Ursprung
3ac9793553
Commit
6abd0cfdaa
@ -594,7 +594,7 @@ public class PacketContainer implements Serializable {
|
|||||||
* Retrieves a read/write structure for chat components in Minecraft 1.7.2.
|
* Retrieves a read/write structure for chat components in Minecraft 1.7.2.
|
||||||
* <p>
|
* <p>
|
||||||
* This modifier will automatically marshall between WrappedChatComponent and the
|
* This modifier will automatically marshall between WrappedChatComponent and the
|
||||||
* internal Minecraft GameProfile.
|
* internal Minecraft IChatBaseComponent.
|
||||||
* @return A modifier for ChatComponent fields.
|
* @return A modifier for ChatComponent fields.
|
||||||
*/
|
*/
|
||||||
public StructureModifier<WrappedChatComponent> getChatComponents() {
|
public StructureModifier<WrappedChatComponent> getChatComponents() {
|
||||||
@ -602,6 +602,20 @@ public class PacketContainer implements Serializable {
|
|||||||
return structureModifier.<WrappedChatComponent>withType(
|
return structureModifier.<WrappedChatComponent>withType(
|
||||||
MinecraftReflection.getIChatBaseComponentClass(), BukkitConverters.getWrappedChatComponentConverter());
|
MinecraftReflection.getIChatBaseComponentClass(), BukkitConverters.getWrappedChatComponentConverter());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves a read/write structure for arrays of chat components.
|
||||||
|
* <p>
|
||||||
|
* This modifier will automatically marshall between WrappedChatComponent and the
|
||||||
|
* internal Minecraft IChatBaseComponent.
|
||||||
|
* @return A modifier for ItemStack array fields.
|
||||||
|
*/
|
||||||
|
public StructureModifier<WrappedChatComponent[]> getChatComponentArrays() {
|
||||||
|
// Convert to and from the Bukkit wrapper
|
||||||
|
return structureModifier.<WrappedChatComponent[]>withType(
|
||||||
|
MinecraftReflection.getIChatBaseComponentClass(),
|
||||||
|
BukkitConverters.getIgnoreNull(new WrappedChatComponentArrayConverter()));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve a read/write structure for the ServerPing fields in the following packet: <br>
|
* Retrieve a read/write structure for the ServerPing fields in the following packet: <br>
|
||||||
@ -899,4 +913,41 @@ public class PacketContainer implements Serializable {
|
|||||||
return ItemStack[].class;
|
return ItemStack[].class;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents an equivalent converter for ChatComponent arrays.
|
||||||
|
* @author Kristian
|
||||||
|
*/
|
||||||
|
private static class WrappedChatComponentArrayConverter implements EquivalentConverter<WrappedChatComponent[]> {
|
||||||
|
final EquivalentConverter<WrappedChatComponent> componentConverter = BukkitConverters.getWrappedChatComponentConverter();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getGeneric(Class<?>genericType, WrappedChatComponent[] specific) {
|
||||||
|
Class<?> nmsComponent = MinecraftReflection.getIChatBaseComponentClass();
|
||||||
|
Object[] result = (Object[]) Array.newInstance(nmsComponent, specific.length);
|
||||||
|
|
||||||
|
// Unwrap every item
|
||||||
|
for (int i = 0; i < result.length; i++) {
|
||||||
|
result[i] = componentConverter.getGeneric(nmsComponent, specific[i]);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public WrappedChatComponent[] getSpecific(Object generic) {
|
||||||
|
Object[] input = (Object[]) generic;
|
||||||
|
WrappedChatComponent[] result = new WrappedChatComponent[input.length];
|
||||||
|
|
||||||
|
// Add the wrapper
|
||||||
|
for (int i = 0; i < result.length; i++) {
|
||||||
|
result[i] = componentConverter.getSpecific(input[i]);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<WrappedChatComponent[]> getSpecificType() {
|
||||||
|
return WrappedChatComponent[].class;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren