forked from Upstream/CommandPanels
Add extensive tab completion to /cp and /cpdata
This commit is contained in:
parent
48367ae177
commit
a9919eb705
6
.idea/vcs.xml
Normal file
6
.idea/vcs.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
@ -13,6 +13,8 @@ import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.InventoryType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public class ExecuteOpenVoids {
|
||||
|
@ -10,7 +10,10 @@ import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
public class CommandPanelImport implements CommandExecutor {
|
||||
CommandPanels plugin;
|
||||
public CommandPanelImport(CommandPanels pl) { this.plugin = pl; }
|
||||
|
||||
public CommandPanelImport(CommandPanels pl) {
|
||||
this.plugin = pl;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
@ -20,14 +23,14 @@ public class CommandPanelImport implements CommandExecutor {
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
plugin.downloader.downloadPanel(sender,args[1],args[0]);
|
||||
plugin.downloader.downloadPanel(sender, args[1], args[0]);
|
||||
plugin.reloadPanelFiles();
|
||||
plugin.hotbar.reloadHotbarSlots();
|
||||
}
|
||||
}.run();
|
||||
return true;
|
||||
}
|
||||
}else{
|
||||
} 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>"));
|
||||
|
@ -3,6 +3,7 @@ package me.rockyhawk.commandpanels.commands;
|
||||
import me.rockyhawk.commandpanels.CommandPanels;
|
||||
import me.rockyhawk.commandpanels.api.Panel;
|
||||
import me.rockyhawk.commandpanels.openpanelsmanager.PanelPosition;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
@ -22,72 +23,92 @@ public class Commandpanel implements CommandExecutor {
|
||||
//below is going to go through the files and find the right one
|
||||
Panel panel = null;
|
||||
if (args.length != 0) { //check to make sure the person hasn't just left it empty
|
||||
for(Panel tempPanel : plugin.panelList){
|
||||
if(tempPanel.getName().equals(args[0])) {
|
||||
for (Panel tempPanel : plugin.panelList) {
|
||||
if (tempPanel.getName().equals(args[0])) {
|
||||
panel = tempPanel;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
} else {
|
||||
plugin.helpMessage(sender);
|
||||
return true;
|
||||
}
|
||||
if(panel == null){
|
||||
if (panel == null) {
|
||||
sender.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.nopanel")));
|
||||
return true;
|
||||
}
|
||||
boolean disableCommand = false;
|
||||
if(panel.getConfig().contains("panelType")) {
|
||||
if (panel.getConfig().contains("panelType")) {
|
||||
if (panel.getConfig().getStringList("panelType").contains("nocommand")) {
|
||||
//do not allow command with noCommand, console is an exception
|
||||
disableCommand = true;
|
||||
disableCommand = true;
|
||||
}
|
||||
}
|
||||
//below will start the command, once it got the right file and panel
|
||||
if(!(sender instanceof Player)) {
|
||||
if (!(sender instanceof Player)) {
|
||||
//do console command
|
||||
if(args.length == 2){
|
||||
if(!args[1].equals("item")){
|
||||
plugin.openVoids.openCommandPanel(sender, plugin.getServer().getPlayer(args[1]), panel.copy(), PanelPosition.Top, true);
|
||||
}else{
|
||||
sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + "Usage: /cp <panel> [item] [player]"));
|
||||
if (args.length == 2) {
|
||||
if (!args[1].equals("item")) {
|
||||
if (args[1].equalsIgnoreCase("all")) {
|
||||
for (Player player : Bukkit.getOnlinePlayers())
|
||||
plugin.openVoids.openCommandPanel(sender, player, panel.copy(), PanelPosition.Top, true);
|
||||
} else
|
||||
plugin.openVoids.openCommandPanel(sender, plugin.getServer().getPlayer(args[1]), panel.copy(), PanelPosition.Top, true);
|
||||
} else {
|
||||
sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + "Usage: /cp <panel> [item] [player|all]"));
|
||||
}
|
||||
return true;
|
||||
}else if(args.length == 3){
|
||||
} else if (args.length == 3) {
|
||||
if (args[1].equals("item")) {
|
||||
plugin.openVoids.giveHotbarItem(sender,plugin.getServer().getPlayer(args[2]),panel.copy(),true);
|
||||
}else{
|
||||
sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + "Usage: /cp <panel> item [player]"));
|
||||
if (args[2].equalsIgnoreCase("all")) {
|
||||
// if the argument is all open the panel for all of the players
|
||||
for (Player player : Bukkit.getOnlinePlayers())
|
||||
plugin.openVoids.openCommandPanel(sender, player, panel.copy(), PanelPosition.Top, true);
|
||||
} else
|
||||
plugin.openVoids.giveHotbarItem(sender, plugin.getServer().getPlayer(args[2]), panel.copy(), true);
|
||||
} else {
|
||||
sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + "Usage: /cp <panel> item [player|all]"));
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
sender.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.RED + "Please execute command directed to a Player!"));
|
||||
sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + "Please execute command directed to a Player!"));
|
||||
return true;
|
||||
}
|
||||
}else{
|
||||
} else {
|
||||
//get player
|
||||
Player p = (Player) sender;
|
||||
//do player command
|
||||
if (args.length == 1) {
|
||||
if(!disableCommand) {
|
||||
plugin.openVoids.openCommandPanel(sender, p, panel.copy(),PanelPosition.Top, false);
|
||||
if (!disableCommand) {
|
||||
plugin.openVoids.openCommandPanel(sender, p, panel.copy(), PanelPosition.Top, false);
|
||||
}
|
||||
return true;
|
||||
}else if(args.length == 2){
|
||||
} else if (args.length == 2) {
|
||||
if (args[1].equals("item")) {
|
||||
|
||||
plugin.openVoids.giveHotbarItem(sender, p, panel.copy(), false);
|
||||
}else{
|
||||
if(!disableCommand) {
|
||||
plugin.openVoids.openCommandPanel(sender, plugin.getServer().getPlayer(args[1]), panel.copy(),PanelPosition.Top, true);
|
||||
} else {
|
||||
if (!disableCommand) {
|
||||
if (args[1].equalsIgnoreCase("all")) {
|
||||
// if the argument is all open the panel for all of the players
|
||||
for (Player player : Bukkit.getOnlinePlayers())
|
||||
plugin.openVoids.openCommandPanel(sender, player, panel.copy(), PanelPosition.Top, true);
|
||||
} else
|
||||
plugin.openVoids.openCommandPanel(sender, plugin.getServer().getPlayer(args[1]), panel.copy(), PanelPosition.Top, true);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}else if(args.length == 3){
|
||||
plugin.openVoids.giveHotbarItem(sender, plugin.getServer().getPlayer(args[2]), panel.copy(),true);
|
||||
} else if (args.length == 3) {
|
||||
if (args[2].equalsIgnoreCase("all")) {
|
||||
// if the argument is all open the panel for all of the players
|
||||
for (Player player : Bukkit.getOnlinePlayers())
|
||||
plugin.openVoids.giveHotbarItem(sender, player, panel.copy(), true);
|
||||
} else
|
||||
plugin.openVoids.giveHotbarItem(sender, plugin.getServer().getPlayer(args[2]), panel.copy(), true);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + "Usage: /cp <panel> [player:item] [player]"));
|
||||
sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + "Usage: /cp <panel> [player|all:item] [player|all]"));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,13 @@
|
||||
package me.rockyhawk.commandpanels.commands;
|
||||
|
||||
import me.rockyhawk.commandpanels.CommandPanels;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
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;
|
||||
|
||||
import java.util.Arrays;
|
||||
@ -13,7 +16,7 @@ public class Commandpanelsdata implements CommandExecutor {
|
||||
CommandPanels plugin;
|
||||
public Commandpanelsdata(CommandPanels pl) { this.plugin = pl; }
|
||||
|
||||
@EventHandler
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
if (sender.hasPermission("commandpanel.data")) {
|
||||
boolean sendPlayerMessage = true;
|
||||
@ -25,7 +28,12 @@ public class Commandpanelsdata implements CommandExecutor {
|
||||
if(args.length == 2){
|
||||
//for the clear command
|
||||
if(args[0].equals("clear")){
|
||||
plugin.panelData.clearData(plugin.panelData.getOffline(args[1]));
|
||||
if (args[1].equalsIgnoreCase("all")) {
|
||||
for (OfflinePlayer player : Bukkit.getOfflinePlayers()) {
|
||||
plugin.panelData.clearData(plugin.panelData.getOffline(player.getName()));
|
||||
}
|
||||
} else
|
||||
plugin.panelData.clearData(plugin.panelData.getOffline(args[1]));
|
||||
if(sendPlayerMessage) {
|
||||
sender.sendMessage(plugin.tex.colour(plugin.tag
|
||||
+ ChatColor.GREEN + "Cleared all data for "
|
||||
@ -36,7 +44,12 @@ public class Commandpanelsdata implements CommandExecutor {
|
||||
}else if (args.length == 3){
|
||||
//for the remove command
|
||||
if(args[0].equals("remove")) {
|
||||
plugin.panelData.delUserData(plugin.panelData.getOffline(args[1]), args[2]);
|
||||
if (args[1].equalsIgnoreCase("all")) {
|
||||
for (OfflinePlayer player : Bukkit.getOfflinePlayers()) {
|
||||
plugin.panelData.delUserData(plugin.panelData.getOffline(player.getName()), args[2]);
|
||||
}
|
||||
} else
|
||||
plugin.panelData.delUserData(plugin.panelData.getOffline(args[1]), args[2]);
|
||||
if(sendPlayerMessage) {
|
||||
sender.sendMessage(plugin.tex.colour(plugin.tag
|
||||
+ ChatColor.GREEN + "Removed "
|
||||
@ -55,7 +68,13 @@ public class Commandpanelsdata implements CommandExecutor {
|
||||
}else if (args.length == 4){
|
||||
if(args[0].equals("set")){
|
||||
//for set command
|
||||
plugin.panelData.setUserData(plugin.panelData.getOffline(args[1]), args[2],args[3],true);
|
||||
if (args[1].equalsIgnoreCase("all")) {
|
||||
for (OfflinePlayer player : Bukkit.getOfflinePlayers()) {
|
||||
plugin.panelData.setUserData(plugin.panelData.getOffline(player.getName()), args[2],args[3],true);
|
||||
}
|
||||
} else {
|
||||
plugin.panelData.setUserData(plugin.panelData.getOffline(args[1]), args[2], args[3], true);
|
||||
}
|
||||
if(sendPlayerMessage) {
|
||||
sender.sendMessage(plugin.tex.colour(plugin.tag
|
||||
+ ChatColor.GREEN + "Set "
|
||||
@ -65,7 +84,12 @@ public class Commandpanelsdata implements CommandExecutor {
|
||||
}
|
||||
}else{
|
||||
//for add command
|
||||
plugin.panelData.setUserData(plugin.panelData.getOffline(args[1]), args[2],args[3],false);
|
||||
if (args[1].equalsIgnoreCase("all")) {
|
||||
for (OfflinePlayer player : Bukkit.getOfflinePlayers()) {
|
||||
plugin.panelData.setUserData(plugin.panelData.getOffline(player.getName()), args[2],args[3],false);
|
||||
}
|
||||
} else
|
||||
plugin.panelData.setUserData(plugin.panelData.getOffline(args[1]), args[2],args[3],false);
|
||||
if(sendPlayerMessage) {
|
||||
sender.sendMessage(plugin.tex.colour(plugin.tag
|
||||
+ ChatColor.GREEN + "Set "
|
||||
@ -77,7 +101,7 @@ public class Commandpanelsdata implements CommandExecutor {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + "Usage: /cpdata <set:add:get:remove:clear> <player> <data> [value]"));
|
||||
sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + "Usage: /cpdata <set:add:get:remove:clear> <player|all> <data> [value]"));
|
||||
}else{
|
||||
sender.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.perms")));
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ public class Commandpanelsdebug implements CommandExecutor {
|
||||
CommandPanels plugin;
|
||||
public Commandpanelsdebug(CommandPanels pl) { this.plugin = pl; }
|
||||
|
||||
@EventHandler
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
if (sender.hasPermission("commandpanel.debug")) {
|
||||
if (args.length == 0) {
|
||||
|
@ -2,6 +2,7 @@ package me.rockyhawk.commandpanels.completetabs;
|
||||
|
||||
import me.rockyhawk.commandpanels.CommandPanels;
|
||||
import me.rockyhawk.commandpanels.api.Panel;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
@ -9,41 +10,68 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
|
||||
public class CpTabComplete implements TabCompleter {
|
||||
CommandPanels plugin;
|
||||
public CpTabComplete(CommandPanels pl) { this.plugin = pl; }
|
||||
|
||||
public CpTabComplete(CommandPanels pl) {
|
||||
this.plugin = pl;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
if(sender instanceof Player && args.length == 1){
|
||||
Player p = ((Player) sender).getPlayer();
|
||||
if(label.equalsIgnoreCase("cp") || label.equalsIgnoreCase("cpanel") || label.equalsIgnoreCase("commandpanel")){
|
||||
ArrayList<String> apanels = new ArrayList<String>(); //all panels
|
||||
for(Panel panel : plugin.panelList) { //will loop through all the files in folder
|
||||
try {
|
||||
if (!panel.getName().startsWith(args[0])) {
|
||||
//this will narrow down the panels to what the user types
|
||||
continue;
|
||||
}
|
||||
if (sender.hasPermission("commandpanel.panel." + panel.getConfig().getString("perm"))) {
|
||||
if(panel.getConfig().contains("panelType")) {
|
||||
if (panel.getConfig().getStringList("panelType").contains("nocommand")) {
|
||||
//do not allow command with nocommand
|
||||
continue;
|
||||
if (sender instanceof Player && args.length >= 1)
|
||||
if (label.equalsIgnoreCase("cp") || label.equalsIgnoreCase("cpanel") || label.equalsIgnoreCase("commandpanel")) {
|
||||
Player p = ((Player) sender).getPlayer();
|
||||
if (args.length == 1) {
|
||||
ArrayList<String> apanels = new ArrayList<String>(); //all panels
|
||||
for (Panel panel : plugin.panelList) { //will loop through all the files in folder
|
||||
try {
|
||||
if (!panel.getName().startsWith(args[0])) {
|
||||
//this will narrow down the panels to what the user types
|
||||
continue;
|
||||
}
|
||||
if (sender.hasPermission("commandpanel.panel." + panel.getConfig().getString("perm"))) {
|
||||
if (panel.getConfig().contains("panelType")) {
|
||||
if (panel.getConfig().getStringList("panelType").contains("nocommand")) {
|
||||
//do not allow command with nocommand
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (plugin.panelPerms.isPanelWorldEnabled(p, panel.getConfig())) {
|
||||
apanels.add(panel.getName());
|
||||
}
|
||||
}
|
||||
if(plugin.panelPerms.isPanelWorldEnabled(p,panel.getConfig())){
|
||||
apanels.add(panel.getName());
|
||||
}
|
||||
} catch (Exception skip) {
|
||||
//ignore panel
|
||||
}
|
||||
}catch(Exception skip){
|
||||
//ignore panel
|
||||
}
|
||||
return apanels;
|
||||
}
|
||||
return apanels;
|
||||
|
||||
if (args.length == 2 || args.length == 3) {
|
||||
|
||||
List<String> aplayers = new ArrayList<>();
|
||||
|
||||
if ("all".startsWith(args[(args.length == 2 ? 1 : 2)].toLowerCase())) aplayers.add("all");
|
||||
|
||||
if (args.length == 2 && "item".startsWith(args[1].toLowerCase())) aplayers.add("item");
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
String name = player.getName();
|
||||
if (name.toLowerCase().startsWith(args[(args.length == 2 ? 1 : 2)])) {
|
||||
//this will narrow down the panels to what the user types
|
||||
aplayers.add(name);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return aplayers;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
@ -2,6 +2,7 @@ package me.rockyhawk.commandpanels.completetabs;
|
||||
|
||||
import me.rockyhawk.commandpanels.CommandPanels;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
@ -19,17 +20,23 @@ public class DataTabComplete implements TabCompleter {
|
||||
if(sender.hasPermission("commandpanel.data")) {
|
||||
ArrayList<String> output = new ArrayList<>();
|
||||
if(args.length == 1){
|
||||
output.add("set");
|
||||
output.add("add");
|
||||
output.add("get");
|
||||
output.add("remove");
|
||||
output.add("clear");
|
||||
String arg1 = args[0].toLowerCase();
|
||||
if ("set".startsWith(arg1))output.add("set");
|
||||
if ("add".startsWith(arg1))output.add("add");
|
||||
if ("get".startsWith(arg1))output.add("get");
|
||||
if ("remove".startsWith(arg1))output.add("remove");
|
||||
if ("clear".startsWith(arg1))output.add("clear");
|
||||
}else if(args.length == 2){
|
||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||
if (!p.getName().startsWith(args[1])) {
|
||||
continue;
|
||||
if ("all".startsWith(args[1].toLowerCase()) && !args[0].equalsIgnoreCase("get")) output.add("all");
|
||||
|
||||
for (OfflinePlayer player : Bukkit.getOfflinePlayers()) {
|
||||
String name = player.getName();
|
||||
// don't worry about it saying it may throw a NPE
|
||||
if (name.toLowerCase().startsWith(args[1])) {
|
||||
//this will narrow down the panels to what the user types
|
||||
output.add(name);
|
||||
}
|
||||
output.add(p.getName());
|
||||
|
||||
}
|
||||
}else if(args.length == 3){
|
||||
//the clear function is here as it is the only subcommand with 3 args
|
||||
|
Loading…
Reference in New Issue
Block a user