Ejemplo n.º 1
0
  public static List<Property> getProperties(dObject object) {
    List<Property> props = new ArrayList<Property>();

    try {
      if (properties.containsKey(object.getClass())) {
        for (Class property : properties.get(object.getClass())) {
          if ((Boolean) describes.get(property).invoke(null, object))
            props.add((Property) getFrom.get(property).invoke(null, object));
        }
      }

    } catch (IllegalAccessException e) {
      dB.echoError(e);
    } catch (InvocationTargetException e) {
      dB.echoError(e);
    }

    return props;
  }
Ejemplo n.º 2
0
  public void registerProperty(Class property, Class<? extends dObject> object) {
    // Add property to the dObject's Properties list
    List<Class> prop_list;

    // Get current properties list, or make a new one
    if (properties.containsKey(object)) prop_list = properties.get(object);
    else prop_list = new ArrayList<Class>();

    // Add this property to the list
    prop_list.add(property);

    // Put the list back into the Map
    properties.put(object, prop_list);

    // Cache methods used for fetching new properties
    try {
      describes.put(property, property.getMethod("describes", dObject.class));
      getFrom.put(property, property.getMethod("getFrom", dObject.class));

    } catch (NoSuchMethodException e) {
      dB.echoError("Unable to register property '" + property.getSimpleName() + "'!");
    }
  }
Ejemplo n.º 3
0
  public PropertyParser() {
    properties.clear();
    describes.clear();
    getFrom.clear();

    // register core dEntity properties
    registerProperty(EntityAge.class, dEntity.class);
    registerProperty(EntityColor.class, dEntity.class);
    registerProperty(EntityFramed.class, dEntity.class);
    registerProperty(EntityInfected.class, dEntity.class);
    registerProperty(EntityPotion.class, dEntity.class);
    registerProperty(EntityCritical.class, dEntity.class);
    registerProperty(EntityPowered.class, dEntity.class);
    registerProperty(EntityProfession.class, dEntity.class);
    registerProperty(EntitySize.class, dEntity.class);
    registerProperty(EntityTame.class, dEntity.class);

    // register core dInventory properties
    registerProperty(InventoryContents.class, dInventory.class);
    registerProperty(InventoryHolder.class, dInventory.class);
    registerProperty(InventorySize.class, dInventory.class);
    registerProperty(InventoryTitle.class, dInventory.class);

    // register core dItem properties
    registerProperty(ItemApple.class, dItem.class);
    registerProperty(ItemBook.class, dItem.class);
    registerProperty(ItemDisplayname.class, dItem.class);
    registerProperty(ItemDurability.class, dItem.class);
    registerProperty(ItemDye.class, dItem.class);
    registerProperty(ItemEnchantments.class, dItem.class);
    registerProperty(ItemLore.class, dItem.class);
    registerProperty(ItemPlantgrowth.class, dItem.class);
    registerProperty(ItemPotion.class, dItem.class);
    registerProperty(ItemQuantity.class, dItem.class);
    registerProperty(ItemSkullskin.class, dItem.class);
  }