2015-07-26 16:51:12 +02:00
|
|
|
package com.plotsquared.bukkit;
|
2015-07-05 17:44:10 +02:00
|
|
|
|
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-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;
|
2016-02-10 19:59:51 +01:00
|
|
|
import com.intellectualcrafters.plot.generator.GeneratorWrapper;
|
|
|
|
import com.intellectualcrafters.plot.generator.HybridGen;
|
2015-07-27 19:50:04 +02:00
|
|
|
import com.intellectualcrafters.plot.generator.HybridUtils;
|
2016-02-10 19:59:51 +01:00
|
|
|
import com.intellectualcrafters.plot.generator.IndependentPlotGenerator;
|
2018-01-27 06:26:09 +01:00
|
|
|
import com.intellectualcrafters.plot.object.*;
|
2016-06-27 16:10:55 +02:00
|
|
|
import com.intellectualcrafters.plot.object.chat.PlainChatManager;
|
2017-04-03 23:59:36 +02:00
|
|
|
import com.intellectualcrafters.plot.object.worlds.PlotAreaManager;
|
|
|
|
import com.intellectualcrafters.plot.object.worlds.SinglePlotArea;
|
|
|
|
import com.intellectualcrafters.plot.object.worlds.SinglePlotAreaManager;
|
2017-03-23 01:10:29 +01:00
|
|
|
import com.intellectualcrafters.plot.object.worlds.SingleWorldGenerator;
|
2018-01-27 06:26:09 +01:00
|
|
|
import com.intellectualcrafters.plot.util.*;
|
2016-06-13 06:47:50 +02:00
|
|
|
import com.intellectualcrafters.plot.util.block.QueueProvider;
|
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-08-25 01:01:45 +02:00
|
|
|
import com.plotsquared.bukkit.generator.BukkitPlotGenerator;
|
2018-01-27 06:26:09 +01:00
|
|
|
import com.plotsquared.bukkit.listeners.*;
|
2016-11-30 06:28:50 +01:00
|
|
|
import com.plotsquared.bukkit.titles.DefaultTitle_111;
|
2018-01-27 06:26:09 +01:00
|
|
|
import com.plotsquared.bukkit.util.*;
|
|
|
|
import com.plotsquared.bukkit.util.block.*;
|
|
|
|
import com.plotsquared.bukkit.uuid.*;
|
2016-06-01 22:50:35 +02:00
|
|
|
import com.sk89q.worldedit.WorldEdit;
|
2016-11-30 06:28:50 +01:00
|
|
|
import java.io.File;
|
|
|
|
import java.lang.reflect.Field;
|
2018-01-27 06:26:09 +01:00
|
|
|
import java.lang.reflect.Method;
|
|
|
|
import java.util.*;
|
2016-11-30 06:28:50 +01:00
|
|
|
import java.util.concurrent.ConcurrentHashMap;
|
2018-01-27 06:26:09 +01:00
|
|
|
import org.bukkit.*;
|
2016-02-26 07:29:31 +01:00
|
|
|
import org.bukkit.Location;
|
|
|
|
import org.bukkit.command.PluginCommand;
|
|
|
|
import org.bukkit.entity.Entity;
|
2016-06-03 16:57:25 +02:00
|
|
|
import org.bukkit.entity.LivingEntity;
|
2016-02-26 07:29:31 +01:00
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
import org.bukkit.event.Listener;
|
|
|
|
import org.bukkit.generator.ChunkGenerator;
|
2017-12-03 17:21:15 +01:00
|
|
|
import org.bukkit.metadata.FixedMetadataValue;
|
2016-02-26 07:29:31 +01:00
|
|
|
import org.bukkit.metadata.MetadataValue;
|
|
|
|
import org.bukkit.plugin.Plugin;
|
2016-09-30 08:14:35 +02:00
|
|
|
import org.bukkit.plugin.PluginManager;
|
2016-02-26 07:29:31 +01:00
|
|
|
import org.bukkit.plugin.java.JavaPlugin;
|
2016-03-23 02:41:37 +01:00
|
|
|
|
2018-01-27 06:26:09 +01:00
|
|
|
|
|
|
|
import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass;
|
|
|
|
|
2016-04-19 22:59:10 +02:00
|
|
|
public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
2016-03-20 23:19:37 +01:00
|
|
|
|
2016-09-30 08:14:35 +02:00
|
|
|
private static ConcurrentHashMap<String, Plugin> pluginMap;
|
|
|
|
|
|
|
|
static {
|
2016-11-21 04:24:27 +01:00
|
|
|
// Disable AWE as otherwise both fail to load
|
|
|
|
PluginManager manager = Bukkit.getPluginManager();
|
|
|
|
try {
|
|
|
|
Settings.load(new File("plugins/PlotSquared/config/settings.yml"));
|
|
|
|
if (Settings.Enabled_Components.PLOTME_CONVERTER) { // Only disable PlotMe if conversion is enabled
|
|
|
|
Field pluginsField = manager.getClass().getDeclaredField("plugins");
|
|
|
|
Field lookupNamesField = manager.getClass().getDeclaredField("lookupNames");
|
|
|
|
pluginsField.setAccessible(true);
|
|
|
|
lookupNamesField.setAccessible(true);
|
|
|
|
List<Plugin> plugins = (List<Plugin>) pluginsField.get(manager);
|
|
|
|
Iterator<Plugin> iter = plugins.iterator();
|
|
|
|
while (iter.hasNext()) {
|
|
|
|
if (iter.next().getName().startsWith("PlotMe")) {
|
|
|
|
iter.remove();
|
2016-09-30 08:14:35 +02:00
|
|
|
}
|
2016-11-21 04:24:27 +01:00
|
|
|
}
|
|
|
|
Map<String, Plugin> lookupNames = (Map<String, Plugin>) lookupNamesField.get(manager);
|
|
|
|
lookupNames.remove("PlotMe");
|
|
|
|
lookupNames.remove("PlotMe-DefaultGenerator");
|
|
|
|
pluginsField.set(manager, new ArrayList<Plugin>(plugins) {
|
|
|
|
@Override
|
|
|
|
public boolean add(Plugin plugin) {
|
|
|
|
if (plugin.getName().startsWith("PlotMe")) {
|
|
|
|
System.out.print("Disabling `" + plugin.getName() + "` for PlotMe conversion (configure in PlotSquared settings.yml)");
|
|
|
|
} else {
|
|
|
|
return super.add(plugin);
|
2016-09-30 08:14:35 +02:00
|
|
|
}
|
2016-11-21 04:24:27 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
pluginMap = new ConcurrentHashMap<String, Plugin>(lookupNames) {
|
|
|
|
@Override
|
|
|
|
public Plugin put(String key, Plugin plugin) {
|
|
|
|
if (!plugin.getName().startsWith("PlotMe")) {
|
|
|
|
return super.put(key, plugin);
|
2016-09-30 08:14:35 +02:00
|
|
|
}
|
2016-11-21 04:24:27 +01:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
lookupNamesField.set(manager, pluginMap);
|
|
|
|
}
|
|
|
|
} catch (Throwable ignore) {}
|
2016-09-30 08:14:35 +02:00
|
|
|
}
|
|
|
|
|
2016-06-01 22:50:35 +02:00
|
|
|
public static WorldEdit worldEdit;
|
2016-03-20 23:19:37 +01:00
|
|
|
|
2015-09-11 12:09:22 +02:00
|
|
|
private int[] version;
|
2016-09-26 10:31:08 +02:00
|
|
|
private String name;
|
2017-09-25 08:57:42 +02:00
|
|
|
private SingleWorldListener singleWorldListener;
|
2016-03-20 23:19:37 +01:00
|
|
|
|
2015-06-24 05:31:13 +02:00
|
|
|
@Override
|
2015-09-13 06:04:31 +02:00
|
|
|
public int[] getServerVersion() {
|
2016-03-23 02:41:37 +01:00
|
|
|
if (this.version == null) {
|
2015-09-13 06:04:31 +02:00
|
|
|
try {
|
2016-03-23 02:41:37 +01:00
|
|
|
this.version = new int[3];
|
|
|
|
String[] split = Bukkit.getBukkitVersion().split("-")[0].split("\\.");
|
|
|
|
this.version[0] = Integer.parseInt(split[0]);
|
|
|
|
this.version[1] = Integer.parseInt(split[1]);
|
2015-09-13 06:04:31 +02:00
|
|
|
if (split.length == 3) {
|
2016-03-23 02:41:37 +01:00
|
|
|
this.version[2] = Integer.parseInt(split[2]);
|
2015-06-24 05:31:13 +02:00
|
|
|
}
|
2016-04-26 16:14:22 +02:00
|
|
|
} catch (NumberFormatException 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("\\.")));
|
2016-06-24 02:12:17 +02:00
|
|
|
return new int[]{1, 10, 0};
|
2015-02-20 11:53:18 +01:00
|
|
|
}
|
|
|
|
}
|
2016-03-23 02:41:37 +01:00
|
|
|
return this.version;
|
2015-02-20 11:53:18 +01:00
|
|
|
}
|
2016-03-20 23:19:37 +01:00
|
|
|
|
2015-02-19 07:08:15 +01:00
|
|
|
@Override
|
2015-09-13 06:04:31 +02:00
|
|
|
public void onEnable() {
|
2016-09-30 08:14:35 +02:00
|
|
|
if (pluginMap != null) {
|
|
|
|
pluginMap.put("PlotMe-DefaultGenerator", this);
|
|
|
|
}
|
2016-09-26 10:31:08 +02:00
|
|
|
this.name = getDescription().getName();
|
2016-07-17 04:51:49 +02:00
|
|
|
getServer().getName();
|
2015-11-15 03:30:52 +01:00
|
|
|
new PS(this, "Bukkit");
|
2016-07-17 04:51:49 +02:00
|
|
|
if (Settings.Enabled_Components.METRICS) {
|
|
|
|
new Metrics(this).start();
|
|
|
|
PS.log(C.PREFIX + "&6Metrics enabled.");
|
|
|
|
} else {
|
2016-09-26 10:31:08 +02:00
|
|
|
PS.log(C.CONSOLE_PLEASE_ENABLE_METRICS.f(getPluginName()));
|
2016-07-17 04:51:49 +02:00
|
|
|
}
|
2017-04-03 23:59:36 +02:00
|
|
|
if (Settings.Enabled_Components.WORLDS) {
|
|
|
|
TaskManager.IMP.taskRepeat(new Runnable() {
|
|
|
|
@Override
|
|
|
|
public void run() {
|
|
|
|
unload();
|
|
|
|
}
|
2017-09-25 08:57:42 +02:00
|
|
|
}, 20);
|
|
|
|
try {
|
|
|
|
singleWorldListener = new SingleWorldListener(this);
|
|
|
|
} catch (Exception e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
2017-04-03 23:59:36 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-09-25 08:57:42 +02:00
|
|
|
public SingleWorldListener getSingleWorldListener() {
|
|
|
|
return singleWorldListener;
|
|
|
|
}
|
|
|
|
|
2018-01-27 06:26:09 +01:00
|
|
|
private Method methodUnloadChunk0;
|
|
|
|
private boolean methodUnloadSetup = false;
|
|
|
|
|
2017-04-03 23:59:36 +02:00
|
|
|
public void unload() {
|
2018-01-27 06:26:09 +01:00
|
|
|
if (!methodUnloadSetup) {
|
|
|
|
methodUnloadSetup = true;
|
|
|
|
try {
|
|
|
|
ReflectionUtils.RefClass classCraftWorld = getRefClass("{cb}.CraftWorld");
|
|
|
|
methodUnloadChunk0 = classCraftWorld.getRealClass().getDeclaredMethod("unloadChunk0", int.class, int.class, boolean.class);
|
|
|
|
methodUnloadChunk0.setAccessible(true);
|
|
|
|
} catch (Throwable ignore) {
|
|
|
|
ignore.printStackTrace();
|
|
|
|
}
|
|
|
|
}
|
2017-04-03 23:59:36 +02:00
|
|
|
PlotAreaManager manager = PS.get().getPlotAreaManager();
|
|
|
|
if (manager instanceof SinglePlotAreaManager) {
|
|
|
|
long start = System.currentTimeMillis();
|
|
|
|
SinglePlotArea area = ((SinglePlotAreaManager) manager).getArea();
|
2018-01-27 06:26:09 +01:00
|
|
|
outer:
|
2017-04-03 23:59:36 +02:00
|
|
|
for (World world : Bukkit.getWorlds()) {
|
|
|
|
String name = world.getName();
|
2017-09-23 16:13:05 +02:00
|
|
|
char char0 = name.charAt(0);
|
|
|
|
if (!Character.isDigit(char0) && char0 != '-') continue;
|
2018-01-27 06:26:09 +01:00
|
|
|
if (!world.getPlayers().isEmpty()) {
|
|
|
|
continue;
|
|
|
|
}
|
2017-09-23 16:13:05 +02:00
|
|
|
|
2017-04-03 23:59:36 +02:00
|
|
|
PlotId id = PlotId.fromString(name);
|
|
|
|
if (id != null) {
|
|
|
|
Plot plot = area.getOwnedPlot(id);
|
|
|
|
if (plot != null) {
|
2017-09-23 16:13:05 +02:00
|
|
|
if (PlotPlayer.wrap(plot.owner) == null) {
|
|
|
|
if (world.getKeepSpawnInMemory()) {
|
|
|
|
world.setKeepSpawnInMemory(false);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
Chunk[] chunks = world.getLoadedChunks();
|
|
|
|
if (chunks.length == 0) {
|
|
|
|
if (!Bukkit.unloadWorld(world, true)) {
|
|
|
|
PS.debug("Failed to unload " + world.getName());
|
2017-04-03 23:59:36 +02:00
|
|
|
}
|
2017-09-23 16:13:05 +02:00
|
|
|
return;
|
2018-01-27 06:26:09 +01:00
|
|
|
} else {
|
|
|
|
int index = 0;
|
|
|
|
do {
|
|
|
|
Chunk chunkI = chunks[index++];
|
|
|
|
boolean result;
|
|
|
|
if (methodUnloadChunk0 != null) {
|
|
|
|
try {
|
|
|
|
result = (boolean) methodUnloadChunk0.invoke(world, chunkI.getX(), chunkI.getZ(), true);
|
|
|
|
} catch (Throwable e) {
|
|
|
|
methodUnloadChunk0 = null;
|
|
|
|
e.printStackTrace();
|
|
|
|
continue outer;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
result = world.unloadChunk(chunkI.getX(), chunkI.getZ(), true, false);
|
|
|
|
}
|
|
|
|
if (!result) {
|
|
|
|
continue outer;
|
|
|
|
}
|
|
|
|
} while (index < chunks.length && System.currentTimeMillis() - start < 5);
|
|
|
|
return;
|
2017-04-03 23:59:36 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-02-19 07:08:15 +01:00
|
|
|
}
|
2016-03-20 23:19:37 +01:00
|
|
|
|
2015-02-19 07:08:15 +01:00
|
|
|
@Override
|
2015-09-13 06:04:31 +02:00
|
|
|
public void onDisable() {
|
2015-07-03 14:15:20 +02:00
|
|
|
PS.get().disable();
|
2015-08-11 12:45:13 +02:00
|
|
|
Bukkit.getScheduler().cancelTasks(this);
|
2015-02-19 07:08:15 +01:00
|
|
|
}
|
2016-03-20 23:19:37 +01:00
|
|
|
|
2015-02-19 07:08:15 +01:00
|
|
|
@Override
|
2015-09-13 06:04:31 +02:00
|
|
|
public void log(String message) {
|
2016-04-05 18:37:11 +02:00
|
|
|
try {
|
|
|
|
message = C.color(message);
|
2016-06-10 19:00:34 +02:00
|
|
|
if (!Settings.Chat.CONSOLE_COLOR) {
|
2016-04-05 18:37:11 +02:00
|
|
|
message = ChatColor.stripColor(message);
|
2016-03-23 02:41:37 +01:00
|
|
|
}
|
2016-04-05 18:37:11 +02:00
|
|
|
this.getServer().getConsoleSender().sendMessage(message);
|
2016-05-21 17:16:21 +02:00
|
|
|
} catch (Throwable ignored) {
|
|
|
|
System.out.println(ConsoleColors.fromString(message));
|
|
|
|
}
|
2015-02-19 07:08:15 +01:00
|
|
|
}
|
2016-03-20 23:19:37 +01:00
|
|
|
|
2015-02-19 07:08:15 +01:00
|
|
|
@Override
|
2015-09-13 06:04:31 +02:00
|
|
|
public void disable() {
|
2016-04-05 18:37:11 +02:00
|
|
|
onDisable();
|
2015-02-19 07:08:15 +01:00
|
|
|
}
|
2016-03-20 23:19:37 +01:00
|
|
|
|
2015-02-19 07:08:15 +01:00
|
|
|
@Override
|
2016-03-17 17:05:36 +01:00
|
|
|
public int[] getPluginVersion() {
|
2016-04-05 18:37:11 +02:00
|
|
|
String ver = getDescription().getVersion();
|
2016-05-19 21:10:46 +02:00
|
|
|
if (ver.contains("-")) {
|
|
|
|
ver = ver.split("-")[0];
|
2016-03-29 05:23:56 +02:00
|
|
|
}
|
2016-04-05 18:37:11 +02:00
|
|
|
String[] split = ver.split("\\.");
|
2016-03-23 02:41:37 +01:00
|
|
|
return new int[]{Integer.parseInt(split[0]), Integer.parseInt(split[1]), Integer.parseInt(split[2])};
|
2015-02-19 07:08:15 +01:00
|
|
|
}
|
2016-03-20 23:19:37 +01:00
|
|
|
|
2016-06-24 02:12:17 +02:00
|
|
|
@Override public String getPluginVersionString() {
|
|
|
|
return getDescription().getVersion();
|
|
|
|
}
|
|
|
|
|
2016-09-26 10:31:08 +02:00
|
|
|
@Override
|
|
|
|
public String getPluginName() {
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
|
2015-02-19 07:08:15 +01:00
|
|
|
@Override
|
2015-09-13 06:04:31 +02:00
|
|
|
public void registerCommands() {
|
2016-03-29 21:47:59 +02:00
|
|
|
BukkitCommand bukkitCommand = new BukkitCommand();
|
2016-03-23 02:41:37 +01:00
|
|
|
PluginCommand plotCommand = getCommand("plots");
|
2016-03-29 21:47:59 +02:00
|
|
|
plotCommand.setExecutor(bukkitCommand);
|
2015-02-19 07:08:15 +01:00
|
|
|
plotCommand.setAliases(Arrays.asList("p", "ps", "plotme", "plot"));
|
2016-03-29 21:47:59 +02:00
|
|
|
plotCommand.setTabCompleter(bukkitCommand);
|
2015-02-19 07:08:15 +01:00
|
|
|
}
|
2016-03-20 23:19:37 +01:00
|
|
|
|
2015-02-19 07:08:15 +01:00
|
|
|
@Override
|
2015-09-13 06:04:31 +02:00
|
|
|
public File getDirectory() {
|
2015-02-19 07:08:15 +01:00
|
|
|
return getDataFolder();
|
|
|
|
}
|
2016-03-20 23:19:37 +01:00
|
|
|
|
2015-09-10 07:34:41 +02:00
|
|
|
@Override
|
|
|
|
public File getWorldContainer() {
|
|
|
|
return Bukkit.getWorldContainer();
|
|
|
|
}
|
2016-03-20 23:19:37 +01:00
|
|
|
|
2015-02-19 07:08:15 +01:00
|
|
|
@Override
|
2015-09-13 06:04:31 +02:00
|
|
|
public TaskManager getTaskManager() {
|
2016-04-05 18:37:11 +02:00
|
|
|
return new BukkitTaskManager(this);
|
2015-02-19 07:08:15 +01:00
|
|
|
}
|
2016-03-20 23:19:37 +01:00
|
|
|
|
2015-02-19 07:08:15 +01:00
|
|
|
@Override
|
2015-09-13 06:04:31 +02:00
|
|
|
public void runEntityTask() {
|
2016-05-21 16:45:48 +02:00
|
|
|
PS.log(C.PREFIX + "KillAllEntities started.");
|
2015-09-13 06:04:31 +02:00
|
|
|
TaskManager.runTaskRepeat(new Runnable() {
|
2015-02-19 07:08:15 +01:00
|
|
|
@Override
|
2015-09-13 06:04:31 +02:00
|
|
|
public void run() {
|
2016-02-10 19:59:51 +01:00
|
|
|
PS.get().foreachPlotArea(new RunnableVal<PlotArea>() {
|
|
|
|
@Override
|
2016-04-19 22:59:10 +02:00
|
|
|
public void run(PlotArea plotArea) {
|
|
|
|
World world = Bukkit.getWorld(plotArea.worldname);
|
2016-02-10 19:59:51 +01:00
|
|
|
try {
|
|
|
|
if (world == null) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
List<Entity> entities = world.getEntities();
|
2016-03-23 02:41:37 +01:00
|
|
|
Iterator<Entity> iterator = entities.iterator();
|
|
|
|
while (iterator.hasNext()) {
|
|
|
|
Entity entity = iterator.next();
|
2016-02-10 19:59:51 +01:00
|
|
|
switch (entity.getType()) {
|
|
|
|
case EGG:
|
|
|
|
case COMPLEX_PART:
|
|
|
|
case FISHING_HOOK:
|
|
|
|
case ENDER_SIGNAL:
|
2016-04-19 22:59:10 +02:00
|
|
|
case LINGERING_POTION:
|
2016-03-23 02:41:37 +01:00
|
|
|
case AREA_EFFECT_CLOUD:
|
2016-02-10 19:59:51 +01:00
|
|
|
case EXPERIENCE_ORB:
|
|
|
|
case LEASH_HITCH:
|
|
|
|
case FIREWORK:
|
|
|
|
case WEATHER:
|
|
|
|
case LIGHTNING:
|
|
|
|
case WITHER_SKULL:
|
|
|
|
case UNKNOWN:
|
2016-03-29 23:00:07 +02:00
|
|
|
case PLAYER:
|
2016-03-29 21:47:59 +02:00
|
|
|
// non moving / unmovable
|
2015-08-04 14:21:12 +02:00
|
|
|
continue;
|
2016-02-10 19:59:51 +01:00
|
|
|
case THROWN_EXP_BOTTLE:
|
|
|
|
case SPLASH_POTION:
|
|
|
|
case SNOWBALL:
|
2016-03-23 02:41:37 +01:00
|
|
|
case SHULKER_BULLET:
|
|
|
|
case SPECTRAL_ARROW:
|
|
|
|
case TIPPED_ARROW:
|
2016-02-10 19:59:51 +01:00
|
|
|
case ENDER_PEARL:
|
2016-03-29 23:00:07 +02:00
|
|
|
case ARROW:
|
2016-11-21 04:24:27 +01:00
|
|
|
case LLAMA_SPIT:
|
2016-02-10 19:59:51 +01:00
|
|
|
// managed elsewhere | projectile
|
|
|
|
continue;
|
2016-02-15 06:25:37 +01:00
|
|
|
case ITEM_FRAME:
|
2016-03-29 23:00:07 +02:00
|
|
|
case PAINTING:
|
2016-06-13 07:32:13 +02:00
|
|
|
// Not vehicles
|
|
|
|
continue;
|
2016-06-13 07:35:33 +02:00
|
|
|
case ARMOR_STAND:
|
2016-07-01 23:13:49 +02:00
|
|
|
// Temporarily classify as vehicle
|
2016-02-10 19:59:51 +01:00
|
|
|
case MINECART:
|
|
|
|
case MINECART_CHEST:
|
|
|
|
case MINECART_COMMAND:
|
|
|
|
case MINECART_FURNACE:
|
|
|
|
case MINECART_HOPPER:
|
|
|
|
case MINECART_MOB_SPAWNER:
|
2016-07-01 23:13:49 +02:00
|
|
|
case ENDER_CRYSTAL:
|
2016-02-10 19:59:51 +01:00
|
|
|
case MINECART_TNT:
|
2016-11-21 04:24:27 +01:00
|
|
|
case BOAT:
|
2016-07-01 23:13:49 +02:00
|
|
|
if (Settings.Enabled_Components.KILL_ROAD_VEHICLES) {
|
|
|
|
com.intellectualcrafters.plot.object.Location location = BukkitUtil.getLocation(entity.getLocation());
|
|
|
|
Plot plot = location.getPlot();
|
|
|
|
if (plot == null) {
|
|
|
|
if (location.isPlotArea()) {
|
|
|
|
iterator.remove();
|
|
|
|
entity.remove();
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
List<MetadataValue> meta = entity.getMetadata("plot");
|
|
|
|
if (meta.isEmpty()) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
Plot origin = (Plot) meta.get(0).value();
|
|
|
|
if (!plot.equals(origin.getBasePlot(false))) {
|
2016-03-23 02:41:37 +01:00
|
|
|
iterator.remove();
|
2016-02-10 19:59:51 +01:00
|
|
|
entity.remove();
|
|
|
|
}
|
|
|
|
continue;
|
2016-07-01 23:13:49 +02:00
|
|
|
} else {
|
2016-02-10 19:59:51 +01:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
case SMALL_FIREBALL:
|
|
|
|
case FIREBALL:
|
2016-03-23 02:41:37 +01:00
|
|
|
case DRAGON_FIREBALL:
|
2016-03-29 23:00:07 +02:00
|
|
|
case DROPPED_ITEM:
|
2016-02-10 19:59:51 +01:00
|
|
|
// dropped item
|
2015-11-15 03:30:52 +01:00
|
|
|
continue;
|
2016-02-10 19:59:51 +01:00
|
|
|
case PRIMED_TNT:
|
2016-03-29 23:00:07 +02:00
|
|
|
case FALLING_BLOCK:
|
2016-02-10 19:59:51 +01:00
|
|
|
// managed elsewhere
|
2015-08-04 14:21:12 +02:00
|
|
|
continue;
|
2016-11-21 04:24:27 +01:00
|
|
|
case LLAMA:
|
|
|
|
case DONKEY:
|
|
|
|
case MULE:
|
|
|
|
case ZOMBIE_HORSE:
|
|
|
|
case SKELETON_HORSE:
|
|
|
|
case HUSK:
|
|
|
|
case ELDER_GUARDIAN:
|
|
|
|
case WITHER_SKELETON:
|
|
|
|
case STRAY:
|
|
|
|
case ZOMBIE_VILLAGER:
|
|
|
|
case EVOKER:
|
|
|
|
case EVOKER_FANGS:
|
|
|
|
case VEX:
|
|
|
|
case VINDICATOR:
|
2016-06-24 02:12:17 +02:00
|
|
|
case POLAR_BEAR:
|
2016-02-10 19:59:51 +01:00
|
|
|
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:
|
2018-01-10 07:06:35 +01:00
|
|
|
default: {
|
2016-07-01 23:13:49 +02:00
|
|
|
if (Settings.Enabled_Components.KILL_ROAD_MOBS) {
|
|
|
|
Location location = entity.getLocation();
|
|
|
|
if (BukkitUtil.getLocation(location).isPlotRoad()) {
|
|
|
|
if (entity instanceof LivingEntity) {
|
|
|
|
LivingEntity livingEntity = (LivingEntity) entity;
|
|
|
|
if (!livingEntity.isLeashed() || !entity.hasMetadata("keep")) {
|
|
|
|
Entity passenger = entity.getPassenger();
|
|
|
|
if (!(passenger instanceof Player) && entity.getMetadata("keep").isEmpty()) {
|
|
|
|
iterator.remove();
|
|
|
|
entity.remove();
|
2018-03-12 07:26:40 +01:00
|
|
|
continue;
|
2016-07-01 23:13:49 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
2016-06-03 16:57:25 +02:00
|
|
|
Entity passenger = entity.getPassenger();
|
|
|
|
if (!(passenger instanceof Player) && entity.getMetadata("keep").isEmpty()) {
|
|
|
|
iterator.remove();
|
|
|
|
entity.remove();
|
2018-03-12 07:26:40 +01:00
|
|
|
continue;
|
2016-06-03 16:57:25 +02:00
|
|
|
}
|
|
|
|
}
|
2015-10-07 08:33:33 +02:00
|
|
|
}
|
2015-08-08 19:27:18 +02:00
|
|
|
}
|
2018-01-10 07:06:35 +01:00
|
|
|
}
|
|
|
|
case SHULKER: {
|
|
|
|
if (Settings.Enabled_Components.KILL_ROAD_MOBS) {
|
|
|
|
LivingEntity livingEntity = (LivingEntity) entity;
|
|
|
|
if (entity.hasMetadata("plot")) {
|
|
|
|
if (!livingEntity.isLeashed() || !entity.hasMetadata("keep")) {
|
|
|
|
PlotId originalPlotId = (PlotId) (!entity.getMetadata("plot").isEmpty() ? entity.getMetadata("plot").get(0).value() : null);
|
|
|
|
PlotId currentPlotId = BukkitUtil.getLocation(entity.getLocation()).getPlot().getId();
|
|
|
|
if (!currentPlotId.equals(originalPlotId)) {
|
|
|
|
iterator.remove();
|
|
|
|
entity.remove();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (!entity.hasMetadata("plot")) {
|
|
|
|
//This is to apply the metadata to already spawned shulkers (see EntitySpawnListener.java)
|
|
|
|
entity.setMetadata("plot", new FixedMetadataValue((Plugin) PS.get().IMP, BukkitUtil.getLocation(entity.getLocation()).getPlot().getId()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-02-19 07:08:15 +01:00
|
|
|
}
|
|
|
|
}
|
2016-03-23 02:41:37 +01:00
|
|
|
} catch (Throwable e) {
|
2016-02-10 19:59:51 +01:00
|
|
|
e.printStackTrace();
|
2015-02-19 07:08:15 +01:00
|
|
|
}
|
|
|
|
}
|
2016-02-10 19:59:51 +01:00
|
|
|
});
|
2015-02-19 07:08:15 +01:00
|
|
|
}
|
|
|
|
}, 20);
|
|
|
|
}
|
2016-03-20 23:19:37 +01:00
|
|
|
|
2015-02-19 09:51:10 +01:00
|
|
|
@Override
|
2016-03-23 18:09:13 +01:00
|
|
|
public final ChunkGenerator getDefaultWorldGenerator(String world, String id) {
|
2016-09-30 08:14:35 +02:00
|
|
|
if (Settings.Enabled_Components.PLOTME_CONVERTER) {
|
|
|
|
initPlotMeConverter();
|
|
|
|
Settings.Enabled_Components.PLOTME_CONVERTER = false;
|
|
|
|
}
|
2017-03-23 01:10:29 +01:00
|
|
|
IndependentPlotGenerator result;
|
|
|
|
if (id != null && id.equalsIgnoreCase("single")) {
|
|
|
|
result = new SingleWorldGenerator();
|
|
|
|
} else {
|
|
|
|
result = PS.get().IMP.getDefaultGenerator();
|
|
|
|
if (!PS.get().setupPlotWorld(world, id, result)) {
|
|
|
|
return null;
|
|
|
|
}
|
2015-09-13 06:04:31 +02:00
|
|
|
}
|
2016-09-06 16:28:01 +02:00
|
|
|
return (ChunkGenerator) result.specify(world);
|
2015-02-19 09:51:10 +01:00
|
|
|
}
|
2016-03-20 23:19:37 +01:00
|
|
|
|
2015-02-19 07:08:15 +01:00
|
|
|
@Override
|
2015-09-13 06:04:31 +02:00
|
|
|
public void registerPlayerEvents() {
|
2016-03-30 04:23:31 +02:00
|
|
|
PlayerEvents main = new PlayerEvents();
|
|
|
|
getServer().getPluginManager().registerEvents(main, this);
|
2016-06-27 18:03:16 +02:00
|
|
|
try {
|
2016-07-30 03:40:02 +02:00
|
|
|
getServer().getClass().getMethod("spigot");
|
2016-11-27 07:26:06 +01:00
|
|
|
Class.forName("org.bukkit.event.entity.EntitySpawnEvent");
|
2016-06-27 18:03:16 +02:00
|
|
|
getServer().getPluginManager().registerEvents(new EntitySpawnListener(), this);
|
2016-11-27 07:26:06 +01:00
|
|
|
} catch (NoSuchMethodException | ClassNotFoundException ignored) {
|
2016-07-30 03:40:02 +02:00
|
|
|
PS.debug("Not running Spigot. Skipping EntitySpawnListener event.");
|
|
|
|
}
|
2016-09-14 18:16:22 +02:00
|
|
|
if (PS.get().checkVersion(getServerVersion(), BukkitVersion.v1_8_0)) {
|
2016-05-14 15:50:35 +02:00
|
|
|
try {
|
|
|
|
getServer().getPluginManager().registerEvents(new PlayerEvents_1_8(), this);
|
|
|
|
} catch (Throwable e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
2015-02-19 07:08:15 +01:00
|
|
|
}
|
2016-09-14 18:16:22 +02:00
|
|
|
if (PS.get().checkVersion(getServerVersion(), BukkitVersion.v1_8_3)) {
|
2016-05-14 15:50:35 +02:00
|
|
|
try {
|
|
|
|
getServer().getPluginManager().registerEvents(new PlayerEvents183(), this);
|
|
|
|
} catch (Throwable e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
2016-03-30 04:23:31 +02:00
|
|
|
}
|
2016-09-14 18:16:22 +02:00
|
|
|
if (PS.get().checkVersion(getServerVersion(), BukkitVersion.v1_9_0)) {
|
2016-05-14 15:50:35 +02:00
|
|
|
try {
|
|
|
|
getServer().getPluginManager().registerEvents(new PlayerEvents_1_9(main), this);
|
|
|
|
} catch (Throwable e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
2015-05-13 17:49:57 +02:00
|
|
|
}
|
2015-02-19 07:08:15 +01:00
|
|
|
}
|
2016-03-20 23:19:37 +01:00
|
|
|
|
2015-02-19 07:08:15 +01:00
|
|
|
@Override
|
2015-09-13 06:04:31 +02:00
|
|
|
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
|
|
|
}
|
2016-03-20 23:19:37 +01:00
|
|
|
|
2015-02-19 07:08:15 +01:00
|
|
|
@Override
|
2015-09-13 06:04:31 +02:00
|
|
|
public void registerPlotPlusEvents() {
|
2015-02-19 07:08:15 +01:00
|
|
|
PlotPlusListener.startRunnable(this);
|
|
|
|
getServer().getPluginManager().registerEvents(new PlotPlusListener(), this);
|
2017-08-10 08:46:51 +02:00
|
|
|
if (PS.get().checkVersion(getServerVersion(), BukkitVersion.v1_12_0)) {
|
|
|
|
getServer().getPluginManager().registerEvents(new PlotPlusListener_1_12(), this);
|
|
|
|
} else {
|
|
|
|
getServer().getPluginManager().registerEvents(new PlotPlusListener_Legacy(), this);
|
|
|
|
}
|
2015-02-19 07:08:15 +01:00
|
|
|
}
|
2016-03-20 23:19:37 +01:00
|
|
|
|
2015-02-19 07:08:15 +01:00
|
|
|
@Override
|
2015-09-13 06:04:31 +02:00
|
|
|
public void registerForceFieldEvents() {
|
2015-02-19 07:08:15 +01:00
|
|
|
}
|
2016-03-20 23:19:37 +01:00
|
|
|
|
2015-02-19 07:08:15 +01:00
|
|
|
@Override
|
2015-09-13 06:04:31 +02:00
|
|
|
public boolean initWorldEdit() {
|
|
|
|
if (getServer().getPluginManager().getPlugin("WorldEdit") != null) {
|
2016-06-01 22:50:35 +02:00
|
|
|
worldEdit = WorldEdit.getInstance();
|
2016-03-23 02:41:37 +01:00
|
|
|
return true;
|
2015-02-19 07:08:15 +01:00
|
|
|
}
|
2015-09-07 14:17:48 +02:00
|
|
|
return false;
|
2015-02-19 07:08:15 +01:00
|
|
|
}
|
2016-03-20 23:19:37 +01:00
|
|
|
|
2015-02-19 07:08:15 +01:00
|
|
|
@Override
|
2015-09-13 06:04:31 +02:00
|
|
|
public EconHandler getEconomyHandler() {
|
|
|
|
try {
|
2016-03-23 02:41:37 +01:00
|
|
|
BukkitEconHandler econ = new BukkitEconHandler();
|
2015-09-13 06:04:31 +02:00
|
|
|
if (econ.init()) {
|
|
|
|
return econ;
|
|
|
|
}
|
2016-03-23 02:41:37 +01:00
|
|
|
} catch (Throwable ignored) {
|
2016-03-29 08:39:29 +02:00
|
|
|
PS.debug("No economy detected!");
|
2016-02-14 02:01:18 +01:00
|
|
|
}
|
2015-02-19 07:08:15 +01:00
|
|
|
return null;
|
|
|
|
}
|
2016-03-20 23:19:37 +01:00
|
|
|
|
2015-02-19 09:51:10 +01:00
|
|
|
@Override
|
2016-06-13 06:47:50 +02:00
|
|
|
public QueueProvider initBlockQueue() {
|
2016-02-10 19:59:51 +01:00
|
|
|
try {
|
|
|
|
new SendChunk();
|
|
|
|
MainUtil.canSendChunk = true;
|
2016-04-30 00:14:12 +02:00
|
|
|
} catch (ClassNotFoundException | NoSuchFieldException | NoSuchMethodException e) {
|
2016-06-27 10:38:14 +02:00
|
|
|
PS.debug(SendChunk.class + " does not support " + StringMan.getString(getServerVersion()));
|
2016-02-10 19:59:51 +01:00
|
|
|
MainUtil.canSendChunk = false;
|
|
|
|
}
|
2016-09-14 18:16:22 +02:00
|
|
|
if (PS.get().checkVersion(getServerVersion(), BukkitVersion.v1_9_0)) {
|
2016-06-13 06:47:50 +02:00
|
|
|
return QueueProvider.of(BukkitLocalQueue_1_9.class, BukkitLocalQueue.class);
|
2016-03-02 22:51:01 +01:00
|
|
|
}
|
2016-09-14 18:16:22 +02:00
|
|
|
if (PS.get().checkVersion(getServerVersion(), BukkitVersion.v1_8_3)) {
|
2016-06-13 06:47:50 +02:00
|
|
|
return QueueProvider.of(BukkitLocalQueue_1_8_3.class, BukkitLocalQueue.class);
|
2015-02-19 09:51:10 +01:00
|
|
|
}
|
2016-09-14 18:16:22 +02:00
|
|
|
if (PS.get().checkVersion(getServerVersion(), BukkitVersion.v1_8_0)) {
|
2016-06-13 06:47:50 +02:00
|
|
|
return QueueProvider.of(BukkitLocalQueue_1_8.class, BukkitLocalQueue.class);
|
2016-02-10 19:59:51 +01:00
|
|
|
}
|
2016-06-13 06:47:50 +02:00
|
|
|
return QueueProvider.of(BukkitLocalQueue_1_7.class, BukkitLocalQueue.class);
|
2016-02-10 19:59:51 +01:00
|
|
|
}
|
2016-03-20 23:19:37 +01:00
|
|
|
|
2016-02-10 19:59:51 +01:00
|
|
|
@Override
|
|
|
|
public WorldUtil initWorldUtil() {
|
|
|
|
return new BukkitUtil();
|
2015-02-19 09:51:10 +01:00
|
|
|
}
|
2016-03-20 23:19:37 +01:00
|
|
|
|
2015-02-19 09:51:10 +01:00
|
|
|
@Override
|
2015-09-13 06:04:31 +02:00
|
|
|
public boolean initPlotMeConverter() {
|
2016-09-26 10:31:08 +02:00
|
|
|
if (new LikePlotMeConverter("PlotMe").run(new ClassicPlotMeConnector())) {
|
|
|
|
return true;
|
2016-11-21 04:24:27 +01:00
|
|
|
} else if (new LikePlotMeConverter("PlotMe").run(new PlotMeConnector_017())) {
|
2016-09-26 10:31:08 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
2015-02-19 09:51:10 +01:00
|
|
|
}
|
2016-03-20 23:19:37 +01:00
|
|
|
|
2015-02-19 09:51:10 +01:00
|
|
|
@Override
|
2016-03-23 02:41:37 +01:00
|
|
|
public GeneratorWrapper<?> getGenerator(String world, String name) {
|
2015-09-13 06:04:31 +02:00
|
|
|
if (name == null) {
|
2016-02-10 19:59:51 +01:00
|
|
|
return null;
|
2015-09-13 06:04:31 +02:00
|
|
|
}
|
2016-03-23 02:41:37 +01:00
|
|
|
Plugin genPlugin = Bukkit.getPluginManager().getPlugin(name);
|
|
|
|
if (genPlugin != null && genPlugin.isEnabled()) {
|
|
|
|
ChunkGenerator gen = genPlugin.getDefaultWorldGenerator(world, "");
|
2016-02-10 19:59:51 +01:00
|
|
|
if (gen instanceof GeneratorWrapper<?>) {
|
|
|
|
return (GeneratorWrapper<?>) gen;
|
|
|
|
}
|
|
|
|
return new BukkitPlotGenerator(world, gen);
|
2015-09-13 06:04:31 +02:00
|
|
|
} else {
|
2016-09-17 08:02:05 +02:00
|
|
|
return new BukkitPlotGenerator(PS.get().IMP.getDefaultGenerator());
|
2015-02-19 09:51:10 +01:00
|
|
|
}
|
|
|
|
}
|
2016-03-20 23:19:37 +01:00
|
|
|
|
2015-02-22 14:20:41 +01:00
|
|
|
@Override
|
2015-09-13 06:04:31 +02:00
|
|
|
public HybridUtils initHybridUtils() {
|
2015-02-22 14:20:41 +01:00
|
|
|
return new BukkitHybridUtils();
|
|
|
|
}
|
2016-03-20 23:19:37 +01:00
|
|
|
|
2015-02-22 14:20:41 +01:00
|
|
|
@Override
|
2015-09-13 06:04:31 +02:00
|
|
|
public SetupUtils initSetupUtils() {
|
2015-02-22 14:20:41 +01:00
|
|
|
return new BukkitSetupUtils();
|
|
|
|
}
|
2016-03-20 23:19:37 +01:00
|
|
|
|
2015-02-23 00:12:33 +01:00
|
|
|
@Override
|
2015-09-13 06:04:31 +02:00
|
|
|
public UUIDHandlerImplementation initUUIDHandler() {
|
2016-09-14 18:16:22 +02:00
|
|
|
boolean checkVersion = PS.get().checkVersion(getServerVersion(), BukkitVersion.v1_7_6);
|
2015-07-27 09:26:50 +02:00
|
|
|
UUIDWrapper wrapper;
|
2016-06-05 09:28:34 +02:00
|
|
|
if (Settings.UUID.OFFLINE) {
|
|
|
|
if (Settings.UUID.FORCE_LOWERCASE) {
|
2016-03-21 03:52:16 +01:00
|
|
|
wrapper = new LowerOfflineUUIDWrapper();
|
2015-09-13 06:04:31 +02:00
|
|
|
} else {
|
2016-03-21 03:52:16 +01:00
|
|
|
wrapper = new OfflineUUIDWrapper();
|
2015-04-12 07:24:54 +02:00
|
|
|
}
|
2016-06-05 09:28:34 +02:00
|
|
|
Settings.UUID.OFFLINE = true;
|
2015-09-13 06:04:31 +02:00
|
|
|
} else if (checkVersion) {
|
2016-03-21 03:52:16 +01:00
|
|
|
wrapper = new DefaultUUIDWrapper();
|
2016-06-05 09:28:34 +02:00
|
|
|
Settings.UUID.OFFLINE = false;
|
2015-09-13 06:04:31 +02:00
|
|
|
} else {
|
2016-06-05 09:28:34 +02:00
|
|
|
if (Settings.UUID.FORCE_LOWERCASE) {
|
2016-03-21 03:52:16 +01:00
|
|
|
wrapper = new LowerOfflineUUIDWrapper();
|
2015-09-13 06:04:31 +02:00
|
|
|
} else {
|
2016-03-21 03:52:16 +01:00
|
|
|
wrapper = new OfflineUUIDWrapper();
|
2015-04-12 07:24:54 +02:00
|
|
|
}
|
2016-06-05 09:28:34 +02:00
|
|
|
Settings.UUID.OFFLINE = true;
|
2015-02-23 00:12:33 +01:00
|
|
|
}
|
2015-09-13 06:04:31 +02:00
|
|
|
if (!checkVersion) {
|
2016-05-21 16:45:48 +02:00
|
|
|
PS.log(C.PREFIX + " &c[WARN] Titles are disabled - please update your version of Bukkit to support this feature.");
|
2015-05-02 12:08:30 +02:00
|
|
|
Settings.TITLES = false;
|
2015-09-13 06:04:31 +02:00
|
|
|
} else {
|
2016-11-30 06:28:50 +01:00
|
|
|
AbstractTitle.TITLE_CLASS = new DefaultTitle_111();
|
2016-02-14 02:01:18 +01:00
|
|
|
if (wrapper instanceof DefaultUUIDWrapper || wrapper.getClass() == OfflineUUIDWrapper.class && !Bukkit.getOnlineMode()) {
|
2016-06-05 09:28:34 +02:00
|
|
|
Settings.UUID.NATIVE_UUID_PROVIDER = true;
|
2015-05-02 12:08:30 +02:00
|
|
|
}
|
|
|
|
}
|
2016-06-05 09:28:34 +02:00
|
|
|
if (Settings.UUID.OFFLINE) {
|
2016-05-21 16:45:48 +02:00
|
|
|
PS.log(C.PREFIX
|
2016-09-26 10:31:08 +02:00
|
|
|
+ " &6" + getPluginName() + " is using Offline Mode UUIDs either because of user preference, or because you are using an old version of "
|
2016-03-23 02:41:37 +01:00
|
|
|
+ "Bukkit");
|
2015-09-13 06:04:31 +02:00
|
|
|
} else {
|
2016-09-26 10:31:08 +02:00
|
|
|
PS.log(C.PREFIX + " &6" + getPluginName() + " is using online UUIDs");
|
2015-02-23 00:12:33 +01:00
|
|
|
}
|
2016-06-05 09:28:34 +02:00
|
|
|
if (Settings.UUID.USE_SQLUUIDHANDLER) {
|
2016-03-23 02:41:37 +01:00
|
|
|
return new SQLUUIDHandler(wrapper);
|
|
|
|
} else {
|
|
|
|
return new FileUUIDHandler(wrapper);
|
|
|
|
}
|
2015-02-23 00:12:33 +01:00
|
|
|
}
|
2016-03-20 23:19:37 +01:00
|
|
|
|
2015-02-23 01:05:25 +01:00
|
|
|
@Override
|
2015-09-13 06:04:31 +02:00
|
|
|
public ChunkManager initChunkManager() {
|
2015-02-23 06:29:45 +01:00
|
|
|
return new BukkitChunkManager();
|
|
|
|
}
|
2016-03-20 23:19:37 +01:00
|
|
|
|
2015-02-23 06:29:45 +01:00
|
|
|
@Override
|
2015-09-13 06:04:31 +02:00
|
|
|
public EventUtil initEventUtil() {
|
2015-02-23 06:29:45 +01:00
|
|
|
return new BukkitEventUtil();
|
2015-02-23 01:05:25 +01:00
|
|
|
}
|
2016-03-20 23:19:37 +01:00
|
|
|
|
2015-04-09 07:41:14 +02:00
|
|
|
@Override
|
2016-03-23 02:41:37 +01:00
|
|
|
public void unregister(PlotPlayer player) {
|
2015-04-09 07:41:14 +02:00
|
|
|
BukkitUtil.removePlayer(player.getName());
|
|
|
|
}
|
2016-03-20 23:19:37 +01:00
|
|
|
|
2015-04-26 08:29:58 +02:00
|
|
|
@Override
|
2015-09-13 06:04:31 +02:00
|
|
|
public void registerChunkProcessor() {
|
2015-04-26 08:29:58 +02:00
|
|
|
getServer().getPluginManager().registerEvents(new ChunkListener(), this);
|
|
|
|
}
|
2016-03-20 23:19:37 +01:00
|
|
|
|
2015-04-26 08:29:58 +02:00
|
|
|
@Override
|
2015-09-13 06:04:31 +02:00
|
|
|
public void registerWorldEvents() {
|
2015-04-26 08:29:58 +02:00
|
|
|
getServer().getPluginManager().registerEvents(new WorldEvents(), this);
|
|
|
|
}
|
2016-03-20 23:19:37 +01:00
|
|
|
|
2016-09-17 08:02:05 +02:00
|
|
|
@Override
|
|
|
|
public IndependentPlotGenerator getDefaultGenerator() {
|
|
|
|
return new HybridGen();
|
|
|
|
}
|
|
|
|
|
2015-07-03 04:11:41 +02:00
|
|
|
@Override
|
2015-09-13 06:04:31 +02:00
|
|
|
public InventoryUtil initInventoryUtil() {
|
2015-07-03 04:11:41 +02:00
|
|
|
return new BukkitInventoryUtil();
|
|
|
|
}
|
2016-03-20 23:19:37 +01:00
|
|
|
|
2015-07-28 08:06:19 +02:00
|
|
|
@Override
|
2015-09-13 06:04:31 +02:00
|
|
|
public void startMetrics() {
|
2016-07-17 04:51:49 +02:00
|
|
|
new Metrics(this).start();
|
2016-05-21 16:45:48 +02:00
|
|
|
PS.log(C.PREFIX + "&6Metrics enabled.");
|
2015-07-28 08:06:19 +02:00
|
|
|
}
|
2016-03-20 23:19:37 +01:00
|
|
|
|
2015-07-28 08:06:19 +02:00
|
|
|
@Override
|
2016-03-23 02:41:37 +01:00
|
|
|
public void setGenerator(String worldName) {
|
|
|
|
World world = BukkitUtil.getWorld(worldName);
|
2015-09-13 06:04:31 +02:00
|
|
|
if (world == null) {
|
2015-08-09 11:58:29 +02:00
|
|
|
// create world
|
2016-06-05 09:28:34 +02:00
|
|
|
ConfigurationSection worldConfig = PS.get().worlds.getConfigurationSection("worlds." + worldName);
|
2016-09-26 10:31:08 +02:00
|
|
|
String manager = worldConfig.getString("generator.plugin", getPluginName());
|
2016-03-23 02:41:37 +01:00
|
|
|
SetupObject setup = new SetupObject();
|
2015-08-09 11:58:29 +02:00
|
|
|
setup.plotManager = manager;
|
2016-03-23 18:09:13 +01:00
|
|
|
setup.setupGenerator = worldConfig.getString("generator.init", manager);
|
|
|
|
setup.type = worldConfig.getInt("generator.type");
|
|
|
|
setup.terrain = worldConfig.getInt("generator.terrain");
|
2015-08-09 11:58:29 +02:00
|
|
|
setup.step = new ConfigurationNode[0];
|
2016-03-23 02:41:37 +01:00
|
|
|
setup.world = worldName;
|
2015-08-09 11:58:29 +02:00
|
|
|
SetupUtils.manager.setupWorld(setup);
|
2016-09-02 07:58:24 +02:00
|
|
|
world = Bukkit.getWorld(worldName);
|
2015-09-13 06:04:31 +02:00
|
|
|
} else {
|
|
|
|
try {
|
2016-03-23 02:41:37 +01:00
|
|
|
if (!PS.get().hasPlotArea(worldName)) {
|
|
|
|
SetGenCB.setGenerator(BukkitUtil.getWorld(worldName));
|
2015-08-25 01:01:45 +02:00
|
|
|
}
|
2016-04-26 16:14:22 +02:00
|
|
|
} catch (Exception ignored) {
|
2016-09-02 07:58:24 +02:00
|
|
|
PS.log("Failed to reload world: " + world + " | " + ignored.getMessage());
|
2015-08-25 01:01:45 +02:00
|
|
|
Bukkit.getServer().unloadWorld(world, false);
|
2016-09-02 07:58:24 +02:00
|
|
|
return;
|
2015-08-25 01:01:45 +02:00
|
|
|
}
|
|
|
|
}
|
2016-03-23 02:41:37 +01:00
|
|
|
ChunkGenerator gen = world.getGenerator();
|
2015-09-13 06:04:31 +02:00
|
|
|
if (gen instanceof BukkitPlotGenerator) {
|
2016-03-23 02:41:37 +01:00
|
|
|
PS.get().loadWorld(worldName, (BukkitPlotGenerator) gen);
|
2016-02-10 19:59:51 +01:00
|
|
|
} else if (gen != null) {
|
2016-03-23 02:41:37 +01:00
|
|
|
PS.get().loadWorld(worldName, new BukkitPlotGenerator(worldName, gen));
|
2016-06-05 09:28:34 +02:00
|
|
|
} else if (PS.get().worlds.contains("worlds." + worldName)) {
|
2016-03-23 02:41:37 +01:00
|
|
|
PS.get().loadWorld(worldName, null);
|
2015-07-28 08:06:19 +02:00
|
|
|
}
|
|
|
|
}
|
2016-03-20 23:19:37 +01:00
|
|
|
|
2015-07-30 16:25:16 +02:00
|
|
|
@Override
|
2015-09-13 06:04:31 +02:00
|
|
|
public SchematicHandler initSchematicHandler() {
|
2015-07-30 16:25:16 +02:00
|
|
|
return new BukkitSchematicHandler();
|
|
|
|
}
|
2016-03-20 23:19:37 +01: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
|
|
|
// Already initialized in UUID handler
|
|
|
|
return AbstractTitle.TITLE_CLASS;
|
|
|
|
}
|
2016-03-20 23:19:37 +01:00
|
|
|
|
2015-07-30 19:24:01 +02:00
|
|
|
@Override
|
2016-03-23 02:41:37 +01:00
|
|
|
public PlotPlayer wrapPlayer(Object player) {
|
|
|
|
if (player instanceof Player) {
|
|
|
|
return BukkitUtil.getPlayer((Player) player);
|
2016-04-28 22:38:51 +02:00
|
|
|
}
|
|
|
|
if (player instanceof OfflinePlayer) {
|
2016-03-23 02:41:37 +01:00
|
|
|
return BukkitUtil.getPlayer((OfflinePlayer) player);
|
2016-04-28 22:38:51 +02:00
|
|
|
}
|
|
|
|
if (player instanceof String) {
|
2016-03-23 02:41:37 +01:00
|
|
|
return UUIDHandler.getPlayer((String) player);
|
2016-04-28 22:38:51 +02:00
|
|
|
}
|
|
|
|
if (player instanceof UUID) {
|
2016-03-23 02:41:37 +01:00
|
|
|
return UUIDHandler.getPlayer((UUID) player);
|
2015-07-30 19:24:01 +02:00
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
2016-03-20 23:19:37 +01:00
|
|
|
|
2015-08-03 20:20:04 +02:00
|
|
|
@Override
|
2015-09-13 06:04:31 +02:00
|
|
|
public String getNMSPackage() {
|
2016-03-19 05:39:42 +01:00
|
|
|
String name = Bukkit.getServer().getClass().getPackage().getName();
|
|
|
|
return name.substring(name.lastIndexOf('.') + 1);
|
2015-08-03 20:20:04 +02:00
|
|
|
}
|
2016-03-20 23:19:37 +01:00
|
|
|
|
2015-08-24 18:28:32 +02:00
|
|
|
@Override
|
2015-09-13 06:04:31 +02:00
|
|
|
public ChatManager<?> initChatManager() {
|
2016-06-10 19:00:34 +02:00
|
|
|
if (Settings.Chat.INTERACTIVE) {
|
2015-08-24 18:28:32 +02:00
|
|
|
return new BukkitChatManager();
|
2015-09-13 06:04:31 +02:00
|
|
|
} else {
|
2016-06-27 10:38:14 +02:00
|
|
|
return new PlainChatManager();
|
2015-08-24 18:28:32 +02:00
|
|
|
}
|
|
|
|
}
|
2016-03-20 23:19:37 +01:00
|
|
|
|
2016-02-10 19:59:51 +01:00
|
|
|
@Override
|
2016-09-06 16:28:01 +02:00
|
|
|
public GeneratorWrapper<?> wrapPlotGenerator(String world, IndependentPlotGenerator generator) {
|
2016-02-19 19:42:06 +01:00
|
|
|
return new BukkitPlotGenerator(generator);
|
2016-02-10 19:59:51 +01:00
|
|
|
}
|
2016-03-20 23:19:37 +01:00
|
|
|
|
2016-02-10 19:59:51 +01:00
|
|
|
@Override
|
|
|
|
public List<String> getPluginIds() {
|
|
|
|
ArrayList<String> names = new ArrayList<>();
|
|
|
|
for (Plugin plugin : Bukkit.getPluginManager().getPlugins()) {
|
2016-04-30 00:14:12 +02:00
|
|
|
names.add(plugin.getName() + ';' + plugin.getDescription().getVersion() + ':' + plugin.isEnabled());
|
2016-02-10 19:59:51 +01:00
|
|
|
}
|
|
|
|
return names;
|
|
|
|
}
|
2015-02-19 04:24:05 +01:00
|
|
|
}
|