Add support for ResourcePackStatus
Dieser Commit ist enthalten in:
Ursprung
d7087c2da5
Commit
1c8e3b5ee3
@ -76,6 +76,7 @@ import com.comphenix.protocol.wrappers.EnumWrappers.ClientCommand;
|
||||
import com.comphenix.protocol.wrappers.EnumWrappers.Difficulty;
|
||||
import com.comphenix.protocol.wrappers.EnumWrappers.EntityUseAction;
|
||||
import com.comphenix.protocol.wrappers.EnumWrappers.NativeGameMode;
|
||||
import com.comphenix.protocol.wrappers.EnumWrappers.ResourcePackStatus;
|
||||
import com.comphenix.protocol.wrappers.WrappedAttribute;
|
||||
import com.comphenix.protocol.wrappers.WrappedChatComponent;
|
||||
import com.comphenix.protocol.wrappers.WrappedDataWatcher;
|
||||
@ -690,6 +691,16 @@ public class PacketContainer implements Serializable {
|
||||
EnumWrappers.getGameModeClass(), EnumWrappers.getGameModeConverter());
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a read/write structure for the ResourcePackStatus enum in 1.8.
|
||||
* @return A modifier for ResourcePackStatus enum fields.
|
||||
*/
|
||||
public StructureModifier<ResourcePackStatus> getResourcePackStatus() {
|
||||
// Convert to and from the wrapper
|
||||
return structureModifier.<ResourcePackStatus>withType(
|
||||
EnumWrappers.getResourcePackStatusClass(), EnumWrappers.getResourcePackStatusConverter());
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the ID of this packet.
|
||||
* <p>
|
||||
|
@ -60,13 +60,22 @@ public abstract class EnumWrappers {
|
||||
NONE;
|
||||
}
|
||||
|
||||
public enum ResourcePackStatus {
|
||||
SUCCESSFULLY_LOADED,
|
||||
DECLINED,
|
||||
FAILED_DOWNLOAD,
|
||||
ACCEPTED;
|
||||
}
|
||||
|
||||
private static Class<?> PROTOCOL_CLASS = null;
|
||||
private static Class<?> CLIENT_COMMAND_CLASS = null;
|
||||
private static Class<?> CHAT_VISIBILITY_CLASS = null;
|
||||
private static Class<?> DIFFICULTY_CLASS = null;
|
||||
private static Class<?> ENTITY_USE_ACTION_CLASS = null;
|
||||
private static Class<?> GAMEMODE_CLASS = null;
|
||||
private static Class<?> RESOURCE_PACK_STATUS_CLASS = null;
|
||||
|
||||
private static boolean INITIALIZED = false;
|
||||
private static Map<Class<?>, EquivalentConverter<?>> FROM_NATIVE = Maps.newHashMap();
|
||||
private static Map<Class<?>, EquivalentConverter<?>> FROM_WRAPPER = Maps.newHashMap();
|
||||
|
||||
@ -77,12 +86,16 @@ public abstract class EnumWrappers {
|
||||
if (!MinecraftReflection.isUsingNetty())
|
||||
throw new IllegalArgumentException("Not supported on 1.6.4 and earlier.");
|
||||
|
||||
if (INITIALIZED)
|
||||
return;
|
||||
|
||||
PROTOCOL_CLASS = getEnum(PacketType.Handshake.Client.SET_PROTOCOL.getPacketClass(), 0);
|
||||
CLIENT_COMMAND_CLASS = getEnum(PacketType.Play.Client.CLIENT_COMMAND.getPacketClass(), 0);
|
||||
CHAT_VISIBILITY_CLASS = getEnum(PacketType.Play.Client.SETTINGS.getPacketClass(), 0);
|
||||
DIFFICULTY_CLASS = getEnum(PacketType.Play.Server.LOGIN.getPacketClass(), 1);
|
||||
ENTITY_USE_ACTION_CLASS = getEnum(PacketType.Play.Client.USE_ENTITY.getPacketClass(), 0);
|
||||
GAMEMODE_CLASS = getEnum(PacketType.Play.Server.LOGIN.getPacketClass(), 0);
|
||||
RESOURCE_PACK_STATUS_CLASS = getEnum(PacketType.Play.Client.RESOURCE_PACK_STATUS.getPacketClass(), 0);
|
||||
|
||||
associate(PROTOCOL_CLASS, Protocol.class, getClientCommandConverter());
|
||||
associate(CLIENT_COMMAND_CLASS, ClientCommand.class, getClientCommandConverter());
|
||||
@ -90,6 +103,8 @@ public abstract class EnumWrappers {
|
||||
associate(DIFFICULTY_CLASS, Difficulty.class, getDifficultyConverter());
|
||||
associate(ENTITY_USE_ACTION_CLASS, EntityUseAction.class, getEntityUseActionConverter());
|
||||
associate(GAMEMODE_CLASS, NativeGameMode.class, getGameModeConverter());
|
||||
associate(RESOURCE_PACK_STATUS_CLASS, ResourcePackStatus.class, getResourcePackStatusConverter());
|
||||
INITIALIZED = true;
|
||||
}
|
||||
|
||||
private static void associate(Class<?> nativeClass, Class<?> wrapperClass, EquivalentConverter<?> converter) {
|
||||
@ -120,47 +135,66 @@ public abstract class EnumWrappers {
|
||||
initialize();
|
||||
return PROTOCOL_CLASS;
|
||||
}
|
||||
|
||||
public static Class<?> getClientCommandClass() {
|
||||
initialize();
|
||||
return CLIENT_COMMAND_CLASS;
|
||||
}
|
||||
|
||||
public static Class<?> getChatVisibilityClass() {
|
||||
initialize();
|
||||
return CHAT_VISIBILITY_CLASS;
|
||||
}
|
||||
|
||||
public static Class<?> getDifficultyClass() {
|
||||
initialize();
|
||||
return DIFFICULTY_CLASS;
|
||||
}
|
||||
|
||||
public static Class<?> getEntityUseActionClass() {
|
||||
initialize();
|
||||
return ENTITY_USE_ACTION_CLASS;
|
||||
}
|
||||
|
||||
public static Class<?> getGameModeClass() {
|
||||
initialize();
|
||||
return GAMEMODE_CLASS;
|
||||
}
|
||||
|
||||
public static Class<?> getResourcePackStatusClass() {
|
||||
initialize();
|
||||
return RESOURCE_PACK_STATUS_CLASS;
|
||||
}
|
||||
|
||||
// Get the converters
|
||||
public static EquivalentConverter<Protocol> getProtocolConverter() {
|
||||
return new EnumConverter<Protocol>(Protocol.class);
|
||||
}
|
||||
|
||||
public static EquivalentConverter<ClientCommand> getClientCommandConverter() {
|
||||
return new EnumConverter<ClientCommand>(ClientCommand.class);
|
||||
}
|
||||
|
||||
public static EquivalentConverter<ChatVisibility> getChatVisibilityConverter() {
|
||||
return new EnumConverter<ChatVisibility>(ChatVisibility.class);
|
||||
}
|
||||
|
||||
public static EquivalentConverter<Difficulty> getDifficultyConverter() {
|
||||
return new EnumConverter<Difficulty>(Difficulty.class);
|
||||
}
|
||||
|
||||
public static EquivalentConverter<EntityUseAction> getEntityUseActionConverter() {
|
||||
return new EnumConverter<EntityUseAction>(EntityUseAction.class);
|
||||
}
|
||||
|
||||
public static EquivalentConverter<NativeGameMode> getGameModeConverter() {
|
||||
return new EnumConverter<NativeGameMode>(NativeGameMode.class);
|
||||
}
|
||||
|
||||
public static EquivalentConverter<ResourcePackStatus> getResourcePackStatusConverter() {
|
||||
return new EnumConverter<ResourcePackStatus>(ResourcePackStatus.class);
|
||||
}
|
||||
|
||||
// The common enum converter
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
private static class EnumConverter<T extends Enum<T>> implements EquivalentConverter<T> {
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren