mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-12-26 17:18:43 +01:00
A whole load of fixes
This commit is contained in:
parent
c25eccf4a0
commit
75a5a76fe9
@ -40,6 +40,7 @@ public class ListTagBuilder {
|
||||
*
|
||||
* @return a new builder
|
||||
*/
|
||||
@SafeVarargs
|
||||
public static <T extends Tag> ListTagBuilder createWith(final T... entries) {
|
||||
checkNotNull(entries);
|
||||
|
||||
|
@ -179,8 +179,8 @@ public final class NBTOutputStream implements Closeable {
|
||||
|
||||
this.os.writeByte(NBTUtils.getTypeCode(clazz));
|
||||
this.os.writeInt(size);
|
||||
for (int i = 0; i < size; ++i) {
|
||||
writeTagPayload(tags.get(i));
|
||||
for (Tag tag1 : tags) {
|
||||
writeTagPayload(tag1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -131,7 +131,6 @@ public final class NBTUtils {
|
||||
* @param key the key to look for
|
||||
* @param expected the expected NBT class type
|
||||
* @return child tag
|
||||
* @throws InvalidFormatException
|
||||
*/
|
||||
public static <T extends Tag> T getChildTag(final Map<String, Tag> items, final String key, final Class<T> expected) throws IllegalArgumentException {
|
||||
if (!items.containsKey(key)) {
|
||||
|
@ -247,7 +247,7 @@ public class CDL {
|
||||
if ((names == null) || (names.length() == 0)) {
|
||||
return null;
|
||||
}
|
||||
final StringBuffer sb = new StringBuffer();
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < ja.length(); i += 1) {
|
||||
final JSONObject jo = ja.optJSONObject(i);
|
||||
if (jo != null) {
|
||||
|
@ -27,7 +27,6 @@ import java.io.Writer;
|
||||
import java.lang.reflect.Array;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@ -145,9 +144,8 @@ public class JSONArray {
|
||||
public JSONArray(final Collection<Object> collection) {
|
||||
this.myArrayList = new ArrayList<Object>();
|
||||
if (collection != null) {
|
||||
final Iterator<Object> iter = collection.iterator();
|
||||
while (iter.hasNext()) {
|
||||
this.myArrayList.add(JSONObject.wrap(iter.next()));
|
||||
for (Object aCollection : collection) {
|
||||
this.myArrayList.add(JSONObject.wrap(aCollection));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -548,7 +546,7 @@ public class JSONArray {
|
||||
* @throws JSONException if the value is not finite.
|
||||
*/
|
||||
public JSONArray put(final double value) throws JSONException {
|
||||
final Double d = new Double(value);
|
||||
final Double d = value;
|
||||
JSONObject.testValidity(d);
|
||||
this.put(d);
|
||||
return this;
|
||||
|
@ -164,9 +164,7 @@ public class JSONObject {
|
||||
public JSONObject(final Map<String, Object> map) {
|
||||
this.map = new HashMap<String, Object>();
|
||||
if (map != null) {
|
||||
final Iterator<Entry<String, Object>> i = map.entrySet().iterator();
|
||||
while (i.hasNext()) {
|
||||
final Entry<String, Object> entry = i.next();
|
||||
for (Entry<String, Object> entry : map.entrySet()) {
|
||||
final Object value = entry.getValue();
|
||||
if (value != null) {
|
||||
this.map.put(entry.getKey(), wrap(value));
|
||||
@ -1319,9 +1317,7 @@ public class JSONObject {
|
||||
if (!set.equals(((JSONObject) other).keySet())) {
|
||||
return false;
|
||||
}
|
||||
final Iterator<String> iterator = set.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
final String name = iterator.next();
|
||||
for (String name : set) {
|
||||
final Object valueThis = this.get(name);
|
||||
final Object valueOther = ((JSONObject) other).get(name);
|
||||
if (valueThis instanceof JSONObject) {
|
||||
@ -1485,7 +1481,11 @@ public class JSONObject {
|
||||
*/
|
||||
@Override
|
||||
protected final Object clone() {
|
||||
return this;
|
||||
try {
|
||||
return super.clone();
|
||||
} catch (Exception e) {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -38,6 +38,10 @@ import java.io.Writer;
|
||||
*/
|
||||
public class JSONWriter {
|
||||
private static final int maxdepth = 200;
|
||||
/**
|
||||
* The writer that will receive the output.
|
||||
*/
|
||||
protected final Writer writer;
|
||||
/**
|
||||
* The object/array stack.
|
||||
*/
|
||||
@ -51,10 +55,6 @@ public class JSONWriter {
|
||||
* 'o' (object).
|
||||
*/
|
||||
protected char mode;
|
||||
/**
|
||||
* The writer that will receive the output.
|
||||
*/
|
||||
protected Writer writer;
|
||||
/**
|
||||
* The comma flag determines if a comma should be output before the next
|
||||
* value.
|
||||
|
@ -42,10 +42,8 @@ import com.intellectualcrafters.plot.uuid.PlotUUIDSaver;
|
||||
import com.intellectualcrafters.plot.uuid.UUIDSaver;
|
||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
|
||||
import me.confuser.barapi.BarAPI;
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.command.PluginCommand;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
@ -80,6 +78,43 @@ public class PlotMain extends JavaPlugin {
|
||||
*/
|
||||
public static final String ADMIN_PERMISSION =
|
||||
"plots.admin";
|
||||
/**
|
||||
* Storage version
|
||||
*/
|
||||
public final static int storage_ver =
|
||||
1;
|
||||
/**
|
||||
* Boolean Flags (material)
|
||||
*/
|
||||
public final static HashMap<Material, String> booleanFlags =
|
||||
new HashMap<>();
|
||||
|
||||
/**
|
||||
* Initialize the material flags
|
||||
*/
|
||||
static {
|
||||
booleanFlags.put(Material.WOODEN_DOOR, "wooden_door");
|
||||
booleanFlags.put(Material.IRON_DOOR, "iron_door");
|
||||
booleanFlags.put(Material.STONE_BUTTON, "stone_button");
|
||||
booleanFlags.put(Material.WOOD_BUTTON, "wooden_button");
|
||||
booleanFlags.put(Material.LEVER, "lever");
|
||||
booleanFlags.put(Material.WOOD_PLATE, "wooden_plate");
|
||||
booleanFlags.put(Material.STONE_PLATE, "stone_plate");
|
||||
booleanFlags.put(Material.CHEST, "chest");
|
||||
booleanFlags.put(Material.TRAPPED_CHEST, "trapped_chest");
|
||||
booleanFlags.put(Material.TRAP_DOOR, "trap_door");
|
||||
booleanFlags.put(Material.DISPENSER, "dispenser");
|
||||
booleanFlags.put(Material.DROPPER, "dropper");
|
||||
}
|
||||
|
||||
/**
|
||||
* All loaded plot worlds
|
||||
*/
|
||||
private final static HashMap<String, PlotWorld> worlds = new HashMap<>();
|
||||
/**
|
||||
* All world managers
|
||||
*/
|
||||
private final static HashMap<String, PlotManager> managers = new HashMap<>();
|
||||
/**
|
||||
* settings.properties
|
||||
*/
|
||||
@ -96,11 +131,6 @@ public class PlotMain extends JavaPlugin {
|
||||
* Contains storage options
|
||||
*/
|
||||
public static YamlConfiguration storage;
|
||||
/**
|
||||
* Storage version
|
||||
*/
|
||||
public static int storage_ver =
|
||||
1;
|
||||
/**
|
||||
* MySQL Connection
|
||||
*/
|
||||
@ -135,30 +165,6 @@ public class PlotMain extends JavaPlugin {
|
||||
*/
|
||||
public static boolean useEconomy =
|
||||
false;
|
||||
/**
|
||||
* Boolean Flags (material)
|
||||
*/
|
||||
public static HashMap<Material, String> booleanFlags =
|
||||
new HashMap<>();
|
||||
|
||||
/**
|
||||
* Initialize the material flags
|
||||
*/
|
||||
static {
|
||||
booleanFlags.put(Material.WOODEN_DOOR, "wooden_door");
|
||||
booleanFlags.put(Material.IRON_DOOR, "iron_door");
|
||||
booleanFlags.put(Material.STONE_BUTTON, "stone_button");
|
||||
booleanFlags.put(Material.WOOD_BUTTON, "wooden_button");
|
||||
booleanFlags.put(Material.LEVER, "lever");
|
||||
booleanFlags.put(Material.WOOD_PLATE, "wooden_plate");
|
||||
booleanFlags.put(Material.STONE_PLATE, "stone_plate");
|
||||
booleanFlags.put(Material.CHEST, "chest");
|
||||
booleanFlags.put(Material.TRAPPED_CHEST, "trapped_chest");
|
||||
booleanFlags.put(Material.TRAP_DOOR, "trap_door");
|
||||
booleanFlags.put(Material.DISPENSER, "dispenser");
|
||||
booleanFlags.put(Material.DROPPER, "dropper");
|
||||
}
|
||||
|
||||
/**
|
||||
* The UUID Saver
|
||||
*/
|
||||
@ -172,14 +178,6 @@ public class PlotMain extends JavaPlugin {
|
||||
* DO NOT USE EXCEPT FOR DATABASE PURPOSES
|
||||
*/
|
||||
private static LinkedHashMap<String, HashMap<PlotId, Plot>> plots;
|
||||
/**
|
||||
* All loaded plot worlds
|
||||
*/
|
||||
private static HashMap<String, PlotWorld> worlds = new HashMap<>();
|
||||
/**
|
||||
* All world managers
|
||||
*/
|
||||
private static HashMap<String, PlotManager> managers = new HashMap<>();
|
||||
|
||||
/**
|
||||
* Check for expired plots
|
||||
@ -202,12 +200,9 @@ public class PlotMain extends JavaPlugin {
|
||||
* Check a range of permissions e.g. 'plots.plot.<0-100>'<br>
|
||||
* Returns highest integer in range.
|
||||
*
|
||||
* @param player
|
||||
* to check
|
||||
* @param stub
|
||||
* to check
|
||||
* @param range
|
||||
* tp check
|
||||
* @param player to check
|
||||
* @param stub to check
|
||||
* @param range tp check
|
||||
* @return permitted range
|
||||
*/
|
||||
public static int hasPermissionRange(final Player player, final String stub, final int range) {
|
||||
@ -230,10 +225,8 @@ public class PlotMain extends JavaPlugin {
|
||||
* - Op has all permissions <br>
|
||||
* - checks for '*' nodes
|
||||
*
|
||||
* @param player
|
||||
* to check
|
||||
* @param perms
|
||||
* to check
|
||||
* @param player to check
|
||||
* @param perms to check
|
||||
* @return true of player has permissions
|
||||
*/
|
||||
public static boolean hasPermissions(final Player player, final String[] perms) {
|
||||
@ -266,6 +259,7 @@ public class PlotMain extends JavaPlugin {
|
||||
|
||||
/**
|
||||
* Get the uuid saver
|
||||
*
|
||||
* @return uuid saver
|
||||
* @see com.intellectualcrafters.plot.uuid.UUIDSaver;
|
||||
*/
|
||||
@ -288,10 +282,8 @@ public class PlotMain extends JavaPlugin {
|
||||
* - Op has all permissions <br>
|
||||
* - checks for '*' nodes
|
||||
*
|
||||
* @param player
|
||||
* to check
|
||||
* @param perm
|
||||
* to check
|
||||
* @param player to check
|
||||
* @param perm to check
|
||||
* @return true if player has the permission
|
||||
*/
|
||||
public static boolean hasPermission(final Player player, final String perm) {
|
||||
@ -328,6 +320,7 @@ public class PlotMain extends JavaPlugin {
|
||||
|
||||
/**
|
||||
* Get a sorted list of plots
|
||||
*
|
||||
* @return sorted list
|
||||
*/
|
||||
public static LinkedHashSet<Plot> getPlotsSorted() {
|
||||
@ -339,8 +332,7 @@ public class PlotMain extends JavaPlugin {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param player
|
||||
* player
|
||||
* @param player player
|
||||
* @return Set Containing the players plots
|
||||
*/
|
||||
public static Set<Plot> getPlots(final Player player) {
|
||||
@ -390,8 +382,7 @@ public class PlotMain extends JavaPlugin {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param world
|
||||
* plot world
|
||||
* @param world plot world
|
||||
* @return plots in world
|
||||
*/
|
||||
public static HashMap<PlotId, Plot> getPlots(final World world) {
|
||||
@ -418,8 +409,7 @@ public class PlotMain extends JavaPlugin {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param world
|
||||
* plotworld(?)
|
||||
* @param world plotworld(?)
|
||||
* @return true if the world is a plotworld
|
||||
*/
|
||||
public static boolean isPlotWorld(final World world) {
|
||||
@ -427,8 +417,7 @@ public class PlotMain extends JavaPlugin {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param world
|
||||
* plotworld(?)
|
||||
* @param world plotworld(?)
|
||||
* @return true if the world is a plotworld
|
||||
*/
|
||||
public static boolean isPlotWorld(final String world) {
|
||||
@ -436,8 +425,7 @@ public class PlotMain extends JavaPlugin {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param world
|
||||
* World to get manager for
|
||||
* @param world World to get manager for
|
||||
* @return manager for world
|
||||
*/
|
||||
public static PlotManager getPlotManager(final World world) {
|
||||
@ -491,8 +479,9 @@ public class PlotMain extends JavaPlugin {
|
||||
|
||||
/**
|
||||
* Remove a plot
|
||||
* @param world The Plot World
|
||||
* @param id The Plot ID
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
@ -512,8 +501,7 @@ public class PlotMain extends JavaPlugin {
|
||||
/**
|
||||
* Replace the plot object with an updated version
|
||||
*
|
||||
* @param plot
|
||||
* plot object
|
||||
* @param plot plot object
|
||||
*/
|
||||
public static void updatePlot(final Plot plot) {
|
||||
final String world = plot.world;
|
||||
@ -545,10 +533,8 @@ public class PlotMain extends JavaPlugin {
|
||||
* - Add new plots to the end.<br>
|
||||
* - The task then only needs to go through the first few plots
|
||||
*
|
||||
* @param plugin
|
||||
* Plugin
|
||||
* @param async
|
||||
* Call async?
|
||||
* @param plugin Plugin
|
||||
* @param async Call async?
|
||||
*/
|
||||
private static void checkExpired(final JavaPlugin plugin, final boolean async) {
|
||||
if (async) {
|
||||
@ -633,8 +619,7 @@ public class PlotMain extends JavaPlugin {
|
||||
/**
|
||||
* Send a message to the console.
|
||||
*
|
||||
* @param string
|
||||
* message
|
||||
* @param string message
|
||||
*/
|
||||
public static void sendConsoleSenderMessage(final String string) {
|
||||
if (getMain().getServer().getConsoleSender() == null) {
|
||||
@ -646,9 +631,10 @@ 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
|
||||
* @param from Previous Location
|
||||
* @param plot Plot to teleport to
|
||||
* @return true if successful
|
||||
*/
|
||||
public static boolean teleportPlayer(final Player player, final Location from, final Plot plot) {
|
||||
@ -669,8 +655,7 @@ public class PlotMain extends JavaPlugin {
|
||||
/**
|
||||
* Send a message to the console
|
||||
*
|
||||
* @param c
|
||||
* message
|
||||
* @param c message
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public static void sendConsoleSenderMessage(final C c) {
|
||||
@ -680,8 +665,7 @@ public class PlotMain extends JavaPlugin {
|
||||
/**
|
||||
* Broadcast publicly
|
||||
*
|
||||
* @param c
|
||||
* message
|
||||
* @param c message
|
||||
*/
|
||||
public static void Broadcast(final C c) {
|
||||
Bukkit.broadcastMessage(ChatColor.translateAlternateColorCodes('&', C.PREFIX.s() + c.s()));
|
||||
@ -699,8 +683,7 @@ public class PlotMain extends JavaPlugin {
|
||||
/**
|
||||
* Broadcast a message to all admins
|
||||
*
|
||||
* @param c
|
||||
* message
|
||||
* @param c message
|
||||
*/
|
||||
public static void BroadcastWithPerms(final C c) {
|
||||
for (final Player player : Bukkit.getOnlinePlayers()) {
|
||||
@ -713,6 +696,7 @@ public class PlotMain extends JavaPlugin {
|
||||
|
||||
/**
|
||||
* Reload all translations
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
public static void reloadTranslations() throws IOException {
|
||||
@ -721,6 +705,7 @@ public class PlotMain extends JavaPlugin {
|
||||
|
||||
/**
|
||||
* Ge the last played time
|
||||
*
|
||||
* @param uuid UUID for the player
|
||||
* @return last play time as a long
|
||||
*/
|
||||
@ -968,6 +953,7 @@ public class PlotMain extends JavaPlugin {
|
||||
|
||||
/**
|
||||
* Create a plotworld config section
|
||||
*
|
||||
* @param plotworld World to create the section for
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
@ -1299,9 +1285,10 @@ public class PlotMain extends JavaPlugin {
|
||||
|
||||
/**
|
||||
* Add a Plot world
|
||||
* @param world World to add
|
||||
*
|
||||
* @param world World to add
|
||||
* @param plotworld PlotWorld Object
|
||||
* @param manager Plot Manager for the new world
|
||||
* @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);
|
||||
@ -1313,6 +1300,7 @@ public class PlotMain extends JavaPlugin {
|
||||
|
||||
/**
|
||||
* Remove a plot world
|
||||
*
|
||||
* @param world World to remove
|
||||
*/
|
||||
public static void removePlotWorld(final String world) {
|
||||
@ -1323,21 +1311,13 @@ public class PlotMain extends JavaPlugin {
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set all plots
|
||||
*
|
||||
* @param plots New Plot LinkedHashMap
|
||||
*/
|
||||
public static void setAllPlotsRaw(final LinkedHashMap<String, HashMap<PlotId, Plot>> plots) {
|
||||
PlotMain.plots = plots;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set all plots
|
||||
*
|
||||
@ -1348,6 +1328,15 @@ public class PlotMain extends JavaPlugin {
|
||||
// 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the PlotSquared World Generator
|
||||
*
|
||||
@ -1595,7 +1584,7 @@ public class PlotMain extends JavaPlugin {
|
||||
} catch (final Exception e) {
|
||||
PlotHelper.canSetFast = false;
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
new SendChunk();
|
||||
PlotHelper.canSendChunk = true;
|
||||
|
@ -33,7 +33,7 @@ import org.bukkit.entity.Player;
|
||||
import java.util.UUID;
|
||||
|
||||
|
||||
@SuppressWarnings("deprecated")
|
||||
@SuppressWarnings("deprecation")
|
||||
public class Denied extends SubCommand {
|
||||
|
||||
public Denied() {
|
||||
|
@ -53,7 +53,7 @@ public class Inbox extends SubCommand {
|
||||
return false;
|
||||
}
|
||||
|
||||
Integer tier = null;
|
||||
Integer tier;
|
||||
final UUID uuid = plr.getUniqueId();
|
||||
if (PlotMain.hasPermission(plr, "plots.admin")) {
|
||||
tier = 0;
|
||||
@ -151,14 +151,13 @@ public class Inbox extends SubCommand {
|
||||
}
|
||||
plot.settings.removeComments(comments);
|
||||
PlayerFunctions.sendMessage(plr, C.COMMENT_REMOVED, "all comments in that category");
|
||||
return;
|
||||
} else {
|
||||
final List<String> recipients = Arrays.asList(new String[]{"A", "O", "H", "T", "E"});
|
||||
final List<String> recipients = Arrays.asList("A", "O", "H", "T", "E");
|
||||
int count = 1;
|
||||
final StringBuilder message = new StringBuilder();
|
||||
String prefix = "";
|
||||
for (final PlotComment comment : comments) {
|
||||
message.append(prefix + "[" + count + "]&6[&c" + recipients.get(tier2) + "&6] &7" + comment.senderName + "&f: " + comment.comment);
|
||||
message.append(prefix).append("[").append(count).append("]&6[&c").append(recipients.get(tier2)).append("&6] &7").append(comment.senderName).append("&f: ").append(comment.comment);
|
||||
prefix = "\n";
|
||||
count++;
|
||||
}
|
||||
|
@ -103,16 +103,8 @@ public class Info extends SubCommand {
|
||||
|
||||
// Wildcard player {added}
|
||||
{
|
||||
if (plot.helpers == null) {
|
||||
containsEveryone = false;
|
||||
} else {
|
||||
containsEveryone = plot.helpers.contains(DBFunc.everyone);
|
||||
}
|
||||
if (plot.trusted == null) {
|
||||
trustedEveryone = false;
|
||||
} else {
|
||||
trustedEveryone = plot.trusted.contains(DBFunc.everyone);
|
||||
}
|
||||
containsEveryone = plot.helpers != null && plot.helpers.contains(DBFunc.everyone);
|
||||
trustedEveryone = plot.trusted != null && plot.trusted.contains(DBFunc.everyone);
|
||||
}
|
||||
|
||||
// Unclaimed?
|
||||
@ -183,7 +175,7 @@ public class Info extends SubCommand {
|
||||
final String denied = getPlayerList(plot.denied);
|
||||
final String rating = String.format("%.1f", DBFunc.getRatings(plot));
|
||||
final String flags = "&6" + (StringUtils.join(plot.settings.getFlags(), "").length() > 0 ? StringUtils.join(plot.settings.getFlags(), "&7, &6") : "none");
|
||||
final boolean build = player == null ? true : plot.hasRights(player);
|
||||
final boolean build = player == null || plot.hasRights(player);
|
||||
|
||||
String owner = "none";
|
||||
if (plot.owner != null) {
|
||||
|
@ -49,7 +49,7 @@ public class MainCommand implements CommandExecutor, TabCompleter {
|
||||
public static final String
|
||||
MAIN_PERMISSION = "plots.use";
|
||||
|
||||
private static SubCommand[] _subCommands =
|
||||
private final static SubCommand[] _subCommands =
|
||||
new SubCommand[]{
|
||||
new Ban(), new Unban(),
|
||||
new OP(), new DEOP(),
|
||||
@ -71,7 +71,7 @@ public class MainCommand implements CommandExecutor, TabCompleter {
|
||||
new Comment(), new Database(),
|
||||
new Swap(), new MusicSubcommand()};
|
||||
|
||||
public static ArrayList<SubCommand> subCommands = new ArrayList<SubCommand>() {
|
||||
public final static ArrayList<SubCommand> subCommands = new ArrayList<SubCommand>() {
|
||||
{
|
||||
addAll(Arrays.asList(_subCommands));
|
||||
}
|
||||
|
@ -43,8 +43,8 @@ import java.util.ArrayList;
|
||||
*/
|
||||
public class Merge extends SubCommand {
|
||||
|
||||
public static String[] values = new String[]{"north", "east", "south", "west"};
|
||||
public static String[] aliases = new String[]{"n", "e", "s", "w"};
|
||||
public final static String[] values = new String[]{"north", "east", "south", "west"};
|
||||
public final static String[] aliases = new String[]{"n", "e", "s", "w"};
|
||||
|
||||
public Merge() {
|
||||
super(Command.MERGE, "Merge the plot you are standing on with another plot.", "merge", CommandCategory.ACTIONS, true);
|
||||
|
@ -53,8 +53,8 @@ import java.util.List;
|
||||
*/
|
||||
public class Set extends SubCommand {
|
||||
|
||||
public static String[] values = new String[]{"biome", "wall", "wall_filling", "floor", "alias", "home", "flag"};
|
||||
public static String[] aliases = new String[]{"b", "w", "wf", "f", "a", "h", "fl"};
|
||||
public final static String[] values = new String[]{"biome", "wall", "wall_filling", "floor", "alias", "home", "flag"};
|
||||
public final static String[] aliases = new String[]{"b", "w", "wf", "f", "a", "h", "fl"};
|
||||
|
||||
public Set() {
|
||||
super(Command.SET, "Set a plot value", "set {arg} {value...}", CommandCategory.ACTIONS, true);
|
||||
|
@ -49,7 +49,7 @@ import java.util.Map;
|
||||
*/
|
||||
public class Setup extends SubCommand implements Listener {
|
||||
|
||||
public static Map<String, SetupObject> setupMap = new HashMap<>();
|
||||
public final static Map<String, SetupObject> setupMap = new HashMap<>();
|
||||
|
||||
public Setup() {
|
||||
super("setup", "plots.admin", "Setup a PlotWorld", "setup {world} {generator}", "setup", CommandCategory.ACTIONS, false);
|
||||
@ -208,12 +208,11 @@ public class Setup extends SubCommand implements Listener {
|
||||
}
|
||||
|
||||
private class SetupObject {
|
||||
String world;
|
||||
String plugin;
|
||||
final String world;
|
||||
final String plugin;
|
||||
final ConfigurationNode[] step;
|
||||
int current = 0;
|
||||
|
||||
ConfigurationNode[] step;
|
||||
|
||||
public SetupObject(final String world, final PlotWorld plotworld, final String plugin) {
|
||||
this.world = world;
|
||||
this.step = plotworld.getSettingNodes();
|
||||
|
@ -60,7 +60,7 @@ public abstract class SubCommand {
|
||||
/**
|
||||
* Is this a player-online command?
|
||||
*/
|
||||
public boolean isPlayer;
|
||||
public final boolean isPlayer;
|
||||
|
||||
/**
|
||||
* @param cmd Command /plot {cmd} <-- That!
|
||||
|
@ -33,7 +33,9 @@ import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* Created by Citymonstret on 2014-08-01.
|
||||
* Created 2014-08-01 for PlotSquared
|
||||
*
|
||||
* @author Empire92
|
||||
*/
|
||||
public class Swap extends SubCommand {
|
||||
|
||||
@ -76,6 +78,7 @@ public class Swap extends SubCommand {
|
||||
PlayerFunctions.sendMessage(plr, C.SWAP_SYNTAX);
|
||||
return false;
|
||||
}
|
||||
assert plot != null;
|
||||
if (plot.id.equals(plotid)) {
|
||||
PlayerFunctions.sendMessage(plr, C.NOT_VALID_PLOT_ID);
|
||||
PlayerFunctions.sendMessage(plr, C.SWAP_SYNTAX);
|
||||
|
@ -382,7 +382,7 @@ public enum C {
|
||||
*
|
||||
* @see com.intellectualsites.translation.TranslationLanguage
|
||||
*/
|
||||
protected static TranslationLanguage lang = new TranslationLanguage("PlotSquared", "this", "use");
|
||||
protected final static TranslationLanguage lang = new TranslationLanguage("PlotSquared", "this", "use");
|
||||
|
||||
/**
|
||||
* The TranslationManager
|
||||
|
@ -29,71 +29,58 @@ package com.intellectualcrafters.plot.config;
|
||||
*/
|
||||
public class Settings {
|
||||
|
||||
/**
|
||||
* Default kill road mobs: true
|
||||
*/
|
||||
public final static boolean KILL_ROAD_MOBS_DEFAULT = true;
|
||||
/**
|
||||
* Default mob pathfinding: true
|
||||
*/
|
||||
public final static boolean MOB_PATHFINDING_DEFAULT = true;
|
||||
/**
|
||||
* 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?
|
||||
*/
|
||||
|
@ -33,24 +33,43 @@ import java.util.LinkedHashMap;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* DB Functions
|
||||
*
|
||||
* @author Empire92
|
||||
* @author Citymonstret
|
||||
*/
|
||||
public class DBFunc {
|
||||
|
||||
/**
|
||||
* The "global" uuid
|
||||
*/
|
||||
public static final UUID everyone = UUID.fromString("1-1-3-3-7");
|
||||
/**
|
||||
* Abstract Database Manager
|
||||
*/
|
||||
public static AbstractDB dbManager;
|
||||
|
||||
// TODO MongoDB @Brandon
|
||||
|
||||
public static UUID everyone = UUID.fromString("1-1-3-3-7");
|
||||
|
||||
/**
|
||||
* Set the owner of a plot
|
||||
* @param plot Plot Object
|
||||
* @param uuid New Owner
|
||||
*/
|
||||
public static void setOwner(final Plot plot, final UUID uuid) {
|
||||
dbManager.setOwner(plot, uuid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create all settings + (helpers, denied, trusted)
|
||||
* @param plots List containing all plot objects
|
||||
*/
|
||||
public static void createAllSettingsAndHelpers(final ArrayList<Plot> plots) {
|
||||
dbManager.createAllSettingsAndHelpers(plots);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create all plots
|
||||
* @param plots A list containing plot objects
|
||||
*/
|
||||
public static void createPlots(final ArrayList<Plot> plots) {
|
||||
dbManager.createPlots(plots);
|
||||
}
|
||||
@ -58,7 +77,7 @@ public class DBFunc {
|
||||
/**
|
||||
* Create a plot
|
||||
*
|
||||
* @param plot
|
||||
* @param plot Plot to create
|
||||
*/
|
||||
public static void createPlot(final Plot plot) {
|
||||
dbManager.createPlot(plot);
|
||||
@ -76,7 +95,7 @@ public class DBFunc {
|
||||
/**
|
||||
* Delete a plot
|
||||
*
|
||||
* @param plot
|
||||
* @param plot Plot to delete
|
||||
*/
|
||||
public static void delete(final String world, final Plot plot) {
|
||||
dbManager.delete(world, plot);
|
||||
@ -85,8 +104,8 @@ public class DBFunc {
|
||||
/**
|
||||
* Create plot settings
|
||||
*
|
||||
* @param id
|
||||
* @param plot
|
||||
* @param id Plot ID
|
||||
* @param plot Plot Object
|
||||
*/
|
||||
public static void createPlotSettings(final int id, final Plot plot) {
|
||||
dbManager.createPlotSettings(id, plot);
|
||||
@ -95,8 +114,9 @@ public class DBFunc {
|
||||
/**
|
||||
* Get a plot id
|
||||
*
|
||||
* @param plot_id
|
||||
* @return
|
||||
* @param world World
|
||||
* @param id2 Plot ID
|
||||
* @return ID
|
||||
*/
|
||||
/*
|
||||
* public static int getId(String world, PlotId id2) { Statement stmt =
|
||||
@ -113,7 +133,7 @@ public class DBFunc {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
* @return Plots
|
||||
*/
|
||||
public static LinkedHashMap<String, HashMap<PlotId, Plot>> getPlots() {
|
||||
return dbManager.getPlots();
|
||||
|
@ -39,7 +39,7 @@ public abstract class Database {
|
||||
/**
|
||||
* Plugin instance, use for plugin.getDataFolder()
|
||||
*/
|
||||
protected Plugin plugin;
|
||||
protected final Plugin plugin;
|
||||
|
||||
/**
|
||||
* Creates a new Database
|
||||
|
@ -1,7 +0,0 @@
|
||||
package com.intellectualcrafters.plot.database;
|
||||
|
||||
/**
|
||||
* Created by Citymonstret on 2014-09-23.
|
||||
*/
|
||||
public class FlatFileManager {
|
||||
}
|
@ -97,9 +97,7 @@ public class MySQL extends Database {
|
||||
|
||||
final Statement statement = this.connection.createStatement();
|
||||
|
||||
final ResultSet result = statement.executeQuery(query);
|
||||
|
||||
return result;
|
||||
return statement.executeQuery(query);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -110,9 +108,7 @@ public class MySQL extends Database {
|
||||
|
||||
final Statement statement = this.connection.createStatement();
|
||||
|
||||
final int result = statement.executeUpdate(query);
|
||||
|
||||
return result;
|
||||
return statement.executeUpdate(query);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -195,12 +195,12 @@ public class PlotMeConverter {
|
||||
final PlotId id = new PlotId(Integer.parseInt(plot.id.split(";")[0]), Integer.parseInt(plot.id.split(";")[1]));
|
||||
com.intellectualcrafters.plot.object.Plot pl;
|
||||
if (online) {
|
||||
pl = new com.intellectualcrafters.plot.object.Plot(id, plot.getOwnerId(), plot.getBiome(), psAdded, psTrusted, psDenied,
|
||||
pl = new com.intellectualcrafters.plot.object.Plot(id, plot.getOwnerId(), psAdded, psTrusted, psDenied,
|
||||
|
||||
"", PlotHomePosition.DEFAULT, null, world.getName(), new boolean[]{false, false, false, false});
|
||||
} else {
|
||||
final String owner = plot.getOwner();
|
||||
pl = new com.intellectualcrafters.plot.object.Plot(id, UUID.nameUUIDFromBytes(("OfflinePlayer:" + owner).getBytes(Charsets.UTF_8)), plot.getBiome(), psAdded, psTrusted, psDenied,
|
||||
pl = new com.intellectualcrafters.plot.object.Plot(id, UUID.nameUUIDFromBytes(("OfflinePlayer:" + owner).getBytes(Charsets.UTF_8)), psAdded, psTrusted, psDenied,
|
||||
|
||||
"", PlotHomePosition.DEFAULT, null, world.getName(), new boolean[]{false, false, false, false});
|
||||
}
|
||||
|
@ -383,7 +383,7 @@ public class SQLManager implements AbstractDB {
|
||||
*/
|
||||
@Override
|
||||
public LinkedHashMap<String, HashMap<PlotId, Plot>> getPlots() {
|
||||
final LinkedHashMap<String, HashMap<PlotId, Plot>> newplots = new LinkedHashMap<String, HashMap<PlotId, Plot>>();
|
||||
final LinkedHashMap<String, HashMap<PlotId, Plot>> newplots = new LinkedHashMap<>();
|
||||
try {
|
||||
final DatabaseMetaData data = connection.getMetaData();
|
||||
ResultSet rs = data.getColumns(null, null, prefix + "plot", "plot_id");
|
||||
@ -408,12 +408,12 @@ public class SQLManager implements AbstractDB {
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
final HashMap<Integer, Plot> plots = new HashMap<Integer, Plot>();
|
||||
final HashMap<Integer, Plot> plots = new HashMap<>();
|
||||
|
||||
Statement stmt = null;
|
||||
try {
|
||||
|
||||
Set<String> worlds = new HashSet<String>();
|
||||
Set<String> worlds = new HashSet<>();
|
||||
if (PlotMain.config.contains("worlds")) {
|
||||
worlds = PlotMain.config.getConfigurationSection("worlds").getKeys(false);
|
||||
}
|
||||
@ -448,7 +448,7 @@ public class SQLManager implements AbstractDB {
|
||||
user = UUID.fromString(o);
|
||||
uuids.put(o, user);
|
||||
}
|
||||
p = new Plot(plot_id, user, Biome.FOREST, new ArrayList<UUID>(), new ArrayList<UUID>(), new ArrayList<UUID>(), "", PlotHomePosition.DEFAULT, null, worldname, new boolean[]{false, false, false, false});
|
||||
p = new Plot(plot_id, user, new ArrayList<UUID>(), new ArrayList<UUID>(), new ArrayList<UUID>(), "", PlotHomePosition.DEFAULT, null, worldname, new boolean[]{false, false, false, false});
|
||||
plots.put(id, p);
|
||||
}
|
||||
// stmt.close();
|
||||
@ -924,7 +924,6 @@ public class SQLManager implements AbstractDB {
|
||||
h.put(var, val);
|
||||
}
|
||||
stmt.close();
|
||||
;
|
||||
} catch (final SQLException e) {
|
||||
Logger.add(LogLevel.WARNING, "Failed to load settings for plot: " + id);
|
||||
e.printStackTrace();
|
||||
|
@ -36,8 +36,8 @@ import java.util.logging.Level;
|
||||
*/
|
||||
public class SQLite extends Database {
|
||||
|
||||
private Connection connection;
|
||||
private final String dbLocation;
|
||||
private Connection connection;
|
||||
|
||||
/**
|
||||
* Creates a new SQLite instance
|
||||
@ -98,9 +98,7 @@ public class SQLite extends Database {
|
||||
|
||||
final Statement statement = this.connection.createStatement();
|
||||
|
||||
final ResultSet result = statement.executeQuery(query);
|
||||
|
||||
return result;
|
||||
return statement.executeQuery(query);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -111,8 +109,6 @@ public class SQLite extends Database {
|
||||
|
||||
final Statement statement = this.connection.createStatement();
|
||||
|
||||
final int result = statement.executeUpdate(query);
|
||||
|
||||
return result;
|
||||
return statement.executeUpdate(query);
|
||||
}
|
||||
}
|
||||
|
@ -1,17 +0,0 @@
|
||||
package com.intellectualcrafters.plot.database.sqlobjects;
|
||||
|
||||
/**
|
||||
* Created by Citymonstret on 2014-10-28.
|
||||
*/
|
||||
public class PlotTable extends SQLTable {
|
||||
|
||||
public PlotTable() {
|
||||
super("plots", "hello", null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void create() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
}
|
@ -1,45 +0,0 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// PlotSquared - A plot manager and world generator for the Bukkit API /
|
||||
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
|
||||
// /
|
||||
// This program is free software; you can redistribute it and/or modify /
|
||||
// it under the terms of the GNU General Public License as published by /
|
||||
// the Free Software Foundation; either version 3 of the License, or /
|
||||
// (at your option) any later version. /
|
||||
// /
|
||||
// This program is distributed in the hope that it will be useful, /
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
|
||||
// GNU General Public License for more details. /
|
||||
// /
|
||||
// You should have received a copy of the GNU General Public License /
|
||||
// along with this program; if not, write to the Free Software Foundation, /
|
||||
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
|
||||
// /
|
||||
// You can contact us via: support@intellectualsites.com /
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
package com.intellectualcrafters.plot.database.sqlobjects;
|
||||
|
||||
/**
|
||||
* Created by Citymonstret on 2014-10-28.
|
||||
*/
|
||||
public class SQLField {
|
||||
|
||||
private final SQLType type;
|
||||
private final Object value;
|
||||
|
||||
public SQLField(final SQLType type, final Object value) {
|
||||
this.type = type;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public SQLType getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
public Object getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
}
|
@ -1,50 +0,0 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// PlotSquared - A plot manager and world generator for the Bukkit API /
|
||||
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
|
||||
// /
|
||||
// This program is free software; you can redistribute it and/or modify /
|
||||
// it under the terms of the GNU General Public License as published by /
|
||||
// the Free Software Foundation; either version 3 of the License, or /
|
||||
// (at your option) any later version. /
|
||||
// /
|
||||
// This program is distributed in the hope that it will be useful, /
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
|
||||
// GNU General Public License for more details. /
|
||||
// /
|
||||
// You should have received a copy of the GNU General Public License /
|
||||
// along with this program; if not, write to the Free Software Foundation, /
|
||||
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
|
||||
// /
|
||||
// You can contact us via: support@intellectualsites.com /
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
package com.intellectualcrafters.plot.database.sqlobjects;
|
||||
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
|
||||
/**
|
||||
* Created by Citymonstret on 2014-10-28.
|
||||
*/
|
||||
public abstract class SQLTable {
|
||||
|
||||
private final String name;
|
||||
private final SQLField[] fields;
|
||||
|
||||
public SQLTable(final String name, final String primaryKey, final SQLField... fields) {
|
||||
this.name = Settings.DB.PREFIX + name;
|
||||
this.fields = fields;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public SQLField[] getFields() {
|
||||
return this.fields;
|
||||
}
|
||||
|
||||
public abstract void create();
|
||||
|
||||
}
|
@ -1,61 +0,0 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// PlotSquared - A plot manager and world generator for the Bukkit API /
|
||||
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
|
||||
// /
|
||||
// This program is free software; you can redistribute it and/or modify /
|
||||
// it under the terms of the GNU General Public License as published by /
|
||||
// the Free Software Foundation; either version 3 of the License, or /
|
||||
// (at your option) any later version. /
|
||||
// /
|
||||
// This program is distributed in the hope that it will be useful, /
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
|
||||
// GNU General Public License for more details. /
|
||||
// /
|
||||
// You should have received a copy of the GNU General Public License /
|
||||
// along with this program; if not, write to the Free Software Foundation, /
|
||||
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
|
||||
// /
|
||||
// You can contact us via: support@intellectualsites.com /
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
package com.intellectualcrafters.plot.database.sqlobjects;
|
||||
|
||||
/**
|
||||
* Created by Citymonstret on 2014-10-28.
|
||||
*/
|
||||
public enum SQLType {
|
||||
|
||||
INTEGER(0, "integer", Integer.class, 11),
|
||||
VARCHAR("", "varchar", String.class, 300),
|
||||
BOOL(false, "bool", Boolean.class, 1);
|
||||
|
||||
private Object defaultValue;
|
||||
private String sqlName;
|
||||
private Class javaClass;
|
||||
private int length;
|
||||
|
||||
SQLType(final Object defaultValue, final String sqlName, final Class javaClass, final int length) {
|
||||
this.defaultValue = defaultValue;
|
||||
this.sqlName = sqlName;
|
||||
this.javaClass = javaClass;
|
||||
this.length = length;
|
||||
}
|
||||
|
||||
public int getLength() {
|
||||
return this.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.sqlName;
|
||||
}
|
||||
|
||||
public Class getJavaClass() {
|
||||
return this.javaClass;
|
||||
}
|
||||
|
||||
public Object getDefaultValue() {
|
||||
return this.defaultValue;
|
||||
}
|
||||
}
|
@ -42,7 +42,7 @@ public class FlagManager {
|
||||
// - Mob cap
|
||||
// - customized plot composition
|
||||
|
||||
private static ArrayList<AbstractFlag> flags = new ArrayList<>();
|
||||
private final static ArrayList<AbstractFlag> flags = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Register an AbstractFlag with PlotSquared
|
||||
|
@ -10,7 +10,7 @@ public abstract class FlagValue<T> {
|
||||
private Class<T> clazz;
|
||||
|
||||
public FlagValue() {
|
||||
this.clazz = (Class<T>) this.getClass();
|
||||
this.clazz = (Class<T>) getClass();
|
||||
}
|
||||
|
||||
public FlagValue(Class<T> clazz) {
|
||||
|
@ -33,6 +33,7 @@ import org.bukkit.block.Block;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class DefaultPlotManager extends PlotManager {
|
||||
|
||||
/**
|
||||
@ -186,10 +187,7 @@ public class DefaultPlotManager extends PlotManager {
|
||||
@Override
|
||||
public boolean isInPlotAbs(final PlotWorld plotworld, final Location loc, final PlotId plotid) {
|
||||
final PlotId result = getPlotIdAbs(plotworld, loc);
|
||||
if (result == null) {
|
||||
return false;
|
||||
}
|
||||
return result == plotid;
|
||||
return result != null && result == plotid;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -40,49 +40,49 @@ public class DefaultPlotWorld extends PlotWorld {
|
||||
/**
|
||||
* Default Road Height: 64
|
||||
*/
|
||||
public static int ROAD_HEIGHT_DEFAULT = 64;
|
||||
public final static int ROAD_HEIGHT_DEFAULT = 64;
|
||||
/**
|
||||
* Default plot height: 64
|
||||
*/
|
||||
public static int PLOT_HEIGHT_DEFAULT = 64;
|
||||
public final static int PLOT_HEIGHT_DEFAULT = 64;
|
||||
/**
|
||||
* Default Wall Height: 64
|
||||
*/
|
||||
public static int WALL_HEIGHT_DEFAULT = 64;
|
||||
public final static int WALL_HEIGHT_DEFAULT = 64;
|
||||
/**
|
||||
* Default plot width: 32
|
||||
*/
|
||||
public static int PLOT_WIDTH_DEFAULT = 32;
|
||||
public final static int PLOT_WIDTH_DEFAULT = 32;
|
||||
/**
|
||||
* Default road width: 7
|
||||
*/
|
||||
public static int ROAD_WIDTH_DEFAULT = 7;
|
||||
public final static int ROAD_WIDTH_DEFAULT = 7;
|
||||
/**
|
||||
* Default main block: 1
|
||||
*/
|
||||
public static PlotBlock[] MAIN_BLOCK_DEFAULT = new PlotBlock[]{new PlotBlock((short) 1, (byte) 0)};
|
||||
public final static PlotBlock[] MAIN_BLOCK_DEFAULT = new PlotBlock[]{new PlotBlock((short) 1, (byte) 0)};
|
||||
/**
|
||||
* Default top blocks: {"2"}
|
||||
*/
|
||||
public static PlotBlock[] TOP_BLOCK_DEFAULT = new PlotBlock[]{new PlotBlock((short) 2, (byte) 0)};
|
||||
public final static PlotBlock[] TOP_BLOCK_DEFAULT = new PlotBlock[]{new PlotBlock((short) 2, (byte) 0)};
|
||||
/**
|
||||
* Default wall block: 44
|
||||
*/
|
||||
public static PlotBlock WALL_BLOCK_DEFAULT = new PlotBlock((short) 44, (byte) 0);
|
||||
public static PlotBlock CLAIMED_WALL_BLOCK_DEFAULT = new PlotBlock((short) 44, (byte) 1);
|
||||
public final static PlotBlock WALL_BLOCK_DEFAULT = new PlotBlock((short) 44, (byte) 0);
|
||||
public final static PlotBlock CLAIMED_WALL_BLOCK_DEFAULT = new PlotBlock((short) 44, (byte) 1);
|
||||
/**
|
||||
* Default wall filling: 1
|
||||
*/
|
||||
public static PlotBlock WALL_FILLING_DEFAULT = new PlotBlock((short) 1, (byte) 0);
|
||||
public final static PlotBlock WALL_FILLING_DEFAULT = new PlotBlock((short) 1, (byte) 0);
|
||||
/**
|
||||
* Default road stripes: 35
|
||||
*/
|
||||
public static PlotBlock ROAD_STRIPES_DEFAULT = new PlotBlock((short) 98, (byte) 0);
|
||||
public static boolean ROAD_STRIPES_ENABLED_DEFAULT = false;
|
||||
public final static PlotBlock ROAD_STRIPES_DEFAULT = new PlotBlock((short) 98, (byte) 0);
|
||||
public final static boolean ROAD_STRIPES_ENABLED_DEFAULT = false;
|
||||
/**
|
||||
* Default road block: 155
|
||||
*/
|
||||
public static PlotBlock ROAD_BLOCK_DEFAULT = new PlotBlock((short) 155, (byte) 0);
|
||||
public final static PlotBlock ROAD_BLOCK_DEFAULT = new PlotBlock((short) 155, (byte) 0);
|
||||
/**
|
||||
* Road Height
|
||||
*/
|
||||
|
@ -36,12 +36,14 @@ import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
* @author Citymonstret The default generator is very messy, as we have decided
|
||||
* The default generator is very messy, as we have decided
|
||||
* to try externalize all calculations from within the loop. - You will
|
||||
* see a lot of slower implementations have a single for loop. - This is
|
||||
* perfectly fine to do, it will just mean world generation may take
|
||||
* somewhat longer
|
||||
* @auther Empire92
|
||||
*
|
||||
* @author Citymonstret
|
||||
* @author Empire92
|
||||
*/
|
||||
public class WorldGenerator extends PlotGenerator {
|
||||
/**
|
||||
@ -330,7 +332,6 @@ public class WorldGenerator extends PlotGenerator {
|
||||
setCuboidRegion(16 - value, (16 - value) + 1, this.wallheight, this.wallheight + 1, start, 16, this.floor2); //
|
||||
}
|
||||
if ((roadStartZ <= 16) && (roadStartZ > 1)) {
|
||||
final int val = roadStartZ;
|
||||
int start, end;
|
||||
if ((plotMinX + 2) <= 16) {
|
||||
start = 16 - plotMinX - 1;
|
||||
@ -345,11 +346,10 @@ public class WorldGenerator extends PlotGenerator {
|
||||
if (!(((plotMinX + 2) <= 16) || ((roadStartX - 1) <= 16))) {
|
||||
start = 0;
|
||||
}
|
||||
setCuboidRegion(0, end, this.wallheight, this.wallheight + 1, (16 - val) + 1, (16 - val) + 2, this.floor2);
|
||||
setCuboidRegion(start, 16, this.wallheight, this.wallheight + 1, (16 - val) + 1, (16 - val) + 2, this.floor2);
|
||||
setCuboidRegion(0, end, this.wallheight, this.wallheight + 1, (16 - roadStartZ) + 1, (16 - roadStartZ) + 2, this.floor2);
|
||||
setCuboidRegion(start, 16, this.wallheight, this.wallheight + 1, (16 - roadStartZ) + 1, (16 - roadStartZ) + 2, this.floor2);
|
||||
}
|
||||
if ((roadStartX <= 16) && (roadStartX > 1)) {
|
||||
final int val = roadStartX;
|
||||
int start, end;
|
||||
if ((plotMinZ + 2) <= 16) {
|
||||
start = 16 - plotMinZ - 1;
|
||||
@ -364,8 +364,8 @@ public class WorldGenerator extends PlotGenerator {
|
||||
if (!(((plotMinZ + 2) <= 16) || ((roadStartZ - 1) <= 16))) {
|
||||
start = 0;
|
||||
}
|
||||
setCuboidRegion((16 - val) + 1, (16 - val) + 2, this.wallheight, this.wallheight + 1, 0, end, this.floor2); //
|
||||
setCuboidRegion((16 - val) + 1, (16 - val) + 2, this.wallheight, this.wallheight + 1, start, 16, this.floor2); //
|
||||
setCuboidRegion((16 - roadStartX) + 1, (16 - roadStartX) + 2, this.wallheight, this.wallheight + 1, 0, end, this.floor2); //
|
||||
setCuboidRegion((16 - roadStartX) + 1, (16 - roadStartX) + 2, this.wallheight, this.wallheight + 1, start, 16, this.floor2); //
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -42,24 +42,24 @@ public class XPopulator extends BlockPopulator {
|
||||
* information about how a BlockPopulator works.
|
||||
*/
|
||||
|
||||
final int plotsize;
|
||||
final int pathsize;
|
||||
final PlotBlock wall;
|
||||
final PlotBlock wallfilling;
|
||||
final PlotBlock floor1;
|
||||
final PlotBlock floor2;
|
||||
final int size;
|
||||
final int roadheight;
|
||||
final int wallheight;
|
||||
final int plotheight;
|
||||
final PlotBlock[] plotfloors;
|
||||
final PlotBlock[] filling;
|
||||
private final DefaultPlotWorld plotworld;
|
||||
int plotsize;
|
||||
int pathsize;
|
||||
PlotBlock wall;
|
||||
PlotBlock wallfilling;
|
||||
PlotBlock floor1;
|
||||
PlotBlock floor2;
|
||||
int size;
|
||||
final private double pathWidthLower;
|
||||
Biome biome;
|
||||
int roadheight;
|
||||
int wallheight;
|
||||
int plotheight;
|
||||
PlotBlock[] plotfloors;
|
||||
PlotBlock[] filling;
|
||||
private int X;
|
||||
private int Z;
|
||||
private long state;
|
||||
private double pathWidthLower;
|
||||
|
||||
public XPopulator(final PlotWorld pw) {
|
||||
this.plotworld = (DefaultPlotWorld) pw;
|
||||
|
@ -33,7 +33,7 @@ import java.util.Set;
|
||||
@SuppressWarnings({"unused", "deprecation"})
|
||||
public class EntityListener implements Listener {
|
||||
|
||||
public static HashMap<String, HashMap<Plot, HashSet<Integer>>> entityMap = new HashMap<>();
|
||||
public final static HashMap<String, HashMap<Plot, HashSet<Integer>>> entityMap = new HashMap<>();
|
||||
|
||||
public EntityListener() {
|
||||
BukkitScheduler scheduler = Bukkit.getServer().getScheduler();
|
||||
|
@ -733,19 +733,6 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onChangeWorld(final PlayerChangedWorldEvent event) {
|
||||
/*
|
||||
* if (isPlotWorld(event.getFrom()) &&
|
||||
* (Settings.PLOT_SPECIFIC_RESOURCE_PACK.length() > 1)) {
|
||||
* event.getPlayer().setResourcePack("");
|
||||
* }
|
||||
* else {
|
||||
* textures(event.getPlayer());
|
||||
* }
|
||||
*/
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void BlockCreate(final BlockPlaceEvent event) {
|
||||
final World world = event.getPlayer().getWorld();
|
||||
|
@ -50,8 +50,8 @@ import java.util.*;
|
||||
@SuppressWarnings({"deprecation", "unused"})
|
||||
public class PlotPlusListener extends PlotListener implements Listener {
|
||||
|
||||
private static HashMap<String, Interval> feedRunnable = new HashMap<>();
|
||||
private static HashMap<String, Interval> healRunnable = new HashMap<>();
|
||||
private final static HashMap<String, Interval> feedRunnable = new HashMap<>();
|
||||
private final static HashMap<String, Interval> healRunnable = new HashMap<>();
|
||||
|
||||
public static void startRunnable(final JavaPlugin plugin) {
|
||||
plugin.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
|
||||
@ -229,10 +229,10 @@ public class PlotPlusListener extends PlotListener implements Listener {
|
||||
}
|
||||
|
||||
public static class Interval {
|
||||
public int interval;
|
||||
public int amount;
|
||||
public final int interval;
|
||||
public final int amount;
|
||||
public final int max;
|
||||
public int count = 0;
|
||||
public int max;
|
||||
|
||||
public Interval(final int interval, final int amount, final int max) {
|
||||
this.interval = interval;
|
||||
@ -247,7 +247,7 @@ public class PlotPlusListener extends PlotListener implements Listener {
|
||||
* @author Citymonstret
|
||||
*/
|
||||
public static class RecordMeta {
|
||||
public static List<RecordMeta> metaList = new ArrayList<>();
|
||||
public final static List<RecordMeta> metaList = new ArrayList<>();
|
||||
|
||||
static {
|
||||
for (int x = 3; x < 12; x++) {
|
||||
|
@ -45,11 +45,11 @@ public class Plot implements Cloneable {
|
||||
/**
|
||||
* plot ID
|
||||
*/
|
||||
public PlotId id;
|
||||
public final PlotId id;
|
||||
/**
|
||||
* plot world
|
||||
*/
|
||||
public String world;
|
||||
public final String world;
|
||||
/**
|
||||
* plot owner
|
||||
*/
|
||||
@ -92,7 +92,6 @@ public class Plot implements Cloneable {
|
||||
* @param plotBiome
|
||||
* @param helpers
|
||||
* @param denied
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
@Deprecated
|
||||
@ -144,7 +143,6 @@ public class Plot implements Cloneable {
|
||||
* @param helpers
|
||||
* @param denied
|
||||
* @param merged
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
@Deprecated
|
||||
|
@ -25,8 +25,8 @@ package com.intellectualcrafters.plot.object;
|
||||
* @author Empire92
|
||||
*/
|
||||
public class PlotBlock {
|
||||
public short id;
|
||||
public byte data;
|
||||
public final short id;
|
||||
public final byte data;
|
||||
|
||||
public PlotBlock(final short id, final byte data) {
|
||||
this.id = id;
|
||||
|
@ -28,8 +28,8 @@ public enum PlotHomePosition {
|
||||
CENTER("Center", 'c'),
|
||||
DEFAULT("Default", 'd');
|
||||
|
||||
private String string;
|
||||
private char ch;
|
||||
private final String string;
|
||||
private final char ch;
|
||||
|
||||
PlotHomePosition(final String string, final char ch) {
|
||||
this.string = string;
|
||||
|
@ -26,11 +26,11 @@ public class PlotId {
|
||||
/**
|
||||
* x value
|
||||
*/
|
||||
public Integer x;
|
||||
public final Integer x;
|
||||
/**
|
||||
* y value
|
||||
*/
|
||||
public Integer y;
|
||||
public final Integer y;
|
||||
|
||||
/**
|
||||
* PlotId class (PlotId x,y values do not correspond to Block locations)
|
||||
|
@ -38,7 +38,7 @@ import java.util.HashMap;
|
||||
@SuppressWarnings("deprecation")
|
||||
public class PlotSelection {
|
||||
|
||||
public static HashMap<String, PlotSelection> currentSelection = new HashMap<>();
|
||||
public final static HashMap<String, PlotSelection> currentSelection = new HashMap<>();
|
||||
|
||||
private final PlotBlock[] plotBlocks;
|
||||
|
||||
|
@ -39,6 +39,10 @@ import java.util.Set;
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public class PlotSettings {
|
||||
/**
|
||||
* Plot
|
||||
*/
|
||||
private final Plot plot;
|
||||
/**
|
||||
* merged plots
|
||||
*/
|
||||
@ -59,10 +63,6 @@ public class PlotSettings {
|
||||
* Home Position
|
||||
*/
|
||||
private PlotHomePosition position;
|
||||
/**
|
||||
* Plot
|
||||
*/
|
||||
private Plot plot;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
|
@ -42,26 +42,27 @@ 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<>(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 final 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;
|
||||
public static Biome PLOT_BIOME_DEFAULT = Biome.FOREST;
|
||||
public static boolean PLOT_CHAT_DEFAULT = false;
|
||||
public static boolean SCHEMATIC_CLAIM_SPECIFY_DEFAULT = false;
|
||||
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<>();
|
||||
public static boolean USE_ECONOMY_DEFAULT = false;
|
||||
public static double PLOT_PRICE_DEFAULT = 100;
|
||||
public static double MERGE_PRICE_DEFAULT = 100;
|
||||
public static double SELL_PRICE_DEFAULT = 75;
|
||||
public static boolean PVP_DEFAULT = false;
|
||||
public static boolean PVE_DEFAULT = false;
|
||||
public static boolean SPAWN_EGGS_DEFAULT = false;
|
||||
public static boolean SPAWN_CUSTOM_DEFAULT = true;
|
||||
public static boolean SPAWN_BREEDING_DEFAULT = false;
|
||||
public final static boolean AUTO_MERGE_DEFAULT = false;
|
||||
public final static boolean MOB_SPAWNING_DEFAULT = false;
|
||||
public final static Biome PLOT_BIOME_DEFAULT = Biome.FOREST;
|
||||
public final static boolean PLOT_CHAT_DEFAULT = false;
|
||||
public final static boolean SCHEMATIC_CLAIM_SPECIFY_DEFAULT = false;
|
||||
public final static boolean SCHEMATIC_ON_CLAIM_DEFAULT = false;
|
||||
public final static String SCHEMATIC_FILE_DEFAULT = "null";
|
||||
public final static List<String> SCHEMATICS_DEFAULT = null;
|
||||
public final static List<String> DEFAULT_FLAGS_DEFAULT = new ArrayList<>();
|
||||
public final static boolean USE_ECONOMY_DEFAULT = false;
|
||||
public final static double PLOT_PRICE_DEFAULT = 100;
|
||||
public final static double MERGE_PRICE_DEFAULT = 100;
|
||||
public final static double SELL_PRICE_DEFAULT = 75;
|
||||
public final static boolean PVP_DEFAULT = false;
|
||||
public final static boolean PVE_DEFAULT = false;
|
||||
public final static boolean SPAWN_EGGS_DEFAULT = false;
|
||||
public final static boolean SPAWN_CUSTOM_DEFAULT = true;
|
||||
public final static boolean SPAWN_BREEDING_DEFAULT = false;
|
||||
public final String worldname;
|
||||
public boolean AUTO_MERGE;
|
||||
public boolean MOB_SPAWNING;
|
||||
public Biome PLOT_BIOME;
|
||||
@ -80,7 +81,6 @@ public abstract class PlotWorld {
|
||||
public boolean SPAWN_EGGS;
|
||||
public boolean SPAWN_CUSTOM;
|
||||
public boolean SPAWN_BREEDING;
|
||||
public String worldname;
|
||||
|
||||
public PlotWorld(final String worldname) {
|
||||
this.worldname = worldname;
|
||||
|
@ -25,7 +25,7 @@ package com.intellectualcrafters.plot.object;
|
||||
* @author Empire92
|
||||
*/
|
||||
public class StringWrapper {
|
||||
public String value;
|
||||
public final String value;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
|
@ -28,14 +28,14 @@ package com.intellectualcrafters.plot.util;
|
||||
*/
|
||||
public class Lag implements Runnable {
|
||||
|
||||
/**
|
||||
* Ticks
|
||||
*/
|
||||
public final static long[] T = new long[600];
|
||||
/**
|
||||
* Tick count
|
||||
*/
|
||||
public static int TC = 0;
|
||||
/**
|
||||
* Ticks
|
||||
*/
|
||||
public static long[] T = new long[600];
|
||||
/**
|
||||
* something :_:
|
||||
*/
|
||||
|
@ -474,9 +474,7 @@ public class Metrics {
|
||||
json.append(':');
|
||||
json.append('{');
|
||||
boolean firstGraph = true;
|
||||
final Iterator<Graph> iter = this.graphs.iterator();
|
||||
while (iter.hasNext()) {
|
||||
final Graph graph = iter.next();
|
||||
for (Graph graph : this.graphs) {
|
||||
final StringBuilder graphJson = new StringBuilder();
|
||||
graphJson.append('{');
|
||||
for (final Plotter plotter : graph.getPlotters()) {
|
||||
@ -541,9 +539,7 @@ public class Metrics {
|
||||
// Is this the first update this hour?
|
||||
if (response.equals("1") || response.contains("This is your first update this hour")) {
|
||||
synchronized (this.graphs) {
|
||||
final Iterator<Graph> iter = this.graphs.iterator();
|
||||
while (iter.hasNext()) {
|
||||
final Graph graph = iter.next();
|
||||
for (Graph graph : this.graphs) {
|
||||
for (final Plotter plotter : graph.getPlotters()) {
|
||||
plotter.reset();
|
||||
}
|
||||
|
@ -29,7 +29,6 @@ import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.PlotManager;
|
||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.ChatPaginator;
|
||||
|
||||
@ -176,7 +175,7 @@ public class PlayerFunctions {
|
||||
return plots.get(id);
|
||||
}
|
||||
}
|
||||
return new Plot(id, null, Biome.FOREST, new ArrayList<UUID>(), new ArrayList<UUID>(), world.getName());
|
||||
return new Plot(id, null, new ArrayList<UUID>(), new ArrayList<UUID>(), world.getName());
|
||||
|
||||
}
|
||||
|
||||
|
@ -26,9 +26,7 @@ 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;
|
||||
@ -49,10 +47,10 @@ import java.util.UUID;
|
||||
*/
|
||||
@SuppressWarnings({"unused", "javadoc", "deprecation"})
|
||||
public class PlotHelper {
|
||||
public final static HashMap<Plot, Integer> runners = new HashMap<>();
|
||||
public static boolean canSetFast = false;
|
||||
public static boolean canSendChunk = false;
|
||||
public static ArrayList<String> runners_p = new ArrayList<>();
|
||||
public static HashMap<Plot, Integer> runners = new HashMap<>();
|
||||
static long state = 1;
|
||||
|
||||
/**
|
||||
@ -860,6 +858,7 @@ public class PlotHelper {
|
||||
|
||||
/**
|
||||
* Retrieve the location of the default plot home position
|
||||
*
|
||||
* @param plot Plot
|
||||
* @return the location
|
||||
*/
|
||||
@ -871,7 +870,8 @@ public class PlotHelper {
|
||||
|
||||
/**
|
||||
* Get the plot home
|
||||
* @param w World
|
||||
*
|
||||
* @param w World
|
||||
* @param plot Plot Object
|
||||
* @return Plot Home Location
|
||||
* @see #getPlotHome(org.bukkit.World, com.intellectualcrafters.plot.object.PlotId)
|
||||
@ -882,8 +882,9 @@ public class PlotHelper {
|
||||
|
||||
/**
|
||||
* Refresh the plot chunks
|
||||
*
|
||||
* @param world World in which the plot is located
|
||||
* @param plot Plot Object
|
||||
* @param plot Plot Object
|
||||
*/
|
||||
public static void refreshPlotChunks(final World world, final Plot plot) {
|
||||
final int bottomX = getPlotBottomLoc(world, plot.id).getBlockX();
|
||||
@ -897,22 +898,20 @@ public class PlotHelper {
|
||||
final int maxChunkZ = (int) Math.floor((double) topZ / 16);
|
||||
|
||||
ArrayList<Chunk> chunks = new ArrayList<>();
|
||||
|
||||
|
||||
for (int x = minChunkX; x <= maxChunkX; x++) {
|
||||
for (int z = minChunkZ; z <= maxChunkZ; z++) {
|
||||
if (canSendChunk) {
|
||||
Chunk chunk = world.getChunkAt(x, z);
|
||||
chunks.add(chunk);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
world.refreshChunk(x, z);
|
||||
}
|
||||
}
|
||||
}
|
||||
try {
|
||||
SendChunk.sendChunk(chunks);
|
||||
}
|
||||
catch (Throwable e) {
|
||||
} catch (Throwable e) {
|
||||
canSendChunk = false;
|
||||
for (int x = minChunkX; x <= maxChunkX; x++) {
|
||||
for (int z = minChunkZ; z <= maxChunkZ; z++) {
|
||||
|
@ -38,7 +38,7 @@ public class PlotSquaredException extends RuntimeException {
|
||||
public static enum PlotError {
|
||||
PLOTMAIN_NULL("The PlotMain instance was null"),
|
||||
MISSING_DEPENDENCY("Missing Dependency");
|
||||
private String errorHeader;
|
||||
private final String errorHeader;
|
||||
|
||||
PlotError(final String errorHeader) {
|
||||
this.errorHeader = errorHeader;
|
||||
|
@ -426,7 +426,7 @@ public class ReflectionUtils {
|
||||
}
|
||||
|
||||
public class RefExecutor {
|
||||
Object e;
|
||||
final Object e;
|
||||
|
||||
public RefExecutor(final Object e) {
|
||||
this.e = e;
|
||||
@ -530,7 +530,7 @@ public class ReflectionUtils {
|
||||
}
|
||||
|
||||
public class RefExecutor {
|
||||
Object e;
|
||||
final Object e;
|
||||
|
||||
public RefExecutor(final Object e) {
|
||||
this.e = e;
|
||||
|
@ -1,59 +1,72 @@
|
||||
package com.intellectualcrafters.plot.util;
|
||||
|
||||
import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
|
||||
import com.intellectualcrafters.plot.util.ReflectionUtils.RefClass;
|
||||
import com.intellectualcrafters.plot.util.ReflectionUtils.RefConstructor;
|
||||
import com.intellectualcrafters.plot.util.ReflectionUtils.RefField;
|
||||
import com.intellectualcrafters.plot.util.ReflectionUtils.RefMethod;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass;
|
||||
|
||||
/**
|
||||
* An utility that can be used to send chunks, rather than
|
||||
* using bukkit code to do so (uses heavy NMS)
|
||||
*
|
||||
* @author Empire92
|
||||
*/
|
||||
public class SendChunk {
|
||||
|
||||
|
||||
// Ref Class
|
||||
private static final RefClass classWorld = getRefClass("{nms}.World");
|
||||
private static final RefClass classEntityPlayer = getRefClass("{nms}.EntityPlayer");
|
||||
private static final RefClass classChunkCoordIntPair = getRefClass("{nms}.ChunkCoordIntPair");
|
||||
private static final RefClass classCraftChunk = getRefClass("{cb}.CraftChunk");
|
||||
private static final RefClass classChunk = getRefClass("{nms}.Chunk");
|
||||
|
||||
|
||||
// Ref Method
|
||||
private static RefMethod methodGetHandle;
|
||||
|
||||
|
||||
|
||||
// Ref Field
|
||||
private static RefField chunkCoordIntPairQueue;
|
||||
private static RefField players;
|
||||
private static RefField locX;
|
||||
private static RefField locZ;
|
||||
private static RefField world;
|
||||
|
||||
|
||||
// Ref Constructor
|
||||
private static RefConstructor ChunkCoordIntPairCon;
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @throws NoSuchMethodException
|
||||
*/
|
||||
public SendChunk() throws NoSuchMethodException {
|
||||
methodGetHandle = classCraftChunk.getMethod("getHandle");
|
||||
chunkCoordIntPairQueue = classEntityPlayer.getField("chunkCoordIntPairQueue");
|
||||
|
||||
|
||||
players = classWorld.getField("players");
|
||||
locX = classEntityPlayer.getField("locX");
|
||||
locZ = classEntityPlayer.getField("locZ");
|
||||
|
||||
|
||||
world = classChunk.getField("world");
|
||||
|
||||
|
||||
ChunkCoordIntPairCon = classChunkCoordIntPair.getConstructor(int.class, int.class);
|
||||
}
|
||||
|
||||
|
||||
public static void sendChunk(ArrayList<Chunk> chunks) {
|
||||
int diffx, diffz;
|
||||
int view = Bukkit.getServer().getViewDistance() << 4;
|
||||
for (Chunk chunk : chunks) {
|
||||
final Object c = methodGetHandle.of(chunk).call();
|
||||
|
||||
|
||||
final Object w = world.of(c).get();
|
||||
final Object p = players.of(w).get();
|
||||
|
||||
|
||||
for (Object ep : (List<Object>) p) {
|
||||
int x = ((Double) locX.of(ep).get()).intValue();
|
||||
int z = ((Double) locZ.of(ep).get()).intValue();
|
||||
|
@ -68,13 +68,14 @@ public class UUIDHandler {
|
||||
*
|
||||
* @see org.bukkit.Server#getOnlineMode()
|
||||
*/
|
||||
private static boolean online = Bukkit.getServer().getOnlineMode();
|
||||
private final static boolean online = Bukkit.getServer().getOnlineMode();
|
||||
|
||||
/**
|
||||
* Map containing names and UUIDs
|
||||
*
|
||||
* @see com.google.common.collect.BiMap
|
||||
*/
|
||||
private static BiMap<StringWrapper, UUID> uuidMap = HashBiMap.create(new HashMap<StringWrapper, UUID>());
|
||||
private final static BiMap<StringWrapper, UUID> uuidMap = HashBiMap.create(new HashMap<StringWrapper, UUID>());
|
||||
|
||||
/**
|
||||
* Get the map containing all names/uuids
|
||||
|
@ -7,9 +7,9 @@ package com.intellectualsites.translation;
|
||||
*/
|
||||
public class TranslationAsset {
|
||||
|
||||
private TranslationObject trans;
|
||||
private String translated;
|
||||
private TranslationLanguage lang;
|
||||
private final TranslationObject trans;
|
||||
private final String translated;
|
||||
private final TranslationLanguage lang;
|
||||
|
||||
public TranslationAsset(TranslationObject trans, String translated, TranslationLanguage lang) {
|
||||
this.trans = trans;
|
||||
|
@ -2,9 +2,17 @@ package com.intellectualsites.translation;
|
||||
|
||||
public class TranslationLanguage {
|
||||
|
||||
private String countryCode;
|
||||
private String languageCode;
|
||||
private String friendlyName;
|
||||
public static final TranslationLanguage englishAmerican
|
||||
= (new TranslationLanguage("American English", "us", "en"));
|
||||
public static final TranslationLanguage englishBritish
|
||||
= (new TranslationLanguage("British English", "gb", "en"));
|
||||
public static final TranslationLanguage swedishSwedish
|
||||
= (new TranslationLanguage("Swedish", "sv", "se"));
|
||||
public static final TranslationLanguage russianRussian
|
||||
= (new TranslationLanguage("Russian", "ru", "ru"));
|
||||
private final String countryCode;
|
||||
private final String languageCode;
|
||||
private final String friendlyName;
|
||||
|
||||
public TranslationLanguage(String friendlyName, String countryCode, String languageCode) {
|
||||
this.friendlyName = friendlyName;
|
||||
@ -12,6 +20,14 @@ public class TranslationLanguage {
|
||||
this.languageCode = languageCode;
|
||||
}
|
||||
|
||||
public static TranslationLanguage[] values() {
|
||||
return new TranslationLanguage[]{
|
||||
englishAmerican,
|
||||
englishBritish,
|
||||
swedishSwedish
|
||||
};
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return friendlyName;
|
||||
}
|
||||
@ -29,22 +45,4 @@ public class TranslationLanguage {
|
||||
/* en_US */
|
||||
return languageCode.toLowerCase() + "_" + countryCode.toUpperCase();
|
||||
}
|
||||
|
||||
public static final TranslationLanguage englishAmerican
|
||||
= (new TranslationLanguage("American English", "us", "en"));
|
||||
public static final TranslationLanguage englishBritish
|
||||
= (new TranslationLanguage("British English", "gb", "en"));
|
||||
public static final TranslationLanguage swedishSwedish
|
||||
= (new TranslationLanguage("Swedish", "sv", "se"));
|
||||
public static final TranslationLanguage russianRussian
|
||||
= (new TranslationLanguage("Russian", "ru", "ru"));
|
||||
|
||||
|
||||
public static TranslationLanguage[] values() {
|
||||
return new TranslationLanguage[]{
|
||||
englishAmerican,
|
||||
englishBritish,
|
||||
swedishSwedish
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -13,9 +13,13 @@ import java.util.*;
|
||||
public class TranslationManager {
|
||||
|
||||
/**
|
||||
* The instance
|
||||
* Objects
|
||||
*/
|
||||
private TranslationManager instance;
|
||||
private final LinkedList<TranslationObject> translationObjects;
|
||||
/**
|
||||
* The translations
|
||||
*/
|
||||
private final LinkedHashMap<String, TranslationAsset> translatedObjects;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
@ -24,34 +28,6 @@ public class TranslationManager {
|
||||
this(new TranslationObject[]{});
|
||||
}
|
||||
|
||||
/**
|
||||
* Don't use this!
|
||||
*
|
||||
* @return this
|
||||
*/
|
||||
public TranslationManager instance() {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Objects
|
||||
*/
|
||||
private LinkedList<TranslationObject> translationObjects;
|
||||
|
||||
/**
|
||||
* The translations
|
||||
*/
|
||||
private LinkedHashMap<String, TranslationAsset> translatedObjects;
|
||||
|
||||
/**
|
||||
* Get the translation objects
|
||||
*
|
||||
* @return objects
|
||||
*/
|
||||
public List<TranslationObject> translations() {
|
||||
return translationObjects;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
@ -62,7 +38,56 @@ public class TranslationManager {
|
||||
= new LinkedList<TranslationObject>(Arrays.asList(translationObjects));
|
||||
this.translatedObjects
|
||||
= new LinkedHashMap<String, TranslationAsset>();
|
||||
instance = this;
|
||||
}
|
||||
|
||||
public static List<TranslationObject> transformEnum(Object[] os) {
|
||||
List<TranslationObject> eList = new ArrayList<TranslationObject>();
|
||||
for (Object o : os) {
|
||||
eList.add(
|
||||
new TranslationObject(o.toString(), o.toString().toLowerCase().replace("_", " "), "", "")
|
||||
);
|
||||
}
|
||||
return eList;
|
||||
}
|
||||
|
||||
public static void scan(Class c, TranslationManager manager) throws IllegalAccessException {
|
||||
Field[] fields = c.getDeclaredFields();
|
||||
Annotation annotation;
|
||||
for (Field field : fields) {
|
||||
if (field.getType() != String.class || (annotation = field.getAnnotation(Translation.class)) == null)
|
||||
continue;
|
||||
Translation t = (Translation) annotation;
|
||||
String key = field.getName();
|
||||
// Make sure we can get the value
|
||||
field.setAccessible(true);
|
||||
String defaultValue = (String) field.get(c);
|
||||
manager.addTranslationObject(
|
||||
new TranslationObject(
|
||||
key,
|
||||
defaultValue,
|
||||
t.description(),
|
||||
t.creationDescription()
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Don't use this!
|
||||
*
|
||||
* @return this
|
||||
*/
|
||||
public TranslationManager instance() {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the translation objects
|
||||
*
|
||||
* @return objects
|
||||
*/
|
||||
public List<TranslationObject> translations() {
|
||||
return translationObjects;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -149,38 +174,6 @@ public class TranslationManager {
|
||||
return instance();
|
||||
}
|
||||
|
||||
public static List<TranslationObject> transformEnum(Object[] os) {
|
||||
List<TranslationObject> eList = new ArrayList<TranslationObject>();
|
||||
for (Object o : os) {
|
||||
eList.add(
|
||||
new TranslationObject(o.toString(), o.toString().toLowerCase().replace("_", " "), "", "")
|
||||
);
|
||||
}
|
||||
return eList;
|
||||
}
|
||||
|
||||
public static void scan(Class c, TranslationManager manager) throws IllegalAccessException {
|
||||
Field[] fields = c.getDeclaredFields();
|
||||
Annotation annotation;
|
||||
for (Field field : fields) {
|
||||
if (field.getType() != String.class || (annotation = field.getAnnotation(Translation.class)) == null)
|
||||
continue;
|
||||
Translation t = (Translation) annotation;
|
||||
String key = field.getName();
|
||||
// Make sure we can get the value
|
||||
field.setAccessible(true);
|
||||
String defaultValue = (String) field.get(c);
|
||||
manager.addTranslationObject(
|
||||
new TranslationObject(
|
||||
key,
|
||||
defaultValue,
|
||||
t.description(),
|
||||
t.creationDescription()
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public TranslationManager debug(PrintStream out) {
|
||||
for (TranslationObject object : translations()) {
|
||||
out.println(object.getKey() + ":");
|
||||
|
@ -31,7 +31,6 @@ public class TranslationObject {
|
||||
}
|
||||
this.key = key.toLowerCase();
|
||||
this.defaultValue = defaultValue.replace("\n", "&-");
|
||||
;
|
||||
this.description = description;
|
||||
this.creationDescription = creationDescription;
|
||||
}
|
||||
|
@ -19,23 +19,18 @@ import java.util.Map;
|
||||
*/
|
||||
public class YamlTranslationFile extends TranslationFile {
|
||||
|
||||
private File path;
|
||||
private TranslationLanguage language;
|
||||
private String name;
|
||||
final private TranslationLanguage language;
|
||||
final private String name;
|
||||
final private TranslationManager manager;
|
||||
private File file;
|
||||
private HashMap<String, String> map;
|
||||
private String[] header;
|
||||
private boolean fancyHead = false;
|
||||
private YamlTranslationFile instance;
|
||||
private TranslationManager manager;
|
||||
|
||||
/**
|
||||
* Reload
|
||||
* YAML Object
|
||||
*/
|
||||
public void reload() {
|
||||
this.map = new HashMap<String, String>();
|
||||
this.read();
|
||||
}
|
||||
private Yaml yaml;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
@ -45,7 +40,6 @@ public class YamlTranslationFile extends TranslationFile {
|
||||
* @param name project name
|
||||
*/
|
||||
public YamlTranslationFile(File path, TranslationLanguage language, String name, TranslationManager manager) {
|
||||
this.path = path;
|
||||
this.language = language;
|
||||
this.name = name;
|
||||
this.manager = manager;
|
||||
@ -68,6 +62,14 @@ public class YamlTranslationFile extends TranslationFile {
|
||||
this.instance = this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reload
|
||||
*/
|
||||
public void reload() {
|
||||
this.map = new HashMap<String, String>();
|
||||
this.read();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the header
|
||||
*
|
||||
@ -164,11 +166,6 @@ public class YamlTranslationFile extends TranslationFile {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* YAML Object
|
||||
*/
|
||||
private Yaml yaml;
|
||||
|
||||
/**
|
||||
* Get the YAML object
|
||||
*
|
||||
|
@ -125,8 +125,8 @@ public class Test1 {
|
||||
boolean passed = false;
|
||||
try {
|
||||
Object plot = new Plot(new PlotId(0, 0), DBFunc.everyone, Biome.FOREST, new ArrayList<UUID>(), new ArrayList<UUID>(), new ArrayList<UUID>(), null, PlotHomePosition.DEFAULT, null, "testworld", new boolean[]{false, false, false, false});
|
||||
passed = plot != null;
|
||||
} catch (Throwable e) {
|
||||
passed = true;
|
||||
} catch (Throwable ignored) {
|
||||
|
||||
}
|
||||
return passed;
|
||||
@ -223,7 +223,6 @@ public class Test1 {
|
||||
plots.get("testworld").put(id,
|
||||
new Plot(id,
|
||||
DBFunc.everyone,
|
||||
Biome.FOREST,
|
||||
new ArrayList<UUID>(),
|
||||
new ArrayList<UUID>(),
|
||||
new ArrayList<UUID>(),
|
||||
|
Loading…
Reference in New Issue
Block a user