Package com.comphenix.protocol.reflect

Examples of com.comphenix.protocol.reflect.FuzzyReflection


    return highest;
  }

  @Override
  public boolean isMatch(Class<?> value, Object parent) {
    FuzzyReflection reflection = FuzzyReflection.fromClass(value, true);
   
    // Make sure all the contracts are valid
    return (fieldContracts.size() == 0 ||
          processContracts(reflection.getFields(), value, fieldContracts)) &&
         (methodContracts.size() == 0 ||
              processContracts(MethodInfo.fromMethods(reflection.getMethods()), value, methodContracts)) &&
         (constructorContracts.size() == 0 ||
             processContracts(MethodInfo.fromConstructors(value.getDeclaredConstructors()), value, constructorContracts)) &&
         (baseclassContracts.size() == 0 ||
             processValue(value.getSuperclass(), parent, baseclassContracts)) &&
         (interfaceContracts.size() == 0 ||
View Full Code Here


    if (!HAS_INITIALIZED)
      HAS_INITIALIZED = true;
    else
      return;
   
    FuzzyReflection fuzzy = FuzzyReflection.fromClass(MinecraftReflection.getDataWatcherClass(), true);
   
    for (Field lookup : fuzzy.getFieldListByType(Map.class)) {
      if (Modifier.isStatic(lookup.getModifiers())) {
        // This must be the type map
        TYPE_MAP_ACCESSOR = Accessors.getFieldAccessor(lookup, true);
      } else {
        // If not, then we're probably dealing with the value map
        VALUE_MAP_ACCESSOR = Accessors.getFieldAccessor(lookup, true);
      }
    }
    // Spigot workaround (not necessary
    initializeSpigot(fuzzy);
   
    // Initialize static type type
    TYPE_MAP = (Map<Class<?>, Integer>) TYPE_MAP_ACCESSOR.get(null);
   
    try {
      READ_WRITE_LOCK_FIELD = fuzzy.getFieldByType("readWriteLock", ReadWriteLock.class);
    } catch (IllegalArgumentException e) {
      // It's not a big deal
    }
   
    // Check for the entity field as well
    if (MinecraftReflection.isUsingNetty()) {
      ENTITY_FIELD = fuzzy.getFieldByType("entity", MinecraftReflection.getEntityClass());
      ENTITY_FIELD.setAccessible(true);
    }
    initializeMethods(fuzzy);
  }
View Full Code Here

    public void setLookup(int packetID, Class<?> clazz) {
      array[packetID] = clazz;
    }

    private void initialize() throws IllegalAccessException {
      FuzzyReflection reflection = FuzzyReflection.fromClass(MinecraftReflection.getPacketClass());
     
      // Is there a Class array with 256 elements instead?
      for (Field field : reflection.getFieldListByType(Class[].class)) {
        Class<?>[] test = (Class<?>[]) FieldUtils.readField(field, (Object)null);
       
        if (test.length == 256) {
          array = test;
          return;
View Full Code Here

        hasProxyType = true;
        reporter.reportWarning(this, Report.newBuilder(REPORT_DETECTED_CUSTOM_SERVER_HANDLER).callerParam(serverField));
       
        // No? Is it a Proxy type?
        try {
          FuzzyReflection reflection = FuzzyReflection.fromObject(currentHandler, true);
         
          // It might be
          return reflection.getFieldByType("NetServerHandler", MinecraftReflection.getNetServerHandlerClass());
         
        } catch (RuntimeException e) {
          // Damn
        }
      }
View Full Code Here

   */
  public static Class<?> getBlockClass() {
    try {
      return getMinecraftClass("Block");
    } catch (RuntimeException e) {
      FuzzyReflection reflect = FuzzyReflection.fromClass(getItemStackClass());
      Set<Class<?>> candidates = new HashSet<Class<?>>();
     
      // Minecraft objects in the constructor
      for (Constructor<?> constructor : reflect.getConstructors()) {
        for (Class<?> clazz : constructor.getParameterTypes()) {
          if (isMinecraftClass(clazz)) {
            candidates.add(clazz);
          }
        }
      }
     
      // Useful constructors
      Method selected =
            reflect.getMethod(FuzzyMethodContract.newBuilder().
              parameterMatches(FuzzyMatchers.matchAnyOf(candidates)).
              returnTypeExact(float.class).
            build());
      return setMinecraftClass("Block", selected.getParameterTypes()[0]);
    }
View Full Code Here

   * @param source - class source.
   * @param params - parameters.
   * @return Method mapped list.
   */
  private static Map<String, Method> getMethodList(Class<?> source, Class<?>... params) {
    FuzzyReflection reflect = FuzzyReflection.fromClass(source, true);
   
    return reflect.getMappedMethods(
      reflect.getMethodListByParameters(Void.TYPE, params)
    );
  }
View Full Code Here

    @SuppressWarnings("unchecked")
  public synchronized void inject() {
        if (injected)
            throw new IllegalStateException("Cannot inject twice.");
        try {
          FuzzyReflection fuzzyServer = FuzzyReflection.fromClass(MinecraftReflection.getMinecraftServerClass());
            List<Method> serverConnectionMethods = fuzzyServer.getMethodListByParameters(MinecraftReflection.getServerConnectionClass(), new Class[] {});
           
            // Get the server connection
            Object server = fuzzyServer.getSingleton();
            Object serverConnection = null;
           
            for (Method method : serverConnectionMethods) {
              try {
                serverConnection = method.invoke(server);
View Full Code Here

TOP

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

Copyright © 2015 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.