Improve command completion (List Arenas & Keywords)

This commit is contained in:
Arnaud G. GIBERT 2021-04-30 02:57:21 +02:00
parent c8806ac1ed
commit b579e75da7
23 changed files with 284 additions and 42 deletions

View File

@ -6,6 +6,7 @@ import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.TreeMap;
import org.bukkit.Location;
import org.bukkit.World;
@ -177,6 +178,15 @@ public class ArenaManager {
}
}
public List getArenaNameList() {
List<String> list = new ArrayList();
if(_ARENAS.size() > 0) {
list = new ArrayList<>(_ARENAS.keySet());
}
return list;
}
public void listArenas(Player player) {
String type, status;

View File

@ -1,6 +1,7 @@
package com.Geekpower14.Quake.Commands;
import com.Geekpower14.Quake.Quake;
import java.util.List;
import org.bukkit.entity.Player;
public class AddLobbyCommand
@ -22,6 +23,11 @@ implements BasicCommand {
return true;
}
@Override
public String getPermission() {
return "Quake.lobby";
}
@Override
public String help(Player p) {
if (Quake.hasPermission(p, getPermission())) {
@ -31,8 +37,10 @@ implements BasicCommand {
}
@Override
public String getPermission() {
return "Quake.lobby";
public List<String> getCompletionList(String[] args) {
List<String> list = null;
return list;
}
}

View File

@ -4,6 +4,8 @@ import com.Geekpower14.Quake.Arena.Arena;
import com.Geekpower14.Quake.Arena.SArena;
import com.Geekpower14.Quake.Arena.TArena;
import com.Geekpower14.Quake.Quake;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
@ -49,6 +51,11 @@ public class AddSpawnCommand implements BasicCommand {
return true;
}
@Override
public String getPermission() {
return "Quake.edit";
}
@Override
public String help(Player p) {
if(Quake.hasPermission(p, getPermission()))
@ -57,8 +64,19 @@ public class AddSpawnCommand implements BasicCommand {
}
@Override
public String getPermission() {
return "Quake.edit";
public List<String> getCompletionList(String[] args) {
List<String> list = null;
if( args.length <= 2) {
list = _plugin._am.getArenaNameList();
} else {
list = new ArrayList();
list.add(" ");
list.add("TEAM");
}
return list;
}
}

View File

@ -6,13 +6,16 @@
*/
package com.Geekpower14.Quake.Commands;
import java.util.List;
import org.bukkit.entity.Player;
public interface BasicCommand {
public boolean onCommand(Player var1, String[] var2);
public String getPermission();
public String help(Player var1);
public String getPermission();
public List<String> getCompletionList(String[] args);
}

View File

@ -4,6 +4,7 @@ import com.Geekpower14.Quake.Arena.Arena;
import com.Geekpower14.Quake.Arena.SArena;
import com.Geekpower14.Quake.Arena.TArena;
import com.Geekpower14.Quake.Quake;
import java.util.List;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
@ -40,6 +41,11 @@ public class ChangeTeamCommand implements BasicCommand {
return true;
}
@Override
public String getPermission() {
return "Quake.ChangeTeam";
}
@Override
public String help(Player p) {
if (Quake.hasPermission(p, getPermission())) {
@ -49,8 +55,10 @@ public class ChangeTeamCommand implements BasicCommand {
}
@Override
public String getPermission() {
return "Quake.ChangeTeam";
public List<String> getCompletionList(String[] args) {
List<String> list = null;
return list;
}
}

View File

@ -1,6 +1,8 @@
package com.Geekpower14.Quake.Commands;
import com.Geekpower14.Quake.Quake;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
@ -34,6 +36,11 @@ public class CreateCommand implements BasicCommand {
return true;
}
@Override
public String getPermission() {
return "Quake.edit";
}
@Override
public String help(Player p) {
if (Quake.hasPermission(p, getPermission())) {
@ -43,8 +50,17 @@ public class CreateCommand implements BasicCommand {
}
@Override
public String getPermission() {
return "Quake.edit";
public List<String> getCompletionList(String[] args) {
List<String> list = null;
if( args.length == 3) {
list = new ArrayList();
list.add("Solo");
list.add("Team");
}
return list;
}
}

View File

@ -2,6 +2,7 @@ package com.Geekpower14.Quake.Commands;
import com.Geekpower14.Quake.Arena.Arena;
import com.Geekpower14.Quake.Quake;
import java.util.List;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
@ -50,6 +51,11 @@ public class JoinCommand implements BasicCommand {
return true;
}
@Override
public String getPermission() {
return "Quake.player";
}
@Override
public String help(Player p) {
if (Quake.hasPermission(p, getPermission())) {
@ -59,8 +65,14 @@ public class JoinCommand implements BasicCommand {
}
@Override
public String getPermission() {
return "Quake.player";
public List<String> getCompletionList(String[] args) {
List<String> list = null;
if( args.length <= 2) {
list = _plugin._am.getArenaNameList();
}
return list;
}
}

View File

@ -2,6 +2,7 @@ package com.Geekpower14.Quake.Commands;
import com.Geekpower14.Quake.Arena.Arena;
import com.Geekpower14.Quake.Quake;
import java.util.List;
import org.bukkit.entity.Player;
public class LeaveCommand implements BasicCommand {
@ -26,6 +27,11 @@ public class LeaveCommand implements BasicCommand {
return false;
}
@Override
public String getPermission() {
return "Quake.player";
}
@Override
public String help(Player p) {
if (Quake.hasPermission(p, getPermission())) {
@ -35,8 +41,10 @@ public class LeaveCommand implements BasicCommand {
}
@Override
public String getPermission() {
return "Quake.player";
public List<String> getCompletionList(String[] args) {
List<String> list = null;
return list;
}
}

View File

@ -9,6 +9,8 @@
package com.Geekpower14.Quake.Commands;
import com.Geekpower14.Quake.Quake;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
@ -68,6 +70,11 @@ public class MoneyCommand implements BasicCommand {
return true;
}
@Override
public String getPermission() {
return "Quake.edit";
}
@Override
public String help(Player p) {
if (Quake.hasPermission(p, getPermission())) {
@ -77,8 +84,19 @@ public class MoneyCommand implements BasicCommand {
}
@Override
public String getPermission() {
return "Quake.edit";
public List<String> getCompletionList(String[] args) {
List<String> list = null;
if( args.length <= 2) {
list = new ArrayList();
list.add("set");
list.add("add");
list.add("remove");
list.add("get");
}
return list;
}
}

View File

@ -103,11 +103,16 @@ public class MyCommandExecutor implements CommandExecutor {
public List<String> getCompletionList(String[] args) {
List<String> list = null;
if( args.length == 1) {
if( args.length <= 1) {
list = _commands.keySet().stream().collect(Collectors.toList());
list.add( "help");
list.add( "?");
}
else {
if(_commands.containsKey(args[0])) {
list = _commands.get(args[0]).getCompletionList(args);
}
}
return list;
}

View File

@ -1,6 +1,7 @@
package com.Geekpower14.Quake.Commands;
import com.Geekpower14.Quake.Quake;
import java.util.List;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
@ -26,6 +27,11 @@ public class ReloadCommand implements BasicCommand {
return true;
}
@Override
public String getPermission() {
return "Quake.admin";
}
@Override
public String help(Player p) {
if (Quake.hasPermission(p, getPermission())) {
@ -35,8 +41,10 @@ public class ReloadCommand implements BasicCommand {
}
@Override
public String getPermission() {
return "Quake.admin";
public List<String> getCompletionList(String[] args) {
List<String> list = null;
return list;
}
}

View File

@ -2,6 +2,7 @@ package com.Geekpower14.Quake.Commands;
import com.Geekpower14.Quake.Arena.Arena;
import com.Geekpower14.Quake.Quake;
import java.util.List;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
@ -39,6 +40,11 @@ public class RemoveCommand implements BasicCommand {
return true;
}
@Override
public String getPermission() {
return "Quake.edit";
}
@Override
public String help(Player p) {
if (Quake.hasPermission(p, getPermission())) {
@ -48,8 +54,14 @@ public class RemoveCommand implements BasicCommand {
}
@Override
public String getPermission() {
return "Quake.edit";
public List<String> getCompletionList(String[] args) {
List<String> list = null;
if( args.length <= 2) {
list = _plugin._am.getArenaNameList();
}
return list;
}
}

View File

@ -8,6 +8,7 @@
package com.Geekpower14.Quake.Commands;
import com.Geekpower14.Quake.Quake;
import java.util.List;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
@ -35,6 +36,11 @@ public class RemoveLobbyCommand implements BasicCommand {
return true;
}
@Override
public String getPermission() {
return "Quake.lobby";
}
@Override
public String help(Player p) {
if (Quake.hasPermission(p, getPermission())) {
@ -44,8 +50,10 @@ public class RemoveLobbyCommand implements BasicCommand {
}
@Override
public String getPermission() {
return "Quake.lobby";
public List<String> getCompletionList(String[] args) {
List<String> list = null;
return list;
}
}

View File

@ -4,6 +4,7 @@ import com.Geekpower14.Quake.Arena.Arena;
import com.Geekpower14.Quake.Arena.SArena;
import com.Geekpower14.Quake.Arena.TArena;
import com.Geekpower14.Quake.Quake;
import java.util.List;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
@ -53,6 +54,11 @@ public class RemoveSpawnCommand implements BasicCommand {
return true;
}
@Override
public String getPermission() {
return "Quake.edit";
}
@Override
public String help(Player p) {
if (Quake.hasPermission(p, getPermission())) {
@ -62,8 +68,14 @@ public class RemoveSpawnCommand implements BasicCommand {
}
@Override
public String getPermission() {
return "Quake.edit";
public List<String> getCompletionList(String[] args) {
List<String> list = null;
if( args.length <= 2) {
list = _plugin._am.getArenaNameList();
}
return list;
}
}

View File

@ -9,6 +9,7 @@ package com.Geekpower14.Quake.Commands;
import com.Geekpower14.Quake.Arena.Arena;
import com.Geekpower14.Quake.Quake;
import java.util.List;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
@ -42,6 +43,11 @@ public class SaveCommand implements BasicCommand {
return true;
}
@Override
public String getPermission() {
return "Quake.edit";
}
@Override
public String help(Player p) {
if (Quake.hasPermission(p, getPermission())) {
@ -51,8 +57,14 @@ public class SaveCommand implements BasicCommand {
}
@Override
public String getPermission() {
return "Quake.edit";
public List<String> getCompletionList(String[] args) {
List<String> list = null;
if( args.length <= 2) {
list = _plugin._am.getArenaNameList();
}
return list;
}
}

View File

@ -8,6 +8,7 @@
package com.Geekpower14.Quake.Commands;
import com.Geekpower14.Quake.Quake;
import java.util.List;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
@ -30,6 +31,11 @@ public class SetLobbySpawnCommand implements BasicCommand {
return true;
}
@Override
public String getPermission() {
return "Quake.lobby";
}
@Override
public String help(Player p) {
if (Quake.hasPermission(p, getPermission())) {
@ -39,8 +45,10 @@ public class SetLobbySpawnCommand implements BasicCommand {
}
@Override
public String getPermission() {
return "Quake.lobby";
public List<String> getCompletionList(String[] args) {
List<String> list = null;
return list;
}
}

View File

@ -9,6 +9,7 @@ package com.Geekpower14.Quake.Commands;
import com.Geekpower14.Quake.Arena.Arena;
import com.Geekpower14.Quake.Quake;
import java.util.List;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
@ -47,6 +48,11 @@ public class SetMapCommand implements BasicCommand {
return true;
}
@Override
public String getPermission() {
return "Quake.edit";
}
@Override
public String help(Player p) {
if (Quake.hasPermission(p, getPermission())) {
@ -56,8 +62,14 @@ public class SetMapCommand implements BasicCommand {
}
@Override
public String getPermission() {
return "Quake.edit";
public List<String> getCompletionList(String[] args) {
List<String> list = null;
if( args.length <= 2) {
list = _plugin._am.getArenaNameList();
}
return list;
}
}

View File

@ -9,6 +9,7 @@ package com.Geekpower14.Quake.Commands;
import com.Geekpower14.Quake.Arena.Arena;
import com.Geekpower14.Quake.Quake;
import java.util.List;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
@ -47,6 +48,11 @@ public class SetMaxCommand implements BasicCommand {
return true;
}
@Override
public String getPermission() {
return "Quake.edit";
}
@Override
public String help(Player p) {
if (Quake.hasPermission(p, getPermission())) {
@ -56,8 +62,14 @@ public class SetMaxCommand implements BasicCommand {
}
@Override
public String getPermission() {
return "Quake.edit";
public List<String> getCompletionList(String[] args) {
List<String> list = null;
if( args.length <= 2) {
list = _plugin._am.getArenaNameList();
}
return list;
}
}

View File

@ -9,6 +9,7 @@ package com.Geekpower14.Quake.Commands;
import com.Geekpower14.Quake.Arena.Arena;
import com.Geekpower14.Quake.Quake;
import java.util.List;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
@ -47,6 +48,11 @@ public class SetMinCommand implements BasicCommand {
return true;
}
@Override
public String getPermission() {
return "Quake.edit";
}
@Override
public String help(Player p) {
if (Quake.hasPermission(p, getPermission())) {
@ -56,8 +62,14 @@ public class SetMinCommand implements BasicCommand {
}
@Override
public String getPermission() {
return "Quake.edit";
public List<String> getCompletionList(String[] args) {
List<String> list = null;
if( args.length <= 2) {
list = _plugin._am.getArenaNameList();
}
return list;
}
}

View File

@ -7,6 +7,7 @@
package com.Geekpower14.Quake.Commands;
import com.Geekpower14.Quake.Quake;
import java.util.List;
import org.bukkit.entity.Player;
public class ShopCommand implements BasicCommand {
@ -27,6 +28,11 @@ public class ShopCommand implements BasicCommand {
return false;
}
@Override
public String getPermission() {
return "Quake.player";
}
@Override
public String help(Player p) {
if (Quake.hasPermission(p, getPermission())) {
@ -36,8 +42,10 @@ public class ShopCommand implements BasicCommand {
}
@Override
public String getPermission() {
return "Quake.player";
public List<String> getCompletionList(String[] args) {
List<String> list = null;
return list;
}
}

View File

@ -9,6 +9,7 @@ package com.Geekpower14.Quake.Commands;
import com.Geekpower14.Quake.Arena.Arena;
import com.Geekpower14.Quake.Quake;
import java.util.List;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
@ -42,6 +43,11 @@ public class StartCommand implements BasicCommand {
return true;
}
@Override
public String getPermission() {
return "Quake.modo";
}
@Override
public String help(Player p) {
if (Quake.hasPermission(p, getPermission())) {
@ -51,8 +57,14 @@ public class StartCommand implements BasicCommand {
}
@Override
public String getPermission() {
return "Quake.modo";
public List<String> getCompletionList(String[] args) {
List<String> list = null;
if( args.length <= 2) {
list = _plugin._am.getArenaNameList();
}
return list;
}
}

View File

@ -9,6 +9,7 @@ package com.Geekpower14.Quake.Commands;
import com.Geekpower14.Quake.Arena.Arena;
import com.Geekpower14.Quake.Quake;
import java.util.List;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
@ -44,6 +45,11 @@ public class StopCommand implements BasicCommand {
return true;
}
@Override
public String getPermission() {
return "Quake.modo";
}
@Override
public String help(Player p) {
if (Quake.hasPermission(p, getPermission())) {
@ -53,8 +59,14 @@ public class StopCommand implements BasicCommand {
}
@Override
public String getPermission() {
return "Quake.modo";
public List<String> getCompletionList(String[] args) {
List<String> list = null;
if( args.length <= 2) {
list = _plugin._am.getArenaNameList();
}
return list;
}
}

View File

@ -9,6 +9,7 @@ package com.Geekpower14.Quake.Commands;
import com.Geekpower14.Quake.Arena.APlayer;
import com.Geekpower14.Quake.Arena.Arena;
import com.Geekpower14.Quake.Quake;
import java.util.List;
import org.bukkit.entity.Player;
public class UtilsCommand implements BasicCommand {
@ -38,6 +39,11 @@ public class UtilsCommand implements BasicCommand {
return false;
}
@Override
public String getPermission() {
return "Quake.admin";
}
@Override
public String help(Player p) {
if(Quake.hasPermission(p, getPermission())) {
@ -47,8 +53,10 @@ public class UtilsCommand implements BasicCommand {
}
@Override
public String getPermission() {
return "Quake.admin";
public List<String> getCompletionList(String[] args) {
List<String> list = null;
return list;
}
}