diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/Plot.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/Plot.java index dbc7a0785..7a3126e7e 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/Plot.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/Plot.java @@ -37,6 +37,7 @@ import java.util.UUID; * The plot class * * @author Citymonstret + * @author Empire92 */ @SuppressWarnings("javadoc") public class Plot implements Cloneable { @@ -91,7 +92,11 @@ public class Plot implements Cloneable { * @param plotBiome * @param helpers * @param denied + * + * @deprecated */ + @Deprecated + @SuppressWarnings("unused") public Plot(final PlotId id, final UUID owner, final Biome plotBiome, final ArrayList helpers, final ArrayList denied, final String world) { this.id = id; this.settings = new PlotSettings(this); @@ -107,6 +112,29 @@ public class Plot implements Cloneable { this.world = world; } + /** + * Primary constructor + * + * @param id + * @param owner + * @param helpers + * @param denied + */ + public Plot(final PlotId id, final UUID owner, final ArrayList helpers, final ArrayList denied, final String world) { + this.id = id; + this.settings = new PlotSettings(this); + this.owner = owner; + this.deny_entry = this.owner == null; + this.helpers = helpers; + this.denied = denied; + this.trusted = new ArrayList<>(); + this.settings.setAlias(""); + this.settings.setPosition(PlotHomePosition.DEFAULT); + this.delete = false; + this.settings.setFlags(new Flag[0]); + this.world = world; + } + /** * Constructor for saved plots * @@ -116,7 +144,11 @@ public class Plot implements Cloneable { * @param helpers * @param denied * @param merged + * + * @deprecated */ + @Deprecated + @SuppressWarnings("unused") public Plot(final PlotId id, final UUID owner, final Biome plotBiome, final ArrayList helpers, final ArrayList trusted, final ArrayList denied, final String alias, final PlotHomePosition position, final Flag[] flags, final String world, final boolean[] merged) { this.id = id; this.settings = new PlotSettings(this); @@ -137,6 +169,35 @@ public class Plot implements Cloneable { this.world = world; } + /** + * Constructor for saved plots + * + * @param id + * @param owner + * @param helpers + * @param denied + * @param merged + */ + public Plot(final PlotId id, final UUID owner, final ArrayList helpers, final ArrayList trusted, final ArrayList denied, final String alias, final PlotHomePosition position, final Flag[] flags, final String world, final boolean[] merged) { + this.id = id; + this.settings = new PlotSettings(this); + this.owner = owner; + this.deny_entry = this.owner != null; + this.trusted = trusted; + this.helpers = helpers; + this.denied = denied; + this.settings.setAlias(alias); + this.settings.setPosition(position); + this.settings.setMerged(merged); + this.delete = false; + if (flags != null) { + this.settings.setFlags(flags); + } else { + this.settings.setFlags(new Flag[0]); + } + this.world = world; + } + /** * Check if the plot has a set owner * @@ -205,7 +266,7 @@ public class Plot implements Cloneable { public Object clone() throws CloneNotSupportedException { Plot p = (Plot) super.clone(); if (!p.equals(this) || p != this) { - return new Plot(id, owner, settings.getBiome(), helpers, trusted, denied, settings.getAlias(), settings.getPosition(), settings.getFlags().toArray(new Flag[settings.getFlags().size()]), getWorld().getName(), settings.getMerged()); + return new Plot(id, owner, helpers, trusted, denied, settings.getAlias(), settings.getPosition(), settings.getFlags().toArray(new Flag[settings.getFlags().size()]), getWorld().getName(), settings.getMerged()); } return p; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotBlock.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotBlock.java index 6e0a3904e..363065d6c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotBlock.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotBlock.java @@ -21,6 +21,9 @@ package com.intellectualcrafters.plot.object; +/** + * @author Empire92 + */ public class PlotBlock { public short id; public byte data; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotComment.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotComment.java index 2de692e78..1472435bb 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotComment.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotComment.java @@ -21,6 +21,9 @@ package com.intellectualcrafters.plot.object; +/** + * @author Empire92 + */ public class PlotComment { public final String comment; public final int tier; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotHomePosition.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotHomePosition.java index e600aed7a..47de42939 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotHomePosition.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotHomePosition.java @@ -22,7 +22,7 @@ package com.intellectualcrafters.plot.object; /** - * Created by Citymonstret on 2014-08-05. + * @author Citymonstret */ public enum PlotHomePosition { CENTER("Center", 'c'), @@ -37,13 +37,7 @@ public enum PlotHomePosition { } public boolean isMatching(final String string) { - if ((string.length() < 2) && (string.charAt(0) == this.ch)) { - return true; - } - if (string.equalsIgnoreCase(this.string)) { - return true; - } - return false; + return (string.length() < 2) && (string.charAt(0) == this.ch) || string.equalsIgnoreCase(this.string); } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotSettings.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotSettings.java index d0a207cd3..0c1af3d41 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotSettings.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotSettings.java @@ -23,6 +23,7 @@ package com.intellectualcrafters.plot.object; import com.intellectualcrafters.plot.flag.Flag; import com.intellectualcrafters.plot.util.PlotHelper; +import com.sun.istack.internal.NotNull; import org.bukkit.block.Biome; import java.util.ArrayList; @@ -36,6 +37,7 @@ import java.util.Set; * @author Citymonstret * @author Empire92 */ +@SuppressWarnings("unused") public class PlotSettings { /** * merged plots @@ -133,15 +135,19 @@ public class PlotSettings { } /** - * @param flags + * Set multiple flags + * + * @param flags Flag Array */ - public void setFlags(final Flag[] flags) { - this.flags = new HashSet(Arrays.asList(flags)); + public void setFlags(@NotNull final Flag[] flags) { + this.flags = new HashSet<>(Arrays.asList(flags)); } /** - * @param flag - * @return + * Get a flag + * + * @param flag Flag to get + * @return flag */ public Flag getFlag(final String flag) { for (final Flag myflag : this.flags) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotWorld.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotWorld.java index 103cbf946..6bd58a650 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotWorld.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotWorld.java @@ -42,7 +42,7 @@ public abstract class PlotWorld { // TODO make this configurable // make non static and static_default_valu + add config option @SuppressWarnings("deprecation") - public static ArrayList 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 static ArrayList BLOCKS = new ArrayList<>(Arrays.asList(new Material[]{ACACIA_STAIRS, BEACON, BEDROCK, BIRCH_WOOD_STAIRS, BOOKSHELF, BREWING_STAND, BRICK, BRICK_STAIRS, BURNING_FURNACE, CAKE_BLOCK, CAULDRON, CLAY_BRICK, CLAY, COAL_BLOCK, COAL_ORE, COBBLE_WALL, COBBLESTONE, COBBLESTONE_STAIRS, COMMAND, DARK_OAK_STAIRS, DAYLIGHT_DETECTOR, DIAMOND_ORE, DIAMOND_BLOCK, DIRT, DISPENSER, DROPPER, EMERALD_BLOCK, EMERALD_ORE, ENCHANTMENT_TABLE, ENDER_PORTAL_FRAME, ENDER_STONE, FURNACE, GLOWSTONE, GOLD_ORE, GOLD_BLOCK, GRASS, GRAVEL, GLASS, HARD_CLAY, HAY_BLOCK, HUGE_MUSHROOM_1, HUGE_MUSHROOM_2, IRON_BLOCK, IRON_ORE, JACK_O_LANTERN, JUKEBOX, JUNGLE_WOOD_STAIRS, LAPIS_BLOCK, LAPIS_ORE, LEAVES, LEAVES_2, LOG, LOG_2, MELON_BLOCK, MOB_SPAWNER, MOSSY_COBBLESTONE, MYCEL, NETHER_BRICK, NETHER_BRICK_STAIRS, NETHERRACK, NOTE_BLOCK, OBSIDIAN, PACKED_ICE, PUMPKIN, QUARTZ_BLOCK, QUARTZ_ORE, QUARTZ_STAIRS, REDSTONE_BLOCK, SANDSTONE, SAND, SANDSTONE_STAIRS, SMOOTH_BRICK, SMOOTH_STAIRS, SNOW_BLOCK, SOUL_SAND, SPONGE, SPRUCE_WOOD_STAIRS, STONE, WOOD, WOOD_STAIRS, WORKBENCH, WOOL, getMaterial(44), getMaterial(126)})); public static boolean AUTO_MERGE_DEFAULT = false; public static boolean MOB_SPAWNING_DEFAULT = false; @@ -52,7 +52,7 @@ public abstract class PlotWorld { public static boolean SCHEMATIC_ON_CLAIM_DEFAULT = false; public static String SCHEMATIC_FILE_DEFAULT = "null"; public static List SCHEMATICS_DEFAULT = null; - public static List DEFAULT_FLAGS_DEFAULT = new ArrayList(); + public static List DEFAULT_FLAGS_DEFAULT = new ArrayList<>(); public static boolean USE_ECONOMY_DEFAULT = false; public static double PLOT_PRICE_DEFAULT = 100; public static double MERGE_PRICE_DEFAULT = 100; @@ -89,7 +89,7 @@ public abstract class PlotWorld { /** * When a world is created, the following method will be called for each * - * @param config + * @param config Configuration Section */ public void loadDefaultConfiguration(final ConfigurationSection config) { this.MOB_SPAWNING = config.getBoolean("natural_mob_spawning"); @@ -118,10 +118,10 @@ public abstract class PlotWorld { /** * Saving core plotworld settings * - * @param config + * @param config Configuration Section */ public void saveConfiguration(final ConfigurationSection config) { - final HashMap options = new HashMap(); + final HashMap options = new HashMap<>(); options.put("natural_mob_spawning", PlotWorld.MOB_SPAWNING_DEFAULT); options.put("plot.auto_merge", PlotWorld.AUTO_MERGE_DEFAULT); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/Title.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/Title.java index 14011de67..f3881123f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/Title.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/Title.java @@ -43,6 +43,7 @@ public class Title { static { CORRESPONDING_TYPES = new HashMap<>(); } + /* Title packet */ private Class packetTitle; /* Title packet actions ENUM */ @@ -50,7 +51,7 @@ public class Title { /* Chat serializer */ private Class nmsChatSerializer; /* Title text and color */ - private String title = ""; + private String title; private ChatColor titleColor = ChatColor.WHITE; /* Subtitle text and color */ private String subtitle = ""; @@ -78,6 +79,7 @@ public class Title { * @param subtitle Subtitle text */ public Title(final String title, final String subtitle) { + this.title = ""; this.title = title; this.subtitle = subtitle; loadClasses(); @@ -93,6 +95,7 @@ public class Title { * @param fadeOutTime Fade out time */ public Title(final String title, final String subtitle, final int fadeInTime, final int stayTime, final int fadeOutTime) { + this.title = ""; this.title = title; this.subtitle = subtitle; this.fadeInTime = fadeInTime; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/LSetCube.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/LSetCube.java index 78f861bea..8ae392e45 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/LSetCube.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/LSetCube.java @@ -28,6 +28,7 @@ import org.bukkit.Location; * * @author Citymonstret */ +@SuppressWarnings({"javadoc", "unused"}) public class LSetCube { /** diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PWE.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PWE.java index 6bdac9b9a..b663f391f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PWE.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PWE.java @@ -98,6 +98,7 @@ public class PWE { return s.getMask() == null; } + @SuppressWarnings("deprecation") public static void setNoMask(final Player p) { try { LocalSession s; @@ -110,7 +111,7 @@ public class PWE { final Vector p1 = new Vector(69, 69, 69), p2 = new Vector(69, 69, 69); s.setMask(new RegionMask(new CuboidRegion(plr.getWorld(), p1, p2))); } catch (final Exception e) { - + // } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlotHelper.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlotHelper.java index 94229e43a..c12637607 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlotHelper.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlotHelper.java @@ -45,10 +45,11 @@ import java.util.UUID; * * @author Citymonstret */ +@SuppressWarnings({"unused", "javadoc", "deprecation"}) public class PlotHelper { public static boolean canSetFast = false; - public static ArrayList runners_p = new ArrayList(); - public static HashMap runners = new HashMap(); + public static ArrayList runners_p = new ArrayList<>(); + public static HashMap runners = new HashMap<>(); static long state = 1; /** @@ -190,7 +191,7 @@ public class PlotHelper { final PlotManager manager = PlotMain.getPlotManager(world); final PlotWorld plotworld = PlotMain.getWorldSettings(world); - if (lesserPlot.id.x == greaterPlot.id.x) { + if (lesserPlot.id.x.equals(greaterPlot.id.x)) { if (!lesserPlot.settings.getMerged(2)) { lesserPlot.settings.setMerged(2, true); greaterPlot.settings.setMerged(0, true); @@ -208,7 +209,7 @@ public class PlotHelper { /* * Random number gen section */ - public static final long nextLong() { + public static long nextLong() { final long a = state; state = xorShift64(a); return a; @@ -218,14 +219,14 @@ public class PlotHelper { * End of random number gen section */ - public static final long xorShift64(long a) { + public static long xorShift64(long a) { a ^= (a << 21); a ^= (a >>> 35); a ^= (a << 4); return a; } - public static final int random(final int n) { + public static int random(final int n) { if (n == 1) { return 0; } @@ -352,7 +353,6 @@ public class PlotHelper { count++; final PlotId bot = PlayerFunctions.getBottomPlot(world, plot).id; final PlotId top = PlayerFunctions.getTopPlot(world, plot).id; - merge = false; plots = PlayerFunctions.getPlotSelectionIds(world, new PlotId(bot.x, bot.y - 1), new PlotId(top.x, top.y)); if (ownsPlots(world, plots, player, 0)) { final boolean result = mergePlots(world, plots); @@ -765,6 +765,7 @@ public class PlotHelper { } } } catch (final Exception e) { + // } } } @@ -794,7 +795,7 @@ public class PlotHelper { } } } catch (final Exception e) { - + // } } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ReflectionUtils.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ReflectionUtils.java index 600fc1425..96b365722 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ReflectionUtils.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ReflectionUtils.java @@ -28,6 +28,7 @@ import java.lang.reflect.Constructor; import java.lang.reflect.Field; import java.lang.reflect.Method; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collections; import java.util.List; @@ -232,8 +233,8 @@ public class ReflectionUtils { if (methodTypes.length != classes.length) { continue; } - for (int i = 0; i < classes.length; i++) { - if (!classes.equals(methodTypes)) { + for (Class aClass : classes) { + if (!Arrays.equals(classes, methodTypes)) { continue findMethod; } return new RefMethod(m); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/uuid/NameFetcher.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/uuid/NameFetcher.java index 71ad971d9..5adc83cb8 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/uuid/NameFetcher.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/uuid/NameFetcher.java @@ -35,7 +35,8 @@ import java.util.UUID; import java.util.concurrent.Callable; /** - * @author + * Name Fetcher Class + * From Bukkit */ public class NameFetcher implements Callable> { private static final String PROFILE_URL = "https://sessionserver.mojang.com/session/minecraft/profile/"; @@ -48,7 +49,7 @@ public class NameFetcher implements Callable> { @Override public Map call() throws Exception { - final Map uuidStringMap = new HashMap(); + final Map uuidStringMap = new HashMap<>(); for (final UUID uuid : this.uuids) { if (uuidStringMap.containsKey(uuid)) { continue; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/uuid/PlotUUIDSaver.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/uuid/PlotUUIDSaver.java index 826a2a52d..97ca78944 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/uuid/PlotUUIDSaver.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/uuid/PlotUUIDSaver.java @@ -37,9 +37,9 @@ import java.net.URLConnection; import java.util.UUID; /** - * Created by Citymonstret on 2014-10-13. + * Plot UUID Saver/Fetcher */ -public class PlotUUIDSaver extends UUIDSaver { +public class PlotUUIDSaver implements UUIDSaver { @Override public void globalPopulate() { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/uuid/UUIDFetcher.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/uuid/UUIDFetcher.java index 1921df1df..e7e36550f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/uuid/UUIDFetcher.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/uuid/UUIDFetcher.java @@ -35,7 +35,8 @@ import java.util.*; import java.util.concurrent.Callable; /** - * @author + * UUID Fetcher + * From Bukkit */ public class UUIDFetcher implements Callable> { private static final double PROFILES_PER_REQUEST = 100; @@ -53,29 +54,6 @@ public class UUIDFetcher implements Callable> { this(names, true); } - @Override - public Map call() throws Exception { - final Map uuidMap = new HashMap(); - final int requests = (int) Math.ceil(this.names.size() / PROFILES_PER_REQUEST); - for (int i = 0; i < requests; i++) { - final HttpURLConnection connection = createConnection(); - final String body = JSONArray.toJSONString(this.names.subList(i * 100, Math.min((i + 1) * 100, this.names.size()))); - writeBody(connection, body); - final JSONArray array = (JSONArray) this.jsonParser.parse(new InputStreamReader(connection.getInputStream())); - for (final Object profile : array) { - final JSONObject jsonProfile = (JSONObject) profile; - final String id = (String) jsonProfile.get("id"); - final String name = (String) jsonProfile.get("name"); - final UUID uuid = UUIDFetcher.getUUID(id); - uuidMap.put(name, uuid); - } - if (this.rateLimiting && (i != (requests - 1))) { - Thread.sleep(100L); - } - } - return uuidMap; - } - private static void writeBody(final HttpURLConnection connection, final String body) throws Exception { final OutputStream stream = connection.getOutputStream(); stream.write(body.getBytes()); @@ -98,6 +76,7 @@ public class UUIDFetcher implements Callable> { return UUID.fromString(id.substring(0, 8) + "-" + id.substring(8, 12) + "-" + id.substring(12, 16) + "-" + id.substring(16, 20) + "-" + id.substring(20, 32)); } + @SuppressWarnings("unused") public static byte[] toBytes(final UUID uuid) { final ByteBuffer byteBuffer = ByteBuffer.wrap(new byte[16]); byteBuffer.putLong(uuid.getMostSignificantBits()); @@ -105,6 +84,7 @@ public class UUIDFetcher implements Callable> { return byteBuffer.array(); } + @SuppressWarnings("unused") public static UUID fromBytes(final byte[] array) { if (array.length != 16) { throw new IllegalArgumentException("Illegal byte array length: " + array.length); @@ -115,7 +95,31 @@ public class UUIDFetcher implements Callable> { return new UUID(mostSignificant, leastSignificant); } + @SuppressWarnings("unused") public static UUID getUUIDOf(final String name) throws Exception { return new UUIDFetcher(Arrays.asList(name)).call().get(name); } + + @Override + public Map call() throws Exception { + final Map uuidMap = new HashMap<>(); + final int requests = (int) Math.ceil(this.names.size() / PROFILES_PER_REQUEST); + for (int i = 0; i < requests; i++) { + final HttpURLConnection connection = createConnection(); + final String body = JSONArray.toJSONString(this.names.subList(i * 100, Math.min((i + 1) * 100, this.names.size()))); + writeBody(connection, body); + final JSONArray array = (JSONArray) this.jsonParser.parse(new InputStreamReader(connection.getInputStream())); + for (final Object profile : array) { + final JSONObject jsonProfile = (JSONObject) profile; + final String id = (String) jsonProfile.get("id"); + final String name = (String) jsonProfile.get("name"); + final UUID uuid = UUIDFetcher.getUUID(id); + uuidMap.put(name, uuid); + } + if (this.rateLimiting && (i != (requests - 1))) { + Thread.sleep(100L); + } + } + return uuidMap; + } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/uuid/UUIDSaver.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/uuid/UUIDSaver.java index 5acfe91d6..f84b8c64a 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/uuid/UUIDSaver.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/uuid/UUIDSaver.java @@ -27,20 +27,20 @@ import com.intellectualcrafters.plot.object.StringWrapper; import java.util.UUID; /** - * Created by Citymonstret on 2014-10-13. + * @author Citymonstret */ -public abstract class UUIDSaver { - public abstract void globalPopulate(); +public interface UUIDSaver { + public void globalPopulate(); - public abstract void globalSave(final BiMap biMap); + public void globalSave(final BiMap biMap); - public abstract void save(final UUIDSet set); + public void save(final UUIDSet set); - public abstract UUIDSet get(final String name); + public UUIDSet get(final String name); - public abstract UUIDSet get(final UUID uuid); + public UUIDSet get(final UUID uuid); - public abstract UUID mojangUUID(final String name) throws Exception; + public UUID mojangUUID(final String name) throws Exception; - public abstract String mojangName(final UUID uuid) throws Exception; + public String mojangName(final UUID uuid) throws Exception; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/uuid/UUIDSet.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/uuid/UUIDSet.java index 5dec9bcd8..82e1554c2 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/uuid/UUIDSet.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/uuid/UUIDSet.java @@ -24,7 +24,7 @@ package com.intellectualcrafters.plot.uuid; import java.util.UUID; /** - * Created by Citymonstret on 2014-10-13. + * @author Citymonstret */ public class UUIDSet { private final String name;