Implemented PlatformManager, Platform over old platform registration method.

This commit is contained in:
sk89q
2014-04-04 20:53:58 -07:00
parent bed5fa8fdc
commit 8fb73347e4
19 changed files with 1275 additions and 373 deletions

View File

@ -23,6 +23,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import com.sk89q.worldedit.LocalConfiguration;
import net.minecraft.command.CommandBase;
import net.minecraft.command.ICommandSender;
import net.minecraft.command.ServerCommandManager;
@ -40,10 +41,12 @@ import com.sk89q.worldedit.ServerInterface;
import cpw.mods.fml.common.FMLCommonHandler;
public class ForgeServerInterface extends ServerInterface {
private MinecraftServer server;
private ForgeBiomeTypes biomes;
private final WorldEditMod mod;
private final MinecraftServer server;
private final ForgeBiomeTypes biomes;
public ForgeServerInterface() {
public ForgeServerInterface(WorldEditMod mod) {
this.mod = mod;
this.server = FMLCommonHandler.instance().getMinecraftServerInstance();
this.biomes = new ForgeBiomeTypes();
}
@ -114,4 +117,9 @@ public class ForgeServerInterface extends ServerInterface {
});
}
}
@Override
public LocalConfiguration getConfiguration() {
return mod.getConfig();
}
}

View File

@ -28,6 +28,7 @@ import java.util.jar.JarFile;
import java.util.logging.Logger;
import java.util.zip.ZipEntry;
import com.sk89q.worldedit.extension.platform.PlatformRejectionException;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
@ -92,8 +93,13 @@ public class WorldEditMod {
@EventHandler
public void serverStarting(FMLServerStartingEvent event) {
this.server = new ForgeServerInterface();
this.controller = new WorldEdit(this.server, this.config);
this.server = new ForgeServerInterface(this);
this.controller = WorldEdit.getInstance();
try {
controller.getPlatformManager().register(server);
} catch (PlatformRejectionException e) {
throw new RuntimeException("Failed to register with WorldEdit", e);
}
}
public ForgeConfiguration getConfig() {