Switch to the new I18n class and format cleanup of all classes

This commit is contained in:
snowleo 2011-11-21 02:55:26 +01:00
parent 19f5a2340d
commit 220d68f375
207 changed files with 1247 additions and 1306 deletions

View File

@ -29,7 +29,7 @@ auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.blank
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.blankLinesBeforeClass=2
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.classDeclBracePlacement=NEW_LINE
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.expand-tabs=false
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.importGroupsOrder=*;static *
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.importGroupsOrder=*
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.indent-shift-width=4
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.indentCasesFromSwitch=false
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.methodDeclBracePlacement=NEW_LINE
@ -38,7 +38,7 @@ auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.place
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.placeElseOnNewLine=true
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.placeFinallyOnNewLine=true
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.placeWhileOnNewLine=true
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.separateStaticImports=true
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.separateImportGroups=false
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceAfterTypeCast=false
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaces-per-tab=4
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.tab-size=4

View File

@ -31,7 +31,7 @@ public class AlternativeCommandsHandler
return;
}
final List<Command> commands = PluginCommandYamlParser.parse(plugin);
final String pluginName = plugin.getDescription().getName().toLowerCase();
final String pluginName = plugin.getDescription().getName().toLowerCase(Locale.ENGLISH);
for (Command command : commands)
{
@ -39,18 +39,18 @@ public class AlternativeCommandsHandler
final List<String> labels = new ArrayList<String>(pc.getAliases());
labels.add(pc.getName());
PluginCommand reg = ess.getServer().getPluginCommand(pluginName + ":" + pc.getName().toLowerCase());
PluginCommand reg = ess.getServer().getPluginCommand(pluginName + ":" + pc.getName().toLowerCase(Locale.ENGLISH));
if (reg == null)
{
reg = Bukkit.getServer().getPluginCommand(pc.getName().toLowerCase());
reg = Bukkit.getServer().getPluginCommand(pc.getName().toLowerCase(Locale.ENGLISH));
}
for (String label : labels)
{
List<PluginCommand> plugincommands = altcommands.get(label.toLowerCase());
List<PluginCommand> plugincommands = altcommands.get(label.toLowerCase(Locale.ENGLISH));
if (plugincommands == null)
{
plugincommands = new ArrayList<PluginCommand>();
altcommands.put(label.toLowerCase(), plugincommands);
altcommands.put(label.toLowerCase(Locale.ENGLISH), plugincommands);
}
boolean found = false;
for (PluginCommand pc2 : plugincommands)

View File

@ -1,5 +1,6 @@
package com.earth2me.essentials;
import static com.earth2me.essentials.I18n._;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
@ -60,7 +61,7 @@ public class Backup implements Runnable
{
return;
}
LOGGER.log(Level.INFO, Util.i18n("backupStarted"));
LOGGER.log(Level.INFO, _("backupStarted"));
final CommandSender cs = server.getConsoleSender();
server.dispatchCommand(cs, "save-all");
server.dispatchCommand(cs, "save-off");
@ -68,7 +69,7 @@ public class Backup implements Runnable
ess.scheduleAsyncDelayedTask(
new Runnable()
{
@Override
@Override
public void run()
{
try
@ -110,7 +111,7 @@ public class Backup implements Runnable
ess.scheduleSyncDelayedTask(
new Runnable()
{
@Override
@Override
public void run()
{
server.dispatchCommand(cs, "save-on");
@ -123,7 +124,7 @@ public class Backup implements Runnable
}
}
active = false;
LOGGER.log(Level.INFO, Util.i18n("backupFinished"));
LOGGER.log(Level.INFO, _("backupFinished"));
}
});
}

View File

@ -1,5 +1,6 @@
package com.earth2me.essentials;
import static com.earth2me.essentials.I18n._;
import java.text.SimpleDateFormat;
import java.util.*;
@ -71,7 +72,7 @@ public final class DescParseTickFormat
public static long parse(String desc) throws NumberFormatException
{
// Only look at alphanumeric and lowercase and : for 24:00
desc = desc.toLowerCase().replaceAll("[^A-Za-z0-9:]", "");
desc = desc.toLowerCase(Locale.ENGLISH).replaceAll("[^A-Za-z0-9:]", "");
// Detect ticks format
try
@ -132,7 +133,7 @@ public final class DescParseTickFormat
throw new NumberFormatException();
}
desc = desc.toLowerCase().replaceAll("[^0-9]", "");
desc = desc.toLowerCase(Locale.ENGLISH).replaceAll("[^0-9]", "");
if (desc.length() != 4)
{
@ -155,7 +156,7 @@ public final class DescParseTickFormat
int hours = 0;
int minutes = 0;
desc = desc.toLowerCase().replaceAll("[^0-9]", "");
desc = desc.toLowerCase(Locale.ENGLISH).replaceAll("[^0-9]", "");
if (desc.length() > 4)
{
@ -184,12 +185,12 @@ public final class DescParseTickFormat
{
throw new NumberFormatException();
}
if (desc.endsWith("pm") && hours != 12)
{
hours += 12;
}
if (desc.endsWith("am") && hours == 12)
{
hours -= 12;
@ -230,7 +231,7 @@ public final class DescParseTickFormat
// --------------------------------------------
public static String format(final long ticks)
{
return Util.format("timeFormat", format24(ticks), format12(ticks), formatTicks(ticks));
return _("timeFormat", format24(ticks), format12(ticks), formatTicks(ticks));
}
public static String formatTicks(final long ticks)

View File

@ -1,22 +1,23 @@
/*
* Essentials - a bukkit plugin
* Copyright (C) 2011 Essentials Team
*
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.earth2me.essentials;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.api.Economy;
import com.earth2me.essentials.commands.EssentialsCommand;
import com.earth2me.essentials.commands.IEssentialsCommand;
@ -71,6 +72,7 @@ public class Essentials extends JavaPlugin implements IEssentials
private transient AlternativeCommandsHandler alternativeCommandsHandler;
private transient UserMap userMap;
private transient ExecuteTimer execTimer;
private transient I18n i18n;
@Override
public ISettings getSettings()
@ -89,10 +91,13 @@ public class Essentials extends JavaPlugin implements IEssentials
{
throw new IOException();
}
LOGGER.log(Level.INFO, Util.i18n("usingTempFolderForTesting"));
i18n = new I18n(this);
i18n.onEnable();
LOGGER.log(Level.INFO, _("usingTempFolderForTesting"));
LOGGER.log(Level.INFO, dataFolder.toString());
this.initialize(null, server, new PluginDescriptionFile(new FileReader(new File("src" + File.separator + "plugin.yml"))), dataFolder, null, null);
settings = new Settings(this);
i18n.updateLocale("en");
userMap = new UserMap(this);
permissionsHandler = new PermissionsHandler(this, false);
Economy.setEss(this);
@ -103,6 +108,9 @@ public class Essentials extends JavaPlugin implements IEssentials
{
execTimer = new ExecuteTimer();
execTimer.start();
i18n = new I18n(this);
i18n.onEnable();
execTimer.mark("I18n1");
final EssentialsUpgrade upgrade = new EssentialsUpgrade(this);
upgrade.beforeSettings();
execTimer.mark("Upgrade");
@ -112,7 +120,7 @@ public class Essentials extends JavaPlugin implements IEssentials
execTimer.mark("Settings");
upgrade.afterSettings();
execTimer.mark("Upgrade2");
Util.updateLocale(settings.getLocale(), this);
i18n.updateLocale(settings.getLocale());
userMap = new UserMap(this);
confList.add(userMap);
execTimer.mark("Init(Usermap)");
@ -135,7 +143,7 @@ public class Essentials extends JavaPlugin implements IEssentials
if (plugin.getDescription().getName().startsWith("Essentials")
&& !plugin.getDescription().getVersion().equals(this.getDescription().getVersion()))
{
LOGGER.log(Level.WARNING, Util.format("versionMismatch", plugin.getDescription().getName()));
LOGGER.log(Level.WARNING, _("versionMismatch", plugin.getDescription().getName()));
}
}
final Matcher versionMatch = Pattern.compile("git-Bukkit-([0-9]+).([0-9]+).([0-9]+)-R[0-9]+-[0-9]+-[0-9a-z]+-b([0-9]+)jnks.*").matcher(getServer().getVersion());
@ -144,12 +152,12 @@ public class Essentials extends JavaPlugin implements IEssentials
final int versionNumber = Integer.parseInt(versionMatch.group(4));
if (versionNumber < BUKKIT_VERSION)
{
LOGGER.log(Level.WARNING, Util.i18n("notRecommendedBukkit"));
LOGGER.log(Level.WARNING, _("notRecommendedBukkit"));
}
}
else
{
LOGGER.log(Level.INFO, Util.i18n("bukkitFormatChanged"));
LOGGER.log(Level.INFO, _("bukkitFormatChanged"));
LOGGER.log(Level.INFO, getServer().getVersion());
LOGGER.log(Level.INFO, getServer().getBukkitVersion());
}
@ -218,7 +226,7 @@ public class Essentials extends JavaPlugin implements IEssentials
getScheduler().scheduleSyncRepeatingTask(this, timer, 1, 100);
Economy.setEss(this);
execTimer.mark("RegListeners");
LOGGER.info(Util.format("loadinfo", this.getDescription().getName(), this.getDescription().getVersion(), Util.joinList(this.getDescription().getAuthors())));
LOGGER.info(_("loadinfo", this.getDescription().getName(), this.getDescription().getVersion(), Util.joinList(this.getDescription().getAuthors())));
final String timeroutput = execTimer.end();
if (getSettings().isDebug())
{
@ -229,6 +237,7 @@ public class Essentials extends JavaPlugin implements IEssentials
@Override
public void onDisable()
{
i18n.onDisable();
Economy.setEss(null);
Trade.closeLog();
}
@ -244,7 +253,7 @@ public class Essentials extends JavaPlugin implements IEssentials
execTimer.mark("Reload(" + iConf.getClass().getSimpleName() + ")");
}
Util.updateLocale(settings.getLocale(), this);
i18n.updateLocale(settings.getLocale());
}
@Override
@ -282,7 +291,7 @@ public class Essentials extends JavaPlugin implements IEssentials
final List<String> mail = user.getMails();
if (mail != null && !mail.isEmpty())
{
user.sendMessage(Util.format("youHaveNewMail", mail.size()));
user.sendMessage(_("youHaveNewMail", mail.size()));
}
}
@ -300,16 +309,16 @@ public class Essentials extends JavaPlugin implements IEssentials
}
catch (Exception ex)
{
sender.sendMessage(Util.format("commandNotLoaded", commandLabel));
LOGGER.log(Level.SEVERE, Util.format("commandNotLoaded", commandLabel), ex);
sender.sendMessage(_("commandNotLoaded", commandLabel));
LOGGER.log(Level.SEVERE, _("commandNotLoaded", commandLabel), ex);
return true;
}
// Check authorization
if (user != null && !user.isAuthorized(cmd, permissionPrefix))
{
LOGGER.log(Level.WARNING, Util.format("deniedAccessCommand", user.getName()));
user.sendMessage(Util.i18n("noAccessCommand"));
LOGGER.log(Level.WARNING, _("deniedAccessCommand", user.getName()));
user.sendMessage(_("noAccessCommand"));
return true;
}
@ -344,7 +353,7 @@ public class Essentials extends JavaPlugin implements IEssentials
}
catch (Throwable ex)
{
LOGGER.log(Level.SEVERE, Util.format("commandFailed", commandLabel), ex);
LOGGER.log(Level.SEVERE, _("commandFailed", commandLabel), ex);
return true;
}
}
@ -352,8 +361,8 @@ public class Essentials extends JavaPlugin implements IEssentials
@Override
public void showError(final CommandSender sender, final Throwable exception, final String commandLabel)
{
sender.sendMessage(Util.format("errorWithMessage", exception.getMessage()));
final LogRecord logRecord = new LogRecord(Level.WARNING, Util.format("errorCallingCommand", commandLabel));
sender.sendMessage(_("errorWithMessage", exception.getMessage()));
final LogRecord logRecord = new LogRecord(Level.WARNING, _("errorCallingCommand", commandLabel));
logRecord.setThrown(exception);
if (getSettings().isDebug())
{

View File

@ -1,5 +1,6 @@
package com.earth2me.essentials;
import static com.earth2me.essentials.I18n._;
import java.io.*;
import java.util.HashMap;
import java.util.Map;
@ -38,7 +39,7 @@ public class EssentialsConf extends Configuration
{
if (!configFile.getParentFile().mkdirs())
{
LOGGER.log(Level.SEVERE, Util.format("failedToCreateConfig", configFile.toString()));
LOGGER.log(Level.SEVERE, _("failedToCreateConfig", configFile.toString()));
}
}
// This will delete files where the first character is 0. In most cases they are broken.
@ -81,22 +82,22 @@ public class EssentialsConf extends Configuration
{
if (templateName != null)
{
LOGGER.log(Level.INFO, Util.format("creatingConfigFromTemplate", configFile.toString()));
LOGGER.log(Level.INFO, _("creatingConfigFromTemplate", configFile.toString()));
createFromTemplate();
}
else
{
try
{
LOGGER.log(Level.INFO, Util.format("creatingEmptyConfig", configFile.toString()));
LOGGER.log(Level.INFO, _("creatingEmptyConfig", configFile.toString()));
if (!configFile.createNewFile())
{
LOGGER.log(Level.SEVERE, Util.format("failedToCreateConfig", configFile.toString()));
LOGGER.log(Level.SEVERE, _("failedToCreateConfig", configFile.toString()));
}
}
catch (IOException ex)
{
LOGGER.log(Level.SEVERE, Util.format("failedToCreateConfig", configFile.toString()), ex);
LOGGER.log(Level.SEVERE, _("failedToCreateConfig", configFile.toString()), ex);
}
}
}
@ -126,7 +127,7 @@ public class EssentialsConf extends Configuration
istr = resourceClass.getResourceAsStream(templateName);
if (istr == null)
{
LOGGER.log(Level.SEVERE, Util.format("couldNotFindTemplate", templateName));
LOGGER.log(Level.SEVERE, _("couldNotFindTemplate", templateName));
return;
}
ostr = new FileOutputStream(configFile);
@ -141,7 +142,7 @@ public class EssentialsConf extends Configuration
}
catch (IOException ex)
{
LOGGER.log(Level.SEVERE, Util.format("failedToWriteConfig", configFile.toString()), ex);
LOGGER.log(Level.SEVERE, _("failedToWriteConfig", configFile.toString()), ex);
}
finally
{
@ -165,7 +166,7 @@ public class EssentialsConf extends Configuration
}
catch (IOException ex)
{
LOGGER.log(Level.SEVERE, Util.format("failedToCloseConfig", configFile.toString()), ex);
LOGGER.log(Level.SEVERE, _("failedToCloseConfig", configFile.toString()), ex);
}
}
}
@ -201,7 +202,7 @@ public class EssentialsConf extends Configuration
final World world = server.getWorld(worldName);
if (world == null)
{
throw new Exception(Util.i18n("invalidWorld"));
throw new Exception(_("invalidWorld"));
}
return new Location(world,
getDouble((path == null ? "" : path + ".") + "x", 0),
@ -226,8 +227,10 @@ public class EssentialsConf extends Configuration
return new ItemStack(
Material.valueOf(getString(path + ".type", "AIR")),
getInt(path + ".amount", 1),
(short)getInt(path + ".damage", 0)/*,
(byte)getInt(path + ".data", 0)*/);
(short)getInt(path + ".damage", 0)/*
* ,
* (byte)getInt(path + ".data", 0)
*/);
}
public void setProperty(final String path, final ItemStack stack)

View File

@ -1,5 +1,6 @@
package com.earth2me.essentials;
import static com.earth2me.essentials.I18n._;
import java.util.List;
import java.util.logging.Logger;
import org.bukkit.entity.Entity;
@ -77,7 +78,7 @@ public class EssentialsEntityListener extends EntityListener
if (user.isAuthorized("essentials.back.ondeath") && !ess.getSettings().isCommandDisabled("back"))
{
user.setLastLocation();
user.sendMessage(Util.i18n("backAfterDeath"));
user.sendMessage(_("backAfterDeath"));
}
if (!ess.getSettings().areDeathMessagesEnabled())
{

View File

@ -1,5 +1,6 @@
package com.earth2me.essentials;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.textreader.IText;
import com.earth2me.essentials.textreader.KeywordReplacer;
import com.earth2me.essentials.textreader.TextInput;
@ -8,6 +9,7 @@ import java.io.IOException;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.bukkit.Location;
@ -50,8 +52,8 @@ public class EssentialsPlayerListener extends PlayerListener
if (user.isMuted())
{
event.setCancelled(true);
user.sendMessage(Util.i18n("playerMuted"));
LOGGER.info(Util.format("mutedUserSpeaks", user.getName()));
user.sendMessage(_("playerMuted"));
LOGGER.info(_("mutedUserSpeaks", user.getName()));
}
final Iterator<Player> it = event.getRecipients().iterator();
while (it.hasNext())
@ -136,7 +138,7 @@ public class EssentialsPlayerListener extends PlayerListener
rt.gc();
mem = rt.freeMemory() - mem;
mem /= 1024 * 1024;
LOGGER.log(Level.INFO, Util.format("freedMemory", mem));
LOGGER.log(Level.INFO, _("freedMemory", mem));
}
catch (InterruptedException ex)
{
@ -184,11 +186,11 @@ public class EssentialsPlayerListener extends PlayerListener
final List<String> mail = user.getMails();
if (mail.isEmpty())
{
user.sendMessage(Util.i18n("noNewMail"));
user.sendMessage(_("noNewMail"));
}
else
{
user.sendMessage(Util.format("youHaveNewMail", mail.size()));
user.sendMessage(_("youHaveNewMail", mail.size()));
}
}
}
@ -212,13 +214,13 @@ public class EssentialsPlayerListener extends PlayerListener
if (banExpired == false && (user.isBanned() || event.getResult() == Result.KICK_BANNED))
{
final String banReason = user.getBanReason();
event.disallow(Result.KICK_BANNED, banReason != null && !banReason.isEmpty() && !banReason.equalsIgnoreCase("ban") ? banReason : Util.i18n("defaultBanReason"));
event.disallow(Result.KICK_BANNED, banReason != null && !banReason.isEmpty() && !banReason.equalsIgnoreCase("ban") ? banReason : _("defaultBanReason"));
return;
}
if (server.getOnlinePlayers().length >= server.getMaxPlayers() && !user.isAuthorized("essentials.joinfullserver"))
{
event.disallow(Result.KICK_FULL, Util.i18n("serverFull"));
event.disallow(Result.KICK_FULL, _("serverFull"));
return;
}
event.allow();
@ -271,7 +273,7 @@ public class EssentialsPlayerListener extends PlayerListener
{
final User user = ess.getUser(event.getPlayer());
user.setHome();
user.sendMessage(Util.i18n("homeSetToBed"));
user.sendMessage(_("homeSetToBed"));
}
catch (Throwable ex)
{
@ -365,7 +367,7 @@ public class EssentialsPlayerListener extends PlayerListener
return;
}
final User user = ess.getUser(event.getPlayer());
final String cmd = event.getMessage().toLowerCase().split(" ")[0].replace("/", "").toLowerCase();
final String cmd = event.getMessage().toLowerCase(Locale.ENGLISH).split(" ")[0].replace("/", "").toLowerCase(Locale.ENGLISH);
final List<String> commands = Arrays.asList("msg", "r", "mail", "m", "t", "emsg", "tell", "er", "reply", "ereply", "email");
if (commands.contains(cmd))
{

View File

@ -1,5 +1,6 @@
package com.earth2me.essentials;
import static com.earth2me.essentials.I18n._;
import java.io.*;
import java.math.BigInteger;
import java.security.DigestInputStream;
@ -67,19 +68,19 @@ public class EssentialsUpgrade
}
catch (Throwable e)
{
LOGGER.log(Level.SEVERE, Util.i18n("upgradingFilesError"), e);
LOGGER.log(Level.SEVERE, _("upgradingFilesError"), e);
}
}
private void moveMotdRulesToFile(String name)
{
if (doneFile.getBoolean("move"+name+"ToFile", false))
if (doneFile.getBoolean("move" + name + "ToFile", false))
{
return;
}
try
{
final File file = new File(ess.getDataFolder(), name+".txt");
final File file = new File(ess.getDataFolder(), name + ".txt");
if (file.exists())
{
return;
@ -106,12 +107,12 @@ public class EssentialsUpgrade
}
writer.close();
}
doneFile.setProperty("move"+name+"ToFile", true);
doneFile.setProperty("move" + name + "ToFile", true);
doneFile.save();
}
catch (Throwable e)
{
LOGGER.log(Level.SEVERE, Util.i18n("upgradingFilesError"), e);
LOGGER.log(Level.SEVERE, _("upgradingFilesError"), e);
}
}
@ -161,11 +162,11 @@ public class EssentialsUpgrade
{
if (!file.renameTo(new File(file.getParentFile(), file.getName().concat("." + System.currentTimeMillis() + ".upgradebackup"))))
{
throw new Exception(Util.i18n("configFileMoveError"));
throw new Exception(_("configFileMoveError"));
}
if (!tempFile.renameTo(file))
{
throw new Exception(Util.i18n("configFileRenameError"));
throw new Exception(_("configFileRenameError"));
}
}
else
@ -220,7 +221,7 @@ public class EssentialsUpgrade
((Number)vals.get(3)).floatValue(),
((Number)vals.get(4)).floatValue());
final String worldName = world.getName().toLowerCase();
final String worldName = world.getName().toLowerCase(Locale.ENGLISH);
if (worldName != null && !worldName.isEmpty())
{
config.removeProperty("home");
@ -347,7 +348,7 @@ public class EssentialsUpgrade
{
continue;
}
worldName = loc.getWorld().getName().toLowerCase();
worldName = loc.getWorld().getName().toLowerCase(Locale.ENGLISH);
if (worldName != null && !worldName.isEmpty())
{
config.setProperty("homes." + worldName, loc);
@ -493,7 +494,7 @@ public class EssentialsUpgrade
ess.getWarps().setWarp(filename.substring(0, filename.length() - 4), loc);
if (!listOfFiles[i].renameTo(new File(warpsFolder, filename + ".old")))
{
throw new Exception(Util.format("fileRenameError", filename));
throw new Exception(_("fileRenameError", filename));
}
}
catch (Exception ex)
@ -541,7 +542,7 @@ public class EssentialsUpgrade
ess.getWarps().setWarp(name, loc);
if (!warpFile.renameTo(new File(ess.getDataFolder(), "warps.txt.old")))
{
throw new Exception(Util.format("fileRenameError", "warps.txt"));
throw new Exception(_("fileRenameError", "warps.txt"));
}
}
}
@ -585,17 +586,17 @@ public class EssentialsUpgrade
final File newFile = new File(listOfFiles[i].getParentFile(), sanitizedFilename);
if (!listOfFiles[i].renameTo(tmpFile))
{
LOGGER.log(Level.WARNING, Util.format("userdataMoveError", filename, sanitizedFilename));
LOGGER.log(Level.WARNING, _("userdataMoveError", filename, sanitizedFilename));
continue;
}
if (newFile.exists())
{
LOGGER.log(Level.WARNING, Util.format("duplicatedUserdata", filename, sanitizedFilename));
LOGGER.log(Level.WARNING, _("duplicatedUserdata", filename, sanitizedFilename));
continue;
}
if (!tmpFile.renameTo(newFile))
{
LOGGER.log(Level.WARNING, Util.format("userdataMoveBackError", sanitizedFilename, sanitizedFilename));
LOGGER.log(Level.WARNING, _("userdataMoveBackError", sanitizedFilename, sanitizedFilename));
}
}
doneFile.setProperty("sanitizeAllUserFilenames", true);

View File

@ -18,16 +18,30 @@ public class I18n
private static final String MESSAGES = "messages";
private final transient Locale defaultLocale = Locale.getDefault();
private transient Locale currentLocale = defaultLocale;
private transient ResourceBundle customBundle = ResourceBundle.getBundle(MESSAGES, defaultLocale);
private transient ResourceBundle localeBundle = ResourceBundle.getBundle(MESSAGES, defaultLocale);
private final transient ResourceBundle defaultBundle = ResourceBundle.getBundle(MESSAGES, Locale.ENGLISH);
private transient ResourceBundle customBundle;
private transient ResourceBundle localeBundle;
private final transient ResourceBundle defaultBundle;
private final transient Map<String, MessageFormat> messageFormatCache = new HashMap<String, MessageFormat>();
private final transient IEssentials ess;
public I18n()
public I18n(final IEssentials ess)
{
this.ess = ess;
customBundle = ResourceBundle.getBundle(MESSAGES, defaultLocale);
localeBundle = ResourceBundle.getBundle(MESSAGES, defaultLocale);
defaultBundle = ResourceBundle.getBundle(MESSAGES, Locale.ENGLISH);
}
public void onEnable()
{
instance = this;
}
public void onDisable()
{
instance = null;
}
public Locale getCurrentLocale()
{
return currentLocale;
@ -77,7 +91,7 @@ public class I18n
return messageFormat.format(objects);
}
public void updateLocale(final String loc, final IEssentials ess)
public void updateLocale(final String loc)
{
if (loc == null || loc.isEmpty())
{
@ -101,14 +115,9 @@ public class I18n
localeBundle = ResourceBundle.getBundle(MESSAGES, currentLocale);
}
public static String lowerCase(final String input)
{
return input == null ? null : input.toLowerCase(Locale.ENGLISH);
}
public static String capitalCase(final String input)
{
return input == null || input.length() == 0
return input == null || input.length() == 0
? input
: input.toUpperCase(Locale.ENGLISH).charAt(0)
+ input.toLowerCase(Locale.ENGLISH).substring(1);

View File

@ -1,7 +1,9 @@
package com.earth2me.essentials;
import static com.earth2me.essentials.I18n._;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
@ -24,8 +26,9 @@ public class ItemDb implements IConf
public void reloadConfig()
{
final List<String> lines = file.getLines();
if (lines.isEmpty()) {
if (lines.isEmpty())
{
return;
}
@ -34,7 +37,7 @@ public class ItemDb implements IConf
for (String line : lines)
{
line = line.trim().toLowerCase();
line = line.trim().toLowerCase(Locale.ENGLISH);
if (line.length() > 0 && line.charAt(0) == '#')
{
continue;
@ -48,14 +51,14 @@ public class ItemDb implements IConf
final int numeric = Integer.parseInt(parts[1]);
durabilities.put(parts[0].toLowerCase(), parts.length > 2 && !parts[2].equals("0") ? Short.parseShort(parts[2]) : 0);
items.put(parts[0].toLowerCase(), numeric);
durabilities.put(parts[0].toLowerCase(Locale.ENGLISH), parts.length > 2 && !parts[2].equals("0") ? Short.parseShort(parts[2]) : 0);
items.put(parts[0].toLowerCase(Locale.ENGLISH), numeric);
}
}
public ItemStack get(final String id, final int quantity) throws Exception
{
final ItemStack retval = get(id.toLowerCase());
final ItemStack retval = get(id.toLowerCase(Locale.ENGLISH));
retval.setAmount(quantity);
return retval;
}
@ -76,12 +79,12 @@ public class ItemDb implements IConf
}
else if (id.matches("^[^:+',;.]+[:+',;.]\\d+$"))
{
itemname = id.split("[:+',;.]")[0].toLowerCase();
itemname = id.split("[:+',;.]")[0].toLowerCase(Locale.ENGLISH);
metaData = Short.parseShort(id.split("[:+',;.]")[1]);
}
else
{
itemname = id.toLowerCase();
itemname = id.toLowerCase(Locale.ENGLISH);
}
if (itemname != null)
@ -101,14 +104,14 @@ public class ItemDb implements IConf
}
else
{
throw new Exception(Util.format("unknownItemName", id));
throw new Exception(_("unknownItemName", id));
}
}
final Material mat = Material.getMaterial(itemid);
if (mat == null)
{
throw new Exception(Util.format("unknownItemId", itemid));
throw new Exception(_("unknownItemId", itemid));
}
final ItemStack retval = new ItemStack(mat);
retval.setAmount(ess.getSettings().getDefaultStackSize());

View File

@ -1,7 +1,9 @@
package com.earth2me.essentials;
import static com.earth2me.essentials.I18n._;
import java.io.File;
import java.util.List;
import java.util.Locale;
import java.util.logging.Logger;
import org.bukkit.Location;
import org.bukkit.event.block.BlockBreakEvent;
@ -25,18 +27,18 @@ public class Jail extends BlockListener implements IConf
public void setJail(Location loc, String jailName) throws Exception
{
config.setProperty(jailName.toLowerCase(), loc);
config.setProperty(jailName.toLowerCase(Locale.ENGLISH), loc);
config.save();
}
public Location getJail(String jailName) throws Exception
{
if (jailName == null || config.getProperty(jailName.toLowerCase()) == null)
if (jailName == null || config.getProperty(jailName.toLowerCase(Locale.ENGLISH)) == null)
{
throw new Exception(Util.i18n("jailNotExist"));
throw new Exception(_("jailNotExist"));
}
Location loc = config.getLocation(jailName.toLowerCase(), ess.getServer());
Location loc = config.getLocation(jailName.toLowerCase(Locale.ENGLISH), ess.getServer());
return loc;
}
@ -51,7 +53,7 @@ public class Jail extends BlockListener implements IConf
public void delJail(String jail) throws Exception
{
config.removeProperty(jail.toLowerCase());
config.removeProperty(jail.toLowerCase(Locale.ENGLISH));
config.save();
}

View File

@ -1,5 +1,6 @@
package com.earth2me.essentials;
import static com.earth2me.essentials.I18n._;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.bukkit.event.player.*;
@ -55,9 +56,9 @@ public class JailPlayerListener extends PlayerListener
}
catch (Exception ex)
{
LOGGER.log(Level.WARNING, Util.i18n("returnPlayerToJailError"), ex);
LOGGER.log(Level.WARNING, _("returnPlayerToJailError"), ex);
}
user.sendMessage(Util.i18n("jailMessage"));
user.sendMessage(_("jailMessage"));
}
@Override
@ -72,9 +73,9 @@ public class JailPlayerListener extends PlayerListener
}
catch (Exception ex)
{
LOGGER.log(Level.WARNING, Util.i18n("returnPlayerToJailError"), ex);
LOGGER.log(Level.WARNING, _("returnPlayerToJailError"), ex);
}
u.sendMessage(Util.i18n("jailMessage"));
u.sendMessage(_("jailMessage"));
}
}
}

View File

@ -1,5 +1,6 @@
package com.earth2me.essentials;
import static com.earth2me.essentials.I18n._;
import java.io.*;
import java.math.BigInteger;
import java.security.DigestInputStream;
@ -45,7 +46,7 @@ public class ManagedFile
}
catch (IOException ex)
{
Bukkit.getLogger().log(Level.SEVERE, Util.i18n("itemsCsvNotLoaded"), ex);
Bukkit.getLogger().log(Level.SEVERE, _("itemsCsvNotLoaded"), ex);
}
}
}

View File

@ -1,6 +1,8 @@
package com.earth2me.essentials;
import static com.earth2me.essentials.I18n._;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
@ -61,7 +63,7 @@ public enum Mob
{
for (Mob mob : Mob.values())
{
hashMap.put(mob.name.toLowerCase(), mob);
hashMap.put(mob.name.toLowerCase(Locale.ENGLISH), mob);
}
}
@ -71,7 +73,7 @@ public enum Mob
final LivingEntity entity = player.getWorld().spawnCreature(loc, this.bukkitType);
if (entity == null)
{
logger.log(Level.WARNING, Util.i18n("unableToSpawnMob"));
logger.log(Level.WARNING, _("unableToSpawnMob"));
throw new MobException();
}
return entity;
@ -98,7 +100,7 @@ public enum Mob
public static Mob fromName(final String name)
{
return hashMap.get(name.toLowerCase());
return hashMap.get(name.toLowerCase(Locale.ENGLISH));
}

View File

@ -1,9 +1,9 @@
package com.earth2me.essentials;
import static com.earth2me.essentials.I18n._;
import java.net.InetSocketAddress;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import lombok.Delegate;
@ -27,7 +27,7 @@ public class OfflinePlayer implements Player
private Location location = new Location(null, 0, 0, 0, 0, 0);
private World world;
private UUID uniqueId = UUID.randomUUID();
@Delegate(types=org.bukkit.OfflinePlayer.class)
@Delegate(types = org.bukkit.OfflinePlayer.class)
private final org.bukkit.OfflinePlayer base;
public OfflinePlayer(final String name, final IEssentials ess)
@ -179,25 +179,25 @@ public class OfflinePlayer implements Player
@Override
public int getRemainingAir()
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
@Override
public void setRemainingAir(int i)
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
@Override
public int getMaximumAir()
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
@Override
public void setMaximumAir(int i)
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
@Override
@ -209,73 +209,73 @@ public class OfflinePlayer implements Player
@Override
public void setSneaking(boolean bln)
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
@Override
public void updateInventory()
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
@Override
public void chat(String string)
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
@Override
public double getEyeHeight()
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
@Override
public double getEyeHeight(boolean bln)
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
@Override
public List<Block> getLineOfSight(HashSet<Byte> hs, int i)
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
@Override
public Block getTargetBlock(HashSet<Byte> hs, int i)
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
@Override
public List<Block> getLastTwoTargetBlocks(HashSet<Byte> hs, int i)
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
@Override
public int getFireTicks()
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
@Override
public int getMaxFireTicks()
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
@Override
public void setFireTicks(int i)
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
@Override
public void remove()
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
@Override
@ -286,252 +286,252 @@ public class OfflinePlayer implements Player
public Vector getMomentum()
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
public void setMomentum(Vector vector)
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
@Override
public void setVelocity(Vector vector)
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
@Override
public Vector getVelocity()
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
@Override
public void damage(int i)
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
@Override
public void damage(int i, Entity entity)
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
@Override
public Location getEyeLocation()
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
@Override
public void sendRawMessage(String string)
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
@Override
public Location getCompassTarget()
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
@Override
public int getMaximumNoDamageTicks()
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
@Override
public void setMaximumNoDamageTicks(int i)
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
@Override
public int getLastDamage()
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
@Override
public void setLastDamage(int i)
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
@Override
public int getNoDamageTicks()
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
@Override
public void setNoDamageTicks(int i)
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
@Override
public boolean teleport(Location lctn)
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
@Override
public boolean teleport(Entity entity)
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
@Override
public Entity getPassenger()
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
@Override
public boolean setPassenger(Entity entity)
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
@Override
public boolean isEmpty()
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
@Override
public boolean eject()
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
@Override
public void saveData()
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
@Override
public void loadData()
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
@Override
public boolean isSleeping()
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
@Override
public int getSleepTicks()
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
@Override
public List<Entity> getNearbyEntities(double d, double d1, double d2)
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
@Override
public boolean isDead()
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
@Override
public float getFallDistance()
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
@Override
public void setFallDistance(float f)
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
@Override
public void setSleepingIgnored(boolean bln)
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
@Override
public boolean isSleepingIgnored()
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
@Override
public void awardAchievement(Achievement a)
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
@Override
public void incrementStatistic(Statistic ststc)
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
@Override
public void incrementStatistic(Statistic ststc, int i)
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
@Override
public void incrementStatistic(Statistic ststc, Material mtrl)
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
@Override
public void incrementStatistic(Statistic ststc, Material mtrl, int i)
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
@Override
public void playNote(Location lctn, byte b, byte b1)
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
@Override
public void sendBlockChange(Location lctn, Material mtrl, byte b)
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
@Override
public void sendBlockChange(Location lctn, int i, byte b)
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
@Override
public void setLastDamageCause(EntityDamageEvent ede)
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
@Override
public EntityDamageEvent getLastDamageCause()
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
@Override
public void playEffect(Location lctn, Effect effect, int i)
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
@Override
@ -646,7 +646,7 @@ public class OfflinePlayer implements Player
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void sendMap(MapView mv)
{

View File

@ -1,9 +1,11 @@
package com.earth2me.essentials;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.commands.IEssentialsCommand;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
@ -111,7 +113,7 @@ public class Settings implements ISettings
}
return true;
}
return config.getBoolean("disable-" + label.toLowerCase(), false);
return config.getBoolean("disable-" + label.toLowerCase(Locale.ENGLISH), false);
}
@Override
@ -131,7 +133,7 @@ public class Settings implements ISettings
}
return true;
}
return config.getBoolean("restrict-" + label.toLowerCase(), false);
return config.getBoolean("restrict-" + label.toLowerCase(Locale.ENGLISH), false);
}
@Override
@ -161,7 +163,7 @@ public class Settings implements ISettings
}
return true;
}
return config.getBoolean("override-" + name.toLowerCase(), false);
return config.getBoolean("override-" + name.toLowerCase(Locale.ENGLISH), false);
}
@Override
@ -360,7 +362,7 @@ public class Settings implements ISettings
}
catch (Exception ex)
{
logger.log(Level.SEVERE, Util.format("unknownItemInList", itemName, "item-spawn-blacklist"));
logger.log(Level.SEVERE, _("unknownItemInList", itemName, "item-spawn-blacklist"));
}
}
return epItemSpwn;
@ -377,9 +379,8 @@ public class Settings implements ISettings
{
return config.getBoolean("protect.disable.warn-on-build-disallow", false);
}
private boolean debug = false;
@Override
public boolean isDebug()
{
@ -447,7 +448,7 @@ public class Settings implements ISettings
}
catch (Exception ex)
{
logger.log(Level.SEVERE, Util.format("unknownItemInList", itemName, configName));
logger.log(Level.SEVERE, _("unknownItemInList", itemName, configName));
}
}
return list;
@ -506,13 +507,13 @@ public class Settings implements ISettings
{
return config.getBoolean("add-prefix-suffix", ess.getServer().getPluginManager().isPluginEnabled("EssentialsChat"));
}
@Override
public boolean disablePrefix()
{
return config.getBoolean("disablePrefix", false);
}
@Override
public boolean disableSuffix()
{

View File

@ -1,5 +1,6 @@
package com.earth2me.essentials;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.commands.NotEnoughArgumentsException;
import java.util.Calendar;
import java.util.GregorianCalendar;
@ -93,7 +94,7 @@ public class Teleport implements Runnable
try
{
cooldown(false);
user.sendMessage(Util.i18n("teleportationCommencing"));
user.sendMessage(_("teleportationCommencing"));
try
{
@ -110,7 +111,7 @@ public class Teleport implements Runnable
}
catch (Exception ex)
{
user.sendMessage(Util.format("cooldownWithMessage", ex.getMessage()));
user.sendMessage(_("cooldownWithMessage", ex.getMessage()));
}
}
}
@ -130,7 +131,7 @@ public class Teleport implements Runnable
{
Location loc = ess.getWarps().getWarp(warp);
teleport(new Target(loc), chargeFor);
user.sendMessage(Util.format("warpingTo", warp));
user.sendMessage(_("warpingTo", warp));
}
public void cooldown(boolean check) throws Exception
@ -145,7 +146,7 @@ public class Teleport implements Runnable
cooldownTime.add(Calendar.MILLISECOND, (int)((cooldown * 1000.0) % 1000.0));
if (cooldownTime.after(now) && !user.isAuthorized("essentials.teleport.cooldown.bypass"))
{
throw new Exception(Util.format("timeBeforeTeleport", Util.formatDateDiff(cooldownTime.getTimeInMillis())));
throw new Exception(_("timeBeforeTeleport", Util.formatDateDiff(cooldownTime.getTimeInMillis())));
}
}
// if justCheck is set, don't update lastTeleport; we're just checking
@ -166,7 +167,7 @@ public class Teleport implements Runnable
ess.getServer().getScheduler().cancelTask(teleTimer);
if (notifyUser)
{
user.sendMessage(Util.i18n("pendingTeleportCancelled"));
user.sendMessage(_("pendingTeleportCancelled"));
}
}
finally
@ -214,7 +215,7 @@ public class Teleport implements Runnable
Calendar c = new GregorianCalendar();
c.add(Calendar.SECOND, (int)delay);
c.add(Calendar.MILLISECOND, (int)((delay * 1000.0) % 1000.0));
user.sendMessage(Util.format("dontMoveMessage", Util.formatDateDiff(c.getTimeInMillis())));
user.sendMessage(_("dontMoveMessage", Util.formatDateDiff(c.getTimeInMillis())));
initTimer((long)(delay * 1000.0), target, chargeFor);
teleTimer = ess.scheduleSyncRepeatingTask(this, 10, 10);

