2018-02-09 08:21:44 +00:00
|
|
|
package me.totalfreedom.totalfreedommod.bridge;
|
|
|
|
|
|
|
|
import com.sk89q.worldguard.bukkit.RegionContainer;
|
|
|
|
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
|
|
|
import com.sk89q.worldguard.protection.managers.RegionManager;
|
|
|
|
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
2018-07-31 07:01:29 +00:00
|
|
|
import java.util.Map;
|
2018-02-09 08:21:44 +00:00
|
|
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
|
|
|
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
|
|
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
|
|
|
import org.bukkit.World;
|
|
|
|
import org.bukkit.plugin.Plugin;
|
|
|
|
|
|
|
|
public class WorldGuardBridge extends FreedomService
|
|
|
|
{
|
|
|
|
|
|
|
|
private WorldGuardPlugin worldGuardPlugin;
|
|
|
|
|
|
|
|
public WorldGuardBridge(TotalFreedomMod plugin)
|
|
|
|
{
|
|
|
|
super(plugin);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onStart()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onStop()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public WorldGuardPlugin getWorldGuardPlugin()
|
|
|
|
{
|
|
|
|
if (worldGuardPlugin == null)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
final Plugin worldGuard = server.getPluginManager().getPlugin("WorldGuard");
|
2018-07-28 07:11:48 +00:00
|
|
|
if (worldGuard != null && worldGuard instanceof WorldGuardPlugin)
|
2018-02-09 08:21:44 +00:00
|
|
|
{
|
2018-07-31 07:01:29 +00:00
|
|
|
worldGuardPlugin = (WorldGuardPlugin)worldGuard;
|
2018-02-09 08:21:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
FLog.severe(ex);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return worldGuardPlugin;
|
|
|
|
}
|
|
|
|
|
|
|
|
public Boolean wipeRegions(World world)
|
|
|
|
{
|
|
|
|
RegionContainer container = getWorldGuardPlugin().getRegionContainer();
|
|
|
|
RegionManager rm = container.get(world);
|
|
|
|
if (rm != null)
|
|
|
|
{
|
|
|
|
Map<String, ProtectedRegion> regions = rm.getRegions();
|
|
|
|
for (ProtectedRegion region : regions.values())
|
|
|
|
{
|
|
|
|
rm.removeRegion(region.getId());
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-07-30 07:23:01 +00:00
|
|
|
public boolean isEnabled()
|
2018-07-28 07:11:48 +00:00
|
|
|
{
|
2018-07-30 07:23:01 +00:00
|
|
|
final WorldGuardPlugin wg = getWorldGuardPlugin();
|
|
|
|
|
|
|
|
return wg != null && wg.isEnabled();
|
2018-02-09 08:21:44 +00:00
|
|
|
}
|
|
|
|
}
|