Refactor + optimizations

This commit is contained in:
boy0001 2015-07-31 03:24:01 +10:00
parent 7ce300c47b
commit 4eae78590f
76 changed files with 457 additions and 303 deletions

View File

@ -30,6 +30,13 @@ public interface IPlotMain {
*/ */
File getDirectory(); File getDirectory();
/**
* Wrap a player into a PlotPlayer object
* @param obj
* @return
*/
PlotPlayer wrapPlayer(Object obj);
/** /**
* Disable the implementation * Disable the implementation
* - If a full disable isn't feasibly, just disable what it can * - If a full disable isn't feasibly, just disable what it can

View File

@ -50,8 +50,8 @@ import com.intellectualcrafters.plot.util.Permissions;
import com.intellectualcrafters.plot.util.SchematicHandler; import com.intellectualcrafters.plot.util.SchematicHandler;
import com.intellectualcrafters.plot.util.UUIDHandler; import com.intellectualcrafters.plot.util.UUIDHandler;
import com.intellectualcrafters.plot.uuid.UUIDWrapper; import com.intellectualcrafters.plot.uuid.UUIDWrapper;
import com.plotsquared.bukkit.util.bukkit.BukkitSetBlockManager; import com.plotsquared.bukkit.util.BukkitSetBlockManager;
import com.plotsquared.bukkit.util.bukkit.BukkitUtil; import com.plotsquared.bukkit.util.BukkitUtil;
/** /**
* PlotSquared API * PlotSquared API
@ -185,7 +185,7 @@ import com.plotsquared.bukkit.util.bukkit.BukkitUtil;
* *
* @return BukkitSetBlockManager * @return BukkitSetBlockManager
* *
* @see com.plotsquared.bukkit.util.bukkit.BukkitSetBlockManager * @see com.plotsquared.bukkit.util.BukkitSetBlockManager
*/ */
public BukkitSetBlockManager getBukkitBlockManager() { public BukkitSetBlockManager getBukkitBlockManager() {
return BukkitSetBlockManager.setBlockManager; return BukkitSetBlockManager.setBlockManager;

View File

@ -32,7 +32,7 @@ import com.intellectualcrafters.plot.util.EventUtil;
import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.Permissions;
import com.intellectualcrafters.plot.util.UUIDHandler; import com.intellectualcrafters.plot.util.UUIDHandler;
import com.plotsquared.bukkit.util.bukkit.uuid.SQLUUIDHandler; import com.plotsquared.bukkit.uuid.SQLUUIDHandler;
import com.plotsquared.general.commands.Argument; import com.plotsquared.general.commands.Argument;
import com.plotsquared.general.commands.CommandDeclaration; import com.plotsquared.general.commands.CommandDeclaration;

View File

@ -30,7 +30,6 @@ import java.util.Date;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
import com.intellectualcrafters.plot.util.StringMan;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.PS;
@ -47,6 +46,7 @@ import com.intellectualcrafters.plot.util.BlockManager;
import com.intellectualcrafters.plot.util.ChunkManager; import com.intellectualcrafters.plot.util.ChunkManager;
import com.intellectualcrafters.plot.util.ExpireManager; import com.intellectualcrafters.plot.util.ExpireManager;
import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.StringMan;
import com.intellectualcrafters.plot.util.UUIDHandler; import com.intellectualcrafters.plot.util.UUIDHandler;
import com.plotsquared.bukkit.util.BukkitHybridUtils; import com.plotsquared.bukkit.util.BukkitHybridUtils;
import com.plotsquared.general.commands.CommandDeclaration; import com.plotsquared.general.commands.CommandDeclaration;

View File

@ -32,7 +32,7 @@ import com.intellectualcrafters.plot.util.EventUtil;
import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.Permissions;
import com.intellectualcrafters.plot.util.UUIDHandler; import com.intellectualcrafters.plot.util.UUIDHandler;
import com.plotsquared.bukkit.util.bukkit.uuid.SQLUUIDHandler; import com.plotsquared.bukkit.uuid.SQLUUIDHandler;
import com.plotsquared.general.commands.Argument; import com.plotsquared.general.commands.Argument;
import com.plotsquared.general.commands.CommandDeclaration; import com.plotsquared.general.commands.CommandDeclaration;

View File

@ -24,8 +24,6 @@ import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import com.intellectualcrafters.plot.util.StringMan;
import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.database.DBFunc;
import com.intellectualcrafters.plot.flag.AbstractFlag; import com.intellectualcrafters.plot.flag.AbstractFlag;
@ -37,6 +35,7 @@ import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.Permissions;
import com.intellectualcrafters.plot.util.StringMan;
import com.plotsquared.general.commands.CommandDeclaration; import com.plotsquared.general.commands.CommandDeclaration;
@CommandDeclaration( @CommandDeclaration(

View File

@ -23,8 +23,6 @@ package com.intellectualcrafters.plot.commands;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import com.intellectualcrafters.plot.util.StringMan;
import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotPlayer;

View File

@ -25,9 +25,6 @@ import java.util.Collection;
import java.util.UUID; import java.util.UUID;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import com.intellectualcrafters.plot.util.StringMan;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.config.Settings; import com.intellectualcrafters.plot.config.Settings;
import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.database.DBFunc;
@ -146,7 +143,7 @@ public class Info extends SubCommand {
}; };
UUID uuid = player.getUUID(); UUID uuid = player.getUUID();
String name = MainUtil.getName(plot.owner); String name = MainUtil.getName(plot.owner);
inv.setItem(1, new PlotItemStack(388, (short) 0, 1, "&cPlot Info", new String[] { "&cID: &6" + plot.getId().toString(), "&cOwner: &6" + name, "&cAlias: &6" + plot.getSettings().getAlias(), "&cBiome: &6" + plot.getSettings().getBiome().toString().replaceAll("_", "").toLowerCase(), "&cCan Build: &6" + plot.isAdded(uuid), "&cIs Denied: &6" + plot.isDenied(uuid)})); inv.setItem(1, new PlotItemStack(388, (short) 0, 1, "&cPlot Info", new String[] { "&cID: &6" + plot.getId().toString(), "&cOwner: &6" + name, "&cAlias: &6" + plot.getSettings().getAlias(), "&cBiome: &6" + plot.getBiome().toString().replaceAll("_", "").toLowerCase(), "&cCan Build: &6" + plot.isAdded(uuid), "&cIs Denied: &6" + plot.isDenied(uuid)}));
inv.setItem(1, new PlotItemStack(388, (short) 0, 1, "&cTrusted", new String[] {"&cAmount: &6" + plot.getTrusted().size(), "&8Click to view a list of the trusted users"})); inv.setItem(1, new PlotItemStack(388, (short) 0, 1, "&cTrusted", new String[] {"&cAmount: &6" + plot.getTrusted().size(), "&8Click to view a list of the trusted users"}));
inv.setItem(1, new PlotItemStack(388, (short) 0, 1, "&cMembers", new String[] {"&cAmount: &6" + plot.getMembers().size(), "&8Click to view a list of plot members"})); inv.setItem(1, new PlotItemStack(388, (short) 0, 1, "&cMembers", new String[] {"&cAmount: &6" + plot.getMembers().size(), "&8Click to view a list of plot members"}));
inv.setItem(1, new PlotItemStack(388, (short) 0, 1, "&cDenied", new String[] {"&cDenied", "&cAmount: &6" + plot.getDenied().size(), "&8Click to view a list of denied players"})); inv.setItem(1, new PlotItemStack(388, (short) 0, 1, "&cDenied", new String[] {"&cDenied", "&cAmount: &6" + plot.getDenied().size(), "&8Click to view a list of denied players"}));

View File

@ -24,8 +24,6 @@ import java.util.ArrayList;
import java.util.HashSet; import java.util.HashSet;
import java.util.UUID; import java.util.UUID;
import com.intellectualcrafters.plot.util.StringMan;
import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Location;
@ -38,6 +36,7 @@ import com.intellectualcrafters.plot.util.EconHandler;
import com.intellectualcrafters.plot.util.EventUtil; import com.intellectualcrafters.plot.util.EventUtil;
import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.Permissions;
import com.intellectualcrafters.plot.util.StringMan;
import com.intellectualcrafters.plot.util.UUIDHandler; import com.intellectualcrafters.plot.util.UUIDHandler;
import com.plotsquared.general.commands.Argument; import com.plotsquared.general.commands.Argument;
import com.plotsquared.general.commands.CommandDeclaration; import com.plotsquared.general.commands.CommandDeclaration;

View File

@ -26,8 +26,6 @@ import java.util.Comparator;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.UUID; import java.util.UUID;
import com.intellectualcrafters.plot.util.StringMan;
import org.apache.commons.lang.mutable.MutableInt; import org.apache.commons.lang.mutable.MutableInt;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;

View File

@ -31,7 +31,7 @@ import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.Permissions;
import com.intellectualcrafters.plot.util.UUIDHandler; import com.intellectualcrafters.plot.util.UUIDHandler;
import com.plotsquared.bukkit.util.bukkit.uuid.SQLUUIDHandler; import com.plotsquared.bukkit.uuid.SQLUUIDHandler;
import com.plotsquared.general.commands.Argument; import com.plotsquared.general.commands.Argument;
import com.plotsquared.general.commands.CommandDeclaration; import com.plotsquared.general.commands.CommandDeclaration;

View File

@ -24,8 +24,6 @@ import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import com.intellectualcrafters.plot.util.StringMan;
import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.config.Configuration; import com.intellectualcrafters.plot.config.Configuration;

View File

@ -25,8 +25,6 @@ import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Map.Entry; import java.util.Map.Entry;
import com.intellectualcrafters.plot.util.StringMan;
import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.config.ConfigurationNode; import com.intellectualcrafters.plot.config.ConfigurationNode;
import com.intellectualcrafters.plot.config.Settings; import com.intellectualcrafters.plot.config.Settings;
@ -36,6 +34,7 @@ import com.intellectualcrafters.plot.object.SetupObject;
import com.intellectualcrafters.plot.util.BlockManager; import com.intellectualcrafters.plot.util.BlockManager;
import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.SetupUtils; import com.intellectualcrafters.plot.util.SetupUtils;
import com.intellectualcrafters.plot.util.StringMan;
import com.plotsquared.general.commands.CommandDeclaration; import com.plotsquared.general.commands.CommandDeclaration;
@CommandDeclaration( @CommandDeclaration(

View File

@ -20,7 +20,6 @@
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot.commands; package com.intellectualcrafters.plot.commands;
import com.intellectualcrafters.plot.util.StringMan;
import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Location;

View File

@ -32,7 +32,7 @@ import com.intellectualcrafters.plot.util.EventUtil;
import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.Permissions;
import com.intellectualcrafters.plot.util.UUIDHandler; import com.intellectualcrafters.plot.util.UUIDHandler;
import com.plotsquared.bukkit.util.bukkit.uuid.SQLUUIDHandler; import com.plotsquared.bukkit.uuid.SQLUUIDHandler;
import com.plotsquared.general.commands.Argument; import com.plotsquared.general.commands.Argument;
import com.plotsquared.general.commands.CommandDeclaration; import com.plotsquared.general.commands.CommandDeclaration;

View File

@ -30,7 +30,7 @@ import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.Permissions;
import com.intellectualcrafters.plot.util.UUIDHandler; import com.intellectualcrafters.plot.util.UUIDHandler;
import com.plotsquared.bukkit.util.bukkit.uuid.SQLUUIDHandler; import com.plotsquared.bukkit.uuid.SQLUUIDHandler;
import com.plotsquared.general.commands.Argument; import com.plotsquared.general.commands.Argument;
import com.plotsquared.general.commands.CommandDeclaration; import com.plotsquared.general.commands.CommandDeclaration;

View File

@ -27,7 +27,6 @@ import java.util.List;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.UUID; import java.util.UUID;
import com.intellectualcrafters.plot.util.StringMan;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.PS;
@ -43,9 +42,10 @@ import com.intellectualcrafters.plot.util.EconHandler;
import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.Permissions;
import com.intellectualcrafters.plot.util.StringComparison; import com.intellectualcrafters.plot.util.StringComparison;
import com.intellectualcrafters.plot.util.StringMan;
import com.intellectualcrafters.plot.util.UUIDHandler; import com.intellectualcrafters.plot.util.UUIDHandler;
import com.plotsquared.bukkit.chat.FancyMessage;
import com.plotsquared.bukkit.object.BukkitPlayer; import com.plotsquared.bukkit.object.BukkitPlayer;
import com.plotsquared.bukkit.util.bukkit.chat.FancyMessage;
import com.plotsquared.general.commands.CommandDeclaration; import com.plotsquared.general.commands.CommandDeclaration;
@CommandDeclaration( @CommandDeclaration(

View File

@ -12,7 +12,7 @@ import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.PlotGamemode; import com.intellectualcrafters.plot.util.PlotGamemode;
import com.intellectualcrafters.plot.util.PlotWeather; import com.intellectualcrafters.plot.util.PlotWeather;
public class ConsolePlayer implements PlotPlayer { public class ConsolePlayer extends PlotPlayer {
private static ConsolePlayer instance; private static ConsolePlayer instance;
private Location loc; private Location loc;
@ -82,11 +82,6 @@ public class ConsolePlayer implements PlotPlayer {
this.loc = loc; this.loc = loc;
} }
@Override
public boolean isOp() {
return true;
}
@Override @Override
public boolean isOnline() { public boolean isOnline() {
return true; return true;

View File

@ -29,6 +29,7 @@ import java.util.UUID;
import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.database.DBFunc;
import com.intellectualcrafters.plot.flag.Flag; import com.intellectualcrafters.plot.flag.Flag;
import com.intellectualcrafters.plot.util.BlockManager;
import com.intellectualcrafters.plot.util.ChunkManager; import com.intellectualcrafters.plot.util.ChunkManager;
import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.MainUtil;
@ -473,6 +474,14 @@ public class Plot {
MainUtil.setBiome(this, biome, whenDone); MainUtil.setBiome(this, biome, whenDone);
} }
/**
* Get the biome (String)
*/
public String getBiome() {
final Location loc = getBottom().add(1, 0, 1);
return BlockManager.manager.getBiome(loc.getWorld(), loc.getX(), loc.getZ());
}
/** /**
* Return the top location for the plot * Return the top location for the plot
* @return * @return

View File

@ -1,9 +1,15 @@
package com.intellectualcrafters.plot.object; package com.intellectualcrafters.plot.object;
import java.util.Set;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.commands.RequiredType;
import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.PlotGamemode; import com.intellectualcrafters.plot.util.PlotGamemode;
import com.intellectualcrafters.plot.util.PlotWeather; import com.intellectualcrafters.plot.util.PlotWeather;
import com.intellectualcrafters.plot.util.UUIDHandler;
import com.plotsquared.general.commands.CommandCaller; import com.plotsquared.general.commands.CommandCaller;
/** /**
@ -11,33 +17,214 @@ import com.plotsquared.general.commands.CommandCaller;
* *
* @author Citymonstret * @author Citymonstret
*/ */
public interface PlotPlayer extends CommandCaller { public abstract class PlotPlayer implements CommandCaller {
long getPreviousLogin(); /**
* The metadata map
Location getLocation(); */
private ConcurrentHashMap<String, Object> meta;
Location getLocationFull();
UUID getUUID();
boolean hasPermission(final String perm);
void sendMessage(final String message);
void teleport(final Location loc); /**
* Wrap a Player object to get a PlotPlayer<br>
* - This will usually be cached, so no new object creation
* @param obj
* @return
*/
public static PlotPlayer wrap(Object obj) {
return PS.get().IMP.wrapPlayer(obj);
}
boolean isOp(); /**
* Get the cached PlotPlayer from a username<br>
* - This will return null if the player has just logged in or is not online
* @param name
* @return
*/
public static PlotPlayer get(String name) {
return UUIDHandler.getPlayer(name);
}
/**
* Set some session only metadata for the player
* @param key
* @param value
*/
public void setMeta(String key, Object value) {
if (this.meta == null) {
this.meta = new ConcurrentHashMap<String, Object>();
}
this.meta.put(key, value);
}
boolean isOnline(); /**
* Get the metadata for a key
* @param key
* @return
*/
public Object getMeta(String key) {
if (this.meta != null) {
return this.meta.get(key);
}
return null;
}
String getName(); /**
* Delete the metadata for a key<br>
* - metadata is session only
* - deleting other plugin's metadata may cause issues
* @param key
*/
public void deleteMeta(String key) {
if (this.meta != null) {
this.meta.remove(key);
}
}
void setCompassTarget(Location loc); /**
* Returns the player's name
* @see #getName()
*/
public String toString() {
return getName();
}
void loadData(); /**
* Get the player's current plot<br>
* - This is cached
* @return
*/
public Plot getCurrentPlot() {
return (Plot) getMeta("lastplot");
}
void saveData(); /**
* Get the total number of allowed plots
* @return
*/
public int getAllowedPlots() {
return MainUtil.getAllowedPlots(this);
}
/**
* Get the number of plots the player owns
* @return
*/
public int getPlotCount() {
return MainUtil.getPlayerPlotCount(this);
}
/**
* Get the number of plots the player owns in the world
* @param world
* @return
*/
public int getPlotCount(String world) {
return MainUtil.getPlayerPlotCount(world, this);
}
/**
* Get the plots the player owns
* @see #PS.java for more searching functions
* @return Set of plots
*/
public Set<Plot> getPlots() {
return PS.get().getPlots(this);
}
/**
* Return the PlotWorld the player is currently in, or null
* @return
*/
public PlotWorld getPlotWorld() {
return PS.get().getPlotWorld(getLocation().getWorld());
}
@Override
public RequiredType getSuperCaller() {
return RequiredType.PLAYER;
}
/////////////// PLAYER META ///////////////
////////////// PARTIALLY IMPLEMENTED ///////////
/**
* Get the player's last recorded location
* @return
*/
public Location getLocation() {
Location loc = (Location) getMeta("location");
if (loc != null) {
return loc;
}
return null;
}
////////////////////////////////////////////////
/**
* Get the previous time the player logged in
* @return
*/
public abstract long getPreviousLogin();
/**
* Get the player's full location (including yaw/pitch)
* @return
*/
public abstract Location getLocationFull();
/**
* Get the player's UUID
* @return
*/
public abstract UUID getUUID();
/**
* Check the player's permissions<br>
* - Will be cached if permission caching is enabled
*/
public abstract boolean hasPermission(final String perm);
/**
* Send the player a message
*/
public abstract void sendMessage(final String message);
/**
* Teleport the player to a location
* @param loc
*/
public abstract void teleport(final Location loc);
/**
* Is the player online
* @return
*/
public abstract boolean isOnline();
/**
* Get the player's name
* @return
*/
public abstract String getName();
/**
* Set the compass target
* @param loc
*/
public abstract void setCompassTarget(Location loc);
/**
* Load the player data from disk (if applicable)
*/
public abstract void loadData();
/**
* Save the player data from disk (if applicable)
*/
public abstract void saveData();
/** /**
* Set player data that will persist restarts * Set player data that will persist restarts
@ -45,35 +232,60 @@ public interface PlotPlayer extends CommandCaller {
* - For session only data use meta * - For session only data use meta
* @param key * @param key
*/ */
void setAttribute(String key); public abstract void setAttribute(String key);
/** /**
* The attribute will be either true or false * The attribute will be either true or false
* @param key * @param key
*/ */
boolean getAttribute(String key); public abstract boolean getAttribute(String key);
/** /**
* Remove an attribute from a player * Remove an attribute from a player
* @param key * @param key
*/ */
void removeAttribute(String key); public abstract void removeAttribute(String key);
void setMeta(String key, Object value); /**
Object getMeta(String key); * Set the player's local weather
void deleteMeta(String key); * @param weather
*/
public abstract void setWeather(PlotWeather weather);
void setWeather(PlotWeather weather); /**
* Get the player's gamemode
* @return
*/
public abstract PlotGamemode getGamemode();
PlotGamemode getGamemode(); /**
* Set the player's gamemode
* @param gamemode
*/
public abstract void setGamemode(PlotGamemode gamemode);
void setGamemode(PlotGamemode gamemode); /**
* Set the player's local time
* @param time
*/
public abstract void setTime(long time);
void setTime(long time); /**
* Set the player's fly mode
* @param fly
*/
public abstract void setFlight(boolean fly);
void setFlight(boolean fly); /**
* Play music at a location for the player
* @param loc
* @param id
*/
public abstract void playMusic(Location loc, int id);
void playMusic(Location loc, int id); /**
* Kick the player from the game
void kick(String message); * @param message
*/
public abstract void kick(String message);
} }

View File

@ -28,8 +28,6 @@ import java.util.UUID;
import com.intellectualcrafters.plot.flag.Flag; import com.intellectualcrafters.plot.flag.Flag;
import com.intellectualcrafters.plot.flag.FlagManager; import com.intellectualcrafters.plot.flag.FlagManager;
import com.intellectualcrafters.plot.object.comment.PlotComment; import com.intellectualcrafters.plot.object.comment.PlotComment;
import com.intellectualcrafters.plot.util.BlockManager;
import com.intellectualcrafters.plot.util.MainUtil;
/** /**
* plot settings * plot settings
@ -111,14 +109,6 @@ public class PlotSettings {
this.merged[direction] = merged; this.merged[direction] = merged;
} }
/**
* @return biome at plot loc
*/
public String getBiome() {
final Location loc = MainUtil.getPlotBottomLoc(this.plot.world, this.plot.getId()).add(1, 0, 1);
return BlockManager.manager.getBiome(loc.getWorld(), loc.getX(), loc.getZ());
}
public BlockLoc getPosition() { public BlockLoc getPosition() {
if (this.position == null) { if (this.position == null) {
return new BlockLoc(0, 0, 0); return new BlockLoc(0, 0, 0);

View File

@ -35,7 +35,7 @@ public enum Permissions {
public static boolean hasPermission(final PlotPlayer player, final String perm) { public static boolean hasPermission(final PlotPlayer player, final String perm) {
if ((player == null) || player.isOp() || player.hasPermission(ADMIN.s)) { if ((player == null) || player.hasPermission(ADMIN.s)) {
return true; return true;
} }
if (player.hasPermission(perm)) { if (player.hasPermission(perm)) {
@ -53,7 +53,7 @@ public enum Permissions {
} }
public static boolean hasPermission(final PlotPlayer player, final String perm, boolean notify) { public static boolean hasPermission(final PlotPlayer player, final String perm, boolean notify) {
if ((player == null) || player.isOp() || player.hasPermission(ADMIN.s)) { if ((player == null) || player.hasPermission(ADMIN.s)) {
return true; return true;
} }
if (player.hasPermission(perm)) { if (player.hasPermission(perm)) {
@ -74,7 +74,7 @@ public enum Permissions {
} }
public static int hasPermissionRange(final PlotPlayer player, final String stub, final int range) { public static int hasPermissionRange(final PlotPlayer player, final String stub, final int range) {
if ((player == null) || player.isOp() || player.hasPermission(ADMIN.s)) { if ((player == null) || player.hasPermission(ADMIN.s)) {
return Integer.MAX_VALUE; return Integer.MAX_VALUE;
} }
if (player.hasPermission(stub + ".*")) { if (player.hasPermission(stub + ".*")) {

View File

@ -2,13 +2,16 @@ package com.plotsquared.bukkit;
import java.io.File; import java.io.File;
import java.util.Arrays; import java.util.Arrays;
import java.util.UUID;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.OfflinePlayer;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.command.PluginCommand; import org.bukkit.command.PluginCommand;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.generator.ChunkGenerator; import org.bukkit.generator.ChunkGenerator;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
@ -36,9 +39,9 @@ import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.SchematicHandler; import com.intellectualcrafters.plot.util.SchematicHandler;
import com.intellectualcrafters.plot.util.SetupUtils; import com.intellectualcrafters.plot.util.SetupUtils;
import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.TaskManager;
import com.intellectualcrafters.plot.util.UUIDHandler;
import com.intellectualcrafters.plot.util.UUIDHandlerImplementation; import com.intellectualcrafters.plot.util.UUIDHandlerImplementation;
import com.intellectualcrafters.plot.uuid.UUIDWrapper; import com.intellectualcrafters.plot.uuid.UUIDWrapper;
import com.plotsquared.bukkit.commands.BukkitCommand;
import com.plotsquared.bukkit.database.plotme.ClassicPlotMeConnector; import com.plotsquared.bukkit.database.plotme.ClassicPlotMeConnector;
import com.plotsquared.bukkit.database.plotme.LikePlotMeConverter; import com.plotsquared.bukkit.database.plotme.LikePlotMeConverter;
import com.plotsquared.bukkit.database.plotme.PlotMeConnector_017; import com.plotsquared.bukkit.database.plotme.PlotMeConnector_017;
@ -55,27 +58,28 @@ import com.plotsquared.bukkit.listeners.WorldEvents;
import com.plotsquared.bukkit.listeners.worldedit.WEListener; import com.plotsquared.bukkit.listeners.worldedit.WEListener;
import com.plotsquared.bukkit.listeners.worldedit.WESubscriber; import com.plotsquared.bukkit.listeners.worldedit.WESubscriber;
import com.plotsquared.bukkit.titles.DefaultTitle; import com.plotsquared.bukkit.titles.DefaultTitle;
import com.plotsquared.bukkit.util.BukkitChunkManager;
import com.plotsquared.bukkit.util.BukkitCommand;
import com.plotsquared.bukkit.util.BukkitEconHandler;
import com.plotsquared.bukkit.util.BukkitEventUtil;
import com.plotsquared.bukkit.util.BukkitHybridUtils; import com.plotsquared.bukkit.util.BukkitHybridUtils;
import com.plotsquared.bukkit.util.bukkit.BukkitChunkManager; import com.plotsquared.bukkit.util.BukkitInventoryUtil;
import com.plotsquared.bukkit.util.bukkit.BukkitEconHandler; import com.plotsquared.bukkit.util.BukkitSchematicHandler;
import com.plotsquared.bukkit.util.bukkit.BukkitEventUtil; import com.plotsquared.bukkit.util.BukkitSetBlockManager;
import com.plotsquared.bukkit.util.bukkit.BukkitInventoryUtil; import com.plotsquared.bukkit.util.BukkitSetupUtils;
import com.plotsquared.bukkit.util.bukkit.BukkitSchematicHandler; import com.plotsquared.bukkit.util.BukkitTaskManager;
import com.plotsquared.bukkit.util.bukkit.BukkitSetBlockManager; import com.plotsquared.bukkit.util.BukkitUtil;
import com.plotsquared.bukkit.util.bukkit.BukkitSetupUtils; import com.plotsquared.bukkit.util.Metrics;
import com.plotsquared.bukkit.util.bukkit.BukkitTaskManager; import com.plotsquared.bukkit.util.SendChunk;
import com.plotsquared.bukkit.util.bukkit.BukkitUtil; import com.plotsquared.bukkit.util.SetBlockFast;
import com.plotsquared.bukkit.util.bukkit.Metrics; import com.plotsquared.bukkit.util.SetBlockFast_1_8;
import com.plotsquared.bukkit.util.bukkit.SendChunk; import com.plotsquared.bukkit.util.SetBlockSlow;
import com.plotsquared.bukkit.util.bukkit.SetBlockFast; import com.plotsquared.bukkit.util.SetGenCB;
import com.plotsquared.bukkit.util.bukkit.SetBlockFast_1_8;
import com.plotsquared.bukkit.util.bukkit.SetBlockSlow;
import com.plotsquared.bukkit.util.bukkit.SetGenCB;
import com.plotsquared.bukkit.util.bukkit.uuid.FileUUIDHandler;
import com.plotsquared.bukkit.util.bukkit.uuid.SQLUUIDHandler;
import com.plotsquared.bukkit.uuid.DefaultUUIDWrapper; import com.plotsquared.bukkit.uuid.DefaultUUIDWrapper;
import com.plotsquared.bukkit.uuid.FileUUIDHandler;
import com.plotsquared.bukkit.uuid.LowerOfflineUUIDWrapper; import com.plotsquared.bukkit.uuid.LowerOfflineUUIDWrapper;
import com.plotsquared.bukkit.uuid.OfflineUUIDWrapper; import com.plotsquared.bukkit.uuid.OfflineUUIDWrapper;
import com.plotsquared.bukkit.uuid.SQLUUIDHandler;
import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.bukkit.WorldEditPlugin; import com.sk89q.worldedit.bukkit.WorldEditPlugin;
@ -543,4 +547,21 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
// Already initialized in UUID handler // Already initialized in UUID handler
return AbstractTitle.TITLE_CLASS; return AbstractTitle.TITLE_CLASS;
} }
@Override
public PlotPlayer wrapPlayer(Object obj) {
if (obj instanceof Player) {
return BukkitUtil.getPlayer((Player) obj);
}
else if (obj instanceof OfflinePlayer) {
return BukkitUtil.getPlayer((OfflinePlayer) obj);
}
else if (obj instanceof String) {
return UUIDHandler.getPlayer((String) obj);
}
else if (obj instanceof UUID) {
return UUIDHandler.getPlayer((UUID) obj);
}
return null;
}
} }

View File

@ -1,4 +1,4 @@
package com.plotsquared.bukkit.util.bukkit.chat; package com.plotsquared.bukkit.chat;
import java.lang.reflect.Array; import java.lang.reflect.Array;
import java.util.Arrays; import java.util.Arrays;

View File

@ -1,6 +1,6 @@
package com.plotsquared.bukkit.util.bukkit.chat; package com.plotsquared.bukkit.chat;
import static com.plotsquared.bukkit.util.bukkit.chat.TextualComponent.rawText; import static com.plotsquared.bukkit.chat.TextualComponent.rawText;
import java.io.IOException; import java.io.IOException;
import java.io.StringWriter; import java.io.StringWriter;

View File

@ -1,4 +1,4 @@
package com.plotsquared.bukkit.util.bukkit.chat; package com.plotsquared.bukkit.chat;
import java.io.IOException; import java.io.IOException;

View File

@ -1,4 +1,4 @@
package com.plotsquared.bukkit.util.bukkit.chat; package com.plotsquared.bukkit.chat;
import java.io.IOException; import java.io.IOException;
import java.util.HashMap; import java.util.HashMap;

View File

@ -1,4 +1,4 @@
package com.plotsquared.bukkit.util.bukkit.chat; package com.plotsquared.bukkit.chat;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;

View File

@ -1,4 +1,4 @@
package com.plotsquared.bukkit.util.bukkit.chat; package com.plotsquared.bukkit.chat;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.lang.reflect.Method; import java.lang.reflect.Method;

View File

@ -1,4 +1,4 @@
package com.plotsquared.bukkit.util.bukkit.chat; package com.plotsquared.bukkit.chat;
import java.io.IOException; import java.io.IOException;
import java.util.HashMap; import java.util.HashMap;

View File

@ -23,8 +23,8 @@ import com.intellectualcrafters.plot.object.RegionWrapper;
import com.intellectualcrafters.plot.util.ChunkManager; import com.intellectualcrafters.plot.util.ChunkManager;
import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.TaskManager;
import com.plotsquared.bukkit.util.bukkit.BukkitChunkManager; import com.plotsquared.bukkit.util.BukkitChunkManager;
import com.plotsquared.bukkit.util.bukkit.BukkitSetBlockManager; import com.plotsquared.bukkit.util.BukkitSetBlockManager;
public class AugmentedPopulator extends BlockPopulator { public class AugmentedPopulator extends BlockPopulator {
public final PlotWorld plotworld; public final PlotWorld plotworld;

View File

@ -40,7 +40,6 @@ import com.intellectualcrafters.plot.object.RegionWrapper;
import com.intellectualcrafters.plot.object.SetupObject; import com.intellectualcrafters.plot.object.SetupObject;
import com.intellectualcrafters.plot.util.ChunkManager; import com.intellectualcrafters.plot.util.ChunkManager;
import com.plotsquared.bukkit.listeners.WorldEvents; import com.plotsquared.bukkit.listeners.WorldEvents;
import com.plotsquared.bukkit.object.BukkitPlotPopulator;
public abstract class BukkitPlotGenerator extends ChunkGenerator { public abstract class BukkitPlotGenerator extends ChunkGenerator {

View File

@ -1,4 +1,4 @@
package com.plotsquared.bukkit.object; package com.plotsquared.bukkit.generator;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map.Entry; import java.util.Map.Entry;

View File

@ -36,7 +36,6 @@ import com.intellectualcrafters.plot.object.PlotManager;
import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.object.PlotWorld;
import com.intellectualcrafters.plot.object.PseudoRandom; import com.intellectualcrafters.plot.object.PseudoRandom;
import com.intellectualcrafters.plot.object.RegionWrapper; import com.intellectualcrafters.plot.object.RegionWrapper;
import com.plotsquared.bukkit.object.BukkitPlotPopulator;
/** /**
* The default generator is very messy, as we have decided to try externalize all calculations from within the loop. - * The default generator is very messy, as we have decided to try externalize all calculations from within the loop. -

View File

@ -14,7 +14,6 @@ import com.intellectualcrafters.plot.object.PseudoRandom;
import com.intellectualcrafters.plot.object.RegionWrapper; import com.intellectualcrafters.plot.object.RegionWrapper;
import com.intellectualcrafters.plot.object.schematic.PlotItem; import com.intellectualcrafters.plot.object.schematic.PlotItem;
import com.intellectualcrafters.plot.util.BlockManager; import com.intellectualcrafters.plot.util.BlockManager;
import com.plotsquared.bukkit.object.BukkitPlotPopulator;
/** /**
* @author Citymonstret * @author Citymonstret

View File

@ -18,7 +18,7 @@ import com.intellectualcrafters.plot.object.PlotId;
import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.object.PlotWorld;
import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.MainUtil;
import com.plotsquared.bukkit.util.bukkit.BukkitUtil; import com.plotsquared.bukkit.util.BukkitUtil;
/** /**
* Created 2015-07-13 for PlotSquaredGit * Created 2015-07-13 for PlotSquaredGit

View File

@ -36,8 +36,8 @@ import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.util.UUIDHandler; import com.intellectualcrafters.plot.util.UUIDHandler;
import com.plotsquared.bukkit.events.PlayerEnterPlotEvent; import com.plotsquared.bukkit.events.PlayerEnterPlotEvent;
import com.plotsquared.bukkit.util.bukkit.BukkitPlayerFunctions; import com.plotsquared.bukkit.util.BukkitPlayerFunctions;
import com.plotsquared.bukkit.util.bukkit.BukkitUtil; import com.plotsquared.bukkit.util.BukkitUtil;
/** /**
* @author Citymonstret * @author Citymonstret

View File

@ -142,7 +142,7 @@ import com.intellectualcrafters.plot.util.UUIDHandler;
import com.plotsquared.bukkit.listeners.worldedit.WEManager; import com.plotsquared.bukkit.listeners.worldedit.WEManager;
import com.plotsquared.bukkit.object.BukkitLazyBlock; import com.plotsquared.bukkit.object.BukkitLazyBlock;
import com.plotsquared.bukkit.object.BukkitPlayer; import com.plotsquared.bukkit.object.BukkitPlayer;
import com.plotsquared.bukkit.util.bukkit.BukkitUtil; import com.plotsquared.bukkit.util.BukkitUtil;
/** /**
* Player Events involving plots * Player Events involving plots
@ -445,6 +445,10 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
player.saveData(); player.saveData();
} }
final PlotPlayer pp = BukkitUtil.getPlayer(player); final PlotPlayer pp = BukkitUtil.getPlayer(player);
// Set last location
pp.setMeta("location", BukkitUtil.getLocation(player.getLocation()));
final String username = pp.getName(); final String username = pp.getName();
final StringWrapper name = new StringWrapper(username); final StringWrapper name = new StringWrapper(username);
final UUID uuid = pp.getUUID(); final UUID uuid = pp.getUUID();
@ -485,6 +489,12 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
org.bukkit.Location to = event.getTo(); org.bukkit.Location to = event.getTo();
int x2; int x2;
if (getInt(from.getX()) != (x2 = getInt(to.getX()))) { if (getInt(from.getX()) != (x2 = getInt(to.getX()))) {
Player player = event.getPlayer();
PlotPlayer pp = BukkitUtil.getPlayer(player);
// Set last location
pp.setMeta("location", BukkitUtil.getLocation(to));
String worldname = to.getWorld().getName(); String worldname = to.getWorld().getName();
PlotWorld plotworld = PS.get().getPlotWorld(worldname); PlotWorld plotworld = PS.get().getPlotWorld(worldname);
if (plotworld == null) { if (plotworld == null) {
@ -492,8 +502,6 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
} }
PlotManager plotManager = PS.get().getPlotManager(worldname); PlotManager plotManager = PS.get().getPlotManager(worldname);
PlotId id = plotManager.getPlotId(plotworld, x2, 0, getInt(to.getZ())); PlotId id = plotManager.getPlotId(plotworld, x2, 0, getInt(to.getZ()));
Player player = event.getPlayer();
PlotPlayer pp = BukkitUtil.getPlayer(player);
Plot lastPlot = (Plot) pp.getMeta("lastplot"); Plot lastPlot = (Plot) pp.getMeta("lastplot");
if (id == null) { if (id == null) {
if (lastPlot == null) { if (lastPlot == null) {
@ -547,6 +555,12 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
} }
int z2; int z2;
if (getInt(from.getZ()) != (z2 = getInt(to.getZ())) ) { if (getInt(from.getZ()) != (z2 = getInt(to.getZ())) ) {
Player player = event.getPlayer();
PlotPlayer pp = BukkitUtil.getPlayer(player);
// Set last location
pp.setMeta("location", BukkitUtil.getLocation(to));
String worldname = to.getWorld().getName(); String worldname = to.getWorld().getName();
PlotWorld plotworld = PS.get().getPlotWorld(worldname); PlotWorld plotworld = PS.get().getPlotWorld(worldname);
if (plotworld == null) { if (plotworld == null) {
@ -554,8 +568,6 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
} }
PlotManager plotManager = PS.get().getPlotManager(worldname); PlotManager plotManager = PS.get().getPlotManager(worldname);
PlotId id = plotManager.getPlotId(plotworld, x2, 0, z2); PlotId id = plotManager.getPlotId(plotworld, x2, 0, z2);
Player player = event.getPlayer();
PlotPlayer pp = BukkitUtil.getPlayer(player);
Plot lastPlot = (Plot) pp.getMeta("lastplot"); Plot lastPlot = (Plot) pp.getMeta("lastplot");
if (id == null) { if (id == null) {
if (lastPlot == null) { if (lastPlot == null) {
@ -722,13 +734,19 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onWorldChanged(final PlayerChangedWorldEvent event) { public void onWorldChanged(final PlayerChangedWorldEvent event) {
final PlotPlayer player = BukkitUtil.getPlayer(event.getPlayer()); Player player = event.getPlayer();
final PlotPlayer pp = BukkitUtil.getPlayer(player);
// Delete last location
BukkitUtil.getPlayer(event.getPlayer()).deleteMeta("location");
BukkitUtil.getPlayer(event.getPlayer()).deleteMeta("lastplot");
if (PS.get().worldEdit != null) { if (PS.get().worldEdit != null) {
if (!Permissions.hasPermission(player, PERMISSION_WORLDEDIT_BYPASS)) { if (!Permissions.hasPermission(pp, PERMISSION_WORLDEDIT_BYPASS)) {
WEManager.bypass.remove(player.getName()); WEManager.bypass.remove(pp.getName());
} }
else { else {
WEManager.bypass.add(player.getName()); WEManager.bypass.add(pp.getName());
} }
} }
((BukkitPlayer) player).hasPerm = new HashSet<>(); ((BukkitPlayer) player).hasPerm = new HashSet<>();
@ -1382,6 +1400,8 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onTeleport(final PlayerTeleportEvent event) { public void onTeleport(final PlayerTeleportEvent event) {
if (event.getTo() == null || event.getFrom() == null) { if (event.getTo() == null || event.getFrom() == null) {
BukkitUtil.getPlayer(event.getPlayer()).deleteMeta("location");
BukkitUtil.getPlayer(event.getPlayer()).deleteMeta("lastplot");
return; return;
} }
final org.bukkit.Location from = event.getFrom(); final org.bukkit.Location from = event.getFrom();
@ -1389,6 +1409,12 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
int x2; int x2;
if (getInt(from.getX()) != (x2 = getInt(to.getX()))) { if (getInt(from.getX()) != (x2 = getInt(to.getX()))) {
Player player = event.getPlayer();
PlotPlayer pp = BukkitUtil.getPlayer(player);
// Set last location
pp.setMeta("location", BukkitUtil.getLocation(to));
String worldname = to.getWorld().getName(); String worldname = to.getWorld().getName();
PlotWorld plotworld = PS.get().getPlotWorld(worldname); PlotWorld plotworld = PS.get().getPlotWorld(worldname);
if (plotworld == null) { if (plotworld == null) {
@ -1396,8 +1422,6 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
} }
PlotManager plotManager = PS.get().getPlotManager(worldname); PlotManager plotManager = PS.get().getPlotManager(worldname);
PlotId id = plotManager.getPlotId(plotworld, x2, 0, getInt(to.getZ())); PlotId id = plotManager.getPlotId(plotworld, x2, 0, getInt(to.getZ()));
Player player = event.getPlayer();
PlotPlayer pp = BukkitUtil.getPlayer(player);
Plot lastPlot = (Plot) pp.getMeta("lastplot"); Plot lastPlot = (Plot) pp.getMeta("lastplot");
if (id == null) { if (id == null) {
if (lastPlot == null) { if (lastPlot == null) {
@ -1451,6 +1475,12 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
} }
int z2; int z2;
if (getInt(from.getZ()) != (z2 = getInt(to.getZ())) ) { if (getInt(from.getZ()) != (z2 = getInt(to.getZ())) ) {
Player player = event.getPlayer();
PlotPlayer pp = BukkitUtil.getPlayer(player);
// Set last location
pp.setMeta("location", BukkitUtil.getLocation(to));
String worldname = to.getWorld().getName(); String worldname = to.getWorld().getName();
PlotWorld plotworld = PS.get().getPlotWorld(worldname); PlotWorld plotworld = PS.get().getPlotWorld(worldname);
if (plotworld == null) { if (plotworld == null) {
@ -1458,8 +1488,6 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
} }
PlotManager plotManager = PS.get().getPlotManager(worldname); PlotManager plotManager = PS.get().getPlotManager(worldname);
PlotId id = plotManager.getPlotId(plotworld, x2, 0, z2); PlotId id = plotManager.getPlotId(plotworld, x2, 0, z2);
Player player = event.getPlayer();
PlotPlayer pp = BukkitUtil.getPlayer(player);
Plot lastPlot = (Plot) pp.getMeta("lastplot"); Plot lastPlot = (Plot) pp.getMeta("lastplot");
if (id == null) { if (id == null) {
if (lastPlot == null) { if (lastPlot == null) {

View File

@ -27,7 +27,7 @@ import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.Permissions;
import com.plotsquared.bukkit.util.bukkit.BukkitUtil; import com.plotsquared.bukkit.util.BukkitUtil;
import com.plotsquared.listener.PlotListener; import com.plotsquared.listener.PlotListener;
public class PlayerEvents_1_8 extends PlotListener implements Listener { public class PlayerEvents_1_8 extends PlotListener implements Listener {

View File

@ -13,7 +13,7 @@ import com.intellectualcrafters.plot.flag.FlagManager;
import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.MainUtil;
import com.plotsquared.bukkit.util.bukkit.BukkitUtil; import com.plotsquared.bukkit.util.BukkitUtil;
public class PlayerEvents_1_8_3 implements Listener { public class PlayerEvents_1_8_3 implements Listener {
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)

View File

@ -54,7 +54,7 @@ import com.intellectualcrafters.plot.util.Permissions;
import com.intellectualcrafters.plot.util.UUIDHandler; import com.intellectualcrafters.plot.util.UUIDHandler;
import com.plotsquared.bukkit.events.PlayerEnterPlotEvent; import com.plotsquared.bukkit.events.PlayerEnterPlotEvent;
import com.plotsquared.bukkit.events.PlayerLeavePlotEvent; import com.plotsquared.bukkit.events.PlayerLeavePlotEvent;
import com.plotsquared.bukkit.util.bukkit.BukkitUtil; import com.plotsquared.bukkit.util.BukkitUtil;
import com.plotsquared.listener.PlotListener; import com.plotsquared.listener.PlotListener;
/** /**

View File

@ -17,7 +17,7 @@ import com.intellectualcrafters.plot.flag.FlagManager;
import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.MainUtil;
import com.plotsquared.bukkit.util.bukkit.BukkitUtil; import com.plotsquared.bukkit.util.BukkitUtil;
public class TNTListener implements Listener { public class TNTListener implements Listener {
private double lastRadius; private double lastRadius;

View File

@ -19,7 +19,7 @@ import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.object.RegionWrapper; import com.intellectualcrafters.plot.object.RegionWrapper;
import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.Permissions;
import com.plotsquared.bukkit.util.bukkit.BukkitUtil; import com.plotsquared.bukkit.util.BukkitUtil;
import com.sk89q.worldedit.BlockVector; import com.sk89q.worldedit.BlockVector;
import com.sk89q.worldedit.bukkit.selections.Selection; import com.sk89q.worldedit.bukkit.selections.Selection;

View File

@ -1,6 +1,5 @@
package com.plotsquared.bukkit.object; package com.plotsquared.bukkit.object;
import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.UUID; import java.util.UUID;
@ -13,7 +12,6 @@ import org.bukkit.entity.Player;
import org.bukkit.permissions.Permission; import org.bukkit.permissions.Permission;
import org.bukkit.permissions.PermissionDefault; import org.bukkit.permissions.PermissionDefault;
import com.intellectualcrafters.plot.commands.RequiredType;
import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.config.Settings; import com.intellectualcrafters.plot.config.Settings;
import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Location;
@ -23,19 +21,16 @@ import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.PlotGamemode; import com.intellectualcrafters.plot.util.PlotGamemode;
import com.intellectualcrafters.plot.util.PlotWeather; import com.intellectualcrafters.plot.util.PlotWeather;
import com.intellectualcrafters.plot.util.UUIDHandler; import com.intellectualcrafters.plot.util.UUIDHandler;
import com.plotsquared.bukkit.util.bukkit.BukkitUtil; import com.plotsquared.bukkit.util.BukkitUtil;
public class BukkitPlayer implements PlotPlayer { public class BukkitPlayer extends PlotPlayer {
public final Player player; public final Player player;
private UUID uuid; private UUID uuid;
private String name; private String name;
private int op = 0;
private long last = 0; private long last = 0;
public HashSet<String> hasPerm = new HashSet<>(); public HashSet<String> hasPerm = new HashSet<>();
public HashSet<String> noPerm = new HashSet<>(); public HashSet<String> noPerm = new HashSet<>();
private HashMap<String, Object> meta;
/** /**
* Please do not use this method. Instead use BukkitUtil.getPlayer(Player), as it caches player objects. * Please do not use this method. Instead use BukkitUtil.getPlayer(Player), as it caches player objects.
@ -54,7 +49,8 @@ public class BukkitPlayer implements PlotPlayer {
@Override @Override
public Location getLocation() { public Location getLocation() {
return BukkitUtil.getLocation(this.player); Location loc = super.getLocation();
return loc == null ? BukkitUtil.getLocation(this.player) : loc;
} }
@Override @Override
@ -100,20 +96,6 @@ public class BukkitPlayer implements PlotPlayer {
this.player.teleport(new org.bukkit.Location(BukkitUtil.getWorld(loc.getWorld()), loc.getX() + 0.5, loc.getY(), loc.getZ() + 0.5, loc.getYaw(), loc.getPitch())); this.player.teleport(new org.bukkit.Location(BukkitUtil.getWorld(loc.getWorld()), loc.getX() + 0.5, loc.getY(), loc.getZ() + 0.5, loc.getYaw(), loc.getPitch()));
} }
@Override
public boolean isOp() {
if (this.op != 0) {
return this.op != 1;
}
final boolean result = this.player.isOp();
if (!result) {
this.op = 1;
return false;
}
this.op = 2;
return true;
}
@Override @Override
public String getName() { public String getName() {
if (this.name == null) { if (this.name == null) {
@ -138,34 +120,6 @@ public class BukkitPlayer implements PlotPlayer {
return BukkitUtil.getLocationFull(this.player); return BukkitUtil.getLocationFull(this.player);
} }
@Override
public void setMeta(String key, Object value) {
if (this.meta == null) {
this.meta = new HashMap<String, Object>();
}
this.meta.put(key, value);
}
@Override
public Object getMeta(String key) {
if (this.meta != null) {
return this.meta.get(key);
}
return null;
}
@Override
public void deleteMeta(String key) {
if (this.meta != null) {
this.meta.remove(key);
}
}
@Override
public String toString() {
return getName();
}
@Override @Override
public void setAttribute(String key) { public void setAttribute(String key) {
key = "plotsquared_user_attributes." + key; key = "plotsquared_user_attributes." + key;
@ -202,11 +156,6 @@ public class BukkitPlayer implements PlotPlayer {
player.saveData(); player.saveData();
} }
@Override
public RequiredType getSuperCaller() {
return RequiredType.PLAYER;
}
@Override @Override
public void setWeather(PlotWeather weather) { public void setWeather(PlotWeather weather) {
switch (weather) { switch (weather) {

View File

@ -1,4 +1,4 @@
package com.plotsquared.bukkit.util.bukkit; package com.plotsquared.bukkit.util;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;

View File

@ -1,4 +1,4 @@
package com.plotsquared.bukkit.commands; package com.plotsquared.bukkit.util;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
@ -16,7 +16,6 @@ import com.intellectualcrafters.plot.commands.MainCommand;
import com.intellectualcrafters.plot.object.ConsolePlayer; import com.intellectualcrafters.plot.object.ConsolePlayer;
import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.util.StringComparison; import com.intellectualcrafters.plot.util.StringComparison;
import com.plotsquared.bukkit.util.bukkit.BukkitUtil;
import com.plotsquared.general.commands.Command; import com.plotsquared.general.commands.Command;
/** /**

View File

@ -1,4 +1,4 @@
package com.plotsquared.bukkit.util.bukkit; package com.plotsquared.bukkit.util;
import net.milkbowl.vault.economy.Economy; import net.milkbowl.vault.economy.Economy;
import net.milkbowl.vault.permission.Permission; import net.milkbowl.vault.permission.Permission;

View File

@ -1,4 +1,4 @@
package com.plotsquared.bukkit.util.bukkit; package com.plotsquared.bukkit.util;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.UUID; import java.util.UUID;

View File

@ -37,7 +37,6 @@ import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.MathMan; import com.intellectualcrafters.plot.util.MathMan;
import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.TaskManager;
import com.plotsquared.bukkit.BukkitMain; import com.plotsquared.bukkit.BukkitMain;
import com.plotsquared.bukkit.util.bukkit.BukkitUtil;
public class BukkitHybridUtils extends HybridUtils { public class BukkitHybridUtils extends HybridUtils {

View File

@ -1,4 +1,4 @@
package com.plotsquared.bukkit.util.bukkit; package com.plotsquared.bukkit.util;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;

View File

@ -18,7 +18,7 @@
// / // /
// You can contact us via: support@intellectualsites.com / // You can contact us via: support@intellectualsites.com /
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
package com.plotsquared.bukkit.util.bukkit; package com.plotsquared.bukkit.util;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashSet; import java.util.HashSet;

View File

@ -18,7 +18,7 @@
// / // /
// You can contact us via: support@intellectualsites.com / // You can contact us via: support@intellectualsites.com /
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
package com.plotsquared.bukkit.util.bukkit; package com.plotsquared.bukkit.util;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;

View File

@ -1,4 +1,4 @@
package com.plotsquared.bukkit.util.bukkit; package com.plotsquared.bukkit.util;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;

View File

@ -1,4 +1,4 @@
package com.plotsquared.bukkit.util.bukkit; package com.plotsquared.bukkit.util;
import java.io.IOException; import java.io.IOException;
import java.util.Map.Entry; import java.util.Map.Entry;

View File

@ -1,4 +1,4 @@
package com.plotsquared.bukkit.util.bukkit; package com.plotsquared.bukkit.util;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;

View File

@ -1,4 +1,4 @@
package com.plotsquared.bukkit.util.bukkit; package com.plotsquared.bukkit.util;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
@ -23,7 +23,6 @@ import org.bukkit.material.Step;
import org.bukkit.material.Tree; import org.bukkit.material.Tree;
import org.bukkit.material.WoodenStep; import org.bukkit.material.WoodenStep;
import org.bukkit.material.Wool; import org.bukkit.material.Wool;
import org.spongepowered.api.world.extent.Extent;
import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.PlotBlock; import com.intellectualcrafters.plot.object.PlotBlock;

View File

@ -18,7 +18,7 @@
// / // /
// You can contact us via: support@intellectualsites.com / // You can contact us via: support@intellectualsites.com /
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
package com.plotsquared.bukkit.util.bukkit; package com.plotsquared.bukkit.util;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;

View File

@ -1,4 +1,4 @@
package com.plotsquared.bukkit.util.bukkit; package com.plotsquared.bukkit.util;
import static com.intellectualcrafters.plot.util.ReflectionUtils.callConstructor; import static com.intellectualcrafters.plot.util.ReflectionUtils.callConstructor;
import static com.intellectualcrafters.plot.util.ReflectionUtils.callMethod; import static com.intellectualcrafters.plot.util.ReflectionUtils.callMethod;

View File

@ -1,4 +1,4 @@
package com.plotsquared.bukkit.util.bukkit; package com.plotsquared.bukkit.util;
import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass; import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass;

View File

@ -18,7 +18,7 @@
// / // /
// You can contact us via: support@intellectualsites.com / // You can contact us via: support@intellectualsites.com /
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
package com.plotsquared.bukkit.util.bukkit; package com.plotsquared.bukkit.util;
import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass; import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass;

View File

@ -18,7 +18,7 @@
// / // /
// You can contact us via: support@intellectualsites.com / // You can contact us via: support@intellectualsites.com /
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
package com.plotsquared.bukkit.util.bukkit; package com.plotsquared.bukkit.util;
import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass; import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass;

View File

@ -1,4 +1,4 @@
package com.plotsquared.bukkit.util.bukkit; package com.plotsquared.bukkit.util;
import java.util.Collection; import java.util.Collection;

View File

@ -1,4 +1,4 @@
package com.plotsquared.bukkit.util.bukkit; package com.plotsquared.bukkit.util;
import java.lang.reflect.Constructor; import java.lang.reflect.Constructor;
import java.lang.reflect.Field; import java.lang.reflect.Field;

View File

@ -1,4 +1,4 @@
package com.plotsquared.bukkit.util.bukkit.uuid; package com.plotsquared.bukkit.uuid;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;

View File

@ -1,4 +1,4 @@
package com.plotsquared.bukkit.util.bukkit.uuid; package com.plotsquared.bukkit.uuid;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.IOException; import java.io.IOException;

View File

@ -11,6 +11,7 @@ import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -23,7 +24,6 @@ import org.spongepowered.api.block.BlockTypes;
import org.spongepowered.api.data.manipulator.block.StoneData; import org.spongepowered.api.data.manipulator.block.StoneData;
import org.spongepowered.api.entity.player.Player; import org.spongepowered.api.entity.player.Player;
import org.spongepowered.api.entity.player.gamemode.GameModes; import org.spongepowered.api.entity.player.gamemode.GameModes;
import org.spongepowered.api.event.EventHandler;
import org.spongepowered.api.event.Subscribe; import org.spongepowered.api.event.Subscribe;
import org.spongepowered.api.event.entity.player.PlayerChatEvent; import org.spongepowered.api.event.entity.player.PlayerChatEvent;
import org.spongepowered.api.event.state.PreInitializationEvent; import org.spongepowered.api.event.state.PreInitializationEvent;
@ -38,7 +38,6 @@ import org.spongepowered.api.text.translation.Translation;
import org.spongepowered.api.world.DimensionTypes; import org.spongepowered.api.world.DimensionTypes;
import org.spongepowered.api.world.GeneratorTypes; import org.spongepowered.api.world.GeneratorTypes;
import org.spongepowered.api.world.World; import org.spongepowered.api.world.World;
import org.spongepowered.api.world.gen.WorldGeneratorModifier;
import com.google.common.base.Optional; import com.google.common.base.Optional;
import com.google.inject.Inject; import com.google.inject.Inject;
@ -49,21 +48,18 @@ import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.config.Configuration; import com.intellectualcrafters.plot.config.Configuration;
import com.intellectualcrafters.plot.config.Settings; import com.intellectualcrafters.plot.config.Settings;
import com.intellectualcrafters.plot.generator.HybridUtils; import com.intellectualcrafters.plot.generator.HybridUtils;
import com.intellectualcrafters.plot.generator.PlotGenerator;
import com.intellectualcrafters.plot.object.PlotBlock; import com.intellectualcrafters.plot.object.PlotBlock;
import com.intellectualcrafters.plot.object.PlotManager;
import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.object.PlotWorld;
import com.intellectualcrafters.plot.util.AbstractTitle; import com.intellectualcrafters.plot.util.AbstractTitle;
import com.intellectualcrafters.plot.util.BlockManager; import com.intellectualcrafters.plot.util.BlockManager;
import com.intellectualcrafters.plot.util.ChunkManager; import com.intellectualcrafters.plot.util.ChunkManager;
import com.intellectualcrafters.plot.util.ConsoleColors;
import com.intellectualcrafters.plot.util.EconHandler; import com.intellectualcrafters.plot.util.EconHandler;
import com.intellectualcrafters.plot.util.EventUtil; import com.intellectualcrafters.plot.util.EventUtil;
import com.intellectualcrafters.plot.util.InventoryUtil; import com.intellectualcrafters.plot.util.InventoryUtil;
import com.intellectualcrafters.plot.util.SchematicHandler; import com.intellectualcrafters.plot.util.SchematicHandler;
import com.intellectualcrafters.plot.util.SetupUtils; import com.intellectualcrafters.plot.util.SetupUtils;
import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.TaskManager;
import com.intellectualcrafters.plot.util.UUIDHandler;
import com.intellectualcrafters.plot.util.UUIDHandlerImplementation; import com.intellectualcrafters.plot.util.UUIDHandlerImplementation;
import com.intellectualcrafters.plot.uuid.UUIDWrapper; import com.intellectualcrafters.plot.uuid.UUIDWrapper;
import com.plotsquared.sponge.generator.SpongeBasicGen; import com.plotsquared.sponge.generator.SpongeBasicGen;
@ -72,11 +68,13 @@ import com.plotsquared.sponge.generator.WorldModify;
import com.plotsquared.sponge.listener.MainListener; import com.plotsquared.sponge.listener.MainListener;
import com.plotsquared.sponge.util.KillRoadMobs; import com.plotsquared.sponge.util.KillRoadMobs;
import com.plotsquared.sponge.util.SpongeBlockManager; import com.plotsquared.sponge.util.SpongeBlockManager;
import com.plotsquared.sponge.util.SpongeChunkManager;
import com.plotsquared.sponge.util.SpongeCommand; import com.plotsquared.sponge.util.SpongeCommand;
import com.plotsquared.sponge.util.SpongeEventUtil; import com.plotsquared.sponge.util.SpongeEventUtil;
import com.plotsquared.sponge.util.SpongeInventoryUtil; import com.plotsquared.sponge.util.SpongeInventoryUtil;
import com.plotsquared.sponge.util.SpongeMetrics; import com.plotsquared.sponge.util.SpongeMetrics;
import com.plotsquared.sponge.util.SpongeTaskManager; import com.plotsquared.sponge.util.SpongeTaskManager;
import com.plotsquared.sponge.util.SpongeTitleManager;
import com.plotsquared.sponge.util.SpongeUtil; import com.plotsquared.sponge.util.SpongeUtil;
import com.plotsquared.sponge.uuid.SpongeLowerOfflineUUIDWrapper; import com.plotsquared.sponge.uuid.SpongeLowerOfflineUUIDWrapper;
import com.plotsquared.sponge.uuid.SpongeOnlineUUIDWrapper; import com.plotsquared.sponge.uuid.SpongeOnlineUUIDWrapper;
@ -596,4 +594,21 @@ public class SpongeMain implements IPlotMain, PluginContainer {
public AbstractTitle initTitleManager() { public AbstractTitle initTitleManager() {
return new SpongeTitleManager(); return new SpongeTitleManager();
} }
@Override
public PlotPlayer wrapPlayer(Object obj) {
if (obj instanceof Player) {
return SpongeUtil.getPlayer((Player) obj);
}
// else if (obj instanceof OfflinePlayer) {
// return BukkitUtil.getPlayer((OfflinePlayer) obj);
// }
else if (obj instanceof String) {
return UUIDHandler.getPlayer((String) obj);
}
else if (obj instanceof UUID) {
return UUIDHandler.getPlayer((UUID) obj);
}
return null;
}
} }

View File

@ -4,10 +4,6 @@ import org.spongepowered.api.data.DataContainer;
import org.spongepowered.api.world.WorldCreationSettings; import org.spongepowered.api.world.WorldCreationSettings;
import org.spongepowered.api.world.gen.WorldGenerator; import org.spongepowered.api.world.gen.WorldGenerator;
import org.spongepowered.api.world.gen.WorldGeneratorModifier; import org.spongepowered.api.world.gen.WorldGeneratorModifier;
import org.spongepowered.common.world.gen.SpongeWorldGenerator;
import com.intellectualcrafters.plot.PS;
import com.plotsquared.sponge.SpongeMain;
public class WorldModify implements WorldGeneratorModifier { public class WorldModify implements WorldGeneratorModifier {

View File

@ -22,7 +22,6 @@ import org.spongepowered.api.block.BlockState;
import org.spongepowered.api.entity.Entity; import org.spongepowered.api.entity.Entity;
import org.spongepowered.api.entity.EntityTypes; import org.spongepowered.api.entity.EntityTypes;
import org.spongepowered.api.entity.player.Player; import org.spongepowered.api.entity.player.Player;
import org.spongepowered.api.event.Cancellable;
import org.spongepowered.api.event.Subscribe; import org.spongepowered.api.event.Subscribe;
import org.spongepowered.api.event.block.BlockMoveEvent; import org.spongepowered.api.event.block.BlockMoveEvent;
import org.spongepowered.api.event.block.BlockRedstoneUpdateEvent; import org.spongepowered.api.event.block.BlockRedstoneUpdateEvent;
@ -36,20 +35,16 @@ import org.spongepowered.api.event.entity.player.PlayerChangeWorldEvent;
import org.spongepowered.api.event.entity.player.PlayerChatEvent; import org.spongepowered.api.event.entity.player.PlayerChatEvent;
import org.spongepowered.api.event.entity.player.PlayerInteractBlockEvent; import org.spongepowered.api.event.entity.player.PlayerInteractBlockEvent;
import org.spongepowered.api.event.entity.player.PlayerJoinEvent; import org.spongepowered.api.event.entity.player.PlayerJoinEvent;
import org.spongepowered.api.event.entity.player.PlayerMessageEvent;
import org.spongepowered.api.event.entity.player.PlayerMoveEvent; import org.spongepowered.api.event.entity.player.PlayerMoveEvent;
import org.spongepowered.api.event.entity.player.PlayerPlaceBlockEvent; import org.spongepowered.api.event.entity.player.PlayerPlaceBlockEvent;
import org.spongepowered.api.event.entity.player.PlayerQuitEvent; import org.spongepowered.api.event.entity.player.PlayerQuitEvent;
import org.spongepowered.api.event.message.CommandEvent; import org.spongepowered.api.event.message.CommandEvent;
import org.spongepowered.api.event.network.PlayerConnectionEvent; import org.spongepowered.api.event.network.PlayerConnectionEvent;
import org.spongepowered.api.event.world.ChunkLoadEvent;
import org.spongepowered.api.event.world.ChunkPreGenerateEvent; import org.spongepowered.api.event.world.ChunkPreGenerateEvent;
import org.spongepowered.api.event.world.ChunkPrePopulateEvent;
import org.spongepowered.api.network.PlayerConnection; import org.spongepowered.api.network.PlayerConnection;
import org.spongepowered.api.text.Text; import org.spongepowered.api.text.Text;
import org.spongepowered.api.text.Texts; import org.spongepowered.api.text.Texts;
import org.spongepowered.api.util.command.CommandSource; import org.spongepowered.api.util.command.CommandSource;
import org.spongepowered.api.util.event.callback.EventCallback;
import org.spongepowered.api.world.World; import org.spongepowered.api.world.World;
import org.spongepowered.api.world.extent.Extent; import org.spongepowered.api.world.extent.Extent;
@ -80,7 +75,7 @@ import com.intellectualcrafters.plot.util.UUIDHandler;
import com.plotsquared.bukkit.object.BukkitPlayer; import com.plotsquared.bukkit.object.BukkitPlayer;
import com.plotsquared.listener.PlotListener; import com.plotsquared.listener.PlotListener;
import com.plotsquared.sponge.SpongeMain; import com.plotsquared.sponge.SpongeMain;
import com.plotsquared.sponge.SpongePlayer; import com.plotsquared.sponge.object.SpongePlayer;
import com.plotsquared.sponge.util.SpongeUtil; import com.plotsquared.sponge.util.SpongeUtil;
public class MainListener { public class MainListener {
@ -557,10 +552,14 @@ public class MainListener {
org.spongepowered.api.world.Location to = event.getNewLocation(); org.spongepowered.api.world.Location to = event.getNewLocation();
int x2; int x2;
if (getInt(from.getX()) != (x2 = getInt(to.getX()))) { if (getInt(from.getX()) != (x2 = getInt(to.getX()))) {
Player player = event.getUser();
PlotPlayer pp = SpongeUtil.getPlayer(player);
Extent extent = to.getExtent(); Extent extent = to.getExtent();
if (!(extent instanceof World)) { if (!(extent instanceof World)) {
pp.deleteMeta("location");
return; return;
} }
pp.setMeta("location", SpongeUtil.getLocation(player));
World world = (World) extent; World world = (World) extent;
String worldname = ((World) extent).getName(); String worldname = ((World) extent).getName();
PlotWorld plotworld = PS.get().getPlotWorld(worldname); PlotWorld plotworld = PS.get().getPlotWorld(worldname);
@ -569,8 +568,6 @@ public class MainListener {
} }
PlotManager plotManager = PS.get().getPlotManager(worldname); PlotManager plotManager = PS.get().getPlotManager(worldname);
PlotId id = plotManager.getPlotId(plotworld, x2, 0, getInt(to.getZ())); PlotId id = plotManager.getPlotId(plotworld, x2, 0, getInt(to.getZ()));
Player player = event.getUser();
PlotPlayer pp = SpongeUtil.getPlayer(player);
Plot lastPlot = (Plot) pp.getMeta("lastplot"); Plot lastPlot = (Plot) pp.getMeta("lastplot");
if (id == null) { if (id == null) {
if (lastPlot == null) { if (lastPlot == null) {
@ -622,10 +619,14 @@ public class MainListener {
} }
int z2; int z2;
if (getInt(from.getZ()) != (z2 = getInt(to.getZ())) ) { if (getInt(from.getZ()) != (z2 = getInt(to.getZ())) ) {
Player player = event.getUser();
PlotPlayer pp = SpongeUtil.getPlayer(player);
Extent extent = to.getExtent(); Extent extent = to.getExtent();
if (!(extent instanceof World)) { if (!(extent instanceof World)) {
pp.deleteMeta("location");
return; return;
} }
pp.setMeta("location", SpongeUtil.getLocation(player));
World world = (World) extent; World world = (World) extent;
String worldname = ((World) extent).getName(); String worldname = ((World) extent).getName();
PlotWorld plotworld = PS.get().getPlotWorld(worldname); PlotWorld plotworld = PS.get().getPlotWorld(worldname);
@ -634,8 +635,6 @@ public class MainListener {
} }
PlotManager plotManager = PS.get().getPlotManager(worldname); PlotManager plotManager = PS.get().getPlotManager(worldname);
PlotId id = plotManager.getPlotId(plotworld, x2, 0, z2); PlotId id = plotManager.getPlotId(plotworld, x2, 0, z2);
Player player = event.getUser();
PlotPlayer pp = SpongeUtil.getPlayer(player);
Plot lastPlot = (Plot) pp.getMeta("lastplot"); Plot lastPlot = (Plot) pp.getMeta("lastplot");
if (id == null) { if (id == null) {
if (lastPlot == null) { if (lastPlot == null) {
@ -694,10 +693,14 @@ public class MainListener {
org.spongepowered.api.world.Location to = event.getNewLocation(); org.spongepowered.api.world.Location to = event.getNewLocation();
int x2; int x2;
if (getInt(from.getX()) != (x2 = getInt(to.getX()))) { if (getInt(from.getX()) != (x2 = getInt(to.getX()))) {
Player player = (Player) entity;
PlotPlayer pp = SpongeUtil.getPlayer(player);
Extent extent = to.getExtent(); Extent extent = to.getExtent();
if (!(extent instanceof World)) { if (!(extent instanceof World)) {
pp.deleteMeta("location");
return; return;
} }
pp.setMeta("location", SpongeUtil.getLocation(player));
World world = (World) extent; World world = (World) extent;
String worldname = ((World) extent).getName(); String worldname = ((World) extent).getName();
PlotWorld plotworld = PS.get().getPlotWorld(worldname); PlotWorld plotworld = PS.get().getPlotWorld(worldname);
@ -706,8 +709,6 @@ public class MainListener {
} }
PlotManager plotManager = PS.get().getPlotManager(worldname); PlotManager plotManager = PS.get().getPlotManager(worldname);
PlotId id = plotManager.getPlotId(plotworld, x2, 0, getInt(to.getZ())); PlotId id = plotManager.getPlotId(plotworld, x2, 0, getInt(to.getZ()));
Player player = (Player) entity;
PlotPlayer pp = SpongeUtil.getPlayer(player);
Plot lastPlot = (Plot) pp.getMeta("lastplot"); Plot lastPlot = (Plot) pp.getMeta("lastplot");
if (id == null) { if (id == null) {
if (lastPlot == null) { if (lastPlot == null) {
@ -759,10 +760,14 @@ public class MainListener {
} }
int z2; int z2;
if (getInt(from.getZ()) != (z2 = getInt(to.getZ())) ) { if (getInt(from.getZ()) != (z2 = getInt(to.getZ())) ) {
Player player = (Player) entity;
PlotPlayer pp = SpongeUtil.getPlayer(player);
Extent extent = to.getExtent(); Extent extent = to.getExtent();
if (!(extent instanceof World)) { if (!(extent instanceof World)) {
pp.deleteMeta("location");
return; return;
} }
pp.setMeta("location", SpongeUtil.getLocation(player));
World world = (World) extent; World world = (World) extent;
String worldname = ((World) extent).getName(); String worldname = ((World) extent).getName();
PlotWorld plotworld = PS.get().getPlotWorld(worldname); PlotWorld plotworld = PS.get().getPlotWorld(worldname);
@ -771,8 +776,6 @@ public class MainListener {
} }
PlotManager plotManager = PS.get().getPlotManager(worldname); PlotManager plotManager = PS.get().getPlotManager(worldname);
PlotId id = plotManager.getPlotId(plotworld, x2, 0, z2); PlotId id = plotManager.getPlotId(plotworld, x2, 0, z2);
Player player = (Player) entity;
PlotPlayer pp = SpongeUtil.getPlayer(player);
Plot lastPlot = (Plot) pp.getMeta("lastplot"); Plot lastPlot = (Plot) pp.getMeta("lastplot");
if (id == null) { if (id == null) {
if (lastPlot == null) { if (lastPlot == null) {
@ -828,6 +831,9 @@ public class MainListener {
public void onWorldChange(PlayerChangeWorldEvent event) { public void onWorldChange(PlayerChangeWorldEvent event) {
final PlotPlayer player = SpongeUtil.getPlayer(event.getUser()); final PlotPlayer player = SpongeUtil.getPlayer(event.getUser());
player.deleteMeta("location");
player.deleteMeta("lastplot");
// TODO worldedit mask // TODO worldedit mask
((BukkitPlayer) player).hasPerm = new HashSet<>(); ((BukkitPlayer) player).hasPerm = new HashSet<>();

View File

@ -1,20 +1,14 @@
package com.plotsquared.sponge; package com.plotsquared.sponge.object;
import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.UUID; import java.util.UUID;
import org.spongepowered.api.entity.player.Player; import org.spongepowered.api.entity.player.Player;
import org.spongepowered.api.entity.player.gamemode.GameMode; import org.spongepowered.api.entity.player.gamemode.GameMode;
import org.spongepowered.api.entity.player.gamemode.GameModes; import org.spongepowered.api.entity.player.gamemode.GameModes;
import org.spongepowered.api.service.permission.PermissionService;
import org.spongepowered.api.text.Texts;
import org.spongepowered.api.text.chat.ChatTypes; import org.spongepowered.api.text.chat.ChatTypes;
import org.spongepowered.api.text.title.Title;
import org.spongepowered.api.world.World;
import com.flowpowered.math.vector.Vector3d; import com.flowpowered.math.vector.Vector3d;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.commands.RequiredType; import com.intellectualcrafters.plot.commands.RequiredType;
import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.config.Settings; import com.intellectualcrafters.plot.config.Settings;
@ -25,19 +19,17 @@ import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.PlotGamemode; import com.intellectualcrafters.plot.util.PlotGamemode;
import com.intellectualcrafters.plot.util.PlotWeather; import com.intellectualcrafters.plot.util.PlotWeather;
import com.intellectualcrafters.plot.util.UUIDHandler; import com.intellectualcrafters.plot.util.UUIDHandler;
import com.plotsquared.sponge.SpongeMain;
import com.plotsquared.sponge.util.SpongeUtil; import com.plotsquared.sponge.util.SpongeUtil;
public class SpongePlayer implements PlotPlayer { public class SpongePlayer extends PlotPlayer {
public final Player player; public final Player player;
private UUID uuid; private UUID uuid;
private String name; private String name;
private int op = 0;
private long last = 0; private long last = 0;
private HashSet<String> hasPerm = new HashSet<>(); private HashSet<String> hasPerm = new HashSet<>();
private HashSet<String> noPerm = new HashSet<>(); private HashSet<String> noPerm = new HashSet<>();
private HashMap<String, Object> meta;
public SpongePlayer(Player player) { public SpongePlayer(Player player) {
this.player = player; this.player = player;
@ -60,7 +52,8 @@ public class SpongePlayer implements PlotPlayer {
@Override @Override
public Location getLocation() { public Location getLocation() {
return SpongeUtil.getLocation(player); Location loc = super.getLocation();
return loc == null ? SpongeUtil.getLocation(this.player) : loc;
} }
@Override @Override
@ -114,20 +107,6 @@ public class SpongePlayer implements PlotPlayer {
} }
} }
@Override
public boolean isOp() {
if (this.op != 0) {
return this.op != 1;
}
final boolean result = this.player.hasPermission("*");
if (!result) {
this.op = 1;
return false;
}
this.op = 2;
return true;
}
@Override @Override
public boolean isOnline() { public boolean isOnline() {
return player.isOnline(); return player.isOnline();
@ -159,34 +138,6 @@ public class SpongePlayer implements PlotPlayer {
throw new UnsupportedOperationException("NOT IMPLEMENTED YET"); throw new UnsupportedOperationException("NOT IMPLEMENTED YET");
} }
@Override
public void setMeta(String key, Object value) {
if (this.meta == null) {
this.meta = new HashMap<String, Object>();
}
this.meta.put(key, value);
}
@Override
public Object getMeta(String key) {
if (this.meta != null) {
return this.meta.get(key);
}
return null;
}
@Override
public void deleteMeta(String key) {
if (this.meta != null) {
this.meta.remove(key);
}
}
@Override
public String toString() {
return getName();
}
@Override @Override
public void setAttribute(String key) { public void setAttribute(String key) {
key = "plotsquared_user_attributes." + key; key = "plotsquared_user_attributes." + key;

View File

@ -12,7 +12,6 @@ import org.spongepowered.api.world.World;
import org.spongepowered.api.world.biome.BiomeType; import org.spongepowered.api.world.biome.BiomeType;
import org.spongepowered.api.world.biome.BiomeTypes; import org.spongepowered.api.world.biome.BiomeTypes;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.PlotBlock; import com.intellectualcrafters.plot.object.PlotBlock;
import com.intellectualcrafters.plot.object.schematic.PlotItem; import com.intellectualcrafters.plot.object.schematic.PlotItem;

View File

@ -1,27 +1,22 @@
package com.plotsquared.sponge; package com.plotsquared.sponge.util;
import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.bukkit.Bukkit;
import org.spongepowered.api.data.DataContainer; import org.spongepowered.api.data.DataContainer;
import org.spongepowered.api.world.Chunk; import org.spongepowered.api.world.Chunk;
import org.spongepowered.api.world.World; import org.spongepowered.api.world.World;
import org.spongepowered.api.world.storage.ChunkDataStream; import org.spongepowered.api.world.storage.ChunkDataStream;
import org.spongepowered.api.world.storage.WorldStorage;
import com.google.common.base.Optional; import com.google.common.base.Optional;
import com.google.common.util.concurrent.ListenableFuture;
import com.intellectualcrafters.plot.object.ChunkLoc; import com.intellectualcrafters.plot.object.ChunkLoc;
import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotBlock; import com.intellectualcrafters.plot.object.PlotBlock;
import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotId;
import com.intellectualcrafters.plot.util.ChunkManager; import com.intellectualcrafters.plot.util.ChunkManager;
import com.intellectualcrafters.plot.util.TaskManager;
import com.intellectualcrafters.plot.util.SetBlockQueue.ChunkWrapper; import com.intellectualcrafters.plot.util.SetBlockQueue.ChunkWrapper;
import com.plotsquared.sponge.util.SpongeUtil; import com.intellectualcrafters.plot.util.TaskManager;
public class SpongeChunkManager extends ChunkManager { public class SpongeChunkManager extends ChunkManager {

View File

@ -14,7 +14,6 @@ import org.spongepowered.api.util.command.CommandResult;
import org.spongepowered.api.util.command.CommandSource; import org.spongepowered.api.util.command.CommandSource;
import com.google.common.base.Optional; import com.google.common.base.Optional;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.commands.MainCommand; import com.intellectualcrafters.plot.commands.MainCommand;
import com.intellectualcrafters.plot.object.ConsolePlayer; import com.intellectualcrafters.plot.object.ConsolePlayer;
import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotPlayer;

View File

@ -20,7 +20,7 @@ import com.intellectualcrafters.plot.object.PlotItemStack;
import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.util.InventoryUtil; import com.intellectualcrafters.plot.util.InventoryUtil;
import com.plotsquared.sponge.SpongeMain; import com.plotsquared.sponge.SpongeMain;
import com.plotsquared.sponge.SpongePlayer; import com.plotsquared.sponge.object.SpongePlayer;
public class SpongeInventoryUtil extends InventoryUtil { public class SpongeInventoryUtil extends InventoryUtil {

View File

@ -1,10 +1,11 @@
package com.plotsquared.sponge; package com.plotsquared.sponge.util;
import org.spongepowered.api.text.title.Title; import org.spongepowered.api.text.title.Title;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.util.AbstractTitle; import com.intellectualcrafters.plot.util.AbstractTitle;
import com.plotsquared.sponge.SpongeMain;
import com.plotsquared.sponge.object.SpongePlayer;
public class SpongeTitleManager extends AbstractTitle { public class SpongeTitleManager extends AbstractTitle {

View File

@ -13,7 +13,7 @@ import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.util.MathMan; import com.intellectualcrafters.plot.util.MathMan;
import com.intellectualcrafters.plot.util.UUIDHandler; import com.intellectualcrafters.plot.util.UUIDHandler;
import com.plotsquared.sponge.SpongeMain; import com.plotsquared.sponge.SpongeMain;
import com.plotsquared.sponge.SpongePlayer; import com.plotsquared.sponge.object.SpongePlayer;
public class SpongeUtil { public class SpongeUtil {

View File

@ -7,7 +7,7 @@ import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.util.UUIDHandler; import com.intellectualcrafters.plot.util.UUIDHandler;
import com.intellectualcrafters.plot.uuid.UUIDWrapper; import com.intellectualcrafters.plot.uuid.UUIDWrapper;
import com.plotsquared.sponge.SpongeMain; import com.plotsquared.sponge.SpongeMain;
import com.plotsquared.sponge.SpongePlayer; import com.plotsquared.sponge.object.SpongePlayer;
public class SpongeOnlineUUIDWrapper extends UUIDWrapper { public class SpongeOnlineUUIDWrapper extends UUIDWrapper {