View File

@ -1,10 +1,12 @@
package com.earth2me.essentials;
import static com.earth2me.essentials.I18n._;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.text.DateFormat;
import java.util.Date;
import java.util.Locale;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
@ -50,13 +52,13 @@ public class Trade
&& getMoney() > 0
&& !user.isAuthorized("essentials.eco.loan"))
{
throw new ChargeException(Util.i18n("notEnoughMoney"));
throw new ChargeException(_("notEnoughMoney"));
}
if (getItemStack() != null
&& !InventoryWorkaround.containsItem(user.getInventory(), true, itemStack))
{
throw new ChargeException(Util.format("missingItems", getItemStack().getAmount(), getItemStack().getType().toString().toLowerCase().replace("_", " ")));
throw new ChargeException(_("missingItems", getItemStack().getAmount(), getItemStack().getType().toString().toLowerCase(Locale.ENGLISH).replace("_", " ")));
}
if (command != null && !command.isEmpty()
@ -66,7 +68,7 @@ public class Trade
&& 0 < ess.getSettings().getCommandCost(command.charAt(0) == '/' ? command.substring(1) : command)
&& !user.isAuthorized("essentials.eco.loan"))
{
throw new ChargeException(Util.i18n("notEnoughMoney"));
throw new ChargeException(_("notEnoughMoney"));
}
}
@ -108,7 +110,7 @@ public class Trade
final double mon = user.getMoney();
if (mon < getMoney() && getMoney() > 0 && !user.isAuthorized("essentials.eco.loan"))
{
throw new ChargeException(Util.i18n("notEnoughMoney"));
throw new ChargeException(_("notEnoughMoney"));
}
user.takeMoney(getMoney());
}
@ -116,7 +118,7 @@ public class Trade
{
if (!InventoryWorkaround.containsItem(user.getInventory(), true, itemStack))
{
throw new ChargeException(Util.format("missingItems", getItemStack().getAmount(), getItemStack().getType().toString().toLowerCase().replace("_", " ")));
throw new ChargeException(_("missingItems", getItemStack().getAmount(), getItemStack().getType().toString().toLowerCase(Locale.ENGLISH).replace("_", " ")));
}
InventoryWorkaround.removeItem(user.getInventory(), true, getItemStack());
user.updateInventory();
@ -129,7 +131,7 @@ public class Trade
final double cost = ess.getSettings().getCommandCost(command.charAt(0) == '/' ? command.substring(1) : command);
if (mon < cost && cost > 0 && !user.isAuthorized("essentials.eco.loan"))
{
throw new ChargeException(Util.i18n("notEnoughMoney"));
throw new ChargeException(_("notEnoughMoney"));
}
user.takeMoney(cost);
}

View File

@ -1,5 +1,6 @@
package com.earth2me.essentials;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.commands.IEssentialsCommand;
import com.earth2me.essentials.register.payment.Method;
import java.util.Calendar;
@ -82,7 +83,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
cooldownTime.add(Calendar.MILLISECOND, (int)((cooldown * 1000.0) % 1000.0));
if (cooldownTime.after(now) && !isAuthorized("essentials.heal.cooldown.bypass"))
{
throw new Exception(Util.format("timeBeforeHeal", Util.formatDateDiff(cooldownTime.getTimeInMillis())));
throw new Exception(_("timeBeforeHeal", Util.formatDateDiff(cooldownTime.getTimeInMillis())));
}
}
setLastHealTimestamp(now.getTimeInMillis());
@ -101,10 +102,10 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
return;
}
setMoney(getMoney() + value);
sendMessage(Util.format("addedToAccount", Util.formatCurrency(value, ess)));
sendMessage(_("addedToAccount", Util.formatCurrency(value, ess)));
if (initiator != null)
{
initiator.sendMessage(Util.format("addedToOthersAccount", Util.formatCurrency(value, ess), this.getDisplayName()));
initiator.sendMessage(_("addedToOthersAccount", Util.formatCurrency(value, ess), this.getDisplayName()));
}
}
@ -118,12 +119,12 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
{
setMoney(getMoney() - value);
reciever.setMoney(reciever.getMoney() + value);
sendMessage(Util.format("moneySentTo", Util.formatCurrency(value, ess), reciever.getDisplayName()));
reciever.sendMessage(Util.format("moneyRecievedFrom", Util.formatCurrency(value, ess), getDisplayName()));
sendMessage(_("moneySentTo", Util.formatCurrency(value, ess), reciever.getDisplayName()));
reciever.sendMessage(_("moneyRecievedFrom", Util.formatCurrency(value, ess), getDisplayName()));
}
else
{
throw new Exception(Util.i18n("notEnoughMoney"));
throw new Exception(_("notEnoughMoney"));
}
}
@ -140,10 +141,10 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
return;
}
setMoney(getMoney() - value);
sendMessage(Util.format("takenFromAccount", Util.formatCurrency(value, ess)));
sendMessage(_("takenFromAccount", Util.formatCurrency(value, ess)));
if (initiator != null)
{
initiator.sendMessage(Util.format("takenFromOthersAccount", Util.formatCurrency(value, ess), this.getDisplayName()));
initiator.sendMessage(_("takenFromOthersAccount", Util.formatCurrency(value, ess), this.getDisplayName()));
}
}
@ -412,7 +413,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
{
setJailTimeout(0);
setJailed(false);
sendMessage(Util.i18n("haveBeenReleased"));
sendMessage(_("haveBeenReleased"));
setJail(null);
try
{
@ -432,7 +433,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
if (getMuteTimeout() > 0 && getMuteTimeout() < currentTime && isMuted())
{
setMuteTimeout(0);
sendMessage(Util.i18n("canTalkAgain"));
sendMessage(_("canTalkAgain"));
setMuted(false);
return true;
}
@ -458,7 +459,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
setAfk(false);
if (broadcast && !isHidden())
{
ess.broadcastMessage(this, Util.format("userIsNotAway", getDisplayName()));
ess.broadcastMessage(this, _("userIsNotAway", getDisplayName()));
}
}
lastActivity = System.currentTimeMillis();
@ -470,7 +471,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
if (autoafkkick > 0 && lastActivity + autoafkkick * 1000 < System.currentTimeMillis()
&& !isHidden() && !isAuthorized("essentials.kick.exempt") && !isAuthorized("essentials.afk.kickexempt"))
{
final String kickReason = Util.format("autoAfkKickReason", autoafkkick / 60.0);
final String kickReason = _("autoAfkKickReason", autoafkkick / 60.0);
kickPlayer(kickReason);
@ -479,7 +480,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
final User user = ess.getUser(player);
if (user.isAuthorized("essentials.kick.notify"))
{
player.sendMessage(Util.format("playerKicked", Console.NAME, getName(), kickReason));
player.sendMessage(_("playerKicked", Console.NAME, getName(), kickReason));
}
}
}
@ -489,7 +490,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
setAfk(true);
if (!isHidden())
{
ess.broadcastMessage(this, Util.format("userIsAway", getDisplayName()));
ess.broadcastMessage(this, _("userIsAway", getDisplayName()));
}
}
}

View File

@ -1,10 +1,7 @@
package com.earth2me.essentials;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.logging.Logger;
import org.bukkit.Location;
import org.bukkit.Material;
@ -503,18 +500,18 @@ public abstract class UserData extends PlayerExtension implements IConf
public boolean isIgnoredPlayer(String name)
{
return ignoredPlayers.contains(name.toLowerCase());
return ignoredPlayers.contains(name.toLowerCase(Locale.ENGLISH));
}
public void setIgnoredPlayer(String name, boolean set)
{
if (set)
{
ignoredPlayers.add(name.toLowerCase());
ignoredPlayers.add(name.toLowerCase(Locale.ENGLISH));
}
else
{
ignoredPlayers.remove(name.toLowerCase());
ignoredPlayers.remove(name.toLowerCase(Locale.ENGLISH));
}
setIgnoredPlayers(ignoredPlayers);
}
@ -669,7 +666,6 @@ public abstract class UserData extends PlayerExtension implements IConf
config.setProperty("timestamps.login", time);
config.save();
}
private long lastLogout;
private long _getLastLogout()
@ -688,7 +684,6 @@ public abstract class UserData extends PlayerExtension implements IConf
config.setProperty("timestamps.logout", time);
config.save();
}
private String lastLoginAddress;
private String _getLastLoginAddress()
@ -707,7 +702,6 @@ public abstract class UserData extends PlayerExtension implements IConf
config.setProperty("ipAddress", address);
config.save();
}
private boolean afk;
private boolean getAfk()
@ -856,13 +850,13 @@ public abstract class UserData extends PlayerExtension implements IConf
public Long getKitTimestamp(final String name)
{
final Number num = (Number)kitTimestamps.get(name.toLowerCase());
final Number num = (Number)kitTimestamps.get(name.toLowerCase(Locale.ENGLISH));
return num == null ? null : num.longValue();
}
public void setKitTimestamp(final String name, final long time)
{
kitTimestamps.put(name.toLowerCase(), time);
kitTimestamps.put(name.toLowerCase(Locale.ENGLISH), time);
config.setProperty("timestamps.kits", kitTimestamps);
config.save();
}

View File

