2.7.1 | Bug fixes

Bug fixes:
- When sneaking and using the UseItem, an error occurred.
- The config.yml was not reloaded on '/commandgui admin reload' and the change was rolled back
- The command '/gui-item slot <slot>' was calculated incorrectly and it often came the message that the selected slot was occupied although it was not.
This commit is contained in:
JaTiTV 2022-05-12 18:28:35 +02:00
parent 36de2ff0ca
commit a05b941aaf
4 changed files with 47 additions and 41 deletions

View File

@ -160,11 +160,9 @@ public class Events implements Listener {
private static void openGUI(PlayerInteractEvent e, Player player) { private static void openGUI(PlayerInteractEvent e, Player player) {
e.setCancelled(true); e.setCancelled(true);
if (!SelectConfig.disableInfoBySneak){ if ((!SelectConfig.disableInfoBySneak) && player.isSneaking()) {
if ( player.isSneaking()) { Commands.info(player);
Commands.info(player); return;
return;
}
} }
if (!legacy()) { if (!legacy()) {
@ -213,7 +211,6 @@ public class Events implements Listener {
if (e.getItem() != null && e.getItem().hasItemMeta() && e.getItem().getItemMeta().hasDisplayName() if (e.getItem() != null && e.getItem().hasItemMeta() && e.getItem().getItemMeta().hasDisplayName()
&& e.getItem().getItemMeta().getDisplayName().equals(SelectConfig.UseItem_Name)) { && e.getItem().getItemMeta().getDisplayName().equals(SelectConfig.UseItem_Name)) {
e.setCancelled(true); e.setCancelled(true);
} }
} }

View File

@ -65,13 +65,14 @@ public class Commands {
CmdExecuter_GUITab.arg1.clear(); CmdExecuter_GUITab.arg1.clear();
CmdExecuter_GUITab.arg1.put("admin", "commandgui.admin;commandgui.giveitem.other;commandgui.command.info"); CmdExecuter_GUITab.arg1.put("admin", "commandgui.admin;commandgui.giveitem.other;commandgui.command.info");
SelectConfig.onSelect();
SelectConfig.onSelect();
Main.plugin.reloadConfig(); Main.plugin.reloadConfig();
if (!Objects.equals(SelectDatabase.getStorage().toString(), SelectConfig.storage)) { if (!Objects.equals(SelectDatabase.getStorage().toString(), SelectConfig.storage)) {
if (sender instanceof Player) send.sender(sender, "You have changed the storage medium! To apply this change, you must restart the server!"); if (sender instanceof Player) send.sender(sender, "You have changed the storage medium! To apply this change, you must restart the server!");
send.console("You have changed the storage medium! To apply this change, you must restart the server!"); send.console("You have changed the storage medium! To apply this change, you must restart the server!");
} }
LanguagesCreate.langCreate(); LanguagesCreate.langCreate();
Obj_Select.onSelect(); Obj_Select.onSelect();
@ -160,36 +161,41 @@ public class Commands {
} }
public static void onSetSlot(Player player, Integer setSlot) { public static void onSetSlot(Player player, Integer setSlot) {
if (SelectConfig.UseItem_AllowSetSlot) { if (!SelectConfig.UseItem_AllowSetSlot) {
if (setSlot < 1) { player.sendMessage(Util.getPrefix() + " §4Function disabled");
send.player(player, SelectMessages.ItemSlot_wrongValue); return;
}
if (setSlot < 1) {
send.player(player, SelectMessages.ItemSlot_wrongValue);
return;
}
if (setSlot > 9) {
send.player(player, SelectMessages.ItemSlot_wrongValue);
return;
}
if (Events.useItemHashMap.get(player)) {
if (Objects.equals(Events.useItemSlotHashMap.get(player), setSlot)) {
player.sendMessage(SelectMessages.ItemSlotAlreadySet.replace("[slot]", setSlot.toString()));
return; return;
} }
if (setSlot > 9) { }
send.player(player, SelectMessages.ItemSlot_wrongValue);
return; if (SelectConfig.UseItem_InventorySlotEnforce || player.getInventory().getItem(setSlot - 1) != null) {
} send.player(player, SelectMessages.ItemSlotNotEmpty.replace("[slot]", setSlot.toString()));
ItemStack itm1 = player.getInventory().getItem(setSlot + 1); return;
if (itm1 != null) { }
if (itm1.getType() == Material.valueOf(SelectConfig.UseItem_Material) || itm1.getType() == ItemVersion.getHead()) {
if (itm1.getItemMeta().getDisplayName().equals(SelectConfig.UseItem_Name)) { UseItem.removeItem(player);
player.sendMessage(SelectMessages.ItemSlotAlreadySet.replace("[slot]", setSlot.toString())); SelectDatabase.setSlot(player, setSlot);
return; Events.useItemSlotHashMap.replace(player, setSlot);
}
} if (Events.useItemHashMap.get(player)) {
} UseItem.giveUseItem(player);
if (SelectConfig.UseItem_InventorySlotEnforce || player.getInventory().getItem(setSlot - 1) != null) { }
send.player(player, SelectMessages.ItemSlotNotEmpty.replace("[slot]", setSlot.toString()));
return; send.player(player, SelectMessages.ItemSlot.replace("[slot]", setSlot.toString()));
}
UseItem.removeItem(player);
SelectDatabase.setSlot(player, setSlot);
Events.useItemSlotHashMap.replace(player, setSlot);
if (Events.useItemHashMap.get(player)) {
UseItem.giveUseItem(player);
}
send.player(player, SelectMessages.ItemSlot.replace("[slot]", setSlot.toString()));
} else player.sendMessage(Util.getPrefix() + " §4Function disabled");
} }
public static void gui(Player player) { public static void gui(Player player) {

View File

@ -19,9 +19,6 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
public class SelectConfig { public class SelectConfig {
private static final File config = new File(Main.getPath(), "config.yml");
private static final YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
public static Boolean Debug; public static Boolean Debug;
public static Boolean HelpAlias; public static Boolean HelpAlias;
public static String language; public static String language;
@ -117,6 +114,9 @@ public class SelectConfig {
public static void onSelect() { public static void onSelect() {
File config = new File(Main.getPath(), "config.yml");
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
if (yamlConfiguration.getInt("ConfigVersion") < Util.getConfigVersion() && new File(Main.getPath(), "config.yml").exists()) { if (yamlConfiguration.getInt("ConfigVersion") < Util.getConfigVersion() && new File(Main.getPath(), "config.yml").exists()) {
send.console(Util.getPrefix() + " §4----------------------"); send.console(Util.getPrefix() + " §4----------------------");
send.console(Util.getPrefix() + " "); send.console(Util.getPrefix() + " ");
@ -189,7 +189,7 @@ public class SelectConfig {
UseItemWorldMode = yamlConfiguration.getString("Advanced.UseItem.World.Protection.Mode"); UseItemWorldMode = yamlConfiguration.getString("Advanced.UseItem.World.Protection.Mode");
UseItemWorldList = yamlConfiguration.getStringList("Advanced.UseItem.World.Protection.List"); UseItemWorldList = yamlConfiguration.getStringList("Advanced.UseItem.World.Protection.List");
if (yamlConfiguration.get("Advanced.UseItem.DisableInfoBySneak") != null){ if (yamlConfiguration.get("Advanced.UseItem.DisableInfoBySneak") != null) {
disableInfoBySneak = yamlConfiguration.getBoolean("Advanced.UseItem.DisableInfoBySneak"); disableInfoBySneak = yamlConfiguration.getBoolean("Advanced.UseItem.DisableInfoBySneak");
} }
@ -221,7 +221,6 @@ public class SelectConfig {
Sound_Give_input = (yamlConfiguration.getString("Sound.Give.Sound").toUpperCase().replace(".", "_")); Sound_Give_input = (yamlConfiguration.getString("Sound.Give.Sound").toUpperCase().replace(".", "_"));
Sound_PlayerNotFound_Enable = yamlConfiguration.getBoolean("Sound.PlayerNotFound.Enable"); Sound_PlayerNotFound_Enable = yamlConfiguration.getBoolean("Sound.PlayerNotFound.Enable");
Sound_PlayerNotFound_input = (yamlConfiguration.getString("Sound.PlayerNotFound.Sound").toUpperCase().replace(".", "_")); Sound_PlayerNotFound_input = (yamlConfiguration.getString("Sound.PlayerNotFound.Sound").toUpperCase().replace(".", "_"));
setConfigVersion();
} }
@ -345,7 +344,9 @@ public class SelectConfig {
} }
private static void setConfigVersion() { public static void setConfigVersion() {
File config = new File(Main.getPath(), "config.yml");
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
yamlConfiguration.set("ConfigVersion", Util.getConfigVersion()); yamlConfiguration.set("ConfigVersion", Util.getConfigVersion());
try { try {
yamlConfiguration.save(config); yamlConfiguration.save(config);

View File

@ -69,6 +69,8 @@ public class Load {
e.printStackTrace(); e.printStackTrace();
} }
SelectConfig.setConfigVersion();
if (SelectConfig.Bungee) { if (SelectConfig.Bungee) {
if (!Bukkit.getMessenger().isOutgoingChannelRegistered(plugin, "cgui:bungee")) { if (!Bukkit.getMessenger().isOutgoingChannelRegistered(plugin, "cgui:bungee")) {
send.debug(plugin, "registerOutgoingPluginChannel §ecgui:bungee"); send.debug(plugin, "registerOutgoingPluginChannel §ecgui:bungee");