Refactor message-sending to use sendRichMessage API.
Replaced all instances of sendMiniMessage with sendRichMessage for improved readability and consistency across the codebase. This change ensures better handling of message formatting and placeholders.
This commit is contained in:
parent
ff05856494
commit
10449f4a80
|
|
@ -41,4 +41,4 @@ dependencies {
|
||||||
compileOnly("com.alttd:Galaxy-API:1.21-R0.1-SNAPSHOT") {
|
compileOnly("com.alttd:Galaxy-API:1.21-R0.1-SNAPSHOT") {
|
||||||
isChanging = true
|
isChanging = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,4 +14,4 @@ pluginManagement {
|
||||||
repositories {
|
repositories {
|
||||||
gradlePluginPortal()
|
gradlePluginPortal()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -41,10 +41,10 @@ public class PlayerUtilsCommand implements CommandExecutor, TabExecutor {
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(@NotNull CommandSender commandSender, @NotNull Command command, @NotNull String cmd, @NotNull String[] args) {
|
public boolean onCommand(@NotNull CommandSender commandSender, @NotNull Command command, @NotNull String cmd, @NotNull String[] args) {
|
||||||
if (args.length == 0) {
|
if (args.length == 0) {
|
||||||
commandSender.sendMiniMessage(Messages.HELP.HELP_MESSAGE_WRAPPER.replaceAll("<commands>", subCommands.stream()
|
commandSender.sendRichMessage(Messages.HELP.HELP_MESSAGE_WRAPPER.replaceAll("<commands>", subCommands.stream()
|
||||||
.filter(subCommand -> commandSender.hasPermission(subCommand.getPermission()))
|
.filter(subCommand -> commandSender.hasPermission(subCommand.getPermission()))
|
||||||
.map(SubCommand::getHelpMessage)
|
.map(SubCommand::getHelpMessage)
|
||||||
.collect(Collectors.joining("\n"))), null);
|
.collect(Collectors.joining("\n"))));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -53,13 +53,13 @@ public class PlayerUtilsCommand implements CommandExecutor, TabExecutor {
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!commandSender.hasPermission(subCommand.getPermission())) {
|
if (!commandSender.hasPermission(subCommand.getPermission())) {
|
||||||
commandSender.sendMiniMessage(Messages.GENERIC.NO_PERMISSION, Placeholder.parsed("permission", subCommand.getPermission()));
|
commandSender.sendRichMessage(Messages.GENERIC.NO_PERMISSION, Placeholder.parsed("permission", subCommand.getPermission()));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean executedCorrectly = subCommand.onCommand(commandSender, args);
|
boolean executedCorrectly = subCommand.onCommand(commandSender, args);
|
||||||
if (!executedCorrectly) {
|
if (!executedCorrectly) {
|
||||||
commandSender.sendMiniMessage(subCommand.getHelpMessage(), null);
|
commandSender.sendRichMessage(subCommand.getHelpMessage());
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -102,4 +102,4 @@ public class PlayerUtilsCommand implements CommandExecutor, TabExecutor {
|
||||||
}
|
}
|
||||||
subCommands.add(subCommand);
|
subCommands.add(subCommand);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,7 @@ public class Glow extends SubCommand {
|
||||||
|
|
||||||
Optional<DyeColor> any = Arrays.stream(DyeColor.values()).filter(chatColor -> chatColor.name().equalsIgnoreCase(args[1])).findAny();
|
Optional<DyeColor> any = Arrays.stream(DyeColor.values()).filter(chatColor -> chatColor.name().equalsIgnoreCase(args[1])).findAny();
|
||||||
if (any.isEmpty()) {
|
if (any.isEmpty()) {
|
||||||
commandSender.sendMiniMessage(getHelpMessage(), null);
|
commandSender.sendRichMessage(getHelpMessage());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -75,36 +75,36 @@ public class Glow extends SubCommand {
|
||||||
private Optional<Player> getTargetPlayer(CommandSender commandSender, String[] args) {
|
private Optional<Player> getTargetPlayer(CommandSender commandSender, String[] args) {
|
||||||
if (args.length == 2) {
|
if (args.length == 2) {
|
||||||
if (!(commandSender instanceof Player commandPlayer)) {
|
if (!(commandSender instanceof Player commandPlayer)) {
|
||||||
commandSender.sendMiniMessage(Messages.GENERIC.PLAYER_ONLY, null);
|
commandSender.sendRichMessage(Messages.GENERIC.PLAYER_ONLY);
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
return Optional.of(commandPlayer);
|
return Optional.of(commandPlayer);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!commandSender.hasPermission(getPermission() + ".other")) {
|
if (!commandSender.hasPermission(getPermission() + ".other")) {
|
||||||
commandSender.sendMiniMessage(Messages.GENERIC.NO_PERMISSION, Placeholder.parsed("permission", getPermission() + ".other"));
|
commandSender.sendRichMessage(Messages.GENERIC.NO_PERMISSION, Placeholder.parsed("permission", getPermission() + ".other"));
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
Optional<? extends Player> any = Bukkit.getOnlinePlayers().stream().filter(offlinePlayer -> offlinePlayer.getName().equalsIgnoreCase(args[2])).findAny();
|
Optional<? extends Player> any = Bukkit.getOnlinePlayers().stream().filter(offlinePlayer -> offlinePlayer.getName().equalsIgnoreCase(args[2])).findAny();
|
||||||
if (any.isPresent()) {
|
if (any.isPresent()) {
|
||||||
return Optional.of(any.get());
|
return Optional.of(any.get());
|
||||||
} else {
|
} else {
|
||||||
commandSender.sendMiniMessage(Messages.GENERIC.PLAYER_NOT_FOUND, Placeholder.parsed("player", args[2]));
|
commandSender.sendRichMessage(Messages.GENERIC.PLAYER_NOT_FOUND, Placeholder.parsed("player", args[2]));
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void turnOffGlow(CommandSender commandSender, Player player, boolean otherPlayer) {
|
private void turnOffGlow(CommandSender commandSender, Player player, boolean otherPlayer) {
|
||||||
player.sendMiniMessage(Messages.GLOW.GLOW_OFF, null);
|
player.sendRichMessage(Messages.GLOW.GLOW_OFF);
|
||||||
player.setGlowing(false);
|
player.setGlowing(false);
|
||||||
if (otherPlayer) {
|
if (otherPlayer) {
|
||||||
commandSender.sendMiniMessage(Messages.GLOW.GLOW_OFF_FOR_PLAYER, Placeholder.component("player", player.name()));
|
commandSender.sendRichMessage(Messages.GLOW.GLOW_OFF_FOR_PLAYER, Placeholder.component("player", player.name()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void turnOnGlow(CommandSender commandSender, Player player, Team team, DyeColor dyeColor, boolean otherPlayer) {
|
private void turnOnGlow(CommandSender commandSender, Player player, Team team, DyeColor dyeColor, boolean otherPlayer) {
|
||||||
if (team.getScoreboard() == null) {
|
if (team.getScoreboard() == null) {
|
||||||
commandSender.sendMiniMessage(Messages.GLOW.UNABLE_TO_GET_SCOREBOARD, null);
|
commandSender.sendRichMessage(Messages.GLOW.UNABLE_TO_GET_SCOREBOARD);
|
||||||
logger.warning("Unable to get scoreboard for team");
|
logger.warning("Unable to get scoreboard for team");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -114,9 +114,9 @@ public class Glow extends SubCommand {
|
||||||
player.setScoreboard(team.getScoreboard());
|
player.setScoreboard(team.getScoreboard());
|
||||||
|
|
||||||
player.setGlowing(true);
|
player.setGlowing(true);
|
||||||
player.sendMiniMessage(Messages.GLOW.GLOW_ON, Placeholder.parsed("color", dyeColor.name()));
|
player.sendRichMessage(Messages.GLOW.GLOW_ON, Placeholder.parsed("color", dyeColor.name()));
|
||||||
if (otherPlayer) {
|
if (otherPlayer) {
|
||||||
commandSender.sendMiniMessage(Messages.GLOW.GLOW_ON_FOR_PLAYER, TagResolver.resolver(
|
commandSender.sendRichMessage(Messages.GLOW.GLOW_ON_FOR_PLAYER, TagResolver.resolver(
|
||||||
Placeholder.parsed("color", dyeColor.name()),
|
Placeholder.parsed("color", dyeColor.name()),
|
||||||
Placeholder.component("player", player.name())
|
Placeholder.component("player", player.name())
|
||||||
));
|
));
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ public class Key extends SubCommand {
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender commandSender, String[] args) {
|
public boolean onCommand(CommandSender commandSender, String[] args) {
|
||||||
if (!(commandSender instanceof Player player)) {
|
if (!(commandSender instanceof Player player)) {
|
||||||
commandSender.sendMiniMessage(Messages.GENERIC.PLAYER_ONLY, null);
|
commandSender.sendRichMessage(Messages.GENERIC.PLAYER_ONLY);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -36,7 +36,7 @@ public class Key extends SubCommand {
|
||||||
|
|
||||||
String crate = args[1].toLowerCase();
|
String crate = args[1].toLowerCase();
|
||||||
if (!Config.KEY.CRATES.containsKey(crate)) {
|
if (!Config.KEY.CRATES.containsKey(crate)) {
|
||||||
commandSender.sendMiniMessage(Messages.KEY.CRATE_NOT_EXIST, Placeholder.parsed("crate", crate));
|
commandSender.sendRichMessage(Messages.KEY.CRATE_NOT_EXIST, Placeholder.parsed("crate", crate));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -45,7 +45,7 @@ public class Key extends SubCommand {
|
||||||
int totalKeys = Config.KEY.CRATES.getOrDefault(crate, 0);
|
int totalKeys = Config.KEY.CRATES.getOrDefault(crate, 0);
|
||||||
int keys = crateMap.getOrDefault(uuid, 0);
|
int keys = crateMap.getOrDefault(uuid, 0);
|
||||||
if (keys >= totalKeys) {
|
if (keys >= totalKeys) {
|
||||||
commandSender.sendMiniMessage(Messages.KEY.RETRIEVED_ALL_KEYS, TagResolver.resolver(
|
commandSender.sendRichMessage(Messages.KEY.RETRIEVED_ALL_KEYS, TagResolver.resolver(
|
||||||
Placeholder.parsed("crate", crate),
|
Placeholder.parsed("crate", crate),
|
||||||
Placeholder.parsed("keys", String.valueOf(keys))));
|
Placeholder.parsed("keys", String.valueOf(keys))));
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -55,11 +55,11 @@ public class Key extends SubCommand {
|
||||||
logger.info(String.format("Gave %s one key for %s", player.getName(), crate));
|
logger.info(String.format("Gave %s one key for %s", player.getName(), crate));
|
||||||
commandSender.getServer().dispatchCommand(Bukkit.getConsoleSender(), String.format("crate give v %s 1 %s", crate, player.getName()));
|
commandSender.getServer().dispatchCommand(Bukkit.getConsoleSender(), String.format("crate give v %s 1 %s", crate, player.getName()));
|
||||||
if (keys + 1 == totalKeys) {
|
if (keys + 1 == totalKeys) {
|
||||||
commandSender.sendMiniMessage(Messages.KEY.GAVE_FINAL_KEY, TagResolver.resolver(
|
commandSender.sendRichMessage(Messages.KEY.GAVE_FINAL_KEY, TagResolver.resolver(
|
||||||
Placeholder.parsed("crate", crate),
|
Placeholder.parsed("crate", crate),
|
||||||
Placeholder.parsed("keys", String.valueOf(keys + 1))));
|
Placeholder.parsed("keys", String.valueOf(keys + 1))));
|
||||||
} else {
|
} else {
|
||||||
commandSender.sendMiniMessage(Messages.KEY.GAVE_KEY, TagResolver.resolver(
|
commandSender.sendRichMessage(Messages.KEY.GAVE_KEY, TagResolver.resolver(
|
||||||
Placeholder.parsed("crate", crate),
|
Placeholder.parsed("crate", crate),
|
||||||
Placeholder.parsed("keys", String.valueOf(keys + 1)),
|
Placeholder.parsed("keys", String.valueOf(keys + 1)),
|
||||||
Placeholder.parsed("total_keys", String.valueOf(totalKeys))));
|
Placeholder.parsed("total_keys", String.valueOf(totalKeys))));
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ public class Reload extends SubCommand {
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender commandSender, String[] args) {
|
public boolean onCommand(CommandSender commandSender, String[] args) {
|
||||||
playerUtils.reloadConfigs();
|
playerUtils.reloadConfigs();
|
||||||
commandSender.sendMiniMessage(Messages.RELOAD.RELOADED, null);
|
commandSender.sendRichMessage(Messages.RELOAD.RELOADED);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,15 +19,15 @@ public class RotateBlock extends SubCommand {
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender commandSender, String[] args) {
|
public boolean onCommand(CommandSender commandSender, String[] args) {
|
||||||
if (!(commandSender instanceof Player player)) {
|
if (!(commandSender instanceof Player player)) {
|
||||||
commandSender.sendMiniMessage(Messages.GENERIC.PLAYER_ONLY, null);
|
commandSender.sendRichMessage(Messages.GENERIC.PLAYER_ONLY);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean enabled = rotateBlockEvent.toggleRotate(player.getUniqueId());
|
boolean enabled = rotateBlockEvent.toggleRotate(player.getUniqueId());
|
||||||
if (enabled)
|
if (enabled)
|
||||||
commandSender.sendMiniMessage(Messages.ROTATE_BLOCK.ENABLED, null);
|
commandSender.sendRichMessage(Messages.ROTATE_BLOCK.ENABLED);
|
||||||
else
|
else
|
||||||
commandSender.sendMiniMessage(Messages.ROTATE_BLOCK.DISABLED, null);
|
commandSender.sendRichMessage(Messages.ROTATE_BLOCK.DISABLED);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ public class XPCalc extends SubCommand {
|
||||||
startingLevel++;
|
startingLevel++;
|
||||||
}
|
}
|
||||||
|
|
||||||
commandSender.sendMiniMessage(Messages.XP_CALC.XP_NEEDED, Placeholder.parsed("xp_needed", String.valueOf(totalXpNeeded)));
|
commandSender.sendRichMessage(Messages.XP_CALC.XP_NEEDED, Placeholder.parsed("xp_needed", String.valueOf(totalXpNeeded)));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ public class XPCheque extends SubCommand {
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender commandSender, String[] args) {
|
public boolean onCommand(CommandSender commandSender, String[] args) {
|
||||||
if (!(commandSender instanceof Player player)) {
|
if (!(commandSender instanceof Player player)) {
|
||||||
commandSender.sendMiniMessage(Messages.GENERIC.PLAYER_ONLY, null);
|
commandSender.sendRichMessage(Messages.GENERIC.PLAYER_ONLY);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -48,7 +48,7 @@ public class XPCheque extends SubCommand {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (amount > 64 || amount < 1) {
|
if (amount > 64 || amount < 1) {
|
||||||
commandSender.sendMiniMessage(Messages.XP_CHEQUE.INVALID_AMOUNT, null);
|
commandSender.sendRichMessage(Messages.XP_CHEQUE.INVALID_AMOUNT);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -60,24 +60,24 @@ public class XPCheque extends SubCommand {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((xpValue <= 0)) {
|
if ((xpValue <= 0)) {
|
||||||
commandSender.sendMiniMessage(Messages.XP_CHEQUE.NEGATIVE, null);
|
commandSender.sendRichMessage(Messages.XP_CHEQUE.NEGATIVE);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int totalExperience = player.getTotalExperience();
|
int totalExperience = player.getTotalExperience();
|
||||||
if (totalExperience < (xpValue * amount)) {
|
if (totalExperience < (xpValue * amount)) {
|
||||||
commandSender.sendMiniMessage(Messages.XP_CHEQUE.NOT_ENOUGH_XP, Placeholder.parsed("xp", String.valueOf(totalExperience)));
|
commandSender.sendRichMessage(Messages.XP_CHEQUE.NOT_ENOUGH_XP, Placeholder.parsed("xp", String.valueOf(totalExperience)));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemStack heldItem = player.getInventory().getItemInMainHand();
|
ItemStack heldItem = player.getInventory().getItemInMainHand();
|
||||||
if (!heldItem.getType().equals(Material.GLASS_BOTTLE)) {
|
if (!heldItem.getType().equals(Material.GLASS_BOTTLE)) {
|
||||||
commandSender.sendMiniMessage(Messages.XP_CHEQUE.NOT_HOLDING_BOTTLE, null);
|
commandSender.sendRichMessage(Messages.XP_CHEQUE.NOT_HOLDING_BOTTLE);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (heldItem.getAmount() < amount) {
|
if (heldItem.getAmount() < amount) {
|
||||||
commandSender.sendMiniMessage(Messages.XP_CHEQUE.NOT_ENOUGH_BOTTLE, Placeholder.parsed("amount", String.valueOf(amount)));
|
commandSender.sendRichMessage(Messages.XP_CHEQUE.NOT_ENOUGH_BOTTLE, Placeholder.parsed("amount", String.valueOf(amount)));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -122,7 +122,7 @@ public class XPCheque extends SubCommand {
|
||||||
NamespacedKey customXp = NamespacedKey.fromString("custom_xp", playerUtils);
|
NamespacedKey customXp = NamespacedKey.fromString("custom_xp", playerUtils);
|
||||||
|
|
||||||
if (customXp == null) {
|
if (customXp == null) {
|
||||||
player.sendMiniMessage(Messages.XP_CHEQUE.FAILED_STORAGE, null);
|
player.sendRichMessage(Messages.XP_CHEQUE.FAILED_STORAGE);
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
persistentDataContainer.set(customXp, PersistentDataType.INTEGER, xpValue);
|
persistentDataContainer.set(customXp, PersistentDataType.INTEGER, xpValue);
|
||||||
|
|
|
||||||
|
|
@ -103,7 +103,7 @@ public class XpBottleEvent implements Listener {
|
||||||
NamespacedKey customXp = NamespacedKey.fromString("custom_xp", playerUtils);
|
NamespacedKey customXp = NamespacedKey.fromString("custom_xp", playerUtils);
|
||||||
|
|
||||||
if (customXp == null) {
|
if (customXp == null) {
|
||||||
player.sendMiniMessage(Messages.XP_CHEQUE.FAILED_STORAGE, null);
|
player.sendRichMessage(Messages.XP_CHEQUE.FAILED_STORAGE);
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
persistentDataContainer.set(customXp, PersistentDataType.INTEGER, xpValue);
|
persistentDataContainer.set(customXp, PersistentDataType.INTEGER, xpValue);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user