v3.14.4.6

This commit is contained in:
rockyhawk64 2021-01-04 09:30:21 +11:00
parent da29469afe
commit 2fb64f9eb4
4 changed files with 37 additions and 15 deletions

View File

@ -1,4 +1,4 @@
version: 3.14.4.5
version: 3.14.4.6
main: me.rockyhawk.commandpanels.CommandPanels
name: CommandPanels
author: RockyHawk

View File

@ -96,20 +96,6 @@ public class Commandpanelrefresher implements Listener {
}
}
c = 0;
//check to ensure players haven't duplicated items
try {
p.updateInventory();
for (ItemStack playerContent : plugin.legacy.getStorageContents(p.getInventory())) {
//ensure the panel item is not a placeable item
try {
if (NBTEditor.getString(playerContent, "plugin").equalsIgnoreCase("CommandPanels")) {
p.getInventory().removeItem(playerContent);
}
}catch(Exception ignore){}
}
}catch(Exception e){
//oof
}
this.cancel();
}
}

View File

@ -1,8 +1,12 @@
package me.rockyhawk.commandpanels.openpanelsmanager;
import me.rockyhawk.commandpanels.CommandPanels;
import me.rockyhawk.commandpanels.ioclasses.NBTEditor;
import org.bukkit.Bukkit;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@ -89,6 +93,7 @@ public class OpenPanelsLoader {
for(int i = 0; i < openPanelsPN.size(); i++){
if(openPanelsPN.get(i)[0].equals(playerName)){
panelCloseCommands(playerName,openPanelsPN.get(i)[1]);
checkNBTItems(Bukkit.getPlayer(playerName));
plugin.customCommand.removeCCP(openPanelsPN.get(i)[1], playerName);
openPanelsCF.remove(i);
openPanelsPN.remove(i);
@ -102,6 +107,7 @@ public class OpenPanelsLoader {
for(int i = 0; i < openPanelsPN.size(); i++){
if(Arrays.equals(openPanelsPN.get(i), new String[]{playerName, panelName})){
panelCloseCommands(playerName,panelName);
checkNBTItems(Bukkit.getPlayer(playerName));
plugin.customCommand.removeCCP(panelName, playerName);
openPanelsCF.remove(i);
openPanelsPN.remove(i);
@ -139,4 +145,20 @@ public class OpenPanelsLoader {
}
}
}
//ensure the player has not duplicated items
public void checkNBTItems(Player p){
try {
for(ItemStack playerItem : p.getInventory().getContents()){
//ensure the item is not a panel item
try {
if (NBTEditor.getString(playerItem, "plugin").equalsIgnoreCase("CommandPanels")) {
p.getInventory().removeItem(playerItem);
}
}catch(Exception ignore){}
}
}catch(Exception e){
//oof
}
}
}

View File

@ -1,9 +1,13 @@
package me.rockyhawk.commandpanels.openpanelsmanager;
import me.rockyhawk.commandpanels.CommandPanels;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.event.inventory.InventoryOpenEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import java.util.Objects;
@ -39,4 +43,14 @@ public class UtilsPanelsLoader implements Listener {
}
}
}
@EventHandler
public void onInventoryItemClick(InventoryClickEvent e){
//this will check to ensure an item is not from CommandPanels on inventory open
try {
plugin.openPanels.checkNBTItems((Player) e.getWhoClicked());
}catch(Exception ex){
plugin.debug(ex);
}
}
}