Remove CommonPlaceholders#displayName methods

I18n argument mutation already converts legacy color codes
to parsed MiniMessage. This was redundant and was creating
issues with other parts of the codebase.
This commit is contained in:
Josh Roy 2024-02-09 23:01:20 -05:00
parent 3d9d3a3254
commit 8a57856c96
51 changed files with 100 additions and 180 deletions

View File

@ -455,7 +455,7 @@ public class EssentialsPlayerListener implements Listener, FakeAccessor {
user.getBase().setAllowFlight(true); user.getBase().setAllowFlight(true);
user.getBase().setFlying(true); user.getBase().setFlying(true);
if (ess.getSettings().isSendFlyEnableOnJoin()) { if (ess.getSettings().isSendFlyEnableOnJoin()) {
user.sendTl("flyMode", CommonPlaceholders.enableDisable(user.getSource(), true), CommonPlaceholders.displayName(user)); user.sendTl("flyMode", CommonPlaceholders.enableDisable(user.getSource(), true), user.getDisplayName());
} }
} }
} }

View File

@ -7,7 +7,6 @@ import com.earth2me.essentials.economy.EconomyLayers;
import com.earth2me.essentials.messaging.IMessageRecipient; import com.earth2me.essentials.messaging.IMessageRecipient;
import com.earth2me.essentials.messaging.SimpleMessageRecipient; import com.earth2me.essentials.messaging.SimpleMessageRecipient;
import com.earth2me.essentials.utils.AdventureUtil; import com.earth2me.essentials.utils.AdventureUtil;
import com.earth2me.essentials.utils.CommonPlaceholders;
import com.earth2me.essentials.utils.DateUtil; import com.earth2me.essentials.utils.DateUtil;
import com.earth2me.essentials.utils.EnumUtil; import com.earth2me.essentials.utils.EnumUtil;
import com.earth2me.essentials.utils.FormatUtil; import com.earth2me.essentials.utils.FormatUtil;
@ -16,7 +15,6 @@ import com.earth2me.essentials.utils.TriState;
import com.earth2me.essentials.utils.VersionUtil; import com.earth2me.essentials.utils.VersionUtil;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import net.ess3.api.IEssentials; import net.ess3.api.IEssentials;
import net.ess3.api.IUser;
import net.ess3.api.MaxMoneyException; import net.ess3.api.MaxMoneyException;
import net.ess3.api.events.AfkStatusChangeEvent; import net.ess3.api.events.AfkStatusChangeEvent;
import net.ess3.api.events.JailStatusChangeEvent; import net.ess3.api.events.JailStatusChangeEvent;
@ -250,7 +248,7 @@ public class User extends UserData implements Comparable<User>, IMessageRecipien
setMoney(getMoney().add(value), cause); setMoney(getMoney().add(value), cause);
sendTl("addedToAccount", NumberUtil.displayCurrency(value, ess)); sendTl("addedToAccount", NumberUtil.displayCurrency(value, ess));
if (initiator != null) { if (initiator != null) {
initiator.sendTl("addedToOthersAccount", NumberUtil.displayCurrency(value, ess), CommonPlaceholders.displayName((IUser) this), NumberUtil.displayCurrency(getMoney(), ess)); initiator.sendTl("addedToOthersAccount", NumberUtil.displayCurrency(value, ess), getDisplayName(), NumberUtil.displayCurrency(getMoney(), ess));
} }
} }
@ -267,8 +265,8 @@ public class User extends UserData implements Comparable<User>, IMessageRecipien
if (canAfford(value)) { if (canAfford(value)) {
setMoney(getMoney().subtract(value), cause); setMoney(getMoney().subtract(value), cause);
reciever.setMoney(reciever.getMoney().add(value), cause); reciever.setMoney(reciever.getMoney().add(value), cause);
sendTl("moneySentTo", NumberUtil.displayCurrency(value, ess), CommonPlaceholders.displayName((IUser) reciever)); sendTl("moneySentTo", NumberUtil.displayCurrency(value, ess), reciever.getDisplayName());
reciever.sendTl("moneyRecievedFrom", NumberUtil.displayCurrency(value, ess), CommonPlaceholders.displayName((IUser) this)); reciever.sendTl("moneyRecievedFrom", NumberUtil.displayCurrency(value, ess), getDisplayName());
final TransactionEvent transactionEvent = new TransactionEvent(this.getSource(), reciever, value); final TransactionEvent transactionEvent = new TransactionEvent(this.getSource(), reciever, value);
ess.getServer().getPluginManager().callEvent(transactionEvent); ess.getServer().getPluginManager().callEvent(transactionEvent);
} else { } else {
@ -297,7 +295,7 @@ public class User extends UserData implements Comparable<User>, IMessageRecipien
} }
sendTl("takenFromAccount", NumberUtil.displayCurrency(value, ess)); sendTl("takenFromAccount", NumberUtil.displayCurrency(value, ess));
if (initiator != null) { if (initiator != null) {
initiator.sendTl("takenFromOthersAccount", NumberUtil.displayCurrency(value, ess), CommonPlaceholders.displayName((IUser) this), NumberUtil.displayCurrency(getMoney(), ess)); initiator.sendTl("takenFromOthersAccount", NumberUtil.displayCurrency(value, ess), getDisplayName(), NumberUtil.displayCurrency(getMoney(), ess));
} }
} }
@ -409,7 +407,7 @@ public class User extends UserData implements Comparable<User>, IMessageRecipien
} }
teleportRequestQueue.remove(playerUsername); teleportRequestQueue.remove(playerUsername);
if (inform) { if (inform) {
sendTl("requestTimedOutFrom", CommonPlaceholders.displayName((IUser) ess.getUser(request.getRequesterUuid()))); sendTl("requestTimedOutFrom", ess.getUser(request.getRequesterUuid()).getDisplayName());
} }
return null; return null;
} }
@ -443,7 +441,7 @@ public class User extends UserData implements Comparable<User>, IMessageRecipien
} }
} else { } else {
if (inform) { if (inform) {
sendTl("requestTimedOutFrom", CommonPlaceholders.displayName((IUser) ess.getUser(request.getRequesterUuid()))); sendTl("requestTimedOutFrom", ess.getUser(request.getRequesterUuid()).getDisplayName());
} }
teleportRequestQueue.remove(key); teleportRequestQueue.remove(key);
} }
@ -806,9 +804,9 @@ public class User extends UserData implements Comparable<User>, IMessageRecipien
if (broadcast && !isHidden() && !isAfk()) { if (broadcast && !isHidden() && !isAfk()) {
setDisplayNick(); setDisplayNick();
if (ess.getSettings().broadcastAfkMessage()) { if (ess.getSettings().broadcastAfkMessage()) {
ess.broadcastTl(this, u -> u == this, "userIsNotAway", CommonPlaceholders.displayName((IUser) this)); ess.broadcastTl(this, u -> u == this, "userIsNotAway", getDisplayName());
} }
sendTl("userIsNotAwaySelf", CommonPlaceholders.displayName((IUser) this)); sendTl("userIsNotAwaySelf", getDisplayName());
} }
} }
lastActivity = System.currentTimeMillis(); lastActivity = System.currentTimeMillis();
@ -861,9 +859,9 @@ public class User extends UserData implements Comparable<User>, IMessageRecipien
if (isAfk() && !isHidden()) { if (isAfk() && !isHidden()) {
setDisplayNick(); setDisplayNick();
if (ess.getSettings().broadcastAfkMessage()) { if (ess.getSettings().broadcastAfkMessage()) {
ess.broadcastTl(this, u -> u == this, "userIsAway", CommonPlaceholders.displayName((IUser) this)); ess.broadcastTl(this, u -> u == this, "userIsAway", getDisplayName());
} }
sendTl("userIsAwaySelf", CommonPlaceholders.displayName((IUser) this)); sendTl("userIsAwaySelf", getDisplayName());
} }
} }
} }

View File

@ -2,9 +2,7 @@ package com.earth2me.essentials.commands;
import com.earth2me.essentials.CommandSource; import com.earth2me.essentials.CommandSource;
import com.earth2me.essentials.User; import com.earth2me.essentials.User;
import com.earth2me.essentials.utils.CommonPlaceholders;
import com.earth2me.essentials.utils.DateUtil; import com.earth2me.essentials.utils.DateUtil;
import net.ess3.api.IUser;
import net.ess3.api.TranslatableException; import net.ess3.api.TranslatableException;
import net.ess3.api.events.AfkStatusChangeEvent; import net.ess3.api.events.AfkStatusChangeEvent;
import org.bukkit.Server; import org.bukkit.Server;
@ -97,10 +95,10 @@ public class Commandafk extends EssentialsCommand {
} }
if (!tlKey.isEmpty() && ess.getSettings().broadcastAfkMessage()) { if (!tlKey.isEmpty() && ess.getSettings().broadcastAfkMessage()) {
// exclude user from receiving general AFK announcement in favor of personal message // exclude user from receiving general AFK announcement in favor of personal message
ess.broadcastTl(user, u -> u == user, tlKey, CommonPlaceholders.displayName((IUser) user), message); ess.broadcastTl(user, u -> u == user, tlKey, user.getDisplayName(), message);
} }
if (!selfTlKey.isEmpty()) { if (!selfTlKey.isEmpty()) {
user.sendTl(selfTlKey, CommonPlaceholders.displayName((IUser) user), message); user.sendTl(selfTlKey, user.getDisplayName(), message);
} }
user.setDisplayNick(); // Set this again after toggling user.setDisplayNick(); // Set this again after toggling
} }

View File

