Add PlayerInfoAction EnumWrapper

This commit is contained in:
Flo // Sheigutn 2014-12-02 19:29:10 +01:00
parent 954a37a261
commit ea734965bc
2 changed files with 34 additions and 5 deletions

View File

@ -80,6 +80,7 @@ import com.comphenix.protocol.wrappers.EnumWrappers.NativeGameMode;
import com.comphenix.protocol.wrappers.EnumWrappers.ResourcePackStatus;
import com.comphenix.protocol.wrappers.EnumWrappers.TitleAction;
import com.comphenix.protocol.wrappers.EnumWrappers.WorldBorderAction;
import com.comphenix.protocol.wrappers.EnumWrappers.PlayerInfoAction;
import com.comphenix.protocol.wrappers.WrappedAttribute;
import com.comphenix.protocol.wrappers.WrappedChatComponent;
import com.comphenix.protocol.wrappers.WrappedDataWatcher;
@ -683,7 +684,7 @@ public class PacketContainer implements Serializable {
return structureModifier.<EntityUseAction>withType(
EnumWrappers.getEntityUseActionClass(), EnumWrappers.getEntityUseActionConverter());
}
/**
* Retrieve a read/write structure for the NativeGameMode enum in 1.7.2.
* @return A modifier for NativeGameMode enum fields.
@ -704,6 +705,15 @@ public class PacketContainer implements Serializable {
EnumWrappers.getResourcePackStatusClass(), EnumWrappers.getResourcePackStatusConverter());
}
/**
* Retrieve a read/write structure for the PlayerInfo enum in 1.8
* @return A modifier for PlayerInfoAction enum fields.
*/
public StructureModifier<PlayerInfoAction> getPlayerInfoAction() {
// Convert to and from the wrapper
return structureModifier.<PlayerInfoAction>withType(
EnumWrappers.getPlayerInfoActionClass(), EnumWrappers.getPlayerInfoActionConverter());
}
/**
* Retrieve a read/write structure for the TitleAction enum in 1.8.
* @return A modifier for TitleAction enum fields.

View File

@ -1,15 +1,14 @@
package com.comphenix.protocol.wrappers;
import java.util.Map;
import org.bukkit.GameMode;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.PacketType.Protocol;
import com.comphenix.protocol.reflect.EquivalentConverter;
import com.comphenix.protocol.reflect.FuzzyReflection;
import com.comphenix.protocol.utility.MinecraftReflection;
import com.google.common.collect.Maps;
import org.bukkit.GameMode;
import java.util.Map;
/**
* Represents a generic enum converter.
@ -67,6 +66,14 @@ public abstract class EnumWrappers {
ACCEPTED;
}
public enum PlayerInfoAction {
ADD_PLAYER,
UPDATE_GAMEMODE,
UPDATE_LATENCY,
UPDATE_DISPLAY_NAME,
REMOVE_PLAYER;
}
public enum TitleAction {
TITLE,
SUBTITLE,
@ -97,6 +104,7 @@ public abstract class EnumWrappers {
private static Class<?> ENTITY_USE_ACTION_CLASS = null;
private static Class<?> GAMEMODE_CLASS = null;
private static Class<?> RESOURCE_PACK_STATUS_CLASS = null;
private static Class<?> PLAYER_INFO_ACTION_CLASS = null;
private static Class<?> TITLE_ACTION_CLASS = null;
private static Class<?> WORLD_BORDER_ACTION_CLASS = null;
private static Class<?> COMBAT_EVENT_TYPE_CLASS = null;
@ -122,6 +130,7 @@ public abstract class EnumWrappers {
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);
PLAYER_INFO_ACTION_CLASS = getEnum(PacketType.Play.Server.PLAYER_INFO.getPacketClass(), 0);
TITLE_ACTION_CLASS = getEnum(PacketType.Play.Server.TITLE.getPacketClass(), 0);
WORLD_BORDER_ACTION_CLASS = getEnum(PacketType.Play.Server.WORLD_BORDER.getPacketClass(), 0);
COMBAT_EVENT_TYPE_CLASS = getEnum(PacketType.Play.Server.COMBAT_EVENT.getPacketClass(), 0);
@ -133,6 +142,7 @@ public abstract class EnumWrappers {
associate(ENTITY_USE_ACTION_CLASS, EntityUseAction.class, getEntityUseActionConverter());
associate(GAMEMODE_CLASS, NativeGameMode.class, getGameModeConverter());
associate(RESOURCE_PACK_STATUS_CLASS, ResourcePackStatus.class, getResourcePackStatusConverter());
associate(PLAYER_INFO_ACTION_CLASS, PlayerInfoAction.class, getPlayerInfoActionConverter());
associate(TITLE_ACTION_CLASS, TitleAction.class, getTitleActionConverter());
associate(WORLD_BORDER_ACTION_CLASS, WorldBorderAction.class, getWorldBorderActionConverter());
associate(COMBAT_EVENT_TYPE_CLASS, CombatEventType.class, getCombatEventTypeConverter());
@ -198,6 +208,11 @@ public abstract class EnumWrappers {
return RESOURCE_PACK_STATUS_CLASS;
}
public static Class<?> getPlayerInfoActionClass() {
initialize();
return PLAYER_INFO_ACTION_CLASS;
}
public static Class<?> getTitleActionClass() {
initialize();
return TITLE_ACTION_CLASS;
@ -242,6 +257,10 @@ public abstract class EnumWrappers {
return new EnumConverter<ResourcePackStatus>(ResourcePackStatus.class);
}
public static EquivalentConverter<PlayerInfoAction> getPlayerInfoActionConverter() {
return new EnumConverter<PlayerInfoAction>(PlayerInfoAction.class);
}
public static EquivalentConverter<TitleAction> getTitleActionConverter() {
return new EnumConverter<TitleAction>(TitleAction.class);
}