mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-22 18:45:29 +01:00
added names
This commit is contained in:
parent
ffd078a3f8
commit
a3dd54757e
Binary file not shown.
@ -14,17 +14,20 @@ import net.citizensnpcs.api.npc.trait.trait.LocationTrait;
|
|||||||
import net.citizensnpcs.resources.lib.CraftNPC;
|
import net.citizensnpcs.resources.lib.CraftNPC;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
|
||||||
public class CitizensNPC implements NPC {
|
public class CitizensNPC implements NPC {
|
||||||
private final int id;
|
private final int id;
|
||||||
private final Set<Trait> traits = new HashSet<Trait>();
|
|
||||||
private Character character = null;
|
private Character character = null;
|
||||||
|
private final Set<Trait> traits = new HashSet<Trait>();
|
||||||
|
private String name;
|
||||||
private CraftNPC mcEntity;
|
private CraftNPC mcEntity;
|
||||||
private boolean spawned;
|
private boolean spawned;
|
||||||
private final CitizensNPCManager manager;
|
private final CitizensNPCManager manager;
|
||||||
|
|
||||||
protected CitizensNPC(Character character, Trait... traits) {
|
protected CitizensNPC(String name, Character character, Trait... traits) {
|
||||||
|
this.name = name;
|
||||||
this.character = character;
|
this.character = character;
|
||||||
for (Trait trait : traits) {
|
for (Trait trait : traits) {
|
||||||
this.traits.add(trait);
|
this.traits.add(trait);
|
||||||
@ -33,6 +36,21 @@ public class CitizensNPC implements NPC {
|
|||||||
id = manager.getUniqueID();
|
id = manager.getUniqueID();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getFullName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return ChatColor.stripColor(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addTrait(Trait trait) {
|
public void addTrait(Trait trait) {
|
||||||
if (!hasTrait(trait))
|
if (!hasTrait(trait))
|
||||||
|
@ -29,18 +29,18 @@ public class CitizensNPCManager implements NPCManager {
|
|||||||
private Map<Integer, NPC> byID = new HashMap<Integer, NPC>();
|
private Map<Integer, NPC> byID = new HashMap<Integer, NPC>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NPC createNPC() {
|
public NPC createNPC(String name) {
|
||||||
return createNPC(null);
|
return createNPC(name, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NPC createNPC(Character character) {
|
public NPC createNPC(String name, Character character) {
|
||||||
return createNPC(character);
|
return createNPC(name, character);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NPC createNPC(Character character, Trait... traits) {
|
public NPC createNPC(String name, Character character, Trait... traits) {
|
||||||
CitizensNPC npc = new CitizensNPC(character, traits);
|
CitizensNPC npc = new CitizensNPC(name, character, traits);
|
||||||
byID.put(npc.getId(), npc);
|
byID.put(npc.getId(), npc);
|
||||||
return npc;
|
return npc;
|
||||||
}
|
}
|
||||||
@ -100,7 +100,8 @@ public class CitizensNPCManager implements NPCManager {
|
|||||||
public CraftNPC spawn(NPC npc) {
|
public CraftNPC spawn(NPC npc) {
|
||||||
Location loc = ((LocationTrait) npc.getTrait("location")).getLocation();
|
Location loc = ((LocationTrait) npc.getTrait("location")).getLocation();
|
||||||
WorldServer ws = getWorldServer(loc.getWorld());
|
WorldServer ws = getWorldServer(loc.getWorld());
|
||||||
CraftNPC mcEntity = new CraftNPC(getMinecraftServer(ws.getServer()), ws, "", new ItemInWorldManager(ws));
|
CraftNPC mcEntity = new CraftNPC(getMinecraftServer(ws.getServer()), ws, npc.getFullName(),
|
||||||
|
new ItemInWorldManager(ws));
|
||||||
mcEntity.setPositionRotation(loc.getX(), loc.getY(), loc.getZ(), loc.getYaw(), loc.getPitch());
|
mcEntity.setPositionRotation(loc.getX(), loc.getY(), loc.getZ(), loc.getYaw(), loc.getPitch());
|
||||||
ws.addEntity(mcEntity);
|
ws.addEntity(mcEntity);
|
||||||
ws.players.remove(mcEntity);
|
ws.players.remove(mcEntity);
|
||||||
|
Loading…
Reference in New Issue
Block a user