2013-11-22 21:10:20 +01:00
|
|
|
package me.libraryaddict.disguise.utilities;
|
2013-05-29 00:29:36 +02:00
|
|
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.HashSet;
|
|
|
|
|
2014-01-18 20:24:27 +01:00
|
|
|
import me.libraryaddict.disguise.utilities.ReflectionManager.LibVersion;
|
|
|
|
|
2013-05-29 00:29:36 +02:00
|
|
|
import org.bukkit.Sound;
|
|
|
|
|
2013-11-14 21:10:35 +01:00
|
|
|
/**
|
|
|
|
* Only living disguises go in here!
|
|
|
|
*/
|
2013-05-29 00:29:36 +02:00
|
|
|
public enum DisguiseSound {
|
2014-01-04 10:14:57 +01:00
|
|
|
ARROW(null, null, null, null, "random.bowhit"),
|
2013-05-29 00:29:36 +02:00
|
|
|
|
2013-11-22 15:15:26 +01:00
|
|
|
BAT("mob.bat.hurt", null, "mob.bat.death", "mob.bat.idle", "damage.fallsmall", "mob.bat.loop", "damage.fallbig",
|
|
|
|
"mob.bat.takeoff"),
|
2013-05-29 00:29:36 +02:00
|
|
|
|
2013-11-22 15:15:26 +01:00
|
|
|
BLAZE("mob.blaze.hit", null, "mob.blaze.death", "mob.blaze.breathe", "damage.fallsmall", "damage.fallbig"),
|
2013-05-29 00:29:36 +02:00
|
|
|
|
2013-11-22 15:15:26 +01:00
|
|
|
CAVE_SPIDER("mob.spider.say", "mob.spider.step", "mob.spider.death", "mob.spider.say"),
|
2013-05-29 00:29:36 +02:00
|
|
|
|
2013-11-22 15:15:26 +01:00
|
|
|
CHICKEN("mob.chicken.hurt", "mob.chicken.step", "mob.chicken.hurt", "mob.chicken.say", "damage.fallsmall",
|
|
|
|
"mob.chicken.plop", "damage.fallbig"),
|
2013-05-29 00:29:36 +02:00
|
|
|
|
2013-11-22 15:15:26 +01:00
|
|
|
COW("mob.cow.hurt", "mob.cow.step", "mob.cow.hurt", "mob.cow.say"),
|
2013-05-29 00:29:36 +02:00
|
|
|
|
2013-11-22 15:15:26 +01:00
|
|
|
CREEPER("mob.creeper.say", "step.grass", "mob.creeper.death", null),
|
2013-05-29 00:29:36 +02:00
|
|
|
|
2013-11-22 15:19:00 +01:00
|
|
|
DONKEY("mob.horse.donkey.hit", "step.grass", "mob.horse.donkey.death", "mob.horse.donkey.idle", "mob.horse.gallop",
|
|
|
|
"mob.horse.leather", "mob.horse.donkey.angry", "mob.horse.wood", "mob.horse.armor", "mob.horse.soft",
|
|
|
|
"mob.horse.land", "mob.horse.jump", "mob.horse.angry"),
|
2013-07-09 05:03:33 +02:00
|
|
|
|
2014-09-27 02:17:57 +02:00
|
|
|
ELDER_GUARDIAN("mob.guardian.elder.hit", null, "mob.guardian.elder.death", "mob.guardian.elder.death"),
|
|
|
|
|
2013-11-22 15:15:26 +01:00
|
|
|
ENDER_DRAGON("mob.enderdragon.hit", null, "mob.enderdragon.end", "mob.enderdragon.growl", "damage.fallsmall",
|
|
|
|
"mob.enderdragon.wings", "damage.fallbig"),
|
2013-05-29 00:29:36 +02:00
|
|
|
|
2013-11-22 15:15:26 +01:00
|
|
|
ENDERMAN("mob.endermen.hit", "step.grass", "mob.endermen.death", "mob.endermen.idle", "mob.endermen.scream",
|
|
|
|
"mob.endermen.portal", "mob.endermen.stare"),
|
2013-05-29 00:29:36 +02:00
|
|
|
|
2014-09-27 02:17:57 +02:00
|
|
|
ENDERMITE("mob.silverfish.hit", "mob.silverfish.step", "mob.silverfish.kill", "mob.silverfish.say"),
|
|
|
|
|
2013-11-22 15:15:26 +01:00
|
|
|
GHAST("mob.ghast.scream", null, "mob.ghast.death", "mob.ghast.moan", "damage.fallsmall", "mob.ghast.fireball",
|
|
|
|
"damage.fallbig", "mob.ghast.affectionate_scream", "mob.ghast.charge"),
|
2013-05-29 00:29:36 +02:00
|
|
|
|
2013-11-22 15:15:26 +01:00
|
|
|
GIANT("damage.hit", "step.grass", null, null),
|
2013-05-29 00:29:36 +02:00
|
|
|
|
2014-09-27 02:17:57 +02:00
|
|
|
GUARDIAN("mob.guardian.hit", null, "mob.guardian.death", "mob.guardian.death"),
|
|
|
|
|
2013-11-22 15:19:00 +01:00
|
|
|
HORSE("mob.horse.hit", "step.grass", "mob.horse.death", "mob.horse.idle", "mob.horse.gallop", "mob.horse.leather",
|
|
|
|
"mob.horse.wood", "mob.horse.armor", "mob.horse.soft", "mob.horse.land", "mob.horse.jump", "mob.horse.angry",
|
|
|
|
"mob.horse.leather"),
|
2013-07-09 04:51:35 +02:00
|
|
|
|
2013-11-22 15:15:26 +01:00
|
|
|
IRON_GOLEM("mob.irongolem.hit", "mob.irongolem.walk", "mob.irongolem.death", "mob.irongolem.throw"),
|
2013-05-29 00:29:36 +02:00
|
|
|
|
2013-11-22 15:15:26 +01:00
|
|
|
MAGMA_CUBE("mob.slime.attack", "mob.slime.big", null, null, "mob.slime.small"),
|
2013-05-29 00:29:36 +02:00
|
|
|
|
2013-11-22 15:19:00 +01:00
|
|
|
MULE("mob.horse.donkey.hit", "step.grass", "mob.horse.donkey.death", "mob.horse.donkey.idle"),
|
2013-07-09 05:03:33 +02:00
|
|
|
|
2013-11-22 15:15:26 +01:00
|
|
|
MUSHROOM_COW("mob.cow.hurt", "mob.cow.step", "mob.cow.hurt", "mob.cow.say"),
|
2013-05-29 00:29:36 +02:00
|
|
|
|
2013-11-22 15:15:26 +01:00
|
|
|
OCELOT("mob.cat.hitt", "step.grass", "mob.cat.hitt", "mob.cat.meow", "mob.cat.purreow", "mob.cat.purr"),
|
2013-05-29 00:29:36 +02:00
|
|
|
|
2013-11-22 15:15:26 +01:00
|
|
|
PIG("mob.pig.say", "mob.pig.step", "mob.pig.death", "mob.pig.say"),
|
2013-05-29 00:29:36 +02:00
|
|
|
|
2013-11-22 15:15:26 +01:00
|
|
|
PIG_ZOMBIE("mob.zombiepig.zpighurt", null, "mob.zombiepig.zpigdeath", "mob.zombiepig.zpig", "mob.zombiepig.zpigangry"),
|
2013-05-29 00:29:36 +02:00
|
|
|
|
2014-01-18 20:24:27 +01:00
|
|
|
PLAYER(LibVersion.is1_7() ? "game.player.hurt" : "damage.hit", "step.grass", LibVersion.is1_7() ? "game.player.hurt"
|
|
|
|
: "damage.hit", null),
|
2013-05-29 00:29:36 +02:00
|
|
|
|
2014-09-27 02:17:57 +02:00
|
|
|
RABBIT("mob.rabbit.hurt", "mob.rabbit.hop", "mob.rabbit.death", "mob.rabbit.idle"),
|
|
|
|
|
2013-11-22 15:15:26 +01:00
|
|
|
SHEEP("mob.sheep.say", "mob.sheep.step", null, "mob.sheep.say", "mob.sheep.shear"),
|
2013-05-29 00:29:36 +02:00
|
|
|
|
2013-11-22 15:15:26 +01:00
|
|
|
SILVERFISH("mob.silverfish.hit", "mob.silverfish.step", "mob.silverfish.kill", "mob.silverfish.say"),
|
2013-05-29 00:29:36 +02:00
|
|
|
|
2013-11-22 15:15:26 +01:00
|
|
|
SKELETON("mob.skeleton.hurt", "mob.skeleton.step", "mob.skeleton.death", "mob.skeleton.say"),
|
2013-05-29 00:29:36 +02:00
|
|
|
|
2013-11-22 15:19:00 +01:00
|
|
|
SKELETON_HORSE("mob.horse.skeleton.hit", "step.grass", "mob.horse.skeleton.death", "mob.horse.skeleton.idle",
|
|
|
|
"mob.horse.gallop", "mob.horse.leather", "mob.horse.wood", "mob.horse.armor", "mob.horse.soft", "mob.horse.land",
|
|
|
|
"mob.horse.jump", "mob.horse.angry"),
|
2013-07-09 05:03:33 +02:00
|
|
|
|
2013-11-22 15:15:26 +01:00
|
|
|
SLIME("mob.slime.attack", "mob.slime.big", null, null, "mob.slime.small"),
|
2013-05-29 00:29:36 +02:00
|
|
|
|
2013-07-29 04:53:32 +02:00
|
|
|
SNOWMAN(),
|
2013-07-22 15:31:11 +02:00
|
|
|
|
2013-11-22 15:15:26 +01:00
|
|
|
SPIDER("mob.spider.say", "mob.spider.step", "mob.spider.death", "mob.spider.say"),
|
2013-05-29 00:29:36 +02:00
|
|
|
|
2013-07-29 04:53:32 +02:00
|
|
|
SQUID(),
|
2013-07-22 15:31:11 +02:00
|
|
|
|
2013-11-22 15:19:00 +01:00
|
|
|
UNDEAD_HORSE("mob.horse.zombie.hit", "step.grass", "mob.horse.zombie.death", "mob.horse.zombie.idle", "mob.horse.gallop",
|
|
|
|
"mob.horse.leather", "mob.horse.wood", "mob.horse.armor", "mob.horse.soft", "mob.horse.land", "mob.horse.jump",
|
|
|
|
"mob.horse.angry"),
|
2013-07-22 15:31:11 +02:00
|
|
|
|
2013-11-22 15:15:26 +01:00
|
|
|
VILLAGER("mob.villager.hit", null, "mob.villager.death", "mob.villager.idle", "mob.villager.haggle", "mob.villager.no",
|
|
|
|
"mob.villager.yes"),
|
2013-07-22 15:31:11 +02:00
|
|
|
|
2013-07-22 16:04:42 +02:00
|
|
|
WITCH("mob.witch.hurt", null, "mob.witch.death", "mob.witch.idle"),
|
2013-07-22 15:31:11 +02:00
|
|
|
|
2013-11-22 15:15:26 +01:00
|
|
|
WITHER("mob.wither.hurt", null, "mob.wither.death", "mob.wither.idle", "damage.fallsmall", "mob.wither.spawn",
|
|
|
|
"damage.fallbig", "mob.wither.shoot"),
|
2013-05-29 00:29:36 +02:00
|
|
|
|
2013-11-22 15:15:26 +01:00
|
|
|
WITHER_SKELETON("mob.skeleton.hurt", "mob.skeleton.step", "mob.skeleton.death", "mob.skeleton.say"),
|
2013-05-29 00:29:36 +02:00
|
|
|
|
2013-11-22 15:15:26 +01:00
|
|
|
WOLF("mob.wolf.hurt", "mob.wolf.step", "mob.wolf.death", "mob.wolf.bark", "mob.wolf.panting", "mob.wolf.whine",
|
|
|
|
"mob.wolf.howl", "mob.wolf.growl", "mob.wolf.shake"),
|
2013-05-29 00:29:36 +02:00
|
|
|
|
2014-06-15 09:35:47 +02:00
|
|
|
ZOMBIE("mob.zombie.hurt", "mob.zombie.step", "mob.zombie.death", "mob.zombie.say", "mob.zombie.infect",
|
2014-07-16 02:37:31 +02:00
|
|
|
"mob.zombie.woodbreak", "mob.zombie.metal", "mob.zombie.wood"),
|
|
|
|
|
|
|
|
ZOMBIE_VILLAGER("mob.zombie.hurt", "mob.zombie.step", "mob.zombie.death", "mob.zombie.say", "mob.zombie.infect",
|
2014-06-15 09:35:47 +02:00
|
|
|
"mob.zombie.woodbreak", "mob.zombie.metal", "mob.zombie.wood");
|
2013-05-29 02:27:58 +02:00
|
|
|
|
2013-05-29 00:29:36 +02:00
|
|
|
public enum SoundType {
|
2013-05-29 00:52:54 +02:00
|
|
|
CANCEL, DEATH, HURT, IDLE, STEP;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static DisguiseSound getType(String name) {
|
|
|
|
try {
|
|
|
|
return valueOf(name);
|
|
|
|
} catch (Exception ex) {
|
|
|
|
return null;
|
|
|
|
}
|
2013-05-29 00:29:36 +02:00
|
|
|
}
|
|
|
|
|
2013-07-22 15:31:11 +02:00
|
|
|
private HashSet<String> cancelSounds = new HashSet<String>();
|
|
|
|
private float damageSoundVolume = 1F;
|
2013-07-22 16:18:34 +02:00
|
|
|
private HashMap<SoundType, String> disguiseSounds = new HashMap<SoundType, String>();
|
2013-05-29 00:52:54 +02:00
|
|
|
|
2013-11-14 00:20:38 +01:00
|
|
|
private DisguiseSound(Object... sounds) {
|
2013-05-29 00:29:36 +02:00
|
|
|
for (int i = 0; i < sounds.length; i++) {
|
2013-07-22 15:31:11 +02:00
|
|
|
Object obj = sounds[i];
|
|
|
|
String s;
|
|
|
|
if (obj == null)
|
|
|
|
continue;
|
2013-11-22 15:15:26 +01:00
|
|
|
else if (obj instanceof String) {
|
2013-07-22 15:31:11 +02:00
|
|
|
s = (String) obj;
|
2013-11-22 15:15:26 +01:00
|
|
|
} else if (obj instanceof Sound) {
|
2013-11-18 12:49:04 +01:00
|
|
|
s = ReflectionManager.getCraftSound((Sound) obj);
|
2014-04-04 07:30:20 +02:00
|
|
|
System.out.print("Warning! The sound " + obj + " needs to be converted to a string");
|
2013-11-22 15:15:26 +01:00
|
|
|
} else {
|
2013-07-22 15:31:11 +02:00
|
|
|
throw new RuntimeException("Was given a unknown object " + obj);
|
2013-11-22 15:15:26 +01:00
|
|
|
}
|
2013-07-22 15:31:11 +02:00
|
|
|
switch (i) {
|
|
|
|
case 0:
|
2013-05-29 00:29:36 +02:00
|
|
|
disguiseSounds.put(SoundType.HURT, s);
|
2013-07-22 15:31:11 +02:00
|
|
|
break;
|
|
|
|
case 1:
|
2013-05-29 00:29:36 +02:00
|
|
|
disguiseSounds.put(SoundType.STEP, s);
|
2013-07-22 15:31:11 +02:00
|
|
|
break;
|
|
|
|
case 2:
|
2013-05-29 00:29:36 +02:00
|
|
|
disguiseSounds.put(SoundType.DEATH, s);
|
2013-07-22 15:31:11 +02:00
|
|
|
break;
|
|
|
|
case 3:
|
2013-05-29 00:29:36 +02:00
|
|
|
disguiseSounds.put(SoundType.IDLE, s);
|
2013-07-22 15:31:11 +02:00
|
|
|
break;
|
|
|
|
default:
|
2013-05-29 00:29:36 +02:00
|
|
|
cancelSounds.add(s);
|
2013-07-22 15:31:11 +02:00
|
|
|
break;
|
|
|
|
}
|
2013-05-29 00:29:36 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-01-18 20:39:23 +01:00
|
|
|
public float getDamageAndIdleSoundVolume() {
|
2013-07-22 15:31:11 +02:00
|
|
|
return damageSoundVolume;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getSound(SoundType type) {
|
|
|
|
if (type == null || !disguiseSounds.containsKey(type))
|
2013-05-29 00:29:36 +02:00
|
|
|
return null;
|
|
|
|
return disguiseSounds.get(type);
|
|
|
|
}
|
|
|
|
|
2013-07-22 15:31:11 +02:00
|
|
|
public HashSet<String> getSoundsToCancel() {
|
2013-05-29 00:29:36 +02:00
|
|
|
return cancelSounds;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2013-05-29 19:17:48 +02:00
|
|
|
* Used to check if this sound name is owned by this disguise sound.
|
2013-05-29 00:29:36 +02:00
|
|
|
*/
|
2013-07-28 01:00:43 +02:00
|
|
|
public SoundType getType(String sound, boolean ignoreDamage) {
|
|
|
|
if (isCancelSound(sound))
|
2013-05-29 00:29:36 +02:00
|
|
|
return SoundType.CANCEL;
|
2013-07-22 16:06:19 +02:00
|
|
|
if (disguiseSounds.containsKey(SoundType.STEP) && disguiseSounds.get(SoundType.STEP).startsWith("step.")
|
2013-07-28 01:00:43 +02:00
|
|
|
&& sound.startsWith("step."))
|
2013-05-29 00:29:36 +02:00
|
|
|
return SoundType.STEP;
|
2013-05-29 02:27:58 +02:00
|
|
|
for (SoundType type : SoundType.values()) {
|
2013-05-29 19:17:48 +02:00
|
|
|
if (!disguiseSounds.containsKey(type) || type == SoundType.DEATH || (ignoreDamage && type == SoundType.HURT))
|
2013-05-29 02:27:58 +02:00
|
|
|
continue;
|
2013-07-22 15:31:11 +02:00
|
|
|
String s = disguiseSounds.get(type);
|
2013-05-29 20:20:50 +02:00
|
|
|
if (s != null) {
|
2013-07-28 01:00:43 +02:00
|
|
|
if (s.equals(sound))
|
2013-05-29 00:29:36 +02:00
|
|
|
return type;
|
2013-05-29 20:20:50 +02:00
|
|
|
}
|
2013-05-29 00:29:36 +02:00
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
2013-05-29 21:12:08 +02:00
|
|
|
|
|
|
|
public boolean isCancelSound(String sound) {
|
2013-07-22 15:31:11 +02:00
|
|
|
return getSoundsToCancel().contains(sound);
|
2013-05-29 21:12:08 +02:00
|
|
|
}
|
2013-07-22 16:18:34 +02:00
|
|
|
|
2013-07-29 01:19:59 +02:00
|
|
|
public void removeSound(SoundType type, Sound sound) {
|
2013-11-18 12:49:04 +01:00
|
|
|
removeSound(type, ReflectionManager.getCraftSound(sound));
|
2013-07-29 01:19:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public void removeSound(SoundType type, String sound) {
|
|
|
|
if (type == SoundType.CANCEL)
|
|
|
|
cancelSounds.remove(sound);
|
|
|
|
else {
|
|
|
|
disguiseSounds.remove(type);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-01-18 20:39:23 +01:00
|
|
|
public void setDamageAndIdleSoundVolume(float strength) {
|
2013-07-22 16:18:34 +02:00
|
|
|
this.damageSoundVolume = strength;
|
|
|
|
}
|
2013-07-29 01:19:59 +02:00
|
|
|
|
|
|
|
public void setSound(SoundType type, Sound sound) {
|
2013-11-18 12:49:04 +01:00
|
|
|
setSound(type, ReflectionManager.getCraftSound(sound));
|
2013-07-29 01:19:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public void setSound(SoundType type, String sound) {
|
|
|
|
if (type == SoundType.CANCEL)
|
|
|
|
cancelSounds.add(sound);
|
|
|
|
else {
|
|
|
|
disguiseSounds.put(type, sound);
|
|
|
|
}
|
|
|
|
}
|
2013-05-29 00:29:36 +02:00
|
|
|
}
|