@ -6,6 +6,7 @@ import com.google.common.cache.CacheLoader;
import com.google.common.collect.ConcurrentHashMultiset;
import java.io.File;
import java.util.HashSet;
import java.util.Locale;
import java.util.Set;
import java.util.concurrent.ExecutionException;
import java.util.logging.Level;
@ -47,7 +48,7 @@ public class UserMap extends CacheLoader<String, User> implements IConf
continue;
}
final String name = string.substring(0, string.length() - 4);
keys.add(name.toLowerCase());
keys.add(name.toLowerCase(Locale.ENGLISH));
}
}
});
@ -55,14 +56,14 @@ public class UserMap extends CacheLoader<String, User> implements IConf
public boolean userExists(final String name)
{
return keys.contains(name.toLowerCase());
return keys.contains(name.toLowerCase(Locale.ENGLISH));
}
public User getUser(final String name) throws NullPointerException
{
try
{
return users.get(name.toLowerCase());
return users.get(name.toLowerCase(Locale.ENGLISH));
}
catch (ExecutionException ex)
{
@ -77,7 +78,7 @@ public class UserMap extends CacheLoader<String, User> implements IConf
{
if (player.getName().equalsIgnoreCase(name))
{
keys.add(name.toLowerCase());
keys.add(name.toLowerCase(Locale.ENGLISH));
return new User(player, ess);
}
}
@ -85,7 +86,7 @@ public class UserMap extends CacheLoader<String, User> implements IConf
final File userFile = new File(userFolder, Util.sanitizeFileName(name) + ".yml");
if (userFile.exists())
{
keys.add(name.toLowerCase());
keys.add(name.toLowerCase(Locale.ENGLISH));
return new User(new OfflinePlayer(name, ess), ess);
}
throw new Exception("User not found!");
@ -99,8 +100,8 @@ public class UserMap extends CacheLoader<String, User> implements IConf
public void removeUser(final String name)
{
keys.remove(name.toLowerCase());
users.invalidate(name.toLowerCase());
keys.remove(name.toLowerCase(Locale.ENGLISH));
users.invalidate(name.toLowerCase(Locale.ENGLISH));
}
public Set<User> getAllUsers()

View File

@ -1,13 +1,9 @@
package com.earth2me.essentials;
import java.io.*;
import java.net.MalformedURLException;
import java.net.URL;
import static com.earth2me.essentials.I18n._;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.text.MessageFormat;
import java.util.*;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@ -27,7 +23,7 @@ public class Util
public static String sanitizeFileName(String name)
{
return name.toLowerCase().replaceAll("[^a-z0-9]", "_");
return name.toLowerCase(Locale.ENGLISH).replaceAll("[^a-z0-9]", "_");
}
public static String formatDateDiff(long date)
@ -43,7 +39,7 @@ public class Util
boolean future = false;
if (toDate.equals(fromDate))
{
return Util.i18n("now");
return _("now");
}
if (toDate.after(fromDate))
{
@ -62,18 +58,18 @@ public class Util
};
String[] names = new String[]
{
Util.i18n("year"),
Util.i18n("years"),
Util.i18n("month"),
Util.i18n("months"),
Util.i18n("day"),
Util.i18n("days"),
Util.i18n("hour"),
Util.i18n("hours"),
Util.i18n("minute"),
Util.i18n("minutes"),
Util.i18n("second"),
Util.i18n("seconds")
_("year"),
_("years"),
_("month"),
_("months"),
_("day"),
_("days"),
_("hour"),
_("hours"),
_("minute"),
_("minutes"),
_("second"),
_("seconds")
};
for (int i = 0; i < types.length; i++)
{
@ -173,7 +169,7 @@ public class Util
}
if (!found)
{
throw new Exception(Util.i18n("illegalDate"));
throw new Exception(_("illegalDate"));
}
Calendar c = new GregorianCalendar();
if (years > 0)
@ -206,12 +202,12 @@ public class Util
}
return c.getTimeInMillis();
}
// The player can stand inside these materials
private static final Set<Integer> AIR_MATERIALS = new HashSet<Integer>();
private static final HashSet<Byte> AIR_MATERIALS_TARGET = new HashSet<Byte>();
static {
static
{
AIR_MATERIALS.add(Material.AIR.getId());
AIR_MATERIALS.add(Material.SAPLING.getId());
AIR_MATERIALS.add(Material.POWERED_RAIL.getId());
@ -221,7 +217,7 @@ public class Util
AIR_MATERIALS.add(Material.YELLOW_FLOWER.getId());
AIR_MATERIALS.add(Material.RED_ROSE.getId());
AIR_MATERIALS.add(Material.BROWN_MUSHROOM.getId());
AIR_MATERIALS.add(Material.RED_MUSHROOM.getId());
AIR_MATERIALS.add(Material.RED_MUSHROOM.getId());
AIR_MATERIALS.add(Material.TORCH.getId());
AIR_MATERIALS.add(Material.REDSTONE_WIRE.getId());
AIR_MATERIALS.add(Material.SEEDS.getId());
@ -233,19 +229,19 @@ public class Util
AIR_MATERIALS.add(Material.LEVER.getId());
AIR_MATERIALS.add(Material.STONE_PLATE.getId());
AIR_MATERIALS.add(Material.IRON_DOOR_BLOCK.getId());
AIR_MATERIALS.add(Material.WOOD_PLATE.getId());
AIR_MATERIALS.add(Material.WOOD_PLATE.getId());
AIR_MATERIALS.add(Material.REDSTONE_TORCH_OFF.getId());
AIR_MATERIALS.add(Material.REDSTONE_TORCH_ON.getId());
AIR_MATERIALS.add(Material.STONE_BUTTON.getId());
AIR_MATERIALS.add(Material.SUGAR_CANE_BLOCK.getId());
AIR_MATERIALS.add(Material.SUGAR_CANE_BLOCK.getId());
AIR_MATERIALS.add(Material.DIODE_BLOCK_OFF.getId());
AIR_MATERIALS.add(Material.DIODE_BLOCK_ON.getId());
AIR_MATERIALS.add(Material.DIODE_BLOCK_ON.getId());
AIR_MATERIALS.add(Material.TRAP_DOOR.getId());
AIR_MATERIALS.add(Material.PUMPKIN_STEM.getId());
AIR_MATERIALS.add(Material.MELON_STEM.getId());
AIR_MATERIALS.add(Material.VINE.getId());
//TODO: Add 1.9 materials
for (Integer integer : AIR_MATERIALS)
{
AIR_MATERIALS_TARGET.add(integer.byteValue());
@ -253,26 +249,28 @@ public class Util
AIR_MATERIALS_TARGET.add((byte)Material.WATER.getId());
AIR_MATERIALS_TARGET.add((byte)Material.STATIONARY_WATER.getId());
}
public static Location getTarget(final LivingEntity entity) throws Exception {
public static Location getTarget(final LivingEntity entity) throws Exception
{
final Block block = entity.getTargetBlock(AIR_MATERIALS_TARGET, 300);
if (block == null) {
if (block == null)
{
throw new Exception("Not targeting a block");
}
return block.getLocation();
}
public static Location getSafeDestination(final Location loc) throws Exception
{
if (loc == null || loc.getWorld() == null)
{
throw new Exception(Util.i18n("destinationNotSet"));
throw new Exception(_("destinationNotSet"));
}
final World world = loc.getWorld();
int x = loc.getBlockX();
int y = (int)Math.round(loc.getY());
int z = loc.getBlockZ();
while (isBlockAboveAir(world, x, y, z))
{
y -= 1;
@ -300,7 +298,7 @@ public class Util
x += 1;
if (x - 32 > loc.getBlockX())
{
throw new Exception(Util.i18n("holeInFloor"));
throw new Exception(_("holeInFloor"));
}
}
}
@ -349,175 +347,11 @@ public class Util
return Math.round(d * 100.0) / 100.0;
}
public static Locale getCurrentLocale()
{
return currentLocale;
}
private static class ConfigClassLoader extends ClassLoader
{
private final transient File dataFolder;
private final transient ClassLoader cl;
private final transient IEssentials ess;
public ConfigClassLoader(final ClassLoader cl, final IEssentials ess)
{
this.ess = ess;
this.dataFolder = ess.getDataFolder();
this.cl = cl;
}
@Override
public URL getResource(final String string)
{
final File file = new File(dataFolder, string);
if (file.exists())
{
try
{
return file.toURI().toURL();
}
catch (MalformedURLException ex)
{
return cl.getResource(string);
}
}
return cl.getResource(string);
}
@Override
public synchronized void clearAssertionStatus()
{
cl.clearAssertionStatus();
}
@Override
public InputStream getResourceAsStream(final String string)
{
final File file = new File(dataFolder, string);
if (file.exists())
{
BufferedReader br = null;
try
{
br = new BufferedReader(new FileReader(file));
final String version = br.readLine();
if (version == null || !version.equals("#version: " + ess.getDescription().getVersion()))
{
logger.log(Level.WARNING, String.format("Translation file %s is not updated for Essentials version. Will use default.", file));
return cl.getResourceAsStream(string);
}
return new FileInputStream(file);
}
catch (IOException ex)
{
return cl.getResourceAsStream(string);
}
finally
{
if (br != null)
{
try
{
br.close();
}
catch (IOException ex)
{
}
}
}
}
return cl.getResourceAsStream(string);
}
@Override
public Enumeration<URL> getResources(final String string) throws IOException
{
return cl.getResources(string);
}
@Override
public Class<?> loadClass(final String string) throws ClassNotFoundException
{
return cl.loadClass(string);
}
@Override
public synchronized void setClassAssertionStatus(final String string, final boolean bln)
{
cl.setClassAssertionStatus(string, bln);
}
@Override
public synchronized void setDefaultAssertionStatus(final boolean bln)
{
cl.setDefaultAssertionStatus(bln);
}
@Override
public synchronized void setPackageAssertionStatus(final String string, final boolean bln)
{
cl.setPackageAssertionStatus(string, bln);
}
}
private static final Locale defaultLocale = Locale.getDefault();
private static Locale currentLocale = defaultLocale;
private static ResourceBundle bundle = ResourceBundle.getBundle("messages", defaultLocale);
private static ResourceBundle defaultBundle = ResourceBundle.getBundle("messages", Locale.US);
public static String i18n(String string)
{
try
{
return bundle.getString(string);
}
catch (MissingResourceException ex)
{
logger.log(Level.WARNING, String.format("Missing translation key \"%s\" in translation file %s", ex.getKey(), bundle.getLocale().toString()), ex);
return defaultBundle.getString(string);
}
}
public static String format(String string, Object... objects)
{
MessageFormat mf = new MessageFormat(i18n(string));
return mf.format(objects);
}
public static void updateLocale(String loc, IEssentials ess)
{
if (loc == null || loc.isEmpty())
{
return;
}
String[] parts = loc.split("[_\\.]");
if (parts.length == 1)
{
currentLocale = new Locale(parts[0]);
}
if (parts.length == 2)
{
currentLocale = new Locale(parts[0], parts[1]);
}
if (parts.length == 3)
{
currentLocale = new Locale(parts[0], parts[1], parts[2]);
}
logger.log(Level.INFO, String.format("Using locale %s", currentLocale.toString()));
bundle = ResourceBundle.getBundle("messages", currentLocale, new ConfigClassLoader(Util.class.getClassLoader(), ess));
if (!bundle.keySet().containsAll(defaultBundle.keySet()))
{
logger.log(Level.WARNING, String.format("Translation file %s does not contain all translation keys.", currentLocale.toString()));
}
}
public static String joinList(Object... list)
{
return joinList(", ", list);
}
public static String joinList(String seperator, Object... list)
{
StringBuilder buf = new StringBuilder();
@ -527,14 +361,14 @@ public class Util
{
buf.append(seperator);
}
if(each instanceof List)
if (each instanceof List)
{
buf.append(joinList(seperator, ((List)each).toArray()));
}
else
{
try
try
{
buf.append(each.toString());
}
@ -546,9 +380,4 @@ public class Util
}
return buf.toString();
}
public static String capitalCase(String s)
{
return s.toUpperCase().charAt(0) + s.toLowerCase().substring(1);
}
}

View File

@ -1,5 +1,6 @@
package com.earth2me.essentials;
import static com.earth2me.essentials.I18n._;
import java.io.File;
import java.util.*;
import java.util.logging.Level;
@ -47,7 +48,7 @@ public class Warps implements IConf
EssentialsConf conf = warpPoints.get(new StringIgnoreCase(warp));
if (conf == null)
{
throw new Exception(Util.i18n("warpNotExist"));
throw new Exception(_("warpNotExist"));
}
return conf.getLocation(null, server);
}
@ -61,7 +62,7 @@ public class Warps implements IConf
File confFile = new File(warpsFolder, filename + ".yml");
if (confFile.exists())
{
throw new Exception(Util.i18n("similarWarpExist"));
throw new Exception(_("similarWarpExist"));
}
conf = new EssentialsConf(confFile);
warpPoints.put(new StringIgnoreCase(name), conf);
@ -76,11 +77,11 @@ public class Warps implements IConf
EssentialsConf conf = warpPoints.get(new StringIgnoreCase(name));
if (conf == null)
{
throw new Exception(Util.i18n("warpNotExist"));
throw new Exception(_("warpNotExist"));
}
if (!conf.getFile().delete())
{
throw new Exception(Util.i18n("warpDeleteError"));
throw new Exception(_("warpDeleteError"));
}
warpPoints.remove(new StringIgnoreCase(name));
}
@ -109,7 +110,7 @@ public class Warps implements IConf
}
catch (Exception ex)
{
logger.log(Level.WARNING, Util.format("loadWarpError", filename), ex);
logger.log(Level.WARNING, _("loadWarpError", filename), ex);
}
}
}
@ -129,7 +130,7 @@ public class Warps implements IConf
@Override
public int hashCode()
{
return getString().toLowerCase().hashCode();
return getString().toLowerCase(Locale.ENGLISH).hashCode();
}
@Override

View File

@ -1,6 +1,7 @@
package com.earth2me.essentials;
import java.io.File;
import java.util.Locale;
import java.util.logging.Logger;
import org.bukkit.inventory.ItemStack;
@ -19,7 +20,7 @@ public class Worth implements IConf
public double getPrice(ItemStack itemStack)
{
String itemname = itemStack.getType().toString().toLowerCase().replace("_", "");
String itemname = itemStack.getType().toString().toLowerCase(Locale.ENGLISH).replace("_", "");
double result;
result = config.getDouble("worth." + itemname + "." + itemStack.getDurability(), Double.NaN);
if (Double.isNaN(result))
@ -41,12 +42,12 @@ public class Worth implements IConf
{
if (itemStack.getType().getData() == null)
{
config.setProperty("worth." + itemStack.getType().toString().toLowerCase().replace("_", ""), price);
config.setProperty("worth." + itemStack.getType().toString().toLowerCase(Locale.ENGLISH).replace("_", ""), price);
}
else
{
// Bukkit-bug: getDurability still contains the correct value, while getData().getData() is 0.
config.setProperty("worth." + itemStack.getType().toString().toLowerCase().replace("_", "") + "." + itemStack.getDurability(), price);
config.setProperty("worth." + itemStack.getType().toString().toLowerCase(Locale.ENGLISH).replace("_", "") + "." + itemStack.getDurability(), price);
}
config.removeProperty("worth-" + itemStack.getTypeId());
config.save();

View File

@ -1,6 +1,7 @@
package com.earth2me.essentials.api;
import com.earth2me.essentials.EssentialsConf;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.IEssentials;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
@ -59,7 +60,7 @@ public final class Economy
{
if (!config.delete())
{
logger.log(Level.WARNING, Util.format("deleteFileError", config));
logger.log(Level.WARNING, _("deleteFileError", config));
}
ess.getUserMap().removeUser(name);
}

View File

@ -1,13 +1,12 @@
package com.earth2me.essentials.api;
import com.earth2me.essentials.Util;
import static com.earth2me.essentials.I18n._;
public class NoLoanPermittedException extends Exception
{
public NoLoanPermittedException()
{
super(Util.i18n("negativeBalanceError"));
super(_("negativeBalanceError"));
}
}

View File

@ -1,13 +1,12 @@
package com.earth2me.essentials.api;
import com.earth2me.essentials.Util;
import static com.earth2me.essentials.I18n._;
public class UserDoesNotExistException extends Exception
{
public UserDoesNotExistException(String name)
{
super(Util.format("userDoesNotExist", name));
super(_("userDoesNotExist", name));
}
}

View File

@ -1,7 +1,7 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import org.bukkit.Server;
@ -33,19 +33,19 @@ public class Commandafk extends EssentialsCommand
{
if (!user.toggleAfk())
{
//user.sendMessage(Util.i18n("markedAsNotAway"));
//user.sendMessage(_("markedAsNotAway"));
if (!user.isHidden())
{
ess.broadcastMessage(user, Util.format("userIsNotAway", user.getDisplayName()));
ess.broadcastMessage(user, _("userIsNotAway", user.getDisplayName()));
}
user.updateActivity(false);
}
else
{
//user.sendMessage(Util.i18n("markedAsAway"));
//user.sendMessage(_("markedAsAway"));
if (!user.isHidden())
{
ess.broadcastMessage(user, Util.format("userIsAway", user.getDisplayName()));
ess.broadcastMessage(user, _("userIsAway", user.getDisplayName()));
}
}
}

View File

@ -1,8 +1,8 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.Trade;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import org.bukkit.Server;
@ -18,7 +18,7 @@ public class Commandback extends EssentialsCommand
{
final Trade charge = new Trade(this.getName(), ess);
charge.isAffordableFor(user);
user.sendMessage(Util.i18n("backUsageMsg"));
user.sendMessage(_("backUsageMsg"));
user.getTeleport().back(charge);
}
}

View File

@ -1,7 +1,7 @@
package com.earth2me.essentials.commands;
import com.earth2me.essentials.Backup;
import com.earth2me.essentials.Util;
import static com.earth2me.essentials.I18n._;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
@ -22,6 +22,6 @@ public class Commandbackup extends EssentialsCommand
throw new Exception();
}
backup.run();
sender.sendMessage(Util.i18n("backupStarted"));
sender.sendMessage(_("backupStarted"));
}
}

View File

@ -1,5 +1,6 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import org.bukkit.Server;
@ -20,7 +21,7 @@ public class Commandbalance extends EssentialsCommand
{
throw new NotEnoughArgumentsException();
}
sender.sendMessage(Util.format("balance", Util.formatCurrency(getPlayer(server, args, 0, true).getMoney(), ess)));
sender.sendMessage(_("balance", Util.formatCurrency(getPlayer(server, args, 0, true).getMoney(), ess)));
}
@Override
@ -31,6 +32,6 @@ public class Commandbalance extends EssentialsCommand
|| user.isAuthorized("essentials.balance.other"))
? user
: getPlayer(server, args, 0, true)).getMoney();
user.sendMessage(Util.format("balance", Util.formatCurrency(bal, ess)));
user.sendMessage(_("balance", Util.formatCurrency(bal, ess)));
}
}

View File

@ -1,5 +1,6 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import java.util.*;
@ -49,7 +50,7 @@ public class Commandbalancetop extends EssentialsCommand
}
});
int count = 0;
sender.sendMessage(Util.format("balanceTop", max));
sender.sendMessage(_("balanceTop", max));
for (Map.Entry<User, Double> entry : sortedEntries)
{
if (count == max)

View File

@ -1,9 +1,9 @@
package com.earth2me.essentials.commands;
import com.earth2me.essentials.Console;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.OfflinePlayer;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@ -29,7 +29,7 @@ public class Commandban extends EssentialsCommand
if (sender instanceof Player
&& !ess.getUser(sender).isAuthorized("essentials.ban.offline"))
{
sender.sendMessage(Util.i18n("banExempt"));
sender.sendMessage(_("banExempt"));
return;
}
}
@ -37,7 +37,7 @@ public class Commandban extends EssentialsCommand
{
if (user.isAuthorized("essentials.ban.exempt"))
{
sender.sendMessage(Util.i18n("banExempt"));
sender.sendMessage(_("banExempt"));
return;
}
}
@ -50,7 +50,7 @@ public class Commandban extends EssentialsCommand
}
else
{
banReason = Util.i18n("defaultBanReason");
banReason = _("defaultBanReason");
}
user.setBanned(true);
user.kickPlayer(banReason);
@ -61,7 +61,7 @@ public class Commandban extends EssentialsCommand
final User player = ess.getUser(onlinePlayer);
if (player.isAuthorized("essentials.ban.notify"))
{
onlinePlayer.sendMessage(Util.format("playerBanned", senderName, user.getName(), banReason));
onlinePlayer.sendMessage(_("playerBanned", senderName, user.getName(), banReason));
}
}
}

View File

@ -1,7 +1,7 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
@ -26,17 +26,17 @@ public class Commandbanip extends EssentialsCommand
if (player == null)
{
ess.getServer().banIP(args[0]);
sender.sendMessage(Util.i18n("banIpAddress"));
sender.sendMessage(_("banIpAddress"));
}
else
{
final String ipAddress = player.getLastLoginAddress();
if (ipAddress.length() == 0)
{
throw new Exception(Util.i18n("playerNotFound"));
throw new Exception(_("playerNotFound"));
}
ess.getServer().banIP(player.getLastLoginAddress());
sender.sendMessage(Util.i18n("banIpAddress"));
sender.sendMessage(_("banIpAddress"));
}
}
}

View File

@ -1,5 +1,6 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import org.bukkit.Location;
@ -36,11 +37,11 @@ public class Commandbigtree extends EssentialsCommand
final boolean success = user.getWorld().generateTree(safeLocation, tree);
if (success)
{
user.sendMessage(Util.i18n("bigTreeSuccess"));
user.sendMessage(_("bigTreeSuccess"));
}
else
{
throw new Exception(Util.i18n("bigTreeFailure"));
throw new Exception(_("bigTreeFailure"));
}
}
}

View File

@ -1,6 +1,6 @@
package com.earth2me.essentials.commands;
import com.earth2me.essentials.Util;
import static com.earth2me.essentials.I18n._;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
@ -20,6 +20,6 @@ public class Commandbroadcast extends EssentialsCommand
throw new NotEnoughArgumentsException();
}
ess.broadcastMessage(null, Util.format("broadcast", getFinalArg(args, 0)));
ess.broadcastMessage(null, _("broadcast", getFinalArg(args, 0)));
}
}

View File

@ -1,6 +1,6 @@
package com.earth2me.essentials.commands;
import com.earth2me.essentials.Util;
import static com.earth2me.essentials.I18n._;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@ -24,7 +24,7 @@ public class Commandburn extends EssentialsCommand
for (Player p : server.matchPlayer(args[0]))
{
p.setFireTicks(Integer.parseInt(args[1]) * 20);
sender.sendMessage(Util.format("burnMsg", p.getDisplayName(), Integer.parseInt(args[1])));
sender.sendMessage(_("burnMsg", p.getDisplayName(), Integer.parseInt(args[1])));
}
}
}

View File

@ -1,7 +1,7 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import java.util.List;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
@ -31,11 +31,11 @@ public class Commandclearinventory extends EssentialsCommand
for (Player p : online)
{
p.getInventory().clear();
user.sendMessage(Util.format("inventoryClearedOthers", p.getDisplayName()));
user.sendMessage(_("inventoryClearedOthers", p.getDisplayName()));
}
return;
}
throw new Exception(Util.i18n("playerNotFound"));
throw new Exception(_("playerNotFound"));
}
else
{
@ -43,18 +43,18 @@ public class Commandclearinventory extends EssentialsCommand
if (p != null)
{
p.getInventory().clear();
user.sendMessage(Util.format("inventoryClearedOthers", p.getDisplayName()));
user.sendMessage(_("inventoryClearedOthers", p.getDisplayName()));
}
else
{
throw new Exception(Util.i18n("playerNotFound"));
throw new Exception(_("playerNotFound"));
}
}
}
else
{
user.getInventory().clear();
user.sendMessage(Util.i18n("inventoryCleared"));
user.sendMessage(_("inventoryCleared"));
}
}
@ -75,11 +75,11 @@ public class Commandclearinventory extends EssentialsCommand
for (Player p : online)
{
p.getInventory().clear();
sender.sendMessage(Util.format("inventoryClearedOthers", p.getDisplayName()));
sender.sendMessage(_("inventoryClearedOthers", p.getDisplayName()));
}
return;
}
throw new Exception(Util.i18n("playerNotFound"));
throw new Exception(_("playerNotFound"));
}
else
{
@ -87,11 +87,11 @@ public class Commandclearinventory extends EssentialsCommand
if (u != null)
{
u.getInventory().clear();
sender.sendMessage(Util.format("inventoryClearedOthers", u.getDisplayName()));
sender.sendMessage(_("inventoryClearedOthers", u.getDisplayName()));
}
else
{
throw new Exception(Util.i18n("playerNotFound"));
throw new Exception(_("playerNotFound"));
}
}
}

View File

@ -1,7 +1,7 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import org.bukkit.Server;
@ -53,6 +53,6 @@ public class Commandcompass extends EssentialsCommand
{
dir = "N";
}
user.sendMessage(Util.format("compassBearing", dir, bearing));
user.sendMessage(_("compassBearing", dir, bearing));
}
}

View File

