mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-27 05:05:20 +01:00
Change /npc skin
This commit is contained in:
parent
5184efa09c
commit
54bd62c414
@ -48,7 +48,6 @@ import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.EntityDeathEvent;
|
||||
import org.bukkit.event.entity.EntityTargetEvent;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
import org.bukkit.event.player.PlayerChangedWorldEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
@ -212,14 +211,6 @@ public class EventListen implements Listener {
|
||||
}
|
||||
}, delay + 2);
|
||||
}
|
||||
|
||||
if (event instanceof PlayerDeathEvent && !npc.data().get(NPC.PLAYER_SKIN_NAME_METADATA, "").isEmpty()) {
|
||||
String skinName = npc.data().get(NPC.PLAYER_SKIN_NAME_METADATA, "");
|
||||
PlayerDeathEvent pde = (PlayerDeathEvent) event;
|
||||
pde.setDeathMessage(pde.getDeathMessage().replace(" " + skinName, " " + npc.getFullName())
|
||||
.replace(skinName + " ", npc.getFullName() + " "));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
|
@ -66,6 +66,14 @@ public class SkeletonController extends MobEntityController {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bm() {
|
||||
super.bm();
|
||||
if (npc != null) {
|
||||
npc.update();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean bN() {
|
||||
if (npc == null)
|
||||
@ -79,13 +87,6 @@ public class SkeletonController extends MobEntityController {
|
||||
return false; // shouldLeash
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bm() {
|
||||
super.bm();
|
||||
if (npc != null)
|
||||
npc.update();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collide(net.minecraft.server.v1_7_R2.Entity entity) {
|
||||
// this method is called by both the entities involved - cancelling
|
||||
|
@ -35,8 +35,9 @@ public class PlayerSkin extends Trait {
|
||||
|
||||
public String getSkinName() {
|
||||
String skin = npc.data().get(NPC.PLAYER_SKIN_NAME_METADATA, "");
|
||||
if (skin.isEmpty())
|
||||
if (skin.isEmpty()) {
|
||||
skin = npc.getFullName();
|
||||
}
|
||||
return skin;
|
||||
}
|
||||
|
||||
@ -63,7 +64,7 @@ public class PlayerSkin extends Trait {
|
||||
npcEntity.data().set(NPC.HURT_SOUND_METADATA, "");
|
||||
npcEntity.data().set(NPC.SHOULD_SAVE_METADATA, false);
|
||||
npcEntity.spawn(npc.getStoredLocation());
|
||||
if (name.isEmpty() || !(npcEntity.getEntity() instanceof Slime)) {
|
||||
if (name.isEmpty()) {
|
||||
((LivingEntity) npcEntity.getEntity()).addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 20
|
||||
* 60 * 60 * 24 * 7, 1));
|
||||
} else {
|
||||
@ -99,6 +100,16 @@ public class PlayerSkin extends Trait {
|
||||
|
||||
nameCarriers.add(nameCarrier);
|
||||
}
|
||||
for (Entity entity : nameCarriers) {
|
||||
if (entity instanceof LivingEntity) {
|
||||
LivingEntity le = (LivingEntity) entity;
|
||||
le.setRemainingAir(20);
|
||||
if (!le.hasPotionEffect(PotionEffectType.INVISIBILITY)) {
|
||||
((LivingEntity) entity).addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 20 * 60
|
||||
* 60 * 24 * 7, 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setSkinName(String name) {
|
||||
|
Loading…
Reference in New Issue
Block a user