Package com.comphenix.protocol.reflect

Examples of com.comphenix.protocol.reflect.FieldAccessException


        }
      }
      return result;
     
    } catch (IllegalAccessException e) {
      throw new FieldAccessException("Security limitation prevented access to the list of tracked players.", e);
    } catch (InvocationTargetException e) {
      throw new FieldAccessException("Exception occurred in Minecraft.", e);
    }
  }
View Full Code Here


    Object tracker = null;
   
    try {
      tracker = FieldUtils.readField(entityTrackerField, worldServer, false);
    } catch (IllegalAccessException e) {
      throw new FieldAccessException("Cannot access 'tracker' field due to security limitations.", e);
    }
   
    if (trackedEntitiesField == null) {
      @SuppressWarnings("rawtypes")
      Set<Class> ignoredTypes = new HashSet<Class>();
     
      // Well, this is more difficult. But we're looking for a Minecraft object that is not
      // created by the constructor(s).
      for (Constructor<?> constructor : tracker.getClass().getConstructors()) {
        for (Class<?> type : constructor.getParameterTypes()) {
          ignoredTypes.add(type);
        }
      }
     
      // The Minecraft field that's NOT filled in by the constructor
      trackedEntitiesField = FuzzyReflection.fromObject(tracker, true).
            getFieldByType(MinecraftReflection.getMinecraftObjectRegex(), ignoredTypes);
    }
   
    // Read the entity hashmap
    Object trackedEntities = null;
   
    try {
      trackedEntities = FieldUtils.readField(trackedEntitiesField, tracker, true);
    } catch (IllegalAccessException e) {
      throw new FieldAccessException("Cannot access 'trackedEntities' field due to security limitations.", e);
    }
   
    return WrappedIntHashMap.fromHandle(trackedEntities).get(entityID);
  }
View Full Code Here

        return (Entity) MinecraftReflection.getBukkitEntity(tracker);
      else
        return null;
     
    } catch (Exception e) {
      throw new FieldAccessException("Cannot find entity from ID " + entityID + ".", e);
    }
  }
View Full Code Here

    try {
      // Now we are probably able to check for Netty
      InjectedServerConnection inspector = new InjectedServerConnection(reporter, null, server, null);
      return inspector.getServerConnection();
    } catch (IllegalAccessException e) {
      throw new FieldAccessException("Reflection error.", e);
    } catch (IllegalArgumentException e) {
      throw new FieldAccessException("Corrupt data.", e);
    } catch (InvocationTargetException e) {
      throw new FieldAccessException("Minecraft error.", e);
    }
  }
View Full Code Here

    if (BUILD_METHOD == null) {
      try {
        BUILD_METHOD = builder.getClass().getDeclaredMethod("build", CacheLoader.class);
        BUILD_METHOD.setAccessible(true);
      } catch (Exception e) {
        throw new FieldAccessException("Unable to find CacheBuilder.build(CacheLoader)", e);
      }
    }
   
    // Attempt to build the Cache
    try {
      cache = BUILD_METHOD.invoke(builder, loader);
    } catch (Exception e) {
      throw new FieldAccessException("Unable to invoke " + BUILD_METHOD + " on " + builder, e);
    }
   
    if (AS_MAP_METHOD == null) {
      try {
        AS_MAP_METHOD = cache.getClass().getMethod("asMap");
        AS_MAP_METHOD.setAccessible(true);
      } catch (Exception e) {
        throw new FieldAccessException("Unable to find Cache.asMap() in " + cache, e);
      }
    }
   
    // Retrieve it as a map
    try {
      return (ConcurrentMap<K1, V1>) AS_MAP_METHOD.invoke(cache);
    } catch (Exception e) {
      throw new FieldAccessException("Unable to invoke " + AS_MAP_METHOD + " on " + cache, e);
    }
  }
View Full Code Here

          if (field.get(null) == type) {
            // We got the right field!
            return type.reportName = field.getDeclaringClass().getCanonicalName() + "#" + field.getName();
          }
        } catch (IllegalAccessException e) {
          throw new FieldAccessException("Unable to read field " + field, e);
        }
      }
      throw new IllegalArgumentException("Cannot find report name for " + type);
    }
    return type.reportName;
View Full Code Here

    for (Field field : getReportFields(sender)) {
      try {
        field.setAccessible(true);
        result.add((ReportType) field.get(null));
      } catch (IllegalAccessException e) {
        throw new FieldAccessException("Unable to read field " + field, e);
      }
    }
    return result.toArray(new ReportType[0]);
  }
View Full Code Here

      if (address != null)
        return waitSocketInjector(address);
      else
        return null;
    } catch (IllegalAccessException e) {
      throw new FieldAccessException("Cannot find or access socket field for " + input, e);
    }
  }
View Full Code Here

      while (current instanceof FilterInputStream) {
        current = (InputStream) FieldUtils.readField(filteredInputField, current, true);
      }
      return current;
    } catch (IllegalAccessException e) {
      throw new FieldAccessException("Cannot access filtered input field.", e);
    }
  }
View Full Code Here

TOP

Related Classes of com.comphenix.protocol.reflect.FieldAccessException

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.