@ -1,7 +1,8 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import java.util.Locale;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
@ -38,7 +39,7 @@ public class Commanddelhome extends EssentialsCommand
}
name = expandedArgs[0];
}
user.delHome(name.toLowerCase());
sender.sendMessage(Util.format("deleteHome", name));
user.delHome(name.toLowerCase(Locale.ENGLISH));
sender.sendMessage(_("deleteHome", name));
}
}

View File

@ -1,6 +1,6 @@
package com.earth2me.essentials.commands;
import com.earth2me.essentials.Util;
import static com.earth2me.essentials.I18n._;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
@ -20,6 +20,6 @@ public class Commanddeljail extends EssentialsCommand
throw new NotEnoughArgumentsException();
}
ess.getJail().delJail(args[0]);
sender.sendMessage(Util.format("deleteJail", args[0]));
sender.sendMessage(_("deleteJail", args[0]));
}
}

View File

@ -1,6 +1,6 @@
package com.earth2me.essentials.commands;
import com.earth2me.essentials.Util;
import static com.earth2me.essentials.I18n._;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
@ -20,6 +20,6 @@ public class Commanddelwarp extends EssentialsCommand
throw new NotEnoughArgumentsException();
}
ess.getWarps().delWarp(args[0]);
sender.sendMessage(Util.format("deleteWarp", args[0]));
sender.sendMessage(_("deleteWarp", args[0]));
}
}

View File

@ -1,7 +1,7 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import org.bukkit.Server;
@ -18,15 +18,15 @@ public class Commanddepth extends EssentialsCommand
final int depth = user.getLocation().getBlockY() - 63;
if (depth > 0)
{
user.sendMessage(Util.format("depthAboveSea", depth));
user.sendMessage(_("depthAboveSea", depth));
}
else if (depth < 0)
{
user.sendMessage(Util.format("depthBelowSea", (-depth)));
user.sendMessage(_("depthBelowSea", (-depth)));
}
else
{
user.sendMessage(Util.i18n("depth"));
user.sendMessage(_("depth"));
}
}
}

View File

@ -1,6 +1,6 @@
package com.earth2me.essentials.commands;
import com.earth2me.essentials.Util;
import static com.earth2me.essentials.I18n._;
import java.util.HashMap;
import java.util.Map;
import org.bukkit.Location;
@ -108,7 +108,7 @@ public class Commandessentials extends EssentialsCommand
return;
}
ess.reload();
sender.sendMessage(Util.format("essentialsReload", ess.getDescription().getVersion()));
sender.sendMessage(_("essentialsReload", ess.getDescription().getVersion()));
}
private void stopTune()

View File

@ -1,7 +1,7 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@ -31,7 +31,7 @@ public class Commandext extends EssentialsCommand
if (args.length < 1)
{
user.setFireTicks(0);
user.sendMessage(Util.i18n("extinguish"));
user.sendMessage(_("extinguish"));
return;
}
@ -43,7 +43,7 @@ public class Commandext extends EssentialsCommand
for (Player matchPlayer : server.matchPlayer(name))
{
matchPlayer.setFireTicks(0);
sender.sendMessage(Util.format("extinguishOthers", matchPlayer.getDisplayName()));
sender.sendMessage(_("extinguishOthers", matchPlayer.getDisplayName()));
}
}
}

View File

@ -1,7 +1,8 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import java.util.Locale;
import org.bukkit.GameMode;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
@ -36,7 +37,7 @@ public class Commandgamemode extends EssentialsCommand
}
user.setGameMode(user.getGameMode() == GameMode.SURVIVAL ? GameMode.CREATIVE : GameMode.SURVIVAL);
user.sendMessage(Util.format("gameMode", Util.i18n(user.getGameMode().toString().toLowerCase()), user.getDisplayName()));
user.sendMessage(_("gameMode", _(user.getGameMode().toString().toLowerCase(Locale.ENGLISH)), user.getDisplayName()));
}
private void gamemodeOtherPlayers(final Server server, final CommandSender sender, final String name)
@ -50,9 +51,7 @@ public class Commandgamemode extends EssentialsCommand
}
player.setGameMode(player.getGameMode() == GameMode.SURVIVAL ? GameMode.CREATIVE : GameMode.SURVIVAL);
sender.sendMessage(Util.format("gameMode", Util.i18n(player.getGameMode().toString().toLowerCase()), player.getDisplayName()));
sender.sendMessage(_("gameMode", _(player.getGameMode().toString().toLowerCase(Locale.ENGLISH)), player.getDisplayName()));
}
}
}

View File

@ -1,6 +1,6 @@
package com.earth2me.essentials.commands;
import com.earth2me.essentials.Util;
import static com.earth2me.essentials.I18n._;
import org.bukkit.Server;
import org.bukkit.World;
import org.bukkit.command.CommandSender;
@ -16,16 +16,16 @@ public class Commandgc extends EssentialsCommand
@Override
protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
sender.sendMessage(Util.format("gcmax", (Runtime.getRuntime().maxMemory() / 1024 / 1024)));
sender.sendMessage(Util.format("gctotal", (Runtime.getRuntime().totalMemory() / 1024 / 1024)));
sender.sendMessage(Util.format("gcfree", (Runtime.getRuntime().freeMemory() / 1024 / 1024)));
sender.sendMessage(_("gcmax", (Runtime.getRuntime().maxMemory() / 1024 / 1024)));
sender.sendMessage(_("gctotal", (Runtime.getRuntime().totalMemory() / 1024 / 1024)));
sender.sendMessage(_("gcfree", (Runtime.getRuntime().freeMemory() / 1024 / 1024)));
for (World w : server.getWorlds())
{
sender.sendMessage(
(w.getEnvironment() == World.Environment.NETHER ? "Nether" : "World") + " \"" + w.getName() + "\": "
+ w.getLoadedChunks().length + Util.i18n("gcchunks")
+ w.getEntities().size() + Util.i18n("gcentities"));
+ w.getLoadedChunks().length + _("gcchunks")
+ w.getEntities().size() + _("gcentities"));
}
}
}

View File

@ -1,6 +1,7 @@
package com.earth2me.essentials.commands;
import com.earth2me.essentials.User;
import java.util.Locale;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.Server;
@ -27,7 +28,7 @@ public class Commandgive extends EssentialsCommand
final ItemStack stack = ess.getItemDb().get(args[1]);
final String itemname = stack.getType().toString().toLowerCase().replace("_", "");
final String itemname = stack.getType().toString().toLowerCase(Locale.ENGLISH).replace("_", "");
if (sender instanceof Player
&& (ess.getSettings().permissionBasedItemSpawn()
? (!ess.getUser(sender).isAuthorized("essentials.give.item-all")
@ -49,7 +50,7 @@ public class Commandgive extends EssentialsCommand
}
final User giveTo = getPlayer(server, args, 0);
final String itemName = stack.getType().toString().toLowerCase().replace('_', ' ');
final String itemName = stack.getType().toString().toLowerCase(Locale.ENGLISH).replace('_', ' ');
sender.sendMessage(ChatColor.BLUE + "Giving " + stack.getAmount() + " of " + itemName + " to " + giveTo.getDisplayName() + ".");
giveTo.getInventory().addItem(stack);
giveTo.updateInventory();

View File

@ -1,7 +1,7 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@ -34,7 +34,7 @@ public class Commandgod extends EssentialsCommand
return;
}
user.sendMessage(Util.format("godMode", (user.toggleGodModeEnabled()? Util.i18n("enabled") : Util.i18n("disabled"))));
user.sendMessage(_("godMode", (user.toggleGodModeEnabled() ? _("enabled") : _("disabled"))));
}
private void godOtherPlayers(final Server server, final CommandSender sender, final String name)
@ -47,8 +47,8 @@ public class Commandgod extends EssentialsCommand
continue;
}
final boolean enabled = player.toggleGodModeEnabled();
player.sendMessage(Util.format("godMode", (enabled ? Util.i18n("enabled") : Util.i18n("disabled"))));
sender.sendMessage(Util.format("godMode",Util.format(enabled ? "godEnabledFor": "godDisabledFor", matchPlayer.getDisplayName())));
player.sendMessage(_("godMode", (enabled ? _("enabled") : _("disabled"))));
sender.sendMessage(_("godMode", _(enabled ? "godEnabledFor" : "godDisabledFor", matchPlayer.getDisplayName())));
}
}
}

View File

@ -1,7 +1,7 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import java.util.List;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
@ -35,7 +35,7 @@ public class Commandheal extends EssentialsCommand
}
user.setHealth(20);
user.setFoodLevel(20);
user.sendMessage(Util.i18n("heal"));
user.sendMessage(_("heal"));
}
@Override
@ -54,7 +54,7 @@ public class Commandheal extends EssentialsCommand
final List<Player> players = server.matchPlayer(name);
if (players.isEmpty())
{
sender.sendMessage(Util.i18n("playerNotFound"));
sender.sendMessage(_("playerNotFound"));
return;
}
for (Player p : players)
@ -64,7 +64,7 @@ public class Commandheal extends EssentialsCommand
continue;
}
p.setHealth(20);
sender.sendMessage(Util.format("healOther", p.getDisplayName()));
sender.sendMessage(_("healOther", p.getDisplayName()));
}
}
}

View File

@ -1,5 +1,6 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import java.io.BufferedReader;
@ -8,6 +9,7 @@ import java.io.FileReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map.Entry;
import java.util.logging.Level;
import org.bukkit.Server;
@ -40,7 +42,7 @@ public class Commandhelp extends EssentialsCommand
{
if (args.length > 0)
{
match = args[0].toLowerCase();
match = args[0].toLowerCase(Locale.ENGLISH);
page = Integer.parseInt(args[args.length - 1]);
if (args.length == 1)
{
@ -53,20 +55,20 @@ public class Commandhelp extends EssentialsCommand
{
if (args.length == 1)
{
match = args[0].toLowerCase();
match = args[0].toLowerCase(Locale.ENGLISH);
}
}
final List<String> lines = getHelpLines(user, match);
if (lines.isEmpty())
{
throw new Exception(Util.i18n("noHelpFound"));
throw new Exception(_("noHelpFound"));
}
final int start = (page - 1) * 9;
final int pages = lines.size() / 9 + (lines.size() % 9 > 0 ? 1 : 0);
user.sendMessage(Util.format("helpPages", page, pages));
user.sendMessage(_("helpPages", page, pages));
for (int i = start; i < lines.size() && i < start + 9; i++)
{
user.sendMessage(lines.get(i));
@ -76,7 +78,7 @@ public class Commandhelp extends EssentialsCommand
@Override
protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
sender.sendMessage(Util.i18n("helpConsole"));
sender.sendMessage(_("helpConsole"));
}
@SuppressWarnings("CallToThreadDumpStack")
@ -101,7 +103,8 @@ public class Commandhelp extends EssentialsCommand
while (bufferedReader.ready())
{
final String line = bufferedReader.readLine();
if (line == null) {
if (line == null)
{
break;
}
retval.add(line.replace('&', '§'));
@ -122,15 +125,15 @@ public class Commandhelp extends EssentialsCommand
{
final PluginDescriptionFile desc = p.getDescription();
final HashMap<String, HashMap<String, Object>> cmds = (HashMap<String, HashMap<String, Object>>)desc.getCommands();
pluginName = p.getDescription().getName().toLowerCase();
pluginName = p.getDescription().getName().toLowerCase(Locale.ENGLISH);
for (Entry<String, HashMap<String, Object>> k : cmds.entrySet())
{
try
{
if ((!match.equalsIgnoreCase(""))
&& (!k.getKey().toLowerCase().contains(match))
&& (!k.getKey().toLowerCase(Locale.ENGLISH).contains(match))
&& (!(k.getValue().get(DESCRIPTION) instanceof String
&& ((String)k.getValue().get(DESCRIPTION)).toLowerCase().contains(match)))
&& ((String)k.getValue().get(DESCRIPTION)).toLowerCase(Locale.ENGLISH).contains(match)))
&& (!pluginName.contains(match)))
{
continue;
@ -223,7 +226,7 @@ public class Commandhelp extends EssentialsCommand
{
if (!reported)
{
logger.log(Level.WARNING, Util.format("commandHelpFailedForPlugin", pluginName), ex);
logger.log(Level.WARNING, _("commandHelpFailedForPlugin", pluginName), ex);
}
reported = true;
continue;

View File

@ -1,7 +1,7 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import java.util.logging.Level;
import org.bukkit.Server;
import org.bukkit.entity.Player;
@ -22,7 +22,7 @@ public class Commandhelpop extends EssentialsCommand
throw new NotEnoughArgumentsException();
}
final String message = Util.format("helpOp", user.getDisplayName(), getFinalArg(args, 0));
final String message = _("helpOp", user.getDisplayName(), getFinalArg(args, 0));
logger.log(Level.INFO, message);
for (Player onlinePlayer : server.getOnlinePlayers())
{

View File

@ -1,9 +1,11 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.Trade;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import java.util.List;
import java.util.Locale;
import org.bukkit.Server;
@ -40,7 +42,7 @@ public class Commandhome extends EssentialsCommand
}
try
{
user.getTeleport().home(player, homeName.toLowerCase(), charge);
user.getTeleport().home(player, homeName.toLowerCase(Locale.ENGLISH), charge);
}
catch (NotEnoughArgumentsException e)
{
@ -51,7 +53,7 @@ public class Commandhome extends EssentialsCommand
}
else if (homes.isEmpty())
{
throw new Exception(player == user ? Util.i18n("noHomeSet") : Util.i18n("noHomeSetPlayer"));
throw new Exception(player == user ? _("noHomeSet") : _("noHomeSetPlayer"));
}
else if (homes.size() == 1 && player.equals(user))
{
@ -59,7 +61,7 @@ public class Commandhome extends EssentialsCommand
}
else
{
user.sendMessage(Util.format("homes", Util.joinList(homes)));
user.sendMessage(_("homes", Util.joinList(homes)));
}
}
throw new NoChargeException();

View File

@ -1,13 +1,12 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import org.bukkit.Server;
public class Commandignore extends EssentialsCommand
{
public Commandignore()
{
super("ignore");
@ -25,25 +24,24 @@ public class Commandignore extends EssentialsCommand
{
player = getPlayer(server, args, 0);
}
catch(NoSuchFieldException ex)
catch (NoSuchFieldException ex)
{
player = ess.getOfflineUser(args[0]);
}
if (player == null)
{
throw new Exception(Util.i18n("playerNotFound"));
throw new Exception(_("playerNotFound"));
}
final String name = player.getName();
if (user.isIgnoredPlayer(name)) {
if (user.isIgnoredPlayer(name))
{
user.setIgnoredPlayer(name, false);
user.sendMessage(Util.format("unignorePlayer", player.getName()));
user.sendMessage(_("unignorePlayer", player.getName()));
}
else
{
user.setIgnoredPlayer(name, true);
user.sendMessage(Util.format("ignorePlayer", player.getName()));
user.sendMessage(_("ignorePlayer", player.getName()));
}
}
}

View File

@ -1,7 +1,7 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import java.util.Arrays;
import org.bukkit.Server;
import org.bukkit.inventory.ItemStack;
@ -31,7 +31,7 @@ public class Commandinvsee extends EssentialsCommand
{
invUser.getInventory().setContents(user.getSavedInventory());
user.setSavedInventory(null);
user.sendMessage(Util.i18n("invRestored"));
user.sendMessage(_("invRestored"));
throw new NoChargeException();
}
@ -41,15 +41,17 @@ public class Commandinvsee extends EssentialsCommand
}
ItemStack[] invUserStack = invUser.getInventory().getContents();
final int userStackLength = user.getInventory().getContents().length;
if (invUserStack.length < userStackLength) {
if (invUserStack.length < userStackLength)
{
invUserStack = Arrays.copyOf(invUserStack, userStackLength);
}
if (invUserStack.length > userStackLength) {
throw new Exception(Util.i18n("invBigger"));
if (invUserStack.length > userStackLength)
{
throw new Exception(_("invBigger"));
}
user.getInventory().setContents(invUserStack);
user.sendMessage(Util.format("invSee", invUser.getDisplayName()));
user.sendMessage(Util.i18n("invSeeHelp"));
user.sendMessage(_("invSee", invUser.getDisplayName()));
user.sendMessage(_("invSeeHelp"));
throw new NoChargeException();
}
}

View File

@ -1,7 +1,8 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import java.util.Locale;
import org.bukkit.Material;
import org.bukkit.Server;
import org.bukkit.inventory.ItemStack;
@ -23,7 +24,7 @@ public class Commanditem extends EssentialsCommand
}
final ItemStack stack = ess.getItemDb().get(args[0]);
final String itemname = stack.getType().toString().toLowerCase().replace("_", "");
final String itemname = stack.getType().toString().toLowerCase(Locale.ENGLISH).replace("_", "");
if (ess.getSettings().permissionBasedItemSpawn()
? (!user.isAuthorized("essentials.itemspawn.item-all")
&& !user.isAuthorized("essentials.itemspawn.item-" + itemname)
@ -31,7 +32,7 @@ public class Commanditem extends EssentialsCommand
: (!user.isAuthorized("essentials.itemspawn.exempt")
&& !user.canSpawnItem(stack.getTypeId())))
{
throw new Exception(Util.format("cantSpawnItem", itemname));
throw new Exception(_("cantSpawnItem", itemname));
}
if (args.length > 1 && Integer.parseInt(args[1]) > 0)
@ -41,11 +42,11 @@ public class Commanditem extends EssentialsCommand
if (stack.getType() == Material.AIR)
{
throw new Exception(Util.format("cantSpawnItem", "Air"));
throw new Exception(_("cantSpawnItem", "Air"));
}
final String displayName = stack.getType().toString().toLowerCase().replace('_', ' ');
user.sendMessage(Util.format("itemSpawn", stack.getAmount(), displayName));
final String displayName = stack.getType().toString().toLowerCase(Locale.ENGLISH).replace('_', ' ');
user.sendMessage(_("itemSpawn", stack.getAmount(), displayName));
user.getInventory().addItem(stack);
user.updateInventory();
}

View File

@ -1,9 +1,9 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.TargetBlock;
import com.earth2me.essentials.Trade;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import org.bukkit.Location;
import org.bukkit.Server;
@ -34,7 +34,7 @@ public class Commandjump extends EssentialsCommand
}
catch (NullPointerException ex)
{
throw new Exception(Util.i18n("jumpError"), ex);
throw new Exception(_("jumpError"), ex);
}
final Trade charge = new Trade(this.getName(), ess);

View File

@ -1,8 +1,8 @@
package com.earth2me.essentials.commands;
import com.earth2me.essentials.Console;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@ -26,18 +26,18 @@ public class Commandkick extends EssentialsCommand
final User user = getPlayer(server, args, 0);
if (user.isAuthorized("essentials.kick.exempt"))
{
throw new Exception(Util.i18n("kickExempt"));
throw new Exception(_("kickExempt"));
}
final String kickReason = args.length > 1 ? getFinalArg(args, 1) : Util.i18n("kickDefault");
final String kickReason = args.length > 1 ? getFinalArg(args, 1) : _("kickDefault");
user.kickPlayer(kickReason);
final String senderName = sender instanceof Player ? ((Player)sender).getDisplayName() : Console.NAME;
for(Player onlinePlayer : server.getOnlinePlayers())
for (Player onlinePlayer : server.getOnlinePlayers())
{
User player = ess.getUser(onlinePlayer);
if(player.isAuthorized("essentials.kick.notify"))
if (player.isAuthorized("essentials.kick.notify"))
{
onlinePlayer.sendMessage(Util.format("playerKicked", senderName, user.getName(), kickReason));
onlinePlayer.sendMessage(_("playerKicked", senderName, user.getName(), kickReason));
}
}
}

View File

@ -1,6 +1,6 @@
package com.earth2me.essentials.commands;
import com.earth2me.essentials.Util;
import static com.earth2me.essentials.I18n._;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@ -24,7 +24,7 @@ public class Commandkickall extends EssentialsCommand
}
else
{
onlinePlayer.kickPlayer(args.length > 0 ? getFinalArg(args, 0) : Util.i18n("kickDefault"));
onlinePlayer.kickPlayer(args.length > 0 ? getFinalArg(args, 0) : _("kickDefault"));
}
}
}

