Update wghook

This commit is contained in:
Shevchik 2013-12-11 15:23:20 +04:00
parent c35ae7d630
commit b114b13902
2 changed files with 19 additions and 12 deletions

View File

@ -39,9 +39,8 @@ public class ChairEffects {
String pName = p.getName(); String pName = p.getName();
if (plugin.sit.containsKey(pName)) { if (plugin.sit.containsKey(pName)) {
if (p.hasPermission("chairs.sit.health")) { if (p.hasPermission("chairs.sit.health")) {
double pHealthPcnt = (double) p.getHealth() / (double) p.getMaxHealth() * 100d; double pHealthPcnt = ((double) p.getHealth()) / (double) p.getMaxHealth() * 100d;
if ((pHealthPcnt < plugin.sitMaxHealth) if ((pHealthPcnt < plugin.sitMaxHealth) && (p.getHealth() < p.getMaxHealth())) {
&& (p.getHealth() < p.getMaxHealth())) {
double newHealth = plugin.sitHealthPerInterval + p.getHealth(); double newHealth = plugin.sitHealthPerInterval + p.getHealth();
if (newHealth > p.getMaxHealth()) { if (newHealth > p.getMaxHealth()) {
newHealth = p.getMaxHealth(); newHealth = p.getMaxHealth();

View File

@ -3,6 +3,7 @@ package com.cnaude.chairs;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import com.sk89q.worldedit.bukkit.BukkitUtil; import com.sk89q.worldedit.bukkit.BukkitUtil;
@ -11,16 +12,23 @@ import com.sk89q.worldguard.bukkit.WGBukkit;
public class WGHook { public class WGHook {
public static boolean isAllowedInRegion(HashSet<String> disabledRegions, Location location) { public static boolean isAllowedInRegion(HashSet<String> disabledRegions, Location location) {
try { if (Bukkit.getPluginManager().getPlugin("WorldGuard") == null)
if (disabledRegions.isEmpty()) {return true;} {
return true;
}
if (disabledRegions.isEmpty())
{
return true;
}
List<String> aregions = WGBukkit.getRegionManager(location.getWorld()).getApplicableRegionsIDs(BukkitUtil.toVector(location)); List<String> aregions = WGBukkit.getRegionManager(location.getWorld()).getApplicableRegionsIDs(BukkitUtil.toVector(location));
for (String region : aregions) { for (String region : aregions)
if (disabledRegions.contains(region)) { {
if (disabledRegions.contains(region))
{
return false; return false;
} }
} }
} catch (Exception e) {}
return true; return true;
} }