/** * Gets the wrapped value of this data watcher item. * @return The wrapped value */ public Object getValue() { return getWrapped(getRawValue()); }
return getWrapped(new WrappedWatchableObject(value).getRawValue()); Optional<?> optional = (Optional<?>) value; if (optional.isPresent()) { return Optional.of(getWrapped(optional.get())); } else { return Optional.absent();
/** * Retrieve a watchable object by watcher object. * * @param object The watcher object * @return The watched object or null if it doesn't exist. */ public Object getObject(WrappedDataWatcherObject object) { Validate.notNull(object, "Watcher object cannot be null!"); if (GETTER == null) { FuzzyReflection fuzzy = FuzzyReflection.fromClass(handleType, true); if (MinecraftReflection.watcherObjectExists()) { GETTER = Accessors.getMethodAccessor(fuzzy.getMethod(FuzzyMethodContract.newBuilder() .parameterExactType(object.getHandleType()) .returnTypeExact(Object.class) .build(), "get")); } else { GETTER = Accessors.getMethodAccessor(fuzzy.getMethod(FuzzyMethodContract.newBuilder() .parameterExactType(int.class) .returnTypeExact(MinecraftReflection.getDataWatcherItemClass()) .build())); } } try { Object value = GETTER.invoke(handle, object.getHandle()); return WrappedWatchableObject.getWrapped(value); } catch (Exception ex) { // Nothing exists at this index return null; } }