Fixed lots of "warnings", and minor stuff.

Deprecated old Plot Constructor(s)
This commit is contained in:
Sauilitired 2014-11-19 17:46:30 +01:00
parent 5f9927cda7
commit 8261b944b2
16 changed files with 148 additions and 69 deletions

View File

@ -37,6 +37,7 @@ import java.util.UUID;
* The plot class
*
* @author Citymonstret
* @author Empire92
*/
@SuppressWarnings("javadoc")
public class Plot implements Cloneable {
@ -91,7 +92,11 @@ public class Plot implements Cloneable {
* @param plotBiome
* @param helpers
* @param denied
*
* @deprecated
*/
@Deprecated
@SuppressWarnings("unused")
public Plot(final PlotId id, final UUID owner, final Biome plotBiome, final ArrayList<UUID> helpers, final ArrayList<UUID> denied, final String world) {
this.id = id;
this.settings = new PlotSettings(this);
@ -107,6 +112,29 @@ public class Plot implements Cloneable {
this.world = world;
}
/**
* Primary constructor
*
* @param id
* @param owner
* @param helpers
* @param denied
*/
public Plot(final PlotId id, final UUID owner, final ArrayList<UUID> helpers, final ArrayList<UUID> denied, final String world) {
this.id = id;
this.settings = new PlotSettings(this);
this.owner = owner;
this.deny_entry = this.owner == null;
this.helpers = helpers;
this.denied = denied;
this.trusted = new ArrayList<>();
this.settings.setAlias("");
this.settings.setPosition(PlotHomePosition.DEFAULT);
this.delete = false;
this.settings.setFlags(new Flag[0]);
this.world = world;
}
/**
* Constructor for saved plots
*
@ -116,7 +144,11 @@ public class Plot implements Cloneable {
* @param helpers
* @param denied
* @param merged
*
* @deprecated
*/
@Deprecated
@SuppressWarnings("unused")
public Plot(final PlotId id, final UUID owner, final Biome plotBiome, final ArrayList<UUID> helpers, final ArrayList<UUID> trusted, final ArrayList<UUID> denied, final String alias, final PlotHomePosition position, final Flag[] flags, final String world, final boolean[] merged) {
this.id = id;
this.settings = new PlotSettings(this);
@ -137,6 +169,35 @@ public class Plot implements Cloneable {
this.world = world;
}
/**
* Constructor for saved plots
*
* @param id
* @param owner
* @param helpers
* @param denied
* @param merged
*/
public Plot(final PlotId id, final UUID owner, final ArrayList<UUID> helpers, final ArrayList<UUID> trusted, final ArrayList<UUID> denied, final String alias, final PlotHomePosition position, final Flag[] flags, final String world, final boolean[] merged) {
this.id = id;
this.settings = new PlotSettings(this);
this.owner = owner;
this.deny_entry = this.owner != null;
this.trusted = trusted;
this.helpers = helpers;
this.denied = denied;
this.settings.setAlias(alias);
this.settings.setPosition(position);
this.settings.setMerged(merged);
this.delete = false;
if (flags != null) {
this.settings.setFlags(flags);
} else {
this.settings.setFlags(new Flag[0]);
}
this.world = world;
}
/**
* Check if the plot has a set owner
*
@ -205,7 +266,7 @@ public class Plot implements Cloneable {
public Object clone() throws CloneNotSupportedException {
Plot p = (Plot) super.clone();
if (!p.equals(this) || p != this) {
return new Plot(id, owner, settings.getBiome(), helpers, trusted, denied, settings.getAlias(), settings.getPosition(), settings.getFlags().toArray(new Flag[settings.getFlags().size()]), getWorld().getName(), settings.getMerged());
return new Plot(id, owner, helpers, trusted, denied, settings.getAlias(), settings.getPosition(), settings.getFlags().toArray(new Flag[settings.getFlags().size()]), getWorld().getName(), settings.getMerged());
}
return p;
}

View File

@ -21,6 +21,9 @@
package com.intellectualcrafters.plot.object;
/**
* @author Empire92
*/
public class PlotBlock {
public short id;
public byte data;

View File

@ -21,6 +21,9 @@
package com.intellectualcrafters.plot.object;
/**
* @author Empire92
*/
public class PlotComment {
public final String comment;
public final int tier;

View File

@ -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);
}
}

View File

@ -23,6 +23,7 @@ package com.intellectualcrafters.plot.object;
import com.intellectualcrafters.plot.flag.Flag;
import com.intellectualcrafters.plot.util.PlotHelper;
import com.sun.istack.internal.NotNull;
import org.bukkit.block.Biome;
import java.util.ArrayList;
@ -36,6 +37,7 @@ import java.util.Set;
* @author Citymonstret
* @author Empire92
*/
@SuppressWarnings("unused")
public class PlotSettings {
/**
* merged plots
@ -133,15 +135,19 @@ public class PlotSettings {
}
/**
* @param flags
* Set multiple flags
*
* @param flags Flag Array
*/
public void setFlags(final Flag[] flags) {
this.flags = new HashSet<Flag>(Arrays.asList(flags));
public void setFlags(@NotNull final Flag[] flags) {
this.flags = new HashSet<>(Arrays.asList(flags));
}
/**
* @param flag
* @return
* Get a flag
*
* @param flag Flag to get
* @return flag
*/
public Flag getFlag(final String flag) {
for (final Flag myflag : this.flags) {

View File

@ -42,7 +42,7 @@ public abstract class PlotWorld {
// TODO make this configurable
// make non static and static_default_valu + add config option
@SuppressWarnings("deprecation")
public static ArrayList<Material> BLOCKS = new ArrayList<Material>(Arrays.asList(new Material[]{ACACIA_STAIRS, BEACON, BEDROCK, BIRCH_WOOD_STAIRS, BOOKSHELF, BREWING_STAND, BRICK, BRICK_STAIRS, BURNING_FURNACE, CAKE_BLOCK, CAULDRON, CLAY_BRICK, CLAY, COAL_BLOCK, COAL_ORE, COBBLE_WALL, COBBLESTONE, COBBLESTONE_STAIRS, COMMAND, DARK_OAK_STAIRS, DAYLIGHT_DETECTOR, DIAMOND_ORE, DIAMOND_BLOCK, DIRT, DISPENSER, DROPPER, EMERALD_BLOCK, EMERALD_ORE, ENCHANTMENT_TABLE, ENDER_PORTAL_FRAME, ENDER_STONE, FURNACE, GLOWSTONE, GOLD_ORE, GOLD_BLOCK, GRASS, GRAVEL, GLASS, HARD_CLAY, HAY_BLOCK, HUGE_MUSHROOM_1, HUGE_MUSHROOM_2, IRON_BLOCK, IRON_ORE, JACK_O_LANTERN, JUKEBOX, JUNGLE_WOOD_STAIRS, LAPIS_BLOCK, LAPIS_ORE, LEAVES, LEAVES_2, LOG, LOG_2, MELON_BLOCK, MOB_SPAWNER, MOSSY_COBBLESTONE, MYCEL, NETHER_BRICK, NETHER_BRICK_STAIRS, NETHERRACK, NOTE_BLOCK, OBSIDIAN, PACKED_ICE, PUMPKIN, QUARTZ_BLOCK, QUARTZ_ORE, QUARTZ_STAIRS, REDSTONE_BLOCK, SANDSTONE, SAND,
public static ArrayList<Material> BLOCKS = new ArrayList<>(Arrays.asList(new Material[]{ACACIA_STAIRS, BEACON, BEDROCK, BIRCH_WOOD_STAIRS, BOOKSHELF, BREWING_STAND, BRICK, BRICK_STAIRS, BURNING_FURNACE, CAKE_BLOCK, CAULDRON, CLAY_BRICK, CLAY, COAL_BLOCK, COAL_ORE, COBBLE_WALL, COBBLESTONE, COBBLESTONE_STAIRS, COMMAND, DARK_OAK_STAIRS, DAYLIGHT_DETECTOR, DIAMOND_ORE, DIAMOND_BLOCK, DIRT, DISPENSER, DROPPER, EMERALD_BLOCK, EMERALD_ORE, ENCHANTMENT_TABLE, ENDER_PORTAL_FRAME, ENDER_STONE, FURNACE, GLOWSTONE, GOLD_ORE, GOLD_BLOCK, GRASS, GRAVEL, GLASS, HARD_CLAY, HAY_BLOCK, HUGE_MUSHROOM_1, HUGE_MUSHROOM_2, IRON_BLOCK, IRON_ORE, JACK_O_LANTERN, JUKEBOX, JUNGLE_WOOD_STAIRS, LAPIS_BLOCK, LAPIS_ORE, LEAVES, LEAVES_2, LOG, LOG_2, MELON_BLOCK, MOB_SPAWNER, MOSSY_COBBLESTONE, MYCEL, NETHER_BRICK, NETHER_BRICK_STAIRS, NETHERRACK, NOTE_BLOCK, OBSIDIAN, PACKED_ICE, PUMPKIN, QUARTZ_BLOCK, QUARTZ_ORE, QUARTZ_STAIRS, REDSTONE_BLOCK, SANDSTONE, SAND,
SANDSTONE_STAIRS, SMOOTH_BRICK, SMOOTH_STAIRS, SNOW_BLOCK, SOUL_SAND, SPONGE, SPRUCE_WOOD_STAIRS, STONE, WOOD, WOOD_STAIRS, WORKBENCH, WOOL, getMaterial(44), getMaterial(126)}));
public static boolean AUTO_MERGE_DEFAULT = false;
public static boolean MOB_SPAWNING_DEFAULT = false;
@ -52,7 +52,7 @@ public abstract class PlotWorld {
public static boolean SCHEMATIC_ON_CLAIM_DEFAULT = false;
public static String SCHEMATIC_FILE_DEFAULT = "null";
public static List<String> SCHEMATICS_DEFAULT = null;
public static List<String> DEFAULT_FLAGS_DEFAULT = new ArrayList<String>();
public static List<String> DEFAULT_FLAGS_DEFAULT = new ArrayList<>();
public static boolean USE_ECONOMY_DEFAULT = false;
public static double PLOT_PRICE_DEFAULT = 100;
public static double MERGE_PRICE_DEFAULT = 100;
@ -89,7 +89,7 @@ public abstract class PlotWorld {
/**
* When a world is created, the following method will be called for each
*
* @param config
* @param config Configuration Section
*/
public void loadDefaultConfiguration(final ConfigurationSection config) {
this.MOB_SPAWNING = config.getBoolean("natural_mob_spawning");
@ -118,10 +118,10 @@ public abstract class PlotWorld {
/**
* Saving core plotworld settings
*
* @param config
* @param config Configuration Section
*/
public void saveConfiguration(final ConfigurationSection config) {
final HashMap<String, Object> options = new HashMap<String, Object>();
final HashMap<String, Object> options = new HashMap<>();
options.put("natural_mob_spawning", PlotWorld.MOB_SPAWNING_DEFAULT);
options.put("plot.auto_merge", PlotWorld.AUTO_MERGE_DEFAULT);

View File

@ -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;

View File

@ -28,6 +28,7 @@ import org.bukkit.Location;
*
* @author Citymonstret
*/
@SuppressWarnings({"javadoc", "unused"})
public class LSetCube {
/**

View File

@ -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) {
//
}
}

View File

@ -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<String> runners_p = new ArrayList<String>();
public static HashMap<Plot, Integer> runners = new HashMap<Plot, Integer>();
public static ArrayList<String> runners_p = new ArrayList<>();
public static HashMap<Plot, Integer> runners = new HashMap<>();
static long state = 1;
/**
@ -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) {
//
}
}
}

View File

@ -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);

View File

@ -35,7 +35,8 @@ import java.util.UUID;
import java.util.concurrent.Callable;
/**
* @author
* Name Fetcher Class
* From Bukkit
*/
public class NameFetcher implements Callable<Map<UUID, String>> {
private static final String PROFILE_URL = "https://sessionserver.mojang.com/session/minecraft/profile/";
@ -48,7 +49,7 @@ public class NameFetcher implements Callable<Map<UUID, String>> {
@Override
public Map<UUID, String> call() throws Exception {
final Map<UUID, String> uuidStringMap = new HashMap<UUID, String>();
final Map<UUID, String> uuidStringMap = new HashMap<>();
for (final UUID uuid : this.uuids) {
if (uuidStringMap.containsKey(uuid)) {
continue;

View File

@ -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() {

View File

@ -35,7 +35,8 @@ import java.util.*;
import java.util.concurrent.Callable;
/**
* @author
* UUID Fetcher
* From Bukkit
*/
public class UUIDFetcher implements Callable<Map<String, UUID>> {
private static final double PROFILES_PER_REQUEST = 100;
@ -53,29 +54,6 @@ public class UUIDFetcher implements Callable<Map<String, UUID>> {
this(names, true);
}
@Override
public Map<String, UUID> call() throws Exception {
final Map<String, UUID> uuidMap = new HashMap<String, UUID>();
final int requests = (int) Math.ceil(this.names.size() / PROFILES_PER_REQUEST);
for (int i = 0; i < requests; i++) {
final HttpURLConnection connection = createConnection();
final String body = JSONArray.toJSONString(this.names.subList(i * 100, Math.min((i + 1) * 100, this.names.size())));
writeBody(connection, body);
final JSONArray array = (JSONArray) this.jsonParser.parse(new InputStreamReader(connection.getInputStream()));
for (final Object profile : array) {
final JSONObject jsonProfile = (JSONObject) profile;
final String id = (String) jsonProfile.get("id");
final String name = (String) jsonProfile.get("name");
final UUID uuid = UUIDFetcher.getUUID(id);
uuidMap.put(name, uuid);
}
if (this.rateLimiting && (i != (requests - 1))) {
Thread.sleep(100L);
}
}
return uuidMap;
}
private static void writeBody(final HttpURLConnection connection, final String body) throws Exception {
final OutputStream stream = connection.getOutputStream();
stream.write(body.getBytes());
@ -98,6 +76,7 @@ public class UUIDFetcher implements Callable<Map<String, UUID>> {
return UUID.fromString(id.substring(0, 8) + "-" + id.substring(8, 12) + "-" + id.substring(12, 16) + "-" + id.substring(16, 20) + "-" + id.substring(20, 32));
}
@SuppressWarnings("unused")
public static byte[] toBytes(final UUID uuid) {
final ByteBuffer byteBuffer = ByteBuffer.wrap(new byte[16]);
byteBuffer.putLong(uuid.getMostSignificantBits());
@ -105,6 +84,7 @@ public class UUIDFetcher implements Callable<Map<String, UUID>> {
return byteBuffer.array();
}
@SuppressWarnings("unused")
public static UUID fromBytes(final byte[] array) {
if (array.length != 16) {
throw new IllegalArgumentException("Illegal byte array length: " + array.length);
@ -115,7 +95,31 @@ public class UUIDFetcher implements Callable<Map<String, UUID>> {
return new UUID(mostSignificant, leastSignificant);
}
@SuppressWarnings("unused")
public static UUID getUUIDOf(final String name) throws Exception {
return new UUIDFetcher(Arrays.asList(name)).call().get(name);
}
@Override
public Map<String, UUID> call() throws Exception {
final Map<String, UUID> uuidMap = new HashMap<>();
final int requests = (int) Math.ceil(this.names.size() / PROFILES_PER_REQUEST);
for (int i = 0; i < requests; i++) {
final HttpURLConnection connection = createConnection();
final String body = JSONArray.toJSONString(this.names.subList(i * 100, Math.min((i + 1) * 100, this.names.size())));
writeBody(connection, body);
final JSONArray array = (JSONArray) this.jsonParser.parse(new InputStreamReader(connection.getInputStream()));
for (final Object profile : array) {
final JSONObject jsonProfile = (JSONObject) profile;
final String id = (String) jsonProfile.get("id");
final String name = (String) jsonProfile.get("name");
final UUID uuid = UUIDFetcher.getUUID(id);
uuidMap.put(name, uuid);
}
if (this.rateLimiting && (i != (requests - 1))) {
Thread.sleep(100L);
}
}
return uuidMap;
}
}

View File

@ -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<StringWrapper, UUID> biMap);
public void globalSave(final BiMap<StringWrapper, UUID> 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;
}

View File

@ -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;