Implement per player locale

This commit is contained in:
Phoenix616 2019-04-23 16:07:51 +01:00 committed by md678685
parent 8bcef6022b
commit 1ba13e4655
192 changed files with 1531 additions and 1277 deletions

View File

@ -114,5 +114,11 @@
<version>2.17.1</version> <version>2.17.1</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<dependency>
<groupId>net.ess3</groupId>
<artifactId>LocaleApiProvider</artifactId>
<version>2.16.1</version>
<scope>compile</scope>
</dependency>
</dependencies> </dependencies>
</project> </project>

View File

@ -3,14 +3,22 @@ package com.earth2me.essentials;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import static com.earth2me.essentials.I18n.tl;
public class CommandSource { public class CommandSource {
protected CommandSender sender; protected CommandSender sender;
protected User user = null;
public CommandSource(final CommandSender base) { public CommandSource(final CommandSender base) {
this.sender = base; this.sender = base;
} }
public CommandSource(final User user) {
this.sender = user.getBase();
this.user = user;
}
public final CommandSender getSender() { public final CommandSender getSender() {
return sender; return sender;
} }
@ -30,10 +38,29 @@ public class CommandSource {
return this.sender = base; return this.sender = base;
} }
public void sendMessage(String message) { public void sendMessage(String message) {
if (!message.isEmpty()) { if (!message.isEmpty()) {
sender.sendMessage(message); sender.sendMessage(message);
} }
} }
public void setUser(User user) {
this.user = user;
}
public User getUser() {
return user;
}
public void sendTl(String string, Object... objects) {
sendMessage(tl(string, objects));
}
public String tl(String string, Object... objects) {
if (user != null) {
return I18n.tl(user.getApplicableLocale(), string, objects);
} else {
return I18n.tl(string, objects);
}
}
} }

View File

@ -6,6 +6,8 @@ import com.earth2me.essentials.messaging.SimpleMessageRecipient;
import org.bukkit.Server; import org.bukkit.Server;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import java.util.Locale;
public final class Console implements IMessageRecipient { public final class Console implements IMessageRecipient {
public static final String NAME = "Console"; public static final String NAME = "Console";
@ -55,10 +57,10 @@ public final class Console implements IMessageRecipient {
return true; return true;
} }
/* ================================ /* ================================
* >> DELEGATE METHODS * >> DELEGATE METHODS
* ================================ */ * ================================ */
@Override public MessageResponse sendMessage(IMessageRecipient recipient, String message) { @Override public MessageResponse sendMessage(IMessageRecipient recipient, String message) {
return this.messageRecipient.sendMessage(recipient, message); return this.messageRecipient.sendMessage(recipient, message);
} }
@ -74,4 +76,8 @@ public final class Console implements IMessageRecipient {
@Override public void setReplyRecipient(IMessageRecipient recipient) { @Override public void setReplyRecipient(IMessageRecipient recipient) {
this.messageRecipient.setReplyRecipient(recipient); this.messageRecipient.setReplyRecipient(recipient);
} }
@Override public Locale getLocale() {
return this.messageRecipient.getLocale();
}
} }

View File

