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();
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();

View File

@ -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<String> disabledRegions, Location location) {
try {
if (disabledRegions.isEmpty()) {return true;}
if (Bukkit.getPluginManager().getPlugin("WorldGuard") == null)
{
return true;
}
if (disabledRegions.isEmpty())
{
return true;
}
List<String> aregions = WGBukkit.getRegionManager(location.getWorld()).getApplicableRegionsIDs(BukkitUtil.toVector(location));
for (String region : aregions) {
if (disabledRegions.contains(region)) {
return false;
}
List<String> aregions = WGBukkit.getRegionManager(location.getWorld()).getApplicableRegionsIDs(BukkitUtil.toVector(location));
for (String region : aregions)
{
if (disabledRegions.contains(region))
{
return false;
}
} catch (Exception e) {}
}
return true;
}