TotalFreedomMod/src/main/java/me/totalfreedom/totalfreedommod/bridge/WorldGuardBridge.java

60 lines
1.6 KiB
Java
Raw Normal View History

package me.totalfreedom.totalfreedommod.bridge;
2020-04-14 06:40:22 +00:00
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldguard.WorldGuard;
import com.sk89q.worldguard.protection.managers.RegionManager;
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
2020-04-14 06:40:22 +00:00
import com.sk89q.worldguard.protection.regions.RegionContainer;
import java.util.Map;
import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import org.bukkit.World;
import org.bukkit.plugin.Plugin;
public class WorldGuardBridge extends FreedomService
{
public WorldGuardBridge(TotalFreedomMod plugin)
{
super(plugin);
}
@Override
protected void onStart()
{
}
@Override
protected void onStop()
{
}
2020-04-14 06:40:22 +00:00
public RegionManager getRegionManager(World world)
{
2020-04-14 06:40:22 +00:00
RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();
return container.get(BukkitAdapter.adapt(world));
}
2019-01-28 01:49:07 +00:00
public int wipeRegions(World world)
{
2019-01-28 01:49:07 +00:00
int count = 0;
2020-04-14 06:40:22 +00:00
RegionManager regionManager = getRegionManager(world);
2019-01-28 01:49:07 +00:00
if (regionManager != null)
{
2019-01-28 01:49:07 +00:00
Map<String, ProtectedRegion> regions = regionManager.getRegions();
for (ProtectedRegion region : regions.values())
{
2019-01-28 01:49:07 +00:00
regionManager.removeRegion(region.getId());
count++;
}
}
2019-01-28 01:49:07 +00:00
return count;
}
public boolean isEnabled()
{
2020-04-14 06:40:22 +00:00
Plugin plugin = server.getPluginManager().getPlugin("WorldGuard");
2020-04-14 06:40:22 +00:00
return plugin != null && plugin.isEnabled();
}
}