Add /npc snowman -f to form snow
This commit is contained in:
parent
e4fba63408
commit
c81aa299fb
|
@ -112,6 +112,7 @@ import net.citizensnpcs.trait.Controllable;
|
||||||
import net.citizensnpcs.trait.CurrentLocation;
|
import net.citizensnpcs.trait.CurrentLocation;
|
||||||
import net.citizensnpcs.trait.HologramTrait;
|
import net.citizensnpcs.trait.HologramTrait;
|
||||||
import net.citizensnpcs.trait.ShopTrait;
|
import net.citizensnpcs.trait.ShopTrait;
|
||||||
|
import net.citizensnpcs.trait.versioned.SnowmanTrait;
|
||||||
import net.citizensnpcs.util.ChunkCoord;
|
import net.citizensnpcs.util.ChunkCoord;
|
||||||
import net.citizensnpcs.util.Messages;
|
import net.citizensnpcs.util.Messages;
|
||||||
import net.citizensnpcs.util.NMS;
|
import net.citizensnpcs.util.NMS;
|
||||||
|
@ -250,7 +251,10 @@ public class EventListen implements Listener {
|
||||||
if (npc == null)
|
if (npc == null)
|
||||||
return;
|
return;
|
||||||
if (npc.getEntity() instanceof Snowman) {
|
if (npc.getEntity() instanceof Snowman) {
|
||||||
event.setCancelled(true);
|
boolean formSnow = npc.hasTrait(SnowmanTrait.class)
|
||||||
|
? npc.getTraitNullable(SnowmanTrait.class).shouldFormSnow()
|
||||||
|
: npc.useMinecraftAI();
|
||||||
|
event.setCancelled(!formSnow);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,8 @@ import net.citizensnpcs.util.Messages;
|
||||||
public class SnowmanTrait extends Trait {
|
public class SnowmanTrait extends Trait {
|
||||||
@Persist("derp")
|
@Persist("derp")
|
||||||
private boolean derp;
|
private boolean derp;
|
||||||
|
@Persist
|
||||||
|
private boolean formSnow;
|
||||||
|
|
||||||
public SnowmanTrait() {
|
public SnowmanTrait() {
|
||||||
super("snowmantrait");
|
super("snowmantrait");
|
||||||
|
@ -40,18 +42,26 @@ public class SnowmanTrait extends Trait {
|
||||||
this.derp = derp;
|
this.derp = derp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setFormSnow(boolean snow) {
|
||||||
|
formSnow = snow;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean shouldFormSnow() {
|
||||||
|
return formSnow;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean toggleDerp() {
|
public boolean toggleDerp() {
|
||||||
return derp = !derp;
|
return derp = !derp;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = { "npc" },
|
aliases = { "npc" },
|
||||||
usage = "snowman (-d[erp])",
|
usage = "snowman (-d[erp]) (-f[orm snow])",
|
||||||
desc = "Sets snowman modifiers.",
|
desc = "Sets snowman modifiers.",
|
||||||
modifiers = { "snowman" },
|
modifiers = { "snowman" },
|
||||||
min = 1,
|
min = 1,
|
||||||
max = 1,
|
max = 1,
|
||||||
flags = "d",
|
flags = "df",
|
||||||
permission = "citizens.npc.snowman")
|
permission = "citizens.npc.snowman")
|
||||||
@Requirements(selected = true, ownership = true, types = { EntityType.SNOWMAN })
|
@Requirements(selected = true, ownership = true, types = { EntityType.SNOWMAN })
|
||||||
public static void snowman(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public static void snowman(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
|
@ -62,6 +72,13 @@ public class SnowmanTrait extends Trait {
|
||||||
Messaging.sendTr(sender, isDerp ? Messages.SNOWMAN_DERP_SET : Messages.SNOWMAN_DERP_STOPPED, npc.getName());
|
Messaging.sendTr(sender, isDerp ? Messages.SNOWMAN_DERP_SET : Messages.SNOWMAN_DERP_STOPPED, npc.getName());
|
||||||
hasArg = true;
|
hasArg = true;
|
||||||
}
|
}
|
||||||
|
if (args.hasFlag('f')) {
|
||||||
|
trait.setFormSnow(!trait.shouldFormSnow());
|
||||||
|
Messaging.sendTr(sender,
|
||||||
|
trait.shouldFormSnow() ? Messages.SNOWMAN_FORM_SNOW_SET : Messages.SNOWMAN_FORM_SNOW_STOPPED,
|
||||||
|
npc.getName());
|
||||||
|
hasArg = true;
|
||||||
|
}
|
||||||
if (!hasArg)
|
if (!hasArg)
|
||||||
throw new CommandUsageException();
|
throw new CommandUsageException();
|
||||||
}
|
}
|
||||||
|
|
|
@ -296,6 +296,8 @@
|
||||||
"citizens.commands.npc.sniffer.state-set" : "[[{0}]]''s state set to [[{1}]].",
|
"citizens.commands.npc.sniffer.state-set" : "[[{0}]]''s state set to [[{1}]].",
|
||||||
"citizens.commands.npc.snowman.derp-set" : "[[{0}]] is now in derp mode.",
|
"citizens.commands.npc.snowman.derp-set" : "[[{0}]] is now in derp mode.",
|
||||||
"citizens.commands.npc.snowman.derp-stopped" : "[[{0}]] is no longer in derp mode.",
|
"citizens.commands.npc.snowman.derp-stopped" : "[[{0}]] is no longer in derp mode.",
|
||||||
|
"citizens.commands.npc.snowman.form-snow-set": "[[{0}]] will now form snow when walking.",
|
||||||
|
"citizens.commands.npc.snowman.form-snow-stopped": "[[{0}]] will no longer form snow when walking.",
|
||||||
"citizens.commands.npc.sound.info" : "[[{0}]]''s sounds are: ambient - [[{1}]] hurt - [[{2}]] and death - [[{3}]].<br><br>Valid sounds are {4}.",
|
"citizens.commands.npc.sound.info" : "[[{0}]]''s sounds are: ambient - [[{1}]] hurt - [[{2}]] and death - [[{3}]].<br><br>Valid sounds are {4}.",
|
||||||
"citizens.commands.npc.sound.invalid-sound" : "Invalid sound.",
|
"citizens.commands.npc.sound.invalid-sound" : "Invalid sound.",
|
||||||
"citizens.commands.npc.sound.set" : "[[{0}]]''s sounds are now: ambient - [[{1}]] hurt - [[{2}]] and death - [[{3}]].",
|
"citizens.commands.npc.sound.set" : "[[{0}]]''s sounds are now: ambient - [[{1}]] hurt - [[{2}]] and death - [[{3}]].",
|
||||||
|
|
Loading…
Reference in New Issue