Add mcMMO reload command "/mcmmoreload"

This commit is contained in:
nossr50
2019-04-29 22:55:39 -07:00
parent 7b3f69aee6
commit faed690602
7 changed files with 129 additions and 72 deletions

View File

@ -0,0 +1,26 @@
package com.gmail.nossr50.commands.server;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Permissions;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
public class ReloadCommand implements CommandExecutor {
@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
if (sender instanceof Player) {
if (!Permissions.reload(sender))
return false;
}
Bukkit.broadcastMessage(LocaleLoader.getString("Commands.Reload.Start"));
mcMMO.getConfigManager().reloadConfigs();
Bukkit.broadcastMessage(LocaleLoader.getString("Commands.Reload.Finished"));
return true;
}
}

View File

@ -425,7 +425,6 @@ public class mcMMO extends JavaPlugin {
//Unload configs last
configManager.unloadAllConfigsAndRegisters();
debug("Was disabled."); // How informative!
}

View File

@ -177,6 +177,10 @@ public final class Permissions {
return permissible.hasPermission("mcmmo.commands.mmoedit");
}
public static boolean reload(Permissible permissible) {
return permissible.hasPermission("mcmmo.commands.reload");
}
public static boolean mmoeditOthers(Permissible permissible) {
return permissible.hasPermission("mcmmo.commands.mmoedit.others");
}

View File

@ -14,6 +14,7 @@ import com.gmail.nossr50.commands.experience.SkillresetCommand;
import com.gmail.nossr50.commands.party.PartyCommand;
import com.gmail.nossr50.commands.party.teleport.PtpCommand;
import com.gmail.nossr50.commands.player.*;
import com.gmail.nossr50.commands.server.ReloadCommand;
import com.gmail.nossr50.commands.skills.*;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.locale.LocaleLoader;
@ -174,6 +175,15 @@ public final class CommandRegistrationManager {
command.setExecutor(new MmoeditCommand());
}
private static void registerMcmmoReloadCommand() {
PluginCommand command = mcMMO.p.getCommand("mcmmoreload");
command.setDescription(LocaleLoader.getString("Commands.Description.mcmmoreload"));
command.setPermission("mcmmo.commands.reload");
command.setPermissionMessage(permissionsMessage);
command.setUsage(LocaleLoader.getString("Commands.Usage.0", "mcmmoreload"));
command.setExecutor(new ReloadCommand());
}
private static void registerSkillresetCommand() {
PluginCommand command = mcMMO.p.getCommand("skillreset");
command.setDescription(LocaleLoader.getString("Commands.Description.skillreset"));
@ -445,5 +455,8 @@ public final class CommandRegistrationManager {
// Skill Commands
registerSkillCommands();
//Config Commands
registerMcmmoReloadCommand();
}
}

View File

@ -1043,6 +1043,7 @@ Commands.Description.mcrefresh=Refresh all cooldowns for mcMMO
Commands.Description.mcremove=Remove a user from the mcMMO database
Commands.Description.mcscoreboard=Manage your mcMMO Scoreboard
Commands.Description.mcstats=Show your mcMMO levels and XP
Commands.Description.mcmmoreload=Reload all mcMMO config files
Commands.Description.mctop=Show mcMMO leader boards
Commands.Description.mmoedit=Edit mcMMO levels for a user
Commands.Description.mmoupdate=Migrate mcMMO database from an old database into the current one
@ -1081,4 +1082,7 @@ Profile.Loading.FailureNotice=[[DARK_RED]][A][[RED]] mcMMO was unable to load th
Holiday.AprilFools.Levelup=[[GOLD]]{0} is now level [[GREEN]]{1}[[GOLD]]!
Holiday.Anniversary=[[BLUE]]Happy {0} Year Anniversary!\n[[BLUE]]In honor of all of nossr50's work and all the devs, here's a firework show!
#Reminder Messages
Reminder.Squelched=[[GRAY]]Reminder: You are currently not receiving notifications from mcMMO, to enable notifications please run the /mcnotify command again. This is an automated hourly reminder.
Reminder.Squelched=[[GRAY]]Reminder: You are currently not receiving notifications from mcMMO, to enable notifications please run the /mcnotify command again. This is an automated hourly reminder.
#Misc
Commands.Reload.Start=mcMMO is reloading... this may take a moment
Commands.Reload.Finished=mcMMO has finished reloading!

View File

@ -71,6 +71,9 @@ commands:
mmoedit:
description: Edit the mcMMO skill values for a user
permission: mcmmo.commands.mmoedit
mcmmoreload:
description: Reloads mcMMO's config files
permission: mcmmo.commands.reload
ptp:
description: Teleport to a party member
permission: mcmmo.commands.ptp
@ -792,6 +795,7 @@ permissions:
mcmmo.commands.mcrefresh: true
mcmmo.commands.mcrefresh.others: true
mcmmo.commands.mcremove: true
mcmmo.commands.mcmmoreload: true
mcmmo.commands.mmoedit: true
mcmmo.commands.mmoedit.others: true
mcmmo.commands.mmoshowdb: true
@ -978,6 +982,8 @@ permissions:
description: Allows access to the mining command
mcmmo.commands.mmoedit:
description: Allows access to the mmoedit command
mcmmo.commands.reload:
description: Allows acces to the mcmmoreload command
mcmmo.commands.mmoedit.others:
description: Allows access to the mmoedit command for other players
mcmmo.commands.mmoshowdb: