Skip to content

Commit

Permalink
Future Java versions may not support _ as identifier.
Browse files Browse the repository at this point in the history
  • Loading branch information
FearFree authored and chrisgward committed Mar 22, 2014
1 parent 0b5718f commit 5724c0c
Show file tree
Hide file tree
Showing 176 changed files with 1,032 additions and 1,028 deletions.
6 changes: 3 additions & 3 deletions Essentials/src/com/earth2me/essentials/Backup.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.earth2me.essentials;

import static com.earth2me.essentials.I18n._;
import static com.earth2me.essentials.I18n.tl;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
Expand Down Expand Up @@ -86,7 +86,7 @@ public void run()
active = false;
return;
}
LOGGER.log(Level.INFO, _("backupStarted"));
LOGGER.log(Level.INFO, tl("backupStarted"));
final CommandSender cs = server.getConsoleSender();
server.dispatchCommand(cs, "save-all");
server.dispatchCommand(cs, "save-off");
Expand Down Expand Up @@ -157,7 +157,7 @@ public void run()
stopTask();
}
active = false;
LOGGER.log(Level.INFO, _("backupFinished"));
LOGGER.log(Level.INFO, tl("backupFinished"));
}
});
}
Expand Down
46 changes: 22 additions & 24 deletions Essentials/src/com/earth2me/essentials/Essentials.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*/
package com.earth2me.essentials;

import static com.earth2me.essentials.I18n._;
import static com.earth2me.essentials.I18n.tl;
import com.earth2me.essentials.commands.EssentialsCommand;
import com.earth2me.essentials.commands.IEssentialsCommand;
import com.earth2me.essentials.commands.NoChargeException;
Expand Down Expand Up @@ -58,9 +58,7 @@
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.PluginCommand;
import org.bukkit.command.SimpleCommandMap;
import org.bukkit.command.TabCompleter;
import org.bukkit.command.defaults.VanillaCommand;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
Expand Down Expand Up @@ -100,7 +98,7 @@ public class Essentials extends JavaPlugin implements net.ess3.api.IEssentials
private transient I18n i18n;
private transient Metrics metrics;
private transient EssentialsTimer timer;
private transient List<String> vanishedPlayers = new ArrayList<String>();
private final transient List<String> vanishedPlayers = new ArrayList<String>();

public Essentials()
{
Expand Down Expand Up @@ -131,7 +129,7 @@ public void setupForTesting(final Server server) throws IOException, InvalidDesc
}
i18n = new I18n(this);
i18n.onEnable();
LOGGER.log(Level.INFO, _("usingTempFolderForTesting"));
LOGGER.log(Level.INFO, tl("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);
Expand Down Expand Up @@ -159,7 +157,7 @@ public void onEnable()
&& !plugin.getDescription().getVersion().equals(this.getDescription().getVersion())
&& !plugin.getDescription().getName().equals("EssentialsAntiCheat"))
{
LOGGER.log(Level.WARNING, _("versionMismatch", plugin.getDescription().getName()));
LOGGER.log(Level.WARNING, tl("versionMismatch", plugin.getDescription().getName()));
}
}
final Matcher versionMatch = Pattern.compile("git-Bukkit-(?:(?:[0-9]+)\\.)+[0-9]+-R[\\.0-9]+-(?:[0-9]+-g[0-9a-f]+-)?b([0-9]+)jnks.*").matcher(getServer().getVersion());
Expand All @@ -175,7 +173,7 @@ public void onEnable()
}
else
{
LOGGER.log(Level.INFO, _("bukkitFormatChanged"));
LOGGER.log(Level.INFO, tl("bukkitFormatChanged"));
LOGGER.log(Level.INFO, getServer().getVersion());
LOGGER.log(Level.INFO, getServer().getBukkitVersion());
}
Expand Down Expand Up @@ -211,11 +209,11 @@ public void onEnable()
{
if (pm.getPlugin("EssentialsUpdate") != null)
{
LOGGER.log(Level.SEVERE, _("essentialsHelp2"));
LOGGER.log(Level.SEVERE, tl("essentialsHelp2"));
}
else
{
LOGGER.log(Level.SEVERE, _("essentialsHelp1"));
LOGGER.log(Level.SEVERE, tl("essentialsHelp1"));
}
handleCrash(exception);
return;
Expand Down Expand Up @@ -244,7 +242,7 @@ else if (metricsStarter.getStart() != null && metricsStarter.getStart() == false
final String timeroutput = execTimer.end();
if (getSettings().isDebug())
{
LOGGER.log(Level.INFO, "Essentials load " + timeroutput);
LOGGER.log(Level.INFO, "Essentials load {0}", timeroutput);
}
}
catch (NumberFormatException ex)
Expand Down Expand Up @@ -312,7 +310,7 @@ public void onDisable()
if (user.isVanished())
{
user.setVanished(false);
user.sendMessage(_("unvanishedReload"));
user.sendMessage(tl("unvanishedReload"));
}
}
cleanupOpenInventories();
Expand Down Expand Up @@ -441,7 +439,7 @@ else if (user == null)
final List<String> mail = user.getMails();
if (mail != null && !mail.isEmpty())
{
user.sendMessage(_("youHaveNewMail", mail.size()));
user.sendMessage(tl("youHaveNewMail", mail.size()));
}
}

