mirror of
https://github.com/colbster937/originblacklist.git
synced 2026-02-04 11:07:41 +00:00
Compare commits
1 Commits
v2.0.3+91a
...
v2.0.3+581
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
58123dddd7 |
@@ -1,3 +1,5 @@
|
|||||||
|
import groovy.lang.Closure
|
||||||
|
import com.palantir.gradle.gitversion.VersionDetails
|
||||||
import org.gradle.api.tasks.compile.JavaCompile
|
import org.gradle.api.tasks.compile.JavaCompile
|
||||||
import org.gradle.language.jvm.tasks.ProcessResources
|
import org.gradle.language.jvm.tasks.ProcessResources
|
||||||
import xyz.jpenilla.runpaper.task.RunServer
|
import xyz.jpenilla.runpaper.task.RunServer
|
||||||
@@ -26,23 +28,27 @@ val PLUGIN_CTBR = emptyList<String>()
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
val PLUGIN_DEPA_J = getJSONObj(PLUGIN_DEPA)
|
val PLUGIN_DEPA_J = getBukkitBungeeDeps(PLUGIN_DEPA)
|
||||||
val PLUGIN_DEPB_J = getJSONObj(PLUGIN_DEPB)
|
val PLUGIN_DEPB_J = getBukkitBungeeDeps(PLUGIN_DEPB)
|
||||||
val PLUGIN_DEPC_J = getJSONObjMerge(PLUGIN_DEPC, PLUGIN_SDPC)
|
val PLUGIN_DEPC_J = getVelocityDeps(PLUGIN_DEPC, PLUGIN_SDPC)
|
||||||
val PLUGIN_SDPA_J = getJSONObj(PLUGIN_SDPA)
|
val PLUGIN_SDPA_J = getBukkitBungeeDeps(PLUGIN_SDPA)
|
||||||
val PLUGIN_SDPB_J = getJSONObj(PLUGIN_SDPB)
|
val PLUGIN_SDPB_J = getBukkitBungeeDeps(PLUGIN_SDPB)
|
||||||
val PLUGIN_PROV_J = getJSONObj(PLUGIN_PROV)
|
val PLUGIN_PROV_J = getBukkitBungeeDeps(PLUGIN_PROV)
|
||||||
val PLUGIN_ATHR_J = getJSONObj(PLUGIN_ATHR)
|
val PLUGIN_ATHR_J = getBukkitBungeeDeps(PLUGIN_ATHR)
|
||||||
val PLUGIN_CTBR_J = getJSONObj(PLUGIN_CTBR)
|
val PLUGIN_CTBR_J = getBukkitBungeeDeps(PLUGIN_CTBR)
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id("java")
|
id("java")
|
||||||
id("com.gradleup.shadow") version "9.3.0"
|
id("com.gradleup.shadow") version "9.3.0"
|
||||||
|
id("com.palantir.git-version") version "4.2.0"
|
||||||
id("xyz.jpenilla.run-paper") version "3.0.2"
|
id("xyz.jpenilla.run-paper") version "3.0.2"
|
||||||
id("xyz.jpenilla.run-waterfall") version "3.0.2"
|
id("xyz.jpenilla.run-waterfall") version "3.0.2"
|
||||||
id("xyz.jpenilla.run-velocity") version "3.0.2"
|
id("xyz.jpenilla.run-velocity") version "3.0.2"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Suppress("UNCHECKED_CAST")
|
||||||
|
val GIT_INFO = (extra["versionDetails"] as Closure<VersionDetails>)()
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
maven("https://repo.papermc.io/repository/maven-public/")
|
maven("https://repo.papermc.io/repository/maven-public/")
|
||||||
@@ -85,6 +91,23 @@ java {
|
|||||||
toolchain.languageVersion.set(JavaLanguageVersion.of(17))
|
toolchain.languageVersion.set(JavaLanguageVersion.of(17))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val BUILD_PROPS = mapOf(
|
||||||
|
"plugin_name" to PLUGIN_NAME,
|
||||||
|
"plugin_iden" to PLUGIN_IDEN,
|
||||||
|
"plugin_desc" to PLUGIN_DESC,
|
||||||
|
"plugin_vers" to PLUGIN_VERS,
|
||||||
|
"plugin_site" to PLUGIN_SITE,
|
||||||
|
"plugin_depa" to PLUGIN_DEPA_J,
|
||||||
|
"plugin_depb" to PLUGIN_DEPB_J,
|
||||||
|
"plugin_depc" to PLUGIN_DEPC_J,
|
||||||
|
"plugin_sdpa" to PLUGIN_SDPA_J,
|
||||||
|
"plugin_sdpb" to PLUGIN_SDPB_J,
|
||||||
|
"plugin_prov" to PLUGIN_PROV_J,
|
||||||
|
"plugin_athr" to PLUGIN_ATHR_J,
|
||||||
|
"plugin_ctbr" to PLUGIN_CTBR_J,
|
||||||
|
"git_cm_hash" to GIT_INFO.gitHashFull,
|
||||||
|
)
|
||||||
|
|
||||||
tasks.withType<JavaCompile>().configureEach {
|
tasks.withType<JavaCompile>().configureEach {
|
||||||
options.encoding = "UTF-8"
|
options.encoding = "UTF-8"
|
||||||
options.release.set(17)
|
options.release.set(17)
|
||||||
@@ -93,26 +116,24 @@ tasks.withType<JavaCompile>().configureEach {
|
|||||||
tasks.withType<ProcessResources>() {
|
tasks.withType<ProcessResources>() {
|
||||||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||||
outputs.upToDateWhen { false }
|
outputs.upToDateWhen { false }
|
||||||
|
|
||||||
doFirst {
|
doFirst {
|
||||||
filesMatching(listOf("plugin.yml", "bungee.yml", "velocity-plugin.json")) {
|
filesMatching(listOf("plugin.yml", "bungee.yml", "velocity-plugin.json")) {
|
||||||
expand(mapOf(
|
expand(BUILD_PROPS)
|
||||||
"plugin_name" to PLUGIN_NAME,
|
|
||||||
"plugin_iden" to PLUGIN_IDEN,
|
|
||||||
"plugin_desc" to PLUGIN_DESC,
|
|
||||||
"plugin_vers" to PLUGIN_VERS,
|
|
||||||
"plugin_site" to PLUGIN_SITE,
|
|
||||||
"plugin_depa" to PLUGIN_DEPA_J,
|
|
||||||
"plugin_depb" to PLUGIN_DEPB_J,
|
|
||||||
"plugin_depc" to PLUGIN_DEPC_J,
|
|
||||||
"plugin_sdpa" to PLUGIN_SDPA_J,
|
|
||||||
"plugin_sdpb" to PLUGIN_SDPB_J,
|
|
||||||
"plugin_prov" to PLUGIN_PROV_J,
|
|
||||||
"plugin_athr" to PLUGIN_ATHR_J,
|
|
||||||
"plugin_ctbr" to PLUGIN_CTBR_J,
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
doLast {
|
||||||
|
val file = destinationDir.resolve("build.properties")
|
||||||
|
file.parentFile.mkdirs()
|
||||||
|
|
||||||
|
file.writeText(
|
||||||
|
BUILD_PROPS.entries.joinToString("\n") { (k, v) ->
|
||||||
|
"$k = $v"
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
inputs.files(tasks.named<JavaCompile>("compileJava").map { it.outputs.files })
|
inputs.files(tasks.named<JavaCompile>("compileJava").map { it.outputs.files })
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -162,20 +183,15 @@ tasks.register("printVars") {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getJSONObj(list: List<String>): String {
|
fun getBukkitBungeeDeps(list: List<String>): String {
|
||||||
return if (list.isNotEmpty()) {
|
return list.joinToString(
|
||||||
list.joinToString(
|
prefix = "[",
|
||||||
separator = "\", \"",
|
postfix = "]"
|
||||||
prefix = "\"",
|
) { "\"$it\"" }
|
||||||
postfix = "\""
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
""
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getJSONObjMerge(a: List<String>, b: List<String>): String {
|
fun getVelocityDeps(a: List<String>, b: List<String>): String {
|
||||||
val c = a.joinToString(", ") { "{\"id\":\"$it\",\"optional\":false}" }
|
val c = a.joinToString(", ") { "{\"id\":\"$it\",\"optional\":false}" }
|
||||||
val d = b.joinToString(", ") { "{\"id\":\"$it\",\"optional\":true}" }
|
val d = b.joinToString(", ") { "{\"id\":\"$it\",\"optional\":true}" }
|
||||||
return listOf(c, d).filter { it.isNotEmpty() }.joinToString(",")
|
return "[" + listOf(c, d).filter { it.isNotEmpty() }.joinToString(",") + "]"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import xyz.webmc.originblacklist.base.enums.EnumConnectionType;
|
|||||||
import xyz.webmc.originblacklist.base.enums.EnumLogLevel;
|
import xyz.webmc.originblacklist.base.enums.EnumLogLevel;
|
||||||
import xyz.webmc.originblacklist.base.events.OriginBlacklistLoginEvent;
|
import xyz.webmc.originblacklist.base.events.OriginBlacklistLoginEvent;
|
||||||
import xyz.webmc.originblacklist.base.events.OriginBlacklistMOTDEvent;
|
import xyz.webmc.originblacklist.base.events.OriginBlacklistMOTDEvent;
|
||||||
|
import xyz.webmc.originblacklist.base.util.BuildInfo;
|
||||||
import xyz.webmc.originblacklist.base.util.IOriginBlacklistPlugin;
|
import xyz.webmc.originblacklist.base.util.IOriginBlacklistPlugin;
|
||||||
import xyz.webmc.originblacklist.base.util.OPlayer;
|
import xyz.webmc.originblacklist.base.util.OPlayer;
|
||||||
import xyz.webmc.originblacklist.base.util.UpdateChecker;
|
import xyz.webmc.originblacklist.base.util.UpdateChecker;
|
||||||
@@ -14,8 +15,11 @@ import java.io.InputStream;
|
|||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.net.HttpURLConnection;
|
import java.net.HttpURLConnection;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
import java.net.URLDecoder;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
|
import java.nio.file.Paths;
|
||||||
import java.nio.file.StandardCopyOption;
|
import java.nio.file.StandardCopyOption;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Base64;
|
import java.util.Base64;
|
||||||
@@ -54,6 +58,11 @@ public final class OriginBlacklist {
|
|||||||
}, 60, TimeUnit.MINUTES);
|
}, 60, TimeUnit.MINUTES);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public final void init() {
|
||||||
|
this.plugin.log(EnumLogLevel.INFO, "Initialized Plugin");
|
||||||
|
this.plugin.log(EnumLogLevel.DEBUG, "Commit " + BuildInfo.get("git_cm_hash"));
|
||||||
|
}
|
||||||
|
|
||||||
public final void handleLogin(final OriginBlacklistLoginEvent event) {
|
public final void handleLogin(final OriginBlacklistLoginEvent event) {
|
||||||
final OPlayer player = event.getPlayer();
|
final OPlayer player = event.getPlayer();
|
||||||
final EnumBlacklistType blacklisted = this.testBlacklist(player);
|
final EnumBlacklistType blacklisted = this.testBlacklist(player);
|
||||||
@@ -165,7 +174,7 @@ public final class OriginBlacklist {
|
|||||||
return EnumBlacklistType.ADDR;
|
return EnumBlacklistType.ADDR;
|
||||||
}
|
}
|
||||||
} catch (final AddressStringException exception) {
|
} catch (final AddressStringException exception) {
|
||||||
exception.printStackTrace();
|
// exception.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -275,7 +284,7 @@ public final class OriginBlacklist {
|
|||||||
}
|
}
|
||||||
|
|
||||||
conn.disconnect();
|
conn.disconnect();
|
||||||
} catch (Throwable t) {
|
} catch (final Throwable t) {
|
||||||
t.printStackTrace();
|
t.printStackTrace();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -293,42 +302,49 @@ public final class OriginBlacklist {
|
|||||||
if (!this.config.get("update_checker.auto_update").getAsBoolean()) {
|
if (!this.config.get("update_checker.auto_update").getAsBoolean()) {
|
||||||
this.plugin.log(EnumLogLevel.INFO, "An update is available! Download it at " + this.updateURL);
|
this.plugin.log(EnumLogLevel.INFO, "An update is available! Download it at " + this.updateURL);
|
||||||
} else {
|
} else {
|
||||||
final Path jar = this.plugin.getPluginJarPath();
|
this.updatePlugin();
|
||||||
final Path bak = jar.resolveSibling(jar.getFileName().toString() + ".bak");
|
|
||||||
final Path tmp = jar.resolveSibling(jar.getFileName().toString() + ".tmp");
|
|
||||||
try {
|
|
||||||
Files.copy(jar, bak, StandardCopyOption.REPLACE_EXISTING);
|
|
||||||
} catch (final Throwable t) {
|
|
||||||
t.printStackTrace();
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
final URL url = new URL(this.updateURL);
|
|
||||||
final HttpURLConnection conn = (HttpURLConnection) url.openConnection();
|
|
||||||
conn.setRequestMethod("GET");
|
|
||||||
conn.setConnectTimeout(15000);
|
|
||||||
conn.setReadTimeout(15000);
|
|
||||||
conn.connect();
|
|
||||||
try (final InputStream in = conn.getInputStream()) {
|
|
||||||
Files.copy(in, tmp, StandardCopyOption.REPLACE_EXISTING);
|
|
||||||
} finally {
|
|
||||||
conn.disconnect();
|
|
||||||
}
|
|
||||||
Files.move(tmp, jar, StandardCopyOption.REPLACE_EXISTING);
|
|
||||||
Files.delete(bak);
|
|
||||||
} catch (final Throwable t) {
|
|
||||||
t.printStackTrace();
|
|
||||||
try {
|
|
||||||
Files.move(bak, jar, StandardCopyOption.REPLACE_EXISTING);
|
|
||||||
} catch (final Throwable _t) {
|
|
||||||
_t.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private final void updatePlugin() {
|
||||||
|
try {
|
||||||
|
final URL url = new URL(this.updateURL);
|
||||||
|
final Path jar = this.plugin.getPluginJarPath();
|
||||||
|
final Path bak = jar.resolveSibling(jar.getFileName().toString() + ".bak");
|
||||||
|
final Path upd = jar.resolveSibling(Paths.get(URLDecoder.decode(url.getPath(), StandardCharsets.UTF_8)).getFileName());
|
||||||
|
|
||||||
|
try {
|
||||||
|
Files.copy(jar, bak, StandardCopyOption.REPLACE_EXISTING);
|
||||||
|
} catch (final Throwable t) {
|
||||||
|
t.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
final HttpURLConnection conn = (HttpURLConnection) url.openConnection();
|
||||||
|
conn.setRequestMethod("GET");
|
||||||
|
conn.setConnectTimeout(15000);
|
||||||
|
conn.setReadTimeout(15000);
|
||||||
|
conn.setRequestProperty("User-Agent", OriginBlacklist.getUserAgent());
|
||||||
|
conn.connect();
|
||||||
|
try (final InputStream in = conn.getInputStream()) {
|
||||||
|
Files.copy(in, upd, StandardCopyOption.REPLACE_EXISTING);
|
||||||
|
} finally {
|
||||||
|
conn.disconnect();
|
||||||
|
}
|
||||||
|
Files.delete(jar);
|
||||||
|
Files.delete(bak);
|
||||||
|
} catch (final Throwable t) {
|
||||||
|
t.printStackTrace();
|
||||||
|
Files.move(bak, jar, StandardCopyOption.REPLACE_EXISTING);
|
||||||
|
}
|
||||||
|
} catch (final Throwable t) {
|
||||||
|
t.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static final String getComponentString(final Component comp) {
|
public static final String getComponentString(final Component comp) {
|
||||||
return LegacyComponentSerializer.legacySection().serialize(comp);
|
return LegacyComponentSerializer.legacySection().serialize(comp);
|
||||||
}
|
}
|
||||||
@@ -341,6 +357,10 @@ public final class OriginBlacklist {
|
|||||||
return "data:image/png;base64," + Base64.getEncoder().encodeToString(bytes);
|
return "data:image/png;base64," + Base64.getEncoder().encodeToString(bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static final String getUserAgent() {
|
||||||
|
return BuildInfo.get("plugin_name") + "/" + BuildInfo.get("plugin_vers") + "+" + BuildInfo.get("git_cm_hash");
|
||||||
|
}
|
||||||
|
|
||||||
public static final boolean isNonNull(final String str) {
|
public static final boolean isNonNull(final String str) {
|
||||||
return str != null && !str.isEmpty() && !str.isBlank() && !str.equals("null");
|
return str != null && !str.isEmpty() && !str.isBlank() && !str.equals("null");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package xyz.webmc.originblacklist.base.util;
|
||||||
|
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
|
public class BuildInfo {
|
||||||
|
private static final Properties properties;
|
||||||
|
|
||||||
|
public static final String get(final String key) {
|
||||||
|
return properties.getProperty(key).trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
static {
|
||||||
|
properties = new Properties();
|
||||||
|
try (final InputStream in = BuildInfo.class.getClassLoader().getResourceAsStream("build.properties")) {
|
||||||
|
properties.load(in);
|
||||||
|
} catch (final Throwable t) {}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -17,54 +17,57 @@ import org.semver4j.Semver.VersionDiff;
|
|||||||
public class UpdateChecker {
|
public class UpdateChecker {
|
||||||
private static final Json5 json5 = Json5.builder(builder -> builder.build());
|
private static final Json5 json5 = Json5.builder(builder -> builder.build());
|
||||||
|
|
||||||
public static final String checkForUpdate(final String repo, final Semver currentVersion, final boolean allowPreRelease) {
|
public static final String checkForUpdate(final String repo, final Semver currentVersion, final boolean allowSnapshots) {
|
||||||
try {
|
try {
|
||||||
URL url = new URL("https://api.github.com/repos/" + repo + "/releases");
|
final URL url = new URL("https://api.github.com/repos/" + repo + "/releases");
|
||||||
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
|
final HttpURLConnection conn = (HttpURLConnection) url.openConnection();
|
||||||
conn.setRequestMethod("GET");
|
conn.setRequestMethod("GET");
|
||||||
conn.setConnectTimeout(5000);
|
conn.setConnectTimeout(5000);
|
||||||
conn.setReadTimeout(5000);
|
conn.setReadTimeout(5000);
|
||||||
|
conn.setRequestProperty("User-Agent", OriginBlacklist.getUserAgent());
|
||||||
|
conn.setRequestProperty("Accept", "application/vnd.github+json");
|
||||||
conn.connect();
|
conn.connect();
|
||||||
BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
|
final BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
|
||||||
String ret = null;
|
String ret = null;
|
||||||
Json5Element element = json5.parse(reader);
|
Json5Element element = json5.parse(reader);
|
||||||
|
reader.close();
|
||||||
if (element instanceof Json5Array) {
|
if (element instanceof Json5Array) {
|
||||||
final Json5Array arr = element.getAsJson5Array();
|
final Json5Array arr = element.getAsJson5Array();
|
||||||
if (arr.size() > 0) {
|
if (arr.size() > 0) {
|
||||||
element = arr.get(0);
|
for (int i = 0; i < Math.min(2, arr.size()); i++) {
|
||||||
if (element instanceof Json5Object) {
|
element = arr.get(i);
|
||||||
final Json5Object obj = element.getAsJson5Object();
|
if (element instanceof Json5Object) {
|
||||||
final String tag = obj.get("tag_name").getAsString();
|
final Json5Object obj = element.getAsJson5Object();
|
||||||
final Semver ver = new Semver(tag.substring(1));
|
if (allowSnapshots || !obj.get("prerelease").getAsBoolean()) {
|
||||||
if (ver.isGreaterThan(currentVersion) && (allowPreRelease || currentVersion.diff(ver) != VersionDiff.BUILD)) {
|
final String tag = obj.get("tag_name").getAsString();
|
||||||
element = obj.get("assets");
|
final Semver ver = new Semver(tag.startsWith("v") ? tag.substring(1) : tag);
|
||||||
if (element instanceof Json5Array) {
|
String comm;
|
||||||
final Json5Array aArr = element.getAsJson5Array();
|
try {
|
||||||
element = aArr.get(0);
|
comm = ver.getBuild().get(0).trim();
|
||||||
if (element instanceof Json5Object) {
|
} catch (Throwable t) {
|
||||||
final Json5Object vObj = element.getAsJson5Object();
|
comm = "";
|
||||||
ret = vObj.get("url").getAsString();
|
}
|
||||||
|
if (ver.isGreaterThan(currentVersion) || (allowSnapshots && currentVersion.diff(ver) == VersionDiff.BUILD && OriginBlacklist.isNonNull(comm) && !BuildInfo.get("git_cm_hash").startsWith(comm))) {
|
||||||
|
element = obj.get("assets");
|
||||||
|
if (element instanceof Json5Array) {
|
||||||
|
final Json5Array aArr = element.getAsJson5Array();
|
||||||
|
if (aArr.size() > 0) {
|
||||||
|
element = aArr.get(0);
|
||||||
|
if (element instanceof Json5Object) {
|
||||||
|
final Json5Object vObj = element.getAsJson5Object();
|
||||||
|
ret = vObj.get("browser_download_url").getAsString();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
conn.disconnect();
|
conn.disconnect();
|
||||||
if (OriginBlacklist.isNonNull(ret)) {
|
|
||||||
url = new URL(ret);
|
|
||||||
conn = (HttpURLConnection) url.openConnection();
|
|
||||||
conn.setRequestMethod("GET");
|
|
||||||
conn.setConnectTimeout(5000);
|
|
||||||
conn.setReadTimeout(5000);
|
|
||||||
conn.connect();
|
|
||||||
reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
|
|
||||||
element = json5.parse(reader);
|
|
||||||
if (element instanceof Json5Object) {
|
|
||||||
final Json5Object obj = element.getAsJson5Object();
|
|
||||||
ret = obj.get("browser_download_url").getAsString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ret;
|
return ret;
|
||||||
} catch (final Throwable t) {
|
} catch (final Throwable t) {
|
||||||
t.printStackTrace();
|
t.printStackTrace();
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ public final class OriginBlacklistBukkit extends JavaPlugin implements Listener,
|
|||||||
this.eaglerAPI = EaglerXServerAPI.instance();
|
this.eaglerAPI = EaglerXServerAPI.instance();
|
||||||
this.getCommand("originblacklist").setExecutor(new OriginBlacklistCommandBukkit(this.blacklist));
|
this.getCommand("originblacklist").setExecutor(new OriginBlacklistCommandBukkit(this.blacklist));
|
||||||
this.getServer().getPluginManager().registerEvents(this, this);
|
this.getServer().getPluginManager().registerEvents(this, this);
|
||||||
this.log(EnumLogLevel.INFO, "Initialized Plugin");
|
this.blacklist.init();
|
||||||
if (this.blacklist.isMetricsEnabled()) {
|
if (this.blacklist.isMetricsEnabled()) {
|
||||||
this.metrics = new Metrics(this, OriginBlacklist.BSTATS_ID);
|
this.metrics = new Metrics(this, OriginBlacklist.BSTATS_ID);
|
||||||
this.metrics.addCustomChart(new AdvancedPie("player_types", () -> {
|
this.metrics.addCustomChart(new AdvancedPie("player_types", () -> {
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ public final class OriginBlacklistBungee extends Plugin implements Listener, IOr
|
|||||||
this.eaglerAPI = EaglerXServerAPI.instance();
|
this.eaglerAPI = EaglerXServerAPI.instance();
|
||||||
this.getProxy().getPluginManager().registerCommand(this, new OriginBlacklistCommandBungee(this, this.blacklist, "originblacklist"));
|
this.getProxy().getPluginManager().registerCommand(this, new OriginBlacklistCommandBungee(this, this.blacklist, "originblacklist"));
|
||||||
this.getProxy().getPluginManager().registerListener(this, this);
|
this.getProxy().getPluginManager().registerListener(this, this);
|
||||||
this.log(EnumLogLevel.INFO, "Initialized Plugin");
|
this.blacklist.init();
|
||||||
if (this.blacklist.isMetricsEnabled()) {
|
if (this.blacklist.isMetricsEnabled()) {
|
||||||
this.metrics = new Metrics(this, OriginBlacklist.BSTATS_ID);
|
this.metrics = new Metrics(this, OriginBlacklist.BSTATS_ID);
|
||||||
this.metrics.addCustomChart(new AdvancedPie("player_types", () -> {
|
this.metrics.addCustomChart(new AdvancedPie("player_types", () -> {
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ public final class OriginBlacklistVelocity implements IOriginBlacklistPlugin {
|
|||||||
this.blacklist = new OriginBlacklist(this);
|
this.blacklist = new OriginBlacklist(this);
|
||||||
this.eaglerAPI = EaglerXServerAPI.instance();
|
this.eaglerAPI = EaglerXServerAPI.instance();
|
||||||
this.proxy.getCommandManager().register("originblacklist", new OriginBlacklistCommandVelocity(this.blacklist));
|
this.proxy.getCommandManager().register("originblacklist", new OriginBlacklistCommandVelocity(this.blacklist));
|
||||||
this.log(EnumLogLevel.INFO, "Initialized Plugin");
|
this.blacklist.init();
|
||||||
if (this.blacklist.isMetricsEnabled()) {
|
if (this.blacklist.isMetricsEnabled()) {
|
||||||
this.metrics = this.metricsFactory.make(this, OriginBlacklist.BSTATS_ID);
|
this.metrics = this.metricsFactory.make(this, OriginBlacklist.BSTATS_ID);
|
||||||
this.metrics.addCustomChart(new AdvancedPie("player_types", () -> {
|
this.metrics.addCustomChart(new AdvancedPie("player_types", () -> {
|
||||||
@@ -153,7 +153,7 @@ public final class OriginBlacklistVelocity implements IOriginBlacklistPlugin {
|
|||||||
public final Path getPluginJarPath() {
|
public final Path getPluginJarPath() {
|
||||||
try {
|
try {
|
||||||
return Paths.get(this.getClass().getProtectionDomain().getCodeSource().getLocation().toURI()).toAbsolutePath();
|
return Paths.get(this.getClass().getProtectionDomain().getCodeSource().getLocation().toURI()).toAbsolutePath();
|
||||||
} catch (Throwable t) {
|
} catch (final Throwable t) {
|
||||||
throw new RuntimeException("Unable to determine plugin JAR path");
|
throw new RuntimeException("Unable to determine plugin JAR path");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -166,7 +166,7 @@ public final class OriginBlacklistVelocity implements IOriginBlacklistPlugin {
|
|||||||
this.logger.error(txt);
|
this.logger.error(txt);
|
||||||
} else if (level == EnumLogLevel.DEBUG) {
|
} else if (level == EnumLogLevel.DEBUG) {
|
||||||
if (this.blacklist.isDebugEnabled()) {
|
if (this.blacklist.isDebugEnabled()) {
|
||||||
this.logger.debug(txt);
|
this.logger.info(txt);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.logger.info(txt);
|
this.logger.info(txt);
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ version: ${plugin_vers}
|
|||||||
main: xyz.webmc.${plugin_iden}.bungee.${plugin_name}Bungee
|
main: xyz.webmc.${plugin_iden}.bungee.${plugin_name}Bungee
|
||||||
description: ${plugin_desc}
|
description: ${plugin_desc}
|
||||||
website: ${plugin_site}
|
website: ${plugin_site}
|
||||||
author: [${plugin_athr}]
|
author: ${plugin_athr}
|
||||||
contributors: [${plugin_ctbr}]
|
contributors: ${plugin_ctbr}
|
||||||
depends: [${plugin_depb}]
|
depends: ${plugin_depb}
|
||||||
provides: [${plugin_prov}]
|
provides: ${plugin_prov}
|
||||||
softdepend: [${plugin_sdpb}]
|
softdepend: ${plugin_sdpb}
|
||||||
@@ -3,10 +3,10 @@ version: ${plugin_vers}
|
|||||||
main: xyz.webmc.${plugin_iden}.bukkit.${plugin_name}Bukkit
|
main: xyz.webmc.${plugin_iden}.bukkit.${plugin_name}Bukkit
|
||||||
description: ${plugin_desc}
|
description: ${plugin_desc}
|
||||||
website: ${plugin_site}
|
website: ${plugin_site}
|
||||||
authors: [${plugin_athr}]
|
authors: ${plugin_athr}
|
||||||
contributors: [${plugin_ctbr}]
|
contributors: ${plugin_ctbr}
|
||||||
depend: [${plugin_depa}]
|
depend: ${plugin_depa}
|
||||||
provides: [${plugin_prov}]
|
provides: ${plugin_prov}
|
||||||
softdepend: [${plugin_sdpa}]
|
softdepend: ${plugin_sdpa}
|
||||||
commands:
|
commands:
|
||||||
originblacklist:
|
${plugin_iden}:
|
||||||
@@ -5,6 +5,6 @@
|
|||||||
"description": "${plugin_desc}",
|
"description": "${plugin_desc}",
|
||||||
"website": "${plugin_site}",
|
"website": "${plugin_site}",
|
||||||
"main": "xyz.webmc.${plugin_iden}.velocity.${plugin_name}Velocity",
|
"main": "xyz.webmc.${plugin_iden}.velocity.${plugin_name}Velocity",
|
||||||
"authors": [${plugin_athr}],
|
"authors": ${plugin_athr},
|
||||||
"dependencies": [${plugin_depc}]
|
"dependencies": ${plugin_depc}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user