mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-26 07:06:44 +01:00
Merge remote-tracking branch 'origin/master'
Conflicts: PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlotHelper.java
This commit is contained in:
commit
2a9119c7c3
@ -75,6 +75,9 @@ import java.util.concurrent.TimeUnit;
|
||||
@SuppressWarnings("unused")
|
||||
public class PlotMain extends JavaPlugin {
|
||||
|
||||
/**
|
||||
* Permission that allows for "everything"
|
||||
*/
|
||||
public static final String ADMIN_PERMISSION =
|
||||
"plots.admin";
|
||||
/**
|
||||
@ -192,7 +195,7 @@ public class PlotMain extends JavaPlugin {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}, 0l, /*12 * 60 * 60 * 20l*/ 86_40_00L);
|
||||
}, 0l, 86_40_00L);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -274,6 +277,7 @@ public class PlotMain extends JavaPlugin {
|
||||
* Set the uuid saver
|
||||
*
|
||||
* @param saver new saver
|
||||
* @see com.intellectualcrafters.plot.uuid.UUIDSaver
|
||||
*/
|
||||
public static void setUUIDSaver(final UUIDSaver saver) {
|
||||
uuidSaver = saver;
|
||||
@ -372,6 +376,12 @@ public class PlotMain extends JavaPlugin {
|
||||
return new HashSet<>(myplots);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get plots for the specified world
|
||||
*
|
||||
* @param world A world, in which you want to search for plots
|
||||
* @return HashMap containing Plot IDs and Plot Objects
|
||||
*/
|
||||
public static HashMap<PlotId, Plot> getPlots(final String world) {
|
||||
if (plots.containsKey(world)) {
|
||||
return plots.get(world);
|
||||
@ -479,6 +489,13 @@ public class PlotMain extends JavaPlugin {
|
||||
return (values.toArray(new Plot[values.size()]));
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a plot
|
||||
* @param world The Plot World
|
||||
* @param id The Plot ID
|
||||
* @param callEvent Whether or not to call the PlotDeleteEvent
|
||||
* @return true if successful, false if not
|
||||
*/
|
||||
public static boolean removePlot(final String world, final PlotId id, final boolean callEvent) {
|
||||
if (callEvent) {
|
||||
final PlotDeleteEvent event = new PlotDeleteEvent(world, id);
|
||||
@ -595,7 +612,12 @@ public class PlotMain extends JavaPlugin {
|
||||
}
|
||||
}
|
||||
|
||||
private static double getJavaVersion() {
|
||||
/**
|
||||
* Get the java version
|
||||
*
|
||||
* @return Java Version as a double
|
||||
*/
|
||||
public static double getJavaVersion() {
|
||||
return Double.parseDouble(System.getProperty("java.specification.version"));
|
||||
}
|
||||
|
||||
@ -623,27 +645,12 @@ public class PlotMain extends JavaPlugin {
|
||||
}
|
||||
|
||||
/**
|
||||
* ..
|
||||
* Teleport a player to a plot
|
||||
* @param player Player to teleport
|
||||
* @param from Previous Location
|
||||
* @param plot Plot to teleport to
|
||||
* @return true if successful
|
||||
*/
|
||||
|
||||
// Old Stuff
|
||||
/*
|
||||
* private static boolean checkForUpdate() throws IOException { URL call =
|
||||
* new URL(Settings.Update.VERSION_URL); InputStream stream =
|
||||
* call.openStream(); BufferedReader reader = new BufferedReader(new
|
||||
* InputStreamReader(stream)); String latest = reader.readLine();
|
||||
* reader.close(); return
|
||||
* !getPlotMain().getDescription().getVersion().equalsIgnoreCase(latest); }
|
||||
* private static String getNextUpdateString() throws IOException { URL call
|
||||
* = new URL(Settings.Update.VERSION_URL); InputStream stream =
|
||||
* call.openStream(); BufferedReader reader = new BufferedReader(new
|
||||
* InputStreamReader(stream)); return reader.readLine(); } private static
|
||||
* void update() throws IOException { sendConsoleSenderMessage(C.PREFIX.s()
|
||||
* + "&c&lThere is an update! New Update: &6&l" + getNextUpdateString() +
|
||||
* "&c&l, Current Update: &6&l" +
|
||||
* getPlotMain().getDescription().getVersion()); }
|
||||
*/
|
||||
|
||||
public static boolean teleportPlayer(final Player player, final Location from, final Plot plot) {
|
||||
final PlayerTeleportToPlotEvent event = new PlayerTeleportToPlotEvent(player, from, plot);
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
@ -704,10 +711,19 @@ public class PlotMain extends JavaPlugin {
|
||||
System.out.println(ChatColor.stripColor(ChatColor.translateAlternateColorCodes('&', C.PREFIX.s() + c.s())));
|
||||
}
|
||||
|
||||
/**
|
||||
* Reload all translations
|
||||
* @throws IOException
|
||||
*/
|
||||
public static void reloadTranslations() throws IOException {
|
||||
C.setupTranslations();
|
||||
}
|
||||
|
||||
/**
|
||||
* Ge the last played time
|
||||
* @param uuid UUID for the player
|
||||
* @return last play time as a long
|
||||
*/
|
||||
public static long getLastPlayed(final UUID uuid) {
|
||||
if (uuid == null) {
|
||||
return 0;
|
||||
@ -923,7 +939,7 @@ public class PlotMain extends JavaPlugin {
|
||||
options.put("api.location", Settings.API_URL);
|
||||
options.put("api.custom", Settings.CUSTOM_API);
|
||||
options.put("titles", Settings.TITLES);
|
||||
|
||||
options.put("teleport.on_login", Settings.TELEPORT_ON_LOGIN);
|
||||
options.put("perm-based-mob-cap.enabled", Settings.MOB_CAP_ENABLED);
|
||||
options.put("perm-based-mob-cap.max", Settings.MOB_CAP);
|
||||
|
||||
@ -936,6 +952,7 @@ public class PlotMain extends JavaPlugin {
|
||||
if (Settings.DEBUG) {
|
||||
sendConsoleSenderMessage(C.PREFIX.s() + "&6Debug Mode Enabled (Default). Edit the config to turn this off.");
|
||||
}
|
||||
Settings.TELEPORT_ON_LOGIN = config.getBoolean("teleport.on_login");
|
||||
Settings.KILL_ROAD_MOBS = config.getBoolean("kill_road_mobs");
|
||||
Settings.WORLDGUARD = config.getBoolean("worldguard.enabled");
|
||||
Settings.MOB_PATHFINDING = config.getBoolean("mob_pathfinding");
|
||||
@ -949,6 +966,10 @@ public class PlotMain extends JavaPlugin {
|
||||
Settings.SCHEMATIC_SAVE_PATH = config.getString("schematics.save_path");
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a plotworld config section
|
||||
* @param plotworld World to create the section for
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public static void createConfiguration(final PlotWorld plotworld) {
|
||||
final Map<String, Object> options = new HashMap<>();
|
||||
@ -1276,6 +1297,12 @@ public class PlotMain extends JavaPlugin {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a Plot world
|
||||
* @param world World to add
|
||||
* @param plotworld PlotWorld Object
|
||||
* @param manager Plot Manager for the new world
|
||||
*/
|
||||
public static void addPlotWorld(final String world, final PlotWorld plotworld, final PlotManager manager) {
|
||||
worlds.put(world, plotworld);
|
||||
managers.put(world, manager);
|
||||
@ -1284,33 +1311,56 @@ public class PlotMain extends JavaPlugin {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a plot world
|
||||
* @param world World to remove
|
||||
*/
|
||||
public static void removePlotWorld(final String world) {
|
||||
plots.remove(world);
|
||||
managers.remove(world);
|
||||
worlds.remove(world);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all plots
|
||||
* @return All Plos in a hashmap (world, Hashmap contiang ids and objects))
|
||||
*/
|
||||
public static HashMap<String, HashMap<PlotId, Plot>> getAllPlotsRaw() {
|
||||
return plots;
|
||||
}
|
||||
|
||||
public static void setAllPlotsRaw(final HashMap<String, HashMap<PlotId, Plot>> plots) {
|
||||
PlotMain.plots = new LinkedHashMap<>(plots);
|
||||
// PlotMain.plots.putAll(plots);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set all plots
|
||||
*
|
||||
* @param plots New Plot LinkedHashMap
|
||||
*/
|
||||
public static void setAllPlotsRaw(final LinkedHashMap<String, HashMap<PlotId, Plot>> plots) {
|
||||
PlotMain.plots = plots;
|
||||
}
|
||||
|
||||
/**
|
||||
* !!WorldGeneration!!
|
||||
* Set all plots
|
||||
*
|
||||
* @param plots New Plot HashMap
|
||||
*/
|
||||
public static void setAllPlotsRaw(final HashMap<String, HashMap<PlotId, Plot>> plots) {
|
||||
PlotMain.plots = new LinkedHashMap<>(plots);
|
||||
// PlotMain.plots.putAll(plots);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the PlotSquared World Generator
|
||||
*
|
||||
* @see com.intellectualcrafters.plot.generator.WorldGenerator
|
||||
*/
|
||||
@Override
|
||||
public ChunkGenerator getDefaultWorldGenerator(final String world, final String id) {
|
||||
final public ChunkGenerator getDefaultWorldGenerator(final String world, final String id) {
|
||||
return new WorldGenerator(world);
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup the logger mechanics
|
||||
*/
|
||||
private void setupLogger() {
|
||||
final File log = new File(getMain().getDataFolder() + File.separator + "logs" + File.separator + "plots.log");
|
||||
if (!log.exists()) {
|
||||
@ -1337,7 +1387,7 @@ public class PlotMain extends JavaPlugin {
|
||||
*/
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public void onEnable() {
|
||||
final public void onEnable() {
|
||||
// Pre-Steps
|
||||
{
|
||||
// Init the logger
|
||||
@ -1569,7 +1619,7 @@ public class PlotMain extends JavaPlugin {
|
||||
* On unload
|
||||
*/
|
||||
@Override
|
||||
public void onDisable() {
|
||||
final public void onDisable() {
|
||||
try {
|
||||
C.saveTranslations();
|
||||
} catch (Exception e) {
|
||||
|
@ -33,7 +33,9 @@ import com.intellectualcrafters.plot.object.PlotManager;
|
||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
import com.intellectualcrafters.plot.util.PlayerFunctions;
|
||||
import com.intellectualcrafters.plot.util.PlotHelper;
|
||||
import com.intellectualcrafters.plot.util.PlotSquaredException;
|
||||
import com.intellectualcrafters.plot.util.SchematicHandler;
|
||||
import com.sun.istack.internal.NotNull;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
@ -45,41 +47,70 @@ import java.util.ArrayList;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* The plotMain api class.
|
||||
* PlotSquared API
|
||||
*
|
||||
* @author Citymonstret, Empire92
|
||||
* @author Citymonstret
|
||||
* @author Empire92
|
||||
*
|
||||
* @version API 2.0
|
||||
*/
|
||||
@SuppressWarnings({"unused", "javadoc"})
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class PlotAPI {
|
||||
|
||||
/**
|
||||
* Admin Permission
|
||||
* Permission that allows for admin access,
|
||||
* this permission node will allow the player
|
||||
* to use any part of the plugin, without limitations.
|
||||
*/
|
||||
public static final String ADMIN_PERMISSION = "plots.admin";
|
||||
|
||||
/**
|
||||
* Plot Helper Class
|
||||
* <p/>
|
||||
* General functions involving plots, and the management of them
|
||||
*
|
||||
* @see com.intellectualcrafters.plot.util.PlotHelper
|
||||
*/
|
||||
private static PlotHelper plotHelper;
|
||||
|
||||
/**
|
||||
* Player Functions
|
||||
*
|
||||
* General functions involving players, and plot worlds
|
||||
* @see com.intellectualcrafters.plot.util.PlayerFunctions
|
||||
*/
|
||||
private static PlayerFunctions playerFunctions;
|
||||
|
||||
/**
|
||||
* Flag Manager
|
||||
*
|
||||
* The manager which handles all flags
|
||||
* @see com.intellectualcrafters.plot.flag.FlagManager
|
||||
*/
|
||||
private static FlagManager flagManager;
|
||||
|
||||
/**
|
||||
* Schematic Handler
|
||||
*
|
||||
* The handler which is used to create, and paste, schematics
|
||||
* @see com.intellectualcrafters.plot.util.SchematicHandler
|
||||
*/
|
||||
private static SchematicHandler schematicHandler;
|
||||
|
||||
// Methods/fields in PlotMain class
|
||||
|
||||
// PlotMain.checkForExpiredPlots(); #Ignore
|
||||
// PlotMain.killAllEntities(); #Ignore
|
||||
//
|
||||
// PlotMain.createConfiguration(plotworld);
|
||||
// PlotMain.getPlots(player)
|
||||
// PlotMain.getPlots(world)
|
||||
// PlotMain.getPlots(world, player)
|
||||
// PlotMain.getWorldPlots(world)
|
||||
// PlotMain.getPlotWorlds()
|
||||
// PlotMain.isPlotWorld(world)
|
||||
// PlotMain.removePlot(world, id, callEvent)
|
||||
// PlotMain.teleportPlayer(player, from, plot)
|
||||
// PlotMain.updatePlot(plot);
|
||||
/**
|
||||
* The translation class.
|
||||
*
|
||||
* @see com.intellectualcrafters.plot.config.C
|
||||
*/
|
||||
private static C c;
|
||||
|
||||
// Reference
|
||||
// To access plotMain stuff.
|
||||
/**
|
||||
* PlotMain instance
|
||||
*
|
||||
* This is the instance that allows for most methods to be used.
|
||||
* @see com.intellectualcrafters.plot.PlotMain
|
||||
*/
|
||||
private final PlotMain plotMain;
|
||||
|
||||
/**
|
||||
@ -87,15 +118,21 @@ public class PlotAPI {
|
||||
* (Optimally the plugin that is accessing the method)
|
||||
*
|
||||
* @param plugin Plugin used to access this method
|
||||
* @throws com.intellectualcrafters.plot.util.PlotSquaredException if the program fails to fetch the PlotMain instance
|
||||
* @see com.intellectualcrafters.plot.PlotMain
|
||||
*/
|
||||
public PlotAPI(final JavaPlugin plugin) {
|
||||
public PlotAPI(@NotNull final JavaPlugin plugin) {
|
||||
this.plotMain = JavaPlugin.getPlugin(PlotMain.class);
|
||||
if (plotMain == null) {
|
||||
throw new PlotSquaredException(PlotSquaredException.PlotError.PLOTMAIN_NULL, "Failed to fetch the plotmain instance, Plot API for " + plugin.getName() + " will be disabled");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all plots
|
||||
*
|
||||
* @return all plots
|
||||
* @see com.intellectualcrafters.plot.PlotMain#getPlots()
|
||||
*/
|
||||
public Set<Plot> getAllPlots() {
|
||||
return PlotMain.getPlots();
|
||||
@ -104,15 +141,15 @@ public class PlotAPI {
|
||||
/**
|
||||
* Return all plots for a player
|
||||
*
|
||||
* @param player
|
||||
* @param player Player, whose plots to search for
|
||||
* @return all plots that a player owns
|
||||
*/
|
||||
public Set<Plot> getPlayerPlots(final Player player) {
|
||||
public Set<Plot> getPlayerPlots(@NotNull final Player player) {
|
||||
return PlotMain.getPlots(player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a plotoworld
|
||||
* Add a plot world
|
||||
*
|
||||
* @param world World Name
|
||||
* @param plotWorld Plot World Object
|
||||
@ -121,7 +158,7 @@ public class PlotAPI {
|
||||
* com.intellectualcrafters.plot.object.PlotWorld,
|
||||
* com.intellectualcrafters.plot.object.PlotManager)
|
||||
*/
|
||||
public void addPlotWorld(final String world, final PlotWorld plotWorld, final PlotManager manager) {
|
||||
public void addPlotWorld(@NotNull final String world, @NotNull final PlotWorld plotWorld, @NotNull final PlotManager manager) {
|
||||
PlotMain.addPlotWorld(world, plotWorld, manager);
|
||||
}
|
||||
|
||||
@ -147,6 +184,7 @@ public class PlotAPI {
|
||||
* Only use this if you really need it
|
||||
*
|
||||
* @return PlotMain PlotSquared Main Class
|
||||
* @see com.intellectualcrafters.plot.PlotMain
|
||||
*/
|
||||
public PlotMain getMain() {
|
||||
return this.plotMain;
|
||||
@ -156,6 +194,7 @@ public class PlotAPI {
|
||||
* PlotHelper class contains useful methods relating to plots.
|
||||
*
|
||||
* @return PlotHelper
|
||||
* @see com.intellectualcrafters.plot.util.PlotHelper
|
||||
*/
|
||||
public PlotHelper getPlotHelper() {
|
||||
return plotHelper;
|
||||
@ -166,6 +205,7 @@ public class PlotAPI {
|
||||
* player/plot methods are here as well
|
||||
*
|
||||
* @return PlayerFunctions
|
||||
* @see com.intellectualcrafters.plot.util.PlayerFunctions
|
||||
*/
|
||||
public PlayerFunctions getPlayerFunctions() {
|
||||
return playerFunctions;
|
||||
@ -175,6 +215,7 @@ public class PlotAPI {
|
||||
* FlagManager class contains methods relating to plot flags
|
||||
*
|
||||
* @return FlagManager
|
||||
* @see com.intellectualcrafters.plot.flag.FlagManager
|
||||
*/
|
||||
public FlagManager getFlagManager() {
|
||||
return flagManager;
|
||||
@ -184,6 +225,7 @@ public class PlotAPI {
|
||||
* SchematicHandler class contains methods related to pasting schematics
|
||||
*
|
||||
* @return SchematicHandler
|
||||
* @see com.intellectualcrafters.plot.util.SchematicHandler
|
||||
*/
|
||||
public SchematicHandler getSchematicHandler() {
|
||||
return schematicHandler;
|
||||
@ -193,6 +235,7 @@ public class PlotAPI {
|
||||
* C class contains all the captions from the translations.yml file.
|
||||
*
|
||||
* @return C
|
||||
* @see com.intellectualcrafters.plot.config.C
|
||||
*/
|
||||
public C getCaptions() {
|
||||
return c;
|
||||
@ -202,10 +245,12 @@ public class PlotAPI {
|
||||
* Get the plot manager for a world. - Most of these methods can be accessed
|
||||
* through the PlotHelper
|
||||
*
|
||||
* @param world
|
||||
* @param world Which manager to get
|
||||
* @return PlotManager
|
||||
* @see com.intellectualcrafters.plot.object.PlotManager
|
||||
* @see PlotMain#getPlotManager(org.bukkit.World)
|
||||
*/
|
||||
public PlotManager getPlotManager(final World world) {
|
||||
public PlotManager getPlotManager(@NotNull final World world) {
|
||||
return PlotMain.getPlotManager(world);
|
||||
}
|
||||
|
||||
@ -213,10 +258,12 @@ public class PlotAPI {
|
||||
* Get the plot manager for a world. - Contains useful low level methods for
|
||||
* plot merging, clearing, and tessellation
|
||||
*
|
||||
* @param world
|
||||
* @param world Plot World
|
||||
* @return PlotManager
|
||||
* @see PlotMain#getPlotManager(String)
|
||||
* @see com.intellectualcrafters.plot.object.PlotManager
|
||||
*/
|
||||
public PlotManager getPlotManager(final String world) {
|
||||
public PlotManager getPlotManager(@NotNull final String world) {
|
||||
return PlotMain.getPlotManager(world);
|
||||
}
|
||||
|
||||
@ -228,8 +275,10 @@ public class PlotAPI {
|
||||
* @param world (to get settings of)
|
||||
* @return PlotWorld class for that world ! will return null if not a plot
|
||||
* world world
|
||||
* @see PlotMain#getWorldSettings(org.bukkit.World)
|
||||
* @see com.intellectualcrafters.plot.object.PlotWorld
|
||||
*/
|
||||
public PlotWorld getWorldSettings(final World world) {
|
||||
public PlotWorld getWorldSettings(@NotNull final World world) {
|
||||
return PlotMain.getWorldSettings(world);
|
||||
}
|
||||
|
||||
@ -239,37 +288,42 @@ public class PlotAPI {
|
||||
* @param world (to get settings of)
|
||||
* @return PlotWorld class for that world ! will return null if not a plot
|
||||
* world world
|
||||
* @see PlotMain#getWorldSettings(String)
|
||||
* @see com.intellectualcrafters.plot.object.PlotWorld
|
||||
*/
|
||||
public PlotWorld getWorldSettings(final String world) {
|
||||
public PlotWorld getWorldSettings(@NotNull final String world) {
|
||||
return PlotMain.getWorldSettings(world);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a message to a player.
|
||||
*
|
||||
* @param player
|
||||
* @param player Player that will receive the message
|
||||
* @param c (Caption)
|
||||
* @see com.intellectualcrafters.plot.util.PlayerFunctions#sendMessage(org.bukkit.entity.Player, com.intellectualcrafters.plot.config.C, String...)
|
||||
*/
|
||||
public void sendMessage(final Player player, final C c) {
|
||||
public void sendMessage(@NotNull final Player player, @NotNull final C c) {
|
||||
PlayerFunctions.sendMessage(player, c);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a message to a player. - Supports color codes
|
||||
*
|
||||
* @param player
|
||||
* @param string
|
||||
* @param player Player that will receive the message
|
||||
* @param string The message
|
||||
* @see com.intellectualcrafters.plot.util.PlayerFunctions#sendMessage(org.bukkit.entity.Player, String)
|
||||
*/
|
||||
public void sendMessage(final Player player, final String string) {
|
||||
public void sendMessage(@NotNull final Player player, @NotNull final String string) {
|
||||
PlayerFunctions.sendMessage(player, string);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a message to the console. - Supports color codes
|
||||
*
|
||||
* @param msg
|
||||
* @param msg Message that should be sent to the console
|
||||
* @see PlotMain#sendConsoleSenderMessage(String)
|
||||
*/
|
||||
public void sendConsoleMessage(final String msg) {
|
||||
public void sendConsoleMessage(@NotNull final String msg) {
|
||||
PlotMain.sendConsoleSenderMessage(msg);
|
||||
}
|
||||
|
||||
@ -277,17 +331,21 @@ public class PlotAPI {
|
||||
* Send a message to the console
|
||||
*
|
||||
* @param c (Caption)
|
||||
* @see #sendConsoleMessage(String)
|
||||
* @see com.intellectualcrafters.plot.config.C
|
||||
*/
|
||||
public void sendConsoleMessage(final C c) {
|
||||
public void sendConsoleMessage(@NotNull final C c) {
|
||||
sendConsoleMessage(c.s());
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a flag for use in plots
|
||||
*
|
||||
* @param flag
|
||||
* @param flag Flag that should be registered
|
||||
* @see com.intellectualcrafters.plot.flag.FlagManager#addFlag(com.intellectualcrafters.plot.flag.AbstractFlag)
|
||||
* @see com.intellectualcrafters.plot.flag.AbstractFlag
|
||||
*/
|
||||
public void addFlag(final AbstractFlag flag) {
|
||||
public void addFlag(@NotNull final AbstractFlag flag) {
|
||||
FlagManager.addFlag(flag);
|
||||
}
|
||||
|
||||
@ -295,6 +353,8 @@ public class PlotAPI {
|
||||
* get all the currently registered flags
|
||||
*
|
||||
* @return array of Flag[]
|
||||
* @see com.intellectualcrafters.plot.flag.FlagManager#getFlags()
|
||||
* @see com.intellectualcrafters.plot.flag.AbstractFlag
|
||||
*/
|
||||
public AbstractFlag[] getFlags() {
|
||||
return FlagManager.getFlags().toArray(new AbstractFlag[FlagManager.getFlags().size()]);
|
||||
@ -303,42 +363,49 @@ public class PlotAPI {
|
||||
/**
|
||||
* Get a plot based on the ID
|
||||
*
|
||||
* @param world
|
||||
* @param x
|
||||
* @param z
|
||||
* @param world World in which the plot is located
|
||||
* @param x Plot Location X Co-ord
|
||||
* @param z Plot Location Z Co-ord
|
||||
* @return plot, null if ID is wrong
|
||||
* @see PlotHelper#getPlot(org.bukkit.World, com.intellectualcrafters.plot.object.PlotId)
|
||||
* @see com.intellectualcrafters.plot.object.Plot
|
||||
*/
|
||||
public Plot getPlot(final World world, final int x, final int z) {
|
||||
public Plot getPlot(@NotNull final World world, final int x, final int z) {
|
||||
return PlotHelper.getPlot(world, new PlotId(x, z));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a plot based on the location
|
||||
*
|
||||
* @param l
|
||||
* @param l The location that you want to to retrieve the plot from
|
||||
* @return plot if found, otherwise it creates a temporary plot-
|
||||
* @see PlotHelper#getCurrentPlot(org.bukkit.Location)
|
||||
* @see com.intellectualcrafters.plot.object.Plot
|
||||
*/
|
||||
public Plot getPlot(final Location l) {
|
||||
public Plot getPlot(@NotNull final Location l) {
|
||||
return PlotHelper.getCurrentPlot(l);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a plot based on the player location
|
||||
*
|
||||
* @param player
|
||||
* @param player Get the current plot for the player location
|
||||
* @return plot if found, otherwise it creates a temporary plot
|
||||
* @see #getPlot(org.bukkit.Location)
|
||||
* @see com.intellectualcrafters.plot.object.Plot
|
||||
*/
|
||||
public Plot getPlot(final Player player) {
|
||||
public Plot getPlot(@NotNull final Player player) {
|
||||
return this.getPlot(player.getLocation());
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether or not a player has a plot
|
||||
*
|
||||
* @param player
|
||||
* @param player Player that you want to check for
|
||||
* @return true if player has a plot, false if not.
|
||||
* @see #getPlots(org.bukkit.World, org.bukkit.entity.Player, boolean)
|
||||
*/
|
||||
public boolean hasPlot(final World world, final Player player) {
|
||||
public boolean hasPlot(@NotNull final World world, @NotNull final Player player) {
|
||||
return (getPlots(world, player, true) != null) && (getPlots(world, player, true).length > 0);
|
||||
}
|
||||
|
||||
@ -347,8 +414,9 @@ public class PlotAPI {
|
||||
*
|
||||
* @param plr to search for
|
||||
* @param just_owner should we just search for owner? Or with rights?
|
||||
* @see com.intellectualcrafters.plot.object.Plot
|
||||
*/
|
||||
public Plot[] getPlots(final World world, final Player plr, final boolean just_owner) {
|
||||
public Plot[] getPlots(@NotNull final World world, @NotNull final Player plr, final boolean just_owner) {
|
||||
final ArrayList<Plot> pPlots = new ArrayList<>();
|
||||
for (final Plot plot : PlotMain.getPlots(world).values()) {
|
||||
if (just_owner) {
|
||||
@ -369,8 +437,10 @@ public class PlotAPI {
|
||||
*
|
||||
* @param world to get plots of
|
||||
* @return Plot[] - array of plot objects in world
|
||||
* @see PlotMain#getWorldPlots(org.bukkit.World)
|
||||
* @see com.intellectualcrafters.plot.object.Plot
|
||||
*/
|
||||
public Plot[] getPlots(final World world) {
|
||||
public Plot[] getPlots(@NotNull final World world) {
|
||||
return PlotMain.getWorldPlots(world);
|
||||
}
|
||||
|
||||
@ -378,6 +448,7 @@ public class PlotAPI {
|
||||
* Get all plot worlds
|
||||
*
|
||||
* @return World[] - array of plot worlds
|
||||
* @see com.intellectualcrafters.plot.PlotMain#getPlotWorlds()
|
||||
*/
|
||||
public String[] getPlotWorlds() {
|
||||
return PlotMain.getPlotWorlds();
|
||||
@ -388,18 +459,24 @@ public class PlotAPI {
|
||||
*
|
||||
* @param world (to check if plot world)
|
||||
* @return boolean (if plot world or not)
|
||||
* @see com.intellectualcrafters.plot.PlotMain#isPlotWorld(org.bukkit.World)
|
||||
*/
|
||||
public boolean isPlotWorld(final World world) {
|
||||
public boolean isPlotWorld(@NotNull final World world) {
|
||||
return PlotMain.isPlotWorld(world);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get plot locations
|
||||
*
|
||||
* @param p
|
||||
* @param p Plot that you want to get the locations for
|
||||
* @return [0] = bottomLc, [1] = topLoc, [2] = home
|
||||
* @see com.intellectualcrafters.plot.util.PlotHelper#getPlotBottomLoc(org.bukkit.World, com.intellectualcrafters.plot.object.PlotId)
|
||||
* @see com.intellectualcrafters.plot.util.PlotHelper#getPlotTopLoc(org.bukkit.World, com.intellectualcrafters.plot.object.PlotId)
|
||||
* @see com.intellectualcrafters.plot.util.PlotHelper#getPlotHome(org.bukkit.World, com.intellectualcrafters.plot.object.Plot)
|
||||
* @see com.intellectualcrafters.plot.object.PlotHomePosition
|
||||
* @see com.intellectualcrafters.plot.object.Plot
|
||||
*/
|
||||
public Location[] getLocations(final Plot p) {
|
||||
public Location[] getLocations(@NotNull final Plot p) {
|
||||
final World world = Bukkit.getWorld(p.world);
|
||||
return new Location[]{PlotHelper.getPlotBottomLoc(world, p.id), PlotHelper.getPlotTopLoc(world, p.id), PlotHelper.getPlotHome(world, p.id)};
|
||||
}
|
||||
@ -407,31 +484,38 @@ public class PlotAPI {
|
||||
/**
|
||||
* Get home location
|
||||
*
|
||||
* @param p
|
||||
* @param p Plot that you want to get the location for
|
||||
* @return plot bottom location
|
||||
* @see com.intellectualcrafters.plot.util.PlotHelper#getPlotHome(org.bukkit.World, com.intellectualcrafters.plot.object.Plot)
|
||||
* @see com.intellectualcrafters.plot.object.PlotHomePosition
|
||||
* @see com.intellectualcrafters.plot.object.Plot
|
||||
*/
|
||||
public Location getHomeLocation(final Plot p) {
|
||||
public Location getHomeLocation(@NotNull final Plot p) {
|
||||
return PlotHelper.getPlotHome(p.getWorld(), p.id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Bottom Location
|
||||
* Get Bottom Location (min, min, min)
|
||||
*
|
||||
* @param p
|
||||
* @param p Plot that you want to get the location for
|
||||
* @return plot bottom location
|
||||
* @see com.intellectualcrafters.plot.util.PlotHelper#getPlotBottomLoc(org.bukkit.World, com.intellectualcrafters.plot.object.PlotId)
|
||||
* @see com.intellectualcrafters.plot.object.Plot
|
||||
*/
|
||||
public Location getBottomLocation(final Plot p) {
|
||||
public Location getBottomLocation(@NotNull final Plot p) {
|
||||
final World world = Bukkit.getWorld(p.world);
|
||||
return PlotHelper.getPlotBottomLoc(world, p.id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Top Location
|
||||
* Get Top Location (max, max, max)
|
||||
*
|
||||
* @param p
|
||||
* @param p Plot that you want to get the location for
|
||||
* @return plot top location
|
||||
* @see PlotHelper#getPlotTopLoc(org.bukkit.World, com.intellectualcrafters.plot.object.PlotId)
|
||||
* @see com.intellectualcrafters.plot.object.Plot
|
||||
*/
|
||||
public Location getTopLocation(final Plot p) {
|
||||
public Location getTopLocation(@NotNull final Plot p) {
|
||||
final World world = Bukkit.getWorld(p.world);
|
||||
return PlotHelper.getPlotTopLoc(world, p.id);
|
||||
}
|
||||
@ -439,19 +523,22 @@ public class PlotAPI {
|
||||
/**
|
||||
* Check whether or not a player is in a plot
|
||||
*
|
||||
* @param player
|
||||
* @param player who we're checking for
|
||||
* @return true if the player is in a plot, false if not-
|
||||
* @see com.intellectualcrafters.plot.util.PlayerFunctions#isInPlot(org.bukkit.entity.Player)
|
||||
*/
|
||||
public boolean isInPlot(final Player player) {
|
||||
public boolean isInPlot(@NotNull final Player player) {
|
||||
return PlayerFunctions.isInPlot(player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a subcommand
|
||||
*
|
||||
* @param c
|
||||
* @param c SubCommand, that we want to register
|
||||
* @see com.intellectualcrafters.plot.commands.MainCommand#subCommands
|
||||
* @see com.intellectualcrafters.plot.commands.SubCommand
|
||||
*/
|
||||
public void registerCommand(final SubCommand c) {
|
||||
public void registerCommand(@NotNull final SubCommand c) {
|
||||
MainCommand.subCommands.add(c);
|
||||
}
|
||||
|
||||
@ -459,6 +546,7 @@ public class PlotAPI {
|
||||
* Get the plotMain class
|
||||
*
|
||||
* @return PlotMain Class
|
||||
* @see com.intellectualcrafters.plot.PlotMain
|
||||
*/
|
||||
public PlotMain getPlotMain() {
|
||||
return this.plotMain;
|
||||
@ -467,30 +555,36 @@ public class PlotAPI {
|
||||
/**
|
||||
* Get the player plot count
|
||||
*
|
||||
* @param player
|
||||
* @return
|
||||
* @param world Specify the world we want to select the plots from
|
||||
* @param player Player, for whom we're getting the plot count
|
||||
* @return the number of plots the player has
|
||||
* @see com.intellectualcrafters.plot.util.PlayerFunctions#getPlayerPlotCount(org.bukkit.World, org.bukkit.entity.Player)
|
||||
*/
|
||||
public int getPlayerPlotCount(final World world, final Player player) {
|
||||
public int getPlayerPlotCount(@NotNull final World world, @NotNull final Player player) {
|
||||
return PlayerFunctions.getPlayerPlotCount(world, player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a players plots
|
||||
* Get a collection containing the players plots
|
||||
*
|
||||
* @param player
|
||||
* @param world Specify the world we want to select the plots from
|
||||
* @param player Player, for whom we're getting the plots
|
||||
* @return a set containing the players plots
|
||||
* @see com.intellectualcrafters.plot.util.PlayerFunctions#getPlayerPlots(org.bukkit.World, org.bukkit.entity.Player)
|
||||
* @see com.intellectualcrafters.plot.object.Plot
|
||||
*/
|
||||
public Set<Plot> getPlayerPlots(final World world, final Player player) {
|
||||
public Set<Plot> getPlayerPlots(@NotNull final World world, @NotNull final Player player) {
|
||||
return PlayerFunctions.getPlayerPlots(world, player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the allowed plot count for a player
|
||||
* Get the numbers of plots, which the player is able to build in
|
||||
*
|
||||
* @param player
|
||||
* @param player Player, for whom we're getting the plots (trusted, helper and owner)
|
||||
* @return the number of allowed plots
|
||||
* @see com.intellectualcrafters.plot.util.PlayerFunctions#getAllowedPlots(org.bukkit.entity.Player)
|
||||
*/
|
||||
public int getAllowedPlots(final Player player) {
|
||||
public int getAllowedPlots(@NotNull final Player player) {
|
||||
return PlayerFunctions.getAllowedPlots(player);
|
||||
}
|
||||
}
|
||||
|
@ -153,7 +153,7 @@ public class Auto extends SubCommand {
|
||||
Plot plot = PlotHelper.getPlot(world, Auto.lastPlot);
|
||||
if ((plot == null) || (plot.owner == null)) {
|
||||
plot = PlotHelper.getPlot(world, Auto.lastPlot);
|
||||
Claim.claimPlot(plr, plot, true);
|
||||
Claim.claimPlot(plr, plot, true, true);
|
||||
br = true;
|
||||
final PlotWorld pw = PlotMain.getWorldSettings(world);
|
||||
final Plot plot2 = PlotMain.getPlots(world).get(plot.id);
|
||||
@ -187,7 +187,7 @@ public class Auto extends SubCommand {
|
||||
for (int j = start.y; j <= end.y; j++) {
|
||||
final Plot plot = PlotHelper.getPlot(world, new PlotId(i, j));
|
||||
final boolean teleport = ((i == end.x) && (j == end.y));
|
||||
Claim.claimPlot(plr, plot, teleport);
|
||||
Claim.claimPlot(plr, plot, teleport, true);
|
||||
}
|
||||
}
|
||||
if (!PlotHelper.mergePlots(plr, world, PlayerFunctions.getPlotSelectionIds(world, start, end))) {
|
||||
|
@ -47,12 +47,12 @@ public class Claim extends SubCommand {
|
||||
super(Command.CLAIM, "Claim the current plot you're standing on.", "claim", CommandCategory.CLAIMING, true);
|
||||
}
|
||||
|
||||
public static boolean claimPlot(final Player player, final Plot plot, final boolean teleport) {
|
||||
return claimPlot(player, plot, teleport, "");
|
||||
public static boolean claimPlot(final Player player, final Plot plot, final boolean teleport, boolean auto) {
|
||||
return claimPlot(player, plot, teleport, "", auto);
|
||||
}
|
||||
|
||||
public static boolean claimPlot(final Player player, final Plot plot, final boolean teleport, final String schematic) {
|
||||
final PlayerClaimPlotEvent event = new PlayerClaimPlotEvent(player, plot);
|
||||
public static boolean claimPlot(final Player player, final Plot plot, final boolean teleport, final String schematic, boolean auto) {
|
||||
final PlayerClaimPlotEvent event = new PlayerClaimPlotEvent(player, plot, auto);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (!event.isCancelled()) {
|
||||
PlotHelper.createPlot(player, plot);
|
||||
@ -134,6 +134,6 @@ public class Claim extends SubCommand {
|
||||
}
|
||||
}
|
||||
|
||||
return !claimPlot(plr, plot, false, schematic) || sendMessage(plr, C.PLOT_NOT_CLAIMED);
|
||||
return !claimPlot(plr, plot, false, schematic, false) || sendMessage(plr, C.PLOT_NOT_CLAIMED);
|
||||
}
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ package com.intellectualcrafters.plot.commands;
|
||||
* Created by Citymonstret on 2014-08-03.
|
||||
*
|
||||
* @author Citymonstret
|
||||
* @author Empire92
|
||||
*/
|
||||
public enum Command {
|
||||
|
||||
@ -37,6 +38,9 @@ public enum Command {
|
||||
// - /plot rate <number out of 10>
|
||||
// - /plot list <some parameter to list the most popular, and highest rated
|
||||
// plots>
|
||||
/**
|
||||
*
|
||||
*/
|
||||
SWAP("swap"),
|
||||
/**
|
||||
*
|
||||
@ -58,7 +62,13 @@ public enum Command {
|
||||
*
|
||||
*/
|
||||
PASTE("paste"),
|
||||
/**
|
||||
*
|
||||
*/
|
||||
CLIPBOARD("clipboard", "cboard"),
|
||||
/**
|
||||
*
|
||||
*/
|
||||
COPY("copy"),
|
||||
/**
|
||||
*
|
||||
@ -128,26 +138,44 @@ public enum Command {
|
||||
*
|
||||
*/
|
||||
OP("op", "admin"),
|
||||
/**
|
||||
*
|
||||
*/
|
||||
DEOP("deop", "deadmin"),
|
||||
/**
|
||||
*
|
||||
*/
|
||||
BAN("ban", "block"),
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UNBAN("unban", "unblock"),
|
||||
/**
|
||||
*
|
||||
*/
|
||||
DATABASE("database", "convert"),
|
||||
/**
|
||||
*
|
||||
*/
|
||||
TP("tp", "tp");
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String command;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String alias;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private CommandPermission permission;
|
||||
|
||||
/**
|
||||
* @param command
|
||||
* Command
|
||||
*/
|
||||
private final String command;
|
||||
|
||||
/**
|
||||
* Alias
|
||||
*/
|
||||
private final String alias;
|
||||
|
||||
/**
|
||||
* Permission Node
|
||||
*/
|
||||
private final CommandPermission permission;
|
||||
|
||||
/**
|
||||
* @param command Command "name" (/plot [cmd])
|
||||
*/
|
||||
Command(final String command) {
|
||||
this.command = command;
|
||||
@ -156,8 +184,8 @@ public enum Command {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param command
|
||||
* @param permission
|
||||
* @param command Command "name" (/plot [cmd])
|
||||
* @param permission Command Permission Node
|
||||
*/
|
||||
Command(final String command, final CommandPermission permission) {
|
||||
this.command = command;
|
||||
@ -166,8 +194,8 @@ public enum Command {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param command
|
||||
* @param alias
|
||||
* @param command Command "name" (/plot [cmd])
|
||||
* @param alias Command Alias
|
||||
*/
|
||||
Command(final String command, final String alias) {
|
||||
this.command = command;
|
||||
@ -176,9 +204,9 @@ public enum Command {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Command
|
||||
* @param alias
|
||||
* @param permission
|
||||
* @param command Command "name" (/plot [cmd])
|
||||
* @param alias Command Alias
|
||||
* @param permission Required Permission Node
|
||||
*/
|
||||
Command(final String command, final String alias, final CommandPermission permission) {
|
||||
this.command = command;
|
||||
@ -187,21 +215,22 @@ public enum Command {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
* @return command
|
||||
*/
|
||||
public String getCommand() {
|
||||
return this.command;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
* @return alias
|
||||
*/
|
||||
public String getAlias() {
|
||||
return this.alias;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
* @return permission object
|
||||
* @see com.intellectualcrafters.plot.commands.CommandPermission
|
||||
*/
|
||||
public CommandPermission getPermission() {
|
||||
return this.permission;
|
||||
|
@ -32,9 +32,9 @@ import org.bukkit.entity.Player;
|
||||
public class CommandPermission {
|
||||
|
||||
/**
|
||||
*
|
||||
* Permission Node
|
||||
*/
|
||||
public String permission;
|
||||
public final String permission;
|
||||
|
||||
/**
|
||||
* @param permission Command Permission
|
||||
|
@ -57,7 +57,7 @@ public class DebugClaimTest extends SubCommand {
|
||||
}
|
||||
|
||||
public static boolean claimPlot(final Player player, final Plot plot, final boolean teleport, @SuppressWarnings("unused") final String schematic) {
|
||||
final PlayerClaimPlotEvent event = new PlayerClaimPlotEvent(player, plot);
|
||||
final PlayerClaimPlotEvent event = new PlayerClaimPlotEvent(player, plot, true);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (!event.isCancelled()) {
|
||||
PlotHelper.createPlot(player, plot);
|
||||
|
@ -43,6 +43,9 @@ import java.util.List;
|
||||
*/
|
||||
public class MainCommand implements CommandExecutor, TabCompleter {
|
||||
|
||||
/**
|
||||
* Main Permission Node
|
||||
*/
|
||||
public static final String
|
||||
MAIN_PERMISSION = "plots.use";
|
||||
|
||||
|
@ -30,32 +30,37 @@ import org.bukkit.entity.Player;
|
||||
*
|
||||
* @author Citymonstret
|
||||
*/
|
||||
@SuppressWarnings({"deprecation", "unused", "javadoc"})
|
||||
@SuppressWarnings({"deprecation", "unused"})
|
||||
public abstract class SubCommand {
|
||||
public boolean isPlayer;
|
||||
|
||||
/**
|
||||
* Command
|
||||
*/
|
||||
public String cmd;
|
||||
public final String cmd;
|
||||
/**
|
||||
* Permission node
|
||||
*/
|
||||
public CommandPermission permission;
|
||||
public final CommandPermission permission;
|
||||
/**
|
||||
* Simple description
|
||||
*/
|
||||
public String description;
|
||||
public final String description;
|
||||
/**
|
||||
* Alias
|
||||
*/
|
||||
public String alias;
|
||||
|
||||
public final String alias;
|
||||
/**
|
||||
* Command usage
|
||||
*/
|
||||
public String usage;
|
||||
|
||||
public CommandCategory category;
|
||||
public final String usage;
|
||||
/**
|
||||
* The category
|
||||
*/
|
||||
public final CommandCategory category;
|
||||
/**
|
||||
* Is this a player-online command?
|
||||
*/
|
||||
public boolean isPlayer;
|
||||
|
||||
/**
|
||||
* @param cmd Command /plot {cmd} <-- That!
|
||||
@ -100,6 +105,11 @@ public abstract class SubCommand {
|
||||
*/
|
||||
public abstract boolean execute(final Player plr, final String... args);
|
||||
|
||||
/**
|
||||
* Execute the command as console
|
||||
*
|
||||
* @param args Arguments
|
||||
*/
|
||||
public void executeConsole(final String... args) {
|
||||
this.execute(null, args);
|
||||
}
|
||||
@ -107,23 +117,64 @@ public abstract class SubCommand {
|
||||
/**
|
||||
* Send a message
|
||||
*
|
||||
* @param plr
|
||||
* @param c
|
||||
* @param args
|
||||
* @param plr Player who will receive the mssage
|
||||
* @param c Caption
|
||||
* @param args Arguments (%s's)
|
||||
* @see com.intellectualcrafters.plot.util.PlayerFunctions#sendMessage(org.bukkit.entity.Player, com.intellectualcrafters.plot.config.C, String...)
|
||||
*/
|
||||
public boolean sendMessage(final Player plr, final C c, final String... args) {
|
||||
PlayerFunctions.sendMessage(plr, c, args);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* CommandCategory
|
||||
*
|
||||
* @author Citymonstret
|
||||
* @author Empire92
|
||||
*/
|
||||
public enum CommandCategory {
|
||||
/**
|
||||
* Claiming Commands
|
||||
* <p/>
|
||||
* Such as: /plot claim
|
||||
*/
|
||||
CLAIMING("Claiming"),
|
||||
/**
|
||||
* Teleportation Commands
|
||||
* <p/>
|
||||
* Such as: /plot visit
|
||||
*/
|
||||
TELEPORT("Teleportation"),
|
||||
/**
|
||||
* Action Commands
|
||||
* <p/>
|
||||
* Such as: /plot clear
|
||||
*/
|
||||
ACTIONS("Actions"),
|
||||
/**
|
||||
* Information Commands
|
||||
* <p/>
|
||||
* Such as: /plot info
|
||||
*/
|
||||
INFO("Information"),
|
||||
/**
|
||||
* Debug Commands
|
||||
* <p/>
|
||||
* Such as: /plot debug
|
||||
*/
|
||||
DEBUG("Debug");
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* The category name (Readable)
|
||||
*/
|
||||
private final String name;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param name readable name
|
||||
*/
|
||||
CommandCategory(final String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
@ -197,6 +197,7 @@ public enum C {
|
||||
* Teleport / Entry
|
||||
*/
|
||||
TELEPORTED_TO_PLOT("&6You have been teleported"),
|
||||
TELEPORTED_TO_ROAD("&cYou got teleported to the road"),
|
||||
/*
|
||||
* Set Block
|
||||
*/
|
||||
@ -367,13 +368,6 @@ public enum C {
|
||||
HELP_INFO("&6You have to specify a category"),
|
||||
HELP_INFO_ITEM("&6/plots help %category% &c- &6%category_desc%"),
|
||||
HELP_ITEM("&6%usage% [%alias%]\n &c%desc%\n"),
|
||||
/*
|
||||
HELP_CATEGORY("&6Current Category&c: &l%category%"),
|
||||
HELP_INFO("&6You need to specify a help category"),
|
||||
HELP_INFO_ITEM("&6/plots help %category% &c- &6%category_desc%"),
|
||||
HELP_PAGE("&c>> &6%usage% &c[&6%alias%&c]\n" + "&c>> &6%desc%\n"),
|
||||
HELP_ITEM_SEPARATOR("&c%lines"),
|
||||
HELP_HEADER("&c(Page &6%cur&c/&6%max&c) &6Help for Plots"),*/
|
||||
/*
|
||||
* Direction
|
||||
*/
|
||||
@ -382,13 +376,33 @@ public enum C {
|
||||
* Custom
|
||||
*/
|
||||
CUSTOM_STRING("-");
|
||||
static TranslationLanguage lang = new TranslationLanguage("PlotSquared", "this", "use");
|
||||
|
||||
/**
|
||||
* Special Language
|
||||
*
|
||||
* @see com.intellectualsites.translation.TranslationLanguage
|
||||
*/
|
||||
protected static TranslationLanguage lang = new TranslationLanguage("PlotSquared", "this", "use");
|
||||
|
||||
/**
|
||||
* The TranslationManager
|
||||
*
|
||||
* @see com.intellectualsites.translation.TranslationManager
|
||||
*/
|
||||
private static TranslationManager manager;
|
||||
|
||||
/**
|
||||
* The default file
|
||||
*
|
||||
* @see com.intellectualsites.translation.TranslationFile
|
||||
*/
|
||||
private static TranslationFile defaultFile;
|
||||
|
||||
/**
|
||||
* Default
|
||||
*/
|
||||
private String d;
|
||||
|
||||
/**
|
||||
* Translated
|
||||
*/
|
||||
@ -472,6 +486,7 @@ public enum C {
|
||||
|
||||
/**
|
||||
* @return translated and color decoded
|
||||
* @see org.bukkit.ChatColor#translateAlternateColorCodes(char, String)
|
||||
*/
|
||||
public String translated() {
|
||||
return ChatColor.translateAlternateColorCodes('&', this.s());
|
||||
|
@ -26,6 +26,11 @@ import org.apache.commons.lang.StringUtils;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* Configuration Node
|
||||
*
|
||||
* @author Empire92
|
||||
*/
|
||||
public class ConfigurationNode {
|
||||
private final String constant;
|
||||
private final Object default_value;
|
||||
|
@ -29,66 +29,96 @@ package com.intellectualcrafters.plot.config;
|
||||
*/
|
||||
public class Settings {
|
||||
|
||||
/**
|
||||
* Teleport to path on login
|
||||
*/
|
||||
public static boolean TELEPORT_ON_LOGIN = false;
|
||||
|
||||
/**
|
||||
* Mob Cap Enabled
|
||||
*/
|
||||
public static boolean MOB_CAP_ENABLED = false;
|
||||
|
||||
/**
|
||||
* The Mob Cap
|
||||
*/
|
||||
public static int MOB_CAP = 20;
|
||||
|
||||
/**
|
||||
* Display titles
|
||||
*/
|
||||
public static boolean TITLES = true;
|
||||
|
||||
/**
|
||||
* Schematic Save Path
|
||||
*/
|
||||
public static String SCHEMATIC_SAVE_PATH = "/var/www/schematics";
|
||||
|
||||
/**
|
||||
* Max allowed plots
|
||||
*/
|
||||
public static int MAX_PLOTS = 20;
|
||||
|
||||
/**
|
||||
* WorldGuard region on claimed plots
|
||||
*/
|
||||
public static boolean WORLDGUARD = false;
|
||||
|
||||
/**
|
||||
* metrics
|
||||
*/
|
||||
public static boolean METRICS = true;
|
||||
|
||||
/**
|
||||
* plot specific resource pack
|
||||
*/
|
||||
public static String PLOT_SPECIFIC_RESOURCE_PACK = "";
|
||||
|
||||
/**
|
||||
* Kill road mobs?
|
||||
*/
|
||||
public static boolean KILL_ROAD_MOBS;
|
||||
|
||||
/**
|
||||
* Default kill road mobs: true
|
||||
*/
|
||||
public static boolean KILL_ROAD_MOBS_DEFAULT = true;
|
||||
|
||||
/**
|
||||
* mob pathfinding?
|
||||
*/
|
||||
public static boolean MOB_PATHFINDING;
|
||||
|
||||
/**
|
||||
* Default mob pathfinding: true
|
||||
*/
|
||||
public static boolean MOB_PATHFINDING_DEFAULT = true;
|
||||
|
||||
/**
|
||||
* Delete plots on ban?
|
||||
*/
|
||||
public static boolean DELETE_PLOTS_ON_BAN = false;
|
||||
|
||||
/**
|
||||
* Verbose?
|
||||
*/
|
||||
public static boolean DEBUG = true;
|
||||
|
||||
/**
|
||||
* Auto clear enabled
|
||||
*/
|
||||
public static boolean AUTO_CLEAR = false;
|
||||
|
||||
/**
|
||||
* Days until a plot gets cleared
|
||||
*/
|
||||
public static int AUTO_CLEAR_DAYS = 365;
|
||||
|
||||
/**
|
||||
* API Location
|
||||
*/
|
||||
public static String API_URL = "http://www.intellectualsites.com/minecraft.php";
|
||||
|
||||
/**
|
||||
* Use the custom API
|
||||
*/
|
||||
|
@ -35,136 +35,207 @@ import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author Citymonstret
|
||||
* @author Empire92
|
||||
*/
|
||||
public abstract class AbstractDB {
|
||||
public interface AbstractDB {
|
||||
|
||||
// TODO MongoDB @Brandon
|
||||
|
||||
/**
|
||||
*
|
||||
* The UUID that will count as everyone
|
||||
*/
|
||||
public UUID everyone = UUID.fromString("1-1-3-3-7");
|
||||
|
||||
/**
|
||||
* Set Plot owner
|
||||
*
|
||||
* @param plot
|
||||
* @param uuid
|
||||
* @param plot Plot in which the owner should be set
|
||||
* @param uuid The uuid of the new owner
|
||||
*/
|
||||
public abstract void setOwner(final Plot plot, final UUID uuid);
|
||||
public void setOwner(final Plot plot, final UUID uuid);
|
||||
|
||||
public abstract void createAllSettingsAndHelpers(final ArrayList<Plot> plots);
|
||||
/**
|
||||
* Create all settings, and create default helpers, trusted + denied lists
|
||||
*
|
||||
* @param plots Plots for which the default table entries should be created
|
||||
*/
|
||||
public void createAllSettingsAndHelpers(final ArrayList<Plot> plots);
|
||||
|
||||
/**
|
||||
* Create a plot
|
||||
*
|
||||
* @param plots
|
||||
* @param plots Plots that should be created
|
||||
*/
|
||||
public abstract void createPlots(final ArrayList<Plot> plots);
|
||||
public void createPlots(final ArrayList<Plot> plots);
|
||||
|
||||
/**
|
||||
* Create a plot
|
||||
*
|
||||
* @param plot
|
||||
* @param plot That should be created
|
||||
*/
|
||||
public abstract void createPlot(final Plot plot);
|
||||
public void createPlot(final Plot plot);
|
||||
|
||||
/**
|
||||
* Create tables
|
||||
*
|
||||
* @throws SQLException
|
||||
* @param database Database in which the tables will be created
|
||||
*
|
||||
* @throws SQLException If the database manager is unable to create the tables
|
||||
*/
|
||||
public abstract void createTables(final String database, final boolean add_constraint) throws Exception;
|
||||
public void createTables(final String database, final boolean add_constraint) throws Exception;
|
||||
|
||||
/**
|
||||
* Delete a plot
|
||||
*
|
||||
* @param plot
|
||||
* @param plot Plot that should be deleted
|
||||
*/
|
||||
public abstract void delete(final String world, final Plot plot);
|
||||
public void delete(final String world, final Plot plot);
|
||||
|
||||
/**
|
||||
* Create plot settings
|
||||
*
|
||||
* @param id
|
||||
* @param plot
|
||||
* @param id Plot Entry ID
|
||||
* @param plot Plot Object
|
||||
*/
|
||||
public abstract void createPlotSettings(final int id, final Plot plot);
|
||||
|
||||
public abstract int getId(final String world, final PlotId id2);
|
||||
public void createPlotSettings(final int id, final Plot plot);
|
||||
|
||||
/**
|
||||
* @return
|
||||
* Get the table entry ID
|
||||
*
|
||||
* @param world Which the plot is located in
|
||||
* @param id2 Plot ID
|
||||
* @return Integer = Plot Entry Id
|
||||
*/
|
||||
public abstract LinkedHashMap<String, HashMap<PlotId, Plot>> getPlots();
|
||||
|
||||
public abstract void setMerged(final String world, final Plot plot, final boolean[] merged);
|
||||
|
||||
public abstract void setFlags(final String world, final Plot plot, final Flag[] flags);
|
||||
public int getId(final String world, final PlotId id2);
|
||||
|
||||
/**
|
||||
* @param plot
|
||||
* @param alias
|
||||
* @return A linked hashmap containing all plots
|
||||
*/
|
||||
public abstract void setAlias(final String world, final Plot plot, final String alias);
|
||||
|
||||
public abstract void purge(final String world, final PlotId id);
|
||||
|
||||
public abstract void purge(final String world);
|
||||
public LinkedHashMap<String, HashMap<PlotId, Plot>> getPlots();
|
||||
|
||||
/**
|
||||
* @param plot
|
||||
* @param position
|
||||
* Set the merged status for a plot
|
||||
*
|
||||
* @param world World in which the plot is located
|
||||
* @param plot Plot Object
|
||||
* @param merged boolean[]
|
||||
*/
|
||||
public abstract void setPosition(final String world, final Plot plot, final String position);
|
||||
public void setMerged(final String world, final Plot plot, final boolean[] merged);
|
||||
|
||||
/**
|
||||
* @param id
|
||||
* @return
|
||||
* Set plot flags
|
||||
*
|
||||
* @param world World in which the plot is located
|
||||
* @param plot Plot Object
|
||||
* @param flags flags to set (flag[])
|
||||
*/
|
||||
public abstract HashMap<String, Object> getSettings(final int id);
|
||||
public void setFlags(final String world, final Plot plot, final Flag[] flags);
|
||||
|
||||
/**
|
||||
* @param plot
|
||||
* @param player
|
||||
* Set the plot alias
|
||||
*
|
||||
* @param plot Plot for which the alias should be set
|
||||
* @param alias Plot Alias
|
||||
*/
|
||||
public abstract void removeHelper(final String world, final Plot plot, final OfflinePlayer player);
|
||||
public void setAlias(final String world, final Plot plot, final String alias);
|
||||
|
||||
/**
|
||||
* @param plot
|
||||
* @param player
|
||||
* Purgle a plot
|
||||
*
|
||||
* @param world World in which the plot is located
|
||||
* @param id Plot ID
|
||||
*/
|
||||
public abstract void removeTrusted(final String world, final Plot plot, final OfflinePlayer player);
|
||||
public void purge(final String world, final PlotId id);
|
||||
|
||||
/**
|
||||
* @param plot
|
||||
* @param player
|
||||
* Purge a whole world
|
||||
*
|
||||
* @param world World in which the plots should be purged
|
||||
*/
|
||||
public abstract void setHelper(final String world, final Plot plot, final OfflinePlayer player);
|
||||
public void purge(final String world);
|
||||
|
||||
/**
|
||||
* @param plot
|
||||
* @param player
|
||||
* Set Plot Home Position
|
||||
* @param plot Plot Object
|
||||
* @param position Plot Home Position
|
||||
*/
|
||||
public abstract void setTrusted(final String world, final Plot plot, final OfflinePlayer player);
|
||||
public void setPosition(final String world, final Plot plot, final String position);
|
||||
|
||||
/**
|
||||
* @param plot
|
||||
* @param player
|
||||
* @param id Plot Entry ID
|
||||
* @return Plot Settings
|
||||
*/
|
||||
public abstract void removeDenied(final String world, final Plot plot, final OfflinePlayer player);
|
||||
public HashMap<String, Object> getSettings(final int id);
|
||||
|
||||
/**
|
||||
* @param plot
|
||||
* @param player
|
||||
* @param plot Plot Object
|
||||
* @param player Player that should be removed
|
||||
*/
|
||||
public abstract void setDenied(final String world, final Plot plot, final OfflinePlayer player);
|
||||
public void removeHelper(final String world, final Plot plot, final OfflinePlayer player);
|
||||
|
||||
public abstract double getRatings(final Plot plot);
|
||||
/**
|
||||
* @param plot Plot Object
|
||||
* @param player Player that should be removed
|
||||
*/
|
||||
public void removeTrusted(final String world, final Plot plot, final OfflinePlayer player);
|
||||
|
||||
public abstract void removeComment(final String world, final Plot plot, final PlotComment comment);
|
||||
/**
|
||||
* @param plot Plot Object
|
||||
* @param player Player that should be removed
|
||||
*/
|
||||
public void setHelper(final String world, final Plot plot, final OfflinePlayer player);
|
||||
|
||||
public abstract void setComment(final String world, final Plot plot, final PlotComment comment);
|
||||
/**
|
||||
* @param plot Plot Object
|
||||
* @param player Player that should be added
|
||||
*/
|
||||
public void setTrusted(final String world, final Plot plot, final OfflinePlayer player);
|
||||
|
||||
public abstract ArrayList<PlotComment> getComments(final String world, final Plot plot, final int tier);
|
||||
/**
|
||||
* @param plot Plot Object
|
||||
* @param player Player that should be added
|
||||
*/
|
||||
public void removeDenied(final String world, final Plot plot, final OfflinePlayer player);
|
||||
|
||||
/**
|
||||
* @param plot Plot Object
|
||||
* @param player Player that should be added
|
||||
*/
|
||||
public void setDenied(final String world, final Plot plot, final OfflinePlayer player);
|
||||
|
||||
/**
|
||||
* Get Plots ratings
|
||||
*
|
||||
* @param plot Plot Object
|
||||
* @return Plot Ratings (pre-calculated)
|
||||
*/
|
||||
public double getRatings(final Plot plot);
|
||||
|
||||
/**
|
||||
* Remove a plot comment
|
||||
*
|
||||
* @param world World in which the plot is located
|
||||
* @param plot Plot Object
|
||||
* @param comment Comment to remove
|
||||
*/
|
||||
public void removeComment(final String world, final Plot plot, final PlotComment comment);
|
||||
|
||||
/**
|
||||
* Set a plot comment
|
||||
*
|
||||
* @param world World in which the plot is located
|
||||
* @param plot Plot Object
|
||||
* @param comment Comment to add
|
||||
*/
|
||||
public void setComment(final String world, final Plot plot, final PlotComment comment);
|
||||
|
||||
/**
|
||||
* Get Plot Comments
|
||||
*
|
||||
* @param world World in which the plot is located
|
||||
* @param plot Plot Object
|
||||
* @param tier Comment Tier
|
||||
* @return Plot Comments within the specified tier
|
||||
*/
|
||||
public ArrayList<PlotComment> getComments(final String world, final Plot plot, final int tier);
|
||||
}
|
||||
|
@ -40,17 +40,9 @@ public class DBFunc {
|
||||
public static AbstractDB dbManager;
|
||||
|
||||
// TODO MongoDB @Brandon
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
||||
public static UUID everyone = UUID.fromString("1-1-3-3-7");
|
||||
|
||||
/**
|
||||
* Set Plot owner
|
||||
*
|
||||
* @param plot
|
||||
* @param uuid
|
||||
*/
|
||||
public static void setOwner(final Plot plot, final UUID uuid) {
|
||||
dbManager.setOwner(plot, uuid);
|
||||
}
|
||||
@ -59,11 +51,6 @@ public class DBFunc {
|
||||
dbManager.createAllSettingsAndHelpers(plots);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a plot
|
||||
*
|
||||
* @param plots
|
||||
*/
|
||||
public static void createPlots(final ArrayList<Plot> plots) {
|
||||
dbManager.createPlots(plots);
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ import java.util.*;
|
||||
/**
|
||||
* @author Citymonstret
|
||||
*/
|
||||
public class SQLManager extends AbstractDB {
|
||||
public class SQLManager implements AbstractDB {
|
||||
|
||||
// Public final
|
||||
public final String SET_OWNER;
|
||||
@ -452,7 +452,6 @@ public class SQLManager extends AbstractDB {
|
||||
plots.put(id, p);
|
||||
}
|
||||
// stmt.close();
|
||||
|
||||
/*
|
||||
* Getting helpers
|
||||
*/
|
||||
|
@ -28,22 +28,26 @@ import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
|
||||
/**
|
||||
* Created by Citymonstret on 2014-08-09.
|
||||
* @author Citymonstret
|
||||
* @author Empire92
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public class PlayerClaimPlotEvent extends PlayerEvent implements Cancellable {
|
||||
private static HandlerList handlers = new HandlerList();
|
||||
private final Plot plot;
|
||||
private final boolean auto;
|
||||
private boolean cancelled;
|
||||
|
||||
/**
|
||||
* PlayerClaimPlotEvent: Called when a plot is claimed
|
||||
*
|
||||
* @param player
|
||||
* @param plot
|
||||
* @param player Player that claimed the plot
|
||||
* @param plot Plot that was claimed
|
||||
*/
|
||||
public PlayerClaimPlotEvent(final Player player, final Plot plot) {
|
||||
public PlayerClaimPlotEvent(final Player player, final Plot plot, boolean auto) {
|
||||
super(player);
|
||||
this.plot = plot;
|
||||
this.auto = auto;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
@ -59,6 +63,13 @@ public class PlayerClaimPlotEvent extends PlayerEvent implements Cancellable {
|
||||
return this.plot;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if it was an automated claim, else false
|
||||
*/
|
||||
public boolean wasAuto() {
|
||||
return this.auto;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
|
@ -27,7 +27,8 @@ import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
|
||||
/**
|
||||
* Created by Citymonstret on 2014-08-16.
|
||||
* @author Citymonstret
|
||||
* @author Empire92
|
||||
*/
|
||||
public class PlayerEnterPlotEvent extends PlayerEvent {
|
||||
|
||||
@ -38,8 +39,8 @@ public class PlayerEnterPlotEvent extends PlayerEvent {
|
||||
/**
|
||||
* PlayerEnterPlotEvent: Called when a player leaves a plot
|
||||
*
|
||||
* @param player
|
||||
* @param plot
|
||||
* @param player Player that entered the plot
|
||||
* @param plot Plot that was entered
|
||||
*/
|
||||
public PlayerEnterPlotEvent(final Player player, final Plot plot) {
|
||||
super(player);
|
||||
|
@ -27,7 +27,8 @@ import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
|
||||
/**
|
||||
* Created by Citymonstret on 2014-08-16.
|
||||
* @author Citymonstret
|
||||
* @author Empire92
|
||||
*/
|
||||
public class PlayerLeavePlotEvent extends PlayerEvent {
|
||||
private static HandlerList handlers = new HandlerList();
|
||||
@ -37,8 +38,8 @@ public class PlayerLeavePlotEvent extends PlayerEvent {
|
||||
/**
|
||||
* PlayerLeavePlotEvent: Called when a player leaves a plot
|
||||
*
|
||||
* @param player
|
||||
* @param plot
|
||||
* @param player Player that left the plot
|
||||
* @param plot Plot that was left
|
||||
*/
|
||||
public PlayerLeavePlotEvent(final Player player, final Plot plot) {
|
||||
super(player);
|
||||
|
@ -29,7 +29,8 @@ import org.bukkit.event.HandlerList;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Created by Citymonstret on 2014-08-16.
|
||||
* @author Citymonstret
|
||||
* @author Empire92
|
||||
*/
|
||||
public class PlayerPlotDeniedEvent extends Event {
|
||||
private static HandlerList handlers = new HandlerList();
|
||||
@ -43,10 +44,10 @@ public class PlayerPlotDeniedEvent extends Event {
|
||||
* PlayerPlotDeniedEvent: Called when the denied UUID list is modified for a
|
||||
* plot
|
||||
*
|
||||
* @param initiator
|
||||
* @param plot
|
||||
* @param player
|
||||
* @param added
|
||||
* @param initiator Player that initiated the event
|
||||
* @param plot Plot in which the event occurred
|
||||
* @param player Player that was denied/un-denied
|
||||
* @param added true of add to deny list, false if removed
|
||||
*/
|
||||
public PlayerPlotDeniedEvent(final Player initiator, final Plot plot, final UUID player, final boolean added) {
|
||||
this.initiator = initiator;
|
||||
|
@ -29,7 +29,8 @@ import org.bukkit.event.HandlerList;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Created by Citymonstret on 2014-08-16.
|
||||
* @author Empire92
|
||||
* @author Citymonstret
|
||||
*/
|
||||
public class PlayerPlotHelperEvent extends Event {
|
||||
private static HandlerList handlers = new HandlerList();
|
||||
@ -42,10 +43,10 @@ public class PlayerPlotHelperEvent extends Event {
|
||||
/**
|
||||
* PlayerPlotHelperEvent: Called when a plot helper is added/removed
|
||||
*
|
||||
* @param initiator
|
||||
* @param plot
|
||||
* @param player
|
||||
* @param added
|
||||
* @param initiator Player that initiated the event
|
||||
* @param plot Plot in which the event occurred
|
||||
* @param player Player that was added/removed from the helper list
|
||||
* @param added true of the player was added, false if the player was removed
|
||||
*/
|
||||
public PlayerPlotHelperEvent(final Player initiator, final Plot plot, final UUID player, final boolean added) {
|
||||
this.initiator = initiator;
|
||||
|
@ -29,7 +29,8 @@ import org.bukkit.event.HandlerList;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Created by Citymonstret on 2014-08-16.
|
||||
* @author Citymonstret
|
||||
* @author Empire92
|
||||
*/
|
||||
public class PlayerPlotTrustedEvent extends Event {
|
||||
private static HandlerList handlers = new HandlerList();
|
||||
@ -42,10 +43,10 @@ public class PlayerPlotTrustedEvent extends Event {
|
||||
/**
|
||||
* PlayerPlotTrustedEvent: Called when a plot trusted user is added/removed
|
||||
*
|
||||
* @param initiator
|
||||
* @param plot
|
||||
* @param player
|
||||
* @param added
|
||||
* @param initiator Player that initiated the event
|
||||
* @param plot Plot in which the event occurred
|
||||
* @param player Player that was added/removed from the trusted list
|
||||
* @param added true of the player was added, false if the player was removed
|
||||
*/
|
||||
public PlayerPlotTrustedEvent(final Player initiator, final Plot plot, final UUID player, final boolean added) {
|
||||
this.initiator = initiator;
|
||||
|
@ -30,6 +30,9 @@ import org.bukkit.event.player.PlayerEvent;
|
||||
|
||||
/**
|
||||
* Called when a player teleports to a plot
|
||||
*
|
||||
* @author Citymonstret
|
||||
* @author Empire92
|
||||
*/
|
||||
public class PlayerTeleportToPlotEvent extends PlayerEvent implements Cancellable {
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
@ -42,9 +45,9 @@ public class PlayerTeleportToPlotEvent extends PlayerEvent implements Cancellabl
|
||||
/**
|
||||
* PlayerTeleportToPlotEvent: Called when a player teleports to a plot
|
||||
*
|
||||
* @param player
|
||||
* @param from
|
||||
* @param plot
|
||||
* @param player That was teleported
|
||||
* @param from Start location
|
||||
* @param plot Plot to which the player was teleported
|
||||
*/
|
||||
public PlayerTeleportToPlotEvent(final Player player, final Location from, final Plot plot) {
|
||||
super(player);
|
||||
|
@ -28,6 +28,9 @@ import org.bukkit.event.HandlerList;
|
||||
|
||||
/**
|
||||
* Called when a plot is cleared
|
||||
*
|
||||
* @author Citymonstret
|
||||
* @author Empire92
|
||||
*/
|
||||
public class PlotClearEvent extends Event implements Cancellable {
|
||||
private static HandlerList handlers = new HandlerList();
|
||||
@ -38,8 +41,8 @@ public class PlotClearEvent extends Event implements Cancellable {
|
||||
/**
|
||||
* PlotDeleteEvent: Called when a plot is cleared
|
||||
*
|
||||
* @param world
|
||||
* @param id
|
||||
* @param world The world in which the plot was cleared
|
||||
* @param id The plot that was cleared
|
||||
*/
|
||||
public PlotClearEvent(final String world, final PlotId id) {
|
||||
this.id = id;
|
||||
|
@ -28,6 +28,9 @@ import org.bukkit.event.HandlerList;
|
||||
|
||||
/**
|
||||
* Called when a plot is deleted
|
||||
*
|
||||
* @author Citymonstret
|
||||
* @author Empire92
|
||||
*/
|
||||
public class PlotDeleteEvent extends Event implements Cancellable {
|
||||
private static HandlerList handlers = new HandlerList();
|
||||
@ -38,8 +41,8 @@ public class PlotDeleteEvent extends Event implements Cancellable {
|
||||
/**
|
||||
* PlotDeleteEvent: Called when a plot is deleted
|
||||
*
|
||||
* @param world
|
||||
* @param id
|
||||
* @param world The world in which the plot was deleted
|
||||
* @param id The ID of the plot that was deleted
|
||||
*/
|
||||
public PlotDeleteEvent(final String world, final PlotId id) {
|
||||
this.id = id;
|
||||
|
@ -29,6 +29,9 @@ import org.bukkit.event.HandlerList;
|
||||
|
||||
/**
|
||||
* Called when a Flag is added to a plot
|
||||
*
|
||||
* @author Citymonstret
|
||||
* @author Empire92
|
||||
*/
|
||||
public class PlotFlagAddEvent extends Event implements Cancellable {
|
||||
private static HandlerList handlers = new HandlerList();
|
||||
@ -39,8 +42,8 @@ public class PlotFlagAddEvent extends Event implements Cancellable {
|
||||
/**
|
||||
* PlotFlagAddEvent: Called when a Flag is added to a plot
|
||||
*
|
||||
* @param flag
|
||||
* @param plot
|
||||
* @param flag Flag that was added
|
||||
* @param plot Plot to which the flag was added
|
||||
*/
|
||||
public PlotFlagAddEvent(final Flag flag, final Plot plot) {
|
||||
this.plot = plot;
|
||||
|
@ -29,6 +29,9 @@ import org.bukkit.event.HandlerList;
|
||||
|
||||
/**
|
||||
* Called when a flag is removed from a plot
|
||||
*
|
||||
* @author Citymonstret
|
||||
* @author Empire92
|
||||
*/
|
||||
public class PlotFlagRemoveEvent extends Event implements Cancellable {
|
||||
private static HandlerList handlers = new HandlerList();
|
||||
@ -39,8 +42,8 @@ public class PlotFlagRemoveEvent extends Event implements Cancellable {
|
||||
/**
|
||||
* PlotFlagRemoveEvent: Called when a flag is removed from a plot
|
||||
*
|
||||
* @param flag
|
||||
* @param plot
|
||||
* @param flag Flag that was removed
|
||||
* @param plot Plot from which the flag was removed
|
||||
*/
|
||||
public PlotFlagRemoveEvent(final Flag flag, final Plot plot) {
|
||||
this.plot = plot;
|
||||
|
@ -31,7 +31,7 @@ import org.bukkit.event.HandlerList;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* Created by Citymonstret on 2014-08-09.
|
||||
* @author Empire92
|
||||
*/
|
||||
public class PlotMergeEvent extends Event implements Cancellable {
|
||||
private static HandlerList handlers = new HandlerList();
|
||||
@ -43,8 +43,9 @@ public class PlotMergeEvent extends Event implements Cancellable {
|
||||
/**
|
||||
* PlotMergeEvent: Called when plots are merged
|
||||
*
|
||||
* @param player
|
||||
* @param plot
|
||||
* @param world World in which the event occurred
|
||||
* @param plot Plot that was merged
|
||||
* @param plots A list of plots involved in the event
|
||||
*/
|
||||
public PlotMergeEvent(final World world, final Plot plot, final ArrayList<PlotId> plots) {
|
||||
this.plots = plots;
|
||||
|
@ -30,7 +30,7 @@ import org.bukkit.event.HandlerList;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* Created by Citymonstret on 2014-08-09.
|
||||
* @author Empire92
|
||||
*/
|
||||
public class PlotUnlinkEvent extends Event implements Cancellable {
|
||||
private static HandlerList handlers = new HandlerList();
|
||||
@ -41,8 +41,8 @@ public class PlotUnlinkEvent extends Event implements Cancellable {
|
||||
/**
|
||||
* Called when a mega-plot is unlinked.
|
||||
*
|
||||
* @param world
|
||||
* @param plots
|
||||
* @param world World in which the event occurred
|
||||
* @param plots Plots that are involved in the event
|
||||
*/
|
||||
public PlotUnlinkEvent(final World world, final ArrayList<PlotId> plots) {
|
||||
this.plots = plots;
|
||||
|
@ -52,11 +52,15 @@ public class AbstractFlag {
|
||||
throw new IllegalArgumentException("Key must be <= 16 characters");
|
||||
}
|
||||
this.key = key.toLowerCase();
|
||||
this.value = new FlagValue.StringValue();
|
||||
if (value == null) {
|
||||
this.value = new FlagValue.StringValue();
|
||||
} else {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
|
||||
public String parseValue(final String value) {
|
||||
return this.value.parse(value).toString();
|
||||
return this.value.parse(value);
|
||||
}
|
||||
|
||||
public String getValueDesc() {
|
||||
|
@ -33,6 +33,7 @@ import java.util.Random;
|
||||
/**
|
||||
* @author Citymonstret
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public class XPopulator extends BlockPopulator {
|
||||
|
||||
/*
|
||||
@ -237,7 +238,6 @@ public class XPopulator extends BlockPopulator {
|
||||
setCuboidRegion(16 - value, (16 - value) + 1, this.roadheight, this.roadheight + 1, start, 16, this.floor2, w); //
|
||||
}
|
||||
if ((roadStartZ <= 16) && (roadStartZ > 1)) {
|
||||
final int val = roadStartZ;
|
||||
int start, end;
|
||||
if ((plotMinX + 2) <= 16) {
|
||||
start = 16 - plotMinX - 1;
|
||||
@ -252,11 +252,10 @@ public class XPopulator extends BlockPopulator {
|
||||
if (!(((plotMinX + 2) <= 16) || ((roadStartX - 1) <= 16))) {
|
||||
start = 0;
|
||||
}
|
||||
setCuboidRegion(0, end, this.roadheight, this.roadheight + 1, (16 - val) + 1, (16 - val) + 2, this.floor2, w);
|
||||
setCuboidRegion(start, 16, this.roadheight, this.roadheight + 1, (16 - val) + 1, (16 - val) + 2, this.floor2, w);
|
||||
setCuboidRegion(0, end, this.roadheight, this.roadheight + 1, (16 - roadStartZ) + 1, (16 - roadStartZ) + 2, this.floor2, w);
|
||||
setCuboidRegion(start, 16, this.roadheight, this.roadheight + 1, (16 - roadStartZ) + 1, (16 - roadStartZ) + 2, this.floor2, w);
|
||||
}
|
||||
if ((roadStartX <= 16) && (roadStartX > 1)) {
|
||||
final int val = roadStartX;
|
||||
int start, end;
|
||||
if ((plotMinZ + 2) <= 16) {
|
||||
start = 16 - plotMinZ - 1;
|
||||
@ -271,8 +270,8 @@ public class XPopulator extends BlockPopulator {
|
||||
if (!(((plotMinZ + 2) <= 16) || ((roadStartZ - 1) <= 16))) {
|
||||
start = 0;
|
||||
}
|
||||
setCuboidRegion((16 - val) + 1, (16 - val) + 2, this.roadheight, this.roadheight + 1, 0, end, this.floor2, w); //
|
||||
setCuboidRegion((16 - val) + 1, (16 - val) + 2, this.roadheight, this.roadheight + 1, start, 16, this.floor2, w); //
|
||||
setCuboidRegion((16 - roadStartX) + 1, (16 - roadStartX) + 2, this.roadheight, this.roadheight + 1, 0, end, this.floor2, w); //
|
||||
setCuboidRegion((16 - roadStartX) + 1, (16 - roadStartX) + 2, this.roadheight, this.roadheight + 1, start, 16, this.floor2, w); //
|
||||
}
|
||||
}
|
||||
// WALLS
|
||||
@ -460,6 +459,7 @@ public class XPopulator extends BlockPopulator {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private void setBlock(final World w, final int x, final int y, final int z, final short id, final byte val) {
|
||||
w.getBlockAt(this.X + x, y, this.Z + z).setData(val, false);
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ import org.bukkit.inventory.Inventory;
|
||||
*
|
||||
* @author Citymonstret
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public class InventoryListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
|
@ -28,6 +28,7 @@ import com.intellectualcrafters.plot.config.Settings;
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
import com.intellectualcrafters.plot.object.*;
|
||||
import com.intellectualcrafters.plot.util.PlayerFunctions;
|
||||
import com.intellectualcrafters.plot.util.PlotHelper;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
@ -73,7 +74,12 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
||||
}
|
||||
// textures(event.getPlayer());
|
||||
if (isInPlot(event.getPlayer().getLocation())) {
|
||||
plotEntry(event.getPlayer(), getCurrentPlot(event.getPlayer().getLocation()));
|
||||
if (Settings.TELEPORT_ON_LOGIN) {
|
||||
event.getPlayer().teleport(PlotHelper.getPlotHomeDefault(getPlot(event.getPlayer())));
|
||||
PlayerFunctions.sendMessage(event.getPlayer(), C.TELEPORTED_TO_ROAD);
|
||||
} else {
|
||||
plotEntry(event.getPlayer(), getCurrentPlot(event.getPlayer().getLocation()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -21,6 +21,10 @@
|
||||
|
||||
package com.intellectualcrafters.plot.object;
|
||||
|
||||
import com.sun.istack.internal.NotNull;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
|
||||
/**
|
||||
* Wrapper class for blocks, using
|
||||
* pure data rather than the object.
|
||||
@ -28,16 +32,34 @@ package com.intellectualcrafters.plot.object;
|
||||
* Useful for NMS
|
||||
*
|
||||
* @author Empire92
|
||||
* @author Citymonstret
|
||||
*/
|
||||
public class BlockWrapper {
|
||||
|
||||
// Public Final //////////////////////////
|
||||
public final int x; //
|
||||
public final int y; //
|
||||
public final int z; //
|
||||
public final int id; //
|
||||
public final byte data; //
|
||||
//////////////////////////////////////////
|
||||
/**
|
||||
* X Coordinate
|
||||
*/
|
||||
public final int x;
|
||||
|
||||
/**
|
||||
* Y Coordinate
|
||||
*/
|
||||
public final int y;
|
||||
|
||||
/**
|
||||
* Z Coordinate
|
||||
*/
|
||||
public final int z;
|
||||
|
||||
/**
|
||||
* Block ID
|
||||
*/
|
||||
public final int id;
|
||||
|
||||
/**
|
||||
* Block Data Value
|
||||
*/
|
||||
public final byte data;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
@ -48,11 +70,39 @@ public class BlockWrapper {
|
||||
* @param id Material ID
|
||||
* @param data Data Value
|
||||
*/
|
||||
public BlockWrapper(int x, int y, int z, short id, byte data) {
|
||||
public BlockWrapper(final int x, final int y, final int z, final short id, final byte data) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
this.id = id;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Alternative Constructor
|
||||
* Uses block data, rather than typed data
|
||||
*
|
||||
* @param block Block from which we get the data
|
||||
*/
|
||||
@SuppressWarnings({"deprecation", "unused"})
|
||||
public BlockWrapper(@NotNull final Block block) {
|
||||
this.x = block.getX();
|
||||
this.y = block.getY();
|
||||
this.z = block.getZ();
|
||||
this.id = block.getTypeId();
|
||||
this.data = block.getData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a block based on the block wrapper
|
||||
*
|
||||
* @param world World in which the block is/will be, located
|
||||
* @return block created/fetched from settings
|
||||
*/
|
||||
@SuppressWarnings({"unused", "deprecation"})
|
||||
public Block toBlock(@NotNull final World world) {
|
||||
Block block = world.getBlockAt(x, y, z);
|
||||
block.setTypeIdAndData(id, data, true);
|
||||
return block;
|
||||
}
|
||||
}
|
||||
|
@ -37,6 +37,7 @@ import java.util.UUID;
|
||||
* The plot class
|
||||
*
|
||||
* @author Citymonstret
|
||||
* @author Empire92
|
||||
*/
|
||||
@SuppressWarnings("javadoc")
|
||||
public class Plot implements Cloneable {
|
||||
@ -91,7 +92,11 @@ public class Plot implements Cloneable {
|
||||
* @param plotBiome
|
||||
* @param helpers
|
||||
* @param denied
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("unused")
|
||||
public Plot(final PlotId id, final UUID owner, final Biome plotBiome, final ArrayList<UUID> helpers, final ArrayList<UUID> denied, final String world) {
|
||||
this.id = id;
|
||||
this.settings = new PlotSettings(this);
|
||||
@ -107,6 +112,29 @@ public class Plot implements Cloneable {
|
||||
this.world = world;
|
||||
}
|
||||
|
||||
/**
|
||||
* Primary constructor
|
||||
*
|
||||
* @param id
|
||||
* @param owner
|
||||
* @param helpers
|
||||
* @param denied
|
||||
*/
|
||||
public Plot(final PlotId id, final UUID owner, final ArrayList<UUID> helpers, final ArrayList<UUID> denied, final String world) {
|
||||
this.id = id;
|
||||
this.settings = new PlotSettings(this);
|
||||
this.owner = owner;
|
||||
this.deny_entry = this.owner == null;
|
||||
this.helpers = helpers;
|
||||
this.denied = denied;
|
||||
this.trusted = new ArrayList<>();
|
||||
this.settings.setAlias("");
|
||||
this.settings.setPosition(PlotHomePosition.DEFAULT);
|
||||
this.delete = false;
|
||||
this.settings.setFlags(new Flag[0]);
|
||||
this.world = world;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for saved plots
|
||||
*
|
||||
@ -116,7 +144,11 @@ public class Plot implements Cloneable {
|
||||
* @param helpers
|
||||
* @param denied
|
||||
* @param merged
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("unused")
|
||||
public Plot(final PlotId id, final UUID owner, final Biome plotBiome, final ArrayList<UUID> helpers, final ArrayList<UUID> trusted, final ArrayList<UUID> denied, final String alias, final PlotHomePosition position, final Flag[] flags, final String world, final boolean[] merged) {
|
||||
this.id = id;
|
||||
this.settings = new PlotSettings(this);
|
||||
@ -137,6 +169,35 @@ public class Plot implements Cloneable {
|
||||
this.world = world;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for saved plots
|
||||
*
|
||||
* @param id
|
||||
* @param owner
|
||||
* @param helpers
|
||||
* @param denied
|
||||
* @param merged
|
||||
*/
|
||||
public Plot(final PlotId id, final UUID owner, final ArrayList<UUID> helpers, final ArrayList<UUID> trusted, final ArrayList<UUID> denied, final String alias, final PlotHomePosition position, final Flag[] flags, final String world, final boolean[] merged) {
|
||||
this.id = id;
|
||||
this.settings = new PlotSettings(this);
|
||||
this.owner = owner;
|
||||
this.deny_entry = this.owner != null;
|
||||
this.trusted = trusted;
|
||||
this.helpers = helpers;
|
||||
this.denied = denied;
|
||||
this.settings.setAlias(alias);
|
||||
this.settings.setPosition(position);
|
||||
this.settings.setMerged(merged);
|
||||
this.delete = false;
|
||||
if (flags != null) {
|
||||
this.settings.setFlags(flags);
|
||||
} else {
|
||||
this.settings.setFlags(new Flag[0]);
|
||||
}
|
||||
this.world = world;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the plot has a set owner
|
||||
*
|
||||
@ -205,7 +266,7 @@ public class Plot implements Cloneable {
|
||||
public Object clone() throws CloneNotSupportedException {
|
||||
Plot p = (Plot) super.clone();
|
||||
if (!p.equals(this) || p != this) {
|
||||
return new Plot(id, owner, settings.getBiome(), helpers, trusted, denied, settings.getAlias(), settings.getPosition(), settings.getFlags().toArray(new Flag[settings.getFlags().size()]), getWorld().getName(), settings.getMerged());
|
||||
return new Plot(id, owner, helpers, trusted, denied, settings.getAlias(), settings.getPosition(), settings.getFlags().toArray(new Flag[settings.getFlags().size()]), getWorld().getName(), settings.getMerged());
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
@ -21,6 +21,9 @@
|
||||
|
||||
package com.intellectualcrafters.plot.object;
|
||||
|
||||
/**
|
||||
* @author Empire92
|
||||
*/
|
||||
public class PlotBlock {
|
||||
public short id;
|
||||
public byte data;
|
||||
|
@ -21,6 +21,9 @@
|
||||
|
||||
package com.intellectualcrafters.plot.object;
|
||||
|
||||
/**
|
||||
* @author Empire92
|
||||
*/
|
||||
public class PlotComment {
|
||||
public final String comment;
|
||||
public final int tier;
|
||||
|
@ -22,7 +22,7 @@
|
||||
package com.intellectualcrafters.plot.object;
|
||||
|
||||
/**
|
||||
* Created by Citymonstret on 2014-08-05.
|
||||
* @author Citymonstret
|
||||
*/
|
||||
public enum PlotHomePosition {
|
||||
CENTER("Center", 'c'),
|
||||
@ -37,13 +37,7 @@ public enum PlotHomePosition {
|
||||
}
|
||||
|
||||
public boolean isMatching(final String string) {
|
||||
if ((string.length() < 2) && (string.charAt(0) == this.ch)) {
|
||||
return true;
|
||||
}
|
||||
if (string.equalsIgnoreCase(this.string)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return (string.length() < 2) && (string.charAt(0) == this.ch) || string.equalsIgnoreCase(this.string);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ package com.intellectualcrafters.plot.object;
|
||||
|
||||
import com.intellectualcrafters.plot.flag.Flag;
|
||||
import com.intellectualcrafters.plot.util.PlotHelper;
|
||||
import com.sun.istack.internal.NotNull;
|
||||
import org.bukkit.block.Biome;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -36,6 +37,7 @@ import java.util.Set;
|
||||
* @author Citymonstret
|
||||
* @author Empire92
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public class PlotSettings {
|
||||
/**
|
||||
* merged plots
|
||||
@ -133,15 +135,19 @@ public class PlotSettings {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param flags
|
||||
* Set multiple flags
|
||||
*
|
||||
* @param flags Flag Array
|
||||
*/
|
||||
public void setFlags(final Flag[] flags) {
|
||||
this.flags = new HashSet<Flag>(Arrays.asList(flags));
|
||||
public void setFlags(@NotNull final Flag[] flags) {
|
||||
this.flags = new HashSet<>(Arrays.asList(flags));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param flag
|
||||
* @return
|
||||
* Get a flag
|
||||
*
|
||||
* @param flag Flag to get
|
||||
* @return flag
|
||||
*/
|
||||
public Flag getFlag(final String flag) {
|
||||
for (final Flag myflag : this.flags) {
|
||||
|
@ -42,7 +42,7 @@ public abstract class PlotWorld {
|
||||
// TODO make this configurable
|
||||
// make non static and static_default_valu + add config option
|
||||
@SuppressWarnings("deprecation")
|
||||
public static ArrayList<Material> BLOCKS = new ArrayList<Material>(Arrays.asList(new Material[]{ACACIA_STAIRS, BEACON, BEDROCK, BIRCH_WOOD_STAIRS, BOOKSHELF, BREWING_STAND, BRICK, BRICK_STAIRS, BURNING_FURNACE, CAKE_BLOCK, CAULDRON, CLAY_BRICK, CLAY, COAL_BLOCK, COAL_ORE, COBBLE_WALL, COBBLESTONE, COBBLESTONE_STAIRS, COMMAND, DARK_OAK_STAIRS, DAYLIGHT_DETECTOR, DIAMOND_ORE, DIAMOND_BLOCK, DIRT, DISPENSER, DROPPER, EMERALD_BLOCK, EMERALD_ORE, ENCHANTMENT_TABLE, ENDER_PORTAL_FRAME, ENDER_STONE, FURNACE, GLOWSTONE, GOLD_ORE, GOLD_BLOCK, GRASS, GRAVEL, GLASS, HARD_CLAY, HAY_BLOCK, HUGE_MUSHROOM_1, HUGE_MUSHROOM_2, IRON_BLOCK, IRON_ORE, JACK_O_LANTERN, JUKEBOX, JUNGLE_WOOD_STAIRS, LAPIS_BLOCK, LAPIS_ORE, LEAVES, LEAVES_2, LOG, LOG_2, MELON_BLOCK, MOB_SPAWNER, MOSSY_COBBLESTONE, MYCEL, NETHER_BRICK, NETHER_BRICK_STAIRS, NETHERRACK, NOTE_BLOCK, OBSIDIAN, PACKED_ICE, PUMPKIN, QUARTZ_BLOCK, QUARTZ_ORE, QUARTZ_STAIRS, REDSTONE_BLOCK, SANDSTONE, SAND,
|
||||
public static ArrayList<Material> BLOCKS = new ArrayList<>(Arrays.asList(new Material[]{ACACIA_STAIRS, BEACON, BEDROCK, BIRCH_WOOD_STAIRS, BOOKSHELF, BREWING_STAND, BRICK, BRICK_STAIRS, BURNING_FURNACE, CAKE_BLOCK, CAULDRON, CLAY_BRICK, CLAY, COAL_BLOCK, COAL_ORE, COBBLE_WALL, COBBLESTONE, COBBLESTONE_STAIRS, COMMAND, DARK_OAK_STAIRS, DAYLIGHT_DETECTOR, DIAMOND_ORE, DIAMOND_BLOCK, DIRT, DISPENSER, DROPPER, EMERALD_BLOCK, EMERALD_ORE, ENCHANTMENT_TABLE, ENDER_PORTAL_FRAME, ENDER_STONE, FURNACE, GLOWSTONE, GOLD_ORE, GOLD_BLOCK, GRASS, GRAVEL, GLASS, HARD_CLAY, HAY_BLOCK, HUGE_MUSHROOM_1, HUGE_MUSHROOM_2, IRON_BLOCK, IRON_ORE, JACK_O_LANTERN, JUKEBOX, JUNGLE_WOOD_STAIRS, LAPIS_BLOCK, LAPIS_ORE, LEAVES, LEAVES_2, LOG, LOG_2, MELON_BLOCK, MOB_SPAWNER, MOSSY_COBBLESTONE, MYCEL, NETHER_BRICK, NETHER_BRICK_STAIRS, NETHERRACK, NOTE_BLOCK, OBSIDIAN, PACKED_ICE, PUMPKIN, QUARTZ_BLOCK, QUARTZ_ORE, QUARTZ_STAIRS, REDSTONE_BLOCK, SANDSTONE, SAND,
|
||||
SANDSTONE_STAIRS, SMOOTH_BRICK, SMOOTH_STAIRS, SNOW_BLOCK, SOUL_SAND, SPONGE, SPRUCE_WOOD_STAIRS, STONE, WOOD, WOOD_STAIRS, WORKBENCH, WOOL, getMaterial(44), getMaterial(126)}));
|
||||
public static boolean AUTO_MERGE_DEFAULT = false;
|
||||
public static boolean MOB_SPAWNING_DEFAULT = false;
|
||||
@ -52,7 +52,7 @@ public abstract class PlotWorld {
|
||||
public static boolean SCHEMATIC_ON_CLAIM_DEFAULT = false;
|
||||
public static String SCHEMATIC_FILE_DEFAULT = "null";
|
||||
public static List<String> SCHEMATICS_DEFAULT = null;
|
||||
public static List<String> DEFAULT_FLAGS_DEFAULT = new ArrayList<String>();
|
||||
public static List<String> DEFAULT_FLAGS_DEFAULT = new ArrayList<>();
|
||||
public static boolean USE_ECONOMY_DEFAULT = false;
|
||||
public static double PLOT_PRICE_DEFAULT = 100;
|
||||
public static double MERGE_PRICE_DEFAULT = 100;
|
||||
@ -89,7 +89,7 @@ public abstract class PlotWorld {
|
||||
/**
|
||||
* When a world is created, the following method will be called for each
|
||||
*
|
||||
* @param config
|
||||
* @param config Configuration Section
|
||||
*/
|
||||
public void loadDefaultConfiguration(final ConfigurationSection config) {
|
||||
this.MOB_SPAWNING = config.getBoolean("natural_mob_spawning");
|
||||
@ -118,10 +118,10 @@ public abstract class PlotWorld {
|
||||
/**
|
||||
* Saving core plotworld settings
|
||||
*
|
||||
* @param config
|
||||
* @param config Configuration Section
|
||||
*/
|
||||
public void saveConfiguration(final ConfigurationSection config) {
|
||||
final HashMap<String, Object> options = new HashMap<String, Object>();
|
||||
final HashMap<String, Object> options = new HashMap<>();
|
||||
|
||||
options.put("natural_mob_spawning", PlotWorld.MOB_SPAWNING_DEFAULT);
|
||||
options.put("plot.auto_merge", PlotWorld.AUTO_MERGE_DEFAULT);
|
||||
|
@ -43,6 +43,7 @@ public class Title {
|
||||
static {
|
||||
CORRESPONDING_TYPES = new HashMap<>();
|
||||
}
|
||||
|
||||
/* Title packet */
|
||||
private Class<?> packetTitle;
|
||||
/* Title packet actions ENUM */
|
||||
@ -50,7 +51,7 @@ public class Title {
|
||||
/* Chat serializer */
|
||||
private Class<?> nmsChatSerializer;
|
||||
/* Title text and color */
|
||||
private String title = "";
|
||||
private String title;
|
||||
private ChatColor titleColor = ChatColor.WHITE;
|
||||
/* Subtitle text and color */
|
||||
private String subtitle = "";
|
||||
@ -78,6 +79,7 @@ public class Title {
|
||||
* @param subtitle Subtitle text
|
||||
*/
|
||||
public Title(final String title, final String subtitle) {
|
||||
this.title = "";
|
||||
this.title = title;
|
||||
this.subtitle = subtitle;
|
||||
loadClasses();
|
||||
@ -93,6 +95,7 @@ public class Title {
|
||||
* @param fadeOutTime Fade out time
|
||||
*/
|
||||
public Title(final String title, final String subtitle, final int fadeInTime, final int stayTime, final int fadeOutTime) {
|
||||
this.title = "";
|
||||
this.title = title;
|
||||
this.subtitle = subtitle;
|
||||
this.fadeInTime = fadeInTime;
|
||||
|
@ -28,6 +28,7 @@ import org.bukkit.Location;
|
||||
*
|
||||
* @author Citymonstret
|
||||
*/
|
||||
@SuppressWarnings({"javadoc", "unused"})
|
||||
public class LSetCube {
|
||||
|
||||
/**
|
||||
|
@ -39,10 +39,11 @@ import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* @author Citymonstret
|
||||
* @author Empire92
|
||||
*/
|
||||
@SuppressWarnings("ALL")
|
||||
public class PWE {
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public static void setMask(final Player p, final Location l) {
|
||||
try {
|
||||
LocalSession s;
|
||||
@ -98,6 +99,7 @@ public class PWE {
|
||||
return s.getMask() == null;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public static void setNoMask(final Player p) {
|
||||
try {
|
||||
LocalSession s;
|
||||
@ -110,7 +112,7 @@ public class PWE {
|
||||
final Vector p1 = new Vector(69, 69, 69), p2 = new Vector(69, 69, 69);
|
||||
s.setMask(new RegionMask(new CuboidRegion(plr.getWorld(), p1, p2)));
|
||||
} catch (final Exception e) {
|
||||
|
||||
//
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,9 @@ import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
import com.intellectualcrafters.plot.listeners.PlotListener;
|
||||
import com.intellectualcrafters.plot.object.*;
|
||||
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.block.Block;
|
||||
@ -45,11 +47,12 @@ import java.util.UUID;
|
||||
*
|
||||
* @author Citymonstret
|
||||
*/
|
||||
@SuppressWarnings({"unused", "javadoc", "deprecation"})
|
||||
public class PlotHelper {
|
||||
public static boolean canSetFast = false;
|
||||
public static boolean canSendChunk = false;
|
||||
public static ArrayList<String> runners_p = new ArrayList<String>();
|
||||
public static HashMap<Plot, Integer> runners = new HashMap<Plot, Integer>();
|
||||
public static ArrayList<String> runners_p = new ArrayList<>();
|
||||
public static HashMap<Plot, Integer> runners = new HashMap<>();
|
||||
static long state = 1;
|
||||
|
||||
/**
|
||||
@ -191,7 +194,7 @@ public class PlotHelper {
|
||||
final PlotManager manager = PlotMain.getPlotManager(world);
|
||||
final PlotWorld plotworld = PlotMain.getWorldSettings(world);
|
||||
|
||||
if (lesserPlot.id.x == greaterPlot.id.x) {
|
||||
if (lesserPlot.id.x.equals(greaterPlot.id.x)) {
|
||||
if (!lesserPlot.settings.getMerged(2)) {
|
||||
lesserPlot.settings.setMerged(2, true);
|
||||
greaterPlot.settings.setMerged(0, true);
|
||||
@ -209,7 +212,7 @@ public class PlotHelper {
|
||||
/*
|
||||
* Random number gen section
|
||||
*/
|
||||
public static final long nextLong() {
|
||||
public static long nextLong() {
|
||||
final long a = state;
|
||||
state = xorShift64(a);
|
||||
return a;
|
||||
@ -219,14 +222,14 @@ public class PlotHelper {
|
||||
* End of random number gen section
|
||||
*/
|
||||
|
||||
public static final long xorShift64(long a) {
|
||||
public static long xorShift64(long a) {
|
||||
a ^= (a << 21);
|
||||
a ^= (a >>> 35);
|
||||
a ^= (a << 4);
|
||||
return a;
|
||||
}
|
||||
|
||||
public static final int random(final int n) {
|
||||
public static int random(final int n) {
|
||||
if (n == 1) {
|
||||
return 0;
|
||||
}
|
||||
@ -353,7 +356,6 @@ public class PlotHelper {
|
||||
count++;
|
||||
final PlotId bot = PlayerFunctions.getBottomPlot(world, plot).id;
|
||||
final PlotId top = PlayerFunctions.getTopPlot(world, plot).id;
|
||||
merge = false;
|
||||
plots = PlayerFunctions.getPlotSelectionIds(world, new PlotId(bot.x, bot.y - 1), new PlotId(top.x, top.y));
|
||||
if (ownsPlots(world, plots, player, 0)) {
|
||||
final boolean result = mergePlots(world, plots);
|
||||
@ -765,6 +767,7 @@ public class PlotHelper {
|
||||
}
|
||||
}
|
||||
} catch (final Exception e) {
|
||||
//
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -794,7 +797,7 @@ public class PlotHelper {
|
||||
}
|
||||
}
|
||||
} catch (final Exception e) {
|
||||
|
||||
//
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -829,6 +832,13 @@ public class PlotHelper {
|
||||
return 64;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get plot home
|
||||
*
|
||||
* @param w World in which the plot is located
|
||||
* @param plotid Plot ID
|
||||
* @return Home Location
|
||||
*/
|
||||
public static Location getPlotHome(final World w, final PlotId plotid) {
|
||||
|
||||
if (getPlot(w, plotid).settings.getPosition() == PlotHomePosition.DEFAULT) {
|
||||
@ -848,10 +858,33 @@ public class PlotHelper {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the location of the default plot home position
|
||||
* @param plot Plot
|
||||
* @return the location
|
||||
*/
|
||||
public static Location getPlotHomeDefault(final Plot plot) {
|
||||
final Location l = getPlotBottomLoc(plot.getWorld(), plot.getId()).subtract(0, 0, 0);
|
||||
l.setY(getHeighestBlock(plot.getWorld(), l.getBlockX(), l.getBlockZ()));
|
||||
return l;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the plot home
|
||||
* @param w World
|
||||
* @param plot Plot Object
|
||||
* @return Plot Home Location
|
||||
* @see #getPlotHome(org.bukkit.World, com.intellectualcrafters.plot.object.PlotId)
|
||||
*/
|
||||
public static Location getPlotHome(final World w, final Plot plot) {
|
||||
return getPlotHome(w, plot.id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Refresh the plot chunks
|
||||
* @param world World in which the plot is located
|
||||
* @param plot Plot Object
|
||||
*/
|
||||
public static void refreshPlotChunks(final World world, final Plot plot) {
|
||||
final int bottomX = getPlotBottomLoc(world, plot.id).getBlockX();
|
||||
final int topX = getPlotTopLoc(world, plot.id).getBlockX();
|
||||
|
@ -24,7 +24,9 @@ package com.intellectualcrafters.plot.util;
|
||||
import com.intellectualcrafters.plot.PlotMain;
|
||||
|
||||
/**
|
||||
* Created by Citymonstret on 2014-09-29.
|
||||
* Created 2014-09-29 for PlotSquared
|
||||
*
|
||||
* @author Citymonstret
|
||||
*/
|
||||
public class PlotSquaredException extends RuntimeException {
|
||||
|
||||
@ -34,6 +36,7 @@ public class PlotSquaredException extends RuntimeException {
|
||||
}
|
||||
|
||||
public static enum PlotError {
|
||||
PLOTMAIN_NULL("The PlotMain instance was null"),
|
||||
MISSING_DEPENDENCY("Missing Dependency");
|
||||
private String errorHeader;
|
||||
|
||||
|
@ -28,6 +28,7 @@ import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@ -232,8 +233,8 @@ public class ReflectionUtils {
|
||||
if (methodTypes.length != classes.length) {
|
||||
continue;
|
||||
}
|
||||
for (int i = 0; i < classes.length; i++) {
|
||||
if (!classes.equals(methodTypes)) {
|
||||
for (Class aClass : classes) {
|
||||
if (!Arrays.equals(classes, methodTypes)) {
|
||||
continue findMethod;
|
||||
}
|
||||
return new RefMethod(m);
|
||||
|
@ -45,7 +45,6 @@ import java.util.zip.GZIPOutputStream;
|
||||
* @author Citymonstret
|
||||
* @author Empire92
|
||||
*/
|
||||
@SuppressWarnings({"all"})
|
||||
public class SchematicHandler {
|
||||
/**
|
||||
* Paste a schematic
|
||||
@ -125,7 +124,9 @@ public class SchematicHandler {
|
||||
{
|
||||
final File parent = new File(JavaPlugin.getPlugin(PlotMain.class).getDataFolder() + File.separator + "schematics");
|
||||
if (!parent.exists()) {
|
||||
parent.mkdir();
|
||||
if (!parent.mkdir()) {
|
||||
throw new RuntimeException("Could not create schematic parent directory");
|
||||
}
|
||||
}
|
||||
}
|
||||
final File file = new File(JavaPlugin.getPlugin(PlotMain.class).getDataFolder() + File.separator + "schematics" + File.separator + name + ".schematic");
|
||||
@ -252,6 +253,7 @@ public class SchematicHandler {
|
||||
* @param id plot
|
||||
* @return tag
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public static CompoundTag getCompoundTag(final World world, final PlotId id) {
|
||||
|
||||
if (!PlotMain.getPlots(world).containsKey(id)) {
|
||||
@ -307,6 +309,7 @@ public class SchematicHandler {
|
||||
|
||||
final Block block = world.getBlockAt(new Location(world, pos1.getBlockX() + x, y, pos1.getBlockZ() + z));
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
final int id2 = block.getTypeId();
|
||||
|
||||
if (id2 > 255) {
|
||||
|
@ -34,6 +34,8 @@ import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass;
|
||||
/**
|
||||
* SetBlockFast class<br>
|
||||
* Used to do fast world editing
|
||||
*
|
||||
* @author Empire92
|
||||
*/
|
||||
public class SetBlockFast {
|
||||
|
||||
@ -47,6 +49,11 @@ public class SetBlockFast {
|
||||
private static RefMethod methodA;
|
||||
private static RefMethod methodGetById;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @throws NoSuchMethodException
|
||||
*/
|
||||
public SetBlockFast() throws NoSuchMethodException {
|
||||
methodGetHandle = classCraftWorld.getMethod("getHandle");
|
||||
methodGetChunkAt = classWorld.getMethod("getChunkAt", int.class, int.class);
|
||||
@ -54,6 +61,17 @@ public class SetBlockFast {
|
||||
methodGetById = classBlock.getMethod("getById", int.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the block at the location
|
||||
* @param world World in which the block should be set
|
||||
* @param x X Coordinate
|
||||
* @param y Y Coordinate
|
||||
* @param z Z Coordinate
|
||||
* @param blockId Block ID
|
||||
* @param data Block Data Value
|
||||
* @return true
|
||||
* @throws NoSuchMethodException
|
||||
*/
|
||||
public static boolean set(final org.bukkit.World world, final int x, final int y, final int z, final int blockId, final byte data) throws NoSuchMethodException {
|
||||
|
||||
final Object w = methodGetHandle.of(world).call();
|
||||
@ -63,6 +81,10 @@ public class SetBlockFast {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update chunks
|
||||
* @param player Player whose chunks we're updating
|
||||
*/
|
||||
public static void update(final org.bukkit.entity.Player player) {
|
||||
if (!PlotHelper.canSendChunk) {
|
||||
|
||||
|
@ -36,12 +36,14 @@ public class StringComparison {
|
||||
* Best Match
|
||||
*/
|
||||
private String bestMatch;
|
||||
|
||||
/**
|
||||
* Match Value
|
||||
* <p/>
|
||||
* Can be checked for low match (< .25 or something)
|
||||
*/
|
||||
private double match = 0;
|
||||
|
||||
/**
|
||||
* The actual object
|
||||
*/
|
||||
|
@ -71,7 +71,8 @@ public class UUIDHandler {
|
||||
private static boolean online = Bukkit.getServer().getOnlineMode();
|
||||
|
||||
/**
|
||||
* Map containing names and UUID's
|
||||
* Map containing names and UUIDs
|
||||
* @see com.google.common.collect.BiMap
|
||||
*/
|
||||
private static BiMap<StringWrapper, UUID> uuidMap = HashBiMap.create(new HashMap<StringWrapper, UUID>());
|
||||
|
||||
@ -79,6 +80,7 @@ public class UUIDHandler {
|
||||
* Get the map containing all names/uuids
|
||||
*
|
||||
* @return map with names + uuids
|
||||
* @see com.google.common.collect.BiMap
|
||||
*/
|
||||
public static BiMap<StringWrapper, UUID> getUuidMap() {
|
||||
return uuidMap;
|
||||
@ -89,6 +91,7 @@ public class UUIDHandler {
|
||||
*
|
||||
* @param uuid to check
|
||||
* @return true of the uuid is cached
|
||||
* @see com.google.common.collect.BiMap#containsValue(Object)
|
||||
*/
|
||||
public static boolean uuidExists(final UUID uuid) {
|
||||
return uuidMap.containsValue(uuid);
|
||||
@ -99,6 +102,7 @@ public class UUIDHandler {
|
||||
*
|
||||
* @param name to check
|
||||
* @return true of the name is cached
|
||||
* @see com.google.common.collect.BiMap#containsKey(Object)
|
||||
*/
|
||||
public static boolean nameExists(final StringWrapper name) {
|
||||
return uuidMap.containsKey(name);
|
||||
|
@ -35,7 +35,8 @@ import java.util.UUID;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
/**
|
||||
* @author
|
||||
* Name Fetcher Class
|
||||
* From Bukkit
|
||||
*/
|
||||
public class NameFetcher implements Callable<Map<UUID, String>> {
|
||||
private static final String PROFILE_URL = "https://sessionserver.mojang.com/session/minecraft/profile/";
|
||||
@ -48,7 +49,7 @@ public class NameFetcher implements Callable<Map<UUID, String>> {
|
||||
|
||||
@Override
|
||||
public Map<UUID, String> call() throws Exception {
|
||||
final Map<UUID, String> uuidStringMap = new HashMap<UUID, String>();
|
||||
final Map<UUID, String> uuidStringMap = new HashMap<>();
|
||||
for (final UUID uuid : this.uuids) {
|
||||
if (uuidStringMap.containsKey(uuid)) {
|
||||
continue;
|
||||
|
@ -37,9 +37,12 @@ import java.net.URLConnection;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Created by Citymonstret on 2014-10-13.
|
||||
* Plot UUID Saver/Fetcher
|
||||
*
|
||||
* @author Citymonstret
|
||||
* @author Empire92
|
||||
*/
|
||||
public class PlotUUIDSaver extends UUIDSaver {
|
||||
public class PlotUUIDSaver implements UUIDSaver {
|
||||
|
||||
@Override
|
||||
public void globalPopulate() {
|
||||
|
@ -35,7 +35,8 @@ import java.util.*;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
/**
|
||||
* @author
|
||||
* UUID Fetcher
|
||||
* From Bukkit
|
||||
*/
|
||||
public class UUIDFetcher implements Callable<Map<String, UUID>> {
|
||||
private static final double PROFILES_PER_REQUEST = 100;
|
||||
@ -53,29 +54,6 @@ public class UUIDFetcher implements Callable<Map<String, UUID>> {
|
||||
this(names, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, UUID> call() throws Exception {
|
||||
final Map<String, UUID> uuidMap = new HashMap<String, UUID>();
|
||||
final int requests = (int) Math.ceil(this.names.size() / PROFILES_PER_REQUEST);
|
||||
for (int i = 0; i < requests; i++) {
|
||||
final HttpURLConnection connection = createConnection();
|
||||
final String body = JSONArray.toJSONString(this.names.subList(i * 100, Math.min((i + 1) * 100, this.names.size())));
|
||||
writeBody(connection, body);
|
||||
final JSONArray array = (JSONArray) this.jsonParser.parse(new InputStreamReader(connection.getInputStream()));
|
||||
for (final Object profile : array) {
|
||||
final JSONObject jsonProfile = (JSONObject) profile;
|
||||
final String id = (String) jsonProfile.get("id");
|
||||
final String name = (String) jsonProfile.get("name");
|
||||
final UUID uuid = UUIDFetcher.getUUID(id);
|
||||
uuidMap.put(name, uuid);
|
||||
}
|
||||
if (this.rateLimiting && (i != (requests - 1))) {
|
||||
Thread.sleep(100L);
|
||||
}
|
||||
}
|
||||
return uuidMap;
|
||||
}
|
||||
|
||||
private static void writeBody(final HttpURLConnection connection, final String body) throws Exception {
|
||||
final OutputStream stream = connection.getOutputStream();
|
||||
stream.write(body.getBytes());
|
||||
@ -98,6 +76,7 @@ public class UUIDFetcher implements Callable<Map<String, UUID>> {
|
||||
return UUID.fromString(id.substring(0, 8) + "-" + id.substring(8, 12) + "-" + id.substring(12, 16) + "-" + id.substring(16, 20) + "-" + id.substring(20, 32));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public static byte[] toBytes(final UUID uuid) {
|
||||
final ByteBuffer byteBuffer = ByteBuffer.wrap(new byte[16]);
|
||||
byteBuffer.putLong(uuid.getMostSignificantBits());
|
||||
@ -105,6 +84,7 @@ public class UUIDFetcher implements Callable<Map<String, UUID>> {
|
||||
return byteBuffer.array();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public static UUID fromBytes(final byte[] array) {
|
||||
if (array.length != 16) {
|
||||
throw new IllegalArgumentException("Illegal byte array length: " + array.length);
|
||||
@ -115,7 +95,31 @@ public class UUIDFetcher implements Callable<Map<String, UUID>> {
|
||||
return new UUID(mostSignificant, leastSignificant);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public static UUID getUUIDOf(final String name) throws Exception {
|
||||
return new UUIDFetcher(Arrays.asList(name)).call().get(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, UUID> call() throws Exception {
|
||||
final Map<String, UUID> uuidMap = new HashMap<>();
|
||||
final int requests = (int) Math.ceil(this.names.size() / PROFILES_PER_REQUEST);
|
||||
for (int i = 0; i < requests; i++) {
|
||||
final HttpURLConnection connection = createConnection();
|
||||
final String body = JSONArray.toJSONString(this.names.subList(i * 100, Math.min((i + 1) * 100, this.names.size())));
|
||||
writeBody(connection, body);
|
||||
final JSONArray array = (JSONArray) this.jsonParser.parse(new InputStreamReader(connection.getInputStream()));
|
||||
for (final Object profile : array) {
|
||||
final JSONObject jsonProfile = (JSONObject) profile;
|
||||
final String id = (String) jsonProfile.get("id");
|
||||
final String name = (String) jsonProfile.get("name");
|
||||
final UUID uuid = UUIDFetcher.getUUID(id);
|
||||
uuidMap.put(name, uuid);
|
||||
}
|
||||
if (this.rateLimiting && (i != (requests - 1))) {
|
||||
Thread.sleep(100L);
|
||||
}
|
||||
}
|
||||
return uuidMap;
|
||||
}
|
||||
}
|
||||
|
@ -27,20 +27,60 @@ import com.intellectualcrafters.plot.object.StringWrapper;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Created by Citymonstret on 2014-10-13.
|
||||
* @author Citymonstret
|
||||
*/
|
||||
public abstract class UUIDSaver {
|
||||
public abstract void globalPopulate();
|
||||
public interface UUIDSaver {
|
||||
|
||||
public abstract void globalSave(final BiMap<StringWrapper, UUID> biMap);
|
||||
/**
|
||||
* Populate the default list
|
||||
*/
|
||||
public void globalPopulate();
|
||||
|
||||
public abstract void save(final UUIDSet set);
|
||||
/**
|
||||
* Save the UUIDs
|
||||
*
|
||||
* @param biMap Map containing names and UUIDs
|
||||
*/
|
||||
public void globalSave(final BiMap<StringWrapper, UUID> biMap);
|
||||
|
||||
public abstract UUIDSet get(final String name);
|
||||
/**
|
||||
* Save a single UUIDSet
|
||||
*
|
||||
* @param set Set to save
|
||||
*/
|
||||
public void save(final UUIDSet set);
|
||||
|
||||
public abstract UUIDSet get(final UUID uuid);
|
||||
/**
|
||||
* Get a single UUIDSet
|
||||
*
|
||||
* @param name Username
|
||||
* @return UUID Set
|
||||
*/
|
||||
public UUIDSet get(final String name);
|
||||
|
||||
public abstract UUID mojangUUID(final String name) throws Exception;
|
||||
/**
|
||||
* Get a single UUIDSet
|
||||
*
|
||||
* @param uuid UUID
|
||||
* @return UUID Set
|
||||
*/
|
||||
public UUIDSet get(final UUID uuid);
|
||||
|
||||
public abstract String mojangName(final UUID uuid) throws Exception;
|
||||
/**
|
||||
* Fetch uuid from mojang servers
|
||||
*
|
||||
* @param name Username
|
||||
* @return uuid
|
||||
* @throws Exception
|
||||
*/
|
||||
public UUID mojangUUID(final String name) throws Exception;
|
||||
|
||||
/**
|
||||
* Fetch username from mojang servers
|
||||
*
|
||||
* @param uuid UUID
|
||||
* @return username
|
||||
* @throws Exception
|
||||
*/
|
||||
public String mojangName(final UUID uuid) throws Exception;
|
||||
}
|
||||
|
@ -24,12 +24,26 @@ package com.intellectualcrafters.plot.uuid;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Created by Citymonstret on 2014-10-13.
|
||||
* @author Citymonstret
|
||||
*/
|
||||
public class UUIDSet {
|
||||
|
||||
/**
|
||||
* Player Name
|
||||
*/
|
||||
private final String name;
|
||||
|
||||
/**
|
||||
* Player UUID
|
||||
*/
|
||||
private final UUID uuid;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param name Username
|
||||
* @param uuid UUID
|
||||
*/
|
||||
public UUIDSet(final String name, final UUID uuid) {
|
||||
this.name = name;
|
||||
this.uuid = uuid;
|
||||
@ -40,6 +54,11 @@ public class UUIDSet {
|
||||
return getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the name
|
||||
*
|
||||
* @return Name
|
||||
*/
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
15
README.md
15
README.md
@ -1,6 +1,14 @@
|
||||
PlotSquared Official Repo
|
||||
==========================================================
|
||||
This is the official PlotSquared repo, if you didn't understand that by the title...
|
||||
PlotSquared - Plot Plugin Extraordinaire.
|
||||
|
||||
## Compile: ##
|
||||
Build the project using your favourite compiler (maven is the recommended way to build), then package the jar using `mvn package` **MAVEN IS REQUIRED TO BUILD AND PACKAGE THE JAR**
|
||||
|
||||
To build the PlotMe converted, you need a PlotMe jar file (a release post-UUID), we won't like to this for obvious reasons.
|
||||
|
||||
## API: ##
|
||||
The main API class can be found [here](https://github.com/IntellectualCrafters/PlotSquared/blob/master/PlotSquared/src/main/java/com/intellectualcrafters/plot/api/PlotAPI.java "API"). JavaDoc's can be found [here](http://git.plotworld.info/jdocs/ "JDOCS").
|
||||
|
||||
## Links: ##
|
||||
|
||||
@ -13,5 +21,6 @@ This is the official PlotSquared repo, if you didn't understand that by the titl
|
||||
- [AdvPlots](http://www.spigotmc.org/resources/advplots-%CE%B2.1500/ "AdvPlots")
|
||||
- [PlotRankup](http://www.spigotmc.org/resources/plotrankup.1571/ "PlotRankup")
|
||||
|
||||
Dependencies:
|
||||
[http://intellectualsites.com/download.php?key=a12f1474-6bbc-4017-ba43-d26f8de36a7c](http://intellectualsites.com/download.php?key=a12f1474-6bbc-4017-ba43-d26f8de36a7c "Dependencies (/lib)")
|
||||
...
|
||||
Read [THIS](https://intellectualsites.com/?p=view_post&post=106) before saying that we've stolen code.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user