Expand All @@ -467,28 +465,28 @@ else if (user == null)
}
catch (Exception ex)
{
sender.sendMessage(_("commandNotLoaded", commandLabel));
LOGGER.log(Level.SEVERE, _("commandNotLoaded", commandLabel), ex);
sender.sendMessage(tl("commandNotLoaded", commandLabel));
LOGGER.log(Level.SEVERE, tl("commandNotLoaded", commandLabel), ex);
return true;
}

// Check authorization
if (user != null && !user.isAuthorized(cmd, permissionPrefix))
{
LOGGER.log(Level.INFO, _("deniedAccessCommand", user.getName()));
user.sendMessage(_("noAccessCommand"));
LOGGER.log(Level.INFO, tl("deniedAccessCommand", user.getName()));
user.sendMessage(tl("noAccessCommand"));
return true;
}

if (user != null && user.isJailed() && !user.isAuthorized(cmd, "essentials.jail.allow."))
{
if (user.getJailTimeout() > 0)
{
user.sendMessage(_("playerJailedFor", user.getName(), DateUtil.formatDateDiff(user.getJailTimeout())));
user.sendMessage(tl("playerJailedFor", user.getName(), DateUtil.formatDateDiff(user.getJailTimeout())));
}
else
{
user.sendMessage(_("jailMessage"));
user.sendMessage(tl("jailMessage"));
}
return true;
}
Expand Down Expand Up @@ -532,7 +530,7 @@ else if (user == null)
}
catch (Throwable ex)
{
LOGGER.log(Level.SEVERE, _("commandFailed", commandLabel), ex);
LOGGER.log(Level.SEVERE, tl("commandFailed", commandLabel), ex);
return true;
}
}
Expand Down Expand Up @@ -560,18 +558,18 @@ public void cleanupOpenInventories()
@Override
public void showError(final CommandSource sender, final Throwable exception, final String commandLabel)
{
sender.sendMessage(_("errorWithMessage", exception.getMessage()));
sender.sendMessage(tl("errorWithMessage", exception.getMessage()));
if (getSettings().isDebug())
{
LOGGER.log(Level.WARNING, _("errorCallingCommand", commandLabel), exception);
LOGGER.log(Level.WARNING, tl("errorCallingCommand", commandLabel), exception);
}
}

public static void wrongVersion()
{
LOGGER.log(Level.SEVERE, " * ! * ! * ! * ! * ! * ! * ! * ! * ! * ! * ! * ! *");
LOGGER.log(Level.SEVERE, _("notRecommendedBukkit"));
LOGGER.log(Level.SEVERE, _("requiredBukkit", Integer.toString(BUKKIT_VERSION)));
LOGGER.log(Level.SEVERE, tl("notRecommendedBukkit"));
LOGGER.log(Level.SEVERE, tl("requiredBukkit", Integer.toString(BUKKIT_VERSION)));
LOGGER.log(Level.SEVERE, " * ! * ! * ! * ! * ! * ! * ! * ! * ! * ! * ! * ! *");
}

