Sponge changes.

This commit is contained in:
MattBDev 2016-05-21 10:39:06 -04:00
parent b51d659ff9
commit dc4776d16b
2 changed files with 33 additions and 32 deletions

View File

@ -6,10 +6,10 @@ buildscript {
name = "forge" name = "forge"
url = "http://files.minecraftforge.net/maven" url = "http://files.minecraftforge.net/maven"
} }
maven {url = "http://repo.minecrell.net/snapshots"} maven {url = "http://repo.minecrell.net/releases"}
} }
dependencies { 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' classpath 'net.minecraftforge.gradle:ForgeGradle:2.1-SNAPSHOT'
} }
} }
@ -20,7 +20,7 @@ apply plugin: 'com.github.johnrengelman.shadow'
dependencies { dependencies {
compile project(':Core') compile project(':Core')
compile 'org.spongepowered:spongeapi:4.+' compile 'org.spongepowered:spongeapi:4.+'
compile 'org.mcstats.sponge:metrics:R8-SNAPSHOT' //compile 'org.mcstats.sponge:metrics:R8-SNAPSHOT'
} }
sourceCompatibility = 1.8 sourceCompatibility = 1.8
@ -57,9 +57,9 @@ processResources {
shadowJar { shadowJar {
dependencies { dependencies {
include(dependency(':Core')) 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" archiveName = "${parent.name}-${project.name}-${parent.version}.jar"
destinationDir = file '../target' destinationDir = file '../target'
} }

View File

@ -52,13 +52,6 @@ import com.plotsquared.sponge.util.block.SlowQueue;
import com.plotsquared.sponge.uuid.SpongeLowerOfflineUUIDWrapper; import com.plotsquared.sponge.uuid.SpongeLowerOfflineUUIDWrapper;
import com.plotsquared.sponge.uuid.SpongeOnlineUUIDWrapper; import com.plotsquared.sponge.uuid.SpongeOnlineUUIDWrapper;
import com.plotsquared.sponge.uuid.SpongeUUIDHandler; 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.slf4j.Logger;
import org.spongepowered.api.Game; import org.spongepowered.api.Game;
import org.spongepowered.api.Server; 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.WorldGenerator;
import org.spongepowered.api.world.gen.WorldGeneratorModifier; 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 class SpongeMain implements IPlotMain {
public static SpongeMain THIS; public static SpongeMain THIS;
@Inject
public PluginContainer plugin; public PluginContainer plugin;
@Inject @Inject
private Logger logger; private Logger logger;
@Inject @Inject
private Game game; private Game game;
private Server server; private Server server;
@ -123,12 +129,11 @@ public class SpongeMain implements IPlotMain {
public void onInit(GamePreInitializationEvent event) { public void onInit(GamePreInitializationEvent event) {
log("PlotSquared: Game pre init"); log("PlotSquared: Game pre init");
} }
@Listener @Listener
public void onServerAboutToStart(GameAboutToStartServerEvent event) { public void onServerAboutToStart(GameAboutToStartServerEvent event) {
log("PlotSquared: Server init"); log("PlotSquared: Server init");
THIS = this; THIS = this;
THIS.plugin = this.game.getPluginManager().fromInstance(this).get();
new PS(this, "Sponge"); new PS(this, "Sponge");
this.server = this.game.getServer(); this.server = this.game.getServer();
this.game.getRegistry().register(WorldGeneratorModifier.class, (WorldGeneratorModifier) new HybridGen().specify()); this.game.getRegistry().register(WorldGeneratorModifier.class, (WorldGeneratorModifier) new HybridGen().specify());
@ -154,7 +159,7 @@ public class SpongeMain implements IPlotMain {
@Override @Override
public File getWorldContainer() { public File getWorldContainer() {
return new File("world"); return game.getSavesDirectory().toFile();
} }
@Override @Override
@ -165,8 +170,7 @@ public class SpongeMain implements IPlotMain {
@Override @Override
public int[] getPluginVersion() { public int[] getPluginVersion() {
PluginContainer plugin = this.game.getPluginManager().fromInstance(this).get(); String version = this.plugin.getVersion().orElse("");
String version = plugin.getVersion().orElse("");
String[] split = version.split("\\."); String[] split = version.split("\\.");
return new int[]{Integer.parseInt(split[0]), Integer.parseInt(split[1]), split.length == 3 ? Integer.parseInt(split[2]) : 0}; 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 @Override
public UUIDHandlerImplementation initUUIDHandler() { public UUIDHandlerImplementation initUUIDHandler() {
UUIDWrapper wrapper; UUIDWrapper wrapper;
if (Settings.OFFLINE_MODE || !PS.get().checkVersion(getServerVersion(), 1, 7, 6)) { if (Settings.OFFLINE_MODE) {
wrapper = new SpongeLowerOfflineUUIDWrapper(); wrapper = new SpongeLowerOfflineUUIDWrapper();
} else { } else {
wrapper = new SpongeOnlineUUIDWrapper(); wrapper = new SpongeOnlineUUIDWrapper();
@ -276,7 +280,6 @@ public class SpongeMain implements IPlotMain {
@Override @Override
public boolean initPlotMeConverter() { public boolean initPlotMeConverter() {
// PlotMe was never ported to sponge
return false; return false;
} }
@ -370,25 +373,23 @@ public class SpongeMain implements IPlotMain {
public ChatManager<?> initChatManager() { public ChatManager<?> initChatManager() {
return new SpongeChatManager(); return new SpongeChatManager();
} }
@Override @Override
public PlotQueue<Chunk> initPlotQueue() { public PlotQueue<Chunk> initPlotQueue() {
if (PS.get().checkVersion(getServerVersion(), 1, 8, 0)) { try {
try { MainUtil.canSendChunk = true;
MainUtil.canSendChunk = true; return new FastQueue();
return new FastQueue(); } catch (RuntimeException e) {
} catch (RuntimeException e) { e.printStackTrace();
e.printStackTrace();
}
} }
return new SlowQueue(); return new SlowQueue();
} }
@Override @Override
public WorldUtil initWorldUtil() { public WorldUtil initWorldUtil() {
return new SpongeUtil(); return new SpongeUtil();
} }
@Override @Override
public GeneratorWrapper<?> getGenerator(String world, String name) { public GeneratorWrapper<?> getGenerator(String world, String name) {
if (name == null) { if (name == null) {
@ -405,12 +406,12 @@ public class SpongeMain implements IPlotMain {
} }
return new SpongePlotGenerator(new HybridGen()); return new SpongePlotGenerator(new HybridGen());
} }
@Override @Override
public GeneratorWrapper<?> wrapPlotGenerator(IndependentPlotGenerator generator) { public GeneratorWrapper<?> wrapPlotGenerator(IndependentPlotGenerator generator) {
return new SpongePlotGenerator(generator); return new SpongePlotGenerator(generator);
} }
@Override @Override
public List<String> getPluginIds() { public List<String> getPluginIds() {
return this.game.getPluginManager().getPlugins().stream().map(plugin1 -> plugin1.getName() + ';' + plugin1.getVersion() + ':' + true) return this.game.getPluginManager().getPlugins().stream().map(plugin1 -> plugin1.getName() + ';' + plugin1.getVersion() + ':' + true)