Fix incorrect sending of error message when item is command

This commit is contained in:
ChronosX88 2021-08-04 01:30:29 +03:00
parent a60c58df39
commit 05627a4b33
Signed by: ChronosXYZ
GPG Key ID: 085A69A82C8C511A

View File

@ -87,6 +87,25 @@ public class InventoryEvents implements Listener {
clickedItem = new ItemStack(Objects.requireNonNull(Material.matchMaterial(itemConfig))); // Item that user clicked clickedItem = new ItemStack(Objects.requireNonNull(Material.matchMaterial(itemConfig))); // Item that user clicked
int slot = event.getSlot(); int slot = event.getSlot();
if (OreMarket.main().getGuiConfig().contains("items." + event.getSlot() + ".commands")) {
assert keySection != null;
for (String command : Objects.requireNonNull(OreMarket.main().getGuiConfig().getStringList("items." + event.getSlot() + ".commands"))) {
if (command != null) {
String toSend = plh.format(command, player, keySection);
if (toSend.equals("[close]")) {
player.closeInventory();
}
else if (toSend.contains("[msg]")) {
player.sendMessage(toSend.replace("[msg] ", ""));
}
else {
Bukkit.dispatchCommand(player, toSend);
}
}
}
return;
}
if ((event.getClick() == ClickType.LEFT)) { // Sell Mode if ((event.getClick() == ClickType.LEFT)) { // Sell Mode
if (!OreMarket.main().getGuiConfig().getBoolean("items." + event.getSlot() + ".buyonly")) { if (!OreMarket.main().getGuiConfig().getBoolean("items." + event.getSlot() + ".buyonly")) {
double value = OreMarket.main().getGuiConfig().getDouble("items." + slot + ".value"); double value = OreMarket.main().getGuiConfig().getDouble("items." + slot + ".value");
@ -148,22 +167,6 @@ public class InventoryEvents implements Listener {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', message)); player.sendMessage(ChatColor.translateAlternateColorCodes('&', message));
} }
} }
assert keySection != null;
for (String command : Objects.requireNonNull(OreMarket.main().getGuiConfig().getStringList("items." + event.getSlot() + ".commands"))) {
if (command != null) {
String toSend = plh.format(command, player, keySection);
if (toSend.equals("[close]")) {
player.closeInventory();
}
else if (toSend.contains("[msg]")) {
player.sendMessage(toSend.replace("[msg] ", ""));
}
else {
Bukkit.dispatchCommand(player, toSend);
}
}
}
} }
} }