Fix sounds - merge branch 'JBYoshi-sounds'

This commit is contained in:
libraryaddict 2016-05-10 03:50:24 +12:00
commit d6b6cecb18
3 changed files with 33 additions and 12 deletions

View File

@ -133,7 +133,6 @@ public enum DisguiseSound
public static DisguiseSound getType(String name) public static DisguiseSound getType(String name)
{ {
// TODO: FIX the disguise sounds
try try
{ {
return valueOf(name); return valueOf(name);

View File

@ -844,6 +844,7 @@ public class PacketsManager
mods.write(0, ReflectionManager.getNmsMethod(step.getClass(), "getStepSound") mods.write(0, ReflectionManager.getNmsMethod(step.getClass(), "getStepSound")
.invoke(step)); .invoke(step));
mods.write(1, ReflectionManager.getSoundCategory(disguise.getType()));
} }
} }
catch (Exception ex) catch (Exception ex)
@ -857,6 +858,7 @@ public class PacketsManager
else else
{ {
mods.write(0, ReflectionManager.getCraftSoundEffect(sound)); mods.write(0, ReflectionManager.getCraftSoundEffect(sound));
mods.write(1, ReflectionManager.getSoundCategory(disguise.getType()));
// Time to change the pitch and volume // Time to change the pitch and volume
if (soundType == SoundType.HURT || soundType == SoundType.DEATH if (soundType == SoundType.HURT || soundType == SoundType.DEATH
@ -1006,7 +1008,7 @@ public class PacketsManager
Object craftSoundEffect = ReflectionManager.getCraftSoundEffect(sound); Object craftSoundEffect = ReflectionManager.getCraftSoundEffect(sound);
mods.write(0, craftSoundEffect); mods.write(0, craftSoundEffect);
mods.write(1, ReflectionManager.getSoundCategory("master")); // Meh mods.write(1, ReflectionManager.getSoundCategory(disguise.getType())); // Meh
mods.write(2, (int) (loc.getX() * 8D)); mods.write(2, (int) (loc.getX() * 8D));
mods.write(3, (int) (loc.getY() * 8D)); mods.write(3, (int) (loc.getY() * 8D));
mods.write(4, (int) (loc.getZ() * 8D)); mods.write(4, (int) (loc.getZ() * 8D));
@ -1598,15 +1600,15 @@ public class PacketsManager
public static void setHearDisguisesListener(boolean enabled) public static void setHearDisguisesListener(boolean enabled)
{ {
// TODO: FIX SOUNDS if (soundsListenerEnabled != enabled) {
// if (soundsListenerEnabled != enabled) { soundsListenerEnabled = enabled;
// soundsListenerEnabled = enabled;
// if (soundsListenerEnabled) { if (soundsListenerEnabled){
// ProtocolLibrary.getProtocolManager().addPacketListener(soundsListener); ProtocolLibrary.getProtocolManager().addPacketListener(soundsListener);
// } else { } else {
// ProtocolLibrary.getProtocolManager().removePacketListener(soundsListener); ProtocolLibrary.getProtocolManager().removePacketListener(soundsListener);
// } }
// } }
} }
public static void setInventoryListenerEnabled(boolean enabled) public static void setInventoryListenerEnabled(boolean enabled)

View File

@ -31,6 +31,8 @@ import com.comphenix.protocol.wrappers.WrappedDataWatcher.WrappedDataWatcherObje
import com.comphenix.protocol.wrappers.WrappedGameProfile; import com.comphenix.protocol.wrappers.WrappedGameProfile;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.mojang.authlib.GameProfile; import com.mojang.authlib.GameProfile;
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
import org.bukkit.entity.*;
public class ReflectionManager public class ReflectionManager
{ {
@ -770,10 +772,12 @@ public class ReflectionManager
for (Enum anEnum : enums != null ? enums : new Enum[0]) for (Enum anEnum : enums != null ? enums : new Enum[0])
{ {
if (anEnum.name().equals("MASTER")) if (anEnum.name().equals(category.toUpperCase()))
return anEnum; return anEnum;
} }
} }
return invoke;
} }
catch (Exception e) catch (Exception e)
{ {
@ -783,6 +787,22 @@ public class ReflectionManager
return null; return null;
} }
public static Enum getSoundCategory(DisguiseType disguiseType)
{
if (disguiseType == DisguiseType.PLAYER)
return getSoundCategory("player");
Class<? extends Entity> entityClass = disguiseType.getEntityType().getEntityClass();
if (Monster.class.isAssignableFrom(entityClass))
return getSoundCategory("hostile");
if (Ambient.class.isAssignableFrom(entityClass))
return getSoundCategory("ambient");
return getSoundCategory("neutral");
}
/** /**
* Creates the NMS object EnumItemSlot from an EquipmentSlot. * Creates the NMS object EnumItemSlot from an EquipmentSlot.
* *