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-25 23:29:41 +01:00
Ursprung 0d440994cb
Commit 8256c1fa7a
6 geänderte Dateien mit 29 neuen und 11 gelöschten Zeilen

Datei anzeigen

@ -40,7 +40,11 @@ class TraceEntity_15 extends BaseEntity_15 implements AbstractTraceEntity {
}
@Override
public void display(Player player, boolean exploded) {
public void display(Player player, boolean exploded, int ticks) {
if (ticks != -1) {
this.setCustomNameVisible(true);
this.setCustomName(new ChatComponentText(ticks + ""));
}
if (!this.exploded && exploded) {
this.setCustomNameVisible(true);
this.setCustomName(new ChatComponentText("Bumm"));

Datei anzeigen

@ -24,7 +24,7 @@ import org.bukkit.entity.Player;
public interface AbstractTraceEntity extends AbstractEntity {
void display(Player player, boolean exploded);
void display(Player player, boolean exploded, int ticks);
boolean hide(Player player, boolean always);
}

Datei anzeigen

@ -62,6 +62,7 @@ public class TraceCommand extends SWCommand {
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<String, ShowModeParameterType> showModeParameterTypesMap = new HashMap<>();
showModeParameterTypeListMap.forEach((k, v) -> v.forEach(s -> showModeParameterTypesMap.put(s, k)));
@ -75,12 +76,23 @@ 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;
} catch (IllegalArgumentException ignored) {
// Ignored
}
showModeParameterTypeSet.add(showModeParameterTypesMap.get(previousArgument));
}
showModeParameterTypeSet.remove(null);
List<String> tabCompletes = new ArrayList<>();
for (ShowModeParameterType showModeParameterType : showModeParameterTypeListMap.keySet()) {
if (showModeParameterType == ShowModeParameterType.TICKS && !allowTicks) {
continue;
}
if ((showModeParameterTypeSet.contains(ShowModeParameterType.INTERPOLATE_XZ) || showModeParameterTypeSet.contains(ShowModeParameterType.INTERPOLATE_Y)) && showModeParameterType == ShowModeParameterType.ADVANCED) {
continue;
}
@ -312,12 +324,13 @@ public class TraceCommand extends SWCommand {
@AllArgsConstructor
private enum ShowModeType {
ENTITY(TraceEntityShowMode::new),
RAW(RawEntityShowMode::new),
PARTICLE(ParticleShowMode::new),
BLOCK(BlockShowMode::new);
ENTITY(TraceEntityShowMode::new, true),
RAW(RawEntityShowMode::new, true),
PARTICLE(ParticleShowMode::new, false),
BLOCK(BlockShowMode::new, false);
private BiFunction<Player, ShowModeParameter, ShowMode<TNTPosition>> showModeBiFunction;
private boolean allowTicks;
}
@Register({"show", "gui"})

Datei anzeigen

@ -31,4 +31,5 @@ public class ShowModeParameter {
private boolean interpolate_Y = false;
private boolean interpolate_XZ = false;
private boolean explodeOnly = false;
private boolean ticks = false;
}

Datei anzeigen

@ -30,7 +30,8 @@ public enum ShowModeParameterType {
showModeParameter.setInterpolate_Y(true);
showModeParameter.setInterpolate_XZ(true);
}),
EXPLODE(showModeParameter -> showModeParameter.setExplodeOnly(true));
EXPLODE(showModeParameter -> showModeParameter.setExplodeOnly(true)),
TICKS(showModeParameter -> showModeParameter.setTicks(true));
private final Consumer<ShowModeParameter> showModeParameterConsumer;
@ -41,5 +42,4 @@ public enum ShowModeParameterType {
ShowModeParameterType(Consumer<ShowModeParameter> showModeParameterConsumer) {
this.showModeParameterConsumer = showModeParameterConsumer;
}
}

Datei anzeigen

@ -57,7 +57,7 @@ public abstract class FactoredEntityShowMode implements ShowMode<TNTPosition> {
}
RoundedPosition roundedPosition = new RoundedPosition(position, factor);
AbstractTraceEntity entity = tntEntityMap.computeIfAbsent(roundedPosition, pos -> createEntity(player, position.getLocation(), true));
entity.display(player, position.isExploded());
entity.display(player, position.isExploded(), showModeParameter.isTicks() ? position.getFuseTicks() : 0);
return;
}
if (!showModeParameter.isWater() && position.isExploded() && checkWater(position.getLocation())) {
@ -81,12 +81,12 @@ public abstract class FactoredEntityShowMode implements ShowMode<TNTPosition> {
RoundedPosition roundedPosition = new RoundedPosition(position, factor);
AbstractTraceEntity entity = tntEntityMap.computeIfAbsent(roundedPosition, pos -> createEntity(player, position.getLocation(), true));
entity.display(player, position.isExploded());
entity.display(player, position.isExploded(), showModeParameter.isTicks() ? position.getFuseTicks() : 0);
applyOnPosition(position, updatePointPosition -> {
updateEntityMap.computeIfAbsent(new RoundedPosition(updatePointPosition, factor), pos -> {
return createEntity(player, updatePointPosition, false);
}).display(player, false);
}).display(player, false, showModeParameter.isTicks() ? position.getFuseTicks() : 0);
});
}