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>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>net.ess3</groupId>
<artifactId>LocaleApiProvider</artifactId>
<version>2.16.1</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>

View File

@ -3,14 +3,22 @@ package com.earth2me.essentials;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import static com.earth2me.essentials.I18n.tl;
public class CommandSource {
protected CommandSender sender;
protected User user = null;
public CommandSource(final CommandSender base) {
this.sender = base;
}
public CommandSource(final User user) {
this.sender = user.getBase();
this.user = user;
}
public final CommandSender getSender() {
return sender;
}
@ -30,10 +38,29 @@ public class CommandSource {
return this.sender = base;
}
public void sendMessage(String message) {
if (!message.isEmpty()) {
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.command.CommandSender;
import java.util.Locale;
public final class Console implements IMessageRecipient {
public static final String NAME = "Console";
@ -54,11 +56,11 @@ public final class Console implements IMessageRecipient {
@Override public boolean isReachable() {
return true;
}
/* ================================
* >> DELEGATE METHODS
* ================================ */
@Override public MessageResponse sendMessage(IMessageRecipient recipient, String message) {
return this.messageRecipient.sendMessage(recipient, message);
}
@ -74,4 +76,8 @@ public final class Console implements IMessageRecipient {
@Override public void setReplyRecipient(IMessageRecipient 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.IEssentials;
import net.ess3.api.ISettings;
import net.ess3.nms.PlayerLocaleProvider;
import net.ess3.nms.PotionMetaProvider;
import net.ess3.nms.SpawnEggProvider;
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.LegacySpawnEggProvider;
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.updatedmeta.BasePotionDataProvider;
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 SpawnEggProvider spawnEggProvider;
private transient PotionMetaProvider potionMetaProvider;
private transient PlayerLocaleProvider playerLocaleProvider;
private transient Kits kits;
public Essentials() {
@ -246,6 +250,12 @@ public class Essentials extends JavaPlugin implements net.ess3.api.IEssentials {
BasePotionDataProvider.class,
LegacyPotionMetaProvider.class
), "potion meta").getProvider();
playerLocaleProvider = new ProviderFactory<>(getLogger(),
Arrays.asList(
ApiPlayerLocaleProvider.class,
ReflPlayerLocaleProvider.class
)
, "player locale").getProvider();
execTimer.mark("Init(Providers)");
reload();
@ -343,7 +353,7 @@ public class Essentials extends JavaPlugin implements net.ess3.api.IEssentials {
for (User user : getOnlineUsers()) {
if (user.isVanished()) {
user.setVanished(false);
user.sendMessage(tl("unvanishedReload"));
user.sendTl("unvanishedReload");
}
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
User user = null;
if (cSender instanceof Player) {
user = getUser((Player) cSender);
}
// Note: The tab completer is always a player, even when tab-completing in a command block
User user = null;
if (cSender instanceof Player) {
user = getUser((Player) cSender);
}
Locale locale = user != null ? user.getApplicableLocale() : getI18n().getCurrentLocale();
try {
CommandSource sender = new CommandSource(cSender);
// Check for disabled commands
@ -420,8 +432,8 @@ public class Essentials extends JavaPlugin implements net.ess3.api.IEssentials {
cmd.setEssentials(this);
cmd.setEssentialsModule(module);
} catch (Exception ex) {
sender.sendMessage(tl("commandNotLoaded", commandLabel));
LOGGER.log(Level.SEVERE, tl("commandNotLoaded", commandLabel), ex);
sender.sendMessage(tl(locale, "commandNotLoaded", commandLabel));
LOGGER.log(Level.SEVERE, tl(locale, "commandNotLoaded", commandLabel), ex);
return Collections.emptyList();
}
@ -444,11 +456,11 @@ public class Essentials extends JavaPlugin implements net.ess3.api.IEssentials {
} catch (Exception ex) {
showError(sender, ex, commandLabel);
// 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();
}
} catch (Throwable ex) {
LOGGER.log(Level.SEVERE, tl("commandFailed", commandLabel), ex);
LOGGER.log(Level.SEVERE, tl(locale, "commandFailed", commandLabel), ex);
return Collections.emptyList();
}
}
@ -476,11 +488,12 @@ public class Essentials extends JavaPlugin implements net.ess3.api.IEssentials {
}
try {
User user = null;
Block bSenderBlock = null;
User user = null;
CommandSource sender = new CommandSource(cSender);
if (cSender instanceof Player) {
user = getUser((Player) cSender);
sender.setUser(user);
} else if (cSender instanceof BlockCommandSender) {
BlockCommandSender bsender = (BlockCommandSender) cSender;
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)});
}
CommandSource sender = new CommandSource(cSender);
// New mail notification
if (user != null && !getSettings().isCommandDisabled("mail") && !command.getName().equals("mail") && user.isAuthorized("essentials.mail")) {
user.notifyOfMail();
@ -518,7 +529,7 @@ public class Essentials extends JavaPlugin implements net.ess3.api.IEssentials {
cmd.setEssentials(this);
cmd.setEssentialsModule(module);
} catch (Exception ex) {
sender.sendMessage(tl("commandNotLoaded", commandLabel));
sender.sendTl("commandNotLoaded", commandLabel);
LOGGER.log(Level.SEVERE, tl("commandNotLoaded", commandLabel), ex);
return true;
}
@ -526,15 +537,15 @@ public class Essentials extends JavaPlugin implements net.ess3.api.IEssentials {
// Check authorization
if (user != null && !user.isAuthorized(cmd, permissionPrefix)) {
LOGGER.log(Level.INFO, tl("deniedAccessCommand", user.getName()));
user.sendMessage(tl("noAccessCommand"));
sender.sendTl("noAccessCommand");
return true;
}
if (user != null && user.isJailed() && !user.isAuthorized(cmd, "essentials.jail.allow.")) {
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 {
user.sendMessage(tl("jailMessage"));
sender.sendTl("jailMessage");
}
return true;
}
@ -588,7 +599,7 @@ public class Essentials extends JavaPlugin implements net.ess3.api.IEssentials {
@Override
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()) {
LOGGER.log(Level.INFO, tl("errorCallingCommand", commandLabel), exception);
}
@ -767,20 +778,59 @@ public class Essentials extends JavaPlugin implements net.ess3.api.IEssentials {
final Collection<Player> players = getOnlinePlayers();
for (Player player : players) {
final User user = getUser(player);
if ((permission == null && (sender == null || !user.isIgnoredPlayer(sender))) || (permission != null && user.isAuthorized(permission))) {
if (keywords) {
broadcast = new KeywordReplacer(broadcast, new CommandSource(player), this, false);
}
for (String messageText : broadcast.getLines()) {
user.sendMessage(messageText);
}
}
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();
for (Player player : players) {
final User user = getUser(player);
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) {
broadcast = new KeywordReplacer(broadcast, user.getSource(), this, false);
}
for (String messageText : broadcast.getLines()) {
user.sendMessage(messageText);
}
}
}
@Override
public BukkitTask runTaskAsynchronously(final Runnable run) {
return this.getScheduler().runTaskAsynchronously(this, run);
@ -897,6 +947,11 @@ public class Essentials extends JavaPlugin implements net.ess3.api.IEssentials {
return potionMetaProvider;
}
@Override
public PlayerLocaleProvider getPlayerLocaleProvider() {
return playerLocaleProvider;
}
private static void addDefaultBackPermissionsToWorld(World w) {
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());
if (user.isAuthorized("essentials.back.ondeath") && !ess.getSettings().isCommandDisabled("back")) {
user.setLastLocation();
user.sendMessage(tl("backAfterDeath"));
user.sendMessage(user.tl( "backAfterDeath"));
}
if (!ess.getSettings().areDeathMessagesEnabled()) {
event.setDeathMessage("");

View File

@ -36,7 +36,7 @@ import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.regex.Pattern;
import static com.earth2me.essentials.I18n.tl;
import static com.earth2me.essentials.I18n.capitalCase;
public class EssentialsPlayerListener implements Listener {
@ -78,9 +78,9 @@ public class EssentialsPlayerListener implements Listener {
if (user.isMuted()) {
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 {
final Iterator<Player> it = event.getRecipients().iterator();
@ -283,7 +283,7 @@ public class EssentialsPlayerListener implements Listener {
final List<String> mail = user.getMails();
if (mail.isEmpty()) {
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 {
user.notifyOfMail();
@ -296,7 +296,7 @@ public class EssentialsPlayerListener implements Listener {
user.getBase().setAllowFlight(true);
user.getBase().setFlying(true);
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:
BanEntry banEntry = ess.getServer().getBanList(BanList.Type.NAME).getBanEntry(event.getPlayer().getName());
if (banEntry != null) {
final User buser = ess.getUser(event.getPlayer());
Date banExpiry = banEntry.getExpiration();
if (banExpiry != null) {
String expiry = DateUtil.formatDateDiff(banExpiry.getTime());
event.setKickMessage(tl("tempbanJoin", expiry, banEntry.getReason()));
event.setKickMessage(buser.tl("tempbanJoin", expiry, banEntry.getReason()));
} else {
event.setKickMessage(tl("banJoin", banEntry.getReason()));
event.setKickMessage(buser.tl("banJoin", banEntry.getReason()));
}
} else {
banEntry = ess.getServer().getBanList(BanList.Type.IP).getBanEntry(event.getAddress().getHostAddress());
if (banEntry != null) {
event.setKickMessage(tl("banIpJoin", banEntry.getReason()));
final User buser = ess.getUser(event.getPlayer());
event.setKickMessage(buser.tl("banIpJoin", banEntry.getReason()));
}
}
break;
@ -407,7 +409,7 @@ public class EssentialsPlayerListener implements Listener {
event.allow();
return;
}
event.disallow(Result.KICK_FULL, tl("serverFull"));
event.disallow(Result.KICK_FULL, kfuser.tl("serverFull"));
break;
default:
break;
@ -469,9 +471,9 @@ public class EssentialsPlayerListener implements Listener {
for (User spyer : ess.getOnlineUsers()) {
if (spyer.isSocialSpyEnabled() && !player.equals(spyer.getBase())) {
if (user.isMuted() && ess.getSettings().getSocialSpyListenMutedPlayers()) {
spyer.sendMessage(tl("socialSpyMutedPrefix") + player.getDisplayName() + ": " + event.getMessage());
spyer.sendMessage(spyer.tl( "socialSpyMutedPrefix") + player.getDisplayName() + ": " + event.getMessage());
} 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);
player.sendMessage(tl("voiceSilenced"));
LOGGER.info(tl("mutedUserSpeaks", player.getName(), event.getMessage()));
user.sendTl("voiceSilenced");
LOGGER.info(user.tl("mutedUserSpeaks", player.getName(), event.getMessage()));
return;
}
@ -498,7 +501,6 @@ public class EssentialsPlayerListener implements Listener {
broadcast = false;
}
}
final User user = ess.getUser(player);
if (update) {
user.updateActivityOnInteract(broadcast);
}
@ -523,8 +525,8 @@ public class EssentialsPlayerListener implements Listener {
} else if (entry.getKey().matcher(fullCommand).matches()) {
// User's current cooldown hasn't expired, inform and terminate cooldown code.
if (entry.getValue() > System.currentTimeMillis()) {
String commandCooldownTime = DateUtil.formatDateDiff(entry.getValue());
user.sendMessage(tl("commandCooldown", commandCooldownTime));
String commandCooldownTime = DateUtil.formatDateDiff(user.getSource(), entry.getValue());
user.sendTl("commandCooldown", commandCooldownTime);
cooldownFound = true;
event.setCancelled(true);
break;
@ -583,11 +585,11 @@ public class EssentialsPlayerListener implements Listener {
if (ess.getSettings().getNoGodWorlds().contains(newWorld) && user.isGodModeEnabledRaw()) {
// 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()
user.sendMessage(tl("noGodWorldWarning"));
user.sendTl("noGodWorldWarning");
}
if (!user.getWorld().getName().equals(newWorld)) {
user.sendMessage(tl("currentWorld", newWorld));
user.sendTl("currentWorld", newWorld);
}
if (user.isVanished()) {
user.setVanished(user.isAuthorized("essentials.vanish"));
@ -604,7 +606,7 @@ public class EssentialsPlayerListener implements Listener {
User player = ess.getUser(event.getPlayer());
if (player.isAuthorized("essentials.sethome.bed") && player.getWorld().getEnvironment().equals(World.Environment.NORMAL)) {
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;

View File

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

View File

@ -49,6 +49,14 @@ public interface IEssentials extends Plugin {
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();
BukkitScheduler getScheduler();

View File

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

View File

@ -10,6 +10,7 @@ import org.bukkit.entity.Player;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.regex.Pattern;
@ -106,6 +107,10 @@ public interface IUser {
void sendMessage(String message);
void sendTl(String string, Object... objects);
String tl(String string, Object... objects);
/*
* UserData
*/
@ -150,13 +155,13 @@ public interface IUser {
Map<String, Object> getConfigMap();
Map<String, Object> getConfigMap(String node);
Map<Pattern, Long> getCommandCooldowns();
Date getCommandCooldownExpiry(String label);
void addCommandCooldown(Pattern pattern, Date expiresAt, boolean save);
boolean clearCommandCooldown(Pattern pattern);
/*
@ -171,19 +176,19 @@ public interface IUser {
String getAfkMessage();
void setAfkMessage(final String message);
long getAfkSince();
boolean isAcceptingPay();
void setAcceptingPay(boolean acceptingPay);
boolean isPromptingPayConfirm();
void setPromptingPayConfirm(boolean prompt);
boolean isPromptingClearConfirm();
void setPromptingClearConfirm(boolean prompt);
boolean isLastMessageReplyRecipient();
@ -191,4 +196,10 @@ public interface IUser {
void setLastMessageReplyRecipient(boolean enabled);
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()));
}
}
user.sendMessage(tl("jailMessage"));
user.sendTl("jailMessage");
}
@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()));
}
}
user.sendMessage(tl("jailMessage"));
user.sendTl("jailMessage");
}
}
}

View File

@ -42,7 +42,7 @@ public class Kit {
public void checkPerms(final User user) throws Exception {
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) {
return;
} else if (nextUse < 0L) {
user.sendMessage(tl("kitOnce"));
user.sendTl("kitOnce");
throw new NoChargeException();
} else {
user.sendMessage(tl("kitTimed", DateUtil.formatDateDiff(nextUse)));
user.sendTl("kitTimed", DateUtil.formatDateDiff(user.getSource(), nextUse));
throw new NoChargeException();
}
}
@ -85,7 +85,7 @@ public class Kit {
// Make sure delay is valid
delay = kit.containsKey("delay") ? ((Number) kit.get("delay")).doubleValue() : 0.0d;
} catch (Exception e) {
throw new Exception(tl("kitError2"));
throw new Exception(user.tl( "kitError2"));
}
// When was the last kit used?
@ -203,12 +203,12 @@ public class Kit {
}
user.getBase().updateInventory();
if (spew) {
user.sendMessage(tl("kitInvFull"));
user.sendTl("kitInvFull");
}
} catch (Exception e) {
user.getBase().updateInventory();
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);
BigDecimal costPrice = new Trade("kit-" + kitItem.toLowerCase(Locale.ENGLISH), ess).getCommandCost(user);
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);
@ -105,7 +105,7 @@ public class Kits implements IConf {
if (nextUse == -1 && ess.getSettings().isSkippingUsedOneTimeKitsFromKitList()) {
continue;
} else if (nextUse != 0) {
name = tl("kitDelay", name);
name = user.tl( "kitDelay", name);
}
list.append(" ").append(name).append(cost);
@ -113,7 +113,7 @@ public class Kits implements IConf {
}
return list.toString().trim();
} 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.nms.refl.ReflUtil;
import org.apache.commons.lang.ArrayUtils;
import org.bukkit.Bukkit;
import org.bukkit.Color;
import org.bukkit.DyeColor;
import org.bukkit.FireworkEffect;
@ -127,7 +127,7 @@ public class MetaItemStack {
ess.getLogger().log(Level.INFO, "Itemstack is invalid", npe);
}
} catch (NoSuchMethodError nsme) {
throw new Exception(tl("noMetaJson"), nsme);
throw new Exception(sender.tl("noMetaJson"), nsme);
} catch (Throwable throwable) {
throw new Exception(throwable.getMessage(), throwable);
}
@ -137,13 +137,13 @@ public class MetaItemStack {
}
if (validFirework) {
if (!hasMetaPermission(sender, "firework", true, true, ess)) {
throw new Exception(tl("noMetaFirework"));
throw new Exception(sender.tl("noMetaFirework"));
}
FireworkEffect effect = builder.build();
FireworkMeta fmeta = (FireworkMeta) stack.getItemMeta();
fmeta.addEffect(effect);
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);
}
@ -181,7 +181,7 @@ public class MetaItemStack {
meta.setOwningPlayer(ess.getServer().getOfflinePlayer(owner));
stack.setItemMeta(meta);
} 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))) {
final BookMeta meta = (BookMeta) stack.getItemMeta();
@ -207,7 +207,7 @@ public class MetaItemStack {
meta.setPower(power > 3 ? 4 : power);
stack.setItemMeta(meta);
} 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())) {
//WARNING - Meta for fireworks will be ignored after this point.
addFireworkMeta(sender, false, string, ess);
@ -244,17 +244,25 @@ public class MetaItemStack {
meta.setColor(Color.fromRGB(red, green, blue));
stack.setItemMeta(meta);
} else {
throw new Exception(tl("leatherSyntax"));
throw new Exception(sender.tl("leatherSyntax"));
}
} else {
parseEnchantmentStrings(sender, allowUnsafe, split, ess);
}
}
/**
* @deprecated Use {@link #addItemFlags(CommandSource, String)}
*/
@Deprecated
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);
if (separate.length != 2) {
throw new Exception(tl("invalidItemFlagMeta", string));
throw new Exception(sender.tl("invalidItemFlagMeta", string));
}
String[] split = separate[1].split(",");
@ -269,7 +277,7 @@ public class MetaItemStack {
}
if (meta.getItemFlags().isEmpty()) {
throw new Exception(tl("invalidItemFlagMeta", string));
throw new Exception(sender.tl("invalidItemFlagMeta", string));
}
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 (validFirework) {
if (!hasMetaPermission(sender, "firework", true, true, ess)) {
throw new Exception(tl("noMetaFirework"));
throw new Exception(sender.tl("noMetaFirework"));
}
FireworkEffect effect = builder.build();
FireworkMeta fmeta = (FireworkMeta) stack.getItemMeta();
fmeta.addEffect(effect);
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);
builder = FireworkEffect.builder();
@ -304,7 +312,7 @@ public class MetaItemStack {
validFirework = true;
primaryColors.add(colorMap.get(color.toUpperCase()).getFireworkColor());
} else {
throw new Exception(tl("invalidFireworkFormat", split[1], split[0]));
throw new Exception(sender.tl("invalidFireworkFormat", split[1], split[0]));
}
}
builder.withColor(primaryColors);
@ -314,7 +322,7 @@ public class MetaItemStack {
if (fireworkShape.containsKey(split[1].toUpperCase())) {
finalEffect = fireworkShape.get(split[1].toUpperCase());
} else {
throw new Exception(tl("invalidFireworkFormat", split[1], split[0]));
throw new Exception(sender.tl("invalidFireworkFormat", split[1], split[0]));
}
if (finalEffect != null) {
builder.with(finalEffect);
@ -326,7 +334,7 @@ public class MetaItemStack {
if (colorMap.containsKey(color.toUpperCase())) {
fadeColors.add(colorMap.get(color.toUpperCase()).getFireworkColor());
} else {
throw new Exception(tl("invalidFireworkFormat", split[1], split[0]));
throw new Exception(sender.tl("invalidFireworkFormat", split[1], split[0]));
}
}
if (!fadeColors.isEmpty()) {
@ -340,7 +348,7 @@ public class MetaItemStack {
} else if (effect.equalsIgnoreCase("trail")) {
builder.trail(true);
} 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)) {
validPotionEffect = true;
} else {
throw new Exception(tl("noPotionEffectPerm", pEffectType.getName().toLowerCase(Locale.ENGLISH)));
throw new Exception(sender.tl("noPotionEffectPerm", pEffectType.getName().toLowerCase(Locale.ENGLISH)));
}
} 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"))) {
if (NumberUtil.isInt(split[1])) {
@ -374,14 +382,14 @@ public class MetaItemStack {
power -= 1;
}
} 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"))) {
if (NumberUtil.isInt(split[1])) {
validPotionDuration = true;
duration = Integer.parseInt(split[1]) * 20; //Duration is in ticks by default, converted to seconds
} 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"))) {
isSplashPotion = Boolean.valueOf(split[1]);
@ -391,7 +399,7 @@ public class MetaItemStack {
PotionMeta pmeta = (PotionMeta) stack.getItemMeta();
pEffect = pEffectType.createEffect(duration, power);
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);
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 {
if (enchantment == null) {
throw new Exception(tl("enchantmentNotFound"));
throw new Exception(sender.tl("enchantmentNotFound"));
}
try {
if (stack.getType().equals(Material.ENCHANTED_BOOK)) {
@ -471,7 +479,7 @@ public class MetaItemStack {
final String enchantmentName = enchantment.getName().toLowerCase(Locale.ENGLISH);
if (!hasMetaPermission(user, "enchantments." + enchantmentName, true, false)) {
throw new Exception(tl("enchantmentPerm", enchantmentName));
throw new Exception(user.tl( "enchantmentPerm", enchantmentName));
}
return enchantment;
}
@ -481,7 +489,7 @@ public class MetaItemStack {
final String[] split = splitPattern.split(string, 2);
if (split.length < 2) {
throw new Exception(tl("invalidBanner", split[1]));
throw new Exception(sender.tl("invalidBanner", split[1]));
}
PatternType patternType = null;
@ -505,7 +513,7 @@ public class MetaItemStack {
final String[] split = splitPattern.split(string, 2);
if (split.length < 2) {
throw new Exception(tl("invalidBanner", split[1]));
throw new Exception(sender.tl("invalidBanner", split[1]));
}
PatternType patternType = null;
@ -545,7 +553,7 @@ public class MetaItemStack {
if (graceful) {
return false;
} else {
throw new Exception(tl("noMetaPerm", metaPerm));
throw new Exception(user.tl( "noMetaPerm", metaPerm));
}
}

View File

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

View File

@ -805,6 +805,17 @@ public class Settings implements net.ess3.api.ISettings {
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() {

View File

@ -36,7 +36,7 @@ public class SpawnMob {
}
}
if (availableList.isEmpty()) {
availableList.add(tl("none"));
availableList.add(user.tl( "none"));
}
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 {
final Block block = LocationUtil.getTarget(user.getBase()).getBlock();
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);
}
@ -109,7 +109,7 @@ public class SpawnMob {
if (mobCount > effectiveLimit) {
mobCount = effectiveLimit;
sender.sendMessage(tl("mobSpawnLimit"));
sender.sendTl("mobSpawnLimit");
}
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++) {
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) {
throw new Exception(tl("unableToSpawnMob"), e1);
throw new Exception(sender.tl("unableToSpawnMob"), e1);
} catch (NumberFormatException e2) {
throw new Exception(tl("numberRequired"), e2);
throw new Exception(sender.tl("numberRequired"), e2);
} 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 {
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))) {
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))) {
throw new Exception(tl("noPermToSpawnMob"));
throw new Exception(sender.tl("noPermToSpawnMob"));
}
}
@ -179,7 +179,7 @@ public class SpawnMob {
String data = inputData;
if (data.isEmpty()) {
sender.sendMessage(tl("mobDataList", StringUtil.joinList(MobData.getValidHelp(spawned))));
sender.sendTl("mobDataList", StringUtil.joinList(MobData.getValidHelp(spawned)));
}
if (spawned instanceof Zombie) {

View File

@ -63,7 +63,7 @@ public class Teleport implements ITeleport {
time.setTimeInMillis(lastTime);
time.add(Calendar.SECOND, (int) cooldown);
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
@ -95,7 +95,7 @@ public class Teleport implements ITeleport {
Calendar c = new GregorianCalendar();
c.add(Calendar.SECOND, (int) delay);
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.
@ -115,7 +115,7 @@ public class Teleport implements ITeleport {
}
final ITarget target = new PlayerTarget(entity);
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 {
@ -131,7 +131,7 @@ public class Teleport implements ITeleport {
PaperLib.teleportAsync(teleportee.getBase(), LocationUtil.getSafeDestination(ess, teleportee, loc), cause);
}
} 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 {
if (ess.getSettings().isForceDisableTeleportSafety()) {
@ -162,7 +162,7 @@ public class Teleport implements ITeleport {
@Override
public void teleport(Player entity, Trade chargeFor, TeleportCause cause) throws Exception {
ITarget target = new PlayerTarget(entity);
teleportOwner.sendMessage(tl("teleportToPlayer", entity.getDisplayName()));
teleportOwner.sendTl("teleportToPlayer", entity.getDisplayName());
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 {
ITarget target = new PlayerTarget(entity);
teleport(teleportee, target, chargeFor, cause);
teleportee.sendMessage(tl("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()));
teleportee.sendTl("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 {
@ -292,9 +292,9 @@ public class Teleport implements ITeleport {
}
warp = event.getWarp();
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)) {
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);
}
@ -310,7 +310,7 @@ public class Teleport implements ITeleport {
public void back(IUser teleporter, Trade chargeFor) throws Exception {
tpType = TeleportType.BACK;
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);
}

View File

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

View File

@ -87,20 +87,20 @@ public class Trade {
}
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())) {
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;
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) {
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());
}
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());
}
@ -192,7 +192,7 @@ public class Trade {
ess.getLogger().log(Level.INFO, "charging user " + user.getName() + " itemstack " + getItemStack().toString());
}
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().updateInventory();
@ -200,7 +200,7 @@ public class Trade {
if (command != null) {
final BigDecimal cost = getCommandCost(user);
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);
}
@ -210,7 +210,7 @@ public class Trade {
}
final int experience = SetExpFix.getTotalExperience(user.getBase());
if (experience < getExperience() && getExperience() > 0) {
throw new ChargeException(tl("notEnoughExperience"));
throw new ChargeException(user.tl("notEnoughExperience"));
}
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.MILLISECOND, (int) ((cooldown * 1000.0) % 1000.0));
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());
@ -168,7 +168,7 @@ public class User extends UserData implements Comparable<User>, IMessageRecipien
setMoney(getMoney().add(value));
sendMessage(tl("addedToAccount", NumberUtil.displayCurrency(value, ess)));
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));
reciever.setMoney(reciever.getMoney().add(value));
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 {
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)));
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()) {
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
public int compareTo(final User other) {
return FormatUtil.stripFormat(getDisplayName()).compareToIgnoreCase(FormatUtil.stripFormat(other.getDisplayName()));
@ -843,7 +853,7 @@ public class User extends UserData implements Comparable<User>, IMessageRecipien
@Override
public CommandSource getSource() {
return new CommandSource(getBase());
return new CommandSource(this);
}
@Override
@ -893,6 +903,25 @@ public class User extends UserData implements Comparable<User>, IMessageRecipien
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() {
return confirmingClearCommand;
}

View File

@ -95,6 +95,7 @@ public abstract class UserData extends PlayerExtension implements IConf {
confirmPay = _getConfirmPay();
confirmClear = _getConfirmClear();
lastMessageReplyRecipient = _getLastMessageReplyRecipient();
locale = _getLocale();
}
private BigDecimal money;
@ -210,7 +211,7 @@ public abstract class UserData extends PlayerExtension implements IConf {
config.removeProperty("homes." + search);
config.save();
} 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();
}
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() {
return config.uuid;
}

View File

@ -4,6 +4,7 @@ import com.earth2me.essentials.commands.WarpNotFoundException;
import com.earth2me.essentials.utils.StringUtil;
import net.ess3.api.InvalidNameException;
import net.ess3.api.InvalidWorldException;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Server;
import java.io.File;
@ -65,7 +66,7 @@ public class Warps implements IConf, net.ess3.api.IWarps {
if (conf == null) {
File confFile = new File(warpsFolder, filename + ".yml");
if (confFile.exists()) {
throw new Exception(tl("similarWarpExist"));
throw new Exception(user.tl("similarWarpExist"));
}
conf = new EssentialsConf(confFile);
warpPoints.put(new StringIgnoreCase(name), conf);
@ -76,7 +77,7 @@ public class Warps implements IConf, net.ess3.api.IWarps {
try {
conf.saveWithError();
} 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
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));
if (conf == null) {
throw new Exception(tl("warpNotExist"));
throw new Exception(sender.tl("warpNotExist"));
}
if (!conf.getFile().delete()) {
throw new Exception(tl("warpDeleteError"));
throw new Exception(sender.tl("warpDeleteError"));
}
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 {
if (is == null || is.getType() == Material.AIR) {
throw new Exception(tl("itemSellAir"));
throw new Exception(user.tl("itemSellAir"));
}
int amount = 0;
@ -95,7 +95,7 @@ public class Worth implements IConf {
boolean requireStack = ess.getSettings().isTradeInStacks(is.getType());
if (requireStack && !stack) {
throw new Exception(tl("itemMustBeStacked"));
throw new Exception(user.tl("itemMustBeStacked"));
}
int max = 0;
@ -118,9 +118,9 @@ public class Worth implements IConf {
}
if (amount > max || amount < 1) {
if (!isBulkSell) {
user.sendMessage(tl("itemNotEnough2"));
user.sendMessage(tl("itemNotEnough3"));
throw new Exception(tl("itemNotEnough1"));
user.sendTl("itemNotEnough2");
user.sendTl("itemNotEnough3");
throw new Exception(user.tl("itemNotEnough1"));
} else {
return amount;
}

View File

@ -5,7 +5,7 @@ import java.util.Locale;
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
*/

View File

@ -1,5 +1,6 @@
package com.earth2me.essentials.api;
import com.earth2me.essentials.CommandSource;
import com.earth2me.essentials.IConf;
import com.earth2me.essentials.IUser;
import com.earth2me.essentials.commands.WarpNotFoundException;
@ -43,9 +44,21 @@ public interface IWarps extends IConf {
* @param name - Name of warp
*
* @throws Exception
* @deprecated Use {@link #removeWarp(CommandSource, String)}
*/
@Deprecated
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
*

View File

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

View File

@ -11,8 +11,6 @@ import java.util.Collection;
import java.util.Collections;
import java.util.List;
import static com.earth2me.essentials.I18n.tl;
public class Commandback extends EssentialsCommand {
public Commandback() {
@ -51,14 +49,14 @@ public class Commandback extends EssentialsCommand {
}
for (Player player : players) {
sender.sendMessage(tl("backOther", player.getName()));
sender.sendTl("backOther", player.getName());
teleportBack(sender, ess.getUser(player));
}
}
private void teleportBack(CommandSource sender, User user) throws Exception {
if (user.getLastLocation() == null) {
throw new Exception(tl("noLocationFound"));
throw new Exception(sender.tl("noLocationFound"));
}
String lastWorldName = user.getLastLocation().getWorld().getName();
@ -68,11 +66,11 @@ public class Commandback extends EssentialsCommand {
requester = ess.getUser(sender.getPlayer());
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)) {
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 org.bukkit.Server;
import static com.earth2me.essentials.I18n.tl;
public class Commandbackup extends EssentialsCommand {
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 {
final Backup backup = ess.getBackup();
if (backup == null) {
throw new Exception(tl("backupDisabled"));
throw new Exception(sender.tl("backupDisabled"));
}
final String command = ess.getSettings().getBackupCommand();
if (command == null || "".equals(command) || "save-all".equalsIgnoreCase(command)) {
throw new Exception(tl("backupDisabled"));
throw new Exception(sender.tl("backupDisabled"));
}
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.List;
import static com.earth2me.essentials.I18n.tl;
public class Commandbalance extends EssentialsCommand {
public Commandbalance() {
@ -24,7 +22,7 @@ public class Commandbalance extends EssentialsCommand {
}
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
@ -32,10 +30,10 @@ public class Commandbalance extends EssentialsCommand {
if (args.length == 1 && user.isAuthorized("essentials.balance.others")) {
final User target = getPlayer(server, args, 0, true, true);
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) {
final BigDecimal bal = user.getMoney();
user.sendMessage(tl("balance", NumberUtil.displayCurrency(bal, ess)));
user.sendTl("balance", NumberUtil.displayCurrency(bal, ess));
} else {
throw new NotEnoughArgumentsException();
}

View File

@ -49,7 +49,7 @@ public class Commandbalancetop extends EssentialsCommand {
return;
}
if (ess.getUserMap().getUniqueUsers() > MINUSERS) {
sender.sendMessage(tl("orderBalances", ess.getUserMap().getUniqueUsers()));
sender.sendTl("orderBalances", ess.getUserMap().getUniqueUsers());
}
} finally {
lock.readLock().unlock();
@ -57,7 +57,7 @@ public class Commandbalancetop extends EssentialsCommand {
ess.runTaskAsynchronously(new Viewer(sender, commandLabel, page, force));
} else {
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));
}
@ -68,7 +68,7 @@ public class Commandbalancetop extends EssentialsCommand {
final Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(cacheage);
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);
}

View File

@ -35,11 +35,11 @@ public class Commandban extends EssentialsCommand {
}
if (!user.getBase().isOnline()) {
if (sender.isPlayer() && !ess.getUser(sender.getPlayer()).isAuthorized("essentials.ban.offline")) {
throw new Exception(tl("banExemptOffline"));
throw new Exception(user.tl("banExemptOffline"));
}
} else {
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) {
banReason = FormatUtil.replaceFormat(getFinalArg(args, 1).replace("\\n", "\n").replace("|", "\n"));
} else {
banReason = tl("defaultBanReason");
banReason = user.tl("defaultBanReason");
}
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);
server.getLogger().log(Level.INFO, tl("playerBanned", senderName, user.getName(), banDisplay));
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

View File

@ -48,21 +48,20 @@ public class Commandbanip extends EssentialsCommand {
if (args.length > 1) {
banReason = FormatUtil.replaceFormat(getFinalArg(args, 1).replace("\\n", "\n").replace("|", "\n"));
} 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);
server.getLogger().log(Level.INFO, tl("playerBanIpAddress", senderName, ipAddress, banReason));
for (Player player : ess.getServer().getOnlinePlayers()) {
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

View File

@ -10,8 +10,6 @@ import org.bukkit.TreeType;
import java.util.Collections;
import java.util.List;
import static com.earth2me.essentials.I18n.tl;
public class Commandbigtree extends EssentialsCommand {
public Commandbigtree() {
@ -37,9 +35,9 @@ public class Commandbigtree extends EssentialsCommand {
final Location safeLocation = LocationUtil.getSafeDestination(loc);
final boolean success = user.getWorld().generateTree(safeLocation, tree);
if (success) {
user.sendMessage(tl("bigTreeSuccess"));
user.sendTl("bigTreeSuccess");
} 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.List;
import static com.earth2me.essentials.I18n.tl;
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"))) {
bmeta.setAuthor(args[1]);
item.setItemMeta(bmeta);
user.sendMessage(tl("bookAuthorSet", getFinalArg(args, 1)));
user.sendTl("bookAuthorSet", getFinalArg(args, 1));
} else {
throw new Exception(tl("denyChangeAuthor"));
throw new Exception(user.tl("denyChangeAuthor"));
}
} else if (args.length > 1 && args[0].equalsIgnoreCase("title")) {
if (user.isAuthorized("essentials.book.title") && (isAuthor(bmeta, player) || user.isAuthorized("essentials.book.others"))) {
bmeta.setTitle(args[1]);
item.setItemMeta(bmeta);
user.sendMessage(tl("bookTitleSet", getFinalArg(args, 1)));
user.sendTl("bookTitleSet", getFinalArg(args, 1));
} else {
throw new Exception(tl("denyChangeTitle"));
throw new Exception(user.tl("denyChangeTitle"));
}
} else {
if (isAuthor(bmeta, player) || user.isAuthorized("essentials.book.others")) {
ItemStack newItem = new ItemStack(WRITABLE_BOOK, item.getAmount());
newItem.setItemMeta(bmeta);
InventoryWorkaround.setItemInMainHand(user.getBase(), newItem);
user.sendMessage(tl("editBookContents"));
user.sendTl("editBookContents");
} else {
throw new Exception(tl("denyBookEdit"));
throw new Exception(user.tl("denyBookEdit"));
}
}
} else if (item.getType() == WRITABLE_BOOK) {
@ -64,9 +62,9 @@ public class Commandbook extends EssentialsCommand {
ItemStack newItem = new ItemStack(Material.WRITTEN_BOOK, item.getAmount());
newItem.setItemMeta(bmeta);
InventoryWorkaround.setItemInMainHand(user.getBase(), newItem);
user.sendMessage(tl("bookLocked"));
user.sendTl("bookLocked");
} 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 static com.earth2me.essentials.I18n.tl;
public class Commandbreak extends EssentialsCommand {
public Commandbreak() {
@ -27,7 +25,7 @@ public class Commandbreak extends EssentialsCommand {
throw new NoChargeException();
}
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 BlockBreakEvent event = new BlockBreakEvent(block, user.getBase(), list);

View File

@ -15,19 +15,19 @@ public class Commandbroadcast extends EssentialsCommand {
@Override
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
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) {
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);
}
sendBroadcast(world.getName(), user.getDisplayName(), message);
sendBroadcast(user.getSource(), world.getName(), user.getDisplayName(), message);
}
@Override
@ -53,27 +53,27 @@ public class Commandbroadcastworld extends EssentialsCommand {
if (args.length < 2) {
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);
if (world == null) {
throw new Exception(tl("invalidWorld"));
throw new Exception(sender.tl("invalidWorld"));
}
if (message.isEmpty()) {
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) {
IText broadcast = new SimpleTextInput(message);
private void sendToWorld(World world, String string, Object... objects) {
final Collection<Player> players = ess.getOnlinePlayers();
for (Player player : players) {
if (player.getWorld().equals(world)) {
final User user = ess.getUser(player);
IText broadcast = new SimpleTextInput(user.tl(string, objects));
broadcast = new KeywordReplacer(broadcast, new CommandSource(player), ess, false);
for (String messageText : broadcast.getLines()) {
user.sendMessage(messageText);

View File

@ -7,8 +7,6 @@ import org.bukkit.Server;
import java.util.Collections;
import java.util.List;
import static com.earth2me.essentials.I18n.tl;
public class Commandburn extends EssentialsCommand {
public Commandburn() {
@ -27,7 +25,7 @@ public class Commandburn extends EssentialsCommand {
User user = getPlayer(server, sender, args, 0);
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

View File

@ -1,7 +1,5 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n.tl;
import com.earth2me.essentials.CommandSource;
import com.earth2me.essentials.User;
import com.earth2me.essentials.craftbukkit.InventoryWorkaround;
@ -52,7 +50,7 @@ public class Commandclearinventory extends EssentialsCommand {
}
if (allowAll && args.length > 0 && args[0].contentEquals("*")) {
sender.sendMessage(tl("inventoryClearingFromAll"));
sender.sendTl("inventoryClearingFromAll");
offset = 1;
players = ess.getOnlinePlayers();
} 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 (!formattedCommand.equals(previousClearCommand)) {
senderUser.setConfirmingClearCommand(formattedCommand);
senderUser.sendMessage(tl("confirmClear", formattedCommand));
senderUser.sendTl("confirmClear", formattedCommand);
return;
}
}
@ -108,14 +106,14 @@ public class Commandclearinventory extends EssentialsCommand {
if (type == -1) // type -1 represents wildcard or all items
{
if (showExtended) {
sender.sendMessage(tl("inventoryClearingAllItems", player.getDisplayName()));
sender.sendTl("inventoryClearingAllItems", player.getDisplayName());
}
InventoryWorkaround.clearInventoryNoArmor(player.getInventory());
InventoryWorkaround.setItemInOffHand(player, null);
} else if (type == -2) // type -2 represents double wildcard or all items and armor
{
if (showExtended) {
sender.sendMessage(tl("inventoryClearingAllArmor", player.getDisplayName()));
sender.sendTl("inventoryClearingAllArmor", player.getDisplayName());
}
InventoryWorkaround.clearInventoryNoArmor(player.getInventory());
InventoryWorkaround.setItemInOffHand(player, null);
@ -128,7 +126,7 @@ public class Commandclearinventory extends EssentialsCommand {
ItemStack removedStack = player.getInventory().removeItem(stack).get(0);
final int removedAmount = (BASE_AMOUNT - removedStack.getAmount());
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 {
if (amount < 0) {
@ -136,11 +134,11 @@ public class Commandclearinventory extends EssentialsCommand {
}
ItemStack stack = new ItemStack(mat, 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);
} else {
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;
import static com.earth2me.essentials.I18n.tl;
import com.earth2me.essentials.User;
import org.bukkit.Server;
@ -22,9 +20,9 @@ public class Commandclearinventoryconfirmtoggle extends EssentialsCommand {
}
user.setPromptingClearConfirm(confirmingClear);
if (confirmingClear) {
user.sendMessage(tl("clearInventoryConfirmToggleOn"));
user.sendTl("clearInventoryConfirmToggleOn");
} else {
user.sendMessage(tl("clearInventoryConfirmToggleOff"));
user.sendTl("clearInventoryConfirmToggleOff");
}
user.setConfirmingClearCommand(null);
}

View File

@ -3,8 +3,6 @@ package com.earth2me.essentials.commands;
import com.earth2me.essentials.User;
import org.bukkit.Server;
import static com.earth2me.essentials.I18n.tl;
public class Commandcompass extends EssentialsCommand {
public Commandcompass() {
@ -16,24 +14,24 @@ public class Commandcompass extends EssentialsCommand {
final int bearing = (int) (user.getLocation().getYaw() + 180 + 360) % 360;
String dir;
if (bearing < 23) {
dir = tl("north");
dir = user.tl("north");
} else if (bearing < 68) {
dir = tl("northEast");
dir = user.tl("northEast");
} else if (bearing < 113) {
dir = tl("east");
dir = user.tl("east");
} else if (bearing < 158) {
dir = tl("southEast");
dir = user.tl("southEast");
} else if (bearing < 203) {
dir = tl("south");
dir = user.tl("south");
} else if (bearing < 248) {
dir = tl("southWest");
dir = user.tl("southWest");
} else if (bearing < 293) {
dir = tl("west");
dir = user.tl("west");
} else if (bearing < 338) {
dir = tl("northWest");
dir = user.tl("northWest");
} 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 static com.earth2me.essentials.I18n.tl;
public class Commandcondense extends EssentialsCommand {
public Commandcondense() {
@ -50,9 +48,9 @@ public class Commandcondense extends EssentialsCommand {
user.getBase().updateInventory();
if (didConvert) {
user.sendMessage(tl("itemsConverted"));
user.sendTl("itemsConverted");
} else {
user.sendMessage(tl("itemsNotConverted"));
user.sendTl("itemsNotConverted");
throw new NoChargeException();
}
}

View File

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

View File

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

View File

@ -5,7 +5,6 @@ import org.bukkit.Server;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import static com.earth2me.essentials.I18n.tl;
public class Commanddeljail extends EssentialsCommand {
@ -20,11 +19,11 @@ public class Commanddeljail extends EssentialsCommand {
}
if (ess.getJails().getJail(args[0]) == null) {
throw new Exception(tl("jailNotExist"));
throw new Exception(sender.tl("jailNotExist"));
}
ess.getJails().removeJail(args[0]);
sender.sendMessage(tl("deleteJail", args[0]));
sender.sendTl("deleteJail", args[0]);
}
@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 {
if (args.length < 1) {
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();
} else {
final String kitName = args[0];
@ -35,7 +39,7 @@ public class Commanddelkit extends EssentialsCommand {
}
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.List;
import static com.earth2me.essentials.I18n.tl;
public class Commanddelwarp extends EssentialsCommand {
public Commanddelwarp() {
@ -21,8 +19,8 @@ public class Commanddelwarp extends EssentialsCommand {
throw new NotEnoughArgumentsException();
}
ess.getWarps().removeWarp(args[0]);
sender.sendMessage(tl("deleteWarp", args[0]));
ess.getWarps().removeWarp(sender, args[0]);
sender.sendTl("deleteWarp", args[0]);
}
@Override

View File

@ -3,8 +3,6 @@ package com.earth2me.essentials.commands;
import com.earth2me.essentials.User;
import org.bukkit.Server;
import static com.earth2me.essentials.I18n.tl;
public class Commanddepth extends EssentialsCommand {
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 {
final int depth = user.getLocation().getBlockY() - 63;
if (depth > 0) {
user.sendMessage(tl("depthAboveSea", depth));
user.sendTl("depthAboveSea", depth);
} else if (depth < 0) {
user.sendMessage(tl("depthBelowSea", (-depth)));
user.sendTl("depthBelowSea", (-depth));
} 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 org.bukkit.Server;
import static com.earth2me.essentials.I18n.tl;
public class Commanddisposal extends EssentialsCommand {
public Commanddisposal() {
@ -13,8 +11,8 @@ public class Commanddisposal extends EssentialsCommand {
@Override
protected void run(Server server, User user, String commandLabel, String[] args) throws Exception {
user.sendMessage(tl("openingDisposal"));
user.getBase().openInventory(ess.getServer().createInventory(user.getBase(), 36, tl("disposal")));
user.sendTl("openingDisposal");
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 (args[1].contentEquals("**")) {
server.broadcastMessage(tl("resetBalAll", NumberUtil.displayCurrency(amount, ess)));
ess.broadcastTl("resetBalAll", NumberUtil.displayCurrency(amount, ess));
} 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) {
// 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 {
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 aboveMax = (amount.compareTo(maxBalance) > 0);
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) {
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.TreeSet;
import static com.earth2me.essentials.I18n.tl;
public class Commandenchant extends EssentialsCommand {
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 {
final ItemStack stack = user.getItemInHand();
if (stack == null || stack.getType() == Material.AIR) {
throw new Exception(tl("nothingInHand"));
throw new Exception(user.tl("nothingInHand"));
}
if (args.length == 0) {
final Set<String> enchantmentslist = new TreeSet<>();
@ -43,7 +41,7 @@ public class Commandenchant extends EssentialsCommand {
//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;
@ -65,9 +63,9 @@ public class Commandenchant extends EssentialsCommand {
user.getBase().updateInventory();
final String enchantmentName = enchantment.getName().toLowerCase(Locale.ENGLISH);
if (level == 0) {
user.sendMessage(tl("enchantmentRemoved", enchantmentName.replace('_', ' ')));
user.sendTl("enchantmentRemoved", enchantmentName.replace('_', ' '));
} 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.function.Supplier;
import static com.earth2me.essentials.I18n.tl;
// This command has 4 undocumented behaviours #EasterEgg
public class Commandessentials extends EssentialsCommand {
@ -135,7 +133,7 @@ public class Commandessentials extends EssentialsCommand {
disabledCommands.append(entry.getKey()).append(" => ").append(entry.getValue());
}
if (disabledCommands.length() > 0) {
sender.sendMessage(tl("blockList"));
sender.sendTl("blockList");
sender.sendMessage(disabledCommands.toString());
} else {
sender.sendMessage(tl("blockListEmpty"));
@ -161,7 +159,7 @@ public class Commandessentials extends EssentialsCommand {
// Reloads all reloadable configs.
private void runReload(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception {
ess.reload();
sender.sendMessage(tl("essentialsReload", ess.getDescription().getVersion()));
sender.sendTl("essentialsReload", ess.getDescription().getVersion());
}
// Pop tarts.
@ -205,7 +203,7 @@ public class Commandessentials extends EssentialsCommand {
throw new Exception("/<command> cleanup <days> [money] [homes]");
}
sender.sendMessage(tl("cleaning"));
sender.sendTl("cleaning");
final long daysArg = Long.parseLong(args[1]);
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();
}
sender.sendMessage(tl("cleaned"));
sender.sendTl("cleaned");
});
}
@ -311,8 +309,8 @@ public class Commandessentials extends EssentialsCommand {
final PluginManager pm = server.getPluginManager();
final String essVer = pm.getPlugin("Essentials").getDescription().getVersion();
sender.sendMessage(tl(isServerSupported ? "versionOutputFine" : "versionOutputWarn", "Server", server.getBukkitVersion() + " " + server.getVersion()));
sender.sendMessage(tl("versionOutputFine", "EssentialsX", essVer));
sender.sendTl(isServerSupported ? "versionOutputFine" : "versionOutputWarn", "Server", server.getBukkitVersion() + " " + server.getVersion());
sender.sendTl("versionOutputFine", "EssentialsX", essVer);
for (Plugin plugin : pm.getPlugins()) {
final PluginDescriptionFile desc = plugin.getDescription();
@ -325,22 +323,22 @@ public class Commandessentials extends EssentialsCommand {
if (!version.equalsIgnoreCase(essVer)) {
isMismatched = true;
sender.sendMessage(tl("versionOutputWarn", name, version));
sender.sendTl("versionOutputWarn", name, version);
} else {
sender.sendMessage(tl("versionOutputFine", name, version));
sender.sendTl("versionOutputFine", name, version);
}
} else {
sender.sendMessage(tl("versionOutputUnsupported", name, version));
sender.sendTl("versionOutputUnsupported", name, version);
isUnsupported = true;
}
}
if (versionPlugins.contains(name)) {
if (warnPlugins.contains(name)) {
sender.sendMessage(tl("versionOutputUnsupported", name, version));
sender.sendTl("versionOutputUnsupported", name, version);
isUnsupported = true;
} else {
sender.sendMessage(tl("versionOutputFine", name, version));
sender.sendTl("versionOutputFine", name, version);
}
}
@ -348,19 +346,19 @@ public class Commandessentials extends EssentialsCommand {
}
if (isMismatched) {
sender.sendMessage(tl("versionMismatchAll"));
sender.sendTl("versionMismatchAll");
}
if (!isVaultInstalled) {
sender.sendMessage(tl("versionOutputVaultMissing"));
sender.sendTl("versionOutputVaultMissing");
}
if (isUnsupported) {
sender.sendMessage(tl("versionOutputUnsupportedPlugins"));
sender.sendTl("versionOutputUnsupportedPlugins");
}
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.Locale;
import static com.earth2me.essentials.I18n.tl;
public class Commandexp extends EssentialsCommand {
public Commandexp() {
@ -126,7 +124,7 @@ public class Commandexp extends EssentialsCommand {
}
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?
@ -158,7 +156,7 @@ public class Commandexp extends EssentialsCommand {
amount = 0l;
}
SetExpFix.setTotalExperience(target.getBase(), (int) amount);
sender.sendMessage(tl("expSet", target.getDisplayName(), amount));
sender.sendTl("expSet", target.getDisplayName(), amount);
}
@Override

View File

@ -8,8 +8,6 @@ import org.bukkit.entity.Player;
import java.util.Collections;
import java.util.List;
import static com.earth2me.essentials.I18n.tl;
public class Commandext extends EssentialsLoopCommand {
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 {
if (args.length < 1) {
extPlayer(user.getBase());
user.sendMessage(tl("extinguish"));
user.sendTl("extinguish");
return;
}
@ -39,7 +37,7 @@ public class Commandext extends EssentialsLoopCommand {
@Override
protected void updatePlayer(final Server server, final CommandSource sender, final User player, final String[] args) {
extPlayer(player.getBase());
sender.sendMessage(tl("extinguishOthers", player.getDisplayName()));
sender.sendTl("extinguishOthers", player.getDisplayName());
}
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.List;
import static com.earth2me.essentials.I18n.tl;
public class Commandfeed extends EssentialsLoopCommand {
public Commandfeed() {
@ -29,7 +27,7 @@ public class Commandfeed extends EssentialsLoopCommand {
}
feedPlayer(user.getBase());
user.sendMessage(tl("feed"));
user.sendTl("feed");
}
@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 {
try {
feedPlayer(player.getBase());
sender.sendMessage(tl("feedOther", player.getDisplayName()));
sender.sendTl("feedOther", player.getDisplayName());
} catch (QuietAbortException e) {
//Handle Quietly
}

View File

@ -56,7 +56,7 @@ public class Commandfireball extends EssentialsCommand {
}
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);

View File

@ -18,8 +18,6 @@ import org.bukkit.util.Vector;
import java.util.Collections;
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:
//
//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();
fmeta.clearEffects();
stack.setItemMeta(fmeta);
user.sendMessage(tl("fireworkEffectsCleared"));
user.sendTl("fireworkEffectsCleared");
} else if (args.length > 1 && (args[0].equalsIgnoreCase("power") || (args[0].equalsIgnoreCase("p")))) {
FireworkMeta fmeta = (FireworkMeta) stack.getItemMeta();
try {
int power = Integer.parseInt(args[1]);
fmeta.setPower(power > 3 ? 4 : power);
} 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);
} 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]);
if (amount > serverLimit) {
amount = serverLimit;
user.sendMessage(tl("mobSpawnLimit"));
user.sendTl("mobSpawnLimit");
}
} else {
direction = true;
@ -94,7 +92,7 @@ public class Commandfirework extends EssentialsCommand {
try {
mStack.addFireworkMeta(user.getSource(), true, arg, ess);
} catch (Exception e) {
user.sendMessage(tl("fireworkSyntax"));
user.sendTl("fireworkSyntax");
throw e;
}
}
@ -103,20 +101,20 @@ public class Commandfirework extends EssentialsCommand {
FireworkMeta fmeta = (FireworkMeta) mStack.getItemStack().getItemMeta();
FireworkEffect effect = mStack.getFireworkBuilder().build();
if (fmeta.getEffects().size() > 0 && !user.isAuthorized("essentials.firework.multiple")) {
throw new Exception(tl("multipleCharges"));
throw new Exception(user.tl("multipleCharges"));
}
fmeta.addEffect(effect);
stack.setItemMeta(fmeta);
} else {
user.sendMessage(tl("fireworkSyntax"));
throw new Exception(tl("fireworkColor"));
user.sendTl("fireworkSyntax");
throw new Exception(user.tl("fireworkColor"));
}
}
} else {
throw new NotEnoughArgumentsException();
}
} 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 net.ess3.api.events.FlyStatusChangeEvent;
import static com.earth2me.essentials.I18n.tl;
public class Commandfly extends EssentialsToggleCommand {
public Commandfly() {
super("fly", "essentials.fly.others");
@ -40,9 +38,9 @@ public class Commandfly extends EssentialsToggleCommand {
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())) {
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.Locale;
import static com.earth2me.essentials.I18n.tl;
public class Commandgamemode extends EssentialsCommand {
public Commandgamemode() {
@ -61,21 +59,21 @@ public class Commandgamemode extends EssentialsCommand {
}
if (!canChangeToMode(user, gameMode)) {
user.sendMessage(tl("cantGamemode", gameMode.name()));
user.sendTl("cantGamemode", gameMode.name());
return;
}
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 {
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)) {
sender.sendMessage(tl("cantGamemode", gameMode.name()));
sender.sendTl("cantGamemode", gameMode.name());
return;
}
@ -89,7 +87,7 @@ public class Commandgamemode extends EssentialsCommand {
}
foundUser = true;
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) {
throw new PlayerNotFoundException();

View File

@ -9,8 +9,6 @@ import java.lang.management.ManagementFactory;
import java.util.List;
import java.util.logging.Level;
import static com.earth2me.essentials.I18n.tl;
public class Commandgc extends EssentialsCommand {
public Commandgc() {
@ -29,11 +27,11 @@ public class Commandgc extends EssentialsCommand {
color = ChatColor.RED;
}
sender.sendMessage(tl("uptime", DateUtil.formatDateDiff(ManagementFactory.getRuntimeMXBean().getStartTime())));
sender.sendMessage(tl("tps", "" + color + NumberUtil.formatDouble(tps)));
sender.sendMessage(tl("gcmax", (Runtime.getRuntime().maxMemory() / 1024 / 1024)));
sender.sendMessage(tl("gctotal", (Runtime.getRuntime().totalMemory() / 1024 / 1024)));
sender.sendMessage(tl("gcfree", (Runtime.getRuntime().freeMemory() / 1024 / 1024)));
sender.sendTl("uptime", DateUtil.formatDateDiff(sender, ManagementFactory.getRuntimeMXBean().getStartTime()));
sender.sendTl("tps", "" + color + NumberUtil.formatDouble(tps));
sender.sendTl("gcmax", (Runtime.getRuntime().maxMemory() / 1024 / 1024));
sender.sendTl("gctotal", (Runtime.getRuntime().totalMemory() / 1024 / 1024));
sender.sendTl("gcfree", (Runtime.getRuntime().freeMemory() / 1024 / 1024));
List<World> worlds = server.getWorlds();
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);
}
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.List;
import static com.earth2me.essentials.I18n.tl;
public class Commandgetpos extends EssentialsCommand {
public Commandgetpos() {
@ -36,14 +34,14 @@ public class Commandgetpos extends EssentialsCommand {
}
private void outputPosition(final CommandSource sender, final Location coords, final Location distance) {
sender.sendMessage(tl("currentWorld", coords.getWorld().getName()));
sender.sendMessage(tl("posX", coords.getBlockX()));
sender.sendMessage(tl("posY", coords.getBlockY()));
sender.sendMessage(tl("posZ", coords.getBlockZ()));
sender.sendMessage(tl("posYaw", (coords.getYaw() + 360) % 360));
sender.sendMessage(tl("posPitch", coords.getPitch()));
sender.sendTl("currentWorld", coords.getWorld().getName());
sender.sendTl("posX", coords.getBlockX());
sender.sendTl("posY", coords.getBlockY());
sender.sendTl("posZ", coords.getBlockZ());
sender.sendTl("posYaw", (coords.getYaw() + 360) % 360);
sender.sendTl("posPitch", coords.getPitch());
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.Map;
import static com.earth2me.essentials.I18n.tl;
public class Commandgive extends EssentialsCommand {
public Commandgive() {
@ -34,7 +32,7 @@ public class Commandgive extends EssentialsCommand {
final String itemname = stack.getType().toString().toLowerCase(Locale.ENGLISH).replace("_", "");
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);
@ -56,7 +54,7 @@ public class Commandgive extends EssentialsCommand {
MetaItemStack metaStack = new MetaItemStack(stack);
if (!metaStack.canSpawn(ess)) {
throw new Exception(tl("unableToSpawnItem", itemname));
throw new Exception(sender.tl("unableToSpawnItem", itemname));
}
if (args.length > 3) {
@ -75,11 +73,11 @@ public class Commandgive extends EssentialsCommand {
}
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('_', ' ');
sender.sendMessage(tl("giveSpawn", stack.getAmount(), itemName, giveTo.getDisplayName()));
sender.sendTl("giveSpawn", stack.getAmount(), itemName, giveTo.getDisplayName());
Map<Integer, ItemStack> leftovers;
@ -96,7 +94,7 @@ public class Commandgive extends EssentialsCommand {
World w = giveTo.getWorld();
w.dropItemNaturally(giveTo.getLocation(), item);
} 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 org.bukkit.Server;
import static com.earth2me.essentials.I18n.tl;
public class Commandgod extends EssentialsToggleCommand {
public Commandgod() {
@ -40,9 +38,9 @@ public class Commandgod extends EssentialsToggleCommand {
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())) {
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.List;
import static com.earth2me.essentials.I18n.tl;
public class Commandhat extends EssentialsCommand {
public Commandhat() {
@ -25,12 +23,12 @@ public class Commandhat extends EssentialsCommand {
final PlayerInventory inv = user.getBase().getInventory();
final ItemStack head = inv.getHelmet();
if (head == null || head.getType() == Material.AIR) {
user.sendMessage(tl("hatEmpty"));
user.sendTl("hatEmpty");
} else {
final ItemStack air = new ItemStack(Material.AIR);
inv.setHelmet(air);
InventoryWorkaround.addItems(user.getBase().getInventory(), head);
user.sendMessage(tl("hatRemoved"));
user.sendTl("hatRemoved");
}
} else {
final ItemStack hand = user.getItemInHand();
@ -44,12 +42,12 @@ public class Commandhat extends EssentialsCommand {
final ItemStack head = inv.getHelmet();
inv.setHelmet(hand);
inv.setItemInHand(head);
user.sendMessage(tl("hatPlaced"));
user.sendTl("hatPlaced");
} else {
user.sendMessage(tl("hatArmor"));
user.sendTl("hatArmor");
}
} 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.List;
import static com.earth2me.essentials.I18n.tl;
public class Commandheal extends EssentialsLoopCommand {
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 {
try {
healPlayer(player);
sender.sendMessage(tl("healOther", player.getDisplayName()));
sender.sendTl("healOther", player.getDisplayName());
} catch (QuietAbortException e) {
//Handle Quietly
}
@ -56,7 +54,7 @@ public class Commandheal extends EssentialsLoopCommand {
final Player player = user.getBase();
if (player.getHealth() == 0) {
throw new PlayerExemptException(tl("healDead"));
throw new PlayerExemptException(user.tl("healDead"));
}
final double amount = player.getMaxHealth() - player.getHealth();
@ -74,7 +72,7 @@ public class Commandheal extends EssentialsLoopCommand {
player.setHealth(newAmount);
player.setFoodLevel(20);
player.setFireTicks(0);
user.sendMessage(tl("heal"));
user.sendTl("heal");
for (PotionEffect effect : player.getActivePotionEffects()) {
player.removePotionEffect(effect.getType());
}

View File

@ -10,8 +10,6 @@ import java.util.Collections;
import java.util.List;
import java.util.Locale;
import static com.earth2me.essentials.I18n.tl;
public class Commandhelp extends EssentialsCommand {
public Commandhelp() {
@ -48,7 +46,7 @@ public class Commandhelp extends EssentialsCommand {
@Override
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

View File

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

View File

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

View File

@ -6,8 +6,6 @@ import org.bukkit.Server;
import java.util.Collections;
import java.util.List;
import static com.earth2me.essentials.I18n.tl;
public class Commandignore extends EssentialsCommand {
public Commandignore() {
@ -22,7 +20,7 @@ public class Commandignore extends EssentialsCommand {
sb.append(s).append(" ");
}
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 {
User player;
try {
@ -34,13 +32,13 @@ public class Commandignore extends EssentialsCommand {
throw new PlayerNotFoundException();
}
if (player.isIgnoreExempt()) {
user.sendMessage(tl("ignoreExempt"));
user.sendTl("ignoreExempt");
} else if (user.isIgnoredPlayer(player)) {
user.setIgnoredPlayer(player, false);
user.sendMessage(tl("unignorePlayer", player.getName()));
user.sendTl("unignorePlayer", player.getName());
} else {
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.Locale;
import static com.earth2me.essentials.I18n.tl;
public class Commanditem extends EssentialsCommand {
public Commanditem() {
@ -30,7 +28,7 @@ public class Commanditem extends EssentialsCommand {
final String itemname = stack.getType().toString().toLowerCase(Locale.ENGLISH).replace("_", "");
if (!user.canSpawnItem(stack.getType())) {
throw new Exception(tl("cantSpawnItem", itemname));
throw new Exception(user.tl("cantSpawnItem", itemname));
}
try {
@ -47,7 +45,7 @@ public class Commanditem extends EssentialsCommand {
MetaItemStack metaStack = new MetaItemStack(stack);
if (!metaStack.canSpawn(ess)) {
throw new Exception(tl("unableToSpawnItem", itemname));
throw new Exception(user.tl("unableToSpawnItem", itemname));
}
if (args.length > 2) {
@ -60,11 +58,11 @@ public class Commanditem extends EssentialsCommand {
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('_', ' ');
user.sendMessage(tl("itemSpawn", stack.getAmount(), displayName));
user.sendTl("itemSpawn", stack.getAmount(), displayName);
if (user.isAuthorized("essentials.oversizedstacks")) {
InventoryWorkaround.addOversizedItems(user.getBase().getInventory(), ess.getSettings().getOversizedStackSize(), stack);
} else {

View File

@ -9,8 +9,6 @@ import org.bukkit.inventory.ItemStack;
import java.util.Collections;
import java.util.List;
import static com.earth2me.essentials.I18n.tl;
public class Commanditemdb extends EssentialsCommand {
public Commanditemdb() {
@ -39,23 +37,23 @@ public class Commanditemdb extends EssentialsCommand {
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
if (!tl("itemType").contains("{1}") && !itemId.equals("none")) {
sender.sendMessage(tl("itemId", itemId));
if (!sender.tl("itemType").contains("{1}") && !itemId.equals("none")) {
sender.sendTl("itemId", itemId);
}
if (itemHeld && itemStack.getType() != Material.AIR) {
int maxuses = itemStack.getType().getMaxDurability();
int durability = ((maxuses + 1) - itemStack.getDurability());
if (maxuses != 0) {
sender.sendMessage(tl("durability", Integer.toString(durability)));
sender.sendTl("durability", Integer.toString(durability));
}
}
final String itemNameList = ess.getItemDb().names(itemStack);
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 {
ItemStack item = user.getBase().getItemInHand();
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;
}
@ -35,6 +35,11 @@ public class Commanditemname extends EssentialsCommand {
ItemMeta im = item.getItemMeta();
im.setDisplayName(name);
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 org.bukkit.Server;
import java.util.Collection;
import static com.earth2me.essentials.I18n.tl;
public class Commandjails extends EssentialsCommand {
public Commandjails() {
@ -17,9 +13,9 @@ public class Commandjails extends EssentialsCommand {
@Override
protected void run(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception {
if (ess.getJails().getCount() < 1) {
sender.sendMessage(tl("noJailsDefined"));
sender.sendTl("noJailsDefined");
} 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.List;
import static com.earth2me.essentials.I18n.tl;
// This method contains an undocumented sub command #EasterEgg
public class Commandjump extends EssentialsCommand {
public Commandjump() {
@ -41,7 +39,7 @@ public class Commandjump extends EssentialsCommand {
loc.setPitch(cloc.getPitch());
loc.setY(loc.getY() + 1);
} catch (NullPointerException ex) {
throw new Exception(tl("jumpError"), ex);
throw new Exception(user.tl("jumpError"), ex);
}
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")) {
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"));
target.getBase().kickPlayer(kickReason);
final String senderName = sender.isPlayer() ? sender.getPlayer().getDisplayName() : Console.NAME;
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

View File

@ -1,12 +1,11 @@
package com.earth2me.essentials.commands;
import com.earth2me.essentials.CommandSource;
import com.earth2me.essentials.User;
import com.earth2me.essentials.utils.FormatUtil;
import org.bukkit.Server;
import org.bukkit.entity.Player;
import static com.earth2me.essentials.I18n.tl;
public class Commandkickall extends EssentialsCommand {
public Commandkickall() {
@ -15,16 +14,16 @@ public class Commandkickall extends EssentialsCommand {
@Override
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()) {
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);
}
}
}
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.List;
import static com.earth2me.essentials.I18n.tl;
public class Commandkill extends EssentialsLoopCommand {
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 {
final Player matchPlayer = user.getBase();
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);
server.getPluginManager().callEvent(ede);
@ -44,7 +42,7 @@ public class Commandkill extends EssentialsLoopCommand {
matchPlayer.setHealth(0);
}
sender.sendMessage(tl("kill", matchPlayer.getDisplayName()));
sender.sendTl("kill", matchPlayer.getDisplayName());
}
@Override

View File

@ -12,8 +12,6 @@ import java.util.List;
import java.util.Locale;
import java.util.logging.Level;
import static com.earth2me.essentials.I18n.tl;
public class Commandkit extends EssentialsCommand {
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 {
if (args.length < 1) {
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();
} else if (args.length > 1 && user.isAuthorized("essentials.kit.others")) {
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 {
if (args.length < 2) {
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();
} else {
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);
kit.expandItems(userTo);
sender.sendMessage(tl("kitGiveTo", kitName, userTo.getDisplayName()));
userTo.sendMessage(tl("kitReceive", kitName));
sender.sendTl("kitGiveTo", kitName, userTo.getDisplayName());
userTo.sendTl("kitReceive", kitName);
}
}
}
private void giveKits(final User userTo, final User userFrom, final String kitNames) throws Exception {
if (kitNames.isEmpty()) {
throw new Exception(tl("kitNotFound"));
throw new Exception(userFrom.tl("kitNotFound"));
}
String[] kitList = kitNames.split(",");
@ -66,7 +64,7 @@ public class Commandkit extends EssentialsCommand {
for (final String kitName : kitList) {
if (kitName.isEmpty()) {
throw new Exception(tl("kitNotFound"));
throw new Exception(userFrom.tl("kitNotFound"));
}
Kit kit = new Kit(kitName, ess);
@ -86,10 +84,10 @@ public class Commandkit extends EssentialsCommand {
kit.chargeUser(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) {
if (ess.getSettings().isDebug()) {

View File

@ -12,8 +12,6 @@ import java.util.Collections;
import java.util.List;
import java.util.Set;
import static com.earth2me.essentials.I18n.tl;
public class Commandlightning extends EssentialsLoopCommand {
int power = 5;
@ -44,14 +42,14 @@ public class Commandlightning extends EssentialsLoopCommand {
@Override
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());
if (!matchUser.isGodModeEnabled()) {
matchUser.getBase().damage(power, strike);
}
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 static com.earth2me.essentials.I18n.tl;
public class Commandlist extends EssentialsCommand {
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 {
boolean showHidden = true;
User user = null;
if (sender.isPlayer()) {
user = ess.getUser(sender.getPlayer());
if (sender.getUser() != null) {
user = sender.getUser();
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);
if (args.length > 0) {
sender.sendMessage(PlayerList.listGroupUsers(ess, playerList, args[0].toLowerCase()));
sender.sendMessage(PlayerList.listGroupUsers(ess, sender, playerList, args[0].toLowerCase()));
} else {
sendGroupedList(sender, commandLabel, playerList);
}
@ -67,9 +65,9 @@ public class Commandlist extends EssentialsCommand {
outputUserList.addAll(matchedList);
int limit = Integer.parseInt(groupValue);
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 {
sender.sendMessage(PlayerList.outputFormat(oConfigGroup, PlayerList.listUsers(ess, outputUserList, ", ")));
sender.sendMessage(PlayerList.outputFormat(sender, oConfigGroup, PlayerList.listUsers(ess, sender, outputUserList, ", ")));
}
continue;
}
@ -82,7 +80,7 @@ public class Commandlist extends EssentialsCommand {
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();
@ -107,13 +105,13 @@ public class Commandlist extends EssentialsCommand {
String groupName = asterisk.isEmpty() ? users.get(0).getGroup() : onlineGroup;
if (ess.getPermissionsHandler().getName().equals("ConfigPermissions")) {
groupName = tl("connectedPlayers");
groupName = sender.tl("connectedPlayers");
}
if (users == null || users.isEmpty()) {
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.UUID;
import static com.earth2me.essentials.I18n.tl;
public class Commandmail extends EssentialsCommand {
private static int mailsPerMinute = 0;
@ -31,7 +29,7 @@ public class Commandmail extends EssentialsCommand {
if (args.length >= 1 && "read".equalsIgnoreCase(args[0])) {
final List<String> mail = user.getMails();
if (mail.isEmpty()) {
user.sendMessage(tl("noMail"));
user.sendTl("noMail");
throw new NoChargeException();
}
@ -39,26 +37,26 @@ public class Commandmail extends EssentialsCommand {
final TextPager pager = new TextPager(input);
pager.showPage(args.length > 1 ? args[1] : null, null, commandLabel + " " + args[0], user.getSource());
user.sendMessage(tl("mailClear"));
user.sendTl("mailClear");
return;
}
if (args.length >= 3 && "send".equalsIgnoreCase(args[0])) {
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()) {
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);
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) {
throw new Exception(tl("mailTooLong"));
throw new Exception(user.tl("mailTooLong"));
}
if (!u.isIgnoredPlayer(user)) {
@ -68,32 +66,32 @@ public class Commandmail extends EssentialsCommand {
}
mailsPerMinute++;
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);
return;
}
if (args.length > 1 && "sendall".equalsIgnoreCase(args[0])) {
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(),
FormatUtil.formatMessage(user, "essentials.mail", StringUtil.sanitizeString(FormatUtil.stripFormat(getFinalArg(args, 1)))))));
user.sendMessage(tl("mailSent"));
ess.runTaskAsynchronously(new SendAll("mailFormat", user.getName(),
FormatUtil.formatMessage(user, "essentials.mail", StringUtil.sanitizeString(FormatUtil.stripFormat(getFinalArg(args, 1))))));
user.sendTl("mailSent");
return;
}
if (args.length >= 1 && "clear".equalsIgnoreCase(args[0])) {
if (user.getMails() == null || user.getMails().isEmpty()) {
user.sendMessage(tl("noMail"));
user.sendTl("noMail");
throw new NoChargeException();
}
user.setMails(null);
user.sendMessage(tl("mailCleared"));
user.sendTl("mailCleared");
return;
}
throw new NotEnoughArgumentsException();
@ -102,29 +100,29 @@ public class Commandmail extends EssentialsCommand {
@Override
protected void run(Server server, CommandSource sender, String commandLabel, String[] args) throws Exception {
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])) {
throw new Exception(tl("onlyPlayers", commandLabel + " clear"));
throw new Exception(sender.tl("onlyPlayers", commandLabel + " clear"));
} else if (args.length >= 3 && "send".equalsIgnoreCase(args[0])) {
User u = getPlayer(server, args[1], true, true);
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))));
sender.sendMessage(tl("mailSent"));
u.addMail(u.tl("mailFormat", "Server", FormatUtil.replaceFormat(getFinalArg(args, 2))));
sender.sendTl("mailSent");
return;
} else if (args.length >= 2 && "sendall".equalsIgnoreCase(args[0])) {
ess.runTaskAsynchronously(new SendAll(tl("mailFormat", "Server", FormatUtil.replaceFormat(getFinalArg(args, 1)))));
sender.sendMessage(tl("mailSent"));
ess.runTaskAsynchronously(new SendAll("mailFormat", "Server", FormatUtil.replaceFormat(getFinalArg(args, 1))));
sender.sendTl("mailSent");
return;
} else if (args.length >= 2) {
//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);
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))));
sender.sendMessage(tl("mailSent"));
u.addMail(u.tl("mailFormat", "Server", FormatUtil.replaceFormat(getFinalArg(args, 1))));
sender.sendTl("mailSent");
return;
}
throw new NotEnoughArgumentsException();
@ -132,10 +130,12 @@ public class Commandmail extends EssentialsCommand {
private class SendAll implements Runnable {
String message;
String string;
Object objects;
public SendAll(String message) {
this.message = message;
public SendAll(String string, Object... objects) {
this.string = string;
this.objects = objects;
}
@Override
@ -143,7 +143,7 @@ public class Commandmail extends EssentialsCommand {
for (UUID userid : ess.getUserMap().getAllUniqueUsers()) {
User user = ess.getUserMap().getUser(userid);
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.Set;
import static com.earth2me.essentials.I18n.tl;
public class Commandme extends EssentialsCommand {
public Commandme() {
@ -24,7 +22,7 @@ public class Commandme extends EssentialsCommand {
@Override
public void run(Server server, User user, String commandLabel, String[] args) throws Exception {
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) {
@ -36,9 +34,8 @@ public class Commandme extends EssentialsCommand {
user.setDisplayNick();
int radius = ess.getSettings().getChatRadius();
String toSend = tl("action", user.getDisplayName(), message);
if (radius < 1) {
ess.broadcastMessage(user, toSend);
ess.broadcastTl(user, "action", user.getDisplayName(), message);
return;
}
@ -74,11 +71,11 @@ public class Commandme extends EssentialsCommand {
}
if (outList.size() < 2) {
user.sendMessage(tl("localNoOne"));
user.sendTl("localNoOne");
}
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);
message = FormatUtil.replaceFormat(message);
ess.getServer().broadcastMessage(tl("action", "@", message));
ess.broadcastTl(sender, "action", "@", message);
}
@Override

View File

@ -6,8 +6,6 @@ import org.bukkit.inventory.ItemStack;
import java.util.Locale;
import static com.earth2me.essentials.I18n.tl;
public class Commandmore extends EssentialsCommand {
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 {
final ItemStack stack = user.getItemInHand();
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())) {
throw new Exception(tl("fullStack"));
throw new Exception(user.tl("fullStack"));
}
final String itemname = stack.getType().toString().toLowerCase(Locale.ENGLISH).replace("_", "");
if (!user.canSpawnItem(stack.getType())) {
throw new Exception(tl("cantSpawnItem", itemname));
throw new Exception(user.tl("cantSpawnItem", itemname));
}
if (user.isAuthorized("essentials.oversizedstacks")) {
stack.setAmount(ess.getSettings().getOversizedStackSize());

View File

@ -1,7 +1,5 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n.tl;
import com.earth2me.essentials.CommandSource;
import com.earth2me.essentials.Console;
import com.earth2me.essentials.User;
@ -29,7 +27,7 @@ public class Commandmsg extends EssentialsLoopCommand {
if (sender.isPlayer()) {
User user = ess.getUser(sender.getPlayer());
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);
canWildcard = user.isAuthorized("essentials.msg.multiple");

View File

@ -4,8 +4,6 @@ import com.earth2me.essentials.CommandSource;
import com.earth2me.essentials.User;
import org.bukkit.Server;
import static com.earth2me.essentials.I18n.tl;
public class Commandmsgtoggle extends EssentialsToggleCommand {
public Commandmsgtoggle() {
@ -30,9 +28,9 @@ public class Commandmsgtoggle extends EssentialsToggleCommand {
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())) {
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 (sender.isPlayer() && !ess.getUser(sender.getPlayer()).isAuthorized("essentials.mute.offline")) {
throw new Exception(tl("muteExemptOffline"));
throw new Exception(sender.tl("muteExemptOffline"));
}
} else {
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);
final boolean muted = user.getMuted();
String muteTime = DateUtil.formatDateDiff(muteTimestamp);
String muteTime = DateUtil.formatDateDiff(sender, muteTimestamp);
if (nomatch) {
sender.sendMessage(tl("userUnknown", user.getName()));
sender.sendTl("userUnknown", user.getName());
}
if (muted) {
if (muteTimestamp > 0) {
if (!user.hasMuteReason()) {
sender.sendMessage(tl("mutedPlayerFor", user.getDisplayName(), muteTime));
user.sendMessage(tl("playerMutedFor", muteTime));
sender.sendTl("mutedPlayerFor", user.getDisplayName(), muteTime);
user.sendTl("playerMutedFor", muteTime);
} else {
sender.sendMessage(tl("mutedPlayerForReason", user.getDisplayName(), muteTime, user.getMuteReason()));
user.sendMessage(tl("playerMutedForReason", muteTime, user.getMuteReason()));
sender.sendTl("mutedPlayerForReason", user.getDisplayName(), muteTime, user.getMuteReason());
user.sendTl("playerMutedForReason", muteTime, user.getMuteReason());
}
} else {
if (!user.hasMuteReason()) {
sender.sendMessage(tl("mutedPlayer", user.getDisplayName()));
user.sendMessage(tl("playerMuted"));
sender.sendTl("mutedPlayer", user.getDisplayName());
user.sendTl("playerMuted");
} else {
sender.sendMessage(tl("mutedPlayerReason", user.getDisplayName(), user.getMuteReason()));
user.sendMessage(tl("playerMutedReason", user.getMuteReason()));
sender.sendTl("mutedPlayerReason", user.getDisplayName(), user.getMuteReason());
user.sendTl("playerMutedReason", user.getMuteReason());
}
}
final String message;
if (muteTimestamp > 0) {
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 {
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 {
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 {
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 {
sender.sendMessage(tl("unmutedPlayer", user.getDisplayName()));
user.sendMessage(tl("playerUnmuted"));
sender.sendTl("unmutedPlayer", user.getDisplayName());
user.sendTl("playerUnmuted");
}
}
}

View File

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

View File

@ -12,8 +12,6 @@ import java.util.Collections;
import java.util.List;
import java.util.Locale;
import static com.earth2me.essentials.I18n.tl;
public class Commandnick extends EssentialsLoopCommand {
public Commandnick() {
@ -26,15 +24,15 @@ public class Commandnick extends EssentialsLoopCommand {
throw new NotEnoughArgumentsException();
}
if (!ess.getSettings().changeDisplayName()) {
throw new Exception(tl("nickDisplayName"));
throw new Exception(user.tl("nickDisplayName"));
}
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);
user.sendMessage(tl("nickChanged"));
user.sendTl("nickChanged");
} 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);
}
}
@ -45,11 +43,11 @@ public class Commandnick extends EssentialsLoopCommand {
throw new NotEnoughArgumentsException();
}
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);
sender.sendMessage(tl("nickChanged"));
sender.sendTl("nickChanged");
}
@Override
@ -57,34 +55,34 @@ public class Commandnick extends EssentialsLoopCommand {
final String nick = args[0];
if ("off".equalsIgnoreCase(nick)) {
setNickname(server, sender, target, null);
target.sendMessage(tl("nickNoMore"));
target.sendTl("nickNoMore");
} else if (target.getName().equalsIgnoreCase(nick)) {
String oldName = target.getDisplayName();
setNickname(server, sender, target, nick);
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)) {
throw new NotEnoughArgumentsException(tl("nickInUse"));
throw new NotEnoughArgumentsException(sender.tl("nickInUse"));
} else {
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);
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()) {
throw new Exception(tl("nickTooLong"));
throw new Exception(sender.tl("nickTooLong"));
} 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())) {
throw new Exception(tl("nickNamesOnlyColorChanges"));
throw new Exception(sender.tl("nickNamesOnlyColorChanges"));
} 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;
}

View File

@ -12,8 +12,6 @@ import java.util.Collection;
import java.util.Collections;
import java.util.List;
import static com.earth2me.essentials.I18n.tl;
public class Commandnuke extends EssentialsCommand {
public Commandnuke() {
@ -38,7 +36,7 @@ public class Commandnuke extends EssentialsCommand {
if (player == null) {
continue;
}
player.sendMessage(tl("nuke"));
ess.getUser(player).sendTl("nuke");
final Location loc = player.getLocation();
final World world = loc.getWorld();
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.List;
import static com.earth2me.essentials.I18n.tl;
public class Commandpay extends EssentialsLoopCommand {
BigDecimal amount;
@ -34,7 +32,7 @@ public class Commandpay extends EssentialsLoopCommand {
}
if (args[1].contains("-")) {
throw new Exception(tl("payMustBePositive"));
throw new Exception(user.tl("payMustBePositive"));
}
String stringAmount = args[1].replaceAll("[^0-9\\.]", "");
@ -45,12 +43,12 @@ public class Commandpay extends EssentialsLoopCommand {
amount = new BigDecimal(stringAmount);
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);
if (informToConfirm) {
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());
try {
if (!player.isAcceptingPay()) {
sender.sendMessage(tl("notAcceptingPay", player.getDisplayName()));
sender.sendTl("notAcceptingPay", player.getDisplayName());
return;
}
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);
Trade.log("Command", "Pay", "Player", user.getName(), new Trade(amount, ess), player.getName(), new Trade(amount, ess), user.getLocation(), ess);
} catch (MaxMoneyException ex) {
sender.sendMessage(tl("maxMoney"));
sender.sendTl("maxMoney");
try {
user.setMoney(user.getMoney().add(amount));
} catch (MaxMoneyException ignored) {

View File

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

View File

@ -1,8 +1,5 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n.tl;
import com.earth2me.essentials.I18n;
import com.earth2me.essentials.User;
import org.bukkit.Server;
@ -23,9 +20,9 @@ public class Commandpaytoggle extends EssentialsCommand {
}
user.setAcceptingPay(acceptingPay);
if (acceptingPay) {
user.sendMessage(tl("payToggleOn"));
user.sendTl("payToggleOn");
} 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 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
public class Commandping extends EssentialsCommand {
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 {
if (args.length < 1) {
sender.sendMessage(tl("pong"));
sender.sendTl("pong");
} else {
sender.sendMessage(FormatUtil.replaceFormat(getFinalArg(args, 0)));
}

View File

@ -1,6 +1,5 @@
package com.earth2me.essentials.commands;
import org.bukkit.DyeColor;
import com.google.common.collect.Lists;
import com.earth2me.essentials.MetaItemStack;
@ -11,7 +10,6 @@ import org.bukkit.Material;
import org.bukkit.Server;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.PotionMeta;
import org.bukkit.potion.PotionData;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
@ -22,8 +20,6 @@ import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
import static com.earth2me.essentials.I18n.tl;
import net.ess3.nms.refl.ReflUtil;
@ -44,7 +40,7 @@ public class Commandpotion extends EssentialsCommand {
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;
@ -72,14 +68,14 @@ public class Commandpotion extends EssentialsCommand {
pmeta = (PotionMeta) mStack.getItemStack().getItemMeta();
stack.setItemMeta(pmeta);
} else {
user.sendMessage(tl("invalidPotion"));
user.sendTl("invalidPotion");
throw new NotEnoughArgumentsException();
}
}
}
} 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.Locale;
import static com.earth2me.essentials.I18n.tl;
public class Commandpowertool extends EssentialsCommand {
public Commandpowertool() {
@ -45,12 +43,12 @@ public class Commandpowertool extends EssentialsCommand {
// check to see if this is a clear all command
if (command != null && command.equalsIgnoreCase("d:")) {
user.clearAllPowertools();
sender.sendMessage(tl("powerToolClearAll"));
sender.sendTl("powerToolClearAll");
return;
}
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("_", " ");
@ -58,28 +56,28 @@ public class Commandpowertool extends EssentialsCommand {
if (command != null && !command.isEmpty()) {
if (command.equalsIgnoreCase("l:")) {
if (powertools == null || powertools.isEmpty()) {
throw new Exception(tl("powerToolListEmpty", itemName));
throw new Exception(user.tl("powerToolListEmpty", itemName));
} else {
sender.sendMessage(tl("powerToolList", StringUtil.joinList(powertools), itemName));
sender.sendTl("powerToolList", StringUtil.joinList(powertools), itemName);
}
throw new NoChargeException();
}
if (command.startsWith("r:")) {
command = command.substring(2);
if (!powertools.contains(command)) {
throw new Exception(tl("powerToolNoSuchCommandAssigned", command, itemName));
throw new Exception(user.tl("powerToolNoSuchCommandAssigned", command, itemName));
}
powertools.remove(command);
sender.sendMessage(tl("powerToolRemove", command, itemName));
sender.sendTl("powerToolRemove", command, itemName);
} else {
if (command.startsWith("a:")) {
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);
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()) {
// Replace all commands with this one
@ -89,18 +87,18 @@ public class Commandpowertool extends EssentialsCommand {
}
powertools.add(command);
sender.sendMessage(tl("powerToolAttach", StringUtil.joinList(powertools), itemName));
sender.sendTl("powerToolAttach", StringUtil.joinList(powertools), itemName);
}
} else {
if (powertools != null) {
powertools.clear();
}
sender.sendMessage(tl("powerToolRemoveAll", itemName));
sender.sendTl("powerToolRemoveAll", itemName);
}
if (!user.arePowerToolsEnabled()) {
user.setPowerToolsEnabled(true);
user.sendMessage(tl("powerToolsEnabled"));
user.sendTl("powerToolsEnabled");
}
user.setPowertool(itemStack, powertools);
}

View File

@ -3,8 +3,6 @@ package com.earth2me.essentials.commands;
import com.earth2me.essentials.User;
import org.bukkit.Server;
import static com.earth2me.essentials.I18n.tl;
public class Commandpowertooltoggle extends EssentialsCommand {
public Commandpowertooltoggle() {
@ -14,9 +12,9 @@ public class Commandpowertooltoggle extends EssentialsCommand {
@Override
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception {
if (!user.hasPowerTools()) {
user.sendMessage(tl("noPowerTools"));
user.sendTl("noPowerTools");
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 static com.earth2me.essentials.I18n.tl;
public class Commandptime extends EssentialsCommand {
private static final Set<String> getAliases = new HashSet<>();
@ -46,7 +44,7 @@ public class Commandptime extends EssentialsCommand {
if (sender.isPlayer()) {
User user = ess.getUser(sender.getPlayer());
if (user != null && (!users.contains(user) || users.size() > 1) && !user.isAuthorized("essentials.ptime.others")) {
user.sendMessage(tl("pTimeOthersPermission"));
user.sendTl("pTimeOthersPermission");
return;
}
}
@ -81,18 +79,18 @@ public class Commandptime extends EssentialsCommand {
*/
private void getUsersTime(final CommandSource sender, final Collection<User> users) {
if (users.size() > 1) {
sender.sendMessage(tl("pTimePlayers"));
sender.sendTl("pTimePlayers");
}
for (User user : users) {
if (user.getBase().getPlayerTimeOffset() == 0) {
sender.sendMessage(tl("pTimeNormal", user.getName()));
sender.sendTl("pTimeNormal", user.getName());
} else {
String time = DescParseTickFormat.format(user.getBase().getPlayerTime());
if (!user.getBase().isPlayerTimeRelative()) {
sender.sendMessage(tl("pTimeCurrentFixed", user.getName(), time));
sender.sendTl("pTimeCurrentFixed", user.getName(), time);
} 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
if (ticks == null) {
sender.sendMessage(tl("pTimeReset", msg.toString()));
sender.sendTl("pTimeReset", msg.toString());
} else {
String time = DescParseTickFormat.format(ticks);
if (!relative) {
sender.sendMessage(tl("pTimeSetFixed", time, msg.toString()));
sender.sendTl("pTimeSetFixed", time, msg.toString());
} 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