mirror of
https://github.com/libraryaddict/LibsDisguises.git
synced 2024-12-13 15:16:50 +01:00
Improve message sending
This commit is contained in:
parent
3ced8ae9e4
commit
e74df537bb
@ -45,7 +45,7 @@ public class DisguiseCommand extends DisguiseBaseCommand implements TabCompleter
|
||||
}
|
||||
catch (DisguiseParseException ex) {
|
||||
if (ex.getMessage() != null) {
|
||||
sender.sendMessage(ex.getMessage());
|
||||
DisguiseUtilities.sendMessage(sender, ex.getMessage());
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -51,7 +51,7 @@ public class DisguiseEntityCommand extends DisguiseBaseCommand implements TabCom
|
||||
}
|
||||
catch (DisguiseParseException ex) {
|
||||
if (ex.getMessage() != null) {
|
||||
sender.sendMessage(ex.getMessage());
|
||||
DisguiseUtilities.sendMessage(sender, ex.getMessage());
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -61,7 +61,7 @@ public class DisguisePlayerCommand extends DisguiseBaseCommand implements TabCom
|
||||
}
|
||||
|
||||
if (entityTarget == null) {
|
||||
sender.sendMessage(LibsMsg.CANNOT_FIND_PLAYER.get(args[0]));
|
||||
DisguiseUtilities.sendMessage(sender, LibsMsg.CANNOT_FIND_PLAYER, args[0]);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -81,7 +81,7 @@ public class DisguisePlayerCommand extends DisguiseBaseCommand implements TabCom
|
||||
}
|
||||
catch (DisguiseParseException ex) {
|
||||
if (ex.getMessage() != null) {
|
||||
sender.sendMessage(ex.getMessage());
|
||||
DisguiseUtilities.sendMessage(sender, ex.getMessage());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -119,12 +119,13 @@ public class DisguisePlayerCommand extends DisguiseBaseCommand implements TabCom
|
||||
disguise.startDisguise();
|
||||
|
||||
if (disguise.isDisguiseInUse()) {
|
||||
sender.sendMessage(LibsMsg.DISG_PLAYER_AS_DISG.get(entityTarget instanceof Player ? entityTarget.getName() :
|
||||
DisguiseType.getType(entityTarget).toReadable(), disguise.getDisguiseName()));
|
||||
DisguiseUtilities.sendMessage(sender, LibsMsg.DISG_PLAYER_AS_DISG,
|
||||
entityTarget instanceof Player ? entityTarget.getName() :
|
||||
DisguiseType.getType(entityTarget).toReadable(), disguise.getDisguiseName());
|
||||
} else {
|
||||
sender.sendMessage(LibsMsg.DISG_PLAYER_AS_DISG_FAIL
|
||||
.get(entityTarget instanceof Player ? entityTarget.getName() :
|
||||
DisguiseType.getType(entityTarget).toReadable(), disguise.getDisguiseName()));
|
||||
DisguiseUtilities.sendMessage(sender, LibsMsg.DISG_PLAYER_AS_DISG_FAIL,
|
||||
entityTarget instanceof Player ? entityTarget.getName() :
|
||||
DisguiseType.getType(entityTarget).toReadable(), disguise.getDisguiseName());
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -78,8 +78,8 @@ public class DisguiseRadiusCommand extends DisguiseBaseCommand implements TabCom
|
||||
|
||||
Collections.sort(classes);
|
||||
|
||||
sender.sendMessage(LibsMsg.DRADIUS_ENTITIES
|
||||
.get(ChatColor.GREEN + StringUtils.join(classes, ChatColor.DARK_GREEN + ", " + ChatColor.GREEN)));
|
||||
DisguiseUtilities.sendMessage(sender, LibsMsg.DRADIUS_ENTITIES,
|
||||
ChatColor.GREEN + StringUtils.join(classes, ChatColor.DARK_GREEN + ", " + ChatColor.GREEN));
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -104,15 +104,15 @@ public class DisguiseRadiusCommand extends DisguiseBaseCommand implements TabCom
|
||||
}
|
||||
|
||||
if (type == null) {
|
||||
sender.sendMessage(LibsMsg.DMODRADIUS_UNRECOGNIZED.get(args[0]));
|
||||
DisguiseUtilities.sendMessage(sender, LibsMsg.DMODRADIUS_UNRECOGNIZED, args[0]);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (args.length == starting + 1) {
|
||||
sender.sendMessage(
|
||||
(starting == 0 ? LibsMsg.DRADIUS_NEEDOPTIONS : LibsMsg.DRADIUS_NEEDOPTIONS_ENTITY).get());
|
||||
DisguiseUtilities.sendMessage(sender,
|
||||
starting == 0 ? LibsMsg.DRADIUS_NEEDOPTIONS : LibsMsg.DRADIUS_NEEDOPTIONS_ENTITY);
|
||||
return true;
|
||||
} else if (args.length < 2) {
|
||||
DisguiseUtilities.sendMessage(sender, LibsMsg.DRADIUS_NEEDOPTIONS);
|
||||
@ -120,7 +120,7 @@ public class DisguiseRadiusCommand extends DisguiseBaseCommand implements TabCom
|
||||
}
|
||||
|
||||
if (!isInteger(args[starting])) {
|
||||
sender.sendMessage(LibsMsg.NOT_NUMBER.get(args[starting]));
|
||||
DisguiseUtilities.sendMessage(sender, LibsMsg.NOT_NUMBER, args[starting]);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -213,7 +213,7 @@ public class DisguiseRadiusCommand extends DisguiseBaseCommand implements TabCom
|
||||
}
|
||||
catch (DisguiseParseException ex) {
|
||||
if (ex.getMessage() != null) {
|
||||
sender.sendMessage(ex.getMessage());
|
||||
DisguiseUtilities.sendMessage(sender, ex.getMessage());
|
||||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
|
@ -41,7 +41,7 @@ public class DisguiseEntityInteraction implements LibsEntityInteract {
|
||||
}
|
||||
catch (DisguiseParseException e) {
|
||||
if (e.getMessage() != null) {
|
||||
p.sendMessage(e.getMessage());
|
||||
DisguiseUtilities.sendMessage(p, e.getMessage());
|
||||
}
|
||||
|
||||
return;
|
||||
|
@ -60,7 +60,7 @@ public class DisguiseModifyInteraction implements LibsEntityInteract {
|
||||
}
|
||||
catch (DisguiseParseException ex) {
|
||||
if (ex.getMessage() != null) {
|
||||
p.sendMessage(ex.getMessage());
|
||||
DisguiseUtilities.sendMessage(p, ex.getMessage());
|
||||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
|
@ -3,6 +3,7 @@ package me.libraryaddict.disguise.commands.libsdisguises;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import me.libraryaddict.disguise.commands.LibsDisguisesCommand;
|
||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
@ -39,7 +40,7 @@ public class LDHelp implements LDCommand {
|
||||
continue;
|
||||
}
|
||||
|
||||
sender.sendMessage(cmd.getHelp().get());
|
||||
DisguiseUtilities.sendMessage(sender, cmd.getHelp());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -88,7 +88,7 @@ public class LDJson implements LDCommand {
|
||||
|
||||
private void sendMessage(CommandSender sender, LibsMsg prefix, LibsMsg oldVer, String string) {
|
||||
if (!NmsVersion.v1_13.isSupported()) {
|
||||
sender.sendMessage(oldVer.get(string));
|
||||
DisguiseUtilities.sendMessage(sender, oldVer, string);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -38,7 +38,7 @@ public class LDMods implements LDCommand {
|
||||
player = Bukkit.getPlayer(args[1]);
|
||||
|
||||
if (player == null) {
|
||||
sender.sendMessage(LibsMsg.CANNOT_FIND_PLAYER.get(args[1]));
|
||||
DisguiseUtilities.sendMessage(sender, LibsMsg.CANNOT_FIND_PLAYER, args[1]);
|
||||
return;
|
||||
}
|
||||
} else if (sender instanceof Player) {
|
||||
|
@ -41,7 +41,7 @@ public class LDPermTest implements LDCommand {
|
||||
player = Bukkit.getPlayer(args[1]);
|
||||
|
||||
if (player == null) {
|
||||
sender.sendMessage(LibsMsg.CANNOT_FIND_PLAYER.get(args[1]));
|
||||
DisguiseUtilities.sendMessage(sender, LibsMsg.CANNOT_FIND_PLAYER, args[1]);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
@ -80,9 +80,9 @@ public class LDPermTest implements LDCommand {
|
||||
}
|
||||
|
||||
if (!sender.hasPermission("libsdisguises.seecmd.disguise")) {
|
||||
sender.sendMessage(LibsMsg.LIBS_PERM_COMMAND_FAIL.get("libsdisguises.seecmd.disguise"));
|
||||
DisguiseUtilities.sendMessage(sender, LibsMsg.LIBS_PERM_COMMAND_FAIL, "libsdisguises.seecmd.disguise");
|
||||
} else {
|
||||
sender.sendMessage(LibsMsg.LIBS_PERM_COMMAND_SUCCESS.get("libsdisguises.seecmd.disguise"));
|
||||
DisguiseUtilities.sendMessage(sender, LibsMsg.LIBS_PERM_COMMAND_SUCCESS, "libsdisguises.seecmd.disguise");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -129,7 +129,7 @@ public class LDScoreboard implements LDCommand {
|
||||
player = Bukkit.getPlayer(args[1]);
|
||||
|
||||
if (player == null) {
|
||||
sender.sendMessage(LibsMsg.CANNOT_FIND_PLAYER.get(args[1]));
|
||||
DisguiseUtilities.sendMessage(sender, LibsMsg.CANNOT_FIND_PLAYER, args[1]);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -95,10 +95,10 @@ public class LDUpdate implements LDCommand {
|
||||
|
||||
if (!forceUpdate) {
|
||||
if (updateResult != null) {
|
||||
sender.sendMessage(updateResult.get());
|
||||
DisguiseUtilities.sendMessage(sender, updateResult);
|
||||
} else {
|
||||
for (String msg : checker.getUpdateMessage()) {
|
||||
sender.sendMessage(msg);
|
||||
DisguiseUtilities.sendMessage(sender, msg);
|
||||
}
|
||||
}
|
||||
|
||||
@ -113,7 +113,7 @@ public class LDUpdate implements LDCommand {
|
||||
}
|
||||
|
||||
for (String msg : checker.getUpdateMessage()) {
|
||||
sender.sendMessage(msg);
|
||||
DisguiseUtilities.sendMessage(sender, msg);
|
||||
}
|
||||
|
||||
if (sender instanceof Player) {
|
||||
|
@ -63,7 +63,7 @@ public class DisguiseModifyCommand extends DisguiseBaseCommand implements TabCom
|
||||
}
|
||||
catch (DisguiseParseException ex) {
|
||||
if (ex.getMessage() != null) {
|
||||
sender.sendMessage(ex.getMessage());
|
||||
DisguiseUtilities.sendMessage(sender, ex.getMessage());
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -50,7 +50,7 @@ public class DisguiseModifyPlayerCommand extends DisguiseBaseCommand implements
|
||||
}
|
||||
|
||||
if (entityTarget == null) {
|
||||
sender.sendMessage(LibsMsg.CANNOT_FIND_PLAYER.get(args[0]));
|
||||
DisguiseUtilities.sendMessage(sender, LibsMsg.CANNOT_FIND_PLAYER, args[0]);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -92,7 +92,7 @@ public class DisguiseModifyPlayerCommand extends DisguiseBaseCommand implements
|
||||
}
|
||||
catch (DisguiseParseException ex) {
|
||||
if (ex.getMessage() != null) {
|
||||
sender.sendMessage(ex.getMessage());
|
||||
DisguiseUtilities.sendMessage(sender, ex.getMessage());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -77,8 +77,8 @@ public class DisguiseModifyRadiusCommand extends DisguiseBaseCommand implements
|
||||
|
||||
Collections.sort(classes);
|
||||
|
||||
sender.sendMessage(LibsMsg.DMODRADIUS_USABLE
|
||||
.get(ChatColor.GREEN + StringUtils.join(classes, ChatColor.DARK_GREEN + ", " + ChatColor.GREEN)));
|
||||
DisguiseUtilities.sendMessage(sender, LibsMsg.DMODRADIUS_USABLE,
|
||||
ChatColor.GREEN + StringUtils.join(classes, ChatColor.DARK_GREEN + ", " + ChatColor.GREEN));
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -99,14 +99,14 @@ public class DisguiseModifyRadiusCommand extends DisguiseBaseCommand implements
|
||||
}
|
||||
|
||||
if (baseType == null) {
|
||||
sender.sendMessage(LibsMsg.DMODRADIUS_UNRECOGNIZED.get(args[0]));
|
||||
DisguiseUtilities.sendMessage(sender, LibsMsg.DMODRADIUS_UNRECOGNIZED, args[0]);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (args.length == starting + 1) {
|
||||
sender.sendMessage(
|
||||
(starting == 0 ? LibsMsg.DMODRADIUS_NEEDOPTIONS : LibsMsg.DMODRADIUS_NEEDOPTIONS_ENTITY).get());
|
||||
DisguiseUtilities.sendMessage(sender,
|
||||
starting == 0 ? LibsMsg.DMODRADIUS_NEEDOPTIONS : LibsMsg.DMODRADIUS_NEEDOPTIONS_ENTITY);
|
||||
return true;
|
||||
} else if (args.length < 2) {
|
||||
DisguiseUtilities.sendMessage(sender, LibsMsg.DMODRADIUS_NEEDOPTIONS);
|
||||
@ -114,7 +114,7 @@ public class DisguiseModifyRadiusCommand extends DisguiseBaseCommand implements
|
||||
}
|
||||
|
||||
if (!isInteger(args[starting])) {
|
||||
sender.sendMessage(LibsMsg.NOT_NUMBER.get(args[starting]));
|
||||
DisguiseUtilities.sendMessage(sender, LibsMsg.NOT_NUMBER, args[starting]);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -176,7 +176,7 @@ public class DisguiseModifyRadiusCommand extends DisguiseBaseCommand implements
|
||||
}
|
||||
catch (DisguiseParseException ex) {
|
||||
if (ex.getMessage() != null) {
|
||||
sender.sendMessage(ex.getMessage());
|
||||
DisguiseUtilities.sendMessage(sender, ex.getMessage());
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -85,17 +85,19 @@ public class UndisguisePlayerCommand implements CommandExecutor, TabCompleter {
|
||||
}
|
||||
|
||||
if (entityTarget == null) {
|
||||
sender.sendMessage(LibsMsg.CANNOT_FIND_PLAYER.get(args[0]));
|
||||
DisguiseUtilities.sendMessage(sender, LibsMsg.CANNOT_FIND_PLAYER, args[0]);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (DisguiseAPI.isDisguised(entityTarget)) {
|
||||
DisguiseAPI.undisguiseToAll(entityTarget);
|
||||
sender.sendMessage(LibsMsg.UNDISG_PLAYER.get(entityTarget instanceof Player ? entityTarget.getName() :
|
||||
DisguiseType.getType(entityTarget).toReadable()));
|
||||
DisguiseUtilities.sendMessage(sender, LibsMsg.UNDISG_PLAYER,
|
||||
entityTarget instanceof Player ? entityTarget.getName() :
|
||||
DisguiseType.getType(entityTarget).toReadable());
|
||||
} else {
|
||||
sender.sendMessage(LibsMsg.UNDISG_PLAYER_FAIL.get(entityTarget instanceof Player ? entityTarget.getName() :
|
||||
DisguiseType.getType(entityTarget).toReadable()));
|
||||
DisguiseUtilities.sendMessage(sender, LibsMsg.UNDISG_PLAYER_FAIL,
|
||||
entityTarget instanceof Player ? entityTarget.getName() :
|
||||
DisguiseType.getType(entityTarget).toReadable());
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -45,7 +45,7 @@ public class UndisguiseRadiusCommand implements CommandExecutor {
|
||||
int radius = maxRadius;
|
||||
if (args.length > 0) {
|
||||
if (!isNumeric(args[0])) {
|
||||
sender.sendMessage(LibsMsg.NOT_NUMBER.get(args[0]));
|
||||
DisguiseUtilities.sendMessage(sender, LibsMsg.NOT_NUMBER, args[0]);
|
||||
return true;
|
||||
}
|
||||
radius = Integer.parseInt(args[0]);
|
||||
|
@ -58,7 +58,7 @@ public class CopyDisguiseCommand implements CommandExecutor {
|
||||
}
|
||||
|
||||
if (target == null) {
|
||||
sender.sendMessage(LibsMsg.CANNOT_FIND_PLAYER.get(args[0]));
|
||||
DisguiseUtilities.sendMessage(sender, LibsMsg.CANNOT_FIND_PLAYER, args[0]);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -91,7 +91,7 @@ public class CopyDisguiseCommand implements CommandExecutor {
|
||||
|
||||
public void sendMessage(CommandSender sender, LibsMsg msg, LibsMsg oldVer, String string, boolean forceAbbrev) {
|
||||
if (!NmsVersion.v1_13.isSupported()) {
|
||||
sender.sendMessage(oldVer.get(string));
|
||||
DisguiseUtilities.sendMessage(sender, oldVer, string);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -67,7 +67,7 @@ public class DisguiseHelpCommand extends DisguiseBaseCommand implements TabCompl
|
||||
DisguisePerm type = DisguiseParser.getDisguisePerm(args[0]);
|
||||
|
||||
if (type == null) {
|
||||
sender.sendMessage(LibsMsg.DHELP_CANTFIND.get(args[0]));
|
||||
DisguiseUtilities.sendMessage(sender, LibsMsg.DHELP_CANTFIND, args[0]);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -114,8 +114,8 @@ public class DisguiseHelpCommand extends DisguiseBaseCommand implements TabCompl
|
||||
methods.add(LibsMsg.DHELP_NO_OPTIONS.get());
|
||||
}
|
||||
|
||||
sender.sendMessage(LibsMsg.DHELP_OPTIONS.get(ChatColor.DARK_RED + type.toReadable(),
|
||||
StringUtils.join(methods, ChatColor.DARK_RED + ", ")));
|
||||
DisguiseUtilities.sendMessage(sender, LibsMsg.DHELP_OPTIONS, ChatColor.DARK_RED + type.toReadable(),
|
||||
StringUtils.join(methods, ChatColor.DARK_RED + ", "));
|
||||
|
||||
if (ignored > 0) {
|
||||
DisguiseUtilities.sendMessage(sender, LibsMsg.NO_PERMS_USE_OPTIONS, ignored);
|
||||
|
@ -67,14 +67,14 @@ public class GrabHeadCommand implements CommandExecutor {
|
||||
|
||||
@Override
|
||||
public void onError(LibsMsg msg, Object... args) {
|
||||
sender.sendMessage(msg.get(args));
|
||||
DisguiseUtilities.sendMessage(sender, msg, args);
|
||||
|
||||
runnable.cancel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInfo(LibsMsg msg, Object... args) {
|
||||
sender.sendMessage(msg.get(args));
|
||||
DisguiseUtilities.sendMessage(sender, msg, args);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -75,14 +75,14 @@ public class GrabSkinCommand implements CommandExecutor {
|
||||
|
||||
@Override
|
||||
public void onError(LibsMsg msg, Object... args) {
|
||||
sender.sendMessage(msg.get(args));
|
||||
DisguiseUtilities.sendMessage(sender, msg, args);
|
||||
|
||||
runnable.cancel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInfo(LibsMsg msg, Object... args) {
|
||||
sender.sendMessage(msg.get(args));
|
||||
DisguiseUtilities.sendMessage(sender, msg, args);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -71,7 +71,7 @@ public class SaveDisguiseCommand implements CommandExecutor {
|
||||
}
|
||||
catch (DisguiseParseException e) {
|
||||
if (e.getMessage() != null) {
|
||||
sender.sendMessage(e.getMessage());
|
||||
DisguiseUtilities.sendMessage(sender, e.getMessage());
|
||||
} else {
|
||||
DisguiseUtilities.sendMessage(sender, LibsMsg.PARSE_CANT_LOAD);
|
||||
}
|
||||
@ -109,7 +109,7 @@ public class SaveDisguiseCommand implements CommandExecutor {
|
||||
String usable = SkinUtils.getUsableStatus();
|
||||
|
||||
if (usable != null) {
|
||||
sender.sendMessage(usable);
|
||||
DisguiseUtilities.sendMessage(sender, usable);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -127,12 +127,12 @@ public class SaveDisguiseCommand implements CommandExecutor {
|
||||
public void onError(LibsMsg msg, Object... args) {
|
||||
runnable.cancel();
|
||||
|
||||
sender.sendMessage(msg.get(args));
|
||||
DisguiseUtilities.sendMessage(sender, msg, args);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInfo(LibsMsg msg, Object... args) {
|
||||
sender.sendMessage(msg.get(args));
|
||||
DisguiseUtilities.sendMessage(sender, msg, args);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -169,7 +169,7 @@ public class SaveDisguiseCommand implements CommandExecutor {
|
||||
}
|
||||
catch (DisguiseParseException e) {
|
||||
if (e.getMessage() != null) {
|
||||
sender.sendMessage(e.getMessage());
|
||||
DisguiseUtilities.sendMessage(sender, e.getMessage());
|
||||
} else {
|
||||
DisguiseUtilities.sendMessage(sender, LibsMsg.PARSE_CANT_LOAD);
|
||||
}
|
||||
|
@ -430,10 +430,8 @@ public abstract class Disguise {
|
||||
disguiseExpires < System.currentTimeMillis())) { // If disguise expired
|
||||
removeDisguise();
|
||||
|
||||
String expired = LibsMsg.EXPIRED_DISGUISE.get();
|
||||
|
||||
if (getEntity() instanceof Player && expired.length() > 0) {
|
||||
getEntity().sendMessage(expired);
|
||||
if (getEntity() instanceof Player) {
|
||||
DisguiseUtilities.sendMessage(getEntity(), LibsMsg.EXPIRED_DISGUISE);
|
||||
}
|
||||
|
||||
return;
|
||||
|
@ -2148,11 +2148,33 @@ public class DisguiseUtilities {
|
||||
return Strings.isEmpty(player.getPlayerListName()) ? player.getName() : player.getPlayerListName();
|
||||
}
|
||||
|
||||
public static void sendMessage(CommandSender sender, String message) {
|
||||
if (!NmsVersion.v1_16.isSupported()) {
|
||||
if (!message.isEmpty()) {
|
||||
sender.sendMessage(message);
|
||||
}
|
||||
} else {
|
||||
BaseComponent[] components = getColoredChat(message);
|
||||
|
||||
if (components.length > 0) {
|
||||
sender.spigot().sendMessage(components);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void sendMessage(CommandSender sender, LibsMsg msg, Object... args) {
|
||||
if (!NmsVersion.v1_16.isSupported()) {
|
||||
sender.sendMessage(msg.get(args));
|
||||
String message = msg.get(args);
|
||||
|
||||
if (!message.isEmpty()) {
|
||||
sender.sendMessage(message);
|
||||
}
|
||||
} else {
|
||||
sender.spigot().sendMessage(msg.getChat(args));
|
||||
BaseComponent[] components = msg.getChat(args);
|
||||
|
||||
if (components.length > 0) {
|
||||
sender.spigot().sendMessage(components);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -2219,6 +2241,10 @@ public class DisguiseUtilities {
|
||||
* Modification of TextComponent.fromLegacyText
|
||||
*/
|
||||
public static BaseComponent[] getColoredChat(String message) {
|
||||
if (message.isEmpty()) {
|
||||
return new BaseComponent[0];
|
||||
}
|
||||
|
||||
ArrayList<BaseComponent> components = new ArrayList();
|
||||
StringBuilder builder = new StringBuilder();
|
||||
TextComponent component = new TextComponent();
|
||||
|
@ -125,11 +125,7 @@ public class DisguiseListener implements Listener {
|
||||
if (disguises.length > 0) {
|
||||
DisguiseAPI.undisguiseToAll(player);
|
||||
|
||||
String blown = LibsMsg.BLOWN_DISGUISE.get();
|
||||
|
||||
if (blown.length() > 0) {
|
||||
player.sendMessage(blown);
|
||||
}
|
||||
DisguiseUtilities.sendMessage(player, LibsMsg.BLOWN_DISGUISE);
|
||||
}
|
||||
}
|
||||
|
||||
@ -202,22 +198,14 @@ public class DisguiseListener implements Listener {
|
||||
if (disguises.length > 0) {
|
||||
event.setCancelled(true);
|
||||
|
||||
String cantAttack = LibsMsg.CANT_ATTACK_DISGUISED.get();
|
||||
|
||||
if (cantAttack.length() > 0) {
|
||||
attacker.sendMessage(cantAttack);
|
||||
}
|
||||
DisguiseUtilities.sendMessage(attacker, LibsMsg.CANT_ATTACK_DISGUISED);
|
||||
} else if (DisguiseConfig.getPvPTimer() > 0 && attacker.hasMetadata("LastDisguise")) {
|
||||
long lastDisguised = attacker.getMetadata("LastDisguise").get(0).asLong();
|
||||
|
||||
if (lastDisguised + DisguiseConfig.getPvPTimer() * 1000 > System.currentTimeMillis()) {
|
||||
event.setCancelled(true);
|
||||
|
||||
String cantAttack = LibsMsg.CANT_ATTACK_DISGUISED_RECENTLY.get();
|
||||
|
||||
if (cantAttack.length() > 0) {
|
||||
attacker.sendMessage(cantAttack);
|
||||
}
|
||||
DisguiseUtilities.sendMessage(attacker, LibsMsg.CANT_ATTACK_DISGUISED_RECENTLY);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -331,9 +319,9 @@ public class DisguiseListener implements Listener {
|
||||
if (DisguiseUtilities.isOlderThan(requiredProtocolLib, version)) {
|
||||
p.sendMessage(ChatColor.RED + "Update your ProtocolLib! You are running " + version +
|
||||
" but the minimum version you should be on is " + requiredProtocolLib + "!");
|
||||
p.sendMessage(ChatColor.RED + "https://ci.dmulloy2.net/job/ProtocolLib/lastSuccessfulBuild/artifact/target" +
|
||||
"/ProtocolLib" +
|
||||
".jar");
|
||||
p.sendMessage(
|
||||
ChatColor.RED + "https://ci.dmulloy2.net/job/ProtocolLib/lastSuccessfulBuild/artifact/target" +
|
||||
"/ProtocolLib" + ".jar");
|
||||
p.sendMessage(ChatColor.RED + "Use /ld updateprotocollib - To update to the latest development build");
|
||||
}
|
||||
}
|
||||
@ -563,11 +551,7 @@ public class DisguiseListener implements Listener {
|
||||
disguise.removeDisguise();
|
||||
}
|
||||
|
||||
String msg = LibsMsg.SWITCH_WORLD_DISGUISE_REMOVED.get();
|
||||
|
||||
if (msg.length() > 0) {
|
||||
event.getPlayer().sendMessage(msg);
|
||||
}
|
||||
DisguiseUtilities.sendMessage(event.getPlayer(), LibsMsg.SWITCH_WORLD_DISGUISE_REMOVED);
|
||||
}
|
||||
}
|
||||
|
||||
@ -662,11 +646,7 @@ public class DisguiseListener implements Listener {
|
||||
disguise.removeDisguise();
|
||||
}
|
||||
|
||||
String msg = LibsMsg.SWITCH_WORLD_DISGUISE_REMOVED.get();
|
||||
|
||||
if (msg.length() > 0) {
|
||||
event.getPlayer().sendMessage(msg);
|
||||
}
|
||||
DisguiseUtilities.sendMessage(event.getPlayer(), LibsMsg.SWITCH_WORLD_DISGUISE_REMOVED);
|
||||
}
|
||||
} else {
|
||||
// Stupid hack to fix worldswitch invisibility bug & paper packet bug
|
||||
|
@ -372,16 +372,20 @@ public enum LibsMsg {
|
||||
}
|
||||
|
||||
public String get(Object... strings) {
|
||||
if (StringUtils.countMatches(getRaw(), "%s") != strings.length) {
|
||||
int matches = StringUtils.countMatches(getRaw(), "%s");
|
||||
|
||||
if (matches != strings.length) {
|
||||
DisguiseUtilities.getLogger().severe("Mismatch in messages, incorrect parameters supplied for " + name() +
|
||||
". Please inform plugin author.");
|
||||
". Please inform plugin author if not using translations.");
|
||||
}
|
||||
|
||||
if (strings.length == 0) {
|
||||
return TranslateType.MESSAGES.get(getRaw());
|
||||
String trans = TranslateType.MESSAGES.get(getRaw());
|
||||
|
||||
if (trans.isEmpty() || strings.length == 0) {
|
||||
return trans;
|
||||
}
|
||||
|
||||
return String.format(TranslateType.MESSAGES.get(getRaw()), strings);
|
||||
return String.format(trans, strings);
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
|
Loading…
Reference in New Issue
Block a user