Reintroduced world guard compat feature.
This commit is contained in:
parent
48434973ba
commit
01486f82dc
|
|
@ -83,7 +83,7 @@ public abstract class DataStore
|
||||||
ConcurrentHashMap<UUID, Boolean> softMuteMap = new ConcurrentHashMap<UUID, Boolean>();
|
ConcurrentHashMap<UUID, Boolean> softMuteMap = new ConcurrentHashMap<UUID, Boolean>();
|
||||||
|
|
||||||
//world guard reference, if available
|
//world guard reference, if available
|
||||||
boolean worldGuardHooked = false;
|
private WorldGuardWrapper worldGuard = null;
|
||||||
|
|
||||||
protected int getSchemaVersion()
|
protected int getSchemaVersion()
|
||||||
{
|
{
|
||||||
|
|
@ -139,11 +139,13 @@ public abstract class DataStore
|
||||||
this.setSchemaVersion(latestSchemaVersion);
|
this.setSchemaVersion(latestSchemaVersion);
|
||||||
|
|
||||||
//try to hook into world guard
|
//try to hook into world guard
|
||||||
worldGuardHooked = (GriefPrevention.instance.getServer().getPluginManager().getPlugin("WorldGuard") != null);
|
try
|
||||||
if(worldGuardHooked)
|
|
||||||
{
|
{
|
||||||
|
this.worldGuard = new WorldGuardWrapper();
|
||||||
GriefPrevention.AddLogEntry("Successfully hooked into WorldGuard.");
|
GriefPrevention.AddLogEntry("Successfully hooked into WorldGuard.");
|
||||||
}
|
}
|
||||||
|
//if failed, world guard compat features will just be disabled.
|
||||||
|
catch(ClassNotFoundException exception){ }
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadSoftMutes()
|
private void loadSoftMutes()
|
||||||
|
|
@ -681,27 +683,14 @@ public abstract class DataStore
|
||||||
}
|
}
|
||||||
|
|
||||||
//if worldguard is installed, also prevent claims from overlapping any worldguard regions
|
//if worldguard is installed, also prevent claims from overlapping any worldguard regions
|
||||||
if(this.worldGuardHooked && creatingPlayer != null)
|
if(this.worldGuard != null && creatingPlayer != null)
|
||||||
{
|
{
|
||||||
/*WorldGuardPlugin worldGuard = (WorldGuardPlugin)GriefPrevention.instance.getServer().getPluginManager().getPlugin("WorldGuard");
|
if(!this.worldGuard.canBuild(newClaim.lesserBoundaryCorner, newClaim.greaterBoundaryCorner, creatingPlayer))
|
||||||
RegionManager manager = worldGuard.getRegionManager(world);
|
|
||||||
if(manager != null)
|
|
||||||
{
|
|
||||||
Location lesser = newClaim.getLesserBoundaryCorner();
|
|
||||||
Location greater = newClaim.getGreaterBoundaryCorner();
|
|
||||||
ProtectedCuboidRegion tempRegion = new ProtectedCuboidRegion(
|
|
||||||
"GP_TEMP",
|
|
||||||
new BlockVector(lesser.getX(), 0, lesser.getZ()),
|
|
||||||
new BlockVector(greater.getX(), world.getMaxHeight(), greater.getZ()));
|
|
||||||
ApplicableRegionSet overlaps = manager.getApplicableRegions(tempRegion);
|
|
||||||
LocalPlayer localPlayer = worldGuard.wrapPlayer(creatingPlayer);
|
|
||||||
if(!overlaps.canBuild(localPlayer))
|
|
||||||
{
|
{
|
||||||
result.succeeded = false;
|
result.succeeded = false;
|
||||||
result.claim = null;
|
result.claim = null;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//otherwise add this new claim to the data store to make it effective
|
//otherwise add this new claim to the data store to make it effective
|
||||||
|
|
|
||||||
40
src/me/ryanhamshire/GriefPrevention/WorldGuardWrapper.java
Normal file
40
src/me/ryanhamshire/GriefPrevention/WorldGuardWrapper.java
Normal file
|
|
@ -0,0 +1,40 @@
|
||||||
|
package me.ryanhamshire.GriefPrevention;
|
||||||
|
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import com.sk89q.worldedit.BlockVector;
|
||||||
|
import com.sk89q.worldguard.LocalPlayer;
|
||||||
|
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||||
|
import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
||||||
|
import com.sk89q.worldguard.protection.managers.RegionManager;
|
||||||
|
import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion;
|
||||||
|
|
||||||
|
class WorldGuardWrapper
|
||||||
|
{
|
||||||
|
private WorldGuardPlugin worldGuard = null;
|
||||||
|
|
||||||
|
public WorldGuardWrapper() throws ClassNotFoundException
|
||||||
|
{
|
||||||
|
this.worldGuard = (WorldGuardPlugin)GriefPrevention.instance.getServer().getPluginManager().getPlugin("WorldGuard");
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean canBuild(Location lesserCorner, Location greaterCorner, Player creatingPlayer)
|
||||||
|
{
|
||||||
|
World world = lesserCorner.getWorld();
|
||||||
|
RegionManager manager = this.worldGuard.getRegionManager(world);
|
||||||
|
if(manager != null)
|
||||||
|
{
|
||||||
|
ProtectedCuboidRegion tempRegion = new ProtectedCuboidRegion(
|
||||||
|
"GP_TEMP",
|
||||||
|
new BlockVector(lesserCorner.getX(), 0, lesserCorner.getZ()),
|
||||||
|
new BlockVector(greaterCorner.getX(), world.getMaxHeight(), greaterCorner.getZ()));
|
||||||
|
ApplicableRegionSet overlaps = manager.getApplicableRegions(tempRegion);
|
||||||
|
LocalPlayer localPlayer = worldGuard.wrapPlayer(creatingPlayer);
|
||||||
|
return overlaps.canBuild(localPlayer);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user