2015-07-26 18:14:34 +02:00
|
|
|
package com.plotsquared.sponge;
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
import java.util.Collection;
|
|
|
|
import java.util.UUID;
|
|
|
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
import org.spongepowered.api.Game;
|
|
|
|
import org.spongepowered.api.Server;
|
|
|
|
import org.spongepowered.api.entity.player.Player;
|
|
|
|
import org.spongepowered.api.entity.player.gamemode.GameModes;
|
|
|
|
import org.spongepowered.api.event.Subscribe;
|
|
|
|
import org.spongepowered.api.event.entity.player.PlayerChatEvent;
|
|
|
|
import org.spongepowered.api.event.state.PreInitializationEvent;
|
|
|
|
import org.spongepowered.api.event.state.ServerAboutToStartEvent;
|
2015-07-26 20:38:08 +02:00
|
|
|
import org.spongepowered.api.plugin.Plugin;
|
2015-07-26 18:14:34 +02:00
|
|
|
import org.spongepowered.api.plugin.PluginContainer;
|
|
|
|
import org.spongepowered.api.world.DimensionTypes;
|
|
|
|
import org.spongepowered.api.world.GeneratorTypes;
|
|
|
|
import org.spongepowered.api.world.World;
|
|
|
|
|
|
|
|
import com.google.inject.Inject;
|
2015-07-26 20:38:08 +02:00
|
|
|
import com.intellectualcrafters.configuration.ConfigurationSection;
|
2015-07-26 18:14:34 +02:00
|
|
|
import com.intellectualcrafters.plot.IPlotMain;
|
|
|
|
import com.intellectualcrafters.plot.PS;
|
|
|
|
import com.intellectualcrafters.plot.config.C;
|
|
|
|
import com.intellectualcrafters.plot.config.Settings;
|
|
|
|
import com.intellectualcrafters.plot.generator.HybridUtils;
|
|
|
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
|
|
|
import com.intellectualcrafters.plot.util.BlockManager;
|
|
|
|
import com.intellectualcrafters.plot.util.ChunkManager;
|
|
|
|
import com.intellectualcrafters.plot.util.EconHandler;
|
|
|
|
import com.intellectualcrafters.plot.util.EventUtil;
|
|
|
|
import com.intellectualcrafters.plot.util.InventoryUtil;
|
|
|
|
import com.intellectualcrafters.plot.util.PlayerManager;
|
|
|
|
import com.intellectualcrafters.plot.util.TaskManager;
|
|
|
|
import com.intellectualcrafters.plot.uuid.UUIDWrapper;
|
|
|
|
import com.plotsquared.bukkit.listeners.APlotListener;
|
|
|
|
import com.plotsquared.bukkit.util.SetupUtils;
|
|
|
|
import com.plotsquared.bukkit.util.UUIDHandler;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Created by robin on 01/11/2014
|
|
|
|
*/
|
|
|
|
|
2015-07-26 20:38:08 +02:00
|
|
|
@Plugin(id = "PlotSquared", name = "PlotSquared", version = "3.0.0")
|
2015-07-26 18:14:34 +02:00
|
|
|
public class SpongeMain implements IPlotMain, PluginContainer {
|
|
|
|
public static SpongeMain THIS;
|
|
|
|
|
|
|
|
@Inject private Logger logger;
|
|
|
|
@Inject private Game game;
|
|
|
|
private Server server;
|
|
|
|
|
|
|
|
private WorldModify modify;
|
|
|
|
|
|
|
|
////////////////////// SPONGE PLUGIN REGISTRATION ////////////////////
|
|
|
|
@Override
|
|
|
|
public String getId() {
|
|
|
|
return "PlotSquared";
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Object getInstance() {
|
|
|
|
return THIS;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public String getName() {
|
|
|
|
return "PlotSquared";
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public String getVersion() {
|
|
|
|
int[] version = PS.get().getVersion();
|
|
|
|
String result = "";
|
|
|
|
String prefix = "";
|
|
|
|
for (int i : version) {
|
|
|
|
result += prefix + i;
|
|
|
|
prefix = ".";
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
///////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
///////////////////// ON ENABLE /////////////////////
|
|
|
|
@Subscribe
|
|
|
|
public void onInit(PreInitializationEvent event) {
|
2015-07-26 20:38:08 +02:00
|
|
|
log("PRE INIT");
|
|
|
|
}
|
|
|
|
|
|
|
|
@Subscribe
|
|
|
|
public void onServerAboutToStart(ServerAboutToStartEvent event) {
|
|
|
|
log("INIT");
|
2015-07-26 18:14:34 +02:00
|
|
|
THIS = this;
|
|
|
|
PS.instance = new PS(this);
|
2015-07-26 20:38:08 +02:00
|
|
|
|
|
|
|
// Setup metrics
|
2015-07-26 18:14:34 +02:00
|
|
|
if (Settings.METRICS) {
|
|
|
|
try {
|
|
|
|
final SpongeMetrics metrics = new SpongeMetrics(game, this);
|
|
|
|
metrics.start();
|
|
|
|
log(C.PREFIX.s() + "&6Metrics enabled.");
|
|
|
|
} catch (final Exception e) {
|
|
|
|
log(C.PREFIX.s() + "&cFailed to load up metrics.");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
log("&dUsing metrics will allow us to improve the plugin, please consider it :)");
|
|
|
|
}
|
2015-07-26 20:38:08 +02:00
|
|
|
|
|
|
|
// Set the generators for each world...
|
2015-07-26 18:14:34 +02:00
|
|
|
server = game.getServer();
|
|
|
|
Collection<World> worlds = server.getWorlds();
|
|
|
|
if (worlds.size() > 0) {
|
2015-07-26 20:38:08 +02:00
|
|
|
log("INJECTING WORLDS!!!!!!!");
|
2015-07-26 18:14:34 +02:00
|
|
|
UUIDHandler.startCaching();
|
|
|
|
for (World world : server.getWorlds()) {
|
2015-07-26 20:38:08 +02:00
|
|
|
log("INJECTING WORLD: " + world.getName());
|
2015-07-26 18:14:34 +02:00
|
|
|
world.setWorldGenerator(new SpongePlotGenerator(world.getName()));
|
|
|
|
}
|
|
|
|
}
|
2015-07-26 20:38:08 +02:00
|
|
|
|
|
|
|
ConfigurationSection worldSection = PS.get().config.getConfigurationSection("worlds");
|
|
|
|
for (String world : worldSection.getKeys(false)) {
|
|
|
|
this.modify = new WorldModify(this);
|
|
|
|
Game game = event.getGame();
|
|
|
|
game.getRegistry().registerWorldGeneratorModifier(modify);
|
|
|
|
game.getRegistry().getWorldBuilder()
|
|
|
|
.name(world)
|
|
|
|
.enabled(true)
|
|
|
|
.loadsOnStartup(true)
|
|
|
|
.keepsSpawnLoaded(true)
|
|
|
|
.dimensionType(DimensionTypes.OVERWORLD)
|
|
|
|
.generator(GeneratorTypes.DEBUG)
|
|
|
|
.gameMode(GameModes.CREATIVE)
|
|
|
|
.generatorModifiers(modify)
|
|
|
|
.build();
|
|
|
|
}
|
2015-07-26 18:14:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public Logger getLogger() {
|
|
|
|
return logger;
|
|
|
|
}
|
|
|
|
|
|
|
|
public Game getGame() {
|
|
|
|
return game;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Subscribe
|
|
|
|
public void onPlayerChat(PlayerChatEvent event) {
|
|
|
|
// This is how events sort of work?
|
|
|
|
Player player = event.getUser();
|
|
|
|
log(player.getWorld().getName());
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void log(String message) {
|
|
|
|
logger.info(message);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public File getDirectory() {
|
|
|
|
return new File("mods/PlotSquared");
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void disable() {
|
|
|
|
PS.get().disable();
|
|
|
|
THIS = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int[] getPluginVersion() {
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int[] getServerVersion() {
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void handleKick(UUID uuid, C c) {
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public TaskManager getTaskManager() {
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void runEntityTask() {
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void registerCommands() {
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void registerPlayerEvents() {
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void registerInventoryEvents() {
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void registerPlotPlusEvents() {
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void registerForceFieldEvents() {
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void registerWorldEditEvents() {
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void registerTNTListener() {
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public EconHandler getEconomyHandler() {
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public BlockManager initBlockManager() {
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public EventUtil initEventUtil() {
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public ChunkManager initChunkManager() {
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public SetupUtils initSetupUtils() {
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public HybridUtils initHybridUtils() {
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public UUIDWrapper initUUIDHandler() {
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public InventoryUtil initInventoryUtil() {
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean initPlotMeConverter() {
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void unregister(PlotPlayer player) {
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-07-26 20:38:08 +02:00
|
|
|
public SpongeGeneratorWrapper getGenerator(String world, String name) {
|
2015-07-26 18:14:34 +02:00
|
|
|
// TODO Auto-generated method stub
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public APlotListener initPlotListener() {
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void registerChunkProcessor() {
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void registerWorldEvents() {
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public PlayerManager initPlayerManager() {
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public String getServerName() {
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|