PlotSquared/src/main/java/com/plotsquared/sponge/SpongeMain.java

621 lines
20 KiB
Java
Raw Normal View History

2015-07-26 18:14:34 +02:00
package com.plotsquared.sponge;
2015-07-30 16:25:16 +02:00
import java.io.File;
import java.lang.reflect.Field;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Map.Entry;
2015-10-07 08:33:33 +02:00
import java.util.Optional;
2015-07-30 19:24:01 +02:00
import java.util.UUID;
2015-07-28 08:06:19 +02:00
2015-07-26 18:14:34 +02:00
import org.slf4j.Logger;
2015-07-30 16:25:16 +02:00
import org.spongepowered.api.CatalogType;
2015-07-26 18:14:34 +02:00
import org.spongepowered.api.Game;
import org.spongepowered.api.Server;
2015-07-30 16:25:16 +02:00
import org.spongepowered.api.block.BlockState;
import org.spongepowered.api.block.BlockType;
import org.spongepowered.api.block.BlockTypes;
2015-10-07 08:33:33 +02:00
import org.spongepowered.api.entity.living.player.Player;
import org.spongepowered.api.event.Listener;
import org.spongepowered.api.event.game.state.GameAboutToStartServerEvent;
import org.spongepowered.api.event.game.state.GameInitializationEvent;
import org.spongepowered.api.event.game.state.GamePreInitializationEvent;
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.service.profile.GameProfileResolver;
2015-07-30 16:25:16 +02:00
import org.spongepowered.api.text.Text;
import org.spongepowered.api.text.Texts;
import org.spongepowered.api.text.translation.Translatable;
import org.spongepowered.api.text.translation.Translation;
2015-07-26 18:14:34 +02:00
import org.spongepowered.api.world.DimensionTypes;
import org.spongepowered.api.world.GeneratorTypes;
import org.spongepowered.api.world.World;
2015-07-30 16:25:16 +02:00
import com.google.inject.Inject;
import com.intellectualcrafters.configuration.ConfigurationSection;
import com.intellectualcrafters.plot.IPlotMain;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.config.Configuration;
import com.intellectualcrafters.plot.config.Settings;
import com.intellectualcrafters.plot.generator.HybridUtils;
import com.intellectualcrafters.plot.object.PlotBlock;
import com.intellectualcrafters.plot.object.PlotPlayer;
2015-08-02 21:25:41 +02:00
import com.intellectualcrafters.plot.object.PlotWorld;
2015-07-30 16:25:16 +02:00
import com.intellectualcrafters.plot.util.AbstractTitle;
import com.intellectualcrafters.plot.util.BlockManager;
import com.intellectualcrafters.plot.util.ChatManager;
2015-07-30 16:25:16 +02:00
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.SchematicHandler;
import com.intellectualcrafters.plot.util.SetupUtils;
import com.intellectualcrafters.plot.util.TaskManager;
2015-07-30 19:24:01 +02:00
import com.intellectualcrafters.plot.util.UUIDHandler;
2015-07-30 16:25:16 +02:00
import com.intellectualcrafters.plot.util.UUIDHandlerImplementation;
import com.intellectualcrafters.plot.uuid.UUIDWrapper;
import com.plotsquared.sponge.generator.SpongeBasicGen;
import com.plotsquared.sponge.generator.SpongeGeneratorWrapper;
import com.plotsquared.sponge.generator.WorldModify;
import com.plotsquared.sponge.listener.MainListener;
import com.plotsquared.sponge.util.KillRoadMobs;
import com.plotsquared.sponge.util.SpongeBlockManager;
import com.plotsquared.sponge.util.SpongeChatManager;
2015-07-30 19:24:01 +02:00
import com.plotsquared.sponge.util.SpongeChunkManager;
2015-07-30 16:25:16 +02:00
import com.plotsquared.sponge.util.SpongeCommand;
2015-10-07 08:33:33 +02:00
import com.plotsquared.sponge.util.SpongeEconHandler;
2015-07-30 16:25:16 +02:00
import com.plotsquared.sponge.util.SpongeEventUtil;
import com.plotsquared.sponge.util.SpongeInventoryUtil;
import com.plotsquared.sponge.util.SpongeMetrics;
import com.plotsquared.sponge.util.SpongeTaskManager;
2015-07-30 19:24:01 +02:00
import com.plotsquared.sponge.util.SpongeTitleManager;
2015-07-30 16:25:16 +02:00
import com.plotsquared.sponge.util.SpongeUtil;
import com.plotsquared.sponge.uuid.SpongeLowerOfflineUUIDWrapper;
import com.plotsquared.sponge.uuid.SpongeOnlineUUIDWrapper;
import com.plotsquared.sponge.uuid.SpongeUUIDHandler;
2015-07-26 18:14:34 +02:00
/**
* Created by robin on 01/11/2014
*/
2015-09-11 12:09:22 +02:00
@Plugin(id = "PlotSquared", name = "PlotSquared", version = "3.0.0", dependencies = "before:WorldEdit")
2015-09-13 06:04:31 +02:00
public class SpongeMain implements IPlotMain, PluginContainer {
2015-07-26 18:14:34 +02:00
public static SpongeMain THIS;
2015-09-13 06:04:31 +02:00
2015-09-11 12:09:22 +02:00
@Inject
private Logger logger;
@Inject
private Game game;
2015-07-26 18:14:34 +02:00
private Server server;
2015-09-13 06:04:31 +02:00
private GameProfileResolver resolver;
2015-09-13 06:04:31 +02:00
2015-07-26 18:14:34 +02:00
private WorldModify modify;
2015-09-13 06:04:31 +02:00
private Object plugin;
2015-09-13 06:04:31 +02:00
// stuff //
2015-09-13 06:04:31 +02:00
public Logger getLogger() {
return logger;
}
2015-09-13 06:04:31 +02:00
public Game getGame() {
return game;
}
2015-09-13 06:04:31 +02:00
public Server getServer() {
return server;
}
2015-09-13 06:04:31 +02:00
public GameProfileResolver getResolver() {
return resolver;
}
2015-09-13 06:04:31 +02:00
public Object getPlugin() {
2015-07-30 16:25:16 +02:00
return plugin;
}
2015-09-13 06:04:31 +02:00
public Text getText(final String m) {
2015-07-30 16:25:16 +02:00
return Texts.of(m);
}
2015-09-13 06:04:31 +02:00
public Translatable getTranslation(final String m) {
return new Translatable() {
2015-07-30 16:25:16 +02:00
@Override
2015-09-13 06:04:31 +02:00
public Translation getTranslation() {
return new Translation() {
2015-07-30 16:25:16 +02:00
@Override
2015-09-13 06:04:31 +02:00
public String getId() {
2015-07-30 16:25:16 +02:00
return m;
}
2015-09-13 06:04:31 +02:00
2015-07-30 16:25:16 +02:00
@Override
2015-09-13 06:04:31 +02:00
public String get(final Locale l, final Object... args) {
2015-07-30 16:25:16 +02:00
return m;
}
2015-09-13 06:04:31 +02:00
2015-07-30 16:25:16 +02:00
@Override
2015-09-13 06:04:31 +02:00
public String get(final Locale l) {
2015-07-30 16:25:16 +02:00
return m;
}
};
}
};
}
2015-09-13 06:04:31 +02:00
2015-09-11 12:09:22 +02:00
private final PlotBlock NULL_BLOCK = new PlotBlock((short) 0, (byte) 0);
2015-07-30 16:25:16 +02:00
private BlockState[][] blockMap;
private Map<BlockState, PlotBlock> blockMapReverse;
2015-09-13 06:04:31 +02:00
public BlockState getBlockState(final PlotBlock block) {
if (blockMap[block.id] == null) {
2015-07-30 16:25:16 +02:00
log("UNKNOWN BLOCK: " + block.toString());
return null;
2015-09-13 06:04:31 +02:00
} else if (blockMap[block.id].length <= block.data) {
2015-07-30 16:25:16 +02:00
log("UNKNOWN BLOCK: " + block.toString() + " -> Using " + block.id + ":0 instead");
return blockMap[block.id][0];
}
return blockMap[block.id][block.data];
}
2015-09-13 06:04:31 +02:00
public BlockState getBlockState(final int id) {
2015-07-30 16:25:16 +02:00
return blockMap[id][0];
}
2015-09-13 06:04:31 +02:00
public Collection<BlockState> getAllStates() {
2015-09-11 12:09:22 +02:00
return blockMapReverse.keySet();
2015-07-30 16:25:16 +02:00
}
2015-09-13 06:04:31 +02:00
public PlotBlock getPlotBlock(final BlockState state) {
2015-09-11 12:09:22 +02:00
final PlotBlock val = blockMapReverse.get(state);
2015-09-13 06:04:31 +02:00
if (val == null) {
return NULL_BLOCK;
}
2015-07-30 16:25:16 +02:00
return val;
}
2015-09-13 06:04:31 +02:00
/////////
2015-09-13 06:04:31 +02:00
2015-07-26 18:14:34 +02:00
////////////////////// SPONGE PLUGIN REGISTRATION ////////////////////
@Override
2015-09-13 06:04:31 +02:00
public String getId() {
2015-07-26 18:14:34 +02:00
return "PlotSquared";
}
2015-09-13 06:04:31 +02:00
2015-07-26 18:14:34 +02:00
@Override
2015-09-13 06:04:31 +02:00
public Object getInstance() {
2015-07-26 18:14:34 +02:00
return THIS;
}
2015-09-13 06:04:31 +02:00
2015-07-26 18:14:34 +02:00
@Override
2015-09-13 06:04:31 +02:00
public String getName() {
2015-07-26 18:14:34 +02:00
return "PlotSquared";
}
2015-09-13 06:04:31 +02:00
2015-07-26 18:14:34 +02:00
@Override
2015-09-13 06:04:31 +02:00
public String getVersion() {
2015-09-11 12:09:22 +02:00
final int[] version = PS.get().getVersion();
2015-07-26 18:14:34 +02:00
String result = "";
String prefix = "";
2015-09-13 06:04:31 +02:00
for (final int i : version) {
2015-07-26 18:14:34 +02:00
result += prefix + i;
prefix = ".";
}
return result;
}
2015-09-13 06:04:31 +02:00
2015-07-26 18:14:34 +02:00
///////////////////////////////////////////////////////////////////////
2015-09-13 06:04:31 +02:00
///////////////////// ON ENABLE /////////////////////
2015-10-07 08:33:33 +02:00
@Listener
public void init(final GameInitializationEvent event) {
log("P^2 INIT");
}
2015-09-13 06:04:31 +02:00
2015-10-07 08:33:33 +02:00
@Listener
public void onInit(final GamePreInitializationEvent event) {
log("P^2 PRE INIT");
2015-07-26 20:38:08 +02:00
}
2015-09-13 06:04:31 +02:00
2015-10-07 08:33:33 +02:00
@Listener
public void onServerAboutToStart(final GameAboutToStartServerEvent event) {
log("P^2 ABOUT START");
2015-07-26 18:14:34 +02:00
THIS = this;
2015-09-13 06:04:31 +02:00
2015-07-30 16:25:16 +02:00
//
resolver = game.getServiceManager().provide(GameProfileResolver.class).get();
2015-07-30 16:25:16 +02:00
plugin = this;
server = game.getServer();
//
2015-09-13 06:04:31 +02:00
PS.instance = new PS(this, "Sponge");
2015-09-13 06:04:31 +02:00
2015-07-30 16:25:16 +02:00
registerBlocks();
2015-09-13 06:04:31 +02:00
2015-09-11 12:09:22 +02:00
final ConfigurationSection worldSection = PS.get().config.getConfigurationSection("worlds");
2015-09-13 06:04:31 +02:00
if (worldSection != null) {
for (final String world : worldSection.getKeys(false)) {
2015-08-02 21:25:41 +02:00
createWorldFromConfig(world);
}
}
}
2015-09-13 06:04:31 +02:00
public World createWorldFromConfig(final String world) {
2015-09-11 12:09:22 +02:00
final SpongeBasicGen generator = new SpongeBasicGen(world);
final PlotWorld plotworld = generator.getNewPlotWorld(world);
2015-08-02 21:25:41 +02:00
SpongeGeneratorWrapper wrapper;
2015-09-13 06:04:31 +02:00
if (plotworld.TYPE == 0) {
2015-08-02 21:25:41 +02:00
wrapper = new SpongeGeneratorWrapper(world, generator);
2015-09-13 06:04:31 +02:00
} else {
2015-08-02 21:25:41 +02:00
wrapper = new SpongeGeneratorWrapper(world, null);
}
PS.get().loadWorld(world, wrapper);
2015-09-13 06:04:31 +02:00
switch (plotworld.TYPE) {
// Normal
case 0: {
2015-09-11 12:09:22 +02:00
modify = new WorldModify(generator, false);
game.getRegistry().registerWorldGeneratorModifier(modify);
2015-09-13 06:04:31 +02:00
final Optional<World> builder = game.getRegistry().createWorldBuilder().name(world).enabled(true).loadsOnStartup(true).keepsSpawnLoaded(true).dimensionType(DimensionTypes.OVERWORLD)
.generator(GeneratorTypes.FLAT).usesMapFeatures(false).generatorModifiers(modify).build();
2015-08-02 21:25:41 +02:00
return builder.get();
}
// Augmented
2015-09-13 06:04:31 +02:00
default: {
2015-09-11 12:09:22 +02:00
modify = new WorldModify(generator, true);
2015-08-02 21:25:41 +02:00
game.getRegistry().registerWorldGeneratorModifier(modify);
2015-09-13 06:04:31 +02:00
final Optional<World> builder = game.getRegistry().createWorldBuilder().name(world).enabled(true).loadsOnStartup(true).keepsSpawnLoaded(true).dimensionType(DimensionTypes.OVERWORLD)
.generator(GeneratorTypes.OVERWORLD).usesMapFeatures(false).generatorModifiers(modify).build();
2015-08-02 21:25:41 +02:00
return builder.get();
}
2015-07-26 20:38:08 +02:00
}
2015-07-26 18:14:34 +02:00
}
2015-09-13 06:04:31 +02:00
public void registerBlock(final PlotBlock block, final BlockState state) {
2015-09-11 12:09:22 +02:00
final BlockState[] val = blockMap[block.id];
2015-09-13 06:04:31 +02:00
if (val == null) {
2015-07-30 16:25:16 +02:00
blockMap[block.id] = new BlockState[block.data + 1];
2015-09-13 06:04:31 +02:00
} else if (val.length <= block.data) {
2015-07-30 16:25:16 +02:00
blockMap[block.id] = Arrays.copyOf(val, block.data + 1);
2015-09-13 06:04:31 +02:00
} else if (val[block.data] != null) {
return;
2015-07-30 16:25:16 +02:00
}
blockMap[block.id][block.data] = state;
blockMapReverse.put(state, block);
}
2015-09-13 06:04:31 +02:00
public PlotBlock registerBlock(final BlockState state) {
2015-09-11 12:09:22 +02:00
final PlotBlock val = blockMapReverse.get(state);
2015-09-13 06:04:31 +02:00
if (val != null) {
return val;
}
2015-07-30 16:25:16 +02:00
byte data;
2015-09-13 06:04:31 +02:00
if (blockMap[0] == null) {
2015-07-30 16:25:16 +02:00
blockMap[0] = new BlockState[1];
data = 0;
2015-09-13 06:04:31 +02:00
} else {
2015-07-30 16:25:16 +02:00
data = (byte) (blockMap[0].length);
}
2015-09-11 12:09:22 +02:00
final PlotBlock block = new PlotBlock((short) 0, data);
2015-07-30 16:25:16 +02:00
registerBlock(block, state);
return block;
}
2015-09-13 06:04:31 +02:00
public void registerBlocks() {
2015-07-30 16:25:16 +02:00
blockMap = new BlockState[256][];
2015-08-13 14:39:29 +02:00
blockMapReverse = new HashMap<BlockState, PlotBlock>();
2015-09-11 12:09:22 +02:00
final HashMap<String, BlockState> states = new HashMap<>();
2015-09-13 06:04:31 +02:00
2015-07-30 16:25:16 +02:00
PS.get().copyFile("ids.txt", "config");
PS.get().copyFile("data.txt", "config");
2015-09-13 06:04:31 +02:00
try {
2015-09-11 12:09:22 +02:00
final File id_file = new File(getDirectory(), "config" + File.separator + "ids.txt");
final List<String> id_lines = Files.readAllLines(id_file.toPath(), StandardCharsets.UTF_8);
2015-09-13 06:04:31 +02:00
2015-09-11 12:09:22 +02:00
final File data_file = new File(getDirectory(), "config" + File.separator + "data.txt");
final List<String> data_lines = Files.readAllLines(data_file.toPath(), StandardCharsets.UTF_8);
2015-09-13 06:04:31 +02:00
2015-07-30 16:25:16 +02:00
Field[] fields = BlockTypes.class.getDeclaredFields();
2015-09-13 06:04:31 +02:00
for (final Field field : fields) {
2015-09-11 12:09:22 +02:00
final BlockType type = (BlockType) field.get(null);
final BlockState state = type.getDefaultState();
2015-09-13 06:04:31 +02:00
if (state != null) {
try {
2015-07-30 16:25:16 +02:00
states.put(type.getId() + ":" + 0, state);
2015-09-13 06:04:31 +02:00
} catch (final Exception e) {}
2015-07-30 16:25:16 +02:00
}
}
2015-09-11 12:09:22 +02:00
final String packaze = "org.spongepowered.api.data.type.";
2015-09-13 06:04:31 +02:00
for (int i = 0; i < data_lines.size(); i++) {
2015-09-11 12:09:22 +02:00
final String classname = packaze + data_lines.get(i).trim();
2015-09-13 06:04:31 +02:00
try {
2015-09-11 12:09:22 +02:00
final Class<?> clazz = Class.forName(classname);
fields = clazz.getDeclaredFields();
2015-09-13 06:04:31 +02:00
for (final Field field : fields) {
2015-09-11 12:09:22 +02:00
final CatalogType type = (CatalogType) field.get(null);
final String minecraft_id = type.getId();
final BlockState state = states.get(minecraft_id + ":" + 0);
2015-09-13 06:04:31 +02:00
if (state == null) {
continue;
}
2015-07-30 16:25:16 +02:00
}
2015-09-13 06:04:31 +02:00
} catch (final Throwable e) {}
2015-07-30 16:25:16 +02:00
}
2015-09-13 06:04:31 +02:00
2015-07-30 16:25:16 +02:00
PlotBlock block = null;
2015-09-13 06:04:31 +02:00
for (int i = 0; i < id_lines.size(); i++) {
2015-09-11 12:09:22 +02:00
final String line = id_lines.get(i).trim();
2015-09-13 06:04:31 +02:00
switch (i % 3) {
case 0: {
2015-07-30 16:25:16 +02:00
block = Configuration.BLOCK.parseString(line);
break;
}
2015-09-13 06:04:31 +02:00
case 1: {
2015-07-30 16:25:16 +02:00
break;
}
2015-09-13 06:04:31 +02:00
case 2: {
2015-09-11 12:09:22 +02:00
final String minecraft_id = line;
final BlockState state = states.remove(minecraft_id + ":" + block.data);
2015-09-13 06:04:31 +02:00
if (state == null) {
2015-07-30 16:25:16 +02:00
continue;
}
registerBlock(block, state);
break;
}
}
}
2015-09-13 06:04:31 +02:00
for (final Entry<String, BlockState> state : states.entrySet()) {
2015-07-30 16:25:16 +02:00
log("REGISTERING: " + registerBlock(state.getValue()) + " | " + state.getValue().getType());
}
2015-09-13 06:04:31 +02:00
} catch (final Exception e) {
2015-07-30 16:25:16 +02:00
e.printStackTrace();
}
}
2015-09-13 06:04:31 +02:00
2015-07-26 18:14:34 +02:00
@Override
2015-09-13 06:04:31 +02:00
public void log(String message) {
2015-07-30 16:25:16 +02:00
message = C.format(message, C.replacements);
2015-09-13 06:04:31 +02:00
if (!Settings.CONSOLE_COLOR) {
2015-07-30 16:25:16 +02:00
message = message.replaceAll('\u00a7' + "[a-z|0-9]", "");
}
2015-09-13 06:04:31 +02:00
if ((server == null) || (server.getConsole() == null)) {
2015-07-30 16:25:16 +02:00
logger.info(message);
return;
}
server.getConsole().sendMessage(Texts.of(message));
2015-07-26 18:14:34 +02:00
}
2015-09-13 06:04:31 +02:00
2015-07-26 18:14:34 +02:00
@Override
2015-09-13 06:04:31 +02:00
public File getDirectory() {
2015-07-26 18:14:34 +02:00
return new File("mods/PlotSquared");
}
2015-09-13 06:04:31 +02:00
2015-07-26 18:14:34 +02:00
@Override
public File getWorldContainer() {
return new File("world");
}
2015-09-13 06:04:31 +02:00
2015-07-26 18:14:34 +02:00
@Override
public void disable() {
PS.get().disable();
THIS = null;
}
2015-09-13 06:04:31 +02:00
2015-07-26 18:14:34 +02:00
@Override
2015-09-13 06:04:31 +02:00
public int[] getPluginVersion() {
2015-09-11 12:09:22 +02:00
final PluginContainer plugin = game.getPluginManager().getPlugin("PlotSquared").get();
final String version = plugin.getVersion();
log("Checking plugin version: PlotSquared: ");
2015-09-11 12:09:22 +02:00
final String[] split = version.split("\\.");
return new int[] { Integer.parseInt(split[0]), Integer.parseInt(split[1]), (split.length == 3) ? Integer.parseInt(split[2]) : 0 };
2015-07-26 18:14:34 +02:00
}
2015-09-13 06:04:31 +02:00
2015-07-26 18:14:34 +02:00
@Override
2015-09-13 06:04:31 +02:00
public int[] getServerVersion() {
log("Checking minecraft version: Sponge: ");
2015-09-11 12:09:22 +02:00
final String version = game.getPlatform().getMinecraftVersion().getName();
final String[] split = version.split("\\.");
return new int[] { Integer.parseInt(split[0]), Integer.parseInt(split[1]), (split.length == 3) ? Integer.parseInt(split[2]) : 0 };
2015-07-26 18:14:34 +02:00
}
2015-09-13 06:04:31 +02:00
2015-07-30 16:25:16 +02:00
@Override
2015-09-13 06:04:31 +02:00
public InventoryUtil initInventoryUtil() {
2015-07-30 16:25:16 +02:00
return new SpongeInventoryUtil();
}
2015-09-13 06:04:31 +02:00
2015-07-30 16:25:16 +02:00
@Override
2015-09-13 06:04:31 +02:00
public SpongeGeneratorWrapper getGenerator(final String world, final String name) {
if (name == null) {
return new SpongeGeneratorWrapper(world, null);
2015-07-30 16:25:16 +02:00
}
2015-09-13 06:04:31 +02:00
if (name.equals("PlotSquared")) {
return new SpongeGeneratorWrapper(world, new SpongeBasicGen(world));
} else {
2015-07-30 16:25:16 +02:00
throw new UnsupportedOperationException("NOT IMPLEMENTED YET");
}
}
2015-09-13 06:04:31 +02:00
2015-07-30 16:25:16 +02:00
@Override
2015-09-13 06:04:31 +02:00
public EconHandler getEconomyHandler() {
2015-07-30 16:25:16 +02:00
// TODO Auto-generated method stub
// Nothing like Vault exists yet
2015-10-07 08:33:33 +02:00
return new SpongeEconHandler();
2015-07-30 16:25:16 +02:00
}
2015-09-13 06:04:31 +02:00
2015-07-26 18:14:34 +02:00
@Override
2015-09-13 06:04:31 +02:00
public BlockManager initBlockManager() {
2015-07-30 16:25:16 +02:00
return new SpongeBlockManager();
2015-07-26 18:14:34 +02:00
}
2015-09-13 06:04:31 +02:00
2015-07-26 18:14:34 +02:00
@Override
2015-09-13 06:04:31 +02:00
public EventUtil initEventUtil() {
2015-07-30 16:25:16 +02:00
return new SpongeEventUtil();
2015-07-26 18:14:34 +02:00
}
2015-09-13 06:04:31 +02:00
2015-07-26 18:14:34 +02:00
@Override
2015-09-13 06:04:31 +02:00
public ChunkManager initChunkManager() {
2015-07-30 16:25:16 +02:00
return new SpongeChunkManager();
2015-07-26 18:14:34 +02:00
}
2015-09-13 06:04:31 +02:00
2015-07-26 18:14:34 +02:00
@Override
2015-09-13 06:04:31 +02:00
public SetupUtils initSetupUtils() {
2015-08-02 21:25:41 +02:00
return new SpongeSetupUtils();
2015-07-26 18:14:34 +02:00
}
2015-09-13 06:04:31 +02:00
2015-07-26 18:14:34 +02:00
@Override
2015-09-13 06:04:31 +02:00
public HybridUtils initHybridUtils() {
2015-08-02 13:56:18 +02:00
return new SpongeHybridUtils();
2015-07-26 18:14:34 +02:00
}
2015-09-13 06:04:31 +02:00
2015-07-26 18:14:34 +02:00
@Override
2015-09-13 06:04:31 +02:00
public SchematicHandler initSchematicHandler() {
2015-08-02 13:56:18 +02:00
return new SpongeSchematicHandler();
2015-07-26 18:14:34 +02:00
}
2015-09-13 06:04:31 +02:00
2015-07-26 18:14:34 +02:00
@Override
2015-09-13 06:04:31 +02:00
public TaskManager getTaskManager() {
2015-07-30 16:25:16 +02:00
return new SpongeTaskManager();
2015-07-26 18:14:34 +02:00
}
2015-09-13 06:04:31 +02:00
2015-07-26 18:14:34 +02:00
@Override
2015-09-13 06:04:31 +02:00
public void runEntityTask() {
2015-07-30 16:25:16 +02:00
new KillRoadMobs().run();
2015-07-26 18:14:34 +02:00
}
2015-09-13 06:04:31 +02:00
2015-07-26 18:14:34 +02:00
@Override
2015-09-13 06:04:31 +02:00
public void registerCommands() {
2015-09-11 12:09:22 +02:00
getGame().getCommandDispatcher().register(plugin, new SpongeCommand(), new String[] { "plots", "p", "plot", "ps", "plotsquared", "p2", "2" });
2015-07-26 18:14:34 +02:00
}
2015-09-13 06:04:31 +02:00
2015-07-26 18:14:34 +02:00
@Override
2015-09-13 06:04:31 +02:00
public void registerPlayerEvents() {
2015-10-07 08:33:33 +02:00
game.getEventManager().registerListeners(this, new MainListener());
2015-07-26 18:14:34 +02:00
}
2015-09-13 06:04:31 +02:00
2015-07-26 18:14:34 +02:00
@Override
2015-09-13 06:04:31 +02:00
public void registerInventoryEvents() {
2015-07-26 18:14:34 +02:00
// TODO Auto-generated method stub
2015-07-30 16:25:16 +02:00
log("registerInventoryEvents is not implemented!");
2015-07-26 18:14:34 +02:00
}
2015-09-13 06:04:31 +02:00
2015-07-26 18:14:34 +02:00
@Override
2015-09-13 06:04:31 +02:00
public void registerPlotPlusEvents() {
2015-07-26 18:14:34 +02:00
// TODO Auto-generated method stub
2015-07-30 16:25:16 +02:00
log("registerPlotPlusEvents is not implemented!");
2015-07-26 18:14:34 +02:00
}
2015-09-13 06:04:31 +02:00
2015-07-26 18:14:34 +02:00
@Override
2015-09-13 06:04:31 +02:00
public void registerForceFieldEvents() {
2015-07-26 18:14:34 +02:00
// TODO Auto-generated method stub
2015-07-30 16:25:16 +02:00
log("registerForceFieldEvents is not implemented!");
2015-07-26 18:14:34 +02:00
}
2015-09-13 06:04:31 +02:00
2015-07-26 18:14:34 +02:00
@Override
2015-09-13 06:04:31 +02:00
public boolean initWorldEdit() {
try {
log("CHECKING FOR WORLDEDIT!?");
Class.forName("com.sk89q.worldedit.WorldEdit");
return true;
2015-09-13 06:04:31 +02:00
} catch (final Throwable e) {
return false;
}
2015-07-26 18:14:34 +02:00
}
2015-09-13 06:04:31 +02:00
2015-07-26 18:14:34 +02:00
@Override
2015-09-13 06:04:31 +02:00
public UUIDHandlerImplementation initUUIDHandler() {
UUIDWrapper wrapper;
2015-09-13 06:04:31 +02:00
if (Settings.OFFLINE_MODE || !PS.get().checkVersion(getServerVersion(), 1, 7, 6)) {
wrapper = new SpongeLowerOfflineUUIDWrapper();
2015-09-13 06:04:31 +02:00
} else {
wrapper = new SpongeOnlineUUIDWrapper();
}
return new SpongeUUIDHandler(wrapper);
2015-07-26 18:14:34 +02:00
}
2015-09-13 06:04:31 +02:00
2015-07-26 18:14:34 +02:00
@Override
2015-09-13 06:04:31 +02:00
public boolean initPlotMeConverter() {
2015-07-26 18:14:34 +02:00
// TODO Auto-generated method stub
2015-07-30 16:25:16 +02:00
PS.log("initPlotMeConverter NOT IMPLEMENTED YET");
2015-07-26 18:14:34 +02:00
return false;
}
2015-09-13 06:04:31 +02:00
2015-07-26 18:14:34 +02:00
@Override
2015-09-13 06:04:31 +02:00
public void unregister(final PlotPlayer player) {
2015-07-30 16:25:16 +02:00
SpongeUtil.removePlayer(player.getName());
2015-07-26 18:14:34 +02:00
}
2015-09-13 06:04:31 +02:00
2015-07-26 18:14:34 +02:00
@Override
2015-09-13 06:04:31 +02:00
public void registerChunkProcessor() {
2015-07-26 18:14:34 +02:00
// TODO Auto-generated method stub
2015-07-30 16:25:16 +02:00
PS.log("registerChunkProcessor NOT IMPLEMENTED YET");
2015-07-26 18:14:34 +02:00
}
2015-09-13 06:04:31 +02:00
2015-07-26 18:14:34 +02:00
@Override
2015-09-13 06:04:31 +02:00
public void registerWorldEvents() {
2015-07-26 18:14:34 +02:00
// TODO Auto-generated method stub
2015-07-30 16:25:16 +02:00
PS.log("registerWorldEvents NOT IMPLEMENTED YET");
2015-07-26 18:14:34 +02:00
}
2015-09-13 06:04:31 +02:00
2015-07-26 18:14:34 +02:00
@Override
2015-09-13 06:04:31 +02:00
public String getServerName() {
2015-07-30 16:25:16 +02:00
// TODO FIXME
throw new UnsupportedOperationException("NOT IMPLEMENTED YET");
2015-07-26 18:14:34 +02:00
}
2015-09-13 06:04:31 +02:00
2015-07-28 08:06:19 +02:00
@Override
2015-09-13 06:04:31 +02:00
public void startMetrics() {
try {
final SpongeMetrics metrics = new SpongeMetrics(game, this);
metrics.start();
log(C.PREFIX.s() + "&6Metrics enabled.");
2015-09-13 06:04:31 +02:00
} catch (final Exception e) {
log(C.PREFIX.s() + "&cFailed to load up metrics.");
}
2015-07-28 08:06:19 +02:00
}
2015-09-13 06:04:31 +02:00
2015-07-28 08:06:19 +02:00
@Override
2015-09-13 06:04:31 +02:00
public void setGenerator(final String world) {
2015-08-02 21:25:41 +02:00
// TODO THIS IS DONE DURING STARTUP ALREADY
2015-07-30 16:25:16 +02:00
}
2015-09-13 06:04:31 +02:00
2015-07-30 16:25:16 +02:00
@Override
2015-09-13 06:04:31 +02:00
public AbstractTitle initTitleManager() {
2015-07-30 16:25:16 +02:00
return new SpongeTitleManager();
2015-07-28 08:06:19 +02:00
}
2015-09-13 06:04:31 +02:00
2015-07-30 19:24:01 +02:00
@Override
2015-09-13 06:04:31 +02:00
public PlotPlayer wrapPlayer(final Object obj) {
if (obj instanceof Player) {
2015-07-30 19:24:01 +02:00
return SpongeUtil.getPlayer((Player) obj);
}
2015-09-11 12:09:22 +02:00
// else if (obj instanceof OfflinePlayer) {
// return BukkitUtil.getPlayer((OfflinePlayer) obj);
// }
2015-09-13 06:04:31 +02:00
else if (obj instanceof String) {
2015-07-30 19:24:01 +02:00
return UUIDHandler.getPlayer((String) obj);
2015-09-13 06:04:31 +02:00
} else if (obj instanceof UUID) {
return UUIDHandler.getPlayer((UUID) obj);
2015-07-30 19:24:01 +02:00
}
return null;
}
2015-09-13 06:04:31 +02:00
2015-08-03 20:20:04 +02:00
@Override
2015-09-13 06:04:31 +02:00
public String getNMSPackage() {
2015-08-03 20:20:04 +02:00
return "1_8_R3";
}
2015-09-13 06:04:31 +02:00
@Override
2015-09-13 06:04:31 +02:00
public ChatManager<?> initChatManager() {
return new SpongeChatManager();
}
2015-09-11 12:09:22 +02:00
}