Skip to content

Commit

Permalink
Fix kill and item drop listeners.
Browse files Browse the repository at this point in the history
  • Loading branch information
davidcernat committed Jul 9, 2013
1 parent f1ff701 commit 9133c21
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ public String report() {
public void mobKilled(EntityDeathEvent event) {
if (type != ItemDropType.MOBKILL) return;
dB.echoDebug("...checking kill");
if (event.getEntity().getKiller() != player) return;
if (event.getEntity().getKiller() != player.getPlayerEntity()) return;
dB.echoDebug("...killed by player");
if (event.getEntity().getType() != mob) return;
dB.echoDebug("...proper mob");
Expand All @@ -218,7 +218,7 @@ public void mobKilled(EntityDeathEvent event) {
public void blockMined(BlockBreakEvent event) {
if (type != ItemDropType.BLOCKBREAK) return;
dB.echoDebug("...checking blockbreakevent");
if (event.getPlayer() != player) return;
if (event.getPlayer() != player.getPlayerEntity()) return;
dB.echoDebug("...mined by player");
if (event.getBlock().getType() != block) return;
dB.echoDebug("...proper block mined");
Expand All @@ -243,7 +243,7 @@ public void blockMined(BlockBreakEvent event) {
public void blockPlaced(BlockPlaceEvent event) {
if (type != ItemDropType.BLOCKPLACE) return;
dB.echoDebug("...checking blockplaceevent");
if (event.getPlayer() != player) return;
if (event.getPlayer() != player.getPlayerEntity()) return;
dB.echoDebug("...placed by player");
if (event.getBlock().getType() != block) return;
dB.echoDebug("...proper block placed");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,16 +153,18 @@ public void deconstructed() {

@EventHandler
public void listen(EntityDeathEvent event) {

// Only continue if the event is an event for the player that owns this listener.
if (event.getEntity().getKiller() != player) return;

if (event.getEntity().getKiller() != player.getPlayerEntity()) return;
// If REGION argument specified, check. If not in region, don't count kill!
if (region != null)
if (!WorldGuardUtilities.checkWGRegion(player.getPlayerEntity().getLocation(), region)) return;

// Check type!
if (type == KillType.ENTITY) {
if (targets.contains(event.getEntityType().toString()) || targets.contains(event.getEntityType().toString().toLowerCase()) || targets.contains("*")) {

if (targets.contains(event.getEntityType().name()) || targets.contains(event.getEntityType().name().toLowerCase()) || targets.contains("*")) {
currentKills++;
dB.log(player.getName() + " killed a " + event.getEntityType().toString() + ". Current progress '" + currentKills + "/" + quantity + "'.");
check();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,12 +190,12 @@ public void onHit(EntityDamageByEntityEvent event) {
player = dPlayer.mirrorBukkitPlayer((Player) event.getEntity());

DenizenAPI.getDenizenNPC(npc).action("hit", player);
DenizenAPI.getDenizenNPC(npc).action("hit on " + event.getEntityType().toString(), player);
DenizenAPI.getDenizenNPC(npc).action("hit on " + event.getEntityType().name(), player);

if (event.getEntity() instanceof LivingEntity) {
if (((LivingEntity) event.getEntity()).getHealth() - event.getDamage() <= 0) {
DenizenAPI.getDenizenNPC(npc).action("kill", player);
DenizenAPI.getDenizenNPC(npc).action("kill of " + event.getEntityType().toString(), player);
DenizenAPI.getDenizenNPC(npc).action("kill of " + event.getEntityType().name(), player);
}
}

Expand Down

0 comments on commit 9133c21

Please sign in to comment.