diff --git a/pom.xml b/pom.xml index 946ccf2..6d5beba 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 net.sourcewriters.minecraft vcompat-parent - 3.0.5 + 3.0.6 pom diff --git a/vcompat-1_17_R1/pom.xml b/vcompat-1_17_R1/pom.xml index b06153a..d003b12 100644 --- a/vcompat-1_17_R1/pom.xml +++ b/vcompat-1_17_R1/pom.xml @@ -3,7 +3,7 @@ net.sourcewriters.minecraft vcompat-parent - 3.0.5 + 3.0.6 vcompat-1_17_R1 diff --git a/vcompat-1_17_R1/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_17_R1/tools/ServerTools1_17_R1.java b/vcompat-1_17_R1/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_17_R1/tools/ServerTools1_17_R1.java index 6777320..9ce3050 100644 --- a/vcompat-1_17_R1/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_17_R1/tools/ServerTools1_17_R1.java +++ b/vcompat-1_17_R1/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_17_R1/tools/ServerTools1_17_R1.java @@ -17,6 +17,11 @@ public void setMotd(String text) { public String getMotd() { return ((CraftServer) Bukkit.getServer()).getServer().getMotd(); } + + @Override + public String getLevelName() { + return ((CraftServer) Bukkit.getServer()).getServer().getProperties().levelName; + } @Override public ConsoleReaderWrapper1_17_R1 getConsole() { diff --git a/vcompat-1_18_R1/pom.xml b/vcompat-1_18_R1/pom.xml index 29a245e..b3319ac 100644 --- a/vcompat-1_18_R1/pom.xml +++ b/vcompat-1_18_R1/pom.xml @@ -3,7 +3,7 @@ net.sourcewriters.minecraft vcompat-parent - 3.0.5 + 3.0.6 vcompat-1_18_R1 diff --git a/vcompat-1_18_R1/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_18_R1/tools/ServerTools1_18_R1.java b/vcompat-1_18_R1/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_18_R1/tools/ServerTools1_18_R1.java index 4a18f4f..8dfb657 100644 --- a/vcompat-1_18_R1/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_18_R1/tools/ServerTools1_18_R1.java +++ b/vcompat-1_18_R1/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_18_R1/tools/ServerTools1_18_R1.java @@ -17,6 +17,11 @@ public void setMotd(String text) { public String getMotd() { return ((CraftServer) Bukkit.getServer()).getServer().getMotd(); } + + @Override + public String getLevelName() { + return ((CraftServer) Bukkit.getServer()).getServer().getProperties().levelName; + } @Override public ConsoleReaderWrapper1_18_R1 getConsole() { diff --git a/vcompat-1_18_R2/pom.xml b/vcompat-1_18_R2/pom.xml index 28cc751..34d6aab 100644 --- a/vcompat-1_18_R2/pom.xml +++ b/vcompat-1_18_R2/pom.xml @@ -3,7 +3,7 @@ net.sourcewriters.minecraft vcompat-parent - 3.0.5 + 3.0.6 vcompat-1_18_R2 diff --git a/vcompat-1_18_R2/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_18_R2/tools/ServerTools1_18_R2.java b/vcompat-1_18_R2/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_18_R2/tools/ServerTools1_18_R2.java index 4ca1572..618f5d6 100644 --- a/vcompat-1_18_R2/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_18_R2/tools/ServerTools1_18_R2.java +++ b/vcompat-1_18_R2/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_18_R2/tools/ServerTools1_18_R2.java @@ -17,6 +17,11 @@ public void setMotd(String text) { public String getMotd() { return ((CraftServer) Bukkit.getServer()).getServer().getMotd(); } + + @Override + public String getLevelName() { + return ((CraftServer) Bukkit.getServer()).getServer().getProperties().levelName; + } @Override public ConsoleReaderWrapper1_18_R2 getConsole() { diff --git a/vcompat-1_19_R1/pom.xml b/vcompat-1_19_R1/pom.xml index 0238061..625acf7 100644 --- a/vcompat-1_19_R1/pom.xml +++ b/vcompat-1_19_R1/pom.xml @@ -5,7 +5,7 @@ net.sourcewriters.minecraft vcompat-parent - 3.0.5 + 3.0.6 vcompat-1_19_R1 diff --git a/vcompat-1_19_R1/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_19_R1/tools/ServerTools1_19_R1.java b/vcompat-1_19_R1/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_19_R1/tools/ServerTools1_19_R1.java index 394e7ad..e752dfb 100644 --- a/vcompat-1_19_R1/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_19_R1/tools/ServerTools1_19_R1.java +++ b/vcompat-1_19_R1/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_19_R1/tools/ServerTools1_19_R1.java @@ -17,6 +17,11 @@ public void setMotd(String text) { public String getMotd() { return ((CraftServer) Bukkit.getServer()).getServer().getMotd(); } + + @Override + public String getLevelName() { + return ((CraftServer) Bukkit.getServer()).getServer().getProperties().levelName; + } @Override public ConsoleReaderWrapper1_19_R1 getConsole() { diff --git a/vcompat-api/pom.xml b/vcompat-api/pom.xml index 147ac96..36a2d67 100644 --- a/vcompat-api/pom.xml +++ b/vcompat-api/pom.xml @@ -3,7 +3,7 @@ net.sourcewriters.minecraft vcompat-parent - 3.0.5 + 3.0.6 vcompat-api diff --git a/vcompat-api/src/main/java/net/sourcewriters/minecraft/vcompat/provider/tools/ServerTools.java b/vcompat-api/src/main/java/net/sourcewriters/minecraft/vcompat/provider/tools/ServerTools.java index a28d521..c706e28 100644 --- a/vcompat-api/src/main/java/net/sourcewriters/minecraft/vcompat/provider/tools/ServerTools.java +++ b/vcompat-api/src/main/java/net/sourcewriters/minecraft/vcompat/provider/tools/ServerTools.java @@ -1,13 +1,29 @@ package net.sourcewriters.minecraft.vcompat.provider.tools; +import java.io.File; + +import org.bukkit.Bukkit; + import net.sourcewriters.minecraft.vcompat.provider.wrapper.ConsoleReaderWrapper; public abstract class ServerTools { + + private final File worldFolder; + + public ServerTools() { + this.worldFolder = new File(Bukkit.getServer().getWorldContainer(), getLevelName()); + } public abstract void setMotd(String text); public abstract String getMotd(); + public abstract String getLevelName(); + + public final File getWorldFolder() { + return worldFolder; + } + public abstract ConsoleReaderWrapper getConsole(); } \ No newline at end of file diff --git a/vcompat-core/pom.xml b/vcompat-core/pom.xml index e2b97e7..f1705c4 100644 --- a/vcompat-core/pom.xml +++ b/vcompat-core/pom.xml @@ -3,7 +3,7 @@ net.sourcewriters.minecraft vcompat-parent - 3.0.5 + 3.0.6 vcompat diff --git a/vcompat-core/src/main/java/net/sourcewriters/minecraft/vcompat/VersionCompat.java b/vcompat-core/src/main/java/net/sourcewriters/minecraft/vcompat/VersionCompat.java index bef3a42..7f0c5cc 100644 --- a/vcompat-core/src/main/java/net/sourcewriters/minecraft/vcompat/VersionCompat.java +++ b/vcompat-core/src/main/java/net/sourcewriters/minecraft/vcompat/VersionCompat.java @@ -1,7 +1,9 @@ package net.sourcewriters.minecraft.vcompat; +import java.lang.invoke.MethodHandles; +import java.lang.invoke.MethodType; + import net.sourcewriters.minecraft.vcompat.provider.VersionControl; -import net.sourcewriters.minecraft.vcompat.provider.lookup.handle.ClassLookup; import net.sourcewriters.minecraft.vcompat.shaded.syntaxapi.utils.java.tools.Container; import net.sourcewriters.minecraft.vcompat.version.Versions; @@ -24,18 +26,21 @@ protected final void init() throws Exception { @Override protected final void shutdown() { - if(!init) { + if (!init) { return; } control.ifPresent(VersionControl::shutdown); } private final VersionControl initControl() { - Object object = ClassLookup.of(VERSION_PATH).searchMethod("init", "init").run("init"); - if (object == null || !(object instanceof VersionControl)) { - throw new IllegalStateException("Can't initialize VersionControl"); + try { + Class clazz = Class.forName(VERSION_PATH, true, getClass().getClassLoader()); + Object object = MethodHandles.privateLookupIn(clazz, MethodHandles.lookup()) + .findStatic(clazz, "init", MethodType.methodType(clazz)).invoke(); + return (VersionControl) object; + } catch (Throwable e) { + throw new IllegalStateException("Couldn't initialize VersionControl", e); } - return (VersionControl) object; } @Override diff --git a/vcompat-legacy/pom.xml b/vcompat-legacy/pom.xml index d1f2a60..1c40646 100644 --- a/vcompat-legacy/pom.xml +++ b/vcompat-legacy/pom.xml @@ -3,7 +3,7 @@ net.sourcewriters.minecraft vcompat-parent - 3.0.5 + 3.0.6 vcompat-legacy diff --git a/vcompat-legacy/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_10_R1/PlayerProvider1_10_R1.java b/vcompat-legacy/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_10_R1/PlayerProvider1_10_R1.java index 165c32a..a3dc86e 100644 --- a/vcompat-legacy/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_10_R1/PlayerProvider1_10_R1.java +++ b/vcompat-legacy/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_10_R1/PlayerProvider1_10_R1.java @@ -3,7 +3,6 @@ import java.io.File; import java.util.UUID; -import org.bukkit.Bukkit; import org.bukkit.entity.Player; import net.sourcewriters.minecraft.vcompat.provider.impl.v1_10_R1.entity.Player1_10_R1; @@ -18,8 +17,9 @@ public class PlayerProvider1_10_R1 extends PlayerProvider protected PlayerProvider1_10_R1(VersionControl1_10_R1 versionControl) { super(versionControl); - distributor = versionControl.getDataProvider().createDistributor(new File(Bukkit.getWorlds().get(0).getWorldFolder(), "playerdata"), - uuid -> "custom_" + uuid.toString(), DataProvider.DEFAULT_RANDOM); + distributor = versionControl.getDataProvider().createDistributor( + new File(versionControl.getToolProvider().getServerTools().getWorldFolder(), "playerdata"), uuid -> "custom_" + uuid.toString(), + DataProvider.DEFAULT_RANDOM); } @Override diff --git a/vcompat-legacy/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_10_R1/tools/ServerTools1_10_R1.java b/vcompat-legacy/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_10_R1/tools/ServerTools1_10_R1.java index 3991040..6bf5513 100644 --- a/vcompat-legacy/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_10_R1/tools/ServerTools1_10_R1.java +++ b/vcompat-legacy/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_10_R1/tools/ServerTools1_10_R1.java @@ -17,6 +17,11 @@ public void setMotd(String text) { public String getMotd() { return ((CraftServer) Bukkit.getServer()).getServer().getMotd(); } + + @Override + public String getLevelName() { + return ((CraftServer) Bukkit.getServer()).getServer().getPropertyManager().getString("level-name", "world"); + } @Override public ConsoleReaderWrapper1_10_R1 getConsole() { diff --git a/vcompat-legacy/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_11_R1/PlayerProvider1_11_R1.java b/vcompat-legacy/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_11_R1/PlayerProvider1_11_R1.java index 1d80788..e959fdd 100644 --- a/vcompat-legacy/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_11_R1/PlayerProvider1_11_R1.java +++ b/vcompat-legacy/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_11_R1/PlayerProvider1_11_R1.java @@ -3,7 +3,6 @@ import java.io.File; import java.util.UUID; -import org.bukkit.Bukkit; import org.bukkit.entity.Player; import net.sourcewriters.minecraft.vcompat.provider.impl.v1_11_R1.entity.Player1_11_R1; @@ -18,8 +17,9 @@ public class PlayerProvider1_11_R1 extends PlayerProvider protected PlayerProvider1_11_R1(VersionControl1_11_R1 versionControl) { super(versionControl); - distributor = versionControl.getDataProvider().createDistributor(new File(Bukkit.getWorlds().get(0).getWorldFolder(), "playerdata"), - uuid -> "custom_" + uuid.toString(), DataProvider.DEFAULT_RANDOM); + distributor = versionControl.getDataProvider().createDistributor( + new File(versionControl.getToolProvider().getServerTools().getWorldFolder(), "playerdata"), uuid -> "custom_" + uuid.toString(), + DataProvider.DEFAULT_RANDOM); } @Override diff --git a/vcompat-legacy/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_11_R1/tools/ServerTools1_11_R1.java b/vcompat-legacy/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_11_R1/tools/ServerTools1_11_R1.java index a57cdfd..5498a02 100644 --- a/vcompat-legacy/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_11_R1/tools/ServerTools1_11_R1.java +++ b/vcompat-legacy/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_11_R1/tools/ServerTools1_11_R1.java @@ -17,6 +17,11 @@ public void setMotd(String text) { public String getMotd() { return ((CraftServer) Bukkit.getServer()).getServer().getMotd(); } + + @Override + public String getLevelName() { + return ((CraftServer) Bukkit.getServer()).getServer().getPropertyManager().getString("level-name", "world"); + } @Override public ConsoleReaderWrapper1_11_R1 getConsole() { diff --git a/vcompat-legacy/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_12_R1/PlayerProvider1_12_R1.java b/vcompat-legacy/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_12_R1/PlayerProvider1_12_R1.java index de78a7f..c4ca478 100644 --- a/vcompat-legacy/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_12_R1/PlayerProvider1_12_R1.java +++ b/vcompat-legacy/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_12_R1/PlayerProvider1_12_R1.java @@ -3,7 +3,6 @@ import java.io.File; import java.util.UUID; -import org.bukkit.Bukkit; import org.bukkit.entity.Player; import net.sourcewriters.minecraft.vcompat.provider.impl.v1_12_R1.entity.Player1_12_R1; @@ -18,8 +17,9 @@ public class PlayerProvider1_12_R1 extends PlayerProvider protected PlayerProvider1_12_R1(VersionControl1_12_R1 versionControl) { super(versionControl); - distributor = versionControl.getDataProvider().createDistributor(new File(Bukkit.getWorlds().get(0).getWorldFolder(), "playerdata"), - uuid -> "custom_" + uuid.toString(), DataProvider.DEFAULT_RANDOM); + distributor = versionControl.getDataProvider().createDistributor( + new File(versionControl.getToolProvider().getServerTools().getWorldFolder(), "playerdata"), uuid -> "custom_" + uuid.toString(), + DataProvider.DEFAULT_RANDOM); } @Override diff --git a/vcompat-legacy/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_12_R1/tools/ServerTools1_12_R1.java b/vcompat-legacy/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_12_R1/tools/ServerTools1_12_R1.java index a97ade4..639c723 100644 --- a/vcompat-legacy/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_12_R1/tools/ServerTools1_12_R1.java +++ b/vcompat-legacy/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_12_R1/tools/ServerTools1_12_R1.java @@ -17,6 +17,11 @@ public void setMotd(String text) { public String getMotd() { return ((CraftServer) Bukkit.getServer()).getServer().getMotd(); } + + @Override + public String getLevelName() { + return ((CraftServer) Bukkit.getServer()).getServer().getPropertyManager().getString("level-name", "world"); + } @Override public ConsoleReaderWrapper1_12_R1 getConsole() { diff --git a/vcompat-legacy/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_13_R1/PlayerProvider1_13_R1.java b/vcompat-legacy/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_13_R1/PlayerProvider1_13_R1.java index 92a3341..4332129 100644 --- a/vcompat-legacy/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_13_R1/PlayerProvider1_13_R1.java +++ b/vcompat-legacy/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_13_R1/PlayerProvider1_13_R1.java @@ -3,7 +3,6 @@ import java.io.File; import java.util.UUID; -import org.bukkit.Bukkit; import org.bukkit.entity.Player; import net.sourcewriters.minecraft.vcompat.provider.impl.v1_13_R1.entity.Player1_13_R1; @@ -18,8 +17,9 @@ public class PlayerProvider1_13_R1 extends PlayerProvider protected PlayerProvider1_13_R1(VersionControl1_13_R1 versionControl) { super(versionControl); - distributor = versionControl.getDataProvider().createDistributor(new File(Bukkit.getWorlds().get(0).getWorldFolder(), "playerdata"), - uuid -> "custom_" + uuid.toString(), DataProvider.DEFAULT_RANDOM); + distributor = versionControl.getDataProvider().createDistributor( + new File(versionControl.getToolProvider().getServerTools().getWorldFolder(), "playerdata"), uuid -> "custom_" + uuid.toString(), + DataProvider.DEFAULT_RANDOM); } @Override diff --git a/vcompat-legacy/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_13_R1/tools/ServerTools1_13_R1.java b/vcompat-legacy/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_13_R1/tools/ServerTools1_13_R1.java index b8dd087..072309b 100644 --- a/vcompat-legacy/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_13_R1/tools/ServerTools1_13_R1.java +++ b/vcompat-legacy/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_13_R1/tools/ServerTools1_13_R1.java @@ -17,6 +17,11 @@ public void setMotd(String text) { public String getMotd() { return ((CraftServer) Bukkit.getServer()).getServer().getMotd(); } + + @Override + public String getLevelName() { + return ((CraftServer) Bukkit.getServer()).getServer().getPropertyManager().getString("level-name", "world"); + } @Override public ConsoleReaderWrapper1_13_R1 getConsole() { diff --git a/vcompat-legacy/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_13_R2/PlayerProvider1_13_R2.java b/vcompat-legacy/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_13_R2/PlayerProvider1_13_R2.java index c7bbb65..1d38a88 100644 --- a/vcompat-legacy/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_13_R2/PlayerProvider1_13_R2.java +++ b/vcompat-legacy/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_13_R2/PlayerProvider1_13_R2.java @@ -3,7 +3,6 @@ import java.io.File; import java.util.UUID; -import org.bukkit.Bukkit; import org.bukkit.entity.Player; import net.sourcewriters.minecraft.vcompat.provider.impl.v1_13_R2.entity.Player1_13_R2; @@ -18,8 +17,9 @@ public class PlayerProvider1_13_R2 extends PlayerProvider protected PlayerProvider1_13_R2(VersionControl1_13_R2 versionControl) { super(versionControl); - distributor = versionControl.getDataProvider().createDistributor(new File(Bukkit.getWorlds().get(0).getWorldFolder(), "playerdata"), - uuid -> "custom_" + uuid.toString(), DataProvider.DEFAULT_RANDOM); + distributor = versionControl.getDataProvider().createDistributor( + new File(versionControl.getToolProvider().getServerTools().getWorldFolder(), "playerdata"), uuid -> "custom_" + uuid.toString(), + DataProvider.DEFAULT_RANDOM); } @Override diff --git a/vcompat-legacy/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_13_R2/tools/ServerTools1_13_R2.java b/vcompat-legacy/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_13_R2/tools/ServerTools1_13_R2.java index ae4c120..8b32d1c 100644 --- a/vcompat-legacy/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_13_R2/tools/ServerTools1_13_R2.java +++ b/vcompat-legacy/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_13_R2/tools/ServerTools1_13_R2.java @@ -17,6 +17,11 @@ public void setMotd(String text) { public String getMotd() { return ((CraftServer) Bukkit.getServer()).getServer().getMotd(); } + + @Override + public String getLevelName() { + return ((CraftServer) Bukkit.getServer()).getServer().getPropertyManager().getString("level-name", "world"); + } @Override public ConsoleReaderWrapper1_13_R2 getConsole() { diff --git a/vcompat-legacy/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_14_R1/tools/ServerTools1_14_R1.java b/vcompat-legacy/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_14_R1/tools/ServerTools1_14_R1.java index 4bfa15e..e38b904 100644 --- a/vcompat-legacy/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_14_R1/tools/ServerTools1_14_R1.java +++ b/vcompat-legacy/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_14_R1/tools/ServerTools1_14_R1.java @@ -17,6 +17,11 @@ public void setMotd(String text) { public String getMotd() { return ((CraftServer) Bukkit.getServer()).getServer().getMotd(); } + + @Override + public String getLevelName() { + return ((CraftServer) Bukkit.getServer()).getServer().getDedicatedServerProperties().levelName; + } @Override public ConsoleReaderWrapper1_14_R1 getConsole() { diff --git a/vcompat-legacy/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_15_R1/tools/ServerTools1_15_R1.java b/vcompat-legacy/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_15_R1/tools/ServerTools1_15_R1.java index 1c9c05e..88a7888 100644 --- a/vcompat-legacy/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_15_R1/tools/ServerTools1_15_R1.java +++ b/vcompat-legacy/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_15_R1/tools/ServerTools1_15_R1.java @@ -17,6 +17,11 @@ public void setMotd(String text) { public String getMotd() { return ((CraftServer) Bukkit.getServer()).getServer().getMotd(); } + + @Override + public String getLevelName() { + return ((CraftServer) Bukkit.getServer()).getServer().getDedicatedServerProperties().levelName; + } @Override public ConsoleReaderWrapper1_15_R1 getConsole() { diff --git a/vcompat-legacy/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_16_R1/tools/ServerTools1_16_R1.java b/vcompat-legacy/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_16_R1/tools/ServerTools1_16_R1.java index 7238264..4817e10 100644 --- a/vcompat-legacy/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_16_R1/tools/ServerTools1_16_R1.java +++ b/vcompat-legacy/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_16_R1/tools/ServerTools1_16_R1.java @@ -17,6 +17,11 @@ public void setMotd(String text) { public String getMotd() { return ((CraftServer) Bukkit.getServer()).getServer().getMotd(); } + + @Override + public String getLevelName() { + return ((CraftServer) Bukkit.getServer()).getServer().getDedicatedServerProperties().levelName; + } @Override public ConsoleReaderWrapper1_16_R1 getConsole() { diff --git a/vcompat-legacy/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_16_R2/tools/ServerTools1_16_R2.java b/vcompat-legacy/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_16_R2/tools/ServerTools1_16_R2.java index 426b042..ed3f711 100644 --- a/vcompat-legacy/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_16_R2/tools/ServerTools1_16_R2.java +++ b/vcompat-legacy/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_16_R2/tools/ServerTools1_16_R2.java @@ -17,6 +17,11 @@ public void setMotd(String text) { public String getMotd() { return ((CraftServer) Bukkit.getServer()).getServer().getMotd(); } + + @Override + public String getLevelName() { + return ((CraftServer) Bukkit.getServer()).getServer().getDedicatedServerProperties().levelName; + } @Override public ConsoleReaderWrapper1_16_R2 getConsole() { diff --git a/vcompat-legacy/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_16_R3/tools/ServerTools1_16_R3.java b/vcompat-legacy/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_16_R3/tools/ServerTools1_16_R3.java index 230707f..3b627b3 100644 --- a/vcompat-legacy/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_16_R3/tools/ServerTools1_16_R3.java +++ b/vcompat-legacy/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_16_R3/tools/ServerTools1_16_R3.java @@ -17,6 +17,11 @@ public void setMotd(String text) { public String getMotd() { return ((CraftServer) Bukkit.getServer()).getServer().getMotd(); } + + @Override + public String getLevelName() { + return ((CraftServer) Bukkit.getServer()).getServer().getDedicatedServerProperties().levelName; + } @Override public ConsoleReaderWrapper1_16_R3 getConsole() { diff --git a/vcompat-legacy/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_8_R1/PlayerProvider1_8_R1.java b/vcompat-legacy/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_8_R1/PlayerProvider1_8_R1.java index 1d8e6ad..98e78f6 100644 --- a/vcompat-legacy/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_8_R1/PlayerProvider1_8_R1.java +++ b/vcompat-legacy/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_8_R1/PlayerProvider1_8_R1.java @@ -3,7 +3,6 @@ import java.io.File; import java.util.UUID; -import org.bukkit.Bukkit; import org.bukkit.entity.Player; import net.sourcewriters.minecraft.vcompat.provider.impl.v1_8_R1.entity.Player1_8_R1; @@ -18,8 +17,9 @@ public class PlayerProvider1_8_R1 extends PlayerProvider { protected PlayerProvider1_8_R1(VersionControl1_8_R1 versionControl) { super(versionControl); - distributor = versionControl.getDataProvider().createDistributor(new File(Bukkit.getWorlds().get(0).getWorldFolder(), "playerdata"), - uuid -> "custom_" + uuid.toString(), DataProvider.DEFAULT_RANDOM); + distributor = versionControl.getDataProvider().createDistributor( + new File(versionControl.getToolProvider().getServerTools().getWorldFolder(), "playerdata"), uuid -> "custom_" + uuid.toString(), + DataProvider.DEFAULT_RANDOM); } @Override diff --git a/vcompat-legacy/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_8_R1/tools/ServerTools1_8_R1.java b/vcompat-legacy/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_8_R1/tools/ServerTools1_8_R1.java index 898c39e..a19bb95 100644 --- a/vcompat-legacy/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_8_R1/tools/ServerTools1_8_R1.java +++ b/vcompat-legacy/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_8_R1/tools/ServerTools1_8_R1.java @@ -17,6 +17,11 @@ public void setMotd(String text) { public String getMotd() { return ((CraftServer) Bukkit.getServer()).getServer().getMotd(); } + + @Override + public String getLevelName() { + return ((CraftServer) Bukkit.getServer()).getServer().getPropertyManager().getString("level-name", "world"); + } @Override public ConsoleReaderWrapper1_8_R1 getConsole() { diff --git a/vcompat-legacy/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_8_R2/PlayerProvider1_8_R2.java b/vcompat-legacy/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_8_R2/PlayerProvider1_8_R2.java index db0facb..dc05274 100644 --- a/vcompat-legacy/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_8_R2/PlayerProvider1_8_R2.java +++ b/vcompat-legacy/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_8_R2/PlayerProvider1_8_R2.java @@ -3,7 +3,6 @@ import java.io.File; import java.util.UUID; -import org.bukkit.Bukkit; import org.bukkit.entity.Player; import net.sourcewriters.minecraft.vcompat.provider.impl.v1_8_R2.entity.Player1_8_R2; @@ -18,8 +17,9 @@ public class PlayerProvider1_8_R2 extends PlayerProvider { protected PlayerProvider1_8_R2(VersionControl1_8_R2 versionControl) { super(versionControl); - distributor = versionControl.getDataProvider().createDistributor(new File(Bukkit.getWorlds().get(0).getWorldFolder(), "playerdata"), - uuid -> "custom_" + uuid.toString(), DataProvider.DEFAULT_RANDOM); + distributor = versionControl.getDataProvider().createDistributor( + new File(versionControl.getToolProvider().getServerTools().getWorldFolder(), "playerdata"), uuid -> "custom_" + uuid.toString(), + DataProvider.DEFAULT_RANDOM); } @Override diff --git a/vcompat-legacy/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_8_R2/tools/ServerTools1_8_R2.java b/vcompat-legacy/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_8_R2/tools/ServerTools1_8_R2.java index da32424..1a75631 100644 --- a/vcompat-legacy/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_8_R2/tools/ServerTools1_8_R2.java +++ b/vcompat-legacy/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_8_R2/tools/ServerTools1_8_R2.java @@ -18,6 +18,11 @@ public String getMotd() { return ((CraftServer) Bukkit.getServer()).getServer().getMotd(); } + @Override + public String getLevelName() { + return ((CraftServer) Bukkit.getServer()).getServer().getPropertyManager().getString("level-name", "world"); + } + @Override public ConsoleReaderWrapper1_8_R2 getConsole() { return ConsoleReaderWrapper1_8_R2.INSTANCE; diff --git a/vcompat-legacy/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_8_R3/PlayerProvider1_8_R3.java b/vcompat-legacy/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_8_R3/PlayerProvider1_8_R3.java index 9fb94ad..567f6a7 100644 --- a/vcompat-legacy/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_8_R3/PlayerProvider1_8_R3.java +++ b/vcompat-legacy/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_8_R3/PlayerProvider1_8_R3.java @@ -3,7 +3,6 @@ import java.io.File; import java.util.UUID; -import org.bukkit.Bukkit; import org.bukkit.entity.Player; import net.sourcewriters.minecraft.vcompat.provider.impl.v1_8_R3.entity.Player1_8_R3; @@ -18,8 +17,9 @@ public class PlayerProvider1_8_R3 extends PlayerProvider { protected PlayerProvider1_8_R3(VersionControl1_8_R3 versionControl) { super(versionControl); - distributor = versionControl.getDataProvider().createDistributor(new File(Bukkit.getWorlds().get(0).getWorldFolder(), "playerdata"), - uuid -> "custom_" + uuid.toString(), DataProvider.DEFAULT_RANDOM); + distributor = versionControl.getDataProvider().createDistributor( + new File(versionControl.getToolProvider().getServerTools().getWorldFolder(), "playerdata"), uuid -> "custom_" + uuid.toString(), + DataProvider.DEFAULT_RANDOM); } @Override diff --git a/vcompat-legacy/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_8_R3/tools/ServerTools1_8_R3.java b/vcompat-legacy/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_8_R3/tools/ServerTools1_8_R3.java index 15e19bf..547c641 100644 --- a/vcompat-legacy/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_8_R3/tools/ServerTools1_8_R3.java +++ b/vcompat-legacy/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_8_R3/tools/ServerTools1_8_R3.java @@ -17,7 +17,12 @@ public void setMotd(String text) { public String getMotd() { return ((CraftServer) Bukkit.getServer()).getServer().getMotd(); } - + + @Override + public String getLevelName() { + return ((CraftServer) Bukkit.getServer()).getServer().getPropertyManager().getString("level-name", "world"); + } + @Override public ConsoleReaderWrapper1_8_R3 getConsole() { return ConsoleReaderWrapper1_8_R3.INSTANCE; diff --git a/vcompat-legacy/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_9_R1/PlayerProvider1_9_R1.java b/vcompat-legacy/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_9_R1/PlayerProvider1_9_R1.java index 5b7f881..67eb434 100644 --- a/vcompat-legacy/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_9_R1/PlayerProvider1_9_R1.java +++ b/vcompat-legacy/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_9_R1/PlayerProvider1_9_R1.java @@ -3,7 +3,6 @@ import java.io.File; import java.util.UUID; -import org.bukkit.Bukkit; import org.bukkit.entity.Player; import net.sourcewriters.minecraft.vcompat.provider.impl.v1_9_R1.entity.Player1_9_R1; @@ -18,8 +17,9 @@ public class PlayerProvider1_9_R1 extends PlayerProvider { protected PlayerProvider1_9_R1(VersionControl1_9_R1 versionControl) { super(versionControl); - distributor = versionControl.getDataProvider().createDistributor(new File(Bukkit.getWorlds().get(0).getWorldFolder(), "playerdata"), - uuid -> "custom_" + uuid.toString(), DataProvider.DEFAULT_RANDOM); + distributor = versionControl.getDataProvider().createDistributor( + new File(versionControl.getToolProvider().getServerTools().getWorldFolder(), "playerdata"), uuid -> "custom_" + uuid.toString(), + DataProvider.DEFAULT_RANDOM); } @Override diff --git a/vcompat-legacy/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_9_R1/tools/ServerTools1_9_R1.java b/vcompat-legacy/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_9_R1/tools/ServerTools1_9_R1.java index e474e39..8c565f3 100644 --- a/vcompat-legacy/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_9_R1/tools/ServerTools1_9_R1.java +++ b/vcompat-legacy/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_9_R1/tools/ServerTools1_9_R1.java @@ -17,6 +17,11 @@ public void setMotd(String text) { public String getMotd() { return ((CraftServer) Bukkit.getServer()).getServer().getMotd(); } + + @Override + public String getLevelName() { + return ((CraftServer) Bukkit.getServer()).getServer().getPropertyManager().getString("level-name", "world"); + } @Override public ConsoleReaderWrapper1_9_R1 getConsole() { diff --git a/vcompat-legacy/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_9_R2/PlayerProvider1_9_R2.java b/vcompat-legacy/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_9_R2/PlayerProvider1_9_R2.java index f694240..42a368d 100644 --- a/vcompat-legacy/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_9_R2/PlayerProvider1_9_R2.java +++ b/vcompat-legacy/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_9_R2/PlayerProvider1_9_R2.java @@ -3,7 +3,6 @@ import java.io.File; import java.util.UUID; -import org.bukkit.Bukkit; import org.bukkit.entity.Player; import net.sourcewriters.minecraft.vcompat.provider.impl.v1_9_R2.entity.Player1_9_R2; @@ -18,8 +17,9 @@ public class PlayerProvider1_9_R2 extends PlayerProvider { protected PlayerProvider1_9_R2(VersionControl1_9_R2 versionControl) { super(versionControl); - distributor = versionControl.getDataProvider().createDistributor(new File(Bukkit.getWorlds().get(0).getWorldFolder(), "playerdata"), - uuid -> "custom_" + uuid.toString(), DataProvider.DEFAULT_RANDOM); + distributor = versionControl.getDataProvider().createDistributor( + new File(versionControl.getToolProvider().getServerTools().getWorldFolder(), "playerdata"), uuid -> "custom_" + uuid.toString(), + DataProvider.DEFAULT_RANDOM); } @Override diff --git a/vcompat-legacy/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_9_R2/tools/ServerTools1_9_R2.java b/vcompat-legacy/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_9_R2/tools/ServerTools1_9_R2.java index b0a32f1..abac81f 100644 --- a/vcompat-legacy/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_9_R2/tools/ServerTools1_9_R2.java +++ b/vcompat-legacy/src/main/java/net/sourcewriters/minecraft/vcompat/provider/impl/v1_9_R2/tools/ServerTools1_9_R2.java @@ -17,6 +17,11 @@ public void setMotd(String text) { public String getMotd() { return ((CraftServer) Bukkit.getServer()).getServer().getMotd(); } + + @Override + public String getLevelName() { + return ((CraftServer) Bukkit.getServer()).getServer().getPropertyManager().getString("level-name", "world"); + } @Override public ConsoleReaderWrapper1_9_R2 getConsole() {