v3.15.5.4

This commit is contained in:
rockyhawk64 2021-05-17 21:57:08 +10:00
parent b87e7d8df1
commit 9d6a15bd87
6 changed files with 39 additions and 18 deletions

View File

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

View File

@ -151,14 +151,7 @@ public class Utils implements Listener {
//end custom command PlaceHolders //end custom command PlaceHolders
//make the command //make the command
String command; String command = plugin.tex.papi(panel,p,commands.get(i));
if(commands.get(i).split("\\s")[0].equalsIgnoreCase("nopapi=")){
//won't parse PAPI placeholders
command = plugin.tex.papi(plugin.placeholders.setCpPlaceholders(panel,p,commands.get(i))).replace("nopapi=","").trim();
}else{
//will parse every placeholder
command = plugin.tex.papi(panel,p,commands.get(i));
}
int val = plugin.commandTags.commandPayWall(p,command); int val = plugin.commandTags.commandPayWall(p,command);
if(val == 0){ if(val == 0){

View File

@ -2,6 +2,7 @@ package me.rockyhawk.commandpanels.commandtags;
import me.rockyhawk.commandpanels.CommandPanels; import me.rockyhawk.commandpanels.CommandPanels;
import me.rockyhawk.commandpanels.api.Panel; import me.rockyhawk.commandpanels.api.Panel;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.Event; import org.bukkit.event.Event;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
@ -19,6 +20,13 @@ public class CommandTagEvent extends Event {
this.p = player; this.p = player;
this.panel = panel1; this.panel = panel1;
//do nopapi= tag (donation feature) which will stop PlaceholderAPI placeholders from executing
boolean doApiPlaceholders = true;
if(rawCommand1.startsWith("nopapi= ")){
rawCommand1 = rawCommand1.replace("nopapi= ","");
doApiPlaceholders = false;
}
String[] split = rawCommand1.split(" ", 2); String[] split = rawCommand1.split(" ", 2);
if(split.length == 1){ if(split.length == 1){
split = new String[]{split[0],""}; split = new String[]{split[0],""};
@ -31,7 +39,11 @@ public class CommandTagEvent extends Event {
this.name = split[0].trim(); this.name = split[0].trim();
this.raw = split[1].trim().split("\\s"); this.raw = split[1].trim().split("\\s");
this.args = plugin.tex.papi(panel1,player,split[1].trim()).split("\\s"); if(doApiPlaceholders) {
this.args = plugin.tex.papi(panel1, player, split[1].trim()).split("\\s");
}else{
this.args = ChatColor.translateAlternateColorCodes('&',plugin.placeholders.setCpPlaceholders(panel, p,split[1].trim())).split("\\s");
}
} }
public void commandTagUsed(){ public void commandTagUsed(){

View File

@ -160,9 +160,10 @@ public class OpenGUI {
} }
if (onOpen == 1 || onOpen == 3) { if (onOpen == 1 || onOpen == 3) {
//onOpen 1 is default and 3 is for the editor //onOpen 1 is default and 3 is for the editor
//open the panel plugin.openPanels.skipPanelClose.add(p.getName());
plugin.openPanels.openPanelForLoader(p.getName(), panel); plugin.openPanels.openPanelForLoader(p.getName(),panel);
p.openInventory(i); p.openInventory(i);
plugin.openPanels.skipPanelClose.remove(p.getName());
} else if (onOpen == 0) { } else if (onOpen == 0) {
//onOpen 0 will just refresh the panel //onOpen 0 will just refresh the panel
plugin.legacy.setStorageContents(p,plugin.legacy.getStorageContents(i)); plugin.legacy.setStorageContents(p,plugin.legacy.getStorageContents(i));

View File

@ -7,10 +7,7 @@ import me.rockyhawk.commandpanels.ioclasses.NBTEditor;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import java.util.HashMap; import java.util.*;
import java.util.List;
import java.util.Map;
import java.util.Objects;
public class OpenPanelsLoader { public class OpenPanelsLoader {
CommandPanels plugin; CommandPanels plugin;
@ -24,6 +21,7 @@ public class OpenPanelsLoader {
into the correct panel, so there is no need for the panel name into the correct panel, so there is no need for the panel name
*/ */
public HashMap<String, Panel> openPanels = new HashMap<>(); //player name and panel public HashMap<String, Panel> openPanels = new HashMap<>(); //player name and panel
public HashSet<String> skipPanelClose = new HashSet<>(); //don't remove the player if they are in this list
//this will return the panel CF based on the player, if it isn't there it returns null //this will return the panel CF based on the player, if it isn't there it returns null
public Panel getOpenPanel(String playerName){ public Panel getOpenPanel(String playerName){
@ -77,7 +75,7 @@ public class OpenPanelsLoader {
//close all of the panels for a player currently open //close all of the panels for a player currently open
public void closePanelForLoader(String playerName){ public void closePanelForLoader(String playerName){
if(!openPanels.containsKey(playerName)){ if(!openPanels.containsKey(playerName) || skipPanelClose.contains(playerName)){
return; return;
} }
panelCloseCommands(playerName,openPanels.get(playerName)); panelCloseCommands(playerName,openPanels.get(playerName));

View File

@ -1,7 +1,10 @@
package me.rockyhawk.commandpanels.openpanelsmanager; package me.rockyhawk.commandpanels.openpanelsmanager;
import me.rockyhawk.commandpanels.CommandPanels; import me.rockyhawk.commandpanels.CommandPanels;
import me.rockyhawk.commandpanels.api.Panel;
import me.rockyhawk.commandpanels.api.PanelClosedEvent;
import me.rockyhawk.commandpanels.ioclasses.NBTEditor; import me.rockyhawk.commandpanels.ioclasses.NBTEditor;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
@ -63,7 +66,21 @@ public class UtilsPanelsLoader implements Listener {
public void vanillaOpenedEvent(InventoryOpenEvent e){ public void vanillaOpenedEvent(InventoryOpenEvent e){
if(e.isCancelled()) { if(e.isCancelled()) {
if (plugin.openPanels.hasPanelOpen(e.getPlayer().getName())) { if (plugin.openPanels.hasPanelOpen(e.getPlayer().getName())) {
plugin.openPanels.closePanelForLoader(e.getPlayer().getName()); Panel closedPanel = plugin.openPanels.getOpenPanel(e.getPlayer().getName());
//manually remove player with no skip checks
plugin.openPanels.openPanels.remove(e.getPlayer().getName());
//fire PanelClosedEvent
PanelClosedEvent closedEvent = new PanelClosedEvent(Bukkit.getPlayer(e.getPlayer().getName()),closedPanel);
Bukkit.getPluginManager().callEvent(closedEvent);
//do message
if (plugin.config.contains("config.panel-snooper")) {
if (Objects.requireNonNull(plugin.config.getString("config.panel-snooper")).equalsIgnoreCase("true")) {
Bukkit.getConsoleSender().sendMessage("[CommandPanels] " + e.getPlayer().getName() + "'s Panel was Force Closed");
}
}
} }
} }
} }