forked from Upstream/CommandPanels
v3.14.2.1
This commit is contained in:
parent
16fc049660
commit
00152786e0
@ -1,4 +1,4 @@
|
|||||||
version: 3.14.2.0
|
version: 3.14.2.1
|
||||||
main: me.rockyhawk.commandpanels.CommandPanels
|
main: me.rockyhawk.commandpanels.CommandPanels
|
||||||
name: CommandPanels
|
name: CommandPanels
|
||||||
author: RockyHawk
|
author: RockyHawk
|
||||||
|
@ -51,10 +51,15 @@ public class HotbarItemLoader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//return true if found
|
//return true if found
|
||||||
public boolean itemCheckExecute(ItemStack invItem, Player p, boolean openPanel){
|
public boolean itemCheckExecute(ItemStack invItem, Player p, boolean openPanel, boolean stationaryOnly){
|
||||||
for(String[] panelName : plugin.panelNames) {
|
for(String[] panelName : plugin.panelNames) {
|
||||||
ConfigurationSection tempFile = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + plugin.panelFiles.get(Integer.parseInt(panelName[1])))).getConfigurationSection("panels." + panelName[0]);
|
ConfigurationSection tempFile = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + plugin.panelFiles.get(Integer.parseInt(panelName[1])))).getConfigurationSection("panels." + panelName[0]);
|
||||||
String tempName = panelName[0];
|
String tempName = panelName[0];
|
||||||
|
if(stationaryOnly){
|
||||||
|
if(!tempFile.contains("open-with-item.stationary")){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
if(tempFile.contains("open-with-item")){
|
if(tempFile.contains("open-with-item")){
|
||||||
ItemStack panelItem = plugin.itemCreate.makeItemFromConfig(Objects.requireNonNull(tempFile.getConfigurationSection("open-with-item")), p, false, true);
|
ItemStack panelItem = plugin.itemCreate.makeItemFromConfig(Objects.requireNonNull(tempFile.getConfigurationSection("open-with-item")), p, false, true);
|
||||||
if(invItem != null && panelItem != null) {
|
if(invItem != null && panelItem != null) {
|
||||||
|
@ -18,7 +18,7 @@ public class SwapItemEvent implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Player p = e.getPlayer();
|
Player p = e.getPlayer();
|
||||||
if(plugin.hotbar.itemCheckExecute(e.getOffHandItem(),p,false)){
|
if(plugin.hotbar.itemCheckExecute(e.getOffHandItem(),p,false,true)){
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
p.updateInventory();
|
p.updateInventory();
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,7 @@ public class UtilsOpenWithItem implements Listener {
|
|||||||
p.updateInventory();
|
p.updateInventory();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(plugin.hotbar.itemCheckExecute(e.getCurrentItem(),p,false) || plugin.hotbar.itemCheckExecute(e.getCursor(),p,false) || plugin.hotbar.stationaryExecute(e.getHotbarButton(),p,false)){
|
if (plugin.hotbar.itemCheckExecute(e.getCurrentItem(), p, false,true) || plugin.hotbar.itemCheckExecute(e.getCursor(), p, false,true) || plugin.hotbar.stationaryExecute(e.getHotbarButton(), p, false)) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
p.updateInventory();
|
p.updateInventory();
|
||||||
}
|
}
|
||||||
@ -64,7 +64,7 @@ public class UtilsOpenWithItem implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Player p = e.getPlayer();
|
Player p = e.getPlayer();
|
||||||
if(plugin.hotbar.itemCheckExecute(e.getItem(),p,true)){
|
if(plugin.hotbar.itemCheckExecute(e.getItem(),p,true,false)){
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
p.updateInventory();
|
p.updateInventory();
|
||||||
}
|
}
|
||||||
@ -259,35 +259,9 @@ public class UtilsOpenWithItem implements Listener {
|
|||||||
}
|
}
|
||||||
//if item dropped
|
//if item dropped
|
||||||
Player p = e.getPlayer();
|
Player p = e.getPlayer();
|
||||||
try {
|
if(plugin.hotbar.itemCheckExecute(e.getItemDrop().getItemStack(),p,false,true)){
|
||||||
if (plugin.panelFiles == null) {
|
e.setCancelled(true);
|
||||||
return;
|
p.updateInventory();
|
||||||
}
|
|
||||||
}catch(Exception b){
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ItemStack clicked = e.getItemDrop().getItemStack();
|
|
||||||
for(String[] panelName : plugin.panelNames){
|
|
||||||
YamlConfiguration tempFile = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + plugin.panelFiles.get(Integer.parseInt(panelName[1]))));
|
|
||||||
String tempName = panelName[0];
|
|
||||||
if(tempFile.contains("panels." + tempName + ".open-with-item")) {
|
|
||||||
try{
|
|
||||||
assert clicked != null;
|
|
||||||
if (clicked.getType() == new ItemStack(Objects.requireNonNull(plugin.itemCreate.makeItemFromConfig(Objects.requireNonNull(tempFile.getConfigurationSection("panels." + tempName + ".open-with-item")), p, false, true).getType()), 1).getType()) {
|
|
||||||
if ((plugin.papi( Objects.requireNonNull(clicked.getItemMeta()).getDisplayName()).equals(plugin.papi( Objects.requireNonNull(tempFile.getString("panels." + tempName + ".open-with-item.name")))))) {
|
|
||||||
//cancel the click item event
|
|
||||||
if (tempFile.contains("panels." + tempName + ".open-with-item.stationary")) {
|
|
||||||
e.setCancelled(true);
|
|
||||||
p.updateInventory();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}catch(NullPointerException cancel){
|
|
||||||
//do nothing skip item
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@EventHandler
|
@EventHandler
|
||||||
@ -304,7 +278,7 @@ public class UtilsOpenWithItem implements Listener {
|
|||||||
}else{
|
}else{
|
||||||
clicked = new GetItemInHand(plugin).itemInHand(p);
|
clicked = new GetItemInHand(plugin).itemInHand(p);
|
||||||
}
|
}
|
||||||
if(plugin.hotbar.itemCheckExecute(clicked,p,true)){
|
if(plugin.hotbar.itemCheckExecute(clicked,p,true,false)){
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
p.updateInventory();
|
p.updateInventory();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user