From 3e0d8331bee965738bc4e6741183939512ec7995 Mon Sep 17 00:00:00 2001 From: Wesley Wolfe Date: Thu, 11 Apr 2013 23:12:45 -0500 Subject: [PATCH] Change perspective of team checking. Fixes BUKKIT-4044 The method's return value was being incorrectly calculated from the perspective of this.canHurt(that), where it's actually used from the this.canBeHurtBy(that) perspective. --- .../net/minecraft/server/EntityHuman.java | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/main/java/net/minecraft/server/EntityHuman.java b/src/main/java/net/minecraft/server/EntityHuman.java index 91b44a0319..d647d2ef33 100644 --- a/src/main/java/net/minecraft/server/EntityHuman.java +++ b/src/main/java/net/minecraft/server/EntityHuman.java @@ -688,27 +688,28 @@ public abstract class EntityHuman extends EntityLiving implements ICommandListen } public boolean a(EntityHuman entityhuman) { - // CraftBukkit start - Change to check player's scoreboard team according to API reference to this (or main) scoreboard + // CraftBukkit start - Change to check OTHER player's scoreboard team according to API + // To summarize this method's logic, it's "Can parameter hurt this" org.bukkit.scoreboard.Team team; - if (this instanceof EntityPlayer) { - EntityPlayer thisPlayer = (EntityPlayer) this; - team = thisPlayer.getBukkitEntity().getScoreboard().getPlayerTeam(thisPlayer.getBukkitEntity()); + if (entityhuman instanceof EntityPlayer) { + EntityPlayer thatPlayer = (EntityPlayer) entityhuman; + team = thatPlayer.getBukkitEntity().getScoreboard().getPlayerTeam(thatPlayer.getBukkitEntity()); if (team == null || team.allowFriendlyFire()) { return true; } } else { // This should never be called, but is implemented anyway - org.bukkit.OfflinePlayer thisPlayer = this.world.getServer().getOfflinePlayer(this.name); - team = this.world.getServer().getScoreboardManager().getMainScoreboard().getPlayerTeam(thisPlayer); + org.bukkit.OfflinePlayer thisPlayer = entityhuman.world.getServer().getOfflinePlayer(entityhuman.name); + team = entityhuman.world.getServer().getScoreboardManager().getMainScoreboard().getPlayerTeam(thisPlayer); if (team == null || team.allowFriendlyFire()) { return true; } } - if (entityhuman instanceof EntityPlayer) { - return team.hasPlayer(((EntityPlayer) entityhuman).getBukkitEntity()); + if (this instanceof EntityPlayer) { + return !team.hasPlayer(((EntityPlayer) this).getBukkitEntity()); } - return team.hasPlayer(this.world.getServer().getOfflinePlayer(entityhuman.name)); + return !team.hasPlayer(this.world.getServer().getOfflinePlayer(this.name)); // CraftBukkit end }