SteamWar/BauSystem2.0
Archiviert
12
0

Add Depth.tntCount

Dieser Commit ist enthalten in:
yoyosource 2021-05-02 13:52:59 +02:00
Ursprung 5bb18c8153
Commit 11dac9ae42
2 geänderte Dateien mit 11 neuen und 8 gelöschten Zeilen

Datei anzeigen

@ -33,6 +33,7 @@ import java.util.Set;
public class Depth { public class Depth {
private int tntCount = 1;
private Vector minVector = null; private Vector minVector = null;
private Vector maxVector = null; private Vector maxVector = null;
@ -53,7 +54,7 @@ public class Depth {
}); });
bukkitTask = Bukkit.getScheduler().runTaskTimer(BauSystem.getInstance(), () -> { bukkitTask = Bukkit.getScheduler().runTaskTimer(BauSystem.getInstance(), () -> {
if (TPSUtils.currentTick.get() - lastUpdate > 10) { if (TPSUtils.currentTick.get() - lastUpdate > 20) {
bukkitTask.cancel(); bukkitTask.cancel();
Vector dimensions = maxVector.subtract(minVector); Vector dimensions = maxVector.subtract(minVector);
@ -62,7 +63,7 @@ public class Depth {
dimensions.setZ(Math.abs(dimensions.getZ())); dimensions.setZ(Math.abs(dimensions.getZ()));
if (dimensions.getX() != 0 && dimensions.getY() != 0 && dimensions.getZ() != 0) { if (dimensions.getX() != 0 && dimensions.getY() != 0 && dimensions.getZ() != 0) {
RegionUtils.message(region, player -> DepthCounter.getMessage(player, dimensions.getBlockX(), dimensions.getBlockY(), dimensions.getBlockZ())); RegionUtils.message(region, player -> DepthCounter.getMessage(player, dimensions.getBlockX(), dimensions.getBlockY(), dimensions.getBlockZ(), tntCount));
} }
Set<Depth> depthSet = DepthCounter.depthMap.get(region); Set<Depth> depthSet = DepthCounter.depthMap.get(region);
@ -74,11 +75,11 @@ public class Depth {
DepthCounter.depthMap.remove(region); DepthCounter.depthMap.remove(region);
} }
} }
}, 2, 2); }, 5, 5);
} }
public boolean update(List<Block> blocks) { public boolean update(List<Block> blocks) {
boolean expand = blocks.stream().anyMatch(block -> { long overlappingBlocks = blocks.stream().filter(block -> {
Vector vector = DepthCounter.blockVector(block.getLocation().toVector()); Vector vector = DepthCounter.blockVector(block.getLocation().toVector());
return vector.getX() >= minVector.getX() return vector.getX() >= minVector.getX()
&& vector.getY() >= minVector.getY() && vector.getY() >= minVector.getY()
@ -86,12 +87,13 @@ public class Depth {
&& vector.getX() <= maxVector.getX() && vector.getX() <= maxVector.getX()
&& vector.getY() <= maxVector.getY() && vector.getY() <= maxVector.getY()
&& vector.getZ() <= maxVector.getZ(); && vector.getZ() <= maxVector.getZ();
}); }).count();
if (!expand) { if (overlappingBlocks < 4) {
return false; return false;
} }
lastUpdate = TPSUtils.currentTick.get(); lastUpdate = TPSUtils.currentTick.get();
blocks.forEach(this::internalUpdate); blocks.forEach(this::internalUpdate);
tntCount++;
return true; return true;
} }

Datei anzeigen

@ -97,7 +97,7 @@ public class DepthCounter {
return values.stream().max(Integer::compare).orElse(0); return values.stream().max(Integer::compare).orElse(0);
} }
public String getMessage(Player player, int x, int y, int z) { public String getMessage(Player player, int x, int y, int z, int tntCount) {
final boolean xActive = DepthCounter.isActive(player, CountMode.X); final boolean xActive = DepthCounter.isActive(player, CountMode.X);
final boolean yActive = DepthCounter.isActive(player, CountMode.Y); final boolean yActive = DepthCounter.isActive(player, CountMode.Y);
final boolean zActive = DepthCounter.isActive(player, CountMode.Z); final boolean zActive = DepthCounter.isActive(player, CountMode.Z);
@ -106,7 +106,7 @@ public class DepthCounter {
return null; return null;
} }
final StringBuilder result = new StringBuilder(BauSystem.PREFIX).append("Schadensdimensionen ").append(ColorConfig.OTHER).append("> ").append(ColorConfig.BASE); final StringBuilder result = new StringBuilder(BauSystem.PREFIX).append("Schaden ").append(ColorConfig.OTHER).append("> ").append(ColorConfig.BASE);
final Set<Integer> dimensions = new HashSet<>(); final Set<Integer> dimensions = new HashSet<>();
if (xActive) { if (xActive) {
@ -145,6 +145,7 @@ public class DepthCounter {
} }
} }
result.append(ColorConfig.BASE).append("TNT").append(ColorConfig.OTHER).append(": ").append(ColorConfig.HIGHLIGHT).append(tntCount);
return result.toString(); return result.toString();
} }
} }