@ -2,9 +2,7 @@ package com.earth2me.essentials.commands;
import com.earth2me.essentials.CommandSource; import com.earth2me.essentials.CommandSource;
import com.earth2me.essentials.User; import com.earth2me.essentials.User;
import com.earth2me.essentials.utils.CommonPlaceholders;
import com.earth2me.essentials.utils.NumberUtil; import com.earth2me.essentials.utils.NumberUtil;
import net.ess3.api.IUser;
import org.bukkit.Server; import org.bukkit.Server;
import java.util.Collections; import java.util.Collections;
@ -22,14 +20,14 @@ public class Commandbalance extends EssentialsCommand {
} }
final User target = getPlayer(server, args, 0, false, true); final User target = getPlayer(server, args, 0, false, true);
sender.sendTl("balanceOther", target.isHidden() ? target.getName() : CommonPlaceholders.displayName((IUser) target), NumberUtil.displayCurrency(target.getMoney(), ess)); sender.sendTl("balanceOther", target.isHidden() ? target.getName() : target.getDisplayName(), NumberUtil.displayCurrency(target.getMoney(), ess));
} }
@Override @Override
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception { public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception {
if (args.length == 1 && user.isAuthorized("essentials.balance.others")) { if (args.length == 1 && user.isAuthorized("essentials.balance.others")) {
final User target = getPlayer(server, args, 0, true, true); final User target = getPlayer(server, args, 0, true, true);
user.sendTl("balanceOther", target.isHidden() ? target.getName() : CommonPlaceholders.displayName((IUser) target), NumberUtil.displayCurrency(target.getMoney(), ess)); user.sendTl("balanceOther", target.isHidden() ? target.getName() : target.getDisplayName(), NumberUtil.displayCurrency(target.getMoney(), ess));
} else if (args.length < 2) { } else if (args.length < 2) {
user.sendTl("balance", NumberUtil.displayCurrency(user.getMoney(), ess)); user.sendTl("balance", NumberUtil.displayCurrency(user.getMoney(), ess));
} else { } else {

View File

@ -2,8 +2,6 @@ package com.earth2me.essentials.commands;
import com.earth2me.essentials.CommandSource; import com.earth2me.essentials.CommandSource;
import com.earth2me.essentials.User; import com.earth2me.essentials.User;
import com.earth2me.essentials.utils.CommonPlaceholders;
import net.ess3.api.IUser;
import org.bukkit.Server; import org.bukkit.Server;
import java.util.Collections; import java.util.Collections;
@ -22,7 +20,7 @@ public class Commandburn extends EssentialsCommand {
final User user = getPlayer(server, sender, args, 0); final User user = getPlayer(server, sender, args, 0);
user.getBase().setFireTicks(Integer.parseInt(args[1]) * 20); user.getBase().setFireTicks(Integer.parseInt(args[1]) * 20);
sender.sendTl("burnMsg", CommonPlaceholders.displayName((IUser) user), Integer.parseInt(args[1])); sender.sendTl("burnMsg", user.getDisplayName(), Integer.parseInt(args[1]));
} }
@Override @Override

View File

@ -3,10 +3,8 @@ package com.earth2me.essentials.commands;
import com.earth2me.essentials.ChargeException; import com.earth2me.essentials.ChargeException;
import com.earth2me.essentials.CommandSource; import com.earth2me.essentials.CommandSource;
import com.earth2me.essentials.User; import com.earth2me.essentials.User;
import com.earth2me.essentials.utils.CommonPlaceholders;
import com.earth2me.essentials.utils.NumberUtil; import com.earth2me.essentials.utils.NumberUtil;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import net.ess3.api.IUser;
import net.ess3.api.MaxMoneyException; import net.ess3.api.MaxMoneyException;
import net.ess3.api.TranslatableException; import net.ess3.api.TranslatableException;
import net.ess3.api.events.UserBalanceUpdateEvent; import net.ess3.api.events.UserBalanceUpdateEvent;
@ -67,7 +65,7 @@ public class Commandeco extends EssentialsLoopCommand {
final boolean aboveMax = userAmount.compareTo(maxBal) > 0; final boolean aboveMax = userAmount.compareTo(maxBal) > 0;
player.setMoney(underMin ? minBal : aboveMax ? maxBal : userAmount, UserBalanceUpdateEvent.Cause.COMMAND_ECO); player.setMoney(underMin ? minBal : aboveMax ? maxBal : userAmount, UserBalanceUpdateEvent.Cause.COMMAND_ECO);
player.sendTl("setBal", NumberUtil.displayCurrency(player.getMoney(), ess)); player.sendTl("setBal", NumberUtil.displayCurrency(player.getMoney(), ess));
sender.sendTl("setBalOthers", CommonPlaceholders.displayName((IUser) player), NumberUtil.displayCurrency(player.getMoney(), ess)); sender.sendTl("setBalOthers", player.getDisplayName(), NumberUtil.displayCurrency(player.getMoney(), ess));
break; break;
} }
} }

View File

@ -9,7 +9,6 @@ import com.earth2me.essentials.economy.EconomyLayers;
import com.earth2me.essentials.userstorage.ModernUserMap; import com.earth2me.essentials.userstorage.ModernUserMap;
import com.earth2me.essentials.utils.AdventureUtil; import com.earth2me.essentials.utils.AdventureUtil;
import com.earth2me.essentials.utils.CommandMapUtil; import com.earth2me.essentials.utils.CommandMapUtil;
import com.earth2me.essentials.utils.CommonPlaceholders;
import com.earth2me.essentials.utils.DateUtil; import com.earth2me.essentials.utils.DateUtil;
import com.earth2me.essentials.utils.EnumUtil; import com.earth2me.essentials.utils.EnumUtil;
import com.earth2me.essentials.utils.FloatUtil; import com.earth2me.essentials.utils.FloatUtil;
@ -22,7 +21,6 @@ import com.google.gson.JsonArray;
import com.google.gson.JsonNull; import com.google.gson.JsonNull;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import com.google.gson.JsonPrimitive; import com.google.gson.JsonPrimitive;
import net.ess3.api.IUser;
import net.ess3.api.TranslatableException; import net.ess3.api.TranslatableException;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor; import net.kyori.adventure.text.format.NamedTextColor;
@ -485,7 +483,7 @@ public class Commandessentials extends EssentialsCommand {
} }
final User user = getPlayer(server, args, 1, true, true); final User user = getPlayer(server, args, 1, true, true);
user.reset(); user.reset();
sender.sendMessage("Reset Essentials userdata for player: " + CommonPlaceholders.displayName((IUser) user)); sender.sendMessage("Reset Essentials userdata for player: " + user.getDisplayName());
} }
// Toggles debug mode. // Toggles debug mode.

View File

@ -4,8 +4,6 @@ import com.earth2me.essentials.CommandSource;
import com.earth2me.essentials.IUser; import com.earth2me.essentials.IUser;
import com.earth2me.essentials.User; import com.earth2me.essentials.User;
import com.earth2me.essentials.craftbukkit.SetExpFix; import com.earth2me.essentials.craftbukkit.SetExpFix;
import com.earth2me.essentials.messaging.IMessageRecipient;
import com.earth2me.essentials.utils.CommonPlaceholders;
import com.earth2me.essentials.utils.NumberUtil; import com.earth2me.essentials.utils.NumberUtil;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import org.bukkit.Server; import org.bukkit.Server;
@ -99,7 +97,7 @@ public class Commandexp extends EssentialsLoopCommand {
} }
private void showExp(final CommandSource sender, final IUser target) { private void showExp(final CommandSource sender, final IUser target) {
sender.sendTl("exp", CommonPlaceholders.displayNameRecipient((IMessageRecipient) target), SetExpFix.getTotalExperience(target.getBase()), target.getBase().getLevel(), SetExpFix.getExpUntilNextLevel(target.getBase())); sender.sendTl("exp", target.getDisplayName(), SetExpFix.getTotalExperience(target.getBase()), target.getBase().getLevel(), SetExpFix.getExpUntilNextLevel(target.getBase()));
} }
//TODO: Limit who can give negative exp? //TODO: Limit who can give negative exp?
@ -131,7 +129,7 @@ public class Commandexp extends EssentialsLoopCommand {
amount = 0L; amount = 0L;
} }
SetExpFix.setTotalExperience(target.getBase(), (int) amount); SetExpFix.setTotalExperience(target.getBase(), (int) amount);
sender.sendTl("expSet", CommonPlaceholders.displayNameRecipient((IMessageRecipient) target), amount); sender.sendTl("expSet", target.getDisplayName(), amount);
} }
@Override @Override

View File

@ -2,8 +2,6 @@ package com.earth2me.essentials.commands;
import com.earth2me.essentials.CommandSource; import com.earth2me.essentials.CommandSource;
import com.earth2me.essentials.User; import com.earth2me.essentials.User;
import com.earth2me.essentials.utils.CommonPlaceholders;
import net.ess3.api.IUser;
import org.bukkit.Server; import org.bukkit.Server;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -38,7 +36,7 @@ public class Commandext extends EssentialsLoopCommand {
@Override @Override
protected void updatePlayer(final Server server, final CommandSource sender, final User player, final String[] args) { protected void updatePlayer(final Server server, final CommandSource sender, final User player, final String[] args) {
extPlayer(player.getBase()); extPlayer(player.getBase());
sender.sendTl("extinguishOthers", CommonPlaceholders.displayName((IUser) player)); sender.sendTl("extinguishOthers", player.getDisplayName());
} }
private void extPlayer(final Player player) { private void extPlayer(final Player player) {

View File

@ -2,8 +2,6 @@ package com.earth2me.essentials.commands;
import com.earth2me.essentials.CommandSource; import com.earth2me.essentials.CommandSource;
import com.earth2me.essentials.User; import com.earth2me.essentials.User;
import com.earth2me.essentials.utils.CommonPlaceholders;
import net.ess3.api.IUser;
import org.bukkit.Server; import org.bukkit.Server;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.entity.FoodLevelChangeEvent; import org.bukkit.event.entity.FoodLevelChangeEvent;
@ -44,7 +42,7 @@ public class Commandfeed extends EssentialsLoopCommand {
protected void updatePlayer(final Server server, final CommandSource sender, final User player, final String[] args) throws PlayerExemptException { protected void updatePlayer(final Server server, final CommandSource sender, final User player, final String[] args) throws PlayerExemptException {
try { try {
feedPlayer(player.getBase()); feedPlayer(player.getBase());
sender.sendTl("feedOther", CommonPlaceholders.displayName((IUser) player)); sender.sendTl("feedOther", player.getDisplayName());
} catch (final QuietAbortException e) { } catch (final QuietAbortException e) {
//Handle Quietly //Handle Quietly
} }

View File

@ -3,7 +3,6 @@ package com.earth2me.essentials.commands;
import com.earth2me.essentials.CommandSource; import com.earth2me.essentials.CommandSource;
import com.earth2me.essentials.User; import com.earth2me.essentials.User;
import com.earth2me.essentials.utils.CommonPlaceholders; import com.earth2me.essentials.utils.CommonPlaceholders;
import net.ess3.api.IUser;
import net.ess3.api.events.FlyStatusChangeEvent; import net.ess3.api.events.FlyStatusChangeEvent;
import org.bukkit.Server; import org.bukkit.Server;
@ -39,9 +38,9 @@ public class Commandfly extends EssentialsToggleCommand {
user.getBase().setFlying(false); user.getBase().setFlying(false);
} }
user.sendTl("flyMode", CommonPlaceholders.enableDisable(user.getSource(), enabled), CommonPlaceholders.displayName((IUser) user)); user.sendTl("flyMode", CommonPlaceholders.enableDisable(user.getSource(), enabled), user.getDisplayName());
if (!sender.isPlayer() || !sender.getPlayer().equals(user.getBase())) { if (!sender.isPlayer() || !sender.getPlayer().equals(user.getBase())) {
sender.sendTl("flyMode", CommonPlaceholders.enableDisable(user.getSource(), enabled), CommonPlaceholders.displayName((IUser) user)); sender.sendTl("flyMode", CommonPlaceholders.enableDisable(user.getSource(), enabled), user.getDisplayName());
} }
} }
} }

View File

@ -3,8 +3,6 @@ package com.earth2me.essentials.commands;
import com.earth2me.essentials.CommandSource; import com.earth2me.essentials.CommandSource;
import com.earth2me.essentials.IUser; import com.earth2me.essentials.IUser;
import com.earth2me.essentials.User; import com.earth2me.essentials.User;
import com.earth2me.essentials.messaging.IMessageRecipient;
import com.earth2me.essentials.utils.CommonPlaceholders;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.Server; import org.bukkit.Server;
@ -62,7 +60,7 @@ public class Commandgamemode extends EssentialsLoopCommand {
} }
user.getBase().setGameMode(gameMode); user.getBase().setGameMode(gameMode);
user.sendTl("gameMode", user.playerTl(user.getBase().getGameMode().toString().toLowerCase(Locale.ENGLISH)), CommonPlaceholders.displayNameRecipient((IMessageRecipient) user)); user.sendTl("gameMode", user.playerTl(user.getBase().getGameMode().toString().toLowerCase(Locale.ENGLISH)), user.getDisplayName());
} }
private void setUserGamemode(final CommandSource sender, final GameMode gameMode, final User user) throws NotEnoughArgumentsException { private void setUserGamemode(final CommandSource sender, final GameMode gameMode, final User user) throws NotEnoughArgumentsException {
@ -76,7 +74,7 @@ public class Commandgamemode extends EssentialsLoopCommand {
} }
user.getBase().setGameMode(gameMode); user.getBase().setGameMode(gameMode);
sender.sendTl("gameMode", sender.tl(gameMode.toString().toLowerCase(Locale.ENGLISH)), CommonPlaceholders.displayNameRecipient((IMessageRecipient) user)); sender.sendTl("gameMode", sender.tl(gameMode.toString().toLowerCase(Locale.ENGLISH)), user.getDisplayName());
} }
// essentials.gamemode will let them change to any but essentials.gamemode.survival would only let them change to survival. // essentials.gamemode will let them change to any but essentials.gamemode.survival would only let them change to survival.

