mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-29 06:05:17 +01:00
Consolidate versioned trait commands
This commit is contained in:
parent
aaca31740b
commit
3fcf8931f7
@ -1,10 +1,21 @@
|
|||||||
package net.citizensnpcs.trait.versioned;
|
package net.citizensnpcs.trait.versioned;
|
||||||
|
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Axolotl;
|
import org.bukkit.entity.Axolotl;
|
||||||
|
import org.bukkit.entity.EntityType;
|
||||||
|
|
||||||
|
import net.citizensnpcs.api.command.Command;
|
||||||
|
import net.citizensnpcs.api.command.CommandContext;
|
||||||
|
import net.citizensnpcs.api.command.Requirements;
|
||||||
|
import net.citizensnpcs.api.command.exception.CommandException;
|
||||||
|
import net.citizensnpcs.api.command.exception.CommandUsageException;
|
||||||
|
import net.citizensnpcs.api.npc.NPC;
|
||||||
import net.citizensnpcs.api.persistence.Persist;
|
import net.citizensnpcs.api.persistence.Persist;
|
||||||
import net.citizensnpcs.api.trait.Trait;
|
import net.citizensnpcs.api.trait.Trait;
|
||||||
import net.citizensnpcs.api.trait.TraitName;
|
import net.citizensnpcs.api.trait.TraitName;
|
||||||
|
import net.citizensnpcs.api.util.Messaging;
|
||||||
|
import net.citizensnpcs.util.Messages;
|
||||||
|
import net.citizensnpcs.util.Util;
|
||||||
|
|
||||||
@TraitName("axolotltrait")
|
@TraitName("axolotltrait")
|
||||||
public class AxolotlTrait extends Trait {
|
public class AxolotlTrait extends Trait {
|
||||||
@ -43,4 +54,38 @@ public class AxolotlTrait extends Trait {
|
|||||||
public void setVariant(Axolotl.Variant variant) {
|
public void setVariant(Axolotl.Variant variant) {
|
||||||
this.variant = variant;
|
this.variant = variant;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Command(
|
||||||
|
aliases = { "npc" },
|
||||||
|
usage = "axolotl (-d) (--variant variant)",
|
||||||
|
desc = "Sets axolotl modifiers",
|
||||||
|
modifiers = { "axolotl" },
|
||||||
|
min = 1,
|
||||||
|
max = 1,
|
||||||
|
flags = "d",
|
||||||
|
permission = "citizens.npc.axolotl")
|
||||||
|
@Requirements(selected = true, ownership = true, types = EntityType.AXOLOTL)
|
||||||
|
public static void axolotl(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
|
AxolotlTrait trait = npc.getOrAddTrait(AxolotlTrait.class);
|
||||||
|
String output = "";
|
||||||
|
if (args.hasValueFlag("variant")) {
|
||||||
|
Axolotl.Variant variant = Util.matchEnum(Axolotl.Variant.values(), args.getFlag("variant"));
|
||||||
|
if (variant == null) {
|
||||||
|
throw new CommandException(Messages.INVALID_AXOLOTL_VARIANT,
|
||||||
|
Util.listValuesPretty(Axolotl.Variant.values()));
|
||||||
|
}
|
||||||
|
trait.setVariant(variant);
|
||||||
|
output += ' ' + Messaging.tr(Messages.AXOLOTL_VARIANT_SET, args.getFlag("variant"));
|
||||||
|
}
|
||||||
|
if (args.hasFlag('d')) {
|
||||||
|
trait.setPlayingDead(!trait.isPlayingDead());
|
||||||
|
output += ' ' + (trait.isPlayingDead() ? Messaging.tr(Messages.AXOLOTL_PLAYING_DEAD, npc.getName())
|
||||||
|
: Messaging.tr(Messages.AXOLOTL_NOT_PLAYING_DEAD, npc.getName()));
|
||||||
|
}
|
||||||
|
if (!output.isEmpty()) {
|
||||||
|
Messaging.send(sender, output.trim());
|
||||||
|
} else {
|
||||||
|
throw new CommandUsageException();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,20 @@
|
|||||||
package net.citizensnpcs.trait.versioned;
|
package net.citizensnpcs.trait.versioned;
|
||||||
|
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Bee;
|
import org.bukkit.entity.Bee;
|
||||||
|
import org.bukkit.entity.EntityType;
|
||||||
|
|
||||||
|
import net.citizensnpcs.api.command.Command;
|
||||||
|
import net.citizensnpcs.api.command.CommandContext;
|
||||||
|
import net.citizensnpcs.api.command.Requirements;
|
||||||
|
import net.citizensnpcs.api.command.exception.CommandException;
|
||||||
|
import net.citizensnpcs.api.command.exception.CommandUsageException;
|
||||||
|
import net.citizensnpcs.api.npc.NPC;
|
||||||
import net.citizensnpcs.api.persistence.Persist;
|
import net.citizensnpcs.api.persistence.Persist;
|
||||||
import net.citizensnpcs.api.trait.Trait;
|
import net.citizensnpcs.api.trait.Trait;
|
||||||
import net.citizensnpcs.api.trait.TraitName;
|
import net.citizensnpcs.api.trait.TraitName;
|
||||||
|
import net.citizensnpcs.api.util.Messaging;
|
||||||
|
import net.citizensnpcs.util.Messages;
|
||||||
|
|
||||||
@TraitName("beetrait")
|
@TraitName("beetrait")
|
||||||
public class BeeTrait extends Trait {
|
public class BeeTrait extends Trait {
|
||||||
@ -48,4 +58,42 @@ public class BeeTrait extends Trait {
|
|||||||
public void setStung(boolean stung) {
|
public void setStung(boolean stung) {
|
||||||
this.stung = stung;
|
this.stung = stung;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Command(
|
||||||
|
aliases = { "npc" },
|
||||||
|
usage = "bee (-s/-n) --anger anger",
|
||||||
|
desc = "Sets bee modifiers",
|
||||||
|
modifiers = { "bee" },
|
||||||
|
min = 1,
|
||||||
|
max = 1,
|
||||||
|
flags = "sn",
|
||||||
|
permission = "citizens.npc.bee")
|
||||||
|
@Requirements(selected = true, ownership = true, types = EntityType.BEE)
|
||||||
|
public static void bee(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
|
BeeTrait trait = npc.getOrAddTrait(BeeTrait.class);
|
||||||
|
String output = "";
|
||||||
|
if (args.hasValueFlag("anger")) {
|
||||||
|
int anger = args.getFlagInteger("anger");
|
||||||
|
if (anger < 0) {
|
||||||
|
throw new CommandException(Messages.INVALID_BEE_ANGER);
|
||||||
|
}
|
||||||
|
trait.setAnger(anger);
|
||||||
|
output += ' ' + Messaging.tr(Messages.BEE_ANGER_SET, args.getFlag("anger"));
|
||||||
|
}
|
||||||
|
if (args.hasFlag('s')) {
|
||||||
|
trait.setStung(!trait.hasStung());
|
||||||
|
output += ' ' + (trait.hasStung() ? Messaging.tr(Messages.BEE_STUNG, npc.getName())
|
||||||
|
: Messaging.tr(Messages.BEE_NOT_STUNG, npc.getName()));
|
||||||
|
}
|
||||||
|
if (args.hasFlag('n')) {
|
||||||
|
trait.setNectar(!trait.hasNectar());
|
||||||
|
output += ' ' + (trait.hasNectar() ? Messaging.tr(Messages.BEE_HAS_NECTAR, npc.getName())
|
||||||
|
: Messaging.tr(Messages.BEE_NO_NECTAR, npc.getName()));
|
||||||
|
}
|
||||||
|
if (!output.isEmpty()) {
|
||||||
|
Messaging.send(sender, output.trim());
|
||||||
|
} else {
|
||||||
|
throw new CommandUsageException();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,19 +9,28 @@ import org.bukkit.boss.BarColor;
|
|||||||
import org.bukkit.boss.BarFlag;
|
import org.bukkit.boss.BarFlag;
|
||||||
import org.bukkit.boss.BarStyle;
|
import org.bukkit.boss.BarStyle;
|
||||||
import org.bukkit.boss.BossBar;
|
import org.bukkit.boss.BossBar;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import com.google.common.base.Splitter;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
|
||||||
import net.citizensnpcs.Settings.Setting;
|
import net.citizensnpcs.Settings.Setting;
|
||||||
|
import net.citizensnpcs.api.command.Command;
|
||||||
|
import net.citizensnpcs.api.command.CommandContext;
|
||||||
|
import net.citizensnpcs.api.command.Requirements;
|
||||||
|
import net.citizensnpcs.api.command.exception.CommandException;
|
||||||
|
import net.citizensnpcs.api.npc.NPC;
|
||||||
import net.citizensnpcs.api.persistence.Persist;
|
import net.citizensnpcs.api.persistence.Persist;
|
||||||
import net.citizensnpcs.api.trait.Trait;
|
import net.citizensnpcs.api.trait.Trait;
|
||||||
import net.citizensnpcs.api.trait.TraitName;
|
import net.citizensnpcs.api.trait.TraitName;
|
||||||
|
import net.citizensnpcs.api.util.Colorizer;
|
||||||
import net.citizensnpcs.api.util.Placeholders;
|
import net.citizensnpcs.api.util.Placeholders;
|
||||||
import net.citizensnpcs.util.NMS;
|
import net.citizensnpcs.util.NMS;
|
||||||
|
import net.citizensnpcs.util.Util;
|
||||||
|
|
||||||
@TraitName("bossbar")
|
@TraitName("bossbar")
|
||||||
public class BossBarTrait extends Trait {
|
public class BossBarTrait extends Trait {
|
||||||
@ -179,5 +188,48 @@ public class BossBarTrait extends Trait {
|
|||||||
this.visible = visible;
|
this.visible = visible;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Command(
|
||||||
|
aliases = { "npc" },
|
||||||
|
usage = "bossbar --style [style] --color [color] --title [title] --visible [visible] --flags [flags] --track [health | placeholder]",
|
||||||
|
desc = "Edit bossbar properties",
|
||||||
|
modifiers = { "bossbar" },
|
||||||
|
min = 1,
|
||||||
|
max = 1)
|
||||||
|
@Requirements(selected = true, ownership = true)
|
||||||
|
public static void bossbar(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
|
BossBarTrait trait = npc.getOrAddTrait(BossBarTrait.class);
|
||||||
|
if (args.hasValueFlag("style")) {
|
||||||
|
BarStyle style = Util.matchEnum(BarStyle.values(), args.getFlag("style"));
|
||||||
|
if (style != null) {
|
||||||
|
trait.setStyle(style);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (args.hasValueFlag("color")) {
|
||||||
|
BarColor color = Util.matchEnum(BarColor.values(), args.getFlag("color"));
|
||||||
|
if (color != null) {
|
||||||
|
trait.setColor(color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (args.hasValueFlag("track")) {
|
||||||
|
trait.setTrackVariable(args.getFlag("track"));
|
||||||
|
}
|
||||||
|
if (args.hasValueFlag("title")) {
|
||||||
|
trait.setTitle(Colorizer.parseColors(args.getFlag("title")));
|
||||||
|
}
|
||||||
|
if (args.hasValueFlag("visible")) {
|
||||||
|
trait.setVisible(Boolean.parseBoolean(args.getFlag("visible")));
|
||||||
|
}
|
||||||
|
if (args.hasValueFlag("flags")) {
|
||||||
|
List<BarFlag> flags = Lists.newArrayList();
|
||||||
|
for (String s : Splitter.on(',').omitEmptyStrings().trimResults().split(args.getFlag("flags"))) {
|
||||||
|
BarFlag flag = Util.matchEnum(BarFlag.values(), s);
|
||||||
|
if (flag != null) {
|
||||||
|
flags.add(flag);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
trait.setFlags(flags);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static boolean SUPPORT_ATTRIBUTES = true;
|
private static boolean SUPPORT_ATTRIBUTES = true;
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,24 @@
|
|||||||
package net.citizensnpcs.trait.versioned;
|
package net.citizensnpcs.trait.versioned;
|
||||||
|
|
||||||
import org.bukkit.DyeColor;
|
import org.bukkit.DyeColor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Cat;
|
import org.bukkit.entity.Cat;
|
||||||
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.Ocelot.Type;
|
import org.bukkit.entity.Ocelot.Type;
|
||||||
|
|
||||||
|
import net.citizensnpcs.api.command.Command;
|
||||||
|
import net.citizensnpcs.api.command.CommandContext;
|
||||||
|
import net.citizensnpcs.api.command.Requirements;
|
||||||
|
import net.citizensnpcs.api.command.exception.CommandException;
|
||||||
|
import net.citizensnpcs.api.command.exception.CommandUsageException;
|
||||||
|
import net.citizensnpcs.api.npc.NPC;
|
||||||
import net.citizensnpcs.api.persistence.Persist;
|
import net.citizensnpcs.api.persistence.Persist;
|
||||||
import net.citizensnpcs.api.trait.Trait;
|
import net.citizensnpcs.api.trait.Trait;
|
||||||
import net.citizensnpcs.api.trait.TraitName;
|
import net.citizensnpcs.api.trait.TraitName;
|
||||||
|
import net.citizensnpcs.api.util.Messaging;
|
||||||
|
import net.citizensnpcs.util.Messages;
|
||||||
import net.citizensnpcs.util.NMS;
|
import net.citizensnpcs.util.NMS;
|
||||||
|
import net.citizensnpcs.util.Util;
|
||||||
|
|
||||||
@TraitName("cattrait")
|
@TraitName("cattrait")
|
||||||
public class CatTrait extends Trait {
|
public class CatTrait extends Trait {
|
||||||
@ -73,4 +84,53 @@ public class CatTrait extends Trait {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Command(
|
||||||
|
aliases = { "npc" },
|
||||||
|
usage = "cat (-s/-n/-l) --type type --ccolor collar color",
|
||||||
|
desc = "Sets cat modifiers",
|
||||||
|
modifiers = { "cat" },
|
||||||
|
min = 1,
|
||||||
|
max = 1,
|
||||||
|
flags = "snl",
|
||||||
|
permission = "citizens.npc.cat")
|
||||||
|
@Requirements(selected = true, ownership = true, types = EntityType.CAT)
|
||||||
|
public static void cat(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
|
CatTrait trait = npc.getOrAddTrait(CatTrait.class);
|
||||||
|
String output = "";
|
||||||
|
if (args.hasValueFlag("type")) {
|
||||||
|
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()));
|
||||||
|
}
|
||||||
|
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, npc.getName());
|
||||||
|
} else if (args.hasFlag('n')) {
|
||||||
|
trait.setSitting(false);
|
||||||
|
output += ' ' + Messaging.tr(Messages.CAT_STOPPED_SITTING, npc.getName());
|
||||||
|
}
|
||||||
|
if (args.hasFlag('l')) {
|
||||||
|
trait.setLyingDown(!trait.isLyingDown());
|
||||||
|
output += ' ' + Messaging.tr(trait.isLyingDown() ? Messages.CAT_STARTED_LYING : Messages.CAT_STOPPED_LYING,
|
||||||
|
npc.getName());
|
||||||
|
}
|
||||||
|
if (!output.isEmpty()) {
|
||||||
|
Messaging.send(sender, output.trim());
|
||||||
|
} else {
|
||||||
|
throw new CommandUsageException();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,21 @@
|
|||||||
package net.citizensnpcs.trait.versioned;
|
package net.citizensnpcs.trait.versioned;
|
||||||
|
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.Fox;
|
import org.bukkit.entity.Fox;
|
||||||
|
|
||||||
|
import net.citizensnpcs.api.command.Command;
|
||||||
|
import net.citizensnpcs.api.command.CommandContext;
|
||||||
|
import net.citizensnpcs.api.command.Requirements;
|
||||||
|
import net.citizensnpcs.api.command.exception.CommandException;
|
||||||
|
import net.citizensnpcs.api.command.exception.CommandUsageException;
|
||||||
|
import net.citizensnpcs.api.npc.NPC;
|
||||||
import net.citizensnpcs.api.persistence.Persist;
|
import net.citizensnpcs.api.persistence.Persist;
|
||||||
import net.citizensnpcs.api.trait.Trait;
|
import net.citizensnpcs.api.trait.Trait;
|
||||||
import net.citizensnpcs.api.trait.TraitName;
|
import net.citizensnpcs.api.trait.TraitName;
|
||||||
|
import net.citizensnpcs.api.util.Messaging;
|
||||||
|
import net.citizensnpcs.util.Messages;
|
||||||
|
import net.citizensnpcs.util.Util;
|
||||||
|
|
||||||
@TraitName("foxtrait")
|
@TraitName("foxtrait")
|
||||||
public class FoxTrait extends Trait {
|
public class FoxTrait extends Trait {
|
||||||
@ -63,4 +74,46 @@ public class FoxTrait extends Trait {
|
|||||||
public void setType(Fox.Type type) {
|
public void setType(Fox.Type type) {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@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 static void fox(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
|
FoxTrait trait = npc.getOrAddTrait(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();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,21 @@
|
|||||||
package net.citizensnpcs.trait.versioned;
|
package net.citizensnpcs.trait.versioned;
|
||||||
|
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.Frog;
|
import org.bukkit.entity.Frog;
|
||||||
import org.bukkit.entity.Frog.Variant;
|
import org.bukkit.entity.Frog.Variant;
|
||||||
|
|
||||||
|
import net.citizensnpcs.api.command.Command;
|
||||||
|
import net.citizensnpcs.api.command.CommandContext;
|
||||||
|
import net.citizensnpcs.api.command.Requirements;
|
||||||
|
import net.citizensnpcs.api.command.exception.CommandException;
|
||||||
|
import net.citizensnpcs.api.npc.NPC;
|
||||||
import net.citizensnpcs.api.persistence.Persist;
|
import net.citizensnpcs.api.persistence.Persist;
|
||||||
import net.citizensnpcs.api.trait.Trait;
|
import net.citizensnpcs.api.trait.Trait;
|
||||||
import net.citizensnpcs.api.trait.TraitName;
|
import net.citizensnpcs.api.trait.TraitName;
|
||||||
|
import net.citizensnpcs.api.util.Messaging;
|
||||||
|
import net.citizensnpcs.util.Messages;
|
||||||
|
import net.citizensnpcs.util.Util;
|
||||||
|
|
||||||
@TraitName("frogtrait")
|
@TraitName("frogtrait")
|
||||||
public class FrogTrait extends Trait {
|
public class FrogTrait extends Trait {
|
||||||
@ -31,4 +41,31 @@ public class FrogTrait extends Trait {
|
|||||||
public void setVariant(Frog.Variant variant) {
|
public void setVariant(Frog.Variant variant) {
|
||||||
this.variant = variant;
|
this.variant = variant;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Command(
|
||||||
|
aliases = { "npc" },
|
||||||
|
usage = "frog (--variant variant) (--target [target])",
|
||||||
|
desc = "Sets frog modifiers",
|
||||||
|
modifiers = { "frog" },
|
||||||
|
min = 1,
|
||||||
|
max = 1,
|
||||||
|
permission = "citizens.npc.frog")
|
||||||
|
@Requirements(selected = true, ownership = true, types = EntityType.FROG)
|
||||||
|
public static void frog(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
|
FrogTrait trait = npc.getOrAddTrait(FrogTrait.class);
|
||||||
|
String output = "";
|
||||||
|
if (args.hasValueFlag("variant")) {
|
||||||
|
String variantRaw = args.getFlag("variant");
|
||||||
|
Frog.Variant variant = Util.matchEnum(Frog.Variant.values(), variantRaw);
|
||||||
|
if (variant == null) {
|
||||||
|
String valid = Util.listValuesPretty(Frog.Variant.values());
|
||||||
|
throw new CommandException(Messages.INVALID_FROG_VARIANT, valid);
|
||||||
|
}
|
||||||
|
trait.setVariant(variant);
|
||||||
|
output += Messaging.tr(Messages.FROG_VARIANT_SET, Util.prettyEnum(variant));
|
||||||
|
}
|
||||||
|
if (!output.isEmpty()) {
|
||||||
|
Messaging.send(sender, output);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,19 @@
|
|||||||
package net.citizensnpcs.trait.versioned;
|
package net.citizensnpcs.trait.versioned;
|
||||||
|
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.Goat;
|
import org.bukkit.entity.Goat;
|
||||||
|
|
||||||
|
import net.citizensnpcs.api.command.Command;
|
||||||
|
import net.citizensnpcs.api.command.CommandContext;
|
||||||
|
import net.citizensnpcs.api.command.Requirements;
|
||||||
|
import net.citizensnpcs.api.command.exception.CommandException;
|
||||||
|
import net.citizensnpcs.api.npc.NPC;
|
||||||
import net.citizensnpcs.api.persistence.Persist;
|
import net.citizensnpcs.api.persistence.Persist;
|
||||||
import net.citizensnpcs.api.trait.Trait;
|
import net.citizensnpcs.api.trait.Trait;
|
||||||
import net.citizensnpcs.api.trait.TraitName;
|
import net.citizensnpcs.api.trait.TraitName;
|
||||||
|
import net.citizensnpcs.api.util.Messaging;
|
||||||
|
import net.citizensnpcs.util.Messages;
|
||||||
|
|
||||||
@TraitName("goattrait")
|
@TraitName("goattrait")
|
||||||
public class GoatTrait extends Trait {
|
public class GoatTrait extends Trait {
|
||||||
@ -29,8 +38,14 @@ public class GoatTrait extends Trait {
|
|||||||
public void run() {
|
public void run() {
|
||||||
if (npc.isSpawned() && npc.getEntity() instanceof Goat) {
|
if (npc.isSpawned() && npc.getEntity() instanceof Goat) {
|
||||||
Goat goat = (Goat) npc.getEntity();
|
Goat goat = (Goat) npc.getEntity();
|
||||||
|
if (SUPPORTS_HORNS) {
|
||||||
|
try {
|
||||||
goat.setRightHorn(rightHorn);
|
goat.setRightHorn(rightHorn);
|
||||||
goat.setLeftHorn(leftHorn);
|
goat.setLeftHorn(leftHorn);
|
||||||
|
} catch (Throwable t) {
|
||||||
|
SUPPORTS_HORNS = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,4 +56,39 @@ public class GoatTrait extends Trait {
|
|||||||
public void setRightHorn(boolean horn) {
|
public void setRightHorn(boolean horn) {
|
||||||
this.rightHorn = horn;
|
this.rightHorn = horn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Command(
|
||||||
|
aliases = { "npc" },
|
||||||
|
usage = "goat -l(eft) -r(ight) -n(either) -b(oth) horn",
|
||||||
|
desc = "Sets goat modifiers",
|
||||||
|
modifiers = { "goat" },
|
||||||
|
flags = "lrnb",
|
||||||
|
min = 1,
|
||||||
|
max = 1,
|
||||||
|
permission = "citizens.npc.goat")
|
||||||
|
@Requirements(selected = true, ownership = true, types = EntityType.GOAT)
|
||||||
|
public static void goat(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
|
GoatTrait trait = npc.getOrAddTrait(GoatTrait.class);
|
||||||
|
boolean left = trait.isLeftHorn(), right = trait.isRightHorn();
|
||||||
|
if (args.hasFlag('l')) {
|
||||||
|
left = !left;
|
||||||
|
}
|
||||||
|
if (args.hasFlag('r')) {
|
||||||
|
right = !right;
|
||||||
|
}
|
||||||
|
if (args.hasFlag('b')) {
|
||||||
|
left = right = true;
|
||||||
|
}
|
||||||
|
if (args.hasFlag('n')) {
|
||||||
|
left = right = false;
|
||||||
|
}
|
||||||
|
trait.setLeftHorn(left);
|
||||||
|
trait.setRightHorn(right);
|
||||||
|
String output = Messaging.tr(Messages.NPC_GOAT_HORNS_SET, npc.getName(), left, right);
|
||||||
|
if (!output.isEmpty()) {
|
||||||
|
Messaging.send(sender, output);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean SUPPORTS_HORNS = true;
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,22 @@
|
|||||||
package net.citizensnpcs.trait.versioned;
|
package net.citizensnpcs.trait.versioned;
|
||||||
|
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.Llama;
|
import org.bukkit.entity.Llama;
|
||||||
import org.bukkit.entity.Llama.Color;
|
import org.bukkit.entity.Llama.Color;
|
||||||
|
|
||||||
|
import net.citizensnpcs.api.command.Command;
|
||||||
|
import net.citizensnpcs.api.command.CommandContext;
|
||||||
|
import net.citizensnpcs.api.command.Requirements;
|
||||||
|
import net.citizensnpcs.api.command.exception.CommandException;
|
||||||
|
import net.citizensnpcs.api.npc.NPC;
|
||||||
import net.citizensnpcs.api.persistence.Persist;
|
import net.citizensnpcs.api.persistence.Persist;
|
||||||
import net.citizensnpcs.api.trait.Trait;
|
import net.citizensnpcs.api.trait.Trait;
|
||||||
import net.citizensnpcs.api.trait.TraitName;
|
import net.citizensnpcs.api.trait.TraitName;
|
||||||
|
import net.citizensnpcs.api.util.Messaging;
|
||||||
|
import net.citizensnpcs.trait.HorseModifiers;
|
||||||
|
import net.citizensnpcs.util.Messages;
|
||||||
|
import net.citizensnpcs.util.Util;
|
||||||
|
|
||||||
@TraitName("llamatrait")
|
@TraitName("llamatrait")
|
||||||
public class LlamaTrait extends Trait {
|
public class LlamaTrait extends Trait {
|
||||||
@ -42,4 +53,43 @@ public class LlamaTrait extends Trait {
|
|||||||
public void setStrength(int strength) {
|
public void setStrength(int strength) {
|
||||||
this.strength = strength;
|
this.strength = strength;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Command(
|
||||||
|
aliases = { "npc" },
|
||||||
|
usage = "llama (--color color) (--strength strength)",
|
||||||
|
desc = "Sets llama modifiers",
|
||||||
|
modifiers = { "llama" },
|
||||||
|
min = 1,
|
||||||
|
max = 1,
|
||||||
|
permission = "citizens.npc.llama")
|
||||||
|
@Requirements(selected = true, ownership = true, types = { EntityType.LLAMA, EntityType.TRADER_LLAMA })
|
||||||
|
public static void llama(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
|
LlamaTrait trait = npc.getOrAddTrait(LlamaTrait.class);
|
||||||
|
String output = "";
|
||||||
|
if (args.hasValueFlag("color") || args.hasValueFlag("colour")) {
|
||||||
|
String colorRaw = args.getFlag("color", args.getFlag("colour"));
|
||||||
|
Color color = Util.matchEnum(Color.values(), colorRaw);
|
||||||
|
if (color == null) {
|
||||||
|
String valid = Util.listValuesPretty(Color.values());
|
||||||
|
throw new CommandException(Messages.INVALID_LLAMA_COLOR, valid);
|
||||||
|
}
|
||||||
|
trait.setColor(color);
|
||||||
|
output += Messaging.tr(Messages.LLAMA_COLOR_SET, Util.prettyEnum(color));
|
||||||
|
}
|
||||||
|
if (args.hasValueFlag("strength")) {
|
||||||
|
trait.setStrength(Math.max(1, Math.min(5, args.getFlagInteger("strength"))));
|
||||||
|
output += Messaging.tr(Messages.LLAMA_STRENGTH_SET, args.getFlagInteger("strength"));
|
||||||
|
}
|
||||||
|
if (args.hasFlag('c')) {
|
||||||
|
npc.getOrAddTrait(HorseModifiers.class).setCarryingChest(true);
|
||||||
|
output += Messaging.tr(Messages.HORSE_CHEST_SET) + " ";
|
||||||
|
} else if (args.hasFlag('b')) {
|
||||||
|
npc.getOrAddTrait(HorseModifiers.class).setCarryingChest(false);
|
||||||
|
output += Messaging.tr(Messages.HORSE_CHEST_UNSET) + " ";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!output.isEmpty()) {
|
||||||
|
Messaging.send(sender, output);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,22 @@
|
|||||||
package net.citizensnpcs.trait.versioned;
|
package net.citizensnpcs.trait.versioned;
|
||||||
|
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.MushroomCow;
|
import org.bukkit.entity.MushroomCow;
|
||||||
import org.bukkit.entity.MushroomCow.Variant;
|
import org.bukkit.entity.MushroomCow.Variant;
|
||||||
|
|
||||||
|
import net.citizensnpcs.api.command.Command;
|
||||||
|
import net.citizensnpcs.api.command.CommandContext;
|
||||||
|
import net.citizensnpcs.api.command.Requirements;
|
||||||
|
import net.citizensnpcs.api.command.exception.CommandException;
|
||||||
|
import net.citizensnpcs.api.command.exception.CommandUsageException;
|
||||||
|
import net.citizensnpcs.api.npc.NPC;
|
||||||
import net.citizensnpcs.api.persistence.Persist;
|
import net.citizensnpcs.api.persistence.Persist;
|
||||||
import net.citizensnpcs.api.trait.Trait;
|
import net.citizensnpcs.api.trait.Trait;
|
||||||
import net.citizensnpcs.api.trait.TraitName;
|
import net.citizensnpcs.api.trait.TraitName;
|
||||||
|
import net.citizensnpcs.api.util.Messaging;
|
||||||
|
import net.citizensnpcs.util.Messages;
|
||||||
|
import net.citizensnpcs.util.Util;
|
||||||
|
|
||||||
@TraitName("mushroomcowtrait")
|
@TraitName("mushroomcowtrait")
|
||||||
public class MushroomCowTrait extends Trait {
|
public class MushroomCowTrait extends Trait {
|
||||||
@ -35,4 +46,32 @@ public class MushroomCowTrait extends Trait {
|
|||||||
public void setVariant(Variant variant) {
|
public void setVariant(Variant variant) {
|
||||||
this.variant = variant;
|
this.variant = variant;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Command(
|
||||||
|
aliases = { "npc" },
|
||||||
|
usage = "mcow (--variant [variant])",
|
||||||
|
desc = "Sets mushroom cow modifiers.",
|
||||||
|
modifiers = { "mcow", "mushroomcow" },
|
||||||
|
min = 1,
|
||||||
|
max = 1,
|
||||||
|
permission = "citizens.npc.mushroomcow")
|
||||||
|
@Requirements(selected = true, ownership = true, types = { EntityType.MUSHROOM_COW })
|
||||||
|
public static void mushroomcow(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
|
MushroomCowTrait trait = npc.getOrAddTrait(MushroomCowTrait.class);
|
||||||
|
boolean hasArg = false;
|
||||||
|
if (args.hasValueFlag("variant")) {
|
||||||
|
MushroomCow.Variant variant = Util.matchEnum(MushroomCow.Variant.values(), args.getFlag("variant"));
|
||||||
|
if (variant == null) {
|
||||||
|
Messaging.sendErrorTr(sender, Messages.INVALID_MUSHROOM_COW_VARIANT,
|
||||||
|
Util.listValuesPretty(MushroomCow.Variant.values()));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
trait.setVariant(variant);
|
||||||
|
Messaging.sendTr(sender, Messages.MUSHROOM_COW_VARIANT_SET, npc.getName(), variant);
|
||||||
|
hasArg = true;
|
||||||
|
}
|
||||||
|
if (!hasArg) {
|
||||||
|
throw new CommandUsageException();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,22 @@
|
|||||||
package net.citizensnpcs.trait.versioned;
|
package net.citizensnpcs.trait.versioned;
|
||||||
|
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.Panda;
|
import org.bukkit.entity.Panda;
|
||||||
|
|
||||||
|
import net.citizensnpcs.api.command.Command;
|
||||||
|
import net.citizensnpcs.api.command.CommandContext;
|
||||||
|
import net.citizensnpcs.api.command.Requirements;
|
||||||
|
import net.citizensnpcs.api.command.exception.CommandException;
|
||||||
|
import net.citizensnpcs.api.command.exception.CommandUsageException;
|
||||||
|
import net.citizensnpcs.api.npc.NPC;
|
||||||
import net.citizensnpcs.api.persistence.Persist;
|
import net.citizensnpcs.api.persistence.Persist;
|
||||||
import net.citizensnpcs.api.trait.Trait;
|
import net.citizensnpcs.api.trait.Trait;
|
||||||
import net.citizensnpcs.api.trait.TraitName;
|
import net.citizensnpcs.api.trait.TraitName;
|
||||||
|
import net.citizensnpcs.api.util.Messaging;
|
||||||
|
import net.citizensnpcs.util.Messages;
|
||||||
import net.citizensnpcs.util.NMS;
|
import net.citizensnpcs.util.NMS;
|
||||||
|
import net.citizensnpcs.util.Util;
|
||||||
|
|
||||||
@TraitName("pandatrait")
|
@TraitName("pandatrait")
|
||||||
public class PandaTrait extends Trait {
|
public class PandaTrait extends Trait {
|
||||||
@ -60,4 +71,46 @@ public class PandaTrait extends Trait {
|
|||||||
return sitting = !sitting;
|
return sitting = !sitting;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Command(
|
||||||
|
aliases = { "npc" },
|
||||||
|
usage = "panda --gene (main gene) --hgene (hidden gene) -s(itting)",
|
||||||
|
desc = "Sets panda modifiers",
|
||||||
|
modifiers = { "panda" },
|
||||||
|
flags = "s",
|
||||||
|
min = 1,
|
||||||
|
max = 1,
|
||||||
|
permission = "citizens.npc.panda")
|
||||||
|
@Requirements(selected = true, ownership = true, types = EntityType.PANDA)
|
||||||
|
public static void panda(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
|
PandaTrait trait = npc.getOrAddTrait(PandaTrait.class);
|
||||||
|
String output = "";
|
||||||
|
if (args.hasValueFlag("gene")) {
|
||||||
|
Panda.Gene gene = Util.matchEnum(Panda.Gene.values(), args.getFlag("gene"));
|
||||||
|
if (gene == null) {
|
||||||
|
throw new CommandUsageException(Messages.INVALID_PANDA_GENE,
|
||||||
|
Util.listValuesPretty(Panda.Gene.values()));
|
||||||
|
}
|
||||||
|
trait.setMainGene(gene);
|
||||||
|
output += ' ' + Messaging.tr(Messages.PANDA_MAIN_GENE_SET, args.getFlag("gene"));
|
||||||
|
}
|
||||||
|
if (args.hasValueFlag("hgene")) {
|
||||||
|
Panda.Gene gene = Util.matchEnum(Panda.Gene.values(), args.getFlag("hgene"));
|
||||||
|
if (gene == null) {
|
||||||
|
throw new CommandUsageException(Messages.INVALID_PANDA_GENE,
|
||||||
|
Util.listValuesPretty(Panda.Gene.values()));
|
||||||
|
}
|
||||||
|
trait.setHiddenGene(gene);
|
||||||
|
output += ' ' + Messaging.tr(Messages.PANDA_HIDDEN_GENE_SET, args.getFlag("hgene"));
|
||||||
|
}
|
||||||
|
if (args.hasFlag('s')) {
|
||||||
|
boolean isSitting = trait.toggleSitting();
|
||||||
|
output += ' ' + Messaging.tr(isSitting ? Messages.PANDA_SITTING : Messages.PANDA_STOPPED_SITTING);
|
||||||
|
}
|
||||||
|
if (!output.isEmpty()) {
|
||||||
|
Messaging.send(sender, output.trim());
|
||||||
|
} else {
|
||||||
|
throw new CommandUsageException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,21 @@
|
|||||||
package net.citizensnpcs.trait.versioned;
|
package net.citizensnpcs.trait.versioned;
|
||||||
|
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.Parrot;
|
import org.bukkit.entity.Parrot;
|
||||||
import org.bukkit.entity.Parrot.Variant;
|
import org.bukkit.entity.Parrot.Variant;
|
||||||
|
|
||||||
|
import net.citizensnpcs.api.command.Command;
|
||||||
|
import net.citizensnpcs.api.command.CommandContext;
|
||||||
|
import net.citizensnpcs.api.command.Requirements;
|
||||||
|
import net.citizensnpcs.api.command.exception.CommandException;
|
||||||
|
import net.citizensnpcs.api.npc.NPC;
|
||||||
import net.citizensnpcs.api.persistence.Persist;
|
import net.citizensnpcs.api.persistence.Persist;
|
||||||
import net.citizensnpcs.api.trait.Trait;
|
import net.citizensnpcs.api.trait.Trait;
|
||||||
import net.citizensnpcs.api.trait.TraitName;
|
import net.citizensnpcs.api.trait.TraitName;
|
||||||
|
import net.citizensnpcs.api.util.Messaging;
|
||||||
|
import net.citizensnpcs.util.Messages;
|
||||||
|
import net.citizensnpcs.util.Util;
|
||||||
|
|
||||||
@TraitName("parrottrait")
|
@TraitName("parrottrait")
|
||||||
public class ParrotTrait extends Trait {
|
public class ParrotTrait extends Trait {
|
||||||
@ -31,4 +41,31 @@ public class ParrotTrait extends Trait {
|
|||||||
public void setVariant(Parrot.Variant variant) {
|
public void setVariant(Parrot.Variant variant) {
|
||||||
this.variant = variant;
|
this.variant = variant;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Command(
|
||||||
|
aliases = { "npc" },
|
||||||
|
usage = "parrot (--variant variant)",
|
||||||
|
desc = "Sets parrot modifiers",
|
||||||
|
modifiers = { "parrot" },
|
||||||
|
min = 1,
|
||||||
|
max = 1,
|
||||||
|
permission = "citizens.npc.parrot")
|
||||||
|
@Requirements(selected = true, ownership = true, types = EntityType.PARROT)
|
||||||
|
public static void parrot(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
|
ParrotTrait trait = npc.getOrAddTrait(ParrotTrait.class);
|
||||||
|
String output = "";
|
||||||
|
if (args.hasValueFlag("variant")) {
|
||||||
|
String variantRaw = args.getFlag("variant");
|
||||||
|
Variant variant = Util.matchEnum(Variant.values(), variantRaw);
|
||||||
|
if (variant == null) {
|
||||||
|
String valid = Util.listValuesPretty(Variant.values());
|
||||||
|
throw new CommandException(Messages.INVALID_PARROT_VARIANT, valid);
|
||||||
|
}
|
||||||
|
trait.setVariant(variant);
|
||||||
|
output += Messaging.tr(Messages.PARROT_VARIANT_SET, Util.prettyEnum(variant));
|
||||||
|
}
|
||||||
|
if (!output.isEmpty()) {
|
||||||
|
Messaging.send(sender, output);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,20 @@
|
|||||||
package net.citizensnpcs.trait.versioned;
|
package net.citizensnpcs.trait.versioned;
|
||||||
|
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.Phantom;
|
import org.bukkit.entity.Phantom;
|
||||||
|
|
||||||
|
import net.citizensnpcs.api.command.Command;
|
||||||
|
import net.citizensnpcs.api.command.CommandContext;
|
||||||
|
import net.citizensnpcs.api.command.Requirements;
|
||||||
|
import net.citizensnpcs.api.command.exception.CommandException;
|
||||||
|
import net.citizensnpcs.api.command.exception.CommandUsageException;
|
||||||
|
import net.citizensnpcs.api.npc.NPC;
|
||||||
import net.citizensnpcs.api.persistence.Persist;
|
import net.citizensnpcs.api.persistence.Persist;
|
||||||
import net.citizensnpcs.api.trait.Trait;
|
import net.citizensnpcs.api.trait.Trait;
|
||||||
import net.citizensnpcs.api.trait.TraitName;
|
import net.citizensnpcs.api.trait.TraitName;
|
||||||
|
import net.citizensnpcs.api.util.Messaging;
|
||||||
|
import net.citizensnpcs.util.Messages;
|
||||||
|
|
||||||
@TraitName("phantomtrait")
|
@TraitName("phantomtrait")
|
||||||
public class PhantomTrait extends Trait {
|
public class PhantomTrait extends Trait {
|
||||||
@ -30,4 +40,30 @@ public class PhantomTrait extends Trait {
|
|||||||
public void setSize(int size) {
|
public void setSize(int size) {
|
||||||
this.size = size;
|
this.size = size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Command(
|
||||||
|
aliases = { "npc" },
|
||||||
|
usage = "phantom (--size size)",
|
||||||
|
desc = "Sets phantom modifiers",
|
||||||
|
modifiers = { "phantom" },
|
||||||
|
min = 1,
|
||||||
|
max = 1,
|
||||||
|
permission = "citizens.npc.phantom")
|
||||||
|
@Requirements(selected = true, ownership = true, types = EntityType.PHANTOM)
|
||||||
|
public static void phantom(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
|
PhantomTrait trait = npc.getOrAddTrait(PhantomTrait.class);
|
||||||
|
String output = "";
|
||||||
|
if (args.hasValueFlag("size")) {
|
||||||
|
if (args.getFlagInteger("size") <= 0) {
|
||||||
|
throw new CommandUsageException();
|
||||||
|
}
|
||||||
|
trait.setSize(args.getFlagInteger("size"));
|
||||||
|
output += Messaging.tr(Messages.PHANTOM_STATE_SET, args.getFlagInteger("size"));
|
||||||
|
}
|
||||||
|
if (!output.isEmpty()) {
|
||||||
|
Messaging.send(sender, output);
|
||||||
|
} else {
|
||||||
|
throw new CommandUsageException();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,20 @@
|
|||||||
package net.citizensnpcs.trait.versioned;
|
package net.citizensnpcs.trait.versioned;
|
||||||
|
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.Piglin;
|
import org.bukkit.entity.Piglin;
|
||||||
|
|
||||||
|
import net.citizensnpcs.api.command.Command;
|
||||||
|
import net.citizensnpcs.api.command.CommandContext;
|
||||||
|
import net.citizensnpcs.api.command.Requirements;
|
||||||
|
import net.citizensnpcs.api.command.exception.CommandException;
|
||||||
|
import net.citizensnpcs.api.command.exception.CommandUsageException;
|
||||||
|
import net.citizensnpcs.api.npc.NPC;
|
||||||
import net.citizensnpcs.api.persistence.Persist;
|
import net.citizensnpcs.api.persistence.Persist;
|
||||||
import net.citizensnpcs.api.trait.Trait;
|
import net.citizensnpcs.api.trait.Trait;
|
||||||
import net.citizensnpcs.api.trait.TraitName;
|
import net.citizensnpcs.api.trait.TraitName;
|
||||||
|
import net.citizensnpcs.api.util.Messaging;
|
||||||
|
import net.citizensnpcs.util.Messages;
|
||||||
import net.citizensnpcs.util.NMS;
|
import net.citizensnpcs.util.NMS;
|
||||||
|
|
||||||
@TraitName("piglintrait")
|
@TraitName("piglintrait")
|
||||||
@ -31,4 +41,28 @@ public class PiglinTrait extends Trait {
|
|||||||
this.dancing = dancing;
|
this.dancing = dancing;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Command(
|
||||||
|
aliases = { "npc" },
|
||||||
|
usage = "piglin (--dancing [true|false])",
|
||||||
|
desc = "Sets piglin modifiers.",
|
||||||
|
modifiers = { "piglin" },
|
||||||
|
min = 1,
|
||||||
|
max = 1,
|
||||||
|
permission = "citizens.npc.piglin")
|
||||||
|
@Requirements(selected = true, ownership = true, types = { EntityType.PIGLIN })
|
||||||
|
public static void piglin(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
|
PiglinTrait trait = npc.getOrAddTrait(PiglinTrait.class);
|
||||||
|
boolean hasArg = false;
|
||||||
|
if (args.hasValueFlag("dancing")) {
|
||||||
|
boolean dancing = Boolean.valueOf(args.getFlag("dancing"));
|
||||||
|
trait.setDancing(dancing);
|
||||||
|
Messaging.sendTr(sender, dancing ? Messages.PIGLIN_DANCING_SET : Messages.PIGLIN_DANCING_UNSET,
|
||||||
|
npc.getName());
|
||||||
|
hasArg = true;
|
||||||
|
}
|
||||||
|
if (!hasArg) {
|
||||||
|
throw new CommandUsageException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,20 @@
|
|||||||
package net.citizensnpcs.trait.versioned;
|
package net.citizensnpcs.trait.versioned;
|
||||||
|
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.PolarBear;
|
import org.bukkit.entity.PolarBear;
|
||||||
|
|
||||||
|
import net.citizensnpcs.api.command.Command;
|
||||||
|
import net.citizensnpcs.api.command.CommandContext;
|
||||||
|
import net.citizensnpcs.api.command.Requirements;
|
||||||
|
import net.citizensnpcs.api.command.exception.CommandException;
|
||||||
|
import net.citizensnpcs.api.command.exception.CommandUsageException;
|
||||||
|
import net.citizensnpcs.api.npc.NPC;
|
||||||
import net.citizensnpcs.api.persistence.Persist;
|
import net.citizensnpcs.api.persistence.Persist;
|
||||||
import net.citizensnpcs.api.trait.Trait;
|
import net.citizensnpcs.api.trait.Trait;
|
||||||
import net.citizensnpcs.api.trait.TraitName;
|
import net.citizensnpcs.api.trait.TraitName;
|
||||||
|
import net.citizensnpcs.api.util.Messaging;
|
||||||
|
import net.citizensnpcs.util.Messages;
|
||||||
import net.citizensnpcs.util.NMS;
|
import net.citizensnpcs.util.NMS;
|
||||||
|
|
||||||
@TraitName("polarbeartrait")
|
@TraitName("polarbeartrait")
|
||||||
@ -30,4 +40,30 @@ public class PolarBearTrait extends Trait {
|
|||||||
public void setRearing(boolean rearing) {
|
public void setRearing(boolean rearing) {
|
||||||
this.rearing = rearing;
|
this.rearing = rearing;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Command(
|
||||||
|
aliases = { "npc" },
|
||||||
|
usage = "polarbear (-r)",
|
||||||
|
desc = "Sets polarbear modifiers.",
|
||||||
|
modifiers = { "polarbear" },
|
||||||
|
min = 1,
|
||||||
|
max = 1,
|
||||||
|
flags = "r",
|
||||||
|
permission = "citizens.npc.polarbear")
|
||||||
|
@Requirements(selected = true, ownership = true, types = { EntityType.POLAR_BEAR })
|
||||||
|
public static void polarbear(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
|
PolarBearTrait trait = npc.getOrAddTrait(PolarBearTrait.class);
|
||||||
|
String output = "";
|
||||||
|
if (args.hasFlag('r')) {
|
||||||
|
trait.setRearing(!trait.isRearing());
|
||||||
|
output += Messaging.tr(
|
||||||
|
trait.isRearing() ? Messages.POLAR_BEAR_REARING : Messages.POLAR_BEAR_STOPPED_REARING,
|
||||||
|
npc.getName());
|
||||||
|
}
|
||||||
|
if (!output.isEmpty()) {
|
||||||
|
Messaging.send(sender, output);
|
||||||
|
} else {
|
||||||
|
throw new CommandUsageException();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,18 @@
|
|||||||
package net.citizensnpcs.trait.versioned;
|
package net.citizensnpcs.trait.versioned;
|
||||||
|
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.EntityType;
|
||||||
|
|
||||||
|
import net.citizensnpcs.api.command.Command;
|
||||||
|
import net.citizensnpcs.api.command.CommandContext;
|
||||||
|
import net.citizensnpcs.api.command.Requirements;
|
||||||
|
import net.citizensnpcs.api.command.exception.CommandException;
|
||||||
|
import net.citizensnpcs.api.npc.NPC;
|
||||||
import net.citizensnpcs.api.persistence.Persist;
|
import net.citizensnpcs.api.persistence.Persist;
|
||||||
import net.citizensnpcs.api.trait.Trait;
|
import net.citizensnpcs.api.trait.Trait;
|
||||||
import net.citizensnpcs.api.trait.TraitName;
|
import net.citizensnpcs.api.trait.TraitName;
|
||||||
|
import net.citizensnpcs.api.util.Messaging;
|
||||||
|
import net.citizensnpcs.util.Messages;
|
||||||
|
|
||||||
@TraitName("pufferfishtrait")
|
@TraitName("pufferfishtrait")
|
||||||
public class PufferFishTrait extends Trait {
|
public class PufferFishTrait extends Trait {
|
||||||
@ -20,4 +30,26 @@ public class PufferFishTrait extends Trait {
|
|||||||
public void setPuffState(int state) {
|
public void setPuffState(int state) {
|
||||||
this.puffState = state;
|
this.puffState = state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Command(
|
||||||
|
aliases = { "npc" },
|
||||||
|
usage = "pufferfish (--state state)",
|
||||||
|
desc = "Sets pufferfish modifiers",
|
||||||
|
modifiers = { "pufferfish" },
|
||||||
|
min = 1,
|
||||||
|
max = 1,
|
||||||
|
permission = "citizens.npc.pufferfish")
|
||||||
|
@Requirements(selected = true, ownership = true, types = EntityType.PUFFERFISH)
|
||||||
|
public static void pufferfish(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
|
PufferFishTrait trait = npc.getOrAddTrait(PufferFishTrait.class);
|
||||||
|
String output = "";
|
||||||
|
if (args.hasValueFlag("state")) {
|
||||||
|
int state = Math.min(Math.max(args.getFlagInteger("state"), 0), 3);
|
||||||
|
trait.setPuffState(state);
|
||||||
|
output += Messaging.tr(Messages.PUFFERFISH_STATE_SET, state);
|
||||||
|
}
|
||||||
|
if (!output.isEmpty()) {
|
||||||
|
Messaging.send(sender, output);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,23 @@
|
|||||||
package net.citizensnpcs.trait.versioned;
|
package net.citizensnpcs.trait.versioned;
|
||||||
|
|
||||||
import org.bukkit.DyeColor;
|
import org.bukkit.DyeColor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.Shulker;
|
import org.bukkit.entity.Shulker;
|
||||||
|
|
||||||
|
import net.citizensnpcs.api.command.Command;
|
||||||
|
import net.citizensnpcs.api.command.CommandContext;
|
||||||
|
import net.citizensnpcs.api.command.Requirements;
|
||||||
|
import net.citizensnpcs.api.command.exception.CommandException;
|
||||||
|
import net.citizensnpcs.api.command.exception.CommandUsageException;
|
||||||
|
import net.citizensnpcs.api.npc.NPC;
|
||||||
import net.citizensnpcs.api.persistence.Persist;
|
import net.citizensnpcs.api.persistence.Persist;
|
||||||
import net.citizensnpcs.api.trait.Trait;
|
import net.citizensnpcs.api.trait.Trait;
|
||||||
import net.citizensnpcs.api.trait.TraitName;
|
import net.citizensnpcs.api.trait.TraitName;
|
||||||
|
import net.citizensnpcs.api.util.Messaging;
|
||||||
|
import net.citizensnpcs.util.Messages;
|
||||||
import net.citizensnpcs.util.NMS;
|
import net.citizensnpcs.util.NMS;
|
||||||
|
import net.citizensnpcs.util.Util;
|
||||||
|
|
||||||
@TraitName("shulkertrait")
|
@TraitName("shulkertrait")
|
||||||
public class ShulkerTrait extends Trait {
|
public class ShulkerTrait extends Trait {
|
||||||
@ -55,4 +66,37 @@ public class ShulkerTrait extends Trait {
|
|||||||
this.peek = peek;
|
this.peek = peek;
|
||||||
lastPeekSet = -1;
|
lastPeekSet = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Command(
|
||||||
|
aliases = { "npc" },
|
||||||
|
usage = "shulker (--peek [peek] --color [color])",
|
||||||
|
desc = "Sets shulker modifiers.",
|
||||||
|
modifiers = { "shulker" },
|
||||||
|
min = 1,
|
||||||
|
max = 1,
|
||||||
|
permission = "citizens.npc.shulker")
|
||||||
|
@Requirements(selected = true, ownership = true, types = { EntityType.SHULKER })
|
||||||
|
public static void shulker(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
|
ShulkerTrait trait = npc.getOrAddTrait(ShulkerTrait.class);
|
||||||
|
boolean hasArg = false;
|
||||||
|
if (args.hasValueFlag("peek")) {
|
||||||
|
int peek = (byte) args.getFlagInteger("peek");
|
||||||
|
trait.setPeek(peek);
|
||||||
|
Messaging.sendTr(sender, Messages.SHULKER_PEEK_SET, npc.getName(), peek);
|
||||||
|
hasArg = true;
|
||||||
|
}
|
||||||
|
if (args.hasValueFlag("color")) {
|
||||||
|
DyeColor color = Util.matchEnum(DyeColor.values(), args.getFlag("color"));
|
||||||
|
if (color == null) {
|
||||||
|
Messaging.sendErrorTr(sender, Messages.INVALID_SHULKER_COLOR, Util.listValuesPretty(DyeColor.values()));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
trait.setColor(color);
|
||||||
|
Messaging.sendTr(sender, Messages.SHULKER_COLOR_SET, npc.getName(), Util.prettyEnum(color));
|
||||||
|
hasArg = true;
|
||||||
|
}
|
||||||
|
if (!hasArg) {
|
||||||
|
throw new CommandUsageException();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,20 @@
|
|||||||
package net.citizensnpcs.trait.versioned;
|
package net.citizensnpcs.trait.versioned;
|
||||||
|
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.Snowman;
|
import org.bukkit.entity.Snowman;
|
||||||
|
|
||||||
|
import net.citizensnpcs.api.command.Command;
|
||||||
|
import net.citizensnpcs.api.command.CommandContext;
|
||||||
|
import net.citizensnpcs.api.command.Requirements;
|
||||||
|
import net.citizensnpcs.api.command.exception.CommandException;
|
||||||
|
import net.citizensnpcs.api.command.exception.CommandUsageException;
|
||||||
|
import net.citizensnpcs.api.npc.NPC;
|
||||||
import net.citizensnpcs.api.persistence.Persist;
|
import net.citizensnpcs.api.persistence.Persist;
|
||||||
import net.citizensnpcs.api.trait.Trait;
|
import net.citizensnpcs.api.trait.Trait;
|
||||||
import net.citizensnpcs.api.trait.TraitName;
|
import net.citizensnpcs.api.trait.TraitName;
|
||||||
|
import net.citizensnpcs.api.util.Messaging;
|
||||||
|
import net.citizensnpcs.util.Messages;
|
||||||
|
|
||||||
@TraitName("snowmantrait")
|
@TraitName("snowmantrait")
|
||||||
public class SnowmanTrait extends Trait {
|
public class SnowmanTrait extends Trait {
|
||||||
@ -33,4 +43,27 @@ public class SnowmanTrait extends Trait {
|
|||||||
public boolean toggleDerp() {
|
public boolean toggleDerp() {
|
||||||
return this.derp = !this.derp;
|
return this.derp = !this.derp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Command(
|
||||||
|
aliases = { "npc" },
|
||||||
|
usage = "snowman (-d[erp])",
|
||||||
|
desc = "Sets snowman modifiers.",
|
||||||
|
modifiers = { "snowman" },
|
||||||
|
min = 1,
|
||||||
|
max = 1,
|
||||||
|
flags = "d",
|
||||||
|
permission = "citizens.npc.snowman")
|
||||||
|
@Requirements(selected = true, ownership = true, types = { EntityType.SNOWMAN })
|
||||||
|
public static void snowman(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
|
SnowmanTrait trait = npc.getOrAddTrait(SnowmanTrait.class);
|
||||||
|
boolean hasArg = false;
|
||||||
|
if (args.hasFlag('d')) {
|
||||||
|
boolean isDerp = trait.toggleDerp();
|
||||||
|
Messaging.sendTr(sender, isDerp ? Messages.SNOWMAN_DERP_SET : Messages.SNOWMAN_DERP_STOPPED, npc.getName());
|
||||||
|
hasArg = true;
|
||||||
|
}
|
||||||
|
if (!hasArg) {
|
||||||
|
throw new CommandUsageException();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,23 @@
|
|||||||
package net.citizensnpcs.trait.versioned;
|
package net.citizensnpcs.trait.versioned;
|
||||||
|
|
||||||
import org.bukkit.DyeColor;
|
import org.bukkit.DyeColor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.TropicalFish;
|
import org.bukkit.entity.TropicalFish;
|
||||||
import org.bukkit.entity.TropicalFish.Pattern;
|
import org.bukkit.entity.TropicalFish.Pattern;
|
||||||
|
|
||||||
|
import net.citizensnpcs.api.command.Command;
|
||||||
|
import net.citizensnpcs.api.command.CommandContext;
|
||||||
|
import net.citizensnpcs.api.command.Requirements;
|
||||||
|
import net.citizensnpcs.api.command.exception.CommandException;
|
||||||
|
import net.citizensnpcs.api.command.exception.CommandUsageException;
|
||||||
|
import net.citizensnpcs.api.npc.NPC;
|
||||||
import net.citizensnpcs.api.persistence.Persist;
|
import net.citizensnpcs.api.persistence.Persist;
|
||||||
import net.citizensnpcs.api.trait.Trait;
|
import net.citizensnpcs.api.trait.Trait;
|
||||||
import net.citizensnpcs.api.trait.TraitName;
|
import net.citizensnpcs.api.trait.TraitName;
|
||||||
|
import net.citizensnpcs.api.util.Messaging;
|
||||||
|
import net.citizensnpcs.util.Messages;
|
||||||
|
import net.citizensnpcs.util.Util;
|
||||||
|
|
||||||
@TraitName("tropicalfishtrait")
|
@TraitName("tropicalfishtrait")
|
||||||
public class TropicalFishTrait extends Trait {
|
public class TropicalFishTrait extends Trait {
|
||||||
@ -54,4 +65,50 @@ public class TropicalFishTrait extends Trait {
|
|||||||
public void setPatternColor(DyeColor color) {
|
public void setPatternColor(DyeColor color) {
|
||||||
this.patternColor = color;
|
this.patternColor = color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Command(
|
||||||
|
aliases = { "npc" },
|
||||||
|
usage = "tfish (--body color) (--pattern pattern) (--patterncolor color)",
|
||||||
|
desc = "Sets tropical fish modifiers",
|
||||||
|
modifiers = { "tfish" },
|
||||||
|
min = 1,
|
||||||
|
max = 1,
|
||||||
|
permission = "citizens.npc.tropicalfish")
|
||||||
|
@Requirements(selected = true, ownership = true, types = EntityType.TROPICAL_FISH)
|
||||||
|
public static void tropicalfish(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
|
TropicalFishTrait trait = npc.getOrAddTrait(TropicalFishTrait.class);
|
||||||
|
String output = "";
|
||||||
|
if (args.hasValueFlag("body")) {
|
||||||
|
DyeColor color = Util.matchEnum(DyeColor.values(), args.getFlag("body"));
|
||||||
|
if (color == null) {
|
||||||
|
throw new CommandException(Messages.INVALID_TROPICALFISH_COLOR,
|
||||||
|
Util.listValuesPretty(DyeColor.values()));
|
||||||
|
}
|
||||||
|
trait.setBodyColor(color);
|
||||||
|
output += Messaging.tr(Messages.TROPICALFISH_BODY_COLOR_SET, Util.prettyEnum(color));
|
||||||
|
}
|
||||||
|
if (args.hasValueFlag("patterncolor")) {
|
||||||
|
DyeColor color = Util.matchEnum(DyeColor.values(), args.getFlag("patterncolor"));
|
||||||
|
if (color == null) {
|
||||||
|
throw new CommandException(Messages.INVALID_TROPICALFISH_COLOR,
|
||||||
|
Util.listValuesPretty(DyeColor.values()));
|
||||||
|
}
|
||||||
|
trait.setPatternColor(color);
|
||||||
|
output += Messaging.tr(Messages.TROPICALFISH_PATTERN_COLOR_SET, Util.prettyEnum(color));
|
||||||
|
}
|
||||||
|
if (args.hasValueFlag("pattern")) {
|
||||||
|
Pattern pattern = Util.matchEnum(Pattern.values(), args.getFlag("pattern"));
|
||||||
|
if (pattern == null) {
|
||||||
|
throw new CommandException(Messages.INVALID_TROPICALFISH_PATTERN,
|
||||||
|
Util.listValuesPretty(Pattern.values()));
|
||||||
|
}
|
||||||
|
trait.setPattern(pattern);
|
||||||
|
output += Messaging.tr(Messages.TROPICALFISH_PATTERN_SET, Util.prettyEnum(pattern));
|
||||||
|
}
|
||||||
|
if (!output.isEmpty()) {
|
||||||
|
Messaging.send(sender, output);
|
||||||
|
} else {
|
||||||
|
throw new CommandUsageException();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,25 @@
|
|||||||
package net.citizensnpcs.trait.versioned;
|
package net.citizensnpcs.trait.versioned;
|
||||||
|
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.Villager;
|
import org.bukkit.entity.Villager;
|
||||||
|
import org.bukkit.entity.Villager.Profession;
|
||||||
|
|
||||||
|
import com.google.common.base.Joiner;
|
||||||
|
|
||||||
|
import net.citizensnpcs.api.command.Command;
|
||||||
|
import net.citizensnpcs.api.command.CommandContext;
|
||||||
|
import net.citizensnpcs.api.command.Requirements;
|
||||||
|
import net.citizensnpcs.api.command.exception.CommandException;
|
||||||
|
import net.citizensnpcs.api.command.exception.CommandUsageException;
|
||||||
|
import net.citizensnpcs.api.npc.NPC;
|
||||||
import net.citizensnpcs.api.persistence.Persist;
|
import net.citizensnpcs.api.persistence.Persist;
|
||||||
import net.citizensnpcs.api.trait.Trait;
|
import net.citizensnpcs.api.trait.Trait;
|
||||||
import net.citizensnpcs.api.trait.TraitName;
|
import net.citizensnpcs.api.trait.TraitName;
|
||||||
|
import net.citizensnpcs.api.util.Messaging;
|
||||||
|
import net.citizensnpcs.trait.VillagerProfession;
|
||||||
|
import net.citizensnpcs.util.Messages;
|
||||||
|
import net.citizensnpcs.util.Util;
|
||||||
|
|
||||||
@TraitName("villagertrait")
|
@TraitName("villagertrait")
|
||||||
public class VillagerTrait extends Trait {
|
public class VillagerTrait extends Trait {
|
||||||
@ -43,4 +58,48 @@ public class VillagerTrait extends Trait {
|
|||||||
public void setType(Villager.Type type) {
|
public void setType(Villager.Type type) {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Command(
|
||||||
|
aliases = { "npc" },
|
||||||
|
usage = "villager (--level level) (--type type) (--profession profession)",
|
||||||
|
desc = "Sets villager modifiers",
|
||||||
|
modifiers = { "villager" },
|
||||||
|
min = 1,
|
||||||
|
max = 1,
|
||||||
|
permission = "citizens.npc.villager")
|
||||||
|
@Requirements(selected = true, ownership = true, types = EntityType.VILLAGER)
|
||||||
|
public static void villager(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
|
VillagerTrait trait = npc.getOrAddTrait(VillagerTrait.class);
|
||||||
|
String output = "";
|
||||||
|
if (args.hasValueFlag("level")) {
|
||||||
|
if (args.getFlagInteger("level") < 0) {
|
||||||
|
throw new CommandUsageException();
|
||||||
|
}
|
||||||
|
trait.setLevel(args.getFlagInteger("level"));
|
||||||
|
output += " " + Messaging.tr(Messages.VILLAGER_LEVEL_SET, args.getFlagInteger("level"));
|
||||||
|
}
|
||||||
|
if (args.hasValueFlag("type")) {
|
||||||
|
Villager.Type type = Util.matchEnum(Villager.Type.values(), args.getFlag("type"));
|
||||||
|
if (type == null) {
|
||||||
|
throw new CommandException(Messages.INVALID_VILLAGER_TYPE,
|
||||||
|
Util.listValuesPretty(Villager.Type.values()));
|
||||||
|
}
|
||||||
|
trait.setType(type);
|
||||||
|
output += " " + Messaging.tr(Messages.VILLAGER_TYPE_SET, args.getFlag("type"));
|
||||||
|
}
|
||||||
|
if (args.hasValueFlag("profession")) {
|
||||||
|
Profession parsed = Util.matchEnum(Profession.values(), args.getFlag("profession"));
|
||||||
|
if (parsed == null) {
|
||||||
|
throw new CommandException(Messages.INVALID_PROFESSION, args.getFlag("profession"),
|
||||||
|
Joiner.on(',').join(Profession.values()));
|
||||||
|
}
|
||||||
|
npc.getOrAddTrait(VillagerProfession.class).setProfession(parsed);
|
||||||
|
output += " " + Messaging.tr(Messages.PROFESSION_SET, npc.getName(), args.getFlag("profession"));
|
||||||
|
}
|
||||||
|
if (!output.isEmpty()) {
|
||||||
|
Messaging.send(sender, output.trim());
|
||||||
|
} else {
|
||||||
|
throw new CommandUsageException();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,10 +3,9 @@ package net.citizensnpcs.util;
|
|||||||
import org.apache.commons.lang.builder.EqualsBuilder;
|
import org.apache.commons.lang.builder.EqualsBuilder;
|
||||||
import org.apache.commons.lang.builder.HashCodeBuilder;
|
import org.apache.commons.lang.builder.HashCodeBuilder;
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Pose object which holds yaw/pitch of the head with a name to identify.
|
* A named head yaw/pitch
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class Pose {
|
public class Pose {
|
||||||
private final String name;
|
private final String name;
|
||||||
private final float pitch;
|
private final float pitch;
|
||||||
|
@ -1,155 +0,0 @@
|
|||||||
package net.citizensnpcs.nms.v1_10_R1.trait;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.bukkit.DyeColor;
|
|
||||||
import org.bukkit.boss.BarColor;
|
|
||||||
import org.bukkit.boss.BarFlag;
|
|
||||||
import org.bukkit.boss.BarStyle;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.EntityType;
|
|
||||||
|
|
||||||
import com.google.common.base.Splitter;
|
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
|
|
||||||
import net.citizensnpcs.api.command.Command;
|
|
||||||
import net.citizensnpcs.api.command.CommandContext;
|
|
||||||
import net.citizensnpcs.api.command.Requirements;
|
|
||||||
import net.citizensnpcs.api.command.exception.CommandException;
|
|
||||||
import net.citizensnpcs.api.command.exception.CommandUsageException;
|
|
||||||
import net.citizensnpcs.api.npc.NPC;
|
|
||||||
import net.citizensnpcs.api.util.Colorizer;
|
|
||||||
import net.citizensnpcs.api.util.Messaging;
|
|
||||||
import net.citizensnpcs.trait.versioned.BossBarTrait;
|
|
||||||
import net.citizensnpcs.trait.versioned.PolarBearTrait;
|
|
||||||
import net.citizensnpcs.trait.versioned.ShulkerTrait;
|
|
||||||
import net.citizensnpcs.trait.versioned.SnowmanTrait;
|
|
||||||
import net.citizensnpcs.util.Messages;
|
|
||||||
import net.citizensnpcs.util.Util;
|
|
||||||
|
|
||||||
public class Commands {
|
|
||||||
@Command(
|
|
||||||
aliases = { "npc" },
|
|
||||||
usage = "bossbar --style [style] --color [color] --title [title] --visible [visible] --flags [flags] --track [health | placeholder]",
|
|
||||||
desc = "Edit bossbar properties",
|
|
||||||
modifiers = { "bossbar" },
|
|
||||||
min = 1,
|
|
||||||
max = 1)
|
|
||||||
@Requirements(selected = true, ownership = true)
|
|
||||||
public void bossbar(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
BossBarTrait trait = npc.getOrAddTrait(BossBarTrait.class);
|
|
||||||
if (args.hasValueFlag("style")) {
|
|
||||||
BarStyle style = Util.matchEnum(BarStyle.values(), args.getFlag("style"));
|
|
||||||
if (style != null) {
|
|
||||||
trait.setStyle(style);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (args.hasValueFlag("color")) {
|
|
||||||
BarColor color = Util.matchEnum(BarColor.values(), args.getFlag("color"));
|
|
||||||
if (color != null) {
|
|
||||||
trait.setColor(color);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (args.hasValueFlag("track")) {
|
|
||||||
trait.setTrackVariable(args.getFlag("track"));
|
|
||||||
}
|
|
||||||
if (args.hasValueFlag("title")) {
|
|
||||||
trait.setTitle(Colorizer.parseColors(args.getFlag("title")));
|
|
||||||
}
|
|
||||||
if (args.hasValueFlag("visible")) {
|
|
||||||
trait.setVisible(Boolean.parseBoolean(args.getFlag("visible")));
|
|
||||||
}
|
|
||||||
if (args.hasValueFlag("flags")) {
|
|
||||||
List<BarFlag> flags = Lists.newArrayList();
|
|
||||||
for (String s : Splitter.on(',').omitEmptyStrings().trimResults().split(args.getFlag("flags"))) {
|
|
||||||
BarFlag flag = Util.matchEnum(BarFlag.values(), s);
|
|
||||||
if (flag != null) {
|
|
||||||
flags.add(flag);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
trait.setFlags(flags);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
aliases = { "npc" },
|
|
||||||
usage = "polarbear (-r)",
|
|
||||||
desc = "Sets polarbear modifiers.",
|
|
||||||
modifiers = { "polarbear" },
|
|
||||||
min = 1,
|
|
||||||
max = 1,
|
|
||||||
flags = "r",
|
|
||||||
permission = "citizens.npc.polarbear")
|
|
||||||
@Requirements(selected = true, ownership = true, types = { EntityType.POLAR_BEAR })
|
|
||||||
public void polarbear(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
PolarBearTrait trait = npc.getOrAddTrait(PolarBearTrait.class);
|
|
||||||
String output = "";
|
|
||||||
if (args.hasFlag('r')) {
|
|
||||||
trait.setRearing(!trait.isRearing());
|
|
||||||
output += Messaging.tr(
|
|
||||||
trait.isRearing() ? Messages.POLAR_BEAR_REARING : Messages.POLAR_BEAR_STOPPED_REARING,
|
|
||||||
npc.getName());
|
|
||||||
}
|
|
||||||
if (!output.isEmpty()) {
|
|
||||||
Messaging.send(sender, output);
|
|
||||||
} else {
|
|
||||||
throw new CommandUsageException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
aliases = { "npc" },
|
|
||||||
usage = "shulker (--peek [peek] --color [color])",
|
|
||||||
desc = "Sets shulker modifiers.",
|
|
||||||
modifiers = { "shulker" },
|
|
||||||
min = 1,
|
|
||||||
max = 1,
|
|
||||||
permission = "citizens.npc.shulker")
|
|
||||||
@Requirements(selected = true, ownership = true, types = { EntityType.SHULKER })
|
|
||||||
public void shulker(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
ShulkerTrait trait = npc.getOrAddTrait(ShulkerTrait.class);
|
|
||||||
boolean hasArg = false;
|
|
||||||
if (args.hasValueFlag("peek")) {
|
|
||||||
int peek = (byte) args.getFlagInteger("peek");
|
|
||||||
trait.setPeek(peek);
|
|
||||||
Messaging.sendTr(sender, Messages.SHULKER_PEEK_SET, npc.getName(), peek);
|
|
||||||
hasArg = true;
|
|
||||||
}
|
|
||||||
if (args.hasValueFlag("color")) {
|
|
||||||
DyeColor color = Util.matchEnum(DyeColor.values(), args.getFlag("color"));
|
|
||||||
if (color == null) {
|
|
||||||
Messaging.sendErrorTr(sender, Messages.INVALID_SHULKER_COLOR, Util.listValuesPretty(DyeColor.values()));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
trait.setColor(color);
|
|
||||||
Messaging.sendTr(sender, Messages.SHULKER_COLOR_SET, npc.getName(), Util.prettyEnum(color));
|
|
||||||
hasArg = true;
|
|
||||||
}
|
|
||||||
if (!hasArg) {
|
|
||||||
throw new CommandUsageException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
aliases = { "npc" },
|
|
||||||
usage = "snowman (-d[erp])",
|
|
||||||
desc = "Sets snowman modifiers.",
|
|
||||||
modifiers = { "snowman" },
|
|
||||||
min = 1,
|
|
||||||
max = 1,
|
|
||||||
flags = "d",
|
|
||||||
permission = "citizens.npc.snowman")
|
|
||||||
@Requirements(selected = true, ownership = true, types = { EntityType.SNOWMAN })
|
|
||||||
public void snowman(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
SnowmanTrait trait = npc.getOrAddTrait(SnowmanTrait.class);
|
|
||||||
boolean hasArg = false;
|
|
||||||
if (args.hasFlag('d')) {
|
|
||||||
boolean isDerp = trait.toggleDerp();
|
|
||||||
Messaging.sendTr(sender, isDerp ? Messages.SNOWMAN_DERP_SET : Messages.SNOWMAN_DERP_STOPPED, npc.getName());
|
|
||||||
hasArg = true;
|
|
||||||
}
|
|
||||||
if (!hasArg) {
|
|
||||||
throw new CommandUsageException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -73,6 +73,7 @@ import net.citizensnpcs.api.npc.BlockBreaker;
|
|||||||
import net.citizensnpcs.api.npc.BlockBreaker.BlockBreakerConfiguration;
|
import net.citizensnpcs.api.npc.BlockBreaker.BlockBreakerConfiguration;
|
||||||
import net.citizensnpcs.api.npc.NPC;
|
import net.citizensnpcs.api.npc.NPC;
|
||||||
import net.citizensnpcs.api.npc.NPCRegistry;
|
import net.citizensnpcs.api.npc.NPCRegistry;
|
||||||
|
import net.citizensnpcs.api.trait.Trait;
|
||||||
import net.citizensnpcs.api.trait.TraitInfo;
|
import net.citizensnpcs.api.trait.TraitInfo;
|
||||||
import net.citizensnpcs.api.util.BoundingBox;
|
import net.citizensnpcs.api.util.BoundingBox;
|
||||||
import net.citizensnpcs.api.util.Messaging;
|
import net.citizensnpcs.api.util.Messaging;
|
||||||
@ -144,7 +145,6 @@ import net.citizensnpcs.nms.v1_10_R1.entity.nonliving.ThrownPotionController;
|
|||||||
import net.citizensnpcs.nms.v1_10_R1.entity.nonliving.TippedArrowController;
|
import net.citizensnpcs.nms.v1_10_R1.entity.nonliving.TippedArrowController;
|
||||||
import net.citizensnpcs.nms.v1_10_R1.entity.nonliving.WitherSkullController;
|
import net.citizensnpcs.nms.v1_10_R1.entity.nonliving.WitherSkullController;
|
||||||
import net.citizensnpcs.nms.v1_10_R1.network.EmptyChannel;
|
import net.citizensnpcs.nms.v1_10_R1.network.EmptyChannel;
|
||||||
import net.citizensnpcs.nms.v1_10_R1.trait.Commands;
|
|
||||||
import net.citizensnpcs.npc.EntityControllers;
|
import net.citizensnpcs.npc.EntityControllers;
|
||||||
import net.citizensnpcs.npc.ai.MCNavigationStrategy.MCNavigator;
|
import net.citizensnpcs.npc.ai.MCNavigationStrategy.MCNavigator;
|
||||||
import net.citizensnpcs.npc.ai.MCTargetStrategy.TargetNavigator;
|
import net.citizensnpcs.npc.ai.MCTargetStrategy.TargetNavigator;
|
||||||
@ -626,12 +626,11 @@ public class NMSImpl implements NMSBridge {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void load(CommandManager commands) {
|
public void load(CommandManager manager) {
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(BossBarTrait.class));
|
registerTraitWithCommand(manager, BossBarTrait.class);
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(ShulkerTrait.class));
|
registerTraitWithCommand(manager, PolarBearTrait.class);
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(SnowmanTrait.class));
|
registerTraitWithCommand(manager, ShulkerTrait.class);
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(PolarBearTrait.class));
|
registerTraitWithCommand(manager, SnowmanTrait.class);
|
||||||
commands.register(Commands.class);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadEntityTypes() {
|
private void loadEntityTypes() {
|
||||||
@ -880,6 +879,11 @@ public class NMSImpl implements NMSBridge {
|
|||||||
throw new IllegalArgumentException("unable to find valid entity superclass for class " + clazz.toString());
|
throw new IllegalArgumentException("unable to find valid entity superclass for class " + clazz.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void registerTraitWithCommand(CommandManager manager, Class<? extends Trait> clazz) {
|
||||||
|
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(clazz));
|
||||||
|
manager.register(clazz);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void remove(org.bukkit.entity.Entity entity) {
|
public void remove(org.bukkit.entity.Entity entity) {
|
||||||
NMSImpl.getHandle(entity).die();
|
NMSImpl.getHandle(entity).die();
|
||||||
|
@ -1,196 +0,0 @@
|
|||||||
package net.citizensnpcs.nms.v1_11_R1.trait;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.bukkit.DyeColor;
|
|
||||||
import org.bukkit.boss.BarColor;
|
|
||||||
import org.bukkit.boss.BarFlag;
|
|
||||||
import org.bukkit.boss.BarStyle;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.EntityType;
|
|
||||||
import org.bukkit.entity.Llama.Color;
|
|
||||||
|
|
||||||
import com.google.common.base.Splitter;
|
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
|
|
||||||
import net.citizensnpcs.api.command.Command;
|
|
||||||
import net.citizensnpcs.api.command.CommandContext;
|
|
||||||
import net.citizensnpcs.api.command.Requirements;
|
|
||||||
import net.citizensnpcs.api.command.exception.CommandException;
|
|
||||||
import net.citizensnpcs.api.command.exception.CommandUsageException;
|
|
||||||
import net.citizensnpcs.api.npc.NPC;
|
|
||||||
import net.citizensnpcs.api.util.Colorizer;
|
|
||||||
import net.citizensnpcs.api.util.Messaging;
|
|
||||||
import net.citizensnpcs.trait.HorseModifiers;
|
|
||||||
import net.citizensnpcs.trait.versioned.BossBarTrait;
|
|
||||||
import net.citizensnpcs.trait.versioned.LlamaTrait;
|
|
||||||
import net.citizensnpcs.trait.versioned.PolarBearTrait;
|
|
||||||
import net.citizensnpcs.trait.versioned.ShulkerTrait;
|
|
||||||
import net.citizensnpcs.trait.versioned.SnowmanTrait;
|
|
||||||
import net.citizensnpcs.util.Messages;
|
|
||||||
import net.citizensnpcs.util.Util;
|
|
||||||
|
|
||||||
public class Commands {
|
|
||||||
@Command(
|
|
||||||
aliases = { "npc" },
|
|
||||||
usage = "bossbar --style [style] --color [color] --title [title] --visible [visible] --flags [flags] --track [health | placeholder]",
|
|
||||||
desc = "Edit bossbar properties",
|
|
||||||
modifiers = { "bossbar" },
|
|
||||||
min = 1,
|
|
||||||
max = 1)
|
|
||||||
@Requirements(selected = true, ownership = true)
|
|
||||||
public void bossbar(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
BossBarTrait trait = npc.getOrAddTrait(BossBarTrait.class);
|
|
||||||
if (args.hasValueFlag("style")) {
|
|
||||||
BarStyle style = Util.matchEnum(BarStyle.values(), args.getFlag("style"));
|
|
||||||
if (style != null) {
|
|
||||||
trait.setStyle(style);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (args.hasValueFlag("color")) {
|
|
||||||
BarColor color = Util.matchEnum(BarColor.values(), args.getFlag("color"));
|
|
||||||
if (color != null) {
|
|
||||||
trait.setColor(color);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (args.hasValueFlag("track")) {
|
|
||||||
trait.setTrackVariable(args.getFlag("track"));
|
|
||||||
}
|
|
||||||
if (args.hasValueFlag("title")) {
|
|
||||||
trait.setTitle(Colorizer.parseColors(args.getFlag("title")));
|
|
||||||
}
|
|
||||||
if (args.hasValueFlag("visible")) {
|
|
||||||
trait.setVisible(Boolean.parseBoolean(args.getFlag("visible")));
|
|
||||||
}
|
|
||||||
if (args.hasValueFlag("flags")) {
|
|
||||||
List<BarFlag> flags = Lists.newArrayList();
|
|
||||||
for (String s : Splitter.on(',').omitEmptyStrings().trimResults().split(args.getFlag("flags"))) {
|
|
||||||
BarFlag flag = Util.matchEnum(BarFlag.values(), s);
|
|
||||||
if (flag != null) {
|
|
||||||
flags.add(flag);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
trait.setFlags(flags);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
aliases = { "npc" },
|
|
||||||
usage = "llama (--color color) (--strength strength)",
|
|
||||||
desc = "Sets llama modifiers",
|
|
||||||
modifiers = { "llama" },
|
|
||||||
min = 1,
|
|
||||||
max = 1,
|
|
||||||
permission = "citizens.npc.llama")
|
|
||||||
@Requirements(selected = true, ownership = true, types = EntityType.LLAMA)
|
|
||||||
public void llama(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
LlamaTrait trait = npc.getOrAddTrait(LlamaTrait.class);
|
|
||||||
String output = "";
|
|
||||||
if (args.hasValueFlag("color") || args.hasValueFlag("colour")) {
|
|
||||||
String colorRaw = args.getFlag("color", args.getFlag("colour"));
|
|
||||||
Color color = Util.matchEnum(Color.values(), colorRaw);
|
|
||||||
if (color == null) {
|
|
||||||
String valid = Util.listValuesPretty(Color.values());
|
|
||||||
throw new CommandException(Messages.INVALID_LLAMA_COLOR, valid);
|
|
||||||
}
|
|
||||||
trait.setColor(color);
|
|
||||||
output += Messaging.tr(Messages.LLAMA_COLOR_SET, Util.prettyEnum(color));
|
|
||||||
}
|
|
||||||
if (args.hasValueFlag("strength")) {
|
|
||||||
trait.setStrength(Math.max(1, Math.min(5, args.getFlagInteger("strength"))));
|
|
||||||
output += Messaging.tr(Messages.LLAMA_STRENGTH_SET, args.getFlagInteger("strength"));
|
|
||||||
}
|
|
||||||
if (args.hasFlag('c')) {
|
|
||||||
npc.getOrAddTrait(HorseModifiers.class).setCarryingChest(true);
|
|
||||||
output += Messaging.tr(Messages.HORSE_CHEST_SET) + " ";
|
|
||||||
} else if (args.hasFlag('b')) {
|
|
||||||
npc.getOrAddTrait(HorseModifiers.class).setCarryingChest(false);
|
|
||||||
output += Messaging.tr(Messages.HORSE_CHEST_UNSET) + " ";
|
|
||||||
}
|
|
||||||
if (!output.isEmpty()) {
|
|
||||||
Messaging.send(sender, output);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
aliases = { "npc" },
|
|
||||||
usage = "polarbear (-r)",
|
|
||||||
desc = "Sets polarbear modifiers.",
|
|
||||||
modifiers = { "polarbear" },
|
|
||||||
min = 1,
|
|
||||||
max = 1,
|
|
||||||
flags = "r",
|
|
||||||
permission = "citizens.npc.polarbear")
|
|
||||||
@Requirements(selected = true, ownership = true, types = { EntityType.POLAR_BEAR })
|
|
||||||
public void polarbear(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
PolarBearTrait trait = npc.getOrAddTrait(PolarBearTrait.class);
|
|
||||||
String output = "";
|
|
||||||
if (args.hasFlag('r')) {
|
|
||||||
trait.setRearing(!trait.isRearing());
|
|
||||||
output += Messaging.tr(
|
|
||||||
trait.isRearing() ? Messages.POLAR_BEAR_REARING : Messages.POLAR_BEAR_STOPPED_REARING,
|
|
||||||
npc.getName());
|
|
||||||
}
|
|
||||||
if (!output.isEmpty()) {
|
|
||||||
Messaging.send(sender, output);
|
|
||||||
} else {
|
|
||||||
throw new CommandUsageException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
aliases = { "npc" },
|
|
||||||
usage = "shulker (--peek [peek] --color [color])",
|
|
||||||
desc = "Sets shulker modifiers.",
|
|
||||||
modifiers = { "shulker" },
|
|
||||||
min = 1,
|
|
||||||
max = 1,
|
|
||||||
permission = "citizens.npc.shulker")
|
|
||||||
@Requirements(selected = true, ownership = true, types = { EntityType.SHULKER })
|
|
||||||
public void shulker(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
ShulkerTrait trait = npc.getOrAddTrait(ShulkerTrait.class);
|
|
||||||
boolean hasArg = false;
|
|
||||||
if (args.hasValueFlag("peek")) {
|
|
||||||
int peek = (byte) args.getFlagInteger("peek");
|
|
||||||
trait.setPeek(peek);
|
|
||||||
Messaging.sendTr(sender, Messages.SHULKER_PEEK_SET, npc.getName(), peek);
|
|
||||||
hasArg = true;
|
|
||||||
}
|
|
||||||
if (args.hasValueFlag("color")) {
|
|
||||||
DyeColor color = Util.matchEnum(DyeColor.values(), args.getFlag("color"));
|
|
||||||
if (color == null) {
|
|
||||||
Messaging.sendErrorTr(sender, Messages.INVALID_SHULKER_COLOR, Util.listValuesPretty(DyeColor.values()));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
trait.setColor(color);
|
|
||||||
Messaging.sendTr(sender, Messages.SHULKER_COLOR_SET, npc.getName(), Util.prettyEnum(color));
|
|
||||||
hasArg = true;
|
|
||||||
}
|
|
||||||
if (!hasArg) {
|
|
||||||
throw new CommandUsageException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
aliases = { "npc" },
|
|
||||||
usage = "snowman (-d[erp])",
|
|
||||||
desc = "Sets snowman modifiers.",
|
|
||||||
modifiers = { "snowman" },
|
|
||||||
min = 1,
|
|
||||||
max = 1,
|
|
||||||
flags = "d",
|
|
||||||
permission = "citizens.npc.snowman")
|
|
||||||
@Requirements(selected = true, ownership = true, types = { EntityType.SNOWMAN })
|
|
||||||
public void snowman(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
SnowmanTrait trait = npc.getOrAddTrait(SnowmanTrait.class);
|
|
||||||
boolean hasArg = false;
|
|
||||||
if (args.hasFlag('d')) {
|
|
||||||
boolean isDerp = trait.toggleDerp();
|
|
||||||
Messaging.sendTr(sender, isDerp ? Messages.SNOWMAN_DERP_SET : Messages.SNOWMAN_DERP_STOPPED, npc.getName());
|
|
||||||
hasArg = true;
|
|
||||||
}
|
|
||||||
if (!hasArg) {
|
|
||||||
throw new CommandUsageException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -72,6 +72,7 @@ import net.citizensnpcs.api.npc.BlockBreaker;
|
|||||||
import net.citizensnpcs.api.npc.BlockBreaker.BlockBreakerConfiguration;
|
import net.citizensnpcs.api.npc.BlockBreaker.BlockBreakerConfiguration;
|
||||||
import net.citizensnpcs.api.npc.NPC;
|
import net.citizensnpcs.api.npc.NPC;
|
||||||
import net.citizensnpcs.api.npc.NPCRegistry;
|
import net.citizensnpcs.api.npc.NPCRegistry;
|
||||||
|
import net.citizensnpcs.api.trait.Trait;
|
||||||
import net.citizensnpcs.api.trait.TraitInfo;
|
import net.citizensnpcs.api.trait.TraitInfo;
|
||||||
import net.citizensnpcs.api.util.BoundingBox;
|
import net.citizensnpcs.api.util.BoundingBox;
|
||||||
import net.citizensnpcs.api.util.Messaging;
|
import net.citizensnpcs.api.util.Messaging;
|
||||||
@ -158,7 +159,6 @@ import net.citizensnpcs.nms.v1_11_R1.entity.nonliving.ThrownPotionController;
|
|||||||
import net.citizensnpcs.nms.v1_11_R1.entity.nonliving.TippedArrowController;
|
import net.citizensnpcs.nms.v1_11_R1.entity.nonliving.TippedArrowController;
|
||||||
import net.citizensnpcs.nms.v1_11_R1.entity.nonliving.WitherSkullController;
|
import net.citizensnpcs.nms.v1_11_R1.entity.nonliving.WitherSkullController;
|
||||||
import net.citizensnpcs.nms.v1_11_R1.network.EmptyChannel;
|
import net.citizensnpcs.nms.v1_11_R1.network.EmptyChannel;
|
||||||
import net.citizensnpcs.nms.v1_11_R1.trait.Commands;
|
|
||||||
import net.citizensnpcs.npc.EntityControllers;
|
import net.citizensnpcs.npc.EntityControllers;
|
||||||
import net.citizensnpcs.npc.ai.MCNavigationStrategy.MCNavigator;
|
import net.citizensnpcs.npc.ai.MCNavigationStrategy.MCNavigator;
|
||||||
import net.citizensnpcs.npc.ai.MCTargetStrategy.TargetNavigator;
|
import net.citizensnpcs.npc.ai.MCTargetStrategy.TargetNavigator;
|
||||||
@ -665,12 +665,11 @@ public class NMSImpl implements NMSBridge {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void load(CommandManager manager) {
|
public void load(CommandManager manager) {
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(BossBarTrait.class));
|
registerTraitWithCommand(manager, BossBarTrait.class);
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(ShulkerTrait.class));
|
registerTraitWithCommand(manager, LlamaTrait.class);
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(LlamaTrait.class));
|
registerTraitWithCommand(manager, PolarBearTrait.class);
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(SnowmanTrait.class));
|
registerTraitWithCommand(manager, ShulkerTrait.class);
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(PolarBearTrait.class));
|
registerTraitWithCommand(manager, SnowmanTrait.class);
|
||||||
manager.register(Commands.class);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadEntityTypes() {
|
private void loadEntityTypes() {
|
||||||
@ -936,6 +935,11 @@ public class NMSImpl implements NMSBridge {
|
|||||||
throw new IllegalArgumentException("unable to find valid entity superclass for class " + clazz.toString());
|
throw new IllegalArgumentException("unable to find valid entity superclass for class " + clazz.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void registerTraitWithCommand(CommandManager manager, Class<? extends Trait> clazz) {
|
||||||
|
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(clazz));
|
||||||
|
manager.register(clazz);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void remove(org.bukkit.entity.Entity entity) {
|
public void remove(org.bukkit.entity.Entity entity) {
|
||||||
NMSImpl.getHandle(entity).die();
|
NMSImpl.getHandle(entity).die();
|
||||||
|
@ -1,225 +0,0 @@
|
|||||||
package net.citizensnpcs.nms.v1_12_R1.trait;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.bukkit.DyeColor;
|
|
||||||
import org.bukkit.boss.BarColor;
|
|
||||||
import org.bukkit.boss.BarFlag;
|
|
||||||
import org.bukkit.boss.BarStyle;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.EntityType;
|
|
||||||
import org.bukkit.entity.Llama.Color;
|
|
||||||
import org.bukkit.entity.Parrot.Variant;
|
|
||||||
|
|
||||||
import com.google.common.base.Splitter;
|
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
|
|
||||||
import net.citizensnpcs.api.command.Command;
|
|
||||||
import net.citizensnpcs.api.command.CommandContext;
|
|
||||||
import net.citizensnpcs.api.command.Requirements;
|
|
||||||
import net.citizensnpcs.api.command.exception.CommandException;
|
|
||||||
import net.citizensnpcs.api.command.exception.CommandUsageException;
|
|
||||||
import net.citizensnpcs.api.npc.NPC;
|
|
||||||
import net.citizensnpcs.api.util.Colorizer;
|
|
||||||
import net.citizensnpcs.api.util.Messaging;
|
|
||||||
import net.citizensnpcs.trait.HorseModifiers;
|
|
||||||
import net.citizensnpcs.trait.versioned.BossBarTrait;
|
|
||||||
import net.citizensnpcs.trait.versioned.LlamaTrait;
|
|
||||||
import net.citizensnpcs.trait.versioned.ParrotTrait;
|
|
||||||
import net.citizensnpcs.trait.versioned.PolarBearTrait;
|
|
||||||
import net.citizensnpcs.trait.versioned.ShulkerTrait;
|
|
||||||
import net.citizensnpcs.trait.versioned.SnowmanTrait;
|
|
||||||
import net.citizensnpcs.util.Messages;
|
|
||||||
import net.citizensnpcs.util.Util;
|
|
||||||
|
|
||||||
public class Commands {
|
|
||||||
@Command(
|
|
||||||
aliases = { "npc" },
|
|
||||||
usage = "bossbar --style [style] --color [color] --title [title] --visible [visible] --flags [flags] --track [health | placeholder]",
|
|
||||||
desc = "Edit bossbar properties",
|
|
||||||
modifiers = { "bossbar" },
|
|
||||||
min = 1,
|
|
||||||
max = 1)
|
|
||||||
@Requirements(selected = true, ownership = true)
|
|
||||||
public void bossbar(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
BossBarTrait trait = npc.getOrAddTrait(BossBarTrait.class);
|
|
||||||
if (args.hasValueFlag("style")) {
|
|
||||||
BarStyle style = Util.matchEnum(BarStyle.values(), args.getFlag("style"));
|
|
||||||
if (style != null) {
|
|
||||||
trait.setStyle(style);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (args.hasValueFlag("color")) {
|
|
||||||
BarColor color = Util.matchEnum(BarColor.values(), args.getFlag("color"));
|
|
||||||
if (color != null) {
|
|
||||||
trait.setColor(color);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (args.hasValueFlag("track")) {
|
|
||||||
trait.setTrackVariable(args.getFlag("track"));
|
|
||||||
}
|
|
||||||
if (args.hasValueFlag("title")) {
|
|
||||||
trait.setTitle(Colorizer.parseColors(args.getFlag("title")));
|
|
||||||
}
|
|
||||||
if (args.hasValueFlag("visible")) {
|
|
||||||
trait.setVisible(Boolean.parseBoolean(args.getFlag("visible")));
|
|
||||||
}
|
|
||||||
if (args.hasValueFlag("flags")) {
|
|
||||||
List<BarFlag> flags = Lists.newArrayList();
|
|
||||||
for (String s : Splitter.on(',').omitEmptyStrings().trimResults().split(args.getFlag("flags"))) {
|
|
||||||
BarFlag flag = Util.matchEnum(BarFlag.values(), s);
|
|
||||||
if (flag != null) {
|
|
||||||
flags.add(flag);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
trait.setFlags(flags);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
aliases = { "npc" },
|
|
||||||
usage = "llama (--color color) (--strength strength)",
|
|
||||||
desc = "Sets llama modifiers",
|
|
||||||
modifiers = { "llama" },
|
|
||||||
min = 1,
|
|
||||||
max = 1,
|
|
||||||
permission = "citizens.npc.llama")
|
|
||||||
@Requirements(selected = true, ownership = true, types = EntityType.LLAMA)
|
|
||||||
public void llama(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
LlamaTrait trait = npc.getOrAddTrait(LlamaTrait.class);
|
|
||||||
String output = "";
|
|
||||||
if (args.hasValueFlag("color") || args.hasValueFlag("colour")) {
|
|
||||||
String colorRaw = args.getFlag("color", args.getFlag("colour"));
|
|
||||||
Color color = Util.matchEnum(Color.values(), colorRaw);
|
|
||||||
if (color == null) {
|
|
||||||
String valid = Util.listValuesPretty(Color.values());
|
|
||||||
throw new CommandException(Messages.INVALID_LLAMA_COLOR, valid);
|
|
||||||
}
|
|
||||||
trait.setColor(color);
|
|
||||||
output += Messaging.tr(Messages.LLAMA_COLOR_SET, Util.prettyEnum(color));
|
|
||||||
}
|
|
||||||
if (args.hasValueFlag("strength")) {
|
|
||||||
trait.setStrength(Math.max(1, Math.min(5, args.getFlagInteger("strength"))));
|
|
||||||
output += Messaging.tr(Messages.LLAMA_STRENGTH_SET, args.getFlagInteger("strength"));
|
|
||||||
}
|
|
||||||
if (args.hasFlag('c')) {
|
|
||||||
npc.getOrAddTrait(HorseModifiers.class).setCarryingChest(true);
|
|
||||||
output += Messaging.tr(Messages.HORSE_CHEST_SET) + " ";
|
|
||||||
} else if (args.hasFlag('b')) {
|
|
||||||
npc.getOrAddTrait(HorseModifiers.class).setCarryingChest(false);
|
|
||||||
output += Messaging.tr(Messages.HORSE_CHEST_UNSET) + " ";
|
|
||||||
}
|
|
||||||
if (!output.isEmpty()) {
|
|
||||||
Messaging.send(sender, output);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
aliases = { "npc" },
|
|
||||||
usage = "parrot (--variant variant)",
|
|
||||||
desc = "Sets parrot modifiers",
|
|
||||||
modifiers = { "parrot" },
|
|
||||||
min = 1,
|
|
||||||
max = 1,
|
|
||||||
permission = "citizens.npc.parrot")
|
|
||||||
@Requirements(selected = true, ownership = true, types = EntityType.PARROT)
|
|
||||||
public void parrot(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
ParrotTrait trait = npc.getOrAddTrait(ParrotTrait.class);
|
|
||||||
String output = "";
|
|
||||||
if (args.hasValueFlag("variant")) {
|
|
||||||
String variantRaw = args.getFlag("variant");
|
|
||||||
Variant variant = Util.matchEnum(Variant.values(), variantRaw);
|
|
||||||
if (variant == null) {
|
|
||||||
String valid = Util.listValuesPretty(Variant.values());
|
|
||||||
throw new CommandException(Messages.INVALID_PARROT_VARIANT, valid);
|
|
||||||
}
|
|
||||||
trait.setVariant(variant);
|
|
||||||
output += Messaging.tr(Messages.PARROT_VARIANT_SET, Util.prettyEnum(variant));
|
|
||||||
}
|
|
||||||
if (!output.isEmpty()) {
|
|
||||||
Messaging.send(sender, output);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
aliases = { "npc" },
|
|
||||||
usage = "polarbear (-r)",
|
|
||||||
desc = "Sets polarbear modifiers.",
|
|
||||||
modifiers = { "polarbear" },
|
|
||||||
min = 1,
|
|
||||||
max = 1,
|
|
||||||
flags = "r",
|
|
||||||
permission = "citizens.npc.polarbear")
|
|
||||||
@Requirements(selected = true, ownership = true, types = { EntityType.POLAR_BEAR })
|
|
||||||
public void polarbear(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
PolarBearTrait trait = npc.getOrAddTrait(PolarBearTrait.class);
|
|
||||||
String output = "";
|
|
||||||
if (args.hasFlag('r')) {
|
|
||||||
trait.setRearing(!trait.isRearing());
|
|
||||||
output += Messaging.tr(
|
|
||||||
trait.isRearing() ? Messages.POLAR_BEAR_REARING : Messages.POLAR_BEAR_STOPPED_REARING,
|
|
||||||
npc.getName());
|
|
||||||
}
|
|
||||||
if (!output.isEmpty()) {
|
|
||||||
Messaging.send(sender, output);
|
|
||||||
} else {
|
|
||||||
throw new CommandUsageException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
aliases = { "npc" },
|
|
||||||
usage = "shulker (--peek [peek] --color [color])",
|
|
||||||
desc = "Sets shulker modifiers.",
|
|
||||||
modifiers = { "shulker" },
|
|
||||||
min = 1,
|
|
||||||
max = 1,
|
|
||||||
permission = "citizens.npc.shulker")
|
|
||||||
@Requirements(selected = true, ownership = true, types = { EntityType.SHULKER })
|
|
||||||
public void shulker(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
ShulkerTrait trait = npc.getOrAddTrait(ShulkerTrait.class);
|
|
||||||
boolean hasArg = false;
|
|
||||||
if (args.hasValueFlag("peek")) {
|
|
||||||
int peek = (byte) args.getFlagInteger("peek");
|
|
||||||
trait.setPeek(peek);
|
|
||||||
Messaging.sendTr(sender, Messages.SHULKER_PEEK_SET, npc.getName(), peek);
|
|
||||||
hasArg = true;
|
|
||||||
}
|
|
||||||
if (args.hasValueFlag("color")) {
|
|
||||||
DyeColor color = Util.matchEnum(DyeColor.values(), args.getFlag("color"));
|
|
||||||
if (color == null) {
|
|
||||||
Messaging.sendErrorTr(sender, Messages.INVALID_SHULKER_COLOR, Util.listValuesPretty(DyeColor.values()));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
trait.setColor(color);
|
|
||||||
Messaging.sendTr(sender, Messages.SHULKER_COLOR_SET, npc.getName(), Util.prettyEnum(color));
|
|
||||||
hasArg = true;
|
|
||||||
}
|
|
||||||
if (!hasArg) {
|
|
||||||
throw new CommandUsageException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
aliases = { "npc" },
|
|
||||||
usage = "snowman (-d[erp])",
|
|
||||||
desc = "Sets snowman modifiers.",
|
|
||||||
modifiers = { "snowman" },
|
|
||||||
min = 1,
|
|
||||||
max = 1,
|
|
||||||
flags = "d",
|
|
||||||
permission = "citizens.npc.snowman")
|
|
||||||
@Requirements(selected = true, ownership = true, types = { EntityType.SNOWMAN })
|
|
||||||
public void snowman(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
SnowmanTrait trait = npc.getOrAddTrait(SnowmanTrait.class);
|
|
||||||
boolean hasArg = false;
|
|
||||||
if (args.hasFlag('d')) {
|
|
||||||
boolean isDerp = trait.toggleDerp();
|
|
||||||
Messaging.sendTr(sender, isDerp ? Messages.SNOWMAN_DERP_SET : Messages.SNOWMAN_DERP_STOPPED, npc.getName());
|
|
||||||
hasArg = true;
|
|
||||||
}
|
|
||||||
if (!hasArg) {
|
|
||||||
throw new CommandUsageException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -72,6 +72,7 @@ import net.citizensnpcs.api.npc.BlockBreaker;
|
|||||||
import net.citizensnpcs.api.npc.BlockBreaker.BlockBreakerConfiguration;
|
import net.citizensnpcs.api.npc.BlockBreaker.BlockBreakerConfiguration;
|
||||||
import net.citizensnpcs.api.npc.NPC;
|
import net.citizensnpcs.api.npc.NPC;
|
||||||
import net.citizensnpcs.api.npc.NPCRegistry;
|
import net.citizensnpcs.api.npc.NPCRegistry;
|
||||||
|
import net.citizensnpcs.api.trait.Trait;
|
||||||
import net.citizensnpcs.api.trait.TraitInfo;
|
import net.citizensnpcs.api.trait.TraitInfo;
|
||||||
import net.citizensnpcs.api.util.BoundingBox;
|
import net.citizensnpcs.api.util.BoundingBox;
|
||||||
import net.citizensnpcs.api.util.Messaging;
|
import net.citizensnpcs.api.util.Messaging;
|
||||||
@ -160,7 +161,6 @@ import net.citizensnpcs.nms.v1_12_R1.entity.nonliving.ThrownPotionController;
|
|||||||
import net.citizensnpcs.nms.v1_12_R1.entity.nonliving.TippedArrowController;
|
import net.citizensnpcs.nms.v1_12_R1.entity.nonliving.TippedArrowController;
|
||||||
import net.citizensnpcs.nms.v1_12_R1.entity.nonliving.WitherSkullController;
|
import net.citizensnpcs.nms.v1_12_R1.entity.nonliving.WitherSkullController;
|
||||||
import net.citizensnpcs.nms.v1_12_R1.network.EmptyChannel;
|
import net.citizensnpcs.nms.v1_12_R1.network.EmptyChannel;
|
||||||
import net.citizensnpcs.nms.v1_12_R1.trait.Commands;
|
|
||||||
import net.citizensnpcs.npc.EntityControllers;
|
import net.citizensnpcs.npc.EntityControllers;
|
||||||
import net.citizensnpcs.npc.ai.MCNavigationStrategy.MCNavigator;
|
import net.citizensnpcs.npc.ai.MCNavigationStrategy.MCNavigator;
|
||||||
import net.citizensnpcs.npc.ai.MCTargetStrategy.TargetNavigator;
|
import net.citizensnpcs.npc.ai.MCTargetStrategy.TargetNavigator;
|
||||||
@ -669,13 +669,12 @@ public class NMSImpl implements NMSBridge {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void load(CommandManager manager) {
|
public void load(CommandManager manager) {
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(LlamaTrait.class));
|
registerTraitWithCommand(manager, BossBarTrait.class);
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(ParrotTrait.class));
|
registerTraitWithCommand(manager, LlamaTrait.class);
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(BossBarTrait.class));
|
registerTraitWithCommand(manager, ParrotTrait.class);
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(ShulkerTrait.class));
|
registerTraitWithCommand(manager, PolarBearTrait.class);
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(PolarBearTrait.class));
|
registerTraitWithCommand(manager, ShulkerTrait.class);
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(SnowmanTrait.class));
|
registerTraitWithCommand(manager, SnowmanTrait.class);
|
||||||
manager.register(Commands.class);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadEntityTypes() {
|
private void loadEntityTypes() {
|
||||||
@ -941,6 +940,11 @@ public class NMSImpl implements NMSBridge {
|
|||||||
throw new IllegalArgumentException("unable to find valid entity superclass for class " + clazz.toString());
|
throw new IllegalArgumentException("unable to find valid entity superclass for class " + clazz.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void registerTraitWithCommand(CommandManager manager, Class<? extends Trait> clazz) {
|
||||||
|
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(clazz));
|
||||||
|
manager.register(clazz);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void remove(org.bukkit.entity.Entity entity) {
|
public void remove(org.bukkit.entity.Entity entity) {
|
||||||
NMSImpl.getHandle(entity).die();
|
NMSImpl.getHandle(entity).die();
|
||||||
|
@ -1,323 +0,0 @@
|
|||||||
package net.citizensnpcs.nms.v1_13_R2.trait;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.bukkit.DyeColor;
|
|
||||||
import org.bukkit.boss.BarColor;
|
|
||||||
import org.bukkit.boss.BarFlag;
|
|
||||||
import org.bukkit.boss.BarStyle;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.EntityType;
|
|
||||||
import org.bukkit.entity.Llama.Color;
|
|
||||||
import org.bukkit.entity.Parrot.Variant;
|
|
||||||
import org.bukkit.entity.TropicalFish.Pattern;
|
|
||||||
|
|
||||||
import com.google.common.base.Splitter;
|
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
|
|
||||||
import net.citizensnpcs.api.command.Command;
|
|
||||||
import net.citizensnpcs.api.command.CommandContext;
|
|
||||||
import net.citizensnpcs.api.command.Requirements;
|
|
||||||
import net.citizensnpcs.api.command.exception.CommandException;
|
|
||||||
import net.citizensnpcs.api.command.exception.CommandUsageException;
|
|
||||||
import net.citizensnpcs.api.npc.NPC;
|
|
||||||
import net.citizensnpcs.api.util.Colorizer;
|
|
||||||
import net.citizensnpcs.api.util.Messaging;
|
|
||||||
import net.citizensnpcs.trait.HorseModifiers;
|
|
||||||
import net.citizensnpcs.trait.versioned.BossBarTrait;
|
|
||||||
import net.citizensnpcs.trait.versioned.LlamaTrait;
|
|
||||||
import net.citizensnpcs.trait.versioned.ParrotTrait;
|
|
||||||
import net.citizensnpcs.trait.versioned.PhantomTrait;
|
|
||||||
import net.citizensnpcs.trait.versioned.PolarBearTrait;
|
|
||||||
import net.citizensnpcs.trait.versioned.PufferFishTrait;
|
|
||||||
import net.citizensnpcs.trait.versioned.ShulkerTrait;
|
|
||||||
import net.citizensnpcs.trait.versioned.SnowmanTrait;
|
|
||||||
import net.citizensnpcs.trait.versioned.TropicalFishTrait;
|
|
||||||
import net.citizensnpcs.util.Messages;
|
|
||||||
import net.citizensnpcs.util.Util;
|
|
||||||
|
|
||||||
public class Commands {
|
|
||||||
@Command(
|
|
||||||
aliases = { "npc" },
|
|
||||||
usage = "bossbar --style [style] --color [color] --title [title] --visible [visible] --flags [flags] --track [health | placeholder]",
|
|
||||||
desc = "Edit bossbar properties",
|
|
||||||
modifiers = { "bossbar" },
|
|
||||||
min = 1,
|
|
||||||
max = 1)
|
|
||||||
@Requirements(selected = true, ownership = true)
|
|
||||||
public void bossbar(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
BossBarTrait trait = npc.getOrAddTrait(BossBarTrait.class);
|
|
||||||
if (args.hasValueFlag("style")) {
|
|
||||||
BarStyle style = Util.matchEnum(BarStyle.values(), args.getFlag("style"));
|
|
||||||
if (style != null) {
|
|
||||||
trait.setStyle(style);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (args.hasValueFlag("color")) {
|
|
||||||
BarColor color = Util.matchEnum(BarColor.values(), args.getFlag("color"));
|
|
||||||
if (color != null) {
|
|
||||||
trait.setColor(color);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (args.hasValueFlag("track")) {
|
|
||||||
trait.setTrackVariable(args.getFlag("track"));
|
|
||||||
}
|
|
||||||
if (args.hasValueFlag("title")) {
|
|
||||||
trait.setTitle(Colorizer.parseColors(args.getFlag("title")));
|
|
||||||
}
|
|
||||||
if (args.hasValueFlag("visible")) {
|
|
||||||
trait.setVisible(Boolean.parseBoolean(args.getFlag("visible")));
|
|
||||||
}
|
|
||||||
if (args.hasValueFlag("flags")) {
|
|
||||||
List<BarFlag> flags = Lists.newArrayList();
|
|
||||||
for (String s : Splitter.on(',').omitEmptyStrings().trimResults().split(args.getFlag("flags"))) {
|
|
||||||
BarFlag flag = Util.matchEnum(BarFlag.values(), s);
|
|
||||||
if (flag != null) {
|
|
||||||
flags.add(flag);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
trait.setFlags(flags);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
aliases = { "npc" },
|
|
||||||
usage = "llama (--color color) (--strength strength)",
|
|
||||||
desc = "Sets llama modifiers",
|
|
||||||
modifiers = { "llama" },
|
|
||||||
min = 1,
|
|
||||||
max = 1,
|
|
||||||
permission = "citizens.npc.llama")
|
|
||||||
@Requirements(selected = true, ownership = true, types = EntityType.LLAMA)
|
|
||||||
public void llama(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
LlamaTrait trait = npc.getOrAddTrait(LlamaTrait.class);
|
|
||||||
String output = "";
|
|
||||||
if (args.hasValueFlag("color") || args.hasValueFlag("colour")) {
|
|
||||||
String colorRaw = args.getFlag("color", args.getFlag("colour"));
|
|
||||||
Color color = Util.matchEnum(Color.values(), colorRaw);
|
|
||||||
if (color == null) {
|
|
||||||
String valid = Util.listValuesPretty(Color.values());
|
|
||||||
throw new CommandException(Messages.INVALID_LLAMA_COLOR, valid);
|
|
||||||
}
|
|
||||||
trait.setColor(color);
|
|
||||||
output += Messaging.tr(Messages.LLAMA_COLOR_SET, Util.prettyEnum(color));
|
|
||||||
}
|
|
||||||
if (args.hasValueFlag("strength")) {
|
|
||||||
trait.setStrength(Math.max(1, Math.min(5, args.getFlagInteger("strength"))));
|
|
||||||
output += Messaging.tr(Messages.LLAMA_STRENGTH_SET, args.getFlagInteger("strength"));
|
|
||||||
}
|
|
||||||
if (args.hasFlag('c')) {
|
|
||||||
npc.getOrAddTrait(HorseModifiers.class).setCarryingChest(true);
|
|
||||||
output += Messaging.tr(Messages.HORSE_CHEST_SET) + " ";
|
|
||||||
} else if (args.hasFlag('b')) {
|
|
||||||
npc.getOrAddTrait(HorseModifiers.class).setCarryingChest(false);
|
|
||||||
output += Messaging.tr(Messages.HORSE_CHEST_UNSET) + " ";
|
|
||||||
}
|
|
||||||
if (!output.isEmpty()) {
|
|
||||||
Messaging.send(sender, output);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
aliases = { "npc" },
|
|
||||||
usage = "parrot (--variant variant)",
|
|
||||||
desc = "Sets parrot modifiers",
|
|
||||||
modifiers = { "parrot" },
|
|
||||||
min = 1,
|
|
||||||
max = 1,
|
|
||||||
permission = "citizens.npc.parrot")
|
|
||||||
@Requirements(selected = true, ownership = true, types = EntityType.PARROT)
|
|
||||||
public void parrot(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
ParrotTrait trait = npc.getOrAddTrait(ParrotTrait.class);
|
|
||||||
String output = "";
|
|
||||||
if (args.hasValueFlag("variant")) {
|
|
||||||
String variantRaw = args.getFlag("variant");
|
|
||||||
Variant variant = Util.matchEnum(Variant.values(), variantRaw);
|
|
||||||
if (variant == null) {
|
|
||||||
String valid = Util.listValuesPretty(Variant.values());
|
|
||||||
throw new CommandException(Messages.INVALID_PARROT_VARIANT, valid);
|
|
||||||
}
|
|
||||||
trait.setVariant(variant);
|
|
||||||
output += Messaging.tr(Messages.PARROT_VARIANT_SET, Util.prettyEnum(variant));
|
|
||||||
}
|
|
||||||
if (!output.isEmpty()) {
|
|
||||||
Messaging.send(sender, output);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
aliases = { "npc" },
|
|
||||||
usage = "phantom (--size size)",
|
|
||||||
desc = "Sets phantom modifiers",
|
|
||||||
modifiers = { "phantom" },
|
|
||||||
min = 1,
|
|
||||||
max = 1,
|
|
||||||
permission = "citizens.npc.phantom")
|
|
||||||
@Requirements(selected = true, ownership = true, types = EntityType.PHANTOM)
|
|
||||||
public void phantom(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
PhantomTrait trait = npc.getOrAddTrait(PhantomTrait.class);
|
|
||||||
String output = "";
|
|
||||||
if (args.hasValueFlag("size")) {
|
|
||||||
if (args.getFlagInteger("size") <= 0) {
|
|
||||||
throw new CommandUsageException();
|
|
||||||
}
|
|
||||||
trait.setSize(args.getFlagInteger("size"));
|
|
||||||
output += Messaging.tr(Messages.PHANTOM_STATE_SET, args.getFlagInteger("size"));
|
|
||||||
}
|
|
||||||
if (!output.isEmpty()) {
|
|
||||||
Messaging.send(sender, output);
|
|
||||||
} else {
|
|
||||||
throw new CommandUsageException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
aliases = { "npc" },
|
|
||||||
usage = "polarbear (-r)",
|
|
||||||
desc = "Sets polarbear modifiers.",
|
|
||||||
modifiers = { "polarbear" },
|
|
||||||
min = 1,
|
|
||||||
max = 1,
|
|
||||||
flags = "r",
|
|
||||||
permission = "citizens.npc.polarbear")
|
|
||||||
@Requirements(selected = true, ownership = true, types = { EntityType.POLAR_BEAR })
|
|
||||||
public void polarbear(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
PolarBearTrait trait = npc.getOrAddTrait(PolarBearTrait.class);
|
|
||||||
String output = "";
|
|
||||||
if (args.hasFlag('r')) {
|
|
||||||
trait.setRearing(!trait.isRearing());
|
|
||||||
output += Messaging.tr(
|
|
||||||
trait.isRearing() ? Messages.POLAR_BEAR_REARING : Messages.POLAR_BEAR_STOPPED_REARING,
|
|
||||||
npc.getName());
|
|
||||||
}
|
|
||||||
if (!output.isEmpty()) {
|
|
||||||
Messaging.send(sender, output);
|
|
||||||
} else {
|
|
||||||
throw new CommandUsageException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
aliases = { "npc" },
|
|
||||||
usage = "pufferfish (--state state)",
|
|
||||||
desc = "Sets pufferfish modifiers",
|
|
||||||
modifiers = { "pufferfish" },
|
|
||||||
min = 1,
|
|
||||||
max = 1,
|
|
||||||
permission = "citizens.npc.pufferfish")
|
|
||||||
@Requirements(selected = true, ownership = true, types = EntityType.PUFFERFISH)
|
|
||||||
public void pufferfish(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
PufferFishTrait trait = npc.getOrAddTrait(PufferFishTrait.class);
|
|
||||||
String output = "";
|
|
||||||
if (args.hasValueFlag("state")) {
|
|
||||||
int state = Math.min(Math.max(args.getFlagInteger("state"), 0), 3);
|
|
||||||
trait.setPuffState(state);
|
|
||||||
output += Messaging.tr(Messages.PUFFERFISH_STATE_SET, state);
|
|
||||||
}
|
|
||||||
if (!output.isEmpty()) {
|
|
||||||
Messaging.send(sender, output);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
aliases = { "npc" },
|
|
||||||
usage = "shulker (--peek [peek] --color [color])",
|
|
||||||
desc = "Sets shulker modifiers.",
|
|
||||||
modifiers = { "shulker" },
|
|
||||||
min = 1,
|
|
||||||
max = 1,
|
|
||||||
permission = "citizens.npc.shulker")
|
|
||||||
@Requirements(selected = true, ownership = true, types = { EntityType.SHULKER })
|
|
||||||
public void shulker(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
ShulkerTrait trait = npc.getOrAddTrait(ShulkerTrait.class);
|
|
||||||
boolean hasArg = false;
|
|
||||||
if (args.hasValueFlag("peek")) {
|
|
||||||
int peek = (byte) args.getFlagInteger("peek");
|
|
||||||
trait.setPeek(peek);
|
|
||||||
Messaging.sendTr(sender, Messages.SHULKER_PEEK_SET, npc.getName(), peek);
|
|
||||||
hasArg = true;
|
|
||||||
}
|
|
||||||
if (args.hasValueFlag("color")) {
|
|
||||||
DyeColor color = Util.matchEnum(DyeColor.values(), args.getFlag("color"));
|
|
||||||
if (color == null) {
|
|
||||||
Messaging.sendErrorTr(sender, Messages.INVALID_SHULKER_COLOR, Util.listValuesPretty(DyeColor.values()));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
trait.setColor(color);
|
|
||||||
Messaging.sendTr(sender, Messages.SHULKER_COLOR_SET, npc.getName(), Util.prettyEnum(color));
|
|
||||||
hasArg = true;
|
|
||||||
}
|
|
||||||
if (!hasArg) {
|
|
||||||
throw new CommandUsageException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
aliases = { "npc" },
|
|
||||||
usage = "snowman (-d[erp])",
|
|
||||||
desc = "Sets snowman modifiers.",
|
|
||||||
modifiers = { "snowman" },
|
|
||||||
min = 1,
|
|
||||||
max = 1,
|
|
||||||
flags = "d",
|
|
||||||
permission = "citizens.npc.snowman")
|
|
||||||
@Requirements(selected = true, ownership = true, types = { EntityType.SNOWMAN })
|
|
||||||
public void snowman(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
SnowmanTrait trait = npc.getOrAddTrait(SnowmanTrait.class);
|
|
||||||
boolean hasArg = false;
|
|
||||||
if (args.hasFlag('d')) {
|
|
||||||
boolean isDerp = trait.toggleDerp();
|
|
||||||
Messaging.sendTr(sender, isDerp ? Messages.SNOWMAN_DERP_SET : Messages.SNOWMAN_DERP_STOPPED, npc.getName());
|
|
||||||
hasArg = true;
|
|
||||||
}
|
|
||||||
if (!hasArg) {
|
|
||||||
throw new CommandUsageException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
aliases = { "npc" },
|
|
||||||
usage = "tfish (--body color) (--pattern pattern) (--patterncolor color)",
|
|
||||||
desc = "Sets tropical fish modifiers",
|
|
||||||
modifiers = { "tfish" },
|
|
||||||
min = 1,
|
|
||||||
max = 1,
|
|
||||||
permission = "citizens.npc.tropicalfish")
|
|
||||||
@Requirements(selected = true, ownership = true, types = EntityType.TROPICAL_FISH)
|
|
||||||
public void tropicalfish(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
TropicalFishTrait trait = npc.getOrAddTrait(TropicalFishTrait.class);
|
|
||||||
String output = "";
|
|
||||||
if (args.hasValueFlag("body")) {
|
|
||||||
DyeColor color = Util.matchEnum(DyeColor.values(), args.getFlag("body"));
|
|
||||||
if (color == null) {
|
|
||||||
throw new CommandException(Messages.INVALID_TROPICALFISH_COLOR,
|
|
||||||
Util.listValuesPretty(DyeColor.values()));
|
|
||||||
}
|
|
||||||
trait.setBodyColor(color);
|
|
||||||
output += Messaging.tr(Messages.TROPICALFISH_BODY_COLOR_SET, Util.prettyEnum(color));
|
|
||||||
}
|
|
||||||
if (args.hasValueFlag("patterncolor")) {
|
|
||||||
DyeColor color = Util.matchEnum(DyeColor.values(), args.getFlag("patterncolor"));
|
|
||||||
if (color == null) {
|
|
||||||
throw new CommandException(Messages.INVALID_TROPICALFISH_COLOR,
|
|
||||||
Util.listValuesPretty(DyeColor.values()));
|
|
||||||
}
|
|
||||||
trait.setPatternColor(color);
|
|
||||||
output += Messaging.tr(Messages.TROPICALFISH_PATTERN_COLOR_SET, Util.prettyEnum(color));
|
|
||||||
}
|
|
||||||
if (args.hasValueFlag("pattern")) {
|
|
||||||
Pattern pattern = Util.matchEnum(Pattern.values(), args.getFlag("pattern"));
|
|
||||||
if (pattern == null) {
|
|
||||||
throw new CommandException(Messages.INVALID_TROPICALFISH_PATTERN,
|
|
||||||
Util.listValuesPretty(Pattern.values()));
|
|
||||||
}
|
|
||||||
trait.setPattern(pattern);
|
|
||||||
output += Messaging.tr(Messages.TROPICALFISH_PATTERN_SET, Util.prettyEnum(pattern));
|
|
||||||
}
|
|
||||||
if (!output.isEmpty()) {
|
|
||||||
Messaging.send(sender, output);
|
|
||||||
} else {
|
|
||||||
throw new CommandUsageException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -74,6 +74,7 @@ import net.citizensnpcs.api.npc.BlockBreaker;
|
|||||||
import net.citizensnpcs.api.npc.BlockBreaker.BlockBreakerConfiguration;
|
import net.citizensnpcs.api.npc.BlockBreaker.BlockBreakerConfiguration;
|
||||||
import net.citizensnpcs.api.npc.NPC;
|
import net.citizensnpcs.api.npc.NPC;
|
||||||
import net.citizensnpcs.api.npc.NPCRegistry;
|
import net.citizensnpcs.api.npc.NPCRegistry;
|
||||||
|
import net.citizensnpcs.api.trait.Trait;
|
||||||
import net.citizensnpcs.api.trait.TraitInfo;
|
import net.citizensnpcs.api.trait.TraitInfo;
|
||||||
import net.citizensnpcs.api.util.BoundingBox;
|
import net.citizensnpcs.api.util.BoundingBox;
|
||||||
import net.citizensnpcs.api.util.Messaging;
|
import net.citizensnpcs.api.util.Messaging;
|
||||||
@ -171,7 +172,6 @@ import net.citizensnpcs.nms.v1_13_R2.entity.nonliving.ThrownTridentController;
|
|||||||
import net.citizensnpcs.nms.v1_13_R2.entity.nonliving.TippedArrowController;
|
import net.citizensnpcs.nms.v1_13_R2.entity.nonliving.TippedArrowController;
|
||||||
import net.citizensnpcs.nms.v1_13_R2.entity.nonliving.WitherSkullController;
|
import net.citizensnpcs.nms.v1_13_R2.entity.nonliving.WitherSkullController;
|
||||||
import net.citizensnpcs.nms.v1_13_R2.network.EmptyChannel;
|
import net.citizensnpcs.nms.v1_13_R2.network.EmptyChannel;
|
||||||
import net.citizensnpcs.nms.v1_13_R2.trait.Commands;
|
|
||||||
import net.citizensnpcs.npc.EntityControllers;
|
import net.citizensnpcs.npc.EntityControllers;
|
||||||
import net.citizensnpcs.npc.ai.MCNavigationStrategy.MCNavigator;
|
import net.citizensnpcs.npc.ai.MCNavigationStrategy.MCNavigator;
|
||||||
import net.citizensnpcs.npc.ai.MCTargetStrategy.TargetNavigator;
|
import net.citizensnpcs.npc.ai.MCTargetStrategy.TargetNavigator;
|
||||||
@ -692,16 +692,15 @@ public class NMSImpl implements NMSBridge {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void load(CommandManager manager) {
|
public void load(CommandManager manager) {
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(LlamaTrait.class));
|
registerTraitWithCommand(manager, BossBarTrait.class);
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(ParrotTrait.class));
|
registerTraitWithCommand(manager, LlamaTrait.class);
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(BossBarTrait.class));
|
registerTraitWithCommand(manager, ParrotTrait.class);
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(ShulkerTrait.class));
|
registerTraitWithCommand(manager, PhantomTrait.class);
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(SnowmanTrait.class));
|
registerTraitWithCommand(manager, PolarBearTrait.class);
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(PhantomTrait.class));
|
registerTraitWithCommand(manager, PufferFishTrait.class);
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(PolarBearTrait.class));
|
registerTraitWithCommand(manager, ShulkerTrait.class);
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(PufferFishTrait.class));
|
registerTraitWithCommand(manager, SnowmanTrait.class);
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(TropicalFishTrait.class));
|
registerTraitWithCommand(manager, TropicalFishTrait.class);
|
||||||
manager.register(Commands.class);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadEntityTypes() {
|
private void loadEntityTypes() {
|
||||||
@ -977,6 +976,11 @@ public class NMSImpl implements NMSBridge {
|
|||||||
throw new IllegalArgumentException("unable to find valid entity superclass for class " + clazz.toString());
|
throw new IllegalArgumentException("unable to find valid entity superclass for class " + clazz.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void registerTraitWithCommand(CommandManager manager, Class<? extends Trait> clazz) {
|
||||||
|
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(clazz));
|
||||||
|
manager.register(clazz);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void remove(org.bukkit.entity.Entity entity) {
|
public void remove(org.bukkit.entity.Entity entity) {
|
||||||
NMSImpl.getHandle(entity).die();
|
NMSImpl.getHandle(entity).die();
|
||||||
|
@ -1,536 +0,0 @@
|
|||||||
package net.citizensnpcs.nms.v1_14_R1.trait;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.bukkit.DyeColor;
|
|
||||||
import org.bukkit.boss.BarColor;
|
|
||||||
import org.bukkit.boss.BarFlag;
|
|
||||||
import org.bukkit.boss.BarStyle;
|
|
||||||
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.MushroomCow;
|
|
||||||
import org.bukkit.entity.Panda;
|
|
||||||
import org.bukkit.entity.Parrot.Variant;
|
|
||||||
import org.bukkit.entity.TropicalFish.Pattern;
|
|
||||||
import org.bukkit.entity.Villager;
|
|
||||||
import org.bukkit.entity.Villager.Profession;
|
|
||||||
|
|
||||||
import com.google.common.base.Joiner;
|
|
||||||
import com.google.common.base.Splitter;
|
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
|
|
||||||
import net.citizensnpcs.api.command.Command;
|
|
||||||
import net.citizensnpcs.api.command.CommandContext;
|
|
||||||
import net.citizensnpcs.api.command.Requirements;
|
|
||||||
import net.citizensnpcs.api.command.exception.CommandException;
|
|
||||||
import net.citizensnpcs.api.command.exception.CommandUsageException;
|
|
||||||
import net.citizensnpcs.api.npc.NPC;
|
|
||||||
import net.citizensnpcs.api.util.Colorizer;
|
|
||||||
import net.citizensnpcs.api.util.Messaging;
|
|
||||||
import net.citizensnpcs.trait.HorseModifiers;
|
|
||||||
import net.citizensnpcs.trait.VillagerProfession;
|
|
||||||
import net.citizensnpcs.trait.versioned.BossBarTrait;
|
|
||||||
import net.citizensnpcs.trait.versioned.CatTrait;
|
|
||||||
import net.citizensnpcs.trait.versioned.FoxTrait;
|
|
||||||
import net.citizensnpcs.trait.versioned.LlamaTrait;
|
|
||||||
import net.citizensnpcs.trait.versioned.MushroomCowTrait;
|
|
||||||
import net.citizensnpcs.trait.versioned.PandaTrait;
|
|
||||||
import net.citizensnpcs.trait.versioned.ParrotTrait;
|
|
||||||
import net.citizensnpcs.trait.versioned.PhantomTrait;
|
|
||||||
import net.citizensnpcs.trait.versioned.PolarBearTrait;
|
|
||||||
import net.citizensnpcs.trait.versioned.PufferFishTrait;
|
|
||||||
import net.citizensnpcs.trait.versioned.ShulkerTrait;
|
|
||||||
import net.citizensnpcs.trait.versioned.SnowmanTrait;
|
|
||||||
import net.citizensnpcs.trait.versioned.TropicalFishTrait;
|
|
||||||
import net.citizensnpcs.trait.versioned.VillagerTrait;
|
|
||||||
import net.citizensnpcs.util.Messages;
|
|
||||||
import net.citizensnpcs.util.Util;
|
|
||||||
|
|
||||||
public class Commands {
|
|
||||||
@Command(
|
|
||||||
aliases = { "npc" },
|
|
||||||
usage = "bossbar --style [style] --color [color] --title [title] --visible [visible] --flags [flags] --track [health | placeholder]",
|
|
||||||
desc = "Edit bossbar properties",
|
|
||||||
modifiers = { "bossbar" },
|
|
||||||
min = 1,
|
|
||||||
max = 1)
|
|
||||||
@Requirements(selected = true, ownership = true)
|
|
||||||
public void bossbar(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
BossBarTrait trait = npc.getOrAddTrait(BossBarTrait.class);
|
|
||||||
if (args.hasValueFlag("style")) {
|
|
||||||
BarStyle style = Util.matchEnum(BarStyle.values(), args.getFlag("style"));
|
|
||||||
if (style != null) {
|
|
||||||
trait.setStyle(style);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (args.hasValueFlag("color")) {
|
|
||||||
BarColor color = Util.matchEnum(BarColor.values(), args.getFlag("color"));
|
|
||||||
if (color != null) {
|
|
||||||
trait.setColor(color);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (args.hasValueFlag("track")) {
|
|
||||||
trait.setTrackVariable(args.getFlag("track"));
|
|
||||||
}
|
|
||||||
if (args.hasValueFlag("title")) {
|
|
||||||
trait.setTitle(Colorizer.parseColors(args.getFlag("title")));
|
|
||||||
}
|
|
||||||
if (args.hasValueFlag("visible")) {
|
|
||||||
trait.setVisible(Boolean.parseBoolean(args.getFlag("visible")));
|
|
||||||
}
|
|
||||||
if (args.hasValueFlag("flags")) {
|
|
||||||
List<BarFlag> flags = Lists.newArrayList();
|
|
||||||
for (String s : Splitter.on(',').omitEmptyStrings().trimResults().split(args.getFlag("flags"))) {
|
|
||||||
BarFlag flag = Util.matchEnum(BarFlag.values(), s);
|
|
||||||
if (flag != null) {
|
|
||||||
flags.add(flag);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
trait.setFlags(flags);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
aliases = { "npc" },
|
|
||||||
usage = "cat (-s/-n/-l) --type type --ccolor collar color",
|
|
||||||
desc = "Sets cat modifiers",
|
|
||||||
modifiers = { "cat" },
|
|
||||||
min = 1,
|
|
||||||
max = 1,
|
|
||||||
flags = "snl",
|
|
||||||
permission = "citizens.npc.cat")
|
|
||||||
@Requirements(selected = true, ownership = true, types = EntityType.CAT)
|
|
||||||
public void cat(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
CatTrait trait = npc.getOrAddTrait(CatTrait.class);
|
|
||||||
String output = "";
|
|
||||||
if (args.hasValueFlag("type")) {
|
|
||||||
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()));
|
|
||||||
}
|
|
||||||
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, npc.getName());
|
|
||||||
} else if (args.hasFlag('n')) {
|
|
||||||
trait.setSitting(false);
|
|
||||||
output += ' ' + Messaging.tr(Messages.CAT_STOPPED_SITTING, npc.getName());
|
|
||||||
}
|
|
||||||
if (args.hasFlag('l')) {
|
|
||||||
trait.setLyingDown(!trait.isLyingDown());
|
|
||||||
output += ' ' + Messaging.tr(trait.isLyingDown() ? Messages.CAT_STARTED_LYING : Messages.CAT_STOPPED_LYING,
|
|
||||||
npc.getName());
|
|
||||||
}
|
|
||||||
if (!output.isEmpty()) {
|
|
||||||
Messaging.send(sender, output.trim());
|
|
||||||
} else {
|
|
||||||
throw new CommandUsageException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@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.getOrAddTrait(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)",
|
|
||||||
desc = "Sets llama modifiers",
|
|
||||||
modifiers = { "llama" },
|
|
||||||
min = 1,
|
|
||||||
max = 1,
|
|
||||||
permission = "citizens.npc.llama")
|
|
||||||
@Requirements(selected = true, ownership = true, types = { EntityType.LLAMA, EntityType.TRADER_LLAMA })
|
|
||||||
public void llama(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
LlamaTrait trait = npc.getOrAddTrait(LlamaTrait.class);
|
|
||||||
String output = "";
|
|
||||||
if (args.hasValueFlag("color") || args.hasValueFlag("colour")) {
|
|
||||||
String colorRaw = args.getFlag("color", args.getFlag("colour"));
|
|
||||||
Color color = Util.matchEnum(Color.values(), colorRaw);
|
|
||||||
if (color == null) {
|
|
||||||
String valid = Util.listValuesPretty(Color.values());
|
|
||||||
throw new CommandException(Messages.INVALID_LLAMA_COLOR, valid);
|
|
||||||
}
|
|
||||||
trait.setColor(color);
|
|
||||||
output += Messaging.tr(Messages.LLAMA_COLOR_SET, Util.prettyEnum(color));
|
|
||||||
}
|
|
||||||
if (args.hasValueFlag("strength")) {
|
|
||||||
trait.setStrength(Math.max(1, Math.min(5, args.getFlagInteger("strength"))));
|
|
||||||
output += Messaging.tr(Messages.LLAMA_STRENGTH_SET, args.getFlagInteger("strength"));
|
|
||||||
}
|
|
||||||
if (args.hasFlag('c')) {
|
|
||||||
npc.getOrAddTrait(HorseModifiers.class).setCarryingChest(true);
|
|
||||||
output += Messaging.tr(Messages.HORSE_CHEST_SET) + " ";
|
|
||||||
} else if (args.hasFlag('b')) {
|
|
||||||
npc.getOrAddTrait(HorseModifiers.class).setCarryingChest(false);
|
|
||||||
output += Messaging.tr(Messages.HORSE_CHEST_UNSET) + " ";
|
|
||||||
}
|
|
||||||
if (!output.isEmpty()) {
|
|
||||||
Messaging.send(sender, output);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
aliases = { "npc" },
|
|
||||||
usage = "mcow (--variant [variant])",
|
|
||||||
desc = "Sets mushroom cow modifiers.",
|
|
||||||
modifiers = { "mcow", "mushroomcow" },
|
|
||||||
min = 1,
|
|
||||||
max = 1,
|
|
||||||
permission = "citizens.npc.mushroomcow")
|
|
||||||
@Requirements(selected = true, ownership = true, types = { EntityType.MUSHROOM_COW })
|
|
||||||
public void mushroomcow(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
MushroomCowTrait trait = npc.getOrAddTrait(MushroomCowTrait.class);
|
|
||||||
boolean hasArg = false;
|
|
||||||
if (args.hasValueFlag("variant")) {
|
|
||||||
MushroomCow.Variant variant = Util.matchEnum(MushroomCow.Variant.values(), args.getFlag("variant"));
|
|
||||||
if (variant == null) {
|
|
||||||
Messaging.sendErrorTr(sender, Messages.INVALID_MUSHROOM_COW_VARIANT,
|
|
||||||
Util.listValuesPretty(MushroomCow.Variant.values()));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
trait.setVariant(variant);
|
|
||||||
Messaging.sendTr(sender, Messages.MUSHROOM_COW_VARIANT_SET, npc.getName(), variant);
|
|
||||||
hasArg = true;
|
|
||||||
}
|
|
||||||
if (!hasArg) {
|
|
||||||
throw new CommandUsageException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
aliases = { "npc" },
|
|
||||||
usage = "panda --gene (main gene) --hgene (hidden gene)",
|
|
||||||
desc = "Sets panda modifiers",
|
|
||||||
modifiers = { "panda" },
|
|
||||||
min = 1,
|
|
||||||
max = 1,
|
|
||||||
permission = "citizens.npc.panda")
|
|
||||||
@Requirements(selected = true, ownership = true, types = EntityType.PANDA)
|
|
||||||
public void panda(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
PandaTrait trait = npc.getOrAddTrait(PandaTrait.class);
|
|
||||||
String output = "";
|
|
||||||
if (args.hasValueFlag("gene")) {
|
|
||||||
Panda.Gene gene = Util.matchEnum(Panda.Gene.values(), args.getFlag("gene"));
|
|
||||||
if (gene == null) {
|
|
||||||
throw new CommandUsageException(Messages.INVALID_PANDA_GENE,
|
|
||||||
Util.listValuesPretty(Panda.Gene.values()));
|
|
||||||
}
|
|
||||||
trait.setMainGene(gene);
|
|
||||||
output += ' ' + Messaging.tr(Messages.PANDA_MAIN_GENE_SET, args.getFlag("gene"));
|
|
||||||
}
|
|
||||||
if (args.hasValueFlag("hgene")) {
|
|
||||||
Panda.Gene gene = Util.matchEnum(Panda.Gene.values(), args.getFlag("hgene"));
|
|
||||||
if (gene == null) {
|
|
||||||
throw new CommandUsageException(Messages.INVALID_PANDA_GENE,
|
|
||||||
Util.listValuesPretty(Panda.Gene.values()));
|
|
||||||
}
|
|
||||||
trait.setHiddenGene(gene);
|
|
||||||
output += ' ' + Messaging.tr(Messages.PANDA_HIDDEN_GENE_SET, args.getFlag("hgene"));
|
|
||||||
}
|
|
||||||
if (!output.isEmpty()) {
|
|
||||||
Messaging.send(sender, output.trim());
|
|
||||||
} else {
|
|
||||||
throw new CommandUsageException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
aliases = { "npc" },
|
|
||||||
usage = "parrot (--variant variant)",
|
|
||||||
desc = "Sets parrot modifiers",
|
|
||||||
modifiers = { "parrot" },
|
|
||||||
min = 1,
|
|
||||||
max = 1,
|
|
||||||
permission = "citizens.npc.parrot")
|
|
||||||
@Requirements(selected = true, ownership = true, types = EntityType.PARROT)
|
|
||||||
public void parrot(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
ParrotTrait trait = npc.getOrAddTrait(ParrotTrait.class);
|
|
||||||
String output = "";
|
|
||||||
if (args.hasValueFlag("variant")) {
|
|
||||||
String variantRaw = args.getFlag("variant");
|
|
||||||
Variant variant = Util.matchEnum(Variant.values(), variantRaw);
|
|
||||||
if (variant == null) {
|
|
||||||
String valid = Util.listValuesPretty(Variant.values());
|
|
||||||
throw new CommandException(Messages.INVALID_PARROT_VARIANT, valid);
|
|
||||||
}
|
|
||||||
trait.setVariant(variant);
|
|
||||||
output += Messaging.tr(Messages.PARROT_VARIANT_SET, Util.prettyEnum(variant));
|
|
||||||
}
|
|
||||||
if (!output.isEmpty()) {
|
|
||||||
Messaging.send(sender, output);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
aliases = { "npc" },
|
|
||||||
usage = "phantom (--size size)",
|
|
||||||
desc = "Sets phantom modifiers",
|
|
||||||
modifiers = { "phantom" },
|
|
||||||
min = 1,
|
|
||||||
max = 1,
|
|
||||||
permission = "citizens.npc.phantom")
|
|
||||||
@Requirements(selected = true, ownership = true, types = EntityType.PHANTOM)
|
|
||||||
public void phantom(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
PhantomTrait trait = npc.getOrAddTrait(PhantomTrait.class);
|
|
||||||
String output = "";
|
|
||||||
if (args.hasValueFlag("size")) {
|
|
||||||
if (args.getFlagInteger("size") <= 0) {
|
|
||||||
throw new CommandUsageException();
|
|
||||||
}
|
|
||||||
trait.setSize(args.getFlagInteger("size"));
|
|
||||||
output += Messaging.tr(Messages.PHANTOM_STATE_SET, args.getFlagInteger("size"));
|
|
||||||
}
|
|
||||||
if (!output.isEmpty()) {
|
|
||||||
Messaging.send(sender, output);
|
|
||||||
} else {
|
|
||||||
throw new CommandUsageException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
aliases = { "npc" },
|
|
||||||
usage = "polarbear (-r)",
|
|
||||||
desc = "Sets polarbear modifiers.",
|
|
||||||
modifiers = { "polarbear" },
|
|
||||||
min = 1,
|
|
||||||
max = 1,
|
|
||||||
flags = "r",
|
|
||||||
permission = "citizens.npc.polarbear")
|
|
||||||
@Requirements(selected = true, ownership = true, types = { EntityType.POLAR_BEAR })
|
|
||||||
public void polarbear(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
PolarBearTrait trait = npc.getOrAddTrait(PolarBearTrait.class);
|
|
||||||
String output = "";
|
|
||||||
if (args.hasFlag('r')) {
|
|
||||||
trait.setRearing(!trait.isRearing());
|
|
||||||
output += Messaging.tr(
|
|
||||||
trait.isRearing() ? Messages.POLAR_BEAR_REARING : Messages.POLAR_BEAR_STOPPED_REARING,
|
|
||||||
npc.getName());
|
|
||||||
}
|
|
||||||
if (!output.isEmpty()) {
|
|
||||||
Messaging.send(sender, output);
|
|
||||||
} else {
|
|
||||||
throw new CommandUsageException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
aliases = { "npc" },
|
|
||||||
usage = "pufferfish (--state state)",
|
|
||||||
desc = "Sets pufferfish modifiers",
|
|
||||||
modifiers = { "pufferfish" },
|
|
||||||
min = 1,
|
|
||||||
max = 1,
|
|
||||||
permission = "citizens.npc.pufferfish")
|
|
||||||
@Requirements(selected = true, ownership = true, types = EntityType.PUFFERFISH)
|
|
||||||
public void pufferfish(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
PufferFishTrait trait = npc.getOrAddTrait(PufferFishTrait.class);
|
|
||||||
String output = "";
|
|
||||||
if (args.hasValueFlag("state")) {
|
|
||||||
int state = Math.min(Math.max(args.getFlagInteger("state"), 0), 3);
|
|
||||||
trait.setPuffState(state);
|
|
||||||
output += Messaging.tr(Messages.PUFFERFISH_STATE_SET, state);
|
|
||||||
}
|
|
||||||
if (!output.isEmpty()) {
|
|
||||||
Messaging.send(sender, output);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
aliases = { "npc" },
|
|
||||||
usage = "shulker (--peek [peek] --color [color])",
|
|
||||||
desc = "Sets shulker modifiers.",
|
|
||||||
modifiers = { "shulker" },
|
|
||||||
min = 1,
|
|
||||||
max = 1,
|
|
||||||
permission = "citizens.npc.shulker")
|
|
||||||
@Requirements(selected = true, ownership = true, types = { EntityType.SHULKER })
|
|
||||||
public void shulker(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
ShulkerTrait trait = npc.getOrAddTrait(ShulkerTrait.class);
|
|
||||||
boolean hasArg = false;
|
|
||||||
if (args.hasValueFlag("peek")) {
|
|
||||||
int peek = (byte) args.getFlagInteger("peek");
|
|
||||||
trait.setPeek(peek);
|
|
||||||
Messaging.sendTr(sender, Messages.SHULKER_PEEK_SET, npc.getName(), peek);
|
|
||||||
hasArg = true;
|
|
||||||
}
|
|
||||||
if (args.hasValueFlag("color")) {
|
|
||||||
DyeColor color = Util.matchEnum(DyeColor.values(), args.getFlag("color"));
|
|
||||||
if (color == null) {
|
|
||||||
Messaging.sendErrorTr(sender, Messages.INVALID_SHULKER_COLOR, Util.listValuesPretty(DyeColor.values()));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
trait.setColor(color);
|
|
||||||
Messaging.sendTr(sender, Messages.SHULKER_COLOR_SET, npc.getName(), Util.prettyEnum(color));
|
|
||||||
hasArg = true;
|
|
||||||
}
|
|
||||||
if (!hasArg) {
|
|
||||||
throw new CommandUsageException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
aliases = { "npc" },
|
|
||||||
usage = "snowman (-d[erp])",
|
|
||||||
desc = "Sets snowman modifiers.",
|
|
||||||
modifiers = { "snowman" },
|
|
||||||
min = 1,
|
|
||||||
max = 1,
|
|
||||||
flags = "d",
|
|
||||||
permission = "citizens.npc.snowman")
|
|
||||||
@Requirements(selected = true, ownership = true, types = { EntityType.SNOWMAN })
|
|
||||||
public void snowman(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
SnowmanTrait trait = npc.getOrAddTrait(SnowmanTrait.class);
|
|
||||||
boolean hasArg = false;
|
|
||||||
if (args.hasFlag('d')) {
|
|
||||||
boolean isDerp = trait.toggleDerp();
|
|
||||||
Messaging.sendTr(sender, isDerp ? Messages.SNOWMAN_DERP_SET : Messages.SNOWMAN_DERP_STOPPED, npc.getName());
|
|
||||||
hasArg = true;
|
|
||||||
}
|
|
||||||
if (!hasArg) {
|
|
||||||
throw new CommandUsageException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
aliases = { "npc" },
|
|
||||||
usage = "tfish (--body color) (--pattern pattern) (--patterncolor color)",
|
|
||||||
desc = "Sets tropical fish modifiers",
|
|
||||||
modifiers = { "tfish" },
|
|
||||||
min = 1,
|
|
||||||
max = 1,
|
|
||||||
permission = "citizens.npc.tropicalfish")
|
|
||||||
@Requirements(selected = true, ownership = true, types = EntityType.TROPICAL_FISH)
|
|
||||||
public void tropicalfish(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
TropicalFishTrait trait = npc.getOrAddTrait(TropicalFishTrait.class);
|
|
||||||
String output = "";
|
|
||||||
if (args.hasValueFlag("body")) {
|
|
||||||
DyeColor color = Util.matchEnum(DyeColor.values(), args.getFlag("body"));
|
|
||||||
if (color == null) {
|
|
||||||
throw new CommandException(Messages.INVALID_TROPICALFISH_COLOR,
|
|
||||||
Util.listValuesPretty(DyeColor.values()));
|
|
||||||
}
|
|
||||||
trait.setBodyColor(color);
|
|
||||||
output += Messaging.tr(Messages.TROPICALFISH_BODY_COLOR_SET, Util.prettyEnum(color));
|
|
||||||
}
|
|
||||||
if (args.hasValueFlag("patterncolor")) {
|
|
||||||
DyeColor color = Util.matchEnum(DyeColor.values(), args.getFlag("patterncolor"));
|
|
||||||
if (color == null) {
|
|
||||||
throw new CommandException(Messages.INVALID_TROPICALFISH_COLOR,
|
|
||||||
Util.listValuesPretty(DyeColor.values()));
|
|
||||||
}
|
|
||||||
trait.setPatternColor(color);
|
|
||||||
output += Messaging.tr(Messages.TROPICALFISH_PATTERN_COLOR_SET, Util.prettyEnum(color));
|
|
||||||
}
|
|
||||||
if (args.hasValueFlag("pattern")) {
|
|
||||||
Pattern pattern = Util.matchEnum(Pattern.values(), args.getFlag("pattern"));
|
|
||||||
if (pattern == null) {
|
|
||||||
throw new CommandException(Messages.INVALID_TROPICALFISH_PATTERN,
|
|
||||||
Util.listValuesPretty(Pattern.values()));
|
|
||||||
}
|
|
||||||
trait.setPattern(pattern);
|
|
||||||
output += Messaging.tr(Messages.TROPICALFISH_PATTERN_SET, Util.prettyEnum(pattern));
|
|
||||||
}
|
|
||||||
if (!output.isEmpty()) {
|
|
||||||
Messaging.send(sender, output);
|
|
||||||
} else {
|
|
||||||
throw new CommandUsageException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
aliases = { "npc" },
|
|
||||||
usage = "villager (--level level) (--type type) (--profession profession)",
|
|
||||||
desc = "Sets villager modifiers",
|
|
||||||
modifiers = { "villager" },
|
|
||||||
min = 1,
|
|
||||||
max = 1,
|
|
||||||
permission = "citizens.npc.villager")
|
|
||||||
@Requirements(selected = true, ownership = true, types = EntityType.VILLAGER)
|
|
||||||
public void villager(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
VillagerTrait trait = npc.getOrAddTrait(VillagerTrait.class);
|
|
||||||
String output = "";
|
|
||||||
if (args.hasValueFlag("level")) {
|
|
||||||
if (args.getFlagInteger("level") < 0) {
|
|
||||||
throw new CommandUsageException();
|
|
||||||
}
|
|
||||||
trait.setLevel(args.getFlagInteger("level"));
|
|
||||||
output += " " + Messaging.tr(Messages.VILLAGER_LEVEL_SET, args.getFlagInteger("level"));
|
|
||||||
}
|
|
||||||
if (args.hasValueFlag("type")) {
|
|
||||||
Villager.Type type = Util.matchEnum(Villager.Type.values(), args.getFlag("type"));
|
|
||||||
if (type == null) {
|
|
||||||
throw new CommandException(Messages.INVALID_VILLAGER_TYPE,
|
|
||||||
Util.listValuesPretty(Villager.Type.values()));
|
|
||||||
}
|
|
||||||
trait.setType(type);
|
|
||||||
output += " " + Messaging.tr(Messages.VILLAGER_TYPE_SET, args.getFlag("type"));
|
|
||||||
}
|
|
||||||
if (args.hasValueFlag("profession")) {
|
|
||||||
Profession parsed = Util.matchEnum(Profession.values(), args.getFlag("profession"));
|
|
||||||
if (parsed == null) {
|
|
||||||
throw new CommandException(Messages.INVALID_PROFESSION, args.getFlag("profession"),
|
|
||||||
Joiner.on(',').join(Profession.values()));
|
|
||||||
}
|
|
||||||
npc.getOrAddTrait(VillagerProfession.class).setProfession(parsed);
|
|
||||||
output += " " + Messaging.tr(Messages.PROFESSION_SET, npc.getName(), args.getFlag("profession"));
|
|
||||||
}
|
|
||||||
if (!output.isEmpty()) {
|
|
||||||
Messaging.send(sender, output.trim());
|
|
||||||
} else {
|
|
||||||
throw new CommandUsageException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -75,6 +75,7 @@ import net.citizensnpcs.api.npc.BlockBreaker;
|
|||||||
import net.citizensnpcs.api.npc.BlockBreaker.BlockBreakerConfiguration;
|
import net.citizensnpcs.api.npc.BlockBreaker.BlockBreakerConfiguration;
|
||||||
import net.citizensnpcs.api.npc.NPC;
|
import net.citizensnpcs.api.npc.NPC;
|
||||||
import net.citizensnpcs.api.npc.NPCRegistry;
|
import net.citizensnpcs.api.npc.NPCRegistry;
|
||||||
|
import net.citizensnpcs.api.trait.Trait;
|
||||||
import net.citizensnpcs.api.trait.TraitInfo;
|
import net.citizensnpcs.api.trait.TraitInfo;
|
||||||
import net.citizensnpcs.api.util.BoundingBox;
|
import net.citizensnpcs.api.util.BoundingBox;
|
||||||
import net.citizensnpcs.api.util.Messaging;
|
import net.citizensnpcs.api.util.Messaging;
|
||||||
@ -179,7 +180,6 @@ import net.citizensnpcs.nms.v1_14_R1.entity.nonliving.ThrownTridentController;
|
|||||||
import net.citizensnpcs.nms.v1_14_R1.entity.nonliving.TippedArrowController;
|
import net.citizensnpcs.nms.v1_14_R1.entity.nonliving.TippedArrowController;
|
||||||
import net.citizensnpcs.nms.v1_14_R1.entity.nonliving.WitherSkullController;
|
import net.citizensnpcs.nms.v1_14_R1.entity.nonliving.WitherSkullController;
|
||||||
import net.citizensnpcs.nms.v1_14_R1.network.EmptyChannel;
|
import net.citizensnpcs.nms.v1_14_R1.network.EmptyChannel;
|
||||||
import net.citizensnpcs.nms.v1_14_R1.trait.Commands;
|
|
||||||
import net.citizensnpcs.npc.EntityControllers;
|
import net.citizensnpcs.npc.EntityControllers;
|
||||||
import net.citizensnpcs.npc.ai.MCNavigationStrategy.MCNavigator;
|
import net.citizensnpcs.npc.ai.MCNavigationStrategy.MCNavigator;
|
||||||
import net.citizensnpcs.npc.ai.MCTargetStrategy.TargetNavigator;
|
import net.citizensnpcs.npc.ai.MCTargetStrategy.TargetNavigator;
|
||||||
@ -748,21 +748,20 @@ public class NMSImpl implements NMSBridge {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void load(CommandManager manager) {
|
public void load(CommandManager manager) {
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(BossBarTrait.class));
|
registerTraitWithCommand(manager, BossBarTrait.class);
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(CatTrait.class));
|
registerTraitWithCommand(manager, CatTrait.class);
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(FoxTrait.class));
|
registerTraitWithCommand(manager, FoxTrait.class);
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(LlamaTrait.class));
|
registerTraitWithCommand(manager, LlamaTrait.class);
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(MushroomCowTrait.class));
|
registerTraitWithCommand(manager, MushroomCowTrait.class);
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(ParrotTrait.class));
|
registerTraitWithCommand(manager, ParrotTrait.class);
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(PandaTrait.class));
|
registerTraitWithCommand(manager, PandaTrait.class);
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(PhantomTrait.class));
|
registerTraitWithCommand(manager, PhantomTrait.class);
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(PolarBearTrait.class));
|
registerTraitWithCommand(manager, PolarBearTrait.class);
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(PufferFishTrait.class));
|
registerTraitWithCommand(manager, PufferFishTrait.class);
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(ShulkerTrait.class));
|
registerTraitWithCommand(manager, ShulkerTrait.class);
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(SnowmanTrait.class));
|
registerTraitWithCommand(manager, SnowmanTrait.class);
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(TropicalFishTrait.class));
|
registerTraitWithCommand(manager, TropicalFishTrait.class);
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(VillagerTrait.class));
|
registerTraitWithCommand(manager, VillagerTrait.class);
|
||||||
manager.register(Commands.class);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadEntityTypes() {
|
private void loadEntityTypes() {
|
||||||
@ -1045,6 +1044,11 @@ public class NMSImpl implements NMSBridge {
|
|||||||
throw new IllegalArgumentException("unable to find valid entity superclass for class " + clazz.toString());
|
throw new IllegalArgumentException("unable to find valid entity superclass for class " + clazz.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void registerTraitWithCommand(CommandManager manager, Class<? extends Trait> clazz) {
|
||||||
|
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(clazz));
|
||||||
|
manager.register(clazz);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void remove(org.bukkit.entity.Entity entity) {
|
public void remove(org.bukkit.entity.Entity entity) {
|
||||||
NMSImpl.getHandle(entity).die();
|
NMSImpl.getHandle(entity).die();
|
||||||
|
@ -1,580 +0,0 @@
|
|||||||
package net.citizensnpcs.nms.v1_15_R1.trait;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.bukkit.DyeColor;
|
|
||||||
import org.bukkit.boss.BarColor;
|
|
||||||
import org.bukkit.boss.BarFlag;
|
|
||||||
import org.bukkit.boss.BarStyle;
|
|
||||||
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.MushroomCow;
|
|
||||||
import org.bukkit.entity.Panda;
|
|
||||||
import org.bukkit.entity.Parrot.Variant;
|
|
||||||
import org.bukkit.entity.TropicalFish.Pattern;
|
|
||||||
import org.bukkit.entity.Villager;
|
|
||||||
import org.bukkit.entity.Villager.Profession;
|
|
||||||
|
|
||||||
import com.google.common.base.Joiner;
|
|
||||||
import com.google.common.base.Splitter;
|
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
|
|
||||||
import net.citizensnpcs.api.command.Command;
|
|
||||||
import net.citizensnpcs.api.command.CommandContext;
|
|
||||||
import net.citizensnpcs.api.command.Requirements;
|
|
||||||
import net.citizensnpcs.api.command.exception.CommandException;
|
|
||||||
import net.citizensnpcs.api.command.exception.CommandUsageException;
|
|
||||||
import net.citizensnpcs.api.npc.NPC;
|
|
||||||
import net.citizensnpcs.api.util.Colorizer;
|
|
||||||
import net.citizensnpcs.api.util.Messaging;
|
|
||||||
import net.citizensnpcs.trait.HorseModifiers;
|
|
||||||
import net.citizensnpcs.trait.VillagerProfession;
|
|
||||||
import net.citizensnpcs.trait.versioned.BeeTrait;
|
|
||||||
import net.citizensnpcs.trait.versioned.BossBarTrait;
|
|
||||||
import net.citizensnpcs.trait.versioned.CatTrait;
|
|
||||||
import net.citizensnpcs.trait.versioned.FoxTrait;
|
|
||||||
import net.citizensnpcs.trait.versioned.LlamaTrait;
|
|
||||||
import net.citizensnpcs.trait.versioned.MushroomCowTrait;
|
|
||||||
import net.citizensnpcs.trait.versioned.PandaTrait;
|
|
||||||
import net.citizensnpcs.trait.versioned.ParrotTrait;
|
|
||||||
import net.citizensnpcs.trait.versioned.PhantomTrait;
|
|
||||||
import net.citizensnpcs.trait.versioned.PolarBearTrait;
|
|
||||||
import net.citizensnpcs.trait.versioned.PufferFishTrait;
|
|
||||||
import net.citizensnpcs.trait.versioned.ShulkerTrait;
|
|
||||||
import net.citizensnpcs.trait.versioned.SnowmanTrait;
|
|
||||||
import net.citizensnpcs.trait.versioned.TropicalFishTrait;
|
|
||||||
import net.citizensnpcs.trait.versioned.VillagerTrait;
|
|
||||||
import net.citizensnpcs.util.Messages;
|
|
||||||
import net.citizensnpcs.util.Util;
|
|
||||||
|
|
||||||
public class Commands {
|
|
||||||
@Command(
|
|
||||||
aliases = { "npc" },
|
|
||||||
usage = "bee (-s/-n) --anger anger",
|
|
||||||
desc = "Sets bee modifiers",
|
|
||||||
modifiers = { "bee" },
|
|
||||||
min = 1,
|
|
||||||
max = 1,
|
|
||||||
flags = "sn",
|
|
||||||
permission = "citizens.npc.bee")
|
|
||||||
@Requirements(selected = true, ownership = true, types = EntityType.BEE)
|
|
||||||
public void bee(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
BeeTrait trait = npc.getOrAddTrait(BeeTrait.class);
|
|
||||||
String output = "";
|
|
||||||
if (args.hasValueFlag("anger")) {
|
|
||||||
int anger = args.getFlagInteger("anger");
|
|
||||||
if (anger < 0) {
|
|
||||||
throw new CommandException(Messages.INVALID_BEE_ANGER);
|
|
||||||
}
|
|
||||||
trait.setAnger(anger);
|
|
||||||
output += ' ' + Messaging.tr(Messages.BEE_ANGER_SET, args.getFlag("anger"));
|
|
||||||
}
|
|
||||||
if (args.hasFlag('s')) {
|
|
||||||
trait.setStung(!trait.hasStung());
|
|
||||||
output += ' ' + (trait.hasStung() ? Messaging.tr(Messages.BEE_STUNG, npc.getName())
|
|
||||||
: Messaging.tr(Messages.BEE_NOT_STUNG, npc.getName()));
|
|
||||||
}
|
|
||||||
if (args.hasFlag('n')) {
|
|
||||||
trait.setNectar(!trait.hasNectar());
|
|
||||||
output += ' ' + (trait.hasNectar() ? Messaging.tr(Messages.BEE_HAS_NECTAR, npc.getName())
|
|
||||||
: Messaging.tr(Messages.BEE_NO_NECTAR, npc.getName()));
|
|
||||||
}
|
|
||||||
if (!output.isEmpty()) {
|
|
||||||
Messaging.send(sender, output.trim());
|
|
||||||
} else {
|
|
||||||
throw new CommandUsageException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
aliases = { "npc" },
|
|
||||||
usage = "bossbar --style [style] --color [color] --title [title] --visible [visible] --flags [flags] --track [health | placeholder]",
|
|
||||||
desc = "Edit bossbar properties",
|
|
||||||
modifiers = { "bossbar" },
|
|
||||||
min = 1,
|
|
||||||
max = 1)
|
|
||||||
@Requirements(selected = true, ownership = true)
|
|
||||||
public void bossbar(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
BossBarTrait trait = npc.getOrAddTrait(BossBarTrait.class);
|
|
||||||
if (args.hasValueFlag("style")) {
|
|
||||||
BarStyle style = Util.matchEnum(BarStyle.values(), args.getFlag("style"));
|
|
||||||
if (style != null) {
|
|
||||||
trait.setStyle(style);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (args.hasValueFlag("color")) {
|
|
||||||
BarColor color = Util.matchEnum(BarColor.values(), args.getFlag("color"));
|
|
||||||
if (color != null) {
|
|
||||||
trait.setColor(color);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (args.hasValueFlag("track")) {
|
|
||||||
trait.setTrackVariable(args.getFlag("track"));
|
|
||||||
}
|
|
||||||
if (args.hasValueFlag("title")) {
|
|
||||||
trait.setTitle(Colorizer.parseColors(args.getFlag("title")));
|
|
||||||
}
|
|
||||||
if (args.hasValueFlag("visible")) {
|
|
||||||
trait.setVisible(Boolean.parseBoolean(args.getFlag("visible")));
|
|
||||||
}
|
|
||||||
if (args.hasValueFlag("flags")) {
|
|
||||||
List<BarFlag> flags = Lists.newArrayList();
|
|
||||||
for (String s : Splitter.on(',').omitEmptyStrings().trimResults().split(args.getFlag("flags"))) {
|
|
||||||
BarFlag flag = Util.matchEnum(BarFlag.values(), s);
|
|
||||||
if (flag != null) {
|
|
||||||
flags.add(flag);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
trait.setFlags(flags);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
aliases = { "npc" },
|
|
||||||
usage = "cat (-s/-n/-l) --type type --ccolor collar color",
|
|
||||||
desc = "Sets cat modifiers",
|
|
||||||
modifiers = { "cat" },
|
|
||||||
min = 1,
|
|
||||||
max = 1,
|
|
||||||
flags = "snl",
|
|
||||||
permission = "citizens.npc.cat")
|
|
||||||
@Requirements(selected = true, ownership = true, types = EntityType.CAT)
|
|
||||||
public void cat(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
CatTrait trait = npc.getOrAddTrait(CatTrait.class);
|
|
||||||
String output = "";
|
|
||||||
if (args.hasValueFlag("type")) {
|
|
||||||
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()));
|
|
||||||
}
|
|
||||||
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, npc.getName());
|
|
||||||
} else if (args.hasFlag('n')) {
|
|
||||||
trait.setSitting(false);
|
|
||||||
output += ' ' + Messaging.tr(Messages.CAT_STOPPED_SITTING, npc.getName());
|
|
||||||
}
|
|
||||||
if (args.hasFlag('l')) {
|
|
||||||
trait.setLyingDown(!trait.isLyingDown());
|
|
||||||
output += ' ' + Messaging.tr(trait.isLyingDown() ? Messages.CAT_STARTED_LYING : Messages.CAT_STOPPED_LYING,
|
|
||||||
npc.getName());
|
|
||||||
}
|
|
||||||
if (!output.isEmpty()) {
|
|
||||||
Messaging.send(sender, output.trim());
|
|
||||||
} else {
|
|
||||||
throw new CommandUsageException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@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.getOrAddTrait(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)",
|
|
||||||
desc = "Sets llama modifiers",
|
|
||||||
modifiers = { "llama" },
|
|
||||||
min = 1,
|
|
||||||
max = 1,
|
|
||||||
permission = "citizens.npc.llama")
|
|
||||||
@Requirements(selected = true, ownership = true, types = { EntityType.LLAMA, EntityType.TRADER_LLAMA })
|
|
||||||
public void llama(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
LlamaTrait trait = npc.getOrAddTrait(LlamaTrait.class);
|
|
||||||
String output = "";
|
|
||||||
if (args.hasValueFlag("color") || args.hasValueFlag("colour")) {
|
|
||||||
String colorRaw = args.getFlag("color", args.getFlag("colour"));
|
|
||||||
Color color = Util.matchEnum(Color.values(), colorRaw);
|
|
||||||
if (color == null) {
|
|
||||||
String valid = Util.listValuesPretty(Color.values());
|
|
||||||
throw new CommandException(Messages.INVALID_LLAMA_COLOR, valid);
|
|
||||||
}
|
|
||||||
trait.setColor(color);
|
|
||||||
output += Messaging.tr(Messages.LLAMA_COLOR_SET, Util.prettyEnum(color));
|
|
||||||
}
|
|
||||||
if (args.hasValueFlag("strength")) {
|
|
||||||
trait.setStrength(Math.max(1, Math.min(5, args.getFlagInteger("strength"))));
|
|
||||||
output += Messaging.tr(Messages.LLAMA_STRENGTH_SET, args.getFlagInteger("strength"));
|
|
||||||
}
|
|
||||||
if (args.hasFlag('c')) {
|
|
||||||
npc.getOrAddTrait(HorseModifiers.class).setCarryingChest(true);
|
|
||||||
output += Messaging.tr(Messages.HORSE_CHEST_SET) + " ";
|
|
||||||
} else if (args.hasFlag('b')) {
|
|
||||||
npc.getOrAddTrait(HorseModifiers.class).setCarryingChest(false);
|
|
||||||
output += Messaging.tr(Messages.HORSE_CHEST_UNSET) + " ";
|
|
||||||
}
|
|
||||||
if (!output.isEmpty()) {
|
|
||||||
Messaging.send(sender, output);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
aliases = { "npc" },
|
|
||||||
usage = "mcow (--variant [variant])",
|
|
||||||
desc = "Sets mushroom cow modifiers.",
|
|
||||||
modifiers = { "mcow", "mushroomcow" },
|
|
||||||
min = 1,
|
|
||||||
max = 1,
|
|
||||||
permission = "citizens.npc.mushroomcow")
|
|
||||||
@Requirements(selected = true, ownership = true, types = { EntityType.MUSHROOM_COW })
|
|
||||||
public void mushroomcow(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
MushroomCowTrait trait = npc.getOrAddTrait(MushroomCowTrait.class);
|
|
||||||
boolean hasArg = false;
|
|
||||||
if (args.hasValueFlag("variant")) {
|
|
||||||
MushroomCow.Variant variant = Util.matchEnum(MushroomCow.Variant.values(), args.getFlag("variant"));
|
|
||||||
if (variant == null) {
|
|
||||||
Messaging.sendErrorTr(sender, Messages.INVALID_MUSHROOM_COW_VARIANT,
|
|
||||||
Util.listValuesPretty(MushroomCow.Variant.values()));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
trait.setVariant(variant);
|
|
||||||
Messaging.sendTr(sender, Messages.MUSHROOM_COW_VARIANT_SET, npc.getName(), variant);
|
|
||||||
hasArg = true;
|
|
||||||
}
|
|
||||||
if (!hasArg) {
|
|
||||||
throw new CommandUsageException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
aliases = { "npc" },
|
|
||||||
usage = "panda --gene (main gene) --hgene (hidden gene) -s(itting)",
|
|
||||||
desc = "Sets panda modifiers",
|
|
||||||
modifiers = { "panda" },
|
|
||||||
flags = "s",
|
|
||||||
min = 1,
|
|
||||||
max = 1,
|
|
||||||
permission = "citizens.npc.panda")
|
|
||||||
@Requirements(selected = true, ownership = true, types = EntityType.PANDA)
|
|
||||||
public void panda(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
PandaTrait trait = npc.getOrAddTrait(PandaTrait.class);
|
|
||||||
String output = "";
|
|
||||||
if (args.hasValueFlag("gene")) {
|
|
||||||
Panda.Gene gene = Util.matchEnum(Panda.Gene.values(), args.getFlag("gene"));
|
|
||||||
if (gene == null) {
|
|
||||||
throw new CommandUsageException(Messages.INVALID_PANDA_GENE,
|
|
||||||
Util.listValuesPretty(Panda.Gene.values()));
|
|
||||||
}
|
|
||||||
trait.setMainGene(gene);
|
|
||||||
output += ' ' + Messaging.tr(Messages.PANDA_MAIN_GENE_SET, args.getFlag("gene"));
|
|
||||||
}
|
|
||||||
if (args.hasValueFlag("hgene")) {
|
|
||||||
Panda.Gene gene = Util.matchEnum(Panda.Gene.values(), args.getFlag("hgene"));
|
|
||||||
if (gene == null) {
|
|
||||||
throw new CommandUsageException(Messages.INVALID_PANDA_GENE,
|
|
||||||
Util.listValuesPretty(Panda.Gene.values()));
|
|
||||||
}
|
|
||||||
trait.setHiddenGene(gene);
|
|
||||||
output += ' ' + Messaging.tr(Messages.PANDA_HIDDEN_GENE_SET, args.getFlag("hgene"));
|
|
||||||
}
|
|
||||||
if (args.hasFlag('s')) {
|
|
||||||
boolean isSitting = trait.toggleSitting();
|
|
||||||
output += ' ' + Messaging.tr(isSitting ? Messages.PANDA_SITTING : Messages.PANDA_STOPPED_SITTING);
|
|
||||||
}
|
|
||||||
if (!output.isEmpty()) {
|
|
||||||
Messaging.send(sender, output.trim());
|
|
||||||
} else {
|
|
||||||
throw new CommandUsageException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
aliases = { "npc" },
|
|
||||||
usage = "parrot (--variant variant)",
|
|
||||||
desc = "Sets parrot modifiers",
|
|
||||||
modifiers = { "parrot" },
|
|
||||||
min = 1,
|
|
||||||
max = 1,
|
|
||||||
permission = "citizens.npc.parrot")
|
|
||||||
@Requirements(selected = true, ownership = true, types = EntityType.PARROT)
|
|
||||||
public void parrot(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
ParrotTrait trait = npc.getOrAddTrait(ParrotTrait.class);
|
|
||||||
String output = "";
|
|
||||||
if (args.hasValueFlag("variant")) {
|
|
||||||
String variantRaw = args.getFlag("variant");
|
|
||||||
Variant variant = Util.matchEnum(Variant.values(), variantRaw);
|
|
||||||
if (variant == null) {
|
|
||||||
String valid = Util.listValuesPretty(Variant.values());
|
|
||||||
throw new CommandException(Messages.INVALID_PARROT_VARIANT, valid);
|
|
||||||
}
|
|
||||||
trait.setVariant(variant);
|
|
||||||
output += Messaging.tr(Messages.PARROT_VARIANT_SET, Util.prettyEnum(variant));
|
|
||||||
}
|
|
||||||
if (!output.isEmpty()) {
|
|
||||||
Messaging.send(sender, output);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
aliases = { "npc" },
|
|
||||||
usage = "phantom (--size size)",
|
|
||||||
desc = "Sets phantom modifiers",
|
|
||||||
modifiers = { "phantom" },
|
|
||||||
min = 1,
|
|
||||||
max = 1,
|
|
||||||
permission = "citizens.npc.phantom")
|
|
||||||
@Requirements(selected = true, ownership = true, types = EntityType.PHANTOM)
|
|
||||||
public void phantom(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
PhantomTrait trait = npc.getOrAddTrait(PhantomTrait.class);
|
|
||||||
String output = "";
|
|
||||||
if (args.hasValueFlag("size")) {
|
|
||||||
if (args.getFlagInteger("size") <= 0) {
|
|
||||||
throw new CommandUsageException();
|
|
||||||
}
|
|
||||||
trait.setSize(args.getFlagInteger("size"));
|
|
||||||
output += Messaging.tr(Messages.PHANTOM_STATE_SET, args.getFlagInteger("size"));
|
|
||||||
}
|
|
||||||
if (!output.isEmpty()) {
|
|
||||||
Messaging.send(sender, output);
|
|
||||||
} else {
|
|
||||||
throw new CommandUsageException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
aliases = { "npc" },
|
|
||||||
usage = "polarbear (-r)",
|
|
||||||
desc = "Sets polarbear modifiers.",
|
|
||||||
modifiers = { "polarbear" },
|
|
||||||
min = 1,
|
|
||||||
max = 1,
|
|
||||||
flags = "r",
|
|
||||||
permission = "citizens.npc.polarbear")
|
|
||||||
@Requirements(selected = true, ownership = true, types = { EntityType.POLAR_BEAR })
|
|
||||||
public void polarbear(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
PolarBearTrait trait = npc.getOrAddTrait(PolarBearTrait.class);
|
|
||||||
String output = "";
|
|
||||||
if (args.hasFlag('r')) {
|
|
||||||
trait.setRearing(!trait.isRearing());
|
|
||||||
output += Messaging.tr(
|
|
||||||
trait.isRearing() ? Messages.POLAR_BEAR_REARING : Messages.POLAR_BEAR_STOPPED_REARING,
|
|
||||||
npc.getName());
|
|
||||||
}
|
|
||||||
if (!output.isEmpty()) {
|
|
||||||
Messaging.send(sender, output);
|
|
||||||
} else {
|
|
||||||
throw new CommandUsageException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
aliases = { "npc" },
|
|
||||||
usage = "pufferfish (--state state)",
|
|
||||||
desc = "Sets pufferfish modifiers",
|
|
||||||
modifiers = { "pufferfish" },
|
|
||||||
min = 1,
|
|
||||||
max = 1,
|
|
||||||
permission = "citizens.npc.pufferfish")
|
|
||||||
@Requirements(selected = true, ownership = true, types = EntityType.PUFFERFISH)
|
|
||||||
public void pufferfish(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
PufferFishTrait trait = npc.getOrAddTrait(PufferFishTrait.class);
|
|
||||||
String output = "";
|
|
||||||
if (args.hasValueFlag("state")) {
|
|
||||||
int state = Math.min(Math.max(args.getFlagInteger("state"), 0), 3);
|
|
||||||
trait.setPuffState(state);
|
|
||||||
output += Messaging.tr(Messages.PUFFERFISH_STATE_SET, state);
|
|
||||||
}
|
|
||||||
if (!output.isEmpty()) {
|
|
||||||
Messaging.send(sender, output);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
aliases = { "npc" },
|
|
||||||
usage = "shulker (--peek [peek] --color [color])",
|
|
||||||
desc = "Sets shulker modifiers.",
|
|
||||||
modifiers = { "shulker" },
|
|
||||||
min = 1,
|
|
||||||
max = 1,
|
|
||||||
permission = "citizens.npc.shulker")
|
|
||||||
@Requirements(selected = true, ownership = true, types = { EntityType.SHULKER })
|
|
||||||
public void shulker(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
ShulkerTrait trait = npc.getOrAddTrait(ShulkerTrait.class);
|
|
||||||
boolean hasArg = false;
|
|
||||||
if (args.hasValueFlag("peek")) {
|
|
||||||
int peek = (byte) args.getFlagInteger("peek");
|
|
||||||
trait.setPeek(peek);
|
|
||||||
Messaging.sendTr(sender, Messages.SHULKER_PEEK_SET, npc.getName(), peek);
|
|
||||||
hasArg = true;
|
|
||||||
}
|
|
||||||
if (args.hasValueFlag("color")) {
|
|
||||||
DyeColor color = Util.matchEnum(DyeColor.values(), args.getFlag("color"));
|
|
||||||
if (color == null) {
|
|
||||||
Messaging.sendErrorTr(sender, Messages.INVALID_SHULKER_COLOR, Util.listValuesPretty(DyeColor.values()));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
trait.setColor(color);
|
|
||||||
Messaging.sendTr(sender, Messages.SHULKER_COLOR_SET, npc.getName(), Util.prettyEnum(color));
|
|
||||||
hasArg = true;
|
|
||||||
}
|
|
||||||
if (!hasArg) {
|
|
||||||
throw new CommandUsageException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
aliases = { "npc" },
|
|
||||||
usage = "snowman (-d[erp])",
|
|
||||||
desc = "Sets snowman modifiers.",
|
|
||||||
modifiers = { "snowman" },
|
|
||||||
min = 1,
|
|
||||||
max = 1,
|
|
||||||
flags = "d",
|
|
||||||
permission = "citizens.npc.snowman")
|
|
||||||
@Requirements(selected = true, ownership = true, types = { EntityType.SNOWMAN })
|
|
||||||
public void snowman(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
SnowmanTrait trait = npc.getOrAddTrait(SnowmanTrait.class);
|
|
||||||
boolean hasArg = false;
|
|
||||||
if (args.hasFlag('d')) {
|
|
||||||
boolean isDerp = trait.toggleDerp();
|
|
||||||
Messaging.sendTr(sender, isDerp ? Messages.SNOWMAN_DERP_SET : Messages.SNOWMAN_DERP_STOPPED, npc.getName());
|
|
||||||
hasArg = true;
|
|
||||||
}
|
|
||||||
if (!hasArg) {
|
|
||||||
throw new CommandUsageException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
aliases = { "npc" },
|
|
||||||
usage = "tfish (--body color) (--pattern pattern) (--patterncolor color)",
|
|
||||||
desc = "Sets tropical fish modifiers",
|
|
||||||
modifiers = { "tfish" },
|
|
||||||
min = 1,
|
|
||||||
max = 1,
|
|
||||||
permission = "citizens.npc.tropicalfish")
|
|
||||||
@Requirements(selected = true, ownership = true, types = EntityType.TROPICAL_FISH)
|
|
||||||
public void tropicalfish(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
TropicalFishTrait trait = npc.getOrAddTrait(TropicalFishTrait.class);
|
|
||||||
String output = "";
|
|
||||||
if (args.hasValueFlag("body")) {
|
|
||||||
DyeColor color = Util.matchEnum(DyeColor.values(), args.getFlag("body"));
|
|
||||||
if (color == null) {
|
|
||||||
throw new CommandException(Messages.INVALID_TROPICALFISH_COLOR,
|
|
||||||
Util.listValuesPretty(DyeColor.values()));
|
|
||||||
}
|
|
||||||
trait.setBodyColor(color);
|
|
||||||
output += Messaging.tr(Messages.TROPICALFISH_BODY_COLOR_SET, Util.prettyEnum(color));
|
|
||||||
}
|
|
||||||
if (args.hasValueFlag("patterncolor")) {
|
|
||||||
DyeColor color = Util.matchEnum(DyeColor.values(), args.getFlag("patterncolor"));
|
|
||||||
if (color == null) {
|
|
||||||
throw new CommandException(Messages.INVALID_TROPICALFISH_COLOR,
|
|
||||||
Util.listValuesPretty(DyeColor.values()));
|
|
||||||
}
|
|
||||||
trait.setPatternColor(color);
|
|
||||||
output += Messaging.tr(Messages.TROPICALFISH_PATTERN_COLOR_SET, Util.prettyEnum(color));
|
|
||||||
}
|
|
||||||
if (args.hasValueFlag("pattern")) {
|
|
||||||
Pattern pattern = Util.matchEnum(Pattern.values(), args.getFlag("pattern"));
|
|
||||||
if (pattern == null) {
|
|
||||||
throw new CommandException(Messages.INVALID_TROPICALFISH_PATTERN,
|
|
||||||
Util.listValuesPretty(Pattern.values()));
|
|
||||||
}
|
|
||||||
trait.setPattern(pattern);
|
|
||||||
output += Messaging.tr(Messages.TROPICALFISH_PATTERN_SET, Util.prettyEnum(pattern));
|
|
||||||
}
|
|
||||||
if (!output.isEmpty()) {
|
|
||||||
Messaging.send(sender, output);
|
|
||||||
} else {
|
|
||||||
throw new CommandUsageException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
aliases = { "npc" },
|
|
||||||
usage = "villager (--level level) (--type type) (--profession profession)",
|
|
||||||
desc = "Sets villager modifiers",
|
|
||||||
modifiers = { "villager" },
|
|
||||||
min = 1,
|
|
||||||
max = 1,
|
|
||||||
permission = "citizens.npc.villager")
|
|
||||||
@Requirements(selected = true, ownership = true, types = EntityType.VILLAGER)
|
|
||||||
public void villager(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
VillagerTrait trait = npc.getOrAddTrait(VillagerTrait.class);
|
|
||||||
String output = "";
|
|
||||||
if (args.hasValueFlag("level")) {
|
|
||||||
if (args.getFlagInteger("level") < 0) {
|
|
||||||
throw new CommandUsageException();
|
|
||||||
}
|
|
||||||
trait.setLevel(args.getFlagInteger("level"));
|
|
||||||
output += " " + Messaging.tr(Messages.VILLAGER_LEVEL_SET, args.getFlagInteger("level"));
|
|
||||||
}
|
|
||||||
if (args.hasValueFlag("type")) {
|
|
||||||
Villager.Type type = Util.matchEnum(Villager.Type.values(), args.getFlag("type"));
|
|
||||||
if (type == null) {
|
|
||||||
throw new CommandException(Messages.INVALID_VILLAGER_TYPE,
|
|
||||||
Util.listValuesPretty(Villager.Type.values()));
|
|
||||||
}
|
|
||||||
trait.setType(type);
|
|
||||||
output += " " + Messaging.tr(Messages.VILLAGER_TYPE_SET, args.getFlag("type"));
|
|
||||||
}
|
|
||||||
if (args.hasValueFlag("profession")) {
|
|
||||||
Profession parsed = Util.matchEnum(Profession.values(), args.getFlag("profession"));
|
|
||||||
if (parsed == null) {
|
|
||||||
throw new CommandException(Messages.INVALID_PROFESSION, args.getFlag("profession"),
|
|
||||||
Joiner.on(',').join(Profession.values()));
|
|
||||||
}
|
|
||||||
npc.getOrAddTrait(VillagerProfession.class).setProfession(parsed);
|
|
||||||
output += " " + Messaging.tr(Messages.PROFESSION_SET, npc.getName(), args.getFlag("profession"));
|
|
||||||
}
|
|
||||||
if (!output.isEmpty()) {
|
|
||||||
Messaging.send(sender, output.trim());
|
|
||||||
} else {
|
|
||||||
throw new CommandUsageException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -75,6 +75,7 @@ import net.citizensnpcs.api.npc.BlockBreaker;
|
|||||||
import net.citizensnpcs.api.npc.BlockBreaker.BlockBreakerConfiguration;
|
import net.citizensnpcs.api.npc.BlockBreaker.BlockBreakerConfiguration;
|
||||||
import net.citizensnpcs.api.npc.NPC;
|
import net.citizensnpcs.api.npc.NPC;
|
||||||
import net.citizensnpcs.api.npc.NPCRegistry;
|
import net.citizensnpcs.api.npc.NPCRegistry;
|
||||||
|
import net.citizensnpcs.api.trait.Trait;
|
||||||
import net.citizensnpcs.api.trait.TraitInfo;
|
import net.citizensnpcs.api.trait.TraitInfo;
|
||||||
import net.citizensnpcs.api.util.BoundingBox;
|
import net.citizensnpcs.api.util.BoundingBox;
|
||||||
import net.citizensnpcs.api.util.Messaging;
|
import net.citizensnpcs.api.util.Messaging;
|
||||||
@ -180,7 +181,6 @@ import net.citizensnpcs.nms.v1_15_R1.entity.nonliving.ThrownTridentController;
|
|||||||
import net.citizensnpcs.nms.v1_15_R1.entity.nonliving.TippedArrowController;
|
import net.citizensnpcs.nms.v1_15_R1.entity.nonliving.TippedArrowController;
|
||||||
import net.citizensnpcs.nms.v1_15_R1.entity.nonliving.WitherSkullController;
|
import net.citizensnpcs.nms.v1_15_R1.entity.nonliving.WitherSkullController;
|
||||||
import net.citizensnpcs.nms.v1_15_R1.network.EmptyChannel;
|
import net.citizensnpcs.nms.v1_15_R1.network.EmptyChannel;
|
||||||
import net.citizensnpcs.nms.v1_15_R1.trait.Commands;
|
|
||||||
import net.citizensnpcs.npc.EntityControllers;
|
import net.citizensnpcs.npc.EntityControllers;
|
||||||
import net.citizensnpcs.npc.ai.MCNavigationStrategy.MCNavigator;
|
import net.citizensnpcs.npc.ai.MCNavigationStrategy.MCNavigator;
|
||||||
import net.citizensnpcs.npc.ai.MCTargetStrategy.TargetNavigator;
|
import net.citizensnpcs.npc.ai.MCTargetStrategy.TargetNavigator;
|
||||||
@ -758,22 +758,21 @@ public class NMSImpl implements NMSBridge {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void load(CommandManager manager) {
|
public void load(CommandManager manager) {
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(BeeTrait.class));
|
registerTraitWithCommand(manager, BeeTrait.class);
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(BossBarTrait.class));
|
registerTraitWithCommand(manager, BossBarTrait.class);
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(CatTrait.class));
|
registerTraitWithCommand(manager, CatTrait.class);
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(FoxTrait.class));
|
registerTraitWithCommand(manager, FoxTrait.class);
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(LlamaTrait.class));
|
registerTraitWithCommand(manager, LlamaTrait.class);
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(MushroomCowTrait.class));
|
registerTraitWithCommand(manager, MushroomCowTrait.class);
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(ParrotTrait.class));
|
registerTraitWithCommand(manager, ParrotTrait.class);
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(PandaTrait.class));
|
registerTraitWithCommand(manager, PandaTrait.class);
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(PhantomTrait.class));
|
registerTraitWithCommand(manager, PhantomTrait.class);
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(PolarBearTrait.class));
|
registerTraitWithCommand(manager, PolarBearTrait.class);
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(PufferFishTrait.class));
|
registerTraitWithCommand(manager, PufferFishTrait.class);
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(ShulkerTrait.class));
|
registerTraitWithCommand(manager, ShulkerTrait.class);
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(SnowmanTrait.class));
|
registerTraitWithCommand(manager, SnowmanTrait.class);
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(TropicalFishTrait.class));
|
registerTraitWithCommand(manager, TropicalFishTrait.class);
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(VillagerTrait.class));
|
registerTraitWithCommand(manager, VillagerTrait.class);
|
||||||
manager.register(Commands.class);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadEntityTypes() {
|
private void loadEntityTypes() {
|
||||||
@ -1057,6 +1056,11 @@ public class NMSImpl implements NMSBridge {
|
|||||||
throw new IllegalArgumentException("unable to find valid entity superclass for class " + clazz.toString());
|
throw new IllegalArgumentException("unable to find valid entity superclass for class " + clazz.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void registerTraitWithCommand(CommandManager manager, Class<? extends Trait> clazz) {
|
||||||
|
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(clazz));
|
||||||
|
manager.register(clazz);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void remove(org.bukkit.entity.Entity entity) {
|
public void remove(org.bukkit.entity.Entity entity) {
|
||||||
NMSImpl.getHandle(entity).die();
|
NMSImpl.getHandle(entity).die();
|
||||||
|
@ -1,605 +0,0 @@
|
|||||||
package net.citizensnpcs.nms.v1_16_R3.trait;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.bukkit.DyeColor;
|
|
||||||
import org.bukkit.boss.BarColor;
|
|
||||||
import org.bukkit.boss.BarFlag;
|
|
||||||
import org.bukkit.boss.BarStyle;
|
|
||||||
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.MushroomCow;
|
|
||||||
import org.bukkit.entity.Panda;
|
|
||||||
import org.bukkit.entity.Parrot.Variant;
|
|
||||||
import org.bukkit.entity.TropicalFish.Pattern;
|
|
||||||
import org.bukkit.entity.Villager;
|
|
||||||
import org.bukkit.entity.Villager.Profession;
|
|
||||||
|
|
||||||
import com.google.common.base.Joiner;
|
|
||||||
import com.google.common.base.Splitter;
|
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
|
|
||||||
import net.citizensnpcs.api.command.Command;
|
|
||||||
import net.citizensnpcs.api.command.CommandContext;
|
|
||||||
import net.citizensnpcs.api.command.Requirements;
|
|
||||||
import net.citizensnpcs.api.command.exception.CommandException;
|
|
||||||
import net.citizensnpcs.api.command.exception.CommandUsageException;
|
|
||||||
import net.citizensnpcs.api.npc.NPC;
|
|
||||||
import net.citizensnpcs.api.util.Colorizer;
|
|
||||||
import net.citizensnpcs.api.util.Messaging;
|
|
||||||
import net.citizensnpcs.trait.HorseModifiers;
|
|
||||||
import net.citizensnpcs.trait.VillagerProfession;
|
|
||||||
import net.citizensnpcs.trait.versioned.BeeTrait;
|
|
||||||
import net.citizensnpcs.trait.versioned.BossBarTrait;
|
|
||||||
import net.citizensnpcs.trait.versioned.CatTrait;
|
|
||||||
import net.citizensnpcs.trait.versioned.FoxTrait;
|
|
||||||
import net.citizensnpcs.trait.versioned.LlamaTrait;
|
|
||||||
import net.citizensnpcs.trait.versioned.MushroomCowTrait;
|
|
||||||
import net.citizensnpcs.trait.versioned.PandaTrait;
|
|
||||||
import net.citizensnpcs.trait.versioned.ParrotTrait;
|
|
||||||
import net.citizensnpcs.trait.versioned.PhantomTrait;
|
|
||||||
import net.citizensnpcs.trait.versioned.PiglinTrait;
|
|
||||||
import net.citizensnpcs.trait.versioned.PolarBearTrait;
|
|
||||||
import net.citizensnpcs.trait.versioned.PufferFishTrait;
|
|
||||||
import net.citizensnpcs.trait.versioned.ShulkerTrait;
|
|
||||||
import net.citizensnpcs.trait.versioned.SnowmanTrait;
|
|
||||||
import net.citizensnpcs.trait.versioned.TropicalFishTrait;
|
|
||||||
import net.citizensnpcs.trait.versioned.VillagerTrait;
|
|
||||||
import net.citizensnpcs.util.Messages;
|
|
||||||
import net.citizensnpcs.util.Util;
|
|
||||||
|
|
||||||
public class Commands {
|
|
||||||
@Command(
|
|
||||||
aliases = { "npc" },
|
|
||||||
usage = "bee (-s/-n) --anger anger",
|
|
||||||
desc = "Sets bee modifiers",
|
|
||||||
modifiers = { "bee" },
|
|
||||||
min = 1,
|
|
||||||
max = 1,
|
|
||||||
flags = "sn",
|
|
||||||
permission = "citizens.npc.bee")
|
|
||||||
@Requirements(selected = true, ownership = true, types = EntityType.BEE)
|
|
||||||
public void bee(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
BeeTrait trait = npc.getOrAddTrait(BeeTrait.class);
|
|
||||||
String output = "";
|
|
||||||
if (args.hasValueFlag("anger")) {
|
|
||||||
int anger = args.getFlagInteger("anger");
|
|
||||||
if (anger < 0) {
|
|
||||||
throw new CommandException(Messages.INVALID_BEE_ANGER);
|
|
||||||
}
|
|
||||||
trait.setAnger(anger);
|
|
||||||
output += ' ' + Messaging.tr(Messages.BEE_ANGER_SET, args.getFlag("anger"));
|
|
||||||
}
|
|
||||||
if (args.hasFlag('s')) {
|
|
||||||
trait.setStung(!trait.hasStung());
|
|
||||||
output += ' ' + (trait.hasStung() ? Messaging.tr(Messages.BEE_STUNG, npc.getName())
|
|
||||||
: Messaging.tr(Messages.BEE_NOT_STUNG, npc.getName()));
|
|
||||||
}
|
|
||||||
if (args.hasFlag('n')) {
|
|
||||||
trait.setNectar(!trait.hasNectar());
|
|
||||||
output += ' ' + (trait.hasNectar() ? Messaging.tr(Messages.BEE_HAS_NECTAR, npc.getName())
|
|
||||||
: Messaging.tr(Messages.BEE_NO_NECTAR, npc.getName()));
|
|
||||||
}
|
|
||||||
if (!output.isEmpty()) {
|
|
||||||
Messaging.send(sender, output.trim());
|
|
||||||
} else {
|
|
||||||
throw new CommandUsageException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
aliases = { "npc" },
|
|
||||||
usage = "bossbar --style [style] --color [color] --title [title] --visible [visible] --flags [flags] --track [health | placeholder]",
|
|
||||||
desc = "Edit bossbar properties",
|
|
||||||
modifiers = { "bossbar" },
|
|
||||||
min = 1,
|
|
||||||
max = 1)
|
|
||||||
@Requirements(selected = true, ownership = true)
|
|
||||||
public void bossbar(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
BossBarTrait trait = npc.getOrAddTrait(BossBarTrait.class);
|
|
||||||
if (args.hasValueFlag("style")) {
|
|
||||||
BarStyle style = Util.matchEnum(BarStyle.values(), args.getFlag("style"));
|
|
||||||
if (style != null) {
|
|
||||||
trait.setStyle(style);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (args.hasValueFlag("color")) {
|
|
||||||
BarColor color = Util.matchEnum(BarColor.values(), args.getFlag("color"));
|
|
||||||
if (color != null) {
|
|
||||||
trait.setColor(color);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (args.hasValueFlag("track")) {
|
|
||||||
trait.setTrackVariable(args.getFlag("track"));
|
|
||||||
}
|
|
||||||
if (args.hasValueFlag("title")) {
|
|
||||||
trait.setTitle(Colorizer.parseColors(args.getFlag("title")));
|
|
||||||
}
|
|
||||||
if (args.hasValueFlag("visible")) {
|
|
||||||
trait.setVisible(Boolean.parseBoolean(args.getFlag("visible")));
|
|
||||||
}
|
|
||||||
if (args.hasValueFlag("flags")) {
|
|
||||||
List<BarFlag> flags = Lists.newArrayList();
|
|
||||||
for (String s : Splitter.on(',').omitEmptyStrings().trimResults().split(args.getFlag("flags"))) {
|
|
||||||
BarFlag flag = Util.matchEnum(BarFlag.values(), s);
|
|
||||||
if (flag != null) {
|
|
||||||
flags.add(flag);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
trait.setFlags(flags);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
aliases = { "npc" },
|
|
||||||
usage = "cat (-s/-n/-l) --type type --ccolor collar color",
|
|
||||||
desc = "Sets cat modifiers",
|
|
||||||
modifiers = { "cat" },
|
|
||||||
min = 1,
|
|
||||||
max = 1,
|
|
||||||
flags = "snl",
|
|
||||||
permission = "citizens.npc.cat")
|
|
||||||
@Requirements(selected = true, ownership = true, types = EntityType.CAT)
|
|
||||||
public void cat(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
CatTrait trait = npc.getOrAddTrait(CatTrait.class);
|
|
||||||
String output = "";
|
|
||||||
if (args.hasValueFlag("type")) {
|
|
||||||
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()));
|
|
||||||
}
|
|
||||||
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, npc.getName());
|
|
||||||
} else if (args.hasFlag('n')) {
|
|
||||||
trait.setSitting(false);
|
|
||||||
output += ' ' + Messaging.tr(Messages.CAT_STOPPED_SITTING, npc.getName());
|
|
||||||
}
|
|
||||||
if (args.hasFlag('l')) {
|
|
||||||
trait.setLyingDown(!trait.isLyingDown());
|
|
||||||
output += ' ' + Messaging.tr(trait.isLyingDown() ? Messages.CAT_STARTED_LYING : Messages.CAT_STOPPED_LYING,
|
|
||||||
npc.getName());
|
|
||||||
}
|
|
||||||
if (!output.isEmpty()) {
|
|
||||||
Messaging.send(sender, output.trim());
|
|
||||||
} else {
|
|
||||||
throw new CommandUsageException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@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.getOrAddTrait(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)",
|
|
||||||
desc = "Sets llama modifiers",
|
|
||||||
modifiers = { "llama" },
|
|
||||||
min = 1,
|
|
||||||
max = 1,
|
|
||||||
permission = "citizens.npc.llama")
|
|
||||||
@Requirements(selected = true, ownership = true, types = { EntityType.LLAMA, EntityType.TRADER_LLAMA })
|
|
||||||
public void llama(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
LlamaTrait trait = npc.getOrAddTrait(LlamaTrait.class);
|
|
||||||
String output = "";
|
|
||||||
if (args.hasValueFlag("color") || args.hasValueFlag("colour")) {
|
|
||||||
String colorRaw = args.getFlag("color", args.getFlag("colour"));
|
|
||||||
Color color = Util.matchEnum(Color.values(), colorRaw);
|
|
||||||
if (color == null) {
|
|
||||||
String valid = Util.listValuesPretty(Color.values());
|
|
||||||
throw new CommandException(Messages.INVALID_LLAMA_COLOR, valid);
|
|
||||||
}
|
|
||||||
trait.setColor(color);
|
|
||||||
output += Messaging.tr(Messages.LLAMA_COLOR_SET, Util.prettyEnum(color));
|
|
||||||
}
|
|
||||||
if (args.hasValueFlag("strength")) {
|
|
||||||
trait.setStrength(Math.max(1, Math.min(5, args.getFlagInteger("strength"))));
|
|
||||||
output += Messaging.tr(Messages.LLAMA_STRENGTH_SET, args.getFlagInteger("strength"));
|
|
||||||
}
|
|
||||||
if (args.hasFlag('c')) {
|
|
||||||
npc.getOrAddTrait(HorseModifiers.class).setCarryingChest(true);
|
|
||||||
output += Messaging.tr(Messages.HORSE_CHEST_SET) + " ";
|
|
||||||
} else if (args.hasFlag('b')) {
|
|
||||||
npc.getOrAddTrait(HorseModifiers.class).setCarryingChest(false);
|
|
||||||
output += Messaging.tr(Messages.HORSE_CHEST_UNSET) + " ";
|
|
||||||
}
|
|
||||||
if (!output.isEmpty()) {
|
|
||||||
Messaging.send(sender, output);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
aliases = { "npc" },
|
|
||||||
usage = "mcow (--variant [variant])",
|
|
||||||
desc = "Sets mushroom cow modifiers.",
|
|
||||||
modifiers = { "mcow", "mushroomcow" },
|
|
||||||
min = 1,
|
|
||||||
max = 1,
|
|
||||||
permission = "citizens.npc.mushroomcow")
|
|
||||||
@Requirements(selected = true, ownership = true, types = { EntityType.MUSHROOM_COW })
|
|
||||||
public void mushroomcow(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
MushroomCowTrait trait = npc.getOrAddTrait(MushroomCowTrait.class);
|
|
||||||
boolean hasArg = false;
|
|
||||||
if (args.hasValueFlag("variant")) {
|
|
||||||
MushroomCow.Variant variant = Util.matchEnum(MushroomCow.Variant.values(), args.getFlag("variant"));
|
|
||||||
if (variant == null) {
|
|
||||||
Messaging.sendErrorTr(sender, Messages.INVALID_MUSHROOM_COW_VARIANT,
|
|
||||||
Util.listValuesPretty(MushroomCow.Variant.values()));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
trait.setVariant(variant);
|
|
||||||
Messaging.sendTr(sender, Messages.MUSHROOM_COW_VARIANT_SET, npc.getName(), variant);
|
|
||||||
hasArg = true;
|
|
||||||
}
|
|
||||||
if (!hasArg) {
|
|
||||||
throw new CommandUsageException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
aliases = { "npc" },
|
|
||||||
usage = "panda --gene (main gene) --hgene (hidden gene) -s(itting)",
|
|
||||||
desc = "Sets panda modifiers",
|
|
||||||
modifiers = { "panda" },
|
|
||||||
flags = "s",
|
|
||||||
min = 1,
|
|
||||||
max = 1,
|
|
||||||
permission = "citizens.npc.panda")
|
|
||||||
@Requirements(selected = true, ownership = true, types = EntityType.PANDA)
|
|
||||||
public void panda(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
PandaTrait trait = npc.getOrAddTrait(PandaTrait.class);
|
|
||||||
String output = "";
|
|
||||||
if (args.hasValueFlag("gene")) {
|
|
||||||
Panda.Gene gene = Util.matchEnum(Panda.Gene.values(), args.getFlag("gene"));
|
|
||||||
if (gene == null) {
|
|
||||||
throw new CommandUsageException(Messages.INVALID_PANDA_GENE,
|
|
||||||
Util.listValuesPretty(Panda.Gene.values()));
|
|
||||||
}
|
|
||||||
trait.setMainGene(gene);
|
|
||||||
output += ' ' + Messaging.tr(Messages.PANDA_MAIN_GENE_SET, args.getFlag("gene"));
|
|
||||||
}
|
|
||||||
if (args.hasValueFlag("hgene")) {
|
|
||||||
Panda.Gene gene = Util.matchEnum(Panda.Gene.values(), args.getFlag("hgene"));
|
|
||||||
if (gene == null) {
|
|
||||||
throw new CommandUsageException(Messages.INVALID_PANDA_GENE,
|
|
||||||
Util.listValuesPretty(Panda.Gene.values()));
|
|
||||||
}
|
|
||||||
trait.setHiddenGene(gene);
|
|
||||||
output += ' ' + Messaging.tr(Messages.PANDA_HIDDEN_GENE_SET, args.getFlag("hgene"));
|
|
||||||
}
|
|
||||||
if (args.hasFlag('s')) {
|
|
||||||
boolean isSitting = trait.toggleSitting();
|
|
||||||
output += ' ' + Messaging.tr(isSitting ? Messages.PANDA_SITTING : Messages.PANDA_STOPPED_SITTING);
|
|
||||||
}
|
|
||||||
if (!output.isEmpty()) {
|
|
||||||
Messaging.send(sender, output.trim());
|
|
||||||
} else {
|
|
||||||
throw new CommandUsageException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
aliases = { "npc" },
|
|
||||||
usage = "parrot (--variant variant)",
|
|
||||||
desc = "Sets parrot modifiers",
|
|
||||||
modifiers = { "parrot" },
|
|
||||||
min = 1,
|
|
||||||
max = 1,
|
|
||||||
permission = "citizens.npc.parrot")
|
|
||||||
@Requirements(selected = true, ownership = true, types = EntityType.PARROT)
|
|
||||||
public void parrot(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
ParrotTrait trait = npc.getOrAddTrait(ParrotTrait.class);
|
|
||||||
String output = "";
|
|
||||||
if (args.hasValueFlag("variant")) {
|
|
||||||
String variantRaw = args.getFlag("variant");
|
|
||||||
Variant variant = Util.matchEnum(Variant.values(), variantRaw);
|
|
||||||
if (variant == null) {
|
|
||||||
String valid = Util.listValuesPretty(Variant.values());
|
|
||||||
throw new CommandException(Messages.INVALID_PARROT_VARIANT, valid);
|
|
||||||
}
|
|
||||||
trait.setVariant(variant);
|
|
||||||
output += Messaging.tr(Messages.PARROT_VARIANT_SET, Util.prettyEnum(variant));
|
|
||||||
}
|
|
||||||
if (!output.isEmpty()) {
|
|
||||||
Messaging.send(sender, output);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
aliases = { "npc" },
|
|
||||||
usage = "phantom (--size size)",
|
|
||||||
desc = "Sets phantom modifiers",
|
|
||||||
modifiers = { "phantom" },
|
|
||||||
min = 1,
|
|
||||||
max = 1,
|
|
||||||
permission = "citizens.npc.phantom")
|
|
||||||
@Requirements(selected = true, ownership = true, types = EntityType.PHANTOM)
|
|
||||||
public void phantom(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
PhantomTrait trait = npc.getOrAddTrait(PhantomTrait.class);
|
|
||||||
String output = "";
|
|
||||||
if (args.hasValueFlag("size")) {
|
|
||||||
if (args.getFlagInteger("size") <= 0) {
|
|
||||||
throw new CommandUsageException();
|
|
||||||
}
|
|
||||||
trait.setSize(args.getFlagInteger("size"));
|
|
||||||
output += Messaging.tr(Messages.PHANTOM_STATE_SET, args.getFlagInteger("size"));
|
|
||||||
}
|
|
||||||
if (!output.isEmpty()) {
|
|
||||||
Messaging.send(sender, output);
|
|
||||||
} else {
|
|
||||||
throw new CommandUsageException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
aliases = { "npc" },
|
|
||||||
usage = "piglin (--dancing [true|false])",
|
|
||||||
desc = "Sets piglin modifiers.",
|
|
||||||
modifiers = { "piglin" },
|
|
||||||
min = 1,
|
|
||||||
max = 1,
|
|
||||||
permission = "citizens.npc.piglin")
|
|
||||||
@Requirements(selected = true, ownership = true, types = { EntityType.PIGLIN })
|
|
||||||
public void piglin(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
PiglinTrait trait = npc.getOrAddTrait(PiglinTrait.class);
|
|
||||||
boolean hasArg = false;
|
|
||||||
if (args.hasValueFlag("dancing")) {
|
|
||||||
boolean dancing = Boolean.valueOf(args.getFlag("dancing"));
|
|
||||||
trait.setDancing(dancing);
|
|
||||||
Messaging.sendTr(sender, dancing ? Messages.PIGLIN_DANCING_SET : Messages.PIGLIN_DANCING_UNSET,
|
|
||||||
npc.getName());
|
|
||||||
hasArg = true;
|
|
||||||
}
|
|
||||||
if (!hasArg) {
|
|
||||||
throw new CommandUsageException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
aliases = { "npc" },
|
|
||||||
usage = "polarbear (-r)",
|
|
||||||
desc = "Sets polarbear modifiers.",
|
|
||||||
modifiers = { "polarbear" },
|
|
||||||
min = 1,
|
|
||||||
max = 1,
|
|
||||||
flags = "r",
|
|
||||||
permission = "citizens.npc.polarbear")
|
|
||||||
@Requirements(selected = true, ownership = true, types = { EntityType.POLAR_BEAR })
|
|
||||||
public void polarbear(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
PolarBearTrait trait = npc.getOrAddTrait(PolarBearTrait.class);
|
|
||||||
String output = "";
|
|
||||||
if (args.hasFlag('r')) {
|
|
||||||
trait.setRearing(!trait.isRearing());
|
|
||||||
output += Messaging.tr(
|
|
||||||
trait.isRearing() ? Messages.POLAR_BEAR_REARING : Messages.POLAR_BEAR_STOPPED_REARING,
|
|
||||||
npc.getName());
|
|
||||||
}
|
|
||||||
if (!output.isEmpty()) {
|
|
||||||
Messaging.send(sender, output);
|
|
||||||
} else {
|
|
||||||
throw new CommandUsageException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
aliases = { "npc" },
|
|
||||||
usage = "pufferfish (--state state)",
|
|
||||||
desc = "Sets pufferfish modifiers",
|
|
||||||
modifiers = { "pufferfish" },
|
|
||||||
min = 1,
|
|
||||||
max = 1,
|
|
||||||
permission = "citizens.npc.pufferfish")
|
|
||||||
@Requirements(selected = true, ownership = true, types = EntityType.PUFFERFISH)
|
|
||||||
public void pufferfish(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
PufferFishTrait trait = npc.getOrAddTrait(PufferFishTrait.class);
|
|
||||||
String output = "";
|
|
||||||
if (args.hasValueFlag("state")) {
|
|
||||||
int state = Math.min(Math.max(args.getFlagInteger("state"), 0), 3);
|
|
||||||
trait.setPuffState(state);
|
|
||||||
output += Messaging.tr(Messages.PUFFERFISH_STATE_SET, state);
|
|
||||||
}
|
|
||||||
if (!output.isEmpty()) {
|
|
||||||
Messaging.send(sender, output);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
aliases = { "npc" },
|
|
||||||
usage = "shulker (--peek [peek] --color [color])",
|
|
||||||
desc = "Sets shulker modifiers.",
|
|
||||||
modifiers = { "shulker" },
|
|
||||||
min = 1,
|
|
||||||
max = 1,
|
|
||||||
permission = "citizens.npc.shulker")
|
|
||||||
@Requirements(selected = true, ownership = true, types = { EntityType.SHULKER })
|
|
||||||
public void shulker(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
ShulkerTrait trait = npc.getOrAddTrait(ShulkerTrait.class);
|
|
||||||
boolean hasArg = false;
|
|
||||||
if (args.hasValueFlag("peek")) {
|
|
||||||
int peek = (byte) args.getFlagInteger("peek");
|
|
||||||
trait.setPeek(peek);
|
|
||||||
Messaging.sendTr(sender, Messages.SHULKER_PEEK_SET, npc.getName(), peek);
|
|
||||||
hasArg = true;
|
|
||||||
}
|
|
||||||
if (args.hasValueFlag("color")) {
|
|
||||||
DyeColor color = Util.matchEnum(DyeColor.values(), args.getFlag("color"));
|
|
||||||
if (color == null) {
|
|
||||||
Messaging.sendErrorTr(sender, Messages.INVALID_SHULKER_COLOR, Util.listValuesPretty(DyeColor.values()));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
trait.setColor(color);
|
|
||||||
Messaging.sendTr(sender, Messages.SHULKER_COLOR_SET, npc.getName(), Util.prettyEnum(color));
|
|
||||||
hasArg = true;
|
|
||||||
}
|
|
||||||
if (!hasArg) {
|
|
||||||
throw new CommandUsageException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
aliases = { "npc" },
|
|
||||||
usage = "snowman (-d[erp])",
|
|
||||||
desc = "Sets snowman modifiers.",
|
|
||||||
modifiers = { "snowman" },
|
|
||||||
min = 1,
|
|
||||||
max = 1,
|
|
||||||
flags = "d",
|
|
||||||
permission = "citizens.npc.snowman")
|
|
||||||
@Requirements(selected = true, ownership = true, types = { EntityType.SNOWMAN })
|
|
||||||
public void snowman(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
SnowmanTrait trait = npc.getOrAddTrait(SnowmanTrait.class);
|
|
||||||
boolean hasArg = false;
|
|
||||||
if (args.hasFlag('d')) {
|
|
||||||
boolean isDerp = trait.toggleDerp();
|
|
||||||
Messaging.sendTr(sender, isDerp ? Messages.SNOWMAN_DERP_SET : Messages.SNOWMAN_DERP_STOPPED, npc.getName());
|
|
||||||
hasArg = true;
|
|
||||||
}
|
|
||||||
if (!hasArg) {
|
|
||||||
throw new CommandUsageException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
aliases = { "npc" },
|
|
||||||
usage = "tfish (--body color) (--pattern pattern) (--patterncolor color)",
|
|
||||||
desc = "Sets tropical fish modifiers",
|
|
||||||
modifiers = { "tfish" },
|
|
||||||
min = 1,
|
|
||||||
max = 1,
|
|
||||||
permission = "citizens.npc.tropicalfish")
|
|
||||||
@Requirements(selected = true, ownership = true, types = EntityType.TROPICAL_FISH)
|
|
||||||
public void tropicalfish(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
TropicalFishTrait trait = npc.getOrAddTrait(TropicalFishTrait.class);
|
|
||||||
String output = "";
|
|
||||||
if (args.hasValueFlag("body")) {
|
|
||||||
DyeColor color = Util.matchEnum(DyeColor.values(), args.getFlag("body"));
|
|
||||||
if (color == null) {
|
|
||||||
throw new CommandException(Messages.INVALID_TROPICALFISH_COLOR,
|
|
||||||
Util.listValuesPretty(DyeColor.values()));
|
|
||||||
}
|
|
||||||
trait.setBodyColor(color);
|
|
||||||
output += Messaging.tr(Messages.TROPICALFISH_BODY_COLOR_SET, Util.prettyEnum(color));
|
|
||||||
}
|
|
||||||
if (args.hasValueFlag("patterncolor")) {
|
|
||||||
DyeColor color = Util.matchEnum(DyeColor.values(), args.getFlag("patterncolor"));
|
|
||||||
if (color == null) {
|
|
||||||
throw new CommandException(Messages.INVALID_TROPICALFISH_COLOR,
|
|
||||||
Util.listValuesPretty(DyeColor.values()));
|
|
||||||
}
|
|
||||||
trait.setPatternColor(color);
|
|
||||||
output += Messaging.tr(Messages.TROPICALFISH_PATTERN_COLOR_SET, Util.prettyEnum(color));
|
|
||||||
}
|
|
||||||
if (args.hasValueFlag("pattern")) {
|
|
||||||
Pattern pattern = Util.matchEnum(Pattern.values(), args.getFlag("pattern"));
|
|
||||||
if (pattern == null) {
|
|
||||||
throw new CommandException(Messages.INVALID_TROPICALFISH_PATTERN,
|
|
||||||
Util.listValuesPretty(Pattern.values()));
|
|
||||||
}
|
|
||||||
trait.setPattern(pattern);
|
|
||||||
output += Messaging.tr(Messages.TROPICALFISH_PATTERN_SET, Util.prettyEnum(pattern));
|
|
||||||
}
|
|
||||||
if (!output.isEmpty()) {
|
|
||||||
Messaging.send(sender, output);
|
|
||||||
} else {
|
|
||||||
throw new CommandUsageException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
aliases = { "npc" },
|
|
||||||
usage = "villager (--level level) (--type type) (--profession profession)",
|
|
||||||
desc = "Sets villager modifiers",
|
|
||||||
modifiers = { "villager" },
|
|
||||||
min = 1,
|
|
||||||
max = 1,
|
|
||||||
permission = "citizens.npc.villager")
|
|
||||||
@Requirements(selected = true, ownership = true, types = EntityType.VILLAGER)
|
|
||||||
public void villager(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
VillagerTrait trait = npc.getOrAddTrait(VillagerTrait.class);
|
|
||||||
String output = "";
|
|
||||||
if (args.hasValueFlag("level")) {
|
|
||||||
if (args.getFlagInteger("level") < 0) {
|
|
||||||
throw new CommandUsageException();
|
|
||||||
}
|
|
||||||
trait.setLevel(args.getFlagInteger("level"));
|
|
||||||
output += " " + Messaging.tr(Messages.VILLAGER_LEVEL_SET, args.getFlagInteger("level"));
|
|
||||||
}
|
|
||||||
if (args.hasValueFlag("type")) {
|
|
||||||
Villager.Type type = Util.matchEnum(Villager.Type.values(), args.getFlag("type"));
|
|
||||||
if (type == null) {
|
|
||||||
throw new CommandException(Messages.INVALID_VILLAGER_TYPE,
|
|
||||||
Util.listValuesPretty(Villager.Type.values()));
|
|
||||||
}
|
|
||||||
trait.setType(type);
|
|
||||||
output += " " + Messaging.tr(Messages.VILLAGER_TYPE_SET, args.getFlag("type"));
|
|
||||||
}
|
|
||||||
if (args.hasValueFlag("profession")) {
|
|
||||||
Profession parsed = Util.matchEnum(Profession.values(), args.getFlag("profession"));
|
|
||||||
if (parsed == null) {
|
|
||||||
throw new CommandException(Messages.INVALID_PROFESSION, args.getFlag("profession"),
|
|
||||||
Joiner.on(',').join(Profession.values()));
|
|
||||||
}
|
|
||||||
npc.getOrAddTrait(VillagerProfession.class).setProfession(parsed);
|
|
||||||
output += " " + Messaging.tr(Messages.PROFESSION_SET, npc.getName(), args.getFlag("profession"));
|
|
||||||
}
|
|
||||||
if (!output.isEmpty()) {
|
|
||||||
Messaging.send(sender, output.trim());
|
|
||||||
} else {
|
|
||||||
throw new CommandUsageException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -76,6 +76,7 @@ import net.citizensnpcs.api.npc.BlockBreaker;
|
|||||||
import net.citizensnpcs.api.npc.BlockBreaker.BlockBreakerConfiguration;
|
import net.citizensnpcs.api.npc.BlockBreaker.BlockBreakerConfiguration;
|
||||||
import net.citizensnpcs.api.npc.NPC;
|
import net.citizensnpcs.api.npc.NPC;
|
||||||
import net.citizensnpcs.api.npc.NPCRegistry;
|
import net.citizensnpcs.api.npc.NPCRegistry;
|
||||||
|
import net.citizensnpcs.api.trait.Trait;
|
||||||
import net.citizensnpcs.api.trait.TraitInfo;
|
import net.citizensnpcs.api.trait.TraitInfo;
|
||||||
import net.citizensnpcs.api.util.BoundingBox;
|
import net.citizensnpcs.api.util.BoundingBox;
|
||||||
import net.citizensnpcs.api.util.Messaging;
|
import net.citizensnpcs.api.util.Messaging;
|
||||||
@ -186,7 +187,6 @@ import net.citizensnpcs.nms.v1_16_R3.entity.nonliving.ThrownTridentController;
|
|||||||
import net.citizensnpcs.nms.v1_16_R3.entity.nonliving.TippedArrowController;
|
import net.citizensnpcs.nms.v1_16_R3.entity.nonliving.TippedArrowController;
|
||||||
import net.citizensnpcs.nms.v1_16_R3.entity.nonliving.WitherSkullController;
|
import net.citizensnpcs.nms.v1_16_R3.entity.nonliving.WitherSkullController;
|
||||||
import net.citizensnpcs.nms.v1_16_R3.network.EmptyChannel;
|
import net.citizensnpcs.nms.v1_16_R3.network.EmptyChannel;
|
||||||
import net.citizensnpcs.nms.v1_16_R3.trait.Commands;
|
|
||||||
import net.citizensnpcs.npc.EntityControllers;
|
import net.citizensnpcs.npc.EntityControllers;
|
||||||
import net.citizensnpcs.npc.ai.MCNavigationStrategy.MCNavigator;
|
import net.citizensnpcs.npc.ai.MCNavigationStrategy.MCNavigator;
|
||||||
import net.citizensnpcs.npc.ai.MCTargetStrategy.TargetNavigator;
|
import net.citizensnpcs.npc.ai.MCTargetStrategy.TargetNavigator;
|
||||||
@ -776,23 +776,22 @@ public class NMSImpl implements NMSBridge {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void load(CommandManager manager) {
|
public void load(CommandManager manager) {
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(BeeTrait.class));
|
registerTraitWithCommand(manager, BeeTrait.class);
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(BossBarTrait.class));
|
registerTraitWithCommand(manager, BossBarTrait.class);
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(CatTrait.class));
|
registerTraitWithCommand(manager, CatTrait.class);
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(FoxTrait.class));
|
registerTraitWithCommand(manager, FoxTrait.class);
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(LlamaTrait.class));
|
registerTraitWithCommand(manager, LlamaTrait.class);
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(MushroomCowTrait.class));
|
registerTraitWithCommand(manager, MushroomCowTrait.class);
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(ParrotTrait.class));
|
registerTraitWithCommand(manager, ParrotTrait.class);
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(PandaTrait.class));
|
registerTraitWithCommand(manager, PandaTrait.class);
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(PiglinTrait.class));
|
registerTraitWithCommand(manager, PiglinTrait.class);
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(PhantomTrait.class));
|
registerTraitWithCommand(manager, PhantomTrait.class);
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(PolarBearTrait.class));
|
registerTraitWithCommand(manager, PolarBearTrait.class);
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(PufferFishTrait.class));
|
registerTraitWithCommand(manager, PufferFishTrait.class);
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(ShulkerTrait.class));
|
registerTraitWithCommand(manager, ShulkerTrait.class);
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(SnowmanTrait.class));
|
registerTraitWithCommand(manager, SnowmanTrait.class);
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(TropicalFishTrait.class));
|
registerTraitWithCommand(manager, TropicalFishTrait.class);
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(VillagerTrait.class));
|
registerTraitWithCommand(manager, VillagerTrait.class);
|
||||||
manager.register(Commands.class);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadEntityTypes() {
|
private void loadEntityTypes() {
|
||||||
@ -1075,6 +1074,11 @@ public class NMSImpl implements NMSBridge {
|
|||||||
throw new IllegalArgumentException("unable to find valid entity superclass for class " + clazz.toString());
|
throw new IllegalArgumentException("unable to find valid entity superclass for class " + clazz.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void registerTraitWithCommand(CommandManager manager, Class<? extends Trait> clazz) {
|
||||||
|
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(clazz));
|
||||||
|
manager.register(clazz);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void remove(org.bukkit.entity.Entity entity) {
|
public void remove(org.bukkit.entity.Entity entity) {
|
||||||
NMSImpl.getHandle(entity).die();
|
NMSImpl.getHandle(entity).die();
|
||||||
|
@ -1,641 +0,0 @@
|
|||||||
package net.citizensnpcs.nms.v1_17_R1.trait;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.bukkit.DyeColor;
|
|
||||||
import org.bukkit.boss.BarColor;
|
|
||||||
import org.bukkit.boss.BarFlag;
|
|
||||||
import org.bukkit.boss.BarStyle;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Axolotl;
|
|
||||||
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.MushroomCow;
|
|
||||||
import org.bukkit.entity.Panda;
|
|
||||||
import org.bukkit.entity.Parrot.Variant;
|
|
||||||
import org.bukkit.entity.TropicalFish.Pattern;
|
|
||||||
import org.bukkit.entity.Villager;
|
|
||||||
import org.bukkit.entity.Villager.Profession;
|
|
||||||
|
|
||||||
import com.google.common.base.Joiner;
|
|
||||||
import com.google.common.base.Splitter;
|
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
|
|
||||||
import net.citizensnpcs.api.command.Command;
|
|
||||||
import net.citizensnpcs.api.command.CommandContext;
|
|
||||||
import net.citizensnpcs.api.command.Requirements;
|
|
||||||
import net.citizensnpcs.api.command.exception.CommandException;
|
|
||||||
import net.citizensnpcs.api.command.exception.CommandUsageException;
|
|
||||||
import net.citizensnpcs.api.npc.NPC;
|
|
||||||
import net.citizensnpcs.api.util.Colorizer;
|
|
||||||
import net.citizensnpcs.api.util.Messaging;
|
|
||||||
import net.citizensnpcs.trait.HorseModifiers;
|
|
||||||
import net.citizensnpcs.trait.VillagerProfession;
|
|
||||||
import net.citizensnpcs.trait.versioned.AxolotlTrait;
|
|
||||||
import net.citizensnpcs.trait.versioned.BeeTrait;
|
|
||||||
import net.citizensnpcs.trait.versioned.BossBarTrait;
|
|
||||||
import net.citizensnpcs.trait.versioned.CatTrait;
|
|
||||||
import net.citizensnpcs.trait.versioned.FoxTrait;
|
|
||||||
import net.citizensnpcs.trait.versioned.LlamaTrait;
|
|
||||||
import net.citizensnpcs.trait.versioned.MushroomCowTrait;
|
|
||||||
import net.citizensnpcs.trait.versioned.PandaTrait;
|
|
||||||
import net.citizensnpcs.trait.versioned.ParrotTrait;
|
|
||||||
import net.citizensnpcs.trait.versioned.PhantomTrait;
|
|
||||||
import net.citizensnpcs.trait.versioned.PiglinTrait;
|
|
||||||
import net.citizensnpcs.trait.versioned.PolarBearTrait;
|
|
||||||
import net.citizensnpcs.trait.versioned.PufferFishTrait;
|
|
||||||
import net.citizensnpcs.trait.versioned.ShulkerTrait;
|
|
||||||
import net.citizensnpcs.trait.versioned.SnowmanTrait;
|
|
||||||
import net.citizensnpcs.trait.versioned.TropicalFishTrait;
|
|
||||||
import net.citizensnpcs.trait.versioned.VillagerTrait;
|
|
||||||
import net.citizensnpcs.util.Messages;
|
|
||||||
import net.citizensnpcs.util.Util;
|
|
||||||
|
|
||||||
public class Commands {
|
|
||||||
@Command(
|
|
||||||
aliases = { "npc" },
|
|
||||||
usage = "axolotl (-d) (--variant variant)",
|
|
||||||
desc = "Sets axolotl modifiers",
|
|
||||||
modifiers = { "axolotl" },
|
|
||||||
min = 1,
|
|
||||||
max = 1,
|
|
||||||
flags = "d",
|
|
||||||
permission = "citizens.npc.axolotl")
|
|
||||||
@Requirements(selected = true, ownership = true, types = EntityType.AXOLOTL)
|
|
||||||
public void axolotl(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
AxolotlTrait trait = npc.getOrAddTrait(AxolotlTrait.class);
|
|
||||||
String output = "";
|
|
||||||
if (args.hasValueFlag("variant")) {
|
|
||||||
Axolotl.Variant variant = Util.matchEnum(Axolotl.Variant.values(), args.getFlag("variant"));
|
|
||||||
if (variant == null) {
|
|
||||||
throw new CommandException(Messages.INVALID_AXOLOTL_VARIANT,
|
|
||||||
Util.listValuesPretty(Axolotl.Variant.values()));
|
|
||||||
}
|
|
||||||
trait.setVariant(variant);
|
|
||||||
output += ' ' + Messaging.tr(Messages.AXOLOTL_VARIANT_SET, args.getFlag("variant"));
|
|
||||||
}
|
|
||||||
if (args.hasFlag('d')) {
|
|
||||||
trait.setPlayingDead(!trait.isPlayingDead());
|
|
||||||
output += ' ' + (trait.isPlayingDead() ? Messaging.tr(Messages.AXOLOTL_PLAYING_DEAD, npc.getName())
|
|
||||||
: Messaging.tr(Messages.AXOLOTL_NOT_PLAYING_DEAD, npc.getName()));
|
|
||||||
}
|
|
||||||
if (!output.isEmpty()) {
|
|
||||||
Messaging.send(sender, output.trim());
|
|
||||||
} else {
|
|
||||||
throw new CommandUsageException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
aliases = { "npc" },
|
|
||||||
usage = "bee (-s/-n) --anger anger",
|
|
||||||
desc = "Sets bee modifiers",
|
|
||||||
modifiers = { "bee" },
|
|
||||||
min = 1,
|
|
||||||
max = 1,
|
|
||||||
flags = "sn",
|
|
||||||
permission = "citizens.npc.bee")
|
|
||||||
@Requirements(selected = true, ownership = true, types = EntityType.BEE)
|
|
||||||
public void bee(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
BeeTrait trait = npc.getOrAddTrait(BeeTrait.class);
|
|
||||||
String output = "";
|
|
||||||
if (args.hasValueFlag("anger")) {
|
|
||||||
int anger = args.getFlagInteger("anger");
|
|
||||||
if (anger < 0) {
|
|
||||||
throw new CommandException(Messages.INVALID_BEE_ANGER);
|
|
||||||
}
|
|
||||||
trait.setAnger(anger);
|
|
||||||
output += ' ' + Messaging.tr(Messages.BEE_ANGER_SET, args.getFlag("anger"));
|
|
||||||
}
|
|
||||||
if (args.hasFlag('s')) {
|
|
||||||
trait.setStung(!trait.hasStung());
|
|
||||||
output += ' ' + (trait.hasStung() ? Messaging.tr(Messages.BEE_STUNG, npc.getName())
|
|
||||||
: Messaging.tr(Messages.BEE_NOT_STUNG, npc.getName()));
|
|
||||||
}
|
|
||||||
if (args.hasFlag('n')) {
|
|
||||||
trait.setNectar(!trait.hasNectar());
|
|
||||||
output += ' ' + (trait.hasNectar() ? Messaging.tr(Messages.BEE_HAS_NECTAR, npc.getName())
|
|
||||||
: Messaging.tr(Messages.BEE_NO_NECTAR, npc.getName()));
|
|
||||||
}
|
|
||||||
if (!output.isEmpty()) {
|
|
||||||
Messaging.send(sender, output.trim());
|
|
||||||
} else {
|
|
||||||
throw new CommandUsageException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
aliases = { "npc" },
|
|
||||||
usage = "bossbar --style [style] --color [color] --title [title] --visible [visible] --flags [flags] --track [health | placeholder]",
|
|
||||||
desc = "Edit bossbar properties",
|
|
||||||
modifiers = { "bossbar" },
|
|
||||||
min = 1,
|
|
||||||
max = 1)
|
|
||||||
@Requirements(selected = true, ownership = true)
|
|
||||||
public void bossbar(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
BossBarTrait trait = npc.getOrAddTrait(BossBarTrait.class);
|
|
||||||
if (args.hasValueFlag("style")) {
|
|
||||||
BarStyle style = Util.matchEnum(BarStyle.values(), args.getFlag("style"));
|
|
||||||
if (style != null) {
|
|
||||||
trait.setStyle(style);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (args.hasValueFlag("color")) {
|
|
||||||
BarColor color = Util.matchEnum(BarColor.values(), args.getFlag("color"));
|
|
||||||
if (color != null) {
|
|
||||||
trait.setColor(color);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (args.hasValueFlag("track")) {
|
|
||||||
trait.setTrackVariable(args.getFlag("track"));
|
|
||||||
}
|
|
||||||
if (args.hasValueFlag("title")) {
|
|
||||||
trait.setTitle(Colorizer.parseColors(args.getFlag("title")));
|
|
||||||
}
|
|
||||||
if (args.hasValueFlag("visible")) {
|
|
||||||
trait.setVisible(Boolean.parseBoolean(args.getFlag("visible")));
|
|
||||||
}
|
|
||||||
if (args.hasValueFlag("flags")) {
|
|
||||||
List<BarFlag> flags = Lists.newArrayList();
|
|
||||||
for (String s : Splitter.on(',').omitEmptyStrings().trimResults().split(args.getFlag("flags"))) {
|
|
||||||
BarFlag flag = Util.matchEnum(BarFlag.values(), s);
|
|
||||||
if (flag != null) {
|
|
||||||
flags.add(flag);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
trait.setFlags(flags);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
aliases = { "npc" },
|
|
||||||
usage = "cat (-s/-n/-l) --type type --ccolor collar color",
|
|
||||||
desc = "Sets cat modifiers",
|
|
||||||
modifiers = { "cat" },
|
|
||||||
min = 1,
|
|
||||||
max = 1,
|
|
||||||
flags = "snl",
|
|
||||||
permission = "citizens.npc.cat")
|
|
||||||
@Requirements(selected = true, ownership = true, types = EntityType.CAT)
|
|
||||||
public void cat(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
CatTrait trait = npc.getOrAddTrait(CatTrait.class);
|
|
||||||
String output = "";
|
|
||||||
if (args.hasValueFlag("type")) {
|
|
||||||
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()));
|
|
||||||
}
|
|
||||||
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, npc.getName());
|
|
||||||
} else if (args.hasFlag('n')) {
|
|
||||||
trait.setSitting(false);
|
|
||||||
output += ' ' + Messaging.tr(Messages.CAT_STOPPED_SITTING, npc.getName());
|
|
||||||
}
|
|
||||||
if (args.hasFlag('l')) {
|
|
||||||
trait.setLyingDown(!trait.isLyingDown());
|
|
||||||
output += ' ' + Messaging.tr(trait.isLyingDown() ? Messages.CAT_STARTED_LYING : Messages.CAT_STOPPED_LYING,
|
|
||||||
npc.getName());
|
|
||||||
}
|
|
||||||
if (!output.isEmpty()) {
|
|
||||||
Messaging.send(sender, output.trim());
|
|
||||||
} else {
|
|
||||||
throw new CommandUsageException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@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.getOrAddTrait(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)",
|
|
||||||
desc = "Sets llama modifiers",
|
|
||||||
modifiers = { "llama" },
|
|
||||||
min = 1,
|
|
||||||
max = 1,
|
|
||||||
permission = "citizens.npc.llama")
|
|
||||||
@Requirements(selected = true, ownership = true, types = { EntityType.LLAMA, EntityType.TRADER_LLAMA })
|
|
||||||
public void llama(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
LlamaTrait trait = npc.getOrAddTrait(LlamaTrait.class);
|
|
||||||
String output = "";
|
|
||||||
if (args.hasValueFlag("color") || args.hasValueFlag("colour")) {
|
|
||||||
String colorRaw = args.getFlag("color", args.getFlag("colour"));
|
|
||||||
Color color = Util.matchEnum(Color.values(), colorRaw);
|
|
||||||
if (color == null) {
|
|
||||||
String valid = Util.listValuesPretty(Color.values());
|
|
||||||
throw new CommandException(Messages.INVALID_LLAMA_COLOR, valid);
|
|
||||||
}
|
|
||||||
trait.setColor(color);
|
|
||||||
output += Messaging.tr(Messages.LLAMA_COLOR_SET, Util.prettyEnum(color));
|
|
||||||
}
|
|
||||||
if (args.hasValueFlag("strength")) {
|
|
||||||
trait.setStrength(Math.max(1, Math.min(5, args.getFlagInteger("strength"))));
|
|
||||||
output += Messaging.tr(Messages.LLAMA_STRENGTH_SET, args.getFlagInteger("strength"));
|
|
||||||
}
|
|
||||||
if (args.hasFlag('c')) {
|
|
||||||
npc.getOrAddTrait(HorseModifiers.class).setCarryingChest(true);
|
|
||||||
output += Messaging.tr(Messages.HORSE_CHEST_SET) + " ";
|
|
||||||
} else if (args.hasFlag('b')) {
|
|
||||||
npc.getOrAddTrait(HorseModifiers.class).setCarryingChest(false);
|
|
||||||
output += Messaging.tr(Messages.HORSE_CHEST_UNSET) + " ";
|
|
||||||
}
|
|
||||||
if (!output.isEmpty()) {
|
|
||||||
Messaging.send(sender, output);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
aliases = { "npc" },
|
|
||||||
usage = "mcow (--variant [variant])",
|
|
||||||
desc = "Sets mushroom cow modifiers.",
|
|
||||||
modifiers = { "mcow", "mushroomcow" },
|
|
||||||
min = 1,
|
|
||||||
max = 1,
|
|
||||||
permission = "citizens.npc.mushroomcow")
|
|
||||||
@Requirements(selected = true, ownership = true, types = { EntityType.MUSHROOM_COW })
|
|
||||||
public void mushroomcow(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
MushroomCowTrait trait = npc.getOrAddTrait(MushroomCowTrait.class);
|
|
||||||
boolean hasArg = false;
|
|
||||||
if (args.hasValueFlag("variant")) {
|
|
||||||
MushroomCow.Variant variant = Util.matchEnum(MushroomCow.Variant.values(), args.getFlag("variant"));
|
|
||||||
if (variant == null) {
|
|
||||||
Messaging.sendErrorTr(sender, Messages.INVALID_MUSHROOM_COW_VARIANT,
|
|
||||||
Util.listValuesPretty(MushroomCow.Variant.values()));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
trait.setVariant(variant);
|
|
||||||
Messaging.sendTr(sender, Messages.MUSHROOM_COW_VARIANT_SET, npc.getName(), variant);
|
|
||||||
hasArg = true;
|
|
||||||
}
|
|
||||||
if (!hasArg) {
|
|
||||||
throw new CommandUsageException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
aliases = { "npc" },
|
|
||||||
usage = "panda --gene (main gene) --hgene (hidden gene) -s(itting)",
|
|
||||||
desc = "Sets panda modifiers",
|
|
||||||
modifiers = { "panda" },
|
|
||||||
flags = "s",
|
|
||||||
min = 1,
|
|
||||||
max = 1,
|
|
||||||
permission = "citizens.npc.panda")
|
|
||||||
@Requirements(selected = true, ownership = true, types = EntityType.PANDA)
|
|
||||||
public void panda(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
PandaTrait trait = npc.getOrAddTrait(PandaTrait.class);
|
|
||||||
String output = "";
|
|
||||||
if (args.hasValueFlag("gene")) {
|
|
||||||
Panda.Gene gene = Util.matchEnum(Panda.Gene.values(), args.getFlag("gene"));
|
|
||||||
if (gene == null) {
|
|
||||||
throw new CommandUsageException(Messages.INVALID_PANDA_GENE,
|
|
||||||
Util.listValuesPretty(Panda.Gene.values()));
|
|
||||||
}
|
|
||||||
trait.setMainGene(gene);
|
|
||||||
output += ' ' + Messaging.tr(Messages.PANDA_MAIN_GENE_SET, args.getFlag("gene"));
|
|
||||||
}
|
|
||||||
if (args.hasValueFlag("hgene")) {
|
|
||||||
Panda.Gene gene = Util.matchEnum(Panda.Gene.values(), args.getFlag("hgene"));
|
|
||||||
if (gene == null) {
|
|
||||||
throw new CommandUsageException(Messages.INVALID_PANDA_GENE,
|
|
||||||
Util.listValuesPretty(Panda.Gene.values()));
|
|
||||||
}
|
|
||||||
trait.setHiddenGene(gene);
|
|
||||||
output += ' ' + Messaging.tr(Messages.PANDA_HIDDEN_GENE_SET, args.getFlag("hgene"));
|
|
||||||
}
|
|
||||||
if (args.hasFlag('s')) {
|
|
||||||
boolean isSitting = trait.toggleSitting();
|
|
||||||
output += ' ' + Messaging.tr(isSitting ? Messages.PANDA_SITTING : Messages.PANDA_STOPPED_SITTING);
|
|
||||||
}
|
|
||||||
if (!output.isEmpty()) {
|
|
||||||
Messaging.send(sender, output.trim());
|
|
||||||
} else {
|
|
||||||
throw new CommandUsageException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
aliases = { "npc" },
|
|
||||||
usage = "parrot (--variant variant)",
|
|
||||||
desc = "Sets parrot modifiers",
|
|
||||||
modifiers = { "parrot" },
|
|
||||||
min = 1,
|
|
||||||
max = 1,
|
|
||||||
permission = "citizens.npc.parrot")
|
|
||||||
@Requirements(selected = true, ownership = true, types = EntityType.PARROT)
|
|
||||||
public void parrot(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
ParrotTrait trait = npc.getOrAddTrait(ParrotTrait.class);
|
|
||||||
String output = "";
|
|
||||||
if (args.hasValueFlag("variant")) {
|
|
||||||
String variantRaw = args.getFlag("variant");
|
|
||||||
Variant variant = Util.matchEnum(Variant.values(), variantRaw);
|
|
||||||
if (variant == null) {
|
|
||||||
String valid = Util.listValuesPretty(Variant.values());
|
|
||||||
throw new CommandException(Messages.INVALID_PARROT_VARIANT, valid);
|
|
||||||
}
|
|
||||||
trait.setVariant(variant);
|
|
||||||
output += Messaging.tr(Messages.PARROT_VARIANT_SET, Util.prettyEnum(variant));
|
|
||||||
}
|
|
||||||
if (!output.isEmpty()) {
|
|
||||||
Messaging.send(sender, output);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
aliases = { "npc" },
|
|
||||||
usage = "phantom (--size size)",
|
|
||||||
desc = "Sets phantom modifiers",
|
|
||||||
modifiers = { "phantom" },
|
|
||||||
min = 1,
|
|
||||||
max = 1,
|
|
||||||
permission = "citizens.npc.phantom")
|
|
||||||
@Requirements(selected = true, ownership = true, types = EntityType.PHANTOM)
|
|
||||||
public void phantom(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
PhantomTrait trait = npc.getOrAddTrait(PhantomTrait.class);
|
|
||||||
String output = "";
|
|
||||||
if (args.hasValueFlag("size")) {
|
|
||||||
if (args.getFlagInteger("size") <= 0) {
|
|
||||||
throw new CommandUsageException();
|
|
||||||
}
|
|
||||||
trait.setSize(args.getFlagInteger("size"));
|
|
||||||
output += Messaging.tr(Messages.PHANTOM_STATE_SET, args.getFlagInteger("size"));
|
|
||||||
}
|
|
||||||
if (!output.isEmpty()) {
|
|
||||||
Messaging.send(sender, output);
|
|
||||||
} else {
|
|
||||||
throw new CommandUsageException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
aliases = { "npc" },
|
|
||||||
usage = "piglin (--dancing [true|false])",
|
|
||||||
desc = "Sets piglin modifiers.",
|
|
||||||
modifiers = { "piglin" },
|
|
||||||
min = 1,
|
|
||||||
max = 1,
|
|
||||||
permission = "citizens.npc.piglin")
|
|
||||||
@Requirements(selected = true, ownership = true, types = { EntityType.PIGLIN })
|
|
||||||
public void piglin(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
PiglinTrait trait = npc.getOrAddTrait(PiglinTrait.class);
|
|
||||||
boolean hasArg = false;
|
|
||||||
if (args.hasValueFlag("dancing")) {
|
|
||||||
boolean dancing = Boolean.valueOf(args.getFlag("dancing"));
|
|
||||||
trait.setDancing(dancing);
|
|
||||||
Messaging.sendTr(sender, dancing ? Messages.PIGLIN_DANCING_SET : Messages.PIGLIN_DANCING_UNSET,
|
|
||||||
npc.getName());
|
|
||||||
hasArg = true;
|
|
||||||
}
|
|
||||||
if (!hasArg) {
|
|
||||||
throw new CommandUsageException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
aliases = { "npc" },
|
|
||||||
usage = "polarbear (-r)",
|
|
||||||
desc = "Sets polarbear modifiers.",
|
|
||||||
modifiers = { "polarbear" },
|
|
||||||
min = 1,
|
|
||||||
max = 1,
|
|
||||||
flags = "r",
|
|
||||||
permission = "citizens.npc.polarbear")
|
|
||||||
@Requirements(selected = true, ownership = true, types = { EntityType.POLAR_BEAR })
|
|
||||||
public void polarbear(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
PolarBearTrait trait = npc.getOrAddTrait(PolarBearTrait.class);
|
|
||||||
String output = "";
|
|
||||||
if (args.hasFlag('r')) {
|
|
||||||
trait.setRearing(!trait.isRearing());
|
|
||||||
output += Messaging.tr(
|
|
||||||
trait.isRearing() ? Messages.POLAR_BEAR_REARING : Messages.POLAR_BEAR_STOPPED_REARING,
|
|
||||||
npc.getName());
|
|
||||||
}
|
|
||||||
if (!output.isEmpty()) {
|
|
||||||
Messaging.send(sender, output);
|
|
||||||
} else {
|
|
||||||
throw new CommandUsageException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
aliases = { "npc" },
|
|
||||||
usage = "pufferfish (--state state)",
|
|
||||||
desc = "Sets pufferfish modifiers",
|
|
||||||
modifiers = { "pufferfish" },
|
|
||||||
min = 1,
|
|
||||||
max = 1,
|
|
||||||
permission = "citizens.npc.pufferfish")
|
|
||||||
@Requirements(selected = true, ownership = true, types = EntityType.PUFFERFISH)
|
|
||||||
public void pufferfish(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
PufferFishTrait trait = npc.getOrAddTrait(PufferFishTrait.class);
|
|
||||||
String output = "";
|
|
||||||
if (args.hasValueFlag("state")) {
|
|
||||||
int state = Math.min(Math.max(args.getFlagInteger("state"), 0), 3);
|
|
||||||
trait.setPuffState(state);
|
|
||||||
output += Messaging.tr(Messages.PUFFERFISH_STATE_SET, state);
|
|
||||||
}
|
|
||||||
if (!output.isEmpty()) {
|
|
||||||
Messaging.send(sender, output);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
aliases = { "npc" },
|
|
||||||
usage = "shulker (--peek [peek] --color [color])",
|
|
||||||
desc = "Sets shulker modifiers.",
|
|
||||||
modifiers = { "shulker" },
|
|
||||||
min = 1,
|
|
||||||
max = 1,
|
|
||||||
permission = "citizens.npc.shulker")
|
|
||||||
@Requirements(selected = true, ownership = true, types = { EntityType.SHULKER })
|
|
||||||
public void shulker(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
ShulkerTrait trait = npc.getOrAddTrait(ShulkerTrait.class);
|
|
||||||
boolean hasArg = false;
|
|
||||||
if (args.hasValueFlag("peek")) {
|
|
||||||
int peek = (byte) args.getFlagInteger("peek");
|
|
||||||
trait.setPeek(peek);
|
|
||||||
Messaging.sendTr(sender, Messages.SHULKER_PEEK_SET, npc.getName(), peek);
|
|
||||||
hasArg = true;
|
|
||||||
}
|
|
||||||
if (args.hasValueFlag("color")) {
|
|
||||||
DyeColor color = Util.matchEnum(DyeColor.values(), args.getFlag("color"));
|
|
||||||
if (color == null) {
|
|
||||||
Messaging.sendErrorTr(sender, Messages.INVALID_SHULKER_COLOR, Util.listValuesPretty(DyeColor.values()));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
trait.setColor(color);
|
|
||||||
Messaging.sendTr(sender, Messages.SHULKER_COLOR_SET, npc.getName(), Util.prettyEnum(color));
|
|
||||||
hasArg = true;
|
|
||||||
}
|
|
||||||
if (!hasArg) {
|
|
||||||
throw new CommandUsageException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
aliases = { "npc" },
|
|
||||||
usage = "snowman (-d[erp])",
|
|
||||||
desc = "Sets snowman modifiers.",
|
|
||||||
modifiers = { "snowman" },
|
|
||||||
min = 1,
|
|
||||||
max = 1,
|
|
||||||
flags = "d",
|
|
||||||
permission = "citizens.npc.snowman")
|
|
||||||
@Requirements(selected = true, ownership = true, types = { EntityType.SNOWMAN })
|
|
||||||
public void snowman(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
SnowmanTrait trait = npc.getOrAddTrait(SnowmanTrait.class);
|
|
||||||
boolean hasArg = false;
|
|
||||||
if (args.hasFlag('d')) {
|
|
||||||
boolean isDerp = trait.toggleDerp();
|
|
||||||
Messaging.sendTr(sender, isDerp ? Messages.SNOWMAN_DERP_SET : Messages.SNOWMAN_DERP_STOPPED, npc.getName());
|
|
||||||
hasArg = true;
|
|
||||||
}
|
|
||||||
if (!hasArg) {
|
|
||||||
throw new CommandUsageException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
aliases = { "npc" },
|
|
||||||
usage = "tfish (--body color) (--pattern pattern) (--patterncolor color)",
|
|
||||||
desc = "Sets tropical fish modifiers",
|
|
||||||
modifiers = { "tfish" },
|
|
||||||
min = 1,
|
|
||||||
max = 1,
|
|
||||||
permission = "citizens.npc.tropicalfish")
|
|
||||||
@Requirements(selected = true, ownership = true, types = EntityType.TROPICAL_FISH)
|
|
||||||
public void tropicalfish(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
TropicalFishTrait trait = npc.getOrAddTrait(TropicalFishTrait.class);
|
|
||||||
String output = "";
|
|
||||||
if (args.hasValueFlag("body")) {
|
|
||||||
DyeColor color = Util.matchEnum(DyeColor.values(), args.getFlag("body"));
|
|
||||||
if (color == null) {
|
|
||||||
throw new CommandException(Messages.INVALID_TROPICALFISH_COLOR,
|
|
||||||
Util.listValuesPretty(DyeColor.values()));
|
|
||||||
}
|
|
||||||
trait.setBodyColor(color);
|
|
||||||
output += Messaging.tr(Messages.TROPICALFISH_BODY_COLOR_SET, Util.prettyEnum(color));
|
|
||||||
}
|
|
||||||
if (args.hasValueFlag("patterncolor")) {
|
|
||||||
DyeColor color = Util.matchEnum(DyeColor.values(), args.getFlag("patterncolor"));
|
|
||||||
if (color == null) {
|
|
||||||
throw new CommandException(Messages.INVALID_TROPICALFISH_COLOR,
|
|
||||||
Util.listValuesPretty(DyeColor.values()));
|
|
||||||
}
|
|
||||||
trait.setPatternColor(color);
|
|
||||||
output += Messaging.tr(Messages.TROPICALFISH_PATTERN_COLOR_SET, Util.prettyEnum(color));
|
|
||||||
}
|
|
||||||
if (args.hasValueFlag("pattern")) {
|
|
||||||
Pattern pattern = Util.matchEnum(Pattern.values(), args.getFlag("pattern"));
|
|
||||||
if (pattern == null) {
|
|
||||||
throw new CommandException(Messages.INVALID_TROPICALFISH_PATTERN,
|
|
||||||
Util.listValuesPretty(Pattern.values()));
|
|
||||||
}
|
|
||||||
trait.setPattern(pattern);
|
|
||||||
output += Messaging.tr(Messages.TROPICALFISH_PATTERN_SET, Util.prettyEnum(pattern));
|
|
||||||
}
|
|
||||||
if (!output.isEmpty()) {
|
|
||||||
Messaging.send(sender, output);
|
|
||||||
} else {
|
|
||||||
throw new CommandUsageException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
aliases = { "npc" },
|
|
||||||
usage = "villager (--level level) (--type type) (--profession profession)",
|
|
||||||
desc = "Sets villager modifiers",
|
|
||||||
modifiers = { "villager" },
|
|
||||||
min = 1,
|
|
||||||
max = 1,
|
|
||||||
permission = "citizens.npc.villager")
|
|
||||||
@Requirements(selected = true, ownership = true, types = EntityType.VILLAGER)
|
|
||||||
public void villager(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
VillagerTrait trait = npc.getOrAddTrait(VillagerTrait.class);
|
|
||||||
String output = "";
|
|
||||||
if (args.hasValueFlag("level")) {
|
|
||||||
if (args.getFlagInteger("level") < 0) {
|
|
||||||
throw new CommandUsageException();
|
|
||||||
}
|
|
||||||
trait.setLevel(args.getFlagInteger("level"));
|
|
||||||
output += " " + Messaging.tr(Messages.VILLAGER_LEVEL_SET, args.getFlagInteger("level"));
|
|
||||||
}
|
|
||||||
if (args.hasValueFlag("type")) {
|
|
||||||
Villager.Type type = Util.matchEnum(Villager.Type.values(), args.getFlag("type"));
|
|
||||||
if (type == null) {
|
|
||||||
throw new CommandException(Messages.INVALID_VILLAGER_TYPE,
|
|
||||||
Util.listValuesPretty(Villager.Type.values()));
|
|
||||||
}
|
|
||||||
trait.setType(type);
|
|
||||||
output += " " + Messaging.tr(Messages.VILLAGER_TYPE_SET, args.getFlag("type"));
|
|
||||||
}
|
|
||||||
if (args.hasValueFlag("profession")) {
|
|
||||||
Profession parsed = Util.matchEnum(Profession.values(), args.getFlag("profession"));
|
|
||||||
if (parsed == null) {
|
|
||||||
throw new CommandException(Messages.INVALID_PROFESSION, args.getFlag("profession"),
|
|
||||||
Joiner.on(',').join(Profession.values()));
|
|
||||||
}
|
|
||||||
npc.getOrAddTrait(VillagerProfession.class).setProfession(parsed);
|
|
||||||
output += " " + Messaging.tr(Messages.PROFESSION_SET, npc.getName(), args.getFlag("profession"));
|
|
||||||
}
|
|
||||||
if (!output.isEmpty()) {
|
|
||||||
Messaging.send(sender, output.trim());
|
|
||||||
} else {
|
|
||||||
throw new CommandUsageException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -73,6 +73,7 @@ import net.citizensnpcs.api.npc.BlockBreaker;
|
|||||||
import net.citizensnpcs.api.npc.BlockBreaker.BlockBreakerConfiguration;
|
import net.citizensnpcs.api.npc.BlockBreaker.BlockBreakerConfiguration;
|
||||||
import net.citizensnpcs.api.npc.NPC;
|
import net.citizensnpcs.api.npc.NPC;
|
||||||
import net.citizensnpcs.api.npc.NPCRegistry;
|
import net.citizensnpcs.api.npc.NPCRegistry;
|
||||||
|
import net.citizensnpcs.api.trait.Trait;
|
||||||
import net.citizensnpcs.api.trait.TraitInfo;
|
import net.citizensnpcs.api.trait.TraitInfo;
|
||||||
import net.citizensnpcs.api.util.BoundingBox;
|
import net.citizensnpcs.api.util.BoundingBox;
|
||||||
import net.citizensnpcs.api.util.Messaging;
|
import net.citizensnpcs.api.util.Messaging;
|
||||||
@ -188,7 +189,6 @@ import net.citizensnpcs.nms.v1_17_R1.entity.nonliving.ThrownTridentController;
|
|||||||
import net.citizensnpcs.nms.v1_17_R1.entity.nonliving.TippedArrowController;
|
import net.citizensnpcs.nms.v1_17_R1.entity.nonliving.TippedArrowController;
|
||||||
import net.citizensnpcs.nms.v1_17_R1.entity.nonliving.WitherSkullController;
|
import net.citizensnpcs.nms.v1_17_R1.entity.nonliving.WitherSkullController;
|
||||||
import net.citizensnpcs.nms.v1_17_R1.network.EmptyChannel;
|
import net.citizensnpcs.nms.v1_17_R1.network.EmptyChannel;
|
||||||
import net.citizensnpcs.nms.v1_17_R1.trait.Commands;
|
|
||||||
import net.citizensnpcs.npc.EntityControllers;
|
import net.citizensnpcs.npc.EntityControllers;
|
||||||
import net.citizensnpcs.npc.ai.MCNavigationStrategy.MCNavigator;
|
import net.citizensnpcs.npc.ai.MCNavigationStrategy.MCNavigator;
|
||||||
import net.citizensnpcs.npc.ai.MCTargetStrategy.TargetNavigator;
|
import net.citizensnpcs.npc.ai.MCTargetStrategy.TargetNavigator;
|
||||||
@ -776,24 +776,23 @@ public class NMSImpl implements NMSBridge {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void load(CommandManager manager) {
|
public void load(CommandManager manager) {
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(AxolotlTrait.class));
|
registerTraitWithCommand(manager, AxolotlTrait.class);
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(BeeTrait.class));
|
registerTraitWithCommand(manager, BeeTrait.class);
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(BossBarTrait.class));
|
registerTraitWithCommand(manager, BossBarTrait.class);
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(CatTrait.class));
|
registerTraitWithCommand(manager, CatTrait.class);
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(FoxTrait.class));
|
registerTraitWithCommand(manager, FoxTrait.class);
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(LlamaTrait.class));
|
registerTraitWithCommand(manager, LlamaTrait.class);
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(MushroomCowTrait.class));
|
registerTraitWithCommand(manager, MushroomCowTrait.class);
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(ParrotTrait.class));
|
registerTraitWithCommand(manager, ParrotTrait.class);
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(PandaTrait.class));
|
registerTraitWithCommand(manager, PandaTrait.class);
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(PhantomTrait.class));
|
registerTraitWithCommand(manager, PiglinTrait.class);
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(PiglinTrait.class));
|
registerTraitWithCommand(manager, PhantomTrait.class);
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(PolarBearTrait.class));
|
registerTraitWithCommand(manager, PolarBearTrait.class);
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(PufferFishTrait.class));
|
registerTraitWithCommand(manager, PufferFishTrait.class);
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(ShulkerTrait.class));
|
registerTraitWithCommand(manager, ShulkerTrait.class);
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(SnowmanTrait.class));
|
registerTraitWithCommand(manager, SnowmanTrait.class);
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(TropicalFishTrait.class));
|
registerTraitWithCommand(manager, TropicalFishTrait.class);
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(VillagerTrait.class));
|
registerTraitWithCommand(manager, VillagerTrait.class);
|
||||||
manager.register(Commands.class);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadEntityTypes() {
|
private void loadEntityTypes() {
|
||||||
@ -1081,6 +1080,11 @@ public class NMSImpl implements NMSBridge {
|
|||||||
throw new IllegalArgumentException("unable to find valid entity superclass for class " + clazz.toString());
|
throw new IllegalArgumentException("unable to find valid entity superclass for class " + clazz.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void registerTraitWithCommand(CommandManager manager, Class<? extends Trait> clazz) {
|
||||||
|
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(clazz));
|
||||||
|
manager.register(clazz);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void remove(org.bukkit.entity.Entity entity) {
|
public void remove(org.bukkit.entity.Entity entity) {
|
||||||
NMSImpl.getHandle(entity).remove(RemovalReason.KILLED);
|
NMSImpl.getHandle(entity).remove(RemovalReason.KILLED);
|
||||||
|
@ -1,642 +0,0 @@
|
|||||||
package net.citizensnpcs.nms.v1_18_R2.trait;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.bukkit.DyeColor;
|
|
||||||
import org.bukkit.boss.BarColor;
|
|
||||||
import org.bukkit.boss.BarFlag;
|
|
||||||
import org.bukkit.boss.BarStyle;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Axolotl;
|
|
||||||
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.MushroomCow;
|
|
||||||
import org.bukkit.entity.Panda;
|
|
||||||
import org.bukkit.entity.Parrot.Variant;
|
|
||||||
import org.bukkit.entity.TropicalFish.Pattern;
|
|
||||||
import org.bukkit.entity.Villager;
|
|
||||||
import org.bukkit.entity.Villager.Profession;
|
|
||||||
|
|
||||||
import com.google.common.base.Joiner;
|
|
||||||
import com.google.common.base.Splitter;
|
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
|
|
||||||
import net.citizensnpcs.api.command.Command;
|
|
||||||
import net.citizensnpcs.api.command.CommandContext;
|
|
||||||
import net.citizensnpcs.api.command.Requirements;
|
|
||||||
import net.citizensnpcs.api.command.exception.CommandException;
|
|
||||||
import net.citizensnpcs.api.command.exception.CommandUsageException;
|
|
||||||
import net.citizensnpcs.api.npc.NPC;
|
|
||||||
import net.citizensnpcs.api.util.Colorizer;
|
|
||||||
import net.citizensnpcs.api.util.Messaging;
|
|
||||||
import net.citizensnpcs.trait.HorseModifiers;
|
|
||||||
import net.citizensnpcs.trait.VillagerProfession;
|
|
||||||
import net.citizensnpcs.trait.versioned.AxolotlTrait;
|
|
||||||
import net.citizensnpcs.trait.versioned.BeeTrait;
|
|
||||||
import net.citizensnpcs.trait.versioned.BossBarTrait;
|
|
||||||
import net.citizensnpcs.trait.versioned.CatTrait;
|
|
||||||
import net.citizensnpcs.trait.versioned.FoxTrait;
|
|
||||||
import net.citizensnpcs.trait.versioned.LlamaTrait;
|
|
||||||
import net.citizensnpcs.trait.versioned.MushroomCowTrait;
|
|
||||||
import net.citizensnpcs.trait.versioned.PandaTrait;
|
|
||||||
import net.citizensnpcs.trait.versioned.ParrotTrait;
|
|
||||||
import net.citizensnpcs.trait.versioned.PhantomTrait;
|
|
||||||
import net.citizensnpcs.trait.versioned.PiglinTrait;
|
|
||||||
import net.citizensnpcs.trait.versioned.PolarBearTrait;
|
|
||||||
import net.citizensnpcs.trait.versioned.PufferFishTrait;
|
|
||||||
import net.citizensnpcs.trait.versioned.ShulkerTrait;
|
|
||||||
import net.citizensnpcs.trait.versioned.SnowmanTrait;
|
|
||||||
import net.citizensnpcs.trait.versioned.TropicalFishTrait;
|
|
||||||
import net.citizensnpcs.trait.versioned.VillagerTrait;
|
|
||||||
import net.citizensnpcs.util.Messages;
|
|
||||||
import net.citizensnpcs.util.Util;
|
|
||||||
|
|
||||||
public class Commands {
|
|
||||||
@Command(
|
|
||||||
aliases = { "npc" },
|
|
||||||
usage = "axolotl (-d) (--variant variant)",
|
|
||||||
desc = "Sets axolotl modifiers",
|
|
||||||
modifiers = { "axolotl" },
|
|
||||||
min = 1,
|
|
||||||
max = 1,
|
|
||||||
flags = "d",
|
|
||||||
permission = "citizens.npc.axolotl")
|
|
||||||
@Requirements(selected = true, ownership = true, types = EntityType.AXOLOTL)
|
|
||||||
public void axolotl(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
AxolotlTrait trait = npc.getOrAddTrait(AxolotlTrait.class);
|
|
||||||
String output = "";
|
|
||||||
if (args.hasValueFlag("variant")) {
|
|
||||||
Axolotl.Variant variant = Util.matchEnum(Axolotl.Variant.values(), args.getFlag("variant"));
|
|
||||||
if (variant == null) {
|
|
||||||
throw new CommandException(Messages.INVALID_AXOLOTL_VARIANT,
|
|
||||||
Util.listValuesPretty(Axolotl.Variant.values()));
|
|
||||||
}
|
|
||||||
trait.setVariant(variant);
|
|
||||||
output += ' ' + Messaging.tr(Messages.AXOLOTL_VARIANT_SET, args.getFlag("variant"));
|
|
||||||
}
|
|
||||||
if (args.hasFlag('d')) {
|
|
||||||
trait.setPlayingDead(!trait.isPlayingDead());
|
|
||||||
output += ' ' + (trait.isPlayingDead() ? Messaging.tr(Messages.AXOLOTL_PLAYING_DEAD, npc.getName())
|
|
||||||
: Messaging.tr(Messages.AXOLOTL_NOT_PLAYING_DEAD, npc.getName()));
|
|
||||||
}
|
|
||||||
if (!output.isEmpty()) {
|
|
||||||
Messaging.send(sender, output.trim());
|
|
||||||
} else {
|
|
||||||
throw new CommandUsageException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
aliases = { "npc" },
|
|
||||||
usage = "bee (-s/-n) --anger anger",
|
|
||||||
desc = "Sets bee modifiers",
|
|
||||||
modifiers = { "bee" },
|
|
||||||
min = 1,
|
|
||||||
max = 1,
|
|
||||||
flags = "sn",
|
|
||||||
permission = "citizens.npc.bee")
|
|
||||||
@Requirements(selected = true, ownership = true, types = EntityType.BEE)
|
|
||||||
public void bee(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
BeeTrait trait = npc.getOrAddTrait(BeeTrait.class);
|
|
||||||
String output = "";
|
|
||||||
if (args.hasValueFlag("anger")) {
|
|
||||||
int anger = args.getFlagInteger("anger");
|
|
||||||
if (anger < 0) {
|
|
||||||
throw new CommandException(Messages.INVALID_BEE_ANGER);
|
|
||||||
}
|
|
||||||
trait.setAnger(anger);
|
|
||||||
output += ' ' + Messaging.tr(Messages.BEE_ANGER_SET, args.getFlag("anger"));
|
|
||||||
}
|
|
||||||
if (args.hasFlag('s')) {
|
|
||||||
trait.setStung(!trait.hasStung());
|
|
||||||
output += ' ' + (trait.hasStung() ? Messaging.tr(Messages.BEE_STUNG, npc.getName())
|
|
||||||
: Messaging.tr(Messages.BEE_NOT_STUNG, npc.getName()));
|
|
||||||
}
|
|
||||||
if (args.hasFlag('n')) {
|
|
||||||
trait.setNectar(!trait.hasNectar());
|
|
||||||
output += ' ' + (trait.hasNectar() ? Messaging.tr(Messages.BEE_HAS_NECTAR, npc.getName())
|
|
||||||
: Messaging.tr(Messages.BEE_NO_NECTAR, npc.getName()));
|
|
||||||
}
|
|
||||||
if (!output.isEmpty()) {
|
|
||||||
Messaging.send(sender, output.trim());
|
|
||||||
} else {
|
|
||||||
throw new CommandUsageException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
aliases = { "npc" },
|
|
||||||
usage = "bossbar --style [style] --color [color] --title [title] --visible [visible] --flags [flags] --track [health | placeholder]",
|
|
||||||
desc = "Edit bossbar properties",
|
|
||||||
modifiers = { "bossbar" },
|
|
||||||
min = 1,
|
|
||||||
max = 1)
|
|
||||||
@Requirements(selected = true, ownership = true)
|
|
||||||
public void bossbar(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
BossBarTrait trait = npc.getOrAddTrait(BossBarTrait.class);
|
|
||||||
if (args.hasValueFlag("style")) {
|
|
||||||
BarStyle style = Util.matchEnum(BarStyle.values(), args.getFlag("style"));
|
|
||||||
if (style != null) {
|
|
||||||
trait.setStyle(style);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (args.hasValueFlag("color")) {
|
|
||||||
BarColor color = Util.matchEnum(BarColor.values(), args.getFlag("color"));
|
|
||||||
if (color != null) {
|
|
||||||
trait.setColor(color);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (args.hasValueFlag("track")) {
|
|
||||||
trait.setTrackVariable(args.getFlag("track"));
|
|
||||||
}
|
|
||||||
if (args.hasValueFlag("title")) {
|
|
||||||
trait.setTitle(Colorizer.parseColors(args.getFlag("title")));
|
|
||||||
}
|
|
||||||
if (args.hasValueFlag("visible")) {
|
|
||||||
trait.setVisible(Boolean.parseBoolean(args.getFlag("visible")));
|
|
||||||
}
|
|
||||||
if (args.hasValueFlag("flags")) {
|
|
||||||
List<BarFlag> flags = Lists.newArrayList();
|
|
||||||
for (String s : Splitter.on(',').omitEmptyStrings().trimResults().split(args.getFlag("flags"))) {
|
|
||||||
BarFlag flag = Util.matchEnum(BarFlag.values(), s);
|
|
||||||
if (flag != null) {
|
|
||||||
flags.add(flag);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
trait.setFlags(flags);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
aliases = { "npc" },
|
|
||||||
usage = "cat (-s/-n/-l) --type type --ccolor collar color",
|
|
||||||
desc = "Sets cat modifiers",
|
|
||||||
modifiers = { "cat" },
|
|
||||||
min = 1,
|
|
||||||
max = 1,
|
|
||||||
flags = "snl",
|
|
||||||
permission = "citizens.npc.cat")
|
|
||||||
@Requirements(selected = true, ownership = true, types = EntityType.CAT)
|
|
||||||
public void cat(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
CatTrait trait = npc.getOrAddTrait(CatTrait.class);
|
|
||||||
String output = "";
|
|
||||||
if (args.hasValueFlag("type")) {
|
|
||||||
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()));
|
|
||||||
}
|
|
||||||
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, npc.getName());
|
|
||||||
} else if (args.hasFlag('n')) {
|
|
||||||
trait.setSitting(false);
|
|
||||||
output += ' ' + Messaging.tr(Messages.CAT_STOPPED_SITTING, npc.getName());
|
|
||||||
}
|
|
||||||
if (args.hasFlag('l')) {
|
|
||||||
trait.setLyingDown(!trait.isLyingDown());
|
|
||||||
output += ' ' + Messaging.tr(trait.isLyingDown() ? Messages.CAT_STARTED_LYING : Messages.CAT_STOPPED_LYING,
|
|
||||||
npc.getName());
|
|
||||||
}
|
|
||||||
if (!output.isEmpty()) {
|
|
||||||
Messaging.send(sender, output.trim());
|
|
||||||
} else {
|
|
||||||
throw new CommandUsageException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@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.getOrAddTrait(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)",
|
|
||||||
desc = "Sets llama modifiers",
|
|
||||||
modifiers = { "llama" },
|
|
||||||
min = 1,
|
|
||||||
max = 1,
|
|
||||||
permission = "citizens.npc.llama")
|
|
||||||
@Requirements(selected = true, ownership = true, types = { EntityType.LLAMA, EntityType.TRADER_LLAMA })
|
|
||||||
public void llama(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
LlamaTrait trait = npc.getOrAddTrait(LlamaTrait.class);
|
|
||||||
String output = "";
|
|
||||||
if (args.hasValueFlag("color") || args.hasValueFlag("colour")) {
|
|
||||||
String colorRaw = args.getFlag("color", args.getFlag("colour"));
|
|
||||||
Color color = Util.matchEnum(Color.values(), colorRaw);
|
|
||||||
if (color == null) {
|
|
||||||
String valid = Util.listValuesPretty(Color.values());
|
|
||||||
throw new CommandException(Messages.INVALID_LLAMA_COLOR, valid);
|
|
||||||
}
|
|
||||||
trait.setColor(color);
|
|
||||||
output += Messaging.tr(Messages.LLAMA_COLOR_SET, Util.prettyEnum(color));
|
|
||||||
}
|
|
||||||
if (args.hasValueFlag("strength")) {
|
|
||||||
trait.setStrength(Math.max(1, Math.min(5, args.getFlagInteger("strength"))));
|
|
||||||
output += Messaging.tr(Messages.LLAMA_STRENGTH_SET, args.getFlagInteger("strength"));
|
|
||||||
}
|
|
||||||
if (args.hasFlag('c')) {
|
|
||||||
npc.getOrAddTrait(HorseModifiers.class).setCarryingChest(true);
|
|
||||||
output += Messaging.tr(Messages.HORSE_CHEST_SET) + " ";
|
|
||||||
} else if (args.hasFlag('b')) {
|
|
||||||
npc.getOrAddTrait(HorseModifiers.class).setCarryingChest(false);
|
|
||||||
output += Messaging.tr(Messages.HORSE_CHEST_UNSET) + " ";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!output.isEmpty()) {
|
|
||||||
Messaging.send(sender, output);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
aliases = { "npc" },
|
|
||||||
usage = "mcow (--variant [variant])",
|
|
||||||
desc = "Sets mushroom cow modifiers.",
|
|
||||||
modifiers = { "mcow", "mushroomcow" },
|
|
||||||
min = 1,
|
|
||||||
max = 1,
|
|
||||||
permission = "citizens.npc.mushroomcow")
|
|
||||||
@Requirements(selected = true, ownership = true, types = { EntityType.MUSHROOM_COW })
|
|
||||||
public void mushroomcow(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
MushroomCowTrait trait = npc.getOrAddTrait(MushroomCowTrait.class);
|
|
||||||
boolean hasArg = false;
|
|
||||||
if (args.hasValueFlag("variant")) {
|
|
||||||
MushroomCow.Variant variant = Util.matchEnum(MushroomCow.Variant.values(), args.getFlag("variant"));
|
|
||||||
if (variant == null) {
|
|
||||||
Messaging.sendErrorTr(sender, Messages.INVALID_MUSHROOM_COW_VARIANT,
|
|
||||||
Util.listValuesPretty(MushroomCow.Variant.values()));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
trait.setVariant(variant);
|
|
||||||
Messaging.sendTr(sender, Messages.MUSHROOM_COW_VARIANT_SET, npc.getName(), variant);
|
|
||||||
hasArg = true;
|
|
||||||
}
|
|
||||||
if (!hasArg) {
|
|
||||||
throw new CommandUsageException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
aliases = { "npc" },
|
|
||||||
usage = "panda --gene (main gene) --hgene (hidden gene) -s(itting)",
|
|
||||||
desc = "Sets panda modifiers",
|
|
||||||
modifiers = { "panda" },
|
|
||||||
flags = "s",
|
|
||||||
min = 1,
|
|
||||||
max = 1,
|
|
||||||
permission = "citizens.npc.panda")
|
|
||||||
@Requirements(selected = true, ownership = true, types = EntityType.PANDA)
|
|
||||||
public void panda(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
PandaTrait trait = npc.getOrAddTrait(PandaTrait.class);
|
|
||||||
String output = "";
|
|
||||||
if (args.hasValueFlag("gene")) {
|
|
||||||
Panda.Gene gene = Util.matchEnum(Panda.Gene.values(), args.getFlag("gene"));
|
|
||||||
if (gene == null) {
|
|
||||||
throw new CommandUsageException(Messages.INVALID_PANDA_GENE,
|
|
||||||
Util.listValuesPretty(Panda.Gene.values()));
|
|
||||||
}
|
|
||||||
trait.setMainGene(gene);
|
|
||||||
output += ' ' + Messaging.tr(Messages.PANDA_MAIN_GENE_SET, args.getFlag("gene"));
|
|
||||||
}
|
|
||||||
if (args.hasValueFlag("hgene")) {
|
|
||||||
Panda.Gene gene = Util.matchEnum(Panda.Gene.values(), args.getFlag("hgene"));
|
|
||||||
if (gene == null) {
|
|
||||||
throw new CommandUsageException(Messages.INVALID_PANDA_GENE,
|
|
||||||
Util.listValuesPretty(Panda.Gene.values()));
|
|
||||||
}
|
|
||||||
trait.setHiddenGene(gene);
|
|
||||||
output += ' ' + Messaging.tr(Messages.PANDA_HIDDEN_GENE_SET, args.getFlag("hgene"));
|
|
||||||
}
|
|
||||||
if (args.hasFlag('s')) {
|
|
||||||
boolean isSitting = trait.toggleSitting();
|
|
||||||
output += ' ' + Messaging.tr(isSitting ? Messages.PANDA_SITTING : Messages.PANDA_STOPPED_SITTING);
|
|
||||||
}
|
|
||||||
if (!output.isEmpty()) {
|
|
||||||
Messaging.send(sender, output.trim());
|
|
||||||
} else {
|
|
||||||
throw new CommandUsageException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
aliases = { "npc" },
|
|
||||||
usage = "parrot (--variant variant)",
|
|
||||||
desc = "Sets parrot modifiers",
|
|
||||||
modifiers = { "parrot" },
|
|
||||||
min = 1,
|
|
||||||
max = 1,
|
|
||||||
permission = "citizens.npc.parrot")
|
|
||||||
@Requirements(selected = true, ownership = true, types = EntityType.PARROT)
|
|
||||||
public void parrot(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
ParrotTrait trait = npc.getOrAddTrait(ParrotTrait.class);
|
|
||||||
String output = "";
|
|
||||||
if (args.hasValueFlag("variant")) {
|
|
||||||
String variantRaw = args.getFlag("variant");
|
|
||||||
Variant variant = Util.matchEnum(Variant.values(), variantRaw);
|
|
||||||
if (variant == null) {
|
|
||||||
String valid = Util.listValuesPretty(Variant.values());
|
|
||||||
throw new CommandException(Messages.INVALID_PARROT_VARIANT, valid);
|
|
||||||
}
|
|
||||||
trait.setVariant(variant);
|
|
||||||
output += Messaging.tr(Messages.PARROT_VARIANT_SET, Util.prettyEnum(variant));
|
|
||||||
}
|
|
||||||
if (!output.isEmpty()) {
|
|
||||||
Messaging.send(sender, output);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
aliases = { "npc" },
|
|
||||||
usage = "phantom (--size size)",
|
|
||||||
desc = "Sets phantom modifiers",
|
|
||||||
modifiers = { "phantom" },
|
|
||||||
min = 1,
|
|
||||||
max = 1,
|
|
||||||
permission = "citizens.npc.phantom")
|
|
||||||
@Requirements(selected = true, ownership = true, types = EntityType.PHANTOM)
|
|
||||||
public void phantom(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
PhantomTrait trait = npc.getOrAddTrait(PhantomTrait.class);
|
|
||||||
String output = "";
|
|
||||||
if (args.hasValueFlag("size")) {
|
|
||||||
if (args.getFlagInteger("size") <= 0) {
|
|
||||||
throw new CommandUsageException();
|
|
||||||
}
|
|
||||||
trait.setSize(args.getFlagInteger("size"));
|
|
||||||
output += Messaging.tr(Messages.PHANTOM_STATE_SET, args.getFlagInteger("size"));
|
|
||||||
}
|
|
||||||
if (!output.isEmpty()) {
|
|
||||||
Messaging.send(sender, output);
|
|
||||||
} else {
|
|
||||||
throw new CommandUsageException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
aliases = { "npc" },
|
|
||||||
usage = "piglin (--dancing [true|false])",
|
|
||||||
desc = "Sets piglin modifiers.",
|
|
||||||
modifiers = { "piglin" },
|
|
||||||
min = 1,
|
|
||||||
max = 1,
|
|
||||||
permission = "citizens.npc.piglin")
|
|
||||||
@Requirements(selected = true, ownership = true, types = { EntityType.PIGLIN })
|
|
||||||
public void piglin(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
PiglinTrait trait = npc.getOrAddTrait(PiglinTrait.class);
|
|
||||||
boolean hasArg = false;
|
|
||||||
if (args.hasValueFlag("dancing")) {
|
|
||||||
boolean dancing = Boolean.valueOf(args.getFlag("dancing"));
|
|
||||||
trait.setDancing(dancing);
|
|
||||||
Messaging.sendTr(sender, dancing ? Messages.PIGLIN_DANCING_SET : Messages.PIGLIN_DANCING_UNSET,
|
|
||||||
npc.getName());
|
|
||||||
hasArg = true;
|
|
||||||
}
|
|
||||||
if (!hasArg) {
|
|
||||||
throw new CommandUsageException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
aliases = { "npc" },
|
|
||||||
usage = "polarbear (-r)",
|
|
||||||
desc = "Sets polarbear modifiers.",
|
|
||||||
modifiers = { "polarbear" },
|
|
||||||
min = 1,
|
|
||||||
max = 1,
|
|
||||||
flags = "r",
|
|
||||||
permission = "citizens.npc.polarbear")
|
|
||||||
@Requirements(selected = true, ownership = true, types = { EntityType.POLAR_BEAR })
|
|
||||||
public void polarbear(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
PolarBearTrait trait = npc.getOrAddTrait(PolarBearTrait.class);
|
|
||||||
String output = "";
|
|
||||||
if (args.hasFlag('r')) {
|
|
||||||
trait.setRearing(!trait.isRearing());
|
|
||||||
output += Messaging.tr(
|
|
||||||
trait.isRearing() ? Messages.POLAR_BEAR_REARING : Messages.POLAR_BEAR_STOPPED_REARING,
|
|
||||||
npc.getName());
|
|
||||||
}
|
|
||||||
if (!output.isEmpty()) {
|
|
||||||
Messaging.send(sender, output);
|
|
||||||
} else {
|
|
||||||
throw new CommandUsageException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
aliases = { "npc" },
|
|
||||||
usage = "pufferfish (--state state)",
|
|
||||||
desc = "Sets pufferfish modifiers",
|
|
||||||
modifiers = { "pufferfish" },
|
|
||||||
min = 1,
|
|
||||||
max = 1,
|
|
||||||
permission = "citizens.npc.pufferfish")
|
|
||||||
@Requirements(selected = true, ownership = true, types = EntityType.PUFFERFISH)
|
|
||||||
public void pufferfish(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
PufferFishTrait trait = npc.getOrAddTrait(PufferFishTrait.class);
|
|
||||||
String output = "";
|
|
||||||
if (args.hasValueFlag("state")) {
|
|
||||||
int state = Math.min(Math.max(args.getFlagInteger("state"), 0), 3);
|
|
||||||
trait.setPuffState(state);
|
|
||||||
output += Messaging.tr(Messages.PUFFERFISH_STATE_SET, state);
|
|
||||||
}
|
|
||||||
if (!output.isEmpty()) {
|
|
||||||
Messaging.send(sender, output);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
aliases = { "npc" },
|
|
||||||
usage = "shulker (--peek [peek] --color [color])",
|
|
||||||
desc = "Sets shulker modifiers.",
|
|
||||||
modifiers = { "shulker" },
|
|
||||||
min = 1,
|
|
||||||
max = 1,
|
|
||||||
permission = "citizens.npc.shulker")
|
|
||||||
@Requirements(selected = true, ownership = true, types = { EntityType.SHULKER })
|
|
||||||
public void shulker(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
ShulkerTrait trait = npc.getOrAddTrait(ShulkerTrait.class);
|
|
||||||
boolean hasArg = false;
|
|
||||||
if (args.hasValueFlag("peek")) {
|
|
||||||
int peek = (byte) args.getFlagInteger("peek");
|
|
||||||
trait.setPeek(peek);
|
|
||||||
Messaging.sendTr(sender, Messages.SHULKER_PEEK_SET, npc.getName(), peek);
|
|
||||||
hasArg = true;
|
|
||||||
}
|
|
||||||
if (args.hasValueFlag("color")) {
|
|
||||||
DyeColor color = Util.matchEnum(DyeColor.values(), args.getFlag("color"));
|
|
||||||
if (color == null) {
|
|
||||||
Messaging.sendErrorTr(sender, Messages.INVALID_SHULKER_COLOR, Util.listValuesPretty(DyeColor.values()));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
trait.setColor(color);
|
|
||||||
Messaging.sendTr(sender, Messages.SHULKER_COLOR_SET, npc.getName(), Util.prettyEnum(color));
|
|
||||||
hasArg = true;
|
|
||||||
}
|
|
||||||
if (!hasArg) {
|
|
||||||
throw new CommandUsageException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
aliases = { "npc" },
|
|
||||||
usage = "snowman (-d[erp])",
|
|
||||||
desc = "Sets snowman modifiers.",
|
|
||||||
modifiers = { "snowman" },
|
|
||||||
min = 1,
|
|
||||||
max = 1,
|
|
||||||
flags = "d",
|
|
||||||
permission = "citizens.npc.snowman")
|
|
||||||
@Requirements(selected = true, ownership = true, types = { EntityType.SNOWMAN })
|
|
||||||
public void snowman(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
SnowmanTrait trait = npc.getOrAddTrait(SnowmanTrait.class);
|
|
||||||
boolean hasArg = false;
|
|
||||||
if (args.hasFlag('d')) {
|
|
||||||
boolean isDerp = trait.toggleDerp();
|
|
||||||
Messaging.sendTr(sender, isDerp ? Messages.SNOWMAN_DERP_SET : Messages.SNOWMAN_DERP_STOPPED, npc.getName());
|
|
||||||
hasArg = true;
|
|
||||||
}
|
|
||||||
if (!hasArg) {
|
|
||||||
throw new CommandUsageException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
aliases = { "npc" },
|
|
||||||
usage = "tfish (--body color) (--pattern pattern) (--patterncolor color)",
|
|
||||||
desc = "Sets tropical fish modifiers",
|
|
||||||
modifiers = { "tfish" },
|
|
||||||
min = 1,
|
|
||||||
max = 1,
|
|
||||||
permission = "citizens.npc.tropicalfish")
|
|
||||||
@Requirements(selected = true, ownership = true, types = EntityType.TROPICAL_FISH)
|
|
||||||
public void tropicalfish(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
TropicalFishTrait trait = npc.getOrAddTrait(TropicalFishTrait.class);
|
|
||||||
String output = "";
|
|
||||||
if (args.hasValueFlag("body")) {
|
|
||||||
DyeColor color = Util.matchEnum(DyeColor.values(), args.getFlag("body"));
|
|
||||||
if (color == null) {
|
|
||||||
throw new CommandException(Messages.INVALID_TROPICALFISH_COLOR,
|
|
||||||
Util.listValuesPretty(DyeColor.values()));
|
|
||||||
}
|
|
||||||
trait.setBodyColor(color);
|
|
||||||
output += Messaging.tr(Messages.TROPICALFISH_BODY_COLOR_SET, Util.prettyEnum(color));
|
|
||||||
}
|
|
||||||
if (args.hasValueFlag("patterncolor")) {
|
|
||||||
DyeColor color = Util.matchEnum(DyeColor.values(), args.getFlag("patterncolor"));
|
|
||||||
if (color == null) {
|
|
||||||
throw new CommandException(Messages.INVALID_TROPICALFISH_COLOR,
|
|
||||||
Util.listValuesPretty(DyeColor.values()));
|
|
||||||
}
|
|
||||||
trait.setPatternColor(color);
|
|
||||||
output += Messaging.tr(Messages.TROPICALFISH_PATTERN_COLOR_SET, Util.prettyEnum(color));
|
|
||||||
}
|
|
||||||
if (args.hasValueFlag("pattern")) {
|
|
||||||
Pattern pattern = Util.matchEnum(Pattern.values(), args.getFlag("pattern"));
|
|
||||||
if (pattern == null) {
|
|
||||||
throw new CommandException(Messages.INVALID_TROPICALFISH_PATTERN,
|
|
||||||
Util.listValuesPretty(Pattern.values()));
|
|
||||||
}
|
|
||||||
trait.setPattern(pattern);
|
|
||||||
output += Messaging.tr(Messages.TROPICALFISH_PATTERN_SET, Util.prettyEnum(pattern));
|
|
||||||
}
|
|
||||||
if (!output.isEmpty()) {
|
|
||||||
Messaging.send(sender, output);
|
|
||||||
} else {
|
|
||||||
throw new CommandUsageException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
aliases = { "npc" },
|
|
||||||
usage = "villager (--level level) (--type type) (--profession profession)",
|
|
||||||
desc = "Sets villager modifiers",
|
|
||||||
modifiers = { "villager" },
|
|
||||||
min = 1,
|
|
||||||
max = 1,
|
|
||||||
permission = "citizens.npc.villager")
|
|
||||||
@Requirements(selected = true, ownership = true, types = EntityType.VILLAGER)
|
|
||||||
public void villager(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
VillagerTrait trait = npc.getOrAddTrait(VillagerTrait.class);
|
|
||||||
String output = "";
|
|
||||||
if (args.hasValueFlag("level")) {
|
|
||||||
if (args.getFlagInteger("level") < 0) {
|
|
||||||
throw new CommandUsageException();
|
|
||||||
}
|
|
||||||
trait.setLevel(args.getFlagInteger("level"));
|
|
||||||
output += " " + Messaging.tr(Messages.VILLAGER_LEVEL_SET, args.getFlagInteger("level"));
|
|
||||||
}
|
|
||||||
if (args.hasValueFlag("type")) {
|
|
||||||
Villager.Type type = Util.matchEnum(Villager.Type.values(), args.getFlag("type"));
|
|
||||||
if (type == null) {
|
|
||||||
throw new CommandException(Messages.INVALID_VILLAGER_TYPE,
|
|
||||||
Util.listValuesPretty(Villager.Type.values()));
|
|
||||||
}
|
|
||||||
trait.setType(type);
|
|
||||||
output += " " + Messaging.tr(Messages.VILLAGER_TYPE_SET, args.getFlag("type"));
|
|
||||||
}
|
|
||||||
if (args.hasValueFlag("profession")) {
|
|
||||||
Profession parsed = Util.matchEnum(Profession.values(), args.getFlag("profession"));
|
|
||||||
if (parsed == null) {
|
|
||||||
throw new CommandException(Messages.INVALID_PROFESSION, args.getFlag("profession"),
|
|
||||||
Joiner.on(',').join(Profession.values()));
|
|
||||||
}
|
|
||||||
npc.getOrAddTrait(VillagerProfession.class).setProfession(parsed);
|
|
||||||
output += " " + Messaging.tr(Messages.PROFESSION_SET, npc.getName(), args.getFlag("profession"));
|
|
||||||
}
|
|
||||||
if (!output.isEmpty()) {
|
|
||||||
Messaging.send(sender, output.trim());
|
|
||||||
} else {
|
|
||||||
throw new CommandUsageException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -75,6 +75,7 @@ import net.citizensnpcs.api.npc.BlockBreaker;
|
|||||||
import net.citizensnpcs.api.npc.BlockBreaker.BlockBreakerConfiguration;
|
import net.citizensnpcs.api.npc.BlockBreaker.BlockBreakerConfiguration;
|
||||||
import net.citizensnpcs.api.npc.NPC;
|
import net.citizensnpcs.api.npc.NPC;
|
||||||
import net.citizensnpcs.api.npc.NPCRegistry;
|
import net.citizensnpcs.api.npc.NPCRegistry;
|
||||||
|
import net.citizensnpcs.api.trait.Trait;
|
||||||
import net.citizensnpcs.api.trait.TraitInfo;
|
import net.citizensnpcs.api.trait.TraitInfo;
|
||||||
import net.citizensnpcs.api.util.BoundingBox;
|
import net.citizensnpcs.api.util.BoundingBox;
|
||||||
import net.citizensnpcs.api.util.Messaging;
|
import net.citizensnpcs.api.util.Messaging;
|
||||||
@ -190,7 +191,6 @@ import net.citizensnpcs.nms.v1_18_R2.entity.nonliving.ThrownTridentController;
|
|||||||
import net.citizensnpcs.nms.v1_18_R2.entity.nonliving.TippedArrowController;
|
import net.citizensnpcs.nms.v1_18_R2.entity.nonliving.TippedArrowController;
|
||||||
import net.citizensnpcs.nms.v1_18_R2.entity.nonliving.WitherSkullController;
|
import net.citizensnpcs.nms.v1_18_R2.entity.nonliving.WitherSkullController;
|
||||||
import net.citizensnpcs.nms.v1_18_R2.network.EmptyChannel;
|
import net.citizensnpcs.nms.v1_18_R2.network.EmptyChannel;
|
||||||
import net.citizensnpcs.nms.v1_18_R2.trait.Commands;
|
|
||||||
import net.citizensnpcs.npc.EntityControllers;
|
import net.citizensnpcs.npc.EntityControllers;
|
||||||
import net.citizensnpcs.npc.ai.MCNavigationStrategy.MCNavigator;
|
import net.citizensnpcs.npc.ai.MCNavigationStrategy.MCNavigator;
|
||||||
import net.citizensnpcs.npc.ai.MCTargetStrategy.TargetNavigator;
|
import net.citizensnpcs.npc.ai.MCTargetStrategy.TargetNavigator;
|
||||||
@ -222,6 +222,7 @@ import net.citizensnpcs.util.Util;
|
|||||||
import net.minecraft.CrashReport;
|
import net.minecraft.CrashReport;
|
||||||
import net.minecraft.CrashReportCategory;
|
import net.minecraft.CrashReportCategory;
|
||||||
import net.minecraft.ReportedException;
|
import net.minecraft.ReportedException;
|
||||||
|
import net.minecraft.commands.Commands;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.Registry;
|
import net.minecraft.core.Registry;
|
||||||
import net.minecraft.network.Connection;
|
import net.minecraft.network.Connection;
|
||||||
@ -781,24 +782,23 @@ public class NMSImpl implements NMSBridge {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void load(CommandManager manager) {
|
public void load(CommandManager manager) {
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(AxolotlTrait.class));
|
registerTraitWithCommand(manager, AxolotlTrait.class);
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(BeeTrait.class));
|
registerTraitWithCommand(manager, BeeTrait.class);
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(BossBarTrait.class));
|
registerTraitWithCommand(manager, BossBarTrait.class);
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(CatTrait.class));
|
registerTraitWithCommand(manager, CatTrait.class);
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(FoxTrait.class));
|
registerTraitWithCommand(manager, FoxTrait.class);
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(LlamaTrait.class));
|
registerTraitWithCommand(manager, LlamaTrait.class);
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(MushroomCowTrait.class));
|
registerTraitWithCommand(manager, MushroomCowTrait.class);
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(ParrotTrait.class));
|
registerTraitWithCommand(manager, ParrotTrait.class);
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(PandaTrait.class));
|
registerTraitWithCommand(manager, PandaTrait.class);
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(PiglinTrait.class));
|
registerTraitWithCommand(manager, PiglinTrait.class);
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(PhantomTrait.class));
|
registerTraitWithCommand(manager, PhantomTrait.class);
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(PolarBearTrait.class));
|
registerTraitWithCommand(manager, PolarBearTrait.class);
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(PufferFishTrait.class));
|
registerTraitWithCommand(manager, PufferFishTrait.class);
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(ShulkerTrait.class));
|
registerTraitWithCommand(manager, ShulkerTrait.class);
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(SnowmanTrait.class));
|
registerTraitWithCommand(manager, SnowmanTrait.class);
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(TropicalFishTrait.class));
|
registerTraitWithCommand(manager, TropicalFishTrait.class);
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(VillagerTrait.class));
|
registerTraitWithCommand(manager, VillagerTrait.class);
|
||||||
manager.register(Commands.class);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadEntityTypes() {
|
private void loadEntityTypes() {
|
||||||
@ -1088,6 +1088,11 @@ public class NMSImpl implements NMSBridge {
|
|||||||
throw new IllegalArgumentException("unable to find valid entity superclass for class " + clazz.toString());
|
throw new IllegalArgumentException("unable to find valid entity superclass for class " + clazz.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void registerTraitWithCommand(CommandManager manager, Class<? extends Trait> clazz) {
|
||||||
|
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(clazz));
|
||||||
|
manager.register(clazz);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void remove(org.bukkit.entity.Entity entity) {
|
public void remove(org.bukkit.entity.Entity entity) {
|
||||||
NMSImpl.getHandle(entity).remove(RemovalReason.KILLED);
|
NMSImpl.getHandle(entity).remove(RemovalReason.KILLED);
|
||||||
|
@ -69,7 +69,6 @@ public class HumanController extends AbstractEntityController {
|
|||||||
}, 20);
|
}, 20);
|
||||||
|
|
||||||
handle.getBukkitEntity().setSleepingIgnored(true);
|
handle.getBukkitEntity().setSleepingIgnored(true);
|
||||||
|
|
||||||
return handle.getBukkitEntity();
|
return handle.getBukkitEntity();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,705 +0,0 @@
|
|||||||
package net.citizensnpcs.nms.v1_19_R1.trait;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.bukkit.DyeColor;
|
|
||||||
import org.bukkit.boss.BarColor;
|
|
||||||
import org.bukkit.boss.BarFlag;
|
|
||||||
import org.bukkit.boss.BarStyle;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Axolotl;
|
|
||||||
import org.bukkit.entity.Cat;
|
|
||||||
import org.bukkit.entity.EntityType;
|
|
||||||
import org.bukkit.entity.Fox;
|
|
||||||
import org.bukkit.entity.Frog;
|
|
||||||
import org.bukkit.entity.Llama.Color;
|
|
||||||
import org.bukkit.entity.MushroomCow;
|
|
||||||
import org.bukkit.entity.Panda;
|
|
||||||
import org.bukkit.entity.Parrot.Variant;
|
|
||||||
import org.bukkit.entity.TropicalFish.Pattern;
|
|
||||||
import org.bukkit.entity.Villager;
|
|
||||||
import org.bukkit.entity.Villager.Profession;
|
|
||||||
|
|
||||||
import com.google.common.base.Joiner;
|
|
||||||
import com.google.common.base.Splitter;
|
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
|
|
||||||
import net.citizensnpcs.api.command.Command;
|
|
||||||
import net.citizensnpcs.api.command.CommandContext;
|
|
||||||
import net.citizensnpcs.api.command.Requirements;
|
|
||||||
import net.citizensnpcs.api.command.exception.CommandException;
|
|
||||||
import net.citizensnpcs.api.command.exception.CommandUsageException;
|
|
||||||
import net.citizensnpcs.api.npc.NPC;
|
|
||||||
import net.citizensnpcs.api.util.Colorizer;
|
|
||||||
import net.citizensnpcs.api.util.Messaging;
|
|
||||||
import net.citizensnpcs.trait.HorseModifiers;
|
|
||||||
import net.citizensnpcs.trait.VillagerProfession;
|
|
||||||
import net.citizensnpcs.trait.versioned.AxolotlTrait;
|
|
||||||
import net.citizensnpcs.trait.versioned.BeeTrait;
|
|
||||||
import net.citizensnpcs.trait.versioned.BossBarTrait;
|
|
||||||
import net.citizensnpcs.trait.versioned.CatTrait;
|
|
||||||
import net.citizensnpcs.trait.versioned.FoxTrait;
|
|
||||||
import net.citizensnpcs.trait.versioned.FrogTrait;
|
|
||||||
import net.citizensnpcs.trait.versioned.GoatTrait;
|
|
||||||
import net.citizensnpcs.trait.versioned.LlamaTrait;
|
|
||||||
import net.citizensnpcs.trait.versioned.MushroomCowTrait;
|
|
||||||
import net.citizensnpcs.trait.versioned.PandaTrait;
|
|
||||||
import net.citizensnpcs.trait.versioned.ParrotTrait;
|
|
||||||
import net.citizensnpcs.trait.versioned.PhantomTrait;
|
|
||||||
import net.citizensnpcs.trait.versioned.PiglinTrait;
|
|
||||||
import net.citizensnpcs.trait.versioned.PolarBearTrait;
|
|
||||||
import net.citizensnpcs.trait.versioned.PufferFishTrait;
|
|
||||||
import net.citizensnpcs.trait.versioned.ShulkerTrait;
|
|
||||||
import net.citizensnpcs.trait.versioned.SnowmanTrait;
|
|
||||||
import net.citizensnpcs.trait.versioned.TropicalFishTrait;
|
|
||||||
import net.citizensnpcs.trait.versioned.VillagerTrait;
|
|
||||||
import net.citizensnpcs.util.Messages;
|
|
||||||
import net.citizensnpcs.util.Util;
|
|
||||||
|
|
||||||
public class Commands {
|
|
||||||
@Command(
|
|
||||||
aliases = { "npc" },
|
|
||||||
usage = "axolotl (-d) (--variant variant)",
|
|
||||||
desc = "Sets axolotl modifiers",
|
|
||||||
modifiers = { "axolotl" },
|
|
||||||
min = 1,
|
|
||||||
max = 1,
|
|
||||||
flags = "d",
|
|
||||||
permission = "citizens.npc.axolotl")
|
|
||||||
@Requirements(selected = true, ownership = true, types = EntityType.AXOLOTL)
|
|
||||||
public void axolotl(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
AxolotlTrait trait = npc.getOrAddTrait(AxolotlTrait.class);
|
|
||||||
String output = "";
|
|
||||||
if (args.hasValueFlag("variant")) {
|
|
||||||
Axolotl.Variant variant = Util.matchEnum(Axolotl.Variant.values(), args.getFlag("variant"));
|
|
||||||
if (variant == null) {
|
|
||||||
throw new CommandException(Messages.INVALID_AXOLOTL_VARIANT,
|
|
||||||
Util.listValuesPretty(Axolotl.Variant.values()));
|
|
||||||
}
|
|
||||||
trait.setVariant(variant);
|
|
||||||
output += ' ' + Messaging.tr(Messages.AXOLOTL_VARIANT_SET, args.getFlag("variant"));
|
|
||||||
}
|
|
||||||
if (args.hasFlag('d')) {
|
|
||||||
trait.setPlayingDead(!trait.isPlayingDead());
|
|
||||||
output += ' ' + (trait.isPlayingDead() ? Messaging.tr(Messages.AXOLOTL_PLAYING_DEAD, npc.getName())
|
|
||||||
: Messaging.tr(Messages.AXOLOTL_NOT_PLAYING_DEAD, npc.getName()));
|
|
||||||
}
|
|
||||||
if (!output.isEmpty()) {
|
|
||||||
Messaging.send(sender, output.trim());
|
|
||||||
} else {
|
|
||||||
throw new CommandUsageException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
aliases = { "npc" },
|
|
||||||
usage = "bee (-s/-n) --anger anger",
|
|
||||||
desc = "Sets bee modifiers",
|
|
||||||
modifiers = { "bee" },
|
|
||||||
min = 1,
|
|
||||||
max = 1,
|
|
||||||
flags = "sn",
|
|
||||||
permission = "citizens.npc.bee")
|
|
||||||
@Requirements(selected = true, ownership = true, types = EntityType.BEE)
|
|
||||||
public void bee(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
BeeTrait trait = npc.getOrAddTrait(BeeTrait.class);
|
|
||||||
String output = "";
|
|
||||||
if (args.hasValueFlag("anger")) {
|
|
||||||
int anger = args.getFlagInteger("anger");
|
|
||||||
if (anger < 0) {
|
|
||||||
throw new CommandException(Messages.INVALID_BEE_ANGER);
|
|
||||||
}
|
|
||||||
trait.setAnger(anger);
|
|
||||||
output += ' ' + Messaging.tr(Messages.BEE_ANGER_SET, args.getFlag("anger"));
|
|
||||||
}
|
|
||||||
if (args.hasFlag('s')) {
|
|
||||||
trait.setStung(!trait.hasStung());
|
|
||||||
output += ' ' + (trait.hasStung() ? Messaging.tr(Messages.BEE_STUNG, npc.getName())
|
|
||||||
: Messaging.tr(Messages.BEE_NOT_STUNG, npc.getName()));
|
|
||||||
}
|
|
||||||
if (args.hasFlag('n')) {
|
|
||||||
trait.setNectar(!trait.hasNectar());
|
|
||||||
output += ' ' + (trait.hasNectar() ? Messaging.tr(Messages.BEE_HAS_NECTAR, npc.getName())
|
|
||||||
: Messaging.tr(Messages.BEE_NO_NECTAR, npc.getName()));
|
|
||||||
}
|
|
||||||
if (!output.isEmpty()) {
|
|
||||||
Messaging.send(sender, output.trim());
|
|
||||||
} else {
|
|
||||||
throw new CommandUsageException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
aliases = { "npc" },
|
|
||||||
usage = "bossbar --style [style] --color [color] --title [title] --visible [visible] --flags [flags] --track [health | placeholder]",
|
|
||||||
desc = "Edit bossbar properties",
|
|
||||||
modifiers = { "bossbar" },
|
|
||||||
min = 1,
|
|
||||||
max = 1)
|
|
||||||
@Requirements(selected = true, ownership = true)
|
|
||||||
public void bossbar(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
BossBarTrait trait = npc.getOrAddTrait(BossBarTrait.class);
|
|
||||||
if (args.hasValueFlag("style")) {
|
|
||||||
BarStyle style = Util.matchEnum(BarStyle.values(), args.getFlag("style"));
|
|
||||||
if (style != null) {
|
|
||||||
trait.setStyle(style);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (args.hasValueFlag("color")) {
|
|
||||||
BarColor color = Util.matchEnum(BarColor.values(), args.getFlag("color"));
|
|
||||||
if (color != null) {
|
|
||||||
trait.setColor(color);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (args.hasValueFlag("track")) {
|
|
||||||
trait.setTrackVariable(args.getFlag("track"));
|
|
||||||
}
|
|
||||||
if (args.hasValueFlag("title")) {
|
|
||||||
trait.setTitle(Colorizer.parseColors(args.getFlag("title")));
|
|
||||||
}
|
|
||||||
if (args.hasValueFlag("visible")) {
|
|
||||||
trait.setVisible(Boolean.parseBoolean(args.getFlag("visible")));
|
|
||||||
}
|
|
||||||
if (args.hasValueFlag("flags")) {
|
|
||||||
List<BarFlag> flags = Lists.newArrayList();
|
|
||||||
for (String s : Splitter.on(',').omitEmptyStrings().trimResults().split(args.getFlag("flags"))) {
|
|
||||||
BarFlag flag = Util.matchEnum(BarFlag.values(), s);
|
|
||||||
if (flag != null) {
|
|
||||||
flags.add(flag);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
trait.setFlags(flags);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
aliases = { "npc" },
|
|
||||||
usage = "cat (-s/-n/-l) --type type --ccolor collar color",
|
|
||||||
desc = "Sets cat modifiers",
|
|
||||||
modifiers = { "cat" },
|
|
||||||
min = 1,
|
|
||||||
max = 1,
|
|
||||||
flags = "snl",
|
|
||||||
permission = "citizens.npc.cat")
|
|
||||||
@Requirements(selected = true, ownership = true, types = EntityType.CAT)
|
|
||||||
public void cat(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
CatTrait trait = npc.getOrAddTrait(CatTrait.class);
|
|
||||||
String output = "";
|
|
||||||
if (args.hasValueFlag("type")) {
|
|
||||||
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()));
|
|
||||||
}
|
|
||||||
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, npc.getName());
|
|
||||||
} else if (args.hasFlag('n')) {
|
|
||||||
trait.setSitting(false);
|
|
||||||
output += ' ' + Messaging.tr(Messages.CAT_STOPPED_SITTING, npc.getName());
|
|
||||||
}
|
|
||||||
if (args.hasFlag('l')) {
|
|
||||||
trait.setLyingDown(!trait.isLyingDown());
|
|
||||||
output += ' ' + Messaging.tr(trait.isLyingDown() ? Messages.CAT_STARTED_LYING : Messages.CAT_STOPPED_LYING,
|
|
||||||
npc.getName());
|
|
||||||
}
|
|
||||||
if (!output.isEmpty()) {
|
|
||||||
Messaging.send(sender, output.trim());
|
|
||||||
} else {
|
|
||||||
throw new CommandUsageException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@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.getOrAddTrait(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 = "frog (--variant variant) (--target [target])",
|
|
||||||
desc = "Sets frog modifiers",
|
|
||||||
modifiers = { "frog" },
|
|
||||||
min = 1,
|
|
||||||
max = 1,
|
|
||||||
permission = "citizens.npc.frog")
|
|
||||||
@Requirements(selected = true, ownership = true, types = EntityType.FROG)
|
|
||||||
public void frog(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
FrogTrait trait = npc.getOrAddTrait(FrogTrait.class);
|
|
||||||
String output = "";
|
|
||||||
if (args.hasValueFlag("variant")) {
|
|
||||||
String variantRaw = args.getFlag("variant");
|
|
||||||
Frog.Variant variant = Util.matchEnum(Frog.Variant.values(), variantRaw);
|
|
||||||
if (variant == null) {
|
|
||||||
String valid = Util.listValuesPretty(Frog.Variant.values());
|
|
||||||
throw new CommandException(Messages.INVALID_FROG_VARIANT, valid);
|
|
||||||
}
|
|
||||||
trait.setVariant(variant);
|
|
||||||
output += Messaging.tr(Messages.FROG_VARIANT_SET, Util.prettyEnum(variant));
|
|
||||||
}
|
|
||||||
if (!output.isEmpty()) {
|
|
||||||
Messaging.send(sender, output);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
aliases = { "npc" },
|
|
||||||
usage = "goat -l(eft) -r(ight) -n(either) -b(oth) horn",
|
|
||||||
desc = "Sets goat modifiers",
|
|
||||||
modifiers = { "goat" },
|
|
||||||
flags = "lrnb",
|
|
||||||
min = 1,
|
|
||||||
max = 1,
|
|
||||||
permission = "citizens.npc.goat")
|
|
||||||
@Requirements(selected = true, ownership = true, types = EntityType.GOAT)
|
|
||||||
public void goat(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
GoatTrait trait = npc.getOrAddTrait(GoatTrait.class);
|
|
||||||
boolean left = trait.isLeftHorn(), right = trait.isRightHorn();
|
|
||||||
if (args.hasFlag('l')) {
|
|
||||||
left = !left;
|
|
||||||
}
|
|
||||||
if (args.hasFlag('r')) {
|
|
||||||
right = !right;
|
|
||||||
}
|
|
||||||
if (args.hasFlag('b')) {
|
|
||||||
left = right = true;
|
|
||||||
}
|
|
||||||
if (args.hasFlag('n')) {
|
|
||||||
left = right = false;
|
|
||||||
}
|
|
||||||
trait.setLeftHorn(left);
|
|
||||||
trait.setRightHorn(right);
|
|
||||||
String output = Messaging.tr(Messages.NPC_GOAT_HORNS_SET, npc.getName(), left, right);
|
|
||||||
if (!output.isEmpty()) {
|
|
||||||
Messaging.send(sender, output);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
aliases = { "npc" },
|
|
||||||
usage = "llama (--color color) (--strength strength)",
|
|
||||||
desc = "Sets llama modifiers",
|
|
||||||
modifiers = { "llama" },
|
|
||||||
min = 1,
|
|
||||||
max = 1,
|
|
||||||
permission = "citizens.npc.llama")
|
|
||||||
@Requirements(selected = true, ownership = true, types = { EntityType.LLAMA, EntityType.TRADER_LLAMA })
|
|
||||||
public void llama(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
LlamaTrait trait = npc.getOrAddTrait(LlamaTrait.class);
|
|
||||||
String output = "";
|
|
||||||
if (args.hasValueFlag("color") || args.hasValueFlag("colour")) {
|
|
||||||
String colorRaw = args.getFlag("color", args.getFlag("colour"));
|
|
||||||
Color color = Util.matchEnum(Color.values(), colorRaw);
|
|
||||||
if (color == null) {
|
|
||||||
String valid = Util.listValuesPretty(Color.values());
|
|
||||||
throw new CommandException(Messages.INVALID_LLAMA_COLOR, valid);
|
|
||||||
}
|
|
||||||
trait.setColor(color);
|
|
||||||
output += Messaging.tr(Messages.LLAMA_COLOR_SET, Util.prettyEnum(color));
|
|
||||||
}
|
|
||||||
if (args.hasValueFlag("strength")) {
|
|
||||||
trait.setStrength(Math.max(1, Math.min(5, args.getFlagInteger("strength"))));
|
|
||||||
output += Messaging.tr(Messages.LLAMA_STRENGTH_SET, args.getFlagInteger("strength"));
|
|
||||||
}
|
|
||||||
if (args.hasFlag('c')) {
|
|
||||||
npc.getOrAddTrait(HorseModifiers.class).setCarryingChest(true);
|
|
||||||
output += Messaging.tr(Messages.HORSE_CHEST_SET) + " ";
|
|
||||||
} else if (args.hasFlag('b')) {
|
|
||||||
npc.getOrAddTrait(HorseModifiers.class).setCarryingChest(false);
|
|
||||||
output += Messaging.tr(Messages.HORSE_CHEST_UNSET) + " ";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!output.isEmpty()) {
|
|
||||||
Messaging.send(sender, output);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
aliases = { "npc" },
|
|
||||||
usage = "mcow (--variant [variant])",
|
|
||||||
desc = "Sets mushroom cow modifiers.",
|
|
||||||
modifiers = { "mcow", "mushroomcow" },
|
|
||||||
min = 1,
|
|
||||||
max = 1,
|
|
||||||
permission = "citizens.npc.mushroomcow")
|
|
||||||
@Requirements(selected = true, ownership = true, types = { EntityType.MUSHROOM_COW })
|
|
||||||
public void mushroomcow(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
MushroomCowTrait trait = npc.getOrAddTrait(MushroomCowTrait.class);
|
|
||||||
boolean hasArg = false;
|
|
||||||
if (args.hasValueFlag("variant")) {
|
|
||||||
MushroomCow.Variant variant = Util.matchEnum(MushroomCow.Variant.values(), args.getFlag("variant"));
|
|
||||||
if (variant == null) {
|
|
||||||
Messaging.sendErrorTr(sender, Messages.INVALID_MUSHROOM_COW_VARIANT,
|
|
||||||
Util.listValuesPretty(MushroomCow.Variant.values()));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
trait.setVariant(variant);
|
|
||||||
Messaging.sendTr(sender, Messages.MUSHROOM_COW_VARIANT_SET, npc.getName(), variant);
|
|
||||||
hasArg = true;
|
|
||||||
}
|
|
||||||
if (!hasArg) {
|
|
||||||
throw new CommandUsageException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
aliases = { "npc" },
|
|
||||||
usage = "panda --gene (main gene) --hgene (hidden gene) -s(itting)",
|
|
||||||
desc = "Sets panda modifiers",
|
|
||||||
modifiers = { "panda" },
|
|
||||||
flags = "s",
|
|
||||||
min = 1,
|
|
||||||
max = 1,
|
|
||||||
permission = "citizens.npc.panda")
|
|
||||||
@Requirements(selected = true, ownership = true, types = EntityType.PANDA)
|
|
||||||
public void panda(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
PandaTrait trait = npc.getOrAddTrait(PandaTrait.class);
|
|
||||||
String output = "";
|
|
||||||
if (args.hasValueFlag("gene")) {
|
|
||||||
Panda.Gene gene = Util.matchEnum(Panda.Gene.values(), args.getFlag("gene"));
|
|
||||||
if (gene == null) {
|
|
||||||
throw new CommandUsageException(Messages.INVALID_PANDA_GENE,
|
|
||||||
Util.listValuesPretty(Panda.Gene.values()));
|
|
||||||
}
|
|
||||||
trait.setMainGene(gene);
|
|
||||||
output += ' ' + Messaging.tr(Messages.PANDA_MAIN_GENE_SET, args.getFlag("gene"));
|
|
||||||
}
|
|
||||||
if (args.hasValueFlag("hgene")) {
|
|
||||||
Panda.Gene gene = Util.matchEnum(Panda.Gene.values(), args.getFlag("hgene"));
|
|
||||||
if (gene == null) {
|
|
||||||
throw new CommandUsageException(Messages.INVALID_PANDA_GENE,
|
|
||||||
Util.listValuesPretty(Panda.Gene.values()));
|
|
||||||
}
|
|
||||||
trait.setHiddenGene(gene);
|
|
||||||
output += ' ' + Messaging.tr(Messages.PANDA_HIDDEN_GENE_SET, args.getFlag("hgene"));
|
|
||||||
}
|
|
||||||
if (args.hasFlag('s')) {
|
|
||||||
boolean isSitting = trait.toggleSitting();
|
|
||||||
output += ' ' + Messaging.tr(isSitting ? Messages.PANDA_SITTING : Messages.PANDA_STOPPED_SITTING);
|
|
||||||
}
|
|
||||||
if (!output.isEmpty()) {
|
|
||||||
Messaging.send(sender, output.trim());
|
|
||||||
} else {
|
|
||||||
throw new CommandUsageException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
aliases = { "npc" },
|
|
||||||
usage = "parrot (--variant variant)",
|
|
||||||
desc = "Sets parrot modifiers",
|
|
||||||
modifiers = { "parrot" },
|
|
||||||
min = 1,
|
|
||||||
max = 1,
|
|
||||||
permission = "citizens.npc.parrot")
|
|
||||||
@Requirements(selected = true, ownership = true, types = EntityType.PARROT)
|
|
||||||
public void parrot(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
ParrotTrait trait = npc.getOrAddTrait(ParrotTrait.class);
|
|
||||||
String output = "";
|
|
||||||
if (args.hasValueFlag("variant")) {
|
|
||||||
String variantRaw = args.getFlag("variant");
|
|
||||||
Variant variant = Util.matchEnum(Variant.values(), variantRaw);
|
|
||||||
if (variant == null) {
|
|
||||||
String valid = Util.listValuesPretty(Variant.values());
|
|
||||||
throw new CommandException(Messages.INVALID_PARROT_VARIANT, valid);
|
|
||||||
}
|
|
||||||
trait.setVariant(variant);
|
|
||||||
output += Messaging.tr(Messages.PARROT_VARIANT_SET, Util.prettyEnum(variant));
|
|
||||||
}
|
|
||||||
if (!output.isEmpty()) {
|
|
||||||
Messaging.send(sender, output);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
aliases = { "npc" },
|
|
||||||
usage = "phantom (--size size)",
|
|
||||||
desc = "Sets phantom modifiers",
|
|
||||||
modifiers = { "phantom" },
|
|
||||||
min = 1,
|
|
||||||
max = 1,
|
|
||||||
permission = "citizens.npc.phantom")
|
|
||||||
@Requirements(selected = true, ownership = true, types = EntityType.PHANTOM)
|
|
||||||
public void phantom(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
PhantomTrait trait = npc.getOrAddTrait(PhantomTrait.class);
|
|
||||||
String output = "";
|
|
||||||
if (args.hasValueFlag("size")) {
|
|
||||||
if (args.getFlagInteger("size") <= 0) {
|
|
||||||
throw new CommandUsageException();
|
|
||||||
}
|
|
||||||
trait.setSize(args.getFlagInteger("size"));
|
|
||||||
output += Messaging.tr(Messages.PHANTOM_STATE_SET, args.getFlagInteger("size"));
|
|
||||||
}
|
|
||||||
if (!output.isEmpty()) {
|
|
||||||
Messaging.send(sender, output);
|
|
||||||
} else {
|
|
||||||
throw new CommandUsageException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
aliases = { "npc" },
|
|
||||||
usage = "piglin (--dancing [true|false])",
|
|
||||||
desc = "Sets piglin modifiers.",
|
|
||||||
modifiers = { "piglin" },
|
|
||||||
min = 1,
|
|
||||||
max = 1,
|
|
||||||
permission = "citizens.npc.piglin")
|
|
||||||
@Requirements(selected = true, ownership = true, types = { EntityType.PIGLIN })
|
|
||||||
public void piglin(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
PiglinTrait trait = npc.getOrAddTrait(PiglinTrait.class);
|
|
||||||
boolean hasArg = false;
|
|
||||||
if (args.hasValueFlag("dancing")) {
|
|
||||||
boolean dancing = Boolean.valueOf(args.getFlag("dancing"));
|
|
||||||
trait.setDancing(dancing);
|
|
||||||
Messaging.sendTr(sender, dancing ? Messages.PIGLIN_DANCING_SET : Messages.PIGLIN_DANCING_UNSET,
|
|
||||||
npc.getName());
|
|
||||||
hasArg = true;
|
|
||||||
}
|
|
||||||
if (!hasArg) {
|
|
||||||
throw new CommandUsageException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
aliases = { "npc" },
|
|
||||||
usage = "polarbear (-r)",
|
|
||||||
desc = "Sets polarbear modifiers.",
|
|
||||||
modifiers = { "polarbear" },
|
|
||||||
min = 1,
|
|
||||||
max = 1,
|
|
||||||
flags = "r",
|
|
||||||
permission = "citizens.npc.polarbear")
|
|
||||||
@Requirements(selected = true, ownership = true, types = { EntityType.POLAR_BEAR })
|
|
||||||
public void polarbear(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
PolarBearTrait trait = npc.getOrAddTrait(PolarBearTrait.class);
|
|
||||||
String output = "";
|
|
||||||
if (args.hasFlag('r')) {
|
|
||||||
trait.setRearing(!trait.isRearing());
|
|
||||||
output += Messaging.tr(
|
|
||||||
trait.isRearing() ? Messages.POLAR_BEAR_REARING : Messages.POLAR_BEAR_STOPPED_REARING,
|
|
||||||
npc.getName());
|
|
||||||
}
|
|
||||||
if (!output.isEmpty()) {
|
|
||||||
Messaging.send(sender, output);
|
|
||||||
} else {
|
|
||||||
throw new CommandUsageException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
aliases = { "npc" },
|
|
||||||
usage = "pufferfish (--state state)",
|
|
||||||
desc = "Sets pufferfish modifiers",
|
|
||||||
modifiers = { "pufferfish" },
|
|
||||||
min = 1,
|
|
||||||
max = 1,
|
|
||||||
permission = "citizens.npc.pufferfish")
|
|
||||||
@Requirements(selected = true, ownership = true, types = EntityType.PUFFERFISH)
|
|
||||||
public void pufferfish(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
PufferFishTrait trait = npc.getOrAddTrait(PufferFishTrait.class);
|
|
||||||
String output = "";
|
|
||||||
if (args.hasValueFlag("state")) {
|
|
||||||
int state = Math.min(Math.max(args.getFlagInteger("state"), 0), 3);
|
|
||||||
trait.setPuffState(state);
|
|
||||||
output += Messaging.tr(Messages.PUFFERFISH_STATE_SET, state);
|
|
||||||
}
|
|
||||||
if (!output.isEmpty()) {
|
|
||||||
Messaging.send(sender, output);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
aliases = { "npc" },
|
|
||||||
usage = "shulker (--peek [peek] --color [color])",
|
|
||||||
desc = "Sets shulker modifiers.",
|
|
||||||
modifiers = { "shulker" },
|
|
||||||
min = 1,
|
|
||||||
max = 1,
|
|
||||||
permission = "citizens.npc.shulker")
|
|
||||||
@Requirements(selected = true, ownership = true, types = { EntityType.SHULKER })
|
|
||||||
public void shulker(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
ShulkerTrait trait = npc.getOrAddTrait(ShulkerTrait.class);
|
|
||||||
boolean hasArg = false;
|
|
||||||
if (args.hasValueFlag("peek")) {
|
|
||||||
int peek = (byte) args.getFlagInteger("peek");
|
|
||||||
trait.setPeek(peek);
|
|
||||||
Messaging.sendTr(sender, Messages.SHULKER_PEEK_SET, npc.getName(), peek);
|
|
||||||
hasArg = true;
|
|
||||||
}
|
|
||||||
if (args.hasValueFlag("color")) {
|
|
||||||
DyeColor color = Util.matchEnum(DyeColor.values(), args.getFlag("color"));
|
|
||||||
if (color == null) {
|
|
||||||
Messaging.sendErrorTr(sender, Messages.INVALID_SHULKER_COLOR, Util.listValuesPretty(DyeColor.values()));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
trait.setColor(color);
|
|
||||||
Messaging.sendTr(sender, Messages.SHULKER_COLOR_SET, npc.getName(), Util.prettyEnum(color));
|
|
||||||
hasArg = true;
|
|
||||||
}
|
|
||||||
if (!hasArg) {
|
|
||||||
throw new CommandUsageException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
aliases = { "npc" },
|
|
||||||
usage = "snowman (-d[erp])",
|
|
||||||
desc = "Sets snowman modifiers.",
|
|
||||||
modifiers = { "snowman" },
|
|
||||||
min = 1,
|
|
||||||
max = 1,
|
|
||||||
flags = "d",
|
|
||||||
permission = "citizens.npc.snowman")
|
|
||||||
@Requirements(selected = true, ownership = true, types = { EntityType.SNOWMAN })
|
|
||||||
public void snowman(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
SnowmanTrait trait = npc.getOrAddTrait(SnowmanTrait.class);
|
|
||||||
boolean hasArg = false;
|
|
||||||
if (args.hasFlag('d')) {
|
|
||||||
boolean isDerp = trait.toggleDerp();
|
|
||||||
Messaging.sendTr(sender, isDerp ? Messages.SNOWMAN_DERP_SET : Messages.SNOWMAN_DERP_STOPPED, npc.getName());
|
|
||||||
hasArg = true;
|
|
||||||
}
|
|
||||||
if (!hasArg) {
|
|
||||||
throw new CommandUsageException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
aliases = { "npc" },
|
|
||||||
usage = "tfish (--body color) (--pattern pattern) (--patterncolor color)",
|
|
||||||
desc = "Sets tropical fish modifiers",
|
|
||||||
modifiers = { "tfish" },
|
|
||||||
min = 1,
|
|
||||||
max = 1,
|
|
||||||
permission = "citizens.npc.tropicalfish")
|
|
||||||
@Requirements(selected = true, ownership = true, types = EntityType.TROPICAL_FISH)
|
|
||||||
public void tropicalfish(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
TropicalFishTrait trait = npc.getOrAddTrait(TropicalFishTrait.class);
|
|
||||||
String output = "";
|
|
||||||
if (args.hasValueFlag("body")) {
|
|
||||||
DyeColor color = Util.matchEnum(DyeColor.values(), args.getFlag("body"));
|
|
||||||
if (color == null) {
|
|
||||||
throw new CommandException(Messages.INVALID_TROPICALFISH_COLOR,
|
|
||||||
Util.listValuesPretty(DyeColor.values()));
|
|
||||||
}
|
|
||||||
trait.setBodyColor(color);
|
|
||||||
output += Messaging.tr(Messages.TROPICALFISH_BODY_COLOR_SET, Util.prettyEnum(color));
|
|
||||||
}
|
|
||||||
if (args.hasValueFlag("patterncolor")) {
|
|
||||||
DyeColor color = Util.matchEnum(DyeColor.values(), args.getFlag("patterncolor"));
|
|
||||||
if (color == null) {
|
|
||||||
throw new CommandException(Messages.INVALID_TROPICALFISH_COLOR,
|
|
||||||
Util.listValuesPretty(DyeColor.values()));
|
|
||||||
}
|
|
||||||
trait.setPatternColor(color);
|
|
||||||
output += Messaging.tr(Messages.TROPICALFISH_PATTERN_COLOR_SET, Util.prettyEnum(color));
|
|
||||||
}
|
|
||||||
if (args.hasValueFlag("pattern")) {
|
|
||||||
Pattern pattern = Util.matchEnum(Pattern.values(), args.getFlag("pattern"));
|
|
||||||
if (pattern == null) {
|
|
||||||
throw new CommandException(Messages.INVALID_TROPICALFISH_PATTERN,
|
|
||||||
Util.listValuesPretty(Pattern.values()));
|
|
||||||
}
|
|
||||||
trait.setPattern(pattern);
|
|
||||||
output += Messaging.tr(Messages.TROPICALFISH_PATTERN_SET, Util.prettyEnum(pattern));
|
|
||||||
}
|
|
||||||
if (!output.isEmpty()) {
|
|
||||||
Messaging.send(sender, output);
|
|
||||||
} else {
|
|
||||||
throw new CommandUsageException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
aliases = { "npc" },
|
|
||||||
usage = "villager (--level level) (--type type) (--profession profession)",
|
|
||||||
desc = "Sets villager modifiers",
|
|
||||||
modifiers = { "villager" },
|
|
||||||
min = 1,
|
|
||||||
max = 1,
|
|
||||||
permission = "citizens.npc.villager")
|
|
||||||
@Requirements(selected = true, ownership = true, types = EntityType.VILLAGER)
|
|
||||||
public void villager(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
|
||||||
VillagerTrait trait = npc.getOrAddTrait(VillagerTrait.class);
|
|
||||||
String output = "";
|
|
||||||
if (args.hasValueFlag("level")) {
|
|
||||||
if (args.getFlagInteger("level") < 0) {
|
|
||||||
throw new CommandUsageException();
|
|
||||||
}
|
|
||||||
trait.setLevel(args.getFlagInteger("level"));
|
|
||||||
output += " " + Messaging.tr(Messages.VILLAGER_LEVEL_SET, args.getFlagInteger("level"));
|
|
||||||
}
|
|
||||||
if (args.hasValueFlag("type")) {
|
|
||||||
Villager.Type type = Util.matchEnum(Villager.Type.values(), args.getFlag("type"));
|
|
||||||
if (type == null) {
|
|
||||||
throw new CommandException(Messages.INVALID_VILLAGER_TYPE,
|
|
||||||
Util.listValuesPretty(Villager.Type.values()));
|
|
||||||
}
|
|
||||||
trait.setType(type);
|
|
||||||
output += " " + Messaging.tr(Messages.VILLAGER_TYPE_SET, args.getFlag("type"));
|
|
||||||
}
|
|
||||||
if (args.hasValueFlag("profession")) {
|
|
||||||
Profession parsed = Util.matchEnum(Profession.values(), args.getFlag("profession"));
|
|
||||||
if (parsed == null) {
|
|
||||||
throw new CommandException(Messages.INVALID_PROFESSION, args.getFlag("profession"),
|
|
||||||
Joiner.on(',').join(Profession.values()));
|
|
||||||
}
|
|
||||||
npc.getOrAddTrait(VillagerProfession.class).setProfession(parsed);
|
|
||||||
output += " " + Messaging.tr(Messages.PROFESSION_SET, npc.getName(), args.getFlag("profession"));
|
|
||||||
}
|
|
||||||
if (!output.isEmpty()) {
|
|
||||||
Messaging.send(sender, output.trim());
|
|
||||||
} else {
|
|
||||||
throw new CommandUsageException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -75,6 +75,7 @@ import net.citizensnpcs.api.npc.BlockBreaker;
|
|||||||
import net.citizensnpcs.api.npc.BlockBreaker.BlockBreakerConfiguration;
|
import net.citizensnpcs.api.npc.BlockBreaker.BlockBreakerConfiguration;
|
||||||
import net.citizensnpcs.api.npc.NPC;
|
import net.citizensnpcs.api.npc.NPC;
|
||||||
import net.citizensnpcs.api.npc.NPCRegistry;
|
import net.citizensnpcs.api.npc.NPCRegistry;
|
||||||
|
import net.citizensnpcs.api.trait.Trait;
|
||||||
import net.citizensnpcs.api.trait.TraitInfo;
|
import net.citizensnpcs.api.trait.TraitInfo;
|
||||||
import net.citizensnpcs.api.util.BoundingBox;
|
import net.citizensnpcs.api.util.BoundingBox;
|
||||||
import net.citizensnpcs.api.util.Messaging;
|
import net.citizensnpcs.api.util.Messaging;
|
||||||
@ -195,7 +196,6 @@ import net.citizensnpcs.nms.v1_19_R1.entity.nonliving.ThrownTridentController;
|
|||||||
import net.citizensnpcs.nms.v1_19_R1.entity.nonliving.TippedArrowController;
|
import net.citizensnpcs.nms.v1_19_R1.entity.nonliving.TippedArrowController;
|
||||||
import net.citizensnpcs.nms.v1_19_R1.entity.nonliving.WitherSkullController;
|
import net.citizensnpcs.nms.v1_19_R1.entity.nonliving.WitherSkullController;
|
||||||
import net.citizensnpcs.nms.v1_19_R1.network.EmptyChannel;
|
import net.citizensnpcs.nms.v1_19_R1.network.EmptyChannel;
|
||||||
import net.citizensnpcs.nms.v1_19_R1.trait.Commands;
|
|
||||||
import net.citizensnpcs.npc.EntityControllers;
|
import net.citizensnpcs.npc.EntityControllers;
|
||||||
import net.citizensnpcs.npc.ai.MCNavigationStrategy.MCNavigator;
|
import net.citizensnpcs.npc.ai.MCNavigationStrategy.MCNavigator;
|
||||||
import net.citizensnpcs.npc.ai.MCTargetStrategy.TargetNavigator;
|
import net.citizensnpcs.npc.ai.MCTargetStrategy.TargetNavigator;
|
||||||
@ -790,26 +790,25 @@ public class NMSImpl implements NMSBridge {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void load(CommandManager manager) {
|
public void load(CommandManager manager) {
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(AxolotlTrait.class));
|
registerTraitWithCommand(manager, AxolotlTrait.class);
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(BeeTrait.class));
|
registerTraitWithCommand(manager, BeeTrait.class);
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(BossBarTrait.class));
|
registerTraitWithCommand(manager, BossBarTrait.class);
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(CatTrait.class));
|
registerTraitWithCommand(manager, CatTrait.class);
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(FoxTrait.class));
|
registerTraitWithCommand(manager, FoxTrait.class);
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(FrogTrait.class));
|
registerTraitWithCommand(manager, FrogTrait.class);
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(GoatTrait.class));
|
registerTraitWithCommand(manager, GoatTrait.class);
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(LlamaTrait.class));
|
registerTraitWithCommand(manager, LlamaTrait.class);
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(MushroomCowTrait.class));
|
registerTraitWithCommand(manager, MushroomCowTrait.class);
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(ParrotTrait.class));
|
registerTraitWithCommand(manager, ParrotTrait.class);
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(PandaTrait.class));
|
registerTraitWithCommand(manager, PandaTrait.class);
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(PiglinTrait.class));
|
registerTraitWithCommand(manager, PiglinTrait.class);
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(PhantomTrait.class));
|
registerTraitWithCommand(manager, PhantomTrait.class);
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(PolarBearTrait.class));
|
registerTraitWithCommand(manager, PolarBearTrait.class);
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(PufferFishTrait.class));
|
registerTraitWithCommand(manager, PufferFishTrait.class);
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(ShulkerTrait.class));
|
registerTraitWithCommand(manager, ShulkerTrait.class);
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(SnowmanTrait.class));
|
registerTraitWithCommand(manager, SnowmanTrait.class);
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(TropicalFishTrait.class));
|
registerTraitWithCommand(manager, TropicalFishTrait.class);
|
||||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(VillagerTrait.class));
|
registerTraitWithCommand(manager, VillagerTrait.class);
|
||||||
manager.register(Commands.class);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadEntityTypes() {
|
private void loadEntityTypes() {
|
||||||
@ -1104,6 +1103,11 @@ public class NMSImpl implements NMSBridge {
|
|||||||
throw new IllegalArgumentException("unable to find valid entity superclass for class " + clazz.toString());
|
throw new IllegalArgumentException("unable to find valid entity superclass for class " + clazz.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void registerTraitWithCommand(CommandManager manager, Class<? extends Trait> clazz) {
|
||||||
|
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(clazz));
|
||||||
|
manager.register(clazz);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void remove(org.bukkit.entity.Entity entity) {
|
public void remove(org.bukkit.entity.Entity entity) {
|
||||||
NMSImpl.getHandle(entity).remove(RemovalReason.KILLED);
|
NMSImpl.getHandle(entity).remove(RemovalReason.KILLED);
|
||||||
|
Loading…
Reference in New Issue
Block a user