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>
<artifactId>CommandGUI_V2</artifactId>
<version>2.7.0</version>
<version>2.7.1</version>
<packaging>jar</packaging>
<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;
}
if (!SelectConfig.UseItem_GiveOnEveryJoin) {
send.debug(Main.plugin,"!GiveOnEveryJoin: " +player.getName());
send.debug(Main.plugin, "!GiveOnEveryJoin: " + player.getName());
return;
}
new BukkitRunnable() {
@Override
public void run() {
if (player == null) return;
if (!SelectConfig.UseItem_AllowToggle || Events.useItemHashMap.get(player)) {
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);
if (setCursor) {
setCursor(player, slot);
@@ -79,37 +80,37 @@ public class ItemChange {
}
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) {
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 (!player.hasPlayedBefore()) {
player.getInventory().setHeldItemSlot(slot - 1);
send.debug(Main.plugin,"setCursor 3 Player: "+player.getName());
send.debug(Main.plugin, "setCursor 3 Player: " + player.getName());
}
return;
}
send.debug(Main.plugin,"setCursor 4 Player: "+player.getName());
send.debug(Main.plugin, "setCursor 4 Player: " + player.getName());
if (!SelectConfig.Bungee) {
player.getInventory().setHeldItemSlot(slot - 1);
send.debug(Main.plugin,"setCursor 5 Player: "+player.getName());
send.debug(Main.plugin, "setCursor 5 Player: " + player.getName());
return;
}
send.debug(Main.plugin,"setCursor 6 Player: "+player.getName());
send.debug(Main.plugin, "setCursor 6 Player: " + player.getName());
if (SelectConfig.UseItem_ServerChange) {
player.getInventory().setHeldItemSlot(slot - 1);
send.debug(Main.plugin,"setCursor 7 Player: "+player.getName());
send.debug(Main.plugin, "setCursor 7 Player: " + player.getName());
return;
}
send.debug(Main.plugin,"setCursor 8 Player: "+player.getName());
send.debug(Main.plugin,"setCursor bungeejoinplayers: " +Main.bungeejoinplayers);
send.debug(Main.plugin,"setCursor 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 Player: " + player.getName());
if (Main.bungeejoinplayers.contains(player.getName())) {
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());
}
}

View File

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

View File

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

View File

@@ -19,9 +19,6 @@ import java.util.ArrayList;
import java.util.List;
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 HelpAlias;
public static String language;
@@ -61,7 +58,7 @@ public class SelectConfig {
public static String UseItemWorldMode;
public static List<String> UseItemWorldList;
public static Boolean disableInfoBySneak;
public static Boolean disableInfoBySneak = false;
public static Boolean UseItem_InventorySlot_FreeSlot;
public static Integer UseItem_InventorySlot;
@@ -117,6 +114,9 @@ public class SelectConfig {
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()) {
send.console(Util.getPrefix() + " §4----------------------");
send.console(Util.getPrefix() + " ");
@@ -189,7 +189,7 @@ public class SelectConfig {
UseItemWorldMode = yamlConfiguration.getString("Advanced.UseItem.World.Protection.Mode");
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");
}
@@ -221,7 +221,6 @@ public class SelectConfig {
Sound_Give_input = (yamlConfiguration.getString("Sound.Give.Sound").toUpperCase().replace(".", "_"));
Sound_PlayerNotFound_Enable = yamlConfiguration.getBoolean("Sound.PlayerNotFound.Enable");
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());
try {
yamlConfiguration.save(config);

View File

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