Misc cleanup

This commit is contained in:
KHobbits 2013-07-07 12:11:57 +01:00
parent 3f5e2ad85a
commit 3d29248ace
36 changed files with 68 additions and 67 deletions

View File

@ -502,13 +502,13 @@ public class Essentials extends JavaPlugin implements IEssentials
User user = getUser(player);
if (user.isRecipeSee())
{
user.getPlayer().getOpenInventory().getTopInventory().clear();
user.getPlayer().getOpenInventory().close();
user.getBase().getOpenInventory().getTopInventory().clear();
user.getBase().getOpenInventory().close();
user.setRecipeSee(false);
}
if (user.isInvSee() || user.isEnderSee())
{
user.getPlayer().getOpenInventory().close();
user.getBase().getOpenInventory().close();
user.setInvSee(false);
user.setEnderSee(false);
}

View File

@ -61,8 +61,8 @@ public class EssentialsBlockListener implements Listener
@Override
public void run()
{
user.getInventory().addItem(is);
user.updateInventory();
user.getBase().getInventory().addItem(is);
user.getBase().updateInventory();
}
});
}

View File

@ -149,7 +149,7 @@ public class EssentialsPlayerListener implements Listener
user.setLogoutLocation();
if (user.isRecipeSee())
{
user.getPlayer().getOpenInventory().getTopInventory().clear();
user.getBase().getOpenInventory().getTopInventory().clear();
}
user.updateActivity(false);
user.dispose();
@ -493,7 +493,7 @@ public class EssentialsPlayerListener implements Listener
{
try
{
final Location otarget = LocationUtil.getTarget(user);
final Location otarget = LocationUtil.getTarget(user.getBase());
ess.scheduleSyncDelayedTask(
new Runnable()

View File

@ -6,10 +6,11 @@ import java.math.BigDecimal;
import java.util.Map;
import java.util.Set;
import org.bukkit.Location;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public interface IUser extends Player
public interface IUser extends CommandSender
{
long getLastTeleportTimestamp();

View File

@ -148,7 +148,7 @@ public class Jails extends AsyncStorageObjectHolder<com.earth2me.essentials.sett
acquireReadLock();
try
{
if (user.isOnline())
if (user.getBase().isOnline())
{
Location loc = getJail(jail);
user.getTeleport().now(loc, false, TeleportCause.COMMAND);

View File

@ -11,7 +11,7 @@ import org.bukkit.permissions.Permissible;
import org.bukkit.permissions.ServerOperator;
public class PlayerExtension implements Player
public class PlayerExtension
{
@Delegate(types =
{

View File

@ -83,7 +83,7 @@ public class SpawnMob
// This method spawns a mob where the user is looking, owned by user
public static void spawnmob(final IEssentials ess, final Server server, final User user, final List<String> parts, final List<String> data, int mobCount) throws Exception
{
final Block block = LocationUtil.getTarget(user).getBlock();
final Block block = LocationUtil.getTarget(user.getBase()).getBlock();
if (block == null)
{
throw new Exception(_("unableToSpawnMob"));

View File

@ -160,7 +160,7 @@ public class Teleport implements ITeleport
@Override
public void teleportToMe(IUser otherUser, Trade chargeFor, TeleportCause cause) throws Exception
{
ITarget target = new PlayerTarget(teleportOwner);
ITarget target = new PlayerTarget(teleportOwner.getBase());
teleport(otherUser, target, chargeFor, cause);
}

View File

@ -36,10 +36,10 @@ public class TimedTeleport implements Runnable
this.teleport = teleport;
this.timer_started = System.currentTimeMillis();
this.timer_delay = delay;
this.timer_health = teleportUser.getHealth();
this.timer_initX = Math.round(teleportUser.getLocation().getX() * MOVE_CONSTANT);
this.timer_initY = Math.round(teleportUser.getLocation().getY() * MOVE_CONSTANT);
this.timer_initZ = Math.round(teleportUser.getLocation().getZ() * MOVE_CONSTANT);
this.timer_health = teleportUser.getBase().getHealth();
this.timer_initX = Math.round(teleportUser.getBase().getLocation().getX() * MOVE_CONSTANT);
this.timer_initY = Math.round(teleportUser.getBase().getLocation().getY() * MOVE_CONSTANT);
this.timer_initZ = Math.round(teleportUser.getBase().getLocation().getZ() * MOVE_CONSTANT);
this.timer_teleportee = teleportUser.getName();
this.timer_teleportTarget = target;
this.timer_chargeFor = chargeFor;
@ -54,7 +54,7 @@ public class TimedTeleport implements Runnable
public void run()
{
if (teleportOwner == null || !teleportOwner.isOnline() || teleportOwner.getLocation() == null)
if (teleportOwner == null || !teleportOwner.getBase().isOnline() || teleportOwner.getBase().getLocation() == null)
{
cancelTimer(false);
return;
@ -62,13 +62,13 @@ public class TimedTeleport implements Runnable
IUser teleportUser = ess.getUser(this.timer_teleportee);
if (teleportUser == null || !teleportUser.isOnline())
if (teleportUser == null || !teleportUser.getBase().isOnline())
{
cancelTimer(false);
return;
}
final Location currLocation = teleportUser.getLocation();
final Location currLocation = teleportUser.getBase().getLocation();
if (currLocation == null)
{
cancelTimer(false);
@ -79,14 +79,14 @@ public class TimedTeleport implements Runnable
&& (Math.round(currLocation.getX() * MOVE_CONSTANT) != timer_initX
|| Math.round(currLocation.getY() * MOVE_CONSTANT) != timer_initY
|| Math.round(currLocation.getZ() * MOVE_CONSTANT) != timer_initZ
|| teleportUser.getHealth() < timer_health))
|| teleportUser.getBase().getHealth() < timer_health))
{
// user moved, cancelTimer teleportPlayer
cancelTimer(true);
return;
}
timer_health = teleportUser.getHealth(); // in case user healed, then later gets injured
timer_health = teleportUser.getBase().getHealth(); // in case user healed, then later gets injured
final long now = System.currentTimeMillis();
if (now > timer_started + timer_delay)
{

View File

@ -100,7 +100,7 @@ public class Trade
}
if (getItemStack() != null
&& !user.getInventory().containsAtLeast(itemStack, itemStack.getAmount()))
&& !user.getBase().getInventory().containsAtLeast(itemStack, itemStack.getAmount()))
{
throw new ChargeException(_("missingItems", getItemStack().getAmount(), getItemStack().getType().toString().toLowerCase(Locale.ENGLISH).replace("_", " ")));
}
@ -114,7 +114,7 @@ public class Trade
}
if (exp != null && exp > 0
&& SetExpFix.getTotalExperience(user) < exp)
&& SetExpFix.getTotalExperience(user.getBase()) < exp)
{
throw new ChargeException(_("notEnoughExperience"));
}
@ -138,7 +138,7 @@ public class Trade
if (getItemStack() != null)
{
// This stores the would be overflow
Map<Integer, ItemStack> overFlow = InventoryWorkaround.addAllItems(user.getInventory(), getItemStack());
Map<Integer, ItemStack> overFlow = InventoryWorkaround.addAllItems(user.getBase().getInventory(), getItemStack());
if (overFlow != null)
{
@ -154,8 +154,8 @@ public class Trade
case RETURN:
// Pay the user the items, and return overflow
final Map<Integer, ItemStack> returnStack = InventoryWorkaround.addItems(user.getInventory(), getItemStack());
user.updateInventory();
final Map<Integer, ItemStack> returnStack = InventoryWorkaround.addItems(user.getBase().getInventory(), getItemStack());
user.getBase().updateInventory();
if (ess.getSettings().isDebug())
{
@ -166,8 +166,8 @@ public class Trade
case DROP:
// Pay the users the items directly, and drop the rest, will always return no overflow.
final Map<Integer, ItemStack> leftOver = InventoryWorkaround.addItems(user.getInventory(), getItemStack());
final Location loc = user.getLocation();
final Map<Integer, ItemStack> leftOver = InventoryWorkaround.addItems(user.getBase().getInventory(), getItemStack());
final Location loc = user.getBase().getLocation();
for (ItemStack loStack : leftOver.values())
{
final int maxStackSize = loStack.getType().getMaxStackSize();
@ -197,11 +197,11 @@ public class Trade
{
ess.getLogger().log(Level.INFO, "paying " + user.getName() + " itemstack " + getItemStack().toString());
}
user.updateInventory();
user.getBase().updateInventory();
}
if (getExperience() != null)
{
SetExpFix.setTotalExperience(user, SetExpFix.getTotalExperience(user) + getExperience());
SetExpFix.setTotalExperience(user.getBase(), SetExpFix.getTotalExperience(user.getBase()) + getExperience());
}
return null;
}
@ -230,12 +230,12 @@ public class Trade
{
ess.getLogger().log(Level.INFO, "charging user " + user.getName() + " itemstack " + getItemStack().toString());
}
if (!user.getInventory().containsAtLeast(getItemStack(), getItemStack().getAmount()))
if (!user.getBase().getInventory().containsAtLeast(getItemStack(), getItemStack().getAmount()))
{
throw new ChargeException(_("missingItems", getItemStack().getAmount(), getItemStack().getType().toString().toLowerCase(Locale.ENGLISH).replace("_", " ")));
}
user.getInventory().removeItem(getItemStack());
user.updateInventory();
user.getBase().getInventory().removeItem(getItemStack());
user.getBase().updateInventory();
}
if (command != null)
{
@ -252,12 +252,12 @@ public class Trade
{
ess.getLogger().log(Level.INFO, "charging user " + user.getName() + " exp " + getExperience());
}
final int experience = SetExpFix.getTotalExperience(user);
final int experience = SetExpFix.getTotalExperience(user.getBase());
if (experience < getExperience() && getExperience() > 0)
{
throw new ChargeException(_("notEnoughExperience"));
}
SetExpFix.setTotalExperience(user, experience - getExperience());
SetExpFix.setTotalExperience(user.getBase(), experience - getExperience());
}
if (ess.getSettings().isDebug())
{

View File

@ -502,7 +502,7 @@ public abstract class UserData extends PlayerExtension implements IConf
public boolean isIgnoredPlayer(final String userName)
{
final IUser user = ess.getUser(userName);
if (user == null || !user.isOnline())
if (user == null || !user.getBase().isOnline())
{
return false;
}

View File

@ -23,7 +23,7 @@ public class Commandantioch extends EssentialsCommand
ess.broadcastMessage(user, "who being naughty in My sight, shall snuff it.");
}
final Location loc = LocationUtil.getTarget(user);
final Location loc = LocationUtil.getTarget(user.getBase());
loc.getWorld().spawn(loc, TNTPrimed.class);
}
}

View File

@ -36,7 +36,7 @@ public class Commandbigtree extends EssentialsCommand
throw new NotEnoughArgumentsException();
}
final Location loc = LocationUtil.getTarget(user);
final Location loc = LocationUtil.getTarget(user.getBase());
final Location safeLocation = LocationUtil.getSafeDestination(loc);
final boolean success = user.getWorld().generateTree(safeLocation, tree);
if (success)

View File

@ -41,7 +41,7 @@ public class Commandclearinventory extends EssentialsCommand
if (sender instanceof User)
{
players.add((Player)sender);
players.add(((User)sender).getBase());
}
if (allowAll && args.length > 0 && args[0].contentEquals("*"))

View File

@ -159,7 +159,7 @@ public class Commandexp extends EssentialsCommand
private void showExp(final CommandSender sender, final User target)
{
sender.sendMessage(_("exp", target.getDisplayName(), SetExpFix.getTotalExperience(target), target.getLevel(), SetExpFix.getExpUntilNextLevel(target)));
sender.sendMessage(_("exp", target.getDisplayName(), SetExpFix.getTotalExperience(target.getBase()), target.getLevel(), SetExpFix.getExpUntilNextLevel(target.getBase())));
}
//TODO: Limit who can give negative exp?
@ -176,7 +176,7 @@ public class Commandexp extends EssentialsCommand
neededLevel += target.getLevel();
}
amount = (long)SetExpFix.getExpToLevel(neededLevel);
SetExpFix.setTotalExperience(target, 0);
SetExpFix.setTotalExperience(target.getBase(), 0);
}
else
{
@ -189,7 +189,7 @@ public class Commandexp extends EssentialsCommand
if (give)
{
amount += SetExpFix.getTotalExperience(target);
amount += SetExpFix.getTotalExperience(target.getBase());
}
if (amount > Integer.MAX_VALUE)
{
@ -199,7 +199,7 @@ public class Commandexp extends EssentialsCommand
{
amount = 0l;
}
SetExpFix.setTotalExperience(target, (int)amount);
SetExpFix.setTotalExperience(target.getBase(), (int)amount);
sender.sendMessage(_("expSet", target.getDisplayName(), amount));
}
}

View File

@ -27,7 +27,7 @@ public class Commandinvsee extends EssentialsCommand
if (args.length > 1 && user.isAuthorized("essentials.invsee.equip"))
{
inv = server.createInventory(invUser, 9, "Equipped");
inv = server.createInventory(invUser.getBase(), 9, "Equipped");
inv.setContents(invUser.getInventory().getArmorContents());
}
else

View File

@ -39,7 +39,7 @@ public class Commandjump extends EssentialsCommand
try
{
loc = LocationUtil.getTarget(user);
loc = LocationUtil.getTarget(user.getBase());
loc.setYaw(cloc.getYaw());
loc.setPitch(cloc.getPitch());
loc.setY(loc.getY() + 1);

View File

@ -81,7 +81,7 @@ public class Commandmsg extends EssentialsCommand
}
matchPlayer.sendMessage(_("msgFormat", senderName, translatedMe, message));
replyTo.setReplyTo(matchedUser);
replyTo.setReplyTo(matchPlayer);
ess.getUser(matchPlayer).setReplyTo(sender);
}

View File

@ -29,7 +29,7 @@ public class Commandnuke extends EssentialsCommand
int pos = 0;
for (String arg : args)
{
targets.add(getPlayer(server, sender, args, pos));
targets.add(getPlayer(server, sender, args, pos).getBase());
pos++;
}
}

View File

@ -57,7 +57,7 @@ public class Commandpotion extends EssentialsCommand
{
for (PotionEffect effect : pmeta.getCustomEffects())
{
effect.apply(user);
effect.apply(user.getBase());
}
}
else if (args.length < 3)

View File

@ -73,7 +73,7 @@ public class Commandremove extends EssentialsCommand
}
}
removeEntities(user, world, toRemove, radius);
removeEntities(user.getBase(), world, toRemove, radius);
}
@Override

View File

@ -29,7 +29,7 @@ public class Commandspawner extends EssentialsCommand
throw new NotEnoughArgumentsException(_("mobsAvailable", StringUtil.joinList(Mob.getMobList())));
}
final Location target = LocationUtil.getTarget(user);
final Location target = LocationUtil.getTarget(user.getBase());
if (target == null || target.getBlock().getType() != Material.MOB_SPAWNER)
{
throw new Exception(_("mobSpawnTarget"));

View File

@ -39,7 +39,7 @@ public class Commandtp extends EssentialsCommand
user.sendMessage(_("teleporting"));
final Trade charge = new Trade(this.getName(), ess);
charge.isAffordableFor(user);
user.getTeleport().teleport(player, charge, TeleportCause.COMMAND);
user.getTeleport().teleport(player.getBase(), charge, TeleportCause.COMMAND);
throw new NoChargeException();
case 4:
if (!user.isAuthorized("essentials.tp.others"))
@ -84,7 +84,7 @@ public class Commandtp extends EssentialsCommand
{
throw new Exception(_("noPerm", "essentials.worlds." + toPlayer.getWorld().getName()));
}
target.getTeleport().now(toPlayer, false, TeleportCause.COMMAND);
target.getTeleport().now(toPlayer.getBase(), false, TeleportCause.COMMAND);
user.sendMessage(_("teleporting"));
target.sendMessage(_("teleportAtoB", user.getDisplayName(), toPlayer.getDisplayName()));
break;
@ -103,7 +103,7 @@ public class Commandtp extends EssentialsCommand
if (args.length == 2)
{
final User toPlayer = getPlayer(server, args, 1, true, false);
target.getTeleport().now(toPlayer, false, TeleportCause.COMMAND);
target.getTeleport().now(toPlayer.getBase(), false, TeleportCause.COMMAND);
target.sendMessage(_("teleportAtoB", Console.NAME, toPlayer.getDisplayName()));
}
else if (args.length > 3)

View File

@ -63,7 +63,7 @@ public class Commandtpaccept extends EssentialsCommand
}
else
{
target.getTeleport().teleport(user, charge, TeleportCause.COMMAND);
target.getTeleport().teleport(user.getBase(), charge, TeleportCause.COMMAND);
}
}
catch (Exception ex)