View File

@ -1,6 +1,6 @@
package com.earth2me.essentials.commands;
import com.earth2me.essentials.Util;
import static com.earth2me.essentials.I18n._;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@ -32,7 +32,7 @@ public class Commandkill extends EssentialsCommand
}
matchPlayer.setHealth(0);
sender.sendMessage(Util.format("kill", matchPlayer.getDisplayName()));
sender.sendMessage(_("kill", matchPlayer.getDisplayName()));
}
}
}

View File

@ -1,5 +1,6 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.Trade;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
@ -27,36 +28,36 @@ public class Commandkit extends EssentialsCommand
final StringBuilder list = new StringBuilder();
for (String kiteItem : kits.keySet())
{
if (user.isAuthorized("essentials.kit." + kiteItem.toLowerCase()))
if (user.isAuthorized("essentials.kit." + kiteItem.toLowerCase(Locale.ENGLISH)))
{
list.append(" ").append(kiteItem);
}
}
if (list.length() > 0)
{
user.sendMessage(Util.format("kits", list.toString()));
user.sendMessage(_("kits", list.toString()));
}
else
{
user.sendMessage(Util.i18n("noKits"));
user.sendMessage(_("noKits"));
}
}
catch (Exception ex)
{
user.sendMessage(Util.i18n("kitError"));
user.sendMessage(_("kitError"));
}
}
else
{
try
{
final String kitName = args[0].toLowerCase();
final String kitName = args[0].toLowerCase(Locale.ENGLISH);
final Object kit = ess.getSettings().getKit(kitName);
List<String> items;
if (!user.isAuthorized("essentials.kit." + kitName))
{
user.sendMessage(Util.format("noKitPermission", "essentials.kit." + kitName));
user.sendMessage(_("noKitPermission", "essentials.kit." + kitName));
return;
}
@ -69,20 +70,23 @@ public class Commandkit extends EssentialsCommand
final double delay = els.containsKey("delay") ? ((Number)els.get("delay")).doubleValue() : 0L;
final Calendar c = new GregorianCalendar();
c.add(Calendar.SECOND, -(int)delay);
c.add(Calendar.MILLISECOND, -(int)((delay*1000.0)%1000.0));
c.add(Calendar.MILLISECOND, -(int)((delay * 1000.0) % 1000.0));
final long mintime = c.getTimeInMillis();
final Long lastTime = user.getKitTimestamp(kitName);
if (lastTime == null || lastTime < mintime) {
if (lastTime == null || lastTime < mintime)
{
final Calendar now = new GregorianCalendar();
user.setKitTimestamp(kitName, now.getTimeInMillis());
} else {
}
else
{
final Calendar future = new GregorianCalendar();
future.setTimeInMillis(lastTime);
future.add(Calendar.SECOND, (int)delay);
future.add(Calendar.MILLISECOND, (int)((delay*1000.0)%1000.0));
user.sendMessage(Util.format("kitTimed", Util.formatDateDiff(future.getTimeInMillis())));
future.add(Calendar.MILLISECOND, (int)((delay * 1000.0) % 1000.0));
user.sendMessage(_("kitTimed", Util.formatDateDiff(future.getTimeInMillis())));
return;
}
}
@ -109,7 +113,7 @@ public class Commandkit extends EssentialsCommand
final int id = Material.getMaterial(Integer.parseInt(parts[0])).getId();
final int amount = parts.length > 1 ? Integer.parseInt(parts[parts.length > 2 ? 2 : 1]) : 1;
final short data = parts.length > 2 ? Short.parseShort(parts[1]) : 0;
final HashMap<Integer,ItemStack> overfilled = user.getInventory().addItem(new ItemStack(id, amount, data));
final HashMap<Integer, ItemStack> overfilled = user.getInventory().addItem(new ItemStack(id, amount, data));
for (ItemStack itemStack : overfilled.values())
{
user.getWorld().dropItemNaturally(user.getLocation(), itemStack);
@ -118,7 +122,7 @@ public class Commandkit extends EssentialsCommand
}
if (spew)
{
user.sendMessage(Util.i18n("kitInvFull"));
user.sendMessage(_("kitInvFull"));
}
try
{
@ -128,12 +132,12 @@ public class Commandkit extends EssentialsCommand
{
user.sendMessage(ex.getMessage());
}
user.sendMessage(Util.format("kitGive", kitName));
user.sendMessage(_("kitGive", kitName));
}
catch (Exception ex)
{
user.sendMessage(Util.i18n("kitError2"));
user.sendMessage(Util.i18n("kitErrorHelp"));
user.sendMessage(_("kitError2"));
user.sendMessage(_("kitErrorHelp"));
}
}
}

View File

@ -1,7 +1,7 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@ -31,19 +31,20 @@ public class Commandlightning extends EssentialsCommand
if (server.matchPlayer(args[0]).isEmpty())
{
throw new Exception(Util.i18n("playerNotFound"));
throw new Exception(_("playerNotFound"));
}
for (Player matchPlayer : server.matchPlayer(args[0]))
{
sender.sendMessage(Util.format("lightningUse", matchPlayer.getDisplayName()));
sender.sendMessage(_("lightningUse", matchPlayer.getDisplayName()));
matchPlayer.getWorld().strikeLightning(matchPlayer.getLocation());
if (!ess.getUser(matchPlayer).isGodModeEnabled()) {
if (!ess.getUser(matchPlayer).isGodModeEnabled())
{
matchPlayer.setHealth(matchPlayer.getHealth() < 5 ? 0 : matchPlayer.getHealth() - 5);
}
if (ess.getSettings().warnOnSmite())
{
matchPlayer.sendMessage(Util.i18n("lightningSmited"));
matchPlayer.sendMessage(_("lightningSmited"));
}
}
}

View File

@ -1,7 +1,7 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import java.util.*;
import org.bukkit.ChatColor;
import org.bukkit.Server;
@ -117,7 +117,7 @@ public class Commandlist extends EssentialsCommand
Collections.sort(users);
final StringBuilder onlineUsers = new StringBuilder();
onlineUsers.append(Util.i18n("connectedPlayers"));
onlineUsers.append(_("connectedPlayers"));
boolean first = true;
for (User user : users)
{

View File

@ -1,7 +1,7 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import java.util.List;
import org.bukkit.ChatColor;
import org.bukkit.Server;
@ -25,21 +25,21 @@ public class Commandmail extends EssentialsCommand
final List<String> mail = user.getMails();
if (mail.isEmpty())
{
user.sendMessage(Util.i18n("noMail"));
user.sendMessage(_("noMail"));
throw new NoChargeException();
}
for (String messages : mail)
{
user.sendMessage(messages);
}
user.sendMessage(Util.i18n("mailClear"));
user.sendMessage(_("mailClear"));
return;
}
if (args.length >= 3 && "send".equalsIgnoreCase(args[0]))
{
if (!user.isAuthorized("essentials.mail.send"))
{
throw new Exception(Util.i18n("noMailSendPerm"));
throw new Exception(_("noMailSendPerm"));
}
Player player = server.getPlayer(args[1]);
@ -54,19 +54,19 @@ public class Commandmail extends EssentialsCommand
}
if (u == null)
{
throw new Exception(Util.format("playerNeverOnServer", args[1]));
throw new Exception(_("playerNeverOnServer", args[1]));
}
if (!u.isIgnoredPlayer(user.getName()))
{
u.addMail(ChatColor.stripColor(user.getDisplayName()) + ": " + getFinalArg(args, 2));
}
user.sendMessage(Util.i18n("mailSent"));
user.sendMessage(_("mailSent"));
return;
}
if (args.length >= 1 && "clear".equalsIgnoreCase(args[0]))
{
user.setMails(null);
user.sendMessage(Util.i18n("mailCleared"));
user.sendMessage(_("mailCleared"));
return;
}
throw new NotEnoughArgumentsException();
@ -77,11 +77,11 @@ public class Commandmail extends EssentialsCommand
{
if (args.length >= 1 && "read".equalsIgnoreCase(args[0]))
{
throw new Exception(Util.format("onlyPlayers", commandLabel + " read"));
throw new Exception(_("onlyPlayers", commandLabel + " read"));
}
else if (args.length >= 1 && "clear".equalsIgnoreCase(args[0]))
{
throw new Exception(Util.format("onlyPlayers", commandLabel + " clear"));
throw new Exception(_("onlyPlayers", commandLabel + " clear"));
}
else if (args.length >= 3 && "send".equalsIgnoreCase(args[0]))
{
@ -97,10 +97,10 @@ public class Commandmail extends EssentialsCommand
}
if (u == null)
{
throw new Exception(Util.format("playerNeverOnServer", args[1]));
throw new Exception(_("playerNeverOnServer", args[1]));
}
u.addMail("Server: " + getFinalArg(args, 2));
sender.sendMessage(Util.i18n("mailSent"));
sender.sendMessage(_("mailSent"));
return;
}
else if (args.length >= 2)
@ -118,10 +118,10 @@ public class Commandmail extends EssentialsCommand
}
if (u == null)
{
throw new Exception(Util.format("playerNeverOnServer", args[0]));
throw new Exception(_("playerNeverOnServer", args[0]));
}
u.addMail("Server: " + getFinalArg(args, 1));
sender.sendMessage(Util.i18n("mailSent"));
sender.sendMessage(_("mailSent"));
return;
}
throw new NotEnoughArgumentsException();

View File

@ -1,7 +1,7 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import org.bukkit.Server;
@ -17,7 +17,7 @@ public class Commandme extends EssentialsCommand
{
if (user.isMuted())
{
throw new Exception(Util.i18n("voiceSilenced"));
throw new Exception(_("voiceSilenced"));
}
if (args.length < 1)
@ -31,6 +31,6 @@ public class Commandme extends EssentialsCommand
message = message.replaceAll("&([0-9a-f])", "§$1");
}
ess.broadcastMessage(user, Util.format("action", user.getDisplayName(), message));
ess.broadcastMessage(user, _("action", user.getDisplayName(), message));
}
}

View File

@ -1,9 +1,9 @@
package com.earth2me.essentials.commands;
import com.earth2me.essentials.Console;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.IReplyTo;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import java.util.List;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
@ -30,21 +30,21 @@ public class Commandmsg extends EssentialsCommand
User user = ess.getUser(sender);
if (user.isMuted())
{
throw new Exception(Util.i18n("voiceSilenced"));
throw new Exception(_("voiceSilenced"));
}
}
String message = getFinalArg(args, 1);
String translatedMe = Util.i18n("me");
String translatedMe = _("me");
IReplyTo replyTo = sender instanceof Player ? ess.getUser((Player)sender) : Console.getConsoleReplyTo();
String senderName = sender instanceof Player ? ((Player)sender).getDisplayName() : Console.NAME;
if (args[0].equalsIgnoreCase(Console.NAME))
{
sender.sendMessage(Util.format("msgFormat", translatedMe, Console.NAME, message));
sender.sendMessage(_("msgFormat", translatedMe, Console.NAME, message));
CommandSender cs = Console.getCommandSender(server);
cs.sendMessage(Util.format("msgFormat", senderName, translatedMe, message));
cs.sendMessage(_("msgFormat", senderName, translatedMe, message));
replyTo.setReplyTo(cs);
Console.getConsoleReplyTo().setReplyTo(sender);
return;
@ -54,7 +54,7 @@ public class Commandmsg extends EssentialsCommand
if (matches.isEmpty())
{
throw new Exception(Util.i18n("playerNotFound"));
throw new Exception(_("playerNotFound"));
}
int i = 0;
@ -68,18 +68,18 @@ public class Commandmsg extends EssentialsCommand
}
if (i == matches.size())
{
throw new Exception(Util.i18n("playerNotFound"));
throw new Exception(_("playerNotFound"));
}
for (Player p : matches)
{
sender.sendMessage(Util.format("msgFormat", translatedMe, p.getDisplayName(), message));
sender.sendMessage(_("msgFormat", translatedMe, p.getDisplayName(), message));
final User u = ess.getUser(p);
if (sender instanceof Player && (u.isIgnoredPlayer(((Player)sender).getName()) || u.isHidden()))
{
continue;
}
p.sendMessage(Util.format("msgFormat", senderName, translatedMe, message));
p.sendMessage(_("msgFormat", senderName, translatedMe, message));
replyTo.setReplyTo(ess.getUser(p));
ess.getUser(p).setReplyTo(sender);
}

View File

@ -1,5 +1,6 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import org.bukkit.Server;
@ -24,7 +25,7 @@ public class Commandmute extends EssentialsCommand
final User player = getPlayer(server, args, 0, true);
if (!player.isMuted() && player.isAuthorized("essentials.mute.exempt"))
{
throw new Exception(Util.i18n("muteExempt"));
throw new Exception(_("muteExempt"));
}
long muteTimestamp = 0;
if (args.length > 1)
@ -37,14 +38,14 @@ public class Commandmute extends EssentialsCommand
sender.sendMessage(
muted
? (muteTimestamp > 0
? Util.format("mutedPlayerFor", player.getDisplayName(), Util.formatDateDiff(muteTimestamp))
: Util.format("mutedPlayer", player.getDisplayName()))
: Util.format("unmutedPlayer", player.getDisplayName()));
? _("mutedPlayerFor", player.getDisplayName(), Util.formatDateDiff(muteTimestamp))
: _("mutedPlayer", player.getDisplayName()))
: _("unmutedPlayer", player.getDisplayName()));
player.sendMessage(
muted
? (muteTimestamp > 0
? Util.format("playerMutedFor", Util.formatDateDiff(muteTimestamp))
: Util.i18n("playerMuted"))
: Util.i18n("playerUnmuted"));
? _("playerMutedFor", Util.formatDateDiff(muteTimestamp))
: _("playerMuted"))
: _("playerUnmuted"));
}
}

View File

@ -1,7 +1,8 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import java.util.Locale;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@ -23,16 +24,16 @@ public class Commandnick extends EssentialsCommand
}
if (!ess.getSettings().changeDisplayName())
{
throw new Exception(Util.i18n("nickDisplayName"));
throw new Exception(_("nickDisplayName"));
}
if (args.length > 1)
{
if (!user.isAuthorized("essentials.nick.others"))
{
throw new Exception(Util.i18n("nickOthersPermission"));
throw new Exception(_("nickOthersPermission"));
}
setNickname(server, getPlayer(server, args, 0), args[1]);
user.sendMessage(Util.i18n("nickChanged"));
user.sendMessage(_("nickChanged"));
return;
}
setNickname(server, user, args[0]);
@ -47,23 +48,23 @@ public class Commandnick extends EssentialsCommand
}
if (!ess.getSettings().changeDisplayName())
{
throw new Exception(Util.i18n("nickDisplayName"));
throw new Exception(_("nickDisplayName"));
}
setNickname(server, getPlayer(server, args, 0), args[1]);
sender.sendMessage(Util.i18n("nickChanged"));
sender.sendMessage(_("nickChanged"));
}
private void setNickname(final Server server, final User target, final String nick) throws Exception
{
if (nick.matches("[^a-zA-Z_0-9]"))
{
throw new Exception(Util.i18n("nickNamesAlpha"));
throw new Exception(_("nickNamesAlpha"));
}
else if ("off".equalsIgnoreCase(nick) || target.getName().equalsIgnoreCase(nick))
{
target.setNickname(null);
target.setDisplayNick();
target.sendMessage(Util.i18n("nickNoMore"));
target.sendMessage(_("nickNoMore"));
}
else
{
@ -74,18 +75,18 @@ public class Commandnick extends EssentialsCommand
{
continue;
}
String dn = p.getDisplayName().toLowerCase();
String n = p.getName().toLowerCase();
String nk = formattedNick.toLowerCase();
String dn = p.getDisplayName().toLowerCase(Locale.ENGLISH);
String n = p.getName().toLowerCase(Locale.ENGLISH);
String nk = formattedNick.toLowerCase(Locale.ENGLISH);
if (nk.equals(dn) || nk.equals(n))
{
throw new Exception(Util.i18n("nickInUse"));
throw new Exception(_("nickInUse"));
}
}
target.setNickname(formattedNick);
target.setDisplayNick();
target.sendMessage(Util.format("nickSet", target.getDisplayName() + "§7."));
target.sendMessage(_("nickSet", target.getDisplayName() + "§7."));
}
}
}

View File

@ -22,7 +22,7 @@ public class Commandnuke extends EssentialsCommand
protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws NoSuchFieldException, NotEnoughArgumentsException
{
List<Player> targets;
if (args.length > 0)
if (args.length > 0)
{
targets = new ArrayList<Player>();
int pos = 0;
@ -34,14 +34,15 @@ public class Commandnuke extends EssentialsCommand
}
else
{
targets = Arrays.asList(server.getOnlinePlayers());
targets = Arrays.asList(server.getOnlinePlayers());
}
ess.getTNTListener().enable();
for (Player player : targets)
{
if (player == null) {
if (player == null)
{
continue;
}
}
player.sendMessage("May death rain upon them");
final Location loc = player.getLocation();
final World world = loc.getWorld();

View File

@ -1,7 +1,7 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import org.bukkit.Server;
import org.bukkit.entity.Player;
@ -34,9 +34,10 @@ public class Commandpay extends EssentialsCommand
user.payUser(u, amount);
foundUser = true;
}
if(foundUser == false) {
throw new NoSuchFieldException(Util.i18n("playerNotFound"));
if (foundUser == false)
{
throw new NoSuchFieldException(_("playerNotFound"));
}
}
}

View File

@ -1,7 +1,7 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import org.bukkit.Server;
@ -15,6 +15,6 @@ public class Commandping extends EssentialsCommand
@Override
public void run(Server server, User player, String commandLabel, String[] args) throws Exception
{
player.sendMessage(Util.i18n("pong"));
player.sendMessage(_("pong"));
}
}

