3.10.3 Fixes

This commit is contained in:
rockyhawk64 2020-08-30 17:03:57 +10:00
parent d35e45ea3e
commit c71a54c765
17 changed files with 1503 additions and 1403 deletions

View File

@ -1,4 +1,4 @@
version: 3.10.2
version: 3.10.3
main: me.rockyhawk.commandPanels.commandpanels
name: CommandPanels
author: RockyHawk

View File

@ -0,0 +1,464 @@
package me.rockyhawk.commandPanels.ClassResources;
import com.google.common.io.ByteArrayDataOutput;
import com.google.common.io.ByteStreams;
import me.realized.tokenmanager.api.TokenManager;
import me.rockyhawk.commandPanels.commandpanels;
import org.bukkit.*;
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;
public class CommandTags {
commandpanels plugin;
public CommandTags(commandpanels pl) {
this.plugin = pl;
}
public void commandTags(Player p, String command) {
String tag = plugin.config.getString("config.format.tag") + " ";
//set cp placeholders
command = plugin.papi(p, plugin.setCpPlaceholders(p, command));
if (command.split("\\s")[0].equalsIgnoreCase("server=")) {
//this contacts bungee and tells it to send the server change command
ByteArrayDataOutput out = ByteStreams.newDataOutput();
out.writeUTF("Connect");
out.writeUTF(command.split("\\s")[1]);
Player player = Bukkit.getPlayerExact(p.getName());
assert player != null;
player.sendPluginMessage(plugin, "BungeeCord", out.toByteArray());
} else if (command.split("\\s")[0].equalsIgnoreCase("open=")) {
//if player uses open= it will open the panel forced
String panelName = command.split("\\s")[1];
for(String[] tempName : plugin.panelNames){
if(tempName[0].equals(panelName)){
YamlConfiguration panelConfig = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + plugin.panelFiles.get(Integer.parseInt(tempName[1]))));
plugin.openGui(panelName, p, panelConfig, 1, 0);
return;
}
}
}else if (command.split("\\s")[0].equalsIgnoreCase("op=")) {
//if player uses op= it will perform command as op
boolean isop = p.isOp();
try {
p.setOp(true);
Bukkit.dispatchCommand(p,plugin.papi(p, command.replace("op=", "").trim()));
p.setOp(isop);
} catch (Exception exc) {
p.setOp(isop);
plugin.debug(exc);
p.sendMessage(tag + plugin.papi( plugin.config.getString("config.format.error") + " op=: Error in op command!"));
}
}else if (command.split("\\s")[0].equalsIgnoreCase("delay=")) {
//if player uses op= it will perform command as op
final int delaySeconds = Integer.parseInt(command.split("\\s")[1]);
String finalCommand = command.split("\\s",3)[2];
new BukkitRunnable() {
@Override
public void run() {
commandTags(p, finalCommand);
this.cancel();
}
}.runTaskTimer(plugin, 20*delaySeconds, 20); //20 ticks == 1 second
} else if (command.split("\\s")[0].equalsIgnoreCase("console=")) {
//if player uses console= it will perform command in the console
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), plugin.papi(p, command.replace("console=", "").trim()));
} else if (command.split("\\s")[0].equalsIgnoreCase("buy=")) {
//if player uses buy= it will be eg. buy= <price> <item> <amount of item> <ID>
try {
if (plugin.econ != null) {
if (plugin.econ.getBalance(p) >= Double.parseDouble(command.split("\\s")[1])) {
plugin.econ.withdrawPlayer(p, Double.parseDouble(command.split("\\s")[1]));
//if the message is empty don't send
if(!Objects.requireNonNull(plugin.config.getString("config.format.bought")).isEmpty()){
p.sendMessage(plugin.papi( tag + Objects.requireNonNull(plugin.config.getString("config.format.bought")).replaceAll("%cp-args%", command.split("\\s")[1])));
}
if (p.getInventory().firstEmpty() >= 0) {
p.getInventory().addItem(new ItemStack(Objects.requireNonNull(Material.matchMaterial(command.split("\\s")[2])), Integer.parseInt(command.split("\\s")[3])));
} else {
Objects.requireNonNull(p.getLocation().getWorld()).dropItemNaturally(p.getLocation(), new ItemStack(Objects.requireNonNull(Material.matchMaterial(command.split("\\s")[2])), Integer.parseInt(command.split("\\s")[3])));
}
} else {
p.sendMessage(plugin.papi( tag + plugin.config.getString("config.format.needmoney")));
}
} else {
p.sendMessage(plugin.papi( tag + ChatColor.RED + "Buying Requires Vault and an Economy to work!"));
}
} catch (Exception buy) {
plugin.debug(buy);
p.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.error") + " " + "commands: " + command));
}
} else if (command.split("\\s")[0].equalsIgnoreCase("tokenbuy=")) {
//if player uses tokenbuy= it will be eg. tokenbuy= <price> <item> <amount of item> <ID>
try {
if (plugin.getServer().getPluginManager().isPluginEnabled("TokenManager")) {
TokenManager api = (TokenManager) Bukkit.getServer().getPluginManager().getPlugin("TokenManager");
assert api != null;
int balance = Integer.parseInt(Long.toString(api.getTokens(p).orElse(0)));
if (balance >= Double.parseDouble(command.split("\\s")[1])) {
api.removeTokens(p, Long.parseLong(command.split("\\s")[1]));
//if the message is empty don't send
if(!Objects.requireNonNull(plugin.config.getString("config.format.bought")).isEmpty()) {
p.sendMessage(plugin.papi( tag + Objects.requireNonNull(plugin.config.getString("config.format.bought")).replaceAll("%cp-args%", command.split("\\s")[1])));
}
if (p.getInventory().firstEmpty() >= 0) {
p.getInventory().addItem(new ItemStack(Objects.requireNonNull(Material.matchMaterial(command.split("\\s")[2])), Integer.parseInt(command.split("\\s")[3])));
} else {
Objects.requireNonNull(p.getLocation().getWorld()).dropItemNaturally(p.getLocation(), new ItemStack(Objects.requireNonNull(Material.matchMaterial(command.split("\\s")[2])), Integer.parseInt(command.split("\\s")[3])));
}
} else {
p.sendMessage(plugin.papi( tag + plugin.config.getString("config.format.needmoney")));
}
} else {
p.sendMessage(plugin.papi( tag + ChatColor.RED + "Buying Requires TokenManager to work!"));
}
} catch (Exception buy) {
plugin.debug(buy);
p.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.error") + " " + "commands: " + command));
}
} else if (command.split("\\s")[0].equalsIgnoreCase("sell=")) {
//if player uses sell= it will be eg. sell= <cashback> <item> <amount of item> [enchanted:KNOCKBACK:1] [potion:JUMP]
try {
if (plugin.econ != null) {
boolean sold = false;
for (int f = 0; f < p.getInventory().getSize(); f++) {
ItemStack itm = p.getInventory().getItem(f);
if (itm != null && itm.getType().equals(Material.matchMaterial(command.split("\\s")[2]))) {
//determine if the command contains parameters for extensions
String potion = "false";
for(String argsTemp : command.split("\\s")){
if(argsTemp.startsWith("potion:")){
potion = argsTemp.replace("potion:","");
}
}
//check to ensure any extensions are checked
try {
if (!potion.equals("false")) {
PotionMeta potionMeta = (PotionMeta) itm.getItemMeta();
assert potionMeta != null;
if (!potionMeta.getBasePotionData().getType().name().equalsIgnoreCase(potion)) {
p.sendMessage(plugin.papi( tag + ChatColor.RED + "Your item has the wrong potion effect"));
return;
}
}
}catch(Exception exc){
//skip unless plugin.debug enabled
plugin.debug(exc);
}
if (itm.getAmount() >= new ItemStack(Objects.requireNonNull(Material.matchMaterial(command.split("\\s")[2])), Integer.parseInt(command.split("\\s")[3])).getAmount()) {
int amt = itm.getAmount() - new ItemStack(Objects.requireNonNull(Material.matchMaterial(command.split("\\s")[2])), Integer.parseInt(command.split("\\s")[3])).getAmount();
itm.setAmount(amt);
p.getInventory().setItem(f, amt > 0 ? itm : null);
plugin.econ.depositPlayer(p, Double.parseDouble(command.split("\\s")[1]));
sold = true;
p.updateInventory();
break;
}
}
}
if (!sold) {
p.sendMessage(plugin.papi( tag + plugin.config.getString("config.format.needitems")));
} else {
//if the message is empty don't send
if(!Objects.requireNonNull(plugin.config.getString("config.format.sold")).isEmpty()) {
p.sendMessage(plugin.papi( tag + Objects.requireNonNull(plugin.config.getString("config.format.sold")).replaceAll("%cp-args%", command.split("\\s")[1])));
}
}
} else {
p.sendMessage(plugin.papi( tag + ChatColor.RED + "Selling Requires Vault and an Economy to work!"));
}
} catch (Exception sell) {
plugin.debug(sell);
p.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.error") + " " + "commands: " + command));
}
} else if (command.split("\\s")[0].equalsIgnoreCase("tokensell=")) {
//if player uses tokensell= it will be eg. tokensell= <cashback> <item> <amount of item> [enchanted:KNOCKBACK:1] [potion:JUMP]
try {
if (plugin.getServer().getPluginManager().isPluginEnabled("TokenManager")) {
TokenManager api = (TokenManager) Bukkit.getServer().getPluginManager().getPlugin("TokenManager");
boolean sold = false;
for (int f = 0; f < p.getInventory().getSize(); f++) {
ItemStack itm = p.getInventory().getItem(f);
if (itm != null && itm.getType().equals(Material.matchMaterial(command.split("\\s")[2]))) {
//determine if the command contains parameters for extensions
String potion = "false";
for(String argsTemp : command.split("\\s")){
if(argsTemp.startsWith("potion:")){
potion = argsTemp.replace("potion:","");
}
}
//check to ensure any extensions are checked
try {
if (!potion.equals("false")) {
PotionMeta potionMeta = (PotionMeta) itm.getItemMeta();
assert potionMeta != null;
if (!potionMeta.getBasePotionData().getType().name().equalsIgnoreCase(potion)) {
p.sendMessage(plugin.papi( tag + ChatColor.RED + "Your item has the wrong potion effect"));
return;
}
}
}catch(Exception exc){
//skip if it cannot do unless plugin.debug is enabled
plugin.debug(exc);
}
if (itm.getAmount() >= new ItemStack(Objects.requireNonNull(Material.matchMaterial(command.split("\\s")[2])), Integer.parseInt(command.split("\\s")[3])).getAmount()) {
int amt = itm.getAmount() - new ItemStack(Objects.requireNonNull(Material.matchMaterial(command.split("\\s")[2])), Integer.parseInt(command.split("\\s")[3])).getAmount();
itm.setAmount(amt);
p.getInventory().setItem(f, amt > 0 ? itm : null);
plugin.econ.depositPlayer(p, Double.parseDouble(command.split("\\s")[1]));
assert api != null;
api.addTokens(p, Long.parseLong(command.split("\\s")[1]));
sold = true;
p.updateInventory();
break;
}
}
}
if (!sold) {
p.sendMessage(plugin.papi( tag + plugin.config.getString("config.format.needitems")));
} else {
//if the message is empty don't send
if(!Objects.requireNonNull(plugin.config.getString("config.format.sold")).isEmpty()) {
p.sendMessage(plugin.papi( tag + Objects.requireNonNull(plugin.config.getString("config.format.sold")).replaceAll("%cp-args%", command.split("\\s")[1])));
}
}
} else {
p.sendMessage(plugin.papi( tag + ChatColor.RED + "Selling Requires TokenManager to work!"));
}
} catch (Exception sell) {
plugin.debug(sell);
p.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.error") + " " + "commands: " + command));
}
} else if (command.split("\\s")[0].equalsIgnoreCase("msg=")) {
//if player uses msg= it will send the player a message
p.sendMessage(plugin.papi(p, command.replace("msg=", "").trim()));
} else if (command.split("\\s")[0].equalsIgnoreCase("sound=")) {
//if player uses sound= it will play a sound (sound= [sound])
try {
p.playSound(p.getLocation(), Sound.valueOf(command.split("\\s")[1]), 1F, 1F);
} catch (Exception s) {
plugin.debug(s);
p.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.error") + " " + "commands: " + command));
}
} else if (command.split("\\s")[0].equalsIgnoreCase("tokenbuycommand=")) {
//if player uses tokenbuycommand [price] [command]
try {
if (plugin.getServer().getPluginManager().isPluginEnabled("TokenManager")) {
TokenManager api = (TokenManager) Bukkit.getServer().getPluginManager().getPlugin("TokenManager");
assert api != null;
int balance = Integer.parseInt(Long.toString(api.getTokens(p).orElse(0)));
if (balance >= Double.parseDouble(command.split("\\s")[1])) {
api.removeTokens(p, Long.parseLong(command.split("\\s")[1]));
//execute command under here
String commandp = command;
commandp = commandp.replace("tokenbuycommand=", "").trim();
String price = commandp.split(" ", 2)[0];
commandp = commandp.split(" ", 2)[1];
commandTags(p,plugin.papi(p, commandp));
//if the message is empty don't send
if(!Objects.requireNonNull(plugin.config.getString("config.format.bought")).isEmpty()) {
p.sendMessage(plugin.papi( tag + Objects.requireNonNull(plugin.config.getString("config.format.bought")).replaceAll("%cp-args%", price)));
}
} else {
p.sendMessage(plugin.papi( tag + plugin.config.getString("config.format.needmoney")));
}
} else {
p.sendMessage(plugin.papi( tag + ChatColor.RED + "Buying Requires Vault and an Economy to work!"));
}
} catch (Exception buyc) {
plugin.debug(buyc);
p.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.error") + " " + "commands: " + command));
}
} else if (command.split("\\s")[0].equalsIgnoreCase("buycommand=")) {
//if player uses buycommand [price] [command]
try {
if (plugin.econ != null) {
if (plugin.econ.getBalance(p) >= Double.parseDouble(command.split("\\s")[1])) {
plugin.econ.withdrawPlayer(p, Double.parseDouble(command.split("\\s")[1]));
//execute command under here
String commandp = command;
commandp = commandp.replace("buycommand=", "").trim();
String price = commandp.split(" ", 2)[0];
commandp = commandp.split(" ", 2)[1];
commandTags(p,plugin.papi(p, commandp));
//if the message is empty don't send
if(!Objects.requireNonNull(plugin.config.getString("config.format.bought")).isEmpty()) {
p.sendMessage(plugin.papi( tag + Objects.requireNonNull(plugin.config.getString("config.format.bought")).replaceAll("%cp-args%", price)));
}
} else {
p.sendMessage(plugin.papi( tag + plugin.config.getString("config.format.needmoney")));
}
} else {
p.sendMessage(plugin.papi( tag + ChatColor.RED + "Buying Requires Vault and an Economy to work!"));
}
} catch (Exception buyc) {
plugin.debug(buyc);
p.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.error") + " " + "commands: " + command));
}
} else if (command.split("\\s")[0].equalsIgnoreCase("teleport=")) {
//if player uses teleport= x y z (optional other player)
if (command.split("\\s").length == 6) {
float x, y, z, yaw, pitch; //pitch is the heads Y axis and yaw is the X axis
x = Float.parseFloat(plugin.papi(p, command.split("\\s")[1]));
y = Float.parseFloat(plugin.papi(p, command.split("\\s")[2]));
z = Float.parseFloat(plugin.papi(p, command.split("\\s")[3]));
yaw = Float.parseFloat(plugin.papi(p, command.split("\\s")[4]));
pitch = Float.parseFloat(plugin.papi(p, command.split("\\s")[5]));
p.teleport(new Location(p.getWorld(), x, y, z, yaw, pitch));
} else if (command.split("\\s").length <= 4) {
float x, y, z;
x = Float.parseFloat(plugin.papi(p, command.split("\\s")[1]));
y = Float.parseFloat(plugin.papi(p, command.split("\\s")[2]));
z = Float.parseFloat(plugin.papi(p, command.split("\\s")[3]));
p.teleport(new Location(p.getWorld(), x, y, z));
} else {
try {
Player otherplayer = Bukkit.getPlayer(plugin.papi(p, command.split("\\s")[4]));
float x, y, z;
x = Float.parseFloat(plugin.papi(p, command.split("\\s")[1]));
y = Float.parseFloat(plugin.papi(p, command.split("\\s")[2]));
z = Float.parseFloat(plugin.papi(p, command.split("\\s")[3]));
assert otherplayer != null;
otherplayer.teleport(new Location(otherplayer.getWorld(), x, y, z));
} catch (Exception tpe) {
p.sendMessage(tag + plugin.config.getString("config.format.notitem"));
}
}
} else if (command.split("\\s")[0].equalsIgnoreCase("stopsound=")) {
//if player uses stopsound= [sound]
try {
p.stopSound(Sound.valueOf(command.split("\\s")[1]));
} catch (Exception ss) {
plugin.debug(ss);
p.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.error") + " " + "commands: " + command));
}
} else if (command.split("\\s")[0].equalsIgnoreCase("sudo=")) {
//if player uses sudo= [command]
p.chat(plugin.papi(p, "/" + command.replaceAll("sudo=", "").trim()));
} else {
Bukkit.dispatchCommand(p, plugin.papi(p, command));
}
}
public int commandPayWall(Player p, String command) { //return 0 means no funds, 1 is they passed and 2 means paywall is not this command
String tag = plugin.config.getString("config.format.tag") + " ";
if (command.split("\\s")[0].equalsIgnoreCase("paywall=")) {
//if player uses paywall= [price]
try {
if (plugin.econ != null) {
if (plugin.econ.getBalance(p) >= Double.parseDouble(command.split("\\s")[1])) {
plugin.econ.withdrawPlayer(p, Double.parseDouble(command.split("\\s")[1]));
//if the message is empty don't send
if(!plugin.config.getString("config.format.bought").isEmpty()) {
p.sendMessage(plugin.papi( tag + Objects.requireNonNull(plugin.config.getString("config.format.bought")).replaceAll("%cp-args%", command.split("\\s")[1])));
}
return 1;
} else {
p.sendMessage(plugin.papi( tag + plugin.config.getString("config.format.needmoney")));
return 0;
}
} else {
p.sendMessage(plugin.papi( tag + ChatColor.RED + "Paying Requires Vault and an Economy to work!"));
return 0;
}
} catch (Exception buyc) {
plugin.debug(buyc);
p.sendMessage(plugin.papi(p, tag + plugin.config.getString("config.format.error") + " " + "commands: " + command));
return 0;
}
} else if (command.split("\\s")[0].equalsIgnoreCase("tokenpaywall=")) {
//if player uses tokenpaywall= [price]
try {
if (plugin.getServer().getPluginManager().isPluginEnabled("TokenManager")) {
TokenManager api = (TokenManager) Bukkit.getServer().getPluginManager().getPlugin("TokenManager");
assert api != null;
int balance = Integer.parseInt(Long.toString(api.getTokens(p).orElse(0)));
if (balance >= Double.parseDouble(command.split("\\s")[1])) {
api.removeTokens(p, Long.parseLong(command.split("\\s")[1]));
//if the message is empty don't send
if(!Objects.requireNonNull(plugin.config.getString("config.format.bought")).isEmpty()) {
p.sendMessage(plugin.papi( tag + Objects.requireNonNull(plugin.config.getString("config.format.bought")).replaceAll("%cp-args%", command.split("\\s")[1])));
}
return 1;
} else {
p.sendMessage(plugin.papi( tag + plugin.config.getString("config.format.needmoney")));
return 0;
}
} else {
p.sendMessage(plugin.papi( tag + ChatColor.RED + "Paying TokenManager to work!"));
return 0;
}
} catch (Exception buyc) {
plugin.debug(buyc);
p.sendMessage(plugin.papi(p, tag + plugin.config.getString("config.format.error") + " " + "commands: " + command));
return 0;
}
}else if (command.split("\\s")[0].equalsIgnoreCase("item-paywall=")) {
//if player uses item-paywall= [Material] [Amount]
try {
ItemStack sellItem = new ItemStack(Objects.requireNonNull(Material.matchMaterial(command.split("\\s")[1])),Integer.parseInt(command.split("\\s")[2]));
int sellItemAmount = sellItem.getAmount();
sellItem.setAmount(1);
int removedItem = 0;
for(ItemStack content : p.getInventory().getContents()){
int contentAmount;
try {
contentAmount = content.getAmount();
}catch(NullPointerException skip){
//item is air
continue;
}
content.setAmount(1);
if(content.isSimilar(sellItem)){
if(sellItemAmount <= contentAmount){
content.setAmount(contentAmount-sellItemAmount);
p.updateInventory();
removedItem = 1;
break;
}
}
content.setAmount(contentAmount);
}
if(removedItem == 0){
p.sendMessage(plugin.papi( tag + plugin.config.getString("config.format.needmoney")));
}else{
if(!Objects.requireNonNull(plugin.config.getString("config.format.sold")).isEmpty()) {
p.sendMessage(plugin.papi( tag + plugin.config.getString("config.format.sold")));
}
}
return removedItem;
} catch (Exception buyc) {
plugin.debug(buyc);
p.sendMessage(plugin.papi(p, tag + plugin.config.getString("config.format.error") + " " + "commands: " + command));
return 0;
}
}else if (command.split("\\s")[0].equalsIgnoreCase("xp-paywall=")) {
//if player uses xp-paywall= [price]
try {
int balance = p.getLevel();
if (balance >= Integer.parseInt(command.split("\\s")[1])) {
p.setLevel(p.getLevel() - Integer.parseInt(command.split("\\s")[1]));
//if the message is empty don't send
if(!Objects.requireNonNull(plugin.config.getString("config.format.bought")).isEmpty()) {
p.sendMessage(plugin.papi( tag + Objects.requireNonNull(plugin.config.getString("config.format.bought")).replaceAll("%cp-args%", command.split("\\s")[1])));
}
return 1;
} else {
p.sendMessage(plugin.papi( tag + plugin.config.getString("config.format.needmoney")));
return 0;
}
} catch (Exception buyc) {
plugin.debug(buyc);
p.sendMessage(plugin.papi(p, tag + plugin.config.getString("config.format.error") + " " + "commands: " + command));
return 0;
}
} else {
return 2;
}
}
}

View File

@ -0,0 +1,139 @@
package me.rockyhawk.commandPanels.ClassResources;
import me.rockyhawk.commandPanels.commandpanels;
import org.bukkit.ChatColor;
import org.bukkit.Sound;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import java.util.List;
import java.util.Objects;
public class ExecuteOpenVoids {
commandpanels plugin;
public ExecuteOpenVoids(commandpanels pl) {
this.plugin = pl;
}
//this is the main method to open a panel
public void openCommandPanel(CommandSender sender, Player p, String panels, YamlConfiguration cf, boolean sendOpenedMessage){
String tag = plugin.config.getString("config.format.tag") + " ";
if (sender.hasPermission("commandpanel.panel." + cf.getString("panels." + panels + ".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("panels." + panels + ".disabled-worlds")) {
List<String> disabledWorlds = cf.getStringList("panels." + panels + ".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(tag + ChatColor.RED + "Panel is disabled in the world!"));
}
return;
}
}
}catch(NullPointerException offlinePlayer){
//SKIP because player is offline
sender.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.notitem")));
return;
}
try {
if (cf.contains("panels." + panels + ".sound-on-open")) {
//play sound when panel is opened
if(!Objects.requireNonNull(cf.getString("panels." + panels + ".sound-on-open")).equalsIgnoreCase("off")) {
try {
p.playSound(p.getLocation(), Sound.valueOf(Objects.requireNonNull(cf.getString("panels." + panels + ".sound-on-open")).toUpperCase()), 1F, 1F);
} catch (Exception s) {
p.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.error") + " " + "sound-on-open: " + cf.getString("panels." + panels + ".sound-on-open")));
}
}
}
if (cf.contains("panels." + panels + ".commands-on-open")) {
//execute commands on panel open
try {
List<String> commands = cf.getStringList("panels." + panels + ".commands-on-open");
for (int i = 0; commands.size() - 1 >= i; i++) {
int val = plugin.commandTags.commandPayWall(p,commands.get(i));
if(val == 0){
break;
}
if(val == 2){
plugin.commandTags.commandTags(p, commands.get(i));
}
}
}catch(Exception s){
p.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.error") + " " + "commands-on-open: " + cf.getString("panels." + panels + ".commands-on-open")));
}
}
plugin.openGui(panels, p, cf,1,0);
if(sendOpenedMessage) {
sender.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Panel Opened for " + p.getDisplayName()));
}
} catch (Exception r) {
plugin.debug(r);
sender.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.notitem")));
}
}else{
sender.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.perms")));
}
return;
}
sender.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.perms")));
}
//this will give a hotbar item to a player
public void giveHotbarItem(CommandSender sender, Player p, String panels, YamlConfiguration cf, boolean sendGiveMessage){
String tag = plugin.config.getString("config.format.tag") + " ";
if (sender.hasPermission("commandpanel.item." + cf.getString("panels." + panels + ".perm")) && cf.contains("panels." + panels + ".open-with-item")) {
try {
if (cf.contains("panels." + panels + ".disabled-worlds")) {
List<String> disabledWorlds = cf.getStringList("panels." + panels + ".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(tag + ChatColor.RED + "Panel is disabled in the world!"));
}
return;
}
}
}catch(NullPointerException offlinePlayer){
//SKIP because player is offline
sender.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.notitem")));
return;
}
ItemStack s;
try {
s = plugin.itemCreate.makeItemFromConfig(Objects.requireNonNull(cf.getConfigurationSection("panels." + panels + ".open-with-item")), p, false, true);
}catch(Exception n){
sender.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.error") + " open-with-item: material"));
return;
}
plugin.setName(s, cf.getString("panels." + panels + ".open-with-item.name"), cf.getStringList("panels." + panels + ".open-with-item.lore"),p,false, true);
//if the sender has OTHER perms, or if sendGiveMessage is false, implying it is not for another person
if(sender.hasPermission("commandpanel.other") || !sendGiveMessage) {
try {
if(cf.contains("panels." + panels + ".open-with-item.stationary")) {
p.getInventory().setItem(Integer.parseInt(Objects.requireNonNull(cf.getString("panels." + panels + ".open-with-item.stationary"))), s);
}else{
p.getInventory().addItem(s);
}
if(sendGiveMessage) {
sender.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Item Given to " + p.getDisplayName()));
}
} catch (Exception r) {
sender.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.notitem")));
}
}else{
sender.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.perms")));
}
return;
}
if (!cf.contains("panels." + panels + ".open-with-item")) {
sender.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.noitem")));
return;
}
sender.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.perms")));
}
}

