From e8f873cb9a67caf15fa19db5f44149d0bbd3ed54 Mon Sep 17 00:00:00 2001 From: Eric Date: Fri, 31 May 2019 15:50:47 +0200 Subject: [PATCH] Fix wrapping of non-primitive flags --- .../legacy/flag/WrappedPrimitiveFlag.java | 15 +++++++ .../legacy/region/WrappedRegion.java | 8 ++-- .../utility/WorldGuardFlagUtilities.java | 44 ++++++++++++++++++- implementation/v6/pom.xml | 6 +++ .../v6/flag/WrappedPrimitiveFlag.java | 15 +++++++ .../v6/region/WrappedRegion.java | 8 ++-- .../v6/utility/WorldGuardFlagUtilities.java | 41 ++++++++++++++++- .../v7/flag/WrappedPrimitiveFlag.java | 17 +++++++ .../v7/region/WrappedRegion.java | 8 ++-- .../v7/utility/WorldGuardFlagUtilities.java | 28 +++++++++++- .../v7fawe/flag/WrappedPrimitiveFlag.java | 17 +++++++ .../v7fawe/region/WrappedRegion.java | 8 ++-- .../utility/WorldGuardFlagUtilities.java | 27 +++++++++++- 13 files changed, 222 insertions(+), 20 deletions(-) diff --git a/implementation/legacy/src/main/java/org/codemc/worldguardwrapper/implementation/legacy/flag/WrappedPrimitiveFlag.java b/implementation/legacy/src/main/java/org/codemc/worldguardwrapper/implementation/legacy/flag/WrappedPrimitiveFlag.java index 154d99c..cd8d828 100644 --- a/implementation/legacy/src/main/java/org/codemc/worldguardwrapper/implementation/legacy/flag/WrappedPrimitiveFlag.java +++ b/implementation/legacy/src/main/java/org/codemc/worldguardwrapper/implementation/legacy/flag/WrappedPrimitiveFlag.java @@ -2,6 +2,10 @@ package org.codemc.worldguardwrapper.implementation.legacy.flag; import com.sk89q.worldguard.protection.flags.Flag; +import org.bukkit.Location; +import org.bukkit.util.Vector; +import org.codemc.worldguardwrapper.implementation.legacy.utility.WorldGuardFlagUtilities; + import java.util.Optional; public class WrappedPrimitiveFlag extends AbstractWrappedFlag { @@ -10,13 +14,24 @@ public class WrappedPrimitiveFlag extends AbstractWrappedFlag { super(handle); } + @SuppressWarnings("unchecked") @Override public Optional fromWGValue(Object value) { + if (value instanceof com.sk89q.worldedit.Location) { + return Optional.of((T) WorldGuardFlagUtilities.adaptLocation((com.sk89q.worldedit.Location) value)); + } else if (value instanceof com.sk89q.worldedit.Vector) { + return Optional.of((T) WorldGuardFlagUtilities.adaptVector((com.sk89q.worldedit.Vector) value)); + } return Optional.ofNullable((T) value); } @Override public Optional fromWrapperValue(T value) { + if (value instanceof Location) { + return Optional.of(WorldGuardFlagUtilities.adaptLocation((Location) value)); + } else if (value instanceof Vector) { + return Optional.of(WorldGuardFlagUtilities.adaptVector((Vector) value)); + } return Optional.ofNullable(value); } diff --git a/implementation/legacy/src/main/java/org/codemc/worldguardwrapper/implementation/legacy/region/WrappedRegion.java b/implementation/legacy/src/main/java/org/codemc/worldguardwrapper/implementation/legacy/region/WrappedRegion.java index 7c24898..62a9975 100644 --- a/implementation/legacy/src/main/java/org/codemc/worldguardwrapper/implementation/legacy/region/WrappedRegion.java +++ b/implementation/legacy/src/main/java/org/codemc/worldguardwrapper/implementation/legacy/region/WrappedRegion.java @@ -79,9 +79,11 @@ public class WrappedRegion implements IWrappedRegion { Map, Object> result = new HashMap<>(); handle.getFlags().forEach((flag, value) -> { if (value != null) { - IWrappedFlag wrappedFlag = WorldGuardFlagUtilities.wrap(flag, value.getClass()); - Optional wrappedValue = ((AbstractWrappedFlag) wrappedFlag).fromWGValue(value); - wrappedValue.ifPresent(val -> result.put(wrappedFlag, val)); + try { + IWrappedFlag wrappedFlag = WorldGuardFlagUtilities.wrapFixType(flag, value.getClass()); + Optional wrappedValue = ((AbstractWrappedFlag) wrappedFlag).fromWGValue(value); + wrappedValue.ifPresent(val -> result.put(wrappedFlag, val)); + } catch (IllegalArgumentException ignored) {/* Unsupported flag type */} } }); return result; diff --git a/implementation/legacy/src/main/java/org/codemc/worldguardwrapper/implementation/legacy/utility/WorldGuardFlagUtilities.java b/implementation/legacy/src/main/java/org/codemc/worldguardwrapper/implementation/legacy/utility/WorldGuardFlagUtilities.java index 5665e74..0813477 100644 --- a/implementation/legacy/src/main/java/org/codemc/worldguardwrapper/implementation/legacy/utility/WorldGuardFlagUtilities.java +++ b/implementation/legacy/src/main/java/org/codemc/worldguardwrapper/implementation/legacy/utility/WorldGuardFlagUtilities.java @@ -1,11 +1,13 @@ package org.codemc.worldguardwrapper.implementation.legacy.utility; -import java.util.Vector; - +import com.sk89q.worldedit.bukkit.BukkitWorld; import com.sk89q.worldguard.protection.flags.Flag; import com.sk89q.worldguard.protection.flags.StateFlag; +import org.bukkit.Bukkit; import org.bukkit.Location; +import org.bukkit.World; +import org.bukkit.util.Vector; import org.codemc.worldguardwrapper.flag.IWrappedFlag; import org.codemc.worldguardwrapper.flag.WrappedState; import org.codemc.worldguardwrapper.implementation.legacy.flag.WrappedPrimitiveFlag; @@ -42,4 +44,42 @@ public class WorldGuardFlagUtilities { return wrappedFlag; } + // Used when the flag's type is not known, so it has to be derived from a sample value's class + public IWrappedFlag wrapFixType(Flag flag, Class type) { + if (StateFlag.State.class.isAssignableFrom(type)) { + // StateFlag + type = WrappedState.class; + } else if (com.sk89q.worldedit.Location.class.isAssignableFrom(type)) { + // LocationFlag + type = org.bukkit.Location.class; + } else if (com.sk89q.worldedit.Vector.class.isAssignableFrom(type)) { + // VectorFlag + type = Vector.class; + } + + return wrap(flag, type); + } + + public Vector adaptVector(com.sk89q.worldedit.Vector vector) { + return new Vector(vector.getX(), vector.getY(), vector.getZ()); + } + + public com.sk89q.worldedit.Vector adaptVector(Vector vector) { + return new com.sk89q.worldedit.Vector(vector.getX(), vector.getY(), vector.getZ()); + } + + public Location adaptLocation(com.sk89q.worldedit.Location location) { + com.sk89q.worldedit.Vector pos = location.getPosition(); + World world = location.getWorld() instanceof BukkitWorld + ? ((BukkitWorld) location.getWorld()).getWorld() + : Bukkit.getWorld(location.getWorld().getName()); + + return new Location(world, pos.getX(), pos.getY(), pos.getZ()); + } + + public com.sk89q.worldedit.Location adaptLocation(Location location) { + return new com.sk89q.worldedit.Location(new BukkitWorld(location.getWorld()), + new com.sk89q.worldedit.Vector(location.getX(), location.getY(), location.getZ())); + } + } \ No newline at end of file diff --git a/implementation/v6/pom.xml b/implementation/v6/pom.xml index f975064..0ee5342 100644 --- a/implementation/v6/pom.xml +++ b/implementation/v6/pom.xml @@ -37,6 +37,12 @@ 6.2 provided + + com.sk89q.worldedit + worldedit-bukkit + 6.1.5 + provided + com.sk89q.worldedit worldedit-core diff --git a/implementation/v6/src/main/java/org/codemc/worldguardwrapper/implementation/v6/flag/WrappedPrimitiveFlag.java b/implementation/v6/src/main/java/org/codemc/worldguardwrapper/implementation/v6/flag/WrappedPrimitiveFlag.java index e0f41ff..0b13aff 100644 --- a/implementation/v6/src/main/java/org/codemc/worldguardwrapper/implementation/v6/flag/WrappedPrimitiveFlag.java +++ b/implementation/v6/src/main/java/org/codemc/worldguardwrapper/implementation/v6/flag/WrappedPrimitiveFlag.java @@ -2,6 +2,10 @@ package org.codemc.worldguardwrapper.implementation.v6.flag; import com.sk89q.worldguard.protection.flags.Flag; +import org.bukkit.Location; +import org.bukkit.util.Vector; +import org.codemc.worldguardwrapper.implementation.v6.utility.WorldGuardFlagUtilities; + import java.util.Optional; public class WrappedPrimitiveFlag extends AbstractWrappedFlag { @@ -10,13 +14,24 @@ public class WrappedPrimitiveFlag extends AbstractWrappedFlag { super(handle); } + @SuppressWarnings("unchecked") @Override public Optional fromWGValue(Object value) { + if (value instanceof com.sk89q.worldedit.util.Location) { + return Optional.of((T) WorldGuardFlagUtilities.adaptLocation((com.sk89q.worldedit.util.Location) value)); + } else if (value instanceof com.sk89q.worldedit.Vector) { + return Optional.of((T) WorldGuardFlagUtilities.adaptVector((com.sk89q.worldedit.Vector) value)); + } return Optional.ofNullable((T) value); } @Override public Optional fromWrapperValue(T value) { + if (value instanceof Location) { + return Optional.of(WorldGuardFlagUtilities.adaptLocation((Location) value)); + } else if (value instanceof Vector) { + return Optional.of(WorldGuardFlagUtilities.adaptVector((Vector) value)); + } return Optional.ofNullable(value); } diff --git a/implementation/v6/src/main/java/org/codemc/worldguardwrapper/implementation/v6/region/WrappedRegion.java b/implementation/v6/src/main/java/org/codemc/worldguardwrapper/implementation/v6/region/WrappedRegion.java index 6754abb..ce06403 100644 --- a/implementation/v6/src/main/java/org/codemc/worldguardwrapper/implementation/v6/region/WrappedRegion.java +++ b/implementation/v6/src/main/java/org/codemc/worldguardwrapper/implementation/v6/region/WrappedRegion.java @@ -79,9 +79,11 @@ public class WrappedRegion implements IWrappedRegion { Map, Object> result = new HashMap<>(); handle.getFlags().forEach((flag, value) -> { if (value != null) { - IWrappedFlag wrappedFlag = WorldGuardFlagUtilities.wrap(flag, value.getClass()); - Optional wrappedValue = ((AbstractWrappedFlag) wrappedFlag).fromWGValue(value); - wrappedValue.ifPresent(val -> result.put(wrappedFlag, val)); + try { + IWrappedFlag wrappedFlag = WorldGuardFlagUtilities.wrapFixType(flag, value.getClass()); + Optional wrappedValue = ((AbstractWrappedFlag) wrappedFlag).fromWGValue(value); + wrappedValue.ifPresent(val -> result.put(wrappedFlag, val)); + } catch (IllegalArgumentException ignored) {/* Unsupported flag type */} } }); return result; diff --git a/implementation/v6/src/main/java/org/codemc/worldguardwrapper/implementation/v6/utility/WorldGuardFlagUtilities.java b/implementation/v6/src/main/java/org/codemc/worldguardwrapper/implementation/v6/utility/WorldGuardFlagUtilities.java index 6782366..9ebae01 100644 --- a/implementation/v6/src/main/java/org/codemc/worldguardwrapper/implementation/v6/utility/WorldGuardFlagUtilities.java +++ b/implementation/v6/src/main/java/org/codemc/worldguardwrapper/implementation/v6/utility/WorldGuardFlagUtilities.java @@ -1,11 +1,12 @@ package org.codemc.worldguardwrapper.implementation.v6.utility; -import java.util.Vector; - +import com.sk89q.worldedit.bukkit.BukkitWorld; import com.sk89q.worldguard.protection.flags.Flag; import com.sk89q.worldguard.protection.flags.StateFlag; import org.bukkit.Location; +import org.bukkit.World; +import org.bukkit.util.Vector; import org.codemc.worldguardwrapper.flag.IWrappedFlag; import org.codemc.worldguardwrapper.flag.WrappedState; import org.codemc.worldguardwrapper.implementation.v6.flag.WrappedPrimitiveFlag; @@ -42,4 +43,40 @@ public class WorldGuardFlagUtilities { return wrappedFlag; } + // Used when the flag's type is not known, so it has to be derived from a sample value's class + public IWrappedFlag wrapFixType(Flag flag, Class type) { + if (StateFlag.State.class.isAssignableFrom(type)) { + // StateFlag + type = WrappedState.class; + } else if (com.sk89q.worldedit.util.Location.class.isAssignableFrom(type)) { + // LocationFlag + type = org.bukkit.Location.class; + } else if (com.sk89q.worldedit.Vector.class.isAssignableFrom(type)) { + // VectorFlag + type = Vector.class; + } + + return wrap(flag, type); + } + + public Vector adaptVector(com.sk89q.worldedit.Vector vector) { + return new Vector(vector.getX(), vector.getY(), vector.getZ()); + } + + public com.sk89q.worldedit.Vector adaptVector(Vector vector) { + return new com.sk89q.worldedit.Vector(vector.getX(), vector.getY(), vector.getZ()); + } + + public Location adaptLocation(com.sk89q.worldedit.util.Location location) { + World world = location.getExtent() instanceof BukkitWorld + ? ((BukkitWorld) location.getExtent()).getWorld() : null; + + return new Location(world, location.getX(), location.getY(), location.getZ()); + } + + public com.sk89q.worldedit.util.Location adaptLocation(Location location) { + return new com.sk89q.worldedit.util.Location(new BukkitWorld(location.getWorld()), + location.getX(), location.getY(), location.getZ()); + } + } \ No newline at end of file diff --git a/implementation/v7/src/main/java/org/codemc/worldguardwrapper/implementation/v7/flag/WrappedPrimitiveFlag.java b/implementation/v7/src/main/java/org/codemc/worldguardwrapper/implementation/v7/flag/WrappedPrimitiveFlag.java index e669c29..4874fc1 100644 --- a/implementation/v7/src/main/java/org/codemc/worldguardwrapper/implementation/v7/flag/WrappedPrimitiveFlag.java +++ b/implementation/v7/src/main/java/org/codemc/worldguardwrapper/implementation/v7/flag/WrappedPrimitiveFlag.java @@ -1,7 +1,13 @@ package org.codemc.worldguardwrapper.implementation.v7.flag; +import com.sk89q.worldedit.bukkit.BukkitAdapter; +import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldguard.protection.flags.Flag; +import org.bukkit.Location; +import org.bukkit.util.Vector; +import org.codemc.worldguardwrapper.implementation.v7.utility.WorldGuardFlagUtilities; + import java.util.Optional; public class WrappedPrimitiveFlag extends AbstractWrappedFlag { @@ -10,13 +16,24 @@ public class WrappedPrimitiveFlag extends AbstractWrappedFlag { super(handle); } + @SuppressWarnings("unchecked") @Override public Optional fromWGValue(Object value) { + if (value instanceof com.sk89q.worldedit.util.Location) { + return Optional.of((T) BukkitAdapter.adapt((com.sk89q.worldedit.util.Location) value)); + } else if (value instanceof Vector3) { + return Optional.of((T) WorldGuardFlagUtilities.adaptVector((Vector3) value)); + } return Optional.ofNullable((T) value); } @Override public Optional fromWrapperValue(T value) { + if (value instanceof Location) { + return Optional.of(BukkitAdapter.adapt((Location) value)); + } else if (value instanceof Vector) { + return Optional.of(WorldGuardFlagUtilities.adaptVector((Vector) value)); + } return Optional.ofNullable(value); } diff --git a/implementation/v7/src/main/java/org/codemc/worldguardwrapper/implementation/v7/region/WrappedRegion.java b/implementation/v7/src/main/java/org/codemc/worldguardwrapper/implementation/v7/region/WrappedRegion.java index 0cf7efb..ae7fc5e 100644 --- a/implementation/v7/src/main/java/org/codemc/worldguardwrapper/implementation/v7/region/WrappedRegion.java +++ b/implementation/v7/src/main/java/org/codemc/worldguardwrapper/implementation/v7/region/WrappedRegion.java @@ -79,9 +79,11 @@ public class WrappedRegion implements IWrappedRegion { Map, Object> result = new HashMap<>(); handle.getFlags().forEach((flag, value) -> { if (value != null) { - IWrappedFlag wrappedFlag = WorldGuardFlagUtilities.wrap(flag, value.getClass()); - Optional wrappedValue = ((AbstractWrappedFlag) wrappedFlag).fromWGValue(value); - wrappedValue.ifPresent(val -> result.put(wrappedFlag, val)); + try { + IWrappedFlag wrappedFlag = WorldGuardFlagUtilities.wrapFixType(flag, value.getClass()); + Optional wrappedValue = ((AbstractWrappedFlag) wrappedFlag).fromWGValue(value); + wrappedValue.ifPresent(val -> result.put(wrappedFlag, val)); + } catch (IllegalArgumentException ignored) {/* Unsupported flag type */} } }); return result; diff --git a/implementation/v7/src/main/java/org/codemc/worldguardwrapper/implementation/v7/utility/WorldGuardFlagUtilities.java b/implementation/v7/src/main/java/org/codemc/worldguardwrapper/implementation/v7/utility/WorldGuardFlagUtilities.java index d7162cf..84652d5 100644 --- a/implementation/v7/src/main/java/org/codemc/worldguardwrapper/implementation/v7/utility/WorldGuardFlagUtilities.java +++ b/implementation/v7/src/main/java/org/codemc/worldguardwrapper/implementation/v7/utility/WorldGuardFlagUtilities.java @@ -1,11 +1,11 @@ package org.codemc.worldguardwrapper.implementation.v7.utility; -import java.util.Vector; - +import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldguard.protection.flags.Flag; import com.sk89q.worldguard.protection.flags.StateFlag; import org.bukkit.Location; +import org.bukkit.util.Vector; import org.codemc.worldguardwrapper.flag.IWrappedFlag; import org.codemc.worldguardwrapper.flag.WrappedState; import org.codemc.worldguardwrapper.implementation.v7.flag.WrappedPrimitiveFlag; @@ -42,4 +42,28 @@ public class WorldGuardFlagUtilities { return wrappedFlag; } + // Used when the flag's type is not known, so it has to be derived from a sample value's class + public IWrappedFlag wrapFixType(Flag flag, Class type) { + if (StateFlag.State.class.isAssignableFrom(type)) { + // StateFlag + type = WrappedState.class; + } else if (com.sk89q.worldedit.util.Location.class.isAssignableFrom(type)) { + // LocationFlag + type = org.bukkit.Location.class; + } else if (Vector3.class.isAssignableFrom(type)) { + // VectorFlag + type = Vector.class; + } + + return wrap(flag, type); + } + + public Vector adaptVector(Vector3 vector) { + return new Vector(vector.getX(), vector.getY(), vector.getZ()); + } + + public Vector3 adaptVector(Vector vector) { + return Vector3.at(vector.getX(), vector.getY(), vector.getZ()); + } + } \ No newline at end of file diff --git a/implementation/v7fawe/src/main/java/org/codemc/worldguardwrapper/implementation/v7fawe/flag/WrappedPrimitiveFlag.java b/implementation/v7fawe/src/main/java/org/codemc/worldguardwrapper/implementation/v7fawe/flag/WrappedPrimitiveFlag.java index 36c8d3b..5d0cbd3 100644 --- a/implementation/v7fawe/src/main/java/org/codemc/worldguardwrapper/implementation/v7fawe/flag/WrappedPrimitiveFlag.java +++ b/implementation/v7fawe/src/main/java/org/codemc/worldguardwrapper/implementation/v7fawe/flag/WrappedPrimitiveFlag.java @@ -1,7 +1,13 @@ package org.codemc.worldguardwrapper.implementation.v7fawe.flag; +import com.sk89q.worldedit.bukkit.BukkitAdapter; +import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldguard.protection.flags.Flag; +import org.bukkit.Location; +import org.bukkit.util.Vector; +import org.codemc.worldguardwrapper.implementation.v7.utility.WorldGuardFlagUtilities; + import java.util.Optional; public class WrappedPrimitiveFlag extends AbstractWrappedFlag { @@ -10,13 +16,24 @@ public class WrappedPrimitiveFlag extends AbstractWrappedFlag { super(handle); } + @SuppressWarnings("unchecked") @Override public Optional fromWGValue(Object value) { + if (value instanceof com.sk89q.worldedit.util.Location) { + return Optional.of((T) BukkitAdapter.adapt((com.sk89q.worldedit.util.Location) value)); + } else if (value instanceof Vector3) { + return Optional.of((T) WorldGuardFlagUtilities.adaptVector((Vector3) value)); + } return Optional.ofNullable((T) value); } @Override public Optional fromWrapperValue(T value) { + if (value instanceof Location) { + return Optional.of(BukkitAdapter.adapt((Location) value)); + } else if (value instanceof Vector) { + return Optional.of(WorldGuardFlagUtilities.adaptVector((Vector) value)); + } return Optional.ofNullable(value); } diff --git a/implementation/v7fawe/src/main/java/org/codemc/worldguardwrapper/implementation/v7fawe/region/WrappedRegion.java b/implementation/v7fawe/src/main/java/org/codemc/worldguardwrapper/implementation/v7fawe/region/WrappedRegion.java index 3e2df8c..4952f7e 100644 --- a/implementation/v7fawe/src/main/java/org/codemc/worldguardwrapper/implementation/v7fawe/region/WrappedRegion.java +++ b/implementation/v7fawe/src/main/java/org/codemc/worldguardwrapper/implementation/v7fawe/region/WrappedRegion.java @@ -79,9 +79,11 @@ public class WrappedRegion implements IWrappedRegion { Map, Object> result = new HashMap<>(); handle.getFlags().forEach((flag, value) -> { if (value != null) { - IWrappedFlag wrappedFlag = WorldGuardFlagUtilities.wrap(flag, value.getClass()); - Optional wrappedValue = ((AbstractWrappedFlag) wrappedFlag).fromWGValue(value); - wrappedValue.ifPresent(val -> result.put(wrappedFlag, val)); + try { + IWrappedFlag wrappedFlag = WorldGuardFlagUtilities.wrapFixType(flag, value.getClass()); + Optional wrappedValue = ((AbstractWrappedFlag) wrappedFlag).fromWGValue(value); + wrappedValue.ifPresent(val -> result.put(wrappedFlag, val)); + } catch (IllegalArgumentException ignored) {/* Unsupported flag type */} } }); return result; diff --git a/implementation/v7fawe/src/main/java/org/codemc/worldguardwrapper/implementation/v7fawe/utility/WorldGuardFlagUtilities.java b/implementation/v7fawe/src/main/java/org/codemc/worldguardwrapper/implementation/v7fawe/utility/WorldGuardFlagUtilities.java index f3a5ed9..f2642bc 100644 --- a/implementation/v7fawe/src/main/java/org/codemc/worldguardwrapper/implementation/v7fawe/utility/WorldGuardFlagUtilities.java +++ b/implementation/v7fawe/src/main/java/org/codemc/worldguardwrapper/implementation/v7fawe/utility/WorldGuardFlagUtilities.java @@ -1,11 +1,10 @@ package org.codemc.worldguardwrapper.implementation.v7fawe.utility; -import java.util.Vector; - import com.sk89q.worldguard.protection.flags.Flag; import com.sk89q.worldguard.protection.flags.StateFlag; import org.bukkit.Location; +import org.bukkit.util.Vector; import org.codemc.worldguardwrapper.flag.IWrappedFlag; import org.codemc.worldguardwrapper.flag.WrappedState; import org.codemc.worldguardwrapper.implementation.v7fawe.flag.WrappedPrimitiveFlag; @@ -42,4 +41,28 @@ public class WorldGuardFlagUtilities { return wrappedFlag; } + // Used when the flag's type is not known, so it has to be derived from a sample value's class + public IWrappedFlag wrapFixType(Flag flag, Class type) { + if (StateFlag.State.class.isAssignableFrom(type)) { + // StateFlag + type = WrappedState.class; + } else if (com.sk89q.worldedit.util.Location.class.isAssignableFrom(type)) { + // LocationFlag + type = org.bukkit.Location.class; + } else if (Vector3.class.isAssignableFrom(type)) { + // VectorFlag + type = Vector.class; + } + + return wrap(flag, type); + } + + public Vector adaptVector(Vector3 vector) { + return new Vector(vector.getX(), vector.getY(), vector.getZ()); + } + + public Vector3 adaptVector(Vector vector) { + return Vector3.at(vector.getX(), vector.getY(), vector.getZ()); + } + } \ No newline at end of file