mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2025-02-16 12:21:25 +01:00
Add new commands for new 1.14 API
This commit is contained in:
parent
244e8dd343
commit
483c25f11a
@ -281,8 +281,9 @@ public class CitizensNPC extends AbstractNPC {
|
||||
public void update() {
|
||||
try {
|
||||
super.update();
|
||||
if (!isSpawned())
|
||||
if (!isSpawned()) {
|
||||
return;
|
||||
}
|
||||
if (data().get(NPC.SWIMMING_METADATA, true)) {
|
||||
NMS.trySwim(getEntity());
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ public class Messages {
|
||||
public static final String BEHAVIOURS_ADDED = "citizens.commands.npc.behaviour.added";
|
||||
public static final String BEHAVIOURS_REMOVED = "citizens.commands.npc.behaviour.removed";
|
||||
public static final String CANNOT_TELEPORT_ACROSS_WORLDS = "citizens.commands.npc.tphere.multiworld-not-allowed";
|
||||
public static final String CAT_COLLAR_COLOR_SET = "citizens.commands.npc.cat.collar-color-set";
|
||||
public static final String CAT_STARTED_SITTING = "citizens.commands.npc.cat.sitting-start";
|
||||
public static final String CAT_STOPPED_SITTING = "citizens.commands.npc.cat.sitting-stop";
|
||||
public static final String CAT_TYPE_SET = "citizens.commands.npc.cat.type-set";
|
||||
@ -88,6 +89,13 @@ public class Messages {
|
||||
public static final String FOLLOW_PLAYER_NOT_INGAME = "citizens.commands.npc.follow.player-not-ingame";
|
||||
public static final String FOLLOW_SET = "citizens.commands.npc.follow.set";
|
||||
public static final String FOLLOW_UNSET = "citizens.commands.npc.follow.unset";
|
||||
public static final String FOX_CROUCHING_SET = "citizens.commands.npc.fox.crouching-set";
|
||||
public static final String FOX_CROUCHING_UNSET = "citizens.commands.npc.fox.crouching-unset";
|
||||
public static final String FOX_SITTING_SET = "citizens.commands.npc.fox.sitting-set";
|
||||
public static final String FOX_SITTING_UNSET = "citizens.commands.npc.fox.sitting-unset";
|
||||
public static final String FOX_SLEEPING_SET = "citizens.commands.npc.fox.sleeping-set";
|
||||
public static final String FOX_SLEEPING_UNSET = "citizens.commands.npc.fox.sleeping-unset";
|
||||
public static final String FOX_TYPE_SET = "citizens.commands.npc.fox.fox-type-set";
|
||||
public static final String FROM_ENTITY_NOT_FOUND = "citizens.commands.npc.tpto.from-not-found";
|
||||
public static final String GAMEMODE_DESCRIBE = "citizens.commands.npc.gamemode.describe";
|
||||
public static final String GAMEMODE_INVALID = "citizens.commands.npc.gamemode.invalid";
|
||||
@ -110,8 +118,10 @@ public class Messages {
|
||||
public static final String INVALID_AGE = "citizens.commands.npc.age.invalid-age";
|
||||
public static final String INVALID_ANCHOR_NAME = "citizens.commands.npc.anchor.invalid-name";
|
||||
public static final String INVALID_ANIMATION = "citizens.editors.waypoints.triggers.animation.invalid-animation";
|
||||
public static final String INVALID_CAT_COLLAR_COLOR = "citizens.commands.npc.cat.invalid-collar-color";
|
||||
public static final String INVALID_CAT_TYPE = "citizens.commands.npc.cat.invalid-type";
|
||||
public static final String INVALID_ENTITY_TYPE = "citizens.commands.npc.type.invalid";
|
||||
public static final String INVALID_FOX_TYPE = "citizens.commands.npc.fox.invalid-fox-type";
|
||||
public static final String INVALID_HORSE_COLOR = "citizens.commands.npc.horse.invalid-color";
|
||||
public static final String INVALID_HORSE_STYLE = "citizens.commands.npc.horse.invalid-style";
|
||||
public static final String INVALID_HORSE_VARIANT = "citizens.commands.npc.horse.invalid-variant";
|
||||
|
@ -26,6 +26,8 @@ citizens.commands.npc.behaviour.added=Behaviours added.
|
||||
citizens.commands.npc.behaviour.help=The scripts argument is a comma-separated list of file names. Scripts will be loaded automatically and run every tick. Use the [[-r]] flag to remove behaviours.
|
||||
citizens.commands.npc.behaviour.removed=Behaviours removed.
|
||||
citizens.commands.npc.cat.invalid-type=Invalid type specified. Valid types are [[{0}]].
|
||||
citizens.commands.npc.cat.invalid-collar-color=Invalid collar color specified. Valid types are [[{0}]].
|
||||
citizens.commands.npc.cat.collar-color-set=Collar color set to [[{0}]].
|
||||
citizens.commands.npc.cat.sitting-start=[[{0}]] started sitting.
|
||||
citizens.commands.npc.cat.sitting-stop=[[{0}]] stopped sitting.
|
||||
citizens.commands.npc.cat.type-set=Type set to [[{0}]].
|
||||
@ -43,6 +45,14 @@ citizens.commands.npc.create.no-player-for-spawn=No player could be found by tha
|
||||
citizens.commands.npc.despawn.despawned=You despawned [[{0}]].
|
||||
citizens.commands.npc.flyable.set=[[{0}]] is now flyable.
|
||||
citizens.commands.npc.flyable.unset=[[{0}]] is no longer flyable.
|
||||
citizens.commands.npc.fox.crouching-set=[[{0}]] is now crouching.
|
||||
citizens.commands.npc.fox.crouching-unset=[[{0}]] is no longer crouching.
|
||||
citizens.commands.npc.fox.sitting-set=[[{0}]] is now sitting.
|
||||
citizens.commands.npc.fox.sitting-unset=[[{0}]] is no longer sitting.
|
||||
citizens.commands.npc.fox.sleeping-set=[[{0}]] is now sleeping.
|
||||
citizens.commands.npc.fox.sleeping-unset=[[{0}]] is no longer sleeping.
|
||||
citizens.commands.npc.fox.fox-type-set=Fox type set to [[{0}]].
|
||||
citizens.commands.npc.fox.invalid-fox-type=Invalid fox type specified. Valid types are [[{0}]].
|
||||
citizens.commands.npc.follow.set=[[{0}]] is now following [[{1}]].
|
||||
citizens.commands.npc.follow.unset=[[{0}]] is no longer following anyone.
|
||||
citizens.commands.npc.gamemode.describe={0}''s gamemode is [[{1}]].
|
||||
|
@ -1,5 +1,6 @@
|
||||
package net.citizensnpcs.nms.v1_14_R1.trait;
|
||||
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.entity.Cat;
|
||||
|
||||
import net.citizensnpcs.api.persistence.Persist;
|
||||
@ -8,6 +9,8 @@ import net.citizensnpcs.api.trait.TraitName;
|
||||
|
||||
@TraitName("cattrait")
|
||||
public class CatTrait extends Trait {
|
||||
@Persist
|
||||
private DyeColor collarColor = null;
|
||||
@Persist
|
||||
private boolean sitting = false;
|
||||
@Persist
|
||||
@ -23,9 +26,16 @@ public class CatTrait extends Trait {
|
||||
Cat cat = (Cat) npc.getEntity();
|
||||
cat.setSitting(sitting);
|
||||
cat.setCatType(type);
|
||||
if (collarColor != null) {
|
||||
cat.setCollarColor(collarColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setCollarColor(DyeColor color) {
|
||||
this.collarColor = color;
|
||||
}
|
||||
|
||||
public void setSitting(boolean sitting) {
|
||||
this.sitting = sitting;
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ import org.bukkit.boss.BarFlag;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Cat;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Fox;
|
||||
import org.bukkit.entity.Llama.Color;
|
||||
import org.bukkit.entity.Panda;
|
||||
import org.bukkit.entity.Parrot.Variant;
|
||||
@ -41,6 +42,7 @@ public class Commands {
|
||||
BarColor color = Util.matchEnum(BarColor.values(), args.getFlag("color"));
|
||||
trait.setColor(color);
|
||||
}
|
||||
|
||||
if (args.hasValueFlag("title")) {
|
||||
trait.setTitle(args.getFlag("title"));
|
||||
}
|
||||
@ -61,7 +63,7 @@ public class Commands {
|
||||
|
||||
@Command(
|
||||
aliases = { "npc" },
|
||||
usage = "cat (-s/-n) --type type",
|
||||
usage = "cat (-s/-n) --type type --ccolor collar color",
|
||||
desc = "Sets cat modifiers",
|
||||
modifiers = { "cat" },
|
||||
min = 1,
|
||||
@ -72,9 +74,6 @@ public class Commands {
|
||||
CatTrait trait = npc.getTrait(CatTrait.class);
|
||||
String output = "";
|
||||
if (args.hasValueFlag("type")) {
|
||||
if (args.getFlagInteger("size") <= 0) {
|
||||
throw new CommandUsageException();
|
||||
}
|
||||
Cat.Type type = Util.matchEnum(Cat.Type.values(), args.getFlag("type"));
|
||||
if (type == null) {
|
||||
throw new CommandUsageException(Messages.INVALID_CAT_TYPE, Util.listValuesPretty(Cat.Type.values()));
|
||||
@ -82,6 +81,15 @@ public class Commands {
|
||||
trait.setType(type);
|
||||
output += ' ' + Messaging.tr(Messages.CAT_TYPE_SET, args.getFlag("type"));
|
||||
}
|
||||
if (args.hasValueFlag("ccolor")) {
|
||||
DyeColor color = Util.matchEnum(DyeColor.values(), args.getFlag("ccolor"));
|
||||
if (color == null) {
|
||||
throw new CommandUsageException(Messages.INVALID_CAT_COLLAR_COLOR,
|
||||
Util.listValuesPretty(DyeColor.values()));
|
||||
}
|
||||
trait.setCollarColor(color);
|
||||
output += ' ' + Messaging.tr(Messages.CAT_COLLAR_COLOR_SET, args.getFlag("ccolor"));
|
||||
}
|
||||
if (args.hasFlag('s')) {
|
||||
trait.setSitting(true);
|
||||
output += ' ' + Messaging.tr(Messages.CAT_STARTED_SITTING);
|
||||
@ -96,6 +104,48 @@ public class Commands {
|
||||
}
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "npc" },
|
||||
usage = "fox --type type --sleeping [true|false] --sitting [true|false] --crouching [true|false]",
|
||||
desc = "Sets fox modifiers",
|
||||
modifiers = { "fox" },
|
||||
min = 1,
|
||||
max = 1,
|
||||
permission = "citizens.npc.fox")
|
||||
@Requirements(selected = true, ownership = true, types = EntityType.FOX)
|
||||
public void fox(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||
FoxTrait trait = npc.getTrait(FoxTrait.class);
|
||||
String output = "";
|
||||
if (args.hasValueFlag("type")) {
|
||||
Fox.Type type = Util.matchEnum(Fox.Type.values(), args.getFlag("type"));
|
||||
if (type == null) {
|
||||
throw new CommandUsageException(Messages.INVALID_FOX_TYPE, Util.listValuesPretty(Fox.Type.values()));
|
||||
}
|
||||
trait.setType(type);
|
||||
output += ' ' + Messaging.tr(Messages.FOX_TYPE_SET, args.getFlag("type"));
|
||||
}
|
||||
if (args.hasValueFlag("sleeping")) {
|
||||
boolean sleeping = Boolean.parseBoolean(args.getFlag("sleeping"));
|
||||
trait.setSleeping(sleeping);
|
||||
output += ' ' + Messaging.tr(sleeping ? Messages.FOX_SLEEPING_SET : Messages.FOX_SLEEPING_UNSET);
|
||||
}
|
||||
if (args.hasValueFlag("sitting")) {
|
||||
boolean sitting = Boolean.parseBoolean(args.getFlag("sitting"));
|
||||
trait.setSitting(sitting);
|
||||
output += ' ' + Messaging.tr(sitting ? Messages.FOX_SITTING_SET : Messages.FOX_SITTING_UNSET);
|
||||
}
|
||||
if (args.hasValueFlag("crouching")) {
|
||||
boolean crouching = Boolean.parseBoolean(args.getFlag("crouching"));
|
||||
trait.setCrouching(crouching);
|
||||
output += ' ' + Messaging.tr(crouching ? Messages.FOX_CROUCHING_SET : Messages.FOX_CROUCHING_UNSET);
|
||||
}
|
||||
if (!output.isEmpty()) {
|
||||
Messaging.send(sender, output.trim());
|
||||
} else {
|
||||
throw new CommandUsageException();
|
||||
}
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "npc" },
|
||||
usage = "llama (--color color) (--strength strength)",
|
||||
|
@ -0,0 +1,50 @@
|
||||
package net.citizensnpcs.nms.v1_14_R1.trait;
|
||||
|
||||
import org.bukkit.entity.Fox;
|
||||
|
||||
import net.citizensnpcs.api.persistence.Persist;
|
||||
import net.citizensnpcs.api.trait.Trait;
|
||||
import net.citizensnpcs.api.trait.TraitName;
|
||||
|
||||
@TraitName("foxtrait")
|
||||
public class FoxTrait extends Trait {
|
||||
@Persist
|
||||
private boolean crouching = false;
|
||||
@Persist
|
||||
private boolean sitting = false;
|
||||
@Persist
|
||||
private boolean sleeping = false;
|
||||
@Persist
|
||||
private Fox.Type type = Fox.Type.RED;
|
||||
|
||||
public FoxTrait() {
|
||||
super("foxtrait");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (npc.isSpawned() && npc.getEntity() instanceof Fox) {
|
||||
Fox fox = (Fox) npc.getEntity();
|
||||
fox.setSitting(sitting);
|
||||
fox.setCrouching(crouching);
|
||||
fox.setSleeping(sleeping);
|
||||
fox.setFoxType(type);
|
||||
}
|
||||
}
|
||||
|
||||
public void setCrouching(boolean crouching) {
|
||||
this.crouching = crouching;
|
||||
}
|
||||
|
||||
public void setSitting(boolean sitting) {
|
||||
this.sitting = sitting;
|
||||
}
|
||||
|
||||
public void setSleeping(boolean sleeping) {
|
||||
this.sleeping = sleeping;
|
||||
}
|
||||
|
||||
public void setType(Fox.Type type) {
|
||||
this.type = type;
|
||||
}
|
||||
}
|
@ -593,6 +593,7 @@ public class NMSImpl implements NMSBridge {
|
||||
@Override
|
||||
public void load(CommandManager manager) {
|
||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(CatTrait.class));
|
||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(FoxTrait.class));
|
||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(LlamaTrait.class));
|
||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(ParrotTrait.class));
|
||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(BossBarTrait.class));
|
||||
|
Loading…
Reference in New Issue
Block a user