mirror of
				https://github.com/mcMMO-Dev/mcMMO.git
				synced 2025-11-04 02:53:43 +01:00 
			
		
		
		
	Merge pull request #3911 from mikroskeem/feature/locale-reload-command
Add a command to reload locale
This commit is contained in:
		@@ -0,0 +1,30 @@
 | 
				
			|||||||
 | 
					package com.gmail.nossr50.commands.admin;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.gmail.nossr50.locale.LocaleLoader;
 | 
				
			||||||
 | 
					import com.gmail.nossr50.util.Permissions;
 | 
				
			||||||
 | 
					import org.bukkit.command.Command;
 | 
				
			||||||
 | 
					import org.bukkit.command.CommandExecutor;
 | 
				
			||||||
 | 
					import org.bukkit.command.CommandSender;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * @author Mark Vainomaa
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					public final class McmmoReloadLocaleCommand implements CommandExecutor {
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
 | 
				
			||||||
 | 
					        switch (args.length) {
 | 
				
			||||||
 | 
					            case 0:
 | 
				
			||||||
 | 
					                if (!Permissions.reloadlocale(sender)) {
 | 
				
			||||||
 | 
					                    sender.sendMessage(command.getPermissionMessage());
 | 
				
			||||||
 | 
					                    return true;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                LocaleLoader.reloadLocale();
 | 
				
			||||||
 | 
					                sender.sendMessage(LocaleLoader.getString("Locale.Reloaded"));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                return true;
 | 
				
			||||||
 | 
					            default:
 | 
				
			||||||
 | 
					                return false;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -47,6 +47,17 @@ public final class LocaleLoader {
 | 
				
			|||||||
        return formatString(rawMessage, messageArguments);
 | 
					        return formatString(rawMessage, messageArguments);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Reloads locale
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public static void reloadLocale() {
 | 
				
			||||||
 | 
					        bundle = null;
 | 
				
			||||||
 | 
					        filesystemBundle = null;
 | 
				
			||||||
 | 
					        enBundle = null;
 | 
				
			||||||
 | 
					        bundleCache = new HashMap<>(); // Cheaper to replace than clear()
 | 
				
			||||||
 | 
					        initialize();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private static String getRawString(String key) {
 | 
					    private static String getRawString(String key) {
 | 
				
			||||||
        if (filesystemBundle != null) {
 | 
					        if (filesystemBundle != null) {
 | 
				
			||||||
            try {
 | 
					            try {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -101,6 +101,7 @@ public final class Permissions {
 | 
				
			|||||||
    public static boolean mcpurge(Permissible permissible) { return permissible.hasPermission("mcmmo.commands.mcpurge"); }
 | 
					    public static boolean mcpurge(Permissible permissible) { return permissible.hasPermission("mcmmo.commands.mcpurge"); }
 | 
				
			||||||
    public static boolean mcremove(Permissible permissible) { return permissible.hasPermission("mcmmo.commands.mcremove"); }
 | 
					    public static boolean mcremove(Permissible permissible) { return permissible.hasPermission("mcmmo.commands.mcremove"); }
 | 
				
			||||||
    public static boolean mmoupdate(Permissible permissible) { return permissible.hasPermission("mcmmo.commands.mmoupdate"); }
 | 
					    public static boolean mmoupdate(Permissible permissible) { return permissible.hasPermission("mcmmo.commands.mmoupdate"); }
 | 
				
			||||||
 | 
					    public static boolean reloadlocale(Permissible permissible) { return permissible.hasPermission("mcmmo.commands.reloadlocale"); }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /*
 | 
					    /*
 | 
				
			||||||
     * PERKS
 | 
					     * PERKS
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,6 +1,7 @@
 | 
				
			|||||||
package com.gmail.nossr50.util.commands;
 | 
					package com.gmail.nossr50.util.commands;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import com.gmail.nossr50.commands.*;
 | 
					import com.gmail.nossr50.commands.*;
 | 
				
			||||||
 | 
					import com.gmail.nossr50.commands.admin.McmmoReloadLocaleCommand;
 | 
				
			||||||
import com.gmail.nossr50.commands.chat.AdminChatCommand;
 | 
					import com.gmail.nossr50.commands.chat.AdminChatCommand;
 | 
				
			||||||
import com.gmail.nossr50.commands.chat.McChatSpy;
 | 
					import com.gmail.nossr50.commands.chat.McChatSpy;
 | 
				
			||||||
import com.gmail.nossr50.commands.chat.PartyChatCommand;
 | 
					import com.gmail.nossr50.commands.chat.PartyChatCommand;
 | 
				
			||||||
@@ -400,6 +401,15 @@ public final class CommandRegistrationManager {
 | 
				
			|||||||
        command.setExecutor(new McImportCommand());
 | 
					        command.setExecutor(new McImportCommand());
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private static void registerReloadLocaleCommand() {
 | 
				
			||||||
 | 
					        PluginCommand command = mcMMO.p.getCommand("mcmmoreloadlocale");
 | 
				
			||||||
 | 
					        command.setDescription("Reloads locale"); // TODO: Localize
 | 
				
			||||||
 | 
					        command.setPermission("mcmmo.commands.reloadlocale");
 | 
				
			||||||
 | 
					        command.setPermissionMessage(permissionsMessage);
 | 
				
			||||||
 | 
					        command.setUsage(LocaleLoader.formatString("Commands.Usage.0", "mcmmoreloadlocale"));
 | 
				
			||||||
 | 
					        command.setExecutor(new McmmoReloadLocaleCommand());
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public static void registerCommands() {
 | 
					    public static void registerCommands() {
 | 
				
			||||||
        // Generic Commands
 | 
					        // Generic Commands
 | 
				
			||||||
        registerMmoInfoCommand();
 | 
					        registerMmoInfoCommand();
 | 
				
			||||||
@@ -447,5 +457,8 @@ public final class CommandRegistrationManager {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        // Skill Commands
 | 
					        // Skill Commands
 | 
				
			||||||
        registerSkillCommands();
 | 
					        registerSkillCommands();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // Admin commands
 | 
				
			||||||
 | 
					        registerReloadLocaleCommand();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1076,4 +1076,6 @@ 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.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!
 | 
					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 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.
 | 
				
			||||||
 | 
					#Locale
 | 
				
			||||||
 | 
					Locale.Reloaded=[[GREEN]]Locale reloaded!
 | 
				
			||||||
@@ -168,6 +168,10 @@ commands:
 | 
				
			|||||||
        aliases: [macho, jumping, throwing, wrecking, crafting, walking, swimming, falling, climbing, flying, diving, piggy]
 | 
					        aliases: [macho, jumping, throwing, wrecking, crafting, walking, swimming, falling, climbing, flying, diving, piggy]
 | 
				
			||||||
        description: Deploy jokes
 | 
					        description: Deploy jokes
 | 
				
			||||||
        permission: mcmmo.commands.mcfools
 | 
					        permission: mcmmo.commands.mcfools
 | 
				
			||||||
 | 
					    mcmmoreloadlocale:
 | 
				
			||||||
 | 
					        aliases: [mcreloadlocale]
 | 
				
			||||||
 | 
					        description: Reloads locale
 | 
				
			||||||
 | 
					        permission: mcmmo.commands.reloadlocale
 | 
				
			||||||
permissions:
 | 
					permissions:
 | 
				
			||||||
    mcmmo.*:
 | 
					    mcmmo.*:
 | 
				
			||||||
        default: false
 | 
					        default: false
 | 
				
			||||||
@@ -807,6 +811,7 @@ permissions:
 | 
				
			|||||||
            mcmmo.commands.mmoedit.others: true
 | 
					            mcmmo.commands.mmoedit.others: true
 | 
				
			||||||
            mcmmo.commands.mmoshowdb: true
 | 
					            mcmmo.commands.mmoshowdb: true
 | 
				
			||||||
            mcmmo.commands.ptp.world.all: true
 | 
					            mcmmo.commands.ptp.world.all: true
 | 
				
			||||||
 | 
					            mcmmo.commands.reloadlocale: true
 | 
				
			||||||
            mcmmo.commands.skillreset.all: true
 | 
					            mcmmo.commands.skillreset.all: true
 | 
				
			||||||
            mcmmo.commands.vampirism.all: true
 | 
					            mcmmo.commands.vampirism.all: true
 | 
				
			||||||
            mcmmo.commands.xprate.all: true
 | 
					            mcmmo.commands.xprate.all: true
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user