mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-22 21:26:46 +01:00
Merge pull request #3911 from mikroskeem/feature/locale-reload-command
Add a command to reload locale
This commit is contained in:
commit
7f95956a01
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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) {
|
||||
if (filesystemBundle != null) {
|
||||
try {
|
||||
|
@ -101,6 +101,7 @@ public final class Permissions {
|
||||
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 mmoupdate(Permissible permissible) { return permissible.hasPermission("mcmmo.commands.mmoupdate"); }
|
||||
public static boolean reloadlocale(Permissible permissible) { return permissible.hasPermission("mcmmo.commands.reloadlocale"); }
|
||||
|
||||
/*
|
||||
* PERKS
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.gmail.nossr50.util.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.McChatSpy;
|
||||
import com.gmail.nossr50.commands.chat.PartyChatCommand;
|
||||
@ -400,6 +401,15 @@ public final class CommandRegistrationManager {
|
||||
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() {
|
||||
// Generic Commands
|
||||
registerMmoInfoCommand();
|
||||
@ -447,5 +457,8 @@ public final class CommandRegistrationManager {
|
||||
|
||||
// Skill Commands
|
||||
registerSkillCommands();
|
||||
|
||||
// Admin commands
|
||||
registerReloadLocaleCommand();
|
||||
}
|
||||
}
|
||||
|
@ -1077,3 +1077,5 @@ 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.
|
||||
#Locale
|
||||
Locale.Reloaded=[[GREEN]]Locale reloaded!
|
@ -168,6 +168,10 @@ commands:
|
||||
aliases: [macho, jumping, throwing, wrecking, crafting, walking, swimming, falling, climbing, flying, diving, piggy]
|
||||
description: Deploy jokes
|
||||
permission: mcmmo.commands.mcfools
|
||||
mcmmoreloadlocale:
|
||||
aliases: [mcreloadlocale]
|
||||
description: Reloads locale
|
||||
permission: mcmmo.commands.reloadlocale
|
||||
permissions:
|
||||
mcmmo.*:
|
||||
default: false
|
||||
@ -807,6 +811,7 @@ permissions:
|
||||
mcmmo.commands.mmoedit.others: true
|
||||
mcmmo.commands.mmoshowdb: true
|
||||
mcmmo.commands.ptp.world.all: true
|
||||
mcmmo.commands.reloadlocale: true
|
||||
mcmmo.commands.skillreset.all: true
|
||||
mcmmo.commands.vampirism.all: true
|
||||
mcmmo.commands.xprate.all: true
|
||||
|
Loading…
Reference in New Issue
Block a user