Tracer-entity #147
@ -40,9 +40,8 @@ class TraceEntity_12 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("Bumm");
|
this.setCustomName("Bumm");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -47,9 +47,7 @@ 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();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void stopRecording() {
|
void stopRecording() {
|
||||||
|
@ -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),
|
||||||
|
@ -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),
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren