mirror of
https://github.com/dmulloy2/ProtocolLib.git
synced 2025-01-09 18:07:36 +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.
|
* @return Wrapped game profile converter.
|
||||||
*/
|
*/
|
||||||
public static EquivalentConverter<WrappedGameProfile> getWrappedGameProfileConverter() {
|
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.
|
* @return Wrapped chat component.
|
||||||
*/
|
*/
|
||||||
public static EquivalentConverter<WrappedChatComponent> getWrappedChatComponentConverter() {
|
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.
|
* @return Wrapped block data.
|
||||||
*/
|
*/
|
||||||
public static EquivalentConverter<WrappedBlockData> getWrappedBlockDataConverter() {
|
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.
|
* @return Wrapped attribute snapshot converter.
|
||||||
*/
|
*/
|
||||||
public static EquivalentConverter<WrappedAttribute> getWrappedAttributeConverter() {
|
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.
|
* @return Server ping converter.
|
||||||
*/
|
*/
|
||||||
public static EquivalentConverter<WrappedServerPing> getWrappedServerPingConverter() {
|
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.
|
* @return Statistic converter.
|
||||||
*/
|
*/
|
||||||
public static EquivalentConverter<WrappedStatistic> getWrappedStatisticConverter() {
|
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;
|
private static MethodAccessor BLOCK_FROM_MATERIAL;
|
||||||
@ -1016,7 +1016,7 @@ public class BukkitConverters {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static EquivalentConverter<WrappedParticle> getParticleConverter() {
|
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() {
|
public static EquivalentConverter<Advancement> getAdvancementConverter() {
|
||||||
|
@ -88,7 +88,7 @@ public class Converters {
|
|||||||
* @return A handle converter
|
* @return A handle converter
|
||||||
*/
|
*/
|
||||||
public static <T> EquivalentConverter<T> handle(final Function<T, Object> toHandle,
|
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>() {
|
return new EquivalentConverter<T>() {
|
||||||
@Override
|
@Override
|
||||||
public T getSpecific(Object generic) {
|
public T getSpecific(Object generic) {
|
||||||
@ -102,7 +102,7 @@ public class Converters {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Class<T> getSpecificType() {
|
public Class<T> getSpecificType() {
|
||||||
return null;
|
return specificType;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -121,7 +121,8 @@ public class Converters {
|
|||||||
@Override
|
@Override
|
||||||
public T[] getSpecific(Object generic) {
|
public T[] getSpecific(Object generic) {
|
||||||
Object[] array = (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
|
// Unwrap every item
|
||||||
for (int i = 0; i < result.length; i++) {
|
for (int i = 0; i < result.length; i++) {
|
||||||
|
Loading…
Reference in New Issue
Block a user