Switch from sendMiniMessage to sendRichMessage.

This commit is contained in:
Len
2025-06-15 09:14:08 +02:00
parent 646d0fae3f
commit df388ed93f
7 changed files with 33 additions and 38 deletions
@@ -8,6 +8,7 @@ import com.alttd.playershops.shop.PlayerShop;
import com.alttd.playershops.utils.ShopUtil;
import com.alttd.playershops.utils.Util;
import com.destroystokyo.paper.ParticleBuilder;
import net.kyori.adventure.chat.ChatType;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
@@ -48,11 +49,11 @@ public class CheckStockCommand implements Subcommand {
public boolean doStockCheck(final CommandSender sender, final String[] args) {
if (!(sender instanceof Player player)) {
sender.sendMessage(Util.parseMiniMessage("<red>Only players can use this command."));
sender.sendRichMessage("<red>Only players can use this command.");
return false;
}
if (args.length != 1 && args.length != 2) {
player.sendMessage(Util.parseMiniMessage("<red>Invalid command syntax, use /checkstock <radius> [minimum stock]"));
player.sendRichMessage("<red>Invalid command syntax, use /checkstock <radius> [minimum stock]");
return false;
}
@@ -60,12 +61,12 @@ public class CheckStockCommand implements Subcommand {
try {
radius = Integer.parseInt(args[0]);
} catch (NumberFormatException e) {
player.sendMessage(Util.parseMiniMessage("<red>radius has to be a valid number, use /checkstock <radius> [minimum stock]"));
player.sendRichMessage("<red>radius has to be a valid number, use /checkstock <radius> [minimum stock]");
return false;
}
if (radius > 100 || radius <= 0) {
player.sendMessage(Util.parseMiniMessage("<red>Please keep the radius between 1 and 100"));
player.sendRichMessage("<red>Please keep the radius between 1 and 100");
return false;
}
@@ -73,7 +74,7 @@ public class CheckStockCommand implements Subcommand {
try {
minimumStock = Integer.parseInt(args[1]);
} catch (NumberFormatException e) {
player.sendMessage(Util.parseMiniMessage("<red>minimum stock has to be a valid number, use /checkstock <radius> [minimum stock]"));
player.sendRichMessage("<red>minimum stock has to be a valid number, use /checkstock <radius> [minimum stock]");
return false;
}
}
@@ -175,11 +176,11 @@ public class CheckStockCommand implements Subcommand {
}
if (component == null)
if (minimumStock == -1)
player.sendMessage(Util.parseMiniMessage("<yellow>No shops that you have permission to view found in specified radius.<yellow>"));
player.sendRichMessage("<yellow>No shops that you have permission to view found in specified radius.<yellow>");
else
player.sendMessage(Util.parseMiniMessage(
player.sendRichMessage(
"<yellow>No shops with less than <minimum_stock> stock found.</yellow>",
TagResolver.resolver(Placeholder.parsed("minimum_stock", minimumStock + ""))));
TagResolver.resolver(Placeholder.parsed("minimum_stock", minimumStock + "")));
else
player.sendMessage(component);
}
@@ -33,31 +33,31 @@ public class TransferShopsCommand implements Subcommand {
@Override
public boolean execute(CommandSender sender, String subCommand, String[] args) {
if (!(sender instanceof Player player)) {
sender.sendMiniMessage("<red>Only players can use this command.", null);
sender.sendRichMessage("<red>Only players can use this command.");
return false;
}
if (args.length != 1 && args.length != 2) {
player.sendMiniMessage("<red>Invalid command syntax, use /transfershops <uuid> <newplayer>", null);
player.sendRichMessage("<red>Invalid command syntax, use /transfershops <uuid> <newplayer>");
return false;
}
OfflinePlayer oldOfflinePlayer = Bukkit.getOfflinePlayer(args[0]);
if (!oldOfflinePlayer.hasPlayedBefore()) {
player.sendMiniMessage("<red>" + args[0] + " has not joined this server before.", null);
player.sendRichMessage("<red>" + args[0] + " has not joined this server before.");
return false;
}
Player newShopOwner = Bukkit.getPlayer(args[1]);
if (newShopOwner == null) {
player.sendMiniMessage("<red>" + args[1] + " is not online and has to be online for this process.", null);
player.sendRichMessage("<red>" + args[1] + " is not online and has to be online for this process.");
return false;
}
UUID oldUUID = oldOfflinePlayer.getUniqueId();
List<PlayerShop> playerShops = PlayerShops.getInstance().getShopHandler().getShops(oldUUID);
sender.sendMiniMessage("<red>Starting the transfer process now, this might lag the server.", null);
sender.sendRichMessage("<red>Starting the transfer process now, this might lag the server.");
for (PlayerShop playerShop : playerShops) {
playerShop.setOwner(newShopOwner);
}
newShopOwner.sendMiniMessage(playerShops.size() + " have been transferred to you.", null);
sender.sendMiniMessage(playerShops.size() + " have been transferred to " + args[1] + ".", null);
newShopOwner.sendRichMessage(playerShops.size() + " have been transferred to you.");
sender.sendRichMessage(playerShops.size() + " have been transferred to " + args[1] + ".");
return true;
}