mirror of
https://github.com/essentials/Essentials.git
synced 2025-08-28 08:50:02 +02:00
Fix queue save in god/tptoggle
Use settings abstract for socialspy
This commit is contained in:
@@ -341,6 +341,7 @@ signFormatTemplate=[{0}]
|
|||||||
signProtectInvalidLocation=\u00a74You are not allowed to create sign here.
|
signProtectInvalidLocation=\u00a74You are not allowed to create sign here.
|
||||||
similarWarpExist=\u00a74A warp with a similar name already exists.
|
similarWarpExist=\u00a74A warp with a similar name already exists.
|
||||||
slimeMalformedSize=\u00a74Malformed size.
|
slimeMalformedSize=\u00a74Malformed size.
|
||||||
|
socialSpyMode=\u00a76SocialSpy\u00a7c {0} \u00a76for {1}\u00a76.
|
||||||
soloMob=\u00a74That mob likes to be alone.
|
soloMob=\u00a74That mob likes to be alone.
|
||||||
spawnSet=\u00a76Spawn location set for group\u00a7c {0}\u00a76.
|
spawnSet=\u00a76Spawn location set for group\u00a7c {0}\u00a76.
|
||||||
spawned=spawned
|
spawned=spawned
|
||||||
|
@@ -10,6 +10,7 @@ public class Commandgod extends EssentialsSettingsCommand
|
|||||||
protected void setValue(final IUser player, final boolean value)
|
protected void setValue(final IUser player, final boolean value)
|
||||||
{
|
{
|
||||||
player.setGodModeEnabled(value);
|
player.setGodModeEnabled(value);
|
||||||
|
player.queueSave();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean getValue(final IUser player)
|
protected boolean getValue(final IUser player)
|
||||||
|
@@ -6,66 +6,44 @@ import net.ess3.permissions.Permissions;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
|
|
||||||
public class Commandsocialspy extends EssentialsCommand
|
public class Commandsocialspy extends EssentialsSettingsCommand
|
||||||
{
|
{
|
||||||
@Override
|
|
||||||
public void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
|
||||||
{
|
|
||||||
if (args.length < 1)
|
|
||||||
{
|
|
||||||
throw new NotEnoughArgumentsException();
|
|
||||||
}
|
|
||||||
|
|
||||||
socialspyOtherPlayers(sender, args);
|
protected void setValue(final IUser player, final boolean value)
|
||||||
|
{
|
||||||
|
player.getData().setSocialspy(value);
|
||||||
|
player.queueSave();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
protected boolean getValue(final IUser player)
|
||||||
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))
|
return player.getData().isSocialspy();
|
||||||
{
|
|
||||||
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)
|
protected void informSender(final CommandSender sender, final boolean value, final IUser player)
|
||||||
{
|
{
|
||||||
for (IUser player : ess.getUserMap().matchUsers(args[0], true))
|
if (value) {
|
||||||
{
|
sender.sendMessage( _("socialSpyMode", _(getValue(player) ? "enabled" : "disabled"), player.getPlayer().getDisplayName()));
|
||||||
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")));
|
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
//TODO: TL this
|
||||||
|
sender.sendMessage("Can't change socialspy for player " + player.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void informPlayer(final IUser player)
|
||||||
|
{
|
||||||
|
final String message = _("socialSpyMode", _(getValue(player) ? "enabled" : "disabled"), player.getPlayer().getDisplayName());
|
||||||
|
player.sendMessage(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean canToggleOthers(final IUser user)
|
||||||
|
{
|
||||||
|
return Permissions.SOCIALSPY_OTHERS.isAuthorized(user);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean isExempt(final CommandSender sender, final IUser player)
|
||||||
|
{
|
||||||
|
return (player.isOnline() ? Permissions.SOCIALSPY_EXEMPT.isAuthorized(player) : !Permissions.SOCIALSPY_OFFLINE.isAuthorized(sender));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -12,6 +12,7 @@ public class Commandtptoggle extends EssentialsSettingsCommand
|
|||||||
protected void setValue(final IUser player, final boolean value)
|
protected void setValue(final IUser player, final boolean value)
|
||||||
{
|
{
|
||||||
player.getData().setTeleportEnabled(value);
|
player.getData().setTeleportEnabled(value);
|
||||||
|
player.queueSave();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean getValue(final IUser player)
|
protected boolean getValue(final IUser player)
|
||||||
|
@@ -100,7 +100,6 @@ public abstract class EssentialsSettingsCommand extends EssentialsCommand
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
setValue(matchPlayer, true);
|
setValue(matchPlayer, true);
|
||||||
;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
Reference in New Issue
Block a user