1
0
mirror of https://github.com/essentials/Essentials.git synced 2025-08-28 00:40:05 +02:00

Fix queue save in god/tptoggle

Use settings abstract for socialspy
This commit is contained in:
KHobbits
2012-12-01 23:42:21 +00:00
parent bb8b15785d
commit f79fe70a86
5 changed files with 33 additions and 53 deletions

View File

@@ -341,6 +341,7 @@ signFormatTemplate=[{0}]
signProtectInvalidLocation=\u00a74You are not allowed to create sign here.
similarWarpExist=\u00a74A warp with a similar name already exists.
slimeMalformedSize=\u00a74Malformed size.
socialSpyMode=\u00a76SocialSpy\u00a7c {0} \u00a76for {1}\u00a76.
soloMob=\u00a74That mob likes to be alone.
spawnSet=\u00a76Spawn location set for group\u00a7c {0}\u00a76.
spawned=spawned

View File

@@ -10,6 +10,7 @@ public class Commandgod extends EssentialsSettingsCommand
protected void setValue(final IUser player, final boolean value)
{
player.setGodModeEnabled(value);
player.queueSave();
}
protected boolean getValue(final IUser player)

View File

@@ -6,66 +6,44 @@ import net.ess3.permissions.Permissions;
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 void run(final IUser user, final String commandLabel, final String[] args) throws Exception
protected boolean getValue(final IUser player)
{
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")));
return player.getData().isSocialspy();
}
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 (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")));
if (value) {
sender.sendMessage( _("socialSpyMode", _(getValue(player) ? "enabled" : "disabled"), player.getPlayer().getDisplayName()));
}
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));
}
}

View File

@@ -12,6 +12,7 @@ public class Commandtptoggle extends EssentialsSettingsCommand
protected void setValue(final IUser player, final boolean value)
{
player.getData().setTeleportEnabled(value);
player.queueSave();
}
protected boolean getValue(final IUser player)

View File

@@ -100,7 +100,6 @@ public abstract class EssentialsSettingsCommand extends EssentialsCommand
else
{
setValue(matchPlayer, true);
;
}
}
else