Fix up sounds and some other stuff

This commit is contained in:
libraryaddict
2021-12-11 20:57:23 +13:00
parent 42cd210fc7
commit 52cb313f77
7 changed files with 86 additions and 52 deletions

View File

@@ -24,6 +24,7 @@ import me.libraryaddict.disguise.utilities.listeners.PaperDisguiseListener;
import me.libraryaddict.disguise.utilities.listeners.PlayerSkinHandler;
import me.libraryaddict.disguise.utilities.metrics.MetricsInitalizer;
import me.libraryaddict.disguise.utilities.packets.PacketsManager;
import me.libraryaddict.disguise.utilities.params.ParamInfoManager;
import me.libraryaddict.disguise.utilities.parser.DisguiseParser;
import me.libraryaddict.disguise.utilities.reflection.NmsVersion;
import me.libraryaddict.disguise.utilities.reflection.ReflectionManager;
@@ -83,8 +84,8 @@ public class LibsDisguises extends JavaPlugin {
getLogger().severe("Please restart the server to complete the ProtocolLib update!");
}
} catch (Exception e) {
getLogger()
.severe("Looks like ProtocolLib's site may be down! MythicCraft/MythicMobs has a discord server https://discord.gg/EErRhJ4qgx you" +
getLogger().severe(
"Looks like ProtocolLib's site may be down! MythicCraft/MythicMobs has a discord server https://discord.gg/EErRhJ4qgx you" +
" can " + "join. Check the pins in #libs-support for a ProtocolLib.jar you can download!");
e.printStackTrace();
}
@@ -164,8 +165,8 @@ public class LibsDisguises extends JavaPlugin {
LibsPremium.check(getDescription().getVersion(), getFile());
if (!LibsPremium.isPremium()) {
getLogger()
.info("You are running the free version, commands limited to non-players and operators. (Console," + " Command " + "Blocks, Admins)");
getLogger().info(
"You are running the free version, commands limited to non-players and operators. (Console," + " Command " + "Blocks, Admins)");
}
if (ReflectionManager.getVersion() == null) {
@@ -185,8 +186,9 @@ public class LibsDisguises extends JavaPlugin {
@Override
public void run() {
getLogger().severe("!! May I have your attention please !!");
getLogger().severe("Update your ProtocolLib! You are running " + version + " but the minimum version you should be on is " +
requiredProtocolLib + "!");
getLogger().severe(
"Update your ProtocolLib! You are running " + version + " but the minimum version you should be on is " + requiredProtocolLib +
"!");
getLogger().severe("https://ci.dmulloy2.net/job/ProtocolLib/lastSuccessfulBuild/artifact/target" + "/ProtocolLib" + ".jar");
getLogger().severe("Or! Use /ld protocollib - To update to the latest development build");
@@ -218,9 +220,11 @@ public class LibsDisguises extends JavaPlugin {
PacketsManager.init();
DisguiseUtilities.init();
new SoundManager().load();
ReflectionManager.registerValues();
new SoundManager().load();
ParamInfoManager.getParamInfoSoundGroup().recalculate();
DisguiseConfig.loadConfig();

View File

@@ -110,8 +110,8 @@ public class PacketListenerSounds extends PacketAdapter {
// Blocks null and CANCEL, HURT and DEATH are 100% handled by entity status!
if (soundType != SoundType.STEP && soundType != SoundType.IDLE) {
event.setCancelled(true);
return;
//event.setCancelled(true);
// return;
}
if (disguisedEntity == observer && !disguise.isSelfDisguiseSoundsReplaced()) {
@@ -141,35 +141,32 @@ public class PacketListenerSounds extends PacketAdapter {
if (disguise instanceof MobDisguise && disguisedEntity instanceof LivingEntity && ((MobDisguise) disguise).doesDisguiseAge()) {
if (((MobDisguise) disguise).isAdult()) {
pitch = (DisguiseUtilities.random.nextFloat() - DisguiseUtilities.random.nextFloat()) * 0.2F + 1.0F;
pitch = ((DisguiseUtilities.random.nextFloat() - DisguiseUtilities.random.nextFloat()) * 0.2F) + 1.0F;
} else {
pitch = (DisguiseUtilities.random.nextFloat() - DisguiseUtilities.random.nextFloat()) * 0.2F + 1.4F;
pitch = ((DisguiseUtilities.random.nextFloat() - DisguiseUtilities.random.nextFloat()) * 0.2F) + 1.4F;
}
}
if (sound.getClass().getSimpleName().equals("MinecraftKey")) {
PacketContainer newPacket = new PacketContainer(Server.CUSTOM_SOUND_EFFECT);
StructureModifier<Object> newModifs = newPacket.getModifier();
PacketContainer newPacket;
newModifs.write(0, sound);
newModifs.write(1, soundCat);
if (sound.getClass().getSimpleName().equals("MinecraftKey")) {
newPacket = new PacketContainer(Server.CUSTOM_SOUND_EFFECT);
StructureModifier<Object> newModifs = newPacket.getModifier();
newModifs.write(2, mods.read(2));
newModifs.write(3, mods.read(3));
newModifs.write(4, mods.read(4));
newModifs.write(5, volume);
newModifs.write(6, pitch);
event.setPacket(newPacket);
} else {
event.setPacket(event.getPacket().shallowClone());
mods = event.getPacket().getModifier();
mods.write(0, sound);
mods.write(1, soundCat);
mods.write(5, volume);
mods.write(6, pitch);
newPacket = event.getPacket().shallowClone();
mods = newPacket.getModifier();
}
mods.write(0, sound);
mods.write(1, soundCat);
mods.write(5, volume);
mods.write(6, pitch);
event.setPacket(newPacket);
}
private void handleEntityStatus(PacketEvent event) {
@@ -191,10 +188,12 @@ public class PacketListenerSounds extends PacketAdapter {
if (disguise instanceof TargetedDisguise) {
Set<TargetedDisguise> discs = DisguiseUtilities.getDisguises().get(entity.getEntityId());
for (TargetedDisguise targetedDisguise : discs) {
if (targetedDisguise != disguise) {
continue;
}
if (!targetedDisguise.canSee(observer)) {
return;
}
@@ -203,7 +202,7 @@ public class PacketListenerSounds extends PacketAdapter {
SoundType soundType = SoundType.HURT;
if (entity instanceof LivingEntity && ((LivingEntity) entity).getHealth() == 0) {
if (entity instanceof LivingEntity && ((LivingEntity) entity).getHealth() <= 0) {
soundType = SoundType.DEATH;
}
@@ -230,8 +229,9 @@ public class PacketListenerSounds extends PacketAdapter {
}
SoundGroup disSound = SoundGroup.getGroup(disguise);
SoundGroup expectedGroup = SoundGroup.getGroup(disguise.getType().name());
if (disSound == null || disSound == entitySoundGroup) {
if (disSound == null || disSound == expectedGroup) {
return;
}

View File

@@ -9,8 +9,9 @@ public class ClassMappings {
public static String getClass(String packageHint, String className) {
String location = classLocations.get(className);
if (location != null)
if (location != null) {
return location;
}
location = className;
String[] arrayOfString;
int i;
@@ -35,14 +36,21 @@ public class ClassMappings {
}
private static String[] getPackages() {
String[] s = {
"net.minecraft.core", "net.minecraft.core.particles", "net.minecraft.nbt", "net.minecraft.network.chat", "net.minecraft.network.protocol.game", "net.minecraft.network.syncher", "net.minecraft.resources", "net.minecraft.server.level", "net.minecraft.server", "net.minecraft.server.network",
"net.minecraft.sounds", "net.minecraft.world.damagesource", "net.minecraft.world.effect", "net.minecraft.world.entity.ambient", "net.minecraft.world.entity.animal.axolotl", "net.minecraft.world.entity.animal", "net.minecraft.world.entity.animal.goat", "net.minecraft.world.entity.animal.horse", "net.minecraft.world.entity.boss.enderdragon", "net.minecraft.world.entity.boss.wither",
"net.minecraft.world.entity.decoration", "net.minecraft.world.entity", "net.minecraft.world.entity.item", "net.minecraft.world.entity.monster", "net.minecraft.world.entity.monster.hoglin", "net.minecraft.world.entity.monster.piglin", "net.minecraft.world.entity.npc", "net.minecraft.world.entity.player", "net.minecraft.world.entity.projectile", "net.minecraft.world.entity.vehicle",
"net.minecraft.world.inventory", "net.minecraft.world.item", "net.minecraft.world.level.block", "net.minecraft.world.level.block.state", "net.minecraft.world.level", "net.minecraft.world.phys", "org.bukkit.craftbukkit.$version$.block.data", "org.bukkit.craftbukkit.$version$", "org.bukkit.craftbukkit.$version$.entity", "org.bukkit.craftbukkit.$version$.inventory",
"org.bukkit.craftbukkit.$version$.util" };
for (int i = 0; i < s.length; i++)
String[] s = {"net.minecraft.server.$version$", "net.minecraft.core", "net.minecraft.core.particles", "net.minecraft.nbt", "net.minecraft.network.chat",
"net.minecraft.network.protocol.game", "net.minecraft.network.syncher", "net.minecraft.resources", "net.minecraft.server.level",
"net.minecraft.server", "net.minecraft.server.network", "net.minecraft.sounds", "net.minecraft.world.damagesource",
"net.minecraft.world.effect", "net.minecraft.world.entity.ambient", "net.minecraft.world.entity.animal.axolotl",
"net.minecraft.world.entity.animal", "net.minecraft.world.entity.animal.goat", "net.minecraft.world.entity.animal.horse",
"net.minecraft.world.entity.boss.enderdragon", "net.minecraft.world.entity.boss.wither", "net.minecraft.world.entity.decoration",
"net.minecraft.world.entity", "net.minecraft.world.entity.item", "net.minecraft.world.entity.monster",
"net.minecraft.world.entity.monster.hoglin", "net.minecraft.world.entity.monster.piglin", "net.minecraft.world.entity.npc",
"net.minecraft.world.entity.player", "net.minecraft.world.entity.projectile", "net.minecraft.world.entity.vehicle",
"net.minecraft.world.inventory", "net.minecraft.world.item", "net.minecraft.world.level.block", "net.minecraft.world.level.block.state",
"net.minecraft.world.level", "net.minecraft.world.phys", "org.bukkit.craftbukkit.$version$.block.data", "org.bukkit.craftbukkit.$version$",
"org.bukkit.craftbukkit.$version$.entity", "org.bukkit.craftbukkit.$version$.inventory", "org.bukkit.craftbukkit.$version$.util"};
for (int i = 0; i < s.length; i++) {
s[i] = s[i].replace("$version$", ReflectionManager.getBukkitVersion());
}
return s;
}
}

View File

@@ -699,6 +699,7 @@ public class ReflectionManager {
Object o = aClass.getConstructor().newInstance();
return (ReflectionManagerAbstract) o;
} catch (ClassNotFoundException ignored) {
} catch (ReflectiveOperationException e) {
e.printStackTrace();
}
@@ -1088,6 +1089,7 @@ public class ReflectionManager {
return (Float) damageAndIdleSoundMethod.invoke(entity);
} catch (Exception ignored) {
}
return null;
}

View File

@@ -24,8 +24,6 @@ public class SoundManager {
loadSounds();
loadCustomSounds();
ParamInfoManager.getParamInfoSoundGroup().recalculate();
}
private void loadCustomSounds() {