mirror of
https://github.com/Minestom/Minestom.git
synced 2024-12-28 20:18:10 +01:00
fix 'seeInvisiblePlayers' friendly flag (#491)
This commit is contained in:
parent
06189ee783
commit
fb39fa59f5
@ -28,6 +28,9 @@ public class Team implements PacketGroupingAudience {
|
||||
|
||||
private static final ConnectionManager CONNECTION_MANAGER = MinecraftServer.getConnectionManager();
|
||||
|
||||
private static final byte ALLOW_FRIENDLY_FIRE_BIT = 0x01;
|
||||
private static final byte SEE_INVISIBLE_PLAYERS_BIT = 0x02;
|
||||
|
||||
/**
|
||||
* A collection of all registered entities who are on the team.
|
||||
*/
|
||||
@ -296,6 +299,44 @@ public class Team implements PacketGroupingAudience {
|
||||
this.sendUpdatePacket();
|
||||
}
|
||||
|
||||
private boolean getFriendlyFlagBit(byte index) {
|
||||
return (this.friendlyFlags & index) == index;
|
||||
}
|
||||
|
||||
private void setFriendlyFlagBit(byte index, boolean value) {
|
||||
if (value) {
|
||||
this.friendlyFlags |= index;
|
||||
} else {
|
||||
this.friendlyFlags &= ~index;
|
||||
}
|
||||
}
|
||||
|
||||
public void setAllowFriendlyFire(boolean value) {
|
||||
this.setFriendlyFlagBit(ALLOW_FRIENDLY_FIRE_BIT, value);
|
||||
}
|
||||
|
||||
public void updateAllowFriendlyFire(boolean value) {
|
||||
this.setAllowFriendlyFire(value);
|
||||
this.sendUpdatePacket();
|
||||
}
|
||||
|
||||
public boolean isAllowFriendlyFire() {
|
||||
return this.getFriendlyFlagBit(ALLOW_FRIENDLY_FIRE_BIT);
|
||||
}
|
||||
|
||||
public void setSeeInvisiblePlayers(boolean value) {
|
||||
this.setFriendlyFlagBit(SEE_INVISIBLE_PLAYERS_BIT, value);
|
||||
}
|
||||
|
||||
public void updateSeeInvisiblePlayers(boolean value) {
|
||||
this.setSeeInvisiblePlayers(value);
|
||||
this.sendUpdatePacket();
|
||||
}
|
||||
|
||||
public boolean isSeeInvisiblePlayers() {
|
||||
return this.getFriendlyFlagBit(SEE_INVISIBLE_PLAYERS_BIT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the registry name of the team.
|
||||
*
|
||||
|
@ -128,7 +128,8 @@ public class TeamBuilder {
|
||||
* @return this builder, for chaining
|
||||
*/
|
||||
public TeamBuilder updateAllowFriendlyFire() {
|
||||
return this.updateFriendlyFlags((byte) 0x01);
|
||||
this.team.updateAllowFriendlyFire(true);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -137,7 +138,8 @@ public class TeamBuilder {
|
||||
* @return this builder, for chaining
|
||||
*/
|
||||
public TeamBuilder updateSeeInvisiblePlayers() {
|
||||
return this.updateFriendlyFlags((byte) 0x01);
|
||||
this.team.updateSeeInvisiblePlayers(true);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -239,7 +241,8 @@ public class TeamBuilder {
|
||||
* @return this builder, for chaining
|
||||
*/
|
||||
public TeamBuilder allowFriendlyFire() {
|
||||
return this.friendlyFlags((byte) 0x01);
|
||||
this.team.setAllowFriendlyFire(true);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -250,7 +253,8 @@ public class TeamBuilder {
|
||||
* @return this builder, for chaining
|
||||
*/
|
||||
public TeamBuilder seeInvisiblePlayers() {
|
||||
return this.friendlyFlags((byte) 0x01);
|
||||
this.team.setSeeInvisiblePlayers(true);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user