diff options
author | Wesley Wolfe <weswolf@aol.com> | 2013-04-11 23:12:45 -0500 |
---|---|---|
committer | Wesley Wolfe <weswolf@aol.com> | 2013-04-11 23:22:41 -0500 |
commit | 3e0d8331bee965738bc4e6741183939512ec7995 (patch) | |
tree | 6b7b0eb52835c425fc48c3ab37e4d4e2f3f4f016 /src/main/java/net/minecraft/server | |
parent | ac593849aec264019a7e327086ce303031668ecd (diff) | |
download | craftbukkit-3e0d8331bee965738bc4e6741183939512ec7995.tar craftbukkit-3e0d8331bee965738bc4e6741183939512ec7995.tar.gz craftbukkit-3e0d8331bee965738bc4e6741183939512ec7995.tar.lz craftbukkit-3e0d8331bee965738bc4e6741183939512ec7995.tar.xz craftbukkit-3e0d8331bee965738bc4e6741183939512ec7995.zip |
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.
Diffstat (limited to 'src/main/java/net/minecraft/server')
-rw-r--r-- | src/main/java/net/minecraft/server/EntityHuman.java | 19 |
1 files 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 91b44a03..d647d2ef 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 } |