diff --git a/Essentials/src/com/earth2me/essentials/EssentialsEcoPlayerListener.java b/Essentials/src/com/earth2me/essentials/EssentialsEcoPlayerListener.java index c34b0cf53..9233a6074 100644 --- a/Essentials/src/com/earth2me/essentials/EssentialsEcoPlayerListener.java +++ b/Essentials/src/com/earth2me/essentials/EssentialsEcoPlayerListener.java @@ -47,7 +47,7 @@ public class EssentialsEcoPlayerListener extends PlayerListener double cost = Double.parseDouble(sign.getLine(3).substring(1)); if (user.getMoney() < cost) { - throw new Exception("You do not have sufficient funds."); + throw new Exception(Util.i18n("notEnoughMoney")); } user.takeMoney(cost); Map leftOver = user.getInventory().addItem(item); @@ -59,7 +59,7 @@ public class EssentialsEcoPlayerListener extends PlayerListener } catch (Throwable ex) { - user.sendMessage("§cError: " + ex.getMessage()); + user.sendMessage(Util.format("errorWithMessage", ex.getMessage())); } return; } @@ -73,7 +73,7 @@ public class EssentialsEcoPlayerListener extends PlayerListener double cost = Double.parseDouble(sign.getLine(3).substring(1)); if (!InventoryWorkaround.containsItem(user.getInventory(), true, item)) { - throw new Exception("You do not have enough items to sell."); + throw new Exception(Util.format("missingItems", amount, sign.getLine(2))); } user.giveMoney(cost); InventoryWorkaround.removeItem(user.getInventory(), true, item); @@ -81,7 +81,7 @@ public class EssentialsEcoPlayerListener extends PlayerListener } catch (Throwable ex) { - user.sendMessage("§cError: " + ex.getMessage()); + user.sendMessage(Util.format("errorWithMessage", ex.getMessage())); } return; } @@ -102,7 +102,7 @@ public class EssentialsEcoPlayerListener extends PlayerListener r2 = m2 ? r2 : r2 - r2 % q2; if ((!m1 & q1 < 1) || (!m2 & q2 < 1)) { - throw new Exception("Quantities must be greater than 0."); + throw new Exception(Util.i18n("moreThanZero")); } ItemStack i1 = m1 || r1 <= 0 ? null : ItemDb.get(l1[1], (int)r1); @@ -134,20 +134,20 @@ public class EssentialsEcoPlayerListener extends PlayerListener { if (user.getMoney() < q1) { - throw new Exception("You do not have sufficient funds."); + throw new Exception(Util.i18n("notEnoughMoney")); } } else { if (!InventoryWorkaround.containsItem(user.getInventory(), true, qi1)) { - throw new Exception("You do not have " + String.valueOf((int)q1) + "x " + l1[1] + "."); + throw new Exception(Util.format("missingItems", (int)q1, l1[1])); } } if (r2 < q2) { - throw new Exception("The trade sign does not have enough supply left."); + throw new Exception(Util.i18n("tradeSignEmpty")); } if (m1) @@ -182,12 +182,12 @@ public class EssentialsEcoPlayerListener extends PlayerListener sign.setLine(1, (m1 ? Util.formatCurrency(q1) : String.format("%.0f", q1) + " " + l1[1]) + ":" + String.format((m1 ? "%.2f" : "%.0f"), Util.roundDouble(r1))); sign.setLine(2, (m2 ? Util.formatCurrency(q2) : String.format("%.0f", q2) + " " + l2[1]) + ":" + String.format((m2 ? "%.2f" : "%.0f"), Util.roundDouble(r2))); sign.update(); - user.sendMessage("§7Trade completed."); + user.sendMessage(Util.i18n("tradeCompleted")); } } catch (Throwable ex) { - user.sendMessage("§cError: " + ex.getMessage()); + user.sendMessage(Util.format("errorWithMessage", ex.getMessage())); } return; } diff --git a/Essentials/src/com/earth2me/essentials/EssentialsEntityListener.java b/Essentials/src/com/earth2me/essentials/EssentialsEntityListener.java index a3f6a19b6..8e7a8389d 100644 --- a/Essentials/src/com/earth2me/essentials/EssentialsEntityListener.java +++ b/Essentials/src/com/earth2me/essentials/EssentialsEntityListener.java @@ -1,6 +1,5 @@ package com.earth2me.essentials; -import org.bukkit.Server; import org.bukkit.craftbukkit.entity.CraftPlayer; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; @@ -76,7 +75,7 @@ public class EssentialsEntityListener extends EntityListener if (user.isAuthorized("essentials.back.ondeath") && !ess.getSettings().isCommandDisabled("back")) { user.setLastLocation(); - user.sendMessage("§7Use the /back command to return to your death point"); + user.sendMessage(Util.i18n("backAfterDeath")); } } } diff --git a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java index 236bb3a53..32dffcee4 100644 --- a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java +++ b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java @@ -54,7 +54,7 @@ public class EssentialsPlayerListener extends PlayerListener if (user.isMuted()) { event.setCancelled(true); - logger.info(user.getName() + " tried to speak, but is muted."); + logger.info(Util.format("mutedUserSpeaks", user.getName())); } } @@ -136,15 +136,15 @@ public class EssentialsPlayerListener extends PlayerListener if (world.getEnvironment() == World.Environment.NETHER || ess.getSettings().getGenerateExitPortals()) { portal = NetherPortal.createPortal(dest); - logger.info(event.getPlayer().getName() + " used a portal and generated an exit portal."); - user.sendMessage("§7Generating an exit portal."); + logger.info(Util.format("userCreatedPortal ", event.getPlayer().getName())); + user.sendMessage(Util.i18n("generatingPortal")); loc = portal.getSpawn(); } } else { - logger.info(event.getPlayer().getName() + " used a portal and used an existing exit portal."); - user.sendMessage("§7Teleporting via portal to an existing portal."); + logger.info(Util.format("userUsedPortal", event.getPlayer().getName())); + user.sendMessage(Util.i18n("usingPortal")); loc = portal.getSpawn(); } @@ -159,7 +159,7 @@ public class EssentialsPlayerListener extends PlayerListener user.sendMessage(ex.getMessage()); } user.setJustPortaled(true); - user.sendMessage("§7Teleporting via portal."); + user.sendMessage(Util.i18n("teleportingPortal")); event.setCancelled(true); return; @@ -185,7 +185,6 @@ public class EssentialsPlayerListener extends PlayerListener user.dispose(); Thread thread = new Thread(new Runnable() { - @SuppressWarnings("LoggerStringConcat") public void run() { try @@ -197,7 +196,7 @@ public class EssentialsPlayerListener extends PlayerListener rt.gc(); mem = rt.freeMemory() - mem; mem /= 1024 * 1024; - logger.info("Freed " + mem + " MB."); + logger.log(Level.INFO, Util.format("freedMemory", mem)); } catch (InterruptedException ex) { @@ -219,7 +218,7 @@ public class EssentialsPlayerListener extends PlayerListener if (user.isIpBanned()) { String banReason = user.getBanReason(); - user.kickPlayer(banReason != null && !banReason.isEmpty() ? banReason : "The Ban Hammer has spoken!"); + user.kickPlayer(banReason != null && !banReason.isEmpty() ? banReason : Util.i18n("defaultBanReason")); return; } @@ -242,11 +241,11 @@ public class EssentialsPlayerListener extends PlayerListener List mail = user.getMails(); if (mail.isEmpty()) { - user.sendMessage("§7You have no new mail."); + user.sendMessage(Util.i18n("noNewMail")); } else { - user.sendMessage("§cYou have " + mail.size() + " messages!§f Type §7/mail read§f to view your mail."); + user.sendMessage(Util.format("youHaveNewMail", mail.size())); } } } @@ -263,13 +262,13 @@ public class EssentialsPlayerListener extends PlayerListener if (user.isBanned()) { String banReason = user.getBanReason(); - event.disallow(Result.KICK_BANNED, banReason != null && !banReason.isEmpty() ? banReason : "The Ban Hammer has spoken!"); + event.disallow(Result.KICK_BANNED, banReason != null && !banReason.isEmpty() ? banReason : Util.i18n("defaultBanReason")); return; } if (server.getOnlinePlayers().length >= server.getMaxPlayers() && !user.isAuthorized("essentials.joinfullserver")) { - event.disallow(Result.KICK_FULL, "Server is full"); + event.disallow(Result.KICK_FULL, Util.i18n("serverFull")); return; } @@ -306,9 +305,9 @@ public class EssentialsPlayerListener extends PlayerListener } catch (Exception ex) { - logger.log(Level.WARNING, "Error occured when trying to return player to jail.", ex); + logger.log(Level.WARNING, Util.i18n("returnPlayerToJailError"), ex); } - user.sendMessage(ChatColor.RED + "You do the crime, you do the time."); + user.sendMessage(Util.i18n("jailMessage")); } @Override @@ -335,7 +334,7 @@ public class EssentialsPlayerListener extends PlayerListener if (essBlockListener.isBlockProtected(event.getClickedBlock(), user)) { event.setCancelled(true); - user.sendMessage("§cYou do not have permission to access that chest."); + user.sendMessage(Util.format("noAccessPermission", event.getClickedBlock().getType().toString().toLowerCase())); return; } } @@ -346,7 +345,7 @@ public class EssentialsPlayerListener extends PlayerListener try { user.setHome(); - user.sendMessage("§7Your home is now set to this bed."); + user.sendMessage(Util.i18n("homeSetToBed")); } catch (Throwable ex) { @@ -392,30 +391,30 @@ public class EssentialsPlayerListener extends PlayerListener int q1 = Integer.parseInt(m1 ? l1[0].substring(1) : l1[0]); if (q1 < 1) { - throw new Exception("Quantities must be greater than 0."); + throw new Exception(Util.i18n("moreThanZero")); } if (m1) { if (user.getMoney() < q1) { - throw new Exception("You do not have sufficient funds."); + throw new Exception(Util.i18n("notEnoughMoney")); } user.takeMoney(q1); - user.sendMessage("$" + q1 + " taken from your bank account."); + user.sendMessage(Util.format("moneyTaken", Util.formatCurrency(q1))); } else { ItemStack i = ItemDb.get(l1[1], q1); if (!InventoryWorkaround.containsItem(user.getInventory(), true, i)) { - throw new Exception("You do not have " + q1 + "x " + l1[1] + "."); + throw new Exception(Util.format("missingItems", q1, l1[1])); } InventoryWorkaround.removeItem(user.getInventory(), true, i); user.updateInventory(); } } user.setHealth(20); - user.sendMessage("§7You have been healed."); + user.sendMessage(Util.i18n("youAreHealed")); return; } if (sign.getLine(0).equals("§1[Mail]") && user.isAuthorized("essentials.signs.mail.use") && user.isAuthorized("essentials.mail")) @@ -423,19 +422,19 @@ public class EssentialsPlayerListener extends PlayerListener List mail = user.getMails(); if (mail.isEmpty()) { - user.sendMessage("§cYou do not have any mail!"); + user.sendMessage(Util.i18n("noNewMail")); return; } for (String s : mail) { user.sendMessage(s); } - user.sendMessage("§cTo mark your mail as read, type §c/mail clear"); + user.sendMessage(Util.i18n("markMailAsRead")); return; } if (sign.getLine(0).equals("§1[Balance]") && user.isAuthorized("essentials.signs.balance.use")) { - user.sendMessage("§7Balance: $" + user.getMoney()); + user.sendMessage(Util.format("balance", user.getMoney())); return; } if (sign.getLine(0).equals("§1[Warp]")) @@ -467,7 +466,7 @@ public class EssentialsPlayerListener extends PlayerListener } catch (Throwable ex) { - user.sendMessage("§cError: " + ex.getMessage()); + user.sendMessage(Util.format("errorWithMessage", ex.getMessage())); } } @@ -480,23 +479,23 @@ public class EssentialsPlayerListener extends PlayerListener int q1 = Integer.parseInt(m1 ? l1[0].substring(1) : l1[0]); if (q1 < 1) { - throw new Exception("Quantities must be greater than 0."); + throw new Exception(Util.i18n("moreThanZero")); } if (m1) { if (user.getMoney() < q1) { - throw new Exception("You do not have sufficient funds."); + throw new Exception(Util.i18n("notEnoughMoney")); } user.takeMoney(q1); - user.sendMessage("$" + q1 + " taken from your bank account."); + user.sendMessage(Util.format("moneyTaken", Util.formatCurrency(q1))); } else { ItemStack i = ItemDb.get(l1[1], q1); if (!InventoryWorkaround.containsItem(user.getInventory(), true, i)) { - throw new Exception("You do not have " + q1 + "x " + l1[1] + "."); + throw new Exception(Util.format("missingItems", q1, l1[1])); } InventoryWorkaround.removeItem(user.getInventory(), true, i); user.updateInventory(); diff --git a/Essentials/src/messages.properties b/Essentials/src/messages.properties index 9ac22f460..b5e8bbf63 100644 --- a/Essentials/src/messages.properties +++ b/Essentials/src/messages.properties @@ -25,6 +25,7 @@ bannedPlayersFileError = Error reading banned-players.txt bannedIpsFileNotFound = banned-ips.txt not found bannedIpsFileError = Error reading banned-ips.txt noDestroyPermission = \u00a7cYou do not have permission to destroy that {0}. +noAccessPermission = \u00a7cYou do not have permission to access that {0}. moreThanZero = Quantities must be greater than 0. errorWithMessage = \u00a7cError: {0} creatingConfigFromTemplate = Creating config from template: {0} @@ -35,12 +36,29 @@ failedToWriteConfig = Failed to write config {0} failedToCloseConfig = Failed to close config {0} notEnoughMoney = You do not have sufficient funds. missingItems = You do not have {0}x {1}. -errorWithMessage = \u00a7cError: {0} +tradeSignEmpty = The trade sign does not have enough supply left. +tradeCompleted = \u00a77Trade completed. +backAfterDeath = \u00a77Use the /back command to return to your death point. +mutedUserSpeaks = {0} tried to speak, but is muted. +userCreatedPortal = {0} used a portal and generated an exit portal. +generatingPortal = \u00a77Generating an exit portal. +userUsedPortal = {0} used an existing exit portal. +usingPortal = \u00a77Teleporting via portal to an existing portal. +teleportingPortal = \u00a77Teleporting via portal. +freedMemory = Freed {0} MB. +defaultBanReason = The Ban Hammer has spoken! +noNewMail = \u00a77You have no new mail. +serverFull = Server is full +returnPlayerToJailError = Error occured when trying to return player to jail. +jailMessage = \u00a7cYou do the crime, you do the time. +homeSetToBed = \u00a77Your home is now set to this bed. +moneyTaken = {0} taken from your bank account. +youAreHealed = \u00a77You have been healed. +markMailAsRead = \u00a7cTo mark your mail as read, type /mail clear +balance = \u00a77Balance: {0} backUsageMsg = \u00a77Returning to previous location. -balance = \u00a77Balance: {0}. -playerBanned = \u00a7cPlayer {0} banned. -defaultBanReason = Banned from server. -banIpAddress = \u00a77Banned IP address. +playerBanned = \u00a7cPlayer {0} banned +banIpAddress = \u00a77Banned IP address bigTreeSuccess = \u00a77Big tree spawned. bigTreeFailure = \u00a7cBig tree generation failure. Try again on grass or dirt. broadcast = [\u00a7cBroadcast\u00a7f]\u00a7a {0} @@ -55,4 +73,4 @@ depth = \u00a77You are at sea level. depthAboveSea = \u00a77You are {0} block(s) above sea level. depthBelowSea = \u00a77You are {0} block(s) below sea level. extinguish = \u00a77You extinguished yourself. -extinguishOthers = \u00a77 You extinguished {0}. \ No newline at end of file +extinguishOthers = \u00a77 You extinguished {0}.