mirror of
https://github.com/GeyserMC/MCProtocolLib.git
synced 2024-12-12 08:41:00 -05:00
Make MagicValues key type more lenient.
This commit is contained in:
parent
7dd6887fed
commit
16a120036c
2 changed files with 5 additions and 12 deletions
|
@ -83,7 +83,7 @@ import java.util.Map;
|
|||
import java.util.UUID;
|
||||
|
||||
public class MagicValues {
|
||||
private static final Map<Enum<?>, List<Object>> values = new HashMap<Enum<?>, List<Object>>();
|
||||
private static final Map<Object, List<Object>> values = new HashMap<Object, List<Object>>();
|
||||
|
||||
static {
|
||||
register(AttributeType.MAX_HEALTH, "generic.maxHealth");
|
||||
|
@ -814,8 +814,8 @@ public class MagicValues {
|
|||
}
|
||||
|
||||
@SuppressWarnings({ "unchecked" })
|
||||
public static <T extends Enum<?>> T key(Class<T> keyType, Object value) {
|
||||
for(Enum<?> key : values.keySet()) {
|
||||
public static <T> T key(Class<T> keyType, Object value) {
|
||||
for(Object key : values.keySet()) {
|
||||
if(keyType.isAssignableFrom(key.getClass())) {
|
||||
for(Object val : values.get(key)) {
|
||||
if(val == value || val.equals(value)) {
|
||||
|
@ -835,7 +835,7 @@ public class MagicValues {
|
|||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T> T value(Class<T> valueType, Enum<?> key) {
|
||||
public static <T> T value(Class<T> valueType, Object key) {
|
||||
if(values.containsKey(key)) {
|
||||
for(Object val : values.get(key)) {
|
||||
if(valueType.isAssignableFrom(val.getClass())) {
|
||||
|
|
|
@ -79,14 +79,7 @@ public class ServerPlayEffectPacket implements Packet {
|
|||
|
||||
@Override
|
||||
public void write(NetOutput out) throws IOException {
|
||||
int id = 0;
|
||||
if(this.effect instanceof ParticleEffect) {
|
||||
id = MagicValues.value(Integer.class, (ParticleEffect) this.effect);
|
||||
} else if(this.effect instanceof SoundEffect) {
|
||||
id = MagicValues.value(Integer.class, (SoundEffect) this.effect);
|
||||
}
|
||||
|
||||
out.writeInt(id);
|
||||
out.writeInt(MagicValues.value(Integer.class, this.effect));
|
||||
NetUtil.writePosition(out, this.position);
|
||||
int value = 0;
|
||||
if(this.data instanceof RecordEffectData) {
|
||||
|
|
Loading…
Reference in a new issue