mirror of
https://github.com/EssentialsX/Essentials.git
synced 2025-01-21 23:51:42 +01:00
Fix several regressions from adventure PR (#5637)
* Fixes /list * Fixes /baltop * Fixes Social Spy * Fixes Essentials Signs
This commit is contained in:
parent
3b61b3ed31
commit
16e297269d
@ -1,9 +1,9 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import com.earth2me.essentials.utils.AdventureUtil;
|
||||
import com.earth2me.essentials.utils.FormatUtil;
|
||||
import com.earth2me.essentials.utils.NumberUtil;
|
||||
import net.ess3.api.TranslatableException;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Server;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -39,13 +39,13 @@ public final class PlayerList {
|
||||
groupString.append(tlLiteral("listHiddenTag"));
|
||||
}
|
||||
user.setDisplayNick();
|
||||
groupString.append(user.getDisplayName());
|
||||
groupString.append(AdventureUtil.legacyToMini(user.getDisplayName()));
|
||||
|
||||
final String strippedNick = FormatUtil.stripFormat(user.getNickname());
|
||||
if (ess.getSettings().realNamesOnList() && strippedNick != null && !strippedNick.equals(user.getName())) {
|
||||
groupString.append(" ").append(tlLiteral("listRealName",user.getName()));
|
||||
}
|
||||
groupString.append(ChatColor.WHITE);
|
||||
groupString.append("<white>");
|
||||
}
|
||||
return groupString.toString();
|
||||
}
|
||||
|
@ -110,11 +110,11 @@ public class Commandbalancetop extends EssentialsCommand {
|
||||
future.thenRun(() -> {
|
||||
if (fresh) {
|
||||
final SimpleTextInput newCache = new SimpleTextInput();
|
||||
newCache.getLines().add(tlLiteral("serverTotal", NumberUtil.displayCurrency(ess.getBalanceTop().getBalanceTopTotal(), ess)));
|
||||
newCache.getLines().add(AdventureUtil.miniToLegacy(tlLiteral("serverTotal", NumberUtil.displayCurrency(ess.getBalanceTop().getBalanceTopTotal(), ess))));
|
||||
int pos = 1;
|
||||
for (final Map.Entry<UUID, BalanceTop.Entry> entry : ess.getBalanceTop().getBalanceTopCache().entrySet()) {
|
||||
if (ess.getSettings().showZeroBaltop() || entry.getValue().getBalance().compareTo(BigDecimal.ZERO) > 0) {
|
||||
newCache.getLines().add(tlLiteral("balanceTopLine", pos, AdventureUtil.parsed(AdventureUtil.legacyToMini(entry.getValue().getDisplayName())), NumberUtil.displayCurrency(entry.getValue().getBalance(), ess)));
|
||||
newCache.getLines().add(AdventureUtil.miniToLegacy(tlLiteral("balanceTopLine", pos, entry.getValue().getDisplayName(), NumberUtil.displayCurrency(entry.getValue().getBalance(), ess))));
|
||||
}
|
||||
pos++;
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package com.earth2me.essentials.commands;
|
||||
import com.earth2me.essentials.CommandSource;
|
||||
import com.earth2me.essentials.PlayerList;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.utils.AdventureUtil;
|
||||
import org.bukkit.Server;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -23,11 +24,11 @@ public class Commandlist extends EssentialsCommand {
|
||||
user = ess.getUser(sender.getPlayer());
|
||||
showHidden = user.isAuthorized("essentials.list.hidden") || user.canInteractVanished();
|
||||
}
|
||||
sender.sendMessage(PlayerList.listSummary(ess, user, showHidden));
|
||||
sender.sendComponent(AdventureUtil.miniMessage().deserialize(PlayerList.listSummary(ess, user, 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.sendComponent(AdventureUtil.miniMessage().deserialize(PlayerList.listGroupUsers(ess, playerList, args[0].toLowerCase())));
|
||||
} else {
|
||||
sendGroupedList(sender, commandLabel, playerList);
|
||||
}
|
||||
@ -36,7 +37,7 @@ public class Commandlist extends EssentialsCommand {
|
||||
// Output the standard /list output, when no group is specified
|
||||
private void sendGroupedList(final CommandSource sender, final String commandLabel, final Map<String, List<User>> playerList) {
|
||||
for (final String str : PlayerList.prepareGroupedList(ess, sender, commandLabel, playerList)) {
|
||||
sender.sendMessage(str);
|
||||
sender.sendComponent(AdventureUtil.miniMessage().deserialize(str));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,6 @@ import com.earth2me.essentials.IEssentials;
|
||||
import com.earth2me.essentials.IUser;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.utils.AdventureUtil;
|
||||
import com.earth2me.essentials.utils.CommonPlaceholders;
|
||||
import net.ess3.api.events.PrivateMessagePreSendEvent;
|
||||
import net.ess3.api.events.PrivateMessageSentEvent;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -128,9 +127,9 @@ public class SimpleMessageRecipient implements IMessageRecipient {
|
||||
&& !onlineUser.equals(senderUser)
|
||||
&& !onlineUser.equals(recipient)) {
|
||||
if (senderUser.isMuted() && ess.getSettings().getSocialSpyListenMutedPlayers()) {
|
||||
onlineUser.sendMessage(tlSender("socialSpyMutedPrefix") + tlLiteral("socialSpyMsgFormat", CommonPlaceholders.displayNameRecipient(this), CommonPlaceholders.displayNameRecipient(recipient), message));
|
||||
onlineUser.sendComponent(AdventureUtil.miniMessage().deserialize(tlSender("socialSpyMutedPrefix") + tlLiteral("socialSpyMsgFormat", getDisplayName(), recipient.getDisplayName(), message)));
|
||||
} else {
|
||||
onlineUser.sendMessage(tlLiteral("socialSpyPrefix") + tlLiteral("socialSpyMsgFormat", CommonPlaceholders.displayNameRecipient(this), CommonPlaceholders.displayNameRecipient(recipient), message));
|
||||
onlineUser.sendComponent(AdventureUtil.miniMessage().deserialize(tlLiteral("socialSpyPrefix") + tlLiteral("socialSpyMsgFormat", getDisplayName(), recipient.getDisplayName(), message)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import com.earth2me.essentials.CommandSource;
|
||||
import com.earth2me.essentials.MetaItemStack;
|
||||
import com.earth2me.essentials.Trade;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.utils.AdventureUtil;
|
||||
import com.earth2me.essentials.utils.FormatUtil;
|
||||
import com.earth2me.essentials.utils.MaterialUtil;
|
||||
import com.earth2me.essentials.utils.NumberUtil;
|
||||
@ -103,7 +104,7 @@ public class EssentialsSign {
|
||||
// they won't change it to §1[Signname]
|
||||
return true;
|
||||
}
|
||||
sign.setLine(0, tlLiteral("signFormatFail", this.signName));
|
||||
sign.setLine(0, AdventureUtil.miniToLegacy(tlLiteral("signFormatFail", this.signName)));
|
||||
|
||||
final SignCreateEvent signEvent = new SignCreateEvent(sign, this, user);
|
||||
ess.getServer().getPluginManager().callEvent(signEvent);
|
||||
@ -137,7 +138,7 @@ public class EssentialsSign {
|
||||
}
|
||||
|
||||
public String getSuccessName() {
|
||||
String successName = tlLiteral("signFormatSuccess", this.signName);
|
||||
String successName = AdventureUtil.miniToLegacy(tlLiteral("signFormatSuccess", this.signName));
|
||||
if (successName.isEmpty() || !successName.contains(this.signName)) {
|
||||
// Set to null to cause an error in place of no functionality. This makes an error obvious as opposed to leaving users baffled by lack of
|
||||
// functionality.
|
||||
@ -147,7 +148,7 @@ public class EssentialsSign {
|
||||
}
|
||||
|
||||
public String getTemplateName() {
|
||||
return tlLiteral("signFormatTemplate", this.signName);
|
||||
return AdventureUtil.miniToLegacy(tlLiteral("signFormatTemplate", this.signName));
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
@ -407,7 +408,7 @@ public class EssentialsSign {
|
||||
item.setAmount(quantity);
|
||||
return item;
|
||||
} catch (final Exception ex) {
|
||||
throw new SignException(ex, ex.getMessage());
|
||||
throw new SignException(ex, "errorWithMessage", ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@ -425,7 +426,7 @@ public class EssentialsSign {
|
||||
stack = metaStack.getItemStack();
|
||||
}
|
||||
} catch (final Exception ex) {
|
||||
throw new SignException(ex, ex.getMessage());
|
||||
throw new SignException(ex, "errorWithMessage", ex.getMessage());
|
||||
}
|
||||
return stack;
|
||||
}
|
||||
@ -447,7 +448,7 @@ public class EssentialsSign {
|
||||
try {
|
||||
return new BigDecimal(NumberUtil.sanitizeCurrencyString(line, ess));
|
||||
} catch (final ArithmeticException | NumberFormatException ex) {
|
||||
throw new SignException(ex, ex.getMessage());
|
||||
throw new SignException(ex, "errorWithMessage", ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,7 @@ public class SignEnchant extends EssentialsSign {
|
||||
level = Integer.parseInt(enchantLevel[1]);
|
||||
} catch (final NumberFormatException ex) {
|
||||
sign.setLine(2, "§c<enchant>");
|
||||
throw new SignException(ex, ex.getMessage());
|
||||
throw new SignException(ex, "errorWithMessage", ex.getMessage());
|
||||
}
|
||||
}
|
||||
final boolean allowUnsafe = ess.getSettings().allowUnsafeEnchantments() && player.isAuthorized("essentials.enchantments.allowunsafe") && player.isAuthorized("essentials.signs.enchant.allowunsafe");
|
||||
@ -57,7 +57,7 @@ public class SignEnchant extends EssentialsSign {
|
||||
}
|
||||
}
|
||||
} catch (final Throwable ex) {
|
||||
throw new SignException(ex, ex.getMessage());
|
||||
throw new SignException(ex, "errorWithMessage", ex.getMessage());
|
||||
}
|
||||
getTrade(sign, 3, ess);
|
||||
return true;
|
||||
@ -81,7 +81,7 @@ public class SignEnchant extends EssentialsSign {
|
||||
try {
|
||||
level = Integer.parseInt(enchantLevel[1]);
|
||||
} catch (final NumberFormatException ex) {
|
||||
throw new SignException(ex, ex.getMessage());
|
||||
throw new SignException(ex, "errorWithMessage", ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@ -103,7 +103,7 @@ public class SignEnchant extends EssentialsSign {
|
||||
}
|
||||
}
|
||||
} catch (final Exception ex) {
|
||||
throw new SignException(ex, ex.getMessage());
|
||||
throw new SignException(ex, "errorWithMessage", ex.getMessage());
|
||||
}
|
||||
|
||||
final String enchantmentName = enchantment.getName().toLowerCase(Locale.ENGLISH);
|
||||
|
@ -21,7 +21,7 @@ public class SignFree extends EssentialsSign {
|
||||
item = getItemMeta(item, sign.getLine(3), ess);
|
||||
} catch (final SignException ex) {
|
||||
sign.setLine(1, "§c<item>");
|
||||
throw new SignException(ex, ex.getMessage());
|
||||
throw new SignException(ex, "errorWithMessage", ex.getMessage());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ public class SignInfo extends EssentialsSign {
|
||||
pager.showPage(chapter, page, null, player.getSource());
|
||||
|
||||
} catch (final IOException ex) {
|
||||
throw new SignException(ex, ex.getMessage());
|
||||
throw new SignException(ex, "errorWithMessage", ex.getMessage());
|
||||
}
|
||||
|
||||
charge.charge(player);
|
||||
|
@ -27,7 +27,7 @@ public class SignKit extends EssentialsSign {
|
||||
try {
|
||||
ess.getKits().getKit(kitName);
|
||||
} catch (final Exception ex) {
|
||||
throw new SignException(ex, ex.getMessage());
|
||||
throw new SignException(ex, "errorWithMessage", ex.getMessage());
|
||||
}
|
||||
final String group = sign.getLine(2);
|
||||
if ("Everyone".equalsIgnoreCase(group) || "Everybody".equalsIgnoreCase(group)) {
|
||||
@ -55,7 +55,7 @@ public class SignKit extends EssentialsSign {
|
||||
} catch (final NoChargeException ex) {
|
||||
return false;
|
||||
} catch (final Exception ex) {
|
||||
throw new SignException(ex, ex.getMessage());
|
||||
throw new SignException(ex, "errorWithMessage", ex.getMessage());
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
|
@ -43,7 +43,7 @@ public class SignRepair extends EssentialsSign {
|
||||
}
|
||||
|
||||
} catch (final Exception ex) {
|
||||
throw new SignException(ex, ex.getMessage());
|
||||
throw new SignException(ex, "errorWithMessage", ex.getMessage());
|
||||
}
|
||||
|
||||
charge.charge(player);
|
||||
|
@ -30,7 +30,7 @@ public class SignSpawnmob extends EssentialsSign {
|
||||
final List<String> mobData = SpawnMob.mobData(sign.getLine(2));
|
||||
SpawnMob.spawnmob(ess, ess.getServer(), player.getSource(), player, mobParts, mobData, Integer.parseInt(sign.getLine(1)));
|
||||
} catch (final Exception ex) {
|
||||
throw new SignException(ex, ex.getMessage());
|
||||
throw new SignException(ex, "errorWithMessage", ex.getMessage());
|
||||
}
|
||||
|
||||
charge.charge(player);
|
||||
|
@ -25,7 +25,7 @@ public class SignWarp extends EssentialsSign {
|
||||
try {
|
||||
ess.getWarps().getWarp(warpName);
|
||||
} catch (final Exception ex) {
|
||||
throw new SignException(ex, ex.getMessage());
|
||||
throw new SignException(ex, "errorWithMessage", ex.getMessage());
|
||||
}
|
||||
final String group = sign.getLine(2);
|
||||
if ("Everyone".equalsIgnoreCase(group) || "Everybody".equalsIgnoreCase(group)) {
|
||||
|
Loading…
Reference in New Issue
Block a user