View File

@ -1,8 +1,9 @@
package me.rockyhawk.commandPanels;
package me.rockyhawk.commandPanels.ClassResources;
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.properties.Property;
import com.mojang.authlib.properties.PropertyMap;
import me.rockyhawk.commandPanels.commandpanels;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;

View File

@ -0,0 +1,354 @@
package me.rockyhawk.commandPanels.ClassResources;
import me.arcaniax.hdb.api.HeadDatabaseAPI;
import me.rockyhawk.commandPanels.commandpanels;
import org.bukkit.*;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.*;
import org.bukkit.map.MapCanvas;
import org.bukkit.map.MapRenderer;
import org.bukkit.map.MapView;
import org.bukkit.potion.PotionData;
import org.bukkit.potion.PotionType;
import javax.swing.*;
import java.io.File;
import java.util.Objects;
import java.util.UUID;
public class ItemCreation {
commandpanels plugin;
public ItemCreation(commandpanels pl) {
plugin = pl;
}
public ItemStack makeItemFromConfig(ConfigurationSection itemSection, Player p, boolean placeholders, boolean colours){
String tag = plugin.config.getString("config.format.tag") + " ";
String material = itemSection.getString("material");
try {
if (Objects.requireNonNull(itemSection.getString("material")).equalsIgnoreCase("AIR")) {
return null;
}
}catch(NullPointerException e){
plugin.debug(e);
p.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.error") + " material: could not load material!"));
return null;
}
ItemStack s;
String mat;
String matskull;
String skullname;
//this will convert the %cp-player-online-1-find% into cps= NAME
assert material != null;
if (material.contains("%cp-player-online-")) {
int start = material.indexOf("%cp-player-online-");
int end = material.lastIndexOf("-find%");
String playerLocation = material.substring(start, end).replace("%cp-player-online-", "");
Player[] playerFind = Bukkit.getOnlinePlayers().toArray(new Player[Bukkit.getOnlinePlayers().size()]);
if (Integer.parseInt(playerLocation) > playerFind.length) {
material = material.replace(material.substring(start, end) + "-find%", "cps= " + plugin.config.getString("config.format.offlineHeadValue"));
} else {
material = material.replace(material.substring(start, end) + "-find%", "cpo= " + playerFind[Integer.parseInt(playerLocation) - 1].getName());
//cpo is to get the skull of the player online. It is fine since the plugin knows the player is online
}
}
try {
mat = material.toUpperCase();
matskull = material;
skullname = "no skull";
if (matskull.split("\\s")[0].toLowerCase().equals("cps=") || matskull.split("\\s")[0].toLowerCase().equals("cpo=")) {
skullname = p.getUniqueId().toString();
mat = "PLAYER_HEAD";
}
if (matskull.split("\\s")[0].toLowerCase().equals("hdb=")) {
skullname = "hdb";
mat = "PLAYER_HEAD";
}
s = new ItemStack(Objects.requireNonNull(Material.matchMaterial(mat)), 1);
if (!skullname.equals("no skull") && !skullname.equals("hdb") && !matskull.split("\\s")[0].equalsIgnoreCase("cpo=")) {
try {
SkullMeta meta;
if (matskull.split("\\s")[1].equalsIgnoreCase("self")) {
//if cps= self
meta = (SkullMeta) s.getItemMeta();
try {
assert meta != null;
meta.setOwningPlayer(Bukkit.getOfflinePlayer(UUID.fromString(skullname)));
} catch (Exception var23) {
p.sendMessage(plugin.papi( tag + plugin.config.getString("config.format.error") + " material: cps= self"));
plugin.debug(var23);
}
s.setItemMeta(meta);
}else if (plugin.papiNoColour(p,matskull.split("\\s")[1]).length() <= 16) {
//if cps= username
s = plugin.customHeads.getPlayerHead(plugin.papiNoColour(p,matskull.split("\\s")[1]));
} else {
//custom data cps= base64
s = plugin.customHeads.getCustomHead(plugin.papiNoColour(p,matskull.split("\\s")[1]));
}
} catch (Exception var32) {
p.sendMessage(plugin.papi( tag + plugin.config.getString("config.format.error") + " head material: Could not load skull"));
plugin.debug(var32);
}
}
if (!skullname.equals("no skull") && matskull.split("\\s")[0].equalsIgnoreCase("cpo=")) {
SkullMeta cpoMeta = (SkullMeta) s.getItemMeta();
assert cpoMeta != null;
cpoMeta.setOwningPlayer(Bukkit.getOfflinePlayer(Objects.requireNonNull(Bukkit.getPlayer(matskull.split("\\s")[1])).getUniqueId()));
s.setItemMeta(cpoMeta);
}
if (skullname.equals("hdb")) {
if (plugin.getServer().getPluginManager().isPluginEnabled("HeadDatabase")) {
HeadDatabaseAPI api;
api = new HeadDatabaseAPI();
try {
s = api.getItemHead(matskull.split("\\s")[1].trim());
} catch (Exception var22) {
p.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.error") + " hdb: could not load skull!"));
plugin.debug(var22);
}
} else {
p.sendMessage(plugin.papi(tag + "Download HeadDatabaseHook from Spigot to use this feature!"));
}
}
if (itemSection.contains("map")) {
/*
This will do maps from custom images
the maps will be in the 'maps' folder, so
CommandPanels/maps/image.png <-- here
Commandpanels/panels/example.yml
The images should be 128x128
*/
try{
@SuppressWarnings("deprecation")
MapView map = Bukkit.getServer().getMap(0);
try {
map.getRenderers().clear();
map.setCenterX(30000000);
map.setCenterZ(30000000);
}catch(NullPointerException ignore){
//ignore catch
}
if(new File(plugin.getDataFolder().getPath() + File.separator + "maps" + File.separator + itemSection.getString("map")).exists()) {
map.addRenderer(new MapRenderer() {
public void render(MapView view, MapCanvas canvas, Player player) {
canvas.drawImage(0, 0, new ImageIcon(plugin.getDataFolder().getPath() + File.separator + "maps" + File.separator + itemSection.getString("map")).getImage());
}
});
MapMeta meta = (MapMeta) s.getItemMeta();
meta.setMapView(map);
s.setItemMeta(meta);
}else{
p.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.error") + " map: File not found."));
}
}catch(Exception map){
p.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.error") + " map: " + itemSection.getString("map")));
plugin.debug(map);
}
}
if (itemSection.contains("enchanted")) {
try {
ItemMeta EnchantMeta;
if (Objects.requireNonNull(itemSection.getString("enchanted")).trim().equalsIgnoreCase("true")) {
EnchantMeta = s.getItemMeta();
assert EnchantMeta != null;
EnchantMeta.addEnchant(Enchantment.KNOCKBACK, 1, false);
EnchantMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
s.setItemMeta(EnchantMeta);
} else if (!Objects.requireNonNull(itemSection.getString("enchanted")).trim().equalsIgnoreCase("false")) {
EnchantMeta = s.getItemMeta();
assert EnchantMeta != null;
EnchantMeta.addEnchant(Objects.requireNonNull(Enchantment.getByKey(NamespacedKey.minecraft(Objects.requireNonNull(itemSection.getString("enchanted")).split("\\s")[0].toLowerCase()))), Integer.parseInt(Objects.requireNonNull(itemSection.getString("enchanted")).split("\\s")[1]), true);
s.setItemMeta(EnchantMeta);
}
} catch (Exception ench) {
p.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.error") + " enchanted: " + itemSection.getString("enchanted")));
plugin.debug(ench);
}
}
if (itemSection.contains("customdata")) {
ItemMeta customMeta = s.getItemMeta();
assert customMeta != null;
customMeta.setCustomModelData(Integer.parseInt(Objects.requireNonNull(itemSection.getString("customdata"))));
s.setItemMeta(customMeta);
}
if (itemSection.contains("leatherarmor")) {
//if the item is leather armor, change the colour to this
try {
if (s.getType() == Material.LEATHER_BOOTS || s.getType() == Material.LEATHER_LEGGINGS || s.getType() == Material.LEATHER_CHESTPLATE || s.getType() == Material.LEATHER_HELMET) {
LeatherArmorMeta leatherMeta = (LeatherArmorMeta) s.getItemMeta();
String colourCode = itemSection.getString("leatherarmor");
assert colourCode != null;
if (!colourCode.contains(",")) {
//use a color name
assert leatherMeta != null;
leatherMeta.setColor(plugin.colourCodes.get(colourCode.toUpperCase()));
} else {
//use RGB sequence
int[] colorRGB = {255, 255, 255};
int count = 0;
for (String colourNum : colourCode.split(",")) {
colorRGB[count] = Integer.parseInt(colourNum);
count += 1;
}
assert leatherMeta != null;
leatherMeta.setColor(Color.fromRGB(colorRGB[0], colorRGB[1], colorRGB[2]));
}
s.setItemMeta(leatherMeta);
}
} catch (Exception er) {
//don't colour the armor
plugin.debug(er);
p.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.error") + " leatherarmor: " + itemSection.getString("leatherarmor")));
}
}
if (itemSection.contains("potion")) {
//if the item is a potion, give it an effect
try {
PotionMeta potionMeta = (PotionMeta)s.getItemMeta();
String effectType = itemSection.getString("potion");
assert potionMeta != null;
assert effectType != null;
potionMeta.setBasePotionData(new PotionData(PotionType.valueOf(effectType.toUpperCase())));
potionMeta.addItemFlags(ItemFlag.HIDE_POTION_EFFECTS);
s.setItemMeta(potionMeta);
} catch (Exception er) {
//don't add the effect
plugin.debug(er);
p.sendMessage(plugin.papi(tag + ChatColor.RED + plugin.config.getString("config.format.error") + " potion: " + itemSection.getString("potion")));
}
}
if (itemSection.contains("damage")) {
//change the damage amount (placeholders accepted)
try {
Damageable itemDamage = (Damageable) s.getItemMeta();
itemDamage.setDamage(Integer.parseInt(Objects.requireNonNull(plugin.papi(p, itemSection.getString("damage")))));
s.setItemMeta((ItemMeta) itemDamage);
}catch(Exception e){
plugin.debug(e);
p.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.error") + " damage: " + itemSection.getString("damage")));
}
}
if (itemSection.contains("stack")) {
//change the stack amount (placeholders accepted)
s.setAmount(Integer.parseInt(Objects.requireNonNull(plugin.papi(p,itemSection.getString("stack")))));
}
} catch (IllegalArgumentException | NullPointerException var33) {
plugin.debug(var33);
p.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.error") + " material: " + itemSection.getString("material")));
return null;
}
plugin.setName(s, itemSection.getString("name"), itemSection.getStringList("lore"), p, placeholders, colours);
return s;
}
//hasperm hasvalue, etc sections will be done here
public String hasSection(ConfigurationSection cf, Player p){
if (cf.contains("hasvalue")) {
//this will do the hasvalue without any numbers
boolean outputValue = true;
//outputValue will default to true
if (cf.contains("hasvalue.output")) {
//if output is true, and values match it will be this item, vice versa
outputValue = cf.getBoolean("hasvalue.output");
}
String value = cf.getString("hasvalue.value");
String compare = ChatColor.stripColor(plugin.papi(p,plugin.setCpPlaceholders(p,cf.getString("hasvalue.compare"))));
if (compare.equals(value) == outputValue) {
//onOpen being 3 means it is the editor panel.. hasvalue items cannot be included to avoid item breaking
String section = hasSection(Objects.requireNonNull(cf.getConfigurationSection("hasvalue")), p);
//string section, it executes itself to check for subsections
return ".hasvalue" + section;
}
//loop through possible hasvalue 1,2,3,etc
for (int count = 0; cf.getKeys(false).size() > count; count++) {
if (cf.contains("hasvalue" + count)) {
outputValue = true;
//outputValue will default to true
if (cf.contains("hasvalue" + count + ".output")) {
//if output is true, and values match it will be this item, vice versa
outputValue = cf.getBoolean("hasvalue" + count + ".output");
}
value = cf.getString("hasvalue" + count + ".value");
compare = ChatColor.stripColor(plugin.papi(p,plugin.setCpPlaceholders(p,cf.getString("hasvalue" + count + ".compare"))));
if (compare.equals(value) == outputValue) {
//onOpen being 3 means it is the editor panel.. hasvalue items cannot be included to avoid item breaking
String section = hasSection(Objects.requireNonNull(cf.getConfigurationSection("hasvalue" + count)), p);
//string section, it executes itself to check for subsections
return ".hasvalue" + count + section;
}
}
}
}
if (cf.contains("hasgreater")) {
//this will do the hasgreater without any numbers
boolean outputValue = true;
//outputValue will default to true
if (cf.contains("hasgreater.output")) {
//if output is true, and values match it will be this item, vice versa
outputValue = cf.getBoolean("hasgreater.output");
}
int value = cf.getInt("hasgreater.value");
double compare = Double.parseDouble(ChatColor.stripColor(plugin.papi(p,plugin.setCpPlaceholders(p,cf.getString("hasgreater.compare")))));
if ((compare >= value) == outputValue) {
//onOpen being 3 means it is the editor panel.. hasgreater items cannot be included to avoid item breaking
String section = hasSection(Objects.requireNonNull(cf.getConfigurationSection("hasgreater")), p);
return ".hasgreater" + section;
}
//loop through possible hasgreater 1,2,3,etc
for (int count = 0; cf.getKeys(false).size() > count; count++) {
if (cf.contains("hasgreater" + count)) {
outputValue = true;
//outputValue will default to true
if (cf.contains("hasgreater" + count + ".output")) {
//if output is true, and values match it will be this item, vice versa
outputValue = cf.getBoolean("hasgreater" + count + ".output");
}
value = cf.getInt("hasgreater" + count + ".value");
compare = Double.parseDouble(ChatColor.stripColor(plugin.papi(p,plugin.setCpPlaceholders(p,cf.getString("hasgreater" + count + ".compare")))));
if ((compare >= value) == outputValue) {
//onOpen being 3 means it is the editor panel.. hasgreater items cannot be included to avoid item breaking
String section = hasSection(Objects.requireNonNull(cf.getConfigurationSection("hasgreater" + count)), p);
return ".hasgreater" + count + section;
}
}
}
}
if (cf.contains("hasperm")) {
//this will do hasperm with no numbers
boolean outputValue = true;
//outputValue will default to true
if (cf.contains("output")) {
//if output is true, and values match it will be this item, vice versa
outputValue = cf.getBoolean("output");
}
if (p.hasPermission(Objects.requireNonNull(cf.getString("hasperm.perm"))) == outputValue) {
String section = hasSection(Objects.requireNonNull(cf.getConfigurationSection("hasperm")), p);
return ".hasperm" + section;
}
for(int count = 0; cf.getKeys(false).size() > count; count++){
if (cf.contains("hasperm" + count) && cf.contains("hasperm" + count + ".perm")) {
outputValue = true;
//outputValue will default to true
if (cf.contains("hasperm" + count + ".output")) {
//if output is true, and values match it will be this item, vice versa
outputValue = cf.getBoolean("hasperm" + count + ".output");
}
if (p.hasPermission(Objects.requireNonNull(cf.getString("hasperm" + count + ".perm"))) == outputValue) {
String section = hasSection(Objects.requireNonNull(cf.getConfigurationSection("hasperm" + count)), p);
return ".hasperm" + count + section;
}
}
}
}
return "";
}
}

