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.Difficulty;
|
||||||
import com.comphenix.protocol.wrappers.EnumWrappers.EntityUseAction;
|
import com.comphenix.protocol.wrappers.EnumWrappers.EntityUseAction;
|
||||||
import com.comphenix.protocol.wrappers.EnumWrappers.NativeGameMode;
|
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.WrappedAttribute;
|
||||||
import com.comphenix.protocol.wrappers.WrappedChatComponent;
|
import com.comphenix.protocol.wrappers.WrappedChatComponent;
|
||||||
import com.comphenix.protocol.wrappers.WrappedDataWatcher;
|
import com.comphenix.protocol.wrappers.WrappedDataWatcher;
|
||||||
@ -690,6 +691,16 @@ public class PacketContainer implements Serializable {
|
|||||||
EnumWrappers.getGameModeClass(), EnumWrappers.getGameModeConverter());
|
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.
|
* Retrieves the ID of this packet.
|
||||||
* <p>
|
* <p>
|
||||||
|
@ -60,13 +60,22 @@ public abstract class EnumWrappers {
|
|||||||
NONE;
|
NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public enum ResourcePackStatus {
|
||||||
|
SUCCESSFULLY_LOADED,
|
||||||
|
DECLINED,
|
||||||
|
FAILED_DOWNLOAD,
|
||||||
|
ACCEPTED;
|
||||||
|
}
|
||||||
|
|
||||||
private static Class<?> PROTOCOL_CLASS = null;
|
private static Class<?> PROTOCOL_CLASS = null;
|
||||||
private static Class<?> CLIENT_COMMAND_CLASS = null;
|
private static Class<?> CLIENT_COMMAND_CLASS = null;
|
||||||
private static Class<?> CHAT_VISIBILITY_CLASS = null;
|
private static Class<?> CHAT_VISIBILITY_CLASS = null;
|
||||||
private static Class<?> DIFFICULTY_CLASS = null;
|
private static Class<?> DIFFICULTY_CLASS = null;
|
||||||
private static Class<?> ENTITY_USE_ACTION_CLASS = null;
|
private static Class<?> ENTITY_USE_ACTION_CLASS = null;
|
||||||
private static Class<?> GAMEMODE_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_NATIVE = Maps.newHashMap();
|
||||||
private static Map<Class<?>, EquivalentConverter<?>> FROM_WRAPPER = Maps.newHashMap();
|
private static Map<Class<?>, EquivalentConverter<?>> FROM_WRAPPER = Maps.newHashMap();
|
||||||
|
|
||||||
@ -77,12 +86,16 @@ public abstract class EnumWrappers {
|
|||||||
if (!MinecraftReflection.isUsingNetty())
|
if (!MinecraftReflection.isUsingNetty())
|
||||||
throw new IllegalArgumentException("Not supported on 1.6.4 and earlier.");
|
throw new IllegalArgumentException("Not supported on 1.6.4 and earlier.");
|
||||||
|
|
||||||
|
if (INITIALIZED)
|
||||||
|
return;
|
||||||
|
|
||||||
PROTOCOL_CLASS = getEnum(PacketType.Handshake.Client.SET_PROTOCOL.getPacketClass(), 0);
|
PROTOCOL_CLASS = getEnum(PacketType.Handshake.Client.SET_PROTOCOL.getPacketClass(), 0);
|
||||||
CLIENT_COMMAND_CLASS = getEnum(PacketType.Play.Client.CLIENT_COMMAND.getPacketClass(), 0);
|
CLIENT_COMMAND_CLASS = getEnum(PacketType.Play.Client.CLIENT_COMMAND.getPacketClass(), 0);
|
||||||
CHAT_VISIBILITY_CLASS = getEnum(PacketType.Play.Client.SETTINGS.getPacketClass(), 0);
|
CHAT_VISIBILITY_CLASS = getEnum(PacketType.Play.Client.SETTINGS.getPacketClass(), 0);
|
||||||
DIFFICULTY_CLASS = getEnum(PacketType.Play.Server.LOGIN.getPacketClass(), 1);
|
DIFFICULTY_CLASS = getEnum(PacketType.Play.Server.LOGIN.getPacketClass(), 1);
|
||||||
ENTITY_USE_ACTION_CLASS = getEnum(PacketType.Play.Client.USE_ENTITY.getPacketClass(), 0);
|
ENTITY_USE_ACTION_CLASS = getEnum(PacketType.Play.Client.USE_ENTITY.getPacketClass(), 0);
|
||||||
GAMEMODE_CLASS = getEnum(PacketType.Play.Server.LOGIN.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(PROTOCOL_CLASS, Protocol.class, getClientCommandConverter());
|
||||||
associate(CLIENT_COMMAND_CLASS, ClientCommand.class, getClientCommandConverter());
|
associate(CLIENT_COMMAND_CLASS, ClientCommand.class, getClientCommandConverter());
|
||||||
@ -90,6 +103,8 @@ public abstract class EnumWrappers {
|
|||||||
associate(DIFFICULTY_CLASS, Difficulty.class, getDifficultyConverter());
|
associate(DIFFICULTY_CLASS, Difficulty.class, getDifficultyConverter());
|
||||||
associate(ENTITY_USE_ACTION_CLASS, EntityUseAction.class, getEntityUseActionConverter());
|
associate(ENTITY_USE_ACTION_CLASS, EntityUseAction.class, getEntityUseActionConverter());
|
||||||
associate(GAMEMODE_CLASS, NativeGameMode.class, getGameModeConverter());
|
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) {
|
private static void associate(Class<?> nativeClass, Class<?> wrapperClass, EquivalentConverter<?> converter) {
|
||||||
@ -120,49 +135,68 @@ public abstract class EnumWrappers {
|
|||||||
initialize();
|
initialize();
|
||||||
return PROTOCOL_CLASS;
|
return PROTOCOL_CLASS;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Class<?> getClientCommandClass() {
|
public static Class<?> getClientCommandClass() {
|
||||||
initialize();
|
initialize();
|
||||||
return CLIENT_COMMAND_CLASS;
|
return CLIENT_COMMAND_CLASS;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Class<?> getChatVisibilityClass() {
|
public static Class<?> getChatVisibilityClass() {
|
||||||
initialize();
|
initialize();
|
||||||
return CHAT_VISIBILITY_CLASS;
|
return CHAT_VISIBILITY_CLASS;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Class<?> getDifficultyClass() {
|
public static Class<?> getDifficultyClass() {
|
||||||
initialize();
|
initialize();
|
||||||
return DIFFICULTY_CLASS;
|
return DIFFICULTY_CLASS;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Class<?> getEntityUseActionClass() {
|
public static Class<?> getEntityUseActionClass() {
|
||||||
initialize();
|
initialize();
|
||||||
return ENTITY_USE_ACTION_CLASS;
|
return ENTITY_USE_ACTION_CLASS;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Class<?> getGameModeClass() {
|
public static Class<?> getGameModeClass() {
|
||||||
initialize();
|
initialize();
|
||||||
return GAMEMODE_CLASS;
|
return GAMEMODE_CLASS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Class<?> getResourcePackStatusClass() {
|
||||||
|
initialize();
|
||||||
|
return RESOURCE_PACK_STATUS_CLASS;
|
||||||
|
}
|
||||||
|
|
||||||
// Get the converters
|
// Get the converters
|
||||||
public static EquivalentConverter<Protocol> getProtocolConverter() {
|
public static EquivalentConverter<Protocol> getProtocolConverter() {
|
||||||
return new EnumConverter<Protocol>(Protocol.class);
|
return new EnumConverter<Protocol>(Protocol.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static EquivalentConverter<ClientCommand> getClientCommandConverter() {
|
public static EquivalentConverter<ClientCommand> getClientCommandConverter() {
|
||||||
return new EnumConverter<ClientCommand>(ClientCommand.class);
|
return new EnumConverter<ClientCommand>(ClientCommand.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static EquivalentConverter<ChatVisibility> getChatVisibilityConverter() {
|
public static EquivalentConverter<ChatVisibility> getChatVisibilityConverter() {
|
||||||
return new EnumConverter<ChatVisibility>(ChatVisibility.class);
|
return new EnumConverter<ChatVisibility>(ChatVisibility.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static EquivalentConverter<Difficulty> getDifficultyConverter() {
|
public static EquivalentConverter<Difficulty> getDifficultyConverter() {
|
||||||
return new EnumConverter<Difficulty>(Difficulty.class);
|
return new EnumConverter<Difficulty>(Difficulty.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static EquivalentConverter<EntityUseAction> getEntityUseActionConverter() {
|
public static EquivalentConverter<EntityUseAction> getEntityUseActionConverter() {
|
||||||
return new EnumConverter<EntityUseAction>(EntityUseAction.class);
|
return new EnumConverter<EntityUseAction>(EntityUseAction.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static EquivalentConverter<NativeGameMode> getGameModeConverter() {
|
public static EquivalentConverter<NativeGameMode> getGameModeConverter() {
|
||||||
return new EnumConverter<NativeGameMode>(NativeGameMode.class);
|
return new EnumConverter<NativeGameMode>(NativeGameMode.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static EquivalentConverter<ResourcePackStatus> getResourcePackStatusConverter() {
|
||||||
|
return new EnumConverter<ResourcePackStatus>(ResourcePackStatus.class);
|
||||||
|
}
|
||||||
|
|
||||||
// The common enum converter
|
// The common enum converter
|
||||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||||
private static class EnumConverter<T extends Enum<T>> implements EquivalentConverter<T> {
|
private static class EnumConverter<T extends Enum<T>> implements EquivalentConverter<T> {
|
||||||
private Class<T> specificType;
|
private Class<T> specificType;
|
||||||
|
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren