mirror of
https://github.com/Phoenix616/RandomTeleport.git
synced 2024-11-24 11:36:31 +01:00
Re-add backwards support down to 1.13
Also update PaperLib dependency and repo
This commit is contained in:
parent
c30af21608
commit
b8d686d9d3
6
pom.xml
6
pom.xml
@ -40,7 +40,7 @@
|
||||
</repository>
|
||||
<repository>
|
||||
<id>paper-repo</id>
|
||||
<url>https://papermc.io/repo/repository/maven-public/</url>
|
||||
<url>https://repo.papermc.io/repository/maven-public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>minebench-repo</id>
|
||||
@ -52,13 +52,13 @@
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.17.1-R0.1-SNAPSHOT</version>
|
||||
<version>1.16.5-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.papermc</groupId>
|
||||
<artifactId>paperlib</artifactId>
|
||||
<version>1.0.6</version>
|
||||
<version>1.0.7</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -83,6 +83,8 @@ public class RandomTeleport extends JavaPlugin implements RandomTeleportAPI {
|
||||
private Material[] unsafeBlocks;
|
||||
private Set<String> signVariables;
|
||||
|
||||
private boolean hasMinHeight = true;
|
||||
|
||||
public void onEnable() {
|
||||
hookManager = new HookManager(this);
|
||||
loadConfig();
|
||||
@ -481,4 +483,21 @@ public class RandomTeleport extends JavaPlugin implements RandomTeleportAPI {
|
||||
public RandomSearcher getRandomSearcher(Player player, Location origin, int minRange, int maxRange, LocationValidator... validators) {
|
||||
return new RandomSearcher(this, player, origin, minRange, maxRange, validators);
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility method to get the min height of a world as old versions didn't have support for this.
|
||||
* @param world The world
|
||||
* @return The min height or 0 if querying that isn't supported
|
||||
*/
|
||||
public int getMinHeight(World world) {
|
||||
if (hasMinHeight) {
|
||||
try {
|
||||
return world.getMinHeight();
|
||||
} catch (NoSuchMethodError ignored) {
|
||||
// getMinHeight is only available starting in 1.16.5
|
||||
}
|
||||
hasMinHeight = false;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ public class RandomSearcher {
|
||||
setCenter(center);
|
||||
setMinRadius(minRadius);
|
||||
setMaxRadius(maxRadius);
|
||||
minY = center.getWorld().getMinHeight();
|
||||
minY = plugin.getMinHeight(center.getWorld());
|
||||
if (center.getWorld().getEnvironment() == World.Environment.NETHER) {
|
||||
maxY = 126;
|
||||
} else {
|
||||
@ -257,7 +257,8 @@ public class RandomSearcher {
|
||||
* @param minY The min Y; has to be positive and less than the max Y!
|
||||
*/
|
||||
public void setMinY(int minY) {
|
||||
Validate.isTrue(minY >= center.getWorld().getMinHeight() && minY < maxY, "Min Y has to be at least the world's minimum height and less than the max Y!");
|
||||
Validate.isTrue(minY >= plugin.getMinHeight(center.getWorld()), "Min Y has to be at least the world's minimum height!");
|
||||
Validate.isTrue(minY < maxY, "Min Y has to be less than the max Y!");
|
||||
this.minY = minY;
|
||||
}
|
||||
|
||||
@ -362,7 +363,7 @@ public class RandomSearcher {
|
||||
}
|
||||
lastCheck = center.getWorld().getTime();
|
||||
Location randomLoc = center.clone();
|
||||
randomLoc.setY(center.getWorld().getMinHeight());
|
||||
randomLoc.setY(plugin.getMinHeight(center.getWorld()));
|
||||
int minChunk = minRadius >> 4;
|
||||
int maxChunk = maxRadius >> 4;
|
||||
int randChunkX;
|
||||
|
@ -2,7 +2,7 @@ name: RandomTeleport
|
||||
provides: [FUBSRandomTeleport]
|
||||
main: de.themoep.randomteleport.RandomTeleport
|
||||
version: '${minecraft.plugin.version}'
|
||||
api-version: 1.17
|
||||
api-version: 1.13
|
||||
description: ${project.description}
|
||||
author: Phoenix616
|
||||
website: https://github.com/Phoenix616/RandomTeleport/
|
||||
|
Loading…
Reference in New Issue
Block a user