View File

@ -0,0 +1,485 @@
package me.rockyhawk.commandPanels.ClassResources;
import me.arcaniax.hdb.api.HeadDatabaseAPI;
import me.rockyhawk.commandPanels.commandpanels;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.SkullMeta;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
public class OpenEditorGuis {
commandpanels plugin;
public OpenEditorGuis(commandpanels pl) {
plugin = pl;
}
public void openEditorGui(Player p, int pageChange) {
Inventory i = Bukkit.createInventory(null, 54, "Command Panels Editor");
ArrayList<String> panelNames = new ArrayList<String>(); //all panels from ALL files (panel names)
ArrayList<String> panelTitles = new ArrayList<String>(); //all panels from ALL files (panel titles)
ArrayList<ItemStack> panelItems = new ArrayList<ItemStack>(); //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));
} else {
panelItems.add(new ItemStack(Material.FILLED_MAP));
}
}
}
} catch (Exception fail) {
//could not fetch all panel names (probably no panels exist)
plugin.debug(fail);
return;
}
int pageNumber = 1;
if (p.getOpenInventory().getTitle().equals("Command Panels Editor")) {
pageNumber = Integer.parseInt(ChatColor.stripColor(Objects.requireNonNull(Objects.requireNonNull(p.getOpenInventory().getItem(49)).getItemMeta()).getDisplayName()).replace("Page ", ""));
}
//will add the difference
pageNumber = pageNumber + pageChange;
if (pageNumber <= 0) {
//double check page number IS NOT under 1
pageNumber = 1;
}
//get amount of pages total
int pagesAmount = (int) Math.ceil(panelNames.size() / 45.0);
//make all the bottom bar items
ItemStack temp;
temp = new ItemStack(Material.SUNFLOWER, 1);
plugin.setName(temp, ChatColor.WHITE + "Page " + pageNumber, null, p, true, true);
i.setItem(49, temp);
temp = new ItemStack(Material.BARRIER, 1);
plugin.setName(temp, ChatColor.RED + "Exit Menu", null, p, true, true);
i.setItem(45, temp);
temp = new ItemStack(Material.BOOK, 1);
List<String> lore = new ArrayList();
lore.add(ChatColor.GRAY + "- Click on a panel to edit items.");
lore.add(ChatColor.GRAY + "- Right click on a panel to edit settings.");
lore.add(ChatColor.GRAY + "- To edit an item in a panel, shift click");
lore.add(ChatColor.GRAY + " on the item of choice.");
lore.add(ChatColor.GRAY + "- When entering a value,");
lore.add(ChatColor.GRAY + " type 'remove' to set a");
lore.add(ChatColor.GRAY + " value to default, and use");
lore.add(ChatColor.GRAY + " '" + plugin.config.getString("config.input-cancel") + "' to cancel.");
plugin.setName(temp, ChatColor.WHITE + "Panel Editor Tips", lore, p, true, true);
i.setItem(53, temp);
if (pageNumber != 1) {
//only show previous page button if number is not one
temp = new ItemStack(Material.PAPER, 1);
plugin.setName(temp, ChatColor.WHITE + "Previous Page", null, p, true, true);
i.setItem(48, temp);
}
if (pageNumber < pagesAmount) {
//if page number is under pages amount
temp = new ItemStack(Material.PAPER, 1);
plugin.setName(temp, ChatColor.WHITE + "Next Page", null, p, true, true);
i.setItem(50, temp);
}
int count = 0;
int slot = 0;
lore.clear();
for (String panelName : panelNames) {
//count is +1 because count starts at 0 not 1
if ((pageNumber * 45 - 45) < (count + 1) && (pageNumber * 45) > (count)) {
temp = panelItems.get(count);
plugin.setName(temp, ChatColor.WHITE + panelName, lore, p, false, true);
i.setItem(slot, temp);
slot += 1;
}
count += 1;
}
p.openInventory(i);
}
public void openPanelSettings(Player p, String panelName, YamlConfiguration cf) {
Inventory i = Bukkit.createInventory(null, 45, "Panel Settings: " + panelName);
List<String> lore = new ArrayList();
ItemStack temp;
//remove if the player already had a string from previously
for (int o = 0; plugin.editorInputStrings.size() > o; o++) {
if (plugin.editorInputStrings.get(o)[0].equals(p.getName())) {
plugin.editorInputStrings.remove(o);
o = o - 1;
}
}
//make all the items
temp = new ItemStack(Material.WRITABLE_BOOK, 1);
lore.add(ChatColor.GRAY + "Permission required to open panel");
lore.add(ChatColor.GRAY + "commandpanel.panel.[insert]");
if (cf.contains("panels." + panelName + ".perm")) {
lore.add(ChatColor.WHITE + "--------------------------------");
lore.add(ChatColor.WHITE + "commandpanel.panel." + cf.getString("panels." + panelName + ".perm"));
}
plugin.setName(temp, ChatColor.WHITE + "Panel Permission", lore, p,true, true);
i.setItem(1, temp);
temp = new ItemStack(Material.NAME_TAG, 1);
lore.clear();
lore.add(ChatColor.GRAY + "Title of the Panel");
if (cf.contains("panels." + panelName + ".title")) {
lore.add(ChatColor.WHITE + "------------------");
lore.add(ChatColor.WHITE + cf.getString("panels." + panelName + ".title"));
}
plugin.setName(temp, ChatColor.WHITE + "Panel Title", lore, p,true, true);
i.setItem(3, temp);
temp = new ItemStack(Material.JUKEBOX, 1);
lore.clear();
lore.add(ChatColor.GRAY + "Sound when opening panel");
if (cf.contains("panels." + panelName + ".sound-on-open")) {
lore.add(ChatColor.WHITE + "------------------------");
lore.add(ChatColor.WHITE + Objects.requireNonNull(cf.getString("panels." + panelName + ".sound-on-open")).toUpperCase());
}
plugin.setName(temp, ChatColor.WHITE + "Panel Sound", lore, p,true, true);
i.setItem(5, temp);
temp = new ItemStack(Material.IRON_DOOR, 1);
lore.clear();
lore.add(ChatColor.GRAY + "Custom command to open panel");
if (cf.contains("panels." + panelName + ".command")) {
lore.add(ChatColor.WHITE + "----------------------------");
lore.add(ChatColor.WHITE + cf.getString("panels." + panelName + ".command"));
}
plugin.setName(temp, ChatColor.WHITE + "Panel Command", lore, p,true, true);
i.setItem(7, temp);
temp = new ItemStack(Material.LAVA_BUCKET, 1);
lore.clear();
lore.add(ChatColor.DARK_RED + "Permanently delete Panel");
plugin.setName(temp, ChatColor.RED + "Delete Panel", lore, p,true, true);
i.setItem(21, temp);
temp = new ItemStack(Material.PISTON, 1);
lore.clear();
lore.add(ChatColor.GRAY + "How many rows the panel will be");
lore.add(ChatColor.GRAY + "choose an integer from 1 to 6");
plugin.setName(temp, ChatColor.WHITE + "Panel Rows", lore, p,true, true);
i.setItem(23, temp);
temp = new ItemStack(Material.BLACK_STAINED_GLASS, 1);
lore.clear();
lore.add(ChatColor.GRAY + "Fill empty slots with an item");
if (cf.contains("panels." + panelName + ".empty")) {
lore.add(ChatColor.WHITE + "-----------------------");
lore.add(ChatColor.WHITE + Objects.requireNonNull(cf.getString("panels." + panelName + ".empty")).toUpperCase());
}
plugin.setName(temp, ChatColor.WHITE + "Panel Empty Item", lore, p,true, true);
i.setItem(13, temp);
temp = new ItemStack(Material.COMMAND_BLOCK, 1);
lore.clear();
lore.add(ChatColor.GRAY + "Execute commands when opening");
lore.add(ChatColor.GRAY + "- Left click to add command");
lore.add(ChatColor.GRAY + "- Right click to remove command");
if (cf.contains("panels." + panelName + ".commands-on-open")) {
lore.add(ChatColor.WHITE + "-----------------------------");
int count = 1;
for (String tempLore : cf.getStringList("panels." + panelName + ".commands-on-open")) {
lore.add(ChatColor.WHITE + Integer.toString(count) + ") " + tempLore);
count += 1;
}
}
plugin.setName(temp, ChatColor.WHITE + "Panel Commands", lore, p,true, true);
i.setItem(15, temp);
temp = new ItemStack(Material.ITEM_FRAME, 1);
lore.clear();
lore.add(ChatColor.GRAY + "Code name to open panel");
lore.add(ChatColor.GRAY + "/cp [name]");
lore.add(ChatColor.WHITE + "-----------------------");
lore.add(ChatColor.WHITE + panelName);
plugin.setName(temp, ChatColor.WHITE + "Panel Name", lore, p,true, true);
i.setItem(11, temp);
temp = new ItemStack(Material.BARRIER, 1);
plugin.setName(temp, ChatColor.RED + "Back", null, p,true, true);
i.setItem(18, temp);
//This will create a wall of glass panes, separating panel settings with hotbar settings
temp = new ItemStack(Material.BLACK_STAINED_GLASS_PANE, 1);
plugin.setName(temp, ChatColor.WHITE + "", null, p,false, true);
for(int d = 27; d < 36; d++){
i.setItem(d, temp);
}
//This is the items for hotbar items (open-with-item)
boolean hotbarItems = false;
if(cf.contains("panels." + panelName + ".open-with-item.material")){
hotbarItems = true;
temp = plugin.itemCreate.makeItemFromConfig(cf.getConfigurationSection("panels." + panelName + ".open-with-item"), p, false, true);
}else{
temp = new ItemStack(Material.REDSTONE_BLOCK, 1);
}
lore.clear();
lore.add(ChatColor.GRAY + "Current Item");
if (cf.contains("panels." + panelName + ".open-with-item.material")) {
lore.add(ChatColor.WHITE + "-----------------------");
lore.add(ChatColor.WHITE + Objects.requireNonNull(cf.getString("panels." + panelName + ".open-with-item.material")).toUpperCase());
}else{
lore.add(ChatColor.WHITE + "-----------------------");
lore.add(ChatColor.RED + "DISABLED");
}
plugin.setName(temp, ChatColor.WHITE + "Panel Hotbar Item", lore, p,true, true);
i.setItem(40, temp);
if(hotbarItems) {
temp = new ItemStack(Material.NAME_TAG, 1);
lore.clear();
lore.add(ChatColor.GRAY + "Name for Hotbar item");
if (cf.contains("panels." + panelName + ".open-with-item.name")) {
lore.add(ChatColor.WHITE + "----------");
lore.add(ChatColor.WHITE + Objects.requireNonNull(cf.getString("panels." + panelName + ".open-with-item.name")));
}
plugin.setName(temp, ChatColor.WHITE + "Hotbar Item Name", lore, p, true, true);
i.setItem(38, temp);
temp = new ItemStack(Material.SPRUCE_SIGN, 1);
lore.clear();
lore.add(ChatColor.GRAY + "Display a lore under the Hotbar item");
lore.add(ChatColor.GRAY + "- Left click to add lore");
lore.add(ChatColor.GRAY + "- Right click to remove lore");
if (cf.contains("panels." + panelName + ".open-with-item.lore")) {
lore.add(ChatColor.WHITE + "-------------------------------");
int count = 1;
for (String tempLore : cf.getStringList("panels." + panelName + ".open-with-item.lore")) {
lore.add(ChatColor.WHITE + Integer.toString(count) + ") " + tempLore);
count += 1;
}
}
plugin.setName(temp, ChatColor.WHITE + "Hotbar Lore", lore, p,true, true);
i.setItem(36, temp);
temp = new ItemStack(Material.BEDROCK, 1);
lore.clear();
lore.add(ChatColor.GRAY + "Hotbar location for the item");
lore.add(ChatColor.GRAY + "choose a number from 1 to 9");
if (cf.contains("panels." + panelName + ".open-with-item.stationary")) {
lore.add(ChatColor.WHITE + "-------------------------");
//in the editor, change the value of 0-8 to 1-9 for simplicity
int location = cf.getInt("panels." + panelName + ".open-with-item.stationary") + 1;
lore.add(ChatColor.WHITE + String.valueOf(location));
}
plugin.setName(temp, ChatColor.WHITE + "Hotbar Item Location", lore, p, true, true);
i.setItem(42, temp);
temp = new ItemStack(Material.BOOK, 1);
lore.clear();
lore.add(ChatColor.GRAY + "- To refresh changes use");
lore.add(ChatColor.GRAY + " /cp " + panelName + " item");
lore.add(ChatColor.GRAY + "- Hotbar items will need a");
lore.add(ChatColor.GRAY + " name to work properly.");
plugin.setName(temp, ChatColor.WHITE + "Hotbar Item Tips", lore, p, true, true);
i.setItem(44, temp);
}
p.openInventory(i);
}
public void openItemSettings(Player p, String panelName, YamlConfiguration cf, int itemNumber) {
Inventory i = Bukkit.createInventory(null, 36, "Item Settings: " + panelName);
List<String> lore = new ArrayList();
ItemStack temp;
//remove if the player already had a string from previously
for (int o = 0; plugin.editorInputStrings.size() > o; o++) {
if (plugin.editorInputStrings.get(o)[0].equals(p.getName())) {
plugin.editorInputStrings.remove(o);
o = o - 1;
}
}
//make all the items
temp = new ItemStack(Material.NAME_TAG, 1);
lore.add(ChatColor.GRAY + "Display name of the item in the Panel");
if (cf.contains("panels." + panelName + ".item." + itemNumber + ".name")) {
if (!Objects.equals(cf.getString("panels." + panelName + ".item." + itemNumber + ".name"), "")) {
lore.add(ChatColor.WHITE + "--------------------------------");
lore.add(ChatColor.WHITE + cf.getString("panels." + panelName + ".item." + itemNumber + ".name"));
}
}
plugin.setName(temp, ChatColor.WHITE + "Item Name", lore, p,true, true);
i.setItem(1, temp);
temp = new ItemStack(Material.COMMAND_BLOCK, 1);
lore.clear();
lore.add(ChatColor.GRAY + "Execute commands when item is clicked");
lore.add(ChatColor.GRAY + "- Left click to add command");
lore.add(ChatColor.GRAY + "- Right click to remove command");
if (cf.contains("panels." + panelName + ".item." + itemNumber + ".commands")) {
lore.add(ChatColor.WHITE + "-----------------------------");
int count = 1;
for (String tempLore : cf.getStringList("panels." + panelName + ".item." + itemNumber + ".commands")) {
lore.add(ChatColor.WHITE + Integer.toString(count) + ") " + tempLore);
count += 1;
}
}
plugin.setName(temp, ChatColor.WHITE + "Item Commands", lore, p,true, true);
i.setItem(3, temp);
temp = new ItemStack(Material.EXPERIENCE_BOTTLE, 1);
lore.clear();
lore.add(ChatColor.GRAY + "Display enchantment of the item in the Panel");
if (cf.contains("panels." + panelName + ".item." + itemNumber + ".enchanted")) {
if (!Objects.equals(cf.getString("panels." + panelName + ".item." + itemNumber + ".name"), "")) {
lore.add(ChatColor.WHITE + "--------------------------------");
lore.add(ChatColor.WHITE + cf.getString("panels." + panelName + ".item." + itemNumber + ".enchanted"));
}
} else {
lore.add(ChatColor.WHITE + "--------------------------------");
lore.add(ChatColor.WHITE + "false");
}
plugin.setName(temp, ChatColor.WHITE + "Item Enchantment", lore, p,true, true);
i.setItem(5, temp);
temp = new ItemStack(Material.POTION, 1);
lore.clear();
lore.add(ChatColor.GRAY + "Display potion effect of the item in the Panel");
if (cf.contains("panels." + panelName + ".item." + itemNumber + ".potion")) {
if (!Objects.equals(cf.getString("panels." + panelName + ".item." + itemNumber + ".potion"), "")) {
lore.add(ChatColor.WHITE + "--------------------------------");
lore.add(ChatColor.WHITE + cf.getString("panels." + panelName + ".item." + itemNumber + ".potion"));
}
}
plugin.setName(temp, ChatColor.WHITE + "Item Potion Effect", lore, p,true, true);
i.setItem(7, temp);
temp = new ItemStack(Material.SPRUCE_SIGN, 1);
lore.clear();
lore.add(ChatColor.GRAY + "Display a lore under the item name");
lore.add(ChatColor.GRAY + "- Left click to add lore line");
lore.add(ChatColor.GRAY + "- Right click to remove lore line");
if (cf.contains("panels." + panelName + ".item." + itemNumber + ".lore")) {
lore.add(ChatColor.WHITE + "-----------------------------");
int count = 1;
for (String tempLore : cf.getStringList("panels." + panelName + ".item." + itemNumber + ".lore")) {
lore.add(ChatColor.WHITE + Integer.toString(count) + ") " + tempLore);
count += 1;
}
}
plugin.setName(temp, ChatColor.WHITE + "Item Lores", lore, p, true, true);
i.setItem(19, temp);
temp = new ItemStack(Material.ITEM_FRAME, 2);
lore.clear();
lore.add(ChatColor.GRAY + "How many of the item will be stacked");
if (cf.contains("panels." + panelName + ".item." + itemNumber + ".stack")) {
if (!Objects.equals(cf.getString("panels." + panelName + ".item." + itemNumber + ".stack"), "")) {
try {
temp.setAmount(Integer.parseInt(Objects.requireNonNull(cf.getString("panels." + panelName + ".item." + itemNumber + ".stack"))));
} catch (Exception ignored) {
}
lore.add(ChatColor.WHITE + "--------------------------------");
lore.add(ChatColor.WHITE + cf.getString("panels." + panelName + ".item." + itemNumber + ".stack"));
}
}
plugin.setName(temp, ChatColor.WHITE + "Item Stack Size", lore, p, true, true);
i.setItem(21, temp);
temp = new ItemStack(Material.ANVIL, 1);
lore.clear();
lore.add(ChatColor.GRAY + "Add Custom Model Data here");
if (cf.contains("panels." + panelName + ".item." + itemNumber + ".customdata")) {
if (!Objects.equals(cf.getString("panels." + panelName + ".item." + itemNumber + ".customdata"), "")) {
lore.add(ChatColor.WHITE + "--------------------------------");
lore.add(ChatColor.WHITE + cf.getString("panels." + panelName + ".item." + itemNumber + ".customdata"));
}
}
plugin.setName(temp, ChatColor.WHITE + "Custom Model Data", lore, p, true, true);
i.setItem(23, temp);
temp = new ItemStack(Material.LEATHER_HELMET, 1);
lore.clear();
lore.add(ChatColor.GRAY + "Choose a colour for the armor");
lore.add(ChatColor.GRAY + "use r,g,b or a spigot API color");
if (cf.contains("panels." + panelName + ".item." + itemNumber + ".leatherarmor")) {
if (!Objects.equals(cf.getString("panels." + panelName + ".item." + itemNumber + ".leatherarmor"), "")) {
lore.add(ChatColor.WHITE + "--------------------------------");
lore.add(ChatColor.WHITE + cf.getString("panels." + panelName + ".item." + itemNumber + ".leatherarmor"));
}
}
plugin.setName(temp, ChatColor.WHITE + "Leather Armor Colour", lore, p, true, true);
i.setItem(25, temp);
temp = new ItemStack(Material.BARRIER, 1);
plugin.setName(temp, ChatColor.RED + "Back", null, p, true, true);
i.setItem(27, temp);
if(Objects.requireNonNull(cf.getString("panels." + panelName + ".item." + itemNumber + ".material")).startsWith("cps=")){
temp = new ItemStack(Material.PLAYER_HEAD, 1);
if(Objects.requireNonNull(cf.getString("panels." + panelName + ".item." + itemNumber + ".material")).equalsIgnoreCase("cps= self")){
//if self
SkullMeta meta = (SkullMeta) temp.getItemMeta();
try {
assert meta != null;
meta.setOwningPlayer(Bukkit.getOfflinePlayer(p.getUniqueId()));
} catch (Exception var23) {
plugin.debug(var23);
}
temp.setItemMeta(meta);
}else{
//custom head
temp = plugin.customHeads.getCustomHead(Objects.requireNonNull(cf.getString("panels." + panelName + ".item." + itemNumber + ".material")).replace("cps=", "").trim());
}
}else if (Objects.requireNonNull(cf.getString("panels." + panelName + ".item." + itemNumber + ".material")).startsWith("%cp-player-online-")){
//leave default for the find material tag
temp = new ItemStack(Material.PLAYER_HEAD, 1);
}else if (Objects.requireNonNull(cf.getString("panels." + panelName + ".item." + itemNumber + ".material")).startsWith("hdb=")){
//head database head
temp = new ItemStack(Material.PLAYER_HEAD, 1);
if (plugin.getServer().getPluginManager().isPluginEnabled("HeadDatabase")) {
HeadDatabaseAPI api;
api = new HeadDatabaseAPI();
try {
temp = api.getItemHead(Objects.requireNonNull(cf.getString("panels." + panelName + ".item." + itemNumber + ".material")).replace("hdb=", "").trim());
} catch (Exception var22) {
plugin.debug(var22);
}
}
}else{
temp = new ItemStack(Objects.requireNonNull(Material.matchMaterial(Objects.requireNonNull(cf.getString("panels." + panelName + ".item." + itemNumber + ".material")))), 1);
}
try {
temp.setAmount(Integer.parseInt(Objects.requireNonNull(cf.getString("panels." + panelName + ".item." + itemNumber + ".stack"))));
} catch (Exception ex) {
//skip
}
if (cf.contains("panels." + panelName + ".item." + itemNumber + ".enchanted")) {
if (!Objects.equals(cf.getString("panels." + panelName + ".item." + itemNumber + ".enchanted"), "false")) {
ItemMeta EnchantMeta;
EnchantMeta = temp.getItemMeta();
assert EnchantMeta != null;
EnchantMeta.addEnchant(Enchantment.KNOCKBACK, 1, true);
EnchantMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
temp.setItemMeta(EnchantMeta);
}
}
lore.clear();
lore.add(ChatColor.GRAY + "Click to set custom material");
lore.add(ChatColor.GRAY + "typically for custom heads");
plugin.setName(temp, ChatColor.WHITE + "Item Slot " + itemNumber + " Preview", lore, p, true, true);
i.setItem(35, temp);
p.openInventory(i);
}
}

File diff suppressed because it is too large Load Diff

View File

@ -74,7 +74,7 @@ public class commandpanel implements CommandExecutor {
//do console command command
if(args.length == 2){
if(!args[1].equals("item")){
plugin.openCommandPanel(sender,plugin.getServer().getPlayer(args[1]),panels,cf,true);
plugin.openVoids.openCommandPanel(sender,plugin.getServer().getPlayer(args[1]),panels,cf,true);
return true;
}else{
sender.sendMessage(plugin.papi(tag + ChatColor.RED + "Usage: /cp <panel> [item] [player]"));
@ -82,7 +82,7 @@ public class commandpanel implements CommandExecutor {
}
}else if(args.length == 3){
if (args[1].equals("item")) {
plugin.giveHotbarItem(sender,plugin.getServer().getPlayer(args[2]),panels,cf,true);
plugin.openVoids.giveHotbarItem(sender,plugin.getServer().getPlayer(args[2]),panels,cf,true);
return true;
}else{
sender.sendMessage(plugin.papi(tag + ChatColor.RED + "Usage: /cp <panel> item [player]"));
@ -97,17 +97,17 @@ public class commandpanel implements CommandExecutor {
Player p = (Player) sender;
//do player command
if (args.length == 1) {
plugin.openCommandPanel(sender, p, panels, cf,false);
plugin.openVoids.openCommandPanel(sender, p, panels, cf,false);
return true;
}else if(args.length == 2){
if (args[1].equals("item")) {
plugin.giveHotbarItem(sender, p, panels, cf, false);
plugin.openVoids.giveHotbarItem(sender, p, panels, cf, false);
}else{
plugin.openCommandPanel(sender, plugin.getServer().getPlayer(args[1]), panels, cf,true);
plugin.openVoids.openCommandPanel(sender, plugin.getServer().getPlayer(args[1]), panels, cf,true);
}
return true;
}else if(args.length == 3){
plugin.giveHotbarItem(sender, plugin.getServer().getPlayer(args[2]), panels, cf,true);
plugin.openVoids.giveHotbarItem(sender, plugin.getServer().getPlayer(args[2]), panels, cf,true);
return true;
}
}

View File

@ -67,7 +67,7 @@ public class commandpanelcustom implements Listener {
}
e.setCancelled(true);
try {
plugin.openCommandPanel(p,p,panel,cf,false);
plugin.openVoids.openCommandPanel(p,p,panel,cf,false);
}catch(Exception er){
//do nothing
p.sendMessage(plugin.papi(tag + ChatColor.RED + "Error opening panel!"));

View File

@ -16,6 +16,7 @@ import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.PotionMeta;
import org.bukkit.inventory.meta.SkullMeta;
import java.io.File;
import java.io.IOException;
@ -52,6 +53,7 @@ public class newGenUtils implements Listener {
}
}
}
@EventHandler
public void onInventoryOpenEvent(InventoryOpenEvent e) {
HumanEntity h = e.getPlayer();
@ -61,6 +63,8 @@ public class newGenUtils implements Listener {
generatePanel(p,e.getInventory());
}
}
@SuppressWarnings("deprecation")
void generatePanel(Player p, Inventory inv){
ItemStack[] cont = inv.getContents();
String tag = plugin.config.getString("config.format.tag") + " ";
@ -101,8 +105,13 @@ public class newGenUtils implements Listener {
try{
//make the item here
if(cont[i].getType() == Material.PLAYER_HEAD){
SkullMeta meta = (SkullMeta) cont[i].getItemMeta();
if(plugin.getHeadBase64(cont[i]) != null){
//check for base64
file.addDefault("panels." + date + ".item." + i + ".material", "cps= " + plugin.getHeadBase64(cont[i]));
}else if(meta.hasOwner()){
//check for skull owner
file.addDefault("panels." + date + ".item." + i + ".material", "cps= " + meta.getOwner());
}else{
file.addDefault("panels." + date + ".item." + i + ".material", cont[i].getType().toString());
}

View File

@ -111,7 +111,7 @@ public class cpIngameEditCommand implements CommandExecutor {
return true;
}
if (args.length == 0) {
plugin.openEditorGui(p,0);
plugin.editorGuis.openEditorGui(p,0);
return true;
}
if (args.length == 1) {

View File

@ -69,7 +69,7 @@ public class editorUserInput implements Listener {
if(section.startsWith("panel.")){
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
public void run() {
plugin.openEditorGui(p, 0); //I have to do this to run regular Bukkit voids in an ASYNC Event
plugin.editorGuis.openEditorGui(p, 0); //I have to do this to run regular Bukkit voids in an ASYNC Event
}
});
}else if(section.startsWith("item.")) {

View File

@ -11,6 +11,7 @@ import org.bukkit.event.inventory.*;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryView;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.SkullMeta;
import java.io.File;
import java.io.IOException;
@ -67,7 +68,7 @@ public class editorUtils implements Listener {
//previous page button
try {
if (Objects.requireNonNull(e.getCurrentItem()).getType() == Material.PAPER) {
plugin.openEditorGui(p, -1);
plugin.editorGuis.openEditorGui(p, -1);
p.updateInventory();
return;
}
@ -84,7 +85,7 @@ public class editorUtils implements Listener {
//next page button
try{
if(Objects.requireNonNull(e.getCurrentItem()).getType() == Material.PAPER){
plugin.openEditorGui(p, 1);
plugin.editorGuis.openEditorGui(p, 1);
p.updateInventory();
return;
}
@ -115,7 +116,7 @@ public class editorUtils implements Listener {
int count = 0;
for(String panelName : panelNames){
if(panelName.equals(ChatColor.stripColor(Objects.requireNonNull(e.getCurrentItem().getItemMeta()).getDisplayName()))){
plugin.openPanelSettings(p,panelName,panelYaml.get(count));
plugin.editorGuis.openPanelSettings(p,panelName,panelYaml.get(count));
return;
}
count +=1;
@ -251,7 +252,7 @@ public class editorUtils implements Listener {
inventoryItemSettingsOpening.add(p.getName());
//refresh the yaml config
file = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + fileName));
plugin.openItemSettings(p,panelName,file,e.getSlot());
plugin.editorGuis.openItemSettings(p,panelName,file,e.getSlot());
return;
}
if(tempEdit.contains("panels." + panelName + ".temp." + p.getName() + ".material")) {
@ -405,7 +406,7 @@ public class editorUtils implements Listener {
p.closeInventory();
}
if(e.getSlot() == 18){
plugin.openEditorGui(p,0);
plugin.editorGuis.openEditorGui(p,0);
p.updateInventory();
}
if(e.getSlot() == 40){
@ -576,6 +577,8 @@ public class editorUtils implements Listener {
plugin.debug(s);
}
}
@SuppressWarnings("deprecation")
public void onEditPanelClose(Player p, Inventory inv, InventoryView invView) {
String tag = plugin.config.getString("config.format.tag") + " ";
if(inv.getType() != InventoryType.CHEST){
@ -645,6 +648,11 @@ public class editorUtils implements Listener {
if(plugin.getHeadBase64(cont) != null){
file.set("panels." + panelName + ".item." + i + ".material", "cps= " + plugin.getHeadBase64(cont));
}
//check for skull owner
SkullMeta meta = (SkullMeta) cont.getItemMeta();
if(meta.hasOwner()){
file.set("panels." + panelName + ".item." + i + ".material", "cps= " + meta.getOwner());
}
}
if(cont.getAmount() != 1){
file.set("panels." + panelName + ".item." + i + ".stack", cont.getAmount());

View File

@ -43,14 +43,14 @@ public class utilsOpenWithItem implements Listener {
if(tempFile.contains("panels." + tempName + ".open-with-item") && Objects.requireNonNull(e.getClickedInventory()).getType() == InventoryType.PLAYER) {
try{
assert clicked != null;
if (clicked.getType() == new ItemStack(Objects.requireNonNull(plugin.makeItemFromConfig(Objects.requireNonNull(tempFile.getConfigurationSection("panels." + tempName + ".open-with-item")), p, false, true).getType()), 1).getType()) {
if (clicked.getType() == new ItemStack(Objects.requireNonNull(plugin.itemCreate.makeItemFromConfig(Objects.requireNonNull(tempFile.getConfigurationSection("panels." + tempName + ".open-with-item")), p, false, true).getType()), 1).getType()) {
if ((plugin.papi( Objects.requireNonNull(clicked.getItemMeta()).getDisplayName()).equals(plugin.papi( Objects.requireNonNull(tempFile.getString("panels." + tempName + ".open-with-item.name")))))) {
//cancel the click item event
if (tempFile.contains("panels." + tempName + ".open-with-item.stationary")) {
if (e.getSlot() == Integer.parseInt(Objects.requireNonNull(tempFile.getString("panels." + tempName + ".open-with-item.stationary")))) {
e.setCancelled(true);
p.updateInventory();
plugin.openCommandPanel(p,p,tempName,tempFile,false);
plugin.openVoids.openCommandPanel(p,p,tempName,tempFile,false);
return;
}
}
@ -90,7 +90,7 @@ public class utilsOpenWithItem implements Listener {
if(tempFile.contains("panels." + tempName + ".open-with-item")) {
try{
assert clicked != null;
if (clicked.getType() == new ItemStack(Objects.requireNonNull(plugin.makeItemFromConfig(Objects.requireNonNull(tempFile.getConfigurationSection("panels." + tempName + ".open-with-item")), p, false, true).getType()), 1).getType()) {
if (clicked.getType() == new ItemStack(Objects.requireNonNull(plugin.itemCreate.makeItemFromConfig(Objects.requireNonNull(tempFile.getConfigurationSection("panels." + tempName + ".open-with-item")), p, false, true).getType()), 1).getType()) {
if ((plugin.papi( Objects.requireNonNull(clicked.getItemMeta()).getDisplayName()).equals(plugin.papi(Objects.requireNonNull(tempFile.getString("panels." + tempName + ".open-with-item.name")))))) {
//cancel the click item event
if (tempFile.contains("panels." + tempName + ".open-with-item.stationary")) {
@ -100,7 +100,7 @@ public class utilsOpenWithItem implements Listener {
}
e.setCancelled(true);
p.updateInventory();
plugin.openCommandPanel(p,p,tempName,tempFile,false);
plugin.openVoids.openCommandPanel(p,p,tempName,tempFile,false);
return;
}
}
@ -152,7 +152,7 @@ public class utilsOpenWithItem implements Listener {
}
}
if (p.hasPermission("commandpanel.panel." + temp.getString("panels." + key + ".perm")) && temp.contains("panels." + key + ".open-with-item")) {
ItemStack s = plugin.makeItemFromConfig(Objects.requireNonNull(temp.getConfigurationSection("panels." + key + ".open-with-item")), p, false, true);
ItemStack s = plugin.itemCreate.makeItemFromConfig(Objects.requireNonNull(temp.getConfigurationSection("panels." + key + ".open-with-item")), p, false, true);
if(temp.contains("panels." + key + ".open-with-item.stationary")) {
if (0 <= Integer.parseInt(Objects.requireNonNull(temp.getString("panels." + key + ".open-with-item.stationary"))) && 8 >= 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);
@ -194,7 +194,7 @@ public class utilsOpenWithItem implements Listener {
}
}
if (p.hasPermission("commandpanel.panel." + temp.getString("panels." + key + ".perm")) && temp.contains("panels." + key + ".open-with-item")) {
ItemStack s = plugin.makeItemFromConfig(Objects.requireNonNull(temp.getConfigurationSection("panels." + key + ".open-with-item")), p, false, true);
ItemStack s = plugin.itemCreate.makeItemFromConfig(Objects.requireNonNull(temp.getConfigurationSection("panels." + key + ".open-with-item")), p, false, true);
if(temp.contains("panels." + key + ".open-with-item.stationary") && 0 <= Integer.parseInt(Objects.requireNonNull(temp.getString("panels." + key + ".open-with-item.stationary"))) && 8 >= 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);
}
@ -228,7 +228,7 @@ public class utilsOpenWithItem implements Listener {
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.makeItemFromConfig(Objects.requireNonNull(temp.getConfigurationSection("panels." + key + ".open-with-item")), p, false, true);
ItemStack s = plugin.itemCreate.makeItemFromConfig(Objects.requireNonNull(temp.getConfigurationSection("panels." + key + ".open-with-item")), p, false, true);
e.getDrops().remove(s);
}
}
@ -266,7 +266,7 @@ public class utilsOpenWithItem implements Listener {
continue;
}
}
ItemStack s = plugin.makeItemFromConfig(Objects.requireNonNull(temp.getConfigurationSection("panels." + key + ".open-with-item")), p, false, true);
ItemStack s = plugin.itemCreate.makeItemFromConfig(Objects.requireNonNull(temp.getConfigurationSection("panels." + key + ".open-with-item")), p, false, true);
if(temp.contains("panels." + key + ".open-with-item.stationary") && 0 <= Integer.parseInt(Objects.requireNonNull(temp.getString("panels." + key + ".open-with-item.stationary"))) && 8 >= 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);
}
@ -314,7 +314,7 @@ public class utilsOpenWithItem implements Listener {
if(tempFile.contains("panels." + tempName + ".open-with-item")) {
try{
assert clicked != null;
if (clicked.getType() == new ItemStack(Objects.requireNonNull(plugin.makeItemFromConfig(Objects.requireNonNull(tempFile.getConfigurationSection("panels." + tempName + ".open-with-item")), p, false, true).getType()), 1).getType()) {
if (clicked.getType() == new ItemStack(Objects.requireNonNull(plugin.itemCreate.makeItemFromConfig(Objects.requireNonNull(tempFile.getConfigurationSection("panels." + tempName + ".open-with-item")), p, false, true).getType()), 1).getType()) {
if ((plugin.papi( Objects.requireNonNull(clicked.getItemMeta()).getDisplayName()).equals(plugin.papi( Objects.requireNonNull(tempFile.getString("panels." + tempName + ".open-with-item.name")))))) {
//cancel the click item event
if (tempFile.contains("panels." + tempName + ".open-with-item.stationary")) {

View File

@ -46,7 +46,7 @@ public class panelBlockOnClick implements Listener {
cf = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + plugin.panelFiles.get(Integer.parseInt(temp[1]))));
}
}
plugin.openCommandPanel(p,p,panelName,cf,false);
plugin.openVoids.openCommandPanel(p,p,panelName,cf,false);
return;
}
}

View File

@ -1,7 +1,7 @@
package me.rockyhawk.commandPanels.premium;
import me.rockyhawk.commandPanels.ClassResources.CommandTags;
import me.rockyhawk.commandPanels.commandpanels;
import org.bukkit.ChatColor;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.AsyncPlayerChatEvent;
@ -35,7 +35,7 @@ public class commandpanelUserInput implements Listener {
e.setCancelled(true);
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
public void run() {
plugin.commandTags(e.getPlayer(), command); //I have to do this to run regular Bukkit voids in an ASYNC Event
new CommandTags(plugin).commandTags(e.getPlayer(), command); //I have to do this to run regular Bukkit voids in an ASYNC Event
}
});
}

View File

@ -90,7 +90,7 @@ public class utils implements Listener {
return;
}
//loop through possible hasvalue/hasperm 1,2,3,etc
String section = plugin.hasSection(cf.getConfigurationSection("panels." + panel + ".item." + e.getSlot()), p);
String section = plugin.itemCreate.hasSection(cf.getConfigurationSection("panels." + panel + ".item." + e.getSlot()), p);
//this will remove any pending user inputs, if there is already something there from a previous item
for(int o = 0; plugin.userInputStrings.size() > o; o++){
if(plugin.userInputStrings.get(o)[0].equals(p.getName())){
@ -157,12 +157,12 @@ public class utils implements Listener {
commands.set(i, commands.get(i).replaceAll("%cp-clicked%", "Air"));
}
//end custom PlaceHolders
int val = plugin.commandPayWall(p,commands.get(i));
int val = plugin.commandTags.commandPayWall(p,commands.get(i));
if(val == 0){
return;
}
if(val == 2){
plugin.commandTags(p, commands.get(i));
plugin.commandTags.commandTags(p, commands.get(i));
}
}
}
@ -193,6 +193,7 @@ public class utils implements Listener {
for(String[] tempName : plugin.panelNames){
if(tempName[0].equals(panelName)){
panelConfig = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + plugin.panelFiles.get(Integer.parseInt(tempName[1]))));
break;
}
}
if(panelConfig == null){
@ -218,7 +219,7 @@ public class utils implements Listener {
if(forced){
plugin.openGui(panelName, p, panelConfig, 1, 0);
}else{
plugin.openCommandPanel(p, p, panelName, panelConfig, false);
plugin.openVoids.openCommandPanel(p, p, panelName, panelConfig, false);
}
}
}