mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2025-01-04 07:27:59 +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;
|
continue;
|
||||||
// code beneath modified from CraftServer
|
// code beneath modified from CraftServer
|
||||||
try {
|
try {
|
||||||
Messaging.logF("Loading %s", plugin.getDescription().getFullName());
|
Messaging.logTr(Messages.LOADING_SUB_PLUGIN, plugin.getDescription().getFullName());
|
||||||
plugin.onLoad();
|
plugin.onLoad();
|
||||||
} catch (Throwable ex) {
|
} 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();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -145,7 +146,7 @@ public class Citizens extends JavaPlugin implements CitizensPlugin {
|
|||||||
try {
|
try {
|
||||||
commands.execute(split, sender, sender, npc);
|
commands.execute(split, sender, sender, npc);
|
||||||
} catch (ServerCommandException ex) {
|
} catch (ServerCommandException ex) {
|
||||||
Messaging.send(sender, "You must be in-game to execute that command.");
|
Messaging.sendTr(sender, Messages.INGAME_COMMAND);
|
||||||
} catch (CommandUsageException ex) {
|
} catch (CommandUsageException ex) {
|
||||||
Messaging.sendError(sender, ex.getMessage());
|
Messaging.sendError(sender, ex.getMessage());
|
||||||
Messaging.sendError(sender, ex.getUsage());
|
Messaging.sendError(sender, ex.getUsage());
|
||||||
@ -157,11 +158,11 @@ public class Citizens extends JavaPlugin implements CitizensPlugin {
|
|||||||
Messaging.sendError(sender, ex.getMessage());
|
Messaging.sendError(sender, ex.getMessage());
|
||||||
}
|
}
|
||||||
} catch (NumberFormatException ex) {
|
} catch (NumberFormatException ex) {
|
||||||
Messaging.sendError(sender, "That is not a valid number.");
|
Messaging.sendErrorTr(sender, Messages.COMMAND_INVALID_NUMBER);
|
||||||
} catch (Throwable ex) {
|
} catch (Throwable ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
if (sender instanceof Player) {
|
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());
|
Messaging.sendError(sender, ex.getClass().getName() + ": " + ex.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -197,6 +198,7 @@ public class Citizens extends JavaPlugin implements CitizensPlugin {
|
|||||||
getServer().getPluginManager().disablePlugin(this);
|
getServer().getPluginManager().disablePlugin(this);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
setupTranslator();
|
||||||
registerScriptHelpers();
|
registerScriptHelpers();
|
||||||
|
|
||||||
config = new Settings(getDataFolder());
|
config = new Settings(getDataFolder());
|
||||||
@ -218,7 +220,6 @@ public class Citizens extends JavaPlugin implements CitizensPlugin {
|
|||||||
setupEconomy();
|
setupEconomy();
|
||||||
|
|
||||||
registerCommands();
|
registerCommands();
|
||||||
setupTranslator();
|
|
||||||
Messaging.logF("v%s enabled.", getDescription().getVersion());
|
Messaging.logF("v%s enabled.", getDescription().getVersion());
|
||||||
|
|
||||||
// Setup NPCs after all plugins have been enabled (allows for multiworld
|
// 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());
|
Bukkit.getPluginManager().callEvent(new CitizensEnableEvent());
|
||||||
}
|
}
|
||||||
}) == -1) {
|
}) == -1) {
|
||||||
Messaging.severe("NPC load task couldn't be scheduled - disabling...");
|
Messaging.severeTr(Messages.LOAD_TASK_NOT_SCHEDULED);
|
||||||
getServer().getPluginManager().disablePlugin(this);
|
getServer().getPluginManager().disablePlugin(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -291,7 +292,7 @@ public class Citizens extends JavaPlugin implements CitizensPlugin {
|
|||||||
Bukkit.getPluginManager().registerEvents(new PaymentListener(economy), this);
|
Bukkit.getPluginManager().registerEvents(new PaymentListener(economy), this);
|
||||||
}
|
}
|
||||||
} catch (NoClassDefFoundError e) {
|
} 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;
|
break;
|
||||||
}
|
}
|
||||||
Translator.setInstance(new File(getDataFolder(), "i18n"), locale);
|
Translator.setInstance(new File(getDataFolder(), "i18n"), locale);
|
||||||
Messaging.logF("Using locale %s.", locale);
|
Messaging.logTr(Messages.LOCALE_NOTIFICATION, locale);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void startMetrics() {
|
private void startMetrics() {
|
||||||
@ -342,9 +343,9 @@ public class Citizens extends JavaPlugin implements CitizensPlugin {
|
|||||||
|
|
||||||
traitFactory.addPlotters(metrics.createGraph("traits"));
|
traitFactory.addPlotters(metrics.createGraph("traits"));
|
||||||
metrics.start();
|
metrics.start();
|
||||||
Messaging.log("Metrics started.");
|
Messaging.logTr(Messages.METRICS_NOTIFICATION);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Messaging.logF("Unable to start metrics: %s.", e.getMessage());
|
Messaging.logTr(Messages.METRICS_ERROR_NOTIFICATION, e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}.start();
|
}.start();
|
||||||
@ -377,7 +378,7 @@ public class Citizens extends JavaPlugin implements CitizensPlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!closest.isEmpty()) {
|
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));
|
sender.sendMessage(StringHelper.wrap(" /") + command + " " + StringHelper.wrap(closest));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -192,7 +192,7 @@ public class EventListen implements Listener {
|
|||||||
return;
|
return;
|
||||||
int owned = 0;
|
int owned = 0;
|
||||||
for (NPC npc : npcRegistry) {
|
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++;
|
owned++;
|
||||||
}
|
}
|
||||||
int wouldOwn = owned + 1;
|
int wouldOwn = owned + 1;
|
||||||
|
@ -223,6 +223,7 @@ public class NPCCommands {
|
|||||||
npc.spawn(player.getLocation());
|
npc.spawn(player.getLocation());
|
||||||
|
|
||||||
PlayerCreateNPCEvent event = new PlayerCreateNPCEvent(player, npc);
|
PlayerCreateNPCEvent event = new PlayerCreateNPCEvent(player, npc);
|
||||||
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
if (event.isCancelled()) {
|
if (event.isCancelled()) {
|
||||||
npc.destroy();
|
npc.destroy();
|
||||||
String reason = "Couldn't create NPC.";
|
String reason = "Couldn't create NPC.";
|
||||||
|
@ -15,7 +15,19 @@ import com.google.common.io.Closeables;
|
|||||||
public enum Messages {
|
public enum Messages {
|
||||||
CITIZENS_IMPLEMENTATION_DISABLED("citizens.changed-implementation",
|
CITIZENS_IMPLEMENTATION_DISABLED("citizens.changed-implementation",
|
||||||
"Citizens implementation changed, disabling plugin."),
|
"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 defaultTranslation;
|
||||||
private String key;
|
private String key;
|
||||||
|
|
||||||
|
@ -46,10 +46,6 @@ public class Messaging {
|
|||||||
log(getFormatted(msg));
|
log(getFormatted(msg));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void logTr(Messages key) {
|
|
||||||
log(Level.INFO, Translator.tr(key));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void logTr(Messages key, Object... msg) {
|
public static void logTr(Messages key, Object... msg) {
|
||||||
log(Level.INFO, Translator.tr(key, msg));
|
log(Level.INFO, Translator.tr(key, msg));
|
||||||
}
|
}
|
||||||
@ -66,6 +62,10 @@ public class Messaging {
|
|||||||
sendF(sender, ChatColor.RED.toString() + SPACE.join(msg));
|
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) {
|
public static void sendF(CommandSender sender, Object... msg) {
|
||||||
sendMessageTo(sender, getFormatted(msg));
|
sendMessageTo(sender, getFormatted(msg));
|
||||||
}
|
}
|
||||||
@ -75,10 +75,6 @@ public class Messaging {
|
|||||||
sender.sendMessage(msg);
|
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) {
|
public static void sendTr(CommandSender sender, Messages key, Object... msg) {
|
||||||
sendMessageTo(sender, Translator.tr(key, msg));
|
sendMessageTo(sender, Translator.tr(key, msg));
|
||||||
}
|
}
|
||||||
@ -106,7 +102,7 @@ public class Messaging {
|
|||||||
log(Level.SEVERE, getFormatted(messages));
|
log(Level.SEVERE, getFormatted(messages));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void severeTr(Messages key) {
|
public static void severeTr(Messages key, Object... messages) {
|
||||||
log(Level.SEVERE, Translator.tr(key));
|
log(Level.SEVERE, Translator.tr(key, messages));
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user