View File

@ -50,7 +50,7 @@ public class Commandtpall extends EssentialsCommand
}
try
{
player.getTeleport().now(target, false, TeleportCause.COMMAND);
player.getTeleport().now(target.getBase(), false, TeleportCause.COMMAND);
}
catch (Exception ex)
{

View File

@ -29,7 +29,7 @@ public class Commandtpo extends EssentialsCommand
throw new Exception(_("noPerm", "essentials.worlds." + player.getWorld().getName()));
}
user.sendMessage(_("teleporting"));
user.getTeleport().now(player, false, TeleportCause.COMMAND);
user.getTeleport().now(player.getBase(), false, TeleportCause.COMMAND);
break;
default:
@ -47,7 +47,7 @@ public class Commandtpo extends EssentialsCommand
throw new Exception(_("noPerm", "essentials.worlds." + toPlayer.getWorld().getName()));
}
target.getTeleport().now(toPlayer, false, TeleportCause.COMMAND);
target.getTeleport().now(toPlayer.getBase(), false, TeleportCause.COMMAND);
target.sendMessage(_("teleportAtoB", user.getDisplayName(), toPlayer.getDisplayName()));
break;
}

View File

@ -31,7 +31,7 @@ public class Commandtpohere extends EssentialsCommand
}
// Verify permission
player.getTeleport().now(user, false, TeleportCause.COMMAND);
player.getTeleport().now(user.getBase(), false, TeleportCause.COMMAND);
user.sendMessage(_("teleporting"));
}

View File

@ -60,7 +60,7 @@ public class Commandtree extends EssentialsCommand
throw new NotEnoughArgumentsException();
}
final Location loc = LocationUtil.getTarget(user);
final Location loc = LocationUtil.getTarget(user.getBase());
final Location safeLocation = LocationUtil.getSafeDestination(loc);
final boolean success = user.getWorld().generateTree(safeLocation, tree);
if (success)

View File

@ -33,7 +33,7 @@ public class Commandwhois extends EssentialsCommand
sender.sendMessage(_("whoisNick", user.getDisplayName()));
sender.sendMessage(_("whoisHealth", user.getHealth()));
sender.sendMessage(_("whoisHunger", user.getFoodLevel(), user.getSaturation()));
sender.sendMessage(_("whoisExp", SetExpFix.getTotalExperience(user), user.getLevel()));
sender.sendMessage(_("whoisExp", SetExpFix.getTotalExperience(user.getBase()), user.getLevel()));
sender.sendMessage(_("whoisLocation", user.getLocation().getWorld().getName(), user.getLocation().getBlockX(), user.getLocation().getBlockY(), user.getLocation().getBlockZ()));
if (!ess.getSettings().isEcoDisabled())
{

View File

@ -137,7 +137,7 @@ public abstract class EssentialsCommand implements IEssentialsCommand
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
{
run(server, (CommandSender)user.getBase(), commandLabel, args);
run(server, (CommandSender)(user.getBase()), commandLabel, args);
}
@Override

View File

@ -14,7 +14,7 @@ public class SignDisposal extends EssentialsSign
@Override
protected boolean onSignInteract(final ISign sign, final User player, final String username, final IEssentials ess)
{
player.getBase().openInventory(ess.getServer().createInventory(player, 36));
player.getBase().openInventory(ess.getServer().createInventory(player.getBase(), 36));
return true;
}
}

