2 Commits

Author SHA1 Message Date
a05b941aaf 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.
2022-05-12 18:28:35 +02:00
36de2ff0ca Small bugfix 2022-05-03 19:23:17 +02:00
6 changed files with 62 additions and 54 deletions

View File

@@ -6,7 +6,7 @@
<groupId>net.t2code</groupId> <groupId>net.t2code</groupId>
<artifactId>CommandGUI_V2</artifactId> <artifactId>CommandGUI_V2</artifactId>
<version>2.7.0</version> <version>2.7.1</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>CommandGUI</name> <name>CommandGUI</name>

View File

@@ -43,19 +43,20 @@ public class ItemChange {
} }
} }
} }
send.debug(Main.plugin,"GiveOnlyOnFirstJoin: " +player.getName()); send.debug(Main.plugin, "GiveOnlyOnFirstJoin: " + player.getName());
return; return;
} }
if (!SelectConfig.UseItem_GiveOnEveryJoin) { if (!SelectConfig.UseItem_GiveOnEveryJoin) {
send.debug(Main.plugin,"!GiveOnEveryJoin: " +player.getName()); send.debug(Main.plugin, "!GiveOnEveryJoin: " + player.getName());
return; return;
} }
new BukkitRunnable() { new BukkitRunnable() {
@Override @Override
public void run() { public void run() {
if (player == null) return;
if (!SelectConfig.UseItem_AllowToggle || Events.useItemHashMap.get(player)) { if (!SelectConfig.UseItem_AllowToggle || Events.useItemHashMap.get(player)) {
if (SelectConfig.UseItem_InventorySlotEnforce || player.getInventory().getItem(slot - 1) == null) { if (SelectConfig.UseItem_InventorySlotEnforce || player.getInventory().getItem(slot - 1) == null) {
send.debug(Main.plugin,"Give: " +player.getName()); send.debug(Main.plugin, "Give: " + player.getName());
UseItem.giveUseItem(player); UseItem.giveUseItem(player);
if (setCursor) { if (setCursor) {
setCursor(player, slot); setCursor(player, slot);
@@ -79,37 +80,37 @@ public class ItemChange {
} }
private static void setCursor(Player player, int slot) { private static void setCursor(Player player, int slot) {
send.debug(Main.plugin,"setCursor 1 Player: "+player.getName()); send.debug(Main.plugin, "setCursor 1 Player: " + player.getName());
if (!SelectConfig.Cursor_ToGUIItem_OnLogin) { if (!SelectConfig.Cursor_ToGUIItem_OnLogin) {
return; return;
} }
send.debug(Main.plugin,"setCursor 2 Player: "+player.getName()); send.debug(Main.plugin, "setCursor 2 Player: " + player.getName());
if (SelectConfig.Cursor_ToGUIItem_OnlyOnFirstLogin) { if (SelectConfig.Cursor_ToGUIItem_OnlyOnFirstLogin) {
if (!player.hasPlayedBefore()) { if (!player.hasPlayedBefore()) {
player.getInventory().setHeldItemSlot(slot - 1); player.getInventory().setHeldItemSlot(slot - 1);
send.debug(Main.plugin,"setCursor 3 Player: "+player.getName()); send.debug(Main.plugin, "setCursor 3 Player: " + player.getName());
} }
return; return;
} }
send.debug(Main.plugin,"setCursor 4 Player: "+player.getName()); send.debug(Main.plugin, "setCursor 4 Player: " + player.getName());
if (!SelectConfig.Bungee) { if (!SelectConfig.Bungee) {
player.getInventory().setHeldItemSlot(slot - 1); player.getInventory().setHeldItemSlot(slot - 1);
send.debug(Main.plugin,"setCursor 5 Player: "+player.getName()); send.debug(Main.plugin, "setCursor 5 Player: " + player.getName());
return; return;
} }
send.debug(Main.plugin,"setCursor 6 Player: "+player.getName()); send.debug(Main.plugin, "setCursor 6 Player: " + player.getName());
if (SelectConfig.UseItem_ServerChange) { if (SelectConfig.UseItem_ServerChange) {
player.getInventory().setHeldItemSlot(slot - 1); player.getInventory().setHeldItemSlot(slot - 1);
send.debug(Main.plugin,"setCursor 7 Player: "+player.getName()); send.debug(Main.plugin, "setCursor 7 Player: " + player.getName());
return; return;
} }
send.debug(Main.plugin,"setCursor 8 Player: "+player.getName()); send.debug(Main.plugin, "setCursor 8 Player: " + player.getName());
send.debug(Main.plugin,"setCursor bungeejoinplayers: " +Main.bungeejoinplayers); send.debug(Main.plugin, "setCursor bungeejoinplayers: " + Main.bungeejoinplayers);
send.debug(Main.plugin,"setCursor Player: " +player.getName()); send.debug(Main.plugin, "setCursor Player: " + player.getName());
if (Main.bungeejoinplayers.contains(player.getName())) { if (Main.bungeejoinplayers.contains(player.getName())) {
player.getInventory().setHeldItemSlot(slot - 1); player.getInventory().setHeldItemSlot(slot - 1);
send.debug(Main.plugin,"setCursor 9 Player: "+player.getName()); send.debug(Main.plugin, "setCursor 9 Player: " + player.getName());
Main.bungeejoinplayers.remove(player.getName()); Main.bungeejoinplayers.remove(player.getName());
} }
} }

View File

@@ -160,7 +160,7 @@ 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 && player.isSneaking()) { if ((!SelectConfig.disableInfoBySneak) && player.isSneaking()) {
Commands.info(player); Commands.info(player);
return; return;
} }
@@ -211,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,14 +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");
ConfigCreate.configCreate();
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();
@@ -161,7 +161,11 @@ 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) {
player.sendMessage(Util.getPrefix() + " §4Function disabled");
return;
}
if (setSlot < 1) { if (setSlot < 1) {
send.player(player, SelectMessages.ItemSlot_wrongValue); send.player(player, SelectMessages.ItemSlot_wrongValue);
return; return;
@@ -170,27 +174,28 @@ public class Commands {
send.player(player, SelectMessages.ItemSlot_wrongValue); send.player(player, SelectMessages.ItemSlot_wrongValue);
return; return;
} }
ItemStack itm1 = player.getInventory().getItem(setSlot + 1);
if (itm1 != null) { if (Events.useItemHashMap.get(player)) {
if (itm1.getType() == Material.valueOf(SelectConfig.UseItem_Material) || itm1.getType() == ItemVersion.getHead()) { if (Objects.equals(Events.useItemSlotHashMap.get(player), setSlot)) {
if (itm1.getItemMeta().getDisplayName().equals(SelectConfig.UseItem_Name)) {
player.sendMessage(SelectMessages.ItemSlotAlreadySet.replace("[slot]", setSlot.toString())); player.sendMessage(SelectMessages.ItemSlotAlreadySet.replace("[slot]", setSlot.toString()));
return; return;
} }
} }
}
if (SelectConfig.UseItem_InventorySlotEnforce || player.getInventory().getItem(setSlot - 1) != null) { if (SelectConfig.UseItem_InventorySlotEnforce || player.getInventory().getItem(setSlot - 1) != null) {
send.player(player, SelectMessages.ItemSlotNotEmpty.replace("[slot]", setSlot.toString())); send.player(player, SelectMessages.ItemSlotNotEmpty.replace("[slot]", setSlot.toString()));
return; return;
} }
UseItem.removeItem(player); UseItem.removeItem(player);
SelectDatabase.setSlot(player, setSlot); SelectDatabase.setSlot(player, setSlot);
Events.useItemSlotHashMap.replace(player, setSlot); Events.useItemSlotHashMap.replace(player, setSlot);
if (Events.useItemHashMap.get(player)) { if (Events.useItemHashMap.get(player)) {
UseItem.giveUseItem(player); UseItem.giveUseItem(player);
} }
send.player(player, SelectMessages.ItemSlot.replace("[slot]", setSlot.toString())); 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;
@@ -61,7 +58,7 @@ public class SelectConfig {
public static String UseItemWorldMode; public static String UseItemWorldMode;
public static List<String> UseItemWorldList; public static List<String> UseItemWorldList;
public static Boolean disableInfoBySneak; public static Boolean disableInfoBySneak = false;
public static Boolean UseItem_InventorySlot_FreeSlot; public static Boolean UseItem_InventorySlot_FreeSlot;
public static Integer UseItem_InventorySlot; public static Integer UseItem_InventorySlot;
@@ -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");