Search in sources :

Example 6 with SkinnableEntity

use of net.citizensnpcs.npc.skin.SkinnableEntity in project Citizens2 by CitizensDev.

the class HumanController method remove.

@Override
public void remove() {
    Player entity = getBukkitEntity();
    if (entity != null) {
        NMS.removeFromWorld(entity);
        SkinnableEntity npc = entity instanceof SkinnableEntity ? (SkinnableEntity) entity : null;
        npc.getSkinTracker().onRemoveNPC();
    }
    super.remove();
}
Also used : Player(org.bukkit.entity.Player) SkinnableEntity(net.citizensnpcs.npc.skin.SkinnableEntity)

Example 7 with SkinnableEntity

use of net.citizensnpcs.npc.skin.SkinnableEntity in project Citizens2 by CitizensDev.

the class NPCCommands method skin.

@Command(aliases = { "npc" }, usage = "skin (-c -l(atest)) [name]", desc = "Sets an NPC's skin name. Use -l to set the skin to always update to the latest", modifiers = { "skin" }, min = 1, max = 2, flags = "cl", permission = "citizens.npc.skin")
@Requirements(types = EntityType.PLAYER, selected = true, ownership = true)
public void skin(final CommandContext args, final CommandSender sender, final NPC npc) throws CommandException {
    String skinName = npc.getName();
    if (args.hasFlag('c')) {
        npc.data().remove(NPC.PLAYER_SKIN_UUID_METADATA);
    } else {
        if (args.argsLength() != 2)
            throw new CommandException(Messages.SKIN_REQUIRED);
        npc.data().setPersistent(NPC.PLAYER_SKIN_UUID_METADATA, args.getString(1));
        if (args.hasFlag('l')) {
            npc.data().setPersistent(NPC.PLAYER_SKIN_USE_LATEST, true);
        }
        skinName = args.getString(1);
    }
    Messaging.sendTr(sender, Messages.SKIN_SET, npc.getName(), skinName);
    if (npc.isSpawned()) {
        SkinnableEntity skinnable = npc.getEntity() instanceof SkinnableEntity ? (SkinnableEntity) npc.getEntity() : null;
        if (skinnable != null) {
            skinnable.setSkinName(skinName, true);
        }
    }
}
Also used : SkinnableEntity(net.citizensnpcs.npc.skin.SkinnableEntity) ServerCommandException(net.citizensnpcs.api.command.exception.ServerCommandException) CommandException(net.citizensnpcs.api.command.exception.CommandException) Command(net.citizensnpcs.api.command.Command) Requirements(net.citizensnpcs.api.command.Requirements)

Example 8 with SkinnableEntity

use of net.citizensnpcs.npc.skin.SkinnableEntity in project Citizens2 by CitizensDev.

the class HumanController method remove.

@Override
public void remove() {
    Player entity = getBukkitEntity();
    if (entity != null) {
        NMS.removeFromWorld(entity);
        SkinnableEntity npc = entity instanceof SkinnableEntity ? (SkinnableEntity) entity : null;
        npc.getSkinTracker().onRemoveNPC();
    }
    super.remove();
}
Also used : Player(org.bukkit.entity.Player) SkinnableEntity(net.citizensnpcs.npc.skin.SkinnableEntity)

Example 9 with SkinnableEntity

use of net.citizensnpcs.npc.skin.SkinnableEntity in project Citizens2 by CitizensDev.

the class SkinLayers method setFlags.

private void setFlags() {
    if (!npc.isSpawned())
        return;
    SkinnableEntity skinnable = npc.getEntity() instanceof SkinnableEntity ? (SkinnableEntity) npc.getEntity() : null;
    if (skinnable == null)
        return;
    int flags = 0xFF;
    for (Layer layer : Layer.values()) {
        if (!isVisible(layer)) {
            flags &= ~layer.flag;
        }
    }
    skinnable.setSkinFlags((byte) flags);
}
Also used : SkinnableEntity(net.citizensnpcs.npc.skin.SkinnableEntity)

Example 10 with SkinnableEntity

use of net.citizensnpcs.npc.skin.SkinnableEntity in project Citizens2 by CitizensDev.

the class HumanController method remove.

@Override
public void remove() {
    Player entity = getBukkitEntity();
    if (entity != null) {
        NMS.removeFromWorld(entity);
        SkinnableEntity npc = entity instanceof SkinnableEntity ? (SkinnableEntity) entity : null;
        npc.getSkinTracker().onRemoveNPC();
    }
    super.remove();
}
Also used : Player(org.bukkit.entity.Player) SkinnableEntity(net.citizensnpcs.npc.skin.SkinnableEntity)

Aggregations

SkinnableEntity (net.citizensnpcs.npc.skin.SkinnableEntity)15 Player (org.bukkit.entity.Player)9 EntityPlayer (net.minecraft.server.v1_10_R1.EntityPlayer)2 EntityPlayer (net.minecraft.server.v1_11_R1.EntityPlayer)2 EntityPlayer (net.minecraft.server.v1_12_R1.EntityPlayer)2 EntityPlayer (net.minecraft.server.v1_8_R3.EntityPlayer)2 NPCNeedsRespawnEvent (net.citizensnpcs.NPCNeedsRespawnEvent)1 Command (net.citizensnpcs.api.command.Command)1 Requirements (net.citizensnpcs.api.command.Requirements)1 CommandException (net.citizensnpcs.api.command.exception.CommandException)1 ServerCommandException (net.citizensnpcs.api.command.exception.ServerCommandException)1 NPCSpawnEvent (net.citizensnpcs.api.event.NPCSpawnEvent)1 Trait (net.citizensnpcs.api.trait.Trait)1 Spawned (net.citizensnpcs.api.trait.trait.Spawned)1 EntityHumanNPC (net.citizensnpcs.nms.v1_10_R1.entity.EntityHumanNPC)1 EntityHumanNPC (net.citizensnpcs.nms.v1_11_R1.entity.EntityHumanNPC)1 EntityHumanNPC (net.citizensnpcs.nms.v1_12_R1.entity.EntityHumanNPC)1 EntityHumanNPC (net.citizensnpcs.nms.v1_8_R3.entity.EntityHumanNPC)1 CurrentLocation (net.citizensnpcs.trait.CurrentLocation)1 Entity (net.minecraft.server.v1_10_R1.Entity)1