Add Advanced
Add AdvancedNoWater Add RoundedTNTPosition
Dieser Commit ist enthalten in:
Ursprung
efb1535211
Commit
3f040e6130
@ -37,6 +37,9 @@ class TraceEntity_12 extends EntityFallingBlock implements AbstractTraceEntity {
|
|||||||
this.ticksLived = -12000;
|
this.ticksLived = -12000;
|
||||||
this.dropItem = false;
|
this.dropItem = false;
|
||||||
this.setCustomNameVisible(true);
|
this.setCustomNameVisible(true);
|
||||||
|
if (position.isExploded()) {
|
||||||
|
this.setCustomName("Exploded");
|
||||||
|
}
|
||||||
|
|
||||||
display(player);
|
display(player);
|
||||||
}
|
}
|
||||||
|
@ -38,6 +38,9 @@ class TraceEntity_15 extends EntityFallingBlock implements AbstractTraceEntity {
|
|||||||
this.ticksLived = -12000;
|
this.ticksLived = -12000;
|
||||||
this.dropItem = false;
|
this.dropItem = false;
|
||||||
this.setCustomNameVisible(true);
|
this.setCustomNameVisible(true);
|
||||||
|
if (position.isExploded()) {
|
||||||
|
this.setCustomName(new ChatComponentText("Exploded"));
|
||||||
|
}
|
||||||
|
|
||||||
display(player);
|
display(player);
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,65 @@
|
|||||||
|
/*
|
||||||
|
*
|
||||||
|
* 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;
|
||||||
|
|
||||||
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
public class RoundedTNTPosition {
|
||||||
|
|
||||||
|
private static final int factor = 10;
|
||||||
|
|
||||||
|
private int x;
|
||||||
|
private int y;
|
||||||
|
private int z;
|
||||||
|
|
||||||
|
public RoundedTNTPosition(TNTPosition tntPosition) {
|
||||||
|
this(tntPosition.getLocation().getX(), tntPosition.getLocation().getY(), tntPosition.getLocation().getZ());
|
||||||
|
}
|
||||||
|
|
||||||
|
public RoundedTNTPosition(Vector vector) {
|
||||||
|
this(vector.getX(), vector.getY(), vector.getZ());
|
||||||
|
}
|
||||||
|
|
||||||
|
public RoundedTNTPosition(double x, double y, double z) {
|
||||||
|
this.x = (int)(x * factor);
|
||||||
|
this.y = (int)(y * factor);
|
||||||
|
this.z = (int)(z * factor);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) return true;
|
||||||
|
if (!(o instanceof RoundedTNTPosition)) return false;
|
||||||
|
RoundedTNTPosition that = (RoundedTNTPosition) o;
|
||||||
|
return x == that.x &&
|
||||||
|
y == that.y &&
|
||||||
|
z == that.z;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -25,15 +25,33 @@ import org.bukkit.util.Vector;
|
|||||||
public class TNTPosition {
|
public class TNTPosition {
|
||||||
|
|
||||||
private Vector location;
|
private Vector location;
|
||||||
|
private TNTPosition previous;
|
||||||
|
private boolean exploded;
|
||||||
|
|
||||||
public TNTPosition(Entity entity) {
|
public TNTPosition(Entity entity, TNTPosition previous, boolean exploded) {
|
||||||
location = entity.getLocation().toVector();
|
location = entity.getLocation().toVector();
|
||||||
|
this.previous = previous;
|
||||||
|
this.exploded = exploded;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TNTPosition(Vector vector) {
|
||||||
|
location = vector;
|
||||||
|
this.previous = null;
|
||||||
|
this.exploded = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vector getLocation() {
|
public Vector getLocation() {
|
||||||
return location;
|
return location;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public TNTPosition getPrevious() {
|
||||||
|
return previous;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isExploded() {
|
||||||
|
return exploded;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "Position{" +
|
return "Position{" +
|
||||||
|
@ -51,7 +51,7 @@ public class CommandTraceTabCompleter implements TabCompleter {
|
|||||||
tabComplete.add("auto");
|
tabComplete.add("auto");
|
||||||
tabComplete.add("show");
|
tabComplete.add("show");
|
||||||
if (args[0].equalsIgnoreCase("show") && args.length == 2) {
|
if (args[0].equalsIgnoreCase("show") && args.length == 2) {
|
||||||
return manageList(new ArrayList<>(Arrays.asList("water", "nowater", "no_water", "removedwater", "removed_water", "basic", "default")), args, 1);
|
return manageList(new ArrayList<>(Arrays.asList("nowater", "basic", "default", "advanced")), args, 1);
|
||||||
}
|
}
|
||||||
tabComplete.add("hide");
|
tabComplete.add("hide");
|
||||||
tabComplete.add("delete");
|
tabComplete.add("delete");
|
||||||
|
@ -66,7 +66,12 @@ public class Record {
|
|||||||
|
|
||||||
/* The following methods should only be called by a recorder */
|
/* The following methods should only be called by a recorder */
|
||||||
public void add(TNTPrimed tntPrimed) {
|
public void add(TNTPrimed tntPrimed) {
|
||||||
TNTPosition position = new TNTPosition(tntPrimed);
|
TNTPosition position;
|
||||||
|
if (positions.isEmpty()) {
|
||||||
|
position = new TNTPosition(tntPrimed, null, exploded);
|
||||||
|
} else {
|
||||||
|
position = new TNTPosition(tntPrimed, positions.get(positions.size() - 1), exploded);
|
||||||
|
}
|
||||||
positions.add(position);
|
positions.add(position);
|
||||||
TraceShowManager.show(position);
|
TraceShowManager.show(position);
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,8 @@ package de.steamwar.bausystem.tracer.show;
|
|||||||
|
|
||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.bausystem.tracer.TNTPosition;
|
import de.steamwar.bausystem.tracer.TNTPosition;
|
||||||
|
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.Basic;
|
||||||
import de.steamwar.bausystem.tracer.show.mode.BasicNoWater;
|
import de.steamwar.bausystem.tracer.show.mode.BasicNoWater;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -26,13 +28,18 @@ public class TraceShowManager implements Listener {
|
|||||||
showMode = new Basic(player);
|
showMode = new Basic(player);
|
||||||
} else {
|
} else {
|
||||||
switch (args[1].toLowerCase()) {
|
switch (args[1].toLowerCase()) {
|
||||||
case "water":
|
|
||||||
case "nowater":
|
case "nowater":
|
||||||
case "no_water":
|
case "basic-nowater":
|
||||||
case "removedwater":
|
case "basicnowater":
|
||||||
case "removed_water":
|
|
||||||
showMode = new BasicNoWater(player);
|
showMode = new BasicNoWater(player);
|
||||||
break;
|
break;
|
||||||
|
case "advanced":
|
||||||
|
showMode = new Advanced(player);
|
||||||
|
break;
|
||||||
|
case "advanced-nowater":
|
||||||
|
case "advancednowater":
|
||||||
|
showMode = new AdvancedNoWater(player);
|
||||||
|
break;
|
||||||
case "basic":
|
case "basic":
|
||||||
case "default":
|
case "default":
|
||||||
default:
|
default:
|
||||||
|
@ -21,5 +21,101 @@
|
|||||||
|
|
||||||
package de.steamwar.bausystem.tracer.show.mode;
|
package de.steamwar.bausystem.tracer.show.mode;
|
||||||
|
|
||||||
public class Advanced {
|
import de.steamwar.bausystem.tracer.*;
|
||||||
|
import de.steamwar.bausystem.tracer.show.ShowMode;
|
||||||
|
import de.steamwar.core.Core;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class Advanced implements ShowMode {
|
||||||
|
|
||||||
|
private final Player player;
|
||||||
|
|
||||||
|
private Map<RoundedTNTPosition, AbstractTraceEntity> tntEntityMap = new HashMap<>();
|
||||||
|
private Map<RoundedTNTPosition, AbstractTraceEntity> updateEntityMap = new HashMap<>();
|
||||||
|
|
||||||
|
public Advanced(Player player) {
|
||||||
|
this.player = player;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void show(TNTPosition position) {
|
||||||
|
RoundedTNTPosition roundedTNTPosition = new RoundedTNTPosition(position);
|
||||||
|
if (tntEntityMap.containsKey(roundedTNTPosition)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (Core.getVersion()) {
|
||||||
|
case 12:
|
||||||
|
tntEntityMap.put(roundedTNTPosition, TNTTracer_12.createTNT(player.getWorld(), position, player));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
tntEntityMap.put(roundedTNTPosition, TNTTracer_15.createTNT(player.getWorld(), position, player));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (position.getPrevious() == null) return;
|
||||||
|
|
||||||
|
Vector vector = position.getLocation().clone().subtract(position.getPrevious().getLocation());
|
||||||
|
Vector updatePointY = position.getPrevious().getLocation().clone().setY(position.getLocation().getY());
|
||||||
|
Vector updatePointXZ;
|
||||||
|
if (Math.abs(vector.getX()) > Math.abs(vector.getZ())) {
|
||||||
|
updatePointXZ = updatePointY.clone().setX(position.getLocation().getX());
|
||||||
|
} else {
|
||||||
|
updatePointXZ = updatePointY.clone().setZ(position.getLocation().getZ());
|
||||||
|
}
|
||||||
|
|
||||||
|
System.out.println(updatePointY);
|
||||||
|
System.out.println(updatePointXZ);
|
||||||
|
|
||||||
|
if (!position.getLocation().equals(updatePointY)) {
|
||||||
|
RoundedTNTPosition updatePointPosition = new RoundedTNTPosition(updatePointY);
|
||||||
|
if (updateEntityMap.containsKey(updatePointPosition)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (Core.getVersion()) {
|
||||||
|
case 12:
|
||||||
|
updateEntityMap.put(updatePointPosition, TNTTracer_12.createUpdatePoint(player.getWorld(), new TNTPosition(updatePointY), player));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
updateEntityMap.put(updatePointPosition, TNTTracer_15.createUpdatePoint(player.getWorld(), new TNTPosition(updatePointY), player));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!position.getLocation().equals(updatePointXZ)) {
|
||||||
|
RoundedTNTPosition updatePointPosition = new RoundedTNTPosition(updatePointXZ);
|
||||||
|
if (updateEntityMap.containsKey(updatePointPosition)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (Core.getVersion()) {
|
||||||
|
case 12:
|
||||||
|
updateEntityMap.put(updatePointPosition, TNTTracer_12.createUpdatePoint(player.getWorld(), new TNTPosition(updatePointXZ), player));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
updateEntityMap.put(updatePointPosition, TNTTracer_15.createUpdatePoint(player.getWorld(), new TNTPosition(updatePointXZ), player));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void hide() {
|
||||||
|
tntEntityMap.forEach((roundedTNTPosition, abstractTraceEntity) -> {
|
||||||
|
abstractTraceEntity.hide(player);
|
||||||
|
abstractTraceEntity.remove();
|
||||||
|
});
|
||||||
|
tntEntityMap.clear();
|
||||||
|
|
||||||
|
updateEntityMap.forEach((roundedTNTPosition, abstractTraceEntity) -> {
|
||||||
|
abstractTraceEntity.hide(player);
|
||||||
|
abstractTraceEntity.remove();
|
||||||
|
});
|
||||||
|
updateEntityMap.clear();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,56 @@
|
|||||||
|
/*
|
||||||
|
*
|
||||||
|
* 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.Core;
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void show(TNTPosition position) {
|
||||||
|
boolean b;
|
||||||
|
switch (Core.getVersion()) {
|
||||||
|
case 12:
|
||||||
|
b = TNTTracer_12.inWater(world, position);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
b = TNTTracer_15.inWater(world, position);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (!b) {
|
||||||
|
super.show(position);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -5,7 +5,8 @@ import de.steamwar.bausystem.tracer.show.ShowMode;
|
|||||||
import de.steamwar.core.Core;
|
import de.steamwar.core.Core;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
public class Basic implements ShowMode {
|
public class Basic implements ShowMode {
|
||||||
|
|
||||||
@ -36,46 +37,11 @@ public class Basic implements ShowMode {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void hide() {
|
public void hide() {
|
||||||
tntEntityMap.forEach((roundedTNTPosition, abstractTNTEntity) -> {
|
tntEntityMap.forEach((roundedTNTPosition, abstractTraceEntity) -> {
|
||||||
abstractTNTEntity.hide(player);
|
abstractTraceEntity.hide(player);
|
||||||
abstractTNTEntity.remove();
|
abstractTraceEntity.remove();
|
||||||
});
|
});
|
||||||
tntEntityMap.clear();
|
tntEntityMap.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class RoundedTNTPosition {
|
|
||||||
|
|
||||||
private static final int factor = 10;
|
|
||||||
|
|
||||||
private int x;
|
|
||||||
private int y;
|
|
||||||
private int z;
|
|
||||||
|
|
||||||
private RoundedTNTPosition(TNTPosition tntPosition) {
|
|
||||||
this(tntPosition.getLocation().getX(), tntPosition.getLocation().getY(), tntPosition.getLocation().getZ());
|
|
||||||
}
|
|
||||||
|
|
||||||
private RoundedTNTPosition(double x, double y, double z) {
|
|
||||||
this.x = (int)(x * factor);
|
|
||||||
this.y = (int)(y * factor);
|
|
||||||
this.z = (int)(z * factor);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object o) {
|
|
||||||
if (this == o) return true;
|
|
||||||
if (!(o instanceof RoundedTNTPosition)) return false;
|
|
||||||
RoundedTNTPosition that = (RoundedTNTPosition) o;
|
|
||||||
return x == that.x &&
|
|
||||||
y == that.y &&
|
|
||||||
z == that.z;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return Objects.hash(x, y, z);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -53,9 +53,4 @@ public class BasicNoWater extends Basic {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void hide() {
|
|
||||||
super.hide();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren