mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-26 07:06:44 +01:00
Fixed lots of "warnings", and minor stuff.
Deprecated old Plot Constructor(s)
This commit is contained in:
parent
5f9927cda7
commit
8261b944b2
@ -37,6 +37,7 @@ import java.util.UUID;
|
|||||||
* The plot class
|
* The plot class
|
||||||
*
|
*
|
||||||
* @author Citymonstret
|
* @author Citymonstret
|
||||||
|
* @author Empire92
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("javadoc")
|
@SuppressWarnings("javadoc")
|
||||||
public class Plot implements Cloneable {
|
public class Plot implements Cloneable {
|
||||||
@ -91,7 +92,11 @@ public class Plot implements Cloneable {
|
|||||||
* @param plotBiome
|
* @param plotBiome
|
||||||
* @param helpers
|
* @param helpers
|
||||||
* @param denied
|
* @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) {
|
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.id = id;
|
||||||
this.settings = new PlotSettings(this);
|
this.settings = new PlotSettings(this);
|
||||||
@ -107,6 +112,29 @@ public class Plot implements Cloneable {
|
|||||||
this.world = world;
|
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
|
* Constructor for saved plots
|
||||||
*
|
*
|
||||||
@ -116,7 +144,11 @@ public class Plot implements Cloneable {
|
|||||||
* @param helpers
|
* @param helpers
|
||||||
* @param denied
|
* @param denied
|
||||||
* @param merged
|
* @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) {
|
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.id = id;
|
||||||
this.settings = new PlotSettings(this);
|
this.settings = new PlotSettings(this);
|
||||||
@ -137,6 +169,35 @@ public class Plot implements Cloneable {
|
|||||||
this.world = world;
|
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
|
* Check if the plot has a set owner
|
||||||
*
|
*
|
||||||
@ -205,7 +266,7 @@ public class Plot implements Cloneable {
|
|||||||
public Object clone() throws CloneNotSupportedException {
|
public Object clone() throws CloneNotSupportedException {
|
||||||
Plot p = (Plot) super.clone();
|
Plot p = (Plot) super.clone();
|
||||||
if (!p.equals(this) || p != this) {
|
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;
|
return p;
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,9 @@
|
|||||||
|
|
||||||
package com.intellectualcrafters.plot.object;
|
package com.intellectualcrafters.plot.object;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Empire92
|
||||||
|
*/
|
||||||
public class PlotBlock {
|
public class PlotBlock {
|
||||||
public short id;
|
public short id;
|
||||||
public byte data;
|
public byte data;
|
||||||
|
@ -21,6 +21,9 @@
|
|||||||
|
|
||||||
package com.intellectualcrafters.plot.object;
|
package com.intellectualcrafters.plot.object;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Empire92
|
||||||
|
*/
|
||||||
public class PlotComment {
|
public class PlotComment {
|
||||||
public final String comment;
|
public final String comment;
|
||||||
public final int tier;
|
public final int tier;
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
package com.intellectualcrafters.plot.object;
|
package com.intellectualcrafters.plot.object;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Citymonstret on 2014-08-05.
|
* @author Citymonstret
|
||||||
*/
|
*/
|
||||||
public enum PlotHomePosition {
|
public enum PlotHomePosition {
|
||||||
CENTER("Center", 'c'),
|
CENTER("Center", 'c'),
|
||||||
@ -37,13 +37,7 @@ public enum PlotHomePosition {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isMatching(final String string) {
|
public boolean isMatching(final String string) {
|
||||||
if ((string.length() < 2) && (string.charAt(0) == this.ch)) {
|
return (string.length() < 2) && (string.charAt(0) == this.ch) || string.equalsIgnoreCase(this.string);
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (string.equalsIgnoreCase(this.string)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,7 @@ package com.intellectualcrafters.plot.object;
|
|||||||
|
|
||||||
import com.intellectualcrafters.plot.flag.Flag;
|
import com.intellectualcrafters.plot.flag.Flag;
|
||||||
import com.intellectualcrafters.plot.util.PlotHelper;
|
import com.intellectualcrafters.plot.util.PlotHelper;
|
||||||
|
import com.sun.istack.internal.NotNull;
|
||||||
import org.bukkit.block.Biome;
|
import org.bukkit.block.Biome;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -36,6 +37,7 @@ import java.util.Set;
|
|||||||
* @author Citymonstret
|
* @author Citymonstret
|
||||||
* @author Empire92
|
* @author Empire92
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("unused")
|
||||||
public class PlotSettings {
|
public class PlotSettings {
|
||||||
/**
|
/**
|
||||||
* merged plots
|
* merged plots
|
||||||
@ -133,15 +135,19 @@ public class PlotSettings {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param flags
|
* Set multiple flags
|
||||||
|
*
|
||||||
|
* @param flags Flag Array
|
||||||
*/
|
*/
|
||||||
public void setFlags(final Flag[] flags) {
|
public void setFlags(@NotNull final Flag[] flags) {
|
||||||
this.flags = new HashSet<Flag>(Arrays.asList(flags));
|
this.flags = new HashSet<>(Arrays.asList(flags));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param flag
|
* Get a flag
|
||||||
* @return
|
*
|
||||||
|
* @param flag Flag to get
|
||||||
|
* @return flag
|
||||||
*/
|
*/
|
||||||
public Flag getFlag(final String flag) {
|
public Flag getFlag(final String flag) {
|
||||||
for (final Flag myflag : this.flags) {
|
for (final Flag myflag : this.flags) {
|
||||||
|
@ -42,7 +42,7 @@ public abstract class PlotWorld {
|
|||||||
// TODO make this configurable
|
// TODO make this configurable
|
||||||
// make non static and static_default_valu + add config option
|
// make non static and static_default_valu + add config option
|
||||||
@SuppressWarnings("deprecation")
|
@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)}));
|
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 AUTO_MERGE_DEFAULT = false;
|
||||||
public static boolean MOB_SPAWNING_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 boolean SCHEMATIC_ON_CLAIM_DEFAULT = false;
|
||||||
public static String SCHEMATIC_FILE_DEFAULT = "null";
|
public static String SCHEMATIC_FILE_DEFAULT = "null";
|
||||||
public static List<String> SCHEMATICS_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 boolean USE_ECONOMY_DEFAULT = false;
|
||||||
public static double PLOT_PRICE_DEFAULT = 100;
|
public static double PLOT_PRICE_DEFAULT = 100;
|
||||||
public static double MERGE_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
|
* 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) {
|
public void loadDefaultConfiguration(final ConfigurationSection config) {
|
||||||
this.MOB_SPAWNING = config.getBoolean("natural_mob_spawning");
|
this.MOB_SPAWNING = config.getBoolean("natural_mob_spawning");
|
||||||
@ -118,10 +118,10 @@ public abstract class PlotWorld {
|
|||||||
/**
|
/**
|
||||||
* Saving core plotworld settings
|
* Saving core plotworld settings
|
||||||
*
|
*
|
||||||
* @param config
|
* @param config Configuration Section
|
||||||
*/
|
*/
|
||||||
public void saveConfiguration(final ConfigurationSection config) {
|
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("natural_mob_spawning", PlotWorld.MOB_SPAWNING_DEFAULT);
|
||||||
options.put("plot.auto_merge", PlotWorld.AUTO_MERGE_DEFAULT);
|
options.put("plot.auto_merge", PlotWorld.AUTO_MERGE_DEFAULT);
|
||||||
|
@ -43,6 +43,7 @@ public class Title {
|
|||||||
static {
|
static {
|
||||||
CORRESPONDING_TYPES = new HashMap<>();
|
CORRESPONDING_TYPES = new HashMap<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Title packet */
|
/* Title packet */
|
||||||
private Class<?> packetTitle;
|
private Class<?> packetTitle;
|
||||||
/* Title packet actions ENUM */
|
/* Title packet actions ENUM */
|
||||||
@ -50,7 +51,7 @@ public class Title {
|
|||||||
/* Chat serializer */
|
/* Chat serializer */
|
||||||
private Class<?> nmsChatSerializer;
|
private Class<?> nmsChatSerializer;
|
||||||
/* Title text and color */
|
/* Title text and color */
|
||||||
private String title = "";
|
private String title;
|
||||||
private ChatColor titleColor = ChatColor.WHITE;
|
private ChatColor titleColor = ChatColor.WHITE;
|
||||||
/* Subtitle text and color */
|
/* Subtitle text and color */
|
||||||
private String subtitle = "";
|
private String subtitle = "";
|
||||||
@ -78,6 +79,7 @@ public class Title {
|
|||||||
* @param subtitle Subtitle text
|
* @param subtitle Subtitle text
|
||||||
*/
|
*/
|
||||||
public Title(final String title, final String subtitle) {
|
public Title(final String title, final String subtitle) {
|
||||||
|
this.title = "";
|
||||||
this.title = title;
|
this.title = title;
|
||||||
this.subtitle = subtitle;
|
this.subtitle = subtitle;
|
||||||
loadClasses();
|
loadClasses();
|
||||||
@ -93,6 +95,7 @@ public class Title {
|
|||||||
* @param fadeOutTime Fade out time
|
* @param fadeOutTime Fade out time
|
||||||
*/
|
*/
|
||||||
public Title(final String title, final String subtitle, final int fadeInTime, final int stayTime, final int fadeOutTime) {
|
public Title(final String title, final String subtitle, final int fadeInTime, final int stayTime, final int fadeOutTime) {
|
||||||
|
this.title = "";
|
||||||
this.title = title;
|
this.title = title;
|
||||||
this.subtitle = subtitle;
|
this.subtitle = subtitle;
|
||||||
this.fadeInTime = fadeInTime;
|
this.fadeInTime = fadeInTime;
|
||||||
|
@ -28,6 +28,7 @@ import org.bukkit.Location;
|
|||||||
*
|
*
|
||||||
* @author Citymonstret
|
* @author Citymonstret
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings({"javadoc", "unused"})
|
||||||
public class LSetCube {
|
public class LSetCube {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -98,6 +98,7 @@ public class PWE {
|
|||||||
return s.getMask() == null;
|
return s.getMask() == null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
public static void setNoMask(final Player p) {
|
public static void setNoMask(final Player p) {
|
||||||
try {
|
try {
|
||||||
LocalSession s;
|
LocalSession s;
|
||||||
@ -110,7 +111,7 @@ public class PWE {
|
|||||||
final Vector p1 = new Vector(69, 69, 69), p2 = new Vector(69, 69, 69);
|
final Vector p1 = new Vector(69, 69, 69), p2 = new Vector(69, 69, 69);
|
||||||
s.setMask(new RegionMask(new CuboidRegion(plr.getWorld(), p1, p2)));
|
s.setMask(new RegionMask(new CuboidRegion(plr.getWorld(), p1, p2)));
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
|
//
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,10 +45,11 @@ import java.util.UUID;
|
|||||||
*
|
*
|
||||||
* @author Citymonstret
|
* @author Citymonstret
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings({"unused", "javadoc", "deprecation"})
|
||||||
public class PlotHelper {
|
public class PlotHelper {
|
||||||
public static boolean canSetFast = false;
|
public static boolean canSetFast = false;
|
||||||
public static ArrayList<String> runners_p = new ArrayList<String>();
|
public static ArrayList<String> runners_p = new ArrayList<>();
|
||||||
public static HashMap<Plot, Integer> runners = new HashMap<Plot, Integer>();
|
public static HashMap<Plot, Integer> runners = new HashMap<>();
|
||||||
static long state = 1;
|
static long state = 1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -190,7 +191,7 @@ public class PlotHelper {
|
|||||||
final PlotManager manager = PlotMain.getPlotManager(world);
|
final PlotManager manager = PlotMain.getPlotManager(world);
|
||||||
final PlotWorld plotworld = PlotMain.getWorldSettings(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)) {
|
if (!lesserPlot.settings.getMerged(2)) {
|
||||||
lesserPlot.settings.setMerged(2, true);
|
lesserPlot.settings.setMerged(2, true);
|
||||||
greaterPlot.settings.setMerged(0, true);
|
greaterPlot.settings.setMerged(0, true);
|
||||||
@ -208,7 +209,7 @@ public class PlotHelper {
|
|||||||
/*
|
/*
|
||||||
* Random number gen section
|
* Random number gen section
|
||||||
*/
|
*/
|
||||||
public static final long nextLong() {
|
public static long nextLong() {
|
||||||
final long a = state;
|
final long a = state;
|
||||||
state = xorShift64(a);
|
state = xorShift64(a);
|
||||||
return a;
|
return a;
|
||||||
@ -218,14 +219,14 @@ public class PlotHelper {
|
|||||||
* End of random number gen section
|
* End of random number gen section
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public static final long xorShift64(long a) {
|
public static long xorShift64(long a) {
|
||||||
a ^= (a << 21);
|
a ^= (a << 21);
|
||||||
a ^= (a >>> 35);
|
a ^= (a >>> 35);
|
||||||
a ^= (a << 4);
|
a ^= (a << 4);
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final int random(final int n) {
|
public static int random(final int n) {
|
||||||
if (n == 1) {
|
if (n == 1) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -352,7 +353,6 @@ public class PlotHelper {
|
|||||||
count++;
|
count++;
|
||||||
final PlotId bot = PlayerFunctions.getBottomPlot(world, plot).id;
|
final PlotId bot = PlayerFunctions.getBottomPlot(world, plot).id;
|
||||||
final PlotId top = PlayerFunctions.getTopPlot(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));
|
plots = PlayerFunctions.getPlotSelectionIds(world, new PlotId(bot.x, bot.y - 1), new PlotId(top.x, top.y));
|
||||||
if (ownsPlots(world, plots, player, 0)) {
|
if (ownsPlots(world, plots, player, 0)) {
|
||||||
final boolean result = mergePlots(world, plots);
|
final boolean result = mergePlots(world, plots);
|
||||||
@ -765,6 +765,7 @@ public class PlotHelper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
|
//
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -794,7 +795,7 @@ public class PlotHelper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
|
//
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,6 +28,7 @@ import java.lang.reflect.Constructor;
|
|||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -232,8 +233,8 @@ public class ReflectionUtils {
|
|||||||
if (methodTypes.length != classes.length) {
|
if (methodTypes.length != classes.length) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
for (int i = 0; i < classes.length; i++) {
|
for (Class aClass : classes) {
|
||||||
if (!classes.equals(methodTypes)) {
|
if (!Arrays.equals(classes, methodTypes)) {
|
||||||
continue findMethod;
|
continue findMethod;
|
||||||
}
|
}
|
||||||
return new RefMethod(m);
|
return new RefMethod(m);
|
||||||
|
@ -35,7 +35,8 @@ import java.util.UUID;
|
|||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author
|
* Name Fetcher Class
|
||||||
|
* From Bukkit
|
||||||
*/
|
*/
|
||||||
public class NameFetcher implements Callable<Map<UUID, String>> {
|
public class NameFetcher implements Callable<Map<UUID, String>> {
|
||||||
private static final String PROFILE_URL = "https://sessionserver.mojang.com/session/minecraft/profile/";
|
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
|
@Override
|
||||||
public Map<UUID, String> call() throws Exception {
|
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) {
|
for (final UUID uuid : this.uuids) {
|
||||||
if (uuidStringMap.containsKey(uuid)) {
|
if (uuidStringMap.containsKey(uuid)) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -37,9 +37,9 @@ import java.net.URLConnection;
|
|||||||
import java.util.UUID;
|
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
|
@Override
|
||||||
public void globalPopulate() {
|
public void globalPopulate() {
|
||||||
|
@ -35,7 +35,8 @@ import java.util.*;
|
|||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author
|
* UUID Fetcher
|
||||||
|
* From Bukkit
|
||||||
*/
|
*/
|
||||||
public class UUIDFetcher implements Callable<Map<String, UUID>> {
|
public class UUIDFetcher implements Callable<Map<String, UUID>> {
|
||||||
private static final double PROFILES_PER_REQUEST = 100;
|
private static final double PROFILES_PER_REQUEST = 100;
|
||||||
@ -53,29 +54,6 @@ public class UUIDFetcher implements Callable<Map<String, UUID>> {
|
|||||||
this(names, true);
|
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 {
|
private static void writeBody(final HttpURLConnection connection, final String body) throws Exception {
|
||||||
final OutputStream stream = connection.getOutputStream();
|
final OutputStream stream = connection.getOutputStream();
|
||||||
stream.write(body.getBytes());
|
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));
|
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) {
|
public static byte[] toBytes(final UUID uuid) {
|
||||||
final ByteBuffer byteBuffer = ByteBuffer.wrap(new byte[16]);
|
final ByteBuffer byteBuffer = ByteBuffer.wrap(new byte[16]);
|
||||||
byteBuffer.putLong(uuid.getMostSignificantBits());
|
byteBuffer.putLong(uuid.getMostSignificantBits());
|
||||||
@ -105,6 +84,7 @@ public class UUIDFetcher implements Callable<Map<String, UUID>> {
|
|||||||
return byteBuffer.array();
|
return byteBuffer.array();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
public static UUID fromBytes(final byte[] array) {
|
public static UUID fromBytes(final byte[] array) {
|
||||||
if (array.length != 16) {
|
if (array.length != 16) {
|
||||||
throw new IllegalArgumentException("Illegal byte array length: " + array.length);
|
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);
|
return new UUID(mostSignificant, leastSignificant);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
public static UUID getUUIDOf(final String name) throws Exception {
|
public static UUID getUUIDOf(final String name) throws Exception {
|
||||||
return new UUIDFetcher(Arrays.asList(name)).call().get(name);
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,20 +27,20 @@ import com.intellectualcrafters.plot.object.StringWrapper;
|
|||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Citymonstret on 2014-10-13.
|
* @author Citymonstret
|
||||||
*/
|
*/
|
||||||
public abstract class UUIDSaver {
|
public interface UUIDSaver {
|
||||||
public abstract void globalPopulate();
|
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;
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ package com.intellectualcrafters.plot.uuid;
|
|||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Citymonstret on 2014-10-13.
|
* @author Citymonstret
|
||||||
*/
|
*/
|
||||||
public class UUIDSet {
|
public class UUIDSet {
|
||||||
private final String name;
|
private final String name;
|
||||||
|
Loading…
Reference in New Issue
Block a user