Commit 8feb1017 authored by Amosar's avatar Amosar

fix a bug with Vector in latest WorldEdit.

parent e532c664
1.0.2:
- fix a bug with Vector in latest WorldEdit.
\ No newline at end of file
name: antiRedstoneClock
version: 1.0.1
version: 1.0.2
description: Limit the redstoneClock
author: Amosar
website: https://www.spigotmc.org/resources/antiredstoneclock.18557
......
package com.trafalcraft.antiRedstoneClock.util.WorldGuard;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldguard.protection.ApplicableRegionSet;
import com.sk89q.worldguard.protection.managers.RegionManager;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
class VectorAdaptor {
static ApplicableRegionSet getRegion(RegionManager regionManager, Location loc) {
ApplicableRegionSet region = null;
try {
region = regionManager.getApplicableRegions(BlockVector3.at(loc.getX(), loc.getY(), loc.getZ()));
} catch (NoClassDefFoundError e) {
//Compatibility for older worldguard version
try {
Class vector = Class.forName("com.sk89q.worldedit.Vector");
Object vectorInst = vector.getConstructor(double.class, double.class, double.class)
.newInstance(loc.getX(), loc.getY(), loc.getZ());
Method applicationRegions = regionManager.getClass()
.getMethod("getApplicableRegions", vector);
region = (ApplicableRegionSet) applicationRegions.invoke(regionManager, vectorInst);
} catch (ClassNotFoundException | NoSuchMethodException | InstantiationException
| IllegalAccessException | InvocationTargetException e1) {
Bukkit.getLogger().severe("error with worldEdit vector, please report this issue");
e1.printStackTrace();
}
}
return region;
}
}
package com.trafalcraft.antiRedstoneClock.util.WorldGuard;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
import com.sk89q.worldguard.protection.ApplicableRegionSet;
import com.sk89q.worldguard.protection.managers.RegionManager;
......@@ -37,7 +36,7 @@ public class WorldGuardHook {
}
if (regionManager != null) {
ApplicableRegionSet regions = regionManager.getApplicableRegions(new Vector(loc.getX(), loc.getY(), loc.getZ()));
ApplicableRegionSet regions = VectorAdaptor.getRegion(regionManager, loc);
for (String ignoreRegion : Main.getIgnoredRegions()) {
for (ProtectedRegion region : regions.getRegions()) {
if (region.getId().equals(ignoreRegion)) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment