Skip to content
Permalink
Browse files

Converted emulated player class calls to use base class.

  • Loading branch information...
khobbits committed Apr 13, 2014
1 parent fec02fe commit 517853fb73b2fb21d08c03a3b8d99cc98ff5abc7
Showing with 214 additions and 214 deletions.
  1. +1 −1 Essentials/src/com/earth2me/essentials/EssentialsBlockListener.java
  2. +6 −6 Essentials/src/com/earth2me/essentials/EssentialsEntityListener.java
  3. +29 −29 Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java
  4. +4 −4 Essentials/src/com/earth2me/essentials/ItemDb.java
  5. +4 −4 Essentials/src/com/earth2me/essentials/Kit.java
  6. +6 −6 Essentials/src/com/earth2me/essentials/User.java
  7. +1 −1 Essentials/src/com/earth2me/essentials/Worth.java
  8. +3 −3 Essentials/src/com/earth2me/essentials/commands/Commandban.java
  9. +3 −3 Essentials/src/com/earth2me/essentials/commands/Commandbook.java
  10. +1 −1 Essentials/src/com/earth2me/essentials/commands/Commandbreak.java
  11. +1 −1 Essentials/src/com/earth2me/essentials/commands/Commandburn.java
  12. +3 −3 Essentials/src/com/earth2me/essentials/commands/Commandenchant.java
  13. +4 −4 Essentials/src/com/earth2me/essentials/commands/Commandenderchest.java
  14. +2 −2 Essentials/src/com/earth2me/essentials/commands/Commandexp.java
  15. +2 −2 Essentials/src/com/earth2me/essentials/commands/Commandfireball.java
  16. +2 −2 Essentials/src/com/earth2me/essentials/commands/Commandfirework.java
  17. +5 −5 Essentials/src/com/earth2me/essentials/commands/Commandfly.java
  18. +5 −5 Essentials/src/com/earth2me/essentials/commands/Commandgamemode.java
  19. +3 −3 Essentials/src/com/earth2me/essentials/commands/Commandgive.java
  20. +3 −3 Essentials/src/com/earth2me/essentials/commands/Commandgod.java
  21. +5 −5 Essentials/src/com/earth2me/essentials/commands/Commandhat.java
  22. +3 −3 Essentials/src/com/earth2me/essentials/commands/Commandhome.java
  23. +4 −4 Essentials/src/com/earth2me/essentials/commands/Commandinvsee.java
  24. +3 −3 Essentials/src/com/earth2me/essentials/commands/Commanditem.java
  25. +1 −1 Essentials/src/com/earth2me/essentials/commands/Commandkick.java
  26. +2 −2 Essentials/src/com/earth2me/essentials/commands/Commandkittycannon.java
  27. +1 −1 Essentials/src/com/earth2me/essentials/commands/Commandlightning.java
  28. +2 −2 Essentials/src/com/earth2me/essentials/commands/Commandmore.java
  29. +1 −1 Essentials/src/com/earth2me/essentials/commands/Commandmute.java
  30. +1 −1 Essentials/src/com/earth2me/essentials/commands/Commandpotion.java
  31. +1 −1 Essentials/src/com/earth2me/essentials/commands/Commandpowertool.java
  32. +6 −6 Essentials/src/com/earth2me/essentials/commands/Commandptime.java
  33. +4 −4 Essentials/src/com/earth2me/essentials/commands/Commandpweather.java
  34. +3 −3 Essentials/src/com/earth2me/essentials/commands/Commandrecipe.java
  35. +5 −5 Essentials/src/com/earth2me/essentials/commands/Commandrepair.java
  36. +2 −2 Essentials/src/com/earth2me/essentials/commands/Commandseen.java
  37. +3 −3 Essentials/src/com/earth2me/essentials/commands/Commandsell.java
  38. +1 −1 Essentials/src/com/earth2me/essentials/commands/Commandsetworth.java
  39. +3 −3 Essentials/src/com/earth2me/essentials/commands/Commandspeed.java
  40. +1 −1 Essentials/src/com/earth2me/essentials/commands/Commandsudo.java
  41. +3 −3 Essentials/src/com/earth2me/essentials/commands/Commandsuicide.java
  42. +3 −3 Essentials/src/com/earth2me/essentials/commands/Commandtempban.java
  43. +3 −3 Essentials/src/com/earth2me/essentials/commands/Commandtogglejail.java
  44. +1 −1 Essentials/src/com/earth2me/essentials/commands/Commandtpaccept.java
  45. +1 −1 Essentials/src/com/earth2me/essentials/commands/Commandunban.java
  46. +2 −2 Essentials/src/com/earth2me/essentials/commands/Commandunlimited.java
  47. +7 −7 Essentials/src/com/earth2me/essentials/commands/Commandwhois.java
  48. +1 −1 Essentials/src/com/earth2me/essentials/commands/Commandworkbench.java
  49. +1 −1 Essentials/src/com/earth2me/essentials/commands/EssentialsCommand.java
  50. +2 −2 Essentials/src/com/earth2me/essentials/signs/EssentialsSign.java
  51. +2 −2 Essentials/src/com/earth2me/essentials/signs/SignEnchant.java
  52. +1 −1 Essentials/src/com/earth2me/essentials/signs/SignFree.java
  53. +1 −1 Essentials/src/com/earth2me/essentials/signs/SignGameMode.java
  54. +4 −4 Essentials/src/com/earth2me/essentials/signs/SignHeal.java
  55. +6 −6 Essentials/src/com/earth2me/essentials/signs/SignTrade.java
  56. +2 −2 Essentials/src/com/earth2me/essentials/textreader/KeywordReplacer.java
  57. +1 −1 Essentials/src/com/earth2me/essentials/utils/StringUtil.java
  58. +28 −28 Essentials/test/com/earth2me/essentials/ToggleTest.java
  59. +2 −2 EssentialsAntiBuild/src/com/earth2me/essentials/antibuild/EssentialsAntiBuildListener.java
  60. +1 −1 EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayerListenerLowest.java
  61. +2 −2 EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawnPlayerListener.java
@@ -54,7 +54,7 @@ public void onBlockPlace(final BlockPlaceEvent event)
}

final User user = ess.getUser(event.getPlayer());
if (user.hasUnlimited(is) && user.getGameMode() == GameMode.SURVIVAL)
if (user.hasUnlimited(is) && user.getBase().getGameMode() == GameMode.SURVIVAL)
{
ess.scheduleSyncDelayedTask(
new Runnable()
@@ -42,13 +42,13 @@ public void onEntityDamage(final EntityDamageByEntityEvent event)
}
else if (eDefend instanceof Ageable)
{
final ItemStack hand = attacker.getItemInHand();
final ItemStack hand = attacker.getBase().getItemInHand();
if (hand != null && hand.getType() == Material.MILK_BUCKET)
{
((Ageable)eDefend).setBaby();
hand.setType(Material.BUCKET);
attacker.setItemInHand(hand);
attacker.updateInventory();
attacker.getBase().setItemInHand(hand);
attacker.getBase().updateInventory();
event.setCancelled(true);
}
}
@@ -97,7 +97,7 @@ private void onPlayerVsPlayerDamage(final EntityDamageByEntityEvent event, final

private void onPlayerVsPlayerPowertool(final EntityDamageByEntityEvent event, final Player defender, final User attacker)
{
final List<String> commandList = attacker.getPowertool(attacker.getItemInHand());
final List<String> commandList = attacker.getPowertool(attacker.getBase().getItemInHand());
if (commandList != null && !commandList.isEmpty())
{
for (final String tempCommand : commandList)
@@ -180,8 +180,8 @@ public void onFoodLevelChange(final FoodLevelChangeEvent event)
{
if (user.isGodModeEnabledRaw())
{
user.setFoodLevel(20);
user.setSaturation(10);
user.getBase().setFoodLevel(20);
user.getBase().setSaturation(10);
}
event.setCancelled(true);
}
@@ -225,7 +225,7 @@ public void delayedJoin(final Player player, final String message)
@Override
public void run()
{
if (!user.isOnline())
if (!user.getBase().isOnline())
{
return;
}
@@ -242,14 +242,14 @@ public void run()
Player toVanish = ess.getServer().getPlayerExact(p);
if (toVanish != null && toVanish.isOnline())
{
user.hidePlayer(toVanish);
user.getBase().hidePlayer(toVanish);
}
}
}

if (user.isAuthorized("essentials.sleepingignored"))
{
user.setSleepingIgnored(true);
user.getBase().setSleepingIgnored(true);
}

if ((ess.getSettings().allowSilentJoinQuit() && user.isAuthorized("essentials.silentjoin")) || message == null)
@@ -305,16 +305,16 @@ else if (ess.getSettings().allowSilentJoinQuit())

if (user.isAuthorized("essentials.fly.safelogin"))
{
user.setFallDistance(0);
user.getBase().setFallDistance(0);
if (LocationUtil.shouldFly(user.getLocation()))
{
user.setAllowFlight(true);
user.setFlying(true);
user.sendMessage(tl("flyMode", tl("enabled"), user.getDisplayName()));
user.getBase().setAllowFlight(true);
user.getBase().setFlying(true);
user.getBase().sendMessage(tl("flyMode", tl("enabled"), user.getDisplayName()));
}
}
user.setFlySpeed(0.1f);
user.setWalkSpeed(0.2f);
user.getBase().setFlySpeed(0.1f);
user.getBase().setWalkSpeed(0.2f);

}
});
@@ -326,12 +326,12 @@ private void updateCompass(final User user)
Location loc = user.getHome(user.getLocation());
if (loc == null)
{
loc = user.getBedSpawnLocation();
loc = user.getBase().getBedSpawnLocation();
}
if (loc != null)
{
final Location updateLoc = loc;
user.setCompassTarget(updateLoc);
user.getBase().setCompassTarget(updateLoc);
}
}

@@ -364,7 +364,7 @@ public void onPlayerLogin(final PlayerLoginEvent event)

final User user = ess.getUser(event.getPlayer());

if (event.getResult() == Result.KICK_BANNED || user.isBanned())
if (event.getResult() == Result.KICK_BANNED || user.getBase().isBanned())
{
final boolean banExpired = user.checkBanTimeout(System.currentTimeMillis());
if (!banExpired)
@@ -419,8 +419,8 @@ public void onPlayerEggThrow(final PlayerEggThrowEvent event)
final ItemStack stack = new ItemStack(Material.EGG, 1);
if (user.hasUnlimited(stack))
{
user.getInventory().addItem(stack);
user.updateInventory();
user.getBase().getInventory().addItem(stack);
user.getBase().updateInventory();
}
}

@@ -436,7 +436,7 @@ public void onPlayerBucketEmpty(final PlayerBucketEmptyEvent event)
@Override
public void run()
{
user.updateInventory();
user.getBase().updateInventory();
}
});
}
@@ -469,34 +469,34 @@ else if (!cmd.equalsIgnoreCase("afk"))
public void onPlayerChangedWorldFlyReset(final PlayerChangedWorldEvent event)
{
final User user = ess.getUser(event.getPlayer());
if (user.getGameMode() != GameMode.CREATIVE && !user.isAuthorized("essentials.fly"))
if (user.getBase().getGameMode() != GameMode.CREATIVE && !user.isAuthorized("essentials.fly"))
{
user.setFallDistance(0f);
user.setAllowFlight(false);
user.getBase().setFallDistance(0f);
user.getBase().setAllowFlight(false);
}
if (!user.isAuthorized("essentials.speed"))
{
user.setFlySpeed(0.1f);
user.setWalkSpeed(0.2f);
user.getBase().setFlySpeed(0.1f);
user.getBase().setWalkSpeed(0.2f);
}
else
{
if (user.getFlySpeed() > ess.getSettings().getMaxFlySpeed() && !user.isAuthorized("essentials.speed.bypass"))
if (user.getBase().getFlySpeed() > ess.getSettings().getMaxFlySpeed() && !user.isAuthorized("essentials.speed.bypass"))
{
user.setFlySpeed((float)ess.getSettings().getMaxFlySpeed());
user.getBase().setFlySpeed((float)ess.getSettings().getMaxFlySpeed());
}
else
{
user.setFlySpeed(user.getFlySpeed() * 0.99999f);
user.getBase().setFlySpeed(user.getBase().getFlySpeed() * 0.99999f);
}

if (user.getWalkSpeed() > ess.getSettings().getMaxWalkSpeed() && !user.isAuthorized("essentials.speed.bypass"))
if (user.getBase().getWalkSpeed() > ess.getSettings().getMaxWalkSpeed() && !user.isAuthorized("essentials.speed.bypass"))
{
user.setWalkSpeed((float)ess.getSettings().getMaxWalkSpeed());
user.getBase().setWalkSpeed((float)ess.getSettings().getMaxWalkSpeed());
}
else
{
user.setWalkSpeed(user.getWalkSpeed() * 0.99999f);
user.getBase().setWalkSpeed(user.getBase().getWalkSpeed() * 0.99999f);
}
}
}
@@ -534,7 +534,7 @@ public void onPlayerInteract(final PlayerInteractEvent event)
User player = ess.getUser(event.getPlayer());
if (player.isAuthorized("essentials.sethome.bed"))
{
player.setBedSpawnLocation(event.getClickedBlock().getLocation());
player.getBase().setBedSpawnLocation(event.getClickedBlock().getLocation());
player.sendMessage(tl("bedSet", player.getLocation().getWorld().getName(), player.getLocation().getBlockX(), player.getLocation().getBlockY(), player.getLocation().getBlockZ()));
}
}
@@ -616,7 +616,7 @@ private boolean usePowertools(final User user, final int id)
else if (command.startsWith("c:"))
{
used = true;
user.chat(command.substring(2));
user.getBase().chat(command.substring(2));
}
else
{
@@ -664,7 +664,7 @@ public void onInventoryClickEvent(final InventoryClickEvent event)
final User invOwner = ess.getUser((Player)invHolder);
if (user.isInvSee() && (!user.isAuthorized("essentials.invsee.modify")
|| invOwner.isAuthorized("essentials.invsee.preventmodify")
|| !invOwner.isOnline()))
|| !invOwner.getBase().isOnline()))
{
event.setCancelled(true);
refreshPlayer = user.getBase();
@@ -171,15 +171,15 @@ else if (Material.getMaterial(itemname.toUpperCase(Locale.ENGLISH)) != null)

if (args.length < 1)
{
is.add(user.getItemInHand());
is.add(user.getBase().getItemInHand());
}
else if (args[0].equalsIgnoreCase("hand"))
{
is.add(user.getItemInHand());
is.add(user.getBase().getItemInHand());
}
else if (args[0].equalsIgnoreCase("inventory") || args[0].equalsIgnoreCase("invent") || args[0].equalsIgnoreCase("all"))
{
for (ItemStack stack : user.getInventory().getContents())
for (ItemStack stack : user.getBase().getInventory().getContents())
{
if (stack == null || stack.getType() == Material.AIR)
{
@@ -190,7 +190,7 @@ else if (args[0].equalsIgnoreCase("inventory") || args[0].equalsIgnoreCase("inve
}
else if (args[0].equalsIgnoreCase("blocks"))
{
for (ItemStack stack : user.getInventory().getContents())
for (ItemStack stack : user.getBase().getInventory().getContents())
{
if (stack == null || stack.getTypeId() > 255 || stack.getType() == Material.AIR)
{
@@ -204,11 +204,11 @@ public static void expandItems(final IEssentials ess, final User user, final Lis
final boolean allowOversizedStacks = user.isAuthorized("essentials.oversizedstacks");
if (allowOversizedStacks)
{
overfilled = InventoryWorkaround.addOversizedItems(user.getInventory(), ess.getSettings().getOversizedStackSize(), metaStack.getItemStack());
overfilled = InventoryWorkaround.addOversizedItems(user.getBase().getInventory(), ess.getSettings().getOversizedStackSize(), metaStack.getItemStack());
}
else
{
overfilled = InventoryWorkaround.addItems(user.getInventory(), metaStack.getItemStack());
overfilled = InventoryWorkaround.addItems(user.getBase().getInventory(), metaStack.getItemStack());
}
for (ItemStack itemStack : overfilled.values())
{
@@ -223,15 +223,15 @@ public static void expandItems(final IEssentials ess, final User user, final Lis
spew = true;
}
}
user.updateInventory();
user.getBase().updateInventory();
if (spew)
{
user.sendMessage(tl("kitInvFull"));
}
}
catch (Exception e)
{
user.updateInventory();
user.getBase().updateInventory();
ess.getLogger().log(Level.WARNING, e.getMessage());
throw new Exception(tl("kitError2"), e);
}
@@ -51,7 +51,7 @@
teleport = new Teleport(this, ess);
if (isAfk())
{
afkPosition = this.getBase().getLocation();
afkPosition = this.getLocation();
}
if (this.getBase().isOnline())
{
@@ -237,13 +237,13 @@ public Boolean canSpawnItem(final int itemId)
@Override
public void setLastLocation()
{
setLastLocation(this.getBase().getLocation());
setLastLocation(this.getLocation());
}

@Override
public void setLogoutLocation()
{
setLogoutLocation(this.getBase().getLocation());
setLogoutLocation(this.getLocation());
}

@Override
@@ -258,7 +258,7 @@ public void requestTeleport(final User player, final boolean here)
}
else
{
teleportLocation = here ? player.getBase().getLocation() : this.getBase().getLocation();
teleportLocation = here ? player.getLocation() : this.getLocation();
}
}

@@ -497,7 +497,7 @@ public void setAfk(final boolean set)
this.getBase().setSleepingIgnored(this.isAuthorized("essentials.sleepingignored") ? true : set);
if (set && !isAfk())
{
afkPosition = this.getBase().getLocation();
afkPosition = this.getLocation();
}
else if (!set && isAfk())
{
@@ -643,7 +643,7 @@ public Location getAfkPosition()
@Override
public boolean isGodModeEnabled()
{
return (super.isGodModeEnabled() && !ess.getSettings().getNoGodWorlds().contains(this.getBase().getLocation().getWorld().getName()))
return (super.isGodModeEnabled() && !ess.getSettings().getNoGodWorlds().contains(this.getLocation().getWorld().getName()))
|| (isAfk() && ess.getSettings().getFreezeAfkPlayers());
}

@@ -114,7 +114,7 @@ public int getAmount(IEssentials ess, User user, ItemStack is, String[] args, bo
}

int max = 0;
for (ItemStack s : user.getInventory().getContents())
for (ItemStack s : user.getBase().getInventory().getContents())
{
if (s == null || !s.isSimilar(is))
{
@@ -35,7 +35,7 @@ public void run(final Server server, final CommandSource sender, final String co
nomatch = true;
user = ess.getUser(new OfflinePlayer(args[0], ess));
}
if (!user.isOnline())
if (!user.getBase().isOnline())
{
if (sender.isPlayer() && !ess.getUser(sender.getPlayer()).isAuthorized("essentials.ban.offline"))
{
@@ -62,9 +62,9 @@ public void run(final Server server, final CommandSource sender, final String co
}

user.setBanReason(tl("banFormat", banReason, senderName));
user.setBanned(true);
user.getBase().setBanned(true);
user.setBanTimeout(0);
user.kickPlayer(tl("banFormat", banReason, senderName));
user.getBase().kickPlayer(tl("banFormat", banReason, senderName));

server.getLogger().log(Level.INFO, tl("playerBanned", senderName, user.getName(), banReason));

@@ -19,7 +19,7 @@ public Commandbook()
@Override
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
{
final ItemStack item = user.getItemInHand();
final ItemStack item = user.getBase().getItemInHand();
final String player = user.getName();
if (item.getType() == Material.WRITTEN_BOOK)
{
@@ -57,7 +57,7 @@ else if (args.length > 1 && args[0].equalsIgnoreCase("title"))
{
ItemStack newItem = new ItemStack(Material.BOOK_AND_QUILL, item.getAmount());
newItem.setItemMeta(bmeta);
user.setItemInHand(newItem);
user.getBase().setItemInHand(newItem);
user.sendMessage(tl("editBookContents"));
}
else
@@ -75,7 +75,7 @@ else if (item.getType() == Material.BOOK_AND_QUILL)
}
ItemStack newItem = new ItemStack(Material.WRITTEN_BOOK, item.getAmount());
newItem.setItemMeta(bmeta);
user.setItemInHand(newItem);
user.getBase().setItemInHand(newItem);
user.sendMessage(tl("bookLocked"));
}
else
@@ -19,7 +19,7 @@ public Commandbreak()
@Override
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
{
final Block block = user.getTargetBlock(null, 20);
final Block block = user.getBase().getTargetBlock(null, 20);
if (block == null)
{
throw new NoChargeException();
@@ -27,7 +27,7 @@ protected void run(final Server server, final CommandSource sender, final String
}

User user = getPlayer(server, sender, args, 0);
user.setFireTicks(Integer.parseInt(args[1]) * 20);
user.getBase().setFireTicks(Integer.parseInt(args[1]) * 20);
sender.sendMessage(tl("burnMsg", user.getDisplayName(), Integer.parseInt(args[1])));
}
}

0 comments on commit 517853f

Please sign in to comment.
You can’t perform that action at this time.