Skip to content

Commit

Permalink
Update to Minecraft 1.20
Browse files Browse the repository at this point in the history
  • Loading branch information
Sytm committed Jun 9, 2023
1 parent cae64ea commit cbc377d
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 27 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,8 @@ This plugin is licensed under the MIT license. For more information on it, you c
Because I don't have the time or motivation to support a lot of versions, and it is generally advised to update to the latest Minecraft/Spigot versions only the
last 3 major updates with the latest builds are supported.

At the time of writing this would be 1.19.3, 1.18.2 and 1.17.1, but not 1.18, 1.16.4 or 1.15.2.
At the time of writing this would be 1.20, 1.19.4 and 1.18.2 but not 1.18, 1.16.4 or 1.15.2.
<!-- modrinth_exclude.end -->
### Java version

Java 16 is the minimum required version.
Java 17 is the minimum required version.
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@
org.gradle.jvmargs=-Xmx2G
org.gradle.warning.mode=all
# Kotlin
jvmTarget=16
kotlinVersion=1.8.10
jvmTarget=17
kotlinVersion=1.8.21
shadowVersion=8.1.0
dokkaVersion=1.7.20
group=de.md5lukas.waypoints
version=3.6.3
version=3.6.4
# Spigot
spigotVersion=1.17.1-R0.1-SNAPSHOT
spigotVersion=1.18.2-R0.1-SNAPSHOT
# Required dependencies
md5CommonsVersion=2.0.0
sqliteHelperVersion=1.2.0
kinvsVersion=1.0.2
anvilGUIVersion=1.6.6-SNAPSHOT
bstatsVersion=3.0.1
commandApiVersion=9.0.0
commandApiVersion=9.0.2
# Optional dependencies
vaultVersion=1.7.1
dynmapVersion=3.3
Expand Down
17 changes: 3 additions & 14 deletions utils/src/main/kotlin/de/md5lukas/waypoints/util/SpigotHelper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -89,21 +89,10 @@ fun parseLocationString(player: Player, input: String): Location? {
}
}

private const val MAX_MAP_SIZE: Double = 30_000_000.0
fun isLocationOutOfBounds(location: Location): Boolean {
val world = location.world!!

fun isLocationOutOfBounds(plugin: Plugin, location: Location): Boolean {
if (abs(location.x) >= MAX_MAP_SIZE || abs(location.z) >= MAX_MAP_SIZE) {
return true
}

// TODO: Remove once 1.20 is out
val validYValues = if (isMinecraftVersionEqualOrLaterThan(plugin, 18, 0)) {
-64..320
} else {
0..256
}

return location.y.roundToInt() !in validYValues
return !world.worldBorder.isInside(location) || location.y.roundToInt() !in world.minHeight until world.maxHeight
}

fun isMinecraftVersionEqualOrLaterThan(plugin: Plugin, major: Int, minor: Int = 0): Boolean {
Expand Down
4 changes: 2 additions & 2 deletions waypoints/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ kotlin {

tasks.withType<KotlinCompile> {
// To make sure we have an explicit dependency on the project itself because otherwise we will get a warning that we only depend on an output file and not the project itself
dependsOn(project(":api-sqlite").tasks.jar)
dependsOn(project(":api-sqlite").tasks.shadowJar)
}

tasks.withType<ShadowJar> {
Expand Down Expand Up @@ -154,7 +154,7 @@ modrinth {
versionType.set("release")
uploadFile.set(tasks.shadowJar as Any)

gameVersions.addAll("1.19.3", "1.18.2", "1.17.1")
gameVersions.addAll("1.20", "1.19.4", "1.18.2")
loaders.addAll("spigot", "paper")

syncBodyFrom.set(rootProject.file("README.md").readText())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ class WaypointsCommand(private val plugin: WaypointsPlugin) {
playerExecutor { player, args ->
val location = args[0] as Location

if (isLocationOutOfBounds(plugin, location)) {
if (isLocationOutOfBounds(location)) {
translations.WAYPOINT_CREATE_COORDINATES_OUT_OF_BOUNDS.send(player)
} else {
plugin.api.pointerManager.let {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class WaypointsScriptCommand(private val plugin: WaypointsPlugin) {
return@anyExecutor
}

if (isLocationOutOfBounds(plugin, target)) {
if (isLocationOutOfBounds(target)) {
translations.WAYPOINT_CREATE_COORDINATES_OUT_OF_BOUNDS.send(sender)
} else {
plugin.api.pointerManager.let {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ class GUIFolderPage(wpGUI: WaypointsGUI, private val guiFolder: GUIFolder) : Lis
if (location === null) {
wpGUI.translations.WAYPOINT_CREATE_COORDINATES_INVALID_FORMAT.send(wpGUI.viewer)
AnvilGUI.ResponseAction.replaceInputText(coordinates)
} else if (isLocationOutOfBounds(wpGUI.plugin, location)) {
} else if (isLocationOutOfBounds(location)) {
wpGUI.translations.WAYPOINT_CREATE_COORDINATES_OUT_OF_BOUNDS.send(wpGUI.viewer)
AnvilGUI.ResponseAction.replaceInputText(coordinates)
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ private fun creationPreChecks(plugin: WaypointsPlugin, player: Player, location:
return WorldUnavailable
}

if (isLocationOutOfBounds(plugin, location)) {
if (isLocationOutOfBounds(location)) {
plugin.translations.WAYPOINT_CREATE_COORDINATES_OUT_OF_BOUNDS.send(player)
return LocationOutOfBounds
}
Expand Down

0 comments on commit cbc377d

Please sign in to comment.