View File

@ -4,11 +4,9 @@ import com.earth2me.essentials.CommandSource;
import com.earth2me.essentials.MetaItemStack; import com.earth2me.essentials.MetaItemStack;
import com.earth2me.essentials.User; import com.earth2me.essentials.User;
import com.earth2me.essentials.craftbukkit.Inventories; import com.earth2me.essentials.craftbukkit.Inventories;
import com.earth2me.essentials.utils.CommonPlaceholders;
import com.earth2me.essentials.utils.NumberUtil; import com.earth2me.essentials.utils.NumberUtil;
import com.earth2me.essentials.utils.VersionUtil; import com.earth2me.essentials.utils.VersionUtil;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import net.ess3.api.IUser;
import net.ess3.api.TranslatableException; import net.ess3.api.TranslatableException;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Server; import org.bukkit.Server;
@ -81,7 +79,7 @@ public class Commandgive extends EssentialsLoopCommand {
final boolean isDropItemsIfFull = ess.getSettings().isDropItemsIfFull(); final boolean isDropItemsIfFull = ess.getSettings().isDropItemsIfFull();
final ItemStack finalStack = stack; final ItemStack finalStack = stack;
loopOnlinePlayersConsumer(server, sender, false, true, args[0], player -> { loopOnlinePlayersConsumer(server, sender, false, true, args[0], player -> {
sender.sendTl("giveSpawn", finalStack.getAmount(), itemName, CommonPlaceholders.displayName((IUser) player)); sender.sendTl("giveSpawn", finalStack.getAmount(), itemName, player.getDisplayName());
final Map<Integer, ItemStack> leftovers = Inventories.addItem(player.getBase(), player.isAuthorized("essentials.oversizedstacks") ? ess.getSettings().getOversizedStackSize() : 0, finalStack); final Map<Integer, ItemStack> leftovers = Inventories.addItem(player.getBase(), player.isAuthorized("essentials.oversizedstacks") ? ess.getSettings().getOversizedStackSize() : 0, finalStack);
@ -90,7 +88,7 @@ public class Commandgive extends EssentialsLoopCommand {
final World w = player.getWorld(); final World w = player.getWorld();
w.dropItemNaturally(player.getLocation(), item); w.dropItemNaturally(player.getLocation(), item);
} else { } else {
sender.sendTl("giveSpawnFailure", item.getAmount(), itemName, CommonPlaceholders.displayName((IUser) player)); sender.sendTl("giveSpawnFailure", item.getAmount(), itemName, player.getDisplayName());
} }
} }

View File

@ -2,8 +2,6 @@ package com.earth2me.essentials.commands;
import com.earth2me.essentials.CommandSource; import com.earth2me.essentials.CommandSource;
import com.earth2me.essentials.User; import com.earth2me.essentials.User;
import com.earth2me.essentials.utils.CommonPlaceholders;
import net.ess3.api.IUser;
import org.bukkit.Server; import org.bukkit.Server;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityRegainHealthEvent; import org.bukkit.event.entity.EntityRegainHealthEvent;
@ -71,7 +69,7 @@ public class Commandheal extends EssentialsLoopCommand {
player.removePotionEffect(effect.getType()); player.removePotionEffect(effect.getType());
} }
} }
sender.sendTl("healOther", CommonPlaceholders.displayName((IUser) user)); sender.sendTl("healOther", user.getDisplayName());
} catch (final QuietAbortException e) { } catch (final QuietAbortException e) {
//Handle Quietly //Handle Quietly
} }

View File

