This commit is contained in:
rockyhawk64 2022-07-01 11:19:00 +10:00
parent 5032e5f218
commit 17168ef241
3 changed files with 23 additions and 11 deletions

View File

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

View File

@ -1,6 +1,5 @@
package me.rockyhawk.commandpanels.openpanelsmanager; package me.rockyhawk.commandpanels.openpanelsmanager;
import me.realized.tokenmanager.command.commands.subcommands.TopCommand;
import me.rockyhawk.commandpanels.CommandPanels; import me.rockyhawk.commandpanels.CommandPanels;
import me.rockyhawk.commandpanels.api.Panel; import me.rockyhawk.commandpanels.api.Panel;
import me.rockyhawk.commandpanels.api.PanelClosedEvent; import me.rockyhawk.commandpanels.api.PanelClosedEvent;

View File

@ -20,19 +20,28 @@ public class PanelBlockOnClick implements Listener {
@EventHandler @EventHandler
public void onInteract(PlayerInteractEvent e){ public void onInteract(PlayerInteractEvent e){
if(e.getAction() == Action.RIGHT_CLICK_BLOCK && e.getClickedBlock() != null) { boolean isPanelBlock = blockClickEventTrigger(e.getClickedBlock().getLocation(), e.getPlayer(),true);
e.setCancelled(blockClickEventTrigger(e.getClickedBlock().getLocation(), e.getPlayer())); if(isPanelBlock) {
if (e.getAction() == Action.RIGHT_CLICK_BLOCK && e.getClickedBlock() != null) {
blockClickEventTrigger(e.getClickedBlock().getLocation(), e.getPlayer(),false);
e.setCancelled(true);
}
} }
} }
@EventHandler @EventHandler
public void onInteractEntity(PlayerInteractEntityEvent e){ public void onInteractEntity(PlayerInteractEntityEvent e){
if(!e.getPlayer().isSneaking()) { boolean isPanelBlock = blockClickEventTrigger(e.getRightClicked().getLocation().getBlock().getLocation(), e.getPlayer(),true);
e.setCancelled(blockClickEventTrigger(e.getRightClicked().getLocation().getBlock().getLocation(), e.getPlayer())); if(isPanelBlock) {
if (!e.getPlayer().isSneaking()) {
blockClickEventTrigger(e.getRightClicked().getLocation().getBlock().getLocation(), e.getPlayer(), false);
e.setCancelled(true);
}
} }
} }
public boolean blockClickEventTrigger(Location location, Player p){ //if isVoid is used, it will not trigger anything to happen
public boolean blockClickEventTrigger(Location location, Player p, boolean isVoid){
//if panel blocks are disabled return //if panel blocks are disabled return
if(Objects.requireNonNull(plugin.config.getString("config.panel-blocks")).equalsIgnoreCase("false")){ if(Objects.requireNonNull(plugin.config.getString("config.panel-blocks")).equalsIgnoreCase("false")){
return false; return false;
@ -50,14 +59,18 @@ public class PanelBlockOnClick implements Listener {
Location tempLocation = new Location(plugin.getServer().getWorld(loc[0].replaceAll("%dash%","_")),Double.parseDouble(loc[1]),Double.parseDouble(loc[2]),Double.parseDouble(loc[3])); Location tempLocation = new Location(plugin.getServer().getWorld(loc[0].replaceAll("%dash%","_")),Double.parseDouble(loc[1]),Double.parseDouble(loc[2]),Double.parseDouble(loc[3]));
if(tempLocation.equals(location)){ if(tempLocation.equals(location)){
if(plugin.blockConfig.contains("blocks." + configLocation + ".commands")){ if(plugin.blockConfig.contains("blocks." + configLocation + ".commands")){
for(String command : plugin.blockConfig.getStringList("blocks." + configLocation + ".commands")){ if(!isVoid) {
plugin.commandTags.runCommand(null,PanelPosition.Top,p, command); for (String command : plugin.blockConfig.getStringList("blocks." + configLocation + ".commands")) {
plugin.commandTags.runCommand(null, PanelPosition.Top, p, command);
}
} }
return true; return true;
} }
//uses the open= tag because it will open a panel with panel names, but also works with open= features like placeholders //uses the open= tag because it will open a panel with panel names, but also works with open= features like placeholders
String command = "open= " + plugin.blockConfig.getString("blocks." + configLocation + ".panel"); if(!isVoid) {
plugin.commandTags.runCommand(null,PanelPosition.Top,p, command); String command = "open= " + plugin.blockConfig.getString("blocks." + configLocation + ".panel");
plugin.commandTags.runCommand(null, PanelPosition.Top, p, command);
}
return true; return true;
} }
} }