diff --git a/itemstackformat.txt b/itemstackformat.txt index e871c42d..5f2a912c 100644 --- a/itemstackformat.txt +++ b/itemstackformat.txt @@ -34,7 +34,7 @@ CustomPotionEffects: [ { - ID: byte + Id: byte Amplifier: byte Duration: int Amplifier: bool diff --git a/src/com/massivecraft/mcore5/PS.java b/src/com/massivecraft/mcore5/PS.java index 208e351c..254aa222 100644 --- a/src/com/massivecraft/mcore5/PS.java +++ b/src/com/massivecraft/mcore5/PS.java @@ -530,18 +530,18 @@ public class PS implements Cloneable // TO STRING //----------------------------------------------// - @Override - public synchronized String toString() - { - return this.getClass().getSimpleName()+MCore.gson.toJson(this); - } - - protected final transient static DecimalFormat twoDForm = new DecimalFormat("#.##"); - public List getDesc() - { - // ret.add("World "+this.worldName); - return this.getDesc("%s %s"); - } + @Override + public synchronized String toString() + { + return this.getClass().getSimpleName()+MCore.gson.toJson(this); + } + + protected final transient static DecimalFormat twoDForm = new DecimalFormat("#.##"); + public List getDesc() + { + // ret.add("World "+this.worldName); + return this.getDesc("%s %s"); + } public List getDesc(String format) { List ret = new ArrayList(); @@ -570,9 +570,9 @@ public class PS implements Cloneable } public String getShortDesc() - { - return this.getShortDesc("%s %s "); - } + { + return this.getShortDesc("%s %s "); + } public String getShortDesc(String format) { List ret = new ArrayList(); diff --git a/src/com/massivecraft/mcore5/Permission.java b/src/com/massivecraft/mcore5/Permission.java index 4c2ac9db..50fc3b94 100644 --- a/src/com/massivecraft/mcore5/Permission.java +++ b/src/com/massivecraft/mcore5/Permission.java @@ -28,7 +28,7 @@ public enum Permission Permission(final String permissionNode) { this.node = "mcore."+permissionNode; - } + } public boolean has(CommandSender sender, boolean informSenderIfNot) { diff --git a/src/com/massivecraft/mcore5/adapter/ItemStackAdapterV2.java b/src/com/massivecraft/mcore5/adapter/ItemStackAdapterV2.java index 9219465d..633abd78 100644 --- a/src/com/massivecraft/mcore5/adapter/ItemStackAdapterV2.java +++ b/src/com/massivecraft/mcore5/adapter/ItemStackAdapterV2.java @@ -47,42 +47,42 @@ public class ItemStackAdapterV2 implements JsonDeserializer, JsonSeri public static final String DAMAGE = "damage"; public static final String NAME = "name"; - public static final String LORE = "lore"; - - public static final String ENCHANTS = "enchants"; - - public static final String REPAIRCOST = "repaircost"; - - public static final String BOOK_TITLE = "title"; - public static final String BOOK_AUTHOR = "author"; - public static final String BOOK_PAGES = "pages"; - - public static final String LEATHER_ARMOR_COLOR = "color"; - - public static final String MAP_SCALING = "scaling"; - - public static final String SKULL_OWNER = "skull"; - - public static final String POTION_EFFECTS = "effects"; - + public static final String LORE = "lore"; + + public static final String ENCHANTS = "enchants"; + + public static final String REPAIRCOST = "repaircost"; + + public static final String BOOK_TITLE = "title"; + public static final String BOOK_AUTHOR = "author"; + public static final String BOOK_PAGES = "pages"; + + public static final String LEATHER_ARMOR_COLOR = "color"; + + public static final String MAP_SCALING = "scaling"; + + public static final String SKULL_OWNER = "skull"; + + public static final String POTION_EFFECTS = "effects"; + // -------------------------------------------- // // OTHER CONSTANTS // -------------------------------------------- // - - public static final int DEFAULT_ID; - public static final int DEFAULT_COUNT; - public static final int DEFAULT_DAMAGE; - - // TODO: Awaiting https://bukkit.atlassian.net/browse/BUKKIT-3203 - static final Color DEFAULT_LEATHER_COLOR = Color.fromRGB(0xA06540); - - static - { - ItemStack stack = createItemStack(); - DEFAULT_ID = stack.getTypeId(); - DEFAULT_COUNT = stack.getAmount(); - DEFAULT_DAMAGE = stack.getDurability(); - } + + public static final int DEFAULT_ID; + public static final int DEFAULT_COUNT; + public static final int DEFAULT_DAMAGE; + + // TODO: Awaiting https://bukkit.atlassian.net/browse/BUKKIT-3203 + static final Color DEFAULT_LEATHER_COLOR = Color.fromRGB(0xA06540); + + static + { + ItemStack stack = createItemStack(); + DEFAULT_ID = stack.getTypeId(); + DEFAULT_COUNT = stack.getAmount(); + DEFAULT_DAMAGE = stack.getDurability(); + } // -------------------------------------------- // // GSON INTERFACE IMPLEMENTATION @@ -286,7 +286,7 @@ public class ItemStackAdapterV2 implements JsonDeserializer, JsonSeri if (meta2json) { if ( ! meta.hasLore()) return; - json.add(LORE, fromStringCollection(meta.getLore())); + json.add(LORE, fromStringCollection(meta.getLore())); } else { @@ -306,13 +306,13 @@ public class ItemStackAdapterV2 implements JsonDeserializer, JsonSeri { if ( ! meta.hasEnchants()) return; - JsonObject enchants = new JsonObject(); - for (Entry entry : meta.getEnchants().entrySet()) - { - enchants.addProperty(String.valueOf(entry.getKey().getId()), entry.getValue()); - } - - json.add(ENCHANTS, enchants); + JsonObject enchants = new JsonObject(); + for (Entry entry : meta.getEnchants().entrySet()) + { + enchants.addProperty(String.valueOf(entry.getKey().getId()), entry.getValue()); + } + + json.add(ENCHANTS, enchants); } else { @@ -342,7 +342,7 @@ public class ItemStackAdapterV2 implements JsonDeserializer, JsonSeri if (meta2json) { if ( ! repairable.hasRepairCost()) return; - json.addProperty(REPAIRCOST, repairable.getRepairCost()); + json.addProperty(REPAIRCOST, repairable.getRepairCost()); } else { @@ -528,11 +528,11 @@ public class ItemStackAdapterV2 implements JsonDeserializer, JsonSeri public static JsonArray fromStringCollection(Collection strings) { JsonArray ret = new JsonArray(); - for (String string : strings) - { - ret.add(new JsonPrimitive(string)); - } - return ret; + for (String string : strings) + { + ret.add(new JsonPrimitive(string)); + } + return ret; } public static List toStringCollection(JsonElement json) @@ -546,8 +546,8 @@ public class ItemStackAdapterV2 implements JsonDeserializer, JsonSeri JsonElement element = iter.next(); ret.add(element.getAsString()); } - - return ret; + + return ret; } // -------------------------------------------- // diff --git a/src/com/massivecraft/mcore5/cmd/BukkitGlueCommand.java b/src/com/massivecraft/mcore5/cmd/BukkitGlueCommand.java index e41548b3..8e472c49 100644 --- a/src/com/massivecraft/mcore5/cmd/BukkitGlueCommand.java +++ b/src/com/massivecraft/mcore5/cmd/BukkitGlueCommand.java @@ -19,8 +19,8 @@ public class BukkitGlueCommand extends Command { if ( ! mcommand.p().isEnabled()) { - return false; - } + return false; + } this.mcommand.execute(sender, Txt.tokenizeArguments(Txt.implode(args, " "))); return true; diff --git a/src/com/massivecraft/mcore5/store/ExamineThread.java b/src/com/massivecraft/mcore5/store/ExamineThread.java index 870fb6fd..a411991c 100644 --- a/src/com/massivecraft/mcore5/store/ExamineThread.java +++ b/src/com/massivecraft/mcore5/store/ExamineThread.java @@ -32,7 +32,7 @@ public class ExamineThread extends Thread catch (InterruptedException e) { // We've been interrupted. Lets bail. - return; + return; } catch (Exception e) { diff --git a/src/com/massivecraft/mcore5/store/ModificationState.java b/src/com/massivecraft/mcore5/store/ModificationState.java index 90b12543..5a50883f 100644 --- a/src/com/massivecraft/mcore5/store/ModificationState.java +++ b/src/com/massivecraft/mcore5/store/ModificationState.java @@ -2,14 +2,14 @@ package com.massivecraft.mcore5.store; public enum ModificationState { - LOCAL_ALTER (true, true), + LOCAL_ALTER (true, true), LOCAL_ATTACH (true, true), LOCAL_DETACH (true, true), REMOTE_ALTER (true, false), REMOTE_ATTACH (true, false), REMOTE_DETACH (true, false), - NONE (false, false), - UNKNOWN (false, false), + NONE (false, false), + UNKNOWN (false, false), ; private final boolean modified; diff --git a/src/com/massivecraft/mcore5/store/idstrategy/IdStrategyAiMongo.java b/src/com/massivecraft/mcore5/store/idstrategy/IdStrategyAiMongo.java index 377c65b2..7607181e 100644 --- a/src/com/massivecraft/mcore5/store/idstrategy/IdStrategyAiMongo.java +++ b/src/com/massivecraft/mcore5/store/idstrategy/IdStrategyAiMongo.java @@ -44,15 +44,15 @@ public class IdStrategyAiMongo extends IdStrategyAbstract // this object represents your "query", its analogous to a WHERE clause in SQL DBObject query = new BasicDBObject(); - query.put("_id", sequenseName); // where _id = the input sequence name + query.put("_id", sequenseName); // where _id = the input sequence name - // this object represents the "update" or the SET blah=blah in SQL - DBObject change = new BasicDBObject(this.sequenseField, 1); - DBObject update = new BasicDBObject("$inc", change); // the $inc here is a mongodb command for increment + // this object represents the "update" or the SET blah=blah in SQL + DBObject change = new BasicDBObject(this.sequenseField, 1); + DBObject update = new BasicDBObject("$inc", change); // the $inc here is a mongodb command for increment - // Atomically updates the sequence field and returns the value for you - DBObject res = sequenseCollection.findAndModify(query, new BasicDBObject(), new BasicDBObject(), false, update, true, true); - return res.get(this.sequenseField).toString(); + // Atomically updates the sequence field and returns the value for you + DBObject res = sequenseCollection.findAndModify(query, new BasicDBObject(), new BasicDBObject(), false, update, true, true); + return res.get(this.sequenseField).toString(); } // -------------------------------------------- // diff --git a/src/com/massivecraft/mcore5/util/BiomeUtil.java b/src/com/massivecraft/mcore5/util/BiomeUtil.java index dcf19a39..39ca447f 100644 --- a/src/com/massivecraft/mcore5/util/BiomeUtil.java +++ b/src/com/massivecraft/mcore5/util/BiomeUtil.java @@ -44,14 +44,14 @@ public class BiomeUtil WorldServer worldServer = craftWorld.getHandle(); BiomeBase bb = BiomeBase.biomes[id]; - if (craftWorld.loadChunk(x >> 4, z >> 4, false)) { - Chunk chunk = worldServer.getChunkAtWorldCoords(x, z); + if (craftWorld.loadChunk(x >> 4, z >> 4, false)) { + Chunk chunk = worldServer.getChunkAtWorldCoords(x, z); - if (chunk != null) { - byte[] biomevals = chunk.m(); - biomevals[((z & 0xF) << 4) | (x & 0xF)] = (byte)bb.id; - } - } + if (chunk != null) { + byte[] biomevals = chunk.m(); + biomevals[((z & 0xF) << 4) | (x & 0xF)] = (byte)bb.id; + } + } } public static int getBiomeIdAt(World world, int x, int z) diff --git a/src/com/massivecraft/mcore5/util/ClassResolveUtil.java b/src/com/massivecraft/mcore5/util/ClassResolveUtil.java index e03321df..a6ece16a 100644 --- a/src/com/massivecraft/mcore5/util/ClassResolveUtil.java +++ b/src/com/massivecraft/mcore5/util/ClassResolveUtil.java @@ -45,13 +45,13 @@ public class ClassResolveUtil ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); - try - { - return classLoader.loadClass(className); - } - catch (ClassNotFoundException e) - { - return Class.forName(className, false, classLoader); - } + try + { + return classLoader.loadClass(className); + } + catch (ClassNotFoundException e) + { + return Class.forName(className, false, classLoader); + } } } diff --git a/src/com/massivecraft/mcore5/util/EventUtil.java b/src/com/massivecraft/mcore5/util/EventUtil.java index 811e65eb..733182ab 100644 --- a/src/com/massivecraft/mcore5/util/EventUtil.java +++ b/src/com/massivecraft/mcore5/util/EventUtil.java @@ -36,50 +36,50 @@ public class EventUtil public static void callEventAt(Event event, EventPriority priority) { HandlerList handlers = event.getHandlers(); - RegisteredListener[] listeners = handlers.getRegisteredListeners().clone(); + RegisteredListener[] listeners = handlers.getRegisteredListeners().clone(); - for (RegisteredListener registration : listeners) - { - try + for (RegisteredListener registration : listeners) + { + try { - EventPriority thisPriority = (EventPriority) fieldRegisteredListenerDotPriority.get(registration); - if (thisPriority != priority) continue; + EventPriority thisPriority = (EventPriority) fieldRegisteredListenerDotPriority.get(registration); + if (thisPriority != priority) continue; } catch (Exception e) { e.printStackTrace(); continue; } - fireEventRegistration(event, registration); - } + fireEventRegistration(event, registration); + } } public static void callEventAfter(Event event, Listener listener, EventPriority priority) { HandlerList handlers = event.getHandlers(); - RegisteredListener[] listeners = handlers.getRegisteredListeners().clone(); + RegisteredListener[] listeners = handlers.getRegisteredListeners().clone(); - boolean run = false; - for (RegisteredListener registration : listeners) - { - if (run) - { - fireEventRegistration(event, registration); - } - else - { - try - { - EventPriority thisPriority = (EventPriority) fieldRegisteredListenerDotPriority.get(registration); - Listener thisListener = (Listener) fieldRegisteredListenerDotListener.get(registration); - if (thisListener == listener && thisPriority == priority) run = true; - } - catch (Exception e) - { - e.printStackTrace(); - } - } - } + boolean run = false; + for (RegisteredListener registration : listeners) + { + if (run) + { + fireEventRegistration(event, registration); + } + else + { + try + { + EventPriority thisPriority = (EventPriority) fieldRegisteredListenerDotPriority.get(registration); + Listener thisListener = (Listener) fieldRegisteredListenerDotListener.get(registration); + if (thisListener == listener && thisPriority == priority) run = true; + } + catch (Exception e) + { + e.printStackTrace(); + } + } + } } /** diff --git a/src/com/massivecraft/mcore5/util/LightUtil.java b/src/com/massivecraft/mcore5/util/LightUtil.java index cfd9b6a0..5ad29326 100644 --- a/src/com/massivecraft/mcore5/util/LightUtil.java +++ b/src/com/massivecraft/mcore5/util/LightUtil.java @@ -12,17 +12,17 @@ public class LightUtil // RECALC LIGHT LEVEL AT // -------------------------------------------- // // This method will update the light level for the block. - // It will however only work properly if all chunks that are around the chunk the block is in are loaded. + // It will however only work properly if all chunks that are around the chunk the block is in are loaded. - public static void recalcLightLevelAt(Block block) - { - recalcLightLevelAt(block.getWorld(), block.getX(), block.getY(), block.getZ()); - } - - public static void recalcLightLevelAt(World world, int x, int y, int z) - { - CraftWorld cworld = (CraftWorld)world; - WorldServer worldServer = cworld.getHandle(); - worldServer.z(x, y, z); - } + public static void recalcLightLevelAt(Block block) + { + recalcLightLevelAt(block.getWorld(), block.getX(), block.getY(), block.getZ()); + } + + public static void recalcLightLevelAt(World world, int x, int y, int z) + { + CraftWorld cworld = (CraftWorld)world; + WorldServer worldServer = cworld.getHandle(); + worldServer.z(x, y, z); + } } diff --git a/src/com/massivecraft/mcore5/util/MUtil.java b/src/com/massivecraft/mcore5/util/MUtil.java index bb62689f..56c488f2 100644 --- a/src/com/massivecraft/mcore5/util/MUtil.java +++ b/src/com/massivecraft/mcore5/util/MUtil.java @@ -203,16 +203,16 @@ public class MUtil //http://stackoverflow.com/questions/2864840/treemap-sort-by-value /*public static > SortedSet> entriesSortedByValues(Map map) { - SortedSet> sortedEntries = new TreeSet>( - new Comparator>() { - @Override public int compare(Map.Entry e1, Map.Entry e2) { - int res = e1.getValue().compareTo(e2.getValue()); - return res != 0 ? res : 1; // Special fix to preserve items with equal values - } - } - ); - sortedEntries.addAll(map.entrySet()); - return sortedEntries; + SortedSet> sortedEntries = new TreeSet>( + new Comparator>() { + @Override public int compare(Map.Entry e1, Map.Entry e2) { + int res = e1.getValue().compareTo(e2.getValue()); + return res != 0 ? res : 1; // Special fix to preserve items with equal values + } + } + ); + sortedEntries.addAll(map.entrySet()); + return sortedEntries; }*/ // http://stackoverflow.com/questions/2864840/treemap-sort-by-value diff --git a/src/com/massivecraft/mcore5/util/Perm.java b/src/com/massivecraft/mcore5/util/Perm.java index b7fb6ec5..fe41b6e3 100644 --- a/src/com/massivecraft/mcore5/util/Perm.java +++ b/src/com/massivecraft/mcore5/util/Perm.java @@ -89,43 +89,43 @@ public class Perm // GET CREATIVE // -------------------------------------------- // - public static Permission getCreative(String name) - { - return getCreative(name, null, null, null); - } + public static Permission getCreative(String name) + { + return getCreative(name, null, null, null); + } - public static Permission getCreative(String name, String description) - { - return getCreative(name, description, null, null); - } + public static Permission getCreative(String name, String description) + { + return getCreative(name, description, null, null); + } - public static Permission getCreative(String name, PermissionDefault defaultValue) - { - return getCreative(name, null, defaultValue, null); - } + public static Permission getCreative(String name, PermissionDefault defaultValue) + { + return getCreative(name, null, defaultValue, null); + } - public static Permission getCreative(String name, String description, PermissionDefault defaultValue) - { - return getCreative(name, description, defaultValue, null); - } + public static Permission getCreative(String name, String description, PermissionDefault defaultValue) + { + return getCreative(name, description, defaultValue, null); + } - public static Permission getCreative(String name, Map children) - { - return getCreative(name, null, null, children); - } + public static Permission getCreative(String name, Map children) + { + return getCreative(name, null, null, children); + } - public static Permission getCreative(String name, String description, Map children) - { - return getCreative(name, description, null, children); - } + public static Permission getCreative(String name, String description, Map children) + { + return getCreative(name, description, null, children); + } - public static Permission getCreative(String name, PermissionDefault defaultValue, Map children) - { - return getCreative(name, null, defaultValue, children); - } + public static Permission getCreative(String name, PermissionDefault defaultValue, Map children) + { + return getCreative(name, null, defaultValue, children); + } - public static Permission getCreative(String name, String description, PermissionDefault defaultValue, Map children) - { + public static Permission getCreative(String name, String description, PermissionDefault defaultValue, Map children) + { Permission ret = Bukkit.getPluginManager().getPermission(name); if (ret == null) { @@ -133,5 +133,5 @@ public class Perm Bukkit.getPluginManager().addPermission(ret); } return ret; - } + } } diff --git a/src/com/massivecraft/mcore5/util/SmokeUtil.java b/src/com/massivecraft/mcore5/util/SmokeUtil.java index a59f9f92..e8eabdd3 100644 --- a/src/com/massivecraft/mcore5/util/SmokeUtil.java +++ b/src/com/massivecraft/mcore5/util/SmokeUtil.java @@ -19,16 +19,16 @@ import org.bukkit.craftbukkit.v1_4_5.CraftWorld; // ----------------------------- // Smoke Directions // ----------------------------- -// Direction ID Direction -// 0 South - East -// 1 South -// 2 South - West -// 3 East -// 4 (Up or middle ?) -// 5 West -// 6 North - East -// 7 North -// 8 North - West +// Direction ID Direction +// 0 South - East +// 1 South +// 2 South - West +// 3 East +// 4 (Up or middle ?) +// 5 West +// 6 North - East +// 7 North +// 8 North - West //----------------------------- public class SmokeUtil @@ -98,13 +98,13 @@ public class SmokeUtil } public static void fakeExplosion(Location location, int viewDistance) - { - List chunkPositions = new ArrayList(); - Packet60Explosion packet = new Packet60Explosion(location.getX(),location.getY(), location.getZ(), 0.1f, chunkPositions, null); - CraftServer craftServer = (CraftServer) Bukkit.getServer(); - MinecraftServer minecraftServer = craftServer.getServer(); - minecraftServer.getServerConfigurationManager().sendPacketNearby(location.getX(), location.getY(), location.getZ(), viewDistance, ((CraftWorld)location.getWorld()).getHandle().dimension, packet); - } + { + List chunkPositions = new ArrayList(); + Packet60Explosion packet = new Packet60Explosion(location.getX(),location.getY(), location.getZ(), 0.1f, chunkPositions, null); + CraftServer craftServer = (CraftServer) Bukkit.getServer(); + MinecraftServer minecraftServer = craftServer.getServer(); + minecraftServer.getServerConfigurationManager().sendPacketNearby(location.getX(), location.getY(), location.getZ(), viewDistance, ((CraftWorld)location.getWorld()).getHandle().dimension, packet); + } // -------------------------------------------- // // Attach continuous effects to or locations diff --git a/src/com/massivecraft/mcore5/util/Txt.java b/src/com/massivecraft/mcore5/util/Txt.java index b8202aed..6ccb9aba 100644 --- a/src/com/massivecraft/mcore5/util/Txt.java +++ b/src/com/massivecraft/mcore5/util/Txt.java @@ -19,12 +19,12 @@ public class Txt public static final Pattern parsePattern; public static final long millisPerSecond = 1000; - public static final long millisPerMinute = 60 * millisPerSecond; - public static final long millisPerHour = 60 * millisPerMinute; - public static final long millisPerDay = 24 * millisPerHour; - public static final long millisPerWeek = 7 * millisPerDay; - public static final long millisPerMonth = 31 * millisPerDay; - public static final long millisPerYear = 365 * millisPerDay; + public static final long millisPerMinute = 60 * millisPerSecond; + public static final long millisPerHour = 60 * millisPerMinute; + public static final long millisPerDay = 24 * millisPerHour; + public static final long millisPerWeek = 7 * millisPerDay; + public static final long millisPerMonth = 31 * millisPerDay; + public static final long millisPerYear = 365 * millisPerDay; public static final Set vowel = MUtil.set( "A", "E", "I", "O", "U", "Y", "Å", "Ä", "Ö", @@ -210,32 +210,32 @@ public class Txt public static String repeat(String string, int times) { - if (times <= 0) return ""; - else return string + repeat(string, times-1); + if (times <= 0) return ""; + else return string + repeat(string, times-1); } public static String implode(final Object[] list, final String glue, final String format) { - StringBuilder ret = new StringBuilder(); - for (int i=0; i objects, final String format, final String comma, final String and, final String dot) { - if (objects.size() == 0) return ""; + if (objects.size() == 0) return ""; if (objects.size() == 1) { return implode(objects, comma, format); @@ -285,11 +285,11 @@ public class Txt } public static String implodeCommaAndDot(final Collection objects, final String color) { - return implodeCommaAndDot(objects, color+", ", color+" and ", color+"."); + return implodeCommaAndDot(objects, color+", ", color+" and ", color+"."); } public static String implodeCommaAnd(final Collection objects, final String color) { - return implodeCommaAndDot(objects, color+", ", color+" and ", ""); + return implodeCommaAndDot(objects, color+", ", color+" and ", ""); } public static String implodeCommaAndDot(final Collection objects) {