mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 05:06:44 +01:00
Some documentation updates
This commit is contained in:
parent
be846c2e98
commit
595db4a51f
@ -52,7 +52,9 @@ import java.util.Map.Entry;
|
|||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @awesome @author Citymonstret, Empire92 PlotMain class.
|
* PlotMain class.
|
||||||
|
* @author Citymonstret
|
||||||
|
* @author Empire92
|
||||||
*/
|
*/
|
||||||
public class PlotMain extends JavaPlugin {
|
public class PlotMain extends JavaPlugin {
|
||||||
|
|
||||||
@ -66,8 +68,7 @@ public class PlotMain extends JavaPlugin {
|
|||||||
* The main configuration file
|
* The main configuration file
|
||||||
*/
|
*/
|
||||||
public static YamlConfiguration config;
|
public static YamlConfiguration config;
|
||||||
private static int config_ver = 1;
|
/**
|
||||||
/**
|
|
||||||
* storage.properties
|
* storage.properties
|
||||||
*/
|
*/
|
||||||
public static File storageFile;
|
public static File storageFile;
|
||||||
@ -135,10 +136,10 @@ public class PlotMain extends JavaPlugin {
|
|||||||
* Check a range of permissions e.g. 'plots.plot.<0-100>'<br>
|
* Check a range of permissions e.g. 'plots.plot.<0-100>'<br>
|
||||||
* Returns highest integer in range.
|
* Returns highest integer in range.
|
||||||
*
|
*
|
||||||
* @param player
|
* @param player to check
|
||||||
* @param stub
|
* @param stub to check
|
||||||
* @param range
|
* @param range tp check
|
||||||
* @return
|
* @return permitted range
|
||||||
*/
|
*/
|
||||||
public static int hasPermissionRange(Player player, String stub, int range) {
|
public static int hasPermissionRange(Player player, String stub, int range) {
|
||||||
if (player==null || player.isOp()) {
|
if (player==null || player.isOp()) {
|
||||||
@ -160,10 +161,11 @@ public class PlotMain extends JavaPlugin {
|
|||||||
* - Op has all permissions <br>
|
* - Op has all permissions <br>
|
||||||
* - checks for '*' nodes
|
* - checks for '*' nodes
|
||||||
*
|
*
|
||||||
* @param player
|
* @param player to check
|
||||||
* @param perms
|
* @param perms to check
|
||||||
* @return
|
* @return true of player has permissions
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("unused")
|
||||||
public static boolean hasPermissions(Player player, String[] perms) {
|
public static boolean hasPermissions(Player player, String[] perms) {
|
||||||
// Assumes null player is console.
|
// Assumes null player is console.
|
||||||
if (player==null || player.isOp()) {
|
if (player==null || player.isOp()) {
|
||||||
@ -178,7 +180,7 @@ public class PlotMain extends JavaPlugin {
|
|||||||
String[] nodes = perm.split("\\.");
|
String[] nodes = perm.split("\\.");
|
||||||
StringBuilder n = new StringBuilder();
|
StringBuilder n = new StringBuilder();
|
||||||
for (int i = 0; i < (nodes.length - 1); i++) {
|
for (int i = 0; i < (nodes.length - 1); i++) {
|
||||||
n.append(nodes[i] + ".");
|
n.append(nodes[i]).append(".");
|
||||||
if (player.hasPermission(n + "*")) {
|
if (player.hasPermission(n + "*")) {
|
||||||
hasperm = true;
|
hasperm = true;
|
||||||
break;
|
break;
|
||||||
@ -206,9 +208,9 @@ public class PlotMain extends JavaPlugin {
|
|||||||
* - Op has all permissions <br>
|
* - Op has all permissions <br>
|
||||||
* - checks for '*' nodes
|
* - checks for '*' nodes
|
||||||
*
|
*
|
||||||
* @param player
|
* @param player to check
|
||||||
* @param perm
|
* @param perm to check
|
||||||
* @return
|
* @return true if player has the permission
|
||||||
*/
|
*/
|
||||||
public static boolean hasPermission(Player player, String perm) {
|
public static boolean hasPermission(Player player, String perm) {
|
||||||
if (player==null || player.isOp()) {
|
if (player==null || player.isOp()) {
|
||||||
@ -220,7 +222,7 @@ public class PlotMain extends JavaPlugin {
|
|||||||
String[] nodes = perm.split("\\.");
|
String[] nodes = perm.split("\\.");
|
||||||
StringBuilder n = new StringBuilder();
|
StringBuilder n = new StringBuilder();
|
||||||
for (int i = 0; i < (nodes.length - 1); i++) {
|
for (int i = 0; i < (nodes.length - 1); i++) {
|
||||||
n.append(nodes[i] + ".");
|
n.append(nodes[i]).append(".");
|
||||||
if (player.hasPermission(n + "*")) {
|
if (player.hasPermission(n + "*")) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -237,8 +239,8 @@ public class PlotMain extends JavaPlugin {
|
|||||||
/**
|
/**
|
||||||
* All loaded plot worlds
|
* All loaded plot worlds
|
||||||
*/
|
*/
|
||||||
private static HashMap<String, PlotWorld> worlds = new HashMap<String, PlotWorld>();
|
private static HashMap<String, PlotWorld> worlds = new HashMap<>();
|
||||||
private static HashMap<String, PlotManager> managers = new HashMap<String, PlotManager>();
|
private static HashMap<String, PlotManager> managers = new HashMap<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all plots
|
* Get all plots
|
||||||
@ -246,20 +248,20 @@ public class PlotMain extends JavaPlugin {
|
|||||||
* @return HashMap containing the plot ID and the plot object.
|
* @return HashMap containing the plot ID and the plot object.
|
||||||
*/
|
*/
|
||||||
public static Set<Plot> getPlots() {
|
public static Set<Plot> getPlots() {
|
||||||
ArrayList<Plot> myplots = new ArrayList<Plot>();
|
ArrayList<Plot> myplots = new ArrayList<>();
|
||||||
for (HashMap<PlotId, Plot> world : plots.values()) {
|
for (HashMap<PlotId, Plot> world : plots.values()) {
|
||||||
myplots.addAll(world.values());
|
myplots.addAll(world.values());
|
||||||
}
|
}
|
||||||
return new HashSet<Plot>(myplots);
|
return new HashSet<>(myplots);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param player
|
* @param player player
|
||||||
* @return
|
* @return Set Containing the players plots
|
||||||
*/
|
*/
|
||||||
public static Set<Plot> getPlots(Player player) {
|
public static Set<Plot> getPlots(Player player) {
|
||||||
UUID uuid = player.getUniqueId();
|
UUID uuid = player.getUniqueId();
|
||||||
ArrayList<Plot> myplots = new ArrayList<Plot>();
|
ArrayList<Plot> myplots = new ArrayList<>();
|
||||||
for (HashMap<PlotId, Plot> world : plots.values()) {
|
for (HashMap<PlotId, Plot> world : plots.values()) {
|
||||||
for (Plot plot : world.values()) {
|
for (Plot plot : world.values()) {
|
||||||
if (plot.hasOwner()) {
|
if (plot.hasOwner()) {
|
||||||
@ -269,13 +271,13 @@ public class PlotMain extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return new HashSet<Plot>(myplots);
|
return new HashSet<>(myplots);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param world
|
* @param world plot world
|
||||||
* @param player
|
* @param player plot owner
|
||||||
* @return
|
* @return players plots
|
||||||
*/
|
*/
|
||||||
public static Set<Plot> getPlots(World world, Player player) {
|
public static Set<Plot> getPlots(World world, Player player) {
|
||||||
UUID uuid = player.getUniqueId();
|
UUID uuid = player.getUniqueId();
|
||||||
@ -298,8 +300,8 @@ public class PlotMain extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param world
|
* @param world plot world
|
||||||
* @return
|
* @return plots in world
|
||||||
*/
|
*/
|
||||||
public static HashMap<PlotId, Plot> getPlots(World world) {
|
public static HashMap<PlotId, Plot> getPlots(World world) {
|
||||||
if (plots.containsKey(world.getName())) {
|
if (plots.containsKey(world.getName())) {
|
||||||
@ -316,31 +318,31 @@ public class PlotMain extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return
|
* @return plots worlds
|
||||||
*/
|
*/
|
||||||
public static String[] getPlotWorldsString() {
|
public static String[] getPlotWorldsString() {
|
||||||
return plots.keySet().toArray(new String[0]);
|
return plots.keySet().toArray(new String[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param world
|
* @param world plotworld(?)
|
||||||
* @return
|
* @return true if the world is a plotworld
|
||||||
*/
|
*/
|
||||||
public static boolean isPlotWorld(World world) {
|
public static boolean isPlotWorld(World world) {
|
||||||
return (worlds.containsKey(world.getName()));
|
return (worlds.containsKey(world.getName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param world
|
* @param world plotworld(?)
|
||||||
* @return
|
* @return true if the world is a plotworld
|
||||||
*/
|
*/
|
||||||
public static boolean isPlotWorld(String world) {
|
public static boolean isPlotWorld(String world) {
|
||||||
return (worlds.containsKey(world));
|
return (worlds.containsKey(world));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param world
|
* @param world World to get manager for
|
||||||
* @return
|
* @return manager for world
|
||||||
*/
|
*/
|
||||||
public static PlotManager getPlotManager(World world) {
|
public static PlotManager getPlotManager(World world) {
|
||||||
if (managers.containsKey(world.getName())) {
|
if (managers.containsKey(world.getName())) {
|
||||||
@ -1074,7 +1076,8 @@ public class PlotMain extends JavaPlugin {
|
|||||||
* SETUP: settings.yml
|
* SETUP: settings.yml
|
||||||
*/
|
*/
|
||||||
private static void setupConfig() {
|
private static void setupConfig() {
|
||||||
config.set("version", config_ver);
|
int config_ver = 1;
|
||||||
|
config.set("version", config_ver);
|
||||||
Map<String, Object> options = new HashMap<String, Object>();
|
Map<String, Object> options = new HashMap<String, Object>();
|
||||||
options.put("auto_update", false);
|
options.put("auto_update", false);
|
||||||
options.put("worldguard.enabled", Settings.WORLDGUARD);
|
options.put("worldguard.enabled", Settings.WORLDGUARD);
|
||||||
@ -1426,7 +1429,8 @@ public class PlotMain extends JavaPlugin {
|
|||||||
managers.remove(world);
|
managers.remove(world);
|
||||||
worlds.remove(world);
|
worlds.remove(world);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
public static HashMap<String, HashMap<PlotId, Plot>> getAllPlotsRaw() {
|
public static HashMap<String, HashMap<PlotId, Plot>> getAllPlotsRaw() {
|
||||||
return plots;
|
return plots;
|
||||||
}
|
}
|
||||||
|
@ -21,10 +21,20 @@ import java.util.zip.GZIPInputStream;
|
|||||||
import java.util.zip.GZIPOutputStream;
|
import java.util.zip.GZIPOutputStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Citymonstret on 2014-09-15.
|
* Schematic Handler
|
||||||
|
* @author Citymonstret
|
||||||
|
* @author Empire92
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings({"all"})
|
||||||
public class SchematicHandler {
|
public class SchematicHandler {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Paste a schematic
|
||||||
|
* @param location origin
|
||||||
|
* @param schematic schematic to paste
|
||||||
|
* @param plot plot to paste in
|
||||||
|
* @return true if succeeded
|
||||||
|
*/
|
||||||
public static boolean paste(Location location, Schematic schematic, Plot plot) {
|
public static boolean paste(Location location, Schematic schematic, Plot plot) {
|
||||||
if (schematic == null) {
|
if (schematic == null) {
|
||||||
PlotMain.sendConsoleSenderMessage("Schematic == null :|");
|
PlotMain.sendConsoleSenderMessage("Schematic == null :|");
|
||||||
@ -73,6 +83,11 @@ public class SchematicHandler {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a schematic
|
||||||
|
* @param name to check
|
||||||
|
* @return schematic if found, else null
|
||||||
|
*/
|
||||||
public static Schematic getSchematic(String name) {
|
public static Schematic getSchematic(String name) {
|
||||||
{
|
{
|
||||||
File parent =
|
File parent =
|
||||||
@ -89,7 +104,7 @@ public class SchematicHandler {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
Schematic schematic = null;
|
Schematic schematic;
|
||||||
try {
|
try {
|
||||||
InputStream iStream = new FileInputStream(file);
|
InputStream iStream = new FileInputStream(file);
|
||||||
NBTInputStream stream = new NBTInputStream(new GZIPInputStream(iStream));
|
NBTInputStream stream = new NBTInputStream(new GZIPInputStream(iStream));
|
||||||
@ -141,6 +156,10 @@ public class SchematicHandler {
|
|||||||
return schematic;
|
return schematic;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Schematic Class
|
||||||
|
* @author Citymonstret
|
||||||
|
*/
|
||||||
public static class Schematic {
|
public static class Schematic {
|
||||||
private DataCollection[] blockCollection;
|
private DataCollection[] blockCollection;
|
||||||
private Dimension schematicDimension;
|
private Dimension schematicDimension;
|
||||||
@ -165,6 +184,10 @@ public class SchematicHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Schematic Dimensions
|
||||||
|
* @author Citymonstret
|
||||||
|
*/
|
||||||
public static class Dimension {
|
public static class Dimension {
|
||||||
private int x;
|
private int x;
|
||||||
private int y;
|
private int y;
|
||||||
@ -191,9 +214,9 @@ public class SchematicHandler {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Saves a schematic to a file path
|
* Saves a schematic to a file path
|
||||||
* @param tag
|
* @param tag to save
|
||||||
* @param path
|
* @param path to save in
|
||||||
* @return
|
* @return true if succeeded
|
||||||
*/
|
*/
|
||||||
public static boolean save(CompoundTag tag, String path) {
|
public static boolean save(CompoundTag tag, String path) {
|
||||||
|
|
||||||
@ -217,9 +240,9 @@ public class SchematicHandler {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the schematic of a plot
|
* Gets the schematic of a plot
|
||||||
* @param world
|
* @param world to check
|
||||||
* @param plot
|
* @param id plot
|
||||||
* @return
|
* @return tag
|
||||||
*/
|
*/
|
||||||
public static CompoundTag getCompoundTag(World world, PlotId id) {
|
public static CompoundTag getCompoundTag(World world, PlotId id) {
|
||||||
|
|
||||||
@ -255,7 +278,7 @@ public class SchematicHandler {
|
|||||||
int height = 256;
|
int height = 256;
|
||||||
int length = pos2.getBlockZ()-pos1.getBlockZ();
|
int length = pos2.getBlockZ()-pos1.getBlockZ();
|
||||||
|
|
||||||
HashMap<String, Tag> schematic = new HashMap<String, Tag>();
|
HashMap<String, Tag> schematic = new HashMap<>();
|
||||||
schematic.put("Width", new ShortTag("Width", (short) width));
|
schematic.put("Width", new ShortTag("Width", (short) width));
|
||||||
schematic.put("Length", new ShortTag("Length", (short) length));
|
schematic.put("Length", new ShortTag("Length", (short) length));
|
||||||
schematic.put("Height", new ShortTag("Height", (short) height));
|
schematic.put("Height", new ShortTag("Height", (short) height));
|
||||||
@ -269,17 +292,13 @@ public class SchematicHandler {
|
|||||||
byte[] blocks = new byte[width * height * length];
|
byte[] blocks = new byte[width * height * length];
|
||||||
byte[] addBlocks = null;
|
byte[] addBlocks = null;
|
||||||
byte[] blockData = new byte[width * height * length];
|
byte[] blockData = new byte[width * height * length];
|
||||||
|
|
||||||
int count = 0;
|
|
||||||
|
|
||||||
for (int x = 0; x < width; x++) {
|
for (int x = 0; x < width; x++) {
|
||||||
for (int z = 0; z < length; z++) {
|
for (int z = 0; z < length; z++) {
|
||||||
for (int y = 0; y < height; y++) {
|
for (int y = 0; y < height; y++) {
|
||||||
int index = y * width * length + z * width + x;
|
int index = y * width * length + z * width + x;
|
||||||
|
|
||||||
count++;
|
Block block = world.getBlockAt(new Location(world, pos1.getBlockX() + x, y, pos1.getBlockZ() + z));
|
||||||
|
|
||||||
Block block = world.getBlockAt(new Location(world, pos1.getBlockX() + x, 0 + y, pos1.getBlockZ() + z));
|
|
||||||
|
|
||||||
int id2 = block.getTypeId();
|
int id2 = block.getTypeId();
|
||||||
|
|
||||||
@ -294,7 +313,7 @@ public class SchematicHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
blocks[index] = (byte) id2;
|
blocks[index] = (byte) id2;
|
||||||
blockData[index] = (byte) block.getData();
|
blockData[index] = block.getData();
|
||||||
|
|
||||||
|
|
||||||
// We need worldedit to save tileentity data or entities
|
// We need worldedit to save tileentity data or entities
|
||||||
@ -311,10 +330,13 @@ public class SchematicHandler {
|
|||||||
schematic.put("AddBlocks", new ByteArrayTag("AddBlocks", addBlocks));
|
schematic.put("AddBlocks", new ByteArrayTag("AddBlocks", addBlocks));
|
||||||
}
|
}
|
||||||
|
|
||||||
CompoundTag schematicTag = new CompoundTag("Schematic", schematic);
|
return new CompoundTag("Schematic", schematic);
|
||||||
return schematicTag;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Schematic Data Collection
|
||||||
|
* @author Citymonstret
|
||||||
|
*/
|
||||||
public static class DataCollection {
|
public static class DataCollection {
|
||||||
private short block;
|
private short block;
|
||||||
private byte data;
|
private byte data;
|
||||||
|
@ -15,7 +15,13 @@ package com.intellectualcrafters.plot;
|
|||||||
* @author Empire92
|
* @author Empire92
|
||||||
*/
|
*/
|
||||||
public class Settings {
|
public class Settings {
|
||||||
|
/**
|
||||||
|
* Schematic Save Path
|
||||||
|
*/
|
||||||
public static String SCHEMATIC_SAVE_PATH = "/var/www/schematics";
|
public static String SCHEMATIC_SAVE_PATH = "/var/www/schematics";
|
||||||
|
/**
|
||||||
|
* Max allowed plots
|
||||||
|
*/
|
||||||
public static int MAX_PLOTS = 20;
|
public static int MAX_PLOTS = 20;
|
||||||
/**
|
/**
|
||||||
* WorldGuard region on claimed plots
|
* WorldGuard region on claimed plots
|
||||||
@ -49,29 +55,27 @@ public class Settings {
|
|||||||
* Delete plots on ban?
|
* Delete plots on ban?
|
||||||
*/
|
*/
|
||||||
public static boolean DELETE_PLOTS_ON_BAN = false;
|
public static boolean DELETE_PLOTS_ON_BAN = false;
|
||||||
/**
|
/**
|
||||||
* Update settings
|
* Verbose?
|
||||||
*
|
*/
|
||||||
* @author Citymonstret
|
|
||||||
*/
|
|
||||||
public static String URL = "http://dev.bukkit.org/bukkit-plugins/plotsquared/";
|
|
||||||
|
|
||||||
public static boolean DEBUG = true;
|
public static boolean DEBUG = true;
|
||||||
|
/**
|
||||||
|
* Auto clear enabled
|
||||||
|
*/
|
||||||
public static boolean AUTO_CLEAR = false;
|
public static boolean AUTO_CLEAR = false;
|
||||||
|
/**
|
||||||
|
* Days until a plot gets cleared
|
||||||
|
*/
|
||||||
public static int AUTO_CLEAR_DAYS = 365;
|
public static int AUTO_CLEAR_DAYS = 365;
|
||||||
|
/**
|
||||||
|
* API Location
|
||||||
|
*/
|
||||||
public static String API_URL = "http://www.intellectualsites.com/minecraft.php";
|
public static String API_URL = "http://www.intellectualsites.com/minecraft.php";
|
||||||
|
/**
|
||||||
|
* Use the custom API
|
||||||
|
*/
|
||||||
public static boolean CUSTOM_API = true;
|
public static boolean CUSTOM_API = true;
|
||||||
|
|
||||||
public static class Update {
|
|
||||||
/**
|
|
||||||
* Update plugin?
|
|
||||||
*
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public static boolean AUTO_UPDATE = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Database settings
|
* Database settings
|
||||||
@ -79,19 +83,49 @@ public class Settings {
|
|||||||
* @author Citymonstret
|
* @author Citymonstret
|
||||||
*/
|
*/
|
||||||
public static class DB {
|
public static class DB {
|
||||||
|
/**
|
||||||
|
* MongoDB enabled?
|
||||||
|
*/
|
||||||
public static boolean USE_MONGO = false; /*
|
public static boolean USE_MONGO = false; /*
|
||||||
* TODO: Implement Mongo
|
* TODO: Implement Mongo
|
||||||
*
|
*
|
||||||
* @Brandon
|
* @Brandon
|
||||||
*/;
|
*/
|
||||||
|
/**
|
||||||
|
* SQLite enabled?
|
||||||
|
*/
|
||||||
public static boolean USE_SQLITE = false;
|
public static boolean USE_SQLITE = false;
|
||||||
|
/**
|
||||||
|
* MySQL Enabled?
|
||||||
|
*/
|
||||||
public static boolean USE_MYSQL = true; /* NOTE: Fixed connector */
|
public static boolean USE_MYSQL = true; /* NOTE: Fixed connector */
|
||||||
|
/**
|
||||||
|
* SQLite Database name
|
||||||
|
*/
|
||||||
public static String SQLITE_DB = "storage";
|
public static String SQLITE_DB = "storage";
|
||||||
|
/**
|
||||||
|
* MySQL Host name
|
||||||
|
*/
|
||||||
public static String HOST_NAME = "localhost";
|
public static String HOST_NAME = "localhost";
|
||||||
|
/**
|
||||||
|
* MySQL Port
|
||||||
|
*/
|
||||||
public static String PORT = "3306";
|
public static String PORT = "3306";
|
||||||
|
/**
|
||||||
|
* MySQL DB
|
||||||
|
*/
|
||||||
public static String DATABASE = "plot_db";
|
public static String DATABASE = "plot_db";
|
||||||
|
/**
|
||||||
|
* MySQL User
|
||||||
|
*/
|
||||||
public static String USER = "root";
|
public static String USER = "root";
|
||||||
|
/**
|
||||||
|
* MySQL Password
|
||||||
|
*/
|
||||||
public static String PASSWORD = "password";
|
public static String PASSWORD = "password";
|
||||||
|
/**
|
||||||
|
* MySQL Prefix
|
||||||
|
*/
|
||||||
public static String PREFIX = "";
|
public static String PREFIX = "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,24 @@
|
|||||||
package com.intellectualcrafters.plot;
|
package com.intellectualcrafters.plot;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Empire92
|
||||||
|
*/
|
||||||
public class StringWrapper {
|
public class StringWrapper {
|
||||||
public String value;
|
public String value;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
* @param value to wrap
|
||||||
|
*/
|
||||||
public StringWrapper(String value) {
|
public StringWrapper(String value) {
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if a wrapped string equals another one
|
||||||
|
* @param obj to compare
|
||||||
|
* @return true if obj equals the stored value
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object obj) {
|
||||||
if (this == obj) {
|
if (this == obj) {
|
||||||
@ -22,11 +34,19 @@ public class StringWrapper {
|
|||||||
return other.value.toLowerCase().equals(this.value.toLowerCase());
|
return other.value.toLowerCase().equals(this.value.toLowerCase());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the string value
|
||||||
|
* @return string value
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return this.value;
|
return this.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the hash value
|
||||||
|
* @return has value
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return this.value.toLowerCase().hashCode();
|
return this.value.toLowerCase().hashCode();
|
||||||
|
@ -34,22 +34,48 @@ import java.util.UUID;
|
|||||||
*/
|
*/
|
||||||
public class UUIDHandler {
|
public class UUIDHandler {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Online mode
|
||||||
|
* @see org.bukkit.Server#getOnlineMode()
|
||||||
|
*/
|
||||||
private static boolean online = Bukkit.getServer().getOnlineMode();
|
private static boolean online = Bukkit.getServer().getOnlineMode();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Map containing names and UUID's
|
||||||
|
*/
|
||||||
private static BiMap<StringWrapper, UUID> uuidMap = HashBiMap.create(new HashMap<StringWrapper, UUID>());
|
private static BiMap<StringWrapper, UUID> uuidMap = HashBiMap.create(new HashMap<StringWrapper, UUID>());
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the map containing all names/uuids
|
||||||
|
* @return map with names + uuids
|
||||||
|
*/
|
||||||
public static BiMap<StringWrapper, UUID> getUuidMap() {
|
public static BiMap<StringWrapper, UUID> getUuidMap() {
|
||||||
return uuidMap;
|
return uuidMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if a uuid is cached
|
||||||
|
* @param uuid to check
|
||||||
|
* @return true of the uuid is cached
|
||||||
|
*/
|
||||||
public static boolean uuidExists(UUID uuid) {
|
public static boolean uuidExists(UUID uuid) {
|
||||||
return uuidMap.containsValue(uuid);
|
return uuidMap.containsValue(uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if a name is cached
|
||||||
|
* @param name to check
|
||||||
|
* @return true of the name is cached
|
||||||
|
*/
|
||||||
public static boolean nameExists(StringWrapper name) {
|
public static boolean nameExists(StringWrapper name) {
|
||||||
return uuidMap.containsKey(name);
|
return uuidMap.containsKey(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a set to the cache
|
||||||
|
* @param name to cache
|
||||||
|
* @param uuid to cache
|
||||||
|
*/
|
||||||
public static void add(StringWrapper name, UUID uuid) {
|
public static void add(StringWrapper name, UUID uuid) {
|
||||||
if (!uuidMap.containsKey(name) && !uuidMap.inverse().containsKey(uuid)) {
|
if (!uuidMap.containsKey(name) && !uuidMap.inverse().containsKey(uuid)) {
|
||||||
uuidMap.put(name, uuid);
|
uuidMap.put(name, uuid);
|
||||||
@ -57,7 +83,7 @@ public class UUIDHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param name
|
* @param name to use as key
|
||||||
* @return uuid
|
* @return uuid
|
||||||
*/
|
*/
|
||||||
public static UUID getUUID(String name) {
|
public static UUID getUUID(String name) {
|
||||||
@ -65,6 +91,7 @@ public class UUIDHandler {
|
|||||||
if (uuidMap.containsKey(nameWrap)) {
|
if (uuidMap.containsKey(nameWrap)) {
|
||||||
return uuidMap.get(nameWrap);
|
return uuidMap.get(nameWrap);
|
||||||
}
|
}
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
Player player = Bukkit.getPlayer(name);
|
Player player = Bukkit.getPlayer(name);
|
||||||
if (player!=null) {
|
if (player!=null) {
|
||||||
UUID uuid = player.getUniqueId();
|
UUID uuid = player.getUniqueId();
|
||||||
@ -107,7 +134,7 @@ public class UUIDHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param uuid
|
* @param uuid to use as key
|
||||||
* @return name (cache)
|
* @return name (cache)
|
||||||
*/
|
*/
|
||||||
private static StringWrapper loopSearch(UUID uuid) {
|
private static StringWrapper loopSearch(UUID uuid) {
|
||||||
@ -115,7 +142,7 @@ public class UUIDHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param uuid
|
* @param uuid to use as key
|
||||||
* @return Name
|
* @return Name
|
||||||
*/
|
*/
|
||||||
public static String getName(UUID uuid) {
|
public static String getName(UUID uuid) {
|
||||||
@ -173,7 +200,7 @@ public class UUIDHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param name
|
* @param name to use as key
|
||||||
* @return UUID (name hash)
|
* @return UUID (name hash)
|
||||||
*/
|
*/
|
||||||
private static UUID getUuidOfflineMode(StringWrapper name) {
|
private static UUID getUuidOfflineMode(StringWrapper name) {
|
||||||
@ -183,7 +210,7 @@ public class UUIDHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param uuid
|
* @param uuid to use as key
|
||||||
* @return String - name
|
* @return String - name
|
||||||
*/
|
*/
|
||||||
private static String getNameOnlinePlayer(UUID uuid) {
|
private static String getNameOnlinePlayer(UUID uuid) {
|
||||||
@ -197,7 +224,7 @@ public class UUIDHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param uuid
|
* @param uuid to use as key
|
||||||
* @return String - name
|
* @return String - name
|
||||||
*/
|
*/
|
||||||
private static String getNameOfflinePlayer(UUID uuid) {
|
private static String getNameOfflinePlayer(UUID uuid) {
|
||||||
@ -211,10 +238,11 @@ public class UUIDHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param name
|
* @param name to use as key
|
||||||
* @return UUID
|
* @return UUID
|
||||||
*/
|
*/
|
||||||
private static UUID getUuidOnlinePlayer(StringWrapper name) {
|
private static UUID getUuidOnlinePlayer(StringWrapper name) {
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
Player player = Bukkit.getPlayer(name.value);
|
Player player = Bukkit.getPlayer(name.value);
|
||||||
if (player == null) {
|
if (player == null) {
|
||||||
return null;
|
return null;
|
||||||
@ -225,9 +253,10 @@ public class UUIDHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param name
|
* @param name to use as key
|
||||||
* @return UUID (username hash)
|
* @return UUID (username hash)
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("unused")
|
||||||
private static UUID getUuidOfflinePlayer(StringWrapper name) {
|
private static UUID getUuidOfflinePlayer(StringWrapper name) {
|
||||||
UUID uuid = UUID.nameUUIDFromBytes(("OfflinePlayer:" + name.value).getBytes(Charsets.UTF_8));
|
UUID uuid = UUID.nameUUIDFromBytes(("OfflinePlayer:" + name.value).getBytes(Charsets.UTF_8));
|
||||||
add(name, uuid);
|
add(name, uuid);
|
||||||
@ -235,7 +264,11 @@ public class UUIDHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Save UUIDS */
|
/**
|
||||||
|
* Handle saving of uuids
|
||||||
|
* @see com.intellectualcrafters.plot.uuid.UUIDSaver#globalSave(com.google.common.collect.BiMap)
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("unused")
|
||||||
public static void handleSaving() {
|
public static void handleSaving() {
|
||||||
UUIDSaver saver = PlotMain.getUUIDSaver();
|
UUIDSaver saver = PlotMain.getUUIDSaver();
|
||||||
// Should it save per UUIDSet or all of them? TODO: Let Jesse decide xD
|
// Should it save per UUIDSet or all of them? TODO: Let Jesse decide xD
|
||||||
|
@ -24,7 +24,7 @@ import java.util.Set;
|
|||||||
/**
|
/**
|
||||||
* The plotMain api class.
|
* The plotMain api class.
|
||||||
*
|
*
|
||||||
* @author Citymonstret
|
* @author Citymonstret, Empire92
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings({ "unused", "javadoc" })
|
@SuppressWarnings({ "unused", "javadoc" })
|
||||||
public class PlotAPI {
|
public class PlotAPI {
|
||||||
|
Loading…
Reference in New Issue
Block a user