2018-02-09 08:21:44 +00:00
|
|
|
package me.totalfreedom.totalfreedommod.bridge;
|
|
|
|
|
2020-04-14 06:40:22 +00:00
|
|
|
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
|
|
|
import com.sk89q.worldguard.WorldGuard;
|
2018-02-09 08:21:44 +00:00
|
|
|
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;
|
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 org.bukkit.World;
|
|
|
|
import org.bukkit.plugin.Plugin;
|
|
|
|
|
|
|
|
public class WorldGuardBridge extends FreedomService
|
|
|
|
{
|
|
|
|
@Override
|
2020-07-01 01:51:06 +00:00
|
|
|
public void onStart()
|
2018-02-09 08:21:44 +00:00
|
|
|
{
|
2020-04-29 23:29:43 +00:00
|
|
|
plugin.wr.protectWorld(plugin.wm.hubworld.getWorld());
|
|
|
|
plugin.wr.protectWorld(plugin.wm.masterBuilderWorld.getWorld());
|
2018-02-09 08:21:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2020-07-01 01:51:06 +00:00
|
|
|
public void onStop()
|
2018-02-09 08:21:44 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2020-04-14 06:40:22 +00:00
|
|
|
public RegionManager getRegionManager(World world)
|
2018-02-09 08:21:44 +00:00
|
|
|
{
|
2020-04-14 06:40:22 +00:00
|
|
|
RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();
|
|
|
|
return container.get(BukkitAdapter.adapt(world));
|
2018-02-09 08:21:44 +00:00
|
|
|
}
|
|
|
|
|
2019-01-28 01:49:07 +00:00
|
|
|
public int wipeRegions(World world)
|
2018-02-09 08:21:44 +00:00
|
|
|
{
|
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)
|
2018-02-09 08:21:44 +00:00
|
|
|
{
|
2019-01-28 01:49:07 +00:00
|
|
|
Map<String, ProtectedRegion> regions = regionManager.getRegions();
|
2018-02-09 08:21:44 +00:00
|
|
|
for (ProtectedRegion region : regions.values())
|
|
|
|
{
|
2019-01-28 01:49:07 +00:00
|
|
|
regionManager.removeRegion(region.getId());
|
|
|
|
count++;
|
2018-02-09 08:21:44 +00:00
|
|
|
}
|
|
|
|
}
|
2019-01-28 01:49:07 +00:00
|
|
|
return count;
|
2018-02-09 08:21:44 +00:00
|
|
|
}
|
|
|
|
|
2018-07-30 07:23:01 +00:00
|
|
|
public boolean isEnabled()
|
2018-07-28 07:11:48 +00:00
|
|
|
{
|
2020-04-14 06:40:22 +00:00
|
|
|
Plugin plugin = server.getPluginManager().getPlugin("WorldGuard");
|
2018-07-30 07:23:01 +00:00
|
|
|
|
2020-04-14 06:40:22 +00:00
|
|
|
return plugin != null && plugin.isEnabled();
|
2018-02-09 08:21:44 +00:00
|
|
|
}
|
|
|
|
}
|