v3.14.5.0

This commit is contained in:
rockyhawk64 2021-01-04 16:48:41 +11:00
parent aabdd8a839
commit e2b09581a4
9 changed files with 149 additions and 3 deletions

View File

@ -1,4 +1,4 @@
version: 3.14.4.6
version: 3.14.5.0
main: me.rockyhawk.commandpanels.CommandPanels
name: CommandPanels
author: RockyHawk

View File

@ -7,6 +7,7 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
import me.clip.placeholderapi.PlaceholderAPI;
import me.rockyhawk.commandpanels.api.CommandPanelsAPI;
import me.rockyhawk.commandpanels.classresources.*;
import me.rockyhawk.commandpanels.commands.*;
import me.rockyhawk.commandpanels.completetabs.CpTabComplete;
@ -68,6 +69,7 @@ public class CommandPanels extends JavaPlugin {
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
//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);

View File

@ -0,0 +1,41 @@
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;
public class CommandPanelsAPI {
CommandPanels plugin;
public CommandPanelsAPI(CommandPanels pl) {
this.plugin = pl;
}
//returns true if the player has a panel open
public boolean isPanelOpen(Player p){
return plugin.openPanels.hasPanelOpen(p.getName());
}
//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());
}
//will return item slots of hotbar stationary items
public ArrayList<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);
}
}

View File

@ -0,0 +1,34 @@
package me.rockyhawk.commandpanels.api;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
public class PanelCommandEvent extends Event {
private boolean isCancelled;
private Player p;
private String args;
public PanelCommandEvent(Player player, String message) {
this.p = player;
this.args = message;
}
public Player getPlayer(){
return this.p;
}
public String getMessage(){
return this.args;
}
private static final HandlerList HANDLERS = new HandlerList();
public HandlerList getHandlers() {
return HANDLERS;
}
public static HandlerList getHandlerList() {
return HANDLERS;
}
}

View File

@ -0,0 +1,50 @@
package me.rockyhawk.commandpanels.api;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
public class PanelOpenedEvent extends Event implements Cancellable {
private boolean isCancelled;
private Player p;
private ConfigurationSection cf;
private String name;
public boolean isCancelled() {
return this.isCancelled;
}
public void setCancelled(boolean isCancelled) {
this.isCancelled = isCancelled;
}
public PanelOpenedEvent(Player player, ConfigurationSection panelConfig, String panelName) {
this.p = player;
this.cf = panelConfig;
this.name = panelName;
}
public Player getPlayer(){
return this.p;
}
public ConfigurationSection getPanelConfig(){
return this.cf;
}
public String getPanelName(){
return this.name;
}
private static final HandlerList HANDLERS = new HandlerList();
public HandlerList getHandlers() {
return HANDLERS;
}
public static HandlerList getHandlerList() {
return HANDLERS;
}
}

View File

@ -4,6 +4,7 @@ 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.PanelCommandEvent;
import org.apache.commons.lang.ArrayUtils;
import org.bukkit.*;
import org.bukkit.configuration.ConfigurationSection;
@ -42,6 +43,12 @@ public class CommandTags {
p.closeInventory();
break;
}
case "event=":{
//this will broadcast an event, with args event= [args no space]
PanelCommandEvent commandEvent = new PanelCommandEvent(p,command.split("\\s")[1]);
Bukkit.getPluginManager().callEvent(commandEvent);
break;
}
case "set-data=":{
if(command.split("\\s").length == 4){
plugin.panelData.setUserData(getOffline(command.split("\\s")[3]),command.split("\\s")[1],command.split("\\s")[2],true);

View File

@ -1,6 +1,8 @@
package me.rockyhawk.commandpanels.classresources;
import me.rockyhawk.commandpanels.CommandPanels;
import me.rockyhawk.commandpanels.api.PanelOpenedEvent;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Sound;
import org.bukkit.command.CommandSender;
@ -43,12 +45,21 @@ public class ExecuteOpenVoids {
sender.sendMessage(plugin.papi(plugin.tag + plugin.config.getString("config.format.notitem")));
return;
}
//fire PanelOpenedEvent
PanelOpenedEvent openedEvent = new PanelOpenedEvent(p,cf,panelName);
Bukkit.getPluginManager().callEvent(openedEvent);
if(openedEvent.isCancelled()){
return;
}
//close the panel after the checks for permissions and worlds, so other panels can load
if(!plugin.openPanels.hasPanelOpen(p.getName()) && p.getOpenInventory().getType() != InventoryType.CRAFTING){
p.closeInventory();
}else{
plugin.openPanels.closePanelsForLoader(p.getName());
}
try {
if (cf.contains("sound-on-open")) {
//play sound when panel is opened
@ -77,6 +88,8 @@ public class ExecuteOpenVoids {
p.sendMessage(plugin.papi(plugin.tag + plugin.config.getString("config.format.error") + " " + "commands-on-open: " + cf.getString("commands-on-open")));
}
}
//open the panel
plugin.openPanels.openPanelForLoader(p.getName(), panelName, cf);
plugin.createGUI.openGui(panelName, p, cf,1,0);
if(sendOpenedMessage) {

View File

@ -7,7 +7,6 @@ import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;

View File

@ -16,7 +16,7 @@ public class HotbarItemLoader {
this.plugin = pl;
}
//stationary slots 0-8 are the hotbar, using 9-27 for inside the inventory
//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}
//will compile the ArrayList {slot 0-4, index of panelNames}