mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-25 12:15:53 +01:00
Integrate team creation directly into ScoreboardTrait
This commit is contained in:
parent
71bc177298
commit
5dbc578fd2
@ -479,16 +479,8 @@ public class CitizensNPC extends AbstractNPC {
|
||||
}
|
||||
|
||||
private void updateCustomName() {
|
||||
boolean nameVisibility = false;
|
||||
if (!getEntity().isCustomNameVisible()
|
||||
&& !data().<Object> get(NPC.Metadata.NAMEPLATE_VISIBLE, true).toString().equals("hover")) {
|
||||
} else if (!requiresNameHologram()) {
|
||||
nameVisibility = true;
|
||||
getEntity().setCustomName(getFullName());
|
||||
}
|
||||
|
||||
if (data().has(NPC.Metadata.SCOREBOARD_FAKE_TEAM_NAME)) {
|
||||
getOrAddTrait(ScoreboardTrait.class).apply(nameVisibility);
|
||||
getOrAddTrait(ScoreboardTrait.class).update();
|
||||
}
|
||||
}
|
||||
|
||||
@ -497,6 +489,9 @@ public class CitizensNPC extends AbstractNPC {
|
||||
if (requiresNameHologram()) {
|
||||
nameplateVisible = "false";
|
||||
}
|
||||
if (nameplateVisible.equals("true") || nameplateVisible.equals("hover")) {
|
||||
getEntity().setCustomName(getFullName());
|
||||
}
|
||||
getEntity().setCustomNameVisible(Boolean.parseBoolean(nameplateVisible));
|
||||
}
|
||||
|
||||
|
@ -10,6 +10,7 @@ import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.scoreboard.Scoreboard;
|
||||
import org.bukkit.scoreboard.Team;
|
||||
import org.bukkit.scoreboard.Team.Option;
|
||||
import org.bukkit.scoreboard.Team.OptionStatus;
|
||||
@ -45,7 +46,73 @@ public class ScoreboardTrait extends Trait {
|
||||
tags.add(tag);
|
||||
}
|
||||
|
||||
public void apply(boolean nameVisibility) {
|
||||
public void createTeam(String entityName) {
|
||||
String teamName = Util.getTeamName(npc.getUniqueId());
|
||||
npc.data().set(NPC.SCOREBOARD_FAKE_TEAM_NAME_METADATA, teamName);
|
||||
Scoreboard scoreboard = Util.getDummyScoreboard();
|
||||
Team team = scoreboard.getTeam(teamName);
|
||||
if (team == null) {
|
||||
team = scoreboard.registerNewTeam(teamName);
|
||||
}
|
||||
team.addEntry(entityName);
|
||||
}
|
||||
|
||||
public ChatColor getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
public Set<String> getTags() {
|
||||
return tags;
|
||||
}
|
||||
|
||||
private Team getTeam() {
|
||||
String teamName = npc.data().get(NPC.Metadata.SCOREBOARD_FAKE_TEAM_NAME, "");
|
||||
if (teamName.isEmpty())
|
||||
return null;
|
||||
return Util.getDummyScoreboard().getTeam(teamName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDespawn() {
|
||||
if (npc.getEntity() == null)
|
||||
return;
|
||||
String name = npc.getEntity() instanceof Player ? npc.getEntity().getName() : npc.getUniqueId().toString();
|
||||
String teamName = npc.data().get(NPC.SCOREBOARD_FAKE_TEAM_NAME_METADATA, "");
|
||||
if (teamName.isEmpty())
|
||||
return;
|
||||
Team team = Util.getDummyScoreboard().getTeam(teamName);
|
||||
npc.data().remove(NPC.SCOREBOARD_FAKE_TEAM_NAME_METADATA);
|
||||
if (team == null)
|
||||
return;
|
||||
if (team.hasEntry(name)) {
|
||||
if (team.getSize() == 1) {
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
NMS.sendTeamPacket(player, team, 1);
|
||||
}
|
||||
team.unregister();
|
||||
} else {
|
||||
team.removeEntry(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSpawn() {
|
||||
changed = true;
|
||||
}
|
||||
|
||||
public void removeTag(String tag) {
|
||||
tags.remove(tag);
|
||||
}
|
||||
|
||||
public void setColor(ChatColor color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
public void update() {
|
||||
String forceVisible = npc.data().<Object> get(NPC.Metadata.NAMEPLATE_VISIBLE, true).toString();
|
||||
boolean nameVisibility = !npc.requiresNameHologram()
|
||||
&& (forceVisible.equals("true") || forceVisible.equals("hover"));
|
||||
Team team = getTeam();
|
||||
if (team == null)
|
||||
return;
|
||||
@ -155,42 +222,6 @@ public class ScoreboardTrait extends Trait {
|
||||
}
|
||||
}
|
||||
|
||||
public ChatColor getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
public Set<String> getTags() {
|
||||
return tags;
|
||||
}
|
||||
|
||||
private Team getTeam() {
|
||||
String teamName = npc.data().get(NPC.Metadata.SCOREBOARD_FAKE_TEAM_NAME, "");
|
||||
if (teamName.isEmpty())
|
||||
return null;
|
||||
return Util.getDummyScoreboard().getTeam(teamName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDespawn() {
|
||||
if (npc.getEntity() == null)
|
||||
return;
|
||||
Util.removeTeamFor(npc,
|
||||
npc.getEntity() instanceof Player ? npc.getEntity().getName() : npc.getUniqueId().toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSpawn() {
|
||||
changed = true;
|
||||
}
|
||||
|
||||
public void removeTag(String tag) {
|
||||
tags.remove(tag);
|
||||
}
|
||||
|
||||
public void setColor(ChatColor color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
public static void onPlayerJoin(PlayerJoinEvent event) {
|
||||
for (Player npcPlayer : PlayerUpdateTask.getCurrentPlayerNPCs()) {
|
||||
NPC npc = ((NPCHolder) npcPlayer).getNPC();
|
||||
|
@ -219,7 +219,7 @@ public class ShopTrait extends Trait {
|
||||
}
|
||||
}
|
||||
|
||||
@Menu(title = "NPC Shop Item Editor", type = InventoryType.CHEST, dimensions = { 5, 9 })
|
||||
@Menu(title = "NPC Shop Item Editor", type = InventoryType.CHEST, dimensions = { 6, 9 })
|
||||
@MenuSlot(slot = { 0, 4 }, material = Material.DISPENSER, amount = 1, title = "Place display item below")
|
||||
public static class NPCShopItemEditor extends InventoryMenuPage {
|
||||
private final Consumer<NPCShopItem> callback;
|
||||
|
@ -17,7 +17,6 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.scoreboard.Scoreboard;
|
||||
import org.bukkit.scoreboard.Team;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
@ -101,23 +100,6 @@ public class Util {
|
||||
NMS.look(entity, to, headOnly, immediate);
|
||||
}
|
||||
|
||||
public static void generateTeamFor(NPC npc, String name, String teamName) {
|
||||
Scoreboard scoreboard = getDummyScoreboard();
|
||||
Team team = scoreboard.getTeam(teamName);
|
||||
int mode = 2;
|
||||
if (team == null) {
|
||||
team = scoreboard.registerNewTeam(teamName);
|
||||
if (npc.requiresNameHologram()
|
||||
|| npc.data().<Object> get(NPC.Metadata.NAMEPLATE_VISIBLE, true).toString().equals("false")) {
|
||||
NMS.setTeamNameTagVisible(team, false);
|
||||
}
|
||||
mode = 0;
|
||||
}
|
||||
team.addEntry(name);
|
||||
npc.data().set(NPC.SCOREBOARD_FAKE_TEAM_NAME_METADATA, teamName);
|
||||
sendTeamPacketToOnlinePlayers(team, mode);
|
||||
}
|
||||
|
||||
public static Location getCenterLocation(Block block) {
|
||||
Location bloc = block.getLocation(AT_LOCATION);
|
||||
Location center = new Location(bloc.getWorld(), bloc.getBlockX() + 0.5, bloc.getBlockY(),
|
||||
@ -314,34 +296,6 @@ public class Util {
|
||||
to.getBlockZ(), (int) to.getYaw(), (int) to.getPitch());
|
||||
}
|
||||
|
||||
public static void removeTeamFor(NPC npc, String name) {
|
||||
String teamName = npc.data().get(NPC.SCOREBOARD_FAKE_TEAM_NAME_METADATA, "");
|
||||
if (teamName.isEmpty())
|
||||
return;
|
||||
Team team = getDummyScoreboard().getTeam(teamName);
|
||||
npc.data().remove(NPC.SCOREBOARD_FAKE_TEAM_NAME_METADATA);
|
||||
if (team == null)
|
||||
return;
|
||||
if (team.hasEntry(name)) {
|
||||
if (team.getSize() == 1) {
|
||||
sendTeamPacketToOnlinePlayers(team, 1);
|
||||
team.unregister();
|
||||
} else {
|
||||
team.removeEntry(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mode
|
||||
* 0 for create, 1 for remove, 2 for update
|
||||
*/
|
||||
public static void sendTeamPacketToOnlinePlayers(Team team, int mode) {
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
NMS.sendTeamPacket(player, team, mode);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the entity's yaw and pitch directly including head yaw.
|
||||
*/
|
||||
|
@ -16,6 +16,7 @@ import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.npc.AbstractEntityController;
|
||||
import net.citizensnpcs.npc.skin.Skin;
|
||||
import net.citizensnpcs.npc.skin.SkinnableEntity;
|
||||
import net.citizensnpcs.trait.ScoreboardTrait;
|
||||
import net.citizensnpcs.util.NMS;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_10_R1.PlayerInteractManager;
|
||||
@ -46,7 +47,7 @@ public class HumanController extends AbstractEntityController {
|
||||
}
|
||||
|
||||
if (Setting.USE_SCOREBOARD_TEAMS.asBoolean()) {
|
||||
Util.generateTeamFor(npc, name, teamName);
|
||||
npc.getOrAddTrait(ScoreboardTrait.class).createTeam(name);
|
||||
}
|
||||
|
||||
final GameProfile profile = new GameProfile(uuid, name);
|
||||
|
@ -14,8 +14,8 @@ import net.citizensnpcs.Settings.Setting;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.nms.v1_10_R1.util.NMSImpl;
|
||||
import net.citizensnpcs.npc.AbstractEntityController;
|
||||
import net.citizensnpcs.trait.ScoreboardTrait;
|
||||
import net.citizensnpcs.util.NMS;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_10_R1.EntityInsentient;
|
||||
import net.minecraft.server.v1_10_R1.World;
|
||||
|
||||
@ -48,7 +48,7 @@ public abstract class MobEntityController extends AbstractEntityController {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (Setting.USE_SCOREBOARD_TEAMS.asBoolean()) {
|
||||
Util.generateTeamFor(npc, npc.getUniqueId().toString(), Util.getTeamName(npc.getUniqueId()));
|
||||
npc.getOrAddTrait(ScoreboardTrait.class).createTeam(npc.getUniqueId().toString());
|
||||
}
|
||||
return entity.getBukkitEntity();
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.npc.AbstractEntityController;
|
||||
import net.citizensnpcs.npc.skin.Skin;
|
||||
import net.citizensnpcs.npc.skin.SkinnableEntity;
|
||||
import net.citizensnpcs.trait.ScoreboardTrait;
|
||||
import net.citizensnpcs.util.NMS;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_11_R1.PlayerInteractManager;
|
||||
@ -46,7 +47,7 @@ public class HumanController extends AbstractEntityController {
|
||||
}
|
||||
|
||||
if (Setting.USE_SCOREBOARD_TEAMS.asBoolean()) {
|
||||
Util.generateTeamFor(npc, name, teamName);
|
||||
npc.getOrAddTrait(ScoreboardTrait.class).createTeam(name);
|
||||
}
|
||||
|
||||
final GameProfile profile = new GameProfile(uuid, name);
|
||||
|
@ -14,8 +14,8 @@ import net.citizensnpcs.Settings.Setting;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.nms.v1_11_R1.util.NMSImpl;
|
||||
import net.citizensnpcs.npc.AbstractEntityController;
|
||||
import net.citizensnpcs.trait.ScoreboardTrait;
|
||||
import net.citizensnpcs.util.NMS;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_11_R1.EntityInsentient;
|
||||
import net.minecraft.server.v1_11_R1.World;
|
||||
|
||||
@ -48,7 +48,7 @@ public abstract class MobEntityController extends AbstractEntityController {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (Setting.USE_SCOREBOARD_TEAMS.asBoolean()) {
|
||||
Util.generateTeamFor(npc, npc.getUniqueId().toString(), Util.getTeamName(npc.getUniqueId()));
|
||||
npc.getOrAddTrait(ScoreboardTrait.class).createTeam(npc.getUniqueId().toString());
|
||||
}
|
||||
return entity.getBukkitEntity();
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.npc.AbstractEntityController;
|
||||
import net.citizensnpcs.npc.skin.Skin;
|
||||
import net.citizensnpcs.npc.skin.SkinnableEntity;
|
||||
import net.citizensnpcs.trait.ScoreboardTrait;
|
||||
import net.citizensnpcs.util.NMS;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_12_R1.PlayerInteractManager;
|
||||
@ -46,7 +47,7 @@ public class HumanController extends AbstractEntityController {
|
||||
}
|
||||
|
||||
if (Setting.USE_SCOREBOARD_TEAMS.asBoolean()) {
|
||||
Util.generateTeamFor(npc, name, teamName);
|
||||
npc.getOrAddTrait(ScoreboardTrait.class).createTeam(name);
|
||||
}
|
||||
|
||||
final GameProfile profile = new GameProfile(uuid, name);
|
||||
|
@ -14,8 +14,8 @@ import net.citizensnpcs.Settings.Setting;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.nms.v1_12_R1.util.NMSImpl;
|
||||
import net.citizensnpcs.npc.AbstractEntityController;
|
||||
import net.citizensnpcs.trait.ScoreboardTrait;
|
||||
import net.citizensnpcs.util.NMS;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_12_R1.EntityInsentient;
|
||||
import net.minecraft.server.v1_12_R1.World;
|
||||
|
||||
@ -49,7 +49,7 @@ public abstract class MobEntityController extends AbstractEntityController {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (Setting.USE_SCOREBOARD_TEAMS.asBoolean()) {
|
||||
Util.generateTeamFor(npc, npc.getUniqueId().toString(), Util.getTeamName(npc.getUniqueId()));
|
||||
npc.getOrAddTrait(ScoreboardTrait.class).createTeam(npc.getUniqueId().toString());
|
||||
}
|
||||
return entity.getBukkitEntity();
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.npc.AbstractEntityController;
|
||||
import net.citizensnpcs.npc.skin.Skin;
|
||||
import net.citizensnpcs.npc.skin.SkinnableEntity;
|
||||
import net.citizensnpcs.trait.ScoreboardTrait;
|
||||
import net.citizensnpcs.util.NMS;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_13_R2.PlayerInteractManager;
|
||||
@ -46,7 +47,7 @@ public class HumanController extends AbstractEntityController {
|
||||
}
|
||||
|
||||
if (Setting.USE_SCOREBOARD_TEAMS.asBoolean()) {
|
||||
Util.generateTeamFor(npc, name, teamName);
|
||||
npc.getOrAddTrait(ScoreboardTrait.class).createTeam(name);
|
||||
}
|
||||
|
||||
final GameProfile profile = new GameProfile(uuid, name);
|
||||
|
@ -14,8 +14,8 @@ import net.citizensnpcs.Settings.Setting;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.nms.v1_13_R2.util.NMSImpl;
|
||||
import net.citizensnpcs.npc.AbstractEntityController;
|
||||
import net.citizensnpcs.trait.ScoreboardTrait;
|
||||
import net.citizensnpcs.util.NMS;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_13_R2.EntityInsentient;
|
||||
import net.minecraft.server.v1_13_R2.World;
|
||||
|
||||
@ -48,7 +48,7 @@ public abstract class MobEntityController extends AbstractEntityController {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (Setting.USE_SCOREBOARD_TEAMS.asBoolean()) {
|
||||
Util.generateTeamFor(npc, npc.getUniqueId().toString(), Util.getTeamName(npc.getUniqueId()));
|
||||
npc.getOrAddTrait(ScoreboardTrait.class).createTeam(npc.getUniqueId().toString());
|
||||
}
|
||||
return entity.getBukkitEntity();
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.npc.AbstractEntityController;
|
||||
import net.citizensnpcs.npc.skin.Skin;
|
||||
import net.citizensnpcs.npc.skin.SkinnableEntity;
|
||||
import net.citizensnpcs.trait.ScoreboardTrait;
|
||||
import net.citizensnpcs.util.NMS;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_14_R1.PlayerInteractManager;
|
||||
@ -46,7 +47,7 @@ public class HumanController extends AbstractEntityController {
|
||||
}
|
||||
|
||||
if (Setting.USE_SCOREBOARD_TEAMS.asBoolean()) {
|
||||
Util.generateTeamFor(npc, name, teamName);
|
||||
npc.getOrAddTrait(ScoreboardTrait.class).createTeam(name);
|
||||
}
|
||||
|
||||
final GameProfile profile = new GameProfile(uuid, name);
|
||||
|
@ -14,8 +14,8 @@ import net.citizensnpcs.Settings.Setting;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.nms.v1_14_R1.util.NMSImpl;
|
||||
import net.citizensnpcs.npc.AbstractEntityController;
|
||||
import net.citizensnpcs.trait.ScoreboardTrait;
|
||||
import net.citizensnpcs.util.NMS;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_14_R1.EntityInsentient;
|
||||
import net.minecraft.server.v1_14_R1.EntityTypes;
|
||||
import net.minecraft.server.v1_14_R1.World;
|
||||
@ -50,7 +50,7 @@ public abstract class MobEntityController extends AbstractEntityController {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (Setting.USE_SCOREBOARD_TEAMS.asBoolean()) {
|
||||
Util.generateTeamFor(npc, npc.getUniqueId().toString(), Util.getTeamName(npc.getUniqueId()));
|
||||
npc.getOrAddTrait(ScoreboardTrait.class).createTeam(npc.getUniqueId().toString());
|
||||
}
|
||||
return entity.getBukkitEntity();
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.npc.AbstractEntityController;
|
||||
import net.citizensnpcs.npc.skin.Skin;
|
||||
import net.citizensnpcs.npc.skin.SkinnableEntity;
|
||||
import net.citizensnpcs.trait.ScoreboardTrait;
|
||||
import net.citizensnpcs.util.NMS;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_15_R1.PlayerInteractManager;
|
||||
@ -46,7 +47,7 @@ public class HumanController extends AbstractEntityController {
|
||||
}
|
||||
|
||||
if (Setting.USE_SCOREBOARD_TEAMS.asBoolean()) {
|
||||
Util.generateTeamFor(npc, name, teamName);
|
||||
npc.getOrAddTrait(ScoreboardTrait.class).createTeam(name);
|
||||
}
|
||||
|
||||
final GameProfile profile = new GameProfile(uuid, name);
|
||||
|
@ -14,8 +14,8 @@ import net.citizensnpcs.Settings.Setting;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.nms.v1_15_R1.util.NMSImpl;
|
||||
import net.citizensnpcs.npc.AbstractEntityController;
|
||||
import net.citizensnpcs.trait.ScoreboardTrait;
|
||||
import net.citizensnpcs.util.NMS;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_15_R1.EntityInsentient;
|
||||
import net.minecraft.server.v1_15_R1.EntityTypes;
|
||||
import net.minecraft.server.v1_15_R1.World;
|
||||
@ -51,7 +51,7 @@ public abstract class MobEntityController extends AbstractEntityController {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (Setting.USE_SCOREBOARD_TEAMS.asBoolean()) {
|
||||
Util.generateTeamFor(npc, npc.getUniqueId().toString(), Util.getTeamName(npc.getUniqueId()));
|
||||
npc.getOrAddTrait(ScoreboardTrait.class).createTeam(npc.getUniqueId().toString());
|
||||
}
|
||||
return entity.getBukkitEntity();
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.npc.AbstractEntityController;
|
||||
import net.citizensnpcs.npc.skin.Skin;
|
||||
import net.citizensnpcs.npc.skin.SkinnableEntity;
|
||||
import net.citizensnpcs.trait.ScoreboardTrait;
|
||||
import net.citizensnpcs.util.NMS;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_16_R3.PlayerInteractManager;
|
||||
@ -45,7 +46,7 @@ public class HumanController extends AbstractEntityController {
|
||||
}
|
||||
|
||||
if (Setting.USE_SCOREBOARD_TEAMS.asBoolean()) {
|
||||
Util.generateTeamFor(npc, name, teamName);
|
||||
npc.getOrAddTrait(ScoreboardTrait.class).createTeam(name);
|
||||
}
|
||||
|
||||
final GameProfile profile = new GameProfile(uuid, name);
|
||||
|
@ -14,8 +14,8 @@ import net.citizensnpcs.Settings.Setting;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.nms.v1_16_R3.util.NMSImpl;
|
||||
import net.citizensnpcs.npc.AbstractEntityController;
|
||||
import net.citizensnpcs.trait.ScoreboardTrait;
|
||||
import net.citizensnpcs.util.NMS;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_16_R3.EntityInsentient;
|
||||
import net.minecraft.server.v1_16_R3.EntityTypes;
|
||||
import net.minecraft.server.v1_16_R3.World;
|
||||
@ -51,7 +51,7 @@ public abstract class MobEntityController extends AbstractEntityController {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (Setting.USE_SCOREBOARD_TEAMS.asBoolean()) {
|
||||
Util.generateTeamFor(npc, npc.getUniqueId().toString(), Util.getTeamName(npc.getUniqueId()));
|
||||
npc.getOrAddTrait(ScoreboardTrait.class).createTeam(npc.getUniqueId().toString());
|
||||
}
|
||||
return entity.getBukkitEntity();
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.npc.AbstractEntityController;
|
||||
import net.citizensnpcs.npc.skin.Skin;
|
||||
import net.citizensnpcs.npc.skin.SkinnableEntity;
|
||||
import net.citizensnpcs.trait.ScoreboardTrait;
|
||||
import net.citizensnpcs.util.NMS;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
@ -45,7 +46,7 @@ public class HumanController extends AbstractEntityController {
|
||||
}
|
||||
|
||||
if (Setting.USE_SCOREBOARD_TEAMS.asBoolean()) {
|
||||
Util.generateTeamFor(npc, name, teamName);
|
||||
npc.getOrAddTrait(ScoreboardTrait.class).createTeam(teamName);
|
||||
}
|
||||
|
||||
final GameProfile profile = new GameProfile(uuid, name);
|
||||
|
@ -13,7 +13,7 @@ import net.citizensnpcs.Settings.Setting;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.nms.v1_17_R1.util.NMSImpl;
|
||||
import net.citizensnpcs.npc.AbstractEntityController;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.citizensnpcs.trait.ScoreboardTrait;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.Mob;
|
||||
import net.minecraft.world.level.Level;
|
||||
@ -43,7 +43,7 @@ public abstract class MobEntityController extends AbstractEntityController {
|
||||
}
|
||||
entity.setUUID(npc.getUniqueId());
|
||||
if (Setting.USE_SCOREBOARD_TEAMS.asBoolean()) {
|
||||
Util.generateTeamFor(npc, npc.getUniqueId().toString(), Util.getTeamName(npc.getUniqueId()));
|
||||
npc.getOrAddTrait(ScoreboardTrait.class).createTeam(npc.getUniqueId().toString());
|
||||
}
|
||||
return entity.getBukkitEntity();
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.npc.AbstractEntityController;
|
||||
import net.citizensnpcs.npc.skin.Skin;
|
||||
import net.citizensnpcs.npc.skin.SkinnableEntity;
|
||||
import net.citizensnpcs.trait.ScoreboardTrait;
|
||||
import net.citizensnpcs.util.NMS;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
@ -45,7 +46,7 @@ public class HumanController extends AbstractEntityController {
|
||||
}
|
||||
|
||||
if (Setting.USE_SCOREBOARD_TEAMS.asBoolean()) {
|
||||
Util.generateTeamFor(npc, name, teamName);
|
||||
npc.getOrAddTrait(ScoreboardTrait.class).createTeam(name);
|
||||
}
|
||||
|
||||
final GameProfile profile = new GameProfile(uuid, name);
|
||||
|
@ -13,7 +13,7 @@ import net.citizensnpcs.Settings.Setting;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.nms.v1_18_R2.util.NMSImpl;
|
||||
import net.citizensnpcs.npc.AbstractEntityController;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.citizensnpcs.trait.ScoreboardTrait;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.Mob;
|
||||
import net.minecraft.world.level.Level;
|
||||
@ -45,7 +45,7 @@ public abstract class MobEntityController extends AbstractEntityController {
|
||||
entity.setUUID(npc.getUniqueId());
|
||||
|
||||
if (Setting.USE_SCOREBOARD_TEAMS.asBoolean()) {
|
||||
Util.generateTeamFor(npc, npc.getUniqueId().toString(), Util.getTeamName(npc.getUniqueId()));
|
||||
npc.getOrAddTrait(ScoreboardTrait.class).createTeam(npc.getUniqueId().toString());
|
||||
}
|
||||
return entity.getBukkitEntity();
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.npc.AbstractEntityController;
|
||||
import net.citizensnpcs.npc.skin.Skin;
|
||||
import net.citizensnpcs.npc.skin.SkinnableEntity;
|
||||
import net.citizensnpcs.trait.ScoreboardTrait;
|
||||
import net.citizensnpcs.util.NMS;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
@ -45,7 +46,7 @@ public class HumanController extends AbstractEntityController {
|
||||
}
|
||||
|
||||
if (Setting.USE_SCOREBOARD_TEAMS.asBoolean()) {
|
||||
Util.generateTeamFor(npc, name, teamName);
|
||||
npc.getOrAddTrait(ScoreboardTrait.class).createTeam(name);
|
||||
}
|
||||
|
||||
final GameProfile profile = new GameProfile(uuid, name);
|
||||
|
@ -13,7 +13,7 @@ import net.citizensnpcs.Settings.Setting;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.nms.v1_19_R1.util.NMSImpl;
|
||||
import net.citizensnpcs.npc.AbstractEntityController;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.citizensnpcs.trait.ScoreboardTrait;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.Mob;
|
||||
import net.minecraft.world.level.Level;
|
||||
@ -45,7 +45,7 @@ public abstract class MobEntityController extends AbstractEntityController {
|
||||
entity.setUUID(npc.getUniqueId());
|
||||
|
||||
if (Setting.USE_SCOREBOARD_TEAMS.asBoolean()) {
|
||||
Util.generateTeamFor(npc, npc.getUniqueId().toString(), Util.getTeamName(npc.getUniqueId()));
|
||||
npc.getOrAddTrait(ScoreboardTrait.class).createTeam(npc.getUniqueId().toString());
|
||||
}
|
||||
return entity.getBukkitEntity();
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.npc.AbstractEntityController;
|
||||
import net.citizensnpcs.npc.skin.Skin;
|
||||
import net.citizensnpcs.npc.skin.SkinnableEntity;
|
||||
import net.citizensnpcs.trait.ScoreboardTrait;
|
||||
import net.citizensnpcs.util.NMS;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_8_R3.PlayerInteractManager;
|
||||
@ -46,7 +47,7 @@ public class HumanController extends AbstractEntityController {
|
||||
}
|
||||
|
||||
if (Setting.USE_SCOREBOARD_TEAMS.asBoolean()) {
|
||||
Util.generateTeamFor(npc, name, teamName);
|
||||
npc.getOrAddTrait(ScoreboardTrait.class).createTeam(name);
|
||||
}
|
||||
|
||||
final GameProfile profile = new GameProfile(uuid, name);
|
||||
|
@ -14,8 +14,8 @@ import net.citizensnpcs.Settings.Setting;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.nms.v1_8_R3.util.NMSImpl;
|
||||
import net.citizensnpcs.npc.AbstractEntityController;
|
||||
import net.citizensnpcs.trait.ScoreboardTrait;
|
||||
import net.citizensnpcs.util.NMS;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_8_R3.EntityInsentient;
|
||||
import net.minecraft.server.v1_8_R3.World;
|
||||
|
||||
@ -48,7 +48,7 @@ public abstract class MobEntityController extends AbstractEntityController {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (Setting.USE_SCOREBOARD_TEAMS.asBoolean()) {
|
||||
Util.generateTeamFor(npc, npc.getUniqueId().toString(), Util.getTeamName(npc.getUniqueId()));
|
||||
npc.getOrAddTrait(ScoreboardTrait.class).createTeam(npc.getUniqueId().toString());
|
||||
}
|
||||
return entity.getBukkitEntity();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user