forked from Upstream/CommandPanels
v3.10.0 Updates
This commit is contained in:
parent
677d7d92bd
commit
c62f8ee4fb
@ -6,6 +6,7 @@
|
|||||||
panels:
|
panels:
|
||||||
example:
|
example:
|
||||||
perm: default
|
perm: default
|
||||||
|
panelType: default
|
||||||
rows: 4
|
rows: 4
|
||||||
title: '&6[&bExample Panel&6]&f Welcome!'
|
title: '&6[&bExample Panel&6]&f Welcome!'
|
||||||
command: example
|
command: example
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
version: 3.9.4
|
version: 3.10.0
|
||||||
main: me.rockyhawk.commandPanels.commandpanels
|
main: me.rockyhawk.commandPanels.commandpanels
|
||||||
name: CommandPanels
|
name: CommandPanels
|
||||||
author: RockyHawk
|
author: RockyHawk
|
||||||
|
@ -40,6 +40,7 @@ import me.rockyhawk.commandPanels.premium.commandpanelrefresher;
|
|||||||
import net.milkbowl.vault.economy.Economy;
|
import net.milkbowl.vault.economy.Economy;
|
||||||
import org.bukkit.*;
|
import org.bukkit.*;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.configuration.Configuration;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
@ -187,7 +188,7 @@ public class commandpanels extends JavaPlugin {
|
|||||||
String section = "";
|
String section = "";
|
||||||
//onOpen needs to not be 3 so the editor won't include hasperm and hasvalue, etc items
|
//onOpen needs to not be 3 so the editor won't include hasperm and hasvalue, etc items
|
||||||
if (onOpen != 3) {
|
if (onOpen != 3) {
|
||||||
section = hasSection(panels, pconfig, Integer.parseInt(item.split("\\s")[c]), p);
|
section = hasSection(pconfig.getConfigurationSection("panels." + panels + ".item." + Integer.parseInt(item.split("\\s")[c])), p);
|
||||||
//This section is for animations below here: VISUAL ONLY
|
//This section is for animations below here: VISUAL ONLY
|
||||||
|
|
||||||
//check for if there is animations inside the items section
|
//check for if there is animations inside the items section
|
||||||
@ -1818,92 +1819,100 @@ public class commandpanels extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//hasperm hasvalue, etc sections will be done here
|
//hasperm hasvalue, etc sections will be done here
|
||||||
public String hasSection(String panelName, YamlConfiguration cf, int slot, Player p){
|
public String hasSection(ConfigurationSection cf, Player p){
|
||||||
if (cf.contains("panels." + panelName + ".item." + slot + ".hasvalue")) {
|
if (cf.contains("hasvalue")) {
|
||||||
//loop through possible hasvalue 1,2,3,etc
|
|
||||||
for (int count = 0; Objects.requireNonNull(cf.getConfigurationSection("panels." + panelName + ".item." + slot)).getKeys(false).size() > count; count++) {
|
|
||||||
if (cf.contains("panels." + panelName + ".item." + slot + ".hasvalue" + count)) {
|
|
||||||
boolean outputValue = true;
|
|
||||||
//outputValue will default to true
|
|
||||||
if (cf.contains("panels." + panelName + ".item." + slot + ".hasvalue" + count + ".output")) {
|
|
||||||
//if output is true, and values match it will be this item, vice versa
|
|
||||||
outputValue = cf.getBoolean("panels." + panelName + ".item." + slot + ".hasvalue" + count + ".output");
|
|
||||||
}
|
|
||||||
String value = cf.getString("panels." + panelName + ".item." + slot + ".hasvalue" + count + ".value");
|
|
||||||
String compare = ChatColor.stripColor(papi(p,setCpPlaceholders(p,cf.getString("panels." + panelName + ".item." + slot + ".hasvalue" + count + ".compare"))));
|
|
||||||
if (compare.equals(value) == outputValue) {
|
|
||||||
//onOpen being 3 means it is the editor panel.. hasvalue items cannot be included to avoid item breaking
|
|
||||||
return ".hasvalue" + count;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//this will do the hasvalue without any numbers
|
//this will do the hasvalue without any numbers
|
||||||
boolean outputValue = true;
|
boolean outputValue = true;
|
||||||
//outputValue will default to true
|
//outputValue will default to true
|
||||||
if (cf.contains("panels." + panelName + ".item." + slot + ".hasvalue.output")) {
|
if (cf.contains("hasvalue.output")) {
|
||||||
//if output is true, and values match it will be this item, vice versa
|
//if output is true, and values match it will be this item, vice versa
|
||||||
outputValue = cf.getBoolean("panels." + panelName + ".item." + slot + ".hasvalue.output");
|
outputValue = cf.getBoolean("hasvalue.output");
|
||||||
}
|
}
|
||||||
String value = cf.getString("panels." + panelName + ".item." + slot + ".hasvalue.value");
|
String value = cf.getString("hasvalue.value");
|
||||||
String compare = ChatColor.stripColor(papi(p,setCpPlaceholders(p,cf.getString("panels." + panelName + ".item." + slot + ".hasvalue.compare"))));
|
String compare = ChatColor.stripColor(papi(p,setCpPlaceholders(p,cf.getString("hasvalue.compare"))));
|
||||||
if (compare.equals(value) == outputValue) {
|
if (compare.equals(value) == outputValue) {
|
||||||
//onOpen being 3 means it is the editor panel.. hasvalue items cannot be included to avoid item breaking
|
//onOpen being 3 means it is the editor panel.. hasvalue items cannot be included to avoid item breaking
|
||||||
return ".hasvalue";
|
String section = hasSection(Objects.requireNonNull(cf.getConfigurationSection("hasvalue")), p);
|
||||||
|
//string section, it executes itself to check for subsections
|
||||||
|
return ".hasvalue" + section;
|
||||||
|
}
|
||||||
|
//loop through possible hasvalue 1,2,3,etc
|
||||||
|
for (int count = 0; cf.getKeys(false).size() > count; count++) {
|
||||||
|
if (cf.contains("hasvalue" + count)) {
|
||||||
|
outputValue = true;
|
||||||
|
//outputValue will default to true
|
||||||
|
if (cf.contains("hasvalue" + count + ".output")) {
|
||||||
|
//if output is true, and values match it will be this item, vice versa
|
||||||
|
outputValue = cf.getBoolean("hasvalue" + count + ".output");
|
||||||
|
}
|
||||||
|
value = cf.getString("hasvalue" + count + ".value");
|
||||||
|
compare = ChatColor.stripColor(papi(p,setCpPlaceholders(p,cf.getString("hasvalue" + count + ".compare"))));
|
||||||
|
if (compare.equals(value) == outputValue) {
|
||||||
|
//onOpen being 3 means it is the editor panel.. hasvalue items cannot be included to avoid item breaking
|
||||||
|
String section = hasSection(Objects.requireNonNull(cf.getConfigurationSection("hasvalue" + count)), p);
|
||||||
|
//string section, it executes itself to check for subsections
|
||||||
|
return ".hasvalue" + count + section;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (cf.contains("panels." + panelName + ".item." + slot + ".hasgreater")) {
|
}
|
||||||
|
}
|
||||||
|
if (cf.contains("hasgreater")) {
|
||||||
//this will do the hasgreater without any numbers
|
//this will do the hasgreater without any numbers
|
||||||
boolean outputValue = true;
|
boolean outputValue = true;
|
||||||
//outputValue will default to true
|
//outputValue will default to true
|
||||||
if (cf.contains("panels." + panelName + ".item." + slot + ".hasgreater.output")) {
|
if (cf.contains("hasgreater.output")) {
|
||||||
//if output is true, and values match it will be this item, vice versa
|
//if output is true, and values match it will be this item, vice versa
|
||||||
outputValue = cf.getBoolean("panels." + panelName + ".item." + slot + ".hasgreater.output");
|
outputValue = cf.getBoolean("hasgreater.output");
|
||||||
}
|
}
|
||||||
int value = cf.getInt("panels." + panelName + ".item." + slot + ".hasgreater.value");
|
int value = cf.getInt("hasgreater.value");
|
||||||
double compare = Double.parseDouble(ChatColor.stripColor(papi(p,setCpPlaceholders(p,cf.getString("panels." + panelName + ".item." + slot + ".hasgreater.compare")))));
|
double compare = Double.parseDouble(ChatColor.stripColor(papi(p,setCpPlaceholders(p,cf.getString("hasgreater.compare")))));
|
||||||
if ((compare >= value) == outputValue) {
|
if ((compare >= value) == outputValue) {
|
||||||
//onOpen being 3 means it is the editor panel.. hasgreater items cannot be included to avoid item breaking
|
//onOpen being 3 means it is the editor panel.. hasgreater items cannot be included to avoid item breaking
|
||||||
return ".hasgreater";
|
String section = hasSection(Objects.requireNonNull(cf.getConfigurationSection("hasgreater")), p);
|
||||||
|
return ".hasgreater" + section;
|
||||||
}
|
}
|
||||||
//loop through possible hasgreater 1,2,3,etc
|
//loop through possible hasgreater 1,2,3,etc
|
||||||
for (int count = 0; Objects.requireNonNull(cf.getConfigurationSection("panels." + panelName + ".item." + slot)).getKeys(false).size() > count; count++) {
|
for (int count = 0; cf.getKeys(false).size() > count; count++) {
|
||||||
if (cf.contains("panels." + panelName + ".item." + slot + ".hasgreater" + count)) {
|
if (cf.contains("hasgreater" + count)) {
|
||||||
outputValue = true;
|
outputValue = true;
|
||||||
//outputValue will default to true
|
//outputValue will default to true
|
||||||
if (cf.contains("panels." + panelName + ".item." + slot + ".hasgreater" + count + ".output")) {
|
if (cf.contains("hasgreater" + count + ".output")) {
|
||||||
//if output is true, and values match it will be this item, vice versa
|
//if output is true, and values match it will be this item, vice versa
|
||||||
outputValue = cf.getBoolean("panels." + panelName + ".item." + slot + ".hasgreater" + count + ".output");
|
outputValue = cf.getBoolean("hasgreater" + count + ".output");
|
||||||
}
|
}
|
||||||
value = cf.getInt("panels." + panelName + ".item." + slot + ".hasgreater" + count + ".value");
|
value = cf.getInt("hasgreater" + count + ".value");
|
||||||
compare = Double.parseDouble(ChatColor.stripColor(papi(p,setCpPlaceholders(p,cf.getString("panels." + panelName + ".item." + slot + ".hasgreater" + count + ".compare")))));
|
compare = Double.parseDouble(ChatColor.stripColor(papi(p,setCpPlaceholders(p,cf.getString("hasgreater" + count + ".compare")))));
|
||||||
if ((compare >= value) == outputValue) {
|
if ((compare >= value) == outputValue) {
|
||||||
//onOpen being 3 means it is the editor panel.. hasgreater items cannot be included to avoid item breaking
|
//onOpen being 3 means it is the editor panel.. hasgreater items cannot be included to avoid item breaking
|
||||||
return ".hasgreater" + count;
|
String section = hasSection(Objects.requireNonNull(cf.getConfigurationSection("hasgreater" + count)), p);
|
||||||
|
return ".hasgreater" + count + section;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (cf.contains("panels." + panelName + ".item." + slot + ".hasperm")) {
|
if (cf.contains("hasperm")) {
|
||||||
//this will do hasperm with no numbers
|
//this will do hasperm with no numbers
|
||||||
boolean outputValue = true;
|
boolean outputValue = true;
|
||||||
//outputValue will default to true
|
//outputValue will default to true
|
||||||
if (cf.contains("panels." + panelName + ".item." + slot + ".hasperm" + ".output")) {
|
if (cf.contains("output")) {
|
||||||
//if output is true, and values match it will be this item, vice versa
|
//if output is true, and values match it will be this item, vice versa
|
||||||
outputValue = cf.getBoolean("panels." + panelName + ".item." + slot + ".hasperm" + ".output");
|
outputValue = cf.getBoolean("output");
|
||||||
}
|
}
|
||||||
if (p.hasPermission(Objects.requireNonNull(cf.getString("panels." + panelName + ".item." + slot + ".hasperm.perm"))) == outputValue) {
|
if (p.hasPermission(Objects.requireNonNull(cf.getString("hasperm.perm"))) == outputValue) {
|
||||||
return ".hasperm";
|
String section = hasSection(Objects.requireNonNull(cf.getConfigurationSection("hasperm")), p);
|
||||||
|
return ".hasperm" + section;
|
||||||
}
|
}
|
||||||
for(int count = 0; Objects.requireNonNull(cf.getConfigurationSection("panels." + panelName + ".item." + slot)).getKeys(false).size() > count; count++){
|
for(int count = 0; cf.getKeys(false).size() > count; count++){
|
||||||
if (cf.contains("panels." + panelName + ".item." + slot + ".hasperm" + count) && cf.contains("panels." + panelName + ".item." + slot + ".hasperm" + count + ".perm")) {
|
if (cf.contains("hasperm" + count) && cf.contains("hasperm" + count + ".perm")) {
|
||||||
outputValue = true;
|
outputValue = true;
|
||||||
//outputValue will default to true
|
//outputValue will default to true
|
||||||
if (cf.contains("panels." + panelName + ".item." + slot + ".hasperm" + count + ".output")) {
|
if (cf.contains("hasperm" + count + ".output")) {
|
||||||
//if output is true, and values match it will be this item, vice versa
|
//if output is true, and values match it will be this item, vice versa
|
||||||
outputValue = cf.getBoolean("panels." + panelName + ".item." + slot + ".hasperm" + count + ".output");
|
outputValue = cf.getBoolean("hasperm" + count + ".output");
|
||||||
}
|
}
|
||||||
if (p.hasPermission(Objects.requireNonNull(cf.getString("panels." + panelName + ".item." + slot + ".hasperm" + count + ".perm"))) == outputValue) {
|
if (p.hasPermission(Objects.requireNonNull(cf.getString("hasperm" + count + ".perm"))) == outputValue) {
|
||||||
return ".hasperm" + count;
|
String section = hasSection(Objects.requireNonNull(cf.getConfigurationSection("hasperm" + count)), p);
|
||||||
|
return ".hasperm" + count + section;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -91,6 +91,7 @@ public class newGenUtils implements Listener {
|
|||||||
File folder = new File(plugin.getDataFolder() + File.separator + "panels");
|
File folder = new File(plugin.getDataFolder() + File.separator + "panels");
|
||||||
file = YamlConfiguration.loadConfiguration(new File(folder + File.separator + date + ".yml"));
|
file = YamlConfiguration.loadConfiguration(new File(folder + File.separator + date + ".yml"));
|
||||||
file.addDefault("panels." + date + ".perm", "default");
|
file.addDefault("panels." + date + ".perm", "default");
|
||||||
|
file.addDefault("panels." + date + ".panelType", "default");
|
||||||
file.addDefault("panels." + date + ".rows", inv.getSize()/9);
|
file.addDefault("panels." + date + ".rows", inv.getSize()/9);
|
||||||
file.addDefault("panels." + date + ".title", "&8Generated " + date);
|
file.addDefault("panels." + date + ".title", "&8Generated " + date);
|
||||||
file.addDefault("panels." + date + ".command", date);
|
file.addDefault("panels." + date + ".command", date);
|
||||||
|
@ -19,9 +19,6 @@ public class commandpanelrefresher implements Listener {
|
|||||||
public commandpanelrefresher(commandpanels pl) {
|
public commandpanelrefresher(commandpanels pl) {
|
||||||
this.plugin = pl;
|
this.plugin = pl;
|
||||||
}
|
}
|
||||||
private int c = 0;
|
|
||||||
private int animatevalue = -1;
|
|
||||||
private int animatecount = 0;
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onInventoryOpen(InventoryOpenEvent e){ //Handles when Players open inventory
|
public void onInventoryOpen(InventoryOpenEvent e){ //Handles when Players open inventory
|
||||||
//I have to convert HumanEntity to a player
|
//I have to convert HumanEntity to a player
|
||||||
@ -38,7 +35,6 @@ public class commandpanelrefresher implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//get all panel names (not titles)
|
//get all panel names (not titles)
|
||||||
String tag = plugin.config.getString("config.format.tag") + " ";
|
|
||||||
YamlConfiguration cf = null;
|
YamlConfiguration cf = null;
|
||||||
String panel = null;
|
String panel = null;
|
||||||
String panelTitle = null;
|
String panelTitle = null;
|
||||||
@ -82,9 +78,11 @@ public class commandpanelrefresher implements Listener {
|
|||||||
Bukkit.getConsoleSender().sendMessage("[CommandPanels] " + p.getName() + " Opened " + panel);
|
Bukkit.getConsoleSender().sendMessage("[CommandPanels] " + p.getName() + " Opened " + panel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
assert cf != null;
|
if(cf.contains("panels." + panel + ".panelType")) {
|
||||||
if(cf.contains("panels." + panel + ".animatevalue")){
|
if (cf.getString("panels." + panel + ".panelType").equalsIgnoreCase("temporary")) {
|
||||||
animatevalue = cf.getInt("panels." + panel + ".animatevalue");
|
//do not update temporary panels, only default panels
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
final YamlConfiguration cfFinal = cf;
|
final YamlConfiguration cfFinal = cf;
|
||||||
final String fpanel = panel;
|
final String fpanel = panel;
|
||||||
@ -92,8 +90,14 @@ public class commandpanelrefresher implements Listener {
|
|||||||
ItemStack[] panelItemList = plugin.openGui(fpanel, p, cf,2, -1).getContents();
|
ItemStack[] panelItemList = plugin.openGui(fpanel, p, cf,2, -1).getContents();
|
||||||
ItemStack[] playerItemList = p.getInventory().getStorageContents();
|
ItemStack[] playerItemList = p.getInventory().getStorageContents();
|
||||||
new BukkitRunnable(){
|
new BukkitRunnable(){
|
||||||
|
int c = 0;
|
||||||
|
int animatecount = 0;
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
int animatevalue = -1;
|
||||||
|
if(cfFinal.contains("panels." + fpanel + ".animatevalue")){
|
||||||
|
animatevalue = cfFinal.getInt("panels." + fpanel + ".animatevalue");
|
||||||
|
}
|
||||||
//counter counts to refresh delay (in seconds) then restarts
|
//counter counts to refresh delay (in seconds) then restarts
|
||||||
if(c < Double.parseDouble(Objects.requireNonNull(plugin.config.getString("config.refresh-delay")).trim())){
|
if(c < Double.parseDouble(Objects.requireNonNull(plugin.config.getString("config.refresh-delay")).trim())){
|
||||||
c+=1;
|
c+=1;
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package me.rockyhawk.commandPanels;
|
package me.rockyhawk.commandPanels;
|
||||||
|
|
||||||
import org.bukkit.*;
|
import org.bukkit.*;
|
||||||
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
@ -89,7 +90,7 @@ public class utils implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//loop through possible hasvalue/hasperm 1,2,3,etc
|
//loop through possible hasvalue/hasperm 1,2,3,etc
|
||||||
String section = plugin.hasSection(panel, cf, e.getSlot(),p);
|
String section = plugin.hasSection(cf.getConfigurationSection("panels." + panel + ".item." + e.getSlot()), p);
|
||||||
//this will remove any pending user inputs, if there is already something there from a previous item
|
//this will remove any pending user inputs, if there is already something there from a previous item
|
||||||
for(int o = 0; plugin.userInputStrings.size() > o; o++){
|
for(int o = 0; plugin.userInputStrings.size() > o; o++){
|
||||||
if(plugin.userInputStrings.get(o)[0].equals(p.getName())){
|
if(plugin.userInputStrings.get(o)[0].equals(p.getName())){
|
||||||
@ -198,13 +199,26 @@ public class utils implements Listener {
|
|||||||
p.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.nopanel")));
|
p.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.nopanel")));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
boolean forced = false;
|
||||||
if(cf.contains("panels." + panel + ".item." + slot + section + ".redirect.force")){
|
if(cf.contains("panels." + panel + ".item." + slot + section + ".redirect.force")){
|
||||||
//this will force the panel open without consideration of permissions, world, etc
|
//this will force the panel open without consideration of permissions, world, etc
|
||||||
if(cf.getBoolean("panels." + panel + ".item." + slot + section + ".redirect.force")){
|
if(cf.getBoolean("panels." + panel + ".item." + slot + section + ".redirect.force")){
|
||||||
|
forced = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(cf.contains("panels." + panel + ".item." + slot + section + ".redirect.replacements")){
|
||||||
|
if(!panelConfig.getString("panels." + panelName + ".panelType").equalsIgnoreCase("temporary") && plugin.config.getBoolean("config.refresh-panels")){
|
||||||
|
p.sendMessage(plugin.papi(tag + ChatColor.RED + panelName + " panel type needs to be temporary to replace elements."));
|
||||||
|
}
|
||||||
|
for(String sectionName : cf.getConfigurationSection("panels." + panel + ".item." + slot + section + ".redirect.replacements").getKeys(false)){
|
||||||
|
ConfigurationSection temp = cf.getConfigurationSection("panels." + panel + ".item." + slot + section + ".redirect.replacements." + sectionName);
|
||||||
|
panelConfig.set("panels." + panelName + ".item." + sectionName, temp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(forced){
|
||||||
plugin.openGui(panelName, p, panelConfig, 1, 0);
|
plugin.openGui(panelName, p, panelConfig, 1, 0);
|
||||||
return;
|
}else{
|
||||||
}
|
|
||||||
}
|
|
||||||
plugin.openCommandPanel(p, p, panelName, panelConfig, false);
|
plugin.openCommandPanel(p, p, panelName, panelConfig, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user