mirror of
https://github.com/dmulloy2/ProtocolLib.git
synced 2025-01-08 09:27:34 +01:00
Fix a class cast exception with array wrappers
(Kinda surprised there isn't an issue to link here)
This commit is contained in:
parent
f381f0a2f7
commit
4bc9e8b7b7
@ -485,7 +485,7 @@ public class BukkitConverters {
|
||||
* @return Wrapped game profile converter.
|
||||
*/
|
||||
public static EquivalentConverter<WrappedGameProfile> getWrappedGameProfileConverter() {
|
||||
return ignoreNull(handle(WrappedGameProfile::getHandle, WrappedGameProfile::fromHandle));
|
||||
return ignoreNull(handle(WrappedGameProfile::getHandle, WrappedGameProfile::fromHandle, WrappedGameProfile.class));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -493,7 +493,7 @@ public class BukkitConverters {
|
||||
* @return Wrapped chat component.
|
||||
*/
|
||||
public static EquivalentConverter<WrappedChatComponent> getWrappedChatComponentConverter() {
|
||||
return ignoreNull(handle(WrappedChatComponent::getHandle, WrappedChatComponent::fromHandle));
|
||||
return ignoreNull(handle(WrappedChatComponent::getHandle, WrappedChatComponent::fromHandle, WrappedChatComponent.class));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -501,7 +501,7 @@ public class BukkitConverters {
|
||||
* @return Wrapped block data.
|
||||
*/
|
||||
public static EquivalentConverter<WrappedBlockData> getWrappedBlockDataConverter() {
|
||||
return ignoreNull(handle(WrappedBlockData::getHandle, WrappedBlockData::fromHandle));
|
||||
return ignoreNull(handle(WrappedBlockData::getHandle, WrappedBlockData::fromHandle, WrappedBlockData.class));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -509,7 +509,7 @@ public class BukkitConverters {
|
||||
* @return Wrapped attribute snapshot converter.
|
||||
*/
|
||||
public static EquivalentConverter<WrappedAttribute> getWrappedAttributeConverter() {
|
||||
return ignoreNull(handle(WrappedAttribute::getHandle, WrappedAttribute::fromHandle));
|
||||
return ignoreNull(handle(WrappedAttribute::getHandle, WrappedAttribute::fromHandle, WrappedAttribute.class));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -768,7 +768,7 @@ public class BukkitConverters {
|
||||
* @return Server ping converter.
|
||||
*/
|
||||
public static EquivalentConverter<WrappedServerPing> getWrappedServerPingConverter() {
|
||||
return ignoreNull(handle(WrappedServerPing::getHandle, WrappedServerPing::fromHandle));
|
||||
return ignoreNull(handle(WrappedServerPing::getHandle, WrappedServerPing::fromHandle, WrappedServerPing.class));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -776,7 +776,7 @@ public class BukkitConverters {
|
||||
* @return Statistic converter.
|
||||
*/
|
||||
public static EquivalentConverter<WrappedStatistic> getWrappedStatisticConverter() {
|
||||
return ignoreNull(handle(WrappedStatistic::getHandle, WrappedStatistic::fromHandle));
|
||||
return ignoreNull(handle(WrappedStatistic::getHandle, WrappedStatistic::fromHandle, WrappedStatistic.class));
|
||||
}
|
||||
|
||||
private static MethodAccessor BLOCK_FROM_MATERIAL;
|
||||
@ -1016,7 +1016,7 @@ public class BukkitConverters {
|
||||
}
|
||||
|
||||
public static EquivalentConverter<WrappedParticle> getParticleConverter() {
|
||||
return ignoreNull(handle(WrappedParticle::getHandle, WrappedParticle::fromHandle));
|
||||
return ignoreNull(handle(WrappedParticle::getHandle, WrappedParticle::fromHandle, WrappedParticle.class));
|
||||
}
|
||||
|
||||
public static EquivalentConverter<Advancement> getAdvancementConverter() {
|
||||
|
@ -88,7 +88,7 @@ public class Converters {
|
||||
* @return A handle converter
|
||||
*/
|
||||
public static <T> EquivalentConverter<T> handle(final Function<T, Object> toHandle,
|
||||
final Function<Object, T> fromHandle) {
|
||||
final Function<Object, T> fromHandle, final Class<T> specificType) {
|
||||
return new EquivalentConverter<T>() {
|
||||
@Override
|
||||
public T getSpecific(Object generic) {
|
||||
@ -102,7 +102,7 @@ public class Converters {
|
||||
|
||||
@Override
|
||||
public Class<T> getSpecificType() {
|
||||
return null;
|
||||
return specificType;
|
||||
}
|
||||
};
|
||||
}
|
||||
@ -121,7 +121,8 @@ public class Converters {
|
||||
@Override
|
||||
public T[] getSpecific(Object generic) {
|
||||
Object[] array = (Object[]) generic;
|
||||
T[] result = (T[]) new Object[array.length];
|
||||
Class<T[]> clazz = getSpecificType();
|
||||
T[] result = clazz.cast(Array.newInstance(clazz.getComponentType(), array.length));
|
||||
|
||||
// Unwrap every item
|
||||
for (int i = 0; i < result.length; i++) {
|
||||
|
Loading…
Reference in New Issue
Block a user