Add /npc endercrystal
This commit is contained in:
parent
d99109d0b2
commit
441923191f
|
@ -94,6 +94,7 @@ import net.citizensnpcs.trait.CommandTrait.NPCCommandBuilder;
|
|||
import net.citizensnpcs.trait.Controllable;
|
||||
import net.citizensnpcs.trait.CurrentLocation;
|
||||
import net.citizensnpcs.trait.DropsTrait;
|
||||
import net.citizensnpcs.trait.EnderCrystalTrait;
|
||||
import net.citizensnpcs.trait.EndermanTrait;
|
||||
import net.citizensnpcs.trait.FollowTrait;
|
||||
import net.citizensnpcs.trait.GameModeTrait;
|
||||
|
@ -618,6 +619,28 @@ public class NPCCommands {
|
|||
trait.displayEditor(sender);
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "npc" },
|
||||
usage = "endercrystal -b",
|
||||
desc = "Edit endercrystal modifiers",
|
||||
modifiers = { "endercrystal" },
|
||||
min = 1,
|
||||
max = 1,
|
||||
permission = "citizens.npc.endercrystal")
|
||||
@Requirements(ownership = true, selected = true, types = EntityType.ENDER_CRYSTAL)
|
||||
public void endercrystal(CommandContext args, Player sender, NPC npc) throws CommandException {
|
||||
if (args.hasFlag('b')) {
|
||||
EnderCrystalTrait trait = npc.getOrAddTrait(EnderCrystalTrait.class);
|
||||
boolean showing = !trait.isShowBase();
|
||||
trait.setShowBase(showing);
|
||||
Messaging.sendTr(sender,
|
||||
showing ? Messages.ENDERCRYSTAL_SHOWING_BOTTOM : Messages.ENDERCRYSTAL_NOT_SHOWING_BOTTOM,
|
||||
npc.getName());
|
||||
return;
|
||||
}
|
||||
throw new CommandException();
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "npc" },
|
||||
usage = "enderman -a[ngry]",
|
||||
|
|
|
@ -29,6 +29,7 @@ import net.citizensnpcs.trait.CommandTrait;
|
|||
import net.citizensnpcs.trait.Controllable;
|
||||
import net.citizensnpcs.trait.CurrentLocation;
|
||||
import net.citizensnpcs.trait.DropsTrait;
|
||||
import net.citizensnpcs.trait.EnderCrystalTrait;
|
||||
import net.citizensnpcs.trait.EndermanTrait;
|
||||
import net.citizensnpcs.trait.FollowTrait;
|
||||
import net.citizensnpcs.trait.GameModeTrait;
|
||||
|
@ -68,6 +69,7 @@ public class CitizensTraitFactory implements TraitFactory {
|
|||
registerTrait(TraitInfo.create(Controllable.class));
|
||||
registerTrait(TraitInfo.create(CurrentLocation.class));
|
||||
registerTrait(TraitInfo.create(DropsTrait.class));
|
||||
registerTrait(TraitInfo.create(EnderCrystalTrait.class));
|
||||
registerTrait(TraitInfo.create(EndermanTrait.class));
|
||||
registerTrait(TraitInfo.create(Equipment.class));
|
||||
registerTrait(TraitInfo.create(FollowTrait.class));
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
package net.citizensnpcs.trait;
|
||||
|
||||
import org.bukkit.entity.EnderCrystal;
|
||||
|
||||
import net.citizensnpcs.api.persistence.Persist;
|
||||
import net.citizensnpcs.api.trait.Trait;
|
||||
import net.citizensnpcs.api.trait.TraitName;
|
||||
|
||||
/**
|
||||
* Persists EnderCrystal metadata.
|
||||
*
|
||||
* @see EnderCrystal
|
||||
*/
|
||||
@TraitName("endercrystaltrait")
|
||||
public class EnderCrystalTrait extends Trait {
|
||||
@Persist
|
||||
private boolean showBase;
|
||||
|
||||
public EnderCrystalTrait() {
|
||||
super("endercrystaltrait");
|
||||
}
|
||||
|
||||
public boolean isShowBase() {
|
||||
return showBase;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSpawn() {
|
||||
updateModifiers();
|
||||
}
|
||||
|
||||
public void setShowBase(boolean showBase) {
|
||||
this.showBase = showBase;
|
||||
updateModifiers();
|
||||
}
|
||||
|
||||
private void updateModifiers() {
|
||||
if (!(npc.getEntity() instanceof EnderCrystal) || !SUPPORT_SHOW_BOTTOM)
|
||||
return;
|
||||
EnderCrystal crystal = (EnderCrystal) npc.getEntity();
|
||||
try {
|
||||
crystal.setShowingBottom(showBase);
|
||||
} catch (NoSuchMethodError err) {
|
||||
SUPPORT_SHOW_BOTTOM = false;
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean SUPPORT_SHOW_BOTTOM = true;
|
||||
}
|
|
@ -84,6 +84,8 @@ public class Messages {
|
|||
public static final String DELAY_TRIGGER_PROMPT = "citizens.editors.waypoints.triggers.delay.prompt";
|
||||
public static final String ELDER_SET = "citizens.commands.npc.guardian.elder-set";
|
||||
public static final String ELDER_UNSET = "citizens.commands.npc.guardian.elder-unset";
|
||||
public static final String ENDERCRYSTAL_NOT_SHOWING_BOTTOM = "citizens.commands.npc.endercrystal.not-showing-bottom";
|
||||
public static final String ENDERCRYSTAL_SHOWING_BOTTOM = "citizens.commands.npc.endercrystal.showing-bottom";
|
||||
public static final String ENDERMAN_ANGRY_SET = "citizens.commands.npc.enderman.angry-set";
|
||||
public static final String ENDERMAN_ANGRY_UNSET = "citizens.commands.npc.enderman.angry-unset";
|
||||
public static final String ENTITY_TYPE_SET = "citizens.commands.npc.type.set";
|
||||
|
|
|
@ -66,6 +66,8 @@ citizens.commands.npc.create.invalid-mobtype=[[{0}]] is not a valid mob type.
|
|||
citizens.commands.npc.create.npc-name-too-long=NPC names cannot be longer than [[{0}]] characters. The name has been shortened.
|
||||
citizens.commands.npc.create.no-player-for-spawn=No player could be found by that name to spawn an NPC at.
|
||||
citizens.commands.npc.despawn.despawned=You despawned [[{0}]].
|
||||
citizens.commands.npc.endercrystal.showing-bottom=[[{0}]] is now showing its base.
|
||||
citizens.commands.npc.endercrystal.not-showing-bottom=[[{0}]] is no longer showing its base.
|
||||
citizens.commands.npc.enderman.angry-set=[[{0}]] is now angry.
|
||||
citizens.commands.npc.enderman.angry-unset=[[{0}]] is no longer angry.
|
||||
citizens.commands.npc.flyable.set=[[{0}]] is now flyable.
|
||||
|
|
Loading…
Reference in New Issue