Change sounds to store a string instead, added horse types sounds. Added sound strength for hurt/death
This commit is contained in:
parent
67e9aec7d1
commit
3e0b557d14
@ -5,6 +5,7 @@ import java.util.HashSet;
|
|||||||
|
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.craftbukkit.v1_6_R2.CraftSound;
|
import org.bukkit.craftbukkit.v1_6_R2.CraftSound;
|
||||||
|
import org.bukkit.entity.EntityType;
|
||||||
|
|
||||||
public enum DisguiseSound {
|
public enum DisguiseSound {
|
||||||
|
|
||||||
@ -20,7 +21,7 @@ public enum DisguiseSound {
|
|||||||
|
|
||||||
CREEPER(Sound.CREEPER_HISS, Sound.STEP_GRASS, Sound.CREEPER_DEATH, null),
|
CREEPER(Sound.CREEPER_HISS, Sound.STEP_GRASS, Sound.CREEPER_DEATH, null),
|
||||||
|
|
||||||
DONKEY(null, null, null, null), // TODO Add sounds when donkey sounds are added
|
DONKEY("mob.horse.donkey.hit", Sound.STEP_GRASS, "mob.horse.donkey.death", "mob.horse.donkey.idle"),
|
||||||
|
|
||||||
ENDER_DRAGON(Sound.ENDERDRAGON_HIT, null, Sound.ENDERDRAGON_DEATH, Sound.ENDERDRAGON_GROWL, Sound.ENDERDRAGON_WINGS),
|
ENDER_DRAGON(Sound.ENDERDRAGON_HIT, null, Sound.ENDERDRAGON_DEATH, Sound.ENDERDRAGON_GROWL, Sound.ENDERDRAGON_WINGS),
|
||||||
|
|
||||||
@ -32,13 +33,13 @@ public enum DisguiseSound {
|
|||||||
|
|
||||||
GIANT(Sound.HURT_FLESH, Sound.STEP_GRASS, null, null),
|
GIANT(Sound.HURT_FLESH, Sound.STEP_GRASS, null, null),
|
||||||
|
|
||||||
HORSE(null, null, null, null), // TODO Add sounds when horse sounds are added
|
HORSE("mob.horse.hit", Sound.STEP_GRASS, "mob.horse.death", "mob.horse.idle"),
|
||||||
|
|
||||||
IRON_GOLEM(Sound.IRONGOLEM_HIT, Sound.IRONGOLEM_WALK, Sound.IRONGOLEM_DEATH, Sound.IRONGOLEM_THROW),
|
IRON_GOLEM(Sound.IRONGOLEM_HIT, Sound.IRONGOLEM_WALK, Sound.IRONGOLEM_DEATH, Sound.IRONGOLEM_THROW),
|
||||||
|
|
||||||
MAGMA_CUBE(Sound.SLIME_ATTACK, Sound.SLIME_WALK2, null, null, Sound.SLIME_WALK),
|
MAGMA_CUBE(Sound.SLIME_ATTACK, Sound.SLIME_WALK2, null, null, Sound.SLIME_WALK),
|
||||||
|
|
||||||
MULE(null, null, null, null), // TODO Add sounds when mule sounds are added
|
MULE("mob.horse.donkey.hit", Sound.STEP_GRASS, "mob.horse.donkey.death", "mob.horse.donkey.idle"),
|
||||||
|
|
||||||
MUSHROOM_COW(Sound.COW_HURT, Sound.COW_WALK, Sound.COW_HURT, Sound.COW_IDLE),
|
MUSHROOM_COW(Sound.COW_HURT, Sound.COW_WALK, Sound.COW_HURT, Sound.COW_IDLE),
|
||||||
|
|
||||||
@ -56,12 +57,22 @@ public enum DisguiseSound {
|
|||||||
|
|
||||||
SKELETON(Sound.SKELETON_HURT, Sound.SKELETON_WALK, Sound.SKELETON_DEATH, Sound.SKELETON_IDLE),
|
SKELETON(Sound.SKELETON_HURT, Sound.SKELETON_WALK, Sound.SKELETON_DEATH, Sound.SKELETON_IDLE),
|
||||||
|
|
||||||
SKELETON_HORSE(null, null, null, null), // TODO Add sounds when Skeleton Horse sounds are added
|
SKELETON_HORSE("mob.horse.skeleton.hit", Sound.STEP_GRASS, "mob.horse.skeleton.death", "mob.horse.skeleton.idle"),
|
||||||
|
|
||||||
SLIME(Sound.SLIME_ATTACK, Sound.SLIME_WALK2, null, null, Sound.SLIME_WALK),
|
SLIME(Sound.SLIME_ATTACK, Sound.SLIME_WALK2, null, null, Sound.SLIME_WALK),
|
||||||
|
|
||||||
|
SNOWMAN(null, null, null, null),
|
||||||
|
|
||||||
SPIDER(Sound.SPIDER_IDLE, Sound.SPIDER_WALK, Sound.SPIDER_DEATH, Sound.SPIDER_IDLE),
|
SPIDER(Sound.SPIDER_IDLE, Sound.SPIDER_WALK, Sound.SPIDER_DEATH, Sound.SPIDER_IDLE),
|
||||||
|
|
||||||
|
SQUID(null, null, null, null),
|
||||||
|
|
||||||
|
UNDEAD_HORSE("mob.horse.zombie.hit", Sound.STEP_GRASS, "mob.horse.zombie.death", "mob.horse.zombie.idle"),
|
||||||
|
|
||||||
|
VILLAGER(null, null, null, null),
|
||||||
|
|
||||||
|
WITCH(null, null, null, null),
|
||||||
|
|
||||||
WITHER(Sound.WITHER_HURT, null, Sound.WITHER_DEATH, Sound.WITHER_IDLE, Sound.WITHER_SHOOT, Sound.WITHER_SPAWN),
|
WITHER(Sound.WITHER_HURT, null, Sound.WITHER_DEATH, Sound.WITHER_IDLE, Sound.WITHER_SHOOT, Sound.WITHER_SPAWN),
|
||||||
|
|
||||||
WITHER_SKELETON(Sound.SKELETON_HURT, Sound.SKELETON_WALK, Sound.SKELETON_DEATH, Sound.SKELETON_IDLE),
|
WITHER_SKELETON(Sound.SKELETON_HURT, Sound.SKELETON_WALK, Sound.SKELETON_DEATH, Sound.SKELETON_IDLE),
|
||||||
@ -70,9 +81,7 @@ public enum DisguiseSound {
|
|||||||
Sound.WOLF_HOWL, Sound.WOLF_PANT, Sound.WOLF_SHAKE),
|
Sound.WOLF_HOWL, Sound.WOLF_PANT, Sound.WOLF_SHAKE),
|
||||||
|
|
||||||
ZOMBIE(Sound.ZOMBIE_HURT, Sound.STEP_GRASS, Sound.ZOMBIE_DEATH, Sound.ZOMBIE_IDLE, Sound.ZOMBIE_INFECT, Sound.ZOMBIE_METAL,
|
ZOMBIE(Sound.ZOMBIE_HURT, Sound.STEP_GRASS, Sound.ZOMBIE_DEATH, Sound.ZOMBIE_IDLE, Sound.ZOMBIE_INFECT, Sound.ZOMBIE_METAL,
|
||||||
Sound.ZOMBIE_WOODBREAK, Sound.ZOMBIE_WOOD),
|
Sound.ZOMBIE_WOODBREAK, Sound.ZOMBIE_WOOD);
|
||||||
|
|
||||||
ZOMBIE_HORSE(null, null, null, null); // TODO Add sounds when zombie horse sounds are added
|
|
||||||
|
|
||||||
public enum SoundType {
|
public enum SoundType {
|
||||||
CANCEL, DEATH, HURT, IDLE, STEP;
|
CANCEL, DEATH, HURT, IDLE, STEP;
|
||||||
@ -90,33 +99,57 @@ public enum DisguiseSound {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private HashSet<Sound> cancelSounds = new HashSet<Sound>();
|
private HashSet<String> cancelSounds = new HashSet<String>();
|
||||||
|
private HashMap<SoundType, String> disguiseSounds = new HashMap<SoundType, String>();
|
||||||
|
private float damageSoundVolume = 1F;
|
||||||
|
|
||||||
private HashMap<SoundType, Sound> disguiseSounds = new HashMap<SoundType, Sound>();
|
DisguiseSound(Object... sounds) {
|
||||||
|
|
||||||
DisguiseSound(Sound... sounds) {
|
|
||||||
for (int i = 0; i < sounds.length; i++) {
|
for (int i = 0; i < sounds.length; i++) {
|
||||||
Sound s = sounds[i];
|
Object obj = sounds[i];
|
||||||
if (i == 0)
|
String s;
|
||||||
disguiseSounds.put(SoundType.HURT, s);
|
if (obj == null)
|
||||||
else if (i == 1)
|
continue;
|
||||||
disguiseSounds.put(SoundType.STEP, s);
|
else if (obj instanceof String)
|
||||||
else if (i == 2)
|
s = (String) obj;
|
||||||
disguiseSounds.put(SoundType.DEATH, s);
|
else if (obj instanceof Sound)
|
||||||
else if (i == 3)
|
s = CraftSound.getSound((Sound) obj);
|
||||||
disguiseSounds.put(SoundType.IDLE, s);
|
|
||||||
else
|
else
|
||||||
|
throw new RuntimeException("Was given a unknown object " + obj);
|
||||||
|
switch (i) {
|
||||||
|
case 0:
|
||||||
|
disguiseSounds.put(SoundType.HURT, s);
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
disguiseSounds.put(SoundType.STEP, s);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
disguiseSounds.put(SoundType.DEATH, s);
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
disguiseSounds.put(SoundType.IDLE, s);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
cancelSounds.add(s);
|
cancelSounds.add(s);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Sound getSound(SoundType type) {
|
public void setDamageSoundVolume(float strength) {
|
||||||
if (type == null)
|
this.damageSoundVolume = strength;
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getDamageSoundVolume() {
|
||||||
|
return damageSoundVolume;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSound(SoundType type) {
|
||||||
|
if (type == null || !disguiseSounds.containsKey(type))
|
||||||
return null;
|
return null;
|
||||||
return disguiseSounds.get(type);
|
return disguiseSounds.get(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
public HashSet<Sound> getSoundsToCancel() {
|
public HashSet<String> getSoundsToCancel() {
|
||||||
return cancelSounds;
|
return cancelSounds;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -126,15 +159,14 @@ public enum DisguiseSound {
|
|||||||
public SoundType getType(String name, boolean ignoreDamage) {
|
public SoundType getType(String name, boolean ignoreDamage) {
|
||||||
if (isCancelSound(name))
|
if (isCancelSound(name))
|
||||||
return SoundType.CANCEL;
|
return SoundType.CANCEL;
|
||||||
if (disguiseSounds.get(SoundType.STEP) == Sound.STEP_GRASS && name.startsWith("step."))
|
if (disguiseSounds.get(SoundType.STEP).startsWith("step.") && name.startsWith("step."))
|
||||||
return SoundType.STEP;
|
return SoundType.STEP;
|
||||||
for (SoundType type : SoundType.values()) {
|
for (SoundType type : SoundType.values()) {
|
||||||
if (!disguiseSounds.containsKey(type) || type == SoundType.DEATH || (ignoreDamage && type == SoundType.HURT))
|
if (!disguiseSounds.containsKey(type) || type == SoundType.DEATH || (ignoreDamage && type == SoundType.HURT))
|
||||||
continue;
|
continue;
|
||||||
Sound s = disguiseSounds.get(type);
|
String s = disguiseSounds.get(type);
|
||||||
if (s != null) {
|
if (s != null) {
|
||||||
String soundName = CraftSound.getSound(s);
|
if (s.equals(name))
|
||||||
if (soundName.equals(name))
|
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -146,9 +178,6 @@ public enum DisguiseSound {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isCancelSound(String sound) {
|
public boolean isCancelSound(String sound) {
|
||||||
for (Sound s : cancelSounds)
|
return getSoundsToCancel().contains(sound);
|
||||||
if (getSoundName(s).equals(sound))
|
|
||||||
return true;
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user