fireball logging did not work with 1.8

This commit is contained in:
Mahagon
2015-02-15 17:15:46 +01:00
committed by Philip Cass
parent c3f5ce9a5b
commit a9ff27a2a0
2 changed files with 26 additions and 10 deletions

View File

@@ -1,13 +1,15 @@
package de.diddiz.LogBlock; package de.diddiz.LogBlock;
import static de.diddiz.util.BukkitUtils.entityName; import static de.diddiz.util.BukkitUtils.entityName;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.projectiles.ProjectileSource;
public class Actor { public class Actor {
@Override @Override
@@ -69,6 +71,16 @@ public class Actor {
return new Actor(entity.getName()); return new Actor(entity.getName());
} }
public static Actor actorFromProjectileSource(ProjectileSource psource) {
if (psource instanceof Player) {
Player player = ((Player) psource).getPlayer();
return new Actor(player.getName(),player.getUniqueId().toString());
} else {
return new Actor(psource.toString());
}
}
public static boolean isValidUUID(String uuid) { public static boolean isValidUUID(String uuid) {
try { try {
java.util.UUID.fromString(uuid); java.util.UUID.fromString(uuid);
@@ -82,4 +94,5 @@ public class Actor {
return "log_" + name; return "log_" + name;
} }
} }

View File

@@ -1,12 +1,9 @@
package de.diddiz.LogBlock.listeners; package de.diddiz.LogBlock.listeners;
import de.diddiz.LogBlock.Actor;
import de.diddiz.LogBlock.LogBlock;
import de.diddiz.LogBlock.Logging;
import static de.diddiz.LogBlock.config.Config.getWorldConfig; import static de.diddiz.LogBlock.config.Config.getWorldConfig;
import static de.diddiz.LogBlock.config.Config.logCreeperExplosionsAsPlayerWhoTriggeredThese; import static de.diddiz.LogBlock.config.Config.logCreeperExplosionsAsPlayerWhoTriggeredThese;
import de.diddiz.LogBlock.config.WorldConfig;
import static de.diddiz.util.BukkitUtils.getContainerBlocks; import static de.diddiz.util.BukkitUtils.getContainerBlocks;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.Sign; import org.bukkit.block.Sign;
@@ -23,6 +20,12 @@ import org.bukkit.entity.minecart.ExplosiveMinecart;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityExplodeEvent; import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.projectiles.ProjectileSource;
import de.diddiz.LogBlock.Actor;
import de.diddiz.LogBlock.LogBlock;
import de.diddiz.LogBlock.Logging;
import de.diddiz.LogBlock.config.WorldConfig;
public class ExplosionLogging extends LoggingListener public class ExplosionLogging extends LoggingListener
{ {
@@ -57,7 +60,7 @@ public class ExplosionLogging extends LoggingListener
new Actor("Creeper"); new Actor("Creeper");
} else if (source instanceof Fireball) { } else if (source instanceof Fireball) {
Fireball fireball = (Fireball) source; Fireball fireball = (Fireball) source;
Entity shooter = fireball.getShooter(); ProjectileSource shooter = fireball.getShooter();
if (shooter == null) { if (shooter == null) {
return; return;
} }
@@ -65,12 +68,12 @@ public class ExplosionLogging extends LoggingListener
if (!wcfg.isLogging(Logging.GHASTFIREBALLEXPLOSION)) { if (!wcfg.isLogging(Logging.GHASTFIREBALLEXPLOSION)) {
return; return;
} }
actor = Actor.actorFromEntity(shooter); actor = Actor.actorFromProjectileSource(shooter);
} else if (shooter instanceof Wither) { } else if (shooter instanceof Wither) {
if (!wcfg.isLogging(Logging.WITHER)) { if (!wcfg.isLogging(Logging.WITHER)) {
return; return;
} }
actor = Actor.actorFromEntity(shooter); actor = Actor.actorFromProjectileSource(shooter);
} }
} else if (source instanceof EnderDragon) { } else if (source instanceof EnderDragon) {
if (!wcfg.isLogging(Logging.ENDERDRAGON)) if (!wcfg.isLogging(Logging.ENDERDRAGON))