Expand Down Expand Up @@ -672,7 +670,7 @@ public User getUser(final Player base)
{
if (getSettings().isDebug())
{
LOGGER.log(Level.INFO, "Constructing new userfile from base player " + base.getName());
LOGGER.log(Level.INFO, "Constructing new userfile from base player {0}", base.getName());
}
user = new User(base, this);
}
Expand Down
20 changes: 10 additions & 10 deletions Essentials/src/com/earth2me/essentials/EssentialsConf.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.earth2me.essentials;

import static com.earth2me.essentials.I18n._;
import static com.earth2me.essentials.I18n.tl;
import com.google.common.io.Files;
import java.io.*;
import java.math.BigDecimal;
Expand Down Expand Up @@ -50,14 +50,14 @@ public synchronized void load()
{
if (pendingDiskWrites.get() != 0)
{
LOGGER.log(Level.INFO, "File " + configFile + " not read, because it's not yet written to disk.");
LOGGER.log(Level.INFO, "File {0} not read, because it''s not yet written to disk.", configFile);
return;
}
if (!configFile.getParentFile().exists())
{
if (!configFile.getParentFile().mkdirs())
{
LOGGER.log(Level.SEVERE, _("failedToCreateConfig", configFile.toString()));
LOGGER.log(Level.SEVERE, tl("failedToCreateConfig", configFile.toString()));
}
}
// This will delete files where the first character is 0. In most cases they are broken.
Expand Down Expand Up @@ -100,7 +100,7 @@ public synchronized void load()
{
if (templateName != null)
{
LOGGER.log(Level.INFO, _("creatingConfigFromTemplate", configFile.toString()));
LOGGER.log(Level.INFO, tl("creatingConfigFromTemplate", configFile.toString()));
createFromTemplate();
}
else
Expand Down Expand Up @@ -189,7 +189,7 @@ private void createFromTemplate()
istr = resourceClass.getResourceAsStream(templateName);
if (istr == null)
{
LOGGER.log(Level.SEVERE, _("couldNotFindTemplate", templateName));
LOGGER.log(Level.SEVERE, tl("couldNotFindTemplate", templateName));
return;
}
ostr = new FileOutputStream(configFile);
Expand All @@ -204,7 +204,7 @@ private void createFromTemplate()
}
catch (IOException ex)
{
LOGGER.log(Level.SEVERE, _("failedToWriteConfig", configFile.toString()), ex);
LOGGER.log(Level.SEVERE, tl("failedToWriteConfig", configFile.toString()), ex);
}
finally
{
Expand All @@ -228,7 +228,7 @@ private void createFromTemplate()
}
catch (IOException ex)
{
LOGGER.log(Level.SEVERE, _("failedToCloseConfig", configFile.toString()), ex);
LOGGER.log(Level.SEVERE, tl("failedToCloseConfig", configFile.toString()), ex);
}
}
}
Expand Down Expand Up @@ -352,16 +352,16 @@ public void run()
{
try
{
LOGGER.log(Level.INFO, _("creatingEmptyConfig", configFile.toString()));
LOGGER.log(Level.INFO, tl("creatingEmptyConfig", configFile.toString()));
if (!configFile.createNewFile())
{
LOGGER.log(Level.SEVERE, _("failedToCreateConfig", configFile.toString()));
LOGGER.log(Level.SEVERE, tl("failedToCreateConfig", configFile.toString()));
return;
}
}
catch (IOException ex)
{
LOGGER.log(Level.SEVERE, _("failedToCreateConfig", configFile.toString()), ex);
LOGGER.log(Level.SEVERE, tl("failedToCreateConfig", configFile.toString()), ex);
return;
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.earth2me.essentials;

import static com.earth2me.essentials.I18n._;
import static com.earth2me.essentials.I18n.tl;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
Expand Down Expand Up @@ -151,7 +151,7 @@ public void onPlayerDeathEvent(final PlayerDeathEvent event)
if (user.isAuthorized("essentials.back.ondeath") && !ess.getSettings().isCommandDisabled("back"))
{
user.setLastLocation();
user.sendMessage(_("backAfterDeath"));
user.sendMessage(tl("backAfterDeath"));
}
if (!ess.getSettings().areDeathMessagesEnabled())
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.earth2me.essentials;

import static com.earth2me.essentials.I18n._;
import static com.earth2me.essentials.I18n.tl;
import com.earth2me.essentials.textreader.IText;
import com.earth2me.essentials.textreader.KeywordReplacer;
import com.earth2me.essentials.textreader.TextInput;
Expand Down Expand Up @@ -63,8 +63,8 @@ public void onPlayerChat(final AsyncPlayerChatEvent event)
if (user.isMuted())
{
event.setCancelled(true);
user.sendMessage(_("voiceSilenced"));
LOGGER.info(_("mutedUserSpeaks", user.getName()));
user.sendMessage(tl("voiceSilenced"));
LOGGER.info(tl("mutedUserSpeaks", user.getName()));
}
try
{
Expand Down Expand Up @@ -295,11 +295,11 @@ else if (ess.getSettings().allowSilentJoinQuit())
final List<String> mail = user.getMails();
if (mail.isEmpty())
{
user.sendMessage(_("noNewMail"));
user.sendMessage(tl("noNewMail"));
}
else
{
user.sendMessage(_("youHaveNewMail", mail.size()));
user.sendMessage(tl("youHaveNewMail", mail.size()));
}
}

Expand All @@ -310,7 +310,7 @@ else if (ess.getSettings().allowSilentJoinQuit())
{
user.setAllowFlight(true);
user.setFlying(true);
user.sendMessage(_("flyMode", _("enabled"), user.getDisplayName()));
user.sendMessage(tl("flyMode", tl("enabled"), user.getDisplayName()));
}
}
user.setFlySpeed(0.1f);
Expand Down Expand Up @@ -346,7 +346,7 @@ public void onPlayerLogin2(final PlayerLoginEvent event)
return;
}

