Skip to content

Commit

Permalink
Fix some bugs with sounds
Browse files Browse the repository at this point in the history
  • Loading branch information
fullwall committed May 22, 2014
1 parent 254e1e1 commit 80622f6
Show file tree
Hide file tree
Showing 30 changed files with 47 additions and 34 deletions.
18 changes: 15 additions & 3 deletions src/main/java/net/citizensnpcs/commands/NPCCommands.java
Expand Up @@ -1252,9 +1252,21 @@ public void sound(CommandContext args, CommandSender sender, NPC npc) throws Com
hurtSound = args.getFlag("hurt").equals("d") ? null : NMS.getSound(args.getFlag("hurt"));
}
}
npc.data().setPersistent(NPC.DEATH_SOUND_METADATA, deathSound);
npc.data().setPersistent(NPC.HURT_SOUND_METADATA, hurtSound);
npc.data().setPersistent(NPC.AMBIENT_SOUND_METADATA, ambientSound);
if (deathSound == null) {
npc.data().remove(NPC.DEATH_SOUND_METADATA);
} else {
npc.data().setPersistent(NPC.DEATH_SOUND_METADATA, deathSound);
}
if (hurtSound == null) {
npc.data().remove(NPC.HURT_SOUND_METADATA);
} else {
npc.data().setPersistent(NPC.HURT_SOUND_METADATA, hurtSound);
}
if (ambientSound == null) {
npc.data().remove(ambientSound);
} else {
npc.data().setPersistent(NPC.AMBIENT_SOUND_METADATA, ambientSound);
}

Messaging.sendTr(sender, Messages.SOUND_SET, npc.getName(), ambientSound, hurtSound, deathSound);
}
Expand Down
7 changes: 4 additions & 3 deletions src/main/java/net/citizensnpcs/npc/entity/BatController.java
Expand Up @@ -59,12 +59,13 @@ public EntityBatNPC(World world, NPC npc) {

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

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

@Override
Expand Down Expand Up @@ -148,7 +149,7 @@ public void setFlying(boolean flying) {

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

@Override
Expand Down
Expand Up @@ -135,7 +135,7 @@ public NPC getNPC() {

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

@Override
Expand Down
Expand Up @@ -177,7 +177,7 @@ public boolean h_() {

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

@Override
Expand Down
Expand Up @@ -174,7 +174,7 @@ public boolean h_() {

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

@Override
Expand Down
Expand Up @@ -177,7 +177,7 @@ public boolean h_() {

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

@Override
Expand Down
Expand Up @@ -176,7 +176,7 @@ public void setAllowPowered(boolean allowPowered) {

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

@Override
Expand Down
Expand Up @@ -156,7 +156,7 @@ public NPC getNPC() {

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

@Override
Expand Down
Expand Up @@ -192,7 +192,7 @@ protected boolean k(double d1, double d2, double d3) {

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

private void updateAIWithMovement() {
Expand Down
Expand Up @@ -118,7 +118,7 @@ public NPC getNPC() {

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

@Override
Expand Down
Expand Up @@ -152,7 +152,7 @@ public boolean h_() {

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

@Override
Expand Down
Expand Up @@ -175,7 +175,7 @@ public boolean h_() {

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

private void updateAIWithMovement() {
Expand Down
Expand Up @@ -149,7 +149,7 @@ public boolean h_() {

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

@Override
Expand Down
Expand Up @@ -160,7 +160,7 @@ public boolean h_() {

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

@Override
Expand Down
Expand Up @@ -161,7 +161,7 @@ public boolean h_() {

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

@Override
Expand Down
Expand Up @@ -160,7 +160,7 @@ public boolean h_() {

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

@Override
Expand Down
Expand Up @@ -167,7 +167,7 @@ public boolean h_() {

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

@Override
Expand Down
Expand Up @@ -160,7 +160,7 @@ public boolean h_() {

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

@Override
Expand Down
Expand Up @@ -160,7 +160,7 @@ public boolean h_() {

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

@Override
Expand Down
Expand Up @@ -159,7 +159,7 @@ public boolean h_() {

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

@Override
Expand Down
Expand Up @@ -150,7 +150,7 @@ public boolean h_() {

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

@Override
Expand Down
Expand Up @@ -161,7 +161,7 @@ public boolean h_() {

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

@Override
Expand Down
Expand Up @@ -149,7 +149,7 @@ public boolean h_() {

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

@Override
Expand Down
Expand Up @@ -159,7 +159,7 @@ public boolean h_() {

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

@Override
Expand Down
Expand Up @@ -150,7 +150,7 @@ public boolean h_() {

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

@Override
Expand Down
Expand Up @@ -178,7 +178,7 @@ public void setBlockTrades(boolean blocked) {

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

@Override
Expand Down
Expand Up @@ -149,7 +149,7 @@ public boolean h_() {

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

@Override
Expand Down
Expand Up @@ -128,7 +128,7 @@ public NPC getNPC() {

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

private void updateAIWithMovement() {
Expand Down
Expand Up @@ -162,7 +162,7 @@ public boolean h_() {

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

@Override
Expand Down
Expand Up @@ -150,7 +150,7 @@ public boolean h_() {

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

@Override
Expand Down

0 comments on commit 80622f6

Please sign in to comment.