2020-08-26 18:48:57 +02:00
|
|
|
/*
|
|
|
|
This file is a part of the SteamWar software.
|
|
|
|
|
|
|
|
Copyright (C) 2020 SteamWar.de-Serverteam
|
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU Affero General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU Affero General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Affero General Public License
|
|
|
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2020-07-18 23:01:50 +02:00
|
|
|
package de.steamwar.bausystem.commands;
|
|
|
|
|
2020-12-05 21:33:48 +01:00
|
|
|
import de.steamwar.bausystem.tracer.RecordManager;
|
|
|
|
import de.steamwar.bausystem.tracer.RecordStatus;
|
2020-07-18 23:01:50 +02:00
|
|
|
import org.bukkit.command.Command;
|
|
|
|
import org.bukkit.command.CommandSender;
|
|
|
|
import org.bukkit.command.TabCompleter;
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.Arrays;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
public class CommandTraceTabCompleter implements TabCompleter {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {
|
|
|
|
if(!(sender instanceof Player)) return new ArrayList<>();
|
2020-08-30 02:23:23 +02:00
|
|
|
return tracerTabComplete((Player) sender, args);
|
2020-07-18 23:01:50 +02:00
|
|
|
}
|
|
|
|
|
2020-08-30 02:23:23 +02:00
|
|
|
private List<String> tracerTabComplete(Player player, String[] args) {
|
2020-07-18 23:01:50 +02:00
|
|
|
List<String> tabComplete = new ArrayList<>();
|
2020-12-05 21:33:48 +01:00
|
|
|
if (RecordManager.getRecordStatus() == RecordStatus.IDLE || RecordManager.getRecordStatus() == RecordStatus.IDLE_AUTO) {
|
2020-07-18 23:01:50 +02:00
|
|
|
tabComplete.add("start");
|
|
|
|
} else {
|
|
|
|
tabComplete.add("stop");
|
|
|
|
}
|
|
|
|
tabComplete.add("toggleauto");
|
2020-08-30 02:23:23 +02:00
|
|
|
tabComplete.add("auto");
|
2020-07-19 07:31:04 +02:00
|
|
|
tabComplete.add("toggleshow");
|
2020-07-18 23:01:50 +02:00
|
|
|
tabComplete.add("show");
|
|
|
|
if (args[0].equalsIgnoreCase("show") && args.length == 2) {
|
|
|
|
return manageList(new ArrayList<>(Arrays.asList("block", "particle")), args, 1);
|
|
|
|
}
|
|
|
|
tabComplete.add("hide");
|
|
|
|
tabComplete.add("delete");
|
|
|
|
tabComplete.add("interpolate");
|
|
|
|
if (args[0].equalsIgnoreCase("interpolate") && args.length == 2) {
|
|
|
|
return manageList(new ArrayList<>(Arrays.asList("all", "yaxis", "none")), args, 1);
|
|
|
|
}
|
2020-08-30 02:23:23 +02:00
|
|
|
tabComplete.add("distance");
|
|
|
|
if (args[0].equalsIgnoreCase("distance") && args.length == 2) {
|
|
|
|
return manageList(new ArrayList<>(Arrays.asList("3", "4", "5", "6", "7", "8", "9", "10", "11", "default")), args, 1);
|
|
|
|
}
|
2020-07-18 23:01:50 +02:00
|
|
|
//tabComplete.add("gui");
|
2020-08-30 02:23:23 +02:00
|
|
|
//tabComplete.add("list");
|
2020-07-18 23:01:50 +02:00
|
|
|
|
2020-08-30 02:23:23 +02:00
|
|
|
if (args.length >= 2) {
|
2020-07-18 23:01:50 +02:00
|
|
|
return new ArrayList<>();
|
|
|
|
}
|
|
|
|
return manageList(tabComplete, args, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
private List<String> manageList(List<String> strings, String[] args, int index) {
|
|
|
|
for (int i = strings.size() - 1; i >= 0; i--) {
|
|
|
|
if (!strings.get(i).startsWith(args[index])) {
|
|
|
|
strings.remove(i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return strings;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|