Fix several regressions from adventure PR (#5637)

* Fixes /list
* Fixes /baltop
* Fixes Social Spy
* Fixes Essentials Signs
This commit is contained in:
Josh Roy 2024-02-03 22:35:37 -05:00 committed by GitHub
parent 3b61b3ed31
commit 16e297269d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
12 changed files with 29 additions and 28 deletions

View File

@ -1,9 +1,9 @@
package com.earth2me.essentials; package com.earth2me.essentials;
import com.earth2me.essentials.utils.AdventureUtil;
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 net.ess3.api.TranslatableException; import net.ess3.api.TranslatableException;
import org.bukkit.ChatColor;
import org.bukkit.Server; import org.bukkit.Server;
import java.util.ArrayList; import java.util.ArrayList;
@ -39,13 +39,13 @@ public final class PlayerList {
groupString.append(tlLiteral("listHiddenTag")); groupString.append(tlLiteral("listHiddenTag"));
} }
user.setDisplayNick(); user.setDisplayNick();
groupString.append(user.getDisplayName()); groupString.append(AdventureUtil.legacyToMini(user.getDisplayName()));
final String strippedNick = FormatUtil.stripFormat(user.getNickname()); final String strippedNick = FormatUtil.stripFormat(user.getNickname());
if (ess.getSettings().realNamesOnList() && strippedNick != null && !strippedNick.equals(user.getName())) { if (ess.getSettings().realNamesOnList() && strippedNick != null && !strippedNick.equals(user.getName())) {
groupString.append(" ").append(tlLiteral("listRealName",user.getName())); groupString.append(" ").append(tlLiteral("listRealName",user.getName()));
} }
groupString.append(ChatColor.WHITE); groupString.append("<white>");
} }
return groupString.toString(); return groupString.toString();
} }

View File

@ -110,11 +110,11 @@ public class Commandbalancetop extends EssentialsCommand {
future.thenRun(() -> { future.thenRun(() -> {
if (fresh) { if (fresh) {
final SimpleTextInput newCache = new SimpleTextInput(); 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; int pos = 1;
for (final Map.Entry<UUID, BalanceTop.Entry> entry : ess.getBalanceTop().getBalanceTopCache().entrySet()) { for (final Map.Entry<UUID, BalanceTop.Entry> entry : ess.getBalanceTop().getBalanceTopCache().entrySet()) {
if (ess.getSettings().showZeroBaltop() || entry.getValue().getBalance().compareTo(BigDecimal.ZERO) > 0) { 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++; pos++;
} }

View File

@ -3,6 +3,7 @@ package com.earth2me.essentials.commands;
import com.earth2me.essentials.CommandSource; import com.earth2me.essentials.CommandSource;
import com.earth2me.essentials.PlayerList; import com.earth2me.essentials.PlayerList;
import com.earth2me.essentials.User; import com.earth2me.essentials.User;
import com.earth2me.essentials.utils.AdventureUtil;
import org.bukkit.Server; import org.bukkit.Server;
import java.util.ArrayList; import java.util.ArrayList;
@ -23,11 +24,11 @@ public class Commandlist extends EssentialsCommand {
user = ess.getUser(sender.getPlayer()); user = ess.getUser(sender.getPlayer());
showHidden = user.isAuthorized("essentials.list.hidden") || user.canInteractVanished(); 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); final Map<String, List<User>> playerList = PlayerList.getPlayerLists(ess, user, showHidden);
if (args.length > 0) { if (args.length > 0) {
sender.sendMessage(PlayerList.listGroupUsers(ess, playerList, args[0].toLowerCase())); sender.sendComponent(AdventureUtil.miniMessage().deserialize(PlayerList.listGroupUsers(ess, playerList, args[0].toLowerCase())));
} else { } else {
sendGroupedList(sender, commandLabel, playerList); sendGroupedList(sender, commandLabel, playerList);
} }
@ -36,7 +37,7 @@ public class Commandlist extends EssentialsCommand {
// Output the standard /list output, when no group is specified // 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) { 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)) { for (final String str : PlayerList.prepareGroupedList(ess, sender, commandLabel, playerList)) {
sender.sendMessage(str); sender.sendComponent(AdventureUtil.miniMessage().deserialize(str));
} }
} }

View File

@ -4,7 +4,6 @@ import com.earth2me.essentials.IEssentials;
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.AdventureUtil; import com.earth2me.essentials.utils.AdventureUtil;
import com.earth2me.essentials.utils.CommonPlaceholders;
import net.ess3.api.events.PrivateMessagePreSendEvent; import net.ess3.api.events.PrivateMessagePreSendEvent;
import net.ess3.api.events.PrivateMessageSentEvent; import net.ess3.api.events.PrivateMessageSentEvent;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -128,9 +127,9 @@ public class SimpleMessageRecipient implements IMessageRecipient {
&& !onlineUser.equals(senderUser) && !onlineUser.equals(senderUser)
&& !onlineUser.equals(recipient)) { && !onlineUser.equals(recipient)) {
if (senderUser.isMuted() && ess.getSettings().getSocialSpyListenMutedPlayers()) { 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 { } 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)));
} }
} }
} }

