forked from Upstream/CommandPanels
v3.14.1.1
This commit is contained in:
parent
808b27ef8b
commit
e3872e11b8
@ -493,7 +493,7 @@ public class CommandPanels extends JavaPlugin {
|
||||
ArrayList<String> opanelsTemp = new ArrayList<String>();
|
||||
for(String tempName : apanels){
|
||||
if(opanelsTemp.contains(tempName)){
|
||||
sender.sendMessage("[CommandPanels]" + ChatColor.RED + " Error duplicate panel name: " + tempName);
|
||||
sender.sendMessage(papi(tag) + ChatColor.RED + " Error duplicate panel name: " + tempName);
|
||||
return false;
|
||||
}
|
||||
opanelsTemp.add(tempName);
|
||||
|
@ -55,6 +55,7 @@ public class CommandTags {
|
||||
for(String[] tempName : plugin.panelNames){
|
||||
if(tempName[0].equals(panelName)){
|
||||
ConfigurationSection panelConfig = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + plugin.panelFiles.get(Integer.parseInt(tempName[1])))).getConfigurationSection("panels." + panelName);
|
||||
plugin.openPanels.skipPanels.add(p.getName());
|
||||
plugin.openVoids.openCommandPanel(p,p,panelName,panelConfig,false);
|
||||
return;
|
||||
}
|
||||
@ -487,7 +488,11 @@ public class CommandTags {
|
||||
}else if (command.split("\\s")[0].equalsIgnoreCase("item-paywall=")) {
|
||||
//if player uses item-paywall= [Material] [Amount] [Id]
|
||||
try {
|
||||
ItemStack sellItem = new ItemStack(Objects.requireNonNull(Material.matchMaterial(command.split("\\s")[1])),Integer.parseInt(command.split("\\s")[2]), Short.parseShort(command.split("\\s")[3]));
|
||||
short id = 0;
|
||||
if(command.split("\\s").length == 4){
|
||||
id = Short.parseShort(command.split("\\s")[3]);
|
||||
}
|
||||
ItemStack sellItem = new ItemStack(Objects.requireNonNull(Material.matchMaterial(command.split("\\s")[1])),Integer.parseInt(command.split("\\s")[2]), id);
|
||||
int sellItemAmount = sellItem.getAmount();
|
||||
sellItem.setAmount(1);
|
||||
int removedItem = 0;
|
||||
|
@ -42,8 +42,8 @@ public class ExecuteOpenVoids {
|
||||
sender.sendMessage(plugin.papi(plugin.tag + plugin.config.getString("config.format.notitem")));
|
||||
return;
|
||||
}
|
||||
//close the inventory after the checks for permissions and worlds, so other panels can load
|
||||
p.closeInventory();
|
||||
//close the panel after the checks for permissions and worlds, so other panels can load
|
||||
plugin.openPanels.closePanelsForLoader(p.getName());
|
||||
try {
|
||||
if (cf.contains("sound-on-open")) {
|
||||
//play sound when panel is opened
|
||||
|
@ -14,7 +14,6 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class Commandpanelsreload implements CommandExecutor {
|
||||
CommandPanels plugin;
|
||||
|
@ -325,16 +325,12 @@ public class EditorUtils implements Listener {
|
||||
public void onPlayerClosePanel(InventoryCloseEvent e){
|
||||
//this is put here to avoid conflicts, close panel if it is closed
|
||||
for(int i = 0; i < plugin.openPanels.openPanelsPN.size(); i++){
|
||||
if(plugin.openPanels.skipPanels.contains(e.getPlayer().getName())){
|
||||
plugin.openPanels.skipPanels.remove(e.getPlayer().getName());
|
||||
break;
|
||||
}
|
||||
if(plugin.openPanels.openPanelsPN.get(i)[0].equals(e.getPlayer().getName())){
|
||||
plugin.openPanels.panelCloseCommands(e.getPlayer().getName(),plugin.openPanels.openPanelsPN.get(i)[1]);
|
||||
plugin.customCommand.removeCCP(plugin.openPanels.openPanelsPN.get(i)[1], e.getPlayer().getName());
|
||||
if (plugin.config.contains("config.panel-snooper")) {
|
||||
if (Objects.requireNonNull(plugin.config.getString("config.panel-snooper")).trim().equalsIgnoreCase("true")) {
|
||||
Bukkit.getConsoleSender().sendMessage("[CommandPanels] " + e.getPlayer().getName() + " Closed " + plugin.openPanels.openPanelsPN.get(i)[1]);
|
||||
}
|
||||
}
|
||||
plugin.openPanels.openPanelsPN.remove(i);
|
||||
plugin.openPanels.openPanelsCF.remove(i);
|
||||
plugin.openPanels.closePanelForLoader(e.getPlayer().getName(), plugin.openPanels.openPanelsPN.get(i)[1]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -22,6 +22,9 @@ public class OpenPanelsLoader {
|
||||
public List<ConfigurationSection> openPanelsCF = new ArrayList<>(); //panel config section
|
||||
public List<String[]> openPanelsPN = new ArrayList<>(); //PLayer Name, Panel Name
|
||||
|
||||
//this will skip certain panels from closing for players
|
||||
public List<String> skipPanels = new ArrayList<>(); //PLayer Name
|
||||
|
||||
//this will return the panel CF based on the player, if it isn't there it returns null
|
||||
public ConfigurationSection getOpenPanel(String playerName){
|
||||
for(int i = 0; i < openPanelsCF.size(); i++){
|
||||
@ -53,9 +56,9 @@ public class OpenPanelsLoader {
|
||||
}
|
||||
|
||||
//true if the player has a panel open
|
||||
public boolean hasPanelOpen(String playerName){
|
||||
for(String[] temp : openPanelsPN){
|
||||
if(temp[0].equals(playerName)){
|
||||
public boolean hasPanelOpen(String playerName) {
|
||||
for (String[] temp : openPanelsPN) {
|
||||
if (temp[0].equals(playerName)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -81,14 +84,28 @@ public class OpenPanelsLoader {
|
||||
}
|
||||
}
|
||||
|
||||
//tell loader that the panel is closed
|
||||
public void closePanelForLoader(String playerName, String panelName){
|
||||
for(int i = 0; i < openPanelsCF.size(); i++){
|
||||
if(Arrays.equals(openPanelsPN.get(i), new String[]{playerName, panelName})){
|
||||
panelCloseCommands(playerName,panelName);
|
||||
//close all of the panels for a player currently open
|
||||
public void closePanelsForLoader(String playerName){
|
||||
for(int i = 0; i < openPanelsPN.size(); i++){
|
||||
if(openPanelsPN.get(i)[0].equals(playerName)){
|
||||
panelCloseCommands(playerName,openPanelsPN.get(i)[1]);
|
||||
plugin.customCommand.removeCCP(openPanelsPN.get(i)[1], playerName);
|
||||
openPanelsCF.remove(i);
|
||||
openPanelsPN.remove(i);
|
||||
return;
|
||||
i--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//tell loader that the panel is closed
|
||||
public void closePanelForLoader(String playerName, String panelName){
|
||||
for(int i = 0; i < openPanelsPN.size(); i++){
|
||||
if(Arrays.equals(openPanelsPN.get(i), new String[]{playerName, panelName})){
|
||||
panelCloseCommands(playerName,panelName);
|
||||
plugin.customCommand.removeCCP(panelName, playerName);
|
||||
openPanelsCF.remove(i);
|
||||
openPanelsPN.remove(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (plugin.config.contains("config.panel-snooper")) {
|
||||
|
@ -1,7 +1,6 @@
|
||||
package me.rockyhawk.commandpanels.openpanelsmanager;
|
||||
|
||||
import me.rockyhawk.commandpanels.CommandPanels;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||
@ -18,20 +17,7 @@ public class UtilsPanelsLoader implements Listener {
|
||||
//tell panel loader that player has opened panel
|
||||
@EventHandler
|
||||
public void onPlayerClosePanel(PlayerQuitEvent e){
|
||||
for(int i = 0; i < plugin.openPanels.openPanelsPN.size(); i++){
|
||||
if(plugin.openPanels.openPanelsPN.get(i)[0].equals(e.getPlayer().getName())){
|
||||
plugin.openPanels.panelCloseCommands(e.getPlayer().getName(),plugin.openPanels.openPanelsPN.get(i)[1]);
|
||||
plugin.customCommand.removeCCP(plugin.openPanels.openPanelsPN.get(i)[1], e.getPlayer().getName());
|
||||
if (plugin.config.contains("config.panel-snooper")) {
|
||||
if (Objects.requireNonNull(plugin.config.getString("config.panel-snooper")).trim().equalsIgnoreCase("true")) {
|
||||
Bukkit.getConsoleSender().sendMessage("[CommandPanels] " + e.getPlayer().getName() + " Closed " + plugin.openPanels.openPanelsPN.get(i)[1]);
|
||||
}
|
||||
}
|
||||
plugin.openPanels.openPanelsPN.remove(i);
|
||||
plugin.openPanels.openPanelsCF.remove(i);
|
||||
return;
|
||||
}
|
||||
}
|
||||
plugin.openPanels.closePanelsForLoader(e.getPlayer().getName());
|
||||
}
|
||||
|
||||
//tell panel loader that player has closed the panel (there is also one of these in EditorUtils)
|
||||
@ -40,17 +26,14 @@ public class UtilsPanelsLoader implements Listener {
|
||||
//only do this if editor is disabled as it will disabled this code
|
||||
if(!Objects.requireNonNull(plugin.config.getString("config.ingame-editor")).equalsIgnoreCase("true")) {
|
||||
//this is put here to avoid conflicts, close panel if it is closed
|
||||
if(plugin.openPanels.skipPanels.contains(e.getPlayer().getName())){
|
||||
plugin.openPanels.skipPanels.remove(e.getPlayer().getName());
|
||||
return;
|
||||
}
|
||||
//loop panels
|
||||
for (int i = 0; i < plugin.openPanels.openPanelsPN.size(); i++) {
|
||||
if (plugin.openPanels.openPanelsPN.get(i)[0].equals(e.getPlayer().getName())) {
|
||||
plugin.openPanels.panelCloseCommands(e.getPlayer().getName(),plugin.openPanels.openPanelsPN.get(i)[1]);
|
||||
plugin.customCommand.removeCCP(plugin.openPanels.openPanelsPN.get(i)[1], e.getPlayer().getName());
|
||||
if (plugin.config.contains("config.panel-snooper")) {
|
||||
if (Objects.requireNonNull(plugin.config.getString("config.panel-snooper")).trim().equalsIgnoreCase("true")) {
|
||||
Bukkit.getConsoleSender().sendMessage("[CommandPanels] " + e.getPlayer().getName() + " Closed " + plugin.openPanels.openPanelsPN.get(i)[1]);
|
||||
}
|
||||
}
|
||||
plugin.openPanels.openPanelsPN.remove(i);
|
||||
plugin.openPanels.openPanelsCF.remove(i);
|
||||
plugin.openPanels.closePanelForLoader(e.getPlayer().getName(),plugin.openPanels.openPanelsPN.get(i)[1]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user