SteamWar/BauSystem
Archiviert
13
0

RedstoneTester #202

Manuell gemergt
YoyoNow hat 29 Commits von RedstoneTester nach master 2021-04-01 18:21:40 +02:00 zusammengeführt
6 geänderte Dateien mit 27 neuen und 49 gelöschten Zeilen
Nur Änderungen aus Commit 61f82c0da7 werden angezeigt - Alle Commits anzeigen

Datei anzeigen

@ -23,6 +23,7 @@ import org.bukkit.Material;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import java.util.ArrayList;
import java.util.List; import java.util.List;
public class SWUtils { public class SWUtils {
@ -36,6 +37,7 @@ public class SWUtils {
} }
public static List<String> manageList(List<String> strings, String[] args, int index) { public static List<String> manageList(List<String> strings, String[] args, int index) {
strings = new ArrayList<>(strings);
for (int i = strings.size() - 1; i >= 0; i--) { for (int i = strings.size() - 1; i >= 0; i--) {
if (!strings.get(i).startsWith(args[index])) { if (!strings.get(i).startsWith(args[index])) {
strings.remove(i); strings.remove(i);
@ -48,5 +50,4 @@ public class SWUtils {
return manageList(strings, args, args.length - 1); return manageList(strings, args, args.length - 1);
} }
} }

Datei anzeigen

@ -26,26 +26,19 @@ import org.bukkit.command.TabCompleter;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.List; import java.util.List;
public class CommandDetonatorTabCompleter implements TabCompleter { public class CommandDetonatorTabCompleter implements TabCompleter {
private List<String> arguments = new ArrayList<>(Arrays.asList("wand", "reset", "detonate", "remove"));
@Override @Override
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) { public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {
if(!(sender instanceof Player)) return new ArrayList<>(); if(!(sender instanceof Player)) return new ArrayList<>();
return detonaterTabComplete((Player) sender, args); if (args.length != 1) {
}
private List<String> detonaterTabComplete(Player player, String[] args) {
List<String> tabComplete = new ArrayList<>();
tabComplete.add("wand");
tabComplete.add("reset");
tabComplete.add("detonate");
tabComplete.add("remove");
if (args.length >= 2) {
return new ArrayList<>(); return new ArrayList<>();
} }
return SWUtils.manageList(tabComplete, args, 0); return SWUtils.manageList(arguments, args);
} }
} }

Datei anzeigen

@ -27,26 +27,20 @@ import org.bukkit.command.TabCompleter;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.List; import java.util.List;
public class CommandSimulatorTabCompleter implements TabCompleter { public class CommandSimulatorTabCompleter implements TabCompleter {
private List<String> arguments = new ArrayList<>(Arrays.asList("wand", "start", "delete"));
@Override @Override
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) { public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {
if(!(sender instanceof Player)) return new ArrayList<>(); if(!(sender instanceof Player)) return new ArrayList<>();
return simulatorTabComplete((Player) sender, args); if (args.length != 1) {
}
private List<String> simulatorTabComplete(Player player, String[] args) {
List<String> tabComplete = new ArrayList<>();
tabComplete.add("wand");
tabComplete.add("start");
tabComplete.add("delete");
if (args.length >= 2) {
return new ArrayList<>(); return new ArrayList<>();
} }
return SWUtils.manageList(tabComplete, args, 0); return SWUtils.manageList(arguments, args);
} }
} }

Datei anzeigen

@ -29,31 +29,24 @@ import org.bukkit.command.TabCompleter;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.List; import java.util.List;
public class CommandTNTTabComplete implements TabCompleter { public class CommandTNTTabComplete implements TabCompleter {
private List<String> arguments = new ArrayList<>(Arrays.asList("an", "on", "aus", "off"));
public CommandTNTTabComplete() {
if (Region.buildAreaEnabled()) arguments.addAll(Arrays.asList("testblock", "tb"));
}
@Override @Override
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) { public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {
if(!(sender instanceof Player)) return new ArrayList<>(); if(!(sender instanceof Player)) return new ArrayList<>();
return tntTabComplete(args); if (args.length != 1) {
}
private List<String> tntTabComplete(String[] args) {
List<String> tabComplete = new ArrayList<>();
tabComplete.add("an");
tabComplete.add("on");
tabComplete.add("aus");
tabComplete.add("off");
if (Region.buildAreaEnabled()) {
tabComplete.add("testblock");
tabComplete.add("tb");
}
if (args.length >= 2) {
return new ArrayList<>(); return new ArrayList<>();
} }
return SWUtils.manageList(tabComplete, args, 0); return SWUtils.manageList(arguments, args);
} }
} }

Datei anzeigen

@ -19,10 +19,12 @@
package de.steamwar.bausystem.commands; package de.steamwar.bausystem.commands;
import de.steamwar.bausystem.SWUtils;
import de.steamwar.bausystem.world.TPSUtils; import de.steamwar.bausystem.world.TPSUtils;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter; import org.bukkit.command.TabCompleter;
import org.bukkit.entity.Player;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
@ -38,16 +40,11 @@ public class CommandTPSLimiterTabComplete implements TabCompleter {
@Override @Override
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) { public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {
if(!(sender instanceof Player)) return new ArrayList<>();
if (args.length != 1) { if (args.length != 1) {
return new ArrayList<>(); return new ArrayList<>();
} }
List<String> validArguments = new ArrayList<>(arguments.size()); return SWUtils.manageList(arguments, args);
for (String s : arguments) {
if (s.startsWith(args[0])) {
validArguments.add(s);
}
}
return validArguments;
} }
} }

Datei anzeigen

@ -50,8 +50,8 @@ public class CommandTraceTabCompleter implements TabCompleter {
return tracerTabComplete((Player) sender, args); return tracerTabComplete((Player) sender, args);
} }
private List<String> tracerTabComplete(Player player, String[] args) { private List<String> tracerTabComplete(Player player, java.lang.String[] args) {
List<String> tabComplete = new ArrayList<>(); List<java.lang.String> tabComplete = new ArrayList<>();
for (TabComplete tab : tabCompletes) { for (TabComplete tab : tabCompletes) {
if (tab.test(player, args)) tabComplete.addAll(Arrays.asList(tab.getTabCompletes())); if (tab.test(player, args)) tabComplete.addAll(Arrays.asList(tab.getTabCompletes()));
} }