git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1192 e251c2fe-e539-e718-e476-b85c1f46cddb
This commit is contained in:
ementalo 2011-04-14 22:53:36 +00:00
parent bffaf98fcd
commit 7463d06594

View File

@ -624,9 +624,6 @@ public class User extends PlayerExtension implements Comparable<User>, IReplyTo
public void teleportToHome() public void teleportToHome()
{ {
teleportToHome(null); teleportToHome(null);
} }
public void teleportToNow(Location loc) throws Exception public void teleportToNow(Location loc) throws Exception
@ -634,9 +631,6 @@ public class User extends PlayerExtension implements Comparable<User>, IReplyTo
cancelTeleport(); cancelTeleport();
lastLocation = getLocation(); lastLocation = getLocation();
getBase().teleport(getSafeDestination(loc)); getBase().teleport(getSafeDestination(loc));
} }
public void teleportToNow(Entity entity) public void teleportToNow(Entity entity)
@ -644,41 +638,26 @@ public class User extends PlayerExtension implements Comparable<User>, IReplyTo
cancelTeleport(); cancelTeleport();
lastLocation = getLocation(); lastLocation = getLocation();
getBase().teleport(entity); getBase().teleport(entity);
} }
public void teleportBack(final String chargeFor) public void teleportBack(final String chargeFor)
{ {
teleportTo(lastLocation, chargeFor); teleportTo(lastLocation, chargeFor);
} }
public void teleportBack() public void teleportBack()
{ {
teleportBack(null); teleportBack(null);
} }
public void dispose() public void dispose()
{ {
this.base = new OfflinePlayer(getName()); this.base = new OfflinePlayer(getName());
} }
public void charge(IEssentialsCommand cmd) throws Exception public void charge(IEssentialsCommand cmd) throws Exception
{ {
charge(cmd.getName()); charge(cmd.getName());
} }
public boolean getJustPortaled() public boolean getJustPortaled()
@ -692,33 +671,21 @@ public class User extends PlayerExtension implements Comparable<User>, IReplyTo
public void setJustPortaled(boolean value) public void setJustPortaled(boolean value)
{ {
justPortaled = value; justPortaled = value;
} }
public void setReplyTo(CommandSender user) public void setReplyTo(CommandSender user)
{ {
replyTo = user; replyTo = user;
} }
public CommandSender getReplyTo() public CommandSender getReplyTo()
{ {
return replyTo; return replyTo;
} }
public void setHome() public void setHome()
{ {
setHome(getLocation()); setHome(getLocation());
} }
public void setHome(Location home) public void setHome(Location home)
@ -733,76 +700,46 @@ public class User extends PlayerExtension implements Comparable<User>, IReplyTo
data.put("home", vals); data.put("home", vals);
flush(); flush();
setCompassTarget( setCompassTarget(home);
home);
} }
public String getNick() public String getNick()
{ {
Essentials ess = Essentials.getStatic(); Essentials ess = Essentials.getStatic();
String name = Essentials.getSettings().isCommandDisabled("nick") ? getName() : ess.readNickname(this); String name = Essentials.getSettings().isCommandDisabled("nick") ? getName() : ess.readNickname(this);
if (isOp() && ess.getConfiguration().getString("ops-name-color", "c").matches("^[0-9a-f]$")) if (isOp() && ess.getConfiguration().getString("ops-name-color", "c").matches("^[0-9a-f]$"))
{ {
name = "§" + ess.getConfiguration().getString("ops-name-color", "c") + name + "§f"; name = "§" + ess.getConfiguration().getString("ops-name-color", "c") + name + "§f";
} }
return name; return name;
} }
public void warpTo(String warp, final String chargeFor) throws Exception public void warpTo(String warp, final String chargeFor) throws Exception
{ {
lastLocation = getLocation(); lastLocation = getLocation();
Location loc = Essentials.getWarps().getWarp(warp); Location loc = Essentials.getWarps().getWarp(warp);
teleportTo( teleportTo(loc, chargeFor);
loc, chargeFor); sendMessage("§7Warping to " + warp + ".");
sendMessage(
"§7Warping to " + warp + ".");
} }
public void warpTo(String string) throws Exception public void warpTo(String string) throws Exception
{ {
warpTo(string, null); warpTo(string, null);
} }
public void clearNewFlag() public void clearNewFlag()
{ {
isNew = false; isNew = false;
} }
public int compareTo(User t) public int compareTo(User t)
{ {
return ChatColor.stripColor(this.getDisplayName()).compareToIgnoreCase(ChatColor.stripColor(t.getDisplayName())); return ChatColor.stripColor(this.getDisplayName()).compareToIgnoreCase(ChatColor.stripColor(t.getDisplayName()));
} }
public Boolean canSpawnItem(int itemId) public Boolean canSpawnItem(int itemId)
{ {
return !Essentials.getSettings().itemSpawnBlacklist().contains(itemId); return !Essentials.getSettings().itemSpawnBlacklist().contains(itemId);
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@ -811,50 +748,29 @@ public class User extends PlayerExtension implements Comparable<User>, IReplyTo
if (!data.containsKey("unlimited")) if (!data.containsKey("unlimited"))
{ {
return new ArrayList<Integer>(); return new ArrayList<Integer>();
} }
return (List<Integer>)data.get("unlimited"); return (List<Integer>)data.get("unlimited");
} }
public boolean hasUnlimited(ItemStack stack) public boolean hasUnlimited(ItemStack stack)
{ {
return getUnlimited().contains(stack.getTypeId()); return getUnlimited().contains(stack.getTypeId());
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public void setUnlimited(ItemStack stack, boolean state) public void setUnlimited(ItemStack stack, boolean state)
{ {
List<Integer> items = getUnlimited(); List<Integer> items = getUnlimited();
if (items.contains(stack.getTypeId())) if (items.contains(stack.getTypeId()))
{ {
items.remove(Integer.valueOf(stack.getTypeId())); items.remove(Integer.valueOf(stack.getTypeId()));
} }
if (state) if (state)
{ {
items.add(stack.getTypeId()); items.add(stack.getTypeId());
} }
data.put("unlimited", items); data.put("unlimited", items);
flush(); flush();
} }
public String getPowertool(ItemStack stack) public String getPowertool(ItemStack stack)
@ -862,48 +778,26 @@ public class User extends PlayerExtension implements Comparable<User>, IReplyTo
if (!data.containsKey("powertools")) if (!data.containsKey("powertools"))
{ {
return null; return null;
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
Map<Integer, String> tools = (Map<Integer, String>)data.get("powertools"); Map<Integer, String> tools = (Map<Integer, String>)data.get("powertools");
return tools.get(stack.getTypeId()); return tools.get(stack.getTypeId());
} }
public void setPowertool(ItemStack stack, String command) public void setPowertool(ItemStack stack, String command)
{ {
Map<Integer, String> tools = new HashMap<Integer, String>(); Map<Integer, String> tools = new HashMap<Integer, String>();
if (data.containsKey("powertools")) if (data.containsKey("powertools"))
{ {
tools = (Map<Integer, String>)data.get("powertools"); tools = (Map<Integer, String>)data.get("powertools");
} }
if (command == null || command.trim().isEmpty()) if (command == null || command.trim().isEmpty())
{ {
tools.remove(Integer.valueOf(stack.getTypeId())); tools.remove(Integer.valueOf(stack.getTypeId()));
return; return;
} }
tools.put(Integer.valueOf(stack.getTypeId()), command.trim()); tools.put(Integer.valueOf(stack.getTypeId()), command.trim());
data.put("powertools", tools); data.put("powertools", tools);
flush(); flush();
} }
} }