diff options
author | ementalo <ementalodev@gmx.co.uk> | 2012-05-30 13:12:50 +0100 |
---|---|---|
committer | ementalo <ementalodev@gmx.co.uk> | 2012-05-30 13:12:50 +0100 |
commit | cea3113df4dba1b131b85322d5c02d670dfdf85f (patch) | |
tree | c0497e3027babe03ea3e82c8969d534e30980a31 | |
parent | 53d54146d631d94def8202aa61d6bd6f47e24313 (diff) | |
download | Essentials-cea3113df4dba1b131b85322d5c02d670dfdf85f.tar Essentials-cea3113df4dba1b131b85322d5c02d670dfdf85f.tar.gz Essentials-cea3113df4dba1b131b85322d5c02d670dfdf85f.tar.lz Essentials-cea3113df4dba1b131b85322d5c02d670dfdf85f.tar.xz Essentials-cea3113df4dba1b131b85322d5c02d670dfdf85f.zip |
2.9 -> 3.0
Adding world pems to the various commands (this should be seperated out to its own method)
19 files changed, 150 insertions, 137 deletions
diff --git a/Essentials/src/com/earth2me/essentials/api/IUser.java b/Essentials/src/com/earth2me/essentials/api/IUser.java index 6d225bce6..a1d49f250 100644 --- a/Essentials/src/com/earth2me/essentials/api/IUser.java +++ b/Essentials/src/com/earth2me/essentials/api/IUser.java @@ -92,7 +92,7 @@ public interface IUser extends Player, IStorageObjectHolder<UserData>, IReload, void requestTeleport(IUser user, boolean b); - boolean isTeleportRequestHere(); + boolean isTpRequestHere(); IUser getTeleportRequester(); @@ -115,4 +115,6 @@ public interface IUser extends Player, IStorageObjectHolder<UserData>, IReload, void resetInvulnerabilityAfterTeleport(); void toggleVanished(); + + void update(final Player base); } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandseen.java b/Essentials/src/com/earth2me/essentials/commands/Commandseen.java index 5dcaa0f2a..fd20419ff 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandseen.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandseen.java @@ -4,6 +4,7 @@ import static com.earth2me.essentials.I18n._; import com.earth2me.essentials.utils.Util; import com.earth2me.essentials.api.IUser; import com.earth2me.essentials.permissions.Permissions; +import com.earth2me.essentials.storage.Location; import com.earth2me.essentials.user.UserData.TimestampType; import com.earth2me.essentials.utils.DateUtil; import lombok.Cleanup; @@ -15,16 +16,16 @@ public class Commandseen extends EssentialsCommand @Override protected void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception { - seen(sender,args,true); + seen(sender,args,true, true); } @Override protected void run(final IUser user, final String commandLabel, final String[] args) throws Exception { - seen(user,args,Permissions.SEEN_BANREASON.isAuthorized(user)); + seen(user,args,Permissions.SEEN_BANREASON.isAuthorized(user), Permissions.SEEN_EXTRA.isAuthorized(user)); } - protected void seen (final CommandSender sender, final String[] args, final boolean show) throws Exception + protected void seen (final CommandSender sender, final String[] args, final boolean showBan, final boolean extra) throws Exception { if (args.length < 1) { @@ -32,24 +33,28 @@ public class Commandseen extends EssentialsCommand } try { - IUser u = getPlayer(args, 0); + IUser player = getPlayer(args, 0); player.setDisplayNick(); - sender.sendMessage(_("seenOnline", u.getDisplayName(), DateUtil.formatDateDiff(u.getTimestamp(TimestampType.LOGIN)))); + sender.sendMessage(_("seenOnline", player.getDisplayName(), DateUtil.formatDateDiff(player.getTimestamp(TimestampType.LOGIN)))); + if (extra) + { + sender.sendMessage(_("whoisIPAddress", player.getAddress().getAddress().toString())); + } } catch (NoSuchFieldException e) { @Cleanup - IUser u = ess.getUser(args[0]); - u.acquireReadLock(); - if (u == null) + IUser player = ess.getUser(args[0]); + player.acquireReadLock(); + if (player == null) { throw new Exception(_("playerNotFound")); } player.setDisplayNick(); - sender.sendMessage(_("seenOffline", u.getDisplayName(), DateUtil.formatDateDiff(u.getTimestamp(TimestampType.LOGOUT)))); - if (u.isBanned()) + sender.sendMessage(_("seenOffline", player.getName(), DateUtil.formatDateDiff(player.getTimestamp(TimestampType.LOGOUT)))); + if (player.isBanned()) { - sender.sendMessage(_("whoisBanned", show ? u.getData().getBan().getReason() : _("true"))); + sender.sendMessage(_("whoisBanned", showBan ? player.getData().getBan().getReason() : _("true"))); } if (extra) { diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandsetjail.java b/Essentials/src/com/earth2me/essentials/commands/Commandsetjail.java index fea08f7a0..0b4c7f3ff 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandsetjail.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandsetjail.java @@ -2,6 +2,7 @@ package com.earth2me.essentials.commands; import static com.earth2me.essentials.I18n._; import com.earth2me.essentials.api.IUser; +import com.earth2me.essentials.utils.Util; public class Commandsetjail extends EssentialsCommand diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandsetwarp.java b/Essentials/src/com/earth2me/essentials/commands/Commandsetwarp.java index 72b42fe7c..8a1797f81 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandsetwarp.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandsetwarp.java @@ -3,8 +3,7 @@ package com.earth2me.essentials.commands; import static com.earth2me.essentials.I18n._; import com.earth2me.essentials.api.IUser; import com.earth2me.essentials.api.IWarps; -import com.earth2me.essentials.Util; -import com.earth2me.essentials.Warps; +import com.earth2me.essentials.permissions.WarpPermissions; import org.bukkit.Location; @@ -35,7 +34,9 @@ public class Commandsetwarp extends EssentialsCommand { } - if (warpLoc == null || user.hasPermission("essentials.warp.overwrite." + args[0])) + //todo permissions + if (warpLoc == null || WarpPermissions.getPermission("overwrite." + args[0]).isAuthorized(user)) + { warps.setWarp(args[0], loc); } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandspawner.java b/Essentials/src/com/earth2me/essentials/commands/Commandspawner.java index 96670fa94..81ae6a659 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandspawner.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandspawner.java @@ -2,6 +2,7 @@ package com.earth2me.essentials.commands; import com.earth2me.essentials.*; import static com.earth2me.essentials.I18n._; +import com.earth2me.essentials.api.ISettings; import com.earth2me.essentials.bukkit.Mob; import com.earth2me.essentials.economy.Trade; import com.earth2me.essentials.api.IUser; @@ -9,6 +10,7 @@ import com.earth2me.essentials.permissions.SpawnerPermissions; import com.earth2me.essentials.utils.LocationUtil; import com.earth2me.essentials.utils.Util; import java.util.Locale; +import lombok.Cleanup; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.CreatureSpawner; @@ -39,11 +41,14 @@ public class Commandspawner extends EssentialsCommand { throw new Exception(_("invalidMob")); } - if (ess.getSettings().getData().getGeneral().getPreventSpawn(mob.getType().toString().toLowerCase(Locale.ENGLISH))) + @Cleanup + ISettings settings = ess.getSettings(); + settings.acquireReadLock(); + if (settings.getData().getGeneral().getPreventSpawn(mob.getType().toString().toLowerCase(Locale.ENGLISH))) { throw new Exception(_("disabledToSpawnMob")); } - if (!user.isAuthorized("essentials.spawner." + mob.name.toLowerCase(Locale.ENGLISH))) + if (!SpawnerPermissions.getPermission(mob.name.toLowerCase(Locale.ENGLISH)).isAuthorized(user)) { throw new Exception(_("noPermToSpawnMob")); } @@ -51,24 +56,8 @@ public class Commandspawner extends EssentialsCommand charge.isAffordableFor(user); try { - String name = args[0]; - - Mob mob = null; - mob = Mob.fromName(name); - if (mob == null) - { - user.sendMessage(_("invalidMob")); - return; - } - if (!SpawnerPermissions.getPermission(mob.name).isAuthorized(user)) - { - throw new Exception(_("unableToSpawnMob")); - } - final Trade charge = new Trade("spawner-" + mob.name.toLowerCase(Locale.ENGLISH), ess); - charge.isAffordableFor(user); ((CreatureSpawner)target.getBlock().getState()).setSpawnedType(mob.getType()); - charge.charge(user); - user.sendMessage(_("setSpawner", mob.name)); + } catch (Throwable ex) { diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtp.java b/Essentials/src/com/earth2me/essentials/commands/Commandtp.java index f508c872c..93b0277e1 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandtp.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandtp.java @@ -2,9 +2,11 @@ package com.earth2me.essentials.commands; import com.earth2me.essentials.Console; import static com.earth2me.essentials.I18n._; +import com.earth2me.essentials.api.ISettings; import com.earth2me.essentials.economy.Trade; import com.earth2me.essentials.api.IUser; import com.earth2me.essentials.permissions.Permissions; +import com.earth2me.essentials.permissions.WorldPermissions; import lombok.Cleanup; import org.bukkit.command.CommandSender; import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; @@ -15,6 +17,9 @@ public class Commandtp extends EssentialsCommand @Override public void run(final IUser user, final String commandLabel, final String[] args) throws Exception { + @Cleanup + ISettings settings = ess.getSettings(); + settings.acquireReadLock(); switch (args.length) { case 0: @@ -28,8 +33,8 @@ public class Commandtp extends EssentialsCommand { throw new Exception(_("teleportDisabled", player.getDisplayName())); } - if (user.getWorld() != player.getWorld() && ess.getSettings().isWorldTeleportPermissions() - && !user.isAuthorized("essentials.world." + player.getWorld().getName())) + if (user.getWorld() != player.getWorld() && settings.getData().getGeneral().isWorldTeleportPermissions() + && !WorldPermissions.getPermission(player.getWorld().getName()).isAuthorized(user)) { throw new Exception(_("noPerm", "essentials.world." + player.getWorld().getName())); } @@ -45,18 +50,23 @@ public class Commandtp extends EssentialsCommand throw new Exception(_("needTpohere")); } user.sendMessage(_("teleporting")); + @Cleanup final IUser target = getPlayer(args, 0); + @Cleanup final IUser toPlayer = getPlayer(args, 1); - if (!target.isTeleportEnabled()) + target.acquireReadLock(); + toPlayer.acquireReadLock(); + + if (!target.getData().isTeleportEnabled()) { throw new Exception(_("teleportDisabled", target.getDisplayName())); } - if (!toPlayer.isTeleportEnabled()) + if (!toPlayer.getData().isTeleportEnabled()) { throw new Exception(_("teleportDisabled", toPlayer.getDisplayName())); } - if (target.getWorld() != toPlayer.getWorld() && ess.getSettings().isWorldTeleportPermissions() - && !user.isAuthorized("essentials.world." + toPlayer.getWorld().getName())) + if (target.getWorld() != toPlayer.getWorld() && settings.getData().getGeneral().isWorldTeleportPermissions() + && !WorldPermissions.getPermission(toPlayer.getWorld().getName()).isAuthorized(user)) { throw new Exception(_("noPerm", "essentials.world." + toPlayer.getWorld().getName())); } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtpa.java b/Essentials/src/com/earth2me/essentials/commands/Commandtpa.java index 6ce71b3ba..6e5f7ec53 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandtpa.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandtpa.java @@ -3,6 +3,7 @@ package com.earth2me.essentials.commands; import static com.earth2me.essentials.I18n._; import com.earth2me.essentials.api.ISettings; import com.earth2me.essentials.api.IUser; +import com.earth2me.essentials.permissions.WorldPermissions; import lombok.Cleanup; @@ -23,25 +24,22 @@ public class Commandtpa extends EssentialsCommand { throw new Exception(_("teleportDisabled", player.getDisplayName())); } - if (user.getWorld() != player.getWorld() && ess.getSettings().isWorldTeleportPermissions() - && !user.isAuthorized("essentials.world." + player.getWorld().getName())) + @Cleanup + ISettings settings = ess.getSettings(); + settings.acquireReadLock(); + if (user.getWorld() != player.getWorld() && ess.getSettings().getData().getGeneral().isWorldTeleportPermissions() + && !WorldPermissions.getPermission(user.getWorld().getName()).isAuthorized(user)) { throw new Exception(_("noPerm", "essentials.world." + player.getWorld().getName())); } - if (!player.isIgnoredPlayer(user.getName())) + if (!player.isIgnoringPlayer(user.getName())) { player.requestTeleport(user, false); player.sendMessage(_("teleportRequest", user.getDisplayName())); player.sendMessage(_("typeTpaccept")); player.sendMessage(_("typeTpdeny")); int tpaAcceptCancellation = 0; - ISettings settings = ess.getSettings(); - settings.acquireReadLock(); - try { - tpaAcceptCancellation = settings.getData().getCommands().getTpa().getTimeout(); - } finally { - settings.unlock(); - } + tpaAcceptCancellation = settings.getData().getCommands().getTpa().getTimeout(); if (tpaAcceptCancellation != 0) { player.sendMessage(_("teleportRequestTimeoutInfo", tpaAcceptCancellation)); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtpaall.java b/Essentials/src/com/earth2me/essentials/commands/Commandtpaall.java index 7f7d36413..b5b889c30 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandtpaall.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandtpaall.java @@ -3,6 +3,7 @@ package com.earth2me.essentials.commands; import static com.earth2me.essentials.I18n._; import com.earth2me.essentials.api.ISettings; import com.earth2me.essentials.api.IUser; +import com.earth2me.essentials.permissions.WorldPermissions; import lombok.Cleanup; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; @@ -43,8 +44,11 @@ public class Commandtpaall extends EssentialsCommand { continue; } - if (user.getWorld() != player.getWorld() && ess.getSettings().isWorldTeleportPermissions() - && !user.isAuthorized("essentials.world." + user.getWorld().getName())) + @Cleanup + ISettings settings = ess.getSettings(); + settings.acquireReadLock(); + if (user.getWorld() != player.getWorld() && settings.getData().getGeneral().isWorldTeleportPermissions() + && !WorldPermissions.getPermission(user.getWorld().getName()).isAuthorized(user)) { continue; } @@ -54,16 +58,7 @@ public class Commandtpaall extends EssentialsCommand player.sendMessage(_("teleportHereRequest", user.getDisplayName())); player.sendMessage(_("typeTpaccept")); int tpaAcceptCancellation = 0; - ISettings settings = ess.getSettings(); - settings.acquireReadLock(); - try - { - tpaAcceptCancellation = settings.getData().getCommands().getTpa().getTimeout(); - } - finally - { - settings.unlock(); - } + tpaAcceptCancellation = settings.getData().getCommands().getTpa().getTimeout(); if (tpaAcceptCancellation != 0) { player.sendMessage(_("teleportRequestTimeoutInfo", tpaAcceptCancellation)); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtpaccept.java b/Essentials/src/com/earth2me/essentials/commands/Commandtpaccept.java index 8b7cb7b1b..e0f3b7d0c 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandtpaccept.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandtpaccept.java @@ -1,11 +1,12 @@ package com.earth2me.essentials.commands; import static com.earth2me.essentials.I18n._; -import com.earth2me.essentials.economy.Trade; import com.earth2me.essentials.api.ISettings; import com.earth2me.essentials.api.IUser; +import com.earth2me.essentials.economy.Trade; import com.earth2me.essentials.permissions.Permissions; -import org.bukkit.OfflinePlayer; +import com.earth2me.essentials.permissions.WorldPermissions; +import lombok.Cleanup; import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; @@ -14,58 +15,29 @@ public class Commandtpaccept extends EssentialsCommand @Override public void run(final IUser user, final String commandLabel, final String[] args) throws Exception { - if (user.getTeleportRequester() == null) - { - throw new Exception(_("noPendingRequest")); - } - final IUser target = user.getTeleportRequester(); - if (target == null - || !target.isOnline() - || (user.isTeleportRequestHere() && !Permissions.TPAHERE.isAuthorized(target)) - || (!user.isTeleportRequestHere() && !Permissions.TPA.isAuthorized(target) && !Permissions.TPAALL.isAuthorized(target))) - { - throw new Exception(_("noPendingRequest")); - } - - if (user.isTpRequestHere() && ((!target.isAuthorized("essentials.tpahere") && !target.isAuthorized("essentials.tpaall")) - || (user.getWorld() != target.getWorld() && ess.getSettings().isWorldTeleportPermissions() - && !user.isAuthorized("essentials.world." + user.getWorld().getName())))) - { - throw new Exception(_("noPendingRequest")); - } - - if (!user.isTpRequestHere() && (!target.isAuthorized("essentials.tpa") - || (user.getWorld() != target.getWorld() && ess.getSettings().isWorldTeleportPermissions() - && !user.isAuthorized("essentials.world." + target.getWorld().getName())))) - { - throw new Exception(_("noPendingRequest")); - } - - if (args.length > 0 && !target.getName().contains(args[0])) - { - throw new Exception(_("noPendingRequest")); - } - - int tpaAcceptCancellation = 0; + @Cleanup ISettings settings = ess.getSettings(); settings.acquireReadLock(); - try + if (target == null || !target.isOnline() + || (args.length > 0 && !target.getName().contains(args[0])) + || (user.isTpRequestHere() && !Permissions.TPAHERE.isAuthorized(target)) + || (!user.isTpRequestHere() && ((!Permissions.TPA.isAuthorized(target) && !Permissions.TPAALL.isAuthorized(target)) + || (user.getWorld() != target.getWorld() + && settings.getData().getGeneral().isWorldTeleportPermissions() + && !WorldPermissions.getPermission(user.getWorld().getName()).isAuthorized(user))))) { - tpaAcceptCancellation = settings.getData().getCommands().getTpa().getTimeout(); - } - finally - { - settings.unlock(); + throw new Exception(_("noPendingRequest")); } - if (tpaAcceptCancellation != 0 && (System.currentTimeMillis() - user.getTeleportRequestTime()) / 1000 > tpaAcceptCancellation) + long timeout = settings.getData().getCommands().getTpa().getTimeout(); + if (timeout != 0 && (System.currentTimeMillis() - user.getTeleportRequestTime()) / 1000 > timeout) { user.requestTeleport(null, false); throw new Exception(_("requestTimedOut")); } - final Trade charge = new Trade(commandName, ess); + final Trade charge = new Trade(this.commandName, ess); if (user.isTpRequestHere()) { charge.isAffordableFor(user); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtpahere.java b/Essentials/src/com/earth2me/essentials/commands/Commandtpahere.java index c32a14470..c483f256b 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandtpahere.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandtpahere.java @@ -3,6 +3,7 @@ package com.earth2me.essentials.commands; import static com.earth2me.essentials.I18n._; import com.earth2me.essentials.api.ISettings; import com.earth2me.essentials.api.IUser; +import com.earth2me.essentials.permissions.WorldPermissions; import lombok.Cleanup; @@ -23,8 +24,11 @@ public class Commandtpahere extends EssentialsCommand { throw new Exception(_("teleportDisabled", player.getDisplayName())); } - if (user.getWorld() != player.getWorld() && ess.getSettings().isWorldTeleportPermissions() - && !user.isAuthorized("essentials.world." + user.getWorld().getName())) + @Cleanup + ISettings settings = ess.getSettings(); + settings.acquireReadLock(); + if (user.getWorld() != player.getWorld() && ess.getSettings().getData().getGeneral().isWorldTeleportPermissions() + && !WorldPermissions.getPermission(user.getWorld().getName()).isAuthorized(user)) { throw new Exception(_("noPerm", "essentials.world." + user.getWorld().getName())); } @@ -32,16 +36,9 @@ public class Commandtpahere extends EssentialsCommand player.sendMessage(_("teleportHereRequest", user.getDisplayName())); player.sendMessage(_("typeTpaccept")); int tpaAcceptCancellation = 0; - ISettings settings = ess.getSettings(); - settings.acquireReadLock(); - try { tpaAcceptCancellation = settings.getData().getCommands().getTpa().getTimeout(); } - finally - { - settings.unlock(); - } if (tpaAcceptCancellation != 0) { player.sendMessage(_("teleportRequestTimeoutInfo", tpaAcceptCancellation)); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtpall.java b/Essentials/src/com/earth2me/essentials/commands/Commandtpall.java index fb7efcdcb..a34ce13bd 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandtpall.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandtpall.java @@ -1,7 +1,10 @@ package com.earth2me.essentials.commands; import static com.earth2me.essentials.I18n._; +import com.earth2me.essentials.api.ISettings; import com.earth2me.essentials.api.IUser; +import com.earth2me.essentials.permissions.WorldPermissions; +import lombok.Cleanup; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; @@ -36,8 +39,12 @@ public class Commandtpall extends EssentialsCommand { continue; } - if (user.getWorld() != player.getWorld() && ess.getSettings().isWorldTeleportPermissions() - && !user.isAuthorized("essentials.world." + user.getWorld().getName())) + @Cleanup + ISettings settings = ess.getSettings(); + settings.acquireReadLock(); + + if (user.getWorld() != player.getWorld() && ess.getSettings().getData().getGeneral().isWorldTeleportPermissions() + && !WorldPermissions.getPermission(user.getWorld().getName()).isAuthorized(user)) { continue; } @@ -49,6 +56,7 @@ public class Commandtpall extends EssentialsCommand { ess.getCommandHandler().showCommandError(sender, commandName, ex); } + } } -} +}
\ No newline at end of file diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtphere.java b/Essentials/src/com/earth2me/essentials/commands/Commandtphere.java index a995e31f4..d5449c9e5 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandtphere.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandtphere.java @@ -1,8 +1,10 @@ package com.earth2me.essentials.commands; import static com.earth2me.essentials.I18n._; -import com.earth2me.essentials.economy.Trade; +import com.earth2me.essentials.api.ISettings; import com.earth2me.essentials.api.IUser; +import com.earth2me.essentials.economy.Trade; +import com.earth2me.essentials.permissions.WorldPermissions; import lombok.Cleanup; import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; @@ -19,12 +21,15 @@ public class Commandtphere extends EssentialsCommand { throw new Exception(_("teleportDisabled", player.getDisplayName())); } - if (user.getWorld() != player.getWorld() && ess.getSettings().isWorldTeleportPermissions() - && !user.isAuthorized("essentials.world." + user.getWorld().getName())) + @Cleanup + ISettings settings = ess.getSettings(); + settings.acquireReadLock(); + if (user.getWorld() != player.getWorld() && ess.getSettings().getData().getGeneral().isWorldTeleportPermissions() + && !WorldPermissions.getPermission(user.getWorld().getName()).isAuthorized(user)) { throw new Exception(_("noPerm", "essentials.world." + user.getWorld().getName())); } - player.getTeleport().teleport(user, new Trade(this.getName(), ess), TeleportCause.COMMAND); + player.getTeleport().teleport(user, new Trade(this.commandName, ess), TeleportCause.COMMAND); user.sendMessage(_("teleporting")); player.sendMessage(_("teleporting")); throw new NoChargeException(); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtpo.java b/Essentials/src/com/earth2me/essentials/commands/Commandtpo.java index 931f50202..0dc54b8d7 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandtpo.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandtpo.java @@ -1,8 +1,11 @@ package com.earth2me.essentials.commands; import static com.earth2me.essentials.I18n._; +import com.earth2me.essentials.api.ISettings; import com.earth2me.essentials.api.IUser; import com.earth2me.essentials.permissions.Permissions; +import com.earth2me.essentials.permissions.WorldPermissions; +import lombok.Cleanup; import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; @@ -11,6 +14,8 @@ public class Commandtpo extends EssentialsCommand @Override public void run(final IUser user, final String commandLabel, final String[] args) throws Exception { + @Cleanup + ISettings settings = ess.getSettings(); switch (args.length) { case 0: @@ -18,21 +23,23 @@ public class Commandtpo extends EssentialsCommand case 1: final IUser player = getPlayer(args, 0, true); - if (!player.isOnline() || (player.isHidden() && !user.isAuthorized("essentials.teleport.hidden"))) + if (!player.isOnline() || (player.isHidden() && !Permissions.TELEPORT_HIDDEN.isAuthorized(player))) { throw new NoSuchFieldException(_("playerNotFound")); } - if (user.getWorld() != player.getWorld() && ess.getSettings().isWorldTeleportPermissions() - && !user.isAuthorized("essentials.world." + player.getWorld().getName())) + settings.acquireReadLock(); + if (user.getWorld() != player.getWorld() && settings.getData().getGeneral().isWorldTeleportPermissions() + && !WorldPermissions.getPermission(player.getWorld().getName()).isAuthorized(player)) { throw new Exception(_("noPerm", "essentials.world." + player.getWorld().getName())); } + user.sendMessage(_("teleporting")); user.getTeleport().now(player, false, TeleportCause.COMMAND); break; default: - if (!user.isAuthorized("essentials.tp.others")) + if (!Permissions.TELEPORT_OTHERS.isAuthorized(user)) { throw new Exception(_("noPerm", "essentials.tp.others")); } @@ -41,13 +48,13 @@ public class Commandtpo extends EssentialsCommand final IUser toPlayer = getPlayer(args, 1, true); if (!target.isOnline() || !toPlayer.isOnline() - || ((target.isHidden() || toPlayer.isHidden()) && !user.isAuthorized("essentials.teleport.hidden"))) + || ((target.isHidden() || toPlayer.isHidden()) && !Permissions.TELEPORT_HIDDEN.isAuthorized(user))) { throw new NoSuchFieldException(_("playerNotFound")); } - - if (target.getWorld() != toPlayer.getWorld() && ess.getSettings().isWorldTeleportPermissions() - && !user.isAuthorized("essentials.world." + toPlayer.getWorld().getName())) + settings.acquireReadLock(); + if (target.getWorld() != toPlayer.getWorld() && ess.getSettings().getData().getGeneral().isWorldTeleportPermissions() + && !WorldPermissions.getPermission(toPlayer.getWorld().getName()).isAuthorized(user)) { throw new Exception(_("noPerm", "essentials.world." + toPlayer.getWorld().getName())); } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtpohere.java b/Essentials/src/com/earth2me/essentials/commands/Commandtpohere.java index e27613b20..c108f56f8 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandtpohere.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandtpohere.java @@ -1,8 +1,11 @@ package com.earth2me.essentials.commands; import static com.earth2me.essentials.I18n._; +import com.earth2me.essentials.api.ISettings; import com.earth2me.essentials.api.IUser; import com.earth2me.essentials.permissions.Permissions; +import com.earth2me.essentials.permissions.WorldPermissions; +import lombok.Cleanup; import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; @@ -24,13 +27,17 @@ public class Commandtpohere extends EssentialsCommand { throw new NoSuchFieldException(_("playerNotFound")); } - - if (user.getWorld() != player.getWorld() && ess.getSettings().isWorldTeleportPermissions() - && !user.isAuthorized("essentials.world." + user.getWorld().getName())) + @Cleanup + ISettings settings = ess.getSettings(); + settings.acquireReadLock(); + //todo - common method + if (user.getWorld() != player.getWorld() && settings.getData().getGeneral().isWorldTeleportPermissions() + && !WorldPermissions.getPermission(user.getWorld().getName()).isAuthorized(player)) { throw new Exception(_("noPerm", "essentials.world." + user.getWorld().getName())); } + // Verify permission if (!player.isHidden() || Permissions.TELEPORT_HIDDEN.isAuthorized(user)) { diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandvanish.java b/Essentials/src/com/earth2me/essentials/commands/Commandvanish.java index 032631056..ff4ca2ada 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandvanish.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandvanish.java @@ -2,6 +2,7 @@ package com.earth2me.essentials.commands; import static com.earth2me.essentials.I18n._; import com.earth2me.essentials.api.IUser; +import com.earth2me.essentials.permissions.Permissions; import org.bukkit.entity.Player; @@ -22,7 +23,7 @@ public class Commandvanish extends EssentialsCommand { for (Player p : server.getOnlinePlayers()) { - if (!ess.getUser(p).isAuthorized("essentials.vanish.see")) + if (!Permissions.VANISH_SEE_OTHERS.isAuthorized(p)) { p.hidePlayer(user); } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandwarp.java b/Essentials/src/com/earth2me/essentials/commands/Commandwarp.java index a809c3c8d..db146a107 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandwarp.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandwarp.java @@ -112,7 +112,7 @@ public class Commandwarp extends EssentialsCommand private void warpUser(final IUser user, final String name) throws Exception { final Trade chargeWarp = new Trade("warp-" + name.toLowerCase(Locale.ENGLISH).replace('_', '-'), ess); - final Trade chargeCmd = new Trade(this.getName(), ess); + final Trade chargeCmd = new Trade(this.commandName, ess); final double fullCharge = chargeWarp.getCommandCost(user) + chargeCmd.getCommandCost(user); final Trade charge = new Trade(fullCharge, ess); charge.isAffordableFor(user); diff --git a/Essentials/src/com/earth2me/essentials/permissions/Permissions.java b/Essentials/src/com/earth2me/essentials/permissions/Permissions.java index 151ed77c9..e832fbc8d 100644 --- a/Essentials/src/com/earth2me/essentials/permissions/Permissions.java +++ b/Essentials/src/com/earth2me/essentials/permissions/Permissions.java @@ -56,6 +56,7 @@ public enum Permissions implements IPermission REPAIR_ARMOR, REPAIR_ENCHANTED, SEEN_BANREASON, + SEEN_EXTRA, SETHOME_MULTIPLE, SETHOME_OTHERS, SLEEPINGIGNORED, @@ -63,6 +64,7 @@ public enum Permissions implements IPermission SUDO_EXEMPT, TELEPORT_COOLDOWN_BYPASS, TELEPORT_HIDDEN, + TELEPORT_OTHERS, TELEPORT_TIMER_BYPASS, TEMPBAN_EXEMPT, TEMPBAN_OFFLINE, @@ -74,7 +76,8 @@ public enum Permissions implements IPermission TPOHERE, UNLIMITED_OTHERS, WARP_LIST(PermissionDefault.TRUE), - WARP_OTHERS; + WARP_OTHERS, + VANISH_SEE_OTHERS; private static final String base = "essentials."; private final String permission; private final PermissionDefault defaultPerm; diff --git a/Essentials/src/com/earth2me/essentials/user/User.java b/Essentials/src/com/earth2me/essentials/user/User.java index e181ac1e3..1fa972441 100644 --- a/Essentials/src/com/earth2me/essentials/user/User.java +++ b/Essentials/src/com/earth2me/essentials/user/User.java @@ -73,7 +73,7 @@ public class User extends UserBase implements IUser @Getter private transient IUser teleportRequester; @Getter - private transient boolean teleportRequestHere; + private transient boolean tpRequestHere; @Getter private transient final ITeleport teleport; @Getter @@ -250,7 +250,7 @@ public class User extends UserBase implements IUser { teleportRequestTime = System.currentTimeMillis(); teleportRequester = player; - teleportRequestHere = here; + tpRequestHere = here; } public String getNick(boolean addprefixsuffix) diff --git a/EssentialsProtect/src/com/earth2me/essentials/protect/ProtectHolder.java b/EssentialsProtect/src/com/earth2me/essentials/protect/ProtectHolder.java index 2e2451397..c2ad4f8d3 100644 --- a/EssentialsProtect/src/com/earth2me/essentials/protect/ProtectHolder.java +++ b/EssentialsProtect/src/com/earth2me/essentials/protect/ProtectHolder.java @@ -19,4 +19,16 @@ public class ProtectHolder extends AsyncStorageObjectHolder<Protect> { return new File(ess.getDataFolder(), "protect.yml"); } + + @Override + public void finishRead() + { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void finishWrite() + { + throw new UnsupportedOperationException("Not supported yet."); + } } |