Skip to content

Commit 517853f

Browse files
committed
Converted emulated player class calls to use base class.
1 parent fec02fe commit 517853f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+214
-214
lines changed

Essentials/src/com/earth2me/essentials/EssentialsBlockListener.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public void onBlockPlace(final BlockPlaceEvent event)
5454
}
5555

5656
final User user = ess.getUser(event.getPlayer());
57-
if (user.hasUnlimited(is) && user.getGameMode() == GameMode.SURVIVAL)
57+
if (user.hasUnlimited(is) && user.getBase().getGameMode() == GameMode.SURVIVAL)
5858
{
5959
ess.scheduleSyncDelayedTask(
6060
new Runnable()

Essentials/src/com/earth2me/essentials/EssentialsEntityListener.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,13 @@ public void onEntityDamage(final EntityDamageByEntityEvent event)
4242
}
4343
else if (eDefend instanceof Ageable)
4444
{
45-
final ItemStack hand = attacker.getItemInHand();
45+
final ItemStack hand = attacker.getBase().getItemInHand();
4646
if (hand != null && hand.getType() == Material.MILK_BUCKET)
4747
{
4848
((Ageable)eDefend).setBaby();
4949
hand.setType(Material.BUCKET);
50-
attacker.setItemInHand(hand);
51-
attacker.updateInventory();
50+
attacker.getBase().setItemInHand(hand);
51+
attacker.getBase().updateInventory();
5252
event.setCancelled(true);
5353
}
5454
}
@@ -97,7 +97,7 @@ private void onPlayerVsPlayerDamage(final EntityDamageByEntityEvent event, final
9797

9898
private void onPlayerVsPlayerPowertool(final EntityDamageByEntityEvent event, final Player defender, final User attacker)
9999
{
100-
final List<String> commandList = attacker.getPowertool(attacker.getItemInHand());
100+
final List<String> commandList = attacker.getPowertool(attacker.getBase().getItemInHand());
101101
if (commandList != null && !commandList.isEmpty())
102102
{
103103
for (final String tempCommand : commandList)
@@ -180,8 +180,8 @@ public void onFoodLevelChange(final FoodLevelChangeEvent event)
180180
{
181181
if (user.isGodModeEnabledRaw())
182182
{
183-
user.setFoodLevel(20);
184-
user.setSaturation(10);
183+
user.getBase().setFoodLevel(20);
184+
user.getBase().setSaturation(10);
185185
}
186186
event.setCancelled(true);
187187
}

Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java

+29-29
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ public void delayedJoin(final Player player, final String message)
225225
@Override
226226
public void run()
227227
{
228-
if (!user.isOnline())
228+
if (!user.getBase().isOnline())
229229
{
230230
return;
231231
}
@@ -242,14 +242,14 @@ public void run()
242242
Player toVanish = ess.getServer().getPlayerExact(p);
243243
if (toVanish != null && toVanish.isOnline())
244244
{
245-
user.hidePlayer(toVanish);
245+
user.getBase().hidePlayer(toVanish);
246246
}
247247
}
248248
}
249249

250250
if (user.isAuthorized("essentials.sleepingignored"))
251251
{
252-
user.setSleepingIgnored(true);
252+
user.getBase().setSleepingIgnored(true);
253253
}
254254

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

306306
if (user.isAuthorized("essentials.fly.safelogin"))
307307
{
308-
user.setFallDistance(0);
308+
user.getBase().setFallDistance(0);
309309
if (LocationUtil.shouldFly(user.getLocation()))
310310
{
311-
user.setAllowFlight(true);
312-
user.setFlying(true);
313-
user.sendMessage(tl("flyMode", tl("enabled"), user.getDisplayName()));
311+
user.getBase().setAllowFlight(true);
312+
user.getBase().setFlying(true);
313+
user.getBase().sendMessage(tl("flyMode", tl("enabled"), user.getDisplayName()));
314314
}
315315
}
316-
user.setFlySpeed(0.1f);
317-
user.setWalkSpeed(0.2f);
316+
user.getBase().setFlySpeed(0.1f);
317+
user.getBase().setWalkSpeed(0.2f);
318318

319319
}
320320
});
@@ -326,12 +326,12 @@ private void updateCompass(final User user)
326326
Location loc = user.getHome(user.getLocation());
327327
if (loc == null)
328328
{
329-
loc = user.getBedSpawnLocation();
329+
loc = user.getBase().getBedSpawnLocation();
330330
}
331331
if (loc != null)
332332
{
333333
final Location updateLoc = loc;
334-
user.setCompassTarget(updateLoc);
334+
user.getBase().setCompassTarget(updateLoc);
335335
}
336336
}
337337

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

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

367-
if (event.getResult() == Result.KICK_BANNED || user.isBanned())
367+
if (event.getResult() == Result.KICK_BANNED || user.getBase().isBanned())
368368
{
369369
final boolean banExpired = user.checkBanTimeout(System.currentTimeMillis());
370370
if (!banExpired)
@@ -419,8 +419,8 @@ public void onPlayerEggThrow(final PlayerEggThrowEvent event)
419419
final ItemStack stack = new ItemStack(Material.EGG, 1);
420420
if (user.hasUnlimited(stack))
421421
{
422-
user.getInventory().addItem(stack);
423-
user.updateInventory();
422+
user.getBase().getInventory().addItem(stack);
423+
user.getBase().updateInventory();
424424
}
425425
}
426426

@@ -436,7 +436,7 @@ public void onPlayerBucketEmpty(final PlayerBucketEmptyEvent event)
436436
@Override
437437
public void run()
438438
{
439-
user.updateInventory();
439+
user.getBase().updateInventory();
440440
}
441441
});
442442
}
@@ -469,34 +469,34 @@ else if (!cmd.equalsIgnoreCase("afk"))
469469
public void onPlayerChangedWorldFlyReset(final PlayerChangedWorldEvent event)
470470
{
471471
final User user = ess.getUser(event.getPlayer());
472-
if (user.getGameMode() != GameMode.CREATIVE && !user.isAuthorized("essentials.fly"))
472+
if (user.getBase().getGameMode() != GameMode.CREATIVE && !user.isAuthorized("essentials.fly"))
473473
{
474-
user.setFallDistance(0f);
475-
user.setAllowFlight(false);
474+
user.getBase().setFallDistance(0f);
475+
user.getBase().setAllowFlight(false);
476476
}
477477
if (!user.isAuthorized("essentials.speed"))
478478
{
479-
user.setFlySpeed(0.1f);
480-
user.setWalkSpeed(0.2f);
479+
user.getBase().setFlySpeed(0.1f);
480+
user.getBase().setWalkSpeed(0.2f);
481481
}
482482
else
483483
{
484-
if (user.getFlySpeed() > ess.getSettings().getMaxFlySpeed() && !user.isAuthorized("essentials.speed.bypass"))
484+
if (user.getBase().getFlySpeed() > ess.getSettings().getMaxFlySpeed() && !user.isAuthorized("essentials.speed.bypass"))
485485
{
486-
user.setFlySpeed((float)ess.getSettings().getMaxFlySpeed());
486+
user.getBase().setFlySpeed((float)ess.getSettings().getMaxFlySpeed());
487487
}
488488
else
489489
{
490-
user.setFlySpeed(user.getFlySpeed() * 0.99999f);
490+
user.getBase().setFlySpeed(user.getBase().getFlySpeed() * 0.99999f);
491491
}
492492

493-
if (user.getWalkSpeed() > ess.getSettings().getMaxWalkSpeed() && !user.isAuthorized("essentials.speed.bypass"))
493+
if (user.getBase().getWalkSpeed() > ess.getSettings().getMaxWalkSpeed() && !user.isAuthorized("essentials.speed.bypass"))
494494
{
495-
user.setWalkSpeed((float)ess.getSettings().getMaxWalkSpeed());
495+
user.getBase().setWalkSpeed((float)ess.getSettings().getMaxWalkSpeed());
496496
}
497497
else
498498
{
499-
user.setWalkSpeed(user.getWalkSpeed() * 0.99999f);
499+
user.getBase().setWalkSpeed(user.getBase().getWalkSpeed() * 0.99999f);
500500
}
501501
}
502502
}
@@ -534,7 +534,7 @@ public void onPlayerInteract(final PlayerInteractEvent event)
534534
User player = ess.getUser(event.getPlayer());
535535
if (player.isAuthorized("essentials.sethome.bed"))
536536
{
537-
player.setBedSpawnLocation(event.getClickedBlock().getLocation());
537+
player.getBase().setBedSpawnLocation(event.getClickedBlock().getLocation());
538538
player.sendMessage(tl("bedSet", player.getLocation().getWorld().getName(), player.getLocation().getBlockX(), player.getLocation().getBlockY(), player.getLocation().getBlockZ()));
539539
}
540540
}
@@ -616,7 +616,7 @@ private boolean usePowertools(final User user, final int id)
616616
else if (command.startsWith("c:"))
617617
{
618618
used = true;
619-
user.chat(command.substring(2));
619+
user.getBase().chat(command.substring(2));
620620
}
621621
else
622622
{
@@ -664,7 +664,7 @@ public void onInventoryClickEvent(final InventoryClickEvent event)
664664
final User invOwner = ess.getUser((Player)invHolder);
665665
if (user.isInvSee() && (!user.isAuthorized("essentials.invsee.modify")
666666
|| invOwner.isAuthorized("essentials.invsee.preventmodify")
667-
|| !invOwner.isOnline()))
667+
|| !invOwner.getBase().isOnline()))
668668
{
669669
event.setCancelled(true);
670670
refreshPlayer = user.getBase();

Essentials/src/com/earth2me/essentials/ItemDb.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -171,15 +171,15 @@ public List<ItemStack> getMatching(User user, String[] args) throws Exception
171171

172172
if (args.length < 1)
173173
{
174-
is.add(user.getItemInHand());
174+
is.add(user.getBase().getItemInHand());
175175
}
176176
else if (args[0].equalsIgnoreCase("hand"))
177177
{
178-
is.add(user.getItemInHand());
178+
is.add(user.getBase().getItemInHand());
179179
}
180180
else if (args[0].equalsIgnoreCase("inventory") || args[0].equalsIgnoreCase("invent") || args[0].equalsIgnoreCase("all"))
181181
{
182-
for (ItemStack stack : user.getInventory().getContents())
182+
for (ItemStack stack : user.getBase().getInventory().getContents())
183183
{
184184
if (stack == null || stack.getType() == Material.AIR)
185185
{
@@ -190,7 +190,7 @@ else if (args[0].equalsIgnoreCase("inventory") || args[0].equalsIgnoreCase("inve
190190
}
191191
else if (args[0].equalsIgnoreCase("blocks"))
192192
{
193-
for (ItemStack stack : user.getInventory().getContents())
193+
for (ItemStack stack : user.getBase().getInventory().getContents())
194194
{
195195
if (stack == null || stack.getTypeId() > 255 || stack.getType() == Material.AIR)
196196
{

Essentials/src/com/earth2me/essentials/Kit.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -204,11 +204,11 @@ public static void expandItems(final IEssentials ess, final User user, final Lis
204204
final boolean allowOversizedStacks = user.isAuthorized("essentials.oversizedstacks");
205205
if (allowOversizedStacks)
206206
{
207-
overfilled = InventoryWorkaround.addOversizedItems(user.getInventory(), ess.getSettings().getOversizedStackSize(), metaStack.getItemStack());
207+
overfilled = InventoryWorkaround.addOversizedItems(user.getBase().getInventory(), ess.getSettings().getOversizedStackSize(), metaStack.getItemStack());
208208
}
209209
else
210210
{
211-
overfilled = InventoryWorkaround.addItems(user.getInventory(), metaStack.getItemStack());
211+
overfilled = InventoryWorkaround.addItems(user.getBase().getInventory(), metaStack.getItemStack());
212212
}
213213
for (ItemStack itemStack : overfilled.values())
214214
{
@@ -223,15 +223,15 @@ public static void expandItems(final IEssentials ess, final User user, final Lis
223223
spew = true;
224224
}
225225
}
226-
user.updateInventory();
226+
user.getBase().updateInventory();
227227
if (spew)
228228
{
229229
user.sendMessage(tl("kitInvFull"));
230230
}
231231
}
232232
catch (Exception e)
233233
{
234-
user.updateInventory();
234+
user.getBase().updateInventory();
235235
ess.getLogger().log(Level.WARNING, e.getMessage());
236236
throw new Exception(tl("kitError2"), e);
237237
}

Essentials/src/com/earth2me/essentials/User.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, net.es
5151
teleport = new Teleport(this, ess);
5252
if (isAfk())
5353
{
54-
afkPosition = this.getBase().getLocation();
54+
afkPosition = this.getLocation();
5555
}
5656
if (this.getBase().isOnline())
5757
{
@@ -237,13 +237,13 @@ public Boolean canSpawnItem(final int itemId)
237237
@Override
238238
public void setLastLocation()
239239
{
240-
setLastLocation(this.getBase().getLocation());
240+
setLastLocation(this.getLocation());
241241
}
242242

243243
@Override
244244
public void setLogoutLocation()
245245
{
246-
setLogoutLocation(this.getBase().getLocation());
246+
setLogoutLocation(this.getLocation());
247247
}
248248

249249
@Override
@@ -258,7 +258,7 @@ public void requestTeleport(final User player, final boolean here)
258258
}
259259
else
260260
{
261-
teleportLocation = here ? player.getBase().getLocation() : this.getBase().getLocation();
261+
teleportLocation = here ? player.getLocation() : this.getLocation();
262262
}
263263
}
264264

@@ -497,7 +497,7 @@ public void setAfk(final boolean set)
497497
this.getBase().setSleepingIgnored(this.isAuthorized("essentials.sleepingignored") ? true : set);
498498
if (set && !isAfk())
499499
{
500-
afkPosition = this.getBase().getLocation();
500+
afkPosition = this.getLocation();
501501
}
502502
else if (!set && isAfk())
503503
{
@@ -643,7 +643,7 @@ public Location getAfkPosition()
643643
@Override
644644
public boolean isGodModeEnabled()
645645
{
646-
return (super.isGodModeEnabled() && !ess.getSettings().getNoGodWorlds().contains(this.getBase().getLocation().getWorld().getName()))
646+
return (super.isGodModeEnabled() && !ess.getSettings().getNoGodWorlds().contains(this.getLocation().getWorld().getName()))
647647
|| (isAfk() && ess.getSettings().getFreezeAfkPlayers());
648648
}
649649

Essentials/src/com/earth2me/essentials/Worth.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ public int getAmount(IEssentials ess, User user, ItemStack is, String[] args, bo
114114
}
115115

116116
int max = 0;
117-
for (ItemStack s : user.getInventory().getContents())
117+
for (ItemStack s : user.getBase().getInventory().getContents())
118118
{
119119
if (s == null || !s.isSimilar(is))
120120
{

Essentials/src/com/earth2me/essentials/commands/Commandban.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public void run(final Server server, final CommandSource sender, final String co
3535
nomatch = true;
3636
user = ess.getUser(new OfflinePlayer(args[0], ess));
3737
}
38-
if (!user.isOnline())
38+
if (!user.getBase().isOnline())
3939
{
4040
if (sender.isPlayer() && !ess.getUser(sender.getPlayer()).isAuthorized("essentials.ban.offline"))
4141
{
@@ -62,9 +62,9 @@ public void run(final Server server, final CommandSource sender, final String co
6262
}
6363

6464
user.setBanReason(tl("banFormat", banReason, senderName));
65-
user.setBanned(true);
65+
user.getBase().setBanned(true);
6666
user.setBanTimeout(0);
67-
user.kickPlayer(tl("banFormat", banReason, senderName));
67+
user.getBase().kickPlayer(tl("banFormat", banReason, senderName));
6868

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

Essentials/src/com/earth2me/essentials/commands/Commandbook.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public Commandbook()
1919
@Override
2020
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
2121
{
22-
final ItemStack item = user.getItemInHand();
22+
final ItemStack item = user.getBase().getItemInHand();
2323
final String player = user.getName();
2424
if (item.getType() == Material.WRITTEN_BOOK)
2525
{
@@ -57,7 +57,7 @@ else if (args.length > 1 && args[0].equalsIgnoreCase("title"))
5757
{
5858
ItemStack newItem = new ItemStack(Material.BOOK_AND_QUILL, item.getAmount());
5959
newItem.setItemMeta(bmeta);
60-
user.setItemInHand(newItem);
60+
user.getBase().setItemInHand(newItem);
6161
user.sendMessage(tl("editBookContents"));
6262
}
6363
else
@@ -75,7 +75,7 @@ else if (item.getType() == Material.BOOK_AND_QUILL)
7575
}
7676
ItemStack newItem = new ItemStack(Material.WRITTEN_BOOK, item.getAmount());
7777
newItem.setItemMeta(bmeta);
78-
user.setItemInHand(newItem);
78+
user.getBase().setItemInHand(newItem);
7979
user.sendMessage(tl("bookLocked"));
8080
}
8181
else

Essentials/src/com/earth2me/essentials/commands/Commandbreak.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public Commandbreak()
1919
@Override
2020
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
2121
{
22-
final Block block = user.getTargetBlock(null, 20);
22+
final Block block = user.getBase().getTargetBlock(null, 20);
2323
if (block == null)
2424
{
2525
throw new NoChargeException();

Essentials/src/com/earth2me/essentials/commands/Commandburn.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ protected void run(final Server server, final CommandSource sender, final String
2727
}
2828

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

0 commit comments

Comments
 (0)