13
0
geforkt von Mirrors/Paper

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.
Dieser Commit ist enthalten in:
Wesley Wolfe 2013-04-11 23:12:45 -05:00
Ursprung ac593849ae
Commit 3e0d8331be

Datei anzeigen

@ -688,27 +688,28 @@ public abstract class EntityHuman extends EntityLiving implements ICommandListen
} }
public boolean a(EntityHuman entityhuman) { 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; org.bukkit.scoreboard.Team team;
if (this instanceof EntityPlayer) { if (entityhuman instanceof EntityPlayer) {
EntityPlayer thisPlayer = (EntityPlayer) this; EntityPlayer thatPlayer = (EntityPlayer) entityhuman;
team = thisPlayer.getBukkitEntity().getScoreboard().getPlayerTeam(thisPlayer.getBukkitEntity()); team = thatPlayer.getBukkitEntity().getScoreboard().getPlayerTeam(thatPlayer.getBukkitEntity());
if (team == null || team.allowFriendlyFire()) { if (team == null || team.allowFriendlyFire()) {
return true; return true;
} }
} else { } else {
// This should never be called, but is implemented anyway // This should never be called, but is implemented anyway
org.bukkit.OfflinePlayer thisPlayer = this.world.getServer().getOfflinePlayer(this.name); org.bukkit.OfflinePlayer thisPlayer = entityhuman.world.getServer().getOfflinePlayer(entityhuman.name);
team = this.world.getServer().getScoreboardManager().getMainScoreboard().getPlayerTeam(thisPlayer); team = entityhuman.world.getServer().getScoreboardManager().getMainScoreboard().getPlayerTeam(thisPlayer);
if (team == null || team.allowFriendlyFire()) { if (team == null || team.allowFriendlyFire()) {
return true; return true;
} }
} }
if (entityhuman instanceof EntityPlayer) { if (this instanceof EntityPlayer) {
return team.hasPlayer(((EntityPlayer) entityhuman).getBukkitEntity()); 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 // CraftBukkit end
} }