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

55 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 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()
{
2020-04-29 23:29:43 +00:00
plugin.wr.protectWorld(plugin.wm.hubworld.getWorld());
plugin.wr.protectWorld(plugin.wm.masterBuilderWorld.getWorld());
}
@Override
2020-07-01 01:51:06 +00:00
public 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();
}
}