View File

@ -5,6 +5,7 @@ import com.earth2me.essentials.CommandSource;
import com.earth2me.essentials.MetaItemStack; import com.earth2me.essentials.MetaItemStack;
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.AdventureUtil;
import com.earth2me.essentials.utils.FormatUtil; import com.earth2me.essentials.utils.FormatUtil;
import com.earth2me.essentials.utils.MaterialUtil; import com.earth2me.essentials.utils.MaterialUtil;
import com.earth2me.essentials.utils.NumberUtil; import com.earth2me.essentials.utils.NumberUtil;
@ -103,7 +104,7 @@ public class EssentialsSign {
// they won't change it to §1[Signname] // they won't change it to §1[Signname]
return true; 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); final SignCreateEvent signEvent = new SignCreateEvent(sign, this, user);
ess.getServer().getPluginManager().callEvent(signEvent); ess.getServer().getPluginManager().callEvent(signEvent);
@ -137,7 +138,7 @@ public class EssentialsSign {
} }
public String getSuccessName() { public String getSuccessName() {
String successName = tlLiteral("signFormatSuccess", this.signName); String successName = AdventureUtil.miniToLegacy(tlLiteral("signFormatSuccess", this.signName));
if (successName.isEmpty() || !successName.contains(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 // 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. // functionality.
@ -147,7 +148,7 @@ public class EssentialsSign {
} }
public String getTemplateName() { public String getTemplateName() {
return tlLiteral("signFormatTemplate", this.signName); return AdventureUtil.miniToLegacy(tlLiteral("signFormatTemplate", this.signName));
} }
public String getName() { public String getName() {
@ -407,7 +408,7 @@ public class EssentialsSign {
item.setAmount(quantity); item.setAmount(quantity);
return item; return item;
} catch (final Exception ex) { } 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(); stack = metaStack.getItemStack();
} }
} catch (final Exception ex) { } catch (final Exception ex) {
throw new SignException(ex, ex.getMessage()); throw new SignException(ex, "errorWithMessage", ex.getMessage());
} }
return stack; return stack;
} }
@ -447,7 +448,7 @@ public class EssentialsSign {
try { try {
return new BigDecimal(NumberUtil.sanitizeCurrencyString(line, ess)); return new BigDecimal(NumberUtil.sanitizeCurrencyString(line, ess));
} catch (final ArithmeticException | NumberFormatException ex) { } catch (final ArithmeticException | NumberFormatException ex) {
throw new SignException(ex, ex.getMessage()); throw new SignException(ex, "errorWithMessage", ex.getMessage());
} }
} }

View File

@ -40,7 +40,7 @@ public class SignEnchant extends EssentialsSign {
level = Integer.parseInt(enchantLevel[1]); level = Integer.parseInt(enchantLevel[1]);
} catch (final NumberFormatException ex) { } catch (final NumberFormatException ex) {
sign.setLine(2, "§c<enchant>"); 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"); 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) { } catch (final Throwable ex) {
throw new SignException(ex, ex.getMessage()); throw new SignException(ex, "errorWithMessage", ex.getMessage());
} }
getTrade(sign, 3, ess); getTrade(sign, 3, ess);
return true; return true;
@ -81,7 +81,7 @@ public class SignEnchant extends EssentialsSign {
try { try {
level = Integer.parseInt(enchantLevel[1]); level = Integer.parseInt(enchantLevel[1]);
} catch (final NumberFormatException ex) { } 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) { } 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); final String enchantmentName = enchantment.getName().toLowerCase(Locale.ENGLISH);

