2015-07-26 16:51:12 +02:00
|
|
|
package com.plotsquared.bukkit;
|
2015-07-05 17:44:10 +02:00
|
|
|
|
2015-07-28 08:06:19 +02:00
|
|
|
import java.io.File;
|
2015-08-03 20:20:04 +02:00
|
|
|
import java.lang.reflect.Method;
|
2015-07-28 08:06:19 +02:00
|
|
|
import java.util.Arrays;
|
2015-07-30 19:24:01 +02:00
|
|
|
import java.util.UUID;
|
2015-07-28 08:06:19 +02:00
|
|
|
|
|
|
|
import org.bukkit.Bukkit;
|
|
|
|
import org.bukkit.ChatColor;
|
|
|
|
import org.bukkit.Location;
|
2015-07-30 19:24:01 +02:00
|
|
|
import org.bukkit.OfflinePlayer;
|
2015-08-03 20:20:04 +02:00
|
|
|
import org.bukkit.Server;
|
2015-07-28 08:06:19 +02:00
|
|
|
import org.bukkit.World;
|
|
|
|
import org.bukkit.command.PluginCommand;
|
|
|
|
import org.bukkit.entity.Entity;
|
2015-07-30 19:24:01 +02:00
|
|
|
import org.bukkit.entity.Player;
|
2015-07-28 08:06:19 +02:00
|
|
|
import org.bukkit.event.Listener;
|
|
|
|
import org.bukkit.generator.ChunkGenerator;
|
|
|
|
import org.bukkit.plugin.Plugin;
|
|
|
|
import org.bukkit.plugin.java.JavaPlugin;
|
|
|
|
|
2015-08-09 11:58:29 +02:00
|
|
|
import com.intellectualcrafters.configuration.ConfigurationSection;
|
2015-07-26 16:51:12 +02:00
|
|
|
import com.intellectualcrafters.plot.IPlotMain;
|
|
|
|
import com.intellectualcrafters.plot.PS;
|
2015-07-27 19:50:04 +02:00
|
|
|
import com.intellectualcrafters.plot.commands.MainCommand;
|
|
|
|
import com.intellectualcrafters.plot.commands.WE_Anywhere;
|
2015-02-21 05:27:01 +01:00
|
|
|
import com.intellectualcrafters.plot.config.C;
|
2015-08-09 11:58:29 +02:00
|
|
|
import com.intellectualcrafters.plot.config.ConfigurationNode;
|
2015-02-21 05:27:01 +01:00
|
|
|
import com.intellectualcrafters.plot.config.Settings;
|
2015-07-27 19:50:04 +02:00
|
|
|
import com.intellectualcrafters.plot.flag.FlagManager;
|
|
|
|
import com.intellectualcrafters.plot.generator.HybridUtils;
|
|
|
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
|
|
|
import com.intellectualcrafters.plot.object.PlotWorld;
|
2015-08-09 11:58:29 +02:00
|
|
|
import com.intellectualcrafters.plot.object.SetupObject;
|
2015-07-30 16:25:16 +02:00
|
|
|
import com.intellectualcrafters.plot.util.AbstractTitle;
|
2015-07-28 08:06:19 +02:00
|
|
|
import com.intellectualcrafters.plot.util.BlockManager;
|
|
|
|
import com.intellectualcrafters.plot.util.BlockUpdateUtil;
|
|
|
|
import com.intellectualcrafters.plot.util.ChunkManager;
|
|
|
|
import com.intellectualcrafters.plot.util.ConsoleColors;
|
|
|
|
import com.intellectualcrafters.plot.util.EconHandler;
|
|
|
|
import com.intellectualcrafters.plot.util.EventUtil;
|
|
|
|
import com.intellectualcrafters.plot.util.InventoryUtil;
|
|
|
|
import com.intellectualcrafters.plot.util.MainUtil;
|
2015-07-30 16:25:16 +02:00
|
|
|
import com.intellectualcrafters.plot.util.SchematicHandler;
|
2015-07-28 13:38:49 +02:00
|
|
|
import com.intellectualcrafters.plot.util.SetupUtils;
|
2015-08-03 20:20:04 +02:00
|
|
|
import com.intellectualcrafters.plot.util.StringMan;
|
2015-07-28 08:06:19 +02:00
|
|
|
import com.intellectualcrafters.plot.util.TaskManager;
|
2015-07-30 19:24:01 +02:00
|
|
|
import com.intellectualcrafters.plot.util.UUIDHandler;
|
2015-07-28 08:06:19 +02:00
|
|
|
import com.intellectualcrafters.plot.util.UUIDHandlerImplementation;
|
2015-07-27 19:50:04 +02:00
|
|
|
import com.intellectualcrafters.plot.uuid.UUIDWrapper;
|
2015-07-26 16:51:12 +02:00
|
|
|
import com.plotsquared.bukkit.database.plotme.ClassicPlotMeConnector;
|
|
|
|
import com.plotsquared.bukkit.database.plotme.LikePlotMeConverter;
|
|
|
|
import com.plotsquared.bukkit.database.plotme.PlotMeConnector_017;
|
2015-07-26 19:00:09 +02:00
|
|
|
import com.plotsquared.bukkit.generator.BukkitGeneratorWrapper;
|
2015-07-26 16:51:12 +02:00
|
|
|
import com.plotsquared.bukkit.generator.HybridGen;
|
2015-07-28 08:06:19 +02:00
|
|
|
import com.plotsquared.bukkit.listeners.ChunkListener;
|
|
|
|
import com.plotsquared.bukkit.listeners.ForceFieldListener;
|
|
|
|
import com.plotsquared.bukkit.listeners.PlayerEvents;
|
|
|
|
import com.plotsquared.bukkit.listeners.PlayerEvents_1_8;
|
|
|
|
import com.plotsquared.bukkit.listeners.PlayerEvents_1_8_3;
|
|
|
|
import com.plotsquared.bukkit.listeners.PlotPlusListener;
|
|
|
|
import com.plotsquared.bukkit.listeners.TNTListener;
|
|
|
|
import com.plotsquared.bukkit.listeners.WorldEvents;
|
2015-07-26 16:51:12 +02:00
|
|
|
import com.plotsquared.bukkit.listeners.worldedit.WEListener;
|
|
|
|
import com.plotsquared.bukkit.listeners.worldedit.WESubscriber;
|
|
|
|
import com.plotsquared.bukkit.titles.DefaultTitle;
|
2015-07-30 19:24:01 +02:00
|
|
|
import com.plotsquared.bukkit.util.BukkitChunkManager;
|
|
|
|
import com.plotsquared.bukkit.util.BukkitCommand;
|
|
|
|
import com.plotsquared.bukkit.util.BukkitEconHandler;
|
|
|
|
import com.plotsquared.bukkit.util.BukkitEventUtil;
|
2015-07-28 08:06:19 +02:00
|
|
|
import com.plotsquared.bukkit.util.BukkitHybridUtils;
|
2015-07-30 19:24:01 +02:00
|
|
|
import com.plotsquared.bukkit.util.BukkitInventoryUtil;
|
|
|
|
import com.plotsquared.bukkit.util.BukkitSchematicHandler;
|
|
|
|
import com.plotsquared.bukkit.util.BukkitSetBlockManager;
|
|
|
|
import com.plotsquared.bukkit.util.BukkitSetupUtils;
|
|
|
|
import com.plotsquared.bukkit.util.BukkitTaskManager;
|
|
|
|
import com.plotsquared.bukkit.util.BukkitUtil;
|
|
|
|
import com.plotsquared.bukkit.util.Metrics;
|
|
|
|
import com.plotsquared.bukkit.util.SendChunk;
|
|
|
|
import com.plotsquared.bukkit.util.SetBlockFast;
|
|
|
|
import com.plotsquared.bukkit.util.SetBlockFast_1_8;
|
|
|
|
import com.plotsquared.bukkit.util.SetBlockSlow;
|
|
|
|
import com.plotsquared.bukkit.util.SetGenCB;
|
2015-07-28 08:06:19 +02:00
|
|
|
import com.plotsquared.bukkit.uuid.DefaultUUIDWrapper;
|
2015-07-30 19:24:01 +02:00
|
|
|
import com.plotsquared.bukkit.uuid.FileUUIDHandler;
|
2015-07-28 08:06:19 +02:00
|
|
|
import com.plotsquared.bukkit.uuid.LowerOfflineUUIDWrapper;
|
|
|
|
import com.plotsquared.bukkit.uuid.OfflineUUIDWrapper;
|
2015-07-30 19:24:01 +02:00
|
|
|
import com.plotsquared.bukkit.uuid.SQLUUIDHandler;
|
2015-04-12 07:22:03 +02:00
|
|
|
import com.sk89q.worldedit.WorldEdit;
|
2015-02-21 05:27:01 +01:00
|
|
|
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
2015-02-19 07:08:15 +01:00
|
|
|
|
2015-02-20 07:34:19 +01:00
|
|
|
public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
2015-07-06 11:38:37 +02:00
|
|
|
|
2015-07-26 18:14:34 +02:00
|
|
|
public static BukkitMain THIS;
|
2015-08-02 21:25:41 +02:00
|
|
|
public static WorldEditPlugin worldEdit;
|
2015-07-06 11:38:37 +02:00
|
|
|
|
2015-06-24 05:31:13 +02:00
|
|
|
private int[] version;
|
2015-07-26 17:08:06 +02:00
|
|
|
|
2015-08-02 21:25:41 +02:00
|
|
|
|
2015-06-24 05:31:13 +02:00
|
|
|
@Override
|
2015-07-26 17:08:06 +02:00
|
|
|
public int[] getServerVersion() {
|
2015-06-24 05:31:13 +02:00
|
|
|
if (version == null) {
|
|
|
|
try {
|
|
|
|
version = new int[3];
|
|
|
|
final String[] split = Bukkit.getBukkitVersion().split("-")[0].split("\\.");
|
|
|
|
version[0] = Integer.parseInt(split[0]);
|
|
|
|
version[1] = Integer.parseInt(split[1]);
|
2015-08-07 03:38:39 +02:00
|
|
|
if (split.length == 3) {
|
2015-06-24 05:31:13 +02:00
|
|
|
version[2] = Integer.parseInt(split[2]);
|
|
|
|
}
|
2015-07-06 11:38:37 +02:00
|
|
|
} catch (Exception e) {
|
2015-07-17 05:48:23 +02:00
|
|
|
e.printStackTrace();
|
2015-08-03 20:20:04 +02:00
|
|
|
PS.debug(StringMan.getString(Bukkit.getBukkitVersion()));
|
|
|
|
PS.debug(StringMan.getString(Bukkit.getBukkitVersion().split("-")[0].split("\\.")));
|
|
|
|
return new int[] { Integer.MAX_VALUE, 0, 0 };
|
2015-02-20 11:53:18 +01:00
|
|
|
}
|
|
|
|
}
|
2015-07-26 17:08:06 +02:00
|
|
|
return version;
|
2015-02-20 11:53:18 +01:00
|
|
|
}
|
2015-07-06 11:38:37 +02:00
|
|
|
|
2015-02-19 07:08:15 +01:00
|
|
|
@Override
|
|
|
|
public void onEnable() {
|
|
|
|
THIS = this;
|
2015-07-03 14:15:20 +02:00
|
|
|
PS.instance = new PS(this);
|
2015-02-19 07:08:15 +01:00
|
|
|
}
|
2015-04-01 10:25:58 +02:00
|
|
|
|
2015-02-19 07:08:15 +01:00
|
|
|
@Override
|
|
|
|
public void onDisable() {
|
2015-08-10 23:03:34 +02:00
|
|
|
Bukkit.getScheduler().cancelTasks(this);
|
2015-07-03 14:15:20 +02:00
|
|
|
PS.get().disable();
|
2015-02-19 07:08:15 +01:00
|
|
|
THIS = null;
|
|
|
|
}
|
2015-07-06 11:38:37 +02:00
|
|
|
|
2015-02-19 07:08:15 +01:00
|
|
|
@Override
|
|
|
|
public void log(String message) {
|
2015-03-17 09:38:06 +01:00
|
|
|
if (message == null) {
|
|
|
|
return;
|
|
|
|
}
|
2015-07-06 11:38:37 +02:00
|
|
|
if (THIS != null && Bukkit.getServer().getConsoleSender() != null) {
|
|
|
|
try {
|
2015-07-17 12:48:13 +02:00
|
|
|
message = C.color(message);
|
2015-07-06 11:38:37 +02:00
|
|
|
if (!Settings.CONSOLE_COLOR) {
|
|
|
|
message = ChatColor.stripColor(message);
|
|
|
|
}
|
|
|
|
Bukkit.getServer().getConsoleSender().sendMessage(message);
|
|
|
|
return;
|
2015-02-19 09:51:10 +01:00
|
|
|
}
|
2015-07-27 19:50:04 +02:00
|
|
|
catch (Throwable e) {}
|
2015-02-19 09:51:10 +01:00
|
|
|
}
|
2015-07-06 11:38:37 +02:00
|
|
|
System.out.println(ConsoleColors.fromString(message));
|
2015-02-19 07:08:15 +01:00
|
|
|
}
|
2015-07-06 11:38:37 +02:00
|
|
|
|
2015-02-19 07:08:15 +01:00
|
|
|
@Override
|
|
|
|
public void disable() {
|
2015-07-18 13:18:45 +02:00
|
|
|
if (THIS != null) {
|
|
|
|
onDisable();
|
|
|
|
}
|
2015-02-19 07:08:15 +01:00
|
|
|
}
|
2015-07-06 11:38:37 +02:00
|
|
|
|
2015-02-19 07:08:15 +01:00
|
|
|
@Override
|
2015-07-26 17:08:06 +02:00
|
|
|
public int[] getPluginVersion() {
|
|
|
|
String[] split = this.getDescription().getVersion().split("\\.");
|
|
|
|
return new int[] { Integer.parseInt(split[0]), Integer.parseInt(split[1]), Integer.parseInt(split[2]) };
|
2015-02-19 07:08:15 +01:00
|
|
|
}
|
2015-07-06 11:38:37 +02:00
|
|
|
|
2015-02-19 07:08:15 +01:00
|
|
|
@Override
|
|
|
|
public void registerCommands() {
|
2015-02-21 06:48:49 +01:00
|
|
|
final BukkitCommand bcmd = new BukkitCommand();
|
2015-02-19 07:08:15 +01:00
|
|
|
final PluginCommand plotCommand = getCommand("plots");
|
2015-02-21 06:48:49 +01:00
|
|
|
plotCommand.setExecutor(bcmd);
|
2015-02-19 07:08:15 +01:00
|
|
|
plotCommand.setAliases(Arrays.asList("p", "ps", "plotme", "plot"));
|
2015-02-21 06:48:49 +01:00
|
|
|
plotCommand.setTabCompleter(bcmd);
|
2015-02-19 07:08:15 +01:00
|
|
|
}
|
2015-07-06 11:38:37 +02:00
|
|
|
|
2015-02-19 07:08:15 +01:00
|
|
|
@Override
|
|
|
|
public File getDirectory() {
|
|
|
|
return getDataFolder();
|
|
|
|
}
|
2015-07-06 11:38:37 +02:00
|
|
|
|
2015-02-19 07:08:15 +01:00
|
|
|
@Override
|
|
|
|
public TaskManager getTaskManager() {
|
|
|
|
return new BukkitTaskManager();
|
|
|
|
}
|
2015-07-06 11:38:37 +02:00
|
|
|
|
2015-02-19 07:08:15 +01:00
|
|
|
@Override
|
|
|
|
public void runEntityTask() {
|
|
|
|
log(C.PREFIX.s() + "KillAllEntities started.");
|
|
|
|
TaskManager.runTaskRepeat(new Runnable() {
|
|
|
|
long ticked = 0l;
|
|
|
|
long error = 0l;
|
2015-02-23 02:32:27 +01:00
|
|
|
|
2015-02-19 07:08:15 +01:00
|
|
|
@Override
|
|
|
|
public void run() {
|
|
|
|
if (this.ticked > 36_000L) {
|
|
|
|
this.ticked = 0l;
|
|
|
|
if (this.error > 0) {
|
|
|
|
log(C.PREFIX.s() + "KillAllEntities has been running for 6 hours. Errors: " + this.error);
|
|
|
|
}
|
|
|
|
this.error = 0l;
|
|
|
|
}
|
|
|
|
World world;
|
2015-07-14 15:25:01 +02:00
|
|
|
for (final PlotWorld pw : PS.get().getPlotWorldObjects()) {
|
|
|
|
world = Bukkit.getWorld(pw.worldname);
|
2015-02-19 07:08:15 +01:00
|
|
|
try {
|
2015-08-04 14:21:12 +02:00
|
|
|
for (Entity entity : world.getEntities()) {
|
|
|
|
switch (entity.getType()) {
|
|
|
|
case EGG:
|
|
|
|
case ENDER_CRYSTAL:
|
|
|
|
case COMPLEX_PART:
|
|
|
|
case ARMOR_STAND:
|
|
|
|
case FISHING_HOOK:
|
|
|
|
case ENDER_SIGNAL:
|
|
|
|
case EXPERIENCE_ORB:
|
|
|
|
case LEASH_HITCH:
|
|
|
|
case FIREWORK:
|
|
|
|
case WEATHER:
|
|
|
|
case LIGHTNING:
|
|
|
|
case WITHER_SKULL:
|
|
|
|
case UNKNOWN:
|
|
|
|
case ITEM_FRAME:
|
|
|
|
case PAINTING:
|
|
|
|
case PLAYER: {
|
|
|
|
// non moving / unremovable
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
case THROWN_EXP_BOTTLE:
|
|
|
|
case SPLASH_POTION:
|
|
|
|
case SNOWBALL:
|
|
|
|
case ENDER_PEARL:
|
|
|
|
case ARROW: {
|
|
|
|
// managed elsewhere | projectile
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
case MINECART:
|
|
|
|
case MINECART_CHEST:
|
|
|
|
case MINECART_COMMAND:
|
|
|
|
case MINECART_FURNACE:
|
|
|
|
case MINECART_HOPPER:
|
|
|
|
case MINECART_MOB_SPAWNER:
|
|
|
|
case MINECART_TNT:
|
|
|
|
case BOAT: {
|
|
|
|
if (!Settings.KILL_ROAD_VEHICLES) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
Location loc = entity.getLocation();
|
|
|
|
if (MainUtil.isPlotRoad(BukkitUtil.getLocation(loc))) {
|
|
|
|
entity.remove();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case SMALL_FIREBALL:
|
|
|
|
case FIREBALL:
|
|
|
|
case DROPPED_ITEM: {
|
|
|
|
// dropped item
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
case PRIMED_TNT:
|
|
|
|
case FALLING_BLOCK: {
|
|
|
|
// managed elsewhere
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
case BAT:
|
|
|
|
case BLAZE:
|
|
|
|
case CAVE_SPIDER:
|
|
|
|
case CHICKEN:
|
|
|
|
case COW:
|
|
|
|
case CREEPER:
|
|
|
|
case ENDERMAN:
|
|
|
|
case ENDERMITE:
|
|
|
|
case ENDER_DRAGON:
|
|
|
|
case GHAST:
|
|
|
|
case GIANT:
|
|
|
|
case GUARDIAN:
|
|
|
|
case HORSE:
|
|
|
|
case IRON_GOLEM:
|
|
|
|
case MAGMA_CUBE:
|
|
|
|
case MUSHROOM_COW:
|
|
|
|
case OCELOT:
|
|
|
|
case PIG:
|
|
|
|
case PIG_ZOMBIE:
|
|
|
|
case RABBIT:
|
|
|
|
case SHEEP:
|
|
|
|
case SILVERFISH:
|
|
|
|
case SKELETON:
|
|
|
|
case SLIME:
|
|
|
|
case SNOWMAN:
|
|
|
|
case SPIDER:
|
|
|
|
case SQUID:
|
|
|
|
case VILLAGER:
|
|
|
|
case WITCH:
|
|
|
|
case WITHER:
|
|
|
|
case WOLF:
|
|
|
|
case ZOMBIE:
|
|
|
|
default: {
|
|
|
|
if (!Settings.KILL_ROAD_MOBS) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
Location loc = entity.getLocation();
|
|
|
|
if (MainUtil.isPlotRoad(BukkitUtil.getLocation(loc))) {
|
2015-08-08 19:27:18 +02:00
|
|
|
Entity passenger = entity.getPassenger();
|
|
|
|
if (!(passenger instanceof Player)) {
|
|
|
|
entity.remove();
|
|
|
|
}
|
2015-08-04 14:21:12 +02:00
|
|
|
}
|
|
|
|
break;
|
2015-02-19 07:08:15 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (final Throwable e) {
|
|
|
|
++this.error;
|
|
|
|
} finally {
|
|
|
|
++this.ticked;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, 20);
|
|
|
|
}
|
2015-07-06 11:38:37 +02:00
|
|
|
|
2015-02-19 09:51:10 +01:00
|
|
|
@Override
|
|
|
|
final public ChunkGenerator getDefaultWorldGenerator(final String world, final String id) {
|
2015-05-04 15:53:24 +02:00
|
|
|
WorldEvents.lastWorld = world;
|
2015-07-03 14:15:20 +02:00
|
|
|
if (!PS.get().setupPlotWorld(world, id)) {
|
2015-02-19 09:51:10 +01:00
|
|
|
return null;
|
|
|
|
}
|
2015-05-09 08:24:03 +02:00
|
|
|
HybridGen result = new HybridGen(world);
|
2015-05-04 15:53:24 +02:00
|
|
|
TaskManager.runTaskLater(new Runnable() {
|
|
|
|
@Override
|
|
|
|
public void run() {
|
|
|
|
if (WorldEvents.lastWorld != null && WorldEvents.lastWorld.equals(world)) {
|
|
|
|
WorldEvents.lastWorld = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, 20);
|
|
|
|
return result;
|
2015-02-19 09:51:10 +01:00
|
|
|
}
|
2015-07-06 11:38:37 +02:00
|
|
|
|
2015-02-19 07:08:15 +01:00
|
|
|
@Override
|
|
|
|
public void registerPlayerEvents() {
|
|
|
|
getServer().getPluginManager().registerEvents(new PlayerEvents(), this);
|
2015-07-26 17:08:06 +02:00
|
|
|
if (PS.get().checkVersion(this.getServerVersion(), 1, 8, 0)) {
|
2015-02-19 07:08:15 +01:00
|
|
|
getServer().getPluginManager().registerEvents(new PlayerEvents_1_8(), this);
|
|
|
|
}
|
2015-07-26 17:08:06 +02:00
|
|
|
if (PS.get().checkVersion(this.getServerVersion(), 1, 8, 3)) {
|
2015-05-13 17:49:57 +02:00
|
|
|
getServer().getPluginManager().registerEvents(new PlayerEvents_1_8_3(), this);
|
|
|
|
}
|
2015-02-19 07:08:15 +01:00
|
|
|
}
|
2015-07-06 11:38:37 +02:00
|
|
|
|
2015-02-19 07:08:15 +01:00
|
|
|
@Override
|
|
|
|
public void registerInventoryEvents() {
|
2015-07-28 08:06:19 +02:00
|
|
|
|
|
|
|
// Part of PlayerEvents - can be moved if necessary
|
|
|
|
|
2015-02-19 07:08:15 +01:00
|
|
|
}
|
2015-07-06 11:38:37 +02:00
|
|
|
|
2015-02-19 07:08:15 +01:00
|
|
|
@Override
|
|
|
|
public void registerPlotPlusEvents() {
|
|
|
|
PlotPlusListener.startRunnable(this);
|
|
|
|
getServer().getPluginManager().registerEvents(new PlotPlusListener(), this);
|
|
|
|
}
|
2015-07-06 11:38:37 +02:00
|
|
|
|
2015-02-19 07:08:15 +01:00
|
|
|
@Override
|
|
|
|
public void registerForceFieldEvents() {
|
|
|
|
getServer().getPluginManager().registerEvents(new ForceFieldListener(), this);
|
|
|
|
}
|
2015-07-06 11:38:37 +02:00
|
|
|
|
2015-02-19 07:08:15 +01:00
|
|
|
@Override
|
|
|
|
public void registerWorldEditEvents() {
|
|
|
|
if (getServer().getPluginManager().getPlugin("WorldEdit") != null) {
|
2015-08-02 21:25:41 +02:00
|
|
|
BukkitMain.worldEdit = (WorldEditPlugin) getServer().getPluginManager().getPlugin("WorldEdit");
|
|
|
|
final String version = BukkitMain.worldEdit.getDescription().getVersion();
|
2015-02-19 07:08:15 +01:00
|
|
|
if ((version != null) && version.startsWith("5.")) {
|
|
|
|
log("&cThis version of WorldEdit does not support PlotSquared.");
|
|
|
|
log("&cPlease use WorldEdit 6+ for masking support");
|
|
|
|
log("&c - http://builds.enginehub.org/job/worldedit");
|
|
|
|
} else {
|
2015-04-18 15:47:13 +02:00
|
|
|
getServer().getPluginManager().registerEvents(new WEListener(), this);
|
|
|
|
WorldEdit.getInstance().getEventBus().register(new WESubscriber());
|
2015-07-27 17:41:06 +02:00
|
|
|
MainCommand.getInstance().createCommand(new WE_Anywhere());
|
2015-02-19 07:08:15 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-07-06 11:38:37 +02:00
|
|
|
|
2015-02-19 07:08:15 +01:00
|
|
|
@Override
|
2015-06-05 14:39:31 +02:00
|
|
|
public EconHandler getEconomyHandler() {
|
2015-06-07 21:37:40 +02:00
|
|
|
try {
|
|
|
|
BukkitEconHandler econ = new BukkitEconHandler();
|
|
|
|
if (econ.init()) {
|
|
|
|
return econ;
|
|
|
|
}
|
2015-07-03 11:30:26 +02:00
|
|
|
} catch (Throwable e) {
|
2015-02-19 07:08:15 +01:00
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
2015-07-06 11:38:37 +02:00
|
|
|
|
2015-02-19 09:51:10 +01:00
|
|
|
@Override
|
2015-02-22 14:20:41 +01:00
|
|
|
public BlockManager initBlockManager() {
|
2015-07-26 17:08:06 +02:00
|
|
|
if (PS.get().checkVersion(this.getServerVersion(), 1, 8, 0)) {
|
2015-02-19 09:51:10 +01:00
|
|
|
try {
|
2015-02-23 06:29:45 +01:00
|
|
|
BukkitSetBlockManager.setBlockManager = new SetBlockFast_1_8();
|
2015-02-20 07:34:19 +01:00
|
|
|
} catch (final Throwable e) {
|
2015-02-19 09:51:10 +01:00
|
|
|
e.printStackTrace();
|
2015-02-23 06:29:45 +01:00
|
|
|
BukkitSetBlockManager.setBlockManager = new SetBlockSlow();
|
2015-02-19 09:51:10 +01:00
|
|
|
}
|
2015-06-09 22:00:53 +02:00
|
|
|
try {
|
|
|
|
new SendChunk();
|
|
|
|
MainUtil.canSendChunk = true;
|
|
|
|
} catch (final Throwable e) {
|
|
|
|
MainUtil.canSendChunk = false;
|
|
|
|
}
|
2015-02-20 07:34:19 +01:00
|
|
|
} else {
|
2015-02-19 09:51:10 +01:00
|
|
|
try {
|
2015-02-23 06:29:45 +01:00
|
|
|
BukkitSetBlockManager.setBlockManager = new SetBlockFast();
|
2015-02-20 07:34:19 +01:00
|
|
|
} catch (final Throwable e) {
|
2015-03-18 06:50:07 +01:00
|
|
|
MainUtil.canSetFast = false;
|
2015-02-23 06:29:45 +01:00
|
|
|
BukkitSetBlockManager.setBlockManager = new SetBlockSlow();
|
2015-02-19 09:51:10 +01:00
|
|
|
}
|
|
|
|
}
|
2015-02-23 06:29:45 +01:00
|
|
|
BlockUpdateUtil.setBlockManager = BukkitSetBlockManager.setBlockManager;
|
2015-02-22 14:20:41 +01:00
|
|
|
return BlockManager.manager = new BukkitUtil();
|
2015-02-19 09:51:10 +01:00
|
|
|
}
|
2015-07-06 11:38:37 +02:00
|
|
|
|
2015-02-19 09:51:10 +01:00
|
|
|
@Override
|
|
|
|
public boolean initPlotMeConverter() {
|
2015-05-01 13:00:17 +02:00
|
|
|
TaskManager.runTaskLaterAsync(new Runnable() {
|
|
|
|
@Override
|
|
|
|
public void run() {
|
2015-07-09 06:19:49 +02:00
|
|
|
if (new LikePlotMeConverter("PlotMe").run(new ClassicPlotMeConnector())) return;
|
|
|
|
if (new LikePlotMeConverter("PlotMe").run(new PlotMeConnector_017())) return;
|
|
|
|
if (new LikePlotMeConverter("AthionPlots").run(new ClassicPlotMeConnector())) return;
|
2015-05-01 13:00:17 +02:00
|
|
|
}
|
|
|
|
}, 20);
|
2015-07-03 11:30:26 +02:00
|
|
|
return Bukkit.getPluginManager().getPlugin("PlotMe") != null || Bukkit.getPluginManager().getPlugin("AthionPlots") != null;
|
2015-02-19 09:51:10 +01:00
|
|
|
}
|
2015-07-06 11:38:37 +02:00
|
|
|
|
2015-02-19 09:51:10 +01:00
|
|
|
@Override
|
2015-07-26 19:00:09 +02:00
|
|
|
public BukkitGeneratorWrapper getGenerator(final String world, final String name) {
|
2015-07-27 19:28:39 +02:00
|
|
|
if (name == null) {
|
|
|
|
return new BukkitGeneratorWrapper(world, null);
|
|
|
|
}
|
2015-02-20 07:34:19 +01:00
|
|
|
final Plugin gen_plugin = Bukkit.getPluginManager().getPlugin(name);
|
2015-07-26 19:00:09 +02:00
|
|
|
ChunkGenerator gen;
|
2015-02-20 07:34:19 +01:00
|
|
|
if ((gen_plugin != null) && gen_plugin.isEnabled()) {
|
2015-07-26 19:00:09 +02:00
|
|
|
gen = gen_plugin.getDefaultWorldGenerator(world, "");
|
2015-02-19 09:51:10 +01:00
|
|
|
} else {
|
2015-07-26 19:00:09 +02:00
|
|
|
gen = new HybridGen(world);
|
2015-02-19 09:51:10 +01:00
|
|
|
}
|
2015-07-26 19:00:09 +02:00
|
|
|
return new BukkitGeneratorWrapper(world, gen);
|
2015-02-19 09:51:10 +01:00
|
|
|
}
|
2015-07-06 11:38:37 +02:00
|
|
|
|
2015-02-22 14:20:41 +01:00
|
|
|
@Override
|
|
|
|
public HybridUtils initHybridUtils() {
|
|
|
|
return new BukkitHybridUtils();
|
|
|
|
}
|
2015-02-23 02:32:27 +01:00
|
|
|
|
2015-02-22 14:20:41 +01:00
|
|
|
@Override
|
|
|
|
public SetupUtils initSetupUtils() {
|
|
|
|
return new BukkitSetupUtils();
|
|
|
|
}
|
2015-02-23 02:32:27 +01:00
|
|
|
|
2015-02-23 00:12:33 +01:00
|
|
|
@Override
|
2015-07-27 09:26:50 +02:00
|
|
|
public UUIDHandlerImplementation initUUIDHandler() {
|
2015-07-26 17:08:06 +02:00
|
|
|
final boolean checkVersion = PS.get().checkVersion(this.getServerVersion(), 1, 7, 6);
|
2015-07-27 09:26:50 +02:00
|
|
|
UUIDWrapper wrapper;
|
2015-03-13 04:15:00 +01:00
|
|
|
if (Settings.OFFLINE_MODE) {
|
2015-04-12 07:24:54 +02:00
|
|
|
if (Settings.UUID_LOWERCASE) {
|
2015-07-27 09:26:50 +02:00
|
|
|
wrapper = (new LowerOfflineUUIDWrapper());
|
2015-07-06 11:38:37 +02:00
|
|
|
} else {
|
2015-07-27 09:26:50 +02:00
|
|
|
wrapper = (new OfflineUUIDWrapper());
|
2015-04-12 07:24:54 +02:00
|
|
|
}
|
2015-02-23 00:12:33 +01:00
|
|
|
Settings.OFFLINE_MODE = true;
|
2015-02-23 02:32:27 +01:00
|
|
|
} else if (checkVersion) {
|
2015-07-27 09:26:50 +02:00
|
|
|
wrapper = (new DefaultUUIDWrapper());
|
2015-02-23 00:12:33 +01:00
|
|
|
Settings.OFFLINE_MODE = false;
|
2015-02-23 02:32:27 +01:00
|
|
|
} else {
|
2015-04-12 07:24:54 +02:00
|
|
|
if (Settings.UUID_LOWERCASE) {
|
2015-07-27 09:26:50 +02:00
|
|
|
wrapper = (new LowerOfflineUUIDWrapper());
|
2015-07-06 11:38:37 +02:00
|
|
|
} else {
|
2015-07-27 09:26:50 +02:00
|
|
|
wrapper = (new OfflineUUIDWrapper());
|
2015-04-12 07:24:54 +02:00
|
|
|
}
|
2015-02-23 00:12:33 +01:00
|
|
|
Settings.OFFLINE_MODE = true;
|
|
|
|
}
|
2015-05-02 12:08:30 +02:00
|
|
|
if (!checkVersion) {
|
|
|
|
log(C.PREFIX.s() + " &c[WARN] Titles are disabled - please update your version of Bukkit to support this feature.");
|
|
|
|
Settings.TITLES = false;
|
|
|
|
FlagManager.removeFlag(FlagManager.getFlag("titles"));
|
|
|
|
} else {
|
|
|
|
AbstractTitle.TITLE_CLASS = new DefaultTitle();
|
2015-07-27 15:10:14 +02:00
|
|
|
if (wrapper instanceof DefaultUUIDWrapper) {
|
2015-05-02 12:08:30 +02:00
|
|
|
Settings.TWIN_MODE_UUID = true;
|
2015-07-31 07:40:53 +02:00
|
|
|
} else if (wrapper.getClass() == OfflineUUIDWrapper.class && !Bukkit.getOnlineMode()) {
|
2015-05-02 12:08:30 +02:00
|
|
|
Settings.TWIN_MODE_UUID = true;
|
|
|
|
}
|
|
|
|
}
|
2015-02-23 00:12:33 +01:00
|
|
|
if (Settings.OFFLINE_MODE) {
|
2015-02-23 02:32:27 +01:00
|
|
|
log(C.PREFIX.s() + " &6PlotSquared is using Offline Mode UUIDs either because of user preference, or because you are using an old version of Bukkit");
|
|
|
|
} else {
|
|
|
|
log(C.PREFIX.s() + " &6PlotSquared is using online UUIDs");
|
2015-02-23 00:12:33 +01:00
|
|
|
}
|
2015-07-27 09:26:50 +02:00
|
|
|
return Settings.USE_SQLUUIDHANDLER ? new SQLUUIDHandler(wrapper) : new FileUUIDHandler(wrapper);
|
2015-02-23 00:12:33 +01:00
|
|
|
}
|
2015-02-23 02:32:27 +01:00
|
|
|
|
2015-02-23 01:05:25 +01:00
|
|
|
@Override
|
2015-02-23 06:29:45 +01:00
|
|
|
public ChunkManager initChunkManager() {
|
|
|
|
return new BukkitChunkManager();
|
|
|
|
}
|
2015-07-06 11:38:37 +02:00
|
|
|
|
2015-02-23 06:29:45 +01:00
|
|
|
@Override
|
|
|
|
public EventUtil initEventUtil() {
|
|
|
|
return new BukkitEventUtil();
|
2015-02-23 01:05:25 +01:00
|
|
|
}
|
2015-07-06 11:38:37 +02:00
|
|
|
|
2015-04-01 10:25:58 +02:00
|
|
|
@Override
|
|
|
|
public void registerTNTListener() {
|
|
|
|
getServer().getPluginManager().registerEvents(new TNTListener(), this);
|
|
|
|
}
|
2015-07-06 11:38:37 +02:00
|
|
|
|
2015-04-09 07:41:14 +02:00
|
|
|
@Override
|
|
|
|
public void unregister(PlotPlayer player) {
|
|
|
|
BukkitUtil.removePlayer(player.getName());
|
|
|
|
}
|
2015-07-06 11:38:37 +02:00
|
|
|
|
2015-04-26 08:29:58 +02:00
|
|
|
@Override
|
|
|
|
public void registerChunkProcessor() {
|
|
|
|
getServer().getPluginManager().registerEvents(new ChunkListener(), this);
|
|
|
|
}
|
2015-06-05 16:08:16 +02:00
|
|
|
|
2015-04-26 08:29:58 +02:00
|
|
|
@Override
|
|
|
|
public void registerWorldEvents() {
|
|
|
|
getServer().getPluginManager().registerEvents(new WorldEvents(), this);
|
|
|
|
}
|
2015-07-06 11:38:37 +02:00
|
|
|
|
2015-07-03 04:11:41 +02:00
|
|
|
@Override
|
|
|
|
public InventoryUtil initInventoryUtil() {
|
|
|
|
return new BukkitInventoryUtil();
|
|
|
|
}
|
2015-07-24 19:37:39 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public String getServerName() {
|
|
|
|
return Bukkit.getServerName();
|
|
|
|
}
|
2015-07-28 08:06:19 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void startMetrics() {
|
|
|
|
try {
|
|
|
|
final Metrics metrics = new Metrics(this);
|
|
|
|
metrics.start();
|
|
|
|
log(C.PREFIX.s() + "&6Metrics enabled.");
|
|
|
|
} catch (final Exception e) {
|
|
|
|
log(C.PREFIX.s() + "&cFailed to load up metrics.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-08-09 11:58:29 +02:00
|
|
|
public void setGenerator(String worldname) {
|
|
|
|
World world = BukkitUtil.getWorld(worldname);
|
|
|
|
if (world == null) {
|
|
|
|
// create world
|
|
|
|
ConfigurationSection worldConfig = PS.get().config.getConfigurationSection("worlds." + worldname);
|
|
|
|
String manager = worldConfig.getString("generator.plugin");
|
|
|
|
if (manager == null) {
|
|
|
|
manager = "PlotSquared";
|
|
|
|
}
|
|
|
|
String generator = worldConfig.getString("generator.init");
|
|
|
|
if (generator == null) {
|
|
|
|
generator = manager;
|
|
|
|
}
|
|
|
|
|
|
|
|
int type = worldConfig.getInt("generator.type");
|
|
|
|
int terrain = worldConfig.getInt("generator.terrain");
|
|
|
|
SetupObject setup = new SetupObject();
|
|
|
|
setup.plotManager = manager;
|
|
|
|
setup.setupGenerator = generator;
|
|
|
|
setup.type = type;
|
|
|
|
setup.terrain = terrain;
|
|
|
|
setup.step = new ConfigurationNode[0];
|
|
|
|
setup.world = worldname;
|
|
|
|
SetupUtils.manager.setupWorld(setup);
|
|
|
|
return;
|
|
|
|
}
|
2015-07-28 08:06:19 +02:00
|
|
|
try {
|
2015-08-09 11:58:29 +02:00
|
|
|
SetGenCB.setGenerator(BukkitUtil.getWorld(worldname));
|
2015-07-28 08:06:19 +02:00
|
|
|
} catch (Exception e) {
|
|
|
|
log("Failed to reload world: " + world);
|
|
|
|
Bukkit.getServer().unloadWorld(world, false);
|
|
|
|
}
|
|
|
|
}
|
2015-07-30 16:25:16 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public SchematicHandler initSchematicHandler() {
|
|
|
|
return new BukkitSchematicHandler();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public AbstractTitle initTitleManager() {
|
|
|
|
// Already initialized in UUID handler
|
|
|
|
return AbstractTitle.TITLE_CLASS;
|
|
|
|
}
|
2015-07-30 19:24:01 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public PlotPlayer wrapPlayer(Object obj) {
|
|
|
|
if (obj instanceof Player) {
|
|
|
|
return BukkitUtil.getPlayer((Player) obj);
|
|
|
|
}
|
|
|
|
else if (obj instanceof OfflinePlayer) {
|
|
|
|
return BukkitUtil.getPlayer((OfflinePlayer) obj);
|
|
|
|
}
|
|
|
|
else if (obj instanceof String) {
|
|
|
|
return UUIDHandler.getPlayer((String) obj);
|
|
|
|
}
|
|
|
|
else if (obj instanceof UUID) {
|
|
|
|
return UUIDHandler.getPlayer((UUID) obj);
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
2015-08-03 20:20:04 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public String getNMSPackage() {
|
|
|
|
final Server server = Bukkit.getServer();
|
|
|
|
final Class<?> bukkitServerClass = server.getClass();
|
|
|
|
String[] pas = bukkitServerClass.getName().split("\\.");
|
|
|
|
if (pas.length == 5) {
|
|
|
|
final String verB = pas[3];
|
|
|
|
return verB;
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
final Method getHandle = bukkitServerClass.getDeclaredMethod("getHandle");
|
|
|
|
final Object handle = getHandle.invoke(server);
|
|
|
|
final Class handleServerClass = handle.getClass();
|
|
|
|
pas = handleServerClass.getName().split("\\.");
|
|
|
|
if (pas.length == 5) {
|
|
|
|
final String verM = pas[3];
|
|
|
|
return verM;
|
|
|
|
}
|
|
|
|
} catch (Exception e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
PS.debug("Unknown NMS package: " + StringMan.getString(pas));
|
|
|
|
return "1_8_R3";
|
|
|
|
}
|
2015-02-19 04:24:05 +01:00
|
|
|
}
|