From dc4776d16b47d222f37c096dd736e833dfa3b02c Mon Sep 17 00:00:00 2001 From: MattBDev Date: Sat, 21 May 2016 10:39:06 -0400 Subject: [PATCH] Sponge changes. --- Sponge/build.gradle | 10 ++-- .../com/plotsquared/sponge/SpongeMain.java | 55 ++++++++++--------- 2 files changed, 33 insertions(+), 32 deletions(-) diff --git a/Sponge/build.gradle b/Sponge/build.gradle index 02a459af2..a73a7ccec 100644 --- a/Sponge/build.gradle +++ b/Sponge/build.gradle @@ -6,10 +6,10 @@ buildscript { name = "forge" url = "http://files.minecraftforge.net/maven" } - maven {url = "http://repo.minecrell.net/snapshots"} + maven {url = "http://repo.minecrell.net/releases"} } dependencies { - classpath 'net.minecrell:VanillaGradle:2.0.3-SNAPSHOT' + classpath 'net.minecrell:VanillaGradle:2.0.3_1' classpath 'net.minecraftforge.gradle:ForgeGradle:2.1-SNAPSHOT' } } @@ -20,7 +20,7 @@ apply plugin: 'com.github.johnrengelman.shadow' dependencies { compile project(':Core') compile 'org.spongepowered:spongeapi:4.+' - compile 'org.mcstats.sponge:metrics:R8-SNAPSHOT' + //compile 'org.mcstats.sponge:metrics:R8-SNAPSHOT' } sourceCompatibility = 1.8 @@ -57,9 +57,9 @@ processResources { shadowJar { dependencies { include(dependency(':Core')) - include(dependency('org.mcstats.sponge:metrics:R8-SNAPSHOT')) + //include(dependency('org.mcstats.sponge:metrics:R8-SNAPSHOT')) } - relocate 'org.mcstats', 'com.plotsquared.stats' + //relocate 'org.mcstats', 'com.plotsquared.stats' archiveName = "${parent.name}-${project.name}-${parent.version}.jar" destinationDir = file '../target' } diff --git a/Sponge/src/main/java/com/plotsquared/sponge/SpongeMain.java b/Sponge/src/main/java/com/plotsquared/sponge/SpongeMain.java index aabbe1d17..8f1a86b1a 100644 --- a/Sponge/src/main/java/com/plotsquared/sponge/SpongeMain.java +++ b/Sponge/src/main/java/com/plotsquared/sponge/SpongeMain.java @@ -52,13 +52,6 @@ import com.plotsquared.sponge.util.block.SlowQueue; import com.plotsquared.sponge.uuid.SpongeLowerOfflineUUIDWrapper; import com.plotsquared.sponge.uuid.SpongeOnlineUUIDWrapper; import com.plotsquared.sponge.uuid.SpongeUUIDHandler; -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.UUID; -import java.util.stream.Collectors; import org.slf4j.Logger; import org.spongepowered.api.Game; import org.spongepowered.api.Server; @@ -77,13 +70,26 @@ import org.spongepowered.api.world.gen.GenerationPopulator; import org.spongepowered.api.world.gen.WorldGenerator; import org.spongepowered.api.world.gen.WorldGeneratorModifier; -@Plugin(id = "com.plotsquared", name = "PlotSquared", description = "Easy, yet powerful Plot World generation and management.", url = "https://github.com/IntellectualSites/PlotSquared", version = "3.3.3") +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.UUID; +import java.util.stream.Collectors; + +@Plugin(id = "PlotSquared", name = "PlotSquared", description = "Easy, yet powerful Plot World generation and management.", url = "https://github" + + ".com/IntellectualSites/PlotSquared", version = "3.3.3") public class SpongeMain implements IPlotMain { + public static SpongeMain THIS; + + @Inject public PluginContainer plugin; @Inject private Logger logger; + @Inject private Game game; private Server server; @@ -123,12 +129,11 @@ public class SpongeMain implements IPlotMain { public void onInit(GamePreInitializationEvent event) { log("PlotSquared: Game pre init"); } - + @Listener public void onServerAboutToStart(GameAboutToStartServerEvent event) { log("PlotSquared: Server init"); THIS = this; - THIS.plugin = this.game.getPluginManager().fromInstance(this).get(); new PS(this, "Sponge"); this.server = this.game.getServer(); this.game.getRegistry().register(WorldGeneratorModifier.class, (WorldGeneratorModifier) new HybridGen().specify()); @@ -154,7 +159,7 @@ public class SpongeMain implements IPlotMain { @Override public File getWorldContainer() { - return new File("world"); + return game.getSavesDirectory().toFile(); } @Override @@ -165,8 +170,7 @@ public class SpongeMain implements IPlotMain { @Override public int[] getPluginVersion() { - PluginContainer plugin = this.game.getPluginManager().fromInstance(this).get(); - String version = plugin.getVersion().orElse(""); + String version = this.plugin.getVersion().orElse(""); String[] split = version.split("\\."); return new int[]{Integer.parseInt(split[0]), Integer.parseInt(split[1]), split.length == 3 ? Integer.parseInt(split[2]) : 0}; } @@ -266,7 +270,7 @@ public class SpongeMain implements IPlotMain { @Override public UUIDHandlerImplementation initUUIDHandler() { UUIDWrapper wrapper; - if (Settings.OFFLINE_MODE || !PS.get().checkVersion(getServerVersion(), 1, 7, 6)) { + if (Settings.OFFLINE_MODE) { wrapper = new SpongeLowerOfflineUUIDWrapper(); } else { wrapper = new SpongeOnlineUUIDWrapper(); @@ -276,7 +280,6 @@ public class SpongeMain implements IPlotMain { @Override public boolean initPlotMeConverter() { - // PlotMe was never ported to sponge return false; } @@ -370,25 +373,23 @@ public class SpongeMain implements IPlotMain { public ChatManager initChatManager() { return new SpongeChatManager(); } - + @Override public PlotQueue initPlotQueue() { - if (PS.get().checkVersion(getServerVersion(), 1, 8, 0)) { - try { - MainUtil.canSendChunk = true; - return new FastQueue(); - } catch (RuntimeException e) { - e.printStackTrace(); - } + try { + MainUtil.canSendChunk = true; + return new FastQueue(); + } catch (RuntimeException e) { + e.printStackTrace(); } return new SlowQueue(); } - + @Override public WorldUtil initWorldUtil() { return new SpongeUtil(); } - + @Override public GeneratorWrapper getGenerator(String world, String name) { if (name == null) { @@ -405,12 +406,12 @@ public class SpongeMain implements IPlotMain { } return new SpongePlotGenerator(new HybridGen()); } - + @Override public GeneratorWrapper wrapPlotGenerator(IndependentPlotGenerator generator) { return new SpongePlotGenerator(generator); } - + @Override public List getPluginIds() { return this.game.getPluginManager().getPlugins().stream().map(plugin1 -> plugin1.getName() + ';' + plugin1.getVersion() + ':' + true)