@ -38,6 +38,7 @@ import com.google.common.collect.Iterables;
import net.ess3.api.*; import net.ess3.api.*;
import net.ess3.api.IEssentials; import net.ess3.api.IEssentials;
import net.ess3.api.ISettings; import net.ess3.api.ISettings;
import net.ess3.nms.PlayerLocaleProvider;
import net.ess3.nms.PotionMetaProvider; import net.ess3.nms.PotionMetaProvider;
import net.ess3.nms.SpawnEggProvider; import net.ess3.nms.SpawnEggProvider;
import net.ess3.nms.SpawnerProvider; import net.ess3.nms.SpawnerProvider;
@ -45,6 +46,8 @@ import net.ess3.nms.flattened.FlatSpawnEggProvider;
import net.ess3.nms.legacy.LegacyPotionMetaProvider; import net.ess3.nms.legacy.LegacyPotionMetaProvider;
import net.ess3.nms.legacy.LegacySpawnEggProvider; import net.ess3.nms.legacy.LegacySpawnEggProvider;
import net.ess3.nms.legacy.LegacySpawnerProvider; import net.ess3.nms.legacy.LegacySpawnerProvider;
import net.ess3.nms.localeapi.ApiPlayerLocaleProvider;
import net.ess3.nms.refl.ReflPlayerLocaleProvider;
import net.ess3.nms.refl.ReflSpawnEggProvider; import net.ess3.nms.refl.ReflSpawnEggProvider;
import net.ess3.nms.updatedmeta.BasePotionDataProvider; import net.ess3.nms.updatedmeta.BasePotionDataProvider;
import net.ess3.nms.updatedmeta.BlockMetaSpawnerProvider; import net.ess3.nms.updatedmeta.BlockMetaSpawnerProvider;
@ -110,6 +113,7 @@ public class Essentials extends JavaPlugin implements net.ess3.api.IEssentials {
private transient SpawnerProvider spawnerProvider; private transient SpawnerProvider spawnerProvider;
private transient SpawnEggProvider spawnEggProvider; private transient SpawnEggProvider spawnEggProvider;
private transient PotionMetaProvider potionMetaProvider; private transient PotionMetaProvider potionMetaProvider;
private transient PlayerLocaleProvider playerLocaleProvider;
private transient Kits kits; private transient Kits kits;
public Essentials() { public Essentials() {
@ -246,6 +250,12 @@ public class Essentials extends JavaPlugin implements net.ess3.api.IEssentials {
BasePotionDataProvider.class, BasePotionDataProvider.class,
LegacyPotionMetaProvider.class LegacyPotionMetaProvider.class
), "potion meta").getProvider(); ), "potion meta").getProvider();
playerLocaleProvider = new ProviderFactory<>(getLogger(),
Arrays.asList(
ApiPlayerLocaleProvider.class,
ReflPlayerLocaleProvider.class
)
, "player locale").getProvider();
execTimer.mark("Init(Providers)"); execTimer.mark("Init(Providers)");
reload(); reload();
@ -343,7 +353,7 @@ public class Essentials extends JavaPlugin implements net.ess3.api.IEssentials {
for (User user : getOnlineUsers()) { for (User user : getOnlineUsers()) {
if (user.isVanished()) { if (user.isVanished()) {
user.setVanished(false); user.setVanished(false);
user.sendMessage(tl("unvanishedReload")); user.sendTl("unvanishedReload");
} }
user.stopTransaction(); user.stopTransaction();
} }
@ -400,13 +410,15 @@ public class Essentials extends JavaPlugin implements net.ess3.api.IEssentials {
} }
} }
try {
// Note: The tab completer is always a player, even when tab-completing in a command block // Note: The tab completer is always a player, even when tab-completing in a command block
User user = null; User user = null;
if (cSender instanceof Player) { if (cSender instanceof Player) {
user = getUser((Player) cSender); user = getUser((Player) cSender);
} }
Locale locale = user != null ? user.getApplicableLocale() : getI18n().getCurrentLocale();
try {
CommandSource sender = new CommandSource(cSender); CommandSource sender = new CommandSource(cSender);
// Check for disabled commands // Check for disabled commands
@ -420,8 +432,8 @@ public class Essentials extends JavaPlugin implements net.ess3.api.IEssentials {
cmd.setEssentials(this); cmd.setEssentials(this);
cmd.setEssentialsModule(module); cmd.setEssentialsModule(module);
} catch (Exception ex) { } catch (Exception ex) {
sender.sendMessage(tl("commandNotLoaded", commandLabel)); sender.sendMessage(tl(locale, "commandNotLoaded", commandLabel));
LOGGER.log(Level.SEVERE, tl("commandNotLoaded", commandLabel), ex); LOGGER.log(Level.SEVERE, tl(locale, "commandNotLoaded", commandLabel), ex);
return Collections.emptyList(); return Collections.emptyList();
} }
@ -444,11 +456,11 @@ public class Essentials extends JavaPlugin implements net.ess3.api.IEssentials {
} catch (Exception ex) { } catch (Exception ex) {
showError(sender, ex, commandLabel); showError(sender, ex, commandLabel);
// Tab completion shouldn't fail // Tab completion shouldn't fail
LOGGER.log(Level.SEVERE, tl("commandFailed", commandLabel), ex); LOGGER.log(Level.SEVERE, tl(locale, "commandFailed", commandLabel), ex);
return Collections.emptyList(); return Collections.emptyList();
} }
} catch (Throwable ex) { } catch (Throwable ex) {
LOGGER.log(Level.SEVERE, tl("commandFailed", commandLabel), ex); LOGGER.log(Level.SEVERE, tl(locale, "commandFailed", commandLabel), ex);
return Collections.emptyList(); return Collections.emptyList();
} }
} }
@ -476,11 +488,12 @@ public class Essentials extends JavaPlugin implements net.ess3.api.IEssentials {
} }
try { try {
User user = null;
Block bSenderBlock = null; Block bSenderBlock = null;
User user = null;
CommandSource sender = new CommandSource(cSender);
if (cSender instanceof Player) { if (cSender instanceof Player) {
user = getUser((Player) cSender); user = getUser((Player) cSender);
sender.setUser(user);
} else if (cSender instanceof BlockCommandSender) { } else if (cSender instanceof BlockCommandSender) {
BlockCommandSender bsender = (BlockCommandSender) cSender; BlockCommandSender bsender = (BlockCommandSender) cSender;
bSenderBlock = bsender.getBlock(); bSenderBlock = bsender.getBlock();
@ -494,8 +507,6 @@ public class Essentials extends JavaPlugin implements net.ess3.api.IEssentials {
Bukkit.getLogger().log(Level.INFO, "{0} issued server command: /{1} {2}", new Object[]{cSender.getName(), commandLabel, EssentialsCommand.getFinalArg(args, 0)}); Bukkit.getLogger().log(Level.INFO, "{0} issued server command: /{1} {2}", new Object[]{cSender.getName(), commandLabel, EssentialsCommand.getFinalArg(args, 0)});
} }
CommandSource sender = new CommandSource(cSender);
// New mail notification // New mail notification
if (user != null && !getSettings().isCommandDisabled("mail") && !command.getName().equals("mail") && user.isAuthorized("essentials.mail")) { if (user != null && !getSettings().isCommandDisabled("mail") && !command.getName().equals("mail") && user.isAuthorized("essentials.mail")) {
user.notifyOfMail(); user.notifyOfMail();
@ -518,7 +529,7 @@ public class Essentials extends JavaPlugin implements net.ess3.api.IEssentials {
cmd.setEssentials(this); cmd.setEssentials(this);
cmd.setEssentialsModule(module); cmd.setEssentialsModule(module);
} catch (Exception ex) { } catch (Exception ex) {
sender.sendMessage(tl("commandNotLoaded", commandLabel)); sender.sendTl("commandNotLoaded", commandLabel);
LOGGER.log(Level.SEVERE, tl("commandNotLoaded", commandLabel), ex); LOGGER.log(Level.SEVERE, tl("commandNotLoaded", commandLabel), ex);
return true; return true;
} }
@ -526,15 +537,15 @@ public class Essentials extends JavaPlugin implements net.ess3.api.IEssentials {
// Check authorization // Check authorization
if (user != null && !user.isAuthorized(cmd, permissionPrefix)) { if (user != null && !user.isAuthorized(cmd, permissionPrefix)) {
LOGGER.log(Level.INFO, tl("deniedAccessCommand", user.getName())); LOGGER.log(Level.INFO, tl("deniedAccessCommand", user.getName()));
user.sendMessage(tl("noAccessCommand")); sender.sendTl("noAccessCommand");
return true; return true;
} }
if (user != null && user.isJailed() && !user.isAuthorized(cmd, "essentials.jail.allow.")) { if (user != null && user.isJailed() && !user.isAuthorized(cmd, "essentials.jail.allow.")) {
if (user.getJailTimeout() > 0) { if (user.getJailTimeout() > 0) {
user.sendMessage(tl("playerJailedFor", user.getName(), DateUtil.formatDateDiff(user.getJailTimeout()))); sender.sendTl("playerJailedFor", user.getName(), DateUtil.formatDateDiff(sender, user.getJailTimeout()));
} else { } else {
user.sendMessage(tl("jailMessage")); sender.sendTl("jailMessage");
} }
return true; return true;
} }
@ -588,7 +599,7 @@ public class Essentials extends JavaPlugin implements net.ess3.api.IEssentials {
@Override @Override
public void showError(final CommandSource sender, final Throwable exception, final String commandLabel) { public void showError(final CommandSource sender, final Throwable exception, final String commandLabel) {
sender.sendMessage(tl("errorWithMessage", exception.getMessage())); sender.sendTl("errorWithMessage", exception.getMessage());
if (getSettings().isDebug()) { if (getSettings().isDebug()) {
LOGGER.log(Level.INFO, tl("errorCallingCommand", commandLabel), exception); LOGGER.log(Level.INFO, tl("errorCallingCommand", commandLabel), exception);
} }
@ -764,13 +775,55 @@ public class Essentials extends JavaPlugin implements net.ess3.api.IEssentials {
IText broadcast = new SimpleTextInput(message); IText broadcast = new SimpleTextInput(message);
final Collection<Player> players = getOnlinePlayers();
for (Player player : players) {
sendBroadcast(sender != null ? sender.getSource() : null, permission, keywords, getUser(player), broadcast);
}
return players.size();
}
@Override
public int broadcastTl(final String string, final Object... objects) {
return broadcastTl(null, null, string, true, objects);
}
@Override
public int broadcastTl(final IUser sender, final String string, final Object... objects) {
return broadcastTl(sender.getSource(), null, string, false, objects);
}
@Override
public int broadcastTl(final CommandSource sender, final String string, final Object... objects) {
return broadcastTl(sender, null, string, false, objects);
}
@Override
public int broadcastTl(final String permission, final String string, final Object... objects) {
return broadcastTl(null, permission, string, false, objects);
}
private int broadcastTl(final CommandSource sender, final String permission, final String string, final boolean keywords, final Object... objects) {
if (sender != null && sender.getUser() != null && sender.getUser().isHidden()) {
return 0;
}
final Collection<Player> players = getOnlinePlayers(); final Collection<Player> players = getOnlinePlayers();
for (Player player : players) { for (Player player : players) {
final User user = getUser(player); final User user = getUser(player);
if ((permission == null && (sender == null || !user.isIgnoredPlayer(sender))) || (permission != null && user.isAuthorized(permission))) { sendBroadcast(sender, permission, keywords, user, new SimpleTextInput(user.tl(string, objects)));
}
return players.size();
}
private void sendBroadcast(final CommandSource sender, final String permission, final boolean keywords, final User user, IText broadcast) {
if ((permission == null && (sender == null || sender.getUser() == null || !user.isIgnoredPlayer(sender.getUser()))) || (permission != null && user.isAuthorized(permission))) {
if (keywords) { if (keywords) {
broadcast = new KeywordReplacer(broadcast, new CommandSource(player), this, false); broadcast = new KeywordReplacer(broadcast, user.getSource(), this, false);
} }
for (String messageText : broadcast.getLines()) { for (String messageText : broadcast.getLines()) {
user.sendMessage(messageText); user.sendMessage(messageText);
@ -778,9 +831,6 @@ public class Essentials extends JavaPlugin implements net.ess3.api.IEssentials {
} }
} }
return players.size();
}
@Override @Override
public BukkitTask runTaskAsynchronously(final Runnable run) { public BukkitTask runTaskAsynchronously(final Runnable run) {
return this.getScheduler().runTaskAsynchronously(this, run); return this.getScheduler().runTaskAsynchronously(this, run);
@ -897,6 +947,11 @@ public class Essentials extends JavaPlugin implements net.ess3.api.IEssentials {
return potionMetaProvider; return potionMetaProvider;
} }
@Override
public PlayerLocaleProvider getPlayerLocaleProvider() {
return playerLocaleProvider;
}
private static void addDefaultBackPermissionsToWorld(World w) { private static void addDefaultBackPermissionsToWorld(World w) {
String permName = "essentials.back.into." + w.getName(); String permName = "essentials.back.into." + w.getName();

View File

@ -143,7 +143,7 @@ public class EssentialsEntityListener implements Listener {
final User user = ess.getUser(event.getEntity()); final User user = ess.getUser(event.getEntity());
if (user.isAuthorized("essentials.back.ondeath") && !ess.getSettings().isCommandDisabled("back")) { if (user.isAuthorized("essentials.back.ondeath") && !ess.getSettings().isCommandDisabled("back")) {
user.setLastLocation(); user.setLastLocation();
user.sendMessage(tl("backAfterDeath")); user.sendMessage(user.tl( "backAfterDeath"));
} }
if (!ess.getSettings().areDeathMessagesEnabled()) { if (!ess.getSettings().areDeathMessagesEnabled()) {
event.setDeathMessage(""); event.setDeathMessage("");

View File

@ -36,7 +36,7 @@ import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import static com.earth2me.essentials.I18n.tl; import static com.earth2me.essentials.I18n.capitalCase;
public class EssentialsPlayerListener implements Listener { public class EssentialsPlayerListener implements Listener {
@ -78,9 +78,9 @@ public class EssentialsPlayerListener implements Listener {
if (user.isMuted()) { if (user.isMuted()) {
event.setCancelled(true); event.setCancelled(true);
user.sendMessage(user.hasMuteReason() ? tl("voiceSilencedReason", user.getMuteReason()) : tl("voiceSilenced")); user.sendTl(user.hasMuteReason() ? user.tl("voiceSilencedReason", user.getMuteReason()) : user.tl("voiceSilenced"));
LOGGER.info(tl("mutedUserSpeaks", user.getName(), event.getMessage())); LOGGER.info(user.tl("mutedUserSpeaks", user.getName(), event.getMessage()));
} }
try { try {
final Iterator<Player> it = event.getRecipients().iterator(); final Iterator<Player> it = event.getRecipients().iterator();
@ -283,7 +283,7 @@ public class EssentialsPlayerListener implements Listener {
final List<String> mail = user.getMails(); final List<String> mail = user.getMails();
if (mail.isEmpty()) { if (mail.isEmpty()) {
if (ess.getSettings().isNotifyNoNewMail()) { if (ess.getSettings().isNotifyNoNewMail()) {
user.sendMessage(tl("noNewMail")); // Only notify if they want us to. user.sendTl("noNewMail"); // Only notify if they want us to.
} }
} else { } else {
user.notifyOfMail(); user.notifyOfMail();
@ -296,7 +296,7 @@ public class EssentialsPlayerListener implements Listener {
user.getBase().setAllowFlight(true); user.getBase().setAllowFlight(true);
user.getBase().setFlying(true); user.getBase().setFlying(true);
if (ess.getSettings().isSendFlyEnableOnJoin()) { if (ess.getSettings().isSendFlyEnableOnJoin()) {
user.getBase().sendMessage(tl("flyMode", tl("enabled"), user.getDisplayName())); user.sendTl("flyMode", user.tl( "enabled"), user.getDisplayName());
} }
} }
} }
@ -379,17 +379,19 @@ public class EssentialsPlayerListener implements Listener {
case KICK_BANNED: case KICK_BANNED:
BanEntry banEntry = ess.getServer().getBanList(BanList.Type.NAME).getBanEntry(event.getPlayer().getName()); BanEntry banEntry = ess.getServer().getBanList(BanList.Type.NAME).getBanEntry(event.getPlayer().getName());
if (banEntry != null) { if (banEntry != null) {
final User buser = ess.getUser(event.getPlayer());
Date banExpiry = banEntry.getExpiration(); Date banExpiry = banEntry.getExpiration();
if (banExpiry != null) { if (banExpiry != null) {
String expiry = DateUtil.formatDateDiff(banExpiry.getTime()); String expiry = DateUtil.formatDateDiff(banExpiry.getTime());
event.setKickMessage(tl("tempbanJoin", expiry, banEntry.getReason())); event.setKickMessage(buser.tl("tempbanJoin", expiry, banEntry.getReason()));
} else { } else {
event.setKickMessage(tl("banJoin", banEntry.getReason())); event.setKickMessage(buser.tl("banJoin", banEntry.getReason()));
} }
} else { } else {
banEntry = ess.getServer().getBanList(BanList.Type.IP).getBanEntry(event.getAddress().getHostAddress()); banEntry = ess.getServer().getBanList(BanList.Type.IP).getBanEntry(event.getAddress().getHostAddress());
if (banEntry != null) { if (banEntry != null) {
event.setKickMessage(tl("banIpJoin", banEntry.getReason())); final User buser = ess.getUser(event.getPlayer());
event.setKickMessage(buser.tl("banIpJoin", banEntry.getReason()));
} }
} }
break; break;
@ -407,7 +409,7 @@ public class EssentialsPlayerListener implements Listener {
event.allow(); event.allow();
return; return;
} }
event.disallow(Result.KICK_FULL, tl("serverFull")); event.disallow(Result.KICK_FULL, kfuser.tl("serverFull"));
break; break;
default: default:
break; break;
@ -469,9 +471,9 @@ public class EssentialsPlayerListener implements Listener {
for (User spyer : ess.getOnlineUsers()) { for (User spyer : ess.getOnlineUsers()) {
if (spyer.isSocialSpyEnabled() && !player.equals(spyer.getBase())) { if (spyer.isSocialSpyEnabled() && !player.equals(spyer.getBase())) {
if (user.isMuted() && ess.getSettings().getSocialSpyListenMutedPlayers()) { if (user.isMuted() && ess.getSettings().getSocialSpyListenMutedPlayers()) {
spyer.sendMessage(tl("socialSpyMutedPrefix") + player.getDisplayName() + ": " + event.getMessage()); spyer.sendMessage(spyer.tl( "socialSpyMutedPrefix") + player.getDisplayName() + ": " + event.getMessage());
} else { } else {
spyer.sendMessage(tl("socialSpyPrefix") + player.getDisplayName() + ": " + event.getMessage()); spyer.sendMessage(spyer.tl( "socialSpyPrefix") + player.getDisplayName() + ": " + event.getMessage());
} }
} }
} }
@ -479,10 +481,11 @@ public class EssentialsPlayerListener implements Listener {
} }
} }
if (ess.getUser(player).isMuted() && (ess.getSettings().getMuteCommands().contains(cmd) || ess.getSettings().getMuteCommands().contains("*"))) { final User user = ess.getUser(player);
if (user.isMuted() && (ess.getSettings().getMuteCommands().contains(cmd) || ess.getSettings().getMuteCommands().contains("*"))) {
event.setCancelled(true); event.setCancelled(true);
player.sendMessage(tl("voiceSilenced")); user.sendTl("voiceSilenced");
LOGGER.info(tl("mutedUserSpeaks", player.getName(), event.getMessage())); LOGGER.info(user.tl("mutedUserSpeaks", player.getName(), event.getMessage()));
return; return;
} }
@ -498,7 +501,6 @@ public class EssentialsPlayerListener implements Listener {
broadcast = false; broadcast = false;
} }
} }
final User user = ess.getUser(player);
if (update) { if (update) {
user.updateActivityOnInteract(broadcast); user.updateActivityOnInteract(broadcast);
} }
@ -523,8 +525,8 @@ public class EssentialsPlayerListener implements Listener {
} else if (entry.getKey().matcher(fullCommand).matches()) { } else if (entry.getKey().matcher(fullCommand).matches()) {
// User's current cooldown hasn't expired, inform and terminate cooldown code. // User's current cooldown hasn't expired, inform and terminate cooldown code.
if (entry.getValue() > System.currentTimeMillis()) { if (entry.getValue() > System.currentTimeMillis()) {
String commandCooldownTime = DateUtil.formatDateDiff(entry.getValue()); String commandCooldownTime = DateUtil.formatDateDiff(user.getSource(), entry.getValue());
user.sendMessage(tl("commandCooldown", commandCooldownTime)); user.sendTl("commandCooldown", commandCooldownTime);
cooldownFound = true; cooldownFound = true;
event.setCancelled(true); event.setCancelled(true);
break; break;
@ -583,11 +585,11 @@ public class EssentialsPlayerListener implements Listener {
if (ess.getSettings().getNoGodWorlds().contains(newWorld) && user.isGodModeEnabledRaw()) { if (ess.getSettings().getNoGodWorlds().contains(newWorld) && user.isGodModeEnabledRaw()) {
// Player god mode is never disabled in order to retain it when changing worlds once more. // Player god mode is never disabled in order to retain it when changing worlds once more.
// With that said, players will still take damage as per the result of User#isGodModeEnabled() // With that said, players will still take damage as per the result of User#isGodModeEnabled()
user.sendMessage(tl("noGodWorldWarning")); user.sendTl("noGodWorldWarning");
} }
if (!user.getWorld().getName().equals(newWorld)) { if (!user.getWorld().getName().equals(newWorld)) {
user.sendMessage(tl("currentWorld", newWorld)); user.sendTl("currentWorld", newWorld);
} }
if (user.isVanished()) { if (user.isVanished()) {
user.setVanished(user.isAuthorized("essentials.vanish")); user.setVanished(user.isAuthorized("essentials.vanish"));
@ -604,7 +606,7 @@ public class EssentialsPlayerListener implements Listener {
User player = ess.getUser(event.getPlayer()); User player = ess.getUser(event.getPlayer());
if (player.isAuthorized("essentials.sethome.bed") && player.getWorld().getEnvironment().equals(World.Environment.NORMAL)) { if (player.isAuthorized("essentials.sethome.bed") && player.getWorld().getEnvironment().equals(World.Environment.NORMAL)) {
player.getBase().setBedSpawnLocation(event.getClickedBlock().getLocation()); player.getBase().setBedSpawnLocation(event.getClickedBlock().getLocation());
player.sendMessage(tl("bedSet", player.getLocation().getWorld().getName(), player.getLocation().getBlockX(), player.getLocation().getBlockY(), player.getLocation().getBlockZ())); player.sendTl("bedSet", player.getLocation().getWorld().getName(), player.getLocation().getBlockX(), player.getLocation().getBlockY(), player.getLocation().getBlockZ());
} }
} }
break; break;

View File

@ -20,7 +20,7 @@ public class I18n implements net.ess3.api.II18n {
private static final String MESSAGES = "messages"; private static final String MESSAGES = "messages";
private final transient Locale defaultLocale = Locale.getDefault(); private final transient Locale defaultLocale = Locale.getDefault();
private transient Locale currentLocale = defaultLocale; private transient Locale currentLocale = defaultLocale;
private transient ResourceBundle customBundle; private transient Map<Locale, ResourceBundle> customBundles = new HashMap<>();
private transient ResourceBundle localeBundle; private transient ResourceBundle localeBundle;
private final transient ResourceBundle defaultBundle; private final transient ResourceBundle defaultBundle;
private transient Map<String, MessageFormat> messageFormatCache = new HashMap<String, MessageFormat>(); private transient Map<String, MessageFormat> messageFormatCache = new HashMap<String, MessageFormat>();
@ -40,7 +40,6 @@ public class I18n implements net.ess3.api.II18n {
this.ess = ess; this.ess = ess;
defaultBundle = ResourceBundle.getBundle(MESSAGES, Locale.ENGLISH); defaultBundle = ResourceBundle.getBundle(MESSAGES, Locale.ENGLISH);
localeBundle = defaultBundle; localeBundle = defaultBundle;
customBundle = NULL_BUNDLE;
} }
public void onEnable() { public void onEnable() {
@ -56,10 +55,32 @@ public class I18n implements net.ess3.api.II18n {
return currentLocale; return currentLocale;
} }
private String translate(final String string) { private ResourceBundle getBundle(Locale locale) {
if (customBundles.containsKey(locale)) {
return customBundles.get(locale);
}
ResourceBundle bundle;
try {
bundle = ResourceBundle.getBundle(MESSAGES, locale, new FileResClassLoader(I18n.class.getClassLoader(), ess));
} catch (MissingResourceException ex) {
try {
bundle = ResourceBundle.getBundle(MESSAGES, locale);
} catch (MissingResourceException ex2) {
bundle = NULL_BUNDLE;
}
}
customBundles.put(locale, bundle);
return bundle;
}
private String translate(Locale locale, final String string) {
if (locale == null) {
locale = currentLocale;
}
try { try {
try { try {
return customBundle.getString(string); return getBundle(locale).getString(string);
} catch (MissingResourceException ex) { } catch (MissingResourceException ex) {
return localeBundle.getString(string); return localeBundle.getString(string);
} }
@ -70,18 +91,26 @@ public class I18n implements net.ess3.api.II18n {
} }
public static String tl(final String string, final Object... objects) { public static String tl(final String string, final Object... objects) {
return tl(null, string, objects);
}
public static String tl(final Locale locale, final String string, final Object... objects) {
if (instance == null) { if (instance == null) {
return ""; return "";
} }
if (objects.length == 0) { if (objects.length == 0) {
return NODOUBLEMARK.matcher(instance.translate(string)).replaceAll("'"); return NODOUBLEMARK.matcher(instance.translate(locale, string)).replaceAll("'");
} else { } else {
return instance.format(string, objects); return instance.format(locale, string, objects);
} }
} }
public String format(final String string, final Object... objects) { public String format(final String string, final Object... objects) {
String format = translate(string); return format(null, string, objects);
}
public String format(final Locale locale, final String string, final Object... objects) {
String format = translate(locale, string);
MessageFormat messageFormat = messageFormatCache.get(format); MessageFormat messageFormat = messageFormatCache.get(format);
if (messageFormat == null) { if (messageFormat == null) {
try { try {
@ -98,16 +127,7 @@ public class I18n implements net.ess3.api.II18n {
public void updateLocale(final String loc) { public void updateLocale(final String loc) {
if (loc != null && !loc.isEmpty()) { if (loc != null && !loc.isEmpty()) {
final String[] parts = loc.split("[_\\.]"); currentLocale = getLocale(loc);
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]);
}
} }
ResourceBundle.clearCache(); ResourceBundle.clearCache();
messageFormatCache = new HashMap<String, MessageFormat>(); messageFormatCache = new HashMap<String, MessageFormat>();
@ -119,11 +139,24 @@ public class I18n implements net.ess3.api.II18n {
localeBundle = NULL_BUNDLE; localeBundle = NULL_BUNDLE;
} }
try { customBundles.clear();
customBundle = ResourceBundle.getBundle(MESSAGES, currentLocale, new FileResClassLoader(I18n.class.getClassLoader(), ess));
} catch (MissingResourceException ex) {
customBundle = NULL_BUNDLE;
} }
public static Locale getLocale(String loc) {
if (loc == null) {
return instance.currentLocale;
}
final String[] parts = loc.split("[_\\.]");
if (parts.length == 1) {
return new Locale(parts[0]);
}
if (parts.length == 2) {
return new Locale(parts[0], parts[1]);
}
if (parts.length == 3) {
return new Locale(parts[0], parts[1], parts[2]);
}
return instance.currentLocale;
} }
public static String capitalCase(final String input) { public static String capitalCase(final String input) {

View File

@ -49,6 +49,14 @@ public interface IEssentials extends Plugin {
int broadcastMessage(String permission, String message); int broadcastMessage(String permission, String message);
int broadcastTl(String string, Object... objects);
int broadcastTl(IUser sender, String string, Object... objects);
int broadcastTl(CommandSource sender, String string, Object... objects);
int broadcastTl(String permission, String string, Object... objects);
ISettings getSettings(); ISettings getSettings();
BukkitScheduler getScheduler(); BukkitScheduler getScheduler();

View File

@ -164,6 +164,8 @@ public interface ISettings extends IConf {
boolean changeDisplayName(); boolean changeDisplayName();
boolean changeLocale();
boolean changePlayerListName(); boolean changePlayerListName();
boolean isPlayerCommand(String string); boolean isPlayerCommand(String string);

View File

@ -10,6 +10,7 @@ import org.bukkit.entity.Player;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.regex.Pattern; import java.util.regex.Pattern;
@ -106,6 +107,10 @@ public interface IUser {
void sendMessage(String message); void sendMessage(String message);
void sendTl(String string, Object... objects);
String tl(String string, Object... objects);
/* /*
* UserData * UserData
*/ */
@ -191,4 +196,10 @@ public interface IUser {
void setLastMessageReplyRecipient(boolean enabled); void setLastMessageReplyRecipient(boolean enabled);
Map<User, BigDecimal> getConfirmingPayments(); Map<User, BigDecimal> getConfirmingPayments();
Locale getApplicableLocale();
Locale getLocale();
void setLocale(Locale locale);
} }

View File

@ -237,7 +237,7 @@ public class Jails extends AsyncStorageObjectHolder<com.earth2me.essentials.sett
LOGGER.log(Level.INFO, tl("returnPlayerToJailError", user.getName(), ex.getLocalizedMessage())); LOGGER.log(Level.INFO, tl("returnPlayerToJailError", user.getName(), ex.getLocalizedMessage()));
} }
} }
user.sendMessage(tl("jailMessage")); user.sendTl("jailMessage");
} }
@EventHandler(priority = EventPriority.HIGHEST) @EventHandler(priority = EventPriority.HIGHEST)
@ -258,7 +258,7 @@ public class Jails extends AsyncStorageObjectHolder<com.earth2me.essentials.sett
LOGGER.log(Level.INFO, tl("returnPlayerToJailError", user.getName(), ex.getLocalizedMessage())); LOGGER.log(Level.INFO, tl("returnPlayerToJailError", user.getName(), ex.getLocalizedMessage()));
} }
} }
user.sendMessage(tl("jailMessage")); user.sendTl("jailMessage");
} }
} }
} }

View File

@ -42,7 +42,7 @@ public class Kit {
public void checkPerms(final User user) throws Exception { public void checkPerms(final User user) throws Exception {
if (!user.isAuthorized("essentials.kits." + kitName)) { if (!user.isAuthorized("essentials.kits." + kitName)) {
throw new Exception(tl("noKitPermission", "essentials.kits." + kitName)); throw new Exception(user.tl( "noKitPermission", "essentials.kits." + kitName));
} }
} }
@ -52,10 +52,10 @@ public class Kit {
if (nextUse == 0L) { if (nextUse == 0L) {
return; return;
} else if (nextUse < 0L) { } else if (nextUse < 0L) {
user.sendMessage(tl("kitOnce")); user.sendTl("kitOnce");
throw new NoChargeException(); throw new NoChargeException();
} else { } else {
user.sendMessage(tl("kitTimed", DateUtil.formatDateDiff(nextUse))); user.sendTl("kitTimed", DateUtil.formatDateDiff(user.getSource(), nextUse));
throw new NoChargeException(); throw new NoChargeException();
} }
} }
@ -85,7 +85,7 @@ public class Kit {
// Make sure delay is valid // Make sure delay is valid
delay = kit.containsKey("delay") ? ((Number) kit.get("delay")).doubleValue() : 0.0d; delay = kit.containsKey("delay") ? ((Number) kit.get("delay")).doubleValue() : 0.0d;
} catch (Exception e) { } catch (Exception e) {
throw new Exception(tl("kitError2")); throw new Exception(user.tl( "kitError2"));
} }
// When was the last kit used? // When was the last kit used?
@ -203,12 +203,12 @@ public class Kit {
} }
user.getBase().updateInventory(); user.getBase().updateInventory();
if (spew) { if (spew) {
user.sendMessage(tl("kitInvFull")); user.sendTl("kitInvFull");
} }
} catch (Exception e) { } catch (Exception e) {
user.getBase().updateInventory(); user.getBase().updateInventory();
ess.getLogger().log(Level.WARNING, e.getMessage()); ess.getLogger().log(Level.WARNING, e.getMessage());
throw new Exception(tl("kitError2"), e); throw new Exception(user.tl( "kitError2"), e);
} }
} }
} }

View File

@ -97,7 +97,7 @@ public class Kits implements IConf {
String name = capitalCase(kitItem); String name = capitalCase(kitItem);
BigDecimal costPrice = new Trade("kit-" + kitItem.toLowerCase(Locale.ENGLISH), ess).getCommandCost(user); BigDecimal costPrice = new Trade("kit-" + kitItem.toLowerCase(Locale.ENGLISH), ess).getCommandCost(user);
if (costPrice.signum() > 0) { if (costPrice.signum() > 0) {
cost = tl("kitCost", NumberUtil.displayCurrency(costPrice, ess)); cost = user.tl( "kitCost", NumberUtil.displayCurrency(costPrice, ess));
} }
Kit kit = new Kit(kitItem, ess); Kit kit = new Kit(kitItem, ess);
@ -105,7 +105,7 @@ public class Kits implements IConf {
if (nextUse == -1 && ess.getSettings().isSkippingUsedOneTimeKitsFromKitList()) { if (nextUse == -1 && ess.getSettings().isSkippingUsedOneTimeKitsFromKitList()) {
continue; continue;
} else if (nextUse != 0) { } else if (nextUse != 0) {
name = tl("kitDelay", name); name = user.tl( "kitDelay", name);
} }
list.append(" ").append(name).append(cost); list.append(" ").append(name).append(cost);
@ -113,7 +113,7 @@ public class Kits implements IConf {
} }
return list.toString().trim(); return list.toString().trim();
} catch (Exception ex) { } catch (Exception ex) {
throw new Exception(tl("kitError"), ex); throw new Exception(user.tl( "kitError"), ex);
} }
} }

View File

@ -11,7 +11,7 @@ import com.google.common.base.Joiner;
import net.ess3.api.IEssentials; import net.ess3.api.IEssentials;
import net.ess3.nms.refl.ReflUtil; import net.ess3.nms.refl.ReflUtil;
import org.apache.commons.lang.ArrayUtils; import org.bukkit.Bukkit;
import org.bukkit.Color; import org.bukkit.Color;
import org.bukkit.DyeColor; import org.bukkit.DyeColor;
import org.bukkit.FireworkEffect; import org.bukkit.FireworkEffect;
@ -127,7 +127,7 @@ public class MetaItemStack {
ess.getLogger().log(Level.INFO, "Itemstack is invalid", npe); ess.getLogger().log(Level.INFO, "Itemstack is invalid", npe);
} }
} catch (NoSuchMethodError nsme) { } catch (NoSuchMethodError nsme) {
throw new Exception(tl("noMetaJson"), nsme); throw new Exception(sender.tl("noMetaJson"), nsme);
} catch (Throwable throwable) { } catch (Throwable throwable) {
throw new Exception(throwable.getMessage(), throwable); throw new Exception(throwable.getMessage(), throwable);
} }
@ -137,13 +137,13 @@ public class MetaItemStack {
} }
if (validFirework) { if (validFirework) {
if (!hasMetaPermission(sender, "firework", true, true, ess)) { if (!hasMetaPermission(sender, "firework", true, true, ess)) {
throw new Exception(tl("noMetaFirework")); throw new Exception(sender.tl("noMetaFirework"));
} }
FireworkEffect effect = builder.build(); FireworkEffect effect = builder.build();
FireworkMeta fmeta = (FireworkMeta) stack.getItemMeta(); FireworkMeta fmeta = (FireworkMeta) stack.getItemMeta();
fmeta.addEffect(effect); fmeta.addEffect(effect);
if (fmeta.getEffects().size() > 1 && !hasMetaPermission(sender, "firework-multiple", true, true, ess)) { if (fmeta.getEffects().size() > 1 && !hasMetaPermission(sender, "firework-multiple", true, true, ess)) {
throw new Exception(tl("multipleCharges")); throw new Exception(sender.tl("multipleCharges"));
} }
stack.setItemMeta(fmeta); stack.setItemMeta(fmeta);
} }
@ -181,7 +181,7 @@ public class MetaItemStack {
meta.setOwningPlayer(ess.getServer().getOfflinePlayer(owner)); meta.setOwningPlayer(ess.getServer().getOfflinePlayer(owner));
stack.setItemMeta(meta); stack.setItemMeta(meta);
} else { } else {
throw new Exception(tl("onlyPlayerSkulls")); throw new Exception(sender.tl("onlyPlayerSkulls"));
} }
} else if (split.length > 1 && split[0].equalsIgnoreCase("book") && stack.getType() == WRITTEN_BOOK && (hasMetaPermission(sender, "book", true, true, ess) || hasMetaPermission(sender, "chapter-" + split[1].toLowerCase(Locale.ENGLISH), true, true, ess))) { } else if (split.length > 1 && split[0].equalsIgnoreCase("book") && stack.getType() == WRITTEN_BOOK && (hasMetaPermission(sender, "book", true, true, ess) || hasMetaPermission(sender, "chapter-" + split[1].toLowerCase(Locale.ENGLISH), true, true, ess))) {
final BookMeta meta = (BookMeta) stack.getItemMeta(); final BookMeta meta = (BookMeta) stack.getItemMeta();
@ -207,7 +207,7 @@ public class MetaItemStack {
meta.setPower(power > 3 ? 4 : power); meta.setPower(power > 3 ? 4 : power);
stack.setItemMeta(meta); stack.setItemMeta(meta);
} else if (split.length > 1 && split[0].equalsIgnoreCase("itemflags") && hasMetaPermission(sender, "itemflags", false, true, ess)) { } else if (split.length > 1 && split[0].equalsIgnoreCase("itemflags") && hasMetaPermission(sender, "itemflags", false, true, ess)) {
addItemFlags(string); addItemFlags(sender, string);
} else if (MaterialUtil.isFirework(stack.getType())) { } else if (MaterialUtil.isFirework(stack.getType())) {
//WARNING - Meta for fireworks will be ignored after this point. //WARNING - Meta for fireworks will be ignored after this point.
addFireworkMeta(sender, false, string, ess); addFireworkMeta(sender, false, string, ess);
@ -244,17 +244,25 @@ public class MetaItemStack {
meta.setColor(Color.fromRGB(red, green, blue)); meta.setColor(Color.fromRGB(red, green, blue));
stack.setItemMeta(meta); stack.setItemMeta(meta);
} else { } else {
throw new Exception(tl("leatherSyntax")); throw new Exception(sender.tl("leatherSyntax"));
} }
} else { } else {
parseEnchantmentStrings(sender, allowUnsafe, split, ess); parseEnchantmentStrings(sender, allowUnsafe, split, ess);
} }
} }
/**
* @deprecated Use {@link #addItemFlags(CommandSource, String)}
*/
@Deprecated
public void addItemFlags(final String string) throws Exception { public void addItemFlags(final String string) throws Exception {
addItemFlags(new CommandSource(Bukkit.getConsoleSender()), string);
}
public void addItemFlags(CommandSource sender, final String string) throws Exception {
String[] separate = splitPattern.split(string, 2); String[] separate = splitPattern.split(string, 2);
if (separate.length != 2) { if (separate.length != 2) {
throw new Exception(tl("invalidItemFlagMeta", string)); throw new Exception(sender.tl("invalidItemFlagMeta", string));
} }
String[] split = separate[1].split(","); String[] split = separate[1].split(",");
@ -269,7 +277,7 @@ public class MetaItemStack {
} }
if (meta.getItemFlags().isEmpty()) { if (meta.getItemFlags().isEmpty()) {
throw new Exception(tl("invalidItemFlagMeta", string)); throw new Exception(sender.tl("invalidItemFlagMeta", string));
} }
stack.setItemMeta(meta); stack.setItemMeta(meta);
@ -285,13 +293,13 @@ public class MetaItemStack {
if (split[0].equalsIgnoreCase("color") || split[0].equalsIgnoreCase("colour") || (allowShortName && split[0].equalsIgnoreCase("c"))) { if (split[0].equalsIgnoreCase("color") || split[0].equalsIgnoreCase("colour") || (allowShortName && split[0].equalsIgnoreCase("c"))) {
if (validFirework) { if (validFirework) {
if (!hasMetaPermission(sender, "firework", true, true, ess)) { if (!hasMetaPermission(sender, "firework", true, true, ess)) {
throw new Exception(tl("noMetaFirework")); throw new Exception(sender.tl("noMetaFirework"));
} }
FireworkEffect effect = builder.build(); FireworkEffect effect = builder.build();
FireworkMeta fmeta = (FireworkMeta) stack.getItemMeta(); FireworkMeta fmeta = (FireworkMeta) stack.getItemMeta();
fmeta.addEffect(effect); fmeta.addEffect(effect);
if (fmeta.getEffects().size() > 1 && !hasMetaPermission(sender, "firework-multiple", true, true, ess)) { if (fmeta.getEffects().size() > 1 && !hasMetaPermission(sender, "firework-multiple", true, true, ess)) {
throw new Exception(tl("multipleCharges")); throw new Exception(sender.tl("multipleCharges"));
} }
stack.setItemMeta(fmeta); stack.setItemMeta(fmeta);
builder = FireworkEffect.builder(); builder = FireworkEffect.builder();
@ -304,7 +312,7 @@ public class MetaItemStack {
validFirework = true; validFirework = true;
primaryColors.add(colorMap.get(color.toUpperCase()).getFireworkColor()); primaryColors.add(colorMap.get(color.toUpperCase()).getFireworkColor());
} else { } else {
throw new Exception(tl("invalidFireworkFormat", split[1], split[0])); throw new Exception(sender.tl("invalidFireworkFormat", split[1], split[0]));
} }
} }
builder.withColor(primaryColors); builder.withColor(primaryColors);
@ -314,7 +322,7 @@ public class MetaItemStack {
if (fireworkShape.containsKey(split[1].toUpperCase())) { if (fireworkShape.containsKey(split[1].toUpperCase())) {
finalEffect = fireworkShape.get(split[1].toUpperCase()); finalEffect = fireworkShape.get(split[1].toUpperCase());
} else { } else {
throw new Exception(tl("invalidFireworkFormat", split[1], split[0])); throw new Exception(sender.tl("invalidFireworkFormat", split[1], split[0]));
} }
if (finalEffect != null) { if (finalEffect != null) {
builder.with(finalEffect); builder.with(finalEffect);
@ -326,7 +334,7 @@ public class MetaItemStack {
if (colorMap.containsKey(color.toUpperCase())) { if (colorMap.containsKey(color.toUpperCase())) {
fadeColors.add(colorMap.get(color.toUpperCase()).getFireworkColor()); fadeColors.add(colorMap.get(color.toUpperCase()).getFireworkColor());
} else { } else {
throw new Exception(tl("invalidFireworkFormat", split[1], split[0])); throw new Exception(sender.tl("invalidFireworkFormat", split[1], split[0]));
} }
} }
if (!fadeColors.isEmpty()) { if (!fadeColors.isEmpty()) {
@ -340,7 +348,7 @@ public class MetaItemStack {
} else if (effect.equalsIgnoreCase("trail")) { } else if (effect.equalsIgnoreCase("trail")) {
builder.trail(true); builder.trail(true);
} else { } else {
throw new Exception(tl("invalidFireworkFormat", split[1], split[0])); throw new Exception(sender.tl("invalidFireworkFormat", split[1], split[0]));
} }
} }
} }
@ -361,10 +369,10 @@ public class MetaItemStack {
if (hasMetaPermission(sender, "potions." + pEffectType.getName().toLowerCase(Locale.ENGLISH), true, false, ess)) { if (hasMetaPermission(sender, "potions." + pEffectType.getName().toLowerCase(Locale.ENGLISH), true, false, ess)) {
validPotionEffect = true; validPotionEffect = true;
} else { } else {
throw new Exception(tl("noPotionEffectPerm", pEffectType.getName().toLowerCase(Locale.ENGLISH))); throw new Exception(sender.tl("noPotionEffectPerm", pEffectType.getName().toLowerCase(Locale.ENGLISH)));
} }
} else { } else {
throw new Exception(tl("invalidPotionMeta", split[1])); throw new Exception(sender.tl("invalidPotionMeta", split[1]));
} }
} else if (split[0].equalsIgnoreCase("power") || (allowShortName && split[0].equalsIgnoreCase("p"))) { } else if (split[0].equalsIgnoreCase("power") || (allowShortName && split[0].equalsIgnoreCase("p"))) {
if (NumberUtil.isInt(split[1])) { if (NumberUtil.isInt(split[1])) {
@ -374,14 +382,14 @@ public class MetaItemStack {
power -= 1; power -= 1;
} }
} else { } else {
throw new Exception(tl("invalidPotionMeta", split[1])); throw new Exception(sender.tl("invalidPotionMeta", split[1]));
} }
} else if (split[0].equalsIgnoreCase("duration") || (allowShortName && split[0].equalsIgnoreCase("d"))) { } else if (split[0].equalsIgnoreCase("duration") || (allowShortName && split[0].equalsIgnoreCase("d"))) {
if (NumberUtil.isInt(split[1])) { if (NumberUtil.isInt(split[1])) {
validPotionDuration = true; validPotionDuration = true;
duration = Integer.parseInt(split[1]) * 20; //Duration is in ticks by default, converted to seconds duration = Integer.parseInt(split[1]) * 20; //Duration is in ticks by default, converted to seconds
} else { } else {
throw new Exception(tl("invalidPotionMeta", split[1])); throw new Exception(sender.tl("invalidPotionMeta", split[1]));
} }
} else if (split[0].equalsIgnoreCase("splash") || (allowShortName && split[0].equalsIgnoreCase("s"))) { } else if (split[0].equalsIgnoreCase("splash") || (allowShortName && split[0].equalsIgnoreCase("s"))) {
isSplashPotion = Boolean.valueOf(split[1]); isSplashPotion = Boolean.valueOf(split[1]);
@ -391,7 +399,7 @@ public class MetaItemStack {
PotionMeta pmeta = (PotionMeta) stack.getItemMeta(); PotionMeta pmeta = (PotionMeta) stack.getItemMeta();
pEffect = pEffectType.createEffect(duration, power); pEffect = pEffectType.createEffect(duration, power);
if (pmeta.getCustomEffects().size() > 1 && !hasMetaPermission(sender, "potions.multiple", true, false, ess)) { if (pmeta.getCustomEffects().size() > 1 && !hasMetaPermission(sender, "potions.multiple", true, false, ess)) {
throw new Exception(tl("multiplePotionEffects")); throw new Exception(sender.tl("multiplePotionEffects"));
} }
pmeta.addCustomEffect(pEffect, true); pmeta.addCustomEffect(pEffect, true);
stack.setItemMeta(pmeta); stack.setItemMeta(pmeta);
@ -434,7 +442,7 @@ public class MetaItemStack {
public void addEnchantment(final CommandSource sender, final boolean allowUnsafe, final Enchantment enchantment, final int level) throws Exception { public void addEnchantment(final CommandSource sender, final boolean allowUnsafe, final Enchantment enchantment, final int level) throws Exception {
if (enchantment == null) { if (enchantment == null) {
throw new Exception(tl("enchantmentNotFound")); throw new Exception(sender.tl("enchantmentNotFound"));
} }
try { try {
if (stack.getType().equals(Material.ENCHANTED_BOOK)) { if (stack.getType().equals(Material.ENCHANTED_BOOK)) {
@ -471,7 +479,7 @@ public class MetaItemStack {
final String enchantmentName = enchantment.getName().toLowerCase(Locale.ENGLISH); final String enchantmentName = enchantment.getName().toLowerCase(Locale.ENGLISH);
if (!hasMetaPermission(user, "enchantments." + enchantmentName, true, false)) { if (!hasMetaPermission(user, "enchantments." + enchantmentName, true, false)) {
throw new Exception(tl("enchantmentPerm", enchantmentName)); throw new Exception(user.tl( "enchantmentPerm", enchantmentName));
} }
return enchantment; return enchantment;
} }
@ -481,7 +489,7 @@ public class MetaItemStack {
final String[] split = splitPattern.split(string, 2); final String[] split = splitPattern.split(string, 2);
if (split.length < 2) { if (split.length < 2) {
throw new Exception(tl("invalidBanner", split[1])); throw new Exception(sender.tl("invalidBanner", split[1]));
} }
PatternType patternType = null; PatternType patternType = null;
@ -505,7 +513,7 @@ public class MetaItemStack {
final String[] split = splitPattern.split(string, 2); final String[] split = splitPattern.split(string, 2);
if (split.length < 2) { if (split.length < 2) {
throw new Exception(tl("invalidBanner", split[1])); throw new Exception(sender.tl("invalidBanner", split[1]));
} }
PatternType patternType = null; PatternType patternType = null;
@ -545,7 +553,7 @@ public class MetaItemStack {
if (graceful) { if (graceful) {
return false; return false;
} else { } else {
throw new Exception(tl("noMetaPerm", metaPerm)); throw new Exception(user.tl( "noMetaPerm", metaPerm));
} }
} }

View File

@ -1,6 +1,7 @@
package com.earth2me.essentials; package com.earth2me.essentials;
import com.earth2me.essentials.utils.FormatUtil; import com.earth2me.essentials.utils.FormatUtil;
import org.bukkit.Bukkit;
import org.bukkit.Server; import org.bukkit.Server;
import java.util.*; import java.util.*;
@ -10,7 +11,12 @@ import static com.earth2me.essentials.I18n.tl;
public class PlayerList { public class PlayerList {
// Cosmetic list formatting // Cosmetic list formatting
@Deprecated
public static String listUsers(final IEssentials ess, final List<User> users, final String seperator) { public static String listUsers(final IEssentials ess, final List<User> users, final String seperator) {
return listUsers(ess, new CommandSource(Bukkit.getConsoleSender()), users, seperator);
}
public static String listUsers(final IEssentials ess, final CommandSource sender, final List<User> users, final String seperator) {
final StringBuilder groupString = new StringBuilder(); final StringBuilder groupString = new StringBuilder();
Collections.sort(users); Collections.sort(users);
boolean needComma = false; boolean needComma = false;
@ -20,10 +26,10 @@ public class PlayerList {
} }
needComma = true; needComma = true;
if (user.isAfk()) { if (user.isAfk()) {
groupString.append(tl("listAfkTag")); groupString.append(sender.tl("listAfkTag"));
} }
if (user.isHidden()) { if (user.isHidden()) {
groupString.append(tl("listHiddenTag")); groupString.append(sender.tl("listHiddenTag"));
} }
user.setDisplayNick(); user.setDisplayNick();
groupString.append(user.getDisplayName()); groupString.append(user.getDisplayName());
@ -32,24 +38,28 @@ public class PlayerList {
return groupString.toString(); return groupString.toString();
} }
// Produce a user summary: There are 5 out of maximum 10 players online. @Deprecated
public static String listSummary(final IEssentials ess, final User user, final boolean showHidden) { public static String listSummary(final IEssentials ess, final User user, final boolean showHidden) {
return listSummary(ess, new CommandSource(user), showHidden);
}
public static String listSummary(final IEssentials ess, final CommandSource sender, final boolean showHidden) {
Server server = ess.getServer(); Server server = ess.getServer();
int playerHidden = 0; int playerHidden = 0;
int hiddenCount = 0; int hiddenCount = 0;
for (User onlinePlayer : ess.getOnlineUsers()) { for (User onlinePlayer : ess.getOnlineUsers()) {
if (onlinePlayer.isHidden() || (user != null && !user.getBase().canSee(onlinePlayer.getBase()))) { if (onlinePlayer.isHidden() || (sender.getUser() != null && !sender.getUser().getBase().canSee(onlinePlayer.getBase()))) {
playerHidden++; playerHidden++;
if (showHidden || user.getBase().canSee(onlinePlayer.getBase())) { if (showHidden || sender.getUser().getBase().canSee(onlinePlayer.getBase())) {
hiddenCount++; hiddenCount++;
} }
} }
} }
String online; String online;
if (hiddenCount > 0) { if (hiddenCount > 0) {
online = tl("listAmountHidden", ess.getOnlinePlayers().size() - playerHidden, hiddenCount, server.getMaxPlayers()); online = sender.tl("listAmountHidden", ess.getOnlinePlayers().size() - playerHidden, hiddenCount, server.getMaxPlayers());
} else { } else {
online = tl("listAmount", ess.getOnlinePlayers().size() - playerHidden, server.getMaxPlayers()); online = sender.tl("listAmount", ess.getOnlinePlayers().size() - playerHidden, server.getMaxPlayers());
} }
return online; return online;
} }
@ -98,25 +108,35 @@ public class PlayerList {
} }
// Output a playerlist of just a single group, /list <groupname> // Output a playerlist of just a single group, /list <groupname>
@Deprecated
public static String listGroupUsers(final IEssentials ess, final Map<String, List<User>> playerList, final String groupName) throws Exception { public static String listGroupUsers(final IEssentials ess, final Map<String, List<User>> playerList, final String groupName) throws Exception {
return listGroupUsers(ess, new CommandSource(Bukkit.getConsoleSender()), playerList, groupName);
}
public static String listGroupUsers(final IEssentials ess, final CommandSource sender, final Map<String, List<User>> playerList, final String groupName) throws Exception {
final List<User> users = getMergedList(ess, playerList, groupName); final List<User> users = getMergedList(ess, playerList, groupName);
final List<User> groupUsers = playerList.get(groupName); final List<User> groupUsers = playerList.get(groupName);
if (groupUsers != null && !groupUsers.isEmpty()) { if (groupUsers != null && !groupUsers.isEmpty()) {
users.addAll(groupUsers); users.addAll(groupUsers);
} }
if (users == null || users.isEmpty()) { if (users == null || users.isEmpty()) {
throw new Exception(tl("groupDoesNotExist")); throw new Exception(sender.tl("groupDoesNotExist"));
} }
final StringBuilder displayGroupName = new StringBuilder(); final StringBuilder displayGroupName = new StringBuilder();
displayGroupName.append(Character.toTitleCase(groupName.charAt(0))); displayGroupName.append(Character.toTitleCase(groupName.charAt(0)));
displayGroupName.append(groupName.substring(1)); displayGroupName.append(groupName.substring(1));
return outputFormat(displayGroupName.toString(), listUsers(ess, users, ", ")); return outputFormat(sender, displayGroupName.toString(), listUsers(ess, users, ", "));
} }
// Build the output string // Build the output string
@Deprecated
public static String outputFormat(final String group, final String message) { public static String outputFormat(final String group, final String message) {
return outputFormat(new CommandSource(Bukkit.getConsoleSender()), group, message);
}
public static String outputFormat(final CommandSource sender, final String group, final String message) {
final StringBuilder outputString = new StringBuilder(); final StringBuilder outputString = new StringBuilder();
outputString.append(tl("listGroupTag", FormatUtil.replaceFormat(group))); outputString.append(sender.tl("listGroupTag", FormatUtil.replaceFormat(group)));
outputString.append(message); outputString.append(message);
return outputString.toString(); return outputString.toString();
} }

View File

@ -805,6 +805,17 @@ public class Settings implements net.ess3.api.ISettings {
return changeDisplayName; return changeDisplayName;
} }
private boolean changeLocale = true;
private boolean _changeLocale() {
return config.getBoolean("change-locale", true);
}
@Override
public boolean changeLocale() {
return changeLocale;
}
private boolean changePlayerListName = false; private boolean changePlayerListName = false;
private boolean _changePlayerListName() { private boolean _changePlayerListName() {

View File

@ -36,7 +36,7 @@ public class SpawnMob {
} }
} }
if (availableList.isEmpty()) { if (availableList.isEmpty()) {
availableList.add(tl("none")); availableList.add(user.tl( "none"));
} }
return StringUtil.joinList(availableList); return StringUtil.joinList(availableList);
} }
@ -78,7 +78,7 @@ public class SpawnMob {
public static void spawnmob(final IEssentials ess, final Server server, final User user, final List<String> parts, final List<String> data, int mobCount) throws Exception { public static void spawnmob(final IEssentials ess, final Server server, final User user, final List<String> parts, final List<String> data, int mobCount) throws Exception {
final Block block = LocationUtil.getTarget(user.getBase()).getBlock(); final Block block = LocationUtil.getTarget(user.getBase()).getBlock();
if (block == null) { if (block == null) {
throw new Exception(tl("unableToSpawnMob")); throw new Exception(user.tl( "unableToSpawnMob"));
} }
spawnmob(ess, server, user.getSource(), user, block.getLocation(), parts, data, mobCount); spawnmob(ess, server, user.getSource(), user, block.getLocation(), parts, data, mobCount);
} }
@ -109,7 +109,7 @@ public class SpawnMob {
if (mobCount > effectiveLimit) { if (mobCount > effectiveLimit) {
mobCount = effectiveLimit; mobCount = effectiveLimit;
sender.sendMessage(tl("mobSpawnLimit")); sender.sendTl("mobSpawnLimit");
} }
Mob mob = Mob.fromName(parts.get(0)); // Get the first mob Mob mob = Mob.fromName(parts.get(0)); // Get the first mob
@ -117,13 +117,13 @@ public class SpawnMob {
for (int i = 0; i < mobCount; i++) { for (int i = 0; i < mobCount; i++) {
spawnMob(ess, server, sender, target, sloc, parts, data); spawnMob(ess, server, sender, target, sloc, parts, data);
} }
sender.sendMessage(mobCount * parts.size() + " " + mob.name.toLowerCase(Locale.ENGLISH) + mob.suffix + " " + tl("spawned")); sender.sendMessage(mobCount * parts.size() + " " + mob.name.toLowerCase(Locale.ENGLISH) + mob.suffix + " " + sender.tl("spawned"));
} catch (MobException e1) { } catch (MobException e1) {
throw new Exception(tl("unableToSpawnMob"), e1); throw new Exception(sender.tl("unableToSpawnMob"), e1);
} catch (NumberFormatException e2) { } catch (NumberFormatException e2) {
throw new Exception(tl("numberRequired"), e2); throw new Exception(sender.tl("numberRequired"), e2);
} catch (NullPointerException np) { } catch (NullPointerException np) {
throw new Exception(tl("soloMob"), np); throw new Exception(sender.tl("soloMob"), np);
} }
} }
@ -163,15 +163,15 @@ public class SpawnMob {
private static void checkSpawnable(IEssentials ess, CommandSource sender, Mob mob) throws Exception { private static void checkSpawnable(IEssentials ess, CommandSource sender, Mob mob) throws Exception {
if (mob == null || mob.getType() == null) { if (mob == null || mob.getType() == null) {
throw new Exception(tl("invalidMob")); throw new Exception(sender.tl("invalidMob"));
} }
if (ess.getSettings().getProtectPreventSpawn(mob.getType().toString().toLowerCase(Locale.ENGLISH))) { if (ess.getSettings().getProtectPreventSpawn(mob.getType().toString().toLowerCase(Locale.ENGLISH))) {
throw new Exception(tl("disabledToSpawnMob")); throw new Exception(sender.tl("disabledToSpawnMob"));
} }
if (sender.isPlayer() && !ess.getUser(sender.getPlayer()).isAuthorized("essentials.spawnmob." + mob.name.toLowerCase(Locale.ENGLISH))) { if (sender.isPlayer() && !ess.getUser(sender.getPlayer()).isAuthorized("essentials.spawnmob." + mob.name.toLowerCase(Locale.ENGLISH))) {
throw new Exception(tl("noPermToSpawnMob")); throw new Exception(sender.tl("noPermToSpawnMob"));
} }
} }
@ -179,7 +179,7 @@ public class SpawnMob {
String data = inputData; String data = inputData;
if (data.isEmpty()) { if (data.isEmpty()) {
sender.sendMessage(tl("mobDataList", StringUtil.joinList(MobData.getValidHelp(spawned)))); sender.sendTl("mobDataList", StringUtil.joinList(MobData.getValidHelp(spawned)));
} }
if (spawned instanceof Zombie) { if (spawned instanceof Zombie) {

View File

@ -63,7 +63,7 @@ public class Teleport implements ITeleport {
time.setTimeInMillis(lastTime); time.setTimeInMillis(lastTime);
time.add(Calendar.SECOND, (int) cooldown); time.add(Calendar.SECOND, (int) cooldown);
time.add(Calendar.MILLISECOND, (int) ((cooldown * 1000.0) % 1000.0)); time.add(Calendar.MILLISECOND, (int) ((cooldown * 1000.0) % 1000.0));
throw new Exception(tl("timeBeforeTeleport", DateUtil.formatDateDiff(time.getTimeInMillis()))); throw new Exception(teleportOwner.tl( "timeBeforeTeleport", DateUtil.formatDateDiff(teleportOwner.getSource(), time.getTimeInMillis())));
} }
} }
// if justCheck is set, don't update lastTeleport; we're just checking // if justCheck is set, don't update lastTeleport; we're just checking
@ -95,7 +95,7 @@ public class Teleport implements ITeleport {
Calendar c = new GregorianCalendar(); Calendar c = new GregorianCalendar();
c.add(Calendar.SECOND, (int) delay); 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));
user.sendMessage(tl("dontMoveMessage", DateUtil.formatDateDiff(c.getTimeInMillis()))); user.sendTl("dontMoveMessage", DateUtil.formatDateDiff(user.getSource(), c.getTimeInMillis()));
} }
//The now function is used when you want to skip tp delay when teleporting someone to a location or player. //The now function is used when you want to skip tp delay when teleporting someone to a location or player.
@ -115,7 +115,7 @@ public class Teleport implements ITeleport {
} }
final ITarget target = new PlayerTarget(entity); final ITarget target = new PlayerTarget(entity);
now(teleportOwner, target, cause); now(teleportOwner, target, cause);
teleportOwner.sendMessage(tl("teleporting", target.getLocation().getWorld().getName(), target.getLocation().getBlockX(), target.getLocation().getBlockY(), target.getLocation().getBlockZ())); teleportOwner.sendTl("teleporting", target.getLocation().getWorld().getName(), target.getLocation().getBlockX(), target.getLocation().getBlockY(), target.getLocation().getBlockZ());
} }
protected void now(IUser teleportee, ITarget target, TeleportCause cause) throws Exception { protected void now(IUser teleportee, ITarget target, TeleportCause cause) throws Exception {
@ -131,7 +131,7 @@ public class Teleport implements ITeleport {
PaperLib.teleportAsync(teleportee.getBase(), LocationUtil.getSafeDestination(ess, teleportee, loc), cause); PaperLib.teleportAsync(teleportee.getBase(), LocationUtil.getSafeDestination(ess, teleportee, loc), cause);
} }
} else { } else {
throw new Exception(tl("unsafeTeleportDestination", loc.getWorld().getName(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ())); throw new Exception(teleportee.tl( "unsafeTeleportDestination", loc.getWorld().getName(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()));
} }
} else { } else {
if (ess.getSettings().isForceDisableTeleportSafety()) { if (ess.getSettings().isForceDisableTeleportSafety()) {
@ -162,7 +162,7 @@ public class Teleport implements ITeleport {
@Override @Override
public void teleport(Player entity, Trade chargeFor, TeleportCause cause) throws Exception { public void teleport(Player entity, Trade chargeFor, TeleportCause cause) throws Exception {
ITarget target = new PlayerTarget(entity); ITarget target = new PlayerTarget(entity);
teleportOwner.sendMessage(tl("teleportToPlayer", entity.getDisplayName())); teleportOwner.sendTl("teleportToPlayer", entity.getDisplayName());
teleport(teleportOwner, target, chargeFor, cause); teleport(teleportOwner, target, chargeFor, cause);
} }
@ -177,8 +177,8 @@ public class Teleport implements ITeleport {
public void teleportPlayer(IUser teleportee, Player entity, Trade chargeFor, TeleportCause cause) throws Exception { public void teleportPlayer(IUser teleportee, Player entity, Trade chargeFor, TeleportCause cause) throws Exception {
ITarget target = new PlayerTarget(entity); ITarget target = new PlayerTarget(entity);
teleport(teleportee, target, chargeFor, cause); teleport(teleportee, target, chargeFor, cause);
teleportee.sendMessage(tl("teleporting", target.getLocation().getWorld().getName(), target.getLocation().getBlockX(), target.getLocation().getBlockY(), target.getLocation().getBlockZ())); teleportee.sendTl("teleporting", target.getLocation().getWorld().getName(), target.getLocation().getBlockX(), target.getLocation().getBlockY(), target.getLocation().getBlockZ());
teleportOwner.sendMessage(tl("teleporting", target.getLocation().getWorld().getName(), target.getLocation().getBlockX(), target.getLocation().getBlockY(), target.getLocation().getBlockZ())); teleportOwner.sendTl("teleporting", target.getLocation().getWorld().getName(), target.getLocation().getBlockX(), target.getLocation().getBlockY(), target.getLocation().getBlockZ());
} }
private void teleport(IUser teleportee, ITarget target, Trade chargeFor, TeleportCause cause) throws Exception { private void teleport(IUser teleportee, ITarget target, Trade chargeFor, TeleportCause cause) throws Exception {
@ -292,9 +292,9 @@ public class Teleport implements ITeleport {
} }
warp = event.getWarp(); warp = event.getWarp();
Location loc = ess.getWarps().getWarp(warp); Location loc = ess.getWarps().getWarp(warp);
teleportee.sendMessage(tl("warpingTo", warp, loc.getWorld().getName(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ())); teleportee.sendTl("warpingTo", warp, loc.getWorld().getName(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
if (!teleportee.equals(teleportOwner)) { if (!teleportee.equals(teleportOwner)) {
teleportOwner.sendMessage(tl("warpingTo", warp, loc.getWorld().getName(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ())); teleportOwner.sendTl("warpingTo", warp, loc.getWorld().getName(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
} }
teleport(teleportee, new LocationTarget(loc), chargeFor, cause); teleport(teleportee, new LocationTarget(loc), chargeFor, cause);
} }
@ -310,7 +310,7 @@ public class Teleport implements ITeleport {
public void back(IUser teleporter, Trade chargeFor) throws Exception { public void back(IUser teleporter, Trade chargeFor) throws Exception {
tpType = TeleportType.BACK; tpType = TeleportType.BACK;
final Location loc = teleportOwner.getLastLocation(); final Location loc = teleportOwner.getLastLocation();
teleportOwner.sendMessage(tl("backUsageMsg", loc.getWorld().getName(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ())); teleportOwner.sendTl("backUsageMsg", loc.getWorld().getName(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
teleportOther(teleporter, teleportOwner, new LocationTarget(loc), chargeFor, TeleportCause.COMMAND); teleportOther(teleporter, teleportOwner, new LocationTarget(loc), chargeFor, TeleportCause.COMMAND);
} }

View File

@ -89,14 +89,14 @@ public class TimedTeleport implements Runnable {
try { try {
teleport.cooldown(false); teleport.cooldown(false);
} catch (Exception ex) { } catch (Exception ex) {
teleportOwner.sendMessage(tl("cooldownWithMessage", ex.getMessage())); teleportOwner.sendTl("cooldownWithMessage", ex.getMessage());
if (teleportOwner != teleportUser) { if (teleportOwner != teleportUser) {
teleportUser.sendMessage(tl("cooldownWithMessage", ex.getMessage())); teleportUser.sendTl("cooldownWithMessage", ex.getMessage());
} }
} }
try { try {
cancelTimer(false); cancelTimer(false);
teleportUser.sendMessage(tl("teleportationCommencing")); teleportUser.sendTl("teleportationCommencing");
try { try {
if (timer_chargeFor != null) { if (timer_chargeFor != null) {
@ -129,9 +129,9 @@ public class TimedTeleport implements Runnable {
try { try {
ess.getServer().getScheduler().cancelTask(timer_task); ess.getServer().getScheduler().cancelTask(timer_task);
if (notifyUser) { if (notifyUser) {
teleportOwner.sendMessage(tl("pendingTeleportCancelled")); teleportOwner.sendTl("pendingTeleportCancelled");
if (timer_teleportee != null && !timer_teleportee.equals(teleportOwner.getBase().getUniqueId())) { if (timer_teleportee != null && !timer_teleportee.equals(teleportOwner.getBase().getUniqueId())) {
ess.getUser(timer_teleportee).sendMessage(tl("pendingTeleportCancelled")); ess.getUser(timer_teleportee).sendTl("pendingTeleportCancelled");
} }
} }
} finally { } finally {

View File

@ -87,20 +87,20 @@ public class Trade {
} }
if (getMoney() != null && getMoney().signum() > 0 && !user.canAfford(getMoney())) { if (getMoney() != null && getMoney().signum() > 0 && !user.canAfford(getMoney())) {
throw new ChargeException(tl("notEnoughMoney", NumberUtil.displayCurrency(getMoney(), ess))); throw new ChargeException(user.tl("notEnoughMoney", NumberUtil.displayCurrency(getMoney(), ess)));
} }
if (getItemStack() != null && !user.getBase().getInventory().containsAtLeast(itemStack, itemStack.getAmount())) { if (getItemStack() != null && !user.getBase().getInventory().containsAtLeast(itemStack, itemStack.getAmount())) {
throw new ChargeException(tl("missingItems", getItemStack().getAmount(), ess.getItemDb().name(getItemStack()))); throw new ChargeException(user.tl("missingItems", getItemStack().getAmount(), ess.getItemDb().name(getItemStack())));
} }
BigDecimal money; BigDecimal money;
if (command != null && !command.isEmpty() && (money = getCommandCost(user)).signum() > 0 && !user.canAfford(money)) { if (command != null && !command.isEmpty() && (money = getCommandCost(user)).signum() > 0 && !user.canAfford(money)) {
throw new ChargeException(tl("notEnoughMoney", NumberUtil.displayCurrency(money, ess))); throw new ChargeException(user.tl("notEnoughMoney", NumberUtil.displayCurrency(money, ess)));
} }
if (exp != null && exp > 0 && SetExpFix.getTotalExperience(user.getBase()) < exp) { if (exp != null && exp > 0 && SetExpFix.getTotalExperience(user.getBase()) < exp) {
throw new ChargeException(tl("notEnoughExperience")); throw new ChargeException(user.tl("notEnoughExperience"));
} }
} }
@ -183,7 +183,7 @@ public class Trade {
ess.getLogger().log(Level.INFO, "charging user " + user.getName() + " money " + getMoney().toPlainString()); ess.getLogger().log(Level.INFO, "charging user " + user.getName() + " money " + getMoney().toPlainString());
} }
if (!user.canAfford(getMoney()) && getMoney().signum() > 0) { if (!user.canAfford(getMoney()) && getMoney().signum() > 0) {
throw new ChargeException(tl("notEnoughMoney", NumberUtil.displayCurrency(getMoney(), ess))); throw new ChargeException(user.tl("notEnoughMoney", NumberUtil.displayCurrency(getMoney(), ess)));
} }
user.takeMoney(getMoney()); user.takeMoney(getMoney());
} }
@ -192,7 +192,7 @@ public class Trade {
ess.getLogger().log(Level.INFO, "charging user " + user.getName() + " itemstack " + getItemStack().toString()); ess.getLogger().log(Level.INFO, "charging user " + user.getName() + " itemstack " + getItemStack().toString());
} }
if (!user.getBase().getInventory().containsAtLeast(getItemStack(), getItemStack().getAmount())) { if (!user.getBase().getInventory().containsAtLeast(getItemStack(), getItemStack().getAmount())) {
throw new ChargeException(tl("missingItems", getItemStack().getAmount(), getItemStack().getType().toString().toLowerCase(Locale.ENGLISH).replace("_", " "))); throw new ChargeException(user.tl("missingItems", getItemStack().getAmount(), getItemStack().getType().toString().toLowerCase(Locale.ENGLISH).replace("_", " ")));
} }
user.getBase().getInventory().removeItem(getItemStack()); user.getBase().getInventory().removeItem(getItemStack());
user.getBase().updateInventory(); user.getBase().updateInventory();
@ -200,7 +200,7 @@ public class Trade {
if (command != null) { if (command != null) {
final BigDecimal cost = getCommandCost(user); final BigDecimal cost = getCommandCost(user);
if (!user.canAfford(cost) && cost.signum() > 0) { if (!user.canAfford(cost) && cost.signum() > 0) {
throw new ChargeException(tl("notEnoughMoney", NumberUtil.displayCurrency(cost, ess))); throw new ChargeException(user.tl("notEnoughMoney", NumberUtil.displayCurrency(cost, ess)));
} }
user.takeMoney(cost); user.takeMoney(cost);
} }
@ -210,7 +210,7 @@ public class Trade {
} }
final int experience = SetExpFix.getTotalExperience(user.getBase()); final int experience = SetExpFix.getTotalExperience(user.getBase());
if (experience < getExperience() && getExperience() > 0) { if (experience < getExperience() && getExperience() > 0) {
throw new ChargeException(tl("notEnoughExperience")); throw new ChargeException(user.tl("notEnoughExperience"));
} }
SetExpFix.setTotalExperience(user.getBase(), experience - getExperience()); SetExpFix.setTotalExperience(user.getBase(), experience - getExperience());
} }

View File

@ -149,7 +149,7 @@ public class User extends UserData implements Comparable<User>, IMessageRecipien
cooldownTime.add(Calendar.SECOND, (int) cooldown); cooldownTime.add(Calendar.SECOND, (int) cooldown);
cooldownTime.add(Calendar.MILLISECOND, (int) ((cooldown * 1000.0) % 1000.0)); cooldownTime.add(Calendar.MILLISECOND, (int) ((cooldown * 1000.0) % 1000.0));
if (cooldownTime.after(now) && !isAuthorized("essentials.heal.cooldown.bypass")) { if (cooldownTime.after(now) && !isAuthorized("essentials.heal.cooldown.bypass")) {
throw new Exception(tl("timeBeforeHeal", DateUtil.formatDateDiff(cooldownTime.getTimeInMillis()))); throw new Exception(tl("timeBeforeHeal", DateUtil.formatDateDiff(getSource(), cooldownTime.getTimeInMillis())));
} }
} }
setLastHealTimestamp(now.getTimeInMillis()); setLastHealTimestamp(now.getTimeInMillis());
@ -168,7 +168,7 @@ public class User extends UserData implements Comparable<User>, IMessageRecipien
setMoney(getMoney().add(value)); setMoney(getMoney().add(value));
sendMessage(tl("addedToAccount", NumberUtil.displayCurrency(value, ess))); sendMessage(tl("addedToAccount", NumberUtil.displayCurrency(value, ess)));
if (initiator != null) { if (initiator != null) {
initiator.sendMessage(tl("addedToOthersAccount", NumberUtil.displayCurrency(value, ess), this.getDisplayName(), NumberUtil.displayCurrency(getMoney(), ess))); initiator.sendTl("addedToOthersAccount", NumberUtil.displayCurrency(value, ess), this.getDisplayName(), NumberUtil.displayCurrency(getMoney(), ess));
} }
} }
@ -182,7 +182,7 @@ public class User extends UserData implements Comparable<User>, IMessageRecipien
setMoney(getMoney().subtract(value)); setMoney(getMoney().subtract(value));
reciever.setMoney(reciever.getMoney().add(value)); reciever.setMoney(reciever.getMoney().add(value));
sendMessage(tl("moneySentTo", NumberUtil.displayCurrency(value, ess), reciever.getDisplayName())); sendMessage(tl("moneySentTo", NumberUtil.displayCurrency(value, ess), reciever.getDisplayName()));
reciever.sendMessage(tl("moneyRecievedFrom", NumberUtil.displayCurrency(value, ess), getDisplayName())); reciever.sendTl("moneyRecievedFrom", NumberUtil.displayCurrency(value, ess), getDisplayName());
} else { } else {
throw new ChargeException(tl("notEnoughMoney", NumberUtil.displayCurrency(value, ess))); throw new ChargeException(tl("notEnoughMoney", NumberUtil.displayCurrency(value, ess)));
} }
@ -205,7 +205,7 @@ public class User extends UserData implements Comparable<User>, IMessageRecipien
} }
sendMessage(tl("takenFromAccount", NumberUtil.displayCurrency(value, ess))); sendMessage(tl("takenFromAccount", NumberUtil.displayCurrency(value, ess)));
if (initiator != null) { if (initiator != null) {
initiator.sendMessage(tl("takenFromOthersAccount", NumberUtil.displayCurrency(value, ess), this.getDisplayName(), NumberUtil.displayCurrency(getMoney(), ess))); initiator.sendTl("takenFromOthersAccount", NumberUtil.displayCurrency(value, ess), this.getDisplayName(), NumberUtil.displayCurrency(getMoney(), ess));
} }
} }
@ -622,7 +622,7 @@ public class User extends UserData implements Comparable<User>, IMessageRecipien
for (User user : ess.getOnlineUsers()) { for (User user : ess.getOnlineUsers()) {
if (user.isAuthorized("essentials.kick.notify")) { if (user.isAuthorized("essentials.kick.notify")) {
user.sendMessage(tl("playerKicked", Console.NAME, getName(), kickReason)); user.sendTl("playerKicked", Console.NAME, getName(), kickReason);
} }
} }
} }
@ -822,6 +822,16 @@ public class User extends UserData implements Comparable<User>, IMessageRecipien
} }
} }
@Override
public void sendTl(String string, Object... objects) {
sendMessage(tl(string, objects));
}
@Override
public String tl(String string, Object... objects) {
return I18n.tl(getApplicableLocale(), string, objects);
}
@Override @Override
public int compareTo(final User other) { public int compareTo(final User other) {
return FormatUtil.stripFormat(getDisplayName()).compareToIgnoreCase(FormatUtil.stripFormat(other.getDisplayName())); return FormatUtil.stripFormat(getDisplayName()).compareToIgnoreCase(FormatUtil.stripFormat(other.getDisplayName()));
@ -843,7 +853,7 @@ public class User extends UserData implements Comparable<User>, IMessageRecipien
@Override @Override
public CommandSource getSource() { public CommandSource getSource() {
return new CommandSource(getBase()); return new CommandSource(this);
} }
@Override @Override
@ -893,6 +903,25 @@ public class User extends UserData implements Comparable<User>, IMessageRecipien
return confirmingPayments; return confirmingPayments;
} }
@Override
public Locale getApplicableLocale() {
if (!ess.getSettings().changeLocale()) {
return ess.getI18n().getCurrentLocale();
}
Locale locale = super.getLocale();
if (locale == null) {
if (getBase() != null) {
String clientLocale = ess.getPlayerLocaleProvider().getLocale(getBase());
if (clientLocale != null) {
return I18n.getLocale(clientLocale);
}
}
return ess.getI18n().getCurrentLocale();
}
return locale;
}
public String getConfirmingClearCommand() { public String getConfirmingClearCommand() {
return confirmingClearCommand; return confirmingClearCommand;
} }

