mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2024-12-26 11:08:02 +01:00
Update PRTree library to v1.5
Updated PRTreeRegionManager code to support 3D points and regions Changed region manager to PRTreeRegionManager
This commit is contained in:
parent
9834c30e3a
commit
4f394b5668
2
pom.xml
2
pom.xml
@ -76,7 +76,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.khelekore</groupId>
|
<groupId>org.khelekore</groupId>
|
||||||
<artifactId>prtree</artifactId>
|
<artifactId>prtree</artifactId>
|
||||||
<version>1.4</version>
|
<version>1.5</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -42,6 +42,7 @@
|
|||||||
import com.sk89q.worldguard.protection.databases.MySQLDatabase;
|
import com.sk89q.worldguard.protection.databases.MySQLDatabase;
|
||||||
import com.sk89q.worldguard.protection.flags.StateFlag;
|
import com.sk89q.worldguard.protection.flags.StateFlag;
|
||||||
import com.sk89q.worldguard.protection.managers.FlatRegionManager;
|
import com.sk89q.worldguard.protection.managers.FlatRegionManager;
|
||||||
|
import com.sk89q.worldguard.protection.managers.PRTreeRegionManager;
|
||||||
import com.sk89q.worldguard.protection.managers.RegionManager;
|
import com.sk89q.worldguard.protection.managers.RegionManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -156,7 +157,7 @@ public RegionManager create(World world) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create a manager
|
// Create a manager
|
||||||
RegionManager manager = new FlatRegionManager(database);
|
RegionManager manager = new PRTreeRegionManager(database);
|
||||||
manager.load();
|
manager.load();
|
||||||
|
|
||||||
plugin.getLogger().info(manager.getRegions().size()
|
plugin.getLogger().info(manager.getRegions().size()
|
||||||
|
@ -24,8 +24,10 @@
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
|
|
||||||
|
import org.khelekore.prtree.MBR;
|
||||||
import org.khelekore.prtree.MBRConverter;
|
import org.khelekore.prtree.MBRConverter;
|
||||||
import org.khelekore.prtree.PRTree;
|
import org.khelekore.prtree.PRTree;
|
||||||
|
import org.khelekore.prtree.SimpleMBR;
|
||||||
|
|
||||||
import com.sk89q.worldedit.Vector;
|
import com.sk89q.worldedit.Vector;
|
||||||
import com.sk89q.worldguard.LocalPlayer;
|
import com.sk89q.worldguard.LocalPlayer;
|
||||||
@ -115,11 +117,9 @@ public void removeRegion(String id) {
|
|||||||
public ApplicableRegionSet getApplicableRegions(Vector pt) {
|
public ApplicableRegionSet getApplicableRegions(Vector pt) {
|
||||||
List<ProtectedRegion> appRegions =
|
List<ProtectedRegion> appRegions =
|
||||||
new ArrayList<ProtectedRegion>();
|
new ArrayList<ProtectedRegion>();
|
||||||
|
MBR pointMBR = new SimpleMBR(pt.getX(), pt.getX(), pt.getY(), pt.getY(), pt.getZ(), pt.getZ());
|
||||||
|
|
||||||
int x = pt.getBlockX();
|
for (ProtectedRegion region : tree.find(pointMBR)) {
|
||||||
int z = pt.getBlockZ();
|
|
||||||
|
|
||||||
for (ProtectedRegion region : tree.find(x, z, x, z)) {
|
|
||||||
if (region.contains(pt)) {
|
if (region.contains(pt)) {
|
||||||
appRegions.add(region);
|
appRegions.add(region);
|
||||||
}
|
}
|
||||||
@ -148,11 +148,9 @@ public ApplicableRegionSet getApplicableRegions(ProtectedRegion checkRegion) {
|
|||||||
@Override
|
@Override
|
||||||
public List<String> getApplicableRegionsIDs(Vector pt) {
|
public List<String> getApplicableRegionsIDs(Vector pt) {
|
||||||
List<String> applicable = new ArrayList<String>();
|
List<String> applicable = new ArrayList<String>();
|
||||||
|
MBR pointMBR = new SimpleMBR(pt.getX(), pt.getX(), pt.getY(), pt.getY(), pt.getZ(), pt.getZ());
|
||||||
|
|
||||||
int x = pt.getBlockX();
|
for (ProtectedRegion region : tree.find(pointMBR)) {
|
||||||
int z = pt.getBlockZ();
|
|
||||||
|
|
||||||
for (ProtectedRegion region : tree.find(x, z, x, z)) {
|
|
||||||
if (region.contains(pt)) {
|
if (region.contains(pt)) {
|
||||||
applicable.add(region.getId());
|
applicable.add(region.getId());
|
||||||
}
|
}
|
||||||
|
@ -22,19 +22,35 @@
|
|||||||
import org.khelekore.prtree.MBRConverter;
|
import org.khelekore.prtree.MBRConverter;
|
||||||
|
|
||||||
public class ProtectedRegionMBRConverter implements MBRConverter<ProtectedRegion> {
|
public class ProtectedRegionMBRConverter implements MBRConverter<ProtectedRegion> {
|
||||||
public double getMinX(ProtectedRegion t) {
|
|
||||||
return t.getMinimumPoint().getBlockX();
|
@Override
|
||||||
|
public int getDimensions() {
|
||||||
|
return 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getMinY(ProtectedRegion t) {
|
@Override
|
||||||
return t.getMinimumPoint().getBlockZ();
|
public double getMax(int dimension, ProtectedRegion region) {
|
||||||
|
switch (dimension) {
|
||||||
|
case 0:
|
||||||
|
return region.getMaximumPoint().getBlockX();
|
||||||
|
case 1:
|
||||||
|
return region.getMaximumPoint().getBlockY();
|
||||||
|
case 2:
|
||||||
|
return region.getMaximumPoint().getBlockZ();
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getMaxX(ProtectedRegion t) {
|
@Override
|
||||||
return t.getMaximumPoint().getBlockX();
|
public double getMin(int dimension, ProtectedRegion region) {
|
||||||
}
|
switch (dimension) {
|
||||||
|
case 0:
|
||||||
public double getMaxY(ProtectedRegion t) {
|
return region.getMinimumPoint().getBlockX();
|
||||||
return t.getMaximumPoint().getBlockZ();
|
case 1:
|
||||||
|
return region.getMinimumPoint().getBlockY();
|
||||||
|
case 2:
|
||||||
|
return region.getMinimumPoint().getBlockZ();
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user