View File

@ -40,7 +40,7 @@ public class SignFree extends EssentialsSign
}
item.setAmount(item.getType().getMaxStackSize());
Inventory invent = ess.getServer().createInventory(player, 36);
Inventory invent = ess.getServer().createInventory(player.getBase(), 36);
for (int i = 0; i < 36; i++) {
invent.addItem(item);
}

View File

@ -44,7 +44,7 @@ public class SignGameMode extends EssentialsSign
charge.isAffordableFor(player);
performSetMode(mode.toLowerCase(Locale.ENGLISH), player);
performSetMode(mode.toLowerCase(Locale.ENGLISH), player.getBase());
player.sendMessage(_("gameMode", _(player.getGameMode().toString().toLowerCase(Locale.ENGLISH)), player.getDisplayName()));
Trade.log("Sign", "gameMode", "Interact", username, null, username, charge, sign.getBlock().getLocation(), ess);
charge.charge(player);

View File

@ -50,7 +50,7 @@ public class EssentialsChatPlayerListenerLowest extends EssentialsChatPlayer
event.setMessage(FormatUtil.formatMessage(user, "essentials.chat", event.getMessage()));
String group = user.getGroup();
String world = user.getWorld().getName();
Team team = user.getScoreboard().getPlayerTeam(user);
Team team = user.getScoreboard().getPlayerTeam(user.getBase());
String format = ess.getSettings().getChatFormat(group);
format = format.replace("{0}", group);

View File

@ -21,7 +21,7 @@ public class Commandsetxmpp extends EssentialsCommand
throw new NotEnoughArgumentsException();
}
EssentialsXMPP.getInstance().setAddress(user, args[0]);
EssentialsXMPP.getInstance().setAddress(user.getBase(), args[0]);
user.sendMessage("XMPP address set to " + args[0]);
}
}

View File

@ -95,7 +95,7 @@ public class XMPPManager extends Handler implements MessageListener, ChatManager
break;
default:
final IUser sender = parent.getUserByAddress(StringUtils.parseBareAddress(chat.getParticipant()));
parent.broadcastMessage(sender, "=" + sender.getDisplayName() + ": " + message, StringUtils.parseBareAddress(chat.getParticipant()));
parent.broadcastMessage(sender, "=" + sender.getBase().getDisplayName() + ": " + message, StringUtils.parseBareAddress(chat.getParticipant()));
}
}
}