mirror of
https://github.com/libraryaddict/LibsDisguises.git
synced 2024-09-11 01:38:07 +02:00
Re-add disguise sounds. Now respect 1.9 sound categories.
This commit is contained in:
parent
6776a9b427
commit
282ad55039
@ -78,7 +78,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);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
|
@ -609,6 +609,7 @@ public class PacketsManager {
|
|||||||
if (block != null) {
|
if (block != null) {
|
||||||
Object step = ReflectionManager.getNmsField("Block", "stepSound").get(block);
|
Object step = ReflectionManager.getNmsField("Block", "stepSound").get(block);
|
||||||
mods.write(0, ReflectionManager.getNmsMethod(step.getClass(), "getStepSound").invoke(step));
|
mods.write(0, ReflectionManager.getNmsMethod(step.getClass(), "getStepSound").invoke(step));
|
||||||
|
mods.write(1, ReflectionManager.getSoundCategory(disguise.getType()));
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
@ -618,6 +619,7 @@ public class PacketsManager {
|
|||||||
// sending fake sounds. In which case. Why cancel it.
|
// sending fake sounds. In which case. Why cancel it.
|
||||||
} 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
|
||||||
|| soundType == SoundType.IDLE) {
|
|| soundType == SoundType.IDLE) {
|
||||||
@ -713,7 +715,7 @@ public class PacketsManager {
|
|||||||
mods = packet.getModifier();
|
mods = packet.getModifier();
|
||||||
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()));
|
||||||
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));
|
||||||
@ -1103,15 +1105,14 @@ 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) {
|
||||||
|
@ -7,6 +7,7 @@ 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.apache.commons.lang3.tuple.ImmutablePair;
|
import org.apache.commons.lang3.tuple.ImmutablePair;
|
||||||
import org.apache.commons.lang3.tuple.Pair;
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
import org.bukkit.Art;
|
import org.bukkit.Art;
|
||||||
@ -15,9 +16,7 @@ import org.bukkit.Location;
|
|||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.*;
|
||||||
import org.bukkit.entity.LivingEntity;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.inventory.EntityEquipment;
|
import org.bukkit.inventory.EntityEquipment;
|
||||||
import org.bukkit.inventory.EquipmentSlot;
|
import org.bukkit.inventory.EquipmentSlot;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
@ -530,16 +529,24 @@ public class ReflectionManager {
|
|||||||
Class<?> clazz = getNmsClass("SoundCategory");
|
Class<?> clazz = getNmsClass("SoundCategory");
|
||||||
Enum[] enums = clazz != null ? (Enum[]) clazz.getEnumConstants() : null;
|
Enum[] enums = clazz != null ? (Enum[]) clazz.getEnumConstants() : null;
|
||||||
for (Enum anEnum : enums != null ? enums : new Enum[0]) {
|
for (Enum anEnum : enums != null ? enums : new Enum[0]) {
|
||||||
if (anEnum.name().equals("MASTER")) return anEnum;
|
if (anEnum.name().equals(category.toUpperCase())) return anEnum;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return invoke;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
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.
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user