forked from Upstream/CommandPanels
v3.15.5.4
This commit is contained in:
parent
b87e7d8df1
commit
9d6a15bd87
@ -1,4 +1,4 @@
|
||||
version: 3.15.5.3
|
||||
version: 3.15.5.4
|
||||
main: me.rockyhawk.commandpanels.CommandPanels
|
||||
name: CommandPanels
|
||||
author: RockyHawk
|
||||
|
@ -151,14 +151,7 @@ public class Utils implements Listener {
|
||||
//end custom command PlaceHolders
|
||||
|
||||
//make the command
|
||||
String command;
|
||||
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));
|
||||
}
|
||||
String command = plugin.tex.papi(panel,p,commands.get(i));
|
||||
|
||||
int val = plugin.commandTags.commandPayWall(p,command);
|
||||
if(val == 0){
|
||||
|
@ -2,6 +2,7 @@ package me.rockyhawk.commandpanels.commandtags;
|
||||
|
||||
import me.rockyhawk.commandpanels.CommandPanels;
|
||||
import me.rockyhawk.commandpanels.api.Panel;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
@ -19,6 +20,13 @@ public class CommandTagEvent extends Event {
|
||||
this.p = player;
|
||||
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);
|
||||
if(split.length == 1){
|
||||
split = new String[]{split[0],""};
|
||||
@ -31,7 +39,11 @@ public class CommandTagEvent extends Event {
|
||||
|
||||
this.name = split[0].trim();
|
||||
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(){
|
||||
|
@ -160,9 +160,10 @@ public class OpenGUI {
|
||||
}
|
||||
if (onOpen == 1 || onOpen == 3) {
|
||||
//onOpen 1 is default and 3 is for the editor
|
||||
//open the panel
|
||||
plugin.openPanels.openPanelForLoader(p.getName(), panel);
|
||||
plugin.openPanels.skipPanelClose.add(p.getName());
|
||||
plugin.openPanels.openPanelForLoader(p.getName(),panel);
|
||||
p.openInventory(i);
|
||||
plugin.openPanels.skipPanelClose.remove(p.getName());
|
||||
} else if (onOpen == 0) {
|
||||
//onOpen 0 will just refresh the panel
|
||||
plugin.legacy.setStorageContents(p,plugin.legacy.getStorageContents(i));
|
||||
|
@ -7,10 +7,7 @@ import me.rockyhawk.commandpanels.ioclasses.NBTEditor;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.*;
|
||||
|
||||
public class OpenPanelsLoader {
|
||||
CommandPanels plugin;
|
||||
@ -24,6 +21,7 @@ public class OpenPanelsLoader {
|
||||
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 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
|
||||
public Panel getOpenPanel(String playerName){
|
||||
@ -77,7 +75,7 @@ public class OpenPanelsLoader {
|
||||
|
||||
//close all of the panels for a player currently open
|
||||
public void closePanelForLoader(String playerName){
|
||||
if(!openPanels.containsKey(playerName)){
|
||||
if(!openPanels.containsKey(playerName) || skipPanelClose.contains(playerName)){
|
||||
return;
|
||||
}
|
||||
panelCloseCommands(playerName,openPanels.get(playerName));
|
||||
|
@ -1,7 +1,10 @@
|
||||
package me.rockyhawk.commandpanels.openpanelsmanager;
|
||||
|
||||
import me.rockyhawk.commandpanels.CommandPanels;
|
||||
import me.rockyhawk.commandpanels.api.Panel;
|
||||
import me.rockyhawk.commandpanels.api.PanelClosedEvent;
|
||||
import me.rockyhawk.commandpanels.ioclasses.NBTEditor;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
@ -63,7 +66,21 @@ public class UtilsPanelsLoader implements Listener {
|
||||
public void vanillaOpenedEvent(InventoryOpenEvent e){
|
||||
if(e.isCancelled()) {
|
||||
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");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user