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