Skip to content

Commit

Permalink
Add /npc sound
Browse files Browse the repository at this point in the history
  • Loading branch information
fullwall committed Jan 29, 2014
1 parent 9bae59a commit 04f6658
Show file tree
Hide file tree
Showing 30 changed files with 482 additions and 4 deletions.
50 changes: 47 additions & 3 deletions src/main/java/net/citizensnpcs/commands/NPCCommands.java
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ public void copy(CommandContext args, CommandSender sender, NPC npc) throws Comm
}

CommandSenderCreateNPCEvent event = sender instanceof Player ? new PlayerCreateNPCEvent((Player) sender, copy)
: new CommandSenderCreateNPCEvent(sender, copy);
: new CommandSenderCreateNPCEvent(sender, copy);
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) {
event.getNPC().destroy();
Expand Down Expand Up @@ -337,7 +337,7 @@ public void create(CommandContext args, CommandSender sender, NPC npc) throws Co
spawnLoc = args.getSenderLocation();
}
CommandSenderCreateNPCEvent event = sender instanceof Player ? new PlayerCreateNPCEvent((Player) sender, npc)
: new CommandSenderCreateNPCEvent(sender, npc);
: new CommandSenderCreateNPCEvent(sender, npc);
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) {
npc.destroy();
Expand Down Expand Up @@ -969,7 +969,7 @@ public void pose(CommandContext args, CommandSender sender, NPC npc) throws Comm
@Requirements(selected = true, ownership = true, types = { EntityType.CREEPER })
public void power(CommandContext args, CommandSender sender, NPC npc) {
Messaging
.sendTr(sender, npc.getTrait(Powered.class).toggle() ? Messages.POWERED_SET : Messages.POWERED_STOPPED);
.sendTr(sender, npc.getTrait(Powered.class).toggle() ? Messages.POWERED_SET : Messages.POWERED_STOPPED);
}

@Command(
Expand Down Expand Up @@ -1139,6 +1139,50 @@ public void slimeSize(CommandContext args, CommandSender sender, NPC npc) {
Messaging.sendTr(sender, Messages.SIZE_SET, npc.getName(), size);
}

@Command(
aliases = { "npc" },
usage = "sound (--death [death sound|d]) (--ambient [ambient sound|d]) (--hurt [hurt sound|d]) (-n(one)) (-d(efault))",
desc = "Sets an NPC's played sounds",
modifiers = { "sound" },
flags = "dn",
min = 1,
max = 1,
permission = "citizens.npc.sound")
@Requirements(selected = true, ownership = true, livingEntity = true, excludedTypes = { EntityType.PLAYER })
public void sound(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
String ambientSound = npc.data().get(NPC.AMBIENT_SOUND_METADATA);
String deathSound = npc.data().get(NPC.DEATH_SOUND_METADATA);
String hurtSound = npc.data().get(NPC.HURT_SOUND_METADATA);
if (args.hasFlag('n')) {
ambientSound = deathSound = hurtSound = "";
}
if (args.hasFlag('d')) {
ambientSound = deathSound = hurtSound = null;
} else {
if (args.hasValueFlag("death")) {
deathSound = args.getFlag("death");
if (deathSound.equals("d")) {
deathSound = null;
}
}
if (args.hasValueFlag("ambient")) {
ambientSound = args.getFlag("ambient");
if (ambientSound.equals("d")) {
ambientSound = null;
}
}
if (args.hasValueFlag("hurt")) {
hurtSound = args.getFlag("hurt");
if (hurtSound.equals("d")) {
hurtSound = null;
}
}
}
npc.data().setPersistent(NPC.DEATH_SOUND_METADATA, deathSound);
npc.data().setPersistent(NPC.HURT_SOUND_METADATA, hurtSound);
npc.data().setPersistent(NPC.AMBIENT_SOUND_METADATA, ambientSound);
}

@Command(
aliases = { "npc" },
usage = "spawn (id|name)",
Expand Down
15 changes: 15 additions & 0 deletions src/main/java/net/citizensnpcs/npc/entity/BatController.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,16 @@ public EntityBatNPC(World world, NPC npc) {
}
}

@Override
protected String aT() {
return npc == null ? super.aT() : npc.data().get(NPC.HURT_SOUND_METADATA, super.aT());
}

@Override
protected String aU() {
return npc == null ? super.aT() : npc.data().get(NPC.DEATH_SOUND_METADATA, super.aU());
}

@Override
public boolean bL() {
if (npc == null) {
Expand Down Expand Up @@ -140,5 +150,10 @@ protected boolean isTypeNotPersistent() {
public void setFlying(boolean flying) {
a(flying);
}

@Override
protected String t() {
return npc == null ? super.aT() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
}
}
}
15 changes: 15 additions & 0 deletions src/main/java/net/citizensnpcs/npc/entity/BlazeController.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,16 @@ public EntityBlazeNPC(World world, NPC npc) {
}
}

@Override
protected String aT() {
return npc == null ? super.aT() : npc.data().get(NPC.HURT_SOUND_METADATA, super.aT());
}

@Override
protected String aU() {
return npc == null ? super.aT() : npc.data().get(NPC.DEATH_SOUND_METADATA, super.aU());
}

@Override
public boolean bL() {
if (npc == null)
Expand Down Expand Up @@ -127,5 +137,10 @@ public NPC getNPC() {
protected boolean isTypeNotPersistent() {
return npc == null ? super.isTypeNotPersistent() : false;
}

@Override
protected String t() {
return npc == null ? super.aT() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ public EntityCaveSpiderNPC(World world, NPC npc) {
this.npc = (CitizensNPC) npc;
if (npc != null) {
NMS.clearGoals(goalSelector, targetSelector);

}
}

Expand All @@ -64,6 +63,16 @@ protected void a(double d0, boolean flag) {
}
}

@Override
protected String aT() {
return npc == null ? super.aT() : npc.data().get(NPC.HURT_SOUND_METADATA, super.aT());
}

@Override
protected String aU() {
return npc == null ? super.aT() : npc.data().get(NPC.DEATH_SOUND_METADATA, super.aU());
}

@Override
protected void b(float f) {
if (npc == null || !npc.isFlyable()) {
Expand Down Expand Up @@ -170,5 +179,10 @@ public boolean h_() {
protected boolean isTypeNotPersistent() {
return npc == null ? super.isTypeNotPersistent() : false;
}

@Override
protected String t() {
return npc == null ? super.aT() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
}
}
}
15 changes: 15 additions & 0 deletions src/main/java/net/citizensnpcs/npc/entity/ChickenController.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,16 @@ protected void a(double d0, boolean flag) {
}
}

@Override
protected String aT() {
return npc == null ? super.aT() : npc.data().get(NPC.HURT_SOUND_METADATA, super.aT());
}

@Override
protected String aU() {
return npc == null ? super.aT() : npc.data().get(NPC.DEATH_SOUND_METADATA, super.aU());
}

@Override
protected void b(float f) {
if (npc == null || !npc.isFlyable()) {
Expand Down Expand Up @@ -155,5 +165,10 @@ public boolean h_() {
protected boolean isTypeNotPersistent() {
return npc == null ? super.isTypeNotPersistent() : false;
}

@Override
protected String t() {
return npc == null ? super.aT() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
}
}
}
15 changes: 15 additions & 0 deletions src/main/java/net/citizensnpcs/npc/entity/CowController.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,16 @@ protected void a(double d0, boolean flag) {
}
}

@Override
protected String aT() {
return npc == null ? super.aT() : npc.data().get(NPC.HURT_SOUND_METADATA, super.aT());
}

@Override
protected String aU() {
return npc == null ? super.aT() : npc.data().get(NPC.DEATH_SOUND_METADATA, super.aU());
}

@Override
protected void b(float f) {
if (npc == null || !npc.isFlyable()) {
Expand Down Expand Up @@ -158,5 +168,10 @@ public boolean h_() {
protected boolean isTypeNotPersistent() {
return npc == null ? super.isTypeNotPersistent() : false;
}

@Override
protected String t() {
return npc == null ? super.aT() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
}
}
}
15 changes: 15 additions & 0 deletions src/main/java/net/citizensnpcs/npc/entity/CreeperController.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,16 @@ public void a(EntityLightning entitylightning) {
super.a(entitylightning);
}

@Override
protected String aT() {
return npc == null ? super.aT() : npc.data().get(NPC.HURT_SOUND_METADATA, super.aT());
}

@Override
protected String aU() {
return npc == null ? super.aT() : npc.data().get(NPC.DEATH_SOUND_METADATA, super.aU());
}

@Override
protected void b(float f) {
if (npc == null || !npc.isFlyable()) {
Expand Down Expand Up @@ -168,5 +178,10 @@ protected boolean isTypeNotPersistent() {
public void setAllowPowered(boolean allowPowered) {
this.allowPowered = allowPowered;
}

@Override
protected String t() {
return npc == null ? super.aT() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,16 @@ public EntityEnderDragonNPC(World world, NPC npc) {
}
}

@Override
protected String aT() {
return npc == null ? super.aT() : npc.data().get(NPC.HURT_SOUND_METADATA, super.aT());
}

@Override
protected String aU() {
return npc == null ? super.aT() : npc.data().get(NPC.DEATH_SOUND_METADATA, super.aU());
}

@Override
public boolean bL() {
if (npc == null)
Expand Down Expand Up @@ -148,5 +158,10 @@ public NPC getNPC() {
protected boolean isTypeNotPersistent() {
return npc == null ? super.isTypeNotPersistent() : false;
}

@Override
protected String t() {
return npc == null ? super.aT() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
}
}
}
15 changes: 15 additions & 0 deletions src/main/java/net/citizensnpcs/npc/entity/EndermanController.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,16 @@ protected void a(double d0, boolean flag) {
}
}

@Override
protected String aT() {
return npc == null ? super.aT() : npc.data().get(NPC.HURT_SOUND_METADATA, super.aT());
}

@Override
protected String aU() {
return npc == null ? super.aT() : npc.data().get(NPC.DEATH_SOUND_METADATA, super.aU());
}

@Override
protected void b(float f) {
if (npc == null || !npc.isFlyable()) {
Expand Down Expand Up @@ -185,6 +195,11 @@ protected boolean k(double d1, double d2, double d3) {
return false;
}

@Override
protected String t() {
return npc == null ? super.aT() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
}

private void updateAIWithMovement() {
NMS.updateAI(this);
// taken from EntityLiving update method
Expand Down
15 changes: 15 additions & 0 deletions src/main/java/net/citizensnpcs/npc/entity/GhastController.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,16 @@ public EntityGhastNPC(World world, NPC npc) {
}
}

@Override
protected String aT() {
return npc == null ? super.aT() : npc.data().get(NPC.HURT_SOUND_METADATA, super.aT());
}

@Override
protected String aU() {
return npc == null ? super.aT() : npc.data().get(NPC.DEATH_SOUND_METADATA, super.aU());
}

@Override
public boolean bL() {
if (npc == null)
Expand Down Expand Up @@ -110,6 +120,11 @@ public NPC getNPC() {
protected boolean isTypeNotPersistent() {
return npc == null ? super.isTypeNotPersistent() : false;
}

@Override
protected String t() {
return npc == null ? super.aT() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
}
}

public static class GhastNPC extends CraftGhast implements NPCHolder {
Expand Down
15 changes: 15 additions & 0 deletions src/main/java/net/citizensnpcs/npc/entity/GiantController.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,16 @@ protected void a(double d0, boolean flag) {
}
}

@Override
protected String aT() {
return npc == null ? super.aT() : npc.data().get(NPC.HURT_SOUND_METADATA, super.aT());
}

@Override
protected String aU() {
return npc == null ? super.aT() : npc.data().get(NPC.DEATH_SOUND_METADATA, super.aU());
}

@Override
protected void b(float f) {
if (npc == null || !npc.isFlyable()) {
Expand Down Expand Up @@ -144,6 +154,11 @@ public boolean h_() {
protected boolean isTypeNotPersistent() {
return npc == null ? super.isTypeNotPersistent() : false;
}

@Override
protected String t() {
return npc == null ? super.aT() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
}
}

public static class GiantNPC extends CraftGiant implements NPCHolder {
Expand Down
Loading

0 comments on commit 04f6658

Please sign in to comment.