This commit is contained in:
rockyhawk64 2020-11-13 13:58:21 +11:00
parent b72dcb4956
commit b6afddae20
15 changed files with 77 additions and 20 deletions

View File

@ -6,7 +6,6 @@
panels: panels:
example: example:
perm: admin perm: admin
panelType: default
rows: 4 rows: 4
title: '&6[&bExample Panel&6]&f Welcome!' title: '&6[&bExample Panel&6]&f Welcome!'
commands: commands:

View File

@ -6,7 +6,6 @@
panels: panels:
example: example:
perm: admin perm: admin
panelType: default
rows: 4 rows: 4
title: '&6[&bExample Panel&6]&f Welcome!' title: '&6[&bExample Panel&6]&f Welcome!'
commands: commands:

View File

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

View File

@ -224,6 +224,22 @@ public class OpenEditorGuis {
plugin.setName(temp, ChatColor.WHITE + "Panel Commands", lore, p,true, true); plugin.setName(temp, ChatColor.WHITE + "Panel Commands", lore, p,true, true);
i.setItem(15, temp); i.setItem(15, temp);
temp = new ItemStack(Material.STRING, 1);
lore.clear();
lore.add(ChatColor.GRAY + "Special panel types");
lore.add(ChatColor.GRAY + "- Left click to add panel type");
lore.add(ChatColor.GRAY + "- Right click to remove panel type");
if (cf.contains("panelType")) {
lore.add(ChatColor.WHITE + "-----------------------------");
int count = 1;
for (String tempLore : cf.getStringList("panelType")) {
lore.add(ChatColor.WHITE + Integer.toString(count) + ") " + tempLore);
count += 1;
}
}
plugin.setName(temp, ChatColor.WHITE + "Panel Types", lore, p,true, true);
i.setItem(17, temp);
temp = new ItemStack(Material.ITEM_FRAME, 1); temp = new ItemStack(Material.ITEM_FRAME, 1);
lore.clear(); lore.clear();
lore.add(ChatColor.GRAY + "Code name to open panel"); lore.add(ChatColor.GRAY + "Code name to open panel");

View File

@ -11,7 +11,6 @@ import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import java.io.File; import java.io.File;
import java.util.*;
public class Commandpanel implements CommandExecutor { public class Commandpanel implements CommandExecutor {
CommandPanels plugin; CommandPanels plugin;
@ -42,6 +41,12 @@ public class Commandpanel implements CommandExecutor {
sender.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.nopanel"))); sender.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.nopanel")));
return true; return true;
} }
if(cf.contains("panelType")) {
if (cf.getStringList("panelType").contains("nocommand")) {
//do not allow command with noCommand
return true;
}
}
//below will start the command, once it got the right file and panel //below will start the command, once it got the right file and panel
if (cmd.getName().equalsIgnoreCase("cp") || cmd.getName().equalsIgnoreCase("commandpanel") || cmd.getName().equalsIgnoreCase("cpanel")) { if (cmd.getName().equalsIgnoreCase("cp") || cmd.getName().equalsIgnoreCase("commandpanel") || cmd.getName().equalsIgnoreCase("cpanel")) {
if(!(sender instanceof Player)) { if(!(sender instanceof Player)) {
@ -49,19 +54,17 @@ public class Commandpanel implements CommandExecutor {
if(args.length == 2){ if(args.length == 2){
if(!args[1].equals("item")){ if(!args[1].equals("item")){
plugin.openVoids.openCommandPanel(sender,plugin.getServer().getPlayer(args[1]),panelName,cf,true); plugin.openVoids.openCommandPanel(sender,plugin.getServer().getPlayer(args[1]),panelName,cf,true);
return true;
}else{ }else{
sender.sendMessage(plugin.papi(tag + ChatColor.RED + "Usage: /cp <panel> [item] [player]")); sender.sendMessage(plugin.papi(tag + ChatColor.RED + "Usage: /cp <panel> [item] [player]"));
return true;
} }
return true;
}else if(args.length == 3){ }else if(args.length == 3){
if (args[1].equals("item")) { 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]),cf,true);
return true;
}else{ }else{
sender.sendMessage(plugin.papi(tag + ChatColor.RED + "Usage: /cp <panel> item [player]")); sender.sendMessage(plugin.papi(tag + ChatColor.RED + "Usage: /cp <panel> item [player]"));
return true;
} }
return true;
} else { } else {
sender.sendMessage(plugin.papi( tag + ChatColor.RED + "Please execute command directed to a Player!")); sender.sendMessage(plugin.papi( tag + ChatColor.RED + "Please execute command directed to a Player!"));
return true; return true;

View File

@ -1,7 +1,6 @@
package me.rockyhawk.commandpanels.commands; package me.rockyhawk.commandpanels.commands;
import me.rockyhawk.commandpanels.CommandPanels; import me.rockyhawk.commandpanels.CommandPanels;
import me.rockyhawk.commandpanels.customcommands.Commandpanelcustom;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;

View File

@ -38,6 +38,13 @@ public class CpTabComplete implements TabCompleter {
continue; continue;
} }
if (sender.hasPermission("commandpanel.panel." + temp.getString("panels." + key + ".perm"))) { if (sender.hasPermission("commandpanel.panel." + temp.getString("panels." + key + ".perm"))) {
if(temp.contains("panels." + key + ".panelType")) {
if (temp.getStringList("panels." + key + ".panelType").contains("nocommand")) {
//do not allow command with noCommand
continue;
}
}
if (temp.contains("panels." + key + ".disabled-worlds")) { if (temp.contains("panels." + key + ".disabled-worlds")) {
List<String> disabledWorlds = temp.getStringList("panels." + key + ".disabled-worlds"); List<String> disabledWorlds = temp.getStringList("panels." + key + ".disabled-worlds");
if (!disabledWorlds.contains(p.getWorld().getName())) { if (!disabledWorlds.contains(p.getWorld().getName())) {

View File

@ -92,7 +92,6 @@ public class GenUtils implements Listener {
File folder = new File(plugin.getDataFolder() + File.separator + "panels"); File folder = new File(plugin.getDataFolder() + File.separator + "panels");
file = YamlConfiguration.loadConfiguration(new File(folder + File.separator + date + ".yml")); file = YamlConfiguration.loadConfiguration(new File(folder + File.separator + date + ".yml"));
file.set("panels." + date + ".perm", "default"); file.set("panels." + date + ".perm", "default");
file.set("panels." + date + ".panelType", "default");
file.set("panels." + date + ".rows", inv.getSize()/9); file.set("panels." + date + ".rows", inv.getSize()/9);
file.set("panels." + date + ".title", "&8Generated " + date); file.set("panels." + date + ".title", "&8Generated " + date);
file.addDefault("panels." + date + ".command", date); file.addDefault("panels." + date + ".command", date);

View File

@ -42,7 +42,7 @@ public class CpTabCompleteIngame implements TabCompleter {
if(temp.contains("panels." + key + ".disabled-worlds")){ if(temp.contains("panels." + key + ".disabled-worlds")){
List<String> disabledWorlds = temp.getStringList("panels." + key + ".disabled-worlds"); List<String> disabledWorlds = temp.getStringList("panels." + key + ".disabled-worlds");
assert p != null; assert p != null;
assert disabledWorlds != null;
if(!disabledWorlds.contains(p.getWorld().getName())){ if(!disabledWorlds.contains(p.getWorld().getName())){
apanels.add(key); apanels.add(key);
} }

View File

@ -13,7 +13,6 @@ import org.bukkit.event.player.AsyncPlayerChatEvent;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
@ -222,6 +221,38 @@ public class EditorUserInput implements Listener {
savePanelFile(cf, cfile, panelName, panelFile); savePanelFile(cf, cfile, panelName, panelFile);
p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Sound when opening is now " + tempSound)); p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Sound when opening is now " + tempSound));
break; break;
case "panel.panelType.add":
List<String> typeAdd = new ArrayList<>();
if(cf.contains("panelType")){
typeAdd = cf.getStringList("panelType");
}
typeAdd.add(e.getMessage().toLowerCase());
cf.set("panelType", typeAdd);
savePanelFile(cf, cfile, panelName, panelFile);
p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Added new panel type: " + e.getMessage().toLowerCase()));
break;
case "panel.panelType.remove":
List<String> typeRemove;
if(cf.contains("panelType")){
typeRemove = cf.getStringList("panelType");
}else{
p.sendMessage(plugin.papi( tag + ChatColor.RED + "No types found to remove!"));
break;
}
try {
typeRemove.remove(Integer.parseInt(e.getMessage())-1);
}catch (Exception ex){
p.sendMessage(plugin.papi( tag + ChatColor.RED + "Could not find type!"));
break;
}
if(typeRemove.size() == 0){
cf.set("panelType", null);
}else{
cf.set("panelType", typeRemove);
}
savePanelFile(cf, cfile, panelName, panelFile);
p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Removed panel type " + e.getMessage()));
break;
case "panel.commands.add": case "panel.commands.add":
List<String> commandsAdd = new ArrayList<>(); List<String> commandsAdd = new ArrayList<>();
if(cf.contains("commands")){ if(cf.contains("commands")){

View File

@ -429,6 +429,17 @@ public class EditorUtils implements Listener {
} }
p.closeInventory(); p.closeInventory();
} }
if(e.getSlot() == 17){
//adds abilities to add and remove types
if(e.getClick().isLeftClick()) {
plugin.editorInputStrings.add(new String[]{p.getName(), panelName, "panel.panelType.add"});
p.sendMessage(plugin.papi(tag + ChatColor.WHITE + "Enter New Panel type"));
}else{
plugin.editorInputStrings.add(new String[]{p.getName(), panelName, "panel.panelType.remove"});
p.sendMessage(plugin.papi(tag + ChatColor.WHITE + "Enter Panel Type to remove (must be an integer)"));
}
p.closeInventory();
}
if(e.getSlot() == 25){ if(e.getSlot() == 25){
//adds abilities to add and remove lines //adds abilities to add and remove lines
if(e.getClick().isLeftClick()) { if(e.getClick().isLeftClick()) {

View File

@ -48,7 +48,7 @@ public class Commandpanelrefresher implements Listener {
} }
if(cf.contains("panelType")) { if(cf.contains("panelType")) {
if (cf.getString("panelType").equalsIgnoreCase("temporary")) { if (cf.getStringList("panelType").contains("static")) {
//do not update temporary panels, only default panels //do not update temporary panels, only default panels
return; return;
} }

View File

@ -4,9 +4,6 @@ package me.rockyhawk.commandpanels.ioclasses;
import me.rockyhawk.commandpanels.CommandPanels; import me.rockyhawk.commandpanels.CommandPanels;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import org.apache.commons.io.input.CharSequenceReader; import org.apache.commons.io.input.CharSequenceReader;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;

View File

@ -4,9 +4,6 @@ package me.rockyhawk.commandpanels.ioclasses;
import me.rockyhawk.commandpanels.CommandPanels; import me.rockyhawk.commandpanels.CommandPanels;
import org.bukkit.craftbukkit.libs.org.apache.commons.io.IOUtils; import org.bukkit.craftbukkit.libs.org.apache.commons.io.IOUtils;
import org.bukkit.craftbukkit.libs.org.apache.commons.io.input.CharSequenceReader; import org.bukkit.craftbukkit.libs.org.apache.commons.io.input.CharSequenceReader;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;

View File

@ -9,7 +9,6 @@ import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.ItemMeta;
import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import java.util.Objects; import java.util.Objects;