mirror of
https://github.com/dmulloy2/ProtocolLib.git
synced 2024-11-24 11:36:51 +01:00
Merge pull request #13 from Sheigutn/master
Add PlayerInfoAction EnumWrapper
This commit is contained in:
commit
fa1d419b66
@ -80,6 +80,7 @@ import com.comphenix.protocol.wrappers.EnumWrappers.NativeGameMode;
|
|||||||
import com.comphenix.protocol.wrappers.EnumWrappers.ResourcePackStatus;
|
import com.comphenix.protocol.wrappers.EnumWrappers.ResourcePackStatus;
|
||||||
import com.comphenix.protocol.wrappers.EnumWrappers.TitleAction;
|
import com.comphenix.protocol.wrappers.EnumWrappers.TitleAction;
|
||||||
import com.comphenix.protocol.wrappers.EnumWrappers.WorldBorderAction;
|
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.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;
|
||||||
@ -704,6 +705,15 @@ public class PacketContainer implements Serializable {
|
|||||||
EnumWrappers.getResourcePackStatusClass(), EnumWrappers.getResourcePackStatusConverter());
|
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.
|
* Retrieve a read/write structure for the TitleAction enum in 1.8.
|
||||||
* @return A modifier for TitleAction enum fields.
|
* @return A modifier for TitleAction enum fields.
|
||||||
|
@ -1,15 +1,14 @@
|
|||||||
package com.comphenix.protocol.wrappers;
|
package com.comphenix.protocol.wrappers;
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.bukkit.GameMode;
|
|
||||||
|
|
||||||
import com.comphenix.protocol.PacketType;
|
import com.comphenix.protocol.PacketType;
|
||||||
import com.comphenix.protocol.PacketType.Protocol;
|
import com.comphenix.protocol.PacketType.Protocol;
|
||||||
import com.comphenix.protocol.reflect.EquivalentConverter;
|
import com.comphenix.protocol.reflect.EquivalentConverter;
|
||||||
import com.comphenix.protocol.reflect.FuzzyReflection;
|
import com.comphenix.protocol.reflect.FuzzyReflection;
|
||||||
import com.comphenix.protocol.utility.MinecraftReflection;
|
import com.comphenix.protocol.utility.MinecraftReflection;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
|
import org.bukkit.GameMode;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a generic enum converter.
|
* Represents a generic enum converter.
|
||||||
@ -67,6 +66,14 @@ public abstract class EnumWrappers {
|
|||||||
ACCEPTED;
|
ACCEPTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public enum PlayerInfoAction {
|
||||||
|
ADD_PLAYER,
|
||||||
|
UPDATE_GAMEMODE,
|
||||||
|
UPDATE_LATENCY,
|
||||||
|
UPDATE_DISPLAY_NAME,
|
||||||
|
REMOVE_PLAYER;
|
||||||
|
}
|
||||||
|
|
||||||
public enum TitleAction {
|
public enum TitleAction {
|
||||||
TITLE,
|
TITLE,
|
||||||
SUBTITLE,
|
SUBTITLE,
|
||||||
@ -97,6 +104,7 @@ public abstract class EnumWrappers {
|
|||||||
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 Class<?> RESOURCE_PACK_STATUS_CLASS = null;
|
||||||
|
private static Class<?> PLAYER_INFO_ACTION_CLASS = null;
|
||||||
private static Class<?> TITLE_ACTION_CLASS = null;
|
private static Class<?> TITLE_ACTION_CLASS = null;
|
||||||
private static Class<?> WORLD_BORDER_ACTION_CLASS = null;
|
private static Class<?> WORLD_BORDER_ACTION_CLASS = null;
|
||||||
private static Class<?> COMBAT_EVENT_TYPE_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);
|
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);
|
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);
|
TITLE_ACTION_CLASS = getEnum(PacketType.Play.Server.TITLE.getPacketClass(), 0);
|
||||||
WORLD_BORDER_ACTION_CLASS = getEnum(PacketType.Play.Server.WORLD_BORDER.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);
|
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(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());
|
associate(RESOURCE_PACK_STATUS_CLASS, ResourcePackStatus.class, getResourcePackStatusConverter());
|
||||||
|
associate(PLAYER_INFO_ACTION_CLASS, PlayerInfoAction.class, getPlayerInfoActionConverter());
|
||||||
associate(TITLE_ACTION_CLASS, TitleAction.class, getTitleActionConverter());
|
associate(TITLE_ACTION_CLASS, TitleAction.class, getTitleActionConverter());
|
||||||
associate(WORLD_BORDER_ACTION_CLASS, WorldBorderAction.class, getWorldBorderActionConverter());
|
associate(WORLD_BORDER_ACTION_CLASS, WorldBorderAction.class, getWorldBorderActionConverter());
|
||||||
associate(COMBAT_EVENT_TYPE_CLASS, CombatEventType.class, getCombatEventTypeConverter());
|
associate(COMBAT_EVENT_TYPE_CLASS, CombatEventType.class, getCombatEventTypeConverter());
|
||||||
@ -198,6 +208,11 @@ public abstract class EnumWrappers {
|
|||||||
return RESOURCE_PACK_STATUS_CLASS;
|
return RESOURCE_PACK_STATUS_CLASS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Class<?> getPlayerInfoActionClass() {
|
||||||
|
initialize();
|
||||||
|
return PLAYER_INFO_ACTION_CLASS;
|
||||||
|
}
|
||||||
|
|
||||||
public static Class<?> getTitleActionClass() {
|
public static Class<?> getTitleActionClass() {
|
||||||
initialize();
|
initialize();
|
||||||
return TITLE_ACTION_CLASS;
|
return TITLE_ACTION_CLASS;
|
||||||
@ -242,6 +257,10 @@ public abstract class EnumWrappers {
|
|||||||
return new EnumConverter<ResourcePackStatus>(ResourcePackStatus.class);
|
return new EnumConverter<ResourcePackStatus>(ResourcePackStatus.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static EquivalentConverter<PlayerInfoAction> getPlayerInfoActionConverter() {
|
||||||
|
return new EnumConverter<PlayerInfoAction>(PlayerInfoAction.class);
|
||||||
|
}
|
||||||
|
|
||||||
public static EquivalentConverter<TitleAction> getTitleActionConverter() {
|
public static EquivalentConverter<TitleAction> getTitleActionConverter() {
|
||||||
return new EnumConverter<TitleAction>(TitleAction.class);
|
return new EnumConverter<TitleAction>(TitleAction.class);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user