From 5c76ef312fe09bd70d529f034c4d7cd288dcb6b8 Mon Sep 17 00:00:00 2001 From: GJ Date: Tue, 19 Feb 2013 13:18:27 -0500 Subject: [PATCH] Added '/mcnotify' command to toggle ability notifications on/off --- Changelog.txt | 2 ++ .../commands/CommandRegistrationHelper.java | 10 ++++++ .../commands/player/McnotifyCommand.java | 34 +++++++++++++++++++ .../nossr50/datatypes/PlayerProfile.java | 13 +++++++ src/main/java/com/gmail/nossr50/mcMMO.java | 1 + .../resources/locale/locale_en_US.properties | 3 ++ src/main/resources/plugin.yml | 6 ++++ 7 files changed, 69 insertions(+) create mode 100644 src/main/java/com/gmail/nossr50/commands/player/McnotifyCommand.java diff --git a/Changelog.txt b/Changelog.txt index ffc656ee0..9def7a325 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -34,6 +34,8 @@ Version 1.4.00-dev + Added '/hardcore' and '/vampirism' commands for toggling these modes on or off. + Added Block Cracker to Unarmed's Berserk, turn smooth brick into cracked smooth brick + Added config option to disable automatic zip backups. + + Added particle effects for many abilities. + + Added '/mcnotify' command to toggle ability notifications on/off = Fixed Green Thumb on wheat not working properly at rank 4 = Fixed Green Thumb and Green Terra consuming twice the amount of seed needed = Fixed Green Terra not also checking Green Thumb permissions diff --git a/src/main/java/com/gmail/nossr50/commands/CommandRegistrationHelper.java b/src/main/java/com/gmail/nossr50/commands/CommandRegistrationHelper.java index 6cb31f072..19dd617ac 100644 --- a/src/main/java/com/gmail/nossr50/commands/CommandRegistrationHelper.java +++ b/src/main/java/com/gmail/nossr50/commands/CommandRegistrationHelper.java @@ -20,6 +20,7 @@ import com.gmail.nossr50.commands.admin.XprateCommand; import com.gmail.nossr50.commands.player.InspectCommand; import com.gmail.nossr50.commands.player.McabilityCommand; import com.gmail.nossr50.commands.player.McmmoCommand; +import com.gmail.nossr50.commands.player.McnotifyCommand; import com.gmail.nossr50.commands.player.McrankCommand; import com.gmail.nossr50.commands.player.McstatsCommand; import com.gmail.nossr50.commands.player.MctopCommand; @@ -358,4 +359,13 @@ public final class CommandRegistrationHelper { command.setUsage(command.getUsage() + "\n" + LocaleLoader.getString("Commands.Usage.1", "vampirism", "<" + LocaleLoader.getString("Commands.Usage.Rate") + ">")); command.setExecutor(new VampirismCommand()); } + + public static void registerMcnotifyCommand() { + PluginCommand command = mcMMO.p.getCommand("mcnotify"); + command.setDescription(LocaleLoader.getString("Commands.Description.mcnotify")); + command.setPermission("mcmmo.commands.mcnotify"); + command.setPermissionMessage(permissionsMessage); + command.setUsage(LocaleLoader.getString("Commands.Usage.0", "mcnotify")); + command.setExecutor(new McnotifyCommand()); + } } diff --git a/src/main/java/com/gmail/nossr50/commands/player/McnotifyCommand.java b/src/main/java/com/gmail/nossr50/commands/player/McnotifyCommand.java new file mode 100644 index 000000000..345324300 --- /dev/null +++ b/src/main/java/com/gmail/nossr50/commands/player/McnotifyCommand.java @@ -0,0 +1,34 @@ +package com.gmail.nossr50.commands.player; + +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import com.gmail.nossr50.datatypes.PlayerProfile; +import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.util.Users; + +public class McnotifyCommand implements CommandExecutor { + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + switch (args.length) { + case 0: + PlayerProfile profile = Users.getPlayer((Player) sender).getProfile(); + + if (profile.useChatNotifications()) { + sender.sendMessage(LocaleLoader.getString("Commands.Notifications.Off")); + } + else { + sender.sendMessage(LocaleLoader.getString("Commands.Notifications.On")); + } + + profile.toggleChatNotifications(); + return true; + + default: + return false; + } + } +} diff --git a/src/main/java/com/gmail/nossr50/datatypes/PlayerProfile.java b/src/main/java/com/gmail/nossr50/datatypes/PlayerProfile.java index 13d187dd2..fa5f6d41e 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/PlayerProfile.java +++ b/src/main/java/com/gmail/nossr50/datatypes/PlayerProfile.java @@ -37,6 +37,7 @@ public class PlayerProfile { private boolean hoePreparationMode, shovelPreparationMode, swordsPreparationMode, fistsPreparationMode, pickaxePreparationMode, axePreparationMode; private boolean abilityUse = true; + private boolean displaySkillNotifications = true; // Timestamps private long recentlyHurt; @@ -830,6 +831,18 @@ public class PlayerProfile { respawnATS = (int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR); } + /* + * Ability Notifications + */ + + public boolean useChatNotifications() { + return displaySkillNotifications; + } + + public void toggleChatNotifications() { + displaySkillNotifications = !displaySkillNotifications; + } + /* * Cooldowns */ diff --git a/src/main/java/com/gmail/nossr50/mcMMO.java b/src/main/java/com/gmail/nossr50/mcMMO.java index 24b5e1e9d..0b4c23d22 100644 --- a/src/main/java/com/gmail/nossr50/mcMMO.java +++ b/src/main/java/com/gmail/nossr50/mcMMO.java @@ -309,6 +309,7 @@ public class mcMMO extends JavaPlugin { CommandRegistrationHelper.registerSkillresetCommand(); CommandRegistrationHelper.registerHardcoreCommand(); CommandRegistrationHelper.registerVampirismCommand(); + CommandRegistrationHelper.registerMcnotifyCommand(); // Spout commands CommandRegistrationHelper.registerXplockCommand(); diff --git a/src/main/resources/locale/locale_en_US.properties b/src/main/resources/locale/locale_en_US.properties index e8430c3e6..64c0ee150 100644 --- a/src/main/resources/locale/locale_en_US.properties +++ b/src/main/resources/locale/locale_en_US.properties @@ -435,6 +435,8 @@ Commands.mmoupdate.Start=[[GRAY]]Starting conversion... Commands.mmoupdate.Finish=[[GREEN]]Conversion finished! Commands.ModDescription=[[RED]]- Read brief mod description Commands.NoConsole=This command does not support console usage. +Commands.Notifications.Off=Ability notifications toggled [[RED]]off +Commands.Notifications.On=Ability notifications toggled [[GREEN]]on Commands.Offline=[[RED]]This command does not work for offline players. Commands.Other=[[GREEN]]--OTHER COMMANDS-- Commands.Party.Header=[[RED]]-----[][[GREEN]]PARTY[[RED]][]----- @@ -707,6 +709,7 @@ Commands.Description.mcability=Toggle mcMMO abilities being readied on right-cli Commands.Description.mcgod=Toggle mcMMO god-mode on/off Commands.Description.mchud=Change your mcMMO HUD style Commands.Description.mcmmo=Show a brief description of mcMMO +Commands.Description.mcnotify=Toggle mcMMO abilities chat display notifications on/off Commands.Description.mcpurge=Purge users with no mcMMO levels and users who have not connected in over {0} months from the mcMMO database. Commands.Description.mcrank=Show mcMMO ranking for a player Commands.Description.mcrefresh=Refresh all cooldowns for mcMMO diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 903e5f9c0..a29a36125 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -101,6 +101,9 @@ commands: vampirism: aliases: [mcvampirism] description: Modify the mcMMO vampirism percentage or toggle vampirism mode on/off + mcnotify: + aliases: [notify] + description: Toggle mcMMO abilities chat display notifications on/off permissions: mcmmo.*: default: false @@ -601,6 +604,7 @@ permissions: mcmmo.commands.mcability: true mcmmo.commands.mchud: true mcmmo.commands.mcmmo.all: true + mcmmo.commands.mcnotify: true mcmmo.commands.mcrank: true mcmmo.commands.mcstats: true mcmmo.commands.mctop.all: true @@ -724,6 +728,8 @@ permissions: description: Allows access to the mcmmo command mcmmo.commands.mcmmo.help: description: Allows access to the mcmmo help command + mcmmo.commands.mcnotify: + description: Allows access to the mcnotify command mcmmo.commands.mcpurge: default: false description: Allows access to the mcpurge command