View File

@ -95,6 +95,7 @@ public abstract class UserData extends PlayerExtension implements IConf {
confirmPay = _getConfirmPay(); confirmPay = _getConfirmPay();
confirmClear = _getConfirmClear(); confirmClear = _getConfirmClear();
lastMessageReplyRecipient = _getLastMessageReplyRecipient(); lastMessageReplyRecipient = _getLastMessageReplyRecipient();
locale = _getLocale();
} }
private BigDecimal money; private BigDecimal money;
@ -210,7 +211,7 @@ public abstract class UserData extends PlayerExtension implements IConf {
config.removeProperty("homes." + search); config.removeProperty("homes." + search);
config.save(); config.save();
} else { } else {
throw new Exception(tl("invalidHome", search)); throw new Exception(((User) this).tl("invalidHome", search));
} }
} }
@ -1000,6 +1001,22 @@ public abstract class UserData extends PlayerExtension implements IConf {
save(); save();
} }
private Locale locale = null;
private Locale _getLocale() {
return I18n.getLocale(config.getString("locale", null));
}
public Locale getLocale() {
return locale;
}
public void setLocale(Locale locale) {
this.locale = locale;
config.setProperty("locale", locale != null ? locale.toString() : null);
save();
}
public UUID getConfigUUID() { public UUID getConfigUUID() {
return config.uuid; return config.uuid;
} }

View File

