Merge branch 'feature/rm-redundant-methods' of https://github.com/manuelgu/PlotSquared into manuelgu-feature/rm-redundant-methods

This commit is contained in:
MattBDev
2016-03-20 19:52:11 -04:00
16 changed files with 288 additions and 275 deletions

View File

@ -45,7 +45,6 @@ import org.bukkit.OfflinePlayer;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
@ -66,21 +65,21 @@ import java.util.UUID;
* @see PS
*/
public class PlotAPI {
/**
* Permission that allows for admin access, this permission node will allow the player to use any part of the
* plugin, without limitations.
* @deprecated Use C.PERMISSION_ADMIN.s() instead
* @deprecated Use C.PERMISSION_ADMIN instead
*/
@Deprecated
public static final String ADMIN_PERMISSION = C.PERMISSION_ADMIN.s();
/**
* @deprecated Use new PlotAPI() instead
*/
@Deprecated
public PlotAPI(final JavaPlugin plugin) {}
/**
* @see PS
*
@ -93,7 +92,7 @@ public class PlotAPI {
*/
@Deprecated
public PlotAPI() {}
/**
* Get all plots
*
@ -104,7 +103,7 @@ public class PlotAPI {
public Set<Plot> getAllPlots() {
return PS.get().getPlots();
}
/**
* Return all plots for a player
*
@ -115,7 +114,7 @@ public class PlotAPI {
public Set<Plot> getPlayerPlots(final Player player) {
return PS.get().getPlots(BukkitUtil.getPlayer(player));
}
/**
* Add a plot world
*
@ -125,7 +124,7 @@ public class PlotAPI {
public void addPlotArea(final PlotArea plotArea) {
PS.get().addPlotArea(plotArea);
}
/**
* @return main configuration
*
@ -134,7 +133,7 @@ public class PlotAPI {
public YamlConfiguration getConfig() {
return PS.get().config;
}
/**
* @return storage configuration
*
@ -143,7 +142,7 @@ public class PlotAPI {
public YamlConfiguration getStorage() {
return PS.get().storage;
}
/**
* Get the main class for this plugin <br> - Contains a lot of fields and methods - not very well organized <br>
* Only use this if you really need it
@ -155,7 +154,7 @@ public class PlotAPI {
public PS getMain() {
return PS.get();
}
/**
* ChunkManager class contains several useful methods<br>
* - Chunk deletion<br>
@ -179,7 +178,7 @@ public class PlotAPI {
public SetQueue getSetQueue() {
return SetQueue.IMP;
}
/**
* UUIDWrapper class has basic methods for getting UUIDS (it's recommended to use the UUIDHandler class instead)
*
@ -190,7 +189,7 @@ public class PlotAPI {
public UUIDWrapper getUUIDWrapper() {
return UUIDHandler.getUUIDWrapper();
}
/**
* Do not use this. Instead use FlagManager.[method] in your code.
* - Flag related stuff
@ -203,7 +202,7 @@ public class PlotAPI {
public FlagManager getFlagManager() {
return new FlagManager();
}
/**
* Do not use this. Instead use MainUtil.[method] in your code.
* - Basic plot management stuff
@ -216,7 +215,7 @@ public class PlotAPI {
public MainUtil getMainUtil() {
return new MainUtil();
}
/**
* Do not use this. Instead use C.PERMISSION_[method] in your code.
* - Basic permission management stuff
@ -235,7 +234,7 @@ public class PlotAPI {
}
return perms.toArray(new String[perms.size()]);
}
/**
* SchematicHandler class contains methods related to pasting, reading and writing schematics
*
@ -246,7 +245,7 @@ public class PlotAPI {
public SchematicHandler getSchematicHandler() {
return SchematicHandler.manager;
}
/**
* Use C.[caption] instead
*
@ -258,7 +257,7 @@ public class PlotAPI {
public C[] getCaptions() {
return C.values();
}
/**
* Get the plot manager for a world. - Most of these methods can be accessed through the MainUtil
*
@ -276,7 +275,7 @@ public class PlotAPI {
}
return getPlotManager(world.getName());
}
public Set<PlotArea> getPlotAreas(World world) {
if (world == null) {
return new HashSet<>();
@ -308,7 +307,7 @@ public class PlotAPI {
return null;
}
}
/**
* Get the settings for a world (settings bundled in PlotArea class) - You will need to downcast for the specific
* settings a Generator has. e.g. DefaultPlotWorld class implements PlotArea
@ -327,7 +326,7 @@ public class PlotAPI {
}
return getWorldSettings(world.getName());
}
/**
* Get the settings for a world (settings bundled in PlotArea class)
*
@ -354,7 +353,7 @@ public class PlotAPI {
return null;
}
}
/**
* Send a message to a player.
*
@ -367,7 +366,7 @@ public class PlotAPI {
public void sendMessage(final Player player, final C c) {
MainUtil.sendMessage(BukkitUtil.getPlayer(player), c);
}
/**
* Send a message to a player. - Supports color codes
*
@ -379,7 +378,7 @@ public class PlotAPI {
public void sendMessage(final Player player, final String string) {
MainUtil.sendMessage(BukkitUtil.getPlayer(player), string);
}
/**
* Send a message to the console. - Supports color codes
*
@ -390,7 +389,7 @@ public class PlotAPI {
public void sendConsoleMessage(final String msg) {
PS.log(msg);
}
/**
* Send a message to the console
*
@ -400,9 +399,9 @@ public class PlotAPI {
* @see com.intellectualcrafters.plot.config.C
*/
public void sendConsoleMessage(final C c) {
sendConsoleMessage(c.s());
sendConsoleMessage(c);
}
/**
* Register a flag for use in plots
*
@ -414,7 +413,7 @@ public class PlotAPI {
public void addFlag(final AbstractFlag flag) {
FlagManager.addFlag(flag);
}
/**
* get all the currently registered flags
*
@ -426,7 +425,7 @@ public class PlotAPI {
public AbstractFlag[] getFlags() {
return FlagManager.getFlags().toArray(new AbstractFlag[FlagManager.getFlags().size()]);
}
/**
* Get a plot based on the ID
*
@ -449,7 +448,7 @@ public class PlotAPI {
}
return area.getPlot(new PlotId(x, z));
}
/**
* Get a plot based on the location
*
@ -465,7 +464,7 @@ public class PlotAPI {
}
return BukkitUtil.getLocation(l).getPlot();
}
/**
* Get a plot based on the player location
*
@ -479,7 +478,7 @@ public class PlotAPI {
public Plot getPlot(final Player player) {
return this.getPlot(player.getLocation());
}
/**
* Check whether or not a player has a plot
*
@ -493,7 +492,7 @@ public class PlotAPI {
public boolean hasPlot(final World world, final Player player) {
return getPlots(world, player, true) != null && getPlots(world, player, true).length > 0;
}
/**
* Get all plots for the player
*
@ -517,7 +516,7 @@ public class PlotAPI {
}
return pPlots.toArray(new Plot[pPlots.size()]);
}
/**
* Get all plots for the world
*
@ -536,7 +535,7 @@ public class PlotAPI {
Collection<Plot> plots = PS.get().getPlots(world.getName());
return plots.toArray(new Plot[plots.size()]);
}
/**
* Get all plot worlds
*
@ -548,7 +547,7 @@ public class PlotAPI {
Set<String> plotWorldStrings = PS.get().getPlotWorldStrings();
return plotWorldStrings.toArray(new String[plotWorldStrings.size()]);
}
/**
* Get if plot world
*
@ -562,7 +561,7 @@ public class PlotAPI {
public boolean isPlotWorld(final World world) {
return PS.get().hasPlotArea(world.getName());
}
/**
* Get plot locations
*
@ -578,7 +577,7 @@ public class PlotAPI {
public Location[] getLocations(final Plot p) {
return new Location[] { BukkitUtil.getLocation(p.getBottom()), BukkitUtil.getLocation(p.getTop()), BukkitUtil.getLocation(p.getHome()) };
}
/**
* Get home location
*
@ -591,7 +590,7 @@ public class PlotAPI {
public Location getHomeLocation(final Plot p) {
return BukkitUtil.getLocation(p.getHome());
}
/**
* Get Bottom Location (min, min, min)
*
@ -607,14 +606,14 @@ public class PlotAPI {
public Location getBottomLocation(final Plot p) {
return BukkitUtil.getLocation(p.getBottom());
}
/**
* Get Top Location (max, max, max)
*
* @param p Plot that you want to get the location for
*
* @return plot top location
*
*
* @deprecated As merged plots may not have a rectangular shape
*
* @see Plot
@ -623,7 +622,7 @@ public class PlotAPI {
public Location getTopLocation(final Plot p) {
return BukkitUtil.getLocation(p.getTop());
}
/**
* Check whether or not a player is in a plot
*
@ -635,7 +634,7 @@ public class PlotAPI {
public boolean isInPlot(final Player player) {
return getPlot(player) != null;
}
/**
* Register a subcommand
*
@ -650,7 +649,7 @@ public class PlotAPI {
MainCommand.getInstance().createCommand(c);
}
}
/**
* Get the PlotSquared class
*
@ -661,7 +660,7 @@ public class PlotAPI {
public PS getPlotSquared() {
return PS.get();
}
/**
* Get the player plot count
*
@ -677,7 +676,7 @@ public class PlotAPI {
}
return BukkitUtil.getPlayer(player).getPlotCount(world.getName());
}
/**
* Get a collection containing the players plots
*
@ -696,7 +695,7 @@ public class PlotAPI {
}
return BukkitUtil.getPlayer(player).getPlots(world.getName());
}
/**
* Get the numbers of plots, which the player is able to build in
*
@ -709,7 +708,7 @@ public class PlotAPI {
final PlotPlayer pp = BukkitUtil.getPlayer(player);
return pp.getAllowedPlots();
}
/**
* Get the PlotPlayer for a player<br>
* - The PlotPlayer is usually cached and will provide useful functions relating to players
@ -722,7 +721,7 @@ public class PlotAPI {
public PlotPlayer wrapPlayer(final Player player) {
return PlotPlayer.wrap(player);
}
/**
* Get the PlotPlayer for a UUID (Please note that PlotSquared can be configured to provide different UUIDs than bukkit)
*
@ -734,7 +733,7 @@ public class PlotAPI {
public PlotPlayer wrapPlayer(final UUID uuid) {
return PlotPlayer.wrap(uuid);
}
/**
* Get the PlotPlayer for a username
*
@ -746,7 +745,7 @@ public class PlotAPI {
public PlotPlayer wrapPlayer(final String player) {
return PlotPlayer.wrap(player);
}
/**
* Get the PlotPlayer for an offline player<br>
* Note that this will work if the player is offline, however not all functionality will work

View File

@ -87,7 +87,6 @@ import org.bukkit.generator.ChunkGenerator;
import org.bukkit.metadata.MetadataValue;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
@ -97,12 +96,12 @@ import java.util.List;
import java.util.UUID;
public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
public static BukkitMain THIS;
public static WorldEditPlugin worldEdit;
private int[] version;
@Override
public int[] getServerVersion() {
if (version == null) {
@ -123,20 +122,20 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
}
return version;
}
@Override
public void onEnable() {
THIS = this;
new PS(this, "Bukkit");
}
@Override
public void onDisable() {
PS.get().disable();
Bukkit.getScheduler().cancelTasks(this);
THIS = null;
}
@Override
public void log(String message) {
if ((THIS != null) && (Bukkit.getServer().getConsoleSender() != null)) {
@ -151,20 +150,20 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
}
System.out.println(ConsoleColors.fromString(message));
}
@Override
public void disable() {
if (THIS != null) {
onDisable();
}
}
@Override
public int[] getPluginVersion() {
final String[] split = getDescription().getVersion().split("\\.");
return new int[] { Integer.parseInt(split[0]), Integer.parseInt(split[1]), Integer.parseInt(split[2]) };
}
@Override
public void registerCommands() {
final BukkitCommand bcmd = new BukkitCommand();
@ -174,25 +173,25 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
plotCommand.setTabCompleter(bcmd);
MainCommand.getInstance().addCommand(new DebugUUID());
}
@Override
public File getDirectory() {
return getDataFolder();
}
@Override
public File getWorldContainer() {
return Bukkit.getWorldContainer();
}
@Override
public TaskManager getTaskManager() {
return new BukkitTaskManager();
}
@Override
public void runEntityTask() {
log(C.PREFIX.s() + "KillAllEntities started.");
log(C.PREFIX + "KillAllEntities started.");
TaskManager.runTaskRepeat(new Runnable() {
@Override
public void run() {
@ -335,7 +334,7 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
}
}, 20);
}
@Override
final public ChunkGenerator getDefaultWorldGenerator(final String world, final String id) {
final HybridGen result = new HybridGen();
@ -344,7 +343,7 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
}
return (ChunkGenerator) result.specify();
}
@Override
public void registerPlayerEvents() {
getServer().getPluginManager().registerEvents(new PlayerEvents(), this);
@ -355,23 +354,23 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
getServer().getPluginManager().registerEvents(new PlayerEvents_1_8_3(), this);
}
}
@Override
public void registerInventoryEvents() {
// Part of PlayerEvents - can be moved if necessary
}
@Override
public void registerPlotPlusEvents() {
PlotPlusListener.startRunnable(this);
getServer().getPluginManager().registerEvents(new PlotPlusListener(), this);
}
@Override
public void registerForceFieldEvents() {
getServer().getPluginManager().registerEvents(new ForceFieldListener(), this);
}
@Override
public boolean initWorldEdit() {
if (getServer().getPluginManager().getPlugin("WorldEdit") != null) {
@ -388,7 +387,7 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
}
return false;
}
@Override
public EconHandler getEconomyHandler() {
try {
@ -400,7 +399,7 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
}
return null;
}
@Override
public PlotQueue initPlotQueue() {
try {
@ -439,12 +438,12 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
return new SlowQueue();
}
}
@Override
public WorldUtil initWorldUtil() {
return new BukkitUtil();
}
@Override
public boolean initPlotMeConverter() {
TaskManager.runTaskLaterAsync(new Runnable() {
@ -463,7 +462,7 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
}, 20);
return (Bukkit.getPluginManager().getPlugin("PlotMe") != null) || (Bukkit.getPluginManager().getPlugin("AthionPlots") != null);
}
@Override
public GeneratorWrapper<?> getGenerator(final String world, final String name) {
if (name == null) {
@ -480,17 +479,17 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
return new BukkitPlotGenerator(new HybridGen());
}
}
@Override
public HybridUtils initHybridUtils() {
return new BukkitHybridUtils();
}
@Override
public SetupUtils initSetupUtils() {
return new BukkitSetupUtils();
}
@Override
public UUIDHandlerImplementation initUUIDHandler() {
final boolean checkVersion = PS.get().checkVersion(getServerVersion(), 1, 7, 6);
@ -514,7 +513,7 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
Settings.OFFLINE_MODE = true;
}
if (!checkVersion) {
log(C.PREFIX.s() + " &c[WARN] Titles are disabled - please update your version of Bukkit to support this feature.");
log(C.PREFIX + " &c[WARN] Titles are disabled - please update your version of Bukkit to support this feature.");
Settings.TITLES = false;
FlagManager.removeFlag(FlagManager.getFlag("titles"));
} else {
@ -524,59 +523,59 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
}
}
if (Settings.OFFLINE_MODE) {
log(C.PREFIX.s() + " &6PlotSquared is using Offline Mode UUIDs either because of user preference, or because you are using an old version of Bukkit");
log(C.PREFIX + " &6PlotSquared is using Offline Mode UUIDs either because of user preference, or because you are using an old version of Bukkit");
} else {
log(C.PREFIX.s() + " &6PlotSquared is using online UUIDs");
log(C.PREFIX + " &6PlotSquared is using online UUIDs");
}
return Settings.USE_SQLUUIDHANDLER ? new SQLUUIDHandler(wrapper) : new FileUUIDHandler(wrapper);
}
@Override
public ChunkManager initChunkManager() {
return new BukkitChunkManager();
}
@Override
public EventUtil initEventUtil() {
return new BukkitEventUtil();
}
@Override
public void unregister(final PlotPlayer player) {
BukkitUtil.removePlayer(player.getName());
}
@Override
public void registerChunkProcessor() {
getServer().getPluginManager().registerEvents(new ChunkListener(), this);
}
@Override
public void registerWorldEvents() {
getServer().getPluginManager().registerEvents(new WorldEvents(), this);
}
@Override
public InventoryUtil initInventoryUtil() {
return new BukkitInventoryUtil();
}
@Override
public String getServerName() {
return Bukkit.getServerName();
}
@Override
public void startMetrics() {
try {
Metrics metrics = new Metrics(this);
metrics.start();
log(C.PREFIX.s() + "&6Metrics enabled.");
log(C.PREFIX + "&6Metrics enabled.");
} catch (IOException e) {
log(C.PREFIX.s() + "&cFailed to load up metrics.");
log(C.PREFIX + "&cFailed to load up metrics.");
}
}
@Override
public void setGenerator(final String worldname) {
World world = BukkitUtil.getWorld(worldname);
@ -615,18 +614,18 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
PS.get().loadWorld(worldname, null);
}
}
@Override
public SchematicHandler initSchematicHandler() {
return new BukkitSchematicHandler();
}
@Override
public AbstractTitle initTitleManager() {
// Already initialized in UUID handler
return AbstractTitle.TITLE_CLASS;
}
@Override
public PlotPlayer wrapPlayer(final Object obj) {
if (obj instanceof Player) {
@ -640,13 +639,13 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
}
return null;
}
@Override
public String getNMSPackage() {
String name = Bukkit.getServer().getClass().getPackage().getName();
return name.substring(name.lastIndexOf('.') + 1);
}
@Override
public ChatManager<?> initChatManager() {
if (Settings.FANCY_CHAT) {
@ -655,12 +654,12 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
return new BukkitPlainChatManager();
}
}
@Override
public GeneratorWrapper<?> wrapPlotGenerator(IndependentPlotGenerator generator) {
return new BukkitPlotGenerator(generator);
}
@Override
public List<String> getPluginIds() {
ArrayList<String> names = new ArrayList<>();

View File

@ -42,7 +42,6 @@ import com.plotsquared.bukkit.uuid.LowerOfflineUUIDWrapper;
import com.plotsquared.bukkit.uuid.OfflineUUIDWrapper;
import com.plotsquared.general.commands.Argument;
import com.plotsquared.general.commands.CommandDeclaration;
import java.io.File;
import java.io.FilenameFilter;
import java.io.IOException;
@ -63,16 +62,16 @@ usage = "/plot uuidconvert <lower|offline|online>",
requiredType = RequiredType.CONSOLE,
category = CommandCategory.DEBUG)
public class DebugUUID extends SubCommand {
public DebugUUID() {
requiredArguments = new Argument[] { Argument.String };
}
@Override
public boolean onCommand(final PlotPlayer player, final String[] args) {
final UUIDWrapper currentUUIDWrapper = UUIDHandler.getUUIDWrapper();
final UUIDWrapper newWrapper;
switch (args[0].toLowerCase()) {
case "lower":
newWrapper = new LowerOfflineUUIDWrapper();
@ -104,7 +103,7 @@ public class DebugUUID extends SubCommand {
MainUtil.sendMessage(player, "&7Retype the command with the override parameter when ready :)");
return false;
}
if (currentUUIDWrapper.getClass().getCanonicalName().equals(newWrapper.getClass().getCanonicalName())) {
MainUtil.sendMessage(player, "&cUUID mode already in use!");
return false;
@ -114,14 +113,14 @@ public class DebugUUID extends SubCommand {
for (Entry<String, PlotPlayer> entry : UUIDHandler.getPlayers().entrySet()) {
entry.getValue().kick("PlotSquared UUID conversion has been initiated. You may reconnect when finished.");
}
MainUtil.sendMessage(player, "&7 - Initializing map");
final HashMap<UUID, UUID> uCMap = new HashMap<>();
final HashMap<UUID, UUID> uCReverse = new HashMap<>();
MainUtil.sendMessage(player, "&7 - Collecting playerdata");
final HashSet<String> worlds = new HashSet<>();
worlds.add(WorldUtil.IMP.getMainWorld());
worlds.add("world");
@ -142,7 +141,7 @@ public class DebugUUID extends SubCommand {
final UUID uuid = UUID.fromString(s);
uuids.add(uuid);
} catch (final Exception e) {
MainUtil.sendMessage(player, C.PREFIX.s() + "Invalid playerdata: " + current);
MainUtil.sendMessage(player, C.PREFIX + "Invalid playerdata: " + current);
}
}
final File playersFolder = new File(worldname + File.separator + "players");
@ -158,7 +157,7 @@ public class DebugUUID extends SubCommand {
}
}
}
MainUtil.sendMessage(player, "&7 - Populating map");
UUID uuid2;
final UUIDWrapper wrapper = new DefaultUUIDWrapper();
@ -172,7 +171,7 @@ public class DebugUUID extends SubCommand {
uCReverse.put(uuid2, uuid);
}
} catch (final Throwable e) {
MainUtil.sendMessage(player, C.PREFIX.s() + "&6Invalid playerdata: " + uuid.toString() + ".dat");
MainUtil.sendMessage(player, C.PREFIX + "&6Invalid playerdata: " + uuid.toString() + ".dat");
}
}
for (final String name : names) {
@ -204,7 +203,7 @@ public class DebugUUID extends SubCommand {
MainUtil.sendMessage(player, "&a - Successfully repopulated");
}
}
MainUtil.sendMessage(player, "&7 - Replacing cache");
TaskManager.runTaskAsync(new Runnable() {
@Override
@ -215,9 +214,9 @@ public class DebugUUID extends SubCommand {
UUIDHandler.add(new StringWrapper(name), entry.getValue());
}
}
MainUtil.sendMessage(player, "&7 - Scanning for applicable files (uuids.txt)");
final File file = new File(PS.get().IMP.getDirectory(), "uuids.txt");
if (file.exists()) {
try {
@ -250,12 +249,12 @@ public class DebugUUID extends SubCommand {
e.printStackTrace();
}
}
MainUtil.sendMessage(player, "&7 - Replacing wrapper");
UUIDHandler.setUUIDWrapper(newWrapper);
MainUtil.sendMessage(player, "&7 - Updating plot objects");
for (final Plot plot : PS.get().getPlots()) {
final UUID value = uCMap.get(plot.owner);
if (value != null) {
@ -265,13 +264,13 @@ public class DebugUUID extends SubCommand {
plot.getMembers().clear();
plot.getDenied().clear();
}
MainUtil.sendMessage(player, "&7 - Deleting database");
final AbstractDB database = DBFunc.dbManager;
final boolean result = database.deleteTables();
MainUtil.sendMessage(player, "&7 - Creating tables");
try {
database.createTables();
if (!result) {
@ -294,7 +293,7 @@ public class DebugUUID extends SubCommand {
e.printStackTrace();
return;
}
if (newWrapper instanceof OfflineUUIDWrapper) {
PS.get().config.set("UUID.force-lowercase", false);
PS.get().config.set("UUID.offline", true);
@ -307,9 +306,9 @@ public class DebugUUID extends SubCommand {
} catch (IOException e) {
MainUtil.sendMessage(player, "Could not save configuration. It will need to be manuall set!");
}
MainUtil.sendMessage(player, "&7 - Populating tables");
TaskManager.runTaskAsync(new Runnable() {
@Override
public void run() {
@ -322,7 +321,7 @@ public class DebugUUID extends SubCommand {
});
}
});
MainUtil.sendMessage(player, "&aIt is now safe for players to join");
MainUtil.sendMessage(player, "&cConversion is still in progress, you will be notified when it is complete");
}

View File

@ -10,12 +10,15 @@ import com.intellectualcrafters.plot.database.DBFunc;
import com.intellectualcrafters.plot.object.OfflinePlotPlayer;
import com.intellectualcrafters.plot.object.RunnableVal;
import com.intellectualcrafters.plot.object.StringWrapper;
import com.intellectualcrafters.plot.util.*;
import com.intellectualcrafters.plot.util.ExpireManager;
import com.intellectualcrafters.plot.util.StringMan;
import com.intellectualcrafters.plot.util.TaskManager;
import com.intellectualcrafters.plot.util.UUIDHandler;
import com.intellectualcrafters.plot.util.UUIDHandlerImplementation;
import com.intellectualcrafters.plot.uuid.UUIDWrapper;
import com.plotsquared.bukkit.util.NbtFactory;
import org.bukkit.Bukkit;
import org.bukkit.World;
import java.io.File;
import java.io.FileInputStream;
import java.io.FilenameFilter;
@ -28,16 +31,16 @@ import java.util.List;
import java.util.UUID;
public class FileUUIDHandler extends UUIDHandlerImplementation {
public FileUUIDHandler(final UUIDWrapper wrapper) {
super(wrapper);
}
@Override
public boolean startCaching(final Runnable whenDone) {
return super.startCaching(whenDone) && cache(whenDone);
}
public boolean cache(final Runnable whenDone) {
final File container = Bukkit.getWorldContainer();
final List<World> worlds = Bukkit.getWorlds();
@ -50,7 +53,7 @@ public class FileUUIDHandler extends UUIDHandlerImplementation {
TaskManager.runTaskAsync(new Runnable() {
@Override
public void run() {
PS.debug(C.PREFIX.s() + "&6Starting player data caching for: " + world);
PS.debug(C.PREFIX + "&6Starting player data caching for: " + world);
final File uuidfile = new File(PS.get().IMP.getDirectory(), "uuids.txt");
if (uuidfile.exists()) {
try {
@ -112,7 +115,7 @@ public class FileUUIDHandler extends UUIDHandlerImplementation {
}
} catch (final Exception e) {
e.printStackTrace();
PS.debug(C.PREFIX.s() + "Invalid playerdata: " + current);
PS.debug(C.PREFIX + "Invalid playerdata: " + current);
}
}
}
@ -150,7 +153,7 @@ public class FileUUIDHandler extends UUIDHandlerImplementation {
final UUID uuid = UUID.fromString(s);
uuids.add(uuid);
} catch (final Exception e) {
PS.debug(C.PREFIX.s() + "Invalid playerdata: " + current);
PS.debug(C.PREFIX + "Invalid playerdata: " + current);
}
}
break;
@ -195,7 +198,7 @@ public class FileUUIDHandler extends UUIDHandlerImplementation {
}
toAdd.put(new StringWrapper(name), uuid);
} catch (final Throwable e) {
PS.debug(C.PREFIX.s() + "&6Invalid playerdata: " + uuid.toString() + ".dat");
PS.debug(C.PREFIX + "&6Invalid playerdata: " + uuid.toString() + ".dat");
}
}
for (final String name : names) {
@ -226,7 +229,7 @@ public class FileUUIDHandler extends UUIDHandlerImplementation {
});
return true;
}
@Override
public void fetchUUID(final String name, final RunnableVal<UUID> ifFetch) {
TaskManager.runTaskAsync(new Runnable() {

View File

@ -30,7 +30,7 @@ import java.util.HashMap;
import java.util.UUID;
public class SQLUUIDHandler extends UUIDHandlerImplementation {
final String PROFILE_URL = "https://sessionserver.mojang.com/session/minecraft/profile/";
final int MAX_REQUESTS = 500;
final int INTERVAL = 12000;
@ -56,13 +56,13 @@ public class SQLUUIDHandler extends UUIDHandlerImplementation {
}
startCaching(null);
}
private Connection getConnection() {
synchronized (_sqLite) {
return _sqLite.getConnection();
}
}
@Override
public boolean startCaching(final Runnable whenDone) {
if (!super.startCaching(whenDone)) {
@ -192,10 +192,10 @@ public class SQLUUIDHandler extends UUIDHandlerImplementation {
});
return true;
}
@Override
public void fetchUUID(final String name, final RunnableVal<UUID> ifFetch) {
PS.debug(C.PREFIX.s() + "UUID for '" + name + "' was null. We'll cache this from the mojang servers!");
PS.debug(C.PREFIX + "UUID for '" + name + "' was null. We'll cache this from the mojang servers!");
if (ifFetch == null) {
return;
}
@ -227,7 +227,7 @@ public class SQLUUIDHandler extends UUIDHandlerImplementation {
}
});
}
@Override
public void handleShutdown() {
super.handleShutdown();
@ -237,7 +237,7 @@ public class SQLUUIDHandler extends UUIDHandlerImplementation {
throw new SQLUUIDHandlerException("Couldn't close database connection", e);
}
}
@Override
public boolean add(final StringWrapper name, final UUID uuid) {
// Ignoring duplicates
@ -250,7 +250,7 @@ public class SQLUUIDHandler extends UUIDHandlerImplementation {
statement.setString(1, uuid.toString());
statement.setString(2, name.toString());
statement.execute();
PS.debug(C.PREFIX.s() + "&cAdded '&6" + uuid + "&c' - '&6" + name + "&c'");
PS.debug(C.PREFIX + "&cAdded '&6" + uuid + "&c' - '&6" + name + "&c'");
} catch (final SQLException e) {
e.printStackTrace();
}
@ -260,7 +260,7 @@ public class SQLUUIDHandler extends UUIDHandlerImplementation {
}
return false;
}
/**
* This is useful for name changes
*/
@ -275,7 +275,7 @@ public class SQLUUIDHandler extends UUIDHandlerImplementation {
statement.setString(1, name.value);
statement.setString(2, uuid.toString());
statement.execute();
PS.debug(C.PREFIX.s() + "Name change for '" + uuid + "' to '" + name.value + "'");
PS.debug(C.PREFIX + "Name change for '" + uuid + "' to '" + name.value + "'");
} catch (final SQLException e) {
e.printStackTrace();
}