Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,17 @@ public class DamageTracking implements Listener {
public static boolean EnableFireballTracking = false;
public static boolean EnableTNTTracking = true;
public static boolean EnableTorpedoTracking = false;
public static boolean DisableSinkingCraftTNT = true;
public static boolean DisableDisabledCraftTNT = false;
public static int DamageTimeout = 300;
private final Map<PlayerCraft, List<DamageRecord>> damageRecords = new HashMap<>();

public static void load(@NotNull FileConfiguration config) {
EnableFireballTracking = config.getBoolean("EnableFireballTracking", false);
EnableTNTTracking = config.getBoolean("EnableTNTTracking", true);
EnableTorpedoTracking = config.getBoolean("EnableTorpedoTracking", false);
DisableSinkingCraftTNT = config.getBoolean("DisableSinkingCraftTNT", true);
DisableDisabledCraftTNT = config.getBoolean("DisableDisabledCraftTNT", false);
DamageTimeout = config.getInt("DamageTimeout", 300);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import net.countercraft.movecraft.craft.Craft;
import net.countercraft.movecraft.craft.CraftManager;
import net.countercraft.movecraft.craft.PlayerCraft;
import net.countercraft.movecraft.craft.SinkingCraft;
import net.countercraft.movecraft.util.MathUtils;
import org.bukkit.Bukkit;
import org.bukkit.Location;
Expand Down Expand Up @@ -81,16 +82,25 @@ private Vector getTNTVector() {
}

@EventHandler
public void onEntitySpawn (@NotNull EntitySpawnEvent e) {
public void onEntitySpawn(@NotNull EntitySpawnEvent e) {
if (!DamageTracking.EnableTNTTracking)
return;
if(!e.getEntityType().equals(EntityType.PRIMED_TNT))
if (!e.getEntityType().equals(EntityType.PRIMED_TNT))
return;
TNTPrimed tnt = (TNTPrimed)e.getEntity();
TNTPrimed tnt = (TNTPrimed) e.getEntity();

// Find nearest craft
Craft craft = MathUtils.fastNearestCraftToLoc(CraftManager.getInstance().getCrafts(),
tnt.getLocation());
if (craft instanceof SinkingCraft && DamageTracking.DisableSinkingCraftTNT) {
e.setCancelled(true);
return;
}
else if (craft != null && craft.getDisabled() && DamageTracking.DisableDisabledCraftTNT) {
e.setCancelled(true);
return;
}

if (!(craft instanceof PlayerCraft))
return;
if (!craft.getHitBox().contains(MathUtils.bukkit2MovecraftLoc(tnt.getLocation()))) {
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ ExplosionParticles: VILLAGER_ANGRY # Particle to use for particle tracer explosi
EnableFireballTracking: false # Enable tracking and recording of fireballs (higher lag than other tracking methods)
EnableTNTTracking: false # Enable tracking and recording of TNT damage
EnableTorpedoTracking: false # Enable tracking and recording of Torpedo damage
DisableSinkingCraftTNT: true # Disable spawning of TNT from sinking crafts
DisableDisabledCraftTNT: false # Disable spawning of TNT from disabled crafts
DamageTimeout: 300 # Timeout for damages in seconds

# Combat Release Tracking
Expand Down