SteamWar/BauSystem2.0
Archiviert
12
0

Update TraceCommand.showCommand by -ticks as option
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
yoyosource 2021-12-26 00:04:12 +01:00
Ursprung 8256c1fa7a
Commit 2c77e1a0d1
2 geänderte Dateien mit 47 neuen und 35 gelöschten Zeilen

Datei anzeigen

@ -56,13 +56,10 @@ 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"));
showModeParameterTypeListMap.put(ShowModeParameterType.TICKS, Arrays.asList("-ticks", "-t"));
Map<ShowModeParameterType, List<String>> showModeParameterTypeListMap = new EnumMap<>(ShowModeParameterType.class);
for (ShowModeParameterType value : ShowModeParameterType.values()) {
showModeParameterTypeListMap.put(value, value.getTabCompletes());
}
Map<String, ShowModeParameterType> showModeParameterTypesMap = new HashMap<>();
showModeParameterTypeListMap.forEach((k, v) -> v.forEach(s -> showModeParameterTypesMap.put(s, k)));
@ -76,11 +73,10 @@ public class TraceCommand extends SWCommand {
@Override
public List<String> tabCompletes(CommandSender commandSender, String[] strings, String s) {
Set<ShowModeParameterType> showModeParameterTypeSet = new HashSet<>();
boolean allowTicks = true;
for (String previousArgument : strings) {
try {
ShowModeType showModeType = ShowModeType.valueOf(previousArgument.toUpperCase());
allowTicks &= showModeType.allowTicks;
showModeParameterTypeSet.addAll(Arrays.asList(showModeType.removedTypes));
} catch (IllegalArgumentException ignored) {
// Ignored
}
@ -88,21 +84,15 @@ public class TraceCommand extends SWCommand {
}
showModeParameterTypeSet.remove(null);
List<String> tabCompletes = new ArrayList<>();
for (ShowModeParameterType showModeParameterType : showModeParameterTypeListMap.keySet()) {
if (showModeParameterType == ShowModeParameterType.TICKS && !allowTicks) {
for (Map.Entry<ShowModeParameterType, List<String>> entry : showModeParameterTypeListMap.entrySet()) {
if ((showModeParameterTypeSet.contains(ShowModeParameterType.INTERPOLATE_XZ) || showModeParameterTypeSet.contains(ShowModeParameterType.INTERPOLATE_Y)) && entry.getKey() == ShowModeParameterType.ADVANCED) {
continue;
}
if ((showModeParameterTypeSet.contains(ShowModeParameterType.INTERPOLATE_XZ) || showModeParameterTypeSet.contains(ShowModeParameterType.INTERPOLATE_Y)) && showModeParameterType == ShowModeParameterType.ADVANCED) {
if (showModeParameterTypeSet.contains(entry.getKey())) {
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));
tabCompletes.addAll(entry.getValue());
showModeParameterTypeSet.addAll(Arrays.asList(entry.getKey().getRemoved().get()));
}
return tabCompletes;
}
@ -324,13 +314,13 @@ public class TraceCommand extends SWCommand {
@AllArgsConstructor
private enum ShowModeType {
ENTITY(TraceEntityShowMode::new, true),
RAW(RawEntityShowMode::new, true),
PARTICLE(ParticleShowMode::new, false),
BLOCK(BlockShowMode::new, false);
ENTITY(TraceEntityShowMode::new, new ShowModeParameterType[]{}),
RAW(RawEntityShowMode::new, new ShowModeParameterType[]{}),
PARTICLE(ParticleShowMode::new, new ShowModeParameterType[]{ShowModeParameterType.TICKS}),
BLOCK(BlockShowMode::new, new ShowModeParameterType[]{ShowModeParameterType.TICKS});
private BiFunction<Player, ShowModeParameter, ShowMode<TNTPosition>> showModeBiFunction;
private boolean allowTicks;
private ShowModeParameterType[] removedTypes;
}
@Register({"show", "gui"})

Datei anzeigen

@ -19,27 +19,49 @@
package de.steamwar.bausystem.features.tracer.show;
import lombok.Getter;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Consumer;
import java.util.function.Supplier;
public enum ShowModeParameterType {
WATER(showModeParameter -> showModeParameter.setWater(true)),
INTERPOLATE_Y(showModeParameter -> showModeParameter.setInterpolate_Y(true)),
INTERPOLATE_XZ(showModeParameter -> showModeParameter.setInterpolate_XZ(true)),
WATER(showModeParameter -> showModeParameter.setWater(true), Arrays.asList("-water")),
INTERPOLATE_Y(showModeParameter -> showModeParameter.setInterpolate_Y(true), Arrays.asList("-interpolatey", "-interpolate-y", "-interpolate_y", "-y"), "ADVANCED"),
INTERPOLATE_XZ(showModeParameter -> showModeParameter.setInterpolate_XZ(true), Arrays.asList("-interpolatex", "-interpolate-x", "-interpolate_x", "-x", "-interpolatez", "-interpolate-z", "-interpolate_z", "-z", "-interpolatexz", "-interpolate-xz", "-interpolate_xz", "-xz"), "ADVANCED"),
ADVANCED(showModeParameter -> {
showModeParameter.setInterpolate_Y(true);
showModeParameter.setInterpolate_XZ(true);
}),
EXPLODE(showModeParameter -> showModeParameter.setExplodeOnly(true)),
TICKS(showModeParameter -> showModeParameter.setTicks(true));
}, Arrays.asList("-advanced", "-a"), "INTERPOLATE_Y", "INTERPOLATE_XZ"),
EXPLODE(showModeParameter -> showModeParameter.setExplodeOnly(true), Arrays.asList("-explode", "-explodeonly")),
TICKS(showModeParameter -> showModeParameter.setTicks(true), Arrays.asList("-ticks", "-t"));
@Getter
private final Consumer<ShowModeParameter> showModeParameterConsumer;
public Consumer<ShowModeParameter> getShowModeParameterConsumer() {
return showModeParameterConsumer;
}
@Getter
private List<String> tabCompletes;
ShowModeParameterType(Consumer<ShowModeParameter> showModeParameterConsumer) {
@Getter
private final Supplier<ShowModeParameterType[]> removed;
private AtomicReference<ShowModeParameterType[]> cached = new AtomicReference<>();
ShowModeParameterType(Consumer<ShowModeParameter> showModeParameterConsumer, List<String> tabCompletes, String... removed) {
this.showModeParameterConsumer = showModeParameterConsumer;
this.tabCompletes = tabCompletes;
this.removed = () -> {
if (cached.get() == null) {
ShowModeParameterType[] showModeParameterTypes = new ShowModeParameterType[removed.length];
for (int i = 0; i < removed.length; i++) {
showModeParameterTypes[i] = ShowModeParameterType.valueOf(removed[i]);
}
cached.set(showModeParameterTypes);
return showModeParameterTypes;
}
return cached.get();
};
}
}