mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2025-02-16 12:21:25 +01:00
Add /npc panda -n -r for rolling and sneezing
This commit is contained in:
parent
9bf3194710
commit
e9c989bc55
@ -26,7 +26,11 @@ public class PandaTrait extends Trait {
|
||||
@Persist
|
||||
private Panda.Gene mainGene = Panda.Gene.NORMAL;
|
||||
@Persist
|
||||
private boolean rolling;
|
||||
@Persist
|
||||
private boolean sitting;
|
||||
@Persist
|
||||
private boolean sneezing;
|
||||
|
||||
public PandaTrait() {
|
||||
super("pandatrait");
|
||||
@ -40,16 +44,32 @@ public class PandaTrait extends Trait {
|
||||
return mainGene;
|
||||
}
|
||||
|
||||
public boolean isRolling() {
|
||||
return rolling;
|
||||
}
|
||||
|
||||
public boolean isSitting() {
|
||||
return sitting;
|
||||
}
|
||||
|
||||
public boolean isSneezing() {
|
||||
return sneezing;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (npc.isSpawned() && npc.getEntity() instanceof Panda) {
|
||||
Panda panda = (Panda) npc.getEntity();
|
||||
panda.setMainGene(mainGene);
|
||||
NMS.setPandaSitting(npc.getEntity(), sitting);
|
||||
if (SUPPORT_ROLLING_SNEEZING) {
|
||||
try {
|
||||
panda.setRolling(rolling);
|
||||
panda.setSneezing(sneezing);
|
||||
} catch (Throwable t) {
|
||||
SUPPORT_ROLLING_SNEEZING = false;
|
||||
}
|
||||
}
|
||||
if (hiddenGene != null) {
|
||||
panda.setHiddenGene(hiddenGene);
|
||||
}
|
||||
@ -64,20 +84,36 @@ public class PandaTrait extends Trait {
|
||||
this.mainGene = gene;
|
||||
}
|
||||
|
||||
public void setRolling(boolean rolling) {
|
||||
this.rolling = rolling;
|
||||
}
|
||||
|
||||
public void setSitting(boolean sitting) {
|
||||
this.sitting = sitting;
|
||||
}
|
||||
|
||||
public void setSneezing(boolean sneezing) {
|
||||
this.sneezing = sneezing;
|
||||
}
|
||||
|
||||
public boolean toggleRolling() {
|
||||
return rolling = !rolling;
|
||||
}
|
||||
|
||||
public boolean toggleSitting() {
|
||||
return sitting = !sitting;
|
||||
}
|
||||
|
||||
public boolean toggleSneezing() {
|
||||
return sneezing = !sneezing;
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "npc" },
|
||||
usage = "panda --gene (main gene) --hiddengene (hidden gene) -s(itting)",
|
||||
usage = "panda --gene (main gene) --hiddengene (hidden gene) -s(itting) -n -r(olling)",
|
||||
desc = "Sets panda modifiers",
|
||||
modifiers = { "panda" },
|
||||
flags = "s",
|
||||
flags = "srn",
|
||||
min = 1,
|
||||
max = 1,
|
||||
permission = "citizens.npc.panda")
|
||||
@ -106,6 +142,14 @@ public class PandaTrait extends Trait {
|
||||
boolean isSitting = trait.toggleSitting();
|
||||
output += ' ' + Messaging.tr(isSitting ? Messages.PANDA_SITTING : Messages.PANDA_STOPPED_SITTING);
|
||||
}
|
||||
if (args.hasFlag('r')) {
|
||||
boolean isRolling = trait.toggleRolling();
|
||||
output += ' ' + Messaging.tr(isRolling ? Messages.PANDA_ROLLING : Messages.PANDA_STOPPED_ROLLING);
|
||||
}
|
||||
if (args.hasFlag('n')) {
|
||||
boolean isSneezing = trait.toggleSneezing();
|
||||
output += ' ' + Messaging.tr(isSneezing ? Messages.PANDA_SNEEZING : Messages.PANDA_STOPPED_SNEEZING);
|
||||
}
|
||||
if (!output.isEmpty()) {
|
||||
Messaging.send(sender, output.trim());
|
||||
} else {
|
||||
@ -113,4 +157,6 @@ public class PandaTrait extends Trait {
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean SUPPORT_ROLLING_SNEEZING = true;
|
||||
|
||||
}
|
||||
|
@ -286,8 +286,12 @@ public class Messages {
|
||||
public static final String OWNER_SET_SERVER = "citizens.commands.npc.owner.set-server";
|
||||
public static final String PANDA_HIDDEN_GENE_SET = "citizens.commands.npc.panda.hidden-gene-set";
|
||||
public static final String PANDA_MAIN_GENE_SET = "citizens.commands.npc.panda.main-gene-set";
|
||||
public static final String PANDA_ROLLING = "citizens.commands.npc.panda.rolling";
|
||||
public static final String PANDA_SITTING = "citizens.commands.npc.panda.sitting";
|
||||
public static final String PANDA_SNEEZING = "citizens.commands.npc.panda.sneezing";
|
||||
public static final String PANDA_STOPPED_ROLLING = "citizens.commands.npc.panda.rolling-stopped";
|
||||
public static final String PANDA_STOPPED_SITTING = "citizens.commands.npc.panda.stopped-sitting";
|
||||
public static final String PANDA_STOPPED_SNEEZING = "citizens.commands.npc.panda.sneezing-stopped";
|
||||
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";
|
||||
|
@ -190,6 +190,10 @@ citizens.commands.npc.owner.owner=[[{0}]]''s owner is [[{1}]].
|
||||
citizens.commands.npc.owner.set-server=[[The server]] is now the owner of [[{0}]].
|
||||
citizens.commands.npc.owner.set=[[{1}]] is now the owner of [[{0}]].
|
||||
citizens.commands.npc.panda.invalid-gene=Invalid gene. Valid genes are [[{0}]].
|
||||
citizens.commands.npc.panda.sneezing=Started sneezing.
|
||||
citizens.commands.npc.panda.sneezing-stopped=Stopped sneezing.
|
||||
citizens.commands.npc.panda.rolling=Started rolling.
|
||||
citizens.commands.npc.panda.rolling-stopped=Stopped rolling.
|
||||
citizens.commands.npc.panda.sitting=Started sitting.
|
||||
citizens.commands.npc.panda.stopped-sitting=Stopped sitting.
|
||||
citizens.commands.npc.panda.main-gene-set=Main gene set to [[{0}]].
|
||||
|
Loading…
Reference in New Issue
Block a user