mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-25 14:46:45 +01:00
Replace the R-tree library with PRTree. Fix SquirrelID shading issues. Bump the version to 5.12.0
This commit is contained in:
parent
fdf82d0d1e
commit
b9b0d89b5f
@ -36,7 +36,7 @@ dependencies {
|
||||
implementation("net.ess3:EssentialsX:2.17.2")
|
||||
implementation("net.alpenblock:BungeePerms:4.0-dev-106")
|
||||
compile("se.hyperver.hyperverse:Core:0.6.0-SNAPSHOT"){ transitive = false }
|
||||
compile 'com.github.pavog:SquirrelID:0.6.1'
|
||||
compile('com.sk89q:squirrelid:1.0.0-SNAPSHOT'){ transitive = false }
|
||||
}
|
||||
|
||||
sourceCompatibility = 1.8
|
||||
@ -93,15 +93,14 @@ shadowJar {
|
||||
include(dependency("io.papermc:paperlib:1.0.2"))
|
||||
include(dependency("net.kyori:text-adapter-bukkit:3.0.3"))
|
||||
include(dependency("org.bstats:bstats-bukkit:1.7"))
|
||||
include(dependency("com.github.davidmoten:rtree:0.8.7"))
|
||||
include(dependency("io.reactivex:rxjava:1.3.8"))
|
||||
include(dependency("com.github.davidmoten:guava-mini:0.1.1"))
|
||||
include(dependency("com.github.pavog:SquirrelID:0.6.1"))
|
||||
include(dependency("org.khelekore:prtree:1.7.0-SNAPSHOT"))
|
||||
include(dependency("com.sk89q:squirrelid:1.0.0-SNAPSHOT"))
|
||||
}
|
||||
relocate('net.kyori.text', 'com.plotsquared.formatting.text')
|
||||
relocate("io.papermc.lib", "com.plotsquared.bukkit.paperlib")
|
||||
relocate("org.bstats", "com.plotsquared.metrics")
|
||||
relocate('com.sk89q.squirrelid', 'com.plotsquared.squirrelid')
|
||||
relocate('org.khelekore.prtree', 'com.plotsquared.prtree')
|
||||
archiveFileName = "${project.name}-${parent.version}.jar"
|
||||
destinationDirectory = file "../target"
|
||||
}
|
||||
|
@ -67,10 +67,16 @@
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.pavog</groupId>
|
||||
<artifactId>SquirrelID</artifactId>
|
||||
<version>0.6.1</version>
|
||||
<groupId>com.sk89q</groupId>
|
||||
<artifactId>squirrelid</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>*</artifactId>
|
||||
<groupId>*</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sk89q.worldedit</groupId>
|
||||
@ -137,19 +143,19 @@
|
||||
<dependency>
|
||||
<groupId>me.clip</groupId>
|
||||
<artifactId>placeholderapi</artifactId>
|
||||
<version>2.10.4</version>
|
||||
<version>2.10.6</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.luckperms</groupId>
|
||||
<artifactId>api</artifactId>
|
||||
<version>5.0</version>
|
||||
<version>5.1</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.ess3</groupId>
|
||||
<artifactId>EssentialsX</artifactId>
|
||||
<version>2.16.1</version>
|
||||
<version>2.17.2</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -1,5 +1,6 @@
|
||||
repositories {
|
||||
maven { url = "https://jitpack.io" }
|
||||
maven { url = "https://mvn.intellectualsites.com/content/repositories/snapshots" }
|
||||
}
|
||||
def textVersion = "3.0.2"
|
||||
|
||||
@ -16,7 +17,7 @@ dependencies {
|
||||
testAnnotationProcessor("org.projectlombok:lombok:1.18.8")
|
||||
implementation("org.jetbrains.kotlin:kotlin-stdlib:1.3.72")
|
||||
implementation("org.jetbrains:annotations:19.0.0")
|
||||
implementation 'com.github.davidmoten:rtree:0.8.7'
|
||||
implementation("org.khelekore:prtree:1.7.0-SNAPSHOT")
|
||||
}
|
||||
|
||||
sourceCompatibility = 1.8
|
||||
@ -74,7 +75,7 @@ shadowJar {
|
||||
include(dependency("net.kyori:text-serializer-gson:3.0.2"))
|
||||
include(dependency("net.kyori:text-serializer-legacy:3.0.2"))
|
||||
include(dependency("net.kyori:text-serializer-plain:3.0.2"))
|
||||
include(dependency("com.github.davidmoten:rtree:0.8.7"))
|
||||
include(dependency("org.khelekore:prtree:1.7.0-SNAPSHOT"))
|
||||
}
|
||||
relocate('net.kyori.text', 'com.plotsquared.formatting.text')
|
||||
relocate("org.json", "com.plotsquared.json") {
|
||||
|
@ -93,9 +93,9 @@
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.davidmoten</groupId>
|
||||
<artifactId>rtree</artifactId>
|
||||
<version>0.8.7</version>
|
||||
<groupId>org.khelekore</groupId>
|
||||
<artifactId>prtree</artifactId>
|
||||
<version>1.7.0-SNAPSHOT</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -34,6 +34,8 @@ import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.khelekore.prtree.MBR;
|
||||
import org.khelekore.prtree.SimpleMBR;
|
||||
|
||||
public class Location implements Cloneable, Comparable<Location> {
|
||||
|
||||
@ -221,6 +223,10 @@ public class Location implements Cloneable, Comparable<Location> {
|
||||
return this;
|
||||
}
|
||||
|
||||
public MBR toMBR() {
|
||||
return new SimpleMBR(this.getX(), this.getX(), this.getY(), this.getY(), this.getZ(), this.getZ());
|
||||
}
|
||||
|
||||
@Override public boolean equals(Object o) {
|
||||
if (o == null) {
|
||||
return false;
|
||||
|
@ -25,18 +25,18 @@
|
||||
*/
|
||||
package com.plotsquared.core.plot.world;
|
||||
|
||||
import com.github.davidmoten.rtree.Entry;
|
||||
import com.github.davidmoten.rtree.RTree;
|
||||
import com.github.davidmoten.rtree.geometry.Geometries;
|
||||
import com.github.davidmoten.rtree.geometry.Geometry;
|
||||
import com.plotsquared.core.location.Location;
|
||||
import com.plotsquared.core.plot.PlotArea;
|
||||
import com.plotsquared.core.plot.PlotWorld;
|
||||
import com.plotsquared.core.util.PlotAreaConverter;
|
||||
import com.plotsquared.core.util.RegionUtil;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import rx.Observable;
|
||||
import org.khelekore.prtree.MBR;
|
||||
import org.khelekore.prtree.PRTree;
|
||||
import org.khelekore.prtree.SimpleMBR;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
@ -48,9 +48,12 @@ import java.util.List;
|
||||
*/
|
||||
public class ScatteredPlotWorld extends PlotWorld {
|
||||
|
||||
private static final PlotAreaConverter MBR_CONVERTER = new PlotAreaConverter();
|
||||
private static final int BRANCH_FACTOR = 30;
|
||||
|
||||
private final List<PlotArea> areas = new LinkedList<>();
|
||||
private final Object treeLock = new Object();
|
||||
private RTree<PlotArea, Geometry> areaTree;
|
||||
private PRTree<PlotArea> areaTree;
|
||||
|
||||
/**
|
||||
* Create a new plot world with a given world name
|
||||
@ -66,13 +69,13 @@ public class ScatteredPlotWorld extends PlotWorld {
|
||||
return null;
|
||||
}
|
||||
synchronized (this.treeLock) {
|
||||
final Observable<Entry<PlotArea, Geometry>> area =
|
||||
areaTree.search(Geometries.point(location.getX(), location.getZ()));
|
||||
if (area.isEmpty().toBlocking().first()) {
|
||||
return null;
|
||||
for (final PlotArea area : this.areaTree.find(location.toMBR())) {
|
||||
if (area.contains(location)) {
|
||||
return area;
|
||||
}
|
||||
}
|
||||
return area.toBlocking().first().value();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override @NotNull public Collection<PlotArea> getAreas() {
|
||||
@ -95,7 +98,17 @@ public class ScatteredPlotWorld extends PlotWorld {
|
||||
}
|
||||
synchronized (this.treeLock) {
|
||||
final List<PlotArea> areas = new LinkedList<>();
|
||||
this.areaTree.search(RegionUtil.toRectangle(region)).toBlocking().forEach(entry -> areas.add(entry.value()));
|
||||
|
||||
final BlockVector3 min = region.getMinimumPoint();
|
||||
final BlockVector3 max = region.getMaximumPoint();
|
||||
final MBR mbr = new SimpleMBR(min.getX(), max.getX(), min.getY(), max.getY(), min.getZ(), max.getZ());
|
||||
|
||||
for (final PlotArea area : this.areaTree.find(mbr)) {
|
||||
if (RegionUtil.intersects(area.getRegion(), region)) {
|
||||
areas.add(area);
|
||||
}
|
||||
}
|
||||
|
||||
return areas;
|
||||
}
|
||||
}
|
||||
@ -105,11 +118,8 @@ public class ScatteredPlotWorld extends PlotWorld {
|
||||
*/
|
||||
private void buildTree() {
|
||||
synchronized (this.treeLock) {
|
||||
this.areaTree = RTree.create();
|
||||
for (final PlotArea area : areas) {
|
||||
this.areaTree = this.areaTree.add(area,
|
||||
RegionUtil.toRectangle(area.getRegion()));
|
||||
}
|
||||
this.areaTree = new PRTree<>(MBR_CONVERTER, BRANCH_FACTOR);
|
||||
this.areaTree.load(this.areas);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,68 @@
|
||||
/*
|
||||
* _____ _ _ _____ _
|
||||
* | __ \| | | | / ____| | |
|
||||
* | |__) | | ___ | |_| (___ __ _ _ _ __ _ _ __ ___ __| |
|
||||
* | ___/| |/ _ \| __|\___ \ / _` | | | |/ _` | '__/ _ \/ _` |
|
||||
* | | | | (_) | |_ ____) | (_| | |_| | (_| | | | __/ (_| |
|
||||
* |_| |_|\___/ \__|_____/ \__, |\__,_|\__,_|_| \___|\__,_|
|
||||
* | |
|
||||
* |_|
|
||||
* PlotSquared plot management system for Minecraft
|
||||
* Copyright (C) 2020 IntellectualSites
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.plotsquared.core.util;
|
||||
|
||||
import com.plotsquared.core.plot.PlotArea;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import org.khelekore.prtree.MBRConverter;
|
||||
|
||||
public class PlotAreaConverter implements MBRConverter<PlotArea> {
|
||||
|
||||
public static final int AXIS_X = 0;
|
||||
public static final int AXIS_Y = 1;
|
||||
public static final int AXIS_Z = 2;
|
||||
|
||||
@Override public int getDimensions() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
@Override public double getMin(final int axis, final PlotArea area) {
|
||||
final CuboidRegion region = area.getRegion();
|
||||
if (axis == AXIS_X) {
|
||||
return region.getMinimumPoint().getX();
|
||||
} else if (axis == AXIS_Y) {
|
||||
return region.getMinimumPoint().getY();
|
||||
} else if (axis == AXIS_Z) {
|
||||
return region.getMinimumPoint().getZ();
|
||||
} else {
|
||||
throw new IllegalArgumentException("Unknown axis: " + axis);
|
||||
}
|
||||
}
|
||||
|
||||
@Override public double getMax(final int axis, final PlotArea area) {
|
||||
final CuboidRegion region = area.getRegion();
|
||||
if (axis == AXIS_X) {
|
||||
return region.getMaximumPoint().getX();
|
||||
} else if (axis == AXIS_Y) {
|
||||
return region.getMaximumPoint().getY();
|
||||
} else if (axis == AXIS_Z) {
|
||||
return region.getMaximumPoint().getZ();
|
||||
} else {
|
||||
throw new IllegalArgumentException("Unknown axis: " + axis);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -25,14 +25,14 @@
|
||||
*/
|
||||
package com.plotsquared.core.util;
|
||||
|
||||
import com.github.davidmoten.rtree.geometry.Geometries;
|
||||
import com.github.davidmoten.rtree.geometry.Rectangle;
|
||||
import com.plotsquared.core.plot.Plot;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.awt.geom.Rectangle2D;
|
||||
|
||||
public class RegionUtil {
|
||||
public static CuboidRegion createRegion(int pos1x, int pos2x, int pos1z, int pos2z) {
|
||||
return createRegion(pos1x, pos2x, 0, Plot.MAX_HEIGHT - 1, pos1z, pos2z);
|
||||
@ -58,10 +58,10 @@ public class RegionUtil {
|
||||
.getY() && y <= max.getY();
|
||||
}
|
||||
|
||||
@NotNull public static Rectangle toRectangle(@NotNull final CuboidRegion region) {
|
||||
@NotNull public static Rectangle2D toRectangle(@NotNull final CuboidRegion region) {
|
||||
final BlockVector2 min = region.getMinimumPoint().toBlockVector2();
|
||||
final BlockVector2 max = region.getMaximumPoint().toBlockVector2();
|
||||
return Geometries.rectangle(min.getX(), min.getZ(), max.getX(), max.getZ());
|
||||
return new Rectangle2D.Double(min.getX(), min.getZ(), max.getX(), max.getZ());
|
||||
}
|
||||
|
||||
// Because WE (not fawe) lack this for CuboidRegion
|
||||
|
@ -30,7 +30,7 @@ ext {
|
||||
git = Grgit.open(dir: new File(rootDir.toString() + "/.git"))
|
||||
}
|
||||
|
||||
def ver = "5.11.2"
|
||||
def ver = "5.12.0"
|
||||
def versuffix = ""
|
||||
ext {
|
||||
if (project.hasProperty("versionsuffix")) {
|
||||
|
Loading…
Reference in New Issue
Block a user