@ -5,7 +5,6 @@ import com.earth2me.essentials.Console;
import com.earth2me.essentials.User; import com.earth2me.essentials.User;
import com.earth2me.essentials.messaging.IMessageRecipient; import com.earth2me.essentials.messaging.IMessageRecipient;
import com.earth2me.essentials.utils.AdventureUtil; import com.earth2me.essentials.utils.AdventureUtil;
import com.earth2me.essentials.utils.CommonPlaceholders;
import com.earth2me.essentials.utils.FormatUtil; import com.earth2me.essentials.utils.FormatUtil;
import net.ess3.api.IUser; import net.ess3.api.IUser;
import net.essentialsx.api.v2.events.HelpopMessageSendEvent; import net.essentialsx.api.v2.events.HelpopMessageSendEvent;
@ -40,8 +39,7 @@ public class Commandhelpop extends EssentialsCommand {
} }
final String message = FormatUtil.stripFormat(getFinalArg(args, 0)); final String message = FormatUtil.stripFormat(getFinalArg(args, 0));
final AdventureUtil.ParsedPlaceholder displayName = CommonPlaceholders.displayNameRecipient(from); ess.getLogger().log(Level.INFO, AdventureUtil.miniToLegacy(tlLiteral("helpOp", from.getDisplayName(), message)));
ess.getLogger().log(Level.INFO, AdventureUtil.miniToLegacy(tlLiteral("helpOp", displayName, message)));
final List<IUser> recipients = new ArrayList<>(); final List<IUser> recipients = new ArrayList<>();
for (IUser user : ess.getOnlineUsers()) { for (IUser user : ess.getOnlineUsers()) {
@ -54,7 +52,7 @@ public class Commandhelpop extends EssentialsCommand {
ess.getServer().getPluginManager().callEvent(sendEvent); ess.getServer().getPluginManager().callEvent(sendEvent);
for (IUser recipient : sendEvent.getRecipients()) { for (IUser recipient : sendEvent.getRecipients()) {
recipient.sendTl("helpOp", displayName, message); recipient.sendTl("helpOp", from.getDisplayName(), message);
} }
} }

View File

@ -3,7 +3,6 @@ package com.earth2me.essentials.commands;
import com.earth2me.essentials.ChargeException; import com.earth2me.essentials.ChargeException;
import com.earth2me.essentials.CommandSource; import com.earth2me.essentials.CommandSource;
import com.earth2me.essentials.User; import com.earth2me.essentials.User;
import com.earth2me.essentials.utils.CommonPlaceholders;
import com.earth2me.essentials.utils.VersionUtil; import com.earth2me.essentials.utils.VersionUtil;
import net.ess3.api.IUser; import net.ess3.api.IUser;
import net.ess3.api.MaxMoneyException; import net.ess3.api.MaxMoneyException;
@ -39,7 +38,7 @@ public class Commandice extends EssentialsLoopCommand {
@Override @Override
protected void updatePlayer(Server server, CommandSource sender, User user, String[] args) throws NotEnoughArgumentsException, PlayerExemptException, ChargeException, MaxMoneyException { protected void updatePlayer(Server server, CommandSource sender, User user, String[] args) throws NotEnoughArgumentsException, PlayerExemptException, ChargeException, MaxMoneyException {
freezePlayer(user); freezePlayer(user);
sender.sendTl("iceOther", CommonPlaceholders.displayName((IUser) user)); sender.sendTl("iceOther", user.getDisplayName());
} }
private void freezePlayer(final IUser user) { private void freezePlayer(final IUser user) {

View File

@ -2,8 +2,6 @@ package com.earth2me.essentials.commands;
import com.earth2me.essentials.CommandSource; import com.earth2me.essentials.CommandSource;
import com.earth2me.essentials.User; import com.earth2me.essentials.User;
import com.earth2me.essentials.utils.CommonPlaceholders;
import net.ess3.api.IUser;
import net.ess3.api.TranslatableException; import net.ess3.api.TranslatableException;
import org.bukkit.Server; import org.bukkit.Server;
@ -36,7 +34,7 @@ public class Commandkitreset extends EssentialsCommand {
if (user.equals(target)) { if (user.equals(target)) {
user.sendTl("kitReset", kitName); user.sendTl("kitReset", kitName);
} else { } else {
user.sendTl("kitResetOther", kitName, CommonPlaceholders.displayName((IUser) target)); user.sendTl("kitResetOther", kitName, target.getDisplayName());
} }
} }
@ -53,7 +51,7 @@ public class Commandkitreset extends EssentialsCommand {
final User target = getPlayer(server, sender, args, 1); final User target = getPlayer(server, sender, args, 1);
target.setKitTimestamp(kitName, 0); target.setKitTimestamp(kitName, 0);
sender.sendTl("kitResetOther", kitName, CommonPlaceholders.displayName((IUser) target)); sender.sendTl("kitResetOther", kitName, target.getDisplayName());
} }
@Override @Override

View File

@ -2,9 +2,7 @@ package com.earth2me.essentials.commands;
import com.earth2me.essentials.CommandSource; import com.earth2me.essentials.CommandSource;
import com.earth2me.essentials.User; import com.earth2me.essentials.User;
import com.earth2me.essentials.utils.CommonPlaceholders;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import net.ess3.api.IUser;
import org.bukkit.Server; import org.bukkit.Server;
import org.bukkit.entity.LightningStrike; import org.bukkit.entity.LightningStrike;
@ -35,7 +33,7 @@ public class Commandlightning extends EssentialsLoopCommand {
} }
final int finalPower = power; final int finalPower = power;
loopOnlinePlayersConsumer(server, sender, false, true, args[0], player -> { loopOnlinePlayersConsumer(server, sender, false, true, args[0], player -> {
sender.sendTl("lightningUse", CommonPlaceholders.displayName((IUser) player)); sender.sendTl("lightningUse", player.getDisplayName());
final LightningStrike strike = player.getBase().getWorld().strikeLightningEffect(player.getBase().getLocation()); final LightningStrike strike = player.getBase().getWorld().strikeLightningEffect(player.getBase().getLocation());
if (!player.isGodModeEnabled()) { if (!player.isGodModeEnabled()) {

View File

@ -6,13 +6,11 @@ import com.earth2me.essentials.User;
import com.earth2me.essentials.messaging.IMessageRecipient; import com.earth2me.essentials.messaging.IMessageRecipient;
import com.earth2me.essentials.textreader.SimpleTextPager; import com.earth2me.essentials.textreader.SimpleTextPager;
import com.earth2me.essentials.textreader.SimpleTranslatableText; import com.earth2me.essentials.textreader.SimpleTranslatableText;
import com.earth2me.essentials.utils.CommonPlaceholders;
import com.earth2me.essentials.utils.DateUtil; import com.earth2me.essentials.utils.DateUtil;
import com.earth2me.essentials.utils.FormatUtil; import com.earth2me.essentials.utils.FormatUtil;
import com.earth2me.essentials.utils.NumberUtil; import com.earth2me.essentials.utils.NumberUtil;
import com.earth2me.essentials.utils.StringUtil; import com.earth2me.essentials.utils.StringUtil;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import net.ess3.api.IUser;
import net.ess3.api.TranslatableException; import net.ess3.api.TranslatableException;
import net.essentialsx.api.v2.services.mail.MailMessage; import net.essentialsx.api.v2.services.mail.MailMessage;
import org.bukkit.Server; import org.bukkit.Server;
@ -102,7 +100,7 @@ public class Commandmail extends EssentialsCommand {
u.sendMail(user, msg); u.sendMail(user, msg);
} }
user.sendTl("mailSentTo", CommonPlaceholders.displayName((IUser) u), u.getName()); user.sendTl("mailSentTo", u.getDisplayName(), u.getName());
user.sendMessage(msg); user.sendMessage(msg);
return; return;
} }
@ -145,7 +143,7 @@ public class Commandmail extends EssentialsCommand {
u.sendMail(user, msg, dateDiff); u.sendMail(user, msg, dateDiff);
} }
user.sendTl("mailSentToExpire", CommonPlaceholders.displayName((IUser) u), DateUtil.formatDateDiff(dateDiff), u.getName()); user.sendTl("mailSentToExpire", u.getDisplayName(), DateUtil.formatDateDiff(dateDiff), u.getName());
user.sendMessage(msg); user.sendMessage(msg);
return; return;
} }
@ -187,7 +185,7 @@ public class Commandmail extends EssentialsCommand {
final ArrayList<MailMessage> mails = mailUser.getMailMessages(); final ArrayList<MailMessage> mails = mailUser.getMailMessages();
if (mails == null || mails.isEmpty()) { if (mails == null || mails.isEmpty()) {
user.sendTl(mailUser == user ? "noMail" : "noMailOther", CommonPlaceholders.displayName((IUser) mailUser)); user.sendTl(mailUser == user ? "noMail" : "noMailOther", mailUser.getDisplayName());
throw new NoChargeException(); throw new NoChargeException();
} }
@ -227,7 +225,7 @@ public class Commandmail extends EssentialsCommand {
final ArrayList<MailMessage> mails = mailUser.getMailMessages(); final ArrayList<MailMessage> mails = mailUser.getMailMessages();
if (mails == null || mails.isEmpty()) { if (mails == null || mails.isEmpty()) {
sender.sendTl("noMailOther", CommonPlaceholders.displayName((IUser) mailUser)); sender.sendTl("noMailOther", mailUser.getDisplayName());
throw new NoChargeException(); throw new NoChargeException();
} }

View File

@ -2,8 +2,6 @@ package com.earth2me.essentials.commands;
import com.earth2me.essentials.CommandSource; import com.earth2me.essentials.CommandSource;
import com.earth2me.essentials.User; import com.earth2me.essentials.User;
import com.earth2me.essentials.utils.CommonPlaceholders;
import net.ess3.api.IUser;
import org.bukkit.Server; import org.bukkit.Server;
public class Commandmsgtoggle extends EssentialsToggleCommand { public class Commandmsgtoggle extends EssentialsToggleCommand {
@ -31,7 +29,7 @@ public class Commandmsgtoggle extends EssentialsToggleCommand {
user.sendTl(!enabled ? "msgEnabled" : "msgDisabled"); user.sendTl(!enabled ? "msgEnabled" : "msgDisabled");
if (!sender.isPlayer() || !user.getBase().equals(sender.getPlayer())) { if (!sender.isPlayer() || !user.getBase().equals(sender.getPlayer())) {
sender.sendTl(!enabled ? "msgEnabledFor" : "msgDisabledFor", CommonPlaceholders.displayName((IUser) user)); sender.sendTl(!enabled ? "msgEnabledFor" : "msgDisabledFor", user.getDisplayName());
} }
} }
} }

View File

@ -4,7 +4,6 @@ import com.earth2me.essentials.CommandSource;
import com.earth2me.essentials.OfflinePlayerStub; import com.earth2me.essentials.OfflinePlayerStub;
import com.earth2me.essentials.User; import com.earth2me.essentials.User;
import com.earth2me.essentials.utils.AdventureUtil; import com.earth2me.essentials.utils.AdventureUtil;
import com.earth2me.essentials.utils.CommonPlaceholders;
import com.earth2me.essentials.utils.DateUtil; import com.earth2me.essentials.utils.DateUtil;
import net.ess3.api.TranslatableException; import net.ess3.api.TranslatableException;
import net.ess3.api.events.MuteStatusChangeEvent; import net.ess3.api.events.MuteStatusChangeEvent;
@ -87,18 +86,18 @@ public class Commandmute extends EssentialsCommand {
if (muted) { if (muted) {
if (muteTimestamp > 0) { if (muteTimestamp > 0) {
if (!user.hasMuteReason()) { if (!user.hasMuteReason()) {
sender.sendTl("mutedPlayerFor", CommonPlaceholders.displayName(user), muteTime); sender.sendTl("mutedPlayerFor", user.getDisplayName(), muteTime);
user.sendTl("playerMutedFor", muteTime); user.sendTl("playerMutedFor", muteTime);
} else { } else {
sender.sendTl("mutedPlayerForReason", CommonPlaceholders.displayName(user), muteTime, user.getMuteReason()); sender.sendTl("mutedPlayerForReason", user.getDisplayName(), muteTime, user.getMuteReason());
user.sendTl("playerMutedForReason", muteTime, user.getMuteReason()); user.sendTl("playerMutedForReason", muteTime, user.getMuteReason());
} }
} else { } else {
if (!user.hasMuteReason()) { if (!user.hasMuteReason()) {
sender.sendTl("mutedPlayer", CommonPlaceholders.displayName(user)); sender.sendTl("mutedPlayer", user.getDisplayName());
user.sendTl("playerMuted"); user.sendTl("playerMuted");
} else { } else {
sender.sendTl("mutedPlayerReason", CommonPlaceholders.displayName(user), user.getMuteReason()); sender.sendTl("mutedPlayerReason", user.getDisplayName(), user.getMuteReason());
user.sendTl("playerMutedReason", user.getMuteReason()); user.sendTl("playerMutedReason", user.getMuteReason());
} }
} }
@ -121,7 +120,7 @@ public class Commandmute extends EssentialsCommand {
ess.getLogger().log(Level.INFO, AdventureUtil.miniToLegacy(tlLiteral(tlKey, objects))); ess.getLogger().log(Level.INFO, AdventureUtil.miniToLegacy(tlLiteral(tlKey, objects)));
ess.broadcastTl(null, "essentials.mute.notify", tlKey, objects); ess.broadcastTl(null, "essentials.mute.notify", tlKey, objects);
} else { } else {
sender.sendTl("unmutedPlayer", CommonPlaceholders.displayName(user)); sender.sendTl("unmutedPlayer", user.getDisplayName());
user.sendTl("playerUnmuted"); user.sendTl("playerUnmuted");
} }
} }

View File

@ -2,9 +2,7 @@ package com.earth2me.essentials.commands;
import com.earth2me.essentials.CommandSource; import com.earth2me.essentials.CommandSource;
import com.earth2me.essentials.User; import com.earth2me.essentials.User;
import com.earth2me.essentials.utils.CommonPlaceholders;
import com.earth2me.essentials.utils.FormatUtil; import com.earth2me.essentials.utils.FormatUtil;
import net.ess3.api.IUser;
import net.ess3.api.TranslatableException; import net.ess3.api.TranslatableException;
import net.ess3.api.events.NickChangeEvent; import net.ess3.api.events.NickChangeEvent;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
@ -54,12 +52,12 @@ public class Commandnick extends EssentialsLoopCommand {
if (!target.getDisplayName().equalsIgnoreCase(target.getDisplayName())) { if (!target.getDisplayName().equalsIgnoreCase(target.getDisplayName())) {
target.sendTl("nickNoMore"); target.sendTl("nickNoMore");
} }
target.sendTl("nickSet", ess.getSettings().changeDisplayName() ? CommonPlaceholders.displayName((IUser) target) : nick); target.sendTl("nickSet", ess.getSettings().changeDisplayName() ? target.getDisplayName() : nick);
} else if (nickInUse(target, nick)) { } else if (nickInUse(target, nick)) {
throw new NotEnoughArgumentsException(sender.tl("nickInUse")); throw new NotEnoughArgumentsException(sender.tl("nickInUse"));
} else { } else {
setNickname(server, sender, target, nick); setNickname(server, sender, target, nick);
target.sendTl("nickSet", ess.getSettings().changeDisplayName() ? CommonPlaceholders.displayName((IUser) target) : nick); target.sendTl("nickSet", ess.getSettings().changeDisplayName() ? target.getDisplayName() : nick);
} }
} }

View File

@ -3,11 +3,9 @@ package com.earth2me.essentials.commands;
import com.earth2me.essentials.CommandSource; import com.earth2me.essentials.CommandSource;
import com.earth2me.essentials.Trade; import com.earth2me.essentials.Trade;
import com.earth2me.essentials.User; import com.earth2me.essentials.User;
import com.earth2me.essentials.utils.CommonPlaceholders;
import com.earth2me.essentials.utils.NumberUtil; import com.earth2me.essentials.utils.NumberUtil;
import com.earth2me.essentials.utils.StringUtil; import com.earth2me.essentials.utils.StringUtil;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import net.ess3.api.IUser;
import net.ess3.api.MaxMoneyException; import net.ess3.api.MaxMoneyException;
import net.ess3.api.TranslatableException; import net.ess3.api.TranslatableException;
import net.ess3.api.events.UserBalanceUpdateEvent; import net.ess3.api.events.UserBalanceUpdateEvent;
@ -88,7 +86,7 @@ public class Commandpay extends EssentialsLoopCommand {
} }
if (!player.isAcceptingPay() || (ess.getSettings().isPayExcludesIgnoreList() && player.isIgnoredPlayer(user))) { if (!player.isAcceptingPay() || (ess.getSettings().isPayExcludesIgnoreList() && player.isIgnoredPlayer(user))) {
user.sendTl("notAcceptingPay", CommonPlaceholders.displayName((IUser) player)); user.sendTl("notAcceptingPay", player.getDisplayName());
return; return;
} }
if (user.isPromptingPayConfirm() && !amount.equals(user.getConfirmingPayments().get(player))) { // checks if exists and if command needs to be repeated. if (user.isPromptingPayConfirm() && !amount.equals(user.getConfirmingPayments().get(player))) { // checks if exists and if command needs to be repeated.

View File

@ -2,8 +2,6 @@ package com.earth2me.essentials.commands;
import com.earth2me.essentials.CommandSource; import com.earth2me.essentials.CommandSource;
import com.earth2me.essentials.User; import com.earth2me.essentials.User;
import com.earth2me.essentials.utils.CommonPlaceholders;
import net.ess3.api.IUser;
import org.bukkit.Server; import org.bukkit.Server;
public class Commandpaytoggle extends EssentialsToggleCommand { public class Commandpaytoggle extends EssentialsToggleCommand {
@ -38,7 +36,7 @@ public class Commandpaytoggle extends EssentialsToggleCommand {
user.sendTl(enabled ? "payToggleOn" : "payToggleOff"); user.sendTl(enabled ? "payToggleOn" : "payToggleOff");
if (!sender.isPlayer() || !user.getBase().equals(sender.getPlayer())) { if (!sender.isPlayer() || !user.getBase().equals(sender.getPlayer())) {
sender.sendTl(enabled ? "payEnabledFor" : "payDisabledFor", CommonPlaceholders.displayName((IUser) user)); sender.sendTl(enabled ? "payEnabledFor" : "payDisabledFor", user.getDisplayName());
} }
} }
} }

