mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-12-23 01:27:33 +01:00
Add -h option to /npc name
This commit is contained in:
parent
58c5fc748e
commit
2f7e4ea786
@ -27,7 +27,6 @@ import org.bukkit.entity.Horse;
|
||||
import org.bukkit.entity.Horse.Color;
|
||||
import org.bukkit.entity.Horse.Style;
|
||||
import org.bukkit.entity.ItemFrame;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Ocelot;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Rabbit;
|
||||
@ -964,12 +963,17 @@ public class NPCCommands {
|
||||
desc = "Toggle nameplate visibility",
|
||||
min = 1,
|
||||
max = 1,
|
||||
flags = "h",
|
||||
permission = "citizens.npc.name")
|
||||
@Requirements(selected = true, ownership = true, livingEntity = true)
|
||||
public void name(CommandContext args, CommandSender sender, NPC npc) {
|
||||
LivingEntity entity = (LivingEntity) npc.getEntity();
|
||||
entity.setCustomNameVisible(!entity.isCustomNameVisible());
|
||||
npc.data().setPersistent(NPC.NAMEPLATE_VISIBLE_METADATA, entity.isCustomNameVisible());
|
||||
String old = npc.data().<Object> get(NPC.NAMEPLATE_VISIBLE_METADATA, true).toString();
|
||||
if (args.hasFlag('h')) {
|
||||
old = "hover";
|
||||
} else {
|
||||
old = old.equals("hover") ? "true" : "" + !Boolean.parseBoolean(old);
|
||||
}
|
||||
npc.data().setPersistent(NPC.NAMEPLATE_VISIBLE_METADATA, old);
|
||||
Messaging.sendTr(sender, Messages.NAMEPLATE_VISIBILITY_TOGGLED);
|
||||
}
|
||||
|
||||
|
@ -279,7 +279,8 @@ public class CitizensNPC extends AbstractNPC {
|
||||
updateCounter = 0;
|
||||
if (getEntity() instanceof LivingEntity) {
|
||||
OptionStatus nameVisibility = OptionStatus.NEVER;
|
||||
if (!getEntity().isCustomNameVisible()) {
|
||||
if (!getEntity().isCustomNameVisible()
|
||||
&& !data().<Object> get(NPC.NAMEPLATE_VISIBLE_METADATA, true).toString().equals("hover")) {
|
||||
getEntity().setCustomName("");
|
||||
} else {
|
||||
nameVisibility = OptionStatus.ALWAYS;
|
||||
@ -311,8 +312,12 @@ public class CitizensNPC extends AbstractNPC {
|
||||
}
|
||||
|
||||
if (getEntity() instanceof LivingEntity) {
|
||||
boolean nameplateVisible = data().get(NPC.NAMEPLATE_VISIBLE_METADATA, true);
|
||||
((LivingEntity) getEntity()).setCustomNameVisible(nameplateVisible);
|
||||
String nameplateVisible = data().<Object> get(NPC.NAMEPLATE_VISIBLE_METADATA, true).toString();
|
||||
if (nameplateVisible.equals("hover")) {
|
||||
((LivingEntity) getEntity()).setCustomNameVisible(false);
|
||||
} else {
|
||||
((LivingEntity) getEntity()).setCustomNameVisible(Boolean.parseBoolean(nameplateVisible));
|
||||
}
|
||||
if (data().get(NPC.DEFAULT_PROTECTED_METADATA, true)) {
|
||||
NMS.setKnockbackResistance((LivingEntity) getEntity(), 1D);
|
||||
} else {
|
||||
|
@ -168,8 +168,9 @@ public class PigZombieController extends MobEntityController {
|
||||
@Override
|
||||
public void M() {
|
||||
super.M();
|
||||
if (npc != null)
|
||||
if (npc != null) {
|
||||
npc.update();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user