View File

@ -21,7 +21,7 @@ public class SignFree extends EssentialsSign {
item = getItemMeta(item, sign.getLine(3), ess); item = getItemMeta(item, sign.getLine(3), ess);
} catch (final SignException ex) { } catch (final SignException ex) {
sign.setLine(1, "§c<item>"); sign.setLine(1, "§c<item>");
throw new SignException(ex, ex.getMessage()); throw new SignException(ex, "errorWithMessage", ex.getMessage());
} }
return true; return true;
} }

View File

@ -39,7 +39,7 @@ public class SignInfo extends EssentialsSign {
pager.showPage(chapter, page, null, player.getSource()); pager.showPage(chapter, page, null, player.getSource());
} catch (final IOException ex) { } catch (final IOException ex) {
throw new SignException(ex, ex.getMessage()); throw new SignException(ex, "errorWithMessage", ex.getMessage());
} }
charge.charge(player); charge.charge(player);

View File

@ -27,7 +27,7 @@ public class SignKit extends EssentialsSign {
try { try {
ess.getKits().getKit(kitName); ess.getKits().getKit(kitName);
} catch (final Exception ex) { } catch (final Exception ex) {
throw new SignException(ex, ex.getMessage()); throw new SignException(ex, "errorWithMessage", ex.getMessage());
} }
final String group = sign.getLine(2); final String group = sign.getLine(2);
if ("Everyone".equalsIgnoreCase(group) || "Everybody".equalsIgnoreCase(group)) { if ("Everyone".equalsIgnoreCase(group) || "Everybody".equalsIgnoreCase(group)) {
@ -55,7 +55,7 @@ public class SignKit extends EssentialsSign {
} catch (final NoChargeException ex) { } catch (final NoChargeException ex) {
return false; return false;
} catch (final Exception ex) { } catch (final Exception ex) {
throw new SignException(ex, ex.getMessage()); throw new SignException(ex, "errorWithMessage", ex.getMessage());
} }
return true; return true;
} else { } else {

View File

@ -43,7 +43,7 @@ public class SignRepair extends EssentialsSign {
} }
} catch (final Exception ex) { } catch (final Exception ex) {
throw new SignException(ex, ex.getMessage()); throw new SignException(ex, "errorWithMessage", ex.getMessage());
} }
charge.charge(player); charge.charge(player);

View File

@ -30,7 +30,7 @@ public class SignSpawnmob extends EssentialsSign {
final List<String> mobData = SpawnMob.mobData(sign.getLine(2)); final List<String> mobData = SpawnMob.mobData(sign.getLine(2));
SpawnMob.spawnmob(ess, ess.getServer(), player.getSource(), player, mobParts, mobData, Integer.parseInt(sign.getLine(1))); SpawnMob.spawnmob(ess, ess.getServer(), player.getSource(), player, mobParts, mobData, Integer.parseInt(sign.getLine(1)));
} catch (final Exception ex) { } catch (final Exception ex) {
throw new SignException(ex, ex.getMessage()); throw new SignException(ex, "errorWithMessage", ex.getMessage());
} }
charge.charge(player); charge.charge(player);

View File

@ -25,7 +25,7 @@ public class SignWarp extends EssentialsSign {
try { try {
ess.getWarps().getWarp(warpName); ess.getWarps().getWarp(warpName);
} catch (final Exception ex) { } catch (final Exception ex) {
throw new SignException(ex, ex.getMessage()); throw new SignException(ex, "errorWithMessage", ex.getMessage());
} }
final String group = sign.getLine(2); final String group = sign.getLine(2);
if ("Everyone".equalsIgnoreCase(group) || "Everybody".equalsIgnoreCase(group)) { if ("Everyone".equalsIgnoreCase(group) || "Everybody".equalsIgnoreCase(group)) {