mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-12-23 17:47:35 +01:00
Add parrot command, fix 1.12 bug in players
This commit is contained in:
parent
8e0fa64f9a
commit
9f291dfec2
@ -108,6 +108,7 @@ public class Messages {
|
||||
public static final String INVALID_HORSE_VARIANT = "citizens.commands.npc.horse.invalid-variant";
|
||||
public static final String INVALID_LLAMA_COLOR = "citizens.commands.npc.llama.invalid-color";
|
||||
public static final String INVALID_OCELOT_TYPE = "citizens.commands.npc.ocelot.invalid-type";
|
||||
public static final String INVALID_PARROT_VARIANT = "citizens.commands.npc.parrot.invalid-variant";
|
||||
public static final String INVALID_POSE_NAME = "citizens.commands.npc.pose.invalid-name";
|
||||
public static final String INVALID_PROFESSION = "citizens.commands.npc.profession.invalid-profession";
|
||||
public static final String INVALID_RABBIT_TYPE = "citizens.commands.npc.rabbittype.invalid-type";
|
||||
@ -170,6 +171,7 @@ public class Messages {
|
||||
public static final String OVER_NPC_LIMIT = "citizens.limits.over-npc-limit";
|
||||
public static final String OWNER_SET = "citizens.commands.npc.owner.set";
|
||||
public static final String OWNER_SET_SERVER = "citizens.commands.npc.owner.set-server";
|
||||
public static final String PARROT_VARIANT_SET = "citizens.commands.npc.parrot.variant-set";
|
||||
public static final String PASSIVE_SET = "citizens.commands.npc.passive.set";
|
||||
public static final String PASSIVE_UNSET = "citizens.commands.npc.passive.unset";
|
||||
public static final String PATHFINDING_OPTIONS_ATTACK_RANGE_SET = "citizens.commands.npc.pathopt.attack-range-set";
|
||||
|
@ -81,6 +81,8 @@ citizens.commands.npc.owner.set=[[{1}]] is now the owner of [[{0}]].
|
||||
citizens.commands.npc.passive.set=[[{0}]] will no longer damage entities.
|
||||
citizens.commands.npc.passive.unset=[[{0}]] will now damage entities.
|
||||
citizens.commands.npc.pathfindingrange.set=Pathfinding range set to [[{0}]].
|
||||
citizens.commands.npc.parrot.invalid-variant=Invalid parrot variant. Valid variants are [[{0}]].
|
||||
citizens.commands.npc.parrot.variant-set=Variant set to [[{0}]].
|
||||
citizens.commands.npc.pathopt.avoid-water-set=[[{0}]] will now avoid water.
|
||||
citizens.commands.npc.pathopt.avoid-water-unset=[[{0}]] will no longer avoid water.
|
||||
citizens.commands.npc.pathopt.stationary-ticks-set=[[{0}]]''s maximum stationary ticks set to [[{1}]].
|
||||
|
@ -320,7 +320,6 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
||||
}
|
||||
|
||||
public void livingEntityBaseTick() {
|
||||
B_();
|
||||
this.aC = this.aD;
|
||||
this.aJ = this.aK;
|
||||
if (this.hurtTicks > 0) {
|
||||
|
@ -3,6 +3,7 @@ package net.citizensnpcs.nms.v1_12_R1.trait;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Llama.Color;
|
||||
import org.bukkit.entity.Parrot.Variant;
|
||||
|
||||
import net.citizensnpcs.api.command.Command;
|
||||
import net.citizensnpcs.api.command.CommandContext;
|
||||
@ -44,4 +45,31 @@ public class Commands {
|
||||
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.getTrait(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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,30 @@
|
||||
package net.citizensnpcs.nms.v1_12_R1.trait;
|
||||
|
||||
import org.bukkit.entity.Parrot;
|
||||
import org.bukkit.entity.Parrot.Variant;
|
||||
|
||||
import net.citizensnpcs.api.persistence.Persist;
|
||||
import net.citizensnpcs.api.trait.Trait;
|
||||
import net.citizensnpcs.api.trait.TraitName;
|
||||
|
||||
@TraitName("parrottrait")
|
||||
public class ParrotTrait extends Trait {
|
||||
@Persist
|
||||
private Variant variant = Variant.BLUE;
|
||||
|
||||
public ParrotTrait() {
|
||||
super("parrottrait");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (npc.isSpawned() && npc.getEntity() instanceof Parrot) {
|
||||
Parrot parrot = (Parrot) npc.getEntity();
|
||||
parrot.setVariant(variant);
|
||||
}
|
||||
}
|
||||
|
||||
public void setVariant(Parrot.Variant variant) {
|
||||
this.variant = variant;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user