mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-06-25 02:04:44 +02:00
Added '/mcnotify' command to toggle ability notifications on/off
This commit is contained in:
@ -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());
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
@ -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
|
||||
*/
|
||||
|
@ -309,6 +309,7 @@ public class mcMMO extends JavaPlugin {
|
||||
CommandRegistrationHelper.registerSkillresetCommand();
|
||||
CommandRegistrationHelper.registerHardcoreCommand();
|
||||
CommandRegistrationHelper.registerVampirismCommand();
|
||||
CommandRegistrationHelper.registerMcnotifyCommand();
|
||||
|
||||
// Spout commands
|
||||
CommandRegistrationHelper.registerXplockCommand();
|
||||
|
Reference in New Issue
Block a user