fix handling empty messages

This commit is contained in:
hyperdefined
2025-01-18 13:06:38 -05:00
parent c68a04851b
commit 98ee84ad13
4 changed files with 13 additions and 3 deletions

View File

@@ -23,7 +23,7 @@
<groupId>lol.hyper</groupId>
<artifactId>toolstats</artifactId>
<version>1.8.5</version>
<version>1.8.6</version>
<packaging>jar</packaging>
<name>ToolStats</name>

View File

@@ -65,7 +65,9 @@ public class CraftItem implements Listener {
// if the player shift clicks, send them this warning
if (event.isShiftClick()) {
Component component = toolStats.configTools.formatLore("shift-click-warning.crafting", null, null);
event.getWhoClicked().sendMessage(component);
if (component != null) {
event.getWhoClicked().sendMessage(component);
}
}
// test the item before setting it

View File

@@ -70,7 +70,9 @@ public class VillagerTrade implements Listener {
// if the player shift clicks, show the warning
if (event.isShiftClick()) {
Component component = toolStats.configTools.formatLore("shift-click-warning.trading", null, null);
event.getWhoClicked().sendMessage(component);
if (component != null) {
event.getWhoClicked().sendMessage(component);
}
}
ItemStack newItem = addLore(item, player);
if (newItem != null) {

View File

@@ -100,6 +100,12 @@ public class ConfigTools {
public Component formatLore(String configName, String placeHolder, Object value) {
String lore = toolStats.config.getString("messages." + configName);
if (lore == null) {
toolStats.logger.warning("Unable to find config message for: messages." + configName);
return null;
}
// if the config message is empty, don't send it
if (lore.isEmpty()) {
return null;
}