@ -4,6 +4,7 @@ import com.earth2me.essentials.commands.WarpNotFoundException;
import com.earth2me.essentials.utils.StringUtil; import com.earth2me.essentials.utils.StringUtil;
import net.ess3.api.InvalidNameException; import net.ess3.api.InvalidNameException;
import net.ess3.api.InvalidWorldException; import net.ess3.api.InvalidWorldException;
import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Server; import org.bukkit.Server;
import java.io.File; import java.io.File;
@ -65,7 +66,7 @@ public class Warps implements IConf, net.ess3.api.IWarps {
if (conf == null) { if (conf == null) {
File confFile = new File(warpsFolder, filename + ".yml"); File confFile = new File(warpsFolder, filename + ".yml");
if (confFile.exists()) { if (confFile.exists()) {
throw new Exception(tl("similarWarpExist")); throw new Exception(user.tl("similarWarpExist"));
} }
conf = new EssentialsConf(confFile); conf = new EssentialsConf(confFile);
warpPoints.put(new StringIgnoreCase(name), conf); warpPoints.put(new StringIgnoreCase(name), conf);
@ -76,7 +77,7 @@ public class Warps implements IConf, net.ess3.api.IWarps {
try { try {
conf.saveWithError(); conf.saveWithError();
} catch (IOException ex) { } catch (IOException ex) {
throw new IOException(tl("invalidWarpName")); throw new IOException(user.tl("invalidWarpName"));
} }
} }
@ -96,12 +97,17 @@ public class Warps implements IConf, net.ess3.api.IWarps {
@Override @Override
public void removeWarp(String name) throws Exception { public void removeWarp(String name) throws Exception {
removeWarp(new CommandSource(Bukkit.getConsoleSender()), name);
}
@Override
public void removeWarp(CommandSource sender, String name) throws Exception {
EssentialsConf conf = warpPoints.get(new StringIgnoreCase(name)); EssentialsConf conf = warpPoints.get(new StringIgnoreCase(name));
if (conf == null) { if (conf == null) {
throw new Exception(tl("warpNotExist")); throw new Exception(sender.tl("warpNotExist"));
} }
if (!conf.getFile().delete()) { if (!conf.getFile().delete()) {
throw new Exception(tl("warpDeleteError")); throw new Exception(sender.tl("warpDeleteError"));
} }
warpPoints.remove(new StringIgnoreCase(name)); warpPoints.remove(new StringIgnoreCase(name));
} }

View File

@ -75,7 +75,7 @@ public class Worth implements IConf {
*/ */
public int getAmount(IEssentials ess, User user, ItemStack is, String[] args, boolean isBulkSell) throws Exception { public int getAmount(IEssentials ess, User user, ItemStack is, String[] args, boolean isBulkSell) throws Exception {
if (is == null || is.getType() == Material.AIR) { if (is == null || is.getType() == Material.AIR) {
throw new Exception(tl("itemSellAir")); throw new Exception(user.tl("itemSellAir"));
} }
int amount = 0; int amount = 0;
@ -95,7 +95,7 @@ public class Worth implements IConf {
boolean requireStack = ess.getSettings().isTradeInStacks(is.getType()); boolean requireStack = ess.getSettings().isTradeInStacks(is.getType());
if (requireStack && !stack) { if (requireStack && !stack) {
throw new Exception(tl("itemMustBeStacked")); throw new Exception(user.tl("itemMustBeStacked"));
} }
int max = 0; int max = 0;
@ -118,9 +118,9 @@ public class Worth implements IConf {
} }
if (amount > max || amount < 1) { if (amount > max || amount < 1) {
if (!isBulkSell) { if (!isBulkSell) {
user.sendMessage(tl("itemNotEnough2")); user.sendTl("itemNotEnough2");
user.sendMessage(tl("itemNotEnough3")); user.sendTl("itemNotEnough3");
throw new Exception(tl("itemNotEnough1")); throw new Exception(user.tl("itemNotEnough1"));
} else { } else {
return amount; return amount;
} }

View File

@ -5,7 +5,7 @@ import java.util.Locale;
public interface II18n { public interface II18n {
/** /**
* Gets the current locale setting * Gets the current default locale setting
* *
* @return the current locale, if not set it will return the default locale * @return the current locale, if not set it will return the default locale
*/ */

View File

@ -1,5 +1,6 @@
package com.earth2me.essentials.api; package com.earth2me.essentials.api;
import com.earth2me.essentials.CommandSource;
import com.earth2me.essentials.IConf; import com.earth2me.essentials.IConf;
import com.earth2me.essentials.IUser; import com.earth2me.essentials.IUser;
import com.earth2me.essentials.commands.WarpNotFoundException; import com.earth2me.essentials.commands.WarpNotFoundException;
@ -43,9 +44,21 @@ public interface IWarps extends IConf {
* @param name - Name of warp * @param name - Name of warp
* *
* @throws Exception * @throws Exception
* @deprecated Use {@link #removeWarp(CommandSource, String)}
*/ */
@Deprecated
void removeWarp(String name) throws Exception; void removeWarp(String name) throws Exception;
/**
* Delete a warp from the warp DB
*
* @param sender - The one who wants to remove the warp
* @param name - Name of warp
*
* @throws Exception
*/
void removeWarp(CommandSource sender, String name) throws Exception;
/** /**
* Set a warp * Set a warp
* *

View File

@ -7,8 +7,6 @@ import org.bukkit.Server;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import static com.earth2me.essentials.I18n.tl;
public class Commandafk extends EssentialsCommand { public class Commandafk extends EssentialsCommand {
public Commandafk() { public Commandafk() {
@ -51,10 +49,10 @@ public class Commandafk extends EssentialsCommand {
private void toggleAfk(User sender, User user, String message) throws Exception { private void toggleAfk(User sender, User user, String message) throws Exception {
if (message != null && sender != null) { if (message != null && sender != null) {
if (sender.isMuted()) { if (sender.isMuted()) {
throw new Exception(sender.hasMuteReason() ? tl("voiceSilencedReason", sender.getMuteReason()) : tl("voiceSilenced")); throw new Exception(sender.hasMuteReason() ? sender.tl("voiceSilencedReason", sender.getMuteReason()) : sender.tl("voiceSilenced"));
} }
if (!sender.isAuthorized("essentials.afk.message")) { if (!sender.isAuthorized("essentials.afk.message")) {
throw new Exception(tl("noPermToAFKMessage")); throw new Exception(sender.tl("noPermToAFKMessage"));
} }
} }
user.setDisplayNick(); user.setDisplayNick();
@ -62,22 +60,22 @@ public class Commandafk extends EssentialsCommand {
if (!user.toggleAfk()) { if (!user.toggleAfk()) {
//user.sendMessage(_("markedAsNotAway")); //user.sendMessage(_("markedAsNotAway"));
if (!user.isHidden()) { if (!user.isHidden()) {
msg = tl("userIsNotAway", user.getDisplayName()); msg = "userIsNotAway";
} }
user.updateActivity(false); user.updateActivity(false);
} else { } else {
//user.sendMessage(_("markedAsAway")); //user.sendMessage(_("markedAsAway"));
if (!user.isHidden()) { if (!user.isHidden()) {
if (message != null) { if (message != null) {
msg = tl("userIsAwayWithMessage", user.getDisplayName(), message); msg = "userIsAwayWithMessage";
} else { } else {
msg = tl("userIsAway", user.getDisplayName()); msg = "userIsAway";
} }
} }
user.setAfkMessage(message); user.setAfkMessage(message);
} }
if (!msg.isEmpty()) { if (!msg.isEmpty()) {
ess.broadcastMessage(user, msg); ess.broadcastTl(user, msg, user.getDisplayName(), message);
} }
user.setDisplayNick(); // Set this again after toggling user.setDisplayNick(); // Set this again after toggling
} }

View File

@ -11,8 +11,6 @@ import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import static com.earth2me.essentials.I18n.tl;
public class Commandback extends EssentialsCommand { public class Commandback extends EssentialsCommand {
public Commandback() { public Commandback() {
@ -51,14 +49,14 @@ public class Commandback extends EssentialsCommand {
} }
for (Player player : players) { for (Player player : players) {
sender.sendMessage(tl("backOther", player.getName())); sender.sendTl("backOther", player.getName());
teleportBack(sender, ess.getUser(player)); teleportBack(sender, ess.getUser(player));
} }
} }
private void teleportBack(CommandSource sender, User user) throws Exception { private void teleportBack(CommandSource sender, User user) throws Exception {
if (user.getLastLocation() == null) { if (user.getLastLocation() == null) {
throw new Exception(tl("noLocationFound")); throw new Exception(sender.tl("noLocationFound"));
} }
String lastWorldName = user.getLastLocation().getWorld().getName(); String lastWorldName = user.getLastLocation().getWorld().getName();
@ -68,11 +66,11 @@ public class Commandback extends EssentialsCommand {
requester = ess.getUser(sender.getPlayer()); requester = ess.getUser(sender.getPlayer());
if (user.getWorld() != user.getLastLocation().getWorld() && this.ess.getSettings().isWorldTeleportPermissions() && !user.isAuthorized("essentials.worlds." + lastWorldName)) { if (user.getWorld() != user.getLastLocation().getWorld() && this.ess.getSettings().isWorldTeleportPermissions() && !user.isAuthorized("essentials.worlds." + lastWorldName)) {
throw new Exception(tl("noPerm", "essentials.worlds." + lastWorldName)); throw new Exception(sender.tl("noPerm", "essentials.worlds." + lastWorldName));
} }
if (!requester.isAuthorized("essentials.back.into." + lastWorldName)) { if (!requester.isAuthorized("essentials.back.into." + lastWorldName)) {
throw new Exception(tl("noPerm", "essentials.back.into." + lastWorldName)); throw new Exception(sender.tl("noPerm", "essentials.back.into." + lastWorldName));
} }
} }

View File

@ -4,8 +4,6 @@ import com.earth2me.essentials.Backup;
import com.earth2me.essentials.CommandSource; import com.earth2me.essentials.CommandSource;
import org.bukkit.Server; import org.bukkit.Server;
import static com.earth2me.essentials.I18n.tl;
public class Commandbackup extends EssentialsCommand { public class Commandbackup extends EssentialsCommand {
public Commandbackup() { public Commandbackup() {
@ -16,13 +14,13 @@ public class Commandbackup extends EssentialsCommand {
protected void run(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception { protected void run(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception {
final Backup backup = ess.getBackup(); final Backup backup = ess.getBackup();
if (backup == null) { if (backup == null) {
throw new Exception(tl("backupDisabled")); throw new Exception(sender.tl("backupDisabled"));
} }
final String command = ess.getSettings().getBackupCommand(); final String command = ess.getSettings().getBackupCommand();
if (command == null || "".equals(command) || "save-all".equalsIgnoreCase(command)) { if (command == null || "".equals(command) || "save-all".equalsIgnoreCase(command)) {
throw new Exception(tl("backupDisabled")); throw new Exception(sender.tl("backupDisabled"));
} }
backup.run(); backup.run();
sender.sendMessage(tl("backupStarted")); sender.sendTl("backupStarted");
} }
} }

View File

@ -9,8 +9,6 @@ import java.math.BigDecimal;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import static com.earth2me.essentials.I18n.tl;
public class Commandbalance extends EssentialsCommand { public class Commandbalance extends EssentialsCommand {
public Commandbalance() { public Commandbalance() {
@ -24,7 +22,7 @@ public class Commandbalance extends EssentialsCommand {
} }
User target = getPlayer(server, args, 0, true, true); User target = getPlayer(server, args, 0, true, true);
sender.sendMessage(tl("balanceOther", target.isHidden() ? target.getName() : target.getDisplayName(), NumberUtil.displayCurrency(target.getMoney(), ess))); sender.sendTl("balanceOther", target.isHidden() ? target.getName() : target.getDisplayName(), NumberUtil.displayCurrency(target.getMoney(), ess));
} }
@Override @Override
@ -32,10 +30,10 @@ public class Commandbalance extends EssentialsCommand {
if (args.length == 1 && user.isAuthorized("essentials.balance.others")) { if (args.length == 1 && user.isAuthorized("essentials.balance.others")) {
final User target = getPlayer(server, args, 0, true, true); final User target = getPlayer(server, args, 0, true, true);
final BigDecimal bal = target.getMoney(); final BigDecimal bal = target.getMoney();
user.sendMessage(tl("balanceOther", target.isHidden() ? target.getName() : target.getDisplayName(), NumberUtil.displayCurrency(bal, ess))); user.sendTl("balanceOther", target.isHidden() ? target.getName() : target.getDisplayName(), NumberUtil.displayCurrency(bal, ess));
} else if (args.length < 2) { } else if (args.length < 2) {
final BigDecimal bal = user.getMoney(); final BigDecimal bal = user.getMoney();
user.sendMessage(tl("balance", NumberUtil.displayCurrency(bal, ess))); user.sendTl("balance", NumberUtil.displayCurrency(bal, ess));
} else { } else {
throw new NotEnoughArgumentsException(); throw new NotEnoughArgumentsException();
} }

View File

@ -49,7 +49,7 @@ public class Commandbalancetop extends EssentialsCommand {
return; return;
} }
if (ess.getUserMap().getUniqueUsers() > MINUSERS) { if (ess.getUserMap().getUniqueUsers() > MINUSERS) {
sender.sendMessage(tl("orderBalances", ess.getUserMap().getUniqueUsers())); sender.sendTl("orderBalances", ess.getUserMap().getUniqueUsers());
} }
} finally { } finally {
lock.readLock().unlock(); lock.readLock().unlock();
@ -57,7 +57,7 @@ public class Commandbalancetop extends EssentialsCommand {
ess.runTaskAsynchronously(new Viewer(sender, commandLabel, page, force)); ess.runTaskAsynchronously(new Viewer(sender, commandLabel, page, force));
} else { } else {
if (ess.getUserMap().getUniqueUsers() > MINUSERS) { if (ess.getUserMap().getUniqueUsers() > MINUSERS) {
sender.sendMessage(tl("orderBalances", ess.getUserMap().getUniqueUsers())); sender.sendTl("orderBalances", ess.getUserMap().getUniqueUsers());
} }
ess.runTaskAsynchronously(new Viewer(sender, commandLabel, page, force)); ess.runTaskAsynchronously(new Viewer(sender, commandLabel, page, force));
} }
@ -68,7 +68,7 @@ public class Commandbalancetop extends EssentialsCommand {
final Calendar cal = Calendar.getInstance(); final Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(cacheage); cal.setTimeInMillis(cacheage);
final DateFormat format = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT); final DateFormat format = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
sender.sendMessage(tl("balanceTop", format.format(cal.getTime()))); sender.sendTl("balanceTop", format.format(cal.getTime()));
new TextPager(cache).showPage(Integer.toString(page), null, "balancetop", sender); new TextPager(cache).showPage(Integer.toString(page), null, "balancetop", sender);
} }

View File

@ -35,11 +35,11 @@ public class Commandban extends EssentialsCommand {
} }
if (!user.getBase().isOnline()) { if (!user.getBase().isOnline()) {
if (sender.isPlayer() && !ess.getUser(sender.getPlayer()).isAuthorized("essentials.ban.offline")) { if (sender.isPlayer() && !ess.getUser(sender.getPlayer()).isAuthorized("essentials.ban.offline")) {
throw new Exception(tl("banExemptOffline")); throw new Exception(user.tl("banExemptOffline"));
} }
} else { } else {
if (user.isAuthorized("essentials.ban.exempt") && sender.isPlayer()) { if (user.isAuthorized("essentials.ban.exempt") && sender.isPlayer()) {
throw new Exception(tl("banExempt")); throw new Exception(user.tl("banExempt"));
} }
} }
@ -48,21 +48,21 @@ public class Commandban extends EssentialsCommand {
if (args.length > 1) { if (args.length > 1) {
banReason = FormatUtil.replaceFormat(getFinalArg(args, 1).replace("\\n", "\n").replace("|", "\n")); banReason = FormatUtil.replaceFormat(getFinalArg(args, 1).replace("\\n", "\n").replace("|", "\n"));
} else { } else {
banReason = tl("defaultBanReason"); banReason = user.tl("defaultBanReason");
} }
ess.getServer().getBanList(BanList.Type.NAME).addBan(user.getName(), banReason, null, senderName); ess.getServer().getBanList(BanList.Type.NAME).addBan(user.getName(), banReason, null, senderName);
String banDisplay = tl("banFormat", banReason, senderName); String banDisplay = user.tl("banFormat", banReason, senderName);
user.getBase().kickPlayer(banDisplay); user.getBase().kickPlayer(banDisplay);
server.getLogger().log(Level.INFO, tl("playerBanned", senderName, user.getName(), banDisplay)); server.getLogger().log(Level.INFO, tl("playerBanned", senderName, user.getName(), banDisplay));
if (nomatch) { if (nomatch) {
sender.sendMessage(tl("userUnknown", user.getName())); sender.sendTl("userUnknown", user.getName());
} }
ess.broadcastMessage("essentials.ban.notify", tl("playerBanned", senderName, user.getName(), banReason)); ess.broadcastTl("essentials.ban.notify", "playerBanned", senderName, user.getName(), banReason);
} }
@Override @Override

View File

@ -48,21 +48,20 @@ public class Commandbanip extends EssentialsCommand {
if (args.length > 1) { if (args.length > 1) {
banReason = FormatUtil.replaceFormat(getFinalArg(args, 1).replace("\\n", "\n").replace("|", "\n")); banReason = FormatUtil.replaceFormat(getFinalArg(args, 1).replace("\\n", "\n").replace("|", "\n"));
} else { } else {
banReason = tl("defaultBanReason"); banReason = sender.tl("defaultBanReason");
} }
String banDisplay = tl("banFormat", banReason, senderName);
ess.getServer().getBanList(BanList.Type.IP).addBan(ipAddress, banReason, null, senderName); ess.getServer().getBanList(BanList.Type.IP).addBan(ipAddress, banReason, null, senderName);
server.getLogger().log(Level.INFO, tl("playerBanIpAddress", senderName, ipAddress, banReason)); server.getLogger().log(Level.INFO, tl("playerBanIpAddress", senderName, ipAddress, banReason));
for (Player player : ess.getServer().getOnlinePlayers()) { for (Player player : ess.getServer().getOnlinePlayers()) {
if (player.getAddress().getAddress().getHostAddress().equalsIgnoreCase(ipAddress)) { if (player.getAddress().getAddress().getHostAddress().equalsIgnoreCase(ipAddress)) {
player.kickPlayer(banDisplay); final User buser = ess.getUser(player);
player.kickPlayer(buser.tl("banFormat", banReason, senderName));
} }
} }
ess.broadcastMessage("essentials.banip.notify", tl("playerBanIpAddress", senderName, ipAddress, banReason)); ess.broadcastTl("essentials.banip.notify", "playerBanIpAddress", senderName, ipAddress, banReason);
} }
@Override @Override

View File

@ -10,8 +10,6 @@ import org.bukkit.TreeType;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import static com.earth2me.essentials.I18n.tl;
public class Commandbigtree extends EssentialsCommand { public class Commandbigtree extends EssentialsCommand {
public Commandbigtree() { public Commandbigtree() {
@ -37,9 +35,9 @@ public class Commandbigtree extends EssentialsCommand {
final Location safeLocation = LocationUtil.getSafeDestination(loc); final Location safeLocation = LocationUtil.getSafeDestination(loc);
final boolean success = user.getWorld().generateTree(safeLocation, tree); final boolean success = user.getWorld().generateTree(safeLocation, tree);
if (success) { if (success) {
user.sendMessage(tl("bigTreeSuccess")); user.sendTl("bigTreeSuccess");
} else { } else {
throw new Exception(tl("bigTreeFailure")); throw new Exception(user.tl("bigTreeFailure"));
} }
} }

View File

@ -12,8 +12,6 @@ import org.bukkit.inventory.meta.BookMeta;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import static com.earth2me.essentials.I18n.tl;
public class Commandbook extends EssentialsCommand { public class Commandbook extends EssentialsCommand {
@ -34,26 +32,26 @@ public class Commandbook extends EssentialsCommand {
if (user.isAuthorized("essentials.book.author") && (isAuthor(bmeta, player) || user.isAuthorized("essentials.book.others"))) { if (user.isAuthorized("essentials.book.author") && (isAuthor(bmeta, player) || user.isAuthorized("essentials.book.others"))) {
bmeta.setAuthor(args[1]); bmeta.setAuthor(args[1]);
item.setItemMeta(bmeta); item.setItemMeta(bmeta);
user.sendMessage(tl("bookAuthorSet", getFinalArg(args, 1))); user.sendTl("bookAuthorSet", getFinalArg(args, 1));
} else { } else {
throw new Exception(tl("denyChangeAuthor")); throw new Exception(user.tl("denyChangeAuthor"));
} }
} else if (args.length > 1 && args[0].equalsIgnoreCase("title")) { } else if (args.length > 1 && args[0].equalsIgnoreCase("title")) {
if (user.isAuthorized("essentials.book.title") && (isAuthor(bmeta, player) || user.isAuthorized("essentials.book.others"))) { if (user.isAuthorized("essentials.book.title") && (isAuthor(bmeta, player) || user.isAuthorized("essentials.book.others"))) {
bmeta.setTitle(args[1]); bmeta.setTitle(args[1]);
item.setItemMeta(bmeta); item.setItemMeta(bmeta);
user.sendMessage(tl("bookTitleSet", getFinalArg(args, 1))); user.sendTl("bookTitleSet", getFinalArg(args, 1));
} else { } else {
throw new Exception(tl("denyChangeTitle")); throw new Exception(user.tl("denyChangeTitle"));
} }
} else { } else {
if (isAuthor(bmeta, player) || user.isAuthorized("essentials.book.others")) { if (isAuthor(bmeta, player) || user.isAuthorized("essentials.book.others")) {
ItemStack newItem = new ItemStack(WRITABLE_BOOK, item.getAmount()); ItemStack newItem = new ItemStack(WRITABLE_BOOK, item.getAmount());
newItem.setItemMeta(bmeta); newItem.setItemMeta(bmeta);
InventoryWorkaround.setItemInMainHand(user.getBase(), newItem); InventoryWorkaround.setItemInMainHand(user.getBase(), newItem);
user.sendMessage(tl("editBookContents")); user.sendTl("editBookContents");
} else { } else {
throw new Exception(tl("denyBookEdit")); throw new Exception(user.tl("denyBookEdit"));
} }
} }
} else if (item.getType() == WRITABLE_BOOK) { } else if (item.getType() == WRITABLE_BOOK) {
@ -64,9 +62,9 @@ public class Commandbook extends EssentialsCommand {
ItemStack newItem = new ItemStack(Material.WRITTEN_BOOK, item.getAmount()); ItemStack newItem = new ItemStack(Material.WRITTEN_BOOK, item.getAmount());
newItem.setItemMeta(bmeta); newItem.setItemMeta(bmeta);
InventoryWorkaround.setItemInMainHand(user.getBase(), newItem); InventoryWorkaround.setItemInMainHand(user.getBase(), newItem);
user.sendMessage(tl("bookLocked")); user.sendTl("bookLocked");
} else { } else {
throw new Exception(tl("holdBook")); throw new Exception(user.tl("holdBook"));
} }
} }

View File

@ -8,8 +8,6 @@ import org.bukkit.event.block.BlockBreakEvent;
import java.util.Set; import java.util.Set;
import static com.earth2me.essentials.I18n.tl;
public class Commandbreak extends EssentialsCommand { public class Commandbreak extends EssentialsCommand {
public Commandbreak() { public Commandbreak() {
@ -27,7 +25,7 @@ public class Commandbreak extends EssentialsCommand {
throw new NoChargeException(); throw new NoChargeException();
} }
if (block.getType() == Material.BEDROCK && !user.isAuthorized("essentials.break.bedrock")) { if (block.getType() == Material.BEDROCK && !user.isAuthorized("essentials.break.bedrock")) {
throw new Exception(tl("noBreakBedrock")); throw new Exception(user.tl("noBreakBedrock"));
} }
//final List<ItemStack> list = (List<ItemStack>)block.getDrops(); //final List<ItemStack> list = (List<ItemStack>)block.getDrops();
//final BlockBreakEvent event = new BlockBreakEvent(block, user.getBase(), list); //final BlockBreakEvent event = new BlockBreakEvent(block, user.getBase(), list);

View File

@ -15,19 +15,19 @@ public class Commandbroadcast extends EssentialsCommand {
@Override @Override
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception { public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception {
sendBroadcast(user.getDisplayName(), args); sendBroadcast(user.getSource(), user.getDisplayName(), args);
} }
@Override @Override
public void run(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception { public void run(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception {
sendBroadcast(sender.getSender().getName(), args); sendBroadcast(sender, sender.getSender().getName(), args);
} }
private void sendBroadcast(final String name, final String[] args) throws NotEnoughArgumentsException { private void sendBroadcast(final CommandSource sender, final String name, final String[] args) throws NotEnoughArgumentsException {
if (args.length < 1) { if (args.length < 1) {
throw new NotEnoughArgumentsException(); throw new NotEnoughArgumentsException();
} }
ess.broadcastMessage(tl("broadcast", FormatUtil.replaceFormat(getFinalArg(args, 0)).replace("\\n", "\n"), name)); ess.broadcastTl(sender, "broadcast", FormatUtil.replaceFormat(getFinalArg(args, 0)).replace("\\n", "\n"), name);
} }
} }

View File

@ -45,7 +45,7 @@ public class Commandbroadcastworld extends EssentialsCommand {
message = getFinalArg(args, 0); message = getFinalArg(args, 0);
} }
sendBroadcast(world.getName(), user.getDisplayName(), message); sendBroadcast(user.getSource(), world.getName(), user.getDisplayName(), message);
} }
@Override @Override
@ -53,27 +53,27 @@ public class Commandbroadcastworld extends EssentialsCommand {
if (args.length < 2) { if (args.length < 2) {
throw new NotEnoughArgumentsException("world"); throw new NotEnoughArgumentsException("world");
} }
sendBroadcast(args[0], sender.getSender().getName(), getFinalArg(args, 1)); sendBroadcast(sender, args[0], sender.getSender().getName(), getFinalArg(args, 1));
} }
private void sendBroadcast(final String worldName, final String name, final String message) throws Exception { private void sendBroadcast(final CommandSource sender, final String worldName, final String name, final String message) throws Exception {
World world = ess.getWorld(worldName); World world = ess.getWorld(worldName);
if (world == null) { if (world == null) {
throw new Exception(tl("invalidWorld")); throw new Exception(sender.tl("invalidWorld"));
} }
if (message.isEmpty()) { if (message.isEmpty()) {
throw new NotEnoughArgumentsException(); throw new NotEnoughArgumentsException();
} }
sendToWorld(world, tl("broadcast", FormatUtil.replaceFormat(message).replace("\\n", "\n"), name)); sendToWorld(world, "broadcast", FormatUtil.replaceFormat(message).replace("\\n", "\n"), name);
} }
private void sendToWorld(World world, String message) { private void sendToWorld(World world, String string, Object... objects) {
IText broadcast = new SimpleTextInput(message);
final Collection<Player> players = ess.getOnlinePlayers(); final Collection<Player> players = ess.getOnlinePlayers();
for (Player player : players) { for (Player player : players) {
if (player.getWorld().equals(world)) { if (player.getWorld().equals(world)) {
final User user = ess.getUser(player); final User user = ess.getUser(player);
IText broadcast = new SimpleTextInput(user.tl(string, objects));
broadcast = new KeywordReplacer(broadcast, new CommandSource(player), ess, false); broadcast = new KeywordReplacer(broadcast, new CommandSource(player), ess, false);
for (String messageText : broadcast.getLines()) { for (String messageText : broadcast.getLines()) {
user.sendMessage(messageText); user.sendMessage(messageText);

View File

@ -7,8 +7,6 @@ import org.bukkit.Server;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import static com.earth2me.essentials.I18n.tl;
public class Commandburn extends EssentialsCommand { public class Commandburn extends EssentialsCommand {
public Commandburn() { public Commandburn() {
@ -27,7 +25,7 @@ public class Commandburn extends EssentialsCommand {
User user = getPlayer(server, sender, args, 0); User user = getPlayer(server, sender, args, 0);
user.getBase().setFireTicks(Integer.parseInt(args[1]) * 20); user.getBase().setFireTicks(Integer.parseInt(args[1]) * 20);
sender.sendMessage(tl("burnMsg", user.getDisplayName(), Integer.parseInt(args[1]))); sender.sendTl("burnMsg", user.getDisplayName(), Integer.parseInt(args[1]));
} }
@Override @Override

View File

@ -1,7 +1,5 @@
package com.earth2me.essentials.commands; package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n.tl;
import com.earth2me.essentials.CommandSource; import com.earth2me.essentials.CommandSource;
import com.earth2me.essentials.User; import com.earth2me.essentials.User;
import com.earth2me.essentials.craftbukkit.InventoryWorkaround; import com.earth2me.essentials.craftbukkit.InventoryWorkaround;
@ -52,7 +50,7 @@ public class Commandclearinventory extends EssentialsCommand {
} }
if (allowAll && args.length > 0 && args[0].contentEquals("*")) { if (allowAll && args.length > 0 && args[0].contentEquals("*")) {
sender.sendMessage(tl("inventoryClearingFromAll")); sender.sendTl("inventoryClearingFromAll");
offset = 1; offset = 1;
players = ess.getOnlinePlayers(); players = ess.getOnlinePlayers();
} else if (allowOthers && args.length > 0 && args[0].trim().length() > 2) { } else if (allowOthers && args.length > 0 && args[0].trim().length() > 2) {
@ -70,7 +68,7 @@ public class Commandclearinventory extends EssentialsCommand {
if (senderUser != null && senderUser.isPromptingClearConfirm()) { if (senderUser != null && senderUser.isPromptingClearConfirm()) {
if (!formattedCommand.equals(previousClearCommand)) { if (!formattedCommand.equals(previousClearCommand)) {
senderUser.setConfirmingClearCommand(formattedCommand); senderUser.setConfirmingClearCommand(formattedCommand);
senderUser.sendMessage(tl("confirmClear", formattedCommand)); senderUser.sendTl("confirmClear", formattedCommand);
return; return;
} }
} }
@ -108,14 +106,14 @@ public class Commandclearinventory extends EssentialsCommand {
if (type == -1) // type -1 represents wildcard or all items if (type == -1) // type -1 represents wildcard or all items
{ {
if (showExtended) { if (showExtended) {
sender.sendMessage(tl("inventoryClearingAllItems", player.getDisplayName())); sender.sendTl("inventoryClearingAllItems", player.getDisplayName());
} }
InventoryWorkaround.clearInventoryNoArmor(player.getInventory()); InventoryWorkaround.clearInventoryNoArmor(player.getInventory());
InventoryWorkaround.setItemInOffHand(player, null); InventoryWorkaround.setItemInOffHand(player, null);
} else if (type == -2) // type -2 represents double wildcard or all items and armor } else if (type == -2) // type -2 represents double wildcard or all items and armor
{ {
if (showExtended) { if (showExtended) {
sender.sendMessage(tl("inventoryClearingAllArmor", player.getDisplayName())); sender.sendTl("inventoryClearingAllArmor", player.getDisplayName());
} }
InventoryWorkaround.clearInventoryNoArmor(player.getInventory()); InventoryWorkaround.clearInventoryNoArmor(player.getInventory());
InventoryWorkaround.setItemInOffHand(player, null); InventoryWorkaround.setItemInOffHand(player, null);
@ -128,7 +126,7 @@ public class Commandclearinventory extends EssentialsCommand {
ItemStack removedStack = player.getInventory().removeItem(stack).get(0); ItemStack removedStack = player.getInventory().removeItem(stack).get(0);
final int removedAmount = (BASE_AMOUNT - removedStack.getAmount()); final int removedAmount = (BASE_AMOUNT - removedStack.getAmount());
if (removedAmount > 0 || showExtended) { if (removedAmount > 0 || showExtended) {
sender.sendMessage(tl("inventoryClearingStack", removedAmount, stack.getType().toString().toLowerCase(Locale.ENGLISH), player.getDisplayName())); sender.sendTl("inventoryClearingStack", removedAmount, stack.getType().toString().toLowerCase(Locale.ENGLISH), player.getDisplayName());
} }
} else { } else {
if (amount < 0) { if (amount < 0) {
@ -136,11 +134,11 @@ public class Commandclearinventory extends EssentialsCommand {
} }
ItemStack stack = new ItemStack(mat, amount); ItemStack stack = new ItemStack(mat, amount);
if (player.getInventory().containsAtLeast(stack, amount)) { if (player.getInventory().containsAtLeast(stack, amount)) {
sender.sendMessage(tl("inventoryClearingStack", amount, stack.getType().toString().toLowerCase(Locale.ENGLISH), player.getDisplayName())); sender.sendTl("inventoryClearingStack", amount, stack.getType().toString().toLowerCase(Locale.ENGLISH), player.getDisplayName());
player.getInventory().removeItem(stack); player.getInventory().removeItem(stack);
} else { } else {
if (showExtended) { if (showExtended) {
sender.sendMessage(tl("inventoryClearFail", player.getDisplayName(), amount, stack.getType().toString().toLowerCase(Locale.ENGLISH))); sender.sendTl("inventoryClearFail", player.getDisplayName(), amount, stack.getType().toString().toLowerCase(Locale.ENGLISH));
} }
} }
} }

View File

@ -1,7 +1,5 @@
package com.earth2me.essentials.commands; package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n.tl;
import com.earth2me.essentials.User; import com.earth2me.essentials.User;
import org.bukkit.Server; import org.bukkit.Server;
@ -22,9 +20,9 @@ public class Commandclearinventoryconfirmtoggle extends EssentialsCommand {
} }
user.setPromptingClearConfirm(confirmingClear); user.setPromptingClearConfirm(confirmingClear);
if (confirmingClear) { if (confirmingClear) {
user.sendMessage(tl("clearInventoryConfirmToggleOn")); user.sendTl("clearInventoryConfirmToggleOn");
} else { } else {
user.sendMessage(tl("clearInventoryConfirmToggleOff")); user.sendTl("clearInventoryConfirmToggleOff");
} }
user.setConfirmingClearCommand(null); user.setConfirmingClearCommand(null);
} }

View File

@ -3,8 +3,6 @@ package com.earth2me.essentials.commands;
import com.earth2me.essentials.User; import com.earth2me.essentials.User;
import org.bukkit.Server; import org.bukkit.Server;
import static com.earth2me.essentials.I18n.tl;
public class Commandcompass extends EssentialsCommand { public class Commandcompass extends EssentialsCommand {
public Commandcompass() { public Commandcompass() {
@ -16,24 +14,24 @@ public class Commandcompass extends EssentialsCommand {
final int bearing = (int) (user.getLocation().getYaw() + 180 + 360) % 360; final int bearing = (int) (user.getLocation().getYaw() + 180 + 360) % 360;
String dir; String dir;
if (bearing < 23) { if (bearing < 23) {
dir = tl("north"); dir = user.tl("north");
} else if (bearing < 68) { } else if (bearing < 68) {
dir = tl("northEast"); dir = user.tl("northEast");
} else if (bearing < 113) { } else if (bearing < 113) {
dir = tl("east"); dir = user.tl("east");
} else if (bearing < 158) { } else if (bearing < 158) {
dir = tl("southEast"); dir = user.tl("southEast");
} else if (bearing < 203) { } else if (bearing < 203) {
dir = tl("south"); dir = user.tl("south");
} else if (bearing < 248) { } else if (bearing < 248) {
dir = tl("southWest"); dir = user.tl("southWest");
} else if (bearing < 293) { } else if (bearing < 293) {
dir = tl("west"); dir = user.tl("west");
} else if (bearing < 338) { } else if (bearing < 338) {
dir = tl("northWest"); dir = user.tl("northWest");
} else { } else {
dir = tl("north"); dir = user.tl("north");
} }
user.sendMessage(tl("compassBearing", dir, bearing)); user.sendTl("compassBearing", dir, bearing);
} }
} }

View File

@ -14,8 +14,6 @@ import org.bukkit.inventory.ShapelessRecipe;
import java.util.*; import java.util.*;
import static com.earth2me.essentials.I18n.tl;
public class Commandcondense extends EssentialsCommand { public class Commandcondense extends EssentialsCommand {
public Commandcondense() { public Commandcondense() {
@ -50,9 +48,9 @@ public class Commandcondense extends EssentialsCommand {
user.getBase().updateInventory(); user.getBase().updateInventory();
if (didConvert) { if (didConvert) {
user.sendMessage(tl("itemsConverted")); user.sendTl("itemsConverted");
} else { } else {
user.sendMessage(tl("itemsNotConverted")); user.sendTl("itemsNotConverted");
throw new NoChargeException(); throw new NoChargeException();
} }
} }

View File

@ -30,8 +30,6 @@ import java.util.List;
import java.util.concurrent.ExecutorService; import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
import static com.earth2me.essentials.I18n.tl;
public class Commandcreatekit extends EssentialsCommand { public class Commandcreatekit extends EssentialsCommand {
private static final String PASTE_URL = "https://hastebin.com/"; private static final String PASTE_URL = "https://hastebin.com/";
@ -70,7 +68,7 @@ public class Commandcreatekit extends EssentialsCommand {
// Some users might want to directly write to config knowing the consequences. *shrug* // Some users might want to directly write to config knowing the consequences. *shrug*
if (!ess.getSettings().isPastebinCreateKit()) { if (!ess.getSettings().isPastebinCreateKit()) {
ess.getKits().addKit(kitname, list, delay); ess.getKits().addKit(kitname, list, delay);
user.sendMessage(tl("createdKit", kitname, list.size(), delay)); user.sendTl("createdKit", kitname, list.size(), delay);
} else { } else {
ConfigurationSection config = new MemoryConfiguration(); ConfigurationSection config = new MemoryConfiguration();
config.set("kits." + kitname + ".delay", delay); config.set("kits." + kitname + ".delay", delay);
@ -99,7 +97,7 @@ public class Commandcreatekit extends EssentialsCommand {
} }
// Error // Error
if (connection.getResponseCode() >= 400) { if (connection.getResponseCode() >= 400) {
sender.sendMessage(tl("createKitFailed", kitName)); sender.sendTl("createKitFailed", kitName);
String message = CharStreams.toString(new InputStreamReader(connection.getErrorStream(), Charsets.UTF_8)); String message = CharStreams.toString(new InputStreamReader(connection.getErrorStream(), Charsets.UTF_8));
ess.getLogger().severe("Error creating kit: " + message); ess.getLogger().severe("Error creating kit: " + message);
return; return;
@ -110,19 +108,19 @@ public class Commandcreatekit extends EssentialsCommand {
String pasteUrl = PASTE_URL + object.get("key").getAsString(); String pasteUrl = PASTE_URL + object.get("key").getAsString();
connection.disconnect(); connection.disconnect();
String separator = tl("createKitSeparator"); String separator = sender.tl("createKitSeparator");
String delayFormat = "0"; String delayFormat = "0";
if (delay > 0) { if (delay > 0) {
delayFormat = DateUtil.formatDateDiff(System.currentTimeMillis() + (delay * 1000)); delayFormat = DateUtil.formatDateDiff(sender, System.currentTimeMillis() + (delay * 1000));
} }
sender.sendMessage(separator); sender.sendMessage(separator);
sender.sendMessage(tl("createKitSuccess", kitName, delayFormat, pasteUrl)); sender.sendTl("createKitSuccess", kitName, delayFormat, pasteUrl);
sender.sendMessage(separator); sender.sendMessage(separator);
if (ess.getSettings().isDebug()) { if (ess.getSettings().isDebug()) {
ess.getLogger().info(sender.getSender().getName() + " created a kit: " + pasteUrl); ess.getLogger().info(sender.getSender().getName() + " created a kit: " + pasteUrl);
} }
} catch (Exception e) { } catch (Exception e) {
sender.sendMessage(tl("createKitFailed", kitName)); sender.sendTl("createKitFailed", kitName);
e.printStackTrace(); e.printStackTrace();
} }
} }

View File

@ -4,12 +4,10 @@ import com.earth2me.essentials.CommandSource;
import com.earth2me.essentials.User; import com.earth2me.essentials.User;
import org.bukkit.Server; import org.bukkit.Server;
import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import static com.earth2me.essentials.I18n.tl;
public class Commanddelhome extends EssentialsCommand { public class Commanddelhome extends EssentialsCommand {
@ -45,11 +43,11 @@ public class Commanddelhome extends EssentialsCommand {
} }
if (name.equalsIgnoreCase("bed")) { if (name.equalsIgnoreCase("bed")) {
throw new Exception(tl("invalidHomeName")); throw new Exception(user.tl("invalidHomeName"));
} }
user.delHome(name.toLowerCase(Locale.ENGLISH)); user.delHome(name.toLowerCase(Locale.ENGLISH));
sender.sendMessage(tl("deleteHome", name)); sender.sendTl("deleteHome", name);
} }
@Override @Override

View File

@ -5,7 +5,6 @@ import org.bukkit.Server;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import static com.earth2me.essentials.I18n.tl;
public class Commanddeljail extends EssentialsCommand { public class Commanddeljail extends EssentialsCommand {
@ -20,11 +19,11 @@ public class Commanddeljail extends EssentialsCommand {
} }
if (ess.getJails().getJail(args[0]) == null) { if (ess.getJails().getJail(args[0]) == null) {
throw new Exception(tl("jailNotExist")); throw new Exception(sender.tl("jailNotExist"));
} }
ess.getJails().removeJail(args[0]); ess.getJails().removeJail(args[0]);
sender.sendMessage(tl("deleteJail", args[0])); sender.sendTl("deleteJail", args[0]);
} }
@Override @Override

View File

@ -24,7 +24,11 @@ public class Commanddelkit extends EssentialsCommand {
public void run(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception { public void run(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception {
if (args.length < 1) { if (args.length < 1) {
final String kitList = ess.getKits().listKits(ess, null); final String kitList = ess.getKits().listKits(ess, null);
sender.sendMessage(kitList.length() > 0 ? tl("kits", kitList) : tl("noKits")); if (kitList.length() > 0) {
sender.sendTl("kits", kitList);
} else {
sender.sendTl("noKits");
}
throw new NoChargeException(); throw new NoChargeException();
} else { } else {
final String kitName = args[0]; final String kitName = args[0];
@ -35,7 +39,7 @@ public class Commanddelkit extends EssentialsCommand {
} }
ess.getKits().removeKit(kitName); ess.getKits().removeKit(kitName);
sender.sendMessage(tl("deleteKit", kit)); sender.sendTl("deleteKit", kit);
} }
} }
} }

View File

@ -7,8 +7,6 @@ import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import static com.earth2me.essentials.I18n.tl;
public class Commanddelwarp extends EssentialsCommand { public class Commanddelwarp extends EssentialsCommand {
public Commanddelwarp() { public Commanddelwarp() {
@ -21,8 +19,8 @@ public class Commanddelwarp extends EssentialsCommand {
throw new NotEnoughArgumentsException(); throw new NotEnoughArgumentsException();
} }
ess.getWarps().removeWarp(args[0]); ess.getWarps().removeWarp(sender, args[0]);
sender.sendMessage(tl("deleteWarp", args[0])); sender.sendTl("deleteWarp", args[0]);
} }
@Override @Override

View File

@ -3,8 +3,6 @@ package com.earth2me.essentials.commands;
import com.earth2me.essentials.User; import com.earth2me.essentials.User;
import org.bukkit.Server; import org.bukkit.Server;
import static com.earth2me.essentials.I18n.tl;
public class Commanddepth extends EssentialsCommand { public class Commanddepth extends EssentialsCommand {
public Commanddepth() { public Commanddepth() {
@ -15,11 +13,11 @@ public class Commanddepth extends EssentialsCommand {
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception { public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception {
final int depth = user.getLocation().getBlockY() - 63; final int depth = user.getLocation().getBlockY() - 63;
if (depth > 0) { if (depth > 0) {
user.sendMessage(tl("depthAboveSea", depth)); user.sendTl("depthAboveSea", depth);
} else if (depth < 0) { } else if (depth < 0) {
user.sendMessage(tl("depthBelowSea", (-depth))); user.sendTl("depthBelowSea", (-depth));
} else { } else {
user.sendMessage(tl("depth")); user.sendTl("depth");
} }
} }
} }

View File

@ -3,8 +3,6 @@ package com.earth2me.essentials.commands;
import com.earth2me.essentials.User; import com.earth2me.essentials.User;
import org.bukkit.Server; import org.bukkit.Server;
import static com.earth2me.essentials.I18n.tl;
public class Commanddisposal extends EssentialsCommand { public class Commanddisposal extends EssentialsCommand {
public Commanddisposal() { public Commanddisposal() {
@ -13,8 +11,8 @@ public class Commanddisposal extends EssentialsCommand {
@Override @Override
protected void run(Server server, User user, String commandLabel, String[] args) throws Exception { protected void run(Server server, User user, String commandLabel, String[] args) throws Exception {
user.sendMessage(tl("openingDisposal")); user.sendTl("openingDisposal");
user.getBase().openInventory(ess.getServer().createInventory(user.getBase(), 36, tl("disposal"))); user.getBase().openInventory(ess.getServer().createInventory(user.getBase(), 36, user.tl("disposal")));
} }
} }

View File

@ -43,9 +43,9 @@ public class Commandeco extends EssentialsLoopCommand {
if (cmd == Commandeco.EcoCommands.RESET || cmd == Commandeco.EcoCommands.SET) { if (cmd == Commandeco.EcoCommands.RESET || cmd == Commandeco.EcoCommands.SET) {
if (args[1].contentEquals("**")) { if (args[1].contentEquals("**")) {
server.broadcastMessage(tl("resetBalAll", NumberUtil.displayCurrency(amount, ess))); ess.broadcastTl("resetBalAll", NumberUtil.displayCurrency(amount, ess));
} else if (args[1].contentEquals("*")) { } else if (args[1].contentEquals("*")) {
server.broadcastMessage(tl("resetBal", NumberUtil.displayCurrency(amount, ess))); ess.broadcastTl("resetBal", NumberUtil.displayCurrency(amount, ess));
} }
} }
} }
@ -79,9 +79,9 @@ public class Commandeco extends EssentialsLoopCommand {
} catch (MaxMoneyException ex) { } catch (MaxMoneyException ex) {
// Take shouldn't be able to throw a max money exception // Take shouldn't be able to throw a max money exception
} }
player.sendMessage(tl("takenFromAccount", NumberUtil.displayCurrency(player.getMoney(), ess))); player.sendTl("takenFromAccount", NumberUtil.displayCurrency(player.getMoney(), ess));
} else { } else {
throw new ChargeException(tl("insufficientFunds")); throw new ChargeException(player.tl("insufficientFunds"));
} }
} }
@ -91,9 +91,9 @@ public class Commandeco extends EssentialsLoopCommand {
boolean underMinimum = (amount.compareTo(minBalance) < 0); boolean underMinimum = (amount.compareTo(minBalance) < 0);
boolean aboveMax = (amount.compareTo(maxBalance) > 0); boolean aboveMax = (amount.compareTo(maxBalance) > 0);
player.setMoney(underMinimum ? minBalance : aboveMax ? maxBalance : amount); player.setMoney(underMinimum ? minBalance : aboveMax ? maxBalance : amount);
player.sendMessage(tl("setBal", NumberUtil.displayCurrency(player.getMoney(), ess))); player.sendTl("setBal", NumberUtil.displayCurrency(player.getMoney(), ess));
if (sender != null) { if (sender != null) {
sender.sendMessage(tl("setBalOthers", player.getDisplayName(), NumberUtil.displayCurrency(player.getMoney(), ess))); sender.sendTl("setBalOthers", player.getDisplayName(), NumberUtil.displayCurrency(player.getMoney(), ess));
} }
} }

View File

@ -19,8 +19,6 @@ import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.TreeSet; import java.util.TreeSet;
import static com.earth2me.essentials.I18n.tl;
public class Commandenchant extends EssentialsCommand { public class Commandenchant extends EssentialsCommand {
public Commandenchant() { public Commandenchant() {
@ -32,7 +30,7 @@ public class Commandenchant extends EssentialsCommand {
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception { protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception {
final ItemStack stack = user.getItemInHand(); final ItemStack stack = user.getItemInHand();
if (stack == null || stack.getType() == Material.AIR) { if (stack == null || stack.getType() == Material.AIR) {
throw new Exception(tl("nothingInHand")); throw new Exception(user.tl("nothingInHand"));
} }
if (args.length == 0) { if (args.length == 0) {
final Set<String> enchantmentslist = new TreeSet<>(); final Set<String> enchantmentslist = new TreeSet<>();
@ -43,7 +41,7 @@ public class Commandenchant extends EssentialsCommand {
//enchantmentslist.add(enchantmentName); //enchantmentslist.add(enchantmentName);
} }
} }
throw new NotEnoughArgumentsException(tl("enchantments", StringUtil.joinList(enchantmentslist.toArray()))); throw new NotEnoughArgumentsException(user.tl("enchantments", StringUtil.joinList(enchantmentslist.toArray())));
} }
int level = 1; int level = 1;
@ -65,9 +63,9 @@ public class Commandenchant extends EssentialsCommand {
user.getBase().updateInventory(); user.getBase().updateInventory();
final String enchantmentName = enchantment.getName().toLowerCase(Locale.ENGLISH); final String enchantmentName = enchantment.getName().toLowerCase(Locale.ENGLISH);
if (level == 0) { if (level == 0) {
user.sendMessage(tl("enchantmentRemoved", enchantmentName.replace('_', ' '))); user.sendTl("enchantmentRemoved", enchantmentName.replace('_', ' '));
} else { } else {
user.sendMessage(tl("enchantmentApplied", enchantmentName.replace('_', ' '))); user.sendTl("enchantmentApplied", enchantmentName.replace('_', ' '));
} }
} }

View File

@ -19,8 +19,6 @@ import org.bukkit.scheduler.BukkitRunnable;
import java.util.*; import java.util.*;
import java.util.function.Supplier; import java.util.function.Supplier;
import static com.earth2me.essentials.I18n.tl;
// This command has 4 undocumented behaviours #EasterEgg // This command has 4 undocumented behaviours #EasterEgg
public class Commandessentials extends EssentialsCommand { public class Commandessentials extends EssentialsCommand {
@ -135,7 +133,7 @@ public class Commandessentials extends EssentialsCommand {
disabledCommands.append(entry.getKey()).append(" => ").append(entry.getValue()); disabledCommands.append(entry.getKey()).append(" => ").append(entry.getValue());
} }
if (disabledCommands.length() > 0) { if (disabledCommands.length() > 0) {
sender.sendMessage(tl("blockList")); sender.sendTl("blockList");
sender.sendMessage(disabledCommands.toString()); sender.sendMessage(disabledCommands.toString());
} else { } else {
sender.sendMessage(tl("blockListEmpty")); sender.sendMessage(tl("blockListEmpty"));
@ -161,7 +159,7 @@ public class Commandessentials extends EssentialsCommand {
// Reloads all reloadable configs. // Reloads all reloadable configs.
private void runReload(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception { private void runReload(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception {
ess.reload(); ess.reload();
sender.sendMessage(tl("essentialsReload", ess.getDescription().getVersion())); sender.sendTl("essentialsReload", ess.getDescription().getVersion());
} }
// Pop tarts. // Pop tarts.
@ -205,7 +203,7 @@ public class Commandessentials extends EssentialsCommand {
throw new Exception("/<command> cleanup <days> [money] [homes]"); throw new Exception("/<command> cleanup <days> [money] [homes]");
} }
sender.sendMessage(tl("cleaning")); sender.sendTl("cleaning");
final long daysArg = Long.parseLong(args[1]); final long daysArg = Long.parseLong(args[1]);
final double moneyArg = args.length >= 3 ? FloatUtil.parseDouble(args[2].replaceAll("[^0-9\\.]", "")) : 0; final double moneyArg = args.length >= 3 ? FloatUtil.parseDouble(args[2].replaceAll("[^0-9\\.]", "")) : 0;
@ -247,7 +245,7 @@ public class Commandessentials extends EssentialsCommand {
user.reset(); user.reset();
} }
sender.sendMessage(tl("cleaned")); sender.sendTl("cleaned");
}); });
} }
@ -311,8 +309,8 @@ public class Commandessentials extends EssentialsCommand {
final PluginManager pm = server.getPluginManager(); final PluginManager pm = server.getPluginManager();
final String essVer = pm.getPlugin("Essentials").getDescription().getVersion(); final String essVer = pm.getPlugin("Essentials").getDescription().getVersion();
sender.sendMessage(tl(isServerSupported ? "versionOutputFine" : "versionOutputWarn", "Server", server.getBukkitVersion() + " " + server.getVersion())); sender.sendTl(isServerSupported ? "versionOutputFine" : "versionOutputWarn", "Server", server.getBukkitVersion() + " " + server.getVersion());
sender.sendMessage(tl("versionOutputFine", "EssentialsX", essVer)); sender.sendTl("versionOutputFine", "EssentialsX", essVer);
for (Plugin plugin : pm.getPlugins()) { for (Plugin plugin : pm.getPlugins()) {
final PluginDescriptionFile desc = plugin.getDescription(); final PluginDescriptionFile desc = plugin.getDescription();
@ -325,22 +323,22 @@ public class Commandessentials extends EssentialsCommand {
if (!version.equalsIgnoreCase(essVer)) { if (!version.equalsIgnoreCase(essVer)) {
isMismatched = true; isMismatched = true;
sender.sendMessage(tl("versionOutputWarn", name, version)); sender.sendTl("versionOutputWarn", name, version);
} else { } else {
sender.sendMessage(tl("versionOutputFine", name, version)); sender.sendTl("versionOutputFine", name, version);
} }
} else { } else {
sender.sendMessage(tl("versionOutputUnsupported", name, version)); sender.sendTl("versionOutputUnsupported", name, version);
isUnsupported = true; isUnsupported = true;
} }
} }
if (versionPlugins.contains(name)) { if (versionPlugins.contains(name)) {
if (warnPlugins.contains(name)) { if (warnPlugins.contains(name)) {
sender.sendMessage(tl("versionOutputUnsupported", name, version)); sender.sendTl("versionOutputUnsupported", name, version);
isUnsupported = true; isUnsupported = true;
} else { } else {
sender.sendMessage(tl("versionOutputFine", name, version)); sender.sendTl("versionOutputFine", name, version);
} }
} }
@ -348,19 +346,19 @@ public class Commandessentials extends EssentialsCommand {
} }
if (isMismatched) { if (isMismatched) {
sender.sendMessage(tl("versionMismatchAll")); sender.sendTl("versionMismatchAll");
} }
if (!isVaultInstalled) { if (!isVaultInstalled) {
sender.sendMessage(tl("versionOutputVaultMissing")); sender.sendTl("versionOutputVaultMissing");
} }
if (isUnsupported) { if (isUnsupported) {
sender.sendMessage(tl("versionOutputUnsupportedPlugins")); sender.sendTl("versionOutputUnsupportedPlugins");
} }
if (!VersionUtil.isServerSupported()) { if (!VersionUtil.isServerSupported()) {
sender.sendMessage(tl("serverUnsupported")); sender.sendTl("serverUnsupported");
} }
} }

View File

@ -12,8 +12,6 @@ import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import static com.earth2me.essentials.I18n.tl;
public class Commandexp extends EssentialsCommand { public class Commandexp extends EssentialsCommand {
public Commandexp() { public Commandexp() {
@ -126,7 +124,7 @@ public class Commandexp extends EssentialsCommand {
} }
private void showExp(final CommandSource sender, final User target) { private void showExp(final CommandSource sender, final User target) {
sender.sendMessage(tl("exp", target.getDisplayName(), SetExpFix.getTotalExperience(target.getBase()), target.getBase().getLevel(), SetExpFix.getExpUntilNextLevel(target.getBase()))); sender.sendTl("exp", target.getDisplayName(), SetExpFix.getTotalExperience(target.getBase()), target.getBase().getLevel(), SetExpFix.getExpUntilNextLevel(target.getBase()));
} }
//TODO: Limit who can give negative exp? //TODO: Limit who can give negative exp?
@ -158,7 +156,7 @@ public class Commandexp extends EssentialsCommand {
amount = 0l; amount = 0l;
} }
SetExpFix.setTotalExperience(target.getBase(), (int) amount); SetExpFix.setTotalExperience(target.getBase(), (int) amount);
sender.sendMessage(tl("expSet", target.getDisplayName(), amount)); sender.sendTl("expSet", target.getDisplayName(), amount);
} }
@Override @Override

View File

@ -8,8 +8,6 @@ import org.bukkit.entity.Player;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import static com.earth2me.essentials.I18n.tl;
public class Commandext extends EssentialsLoopCommand { public class Commandext extends EssentialsLoopCommand {
public Commandext() { public Commandext() {
@ -29,7 +27,7 @@ public class Commandext extends EssentialsLoopCommand {
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception { public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception {
if (args.length < 1) { if (args.length < 1) {
extPlayer(user.getBase()); extPlayer(user.getBase());
user.sendMessage(tl("extinguish")); user.sendTl("extinguish");
return; return;
} }
@ -39,7 +37,7 @@ public class Commandext extends EssentialsLoopCommand {
@Override @Override
protected void updatePlayer(final Server server, final CommandSource sender, final User player, final String[] args) { protected void updatePlayer(final Server server, final CommandSource sender, final User player, final String[] args) {
extPlayer(player.getBase()); extPlayer(player.getBase());
sender.sendMessage(tl("extinguishOthers", player.getDisplayName())); sender.sendTl("extinguishOthers", player.getDisplayName());
} }
private void extPlayer(final Player player) { private void extPlayer(final Player player) {

View File

@ -9,8 +9,6 @@ import org.bukkit.event.entity.FoodLevelChangeEvent;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import static com.earth2me.essentials.I18n.tl;
public class Commandfeed extends EssentialsLoopCommand { public class Commandfeed extends EssentialsLoopCommand {
public Commandfeed() { public Commandfeed() {
@ -29,7 +27,7 @@ public class Commandfeed extends EssentialsLoopCommand {
} }
feedPlayer(user.getBase()); feedPlayer(user.getBase());
user.sendMessage(tl("feed")); user.sendTl("feed");
} }
@Override @Override
@ -45,7 +43,7 @@ public class Commandfeed extends EssentialsLoopCommand {
protected void updatePlayer(final Server server, final CommandSource sender, final User player, final String[] args) throws PlayerExemptException { protected void updatePlayer(final Server server, final CommandSource sender, final User player, final String[] args) throws PlayerExemptException {
try { try {
feedPlayer(player.getBase()); feedPlayer(player.getBase());
sender.sendMessage(tl("feedOther", player.getDisplayName())); sender.sendTl("feedOther", player.getDisplayName());
} catch (QuietAbortException e) { } catch (QuietAbortException e) {
//Handle Quietly //Handle Quietly
} }

View File

@ -56,7 +56,7 @@ public class Commandfireball extends EssentialsCommand {
} }
if (!user.isAuthorized("essentials.fireball." + type)) { if (!user.isAuthorized("essentials.fireball." + type)) {
throw new Exception(tl("noPerm", "essentials.fireball." + type)); throw new Exception(user.tl("noPerm", "essentials.fireball." + type));
} }
final Vector direction = user.getBase().getEyeLocation().getDirection().multiply(speed); final Vector direction = user.getBase().getEyeLocation().getDirection().multiply(speed);

View File

@ -18,8 +18,6 @@ import org.bukkit.util.Vector;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import static com.earth2me.essentials.I18n.tl;
//This command has quite a complicated syntax, in theory it has 4 seperate syntaxes which are all variable: //This command has quite a complicated syntax, in theory it has 4 seperate syntaxes which are all variable:
// //
//1: /firework clear - This clears all of the effects on a firework stack //1: /firework clear - This clears all of the effects on a firework stack
@ -51,14 +49,14 @@ public class Commandfirework extends EssentialsCommand {
FireworkMeta fmeta = (FireworkMeta) stack.getItemMeta(); FireworkMeta fmeta = (FireworkMeta) stack.getItemMeta();
fmeta.clearEffects(); fmeta.clearEffects();
stack.setItemMeta(fmeta); stack.setItemMeta(fmeta);
user.sendMessage(tl("fireworkEffectsCleared")); user.sendTl("fireworkEffectsCleared");
} else if (args.length > 1 && (args[0].equalsIgnoreCase("power") || (args[0].equalsIgnoreCase("p")))) { } else if (args.length > 1 && (args[0].equalsIgnoreCase("power") || (args[0].equalsIgnoreCase("p")))) {
FireworkMeta fmeta = (FireworkMeta) stack.getItemMeta(); FireworkMeta fmeta = (FireworkMeta) stack.getItemMeta();
try { try {
int power = Integer.parseInt(args[1]); int power = Integer.parseInt(args[1]);
fmeta.setPower(power > 3 ? 4 : power); fmeta.setPower(power > 3 ? 4 : power);
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
throw new Exception(tl("invalidFireworkFormat", args[1], args[0])); throw new Exception(user.tl("invalidFireworkFormat", args[1], args[0]));
} }
stack.setItemMeta(fmeta); stack.setItemMeta(fmeta);
} else if ((args[0].equalsIgnoreCase("fire") || (args[0].equalsIgnoreCase("f"))) && user.isAuthorized("essentials.firework.fire")) { } else if ((args[0].equalsIgnoreCase("fire") || (args[0].equalsIgnoreCase("f"))) && user.isAuthorized("essentials.firework.fire")) {
@ -70,7 +68,7 @@ public class Commandfirework extends EssentialsCommand {
amount = Integer.parseInt(args[1]); amount = Integer.parseInt(args[1]);
if (amount > serverLimit) { if (amount > serverLimit) {
amount = serverLimit; amount = serverLimit;
user.sendMessage(tl("mobSpawnLimit")); user.sendTl("mobSpawnLimit");
} }
} else { } else {
direction = true; direction = true;
@ -94,7 +92,7 @@ public class Commandfirework extends EssentialsCommand {
try { try {
mStack.addFireworkMeta(user.getSource(), true, arg, ess); mStack.addFireworkMeta(user.getSource(), true, arg, ess);
} catch (Exception e) { } catch (Exception e) {
user.sendMessage(tl("fireworkSyntax")); user.sendTl("fireworkSyntax");
throw e; throw e;
} }
} }
@ -103,20 +101,20 @@ public class Commandfirework extends EssentialsCommand {
FireworkMeta fmeta = (FireworkMeta) mStack.getItemStack().getItemMeta(); FireworkMeta fmeta = (FireworkMeta) mStack.getItemStack().getItemMeta();
FireworkEffect effect = mStack.getFireworkBuilder().build(); FireworkEffect effect = mStack.getFireworkBuilder().build();
if (fmeta.getEffects().size() > 0 && !user.isAuthorized("essentials.firework.multiple")) { if (fmeta.getEffects().size() > 0 && !user.isAuthorized("essentials.firework.multiple")) {
throw new Exception(tl("multipleCharges")); throw new Exception(user.tl("multipleCharges"));
} }
fmeta.addEffect(effect); fmeta.addEffect(effect);
stack.setItemMeta(fmeta); stack.setItemMeta(fmeta);
} else { } else {
user.sendMessage(tl("fireworkSyntax")); user.sendTl("fireworkSyntax");
throw new Exception(tl("fireworkColor")); throw new Exception(user.tl("fireworkColor"));
} }
} }
} else { } else {
throw new NotEnoughArgumentsException(); throw new NotEnoughArgumentsException();
} }
} else { } else {
throw new Exception(tl("holdFirework")); throw new Exception(user.tl("holdFirework"));
} }
} }

View File

@ -5,8 +5,6 @@ import com.earth2me.essentials.User;
import org.bukkit.Server; import org.bukkit.Server;
import net.ess3.api.events.FlyStatusChangeEvent; import net.ess3.api.events.FlyStatusChangeEvent;
import static com.earth2me.essentials.I18n.tl;
public class Commandfly extends EssentialsToggleCommand { public class Commandfly extends EssentialsToggleCommand {
public Commandfly() { public Commandfly() {
super("fly", "essentials.fly.others"); super("fly", "essentials.fly.others");
@ -40,9 +38,9 @@ public class Commandfly extends EssentialsToggleCommand {
user.getBase().setFlying(false); user.getBase().setFlying(false);
} }
user.sendMessage(tl("flyMode", tl(enabled ? "enabled" : "disabled"), user.getDisplayName())); user.sendTl("flyMode", user.tl(enabled ? "enabled" : "disabled"), user.getDisplayName());
if (!sender.isPlayer() || !sender.getPlayer().equals(user.getBase())) { if (!sender.isPlayer() || !sender.getPlayer().equals(user.getBase())) {
sender.sendMessage(tl("flyMode", tl(enabled ? "enabled" : "disabled"), user.getDisplayName())); sender.sendTl("flyMode", sender.tl(enabled ? "enabled" : "disabled"), user.getDisplayName());
} }
} }
} }

View File

@ -11,8 +11,6 @@ import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import static com.earth2me.essentials.I18n.tl;
public class Commandgamemode extends EssentialsCommand { public class Commandgamemode extends EssentialsCommand {
public Commandgamemode() { public Commandgamemode() {
@ -61,21 +59,21 @@ public class Commandgamemode extends EssentialsCommand {
} }
if (!canChangeToMode(user, gameMode)) { if (!canChangeToMode(user, gameMode)) {
user.sendMessage(tl("cantGamemode", gameMode.name())); user.sendTl("cantGamemode", gameMode.name());
return; return;
} }
user.getBase().setGameMode(gameMode); user.getBase().setGameMode(gameMode);
user.sendMessage(tl("gameMode", tl(user.getBase().getGameMode().toString().toLowerCase(Locale.ENGLISH)), user.getDisplayName())); user.sendTl("gameMode", user.tl(user.getBase().getGameMode().toString().toLowerCase(Locale.ENGLISH)), user.getDisplayName());
} }
private void gamemodeOtherPlayers(final Server server, final CommandSource sender, final GameMode gameMode, final String name) throws NotEnoughArgumentsException, PlayerNotFoundException { private void gamemodeOtherPlayers(final Server server, final CommandSource sender, final GameMode gameMode, final String name) throws NotEnoughArgumentsException, PlayerNotFoundException {
if (name.trim().length() < 2 || gameMode == null) { if (name.trim().length() < 2 || gameMode == null) {
throw new NotEnoughArgumentsException(tl("gameModeInvalid")); throw new NotEnoughArgumentsException(sender.tl("gameModeInvalid"));
} }
if (sender.isPlayer() && !canChangeToMode(ess.getUser(sender.getPlayer()), gameMode)) { if (sender.isPlayer() && !canChangeToMode(ess.getUser(sender.getPlayer()), gameMode)) {
sender.sendMessage(tl("cantGamemode", gameMode.name())); sender.sendTl("cantGamemode", gameMode.name());
return; return;
} }
@ -89,7 +87,7 @@ public class Commandgamemode extends EssentialsCommand {
} }
foundUser = true; foundUser = true;
player.getBase().setGameMode(gameMode); player.getBase().setGameMode(gameMode);
sender.sendMessage(tl("gameMode", tl(player.getBase().getGameMode().toString().toLowerCase(Locale.ENGLISH)), player.getDisplayName())); sender.sendTl("gameMode", sender.tl(player.getBase().getGameMode().toString().toLowerCase(Locale.ENGLISH)), player.getDisplayName());
} }
if (!foundUser) { if (!foundUser) {
throw new PlayerNotFoundException(); throw new PlayerNotFoundException();

View File

@ -9,8 +9,6 @@ import java.lang.management.ManagementFactory;
import java.util.List; import java.util.List;
import java.util.logging.Level; import java.util.logging.Level;
import static com.earth2me.essentials.I18n.tl;
public class Commandgc extends EssentialsCommand { public class Commandgc extends EssentialsCommand {
public Commandgc() { public Commandgc() {
@ -29,11 +27,11 @@ public class Commandgc extends EssentialsCommand {
color = ChatColor.RED; color = ChatColor.RED;
} }
sender.sendMessage(tl("uptime", DateUtil.formatDateDiff(ManagementFactory.getRuntimeMXBean().getStartTime()))); sender.sendTl("uptime", DateUtil.formatDateDiff(sender, ManagementFactory.getRuntimeMXBean().getStartTime()));
sender.sendMessage(tl("tps", "" + color + NumberUtil.formatDouble(tps))); sender.sendTl("tps", "" + color + NumberUtil.formatDouble(tps));
sender.sendMessage(tl("gcmax", (Runtime.getRuntime().maxMemory() / 1024 / 1024))); sender.sendTl("gcmax", (Runtime.getRuntime().maxMemory() / 1024 / 1024));
sender.sendMessage(tl("gctotal", (Runtime.getRuntime().totalMemory() / 1024 / 1024))); sender.sendTl("gctotal", (Runtime.getRuntime().totalMemory() / 1024 / 1024));
sender.sendMessage(tl("gcfree", (Runtime.getRuntime().freeMemory() / 1024 / 1024))); sender.sendTl("gcfree", (Runtime.getRuntime().freeMemory() / 1024 / 1024));
List<World> worlds = server.getWorlds(); List<World> worlds = server.getWorlds();
for (World w : worlds) { for (World w : worlds) {
@ -57,7 +55,7 @@ public class Commandgc extends EssentialsCommand {
Bukkit.getLogger().log(Level.SEVERE, "Corrupted chunk data on world " + w, ex); Bukkit.getLogger().log(Level.SEVERE, "Corrupted chunk data on world " + w, ex);
} }
sender.sendMessage(tl("gcWorld", worldType, w.getName(), w.getLoadedChunks().length, w.getEntities().size(), tileEntities)); sender.sendTl("gcWorld", worldType, w.getName(), w.getLoadedChunks().length, w.getEntities().size(), tileEntities);
} }
} }
} }

View File

@ -8,8 +8,6 @@ import org.bukkit.Server;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import static com.earth2me.essentials.I18n.tl;
public class Commandgetpos extends EssentialsCommand { public class Commandgetpos extends EssentialsCommand {
public Commandgetpos() { public Commandgetpos() {
@ -36,14 +34,14 @@ public class Commandgetpos extends EssentialsCommand {
} }
private void outputPosition(final CommandSource sender, final Location coords, final Location distance) { private void outputPosition(final CommandSource sender, final Location coords, final Location distance) {
sender.sendMessage(tl("currentWorld", coords.getWorld().getName())); sender.sendTl("currentWorld", coords.getWorld().getName());
sender.sendMessage(tl("posX", coords.getBlockX())); sender.sendTl("posX", coords.getBlockX());
sender.sendMessage(tl("posY", coords.getBlockY())); sender.sendTl("posY", coords.getBlockY());
sender.sendMessage(tl("posZ", coords.getBlockZ())); sender.sendTl("posZ", coords.getBlockZ());
sender.sendMessage(tl("posYaw", (coords.getYaw() + 360) % 360)); sender.sendTl("posYaw", (coords.getYaw() + 360) % 360);
sender.sendMessage(tl("posPitch", coords.getPitch())); sender.sendTl("posPitch", coords.getPitch());
if (distance != null && coords.getWorld().equals(distance.getWorld())) { if (distance != null && coords.getWorld().equals(distance.getWorld())) {
sender.sendMessage(tl("distance", coords.distance(distance))); sender.sendTl("distance", coords.distance(distance));
} }
} }

View File

@ -16,8 +16,6 @@ import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.Map; import java.util.Map;
import static com.earth2me.essentials.I18n.tl;
public class Commandgive extends EssentialsCommand { public class Commandgive extends EssentialsCommand {
public Commandgive() { public Commandgive() {
@ -34,7 +32,7 @@ public class Commandgive extends EssentialsCommand {
final String itemname = stack.getType().toString().toLowerCase(Locale.ENGLISH).replace("_", ""); final String itemname = stack.getType().toString().toLowerCase(Locale.ENGLISH).replace("_", "");
if (sender.isPlayer() && !ess.getUser(sender.getPlayer()).canSpawnItem(stack.getType())) { if (sender.isPlayer() && !ess.getUser(sender.getPlayer()).canSpawnItem(stack.getType())) {
throw new Exception(tl("cantSpawnItem", itemname)); throw new Exception(sender.tl("cantSpawnItem", itemname));
} }
final User giveTo = getPlayer(server, sender, args, 0); final User giveTo = getPlayer(server, sender, args, 0);
@ -56,7 +54,7 @@ public class Commandgive extends EssentialsCommand {
MetaItemStack metaStack = new MetaItemStack(stack); MetaItemStack metaStack = new MetaItemStack(stack);
if (!metaStack.canSpawn(ess)) { if (!metaStack.canSpawn(ess)) {
throw new Exception(tl("unableToSpawnItem", itemname)); throw new Exception(sender.tl("unableToSpawnItem", itemname));
} }
if (args.length > 3) { if (args.length > 3) {
@ -75,11 +73,11 @@ public class Commandgive extends EssentialsCommand {
} }
if (stack.getType() == Material.AIR) { if (stack.getType() == Material.AIR) {
throw new Exception(tl("cantSpawnItem", "Air")); throw new Exception(sender.tl("cantSpawnItem", "Air"));
} }
final String itemName = stack.getType().toString().toLowerCase(Locale.ENGLISH).replace('_', ' '); final String itemName = stack.getType().toString().toLowerCase(Locale.ENGLISH).replace('_', ' ');
sender.sendMessage(tl("giveSpawn", stack.getAmount(), itemName, giveTo.getDisplayName())); sender.sendTl("giveSpawn", stack.getAmount(), itemName, giveTo.getDisplayName());
Map<Integer, ItemStack> leftovers; Map<Integer, ItemStack> leftovers;
@ -96,7 +94,7 @@ public class Commandgive extends EssentialsCommand {
World w = giveTo.getWorld(); World w = giveTo.getWorld();
w.dropItemNaturally(giveTo.getLocation(), item); w.dropItemNaturally(giveTo.getLocation(), item);
} else { } else {
sender.sendMessage(tl("giveSpawnFailure", item.getAmount(), itemName, giveTo.getDisplayName())); sender.sendTl("giveSpawnFailure", item.getAmount(), itemName, giveTo.getDisplayName());
} }
} }

View File

@ -5,8 +5,6 @@ import com.earth2me.essentials.User;
import net.ess3.api.events.GodStatusChangeEvent; import net.ess3.api.events.GodStatusChangeEvent;
import org.bukkit.Server; import org.bukkit.Server;
import static com.earth2me.essentials.I18n.tl;
public class Commandgod extends EssentialsToggleCommand { public class Commandgod extends EssentialsToggleCommand {
public Commandgod() { public Commandgod() {
@ -40,9 +38,9 @@ public class Commandgod extends EssentialsToggleCommand {
user.getBase().setFoodLevel(20); user.getBase().setFoodLevel(20);
} }
user.sendMessage(tl("godMode", enabled ? tl("enabled") : tl("disabled"))); user.sendTl("godMode", enabled ? user.tl("enabled") : user.tl("disabled"));
if (!sender.isPlayer() || !sender.getPlayer().equals(user.getBase())) { if (!sender.isPlayer() || !sender.getPlayer().equals(user.getBase())) {
sender.sendMessage(tl("godMode", tl(enabled ? "godEnabledFor" : "godDisabledFor", user.getDisplayName()))); sender.sendTl("godMode", sender.tl(enabled ? "godEnabledFor" : "godDisabledFor", user.getDisplayName()));
} }
} }
} }

View File

@ -11,8 +11,6 @@ import org.bukkit.inventory.PlayerInventory;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import static com.earth2me.essentials.I18n.tl;
public class Commandhat extends EssentialsCommand { public class Commandhat extends EssentialsCommand {
public Commandhat() { public Commandhat() {
@ -25,12 +23,12 @@ public class Commandhat extends EssentialsCommand {
final PlayerInventory inv = user.getBase().getInventory(); final PlayerInventory inv = user.getBase().getInventory();
final ItemStack head = inv.getHelmet(); final ItemStack head = inv.getHelmet();
if (head == null || head.getType() == Material.AIR) { if (head == null || head.getType() == Material.AIR) {
user.sendMessage(tl("hatEmpty")); user.sendTl("hatEmpty");
} else { } else {
final ItemStack air = new ItemStack(Material.AIR); final ItemStack air = new ItemStack(Material.AIR);
inv.setHelmet(air); inv.setHelmet(air);
InventoryWorkaround.addItems(user.getBase().getInventory(), head); InventoryWorkaround.addItems(user.getBase().getInventory(), head);
user.sendMessage(tl("hatRemoved")); user.sendTl("hatRemoved");
} }
} else { } else {
final ItemStack hand = user.getItemInHand(); final ItemStack hand = user.getItemInHand();
@ -44,12 +42,12 @@ public class Commandhat extends EssentialsCommand {
final ItemStack head = inv.getHelmet(); final ItemStack head = inv.getHelmet();
inv.setHelmet(hand); inv.setHelmet(hand);
inv.setItemInHand(head); inv.setItemInHand(head);
user.sendMessage(tl("hatPlaced")); user.sendTl("hatPlaced");
} else { } else {
user.sendMessage(tl("hatArmor")); user.sendTl("hatArmor");
} }
} else { } else {
user.sendMessage(tl("hatFail")); user.sendTl("hatFail");
} }
} }
} }

View File

@ -11,8 +11,6 @@ import org.bukkit.potion.PotionEffect;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import static com.earth2me.essentials.I18n.tl;
public class Commandheal extends EssentialsLoopCommand { public class Commandheal extends EssentialsLoopCommand {
public Commandheal() { public Commandheal() {
@ -46,7 +44,7 @@ public class Commandheal extends EssentialsLoopCommand {
protected void updatePlayer(final Server server, final CommandSource sender, final User player, final String[] args) throws PlayerExemptException { protected void updatePlayer(final Server server, final CommandSource sender, final User player, final String[] args) throws PlayerExemptException {
try { try {
healPlayer(player); healPlayer(player);
sender.sendMessage(tl("healOther", player.getDisplayName())); sender.sendTl("healOther", player.getDisplayName());
} catch (QuietAbortException e) { } catch (QuietAbortException e) {
//Handle Quietly //Handle Quietly
} }
@ -56,7 +54,7 @@ public class Commandheal extends EssentialsLoopCommand {
final Player player = user.getBase(); final Player player = user.getBase();
if (player.getHealth() == 0) { if (player.getHealth() == 0) {
throw new PlayerExemptException(tl("healDead")); throw new PlayerExemptException(user.tl("healDead"));
} }
final double amount = player.getMaxHealth() - player.getHealth(); final double amount = player.getMaxHealth() - player.getHealth();
@ -74,7 +72,7 @@ public class Commandheal extends EssentialsLoopCommand {
player.setHealth(newAmount); player.setHealth(newAmount);
player.setFoodLevel(20); player.setFoodLevel(20);
player.setFireTicks(0); player.setFireTicks(0);
user.sendMessage(tl("heal")); user.sendTl("heal");
for (PotionEffect effect : player.getActivePotionEffects()) { for (PotionEffect effect : player.getActivePotionEffects()) {
player.removePotionEffect(effect.getType()); player.removePotionEffect(effect.getType());
} }

View File

@ -10,8 +10,6 @@ import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import static com.earth2me.essentials.I18n.tl;
public class Commandhelp extends EssentialsCommand { public class Commandhelp extends EssentialsCommand {
public Commandhelp() { public Commandhelp() {
@ -48,7 +46,7 @@ public class Commandhelp extends EssentialsCommand {
@Override @Override
protected void run(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception { protected void run(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception {
sender.sendMessage(tl("helpConsole")); sender.sendTl("helpConsole");
} }
@Override @Override

View File

@ -35,10 +35,10 @@ public class Commandhelpop extends EssentialsCommand {
if (args.length < 1) { if (args.length < 1) {
throw new NotEnoughArgumentsException(); throw new NotEnoughArgumentsException();
} }
final String message = tl("helpOp", from, FormatUtil.stripFormat(getFinalArg(args, 0))); final String message = FormatUtil.stripFormat(getFinalArg(args, 0));
server.getLogger().log(Level.INFO, message); ess.broadcastTl("essentials.helpop.receive", "helpOp", from, message);
ess.broadcastMessage("essentials.helpop.receive", message); server.getLogger().log(Level.INFO, tl("helpOp", from, message));
return message; return sender.tl("helpOp", from, message);
} }
@Override @Override

View File

@ -7,13 +7,10 @@ import org.bukkit.Location;
import org.bukkit.Server; import org.bukkit.Server;
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import static com.earth2me.essentials.I18n.tl;
public class Commandhome extends EssentialsCommand { public class Commandhome extends EssentialsCommand {
public Commandhome() { public Commandhome() {
@ -45,7 +42,7 @@ public class Commandhome extends EssentialsCommand {
user.getTeleport().teleport(bed, charge, TeleportCause.COMMAND); user.getTeleport().teleport(bed, charge, TeleportCause.COMMAND);
throw new NoChargeException(); throw new NoChargeException();
} else { } else {
throw new Exception(tl("bedMissing")); throw new Exception(user.tl("bedMissing"));
} }
} }
goHome(user, player, homeName.toLowerCase(Locale.ENGLISH), charge); goHome(user, player, homeName.toLowerCase(Locale.ENGLISH), charge);
@ -55,19 +52,19 @@ public class Commandhome extends EssentialsCommand {
if (homes.isEmpty() && player.equals(user)) { if (homes.isEmpty() && player.equals(user)) {
user.getTeleport().respawn(charge, TeleportCause.COMMAND); user.getTeleport().respawn(charge, TeleportCause.COMMAND);
} else if (homes.isEmpty()) { } else if (homes.isEmpty()) {
throw new Exception(tl("noHomeSetPlayer")); throw new Exception(user.tl("noHomeSetPlayer"));
} else if (homes.size() == 1 && player.equals(user)) { } else if (homes.size() == 1 && player.equals(user)) {
goHome(user, player, homes.get(0), charge); goHome(user, player, homes.get(0), charge);
} else { } else {
final int count = homes.size(); final int count = homes.size();
if (user.isAuthorized("essentials.home.bed")) { if (user.isAuthorized("essentials.home.bed")) {
if (bed != null) { if (bed != null) {
homes.add(tl("bed")); homes.add(user.tl("bed"));
} else { } else {
homes.add(tl("bedNull")); homes.add(user.tl("bedNull"));
} }
} }
user.sendMessage(tl("homes", StringUtil.joinList(homes), count, getHomeLimit(player))); user.sendTl("homes", StringUtil.joinList(homes), count, getHomeLimit(player));
} }
} }
throw new NoChargeException(); throw new NoChargeException();
@ -92,10 +89,10 @@ public class Commandhome extends EssentialsCommand {
throw new NotEnoughArgumentsException(); throw new NotEnoughArgumentsException();
} }
if (user.getWorld() != loc.getWorld() && ess.getSettings().isWorldHomePermissions() && !user.isAuthorized("essentials.worlds." + loc.getWorld().getName())) { if (user.getWorld() != loc.getWorld() && ess.getSettings().isWorldHomePermissions() && !user.isAuthorized("essentials.worlds." + loc.getWorld().getName())) {
throw new Exception(tl("noPerm", "essentials.worlds." + loc.getWorld().getName())); throw new Exception(user.tl("noPerm", "essentials.worlds." + loc.getWorld().getName()));
} }
user.getTeleport().teleport(loc, charge, TeleportCause.COMMAND); user.getTeleport().teleport(loc, charge, TeleportCause.COMMAND);
user.sendMessage(tl("teleportHome", home)); user.sendTl("teleportHome", home);
} }
@Override @Override

View File

@ -6,8 +6,6 @@ import org.bukkit.Server;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import static com.earth2me.essentials.I18n.tl;
public class Commandignore extends EssentialsCommand { public class Commandignore extends EssentialsCommand {
public Commandignore() { public Commandignore() {
@ -22,7 +20,7 @@ public class Commandignore extends EssentialsCommand {
sb.append(s).append(" "); sb.append(s).append(" ");
} }
String ignoredList = sb.toString().trim(); String ignoredList = sb.toString().trim();
user.sendMessage(ignoredList.length() > 0 ? tl("ignoredList", ignoredList) : tl("noIgnored")); user.sendMessage(ignoredList.length() > 0 ? user.tl("ignoredList", ignoredList) : user.tl("noIgnored"));
} else { } else {
User player; User player;
try { try {
@ -34,13 +32,13 @@ public class Commandignore extends EssentialsCommand {
throw new PlayerNotFoundException(); throw new PlayerNotFoundException();
} }
if (player.isIgnoreExempt()) { if (player.isIgnoreExempt()) {
user.sendMessage(tl("ignoreExempt")); user.sendTl("ignoreExempt");
} else if (user.isIgnoredPlayer(player)) { } else if (user.isIgnoredPlayer(player)) {
user.setIgnoredPlayer(player, false); user.setIgnoredPlayer(player, false);
user.sendMessage(tl("unignorePlayer", player.getName())); user.sendTl("unignorePlayer", player.getName());
} else { } else {
user.setIgnoredPlayer(player, true); user.setIgnoredPlayer(player, true);
user.sendMessage(tl("ignorePlayer", player.getName())); user.sendTl("ignorePlayer", player.getName());
} }
} }
} }

View File

@ -12,8 +12,6 @@ import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import static com.earth2me.essentials.I18n.tl;
public class Commanditem extends EssentialsCommand { public class Commanditem extends EssentialsCommand {
public Commanditem() { public Commanditem() {
@ -30,7 +28,7 @@ public class Commanditem extends EssentialsCommand {
final String itemname = stack.getType().toString().toLowerCase(Locale.ENGLISH).replace("_", ""); final String itemname = stack.getType().toString().toLowerCase(Locale.ENGLISH).replace("_", "");
if (!user.canSpawnItem(stack.getType())) { if (!user.canSpawnItem(stack.getType())) {
throw new Exception(tl("cantSpawnItem", itemname)); throw new Exception(user.tl("cantSpawnItem", itemname));
} }
try { try {
@ -47,7 +45,7 @@ public class Commanditem extends EssentialsCommand {
MetaItemStack metaStack = new MetaItemStack(stack); MetaItemStack metaStack = new MetaItemStack(stack);
if (!metaStack.canSpawn(ess)) { if (!metaStack.canSpawn(ess)) {
throw new Exception(tl("unableToSpawnItem", itemname)); throw new Exception(user.tl("unableToSpawnItem", itemname));
} }
if (args.length > 2) { if (args.length > 2) {
@ -60,11 +58,11 @@ public class Commanditem extends EssentialsCommand {
if (stack.getType() == Material.AIR) { if (stack.getType() == Material.AIR) {
throw new Exception(tl("cantSpawnItem", "Air")); throw new Exception(user.tl("cantSpawnItem", "Air"));
} }
final String displayName = stack.getType().toString().toLowerCase(Locale.ENGLISH).replace('_', ' '); final String displayName = stack.getType().toString().toLowerCase(Locale.ENGLISH).replace('_', ' ');
user.sendMessage(tl("itemSpawn", stack.getAmount(), displayName)); user.sendTl("itemSpawn", stack.getAmount(), displayName);
if (user.isAuthorized("essentials.oversizedstacks")) { if (user.isAuthorized("essentials.oversizedstacks")) {
InventoryWorkaround.addOversizedItems(user.getBase().getInventory(), ess.getSettings().getOversizedStackSize(), stack); InventoryWorkaround.addOversizedItems(user.getBase().getInventory(), ess.getSettings().getOversizedStackSize(), stack);
} else { } else {

View File

@ -9,8 +9,6 @@ import org.bukkit.inventory.ItemStack;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import static com.earth2me.essentials.I18n.tl;
public class Commanditemdb extends EssentialsCommand { public class Commanditemdb extends EssentialsCommand {
public Commanditemdb() { public Commanditemdb() {
@ -39,23 +37,23 @@ public class Commanditemdb extends EssentialsCommand {
itemId = itemStack.getType().getId() + ":" + itemStack.getDurability(); itemId = itemStack.getType().getId() + ":" + itemStack.getDurability();
} }
sender.sendMessage(tl("itemType", itemStack.getType().toString(), itemId)); sender.sendTl("itemType", itemStack.getType().toString(), itemId);
// Don't send IDs twice // Don't send IDs twice
if (!tl("itemType").contains("{1}") && !itemId.equals("none")) { if (!sender.tl("itemType").contains("{1}") && !itemId.equals("none")) {
sender.sendMessage(tl("itemId", itemId)); sender.sendTl("itemId", itemId);
} }
if (itemHeld && itemStack.getType() != Material.AIR) { if (itemHeld && itemStack.getType() != Material.AIR) {
int maxuses = itemStack.getType().getMaxDurability(); int maxuses = itemStack.getType().getMaxDurability();
int durability = ((maxuses + 1) - itemStack.getDurability()); int durability = ((maxuses + 1) - itemStack.getDurability());
if (maxuses != 0) { if (maxuses != 0) {
sender.sendMessage(tl("durability", Integer.toString(durability))); sender.sendTl("durability", Integer.toString(durability));
} }
} }
final String itemNameList = ess.getItemDb().names(itemStack); final String itemNameList = ess.getItemDb().names(itemStack);
if (itemNameList != null) { if (itemNameList != null) {
sender.sendMessage(tl("itemNames", ess.getItemDb().names(itemStack))); sender.sendTl("itemNames", ess.getItemDb().names(itemStack));
} }
} }

View File

@ -25,7 +25,7 @@ public class Commanditemname extends EssentialsCommand {
protected void run(Server server, User user, String commandLabel, String[] args) throws Exception { protected void run(Server server, User user, String commandLabel, String[] args) throws Exception {
ItemStack item = user.getBase().getItemInHand(); ItemStack item = user.getBase().getItemInHand();
if (item.getType().name().contains("AIR")) { if (item.getType().name().contains("AIR")) {
user.sendMessage(tl("itemnameInvalidItem", item.getType().toString().toLowerCase(Locale.ENGLISH).replace('_', ' '))); user.sendTl("itemnameInvalidItem", item.getType().toString().toLowerCase(Locale.ENGLISH).replace('_', ' '));
return; return;
} }
@ -35,6 +35,11 @@ public class Commanditemname extends EssentialsCommand {
ItemMeta im = item.getItemMeta(); ItemMeta im = item.getItemMeta();
im.setDisplayName(name); im.setDisplayName(name);
item.setItemMeta(im); item.setItemMeta(im);
user.sendMessage(name == null ? tl("itemnameClear") : tl("itemnameSuccess", name));
if (name == null) {
user.sendTl("itemnameClear");
} else {
user.sendTl("itemnameSuccess", name);
}
} }
} }

View File

@ -4,10 +4,6 @@ import com.earth2me.essentials.CommandSource;
import com.earth2me.essentials.utils.StringUtil; import com.earth2me.essentials.utils.StringUtil;
import org.bukkit.Server; import org.bukkit.Server;
import java.util.Collection;
import static com.earth2me.essentials.I18n.tl;
public class Commandjails extends EssentialsCommand { public class Commandjails extends EssentialsCommand {
public Commandjails() { public Commandjails() {
@ -17,9 +13,9 @@ public class Commandjails extends EssentialsCommand {
@Override @Override
protected void run(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception { protected void run(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception {
if (ess.getJails().getCount() < 1) { if (ess.getJails().getCount() < 1) {
sender.sendMessage(tl("noJailsDefined")); sender.sendTl("noJailsDefined");
} else { } else {
sender.sendMessage(tl("jailList", StringUtil.joinList(" ", ess.getJails().getList()))); sender.sendTl("jailList", StringUtil.joinList(" ", ess.getJails().getList()));
} }
} }
} }

View File

@ -11,8 +11,6 @@ import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import static com.earth2me.essentials.I18n.tl;
// This method contains an undocumented sub command #EasterEgg // This method contains an undocumented sub command #EasterEgg
public class Commandjump extends EssentialsCommand { public class Commandjump extends EssentialsCommand {
public Commandjump() { public Commandjump() {
@ -41,7 +39,7 @@ public class Commandjump extends EssentialsCommand {
loc.setPitch(cloc.getPitch()); loc.setPitch(cloc.getPitch());
loc.setY(loc.getY() + 1); loc.setY(loc.getY() + 1);
} catch (NullPointerException ex) { } catch (NullPointerException ex) {
throw new Exception(tl("jumpError"), ex); throw new Exception(user.tl("jumpError"), ex);
} }
final Trade charge = new Trade(this.getName(), ess); final Trade charge = new Trade(this.getName(), ess);

View File

@ -32,18 +32,18 @@ public class Commandkick extends EssentialsCommand {
} }
if (target.isAuthorized("essentials.kick.exempt")) { if (target.isAuthorized("essentials.kick.exempt")) {
throw new Exception(tl("kickExempt")); throw new Exception(user.tl("kickExempt"));
} }
} }
String kickReason = args.length > 1 ? getFinalArg(args, 1) : tl("kickDefault"); String kickReason = args.length > 1 ? getFinalArg(args, 1) : target.tl("kickDefault");
kickReason = FormatUtil.replaceFormat(kickReason.replace("\\n", "\n").replace("|", "\n")); kickReason = FormatUtil.replaceFormat(kickReason.replace("\\n", "\n").replace("|", "\n"));
target.getBase().kickPlayer(kickReason); target.getBase().kickPlayer(kickReason);
final String senderName = sender.isPlayer() ? sender.getPlayer().getDisplayName() : Console.NAME; final String senderName = sender.isPlayer() ? sender.getPlayer().getDisplayName() : Console.NAME;
server.getLogger().log(Level.INFO, tl("playerKicked", senderName, target.getName(), kickReason)); server.getLogger().log(Level.INFO, tl("playerKicked", senderName, target.getName(), kickReason));
ess.broadcastMessage("essentials.kick.notify", tl("playerKicked", senderName, target.getName(), kickReason)); ess.broadcastTl("essentials.kick.notify", "playerKicked", senderName, target.getName(), kickReason);
} }
@Override @Override

View File

@ -1,12 +1,11 @@
package com.earth2me.essentials.commands; package com.earth2me.essentials.commands;
import com.earth2me.essentials.CommandSource; import com.earth2me.essentials.CommandSource;
import com.earth2me.essentials.User;
import com.earth2me.essentials.utils.FormatUtil; import com.earth2me.essentials.utils.FormatUtil;
import org.bukkit.Server; import org.bukkit.Server;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import static com.earth2me.essentials.I18n.tl;
public class Commandkickall extends EssentialsCommand { public class Commandkickall extends EssentialsCommand {
public Commandkickall() { public Commandkickall() {
@ -15,16 +14,16 @@ public class Commandkickall extends EssentialsCommand {
@Override @Override
public void run(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception { public void run(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception {
String kickReason = args.length > 0 ? getFinalArg(args, 0) : tl("kickDefault");
kickReason = FormatUtil.replaceFormat(kickReason.replace("\\n", "\n").replace("|", "\n"));
for (Player onlinePlayer : ess.getOnlinePlayers()) { for (Player onlinePlayer : ess.getOnlinePlayers()) {
if (!sender.isPlayer() || !onlinePlayer.getName().equalsIgnoreCase(sender.getPlayer().getName())) { if (!sender.isPlayer() || !onlinePlayer.getName().equalsIgnoreCase(sender.getPlayer().getName())) {
if (!ess.getUser(onlinePlayer).isAuthorized("essentials.kickall.exempt")) { final User kuser = ess.getUser(onlinePlayer);
if (!kuser.isAuthorized("essentials.kickall.exempt")) {
String kickReason = args.length > 0 ? getFinalArg(args, 0) : kuser.tl("kickDefault");
kickReason = FormatUtil.replaceFormat(kickReason.replace("\\n", "\n").replace("|", "\n"));
onlinePlayer.kickPlayer(kickReason); onlinePlayer.kickPlayer(kickReason);
} }
} }
} }
sender.sendMessage(tl("kickedAll")); sender.sendTl("kickedAll");
} }
} }

View File

@ -9,8 +9,6 @@ import org.bukkit.event.entity.EntityDamageEvent;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import static com.earth2me.essentials.I18n.tl;
public class Commandkill extends EssentialsLoopCommand { public class Commandkill extends EssentialsLoopCommand {
public Commandkill() { public Commandkill() {
@ -30,7 +28,7 @@ public class Commandkill extends EssentialsLoopCommand {
protected void updatePlayer(final Server server, final CommandSource sender, final User user, final String[] args) throws PlayerExemptException { protected void updatePlayer(final Server server, final CommandSource sender, final User user, final String[] args) throws PlayerExemptException {
final Player matchPlayer = user.getBase(); final Player matchPlayer = user.getBase();
if (sender.isPlayer() && user.isAuthorized("essentials.kill.exempt") && !ess.getUser(sender.getPlayer()).isAuthorized("essentials.kill.force")) { if (sender.isPlayer() && user.isAuthorized("essentials.kill.exempt") && !ess.getUser(sender.getPlayer()).isAuthorized("essentials.kill.force")) {
throw new PlayerExemptException(tl("killExempt", matchPlayer.getDisplayName())); throw new PlayerExemptException(user.tl("killExempt", matchPlayer.getDisplayName()));
} }
final EntityDamageEvent ede = new EntityDamageEvent(matchPlayer, sender.isPlayer() && sender.getPlayer().getName().equals(matchPlayer.getName()) ? EntityDamageEvent.DamageCause.SUICIDE : EntityDamageEvent.DamageCause.CUSTOM, Short.MAX_VALUE); final EntityDamageEvent ede = new EntityDamageEvent(matchPlayer, sender.isPlayer() && sender.getPlayer().getName().equals(matchPlayer.getName()) ? EntityDamageEvent.DamageCause.SUICIDE : EntityDamageEvent.DamageCause.CUSTOM, Short.MAX_VALUE);
server.getPluginManager().callEvent(ede); server.getPluginManager().callEvent(ede);
@ -44,7 +42,7 @@ public class Commandkill extends EssentialsLoopCommand {
matchPlayer.setHealth(0); matchPlayer.setHealth(0);
} }
sender.sendMessage(tl("kill", matchPlayer.getDisplayName())); sender.sendTl("kill", matchPlayer.getDisplayName());
} }
@Override @Override

View File

@ -12,8 +12,6 @@ import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.logging.Level; import java.util.logging.Level;
import static com.earth2me.essentials.I18n.tl;
public class Commandkit extends EssentialsCommand { public class Commandkit extends EssentialsCommand {
public Commandkit() { public Commandkit() {
@ -24,7 +22,7 @@ public class Commandkit extends EssentialsCommand {
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception { public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception {
if (args.length < 1) { if (args.length < 1) {
final String kitList = ess.getKits().listKits(ess, user); final String kitList = ess.getKits().listKits(ess, user);
user.sendMessage(kitList.length() > 0 ? tl("kits", kitList) : tl("noKits")); user.sendMessage(kitList.length() > 0 ? user.tl("kits", kitList) : user.tl("noKits"));
throw new NoChargeException(); throw new NoChargeException();
} else if (args.length > 1 && user.isAuthorized("essentials.kit.others")) { } else if (args.length > 1 && user.isAuthorized("essentials.kit.others")) {
final User userTo = getPlayer(server, user, args, 1); final User userTo = getPlayer(server, user, args, 1);
@ -40,7 +38,7 @@ public class Commandkit extends EssentialsCommand {
public void run(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception { public void run(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception {
if (args.length < 2) { if (args.length < 2) {
final String kitList = ess.getKits().listKits(ess, null); final String kitList = ess.getKits().listKits(ess, null);
sender.sendMessage(kitList.length() > 0 ? tl("kits", kitList) : tl("noKits")); sender.sendMessage(kitList.length() > 0 ? sender.tl("kits", kitList) : sender.tl("noKits"));
throw new NoChargeException(); throw new NoChargeException();
} else { } else {
final User userTo = getPlayer(server, args, 1, true, false); final User userTo = getPlayer(server, args, 1, true, false);
@ -50,15 +48,15 @@ public class Commandkit extends EssentialsCommand {
final Kit kit = new Kit(kitName, ess); final Kit kit = new Kit(kitName, ess);
kit.expandItems(userTo); kit.expandItems(userTo);
sender.sendMessage(tl("kitGiveTo", kitName, userTo.getDisplayName())); sender.sendTl("kitGiveTo", kitName, userTo.getDisplayName());
userTo.sendMessage(tl("kitReceive", kitName)); userTo.sendTl("kitReceive", kitName);
} }
} }
} }
private void giveKits(final User userTo, final User userFrom, final String kitNames) throws Exception { private void giveKits(final User userTo, final User userFrom, final String kitNames) throws Exception {
if (kitNames.isEmpty()) { if (kitNames.isEmpty()) {
throw new Exception(tl("kitNotFound")); throw new Exception(userFrom.tl("kitNotFound"));
} }
String[] kitList = kitNames.split(","); String[] kitList = kitNames.split(",");
@ -66,7 +64,7 @@ public class Commandkit extends EssentialsCommand {
for (final String kitName : kitList) { for (final String kitName : kitList) {
if (kitName.isEmpty()) { if (kitName.isEmpty()) {
throw new Exception(tl("kitNotFound")); throw new Exception(userFrom.tl("kitNotFound"));
} }
Kit kit = new Kit(kitName, ess); Kit kit = new Kit(kitName, ess);
@ -86,10 +84,10 @@ public class Commandkit extends EssentialsCommand {
kit.chargeUser(userTo); kit.chargeUser(userTo);
if (!userFrom.equals(userTo)) { if (!userFrom.equals(userTo)) {
userFrom.sendMessage(tl("kitGiveTo", kit.getName(), userTo.getDisplayName())); userFrom.sendTl("kitGiveTo", kit.getName(), userTo.getDisplayName());
} }
userTo.sendMessage(tl("kitReceive", kit.getName())); userTo.sendTl("kitReceive", kit.getName());
} catch (NoChargeException ex) { } catch (NoChargeException ex) {
if (ess.getSettings().isDebug()) { if (ess.getSettings().isDebug()) {

View File

@ -12,8 +12,6 @@ import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import static com.earth2me.essentials.I18n.tl;
public class Commandlightning extends EssentialsLoopCommand { public class Commandlightning extends EssentialsLoopCommand {
int power = 5; int power = 5;
@ -44,14 +42,14 @@ public class Commandlightning extends EssentialsLoopCommand {
@Override @Override
protected void updatePlayer(final Server server, final CommandSource sender, final User matchUser, final String[] args) { protected void updatePlayer(final Server server, final CommandSource sender, final User matchUser, final String[] args) {
sender.sendMessage(tl("lightningUse", matchUser.getDisplayName())); sender.sendTl("lightningUse", matchUser.getDisplayName());
final LightningStrike strike = matchUser.getBase().getWorld().strikeLightningEffect(matchUser.getBase().getLocation()); final LightningStrike strike = matchUser.getBase().getWorld().strikeLightningEffect(matchUser.getBase().getLocation());
if (!matchUser.isGodModeEnabled()) { if (!matchUser.isGodModeEnabled()) {
matchUser.getBase().damage(power, strike); matchUser.getBase().damage(power, strike);
} }
if (ess.getSettings().warnOnSmite()) { if (ess.getSettings().warnOnSmite()) {
matchUser.sendMessage(tl("lightningSmited")); matchUser.sendTl("lightningSmited");
} }
} }

View File

@ -9,8 +9,6 @@ import org.bukkit.Server;
import java.util.*; import java.util.*;
import static com.earth2me.essentials.I18n.tl;
public class Commandlist extends EssentialsCommand { public class Commandlist extends EssentialsCommand {
public Commandlist() { public Commandlist() {
@ -21,15 +19,15 @@ public class Commandlist extends EssentialsCommand {
public void run(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception { public void run(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception {
boolean showHidden = true; boolean showHidden = true;
User user = null; User user = null;
if (sender.isPlayer()) { if (sender.getUser() != null) {
user = ess.getUser(sender.getPlayer()); user = sender.getUser();
showHidden = user.isAuthorized("essentials.list.hidden") || user.canInteractVanished(); showHidden = user.isAuthorized("essentials.list.hidden") || user.canInteractVanished();
} }
sender.sendMessage(PlayerList.listSummary(ess, user, showHidden)); sender.sendMessage(PlayerList.listSummary(ess, sender, showHidden));
final Map<String, List<User>> playerList = PlayerList.getPlayerLists(ess, user, showHidden); final Map<String, List<User>> playerList = PlayerList.getPlayerLists(ess, user, showHidden);
if (args.length > 0) { if (args.length > 0) {
sender.sendMessage(PlayerList.listGroupUsers(ess, playerList, args[0].toLowerCase())); sender.sendMessage(PlayerList.listGroupUsers(ess, sender, playerList, args[0].toLowerCase()));
} else { } else {
sendGroupedList(sender, commandLabel, playerList); sendGroupedList(sender, commandLabel, playerList);
} }
@ -67,9 +65,9 @@ public class Commandlist extends EssentialsCommand {
outputUserList.addAll(matchedList); outputUserList.addAll(matchedList);
int limit = Integer.parseInt(groupValue); int limit = Integer.parseInt(groupValue);
if (matchedList.size() > limit) { if (matchedList.size() > limit) {
sender.sendMessage(PlayerList.outputFormat(oConfigGroup, tl("groupNumber", matchedList.size(), commandLabel, FormatUtil.stripFormat(configGroup)))); sender.sendMessage(PlayerList.outputFormat(sender, oConfigGroup, sender.tl("groupNumber", matchedList.size(), commandLabel, FormatUtil.stripFormat(configGroup))));
} else { } else {
sender.sendMessage(PlayerList.outputFormat(oConfigGroup, PlayerList.listUsers(ess, outputUserList, ", "))); sender.sendMessage(PlayerList.outputFormat(sender, oConfigGroup, PlayerList.listUsers(ess, sender, outputUserList, ", ")));
} }
continue; continue;
} }
@ -82,7 +80,7 @@ public class Commandlist extends EssentialsCommand {
continue; continue;
} }
sender.sendMessage(PlayerList.outputFormat(oConfigGroup, PlayerList.listUsers(ess, outputUserList, ", "))); sender.sendMessage(PlayerList.outputFormat(sender, oConfigGroup, PlayerList.listUsers(ess, sender, outputUserList, ", ")));
} }
Set<String> var = playerList.keySet(); Set<String> var = playerList.keySet();
@ -107,13 +105,13 @@ public class Commandlist extends EssentialsCommand {
String groupName = asterisk.isEmpty() ? users.get(0).getGroup() : onlineGroup; String groupName = asterisk.isEmpty() ? users.get(0).getGroup() : onlineGroup;
if (ess.getPermissionsHandler().getName().equals("ConfigPermissions")) { if (ess.getPermissionsHandler().getName().equals("ConfigPermissions")) {
groupName = tl("connectedPlayers"); groupName = sender.tl("connectedPlayers");
} }
if (users == null || users.isEmpty()) { if (users == null || users.isEmpty()) {
continue; continue;
} }
sender.sendMessage(PlayerList.outputFormat(groupName, PlayerList.listUsers(ess, users, ", "))); sender.sendMessage(PlayerList.outputFormat(sender, groupName, PlayerList.listUsers(ess, sender, users, ", ")));
} }
} }

View File

@ -0,0 +1,83 @@
package com.earth2me.essentials.commands;
import com.earth2me.essentials.CommandSource;
import com.earth2me.essentials.I18n;
import com.earth2me.essentials.User;
import org.bukkit.Server;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
public class Commandlocale extends EssentialsLoopCommand {
public Commandlocale() {
super("locale");
}
@Override
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception {
if (!ess.getSettings().changeLocale()) {
throw new Exception(user.tl("localeChange"));
}
if (args.length < 1) {
throw new NotEnoughArgumentsException();
}
if (args.length > 1 && user.isAuthorized("essentials.locale.others")) {
loopOfflinePlayers(server, user.getSource(), false, true, args[0], new String[]{args[1]});
user.sendTl("localeChanged");
} else {
updatePlayer(server, user.getSource(), user, args);
}
}
@Override
public void run(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception {
if (!ess.getSettings().changeLocale()) {
throw new Exception(sender.tl("localeChange"));
}
if (args.length < 1) {
throw new NotEnoughArgumentsException();
}
loopOfflinePlayers(server, sender, false, true, args[0], new String[]{args[1]});
sender.sendTl("localeChanged");
}
@Override
protected void updatePlayer(final Server server, final CommandSource sender, final User target, final String[] args) throws NotEnoughArgumentsException {
if ("none".equalsIgnoreCase(args[0]) || "default".equalsIgnoreCase(args[0])) {
target.setLocale(null);
target.sendTl("localeNoMore");
return;
}
final Locale locale = I18n.getLocale(args[0]);
if (locale == null) {
throw new NotEnoughArgumentsException(sender.tl("localeUnknown", args[0]));
} else if (locale.equals(target.getLocale())) {
sender.sendTl("localeInUse", target.getLocale().getDisplayName());
} else {
target.setLocale(locale);
target.sendTl("localeSet", locale.getDisplayName());
}
}
@Override
protected List<String> getTabCompleteOptions(final Server server, final User user, final String commandLabel, final String[] args) {
if (args.length == 1 && user.isAuthorized("essentials.locale.others")) {
return getPlayers(server, user);
} else {
return Collections.emptyList();
}
}
@Override
protected List<String> getTabCompleteOptions(final Server server, final CommandSource sender, final String commandLabel, final String[] args) {
if (args.length == 1) {
return getPlayers(server, sender);
} else {
return Collections.emptyList();
}
}
}

View File

@ -14,8 +14,6 @@ import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
import static com.earth2me.essentials.I18n.tl;
public class Commandmail extends EssentialsCommand { public class Commandmail extends EssentialsCommand {
private static int mailsPerMinute = 0; private static int mailsPerMinute = 0;
@ -31,7 +29,7 @@ public class Commandmail extends EssentialsCommand {
if (args.length >= 1 && "read".equalsIgnoreCase(args[0])) { if (args.length >= 1 && "read".equalsIgnoreCase(args[0])) {
final List<String> mail = user.getMails(); final List<String> mail = user.getMails();
if (mail.isEmpty()) { if (mail.isEmpty()) {
user.sendMessage(tl("noMail")); user.sendTl("noMail");
throw new NoChargeException(); throw new NoChargeException();
} }
@ -39,26 +37,26 @@ public class Commandmail extends EssentialsCommand {
final TextPager pager = new TextPager(input); final TextPager pager = new TextPager(input);
pager.showPage(args.length > 1 ? args[1] : null, null, commandLabel + " " + args[0], user.getSource()); pager.showPage(args.length > 1 ? args[1] : null, null, commandLabel + " " + args[0], user.getSource());
user.sendMessage(tl("mailClear")); user.sendTl("mailClear");
return; return;
} }
if (args.length >= 3 && "send".equalsIgnoreCase(args[0])) { if (args.length >= 3 && "send".equalsIgnoreCase(args[0])) {
if (!user.isAuthorized("essentials.mail.send")) { if (!user.isAuthorized("essentials.mail.send")) {
throw new Exception(tl("noPerm", "essentials.mail.send")); throw new Exception(user.tl("noPerm", "essentials.mail.send"));
} }
if (user.isMuted()) { if (user.isMuted()) {
throw new Exception(user.hasMuteReason() ? tl("voiceSilencedReason", user.getMuteReason()) : tl("voiceSilenced")); throw new Exception(user.hasMuteReason() ? user.tl("voiceSilencedReason", user.getMuteReason()) : user.tl("voiceSilenced"));
} }
User u = getPlayer(server, args[1], true, true); User u = getPlayer(server, args[1], true, true);
if (u == null) { if (u == null) {
throw new Exception(tl("playerNeverOnServer", args[1])); throw new Exception(user.tl("playerNeverOnServer", args[1]));
} }
String mail = tl("mailFormat", user.getName(), FormatUtil.formatMessage(user, "essentials.mail", StringUtil.sanitizeString(FormatUtil.stripFormat(getFinalArg(args, 2))))); String mail = user.tl("mailFormat", user.getName(), FormatUtil.formatMessage(user, "essentials.mail", StringUtil.sanitizeString(FormatUtil.stripFormat(getFinalArg(args, 2)))));
if (mail.length() > 1000) { if (mail.length() > 1000) {
throw new Exception(tl("mailTooLong")); throw new Exception(user.tl("mailTooLong"));
} }
if (!u.isIgnoredPlayer(user)) { if (!u.isIgnoredPlayer(user)) {
@ -68,32 +66,32 @@ public class Commandmail extends EssentialsCommand {
} }
mailsPerMinute++; mailsPerMinute++;
if (mailsPerMinute > ess.getSettings().getMailsPerMinute()) { if (mailsPerMinute > ess.getSettings().getMailsPerMinute()) {
throw new Exception(tl("mailDelay", ess.getSettings().getMailsPerMinute())); throw new Exception(user.tl("mailDelay", ess.getSettings().getMailsPerMinute()));
} }
u.addMail(tl("mailMessage", mail)); u.addMail(u.tl("mailMessage", mail));
} }
user.sendMessage(tl("mailSentTo", u.getDisplayName(), u.getName())); user.sendTl("mailSentTo", u.getDisplayName(), u.getName());
user.sendMessage(mail); user.sendMessage(mail);
return; return;
} }
if (args.length > 1 && "sendall".equalsIgnoreCase(args[0])) { if (args.length > 1 && "sendall".equalsIgnoreCase(args[0])) {
if (!user.isAuthorized("essentials.mail.sendall")) { if (!user.isAuthorized("essentials.mail.sendall")) {
throw new Exception(tl("noPerm", "essentials.mail.sendall")); throw new Exception(user.tl("noPerm", "essentials.mail.sendall"));
} }
ess.runTaskAsynchronously(new SendAll(tl("mailFormat", user.getName(), ess.runTaskAsynchronously(new SendAll("mailFormat", user.getName(),
FormatUtil.formatMessage(user, "essentials.mail", StringUtil.sanitizeString(FormatUtil.stripFormat(getFinalArg(args, 1))))))); FormatUtil.formatMessage(user, "essentials.mail", StringUtil.sanitizeString(FormatUtil.stripFormat(getFinalArg(args, 1))))));
user.sendMessage(tl("mailSent")); user.sendTl("mailSent");
return; return;
} }
if (args.length >= 1 && "clear".equalsIgnoreCase(args[0])) { if (args.length >= 1 && "clear".equalsIgnoreCase(args[0])) {
if (user.getMails() == null || user.getMails().isEmpty()) { if (user.getMails() == null || user.getMails().isEmpty()) {
user.sendMessage(tl("noMail")); user.sendTl("noMail");
throw new NoChargeException(); throw new NoChargeException();
} }
user.setMails(null); user.setMails(null);
user.sendMessage(tl("mailCleared")); user.sendTl("mailCleared");
return; return;
} }
throw new NotEnoughArgumentsException(); throw new NotEnoughArgumentsException();
@ -102,29 +100,29 @@ public class Commandmail extends EssentialsCommand {
@Override @Override
protected void run(Server server, CommandSource sender, String commandLabel, String[] args) throws Exception { protected void run(Server server, CommandSource sender, String commandLabel, String[] args) throws Exception {
if (args.length >= 1 && "read".equalsIgnoreCase(args[0])) { if (args.length >= 1 && "read".equalsIgnoreCase(args[0])) {
throw new Exception(tl("onlyPlayers", commandLabel + " read")); throw new Exception(sender.tl("onlyPlayers", commandLabel + " read"));
} else if (args.length >= 1 && "clear".equalsIgnoreCase(args[0])) { } else if (args.length >= 1 && "clear".equalsIgnoreCase(args[0])) {
throw new Exception(tl("onlyPlayers", commandLabel + " clear")); throw new Exception(sender.tl("onlyPlayers", commandLabel + " clear"));
} else if (args.length >= 3 && "send".equalsIgnoreCase(args[0])) { } else if (args.length >= 3 && "send".equalsIgnoreCase(args[0])) {
User u = getPlayer(server, args[1], true, true); User u = getPlayer(server, args[1], true, true);
if (u == null) { if (u == null) {
throw new Exception(tl("playerNeverOnServer", args[1])); throw new Exception(sender.tl("playerNeverOnServer", args[1]));
} }
u.addMail(tl("mailFormat", "Server", FormatUtil.replaceFormat(getFinalArg(args, 2)))); u.addMail(u.tl("mailFormat", "Server", FormatUtil.replaceFormat(getFinalArg(args, 2))));
sender.sendMessage(tl("mailSent")); sender.sendTl("mailSent");
return; return;
} else if (args.length >= 2 && "sendall".equalsIgnoreCase(args[0])) { } else if (args.length >= 2 && "sendall".equalsIgnoreCase(args[0])) {
ess.runTaskAsynchronously(new SendAll(tl("mailFormat", "Server", FormatUtil.replaceFormat(getFinalArg(args, 1))))); ess.runTaskAsynchronously(new SendAll("mailFormat", "Server", FormatUtil.replaceFormat(getFinalArg(args, 1))));
sender.sendMessage(tl("mailSent")); sender.sendTl("mailSent");
return; return;
} else if (args.length >= 2) { } else if (args.length >= 2) {
//allow sending from console without "send" argument, since it's the only thing the console can do //allow sending from console without "send" argument, since it's the only thing the console can do
User u = getPlayer(server, args[0], true, true); User u = getPlayer(server, args[0], true, true);
if (u == null) { if (u == null) {
throw new Exception(tl("playerNeverOnServer", args[0])); throw new Exception(sender.tl("playerNeverOnServer", args[0]));
} }
u.addMail(tl("mailFormat", "Server", FormatUtil.replaceFormat(getFinalArg(args, 1)))); u.addMail(u.tl("mailFormat", "Server", FormatUtil.replaceFormat(getFinalArg(args, 1))));
sender.sendMessage(tl("mailSent")); sender.sendTl("mailSent");
return; return;
} }
throw new NotEnoughArgumentsException(); throw new NotEnoughArgumentsException();
@ -132,10 +130,12 @@ public class Commandmail extends EssentialsCommand {
private class SendAll implements Runnable { private class SendAll implements Runnable {
String message; String string;
Object objects;
public SendAll(String message) { public SendAll(String string, Object... objects) {
this.message = message; this.string = string;
this.objects = objects;
} }
@Override @Override
@ -143,7 +143,7 @@ public class Commandmail extends EssentialsCommand {
for (UUID userid : ess.getUserMap().getAllUniqueUsers()) { for (UUID userid : ess.getUserMap().getAllUniqueUsers()) {
User user = ess.getUserMap().getUser(userid); User user = ess.getUserMap().getUser(userid);
if (user != null) { if (user != null) {
user.addMail(message); user.addMail(user.tl(string, objects));
} }
} }
} }

View File

@ -13,8 +13,6 @@ import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import static com.earth2me.essentials.I18n.tl;
public class Commandme extends EssentialsCommand { public class Commandme extends EssentialsCommand {
public Commandme() { public Commandme() {
@ -24,7 +22,7 @@ public class Commandme extends EssentialsCommand {
@Override @Override
public void run(Server server, User user, String commandLabel, String[] args) throws Exception { public void run(Server server, User user, String commandLabel, String[] args) throws Exception {
if (user.isMuted()) { if (user.isMuted()) {
throw new Exception(user.hasMuteReason() ? tl("voiceSilencedReason", user.getMuteReason()) : tl("voiceSilenced")); throw new Exception(user.hasMuteReason() ? user.tl("voiceSilencedReason", user.getMuteReason()) : user.tl("voiceSilenced"));
} }
if (args.length < 1) { if (args.length < 1) {
@ -36,9 +34,8 @@ public class Commandme extends EssentialsCommand {
user.setDisplayNick(); user.setDisplayNick();
int radius = ess.getSettings().getChatRadius(); int radius = ess.getSettings().getChatRadius();
String toSend = tl("action", user.getDisplayName(), message);
if (radius < 1) { if (radius < 1) {
ess.broadcastMessage(user, toSend); ess.broadcastTl(user, "action", user.getDisplayName(), message);
return; return;
} }
@ -74,11 +71,11 @@ public class Commandme extends EssentialsCommand {
} }
if (outList.size() < 2) { if (outList.size() < 2) {
user.sendMessage(tl("localNoOne")); user.sendTl("localNoOne");
} }
for (Player onlinePlayer : outList) { for (Player onlinePlayer : outList) {
onlinePlayer.sendMessage(toSend); ess.getUser(onlinePlayer).sendTl("action", user.getDisplayName(), message);
} }
} }
@ -91,7 +88,7 @@ public class Commandme extends EssentialsCommand {
String message = getFinalArg(args, 0); String message = getFinalArg(args, 0);
message = FormatUtil.replaceFormat(message); message = FormatUtil.replaceFormat(message);
ess.getServer().broadcastMessage(tl("action", "@", message)); ess.broadcastTl(sender, "action", "@", message);
} }
@Override @Override

View File

@ -6,8 +6,6 @@ import org.bukkit.inventory.ItemStack;
import java.util.Locale; import java.util.Locale;
import static com.earth2me.essentials.I18n.tl;
public class Commandmore extends EssentialsCommand { public class Commandmore extends EssentialsCommand {
public Commandmore() { public Commandmore() {
@ -18,15 +16,15 @@ public class Commandmore extends EssentialsCommand {
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception { public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception {
final ItemStack stack = user.getItemInHand(); final ItemStack stack = user.getItemInHand();
if (stack == null) { if (stack == null) {
throw new Exception(tl("cantSpawnItem", "Air")); throw new Exception(user.tl("cantSpawnItem", "Air"));
} }
if (stack.getAmount() >= ((user.isAuthorized("essentials.oversizedstacks")) ? ess.getSettings().getOversizedStackSize() : stack.getMaxStackSize())) { if (stack.getAmount() >= ((user.isAuthorized("essentials.oversizedstacks")) ? ess.getSettings().getOversizedStackSize() : stack.getMaxStackSize())) {
throw new Exception(tl("fullStack")); throw new Exception(user.tl("fullStack"));
} }
final String itemname = stack.getType().toString().toLowerCase(Locale.ENGLISH).replace("_", ""); final String itemname = stack.getType().toString().toLowerCase(Locale.ENGLISH).replace("_", "");
if (!user.canSpawnItem(stack.getType())) { if (!user.canSpawnItem(stack.getType())) {
throw new Exception(tl("cantSpawnItem", itemname)); throw new Exception(user.tl("cantSpawnItem", itemname));
} }
if (user.isAuthorized("essentials.oversizedstacks")) { if (user.isAuthorized("essentials.oversizedstacks")) {
stack.setAmount(ess.getSettings().getOversizedStackSize()); stack.setAmount(ess.getSettings().getOversizedStackSize());

View File

@ -1,7 +1,5 @@
package com.earth2me.essentials.commands; package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n.tl;
import com.earth2me.essentials.CommandSource; import com.earth2me.essentials.CommandSource;
import com.earth2me.essentials.Console; import com.earth2me.essentials.Console;
import com.earth2me.essentials.User; import com.earth2me.essentials.User;
@ -29,7 +27,7 @@ public class Commandmsg extends EssentialsLoopCommand {
if (sender.isPlayer()) { if (sender.isPlayer()) {
User user = ess.getUser(sender.getPlayer()); User user = ess.getUser(sender.getPlayer());
if (user.isMuted()) { if (user.isMuted()) {
throw new Exception(user.hasMuteReason() ? tl("voiceSilencedReason", user.getMuteReason()) : tl("voiceSilenced")); throw new Exception(user.hasMuteReason() ? user.tl("voiceSilencedReason", user.getMuteReason()) : user.tl("voiceSilenced"));
} }
message = FormatUtil.formatMessage(user, "essentials.msg", message); message = FormatUtil.formatMessage(user, "essentials.msg", message);
canWildcard = user.isAuthorized("essentials.msg.multiple"); canWildcard = user.isAuthorized("essentials.msg.multiple");

View File

@ -4,8 +4,6 @@ import com.earth2me.essentials.CommandSource;
import com.earth2me.essentials.User; import com.earth2me.essentials.User;
import org.bukkit.Server; import org.bukkit.Server;
import static com.earth2me.essentials.I18n.tl;
public class Commandmsgtoggle extends EssentialsToggleCommand { public class Commandmsgtoggle extends EssentialsToggleCommand {
public Commandmsgtoggle() { public Commandmsgtoggle() {
@ -30,9 +28,9 @@ public class Commandmsgtoggle extends EssentialsToggleCommand {
user.setIgnoreMsg(enabled); user.setIgnoreMsg(enabled);
user.sendMessage(!enabled ? tl("msgEnabled") : tl("msgDisabled")); user.sendMessage(!enabled ? user.tl("msgEnabled") : user.tl("msgDisabled"));
if (!sender.isPlayer() || !user.getBase().equals(sender.getPlayer())) { if (!sender.isPlayer() || !user.getBase().equals(sender.getPlayer())) {
sender.sendMessage(!enabled ? tl("msgEnabledFor", user.getDisplayName()) : tl("msgDisabledFor", user.getDisplayName())); sender.sendMessage(!enabled ? user.tl("msgEnabledFor", user.getDisplayName()) : user.tl("msgDisabledFor", user.getDisplayName()));
} }
} }
} }

View File

@ -33,11 +33,11 @@ public class Commandmute extends EssentialsCommand {
} }
if (!user.getBase().isOnline()) { if (!user.getBase().isOnline()) {
if (sender.isPlayer() && !ess.getUser(sender.getPlayer()).isAuthorized("essentials.mute.offline")) { if (sender.isPlayer() && !ess.getUser(sender.getPlayer()).isAuthorized("essentials.mute.offline")) {
throw new Exception(tl("muteExemptOffline")); throw new Exception(sender.tl("muteExemptOffline"));
} }
} else { } else {
if (user.isAuthorized("essentials.mute.exempt") && sender.isPlayer()) { if (user.isAuthorized("essentials.mute.exempt") && sender.isPlayer()) {
throw new Exception(tl("muteExempt")); throw new Exception(sender.tl("muteExempt"));
} }
} }
@ -69,49 +69,50 @@ public class Commandmute extends EssentialsCommand {
} }
user.setMuteTimeout(muteTimestamp); user.setMuteTimeout(muteTimestamp);
final boolean muted = user.getMuted(); final boolean muted = user.getMuted();
String muteTime = DateUtil.formatDateDiff(muteTimestamp); String muteTime = DateUtil.formatDateDiff(sender, muteTimestamp);
if (nomatch) { if (nomatch) {
sender.sendMessage(tl("userUnknown", user.getName())); sender.sendTl("userUnknown", user.getName());
} }
if (muted) { if (muted) {
if (muteTimestamp > 0) { if (muteTimestamp > 0) {
if (!user.hasMuteReason()) { if (!user.hasMuteReason()) {
sender.sendMessage(tl("mutedPlayerFor", user.getDisplayName(), muteTime)); sender.sendTl("mutedPlayerFor", user.getDisplayName(), muteTime);
user.sendMessage(tl("playerMutedFor", muteTime)); user.sendTl("playerMutedFor", muteTime);
} else { } else {
sender.sendMessage(tl("mutedPlayerForReason", user.getDisplayName(), muteTime, user.getMuteReason())); sender.sendTl("mutedPlayerForReason", user.getDisplayName(), muteTime, user.getMuteReason());
user.sendMessage(tl("playerMutedForReason", muteTime, user.getMuteReason())); user.sendTl("playerMutedForReason", muteTime, user.getMuteReason());
} }
} else { } else {
if (!user.hasMuteReason()) { if (!user.hasMuteReason()) {
sender.sendMessage(tl("mutedPlayer", user.getDisplayName())); sender.sendTl("mutedPlayer", user.getDisplayName());
user.sendMessage(tl("playerMuted")); user.sendTl("playerMuted");
} else { } else {
sender.sendMessage(tl("mutedPlayerReason", user.getDisplayName(), user.getMuteReason())); sender.sendTl("mutedPlayerReason", user.getDisplayName(), user.getMuteReason());
user.sendMessage(tl("playerMutedReason", user.getMuteReason())); user.sendTl("playerMutedReason", user.getMuteReason());
} }
} }
final String message;
if (muteTimestamp > 0) { if (muteTimestamp > 0) {
if (!user.hasMuteReason()) { if (!user.hasMuteReason()) {
message = tl("muteNotifyFor", sender.getSender().getName(), user.getName(), muteTime); server.getLogger().log(Level.INFO, tl("muteNotifyFor", sender.getSender().getName(), user.getName(), muteTime));
ess.broadcastTl("essentials.mute.notify", "muteNotifyFor", sender.getSender().getName(), user.getName(), muteTime);
} else { } else {
message = tl("muteNotifyForReason", sender.getSender().getName(), user.getName(), muteTime, user.getMuteReason()); server.getLogger().log(Level.INFO, tl("muteNotifyForReason", sender.getSender().getName(), user.getName(), muteTime, user.getMuteReason()));
ess.broadcastTl("essentials.mute.notify", "muteNotifyForReason", sender.getSender().getName(), user.getName(), muteTime, user.getMuteReason());
} }
} else { } else {
if (!user.hasMuteReason()) { if (!user.hasMuteReason()) {
message = tl("muteNotify", sender.getSender().getName(), user.getName()); server.getLogger().log(Level.INFO, tl("muteNotify", sender.getSender().getName(), user.getName()));
ess.broadcastTl("essentials.mute.notify", "muteNotify", sender.getSender().getName(), user.getName());
} else { } else {
message = tl("muteNotifyReason", sender.getSender().getName(), user.getName(), user.getMuteReason()); server.getLogger().log(Level.INFO, tl("muteNotifyReason", sender.getSender().getName(), user.getName(), user.getMuteReason()));
ess.broadcastTl("essentials.mute.notify", "muteNotifyReason", sender.getSender().getName(), user.getName(), user.getMuteReason());
} }
} }
server.getLogger().log(Level.INFO, message);
ess.broadcastMessage("essentials.mute.notify", message);
} else { } else {
sender.sendMessage(tl("unmutedPlayer", user.getDisplayName())); sender.sendTl("unmutedPlayer", user.getDisplayName());
user.sendMessage(tl("playerUnmuted")); user.sendTl("playerUnmuted");
} }
} }
} }

View File

@ -12,8 +12,6 @@ import java.util.List;
import java.util.PriorityQueue; import java.util.PriorityQueue;
import java.util.Queue; import java.util.Queue;
import static com.earth2me.essentials.I18n.tl;
public class Commandnear extends EssentialsCommand { public class Commandnear extends EssentialsCommand {
public Commandnear() { public Commandnear() {
@ -52,14 +50,14 @@ public class Commandnear extends EssentialsCommand {
radius = Math.abs(radius); radius = Math.abs(radius);
if (radius > maxRadius && !user.isAuthorized("essentials.near.maxexempt")) { if (radius > maxRadius && !user.isAuthorized("essentials.near.maxexempt")) {
user.sendMessage(tl("radiusTooBig", maxRadius)); user.sendTl("radiusTooBig", maxRadius);
radius = maxRadius; radius = maxRadius;
} }
if (otherUser == null || !user.isAuthorized("essentials.near.others")) { if (otherUser == null || !user.isAuthorized("essentials.near.others")) {
otherUser = user; otherUser = user;
} }
user.sendMessage(tl("nearbyPlayers", getLocal(server, otherUser, radius))); user.sendTl("nearbyPlayers", getLocal(server, otherUser, radius));
} }
@Override @Override
@ -75,7 +73,7 @@ public class Commandnear extends EssentialsCommand {
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
} }
} }
sender.sendMessage(tl("nearbyPlayers", getLocal(server, otherUser, radius))); sender.sendTl("nearbyPlayers", getLocal(server, otherUser, radius));
} }
private String getLocal(final Server server, final User user, final long radius) { private String getLocal(final Server server, final User user, final long radius) {
@ -108,8 +106,7 @@ public class Commandnear extends EssentialsCommand {
User nearbyPlayer = nearbyPlayers.poll(); User nearbyPlayer = nearbyPlayers.poll();
output.append(nearbyPlayer.getDisplayName()).append("§f(§4").append((long) nearbyPlayer.getLocation().distance(loc)).append("m§f)"); output.append(nearbyPlayer.getDisplayName()).append("§f(§4").append((long) nearbyPlayer.getLocation().distance(loc)).append("m§f)");
} }
return output.length() > 1 ? output.toString() : user.tl("none");
return output.length() > 1 ? output.toString() : tl("none");
} }
@Override @Override

View File

@ -12,8 +12,6 @@ import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import static com.earth2me.essentials.I18n.tl;
public class Commandnick extends EssentialsLoopCommand { public class Commandnick extends EssentialsLoopCommand {
public Commandnick() { public Commandnick() {
@ -26,15 +24,15 @@ public class Commandnick extends EssentialsLoopCommand {
throw new NotEnoughArgumentsException(); throw new NotEnoughArgumentsException();
} }
if (!ess.getSettings().changeDisplayName()) { if (!ess.getSettings().changeDisplayName()) {
throw new Exception(tl("nickDisplayName")); throw new Exception(user.tl("nickDisplayName"));
} }
if (args.length > 1 && user.isAuthorized("essentials.nick.others")) { if (args.length > 1 && user.isAuthorized("essentials.nick.others")) {
final String[] nickname = formatNickname(user, args[1]).split(" "); final String[] nickname = formatNickname(user.getSource(), user, args[1]).split(" ");
loopOfflinePlayers(server, user.getSource(), false, true, args[0], nickname); loopOfflinePlayers(server, user.getSource(), false, true, args[0], nickname);
user.sendMessage(tl("nickChanged")); user.sendTl("nickChanged");
} else { } else {
final String[] nickname = formatNickname(user, args[0]).split(" "); final String[] nickname = formatNickname(user.getSource(), user, args[0]).split(" ");
updatePlayer(server, user.getSource(), user, nickname); updatePlayer(server, user.getSource(), user, nickname);
} }
} }
@ -45,11 +43,11 @@ public class Commandnick extends EssentialsLoopCommand {
throw new NotEnoughArgumentsException(); throw new NotEnoughArgumentsException();
} }
if (!ess.getSettings().changeDisplayName()) { if (!ess.getSettings().changeDisplayName()) {
throw new Exception(tl("nickDisplayName")); throw new Exception(sender.tl("nickDisplayName"));
} }
final String[] nickname = formatNickname(null, args[1]).split(" "); final String[] nickname = formatNickname(sender, null, args[1]).split(" ");
loopOfflinePlayers(server, sender, false, true, args[0], nickname); loopOfflinePlayers(server, sender, false, true, args[0], nickname);
sender.sendMessage(tl("nickChanged")); sender.sendTl("nickChanged");
} }
@Override @Override
@ -57,34 +55,34 @@ public class Commandnick extends EssentialsLoopCommand {
final String nick = args[0]; final String nick = args[0];
if ("off".equalsIgnoreCase(nick)) { if ("off".equalsIgnoreCase(nick)) {
setNickname(server, sender, target, null); setNickname(server, sender, target, null);
target.sendMessage(tl("nickNoMore")); target.sendTl("nickNoMore");
} else if (target.getName().equalsIgnoreCase(nick)) { } else if (target.getName().equalsIgnoreCase(nick)) {
String oldName = target.getDisplayName(); String oldName = target.getDisplayName();
setNickname(server, sender, target, nick); setNickname(server, sender, target, nick);
if (!target.getDisplayName().equalsIgnoreCase(oldName)) { if (!target.getDisplayName().equalsIgnoreCase(oldName)) {
target.sendMessage(tl("nickNoMore")); target.sendTl("nickNoMore");
} }
target.sendMessage(tl("nickSet", target.getDisplayName())); target.sendTl("nickSet", target.getDisplayName());
} else if (nickInUse(server, target, nick)) { } else if (nickInUse(server, target, nick)) {
throw new NotEnoughArgumentsException(tl("nickInUse")); throw new NotEnoughArgumentsException(sender.tl("nickInUse"));
} else { } else {
setNickname(server, sender, target, nick); setNickname(server, sender, target, nick);
target.sendMessage(tl("nickSet", target.getDisplayName())); target.sendTl("nickSet", target.getDisplayName());
} }
} }
private String formatNickname(final User user, final String nick) throws Exception { private String formatNickname(CommandSource sender, final User user, final String nick) throws Exception {
String newNick = user == null ? FormatUtil.replaceFormat(nick) : FormatUtil.formatString(user, "essentials.nick", nick); String newNick = user == null ? FormatUtil.replaceFormat(nick) : FormatUtil.formatString(user, "essentials.nick", nick);
if (!newNick.matches("^[a-zA-Z_0-9\u00a7]+$") && user != null && !user.isAuthorized("essentials.nick.allowunsafe")) { if (!newNick.matches("^[a-zA-Z_0-9\u00a7]+$") && user != null && !user.isAuthorized("essentials.nick.allowunsafe")) {
throw new Exception(tl("nickNamesAlpha")); throw new Exception(sender.tl("nickNamesAlpha"));
} else if (getNickLength(newNick) > ess.getSettings().getMaxNickLength()) { } else if (getNickLength(newNick) > ess.getSettings().getMaxNickLength()) {
throw new Exception(tl("nickTooLong")); throw new Exception(sender.tl("nickTooLong"));
} else if (FormatUtil.stripFormat(newNick).length() < 1) { } else if (FormatUtil.stripFormat(newNick).length() < 1) {
throw new Exception(tl("nickNamesAlpha")); throw new Exception(sender.tl("nickNamesAlpha"));
} else if (user != null && (user.isAuthorized("essentials.nick.changecolors") && !user.isAuthorized("essentials.nick.changecolors.bypass")) && !FormatUtil.stripFormat(newNick).equals(user.getName())) { } else if (user != null && (user.isAuthorized("essentials.nick.changecolors") && !user.isAuthorized("essentials.nick.changecolors.bypass")) && !FormatUtil.stripFormat(newNick).equals(user.getName())) {
throw new Exception(tl("nickNamesOnlyColorChanges")); throw new Exception(sender.tl("nickNamesOnlyColorChanges"));
} else if (user != null && !user.isAuthorized("essentials.nick.blacklist.bypass") && isNickBanned(newNick)) { } else if (user != null && !user.isAuthorized("essentials.nick.blacklist.bypass") && isNickBanned(newNick)) {
throw new Exception(tl("nickNameBlacklist", nick)); throw new Exception(sender.tl("nickNameBlacklist", nick));
} }
return newNick; return newNick;
} }

View File

@ -12,8 +12,6 @@ import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import static com.earth2me.essentials.I18n.tl;
public class Commandnuke extends EssentialsCommand { public class Commandnuke extends EssentialsCommand {
public Commandnuke() { public Commandnuke() {
@ -38,7 +36,7 @@ public class Commandnuke extends EssentialsCommand {
if (player == null) { if (player == null) {
continue; continue;
} }
player.sendMessage(tl("nuke")); ess.getUser(player).sendTl("nuke");
final Location loc = player.getLocation(); final Location loc = player.getLocation();
final World world = loc.getWorld(); final World world = loc.getWorld();
for (int x = -10; x <= 10; x += 5) { for (int x = -10; x <= 10; x += 5) {

View File

@ -15,8 +15,6 @@ import java.math.BigDecimal;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import static com.earth2me.essentials.I18n.tl;
public class Commandpay extends EssentialsLoopCommand { public class Commandpay extends EssentialsLoopCommand {
BigDecimal amount; BigDecimal amount;
@ -34,7 +32,7 @@ public class Commandpay extends EssentialsLoopCommand {
} }
if (args[1].contains("-")) { if (args[1].contains("-")) {
throw new Exception(tl("payMustBePositive")); throw new Exception(user.tl("payMustBePositive"));
} }
String stringAmount = args[1].replaceAll("[^0-9\\.]", ""); String stringAmount = args[1].replaceAll("[^0-9\\.]", "");
@ -45,12 +43,12 @@ public class Commandpay extends EssentialsLoopCommand {
amount = new BigDecimal(stringAmount); amount = new BigDecimal(stringAmount);
if (amount.compareTo(ess.getSettings().getMinimumPayAmount()) < 0) { // Check if amount is less than minimum-pay-amount if (amount.compareTo(ess.getSettings().getMinimumPayAmount()) < 0) { // Check if amount is less than minimum-pay-amount
throw new Exception(tl("minimumPayAmount", NumberUtil.displayCurrencyExactly(ess.getSettings().getMinimumPayAmount(), ess))); throw new Exception(user.tl("minimumPayAmount", NumberUtil.displayCurrencyExactly(ess.getSettings().getMinimumPayAmount(), ess)));
} }
loopOnlinePlayers(server, user.getSource(), false, user.isAuthorized("essentials.pay.multiple"), args[0], args); loopOnlinePlayers(server, user.getSource(), false, user.isAuthorized("essentials.pay.multiple"), args[0], args);
if (informToConfirm) { if (informToConfirm) {
String cmd = "/" + commandLabel + " " + StringUtil.joinList(" ", (Object[]) args); String cmd = "/" + commandLabel + " " + StringUtil.joinList(" ", (Object[]) args);
user.sendMessage(tl("confirmPayment", NumberUtil.displayCurrency(amount, ess), cmd)); user.sendTl("confirmPayment", NumberUtil.displayCurrency(amount, ess), cmd);
} }
} }
@ -59,7 +57,7 @@ public class Commandpay extends EssentialsLoopCommand {
User user = ess.getUser(sender.getPlayer()); User user = ess.getUser(sender.getPlayer());
try { try {
if (!player.isAcceptingPay()) { if (!player.isAcceptingPay()) {
sender.sendMessage(tl("notAcceptingPay", player.getDisplayName())); sender.sendTl("notAcceptingPay", player.getDisplayName());
return; return;
} }
if (user.isPromptingPayConfirm() && !amount.equals(user.getConfirmingPayments().get(player))) { // checks if exists and if command needs to be repeated. if (user.isPromptingPayConfirm() && !amount.equals(user.getConfirmingPayments().get(player))) { // checks if exists and if command needs to be repeated.
@ -77,7 +75,7 @@ public class Commandpay extends EssentialsLoopCommand {
user.getConfirmingPayments().remove(player); user.getConfirmingPayments().remove(player);
Trade.log("Command", "Pay", "Player", user.getName(), new Trade(amount, ess), player.getName(), new Trade(amount, ess), user.getLocation(), ess); Trade.log("Command", "Pay", "Player", user.getName(), new Trade(amount, ess), player.getName(), new Trade(amount, ess), user.getLocation(), ess);
} catch (MaxMoneyException ex) { } catch (MaxMoneyException ex) {
sender.sendMessage(tl("maxMoney")); sender.sendTl("maxMoney");
try { try {
user.setMoney(user.getMoney().add(amount)); user.setMoney(user.getMoney().add(amount));
} catch (MaxMoneyException ignored) { } catch (MaxMoneyException ignored) {

View File

@ -1,7 +1,5 @@
package com.earth2me.essentials.commands; package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n.tl;
import com.earth2me.essentials.User; import com.earth2me.essentials.User;
import org.bukkit.Server; import org.bukkit.Server;
@ -22,9 +20,9 @@ public class Commandpayconfirmtoggle extends EssentialsCommand {
} }
user.setPromptingPayConfirm(confirmingPay); user.setPromptingPayConfirm(confirmingPay);
if (confirmingPay) { if (confirmingPay) {
user.sendMessage(tl("payConfirmToggleOn")); user.sendTl("payConfirmToggleOn");
} else { } else {
user.sendMessage(tl("payConfirmToggleOff")); user.sendTl("payConfirmToggleOff");
} }
user.getConfirmingPayments().clear(); // Clear any outstanding confirmations. user.getConfirmingPayments().clear(); // Clear any outstanding confirmations.
} }

View File

@ -1,8 +1,5 @@
package com.earth2me.essentials.commands; package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n.tl;
import com.earth2me.essentials.I18n;
import com.earth2me.essentials.User; import com.earth2me.essentials.User;
import org.bukkit.Server; import org.bukkit.Server;
@ -23,9 +20,9 @@ public class Commandpaytoggle extends EssentialsCommand {
} }
user.setAcceptingPay(acceptingPay); user.setAcceptingPay(acceptingPay);
if (acceptingPay) { if (acceptingPay) {
user.sendMessage(tl("payToggleOn")); user.sendTl("payToggleOn");
} else { } else {
user.sendMessage(tl("payToggleOff")); user.sendTl("payToggleOff");
} }
} }
} }

View File

@ -4,8 +4,6 @@ import com.earth2me.essentials.CommandSource;
import com.earth2me.essentials.utils.FormatUtil; import com.earth2me.essentials.utils.FormatUtil;
import org.bukkit.Server; import org.bukkit.Server;
import static com.earth2me.essentials.I18n.tl;
// This command can be used to echo messages to the users screen, mostly useless but also an #EasterEgg // This command can be used to echo messages to the users screen, mostly useless but also an #EasterEgg
public class Commandping extends EssentialsCommand { public class Commandping extends EssentialsCommand {
public Commandping() { public Commandping() {
@ -16,7 +14,7 @@ public class Commandping extends EssentialsCommand {
public void run(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception { public void run(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception {
if (args.length < 1) { if (args.length < 1) {
sender.sendMessage(tl("pong")); sender.sendTl("pong");
} else { } else {
sender.sendMessage(FormatUtil.replaceFormat(getFinalArg(args, 0))); sender.sendMessage(FormatUtil.replaceFormat(getFinalArg(args, 0)));
} }

View File

@ -1,6 +1,5 @@
package com.earth2me.essentials.commands; package com.earth2me.essentials.commands;
import org.bukkit.DyeColor;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.earth2me.essentials.MetaItemStack; import com.earth2me.essentials.MetaItemStack;
@ -11,7 +10,6 @@ import org.bukkit.Material;
import org.bukkit.Server; import org.bukkit.Server;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.PotionMeta; import org.bukkit.inventory.meta.PotionMeta;
import org.bukkit.potion.PotionData;
import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionEffectType;
@ -22,8 +20,6 @@ import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.TreeSet; import java.util.TreeSet;
import static com.earth2me.essentials.I18n.tl;
import net.ess3.nms.refl.ReflUtil; import net.ess3.nms.refl.ReflUtil;
@ -44,7 +40,7 @@ public class Commandpotion extends EssentialsCommand {
potionslist.add(entry.getKey()); potionslist.add(entry.getKey());
} }
} }
throw new NotEnoughArgumentsException(tl("potions", StringUtil.joinList(potionslist.toArray()))); throw new NotEnoughArgumentsException(user.tl("potions", StringUtil.joinList(potionslist.toArray())));
} }
boolean holdingPotion = stack.getType() == Material.POTION; boolean holdingPotion = stack.getType() == Material.POTION;
@ -72,14 +68,14 @@ public class Commandpotion extends EssentialsCommand {
pmeta = (PotionMeta) mStack.getItemStack().getItemMeta(); pmeta = (PotionMeta) mStack.getItemStack().getItemMeta();
stack.setItemMeta(pmeta); stack.setItemMeta(pmeta);
} else { } else {
user.sendMessage(tl("invalidPotion")); user.sendTl("invalidPotion");
throw new NotEnoughArgumentsException(); throw new NotEnoughArgumentsException();
} }
} }
} }
} else { } else {
throw new Exception(tl("holdPotion")); throw new Exception(user.tl("holdPotion"));
} }
} }

View File

@ -13,8 +13,6 @@ import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import static com.earth2me.essentials.I18n.tl;
public class Commandpowertool extends EssentialsCommand { public class Commandpowertool extends EssentialsCommand {
public Commandpowertool() { public Commandpowertool() {
@ -45,12 +43,12 @@ public class Commandpowertool extends EssentialsCommand {
// check to see if this is a clear all command // check to see if this is a clear all command
if (command != null && command.equalsIgnoreCase("d:")) { if (command != null && command.equalsIgnoreCase("d:")) {
user.clearAllPowertools(); user.clearAllPowertools();
sender.sendMessage(tl("powerToolClearAll")); sender.sendTl("powerToolClearAll");
return; return;
} }
if (itemStack == null || itemStack.getType() == Material.AIR) { if (itemStack == null || itemStack.getType() == Material.AIR) {
throw new Exception(tl("powerToolAir")); throw new Exception(user.tl("powerToolAir"));
} }
final String itemName = itemStack.getType().toString().toLowerCase(Locale.ENGLISH).replaceAll("_", " "); final String itemName = itemStack.getType().toString().toLowerCase(Locale.ENGLISH).replaceAll("_", " ");
@ -58,28 +56,28 @@ public class Commandpowertool extends EssentialsCommand {
if (command != null && !command.isEmpty()) { if (command != null && !command.isEmpty()) {
if (command.equalsIgnoreCase("l:")) { if (command.equalsIgnoreCase("l:")) {
if (powertools == null || powertools.isEmpty()) { if (powertools == null || powertools.isEmpty()) {
throw new Exception(tl("powerToolListEmpty", itemName)); throw new Exception(user.tl("powerToolListEmpty", itemName));
} else { } else {
sender.sendMessage(tl("powerToolList", StringUtil.joinList(powertools), itemName)); sender.sendTl("powerToolList", StringUtil.joinList(powertools), itemName);
} }
throw new NoChargeException(); throw new NoChargeException();
} }
if (command.startsWith("r:")) { if (command.startsWith("r:")) {
command = command.substring(2); command = command.substring(2);
if (!powertools.contains(command)) { if (!powertools.contains(command)) {
throw new Exception(tl("powerToolNoSuchCommandAssigned", command, itemName)); throw new Exception(user.tl("powerToolNoSuchCommandAssigned", command, itemName));
} }
powertools.remove(command); powertools.remove(command);
sender.sendMessage(tl("powerToolRemove", command, itemName)); sender.sendTl("powerToolRemove", command, itemName);
} else { } else {
if (command.startsWith("a:")) { if (command.startsWith("a:")) {
if (sender.isPlayer() && !ess.getUser(sender.getPlayer()).isAuthorized("essentials.powertool.append")) { if (sender.isPlayer() && !ess.getUser(sender.getPlayer()).isAuthorized("essentials.powertool.append")) {
throw new Exception(tl("noPerm", "essentials.powertool.append")); throw new Exception(user.tl("noPerm", "essentials.powertool.append"));
} }
command = command.substring(2); command = command.substring(2);
if (powertools.contains(command)) { if (powertools.contains(command)) {
throw new Exception(tl("powerToolAlreadySet", command, itemName)); throw new Exception(user.tl("powerToolAlreadySet", command, itemName));
} }
} else if (powertools != null && !powertools.isEmpty()) { } else if (powertools != null && !powertools.isEmpty()) {
// Replace all commands with this one // Replace all commands with this one
@ -89,18 +87,18 @@ public class Commandpowertool extends EssentialsCommand {
} }
powertools.add(command); powertools.add(command);
sender.sendMessage(tl("powerToolAttach", StringUtil.joinList(powertools), itemName)); sender.sendTl("powerToolAttach", StringUtil.joinList(powertools), itemName);
} }
} else { } else {
if (powertools != null) { if (powertools != null) {
powertools.clear(); powertools.clear();
} }
sender.sendMessage(tl("powerToolRemoveAll", itemName)); sender.sendTl("powerToolRemoveAll", itemName);
} }
if (!user.arePowerToolsEnabled()) { if (!user.arePowerToolsEnabled()) {
user.setPowerToolsEnabled(true); user.setPowerToolsEnabled(true);
user.sendMessage(tl("powerToolsEnabled")); user.sendTl("powerToolsEnabled");
} }
user.setPowertool(itemStack, powertools); user.setPowertool(itemStack, powertools);
} }

View File

@ -3,8 +3,6 @@ package com.earth2me.essentials.commands;
import com.earth2me.essentials.User; import com.earth2me.essentials.User;
import org.bukkit.Server; import org.bukkit.Server;
import static com.earth2me.essentials.I18n.tl;
public class Commandpowertooltoggle extends EssentialsCommand { public class Commandpowertooltoggle extends EssentialsCommand {
public Commandpowertooltoggle() { public Commandpowertooltoggle() {
@ -14,9 +12,9 @@ public class Commandpowertooltoggle extends EssentialsCommand {
@Override @Override
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception { 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(tl("noPowerTools")); user.sendTl("noPowerTools");
return; return;
} }
user.sendMessage(user.togglePowerToolsEnabled() ? tl("powerToolsEnabled") : tl("powerToolsDisabled")); user.sendMessage(user.togglePowerToolsEnabled() ? user.tl("powerToolsEnabled") : user.tl("powerToolsDisabled"));
} }
} }

View File

@ -11,8 +11,6 @@ import org.bukkit.entity.Player;
import java.util.*; import java.util.*;
import static com.earth2me.essentials.I18n.tl;
public class Commandptime extends EssentialsCommand { public class Commandptime extends EssentialsCommand {
private static final Set<String> getAliases = new HashSet<>(); private static final Set<String> getAliases = new HashSet<>();
@ -46,7 +44,7 @@ public class Commandptime extends EssentialsCommand {
if (sender.isPlayer()) { if (sender.isPlayer()) {
User user = ess.getUser(sender.getPlayer()); User user = ess.getUser(sender.getPlayer());
if (user != null && (!users.contains(user) || users.size() > 1) && !user.isAuthorized("essentials.ptime.others")) { if (user != null && (!users.contains(user) || users.size() > 1) && !user.isAuthorized("essentials.ptime.others")) {
user.sendMessage(tl("pTimeOthersPermission")); user.sendTl("pTimeOthersPermission");
return; return;
} }
} }
@ -81,18 +79,18 @@ public class Commandptime extends EssentialsCommand {
*/ */
private void getUsersTime(final CommandSource sender, final Collection<User> users) { private void getUsersTime(final CommandSource sender, final Collection<User> users) {
if (users.size() > 1) { if (users.size() > 1) {
sender.sendMessage(tl("pTimePlayers")); sender.sendTl("pTimePlayers");
} }
for (User user : users) { for (User user : users) {
if (user.getBase().getPlayerTimeOffset() == 0) { if (user.getBase().getPlayerTimeOffset() == 0) {
sender.sendMessage(tl("pTimeNormal", user.getName())); sender.sendTl("pTimeNormal", user.getName());
} else { } else {
String time = DescParseTickFormat.format(user.getBase().getPlayerTime()); String time = DescParseTickFormat.format(user.getBase().getPlayerTime());
if (!user.getBase().isPlayerTimeRelative()) { if (!user.getBase().isPlayerTimeRelative()) {
sender.sendMessage(tl("pTimeCurrentFixed", user.getName(), time)); sender.sendTl("pTimeCurrentFixed", user.getName(), time);
} else { } else {
sender.sendMessage(tl("pTimeCurrent", user.getName(), time)); sender.sendTl("pTimeCurrent", user.getName(), time);
} }
} }
} }
@ -133,13 +131,13 @@ public class Commandptime extends EssentialsCommand {
// Inform the sender of the change // Inform the sender of the change
if (ticks == null) { if (ticks == null) {
sender.sendMessage(tl("pTimeReset", msg.toString())); sender.sendTl("pTimeReset", msg.toString());
} else { } else {
String time = DescParseTickFormat.format(ticks); String time = DescParseTickFormat.format(ticks);
if (!relative) { if (!relative) {
sender.sendMessage(tl("pTimeSetFixed", time, msg.toString())); sender.sendTl("pTimeSetFixed", time, msg.toString());
} else { } else {
sender.sendMessage(tl("pTimeSet", time, msg.toString())); sender.sendTl("pTimeSet", time, msg.toString());
} }
} }
} }

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