Add a first version of the command completion
Improve list command output (new data, sort, color...) Improve help command output (sort) Rename score board Minor fixing
This commit is contained in:
parent
1b6d7f4703
commit
c8806ac1ed
@ -423,11 +423,22 @@ public abstract class Arena {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getStatus() {
|
public String getStatus(Boolean bracket) {
|
||||||
return this._etat <= this._pregame ? (this.getplayers() == this._maxplayer ? ChatColor.DARK_PURPLE + "[FULL]" :
|
String osb, csb;
|
||||||
(this._VIP ? ChatColor.AQUA + "[VIP]" :
|
|
||||||
(this._etat <= this._starting ? ChatColor.GOLD + "[Starting in " + this._etat + "s]" :
|
if( bracket)
|
||||||
ChatColor.GREEN + "[Join]"))) : ChatColor.RED + "[In Game]";
|
{
|
||||||
|
osb="[";
|
||||||
|
csb="]";
|
||||||
|
} else {
|
||||||
|
osb="";
|
||||||
|
csb="";
|
||||||
|
}
|
||||||
|
|
||||||
|
return this._etat <= this._pregame ? (this.getplayers() == this._maxplayer ? ChatColor.DARK_PURPLE + osb + "FULL" + csb :
|
||||||
|
(this._VIP ? ChatColor.AQUA + osb + "VIP" + csb :
|
||||||
|
(this._etat <= this._starting ? ChatColor.GOLD + osb + "Starting in " + this._etat + "s" + csb :
|
||||||
|
ChatColor.GREEN + osb + "Join" + csb))) : ChatColor.RED + osb + "In Game" + csb;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@ import java.io.File;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.TreeMap;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
@ -184,16 +185,26 @@ public class ArenaManager {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
player.sendMessage(ChatColor.LIGHT_PURPLE +"Arena List:");
|
player.sendMessage(ChatColor.LIGHT_PURPLE +"Arena List:");
|
||||||
TableGenerator tg = new TableGenerator(TableGenerator.Alignment.RIGHT, TableGenerator.Alignment.LEFT, TableGenerator.Alignment.LEFT, TableGenerator.Alignment.RIGHT);
|
player.sendMessage("");
|
||||||
|
|
||||||
|
TreeMap<Integer, Arena> _ARENAS_sorted = new TreeMap();
|
||||||
for(Arena aren : _ARENAS.values()) {
|
for(Arena aren : _ARENAS.values()) {
|
||||||
|
_ARENAS_sorted.put( aren._ID, aren);
|
||||||
|
}
|
||||||
|
|
||||||
|
TableGenerator tg = new TableGenerator(TableGenerator.Alignment.RIGHT, TableGenerator.Alignment.LEFT, TableGenerator.Alignment.LEFT, TableGenerator.Alignment.CENTER, TableGenerator.Alignment.RIGHT, TableGenerator.Alignment.CENTER, TableGenerator.Alignment.RIGHT);
|
||||||
|
tg.addRow( ChatColor.RED + "§nID§r" + ChatColor.WHITE, ChatColor.GREEN + "§nType§r", "§nArena Name§r" + ChatColor.WHITE, ChatColor.GREEN + "§nStatus§r" + ChatColor.WHITE, ChatColor.GOLD + "§nNb P§r", ChatColor.BLUE + "§nMin" + ChatColor.WHITE + "§n/" + ChatColor.RED + "§nMax§r", "§nSpawn§r");
|
||||||
|
tg.addRow();
|
||||||
|
|
||||||
|
for(Arena aren : _ARENAS_sorted.values()) {
|
||||||
if(aren instanceof SArena) {
|
if(aren instanceof SArena) {
|
||||||
type="Solo";
|
type="Solo";
|
||||||
} else {
|
} else {
|
||||||
type="Team";
|
type="Team";
|
||||||
}
|
}
|
||||||
|
|
||||||
tg.addRow( ChatColor.RED + Integer.toString(aren._ID) + ChatColor.WHITE, ChatColor.GREEN + type , aren._name + ChatColor.WHITE, aren.getStatus());
|
tg.addRow( ChatColor.RED + Integer.toString(aren._ID) + ChatColor.WHITE, ChatColor.GREEN + type , aren._name + ChatColor.WHITE, aren.getStatus(false),
|
||||||
|
ChatColor.GOLD + Integer.toString( aren._players.size()), ChatColor.BLUE + Integer.toString( aren._minplayer) + ChatColor.WHITE + " / " + ChatColor.RED + Integer.toString( aren._maxplayer) + ChatColor.WHITE, type == "Solo" ? Integer.toString( aren._spawns.size()) : Integer.toString( aren._spawns_B.size()) + " + " + Integer.toString( aren._spawns_R.size()));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,7 +3,9 @@ package com.Geekpower14.Quake.Commands;
|
|||||||
import com.Geekpower14.Quake.Quake;
|
import com.Geekpower14.Quake.Quake;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
@ -12,7 +14,7 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
public class MyCommandExecutor implements CommandExecutor {
|
public class MyCommandExecutor implements CommandExecutor {
|
||||||
public Quake _plugin;
|
public Quake _plugin;
|
||||||
private final HashMap<String, BasicCommand> _commands = new HashMap<>();
|
private final LinkedHashMap<String, BasicCommand> _commands = new LinkedHashMap<>();
|
||||||
|
|
||||||
public MyCommandExecutor(Quake pl) {
|
public MyCommandExecutor(Quake pl) {
|
||||||
_plugin = pl;
|
_plugin = pl;
|
||||||
@ -36,13 +38,13 @@ public class MyCommandExecutor implements CommandExecutor {
|
|||||||
_commands.put("leave", new LeaveCommand(_plugin));
|
_commands.put("leave", new LeaveCommand(_plugin));
|
||||||
_commands.put("start", new StartCommand(_plugin));
|
_commands.put("start", new StartCommand(_plugin));
|
||||||
_commands.put("stop", new StopCommand(_plugin));
|
_commands.put("stop", new StopCommand(_plugin));
|
||||||
_commands.put("shop", new ShopCommand(_plugin));
|
|
||||||
_commands.put("kill", new UtilsCommand(_plugin, "kill"));
|
|
||||||
_commands.put("add", new UtilsCommand(_plugin, "add"));
|
|
||||||
_commands.put("lol", new UtilsCommand(_plugin, "lol"));
|
|
||||||
_commands.put("reload", new ReloadCommand(_plugin));
|
|
||||||
_commands.put("team", new ChangeTeamCommand(_plugin));
|
_commands.put("team", new ChangeTeamCommand(_plugin));
|
||||||
_commands.put("money", new MoneyCommand(_plugin));
|
_commands.put("money", new MoneyCommand(_plugin));
|
||||||
|
_commands.put("shop", new ShopCommand(_plugin));
|
||||||
|
_commands.put("add", new UtilsCommand(_plugin, "add"));
|
||||||
|
_commands.put("kill", new UtilsCommand(_plugin, "kill"));
|
||||||
|
_commands.put("lol", new UtilsCommand(_plugin, "lol"));
|
||||||
|
_commands.put("reload", new ReloadCommand(_plugin));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -55,13 +57,13 @@ public class MyCommandExecutor implements CommandExecutor {
|
|||||||
player = (Player)sender;
|
player = (Player)sender;
|
||||||
if(cmd.getName().equalsIgnoreCase("quake")) {
|
if(cmd.getName().equalsIgnoreCase("quake")) {
|
||||||
if(args == null || args.length < 1) {
|
if(args == null || args.length < 1) {
|
||||||
player.sendMessage(ChatColor.YELLOW + "Plugin By Geekpower14u / Bl4ckSkull666");
|
player.sendMessage(ChatColor.YELLOW + "Plugin by GeekPower14 / Bl4ckSkull666");
|
||||||
player.sendMessage(ChatColor.YELLOW + "Updated bt AlkorZ3 ( Obsidia.Rx3.net )");
|
player.sendMessage(ChatColor.YELLOW + "Updated by AlkorZ3 ( obsidia.rx3.net )");
|
||||||
player.sendMessage(ChatColor.YELLOW + "Version: " + _plugin.getDescription().getVersion());
|
player.sendMessage(ChatColor.YELLOW + "Version: " + _plugin.getDescription().getVersion());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(args[0].equalsIgnoreCase("help")) {
|
if(args[0].equalsIgnoreCase("help") || args[0].equalsIgnoreCase("?")) {
|
||||||
help(player);
|
help(player);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -92,9 +94,21 @@ public class MyCommandExecutor implements CommandExecutor {
|
|||||||
|
|
||||||
public void help(Player p) {
|
public void help(Player p) {
|
||||||
p.sendMessage("/Quake <command> <args>");
|
p.sendMessage("/Quake <command> <args>");
|
||||||
|
|
||||||
for (BasicCommand v : _commands.values()) {
|
for (BasicCommand v : _commands.values()) {
|
||||||
p.sendMessage(ChatColor.GRAY + "- " + v.help(p));
|
p.sendMessage(ChatColor.AQUA + "- " + v.help(p));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
public List<String> getCompletionList(String[] args) {
|
||||||
|
List<String> list = null;
|
||||||
|
|
||||||
|
if( args.length == 1) {
|
||||||
|
list = _commands.keySet().stream().collect(Collectors.toList());
|
||||||
|
list.add( "help");
|
||||||
|
list.add( "?");
|
||||||
|
}
|
||||||
|
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
34
src/com/Geekpower14/Quake/Commands/MyTabCompleter.java
Normal file
34
src/com/Geekpower14/Quake/Commands/MyTabCompleter.java
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
package com.Geekpower14.Quake.Commands;
|
||||||
|
|
||||||
|
import com.Geekpower14.Quake.Quake;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.command.TabCompleter;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class MyTabCompleter implements TabCompleter
|
||||||
|
{
|
||||||
|
public Quake _plugin;
|
||||||
|
|
||||||
|
public MyTabCompleter(Quake pl) {
|
||||||
|
_plugin = pl;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> onTabComplete (CommandSender sender, Command cmd, String label, String[] args) {
|
||||||
|
List<String> list = new ArrayList<>();
|
||||||
|
// _plugin.getLogger().info("MTC [" + cmd + "] [" + label + "] [" + args.length + "]");
|
||||||
|
|
||||||
|
if(cmd.getName().equalsIgnoreCase("quake") && args.length >= 0){
|
||||||
|
if(sender instanceof Player){
|
||||||
|
list = _plugin._ce.getCompletionList(args);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
}
|
@ -235,7 +235,7 @@ public class LobbyManager {
|
|||||||
/*
|
/*
|
||||||
String ligne0 = arena._etat <= arena._pregame ? (arena.getplayers() == arena._maxplayer ? ChatColor.DARK_PURPLE + "[FULL]" : (arena._VIP ? ChatColor.AQUA + "[VIP]" : (arena._etat <= arena._starting ? ChatColor.GOLD + "[Starting]" : ChatColor.GREEN + "[Join]"))) : ChatColor.RED + "[InGame]";
|
String ligne0 = arena._etat <= arena._pregame ? (arena.getplayers() == arena._maxplayer ? ChatColor.DARK_PURPLE + "[FULL]" : (arena._VIP ? ChatColor.AQUA + "[VIP]" : (arena._etat <= arena._starting ? ChatColor.GOLD + "[Starting]" : ChatColor.GREEN + "[Join]"))) : ChatColor.RED + "[InGame]";
|
||||||
*/
|
*/
|
||||||
String ligne0 = arena.getStatus();
|
String ligne0 = arena.getStatus(true);
|
||||||
String tmp = "";
|
String tmp = "";
|
||||||
if (arena instanceof SArena) {
|
if (arena instanceof SArena) {
|
||||||
tmp = "S-";
|
tmp = "S-";
|
||||||
|
@ -2,6 +2,7 @@ package com.Geekpower14.Quake;
|
|||||||
|
|
||||||
import com.Geekpower14.Quake.Arena.ArenaManager;
|
import com.Geekpower14.Quake.Arena.ArenaManager;
|
||||||
import com.Geekpower14.Quake.Commands.MyCommandExecutor;
|
import com.Geekpower14.Quake.Commands.MyCommandExecutor;
|
||||||
|
import com.Geekpower14.Quake.Commands.MyTabCompleter;
|
||||||
import com.Geekpower14.Quake.Eco.EcoManager;
|
import com.Geekpower14.Quake.Eco.EcoManager;
|
||||||
import com.Geekpower14.Quake.Listener.PlayerListener;
|
import com.Geekpower14.Quake.Listener.PlayerListener;
|
||||||
import com.Geekpower14.Quake.Listener.Weather;
|
import com.Geekpower14.Quake.Listener.Weather;
|
||||||
@ -40,6 +41,7 @@ extends JavaPlugin {
|
|||||||
public static boolean _debug = false;
|
public static boolean _debug = false;
|
||||||
public static String _version = "3.5.0";
|
public static String _version = "3.5.0";
|
||||||
public static Version _ver = new Version(_version);
|
public static Version _ver = new Version(_version);
|
||||||
|
public MyCommandExecutor _ce = null;
|
||||||
public ArenaManager _am = null;
|
public ArenaManager _am = null;
|
||||||
public LobbyManager _lobby = null;
|
public LobbyManager _lobby = null;
|
||||||
public int _threadlob = 0;
|
public int _threadlob = 0;
|
||||||
@ -91,7 +93,9 @@ extends JavaPlugin {
|
|||||||
_stuff = new StuffManager(this);
|
_stuff = new StuffManager(this);
|
||||||
getServer().getPluginManager().registerEvents(new PlayerListener(this), this);
|
getServer().getPluginManager().registerEvents(new PlayerListener(this), this);
|
||||||
getServer().getPluginManager().registerEvents(new Weather(this), this);
|
getServer().getPluginManager().registerEvents(new Weather(this), this);
|
||||||
getCommand("Quake").setExecutor(new MyCommandExecutor(this));
|
_ce=new MyCommandExecutor(this);
|
||||||
|
getCommand("Quake").setExecutor(_ce);
|
||||||
|
getCommand("Quake").setTabCompleter(new MyTabCompleter(this));
|
||||||
_am = new ArenaManager(this);
|
_am = new ArenaManager(this);
|
||||||
_lobby = new LobbyManager(this);
|
_lobby = new LobbyManager(this);
|
||||||
_threadlob = Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new Runnable(){
|
_threadlob = Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new Runnable(){
|
||||||
|
@ -38,7 +38,7 @@ public class Translate {
|
|||||||
setDefaultConfig("ScoreBoard.Deaths.name", "Deaths");
|
setDefaultConfig("ScoreBoard.Deaths.name", "Deaths");
|
||||||
setDefaultConfig("ScoreBoard.Shots.name", "Shots");
|
setDefaultConfig("ScoreBoard.Shots.name", "Shots");
|
||||||
setDefaultConfig("ScoreBoard.Wins.name", "Wins");
|
setDefaultConfig("ScoreBoard.Wins.name", "Wins");
|
||||||
setDefaultConfig("ScoreBoard.name", "Scores");
|
setDefaultConfig("ScoreBoard.name", "Quake Scores");
|
||||||
setDefaultConfig("Shop.price", "&r&o&6Price: [PRICE]");
|
setDefaultConfig("Shop.price", "&r&o&6Price: [PRICE]");
|
||||||
setDefaultConfig("Shop.needToBuy", "&r&o&6Need: [NEED]");
|
setDefaultConfig("Shop.needToBuy", "&r&o&6Need: [NEED]");
|
||||||
setDefaultConfig("Shop.navigation.previousPage", "&aBack");
|
setDefaultConfig("Shop.navigation.previousPage", "&aBack");
|
||||||
|
@ -7,6 +7,7 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.scoreboard.DisplaySlot;
|
import org.bukkit.scoreboard.DisplaySlot;
|
||||||
import org.bukkit.scoreboard.Objective;
|
import org.bukkit.scoreboard.Objective;
|
||||||
import org.bukkit.scoreboard.Scoreboard;
|
import org.bukkit.scoreboard.Scoreboard;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
|
||||||
public final class ScoreB {
|
public final class ScoreB {
|
||||||
public Quake _plugin;
|
public Quake _plugin;
|
||||||
@ -30,12 +31,13 @@ public final class ScoreB {
|
|||||||
_board = Bukkit.getScoreboardManager().getNewScoreboard();
|
_board = Bukkit.getScoreboardManager().getNewScoreboard();
|
||||||
_objective = _board.registerNewObjective("Score", "dummy");
|
_objective = _board.registerNewObjective("Score", "dummy");
|
||||||
_objective.setDisplaySlot(DisplaySlot.SIDEBAR);
|
_objective.setDisplaySlot(DisplaySlot.SIDEBAR);
|
||||||
_objective.setDisplayName(_plugin._trad.get("ScoreBoard.name"));
|
_objective.setDisplayName(ChatColor.YELLOW + _plugin._trad.get("ScoreBoard.name"));
|
||||||
_objective.getScore(_plugin._trad.get("Shop.Coins.name")).setScore(_Money);
|
_objective.getScore(_plugin._trad.get("Shop.Coins.name")).setScore(_Money);
|
||||||
_objective.getScore(_plugin._trad.get("ScoreBoard.Kills.name")).setScore(_Kills);
|
_objective.getScore(_plugin._trad.get("ScoreBoard.Kills.name")).setScore(_Kills);
|
||||||
_objective.getScore(_plugin._trad.get("ScoreBoard.Deaths.name")).setScore(_Deaths);
|
_objective.getScore(_plugin._trad.get("ScoreBoard.Deaths.name")).setScore(_Deaths);
|
||||||
_objective.getScore(_plugin._trad.get("ScoreBoard.Shots.name")).setScore(_Shots);
|
_objective.getScore(_plugin._trad.get("ScoreBoard.Shots.name")).setScore(_Shots);
|
||||||
_objective.getScore(_plugin._trad.get("ScoreBoard.Wins.name")).setScore(_Wins);
|
_objective.getScore(_plugin._trad.get("ScoreBoard.Wins.name")).setScore(_Wins);
|
||||||
|
|
||||||
if (isScoreWorld(_player.getWorld().getName())) {
|
if (isScoreWorld(_player.getWorld().getName())) {
|
||||||
_player.setScoreboard(_board);
|
_player.setScoreboard(_board);
|
||||||
} else if (!isScoreWorld(_player.getWorld().getName())) {
|
} else if (!isScoreWorld(_player.getWorld().getName())) {
|
||||||
@ -57,6 +59,7 @@ public final class ScoreB {
|
|||||||
_objective.getScore(_plugin._trad.get("ScoreBoard.Deaths.name")).setScore(_Deaths);
|
_objective.getScore(_plugin._trad.get("ScoreBoard.Deaths.name")).setScore(_Deaths);
|
||||||
_objective.getScore(_plugin._trad.get("ScoreBoard.Shots.name")).setScore(_Shots);
|
_objective.getScore(_plugin._trad.get("ScoreBoard.Shots.name")).setScore(_Shots);
|
||||||
_objective.getScore(_plugin._trad.get("ScoreBoard.Wins.name")).setScore(_Wins);
|
_objective.getScore(_plugin._trad.get("ScoreBoard.Wins.name")).setScore(_Wins);
|
||||||
|
|
||||||
if (isScoreWorld(_player.getWorld().getName())) {
|
if (isScoreWorld(_player.getWorld().getName())) {
|
||||||
_player.setScoreboard(_board);
|
_player.setScoreboard(_board);
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user