Compare commits
2 commits
| Author | SHA1 | Date | |
|---|---|---|---|
| daca492c5e | |||
| e19d169425 |
11 changed files with 23 additions and 86 deletions
|
|
@ -4,7 +4,7 @@ plugins {
|
||||||
}
|
}
|
||||||
|
|
||||||
group = "org.adrianvictor"
|
group = "org.adrianvictor"
|
||||||
version = "2.0"
|
version = "2.1.1"
|
||||||
val buildEnv = System.getenv("BUILD_CHANNEL")
|
val buildEnv = System.getenv("BUILD_CHANNEL")
|
||||||
?: if (System.getenv("JITPACK") != null) "jitpack" else "local"
|
?: if (System.getenv("JITPACK") != null) "jitpack" else "local"
|
||||||
|
|
||||||
|
|
@ -86,16 +86,10 @@ mcVersions.forEach { ver ->
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.register("buildAll") {
|
|
||||||
dependsOn(tasks.withType<Jar>())
|
|
||||||
}
|
|
||||||
|
|
||||||
// Task to merge service files
|
|
||||||
val prepareServiceFiles = tasks.register("prepareServiceFiles") {
|
val prepareServiceFiles = tasks.register("prepareServiceFiles") {
|
||||||
val outputDir = layout.buildDirectory.dir("generated/service-files")
|
val outputDir = layout.buildDirectory.dir("generated/service-files")
|
||||||
val serviceFile = "META-INF/services/org.adrianvictor.lib.versioning.VersionedServiceRegistrar"
|
val serviceFile = "META-INF/services/org.adrianvictor.lib.versioning.VersionedServiceRegistrar"
|
||||||
|
|
||||||
// Define inputs
|
|
||||||
val inputFiles = mcVersions.map { ver -> file("src/$ver/resources/$serviceFile") }.filter { it.exists() }
|
val inputFiles = mcVersions.map { ver -> file("src/$ver/resources/$serviceFile") }.filter { it.exists() }
|
||||||
inputs.files(inputFiles)
|
inputs.files(inputFiles)
|
||||||
outputs.dir(outputDir)
|
outputs.dir(outputDir)
|
||||||
|
|
@ -139,7 +133,7 @@ tasks.named<Jar>("jar") {
|
||||||
|
|
||||||
tasks.register<Jar>("bundleAll") {
|
tasks.register<Jar>("bundleAll") {
|
||||||
dependsOn("jar")
|
dependsOn("jar")
|
||||||
// This is now redundant but we keep it for compatibility with previous instructions
|
|
||||||
from(sourceSets["main"].output)
|
from(sourceSets["main"].output)
|
||||||
mcVersions.forEach { ver ->
|
mcVersions.forEach { ver ->
|
||||||
from(sourceSets[ver].output) {
|
from(sourceSets[ver].output) {
|
||||||
|
|
@ -147,7 +141,6 @@ tasks.register<Jar>("bundleAll") {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Include the merged service file
|
|
||||||
from(prepareServiceFiles)
|
from(prepareServiceFiles)
|
||||||
|
|
||||||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||||
|
|
@ -187,7 +180,6 @@ tasks.withType<JavaCompile> {
|
||||||
/* ----------------------------------------- */
|
/* ----------------------------------------- */
|
||||||
|
|
||||||
tasks.runServer {
|
tasks.runServer {
|
||||||
minecraftVersion("1.21.1")
|
minecraftVersion("1.21.11")
|
||||||
// Include ONLY the all-implementations jar as the plugin
|
|
||||||
pluginJars.setFrom(tasks.named("bundleAll"))
|
pluginJars.setFrom(tasks.named("bundleAll"))
|
||||||
}
|
}
|
||||||
|
|
@ -32,7 +32,7 @@ public class Logger implements LoggerProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void error(String text) {
|
public void severe(String text) {
|
||||||
logger.severe(prefix + text);
|
logger.severe(prefix + text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,6 @@ public class Main extends JavaPlugin {
|
||||||
|
|
||||||
boolean registered = false;
|
boolean registered = false;
|
||||||
|
|
||||||
// 1. Load core registrar based on version mapping
|
|
||||||
String coreRegistrar = version.getRegistrarClass();
|
String coreRegistrar = version.getRegistrarClass();
|
||||||
if (coreRegistrar != null) {
|
if (coreRegistrar != null) {
|
||||||
if (loadRegistrar(coreRegistrar)) {
|
if (loadRegistrar(coreRegistrar)) {
|
||||||
|
|
@ -42,12 +41,11 @@ public class Main extends JavaPlugin {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. Load registrars via ServiceLoader for extensibility
|
|
||||||
try {
|
try {
|
||||||
java.util.ServiceLoader<VersionedServiceRegistrar> loader = java.util.ServiceLoader.load(VersionedServiceRegistrar.class, getClassLoader());
|
java.util.ServiceLoader<VersionedServiceRegistrar> loader = java.util.ServiceLoader.load(VersionedServiceRegistrar.class, getClassLoader());
|
||||||
for (VersionedServiceRegistrar registrar : loader) {
|
for (VersionedServiceRegistrar registrar : loader) {
|
||||||
String registrarName = registrar.getClass().getName();
|
String registrarName = registrar.getClass().getName();
|
||||||
// Skip if already registered as core
|
|
||||||
if (registrarName.equals(coreRegistrar)) continue;
|
if (registrarName.equals(coreRegistrar)) continue;
|
||||||
|
|
||||||
if (registerRegistrar(registrar)) {
|
if (registerRegistrar(registrar)) {
|
||||||
|
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
package org.adrianvictor.lib.loading;
|
|
||||||
|
|
||||||
import org.adrianvictor.lib.versioning.VersionedServiceFactory;
|
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
|
||||||
|
|
||||||
public interface ModernRegistrarLoader {
|
|
||||||
void load(VersionedServiceFactory factory, JavaPlugin plugin);
|
|
||||||
}
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
package org.adrianvictor.lib.loading;
|
|
||||||
|
|
||||||
import org.adrianvictor.lib.versioning.VersionedServiceFactory;
|
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
|
||||||
|
|
||||||
public interface RegistrarBridge {
|
|
||||||
void load(VersionedServiceFactory factory, JavaPlugin plugin);
|
|
||||||
}
|
|
||||||
|
|
@ -9,5 +9,16 @@ public interface LoggerProvider {
|
||||||
|
|
||||||
void info(String text);
|
void info(String text);
|
||||||
void warning(String text);
|
void warning(String text);
|
||||||
void error(String text);
|
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
* Does not throw an error.
|
||||||
|
* <p> Use {@link LoggerProvider#severe(String)} instead.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
default void error(String text) {
|
||||||
|
severe(text);
|
||||||
|
}
|
||||||
|
|
||||||
|
void severe(String text);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,26 +4,6 @@ import org.bukkit.Bukkit;
|
||||||
|
|
||||||
public enum MinecraftVersion {
|
public enum MinecraftVersion {
|
||||||
B1_7_3(0, "b1_7_3", "org.adrianvictor.lib.impl.b1_7_3.B1_7_3Registrar"),
|
B1_7_3(0, "b1_7_3", "org.adrianvictor.lib.impl.b1_7_3.B1_7_3Registrar"),
|
||||||
V1_1(1, "r1_1", "org.adrianvictor.lib.impl.r1_21.R1_21Registrar"),
|
|
||||||
V1_2(2, "r1_1", "org.adrianvictor.lib.impl.r1_21.R1_21Registrar"),
|
|
||||||
V1_3(3, "r1_1", "org.adrianvictor.lib.impl.r1_21.R1_21Registrar"),
|
|
||||||
V1_4(4, "r1_1", "org.adrianvictor.lib.impl.r1_21.R1_21Registrar"),
|
|
||||||
V1_5(5, "r1_1", "org.adrianvictor.lib.impl.r1_21.R1_21Registrar"),
|
|
||||||
V1_6(6, "r1_1", "org.adrianvictor.lib.impl.r1_21.R1_21Registrar"),
|
|
||||||
V1_7(7, "r1_1", "org.adrianvictor.lib.impl.r1_21.R1_21Registrar"),
|
|
||||||
V1_8(8, "r1_1", "org.adrianvictor.lib.impl.r1_21.R1_21Registrar"),
|
|
||||||
V1_9(9, "r1_1", "org.adrianvictor.lib.impl.r1_21.R1_21Registrar"),
|
|
||||||
V1_10(10, "r1_1", "org.adrianvictor.lib.impl.r1_21.R1_21Registrar"),
|
|
||||||
V1_11(11, "r1_1", "org.adrianvictor.lib.impl.r1_21.R1_21Registrar"),
|
|
||||||
V1_12(12, "r1_1", "org.adrianvictor.lib.impl.r1_21.R1_21Registrar"),
|
|
||||||
V1_13(13, "r1_1", "org.adrianvictor.lib.impl.r1_21.R1_21Registrar"),
|
|
||||||
V1_14(14, "r1_1", "org.adrianvictor.lib.impl.r1_21.R1_21Registrar"),
|
|
||||||
V1_15(15, "r1_1", "org.adrianvictor.lib.impl.r1_21.R1_21Registrar"),
|
|
||||||
V1_16(16, "r1_16_5", "org.adrianvictor.lib.impl.r1_21.R1_21Registrar"),
|
|
||||||
V1_17(17, "r1_16_5", "org.adrianvictor.lib.impl.r1_21.R1_21Registrar"),
|
|
||||||
V1_18(18, "r1_16_5", "org.adrianvictor.lib.impl.r1_21.R1_21Registrar"),
|
|
||||||
V1_19(19, "r1_16_5", "org.adrianvictor.lib.impl.r1_21.R1_21Registrar"),
|
|
||||||
V1_20(20, "r1_16_5", "org.adrianvictor.lib.impl.r1_21.R1_21Registrar"),
|
|
||||||
V1_21(21, "r1_21", "org.adrianvictor.lib.impl.r1_21.R1_21Registrar"),
|
V1_21(21, "r1_21", "org.adrianvictor.lib.impl.r1_21.R1_21Registrar"),
|
||||||
UNKNOWN(-1, "unknown");
|
UNKNOWN(-1, "unknown");
|
||||||
|
|
||||||
|
|
@ -64,28 +44,7 @@ public enum MinecraftVersion {
|
||||||
String bukkitVersion = Bukkit.getBukkitVersion();
|
String bukkitVersion = Bukkit.getBukkitVersion();
|
||||||
String mcVer = bukkitVersion.split("-")[0];
|
String mcVer = bukkitVersion.split("-")[0];
|
||||||
|
|
||||||
if (mcVer.startsWith("1.21")) return V1_21;
|
//if (mcVer.startsWith("1.21")) return V1_21;
|
||||||
if (mcVer.startsWith("1.20")) return V1_20;
|
return V1_21;
|
||||||
if (mcVer.startsWith("1.19")) return V1_19;
|
|
||||||
if (mcVer.startsWith("1.18")) return V1_18;
|
|
||||||
if (mcVer.startsWith("1.17")) return V1_17;
|
|
||||||
if (mcVer.startsWith("1.16")) return V1_16;
|
|
||||||
if (mcVer.startsWith("1.15")) return V1_15;
|
|
||||||
if (mcVer.startsWith("1.14")) return V1_14;
|
|
||||||
if (mcVer.startsWith("1.13")) return V1_13;
|
|
||||||
if (mcVer.startsWith("1.12")) return V1_12;
|
|
||||||
if (mcVer.startsWith("1.11")) return V1_11;
|
|
||||||
if (mcVer.startsWith("1.10")) return V1_10;
|
|
||||||
if (mcVer.startsWith("1.9")) return V1_9;
|
|
||||||
if (mcVer.startsWith("1.8")) return V1_8;
|
|
||||||
if (mcVer.startsWith("1.7")) return V1_7;
|
|
||||||
if (mcVer.startsWith("1.6")) return V1_6;
|
|
||||||
if (mcVer.startsWith("1.5")) return V1_5;
|
|
||||||
if (mcVer.startsWith("1.4")) return V1_4;
|
|
||||||
if (mcVer.startsWith("1.3")) return V1_3;
|
|
||||||
if (mcVer.startsWith("1.2")) return V1_2;
|
|
||||||
if (mcVer.startsWith("1.1")) return V1_1;
|
|
||||||
|
|
||||||
return UNKNOWN;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,16 +16,9 @@ public class VersionMatcher {
|
||||||
|
|
||||||
List<String> suffixes = new ArrayList<>();
|
List<String> suffixes = new ArrayList<>();
|
||||||
|
|
||||||
// Add suffixes in order of specificity (newest/most specific first)
|
|
||||||
if (version.isAtLeast(MinecraftVersion.V1_21)) {
|
if (version.isAtLeast(MinecraftVersion.V1_21)) {
|
||||||
suffixes.add("r1_21");
|
suffixes.add("r1_21");
|
||||||
}
|
}
|
||||||
if (version.isAtLeast(MinecraftVersion.V1_16)) {
|
|
||||||
suffixes.add("r1_16_5");
|
|
||||||
}
|
|
||||||
if (version.isAtLeast(MinecraftVersion.V1_1)) {
|
|
||||||
suffixes.add("r1_1");
|
|
||||||
}
|
|
||||||
if (version == MinecraftVersion.B1_7_3) {
|
if (version == MinecraftVersion.B1_7_3) {
|
||||||
suffixes.add("b1_7_3");
|
suffixes.add("b1_7_3");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,5 +4,5 @@ database: false
|
||||||
main: org.adrianvictor.lib.Main
|
main: org.adrianvictor.lib.Main
|
||||||
startup: startup
|
startup: startup
|
||||||
url: https://adrianvic.github.io
|
url: https://adrianvic.github.io
|
||||||
version: '2.1'
|
version: '2.1.1'
|
||||||
api-version: '1.21'
|
api-version: '1.21'
|
||||||
|
|
@ -28,8 +28,8 @@ public class R1_21Registrar implements VersionedServiceRegistrar {
|
||||||
@Override
|
@Override
|
||||||
public void register(VersionedServiceFactory factory) {
|
public void register(VersionedServiceFactory factory) {
|
||||||
Logger.setPlugin(this.plugin);
|
Logger.setPlugin(this.plugin);
|
||||||
factory.register(ConfigurationProvider.class, "r1_1", Configuration::new);
|
factory.register(ConfigurationProvider.class, "r1_21", Configuration::new); // min 1.1
|
||||||
factory.register(TextColorProvider.class, "r1_16_5", TextColor::new);
|
factory.register(TextColorProvider.class, "r1_21", TextColor::new); // min 1.16.5
|
||||||
factory.register(LoggerProvider.class, "r1_21", Logger::new);
|
factory.register(LoggerProvider.class, "r1_21", Logger::new);
|
||||||
factory.register(FileProvider.class, "r1_21", File::new);
|
factory.register(FileProvider.class, "r1_21", File::new);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ public class Logger implements LoggerProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void error(String text) {
|
public void severe(String text) {
|
||||||
logger.severe(text);
|
logger.severe(text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue