SteamWar/BauSystem2.0
Archiviert
12
0

Update TraceCommand make TabComplete better for '/trace show'
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
yoyosource 2021-12-25 23:17:32 +01:00
Ursprung 8d63bea4a3
Commit 0d440994cb

Datei anzeigen

@ -35,19 +35,16 @@ import de.steamwar.bausystem.linkage.Linked;
import de.steamwar.bausystem.shared.ShowMode;
import de.steamwar.bausystem.utils.ListChatView;
import de.steamwar.command.SWCommand;
import de.steamwar.command.SWCommandUtils;
import de.steamwar.command.TypeMapper;
import lombok.AllArgsConstructor;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.ComponentBuilder;
import net.md_5.bungee.api.chat.HoverEvent;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.function.BiFunction;
@Linked(LinkageType.COMMAND)
@ -59,39 +56,45 @@ public class TraceCommand extends SWCommand {
@ClassMapper(value = ShowModeParameterType.class, local = true)
public TypeMapper<ShowModeParameterType> showModeParameterTypesTypeMapper() {
Map<ShowModeParameterType, List<String>> showModeParameterTypeListMap = new HashMap<>();
showModeParameterTypeListMap.put(ShowModeParameterType.WATER, Arrays.asList("-water"));
showModeParameterTypeListMap.put(ShowModeParameterType.INTERPOLATE_Y, Arrays.asList("-interpolatey", "-interpolate-y", "-interpolate_y", "-y"));
showModeParameterTypeListMap.put(ShowModeParameterType.INTERPOLATE_XZ, Arrays.asList("-interpolatex", "-interpolate-x", "-interpolate_x", "-x", "-interpolatez", "-interpolate-z", "-interpolate_z", "-z", "-interpolatexz", "-interpolate-xz", "-interpolate_xz", "-xz"));
showModeParameterTypeListMap.put(ShowModeParameterType.ADVANCED, Arrays.asList("-advanced", "-a"));
showModeParameterTypeListMap.put(ShowModeParameterType.EXPLODE, Arrays.asList("-explode", "-explodeonly"));
Map<String, ShowModeParameterType> showModeParameterTypesMap = new HashMap<>();
showModeParameterTypesMap.put("-water", ShowModeParameterType.WATER);
showModeParameterTypeListMap.forEach((k, v) -> v.forEach(s -> showModeParameterTypesMap.put(s, k)));
showModeParameterTypesMap.put("-interpolatey", ShowModeParameterType.INTERPOLATE_Y);
showModeParameterTypesMap.put("-interpolate-y", ShowModeParameterType.INTERPOLATE_Y);
showModeParameterTypesMap.put("-interpolate_y", ShowModeParameterType.INTERPOLATE_Y);
showModeParameterTypesMap.put("-y", ShowModeParameterType.INTERPOLATE_Y);
return new TypeMapper<ShowModeParameterType>() {
@Override
public ShowModeParameterType map(CommandSender commandSender, String[] previousArguments, String s) {
return showModeParameterTypesMap.get(s);
}
showModeParameterTypesMap.put("-interpolatex", ShowModeParameterType.INTERPOLATE_XZ);
showModeParameterTypesMap.put("-interpolate-x", ShowModeParameterType.INTERPOLATE_XZ);
showModeParameterTypesMap.put("-interpolate_x", ShowModeParameterType.INTERPOLATE_XZ);
showModeParameterTypesMap.put("-x", ShowModeParameterType.INTERPOLATE_XZ);
showModeParameterTypesMap.put("-interpolatez", ShowModeParameterType.INTERPOLATE_XZ);
showModeParameterTypesMap.put("-interpolate-z", ShowModeParameterType.INTERPOLATE_XZ);
showModeParameterTypesMap.put("-interpolate_z", ShowModeParameterType.INTERPOLATE_XZ);
showModeParameterTypesMap.put("-z", ShowModeParameterType.INTERPOLATE_XZ);
showModeParameterTypesMap.put("-interpolatexz", ShowModeParameterType.INTERPOLATE_XZ);
showModeParameterTypesMap.put("-interpolate-xz", ShowModeParameterType.INTERPOLATE_XZ);
showModeParameterTypesMap.put("-interpolate_xz", ShowModeParameterType.INTERPOLATE_XZ);
showModeParameterTypesMap.put("-xz", ShowModeParameterType.INTERPOLATE_XZ);
showModeParameterTypesMap.put("-advanced", ShowModeParameterType.ADVANCED);
showModeParameterTypesMap.put("-a", ShowModeParameterType.ADVANCED);
showModeParameterTypesMap.put("advanced", ShowModeParameterType.ADVANCED);
showModeParameterTypesMap.put("a", ShowModeParameterType.ADVANCED);
showModeParameterTypesMap.put("-explode", ShowModeParameterType.EXPLODE);
showModeParameterTypesMap.put("-explodeonly", ShowModeParameterType.EXPLODE);
List<String> tabCompletes = new ArrayList<>(showModeParameterTypesMap.keySet());
return SWCommandUtils.createMapper(s -> showModeParameterTypesMap.getOrDefault(s, null), s -> tabCompletes);
@Override
public List<String> tabCompletes(CommandSender commandSender, String[] strings, String s) {
Set<ShowModeParameterType> showModeParameterTypeSet = new HashSet<>();
for (String previousArgument : strings) {
showModeParameterTypeSet.add(showModeParameterTypesMap.get(previousArgument));
}
showModeParameterTypeSet.remove(null);
List<String> tabCompletes = new ArrayList<>();
for (ShowModeParameterType showModeParameterType : showModeParameterTypeListMap.keySet()) {
if ((showModeParameterTypeSet.contains(ShowModeParameterType.INTERPOLATE_XZ) || showModeParameterTypeSet.contains(ShowModeParameterType.INTERPOLATE_Y)) && showModeParameterType == ShowModeParameterType.ADVANCED) {
continue;
}
if (showModeParameterTypeSet.contains(ShowModeParameterType.ADVANCED) && (showModeParameterType == ShowModeParameterType.INTERPOLATE_XZ || showModeParameterType == ShowModeParameterType.INTERPOLATE_Y)) {
continue;
}
if (showModeParameterTypeSet.contains(showModeParameterType)) {
continue;
}
tabCompletes.addAll(showModeParameterTypeListMap.get(showModeParameterType));
}
return tabCompletes;
}
};
}
@Register(help = true)