mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2025-01-01 14:08:08 +01:00
Fix CITIZENS-190, add more translations
This commit is contained in:
parent
fb66286117
commit
f0de2fbfe5
@ -91,10 +91,11 @@ public class Citizens extends JavaPlugin implements CitizensPlugin {
|
||||
continue;
|
||||
// code beneath modified from CraftServer
|
||||
try {
|
||||
Messaging.logF("Loading %s", plugin.getDescription().getFullName());
|
||||
Messaging.logTr(Messages.LOADING_SUB_PLUGIN, plugin.getDescription().getFullName());
|
||||
plugin.onLoad();
|
||||
} catch (Throwable ex) {
|
||||
Messaging.severe(ex.getMessage() + " initializing " + plugin.getDescription().getFullName());
|
||||
Messaging.severeTr(Messages.ERROR_INITALISING_SUB_PLUGIN, ex.getMessage(), plugin
|
||||
.getDescription().getFullName());
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
@ -145,7 +146,7 @@ public class Citizens extends JavaPlugin implements CitizensPlugin {
|
||||
try {
|
||||
commands.execute(split, sender, sender, npc);
|
||||
} catch (ServerCommandException ex) {
|
||||
Messaging.send(sender, "You must be in-game to execute that command.");
|
||||
Messaging.sendTr(sender, Messages.INGAME_COMMAND);
|
||||
} catch (CommandUsageException ex) {
|
||||
Messaging.sendError(sender, ex.getMessage());
|
||||
Messaging.sendError(sender, ex.getUsage());
|
||||
@ -157,11 +158,11 @@ public class Citizens extends JavaPlugin implements CitizensPlugin {
|
||||
Messaging.sendError(sender, ex.getMessage());
|
||||
}
|
||||
} catch (NumberFormatException ex) {
|
||||
Messaging.sendError(sender, "That is not a valid number.");
|
||||
Messaging.sendErrorTr(sender, Messages.COMMAND_INVALID_NUMBER);
|
||||
} catch (Throwable ex) {
|
||||
ex.printStackTrace();
|
||||
if (sender instanceof Player) {
|
||||
Messaging.sendError(sender, "Please report this error: [See console]");
|
||||
Messaging.sendErrorTr(sender, Messages.COMMAND_REPORT_ERROR);
|
||||
Messaging.sendError(sender, ex.getClass().getName() + ": " + ex.getMessage());
|
||||
}
|
||||
}
|
||||
@ -197,6 +198,7 @@ public class Citizens extends JavaPlugin implements CitizensPlugin {
|
||||
getServer().getPluginManager().disablePlugin(this);
|
||||
return;
|
||||
}
|
||||
setupTranslator();
|
||||
registerScriptHelpers();
|
||||
|
||||
config = new Settings(getDataFolder());
|
||||
@ -218,7 +220,6 @@ public class Citizens extends JavaPlugin implements CitizensPlugin {
|
||||
setupEconomy();
|
||||
|
||||
registerCommands();
|
||||
setupTranslator();
|
||||
Messaging.logF("v%s enabled.", getDescription().getVersion());
|
||||
|
||||
// Setup NPCs after all plugins have been enabled (allows for multiworld
|
||||
@ -233,7 +234,7 @@ public class Citizens extends JavaPlugin implements CitizensPlugin {
|
||||
Bukkit.getPluginManager().callEvent(new CitizensEnableEvent());
|
||||
}
|
||||
}) == -1) {
|
||||
Messaging.severe("NPC load task couldn't be scheduled - disabling...");
|
||||
Messaging.severeTr(Messages.LOAD_TASK_NOT_SCHEDULED);
|
||||
getServer().getPluginManager().disablePlugin(this);
|
||||
}
|
||||
}
|
||||
@ -291,7 +292,7 @@ public class Citizens extends JavaPlugin implements CitizensPlugin {
|
||||
Bukkit.getPluginManager().registerEvents(new PaymentListener(economy), this);
|
||||
}
|
||||
} catch (NoClassDefFoundError e) {
|
||||
Messaging.log("Unable to use economy handling. Has Vault been enabled?");
|
||||
Messaging.logTr(Messages.ERROR_LOADING_ECONOMY);
|
||||
}
|
||||
}
|
||||
|
||||
@ -322,7 +323,7 @@ public class Citizens extends JavaPlugin implements CitizensPlugin {
|
||||
break;
|
||||
}
|
||||
Translator.setInstance(new File(getDataFolder(), "i18n"), locale);
|
||||
Messaging.logF("Using locale %s.", locale);
|
||||
Messaging.logTr(Messages.LOCALE_NOTIFICATION, locale);
|
||||
}
|
||||
|
||||
private void startMetrics() {
|
||||
@ -342,9 +343,9 @@ public class Citizens extends JavaPlugin implements CitizensPlugin {
|
||||
|
||||
traitFactory.addPlotters(metrics.createGraph("traits"));
|
||||
metrics.start();
|
||||
Messaging.log("Metrics started.");
|
||||
Messaging.logTr(Messages.METRICS_NOTIFICATION);
|
||||
} catch (IOException e) {
|
||||
Messaging.logF("Unable to start metrics: %s.", e.getMessage());
|
||||
Messaging.logTr(Messages.METRICS_ERROR_NOTIFICATION, e.getMessage());
|
||||
}
|
||||
}
|
||||
}.start();
|
||||
@ -377,7 +378,7 @@ public class Citizens extends JavaPlugin implements CitizensPlugin {
|
||||
}
|
||||
}
|
||||
if (!closest.isEmpty()) {
|
||||
sender.sendMessage(ChatColor.GRAY + "Unknown command. Did you mean:");
|
||||
sender.sendMessage(ChatColor.GRAY + Translator.tr(Messages.UNKNOWN_COMMAND));
|
||||
sender.sendMessage(StringHelper.wrap(" /") + command + " " + StringHelper.wrap(closest));
|
||||
return true;
|
||||
}
|
||||
|
@ -192,7 +192,7 @@ public class EventListen implements Listener {
|
||||
return;
|
||||
int owned = 0;
|
||||
for (NPC npc : npcRegistry) {
|
||||
if (npc.getTrait(Owner.class).isOwnedBy(event.getCreator()))
|
||||
if (!event.getNPC().equals(npc) && npc.getTrait(Owner.class).isOwnedBy(event.getCreator()))
|
||||
owned++;
|
||||
}
|
||||
int wouldOwn = owned + 1;
|
||||
|
@ -223,6 +223,7 @@ public class NPCCommands {
|
||||
npc.spawn(player.getLocation());
|
||||
|
||||
PlayerCreateNPCEvent event = new PlayerCreateNPCEvent(player, npc);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (event.isCancelled()) {
|
||||
npc.destroy();
|
||||
String reason = "Couldn't create NPC.";
|
||||
|
@ -15,7 +15,19 @@ import com.google.common.io.Closeables;
|
||||
public enum Messages {
|
||||
CITIZENS_IMPLEMENTATION_DISABLED("citizens.changed-implementation",
|
||||
"Citizens implementation changed, disabling plugin."),
|
||||
FAILED_LOAD_SAVES("citizens.saves.load-failed", "Unable to load saves, disabling...");
|
||||
COMMAND_INVALID_NUMBER("citizens.commands.invalid-number", "That is not a valid number."),
|
||||
COMMAND_REPORT_ERROR("citizens.commands.console-error", "Please report this error: [See console]"),
|
||||
ERROR_INITALISING_SUB_PLUGIN("citizens.sub-plugins.error-on-load", "{0} initializing {1}"),
|
||||
ERROR_LOADING_ECONOMY("citizens.economy.error-loading",
|
||||
"Unable to use economy handling. Has Vault been enabled?"),
|
||||
FAILED_LOAD_SAVES("citizens.saves.load-failed", "Unable to load saves, disabling..."),
|
||||
INGAME_COMMAND("citizens.commands.must-be-ingame", "You must be ingame to use that command."),
|
||||
LOAD_TASK_NOT_SCHEDULED("citizens.load-task-error", "NPC load task couldn't be scheduled - disabling..."),
|
||||
LOADING_SUB_PLUGIN("citizens.sub-plugins.load", "Loading {0}"),
|
||||
LOCALE_NOTIFICATION("citizens.notifications.locale", "Using locale {0}."),
|
||||
METRICS_ERROR_NOTIFICATION("citizens.notifications.metrics-load-error", "Unable to start metrics: {0}."),
|
||||
METRICS_NOTIFICATION("citizens.notifications.metrics-started", "Metrics started."),
|
||||
UNKNOWN_COMMAND("citizens.commands.unknown-command", "Unknown command. Did you mean:");
|
||||
private String defaultTranslation;
|
||||
private String key;
|
||||
|
||||
|
@ -46,10 +46,6 @@ public class Messaging {
|
||||
log(getFormatted(msg));
|
||||
}
|
||||
|
||||
public static void logTr(Messages key) {
|
||||
log(Level.INFO, Translator.tr(key));
|
||||
}
|
||||
|
||||
public static void logTr(Messages key, Object... msg) {
|
||||
log(Level.INFO, Translator.tr(key, msg));
|
||||
}
|
||||
@ -66,6 +62,10 @@ public class Messaging {
|
||||
sendF(sender, ChatColor.RED.toString() + SPACE.join(msg));
|
||||
}
|
||||
|
||||
public static void sendErrorTr(CommandSender sender, Messages key, Object... msg) {
|
||||
sendMessageTo(sender, ChatColor.RED + Translator.tr(key, msg));
|
||||
}
|
||||
|
||||
public static void sendF(CommandSender sender, Object... msg) {
|
||||
sendMessageTo(sender, getFormatted(msg));
|
||||
}
|
||||
@ -75,10 +75,6 @@ public class Messaging {
|
||||
sender.sendMessage(msg);
|
||||
}
|
||||
|
||||
public static void sendTr(CommandSender sender, Messages key) {
|
||||
sendMessageTo(sender, Translator.tr(key));
|
||||
}
|
||||
|
||||
public static void sendTr(CommandSender sender, Messages key, Object... msg) {
|
||||
sendMessageTo(sender, Translator.tr(key, msg));
|
||||
}
|
||||
@ -106,7 +102,7 @@ public class Messaging {
|
||||
log(Level.SEVERE, getFormatted(messages));
|
||||
}
|
||||
|
||||
public static void severeTr(Messages key) {
|
||||
log(Level.SEVERE, Translator.tr(key));
|
||||
public static void severeTr(Messages key, Object... messages) {
|
||||
log(Level.SEVERE, Translator.tr(key, messages));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user