Package com.comphenix.protocol.reflect.accessors

Examples of com.comphenix.protocol.reflect.accessors.FieldAccessor


    TileEntityAccessor<?> accessor = cachedAccessors.get(craftBlockState);
   
    // Attempt to construct the accessor
    if (accessor == null ) {
      TileEntityAccessor<?> created = null;
      FieldAccessor field = null;
     
      try {
        field = Accessors.getFieldAccessor(craftBlockState, MinecraftReflection.getTileEntityClass(), true);
      } catch (Exception e) {
        created = EMPTY_ACCESSOR;
View Full Code Here


   * Note that this may not exist in the current Minecraft version.
   * @param player - the player.
   * @return The game profile.
   */
  public static WrappedGameProfile fromPlayer(Player player) {
    FieldAccessor accessor = PLAYER_PROFILE;
    Object nmsPlayer = BukkitUnwrapper.getInstance().unwrapItem(player);
   
    if (accessor == null) {
      accessor = Accessors.getFieldAccessor(MinecraftReflection.getEntityHumanClass(), GameProfile.class, true);
      PLAYER_PROFILE = accessor;
View Full Code Here

   * Note that this may not exist in the current Minecraft version.
   * @param player - the offline player.
   * @return The game profile.
   */
  public static WrappedGameProfile fromOfflinePlayer(OfflinePlayer player) {
    FieldAccessor accessor = OFFLINE_PROFILE;
   
    if (accessor == null) {
      accessor = Accessors.getFieldAccessor(player.getClass(), GameProfile.class, true);
      OFFLINE_PROFILE = accessor;
    }
View Full Code Here

   * @param packetClass - the packet class.
   * @param packet - the packet.
   */
  protected void handleLogin(Class<?> packetClass, Object packet) {
    Class<?> loginClass = PACKET_LOGIN_CLIENT;
    FieldAccessor loginClient = LOGIN_GAME_PROFILE;
   
    // Initialize packet class and login
    if (loginClass == null) {
      loginClass = PacketType.Login.Client.START.getPacketClass();
      PACKET_LOGIN_CLIENT = loginClass;
    }
    if (loginClient == null) {
      loginClient = Accessors.getFieldAccessor(PACKET_LOGIN_CLIENT, GameProfile.class, true);
      LOGIN_GAME_PROFILE = loginClient;
    }
     
    // See if we are dealing with the login packet
    if (loginClass.equals(packetClass)) {
      GameProfile profile = (GameProfile) loginClient.get(packet);
     
      // Save the channel injector
      factory.cacheInjector(profile.getName(), this);
    }
  }
View Full Code Here

          return delegate.eventLoop();
        }
       
        @Override
        protected Runnable schedulingRunnable(final Runnable runnable) {
          final FieldAccessor accessor = getMessageAccessor(runnable);
         
          if (accessor != null) {
            Runnable result = onMessageScheduled(runnable, accessor);;
            return result != null ? result : getEmptyRunnable();
          }
          return runnable;
        }
       
        @Override
        protected <T> Callable<T> schedulingCallable(Callable<T> callable) {
          FieldAccessor accessor = getMessageAccessor(callable);
         
          if (accessor != null) {
            Callable<T> result = onMessageScheduled(callable, accessor);;
            return result != null ? result : EventLoopProxy.<T>getEmptyCallable();
          }
View Full Code Here

   * @param value - the object.
   * @return The packet field accessor, or NULL if not found.
   */
  private FieldAccessor getMessageAccessor(Object value) { 
    Class<?> clazz = value.getClass();
    FieldAccessor accessor = MESSAGE_LOOKUP.get(clazz);
   
    if (accessor == null) {
      try {
        accessor = Accessors.getFieldAccessor(clazz, messageClass, true);
      } catch (IllegalArgumentException e) {
View Full Code Here

    assertEquals(obj.mode, roundtrip(obj, "mode", EnumWrappers.getGameModeConverter()) );
  }

  @SuppressWarnings("unchecked")
  public <T extends Enum<T>> T roundtrip(Object target, String fieldName, EquivalentConverter<T> converter) {
    FieldAccessor accessor = Accessors.getFieldAccessor(target.getClass(), fieldName, true);
   
    return (T) converter.getGeneric(
      accessor.getField().getType(),
      converter.getSpecific(accessor.get(target))
    );
  }
View Full Code Here

TOP

Related Classes of com.comphenix.protocol.reflect.accessors.FieldAccessor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.