mirror of
https://github.com/PikaMug/Quests.git
synced 2024-11-22 10:36:09 +01:00
Merge pull request #15 from elBukkit/master
Fix Issue#10 : Handle TNT and Projectiles in Kill Mob Objective
This commit is contained in:
commit
049c3977d8
8
pom.xml
8
pom.xml
@ -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>
|
||||
|
@ -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) {
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user