mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-12-23 09:37:35 +01:00
Patch consistent application of scoreboard teams (#2302)
* Patch consistent application of scoreboard teams This corrects issues with scoreboard team logic by ensuring NPCs use a consistent internal name, rather than randomizing * apply team name tag visible=false earlier
This commit is contained in:
parent
31409f46e2
commit
a79e8a571a
@ -33,10 +33,6 @@ public class HumanController extends AbstractEntityController {
|
||||
final WorldServer nmsWorld = ((CraftWorld) at.getWorld()).getHandle();
|
||||
String coloredName = npc.getFullName();
|
||||
String name = coloredName.length() > 16 ? coloredName.substring(0, 16) : coloredName;
|
||||
if (npc.requiresNameHologram()) {
|
||||
name = npc.getId() + UUID.randomUUID().toString().replace("-", "");
|
||||
name = name.substring(0, 16);
|
||||
}
|
||||
|
||||
UUID uuid = npc.getUniqueId();
|
||||
if (uuid.version() == 4) { // clear version
|
||||
@ -46,6 +42,11 @@ public class HumanController extends AbstractEntityController {
|
||||
uuid = new UUID(msb, uuid.getLeastSignificantBits());
|
||||
}
|
||||
|
||||
String teamName = Util.getTeamName(uuid);
|
||||
if (npc.requiresNameHologram()) {
|
||||
name = teamName;
|
||||
}
|
||||
|
||||
final GameProfile profile = new GameProfile(uuid, name);
|
||||
|
||||
final EntityHumanNPC handle = new EntityHumanNPC(nmsWorld.getServer().getServer(), nmsWorld, profile,
|
||||
@ -67,12 +68,14 @@ public class HumanController extends AbstractEntityController {
|
||||
|
||||
if (Setting.USE_SCOREBOARD_TEAMS.asBoolean()) {
|
||||
Scoreboard scoreboard = Util.getDummyScoreboard();
|
||||
String teamName = Util.getTeamName(profile.getId());
|
||||
|
||||
Team team = scoreboard.getTeam(teamName);
|
||||
int mode = 2;
|
||||
if (team == null) {
|
||||
team = scoreboard.registerNewTeam(teamName);
|
||||
if (npc.requiresNameHologram()) {
|
||||
team.setOption(Team.Option.NAME_TAG_VISIBILITY, Team.OptionStatus.NEVER);
|
||||
}
|
||||
mode = 0;
|
||||
}
|
||||
team.addPlayer(handle.getBukkitEntity());
|
||||
|
@ -33,10 +33,6 @@ public class HumanController extends AbstractEntityController {
|
||||
final WorldServer nmsWorld = ((CraftWorld) at.getWorld()).getHandle();
|
||||
String coloredName = npc.getFullName();
|
||||
String name = coloredName.length() > 16 ? coloredName.substring(0, 16) : coloredName;
|
||||
if (npc.requiresNameHologram()) {
|
||||
name = npc.getId() + UUID.randomUUID().toString().replace("-", "");
|
||||
name = name.substring(0, 16);
|
||||
}
|
||||
|
||||
UUID uuid = npc.getUniqueId();
|
||||
if (uuid.version() == 4) { // clear version
|
||||
@ -46,6 +42,11 @@ public class HumanController extends AbstractEntityController {
|
||||
uuid = new UUID(msb, uuid.getLeastSignificantBits());
|
||||
}
|
||||
|
||||
String teamName = Util.getTeamName(uuid);
|
||||
if (npc.requiresNameHologram()) {
|
||||
name = teamName;
|
||||
}
|
||||
|
||||
final GameProfile profile = new GameProfile(uuid, name);
|
||||
|
||||
final EntityHumanNPC handle = new EntityHumanNPC(nmsWorld.getServer().getServer(), nmsWorld, profile,
|
||||
@ -67,12 +68,14 @@ public class HumanController extends AbstractEntityController {
|
||||
|
||||
if (Setting.USE_SCOREBOARD_TEAMS.asBoolean()) {
|
||||
Scoreboard scoreboard = Util.getDummyScoreboard();
|
||||
String teamName = Util.getTeamName(profile.getId());
|
||||
|
||||
Team team = scoreboard.getTeam(teamName);
|
||||
int mode = 2;
|
||||
if (team == null) {
|
||||
team = scoreboard.registerNewTeam(teamName);
|
||||
if (npc.requiresNameHologram()) {
|
||||
team.setOption(Team.Option.NAME_TAG_VISIBILITY, Team.OptionStatus.NEVER);
|
||||
}
|
||||
mode = 0;
|
||||
}
|
||||
team.addPlayer(handle.getBukkitEntity());
|
||||
|
@ -33,10 +33,6 @@ public class HumanController extends AbstractEntityController {
|
||||
final WorldServer nmsWorld = ((CraftWorld) at.getWorld()).getHandle();
|
||||
String coloredName = npc.getFullName();
|
||||
String name = coloredName.length() > 16 ? coloredName.substring(0, 16) : coloredName;
|
||||
if (npc.requiresNameHologram()) {
|
||||
name = npc.getId() + UUID.randomUUID().toString().replace("-", "");
|
||||
name = name.substring(0, 16);
|
||||
}
|
||||
|
||||
UUID uuid = npc.getUniqueId();
|
||||
if (uuid.version() == 4) { // clear version
|
||||
@ -46,6 +42,11 @@ public class HumanController extends AbstractEntityController {
|
||||
uuid = new UUID(msb, uuid.getLeastSignificantBits());
|
||||
}
|
||||
|
||||
String teamName = Util.getTeamName(uuid);
|
||||
if (npc.requiresNameHologram()) {
|
||||
name = teamName;
|
||||
}
|
||||
|
||||
final GameProfile profile = new GameProfile(uuid, name);
|
||||
|
||||
final EntityHumanNPC handle = new EntityHumanNPC(nmsWorld.getServer().getServer(), nmsWorld, profile,
|
||||
@ -67,12 +68,14 @@ public class HumanController extends AbstractEntityController {
|
||||
|
||||
if (Setting.USE_SCOREBOARD_TEAMS.asBoolean()) {
|
||||
Scoreboard scoreboard = Util.getDummyScoreboard();
|
||||
String teamName = Util.getTeamName(profile.getId());
|
||||
|
||||
Team team = scoreboard.getTeam(teamName);
|
||||
int mode = 2;
|
||||
if (team == null) {
|
||||
team = scoreboard.registerNewTeam(teamName);
|
||||
if (npc.requiresNameHologram()) {
|
||||
team.setOption(Team.Option.NAME_TAG_VISIBILITY, Team.OptionStatus.NEVER);
|
||||
}
|
||||
mode = 0;
|
||||
}
|
||||
team.addPlayer(handle.getBukkitEntity());
|
||||
|
@ -33,10 +33,6 @@ public class HumanController extends AbstractEntityController {
|
||||
final WorldServer nmsWorld = ((CraftWorld) at.getWorld()).getHandle();
|
||||
String coloredName = npc.getFullName();
|
||||
String name = coloredName.length() > 16 ? coloredName.substring(0, 16) : coloredName;
|
||||
if (npc.requiresNameHologram()) {
|
||||
name = npc.getId() + UUID.randomUUID().toString().replace("-", "");
|
||||
name = name.substring(0, 16);
|
||||
}
|
||||
|
||||
UUID uuid = npc.getUniqueId();
|
||||
if (uuid.version() == 4) { // clear version
|
||||
@ -46,6 +42,11 @@ public class HumanController extends AbstractEntityController {
|
||||
uuid = new UUID(msb, uuid.getLeastSignificantBits());
|
||||
}
|
||||
|
||||
String teamName = Util.getTeamName(uuid);
|
||||
if (npc.requiresNameHologram()) {
|
||||
name = teamName;
|
||||
}
|
||||
|
||||
final GameProfile profile = new GameProfile(uuid, name);
|
||||
|
||||
final EntityHumanNPC handle = new EntityHumanNPC(nmsWorld.getServer().getServer(), nmsWorld, profile,
|
||||
@ -67,12 +68,14 @@ public class HumanController extends AbstractEntityController {
|
||||
|
||||
if (Setting.USE_SCOREBOARD_TEAMS.asBoolean()) {
|
||||
Scoreboard scoreboard = Util.getDummyScoreboard();
|
||||
String teamName = Util.getTeamName(profile.getId());
|
||||
|
||||
Team team = scoreboard.getTeam(teamName);
|
||||
int mode = 2;
|
||||
if (team == null) {
|
||||
team = scoreboard.registerNewTeam(teamName);
|
||||
if (npc.requiresNameHologram()) {
|
||||
team.setOption(Team.Option.NAME_TAG_VISIBILITY, Team.OptionStatus.NEVER);
|
||||
}
|
||||
mode = 0;
|
||||
}
|
||||
team.addPlayer(handle.getBukkitEntity());
|
||||
|
@ -33,10 +33,6 @@ public class HumanController extends AbstractEntityController {
|
||||
final WorldServer nmsWorld = ((CraftWorld) at.getWorld()).getHandle();
|
||||
String coloredName = npc.getFullName();
|
||||
String name = coloredName.length() > 16 ? coloredName.substring(0, 16) : coloredName;
|
||||
if (npc.requiresNameHologram()) {
|
||||
name = npc.getId() + UUID.randomUUID().toString().replace("-", "");
|
||||
name = name.substring(0, 16);
|
||||
}
|
||||
|
||||
UUID uuid = npc.getUniqueId();
|
||||
if (uuid.version() == 4) { // clear version
|
||||
@ -46,6 +42,11 @@ public class HumanController extends AbstractEntityController {
|
||||
uuid = new UUID(msb, uuid.getLeastSignificantBits());
|
||||
}
|
||||
|
||||
String teamName = Util.getTeamName(uuid);
|
||||
if (npc.requiresNameHologram()) {
|
||||
name = teamName;
|
||||
}
|
||||
|
||||
final GameProfile profile = new GameProfile(uuid, name);
|
||||
|
||||
final EntityHumanNPC handle = new EntityHumanNPC(nmsWorld.getServer().getServer(), nmsWorld, profile,
|
||||
@ -67,12 +68,14 @@ public class HumanController extends AbstractEntityController {
|
||||
|
||||
if (Setting.USE_SCOREBOARD_TEAMS.asBoolean()) {
|
||||
Scoreboard scoreboard = Util.getDummyScoreboard();
|
||||
String teamName = Util.getTeamName(profile.getId());
|
||||
|
||||
Team team = scoreboard.getTeam(teamName);
|
||||
int mode = 2;
|
||||
if (team == null) {
|
||||
team = scoreboard.registerNewTeam(teamName);
|
||||
if (npc.requiresNameHologram()) {
|
||||
team.setOption(Team.Option.NAME_TAG_VISIBILITY, Team.OptionStatus.NEVER);
|
||||
}
|
||||
mode = 0;
|
||||
}
|
||||
team.addPlayer(handle.getBukkitEntity());
|
||||
|
@ -33,10 +33,6 @@ public class HumanController extends AbstractEntityController {
|
||||
final WorldServer nmsWorld = ((CraftWorld) at.getWorld()).getHandle();
|
||||
String coloredName = npc.getFullName();
|
||||
String name = coloredName.length() > 16 ? coloredName.substring(0, 16) : coloredName;
|
||||
if (npc.requiresNameHologram()) {
|
||||
name = npc.getId() + UUID.randomUUID().toString().replace("-", "");
|
||||
name = name.substring(0, 16);
|
||||
}
|
||||
|
||||
UUID uuid = npc.getUniqueId();
|
||||
if (uuid.version() == 4) { // clear version
|
||||
@ -46,6 +42,11 @@ public class HumanController extends AbstractEntityController {
|
||||
uuid = new UUID(msb, uuid.getLeastSignificantBits());
|
||||
}
|
||||
|
||||
String teamName = Util.getTeamName(uuid);
|
||||
if (npc.requiresNameHologram()) {
|
||||
name = teamName;
|
||||
}
|
||||
|
||||
final GameProfile profile = new GameProfile(uuid, name);
|
||||
|
||||
final EntityHumanNPC handle = new EntityHumanNPC(nmsWorld.getServer().getServer(), nmsWorld, profile,
|
||||
@ -67,12 +68,14 @@ public class HumanController extends AbstractEntityController {
|
||||
|
||||
if (Setting.USE_SCOREBOARD_TEAMS.asBoolean()) {
|
||||
Scoreboard scoreboard = Util.getDummyScoreboard();
|
||||
String teamName = Util.getTeamName(profile.getId());
|
||||
|
||||
Team team = scoreboard.getTeam(teamName);
|
||||
int mode = 2;
|
||||
if (team == null) {
|
||||
team = scoreboard.registerNewTeam(teamName);
|
||||
if (npc.requiresNameHologram()) {
|
||||
team.setOption(Team.Option.NAME_TAG_VISIBILITY, Team.OptionStatus.NEVER);
|
||||
}
|
||||
mode = 0;
|
||||
}
|
||||
team.addPlayer(handle.getBukkitEntity());
|
||||
|
@ -33,10 +33,6 @@ public class HumanController extends AbstractEntityController {
|
||||
final WorldServer nmsWorld = ((CraftWorld) at.getWorld()).getHandle();
|
||||
String coloredName = npc.getFullName();
|
||||
String name = coloredName.length() > 16 ? coloredName.substring(0, 16) : coloredName;
|
||||
if (npc.requiresNameHologram()) {
|
||||
name = npc.getId() + UUID.randomUUID().toString().replace("-", "");
|
||||
name = name.substring(0, 16);
|
||||
}
|
||||
|
||||
UUID uuid = npc.getUniqueId();
|
||||
if (uuid.version() == 4) { // clear version
|
||||
@ -45,6 +41,12 @@ public class HumanController extends AbstractEntityController {
|
||||
msb |= 0x0000000000002000L;
|
||||
uuid = new UUID(msb, uuid.getLeastSignificantBits());
|
||||
}
|
||||
|
||||
String teamName = Util.getTeamName(uuid);
|
||||
if (npc.requiresNameHologram()) {
|
||||
name = teamName;
|
||||
}
|
||||
|
||||
final GameProfile profile = new GameProfile(uuid, name);
|
||||
|
||||
final EntityHumanNPC handle = new EntityHumanNPC(nmsWorld.getServer().getServer(), nmsWorld, profile,
|
||||
@ -67,12 +69,14 @@ public class HumanController extends AbstractEntityController {
|
||||
if (!Setting.USE_SCOREBOARD_TEAMS.asBoolean())
|
||||
return;
|
||||
Scoreboard scoreboard = Util.getDummyScoreboard();
|
||||
String teamName = Util.getTeamName(profile.getId());
|
||||
|
||||
Team team = scoreboard.getTeam(teamName);
|
||||
int mode = 2;
|
||||
if (team == null) {
|
||||
team = scoreboard.registerNewTeam(teamName);
|
||||
if (npc.requiresNameHologram()) {
|
||||
team.setOption(Team.Option.NAME_TAG_VISIBILITY, Team.OptionStatus.NEVER);
|
||||
}
|
||||
mode = 0;
|
||||
}
|
||||
team.addPlayer(handle.getBukkitEntity());
|
||||
|
@ -7,6 +7,7 @@ import org.bukkit.Location;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scoreboard.NameTagVisibility;
|
||||
import org.bukkit.scoreboard.Scoreboard;
|
||||
import org.bukkit.scoreboard.Team;
|
||||
|
||||
@ -33,10 +34,6 @@ public class HumanController extends AbstractEntityController {
|
||||
final WorldServer nmsWorld = ((CraftWorld) at.getWorld()).getHandle();
|
||||
String coloredName = npc.getFullName();
|
||||
String name = coloredName.length() > 16 ? coloredName.substring(0, 16) : coloredName;
|
||||
if (npc.requiresNameHologram()) {
|
||||
name = npc.getId() + UUID.randomUUID().toString().replace("-", "");
|
||||
name = name.substring(0, 16);
|
||||
}
|
||||
|
||||
UUID uuid = npc.getUniqueId();
|
||||
if (uuid.version() == 4) { // clear version
|
||||
@ -46,6 +43,11 @@ public class HumanController extends AbstractEntityController {
|
||||
uuid = new UUID(msb, uuid.getLeastSignificantBits());
|
||||
}
|
||||
|
||||
final String teamName = Util.getTeamName(uuid);
|
||||
if (npc.requiresNameHologram()) {
|
||||
name = teamName;
|
||||
}
|
||||
|
||||
final GameProfile profile = new GameProfile(uuid, name);
|
||||
|
||||
final EntityHumanNPC handle = new EntityHumanNPC(nmsWorld.getServer().getServer(), nmsWorld, profile,
|
||||
@ -67,12 +69,14 @@ public class HumanController extends AbstractEntityController {
|
||||
|
||||
if (Setting.USE_SCOREBOARD_TEAMS.asBoolean()) {
|
||||
Scoreboard scoreboard = Util.getDummyScoreboard();
|
||||
String teamName = Util.getTeamName(profile.getId());
|
||||
|
||||
Team team = scoreboard.getTeam(teamName);
|
||||
int mode = 2;
|
||||
if (team == null) {
|
||||
team = scoreboard.registerNewTeam(teamName);
|
||||
if (npc.requiresNameHologram()) {
|
||||
team.setNameTagVisibility(NameTagVisibility.NEVER);
|
||||
}
|
||||
mode = 0;
|
||||
}
|
||||
team.addPlayer(handle.getBukkitEntity());
|
||||
|
Loading…
Reference in New Issue
Block a user