mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-23 13:46:45 +01:00
325 lines
8.2 KiB
Java
325 lines
8.2 KiB
Java
|
package com.plotsquared.sponge;
|
||
|
|
||
|
import java.io.File;
|
||
|
import java.util.Collection;
|
||
|
import java.util.UUID;
|
||
|
|
||
|
import org.bukkit.generator.ChunkGenerator;
|
||
|
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;
|
||
|
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;
|
||
|
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
|
||
|
*/
|
||
|
|
||
|
//@Plugin(id = "PlotSquared", name = "PlotSquared", version = "3.0.0")
|
||
|
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) {
|
||
|
THIS = this;
|
||
|
PS.instance = new PS(this);
|
||
|
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 :)");
|
||
|
}
|
||
|
server = game.getServer();
|
||
|
Collection<World> worlds = server.getWorlds();
|
||
|
if (worlds.size() > 0) {
|
||
|
UUIDHandler.startCaching();
|
||
|
for (World world : server.getWorlds()) {
|
||
|
world.setWorldGenerator(new SpongePlotGenerator(world.getName()));
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@Subscribe
|
||
|
public void onServerAboutToStart(ServerAboutToStartEvent event) {
|
||
|
this.modify = new WorldModify(this);
|
||
|
Game game = event.getGame();
|
||
|
game.getRegistry().registerWorldGeneratorModifier(modify);
|
||
|
game.getRegistry().getWorldBuilder()
|
||
|
.name("test")
|
||
|
.enabled(true)
|
||
|
.loadsOnStartup(true)
|
||
|
.keepsSpawnLoaded(true)
|
||
|
.dimensionType(DimensionTypes.OVERWORLD)
|
||
|
.generator(GeneratorTypes.DEBUG)
|
||
|
.gameMode(GameModes.CREATIVE)
|
||
|
.generatorModifiers(modify)
|
||
|
.build();
|
||
|
}
|
||
|
|
||
|
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
|
||
|
public ChunkGenerator getGenerator(String world, String name) {
|
||
|
// 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;
|
||
|
}
|
||
|
}
|