forked from Upstream/CommandPanels
v3.15.0.0
This commit is contained in:
parent
be52c1fa9d
commit
afa91269cd
@ -11,8 +11,8 @@ config:
|
||||
ingame-editor: true
|
||||
hotbar-items: true
|
||||
custom-commands: true
|
||||
auto-register-commands: true
|
||||
refresh-delay: 4
|
||||
auto-register-commands: false
|
||||
refresh-delay: 20
|
||||
server-ping-timeout: 10
|
||||
stop-sound: true
|
||||
disabled-world-message: true
|
||||
|
@ -1,4 +1,4 @@
|
||||
version: 3.14.6.0
|
||||
version: 3.15.0.0
|
||||
main: me.rockyhawk.commandpanels.CommandPanels
|
||||
name: CommandPanels
|
||||
author: RockyHawk
|
||||
|
@ -8,6 +8,7 @@ import java.util.regex.Pattern;
|
||||
|
||||
import me.clip.placeholderapi.PlaceholderAPI;
|
||||
import me.rockyhawk.commandpanels.api.CommandPanelsAPI;
|
||||
import me.rockyhawk.commandpanels.api.Panel;
|
||||
import me.rockyhawk.commandpanels.classresources.*;
|
||||
import me.rockyhawk.commandpanels.commands.*;
|
||||
import me.rockyhawk.commandpanels.completetabs.CpTabComplete;
|
||||
@ -29,6 +30,7 @@ import me.rockyhawk.commandpanels.legacy.LegacyVersion;
|
||||
import me.rockyhawk.commandpanels.legacy.PlayerHeads;
|
||||
import me.rockyhawk.commandpanels.openpanelsmanager.OpenGUI;
|
||||
import me.rockyhawk.commandpanels.openpanelsmanager.OpenPanelsLoader;
|
||||
import me.rockyhawk.commandpanels.openpanelsmanager.PanelPermissions;
|
||||
import me.rockyhawk.commandpanels.openpanelsmanager.UtilsPanelsLoader;
|
||||
import me.rockyhawk.commandpanels.openwithitem.HotbarItemLoader;
|
||||
import me.rockyhawk.commandpanels.openwithitem.SwapItemEvent;
|
||||
@ -65,14 +67,13 @@ public class CommandPanels extends JavaPlugin {
|
||||
public List<Player> generateMode = new ArrayList<>(); //players that are currently in generate mode
|
||||
public List<String[]> userInputStrings = new ArrayList<>();
|
||||
public List<String[]> editorInputStrings = new ArrayList<>();
|
||||
public List<String> panelFiles = new ArrayList<>(); //names of all the files in the panels folder including extension
|
||||
public List<String[]> panelNames = new ArrayList<>(); //this will return something like {"mainMenuPanel","4"} which means the 4 is for panelFiles.get(4). So you know which file it is for
|
||||
public List<Panel> panelList = new ArrayList<>(); //contains all the panels that are included in the panels folder
|
||||
|
||||
//get alternate classes
|
||||
public CommandPanelsAPI api = new CommandPanelsAPI(this);
|
||||
public CommandTags commandTags = new CommandTags(this);
|
||||
public PanelDataLoader panelData = new PanelDataLoader(this);
|
||||
public Placeholders placeholders = new Placeholders(this);
|
||||
|
||||
public OpenEditorGuis editorGuis = new OpenEditorGuis(this);
|
||||
public ExecuteOpenVoids openVoids = new ExecuteOpenVoids(this);
|
||||
public ItemCreation itemCreate = new ItemCreation(this);
|
||||
@ -80,8 +81,10 @@ public class CommandPanels extends JavaPlugin {
|
||||
public Updater updater = new Updater(this);
|
||||
public PlayerHeads getHeads = new PlayerHeads(this);
|
||||
public LegacyVersion legacy = new LegacyVersion(this);
|
||||
|
||||
public OpenPanelsLoader openPanels = new OpenPanelsLoader(this);
|
||||
public OpenGUI createGUI = new OpenGUI(this);
|
||||
public PanelPermissions panelPerms = new PanelPermissions(this);
|
||||
public CommandPlaceholderLoader customCommand = new CommandPlaceholderLoader(this);
|
||||
public HotbarItemLoader hotbar = new HotbarItemLoader(this);
|
||||
|
||||
@ -210,7 +213,7 @@ public class CommandPanels extends JavaPlugin {
|
||||
@Override
|
||||
public Integer call() throws Exception {
|
||||
//this is the total panels loaded
|
||||
return panelNames.size();
|
||||
return panelList.size();
|
||||
}
|
||||
}));
|
||||
|
||||
@ -228,6 +231,10 @@ public class CommandPanels extends JavaPlugin {
|
||||
Bukkit.getLogger().info("RockyHawk's CommandPanels Plugin Disabled, aww man.");
|
||||
}
|
||||
|
||||
public static CommandPanelsAPI getAPI(){
|
||||
return new CommandPanelsAPI(JavaPlugin.getPlugin(CommandPanels.class));
|
||||
}
|
||||
|
||||
public void setName(ItemStack renamed, String customName, List<String> lore, Player p, Boolean usePlaceholders, Boolean useColours, Boolean hideAttributes) {
|
||||
try {
|
||||
ItemMeta renamedMeta = renamed.getItemMeta();
|
||||
@ -377,8 +384,8 @@ public class CommandPanels extends JavaPlugin {
|
||||
//check for duplicate panel names
|
||||
public boolean checkDuplicatePanel(CommandSender sender){
|
||||
ArrayList<String> apanels = new ArrayList<>();
|
||||
for(String[] panelName : panelNames){
|
||||
apanels.add(panelName[0]);
|
||||
for(Panel panel : panelList){
|
||||
apanels.add(panel.getName());
|
||||
}
|
||||
|
||||
//names is a list of the titles for the Panels
|
||||
@ -414,9 +421,8 @@ public class CommandPanels extends JavaPlugin {
|
||||
this.getServer().getConsoleSender().sendMessage("[CommandPanels]" + ChatColor.RED + " Error in: " + fileName);
|
||||
continue;
|
||||
}
|
||||
panelFiles.add((directory + File.separator + fileName).replace(panelsf.toString() + File.separator,""));
|
||||
for (String tempName : Objects.requireNonNull(YamlConfiguration.loadConfiguration(new File(directory + File.separator + fileName)).getConfigurationSection("panels")).getKeys(false)) {
|
||||
panelNames.add(new String[]{tempName, Integer.toString(panelFiles.size()-1)});
|
||||
panelList.add(new Panel(new File((directory + File.separator + fileName)),tempName));
|
||||
if(YamlConfiguration.loadConfiguration(new File(directory + File.separator + fileName)).contains("panels." + tempName + ".open-with-item")) {
|
||||
openWithItem = true;
|
||||
}
|
||||
@ -425,8 +431,7 @@ public class CommandPanels extends JavaPlugin {
|
||||
}
|
||||
|
||||
public void reloadPanelFiles() {
|
||||
panelFiles.clear();
|
||||
panelNames.clear();
|
||||
panelList.clear();
|
||||
openWithItem = false;
|
||||
//load panel files
|
||||
fileNamesFromDirectory(panelsf);
|
||||
|
@ -1,12 +1,13 @@
|
||||
package me.rockyhawk.commandpanels.api;
|
||||
|
||||
import me.rockyhawk.commandpanels.CommandPanels;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class CommandPanelsAPI {
|
||||
CommandPanels plugin;
|
||||
@ -20,22 +21,46 @@ public class CommandPanelsAPI {
|
||||
}
|
||||
|
||||
//get the name of a panel currently open, will return null if panel is not open
|
||||
public String getPanelName(Player p){
|
||||
return plugin.openPanels.getOpenPanelName(p.getName());
|
||||
public Panel getOpenPanel(Player p){
|
||||
return new Panel(plugin.openPanels.getOpenPanel(p.getName()),plugin.openPanels.getOpenPanelName(p.getName()));
|
||||
}
|
||||
|
||||
//loaded panels in folder
|
||||
public List<Panel> getPanelsLoaded(){
|
||||
return plugin.panelList;
|
||||
}
|
||||
|
||||
//import panel into folder
|
||||
public void addPanel(Panel panel) throws IOException{
|
||||
File addedFile = new File(plugin.panelsf + File.separator + panel.getFile().getName());
|
||||
YamlConfiguration addedYaml = new YamlConfiguration();
|
||||
addedYaml.set("panels." + panel.getName(), panel.getConfig());
|
||||
addedYaml.save(addedFile);
|
||||
}
|
||||
|
||||
//remove panel from folder
|
||||
public void removePanel(Panel panel){
|
||||
for(Panel panels : plugin.panelList){
|
||||
if(panels.getName().equals(panel.getName())){
|
||||
if(panels.getFile().delete()){
|
||||
plugin.reloadPanelFiles();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//get panel from folder
|
||||
public Panel getPanel(String panelName){
|
||||
for(Panel panel : plugin.panelList) {
|
||||
if(panel.getName().equals(panelName)) {
|
||||
return panel;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
//will return item slots of hotbar stationary items
|
||||
public ArrayList<Integer> getHotbarItems(){
|
||||
public Set<Integer> getHotbarItems(){
|
||||
return plugin.hotbar.getStationaryItemSlots();
|
||||
}
|
||||
|
||||
//open a panel using a custom file or configuration
|
||||
public void openGUI(Player p, YamlConfiguration panelYaml, String panelName){
|
||||
ConfigurationSection panelSection = panelYaml.getConfigurationSection("panels." + panelName);
|
||||
plugin.openVoids.openCommandPanel(plugin.getServer().getConsoleSender(), p, panelName, panelSection, false);
|
||||
}
|
||||
public void openGUI(Player p, File panelFile, String panelName){
|
||||
ConfigurationSection panelSection = YamlConfiguration.loadConfiguration(panelFile).getConfigurationSection("panels." + panelName);
|
||||
plugin.openVoids.openCommandPanel(plugin.getServer().getConsoleSender(), p, panelName, panelSection, false);
|
||||
}
|
||||
}
|
88
src/me/rockyhawk/commandpanels/api/Panel.java
Normal file
88
src/me/rockyhawk/commandpanels/api/Panel.java
Normal file
@ -0,0 +1,88 @@
|
||||
package me.rockyhawk.commandpanels.api;
|
||||
|
||||
import me.rockyhawk.commandpanels.CommandPanels;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class Panel{
|
||||
CommandPanels plugin = JavaPlugin.getPlugin(CommandPanels.class);
|
||||
/*This is the PanelConfig object*/
|
||||
|
||||
private ConfigurationSection panelConfig;
|
||||
private String panelName;
|
||||
private File panelFile;
|
||||
|
||||
//make the object, using a file is recommended
|
||||
public Panel(File file, String name){
|
||||
this.panelName = name;
|
||||
this.panelFile = file;
|
||||
this.panelConfig = YamlConfiguration.loadConfiguration(file).getConfigurationSection("panels." + name);
|
||||
}
|
||||
public Panel(ConfigurationSection config, String name){
|
||||
if(config.contains("panels")){
|
||||
config = config.getConfigurationSection("panels." + name);
|
||||
}
|
||||
this.panelName = name;
|
||||
this.panelConfig = config;
|
||||
}
|
||||
public Panel(String name){
|
||||
this.panelName = name;
|
||||
}
|
||||
|
||||
//set elements of the panel
|
||||
public void setName(String name){
|
||||
this.panelName = name;
|
||||
}
|
||||
public void setConfig(ConfigurationSection config){
|
||||
if(config.contains("panels")){
|
||||
config = config.getConfigurationSection("panels." + this.panelName);
|
||||
}
|
||||
this.panelConfig = config;
|
||||
}
|
||||
public void setFile(File file){
|
||||
this.panelFile = file;
|
||||
this.panelConfig = YamlConfiguration.loadConfiguration(file).getConfigurationSection("panels." + this.getName());
|
||||
}
|
||||
|
||||
//get elements of the panel
|
||||
public String getName(){
|
||||
return this.panelName;
|
||||
}
|
||||
|
||||
public ConfigurationSection getConfig(){
|
||||
return this.panelConfig;
|
||||
}
|
||||
|
||||
public File getFile(){
|
||||
return this.panelFile;
|
||||
}
|
||||
|
||||
public ItemStack getItem(Player p, int slot){
|
||||
ConfigurationSection itemSection = panelConfig.getConfigurationSection("item." + slot);
|
||||
return plugin.itemCreate.makeItemFromConfig(itemSection, p, true, true, false);
|
||||
}
|
||||
|
||||
public ItemStack getCustomItem(Player p, String itemName){
|
||||
ConfigurationSection itemSection = panelConfig.getConfigurationSection("custom-item." + itemName);
|
||||
return plugin.itemCreate.makeCustomItemFromConfig(itemSection, p, true, true, false);
|
||||
}
|
||||
|
||||
public ItemStack getHotbarItem(Player p){
|
||||
ConfigurationSection itemSection = panelConfig.getConfigurationSection("open-with-item");
|
||||
return plugin.itemCreate.makeItemFromConfig(itemSection, p, true, true, false);
|
||||
}
|
||||
|
||||
public boolean hasHotbarItem(){
|
||||
return this.panelConfig.contains("open-with-item");
|
||||
}
|
||||
|
||||
//open the panel for the player
|
||||
public void open(Player p){
|
||||
plugin.openVoids.openCommandPanel(p, p, this.panelName, this.panelConfig, false);
|
||||
}
|
||||
}
|
@ -6,7 +6,6 @@ import org.bukkit.event.HandlerList;
|
||||
|
||||
public class PanelCommandEvent extends Event {
|
||||
|
||||
private boolean isCancelled;
|
||||
private Player p;
|
||||
private String args;
|
||||
|
||||
|
@ -5,13 +5,13 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
|
||||
public class PanelOpenedEvent extends Event implements Cancellable {
|
||||
|
||||
private boolean isCancelled;
|
||||
private Player p;
|
||||
private ConfigurationSection cf;
|
||||
private String name;
|
||||
private Panel panel;
|
||||
|
||||
public boolean isCancelled() {
|
||||
return this.isCancelled;
|
||||
@ -23,20 +23,19 @@ public class PanelOpenedEvent extends Event implements Cancellable {
|
||||
|
||||
public PanelOpenedEvent(Player player, ConfigurationSection panelConfig, String panelName) {
|
||||
this.p = player;
|
||||
this.cf = panelConfig;
|
||||
this.name = panelName;
|
||||
this.panel = new Panel(panelConfig,panelName);
|
||||
}
|
||||
|
||||
public Player getPlayer(){
|
||||
return this.p;
|
||||
}
|
||||
|
||||
public ConfigurationSection getPanelConfig(){
|
||||
return this.cf;
|
||||
public Inventory getInventory(){
|
||||
return this.p.getInventory();
|
||||
}
|
||||
|
||||
public String getPanelName(){
|
||||
return this.name;
|
||||
public Panel getPanel(){
|
||||
return this.panel;
|
||||
}
|
||||
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
|
@ -4,17 +4,16 @@ import com.google.common.io.ByteArrayDataOutput;
|
||||
import com.google.common.io.ByteStreams;
|
||||
import me.realized.tokenmanager.api.TokenManager;
|
||||
import me.rockyhawk.commandpanels.CommandPanels;
|
||||
import me.rockyhawk.commandpanels.api.Panel;
|
||||
import me.rockyhawk.commandpanels.api.PanelCommandEvent;
|
||||
import org.apache.commons.lang.ArrayUtils;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.PotionMeta;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
|
||||
@ -115,13 +114,12 @@ 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);
|
||||
for(Panel panel : plugin.panelList){
|
||||
if(panel.getName().equals(panelName)){
|
||||
if(plugin.openPanels.hasPanelOpen(p.getName())) {
|
||||
plugin.openPanels.skipPanels.add(p.getName());
|
||||
}
|
||||
plugin.openVoids.openCommandPanel(p,p,panelName,panelConfig,false);
|
||||
panel.open(p);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -21,28 +21,17 @@ public class ExecuteOpenVoids {
|
||||
}
|
||||
|
||||
//this is the main method to open a panel
|
||||
public void openCommandPanel(CommandSender sender, Player p, String panelName, ConfigurationSection cf, boolean sendOpenedMessage){
|
||||
public void openCommandPanel(CommandSender sender, Player p, String panelName, ConfigurationSection cf, boolean openForOtherUser){
|
||||
if(p.isSleeping()){
|
||||
//avoid plugin glitches when sleeping
|
||||
return;
|
||||
}
|
||||
if (sender.hasPermission("commandpanel.panel." + cf.getString("perm"))) {
|
||||
//if the sender has OTHER perms, or if sendOpenedMessage is false, implying it is not for another person
|
||||
if(sender.hasPermission("commandpanel.other") || !sendOpenedMessage) {
|
||||
try {
|
||||
if (cf.contains("disabled-worlds")) {
|
||||
List<String> disabledWorlds = cf.getStringList("disabled-worlds");
|
||||
if (disabledWorlds.contains(p.getWorld().getName())) {
|
||||
//panel cannot be used in the players world!
|
||||
if (Objects.requireNonNull(plugin.config.getString("config.disabled-world-message")).equalsIgnoreCase("true")) {
|
||||
sender.sendMessage(plugin.papi(plugin.tag + ChatColor.RED + "Panel is disabled in the world!"));
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}catch(NullPointerException offlinePlayer){
|
||||
//SKIP because player is offline
|
||||
sender.sendMessage(plugin.papi(plugin.tag + plugin.config.getString("config.format.notitem")));
|
||||
if(sender.hasPermission("commandpanel.other") || !openForOtherUser) {
|
||||
//check for disabled worlds
|
||||
if(!plugin.panelPerms.isPanelWorldEnabled(p,cf)){
|
||||
sender.sendMessage(plugin.papi(plugin.tag + plugin.config.getString("config.format.perms")));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -95,7 +84,7 @@ public class ExecuteOpenVoids {
|
||||
|
||||
//create and open the GUI
|
||||
plugin.createGUI.openGui(panelName, p, cf,1,0);
|
||||
if(sendOpenedMessage) {
|
||||
if(openForOtherUser) {
|
||||
sender.sendMessage(plugin.papi( plugin.tag + ChatColor.GREEN + "Panel Opened for " + p.getDisplayName()));
|
||||
}
|
||||
} catch (Exception r) {
|
||||
@ -113,22 +102,12 @@ public class ExecuteOpenVoids {
|
||||
//this will give a hotbar item to a player
|
||||
public void giveHotbarItem(CommandSender sender, Player p, ConfigurationSection cf, boolean sendGiveMessage){
|
||||
if (sender.hasPermission("commandpanel.item." + cf.getString("perm")) && cf.contains("open-with-item")) {
|
||||
try {
|
||||
if (cf.contains("disabled-worlds")) {
|
||||
List<String> disabledWorlds = cf.getStringList("disabled-worlds");
|
||||
if (disabledWorlds.contains(p.getWorld().getName())) {
|
||||
//panel cannot be used in the players world!
|
||||
if (Objects.requireNonNull(plugin.config.getString("config.disabled-world-message")).equalsIgnoreCase("true")) {
|
||||
sender.sendMessage(plugin.papi(plugin.tag + ChatColor.RED + "Panel is disabled in the world!"));
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}catch(NullPointerException offlinePlayer){
|
||||
//SKIP because player is offline
|
||||
sender.sendMessage(plugin.papi(plugin.tag + plugin.config.getString("config.format.notitem")));
|
||||
//check for disabled worlds
|
||||
if(!plugin.panelPerms.isPanelWorldEnabled(p,cf)){
|
||||
sender.sendMessage(plugin.papi(plugin.tag + plugin.config.getString("config.format.perms")));
|
||||
return;
|
||||
}
|
||||
|
||||
ItemStack s;
|
||||
try {
|
||||
s = plugin.itemCreate.makeItemFromConfig(Objects.requireNonNull(cf.getConfigurationSection("open-with-item")), p, false, true, false);
|
||||
|
@ -355,7 +355,6 @@ public class ItemCreation {
|
||||
return plugin.itemCreate.makeItemFromConfig(itemSection, p, placeholders, colours, addNBT);
|
||||
}
|
||||
|
||||
|
||||
//hasperm hasvalue, etc sections will be done here
|
||||
public String hasSection(ConfigurationSection cf, Player p){
|
||||
if (cf.contains("hasvalue")) {
|
||||
@ -570,7 +569,7 @@ public class ItemCreation {
|
||||
}
|
||||
} catch (Exception ignore) {}
|
||||
//check for enchantments
|
||||
if(one.getEnchantments().equals(two.getEnchantments())){
|
||||
if(one.getEnchantments() == two.getEnchantments()){
|
||||
if(!one.getEnchantments().isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
@ -1,16 +1,15 @@
|
||||
package me.rockyhawk.commandpanels.classresources;
|
||||
|
||||
import me.rockyhawk.commandpanels.CommandPanels;
|
||||
import me.rockyhawk.commandpanels.api.Panel;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
@ -27,23 +26,15 @@ public class OpenEditorGuis {
|
||||
ArrayList<String> panelTitles = new ArrayList<>(); //all panels from ALL files (panel titles)
|
||||
ArrayList<ItemStack> panelItems = new ArrayList<>(); //all panels from ALL files (panel materials)
|
||||
try {
|
||||
for(String fileName : plugin.panelFiles) { //will loop through all the files in folder
|
||||
YamlConfiguration temp = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + fileName));
|
||||
String key;
|
||||
if (!plugin.checkPanels(temp)) {
|
||||
continue;
|
||||
}
|
||||
for (String s : Objects.requireNonNull(temp.getConfigurationSection("panels")).getKeys(false)) {
|
||||
key = s;
|
||||
panelNames.add(plugin.papi( key));
|
||||
panelTitles.add(plugin.papi( Objects.requireNonNull(temp.getString("panels." + key + ".title"))));
|
||||
if (temp.contains("panels." + key + ".open-with-item.material")) {
|
||||
panelItems.add(plugin.itemCreate.makeItemFromConfig(temp.getConfigurationSection("panels." + key + ".open-with-item"), p, false, true, false));
|
||||
for(Panel panel : plugin.panelList) { //will loop through all the files in folder
|
||||
panelNames.add(plugin.papi(panel.getName()));
|
||||
panelTitles.add(plugin.papi(panel.getConfig().getString("title")));
|
||||
if (panel.getConfig().contains("open-with-item.material")) {
|
||||
panelItems.add(panel.getHotbarItem(p));
|
||||
} else {
|
||||
panelItems.add(new ItemStack(Material.PAPER));
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception fail) {
|
||||
//could not fetch all panel names (probably no panels exist)
|
||||
plugin.debug(fail);
|
||||
|
@ -139,6 +139,12 @@ public class Placeholders {
|
||||
boolean isIdentical = false;
|
||||
ItemStack itm = p.getOpenInventory().getTopInventory().getItem(matSlot);
|
||||
|
||||
if(itm == null){
|
||||
//continue if material is null
|
||||
str = str.replace(str.substring(start, end) + "%", String.valueOf(false));
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
//if it is a regular custom item
|
||||
ItemStack confItm = plugin.itemCreate.makeItemFromConfig(plugin.openPanels.getOpenPanel(p.getName()).getConfigurationSection("custom-item." + matLoc),p,true,true, false);
|
||||
|
@ -1,17 +1,14 @@
|
||||
package me.rockyhawk.commandpanels.commands;
|
||||
|
||||
import me.rockyhawk.commandpanels.CommandPanels;
|
||||
import me.rockyhawk.commandpanels.api.Panel;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class Commandpanel implements CommandExecutor {
|
||||
CommandPanels plugin;
|
||||
|
||||
@ -21,14 +18,12 @@ public class Commandpanel implements CommandExecutor {
|
||||
|
||||
@EventHandler
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
ConfigurationSection cf = null; //this is the file to use for any panel.* requests
|
||||
String panelName = "";
|
||||
//below is going to go through the files and find the right one
|
||||
Panel panel = null;
|
||||
if (args.length != 0) { //check to make sure the person hasn't just left it empty
|
||||
for(String[] panels : plugin.panelNames){
|
||||
if(panels[0].equals(args[0])) {
|
||||
cf = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + plugin.panelFiles.get(Integer.parseInt(panels[1])))).getConfigurationSection("panels." + panels[0]);
|
||||
panelName = panels[0];
|
||||
for(Panel tempPanel : plugin.panelList){
|
||||
if(tempPanel.getName().equals(args[0])) {
|
||||
panel = tempPanel;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -36,13 +31,13 @@ public class Commandpanel implements CommandExecutor {
|
||||
plugin.helpMessage(sender);
|
||||
return true;
|
||||
}
|
||||
if(cf == null){
|
||||
if(panel == null){
|
||||
sender.sendMessage(plugin.papi(plugin.tag + plugin.config.getString("config.format.nopanel")));
|
||||
return true;
|
||||
}
|
||||
boolean disableCommand = false;
|
||||
if(cf.contains("panelType")) {
|
||||
if (cf.getStringList("panelType").contains("nocommand")) {
|
||||
if(panel.getConfig().contains("panelType")) {
|
||||
if (panel.getConfig().getStringList("panelType").contains("nocommand")) {
|
||||
//do not allow command with noCommand
|
||||
disableCommand = true;
|
||||
}
|
||||
@ -57,7 +52,7 @@ public class Commandpanel implements CommandExecutor {
|
||||
plugin.openPanels.skipPanels.add(plugin.getServer().getPlayer(args[1]).getName());
|
||||
}
|
||||
if(!disableCommand) {
|
||||
plugin.openVoids.openCommandPanel(sender, plugin.getServer().getPlayer(args[1]), panelName, cf, true);
|
||||
plugin.openVoids.openCommandPanel(sender, plugin.getServer().getPlayer(args[1]), panel.getName(), panel.getConfig(), true);
|
||||
}
|
||||
}else{
|
||||
sender.sendMessage(plugin.papi(plugin.tag + ChatColor.RED + "Usage: /cp <panel> [item] [player]"));
|
||||
@ -65,7 +60,7 @@ public class Commandpanel implements CommandExecutor {
|
||||
return true;
|
||||
}else if(args.length == 3){
|
||||
if (args[1].equals("item")) {
|
||||
plugin.openVoids.giveHotbarItem(sender,plugin.getServer().getPlayer(args[2]),cf,true);
|
||||
plugin.openVoids.giveHotbarItem(sender,plugin.getServer().getPlayer(args[2]),panel.getConfig(),true);
|
||||
}else{
|
||||
sender.sendMessage(plugin.papi(plugin.tag + ChatColor.RED + "Usage: /cp <panel> item [player]"));
|
||||
}
|
||||
@ -83,23 +78,23 @@ public class Commandpanel implements CommandExecutor {
|
||||
plugin.openPanels.skipPanels.add(p.getName());
|
||||
}
|
||||
if(!disableCommand) {
|
||||
plugin.openVoids.openCommandPanel(sender, p, panelName, cf, false);
|
||||
plugin.openVoids.openCommandPanel(sender, p, panel.getName(), panel.getConfig(), false);
|
||||
}
|
||||
return true;
|
||||
}else if(args.length == 2){
|
||||
if (args[1].equals("item")) {
|
||||
plugin.openVoids.giveHotbarItem(sender, p, cf, false);
|
||||
plugin.openVoids.giveHotbarItem(sender, p, panel.getConfig(), false);
|
||||
}else{
|
||||
if(plugin.openPanels.hasPanelOpen(plugin.getServer().getPlayer(args[1]).getName())) {
|
||||
plugin.openPanels.skipPanels.add(plugin.getServer().getPlayer(args[1]).getName());
|
||||
}
|
||||
if(!disableCommand) {
|
||||
plugin.openVoids.openCommandPanel(sender, plugin.getServer().getPlayer(args[1]), panelName, cf, true);
|
||||
plugin.openVoids.openCommandPanel(sender, plugin.getServer().getPlayer(args[1]), panel.getName(), panel.getConfig(), true);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}else if(args.length == 3){
|
||||
plugin.openVoids.giveHotbarItem(sender, plugin.getServer().getPlayer(args[2]), cf,true);
|
||||
plugin.openVoids.giveHotbarItem(sender, plugin.getServer().getPlayer(args[2]), panel.getConfig(),true);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -1,16 +1,14 @@
|
||||
package me.rockyhawk.commandpanels.commands;
|
||||
|
||||
import me.rockyhawk.commandpanels.CommandPanels;
|
||||
import me.rockyhawk.commandpanels.api.Panel;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
|
||||
|
||||
public class Commandpanelslist implements CommandExecutor {
|
||||
@ -24,7 +22,7 @@ public class Commandpanelslist implements CommandExecutor {
|
||||
//command /cpl
|
||||
//check to make sure the panels isn't empty
|
||||
try {
|
||||
if (plugin.panelFiles == null) {
|
||||
if (plugin.panelList == null) {
|
||||
sender.sendMessage(plugin.papi(plugin.tag + ChatColor.RED + "No panels found!"));
|
||||
return true;
|
||||
}
|
||||
@ -32,52 +30,26 @@ public class Commandpanelslist implements CommandExecutor {
|
||||
sender.sendMessage(plugin.papi(plugin.tag + ChatColor.RED + "No panels found!"));
|
||||
return true;
|
||||
}
|
||||
ArrayList<String> apanels = new ArrayList<String>(); //all panels from all files (panel names)
|
||||
String tpanels; //tpanels is the temp to check through the files
|
||||
for (int f = 0; plugin.panelFiles.size() > f; f++) { //will loop through all the files in folder
|
||||
String key;
|
||||
YamlConfiguration temp;
|
||||
tpanels = "";
|
||||
temp = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + plugin.panelFiles.get(f)));
|
||||
apanels.add("%file%" + plugin.panelFiles.get(f));
|
||||
if(!plugin.checkPanels(temp)){
|
||||
apanels.add("Error Reading File!");
|
||||
continue;
|
||||
}
|
||||
for (Iterator var10 = temp.getConfigurationSection("panels").getKeys(false).iterator(); var10.hasNext(); tpanels = tpanels + key + " ") {
|
||||
key = (String) var10.next();
|
||||
apanels.add(key);
|
||||
}
|
||||
}
|
||||
|
||||
ArrayList<Panel> panels = new ArrayList<>(plugin.panelList);
|
||||
int page = 1;
|
||||
int skip = 0;
|
||||
if(args.length == 1){
|
||||
try {
|
||||
page = Integer.parseInt(args[0]);
|
||||
skip = page*9-9;
|
||||
skip = page*8-8;
|
||||
}catch (Exception e){
|
||||
sender.sendMessage(plugin.papi(plugin.tag + ChatColor.RED + "Inaccessible Page"));
|
||||
}
|
||||
}
|
||||
for (int f = skip; apanels.size() > f; f++) {
|
||||
if(!apanels.get(f).contains("%file%")){
|
||||
skip++;
|
||||
}else{
|
||||
break;
|
||||
}
|
||||
}
|
||||
sender.sendMessage(plugin.papi(plugin.tag + ChatColor.DARK_AQUA + "Panels: (Page " + page + ")"));
|
||||
for (int f = skip; apanels.size() > f; f++) {
|
||||
if(apanels.get(f).contains("%file%")){
|
||||
if(skip+9 <= f){
|
||||
for (int f = skip; panels.size() > f && skip+8 > f; f++) {
|
||||
sender.sendMessage(ChatColor.DARK_GREEN + panels.get(f).getFile().getAbsolutePath().replace(plugin.panelsf.getAbsolutePath(),"") + ChatColor.GREEN + " " + panels.get(f).getName());
|
||||
if(panels.size()-1 == f){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
sender.sendMessage(ChatColor.AQUA + "Type /cpl " + (page+1) + " to read next page");
|
||||
break;
|
||||
}
|
||||
sender.sendMessage(ChatColor.DARK_GREEN + apanels.get(f).replaceAll("%file%",""));
|
||||
}else{
|
||||
sender.sendMessage(ChatColor.GREEN + "- " + apanels.get(f));
|
||||
}
|
||||
}
|
||||
}else{
|
||||
sender.sendMessage(plugin.papi(plugin.tag + plugin.config.getString("config.format.perms")));
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package me.rockyhawk.commandpanels.commands;
|
||||
|
||||
import me.rockyhawk.commandpanels.CommandPanels;
|
||||
import me.rockyhawk.commandpanels.api.Panel;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
@ -74,17 +75,15 @@ public class Commandpanelsreload implements CommandExecutor {
|
||||
ArrayList<String> temp = new ArrayList<>();
|
||||
temp.add("commandpanel");
|
||||
|
||||
for (String[] panelName : plugin.panelNames) {
|
||||
tempFile = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + plugin.panelFiles.get(Integer.parseInt(panelName[1])))).getConfigurationSection("panels." + panelName[0]);
|
||||
|
||||
if(tempFile.contains("panelType")){
|
||||
if(tempFile.getStringList("panelType").contains("nocommandregister")){
|
||||
for (Panel panel : plugin.panelList) {
|
||||
if(panel.getConfig().contains("panelType")){
|
||||
if(panel.getConfig().getStringList("panelType").contains("nocommandregister")){
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if(tempFile.contains("commands")){
|
||||
List<String> panelCommands = tempFile.getStringList("commands");
|
||||
if(panel.getConfig().contains("commands")){
|
||||
List<String> panelCommands = panel.getConfig().getStringList("commands");
|
||||
for(String command : panelCommands){
|
||||
cmdCF.set("aliases." + command.split("\\s")[0],temp);
|
||||
}
|
||||
|
@ -1,15 +1,13 @@
|
||||
package me.rockyhawk.commandpanels.completetabs;
|
||||
|
||||
import me.rockyhawk.commandpanels.CommandPanels;
|
||||
import me.rockyhawk.commandpanels.api.Panel;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@ -22,43 +20,27 @@ public class CpTabComplete implements TabCompleter {
|
||||
Player p = ((Player) sender).getPlayer();
|
||||
if(label.equalsIgnoreCase("cp") || label.equalsIgnoreCase("cpanel") || label.equalsIgnoreCase("commandpanel")){
|
||||
ArrayList<String> apanels = new ArrayList<String>(); //all panels
|
||||
String tpanels; //tpanels is the temp to check through the files
|
||||
for(String fileName : plugin.panelFiles) { //will loop through all the files in folder
|
||||
for(Panel panel : plugin.panelList) { //will loop through all the files in folder
|
||||
try {
|
||||
YamlConfiguration temp = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + fileName));
|
||||
String key;
|
||||
tpanels = "";
|
||||
if (!plugin.checkPanels(temp)) {
|
||||
continue;
|
||||
}
|
||||
for (Iterator var10 = temp.getConfigurationSection("panels").getKeys(false).iterator(); var10.hasNext(); tpanels = tpanels + key + " ") {
|
||||
key = (String) var10.next();
|
||||
if (!key.startsWith(args[0])) {
|
||||
if (!panel.getName().startsWith(args[0])) {
|
||||
//this will narrow down the panels to what the user types
|
||||
continue;
|
||||
}
|
||||
if (sender.hasPermission("commandpanel.panel." + temp.getString("panels." + key + ".perm"))) {
|
||||
if(temp.contains("panels." + key + ".panelType")) {
|
||||
if (temp.getStringList("panels." + key + ".panelType").contains("nocommand")) {
|
||||
if (sender.hasPermission("commandpanel.panel." + panel.getConfig().getString("perm"))) {
|
||||
if(panel.getConfig().contains("panelType")) {
|
||||
if (panel.getConfig().getStringList("panelType").contains("nocommand")) {
|
||||
//do not allow command with noCommand
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (temp.contains("panels." + key + ".disabled-worlds")) {
|
||||
List<String> disabledWorlds = temp.getStringList("panels." + key + ".disabled-worlds");
|
||||
if (!disabledWorlds.contains(p.getWorld().getName())) {
|
||||
apanels.add(key);
|
||||
}
|
||||
} else {
|
||||
apanels.add(key);
|
||||
}
|
||||
if(plugin.panelPerms.isPanelWorldEnabled(p,panel.getConfig())){
|
||||
apanels.add(panel.getName());
|
||||
}
|
||||
}
|
||||
}catch(Exception skip){
|
||||
//ignore panel
|
||||
}
|
||||
//if file contains opened panel then start
|
||||
}
|
||||
return apanels;
|
||||
}
|
||||
|
@ -1,13 +1,11 @@
|
||||
package me.rockyhawk.commandpanels.customcommands;
|
||||
|
||||
import me.rockyhawk.commandpanels.CommandPanels;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import me.rockyhawk.commandpanels.api.Panel;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.*;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
|
||||
public class Commandpanelcustom implements Listener {
|
||||
@ -18,26 +16,16 @@ public class Commandpanelcustom implements Listener {
|
||||
@EventHandler
|
||||
public void PlayerCommand(PlayerCommandPreprocessEvent e) {
|
||||
try {
|
||||
if (plugin.panelsf.list() == null || Objects.requireNonNull(plugin.panelsf.list()).length == 0) {
|
||||
return;
|
||||
}
|
||||
}catch(Exception b){
|
||||
return;
|
||||
}
|
||||
ConfigurationSection tempFile;
|
||||
|
||||
try {
|
||||
for (String[] panelName : plugin.panelNames) {
|
||||
tempFile = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + plugin.panelFiles.get(Integer.parseInt(panelName[1])))).getConfigurationSection("panels." + panelName[0]);
|
||||
if (tempFile.contains("commands")) {
|
||||
List<String> panelCommands = tempFile.getStringList("commands");
|
||||
for (Panel panel : plugin.panelList) {
|
||||
if (panel.getConfig().contains("commands")) {
|
||||
List<String> panelCommands = panel.getConfig().getStringList("commands");
|
||||
for(String cmd : panelCommands){
|
||||
if(cmd.equalsIgnoreCase(e.getMessage().replace("/", ""))){
|
||||
e.setCancelled(true);
|
||||
if(plugin.openPanels.hasPanelOpen(e.getPlayer().getName())) {
|
||||
plugin.openPanels.skipPanels.add(e.getPlayer().getName());
|
||||
}
|
||||
plugin.openVoids.openCommandPanel(e.getPlayer(), e.getPlayer(), panelName[0], tempFile, false);
|
||||
panel.open(e.getPlayer());
|
||||
return;
|
||||
}
|
||||
|
||||
@ -60,12 +48,12 @@ public class Commandpanelcustom implements Listener {
|
||||
if(correctCommand){
|
||||
e.setCancelled(true);
|
||||
for(String[] placeholder : placeholders){
|
||||
plugin.customCommand.addCCP(panelName[0],e.getPlayer().getName(),placeholder[0],placeholder[1]);
|
||||
plugin.customCommand.addCCP(panel.getName(),e.getPlayer().getName(),placeholder[0],placeholder[1]);
|
||||
}
|
||||
if(plugin.openPanels.hasPanelOpen(e.getPlayer().getName())) {
|
||||
plugin.openPanels.skipPanels.add(e.getPlayer().getName());
|
||||
}
|
||||
plugin.openVoids.openCommandPanel(e.getPlayer(), e.getPlayer(), panelName[0], tempFile, false);
|
||||
panel.open(e.getPlayer());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,6 @@ import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.BigInteger;
|
||||
import java.util.*;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package me.rockyhawk.commandpanels.generatepanels;
|
||||
|
||||
import me.rockyhawk.commandpanels.CommandPanels;
|
||||
import me.rockyhawk.commandpanels.api.Panel;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.block.Chest;
|
||||
@ -64,9 +65,9 @@ public class GenUtils implements Listener {
|
||||
@SuppressWarnings("deprecation")
|
||||
void generatePanel(Player p, Inventory inv){
|
||||
ArrayList<String> apanels = new ArrayList();
|
||||
for(String[] panelNames : plugin.panelNames){
|
||||
for(Panel panel : plugin.panelList){
|
||||
//create list of names that aren't a String list
|
||||
apanels.add(panelNames[0]);
|
||||
apanels.add(panel.getName());
|
||||
}
|
||||
//this is done to make sure the inventories are not empty
|
||||
boolean foundItem = false;
|
||||
|
@ -1,16 +1,15 @@
|
||||
package me.rockyhawk.commandpanels.ingameeditor;
|
||||
|
||||
import me.rockyhawk.commandpanels.CommandPanels;
|
||||
import me.rockyhawk.commandpanels.api.Panel;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
|
||||
public class CpIngameEditCommand implements CommandExecutor {
|
||||
@ -36,30 +35,21 @@ public class CpIngameEditCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
ConfigurationSection cf = null; //this is the file to use for any panel.* requests
|
||||
String panelName = "";
|
||||
//below is going to go through the files and find the right one
|
||||
if (args.length != 0) { //check to make sure the person hasn't just left it empty
|
||||
for(String[] panels : plugin.panelNames){
|
||||
if(panels[0].equals(args[0])) {
|
||||
cf = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + plugin.panelFiles.get(Integer.parseInt(panels[1])))).getConfigurationSection("panels." + panels[0]);
|
||||
panelName = panels[0];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
//below will start the command, once it got the right file and panel
|
||||
if (cmd.getName().equalsIgnoreCase("cpe") || cmd.getName().equalsIgnoreCase("commandpaneledit") || cmd.getName().equalsIgnoreCase("cpanele")) {
|
||||
Player p = (Player)sender;
|
||||
//below is going to go through the files and find the right one
|
||||
if (args.length == 1) { //check to make sure the person hasn't just left it empty
|
||||
for(Panel panel : plugin.panelList){
|
||||
if(panel.getName().equals(args[0])) {
|
||||
//below will start the command, once it got the right file and panel
|
||||
plugin.createGUI.openGui(panel.getName(), p, cf,3,0);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (args.length == 0) {
|
||||
plugin.editorGuis.openEditorGui(p,0);
|
||||
return true;
|
||||
}
|
||||
if (args.length == 1) {
|
||||
//open editor window here
|
||||
plugin.createGUI.openGui(panelName, p, cf,3,0);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
sender.sendMessage(plugin.papi(plugin.tag + ChatColor.RED + "Usage: /cpe <panel>"));
|
||||
return true;
|
||||
}
|
||||
|
@ -1,17 +1,14 @@
|
||||
package me.rockyhawk.commandpanels.ingameeditor;
|
||||
|
||||
import me.rockyhawk.commandpanels.CommandPanels;
|
||||
import me.rockyhawk.commandpanels.api.Panel;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
|
||||
public class CpTabCompleteIngame implements TabCompleter {
|
||||
@ -23,32 +20,15 @@ public class CpTabCompleteIngame implements TabCompleter {
|
||||
Player p = ((Player) sender).getPlayer();
|
||||
if(label.equalsIgnoreCase("cpe") || label.equalsIgnoreCase("cpanele") || label.equalsIgnoreCase("commandpaneledit")){
|
||||
ArrayList<String> apanels = new ArrayList<String>(); //all panels
|
||||
String tpanels; //tpanels is the temp to check through the files
|
||||
try {
|
||||
for(String fileName : plugin.panelFiles) { //will loop through all the files in folder
|
||||
YamlConfiguration temp = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + fileName));
|
||||
String key;
|
||||
tpanels = "";
|
||||
if(!plugin.checkPanels(temp)){
|
||||
continue;
|
||||
}
|
||||
for (Iterator var10 = Objects.requireNonNull(temp.getConfigurationSection("panels")).getKeys(false).iterator(); var10.hasNext(); tpanels = tpanels + key + " ") {
|
||||
key = (String) var10.next();
|
||||
if(!key.startsWith(args[0])){
|
||||
for(Panel panel : plugin.panelList) { //will loop through all the files in folder
|
||||
if(!panel.getName().startsWith(args[0])){
|
||||
//this will narrow down the panels to what the user types
|
||||
continue;
|
||||
}
|
||||
if(sender.hasPermission("commandpanel.panel." + temp.getString("panels." + key + ".perm"))) {
|
||||
if(temp.contains("panels." + key + ".disabled-worlds")){
|
||||
List<String> disabledWorlds = temp.getStringList("panels." + key + ".disabled-worlds");
|
||||
assert p != null;
|
||||
|
||||
if(!disabledWorlds.contains(p.getWorld().getName())){
|
||||
apanels.add(key);
|
||||
}
|
||||
}else{
|
||||
apanels.add(key);
|
||||
}
|
||||
if(sender.hasPermission("commandpanel.panel." + panel.getConfig().getString("perm"))) {
|
||||
if(plugin.panelPerms.isPanelWorldEnabled(p,panel.getConfig())){
|
||||
apanels.add(panel.getName());
|
||||
}
|
||||
}
|
||||
//if file contains opened panel then start
|
||||
|
@ -1,6 +1,7 @@
|
||||
package me.rockyhawk.commandpanels.ingameeditor;
|
||||
|
||||
import me.rockyhawk.commandpanels.CommandPanels;
|
||||
import me.rockyhawk.commandpanels.api.Panel;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
@ -37,22 +38,14 @@ public class EditorUserInput implements Listener {
|
||||
YamlConfiguration cfile = null;
|
||||
ConfigurationSection cf = null;
|
||||
try {
|
||||
for (String tempFile : plugin.panelFiles) { //will loop through all the files in folder
|
||||
YamlConfiguration tempConf = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + tempFile));
|
||||
if (!plugin.checkPanels(tempConf)) {
|
||||
continue;
|
||||
}
|
||||
for (String key : Objects.requireNonNull(tempConf.getConfigurationSection("panels")).getKeys(false)) {
|
||||
if (key.equals(panelName)) {
|
||||
cfile = tempConf;
|
||||
cf = tempConf.getConfigurationSection("panels." + key);
|
||||
panelFile = new File(plugin.panelsf + File.separator + tempFile);
|
||||
panelTitle = plugin.papi( Objects.requireNonNull(cf.getString("title")));
|
||||
for (Panel panel : plugin.panelList) { //will loop through all the files in folder
|
||||
if (panel.getName().equals(panelName)) {
|
||||
cf = panel.getConfig();
|
||||
panelFile = panel.getFile();
|
||||
panelTitle = plugin.papi(cf.getString("title"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
//if file contains opened panel then start
|
||||
}
|
||||
} catch (Exception fail) {
|
||||
//could not fetch all panel names (probably no panels exist)
|
||||
plugin.debug(fail);
|
||||
|
@ -1,6 +1,7 @@
|
||||
package me.rockyhawk.commandpanels.ingameeditor;
|
||||
|
||||
import me.rockyhawk.commandpanels.CommandPanels;
|
||||
import me.rockyhawk.commandpanels.api.Panel;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
@ -45,18 +46,10 @@ public class EditorUtils implements Listener {
|
||||
ArrayList<String> panelTitles = new ArrayList<String>(); //all panels from ALL files (panel titles)
|
||||
ArrayList<ConfigurationSection> panelYaml = new ArrayList<ConfigurationSection>(); //all panels from ALL files (panel yaml files)
|
||||
try {
|
||||
for(String fileName : plugin.panelFiles) { //will loop through all the files in folder
|
||||
YamlConfiguration temp = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + fileName));
|
||||
String key;
|
||||
if(!plugin.checkPanels(temp)){
|
||||
continue;
|
||||
}
|
||||
for (String s : Objects.requireNonNull(temp.getConfigurationSection("panels")).getKeys(false)) {
|
||||
key = s;
|
||||
panelNames.add(plugin.papi( key));
|
||||
panelTitles.add(plugin.papi( Objects.requireNonNull(temp.getString("panels." + key + ".title"))));
|
||||
panelYaml.add(temp.getConfigurationSection("panels." + key));
|
||||
}
|
||||
for(Panel panel : plugin.panelList) { //will loop through all the files in folder
|
||||
panelNames.add(plugin.papi(panel.getName()));
|
||||
panelTitles.add(plugin.papi( Objects.requireNonNull(panel.getConfig().getString("title"))));
|
||||
panelYaml.add(panel.getConfig());
|
||||
}
|
||||
}catch(Exception fail){
|
||||
//could not fetch all panel names (probably no panels exist)
|
||||
@ -137,28 +130,20 @@ public class EditorUtils implements Listener {
|
||||
return;
|
||||
}
|
||||
String panelName = ""; //all panels from ALL files (panel names)
|
||||
String fileName = ""; //all panels from ALL files (panel names)
|
||||
YamlConfiguration file = new YamlConfiguration(); //all panels from ALL files (panel yaml files)
|
||||
File file = null; //all panels from ALL files (panel names)
|
||||
YamlConfiguration config = new YamlConfiguration(); //all panels from ALL files (panel yaml files)
|
||||
boolean found = false;
|
||||
try {
|
||||
//neew to loop through files to get file names
|
||||
for(String fileTempName : plugin.panelFiles) { //will loop through all the files in folder
|
||||
YamlConfiguration temp = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + fileName));
|
||||
String key;
|
||||
if(!plugin.checkPanels(temp)){
|
||||
continue;
|
||||
}
|
||||
for (String s : Objects.requireNonNull(temp.getConfigurationSection("panels")).getKeys(false)) {
|
||||
key = s;
|
||||
if (e.getView().getTitle().equals("Editing Panel: " + key)) {
|
||||
panelName = key;
|
||||
fileName = fileTempName;
|
||||
file = temp;
|
||||
for(Panel panel : plugin.panelList) { //will loop through all the files in folder
|
||||
if (e.getView().getTitle().equals("Editing Panel: " + panel.getName())) {
|
||||
panelName = panel.getName();
|
||||
file = panel.getFile();
|
||||
config = YamlConfiguration.loadConfiguration(panel.getFile());
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch(Exception fail){
|
||||
//could not fetch all panel names (probably no panels exist)
|
||||
plugin.debug(fail);
|
||||
@ -182,12 +167,13 @@ public class EditorUtils implements Listener {
|
||||
if(tempEdit.contains("panels." + panelName + ".temp." + p.getName())){
|
||||
try {
|
||||
for (int slot : e.getInventorySlots()) {
|
||||
file.set("panels." + panelName + ".item." + slot, tempEdit.get("panels." + panelName + ".temp." + p.getName()));
|
||||
config.set("panels." + panelName + ".item." + slot, tempEdit.get("panels." + panelName + ".temp." + p.getName()));
|
||||
//stacks can't be saved to file because it is not accurate in drag drop cases
|
||||
if(file.contains("panels." + panelName + ".item." + slot + ".stack")){
|
||||
file.set("panels." + panelName + ".item." + slot + ".stack",null);
|
||||
if(config.contains("panels." + panelName + ".item." + slot + ".stack")){
|
||||
config.set("panels." + panelName + ".item." + slot + ".stack",null);
|
||||
}
|
||||
saveFile(fileName, file, true);
|
||||
saveFile(file, config);
|
||||
saveFile(file, config);
|
||||
}
|
||||
}catch(NullPointerException nu){
|
||||
plugin.debug(nu);
|
||||
@ -204,26 +190,20 @@ public class EditorUtils implements Listener {
|
||||
return;
|
||||
}
|
||||
String panelName = "";
|
||||
String fileName = "";
|
||||
YamlConfiguration file = new YamlConfiguration();
|
||||
File file = null;
|
||||
YamlConfiguration config = new YamlConfiguration();
|
||||
boolean found = false;
|
||||
try {
|
||||
//neew to loop through files to get file names
|
||||
for(String tempName : plugin.panelFiles) { //will loop through all the files in folder
|
||||
YamlConfiguration temp = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + tempName));
|
||||
if(!plugin.checkPanels(temp)){
|
||||
continue;
|
||||
}
|
||||
for (String s : Objects.requireNonNull(temp.getConfigurationSection("panels")).getKeys(false)) {
|
||||
if (e.getView().getTitle().equals("Editing Panel: " + s)) {
|
||||
panelName = s;
|
||||
fileName = tempName;
|
||||
file = temp;
|
||||
for(Panel panel : plugin.panelList) { //will loop through all the files in folder
|
||||
if (e.getView().getTitle().equals("Editing Panel: " + panel.getName())) {
|
||||
panelName = panel.getName();
|
||||
file = panel.getFile();
|
||||
config = YamlConfiguration.loadConfiguration(panel.getFile());
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch(Exception fail){
|
||||
//could not fetch all panel names (probably no panels exist)
|
||||
plugin.debug(fail);
|
||||
@ -248,8 +228,8 @@ public class EditorUtils implements Listener {
|
||||
onEditPanelClose(p,e.getInventory(),e.getView());
|
||||
inventoryItemSettingsOpening.add(p.getName());
|
||||
//refresh the yaml config
|
||||
file = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + fileName));
|
||||
plugin.editorGuis.openItemSettings(p,panelName,file.getConfigurationSection("panels." + panelName + ".item." + e.getSlot()), String.valueOf(e.getSlot()));
|
||||
config = YamlConfiguration.loadConfiguration(file);
|
||||
plugin.editorGuis.openItemSettings(p,panelName,config.getConfigurationSection("panels." + panelName + ".item." + e.getSlot()), String.valueOf(e.getSlot()));
|
||||
p.updateInventory();
|
||||
return;
|
||||
}
|
||||
@ -272,16 +252,16 @@ public class EditorUtils implements Listener {
|
||||
return;
|
||||
}
|
||||
if(e.getAction() == InventoryAction.CLONE_STACK){
|
||||
saveTempItem(e, p, file, panelName);
|
||||
saveFile(fileName,file,true);
|
||||
saveTempItem(e, p, config, panelName);
|
||||
saveFile(file,config);
|
||||
}else if(e.getAction() == InventoryAction.PLACE_ALL){
|
||||
loadTempItem(e, p, file, fileName, panelName);
|
||||
loadTempItem(e, p, config, file, panelName);
|
||||
clearTemp(p, panelName);
|
||||
saveFile(fileName,file,true);
|
||||
saveFile(file,config);
|
||||
}else if(e.getAction() == InventoryAction.COLLECT_TO_CURSOR){
|
||||
saveTempItem(e, p, file, panelName);
|
||||
saveFile(fileName,file,true);
|
||||
removeOldItem(e, p, file, fileName, panelName);
|
||||
saveTempItem(e, p, config, panelName);
|
||||
saveFile(file,config);
|
||||
removeOldItem(e, p, config, file, panelName);
|
||||
}else if(e.getAction() == InventoryAction.DROP_ALL_CURSOR){
|
||||
e.setCancelled(true);
|
||||
}else if(e.getAction() == InventoryAction.DROP_ALL_SLOT){
|
||||
@ -297,26 +277,26 @@ public class EditorUtils implements Listener {
|
||||
}else if(e.getAction() == InventoryAction.MOVE_TO_OTHER_INVENTORY){
|
||||
e.setCancelled(true);
|
||||
}else if(e.getAction() == InventoryAction.PLACE_SOME){
|
||||
loadTempItem(e, p, file, fileName, panelName);
|
||||
saveFile(fileName,file,true);
|
||||
loadTempItem(e, p, config, file, panelName);
|
||||
saveFile(file,config);
|
||||
}else if(e.getAction() == InventoryAction.SWAP_WITH_CURSOR){
|
||||
e.setCancelled(true);
|
||||
}else if(e.getAction() == InventoryAction.PICKUP_ALL){
|
||||
saveTempItem(e, p, file, panelName);
|
||||
saveFile(fileName,file,true);
|
||||
removeOldItem(e, p, file, fileName, panelName);
|
||||
saveTempItem(e, p, config, panelName);
|
||||
saveFile(file,config);
|
||||
removeOldItem(e, p, config, file, panelName);
|
||||
}else if(e.getAction() == InventoryAction.PICKUP_HALF){
|
||||
saveTempItem(e, p, file, panelName);
|
||||
saveFile(fileName,file,true);
|
||||
saveTempItem(e, p, config, panelName);
|
||||
saveFile(file,config);
|
||||
}else if(e.getAction() == InventoryAction.PICKUP_ONE){
|
||||
saveTempItem(e, p, file, panelName);
|
||||
saveFile(fileName,file,true);
|
||||
saveTempItem(e, p, config, panelName);
|
||||
saveFile(file,config);
|
||||
}else if(e.getAction() == InventoryAction.PICKUP_SOME){
|
||||
saveTempItem(e, p, file, panelName);
|
||||
saveFile(fileName,file,true);
|
||||
saveTempItem(e, p, config, panelName);
|
||||
saveFile(file,config);
|
||||
}else if(e.getAction() == InventoryAction.PLACE_ONE){
|
||||
loadTempItem(e, p, file, fileName, panelName);
|
||||
saveFile(fileName,file,true);
|
||||
loadTempItem(e, p, config, file, panelName);
|
||||
saveFile(file,config);
|
||||
}
|
||||
}
|
||||
|
||||
@ -361,22 +341,16 @@ public class EditorUtils implements Listener {
|
||||
boolean hotbarItems = false;
|
||||
try {
|
||||
//neew to loop through files to get file names
|
||||
for(String fileName : plugin.panelFiles) { //will loop through all the files in folder
|
||||
YamlConfiguration temp = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + fileName));
|
||||
if(!plugin.checkPanels(temp)){
|
||||
continue;
|
||||
}
|
||||
for (String key : Objects.requireNonNull(temp.getConfigurationSection("panels")).getKeys(false)){
|
||||
if(e.getView().getTitle().equals("Panel Settings: " + key)){
|
||||
panelName = key;
|
||||
if(temp.contains("panels." + panelName + ".open-with-item")){
|
||||
for(Panel panel : plugin.panelList) { //will loop through all the files in folder
|
||||
if(e.getView().getTitle().equals("Panel Settings: " + panel.getName())){
|
||||
panelName = panel.getName();
|
||||
if(panel.getConfig().contains("open-with-item")){
|
||||
hotbarItems = true;
|
||||
}
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch(Exception fail){
|
||||
//could not fetch all panel names (probably no panels exist)
|
||||
plugin.debug(fail);
|
||||
@ -522,27 +496,18 @@ public class EditorUtils implements Listener {
|
||||
}
|
||||
e.setCancelled(true);
|
||||
String panelName = ""; //all panels from ALL files (panel names)
|
||||
YamlConfiguration panelYaml = null; //all panels from ALL files (panel names)
|
||||
ConfigurationSection panelYaml = null; //all panels from ALL files (panel names)
|
||||
boolean found = false;
|
||||
try {
|
||||
//loop through files to get file names
|
||||
for(String fileName : plugin.panelFiles) { //will loop through all the files in folder
|
||||
YamlConfiguration temp = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + fileName));
|
||||
if(!plugin.checkPanels(temp)){
|
||||
continue;
|
||||
}
|
||||
for (String key : Objects.requireNonNull(temp.getConfigurationSection("panels")).getKeys(false)){
|
||||
if(e.getView().getTitle().equals("Item Settings: " + key)){
|
||||
panelName = key;
|
||||
panelYaml = temp;
|
||||
for(Panel panel : plugin.panelList) { //will loop through all the files in folder
|
||||
if(e.getView().getTitle().equals("Item Settings: " + panel.getName())){
|
||||
panelName = panel.getName();
|
||||
panelYaml = panel.getConfig();
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(found){
|
||||
break;
|
||||
}
|
||||
}
|
||||
}catch(Exception fail){
|
||||
//could not fetch all panel names (probably no panels exist)
|
||||
plugin.debug(fail);
|
||||
@ -624,7 +589,7 @@ public class EditorUtils implements Listener {
|
||||
}
|
||||
if(e.getSlot() == 31){
|
||||
//section includes the slot number at the front
|
||||
plugin.editorGuis.openItemSections(p,panelName,panelYaml.getConfigurationSection("panels." + panelName + ".item." + itemSlot), itemSlot);
|
||||
plugin.editorGuis.openItemSections(p,panelName,panelYaml.getConfigurationSection("item." + itemSlot), itemSlot);
|
||||
p.updateInventory();
|
||||
}
|
||||
if(e.getSlot() == 35){
|
||||
@ -635,9 +600,9 @@ public class EditorUtils implements Listener {
|
||||
if(e.getSlot() == 27){
|
||||
if(itemSlot.contains(".")){
|
||||
String newSection = itemSlot.substring(0, itemSlot.lastIndexOf("."));
|
||||
plugin.editorGuis.openItemSections(p,panelName,panelYaml.getConfigurationSection("panels." + panelName + ".item." + newSection), newSection);
|
||||
plugin.editorGuis.openItemSections(p,panelName,panelYaml.getConfigurationSection("item." + newSection), newSection);
|
||||
}else {
|
||||
plugin.createGUI.openGui(panelName, p, panelYaml.getConfigurationSection("panels." + panelName), 3, 0);
|
||||
plugin.createGUI.openGui(panelName, p, panelYaml, 3, 0);
|
||||
}
|
||||
p.updateInventory();
|
||||
}
|
||||
@ -660,29 +625,19 @@ public class EditorUtils implements Listener {
|
||||
}
|
||||
e.setCancelled(true);
|
||||
String panelName = ""; //all panels from ALL files (panel names)
|
||||
YamlConfiguration panelYaml = null;
|
||||
ConfigurationSection panelYaml = null;
|
||||
ConfigurationSection itemConfSection; //all panels from ALL files (panel names)
|
||||
boolean found = false;
|
||||
try {
|
||||
//loop through files to get file names
|
||||
YamlConfiguration temp;
|
||||
for(String fileName : plugin.panelFiles) { //will loop through all the files in folder
|
||||
temp = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + fileName));
|
||||
if(!plugin.checkPanels(temp)){
|
||||
continue;
|
||||
}
|
||||
for (String key : Objects.requireNonNull(temp.getConfigurationSection("panels")).getKeys(false)){
|
||||
if(e.getView().getTitle().equals("Item Sections: " + key)){
|
||||
panelName = key;
|
||||
panelYaml = temp;
|
||||
for(Panel panel : plugin.panelList) { //will loop through all the files in folder
|
||||
if(e.getView().getTitle().equals("Item Sections: " + panel.getName())){
|
||||
panelName = panel.getName();
|
||||
panelYaml = panel.getConfig();
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(found){
|
||||
break;
|
||||
}
|
||||
}
|
||||
}catch(Exception fail){
|
||||
//could not fetch all panel names (probably no panels exist)
|
||||
plugin.debug(fail);
|
||||
@ -701,7 +656,7 @@ public class EditorUtils implements Listener {
|
||||
plugin.debug(ex);
|
||||
return;
|
||||
}
|
||||
itemConfSection = panelYaml.getConfigurationSection("panels." + panelName + ".item." + section);
|
||||
itemConfSection = panelYaml.getConfigurationSection("item." + section);
|
||||
|
||||
if(e.getSlot() <= 35){
|
||||
if(e.getInventory().getItem(e.getSlot()) != null){
|
||||
@ -739,32 +694,35 @@ public class EditorUtils implements Listener {
|
||||
public void saveTempItem(InventoryClickEvent e, Player p, YamlConfiguration file, String panelName){
|
||||
//saves item to temp, using getslot
|
||||
tempEdit.set("panels." + panelName + ".temp." + p.getName(),file.get("panels." + panelName + ".item." + e.getSlot()));
|
||||
saveFile("temp.yml", tempEdit, false);
|
||||
saveFile("temp.yml", tempEdit);
|
||||
}
|
||||
public void loadTempItem(InventoryClickEvent e, Player p, YamlConfiguration file,String fileName, String panelName){
|
||||
public void loadTempItem(InventoryClickEvent e, Player p, YamlConfiguration config,File file, String panelName){
|
||||
//loads temp item to the current item
|
||||
if(tempEdit.contains("panels." + panelName + ".temp." + p.getName())){
|
||||
file.set("panels." + panelName + ".item." + e.getSlot(),tempEdit.get("panels." + panelName + ".temp." + p.getName()));
|
||||
saveFile(fileName, file, true);
|
||||
config.set("panels." + panelName + ".item." + e.getSlot(),tempEdit.get("panels." + panelName + ".temp." + p.getName()));
|
||||
saveFile(file, config);
|
||||
}
|
||||
}
|
||||
public void removeOldItem(InventoryClickEvent e, Player p, YamlConfiguration file,String fileName, String panelName){
|
||||
public void removeOldItem(InventoryClickEvent e, Player p, YamlConfiguration config,File file, String panelName){
|
||||
//removes the old item from config, if it has been picked up (use this only after saving)
|
||||
file.set("panels." + panelName + ".item." + e.getSlot(),null);
|
||||
saveFile(fileName, file, true);
|
||||
config.set("panels." + panelName + ".item." + e.getSlot(),null);
|
||||
saveFile(file, config);
|
||||
}
|
||||
public void clearTemp(Player p, String panelName){
|
||||
//empty temp item
|
||||
tempEdit.set("panels." + panelName + ".temp." + p.getName(),null);
|
||||
saveFile("temp.yml", tempEdit, false);
|
||||
saveFile("temp.yml", tempEdit);
|
||||
}
|
||||
public void saveFile(String fileName, YamlConfiguration file, boolean inPanelsFolder){
|
||||
public void saveFile(String fileName, YamlConfiguration file){
|
||||
try {
|
||||
if(inPanelsFolder){
|
||||
file.save(new File(plugin.panelsf + File.separator + fileName));
|
||||
}else{
|
||||
file.save(new File(plugin.getDataFolder() + File.separator + fileName));
|
||||
} catch (IOException s) {
|
||||
plugin.debug(s);
|
||||
}
|
||||
}
|
||||
public void saveFile(File file, YamlConfiguration config){
|
||||
try {
|
||||
config.save(file);
|
||||
} catch (IOException s) {
|
||||
plugin.debug(s);
|
||||
}
|
||||
@ -779,28 +737,20 @@ public class EditorUtils implements Listener {
|
||||
return;
|
||||
}
|
||||
String panelName = ""; //all panels from ALL files (panel names)
|
||||
String fileName = ""; //all panels from ALL files (panel names)
|
||||
YamlConfiguration file = new YamlConfiguration(); //all panels from ALL files (panel yaml files)
|
||||
File file = null; //all panels from ALL files (panel names)
|
||||
YamlConfiguration config = new YamlConfiguration(); //all panels from ALL files (panel yaml files)
|
||||
boolean found = false;
|
||||
try {
|
||||
//neew to loop through files to get file names
|
||||
for(String tempFile : plugin.panelFiles) { //will loop through all the files in folder
|
||||
YamlConfiguration temp = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + tempFile));
|
||||
String key;
|
||||
if(!plugin.checkPanels(temp)){
|
||||
continue;
|
||||
}
|
||||
for (String s : Objects.requireNonNull(temp.getConfigurationSection("panels")).getKeys(false)) {
|
||||
key = s;
|
||||
if (invView.getTitle().equals("Editing Panel: " + key)) {
|
||||
panelName = key;
|
||||
fileName = tempFile;
|
||||
file = temp;
|
||||
for(Panel panel : plugin.panelList) { //will loop through all the files in folder
|
||||
if (invView.getTitle().equals("Editing Panel: " + panel.getName())) {
|
||||
panelName = panel.getName();
|
||||
file = panel.getFile();
|
||||
config = YamlConfiguration.loadConfiguration(panel.getFile());
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch(Exception fail){
|
||||
//could not fetch all panel names (probably no panels exist)
|
||||
plugin.debug(fail);
|
||||
@ -810,9 +760,9 @@ public class EditorUtils implements Listener {
|
||||
return;
|
||||
}
|
||||
//save items as they appear
|
||||
file = plugin.itemCreate.generatePanelFile(panelName,inv,file);
|
||||
config = plugin.itemCreate.generatePanelFile(panelName,inv,config);
|
||||
try {
|
||||
file.save(new File(plugin.panelsf + File.separator + fileName));
|
||||
config.save(file);
|
||||
p.sendMessage(plugin.papi(plugin.tag + ChatColor.GREEN + "Saved Changes!"));
|
||||
} catch (IOException s) {
|
||||
p.sendMessage(plugin.papi(plugin.tag + ChatColor.RED + "Could Not Save Changes!"));
|
||||
|
@ -1,12 +1,13 @@
|
||||
package me.rockyhawk.commandpanels.interactives;
|
||||
|
||||
import me.rockyhawk.commandpanels.CommandPanels;
|
||||
import me.rockyhawk.commandpanels.api.Panel;
|
||||
import me.rockyhawk.commandpanels.api.PanelOpenedEvent;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.InventoryOpenEvent;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import java.util.Objects;
|
||||
@ -17,43 +18,39 @@ public class Commandpanelrefresher implements Listener {
|
||||
this.plugin = pl;
|
||||
}
|
||||
@EventHandler
|
||||
public void onInventoryOpen(InventoryOpenEvent e){ //Handles when Players open inventory
|
||||
public void onPanelOpen(PanelOpenedEvent e){ //Handles when Players open inventory
|
||||
//I have to convert HumanEntity to a player
|
||||
if (plugin.config.contains("config.refresh-panels")) {
|
||||
if (Objects.requireNonNull(plugin.config.getString("config.refresh-panels")).trim().equalsIgnoreCase("false")) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
Player p = (Player) e.getPlayer();
|
||||
|
||||
if(!plugin.openPanels.hasPanelOpen(p.getName())){
|
||||
return;
|
||||
}
|
||||
ConfigurationSection cf = plugin.openPanels.getOpenPanel(p.getName()); //this is the panel cf section
|
||||
String panelName = plugin.openPanels.getOpenPanelName(p.getName()); //get panel name
|
||||
Player p = e.getPlayer();
|
||||
Panel pn = e.getPanel();
|
||||
|
||||
//remove sound-on-open on 1.8 for those who do not read the wiki ;)
|
||||
if(cf.contains("sound-on-open")){
|
||||
if(pn.getConfig().contains("sound-on-open")){
|
||||
if(Bukkit.getVersion().contains("1.8")){
|
||||
cf.set("sound-on-open", null);
|
||||
pn.getConfig().set("sound-on-open", null);
|
||||
}
|
||||
}
|
||||
|
||||
//if panel has custom refresh delay
|
||||
int tempRefreshDelay = plugin.config.getInt("config.refresh-delay");
|
||||
if(cf.contains("refresh-delay")){
|
||||
tempRefreshDelay = cf.getInt("refresh-delay");
|
||||
if(pn.getConfig().contains("refresh-delay")){
|
||||
tempRefreshDelay = pn.getConfig().getInt("refresh-delay");
|
||||
}
|
||||
final int refreshDelay = tempRefreshDelay;
|
||||
|
||||
if(cf.contains("panelType")) {
|
||||
if (cf.getStringList("panelType").contains("static")) {
|
||||
if(pn.getConfig().contains("panelType")) {
|
||||
if (pn.getConfig().getStringList("panelType").contains("static")) {
|
||||
//do not update temporary panels, only default panels
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
final ConfigurationSection cfFinal = cf;
|
||||
final ConfigurationSection cfFinal = pn.getConfig();
|
||||
new BukkitRunnable(){
|
||||
int c = 0;
|
||||
int animatecount = 0;
|
||||
@ -70,7 +67,7 @@ public class Commandpanelrefresher implements Listener {
|
||||
c=0;
|
||||
}
|
||||
//refresh here
|
||||
if(plugin.openPanels.hasPanelOpen(p.getName(),panelName)){
|
||||
if(plugin.openPanels.hasPanelOpen(p.getName(),pn.getName())){
|
||||
if(c == 0) {
|
||||
//animation counter
|
||||
if(animatevalue != -1) {
|
||||
@ -85,7 +82,7 @@ public class Commandpanelrefresher implements Listener {
|
||||
} catch (Exception e) {
|
||||
//error opening gui
|
||||
p.closeInventory();
|
||||
plugin.openPanels.closePanelForLoader(p.getName(),panelName);
|
||||
plugin.openPanels.closePanelForLoader(p.getName(),pn.getName());
|
||||
this.cancel();
|
||||
}
|
||||
}
|
||||
@ -101,7 +98,7 @@ public class Commandpanelrefresher implements Listener {
|
||||
this.cancel();
|
||||
}
|
||||
}
|
||||
}.runTaskTimer(this.plugin, 5, 5); //20 ticks == 1 second (5 ticks = 0.25 of a second)
|
||||
}.runTaskTimer(this.plugin, 1,1); //20 ticks == 1 second (5 ticks = 0.25 of a second)
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,23 @@
|
||||
package me.rockyhawk.commandpanels.openpanelsmanager;
|
||||
|
||||
import me.rockyhawk.commandpanels.CommandPanels;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class PanelPermissions {
|
||||
CommandPanels plugin;
|
||||
public PanelPermissions(CommandPanels pl) {
|
||||
this.plugin = pl;
|
||||
}
|
||||
|
||||
//if panel has the world enabled
|
||||
public boolean isPanelWorldEnabled(Player p, ConfigurationSection panelConfig){
|
||||
if(panelConfig.contains("disabled-worlds")){
|
||||
return !panelConfig.getStringList("disabled-worlds").contains(p.getWorld().getName());
|
||||
}
|
||||
if(panelConfig.contains("enabled-worlds")){
|
||||
return panelConfig.getStringList("enabled-worlds").contains(p.getWorld().getName());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
@ -1,14 +1,12 @@
|
||||
package me.rockyhawk.commandpanels.openwithitem;
|
||||
|
||||
import me.rockyhawk.commandpanels.CommandPanels;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import me.rockyhawk.commandpanels.api.Panel;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Objects;
|
||||
import java.util.HashMap;
|
||||
import java.util.Set;
|
||||
|
||||
public class HotbarItemLoader {
|
||||
CommandPanels plugin;
|
||||
@ -17,47 +15,37 @@ public class HotbarItemLoader {
|
||||
}
|
||||
|
||||
//stationary slots 0-8 are the hotbar, using 9-33 for inside the inventory
|
||||
ArrayList<int[]> stationaryItems = new ArrayList<>(); //{slot 0-33, index of panelNames}
|
||||
HashMap<Integer,Panel> stationaryItems = new HashMap<>();
|
||||
|
||||
//will compile the ArrayList {slot 0-4, index of panelNames}
|
||||
public void reloadHotbarSlots() {
|
||||
stationaryItems = new ArrayList<>();
|
||||
int i = 0;
|
||||
for (String[] panelName : plugin.panelNames) {
|
||||
ConfigurationSection tempFile = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + plugin.panelFiles.get(Integer.parseInt(panelName[1])))).getConfigurationSection("panels." + panelName[0]);
|
||||
if(tempFile.contains("open-with-item.stationary")){
|
||||
stationaryItems.add(new int[]{tempFile.getInt("open-with-item.stationary"),i});
|
||||
stationaryItems.clear();
|
||||
for (Panel panel : plugin.panelList) {
|
||||
if(panel.getConfig().contains("open-with-item.stationary")){
|
||||
stationaryItems.put(panel.getConfig().getInt("open-with-item.stationary"), panel);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
public ArrayList<Integer> getStationaryItemSlots(){
|
||||
ArrayList<Integer> tempItems = new ArrayList<>();
|
||||
for(int[] tempItem : stationaryItems){
|
||||
tempItems.add(tempItem[0]);
|
||||
}
|
||||
return tempItems;
|
||||
public Set<Integer> getStationaryItemSlots(){
|
||||
return stationaryItems.keySet();
|
||||
}
|
||||
|
||||
//return true if found
|
||||
public boolean stationaryExecute(int slot, Player p, boolean openPanel){
|
||||
for(int[] temp : stationaryItems){
|
||||
if(slot == temp[0]){
|
||||
for(int temp : stationaryItems.keySet()){
|
||||
if(slot == temp){
|
||||
if(openPanel) {
|
||||
String panelName = plugin.panelNames.get(temp[1])[0];
|
||||
ConfigurationSection tempFile = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + plugin.panelFiles.get(Integer.parseInt(plugin.panelNames.get(temp[1])[1])))).getConfigurationSection("panels." + panelName);
|
||||
Panel panel = stationaryItems.get(temp);
|
||||
//only open panel automatically if there are no commands and player world is not disabled
|
||||
if(!p.hasPermission(tempFile.getString("perm"))){
|
||||
if(!p.hasPermission("commandpanel.panel." + panel.getConfig().getString("perm"))){
|
||||
return false;
|
||||
}
|
||||
if(tempFile.contains("disabled-worlds")){
|
||||
if(tempFile.getStringList("disabled-worlds").contains(p.getWorld().getName())){
|
||||
if(!plugin.panelPerms.isPanelWorldEnabled(p,panel.getConfig())){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if(tempFile.contains("open-with-item.commands")){
|
||||
for(String command : tempFile.getStringList("open-with-item.commands")){
|
||||
if(panel.getConfig().contains("open-with-item.commands")){
|
||||
for(String command : panel.getConfig().getStringList("open-with-item.commands")){
|
||||
plugin.commandTags.commandTags(p,plugin.papi(p,command),command);
|
||||
}
|
||||
return true;
|
||||
@ -65,7 +53,7 @@ public class HotbarItemLoader {
|
||||
if (plugin.openPanels.hasPanelOpen(p.getName())) {
|
||||
plugin.openPanels.skipPanels.add(p.getName());
|
||||
}
|
||||
plugin.openVoids.openCommandPanel(p, p, panelName, tempFile, false);
|
||||
panel.open(p);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -75,16 +63,14 @@ public class HotbarItemLoader {
|
||||
|
||||
//return true if found
|
||||
public boolean itemCheckExecute(ItemStack invItem, Player p, boolean openPanel, boolean stationaryOnly){
|
||||
for(String[] panelName : plugin.panelNames) {
|
||||
ConfigurationSection tempFile = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + plugin.panelFiles.get(Integer.parseInt(panelName[1])))).getConfigurationSection("panels." + panelName[0]);
|
||||
String tempName = panelName[0];
|
||||
for(Panel panel : plugin.panelList) {
|
||||
if(stationaryOnly){
|
||||
if(!tempFile.contains("open-with-item.stationary")){
|
||||
if(!panel.getConfig().contains("open-with-item.stationary")){
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if(tempFile.contains("open-with-item")){
|
||||
ItemStack panelItem = plugin.itemCreate.makeItemFromConfig(Objects.requireNonNull(tempFile.getConfigurationSection("open-with-item")), p, false, true, false);
|
||||
if(panel.hasHotbarItem()){
|
||||
ItemStack panelItem = panel.getHotbarItem(p);
|
||||
if(invItem != null && panelItem != null) {
|
||||
panelItem.setAmount(invItem.getAmount());
|
||||
}else{
|
||||
@ -93,13 +79,11 @@ public class HotbarItemLoader {
|
||||
if(panelItem.isSimilar(invItem)){
|
||||
if(openPanel) {
|
||||
//only open panel automatically if there are no commands and if world is not disabled
|
||||
if(tempFile.contains("disabled-worlds")){
|
||||
if(tempFile.getStringList("disabled-worlds").contains(p.getWorld().getName())){
|
||||
if(!plugin.panelPerms.isPanelWorldEnabled(p,panel.getConfig())){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if(tempFile.contains("open-with-item.commands")){
|
||||
for(String command : tempFile.getStringList("open-with-item.commands")){
|
||||
if(panel.getConfig().contains("open-with-item.commands")){
|
||||
for(String command : panel.getConfig().getStringList("open-with-item.commands")){
|
||||
plugin.commandTags.commandTags(p,plugin.papi(p,command),command);
|
||||
}
|
||||
return true;
|
||||
@ -107,7 +91,7 @@ public class HotbarItemLoader {
|
||||
if (plugin.openPanels.hasPanelOpen(p.getName())) {
|
||||
plugin.openPanels.skipPanels.add(p.getName());
|
||||
}
|
||||
plugin.openVoids.openCommandPanel(p, p, tempName, tempFile, false);
|
||||
panel.open(p);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -1,11 +1,11 @@
|
||||
package me.rockyhawk.commandpanels.openwithitem;
|
||||
|
||||
import me.rockyhawk.commandpanels.CommandPanels;
|
||||
import me.rockyhawk.commandpanels.api.Panel;
|
||||
import me.rockyhawk.commandpanels.ioclasses.GetItemInHand;
|
||||
import me.rockyhawk.commandpanels.ioclasses.GetItemInHand_Legacy;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
@ -17,9 +17,6 @@ import org.bukkit.event.inventory.InventoryType;
|
||||
import org.bukkit.event.player.*;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public class UtilsOpenWithItem implements Listener {
|
||||
@ -86,37 +83,15 @@ public class UtilsOpenWithItem implements Listener {
|
||||
return;
|
||||
}
|
||||
Player p = e.getPlayer();
|
||||
try {
|
||||
if (plugin.panelFiles == null) {
|
||||
return;
|
||||
}
|
||||
}catch(Exception b){
|
||||
return;
|
||||
}
|
||||
String tpanels; //tpanels is the temp to check through the files
|
||||
for(String fileName : plugin.panelFiles) { //will loop through all the files in folder
|
||||
YamlConfiguration temp = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + fileName));
|
||||
String key;
|
||||
tpanels = "";
|
||||
if(!plugin.checkPanels(temp)){
|
||||
|
||||
for(Panel panel : plugin.panelList) { //will loop through all the files in folder
|
||||
if(!plugin.panelPerms.isPanelWorldEnabled(p,panel.getConfig())){
|
||||
continue;
|
||||
}
|
||||
for (Iterator var10 = Objects.requireNonNull(temp.getConfigurationSection("panels")).getKeys(false).iterator(); var10.hasNext(); tpanels = tpanels + key + " ") {
|
||||
key = (String) var10.next();
|
||||
if(temp.contains("panels." + key + ".disabled-worlds")){
|
||||
List<String> disabledWorlds = temp.getStringList("panels." + key + ".disabled-worlds");
|
||||
assert disabledWorlds != null;
|
||||
if(disabledWorlds.contains(p.getWorld().getName())){
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (p.hasPermission("commandpanel.panel." + temp.getString("panels." + key + ".perm")) && temp.contains("panels." + key + ".open-with-item")) {
|
||||
ItemStack s = plugin.itemCreate.makeItemFromConfig(Objects.requireNonNull(temp.getConfigurationSection("panels." + key + ".open-with-item")), p, false, true, false);
|
||||
if(temp.contains("panels." + key + ".open-with-item.stationary")) {
|
||||
if (0 <= Integer.parseInt(Objects.requireNonNull(temp.getString("panels." + key + ".open-with-item.stationary"))) && 33 >= Integer.parseInt(Objects.requireNonNull(temp.getString("panels." + key + ".open-with-item.stationary")))) {
|
||||
p.getInventory().setItem(Integer.parseInt(Objects.requireNonNull(temp.getString("panels." + key + ".open-with-item.stationary"))), s);
|
||||
}
|
||||
}
|
||||
if (p.hasPermission("commandpanel.panel." + panel.getConfig().getString("perm")) && panel.hasHotbarItem()) {
|
||||
ItemStack s = panel.getHotbarItem(p);
|
||||
if(panel.getConfig().contains("open-with-item.stationary")) {
|
||||
p.getInventory().setItem(panel.getConfig().getInt("open-with-item.stationary"),s);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -128,35 +103,14 @@ public class UtilsOpenWithItem implements Listener {
|
||||
return;
|
||||
}
|
||||
Player p = e.getPlayer();
|
||||
try {
|
||||
if (plugin.panelFiles == null) {
|
||||
return;
|
||||
}
|
||||
}catch(Exception b){
|
||||
return;
|
||||
}
|
||||
String tpanels; //tpanels is the temp to check through the files
|
||||
for(String fileName : plugin.panelFiles) { //will loop through all the files in folder
|
||||
YamlConfiguration temp = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + fileName));
|
||||
String key;
|
||||
tpanels = "";
|
||||
if(!plugin.checkPanels(temp)){
|
||||
for(Panel panel : plugin.panelList) { //will loop through all the files in folder
|
||||
if(!plugin.panelPerms.isPanelWorldEnabled(p,panel.getConfig())){
|
||||
continue;
|
||||
}
|
||||
for (Iterator var10 = temp.getConfigurationSection("panels").getKeys(false).iterator(); var10.hasNext(); tpanels = tpanels + key + " ") {
|
||||
key = (String) var10.next();
|
||||
if(temp.contains("panels." + key + ".disabled-worlds")){
|
||||
List<String> disabledWorlds = temp.getStringList("panels." + key + ".disabled-worlds");
|
||||
assert disabledWorlds != null;
|
||||
if(disabledWorlds.contains(p.getWorld().getName())){
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (p.hasPermission("commandpanel.panel." + temp.getString("panels." + key + ".perm")) && temp.contains("panels." + key + ".open-with-item")) {
|
||||
ItemStack s = plugin.itemCreate.makeItemFromConfig(Objects.requireNonNull(temp.getConfigurationSection("panels." + key + ".open-with-item")), p, false, true, false);
|
||||
if(temp.contains("panels." + key + ".open-with-item.stationary") && 0 <= Integer.parseInt(Objects.requireNonNull(temp.getString("panels." + key + ".open-with-item.stationary"))) && 33 >= Integer.parseInt(Objects.requireNonNull(temp.getString("panels." + key + ".open-with-item.stationary")))){
|
||||
p.getInventory().setItem(Integer.parseInt(Objects.requireNonNull(temp.getString("panels." + key + ".open-with-item.stationary"))), s);
|
||||
}
|
||||
if (p.hasPermission("commandpanel.panel." + panel.getConfig().getString("perm")) && panel.hasHotbarItem()) {
|
||||
ItemStack s = panel.getHotbarItem(p);
|
||||
if(panel.getConfig().contains("open-with-item.stationary")){
|
||||
p.getInventory().setItem(panel.getConfig().getInt("open-with-item.stationary"), s);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -168,32 +122,15 @@ public class UtilsOpenWithItem implements Listener {
|
||||
return;
|
||||
}
|
||||
Player p = e.getEntity();
|
||||
try {
|
||||
if (plugin.panelFiles == null) {
|
||||
return;
|
||||
}
|
||||
}catch(Exception b){
|
||||
return;
|
||||
}
|
||||
String tpanels; //tpanels is the temp to check through the files
|
||||
for(String fileName : plugin.panelFiles) { //will loop through all the files in folder
|
||||
YamlConfiguration temp = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + fileName));
|
||||
String key;
|
||||
tpanels = "";
|
||||
if(!plugin.checkPanels(temp)){
|
||||
continue;
|
||||
}
|
||||
for (Iterator var10 = Objects.requireNonNull(temp.getConfigurationSection("panels")).getKeys(false).iterator(); var10.hasNext(); tpanels = tpanels + key + " ") {
|
||||
key = (String) var10.next();
|
||||
if (p.hasPermission("commandpanel.panel." + temp.getString("panels." + key + ".perm")) && temp.contains("panels." + key + ".open-with-item")) {
|
||||
if(temp.contains("panels." + key + ".open-with-item.stationary")){
|
||||
ItemStack s = plugin.itemCreate.makeItemFromConfig(Objects.requireNonNull(temp.getConfigurationSection("panels." + key + ".open-with-item")), p, false, true, false);
|
||||
for(Panel panel : plugin.panelList) { //will loop through all the files in folder
|
||||
if (p.hasPermission("commandpanel.panel." + panel.getConfig().getString("perm")) && panel.hasHotbarItem()) {
|
||||
if(panel.getConfig().contains("open-with-item.stationary")){
|
||||
ItemStack s = panel.getHotbarItem(p);
|
||||
e.getDrops().remove(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@EventHandler
|
||||
public void onPlayerJoin(PlayerJoinEvent e){
|
||||
if(!plugin.openWithItem){
|
||||
@ -201,52 +138,23 @@ public class UtilsOpenWithItem implements Listener {
|
||||
return;
|
||||
}
|
||||
Player p = e.getPlayer();
|
||||
try {
|
||||
if (plugin.panelFiles == null) {
|
||||
return;
|
||||
}
|
||||
}catch(Exception b){
|
||||
return;
|
||||
}
|
||||
String tpanels; //tpanels is the temp to check through the files
|
||||
for(String fileName : plugin.panelFiles) { //will loop through all the files in folder
|
||||
YamlConfiguration temp = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + fileName));
|
||||
String key;
|
||||
tpanels = "";
|
||||
if(!plugin.checkPanels(temp)){
|
||||
for(Panel panel : plugin.panelList) { //will loop through all the files in folder
|
||||
if(!panel.getConfig().contains("open-with-item.stationary")){
|
||||
return;
|
||||
}
|
||||
if (p.hasPermission("commandpanel.panel." + panel.getConfig().getString("perm"))){
|
||||
if(!plugin.panelPerms.isPanelWorldEnabled(p,panel.getConfig())){
|
||||
continue;
|
||||
}
|
||||
for (Iterator var10 = Objects.requireNonNull(temp.getConfigurationSection("panels")).getKeys(false).iterator(); var10.hasNext(); tpanels = tpanels + key + " ") {
|
||||
key = (String) var10.next();
|
||||
if (p.hasPermission("commandpanel.panel." + temp.getString("panels." + key + ".perm")) && temp.contains("panels." + key + ".open-with-item")) {
|
||||
if(temp.contains("panels." + key + ".disabled-worlds")){
|
||||
List<String> disabledWorlds = temp.getStringList("panels." + key + ".disabled-worlds");
|
||||
if(disabledWorlds.contains(p.getWorld().getName())){
|
||||
continue;
|
||||
}
|
||||
}
|
||||
ItemStack s = plugin.itemCreate.makeItemFromConfig(Objects.requireNonNull(temp.getConfigurationSection("panels." + key + ".open-with-item")), p, false, true, false);
|
||||
if(temp.contains("panels." + key + ".open-with-item.stationary") && 0 <= Integer.parseInt(Objects.requireNonNull(temp.getString("panels." + key + ".open-with-item.stationary"))) && 33 >= Integer.parseInt(Objects.requireNonNull(temp.getString("panels." + key + ".open-with-item.stationary")))){
|
||||
p.getInventory().setItem(Integer.parseInt(Objects.requireNonNull(temp.getString("panels." + key + ".open-with-item.stationary"))), s);
|
||||
}
|
||||
ItemStack s = panel.getHotbarItem(p);
|
||||
p.getInventory().setItem(panel.getConfig().getInt("open-with-item.stationary"), s);
|
||||
}else{
|
||||
//if the player has an item that they have no permission for, remove it
|
||||
ItemStack s;
|
||||
try {
|
||||
s = new ItemStack(Objects.requireNonNull(Material.matchMaterial(Objects.requireNonNull(temp.getString("panels." + key + ".open-with-item.material")))), 1);
|
||||
}catch(Exception n){
|
||||
continue;
|
||||
}
|
||||
plugin.setName(s, temp.getString("panels." + key + ".open-with-item.name"), temp.getStringList("panels." + key + ".open-with-item.lore"),p,true, true,true);
|
||||
if(temp.contains("panels." + key + ".open-with-item.stationary") && 0 <= Integer.parseInt(Objects.requireNonNull(temp.getString("panels." + key + ".open-with-item.stationary"))) && 33 >= Integer.parseInt(Objects.requireNonNull(temp.getString("panels." + key + ".open-with-item.stationary")))){
|
||||
try {
|
||||
if (Objects.requireNonNull(p.getInventory().getItem(Integer.parseInt(Objects.requireNonNull(temp.getString("panels." + key + ".open-with-item.stationary"))))).isSimilar(s)) {
|
||||
p.getInventory().setItem(Integer.parseInt(Objects.requireNonNull(temp.getString("panels." + key + ".open-with-item.stationary"))), null);
|
||||
}
|
||||
}catch(NullPointerException nex){
|
||||
//skip as player has no item in slot
|
||||
}
|
||||
}
|
||||
s = panel.getHotbarItem(p);
|
||||
if (p.getInventory().getItem(panel.getConfig().getInt("open-with-item.stationary")).isSimilar(s)) {
|
||||
p.getInventory().setItem(panel.getConfig().getInt("open-with-item.stationary"), null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,17 +1,14 @@
|
||||
package me.rockyhawk.commandpanels.panelblocks;
|
||||
|
||||
import me.rockyhawk.commandpanels.CommandPanels;
|
||||
import me.rockyhawk.commandpanels.api.Panel;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
|
||||
public class BlocksTabComplete implements TabCompleter {
|
||||
@ -21,34 +18,18 @@ public class BlocksTabComplete implements TabCompleter {
|
||||
public List<String> onTabComplete(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
if(sender instanceof Player){
|
||||
Player p = ((Player) sender).getPlayer();
|
||||
if(label.equalsIgnoreCase("cpb") || label.equalsIgnoreCase("cpanelb") || label.equalsIgnoreCase("commandpanelblock")){
|
||||
if(args.length == 2) {
|
||||
if(args[0].equals("add") && p.hasPermission("commandpanel.block.add")) {
|
||||
ArrayList<String> apanels = new ArrayList<String>(); //all panels
|
||||
String tpanels; //tpanels is the temp to check through the files
|
||||
try {
|
||||
for (String fileName : plugin.panelFiles) { //will loop through all the files in folder
|
||||
YamlConfiguration temp = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + fileName));
|
||||
String key;
|
||||
tpanels = "";
|
||||
if (!plugin.checkPanels(temp)) {
|
||||
continue;
|
||||
}
|
||||
for (Iterator var10 = Objects.requireNonNull(temp.getConfigurationSection("panels")).getKeys(false).iterator(); var10.hasNext(); tpanels = tpanels + key + " ") {
|
||||
key = (String) var10.next();
|
||||
if (!key.startsWith(args[1])) {
|
||||
for (Panel panel : plugin.panelList) { //will loop through all the files in folder
|
||||
if (!panel.getName().startsWith(args[1])) {
|
||||
//this will narrow down the panels to what the user types
|
||||
continue;
|
||||
}
|
||||
if (sender.hasPermission("commandpanel.panel." + temp.getString("panels." + key + ".perm"))) {
|
||||
if (temp.contains("panels." + key + ".disabled-worlds")) {
|
||||
List<String> disabledWorlds = temp.getStringList("panels." + key + ".disabled-worlds");
|
||||
if (!disabledWorlds.contains(p.getWorld().getName())) {
|
||||
apanels.add(key);
|
||||
}
|
||||
} else {
|
||||
apanels.add(key);
|
||||
}
|
||||
if (sender.hasPermission("commandpanel.panel." + panel.getConfig().getString("perm"))) {
|
||||
if(plugin.panelPerms.isPanelWorldEnabled(p,panel.getConfig())){
|
||||
apanels.add(panel.getName());
|
||||
}
|
||||
}
|
||||
//if file contains opened panel then start
|
||||
@ -73,7 +54,6 @@ public class BlocksTabComplete implements TabCompleter {
|
||||
return output;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
package me.rockyhawk.commandpanels.panelblocks;
|
||||
|
||||
import me.rockyhawk.commandpanels.CommandPanels;
|
||||
import me.rockyhawk.commandpanels.api.Panel;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
@ -35,8 +36,8 @@ public class Commandpanelblocks implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
boolean foundPanel = false;
|
||||
for(String[] temp : plugin.panelNames){
|
||||
if(temp[0].equals(args[1])){
|
||||
for(Panel temp : plugin.panelList){
|
||||
if(temp.getName().equals(args[1])){
|
||||
foundPanel = true;
|
||||
break;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user