Add command to turn notifications off and on again (per player).

This commit is contained in:
asofold 2013-06-12 00:53:40 +02:00
parent 4811fefb05
commit ae2d6142d9
5 changed files with 111 additions and 13 deletions

View File

@ -26,6 +26,7 @@ import fr.neatmonster.nocheatplus.command.admin.RemovePlayerCommand;
import fr.neatmonster.nocheatplus.command.admin.exemption.ExemptCommand;
import fr.neatmonster.nocheatplus.command.admin.exemption.ExemptionsCommand;
import fr.neatmonster.nocheatplus.command.admin.exemption.UnexemptCommand;
import fr.neatmonster.nocheatplus.command.admin.notify.NotifyCommand;
import fr.neatmonster.nocheatplus.components.INotifyReload;
import fr.neatmonster.nocheatplus.config.ConfPaths;
import fr.neatmonster.nocheatplus.config.ConfigManager;
@ -48,7 +49,7 @@ import fr.neatmonster.nocheatplus.config.ConfigManager;
* MMMMMMMMMMMM
*/
/**
* This the class handling all the commands.
* The /nocheatplus or /ncp command handler, delegates to sub commands.
*/
public class NoCheatPlusCommand extends BaseCommand{
@ -100,6 +101,7 @@ public class NoCheatPlusCommand extends BaseCommand{
new KickListCommand(plugin),
new LagCommand(plugin),
new NCPVersionCommand(plugin),
new NotifyCommand(plugin),
new ReloadCommand(plugin, notifyReload),
new RemovePlayerCommand(plugin),
new TellCommand(plugin),

View File

@ -0,0 +1,23 @@
package fr.neatmonster.nocheatplus.command.admin.notify;
import org.bukkit.plugin.java.JavaPlugin;
import fr.neatmonster.nocheatplus.command.BaseCommand;
import fr.neatmonster.nocheatplus.permissions.Permissions;
/**
* Toggle notifications on and off.
* @author mc_dev
*
*/
public class NotifyCommand extends BaseCommand {
public NotifyCommand(JavaPlugin plugin) {
super(plugin, "notify", Permissions.ADMINISTRATION_NOTIFY, new String[]{"alert", "alerts"});
addSubCommands(
new NotifyOffCommand(plugin),
new NotifyOnCommand(plugin)
);
}
}

View File

@ -0,0 +1,36 @@
package fr.neatmonster.nocheatplus.command.admin.notify;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import fr.neatmonster.nocheatplus.command.BaseCommand;
import fr.neatmonster.nocheatplus.players.DataManager;
public class NotifyOffCommand extends BaseCommand {
public NotifyOffCommand(JavaPlugin plugin) {
super(plugin, "off", null, new String[]{"0", "-"});
}
/* (non-Javadoc)
* @see fr.neatmonster.nocheatplus.command.AbstractCommand#onCommand(org.bukkit.command.CommandSender, org.bukkit.command.Command, java.lang.String, java.lang.String[])
*/
@Override
public boolean onCommand(CommandSender sender, Command command, String alias, String[] args) {
if (args.length != 2){
return false;
}
if (!(sender instanceof Player)){
// TODO: Might implement if upvoted a lot.
sender.sendMessage("[NoCheatPlus] Toggling notifications is only available for online players.");
return true;
}
DataManager.getPlayerData(sender.getName(), true).setNotifyOff(true);
sender.sendMessage(ChatColor.RED + "NCP: " + ChatColor.WHITE + "Notifications are now turned " + ChatColor.RED + "off" + ChatColor.WHITE + ".");
return true;
}
}

View File

@ -0,0 +1,36 @@
package fr.neatmonster.nocheatplus.command.admin.notify;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import fr.neatmonster.nocheatplus.command.BaseCommand;
import fr.neatmonster.nocheatplus.players.DataManager;
public class NotifyOnCommand extends BaseCommand {
public NotifyOnCommand(JavaPlugin plugin) {
super(plugin, "on", null, new String[]{"1", "+"});
}
/* (non-Javadoc)
* @see fr.neatmonster.nocheatplus.command.AbstractCommand#onCommand(org.bukkit.command.CommandSender, org.bukkit.command.Command, java.lang.String, java.lang.String[])
*/
@Override
public boolean onCommand(CommandSender sender, Command command, String alias, String[] args) {
if (args.length != 2){
return false;
}
if (!(sender instanceof Player)){
// TODO: Might implement if upvoted a lot.
sender.sendMessage("[NoCheatPlus] Toggling notifications is only available for online players.");
return true;
}
DataManager.getPlayerData(sender.getName(), true).setNotifyOff(false);
sender.sendMessage(ChatColor.RED + "NCP: " + ChatColor.WHITE + "Notifications are now turned " + ChatColor.YELLOW + "on" + ChatColor.WHITE + ".");
return true;
}
}

View File

@ -16,25 +16,26 @@ commands:
# permissions: nocheatplus.admin.(...)
usage: |
Administrative commands overview:
/<command> version: Show version information.
/<command> reload: reload the configuration
/<command> lag: Lag related info [expect changes]
/<command> info (player): Display the violations of a player
/<command> removeplayer (player) [(check type)]: Remove data
/<command> exemptions (player) [(check type)]: Show exemptions
/<command> exempt (player) [(check type)]: Exempt the player
/<command> unexempt (player) [(check type)]: Unexempt the player
/<command> commands: List all commands, more than shown here
/<command> info (player): Violation summary for a player.
/<command> notify on|off: In-game notifications per player.
/<command> removeplayer (player) [(check type)]: Remove data.
/<command> reload: Reload the configuration.
/<command> lag: Lag-related info.
/<command> version: Version information.
/<command> exemptions (player) [(check type)]: Show exemptions.
/<command> exempt (player) [(check type)]: Exempt a player.
/<command> unexempt (player) [(check type)]: Unexempt a player.
/<command> commands: List all commands, more than shown here.
permissions:
nocheatplus:
description: Allow the player to bypass all checks and give him all administation permissions.
description: Allow the player to bypass all checks and give him all administration permissions.
children:
nocheatplus.admin:
description: Give the player all administation rights.
description: Give the player all administration rights.
children:
nocheatplus.admin.notify:
description: Allow the player to see the alerts in the ingame chat.
description: Allow the player to see the alerts in the in-game chat.
nocheatplus.admin.plugins:
description: Allow the player to see the list of all plugins (/plugins).
nocheatplus.admin.reload: