mirror of
https://github.com/essentials/Essentials.git
synced 2025-08-30 17:59:53 +02:00
Added exempt/offline permissions to fly, god, gamemode and socialspy command. Added more options to socialspy
This commit is contained in:
@@ -39,7 +39,6 @@ public interface IUser extends OfflinePlayer, CommandSender, IStorageObjectHolde
|
||||
Location getHome(Location loc);
|
||||
|
||||
//boolean isHidden();
|
||||
|
||||
ITeleport getTeleport();
|
||||
|
||||
void checkCooldown(UserData.TimestampType cooldownType, double cooldown, boolean set, IPermission bypassPermission) throws CooldownException;
|
||||
@@ -84,8 +83,6 @@ public interface IUser extends OfflinePlayer, CommandSender, IStorageObjectHolde
|
||||
|
||||
void setMuted(boolean mute);
|
||||
|
||||
boolean toggleSocialSpy();
|
||||
|
||||
void requestTeleport(IUser user, boolean b);
|
||||
|
||||
boolean isTpRequestHere();
|
||||
@@ -115,17 +112,17 @@ public interface IUser extends OfflinePlayer, CommandSender, IStorageObjectHolde
|
||||
boolean isInvSee();
|
||||
|
||||
void setInvSee(boolean invsee);
|
||||
|
||||
|
||||
boolean isEnderSee();
|
||||
|
||||
|
||||
void setEnderSee(boolean endersee);
|
||||
|
||||
boolean hasInvulnerabilityAfterTeleport();
|
||||
|
||||
void setGodModeEnabled(boolean set);
|
||||
|
||||
void setVanished(boolean set);
|
||||
|
||||
void setVanished(boolean set);
|
||||
|
||||
boolean checkSignThrottle(int throttle);
|
||||
|
||||
/**
|
||||
|
@@ -40,6 +40,11 @@ public class Commandfly extends EssentialsCommand
|
||||
{
|
||||
for (IUser matchPlayer : ess.getUserMap().matchUsersExcludingHidden(args[0], getPlayerOrNull(sender)))
|
||||
{
|
||||
if (Permissions.FLY_EXEMPT.isAuthorized(matchPlayer))
|
||||
{
|
||||
sender.sendMessage("Can't change fly mode for player " + matchPlayer.getName()); //TODO: I18n
|
||||
continue;
|
||||
}
|
||||
if (args.length > 1)
|
||||
{
|
||||
if (args[1].contains("on") || args[1].contains("ena") || args[1].equalsIgnoreCase("1"))
|
||||
@@ -60,7 +65,9 @@ public class Commandfly extends EssentialsCommand
|
||||
{
|
||||
matchPlayer.getPlayer().setFlying(false);
|
||||
}
|
||||
sender.sendMessage(_("flyMode", _(matchPlayer.getPlayer().getAllowFlight() ? "enabled" : "disabled"), matchPlayer.getPlayer().getDisplayName()));
|
||||
final String message = _("flyMode", _(matchPlayer.getPlayer().getAllowFlight() ? "enabled" : "disabled"), matchPlayer.getPlayer().getDisplayName());
|
||||
matchPlayer.sendMessage(message);
|
||||
sender.sendMessage(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -37,7 +37,12 @@ public class Commandgamemode extends EssentialsCommand
|
||||
private void gamemodeOtherPlayers(final CommandSender sender, final String args[])
|
||||
{
|
||||
for (IUser player : ess.getUserMap().matchUsersExcludingHidden(args[0], getPlayerOrNull(sender)))
|
||||
{
|
||||
{
|
||||
if (Permissions.GAMEMODE_EXEMPT.isAuthorized(player))
|
||||
{
|
||||
sender.sendMessage("Can't change gamemode for player " + player.getPlayer().getDisplayName()); //TODO: I18n
|
||||
continue;
|
||||
}
|
||||
if (args.length > 1)
|
||||
{
|
||||
if (args[1].contains("creat") || args[1].equalsIgnoreCase("1"))
|
||||
|
@@ -36,6 +36,13 @@ public class Commandgod extends EssentialsCommand
|
||||
{
|
||||
for (IUser player : ess.getUserMap().matchUsers(args[0], true))
|
||||
{
|
||||
if (player.isOnline()
|
||||
? Permissions.GOD_EXEMPT.isAuthorized(player)
|
||||
: !Permissions.GOD_OFFLINE.isAuthorized(sender))
|
||||
{
|
||||
sender.sendMessage("Can't change god mode for player " + player.getName()); //TODO: I18n
|
||||
continue;
|
||||
}
|
||||
if (args.length > 1)
|
||||
{
|
||||
if (args[1].contains("on") || args[1].contains("ena") || args[1].equalsIgnoreCase("1"))
|
||||
|
@@ -2,13 +2,70 @@ package net.ess3.commands;
|
||||
|
||||
import static net.ess3.I18n._;
|
||||
import net.ess3.api.IUser;
|
||||
import net.ess3.permissions.Permissions;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
|
||||
public class Commandsocialspy extends EssentialsCommand
|
||||
{
|
||||
@Override
|
||||
public void run(final IUser user, final String commandLabel, final String[] args) throws Exception
|
||||
public void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
user.sendMessage("§7SocialSpy " + (user.toggleSocialSpy() ? _("enabled") : _("disabled")));
|
||||
if (args.length < 1)
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
socialspyOtherPlayers(sender, args);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(final IUser user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length > 0 && !args[0].trim().isEmpty() && Permissions.SOCIALSPY_OTHERS.isAuthorized(user))
|
||||
{
|
||||
socialspyOtherPlayers(user, args);
|
||||
return;
|
||||
}
|
||||
|
||||
user.getData().setSocialspy(!user.getData().isSocialspy());
|
||||
user.queueSave();
|
||||
user.sendMessage("§7SocialSpy " + (user.getData().isSocialspy() ? _("enabled") : _("disabled")));
|
||||
}
|
||||
|
||||
private void socialspyOtherPlayers(final CommandSender sender, final String[] args)
|
||||
{
|
||||
for (IUser player : ess.getUserMap().matchUsers(args[0], true))
|
||||
{
|
||||
if (player.isOnline()
|
||||
? Permissions.SOCIALSPY_EXEMPT.isAuthorized(player)
|
||||
: !Permissions.SOCIALSPY_OFFLINE.isAuthorized(sender))
|
||||
{
|
||||
sender.sendMessage("Can't change socialspy for player " + player.getName()); //TODO: I18n
|
||||
continue;
|
||||
}
|
||||
if (args.length > 1)
|
||||
{
|
||||
if (args[1].contains("on") || args[1].contains("ena") || args[1].equalsIgnoreCase("1"))
|
||||
{
|
||||
player.getData().setSocialspy(true);
|
||||
player.queueSave();
|
||||
}
|
||||
else
|
||||
{
|
||||
player.getData().setSocialspy(false);
|
||||
player.queueSave();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
player.getData().setSocialspy(!player.getData().isSocialspy());
|
||||
player.queueSave();
|
||||
}
|
||||
|
||||
final boolean enabled = player.getData().isSocialspy();
|
||||
player.sendMessage("§7SocialSpy " + (enabled ? _("enabled") : _("disabled"))); //TODO:I18n
|
||||
sender.sendMessage("§7SocialSpy " + (enabled ? _("enabled") : _("disabled")));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -36,11 +36,15 @@ public enum Permissions implements IPermission
|
||||
EXP_SET_OTHERS,
|
||||
EXP_OTHERS,
|
||||
FEED_OTHERS,
|
||||
FLY_EXEMPT,
|
||||
FLY_OTHERS,
|
||||
GAMEMODE_EXEMPT,
|
||||
GAMEMODE_OTHERS,
|
||||
GEOIP_HIDE(PermissionDefault.FALSE),
|
||||
GEOIP_SHOW(PermissionDefault.TRUE),
|
||||
GETPOS_OTHERS,
|
||||
GOD_EXEMPT,
|
||||
GOD_OFFLINE,
|
||||
GOD_OTHERS,
|
||||
GIVE_ENCHANTED,
|
||||
GIVE_ENCHANTED_UNSAFE(PermissionDefault.FALSE),
|
||||
@@ -83,6 +87,9 @@ public enum Permissions implements IPermission
|
||||
SPAWN_OTHERS,
|
||||
SPEED_BYPASS,
|
||||
SPEED_OTHERS,
|
||||
SOCIALSPY_EXEMPT,
|
||||
SOCIALSPY_OFFLINE,
|
||||
SOCIALSPY_OTHERS,
|
||||
SUDO_EXEMPT,
|
||||
TELEPORT_COOLDOWN_BYPASS,
|
||||
TELEPORT_HIDDEN,
|
||||
|
@@ -230,14 +230,6 @@ public abstract class UserBase extends AsyncStorageObjectHolder<UserData> implem
|
||||
queueSave();
|
||||
}
|
||||
|
||||
public boolean toggleSocialSpy()
|
||||
{
|
||||
boolean ret = !getData().isSocialspy();
|
||||
getData().setSocialspy(ret);
|
||||
queueSave();
|
||||
return ret;
|
||||
}
|
||||
|
||||
public boolean toggleTeleportEnabled()
|
||||
{
|
||||
boolean ret = !getData().isTeleportEnabled();
|
||||
|
@@ -320,7 +320,7 @@ commands:
|
||||
aliases: [esetworth]
|
||||
socialspy:
|
||||
description: Toggles if you can see msg/mail commands in chat.
|
||||
usage: /<command>
|
||||
usage: /<command> [player] [on|off]
|
||||
aliases: [esocialspy]
|
||||
spawn:
|
||||
description: Teleport to the spawnpoint.
|
||||
|
Reference in New Issue
Block a user