Merge pull request #15 from elBukkit/master

Fix Issue#10 : Handle TNT and Projectiles in Kill Mob Objective
This commit is contained in:
FlyingPikachu 2015-02-15 18:45:15 -05:00
commit 049c3977d8
3 changed files with 45 additions and 6 deletions

View File

@ -24,11 +24,17 @@
<dependencies>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
<artifactId>craftbukkit</artifactId>
<version>1.8-R0.1-SNAPSHOT</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/craftbukkit-1.8.jar</systemPath>
</dependency>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
<version>1.8-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>craftbukkit1</artifactId>

View File

@ -33,6 +33,7 @@ import org.bukkit.event.inventory.InventoryType;
import org.bukkit.event.player.*;
import org.bukkit.event.player.PlayerFishEvent.State;
import org.bukkit.inventory.ItemStack;
import org.bukkit.projectiles.ProjectileSource;
public class PlayerListener implements Listener, ColorUtil {
@ -566,19 +567,49 @@ public class PlayerListener implements Listener, ColorUtil {
public void onEntityDeath(EntityDeathEvent evt) {
if (evt.getEntity() instanceof Player == false) {
if (evt.getEntity().getLastDamageCause() instanceof EntityDamageByEntityEvent) {
EntityDamageByEntityEvent damageEvent = (EntityDamageByEntityEvent) evt.getEntity().getLastDamageCause();
Entity damager = damageEvent.getDamager();
if (damager != null) {
if (damager instanceof Projectile) {
Projectile projectile = (Projectile)damager;
ProjectileSource source = projectile.getShooter();
if(evt.getEntity().getLastDamageCause().getEntity() instanceof Player) {
if(source instanceof Player) {
Player player = (Player) evt.getEntity().getLastDamageCause().getEntity();
Player player = (Player) source;
boolean okay = true;
if (plugin.citizens != null) {
if (CitizensAPI.getNPCRegistry().isNPC(player)) {
okay = false;
}
}
if (okay) {
Quester quester = plugin.getQuester(player.getUniqueId());
for (Quest quest : quester.currentQuests.keySet()) {
if (quester.hasObjective(quest, "killMob")) {
quester.killMob(quest, evt.getEntity().getLocation(), evt.getEntity().getType());
}
}
}
}
} else if (damager instanceof TNTPrimed) {
TNTPrimed tnt = (TNTPrimed)damager;
Entity source = tnt.getSource();
if(source instanceof Player) {
Player player = (Player) source;
boolean okay = true;
if (plugin.citizens != null) {

View File

@ -4766,7 +4766,9 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
UUID.fromString(s);
return true;
} catch (IllegalArgumentException e) {
e.printStackTrace();
// Maybe only enable this when debugging?
// When it fails, it can generate gigabyte-sized log files.
// e.printStackTrace();
}
}