2.7.2
Small code changes that fixes minor bugs
This commit is contained in:
parent
a05b941aaf
commit
326dfae0e9
@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>net.t2code</groupId>
|
||||
<artifactId>CommandGUI_V2</artifactId>
|
||||
<version>2.7.1</version>
|
||||
<version>2.7.2</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>CommandGUI</name>
|
||||
|
@ -261,7 +261,7 @@ public class GUIListener implements Listener {
|
||||
}
|
||||
|
||||
private static void toggleUseItem(Player player, Gui gui) {
|
||||
if (Events.useItemHashMap.get(player)) {
|
||||
if (Events.useItemHashMap.get(player.getName())) {
|
||||
Commands.itemOff(player);
|
||||
} else {
|
||||
Commands.itemOn(player);
|
||||
|
@ -4,6 +4,7 @@ import de.jatitv.commandguiv2.Spigot.Listener.UseItem_Listener.Events;
|
||||
import de.jatitv.commandguiv2.Spigot.Main;
|
||||
import de.jatitv.commandguiv2.Spigot.system.UseItem;
|
||||
import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig;
|
||||
import de.jatitv.commandguiv2.Spigot.system.database.SelectDatabase;
|
||||
import net.t2code.lib.Spigot.Lib.messages.send;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
@ -14,10 +15,10 @@ public class ItemChange {
|
||||
if (SelectConfig.UseItem_InventorySlotEnforce) {
|
||||
slot = SelectConfig.UseItem_InventorySlot;
|
||||
} else {
|
||||
if (Events.useItemSlotHashMap.get(player) == null) {
|
||||
if (Events.useItemSlotHashMap.get(player.getName()) == null) {
|
||||
slot = SelectConfig.UseItem_InventorySlot;
|
||||
} else {
|
||||
slot = Events.useItemSlotHashMap.get(player);
|
||||
slot = Events.useItemSlotHashMap.get(player.getName());
|
||||
}
|
||||
}
|
||||
|
||||
@ -27,7 +28,7 @@ public class ItemChange {
|
||||
UseItem.removeItem(player);
|
||||
if (UseItem.protection(player, false)) return;
|
||||
if (SelectConfig.UseItem_GiveOnlyOnFirstJoin) {
|
||||
if (!SelectConfig.UseItem_AllowToggle || Events.useItemHashMap.get(player)) {
|
||||
if (!SelectConfig.UseItem_AllowToggle || Events.useItemHashMap.get(player.getName())) {
|
||||
if (!player.hasPlayedBefore()) {
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
@ -53,8 +54,7 @@ public class ItemChange {
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (player == null) return;
|
||||
if (!SelectConfig.UseItem_AllowToggle || Events.useItemHashMap.get(player)) {
|
||||
if (!SelectConfig.UseItem_AllowToggle || Events.useItemHashMap.get(player.getName())) {
|
||||
if (SelectConfig.UseItem_InventorySlotEnforce || player.getInventory().getItem(slot - 1) == null) {
|
||||
send.debug(Main.plugin, "Give: " + player.getName());
|
||||
UseItem.giveUseItem(player);
|
||||
|
@ -34,16 +34,13 @@ import java.util.Iterator;
|
||||
|
||||
public class Events implements Listener {
|
||||
|
||||
public static HashMap<Player, Boolean> useItemHashMap = new HashMap<>();
|
||||
public static HashMap<Player, Integer> useItemSlotHashMap = new HashMap<>();
|
||||
public static HashMap<String, Boolean> useItemHashMap = new HashMap<>();
|
||||
public static HashMap<String, Integer> useItemSlotHashMap = new HashMap<>();
|
||||
|
||||
@EventHandler
|
||||
public void onJoin(PlayerJoinEvent e) {
|
||||
if (SelectDatabase.selectItemStatus(e.getPlayer())) {
|
||||
useItemHashMap.put(e.getPlayer(), true);
|
||||
} else useItemHashMap.put(e.getPlayer(), false);
|
||||
|
||||
useItemSlotHashMap.put(e.getPlayer(), SelectDatabase.selectSlot(e.getPlayer()));
|
||||
useItemHashMap.put(e.getPlayer().getName(), SelectDatabase.selectItemStatus(e.getPlayer()));
|
||||
useItemSlotHashMap.put(e.getPlayer().getName(), SelectDatabase.selectSlot(e.getPlayer()));
|
||||
|
||||
if (CGuiAPI.JoinDisable) {
|
||||
send.debug(Main.plugin, "JoinDisable");
|
||||
@ -62,7 +59,7 @@ public class Events implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onJoin(PlayerQuitEvent e) {
|
||||
useItemHashMap.remove(e.getPlayer());
|
||||
useItemHashMap.remove(e.getPlayer().getName());
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
|
@ -124,10 +124,10 @@ public class Commands {
|
||||
if (SelectConfig.UseItem_InventorySlotEnforce) {
|
||||
slot = SelectConfig.UseItem_InventorySlot;
|
||||
} else {
|
||||
if (Events.useItemSlotHashMap.get(player) == null) {
|
||||
if (Events.useItemSlotHashMap.get(player.getName()) == null) {
|
||||
slot = SelectConfig.UseItem_InventorySlot;
|
||||
} else {
|
||||
slot = Events.useItemSlotHashMap.get(player);
|
||||
slot = Events.useItemSlotHashMap.get(player.getName());
|
||||
}
|
||||
}
|
||||
send.debug(Main.plugin, String.valueOf(slot));
|
||||
@ -175,8 +175,8 @@ public class Commands {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Events.useItemHashMap.get(player)) {
|
||||
if (Objects.equals(Events.useItemSlotHashMap.get(player), setSlot)) {
|
||||
if (Events.useItemHashMap.get(player.getName())) {
|
||||
if (Objects.equals(Events.useItemSlotHashMap.get(player.getName()), setSlot)) {
|
||||
player.sendMessage(SelectMessages.ItemSlotAlreadySet.replace("[slot]", setSlot.toString()));
|
||||
return;
|
||||
}
|
||||
@ -189,9 +189,9 @@ public class Commands {
|
||||
|
||||
UseItem.removeItem(player);
|
||||
SelectDatabase.setSlot(player, setSlot);
|
||||
Events.useItemSlotHashMap.replace(player, setSlot);
|
||||
Events.useItemSlotHashMap.replace(player.getName(), setSlot);
|
||||
|
||||
if (Events.useItemHashMap.get(player)) {
|
||||
if (Events.useItemHashMap.get(player.getName())) {
|
||||
UseItem.giveUseItem(player);
|
||||
}
|
||||
|
||||
|
@ -95,7 +95,7 @@ public class OpenGUI {
|
||||
toggleOff(function, slot.slot, player, inventory);
|
||||
}
|
||||
} else if (function.toggleUseItem) {
|
||||
if (Events.useItemHashMap.get(player)) {
|
||||
if (Events.useItemHashMap.get(player.getName())) {
|
||||
toggleOn(function, slot.slot, player, inventory);
|
||||
} else {
|
||||
toggleOff(function, slot.slot, player, inventory);
|
||||
|
@ -38,17 +38,17 @@ public class Placeholder extends PlaceholderExpansion {
|
||||
@Override
|
||||
public String onPlaceholderRequest(Player p, String params) {
|
||||
if (params.contains("useitem_boolean")) {
|
||||
return Events.useItemHashMap.get(p).toString();
|
||||
return Events.useItemHashMap.get(p.getName()).toString();
|
||||
}
|
||||
|
||||
if (params.contains("useitem")) {
|
||||
if (Events.useItemHashMap.get(p)) {
|
||||
if (Events.useItemHashMap.get(p.getName())) {
|
||||
return SelectConfig.placeholderTrue;
|
||||
} else return SelectConfig.placeholderFalse;
|
||||
}
|
||||
|
||||
if (params.contains("slot")){
|
||||
return Events.useItemSlotHashMap.get(p).toString();
|
||||
return Events.useItemSlotHashMap.get(p.getName()).toString();
|
||||
}
|
||||
|
||||
return null;
|
||||
|
@ -29,10 +29,10 @@ public class UseItem {
|
||||
if (SelectConfig.UseItem_InventorySlotEnforce) {
|
||||
slot = SelectConfig.UseItem_InventorySlot;
|
||||
} else {
|
||||
if (Events.useItemSlotHashMap.get(player) == null) {
|
||||
if (Events.useItemSlotHashMap.get(player.getName()) == null) {
|
||||
slot = SelectConfig.UseItem_InventorySlot;
|
||||
} else {
|
||||
slot = Events.useItemSlotHashMap.get(player);
|
||||
slot = Events.useItemSlotHashMap.get(player.getName());
|
||||
}
|
||||
}
|
||||
if (SelectConfig.UseItem_InventorySlot_FreeSlot) {
|
||||
|
@ -49,7 +49,7 @@ public class SelectDatabase {
|
||||
}
|
||||
|
||||
public static void setItemStatusTrue(Player player) {
|
||||
Events.useItemHashMap.replace(player, true);
|
||||
Events.useItemHashMap.replace(player.getName(), true);
|
||||
switch (Storage) {
|
||||
case MYSQL:
|
||||
MySQL.query("INSERT INTO `gui-item` (`UUID`, `Name`) VALUES ('" + player.getUniqueId() + "', '" + player.getName()
|
||||
@ -67,7 +67,7 @@ public class SelectDatabase {
|
||||
}
|
||||
|
||||
public static void setItemStatusFalse(Player player) {
|
||||
Events.useItemHashMap.replace(player, false);
|
||||
Events.useItemHashMap.replace(player.getName(), false);
|
||||
switch (Storage) {
|
||||
case MYSQL:
|
||||
MySQL.query("INSERT INTO `gui-item` (`UUID`, `Name`, `Status`) VALUES ('" + player.getUniqueId() + "', '" + player.getName()
|
||||
|
@ -44,11 +44,11 @@ public class CGuiAPI {
|
||||
}
|
||||
|
||||
public static Boolean selectPlayerItemEnable(Player player) {
|
||||
return Events.useItemHashMap.get(player);
|
||||
return Events.useItemHashMap.get(player.getName());
|
||||
}
|
||||
|
||||
public static Integer selectPlayerItemSlot(Player player) {
|
||||
return Events.useItemSlotHashMap.get(player);
|
||||
return Events.useItemSlotHashMap.get(player.getName());
|
||||
}
|
||||
|
||||
public static void setPlayerItemEnable(Player player, Boolean value) {
|
||||
|
Loading…
Reference in New Issue
Block a user