mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-22 17:27:38 +00:00
Avoid reflection in MaskTraverser if possible
This commit is contained in:
parent
dd4d405b36
commit
57a4c993a1
@ -2,6 +2,7 @@ package com.boydti.fawe.util;
|
|||||||
|
|
||||||
import com.boydti.fawe.object.mask.ResettableMask;
|
import com.boydti.fawe.object.mask.ResettableMask;
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
|
import com.sk89q.worldedit.function.mask.AbstractExtentMask;
|
||||||
import com.sk89q.worldedit.function.mask.Mask;
|
import com.sk89q.worldedit.function.mask.Mask;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@ -26,11 +27,16 @@ public class MaskTraverser {
|
|||||||
}
|
}
|
||||||
Class<?> current = mask.getClass();
|
Class<?> current = mask.getClass();
|
||||||
while (current.getSuperclass() != null) {
|
while (current.getSuperclass() != null) {
|
||||||
try {
|
if (mask instanceof AbstractExtentMask) {
|
||||||
Field field = current.getDeclaredField("extent");
|
AbstractExtentMask mask1 = (AbstractExtentMask) mask;
|
||||||
field.setAccessible(true);
|
mask1.setExtent(newExtent);
|
||||||
field.set(mask, newExtent);
|
} else {
|
||||||
} catch (NoSuchFieldException | IllegalAccessException ignored) {
|
try {
|
||||||
|
Field field = current.getDeclaredField("extent");
|
||||||
|
field.setAccessible(true);
|
||||||
|
field.set(mask, newExtent);
|
||||||
|
} catch (NoSuchFieldException | IllegalAccessException ignored) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
Field field = current.getDeclaredField("mask");
|
Field field = current.getDeclaredField("mask");
|
||||||
|
Loading…
Reference in New Issue
Block a user