final String banReason = _("banFormat", _("defaultBanReason"), "Console");
final String banReason = tl("banFormat", tl("defaultBanReason"), "Console");
event.disallow(Result.KICK_BANNED, banReason);
}

Expand Down Expand Up @@ -386,7 +386,7 @@ public void onPlayerLogin(final PlayerLoginEvent event)

if (event.getResult() == Result.KICK_FULL && !user.isAuthorized("essentials.joinfullserver"))
{
event.disallow(Result.KICK_FULL, _("serverFull"));
event.disallow(Result.KICK_FULL, tl("serverFull"));
return;
}
event.allow();
Expand Down Expand Up @@ -510,12 +510,12 @@ public void onPlayerChangedWorld(final PlayerChangedWorldEvent event)
updateCompass(user);
if (ess.getSettings().getNoGodWorlds().contains(newWorld) && user.isGodModeEnabledRaw())
{
user.sendMessage(_("noGodWorldWarning"));
user.sendMessage(tl("noGodWorldWarning"));
}

if (!user.getWorld().getName().equals(newWorld))
{
user.sendMessage(_("currentWorld", newWorld));
user.sendMessage(tl("currentWorld", newWorld));
}
if (user.isVanished())
{
Expand All @@ -535,7 +535,7 @@ public void onPlayerInteract(final PlayerInteractEvent event)
if (player.isAuthorized("essentials.sethome.bed"))
{
player.setBedSpawnLocation(event.getClickedBlock().getLocation());
player.sendMessage(_("bedSet", player.getLocation().getWorld().getName(), player.getLocation().getBlockX(), player.getLocation().getBlockY(), player.getLocation().getBlockZ()));
player.sendMessage(tl("bedSet", player.getLocation().getWorld().getName(), player.getLocation().getBlockX(), player.getLocation().getBlockY(), player.getLocation().getBlockZ()));
}
}
break;
Expand Down
Loading

0 comments on commit 5724c0c

Please sign in to comment.