forked from Upstream/CommandPanels
3.16.2.0
This commit is contained in:
parent
5dc197696f
commit
84c83affab
@ -1,6 +1,6 @@
|
||||
# |------------------------------------------------------------------------
|
||||
# | CommandPanels Config File
|
||||
# | By RockyHawk v5.0
|
||||
# | By RockyHawk v5.1
|
||||
# | https://www.spigotmc.org/resources/command-panels-custom-guis.67788/
|
||||
# |
|
||||
# | auto-update and minor-updates-only is HEAVILY RECOMMENDED
|
||||
@ -19,11 +19,6 @@ config:
|
||||
disabled-world-message: true
|
||||
update-notifications: true
|
||||
panel-snooper: false
|
||||
input-cancel: cancel
|
||||
input-cancelled: '&cCancelled!'
|
||||
input-message:
|
||||
- '%cp-tag%&aEnter Input for Command'
|
||||
- '&cType &4%cp-args% &cto Cancel the command'
|
||||
format:
|
||||
tag: '&6[&bCommandPanels&6]'
|
||||
perms: '&cNo permission.'
|
||||
@ -34,6 +29,12 @@ config:
|
||||
error: '&cError found in config.'
|
||||
offline: 'Offline'
|
||||
offlineHeadValue: 'eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNmU1Mjg2YzQ3MGY2NmZmYTFhMTgzMzFjYmZmYjlhM2MyYTQ0MjRhOGM3MjU5YzQ0MzZmZDJlMzU1ODJhNTIyIn19fQ=='
|
||||
input:
|
||||
input-cancel: cancel
|
||||
input-cancelled: '&cCancelled!'
|
||||
input-message:
|
||||
- '%cp-tag%&aEnter Input for Command'
|
||||
- '&cType &4%cp-args% &cto Cancel the command'
|
||||
hexcodes:
|
||||
start_tag: '#'
|
||||
end_tag: ''
|
||||
|
@ -1,4 +1,4 @@
|
||||
version: 3.16.1.1
|
||||
version: 3.16.2.0
|
||||
main: me.rockyhawk.commandpanels.CommandPanels
|
||||
name: CommandPanels
|
||||
author: RockyHawk
|
||||
@ -38,6 +38,10 @@ commands:
|
||||
description: Lists the currently loaded panels.
|
||||
usage: /commandpanellist
|
||||
aliases: [cpl, cpanell]
|
||||
commandpanelimport:
|
||||
description: Import raw text panels from online.
|
||||
usage: /commandpanelimport
|
||||
aliases: [cpi, cpaneli]
|
||||
permissions:
|
||||
commandpanel.panel.default:
|
||||
default: true
|
||||
@ -68,4 +72,6 @@ permissions:
|
||||
commandpanel.edit:
|
||||
default: op
|
||||
commandpanel.list:
|
||||
default: op
|
||||
commandpanel.import:
|
||||
default: op
|
@ -24,7 +24,7 @@ import me.rockyhawk.commandpanels.ingameeditor.CpIngameEditCommand;
|
||||
import me.rockyhawk.commandpanels.ingameeditor.CpTabCompleteIngame;
|
||||
import me.rockyhawk.commandpanels.ingameeditor.EditorUserInput;
|
||||
import me.rockyhawk.commandpanels.ingameeditor.EditorUtils;
|
||||
import me.rockyhawk.commandpanels.interactives.CommandpanelUserInput;
|
||||
import me.rockyhawk.commandpanels.interactives.input.UserInputUtils;
|
||||
import me.rockyhawk.commandpanels.interactives.Commandpanelrefresher;
|
||||
import me.rockyhawk.commandpanels.interactives.OpenOnJoin;
|
||||
import me.rockyhawk.commandpanels.ioclasses.Sequence_1_13;
|
||||
@ -74,7 +74,6 @@ public class CommandPanels extends JavaPlugin{
|
||||
public String tag = "[CommandPanels]";
|
||||
|
||||
public List<Player> generateMode = new ArrayList<>(); //players that are currently in generate mode
|
||||
public List<String[]> userInputStrings = new ArrayList<>();
|
||||
public List<String[]> editorInputStrings = new ArrayList<>();
|
||||
public List<Panel> panelList = new ArrayList<>(); //contains all the panels that are included in the panels folder
|
||||
|
||||
@ -102,6 +101,7 @@ public class CommandPanels extends JavaPlugin{
|
||||
|
||||
public InventorySaver inventorySaver = new InventorySaver(this);
|
||||
public ItemStackSerializer itemSerializer = new ItemStackSerializer(this);
|
||||
public UserInputUtils inputUtils = new UserInputUtils(this);
|
||||
|
||||
public File panelsf = new File(this.getDataFolder() + File.separator + "panels");
|
||||
public YamlConfiguration blockConfig; //where panel block locations are stored
|
||||
@ -153,12 +153,13 @@ public class CommandPanels extends JavaPlugin{
|
||||
Objects.requireNonNull(this.getCommand("commandpaneldebug")).setExecutor(new Commandpanelsdebug(this));
|
||||
Objects.requireNonNull(this.getCommand("commandpanelversion")).setExecutor(new Commandpanelversion(this));
|
||||
Objects.requireNonNull(this.getCommand("commandpanellist")).setExecutor(new Commandpanelslist(this));
|
||||
Objects.requireNonNull(this.getCommand("commandpanelimport")).setExecutor(new CommandPanelImport(this));
|
||||
this.getServer().getPluginManager().registerEvents(new Utils(this), this);
|
||||
this.getServer().getPluginManager().registerEvents(updater, this);
|
||||
this.getServer().getPluginManager().registerEvents(inventorySaver, this);
|
||||
this.getServer().getPluginManager().registerEvents(inputUtils, this);
|
||||
this.getServer().getPluginManager().registerEvents(new UtilsPanelsLoader(this), this);
|
||||
this.getServer().getPluginManager().registerEvents(new GenUtils(this), this);
|
||||
this.getServer().getPluginManager().registerEvents(new CommandpanelUserInput(this), this);
|
||||
this.getServer().getPluginManager().registerEvents(new ItemFallManager(this), this);
|
||||
this.getServer().getPluginManager().registerEvents(new OpenOnJoin(this), this);
|
||||
|
||||
@ -430,6 +431,9 @@ public class CommandPanels extends JavaPlugin{
|
||||
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.import")) {
|
||||
p.sendMessage(ChatColor.GOLD + "/cpi [file name] [URL] " + ChatColor.WHITE + "Downloads a panel from a raw link online.");
|
||||
}
|
||||
if (p.hasPermission("commandpanel.edit")) {
|
||||
p.sendMessage(ChatColor.GOLD + "/cpe [panel] " + ChatColor.WHITE + "Edit a panel with the Panel Editor.");
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package me.rockyhawk.commandpanels;
|
||||
|
||||
import me.rockyhawk.commandpanels.api.Panel;
|
||||
import me.rockyhawk.commandpanels.commandtags.PaywallOutput;
|
||||
import me.rockyhawk.commandpanels.interactives.input.PlayerInput;
|
||||
import me.rockyhawk.commandpanels.openpanelsmanager.PanelPosition;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@ -112,12 +113,10 @@ public class Utils implements Listener {
|
||||
e.setCancelled(true);
|
||||
p.updateInventory();
|
||||
|
||||
//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())){
|
||||
plugin.userInputStrings.remove(o);
|
||||
o=o-1;
|
||||
}
|
||||
//if an item has an area for input instead of commands
|
||||
if(panel.getConfig().contains("item." + clickedSlot + section + ".player-input")) {
|
||||
plugin.inputUtils.playerInput.put(p,new PlayerInput(panel,panel.getConfig().getStringList("item." + clickedSlot + section + ".player-input")));
|
||||
plugin.inputUtils.sendMessage(panel,position,p);
|
||||
}
|
||||
|
||||
if(panel.getConfig().contains("item." + clickedSlot + section + ".commands")) {
|
||||
|
@ -33,7 +33,7 @@ public class Placeholders {
|
||||
String identifier = str.substring(start, end).replace(HOLDERS[0] + "cp-", "").replace(HOLDERS[1], "");
|
||||
String value;
|
||||
try {
|
||||
value = cpPlaceholders(panel,position,p,identifier, str);
|
||||
value = cpPlaceholders(panel,position,p,identifier);
|
||||
} catch (NullPointerException er) {
|
||||
value = "";
|
||||
}
|
||||
@ -69,24 +69,7 @@ public class Placeholders {
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private String cpPlaceholders(Panel panel, PanelPosition position, Player p, String identifier, String string){
|
||||
|
||||
//do player input placeholder first
|
||||
if (identifier.equals("player-input")) {
|
||||
for (String[] key : plugin.userInputStrings) {
|
||||
if (key[0].equals(p.getName())) {
|
||||
plugin.userInputStrings.add(new String[]{p.getName(), string});
|
||||
return "cpc";
|
||||
}
|
||||
}
|
||||
plugin.userInputStrings.add(new String[]{p.getName(), string});
|
||||
List<String> inputMessages = new ArrayList<String>(plugin.config.getStringList("config.input-message"));
|
||||
for (String temp : inputMessages) {
|
||||
temp = temp.replaceAll("%cp-args%", Objects.requireNonNull(plugin.config.getString("config.input-cancel")));
|
||||
p.sendMessage(plugin.tex.placeholders(panel,position,p, temp));
|
||||
}
|
||||
return "cpc";
|
||||
}
|
||||
private String cpPlaceholders(Panel panel, PanelPosition position, Player p, String identifier){
|
||||
|
||||
//replace nodes with PlaceHolders
|
||||
switch(identifier){
|
||||
@ -111,6 +94,9 @@ public class Placeholders {
|
||||
case("online-players"): {
|
||||
return Integer.toString(Bukkit.getServer().getOnlinePlayers().size());
|
||||
}
|
||||
case("panel-position"): {
|
||||
return position.toString();
|
||||
}
|
||||
case("tag"): {
|
||||
return plugin.tex.colour(plugin.tag);
|
||||
}
|
||||
|
@ -0,0 +1,80 @@
|
||||
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.event.EventHandler;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class CommandPanelImport implements CommandExecutor {
|
||||
CommandPanels plugin;
|
||||
public CommandPanelImport(CommandPanels pl) { this.plugin = pl; }
|
||||
|
||||
@EventHandler
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
if (sender.hasPermission("commandpanel.import")) {
|
||||
if (args.length == 2) {
|
||||
//import command
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
downloadPanel(sender,args[1],args[0]);
|
||||
plugin.reloadPanelFiles();
|
||||
}
|
||||
}.run();
|
||||
return true;
|
||||
}
|
||||
}else{
|
||||
sender.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.perms")));
|
||||
}
|
||||
sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + "Usage: /cpi <file name> <url>"));
|
||||
return true;
|
||||
}
|
||||
|
||||
private void downloadPanel(CommandSender sender, String url, String fileName) {
|
||||
BufferedInputStream in = null;
|
||||
FileOutputStream fout = null;
|
||||
|
||||
try {
|
||||
URL fileUrl = new URL(url);
|
||||
in = new BufferedInputStream(fileUrl.openStream());
|
||||
fout = new FileOutputStream(new File(plugin.panelsf, fileName + ".yml"));
|
||||
byte[] data = new byte[1024];
|
||||
|
||||
int count;
|
||||
while((count = in.read(data, 0, 1024)) != -1) {
|
||||
fout.write(data, 0, count);
|
||||
}
|
||||
sender.sendMessage(plugin.tag + ChatColor.GREEN + "Finished downloading.");
|
||||
} catch (Exception var22) {
|
||||
sender.sendMessage(ChatColor.RED + "Could not download panel.");
|
||||
} finally {
|
||||
try {
|
||||
if (in != null) {
|
||||
in.close();
|
||||
}
|
||||
} catch (IOException var21) {
|
||||
this.plugin.getLogger().log(Level.SEVERE, null, var21);
|
||||
}
|
||||
|
||||
try {
|
||||
if (fout != null) {
|
||||
fout.close();
|
||||
}
|
||||
} catch (IOException var20) {
|
||||
this.plugin.getLogger().log(Level.SEVERE, null, var20);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -34,11 +34,6 @@ public class CommandTagEvent extends Event {
|
||||
if(split.length == 1){
|
||||
split = new String[]{split[0],""};
|
||||
}
|
||||
if(split[1].contains("%cp-player-input%")){
|
||||
//set command to cpc and then use full command for input
|
||||
this.name = "cpc";
|
||||
return;
|
||||
}
|
||||
|
||||
this.name = split[0].trim();
|
||||
this.raw = split[1].trim().split("\\s");
|
||||
|
@ -1,6 +1,5 @@
|
||||
package me.rockyhawk.commandpanels.commandtags;
|
||||
|
||||
import jdk.nashorn.internal.ir.Block;
|
||||
import me.realized.tokenmanager.api.TokenManager;
|
||||
import me.rockyhawk.commandpanels.CommandPanels;
|
||||
import me.rockyhawk.commandpanels.api.Panel;
|
||||
|
@ -25,7 +25,12 @@ public class BasicTags implements Listener {
|
||||
}
|
||||
if(e.name.equalsIgnoreCase("refresh")) {
|
||||
e.commandTagUsed();
|
||||
plugin.createGUI.openGui(e.panel, e.p, e.pos, PanelOpenType.Refresh, 0);
|
||||
if(plugin.openPanels.hasPanelOpen(e.p.getName(),e.pos)) {
|
||||
plugin.createGUI.openGui(e.panel, e.p, e.pos, PanelOpenType.Refresh, 0);
|
||||
}
|
||||
if(plugin.inventorySaver.hasNormalInventory(e.p)){
|
||||
plugin.hotbar.updateHotbarItems(e.p);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if(e.name.equalsIgnoreCase("console=")) {
|
||||
|
@ -44,12 +44,6 @@ public class GenUtils implements Listener {
|
||||
Player p = e.getPlayer();
|
||||
//if the player is in generate mode, remove generate mode
|
||||
this.plugin.generateMode.remove(p);
|
||||
for(int o = 0; this.plugin.userInputStrings.size() > o; ++o) {
|
||||
if (this.plugin.userInputStrings.get(o)[0].equals(e.getPlayer().getName())) {
|
||||
this.plugin.userInputStrings.remove(o);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
@ -1,45 +0,0 @@
|
||||
package me.rockyhawk.commandpanels.interactives;
|
||||
|
||||
import me.rockyhawk.commandpanels.CommandPanels;
|
||||
import me.rockyhawk.commandpanels.commandtags.CommandTags;
|
||||
import me.rockyhawk.commandpanels.openpanelsmanager.PanelPosition;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class CommandpanelUserInput implements Listener {
|
||||
CommandPanels plugin;
|
||||
public CommandpanelUserInput(CommandPanels pl) {
|
||||
this.plugin = pl;
|
||||
}
|
||||
@EventHandler
|
||||
public void onPlayerChat(AsyncPlayerChatEvent e) {
|
||||
for(int o = 0; plugin.userInputStrings.size() > o; o++){
|
||||
if(plugin.userInputStrings.get(o)[0].equals(e.getPlayer().getName())){
|
||||
if(e.getMessage().equalsIgnoreCase(plugin.config.getString("config.input-cancel"))){
|
||||
e.setCancelled(true);
|
||||
e.getPlayer().sendMessage(plugin.tex.colour( Objects.requireNonNull(plugin.config.getString("config.input-cancelled"))));
|
||||
for(int i = 0; plugin.userInputStrings.size() > i; i++){
|
||||
if(plugin.userInputStrings.get(i)[0].equals(e.getPlayer().getName())){
|
||||
plugin.userInputStrings.remove(i);
|
||||
//this is here because if one command is removed, i cannot increase by one
|
||||
i=i-1;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
String command = plugin.userInputStrings.get(o)[1].replaceAll("%cp-player-input%", e.getMessage());
|
||||
plugin.userInputStrings.remove(o);
|
||||
o=o-1;
|
||||
e.setCancelled(true);
|
||||
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||
public void run() {
|
||||
new CommandTags(plugin).runCommand(null, PanelPosition.Top,e.getPlayer(), command); //I have to do this to run regular Bukkit voids in an ASYNC Event
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package me.rockyhawk.commandpanels.interactives.input;
|
||||
|
||||
import me.rockyhawk.commandpanels.api.Panel;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class PlayerInput {
|
||||
public Panel panel;
|
||||
public List<String> commands;
|
||||
|
||||
public PlayerInput(Panel panel1, List<String> commands1){
|
||||
panel = panel1;
|
||||
commands = commands1;
|
||||
}
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
package me.rockyhawk.commandpanels.interactives.input;
|
||||
|
||||
import me.rockyhawk.commandpanels.CommandPanels;
|
||||
import me.rockyhawk.commandpanels.api.Panel;
|
||||
import me.rockyhawk.commandpanels.openpanelsmanager.PanelPosition;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public class UserInputUtils implements Listener {
|
||||
CommandPanels plugin;
|
||||
public UserInputUtils(CommandPanels pl) {
|
||||
this.plugin = pl;
|
||||
}
|
||||
|
||||
public HashMap<Player, PlayerInput> playerInput = new HashMap<>();
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerChat(AsyncPlayerChatEvent e) {
|
||||
if(playerInput.containsKey(e.getPlayer())){
|
||||
e.setCancelled(true);
|
||||
if(e.getMessage().equalsIgnoreCase(plugin.config.getString("input.input-cancel"))){
|
||||
e.getPlayer().sendMessage(plugin.tex.colour( Objects.requireNonNull(plugin.config.getString("config.input-cancelled"))));
|
||||
playerInput.remove(e.getPlayer());
|
||||
return;
|
||||
}
|
||||
playerInput.get(e.getPlayer()).panel.placeholders.addPlaceholder("player-input",e.getMessage());
|
||||
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||
public void run() {
|
||||
plugin.commandTags.runCommands(playerInput.get(e.getPlayer()).panel, PanelPosition.Top,e.getPlayer(), playerInput.get(e.getPlayer()).commands); //I have to do this to run regular Bukkit voids in an ASYNC Event
|
||||
playerInput.remove(e.getPlayer());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerQuit(PlayerQuitEvent e) {
|
||||
//if the player is in generate mode, remove generate mode
|
||||
playerInput.remove(e.getPlayer());
|
||||
}
|
||||
|
||||
public void sendMessage(Panel panel, PanelPosition pos, Player p){
|
||||
List<String> inputMessages = new ArrayList<>(plugin.config.getStringList("input.input-message"));
|
||||
for (String temp : inputMessages) {
|
||||
temp = temp.replaceAll("%cp-args%", Objects.requireNonNull(plugin.config.getString("input.input-cancel")));
|
||||
p.sendMessage(plugin.tex.placeholders(panel,pos,p, temp));
|
||||
}
|
||||
}
|
||||
}
|
@ -48,8 +48,8 @@ public class HotbarItemLoader {
|
||||
if(!itemCheckExecute(p.getInventory().getItem(slot),p,false,false)){
|
||||
return false;
|
||||
}
|
||||
if(panel.getConfig().contains("open-with-item.commands")){
|
||||
for(String command : panel.getConfig().getStringList("open-with-item.commands")){
|
||||
if(panel.getHotbarSection(p).contains("commands")){
|
||||
for(String command : panel.getHotbarSection(p).getStringList("commands")){
|
||||
plugin.commandTags.runCommand(panel,PanelPosition.Top,p, command);
|
||||
}
|
||||
return true;
|
||||
@ -85,8 +85,8 @@ public class HotbarItemLoader {
|
||||
if(!plugin.panelPerms.isPanelWorldEnabled(p,panel.getConfig())){
|
||||
return false;
|
||||
}
|
||||
if(panel.getConfig().contains("open-with-item.commands")){
|
||||
for(String command : panel.getConfig().getStringList("open-with-item.commands")){
|
||||
if(panel.getHotbarSection(p).contains("commands")){
|
||||
for(String command : panel.getHotbarSection(p).getStringList("commands")){
|
||||
plugin.commandTags.runCommand(panel,PanelPosition.Top,p, command);
|
||||
}
|
||||
return true;
|
||||
@ -139,5 +139,6 @@ public class HotbarItemLoader {
|
||||
}
|
||||
}
|
||||
}
|
||||
p.updateInventory();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user