forked from Upstream/CommandPanels
3.5.0 Updates
This commit is contained in:
parent
00af0c0b11
commit
68feb414bf
@ -1,4 +1,4 @@
|
||||
version: 3.4.2
|
||||
version: 3.5.0
|
||||
main: me.rockyhawk.commandPanels.commandpanels
|
||||
name: CommandPanels
|
||||
author: RockyHawk
|
||||
|
@ -1281,7 +1281,11 @@ public class commandpanels extends JavaPlugin {
|
||||
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.");
|
||||
setName(temp, ChatColor.WHITE + "Panel Editor", lore, p, true);
|
||||
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 + " " + config.getString("config.input-cancel") + " to cancel.");
|
||||
setName(temp, ChatColor.WHITE + "Panel Editor Tips", lore, p, true);
|
||||
i.setItem(53, temp);
|
||||
if (pageNumber != 1) {
|
||||
//only show previous page button if number is not one
|
||||
@ -1312,7 +1316,7 @@ public class commandpanels extends JavaPlugin {
|
||||
|
||||
public void openPanelSettings(Player p, String panelName, YamlConfiguration cf) {
|
||||
reloadPanelFiles();
|
||||
Inventory i = Bukkit.createInventory((InventoryHolder) null, 27, "Panel Settings: " + panelName);
|
||||
Inventory i = Bukkit.createInventory((InventoryHolder) null, 45, "Panel Settings: " + panelName);
|
||||
List<String> lore = new ArrayList();
|
||||
ItemStack temp;
|
||||
//remove if the player already had a string from previously
|
||||
@ -1415,6 +1419,83 @@ public class commandpanels extends JavaPlugin {
|
||||
setName(temp, ChatColor.RED + "Back", null, p,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);
|
||||
setName(temp, ChatColor.WHITE + "", null, p,false);
|
||||
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 = new ItemStack((Objects.requireNonNull(Material.matchMaterial(Objects.requireNonNull(cf.getString("panels." + panelName + ".open-with-item.material"))))), 1);
|
||||
}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");
|
||||
}
|
||||
setName(temp, ChatColor.WHITE + "Panel Hotbar Item", lore, p,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")));
|
||||
}
|
||||
setName(temp, ChatColor.WHITE + "Hotbar Item Name", lore, p, 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;
|
||||
}
|
||||
}
|
||||
setName(temp, ChatColor.WHITE + "Hotbar Lore", lore, p,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));
|
||||
}
|
||||
setName(temp, ChatColor.WHITE + "Hotbar Item Location", lore, p, 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.");
|
||||
setName(temp, ChatColor.WHITE + "Hotbar Item Tips", lore, p, true);
|
||||
i.setItem(44, temp);
|
||||
}
|
||||
|
||||
p.openInventory(i);
|
||||
}
|
||||
|
||||
|
@ -153,7 +153,7 @@ public class commandpanel implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
}else{
|
||||
sender.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + ChatColor.RED + "Usage: /cp <panel> [item/edit] [player]"));
|
||||
sender.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + ChatColor.RED + "Usage: /cp <panel> [item] [player]"));
|
||||
return true;
|
||||
}
|
||||
}else if(args.length == 3){
|
||||
@ -167,7 +167,7 @@ public class commandpanel implements CommandExecutor {
|
||||
}
|
||||
Player sp;
|
||||
try {
|
||||
sp = plugin.getServer().getPlayer(args[1]);
|
||||
sp = plugin.getServer().getPlayer(args[2]);
|
||||
}catch(Exception e){
|
||||
sender.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + plugin.config.getString("config.format.notitem")));
|
||||
return true;
|
||||
@ -186,7 +186,7 @@ public class commandpanel implements CommandExecutor {
|
||||
List<String> disabledWorlds = (List<String>) cf.getList("panels." + panels + ".disabled-worlds");
|
||||
if(disabledWorlds.contains(sp.getWorld().getName())){
|
||||
//panel cannot be used in the players world!
|
||||
if(plugin.config.getString("config.disabled-world-message").equalsIgnoreCase("true")){
|
||||
if(Objects.requireNonNull(plugin.config.getString("config.disabled-world-message")).equalsIgnoreCase("true")){
|
||||
sp.sendMessage(ChatColor.RED + "Panel is disabled in this world!");
|
||||
}
|
||||
return true;
|
||||
@ -194,7 +194,7 @@ public class commandpanel implements CommandExecutor {
|
||||
}
|
||||
ItemStack s;
|
||||
try {
|
||||
s = new ItemStack(Material.matchMaterial(cf.getString("panels." + panels + ".open-with-item.material")), 1);
|
||||
s = new ItemStack(Objects.requireNonNull(Material.matchMaterial(Objects.requireNonNull(cf.getString("panels." + panels + ".open-with-item.material")))), 1);
|
||||
}catch(Exception n){
|
||||
if (plugin.getServer().getPluginManager().isPluginEnabled("PlaceholderAPI")) {
|
||||
sender.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + PlaceholderAPI.setPlaceholders(sp, plugin.config.getString("config.format.error") + " open-with-item: material")));
|
||||
@ -206,7 +206,11 @@ public class commandpanel implements CommandExecutor {
|
||||
plugin.setName(s, cf.getString("panels." + panels + ".open-with-item.name"), cf.getList("panels." + panels + ".open-with-item.lore"),sp,true);
|
||||
if(sender.hasPermission("commandpanel.other")) {
|
||||
try {
|
||||
plugin.getServer().getPlayer(args[2]).getInventory().addItem(s);
|
||||
if(cf.contains("panels." + panels + ".open-with-item.stationary")) {
|
||||
sp.getInventory().setItem(Integer.parseInt(Objects.requireNonNull(cf.getString("panels." + panels + ".open-with-item.stationary"))), s);
|
||||
}else{
|
||||
sp.getInventory().addItem(s);
|
||||
}
|
||||
sender.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + ChatColor.GREEN + "Item Given to " + plugin.getServer().getPlayer(args[2]).getDisplayName()));
|
||||
} catch (Exception r) {
|
||||
sender.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + plugin.config.getString("config.format.notitem")));
|
||||
@ -393,7 +397,7 @@ public class commandpanel implements CommandExecutor {
|
||||
}
|
||||
plugin.setName(s, cf.getString("panels." + panels + ".open-with-item.name"), cf.getList("panels." + panels + ".open-with-item.lore"),p,true);
|
||||
if(cf.contains("panels." + panels + ".open-with-item.stationary")) {
|
||||
p.getInventory().setItem(Integer.parseInt(cf.getString("panels." + panels + ".open-with-item.stationary")), s);
|
||||
p.getInventory().setItem(Integer.parseInt(Objects.requireNonNull(cf.getString("panels." + panels + ".open-with-item.stationary"))), s);
|
||||
}else{
|
||||
p.getInventory().addItem(s);
|
||||
}
|
||||
|
@ -73,7 +73,7 @@ public class commandpanelcustom implements Listener {
|
||||
}
|
||||
e.setCancelled(true);
|
||||
try {
|
||||
Bukkit.dispatchCommand(p, ChatColor.translateAlternateColorCodes('&', "commandpanel " + panel));
|
||||
Bukkit.dispatchCommand(p, ChatColor.translateAlternateColorCodes('&', "commandpanels:commandpanel " + panel));
|
||||
}catch(Exception er){
|
||||
//do nothing
|
||||
p.sendMessage(ChatColor.translateAlternateColorCodes('&',plugin.papi(p,tag + ChatColor.RED + "Error opening panel!")));
|
||||
|
@ -1,6 +1,7 @@
|
||||
package me.rockyhawk.commandPanels.ingameEditor;
|
||||
|
||||
import me.rockyhawk.commandPanels.commandpanels;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
@ -240,6 +241,85 @@ public class editorUserInput implements Listener {
|
||||
savePanelFile(cf, panelFile);
|
||||
p.sendMessage(ChatColor.translateAlternateColorCodes('&', tag + ChatColor.GREEN + "Removed command line " + e.getMessage()));
|
||||
break;
|
||||
case "panel.hotbar.material":
|
||||
if(e.getMessage().trim().equalsIgnoreCase("remove")){
|
||||
cf.set("panels." + panelName + ".open-with-item", null);
|
||||
savePanelFile(cf, panelFile);
|
||||
p.sendMessage(ChatColor.translateAlternateColorCodes('&', tag + ChatColor.GREEN + "Hotbar item have been removed."));
|
||||
//after an open-with-item has been altered, reload after changes
|
||||
plugin.reloadPanelFiles();
|
||||
break;
|
||||
}
|
||||
Material temp = Material.matchMaterial(e.getMessage());
|
||||
cf.set("panels." + panelName + ".open-with-item.material", temp.toString());
|
||||
if(!cf.contains("panels." + panelName + ".open-with-item.name")){
|
||||
cf.set("panels." + panelName + ".open-with-item.name", panelName + " Item");
|
||||
}
|
||||
savePanelFile(cf, panelFile);
|
||||
p.sendMessage(ChatColor.translateAlternateColorCodes('&', tag + ChatColor.GREEN + "Set new Material to " + ChatColor.WHITE + temp.toString()));
|
||||
//after an open-with-item has been altered, reload after changes
|
||||
plugin.reloadPanelFiles();
|
||||
break;
|
||||
case "panel.hotbar.stationary":
|
||||
if(e.getMessage().trim().equalsIgnoreCase("remove")){
|
||||
cf.set("panels." + panelName + ".open-with-item.stationary", null);
|
||||
savePanelFile(cf, panelFile);
|
||||
p.sendMessage(ChatColor.translateAlternateColorCodes('&', tag + ChatColor.GREEN + "Hotbar item can now be moved."));
|
||||
break;
|
||||
}
|
||||
try {
|
||||
int loc = Integer.parseInt(e.getMessage());
|
||||
if (loc >= 10 || loc <= 0) {
|
||||
//if the number isn't between 1-9
|
||||
p.sendMessage(ChatColor.translateAlternateColorCodes('&', tag + ChatColor.GREEN + "Choose an integer between 1 to 9!"));
|
||||
return;
|
||||
}
|
||||
p.sendMessage(ChatColor.translateAlternateColorCodes('&', tag + ChatColor.GREEN + "Set Hotbar Location to " + loc + "!"));
|
||||
//because it needs to convert 1-9 to 0-8 for in the panel
|
||||
loc -= 1;
|
||||
cf.set("panels." + panelName + ".open-with-item.stationary", loc);
|
||||
cf.save(panelFile);
|
||||
} catch (Exception io) {
|
||||
plugin.debug(io);
|
||||
}
|
||||
break;
|
||||
case "panel.hotbar.name":
|
||||
cf.set("panels." + panelName + ".open-with-item.name",e.getMessage());
|
||||
savePanelFile(cf, panelFile);
|
||||
p.sendMessage(ChatColor.translateAlternateColorCodes('&', tag + ChatColor.GREEN + "Set new Name to " + ChatColor.WHITE + e.getMessage()));
|
||||
break;
|
||||
case "panel.hotbar.lore.add":
|
||||
List<String> loreAdd = new ArrayList<>();
|
||||
if(cf.contains("panels." + panelName + ".open-with-item.lore")){
|
||||
loreAdd = cf.getStringList("panels." + panelName + ".open-with-item.lore");
|
||||
}
|
||||
loreAdd.add(e.getMessage());
|
||||
cf.set("panels." + panelName + ".open-with-item.lore", loreAdd);
|
||||
savePanelFile(cf, panelFile);
|
||||
p.sendMessage(ChatColor.translateAlternateColorCodes('&', tag + ChatColor.GREEN + "Added new lore: " + e.getMessage()));
|
||||
break;
|
||||
case "panel.hotbar.lore.remove":
|
||||
List<String> loreRemove;
|
||||
if(cf.contains("panels." + panelName + ".open-with-item.lore")){
|
||||
loreRemove = cf.getStringList("panels." + panelName + ".open-with-item.lore");
|
||||
}else{
|
||||
p.sendMessage(ChatColor.translateAlternateColorCodes('&', tag + ChatColor.RED + "No lore found to remove!"));
|
||||
break;
|
||||
}
|
||||
try {
|
||||
loreRemove.remove(Integer.parseInt(e.getMessage())-1);
|
||||
}catch (Exception ex){
|
||||
p.sendMessage(ChatColor.translateAlternateColorCodes('&', tag + ChatColor.RED + "Could not find lore!"));
|
||||
break;
|
||||
}
|
||||
if(loreRemove.size() == 0){
|
||||
cf.set("panels." + panelName + ".open-with-item.lore", null);
|
||||
}else{
|
||||
cf.set("panels." + panelName + ".open-with-item.lore", loreRemove);
|
||||
}
|
||||
savePanelFile(cf, panelFile);
|
||||
p.sendMessage(ChatColor.translateAlternateColorCodes('&', tag + ChatColor.GREEN + "Removed lore line " + e.getMessage()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
void itemSectionCheck(Player p, String section, String panelName, YamlConfiguration cf, File panelFile, AsyncPlayerChatEvent e){
|
||||
|
@ -326,6 +326,7 @@ public class editorUtils implements Listener {
|
||||
e.setCancelled(true);
|
||||
String panelName = ""; //all panels from ALL files (panel names)
|
||||
boolean found = false;
|
||||
boolean hotbarItems = false;
|
||||
try {
|
||||
//neew to loop through files to get file names
|
||||
for(String fileName : plugin.panelFiles) { //will loop through all the files in folder
|
||||
@ -336,6 +337,9 @@ public class editorUtils implements Listener {
|
||||
for (String key : Objects.requireNonNull(temp.getConfigurationSection("panels")).getKeys(false)){
|
||||
if(e.getView().getTitle().equals("Panel Settings: " + key)){
|
||||
panelName = key;
|
||||
if(temp.contains("panels." + panelName + ".open-with-item")){
|
||||
hotbarItems = true;
|
||||
}
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
@ -404,6 +408,32 @@ public class editorUtils implements Listener {
|
||||
plugin.openEditorGui(p,0);
|
||||
p.updateInventory();
|
||||
}
|
||||
if(e.getSlot() == 40){
|
||||
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.hotbar.material"});
|
||||
p.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + ChatColor.GREEN + "Enter New Material"));
|
||||
p.closeInventory();
|
||||
}
|
||||
if(e.getSlot() == 38 && hotbarItems){
|
||||
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.hotbar.name"});
|
||||
p.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + ChatColor.GREEN + "Enter New Name"));
|
||||
p.closeInventory();
|
||||
}
|
||||
if(e.getSlot() == 36 && hotbarItems){
|
||||
//adds abilities to add and remove lines
|
||||
if(e.getClick().isLeftClick()) {
|
||||
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.hotbar.lore.add"});
|
||||
p.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + ChatColor.GREEN + "Enter New Item Lore"));
|
||||
}else{
|
||||
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.hotbar.lore.remove"});
|
||||
p.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + ChatColor.GREEN + "Enter lore line to remove (must be an integer)"));
|
||||
}
|
||||
p.closeInventory();
|
||||
}
|
||||
if(e.getSlot() == 42 && hotbarItems){
|
||||
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.hotbar.stationary"});
|
||||
p.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + ChatColor.GREEN + "Enter Location (1 to 9)"));
|
||||
p.closeInventory();
|
||||
}
|
||||
}
|
||||
@EventHandler
|
||||
public void onItemSettings(InventoryClickEvent e) {
|
||||
|
Loading…
Reference in New Issue
Block a user