mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 21:26:45 +01:00
A whole loads of rewritez
This commit is contained in:
parent
8e499dffb2
commit
ebe80350dc
@ -1,12 +1,28 @@
|
||||
package com.intellectualcrafters.plot;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import com.intellectualcrafters.plot.commands.*;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
import com.intellectualcrafters.plot.database.plotme.ClassicPlotMeConnector;
|
||||
import com.intellectualcrafters.plot.database.plotme.LikePlotMeConverter;
|
||||
import com.intellectualcrafters.plot.flag.FlagManager;
|
||||
import com.intellectualcrafters.plot.generator.BukkitHybridUtils;
|
||||
import com.intellectualcrafters.plot.generator.HybridGen;
|
||||
import com.intellectualcrafters.plot.generator.HybridUtils;
|
||||
import com.intellectualcrafters.plot.listeners.*;
|
||||
import com.intellectualcrafters.plot.listeners.worldedit.WEListener;
|
||||
import com.intellectualcrafters.plot.listeners.worldedit.WESubscriber;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.titles.AbstractTitle;
|
||||
import com.intellectualcrafters.plot.titles.DefaultTitle;
|
||||
import com.intellectualcrafters.plot.util.*;
|
||||
import com.intellectualcrafters.plot.util.bukkit.*;
|
||||
import com.intellectualcrafters.plot.uuid.DefaultUUIDWrapper;
|
||||
import com.intellectualcrafters.plot.uuid.LowerOfflineUUIDWrapper;
|
||||
import com.intellectualcrafters.plot.uuid.OfflineUUIDWrapper;
|
||||
import com.intellectualcrafters.plot.uuid.UUIDWrapper;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Chunk;
|
||||
@ -19,130 +35,14 @@ import org.bukkit.generator.ChunkGenerator;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import com.intellectualcrafters.plot.commands.Add;
|
||||
import com.intellectualcrafters.plot.commands.Auto;
|
||||
import com.intellectualcrafters.plot.commands.BukkitCommand;
|
||||
import com.intellectualcrafters.plot.commands.Chat;
|
||||
import com.intellectualcrafters.plot.commands.Claim;
|
||||
import com.intellectualcrafters.plot.commands.Clear;
|
||||
import com.intellectualcrafters.plot.commands.Cluster;
|
||||
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;
|
||||
import com.intellectualcrafters.plot.commands.DebugFill;
|
||||
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.Deny;
|
||||
import com.intellectualcrafters.plot.commands.FlagCmd;
|
||||
import com.intellectualcrafters.plot.commands.Help;
|
||||
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;
|
||||
import com.intellectualcrafters.plot.commands.MainCommand;
|
||||
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.Remove;
|
||||
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.Toggle;
|
||||
import com.intellectualcrafters.plot.commands.Trim;
|
||||
import com.intellectualcrafters.plot.commands.Trust;
|
||||
import com.intellectualcrafters.plot.commands.Unclaim;
|
||||
import com.intellectualcrafters.plot.commands.Undeny;
|
||||
import com.intellectualcrafters.plot.commands.Unlink;
|
||||
import com.intellectualcrafters.plot.commands.Untrust;
|
||||
import com.intellectualcrafters.plot.commands.Visit;
|
||||
import com.intellectualcrafters.plot.commands.WE_Anywhere;
|
||||
import com.intellectualcrafters.plot.commands.list;
|
||||
import com.intellectualcrafters.plot.commands.plugin;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
import com.intellectualcrafters.plot.database.plotme.ClassicPlotMeConnector;
|
||||
import com.intellectualcrafters.plot.database.plotme.LikePlotMeConverter;
|
||||
import com.intellectualcrafters.plot.flag.FlagManager;
|
||||
import com.intellectualcrafters.plot.generator.BukkitHybridUtils;
|
||||
import com.intellectualcrafters.plot.generator.HybridGen;
|
||||
import com.intellectualcrafters.plot.generator.HybridUtils;
|
||||
import com.intellectualcrafters.plot.listeners.APlotListener;
|
||||
import com.intellectualcrafters.plot.listeners.ChunkListener;
|
||||
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;
|
||||
import com.intellectualcrafters.plot.listeners.PlayerEvents_1_8_3;
|
||||
import com.intellectualcrafters.plot.listeners.PlotListener;
|
||||
import com.intellectualcrafters.plot.listeners.PlotPlusListener;
|
||||
import com.intellectualcrafters.plot.listeners.TNTListener;
|
||||
import com.intellectualcrafters.plot.listeners.WorldEvents;
|
||||
import com.intellectualcrafters.plot.listeners.worldedit.WEListener;
|
||||
import com.intellectualcrafters.plot.listeners.worldedit.WESubscriber;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.titles.AbstractTitle;
|
||||
import com.intellectualcrafters.plot.titles.DefaultTitle;
|
||||
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;
|
||||
import com.intellectualcrafters.plot.util.PlayerManager;
|
||||
import com.intellectualcrafters.plot.util.SetupUtils;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.intellectualcrafters.plot.util.bukkit.BukkitChunkManager;
|
||||
import com.intellectualcrafters.plot.util.bukkit.BukkitEconHandler;
|
||||
import com.intellectualcrafters.plot.util.bukkit.BukkitEventUtil;
|
||||
import com.intellectualcrafters.plot.util.bukkit.BukkitInventoryUtil;
|
||||
import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerManager;
|
||||
import com.intellectualcrafters.plot.util.bukkit.BukkitSetBlockManager;
|
||||
import com.intellectualcrafters.plot.util.bukkit.BukkitSetupUtils;
|
||||
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.SetGenCB;
|
||||
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
||||
import com.intellectualcrafters.plot.uuid.DefaultUUIDWrapper;
|
||||
import com.intellectualcrafters.plot.uuid.LowerOfflineUUIDWrapper;
|
||||
import com.intellectualcrafters.plot.uuid.OfflineUUIDWrapper;
|
||||
import com.intellectualcrafters.plot.uuid.UUIDWrapper;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
||||
|
||||
public static BukkitMain THIS = null;
|
||||
public static PlotSquared MAIN = null;
|
||||
|
||||
private int[] version;
|
||||
|
||||
@ -168,7 +68,7 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
||||
@Override
|
||||
public void onEnable() {
|
||||
THIS = this;
|
||||
MAIN = new PlotSquared(this);
|
||||
PlotSquared.instance = new PlotSquared(this);
|
||||
if (Settings.METRICS) {
|
||||
try {
|
||||
final Metrics metrics = new Metrics(this);
|
||||
@ -197,8 +97,7 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
MAIN.disable();
|
||||
MAIN = null;
|
||||
PlotSquared.getInstance().disable();
|
||||
THIS = null;
|
||||
}
|
||||
|
||||
@ -336,7 +235,7 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
||||
this.error = 0l;
|
||||
}
|
||||
World world;
|
||||
for (final String w : PlotSquared.getPlotWorlds()) {
|
||||
for (final String w : PlotSquared.getInstance().getPlotWorlds()) {
|
||||
world = Bukkit.getWorld(w);
|
||||
try {
|
||||
if (world.getLoadedChunks().length < 1) {
|
||||
@ -364,7 +263,7 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
||||
@Override
|
||||
final public ChunkGenerator getDefaultWorldGenerator(final String world, final String id) {
|
||||
WorldEvents.lastWorld = world;
|
||||
if (!PlotSquared.setupPlotWorld(world, id)) {
|
||||
if (!PlotSquared.getInstance().setupPlotWorld(world, id)) {
|
||||
return null;
|
||||
}
|
||||
HybridGen result = new HybridGen(world);
|
||||
@ -409,8 +308,8 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
||||
@Override
|
||||
public void registerWorldEditEvents() {
|
||||
if (getServer().getPluginManager().getPlugin("WorldEdit") != null) {
|
||||
PlotSquared.worldEdit = (WorldEditPlugin) getServer().getPluginManager().getPlugin("WorldEdit");
|
||||
final String version = PlotSquared.worldEdit.getDescription().getVersion();
|
||||
PlotSquared.getInstance().worldEdit = (WorldEditPlugin) getServer().getPluginManager().getPlugin("WorldEdit");
|
||||
final String version = PlotSquared.getInstance().worldEdit.getDescription().getVersion();
|
||||
if ((version != null) && version.startsWith("5.")) {
|
||||
log("&cThis version of WorldEdit does not support PlotSquared.");
|
||||
log("&cPlease use WorldEdit 6+ for masking support");
|
||||
@ -430,8 +329,8 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
||||
if (econ.init()) {
|
||||
return econ;
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
}
|
||||
catch (Throwable e) {};
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -472,10 +371,7 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
||||
}
|
||||
}
|
||||
}, 20);
|
||||
if (Bukkit.getPluginManager().getPlugin("PlotMe") != null || Bukkit.getPluginManager().getPlugin("AthionPlots") != null) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return Bukkit.getPluginManager().getPlugin("PlotMe") != null || Bukkit.getPluginManager().getPlugin("AthionPlots") != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,5 +1,22 @@
|
||||
package com.intellectualcrafters.plot;
|
||||
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.config.Configuration;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
import com.intellectualcrafters.plot.database.*;
|
||||
import com.intellectualcrafters.plot.flag.AbstractFlag;
|
||||
import com.intellectualcrafters.plot.flag.FlagManager;
|
||||
import com.intellectualcrafters.plot.flag.FlagValue;
|
||||
import com.intellectualcrafters.plot.generator.*;
|
||||
import com.intellectualcrafters.plot.listeners.APlotListener;
|
||||
import com.intellectualcrafters.plot.object.*;
|
||||
import com.intellectualcrafters.plot.object.comment.CommentManager;
|
||||
import com.intellectualcrafters.plot.util.*;
|
||||
import com.intellectualcrafters.plot.util.Logger.LogLevel;
|
||||
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
@ -8,101 +25,147 @@ import java.sql.Connection;
|
||||
import java.sql.DatabaseMetaData;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipInputStream;
|
||||
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
/**
|
||||
* An implementation of the core,
|
||||
* with a static getter for easy access
|
||||
*/
|
||||
public class PlotSquared implements PlotSquaredMain {
|
||||
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.config.Configuration;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
import com.intellectualcrafters.plot.database.Database;
|
||||
import com.intellectualcrafters.plot.database.MySQL;
|
||||
import com.intellectualcrafters.plot.database.SQLManager;
|
||||
import com.intellectualcrafters.plot.database.SQLite;
|
||||
import com.intellectualcrafters.plot.flag.AbstractFlag;
|
||||
import com.intellectualcrafters.plot.flag.FlagManager;
|
||||
import com.intellectualcrafters.plot.flag.FlagValue;
|
||||
import com.intellectualcrafters.plot.generator.AugmentedPopulator;
|
||||
import com.intellectualcrafters.plot.generator.ClassicPlotWorld;
|
||||
import com.intellectualcrafters.plot.generator.HybridGen;
|
||||
import com.intellectualcrafters.plot.generator.HybridPlotWorld;
|
||||
import com.intellectualcrafters.plot.generator.HybridUtils;
|
||||
import com.intellectualcrafters.plot.generator.SquarePlotManager;
|
||||
import com.intellectualcrafters.plot.generator.SquarePlotWorld;
|
||||
import com.intellectualcrafters.plot.listeners.APlotListener;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||
import com.intellectualcrafters.plot.object.PlotCluster;
|
||||
import com.intellectualcrafters.plot.object.PlotGenerator;
|
||||
import com.intellectualcrafters.plot.object.PlotHandler;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.PlotManager;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
import com.intellectualcrafters.plot.object.comment.CommentManager;
|
||||
import com.intellectualcrafters.plot.util.BlockManager;
|
||||
import com.intellectualcrafters.plot.util.ChunkManager;
|
||||
import com.intellectualcrafters.plot.util.ClusterManager;
|
||||
import com.intellectualcrafters.plot.util.EconHandler;
|
||||
import com.intellectualcrafters.plot.util.EventUtil;
|
||||
import com.intellectualcrafters.plot.util.ExpireManager;
|
||||
import com.intellectualcrafters.plot.util.InventoryUtil;
|
||||
import com.intellectualcrafters.plot.util.Logger;
|
||||
import com.intellectualcrafters.plot.util.Logger.LogLevel;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.PlayerManager;
|
||||
import com.intellectualcrafters.plot.util.SetupUtils;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||
|
||||
public class PlotSquared {
|
||||
public static final String MAIN_PERMISSION = "plots.use";
|
||||
public static final String ADMIN_PERMISSION = "plots.admin";
|
||||
public static File styleFile;
|
||||
public static YamlConfiguration style;
|
||||
public static File configFile;
|
||||
public static YamlConfiguration config;
|
||||
public static File storageFile;
|
||||
public static YamlConfiguration storage;
|
||||
public static PlotSquared THIS = null; // This class
|
||||
public static File FILE = null; // This file
|
||||
public static IPlotMain IMP = null; // Specific implementation of PlotSquared
|
||||
public static String VERSION = null;
|
||||
public static TaskManager TASK = null;
|
||||
private static boolean LOADING_WORLD = false;
|
||||
public static WorldEditPlugin worldEdit = null;
|
||||
private final static HashMap<String, PlotWorld> plotworlds = new HashMap<>();
|
||||
private final static HashMap<String, PlotManager> plotmanagers = new HashMap<>();
|
||||
|
||||
|
||||
private static LinkedHashMap<String, HashMap<PlotId, Plot>> plots;
|
||||
|
||||
|
||||
private static Database database;
|
||||
public static Connection connection;
|
||||
|
||||
public static Database getDatabase() {
|
||||
protected static PlotSquared instance;
|
||||
private final HashMap<String, PlotWorld> plotworlds = new HashMap<>();
|
||||
private final HashMap<String, PlotManager> plotmanagers = new HashMap<>();
|
||||
public WorldEditPlugin worldEdit = null;
|
||||
private File styleFile;
|
||||
private YamlConfiguration style;
|
||||
private File configFile;
|
||||
private YamlConfiguration config;
|
||||
private File storageFile;
|
||||
private YamlConfiguration storage;
|
||||
private File FILE = null; // This file
|
||||
private IPlotMain IMP = null; // Specific implementation of PlotSquared
|
||||
private String VERSION = null;
|
||||
private boolean LOADING_WORLD = false;
|
||||
private LinkedHashMap<String, HashMap<PlotId, Plot>> plots;
|
||||
private Database database;
|
||||
private Connection connection;
|
||||
|
||||
public PlotSquared(final IPlotMain imp_class) {
|
||||
SetupUtils.generators = new HashMap<>();
|
||||
IMP = imp_class;
|
||||
try {
|
||||
FILE = new File(PlotSquared.class.getProtectionDomain().getCodeSource().getLocation().toURI().getPath());
|
||||
} catch (Exception e) {
|
||||
log("Could not determine file path");
|
||||
}
|
||||
VERSION = IMP.getVersion();
|
||||
EconHandler.manager = IMP.getEconomyHandler();
|
||||
C.setupTranslations();
|
||||
C.saveTranslations();
|
||||
if (getJavaVersion() < 1.7) {
|
||||
log(C.PREFIX.s() + "&cYour java version is outdated. Please update to at least 1.7.");
|
||||
// Didn't know of any other link :D
|
||||
log(C.PREFIX.s() + "&cURL: &6https://java.com/en/download/index.jsp");
|
||||
IMP.disable();
|
||||
return;
|
||||
}
|
||||
if (getJavaVersion() < 1.8) {
|
||||
log(C.PREFIX.s() + "&cIt's really recommended to run Java 1.8, as it increases performance");
|
||||
}
|
||||
TaskManager TASK = IMP.getTaskManager();
|
||||
if (C.ENABLED.s().length() > 0) {
|
||||
log(C.ENABLED.s());
|
||||
}
|
||||
setupConfigs();
|
||||
setupDefaultFlags();
|
||||
setupDatabase();
|
||||
CommentManager.registerDefaultInboxes();
|
||||
// Tasks
|
||||
if (Settings.KILL_ROAD_MOBS) {
|
||||
IMP.runEntityTask();
|
||||
}
|
||||
// Events
|
||||
IMP.registerCommands();
|
||||
IMP.registerPlayerEvents();
|
||||
IMP.registerInventoryEvents();
|
||||
IMP.registerPlotPlusEvents();
|
||||
IMP.registerForceFieldEvents();
|
||||
IMP.registerWorldEditEvents();
|
||||
IMP.registerWorldEvents();
|
||||
if (Settings.TNT_LISTENER) {
|
||||
IMP.registerTNTListener();
|
||||
}
|
||||
if (Settings.CHUNK_PROCESSOR) {
|
||||
IMP.registerChunkProcessor();
|
||||
}
|
||||
// create UUIDWrapper
|
||||
UUIDHandler.uuidWrapper = IMP.initUUIDHandler();
|
||||
// create event util class
|
||||
EventUtil.manager = IMP.initEventUtil();
|
||||
// create Hybrid utility class
|
||||
HybridUtils.manager = IMP.initHybridUtils();
|
||||
// Inventory utility class
|
||||
InventoryUtil.manager = IMP.initInventoryUtil();
|
||||
// create setup util class
|
||||
SetupUtils.manager = IMP.initSetupUtils();
|
||||
// Set block
|
||||
BlockManager.manager = IMP.initBlockManager();
|
||||
// Set chunk
|
||||
ChunkManager.manager = IMP.initChunkManager();
|
||||
// Plot listener
|
||||
APlotListener.manager = IMP.initPlotListener();
|
||||
// Player manager
|
||||
PlayerManager.manager = IMP.initPlayerManager();
|
||||
|
||||
// PlotMe
|
||||
if (Settings.CONVERT_PLOTME || Settings.CACHE_PLOTME) {
|
||||
TaskManager.runTaskLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (IMP.initPlotMeConverter()) {
|
||||
log("&c=== IMPORTANT ===");
|
||||
log("&cTHIS MESSAGE MAY BE EXTREMELY HELPFUL IF YOU HAVE TROUBLE CONVERTING PLOTME!");
|
||||
log("&c - Make sure 'UUID.read-from-disk' is disabled (false)!");
|
||||
log("&c - Sometimes the database can be locked, deleting PlotMe.jar beforehand will fix the issue!");
|
||||
log("&c - After the conversion is finished, please set 'plotme-convert.enabled' to false in the 'settings.yml'");
|
||||
}
|
||||
}
|
||||
}, 200);
|
||||
}
|
||||
if (Settings.AUTO_CLEAR) {
|
||||
ExpireManager.runTask();
|
||||
}
|
||||
|
||||
// Copy files
|
||||
copyFile("town.template", "templates");
|
||||
copyFile("skyblock.template", "templates");
|
||||
copyFile("german.yml", "translations");
|
||||
copyFile("s_chinese_unescaped.yml", "translations");
|
||||
copyFile("s_chinese.yml", "translations");
|
||||
copyFile("italian.yml", "translations");
|
||||
showDebug();
|
||||
}
|
||||
|
||||
public static PlotSquared getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
public static void log(final String message) {
|
||||
getInstance().IMP.log(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Database getDatabase() {
|
||||
return database;
|
||||
}
|
||||
|
||||
public static void updatePlot(final Plot plot) {
|
||||
@Override
|
||||
public void updatePlot(final Plot plot) {
|
||||
final String world = plot.world;
|
||||
if (!plots.containsKey(world)) {
|
||||
plots.put(world, new HashMap<PlotId, Plot>());
|
||||
@ -111,14 +174,16 @@ public class PlotSquared {
|
||||
plots.get(world).put(plot.id, plot);
|
||||
}
|
||||
|
||||
public static PlotWorld getPlotWorld(final String world) {
|
||||
@Override
|
||||
public PlotWorld getPlotWorld(final String world) {
|
||||
if (plotworlds.containsKey(world)) {
|
||||
return plotworlds.get(world);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void addPlotWorld(final String world, final PlotWorld plotworld, final PlotManager manager) {
|
||||
@Override
|
||||
public void addPlotWorld(final String world, final PlotWorld plotworld, final PlotManager manager) {
|
||||
plotworlds.put(world, plotworld);
|
||||
plotmanagers.put(world, manager);
|
||||
if (!plots.containsKey(world)) {
|
||||
@ -126,26 +191,31 @@ public class PlotSquared {
|
||||
}
|
||||
}
|
||||
|
||||
public static void removePlotWorld(final String world) {
|
||||
@Override
|
||||
public void removePlotWorld(final String world) {
|
||||
plots.remove(world);
|
||||
plotmanagers.remove(world);
|
||||
plotworlds.remove(world);
|
||||
}
|
||||
|
||||
public static void removePlotWorldAbs(final String world) {
|
||||
|
||||
@Override
|
||||
public void removePlotWorldAbs(final String world) {
|
||||
plotmanagers.remove(world);
|
||||
plotworlds.remove(world);
|
||||
}
|
||||
|
||||
public static HashMap<String, HashMap<PlotId, Plot>> getAllPlotsRaw() {
|
||||
@Override
|
||||
public HashMap<String, HashMap<PlotId, Plot>> getAllPlotsRaw() {
|
||||
return plots;
|
||||
}
|
||||
|
||||
public static void setAllPlotsRaw(final LinkedHashMap<String, HashMap<PlotId, Plot>> plots) {
|
||||
PlotSquared.plots = plots;
|
||||
@Override
|
||||
public void setAllPlotsRaw(final LinkedHashMap<String, HashMap<PlotId, Plot>> plots) {
|
||||
this.plots = plots;
|
||||
}
|
||||
|
||||
public static Set<Plot> getPlots() {
|
||||
@Override
|
||||
public Set<Plot> getPlots() {
|
||||
final ArrayList<Plot> newplots = new ArrayList<>();
|
||||
for (final Entry<String, HashMap<PlotId, Plot>> entry : plots.entrySet()) {
|
||||
if (isPlotWorld(entry.getKey())) {
|
||||
@ -154,16 +224,18 @@ public class PlotSquared {
|
||||
}
|
||||
return new LinkedHashSet<>(newplots);
|
||||
}
|
||||
|
||||
public static Set<Plot> getPlotsRaw() {
|
||||
|
||||
@Override
|
||||
public Set<Plot> getPlotsRaw() {
|
||||
final ArrayList<Plot> newplots = new ArrayList<>();
|
||||
for (final Entry<String, HashMap<PlotId, Plot>> entry : plots.entrySet()) {
|
||||
newplots.addAll(entry.getValue().values());
|
||||
}
|
||||
return new LinkedHashSet<>(newplots);
|
||||
}
|
||||
|
||||
public static ArrayList<Plot> sortPlots(Collection<Plot> plots) {
|
||||
|
||||
@Override
|
||||
public ArrayList<Plot> sortPlots(Collection<Plot> plots) {
|
||||
ArrayList<Plot> newPlots = new ArrayList<>();
|
||||
newPlots.addAll(plots);
|
||||
Collections.sort(newPlots, new Comparator<Plot>() {
|
||||
@ -188,10 +260,11 @@ public class PlotSquared {
|
||||
});
|
||||
return newPlots;
|
||||
}
|
||||
|
||||
public static ArrayList<Plot> sortPlots(Collection<Plot> plots, final String priorityWorld) {
|
||||
|
||||
@Override
|
||||
public ArrayList<Plot> sortPlots(Collection<Plot> plots, final String priorityWorld) {
|
||||
ArrayList<Plot> newPlots = new ArrayList<>();
|
||||
HashMap<PlotId, Plot> worldPlots = PlotSquared.plots.get(priorityWorld);
|
||||
HashMap<PlotId, Plot> worldPlots = this.plots.get(priorityWorld);
|
||||
if (worldPlots != null) {
|
||||
for (Plot plot : sortPlots(worldPlots.values())) {
|
||||
if (plots.contains(plot)) {
|
||||
@ -199,11 +272,11 @@ public class PlotSquared {
|
||||
}
|
||||
}
|
||||
}
|
||||
ArrayList<String> worlds = new ArrayList<>(PlotSquared.plots.keySet());
|
||||
ArrayList<String> worlds = new ArrayList<>(this.plots.keySet());
|
||||
Collections.sort(worlds);
|
||||
for (String world : worlds) {
|
||||
if (!world.equals(priorityWorld)) {
|
||||
for (Plot plot : PlotSquared.plots.get(world).values()) {
|
||||
for (Plot plot : this.plots.get(world).values()) {
|
||||
if (plots.contains(plot)) {
|
||||
newPlots.add(plot);
|
||||
}
|
||||
@ -212,13 +285,14 @@ public class PlotSquared {
|
||||
}
|
||||
return newPlots;
|
||||
}
|
||||
|
||||
public static ArrayList<Plot> sortPlotsByWorld(Collection<Plot> plots) {
|
||||
|
||||
@Override
|
||||
public ArrayList<Plot> sortPlotsByWorld(Collection<Plot> plots) {
|
||||
ArrayList<Plot> newPlots = new ArrayList<>();
|
||||
ArrayList<String> worlds = new ArrayList<>(PlotSquared.plots.keySet());
|
||||
ArrayList<String> worlds = new ArrayList<>(this.plots.keySet());
|
||||
Collections.sort(worlds);
|
||||
for (String world : worlds) {
|
||||
for (Plot plot : PlotSquared.plots.get(world).values()) {
|
||||
for (Plot plot : this.plots.get(world).values()) {
|
||||
if (plots.contains(plot)) {
|
||||
newPlots.add(plot);
|
||||
}
|
||||
@ -227,17 +301,20 @@ public class PlotSquared {
|
||||
return newPlots;
|
||||
}
|
||||
|
||||
public static Set<Plot> getPlots(final String world, final String player) {
|
||||
@Override
|
||||
public Set<Plot> getPlots(final String world, final String player) {
|
||||
final UUID uuid = UUIDHandler.getUUID(player);
|
||||
return getPlots(world, uuid);
|
||||
}
|
||||
|
||||
public static Set<Plot> getPlots(final String world, final PlotPlayer player) {
|
||||
@Override
|
||||
public Set<Plot> getPlots(final String world, final PlotPlayer player) {
|
||||
final UUID uuid = player.getUUID();
|
||||
return getPlots(world, uuid);
|
||||
}
|
||||
|
||||
public static Set<Plot> getPlots(final String world, final UUID uuid) {
|
||||
@Override
|
||||
public Set<Plot> getPlots(final String world, final UUID uuid) {
|
||||
final ArrayList<Plot> myplots = new ArrayList<>();
|
||||
for (final Plot plot : getPlots(world).values()) {
|
||||
if (plot.hasOwner()) {
|
||||
@ -249,34 +326,40 @@ public class PlotSquared {
|
||||
return new HashSet<>(myplots);
|
||||
}
|
||||
|
||||
public static boolean isPlotWorld(final String world) {
|
||||
@Override
|
||||
public boolean isPlotWorld(final String world) {
|
||||
return (plotworlds.containsKey(world));
|
||||
}
|
||||
|
||||
public static PlotManager getPlotManager(final String world) {
|
||||
@Override
|
||||
public PlotManager getPlotManager(final String world) {
|
||||
if (plotmanagers.containsKey(world)) {
|
||||
return plotmanagers.get(world);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String[] getPlotWorldsString() {
|
||||
@Override
|
||||
public String[] getPlotWorldsString() {
|
||||
final Set<String> strings = plots.keySet();
|
||||
return strings.toArray(new String[strings.size()]);
|
||||
}
|
||||
|
||||
public static HashMap<PlotId, Plot> getPlots(final String world) {
|
||||
@Override
|
||||
public HashMap<PlotId, Plot> getPlots(final String world) {
|
||||
if (plots.containsKey(world)) {
|
||||
return plots.get(world);
|
||||
}
|
||||
return new HashMap<>();
|
||||
}
|
||||
|
||||
public static Set<Plot> getPlots(final PlotPlayer player) {
|
||||
@Override
|
||||
public Set<Plot> getPlots(final PlotPlayer player) {
|
||||
return getPlots(player.getUUID());
|
||||
}
|
||||
|
||||
public static Set<Plot> getPlots(final UUID uuid) {
|
||||
|
||||
@Override
|
||||
public Set<Plot> getPlots(final UUID uuid) {
|
||||
final ArrayList<Plot> myplots = new ArrayList<>();
|
||||
for (final String world : plots.keySet()) {
|
||||
if (isPlotWorld(world)) {
|
||||
@ -292,7 +375,8 @@ public class PlotSquared {
|
||||
return new HashSet<>(myplots);
|
||||
}
|
||||
|
||||
public static boolean removePlot(final String world, final PlotId id, final boolean callEvent) {
|
||||
@Override
|
||||
public boolean removePlot(final String world, final PlotId id, final boolean callEvent) {
|
||||
if (callEvent) {
|
||||
EventUtil.manager.callDelete(world, id);
|
||||
}
|
||||
@ -308,8 +392,9 @@ public class PlotSquared {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void loadWorld(final String world, PlotGenerator generator) {
|
||||
PlotWorld plotWorld = getPlotWorld(world);
|
||||
@Override
|
||||
public void loadWorld(final String world, PlotGenerator generator) {
|
||||
PlotWorld plotWorld = getPlotWorld(world);
|
||||
if (plotWorld != null) {
|
||||
if (generator != null) {
|
||||
generator.init(plotWorld);
|
||||
@ -370,7 +455,7 @@ public class PlotSquared {
|
||||
final PlotGenerator gen_class = generator;
|
||||
plotWorld = gen_class.getNewPlotWorld(world);
|
||||
plotManager = gen_class.getPlotManager();
|
||||
|
||||
|
||||
if (!config.contains(path)) {
|
||||
config.createSection(path);
|
||||
}
|
||||
@ -378,13 +463,13 @@ public class PlotSquared {
|
||||
plotWorld.TERRAIN = 0;
|
||||
plotWorld.saveConfiguration(config.getConfigurationSection(path));
|
||||
plotWorld.loadDefaultConfiguration(config.getConfigurationSection(path));
|
||||
|
||||
|
||||
try {
|
||||
config.save(configFile);
|
||||
} catch (final IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
if (((plotWorld.TYPE == 2) && !Settings.ENABLE_CLUSTERS) || !(plotManager instanceof SquarePlotManager)) {
|
||||
log("&c[ERROR] World '" + world + "' in settings.yml is not using PlotSquared generator! Please set the generator correctly or delete the world from the 'settings.yml'!");
|
||||
return;
|
||||
@ -404,7 +489,8 @@ public class PlotSquared {
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean setupPlotWorld(final String world, final String id) {
|
||||
@Override
|
||||
public boolean setupPlotWorld(final String world, final String id) {
|
||||
if ((id != null) && (id.length() > 0)) {
|
||||
// save configuration
|
||||
final String[] split = id.split(",");
|
||||
@ -428,39 +514,39 @@ public class PlotSquared {
|
||||
switch (key) {
|
||||
case "s":
|
||||
case "size": {
|
||||
SquarePlotWorld.PLOT_WIDTH_DEFAULT = ((Integer) Configuration.INTEGER.parseString(value)).shortValue();
|
||||
SquarePlotWorld.PLOT_WIDTH_DEFAULT = Configuration.INTEGER.parseString(value).shortValue();
|
||||
break;
|
||||
}
|
||||
case "g":
|
||||
case "gap": {
|
||||
SquarePlotWorld.ROAD_WIDTH_DEFAULT = ((Integer) Configuration.INTEGER.parseString(value)).shortValue();
|
||||
SquarePlotWorld.ROAD_WIDTH_DEFAULT = Configuration.INTEGER.parseString(value).shortValue();
|
||||
break;
|
||||
}
|
||||
case "h":
|
||||
case "height": {
|
||||
ClassicPlotWorld.PLOT_HEIGHT_DEFAULT = (Integer) Configuration.INTEGER.parseString(value);
|
||||
ClassicPlotWorld.ROAD_HEIGHT_DEFAULT = (Integer) Configuration.INTEGER.parseString(value);
|
||||
ClassicPlotWorld.WALL_HEIGHT_DEFAULT = (Integer) Configuration.INTEGER.parseString(value);
|
||||
ClassicPlotWorld.PLOT_HEIGHT_DEFAULT = Configuration.INTEGER.parseString(value);
|
||||
ClassicPlotWorld.ROAD_HEIGHT_DEFAULT = Configuration.INTEGER.parseString(value);
|
||||
ClassicPlotWorld.WALL_HEIGHT_DEFAULT = Configuration.INTEGER.parseString(value);
|
||||
break;
|
||||
}
|
||||
case "f":
|
||||
case "floor": {
|
||||
ClassicPlotWorld.TOP_BLOCK_DEFAULT = (PlotBlock[]) Configuration.BLOCKLIST.parseString(value);
|
||||
ClassicPlotWorld.TOP_BLOCK_DEFAULT = Configuration.BLOCKLIST.parseString(value);
|
||||
break;
|
||||
}
|
||||
case "m":
|
||||
case "main": {
|
||||
ClassicPlotWorld.MAIN_BLOCK_DEFAULT = (PlotBlock[]) Configuration.BLOCKLIST.parseString(value);
|
||||
ClassicPlotWorld.MAIN_BLOCK_DEFAULT = Configuration.BLOCKLIST.parseString(value);
|
||||
break;
|
||||
}
|
||||
case "w":
|
||||
case "wall": {
|
||||
ClassicPlotWorld.WALL_FILLING_DEFAULT = (PlotBlock) Configuration.BLOCK.parseString(value);
|
||||
ClassicPlotWorld.WALL_FILLING_DEFAULT = Configuration.BLOCK.parseString(value);
|
||||
break;
|
||||
}
|
||||
case "b":
|
||||
case "border": {
|
||||
ClassicPlotWorld.WALL_BLOCK_DEFAULT = (PlotBlock) Configuration.BLOCK.parseString(value);
|
||||
ClassicPlotWorld.WALL_BLOCK_DEFAULT = Configuration.BLOCK.parseString(value);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
@ -496,112 +582,109 @@ public class PlotSquared {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static Connection getConnection() {
|
||||
@Override
|
||||
public boolean setupPlotWorld(final String world, final String id) {
|
||||
if ((id != null) && (id.length() > 0)) {
|
||||
// save configuration
|
||||
final String[] split = id.split(",");
|
||||
final HybridPlotWorld plotworld = new HybridPlotWorld(world);
|
||||
final int width = SquarePlotWorld.PLOT_WIDTH_DEFAULT;
|
||||
final int gap = SquarePlotWorld.ROAD_WIDTH_DEFAULT;
|
||||
final int height = ClassicPlotWorld.PLOT_HEIGHT_DEFAULT;
|
||||
final PlotBlock[] floor = ClassicPlotWorld.TOP_BLOCK_DEFAULT;
|
||||
final PlotBlock[] main = ClassicPlotWorld.MAIN_BLOCK_DEFAULT;
|
||||
final PlotBlock wall = ClassicPlotWorld.WALL_FILLING_DEFAULT;
|
||||
final PlotBlock border = ClassicPlotWorld.WALL_BLOCK_DEFAULT;
|
||||
for (final String element : split) {
|
||||
final String[] pair = element.split("=");
|
||||
if (pair.length != 2) {
|
||||
log("&cNo value provided for: &7" + element);
|
||||
return false;
|
||||
}
|
||||
final String key = pair[0].toLowerCase();
|
||||
final String value = pair[1];
|
||||
try {
|
||||
switch (key) {
|
||||
case "s":
|
||||
case "size": {
|
||||
SquarePlotWorld.PLOT_WIDTH_DEFAULT = Configuration.INTEGER.parseString(value).shortValue();
|
||||
break;
|
||||
}
|
||||
case "g":
|
||||
case "gap": {
|
||||
SquarePlotWorld.ROAD_WIDTH_DEFAULT = Configuration.INTEGER.parseString(value).shortValue();
|
||||
break;
|
||||
}
|
||||
case "h":
|
||||
case "height": {
|
||||
ClassicPlotWorld.PLOT_HEIGHT_DEFAULT = Configuration.INTEGER.parseString(value);
|
||||
ClassicPlotWorld.ROAD_HEIGHT_DEFAULT = Configuration.INTEGER.parseString(value);
|
||||
ClassicPlotWorld.WALL_HEIGHT_DEFAULT = Configuration.INTEGER.parseString(value);
|
||||
break;
|
||||
}
|
||||
case "f":
|
||||
case "floor": {
|
||||
ClassicPlotWorld.TOP_BLOCK_DEFAULT = Configuration.BLOCKLIST.parseString(value);
|
||||
break;
|
||||
}
|
||||
case "m":
|
||||
case "main": {
|
||||
ClassicPlotWorld.MAIN_BLOCK_DEFAULT = Configuration.BLOCKLIST.parseString(value);
|
||||
break;
|
||||
}
|
||||
case "w":
|
||||
case "wall": {
|
||||
ClassicPlotWorld.WALL_FILLING_DEFAULT = Configuration.BLOCK.parseString(value);
|
||||
break;
|
||||
}
|
||||
case "b":
|
||||
case "border": {
|
||||
ClassicPlotWorld.WALL_BLOCK_DEFAULT = Configuration.BLOCK.parseString(value);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
log("&cKey not found: &7" + element);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
log("&cInvalid value: &7" + value + " in arg " + element);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
try {
|
||||
final String root = "worlds." + world;
|
||||
if (!config.contains(root)) {
|
||||
config.createSection(root);
|
||||
}
|
||||
plotworld.saveConfiguration(config.getConfigurationSection(root));
|
||||
ClassicPlotWorld.PLOT_HEIGHT_DEFAULT = height;
|
||||
ClassicPlotWorld.ROAD_HEIGHT_DEFAULT = height;
|
||||
ClassicPlotWorld.WALL_HEIGHT_DEFAULT = height;
|
||||
ClassicPlotWorld.TOP_BLOCK_DEFAULT = floor;
|
||||
ClassicPlotWorld.MAIN_BLOCK_DEFAULT = main;
|
||||
ClassicPlotWorld.WALL_BLOCK_DEFAULT = border;
|
||||
ClassicPlotWorld.WALL_FILLING_DEFAULT = wall;
|
||||
SquarePlotWorld.PLOT_WIDTH_DEFAULT = width;
|
||||
SquarePlotWorld.ROAD_WIDTH_DEFAULT = gap;
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Connection getConnection() {
|
||||
return connection;
|
||||
}
|
||||
|
||||
public PlotSquared(final IPlotMain imp_class) {
|
||||
SetupUtils.generators = new HashMap<>();
|
||||
THIS = this;
|
||||
IMP = imp_class;
|
||||
try {
|
||||
FILE = new File(PlotSquared.class.getProtectionDomain().getCodeSource().getLocation().toURI().getPath());
|
||||
}
|
||||
catch (Exception e) {
|
||||
log("Could not determine file path");
|
||||
}
|
||||
VERSION = IMP.getVersion();
|
||||
EconHandler.manager = IMP.getEconomyHandler();
|
||||
C.setupTranslations();
|
||||
C.saveTranslations();
|
||||
if (getJavaVersion() < 1.7) {
|
||||
log(C.PREFIX.s() + "&cYour java version is outdated. Please update to at least 1.7.");
|
||||
// Didn't know of any other link :D
|
||||
log(C.PREFIX.s() + "&cURL: &6https://java.com/en/download/index.jsp");
|
||||
IMP.disable();
|
||||
return;
|
||||
}
|
||||
if (getJavaVersion() < 1.8) {
|
||||
log(C.PREFIX.s() + "&cIt's really recommended to run Java 1.8, as it increases performance");
|
||||
}
|
||||
TASK = IMP.getTaskManager();
|
||||
if (C.ENABLED.s().length() > 0) {
|
||||
log(C.ENABLED.s());
|
||||
}
|
||||
setupConfigs();
|
||||
setupDefaultFlags();
|
||||
setupDatabase();
|
||||
CommentManager.registerDefaultInboxes();
|
||||
// Tasks
|
||||
if (Settings.KILL_ROAD_MOBS) {
|
||||
IMP.runEntityTask();
|
||||
}
|
||||
// Events
|
||||
IMP.registerCommands();
|
||||
IMP.registerPlayerEvents();
|
||||
IMP.registerInventoryEvents();
|
||||
IMP.registerPlotPlusEvents();
|
||||
IMP.registerForceFieldEvents();
|
||||
IMP.registerWorldEditEvents();
|
||||
IMP.registerWorldEvents();
|
||||
if (Settings.TNT_LISTENER) {
|
||||
IMP.registerTNTListener();
|
||||
}
|
||||
if (Settings.CHUNK_PROCESSOR) {
|
||||
IMP.registerChunkProcessor();
|
||||
}
|
||||
// create UUIDWrapper
|
||||
UUIDHandler.uuidWrapper = IMP.initUUIDHandler();
|
||||
// create event util class
|
||||
EventUtil.manager = IMP.initEventUtil();
|
||||
// create Hybrid utility class
|
||||
HybridUtils.manager = IMP.initHybridUtils();
|
||||
// Inventory utility class
|
||||
InventoryUtil.manager = IMP.initInventoryUtil();
|
||||
// create setup util class
|
||||
SetupUtils.manager = IMP.initSetupUtils();
|
||||
// Set block
|
||||
BlockManager.manager = IMP.initBlockManager();
|
||||
// Set chunk
|
||||
ChunkManager.manager = IMP.initChunkManager();
|
||||
// Plot listener
|
||||
APlotListener.manager = IMP.initPlotListener();
|
||||
// Player manager
|
||||
PlayerManager.manager = IMP.initPlayerManager();
|
||||
|
||||
// PlotMe
|
||||
if (Settings.CONVERT_PLOTME || Settings.CACHE_PLOTME) {
|
||||
TaskManager.runTaskLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (IMP.initPlotMeConverter()) {
|
||||
log("&c=== IMPORTANT ===");
|
||||
log("&cTHIS MESSAGE MAY BE EXTREMELY HELPFUL IF YOU HAVE TROUBLE CONVERTING PLOTME!");
|
||||
log("&c - Make sure 'UUID.read-from-disk' is disabled (false)!");
|
||||
log("&c - Sometimes the database can be locked, deleting PlotMe.jar beforehand will fix the issue!");
|
||||
log("&c - After the conversion is finished, please set 'plotme-convert.enabled' to false in the 'settings.yml'");
|
||||
}
|
||||
}
|
||||
}, 200);
|
||||
}
|
||||
if (Settings.AUTO_CLEAR) {
|
||||
ExpireManager.runTask();
|
||||
}
|
||||
|
||||
// Copy files
|
||||
copyFile("town.template", "templates");
|
||||
copyFile("skyblock.template", "templates");
|
||||
copyFile("german.yml", "translations");
|
||||
copyFile("s_chinese_unescaped.yml", "translations");
|
||||
copyFile("s_chinese.yml", "translations");
|
||||
copyFile("italian.yml", "translations");
|
||||
showDebug();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copyFile(String file, String folder) {
|
||||
try {
|
||||
byte[] buffer = new byte[2048];
|
||||
File output = PlotSquared.IMP.getDirectory();
|
||||
File output = IMP.getDirectory();
|
||||
if (!output.exists()) {
|
||||
output.mkdirs();
|
||||
}
|
||||
@ -636,6 +719,7 @@ public class PlotSquared {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable() {
|
||||
try {
|
||||
database.closeConnection();
|
||||
@ -644,14 +728,11 @@ public class PlotSquared {
|
||||
}
|
||||
}
|
||||
|
||||
public static void log(final String message) {
|
||||
IMP.log(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setupDatabase() {
|
||||
if (Settings.DB.USE_MYSQL) {
|
||||
try {
|
||||
database = new MySQL(THIS, Settings.DB.HOST_NAME, Settings.DB.PORT, Settings.DB.DATABASE, Settings.DB.USER, Settings.DB.PASSWORD);
|
||||
database = new MySQL(this, Settings.DB.HOST_NAME, Settings.DB.PORT, Settings.DB.DATABASE, Settings.DB.USER, Settings.DB.PASSWORD);
|
||||
connection = database.openConnection();
|
||||
{
|
||||
if (DBFunc.dbManager == null) {
|
||||
@ -679,7 +760,7 @@ public class PlotSquared {
|
||||
log(C.PREFIX.s() + "MongoDB is not yet implemented");
|
||||
} else if (Settings.DB.USE_SQLITE) {
|
||||
try {
|
||||
this.database = new SQLite(THIS, IMP.getDirectory() + File.separator + Settings.DB.SQLITE_DB + ".db");
|
||||
this.database = new SQLite(this, IMP.getDirectory() + File.separator + Settings.DB.SQLITE_DB + ".db");
|
||||
connection = this.database.openConnection();
|
||||
{
|
||||
DBFunc.dbManager = new SQLManager(connection, Settings.DB.PREFIX);
|
||||
@ -705,7 +786,8 @@ public class PlotSquared {
|
||||
}
|
||||
}
|
||||
|
||||
public static void setupDefaultFlags() {
|
||||
@Override
|
||||
public void setupDefaultFlags() {
|
||||
final List<String> booleanFlags = Arrays.asList("notify-enter", "notify-leave", "item-drop", "invincible", "instabreak", "drop-protection", "forcefield", "titles", "pve", "pvp", "no-worldedit", "redstone", "keep");
|
||||
final List<String> intervalFlags = Arrays.asList("feed", "heal");
|
||||
final List<String> stringFlags = Arrays.asList("greeting", "farewell");
|
||||
@ -797,7 +879,8 @@ public class PlotSquared {
|
||||
});
|
||||
}
|
||||
|
||||
public static void setupConfig() {
|
||||
@Override
|
||||
public void setupConfig() {
|
||||
config.set("version", VERSION);
|
||||
|
||||
final Map<String, Object> options = new HashMap<>();
|
||||
@ -976,7 +1059,8 @@ public class PlotSquared {
|
||||
Settings.METRICS = config.getBoolean("metrics");
|
||||
}
|
||||
|
||||
public static void setupConfigs() {
|
||||
@Override
|
||||
public void setupConfigs() {
|
||||
final File folder = new File(IMP.getDirectory() + File.separator + "config");
|
||||
if (!folder.exists() && !folder.mkdirs()) {
|
||||
log(C.PREFIX.s() + "&cFailed to create the /plugins/config folder. Please create it manually.");
|
||||
@ -1030,7 +1114,7 @@ public class PlotSquared {
|
||||
}
|
||||
}
|
||||
|
||||
private static void setupStorage() {
|
||||
private void setupStorage() {
|
||||
storage.set("version", VERSION);
|
||||
final Map<String, Object> options = new HashMap<>();
|
||||
options.put("mysql.use", false);
|
||||
@ -1062,7 +1146,8 @@ public class PlotSquared {
|
||||
Settings.DELETE_PLOTS_ON_BAN = config.getBoolean("clear.on.ban");
|
||||
}
|
||||
|
||||
public static void showDebug() {
|
||||
@Override
|
||||
public void showDebug() {
|
||||
C.COLOR_1 = "&" + (style.getString("color.1"));
|
||||
C.COLOR_2 = "&" + (style.getString("color.2"));
|
||||
C.COLOR_3 = "&" + (style.getString("color.3"));
|
||||
@ -1085,7 +1170,7 @@ public class PlotSquared {
|
||||
}
|
||||
}
|
||||
|
||||
private static void setupStyle() {
|
||||
private void setupStyle() {
|
||||
style.set("version", VERSION);
|
||||
final Map<String, Object> o = new HashMap<>();
|
||||
o.put("color.1", C.COLOR_1.substring(1));
|
||||
@ -1099,15 +1184,18 @@ public class PlotSquared {
|
||||
}
|
||||
}
|
||||
|
||||
public static double getJavaVersion() {
|
||||
@Override
|
||||
public double getJavaVersion() {
|
||||
return Double.parseDouble(System.getProperty("java.specification.version"));
|
||||
}
|
||||
|
||||
public static Set<String> getPlotWorlds() {
|
||||
@Override
|
||||
public Set<String> getPlotWorlds() {
|
||||
return plotworlds.keySet();
|
||||
}
|
||||
|
||||
public static Collection<PlotWorld> getPlotWorldObjects() {
|
||||
|
||||
@Override
|
||||
public Collection<PlotWorld> getPlotWorldObjects() {
|
||||
return plotworlds.values();
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,85 @@
|
||||
package com.intellectualcrafters.plot;
|
||||
|
||||
import com.intellectualcrafters.plot.database.Database;
|
||||
import com.intellectualcrafters.plot.object.*;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Core of the PlotSquared Plugin
|
||||
*/
|
||||
public interface PlotSquaredMain {
|
||||
|
||||
Database getDatabase();
|
||||
|
||||
void updatePlot(Plot plot);
|
||||
|
||||
PlotWorld getPlotWorld(String world);
|
||||
|
||||
void addPlotWorld(String world, PlotWorld plotworld, PlotManager manager);
|
||||
|
||||
void removePlotWorld(String world);
|
||||
|
||||
void removePlotWorldAbs(String world);
|
||||
|
||||
HashMap<String, HashMap<PlotId, Plot>> getAllPlotsRaw();
|
||||
|
||||
void setAllPlotsRaw(LinkedHashMap<String, HashMap<PlotId, Plot>> plots);
|
||||
|
||||
Set<Plot> getPlots();
|
||||
|
||||
Set<Plot> getPlotsRaw();
|
||||
|
||||
ArrayList<Plot> sortPlots(Collection<Plot> plots);
|
||||
|
||||
ArrayList<Plot> sortPlots(Collection<Plot> plots, String priorityWorld);
|
||||
|
||||
ArrayList<Plot> sortPlotsByWorld(Collection<Plot> plots);
|
||||
|
||||
Set<Plot> getPlots(String world, String player);
|
||||
|
||||
Set<Plot> getPlots(String world, PlotPlayer player);
|
||||
|
||||
Set<Plot> getPlots(String world, UUID uuid);
|
||||
|
||||
boolean isPlotWorld(String world);
|
||||
|
||||
PlotManager getPlotManager(String world);
|
||||
|
||||
String[] getPlotWorldsString();
|
||||
|
||||
HashMap<PlotId, Plot> getPlots(String world);
|
||||
|
||||
Set<Plot> getPlots(PlotPlayer player);
|
||||
|
||||
Set<Plot> getPlots(UUID uuid);
|
||||
|
||||
boolean removePlot(String world, PlotId id, boolean callEvent);
|
||||
|
||||
void loadWorld(String world, PlotGenerator generator);
|
||||
|
||||
boolean setupPlotWorld(String world, String id);
|
||||
|
||||
Connection getConnection();
|
||||
|
||||
void copyFile(String file, String folder);
|
||||
|
||||
void disable();
|
||||
|
||||
void setupDatabase();
|
||||
|
||||
void setupDefaultFlags();
|
||||
|
||||
void setupConfig();
|
||||
|
||||
void setupConfigs();
|
||||
|
||||
void showDebug();
|
||||
|
||||
double getJavaVersion();
|
||||
|
||||
Set<String> getPlotWorlds();
|
||||
|
||||
Collection<PlotWorld> getPlotWorldObjects();
|
||||
}
|
@ -21,37 +21,27 @@
|
||||
|
||||
package com.intellectualcrafters.plot.api;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import com.intellectualcrafters.plot.PlotSquared;
|
||||
import com.intellectualcrafters.plot.commands.MainCommand;
|
||||
import com.intellectualcrafters.plot.commands.SubCommand;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.flag.AbstractFlag;
|
||||
import com.intellectualcrafters.plot.flag.FlagManager;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.PlotManager;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
import com.intellectualcrafters.plot.util.BlockManager;
|
||||
import com.intellectualcrafters.plot.util.ChunkManager;
|
||||
import com.intellectualcrafters.plot.util.ClusterManager;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.intellectualcrafters.plot.util.SchematicHandler;
|
||||
import com.intellectualcrafters.plot.object.*;
|
||||
import com.intellectualcrafters.plot.util.*;
|
||||
import com.intellectualcrafters.plot.util.bukkit.BukkitSetBlockManager;
|
||||
import com.intellectualcrafters.plot.util.bukkit.BukkitUtil;
|
||||
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
||||
import com.intellectualcrafters.plot.uuid.UUIDWrapper;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* PlotSquared API
|
||||
@ -93,7 +83,7 @@ import com.intellectualcrafters.plot.uuid.UUIDWrapper;
|
||||
* @see com.intellectualcrafters.plot.PlotSquared#getPlots()
|
||||
*/
|
||||
public Set<Plot> getAllPlots() {
|
||||
return PlotSquared.getPlots();
|
||||
return PlotSquared.getInstance().getPlots();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -104,7 +94,7 @@ import com.intellectualcrafters.plot.uuid.UUIDWrapper;
|
||||
* @return all plots that a player owns
|
||||
*/
|
||||
public Set<Plot> getPlayerPlots(final Player player) {
|
||||
return PlotSquared.getPlots(BukkitUtil.getPlayer(player));
|
||||
return PlotSquared.getInstance().getPlots(BukkitUtil.getPlayer(player));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -118,7 +108,7 @@ import com.intellectualcrafters.plot.uuid.UUIDWrapper;
|
||||
* com.intellectualcrafters.plot.object.PlotManager)
|
||||
*/
|
||||
public void addPlotWorld(final String world, final PlotWorld plotWorld, final PlotManager manager) {
|
||||
PlotSquared.addPlotWorld(world, plotWorld, manager);
|
||||
PlotSquared.getInstance().addPlotWorld(world, plotWorld, manager);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -286,7 +276,7 @@ import com.intellectualcrafters.plot.uuid.UUIDWrapper;
|
||||
* @see PlotSquared#getPlotManager(String)
|
||||
*/
|
||||
public PlotManager getPlotManager(final World world) {
|
||||
return PlotSquared.getPlotManager(world.getName());
|
||||
return PlotSquared.getInstance().getPlotManager(world.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -301,7 +291,7 @@ import com.intellectualcrafters.plot.uuid.UUIDWrapper;
|
||||
* @see com.intellectualcrafters.plot.object.PlotManager
|
||||
*/
|
||||
public PlotManager getPlotManager(final String world) {
|
||||
return PlotSquared.getPlotManager(world);
|
||||
return PlotSquared.getInstance().getPlotManager(world);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -316,7 +306,7 @@ import com.intellectualcrafters.plot.uuid.UUIDWrapper;
|
||||
* @see com.intellectualcrafters.plot.object.PlotWorld
|
||||
*/
|
||||
public PlotWorld getWorldSettings(final World world) {
|
||||
return PlotSquared.getPlotWorld(world.getName());
|
||||
return PlotSquared.getInstance().getPlotWorld(world.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -330,7 +320,7 @@ import com.intellectualcrafters.plot.uuid.UUIDWrapper;
|
||||
* @see com.intellectualcrafters.plot.object.PlotWorld
|
||||
*/
|
||||
public PlotWorld getWorldSettings(final String world) {
|
||||
return PlotSquared.getPlotWorld(world);
|
||||
return PlotSquared.getInstance().getPlotWorld(world);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -472,7 +462,7 @@ import com.intellectualcrafters.plot.uuid.UUIDWrapper;
|
||||
*/
|
||||
public Plot[] getPlots(final World world, final Player plr, final boolean just_owner) {
|
||||
final ArrayList<Plot> pPlots = new ArrayList<>();
|
||||
for (final Plot plot : PlotSquared.getPlots(world.getName()).values()) {
|
||||
for (final Plot plot : PlotSquared.getInstance().getPlots(world.getName()).values()) {
|
||||
if (just_owner) {
|
||||
if ((plot.owner != null) && (plot.owner.equals(UUIDHandler.getUUID(BukkitUtil.getPlayer(plr))))) {
|
||||
pPlots.add(plot);
|
||||
@ -497,7 +487,7 @@ import com.intellectualcrafters.plot.uuid.UUIDWrapper;
|
||||
* @see com.intellectualcrafters.plot.object.Plot
|
||||
*/
|
||||
public Plot[] getPlots(final World world) {
|
||||
Collection<Plot> plots = PlotSquared.getPlots(world.getName()).values();
|
||||
Collection<Plot> plots = PlotSquared.getInstance().getPlots(world.getName()).values();
|
||||
return plots.toArray(new Plot[plots.size()]);
|
||||
}
|
||||
|
||||
@ -509,7 +499,7 @@ import com.intellectualcrafters.plot.uuid.UUIDWrapper;
|
||||
* @see com.intellectualcrafters.plot.PlotSquared#getPlotWorlds()
|
||||
*/
|
||||
public String[] getPlotWorlds() {
|
||||
Set<String> worlds = PlotSquared.getPlotWorlds();
|
||||
Set<String> worlds = PlotSquared.getInstance().getPlotWorlds();
|
||||
return worlds.toArray(new String[worlds.size()]);
|
||||
}
|
||||
|
||||
@ -523,7 +513,7 @@ import com.intellectualcrafters.plot.uuid.UUIDWrapper;
|
||||
* @see com.intellectualcrafters.plot.PlotSquared#isPlotWorld(String)
|
||||
*/
|
||||
public boolean isPlotWorld(final World world) {
|
||||
return PlotSquared.isPlotWorld(world.getName());
|
||||
return PlotSquared.getInstance().isPlotWorld(world.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -652,7 +642,7 @@ import com.intellectualcrafters.plot.uuid.UUIDWrapper;
|
||||
* @see com.intellectualcrafters.plot.object.Plot
|
||||
*/
|
||||
public Set<Plot> getPlayerPlots(final World world, final Player player) {
|
||||
return PlotSquared.getPlots(world.getName(), BukkitUtil.getPlayer(player));
|
||||
return PlotSquared.getInstance().getPlots(world.getName(), BukkitUtil.getPlayer(player));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -662,7 +652,6 @@ import com.intellectualcrafters.plot.uuid.UUIDWrapper;
|
||||
*
|
||||
* @return the number of allowed plots
|
||||
*
|
||||
* @see com.intellectualcrafters.plot.util.MainUtil#getAllowedPlots(PlotPlayer, int)
|
||||
*/
|
||||
public int getAllowedPlots(final Player player) {
|
||||
PlotPlayer pp = BukkitUtil.getPlayer(player);
|
||||
|
@ -20,8 +20,6 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import com.intellectualcrafters.plot.PlotSquared;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
@ -33,6 +31,8 @@ import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class Add extends SubCommand {
|
||||
public Add() {
|
||||
super(Command.ADD, "Allow a user to build while you are online", "add <player>", CommandCategory.ACTIONS, true);
|
||||
@ -77,7 +77,7 @@ public class Add extends SubCommand {
|
||||
DBFunc.removeTrusted(loc.getWorld(), plot, uuid);
|
||||
}
|
||||
if (plot.denied.contains(uuid)) {
|
||||
if (plot.members.size() + plot.trusted.size() >= PlotSquared.getPlotWorld(plot.world).MAX_PLOT_MEMBERS) {
|
||||
if (plot.members.size() + plot.trusted.size() >= PlotSquared.getInstance().getPlotWorld(plot.world).MAX_PLOT_MEMBERS) {
|
||||
MainUtil.sendMessage(plr, C.PLOT_MAX_MEMBERS);
|
||||
return false;
|
||||
}
|
||||
@ -91,7 +91,7 @@ public class Add extends SubCommand {
|
||||
MainUtil.sendMessage(plr, C.ALREADY_ADDED);
|
||||
return false;
|
||||
}
|
||||
if (plot.members.size() + plot.trusted.size() >= PlotSquared.getPlotWorld(plot.world).MAX_PLOT_MEMBERS) {
|
||||
if (plot.members.size() + plot.trusted.size() >= PlotSquared.getInstance().getPlotWorld(plot.world).MAX_PLOT_MEMBERS) {
|
||||
MainUtil.sendMessage(plr, C.PLOT_MAX_MEMBERS);
|
||||
return false;
|
||||
}
|
||||
|
@ -23,12 +23,7 @@ package com.intellectualcrafters.plot.commands;
|
||||
import com.intellectualcrafters.plot.PlotSquared;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotCluster;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
import com.intellectualcrafters.plot.object.*;
|
||||
import com.intellectualcrafters.plot.util.ClusterManager;
|
||||
import com.intellectualcrafters.plot.util.EconHandler;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
@ -75,11 +70,11 @@ public class Auto extends SubCommand {
|
||||
int size_x = 1;
|
||||
int size_z = 1;
|
||||
String schematic = "";
|
||||
if (PlotSquared.getPlotWorlds().size() == 1) {
|
||||
world = PlotSquared.getPlotWorlds().iterator().next();
|
||||
if (PlotSquared.getInstance().getPlotWorlds().size() == 1) {
|
||||
world = PlotSquared.getInstance().getPlotWorlds().iterator().next();
|
||||
} else {
|
||||
world = plr.getLocation().getWorld();
|
||||
if (!PlotSquared.isPlotWorld(world)) {
|
||||
if (!PlotSquared.getInstance().isPlotWorld(world)) {
|
||||
MainUtil.sendMessage(plr, C.NOT_IN_PLOT_WORLD);
|
||||
return false;
|
||||
}
|
||||
@ -127,7 +122,7 @@ public class Auto extends SubCommand {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
final PlotWorld pWorld = PlotSquared.getPlotWorld(world);
|
||||
final PlotWorld pWorld = PlotSquared.getInstance().getPlotWorld(world);
|
||||
if ((EconHandler.manager != null) && pWorld.USE_ECONOMY) {
|
||||
double cost = pWorld.PLOT_PRICE;
|
||||
cost = (size_x * size_z) * cost;
|
||||
@ -153,7 +148,7 @@ public class Auto extends SubCommand {
|
||||
// }
|
||||
}
|
||||
final String worldname = world;
|
||||
final PlotWorld plotworld = PlotSquared.getPlotWorld(worldname);
|
||||
final PlotWorld plotworld = PlotSquared.getInstance().getPlotWorld(worldname);
|
||||
if (plotworld.TYPE == 2) {
|
||||
final Location loc = plr.getLocation();
|
||||
final Plot plot = MainUtil.getPlot(new Location(worldname, loc.getX(), loc.getY(), loc.getZ()));
|
||||
@ -204,7 +199,7 @@ public class Auto extends SubCommand {
|
||||
MainUtil.lastPlot.put(worldname, start);
|
||||
if (lastPlot) {
|
||||
}
|
||||
if ((PlotSquared.getPlots(worldname).get(start) != null) && (PlotSquared.getPlots(worldname).get(start).owner != null)) {
|
||||
if ((PlotSquared.getInstance().getPlots(worldname).get(start) != null) && (PlotSquared.getInstance().getPlots(worldname).get(start).owner != null)) {
|
||||
continue;
|
||||
} else {
|
||||
lastPlot = false;
|
||||
|
@ -26,12 +26,7 @@ import com.intellectualcrafters.plot.config.Settings;
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
import com.intellectualcrafters.plot.flag.Flag;
|
||||
import com.intellectualcrafters.plot.flag.FlagManager;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotHandler;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
import com.intellectualcrafters.plot.object.*;
|
||||
import com.intellectualcrafters.plot.util.EconHandler;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
||||
@ -51,7 +46,7 @@ public class Buy extends SubCommand {
|
||||
}
|
||||
final Location loc = plr.getLocation();
|
||||
final String world = loc.getWorld();
|
||||
if (!PlotSquared.isPlotWorld(world)) {
|
||||
if (!PlotSquared.getInstance().isPlotWorld(world)) {
|
||||
return sendMessage(plr, C.NOT_IN_PLOT_WORLD);
|
||||
}
|
||||
Plot plot;
|
||||
@ -88,7 +83,7 @@ public class Buy extends SubCommand {
|
||||
final PlotId id = plot.id;
|
||||
final PlotId id2 = MainUtil.getTopPlot(plot).id;
|
||||
final int size = MainUtil.getPlotSelectionIds(id, id2).size();
|
||||
final PlotWorld plotworld = PlotSquared.getPlotWorld(world);
|
||||
final PlotWorld plotworld = PlotSquared.getInstance().getPlotWorld(world);
|
||||
if (plotworld.USE_ECONOMY) {
|
||||
price += plotworld.PLOT_PRICE * size;
|
||||
initPrice += plotworld.SELL_PRICE * size;
|
||||
|
@ -13,7 +13,7 @@ public class Chat extends SubCommand {
|
||||
@Override
|
||||
public boolean execute(PlotPlayer plr, String... args) {
|
||||
final String world = plr.getLocation().getWorld();
|
||||
if (!PlotSquared.isPlotWorld(world)) {
|
||||
if (!PlotSquared.getInstance().isPlotWorld(world)) {
|
||||
return !sendMessage(plr, C.NOT_IN_PLOT_WORLD);
|
||||
}
|
||||
boolean enable = !(plr.getMeta("chat") != null && (Boolean) plr.getMeta("chat"));
|
||||
@ -24,7 +24,7 @@ public class Chat extends SubCommand {
|
||||
enable = false;
|
||||
}
|
||||
}
|
||||
final PlotWorld plotworld = PlotSquared.getPlotWorld(world);
|
||||
final PlotWorld plotworld = PlotSquared.getInstance().getPlotWorld(world);
|
||||
if (!enable && plotworld.PLOT_CHAT) {
|
||||
return !sendMessage(plr, C.PLOT_CHAT_FORCED);
|
||||
}
|
||||
|
@ -27,11 +27,7 @@ import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
import com.intellectualcrafters.plot.util.EconHandler;
|
||||
import com.intellectualcrafters.plot.util.EventUtil;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.intellectualcrafters.plot.util.SchematicHandler;
|
||||
import com.intellectualcrafters.plot.util.*;
|
||||
import com.intellectualcrafters.plot.util.SchematicHandler.Schematic;
|
||||
|
||||
/**
|
||||
@ -60,8 +56,8 @@ public class Claim extends SubCommand {
|
||||
MainUtil.teleportPlayer(player, loc, plot);
|
||||
}
|
||||
final String world = plot.world;
|
||||
final PlotWorld plotworld = PlotSquared.getPlotWorld(world);
|
||||
final Plot plot2 = PlotSquared.getPlots(world).get(plot.id);
|
||||
final PlotWorld plotworld = PlotSquared.getInstance().getPlotWorld(world);
|
||||
final Plot plot2 = PlotSquared.getInstance().getPlots(world).get(plot.id);
|
||||
if (plotworld.SCHEMATIC_ON_CLAIM) {
|
||||
Schematic sch;
|
||||
if (schematic.equals("")) {
|
||||
@ -74,7 +70,7 @@ public class Claim extends SubCommand {
|
||||
}
|
||||
SchematicHandler.manager.paste(sch, plot2, 0, 0);
|
||||
}
|
||||
PlotSquared.getPlotManager(world).claimPlot(plotworld, plot);
|
||||
PlotSquared.getInstance().getPlotManager(world).claimPlot(plotworld, plot);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@ -97,7 +93,7 @@ public class Claim extends SubCommand {
|
||||
if (!MainUtil.canClaim(plr, plot)) {
|
||||
return sendMessage(plr, C.PLOT_IS_CLAIMED);
|
||||
}
|
||||
final PlotWorld world = PlotSquared.getPlotWorld(plot.world);
|
||||
final PlotWorld world = PlotSquared.getInstance().getPlotWorld(plot.world);
|
||||
if ((EconHandler.manager != null) && world.USE_ECONOMY) {
|
||||
final double cost = world.PLOT_PRICE;
|
||||
if (cost > 0d) {
|
||||
|
@ -20,8 +20,6 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import com.intellectualcrafters.plot.PlotSquared;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
@ -35,6 +33,8 @@ import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public class Clear extends SubCommand {
|
||||
public Clear() {
|
||||
super(Command.CLEAR, "Clear a plot", "clear", CommandCategory.ACTIONS, false);
|
||||
@ -52,7 +52,7 @@ public class Clear extends SubCommand {
|
||||
if (id == null) {
|
||||
PlotSquared.log("Invalid Plot ID: " + args[0]);
|
||||
} else {
|
||||
if (!PlotSquared.isPlotWorld(world)) {
|
||||
if (!PlotSquared.getInstance().isPlotWorld(world)) {
|
||||
PlotSquared.log("Invalid plot world: " + world);
|
||||
} else {
|
||||
final Plot plot = MainUtil.getPlot(world, id);
|
||||
@ -84,7 +84,7 @@ public class Clear extends SubCommand {
|
||||
PlotId id = PlotId.fromString(args[0]);
|
||||
if (id == null) {
|
||||
if (args[1].equalsIgnoreCase("mine")) {
|
||||
Set<Plot> plots = PlotSquared.getPlots(plr);
|
||||
Set<Plot> plots = PlotSquared.getInstance().getPlots(plr);
|
||||
if (plots.size() == 0) {
|
||||
MainUtil.sendMessage(plr, C.NO_PLOTS);
|
||||
return false;
|
||||
|
@ -20,29 +20,21 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.intellectualcrafters.plot.PlotSquared;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
import com.intellectualcrafters.plot.generator.AugmentedPopulator;
|
||||
import com.intellectualcrafters.plot.generator.HybridGen;
|
||||
import com.intellectualcrafters.plot.object.BlockLoc;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotCluster;
|
||||
import com.intellectualcrafters.plot.object.PlotClusterId;
|
||||
import com.intellectualcrafters.plot.object.PlotGenerator;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
import com.intellectualcrafters.plot.object.*;
|
||||
import com.intellectualcrafters.plot.util.ClusterManager;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.UUID;
|
||||
|
||||
public class Cluster extends SubCommand {
|
||||
public Cluster() {
|
||||
super(Command.CLUSTER, "Manage a plot cluster", "cluster", CommandCategory.ACTIONS, true);
|
||||
@ -129,17 +121,17 @@ public class Cluster extends SubCommand {
|
||||
}
|
||||
ClusterManager.clusters.get(world).add(cluster);
|
||||
// Add any existing plots to the current cluster
|
||||
for (final Plot plot : PlotSquared.getPlots(plr.getLocation().getWorld()).values()) {
|
||||
for (final Plot plot : PlotSquared.getInstance().getPlots(plr.getLocation().getWorld()).values()) {
|
||||
final PlotCluster current = ClusterManager.getCluster(plot);
|
||||
if (cluster.equals(current) && !cluster.isAdded(plot.owner)) {
|
||||
cluster.invited.add(plot.owner);
|
||||
DBFunc.setInvited(world, cluster, plot.owner);
|
||||
}
|
||||
}
|
||||
PlotWorld plotworld = PlotSquared.getPlotWorld(world);
|
||||
PlotWorld plotworld = PlotSquared.getInstance().getPlotWorld(world);
|
||||
if (plotworld == null) {
|
||||
PlotSquared.config.createSection("worlds." + world);
|
||||
PlotSquared.loadWorld(world, null);
|
||||
PlotSquared.getInstance().loadWorld(world, null);
|
||||
}
|
||||
else {
|
||||
final String gen_string = PlotSquared.config.getString("worlds." + world + "." + "generator.plugin");
|
||||
@ -185,10 +177,10 @@ public class Cluster extends SubCommand {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
final PlotWorld plotworld = PlotSquared.getPlotWorld(plr.getLocation().getWorld());
|
||||
final PlotWorld plotworld = PlotSquared.getInstance().getPlotWorld(plr.getLocation().getWorld());
|
||||
if (plotworld.TYPE == 2) {
|
||||
final ArrayList<Plot> toRemove = new ArrayList<>();
|
||||
for (final Plot plot : PlotSquared.getPlots(plr.getLocation().getWorld()).values()) {
|
||||
for (final Plot plot : PlotSquared.getInstance().getPlots(plr.getLocation().getWorld()).values()) {
|
||||
final PlotCluster other = ClusterManager.getCluster(plot);
|
||||
if (cluster.equals(other)) {
|
||||
toRemove.add(plot);
|
||||
@ -369,7 +361,7 @@ public class Cluster extends SubCommand {
|
||||
if (player != null) {
|
||||
MainUtil.sendMessage(player, C.CLUSTER_REMOVED, cluster.getName());
|
||||
}
|
||||
for (final Plot plot : PlotSquared.getPlots(plr.getLocation().getWorld(), uuid)) {
|
||||
for (final Plot plot : PlotSquared.getInstance().getPlots(plr.getLocation().getWorld(), uuid)) {
|
||||
final PlotCluster current = ClusterManager.getCluster(plot);
|
||||
if ((current != null) && current.equals(cluster)) {
|
||||
final String world = plr.getLocation().getWorld();
|
||||
@ -419,7 +411,7 @@ public class Cluster extends SubCommand {
|
||||
cluster.invited.remove(uuid);
|
||||
DBFunc.removeInvited(cluster, uuid);
|
||||
MainUtil.sendMessage(plr, C.CLUSTER_REMOVED, cluster.getName());
|
||||
for (final Plot plot : PlotSquared.getPlots(plr.getLocation().getWorld(), uuid)) {
|
||||
for (final Plot plot : PlotSquared.getInstance().getPlots(plr.getLocation().getWorld(), uuid)) {
|
||||
final PlotCluster current = ClusterManager.getCluster(plot);
|
||||
if ((current != null) && current.equals(cluster)) {
|
||||
final String world = plr.getLocation().getWorld();
|
||||
|
@ -20,14 +20,6 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
import com.intellectualcrafters.plot.PlotSquared;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
@ -35,6 +27,10 @@ import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.BlockManager;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.Set;
|
||||
|
||||
public class Condense extends SubCommand {
|
||||
public static boolean TASK = false;
|
||||
@ -43,6 +39,10 @@ public class Condense extends SubCommand {
|
||||
super("condense", "plots.admin", "Condense a plotworld", "condense", "", CommandCategory.DEBUG, false);
|
||||
}
|
||||
|
||||
public static void sendMessage(final String message) {
|
||||
PlotSquared.log("&3PlotSquared -> Plot condense&8: &7" + message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(final PlotPlayer plr, final String... args) {
|
||||
if (plr != null) {
|
||||
@ -54,7 +54,7 @@ public class Condense extends SubCommand {
|
||||
return false;
|
||||
}
|
||||
final String worldname = args[0];
|
||||
if (!BlockManager.manager.isWorld(worldname) || !PlotSquared.isPlotWorld(worldname)) {
|
||||
if (!BlockManager.manager.isWorld(worldname) || !PlotSquared.getInstance().isPlotWorld(worldname)) {
|
||||
MainUtil.sendMessage(plr, "INVALID WORLD");
|
||||
return false;
|
||||
}
|
||||
@ -199,8 +199,4 @@ public class Condense extends SubCommand {
|
||||
}
|
||||
return outside;
|
||||
}
|
||||
|
||||
public static void sendMessage(final String message) {
|
||||
PlotSquared.log("&3PlotSquared -> Plot condense&8: &7" + message);
|
||||
}
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ public class CreateRoadSchematic extends SubCommand {
|
||||
if (plot == null) {
|
||||
return sendMessage(player, C.NOT_IN_PLOT);
|
||||
}
|
||||
if (!(PlotSquared.getPlotWorld(loc.getWorld()) instanceof HybridPlotWorld)) {
|
||||
if (!(PlotSquared.getInstance().getPlotWorld(loc.getWorld()) instanceof HybridPlotWorld)) {
|
||||
return sendMessage(player, C.NOT_IN_PLOT_WORLD);
|
||||
}
|
||||
HybridUtils.manager.setupRoadSchematic(plot);
|
||||
|
@ -1,10 +1,5 @@
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.intellectualcrafters.plot.PlotSquared;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
import com.intellectualcrafters.plot.database.MySQL;
|
||||
@ -16,6 +11,11 @@ import com.intellectualcrafters.plot.util.StringComparison;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Created 2014-11-15 for PlotSquared
|
||||
*
|
||||
@ -41,7 +41,7 @@ public class Database extends SubCommand {
|
||||
}
|
||||
|
||||
public static void insertPlots(final SQLManager manager, final UUID requester, final Connection c) {
|
||||
final java.util.Set<Plot> plots = PlotSquared.getPlots();
|
||||
final java.util.Set<Plot> plots = PlotSquared.getInstance().getPlots();
|
||||
TaskManager.runTaskAsync(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
@ -51,7 +51,7 @@ public class Debug extends SubCommand {
|
||||
}
|
||||
{
|
||||
final StringBuilder worlds = new StringBuilder("");
|
||||
for (final String world : PlotSquared.getPlotWorlds()) {
|
||||
for (final String world : PlotSquared.getInstance().getPlotWorlds()) {
|
||||
worlds.append(world).append(" ");
|
||||
}
|
||||
information.append(header);
|
||||
@ -61,7 +61,7 @@ public class Debug extends SubCommand {
|
||||
information.append(getLine(line, "TPS Percentage", (int) Lag.getFullPercentage() + "%"));
|
||||
information.append(getSection(section, "PlotWorld"));
|
||||
information.append(getLine(line, "Plot Worlds", worlds));
|
||||
information.append(getLine(line, "Owned Plots", PlotSquared.getPlots().size()));
|
||||
information.append(getLine(line, "Owned Plots", PlotSquared.getInstance().getPlots().size()));
|
||||
information.append(getSection(section, "Messages"));
|
||||
information.append(getLine(line, "Total Messages", C.values().length));
|
||||
information.append(getLine(line, "View all captions", "/plot debug msg"));
|
||||
|
@ -20,27 +20,20 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.google.common.collect.BiMap;
|
||||
import com.intellectualcrafters.plot.PlotSquared;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
import com.intellectualcrafters.plot.object.ChunkLoc;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.PlotManager;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
import com.intellectualcrafters.plot.object.StringWrapper;
|
||||
import com.intellectualcrafters.plot.object.*;
|
||||
import com.intellectualcrafters.plot.util.BlockManager;
|
||||
import com.intellectualcrafters.plot.util.ChunkManager;
|
||||
import com.intellectualcrafters.plot.util.EventUtil;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author Citymonstret
|
||||
*/
|
||||
@ -73,7 +66,7 @@ public class DebugClaimTest extends SubCommand {
|
||||
return !MainUtil.sendMessage(null, "If you accidentally delete your database, this command will attempt to restore all plots based on the data from the plot signs. \n\n&cMissing world arg /plot debugclaimtest {world} {PlotId min} {PlotId max}");
|
||||
}
|
||||
final String world = args[0];
|
||||
if (!BlockManager.manager.isWorld(world) || !PlotSquared.isPlotWorld(world)) {
|
||||
if (!BlockManager.manager.isWorld(world) || !PlotSquared.getInstance().isPlotWorld(world)) {
|
||||
return !MainUtil.sendMessage(null, "&cInvalid plot world!");
|
||||
}
|
||||
PlotId min, max;
|
||||
@ -87,12 +80,12 @@ public class DebugClaimTest extends SubCommand {
|
||||
}
|
||||
MainUtil.sendMessage(null, "&3Sign Block&8->&3PlotSquared&8: &7Beginning sign to plot conversion. This may take a while...");
|
||||
MainUtil.sendMessage(null, "&3Sign Block&8->&3PlotSquared&8: Found an excess of 250,000 chunks. Limiting search radius... (~3.8 min)");
|
||||
final PlotManager manager = PlotSquared.getPlotManager(world);
|
||||
final PlotWorld plotworld = PlotSquared.getPlotWorld(world);
|
||||
final PlotManager manager = PlotSquared.getInstance().getPlotManager(world);
|
||||
final PlotWorld plotworld = PlotSquared.getInstance().getPlotWorld(world);
|
||||
final ArrayList<Plot> plots = new ArrayList<>();
|
||||
for (final PlotId id : MainUtil.getPlotSelectionIds(min, max)) {
|
||||
final Plot plot = MainUtil.getPlot(world, id);
|
||||
final boolean contains = PlotSquared.getPlots(world).containsKey(plot.id);
|
||||
final boolean contains = PlotSquared.getInstance().getPlots(world).containsKey(plot.id);
|
||||
if (contains) {
|
||||
MainUtil.sendMessage(null, " - &cDB Already contains: " + plot.id);
|
||||
continue;
|
||||
@ -141,7 +134,7 @@ public class DebugClaimTest extends SubCommand {
|
||||
}
|
||||
});
|
||||
for (final Plot plot : plots) {
|
||||
PlotSquared.updatePlot(plot);
|
||||
PlotSquared.getInstance().updatePlot(plot);
|
||||
}
|
||||
MainUtil.sendMessage(null, "&3Sign Block&8->&3PlotSquared&8: &7Complete!");
|
||||
} else {
|
||||
|
@ -49,7 +49,7 @@ public class DebugClear extends SubCommand {
|
||||
if (id == null) {
|
||||
PlotSquared.log("Invalid Plot ID: " + args[0]);
|
||||
} else {
|
||||
if (!PlotSquared.isPlotWorld(world) || !(PlotSquared.getPlotWorld(world) instanceof SquarePlotWorld)) {
|
||||
if (!PlotSquared.getInstance().isPlotWorld(world) || !(PlotSquared.getInstance().getPlotWorld(world) instanceof SquarePlotWorld)) {
|
||||
PlotSquared.log("Invalid plot world: " + world);
|
||||
} else {
|
||||
final Plot plot = MainUtil.getPlot(world, id);
|
||||
@ -79,7 +79,7 @@ public class DebugClear extends SubCommand {
|
||||
}
|
||||
final Location loc = plr.getLocation();
|
||||
final Plot plot = MainUtil.getPlot(loc);
|
||||
if ((plot == null) || !(PlotSquared.getPlotWorld(loc.getWorld()) instanceof SquarePlotWorld)) {
|
||||
if ((plot == null) || !(PlotSquared.getInstance().getPlotWorld(loc.getWorld()) instanceof SquarePlotWorld)) {
|
||||
return sendMessage(plr, C.NOT_IN_PLOT);
|
||||
}
|
||||
if (!MainUtil.getTopPlot(plot).equals(MainUtil.getBottomPlot(plot))) {
|
||||
|
@ -20,38 +20,26 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.PrintWriter;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import com.intellectualcrafters.plot.PlotSquared;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.flag.Flag;
|
||||
import com.intellectualcrafters.plot.flag.FlagManager;
|
||||
import com.intellectualcrafters.plot.flag.FlagValue;
|
||||
import com.intellectualcrafters.plot.flag.FlagValue.IntegerListValue;
|
||||
import com.intellectualcrafters.plot.generator.BukkitHybridUtils;
|
||||
import com.intellectualcrafters.plot.generator.HybridUtils;
|
||||
import com.intellectualcrafters.plot.object.ChunkLoc;
|
||||
import com.intellectualcrafters.plot.object.OfflinePlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotAnalysis;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||
import com.intellectualcrafters.plot.object.*;
|
||||
import com.intellectualcrafters.plot.util.BlockManager;
|
||||
import com.intellectualcrafters.plot.util.ChunkManager;
|
||||
import com.intellectualcrafters.plot.util.ExpireManager;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.PrintWriter;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.*;
|
||||
|
||||
public class DebugExec extends SubCommand {
|
||||
public DebugExec() {
|
||||
@ -60,7 +48,7 @@ public class DebugExec extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean execute(final PlotPlayer player, final String... args) {
|
||||
final List<String> allowed_params = Arrays.asList(new String[] { "analyze", "reset-modified", "stop-expire", "start-expire", "show-expired", "update-expired", "seen", "trim-check" });
|
||||
final List<String> allowed_params = Arrays.asList("analyze", "reset-modified", "stop-expire", "start-expire", "show-expired", "update-expired", "seen", "trim-check");
|
||||
if (args.length > 0) {
|
||||
final String arg = args[0].toLowerCase();
|
||||
switch (arg) {
|
||||
@ -70,13 +58,13 @@ public class DebugExec extends SubCommand {
|
||||
@Override
|
||||
public void run() {
|
||||
List<Double> result = new ArrayList<>();
|
||||
result.add((double) (Math.round(value.air * 100) / 100d));
|
||||
result.add((double) (Math.round(value.changes * 100) / 100d));
|
||||
result.add((double) (Math.round(value.complexity * 100) / 100d));
|
||||
result.add((double) (Math.round(value.data * 100) / 100d));
|
||||
result.add((double) (Math.round(value.faces * 100) / 100d));
|
||||
result.add((double) (Math.round(value.air * 100) / 100d));
|
||||
result.add((double) (Math.round(value.variety * 100) / 100d));
|
||||
result.add(Math.round(value.air * 100) / 100d);
|
||||
result.add(Math.round(value.changes * 100) / 100d);
|
||||
result.add(Math.round(value.complexity * 100) / 100d);
|
||||
result.add(Math.round(value.data * 100) / 100d);
|
||||
result.add(Math.round(value.faces * 100) / 100d);
|
||||
result.add(Math.round(value.air * 100) / 100d);
|
||||
result.add(Math.round(value.variety * 100) / 100d);
|
||||
Flag flag = new Flag(FlagManager.getFlag("analysis"), result);
|
||||
FlagManager.addPlotFlag(plot, flag);
|
||||
}
|
||||
@ -98,7 +86,7 @@ public class DebugExec extends SubCommand {
|
||||
return false;
|
||||
}
|
||||
String flag = args[1];
|
||||
for (Plot plot : PlotSquared.getPlots()) {
|
||||
for (Plot plot : PlotSquared.getInstance().getPlots()) {
|
||||
if (FlagManager.getPlotFlag(plot, flag) != null) {
|
||||
FlagManager.removePlotFlag(plot, flag);
|
||||
}
|
||||
@ -111,7 +99,7 @@ public class DebugExec extends SubCommand {
|
||||
return false;
|
||||
}
|
||||
boolean result;
|
||||
if (!PlotSquared.isPlotWorld(args[1])) {
|
||||
if (!PlotSquared.getInstance().isPlotWorld(args[1])) {
|
||||
MainUtil.sendMessage(player, C.NOT_VALID_PLOT_WORLD, args[1]);
|
||||
return false;
|
||||
}
|
||||
@ -138,7 +126,7 @@ public class DebugExec extends SubCommand {
|
||||
while (BukkitHybridUtils.chunks.size() > 0) {
|
||||
ChunkLoc chunk = BukkitHybridUtils.chunks.get(0);
|
||||
BukkitHybridUtils.chunks.remove(0);
|
||||
((BukkitHybridUtils)(HybridUtils.manager)).regenerateRoad(BukkitHybridUtils.world, chunk, 0);
|
||||
HybridUtils.manager.regenerateRoad(BukkitHybridUtils.world, chunk, 0);
|
||||
ChunkManager.manager.unloadChunk(BukkitHybridUtils.world, chunk);
|
||||
}
|
||||
PlotSquared.log("&cCancelled!");
|
||||
@ -209,7 +197,7 @@ public class DebugExec extends SubCommand {
|
||||
return MainUtil.sendMessage(player, "&7 - Run after plot expiry has run");
|
||||
}
|
||||
final String world = args[1];
|
||||
if (!BlockManager.manager.isWorld(world) || !PlotSquared.isPlotWorld(args[1])) {
|
||||
if (!BlockManager.manager.isWorld(world) || !PlotSquared.getInstance().isPlotWorld(args[1])) {
|
||||
return MainUtil.sendMessage(player, "Invalid world: " + args[1]);
|
||||
}
|
||||
final ArrayList<ChunkLoc> empty = new ArrayList<>();
|
||||
|
@ -20,16 +20,9 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import com.intellectualcrafters.plot.PlotSquared;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
import com.intellectualcrafters.plot.flag.AbstractFlag;
|
||||
import com.intellectualcrafters.plot.flag.Flag;
|
||||
import com.intellectualcrafters.plot.flag.FlagManager;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
@ -37,6 +30,10 @@ import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.BlockManager;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
public class DebugFixFlags extends SubCommand {
|
||||
public DebugFixFlags() {
|
||||
super(Command.DEBUGFIXFLAGS, "Attempt to fix all flags for a world", "debugclear", CommandCategory.DEBUG, false);
|
||||
@ -53,12 +50,12 @@ public class DebugFixFlags extends SubCommand {
|
||||
return false;
|
||||
}
|
||||
final String world = args[0];
|
||||
if (!BlockManager.manager.isWorld(world) || !PlotSquared.isPlotWorld(world)) {
|
||||
if (!BlockManager.manager.isWorld(world) || !PlotSquared.getInstance().isPlotWorld(world)) {
|
||||
MainUtil.sendMessage(plr, C.NOT_VALID_PLOT_WORLD, args[0]);
|
||||
return false;
|
||||
}
|
||||
MainUtil.sendMessage(plr, "&8--- &6Starting task &8 ---");
|
||||
for (final Plot plot : PlotSquared.getPlots(world).values()) {
|
||||
for (final Plot plot : PlotSquared.getInstance().getPlots(world).values()) {
|
||||
final HashMap<String, Flag> flags = plot.settings.flags;
|
||||
Iterator<Entry<String, Flag>> i = flags.entrySet().iterator();
|
||||
boolean changed = false;
|
||||
|
@ -38,7 +38,7 @@ public class DebugRoadRegen extends SubCommand {
|
||||
public boolean execute(final PlotPlayer player, final String... args) {
|
||||
final Location loc = player.getLocation();
|
||||
final String world = loc.getWorld();
|
||||
if (!(PlotSquared.getPlotWorld(world) instanceof HybridPlotWorld)) {
|
||||
if (!(PlotSquared.getInstance().getPlotWorld(world) instanceof HybridPlotWorld)) {
|
||||
return sendMessage(player, C.NOT_IN_PLOT_WORLD);
|
||||
}
|
||||
final ChunkLoc chunk = new ChunkLoc(loc.getX() >> 4, loc.getZ() >> 4);
|
||||
|
@ -20,14 +20,14 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.intellectualcrafters.plot.PlotSquared;
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* @author Citymonstret
|
||||
*/
|
||||
@ -40,7 +40,7 @@ public class DebugSaveTest extends SubCommand {
|
||||
public boolean execute(final PlotPlayer plr, final String... args) {
|
||||
if (plr == null) {
|
||||
final ArrayList<Plot> plots = new ArrayList<Plot>();
|
||||
plots.addAll(PlotSquared.getPlots());
|
||||
plots.addAll(PlotSquared.getInstance().getPlots());
|
||||
MainUtil.sendMessage(null, "&6Starting `DEBUGSAVETEST`");
|
||||
DBFunc.createPlotsAndData(plots, new Runnable() {
|
||||
@Override
|
||||
|
@ -20,16 +20,6 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FilenameFilter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import com.intellectualcrafters.plot.PlotSquared;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
@ -47,6 +37,15 @@ import com.intellectualcrafters.plot.uuid.DefaultUUIDWrapper;
|
||||
import com.intellectualcrafters.plot.uuid.LowerOfflineUUIDWrapper;
|
||||
import com.intellectualcrafters.plot.uuid.OfflineUUIDWrapper;
|
||||
import com.intellectualcrafters.plot.uuid.UUIDWrapper;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FilenameFilter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.UUID;
|
||||
|
||||
public class DebugUUID extends SubCommand {
|
||||
public DebugUUID() {
|
||||
@ -215,8 +214,8 @@ public class DebugUUID extends SubCommand {
|
||||
UUIDHandler.uuidWrapper = newWrapper;
|
||||
|
||||
MainUtil.sendConsoleMessage("&7 - Updating plot objects");
|
||||
|
||||
for (Plot plot : PlotSquared.getPlotsRaw()) {
|
||||
|
||||
for (Plot plot : PlotSquared.getInstance().getPlotsRaw()) {
|
||||
UUID value = uCMap.get(plot.owner);
|
||||
if (value != null) {
|
||||
plot.owner = value;
|
||||
@ -236,13 +235,13 @@ public class DebugUUID extends SubCommand {
|
||||
database.createTables(Settings.DB.USE_MYSQL ? "mysql" : "sqlite");
|
||||
if (!result) {
|
||||
MainUtil.sendConsoleMessage("&cConversion failed! Attempting recovery");
|
||||
for (Plot plot : PlotSquared.getPlots()) {
|
||||
for (Plot plot : PlotSquared.getInstance().getPlots()) {
|
||||
UUID value = uCReverse.get(plot.owner);
|
||||
if (value != null) {
|
||||
plot.owner = value;
|
||||
}
|
||||
}
|
||||
database.createPlotsAndData(new ArrayList<>(PlotSquared.getPlots()), new Runnable() {
|
||||
database.createPlotsAndData(new ArrayList<>(PlotSquared.getInstance().getPlots()), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
MainUtil.sendMessage(null, "&6Recovery was successful!");
|
||||
@ -280,7 +279,7 @@ public class DebugUUID extends SubCommand {
|
||||
TaskManager.runTaskAsync(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ArrayList<Plot> plots = new ArrayList<>(PlotSquared.getPlots());
|
||||
ArrayList<Plot> plots = new ArrayList<>(PlotSquared.getInstance().getPlots());
|
||||
database.createPlotsAndData(plots, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
@ -28,11 +28,7 @@ import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
import com.intellectualcrafters.plot.util.CmdConfirm;
|
||||
import com.intellectualcrafters.plot.util.EconHandler;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.intellectualcrafters.plot.util.*;
|
||||
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
||||
|
||||
public class Delete extends SubCommand {
|
||||
@ -54,7 +50,7 @@ public class Delete extends SubCommand {
|
||||
return !sendMessage(plr, C.NO_PLOT_PERMS);
|
||||
}
|
||||
assert plot != null;
|
||||
final PlotWorld pWorld = PlotSquared.getPlotWorld(plot.world);
|
||||
final PlotWorld pWorld = PlotSquared.getInstance().getPlotWorld(plot.world);
|
||||
if (MainUtil.runners.containsKey(plot)) {
|
||||
MainUtil.sendMessage(plr, C.WAIT_FOR_TIMER);
|
||||
return false;
|
||||
@ -69,7 +65,7 @@ public class Delete extends SubCommand {
|
||||
sendMessage(plr, C.ADDED_BALANCE, c + "");
|
||||
}
|
||||
}
|
||||
PlotSquared.removePlot(loc.getWorld(), plot.id, true);
|
||||
PlotSquared.getInstance().removePlot(loc.getWorld(), plot.id, true);
|
||||
final long start = System.currentTimeMillis();
|
||||
final boolean result = MainUtil.clearAsPlayer(plot, true, new Runnable() {
|
||||
@Override
|
||||
|
@ -20,14 +20,14 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.intellectualcrafters.plot.PlotSquared;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* @author Citymonstret
|
||||
*/
|
||||
@ -37,7 +37,7 @@ public class Home extends SubCommand {
|
||||
}
|
||||
|
||||
private Plot isAlias(final String a) {
|
||||
for (final Plot p : PlotSquared.getPlots()) {
|
||||
for (final Plot p : PlotSquared.getInstance().getPlots()) {
|
||||
if ((p.settings.getAlias().length() > 0) && p.settings.getAlias().equalsIgnoreCase(a)) {
|
||||
return p;
|
||||
}
|
||||
@ -47,7 +47,7 @@ public class Home extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean execute(final PlotPlayer plr, String... args) {
|
||||
final ArrayList<Plot> plots = PlotSquared.sortPlotsByWorld(PlotSquared.getPlots(plr));
|
||||
final ArrayList<Plot> plots = PlotSquared.getInstance().sortPlotsByWorld(PlotSquared.getInstance().getPlots(plr));
|
||||
if (plots.size() == 1) {
|
||||
MainUtil.teleportPlayer(plr, plr.getLocation(), plots.get(0));
|
||||
return true;
|
||||
|
@ -20,26 +20,17 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import com.intellectualcrafters.plot.PlotSquared;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.object.*;
|
||||
import com.intellectualcrafters.plot.util.*;
|
||||
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
import com.intellectualcrafters.plot.PlotSquared;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
import com.intellectualcrafters.plot.util.CmdConfirm;
|
||||
import com.intellectualcrafters.plot.util.EconHandler;
|
||||
import com.intellectualcrafters.plot.util.EventUtil;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
||||
|
||||
/**
|
||||
* @author Citymonstret
|
||||
*/
|
||||
@ -172,7 +163,7 @@ public class Merge extends SubCommand {
|
||||
sendMessage(accepter, C.MERGE_NOT_VALID);
|
||||
return;
|
||||
}
|
||||
final PlotWorld plotWorld = PlotSquared.getPlotWorld(world);
|
||||
final PlotWorld plotWorld = PlotSquared.getInstance().getPlotWorld(world);
|
||||
if ((EconHandler.manager != null) && plotWorld.USE_ECONOMY) {
|
||||
double cost = plotWorld.MERGE_PRICE;
|
||||
cost = plots.size() * cost;
|
||||
@ -201,7 +192,7 @@ public class Merge extends SubCommand {
|
||||
MainUtil.sendMessage(plr, C.MERGE_REQUESTED);
|
||||
return true;
|
||||
}
|
||||
final PlotWorld plotWorld = PlotSquared.getPlotWorld(world);
|
||||
final PlotWorld plotWorld = PlotSquared.getInstance().getPlotWorld(world);
|
||||
if ((EconHandler.manager != null) && plotWorld.USE_ECONOMY) {
|
||||
double cost = plotWorld.MERGE_PRICE;
|
||||
cost = plots.size() * cost;
|
||||
|
@ -22,11 +22,7 @@ package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import com.intellectualcrafters.plot.PlotSquared;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
import com.intellectualcrafters.plot.object.*;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.Permissions;
|
||||
|
||||
@ -65,12 +61,12 @@ public class Move extends SubCommand {
|
||||
}
|
||||
String world2;
|
||||
if (args.length == 2) {
|
||||
PlotWorld other = PlotSquared.getPlotWorld(args[1]);
|
||||
PlotWorld current = PlotSquared.getPlotWorld(loc.getWorld());
|
||||
if (other == null || current == null || !other.equals(current)) {
|
||||
MainUtil.sendMessage(plr, C.PLOTWORLD_INCOMPATIBLE);
|
||||
return false;
|
||||
}
|
||||
PlotWorld other = PlotSquared.getInstance().getPlotWorld(args[1]);
|
||||
PlotWorld current = PlotSquared.getInstance().getPlotWorld(loc.getWorld());
|
||||
if (other == null || current == null || !other.equals(current)) {
|
||||
MainUtil.sendMessage(plr, C.PLOTWORLD_INCOMPATIBLE);
|
||||
return false;
|
||||
}
|
||||
world2 = other.worldname;
|
||||
}
|
||||
else {
|
||||
|
@ -20,11 +20,6 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.intellectualcrafters.plot.PlotSquared;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
@ -34,6 +29,11 @@ import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
@SuppressWarnings({ "javadoc" })
|
||||
public class Purge extends SubCommand {
|
||||
public Purge() {
|
||||
@ -91,7 +91,7 @@ public class Purge extends SubCommand {
|
||||
return false;
|
||||
}
|
||||
final String worldname = args[1];
|
||||
if (!PlotSquared.getAllPlotsRaw().containsKey(worldname)) {
|
||||
if (!PlotSquared.getInstance().getAllPlotsRaw().containsKey(worldname)) {
|
||||
MainUtil.sendMessage(plr, "INVALID WORLD");
|
||||
return false;
|
||||
}
|
||||
@ -107,7 +107,7 @@ public class Purge extends SubCommand {
|
||||
return finishPurge(DBid == Integer.MAX_VALUE ? 1 : 0);
|
||||
}
|
||||
if (arg.equals("all")) {
|
||||
final Set<PlotId> ids = PlotSquared.getPlots(worldname).keySet();
|
||||
final Set<PlotId> ids = PlotSquared.getInstance().getPlots(worldname).keySet();
|
||||
int length = ids.size();
|
||||
if (length == 0) {
|
||||
return MainUtil.sendMessage(null, "&cNo plots found");
|
||||
@ -116,7 +116,7 @@ public class Purge extends SubCommand {
|
||||
return finishPurge(length);
|
||||
}
|
||||
if (arg.equals("unknown")) {
|
||||
final Collection<Plot> plots = PlotSquared.getPlots(worldname).values();
|
||||
final Collection<Plot> plots = PlotSquared.getInstance().getPlots(worldname).values();
|
||||
final Set<PlotId> ids = new HashSet<>();
|
||||
for (final Plot plot : plots) {
|
||||
if (plot.owner != null) {
|
||||
@ -134,7 +134,7 @@ public class Purge extends SubCommand {
|
||||
return finishPurge(length);
|
||||
}
|
||||
if (arg.equals("unowned")) {
|
||||
final Collection<Plot> plots = PlotSquared.getPlots(worldname).values();
|
||||
final Collection<Plot> plots = PlotSquared.getInstance().getPlots(worldname).values();
|
||||
final Set<PlotId> ids = new HashSet<>();
|
||||
for (final Plot plot : plots) {
|
||||
if (plot.owner == null) {
|
||||
@ -150,7 +150,7 @@ public class Purge extends SubCommand {
|
||||
}
|
||||
final UUID uuid = UUIDHandler.getUUID(args[0]);
|
||||
if (uuid != null) {
|
||||
final Set<Plot> plots = PlotSquared.getPlots(worldname, uuid);
|
||||
final Set<Plot> plots = PlotSquared.getInstance().getPlots(worldname, uuid);
|
||||
final Set<PlotId> ids = new HashSet<>();
|
||||
for (final Plot plot : plots) {
|
||||
ids.add(plot.id);
|
||||
|
@ -20,8 +20,6 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.intellectualcrafters.plot.PlotSquared;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.generator.HybridPlotManager;
|
||||
@ -31,6 +29,8 @@ import com.intellectualcrafters.plot.object.PlotManager;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.ChunkManager;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class RegenAllRoads extends SubCommand {
|
||||
public RegenAllRoads() {
|
||||
super(Command.REGENALLROADS, "Regenerate all roads in the map using the set road schematic", "rgar", CommandCategory.DEBUG, false);
|
||||
@ -58,7 +58,7 @@ public class RegenAllRoads extends SubCommand {
|
||||
}
|
||||
}
|
||||
final String name = args[0];
|
||||
final PlotManager manager = PlotSquared.getPlotManager(name);
|
||||
final PlotManager manager = PlotSquared.getInstance().getPlotManager(name);
|
||||
if ((manager == null) || !(manager instanceof HybridPlotManager)) {
|
||||
sendMessage(player, C.NOT_VALID_PLOT_WORLD);
|
||||
return false;
|
||||
|
@ -37,10 +37,10 @@ public class Reload extends SubCommand {
|
||||
// The following won't affect world generation, as that has to be
|
||||
// loaded during startup unfortunately.
|
||||
PlotSquared.config.load(PlotSquared.configFile);
|
||||
PlotSquared.setupConfig();
|
||||
PlotSquared.getInstance().setupConfig();
|
||||
C.setupTranslations();
|
||||
for (final String pw : PlotSquared.getPlotWorlds()) {
|
||||
final PlotWorld plotworld = PlotSquared.getPlotWorld(pw);
|
||||
for (final String pw : PlotSquared.getInstance().getPlotWorlds()) {
|
||||
final PlotWorld plotworld = PlotSquared.getInstance().getPlotWorld(pw);
|
||||
plotworld.loadDefaultConfiguration(PlotSquared.config.getConfigurationSection("worlds." + pw));
|
||||
}
|
||||
MainUtil.sendMessage(plr, C.RELOADED_CONFIGS);
|
||||
|
@ -20,26 +20,22 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
|
||||
import com.intellectualcrafters.plot.PlotSquared;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.BlockManager;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.intellectualcrafters.plot.util.SchematicHandler;
|
||||
import com.intellectualcrafters.plot.util.*;
|
||||
import com.intellectualcrafters.plot.util.SchematicHandler.DataCollection;
|
||||
import com.intellectualcrafters.plot.util.SchematicHandler.Dimension;
|
||||
import com.intellectualcrafters.plot.util.SchematicHandler.Schematic;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.intellectualcrafters.plot.util.bukkit.BukkitUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class SchematicCmd extends SubCommand {
|
||||
private int counter = 0;
|
||||
private boolean running = false;
|
||||
@ -202,7 +198,7 @@ public class SchematicCmd extends SubCommand {
|
||||
MainUtil.sendMessage(null, "&cNeed world arg. Use &7/plots sch exportall <world>");
|
||||
return false;
|
||||
}
|
||||
final HashMap<PlotId, Plot> plotmap = PlotSquared.getPlots(args[1]);
|
||||
final HashMap<PlotId, Plot> plotmap = PlotSquared.getInstance().getPlots(args[1]);
|
||||
if ((plotmap == null) || (plotmap.size() == 0)) {
|
||||
MainUtil.sendMessage(plr, "&cInvalid world. Use &7/plots sch exportall <world>");
|
||||
return false;
|
||||
@ -254,11 +250,11 @@ public class SchematicCmd extends SubCommand {
|
||||
world = args[1];
|
||||
final String[] split = args[2].split(";");
|
||||
final PlotId i = new PlotId(Integer.parseInt(split[0]), Integer.parseInt(split[1]));
|
||||
if ((PlotSquared.getPlots(world) == null) || (PlotSquared.getPlots(world).get(i) == null)) {
|
||||
if ((PlotSquared.getInstance().getPlots(world) == null) || (PlotSquared.getInstance().getPlots(world).get(i) == null)) {
|
||||
MainUtil.sendMessage(null, "&cInvalid world or id. Use &7/plots sch save <world> <id>");
|
||||
return false;
|
||||
}
|
||||
p2 = PlotSquared.getPlots(world).get(i);
|
||||
p2 = PlotSquared.getInstance().getPlots(world).get(i);
|
||||
} catch (final Exception e) {
|
||||
MainUtil.sendMessage(null, "&cInvalid world or id. Use &7/plots sch save <world> <id>");
|
||||
return false;
|
||||
|
@ -20,12 +20,6 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
import com.intellectualcrafters.plot.PlotSquared;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.config.Configuration;
|
||||
@ -33,22 +27,15 @@ import com.intellectualcrafters.plot.database.DBFunc;
|
||||
import com.intellectualcrafters.plot.flag.AbstractFlag;
|
||||
import com.intellectualcrafters.plot.flag.Flag;
|
||||
import com.intellectualcrafters.plot.flag.FlagManager;
|
||||
import com.intellectualcrafters.plot.flag.FlagValue.PlotBlockListValue;
|
||||
import com.intellectualcrafters.plot.listeners.APlotListener;
|
||||
import com.intellectualcrafters.plot.object.BlockLoc;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||
import com.intellectualcrafters.plot.object.PlotManager;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
import com.intellectualcrafters.plot.object.StringWrapper;
|
||||
import com.intellectualcrafters.plot.util.BlockManager;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.intellectualcrafters.plot.util.SetBlockQueue;
|
||||
import com.intellectualcrafters.plot.util.StringComparison;
|
||||
import com.intellectualcrafters.plot.object.*;
|
||||
import com.intellectualcrafters.plot.util.*;
|
||||
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Citymonstret
|
||||
@ -79,10 +66,10 @@ public class Set extends SubCommand {
|
||||
}
|
||||
}
|
||||
if (args.length < 1) {
|
||||
PlotManager manager = PlotSquared.getPlotManager(loc.getWorld());
|
||||
PlotManager manager = PlotSquared.getInstance().getPlotManager(loc.getWorld());
|
||||
ArrayList<String> newValues = new ArrayList<String>();
|
||||
newValues.addAll(Arrays.asList(values));
|
||||
newValues.addAll(Arrays.asList(manager.getPlotComponents(PlotSquared.getPlotWorld(loc.getWorld()), plot.id)));
|
||||
newValues.addAll(Arrays.asList(manager.getPlotComponents(PlotSquared.getInstance().getPlotWorld(loc.getWorld()), plot.id)));
|
||||
MainUtil.sendMessage(plr, C.SUBCOMMAND_SET_OPTIONS_HEADER.s() + getArgumentList(newValues));
|
||||
return false;
|
||||
}
|
||||
@ -184,7 +171,7 @@ public class Set extends SubCommand {
|
||||
MainUtil.sendMessage(plr, C.ALIAS_TOO_LONG);
|
||||
return false;
|
||||
}
|
||||
for (final Plot p : PlotSquared.getPlots(plr.getLocation().getWorld()).values()) {
|
||||
for (final Plot p : PlotSquared.getInstance().getPlots(plr.getLocation().getWorld()).values()) {
|
||||
if (p.settings.getAlias().equalsIgnoreCase(alias)) {
|
||||
MainUtil.sendMessage(plr, C.ALIAS_IS_TAKEN);
|
||||
return false;
|
||||
@ -230,8 +217,8 @@ public class Set extends SubCommand {
|
||||
}
|
||||
// Get components
|
||||
final String world = plr.getLocation().getWorld();
|
||||
final PlotWorld plotworld = PlotSquared.getPlotWorld(world);
|
||||
final PlotManager manager = PlotSquared.getPlotManager(world);
|
||||
final PlotWorld plotworld = PlotSquared.getInstance().getPlotWorld(world);
|
||||
final PlotManager manager = PlotSquared.getInstance().getPlotManager(world);
|
||||
final String[] components = manager.getPlotComponents(plotworld, plot.id);
|
||||
for (final String component : components) {
|
||||
if (component.equalsIgnoreCase(args[0])) {
|
||||
@ -321,7 +308,7 @@ public class Set extends SubCommand {
|
||||
}
|
||||
ArrayList<String> newValues = new ArrayList<String>();
|
||||
newValues.addAll(Arrays.asList(values));
|
||||
newValues.addAll(Arrays.asList(manager.getPlotComponents(PlotSquared.getPlotWorld(loc.getWorld()), plot.id)));
|
||||
newValues.addAll(Arrays.asList(manager.getPlotComponents(PlotSquared.getInstance().getPlotWorld(loc.getWorld()), plot.id)));
|
||||
MainUtil.sendMessage(plr, C.SUBCOMMAND_SET_OPTIONS_HEADER.s() + getArgumentList(newValues));
|
||||
return false;
|
||||
}
|
||||
|
@ -20,9 +20,6 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.intellectualcrafters.plot.PlotSquared;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
@ -35,6 +32,9 @@ import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.UUID;
|
||||
|
||||
public class SetOwner extends SubCommand {
|
||||
public SetOwner() {
|
||||
super("setowner", "plots.set.owner", "Set the plot owner", "setowner <player>", "so", CommandCategory.ACTIONS, true);
|
||||
@ -93,14 +93,14 @@ public class SetOwner extends SubCommand {
|
||||
|
||||
final String world = loc.getWorld();
|
||||
for (final PlotId id : plots) {
|
||||
final Plot current = PlotSquared.getPlots(world).get(id);
|
||||
final Plot current = PlotSquared.getInstance().getPlots(world).get(id);
|
||||
final UUID uuid = getUUID(args[0]);
|
||||
if (uuid == null) {
|
||||
MainUtil.sendMessage(plr, C.INVALID_PLAYER, args[0]);
|
||||
return false;
|
||||
}
|
||||
current.owner = uuid;
|
||||
PlotSquared.updatePlot(current);
|
||||
PlotSquared.getInstance().updatePlot(current);
|
||||
DBFunc.setOwner(current, current.owner);
|
||||
}
|
||||
MainUtil.setSign(args[0], plot);
|
||||
|
@ -20,8 +20,6 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
import com.intellectualcrafters.plot.PlotSquared;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
@ -31,6 +29,7 @@ import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.BlockManager;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
/**
|
||||
* @author Citymonstret
|
||||
@ -56,7 +55,7 @@ public class TP extends SubCommand {
|
||||
world = args[1];
|
||||
}
|
||||
}
|
||||
if (!PlotSquared.isPlotWorld(world)) {
|
||||
if (!PlotSquared.getInstance().isPlotWorld(world)) {
|
||||
MainUtil.sendMessage(plr, C.NOT_IN_PLOT_WORLD);
|
||||
return false;
|
||||
}
|
||||
@ -86,7 +85,7 @@ public class TP extends SubCommand {
|
||||
}
|
||||
final PlotPlayer player = UUIDHandler.getPlayer(a);
|
||||
if (player != null) {
|
||||
final java.util.Set<Plot> plotMainPlots = PlotSquared.getPlots(world, player);
|
||||
final java.util.Set<Plot> plotMainPlots = PlotSquared.getInstance().getPlots(world, player);
|
||||
final Plot[] plots = plotMainPlots.toArray(new Plot[plotMainPlots.size()]);
|
||||
if (plots.length > index) {
|
||||
return plots[index];
|
||||
|
@ -35,7 +35,7 @@ public class Target extends SubCommand {
|
||||
@Override
|
||||
public boolean execute(final PlotPlayer plr, final String... args) {
|
||||
final Location ploc = plr.getLocation();
|
||||
if (!PlotSquared.isPlotWorld(ploc.getWorld())) {
|
||||
if (!PlotSquared.getInstance().isPlotWorld(ploc.getWorld())) {
|
||||
MainUtil.sendMessage(plr, C.NOT_IN_PLOT_WORLD);
|
||||
return false;
|
||||
}
|
||||
|
@ -20,6 +20,17 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import com.intellectualcrafters.plot.PlotSquared;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.config.ConfigurationNode;
|
||||
import com.intellectualcrafters.plot.object.*;
|
||||
import com.intellectualcrafters.plot.util.BlockManager;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.SetupUtils;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
@ -29,125 +40,11 @@ import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipInputStream;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import com.intellectualcrafters.plot.PlotSquared;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.config.ConfigurationNode;
|
||||
import com.intellectualcrafters.plot.object.FileBytes;
|
||||
import com.intellectualcrafters.plot.object.PlotManager;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
import com.intellectualcrafters.plot.object.SetupObject;
|
||||
import com.intellectualcrafters.plot.util.BlockManager;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.SetupUtils;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
|
||||
public class Template extends SubCommand {
|
||||
public Template() {
|
||||
super("template", "plots.admin", "Create or use a world template", "template", "", CommandCategory.DEBUG, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(final PlotPlayer plr, final String... args) {
|
||||
if (args.length != 2 && args.length != 3) {
|
||||
if (args.length == 1) {
|
||||
if (args[0].equalsIgnoreCase("export")) {
|
||||
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot template export <world>");
|
||||
return false;
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("import")) {
|
||||
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot template import <world> <template>");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot template <import|export> <world> [template]");
|
||||
return false;
|
||||
}
|
||||
final String world = args[1];
|
||||
switch (args[0].toLowerCase()) {
|
||||
case "import": {
|
||||
if (args.length != 3) {
|
||||
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot template import <world> <template>");
|
||||
return false;
|
||||
}
|
||||
if (PlotSquared.isPlotWorld(world)) {
|
||||
MainUtil.sendMessage(plr, C.SETUP_WORLD_TAKEN, world);
|
||||
return false;
|
||||
}
|
||||
boolean result = extractAllFiles(world, args[2]);
|
||||
if (!result) {
|
||||
MainUtil.sendMessage(plr, "&cInvalid template file: " + args[2] +".template");
|
||||
return false;
|
||||
}
|
||||
File worldFile = new File(PlotSquared.IMP.getDirectory() + File.separator + "templates" + File.separator + "tmp-data.yml");
|
||||
YamlConfiguration worldConfig = YamlConfiguration.loadConfiguration(worldFile);
|
||||
PlotSquared.config.set("worlds." + world, worldConfig.get(""));
|
||||
try {
|
||||
PlotSquared.config.save(PlotSquared.configFile);
|
||||
PlotSquared.config.load(PlotSquared.configFile);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
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 = world;
|
||||
SetupUtils.manager.setupWorld(setup);
|
||||
MainUtil.sendMessage(plr, "Done!");
|
||||
if (plr != null) {
|
||||
plr.teleport(BlockManager.manager.getSpawn(world));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
case "export": {
|
||||
if (args.length != 2) {
|
||||
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot template export <world>");
|
||||
return false;
|
||||
}
|
||||
final PlotWorld plotworld = PlotSquared.getPlotWorld(world);
|
||||
if (!BlockManager.manager.isWorld(world) || (plotworld == null)) {
|
||||
MainUtil.sendMessage(plr, C.NOT_VALID_PLOT_WORLD);
|
||||
return false;
|
||||
}
|
||||
final PlotManager manager = PlotSquared.getPlotManager(world);
|
||||
TaskManager.runTaskAsync(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
manager.exportTemplate(plotworld);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
MainUtil.sendMessage(plr, "Failed: " + e.getMessage());
|
||||
return;
|
||||
}
|
||||
MainUtil.sendMessage(plr, "Done!");
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public static boolean extractAllFiles(String world, String template) {
|
||||
byte[] buffer = new byte[2048];
|
||||
try {
|
||||
@ -155,7 +52,7 @@ public class Template extends SubCommand {
|
||||
if (!folder.exists()) {
|
||||
return false;
|
||||
}
|
||||
File input = new File(folder + File.separator + template +".template");
|
||||
File input = new File(folder + File.separator + template + ".template");
|
||||
File output = PlotSquared.IMP.getDirectory();
|
||||
if (!output.exists()) {
|
||||
output.mkdirs();
|
||||
@ -182,7 +79,7 @@ public class Template extends SubCommand {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static byte[] getBytes(PlotWorld plotworld) {
|
||||
ConfigurationSection section = PlotSquared.config.getConfigurationSection("worlds." + plotworld.worldname);
|
||||
YamlConfiguration config = new YamlConfiguration();
|
||||
@ -195,13 +92,13 @@ public class Template extends SubCommand {
|
||||
}
|
||||
return config.saveToString().getBytes();
|
||||
}
|
||||
|
||||
|
||||
public static void zipAll(final String world, Set<FileBytes> files) throws IOException {
|
||||
File output = new File(PlotSquared.IMP.getDirectory() + File.separator + "templates");
|
||||
output.mkdirs();
|
||||
FileOutputStream fos = new FileOutputStream(output + File.separator + world + ".template");
|
||||
ZipOutputStream zos = new ZipOutputStream(fos);
|
||||
|
||||
|
||||
for (FileBytes file : files) {
|
||||
ZipEntry ze = new ZipEntry(file.path);
|
||||
zos.putNextEntry(ze);
|
||||
@ -210,4 +107,102 @@ public class Template extends SubCommand {
|
||||
zos.closeEntry();
|
||||
zos.close();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(final PlotPlayer plr, final String... args) {
|
||||
if (args.length != 2 && args.length != 3) {
|
||||
if (args.length == 1) {
|
||||
if (args[0].equalsIgnoreCase("export")) {
|
||||
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot template export <world>");
|
||||
return false;
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("import")) {
|
||||
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot template import <world> <template>");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot template <import|export> <world> [template]");
|
||||
return false;
|
||||
}
|
||||
final String world = args[1];
|
||||
switch (args[0].toLowerCase()) {
|
||||
case "import": {
|
||||
if (args.length != 3) {
|
||||
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot template import <world> <template>");
|
||||
return false;
|
||||
}
|
||||
if (PlotSquared.getInstance().isPlotWorld(world)) {
|
||||
MainUtil.sendMessage(plr, C.SETUP_WORLD_TAKEN, world);
|
||||
return false;
|
||||
}
|
||||
boolean result = extractAllFiles(world, args[2]);
|
||||
if (!result) {
|
||||
MainUtil.sendMessage(plr, "&cInvalid template file: " + args[2] +".template");
|
||||
return false;
|
||||
}
|
||||
File worldFile = new File(PlotSquared.IMP.getDirectory() + File.separator + "templates" + File.separator + "tmp-data.yml");
|
||||
YamlConfiguration worldConfig = YamlConfiguration.loadConfiguration(worldFile);
|
||||
PlotSquared.config.set("worlds." + world, worldConfig.get(""));
|
||||
try {
|
||||
PlotSquared.config.save(PlotSquared.configFile);
|
||||
PlotSquared.config.load(PlotSquared.configFile);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
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 = world;
|
||||
SetupUtils.manager.setupWorld(setup);
|
||||
MainUtil.sendMessage(plr, "Done!");
|
||||
if (plr != null) {
|
||||
plr.teleport(BlockManager.manager.getSpawn(world));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
case "export": {
|
||||
if (args.length != 2) {
|
||||
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot template export <world>");
|
||||
return false;
|
||||
}
|
||||
final PlotWorld plotworld = PlotSquared.getInstance().getPlotWorld(world);
|
||||
if (!BlockManager.manager.isWorld(world) || (plotworld == null)) {
|
||||
MainUtil.sendMessage(plr, C.NOT_VALID_PLOT_WORLD);
|
||||
return false;
|
||||
}
|
||||
final PlotManager manager = PlotSquared.getInstance().getPlotManager(world);
|
||||
TaskManager.runTaskAsync(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
manager.exportTemplate(plotworld);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
MainUtil.sendMessage(plr, "Failed: " + e.getMessage());
|
||||
return;
|
||||
}
|
||||
MainUtil.sendMessage(plr, "Done!");
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -20,6 +20,14 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import com.intellectualcrafters.plot.PlotSquared;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.object.*;
|
||||
import com.intellectualcrafters.plot.util.BlockManager;
|
||||
import com.intellectualcrafters.plot.util.ChunkManager;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
@ -28,84 +36,15 @@ import java.nio.file.attribute.BasicFileAttributes;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
|
||||
import com.intellectualcrafters.plot.PlotSquared;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.object.ChunkLoc;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.BlockManager;
|
||||
import com.intellectualcrafters.plot.util.ChunkManager;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
|
||||
public class Trim extends SubCommand {
|
||||
public static boolean TASK = false;
|
||||
public static ArrayList<Plot> expired = null;
|
||||
private static int TASK_ID = 0;
|
||||
|
||||
public Trim() {
|
||||
super("trim", "plots.admin", "Delete unmodified portions of your plotworld", "trim", "", CommandCategory.DEBUG, false);
|
||||
}
|
||||
|
||||
public PlotId getId(final String id) {
|
||||
try {
|
||||
final String[] split = id.split(";");
|
||||
return new PlotId(Integer.parseInt(split[0]), Integer.parseInt(split[1]));
|
||||
} catch (final Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(final PlotPlayer plr, final String... args) {
|
||||
if (plr != null) {
|
||||
MainUtil.sendMessage(plr, (C.NOT_CONSOLE));
|
||||
return false;
|
||||
}
|
||||
if (args.length == 1) {
|
||||
final String arg = args[0].toLowerCase();
|
||||
final PlotId id = getId(arg);
|
||||
if (id != null) {
|
||||
MainUtil.sendMessage(plr, "/plot trim x;z &l<world>");
|
||||
return false;
|
||||
}
|
||||
if (arg.equals("all")) {
|
||||
MainUtil.sendMessage(plr, "/plot trim all &l<world>");
|
||||
return false;
|
||||
}
|
||||
MainUtil.sendMessage(plr, C.TRIM_SYNTAX);
|
||||
return false;
|
||||
}
|
||||
if (args.length != 2) {
|
||||
MainUtil.sendMessage(plr, C.TRIM_SYNTAX);
|
||||
return false;
|
||||
}
|
||||
final String arg = args[0].toLowerCase();
|
||||
if (!arg.equals("all")) {
|
||||
MainUtil.sendMessage(plr, C.TRIM_SYNTAX);
|
||||
return false;
|
||||
}
|
||||
final String world = args[1];
|
||||
if (!BlockManager.manager.isWorld(world) || (PlotSquared.getPlotWorld(world) == null)) {
|
||||
MainUtil.sendMessage(plr, C.NOT_VALID_WORLD);
|
||||
return false;
|
||||
}
|
||||
if (Trim.TASK) {
|
||||
sendMessage(C.TRIM_IN_PROGRESS.s());
|
||||
return false;
|
||||
}
|
||||
sendMessage(C.TRIM_START.s());
|
||||
final ArrayList<ChunkLoc> empty = new ArrayList<>();
|
||||
getTrimRegions(empty, world, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
deleteChunks(world, empty);
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean getBulkRegions(final ArrayList<ChunkLoc> empty, final String world, final Runnable whenDone) {
|
||||
if (Trim.TASK) {
|
||||
return false;
|
||||
@ -167,7 +106,7 @@ public class Trim extends SubCommand {
|
||||
System.currentTimeMillis();
|
||||
sendMessage("Collecting region data...");
|
||||
final ArrayList<Plot> plots = new ArrayList<>();
|
||||
plots.addAll(PlotSquared.getPlots(world).values());
|
||||
plots.addAll(PlotSquared.getInstance().getPlots(world).values());
|
||||
final HashSet<ChunkLoc> chunks = new HashSet<>(ChunkManager.manager.getChunkChunks(world));
|
||||
sendMessage(" - MCA #: " + chunks.size());
|
||||
sendMessage(" - CHUNKS: " + (chunks.size() * 1024) + " (max)");
|
||||
@ -201,8 +140,6 @@ public class Trim extends SubCommand {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static ArrayList<Plot> expired = null;
|
||||
|
||||
public static void deleteChunks(final String world, final ArrayList<ChunkLoc> chunks) {
|
||||
ChunkManager.manager.deleteRegionFiles(world, chunks);
|
||||
}
|
||||
@ -210,4 +147,62 @@ public class Trim extends SubCommand {
|
||||
public static void sendMessage(final String message) {
|
||||
PlotSquared.log("&3PlotSquared -> World trim&8: &7" + message);
|
||||
}
|
||||
|
||||
public PlotId getId(final String id) {
|
||||
try {
|
||||
final String[] split = id.split(";");
|
||||
return new PlotId(Integer.parseInt(split[0]), Integer.parseInt(split[1]));
|
||||
} catch (final Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(final PlotPlayer plr, final String... args) {
|
||||
if (plr != null) {
|
||||
MainUtil.sendMessage(plr, (C.NOT_CONSOLE));
|
||||
return false;
|
||||
}
|
||||
if (args.length == 1) {
|
||||
final String arg = args[0].toLowerCase();
|
||||
final PlotId id = getId(arg);
|
||||
if (id != null) {
|
||||
MainUtil.sendMessage(plr, "/plot trim x;z &l<world>");
|
||||
return false;
|
||||
}
|
||||
if (arg.equals("all")) {
|
||||
MainUtil.sendMessage(plr, "/plot trim all &l<world>");
|
||||
return false;
|
||||
}
|
||||
MainUtil.sendMessage(plr, C.TRIM_SYNTAX);
|
||||
return false;
|
||||
}
|
||||
if (args.length != 2) {
|
||||
MainUtil.sendMessage(plr, C.TRIM_SYNTAX);
|
||||
return false;
|
||||
}
|
||||
final String arg = args[0].toLowerCase();
|
||||
if (!arg.equals("all")) {
|
||||
MainUtil.sendMessage(plr, C.TRIM_SYNTAX);
|
||||
return false;
|
||||
}
|
||||
final String world = args[1];
|
||||
if (!BlockManager.manager.isWorld(world) || (PlotSquared.getInstance().getPlotWorld(world) == null)) {
|
||||
MainUtil.sendMessage(plr, C.NOT_VALID_WORLD);
|
||||
return false;
|
||||
}
|
||||
if (Trim.TASK) {
|
||||
sendMessage(C.TRIM_IN_PROGRESS.s());
|
||||
return false;
|
||||
}
|
||||
sendMessage(C.TRIM_START.s());
|
||||
final ArrayList<ChunkLoc> empty = new ArrayList<>();
|
||||
getTrimRegions(empty, world, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
deleteChunks(world, empty);
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -20,8 +20,6 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import com.intellectualcrafters.plot.PlotSquared;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
@ -33,6 +31,8 @@ import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class Trust extends SubCommand {
|
||||
public Trust() {
|
||||
super(Command.TRUST, "Allow a player to build in a plot", "trust <player>", CommandCategory.ACTIONS, true);
|
||||
@ -77,7 +77,7 @@ public class Trust extends SubCommand {
|
||||
DBFunc.removeMember(loc.getWorld(), plot, uuid);
|
||||
}
|
||||
if (plot.denied.contains(uuid)) {
|
||||
if (plot.members.size() + plot.trusted.size() >= PlotSquared.getPlotWorld(plot.world).MAX_PLOT_MEMBERS) {
|
||||
if (plot.members.size() + plot.trusted.size() >= PlotSquared.getInstance().getPlotWorld(plot.world).MAX_PLOT_MEMBERS) {
|
||||
MainUtil.sendMessage(plr, C.PLOT_MAX_MEMBERS);
|
||||
return false;
|
||||
}
|
||||
@ -91,7 +91,7 @@ public class Trust extends SubCommand {
|
||||
MainUtil.sendMessage(plr, C.ALREADY_ADDED);
|
||||
return false;
|
||||
}
|
||||
if (plot.members.size() + plot.trusted.size() >= PlotSquared.getPlotWorld(plot.world).MAX_PLOT_MEMBERS) {
|
||||
if (plot.members.size() + plot.trusted.size() >= PlotSquared.getInstance().getPlotWorld(plot.world).MAX_PLOT_MEMBERS) {
|
||||
MainUtil.sendMessage(plr, C.PLOT_MAX_MEMBERS);
|
||||
return false;
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ public class Unclaim extends SubCommand {
|
||||
return !sendMessage(plr, C.NO_PLOT_PERMS);
|
||||
}
|
||||
assert plot != null;
|
||||
final PlotWorld pWorld = PlotSquared.getPlotWorld(plot.world);
|
||||
final PlotWorld pWorld = PlotSquared.getInstance().getPlotWorld(plot.world);
|
||||
if ((EconHandler.manager != null) && pWorld.USE_ECONOMY) {
|
||||
final double c = pWorld.SELL_PRICE;
|
||||
if (c > 0d) {
|
||||
@ -58,10 +58,10 @@ public class Unclaim extends SubCommand {
|
||||
sendMessage(plr, C.ADDED_BALANCE, c + "");
|
||||
}
|
||||
}
|
||||
final boolean result = PlotSquared.removePlot(loc.getWorld(), plot.id, true);
|
||||
final boolean result = PlotSquared.getInstance().removePlot(loc.getWorld(), plot.id, true);
|
||||
if (result) {
|
||||
final String worldname = plr.getLocation().getWorld();
|
||||
PlotSquared.getPlotManager(worldname).unclaimPlot(pWorld, plot);
|
||||
PlotSquared.getInstance().getPlotManager(worldname).unclaimPlot(pWorld, plot);
|
||||
DBFunc.delete(worldname, plot);
|
||||
// TODO set wall block
|
||||
} else {
|
||||
|
@ -20,19 +20,18 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.intellectualcrafters.plot.PlotSquared;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class Visit extends SubCommand {
|
||||
public Visit() {
|
||||
super("visit", "plots.visit", "Visit someones plot", "visit {player} [#]", "v", CommandCategory.TELEPORT, true);
|
||||
@ -40,7 +39,7 @@ public class Visit extends SubCommand {
|
||||
|
||||
public List<Plot> getPlots(final UUID uuid) {
|
||||
final List<Plot> plots = new ArrayList<>();
|
||||
for (final Plot p : PlotSquared.getPlots()) {
|
||||
for (final Plot p : PlotSquared.getInstance().getPlots()) {
|
||||
if (p.hasOwner() && p.isOwner(uuid)) {
|
||||
plots.add(p);
|
||||
}
|
||||
@ -57,11 +56,10 @@ public class Visit extends SubCommand {
|
||||
UUID user = UUIDHandler.getUUID(args[0]);
|
||||
if (user != null ) {
|
||||
// do plots by username
|
||||
plots.addAll(PlotSquared.getPlots(user));
|
||||
}
|
||||
else if (PlotSquared.isPlotWorld(args[0])) {
|
||||
plots.addAll(PlotSquared.getInstance().getPlots(user));
|
||||
} else if (PlotSquared.getInstance().isPlotWorld(args[0])) {
|
||||
// do plots by world
|
||||
plots.addAll(PlotSquared.getPlots(args[0]).values());
|
||||
plots.addAll(PlotSquared.getInstance().getPlots(args[0]).values());
|
||||
}
|
||||
else {
|
||||
Plot plot = MainUtil.getPlotFromString(plr, args[0], true);
|
||||
|
@ -20,19 +20,6 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
import com.intellectualcrafters.plot.PlotSquared;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
@ -47,6 +34,12 @@ import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.intellectualcrafters.plot.util.StringComparison;
|
||||
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
||||
import com.intellectualcrafters.plot.util.bukkit.chat.FancyMessage;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author Citymonstret
|
||||
@ -109,7 +102,7 @@ public class list extends SubCommand {
|
||||
world = plr.getLocation().getWorld();
|
||||
}
|
||||
else {
|
||||
Set<String> worlds = PlotSquared.getPlotWorlds();
|
||||
Set<String> worlds = PlotSquared.getInstance().getPlotWorlds();
|
||||
if (worlds.size() == 0) {
|
||||
world = "world";
|
||||
}
|
||||
@ -128,7 +121,7 @@ public class list extends SubCommand {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.mine");
|
||||
return false;
|
||||
}
|
||||
plots = new ArrayList<>(PlotSquared.getPlots(plr));
|
||||
plots = new ArrayList<>(PlotSquared.getInstance().getPlots(plr));
|
||||
break;
|
||||
}
|
||||
case "shared": {
|
||||
@ -140,7 +133,7 @@ public class list extends SubCommand {
|
||||
return false;
|
||||
}
|
||||
plots = new ArrayList<Plot>();
|
||||
for (Plot plot : PlotSquared.getPlots()) {
|
||||
for (Plot plot : PlotSquared.getInstance().getPlots()) {
|
||||
if (plot.trusted.contains(plr.getUUID()) || plot.members.contains(plr.getUUID())) {
|
||||
plots.add(plot);
|
||||
}
|
||||
@ -156,7 +149,7 @@ public class list extends SubCommand {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.world." + world);
|
||||
return false;
|
||||
}
|
||||
plots = new ArrayList<>(PlotSquared.getPlots(world).values());
|
||||
plots = new ArrayList<>(PlotSquared.getInstance().getPlots(world).values());
|
||||
break;
|
||||
}
|
||||
case "all": {
|
||||
@ -164,7 +157,7 @@ public class list extends SubCommand {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.all");
|
||||
return false;
|
||||
}
|
||||
plots = new ArrayList<>(PlotSquared.getPlots());
|
||||
plots = new ArrayList<>(PlotSquared.getInstance().getPlots());
|
||||
break;
|
||||
}
|
||||
case "top": {
|
||||
@ -172,7 +165,7 @@ public class list extends SubCommand {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.top");
|
||||
return false;
|
||||
}
|
||||
plots = new ArrayList<>(PlotSquared.getPlots());
|
||||
plots = new ArrayList<>(PlotSquared.getInstance().getPlots());
|
||||
Collections.sort(plots, new Comparator<Plot>() {
|
||||
@Override
|
||||
public int compare(Plot p1, Plot p2) {
|
||||
@ -210,7 +203,7 @@ public class list extends SubCommand {
|
||||
break;
|
||||
}
|
||||
plots = new ArrayList<>();
|
||||
for (Plot plot : PlotSquared.getPlots()) {
|
||||
for (Plot plot : PlotSquared.getInstance().getPlots()) {
|
||||
final Flag price = FlagManager.getPlotFlag(plot, "price");
|
||||
if (price != null) {
|
||||
plots.add(plot);
|
||||
@ -224,7 +217,7 @@ public class list extends SubCommand {
|
||||
return false;
|
||||
}
|
||||
plots = new ArrayList<>();
|
||||
for (Plot plot : PlotSquared.getPlots()) {
|
||||
for (Plot plot : PlotSquared.getInstance().getPlots()) {
|
||||
if (plot.owner == null) {
|
||||
plots.add(plot);
|
||||
}
|
||||
@ -237,7 +230,7 @@ public class list extends SubCommand {
|
||||
return false;
|
||||
}
|
||||
plots = new ArrayList<>();
|
||||
for (Plot plot : PlotSquared.getPlots()) {
|
||||
for (Plot plot : PlotSquared.getInstance().getPlots()) {
|
||||
if (plot.owner == null) {
|
||||
continue;
|
||||
}
|
||||
@ -248,7 +241,7 @@ public class list extends SubCommand {
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
if (PlotSquared.isPlotWorld(args[0])) {
|
||||
if (PlotSquared.getInstance().isPlotWorld(args[0])) {
|
||||
if (!Permissions.hasPermission(plr, "plots.list.world")) {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.world");
|
||||
return false;
|
||||
@ -257,7 +250,7 @@ public class list extends SubCommand {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.world." + args[0]);
|
||||
return false;
|
||||
}
|
||||
plots = new ArrayList<>(PlotSquared.getPlots(args[0]).values());
|
||||
plots = new ArrayList<>(PlotSquared.getInstance().getPlots(args[0]).values());
|
||||
break;
|
||||
}
|
||||
UUID uuid = UUIDHandler.getUUID(args[0]);
|
||||
@ -266,7 +259,7 @@ public class list extends SubCommand {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.player");
|
||||
return false;
|
||||
}
|
||||
plots = new ArrayList<>(PlotSquared.getPlots(uuid));
|
||||
plots = new ArrayList<>(PlotSquared.getInstance().getPlots(uuid));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -288,10 +281,10 @@ public class list extends SubCommand {
|
||||
public void displayPlots(PlotPlayer player, List<Plot> plots, int pageSize, int page, String world, String[] args, boolean sort) {
|
||||
if (sort) {
|
||||
if (world != null) {
|
||||
plots = PlotSquared.sortPlots(plots, world);
|
||||
plots = PlotSquared.getInstance().sortPlots(plots, world);
|
||||
}
|
||||
else {
|
||||
plots = PlotSquared.sortPlots(plots);
|
||||
plots = PlotSquared.getInstance().sortPlots(plots);
|
||||
}
|
||||
}
|
||||
if (page < 0) {
|
||||
|
@ -20,40 +20,19 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.intellectualcrafters.plot.database;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.DatabaseMetaData;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.block.Biome;
|
||||
|
||||
import com.intellectualcrafters.plot.PlotSquared;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
import com.intellectualcrafters.plot.flag.Flag;
|
||||
import com.intellectualcrafters.plot.flag.FlagManager;
|
||||
import com.intellectualcrafters.plot.object.BlockLoc;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotCluster;
|
||||
import com.intellectualcrafters.plot.object.PlotClusterId;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.PlotSettings;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||
import com.intellectualcrafters.plot.object.*;
|
||||
import com.intellectualcrafters.plot.object.comment.PlotComment;
|
||||
import com.intellectualcrafters.plot.util.ClusterManager;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.block.Biome;
|
||||
|
||||
import java.sql.*;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author Citymonstret
|
||||
@ -70,10 +49,6 @@ public class SQLManager implements AbstractDB {
|
||||
private final String prefix;
|
||||
// Private Final
|
||||
private Connection connection;
|
||||
|
||||
public Connection getConnection() {
|
||||
return this.connection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
@ -101,9 +76,8 @@ public class SQLManager implements AbstractDB {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
SQLManager.this.connection = PlotSquared.getDatabase().forceConnection();
|
||||
}
|
||||
catch (Exception e) {
|
||||
SQLManager.this.connection = PlotSquared.getInstance().getDatabase().forceConnection();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
@ -112,6 +86,10 @@ public class SQLManager implements AbstractDB {
|
||||
updateTables();
|
||||
}
|
||||
|
||||
public Connection getConnection() {
|
||||
return this.connection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Plot owner
|
||||
*
|
||||
@ -139,26 +117,6 @@ public class SQLManager implements AbstractDB {
|
||||
});
|
||||
}
|
||||
|
||||
private class UUIDPair {
|
||||
public final int id;
|
||||
public final UUID uuid;
|
||||
|
||||
public UUIDPair(int id, UUID uuid) {
|
||||
this.id = id;
|
||||
this.uuid = uuid;
|
||||
}
|
||||
}
|
||||
|
||||
private class SettingsPair {
|
||||
public final int id;
|
||||
public final PlotSettings settings;
|
||||
|
||||
public SettingsPair(int id, PlotSettings settings) {
|
||||
this.id = id;
|
||||
this.settings = settings;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createPlotsAndData(final ArrayList<Plot> myList, final Runnable whenDone) {
|
||||
TaskManager.runTaskAsync(new Runnable() {
|
||||
@ -167,7 +125,7 @@ public class SQLManager implements AbstractDB {
|
||||
try {
|
||||
// Create the plots
|
||||
createPlots(myList);
|
||||
|
||||
|
||||
// Creating datastructures
|
||||
HashMap<PlotId, Plot> plotMap = new HashMap<>();
|
||||
for (Plot plot : myList) {
|
||||
@ -211,15 +169,14 @@ public class SQLManager implements AbstractDB {
|
||||
createTiers(trusted, "trusted");
|
||||
createTiers(denied, "denied");
|
||||
TaskManager.runTaskLater(whenDone, 60);
|
||||
}
|
||||
catch (SQLException e) {
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
PlotSquared.log("&7[WARN] " + "Failed to set all helpers for plots");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create a plot
|
||||
*
|
||||
@ -234,8 +191,8 @@ public class SQLManager implements AbstractDB {
|
||||
|
||||
@Override
|
||||
public String getCreateSQLite(int size) {
|
||||
return getCreateSQLite(size,
|
||||
"INSERT INTO `" + prefix + "plot_" + tier + "` SELECT ? AS `plot_plot_id`, ? AS `user_uuid`", 2);
|
||||
return getCreateSQLite(size,
|
||||
"INSERT INTO `" + prefix + "plot_" + tier + "` SELECT ? AS `plot_plot_id`, ? AS `user_uuid`", 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -285,7 +242,7 @@ public class SQLManager implements AbstractDB {
|
||||
public String getCreateSQL() {
|
||||
return CREATE_PLOT;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setMySQL(PreparedStatement stmt, int i, Plot plot) throws SQLException {
|
||||
stmt.setInt((i * 4) + 1, plot.id.x);
|
||||
@ -322,12 +279,12 @@ public class SQLManager implements AbstractDB {
|
||||
};
|
||||
setBulk(myList, mod);
|
||||
}
|
||||
|
||||
|
||||
public <T> void setBulk(ArrayList<T> objList, StmtMod<T> mod) {
|
||||
final int size = objList.size();
|
||||
if (size == 0) {
|
||||
return;
|
||||
}
|
||||
final int size = objList.size();
|
||||
if (size == 0) {
|
||||
return;
|
||||
}
|
||||
int packet;
|
||||
if (Settings.DB.USE_MYSQL) {
|
||||
packet = Math.min(size, 5000);
|
||||
@ -335,7 +292,7 @@ public class SQLManager implements AbstractDB {
|
||||
packet = Math.min(size, 50);
|
||||
}
|
||||
final int amount = size / packet;
|
||||
|
||||
|
||||
try {
|
||||
int count = 0;
|
||||
PreparedStatement preparedStmt = null;
|
||||
@ -360,7 +317,7 @@ public class SQLManager implements AbstractDB {
|
||||
for (int i = 0; i < subList.size(); i++) {
|
||||
count++;
|
||||
final T obj = subList.get(i);
|
||||
mod.setMySQL(preparedStmt, i , obj);
|
||||
mod.setMySQL(preparedStmt, i, obj);
|
||||
}
|
||||
last = subList.size();
|
||||
preparedStmt.addBatch();
|
||||
@ -370,8 +327,7 @@ public class SQLManager implements AbstractDB {
|
||||
preparedStmt.clearParameters();
|
||||
preparedStmt.close();
|
||||
return;
|
||||
}
|
||||
catch (Exception e) {
|
||||
} catch (Exception e) {
|
||||
if (Settings.DB.USE_MYSQL) {
|
||||
e.printStackTrace();
|
||||
PlotSquared.log("&cERROR 1: " + " | " + objList.get(0).getClass().getCanonicalName());
|
||||
@ -395,14 +351,14 @@ public class SQLManager implements AbstractDB {
|
||||
if (subList.size() != last || (count % 5000 == 0 && count > 0)) {
|
||||
preparedStmt.executeBatch();
|
||||
preparedStmt.close();
|
||||
|
||||
|
||||
statement = mod.getCreateSQLite(subList.size());
|
||||
preparedStmt = this.connection.prepareStatement(statement.toString());
|
||||
}
|
||||
for (int i = 0; i < subList.size(); i++) {
|
||||
count++;
|
||||
final T obj = subList.get(i);
|
||||
mod.setSQLite(preparedStmt, i , obj);
|
||||
mod.setSQLite(preparedStmt, i, obj);
|
||||
}
|
||||
last = subList.size();
|
||||
preparedStmt.addBatch();
|
||||
@ -412,18 +368,17 @@ public class SQLManager implements AbstractDB {
|
||||
preparedStmt.clearParameters();
|
||||
preparedStmt.close();
|
||||
return;
|
||||
}
|
||||
catch (Exception e) {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
PlotSquared.log("&cERROR 2: " + " | " + objList.get(0).getClass().getCanonicalName());
|
||||
}
|
||||
|
||||
|
||||
PlotSquared.log("&6[WARN] " + "Could not bulk save!");
|
||||
try {
|
||||
PreparedStatement preparedStmt = null;
|
||||
String nonBulk = mod.getCreateSQL();
|
||||
preparedStmt = this.connection.prepareStatement(nonBulk.toString());
|
||||
for (final T obj : objList) {
|
||||
for (final T obj : objList) {
|
||||
try {
|
||||
mod.setSQL(preparedStmt, obj);
|
||||
preparedStmt.addBatch();
|
||||
@ -434,13 +389,12 @@ public class SQLManager implements AbstractDB {
|
||||
PlotSquared.log("&aBatch 3");
|
||||
preparedStmt.executeBatch();
|
||||
preparedStmt.close();
|
||||
}
|
||||
catch (Exception e3) {
|
||||
} catch (Exception e3) {
|
||||
e3.printStackTrace();
|
||||
PlotSquared.log("&c[ERROR] " + "Failed to save all!");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void createSettings(final ArrayList<SettingsPair> myList) {
|
||||
final StmtMod<SettingsPair> mod = new StmtMod<SettingsPair>() {
|
||||
@Override
|
||||
@ -460,7 +414,7 @@ public class SQLManager implements AbstractDB {
|
||||
|
||||
@Override
|
||||
public void setMySQL(PreparedStatement stmt, int i, SettingsPair pair) throws SQLException {
|
||||
stmt.setInt((i * 10) + 1, pair.id ); // id
|
||||
stmt.setInt((i * 10) + 1, pair.id); // id
|
||||
stmt.setNull((i * 10) + 2, 4); // biome
|
||||
stmt.setNull((i * 10) + 3, 4); // rain
|
||||
stmt.setNull((i * 10) + 4, 4); // custom_time
|
||||
@ -468,14 +422,12 @@ public class SQLManager implements AbstractDB {
|
||||
stmt.setNull((i * 10) + 6, 4); // deny_entry
|
||||
if (pair.settings.getAlias().equals("")) {
|
||||
stmt.setNull((i * 10) + 7, 4);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
stmt.setString((i * 10) + 7, pair.settings.getAlias());
|
||||
}
|
||||
if (pair.settings.flags == null) {
|
||||
stmt.setNull((i * 10) + 8, 4);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
final StringBuilder flag_string = new StringBuilder();
|
||||
int k = 0;
|
||||
for (final Flag flag : pair.settings.flags.values()) {
|
||||
@ -497,8 +449,7 @@ public class SQLManager implements AbstractDB {
|
||||
String position;
|
||||
if (loc.y == 0) {
|
||||
position = "DEFAULT";
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
position = loc.x + "," + loc.y + "," + loc.z;
|
||||
}
|
||||
stmt.setString((i * 10) + 10, position);
|
||||
@ -506,7 +457,7 @@ public class SQLManager implements AbstractDB {
|
||||
|
||||
@Override
|
||||
public void setSQLite(PreparedStatement stmt, int i, SettingsPair pair) throws SQLException {
|
||||
stmt.setInt((i * 10) + 1, pair.id ); // id
|
||||
stmt.setInt((i * 10) + 1, pair.id); // id
|
||||
stmt.setNull((i * 10) + 2, 4); // biome
|
||||
stmt.setNull((i * 10) + 3, 4); // rain
|
||||
stmt.setNull((i * 10) + 4, 4); // custom_time
|
||||
@ -514,14 +465,12 @@ public class SQLManager implements AbstractDB {
|
||||
stmt.setNull((i * 10) + 6, 4); // deny_entry
|
||||
if (pair.settings.getAlias().equals("")) {
|
||||
stmt.setNull((i * 10) + 7, 4);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
stmt.setString((i * 10) + 7, pair.settings.getAlias());
|
||||
}
|
||||
if (pair.settings.flags == null) {
|
||||
stmt.setNull((i * 10) + 8, 4);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
final StringBuilder flag_string = new StringBuilder();
|
||||
int k = 0;
|
||||
for (final Flag flag : pair.settings.flags.values()) {
|
||||
@ -543,8 +492,7 @@ public class SQLManager implements AbstractDB {
|
||||
String position;
|
||||
if (loc.y == 0) {
|
||||
position = "DEFAULT";
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
position = loc.x + "," + loc.y + "," + loc.z;
|
||||
}
|
||||
stmt.setString((i * 10) + 10, position);
|
||||
@ -562,7 +510,7 @@ public class SQLManager implements AbstractDB {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public void createEmptySettings(final ArrayList<Integer> myList) {
|
||||
final StmtMod<Integer> mod = new StmtMod<Integer>() {
|
||||
@Override
|
||||
@ -587,7 +535,7 @@ public class SQLManager implements AbstractDB {
|
||||
|
||||
@Override
|
||||
public void setSQLite(PreparedStatement stmt, int i, Integer id) throws SQLException {
|
||||
stmt.setInt((i * 10) + 1, id );
|
||||
stmt.setInt((i * 10) + 1, id);
|
||||
stmt.setNull((i * 10) + 2, 4);
|
||||
stmt.setNull((i * 10) + 3, 4);
|
||||
stmt.setNull((i * 10) + 4, 4);
|
||||
@ -675,10 +623,9 @@ public class SQLManager implements AbstractDB {
|
||||
public void createTables(final String database) throws SQLException {
|
||||
final String[] tables;
|
||||
if (Settings.ENABLE_CLUSTERS) {
|
||||
tables = new String[] { "plot", "plot_denied", "plot_helpers", "plot_comments", "plot_trusted", "plot_rating", "plot_settings", "cluster" };
|
||||
}
|
||||
else {
|
||||
tables = new String[] { "plot", "plot_denied", "plot_helpers", "plot_comments", "plot_trusted", "plot_rating", "plot_settings" };
|
||||
tables = new String[]{"plot", "plot_denied", "plot_helpers", "plot_comments", "plot_trusted", "plot_rating", "plot_settings", "cluster"};
|
||||
} else {
|
||||
tables = new String[]{"plot", "plot_denied", "plot_helpers", "plot_comments", "plot_trusted", "plot_rating", "plot_settings"};
|
||||
}
|
||||
final DatabaseMetaData meta = connection.getMetaData();
|
||||
int create = 0;
|
||||
@ -693,12 +640,7 @@ public class SQLManager implements AbstractDB {
|
||||
return;
|
||||
}
|
||||
boolean add_constraint;
|
||||
if (create == tables.length) {
|
||||
add_constraint = true;
|
||||
}
|
||||
else {
|
||||
add_constraint = false;
|
||||
}
|
||||
add_constraint = create == tables.length;
|
||||
PlotSquared.log("Creating tables");
|
||||
final boolean mysql = database.equals("mysql");
|
||||
final Statement stmt = this.connection.createStatement();
|
||||
@ -706,7 +648,7 @@ public class SQLManager implements AbstractDB {
|
||||
stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot` (" + "`id` INT(11) NOT NULL AUTO_INCREMENT," + "`plot_id_x` INT(11) NOT NULL," + "`plot_id_z` INT(11) NOT NULL," + "`owner` VARCHAR(40) NOT NULL," + "`world` VARCHAR(45) NOT NULL," + "`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP," + "PRIMARY KEY (`id`)" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=0");
|
||||
stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot_denied` (" + "`plot_plot_id` INT(11) NOT NULL," + "`user_uuid` VARCHAR(40) NOT NULL" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8");
|
||||
stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot_helpers` (" + "`plot_plot_id` INT(11) NOT NULL," + "`user_uuid` VARCHAR(40) NOT NULL" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8");
|
||||
stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot_comments` (" + "`world` VARCHAR(40) NOT NULL, `hashcode` INT(11) NOT NULL," + "`comment` VARCHAR(40) NOT NULL," + "`inbox` VARCHAR(40) NOT NULL," + "`timestamp` INT(11) NOT NULL," + "`sender` VARCHAR(40) NOT NULL" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8");
|
||||
stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot_comments` (" + "`world` VARCHAR(40) NOT NULL, `hashcode` INT(11) NOT NULL," + "`comment` VARCHAR(40) NOT NULL," + "`inbox` VARCHAR(40) NOT NULL," + "`timestamp` INT(11) NOT NULL," + "`sender` VARCHAR(40) NOT NULL" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8");
|
||||
stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot_trusted` (" + "`plot_plot_id` INT(11) NOT NULL," + "`user_uuid` VARCHAR(40) NOT NULL" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8");
|
||||
stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot_settings` (" + " `plot_plot_id` INT(11) NOT NULL," + " `biome` VARCHAR(45) DEFAULT 'FOREST'," + " `rain` INT(1) DEFAULT 0," + " `custom_time` TINYINT(1) DEFAULT '0'," + " `time` INT(11) DEFAULT '8000'," + " `deny_entry` TINYINT(1) DEFAULT '0'," + " `alias` VARCHAR(50) DEFAULT NULL," + " `flags` VARCHAR(512) DEFAULT NULL," + " `merged` INT(11) DEFAULT NULL," + " `position` VARCHAR(50) NOT NULL DEFAULT 'DEFAULT'," + " PRIMARY KEY (`plot_plot_id`)," + " UNIQUE KEY `unique_alias` (`alias`)" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8");
|
||||
stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot_rating` ( `plot_plot_id` INT(11) NOT NULL, `rating` INT(2) NOT NULL, `player` VARCHAR(40) NOT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8");
|
||||
@ -742,7 +684,7 @@ public class SQLManager implements AbstractDB {
|
||||
*/
|
||||
@Override
|
||||
public void delete(final String world, final Plot plot) {
|
||||
PlotSquared.removePlot(world, plot.id, false);
|
||||
PlotSquared.getInstance().removePlot(world, plot.id, false);
|
||||
TaskManager.runTaskAsync(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@ -826,7 +768,7 @@ public class SQLManager implements AbstractDB {
|
||||
}
|
||||
return Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
|
||||
public void updateTables() {
|
||||
try {
|
||||
final DatabaseMetaData data = this.connection.getMetaData();
|
||||
@ -840,15 +782,13 @@ public class SQLManager implements AbstractDB {
|
||||
final Statement statement = this.connection.createStatement();
|
||||
statement.addBatch("DROP TABLE `" + this.prefix + "plot_comments`");
|
||||
if (Settings.DB.USE_MYSQL) {
|
||||
statement.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot_comments` (" + "`world` VARCHAR(40) NOT NULL, `hashcode` INT(11) NOT NULL," + "`comment` VARCHAR(40) NOT NULL," + "`inbox` VARCHAR(40) NOT NULL," + "`timestamp` INT(11) NOT NULL," + "`sender` VARCHAR(40) NOT NULL" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8");
|
||||
}
|
||||
else {
|
||||
statement.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot_comments` (" + "`world` VARCHAR(40) NOT NULL, `hashcode` INT(11) NOT NULL," + "`comment` VARCHAR(40) NOT NULL," + "`inbox` VARCHAR(40) NOT NULL," + "`timestamp` INT(11) NOT NULL," + "`sender` VARCHAR(40) NOT NULL" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8");
|
||||
} else {
|
||||
statement.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot_comments` (" + "`world` VARCHAR(40) NOT NULL, `hashcode` INT(11) NOT NULL," + "`comment` VARCHAR(40) NOT NULL," + "`inbox` VARCHAR(40) NOT NULL, `timestamp` INT(11) NOT NULL," + "`sender` VARCHAR(40) NOT NULL" + ")");
|
||||
}
|
||||
statement.executeBatch();
|
||||
statement.close();
|
||||
}
|
||||
catch (SQLException e) {
|
||||
} catch (SQLException e) {
|
||||
final Statement statement = this.connection.createStatement();
|
||||
statement.addBatch("ALTER IGNORE TABLE `" + this.prefix + "plot_comments` ADD `inbox` VARCHAR(11) DEFAULT `public`");
|
||||
statement.addBatch("ALTER IGNORE TABLE `" + this.prefix + "plot_comments` ADD `timestamp` INT(11) DEFAULT 0");
|
||||
@ -859,8 +799,7 @@ public class SQLManager implements AbstractDB {
|
||||
}
|
||||
}
|
||||
rs.close();
|
||||
}
|
||||
catch (SQLException e) {
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
@ -907,10 +846,10 @@ public class SQLManager implements AbstractDB {
|
||||
user = UUID.fromString(o);
|
||||
uuids.put(o, user);
|
||||
}
|
||||
p = new Plot(plot_id, user, new ArrayList<UUID>(), new ArrayList<UUID>(), new ArrayList<UUID>(), "", null, null, worldname, new boolean[] { false, false, false, false });
|
||||
p = new Plot(plot_id, user, new ArrayList<UUID>(), new ArrayList<UUID>(), new ArrayList<UUID>(), "", null, null, worldname, new boolean[]{false, false, false, false});
|
||||
plots.put(id, p);
|
||||
}
|
||||
|
||||
|
||||
if (Settings.CACHE_RATINGS) {
|
||||
r = stmt.executeQuery("SELECT `plot_plot_id`, `player`, `rating` FROM `" + this.prefix + "plot_rating`");
|
||||
while (r.next()) {
|
||||
@ -923,7 +862,7 @@ public class SQLManager implements AbstractDB {
|
||||
}
|
||||
final Plot plot = plots.get(id);
|
||||
if (plot != null) {
|
||||
if (plot.settings.ratings == null ) {
|
||||
if (plot.settings.ratings == null) {
|
||||
plot.settings.ratings = new HashMap<UUID, Integer>();
|
||||
}
|
||||
plot.settings.ratings.put(user, r.getInt("rating"));
|
||||
@ -932,7 +871,7 @@ public class SQLManager implements AbstractDB {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Getting helpers
|
||||
*/
|
||||
@ -1033,17 +972,17 @@ public class SQLManager implements AbstractDB {
|
||||
}
|
||||
plot.settings.setMerged(merged);
|
||||
} else {
|
||||
plot.settings.setMerged(new boolean[] { false, false, false, false });
|
||||
plot.settings.setMerged(new boolean[]{false, false, false, false});
|
||||
}
|
||||
String[] flags_string;
|
||||
final String myflags = r.getString("flags");
|
||||
if (myflags == null) {
|
||||
flags_string = new String[] {};
|
||||
flags_string = new String[]{};
|
||||
} else {
|
||||
if (myflags.length() > 0) {
|
||||
flags_string = myflags.split(",");
|
||||
} else {
|
||||
flags_string = new String[] {};
|
||||
flags_string = new String[]{};
|
||||
}
|
||||
}
|
||||
final HashMap<String, Flag> flags = new HashMap<>();
|
||||
@ -1064,8 +1003,7 @@ public class SQLManager implements AbstractDB {
|
||||
if (StringUtils.isAlpha(element.replaceAll("_", "").replaceAll("-", ""))) {
|
||||
Flag flag = new Flag(FlagManager.getFlag(element, true), "");
|
||||
flags.put(flag.getKey(), flag);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
PlotSquared.log("INVALID FLAG: " + element);
|
||||
}
|
||||
}
|
||||
@ -1308,11 +1246,11 @@ public class SQLManager implements AbstractDB {
|
||||
purgeIds(world, ids);
|
||||
stmt.close();
|
||||
r.close();
|
||||
for (Iterator<PlotId> iter = plots.iterator(); iter.hasNext();) {
|
||||
for (Iterator<PlotId> iter = plots.iterator(); iter.hasNext(); ) {
|
||||
PlotId plotId = iter.next();
|
||||
iter.remove();
|
||||
PlotId id = new PlotId(plotId.x, plotId.y);
|
||||
PlotSquared.removePlot(world, new PlotId(id.x, id.y), true);
|
||||
PlotSquared.getInstance().removePlot(world, new PlotId(id.x, id.y), true);
|
||||
}
|
||||
} catch (final SQLException e) {
|
||||
e.printStackTrace();
|
||||
@ -1417,7 +1355,7 @@ public class SQLManager implements AbstractDB {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void clearInbox(final Plot plot, final String inbox) {
|
||||
TaskManager.runTaskAsync(new Runnable() {
|
||||
@ -1470,8 +1408,7 @@ public class SQLManager implements AbstractDB {
|
||||
PlotId id;
|
||||
if (hash != 0) {
|
||||
id = PlotId.unpair(hash);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
id = null;
|
||||
}
|
||||
final String msg = set.getString("comment");
|
||||
@ -1653,7 +1590,7 @@ public class SQLManager implements AbstractDB {
|
||||
final PreparedStatement statement = this.connection.prepareStatement("SELECT `rating`, `player` FROM `" + this.prefix + "plot_rating` WHERE `plot_plot_id` = ? ");
|
||||
statement.setInt(1, getId(plot.world, plot.id));
|
||||
final ResultSet set = statement.executeQuery();
|
||||
while(set.next()) {
|
||||
while (set.next()) {
|
||||
UUID uuid = UUID.fromString(set.getString("player"));
|
||||
int rating = set.getInt("rating");
|
||||
map.put(uuid, rating);
|
||||
@ -1666,7 +1603,6 @@ public class SQLManager implements AbstractDB {
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setRating(final Plot plot, final UUID rater, final int value) {
|
||||
@ -1866,17 +1802,17 @@ public class SQLManager implements AbstractDB {
|
||||
}
|
||||
cluster.settings.setMerged(merged);
|
||||
} else {
|
||||
cluster.settings.setMerged(new boolean[] { false, false, false, false });
|
||||
cluster.settings.setMerged(new boolean[]{false, false, false, false});
|
||||
}
|
||||
String[] flags_string;
|
||||
final String myflags = r.getString("flags");
|
||||
if (myflags == null) {
|
||||
flags_string = new String[] {};
|
||||
flags_string = new String[]{};
|
||||
} else {
|
||||
if (myflags.length() > 0) {
|
||||
flags_string = myflags.split(",");
|
||||
} else {
|
||||
flags_string = new String[] {};
|
||||
flags_string = new String[]{};
|
||||
}
|
||||
}
|
||||
final HashMap<String, Flag> flags = new HashMap<>();
|
||||
@ -2184,7 +2120,7 @@ public class SQLManager implements AbstractDB {
|
||||
public boolean deleteTables() {
|
||||
try {
|
||||
SQLManager.this.connection.close();
|
||||
SQLManager.this.connection = PlotSquared.getDatabase().forceConnection();
|
||||
SQLManager.this.connection = PlotSquared.getInstance().getDatabase().forceConnection();
|
||||
final Statement stmt = this.connection.createStatement();
|
||||
stmt.addBatch("DROP TABLE `" + prefix + "cluster_invited`");
|
||||
stmt.addBatch("DROP TABLE `" + prefix + "cluster_helpers`");
|
||||
@ -2198,15 +2134,34 @@ public class SQLManager implements AbstractDB {
|
||||
stmt.executeBatch();
|
||||
stmt.clearBatch();
|
||||
stmt.close();
|
||||
|
||||
|
||||
PreparedStatement statement = connection.prepareStatement("DROP TABLE `" + prefix + "plot`");
|
||||
statement.executeUpdate();
|
||||
statement.close();
|
||||
return true;
|
||||
}
|
||||
catch (Exception e) {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private class UUIDPair {
|
||||
public final int id;
|
||||
public final UUID uuid;
|
||||
|
||||
public UUIDPair(int id, UUID uuid) {
|
||||
this.id = id;
|
||||
this.uuid = uuid;
|
||||
}
|
||||
}
|
||||
|
||||
private class SettingsPair {
|
||||
public final int id;
|
||||
public final PlotSettings settings;
|
||||
|
||||
public SettingsPair(int id, PlotSettings settings) {
|
||||
this.id = id;
|
||||
this.settings = settings;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -20,6 +20,19 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.intellectualcrafters.plot.database.plotme;
|
||||
|
||||
import com.intellectualcrafters.plot.PlotSquared;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
import com.intellectualcrafters.plot.generator.HybridGen;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.WorldCreator;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.Charset;
|
||||
@ -34,20 +47,6 @@ import java.util.HashMap;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.WorldCreator;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import com.intellectualcrafters.plot.PlotSquared;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
import com.intellectualcrafters.plot.generator.HybridGen;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
|
||||
/**
|
||||
* Created 2014-08-17 for PlotSquared
|
||||
*
|
||||
@ -65,6 +64,15 @@ public class LikePlotMeConverter {
|
||||
public LikePlotMeConverter(String plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public static String getWorld(final String world) {
|
||||
for (final World newworld : Bukkit.getWorlds()) {
|
||||
if (newworld.getName().equalsIgnoreCase(world)) {
|
||||
return newworld.getName();
|
||||
}
|
||||
}
|
||||
return world;
|
||||
}
|
||||
|
||||
private void sendMessage(final String message) {
|
||||
PlotSquared.log("&3PlotMe&8->&3PlotSquared&8: &7" + message);
|
||||
@ -89,7 +97,7 @@ public class LikePlotMeConverter {
|
||||
public Set<String> getPlotMeWorlds(FileConfiguration plotConfig) {
|
||||
return plotConfig.getConfigurationSection("worlds").getKeys(false);
|
||||
}
|
||||
|
||||
|
||||
public void updateWorldYml(String plugin, String location) {
|
||||
try {
|
||||
Path path = Paths.get(location);
|
||||
@ -102,37 +110,54 @@ public class LikePlotMeConverter {
|
||||
content = content.replaceAll("PlotMe-DefaultGenerator", "PlotSquared");
|
||||
content = content.replaceAll(plugin, "PlotSquared");
|
||||
Files.write(path, content.getBytes(charset));
|
||||
} catch (Exception e) {};
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void updateWorldYml(String plugin, String location) {
|
||||
try {
|
||||
Path path = Paths.get(location);
|
||||
File file = new File(location);
|
||||
if (!file.exists()) {
|
||||
return;
|
||||
}
|
||||
Charset charset = StandardCharsets.UTF_8;
|
||||
String content = new String(Files.readAllBytes(path), charset);
|
||||
content = content.replaceAll("PlotMe-DefaultGenerator", "PlotSquared");
|
||||
content = content.replaceAll(plugin, "PlotSquared");
|
||||
Files.write(path, content.getBytes(charset));
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean run(final APlotMeConnector connector) {
|
||||
try {
|
||||
String dataFolder = getPlotMePath();
|
||||
FileConfiguration plotConfig = getPlotMeConfig(dataFolder);
|
||||
|
||||
|
||||
if (plotConfig == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Connection connection = connector.getPlotMeConnection(plugin, plotConfig, dataFolder);
|
||||
|
||||
|
||||
if (connection == null) {
|
||||
sendMessage("Cannot connect to PlotMe DB. Conversion process will not continue");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
sendMessage(plugin + " conversion has started. To disable this, please set 'plotme-convert.enabled' in the 'settings.yml'");
|
||||
sendMessage("Connecting to " + plugin + " DB");
|
||||
|
||||
|
||||
int plotCount = 0;
|
||||
final ArrayList<Plot> createdPlots = new ArrayList<>();
|
||||
|
||||
|
||||
sendMessage("Collecting plot data");
|
||||
|
||||
|
||||
String dbPrefix = plugin.toLowerCase();
|
||||
sendMessage(" - " + dbPrefix + "Plots");
|
||||
final Set<String> worlds = getPlotMeWorlds(plotConfig);
|
||||
|
||||
|
||||
sendMessage("Updating bukkit.yml");
|
||||
updateWorldYml(plugin, "bukkit.yml");
|
||||
updateWorldYml(plugin, "plugins/Multiverse-Core/worlds.yml");
|
||||
@ -162,7 +187,7 @@ public class LikePlotMeConverter {
|
||||
sendMessage("&c-- &lFailed to save configuration for world '" + world + "'\nThis will need to be done using the setup command, or manually");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
HashMap<String, HashMap<PlotId, Plot>> plots = connector.getPlotMePlots(connection);
|
||||
for (Entry<String, HashMap<PlotId, Plot>> entry : plots.entrySet()) {
|
||||
plotCount += entry.getValue().size();
|
||||
@ -170,9 +195,9 @@ public class LikePlotMeConverter {
|
||||
if (!Settings.CONVERT_PLOTME) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
sendMessage(" - " + dbPrefix + "Allowed");
|
||||
|
||||
|
||||
sendMessage("Collected " + plotCount + " plots from PlotMe");
|
||||
final File PLOTME_DG_FILE = new File(dataFolder + File.separator + "PlotMe-DefaultGenerator" + File.separator + "config.yml");
|
||||
if (PLOTME_DG_FILE.exists()) {
|
||||
@ -249,7 +274,7 @@ public class LikePlotMeConverter {
|
||||
PlotSquared.log("&c - Disable 'plotme-convert.enabled' and 'plotme-convert.cache-uuids' in the settings.yml");
|
||||
PlotSquared.log("&c - Correct any generator settings that haven't copied to 'settings.yml' properly");
|
||||
PlotSquared.log("&c - Start the server");
|
||||
PlotSquared.setAllPlotsRaw(DBFunc.getPlots());
|
||||
PlotSquared.getInstance().setAllPlotsRaw(DBFunc.getPlots());
|
||||
}
|
||||
});
|
||||
sendMessage("Saving configuration...");
|
||||
@ -276,7 +301,7 @@ public class LikePlotMeConverter {
|
||||
}
|
||||
final String actualWorldName = world.getName();
|
||||
sendMessage("Reloading generator for world: '" + actualWorldName + "'...");
|
||||
PlotSquared.removePlotWorld(actualWorldName);
|
||||
PlotSquared.getInstance().removePlotWorld(actualWorldName);
|
||||
if (MV) {
|
||||
// unload world with MV
|
||||
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mv unload " + actualWorldName);
|
||||
@ -316,13 +341,4 @@ public class LikePlotMeConverter {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static String getWorld(final String world) {
|
||||
for (final World newworld : Bukkit.getWorlds()) {
|
||||
if (newworld.getName().equalsIgnoreCase(world)) {
|
||||
return newworld.getName();
|
||||
}
|
||||
}
|
||||
return world;
|
||||
}
|
||||
}
|
||||
|
@ -20,24 +20,14 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.intellectualcrafters.plot.flag;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import com.intellectualcrafters.plot.PlotSquared;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotCluster;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.PlotSettings;
|
||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
import com.intellectualcrafters.plot.object.*;
|
||||
import com.intellectualcrafters.plot.util.EventUtil;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Flag Manager Utility
|
||||
*
|
||||
@ -101,14 +91,14 @@ public class FlagManager {
|
||||
|
||||
public static boolean addFlag(AbstractFlag af, boolean reserved) {
|
||||
PlotSquared.log(C.PREFIX.s() + "&8 - Adding flag: &7" + af);
|
||||
for (PlotWorld plotworld : PlotSquared.getPlotWorldObjects()) {
|
||||
for (PlotWorld plotworld : PlotSquared.getInstance().getPlotWorldObjects()) {
|
||||
Flag flag = ((HashMap<String, Flag>) plotworld.DEFAULT_FLAGS.clone()).get(af.getKey());
|
||||
if (flag != null) {
|
||||
flag.setKey(af);
|
||||
}
|
||||
}
|
||||
if (PlotSquared.getAllPlotsRaw() != null) {
|
||||
for (final Plot plot : PlotSquared.getPlotsRaw()) {
|
||||
if (PlotSquared.getInstance().getAllPlotsRaw() != null) {
|
||||
for (final Plot plot : PlotSquared.getInstance().getPlotsRaw()) {
|
||||
Flag flag = plot.settings.flags.get(af.getKey());
|
||||
if (flag != null) {
|
||||
flag.setKey(af);
|
||||
@ -125,7 +115,7 @@ public class FlagManager {
|
||||
public static Flag getSettingFlag(final String world, final PlotSettings settings, final String id) {
|
||||
Flag flag = settings.flags.get(id);
|
||||
if (flag == null) {
|
||||
PlotWorld plotworld = PlotSquared.getPlotWorld(world);
|
||||
PlotWorld plotworld = PlotSquared.getInstance().getPlotWorld(world);
|
||||
if (plotworld == null) {
|
||||
return null;
|
||||
}
|
||||
@ -237,7 +227,7 @@ public class FlagManager {
|
||||
}
|
||||
|
||||
public static Collection<Flag> getSettingFlags(final String world, final PlotSettings settings) {
|
||||
PlotWorld plotworld = PlotSquared.getPlotWorld(world);
|
||||
PlotWorld plotworld = PlotSquared.getInstance().getPlotWorld(world);
|
||||
HashMap<String, Flag> map;
|
||||
if (plotworld == null) {
|
||||
map = new HashMap<>();
|
||||
|
@ -1,32 +1,26 @@
|
||||
package com.intellectualcrafters.plot.generator;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Random;
|
||||
|
||||
import com.intellectualcrafters.plot.PlotSquared;
|
||||
import com.intellectualcrafters.plot.object.*;
|
||||
import com.intellectualcrafters.plot.util.ChunkManager;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.intellectualcrafters.plot.util.bukkit.BukkitChunkManager;
|
||||
import com.intellectualcrafters.plot.util.bukkit.BukkitSetBlockManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.generator.BlockPopulator;
|
||||
|
||||
import com.intellectualcrafters.plot.PlotSquared;
|
||||
import com.intellectualcrafters.plot.object.BlockWrapper;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.PlotCluster;
|
||||
import com.intellectualcrafters.plot.object.PlotGenerator;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.PlotLoc;
|
||||
import com.intellectualcrafters.plot.object.PlotManager;
|
||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
import com.intellectualcrafters.plot.object.RegionWrapper;
|
||||
import com.intellectualcrafters.plot.util.ChunkManager;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.intellectualcrafters.plot.util.bukkit.BukkitChunkManager;
|
||||
import com.intellectualcrafters.plot.util.bukkit.BukkitSetBlockManager;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Random;
|
||||
|
||||
public class AugmentedPopulator extends BlockPopulator {
|
||||
public static short[][] x_loc;
|
||||
public static short[][] y_loc;
|
||||
public static short[][] z_loc;
|
||||
public final PlotWorld plotworld;
|
||||
public final PlotManager manager;
|
||||
public final PlotGenerator generator;
|
||||
@ -40,59 +34,11 @@ public class AugmentedPopulator extends BlockPopulator {
|
||||
private final int tx;
|
||||
private final int tz;
|
||||
|
||||
public static void removePopulator(final String worldname, final PlotCluster cluster) {
|
||||
final World world = Bukkit.getWorld(worldname);
|
||||
for (final Iterator<BlockPopulator> iterator = world.getPopulators().iterator(); iterator.hasNext();) {
|
||||
final BlockPopulator populator = iterator.next();
|
||||
if (populator instanceof AugmentedPopulator) {
|
||||
if (((AugmentedPopulator) populator).cluster.equals(cluster)) {
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public BlockWrapper get(final int x, final int z, final int i, final int j, final short[][] r, final boolean c) {
|
||||
final int y = (i << 4) + (j >> 8);
|
||||
final int a = (j - ((y & 0xF) << 8));
|
||||
final int z1 = (a >> 4);
|
||||
final int x1 = a - (z1 << 4);
|
||||
if (r[i] == null) {
|
||||
return (c && (((z + z1) < this.bz) || ((z + z1) > this.tz) || ((x + x1) < this.bx) || ((x + x1) > this.tx))) ? null : new BlockWrapper(x1, y, z1, (short) 0, (byte) 0);
|
||||
} else {
|
||||
return (c && (((z + z1) < this.bz) || ((z + z1) > this.tz) || ((x + x1) < this.bx) || ((x + x1) > this.tx))) ? null : new BlockWrapper(x1, y, z1, r[i][j], (byte) 0);
|
||||
}
|
||||
}
|
||||
|
||||
public static short[][] x_loc;
|
||||
public static short[][] y_loc;
|
||||
public static short[][] z_loc;
|
||||
|
||||
public static void initCache() {
|
||||
if (x_loc == null) {
|
||||
x_loc = new short[16][4096];
|
||||
y_loc = new short[16][4096];
|
||||
z_loc = new short[16][4096];
|
||||
for (int i = 0; i < 16; i++) {
|
||||
int i4 = i << 4;
|
||||
for (int j = 0; j < 4096; j++) {
|
||||
final int y = (i4) + (j >> 8);
|
||||
final int a = (j - ((y & 0xF) << 8));
|
||||
final int z1 = (a >> 4);
|
||||
final int x1 = a - (z1 << 4);
|
||||
x_loc[i][j] = (short) x1;
|
||||
y_loc[i][j] = (short) y;
|
||||
z_loc[i][j] = (short) z1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public AugmentedPopulator(final String world, final PlotGenerator generator, final PlotCluster cluster, final boolean p, final boolean b) {
|
||||
initCache();
|
||||
this.cluster = cluster;
|
||||
this.generator = generator;
|
||||
this.plotworld = PlotSquared.getPlotWorld(world);
|
||||
this.plotworld = PlotSquared.getInstance().getPlotWorld(world);
|
||||
this.manager = generator.getPlotManager();
|
||||
this.p = p;
|
||||
this.b = b;
|
||||
@ -119,6 +65,50 @@ public class AugmentedPopulator extends BlockPopulator {
|
||||
}
|
||||
}
|
||||
|
||||
public static void removePopulator(final String worldname, final PlotCluster cluster) {
|
||||
final World world = Bukkit.getWorld(worldname);
|
||||
for (final Iterator<BlockPopulator> iterator = world.getPopulators().iterator(); iterator.hasNext();) {
|
||||
final BlockPopulator populator = iterator.next();
|
||||
if (populator instanceof AugmentedPopulator) {
|
||||
if (((AugmentedPopulator) populator).cluster.equals(cluster)) {
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void initCache() {
|
||||
if (x_loc == null) {
|
||||
x_loc = new short[16][4096];
|
||||
y_loc = new short[16][4096];
|
||||
z_loc = new short[16][4096];
|
||||
for (int i = 0; i < 16; i++) {
|
||||
int i4 = i << 4;
|
||||
for (int j = 0; j < 4096; j++) {
|
||||
final int y = (i4) + (j >> 8);
|
||||
final int a = (j - ((y & 0xF) << 8));
|
||||
final int z1 = (a >> 4);
|
||||
final int x1 = a - (z1 << 4);
|
||||
x_loc[i][j] = (short) x1;
|
||||
y_loc[i][j] = (short) y;
|
||||
z_loc[i][j] = (short) z1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public BlockWrapper get(final int x, final int z, final int i, final int j, final short[][] r, final boolean c) {
|
||||
final int y = (i << 4) + (j >> 8);
|
||||
final int a = (j - ((y & 0xF) << 8));
|
||||
final int z1 = (a >> 4);
|
||||
final int x1 = a - (z1 << 4);
|
||||
if (r[i] == null) {
|
||||
return (c && (((z + z1) < this.bz) || ((z + z1) > this.tz) || ((x + x1) < this.bx) || ((x + x1) > this.tx))) ? null : new BlockWrapper(x1, y, z1, (short) 0, (byte) 0);
|
||||
} else {
|
||||
return (c && (((z + z1) < this.bz) || ((z + z1) > this.tz) || ((x + x1) < this.bx) || ((x + x1) > this.tx))) ? null : new BlockWrapper(x1, y, z1, r[i][j], (byte) 0);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void populate(final World world, final Random rand, final Chunk chunk) {
|
||||
if (this.plotworld.TERRAIN == 3) {
|
||||
@ -139,7 +129,7 @@ public class AugmentedPopulator extends BlockPopulator {
|
||||
else {
|
||||
data = 0;
|
||||
}
|
||||
BukkitSetBlockManager.setBlockManager.set(world, x, y, z, blocks.get(y), (byte) data);
|
||||
BukkitSetBlockManager.setBlockManager.set(world, x, y, z, blocks.get(y), data);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -163,7 +153,7 @@ public class AugmentedPopulator extends BlockPopulator {
|
||||
int zz = loc.z - Z;
|
||||
if (xx >= 0 && xx < 16) {
|
||||
if (zz >= 0 && zz < 16) {
|
||||
BukkitSetBlockManager.setBlockManager.set(world, xx, y, zz, entry2.getValue(), (byte) data);
|
||||
BukkitSetBlockManager.setBlockManager.set(world, xx, y, zz, entry2.getValue(), data);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -187,11 +177,7 @@ public class AugmentedPopulator extends BlockPopulator {
|
||||
return;
|
||||
}
|
||||
final boolean check;
|
||||
if (!inX1 || !inX2 || !inZ1 || !inZ2) {
|
||||
check = true;
|
||||
} else {
|
||||
check = false;
|
||||
}
|
||||
check = !inX1 || !inX2 || !inZ1 || !inZ2;
|
||||
if (this.plotworld.TERRAIN > 1) {
|
||||
final PlotId plot1 = this.manager.getPlotIdAbs(this.plotworld, x, 0, z);
|
||||
final PlotId plot2 = this.manager.getPlotIdAbs(this.plotworld, x2, 0, z2);
|
||||
|
@ -1,12 +1,13 @@
|
||||
package com.intellectualcrafters.plot.generator;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import com.intellectualcrafters.plot.BukkitMain;
|
||||
import com.intellectualcrafters.plot.PlotSquared;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.object.*;
|
||||
import com.intellectualcrafters.plot.util.ChunkManager;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.intellectualcrafters.plot.util.bukkit.BukkitUtil;
|
||||
import org.apache.commons.lang.mutable.MutableInt;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
@ -14,37 +15,29 @@ import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
import org.bukkit.generator.ChunkGenerator.BiomeGrid;
|
||||
import org.bukkit.material.Directional;
|
||||
import org.bukkit.material.MaterialData;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import com.intellectualcrafters.plot.BukkitMain;
|
||||
import com.intellectualcrafters.plot.PlotSquared;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.object.ChunkLoc;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotAnalysis;
|
||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||
import com.intellectualcrafters.plot.object.PlotGenerator;
|
||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||
import com.intellectualcrafters.plot.util.ChunkManager;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.intellectualcrafters.plot.util.bukkit.BukkitUtil;
|
||||
import java.util.*;
|
||||
|
||||
public class BukkitHybridUtils extends HybridUtils {
|
||||
|
||||
|
||||
public static List<ChunkLoc> regions;
|
||||
public static List<ChunkLoc> chunks = new ArrayList<>();
|
||||
public static String world;
|
||||
private static boolean UPDATE = false;
|
||||
public int task;
|
||||
private long last;
|
||||
|
||||
public double getMean(int[] array) {
|
||||
double count = 0;
|
||||
for (int i : array) {
|
||||
count += i;
|
||||
}
|
||||
return count / array.length;
|
||||
return count / array.length;
|
||||
}
|
||||
|
||||
public double getMean(double[] array) {
|
||||
@ -52,7 +45,7 @@ public class BukkitHybridUtils extends HybridUtils {
|
||||
for (double i : array) {
|
||||
count += i;
|
||||
}
|
||||
return count / array.length;
|
||||
return count / array.length;
|
||||
}
|
||||
|
||||
public double getSD(double[] array, double av) {
|
||||
@ -84,17 +77,17 @@ public class BukkitHybridUtils extends HybridUtils {
|
||||
public void analyzePlot(Plot plot, final RunnableVal<PlotAnalysis> whenDone) {
|
||||
// TODO Auto-generated method stub
|
||||
// int diff, int variety, int verticies, int rotation, int height_sd
|
||||
|
||||
|
||||
/*
|
||||
* diff: compare to base by looping through all blocks
|
||||
* variety: add to hashset for each plotblock
|
||||
* height_sd: loop over all blocks and get top block
|
||||
*
|
||||
*
|
||||
* verticies: store air map and compare with neighbours
|
||||
* for each block check the adjacent
|
||||
* - Store all blocks then go through in second loop
|
||||
* - recheck each block
|
||||
*
|
||||
*
|
||||
*/
|
||||
final World world = Bukkit.getWorld(plot.world);
|
||||
final ChunkGenerator gen = world.getGenerator();
|
||||
@ -114,23 +107,23 @@ public class BukkitHybridUtils extends HybridUtils {
|
||||
final int ctz = tz >> 4;
|
||||
final Random r = new Random();
|
||||
AugmentedPopulator.initCache();
|
||||
|
||||
|
||||
final int width = tx - bx + 1;
|
||||
final int length = tz - bz + 1;
|
||||
|
||||
|
||||
final short[][][] oldblocks = new short[256][width][length];
|
||||
final short[][][] newblocks = new short[256][width][length];
|
||||
|
||||
|
||||
final List<Chunk> chunks = new ArrayList<>();
|
||||
final List<Chunk> processed_chunks = new ArrayList<>();
|
||||
|
||||
|
||||
for (int X = cbx; X <= ctx; X++) {
|
||||
for (int Z = cbz; Z <= ctz; Z++) {
|
||||
Chunk chunk = world.getChunkAt(X, Z);
|
||||
chunks.add(chunk);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
final Runnable run = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@ -163,14 +156,14 @@ public class BukkitHybridUtils extends HybridUtils {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int size = width * length;
|
||||
int[] changes = new int[size];
|
||||
int[] faces = new int[size];
|
||||
int[] data = new int[size];
|
||||
int[] air = new int[size];
|
||||
int[] variety = new int[size];
|
||||
|
||||
|
||||
int i = 0;
|
||||
for (int x = 0; x < width;x++) {
|
||||
for (int z = 0; z < length;z++) {
|
||||
@ -188,7 +181,7 @@ public class BukkitHybridUtils extends HybridUtils {
|
||||
else {
|
||||
// check verticies
|
||||
// modifications_adjacent
|
||||
|
||||
|
||||
if (x > 0 && z > 0 && y > 0 && x < width - 1 && z < length - 1 && y < 255) {
|
||||
if (oldblocks[y - 1][x][z] == 0) faces[i]++;
|
||||
if (oldblocks[y][x - 1][z] == 0) faces[i]++;
|
||||
@ -197,7 +190,7 @@ public class BukkitHybridUtils extends HybridUtils {
|
||||
if (oldblocks[y][x + 1][z] == 0) faces[i]++;
|
||||
if (oldblocks[y][x][z + 1] == 0) faces[i]++;
|
||||
}
|
||||
|
||||
|
||||
Material material = Material.getMaterial(now);
|
||||
Class<? extends MaterialData> md = material.getData();
|
||||
if (md.equals(Directional.class)) {
|
||||
@ -213,10 +206,10 @@ public class BukkitHybridUtils extends HybridUtils {
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// analyze plot
|
||||
// put in analysis obj
|
||||
|
||||
|
||||
// run whenDone
|
||||
PlotAnalysis analysis = new PlotAnalysis();
|
||||
analysis.changes = getMean(changes);
|
||||
@ -229,10 +222,10 @@ public class BukkitHybridUtils extends HybridUtils {
|
||||
whenDone.run();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
System.gc();
|
||||
AugmentedPopulator.initCache();
|
||||
|
||||
|
||||
TaskManager.index.increment();
|
||||
final Integer currentIndex = TaskManager.index.toInteger();
|
||||
final Integer task = TaskManager.runTaskRepeat(new Runnable() {
|
||||
@ -261,29 +254,29 @@ public class BukkitHybridUtils extends HybridUtils {
|
||||
else maxX = 16;
|
||||
if (Z == ctz) maxZ = mod(tz);
|
||||
else maxZ = 16;
|
||||
|
||||
|
||||
int xb = ((X - cbx) << 4) - bx;
|
||||
int zb = ((Z - cbz) << 4) - bz;
|
||||
|
||||
|
||||
for (int x = minX; x <= maxX; x++) {
|
||||
for (int z = minZ; z <= maxZ; z++) {
|
||||
for (int y = 0; y < 256; y++) {
|
||||
Block block = chunk.getBlock(x, y, z);
|
||||
int xx = xb + x;
|
||||
int xx = xb + x;
|
||||
int zz = zb + z;
|
||||
newblocks[y][xx][zz] = (short) block.getTypeId();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}, 1);
|
||||
TaskManager.tasks.put(currentIndex, task);
|
||||
}
|
||||
|
||||
public void checkModified(final Plot plot, final RunnableVal<Integer> whenDone) {
|
||||
TaskManager.index.increment();
|
||||
final Location bot = MainUtil.getPlotBottomLoc(plot.world, plot.id).add(1, 0, 1);
|
||||
final Location top = MainUtil.getPlotTopLoc(plot.world, plot.id);
|
||||
|
||||
public void checkModified(final Plot plot, final RunnableVal<Integer> whenDone) {
|
||||
TaskManager.index.increment();
|
||||
final Location bot = MainUtil.getPlotBottomLoc(plot.world, plot.id).add(1, 0, 1);
|
||||
final Location top = MainUtil.getPlotTopLoc(plot.world, plot.id);
|
||||
int bx = bot.getX() >> 4;
|
||||
int bz = bot.getZ() >> 4;
|
||||
int tx = top.getX() >> 4;
|
||||
@ -295,17 +288,17 @@ public class BukkitHybridUtils extends HybridUtils {
|
||||
chunks.add(world.getChunkAt(X,Z));
|
||||
}
|
||||
}
|
||||
PlotWorld plotworld = PlotSquared.getPlotWorld(plot.world);
|
||||
PlotWorld plotworld = PlotSquared.getInstance().getPlotWorld(plot.world);
|
||||
if (!(plotworld instanceof ClassicPlotWorld)) {
|
||||
whenDone.value = -1;
|
||||
TaskManager.runTaskLater(whenDone, 1);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
final ClassicPlotWorld cpw = (ClassicPlotWorld) plotworld;
|
||||
|
||||
|
||||
final MutableInt count = new MutableInt(0);
|
||||
|
||||
|
||||
final Integer currentIndex = TaskManager.index.toInteger();
|
||||
final Integer task = TaskManager.runTaskRepeat(new Runnable() {
|
||||
@Override
|
||||
@ -333,7 +326,7 @@ public class BukkitHybridUtils extends HybridUtils {
|
||||
TaskManager.tasks.put(currentIndex, task);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int checkModified(final String worldname, final int x1, final int x2, final int y1, final int y2, final int z1, final int z2, final PlotBlock[] blocks) {
|
||||
final World world = BukkitUtil.getWorld(worldname);
|
||||
@ -358,7 +351,7 @@ public class BukkitHybridUtils extends HybridUtils {
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int get_ey(final String worldname, final int sx, final int ex, final int sz, final int ez, final int sy) {
|
||||
final World world = BukkitUtil.getWorld(worldname);
|
||||
@ -399,7 +392,7 @@ public class BukkitHybridUtils extends HybridUtils {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public final ArrayList<ChunkLoc> getChunks(ChunkLoc region) {
|
||||
ArrayList<ChunkLoc> chunks = new ArrayList<ChunkLoc>();
|
||||
final int sx = region.x << 5;
|
||||
@ -411,10 +404,6 @@ public class BukkitHybridUtils extends HybridUtils {
|
||||
}
|
||||
return chunks;
|
||||
}
|
||||
|
||||
private static boolean UPDATE = false;
|
||||
public int task;
|
||||
private long last;
|
||||
|
||||
@Override
|
||||
public boolean scheduleRoadUpdate(final String world, int extend) {
|
||||
@ -426,10 +415,6 @@ public class BukkitHybridUtils extends HybridUtils {
|
||||
return scheduleRoadUpdate(world, regions, extend);
|
||||
}
|
||||
|
||||
public static List<ChunkLoc> regions;
|
||||
public static List<ChunkLoc> chunks = new ArrayList<>();
|
||||
public static String world;
|
||||
|
||||
public boolean scheduleRoadUpdate(final String world, final List<ChunkLoc> rgs, final int extend) {
|
||||
BukkitHybridUtils.regions = rgs;
|
||||
BukkitHybridUtils.world = world;
|
||||
|
@ -1,19 +1,14 @@
|
||||
package com.intellectualcrafters.plot.generator;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
|
||||
import com.intellectualcrafters.plot.PlotSquared;
|
||||
import com.intellectualcrafters.plot.object.*;
|
||||
import com.intellectualcrafters.plot.object.schematic.PlotItem;
|
||||
import com.intellectualcrafters.plot.util.BlockManager;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Biome;
|
||||
|
||||
import com.intellectualcrafters.plot.PlotSquared;
|
||||
import com.intellectualcrafters.plot.object.PlotLoc;
|
||||
import com.intellectualcrafters.plot.object.PlotPopulator;
|
||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
import com.intellectualcrafters.plot.object.PseudoRandom;
|
||||
import com.intellectualcrafters.plot.object.RegionWrapper;
|
||||
import com.intellectualcrafters.plot.object.schematic.PlotItem;
|
||||
import com.intellectualcrafters.plot.util.BlockManager;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
|
||||
/**
|
||||
* @author Citymonstret
|
||||
@ -35,9 +30,9 @@ public class HybridPop extends PlotPopulator {
|
||||
final int plotheight;
|
||||
final byte[] plotfloors;
|
||||
final byte[] filling;
|
||||
private final HybridPlotWorld plotworld;
|
||||
final short pathWidthLower;
|
||||
final short pathWidthUpper;
|
||||
private final HybridPlotWorld plotworld;
|
||||
Biome biome;
|
||||
private long state;
|
||||
private boolean doFilling = false;
|
||||
@ -111,7 +106,7 @@ public class HybridPop extends PlotPopulator {
|
||||
|
||||
@Override
|
||||
public void populate(World world, RegionWrapper requiredRegion, PseudoRandom random, int cx, int cz) {
|
||||
PlotSquared.getPlotManager(world.getName());
|
||||
PlotSquared.getInstance().getPlotManager(world.getName());
|
||||
|
||||
int sx = (short) ((this.X) % this.size);
|
||||
int sz = (short) ((this.Z) % this.size);
|
||||
|
@ -1,24 +1,16 @@
|
||||
package com.intellectualcrafters.plot.generator;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
|
||||
import com.intellectualcrafters.jnbt.CompoundTag;
|
||||
import com.intellectualcrafters.plot.PlotSquared;
|
||||
import com.intellectualcrafters.plot.object.ChunkLoc;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotAnalysis;
|
||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.PlotLoc;
|
||||
import com.intellectualcrafters.plot.object.PlotManager;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||
import com.intellectualcrafters.plot.object.*;
|
||||
import com.intellectualcrafters.plot.util.BlockManager;
|
||||
import com.intellectualcrafters.plot.util.ChunkManager;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.SchematicHandler;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
|
||||
public abstract class HybridUtils {
|
||||
|
||||
public static HybridUtils manager;
|
||||
@ -33,7 +25,7 @@ public abstract class HybridUtils {
|
||||
final String world = plot.world;
|
||||
final Location bot = MainUtil.getPlotBottomLoc(world, plot.id);
|
||||
final Location top = MainUtil.getPlotTopLoc(world, plot.id);
|
||||
final HybridPlotWorld plotworld = (HybridPlotWorld) PlotSquared.getPlotWorld(world);
|
||||
final HybridPlotWorld plotworld = (HybridPlotWorld) PlotSquared.getInstance().getPlotWorld(world);
|
||||
final int sx = (bot.getX() - plotworld.ROAD_WIDTH) + 1;
|
||||
final int sz = bot.getZ() + 1;
|
||||
final int sy = plotworld.ROAD_HEIGHT;
|
||||
@ -69,7 +61,7 @@ public abstract class HybridUtils {
|
||||
final int z = chunk.z << 4;
|
||||
final int ex = x + 15;
|
||||
final int ez = z + 15;
|
||||
final HybridPlotWorld plotworld = (HybridPlotWorld) PlotSquared.getPlotWorld(world);
|
||||
final HybridPlotWorld plotworld = (HybridPlotWorld) PlotSquared.getInstance().getPlotWorld(world);
|
||||
extend = Math.min(extend, 255 - plotworld.ROAD_HEIGHT - plotworld.SCHEMATIC_HEIGHT);
|
||||
if (!plotworld.ROAD_SCHEMATIC_ENABLED) {
|
||||
return false;
|
||||
@ -85,7 +77,7 @@ public abstract class HybridUtils {
|
||||
toCheck = c1 ^ c2;
|
||||
}
|
||||
}
|
||||
final PlotManager manager = PlotSquared.getPlotManager(world);
|
||||
final PlotManager manager = PlotSquared.getInstance().getPlotManager(world);
|
||||
final PlotId id1 = manager.getPlotId(plotworld, x, 0, z);
|
||||
final PlotId id2 = manager.getPlotId(plotworld, ex, 0, ez);
|
||||
if ((id1 == null) || (id2 == null) || (id1 != id2)) {
|
||||
|
@ -1,9 +1,11 @@
|
||||
package com.intellectualcrafters.plot.listeners;
|
||||
|
||||
import com.intellectualcrafters.plot.PlotSquared;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Item;
|
||||
@ -12,19 +14,17 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockFromToEvent;
|
||||
import org.bukkit.event.block.BlockPhysicsEvent;
|
||||
import org.bukkit.event.block.EntityBlockFormEvent;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||
import org.bukkit.event.entity.ItemSpawnEvent;
|
||||
import org.bukkit.event.world.ChunkLoadEvent;
|
||||
import org.bukkit.event.world.ChunkUnloadEvent;
|
||||
|
||||
import com.intellectualcrafters.plot.PlotSquared;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
|
||||
public class ChunkListener implements Listener {
|
||||
|
||||
private Chunk lastChunk = null;
|
||||
private long last = 0;
|
||||
private int count = 0;
|
||||
|
||||
@EventHandler
|
||||
public void onChunkUnload(ChunkUnloadEvent event) {
|
||||
@ -37,9 +37,7 @@ public class ChunkListener implements Listener {
|
||||
public void onChunkLoad(ChunkLoadEvent event) {
|
||||
processChunk(event.getChunk(), false);
|
||||
}
|
||||
|
||||
private Chunk lastChunk = null;
|
||||
|
||||
|
||||
@EventHandler(priority=EventPriority.LOWEST)
|
||||
public void onItemSpawn(ItemSpawnEvent event) {
|
||||
Item entity = event.getEntity();
|
||||
@ -49,7 +47,7 @@ public class ChunkListener implements Listener {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if (!PlotSquared.isPlotWorld(chunk.getWorld().getName())) {
|
||||
if (!PlotSquared.getInstance().isPlotWorld(chunk.getWorld().getName())) {
|
||||
return;
|
||||
}
|
||||
Entity[] entities = chunk.getEntities();
|
||||
@ -63,9 +61,6 @@ public class ChunkListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
private long last = 0;
|
||||
private int count = 0;
|
||||
|
||||
@EventHandler(priority=EventPriority.LOWEST)
|
||||
public void onBlockPhysics(BlockPhysicsEvent event) {
|
||||
long now = System.currentTimeMillis();
|
||||
@ -90,7 +85,7 @@ public class ChunkListener implements Listener {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if (!PlotSquared.isPlotWorld(chunk.getWorld().getName())) {
|
||||
if (!PlotSquared.getInstance().isPlotWorld(chunk.getWorld().getName())) {
|
||||
return;
|
||||
}
|
||||
Entity[] entities = chunk.getEntities();
|
||||
@ -144,7 +139,7 @@ public class ChunkListener implements Listener {
|
||||
}
|
||||
|
||||
public boolean processChunk(Chunk chunk, boolean unload) {
|
||||
if (!PlotSquared.isPlotWorld(chunk.getWorld().getName())) {
|
||||
if (!PlotSquared.getInstance().isPlotWorld(chunk.getWorld().getName())) {
|
||||
return false;
|
||||
}
|
||||
Entity[] entities = chunk.getEntities();
|
||||
|
@ -1,91 +1,5 @@
|
||||
package com.intellectualcrafters.plot.listeners;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.command.PluginCommand;
|
||||
import org.bukkit.entity.Animals;
|
||||
import org.bukkit.entity.Arrow;
|
||||
import org.bukkit.entity.Creature;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.FallingBlock;
|
||||
import org.bukkit.entity.HumanEntity;
|
||||
import org.bukkit.entity.ItemFrame;
|
||||
import org.bukkit.entity.Monster;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Projectile;
|
||||
import org.bukkit.entity.Tameable;
|
||||
import org.bukkit.entity.ThrownPotion;
|
||||
import org.bukkit.entity.Vehicle;
|
||||
import org.bukkit.entity.minecart.RideableMinecart;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockDamageEvent;
|
||||
import org.bukkit.event.block.BlockFadeEvent;
|
||||
import org.bukkit.event.block.BlockFormEvent;
|
||||
import org.bukkit.event.block.BlockFromToEvent;
|
||||
import org.bukkit.event.block.BlockGrowEvent;
|
||||
import org.bukkit.event.block.BlockIgniteEvent;
|
||||
import org.bukkit.event.block.BlockPhysicsEvent;
|
||||
import org.bukkit.event.block.BlockPistonExtendEvent;
|
||||
import org.bukkit.event.block.BlockPistonRetractEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.block.BlockRedstoneEvent;
|
||||
import org.bukkit.event.block.BlockSpreadEvent;
|
||||
import org.bukkit.event.block.EntityBlockFormEvent;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||
import org.bukkit.event.entity.EntityChangeBlockEvent;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
import org.bukkit.event.entity.ProjectileHitEvent;
|
||||
import org.bukkit.event.hanging.HangingBreakByEntityEvent;
|
||||
import org.bukkit.event.hanging.HangingPlaceEvent;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
import org.bukkit.event.player.PlayerBucketEmptyEvent;
|
||||
import org.bukkit.event.player.PlayerBucketFillEvent;
|
||||
import org.bukkit.event.player.PlayerChangedWorldEvent;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.event.player.PlayerEggThrowEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
import org.bukkit.event.vehicle.VehicleCreateEvent;
|
||||
import org.bukkit.event.vehicle.VehicleDestroyEvent;
|
||||
import org.bukkit.event.world.ChunkLoadEvent;
|
||||
import org.bukkit.event.world.StructureGrowEvent;
|
||||
import org.bukkit.inventory.InventoryView;
|
||||
import org.bukkit.material.MaterialData;
|
||||
import org.bukkit.material.Tree;
|
||||
import org.bukkit.material.Wool;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
import org.bukkit.projectiles.BlockProjectileSource;
|
||||
import org.bukkit.projectiles.ProjectileSource;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import com.intellectualcrafters.plot.PlotSquared;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
@ -93,25 +7,41 @@ import com.intellectualcrafters.plot.database.DBFunc;
|
||||
import com.intellectualcrafters.plot.flag.Flag;
|
||||
import com.intellectualcrafters.plot.flag.FlagManager;
|
||||
import com.intellectualcrafters.plot.listeners.worldedit.WEManager;
|
||||
import com.intellectualcrafters.plot.object.BukkitPlayer;
|
||||
import com.intellectualcrafters.plot.object.*;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||
import com.intellectualcrafters.plot.object.PlotHandler;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.PlotInventory;
|
||||
import com.intellectualcrafters.plot.object.PlotManager;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
import com.intellectualcrafters.plot.object.StringWrapper;
|
||||
import com.intellectualcrafters.plot.util.ChunkManager;
|
||||
import com.intellectualcrafters.plot.util.EventUtil;
|
||||
import com.intellectualcrafters.plot.util.ExpireManager;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.intellectualcrafters.plot.util.*;
|
||||
import com.intellectualcrafters.plot.util.bukkit.BukkitUtil;
|
||||
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.command.PluginCommand;
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.entity.minecart.RideableMinecart;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.*;
|
||||
import org.bukkit.event.entity.*;
|
||||
import org.bukkit.event.hanging.HangingBreakByEntityEvent;
|
||||
import org.bukkit.event.hanging.HangingPlaceEvent;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||
import org.bukkit.event.player.*;
|
||||
import org.bukkit.event.vehicle.VehicleCreateEvent;
|
||||
import org.bukkit.event.vehicle.VehicleDestroyEvent;
|
||||
import org.bukkit.event.world.ChunkLoadEvent;
|
||||
import org.bukkit.event.world.StructureGrowEvent;
|
||||
import org.bukkit.material.MaterialData;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
import org.bukkit.projectiles.BlockProjectileSource;
|
||||
import org.bukkit.projectiles.ProjectileSource;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Player Events involving plots
|
||||
@ -121,11 +51,37 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
||||
*/
|
||||
public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotListener implements Listener {
|
||||
|
||||
private boolean pistonBlocks = true;
|
||||
|
||||
public static void sendBlockChange(final org.bukkit.Location bloc, final Material type, final byte data) {
|
||||
TaskManager.runTaskLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
String world = bloc.getWorld().getName();
|
||||
int x = bloc.getBlockX();
|
||||
int z = bloc.getBlockZ();
|
||||
int distance = Bukkit.getViewDistance() * 16;
|
||||
for (PlotPlayer player : UUIDHandler.players.values()) {
|
||||
Location loc = player.getLocation();
|
||||
if (loc.getWorld().equals(world)) {
|
||||
if (16 * (Math.abs(loc.getX() - x) / 16) > distance) {
|
||||
continue;
|
||||
}
|
||||
if (16 * (Math.abs(loc.getZ() - z) / 16) > distance) {
|
||||
continue;
|
||||
}
|
||||
((BukkitPlayer) player).player.sendBlockChange(bloc, type, data);
|
||||
}
|
||||
}
|
||||
}
|
||||
}, 3);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onRedstoneEvent(BlockRedstoneEvent event) {
|
||||
Block block = event.getBlock();
|
||||
Location loc = BukkitUtil.getLocation(block.getLocation());
|
||||
if (!PlotSquared.isPlotWorld(loc.getWorld())) {
|
||||
if (!PlotSquared.getInstance().isPlotWorld(loc.getWorld())) {
|
||||
return;
|
||||
}
|
||||
Plot plot = MainUtil.getPlot(loc);
|
||||
@ -184,35 +140,11 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
||||
event.setNewCurrent(0);
|
||||
}
|
||||
|
||||
public static void sendBlockChange(final org.bukkit.Location bloc, final Material type, final byte data) {
|
||||
TaskManager.runTaskLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
String world = bloc.getWorld().getName();
|
||||
int x = bloc.getBlockX();
|
||||
int z = bloc.getBlockZ();
|
||||
int distance = Bukkit.getViewDistance() * 16;
|
||||
for (PlotPlayer player : UUIDHandler.players.values()) {
|
||||
Location loc = player.getLocation();
|
||||
if (loc.getWorld().equals(world)) {
|
||||
if (16 * (Math.abs(loc.getX() - x)/16) > distance) {
|
||||
continue;
|
||||
}
|
||||
if (16 * (Math.abs(loc.getZ() - z)/16) > distance) {
|
||||
continue;
|
||||
}
|
||||
((BukkitPlayer) player).player.sendBlockChange(bloc, type, data);
|
||||
}
|
||||
}
|
||||
}
|
||||
}, 3);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPhysicsEvent(BlockPhysicsEvent event) {
|
||||
Block block = event.getBlock();
|
||||
Location loc = BukkitUtil.getLocation(block.getLocation());
|
||||
if (!PlotSquared.isPlotWorld(loc.getWorld())) {
|
||||
if (!PlotSquared.getInstance().isPlotWorld(loc.getWorld())) {
|
||||
return;
|
||||
}
|
||||
switch (block.getType()) {
|
||||
@ -244,12 +176,11 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void onProjectileHit(ProjectileHitEvent event) {
|
||||
Projectile entity = (Projectile) event.getEntity();
|
||||
Projectile entity = event.getEntity();
|
||||
Location loc = BukkitUtil.getLocation(entity);
|
||||
if (!PlotSquared.isPlotWorld(loc.getWorld())) {
|
||||
if (!PlotSquared.getInstance().isPlotWorld(loc.getWorld())) {
|
||||
return;
|
||||
}
|
||||
Plot plot = MainUtil.getPlot(loc);
|
||||
@ -286,7 +217,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
||||
entity.remove();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void PlayerCommand(final PlayerCommandPreprocessEvent event) {
|
||||
final String message = event.getMessage().toLowerCase().replaceAll("/", "");
|
||||
@ -360,7 +291,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
||||
TaskManager.TELEPORT_QUEUE.remove(player.getName());
|
||||
}
|
||||
final String worldname = t.getWorld();
|
||||
if (!PlotSquared.isPlotWorld(worldname)) {
|
||||
if (!PlotSquared.getInstance().isPlotWorld(worldname)) {
|
||||
return;
|
||||
}
|
||||
if (MainUtil.worldBorder.containsKey(worldname)) {
|
||||
@ -405,7 +336,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
||||
if (!plot.equals(MainUtil.getPlot(f))) {
|
||||
plotEntry(pp, plot);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (MainUtil.leftPlot(f, t)) {
|
||||
plot = MainUtil.getPlot(f);
|
||||
plotExit(BukkitUtil.getPlayer(player), plot);
|
||||
@ -417,10 +348,10 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
||||
public void onChat(final AsyncPlayerChatEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
final String world = player.getWorld().getName();
|
||||
if (!PlotSquared.isPlotWorld(world)) {
|
||||
if (!PlotSquared.getInstance().isPlotWorld(world)) {
|
||||
return;
|
||||
}
|
||||
final PlotWorld plotworld = PlotSquared.getPlotWorld(world);
|
||||
final PlotWorld plotworld = PlotSquared.getInstance().getPlotWorld(world);
|
||||
final PlotPlayer plr = BukkitUtil.getPlayer(player);
|
||||
if (!plotworld.PLOT_CHAT && (plr.getMeta("chat") == null || !(Boolean) plr.getMeta("chat"))) {
|
||||
return;
|
||||
@ -450,7 +381,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
||||
public void BlockDestroy(final BlockBreakEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
final String world = player.getWorld().getName();
|
||||
if (!PlotSquared.isPlotWorld(world)) {
|
||||
if (!PlotSquared.getInstance().isPlotWorld(world)) {
|
||||
return;
|
||||
}
|
||||
final Location loc = BukkitUtil.getLocation(event.getBlock().getLocation());
|
||||
@ -500,7 +431,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
||||
public void onBigBoom(final EntityExplodeEvent event) {
|
||||
Location loc = BukkitUtil.getLocation(event.getLocation());
|
||||
final String world = loc.getWorld();
|
||||
if (!PlotSquared.isPlotWorld(world)) {
|
||||
if (!PlotSquared.getInstance().isPlotWorld(world)) {
|
||||
return;
|
||||
}
|
||||
final Plot plot = MainUtil.getPlot(loc);
|
||||
@ -547,7 +478,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onPeskyMobsChangeTheWorldLikeWTFEvent(final EntityChangeBlockEvent event) {
|
||||
final String world = event.getBlock().getWorld().getName();
|
||||
if (!PlotSquared.isPlotWorld(world)) {
|
||||
if (!PlotSquared.getInstance().isPlotWorld(world)) {
|
||||
return;
|
||||
}
|
||||
final Entity e = event.getEntity();
|
||||
@ -597,7 +528,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onEntityBlockForm(final EntityBlockFormEvent e) {
|
||||
final String world = e.getBlock().getWorld().getName();
|
||||
if (!PlotSquared.isPlotWorld(world)) {
|
||||
if (!PlotSquared.getInstance().isPlotWorld(world)) {
|
||||
return;
|
||||
}
|
||||
if ((!(e.getEntity() instanceof Player))) {
|
||||
@ -611,7 +542,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
||||
public void onBS(final BlockSpreadEvent e) {
|
||||
final Block b = e.getBlock();
|
||||
final Location loc = BukkitUtil.getLocation(b.getLocation());
|
||||
if (PlotSquared.isPlotWorld(loc.getWorld())) {
|
||||
if (PlotSquared.getInstance().isPlotWorld(loc.getWorld())) {
|
||||
if (MainUtil.isPlotRoad(loc)) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
@ -622,7 +553,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
||||
public void onBF(final BlockFormEvent e) {
|
||||
final Block b = e.getBlock();
|
||||
final Location loc = BukkitUtil.getLocation(b.getLocation());
|
||||
if (PlotSquared.isPlotWorld(loc.getWorld())) {
|
||||
if (PlotSquared.getInstance().isPlotWorld(loc.getWorld())) {
|
||||
if (MainUtil.isPlotRoad(loc)) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
@ -634,14 +565,14 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
||||
final Player player = event.getPlayer();
|
||||
if (player == null) {
|
||||
final Location loc = BukkitUtil.getLocation(event.getBlock().getLocation());
|
||||
if (PlotSquared.isPlotWorld(loc.getWorld())) {
|
||||
if (PlotSquared.getInstance().isPlotWorld(loc.getWorld())) {
|
||||
if (MainUtil.isPlotRoad(loc)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
final String world = player.getWorld().getName();
|
||||
if (!PlotSquared.isPlotWorld(world)) {
|
||||
if (!PlotSquared.getInstance().isPlotWorld(world)) {
|
||||
return;
|
||||
}
|
||||
final Location loc = BukkitUtil.getLocation(event.getBlock().getLocation());
|
||||
@ -691,7 +622,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
||||
public void onFade(final BlockFadeEvent e) {
|
||||
final Block b = e.getBlock();
|
||||
final Location loc = BukkitUtil.getLocation(b.getLocation());
|
||||
if (PlotSquared.isPlotWorld(loc.getWorld())) {
|
||||
if (PlotSquared.getInstance().isPlotWorld(loc.getWorld())) {
|
||||
if (MainUtil.isPlotRoad(loc)) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
@ -702,7 +633,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
||||
public void onChange(final BlockFromToEvent e) {
|
||||
final Block b = e.getToBlock();
|
||||
final Location loc = BukkitUtil.getLocation(b.getLocation());
|
||||
if (PlotSquared.isPlotWorld(loc.getWorld())) {
|
||||
if (PlotSquared.getInstance().isPlotWorld(loc.getWorld())) {
|
||||
if (MainUtil.isPlotRoad(loc)) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
@ -719,7 +650,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
||||
public void onGrow(final BlockGrowEvent e) {
|
||||
final Block b = e.getBlock();
|
||||
final Location loc = BukkitUtil.getLocation(b.getLocation());
|
||||
if (PlotSquared.isPlotWorld(loc.getWorld())) {
|
||||
if (PlotSquared.getInstance().isPlotWorld(loc.getWorld())) {
|
||||
if (MainUtil.isPlotRoad(loc)) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
@ -731,7 +662,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
||||
final Block block = event.getBlock();
|
||||
Location loc = BukkitUtil.getLocation(block.getLocation());
|
||||
String world = loc.getWorld();
|
||||
if (!PlotSquared.isPlotWorld(world)) {
|
||||
if (!PlotSquared.getInstance().isPlotWorld(world)) {
|
||||
return;
|
||||
}
|
||||
Plot plot = MainUtil.getPlot(loc);
|
||||
@ -767,15 +698,13 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean pistonBlocks = true;
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onBlockPistonRetract(final BlockPistonRetractEvent event) {
|
||||
final Block block = event.getBlock();
|
||||
Location loc = BukkitUtil.getLocation(block.getLocation());
|
||||
String world = loc.getWorld();
|
||||
if (!PlotSquared.isPlotWorld(world)) {
|
||||
if (!PlotSquared.getInstance().isPlotWorld(world)) {
|
||||
return;
|
||||
}
|
||||
if (block.getType() != Material.PISTON_STICKY_BASE && block.getType() != Material.PISTON_BASE && block.getType() != Material.PISTON_MOVING_PIECE) {
|
||||
@ -811,7 +740,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onStructureGrow(final StructureGrowEvent e) {
|
||||
if (!PlotSquared.isPlotWorld(e.getWorld().getName())) {
|
||||
if (!PlotSquared.getInstance().isPlotWorld(e.getWorld().getName())) {
|
||||
return;
|
||||
}
|
||||
final List<BlockState> blocks = e.getBlocks();
|
||||
@ -837,6 +766,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
||||
return;
|
||||
}
|
||||
Material type = block.getType();
|
||||
|
||||
if (action == Action.RIGHT_CLICK_BLOCK && type.isSolid() && type.isBlock() && type.isOccluding() && !type.isBurnable()) {
|
||||
BlockState state = block.getState();
|
||||
if (state.getData().getClass().equals(MaterialData.class)) {
|
||||
@ -848,7 +778,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
||||
}
|
||||
final Player player = event.getPlayer();
|
||||
final String world = player.getWorld().getName();
|
||||
if (!PlotSquared.isPlotWorld(world)) {
|
||||
if (!PlotSquared.getInstance().isPlotWorld(world)) {
|
||||
return;
|
||||
}
|
||||
final Location loc = BukkitUtil.getLocation(event.getClickedBlock().getLocation());
|
||||
@ -866,6 +796,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
final Flag use = FlagManager.getPlotFlag(plot, "use");
|
||||
if ((use != null) && ((HashSet<PlotBlock>) use.getValue()).contains(new PlotBlock((short) block.getTypeId(), block.getData()))) {
|
||||
return;
|
||||
@ -904,13 +835,13 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
||||
}
|
||||
final Location loc = BukkitUtil.getLocation(event.getLocation());
|
||||
final String world = loc.getWorld();
|
||||
if (!PlotSquared.isPlotWorld(world)) {
|
||||
if (!PlotSquared.getInstance().isPlotWorld(world)) {
|
||||
return;
|
||||
}
|
||||
if (!MainUtil.isPlotArea(loc)) {
|
||||
return;
|
||||
}
|
||||
final PlotWorld pW = PlotSquared.getPlotWorld(world);
|
||||
final PlotWorld pW = PlotSquared.getInstance().getPlotWorld(world);
|
||||
final CreatureSpawnEvent.SpawnReason reason = event.getSpawnReason();
|
||||
if ((reason == CreatureSpawnEvent.SpawnReason.SPAWNER_EGG || reason == CreatureSpawnEvent.SpawnReason.DISPENSE_EGG) && !pW.SPAWN_EGGS) {
|
||||
event.setCancelled(true);
|
||||
@ -922,6 +853,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
Plot plot = MainUtil.getPlot(loc);
|
||||
if (checkEntity(entity, plot)) {
|
||||
event.setCancelled(true);
|
||||
@ -936,7 +868,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
||||
Block block = event.getBlock();
|
||||
World world = block.getWorld();
|
||||
String worldname = world.getName();
|
||||
if (!PlotSquared.isPlotWorld(worldname)) {
|
||||
if (!PlotSquared.getInstance().isPlotWorld(worldname)) {
|
||||
return;
|
||||
}
|
||||
Location loc = BukkitUtil.getLocation(block.getLocation());
|
||||
@ -1034,7 +966,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
if (!PlotSquared.isPlotWorld(world)) {
|
||||
if (!PlotSquared.getInstance().isPlotWorld(world)) {
|
||||
return;
|
||||
}
|
||||
if (e.getCause() == BlockIgniteEvent.IgniteCause.LIGHTNING) {
|
||||
@ -1090,7 +1022,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
||||
final Location t = BukkitUtil.getLocation(event.getTo());
|
||||
final Location q = new Location(t.getWorld(), t.getX(), 64, t.getZ());
|
||||
final Player player = event.getPlayer();
|
||||
if (PlotSquared.isPlotWorld(q.getWorld())) {
|
||||
if (PlotSquared.getInstance().isPlotWorld(q.getWorld())) {
|
||||
final Plot plot = MainUtil.getPlot(q);
|
||||
if (plot != null) {
|
||||
final PlotPlayer pp = BukkitUtil.getPlayer(player);
|
||||
@ -1124,7 +1056,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
||||
final BlockFace bf = e.getBlockFace();
|
||||
final Block b = e.getBlockClicked().getLocation().add(bf.getModX(), bf.getModY(), bf.getModZ()).getBlock();
|
||||
final Location loc = BukkitUtil.getLocation(b.getLocation());
|
||||
if (PlotSquared.isPlotWorld(loc.getWorld())) {
|
||||
if (PlotSquared.getInstance().isPlotWorld(loc.getWorld())) {
|
||||
final PlotPlayer pp = BukkitUtil.getPlayer(e.getPlayer());
|
||||
Plot plot = MainUtil.getPlot(loc);
|
||||
if (plot == null) {
|
||||
@ -1200,8 +1132,8 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
||||
if (Settings.DELETE_PLOTS_ON_BAN && event.getPlayer().isBanned()) {
|
||||
final Collection<Plot> plots = PlotSquared.getPlots(pp.getName()).values();
|
||||
for (final Plot plot : plots) {
|
||||
final PlotWorld plotworld = PlotSquared.getPlotWorld(plot.world);
|
||||
final PlotManager manager = PlotSquared.getPlotManager(plot.world);
|
||||
final PlotWorld plotworld = PlotSquared.getInstance().getPlotWorld(plot.world);
|
||||
final PlotManager manager = PlotSquared.getInstance().getPlotManager(plot.world);
|
||||
manager.clearPlot(plotworld, plot, true, null);
|
||||
DBFunc.delete(plot.world, plot);
|
||||
PlotSquared.log(String.format("&cPlot &6%s &cwas deleted + cleared due to &6%s&c getting banned", plot.getId(), event.getPlayer().getName()));
|
||||
@ -1214,7 +1146,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
||||
public void onBucketFill(final PlayerBucketFillEvent e) {
|
||||
final Block b = e.getBlockClicked();
|
||||
final Location loc = BukkitUtil.getLocation(b.getLocation());
|
||||
if (PlotSquared.isPlotWorld(loc.getWorld())) {
|
||||
if (PlotSquared.getInstance().isPlotWorld(loc.getWorld())) {
|
||||
final Player p = e.getPlayer();
|
||||
final PlotPlayer pp = BukkitUtil.getPlayer(p);
|
||||
Plot plot = MainUtil.getPlot(loc);
|
||||
@ -1258,7 +1190,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
||||
public void onHangingPlace(final HangingPlaceEvent e) {
|
||||
final Block b = e.getBlock();
|
||||
final Location loc = BukkitUtil.getLocation(b.getLocation());
|
||||
if (PlotSquared.isPlotWorld(loc.getWorld())) {
|
||||
if (PlotSquared.getInstance().isPlotWorld(loc.getWorld())) {
|
||||
final Player p = e.getPlayer();
|
||||
final PlotPlayer pp = BukkitUtil.getPlayer(p);
|
||||
Plot plot = MainUtil.getPlot(loc);
|
||||
@ -1300,7 +1232,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
||||
final Player p = (Player) r;
|
||||
final Location l = BukkitUtil.getLocation(e.getEntity());
|
||||
final PlotPlayer pp = BukkitUtil.getPlayer(p);
|
||||
if (PlotSquared.isPlotWorld(l.getWorld())) {
|
||||
if (PlotSquared.getInstance().isPlotWorld(l.getWorld())) {
|
||||
Plot plot = MainUtil.getPlot(l);
|
||||
if (plot == null) {
|
||||
if (MainUtil.isPlotAreaAbs(l)) {
|
||||
@ -1337,7 +1269,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onPlayerInteractEntity(final PlayerInteractEntityEvent e) {
|
||||
final Location l = BukkitUtil.getLocation(e.getRightClicked().getLocation());
|
||||
if (PlotSquared.isPlotWorld(l.getWorld())) {
|
||||
if (PlotSquared.getInstance().isPlotWorld(l.getWorld())) {
|
||||
final Player p = e.getPlayer();
|
||||
final PlotPlayer pp = BukkitUtil.getPlayer(p);
|
||||
Plot plot = MainUtil.getPlot(l);
|
||||
@ -1396,11 +1328,11 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onVehicleDestroy(final VehicleDestroyEvent e) {
|
||||
final Location l = BukkitUtil.getLocation(e.getVehicle());
|
||||
if (PlotSquared.isPlotWorld(l.getWorld())) {
|
||||
if (PlotSquared.getInstance().isPlotWorld(l.getWorld())) {
|
||||
final Entity d = e.getAttacker();
|
||||
if (d instanceof Player) {
|
||||
final Player p = (Player) d;
|
||||
PlotSquared.getPlotWorld(l.getWorld());
|
||||
PlotSquared.getInstance().getPlotWorld(l.getWorld());
|
||||
final PlotPlayer pp = BukkitUtil.getPlayer(p);
|
||||
Plot plot = MainUtil.getPlot(l);
|
||||
if (plot == null) {
|
||||
@ -1450,7 +1382,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
||||
TaskManager.TELEPORT_QUEUE.remove(name);
|
||||
}
|
||||
}
|
||||
if (PlotSquared.isPlotWorld(l.getWorld())) {
|
||||
if (PlotSquared.getInstance().isPlotWorld(l.getWorld())) {
|
||||
Player p = null;
|
||||
Projectile projectile = null;
|
||||
if (damager instanceof Player) {
|
||||
@ -1489,7 +1421,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
||||
}
|
||||
if (p != null) {
|
||||
final boolean aPlr = victim instanceof Player;
|
||||
final PlotWorld pW = PlotSquared.getPlotWorld(l.getWorld());
|
||||
final PlotWorld pW = PlotSquared.getInstance().getPlotWorld(l.getWorld());
|
||||
if (!aPlr && pW.PVE && (!(victim instanceof ItemFrame) && !(victim.getType().getTypeId() == 30))) {
|
||||
return;
|
||||
} else if (aPlr && pW.PVP) {
|
||||
@ -1559,7 +1491,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onPlayerEggThrow(final PlayerEggThrowEvent e) {
|
||||
final Location l = BukkitUtil.getLocation(e.getEgg().getLocation());
|
||||
if (PlotSquared.isPlotWorld(l.getWorld())) {
|
||||
if (PlotSquared.getInstance().isPlotWorld(l.getWorld())) {
|
||||
final Player p = e.getPlayer();
|
||||
final PlotPlayer pp = BukkitUtil.getPlayer(p);
|
||||
Plot plot = MainUtil.getPlot(l);
|
||||
@ -1596,7 +1528,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
||||
public void BlockCreate(final BlockPlaceEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
final String world = player.getWorld().getName();
|
||||
if (!PlotSquared.isPlotWorld(world)) {
|
||||
if (!PlotSquared.getInstance().isPlotWorld(world)) {
|
||||
return;
|
||||
}
|
||||
final PlotPlayer pp = BukkitUtil.getPlayer(player);
|
||||
|
@ -1,9 +1,13 @@
|
||||
package com.intellectualcrafters.plot.listeners;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.intellectualcrafters.plot.PlotSquared;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.intellectualcrafters.plot.util.bukkit.BukkitUtil;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.entity.ArmorStand;
|
||||
@ -20,14 +24,9 @@ import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import com.intellectualcrafters.plot.PlotSquared;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.intellectualcrafters.plot.util.bukkit.BukkitUtil;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class PlayerEvents_1_8 extends PlotListener implements Listener {
|
||||
|
||||
@ -37,7 +36,7 @@ public class PlayerEvents_1_8 extends PlotListener implements Listener {
|
||||
return;
|
||||
}
|
||||
HumanEntity entity = event.getWhoClicked();
|
||||
if (!(entity instanceof Player) || !PlotSquared.isPlotWorld(entity.getWorld().getName())) {
|
||||
if (!(entity instanceof Player) || !PlotSquared.getInstance().isPlotWorld(entity.getWorld().getName())) {
|
||||
return;
|
||||
}
|
||||
Player player = (Player) entity;
|
||||
@ -124,7 +123,7 @@ public class PlayerEvents_1_8 extends PlotListener implements Listener {
|
||||
}
|
||||
final Location l = BukkitUtil.getLocation(e.getRightClicked().getLocation());
|
||||
String world = l.getWorld();
|
||||
if (!PlotSquared.isPlotWorld(world)) {
|
||||
if (!PlotSquared.getInstance().isPlotWorld(world)) {
|
||||
return;
|
||||
}
|
||||
Plot plot = MainUtil.getPlot(l);
|
||||
|
@ -1,19 +1,18 @@
|
||||
package com.intellectualcrafters.plot.listeners;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockExplodeEvent;
|
||||
|
||||
import com.intellectualcrafters.plot.PlotSquared;
|
||||
import com.intellectualcrafters.plot.flag.FlagManager;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.bukkit.BukkitUtil;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockExplodeEvent;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
public class PlayerEvents_1_8_3 implements Listener {
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
@ -21,7 +20,7 @@ public class PlayerEvents_1_8_3 implements Listener {
|
||||
Block block = event.getBlock();
|
||||
Location loc = BukkitUtil.getLocation(block.getLocation());
|
||||
final String world = loc.getWorld();
|
||||
if (!PlotSquared.isPlotWorld(world)) {
|
||||
if (!PlotSquared.getInstance().isPlotWorld(world)) {
|
||||
return;
|
||||
}
|
||||
final Plot plot = MainUtil.getPlot(loc);
|
||||
|
@ -20,17 +20,6 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.intellectualcrafters.plot.listeners;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.WeatherType;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.intellectualcrafters.plot.PlotSquared;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
@ -47,6 +36,11 @@ import com.intellectualcrafters.plot.titles.AbstractTitle;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.bukkit.BukkitUtil;
|
||||
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author Citymonstret
|
||||
@ -54,7 +48,7 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
||||
*/
|
||||
public class PlotListener extends APlotListener {
|
||||
public void textures(final Player p) {
|
||||
if ((Settings.PLOT_SPECIFIC_RESOURCE_PACK.length() > 1) && PlotSquared.isPlotWorld(p.getWorld().getName())) {
|
||||
if ((Settings.PLOT_SPECIFIC_RESOURCE_PACK.length() > 1) && PlotSquared.getInstance().isPlotWorld(p.getWorld().getName())) {
|
||||
p.setResourcePack(Settings.PLOT_SPECIFIC_RESOURCE_PACK);
|
||||
}
|
||||
}
|
||||
@ -148,7 +142,7 @@ public class PlotListener extends APlotListener {
|
||||
if (id >= 2256 && id <= 2267) {
|
||||
Location center = MainUtil.getPlotCenter(plot);
|
||||
org.bukkit.Location newLoc = BukkitUtil.getLocation(center);
|
||||
newLoc.setY(Math.min((((int) player.getLocation().getBlockY())/16) * 16, 240));
|
||||
newLoc.setY(Math.min((player.getLocation().getBlockY() / 16) * 16, 240));
|
||||
try {
|
||||
player.playEffect(newLoc, Effect.RECORD_PLAY, Material.getMaterial(id));
|
||||
}
|
||||
|
@ -1,7 +1,11 @@
|
||||
package com.intellectualcrafters.plot.listeners;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.intellectualcrafters.plot.PlotSquared;
|
||||
import com.intellectualcrafters.plot.flag.FlagManager;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.bukkit.BukkitUtil;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
@ -12,12 +16,7 @@ import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
import org.bukkit.event.entity.ExplosionPrimeEvent;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import com.intellectualcrafters.plot.PlotSquared;
|
||||
import com.intellectualcrafters.plot.flag.FlagManager;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.bukkit.BukkitUtil;
|
||||
import java.util.List;
|
||||
|
||||
public class TNTListener implements Listener {
|
||||
private double lastRadius;
|
||||
@ -34,7 +33,7 @@ public class TNTListener implements Listener {
|
||||
}
|
||||
World world = entity.getWorld();
|
||||
String worldname = world.getName();
|
||||
if (!PlotSquared.isPlotWorld(worldname)) {
|
||||
if (!PlotSquared.getInstance().isPlotWorld(worldname)) {
|
||||
return;
|
||||
}
|
||||
Plot plot = MainUtil.getPlot(BukkitUtil.getLocation(entity));
|
||||
|
@ -1,5 +1,8 @@
|
||||
package com.intellectualcrafters.plot.listeners;
|
||||
|
||||
import com.intellectualcrafters.plot.PlotSquared;
|
||||
import com.intellectualcrafters.plot.object.PlotGenerator;
|
||||
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
@ -8,10 +11,6 @@ import org.bukkit.event.world.WorldInitEvent;
|
||||
import org.bukkit.event.world.WorldLoadEvent;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
|
||||
import com.intellectualcrafters.plot.PlotSquared;
|
||||
import com.intellectualcrafters.plot.object.PlotGenerator;
|
||||
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
||||
|
||||
public class WorldEvents implements Listener {
|
||||
|
||||
public static String lastWorld = null;
|
||||
@ -32,10 +31,10 @@ public class WorldEvents implements Listener {
|
||||
final ChunkGenerator gen = world.getGenerator();
|
||||
if (gen instanceof PlotGenerator) {
|
||||
//
|
||||
PlotSquared.loadWorld(name, (PlotGenerator) gen);
|
||||
PlotSquared.getInstance().loadWorld(name, (PlotGenerator) gen);
|
||||
} else {
|
||||
if (PlotSquared.config.contains("worlds." + name)) {
|
||||
PlotSquared.loadWorld(name, null);
|
||||
PlotSquared.getInstance().loadWorld(name, null);
|
||||
}
|
||||
}
|
||||
lastWorld = null;
|
||||
|
@ -1,16 +1,5 @@
|
||||
package com.intellectualcrafters.plot.listeners.worldedit;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
|
||||
import com.intellectualcrafters.plot.PlotSquared;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
@ -22,6 +11,16 @@ import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.intellectualcrafters.plot.util.bukkit.BukkitUtil;
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldedit.bukkit.selections.Selection;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
public class WEListener implements Listener {
|
||||
|
||||
@ -138,7 +137,7 @@ public class WEListener implements Listener {
|
||||
public boolean onPlayerCommand(final PlayerCommandPreprocessEvent e) {
|
||||
final Player p = e.getPlayer();
|
||||
final PlotPlayer pp = BukkitUtil.getPlayer(p);
|
||||
if (!PlotSquared.isPlotWorld(p.getWorld().getName())) {
|
||||
if (!PlotSquared.getInstance().isPlotWorld(p.getWorld().getName())) {
|
||||
return true;
|
||||
}
|
||||
String cmd = e.getMessage().toLowerCase();
|
||||
|
@ -1,7 +1,5 @@
|
||||
package com.intellectualcrafters.plot.listeners.worldedit;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
||||
import com.intellectualcrafters.plot.PlotSquared;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
@ -15,11 +13,13 @@ import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.util.eventbus.EventHandler.Priority;
|
||||
import com.sk89q.worldedit.util.eventbus.Subscribe;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
||||
public class WESubscriber {
|
||||
@Subscribe(priority=Priority.VERY_EARLY)
|
||||
public void onEditSession(EditSessionEvent event) {
|
||||
String world = event.getWorld().getName();
|
||||
if (!PlotSquared.isPlotWorld(world)) {
|
||||
if (!PlotSquared.getInstance().isPlotWorld(world)) {
|
||||
return;
|
||||
}
|
||||
Actor actor = event.getActor();
|
||||
|
@ -20,30 +20,29 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.intellectualcrafters.plot.object;
|
||||
|
||||
import com.intellectualcrafters.plot.PlotSquared;
|
||||
import com.intellectualcrafters.plot.listeners.WorldEvents;
|
||||
import com.intellectualcrafters.plot.util.ChunkManager;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.generator.BlockPopulator;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.generator.BlockPopulator;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
|
||||
import com.intellectualcrafters.plot.PlotSquared;
|
||||
import com.intellectualcrafters.plot.listeners.WorldEvents;
|
||||
import com.intellectualcrafters.plot.util.ChunkManager;
|
||||
|
||||
public abstract class PlotGenerator extends ChunkGenerator {
|
||||
|
||||
private boolean loaded = false;
|
||||
private short[][] result;
|
||||
public int X;
|
||||
public int Z;
|
||||
private PseudoRandom random = new PseudoRandom();
|
||||
|
||||
public static short[][][] CACHE_I = null;
|
||||
public static short[][][] CACHE_J = null;
|
||||
public int X;
|
||||
public int Z;
|
||||
private boolean loaded = false;
|
||||
private short[][] result;
|
||||
private PseudoRandom random = new PseudoRandom();
|
||||
|
||||
public PlotGenerator(String world) {
|
||||
WorldEvents.lastWorld = world;
|
||||
@ -72,8 +71,8 @@ public abstract class PlotGenerator extends ChunkGenerator {
|
||||
public List<BlockPopulator> getDefaultPopulators(World world) {
|
||||
try {
|
||||
if (!loaded) {
|
||||
PlotSquared.loadWorld(WorldEvents.getName(world), this);
|
||||
PlotWorld plotworld = PlotSquared.getPlotWorld(WorldEvents.getName(world));
|
||||
PlotSquared.getInstance().loadWorld(WorldEvents.getName(world), this);
|
||||
PlotWorld plotworld = PlotSquared.getInstance().getPlotWorld(WorldEvents.getName(world));
|
||||
if (!plotworld.MOB_SPAWNING) {
|
||||
if (!plotworld.SPAWN_EGGS) {
|
||||
world.setSpawnFlags(false, false);
|
||||
@ -104,7 +103,7 @@ public abstract class PlotGenerator extends ChunkGenerator {
|
||||
public short[][] generateExtBlockSections(World world, Random r, int cx, int cz, BiomeGrid biomes) {
|
||||
try {
|
||||
if (!loaded) {
|
||||
PlotSquared.loadWorld(WorldEvents.getName(world), this);
|
||||
PlotSquared.getInstance().loadWorld(WorldEvents.getName(world), this);
|
||||
loaded = true;
|
||||
}
|
||||
final int prime = 13;
|
||||
@ -116,7 +115,7 @@ public abstract class PlotGenerator extends ChunkGenerator {
|
||||
this.X = cx << 4;
|
||||
this.Z = cz << 4;
|
||||
if (ChunkManager.FORCE_PASTE) {
|
||||
PlotWorld plotworld = PlotSquared.getPlotWorld(world.getName());
|
||||
PlotWorld plotworld = PlotSquared.getInstance().getPlotWorld(world.getName());
|
||||
Biome biome = Biome.valueOf(plotworld.PLOT_BIOME);
|
||||
for (short x = 0; x < 16; x++) {
|
||||
for (short z = 0; z < 16; z++) {
|
||||
@ -243,5 +242,6 @@ public abstract class PlotGenerator extends ChunkGenerator {
|
||||
* Feel free to extend BukkitSetupUtils and customize world creation
|
||||
* @param object
|
||||
*/
|
||||
public void processSetup(SetupObject object) {};
|
||||
public void processSetup(SetupObject object) {
|
||||
}
|
||||
}
|
||||
|
@ -1,41 +1,28 @@
|
||||
package com.intellectualcrafters.plot.util;
|
||||
|
||||
import com.intellectualcrafters.plot.PlotSquared;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.generator.AugmentedPopulator;
|
||||
import com.intellectualcrafters.plot.object.*;
|
||||
import com.intellectualcrafters.plot.util.bukkit.BukkitUtil;
|
||||
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.generator.BlockPopulator;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.generator.BlockPopulator;
|
||||
|
||||
import com.intellectualcrafters.plot.PlotSquared;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.generator.AugmentedPopulator;
|
||||
import com.intellectualcrafters.plot.object.BlockLoc;
|
||||
import com.intellectualcrafters.plot.object.ChunkLoc;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotCluster;
|
||||
import com.intellectualcrafters.plot.object.PlotClusterId;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.PlotManager;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
import com.intellectualcrafters.plot.util.bukkit.BukkitUtil;
|
||||
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
||||
|
||||
public class ClusterManager {
|
||||
public static HashMap<String, HashSet<PlotCluster>> clusters;
|
||||
private static HashSet<String> regenerating = new HashSet<>();
|
||||
public static PlotCluster last;
|
||||
private static HashSet<String> regenerating = new HashSet<>();
|
||||
|
||||
public static boolean contains(final PlotCluster cluster, final PlotId id) {
|
||||
if ((cluster.getP1().x <= id.x) && (cluster.getP1().y <= id.y) && (cluster.getP2().x >= id.x) && (cluster.getP2().y >= id.y)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return (cluster.getP1().x <= id.x) && (cluster.getP1().y <= id.y) && (cluster.getP2().x >= id.x) && (cluster.getP2().y >= id.y);
|
||||
}
|
||||
|
||||
public static HashSet<PlotCluster> getClusters(final World world) {
|
||||
@ -57,8 +44,8 @@ public class ClusterManager {
|
||||
final PlotId center = getCenterPlot(cluster);
|
||||
toReturn = MainUtil.getPlotHome(cluster.world, center);
|
||||
if (toReturn.getY() == 0) {
|
||||
final PlotManager manager = PlotSquared.getPlotManager(cluster.world);
|
||||
final PlotWorld plotworld = PlotSquared.getPlotWorld(cluster.world);
|
||||
final PlotManager manager = PlotSquared.getInstance().getPlotManager(cluster.world);
|
||||
final PlotWorld plotworld = PlotSquared.getInstance().getPlotWorld(cluster.world);
|
||||
final Location loc = manager.getSignLoc(plotworld, MainUtil.getPlot(cluster.world, center));
|
||||
toReturn.setY(loc.getY());
|
||||
}
|
||||
@ -80,15 +67,15 @@ public class ClusterManager {
|
||||
|
||||
public static Location getClusterBottom(final PlotCluster cluster) {
|
||||
final String world = cluster.world;
|
||||
final PlotWorld plotworld = PlotSquared.getPlotWorld(world);
|
||||
final PlotManager manager = PlotSquared.getPlotManager(world);
|
||||
final PlotWorld plotworld = PlotSquared.getInstance().getPlotWorld(world);
|
||||
final PlotManager manager = PlotSquared.getInstance().getPlotManager(world);
|
||||
return manager.getPlotBottomLocAbs(plotworld, cluster.getP1());
|
||||
}
|
||||
|
||||
public static Location getClusterTop(final PlotCluster cluster) {
|
||||
final String world = cluster.world;
|
||||
final PlotWorld plotworld = PlotSquared.getPlotWorld(world);
|
||||
final PlotManager manager = PlotSquared.getPlotManager(world);
|
||||
final PlotWorld plotworld = PlotSquared.getInstance().getPlotWorld(world);
|
||||
final PlotManager manager = PlotSquared.getInstance().getPlotManager(world);
|
||||
return manager.getPlotTopLocAbs(plotworld, cluster.getP2());
|
||||
}
|
||||
|
||||
@ -106,14 +93,11 @@ public class ClusterManager {
|
||||
|
||||
public static boolean contains(final PlotCluster cluster, final Location loc) {
|
||||
final String world = loc.getWorld();
|
||||
final PlotManager manager = PlotSquared.getPlotManager(world);
|
||||
final PlotWorld plotworld = PlotSquared.getPlotWorld(world);
|
||||
final PlotManager manager = PlotSquared.getInstance().getPlotManager(world);
|
||||
final PlotWorld plotworld = PlotSquared.getInstance().getPlotWorld(world);
|
||||
final Location bot = manager.getPlotBottomLocAbs(plotworld, cluster.getP1());
|
||||
final Location top = manager.getPlotTopLocAbs(plotworld, cluster.getP2()).add(1, 0, 1);
|
||||
if ((bot.getX() < loc.getX()) && (bot.getZ() < loc.getZ()) && (top.getX() > loc.getX()) && (top.getZ() > loc.getZ())) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return (bot.getX() < loc.getX()) && (bot.getZ() < loc.getZ()) && (top.getX() > loc.getX()) && (top.getZ() > loc.getZ());
|
||||
}
|
||||
|
||||
public static HashSet<PlotCluster> getIntersects(final String world, final PlotClusterId id) {
|
||||
@ -132,10 +116,7 @@ public class ClusterManager {
|
||||
public static boolean intersects(final PlotCluster cluster, final PlotClusterId id) {
|
||||
final PlotId pos1 = cluster.getP1();
|
||||
final PlotId pos2 = cluster.getP2();
|
||||
if ((pos1.x <= id.pos2.x) && (pos2.x >= id.pos1.x) && (pos1.y <= id.pos2.y) && (pos2.y >= id.pos1.y)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return (pos1.x <= id.pos2.x) && (pos2.x >= id.pos1.x) && (pos1.y <= id.pos2.y) && (pos2.y >= id.pos1.y);
|
||||
}
|
||||
|
||||
public static PlotCluster getCluster(final Plot plot) {
|
||||
@ -167,8 +148,8 @@ public class ClusterManager {
|
||||
|
||||
public static PlotCluster getCluster(final Location loc) {
|
||||
final String world = loc.getWorld();
|
||||
PlotManager manager = PlotSquared.getPlotManager(world);
|
||||
PlotId id = manager.getPlotIdAbs(PlotSquared.getPlotWorld(world), loc.getX(), loc.getY(), loc.getZ());
|
||||
PlotManager manager = PlotSquared.getInstance().getPlotManager(world);
|
||||
PlotId id = manager.getPlotIdAbs(PlotSquared.getInstance().getPlotWorld(world), loc.getX(), loc.getY(), loc.getZ());
|
||||
if (id != null) {
|
||||
return getCluster(world, id);
|
||||
}
|
||||
@ -229,12 +210,12 @@ public class ClusterManager {
|
||||
int xw;
|
||||
int zw;
|
||||
final String world = loc.getWorld();
|
||||
final PlotWorld plotworld = PlotSquared.getPlotWorld(world);
|
||||
final PlotWorld plotworld = PlotSquared.getInstance().getPlotWorld(world);
|
||||
if (plotworld == null) {
|
||||
xw = 39;
|
||||
zw = 39;
|
||||
} else {
|
||||
final PlotManager manager = PlotSquared.getPlotManager(world);
|
||||
final PlotManager manager = PlotSquared.getInstance().getPlotManager(world);
|
||||
final Location al = manager.getPlotBottomLocAbs(plotworld, a);
|
||||
final Location bl = manager.getPlotBottomLocAbs(plotworld, b);
|
||||
xw = bl.getX() - al.getX();
|
||||
@ -254,7 +235,7 @@ public class ClusterManager {
|
||||
int i = 0;
|
||||
final Random rand = new Random();
|
||||
final World world = Bukkit.getWorld(cluster.world);
|
||||
final PlotWorld plotworld = PlotSquared.getPlotWorld(cluster.world);
|
||||
final PlotWorld plotworld = PlotSquared.getInstance().getPlotWorld(cluster.world);
|
||||
final Location bot = getClusterBottom(cluster);
|
||||
final Location top = getClusterTop(cluster);
|
||||
final int minChunkX = bot.getX() >> 4;
|
||||
|
@ -1,17 +1,5 @@
|
||||
package com.intellectualcrafters.plot.util;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
|
||||
import com.intellectualcrafters.plot.BukkitMain;
|
||||
import com.intellectualcrafters.plot.PlotSquared;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
@ -19,16 +7,15 @@ import com.intellectualcrafters.plot.database.DBFunc;
|
||||
import com.intellectualcrafters.plot.flag.Flag;
|
||||
import com.intellectualcrafters.plot.flag.FlagManager;
|
||||
import com.intellectualcrafters.plot.generator.ClassicPlotManager;
|
||||
import com.intellectualcrafters.plot.generator.HybridPlotManager;
|
||||
import com.intellectualcrafters.plot.generator.HybridUtils;
|
||||
import com.intellectualcrafters.plot.object.OfflinePlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotHandler;
|
||||
import com.intellectualcrafters.plot.object.PlotManager;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||
import com.intellectualcrafters.plot.object.*;
|
||||
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class ExpireManager {
|
||||
public static ConcurrentHashMap<String, List<Plot>> expiredPlots = new ConcurrentHashMap<>();
|
||||
@ -77,7 +64,7 @@ public class ExpireManager {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
for (final String world : PlotSquared.getPlotWorldsString()) {
|
||||
for (final String world : PlotSquared.getInstance().getPlotWorldsString()) {
|
||||
if (!ExpireManager.updatingPlots.containsKey(world)) {
|
||||
ExpireManager.updatingPlots.put(world, false);
|
||||
}
|
||||
@ -117,17 +104,17 @@ public class ExpireManager {
|
||||
MainUtil.sendMessage(player, C.PLOT_REMOVED_USER, plot.id.toString());
|
||||
}
|
||||
}
|
||||
final PlotManager manager = PlotSquared.getPlotManager(world);
|
||||
final PlotManager manager = PlotSquared.getInstance().getPlotManager(world);
|
||||
if (manager == null) {
|
||||
PlotSquared.log("&7[&5Expire&dManager&7] &cThis is a friendly reminder to create or delete " + world +" as it is currently setup incorrectly");
|
||||
expiredPlots.get(world).remove(plot);
|
||||
return;
|
||||
}
|
||||
final PlotWorld plotworld = PlotSquared.getPlotWorld(world);
|
||||
final PlotWorld plotworld = PlotSquared.getInstance().getPlotWorld(world);
|
||||
RunnableVal run = new RunnableVal<Integer>() {
|
||||
@Override
|
||||
public void run() {
|
||||
int changed = (Integer) this.value;
|
||||
int changed = this.value;
|
||||
if (Settings.MIN_BLOCKS_CHANGED_IGNORED > 0 || Settings.MIN_BLOCKS_CHANGED > 0 && manager instanceof ClassicPlotManager) {
|
||||
if (changed >= Settings.MIN_BLOCKS_CHANGED && Settings.MIN_BLOCKS_CHANGED > 0) {
|
||||
PlotSquared.log("&7[&5Expire&dManager&7] &bKeep flag added to: " + plot.id + (changed != -1 ? " (changed " + value + ")" : ""));
|
||||
@ -148,7 +135,7 @@ public class ExpireManager {
|
||||
manager.clearPlot(plotworld, plot, false, null);
|
||||
MainUtil.removeSign(plot);
|
||||
DBFunc.delete(world, plot);
|
||||
PlotSquared.removePlot(world, plot.id, false);
|
||||
PlotSquared.getInstance().removePlot(world, plot.id, false);
|
||||
expiredPlots.get(world).remove(plot);
|
||||
PlotSquared.log("&7[&5Expire&dManager&7] &cDeleted expired plot: " + plot.id + (changed != -1 ? " (changed " + value + ")" : ""));
|
||||
PlotSquared.log("&3 - World: " + plot.world);
|
||||
@ -228,7 +215,7 @@ public class ExpireManager {
|
||||
}
|
||||
|
||||
public static List<Plot> getOldPlots(final String world) {
|
||||
final Collection<Plot> plots = PlotSquared.getPlots(world).values();
|
||||
final Collection<Plot> plots = PlotSquared.getInstance().getPlots(world).values();
|
||||
final List<Plot> toRemove = new ArrayList<>();
|
||||
Iterator<Plot> iter = plots.iterator();
|
||||
while (iter.hasNext()) {
|
||||
|
@ -20,31 +20,20 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.intellectualcrafters.plot.util;
|
||||
|
||||
import com.intellectualcrafters.plot.PlotSquared;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
import com.intellectualcrafters.plot.object.*;
|
||||
import com.intellectualcrafters.plot.util.bukkit.BukkitUtil;
|
||||
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.intellectualcrafters.plot.PlotSquared;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
import com.intellectualcrafters.plot.object.BlockLoc;
|
||||
import com.intellectualcrafters.plot.object.ChunkLoc;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||
import com.intellectualcrafters.plot.object.PlotCluster;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.PlotManager;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.PlotSettings;
|
||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
import com.intellectualcrafters.plot.object.PseudoRandom;
|
||||
import com.intellectualcrafters.plot.util.bukkit.BukkitUtil;
|
||||
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
||||
|
||||
/**
|
||||
* plot functions
|
||||
*
|
||||
@ -55,13 +44,13 @@ public class MainUtil {
|
||||
public static boolean canSendChunk = false;
|
||||
public static boolean canSetFast = true;
|
||||
public static ArrayList<String> runners_p = new ArrayList<>();
|
||||
static long state = 1;
|
||||
public static HashMap<String, PlotId> lastPlot = new HashMap<>();
|
||||
public static HashMap<String, Integer> worldBorder = new HashMap<>();
|
||||
static long state = 1;
|
||||
static PseudoRandom random = new PseudoRandom();
|
||||
|
||||
public static boolean isPlotArea(final Location location) {
|
||||
final PlotWorld plotworld = PlotSquared.getPlotWorld(location.getWorld());
|
||||
final PlotWorld plotworld = PlotSquared.getInstance().getPlotWorld(location.getWorld());
|
||||
if (plotworld.TYPE == 2) {
|
||||
return ClusterManager.getCluster(location) != null;
|
||||
}
|
||||
@ -101,21 +90,21 @@ public class MainUtil {
|
||||
}
|
||||
else {
|
||||
if (worldname == null) {
|
||||
if (PlotSquared.getPlotWorlds().size() == 0) {
|
||||
if (PlotSquared.getInstance().getPlotWorlds().size() == 0) {
|
||||
if (message) MainUtil.sendMessage(player, C.NOT_VALID_PLOT_WORLD);
|
||||
return null;
|
||||
}
|
||||
worldname = PlotSquared.getPlotWorlds().iterator().next();
|
||||
worldname = PlotSquared.getInstance().getPlotWorlds().iterator().next();
|
||||
}
|
||||
for (Plot p : PlotSquared.getPlots(worldname).values()) {
|
||||
for (Plot p : PlotSquared.getInstance().getPlots(worldname).values()) {
|
||||
String name = p.settings.getAlias();
|
||||
if (name.length() != 0 && name.equalsIgnoreCase(arg)) {
|
||||
return p;
|
||||
}
|
||||
}
|
||||
for (String world : PlotSquared.getPlotWorlds()) {
|
||||
for (String world : PlotSquared.getInstance().getPlotWorlds()) {
|
||||
if (!world.endsWith(worldname)) {
|
||||
for (Plot p : PlotSquared.getPlots(world).values()) {
|
||||
for (Plot p : PlotSquared.getInstance().getPlots(world).values()) {
|
||||
String name = p.settings.getAlias();
|
||||
if (name.length() != 0 && name.equalsIgnoreCase(arg)) {
|
||||
return p;
|
||||
@ -124,7 +113,7 @@ public class MainUtil {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (worldname == null || !PlotSquared.isPlotWorld(worldname)) {
|
||||
if (worldname == null || !PlotSquared.getInstance().isPlotWorld(worldname)) {
|
||||
if (message) MainUtil.sendMessage(player, C.NOT_VALID_PLOT_WORLD);
|
||||
System.out.print("INVALID WORLD: ");
|
||||
return null;
|
||||
@ -148,7 +137,7 @@ public class MainUtil {
|
||||
* @return boolean
|
||||
*/
|
||||
public static boolean mergePlots(final PlotPlayer player, final String world, final ArrayList<PlotId> plotIds) {
|
||||
final PlotWorld plotworld = PlotSquared.getPlotWorld(world);
|
||||
final PlotWorld plotworld = PlotSquared.getInstance().getPlotWorld(world);
|
||||
if ((EconHandler.manager != null) && plotworld.USE_ECONOMY) {
|
||||
final double cost = plotIds.size() * plotworld.MERGE_PRICE;
|
||||
if (cost > 0d) {
|
||||
@ -172,11 +161,11 @@ public class MainUtil {
|
||||
if (!result) {
|
||||
return false;
|
||||
}
|
||||
final PlotManager manager = PlotSquared.getPlotManager(world);
|
||||
final PlotWorld plotworld = PlotSquared.getPlotWorld(world);
|
||||
final PlotManager manager = PlotSquared.getInstance().getPlotManager(world);
|
||||
final PlotWorld plotworld = PlotSquared.getInstance().getPlotWorld(world);
|
||||
manager.startPlotUnlink(plotworld, ids);
|
||||
for (final PlotId id : ids) {
|
||||
final Plot myplot = PlotSquared.getPlots(world).get(id);
|
||||
final Plot myplot = PlotSquared.getInstance().getPlots(world).get(id);
|
||||
if (plot == null) {
|
||||
continue;
|
||||
}
|
||||
@ -223,7 +212,7 @@ public class MainUtil {
|
||||
}
|
||||
|
||||
public static boolean isPlotAreaAbs(final Location location) {
|
||||
final PlotWorld plotworld = PlotSquared.getPlotWorld(location.getWorld());
|
||||
final PlotWorld plotworld = PlotSquared.getInstance().getPlotWorld(location.getWorld());
|
||||
if (plotworld.TYPE == 2) {
|
||||
return ClusterManager.getClusterAbs(location) != null;
|
||||
}
|
||||
@ -231,19 +220,19 @@ public class MainUtil {
|
||||
}
|
||||
|
||||
public static boolean isPlotRoad(final Location location) {
|
||||
final PlotWorld plotworld = PlotSquared.getPlotWorld(location.getWorld());
|
||||
final PlotWorld plotworld = PlotSquared.getInstance().getPlotWorld(location.getWorld());
|
||||
if (plotworld.TYPE == 2) {
|
||||
PlotCluster cluster = ClusterManager.getCluster(location);
|
||||
if (cluster == null) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
PlotManager manager = PlotSquared.getPlotManager(location.getWorld());
|
||||
PlotManager manager = PlotSquared.getInstance().getPlotManager(location.getWorld());
|
||||
return manager.getPlotId(plotworld, location.getX(), location.getY(), location.getZ()) == null;
|
||||
}
|
||||
|
||||
public static boolean isPlotArea(final Plot plot) {
|
||||
final PlotWorld plotworld = PlotSquared.getPlotWorld(plot.world);
|
||||
final PlotWorld plotworld = PlotSquared.getInstance().getPlotWorld(plot.world);
|
||||
if (plotworld.TYPE == 2) {
|
||||
return ClusterManager.getCluster(plot) != null;
|
||||
}
|
||||
@ -263,9 +252,9 @@ public class MainUtil {
|
||||
}
|
||||
|
||||
public static ArrayList<PlotId> getMaxPlotSelectionIds(final String world, PlotId pos1, PlotId pos2) {
|
||||
|
||||
final Plot plot1 = PlotSquared.getPlots(world).get(pos1);
|
||||
final Plot plot2 = PlotSquared.getPlots(world).get(pos2);
|
||||
|
||||
final Plot plot1 = PlotSquared.getInstance().getPlots(world).get(pos1);
|
||||
final Plot plot2 = PlotSquared.getInstance().getPlots(world).get(pos2);
|
||||
|
||||
if (plot1 != null) {
|
||||
pos1 = getBottomPlot(plot1).id;
|
||||
@ -304,7 +293,7 @@ public class MainUtil {
|
||||
public static int getPlayerPlotCount(final String world, final PlotPlayer plr) {
|
||||
final UUID uuid = plr.getUUID();
|
||||
int count = 0;
|
||||
for (final Plot plot : PlotSquared.getPlots(world).values()) {
|
||||
for (final Plot plot : PlotSquared.getInstance().getPlots(world).values()) {
|
||||
if (plot.hasOwner() && plot.owner.equals(uuid) && plot.countsTowardsMax) {
|
||||
count++;
|
||||
}
|
||||
@ -314,17 +303,17 @@ public class MainUtil {
|
||||
|
||||
public static int getPlayerPlotCount(final PlotPlayer plr) {
|
||||
int count = 0;
|
||||
for (final String world : PlotSquared.getPlotWorldsString()) {
|
||||
for (final String world : PlotSquared.getInstance().getPlotWorldsString()) {
|
||||
count += getPlayerPlotCount(world, plr);
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
public static Location getDefaultHome(Plot plot) {
|
||||
PlotWorld plotworld = PlotSquared.getPlotWorld(plot.world);
|
||||
PlotWorld plotworld = PlotSquared.getInstance().getPlotWorld(plot.world);
|
||||
if (plotworld.DEFAULT_HOME != null) {
|
||||
final Location bot = getPlotBottomLoc(plot.world, plot.id);
|
||||
final PlotManager manager = PlotSquared.getPlotManager(plot.world);
|
||||
final PlotManager manager = PlotSquared.getInstance().getPlotManager(plot.world);
|
||||
final int x;
|
||||
final int z;
|
||||
if (plotworld.DEFAULT_HOME.x == Integer.MAX_VALUE && plotworld.DEFAULT_HOME.z == Integer.MAX_VALUE) {
|
||||
@ -336,15 +325,15 @@ public class MainUtil {
|
||||
x = bot.getX() + plotworld.DEFAULT_HOME.x;
|
||||
z = bot.getZ() + plotworld.DEFAULT_HOME.z;
|
||||
}
|
||||
final int y = Math.max(getHeighestBlock(plot.world, x, z), manager.getSignLoc(PlotSquared.getPlotWorld(plot.world), plot).getY());
|
||||
final int y = Math.max(getHeighestBlock(plot.world, x, z), manager.getSignLoc(PlotSquared.getInstance().getPlotWorld(plot.world), plot).getY());
|
||||
return new Location(plot.world, x, y + 1, z);
|
||||
}
|
||||
final Location top = getPlotTopLoc(plot.world, plot.id);
|
||||
final Location bot = getPlotBottomLoc(plot.world, plot.id);
|
||||
final int x = ((top.getX() - bot.getX()) / 2) + bot.getX();
|
||||
final int z = bot.getZ();
|
||||
PlotManager manager = PlotSquared.getPlotManager(plot.world);
|
||||
final int y = Math.max(getHeighestBlock(plot.world, x, z), manager.getSignLoc(PlotSquared.getPlotWorld(plot.world), plot).getY());
|
||||
PlotManager manager = PlotSquared.getInstance().getPlotManager(plot.world);
|
||||
final int y = Math.max(getHeighestBlock(plot.world, x, z), manager.getSignLoc(PlotSquared.getInstance().getPlotWorld(plot.world), plot).getY());
|
||||
return new Location(plot.world, x, y + 1, z);
|
||||
}
|
||||
|
||||
@ -355,7 +344,7 @@ public class MainUtil {
|
||||
|
||||
if (result) {
|
||||
final Location location;
|
||||
if (PlotSquared.getPlotWorld(plot.world).HOME_ALLOW_NONMEMBER || plot.isAdded(player.getUUID())) {
|
||||
if (PlotSquared.getInstance().getPlotWorld(plot.world).HOME_ALLOW_NONMEMBER || plot.isAdded(player.getUUID())) {
|
||||
location = MainUtil.getPlotHome(bot.world, bot);
|
||||
}
|
||||
else {
|
||||
@ -391,21 +380,21 @@ public class MainUtil {
|
||||
|
||||
public static int getBorder(final String worldname) {
|
||||
if (worldBorder.containsKey(worldname)) {
|
||||
PlotSquared.getPlotWorld(worldname);
|
||||
PlotSquared.getInstance().getPlotWorld(worldname);
|
||||
return worldBorder.get(worldname) + 16;
|
||||
}
|
||||
return Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
public static void setupBorder(final String world) {
|
||||
final PlotWorld plotworld = PlotSquared.getPlotWorld(world);
|
||||
final PlotWorld plotworld = PlotSquared.getInstance().getPlotWorld(world);
|
||||
if (!plotworld.WORLD_BORDER) {
|
||||
return;
|
||||
}
|
||||
if (!worldBorder.containsKey(world)) {
|
||||
worldBorder.put(world, 0);
|
||||
}
|
||||
for (final Plot plot : PlotSquared.getPlots(world).values()) {
|
||||
for (final Plot plot : PlotSquared.getInstance().getPlots(world).values()) {
|
||||
updateWorldBorder(plot);
|
||||
}
|
||||
}
|
||||
@ -495,8 +484,8 @@ public class MainUtil {
|
||||
}
|
||||
final PlotId pos1 = plotIds.get(0);
|
||||
final PlotId pos2 = plotIds.get(plotIds.size() - 1);
|
||||
final PlotManager manager = PlotSquared.getPlotManager(world);
|
||||
final PlotWorld plotworld = PlotSquared.getPlotWorld(world);
|
||||
final PlotManager manager = PlotSquared.getInstance().getPlotManager(world);
|
||||
final PlotWorld plotworld = PlotSquared.getInstance().getPlotWorld(world);
|
||||
|
||||
boolean result = EventUtil.manager.callMerge(world, getPlot(world, pos1), plotIds);
|
||||
if (!result) {
|
||||
@ -509,7 +498,7 @@ public class MainUtil {
|
||||
final boolean lx = x < pos2.x;
|
||||
final boolean ly = y < pos2.y;
|
||||
final PlotId id = new PlotId(x, y);
|
||||
final Plot plot = PlotSquared.getPlots(world).get(id);
|
||||
final Plot plot = PlotSquared.getInstance().getPlots(world).get(id);
|
||||
Plot plot2 = null;
|
||||
if (removeRoads) {
|
||||
removeSign(plot);
|
||||
@ -523,7 +512,7 @@ public class MainUtil {
|
||||
}
|
||||
}
|
||||
if (!plot.settings.getMerged(1)) {
|
||||
plot2 = PlotSquared.getPlots(world).get(new PlotId(x + 1, y));
|
||||
plot2 = PlotSquared.getInstance().getPlots(world).get(new PlotId(x + 1, y));
|
||||
mergePlot(world, plot, plot2, removeRoads);
|
||||
plot.settings.setMerged(1, true);
|
||||
plot2.settings.setMerged(3, true);
|
||||
@ -531,7 +520,7 @@ public class MainUtil {
|
||||
}
|
||||
if (ly) {
|
||||
if (!plot.settings.getMerged(2)) {
|
||||
plot2 = PlotSquared.getPlots(world).get(new PlotId(x, y + 1));
|
||||
plot2 = PlotSquared.getInstance().getPlots(world).get(new PlotId(x, y + 1));
|
||||
mergePlot(world, plot, plot2, removeRoads);
|
||||
plot.settings.setMerged(2, true);
|
||||
plot2.settings.setMerged(0, true);
|
||||
@ -542,7 +531,7 @@ public class MainUtil {
|
||||
for (int x = pos1.x; x <= pos2.x; x++) {
|
||||
for (int y = pos1.y; y <= pos2.y; y++) {
|
||||
final PlotId id = new PlotId(x, y);
|
||||
final Plot plot = PlotSquared.getPlots(world).get(id);
|
||||
final Plot plot = PlotSquared.getInstance().getPlots(world).get(id);
|
||||
DBFunc.setMerged(world, plot, plot.settings.getMerged());
|
||||
}
|
||||
}
|
||||
@ -564,7 +553,7 @@ public class MainUtil {
|
||||
ChunkManager.manager.regenerateRegion(pos1, pos2, null);
|
||||
}
|
||||
else {
|
||||
PlotSquared.getPlotManager(plot.world).removeRoadSouthEast(plotworld, plot);
|
||||
PlotSquared.getInstance().getPlotManager(plot.world).removeRoadSouthEast(plotworld, plot);
|
||||
}
|
||||
}
|
||||
|
||||
@ -582,7 +571,7 @@ public class MainUtil {
|
||||
ChunkManager.manager.regenerateRegion(pos1, pos2, null);
|
||||
}
|
||||
else {
|
||||
PlotSquared.getPlotManager(plot.world).removeRoadEast(plotworld, plot);
|
||||
PlotSquared.getInstance().getPlotManager(plot.world).removeRoadEast(plotworld, plot);
|
||||
}
|
||||
}
|
||||
|
||||
@ -600,7 +589,7 @@ public class MainUtil {
|
||||
ChunkManager.manager.regenerateRegion(pos1, pos2, null);
|
||||
}
|
||||
else {
|
||||
PlotSquared.getPlotManager(plot.world).removeRoadSouth(plotworld, plot);
|
||||
PlotSquared.getInstance().getPlotManager(plot.world).removeRoadSouth(plotworld, plot);
|
||||
}
|
||||
}
|
||||
|
||||
@ -614,7 +603,7 @@ public class MainUtil {
|
||||
* @param greaterPlot
|
||||
*/
|
||||
public static void mergePlot(final String world, final Plot lesserPlot, final Plot greaterPlot, final boolean removeRoads) {
|
||||
final PlotWorld plotworld = PlotSquared.getPlotWorld(world);
|
||||
final PlotWorld plotworld = PlotSquared.getInstance().getPlotWorld(world);
|
||||
if (lesserPlot.id.x.equals(greaterPlot.id.x)) {
|
||||
if (!lesserPlot.settings.getMerged(2)) {
|
||||
lesserPlot.settings.setMerged(2, true);
|
||||
@ -636,8 +625,8 @@ public class MainUtil {
|
||||
|
||||
public static void removeSign(final Plot p) {
|
||||
final String world = p.world;
|
||||
final PlotManager manager = PlotSquared.getPlotManager(world);
|
||||
final PlotWorld plotworld = PlotSquared.getPlotWorld(world);
|
||||
final PlotManager manager = PlotSquared.getInstance().getPlotManager(world);
|
||||
final PlotWorld plotworld = PlotSquared.getInstance().getPlotWorld(world);
|
||||
if (!plotworld.ALLOW_SIGNS) {
|
||||
return;
|
||||
}
|
||||
@ -649,8 +638,8 @@ public class MainUtil {
|
||||
if (name == null) {
|
||||
name = "unknown";
|
||||
}
|
||||
final PlotManager manager = PlotSquared.getPlotManager(p.world);
|
||||
final PlotWorld plotworld = PlotSquared.getPlotWorld(p.world);
|
||||
final PlotManager manager = PlotSquared.getInstance().getPlotManager(p.world);
|
||||
final PlotWorld plotworld = PlotSquared.getInstance().getPlotWorld(p.world);
|
||||
if (plotworld.ALLOW_SIGNS) {
|
||||
final Location loc = manager.getSignLoc(plotworld, p);
|
||||
final String id = p.id.x + ";" + p.id.y;
|
||||
@ -726,7 +715,7 @@ public class MainUtil {
|
||||
final PlotId id_min = plots.get(0);
|
||||
final PlotId id_max = plots.get(plots.size() - 1);
|
||||
for (final PlotId myid : plots) {
|
||||
final Plot myplot = PlotSquared.getPlots(world).get(myid);
|
||||
final Plot myplot = PlotSquared.getInstance().getPlots(world).get(myid);
|
||||
if ((myplot == null) || myplot.owner == null || !(myplot.owner.equals(uuid))) {
|
||||
return false;
|
||||
}
|
||||
@ -747,8 +736,8 @@ public class MainUtil {
|
||||
return;
|
||||
}
|
||||
final String world = plot.world;
|
||||
final PlotManager manager = PlotSquared.getPlotManager(world);
|
||||
final PlotWorld plotworld = PlotSquared.getPlotWorld(world);
|
||||
final PlotManager manager = PlotSquared.getInstance().getPlotManager(world);
|
||||
final PlotWorld plotworld = PlotSquared.getInstance().getPlotWorld(world);
|
||||
final Location bot = manager.getPlotBottomLocAbs(plotworld, plot.id);
|
||||
final Location top = manager.getPlotTopLocAbs(plotworld, plot.id);
|
||||
final int border = worldBorder.get(plot.world);
|
||||
@ -768,7 +757,7 @@ public class MainUtil {
|
||||
updateWorldBorder(plot);
|
||||
}
|
||||
final Plot p = createPlotAbs(uuid, plot);
|
||||
final PlotWorld plotworld = PlotSquared.getPlotWorld(plot.world);
|
||||
final PlotWorld plotworld = PlotSquared.getInstance().getPlotWorld(plot.world);
|
||||
if (plotworld.AUTO_MERGE) {
|
||||
autoMerge(plot.world, p, uuid);
|
||||
}
|
||||
@ -781,7 +770,7 @@ public class MainUtil {
|
||||
public static Plot createPlotAbs(final UUID uuid, final Plot plot) {
|
||||
final String w = plot.world;
|
||||
final Plot p = new Plot(plot.id, uuid, new ArrayList<UUID>(), new ArrayList<UUID>(), w);
|
||||
PlotSquared.updatePlot(p);
|
||||
PlotSquared.getInstance().updatePlot(p);
|
||||
DBFunc.createPlotAndSettings(p);
|
||||
return p;
|
||||
}
|
||||
@ -820,7 +809,7 @@ public class MainUtil {
|
||||
}
|
||||
|
||||
public static void clear(final String world, final Plot plot, final boolean isDelete, final Runnable whenDone) {
|
||||
final PlotManager manager = PlotSquared.getPlotManager(world);
|
||||
final PlotManager manager = PlotSquared.getInstance().getPlotManager(world);
|
||||
final Location pos1 = MainUtil.getPlotBottomLoc(world, plot.id).add(1, 0, 1);
|
||||
final int prime = 31;
|
||||
int h = 1;
|
||||
@ -828,7 +817,7 @@ public class MainUtil {
|
||||
h = (prime * h) + pos1.getZ();
|
||||
state = h;
|
||||
System.currentTimeMillis();
|
||||
final PlotWorld plotworld = PlotSquared.getPlotWorld(world);
|
||||
final PlotWorld plotworld = PlotSquared.getInstance().getPlotWorld(world);
|
||||
runners.put(plot, 1);
|
||||
if (plotworld.TERRAIN != 0 || Settings.FAST_CLEAR) {
|
||||
final Location pos2 = MainUtil.getPlotTopLoc(world, plot.id);
|
||||
@ -959,7 +948,7 @@ public class MainUtil {
|
||||
final Plot plot = getPlot(w, plotid);
|
||||
final BlockLoc home = plot.settings.getPosition();
|
||||
final Location bot = getPlotBottomLoc(w, plotid);
|
||||
final PlotManager manager = PlotSquared.getPlotManager(w);
|
||||
final PlotManager manager = PlotSquared.getInstance().getPlotManager(w);
|
||||
if ((home == null) || ((home.x == 0) && (home.z == 0))) {
|
||||
return getDefaultHome(plot);
|
||||
} else {
|
||||
@ -992,8 +981,8 @@ public class MainUtil {
|
||||
* @return Location top
|
||||
*/
|
||||
public static Location getPlotTopLocAbs(final String world, final PlotId id) {
|
||||
final PlotWorld plotworld = PlotSquared.getPlotWorld(world);
|
||||
final PlotManager manager = PlotSquared.getPlotManager(world);
|
||||
final PlotWorld plotworld = PlotSquared.getInstance().getPlotWorld(world);
|
||||
final PlotManager manager = PlotSquared.getInstance().getPlotManager(world);
|
||||
return manager.getPlotTopLocAbs(plotworld, id);
|
||||
}
|
||||
|
||||
@ -1007,8 +996,8 @@ public class MainUtil {
|
||||
* @return Location bottom
|
||||
*/
|
||||
public static Location getPlotBottomLocAbs(final String world, final PlotId id) {
|
||||
final PlotWorld plotworld = PlotSquared.getPlotWorld(world);
|
||||
final PlotManager manager = PlotSquared.getPlotManager(world);
|
||||
final PlotWorld plotworld = PlotSquared.getInstance().getPlotWorld(world);
|
||||
final PlotManager manager = PlotSquared.getInstance().getPlotManager(world);
|
||||
return manager.getPlotBottomLocAbs(plotworld, id);
|
||||
}
|
||||
|
||||
@ -1034,12 +1023,12 @@ public class MainUtil {
|
||||
* @return Location top of mega plot
|
||||
*/
|
||||
public static Location getPlotTopLoc(final String world, PlotId id) {
|
||||
final Plot plot = PlotSquared.getPlots(world).get(id);
|
||||
final Plot plot = PlotSquared.getInstance().getPlots(world).get(id);
|
||||
if (plot != null) {
|
||||
id = getTopPlot(plot).id;
|
||||
}
|
||||
final PlotWorld plotworld = PlotSquared.getPlotWorld(world);
|
||||
final PlotManager manager = PlotSquared.getPlotManager(world);
|
||||
final PlotWorld plotworld = PlotSquared.getInstance().getPlotWorld(world);
|
||||
final PlotManager manager = PlotSquared.getInstance().getPlotManager(world);
|
||||
return manager.getPlotTopLocAbs(plotworld, id);
|
||||
}
|
||||
|
||||
@ -1053,12 +1042,12 @@ public class MainUtil {
|
||||
* @return Location bottom of mega plot
|
||||
*/
|
||||
public static Location getPlotBottomLoc(final String world, PlotId id) {
|
||||
final Plot plot = PlotSquared.getPlots(world).get(id);
|
||||
final Plot plot = PlotSquared.getInstance().getPlots(world).get(id);
|
||||
if (plot != null) {
|
||||
id = getBottomPlot(plot).id;
|
||||
}
|
||||
final PlotWorld plotworld = PlotSquared.getPlotWorld(world);
|
||||
final PlotManager manager = PlotSquared.getPlotManager(world);
|
||||
final PlotWorld plotworld = PlotSquared.getInstance().getPlotWorld(world);
|
||||
final PlotManager manager = PlotSquared.getInstance().getPlotManager(world);
|
||||
return manager.getPlotBottomLocAbs(plotworld, id);
|
||||
}
|
||||
|
||||
@ -1087,18 +1076,15 @@ public class MainUtil {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (plot.owner != null) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return plot.owner == null;
|
||||
}
|
||||
|
||||
public static boolean isUnowned(final String world, final PlotId pos1, final PlotId pos2) {
|
||||
for (int x = pos1.x; x <= pos2.x; x++) {
|
||||
for (int y = pos1.y; y <= pos2.y; y++) {
|
||||
final PlotId id = new PlotId(x, y);
|
||||
if (PlotSquared.getPlots(world).get(id) != null) {
|
||||
if (PlotSquared.getPlots(world).get(id).owner != null) {
|
||||
if (PlotSquared.getInstance().getPlots(world).get(id) != null) {
|
||||
if (PlotSquared.getInstance().getPlots(world).get(id).owner != null) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -1108,8 +1094,8 @@ public class MainUtil {
|
||||
}
|
||||
|
||||
public static boolean swap(final String world, final PlotId current, final PlotId newPlot, final Runnable whenDone) {
|
||||
Plot p1 = PlotSquared.getPlots(world).get(current);
|
||||
Plot p2 = PlotSquared.getPlots(world).get(newPlot);
|
||||
Plot p1 = PlotSquared.getInstance().getPlots(world).get(current);
|
||||
Plot p2 = PlotSquared.getInstance().getPlots(world).get(newPlot);
|
||||
if (p1==null || p2 == null || p1.owner == null || !p1.owner.equals(p2.owner)) {
|
||||
return false;
|
||||
}
|
||||
@ -1121,20 +1107,20 @@ public class MainUtil {
|
||||
p1.id.y = p2.id.y.intValue();
|
||||
p2.id.x = temp.x;
|
||||
p2.id.y = temp.y;
|
||||
PlotSquared.getPlots(world).remove(p1.id);
|
||||
PlotSquared.getPlots(world).remove(p2.id);
|
||||
PlotSquared.getInstance().getPlots(world).remove(p1.id);
|
||||
PlotSquared.getInstance().getPlots(world).remove(p2.id);
|
||||
p1.id.recalculateHash();
|
||||
p2.id.recalculateHash();
|
||||
PlotSquared.getPlots(world).put(p1.id, p1);
|
||||
PlotSquared.getPlots(world).put(p2.id, p2);
|
||||
PlotSquared.getInstance().getPlots(world).put(p1.id, p1);
|
||||
PlotSquared.getInstance().getPlots(world).put(p2.id, p2);
|
||||
// Swap database
|
||||
DBFunc.dbManager.swapPlots(p2, p1);
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean swapData(final String world, final PlotId current, final PlotId newPlot, final Runnable whenDone) {
|
||||
Plot p1 = PlotSquared.getPlots(world).get(current);
|
||||
Plot p2 = PlotSquared.getPlots(world).get(newPlot);
|
||||
Plot p1 = PlotSquared.getInstance().getPlots(world).get(current);
|
||||
Plot p2 = PlotSquared.getInstance().getPlots(world).get(newPlot);
|
||||
if (p1 == null || p1.owner == null) {
|
||||
if (p2 != null && p2.owner != null) {
|
||||
moveData(p2, p1, whenDone);
|
||||
@ -1155,12 +1141,12 @@ public class MainUtil {
|
||||
p1.id.y = p2.id.y.intValue();
|
||||
p2.id.x = temp.x;
|
||||
p2.id.y = temp.y;
|
||||
PlotSquared.getPlots(world).remove(p1.id);
|
||||
PlotSquared.getPlots(world).remove(p2.id);
|
||||
PlotSquared.getInstance().getPlots(world).remove(p1.id);
|
||||
PlotSquared.getInstance().getPlots(world).remove(p2.id);
|
||||
p1.id.recalculateHash();
|
||||
p2.id.recalculateHash();
|
||||
PlotSquared.getPlots(world).put(p1.id, p1);
|
||||
PlotSquared.getPlots(world).put(p2.id, p2);
|
||||
PlotSquared.getInstance().getPlots(world).put(p1.id, p1);
|
||||
PlotSquared.getInstance().getPlots(world).put(p2.id, p2);
|
||||
// Swap database
|
||||
DBFunc.dbManager.swapPlots(p2, p1);
|
||||
TaskManager.runTask(whenDone);
|
||||
@ -1184,12 +1170,12 @@ public class MainUtil {
|
||||
final ArrayList<PlotId> selection = getPlotSelectionIds(pos1.id, pos2.id);
|
||||
for (final PlotId id : selection) {
|
||||
DBFunc.movePlot(getPlot(plot1.world, new PlotId(id.x, id.y)), getPlot(plot2.world, new PlotId(id.x + offset_x, id.y + offset_y)));
|
||||
final Plot plot = PlotSquared.getPlots(plot1.world).get(id);
|
||||
PlotSquared.getPlots(plot1.world).remove(id);
|
||||
final Plot plot = PlotSquared.getInstance().getPlots(plot1.world).get(id);
|
||||
PlotSquared.getInstance().getPlots(plot1.world).remove(id);
|
||||
plot.id.x += offset_x;
|
||||
plot.id.y += offset_y;
|
||||
plot.id.recalculateHash();
|
||||
PlotSquared.getPlots(plot2.world).put(plot.id, plot);
|
||||
PlotSquared.getInstance().getPlots(plot2.world).put(plot.id, plot);
|
||||
}
|
||||
TaskManager.runTaskLater(whenDone, 1);
|
||||
return true;
|
||||
@ -1214,12 +1200,12 @@ public class MainUtil {
|
||||
for (final PlotId id : selection) {
|
||||
String worldOriginal = plot1.world;
|
||||
PlotId idOriginal = new PlotId(id.x, id.y);
|
||||
final Plot plot = PlotSquared.getPlots(plot1.world).get(id);
|
||||
PlotSquared.getPlots(plot1.world).remove(id);
|
||||
final Plot plot = PlotSquared.getInstance().getPlots(plot1.world).get(id);
|
||||
PlotSquared.getInstance().getPlots(plot1.world).remove(id);
|
||||
plot.id.x += offset_x;
|
||||
plot.id.y += offset_y;
|
||||
plot.id.recalculateHash();
|
||||
PlotSquared.getPlots(plot2.world).put(plot.id, plot);
|
||||
PlotSquared.getInstance().getPlots(plot2.world).put(plot.id, plot);
|
||||
DBFunc.movePlot(getPlot(worldOriginal, idOriginal), getPlot(plot2.world, new PlotId(id.x + offset_x, id.y + offset_y)));
|
||||
}
|
||||
ChunkManager.manager.copyRegion(bot1, top, bot2, new Runnable() {
|
||||
@ -1282,7 +1268,7 @@ public class MainUtil {
|
||||
DBFunc.setDenied(world, plot, denied);
|
||||
}
|
||||
}
|
||||
PlotSquared.getPlots(world).put(plot.id, plot);
|
||||
PlotSquared.getInstance().getPlots(world).put(plot.id, plot);
|
||||
}
|
||||
ChunkManager.manager.copyRegion(bot1, top, bot2, whenDone);
|
||||
return true;
|
||||
@ -1449,14 +1435,14 @@ public class MainUtil {
|
||||
|
||||
public static Plot getBottomPlot(final Plot plot) {
|
||||
if (plot.settings.getMerged(0)) {
|
||||
final Plot p = PlotSquared.getPlots(plot.world).get(new PlotId(plot.id.x, plot.id.y - 1));
|
||||
final Plot p = PlotSquared.getInstance().getPlots(plot.world).get(new PlotId(plot.id.x, plot.id.y - 1));
|
||||
if (p == null) {
|
||||
return plot;
|
||||
}
|
||||
return getBottomPlot(p);
|
||||
}
|
||||
if (plot.settings.getMerged(3)) {
|
||||
final Plot p = PlotSquared.getPlots(plot.world).get(new PlotId(plot.id.x - 1, plot.id.y));
|
||||
final Plot p = PlotSquared.getInstance().getPlots(plot.world).get(new PlotId(plot.id.x - 1, plot.id.y));
|
||||
if (p == null) {
|
||||
return plot;
|
||||
}
|
||||
@ -1467,14 +1453,14 @@ public class MainUtil {
|
||||
|
||||
public static Plot getTopPlot(final Plot plot) {
|
||||
if (plot.settings.getMerged(2)) {
|
||||
final Plot p = PlotSquared.getPlots(plot.world).get(new PlotId(plot.id.x, plot.id.y + 1));
|
||||
final Plot p = PlotSquared.getInstance().getPlots(plot.world).get(new PlotId(plot.id.x, plot.id.y + 1));
|
||||
if (p == null) {
|
||||
return plot;
|
||||
}
|
||||
return getTopPlot(p);
|
||||
}
|
||||
if (plot.settings.getMerged(1)) {
|
||||
final Plot p = PlotSquared.getPlots(plot.world).get(new PlotId(plot.id.x + 1, plot.id.y));
|
||||
final Plot p = PlotSquared.getInstance().getPlots(plot.world).get(new PlotId(plot.id.x + 1, plot.id.y));
|
||||
if (p == null) {
|
||||
return plot;
|
||||
}
|
||||
@ -1501,8 +1487,8 @@ public class MainUtil {
|
||||
if (id == null) {
|
||||
return null;
|
||||
}
|
||||
if (PlotSquared.getPlots(world).containsKey(id)) {
|
||||
return PlotSquared.getPlots(world).get(id);
|
||||
if (PlotSquared.getInstance().getPlots(world).containsKey(id)) {
|
||||
return PlotSquared.getInstance().getPlots(world).get(id);
|
||||
}
|
||||
return new Plot(id, null, new ArrayList<UUID>(), new ArrayList<UUID>(), world);
|
||||
}
|
||||
@ -1514,11 +1500,11 @@ public class MainUtil {
|
||||
*/
|
||||
public static PlotId getPlotAbs(final Location loc) {
|
||||
final String world = loc.getWorld();
|
||||
final PlotManager manager = PlotSquared.getPlotManager(world);
|
||||
final PlotManager manager = PlotSquared.getInstance().getPlotManager(world);
|
||||
if (manager == null) {
|
||||
return null;
|
||||
}
|
||||
final PlotWorld plotworld = PlotSquared.getPlotWorld(world);
|
||||
final PlotWorld plotworld = PlotSquared.getInstance().getPlotWorld(world);
|
||||
return manager.getPlotIdAbs(plotworld, loc.getX(), loc.getY(), loc.getZ());
|
||||
}
|
||||
|
||||
@ -1529,11 +1515,11 @@ public class MainUtil {
|
||||
*/
|
||||
public static PlotId getPlotId(final Location loc) {
|
||||
final String world = loc.getWorld();
|
||||
final PlotManager manager = PlotSquared.getPlotManager(world);
|
||||
final PlotManager manager = PlotSquared.getInstance().getPlotManager(world);
|
||||
if (manager == null) {
|
||||
return null;
|
||||
}
|
||||
final PlotWorld plotworld = PlotSquared.getPlotWorld(world);
|
||||
final PlotWorld plotworld = PlotSquared.getInstance().getPlotWorld(world);
|
||||
final PlotId id = manager.getPlotId(plotworld, loc.getX(), loc.getY(), loc.getZ());
|
||||
if ((id != null) && (plotworld.TYPE == 2)) {
|
||||
if (ClusterManager.getCluster(world, id) == null) {
|
||||
|
@ -20,18 +20,17 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.intellectualcrafters.plot.util.bukkit;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.intellectualcrafters.plot.PlotSquared;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Functions involving players, plots and locations.
|
||||
@ -111,7 +110,7 @@ public class BukkitPlayerFunctions {
|
||||
* @return boolean
|
||||
*/
|
||||
public static Plot getCurrentPlot(final Player player) {
|
||||
if (!PlotSquared.isPlotWorld(player.getWorld().getName())) {
|
||||
if (!PlotSquared.getInstance().isPlotWorld(player.getWorld().getName())) {
|
||||
return null;
|
||||
}
|
||||
final PlotId id = MainUtil.getPlotId(BukkitUtil.getLocation(player));
|
||||
@ -133,7 +132,7 @@ public class BukkitPlayerFunctions {
|
||||
* @return boolean
|
||||
*/
|
||||
public static Set<Plot> getPlayerPlots(final String world, final Player plr) {
|
||||
final Set<Plot> p = PlotSquared.getPlots(world, plr.getName());
|
||||
final Set<Plot> p = PlotSquared.getInstance().getPlots(world, plr.getName());
|
||||
if (p == null) {
|
||||
return new HashSet<>();
|
||||
}
|
||||
|
@ -1,21 +1,20 @@
|
||||
package com.intellectualcrafters.plot.util.bukkit;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.World.Environment;
|
||||
import org.bukkit.WorldCreator;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import com.intellectualcrafters.plot.PlotSquared;
|
||||
import com.intellectualcrafters.plot.config.ConfigurationNode;
|
||||
import com.intellectualcrafters.plot.object.PlotGenerator;
|
||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
import com.intellectualcrafters.plot.object.SetupObject;
|
||||
import com.intellectualcrafters.plot.util.SetupUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.World.Environment;
|
||||
import org.bukkit.WorldCreator;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
public class BukkitSetupUtils extends SetupUtils {
|
||||
|
||||
@ -29,7 +28,7 @@ public class BukkitSetupUtils extends SetupUtils {
|
||||
if (plugin.isEnabled()) {
|
||||
final ChunkGenerator generator = plugin.getDefaultWorldGenerator(testWorld, "");
|
||||
if (generator != null) {
|
||||
PlotSquared.removePlotWorld(testWorld);
|
||||
PlotSquared.getInstance().removePlotWorld(testWorld);
|
||||
final String name = plugin.getDescription().getName();
|
||||
// final PlotGenerator pgen = (PlotGenerator) generator;
|
||||
// if (pgen.getPlotManager() instanceof SquarePlotManager) {
|
||||
|
@ -1,22 +1,21 @@
|
||||
package com.intellectualcrafters.plot.util.bukkit;
|
||||
|
||||
import com.intellectualcrafters.plot.PlotSquared;
|
||||
import com.intellectualcrafters.plot.generator.AugmentedPopulator;
|
||||
import com.intellectualcrafters.plot.util.SetupUtils;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.generator.BlockPopulator;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.generator.BlockPopulator;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
|
||||
import com.intellectualcrafters.plot.PlotSquared;
|
||||
import com.intellectualcrafters.plot.generator.AugmentedPopulator;
|
||||
import com.intellectualcrafters.plot.util.SetupUtils;
|
||||
|
||||
public class SetGenCB {
|
||||
public static void setGenerator(World world) throws Exception {
|
||||
SetupUtils.manager.updateGenerators();
|
||||
PlotSquared.removePlotWorldAbs(world.getName());
|
||||
PlotSquared.getInstance().removePlotWorldAbs(world.getName());
|
||||
ChunkGenerator gen = world.getGenerator();
|
||||
if (gen == null) {
|
||||
return;
|
||||
@ -50,6 +49,6 @@ public class SetGenCB {
|
||||
}
|
||||
}
|
||||
}
|
||||
PlotSquared.loadWorld(world.getName(), null);
|
||||
PlotSquared.getInstance().loadWorld(world.getName(), null);
|
||||
}
|
||||
}
|
||||
|
@ -1,52 +1,41 @@
|
||||
package com.intellectualcrafters.plot.util.bukkit;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.FilenameFilter;
|
||||
import java.nio.file.StandardOpenOption;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
|
||||
import com.google.common.collect.BiMap;
|
||||
import com.google.common.collect.HashBiMap;
|
||||
import com.google.common.io.Files;
|
||||
import com.google.common.io.InputSupplier;
|
||||
import com.google.common.io.OutputSupplier;
|
||||
import com.intellectualcrafters.plot.PlotSquared;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
import com.intellectualcrafters.plot.object.BukkitOfflinePlayer;
|
||||
import com.intellectualcrafters.plot.object.OfflinePlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.StringWrapper;
|
||||
import com.intellectualcrafters.plot.object.*;
|
||||
import com.intellectualcrafters.plot.util.ExpireManager;
|
||||
import com.intellectualcrafters.plot.util.NbtFactory;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.intellectualcrafters.plot.util.NbtFactory.NbtCompound;
|
||||
import com.intellectualcrafters.plot.util.NbtFactory.StreamOptions;
|
||||
import com.intellectualcrafters.plot.uuid.DefaultUUIDWrapper;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.intellectualcrafters.plot.uuid.OfflineUUIDWrapper;
|
||||
import com.intellectualcrafters.plot.uuid.UUIDWrapper;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FilenameFilter;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.UUID;
|
||||
|
||||
public class UUIDHandler {
|
||||
public static boolean CACHED = false;
|
||||
public static UUIDWrapper uuidWrapper = null;
|
||||
public static HashMap<String, PlotPlayer> players = new HashMap<>();
|
||||
|
||||
/**
|
||||
* Map containing names and UUIDs
|
||||
*
|
||||
* @see com.google.common.collect.BiMap
|
||||
*/
|
||||
private final static BiMap<StringWrapper, UUID> uuidMap = HashBiMap.create(new HashMap<StringWrapper, UUID>());
|
||||
public static boolean CACHED = false;
|
||||
public static UUIDWrapper uuidWrapper = null;
|
||||
public static HashMap<String, PlotPlayer> players = new HashMap<>();
|
||||
|
||||
public static void add(final StringWrapper name, final UUID uuid) {
|
||||
if ((uuid == null) || (name == null)) {
|
||||
@ -101,7 +90,7 @@ public class UUIDHandler {
|
||||
|
||||
public static HashSet<UUID> getAllUUIDS() {
|
||||
HashSet<UUID> uuids = new HashSet<UUID>();
|
||||
for (Plot plot : PlotSquared.getPlotsRaw()) {
|
||||
for (Plot plot : PlotSquared.getInstance().getPlotsRaw()) {
|
||||
for (UUID uuid : plot.trusted) {
|
||||
uuids.add(uuid);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user