From 57a4c993a11420774cebeb615de09077db71f521 Mon Sep 17 00:00:00 2001 From: MattBDev <4009945+MattBDev@users.noreply.github.com> Date: Mon, 2 Mar 2020 22:53:50 -0500 Subject: [PATCH] Avoid reflection in MaskTraverser if possible --- .../java/com/boydti/fawe/util/MaskTraverser.java | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/worldedit-core/src/main/java/com/boydti/fawe/util/MaskTraverser.java b/worldedit-core/src/main/java/com/boydti/fawe/util/MaskTraverser.java index 24db5ec76..a5e4897ff 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/util/MaskTraverser.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/util/MaskTraverser.java @@ -2,6 +2,7 @@ package com.boydti.fawe.util; import com.boydti.fawe.object.mask.ResettableMask; import com.sk89q.worldedit.extent.Extent; +import com.sk89q.worldedit.function.mask.AbstractExtentMask; import com.sk89q.worldedit.function.mask.Mask; import java.lang.reflect.Field; import java.util.Collection; @@ -26,11 +27,16 @@ public class MaskTraverser { } Class current = mask.getClass(); while (current.getSuperclass() != null) { - try { - Field field = current.getDeclaredField("extent"); - field.setAccessible(true); - field.set(mask, newExtent); - } catch (NoSuchFieldException | IllegalAccessException ignored) { + if (mask instanceof AbstractExtentMask) { + AbstractExtentMask mask1 = (AbstractExtentMask) mask; + mask1.setExtent(newExtent); + } else { + try { + Field field = current.getDeclaredField("extent"); + field.setAccessible(true); + field.set(mask, newExtent); + } catch (NoSuchFieldException | IllegalAccessException ignored) { + } } try { Field field = current.getDeclaredField("mask");