From b114b139029adce1421db91e0b2c5a241150372f Mon Sep 17 00:00:00 2001 From: Shevchik Date: Wed, 11 Dec 2013 15:23:20 +0400 Subject: [PATCH] Update wghook --- src/com/cnaude/chairs/ChairEffects.java | 5 ++--- src/com/cnaude/chairs/WGHook.java | 26 ++++++++++++++++--------- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/src/com/cnaude/chairs/ChairEffects.java b/src/com/cnaude/chairs/ChairEffects.java index e9531de..dad6a22 100644 --- a/src/com/cnaude/chairs/ChairEffects.java +++ b/src/com/cnaude/chairs/ChairEffects.java @@ -39,9 +39,8 @@ public class ChairEffects { String pName = p.getName(); if (plugin.sit.containsKey(pName)) { if (p.hasPermission("chairs.sit.health")) { - double pHealthPcnt = (double) p.getHealth() / (double) p.getMaxHealth() * 100d; - if ((pHealthPcnt < plugin.sitMaxHealth) - && (p.getHealth() < p.getMaxHealth())) { + double pHealthPcnt = ((double) p.getHealth()) / (double) p.getMaxHealth() * 100d; + if ((pHealthPcnt < plugin.sitMaxHealth) && (p.getHealth() < p.getMaxHealth())) { double newHealth = plugin.sitHealthPerInterval + p.getHealth(); if (newHealth > p.getMaxHealth()) { newHealth = p.getMaxHealth(); diff --git a/src/com/cnaude/chairs/WGHook.java b/src/com/cnaude/chairs/WGHook.java index f2e09c8..5e547c7 100644 --- a/src/com/cnaude/chairs/WGHook.java +++ b/src/com/cnaude/chairs/WGHook.java @@ -3,6 +3,7 @@ package com.cnaude.chairs; import java.util.HashSet; import java.util.List; +import org.bukkit.Bukkit; import org.bukkit.Location; import com.sk89q.worldedit.bukkit.BukkitUtil; @@ -11,16 +12,23 @@ import com.sk89q.worldguard.bukkit.WGBukkit; public class WGHook { public static boolean isAllowedInRegion(HashSet disabledRegions, Location location) { - try { - if (disabledRegions.isEmpty()) {return true;} - - List aregions = WGBukkit.getRegionManager(location.getWorld()).getApplicableRegionsIDs(BukkitUtil.toVector(location)); - for (String region : aregions) { - if (disabledRegions.contains(region)) { - return false; - } + if (Bukkit.getPluginManager().getPlugin("WorldGuard") == null) + { + return true; + } + if (disabledRegions.isEmpty()) + { + return true; + } + + List aregions = WGBukkit.getRegionManager(location.getWorld()).getApplicableRegionsIDs(BukkitUtil.toVector(location)); + for (String region : aregions) + { + if (disabledRegions.contains(region)) + { + return false; } - } catch (Exception e) {} + } return true; }