View File

@ -1,9 +1,11 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import org.bukkit.Material;
import org.bukkit.Server;
import org.bukkit.inventory.ItemStack;
@ -22,20 +24,20 @@ public class Commandpowertool extends EssentialsCommand
String command = getFinalArg(args, 0);
// check to see if this is a clear all command
if(command != null && command.equalsIgnoreCase("c:"))
if (command != null && command.equalsIgnoreCase("c:"))
{
user.clearAllPowertools();
user.sendMessage(Util.i18n("powerToolClearAll"));
user.sendMessage(_("powerToolClearAll"));
return;
}
final ItemStack itemStack = user.getItemInHand();
if (itemStack == null || itemStack.getType() == Material.AIR)
{
throw new Exception(Util.i18n("powerToolAir"));
throw new Exception(_("powerToolAir"));
}
final String itemName = itemStack.getType().toString().toLowerCase().replaceAll("_", " ");
final String itemName = itemStack.getType().toString().toLowerCase(Locale.ENGLISH).replaceAll("_", " ");
List<String> powertools = user.getPowertool(itemStack);
if (command != null && !command.isEmpty())
{
@ -43,11 +45,11 @@ public class Commandpowertool extends EssentialsCommand
{
if (powertools == null || powertools.isEmpty())
{
throw new Exception(Util.format("powerToolListEmpty", itemName));
throw new Exception(_("powerToolListEmpty", itemName));
}
else
{
user.sendMessage(Util.format("powerToolList", Util.joinList(powertools), itemName));
user.sendMessage(_("powerToolList", Util.joinList(powertools), itemName));
}
return;
}
@ -58,11 +60,11 @@ public class Commandpowertool extends EssentialsCommand
command = command.substring(2);
if (!powertools.contains(command))
{
throw new Exception(Util.format("powerToolNoSuchCommandAssigned", command, itemName));
throw new Exception(_("powerToolNoSuchCommandAssigned", command, itemName));
}
powertools.remove(command);
user.sendMessage(Util.format("powerToolRemove", command, itemName));
user.sendMessage(_("powerToolRemove", command, itemName));
}
catch (Exception e)
{
@ -77,7 +79,7 @@ public class Commandpowertool extends EssentialsCommand
command = command.substring(2);
if (powertools.contains(command))
{
throw new Exception(Util.format("powerToolAlreadySet", command, itemName));
throw new Exception(_("powerToolAlreadySet", command, itemName));
}
}
else if (powertools != null && !powertools.isEmpty())
@ -91,7 +93,7 @@ public class Commandpowertool extends EssentialsCommand
}
powertools.add(command);
user.sendMessage(Util.format("powerToolAttach", Util.joinList(powertools), itemName));
user.sendMessage(_("powerToolAttach", Util.joinList(powertools), itemName));
}
}
else
@ -100,7 +102,7 @@ public class Commandpowertool extends EssentialsCommand
{
powertools.clear();
}
user.sendMessage(Util.format("powerToolRemoveAll", itemName));
user.sendMessage(_("powerToolRemoveAll", itemName));
}
user.setPowertool(itemStack, powertools);

View File

@ -1,7 +1,7 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import org.bukkit.Server;
@ -15,15 +15,13 @@ public class Commandpowertooltoggle extends EssentialsCommand
@Override
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
{
if(!user.hasPowerTools())
if (!user.hasPowerTools())
{
user.sendMessage(Util.i18n("noPowerTools"));
user.sendMessage(_("noPowerTools"));
return;
}
}
user.sendMessage(user.togglePowerToolsEnabled()
? Util.i18n("powerToolsEnabled")
: Util.i18n("powerToolsDisabled"));
? _("powerToolsEnabled")
: _("powerToolsDisabled"));
}
}

View File

@ -1,8 +1,8 @@
package com.earth2me.essentials.commands;
import com.earth2me.essentials.DescParseTickFormat;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import java.util.*;
import org.bukkit.Server;
import org.bukkit.World;
@ -48,7 +48,7 @@ public class Commandptime extends EssentialsCommand
User user = ess.getUser(sender);
if ((!users.contains(user) || users.size() > 1) && user != null && !user.isAuthorized("essentials.ptime.others"))
{
user.sendMessage(Util.i18n("pTimeOthersPermission"));
user.sendMessage(_("pTimeOthersPermission"));
return;
}
@ -93,25 +93,25 @@ public class Commandptime extends EssentialsCommand
{
if (users.size() > 1)
{
sender.sendMessage(Util.format("pTimePlayers"));
sender.sendMessage(_("pTimePlayers"));
}
for (User user : users)
{
if (user.getPlayerTimeOffset() == 0)
{
sender.sendMessage(Util.format("pTimeNormal", user.getName()));
sender.sendMessage(_("pTimeNormal", user.getName()));
}
else
{
String time = DescParseTickFormat.format(user.getPlayerTime());
if (!user.isPlayerTimeRelative())
{
sender.sendMessage(Util.format("pTimeCurrentFixed", user.getName(), time));
sender.sendMessage(_("pTimeCurrentFixed", user.getName(), time));
}
else
{
sender.sendMessage(Util.format("pTimeCurrent", user.getName(), time));
sender.sendMessage(_("pTimeCurrent", user.getName(), time));
}
}
}
@ -162,18 +162,18 @@ public class Commandptime extends EssentialsCommand
// Inform the sender of the change
if (ticks == null)
{
sender.sendMessage(Util.format("pTimeReset", msg.toString()));
sender.sendMessage(_("pTimeReset", msg.toString()));
}
else
{
String time = DescParseTickFormat.format(ticks);
if (!relative)
{
sender.sendMessage(Util.format("pTimeSetFixed", time, msg.toString()));
sender.sendMessage(_("pTimeSetFixed", time, msg.toString()));
}
else
{
sender.sendMessage(Util.format("pTimeSet", time, msg.toString()));
sender.sendMessage(_("pTimeSet", time, msg.toString()));
}
}
}
@ -225,7 +225,7 @@ public class Commandptime extends EssentialsCommand
// We failed to understand the world target...
else
{
throw new Exception(Util.i18n("playerNotFound"));
throw new Exception(_("playerNotFound"));
}
return users;

View File

@ -1,9 +1,9 @@
package com.earth2me.essentials.commands;
import com.earth2me.essentials.Console;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.IReplyTo;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@ -32,10 +32,10 @@ public class Commandr extends EssentialsCommand
if (target == null)
{
throw new Exception(Util.i18n("foreverAlone"));
throw new Exception(_("foreverAlone"));
}
sender.sendMessage(Util.format("msgFormat", Util.i18n("me"), targetName, message));
sender.sendMessage(_("msgFormat", _("me"), targetName, message));
if (target instanceof Player)
{
User u = ess.getUser(target);
@ -44,7 +44,7 @@ public class Commandr extends EssentialsCommand
return;
}
}
target.sendMessage(Util.format("msgFormat", senderName, Util.i18n("me"), message));
target.sendMessage(_("msgFormat", senderName, _("me"), message));
replyTo.setReplyTo(target);
if (target != sender)
{

View File

@ -1,7 +1,8 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import java.util.Locale;
import org.bukkit.ChatColor;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
@ -22,7 +23,7 @@ public class Commandrealname extends EssentialsCommand
{
throw new NotEnoughArgumentsException();
}
final String whois = args[0].toLowerCase();
final String whois = args[0].toLowerCase(Locale.ENGLISH);
for (Player p : server.getOnlinePlayers())
{
final User u = ess.getUser(p);
@ -30,14 +31,14 @@ public class Commandrealname extends EssentialsCommand
{
continue;
}
final String displayName = ChatColor.stripColor(u.getDisplayName()).toLowerCase();
final String displayName = ChatColor.stripColor(u.getDisplayName()).toLowerCase(Locale.ENGLISH);
if (!whois.equals(displayName)
&& !displayName.equals(ChatColor.stripColor(ess.getSettings().getNicknamePrefix()) + whois)
&& !whois.equalsIgnoreCase(u.getName()))
{
continue;
}
sender.sendMessage(u.getDisplayName() + " " + Util.i18n("is") + " " + u.getName());
sender.sendMessage(u.getDisplayName() + " " + _("is") + " " + u.getName());
}
}
}

View File

@ -1,8 +1,10 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import org.bukkit.Material;
import org.bukkit.Server;
import org.bukkit.inventory.ItemStack;
@ -28,9 +30,9 @@ public class Commandrepair extends EssentialsCommand
final ItemStack item = user.getItemInHand();
if (item == null)
{
throw new Exception(Util.i18n("repairInvalidType"));
throw new Exception(_("repairInvalidType"));
}
final String itemName = item.getType().toString().toLowerCase();
final String itemName = item.getType().toString().toLowerCase(Locale.ENGLISH);
final Trade charge = new Trade("repair-" + itemName.replace('_', '-'), ess);
charge.isAffordableFor(user);
@ -39,24 +41,25 @@ public class Commandrepair extends EssentialsCommand
charge.charge(user);
user.sendMessage(Util.format("repair", itemName.replace('_', ' ')));
user.sendMessage(_("repair", itemName.replace('_', ' ')));
}
else if (args[0].equalsIgnoreCase("all"))
{
final List<String> repaired = new ArrayList<String>();
repairItems(user.getInventory().getContents(), user, repaired);
if (user.isAuthorized("essentials.repair.armor")) {
if (user.isAuthorized("essentials.repair.armor"))
{
repairItems(user.getInventory().getArmorContents(), user, repaired);
}
if (repaired.isEmpty())
{
throw new Exception(Util.format("repairNone"));
throw new Exception(_("repairNone"));
}
else
{
user.sendMessage(Util.format("repair", Util.joinList(repaired)));
user.sendMessage(_("repair", Util.joinList(repaired)));
}
}
@ -71,12 +74,12 @@ public class Commandrepair extends EssentialsCommand
final Material material = Material.getMaterial(item.getTypeId());
if (material.isBlock() || material.getMaxDurability() < 0)
{
throw new Exception(Util.i18n("repairInvalidType"));
throw new Exception(_("repairInvalidType"));
}
if (item.getDurability() == 0)
{
throw new Exception(Util.i18n("repairAlreadyFixed"));
throw new Exception(_("repairAlreadyFixed"));
}
item.setDurability((short)0);
@ -90,7 +93,7 @@ public class Commandrepair extends EssentialsCommand
{
continue;
}
final String itemName = item.getType().toString().toLowerCase();
final String itemName = item.getType().toString().toLowerCase(Locale.ENGLISH);
final Trade charge = new Trade("repair-" + itemName.replace('_', '-'), ess);
try
{

View File

@ -1,5 +1,6 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import org.bukkit.Server;
@ -23,16 +24,16 @@ public class Commandseen extends EssentialsCommand
try
{
User u = getPlayer(server, args, 0);
sender.sendMessage(Util.format("seenOnline",u.getDisplayName(), Util.formatDateDiff(u.getLastLogin())));
sender.sendMessage(_("seenOnline", u.getDisplayName(), Util.formatDateDiff(u.getLastLogin())));
}
catch (NoSuchFieldException e)
{
User u = ess.getOfflineUser(args[0]);
if (u == null)
{
throw new Exception(Util.i18n("playerNotFound"));
throw new Exception(_("playerNotFound"));
}
sender.sendMessage(Util.format("seenOffline", u.getDisplayName(), Util.formatDateDiff(u.getLastLogout())));
sender.sendMessage(_("seenOffline", u.getDisplayName(), Util.formatDateDiff(u.getLastLogout())));
}
}
}

View File

@ -1,9 +1,11 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.InventoryWorkaround;
import com.earth2me.essentials.Trade;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import java.util.Locale;
import java.util.logging.Level;
import org.bukkit.Material;
import org.bukkit.Server;
@ -76,7 +78,7 @@ public class Commandsell extends EssentialsCommand
{
if (is == null || is.getType() == Material.AIR)
{
throw new Exception(Util.i18n("itemSellAir"));
throw new Exception(_("itemSellAir"));
}
int id = is.getTypeId();
int amount = 0;
@ -94,11 +96,11 @@ public class Commandsell extends EssentialsCommand
if (Double.isNaN(worth))
{
throw new Exception(Util.i18n("itemCannotBeSold"));
throw new Exception(_("itemCannotBeSold"));
}
if (requireStack && !stack)
{
throw new Exception(Util.i18n("itemMustBeStacked"));
throw new Exception(_("itemMustBeStacked"));
}
@ -137,9 +139,9 @@ public class Commandsell extends EssentialsCommand
{
if (!isBulkSell)
{
user.sendMessage(Util.i18n("itemNotEnough1"));
user.sendMessage(Util.i18n("itemNotEnough2"));
throw new Exception(Util.i18n("itemNotEnough3"));
user.sendMessage(_("itemNotEnough1"));
user.sendMessage(_("itemNotEnough2"));
throw new Exception(_("itemNotEnough3"));
}
else
{
@ -152,8 +154,8 @@ public class Commandsell extends EssentialsCommand
user.updateInventory();
Trade.log("Command", "Sell", "Item", user.getName(), new Trade(ris, ess), user.getName(), new Trade(worth * amount, ess), user.getLocation(), ess);
user.giveMoney(worth * amount);
user.sendMessage(Util.format("itemSold", Util.formatCurrency(worth * amount, ess), amount, is.getType().toString().toLowerCase(), Util.formatCurrency(worth, ess)));
logger.log(Level.INFO, Util.format("itemSoldConsole", user.getDisplayName(), is.getType().toString().toLowerCase(), Util.formatCurrency(worth * amount, ess), amount, Util.formatCurrency(worth, ess)));
user.sendMessage(_("itemSold", Util.formatCurrency(worth * amount, ess), amount, is.getType().toString().toLowerCase(Locale.ENGLISH), Util.formatCurrency(worth, ess)));
logger.log(Level.INFO, _("itemSoldConsole", user.getDisplayName(), is.getType().toString().toLowerCase(Locale.ENGLISH), Util.formatCurrency(worth * amount, ess), amount, Util.formatCurrency(worth, ess)));
}
}

View File

@ -1,7 +1,8 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import java.util.Locale;
import org.bukkit.Server;
@ -29,18 +30,19 @@ public class Commandsethome extends EssentialsCommand
if (user.isAuthorized("essentials.sethome.multiple"))
{
if ((user.isAuthorized("essentials.sethome.multiple.unlimited")) || (user.getHomes().size() < ess.getSettings().getHomeLimit(user))
|| (user.getHomes().contains(args[0].toLowerCase())))
|| (user.getHomes().contains(args[0].toLowerCase(Locale.ENGLISH))))
{
user.setHome(args[0].toLowerCase());
user.setHome(args[0].toLowerCase(Locale.ENGLISH));
}
else
{
throw new Exception(Util.format("maxHomes", ess.getSettings().getHomeLimit(user)));
throw new Exception(_("maxHomes", ess.getSettings().getHomeLimit(user)));
}
}
else {
throw new Exception(Util.format("maxHomes", 1));
else
{
throw new Exception(_("maxHomes", 1));
}
}
else
@ -54,9 +56,9 @@ public class Commandsethome extends EssentialsCommand
}
if (usersHome == null)
{
throw new Exception(Util.i18n("playerNotFound"));
throw new Exception(_("playerNotFound"));
}
String name = args[1].toLowerCase();
String name = args[1].toLowerCase(Locale.ENGLISH);
if (!user.isAuthorized("essentials.sethome.multiple"))
{
name = "home";
@ -69,7 +71,7 @@ public class Commandsethome extends EssentialsCommand
{
user.setHome();
}
user.sendMessage(Util.i18n("homeSet"));
user.sendMessage(_("homeSet"));
}
}

View File

@ -1,7 +1,7 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import org.bukkit.Server;
@ -11,7 +11,7 @@ public class Commandsetjail extends EssentialsCommand
{
super("setjail");
}
@Override
public void run(Server server, User user, String commandLabel, String[] args) throws Exception
{
@ -20,7 +20,7 @@ public class Commandsetjail extends EssentialsCommand
throw new NotEnoughArgumentsException();
}
ess.getJail().setJail(user.getLocation(), args[0]);
user.sendMessage(Util.format("jailSet",args[0]));
user.sendMessage(_("jailSet", args[0]));
}
}

View File

@ -1,7 +1,7 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import org.bukkit.Location;
import org.bukkit.Server;
@ -23,6 +23,6 @@ public class Commandsetwarp extends EssentialsCommand
Location loc = user.getLocation();
ess.getWarps().setWarp(args[0], loc);
user.sendMessage(Util.format("warpSet", args[0]));
user.sendMessage(_("warpSet", args[0]));
}
}

View File

@ -1,7 +1,7 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import org.bukkit.Server;
import org.bukkit.inventory.ItemStack;
@ -23,6 +23,6 @@ public class Commandsetworth extends EssentialsCommand
ItemStack stack = ess.getItemDb().get(args[0]);
ess.getWorth().setPrice(stack, Double.parseDouble(args[1]));
user.sendMessage(Util.i18n("worthSet"));
user.sendMessage(_("worthSet"));
}
}

View File

@ -1,8 +1,8 @@
package com.earth2me.essentials.commands;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import org.bukkit.Server;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import org.bukkit.Server;
public class Commandsocialspy extends EssentialsCommand
@ -15,6 +15,6 @@ public class Commandsocialspy extends EssentialsCommand
@Override
public void run(Server server, User user, String commandLabel, String[] args) throws Exception
{
user.sendMessage("§7SocialSpy " + (user.toggleSocialSpy() ? Util.i18n("enabled") : Util.i18n("disabled")));
user.sendMessage("§7SocialSpy " + (user.toggleSocialSpy() ? _("enabled") : _("disabled")));
}
}

View File

@ -1,8 +1,8 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.Mob;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import org.bukkit.Material;
import org.bukkit.Server;
import org.bukkit.block.Block;
@ -28,7 +28,7 @@ public class Commandspawner extends EssentialsCommand
final Block target = user.getTarget().getTargetBlock();
if (target.getType() != Material.MOB_SPAWNER)
{
throw new Exception(Util.i18n("mobSpawnTarget"));
throw new Exception(_("mobSpawnTarget"));
}
try
@ -39,15 +39,15 @@ public class Commandspawner extends EssentialsCommand
mob = Mob.fromName(name);
if (mob == null)
{
user.sendMessage(Util.i18n("invalidMob"));
user.sendMessage(_("invalidMob"));
return;
}
((CreatureSpawner)target.getState()).setCreatureType(mob.getType());
user.sendMessage(Util.format("setSpawner", mob.name));
user.sendMessage(_("setSpawner", mob.name));
}
catch (Throwable ex)
{
throw new Exception(Util.i18n("mobSpawnError"), ex);
throw new Exception(_("mobSpawnError"), ex);
}
}
}

