mirror of
https://github.com/essentials/Essentials.git
synced 2025-08-22 06:12:56 +02:00
2.9 -> 3.0
Adding world pems to the various commands (this should be seperated out to its own method)
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
@@ -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)
|
||||
{
|
||||
|
@@ -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
|
||||
|
@@ -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);
|
||||
}
|
||||
|
@@ -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)
|
||||
{
|
||||
|
@@ -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()));
|
||||
}
|
||||
|
@@ -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));
|
||||
|
@@ -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));
|
||||
|
@@ -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);
|
||||
|
@@ -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));
|
||||
|
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -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();
|
||||
|
@@ -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()));
|
||||
}
|
||||
|
@@ -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))
|
||||
{
|
||||
|
@@ -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);
|
||||
}
|
||||
|
@@ -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);
|
||||
|
@@ -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;
|
||||
|
@@ -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)
|
||||
|
@@ -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.");
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user