SteamWar/BauSystem
Archiviert
13
0

Tracer-entity #147

Manuell gemergt
YoyoNow hat 47 Commits von Tracer-entity nach master 2020-12-27 22:16:04 +01:00 zusammengeführt
6 geänderte Dateien mit 40 neuen und 31 gelöschten Zeilen
Nur Änderungen aus Commit df00896c93 werden angezeigt - Alle Commits anzeigen

Datei anzeigen

@ -40,9 +40,8 @@ class TraceEntity_12 extends EntityFallingBlock implements AbstractTraceEntity {
this.setNoGravity(true); this.setNoGravity(true);
Veraltet
Review

Items sollten sowieso nicht droppen (gamerule)

Items sollten sowieso nicht droppen (gamerule)
Veraltet
Review

Auch das hier behoben

Auch das hier behoben
this.ticksLived = -12000; this.ticksLived = -12000;
Veraltet
Review

Kann man glaube ich mit in das if ziehen.

Kann man glaube ich mit in das if ziehen.
Veraltet
Review

Ich wollte noch vllt als Namen den int tick anzeigen was hältst du davon?

Ich wollte noch vllt als Namen den int tick anzeigen was hältst du davon?
this.dropItem = false;
this.setCustomNameVisible(true);
if (exploded) { if (exploded) {
this.setCustomNameVisible(true);
this.setCustomName("Bumm"); this.setCustomName("Bumm");
} }

Datei anzeigen

@ -39,9 +39,8 @@ class TraceEntity_15 extends EntityFallingBlock implements AbstractTraceEntity {
this.setNoGravity(true); this.setNoGravity(true);
this.ticksLived = -12000; this.ticksLived = -12000;
this.dropItem = false;
this.setCustomNameVisible(true);
if (exploded) { if (exploded) {
this.setCustomNameVisible(true);
this.setCustomName(new ChatComponentText("Bumm")); this.setCustomName(new ChatComponentText("Bumm"));
} }

Datei anzeigen

@ -29,9 +29,19 @@ import org.bukkit.entity.Player;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.function.BiPredicate;
public class CommandTraceTabCompleter implements TabCompleter { public class CommandTraceTabCompleter implements TabCompleter {
private static List<TabComplete> tabCompletes = new ArrayList<>();
static {
tabCompletes.add(new TabComplete((player, args) -> args.length == 1 && (RecordStateMachine.getRecordStatus() == RecordStatus.IDLE || RecordStateMachine.getRecordStatus() == RecordStatus.IDLE_AUTO), "start"));
tabCompletes.add(new TabComplete((player, args) -> args.length == 1 && (RecordStateMachine.getRecordStatus() != RecordStatus.IDLE && RecordStateMachine.getRecordStatus() != RecordStatus.IDLE_AUTO), "stop"));
tabCompletes.add(new TabComplete((player, args) -> args.length == 1, "toggleauto", "auto", "show", "hide", "delete", "clear"));
tabCompletes.add(new TabComplete((player, args) -> args.length == 2 && args[0].equalsIgnoreCase("show"), "nowater", "basic", "advanced", "advanced-nowater"));
}
@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<>();
@ -40,36 +50,37 @@ public class CommandTraceTabCompleter implements TabCompleter {
private List<String> tracerTabComplete(Player player, String[] args) { private List<String> tracerTabComplete(Player player, String[] args) {
List<String> tabComplete = new ArrayList<>(); List<String> tabComplete = new ArrayList<>();
if (RecordStateMachine.getRecordStatus() == RecordStatus.IDLE || RecordStateMachine.getRecordStatus() == RecordStatus.IDLE_AUTO) { for (TabComplete tab : tabCompletes) {
tabComplete.add("start"); if (tab.test(player, args)) tabComplete.addAll(Arrays.asList(tab.getTabCompletes()));
} else {
tabComplete.add("stop");
} }
tabComplete.add("toggleauto"); return manageList(tabComplete, args);
tabComplete.add("auto");
tabComplete.add("show");
if (args[0].equalsIgnoreCase("show") && args.length == 2) {
return manageList(new ArrayList<>(Arrays.asList("nowater", "basic", "advanced", "advanced-nowater")), args, 1);
}
tabComplete.add("hide");
tabComplete.add("delete");
tabComplete.add("clear");
//tabComplete.add("gui");
//tabComplete.add("list");
if (args.length >= 2) {
return new ArrayList<>();
}
return manageList(tabComplete, args, 0);
} }
private List<String> manageList(List<String> strings, String[] args, int index) { private List<String> manageList(List<String> strings, String[] args) {
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[args.length - 1])) strings.remove(i);
strings.remove(i);
}
} }
return strings; return strings;
} }
private static class TabComplete {
private BiPredicate<Player, String[]> function;
private String[] tabCompletes;
private TabComplete(BiPredicate<Player, String[]> function, String... tabCompletes) {
this.function = function;
this.tabCompletes = tabCompletes;
}
public boolean test(Player player, String[] args) {
return function.test(player, args);
}
public String[] getTabCompletes() {
return tabCompletes;
}
}
} }

Datei anzeigen

@ -47,10 +47,8 @@ public class Recorder implements Listener {
record = new Record(); record = new Record();
// To trace TNT initial positions with AutoTracer // To trace TNT initial positions with AutoTracer
if (RecordStateMachine.getRecordStatus() == RecordStatus.IDLE_AUTO) {
run(); run();
Veraltet
Review

Würde ich unabhängig vom derzeitgen RecordStatus machen. Wenn du einen Recorder erzeugst, möchtest du ja aufnehmen.

Würde ich unabhängig vom derzeitgen RecordStatus machen. Wenn du einen Recorder erzeugst, möchtest du ja aufnehmen.
} }
}
void stopRecording() { void stopRecording() {
HandlerList.unregisterAll(this); HandlerList.unregisterAll(this);

Datei anzeigen

@ -37,6 +37,7 @@ public class AdvancedNoWater extends Advanced {
super(player); super(player);
} }
@SuppressWarnings({"java:S5411"})
@Override @Override
public void show(TNTPosition position) { public void show(TNTPosition position) {
if (VersionedCallable.call(new VersionedCallable<>(() -> TNTTracer_12.inWater(world, position.getLocation()), 8), if (VersionedCallable.call(new VersionedCallable<>(() -> TNTTracer_12.inWater(world, position.getLocation()), 8),

Datei anzeigen

@ -37,6 +37,7 @@ public class BasicNoWater extends Basic {
super(player); super(player);
} }
@SuppressWarnings({"java:S5411"})
@Override @Override
public void show(TNTPosition position) { public void show(TNTPosition position) {
if (VersionedCallable.call(new VersionedCallable<>(() -> TNTTracer_12.inWater(world, position.getLocation()), 8), if (VersionedCallable.call(new VersionedCallable<>(() -> TNTTracer_12.inWater(world, position.getLocation()), 8),