View File

@ -1,9 +1,11 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.Mob;
import com.earth2me.essentials.Mob.MobException;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import java.util.Locale;
import java.util.Random;
import org.bukkit.DyeColor;
import org.bukkit.Location;
@ -58,18 +60,18 @@ public class Commandspawnmob extends EssentialsCommand
mob = Mob.fromName(mobType);
if (mob == null)
{
throw new Exception(Util.i18n("invalidMob"));
throw new Exception(_("invalidMob"));
}
if (ess.getSettings().getProtectPreventSpawn(mob.getType().toString().toLowerCase()))
if (ess.getSettings().getProtectPreventSpawn(mob.getType().toString().toLowerCase(Locale.ENGLISH)))
{
throw new Exception(Util.i18n("unableToSpawnMob"));
throw new Exception(_("unableToSpawnMob"));
}
final Block block = Util.getTarget(user).getBlock();
if (block == null)
{
throw new Exception(Util.i18n("unableToSpawnMob"));
throw new Exception(_("unableToSpawnMob"));
}
Location loc = block.getLocation();
Location sloc = Util.getSafeDestination(loc);
@ -79,7 +81,7 @@ public class Commandspawnmob extends EssentialsCommand
}
catch (MobException e)
{
throw new Exception(Util.i18n("unableToSpawnMob"));
throw new Exception(_("unableToSpawnMob"));
}
if (mountType != null)
@ -87,13 +89,13 @@ public class Commandspawnmob extends EssentialsCommand
mobMount = Mob.fromName(mountType);
if (mobMount == null)
{
user.sendMessage(Util.i18n("invalidMob"));
user.sendMessage(_("invalidMob"));
return;
}
if (ess.getSettings().getProtectPreventSpawn(mobMount.getType().toString().toLowerCase()))
if (ess.getSettings().getProtectPreventSpawn(mobMount.getType().toString().toLowerCase(Locale.ENGLISH)))
{
throw new Exception(Util.i18n("unableToSpawnMob"));
throw new Exception(_("unableToSpawnMob"));
}
try
{
@ -101,7 +103,7 @@ public class Commandspawnmob extends EssentialsCommand
}
catch (MobException e)
{
throw new Exception(Util.i18n("unableToSpawnMob"));
throw new Exception(_("unableToSpawnMob"));
}
spawnedMob.setPassenger(spawnedMount);
}
@ -120,7 +122,7 @@ public class Commandspawnmob extends EssentialsCommand
if (mobCount > serverLimit)
{
mobCount = serverLimit;
user.sendMessage(Util.i18n("mobSpawnLimit"));
user.sendMessage(_("mobSpawnLimit"));
}
try
@ -136,7 +138,7 @@ public class Commandspawnmob extends EssentialsCommand
}
catch (MobException e)
{
throw new Exception(Util.i18n("unableToSpawnMob"));
throw new Exception(_("unableToSpawnMob"));
}
spawnedMob.setPassenger(spawnedMount);
}
@ -149,24 +151,24 @@ public class Commandspawnmob extends EssentialsCommand
changeMobData(mobMount.name, spawnedMount, mountData, user);
}
}
user.sendMessage(args[1] + " " + mob.name.toLowerCase() + mob.suffix + " " + Util.i18n("spawned"));
user.sendMessage(args[1] + " " + mob.name.toLowerCase(Locale.ENGLISH) + mob.suffix + " " + _("spawned"));
}
catch (MobException e1)
{
throw new Exception(Util.i18n("unableToSpawnMob"), e1);
throw new Exception(_("unableToSpawnMob"), e1);
}
catch (NumberFormatException e2)
{
throw new Exception(Util.i18n("numberRequired"), e2);
throw new Exception(_("numberRequired"), e2);
}
catch (NullPointerException np)
{
throw new Exception(Util.i18n("soloMob"), np);
throw new Exception(_("soloMob"), np);
}
}
else
{
user.sendMessage(mob.name + " " + Util.i18n("spawned"));
user.sendMessage(mob.name + " " + _("spawned"));
}
}
@ -180,7 +182,7 @@ public class Commandspawnmob extends EssentialsCommand
}
catch (Exception e)
{
throw new Exception(Util.i18n("slimeMalformedSize"), e);
throw new Exception(_("slimeMalformedSize"), e);
}
}
if ("Sheep".equalsIgnoreCase(type))
@ -199,7 +201,7 @@ public class Commandspawnmob extends EssentialsCommand
}
catch (Exception e)
{
throw new Exception(Util.i18n("sheepMalformedColor"), e);
throw new Exception(_("sheepMalformedColor"), e);
}
}
if ("Wolf".equalsIgnoreCase(type) && data.equalsIgnoreCase("tamed"))

View File

@ -24,7 +24,8 @@ public class Commandsudo extends EssentialsCommand
final User user = getPlayer(server, args, 0, false);
final String command = args[1];
final String[] arguments = new String[args.length - 2];
if (arguments.length > 0) {
if (arguments.length > 0)
{
System.arraycopy(args, 2, arguments, 0, args.length - 2);
}

View File

@ -1,7 +1,7 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import org.bukkit.Server;
@ -16,8 +16,8 @@ public class Commandsuicide extends EssentialsCommand
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
{
user.setHealth(0);
user.sendMessage(Util.i18n("suicideMessage"));
user.sendMessage(_("suicideMessage"));
ess.broadcastMessage(user,
Util.format("suicideSuccess", user.getDisplayName()));
_("suicideSuccess", user.getDisplayName()));
}
}

View File

@ -1,6 +1,7 @@
package com.earth2me.essentials.commands;
import com.earth2me.essentials.Console;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.OfflinePlayer;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
@ -29,7 +30,7 @@ public class Commandtempban extends EssentialsCommand
if (sender instanceof Player
&& !ess.getUser(sender).isAuthorized("essentials.tempban.offline"))
{
sender.sendMessage(Util.i18n("tempbanExempt"));
sender.sendMessage(_("tempbanExempt"));
return;
}
}
@ -37,26 +38,26 @@ public class Commandtempban extends EssentialsCommand
{
if (user.isAuthorized("essentials.tempban.exempt"))
{
sender.sendMessage(Util.i18n("tempbanExempt"));
sender.sendMessage(_("tempbanExempt"));
return;
}
}
final String time = getFinalArg(args, 1);
final long banTimestamp = Util.parseDateDiff(time, true);
final String banReason = Util.format("tempBanned", Util.formatDateDiff(banTimestamp));
final String banReason = _("tempBanned", Util.formatDateDiff(banTimestamp));
user.setBanReason(banReason);
user.setBanTimeout(banTimestamp);
user.setBanned(true);
user.kickPlayer(banReason);
final String senderName = sender instanceof Player ? ((Player)sender).getDisplayName() : Console.NAME;
for(Player onlinePlayer : server.getOnlinePlayers())
for (Player onlinePlayer : server.getOnlinePlayers())
{
final User player = ess.getUser(onlinePlayer);
if(player.isAuthorized("essentials.ban.notify"))
if (player.isAuthorized("essentials.ban.notify"))
{
onlinePlayer.sendMessage(Util.format("playerBanned", senderName, user.getName(), banReason));
onlinePlayer.sendMessage(_("playerBanned", senderName, user.getName(), banReason));
}
}
}

View File

@ -1,7 +1,7 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import org.bukkit.Server;
import org.bukkit.World;
@ -28,13 +28,13 @@ public class Commandthunder extends EssentialsCommand
world.setThundering(setThunder ? true : false);
world.setThunderDuration(Integer.parseInt(args[1]) * 20);
user.sendMessage(Util.format("thunderDuration", (setThunder ? Util.i18n("enabled") : Util.i18n("disabled")), Integer.parseInt(args[1])));
user.sendMessage(_("thunderDuration", (setThunder ? _("enabled") : _("disabled")), Integer.parseInt(args[1])));
}
else
{
world.setThundering(setThunder ? true : false);
user.sendMessage(Util.format("thunder", setThunder ? Util.i18n("enabled") : Util.i18n("disabled")));
user.sendMessage(_("thunder", setThunder ? _("enabled") : _("disabled")));
}
}

View File

@ -1,8 +1,8 @@
package com.earth2me.essentials.commands;
import com.earth2me.essentials.DescParseTickFormat;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import java.util.*;
import org.bukkit.Server;
import org.bukkit.World;
@ -37,7 +37,7 @@ public class Commandtime extends EssentialsCommand
final User user = ess.getUser(sender);
if (user != null && !user.isAuthorized("essentials.time.set"))
{
user.sendMessage(Util.i18n("timeSetPermission"));
user.sendMessage(_("timeSetPermission"));
return;
}
@ -69,7 +69,7 @@ public class Commandtime extends EssentialsCommand
for (World world : worlds)
{
sender.sendMessage(Util.format("timeWorldCurrent", world.getName(), DescParseTickFormat.format(world.getTime())));
sender.sendMessage(_("timeWorldCurrent", world.getName(), DescParseTickFormat.format(world.getTime())));
}
}
@ -97,7 +97,7 @@ public class Commandtime extends EssentialsCommand
output.append(world.getName());
}
sender.sendMessage(Util.format("timeWorldSet", DescParseTickFormat.format(ticks), output.toString()));
sender.sendMessage(_("timeWorldSet", DescParseTickFormat.format(ticks), output.toString()));
}
/**
@ -136,7 +136,7 @@ public class Commandtime extends EssentialsCommand
// We failed to understand the world target...
else
{
throw new Exception(Util.i18n("invalidWorld"));
throw new Exception(_("invalidWorld"));
}
return worlds;

View File

@ -1,5 +1,6 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.OfflinePlayer;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
@ -32,7 +33,7 @@ public class Commandtogglejail extends EssentialsCommand
if (sender instanceof Player
&& !ess.getUser(sender).isAuthorized("essentials.togglejail.offline"))
{
sender.sendMessage(Util.i18n("mayNotJail"));
sender.sendMessage(_("mayNotJail"));
return;
}
}
@ -40,7 +41,7 @@ public class Commandtogglejail extends EssentialsCommand
{
if (player.isAuthorized("essentials.jail.exempt"))
{
sender.sendMessage(Util.i18n("mayNotJail"));
sender.sendMessage(_("mayNotJail"));
return;
}
}
@ -54,7 +55,7 @@ public class Commandtogglejail extends EssentialsCommand
ess.getJail().getJail(args[1]);
}
player.setJailed(true);
player.sendMessage(Util.i18n("userJailed"));
player.sendMessage(_("userJailed"));
player.setJail(null);
player.setJail(args[1]);
long timeDiff = 0;
@ -65,14 +66,14 @@ public class Commandtogglejail extends EssentialsCommand
player.setJailTimeout(timeDiff);
}
sender.sendMessage((timeDiff > 0
? Util.format("playerJailedFor", player.getName(), Util.formatDateDiff(timeDiff))
: Util.format("playerJailed", player.getName())));
? _("playerJailedFor", player.getName(), Util.formatDateDiff(timeDiff))
: _("playerJailed", player.getName())));
return;
}
if (args.length >= 2 && player.isJailed() && !args[1].equalsIgnoreCase(player.getJail()))
{
sender.sendMessage(Util.format("jailAlreadyIncarcerated", player.getJail()));
sender.sendMessage(_("jailAlreadyIncarcerated", player.getJail()));
return;
}
@ -81,7 +82,7 @@ public class Commandtogglejail extends EssentialsCommand
final String time = getFinalArg(args, 2);
final long timeDiff = Util.parseDateDiff(time, true);
player.setJailTimeout(timeDiff);
sender.sendMessage(Util.format("jailSentenceExtended", Util.formatDateDiff(timeDiff)));
sender.sendMessage(_("jailSentenceExtended", Util.formatDateDiff(timeDiff)));
return;
}
@ -93,13 +94,13 @@ public class Commandtogglejail extends EssentialsCommand
}
player.setJailed(false);
player.setJailTimeout(0);
player.sendMessage(Util.format("jailReleasedPlayerNotify"));
player.sendMessage(_("jailReleasedPlayerNotify"));
player.setJail(null);
if (!(player.getBase() instanceof OfflinePlayer))
{
player.getTeleport().back();
}
sender.sendMessage(Util.format("jailReleased", player.getName()));
sender.sendMessage(_("jailReleased", player.getName()));
}
}
}

View File

@ -1,8 +1,8 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.Trade;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import org.bukkit.Location;
import org.bukkit.Server;
@ -21,6 +21,6 @@ public class Commandtop extends EssentialsCommand
final int topZ = user.getLocation().getBlockZ();
final int topY = user.getWorld().getHighestBlockYAt(topX, topZ);
user.getTeleport().teleport(new Location(user.getWorld(), user.getLocation().getX(), topY + 1, user.getLocation().getZ()), new Trade(this.getName(), ess));
user.sendMessage(Util.i18n("teleportTop"));
user.sendMessage(_("teleportTop"));
}
}

View File

@ -1,9 +1,9 @@
package com.earth2me.essentials.commands;
import com.earth2me.essentials.Console;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.Trade;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
@ -27,9 +27,9 @@ public class Commandtp extends EssentialsCommand
final User player = getPlayer(server, args, 0);
if (!player.isTeleportEnabled())
{
throw new Exception(Util.format("teleportDisabled", player.getDisplayName()));
throw new Exception(_("teleportDisabled", player.getDisplayName()));
}
user.sendMessage(Util.i18n("teleporting"));
user.sendMessage(_("teleporting"));
final Trade charge = new Trade(this.getName(), ess);
charge.isAffordableFor(user);
user.getTeleport().teleport(player, charge);
@ -40,13 +40,13 @@ public class Commandtp extends EssentialsCommand
{
throw new Exception("You need access to /tpohere to teleport other players.");
}
user.sendMessage(Util.i18n("teleporting"));
user.sendMessage(_("teleporting"));
final User target = getPlayer(server, args, 0);
final User toPlayer = getPlayer(server, args, 1);
target.getTeleport().now(toPlayer, false);
target.sendMessage(Util.format("teleportAtoB", user.getDisplayName(), toPlayer.getDisplayName()));
target.sendMessage(_("teleportAtoB", user.getDisplayName(), toPlayer.getDisplayName()));
break;
}
}
}
@Override
@ -57,10 +57,10 @@ public class Commandtp extends EssentialsCommand
throw new NotEnoughArgumentsException();
}
sender.sendMessage(Util.i18n("teleporting"));
sender.sendMessage(_("teleporting"));
final User target = getPlayer(server, args, 0);
final User toPlayer = getPlayer(server, args, 1);
target.getTeleport().now(toPlayer, false);
target.sendMessage(Util.format("teleportAtoB", Console.NAME, toPlayer.getDisplayName()));
target.sendMessage(_("teleportAtoB", Console.NAME, toPlayer.getDisplayName()));
}
}

View File

@ -1,7 +1,7 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import org.bukkit.Server;
@ -23,15 +23,15 @@ public class Commandtpa extends EssentialsCommand
User player = getPlayer(server, args, 0);
if (!player.isTeleportEnabled())
{
throw new Exception(Util.format("teleportDisabled", player.getDisplayName()));
throw new Exception(_("teleportDisabled", player.getDisplayName()));
}
if (!player.isIgnoredPlayer(user.getName()))
{
player.requestTeleport(user, false);
player.sendMessage(Util.format("teleportRequest", user.getDisplayName()));
player.sendMessage(Util.i18n("typeTpaccept"));
player.sendMessage(Util.i18n("typeTpdeny"));
player.sendMessage(_("teleportRequest", user.getDisplayName()));
player.sendMessage(_("typeTpaccept"));
player.sendMessage(_("typeTpdeny"));
}
user.sendMessage(Util.format("requestSent", player.getDisplayName()));
user.sendMessage(_("requestSent", player.getDisplayName()));
}
}

View File

@ -1,7 +1,7 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@ -33,7 +33,7 @@ public class Commandtpaall extends EssentialsCommand
private void teleportAAllPlayers(final Server server, final CommandSender sender, final User user)
{
sender.sendMessage(Util.i18n("teleportAAll"));
sender.sendMessage(_("teleportAAll"));
for (Player onlinePlayer : server.getOnlinePlayers())
{
final User player = ess.getUser(onlinePlayer);
@ -48,8 +48,8 @@ public class Commandtpaall extends EssentialsCommand
try
{
player.requestTeleport(user, true);
player.sendMessage(Util.format("teleportHereRequest", user.getDisplayName()));
player.sendMessage(Util.i18n("typeTpaccept"));
player.sendMessage(_("teleportHereRequest", user.getDisplayName()));
player.sendMessage(_("typeTpaccept"));
}
catch (Exception ex)
{

View File

@ -1,9 +1,9 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.OfflinePlayer;
import com.earth2me.essentials.Trade;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import org.bukkit.Server;
@ -23,7 +23,7 @@ public class Commandtpaccept extends EssentialsCommand
|| target.getBase() instanceof OfflinePlayer
|| (user.isTeleportRequestHere() && !target.isAuthorized("essentials.tpahere")))
{
throw new Exception(Util.i18n("noPendingRequest"));
throw new Exception(_("noPendingRequest"));
}
final Trade charge = new Trade(this.getName(), ess);
@ -35,8 +35,8 @@ public class Commandtpaccept extends EssentialsCommand
{
charge.isAffordableFor(target);
}
user.sendMessage(Util.i18n("requestAccepted"));
target.sendMessage(Util.format("requestAcceptedFrom", user.getDisplayName()));
user.sendMessage(_("requestAccepted"));
target.sendMessage(_("requestAcceptedFrom", user.getDisplayName()));
if (user.isTeleportRequestHere())
{

View File

@ -1,7 +1,7 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import org.bukkit.Server;
@ -23,11 +23,11 @@ public class Commandtpahere extends EssentialsCommand
final User player = getPlayer(server, args, 0);
if (!player.isTeleportEnabled())
{
throw new Exception(Util.format("teleportDisabled", player.getDisplayName()));
throw new Exception(_("teleportDisabled", player.getDisplayName()));
}
player.requestTeleport(user, true);
player.sendMessage(Util.format("teleportHereRequest", user.getDisplayName()));
player.sendMessage(Util.i18n("typeTpaccept"));
user.sendMessage(Util.format("requestSent", player.getDisplayName()));
player.sendMessage(_("teleportHereRequest", user.getDisplayName()));
player.sendMessage(_("typeTpaccept"));
user.sendMessage(_("requestSent", player.getDisplayName()));
}
}

View File

@ -1,7 +1,7 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@ -33,7 +33,7 @@ public class Commandtpall extends EssentialsCommand
private void teleportAllPlayers(Server server, CommandSender sender, User user)
{
sender.sendMessage(Util.i18n("teleportAll"));
sender.sendMessage(_("teleportAll"));
for (Player onlinePlayer : server.getOnlinePlayers())
{
final User player = ess.getUser(onlinePlayer);

Some files were not shown because too many files have changed in this diff Show More