Fixing some issues with reloading

This commit is contained in:
nossr50 2019-06-16 05:57:52 -07:00
parent 2d1472b913
commit 726369077e
5 changed files with 94 additions and 41 deletions

View File

@ -11,6 +11,13 @@ import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
public class ReloadCommand implements CommandExecutor { public class ReloadCommand implements CommandExecutor {
private mcMMO plugin;
public ReloadCommand(mcMMO plugin) {
this.plugin = plugin;
}
@Override @Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) { public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
if (sender instanceof Player) { if (sender instanceof Player) {
@ -19,8 +26,9 @@ public class ReloadCommand implements CommandExecutor {
} }
Bukkit.broadcastMessage(LocaleLoader.getString("Commands.Reload.Start")); Bukkit.broadcastMessage(LocaleLoader.getString("Commands.Reload.Start"));
mcMMO.getConfigManager().reloadConfigs(); plugin.reload();
Bukkit.broadcastMessage(LocaleLoader.getString("Commands.Reload.Finished")); Bukkit.broadcastMessage(LocaleLoader.getString("Commands.Reload.Finished"));
return true; return true;
} }
} }

View File

@ -36,12 +36,14 @@ import com.gmail.nossr50.util.player.PlayerLevelUtils;
import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.scoreboards.ScoreboardManager; import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
import com.gmail.nossr50.util.skills.RankUtils; import com.gmail.nossr50.util.skills.RankUtils;
import com.gmail.nossr50.util.skills.SkillUtils;
import com.gmail.nossr50.worldguard.WorldGuardManager; import com.gmail.nossr50.worldguard.WorldGuardManager;
import net.shatteredlands.shatt.backup.ZipLibrary; import net.shatteredlands.shatt.backup.ZipLibrary;
import org.bstats.bukkit.Metrics; import org.bstats.bukkit.Metrics;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
import org.bukkit.inventory.Recipe;
import org.bukkit.metadata.FixedMetadataValue; import org.bukkit.metadata.FixedMetadataValue;
import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
@ -62,6 +64,7 @@ public class mcMMO extends JavaPlugin {
private static MaterialMapStore materialMapStore; private static MaterialMapStore materialMapStore;
private static PlayerLevelUtils playerLevelUtils; private static PlayerLevelUtils playerLevelUtils;
private static NotificationManager notificationManager; private static NotificationManager notificationManager;
private static CommandRegistrationManager commandRegistrationManager;
/* File Paths */ /* File Paths */
private static String mainDirectory; private static String mainDirectory;
@ -148,7 +151,8 @@ public class mcMMO extends JavaPlugin {
debug("Version " + getDescription().getVersion() + " is enabled!"); debug("Version " + getDescription().getVersion() + " is enabled!");
scheduleTasks(); scheduleTasks();
CommandRegistrationManager.registerCommands(); commandRegistrationManager = new CommandRegistrationManager(this);
commandRegistrationManager.registerCommands();
placeStore = ChunkManagerFactory.getChunkManager(); // Get our ChunkletManager placeStore = ChunkManagerFactory.getChunkManager(); // Get our ChunkletManager
@ -477,6 +481,17 @@ public class mcMMO extends JavaPlugin {
localesDirectoryPath.mkdirs(); localesDirectoryPath.mkdirs();
} }
public void reload() {
// loadConfigFiles();
// registerDynamicSettings(); //Do this after config
//
// databaseManager = DatabaseManagerFactory.getDatabaseManager();
onDisable();
onLoad();
onEnable();
}
private void registerDynamicSettings() { private void registerDynamicSettings() {
dynamicSettingsManager = new DynamicSettingsManager(); dynamicSettingsManager = new DynamicSettingsManager();
} }
@ -522,6 +537,9 @@ public class mcMMO extends JavaPlugin {
private void registerCustomRecipes() { private void registerCustomRecipes() {
getServer().getScheduler().scheduleSyncDelayedTask(this, () -> { getServer().getScheduler().scheduleSyncDelayedTask(this, () -> {
if (mcMMO.getConfigManager().getConfigItems().isChimaeraWingEnabled()) { if (mcMMO.getConfigManager().getConfigItems().isChimaeraWingEnabled()) {
Recipe recipe = ChimaeraWing.getChimaeraWingRecipe();
if(!SkillUtils.hasRecipeBeenRegistered(recipe))
getServer().addRecipe(ChimaeraWing.getChimaeraWingRecipe()); getServer().addRecipe(ChimaeraWing.getChimaeraWingRecipe());
} }
}, 40); }, 40);

View File

@ -16,6 +16,7 @@ import org.bukkit.permissions.Permissible;
import org.bukkit.permissions.Permission; import org.bukkit.permissions.Permission;
import org.bukkit.permissions.PermissionDefault; import org.bukkit.permissions.PermissionDefault;
import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.SimplePluginManager;
public final class Permissions { public final class Permissions {
private Permissions() { private Permissions() {
@ -529,9 +530,14 @@ public final class Permissions {
for (CustomXPPerk customXPPerk : mcMMO.getConfigManager().getConfigExperience().getCustomXPBoosts()) { for (CustomXPPerk customXPPerk : mcMMO.getConfigManager().getConfigExperience().getCustomXPBoosts()) {
Permission permission = new Permission(customXPPerk.getPerkPermissionAddress()); Permission permission = new Permission(customXPPerk.getPerkPermissionAddress());
permission.setDefault(PermissionDefault.FALSE); permission.setDefault(PermissionDefault.FALSE);
try {
((SimplePluginManager) pluginManager).addPermission(permission);
} catch (IllegalArgumentException e) {
pluginManager.removePermission(customXPPerk.getPerkPermissionAddress());
pluginManager.addPermission(permission); pluginManager.addPermission(permission);
} }
}
} }
private static void addDynamicPermission(String permissionName, PluginManager pluginManager) { private static void addDynamicPermission(String permissionName, PluginManager pluginManager) {

View File

@ -27,12 +27,14 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
public final class CommandRegistrationManager { public final class CommandRegistrationManager {
private mcMMO pluginRef;
private static String permissionsMessage = LocaleLoader.getString("mcMMO.NoPermission"); private static String permissionsMessage = LocaleLoader.getString("mcMMO.NoPermission");
private CommandRegistrationManager() { public CommandRegistrationManager(mcMMO pluginRef) {
this.pluginRef = pluginRef;
} }
private static void registerSkillCommands() { private void registerSkillCommands() {
for (PrimarySkillType skill : PrimarySkillType.values()) { for (PrimarySkillType skill : PrimarySkillType.values()) {
String commandName = skill.toString().toLowerCase(); String commandName = skill.toString().toLowerCase();
String localizedName = skill.getName().toLowerCase(); String localizedName = skill.getName().toLowerCase();
@ -113,7 +115,7 @@ public final class CommandRegistrationManager {
} }
} }
private static void registerAddlevelsCommand() { private void registerAddlevelsCommand() {
PluginCommand command = mcMMO.p.getCommand("addlevels"); PluginCommand command = mcMMO.p.getCommand("addlevels");
command.setDescription(LocaleLoader.getString("Commands.Description.addlevels")); command.setDescription(LocaleLoader.getString("Commands.Description.addlevels"));
command.setPermission("mcmmo.commands.addlevels;mcmmo.commands.addlevels.others"); command.setPermission("mcmmo.commands.addlevels;mcmmo.commands.addlevels.others");
@ -122,7 +124,7 @@ public final class CommandRegistrationManager {
command.setExecutor(new AddlevelsCommand()); command.setExecutor(new AddlevelsCommand());
} }
private static void registerAddxpCommand() { private void registerAddxpCommand() {
PluginCommand command = mcMMO.p.getCommand("addxp"); PluginCommand command = mcMMO.p.getCommand("addxp");
command.setDescription(LocaleLoader.getString("Commands.Description.addxp")); command.setDescription(LocaleLoader.getString("Commands.Description.addxp"));
command.setPermission("mcmmo.commands.addxp;mcmmo.commands.addxp.others"); command.setPermission("mcmmo.commands.addxp;mcmmo.commands.addxp.others");
@ -131,7 +133,7 @@ public final class CommandRegistrationManager {
command.setExecutor(new AddxpCommand()); command.setExecutor(new AddxpCommand());
} }
private static void registerMcgodCommand() { private void registerMcgodCommand() {
PluginCommand command = mcMMO.p.getCommand("mcgod"); PluginCommand command = mcMMO.p.getCommand("mcgod");
command.setDescription(LocaleLoader.getString("Commands.Description.mcgod")); command.setDescription(LocaleLoader.getString("Commands.Description.mcgod"));
command.setPermission("mcmmo.commands.mcgod;mcmmo.commands.mcgod.others"); command.setPermission("mcmmo.commands.mcgod;mcmmo.commands.mcgod.others");
@ -140,7 +142,7 @@ public final class CommandRegistrationManager {
command.setExecutor(new McgodCommand()); command.setExecutor(new McgodCommand());
} }
private static void registerMmoInfoCommand() { private void registerMmoInfoCommand() {
PluginCommand command = mcMMO.p.getCommand("mmoinfo"); PluginCommand command = mcMMO.p.getCommand("mmoinfo");
command.setDescription(LocaleLoader.getString("Commands.Description.mmoinfo")); command.setDescription(LocaleLoader.getString("Commands.Description.mmoinfo"));
command.setPermission("mcmmo.commands.mmoinfo"); command.setPermission("mcmmo.commands.mmoinfo");
@ -149,7 +151,7 @@ public final class CommandRegistrationManager {
command.setExecutor(new MmoInfoCommand()); command.setExecutor(new MmoInfoCommand());
} }
private static void registerMcChatSpyCommand() { private void registerMcChatSpyCommand() {
PluginCommand command = mcMMO.p.getCommand("mcchatspy"); PluginCommand command = mcMMO.p.getCommand("mcchatspy");
command.setDescription(LocaleLoader.getString("Commands.Description.mcchatspy")); command.setDescription(LocaleLoader.getString("Commands.Description.mcchatspy"));
command.setPermission("mcmmo.commands.mcchatspy;mcmmo.commands.mcchatspy.others"); command.setPermission("mcmmo.commands.mcchatspy;mcmmo.commands.mcchatspy.others");
@ -158,7 +160,7 @@ public final class CommandRegistrationManager {
command.setExecutor(new McChatSpy()); command.setExecutor(new McChatSpy());
} }
private static void registerMcrefreshCommand() { private void registerMcrefreshCommand() {
PluginCommand command = mcMMO.p.getCommand("mcrefresh"); PluginCommand command = mcMMO.p.getCommand("mcrefresh");
command.setDescription(LocaleLoader.getString("Commands.Description.mcrefresh")); command.setDescription(LocaleLoader.getString("Commands.Description.mcrefresh"));
command.setPermission("mcmmo.commands.mcrefresh;mcmmo.commands.mcrefresh.others"); command.setPermission("mcmmo.commands.mcrefresh;mcmmo.commands.mcrefresh.others");
@ -167,7 +169,7 @@ public final class CommandRegistrationManager {
command.setExecutor(new McrefreshCommand()); command.setExecutor(new McrefreshCommand());
} }
private static void registerMmoeditCommand() { private void registerMmoeditCommand() {
PluginCommand command = mcMMO.p.getCommand("mmoedit"); PluginCommand command = mcMMO.p.getCommand("mmoedit");
command.setDescription(LocaleLoader.getString("Commands.Description.mmoedit")); command.setDescription(LocaleLoader.getString("Commands.Description.mmoedit"));
command.setPermission("mcmmo.commands.mmoedit;mcmmo.commands.mmoedit.others"); command.setPermission("mcmmo.commands.mmoedit;mcmmo.commands.mmoedit.others");
@ -176,16 +178,16 @@ public final class CommandRegistrationManager {
command.setExecutor(new MmoeditCommand()); command.setExecutor(new MmoeditCommand());
} }
private static void registerMcmmoReloadCommand() { private void registerMcmmoReloadCommand() {
PluginCommand command = mcMMO.p.getCommand("mcmmoreload"); PluginCommand command = mcMMO.p.getCommand("mcmmoreload");
command.setDescription(LocaleLoader.getString("Commands.Description.mcmmoreload")); command.setDescription(LocaleLoader.getString("Commands.Description.mcmmoreload"));
command.setPermission("mcmmo.commands.reload"); command.setPermission("mcmmo.commands.reload");
command.setPermissionMessage(permissionsMessage); command.setPermissionMessage(permissionsMessage);
command.setUsage(LocaleLoader.getString("Commands.Usage.0", "mcmmoreload")); command.setUsage(LocaleLoader.getString("Commands.Usage.0", "mcmmoreload"));
command.setExecutor(new ReloadCommand()); command.setExecutor(new ReloadCommand(pluginRef));
} }
private static void registerSkillresetCommand() { private void registerSkillresetCommand() {
PluginCommand command = mcMMO.p.getCommand("skillreset"); PluginCommand command = mcMMO.p.getCommand("skillreset");
command.setDescription(LocaleLoader.getString("Commands.Description.skillreset")); command.setDescription(LocaleLoader.getString("Commands.Description.skillreset"));
command.setPermission("mcmmo.commands.skillreset;mcmmo.commands.skillreset.others"); // Only need the main ones, not the individual skill ones command.setPermission("mcmmo.commands.skillreset;mcmmo.commands.skillreset.others"); // Only need the main ones, not the individual skill ones
@ -194,7 +196,7 @@ public final class CommandRegistrationManager {
command.setExecutor(new SkillresetCommand()); command.setExecutor(new SkillresetCommand());
} }
private static void registerXprateCommand() { private void registerXprateCommand() {
List<String> aliasList = new ArrayList<>(); List<String> aliasList = new ArrayList<>();
aliasList.add("mcxprate"); aliasList.add("mcxprate");
@ -208,7 +210,7 @@ public final class CommandRegistrationManager {
command.setExecutor(new XprateCommand()); command.setExecutor(new XprateCommand());
} }
private static void registerInspectCommand() { private void registerInspectCommand() {
PluginCommand command = mcMMO.p.getCommand("inspect"); PluginCommand command = mcMMO.p.getCommand("inspect");
command.setDescription(LocaleLoader.getString("Commands.Description.inspect")); command.setDescription(LocaleLoader.getString("Commands.Description.inspect"));
command.setPermission("mcmmo.commands.inspect;mcmmo.commands.inspect.far;mcmmo.commands.inspect.offline"); command.setPermission("mcmmo.commands.inspect;mcmmo.commands.inspect.far;mcmmo.commands.inspect.offline");
@ -217,7 +219,7 @@ public final class CommandRegistrationManager {
command.setExecutor(new InspectCommand()); command.setExecutor(new InspectCommand());
} }
private static void registerMccooldownCommand() { private void registerMccooldownCommand() {
PluginCommand command = mcMMO.p.getCommand("mccooldown"); PluginCommand command = mcMMO.p.getCommand("mccooldown");
command.setDescription(LocaleLoader.getString("Commands.Description.mccooldown")); command.setDescription(LocaleLoader.getString("Commands.Description.mccooldown"));
command.setPermission("mcmmo.commands.mccooldown"); command.setPermission("mcmmo.commands.mccooldown");
@ -226,7 +228,7 @@ public final class CommandRegistrationManager {
command.setExecutor(new MccooldownCommand()); command.setExecutor(new MccooldownCommand());
} }
private static void registerMcabilityCommand() { private void registerMcabilityCommand() {
PluginCommand command = mcMMO.p.getCommand("mcability"); PluginCommand command = mcMMO.p.getCommand("mcability");
command.setDescription(LocaleLoader.getString("Commands.Description.mcability")); command.setDescription(LocaleLoader.getString("Commands.Description.mcability"));
command.setPermission("mcmmo.commands.mcability;mcmmo.commands.mcability.others"); command.setPermission("mcmmo.commands.mcability;mcmmo.commands.mcability.others");
@ -235,7 +237,7 @@ public final class CommandRegistrationManager {
command.setExecutor(new McabilityCommand()); command.setExecutor(new McabilityCommand());
} }
private static void registerMcmmoCommand() { private void registerMcmmoCommand() {
PluginCommand command = mcMMO.p.getCommand("mcmmo"); PluginCommand command = mcMMO.p.getCommand("mcmmo");
command.setDescription(LocaleLoader.getString("Commands.Description.mcmmo")); command.setDescription(LocaleLoader.getString("Commands.Description.mcmmo"));
command.setPermission("mcmmo.commands.mcmmo.description;mcmmo.commands.mcmmo.help"); command.setPermission("mcmmo.commands.mcmmo.description;mcmmo.commands.mcmmo.help");
@ -245,7 +247,7 @@ public final class CommandRegistrationManager {
command.setExecutor(new McmmoCommand()); command.setExecutor(new McmmoCommand());
} }
private static void registerMcrankCommand() { private void registerMcrankCommand() {
PluginCommand command = mcMMO.p.getCommand("mcrank"); PluginCommand command = mcMMO.p.getCommand("mcrank");
command.setDescription(LocaleLoader.getString("Commands.Description.mcrank")); command.setDescription(LocaleLoader.getString("Commands.Description.mcrank"));
command.setPermission("mcmmo.commands.mcrank;mcmmo.commands.mcrank.others;mcmmo.commands.mcrank.others.far;mcmmo.commands.mcrank.others.offline"); command.setPermission("mcmmo.commands.mcrank;mcmmo.commands.mcrank.others;mcmmo.commands.mcrank.others.far;mcmmo.commands.mcrank.others.offline");
@ -254,7 +256,7 @@ public final class CommandRegistrationManager {
command.setExecutor(new McrankCommand()); command.setExecutor(new McrankCommand());
} }
private static void registerMcstatsCommand() { private void registerMcstatsCommand() {
PluginCommand command = mcMMO.p.getCommand("mcstats"); PluginCommand command = mcMMO.p.getCommand("mcstats");
command.setDescription(LocaleLoader.getString("Commands.Description.mcstats")); command.setDescription(LocaleLoader.getString("Commands.Description.mcstats"));
command.setPermission("mcmmo.commands.mcstats"); command.setPermission("mcmmo.commands.mcstats");
@ -263,7 +265,7 @@ public final class CommandRegistrationManager {
command.setExecutor(new McstatsCommand()); command.setExecutor(new McstatsCommand());
} }
private static void registerMctopCommand() { private void registerMctopCommand() {
PluginCommand command = mcMMO.p.getCommand("mctop"); PluginCommand command = mcMMO.p.getCommand("mctop");
command.setDescription(LocaleLoader.getString("Commands.Description.mctop")); command.setDescription(LocaleLoader.getString("Commands.Description.mctop"));
command.setPermission("mcmmo.commands.mctop"); // Only need the main one, not the individual skill ones command.setPermission("mcmmo.commands.mctop"); // Only need the main one, not the individual skill ones
@ -272,7 +274,7 @@ public final class CommandRegistrationManager {
command.setExecutor(new MctopCommand()); command.setExecutor(new MctopCommand());
} }
private static void registerMcpurgeCommand() { private void registerMcpurgeCommand() {
PluginCommand command = mcMMO.p.getCommand("mcpurge"); PluginCommand command = mcMMO.p.getCommand("mcpurge");
command.setDescription(LocaleLoader.getString("Commands.Description.mcpurge", mcMMO.getDatabaseCleaningSettings().getOldUserCutoffMonths())); command.setDescription(LocaleLoader.getString("Commands.Description.mcpurge", mcMMO.getDatabaseCleaningSettings().getOldUserCutoffMonths()));
command.setPermission("mcmmo.commands.mcpurge"); command.setPermission("mcmmo.commands.mcpurge");
@ -281,7 +283,7 @@ public final class CommandRegistrationManager {
command.setExecutor(new McpurgeCommand()); command.setExecutor(new McpurgeCommand());
} }
private static void registerMcremoveCommand() { private void registerMcremoveCommand() {
PluginCommand command = mcMMO.p.getCommand("mcremove"); PluginCommand command = mcMMO.p.getCommand("mcremove");
command.setDescription(LocaleLoader.getString("Commands.Description.mcremove")); command.setDescription(LocaleLoader.getString("Commands.Description.mcremove"));
command.setPermission("mcmmo.commands.mcremove"); command.setPermission("mcmmo.commands.mcremove");
@ -290,7 +292,7 @@ public final class CommandRegistrationManager {
command.setExecutor(new McremoveCommand()); command.setExecutor(new McremoveCommand());
} }
private static void registerMmoshowdbCommand() { private void registerMmoshowdbCommand() {
PluginCommand command = mcMMO.p.getCommand("mmoshowdb"); PluginCommand command = mcMMO.p.getCommand("mmoshowdb");
command.setDescription(LocaleLoader.getString("Commands.Description.mmoshowdb")); command.setDescription(LocaleLoader.getString("Commands.Description.mmoshowdb"));
command.setPermission("mcmmo.commands.mmoshowdb"); command.setPermission("mcmmo.commands.mmoshowdb");
@ -299,7 +301,7 @@ public final class CommandRegistrationManager {
command.setExecutor(new MmoshowdbCommand()); command.setExecutor(new MmoshowdbCommand());
} }
private static void registerMcconvertCommand() { private void registerMcconvertCommand() {
PluginCommand command = mcMMO.p.getCommand("mcconvert"); PluginCommand command = mcMMO.p.getCommand("mcconvert");
command.setDescription(LocaleLoader.getString("Commands.Description.mcconvert")); command.setDescription(LocaleLoader.getString("Commands.Description.mcconvert"));
command.setPermission("mcmmo.commands.mcconvert;mcmmo.commands.mcconvert.experience;mcmmo.commands.mcconvert.database"); command.setPermission("mcmmo.commands.mcconvert;mcmmo.commands.mcconvert.experience;mcmmo.commands.mcconvert.database");
@ -309,7 +311,7 @@ public final class CommandRegistrationManager {
command.setExecutor(new McconvertCommand()); command.setExecutor(new McconvertCommand());
} }
private static void registerAdminChatCommand() { private void registerAdminChatCommand() {
PluginCommand command = mcMMO.p.getCommand("adminchat"); PluginCommand command = mcMMO.p.getCommand("adminchat");
command.setDescription(LocaleLoader.getString("Commands.Description.adminchat")); command.setDescription(LocaleLoader.getString("Commands.Description.adminchat"));
command.setPermission("mcmmo.chat.adminchat"); command.setPermission("mcmmo.chat.adminchat");
@ -320,7 +322,7 @@ public final class CommandRegistrationManager {
command.setExecutor(new AdminChatCommand()); command.setExecutor(new AdminChatCommand());
} }
private static void registerPartyChatCommand() { private void registerPartyChatCommand() {
PluginCommand command = mcMMO.p.getCommand("partychat"); PluginCommand command = mcMMO.p.getCommand("partychat");
command.setDescription(LocaleLoader.getString("Commands.Description.partychat")); command.setDescription(LocaleLoader.getString("Commands.Description.partychat"));
command.setPermission("mcmmo.chat.partychat;mcmmo.commands.party"); command.setPermission("mcmmo.chat.partychat;mcmmo.commands.party");
@ -331,7 +333,7 @@ public final class CommandRegistrationManager {
command.setExecutor(new PartyChatCommand()); command.setExecutor(new PartyChatCommand());
} }
private static void registerPartyCommand() { private void registerPartyCommand() {
PluginCommand command = mcMMO.p.getCommand("party"); PluginCommand command = mcMMO.p.getCommand("party");
command.setDescription(LocaleLoader.getString("Commands.Description.party")); command.setDescription(LocaleLoader.getString("Commands.Description.party"));
command.setPermission("mcmmo.commands.party;mcmmo.commands.party.accept;mcmmo.commands.party.create;mcmmo.commands.party.disband;" + command.setPermission("mcmmo.commands.party;mcmmo.commands.party.accept;mcmmo.commands.party.create;mcmmo.commands.party.disband;" +
@ -342,7 +344,7 @@ public final class CommandRegistrationManager {
command.setExecutor(new PartyCommand()); command.setExecutor(new PartyCommand());
} }
private static void registerPtpCommand() { private void registerPtpCommand() {
PluginCommand command = mcMMO.p.getCommand("ptp"); PluginCommand command = mcMMO.p.getCommand("ptp");
command.setDescription(LocaleLoader.getString("Commands.Description.ptp")); command.setDescription(LocaleLoader.getString("Commands.Description.ptp"));
command.setPermission("mcmmo.commands.ptp"); // Only need the main one, not the individual ones for toggle/accept/acceptall command.setPermission("mcmmo.commands.ptp"); // Only need the main one, not the individual ones for toggle/accept/acceptall
@ -352,7 +354,7 @@ public final class CommandRegistrationManager {
command.setExecutor(new PtpCommand()); command.setExecutor(new PtpCommand());
} }
/*private static void registerHardcoreCommand() { /*private void registerHardcoreCommand() {
PluginCommand command = mcMMO.p.getCommand("hardcore"); PluginCommand command = mcMMO.p.getCommand("hardcore");
command.setDescription(LocaleLoader.getString("Commands.Description.hardcore")); command.setDescription(LocaleLoader.getString("Commands.Description.hardcore"));
command.setPermission("mcmmo.commands.hardcore;mcmmo.commands.hardcore.toggle;mcmmo.commands.hardcore.modify"); command.setPermission("mcmmo.commands.hardcore;mcmmo.commands.hardcore.toggle;mcmmo.commands.hardcore.modify");
@ -362,7 +364,7 @@ public final class CommandRegistrationManager {
command.setExecutor(new HardcoreCommand()); command.setExecutor(new HardcoreCommand());
} }
private static void registerVampirismCommand() { private void registerVampirismCommand() {
PluginCommand command = mcMMO.p.getCommand("vampirism"); PluginCommand command = mcMMO.p.getCommand("vampirism");
command.setDescription(LocaleLoader.getString("Commands.Description.vampirism")); command.setDescription(LocaleLoader.getString("Commands.Description.vampirism"));
command.setPermission("mcmmo.commands.vampirism;mcmmo.commands.vampirism.toggle;mcmmo.commands.vampirism.modify"); command.setPermission("mcmmo.commands.vampirism;mcmmo.commands.vampirism.toggle;mcmmo.commands.vampirism.modify");
@ -372,7 +374,7 @@ public final class CommandRegistrationManager {
command.setExecutor(new VampirismCommand()); command.setExecutor(new VampirismCommand());
}*/ }*/
private static void registerMcnotifyCommand() { private void registerMcnotifyCommand() {
PluginCommand command = mcMMO.p.getCommand("mcnotify"); PluginCommand command = mcMMO.p.getCommand("mcnotify");
command.setDescription(LocaleLoader.getString("Commands.Description.mcnotify")); command.setDescription(LocaleLoader.getString("Commands.Description.mcnotify"));
command.setPermission("mcmmo.commands.mcnotify"); command.setPermission("mcmmo.commands.mcnotify");
@ -381,7 +383,7 @@ public final class CommandRegistrationManager {
command.setExecutor(new McnotifyCommand()); command.setExecutor(new McnotifyCommand());
} }
private static void registerMHDCommand() { private void registerMHDCommand() {
PluginCommand command = mcMMO.p.getCommand("mhd"); PluginCommand command = mcMMO.p.getCommand("mhd");
command.setDescription("Resets all mob health bar settings for all players to the default"); //TODO: Localize command.setDescription("Resets all mob health bar settings for all players to the default"); //TODO: Localize
command.setPermission("mcmmo.commands.mhd"); command.setPermission("mcmmo.commands.mhd");
@ -390,7 +392,7 @@ public final class CommandRegistrationManager {
command.setExecutor(new MHDCommand()); command.setExecutor(new MHDCommand());
} }
private static void registerMcscoreboardCommand() { private void registerMcscoreboardCommand() {
PluginCommand command = mcMMO.p.getCommand("mcscoreboard"); PluginCommand command = mcMMO.p.getCommand("mcscoreboard");
command.setDescription("Change the current mcMMO scoreboard being displayed"); //TODO: Localize command.setDescription("Change the current mcMMO scoreboard being displayed"); //TODO: Localize
command.setPermission("mcmmo.commands.mcscoreboard"); command.setPermission("mcmmo.commands.mcscoreboard");
@ -400,7 +402,7 @@ public final class CommandRegistrationManager {
command.setExecutor(new McscoreboardCommand()); command.setExecutor(new McscoreboardCommand());
} }
private static void registerMcImportCommand() { private void registerMcImportCommand() {
PluginCommand command = mcMMO.p.getCommand("mcimport"); PluginCommand command = mcMMO.p.getCommand("mcimport");
command.setDescription("Import mod config files"); //TODO: Localize command.setDescription("Import mod config files"); //TODO: Localize
command.setPermission("mcmmo.commands.mcimport"); command.setPermission("mcmmo.commands.mcimport");
@ -409,7 +411,7 @@ public final class CommandRegistrationManager {
command.setExecutor(new McImportCommand()); command.setExecutor(new McImportCommand());
} }
private static void registerReloadLocaleCommand() { private void registerReloadLocaleCommand() {
PluginCommand command = mcMMO.p.getCommand("mcmmoreloadlocale"); PluginCommand command = mcMMO.p.getCommand("mcmmoreloadlocale");
command.setDescription("Reloads locale"); // TODO: Localize command.setDescription("Reloads locale"); // TODO: Localize
command.setPermission("mcmmo.commands.reloadlocale"); command.setPermission("mcmmo.commands.reloadlocale");
@ -418,7 +420,7 @@ public final class CommandRegistrationManager {
command.setExecutor(new McmmoReloadLocaleCommand()); command.setExecutor(new McmmoReloadLocaleCommand());
} }
public static void registerCommands() { public void registerCommands() {
// Generic Commands // Generic Commands
registerMmoInfoCommand(); registerMmoInfoCommand();
registerMcImportCommand(); registerMcImportCommand();

View File

@ -367,4 +367,23 @@ public class SkillUtils {
return quantity; return quantity;
} }
/**
* Determine if a recipe has already been registered
* @param recipe target recipe
* @return true if the recipe has already been registered
*/
public static boolean hasRecipeBeenRegistered(Recipe recipe) {
for(Iterator<? extends Recipe> recipeIterator = Bukkit.getServer().recipeIterator(); recipeIterator.hasNext();) {
Recipe bukkitRecipe = recipeIterator.next();
if(bukkitRecipe.getResult().isSimilar(recipe.getResult())) {
return true;
}
}
return false;
}
} }