2015-02-19 04:24:05 +01:00
|
|
|
package com.intellectualcrafters.plot;
|
|
|
|
|
2015-02-21 05:27:01 +01:00
|
|
|
import java.io.File;
|
|
|
|
import java.util.Arrays;
|
2015-03-22 12:43:46 +01:00
|
|
|
import java.util.List;
|
2015-02-20 12:37:34 +01:00
|
|
|
|
2015-02-20 11:53:18 +01:00
|
|
|
import net.milkbowl.vault.economy.Economy;
|
2015-02-20 12:37:34 +01:00
|
|
|
|
2015-02-20 11:53:18 +01:00
|
|
|
import org.bukkit.Bukkit;
|
|
|
|
import org.bukkit.ChatColor;
|
|
|
|
import org.bukkit.Chunk;
|
|
|
|
import org.bukkit.World;
|
|
|
|
import org.bukkit.command.PluginCommand;
|
|
|
|
import org.bukkit.entity.Entity;
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
import org.bukkit.event.Listener;
|
|
|
|
import org.bukkit.generator.ChunkGenerator;
|
|
|
|
import org.bukkit.plugin.Plugin;
|
|
|
|
import org.bukkit.plugin.RegisteredServiceProvider;
|
|
|
|
import org.bukkit.plugin.java.JavaPlugin;
|
|
|
|
|
2015-04-26 13:38:29 +02:00
|
|
|
import com.intellectualcrafters.plot.commands.Auto;
|
2015-02-21 06:48:49 +01:00
|
|
|
import com.intellectualcrafters.plot.commands.BukkitCommand;
|
2015-02-21 05:27:01 +01:00
|
|
|
import com.intellectualcrafters.plot.commands.Buy;
|
2015-04-26 13:38:29 +02:00
|
|
|
import com.intellectualcrafters.plot.commands.Claim;
|
|
|
|
import com.intellectualcrafters.plot.commands.Clear;
|
|
|
|
import com.intellectualcrafters.plot.commands.Comment;
|
|
|
|
import com.intellectualcrafters.plot.commands.Condense;
|
|
|
|
import com.intellectualcrafters.plot.commands.Confirm;
|
|
|
|
import com.intellectualcrafters.plot.commands.Copy;
|
|
|
|
import com.intellectualcrafters.plot.commands.CreateRoadSchematic;
|
|
|
|
import com.intellectualcrafters.plot.commands.Database;
|
|
|
|
import com.intellectualcrafters.plot.commands.Debug;
|
|
|
|
import com.intellectualcrafters.plot.commands.DebugClaimTest;
|
|
|
|
import com.intellectualcrafters.plot.commands.DebugClear;
|
|
|
|
import com.intellectualcrafters.plot.commands.DebugExec;
|
2015-04-26 15:38:02 +02:00
|
|
|
import com.intellectualcrafters.plot.commands.DebugFill;
|
2015-04-26 13:38:29 +02:00
|
|
|
import com.intellectualcrafters.plot.commands.DebugFixFlags;
|
|
|
|
import com.intellectualcrafters.plot.commands.DebugLoadTest;
|
|
|
|
import com.intellectualcrafters.plot.commands.DebugRoadRegen;
|
|
|
|
import com.intellectualcrafters.plot.commands.DebugSaveTest;
|
|
|
|
import com.intellectualcrafters.plot.commands.DebugUUID;
|
|
|
|
import com.intellectualcrafters.plot.commands.Delete;
|
|
|
|
import com.intellectualcrafters.plot.commands.Denied;
|
|
|
|
import com.intellectualcrafters.plot.commands.FlagCmd;
|
|
|
|
import com.intellectualcrafters.plot.commands.Help;
|
|
|
|
import com.intellectualcrafters.plot.commands.Helpers;
|
|
|
|
import com.intellectualcrafters.plot.commands.Home;
|
|
|
|
import com.intellectualcrafters.plot.commands.Inbox;
|
|
|
|
import com.intellectualcrafters.plot.commands.Info;
|
|
|
|
import com.intellectualcrafters.plot.commands.Inventory;
|
|
|
|
import com.intellectualcrafters.plot.commands.Kick;
|
2015-02-21 05:27:01 +01:00
|
|
|
import com.intellectualcrafters.plot.commands.MainCommand;
|
2015-04-26 13:38:29 +02:00
|
|
|
import com.intellectualcrafters.plot.commands.Merge;
|
|
|
|
import com.intellectualcrafters.plot.commands.Move;
|
|
|
|
import com.intellectualcrafters.plot.commands.MusicSubcommand;
|
|
|
|
import com.intellectualcrafters.plot.commands.Purge;
|
|
|
|
import com.intellectualcrafters.plot.commands.Rate;
|
|
|
|
import com.intellectualcrafters.plot.commands.RegenAllRoads;
|
|
|
|
import com.intellectualcrafters.plot.commands.Reload;
|
|
|
|
import com.intellectualcrafters.plot.commands.SchematicCmd;
|
|
|
|
import com.intellectualcrafters.plot.commands.Set;
|
|
|
|
import com.intellectualcrafters.plot.commands.SetOwner;
|
|
|
|
import com.intellectualcrafters.plot.commands.Setup;
|
|
|
|
import com.intellectualcrafters.plot.commands.Swap;
|
|
|
|
import com.intellectualcrafters.plot.commands.TP;
|
|
|
|
import com.intellectualcrafters.plot.commands.Target;
|
|
|
|
import com.intellectualcrafters.plot.commands.Template;
|
|
|
|
import com.intellectualcrafters.plot.commands.Trim;
|
|
|
|
import com.intellectualcrafters.plot.commands.Trusted;
|
|
|
|
import com.intellectualcrafters.plot.commands.Unclaim;
|
|
|
|
import com.intellectualcrafters.plot.commands.Unlink;
|
|
|
|
import com.intellectualcrafters.plot.commands.Visit;
|
2015-02-21 05:27:01 +01:00
|
|
|
import com.intellectualcrafters.plot.commands.WE_Anywhere;
|
2015-04-26 13:38:29 +02:00
|
|
|
import com.intellectualcrafters.plot.commands.list;
|
|
|
|
import com.intellectualcrafters.plot.commands.plugin;
|
2015-02-21 05:27:01 +01:00
|
|
|
import com.intellectualcrafters.plot.config.C;
|
|
|
|
import com.intellectualcrafters.plot.config.Settings;
|
2015-05-01 06:13:12 +02:00
|
|
|
import com.intellectualcrafters.plot.database.plotme.ClassicPlotMeConnector;
|
2015-05-01 06:12:31 +02:00
|
|
|
import com.intellectualcrafters.plot.database.plotme.PlotMeConverter;
|
2015-02-23 00:12:33 +01:00
|
|
|
import com.intellectualcrafters.plot.flag.FlagManager;
|
2015-02-22 14:20:41 +01:00
|
|
|
import com.intellectualcrafters.plot.generator.BukkitHybridUtils;
|
2015-02-21 05:27:01 +01:00
|
|
|
import com.intellectualcrafters.plot.generator.HybridGen;
|
2015-02-22 14:20:41 +01:00
|
|
|
import com.intellectualcrafters.plot.generator.HybridUtils;
|
2015-04-26 08:29:58 +02:00
|
|
|
import com.intellectualcrafters.plot.listeners.APlotListener;
|
2015-04-07 14:17:04 +02:00
|
|
|
import com.intellectualcrafters.plot.listeners.ChunkListener;
|
2015-02-21 05:27:01 +01:00
|
|
|
import com.intellectualcrafters.plot.listeners.ForceFieldListener;
|
|
|
|
import com.intellectualcrafters.plot.listeners.InventoryListener;
|
|
|
|
import com.intellectualcrafters.plot.listeners.PlayerEvents;
|
|
|
|
import com.intellectualcrafters.plot.listeners.PlayerEvents_1_8;
|
2015-04-26 08:29:58 +02:00
|
|
|
import com.intellectualcrafters.plot.listeners.PlotListener;
|
2015-02-21 05:27:01 +01:00
|
|
|
import com.intellectualcrafters.plot.listeners.PlotPlusListener;
|
2015-03-27 15:58:08 +01:00
|
|
|
import com.intellectualcrafters.plot.listeners.TNTListener;
|
2015-02-26 10:27:49 +01:00
|
|
|
import com.intellectualcrafters.plot.listeners.WorldEvents;
|
2015-04-12 07:22:03 +02:00
|
|
|
import com.intellectualcrafters.plot.listeners.worldedit.WEListener;
|
2015-04-18 15:47:13 +02:00
|
|
|
import com.intellectualcrafters.plot.listeners.worldedit.WESubscriber;
|
2015-04-09 07:41:14 +02:00
|
|
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
2015-02-23 00:12:33 +01:00
|
|
|
import com.intellectualcrafters.plot.titles.AbstractTitle;
|
|
|
|
import com.intellectualcrafters.plot.titles.DefaultTitle;
|
2015-02-22 14:20:41 +01:00
|
|
|
import com.intellectualcrafters.plot.util.BlockManager;
|
2015-02-25 11:36:19 +01:00
|
|
|
import com.intellectualcrafters.plot.util.BlockUpdateUtil;
|
|
|
|
import com.intellectualcrafters.plot.util.ChunkManager;
|
2015-02-21 05:27:01 +01:00
|
|
|
import com.intellectualcrafters.plot.util.ConsoleColors;
|
2015-02-23 06:29:45 +01:00
|
|
|
import com.intellectualcrafters.plot.util.EventUtil;
|
2015-02-21 05:27:01 +01:00
|
|
|
import com.intellectualcrafters.plot.util.MainUtil;
|
2015-04-27 11:07:42 +02:00
|
|
|
import com.intellectualcrafters.plot.util.PlayerManager;
|
2015-02-22 14:20:41 +01:00
|
|
|
import com.intellectualcrafters.plot.util.SetupUtils;
|
2015-02-21 05:27:01 +01:00
|
|
|
import com.intellectualcrafters.plot.util.TaskManager;
|
2015-02-25 11:36:19 +01:00
|
|
|
import com.intellectualcrafters.plot.util.bukkit.BukkitChunkManager;
|
2015-02-23 06:29:45 +01:00
|
|
|
import com.intellectualcrafters.plot.util.bukkit.BukkitEventUtil;
|
2015-04-27 11:07:42 +02:00
|
|
|
import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerManager;
|
2015-02-25 11:36:19 +01:00
|
|
|
import com.intellectualcrafters.plot.util.bukkit.BukkitSetBlockManager;
|
2015-02-22 14:20:41 +01:00
|
|
|
import com.intellectualcrafters.plot.util.bukkit.BukkitSetupUtils;
|
2015-02-21 05:27:01 +01:00
|
|
|
import com.intellectualcrafters.plot.util.bukkit.BukkitTaskManager;
|
|
|
|
import com.intellectualcrafters.plot.util.bukkit.BukkitUtil;
|
|
|
|
import com.intellectualcrafters.plot.util.bukkit.Metrics;
|
|
|
|
import com.intellectualcrafters.plot.util.bukkit.SendChunk;
|
|
|
|
import com.intellectualcrafters.plot.util.bukkit.SetBlockFast;
|
|
|
|
import com.intellectualcrafters.plot.util.bukkit.SetBlockFast_1_8;
|
|
|
|
import com.intellectualcrafters.plot.util.bukkit.SetBlockSlow;
|
|
|
|
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
2015-02-23 00:12:33 +01:00
|
|
|
import com.intellectualcrafters.plot.uuid.DefaultUUIDWrapper;
|
2015-04-12 07:24:54 +02:00
|
|
|
import com.intellectualcrafters.plot.uuid.LowerOfflineUUIDWrapper;
|
2015-02-23 00:12:33 +01:00
|
|
|
import com.intellectualcrafters.plot.uuid.OfflineUUIDWrapper;
|
|
|
|
import com.intellectualcrafters.plot.uuid.UUIDWrapper;
|
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-02-19 07:08:15 +01:00
|
|
|
public static BukkitMain THIS = null;
|
|
|
|
public static PlotSquared MAIN = null;
|
2015-02-20 11:53:18 +01:00
|
|
|
|
|
|
|
public static boolean checkVersion(final int major, final int minor, final int minor2) {
|
|
|
|
try {
|
|
|
|
final String[] version = Bukkit.getBukkitVersion().split("-")[0].split("\\.");
|
|
|
|
final int a = Integer.parseInt(version[0]);
|
|
|
|
final int b = Integer.parseInt(version[1]);
|
|
|
|
int c = 0;
|
|
|
|
if (version.length == 3) {
|
|
|
|
c = Integer.parseInt(version[2]);
|
|
|
|
}
|
|
|
|
if ((a > major) || ((a == major) && (b > minor)) || ((a == major) && (b == minor) && (c >= minor2))) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
} catch (final Exception e) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2015-02-23 02:32:27 +01:00
|
|
|
|
2015-02-19 07:08:15 +01:00
|
|
|
@Override
|
|
|
|
public void onEnable() {
|
|
|
|
THIS = this;
|
2015-02-23 00:12:33 +01:00
|
|
|
MAIN = new PlotSquared(this);
|
2015-02-19 07:08:15 +01:00
|
|
|
if (Settings.METRICS) {
|
|
|
|
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.");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
log("&dUsing metrics will allow us to improve the plugin, please consider it :)");
|
|
|
|
}
|
2015-03-22 12:43:46 +01:00
|
|
|
List<World> worlds = Bukkit.getWorlds();
|
|
|
|
if (worlds.size() > 0) {
|
|
|
|
UUIDHandler.cacheAll(worlds.get(0).getName());
|
|
|
|
for (World world : worlds) {
|
2015-04-01 15:20:28 +02:00
|
|
|
Bukkit.getServer().unloadWorld(world, false);
|
2015-03-22 12:43:46 +01:00
|
|
|
}
|
|
|
|
}
|
2015-02-19 07:08:15 +01:00
|
|
|
}
|
2015-04-01 10:25:58 +02:00
|
|
|
|
2015-02-23 02:32:27 +01:00
|
|
|
|
2015-02-19 07:08:15 +01:00
|
|
|
@Override
|
|
|
|
public void onDisable() {
|
|
|
|
MAIN.disable();
|
|
|
|
MAIN = null;
|
|
|
|
THIS = null;
|
|
|
|
}
|
2015-02-23 02:32:27 +01: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-02-23 00:12:33 +01:00
|
|
|
message = message.replaceAll("\u00B2", "2");
|
2015-02-20 07:34:19 +01:00
|
|
|
if ((THIS == null) || (Bukkit.getServer().getConsoleSender() == null)) {
|
2015-02-19 09:51:10 +01:00
|
|
|
System.out.println(ChatColor.stripColor(ConsoleColors.fromString(message)));
|
|
|
|
} else {
|
|
|
|
message = ChatColor.translateAlternateColorCodes('&', message);
|
|
|
|
if (!Settings.CONSOLE_COLOR) {
|
|
|
|
message = ChatColor.stripColor(message);
|
|
|
|
}
|
|
|
|
Bukkit.getServer().getConsoleSender().sendMessage(message);
|
|
|
|
}
|
2015-02-19 07:08:15 +01:00
|
|
|
}
|
2015-02-23 02:32:27 +01:00
|
|
|
|
2015-02-19 07:08:15 +01:00
|
|
|
@Override
|
|
|
|
public void disable() {
|
|
|
|
onDisable();
|
|
|
|
}
|
2015-02-23 02:32:27 +01:00
|
|
|
|
2015-02-19 07:08:15 +01:00
|
|
|
@Override
|
|
|
|
public String getVersion() {
|
|
|
|
return this.getDescription().getVersion();
|
|
|
|
}
|
2015-02-23 02:32:27 +01:00
|
|
|
|
2015-02-19 07:08:15 +01:00
|
|
|
@Override
|
|
|
|
public void registerCommands() {
|
2015-02-23 02:32:27 +01:00
|
|
|
new MainCommand();
|
2015-04-26 13:38:29 +02:00
|
|
|
MainCommand.subCommands.add(new Template());
|
|
|
|
MainCommand.subCommands.add(new Setup());
|
|
|
|
MainCommand.subCommands.add(new DebugUUID());
|
2015-04-26 15:38:02 +02:00
|
|
|
MainCommand.subCommands.add(new DebugFill());
|
2015-04-26 13:38:29 +02:00
|
|
|
MainCommand.subCommands.add(new DebugSaveTest());
|
|
|
|
MainCommand.subCommands.add(new DebugLoadTest());
|
|
|
|
MainCommand.subCommands.add(new CreateRoadSchematic());
|
|
|
|
MainCommand.subCommands.add(new RegenAllRoads());
|
|
|
|
MainCommand.subCommands.add(new DebugClear());
|
|
|
|
MainCommand.subCommands.add(new Claim());
|
|
|
|
MainCommand.subCommands.add(new Auto());
|
|
|
|
MainCommand.subCommands.add(new Home());
|
|
|
|
MainCommand.subCommands.add(new Visit());
|
|
|
|
MainCommand.subCommands.add(new TP());
|
|
|
|
MainCommand.subCommands.add(new Set());
|
|
|
|
MainCommand.subCommands.add(new Clear());
|
|
|
|
MainCommand.subCommands.add(new Delete());
|
|
|
|
MainCommand.subCommands.add(new SetOwner());
|
|
|
|
MainCommand.subCommands.add(new Denied());
|
|
|
|
MainCommand.subCommands.add(new Helpers());
|
|
|
|
MainCommand.subCommands.add(new Trusted());
|
|
|
|
MainCommand.subCommands.add(new Info());
|
|
|
|
MainCommand.subCommands.add(new list());
|
|
|
|
MainCommand.subCommands.add(new Help());
|
|
|
|
MainCommand.subCommands.add(new Debug());
|
|
|
|
MainCommand.subCommands.add(new SchematicCmd());
|
|
|
|
MainCommand.subCommands.add(new plugin());
|
|
|
|
MainCommand.subCommands.add(new Inventory());
|
|
|
|
MainCommand.subCommands.add(new Purge());
|
|
|
|
MainCommand.subCommands.add(new Reload());
|
|
|
|
MainCommand.subCommands.add(new Merge());
|
|
|
|
MainCommand.subCommands.add(new Unlink());
|
|
|
|
MainCommand.subCommands.add(new Kick());
|
|
|
|
MainCommand.subCommands.add(new Rate());
|
|
|
|
MainCommand.subCommands.add(new DebugClaimTest());
|
|
|
|
MainCommand.subCommands.add(new Inbox());
|
|
|
|
MainCommand.subCommands.add(new Comment());
|
|
|
|
MainCommand.subCommands.add(new Database());
|
|
|
|
MainCommand.subCommands.add(new Unclaim());
|
|
|
|
MainCommand.subCommands.add(new Swap());
|
|
|
|
MainCommand.subCommands.add(new MusicSubcommand());
|
|
|
|
MainCommand.subCommands.add(new DebugRoadRegen());
|
|
|
|
MainCommand.subCommands.add(new Trim());
|
|
|
|
MainCommand.subCommands.add(new DebugExec());
|
|
|
|
MainCommand.subCommands.add(new FlagCmd());
|
|
|
|
MainCommand.subCommands.add(new Target());
|
|
|
|
MainCommand.subCommands.add(new DebugFixFlags());
|
|
|
|
MainCommand.subCommands.add(new Move());
|
|
|
|
MainCommand.subCommands.add(new Condense());
|
|
|
|
MainCommand.subCommands.add(new Confirm());
|
|
|
|
MainCommand.subCommands.add(new Copy());
|
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-02-23 02:32:27 +01:00
|
|
|
|
2015-02-19 07:08:15 +01:00
|
|
|
@Override
|
|
|
|
public File getDirectory() {
|
|
|
|
return getDataFolder();
|
|
|
|
}
|
2015-02-23 02:32:27 +01:00
|
|
|
|
2015-02-19 07:08:15 +01:00
|
|
|
@Override
|
|
|
|
public TaskManager getTaskManager() {
|
|
|
|
return new BukkitTaskManager();
|
|
|
|
}
|
2015-02-23 02:32:27 +01: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;
|
|
|
|
for (final String w : PlotSquared.getPlotWorlds()) {
|
|
|
|
world = Bukkit.getWorld(w);
|
|
|
|
try {
|
|
|
|
if (world.getLoadedChunks().length < 1) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
for (final Chunk chunk : world.getLoadedChunks()) {
|
|
|
|
final Entity[] entities = chunk.getEntities();
|
|
|
|
Entity entity;
|
|
|
|
for (int i = entities.length - 1; i >= 0; i--) {
|
2015-02-20 12:23:48 +01:00
|
|
|
if (!((entity = entities[i]) instanceof Player) && (MainUtil.getPlot(BukkitUtil.getLocation(entity)) == null)) {
|
2015-02-19 07:08:15 +01:00
|
|
|
entity.remove();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (final Throwable e) {
|
|
|
|
++this.error;
|
|
|
|
} finally {
|
|
|
|
++this.ticked;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, 20);
|
|
|
|
}
|
2015-02-23 02:32:27 +01:00
|
|
|
|
2015-02-19 09:51:10 +01:00
|
|
|
@Override
|
|
|
|
final public ChunkGenerator getDefaultWorldGenerator(final String world, final String id) {
|
|
|
|
if (!PlotSquared.setupPlotWorld(world, id)) {
|
|
|
|
return null;
|
|
|
|
}
|
2015-02-24 12:27:30 +01:00
|
|
|
return new HybridGen();
|
2015-02-19 09:51:10 +01:00
|
|
|
}
|
2015-02-23 02:32:27 +01:00
|
|
|
|
2015-02-19 07:08:15 +01:00
|
|
|
@Override
|
|
|
|
public void registerPlayerEvents() {
|
|
|
|
getServer().getPluginManager().registerEvents(new PlayerEvents(), this);
|
|
|
|
if (checkVersion(1, 8, 0)) {
|
|
|
|
getServer().getPluginManager().registerEvents(new PlayerEvents_1_8(), this);
|
|
|
|
}
|
|
|
|
}
|
2015-02-23 02:32:27 +01:00
|
|
|
|
2015-02-19 07:08:15 +01:00
|
|
|
@Override
|
|
|
|
public void registerInventoryEvents() {
|
|
|
|
getServer().getPluginManager().registerEvents(new InventoryListener(), this);
|
|
|
|
}
|
2015-02-23 02:32:27 +01:00
|
|
|
|
2015-02-19 07:08:15 +01:00
|
|
|
@Override
|
|
|
|
public void registerPlotPlusEvents() {
|
|
|
|
PlotPlusListener.startRunnable(this);
|
|
|
|
getServer().getPluginManager().registerEvents(new PlotPlusListener(), this);
|
|
|
|
}
|
2015-02-23 02:32:27 +01:00
|
|
|
|
2015-02-19 07:08:15 +01:00
|
|
|
@Override
|
|
|
|
public void registerForceFieldEvents() {
|
|
|
|
getServer().getPluginManager().registerEvents(new ForceFieldListener(), this);
|
|
|
|
}
|
2015-02-23 02:32:27 +01:00
|
|
|
|
2015-02-19 07:08:15 +01:00
|
|
|
@Override
|
|
|
|
public void registerWorldEditEvents() {
|
|
|
|
if (getServer().getPluginManager().getPlugin("WorldEdit") != null) {
|
2015-02-19 12:35:45 +01:00
|
|
|
PlotSquared.worldEdit = (WorldEditPlugin) getServer().getPluginManager().getPlugin("WorldEdit");
|
|
|
|
final String version = PlotSquared.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-02-19 07:08:15 +01:00
|
|
|
MainCommand.subCommands.add(new WE_Anywhere());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-02-23 02:32:27 +01:00
|
|
|
|
2015-02-19 07:08:15 +01:00
|
|
|
@Override
|
|
|
|
public Economy getEconomy() {
|
|
|
|
if ((getServer().getPluginManager().getPlugin("Vault") != null) && getServer().getPluginManager().getPlugin("Vault").isEnabled()) {
|
|
|
|
final RegisteredServiceProvider<Economy> economyProvider = getServer().getServicesManager().getRegistration(net.milkbowl.vault.economy.Economy.class);
|
|
|
|
if (economyProvider != null) {
|
|
|
|
MainCommand.subCommands.add(new Buy());
|
|
|
|
return economyProvider.getProvider();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
2015-02-23 02:32:27 +01:00
|
|
|
|
2015-02-19 09:51:10 +01:00
|
|
|
@Override
|
2015-02-22 14:20:41 +01:00
|
|
|
public BlockManager initBlockManager() {
|
2015-02-19 09:51:10 +01:00
|
|
|
if (checkVersion(1, 8, 0)) {
|
|
|
|
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-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-19 09:51:10 +01:00
|
|
|
try {
|
|
|
|
new SendChunk();
|
2015-04-02 02:56:34 +02:00
|
|
|
MainUtil.canSendChunk = true;
|
2015-02-19 09:51:10 +01:00
|
|
|
} catch (final Throwable e) {
|
2015-02-20 12:23:48 +01:00
|
|
|
MainUtil.canSendChunk = false;
|
2015-02-19 09:51:10 +01:00
|
|
|
}
|
2015-02-22 14:20:41 +01:00
|
|
|
return BlockManager.manager = new BukkitUtil();
|
2015-02-19 09:51:10 +01:00
|
|
|
}
|
2015-02-23 02:32:27 +01:00
|
|
|
|
2015-02-19 09:51:10 +01:00
|
|
|
@Override
|
|
|
|
public boolean initPlotMeConverter() {
|
|
|
|
try {
|
2015-05-01 06:13:12 +02:00
|
|
|
new PlotMeConverter().runAsync(new ClassicPlotMeConnector());
|
2015-02-19 09:51:10 +01:00
|
|
|
} catch (final Exception e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
if (Bukkit.getPluginManager().getPlugin("PlotMe") != null) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2015-02-23 02:32:27 +01:00
|
|
|
|
2015-02-19 09:51:10 +01:00
|
|
|
@Override
|
2015-02-26 10:27:49 +01:00
|
|
|
public ChunkGenerator getGenerator(final String world, final String name) {
|
2015-02-20 07:34:19 +01:00
|
|
|
final Plugin gen_plugin = Bukkit.getPluginManager().getPlugin(name);
|
|
|
|
if ((gen_plugin != null) && gen_plugin.isEnabled()) {
|
2015-02-26 10:27:49 +01:00
|
|
|
return gen_plugin.getDefaultWorldGenerator(world, "");
|
2015-02-19 09:51:10 +01:00
|
|
|
} else {
|
2015-02-26 10:27:49 +01:00
|
|
|
return new HybridGen();
|
2015-02-19 09:51:10 +01:00
|
|
|
}
|
|
|
|
}
|
2015-02-23 02:32:27 +01: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
|
|
|
|
public UUIDWrapper initUUIDHandler() {
|
2015-02-23 02:32:27 +01:00
|
|
|
final boolean checkVersion = checkVersion(1, 7, 6);
|
2015-02-23 00:12:33 +01:00
|
|
|
if (!checkVersion) {
|
2015-02-23 02:32:27 +01:00
|
|
|
log(C.PREFIX.s() + " &c[WARN] Titles are disabled - please update your version of Bukkit to support this feature.");
|
2015-02-23 00:12:33 +01:00
|
|
|
Settings.TITLES = false;
|
|
|
|
FlagManager.removeFlag(FlagManager.getFlag("titles"));
|
2015-02-23 02:32:27 +01:00
|
|
|
} else {
|
2015-02-23 00:12:33 +01:00
|
|
|
AbstractTitle.TITLE_CLASS = new DefaultTitle();
|
|
|
|
}
|
2015-03-13 04:15:00 +01:00
|
|
|
if (Settings.OFFLINE_MODE) {
|
2015-04-12 07:24:54 +02:00
|
|
|
if (Settings.UUID_LOWERCASE) {
|
|
|
|
UUIDHandler.uuidWrapper = new LowerOfflineUUIDWrapper();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
UUIDHandler.uuidWrapper = new OfflineUUIDWrapper();
|
|
|
|
}
|
2015-02-23 00:12:33 +01:00
|
|
|
Settings.OFFLINE_MODE = true;
|
2015-02-23 02:32:27 +01:00
|
|
|
} else if (checkVersion) {
|
2015-02-23 00:12:33 +01:00
|
|
|
UUIDHandler.uuidWrapper = new DefaultUUIDWrapper();
|
|
|
|
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) {
|
|
|
|
UUIDHandler.uuidWrapper = new LowerOfflineUUIDWrapper();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
UUIDHandler.uuidWrapper = new OfflineUUIDWrapper();
|
|
|
|
}
|
2015-02-23 00:12:33 +01:00
|
|
|
Settings.OFFLINE_MODE = true;
|
|
|
|
}
|
|
|
|
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
|
|
|
}
|
|
|
|
return UUIDHandler.uuidWrapper;
|
|
|
|
}
|
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();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public EventUtil initEventUtil() {
|
|
|
|
return new BukkitEventUtil();
|
2015-02-23 01:05:25 +01:00
|
|
|
}
|
2015-04-01 10:25:58 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void registerTNTListener() {
|
|
|
|
getServer().getPluginManager().registerEvents(new TNTListener(), this);
|
|
|
|
}
|
2015-04-09 07:41:14 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void unregister(PlotPlayer player) {
|
|
|
|
BukkitUtil.removePlayer(player.getName());
|
|
|
|
}
|
2015-04-26 08:29:58 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public APlotListener initPlotListener() {
|
|
|
|
return new PlotListener();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void registerChunkProcessor() {
|
|
|
|
getServer().getPluginManager().registerEvents(new ChunkListener(), this);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void registerWorldEvents() {
|
|
|
|
getServer().getPluginManager().registerEvents(new WorldEvents(), this);
|
|
|
|
}
|
2015-04-27 11:07:42 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public PlayerManager initPlayerManager() {
|
|
|
|
return new BukkitPlayerManager();
|
|
|
|
}
|
2015-02-19 04:24:05 +01:00
|
|
|
}
|