Merge remote-tracking branch 'origin/master'
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Dieser Commit ist enthalten in:
Commit
94958de2da
@ -23,6 +23,7 @@ import de.steamwar.bausystem.BauSystem;
|
|||||||
import de.steamwar.bausystem.features.tpslimit.TPSUtils;
|
import de.steamwar.bausystem.features.tpslimit.TPSUtils;
|
||||||
import de.steamwar.bausystem.region.Region;
|
import de.steamwar.bausystem.region.Region;
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.entity.TNTPrimed;
|
import org.bukkit.entity.TNTPrimed;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
@ -32,6 +33,8 @@ import org.bukkit.event.entity.EntityExplodeEvent;
|
|||||||
import org.bukkit.event.entity.EntitySpawnEvent;
|
import org.bukkit.event.entity.EntitySpawnEvent;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
@Linked
|
@Linked
|
||||||
public class TraceRecorder implements Listener {
|
public class TraceRecorder implements Listener {
|
||||||
@ -158,14 +161,24 @@ public class TraceRecorder implements Listener {
|
|||||||
List<TNTPoint> history = historyMap.getOrDefault(tntPrimed, new ArrayList<>());
|
List<TNTPoint> history = historyMap.getOrDefault(tntPrimed, new ArrayList<>());
|
||||||
|
|
||||||
// Failsave for tnt entering unloaded chunks
|
// Failsave for tnt entering unloaded chunks
|
||||||
if (tntPrimed.isDead() || history.size() > 0 && history.get(history.size() - 1).getFuse() == tntPrimed.getFuseTicks()) {
|
if (tntPrimed == null || tntPrimed.isDead() || history.size() > 0 && history.get(history.size() - 1).getFuse() == tntPrimed.getFuseTicks()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
int tntID;
|
int tntID;
|
||||||
|
|
||||||
if (history.size() == 0) {
|
if (history.size() == 0) {
|
||||||
|
try {
|
||||||
historyMap.put(tntPrimed, history);
|
historyMap.put(tntPrimed, history);
|
||||||
|
}
|
||||||
|
catch (NullPointerException e) {
|
||||||
|
Logger logger = Bukkit.getLogger();
|
||||||
|
//TODO remove when no longer neccecary
|
||||||
|
logger.log(Level.WARNING, "Nullpointer thrown by historyMap");
|
||||||
|
logger.log(Level.WARNING, "TNT History: " + history);
|
||||||
|
logger.log(Level.WARNING, "History Map: " + historyMap);
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
tntID = wrappedTrace.getNextOpenRecordIdAndIncrement();
|
tntID = wrappedTrace.getNextOpenRecordIdAndIncrement();
|
||||||
} else {
|
} else {
|
||||||
tntID = history.get(0).getTntId();
|
tntID = history.get(0).getTntId();
|
||||||
|
@ -34,6 +34,9 @@ import java.util.stream.Stream;
|
|||||||
* A settable flag that changes how a trace is rendered
|
* A settable flag that changes how a trace is rendered
|
||||||
*/
|
*/
|
||||||
public abstract class ViewFlag {
|
public abstract class ViewFlag {
|
||||||
|
public static final Vector GRAVATY = new Vector(0.0, -0.04, 0.0);
|
||||||
|
public static final Vector DRAG_FACTOR = new Vector(0.98, 0.98, 0.98);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Static registry of static flags
|
* Static registry of static flags
|
||||||
*/
|
*/
|
||||||
@ -119,12 +122,11 @@ public abstract class ViewFlag {
|
|||||||
for (TraceEntity entity : entities) {
|
for (TraceEntity entity : entities) {
|
||||||
TNTPoint representative = entity.getRecords().get(0);
|
TNTPoint representative = entity.getRecords().get(0);
|
||||||
Optional<TNTPoint> prev = representative.getPrevious();
|
Optional<TNTPoint> prev = representative.getPrevious();
|
||||||
|
|
||||||
if (prev.isEmpty()) continue;
|
if (prev.isEmpty()) continue;
|
||||||
|
|
||||||
TNTPoint previous = prev.get();
|
TNTPoint previous = prev.get();
|
||||||
|
|
||||||
Location delta = representative.getLocation().clone().subtract(previous.getLocation());
|
Location delta = representative.getLocation().clone().subtract(previous.getLocation());
|
||||||
|
Vector previousVelocity = previous.isAfterFirstExplosion() ? previous.getVelocity() : delta.toVector().clone().divide(DRAG_FACTOR).subtract(GRAVATY);
|
||||||
|
|
||||||
Location yLocation = previous.getLocation().clone().add(0, delta.getY(), 0);
|
Location yLocation = previous.getLocation().clone().add(0, delta.getY(), 0);
|
||||||
if (yLocation.distanceSquared(representative.getLocation()) >= 1.0 / 256.0 && yLocation.distanceSquared(previous.getLocation()) >= 1.0 / 256.0) {
|
if (yLocation.distanceSquared(representative.getLocation()) >= 1.0 / 256.0 && yLocation.distanceSquared(previous.getLocation()) >= 1.0 / 256.0) {
|
||||||
@ -133,7 +135,7 @@ public abstract class ViewFlag {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Location secoundLocation;
|
Location secoundLocation;
|
||||||
if (delta.getX() >= delta.getZ()) {
|
if (previousVelocity.getX() >= previousVelocity.getZ()) {
|
||||||
secoundLocation = previous.getLocation().clone().add(delta.getX(), delta.getY(), 0);
|
secoundLocation = previous.getLocation().clone().add(delta.getX(), delta.getY(), 0);
|
||||||
} else {
|
} else {
|
||||||
secoundLocation = previous.getLocation().clone().add(0, delta.getY(), delta.getZ());
|
secoundLocation = previous.getLocation().clone().add(0, delta.getY(), delta.getZ());
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
* You should have received a copy of the GNU Affero General Public License
|
* 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/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
// Adding the base plugin fixes the following gradle warnings in IntelliJ:
|
// Adding the base plugin fixes the following gradle warnings in IntelliJ:
|
||||||
//
|
//
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren