v3.14.2.3

This commit is contained in:
rockyhawk64 2020-12-14 21:16:46 +11:00
parent a0d84c3120
commit 99833c01d4
18 changed files with 647 additions and 570 deletions

View File

@ -1,6 +1,6 @@
# |------------------------------------------------------------------------
# | CommandPanels Config File
# | By RockyHawk v4.1
# | By RockyHawk v4.2
# | https://www.spigotmc.org/resources/command-panels-custom-guis.67788/
# |------------------------------------------------------------------------
config:

View File

@ -1,6 +1,6 @@
# |------------------------------------------------------------------------
# | CommandPanels Example File
# | By RockyHawk v2.0
# | By RockyHawk v2.1
# | https://www.spigotmc.org/resources/command-panels-custom-guis.67788/
# |------------------------------------------------------------------------
panels:
@ -99,7 +99,7 @@ panels:
- '&fI will teleport you home!'
commands:
- home
- commandpanels:commandpanelclose
- cpc
- console= title %cp-player-name% times 20 60 20
- console= title %cp-player-name% subtitle {"text":"%cp-player-displayname%","color":"green"}
- console= title %cp-player-name% title {"text":"Welcome Home"}
@ -109,7 +109,7 @@ panels:
potion: INSTANT_HEAL
commands:
- heal
- commandpanels:commandpanelclose
- cpc
'34':
material: REDSTONE_BLOCK
name: '&cNo Permission'
@ -126,7 +126,7 @@ panels:
- '&2to creative mode!'
commands:
- gamemode creative
- commandpanels:commandpanelclose
- cpc
- console= title %cp-player-name% times 20 60 20
- console= title %cp-player-name% subtitle {"text":"You are now in creative mode!","color":"green"}
- console= title %cp-player-name% title {"text":"Awesome %cp-player-displayname%"}

View File

@ -1,6 +1,6 @@
# |------------------------------------------------------------------------
# | CommandPanels Classic Example File
# | By RockyHawk v2.0
# | CommandPanels Legacy Example File
# | By RockyHawk v2.1
# | https://www.spigotmc.org/resources/command-panels-custom-guis.67788/
# |------------------------------------------------------------------------
panels:
@ -101,7 +101,7 @@ panels:
- '&fI will teleport you home!'
commands:
- home
- commandpanels:commandpanelclose
- cpc
- console= title %cp-player-name% times 20 60 20
- console= title %cp-player-name% subtitle {"text":"%cp-player-displayname%","color":"green"}
- console= title %cp-player-name% title {"text":"Welcome Home"}
@ -111,7 +111,7 @@ panels:
name: '&5&lInstant Health II'
commands:
- heal
- commandpanels:commandpanelclose
- cpc
'34':
material: REDSTONE_BLOCK
name: '&cNo Permission'
@ -128,7 +128,7 @@ panels:
- '&2to creative mode!'
commands:
- gamemode creative
- commandpanels:commandpanelclose
- cpc
- console= title %cp-player-name% times 20 60 20
- console= title %cp-player-name% subtitle {"text":"You are now in creative mode!","color":"green"}
- console= title %cp-player-name% title {"text":"Awesome %cp-player-displayname%"}

View File

@ -1,4 +1,4 @@
version: 3.14.2.2
version: 3.14.2.3
main: me.rockyhawk.commandpanels.CommandPanels
name: CommandPanels
author: RockyHawk
@ -22,10 +22,6 @@ commands:
description: Add or remove panels from blocks being looked at.
usage: /commandpanelblock
aliases: [cpb, cpanelb]
commandpanelclose:
description: Close current GUI.
usage: /commandpanelclose
aliases: [cpc, cpanelc]
commandpanelgenerate:
description: Generate GUI.
usage: /commandpanelgenerate

View File

@ -127,7 +127,6 @@ public class CommandPanels extends JavaPlugin {
Objects.requireNonNull(this.getCommand("commandpanelgenerate")).setExecutor(new Commandpanelsgenerate(this));
Objects.requireNonNull(this.getCommand("commandpanelreload")).setExecutor(new Commandpanelsreload(this));
Objects.requireNonNull(this.getCommand("commandpaneldebug")).setExecutor(new Commandpanelsdebug(this));
Objects.requireNonNull(this.getCommand("commandpanelclose")).setExecutor(new Commandpanelclose(this));
Objects.requireNonNull(this.getCommand("commandpanelversion")).setExecutor(new Commandpanelversion(this));
Objects.requireNonNull(this.getCommand("commandpaneladdons")).setExecutor(new Commandpanelresources(this));
Objects.requireNonNull(this.getCommand("commandpanellist")).setExecutor(new Commandpanelslist(this));
@ -561,7 +560,6 @@ public class CommandPanels extends JavaPlugin {
if (p.hasPermission("commandpanel.addons")) {
p.sendMessage(ChatColor.GOLD + "/cpa " + ChatColor.WHITE + "View downloadable panels for CommandPanels.");
}
p.sendMessage(ChatColor.GOLD + "/cpc " + ChatColor.WHITE + "Close current GUI.");
if (p.hasPermission("commandpanel.generate")) {
p.sendMessage(ChatColor.GOLD + "/cpg <rows> " + ChatColor.WHITE + "Generate GUI from popup menu.");
}
@ -569,7 +567,8 @@ public class CommandPanels extends JavaPlugin {
p.sendMessage(ChatColor.GOLD + "/cpv " + ChatColor.WHITE + "Display the current version.");
}
if (p.hasPermission("commandpanel.update")) {
p.sendMessage(ChatColor.GOLD + "/cpv [version:latest:cancel]" + ChatColor.WHITE + "Download an update upon server reload/restart.");
p.sendMessage(ChatColor.GOLD + "/cpv latest " + ChatColor.WHITE + "Download the latest update upon server reload/restart.");
p.sendMessage(ChatColor.GOLD + "/cpv [version:cancel] " + ChatColor.WHITE + "Download an update upon server reload/restart.");
}
if (p.hasPermission("commandpanel.edit")) {
p.sendMessage(ChatColor.GOLD + "/cpe [panel] " + ChatColor.WHITE + "Edit a panel with the Panel Editor.");

File diff suppressed because it is too large Load Diff

View File

@ -325,11 +325,20 @@ public class OpenEditorGuis {
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);
lore.add(ChatColor.GRAY + "Execute commands from Hotbar Item");
lore.add(ChatColor.GRAY + "- Left click to add command");
lore.add(ChatColor.GRAY + "- Right click to remove command");
lore.add(ChatColor.GRAY + "If commands are added, the item will");
lore.add(ChatColor.GRAY + "no longer automatically open the panel");
if (cf.contains("open-with-item.commands")) {
lore.add(ChatColor.WHITE + "-------------------------------");
int count = 1;
for (String tempLore : cf.getStringList("open-with-item.commands")) {
lore.add(ChatColor.WHITE + Integer.toString(count) + ") " + tempLore);
count += 1;
}
}
plugin.setName(temp, ChatColor.WHITE + "Hotbar Item Commands", lore, p, true, true);
i.setItem(44, temp);
}

View File

@ -1,30 +0,0 @@
package me.rockyhawk.commandpanels.commands;
import me.rockyhawk.commandpanels.CommandPanels;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
public class Commandpanelclose implements CommandExecutor {
CommandPanels plugin;
public Commandpanelclose(CommandPanels pl) { this.plugin = pl; }
@EventHandler
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if(!(sender instanceof Player)) {
sender.sendMessage(plugin.papi(plugin.tag + ChatColor.RED + "Please execute command as a Player!"));
return true;
}
Player p = (Player)sender;
if (cmd.getName().equalsIgnoreCase("cpc") || cmd.getName().equalsIgnoreCase("commandpanelclose") && sender instanceof Player || cmd.getName().equalsIgnoreCase("cpanelc") && sender instanceof Player) {
p.closeInventory();
return true;
}
p.sendMessage(plugin.papi(plugin.tag + ChatColor.RED + "Usage: /cpc"));
return true;
}
}

View File

@ -28,6 +28,7 @@ public class Commandpanelsreload implements CommandExecutor {
//empty
}
plugin.config = YamlConfiguration.loadConfiguration(new File(plugin.getDataFolder() + File.separator + "config.yml"));
plugin.blockConfig = YamlConfiguration.loadConfiguration(new File(plugin.getDataFolder() + File.separator + "blocks.yml"));
//check for duplicates
plugin.checkDuplicatePanel(sender);

View File

@ -31,16 +31,16 @@ public class Commandpanelversion implements CommandExecutor {
if (sender.hasPermission("commandpanel.update")) {
if (args[0].equals("cancel")) {
plugin.updater.downloadVersionManually = null;
sender.sendMessage(plugin.papi(plugin.tag + ChatColor.GREEN + "Will not download a new version on reload or restart."));
sender.sendMessage(plugin.papi(plugin.tag + ChatColor.GREEN + "Will not download a new version on restart."));
} else {
plugin.updater.downloadVersionManually = args[0];
sender.sendMessage(plugin.papi(plugin.tag + ChatColor.GREEN + "Downloading version " + ChatColor.GRAY + args[0] + ChatColor.GREEN + " upon server reload or restart."));
sender.sendMessage(plugin.papi(plugin.tag + ChatColor.GREEN + "Downloading version " + ChatColor.GRAY + args[0] + ChatColor.GREEN + " upon server restart."));
}
}else{
sender.sendMessage(plugin.papi(plugin.tag + plugin.config.getString("config.format.perms")));
}
}else{
sender.sendMessage(plugin.papi(plugin.tag + ChatColor.RED + "Usage: /cpv [update]"));
sender.sendMessage(plugin.papi(plugin.tag + ChatColor.RED + "Usage: /cpv [update:latest:cancel]"));
}
return true;
}

View File

@ -429,6 +429,38 @@ public class EditorUserInput implements Listener {
savePanelFile(cf, cfile, panelName, panelFile);
p.sendMessage(plugin.papi( plugin.tag + ChatColor.GREEN + "Removed lore line " + e.getMessage()));
break;
case "panel.hotbar.commands.add":
List<String> commandAdd = new ArrayList<>();
if(cf.contains("open-with-item.commands")){
commandAdd = cf.getStringList("open-with-item.commands");
}
commandAdd.add(e.getMessage());
cf.set("open-with-item.commands", commandAdd);
savePanelFile(cf, cfile, panelName, panelFile);
p.sendMessage(plugin.papi( plugin.tag + ChatColor.GREEN + "Added new command: " + e.getMessage()));
break;
case "panel.hotbar.commands.remove":
List<String> commandRemove;
if(cf.contains("open-with-item.commands")){
commandRemove = cf.getStringList("open-with-item.commands");
}else{
p.sendMessage(plugin.papi( plugin.tag + ChatColor.RED + "No commands found to remove!"));
break;
}
try {
commandRemove.remove(Integer.parseInt(e.getMessage())-1);
}catch (Exception ex){
p.sendMessage(plugin.papi( plugin.tag + ChatColor.RED + "Could not find command!"));
break;
}
if(commandRemove.size() == 0){
cf.set("open-with-item.commands", null);
}else{
cf.set("open-with-item.commands", commandRemove);
}
savePanelFile(cf, cfile, panelName, panelFile);
p.sendMessage(plugin.papi( plugin.tag + ChatColor.GREEN + "Removed command line " + e.getMessage()));
break;
}
}

View File

@ -1,7 +1,6 @@
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.configuration.ConfigurationSection;
@ -494,6 +493,17 @@ public class EditorUtils implements Listener {
p.sendMessage(plugin.papi(plugin.tag + ChatColor.WHITE + "Enter Location (1 to 9)"));
p.closeInventory();
}
if(e.getSlot() == 44 && hotbarItems){
//adds abilities to add and remove lines
if(e.getClick().isLeftClick()) {
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.hotbar.commands.add"});
p.sendMessage(plugin.papi(plugin.tag + ChatColor.WHITE + "Enter New Item Command"));
}else{
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.hotbar.commands.remove"});
p.sendMessage(plugin.papi(plugin.tag + ChatColor.WHITE + "Enter command line to remove (must be an integer)"));
}
p.closeInventory();
}
}
@EventHandler

View File

@ -8,7 +8,6 @@ import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.SkullMeta;
import java.util.Iterator;
import java.util.Objects;

View File

@ -109,7 +109,7 @@ public class OpenPanelsLoader {
}
}
if (plugin.config.contains("config.panel-snooper")) {
if (Objects.requireNonNull(plugin.config.getString("config.panel-snooper")).trim().equalsIgnoreCase("true")) {
if (Objects.requireNonNull(plugin.config.getString("config.panel-snooper")).equalsIgnoreCase("true")) {
Bukkit.getConsoleSender().sendMessage("[CommandPanels] " + playerName + " Closed " + panelName);
}
}

View File

@ -39,6 +39,13 @@ public class HotbarItemLoader {
if(openPanel) {
String panelName = plugin.panelNames.get(temp[1])[0];
ConfigurationSection tempFile = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + plugin.panelFiles.get(Integer.parseInt(plugin.panelNames.get(temp[1])[1])))).getConfigurationSection("panels." + panelName);
//only open panel automatically if there are no commands
if(tempFile.contains("open-with-item.commands")){
for(String command : tempFile.getStringList("open-with-item.commands")){
plugin.commandTags.commandTags(p,plugin.papi(p,command),command);
}
return true;
}
if (plugin.openPanels.hasPanelOpen(p.getName())) {
plugin.openPanels.skipPanels.add(p.getName());
}
@ -69,6 +76,13 @@ public class HotbarItemLoader {
}
if(panelItem.isSimilar(invItem)){
if(openPanel) {
//only open panel automatically if there are no commands
if(tempFile.contains("open-with-item.commands")){
for(String command : tempFile.getStringList("open-with-item.commands")){
plugin.commandTags.commandTags(p,plugin.papi(p,command),command);
}
return true;
}
if (plugin.openPanels.hasPanelOpen(p.getName())) {
plugin.openPanels.skipPanels.add(p.getName());
}

View File

@ -22,7 +22,7 @@ public class Commandpanelblocks implements CommandExecutor {
@EventHandler
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (label.equalsIgnoreCase("cpb") || label.equalsIgnoreCase("commandpanelsblock") || label.equalsIgnoreCase("cpanelb")) {
if(args.length == 2) {
if(args.length >= 2) {
if (args[0].equalsIgnoreCase("add")) {
if(!(sender instanceof Player)) {
sender.sendMessage(plugin.papi(plugin.tag + ChatColor.RED + "Please execute command as a Player!"));
@ -52,7 +52,9 @@ public class Commandpanelblocks implements CommandExecutor {
}
Location blockLocation = blockType.getLocation();
String configValue = "blocks." + Objects.requireNonNull(blockLocation.getWorld()).getName().replaceAll("_", "%dash%") + "_" + blockLocation.getBlockX() + "_" + blockLocation.getBlockY() + "_" + blockLocation.getBlockZ() + ".panel";
plugin.blockConfig.set(configValue, args[1]);
//this is simply getting all of the args values after the add
String panelValue = String.join(" ", args).replace("add ", "");
plugin.blockConfig.set(configValue, panelValue);
try {
plugin.blockConfig.save(new File(plugin.getDataFolder() + File.separator + "blocks.yml"));
} catch (IOException e) {

View File

@ -3,14 +3,12 @@ package me.rockyhawk.commandpanels.panelblocks;
import me.rockyhawk.commandpanels.CommandPanels;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import java.io.File;
import java.util.Objects;
public class PanelBlockOnClick implements Listener {
@ -41,16 +39,15 @@ public class PanelBlockOnClick implements Listener {
Location tempLocation = new Location(plugin.getServer().getWorld(loc[0].replaceAll("%dash%","_")),Double.parseDouble(loc[1]),Double.parseDouble(loc[2]),Double.parseDouble(loc[3]));
if(tempLocation.equals(block.getLocation())){
e.setCancelled(true);
for(String[] temp : plugin.panelNames){
if(temp[0].equals(plugin.blockConfig.getString("blocks." + configLocation + ".panel"))){
String panelName = temp[0];
YamlConfiguration cf = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + plugin.panelFiles.get(Integer.parseInt(temp[1]))));
if(!plugin.openPanels.hasPanelOpen(p.getName())) {
plugin.openVoids.openCommandPanel(p, p, panelName, cf.getConfigurationSection("panels." + panelName), false);
}
return;
if(plugin.blockConfig.contains("blocks." + configLocation + ".commands")){
for(String command : plugin.blockConfig.getStringList("blocks." + configLocation + ".commands")){
plugin.commandTags.commandTags(p,plugin.papi(p,command),command);
}
return;
}
//uses the open= tag because it will open a panel with panel names, but also works with open= features like placeholders
String command = "open= " + plugin.blockConfig.getString("blocks." + configLocation + ".panel");
plugin.commandTags.commandTags(p, plugin.papi(p, command), command);
}
}
}

View File

@ -50,8 +50,8 @@ public class Updater {
if(sendMessages) {
Bukkit.getConsoleSender().sendMessage("[CommandPanels]" + ChatColor.GOLD + " ================================================");
Bukkit.getConsoleSender().sendMessage("[CommandPanels]" + ChatColor.AQUA + " An update for CommandPanels is available.");
Bukkit.getConsoleSender().sendMessage("[CommandPanels]" + " Download CommandPanels " + ChatColor.GOLD + gitVersion + ChatColor.WHITE + " here:");
Bukkit.getConsoleSender().sendMessage("[CommandPanels]" + ChatColor.AQUA + " https://www.spigotmc.org/resources/command-panels-custom-guis.67788/");
Bukkit.getConsoleSender().sendMessage("[CommandPanels]" + " Download CommandPanels " + ChatColor.GOLD + gitVersion + ChatColor.WHITE + " using the");
Bukkit.getConsoleSender().sendMessage("[CommandPanels]" + ChatColor.WHITE + " following command:" + ChatColor.AQUA + " /cpv latest" + ChatColor.WHITE + " and restart the server");
Bukkit.getConsoleSender().sendMessage("[CommandPanels]" + ChatColor.GOLD + " ================================================");
}
}
@ -79,8 +79,8 @@ public class Updater {
return;
}
if(latestVersion.equals(thisVersion)){
//no need to update
if(latestVersion.equals(thisVersion) || thisVersion.contains("-")){
//no need to update or running custom version
return;
}
if(Objects.equals(plugin.config.getString("config.updater.minor-updates-only"), "true")){