Attempt to fix server crash
This commit is contained in:
parent
eba4ba8326
commit
aec78e2321
@ -12,16 +12,19 @@ import me.libraryaddict.disguise.LibsDisguises;
|
|||||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||||
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
||||||
import me.libraryaddict.disguise.disguisetypes.MobDisguise;
|
import me.libraryaddict.disguise.disguisetypes.MobDisguise;
|
||||||
|
import me.libraryaddict.disguise.disguisetypes.TargetedDisguise;
|
||||||
import me.libraryaddict.disguise.utilities.DisguiseSound;
|
import me.libraryaddict.disguise.utilities.DisguiseSound;
|
||||||
import me.libraryaddict.disguise.utilities.DisguiseSound.SoundType;
|
import me.libraryaddict.disguise.utilities.DisguiseSound.SoundType;
|
||||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||||
import me.libraryaddict.disguise.utilities.reflection.ReflectionManager;
|
import me.libraryaddict.disguise.utilities.reflection.ReflectionManager;
|
||||||
|
import org.bukkit.Chunk;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.entity.*;
|
import org.bukkit.entity.*;
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import java.util.HashSet;
|
||||||
|
|
||||||
public class PacketListenerSounds extends PacketAdapter {
|
public class PacketListenerSounds extends PacketAdapter {
|
||||||
/**
|
/**
|
||||||
@ -59,27 +62,27 @@ public class PacketListenerSounds extends PacketAdapter {
|
|||||||
if (event.getPacketType() == Server.NAMED_SOUND_EFFECT) {
|
if (event.getPacketType() == Server.NAMED_SOUND_EFFECT) {
|
||||||
SoundType soundType = null;
|
SoundType soundType = null;
|
||||||
|
|
||||||
int[] soundCords = new int[]{(Integer) mods.read(2), (Integer) mods.read(3), (Integer) mods.read(4)};
|
|
||||||
|
|
||||||
int chunkX = (int) Math.floor((soundCords[0] / 8D) / 16D);
|
|
||||||
int chunkZ = (int) Math.floor((soundCords[2] / 8D) / 16D);
|
|
||||||
|
|
||||||
if (!observer.getWorld().isChunkLoaded(chunkX, chunkZ)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Entity disguisedEntity = null;
|
Entity disguisedEntity = null;
|
||||||
DisguiseSound entitySound = null;
|
DisguiseSound entitySound = null;
|
||||||
|
Object soundEffectObj = mods.read(0);
|
||||||
|
|
||||||
Disguise disguise = null;
|
Disguise disguise = null;
|
||||||
|
|
||||||
Object soundEffectObj = mods.read(0);
|
int[] soundCords = new int[]{(Integer) mods.read(2), (Integer) mods.read(3), (Integer) mods.read(4)};
|
||||||
Entity[] entities = observer.getWorld().getChunkAt(chunkX, chunkZ).getEntities();
|
|
||||||
|
|
||||||
for (Entity entity : entities) {
|
loop:
|
||||||
Disguise entityDisguise = DisguiseAPI.getDisguise(observer, entity);
|
for (HashSet<TargetedDisguise> disguises : DisguiseUtilities.getDisguises().values()) {
|
||||||
|
for (TargetedDisguise entityDisguise : disguises) {
|
||||||
|
Entity entity = entityDisguise.getEntity();
|
||||||
|
|
||||||
|
if (entity.getWorld() != observer.getWorld()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!entityDisguise.canSee(observer)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (entityDisguise != null) {
|
|
||||||
Location loc = entity.getLocation();
|
Location loc = entity.getLocation();
|
||||||
|
|
||||||
int[] entCords = new int[]{(int) (loc.getX() * 8), (int) (loc.getY() * 8), (int) (loc.getZ() * 8)};
|
int[] entCords = new int[]{(int) (loc.getX() * 8), (int) (loc.getY() * 8), (int) (loc.getZ() * 8)};
|
||||||
@ -139,7 +142,7 @@ public class PacketListenerSounds extends PacketAdapter {
|
|||||||
if (soundType != null) {
|
if (soundType != null) {
|
||||||
disguise = entityDisguise;
|
disguise = entityDisguise;
|
||||||
disguisedEntity = entity;
|
disguisedEntity = entity;
|
||||||
break;
|
break loop;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user