mirror of
https://github.com/EssentialsX/Essentials.git
synced 2025-01-02 22:47:41 +01:00
Fix message display issues from Adventure refactor (#5648)
Co-authored-by: Josh Roy <10731363+JRoy@users.noreply.github.com>
This commit is contained in:
parent
16e297269d
commit
0d1462a021
@ -904,7 +904,8 @@ public class Essentials extends JavaPlugin implements net.ess3.api.IEssentials {
|
||||
@Override
|
||||
public void showError(final CommandSource sender, final Throwable exception, final String commandLabel) {
|
||||
if (exception instanceof TranslatableException) {
|
||||
sender.sendTl(((TranslatableException) exception).getTlKey(), ((TranslatableException) exception).getArgs());
|
||||
final String tlMessage = sender.tl(((TranslatableException) exception).getTlKey(), ((TranslatableException) exception).getArgs());
|
||||
sender.sendTl("errorWithMessage", AdventureUtil.parsed(tlMessage));
|
||||
} else {
|
||||
sender.sendTl("errorWithMessage", exception.getMessage());
|
||||
}
|
||||
|
@ -642,11 +642,10 @@ public class EssentialsPlayerListener implements Listener, FakeAccessor {
|
||||
if (!user.isAuthorized("essentials.chat.spy.exempt")) {
|
||||
for (final User spyer : ess.getOnlineUsers()) {
|
||||
if (spyer.isSocialSpyEnabled() && !player.equals(spyer.getBase())) {
|
||||
if (user.isMuted() && ess.getSettings().getSocialSpyListenMutedPlayers()) {
|
||||
spyer.sendMessage(spyer.playerTl("socialSpyMutedPrefix") + player.getDisplayName() + ": " + event.getMessage());
|
||||
} else {
|
||||
spyer.sendMessage(spyer.playerTl("socialSpyPrefix") + player.getDisplayName() + ": " + event.getMessage());
|
||||
}
|
||||
final Component base = (user.isMuted() && ess.getSettings().getSocialSpyListenMutedPlayers())
|
||||
? spyer.tlComponent("socialSpyMutedPrefix")
|
||||
: spyer.tlComponent("socialSpyPrefix");
|
||||
spyer.sendComponent(base.append(Component.text(AdventureUtil.legacyToAdventure(player.getDisplayName()) + ": " + event.getMessage())));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -847,7 +847,7 @@ public class User extends UserData implements Comparable<User>, IMessageRecipien
|
||||
lastActivity = 0;
|
||||
final double kickTime = autoafkkick / 60.0;
|
||||
|
||||
this.getBase().kickPlayer(playerTl("autoAfkKickReason", kickTime));
|
||||
this.getBase().kickPlayer(AdventureUtil.miniToLegacy(playerTl("autoAfkKickReason", kickTime)));
|
||||
|
||||
for (final User user : ess.getOnlineUsers()) {
|
||||
if (user.isAuthorized("essentials.kick.notify")) {
|
||||
|
@ -55,7 +55,7 @@ public class Commandban extends EssentialsCommand {
|
||||
|
||||
final String banDisplay = tlLiteral("banFormat", banReason, senderDisplayName);
|
||||
|
||||
user.getBase().kickPlayer(banDisplay);
|
||||
user.getBase().kickPlayer(AdventureUtil.miniToLegacy(banDisplay));
|
||||
ess.getLogger().log(Level.INFO, AdventureUtil.miniToLegacy(tlLiteral("playerBanned", senderDisplayName, user.getName(), banDisplay)));
|
||||
|
||||
if (nomatch) {
|
||||
|
@ -52,7 +52,7 @@ public class Commandbanip extends EssentialsCommand {
|
||||
banReason = tlLiteral("defaultBanReason");
|
||||
}
|
||||
|
||||
final String banDisplay = tlLiteral("banFormat", banReason, senderDisplayName);
|
||||
final String banDisplay = AdventureUtil.miniToLegacy(tlLiteral("banFormat", banReason, senderDisplayName));
|
||||
|
||||
ess.getServer().getBanList(BanList.Type.IP).addBan(ipAddress, banReason, null, senderName);
|
||||
ess.getLogger().log(Level.INFO, AdventureUtil.miniToLegacy(tlLiteral("playerBanIpAddress", senderDisplayName, ipAddress, banReason)));
|
||||
|
@ -7,6 +7,7 @@ import com.earth2me.essentials.textreader.IText;
|
||||
import com.earth2me.essentials.textreader.KeywordReplacer;
|
||||
import com.earth2me.essentials.textreader.TextInput;
|
||||
import com.earth2me.essentials.textreader.TextPager;
|
||||
import com.earth2me.essentials.utils.AdventureUtil;
|
||||
import com.earth2me.essentials.utils.NumberUtil;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.Command;
|
||||
@ -44,7 +45,7 @@ public class Commandhelp extends EssentialsCommand {
|
||||
final IEssentialsCommand essCommand = isEssCommand ? ess.getCommandMap().get(knownCmd.getValue().getName()) : null;
|
||||
if (essCommand != null && !essCommand.getUsageStrings().isEmpty()) {
|
||||
for (Map.Entry<String, String> usage : essCommand.getUsageStrings().entrySet()) {
|
||||
user.sendTl("commandHelpLineUsage", usage.getKey().replace("<command>", cmd), usage.getValue());
|
||||
user.sendTl("commandHelpLineUsage", usage.getKey().replace("<command>", cmd), AdventureUtil.parsed(usage.getValue()));
|
||||
}
|
||||
} else {
|
||||
user.sendMessage(knownCmd.getValue().getUsage());
|
||||
|
@ -39,7 +39,7 @@ public class Commandkick extends EssentialsCommand {
|
||||
}
|
||||
}
|
||||
|
||||
String kickReason = args.length > 1 ? getFinalArg(args, 1) : tlLiteral("kickDefault");
|
||||
String kickReason = args.length > 1 ? getFinalArg(args, 1) : AdventureUtil.miniToLegacy(tlLiteral("kickDefault"));
|
||||
kickReason = FormatUtil.replaceFormat(kickReason.replace("\\n", "\n").replace("|", "\n"));
|
||||
|
||||
final UserKickEvent event = new UserKickEvent(user, target, kickReason);
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.CommandSource;
|
||||
import com.earth2me.essentials.utils.AdventureUtil;
|
||||
import com.earth2me.essentials.utils.FormatUtil;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -14,7 +15,7 @@ public class Commandkickall extends EssentialsCommand {
|
||||
|
||||
@Override
|
||||
public void run(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception {
|
||||
String kickReason = args.length > 0 ? getFinalArg(args, 0) : tlLiteral("kickDefault");
|
||||
String kickReason = args.length > 0 ? getFinalArg(args, 0) : AdventureUtil.miniToLegacy(tlLiteral("kickDefault"));
|
||||
kickReason = FormatUtil.replaceFormat(kickReason.replace("\\n", "\n").replace("|", "\n"));
|
||||
|
||||
for (final Player onlinePlayer : ess.getOnlinePlayers()) {
|
||||
|
@ -2,6 +2,7 @@ package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.CommandSource;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.utils.AdventureUtil;
|
||||
import com.earth2me.essentials.utils.CommonPlaceholders;
|
||||
import com.google.common.collect.Lists;
|
||||
import net.ess3.api.IUser;
|
||||
@ -74,7 +75,7 @@ public class Commandnear extends EssentialsCommand {
|
||||
} catch (final NumberFormatException ignored) {
|
||||
}
|
||||
}
|
||||
sender.sendTl("nearbyPlayers", getLocal(sender, otherUser, radius));
|
||||
sender.sendTl("nearbyPlayers", AdventureUtil.parsed(getLocal(sender, otherUser, radius)));
|
||||
}
|
||||
|
||||
private String getLocal(final CommandSource source, final User user, final long radius) {
|
||||
|
@ -53,7 +53,8 @@ public class Commandtempban extends EssentialsCommand {
|
||||
ess.getServer().getBanList(BanList.Type.NAME).addBan(user.getName(), banReason, new Date(banTimestamp), senderName);
|
||||
final String expiry = DateUtil.formatDateDiff(banTimestamp);
|
||||
|
||||
user.getBase().kickPlayer(user.playerTl("tempBanned", expiry, senderDisplayName, banReason));
|
||||
final String banDisplay = user.playerTl("tempBanned", expiry, senderDisplayName, banReason);
|
||||
user.getBase().kickPlayer(AdventureUtil.miniToLegacy(banDisplay));
|
||||
|
||||
ess.getLogger().log(Level.INFO, AdventureUtil.miniToLegacy(tlLiteral("playerTempBanned", senderDisplayName, user.getName(), expiry, banReason)));
|
||||
ess.broadcastTl((IUser) null, "essentials.ban.notify", "playerTempBanned", senderDisplayName, user.getName(), expiry, banReason);
|
||||
|
@ -63,7 +63,7 @@ public class Commandtempbanip extends EssentialsCommand {
|
||||
|
||||
ess.getServer().getBanList(BanList.Type.IP).addBan(ipAddress, banReason, new Date(banTimestamp), senderName);
|
||||
|
||||
final String banDisplay = tlLiteral("banFormat", banReason, senderDisplayName);
|
||||
final String banDisplay = AdventureUtil.miniToLegacy(tlLiteral("banFormat", banReason, senderDisplayName));
|
||||
for (final Player player : ess.getServer().getOnlinePlayers()) {
|
||||
if (player.getAddress().getAddress().getHostAddress().equalsIgnoreCase(ipAddress)) {
|
||||
player.kickPlayer(banDisplay);
|
||||
|
@ -90,11 +90,11 @@ public class Commandtogglejail extends EssentialsCommand {
|
||||
final Object[] objects;
|
||||
if (timeDiff > 0) {
|
||||
tlKey = "jailNotifyJailedFor";
|
||||
objects = new Object[]{player.getName(), DateUtil.formatDateDiff(finalDisplayTime)};
|
||||
objects = new Object[]{player.getName(), DateUtil.formatDateDiff(finalDisplayTime), sender.getSender().getName()};
|
||||
sender.sendTl("playerJailedFor", player.getName(), DateUtil.formatDateDiff(finalDisplayTime));
|
||||
} else {
|
||||
tlKey = "jailNotifyJailed";
|
||||
objects = new Object[]{player.getName(), sender.getSender().getName()};
|
||||
objects = new Object[]{player.getName(), sender.getSender().getName(), sender.getSender().getName()};
|
||||
sender.sendTl("playerJailed", player.getName());
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,7 @@ public class HelpInput implements IText {
|
||||
String pluginName = "";
|
||||
String pluginNameLow = "";
|
||||
if (!match.equalsIgnoreCase("")) {
|
||||
lines.add(user.playerTl("helpMatching", match));
|
||||
lines.add(AdventureUtil.miniToLegacy(user.playerTl("helpMatching", match)));
|
||||
}
|
||||
|
||||
final Multimap<Plugin, Command> pluginCommands = HashMultimap.create();
|
||||
@ -50,7 +50,7 @@ public class HelpInput implements IText {
|
||||
if (pluginNameLow.equals(match)) {
|
||||
lines.clear();
|
||||
newLines.clear();
|
||||
lines.add(user.playerTl("helpFrom", p.getDescription().getName()));
|
||||
lines.add(AdventureUtil.miniToLegacy(user.playerTl("helpFrom", p.getDescription().getName())));
|
||||
}
|
||||
final boolean isOnWhitelist = user.isAuthorized("essentials.help." + pluginNameLow);
|
||||
|
||||
@ -69,7 +69,7 @@ public class HelpInput implements IText {
|
||||
if (pluginNameLow.contains("essentials")) {
|
||||
final String node = "essentials." + commandName;
|
||||
if (!ess.getSettings().isCommandDisabled(commandName) && user.isAuthorized(node)) {
|
||||
pluginLines.add(user.playerTl("helpLine", commandName, commandDescription));
|
||||
pluginLines.add(AdventureUtil.miniToLegacy(user.playerTl("helpLine", commandName, commandDescription)));
|
||||
}
|
||||
} else {
|
||||
if (ess.getSettings().showNonEssCommandsInHelp()) {
|
||||
@ -82,7 +82,7 @@ public class HelpInput implements IText {
|
||||
}
|
||||
|
||||
if (isOnWhitelist || user.isAuthorized("essentials.help." + pluginNameLow + "." + commandName)) {
|
||||
pluginLines.add(user.playerTl("helpLine", commandName, commandDescription));
|
||||
pluginLines.add(AdventureUtil.miniToLegacy(user.playerTl("helpLine", commandName, commandDescription)));
|
||||
} else if (permissions.length != 0) {
|
||||
boolean enabled = false;
|
||||
|
||||
@ -94,11 +94,11 @@ public class HelpInput implements IText {
|
||||
}
|
||||
|
||||
if (enabled) {
|
||||
pluginLines.add(user.playerTl("helpLine", commandName, commandDescription));
|
||||
pluginLines.add(AdventureUtil.miniToLegacy(user.playerTl("helpLine", commandName, commandDescription)));
|
||||
}
|
||||
} else {
|
||||
if (!ess.getSettings().hidePermissionlessHelp()) {
|
||||
pluginLines.add(user.playerTl("helpLine", commandName, commandDescription));
|
||||
pluginLines.add(AdventureUtil.miniToLegacy(user.playerTl("helpLine", commandName, commandDescription)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -112,7 +112,7 @@ public class HelpInput implements IText {
|
||||
break;
|
||||
}
|
||||
if (match.equalsIgnoreCase("")) {
|
||||
lines.add(user.playerTl("helpPlugin", pluginName, pluginNameLow));
|
||||
lines.add(AdventureUtil.miniToLegacy(user.playerTl("helpPlugin", pluginName, pluginNameLow)));
|
||||
}
|
||||
}
|
||||
} catch (final NullPointerException ignored) {
|
||||
|
@ -1,5 +1,6 @@
|
||||
package net.essentialsx.discordlink.listeners;
|
||||
|
||||
import com.earth2me.essentials.utils.AdventureUtil;
|
||||
import com.earth2me.essentials.utils.FormatUtil;
|
||||
import net.essentialsx.api.v2.events.AsyncUserDataLoadEvent;
|
||||
import net.essentialsx.api.v2.events.UserMailEvent;
|
||||
@ -153,7 +154,7 @@ public class LinkBukkitListener implements Listener {
|
||||
|
||||
switch (ess.getSettings().getLinkPolicy()) {
|
||||
case KICK: {
|
||||
final Runnable kickTask = () -> event.getUser().getBase().kickPlayer(event.getUser().playerTl("discordLinkLoginKick", "/link " + finalCode, ess.getApi().getInviteUrl()));
|
||||
final Runnable kickTask = () -> event.getUser().getBase().kickPlayer(AdventureUtil.miniToLegacy(event.getUser().playerTl("discordLinkLoginKick", "/link " + finalCode, ess.getApi().getInviteUrl())));
|
||||
if (Bukkit.isPrimaryThread()) {
|
||||
kickTask.run();
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user