mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2025-06-25 10:14:42 +02:00
Cleaning
This commit is contained in:
@ -45,6 +45,7 @@ import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
@ -78,7 +79,8 @@ public class PlotAPI {
|
||||
* @deprecated Use new PlotAPI() instead
|
||||
*/
|
||||
@Deprecated
|
||||
public PlotAPI(final JavaPlugin plugin) {}
|
||||
public PlotAPI(JavaPlugin plugin) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @see PS
|
||||
@ -91,7 +93,8 @@ public class PlotAPI {
|
||||
*
|
||||
*/
|
||||
@Deprecated
|
||||
public PlotAPI() {}
|
||||
public PlotAPI() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all plots
|
||||
@ -111,7 +114,7 @@ public class PlotAPI {
|
||||
*
|
||||
* @return all plots that a player owns
|
||||
*/
|
||||
public Set<Plot> getPlayerPlots(final Player player) {
|
||||
public Set<Plot> getPlayerPlots(Player player) {
|
||||
return PS.get().getPlots(BukkitUtil.getPlayer(player));
|
||||
}
|
||||
|
||||
@ -121,7 +124,7 @@ public class PlotAPI {
|
||||
* @param plotArea Plot World Object
|
||||
* @see PS#addPlotArea(PlotArea)
|
||||
*/
|
||||
public void addPlotArea(final PlotArea plotArea) {
|
||||
public void addPlotArea(PlotArea plotArea) {
|
||||
PS.get().addPlotArea(plotArea);
|
||||
}
|
||||
|
||||
@ -226,9 +229,9 @@ public class PlotAPI {
|
||||
*/
|
||||
@Deprecated
|
||||
public String[] getPermissions() {
|
||||
final ArrayList<String> perms = new ArrayList<>();
|
||||
for (final C c : C.values()) {
|
||||
if ("static.permissions".equals(c.getCat())) {
|
||||
ArrayList<String> perms = new ArrayList<>();
|
||||
for (C c : C.values()) {
|
||||
if ("static.permissions".equals(c.getCategory())) {
|
||||
perms.add(c.s());
|
||||
}
|
||||
}
|
||||
@ -269,7 +272,7 @@ public class PlotAPI {
|
||||
* @see PS#getPlotManager(Plot)
|
||||
*/
|
||||
@Deprecated
|
||||
public PlotManager getPlotManager(final World world) {
|
||||
public PlotManager getPlotManager(World world) {
|
||||
if (world == null) {
|
||||
return null;
|
||||
}
|
||||
@ -295,7 +298,7 @@ public class PlotAPI {
|
||||
* @see com.intellectualcrafters.plot.object.PlotManager
|
||||
*/
|
||||
@Deprecated
|
||||
public PlotManager getPlotManager(final String world) {
|
||||
public PlotManager getPlotManager(String world) {
|
||||
Set<PlotArea> areas = PS.get().getPlotAreas(world);
|
||||
switch (areas.size()) {
|
||||
case 0:
|
||||
@ -320,7 +323,7 @@ public class PlotAPI {
|
||||
* @see com.intellectualcrafters.plot.object.PlotArea
|
||||
*/
|
||||
@Deprecated
|
||||
public PlotArea getWorldSettings(final World world) {
|
||||
public PlotArea getWorldSettings(World world) {
|
||||
if (world == null) {
|
||||
return null;
|
||||
}
|
||||
@ -338,7 +341,7 @@ public class PlotAPI {
|
||||
* @see com.intellectualcrafters.plot.object.PlotArea
|
||||
*/
|
||||
@Deprecated
|
||||
public PlotArea getWorldSettings(final String world) {
|
||||
public PlotArea getWorldSettings(String world) {
|
||||
if (world == null) {
|
||||
return null;
|
||||
}
|
||||
@ -363,7 +366,7 @@ public class PlotAPI {
|
||||
* @see MainUtil#sendMessage(PlotPlayer, C, String...)
|
||||
* com.intellectualcrafters.plot.config.C, String...)
|
||||
*/
|
||||
public void sendMessage(final Player player, final C c) {
|
||||
public void sendMessage(Player player, C c) {
|
||||
MainUtil.sendMessage(BukkitUtil.getPlayer(player), c);
|
||||
}
|
||||
|
||||
@ -375,7 +378,7 @@ public class PlotAPI {
|
||||
*
|
||||
* @see MainUtil#sendMessage(PlotPlayer, String)
|
||||
*/
|
||||
public void sendMessage(final Player player, final String string) {
|
||||
public void sendMessage(Player player, String string) {
|
||||
MainUtil.sendMessage(BukkitUtil.getPlayer(player), string);
|
||||
}
|
||||
|
||||
@ -386,7 +389,7 @@ public class PlotAPI {
|
||||
*
|
||||
* @see MainUtil#sendConsoleMessage(C, String...)
|
||||
*/
|
||||
public void sendConsoleMessage(final String msg) {
|
||||
public void sendConsoleMessage(String msg) {
|
||||
PS.log(msg);
|
||||
}
|
||||
|
||||
@ -398,8 +401,8 @@ public class PlotAPI {
|
||||
* @see #sendConsoleMessage(String)
|
||||
* @see com.intellectualcrafters.plot.config.C
|
||||
*/
|
||||
public void sendConsoleMessage(final C c) {
|
||||
sendConsoleMessage(c);
|
||||
public void sendConsoleMessage(C c) {
|
||||
sendConsoleMessage(c.s());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -410,7 +413,7 @@ public class PlotAPI {
|
||||
* @see com.intellectualcrafters.plot.flag.FlagManager#addFlag(com.intellectualcrafters.plot.flag.AbstractFlag)
|
||||
* @see com.intellectualcrafters.plot.flag.AbstractFlag
|
||||
*/
|
||||
public void addFlag(final AbstractFlag flag) {
|
||||
public void addFlag(AbstractFlag flag) {
|
||||
FlagManager.addFlag(flag);
|
||||
}
|
||||
|
||||
@ -427,7 +430,7 @@ public class PlotAPI {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a plot based on the ID
|
||||
* Get a plot based on the ID.
|
||||
*
|
||||
* @param world World in which the plot is located
|
||||
* @param x Plot Location X Co-ord
|
||||
@ -438,7 +441,7 @@ public class PlotAPI {
|
||||
* @see PlotArea#getPlot(PlotId)
|
||||
*/
|
||||
@Deprecated
|
||||
public Plot getPlot(final World world, final int x, final int z) {
|
||||
public Plot getPlot(World world, int x, int z) {
|
||||
if (world == null) {
|
||||
return null;
|
||||
}
|
||||
@ -450,7 +453,7 @@ public class PlotAPI {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a plot based on the location
|
||||
* Get a plot based on the location.
|
||||
*
|
||||
* @param l The location that you want to to retrieve the plot from
|
||||
*
|
||||
@ -458,7 +461,7 @@ public class PlotAPI {
|
||||
*
|
||||
* @see Plot
|
||||
*/
|
||||
public Plot getPlot(final Location l) {
|
||||
public Plot getPlot(Location l) {
|
||||
if (l == null) {
|
||||
return null;
|
||||
}
|
||||
@ -466,7 +469,7 @@ public class PlotAPI {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a plot based on the player location
|
||||
* Get a plot based on the player location.
|
||||
*
|
||||
* @param player Get the current plot for the player location
|
||||
*
|
||||
@ -475,12 +478,12 @@ public class PlotAPI {
|
||||
* @see #getPlot(org.bukkit.Location)
|
||||
* @see Plot
|
||||
*/
|
||||
public Plot getPlot(final Player player) {
|
||||
public Plot getPlot(Player player) {
|
||||
return this.getPlot(player.getLocation());
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether or not a player has a plot
|
||||
* Check whether or not a player has a plot.
|
||||
*
|
||||
* @param player Player that you want to check for
|
||||
*
|
||||
@ -489,22 +492,23 @@ public class PlotAPI {
|
||||
* @see #getPlots(World, Player, boolean)
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean hasPlot(final World world, final Player player) {
|
||||
public boolean hasPlot(World world, Player player) {
|
||||
return getPlots(world, player, true) != null && getPlots(world, player, true).length > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all plots for the player
|
||||
* Get all plots for the player.
|
||||
*
|
||||
* @param plr to search for
|
||||
* @param just_owner should we just search for owner? Or with rights?
|
||||
* @param world
|
||||
* @param player The player to search for
|
||||
* @param justOwner should we just search for owner? Or with rights?
|
||||
*/
|
||||
@Deprecated
|
||||
public Plot[] getPlots(final World world, final Player plr, final boolean just_owner) {
|
||||
final ArrayList<Plot> pPlots = new ArrayList<>();
|
||||
UUID uuid = BukkitUtil.getPlayer(plr).getUUID();
|
||||
for (final Plot plot : PS.get().getPlots(world.getName())) {
|
||||
if (just_owner) {
|
||||
public Plot[] getPlots(World world, Player player, boolean justOwner) {
|
||||
ArrayList<Plot> pPlots = new ArrayList<>();
|
||||
UUID uuid = BukkitUtil.getPlayer(player).getUUID();
|
||||
for (Plot plot : PS.get().getPlots(world.getName())) {
|
||||
if (justOwner) {
|
||||
if (plot.hasOwner() && plot.isOwner(uuid)) {
|
||||
pPlots.add(plot);
|
||||
}
|
||||
@ -518,7 +522,7 @@ public class PlotAPI {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all plots for the world
|
||||
* Get all plots for the world.
|
||||
*
|
||||
* @param world to get plots of
|
||||
*
|
||||
@ -528,7 +532,7 @@ public class PlotAPI {
|
||||
* @see Plot
|
||||
*/
|
||||
@Deprecated
|
||||
public Plot[] getPlots(final World world) {
|
||||
public Plot[] getPlots(World world) {
|
||||
if (world == null) {
|
||||
return new Plot[0];
|
||||
}
|
||||
@ -537,7 +541,7 @@ public class PlotAPI {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all plot worlds
|
||||
* Get all plot worlds.
|
||||
*
|
||||
* @return World[] - array of plot worlds
|
||||
*
|
||||
@ -558,7 +562,7 @@ public class PlotAPI {
|
||||
* @see PS#hasPlotArea(String)
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean isPlotWorld(final World world) {
|
||||
public boolean isPlotWorld(World world) {
|
||||
return PS.get().hasPlotArea(world.getName());
|
||||
}
|
||||
|
||||
@ -574,8 +578,8 @@ public class PlotAPI {
|
||||
* @see Plot
|
||||
*/
|
||||
@Deprecated
|
||||
public Location[] getLocations(final Plot p) {
|
||||
return new Location[] { BukkitUtil.getLocation(p.getBottom()), BukkitUtil.getLocation(p.getTop()), BukkitUtil.getLocation(p.getHome()) };
|
||||
public Location[] getLocations(Plot p) {
|
||||
return new Location[]{BukkitUtil.getLocation(p.getBottom()), BukkitUtil.getLocation(p.getTop()), BukkitUtil.getLocation(p.getHome())};
|
||||
}
|
||||
|
||||
/**
|
||||
@ -587,7 +591,7 @@ public class PlotAPI {
|
||||
*
|
||||
* @see Plot
|
||||
*/
|
||||
public Location getHomeLocation(final Plot p) {
|
||||
public Location getHomeLocation(Plot p) {
|
||||
return BukkitUtil.getLocation(p.getHome());
|
||||
}
|
||||
|
||||
@ -603,7 +607,7 @@ public class PlotAPI {
|
||||
* @see Plot
|
||||
*/
|
||||
@Deprecated
|
||||
public Location getBottomLocation(final Plot p) {
|
||||
public Location getBottomLocation(Plot p) {
|
||||
return BukkitUtil.getLocation(p.getBottom());
|
||||
}
|
||||
|
||||
@ -619,7 +623,7 @@ public class PlotAPI {
|
||||
* @see Plot
|
||||
*/
|
||||
@Deprecated
|
||||
public Location getTopLocation(final Plot p) {
|
||||
public Location getTopLocation(Plot p) {
|
||||
return BukkitUtil.getLocation(p.getTop());
|
||||
}
|
||||
|
||||
@ -631,7 +635,7 @@ public class PlotAPI {
|
||||
* @return true if the player is in a plot, false if not-
|
||||
*
|
||||
*/
|
||||
public boolean isInPlot(final Player player) {
|
||||
public boolean isInPlot(Player player) {
|
||||
return getPlot(player) != null;
|
||||
}
|
||||
|
||||
@ -642,7 +646,7 @@ public class PlotAPI {
|
||||
*
|
||||
* @see com.intellectualcrafters.plot.commands.SubCommand
|
||||
*/
|
||||
public void registerCommand(final SubCommand c) {
|
||||
public void registerCommand(SubCommand c) {
|
||||
if (c.getCommand() != null) {
|
||||
MainCommand.getInstance().addCommand(c);
|
||||
} else {
|
||||
@ -670,7 +674,7 @@ public class PlotAPI {
|
||||
* @return the number of plots the player has
|
||||
*
|
||||
*/
|
||||
public int getPlayerPlotCount(final World world, final Player player) {
|
||||
public int getPlayerPlotCount(World world, Player player) {
|
||||
if (world == null) {
|
||||
return 0;
|
||||
}
|
||||
@ -689,7 +693,7 @@ public class PlotAPI {
|
||||
*
|
||||
* @see Plot
|
||||
*/
|
||||
public Set<Plot> getPlayerPlots(final World world, final Player player) {
|
||||
public Set<Plot> getPlayerPlots(World world, Player player) {
|
||||
if (world == null) {
|
||||
return new HashSet<>();
|
||||
}
|
||||
@ -704,8 +708,8 @@ public class PlotAPI {
|
||||
* @return the number of allowed plots
|
||||
*
|
||||
*/
|
||||
public int getAllowedPlots(final Player player) {
|
||||
final PlotPlayer pp = BukkitUtil.getPlayer(player);
|
||||
public int getAllowedPlots(Player player) {
|
||||
PlotPlayer pp = BukkitUtil.getPlayer(player);
|
||||
return pp.getAllowedPlots();
|
||||
}
|
||||
|
||||
@ -718,7 +722,7 @@ public class PlotAPI {
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
public PlotPlayer wrapPlayer(final Player player) {
|
||||
public PlotPlayer wrapPlayer(Player player) {
|
||||
return PlotPlayer.wrap(player);
|
||||
}
|
||||
|
||||
@ -730,7 +734,7 @@ public class PlotAPI {
|
||||
* @param uuid
|
||||
* @return
|
||||
*/
|
||||
public PlotPlayer wrapPlayer(final UUID uuid) {
|
||||
public PlotPlayer wrapPlayer(UUID uuid) {
|
||||
return PlotPlayer.wrap(uuid);
|
||||
}
|
||||
|
||||
@ -742,7 +746,7 @@ public class PlotAPI {
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
public PlotPlayer wrapPlayer(final String player) {
|
||||
public PlotPlayer wrapPlayer(String player) {
|
||||
return PlotPlayer.wrap(player);
|
||||
}
|
||||
|
||||
@ -755,7 +759,7 @@ public class PlotAPI {
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
public PlotPlayer wrapPlayer(final OfflinePlayer player) {
|
||||
public PlotPlayer wrapPlayer(OfflinePlayer player) {
|
||||
return PlotPlayer.wrap(player);
|
||||
}
|
||||
}
|
||||
|
@ -89,7 +89,6 @@ import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
@ -139,13 +138,13 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
||||
|
||||
@Override
|
||||
public void log(String message) {
|
||||
if (THIS != null && Bukkit.getServer().getConsoleSender() != null) {
|
||||
if (THIS != null) {
|
||||
try {
|
||||
message = C.color(message);
|
||||
if (!Settings.CONSOLE_COLOR) {
|
||||
message = ChatColor.stripColor(message);
|
||||
}
|
||||
Bukkit.getServer().getConsoleSender().sendMessage(message);
|
||||
this.getServer().getConsoleSender().sendMessage(message);
|
||||
return;
|
||||
} catch (Throwable ignored) {
|
||||
//ignored
|
||||
@ -575,13 +574,9 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
||||
|
||||
@Override
|
||||
public void startMetrics() {
|
||||
try {
|
||||
Metrics metrics = new Metrics(this);
|
||||
metrics.start();
|
||||
log(C.PREFIX + "&6Metrics enabled.");
|
||||
} catch (IOException e) {
|
||||
log(C.PREFIX + "&cFailed to load up metrics.");
|
||||
}
|
||||
Metrics metrics = new Metrics(this);
|
||||
metrics.start();
|
||||
log(C.PREFIX + "&6Metrics enabled.");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -114,8 +114,9 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
|
||||
}
|
||||
|
||||
/**
|
||||
* Deserialize a fancy message from its JSON representation. This JSON representation is of the format of
|
||||
* that returned by {@link #toJSONString()}, and is compatible with vanilla inputs.
|
||||
* Deserialize a fancy message from its JSON representation. This JSON
|
||||
* representation is of the format of hat returned by
|
||||
* {@link #toJSONString()}, and is compatible with vanilla inputs.
|
||||
* @param json The JSON string which represents a fancy message.
|
||||
* @return A {@code FancyMessage} representing the parametrized JSON message.
|
||||
*/
|
||||
|
@ -30,10 +30,6 @@ public final class Reflection {
|
||||
*/
|
||||
private static final Map<Class<?>, Map<String, Map<ArrayWrapper<Class<?>>, Method>>> _loadedMethods = new HashMap<>();
|
||||
|
||||
private Reflection() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the version string from the package name of the CraftBukkit server implementation.
|
||||
* This is needed to bypass the JAR package name changing on each update.
|
||||
@ -103,7 +99,7 @@ public final class Reflection {
|
||||
* @param obj The object for which to retrieve an NMS handle.
|
||||
* @return The NMS handle of the specified object, or {@code null} if it could not be retrieved using {@code getHandle()}.
|
||||
*/
|
||||
public synchronized static Object getHandle(Object obj) {
|
||||
public static synchronized Object getHandle(Object obj) {
|
||||
try {
|
||||
return getMethod(obj.getClass(), "getHandle").invoke(obj);
|
||||
} catch (IllegalAccessException | InvocationTargetException | IllegalArgumentException e) {
|
||||
@ -114,8 +110,9 @@ public final class Reflection {
|
||||
|
||||
/**
|
||||
* Retrieves a {@link Field} instance declared by the specified class with the specified name.
|
||||
* Java access modifiers are ignored during this retrieval. No guarantee is made as to whether the field
|
||||
* returned will be an instance or static field.
|
||||
* Java access modifiers are ignored during this retrieval.
|
||||
* No guarantee is made as to whether the field returned will be an
|
||||
* instance or static field.
|
||||
* <p>
|
||||
* A global caching mechanism within this class is used to store fields. Combined with synchronization, this guarantees that
|
||||
* no field will be reflectively looked up twice.
|
||||
@ -130,7 +127,7 @@ public final class Reflection {
|
||||
* @return A field object with the specified name declared by the specified class.
|
||||
* @see Class#getDeclaredField(String)
|
||||
*/
|
||||
public synchronized static Field getField(Class<?> clazz, String name) {
|
||||
public static synchronized Field getField(Class<?> clazz, String name) {
|
||||
Map<String, Field> loaded;
|
||||
if (!_loadedFields.containsKey(clazz)) {
|
||||
loaded = new HashMap<>();
|
||||
@ -169,6 +166,7 @@ public final class Reflection {
|
||||
* true} before it is returned.
|
||||
* This ensures that callers do not have to check or worry about Java access modifiers when dealing with the returned instance.
|
||||
* </p>
|
||||
*
|
||||
* <p>
|
||||
* This method does <em>not</em> search superclasses of the specified type for methods with the specified signature.
|
||||
* Callers wishing this behavior should use {@link Class#getDeclaredMethod(String, Class...)}.
|
||||
@ -177,7 +175,7 @@ public final class Reflection {
|
||||
* @param args The formal argument types of the method.
|
||||
* @return A method object with the specified name declared by the specified class.
|
||||
*/
|
||||
public synchronized static Method getMethod(Class<?> clazz, String name, Class<?>... args) {
|
||||
public static synchronized Method getMethod(Class<?> clazz, String name, Class<?>... args) {
|
||||
if (!_loadedMethods.containsKey(clazz)) {
|
||||
_loadedMethods.put(clazz, new HashMap<String, Map<ArrayWrapper<Class<?>>, Method>>());
|
||||
}
|
||||
|
@ -27,10 +27,7 @@ import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
/**
|
||||
* Called when a flag is removed from a plot
|
||||
*
|
||||
|
||||
|
||||
* Called when a flag is removed from a plot.
|
||||
*/
|
||||
public class ClusterFlagRemoveEvent extends Event implements Cancellable {
|
||||
|
||||
@ -40,7 +37,7 @@ public class ClusterFlagRemoveEvent extends Event implements Cancellable {
|
||||
private boolean cancelled;
|
||||
|
||||
/**
|
||||
* PlotFlagRemoveEvent: Called when a flag is removed from a plot
|
||||
* PlotFlagRemoveEvent: Called when a flag is removed from a plot.
|
||||
*
|
||||
* @param flag Flag that was removed
|
||||
* @param cluster PlotCluster from which the flag was removed
|
||||
@ -55,7 +52,7 @@ public class ClusterFlagRemoveEvent extends Event implements Cancellable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the cluster involved
|
||||
* Get the cluster involved.
|
||||
*
|
||||
* @return PlotCluster
|
||||
*/
|
||||
@ -64,7 +61,7 @@ public class ClusterFlagRemoveEvent extends Event implements Cancellable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the flag involved
|
||||
* Get the flag involved.
|
||||
*
|
||||
* @return Flag
|
||||
*/
|
||||
|
@ -26,10 +26,6 @@ import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
|
||||
/**
|
||||
|
||||
|
||||
*/
|
||||
public class PlayerClaimPlotEvent extends PlayerEvent implements Cancellable {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
@ -38,7 +34,7 @@ public class PlayerClaimPlotEvent extends PlayerEvent implements Cancellable {
|
||||
private boolean cancelled;
|
||||
|
||||
/**
|
||||
* PlayerClaimPlotEvent: Called when a plot is claimed
|
||||
* PlayerClaimPlotEvent: Called when a plot is claimed.
|
||||
*
|
||||
* @param player Player that claimed the plot
|
||||
* @param plot Plot that was claimed
|
||||
|
@ -25,17 +25,13 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
|
||||
/**
|
||||
|
||||
|
||||
*/
|
||||
public class PlayerEnterPlotEvent extends PlayerEvent {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private final Plot plot;
|
||||
|
||||
/**
|
||||
* PlayerEnterPlotEvent: Called when a player leaves a plot
|
||||
* Called when a player leaves a plot.
|
||||
*
|
||||
* @param player Player that entered the plot
|
||||
* @param plot Plot that was entered
|
||||
@ -50,7 +46,7 @@ public class PlayerEnterPlotEvent extends PlayerEvent {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the plot involved
|
||||
* Get the plot involved.
|
||||
*
|
||||
* @return Plot
|
||||
*/
|
||||
|
@ -26,10 +26,6 @@ import org.bukkit.event.HandlerList;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
|
||||
|
||||
*/
|
||||
public class PlayerPlotDeniedEvent extends PlotEvent {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
@ -38,7 +34,7 @@ public class PlayerPlotDeniedEvent extends PlotEvent {
|
||||
private final UUID player;
|
||||
|
||||
/**
|
||||
* PlayerPlotDeniedEvent: Called when the denied UUID list is modified for a plot
|
||||
* PlayerPlotDeniedEvent: Called when the denied UUID list is modified for a plot.
|
||||
*
|
||||
* @param initiator Player that initiated the event
|
||||
* @param plot Plot in which the event occurred
|
||||
@ -57,7 +53,7 @@ public class PlayerPlotDeniedEvent extends PlotEvent {
|
||||
}
|
||||
|
||||
/**
|
||||
* If a user was added
|
||||
* If a user was added.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
@ -66,7 +62,7 @@ public class PlayerPlotDeniedEvent extends PlotEvent {
|
||||
}
|
||||
|
||||
/**
|
||||
* The player added/removed
|
||||
* The player added/removed.
|
||||
*
|
||||
* @return UUID
|
||||
*/
|
||||
@ -75,7 +71,7 @@ public class PlayerPlotDeniedEvent extends PlotEvent {
|
||||
}
|
||||
|
||||
/**
|
||||
* The player initiating the action
|
||||
* The player initiating the action.
|
||||
*
|
||||
* @return Player
|
||||
*/
|
||||
|
@ -28,8 +28,6 @@ import org.bukkit.event.HandlerList;
|
||||
/**
|
||||
* Called when a plot is cleared
|
||||
*
|
||||
|
||||
|
||||
*/
|
||||
public class PlotClearEvent extends PlotEvent implements Cancellable {
|
||||
|
||||
@ -44,7 +42,7 @@ public class PlotClearEvent extends PlotEvent implements Cancellable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the PlotId
|
||||
* Get the PlotId.
|
||||
*
|
||||
* @return PlotId
|
||||
*/
|
||||
@ -53,7 +51,7 @@ public class PlotClearEvent extends PlotEvent implements Cancellable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the world name
|
||||
* Get the world name.
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
|
@ -27,8 +27,6 @@ import org.bukkit.event.HandlerList;
|
||||
/**
|
||||
* Called when a plot is deleted
|
||||
*
|
||||
|
||||
|
||||
*/
|
||||
public class PlotDeleteEvent extends PlotEvent {
|
||||
|
||||
|
@ -26,10 +26,8 @@ import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
/**
|
||||
* Called when a Flag is added to a plot
|
||||
* Called when a Flag is added to a plot.
|
||||
*
|
||||
|
||||
|
||||
*/
|
||||
public class PlotFlagAddEvent extends PlotEvent implements Cancellable {
|
||||
|
||||
@ -38,7 +36,7 @@ public class PlotFlagAddEvent extends PlotEvent implements Cancellable {
|
||||
private boolean cancelled;
|
||||
|
||||
/**
|
||||
* PlotFlagAddEvent: Called when a Flag is added to a plot
|
||||
* PlotFlagAddEvent: Called when a Flag is added to a plot.
|
||||
*
|
||||
* @param flag Flag that was added
|
||||
* @param plot Plot to which the flag was added
|
||||
@ -53,7 +51,7 @@ public class PlotFlagAddEvent extends PlotEvent implements Cancellable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the flag involved
|
||||
* Get the flag involved.
|
||||
*
|
||||
* @return Flag
|
||||
*/
|
||||
|
@ -28,8 +28,6 @@ import org.bukkit.event.HandlerList;
|
||||
/**
|
||||
* Called when a flag is removed from a plot
|
||||
*
|
||||
|
||||
|
||||
*/
|
||||
public class PlotFlagRemoveEvent extends PlotEvent implements Cancellable {
|
||||
|
||||
|
@ -24,21 +24,16 @@ import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
|
||||
*/
|
||||
public class PlotMergeEvent extends Event implements Cancellable {
|
||||
public class PlotMergeEvent extends PlotEvent implements Cancellable {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private final ArrayList<PlotId> plots;
|
||||
private final World world;
|
||||
private boolean cancelled;
|
||||
private Plot plot;
|
||||
private World world;
|
||||
|
||||
/**
|
||||
* PlotMergeEvent: Called when plots are merged
|
||||
@ -48,6 +43,8 @@ public class PlotMergeEvent extends Event implements Cancellable {
|
||||
* @param plots A list of plots involved in the event
|
||||
*/
|
||||
public PlotMergeEvent(World world, Plot plot, ArrayList<PlotId> plots) {
|
||||
super(plot);
|
||||
this.world = world;
|
||||
this.plots = plots;
|
||||
}
|
||||
|
||||
@ -56,7 +53,7 @@ public class PlotMergeEvent extends Event implements Cancellable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the plots being added;
|
||||
* Get the plots being added.
|
||||
*
|
||||
* @return Plot
|
||||
*/
|
||||
@ -64,15 +61,6 @@ public class PlotMergeEvent extends Event implements Cancellable {
|
||||
return this.plots;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the main plot
|
||||
*
|
||||
* @return Plot
|
||||
*/
|
||||
public Plot getPlot() {
|
||||
return this.plot;
|
||||
}
|
||||
|
||||
public World getWorld() {
|
||||
return this.world;
|
||||
}
|
||||
|
@ -5,11 +5,6 @@ import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.Rating;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
/**
|
||||
* Created 2015-07-13 for PlotSquaredGit
|
||||
*
|
||||
|
||||
*/
|
||||
public class PlotRateEvent extends PlotEvent {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
@ -29,9 +29,6 @@ import org.bukkit.event.HandlerList;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
|
||||
*/
|
||||
public class PlotUnlinkEvent extends Event implements Cancellable {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
@ -57,9 +54,9 @@ public class PlotUnlinkEvent extends Event implements Cancellable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the plots involved
|
||||
* Get the plots involved.
|
||||
*
|
||||
* @return PlotId
|
||||
* @return The {@link PlotId}'s of the plots involved
|
||||
*/
|
||||
public ArrayList<PlotId> getPlots() {
|
||||
return this.plots;
|
||||
|
@ -257,8 +257,8 @@ public class ChunkListener implements Listener {
|
||||
this.lastChunk = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void cleanChunk(final Chunk chunk) {
|
||||
|
||||
private void cleanChunk(final Chunk chunk) {
|
||||
TaskManager.index.incrementAndGet();
|
||||
final Integer currentIndex = TaskManager.index.get();
|
||||
Integer task = TaskManager.runTaskRepeat(new Runnable() {
|
||||
|
@ -7,9 +7,9 @@ import com.plotsquared.bukkit.object.BukkitPlayer;
|
||||
public class DefaultTitle extends AbstractTitle {
|
||||
|
||||
@Override
|
||||
public void sendTitle(final PlotPlayer player, final String head, final String sub, final int in, final int delay, final int out) {
|
||||
public void sendTitle(PlotPlayer player, String head, String sub, int in, int delay, int out) {
|
||||
try {
|
||||
final DefaultTitleManager title = new DefaultTitleManager(head, sub, in, delay, out);
|
||||
DefaultTitleManager title = new DefaultTitleManager(head, sub, in, delay, out);
|
||||
title.send(((BukkitPlayer) player).player);
|
||||
} catch (Throwable e) {
|
||||
AbstractTitle.TITLE_CLASS = new DefaultTitle_183();
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.plotsquared.bukkit.titles;
|
||||
|
||||
import com.plotsquared.bukkit.chat.Reflection;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -121,10 +122,10 @@ public class DefaultTitleManager {
|
||||
* @throws ClassNotFoundException
|
||||
*/
|
||||
private void loadClasses() throws ClassNotFoundException {
|
||||
this.packetTitle = getNMSClass("PacketPlayOutTitle");
|
||||
this.packetActions = getNMSClass("EnumTitleAction");
|
||||
this.chatBaseComponent = getNMSClass("IChatBaseComponent");
|
||||
this.nmsChatSerializer = getNMSClass("ChatSerializer");
|
||||
this.packetTitle = Reflection.getNMSClass("PacketPlayOutTitle");
|
||||
this.packetActions = Reflection.getNMSClass("EnumTitleAction");
|
||||
this.chatBaseComponent = Reflection.getNMSClass("IChatBaseComponent");
|
||||
this.nmsChatSerializer = Reflection.getNMSClass("ChatSerializer");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -343,16 +344,6 @@ public class DefaultTitleManager {
|
||||
return null;
|
||||
}
|
||||
|
||||
private String getVersion() {
|
||||
String name = Bukkit.getServer().getClass().getPackage().getName();
|
||||
return name.substring(name.lastIndexOf('.') + 1) + ".";
|
||||
}
|
||||
|
||||
private Class<?> getNMSClass(String className) throws ClassNotFoundException {
|
||||
String fullName = "net.minecraft.server." + getVersion() + className;
|
||||
return Class.forName(fullName);
|
||||
}
|
||||
|
||||
private Field getField(Class<?> clazz, String name) {
|
||||
try {
|
||||
Field field = clazz.getDeclaredField(name);
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.plotsquared.bukkit.titles;
|
||||
|
||||
import com.plotsquared.bukkit.chat.Reflection;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -127,10 +128,10 @@ public class DefaultTitleManager_183 {
|
||||
* @throws ClassNotFoundException
|
||||
*/
|
||||
private void loadClasses() throws ClassNotFoundException {
|
||||
this.packetTitle = getNMSClass("PacketPlayOutTitle");
|
||||
this.chatBaseComponent = getNMSClass("IChatBaseComponent");
|
||||
this.packetActions = getNMSClass("PacketPlayOutTitle$EnumTitleAction");
|
||||
this.nmsChatSerializer = getNMSClass("IChatBaseComponent$ChatSerializer");
|
||||
this.packetTitle = Reflection.getNMSClass("PacketPlayOutTitle");
|
||||
this.chatBaseComponent = Reflection.getNMSClass("IChatBaseComponent");
|
||||
this.packetActions = Reflection.getNMSClass("PacketPlayOutTitle$EnumTitleAction");
|
||||
this.nmsChatSerializer = Reflection.getNMSClass("IChatBaseComponent$ChatSerializer");
|
||||
|
||||
}
|
||||
|
||||
@ -366,23 +367,12 @@ public class DefaultTitleManager_183 {
|
||||
return null;
|
||||
}
|
||||
|
||||
private String getVersion() {
|
||||
String name = Bukkit.getServer().getClass().getPackage().getName();
|
||||
String version = name.substring(name.lastIndexOf('.') + 1) + ".";
|
||||
return version;
|
||||
}
|
||||
|
||||
private Class<?> getNMSClass(String className) throws ClassNotFoundException {
|
||||
String fullName = "net.minecraft.server." + getVersion() + className;
|
||||
return Class.forName(fullName);
|
||||
}
|
||||
|
||||
private Field getField(Class<?> clazz, String name) {
|
||||
try {
|
||||
Field field = clazz.getDeclaredField(name);
|
||||
field.setAccessible(true);
|
||||
return field;
|
||||
} catch (Exception e) {
|
||||
} catch (NoSuchFieldException | SecurityException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
|
@ -5,12 +5,13 @@ import com.intellectualcrafters.plot.util.AbstractTitle;
|
||||
import com.plotsquared.bukkit.object.BukkitPlayer;
|
||||
|
||||
public class DefaultTitle_183 extends AbstractTitle {
|
||||
|
||||
@Override
|
||||
public void sendTitle(final PlotPlayer player, final String head, final String sub, final int in, final int delay, final int out) {
|
||||
public void sendTitle(PlotPlayer player, String head, String sub, int in, int delay, int out) {
|
||||
try {
|
||||
final DefaultTitleManager_183 title = new DefaultTitleManager_183(head, sub, in, delay, out);
|
||||
DefaultTitleManager_183 title = new DefaultTitleManager_183(head, sub, in, delay, out);
|
||||
title.send(((BukkitPlayer) player).player);
|
||||
} catch (final Throwable e) {
|
||||
} catch (Throwable e) {
|
||||
AbstractTitle.TITLE_CLASS = new HackTitle();
|
||||
AbstractTitle.TITLE_CLASS.sendTitle(player, head, sub, in, delay, out);
|
||||
}
|
||||
|
@ -7,19 +7,19 @@ import com.plotsquared.bukkit.object.BukkitPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class DefaultTitle_19 extends AbstractTitle {
|
||||
|
||||
@Override
|
||||
public void sendTitle(final PlotPlayer player, final String head, final String sub, final int in, final int delay, final int out) {
|
||||
public void sendTitle(PlotPlayer player, String head, String sub, int in, int delay, int out) {
|
||||
try {
|
||||
final Player playerObj = ((BukkitPlayer) player).player;
|
||||
playerObj.sendTitle(head,sub);
|
||||
playerObj.sendTitle(head, sub);
|
||||
TaskManager.runTaskLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
playerObj.sendTitle("","");
|
||||
playerObj.sendTitle("", "");
|
||||
}
|
||||
}, delay * 20);
|
||||
}
|
||||
catch (Throwable e) {
|
||||
} catch (Throwable e) {
|
||||
AbstractTitle.TITLE_CLASS = new DefaultTitle();
|
||||
AbstractTitle.TITLE_CLASS.sendTitle(player, head, sub, in, delay, out);
|
||||
}
|
||||
|
@ -7,10 +7,11 @@ import com.intellectualcrafters.plot.util.AbstractTitle;
|
||||
import com.plotsquared.bukkit.object.BukkitPlayer;
|
||||
|
||||
public class HackTitle extends AbstractTitle {
|
||||
|
||||
@Override
|
||||
public void sendTitle(final PlotPlayer player, final String head, final String sub, final int in, final int delay, final int out) {
|
||||
public void sendTitle(PlotPlayer player, String head, String sub, int in, int delay, int out) {
|
||||
try {
|
||||
final HackTitleManager title = new HackTitleManager(head, sub, in, delay, out);
|
||||
HackTitleManager title = new HackTitleManager(head, sub, in, delay, out);
|
||||
title.send(((BukkitPlayer) player).player);
|
||||
} catch (Throwable e) {
|
||||
PS.debug("&cYour server version does not support titles!");
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.plotsquared.bukkit.titles;
|
||||
|
||||
import com.plotsquared.bukkit.chat.Reflection;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -118,7 +119,7 @@ public class HackTitleManager {
|
||||
private void loadClasses() throws ClassNotFoundException {
|
||||
this.packetTitle = getClass("org.spigotmc.ProtocolInjector$PacketTitle");
|
||||
this.packetActions = getClass("org.spigotmc.ProtocolInjector$PacketTitle$Action");
|
||||
this.nmsChatSerializer = getNMSClass("ChatSerializer");
|
||||
this.nmsChatSerializer = Reflection.getNMSClass("ChatSerializer");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -242,14 +243,16 @@ public class HackTitleManager {
|
||||
// Send title
|
||||
Object serialized = getMethod(this.nmsChatSerializer, "a", String.class).invoke(null,
|
||||
"{text:\"" + ChatColor.translateAlternateColorCodes('&', this.title) + "\",color:" + this.titleColor.name().toLowerCase() + "}");
|
||||
packet = this.packetTitle.getConstructor(this.packetActions, getNMSClass("IChatBaseComponent")).newInstance(actions[0], serialized);
|
||||
packet = this.packetTitle.getConstructor(this.packetActions, Reflection.getNMSClass("IChatBaseComponent"))
|
||||
.newInstance(actions[0], serialized);
|
||||
sendPacket.invoke(connection, packet);
|
||||
if (!this.subtitle.isEmpty()) {
|
||||
// Send subtitle if present
|
||||
serialized = getMethod(this.nmsChatSerializer, "a", String.class).invoke(null,
|
||||
"{text:\"" + ChatColor.translateAlternateColorCodes('&', this.subtitle) + "\",color:" + this.subtitleColor.name()
|
||||
.toLowerCase() + "}");
|
||||
packet = this.packetTitle.getConstructor(this.packetActions, getNMSClass("IChatBaseComponent")).newInstance(actions[1], serialized);
|
||||
packet = this.packetTitle.getConstructor(this.packetActions, Reflection.getNMSClass("IChatBaseComponent"))
|
||||
.newInstance(actions[1], serialized);
|
||||
sendPacket.invoke(connection, packet);
|
||||
}
|
||||
}
|
||||
@ -381,16 +384,6 @@ public class HackTitleManager {
|
||||
return null;
|
||||
}
|
||||
|
||||
private String getVersion() {
|
||||
String name = Bukkit.getServer().getClass().getPackage().getName();
|
||||
return name.substring(name.lastIndexOf('.') + 1) + ".";
|
||||
}
|
||||
|
||||
private Class<?> getNMSClass(String className) throws ClassNotFoundException {
|
||||
String fullName = "net.minecraft.server." + getVersion() + className;
|
||||
return Class.forName(fullName);
|
||||
}
|
||||
|
||||
private Field getField(Class<?> clazz, String name) {
|
||||
try {
|
||||
Field field = clazz.getDeclaredField(name);
|
||||
|
@ -38,7 +38,6 @@ public class FastQueue_1_8_3 extends SlowQueue {
|
||||
private final SendChunk chunksender;
|
||||
private final HashMap<ChunkWrapper, Chunk> toUpdate = new HashMap<>();
|
||||
private final RefMethod methodGetHandleChunk;
|
||||
private final RefConstructor MapChunk;
|
||||
private final RefMethod methodInitLighting;
|
||||
private final RefConstructor classBlockPositionConstructor;
|
||||
private final RefConstructor classChunkSectionConstructor;
|
||||
@ -53,8 +52,6 @@ public class FastQueue_1_8_3 extends SlowQueue {
|
||||
this.methodGetHandleChunk = classCraftChunk.getMethod("getHandle");
|
||||
RefClass classChunk = getRefClass("{nms}.Chunk");
|
||||
this.methodInitLighting = classChunk.getMethod("initLighting");
|
||||
RefClass classMapChunk = getRefClass("{nms}.PacketPlayOutMapChunk");
|
||||
this.MapChunk = classMapChunk.getConstructor(classChunk.getRealClass(), boolean.class, int.class);
|
||||
RefClass classBlockPosition = getRefClass("{nms}.BlockPosition");
|
||||
this.classBlockPositionConstructor = classBlockPosition.getConstructor(int.class, int.class, int.class);
|
||||
RefClass classWorld = getRefClass("{nms}.World");
|
||||
|
@ -11,26 +11,27 @@ import org.bukkit.OfflinePlayer;
|
||||
import java.util.UUID;
|
||||
|
||||
public class DefaultUUIDWrapper extends UUIDWrapper {
|
||||
|
||||
@Override
|
||||
public UUID getUUID(PlotPlayer player) {
|
||||
return ((BukkitPlayer) player).player.getUniqueId();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public UUID getUUID(OfflinePlotPlayer player) {
|
||||
return player.getUUID();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public OfflinePlotPlayer getOfflinePlayer(UUID uuid) {
|
||||
return new BukkitOfflinePlayer(Bukkit.getOfflinePlayer(uuid));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public UUID getUUID(String name) {
|
||||
return Bukkit.getOfflinePlayer(name).getUniqueId();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public OfflinePlotPlayer[] getOfflinePlayers() {
|
||||
OfflinePlayer[] ops = Bukkit.getOfflinePlayers();
|
||||
@ -40,7 +41,7 @@ public class DefaultUUIDWrapper extends UUIDWrapper {
|
||||
}
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public OfflinePlotPlayer getOfflinePlayer(String name) {
|
||||
return new BukkitOfflinePlayer(Bukkit.getOfflinePlayer(name));
|
||||
|
@ -1,106 +1,32 @@
|
||||
package com.plotsquared.bukkit.uuid;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
import com.google.common.collect.BiMap;
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.object.OfflinePlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.StringWrapper;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.plotsquared.bukkit.object.BukkitOfflinePlayer;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Collection;
|
||||
import java.util.UUID;
|
||||
|
||||
public class LowerOfflineUUIDWrapper extends OfflineUUIDWrapper {
|
||||
private final Object[] arg = new Object[0];
|
||||
private Method getOnline = null;
|
||||
|
||||
public LowerOfflineUUIDWrapper() {
|
||||
try {
|
||||
this.getOnline = Server.class.getMethod("getOnlinePlayers");
|
||||
} catch (NoSuchMethodException | SecurityException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public UUID getUUID(PlotPlayer player) {
|
||||
return UUID.nameUUIDFromBytes(("OfflinePlayer:" + player.getName().toLowerCase()).getBytes(Charsets.UTF_8));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public UUID getUUID(OfflinePlotPlayer player) {
|
||||
return UUID.nameUUIDFromBytes(("OfflinePlayer:" + player.getName().toLowerCase()).getBytes(Charsets.UTF_8));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public UUID getUUID(OfflinePlayer player) {
|
||||
return UUID.nameUUIDFromBytes(("OfflinePlayer:" + player.getName().toLowerCase()).getBytes(Charsets.UTF_8));
|
||||
}
|
||||
|
||||
@Override
|
||||
public OfflinePlotPlayer getOfflinePlayer(UUID uuid) {
|
||||
BiMap<UUID, StringWrapper> map = UUIDHandler.getUuidMap().inverse();
|
||||
String name;
|
||||
try {
|
||||
name = map.get(uuid).value;
|
||||
} catch (NullPointerException e) {
|
||||
name = null;
|
||||
}
|
||||
if (name != null) {
|
||||
OfflinePlayer op = Bukkit.getOfflinePlayer(name);
|
||||
if (op.hasPlayedBefore()) {
|
||||
return new BukkitOfflinePlayer(op);
|
||||
}
|
||||
}
|
||||
for (OfflinePlayer player : Bukkit.getOfflinePlayers()) {
|
||||
if (getUUID(player).equals(uuid)) {
|
||||
return new BukkitOfflinePlayer(player);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Player[] getOnlinePlayers() {
|
||||
if (this.getOnline == null) {
|
||||
Collection<? extends Player> onlinePlayers = Bukkit.getOnlinePlayers();
|
||||
return onlinePlayers.toArray(new Player[onlinePlayers.size()]);
|
||||
}
|
||||
try {
|
||||
Object players = this.getOnline.invoke(Bukkit.getServer(), this.arg);
|
||||
if (players instanceof Player[]) {
|
||||
return (Player[]) players;
|
||||
} else {
|
||||
@SuppressWarnings("unchecked") Collection<? extends Player> p = (Collection<? extends Player>) players;
|
||||
return p.toArray(new Player[p.size()]);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
PS.debug("Failed to resolve online players");
|
||||
this.getOnline = null;
|
||||
Collection<? extends Player> onlinePlayers = Bukkit.getOnlinePlayers();
|
||||
return onlinePlayers.toArray(new Player[onlinePlayers.size()]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public UUID getUUID(String name) {
|
||||
return UUID.nameUUIDFromBytes(("OfflinePlayer:" + name.toLowerCase()).getBytes(Charsets.UTF_8));
|
||||
}
|
||||
|
||||
@Override
|
||||
public OfflinePlotPlayer[] getOfflinePlayers() {
|
||||
OfflinePlayer[] ops = Bukkit.getOfflinePlayers();
|
||||
BukkitOfflinePlayer[] toReturn = new BukkitOfflinePlayer[ops.length];
|
||||
for (int i = 0; i < ops.length; i++) {
|
||||
toReturn[i] = new BukkitOfflinePlayer(ops[i]);
|
||||
}
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -19,9 +19,10 @@ import java.util.Collection;
|
||||
import java.util.UUID;
|
||||
|
||||
public class OfflineUUIDWrapper extends UUIDWrapper {
|
||||
|
||||
private final Object[] arg = new Object[0];
|
||||
private Method getOnline = null;
|
||||
|
||||
|
||||
public OfflineUUIDWrapper() {
|
||||
try {
|
||||
this.getOnline = Server.class.getMethod("getOnlinePlayers");
|
||||
@ -29,12 +30,12 @@ public class OfflineUUIDWrapper extends UUIDWrapper {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public UUID getUUID(PlotPlayer player) {
|
||||
return UUID.nameUUIDFromBytes(("OfflinePlayer:" + player.getName()).getBytes(Charsets.UTF_8));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public UUID getUUID(OfflinePlotPlayer player) {
|
||||
return UUID.nameUUIDFromBytes(("OfflinePlayer:" + player.getName()).getBytes(Charsets.UTF_8));
|
||||
@ -43,7 +44,7 @@ public class OfflineUUIDWrapper extends UUIDWrapper {
|
||||
public UUID getUUID(OfflinePlayer player) {
|
||||
return UUID.nameUUIDFromBytes(("OfflinePlayer:" + player.getName()).getBytes(Charsets.UTF_8));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public OfflinePlotPlayer getOfflinePlayer(UUID uuid) {
|
||||
BiMap<UUID, StringWrapper> map = UUIDHandler.getUuidMap().inverse();
|
||||
@ -66,7 +67,7 @@ public class OfflineUUIDWrapper extends UUIDWrapper {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public Player[] getOnlinePlayers() {
|
||||
if (this.getOnline == null) {
|
||||
Collection<? extends Player> onlinePlayers = Bukkit.getOnlinePlayers();
|
||||
@ -87,12 +88,12 @@ public class OfflineUUIDWrapper extends UUIDWrapper {
|
||||
return onlinePlayers.toArray(new Player[onlinePlayers.size()]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public UUID getUUID(String name) {
|
||||
return UUID.nameUUIDFromBytes(("OfflinePlayer:" + name).getBytes(Charsets.UTF_8));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public OfflinePlotPlayer[] getOfflinePlayers() {
|
||||
OfflinePlayer[] ops = Bukkit.getOfflinePlayers();
|
||||
@ -102,7 +103,7 @@ public class OfflineUUIDWrapper extends UUIDWrapper {
|
||||
}
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public OfflinePlotPlayer getOfflinePlayer(String name) {
|
||||
return new BukkitOfflinePlayer(Bukkit.getOfflinePlayer(name));
|
||||
|
Reference in New Issue
Block a user