Compare commits
No commits in common. "3b3bee5209cf44c60ec788e155c761ebdf0902d0" and "3efaba177fade7f8ee56e780e4bf7decd7933e78" have entirely different histories.
3b3bee5209
...
3efaba177f
7 changed files with 101 additions and 16 deletions
|
@ -24,10 +24,6 @@ jobs:
|
||||||
- name: Setup gradle
|
- name: Setup gradle
|
||||||
uses: gradle/actions/setup-gradle@v4
|
uses: gradle/actions/setup-gradle@v4
|
||||||
|
|
||||||
- name: Build
|
|
||||||
if: gitea.ref == 'refs/heads/master'
|
|
||||||
run: ./gradlew build
|
|
||||||
|
|
||||||
- name: Run build & publish with Gradle Wrapper
|
- name: Run build & publish with Gradle Wrapper
|
||||||
if: gitea.ref == 'refs/heads/master'
|
if: gitea.ref == 'refs/heads/master'
|
||||||
run: chmod +x ./gradlew && ./gradlew publishAllPublicationsToNetheriteRepoRepository -PnetheriteRepoUsername=${{ secrets.REPOSILITE_USER }} -PnetheriteRepoPassword=${{ secrets.REPOSILITE_PASSWORD }}
|
run: chmod +x ./gradlew && ./gradlew build publishAllPublicationsToMavenRepository -PnetheriteRepoUsername=${{ secrets.REPOSILITE_USER }} -PnetheriteRepoPassword=${{ secrets.REPOSILITE_PASSWORD }}
|
|
@ -1,6 +1,7 @@
|
||||||
plugins {
|
plugins {
|
||||||
entitylib.`shadow-conventions`
|
entitylib.`shadow-conventions`
|
||||||
entitylib.`library-conventions`
|
entitylib.`library-conventions`
|
||||||
|
`el-version`
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
@ -9,3 +10,21 @@ dependencies {
|
||||||
compileOnly(libs.bundles.adventure)
|
compileOnly(libs.bundles.adventure)
|
||||||
compileOnly(libs.packetevents.api)
|
compileOnly(libs.packetevents.api)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tasks {
|
||||||
|
javadoc {
|
||||||
|
mustRunAfter(generateVersionsFile)
|
||||||
|
}
|
||||||
|
|
||||||
|
sourcesJar {
|
||||||
|
mustRunAfter(generateVersionsFile)
|
||||||
|
}
|
||||||
|
|
||||||
|
withType<JavaCompile> {
|
||||||
|
dependsOn(generateVersionsFile)
|
||||||
|
}
|
||||||
|
|
||||||
|
generateVersionsFile {
|
||||||
|
packageName = "me.tofaa.entitylib.utils"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package me.tofaa.entitylib;
|
package me.tofaa.entitylib;
|
||||||
|
|
||||||
|
import com.github.retrooper.packetevents.util.PEVersion;
|
||||||
|
import me.tofaa.entitylib.utils.ELVersions;
|
||||||
import me.tofaa.entitylib.utils.GithubUpdater;
|
import me.tofaa.entitylib.utils.GithubUpdater;
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
@ -30,4 +32,8 @@ public final class EntityLib {
|
||||||
public static Platform<?> getPlatform() {
|
public static Platform<?> getPlatform() {
|
||||||
return platform;
|
return platform;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static PEVersion getVersion() {
|
||||||
|
return ELVersions.CURRENT;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,17 @@
|
||||||
package me.tofaa.entitylib.utils;
|
package me.tofaa.entitylib.utils;
|
||||||
|
|
||||||
|
import com.github.retrooper.packetevents.util.PEVersion;
|
||||||
|
import com.github.retrooper.packetevents.util.adventure.AdventureSerializer;
|
||||||
|
import com.google.gson.JsonObject;
|
||||||
import me.tofaa.entitylib.EntityLib;
|
import me.tofaa.entitylib.EntityLib;
|
||||||
|
import org.jetbrains.annotations.Blocking;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.net.URLConnection;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
@ -8,11 +19,13 @@ public final class GithubUpdater {
|
||||||
|
|
||||||
private final String org;
|
private final String org;
|
||||||
private final String repo;
|
private final String repo;
|
||||||
|
private final PEVersion currentVersion;
|
||||||
private final Logger logger;
|
private final Logger logger;
|
||||||
|
|
||||||
public GithubUpdater(String org, String repo) {
|
public GithubUpdater(String org, String repo) {
|
||||||
this.org = org;
|
this.org = org;
|
||||||
this.repo = repo;
|
this.repo = repo;
|
||||||
|
this.currentVersion = ELVersions.CURRENT;
|
||||||
this.logger = EntityLib.getPlatform().getLogger();
|
this.logger = EntityLib.getPlatform().getLogger();
|
||||||
|
|
||||||
if (EntityLib.getApi().getSettings().shouldCheckForUpdate()) {
|
if (EntityLib.getApi().getSettings().shouldCheckForUpdate()) {
|
||||||
|
@ -25,7 +38,42 @@ public final class GithubUpdater {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkForUpdates() {
|
private void checkForUpdates() {
|
||||||
logger.log(Level.INFO, "Update checking disabled");
|
CompletableFuture.runAsync(() -> {
|
||||||
|
try {
|
||||||
|
PEVersion latestVersion = getLatestVersion();
|
||||||
|
if (currentVersion.isOlderThan(latestVersion)) {
|
||||||
|
logger.log(Level.WARNING, "You are using an outdated version of EntityLib. Version: " + latestVersion + " is now available.");
|
||||||
|
} else if (currentVersion.equals(latestVersion)) {
|
||||||
|
logger.log(Level.INFO, "No EntityLib updates found.");
|
||||||
|
}
|
||||||
|
} catch (Exception ex) {
|
||||||
|
logger.warning("Failed to check for updates: " + ex.getMessage());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Blocking
|
||||||
|
private PEVersion getLatestVersion() throws IOException {
|
||||||
|
URL url = new URL("https://api.github.com/repos/" + org + "/" + repo + "/releases/latest");
|
||||||
|
URLConnection connection = url.openConnection();
|
||||||
|
connection.addRequestProperty("User-Agent", "Mozilla/5.0");
|
||||||
|
InputStreamReader isr = new InputStreamReader(connection.getInputStream());
|
||||||
|
BufferedReader reader = new BufferedReader(isr);
|
||||||
|
String response = reader.readLine();
|
||||||
|
JsonObject json = AdventureSerializer.getGsonSerializer().serializer().fromJson(response, JsonObject.class);
|
||||||
|
|
||||||
|
reader.close();
|
||||||
|
isr.close();
|
||||||
|
|
||||||
|
if (json.has("tag_name")) {
|
||||||
|
return PEVersion.fromString(json.get("tag_name").getAsString().replaceFirst("^[vV]", ""));
|
||||||
|
}
|
||||||
|
throw new IOException("Could not find name attribute in github api fetch");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
public String getCurrentVersion() {
|
||||||
|
return currentVersion.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getOrg() {
|
public String getOrg() {
|
||||||
|
|
|
@ -22,7 +22,6 @@ fun getVersionMeta(includeHash: Boolean): String {
|
||||||
return "$commitHash-SNAPSHOT"
|
return "$commitHash-SNAPSHOT"
|
||||||
}
|
}
|
||||||
version = "$fullVersion${getVersionMeta(true)}"
|
version = "$fullVersion${getVersionMeta(true)}"
|
||||||
ext["fullVersion"] = fullVersion
|
|
||||||
ext["versionBeta"] = getVersionMeta(true)
|
ext["versionBeta"] = getVersionMeta(true)
|
||||||
ext["versionNoHash"] = "$fullVersion${getVersionMeta(false)}"
|
ext["versionNoHash"] = "$fullVersion${getVersionMeta(false)}"
|
||||||
|
|
||||||
|
|
|
@ -48,14 +48,13 @@ publishing {
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
maven {
|
maven {
|
||||||
val urlHost = "repo.netherite.gg"
|
url = uri("https://git.netherite.gg/api/packages/Netherite-Public/maven")
|
||||||
|
credentials(HttpHeaderCredentials) {
|
||||||
name = "netheriteRepo"
|
name = "Authorization"
|
||||||
url = uri("https://$urlHost/netherite")
|
value = "token ${project.properties["netherite.git.packages.token"]}"
|
||||||
|
}
|
||||||
credentials(PasswordCredentials::class.java)
|
|
||||||
authentication {
|
authentication {
|
||||||
create<BasicAuthentication>("basic")
|
header(HttpHeaderAuthentication)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -64,7 +63,7 @@ publishing {
|
||||||
create<MavenPublication>("EntityLib") {
|
create<MavenPublication>("EntityLib") {
|
||||||
groupId = project.group as String
|
groupId = project.group as String
|
||||||
artifactId = project.name
|
artifactId = project.name
|
||||||
version = rootProject.ext["fullVersion"] as String
|
version = rootProject.ext["versionBeta"] as String
|
||||||
from(components["java"])
|
from(components["java"])
|
||||||
|
|
||||||
pom {
|
pom {
|
||||||
|
|
|
@ -1,11 +1,23 @@
|
||||||
package me.tofaa.entitylib.spigot;
|
package me.tofaa.entitylib.spigot;
|
||||||
|
|
||||||
|
import com.github.retrooper.packetevents.PacketEventsAPI;
|
||||||
|
import io.github.retrooper.packetevents.bstats.bukkit.Metrics;
|
||||||
|
import io.github.retrooper.packetevents.bstats.charts.SimplePie;
|
||||||
import me.tofaa.entitylib.APIConfig;
|
import me.tofaa.entitylib.APIConfig;
|
||||||
|
import me.tofaa.entitylib.EntityLib;
|
||||||
import me.tofaa.entitylib.common.AbstractPlatform;
|
import me.tofaa.entitylib.common.AbstractPlatform;
|
||||||
|
import me.tofaa.entitylib.utils.ConcurrentWeakIdentityHashMap;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
public class SpigotEntityLibPlatform extends AbstractPlatform<JavaPlugin> {
|
public class SpigotEntityLibPlatform extends AbstractPlatform<JavaPlugin> {
|
||||||
|
|
||||||
|
@ -23,6 +35,12 @@ public class SpigotEntityLibPlatform extends AbstractPlatform<JavaPlugin> {
|
||||||
this.setEntityIdProvider(new SpigotEntityIdProvider(this));
|
this.setEntityIdProvider(new SpigotEntityIdProvider(this));
|
||||||
this.api.onLoad();
|
this.api.onLoad();
|
||||||
this.api.onEnable();
|
this.api.onEnable();
|
||||||
|
if (settings.shouldUseBstats()) {
|
||||||
|
PacketEventsAPI<Plugin> pe = (PacketEventsAPI<Plugin>)api.getPacketEvents();
|
||||||
|
Metrics metrics = new Metrics(pe.getPlugin(), 21916);
|
||||||
|
metrics.addCustomChart(new SimplePie("entitylib-version", () -> EntityLib.getVersion().toString()));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue