mirror of
https://github.com/Phoenix616/RandomTeleport.git
synced 2025-02-17 21:11:22 +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>
|
||||||
<repository>
|
<repository>
|
||||||
<id>paper-repo</id>
|
<id>paper-repo</id>
|
||||||
<url>https://papermc.io/repo/repository/maven-public/</url>
|
<url>https://repo.papermc.io/repository/maven-public/</url>
|
||||||
</repository>
|
</repository>
|
||||||
<repository>
|
<repository>
|
||||||
<id>minebench-repo</id>
|
<id>minebench-repo</id>
|
||||||
@ -52,13 +52,13 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.spigotmc</groupId>
|
<groupId>org.spigotmc</groupId>
|
||||||
<artifactId>spigot-api</artifactId>
|
<artifactId>spigot-api</artifactId>
|
||||||
<version>1.17.1-R0.1-SNAPSHOT</version>
|
<version>1.16.5-R0.1-SNAPSHOT</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.papermc</groupId>
|
<groupId>io.papermc</groupId>
|
||||||
<artifactId>paperlib</artifactId>
|
<artifactId>paperlib</artifactId>
|
||||||
<version>1.0.6</version>
|
<version>1.0.7</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -83,6 +83,8 @@ public class RandomTeleport extends JavaPlugin implements RandomTeleportAPI {
|
|||||||
private Material[] unsafeBlocks;
|
private Material[] unsafeBlocks;
|
||||||
private Set<String> signVariables;
|
private Set<String> signVariables;
|
||||||
|
|
||||||
|
private boolean hasMinHeight = true;
|
||||||
|
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
hookManager = new HookManager(this);
|
hookManager = new HookManager(this);
|
||||||
loadConfig();
|
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) {
|
public RandomSearcher getRandomSearcher(Player player, Location origin, int minRange, int maxRange, LocationValidator... validators) {
|
||||||
return new RandomSearcher(this, player, origin, minRange, maxRange, 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);
|
setCenter(center);
|
||||||
setMinRadius(minRadius);
|
setMinRadius(minRadius);
|
||||||
setMaxRadius(maxRadius);
|
setMaxRadius(maxRadius);
|
||||||
minY = center.getWorld().getMinHeight();
|
minY = plugin.getMinHeight(center.getWorld());
|
||||||
if (center.getWorld().getEnvironment() == World.Environment.NETHER) {
|
if (center.getWorld().getEnvironment() == World.Environment.NETHER) {
|
||||||
maxY = 126;
|
maxY = 126;
|
||||||
} else {
|
} else {
|
||||||
@ -257,7 +257,8 @@ public class RandomSearcher {
|
|||||||
* @param minY The min Y; has to be positive and less than the max Y!
|
* @param minY The min Y; has to be positive and less than the max Y!
|
||||||
*/
|
*/
|
||||||
public void setMinY(int minY) {
|
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;
|
this.minY = minY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -362,7 +363,7 @@ public class RandomSearcher {
|
|||||||
}
|
}
|
||||||
lastCheck = center.getWorld().getTime();
|
lastCheck = center.getWorld().getTime();
|
||||||
Location randomLoc = center.clone();
|
Location randomLoc = center.clone();
|
||||||
randomLoc.setY(center.getWorld().getMinHeight());
|
randomLoc.setY(plugin.getMinHeight(center.getWorld()));
|
||||||
int minChunk = minRadius >> 4;
|
int minChunk = minRadius >> 4;
|
||||||
int maxChunk = maxRadius >> 4;
|
int maxChunk = maxRadius >> 4;
|
||||||
int randChunkX;
|
int randChunkX;
|
||||||
|
@ -2,7 +2,7 @@ name: RandomTeleport
|
|||||||
provides: [FUBSRandomTeleport]
|
provides: [FUBSRandomTeleport]
|
||||||
main: de.themoep.randomteleport.RandomTeleport
|
main: de.themoep.randomteleport.RandomTeleport
|
||||||
version: '${minecraft.plugin.version}'
|
version: '${minecraft.plugin.version}'
|
||||||
api-version: 1.17
|
api-version: 1.13
|
||||||
description: ${project.description}
|
description: ${project.description}
|
||||||
author: Phoenix616
|
author: Phoenix616
|
||||||
website: https://github.com/Phoenix616/RandomTeleport/
|
website: https://github.com/Phoenix616/RandomTeleport/
|
||||||
|
Loading…
Reference in New Issue
Block a user