Skip to content

Commit 98ee84a

Browse files
committed
fix handling empty messages
1 parent c68a048 commit 98ee84a

File tree

4 files changed

+13
-3
lines changed

4 files changed

+13
-3
lines changed

pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
<groupId>lol.hyper</groupId>
2525
<artifactId>toolstats</artifactId>
26-
<version>1.8.5</version>
26+
<version>1.8.6</version>
2727
<packaging>jar</packaging>
2828

2929
<name>ToolStats</name>

src/main/java/lol/hyper/toolstats/events/CraftItem.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,9 @@ public void onCraft(CraftItemEvent event) {
6565
// if the player shift clicks, send them this warning
6666
if (event.isShiftClick()) {
6767
Component component = toolStats.configTools.formatLore("shift-click-warning.crafting", null, null);
68-
event.getWhoClicked().sendMessage(component);
68+
if (component != null) {
69+
event.getWhoClicked().sendMessage(component);
70+
}
6971
}
7072

7173
// test the item before setting it

src/main/java/lol/hyper/toolstats/events/VillagerTrade.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,9 @@ public void onTrade(InventoryClickEvent event) {
7070
// if the player shift clicks, show the warning
7171
if (event.isShiftClick()) {
7272
Component component = toolStats.configTools.formatLore("shift-click-warning.trading", null, null);
73-
event.getWhoClicked().sendMessage(component);
73+
if (component != null) {
74+
event.getWhoClicked().sendMessage(component);
75+
}
7476
}
7577
ItemStack newItem = addLore(item, player);
7678
if (newItem != null) {

src/main/java/lol/hyper/toolstats/tools/config/ConfigTools.java

+6
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,12 @@ public boolean checkConfig(Material material, String configName) {
100100
public Component formatLore(String configName, String placeHolder, Object value) {
101101
String lore = toolStats.config.getString("messages." + configName);
102102
if (lore == null) {
103+
toolStats.logger.warning("Unable to find config message for: messages." + configName);
104+
return null;
105+
}
106+
107+
// if the config message is empty, don't send it
108+
if (lore.isEmpty()) {
103109
return null;
104110
}
105111

0 commit comments

Comments
 (0)