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
8 geänderte Dateien mit 137 neuen und 126 gelöschten Zeilen
Nur Änderungen aus Commit a19e0436fb werden angezeigt - Alle Commits anzeigen

Datei anzeigen

@ -22,12 +22,11 @@ package de.steamwar.bausystem.commands;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.Permission;
import de.steamwar.bausystem.tracer.record.RecordStateMachine;
import de.steamwar.bausystem.tracer.show.ShowModeParameter;
import de.steamwar.bausystem.tracer.show.StoredRecords;
import de.steamwar.bausystem.tracer.show.TraceShowManager;
import de.steamwar.bausystem.tracer.show.mode.Advanced;
import de.steamwar.bausystem.tracer.show.mode.AdvancedNoWater;
import de.steamwar.bausystem.tracer.show.mode.Basic;
import de.steamwar.bausystem.tracer.show.mode.BasicNoWater;
import de.steamwar.bausystem.world.Welt;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
@ -89,25 +88,17 @@ public class CommandTrace implements CommandExecutor {
break;
case "show":
if (args.length < 2) {
TraceShowManager.show(player, new Basic(player));
TraceShowManager.show(player, new Basic(player, new ShowModeParameter()));
} else {
ShowModeParameter showModeParameter = ShowModeParameter.parseArguments(args, 2);
switch (args[1].toLowerCase()) {
case "nowater":
case "basic-nowater":
case "basicnowater":
TraceShowManager.show(player, new BasicNoWater(player));
break;
case "advanced":
TraceShowManager.show(player, new Advanced(player));
break;
case "advanced-nowater":
case "advancednowater":
TraceShowManager.show(player, new AdvancedNoWater(player));
TraceShowManager.show(player, new Advanced(player, showModeParameter));
break;
case "basic":
case "default":
default:
TraceShowManager.show(player, new Basic(player));
TraceShowManager.show(player, new Basic(player, showModeParameter));
break;
}
}

Datei anzeigen

@ -39,7 +39,9 @@ public class CommandTraceTabCompleter implements TabCompleter {
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"));
tabCompletes.add(new TabComplete((player, args) -> args.length == 2 && args[0].equalsIgnoreCase("show"), "basic", "advanced"));
tabCompletes.add(new TabComplete((player, args) -> args.length > 2 && args[0].equalsIgnoreCase("show") && (args[1].equalsIgnoreCase("basic") || args[1].equalsIgnoreCase("advanced")), "-water"));
tabCompletes.add(new TabComplete((player, args) -> args.length > 2 && args[0].equalsIgnoreCase("show") && args[1].equalsIgnoreCase("advanced"), "-interpolate-xz", "-interpolate-y"));
}
@Override

Datei anzeigen

@ -1,3 +1,22 @@
/*
This file is a part of the SteamWar software.
Copyright (C) 2020 SteamWar.de-Serverteam
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.tracer.show;
import de.steamwar.bausystem.tracer.TNTPosition;

Datei anzeigen

@ -0,0 +1,89 @@
/*
*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2020 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
* /
*/
package de.steamwar.bausystem.tracer.show;
public class ShowModeParameter {
private boolean water = false;
private boolean interpolate_SET = false;
private boolean interpolate_Y = true;
private boolean interpolate_XZ = true;
public ShowModeParameter() {
}
public boolean isWater() {
return water;
}
public boolean isInterpolate_Y() {
return interpolate_Y;
}
public boolean isInterpolate_XZ() {
return interpolate_XZ;
}
public static ShowModeParameter parseArguments(String[] args, int index) {
ShowModeParameter showModeParameter = new ShowModeParameter();
for (int i = index; i < args.length; i++) {
switch (args[i].toLowerCase()) {
case "-water":
showModeParameter.water = true;
break;
case "-interpolatey":
case "-interpolate-y":
case "-interpolate_y":
case "-y":
if (showModeParameter.interpolate_SET) {
showModeParameter.interpolate_Y = true;
} else {
showModeParameter.interpolate_XZ = false;
showModeParameter.interpolate_SET = true;
}
break;
case "-interpolatex":
case "-interpolate-x":
case "-interpolate_x":
case "-x":
case "-interpolatez":
case "-interpolate-z":
case "-interpolate_z":
case "-z":
case "-interpolatexz":
case "-interpolate-xz":
case "-interpolate_xz":
case "-xz":
if (showModeParameter.interpolate_SET) {
showModeParameter.interpolate_XZ = true;
} else {
showModeParameter.interpolate_Y = false;
showModeParameter.interpolate_SET = true;
}
break;
}
}
return showModeParameter;
}
}

Datei anzeigen

@ -24,6 +24,7 @@ package de.steamwar.bausystem.tracer.show.mode;
import de.steamwar.bausystem.tracer.AbstractTraceEntity;
import de.steamwar.bausystem.tracer.RoundedTNTPosition;
import de.steamwar.bausystem.tracer.TNTPosition;
import de.steamwar.bausystem.tracer.show.ShowModeParameter;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
@ -34,8 +35,8 @@ public class Advanced extends Basic {
private Map<RoundedTNTPosition, AbstractTraceEntity> updateEntityMap = new HashMap<>();
public Advanced(Player player) {
super(player);
public Advanced(Player player, ShowModeParameter showModeParameter) {
super(player, showModeParameter);
}
@Override
@ -53,21 +54,19 @@ public class Advanced extends Basic {
updatePointXZ = updatePointY.clone().setZ(position.getLocation().getZ());
}
if (!position.getLocation().equals(updatePointY)) {
if (showModeParameter.isInterpolate_Y() && !position.getLocation().equals(updatePointY)) {
RoundedTNTPosition updatePointPosition = new RoundedTNTPosition(updatePointY);
if (updateEntityMap.containsKey(updatePointPosition)) {
return;
}
if (!updateEntityMap.containsKey(updatePointPosition)) {
updateEntityMap.put(updatePointPosition, createEntity(updatePointY, false, false));
}
if (!position.getLocation().equals(updatePointXZ)) {
RoundedTNTPosition updatePointPosition = new RoundedTNTPosition(updatePointXZ);
if (updateEntityMap.containsKey(updatePointPosition)) {
return;
}
if (showModeParameter.isInterpolate_XZ() && !position.getLocation().equals(updatePointXZ)) {
RoundedTNTPosition updatePointPosition = new RoundedTNTPosition(updatePointXZ);
if (!updateEntityMap.containsKey(updatePointPosition)) {
updateEntityMap.put(updatePointPosition, createEntity(updatePointXZ, false, false));
}
}
}
@Override
public void hide() {

Datei anzeigen

@ -1,50 +0,0 @@
/*
*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2020 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
* /
*/
package de.steamwar.bausystem.tracer.show.mode;
import de.steamwar.bausystem.tracer.TNTPosition;
import de.steamwar.bausystem.tracer.TNTTracer_12;
import de.steamwar.bausystem.tracer.TNTTracer_15;
import de.steamwar.core.VersionedCallable;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.entity.Player;
public class AdvancedNoWater extends Advanced {
private static final World world = Bukkit.getWorlds().get(0);
public AdvancedNoWater(Player player) {
super(player);
}
@SuppressWarnings({"java:S5411"})
@Override
public void show(TNTPosition position) {
if (VersionedCallable.call(new VersionedCallable<>(() -> TNTTracer_12.inWater(world, position.getLocation()), 8),
new VersionedCallable<>(() -> TNTTracer_15.inWater(world, position.getLocation()), 14))) {
return;
}
super.show(position);
}
}

Datei anzeigen

@ -2,6 +2,7 @@ package de.steamwar.bausystem.tracer.show.mode;
import de.steamwar.bausystem.tracer.*;
import de.steamwar.bausystem.tracer.show.ShowMode;
import de.steamwar.bausystem.tracer.show.ShowModeParameter;
import de.steamwar.core.VersionedCallable;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
@ -12,15 +13,20 @@ import java.util.Map;
public class Basic implements ShowMode {
protected final Player player;
protected final ShowModeParameter showModeParameter;
private Map<RoundedTNTPosition, AbstractTraceEntity> tntEntityMap = new HashMap<>();
public Basic(Player player) {
public Basic(Player player, ShowModeParameter showModeParameter) {
this.player = player;
this.showModeParameter = showModeParameter;
}
@Override
public void show(TNTPosition position) {
if (showModeParameter.isWater() && checkWater(position.getLocation())) {
return;
}
RoundedTNTPosition roundedTNTPosition = new RoundedTNTPosition(position);
if (tntEntityMap.containsKey(roundedTNTPosition)) {
return;
@ -28,6 +34,11 @@ public class Basic implements ShowMode {
tntEntityMap.put(roundedTNTPosition, createEntity(position.getLocation(), position.isExploded(), true));
}
protected boolean checkWater(Vector position) {
return (VersionedCallable.call(new VersionedCallable<>(() -> TNTTracer_12.inWater(player.getWorld(), position), 8),
new VersionedCallable<>(() -> TNTTracer_15.inWater(player.getWorld(), position), 14)));
}
protected AbstractTraceEntity createEntity(Vector position, boolean exploded, boolean tnt) {
return VersionedCallable.call(new VersionedCallable<>(() -> TNTTracer_12.create(player.getWorld(), position, player, exploded, tnt), 8),
new VersionedCallable<>(() -> TNTTracer_15.create(player.getWorld(), position, player, exploded, tnt), 14));

Datei anzeigen

@ -1,50 +0,0 @@
/*
*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2020 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
* /
*/
package de.steamwar.bausystem.tracer.show.mode;
import de.steamwar.bausystem.tracer.TNTPosition;
import de.steamwar.bausystem.tracer.TNTTracer_12;
import de.steamwar.bausystem.tracer.TNTTracer_15;
import de.steamwar.core.VersionedCallable;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.entity.Player;
public class BasicNoWater extends Basic {
private static final World world = Bukkit.getWorlds().get(0);
public BasicNoWater(Player player) {
super(player);
}
@SuppressWarnings({"java:S5411"})
@Override
public void show(TNTPosition position) {
if (VersionedCallable.call(new VersionedCallable<>(() -> TNTTracer_12.inWater(world, position.getLocation()), 8),
new VersionedCallable<>(() -> TNTTracer_15.inWater(world, position.getLocation()), 14))) {
return;
}
super.show(position);
}
}