View File

@ -2,9 +2,7 @@ package com.earth2me.essentials.commands;
import com.earth2me.essentials.CommandSource; import com.earth2me.essentials.CommandSource;
import com.earth2me.essentials.User; import com.earth2me.essentials.User;
import com.earth2me.essentials.utils.CommonPlaceholders;
import com.earth2me.essentials.utils.FormatUtil; import com.earth2me.essentials.utils.FormatUtil;
import net.ess3.api.IUser;
import org.bukkit.Server; import org.bukkit.Server;
import java.util.Locale; import java.util.Locale;
@ -31,7 +29,7 @@ public class Commandrealname extends EssentialsCommand {
u.setDisplayNick(); u.setDisplayNick();
if (FormatUtil.stripFormat(u.getDisplayName()).toLowerCase(Locale.ENGLISH).contains(lookup)) { if (FormatUtil.stripFormat(u.getDisplayName()).toLowerCase(Locale.ENGLISH).contains(lookup)) {
foundUser = true; foundUser = true;
sender.sendTl("realName", CommonPlaceholders.displayName((IUser) u), u.getName()); sender.sendTl("realName", u.getDisplayName(), u.getName());
} }
} }
if (!foundUser) { if (!foundUser) {

View File

@ -3,7 +3,6 @@ package com.earth2me.essentials.commands;
import com.earth2me.essentials.CommandSource; import com.earth2me.essentials.CommandSource;
import com.earth2me.essentials.IUser; import com.earth2me.essentials.IUser;
import com.earth2me.essentials.User; import com.earth2me.essentials.User;
import com.earth2me.essentials.utils.CommonPlaceholders;
import com.earth2me.essentials.utils.VersionUtil; import com.earth2me.essentials.utils.VersionUtil;
import org.bukkit.Server; import org.bukkit.Server;
import org.bukkit.Statistic; import org.bukkit.Statistic;
@ -35,7 +34,7 @@ public class Commandrest extends EssentialsLoopCommand {
@Override @Override
protected void updatePlayer(final Server server, final CommandSource sender, final User player, final String[] args) throws PlayerExemptException { protected void updatePlayer(final Server server, final CommandSource sender, final User player, final String[] args) throws PlayerExemptException {
restPlayer(player); restPlayer(player);
sender.sendTl("restOther", CommonPlaceholders.displayName(player)); sender.sendTl("restOther", player.getDisplayName());
} }
private void restPlayer(final IUser user) { private void restPlayer(final IUser user) {

View File

@ -2,7 +2,6 @@ package com.earth2me.essentials.commands;
import com.earth2me.essentials.CommandSource; import com.earth2me.essentials.CommandSource;
import com.earth2me.essentials.User; import com.earth2me.essentials.User;
import com.earth2me.essentials.utils.CommonPlaceholders;
import org.bukkit.Server; import org.bukkit.Server;
public class Commandrtoggle extends EssentialsToggleCommand { public class Commandrtoggle extends EssentialsToggleCommand {
@ -30,7 +29,7 @@ public class Commandrtoggle extends EssentialsToggleCommand {
user.sendTl(!enabled ? "replyLastRecipientDisabled" : "replyLastRecipientEnabled"); user.sendTl(!enabled ? "replyLastRecipientDisabled" : "replyLastRecipientEnabled");
if (!sender.isPlayer() || !user.getBase().equals(sender.getPlayer())) { if (!sender.isPlayer() || !user.getBase().equals(sender.getPlayer())) {
sender.sendTl(!enabled ? "replyLastRecipientDisabledFor" : "replyLastRecipientEnabledFor", CommonPlaceholders.displayName(user)); sender.sendTl(!enabled ? "replyLastRecipientDisabledFor" : "replyLastRecipientEnabledFor", user.getDisplayName());
} }
} }
} }

View File

@ -102,7 +102,7 @@ public class Commandseen extends EssentialsCommand {
private void seenOnline(final CommandSource sender, final User user, final boolean showIp) { private void seenOnline(final CommandSource sender, final User user, final boolean showIp) {
user.setDisplayNick(); user.setDisplayNick();
sender.sendTl("seenOnline", CommonPlaceholders.displayName(user), DateUtil.formatDateDiff(user.getLastLogin())); sender.sendTl("seenOnline", user.getDisplayName(), DateUtil.formatDateDiff(user.getLastLogin()));
final List<String> history = user.getPastUsernames(); final List<String> history = user.getPastUsernames();
if (history != null && !history.isEmpty()) { if (history != null && !history.isEmpty()) {

View File

@ -4,7 +4,6 @@ import com.earth2me.essentials.Trade;
import com.earth2me.essentials.User; import com.earth2me.essentials.User;
import com.earth2me.essentials.craftbukkit.Inventories; import com.earth2me.essentials.craftbukkit.Inventories;
import com.earth2me.essentials.utils.AdventureUtil; import com.earth2me.essentials.utils.AdventureUtil;
import com.earth2me.essentials.utils.CommonPlaceholders;
import com.earth2me.essentials.utils.NumberUtil; import com.earth2me.essentials.utils.NumberUtil;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import net.ess3.api.TranslatableException; import net.ess3.api.TranslatableException;
@ -123,7 +122,7 @@ public class Commandsell extends EssentialsCommand {
final String typeName = is.getType().toString().toLowerCase(Locale.ENGLISH); final String typeName = is.getType().toString().toLowerCase(Locale.ENGLISH);
final String worthDisplay = NumberUtil.displayCurrency(worth, ess); final String worthDisplay = NumberUtil.displayCurrency(worth, ess);
user.sendTl("itemSold", NumberUtil.displayCurrency(result, ess), amount, typeName, worthDisplay); user.sendTl("itemSold", NumberUtil.displayCurrency(result, ess), amount, typeName, worthDisplay);
ess.getLogger().log(Level.INFO, AdventureUtil.miniToLegacy(tlLiteral("itemSoldConsole", user.getName(), typeName, NumberUtil.displayCurrency(result, ess), amount, worthDisplay, CommonPlaceholders.displayName(user)))); ess.getLogger().log(Level.INFO, AdventureUtil.miniToLegacy(tlLiteral("itemSoldConsole", user.getName(), typeName, NumberUtil.displayCurrency(result, ess), amount, worthDisplay, user.getDisplayName())));
return result; return result;
} }

View File

@ -28,9 +28,9 @@ public class Commandsocialspy extends EssentialsToggleCommand {
user.setSocialSpyEnabled(enabled); user.setSocialSpyEnabled(enabled);
user.sendTl("socialSpy", CommonPlaceholders.displayName(user), CommonPlaceholders.enableDisable(user.getSource(), enabled)); user.sendTl("socialSpy", user.getDisplayName(), CommonPlaceholders.enableDisable(user.getSource(), enabled));
if (!sender.isPlayer() || !sender.getPlayer().equals(user.getBase())) { if (!sender.isPlayer() || !sender.getPlayer().equals(user.getBase())) {
sender.sendTl("socialSpy", CommonPlaceholders.displayName(user), CommonPlaceholders.enableDisable(user.getSource(), enabled)); sender.sendTl("socialSpy", user.getDisplayName(), CommonPlaceholders.enableDisable(user.getSource(), enabled));
} }
} }
} }

View File

@ -3,7 +3,6 @@ package com.earth2me.essentials.commands;
import com.earth2me.essentials.CommandSource; import com.earth2me.essentials.CommandSource;
import com.earth2me.essentials.User; import com.earth2me.essentials.User;
import com.earth2me.essentials.utils.AdventureUtil; import com.earth2me.essentials.utils.AdventureUtil;
import com.earth2me.essentials.utils.CommonPlaceholders;
import com.earth2me.essentials.utils.FloatUtil; import com.earth2me.essentials.utils.FloatUtil;
import org.bukkit.Server; import org.bukkit.Server;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -54,11 +53,11 @@ public class Commandspeed extends EssentialsCommand {
if (isFly) { if (isFly) {
user.getBase().setFlySpeed(getRealMoveSpeed(speed, true, isBypass)); user.getBase().setFlySpeed(getRealMoveSpeed(speed, true, isBypass));
user.sendTl("moveSpeed", AdventureUtil.parsed(user.playerTl("flying")), speed, CommonPlaceholders.displayName(user)); user.sendTl("moveSpeed", AdventureUtil.parsed(user.playerTl("flying")), speed, user.getDisplayName());
return; return;
} }
user.getBase().setWalkSpeed(getRealMoveSpeed(speed, false, isBypass)); user.getBase().setWalkSpeed(getRealMoveSpeed(speed, false, isBypass));
user.sendTl("moveSpeed", AdventureUtil.parsed(user.playerTl("walking")), speed, CommonPlaceholders.displayName(user)); user.sendTl("moveSpeed", AdventureUtil.parsed(user.playerTl("walking")), speed, user.getDisplayName());
} }
private void speedOtherPlayers(final Server server, final CommandSource sender, final boolean isFly, final boolean isBypass, final float speed, final String name) throws PlayerNotFoundException { private void speedOtherPlayers(final Server server, final CommandSource sender, final boolean isFly, final boolean isBypass, final float speed, final String name) throws PlayerNotFoundException {

View File

@ -1,7 +1,6 @@
package com.earth2me.essentials.commands; package com.earth2me.essentials.commands;
import com.earth2me.essentials.User; import com.earth2me.essentials.User;
import com.earth2me.essentials.utils.CommonPlaceholders;
import org.bukkit.Server; import org.bukkit.Server;
import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDamageEvent;
@ -21,7 +20,7 @@ public class Commandsuicide extends EssentialsCommand {
user.getBase().setHealth(0); user.getBase().setHealth(0);
user.sendTl("suicideMessage"); user.sendTl("suicideMessage");
user.setDisplayNick(); user.setDisplayNick();
ess.broadcastTl(user, "suicideSuccess", CommonPlaceholders.displayName(user)); ess.broadcastTl(user, "suicideSuccess", user.getDisplayName());
} }
@Override @Override

View File

@ -4,7 +4,6 @@ import com.earth2me.essentials.CommandSource;
import com.earth2me.essentials.Console; import com.earth2me.essentials.Console;
import com.earth2me.essentials.Trade; import com.earth2me.essentials.Trade;
import com.earth2me.essentials.User; import com.earth2me.essentials.User;
import com.earth2me.essentials.utils.CommonPlaceholders;
import net.ess3.api.TranslatableException; import net.ess3.api.TranslatableException;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Server; import org.bukkit.Server;
@ -29,12 +28,12 @@ public class Commandtp extends EssentialsCommand {
final User player = getPlayer(server, user, args, 0, false, true); final User player = getPlayer(server, user, args, 0, false, true);
if (!player.isTeleportEnabled()) { if (!player.isTeleportEnabled()) {
throw new TranslatableException("teleportDisabled", CommonPlaceholders.displayName(player)); throw new TranslatableException("teleportDisabled", player.getDisplayName());
} }
if (!player.getBase().isOnline()) { if (!player.getBase().isOnline()) {
if (user.isAuthorized("essentials.tpoffline")) { if (user.isAuthorized("essentials.tpoffline")) {
throw new TranslatableException("teleportOffline", CommonPlaceholders.displayName(player)); throw new TranslatableException("teleportOffline", player.getDisplayName());
} }
throw new PlayerNotFoundException(); throw new PlayerNotFoundException();
} }
@ -80,7 +79,7 @@ public class Commandtp extends EssentialsCommand {
} }
final Location locposother = new Location(target2.getWorld(), x, y, z, target2.getLocation().getYaw(), target2.getLocation().getPitch()); final Location locposother = new Location(target2.getWorld(), x, y, z, target2.getLocation().getYaw(), target2.getLocation().getPitch());
if (!target2.isTeleportEnabled()) { if (!target2.isTeleportEnabled()) {
throw new TranslatableException("teleportDisabled", CommonPlaceholders.displayName(target2)); throw new TranslatableException("teleportDisabled", target2.getDisplayName());
} }
user.sendTl("teleporting", locposother.getWorld().getName(), locposother.getBlockX(), locposother.getBlockY(), locposother.getBlockZ()); user.sendTl("teleporting", locposother.getWorld().getName(), locposother.getBlockX(), locposother.getBlockY(), locposother.getBlockZ());
target2.getAsyncTeleport().now(locposother, false, TeleportCause.COMMAND, future); target2.getAsyncTeleport().now(locposother, false, TeleportCause.COMMAND, future);
@ -98,15 +97,15 @@ public class Commandtp extends EssentialsCommand {
final User target = getPlayer(server, user, args, 0); final User target = getPlayer(server, user, args, 0);
final User toPlayer = getPlayer(server, user, args, 1); final User toPlayer = getPlayer(server, user, args, 1);
if (!target.isTeleportEnabled()) { if (!target.isTeleportEnabled()) {
throw new TranslatableException("teleportDisabled", CommonPlaceholders.displayName(target)); throw new TranslatableException("teleportDisabled", target.getDisplayName());
} }
if (!toPlayer.isTeleportEnabled()) { if (!toPlayer.isTeleportEnabled()) {
throw new TranslatableException("teleportDisabled", CommonPlaceholders.displayName(toPlayer)); throw new TranslatableException("teleportDisabled", toPlayer.getDisplayName());
} }
if (target.getWorld() != toPlayer.getWorld() && ess.getSettings().isWorldTeleportPermissions() && !user.isAuthorized("essentials.worlds." + toPlayer.getWorld().getName())) { if (target.getWorld() != toPlayer.getWorld() && ess.getSettings().isWorldTeleportPermissions() && !user.isAuthorized("essentials.worlds." + toPlayer.getWorld().getName())) {
throw new TranslatableException("noPerm", "essentials.worlds." + toPlayer.getWorld().getName()); throw new TranslatableException("noPerm", "essentials.worlds." + toPlayer.getWorld().getName());
} }
target.sendTl("teleportAtoB", CommonPlaceholders.displayName(user), CommonPlaceholders.displayName(toPlayer)); target.sendTl("teleportAtoB", user.getDisplayName(), toPlayer.getDisplayName());
target.getAsyncTeleport().now(toPlayer.getBase(), false, TeleportCause.COMMAND, future); target.getAsyncTeleport().now(toPlayer.getBase(), false, TeleportCause.COMMAND, future);
break; break;
} }
@ -121,7 +120,7 @@ public class Commandtp extends EssentialsCommand {
final User target = getPlayer(server, args, 0, true, false); final User target = getPlayer(server, args, 0, true, false);
if (args.length == 2) { if (args.length == 2) {
final User toPlayer = getPlayer(server, args, 1, true, false); final User toPlayer = getPlayer(server, args, 1, true, false);
target.sendTl("teleportAtoB", Console.DISPLAY_NAME, CommonPlaceholders.displayName(toPlayer)); target.sendTl("teleportAtoB", Console.DISPLAY_NAME, toPlayer.getDisplayName());
target.getAsyncTeleport().now(toPlayer.getBase(), false, TeleportCause.COMMAND, getNewExceptionFuture(sender, commandLabel)); target.getAsyncTeleport().now(toPlayer.getBase(), false, TeleportCause.COMMAND, getNewExceptionFuture(sender, commandLabel));
} else if (args.length > 3) { } else if (args.length > 3) {
final double x = args[1].startsWith("~") ? target.getLocation().getX() + (args[1].length() > 1 ? Double.parseDouble(args[1].substring(1)) : 0) : Double.parseDouble(args[1]); final double x = args[1].startsWith("~") ? target.getLocation().getX() + (args[1].length() > 1 ? Double.parseDouble(args[1].substring(1)) : 0) : Double.parseDouble(args[1]);

View File

@ -3,7 +3,6 @@ package com.earth2me.essentials.commands;
import com.earth2me.essentials.AsyncTeleport; import com.earth2me.essentials.AsyncTeleport;
import com.earth2me.essentials.Trade; import com.earth2me.essentials.Trade;
import com.earth2me.essentials.User; import com.earth2me.essentials.User;
import com.earth2me.essentials.utils.CommonPlaceholders;
import net.ess3.api.TranslatableException; import net.ess3.api.TranslatableException;
import net.ess3.api.events.TPARequestEvent; import net.ess3.api.events.TPARequestEvent;
import org.bukkit.Server; import org.bukkit.Server;
@ -29,10 +28,10 @@ public class Commandtpa extends EssentialsCommand {
throw new NotEnoughArgumentsException(); throw new NotEnoughArgumentsException();
} }
if (!player.isAuthorized("essentials.tpaccept")) { if (!player.isAuthorized("essentials.tpaccept")) {
throw new TranslatableException("teleportNoAcceptPermission", CommonPlaceholders.displayName(player)); throw new TranslatableException("teleportNoAcceptPermission", player.getDisplayName());
} }
if (!player.isTeleportEnabled()) { if (!player.isTeleportEnabled()) {
throw new TranslatableException("teleportDisabled", CommonPlaceholders.displayName(player)); throw new TranslatableException("teleportDisabled", player.getDisplayName());
} }
if (user.getWorld() != player.getWorld() && ess.getSettings().isWorldTeleportPermissions() && !user.isAuthorized("essentials.worlds." + player.getWorld().getName())) { if (user.getWorld() != player.getWorld() && ess.getSettings().isWorldTeleportPermissions() && !user.isAuthorized("essentials.worlds." + player.getWorld().getName())) {
throw new TranslatableException("noPerm", "essentials.worlds." + player.getWorld().getName()); throw new TranslatableException("noPerm", "essentials.worlds." + player.getWorld().getName());
@ -40,7 +39,7 @@ public class Commandtpa extends EssentialsCommand {
// Don't let sender request teleport twice to the same player. // Don't let sender request teleport twice to the same player.
if (player.hasOutstandingTpaRequest(user.getName(), false)) { if (player.hasOutstandingTpaRequest(user.getName(), false)) {
throw new TranslatableException("requestSentAlready", CommonPlaceholders.displayName(player)); throw new TranslatableException("requestSentAlready", player.getDisplayName());
} }
if (player.isAutoTeleportEnabled() && !player.isIgnoredPlayer(user)) { if (player.isAutoTeleportEnabled() && !player.isIgnoredPlayer(user)) {
@ -51,8 +50,8 @@ public class Commandtpa extends EssentialsCommand {
teleport.teleport(player.getBase(), charge, PlayerTeleportEvent.TeleportCause.COMMAND, future); teleport.teleport(player.getBase(), charge, PlayerTeleportEvent.TeleportCause.COMMAND, future);
future.thenAccept(success -> { future.thenAccept(success -> {
if (success) { if (success) {
player.sendTl("requestAcceptedAuto", CommonPlaceholders.displayName(user)); player.sendTl("requestAcceptedAuto", user.getDisplayName());
user.sendTl("requestAcceptedFromAuto", CommonPlaceholders.displayName(player)); user.sendTl("requestAcceptedFromAuto", player.getDisplayName());
} }
}); });
throw new NoChargeException(); throw new NoChargeException();
@ -62,10 +61,10 @@ public class Commandtpa extends EssentialsCommand {
final TPARequestEvent tpaEvent = new TPARequestEvent(user.getSource(), player, false); final TPARequestEvent tpaEvent = new TPARequestEvent(user.getSource(), player, false);
ess.getServer().getPluginManager().callEvent(tpaEvent); ess.getServer().getPluginManager().callEvent(tpaEvent);
if (tpaEvent.isCancelled()) { if (tpaEvent.isCancelled()) {
throw new TranslatableException("teleportRequestCancelled", CommonPlaceholders.displayName(player)); throw new TranslatableException("teleportRequestCancelled", player.getDisplayName());
} }
player.requestTeleport(user, false); player.requestTeleport(user, false);
player.sendTl("teleportRequest", CommonPlaceholders.displayName(user)); player.sendTl("teleportRequest", user.getDisplayName());
player.sendTl("typeTpaccept"); player.sendTl("typeTpaccept");
player.sendTl("typeTpdeny"); player.sendTl("typeTpdeny");
if (ess.getSettings().getTpaAcceptCancellation() != 0) { if (ess.getSettings().getTpaAcceptCancellation() != 0) {
@ -73,7 +72,7 @@ public class Commandtpa extends EssentialsCommand {
} }
} }
user.sendTl("requestSent", CommonPlaceholders.displayName(player)); user.sendTl("requestSent", player.getDisplayName());
if (user.isAuthorized("essentials.tpacancel")) { if (user.isAuthorized("essentials.tpacancel")) {
user.sendTl("typeTpacancel"); user.sendTl("typeTpacancel");
} }

View File

@ -2,7 +2,6 @@ package com.earth2me.essentials.commands;
import com.earth2me.essentials.CommandSource; import com.earth2me.essentials.CommandSource;
import com.earth2me.essentials.User; import com.earth2me.essentials.User;
import com.earth2me.essentials.utils.CommonPlaceholders;
import net.ess3.api.events.TPARequestEvent; import net.ess3.api.events.TPARequestEvent;
import org.bukkit.Server; import org.bukkit.Server;
@ -45,11 +44,11 @@ public class Commandtpaall extends EssentialsCommand {
final TPARequestEvent tpaEvent = new TPARequestEvent(sender, player, true); final TPARequestEvent tpaEvent = new TPARequestEvent(sender, player, true);
ess.getServer().getPluginManager().callEvent(tpaEvent); ess.getServer().getPluginManager().callEvent(tpaEvent);
if (tpaEvent.isCancelled()) { if (tpaEvent.isCancelled()) {
sender.sendTl("teleportRequestCancelled", CommonPlaceholders.displayName(player)); sender.sendTl("teleportRequestCancelled", player.getDisplayName());
continue; continue;
} }
player.requestTeleport(target, true); player.requestTeleport(target, true);
player.sendTl("teleportHereRequest", CommonPlaceholders.displayName(target)); player.sendTl("teleportHereRequest", target.getDisplayName());
player.sendTl("typeTpaccept"); player.sendTl("typeTpaccept");
if (ess.getSettings().getTpaAcceptCancellation() != 0) { if (ess.getSettings().getTpaAcceptCancellation() != 0) {
player.sendTl("teleportRequestTimeoutInfo", ess.getSettings().getTpaAcceptCancellation()); player.sendTl("teleportRequestTimeoutInfo", ess.getSettings().getTpaAcceptCancellation());

View File

@ -4,7 +4,6 @@ import com.earth2me.essentials.AsyncTeleport;
import com.earth2me.essentials.IUser; import com.earth2me.essentials.IUser;
import com.earth2me.essentials.Trade; import com.earth2me.essentials.Trade;
import com.earth2me.essentials.User; import com.earth2me.essentials.User;
import com.earth2me.essentials.utils.CommonPlaceholders;
import net.ess3.api.TranslatableException; import net.ess3.api.TranslatableException;
import net.essentialsx.api.v2.events.TeleportRequestResponseEvent; import net.essentialsx.api.v2.events.TeleportRequestResponseEvent;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@ -105,7 +104,7 @@ public class Commandtpaccept extends EssentialsCommand {
} }
final Trade charge = new Trade(this.getName(), ess); final Trade charge = new Trade(this.getName(), ess);
requester.sendTl("requestAcceptedFrom", CommonPlaceholders.displayName(user)); requester.sendTl("requestAcceptedFrom", user.getDisplayName());
final CompletableFuture<Boolean> future = getNewExceptionFuture(requester.getSource(), commandLabel); final CompletableFuture<Boolean> future = getNewExceptionFuture(requester.getSource(), commandLabel);
future.exceptionally(e -> { future.exceptionally(e -> {

View File

@ -1,7 +1,6 @@
package com.earth2me.essentials.commands; package com.earth2me.essentials.commands;
import com.earth2me.essentials.User; import com.earth2me.essentials.User;
import com.earth2me.essentials.utils.CommonPlaceholders;
import net.ess3.api.TranslatableException; import net.ess3.api.TranslatableException;
import net.ess3.api.events.TPARequestEvent; import net.ess3.api.events.TPARequestEvent;
import org.bukkit.Server; import org.bukkit.Server;
@ -25,10 +24,10 @@ public class Commandtpahere extends EssentialsCommand {
throw new NotEnoughArgumentsException(); throw new NotEnoughArgumentsException();
} }
if (!player.isAuthorized("essentials.tpaccept")) { if (!player.isAuthorized("essentials.tpaccept")) {
throw new TranslatableException("teleportNoAcceptPermission", CommonPlaceholders.displayName(player)); throw new TranslatableException("teleportNoAcceptPermission", player.getDisplayName());
} }
if (!player.isTeleportEnabled()) { if (!player.isTeleportEnabled()) {
throw new TranslatableException("teleportDisabled", CommonPlaceholders.displayName(player)); throw new TranslatableException("teleportDisabled", player.getDisplayName());
} }
if (user.getWorld() != player.getWorld() && ess.getSettings().isWorldTeleportPermissions() && !user.isAuthorized("essentials.worlds." + user.getWorld().getName())) { if (user.getWorld() != player.getWorld() && ess.getSettings().isWorldTeleportPermissions() && !user.isAuthorized("essentials.worlds." + user.getWorld().getName())) {
throw new TranslatableException("noPerm", "essentials.worlds." + user.getWorld().getName()); throw new TranslatableException("noPerm", "essentials.worlds." + user.getWorld().getName());
@ -36,24 +35,24 @@ public class Commandtpahere extends EssentialsCommand {
// Don't let sender request teleport twice to the same player. // Don't let sender request teleport twice to the same player.
if (player.hasOutstandingTpaRequest(user.getName(), true)) { if (player.hasOutstandingTpaRequest(user.getName(), true)) {
throw new TranslatableException("requestSentAlready", CommonPlaceholders.displayName(player)); throw new TranslatableException("requestSentAlready", player.getDisplayName());
} }
if (!player.isIgnoredPlayer(user)) { if (!player.isIgnoredPlayer(user)) {
final TPARequestEvent tpaEvent = new TPARequestEvent(user.getSource(), player, true); final TPARequestEvent tpaEvent = new TPARequestEvent(user.getSource(), player, true);
ess.getServer().getPluginManager().callEvent(tpaEvent); ess.getServer().getPluginManager().callEvent(tpaEvent);
if (tpaEvent.isCancelled()) { if (tpaEvent.isCancelled()) {
throw new TranslatableException("teleportRequestCancelled", CommonPlaceholders.displayName(player)); throw new TranslatableException("teleportRequestCancelled", player.getDisplayName());
} }
player.requestTeleport(user, true); player.requestTeleport(user, true);
player.sendTl("teleportHereRequest", CommonPlaceholders.displayName(user)); player.sendTl("teleportHereRequest", user.getDisplayName());
player.sendTl("typeTpaccept"); player.sendTl("typeTpaccept");
player.sendTl("typeTpdeny"); player.sendTl("typeTpdeny");
if (ess.getSettings().getTpaAcceptCancellation() != 0) { if (ess.getSettings().getTpaAcceptCancellation() != 0) {
player.sendTl("teleportRequestTimeoutInfo", ess.getSettings().getTpaAcceptCancellation()); player.sendTl("teleportRequestTimeoutInfo", ess.getSettings().getTpaAcceptCancellation());
} }
} }
user.sendTl("requestSent", CommonPlaceholders.displayName(player)); user.sendTl("requestSent", player.getDisplayName());
user.sendTl("typeTpacancel"); user.sendTl("typeTpacancel");
} }

View File

@ -2,7 +2,6 @@ package com.earth2me.essentials.commands;
import com.earth2me.essentials.CommandSource; import com.earth2me.essentials.CommandSource;
import com.earth2me.essentials.User; import com.earth2me.essentials.User;
import com.earth2me.essentials.utils.CommonPlaceholders;
import org.bukkit.Server; import org.bukkit.Server;
public class Commandtpauto extends EssentialsToggleCommand { public class Commandtpauto extends EssentialsToggleCommand {
@ -33,7 +32,7 @@ public class Commandtpauto extends EssentialsToggleCommand {
user.sendTl("teleportationDisabledWarning"); user.sendTl("teleportationDisabledWarning");
} }
if (!sender.isPlayer() || !user.getBase().equals(sender.getPlayer())) { if (!sender.isPlayer() || !user.getBase().equals(sender.getPlayer())) {
sender.sendTl(enabled ? "autoTeleportEnabledFor" : "autoTeleportDisabledFor", CommonPlaceholders.displayName(user)); sender.sendTl(enabled ? "autoTeleportEnabledFor" : "autoTeleportDisabledFor", user.getDisplayName());
} }
} }
} }

View File

@ -2,7 +2,6 @@ package com.earth2me.essentials.commands;
import com.earth2me.essentials.IUser; import com.earth2me.essentials.IUser;
import com.earth2me.essentials.User; import com.earth2me.essentials.User;
import com.earth2me.essentials.utils.CommonPlaceholders;
import net.ess3.api.TranslatableException; import net.ess3.api.TranslatableException;
import net.essentialsx.api.v2.events.TeleportRequestResponseEvent; import net.essentialsx.api.v2.events.TeleportRequestResponseEvent;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@ -55,7 +54,7 @@ public class Commandtpdeny extends EssentialsCommand {
} }
user.sendTl("requestDenied"); user.sendTl("requestDenied");
player.sendTl("requestDeniedFrom", CommonPlaceholders.displayName(user)); player.sendTl("requestDeniedFrom", user.getDisplayName());
user.removeTpaRequest(denyRequest.getName()); user.removeTpaRequest(denyRequest.getName());
} }
@ -70,7 +69,7 @@ public class Commandtpdeny extends EssentialsCommand {
} }
if (player != null && player.getBase().isOnline()) { if (player != null && player.getBase().isOnline()) {
player.sendTl("requestDeniedFrom", CommonPlaceholders.displayName(user)); player.sendTl("requestDeniedFrom", user.getDisplayName());
} }
user.removeTpaRequest(request.getName()); user.removeTpaRequest(request.getName());

View File

@ -2,7 +2,6 @@ package com.earth2me.essentials.commands;
import com.earth2me.essentials.Trade; import com.earth2me.essentials.Trade;
import com.earth2me.essentials.User; import com.earth2me.essentials.User;
import com.earth2me.essentials.utils.CommonPlaceholders;
import net.ess3.api.TranslatableException; import net.ess3.api.TranslatableException;
import org.bukkit.Server; import org.bukkit.Server;
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
@ -19,7 +18,7 @@ public class Commandtphere extends EssentialsCommand {
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception { public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception {
final User player = getPlayer(server, user, args, 0); final User player = getPlayer(server, user, args, 0);
if (!player.isTeleportEnabled()) { if (!player.isTeleportEnabled()) {
throw new TranslatableException("teleportDisabled", CommonPlaceholders.displayName(player)); throw new TranslatableException("teleportDisabled", player.getDisplayName());
} }
if (user.getWorld() != player.getWorld() && ess.getSettings().isWorldTeleportPermissions() && !user.isAuthorized("essentials.worlds." + user.getWorld().getName())) { if (user.getWorld() != player.getWorld() && ess.getSettings().isWorldTeleportPermissions() && !user.isAuthorized("essentials.worlds." + user.getWorld().getName())) {
throw new TranslatableException("noPerm", "essentials.worlds." + user.getWorld().getName()); throw new TranslatableException("noPerm", "essentials.worlds." + user.getWorld().getName());

View File

@ -1,7 +1,6 @@
package com.earth2me.essentials.commands; package com.earth2me.essentials.commands;
import com.earth2me.essentials.User; import com.earth2me.essentials.User;
import com.earth2me.essentials.utils.CommonPlaceholders;
import net.ess3.api.TranslatableException; import net.ess3.api.TranslatableException;
import org.bukkit.Server; import org.bukkit.Server;
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
@ -44,7 +43,7 @@ public class Commandtpo extends EssentialsCommand {
target.getAsyncTeleport().now(toPlayer.getBase(), false, TeleportCause.COMMAND, future); target.getAsyncTeleport().now(toPlayer.getBase(), false, TeleportCause.COMMAND, future);
future.thenAccept(success -> { future.thenAccept(success -> {
if (success) { if (success) {
target.sendTl("teleportAtoB", CommonPlaceholders.displayName(user), CommonPlaceholders.displayName(toPlayer)); target.sendTl("teleportAtoB", user.getDisplayName(), toPlayer.getDisplayName());
} }
}); });
break; break;

View File

@ -1,7 +1,6 @@
package com.earth2me.essentials.commands; package com.earth2me.essentials.commands;
import com.earth2me.essentials.User; import com.earth2me.essentials.User;
import com.earth2me.essentials.utils.CommonPlaceholders;
import net.ess3.api.TranslatableException; import net.ess3.api.TranslatableException;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Server; import org.bukkit.Server;
@ -22,7 +21,7 @@ public class Commandtpoffline extends EssentialsCommand {
final Location logout = target.getLogoutLocation(); final Location logout = target.getLogoutLocation();
if (logout == null) { if (logout == null) {
user.sendTl("teleportOfflineUnknown", CommonPlaceholders.displayName(user)); user.sendTl("teleportOfflineUnknown", user.getDisplayName());
throw new NoChargeException(); throw new NoChargeException();
} }

View File

@ -2,7 +2,6 @@ package com.earth2me.essentials.commands;
import com.earth2me.essentials.CommandSource; import com.earth2me.essentials.CommandSource;
import com.earth2me.essentials.User; import com.earth2me.essentials.User;
import com.earth2me.essentials.utils.CommonPlaceholders;
import org.bukkit.Server; import org.bukkit.Server;
public class Commandtptoggle extends EssentialsToggleCommand { public class Commandtptoggle extends EssentialsToggleCommand {
@ -30,7 +29,7 @@ public class Commandtptoggle extends EssentialsToggleCommand {
user.sendTl(enabled ? "teleportationEnabled" : "teleportationDisabled"); user.sendTl(enabled ? "teleportationEnabled" : "teleportationDisabled");
if (!sender.isPlayer() || !user.getBase().equals(sender.getPlayer())) { if (!sender.isPlayer() || !user.getBase().equals(sender.getPlayer())) {
sender.sendTl(enabled ? "teleportationEnabledFor" : "teleportationDisabledFor", CommonPlaceholders.displayName(user)); sender.sendTl(enabled ? "teleportationEnabledFor" : "teleportationDisabledFor", user.getDisplayName());
} }
} }
} }

View File

@ -2,7 +2,6 @@ package com.earth2me.essentials.commands;
import com.earth2me.essentials.User; import com.earth2me.essentials.User;
import com.earth2me.essentials.craftbukkit.Inventories; import com.earth2me.essentials.craftbukkit.Inventories;
import com.earth2me.essentials.utils.CommonPlaceholders;
import net.ess3.api.TranslatableException; import net.ess3.api.TranslatableException;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Server; import org.bukkit.Server;
@ -82,9 +81,9 @@ public class Commandunlimited extends EssentialsCommand {
} }
if (user != target) { if (user != target) {
user.sendTl(message, itemname, CommonPlaceholders.displayName(target)); user.sendTl(message, itemname, target.getDisplayName());
} }
target.sendTl(message, itemname, CommonPlaceholders.displayName(target)); target.sendTl(message, itemname, target.getDisplayName());
target.setUnlimited(stack, enableUnlimited); target.setUnlimited(stack, enableUnlimited);
} }
} }

View File

@ -34,13 +34,13 @@ public class Commandvanish extends EssentialsToggleCommand {
} }
user.setVanished(enabled); user.setVanished(enabled);
user.sendTl("vanish", CommonPlaceholders.displayName(user), CommonPlaceholders.enableDisable(user.getSource(), enabled)); user.sendTl("vanish", user.getDisplayName(), CommonPlaceholders.enableDisable(user.getSource(), enabled));
if (enabled) { if (enabled) {
user.sendTl("vanished"); user.sendTl("vanished");
} }
if (!sender.isPlayer() || !sender.getPlayer().equals(user.getBase())) { if (!sender.isPlayer() || !sender.getPlayer().equals(user.getBase())) {
sender.sendTl("vanish", CommonPlaceholders.displayName(user), CommonPlaceholders.enableDisable(user.getSource(), enabled)); sender.sendTl("vanish", user.getDisplayName(), CommonPlaceholders.enableDisable(user.getSource(), enabled));
} }
} }
} }

View File

@ -34,7 +34,7 @@ public class Commandwhois extends EssentialsCommand {
sender.sendTl("whoisTop", user.getName()); sender.sendTl("whoisTop", user.getName());
user.setDisplayNick(); user.setDisplayNick();
sender.sendTl("whoisNick", CommonPlaceholders.displayName(user)); sender.sendTl("whoisNick", user.getDisplayName());
sender.sendTl("whoisUuid", user.getBase().getUniqueId().toString()); sender.sendTl("whoisUuid", user.getBase().getUniqueId().toString());
sender.sendTl("whoisHealth", user.getBase().getHealth()); sender.sendTl("whoisHealth", user.getBase().getHealth());
sender.sendTl("whoisHunger", user.getBase().getFoodLevel(), user.getBase().getSaturation()); sender.sendTl("whoisHunger", user.getBase().getFoodLevel(), user.getBase().getSaturation());

View File

@ -3,9 +3,7 @@ package com.earth2me.essentials.signs;
import com.earth2me.essentials.ChargeException; import com.earth2me.essentials.ChargeException;
import com.earth2me.essentials.Trade; import com.earth2me.essentials.Trade;
import com.earth2me.essentials.User; import com.earth2me.essentials.User;
import com.earth2me.essentials.utils.CommonPlaceholders;
import net.ess3.api.IEssentials; import net.ess3.api.IEssentials;
import net.ess3.api.IUser;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -40,7 +38,7 @@ public class SignGameMode extends EssentialsSign {
charge.isAffordableFor(player); charge.isAffordableFor(player);
performSetMode(mode.toLowerCase(Locale.ENGLISH), player.getBase()); performSetMode(mode.toLowerCase(Locale.ENGLISH), player.getBase());
player.sendTl("gameMode", player.playerTl(player.getBase().getGameMode().toString().toLowerCase(Locale.ENGLISH)), CommonPlaceholders.displayName((IUser) player)); player.sendTl("gameMode", player.playerTl(player.getBase().getGameMode().toString().toLowerCase(Locale.ENGLISH)), player.getDisplayName());
Trade.log("Sign", "gameMode", "Interact", username, null, username, charge, sign.getBlock().getLocation(), player.getMoney(), ess); Trade.log("Sign", "gameMode", "Interact", username, null, username, charge, sign.getBlock().getLocation(), player.getMoney(), ess);
charge.charge(player); charge.charge(player);
return true; return true;

View File

@ -1,8 +1,6 @@
package com.earth2me.essentials.utils; package com.earth2me.essentials.utils;
import com.earth2me.essentials.CommandSource; import com.earth2me.essentials.CommandSource;
import com.earth2me.essentials.messaging.IMessageRecipient;
import net.ess3.api.IUser;
public final class CommonPlaceholders { public final class CommonPlaceholders {
private CommonPlaceholders() { private CommonPlaceholders() {
@ -15,12 +13,4 @@ public final class CommonPlaceholders {
public static AdventureUtil.ParsedPlaceholder trueFalse(final CommandSource source, final boolean condition) { public static AdventureUtil.ParsedPlaceholder trueFalse(final CommandSource source, final boolean condition) {
return AdventureUtil.parsed(source.tl(condition ? "true" : "false")); return AdventureUtil.parsed(source.tl(condition ? "true" : "false"));
} }
public static AdventureUtil.ParsedPlaceholder displayNameRecipient(final IMessageRecipient recipient) {
return AdventureUtil.parsed(AdventureUtil.legacyToMini(recipient.getDisplayName()));
}
public static AdventureUtil.ParsedPlaceholder displayName(final IUser user) {
return AdventureUtil.parsed(AdventureUtil.legacyToMini(user.getDisplayName()));
}
} }

View File

@ -3,8 +3,6 @@ package com.earth2me.essentials.chat;
import com.earth2me.essentials.CommandSource; import com.earth2me.essentials.CommandSource;
import com.earth2me.essentials.User; import com.earth2me.essentials.User;
import com.earth2me.essentials.commands.EssentialsToggleCommand; import com.earth2me.essentials.commands.EssentialsToggleCommand;
import com.earth2me.essentials.utils.CommonPlaceholders;
import net.ess3.api.IUser;
import org.bukkit.Server; import org.bukkit.Server;
public class Commandtoggleshout extends EssentialsToggleCommand { public class Commandtoggleshout extends EssentialsToggleCommand {
@ -32,7 +30,7 @@ public class Commandtoggleshout extends EssentialsToggleCommand {
user.sendTl(enabled ? "shoutEnabled" : "shoutDisabled"); user.sendTl(enabled ? "shoutEnabled" : "shoutDisabled");
if (!sender.isPlayer() || !user.getBase().equals(sender.getPlayer())) { if (!sender.isPlayer() || !user.getBase().equals(sender.getPlayer())) {
sender.sendTl(enabled ? "shoutEnabledFor" : "shoutDisabledFor", CommonPlaceholders.displayName((IUser) user)); sender.sendTl(enabled ? "shoutEnabledFor" : "shoutDisabledFor", user.getDisplayName());
} }
} }
} }

View File

@ -4,7 +4,6 @@ import com.earth2me.essentials.IConf;
import com.earth2me.essentials.User; import com.earth2me.essentials.User;
import com.earth2me.essentials.config.EssentialsConfiguration; import com.earth2me.essentials.config.EssentialsConfiguration;
import com.earth2me.essentials.utils.AdventureUtil; import com.earth2me.essentials.utils.AdventureUtil;
import com.earth2me.essentials.utils.CommonPlaceholders;
import com.ice.tar.TarEntry; import com.ice.tar.TarEntry;
import com.ice.tar.TarInputStream; import com.ice.tar.TarInputStream;
import com.maxmind.geoip2.DatabaseReader; import com.maxmind.geoip2.DatabaseReader;
@ -13,7 +12,6 @@ import com.maxmind.geoip2.exception.GeoIp2Exception;
import com.maxmind.geoip2.model.CityResponse; import com.maxmind.geoip2.model.CityResponse;
import com.maxmind.geoip2.model.CountryResponse; import com.maxmind.geoip2.model.CountryResponse;
import net.ess3.api.IEssentials; import net.ess3.api.IEssentials;
import net.ess3.api.IUser;
import net.essentialsx.api.v2.events.AsyncUserDataLoadEvent; import net.essentialsx.api.v2.events.AsyncUserDataLoadEvent;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
@ -102,7 +100,7 @@ public class EssentialsGeoIPPlayerListener implements Listener, IConf {
for (final Player online : player.getServer().getOnlinePlayers()) { for (final Player online : player.getServer().getOnlinePlayers()) {
final User user = ess.getUser(online); final User user = ess.getUser(online);
if (user.isAuthorized("essentials.geoip.show")) { if (user.isAuthorized("essentials.geoip.show")) {
user.sendTl("geoipCantFind", CommonPlaceholders.displayName((IUser) u)); user.sendTl("geoipCantFind", u.getDisplayName());
} }
} }
return; return;
@ -121,7 +119,7 @@ public class EssentialsGeoIPPlayerListener implements Listener, IConf {
for (final Player onlinePlayer : player.getServer().getOnlinePlayers()) { for (final Player onlinePlayer : player.getServer().getOnlinePlayers()) {
final User user = ess.getUser(onlinePlayer); final User user = ess.getUser(onlinePlayer);
if (user.isAuthorized("essentials.geoip.show")) { if (user.isAuthorized("essentials.geoip.show")) {
user.sendTl("geoipJoinFormat", CommonPlaceholders.displayName((IUser) u), sb.toString()); user.sendTl("geoipJoinFormat", u.getDisplayName(), sb.toString());
} }
} }
} }

View File

@ -7,8 +7,6 @@ import com.earth2me.essentials.User;
import com.earth2me.essentials.commands.EssentialsCommand; import com.earth2me.essentials.commands.EssentialsCommand;
import com.earth2me.essentials.commands.NoChargeException; import com.earth2me.essentials.commands.NoChargeException;
import com.earth2me.essentials.commands.NotEnoughArgumentsException; import com.earth2me.essentials.commands.NotEnoughArgumentsException;
import com.earth2me.essentials.utils.CommonPlaceholders;
import net.ess3.api.IUser;
import net.essentialsx.api.v2.events.UserTeleportSpawnEvent; import net.essentialsx.api.v2.events.UserTeleportSpawnEvent;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Server; import org.bukkit.Server;
@ -33,7 +31,7 @@ public class Commandspawn extends EssentialsCommand {
future.thenAccept(success -> { future.thenAccept(success -> {
if (success) { if (success) {
if (!otherUser.equals(user)) { if (!otherUser.equals(user)) {
otherUser.sendTl("teleportAtoB", CommonPlaceholders.displayName((IUser) user), "spawn"); otherUser.sendTl("teleportAtoB", user.getDisplayName(), "spawn");
} }
} }
}); });