MCPcopy Create free account
hub / github.com/boxbeam/RedLib / setField

Method setField

src/redempt/redlib/nms/NMSObject.java:115–126  ·  view source on GitHub ↗

Sets the value stored in a field in the wrapped object @param name The name of the field @param supers The number of superclasses to move up before getting the declared field @param obj The object to set. Will be unwrapped if it is an NMSObject.

(int supers, String name, Object obj)

Source from the content-addressed store, hash-verified

113 * @param obj The object to set. Will be unwrapped if it is an NMSObject.
114 */
115 public void setField(int supers, String name, Object obj) {
116 if (obj instanceof NMSObject) {
117 obj = ((NMSObject) obj).getObject();
118 }
119 try {
120 Field field = getSuperclass(this.obj.getClass(), supers).getDeclaredField(name);
121 field.setAccessible(true);
122 field.set(this.obj, obj);
123 } catch (IllegalAccessException | NoSuchFieldException e) {
124 throw new IllegalArgumentException(e);
125 }
126 }
127
128 /**
129 * Sets the value stored in a field in the wrapped object

Callers

nothing calls this directly

Calls 4

getSuperclassMethod · 0.95
getClassMethod · 0.80
setMethod · 0.65
getObjectMethod · 0.45

Tested by

no test coverage detected