Skip to content

Commit a616aaa

Browse files
committed
feat: 1.21.11 support
1 parent 17bae0d commit a616aaa

File tree

7 files changed

+73
-86
lines changed

7 files changed

+73
-86
lines changed

build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ repositories {
2020
maven("https://papermc.io/repo/repository/maven-public/") //Paper
2121
maven("https://repo.codemc.org/repository/maven-public/")
2222
maven("https://maven.enginehub.org/repo/") // WorldGuard
23+
mavenLocal()
2324
}
2425

2526
dependencies {

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
group=com.mineinabyss
22
version=0.12
3-
idofrontVersion=0.26.0
3+
idofrontVersion=1.1.0
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.1-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

settings.gradle.kts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ pluginManagement {
44
maven("https://repo.mineinabyss.com/releases")
55
maven("https://repo.mineinabyss.com/snapshots")
66
maven("https://repo.papermc.io/repository/maven-public/") //Paper
7+
mavenLocal()
78
}
89

910
val idofrontVersion: String by settings
@@ -21,6 +22,7 @@ dependencyResolutionManagement {
2122
repositories {
2223
maven("https://repo.mineinabyss.com/releases")
2324
maven("https://repo.mineinabyss.com/snapshots")
25+
mavenLocal()
2426
}
2527
versionCatalogs{
2628
create("idofrontLibs").from("com.mineinabyss:catalog:$idofrontVersion")

src/main/kotlin/com/mineinabyss/deeperworld/DeeperCommands.kt

Lines changed: 57 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -88,83 +88,70 @@ object DeeperCommands {
8888
}
8989

9090
when {
91-
Plugins.isEnabled("FastAsyncWorldEdit") -> {
92-
try {
93-
val pos1 = BlockVector3.at(
94-
(player.location.x + range),
95-
(player.location.y + range),
96-
(player.location.z + range)
97-
)
98-
val pos2 = BlockVector3.at(
99-
(player.location.x - range),
100-
(player.location.y - range),
101-
(player.location.z - range)
102-
)
103-
104-
val region = CuboidRegion(pos1, pos2)
105-
val clipboard = BlockArrayClipboard(region)
106-
val wep = WorldEditPlugin.getInstance().bukkitImplAdapter
107-
val weWorld: World = wep.adapt(player.world)
108-
val editSession: EditSession = WorldEdit.getInstance().newEditSessionBuilder()
109-
.world(weWorld)
110-
.limitUnlimited()
111-
.build()
112-
113-
val loc = player.location
114-
val linkedSection =
115-
loc.correspondingSection ?: error("Corresponding Section not found")
116-
117-
val linkedBlock = loc.getCorrespondingLocation(section, linkedSection)?.block
118-
?: error("Corresponding Location not found")
119-
120-
val offset = if (pos2.y < 0) pos2.y else 0
121-
TaskManager.taskManager().taskNowAsync {
122-
player.success("Blocks syncing...")
123-
editSession.use { editSession ->
124-
// Copy
125-
val forwardExtentCopy =
126-
ForwardExtentCopy(
127-
editSession, region, clipboard, region.minimumPoint
91+
Plugins.isEnabled("FastAsyncWorldEdit") -> runCatching {
92+
val pos1 = BlockVector3.at(
93+
(player.location.x + range),
94+
(player.location.y + range),
95+
(player.location.z + range)
96+
)
97+
val pos2 = BlockVector3.at(
98+
(player.location.x - range),
99+
(player.location.y - range),
100+
(player.location.z - range)
101+
)
102+
103+
val region = CuboidRegion(pos1, pos2)
104+
val clipboard = BlockArrayClipboard(region)
105+
val wep = WorldEditPlugin.getInstance().bukkitImplAdapter
106+
val weWorld: World = wep.adapt(player.world)
107+
val editSession: EditSession = WorldEdit.getInstance().newEditSessionBuilder()
108+
.world(weWorld).limitUnlimited().build()
109+
110+
val loc = player.location
111+
val linkedSection = loc.correspondingSection ?: error("Corresponding Section not found")
112+
113+
val linkedBlock = loc.getCorrespondingLocation(section, linkedSection)?.block
114+
?: error("Corresponding Location not found")
115+
116+
val offset = pos2.y().coerceAtLeast(0)
117+
TaskManager.taskManager().taskNowAsync {
118+
player.success("Blocks syncing...")
119+
editSession.use { editSession ->
120+
// Copy
121+
val forwardExtentCopy = ForwardExtentCopy(editSession, region, clipboard, region.minimumPoint)
122+
forwardExtentCopy.isCopyingEntities = false
123+
forwardExtentCopy.isCopyingBiomes = true
124+
Operations.complete(forwardExtentCopy)
125+
126+
// Paste
127+
val operation: Operation = ClipboardHolder(clipboard)
128+
.createPaste(editSession)
129+
.to(
130+
BlockVector3.at(
131+
linkedBlock.x - range,
132+
linkedBlock.y - range - offset,
133+
linkedBlock.z - range
128134
)
129-
forwardExtentCopy.isCopyingEntities = false
130-
forwardExtentCopy.isCopyingBiomes = true
131-
Operations.complete(forwardExtentCopy)
132-
133-
// Paste
134-
val operation: Operation = ClipboardHolder(clipboard)
135-
.createPaste(editSession)
136-
.to(
137-
BlockVector3.at(
138-
linkedBlock.x - range,
139-
linkedBlock.y - range - offset,
140-
linkedBlock.z - range
141-
)
142-
).build()
143-
Operations.complete(operation)
144-
}
145-
player.success("Blocks synced (FAWE)")
135+
).build()
136+
Operations.complete(operation)
146137
}
147-
} catch (e: Exception) {
148-
player.error("""An error occurred: ${e.message}""")
138+
player.success("Blocks synced (FAWE)")
149139
}
140+
}.onFailure {
141+
player.error("""An error occurred: ${it.message}""")
150142
}
151143

152144
range <= 100 -> {
153145
// Get blocks in range specified
154-
for (x in -range..range) {
155-
for (y in -range..range) {
156-
for (z in -range..range) {
157-
val block = player.world.getBlockAt(
158-
(player.location.x + x).toInt(),
159-
(player.location.y + y).toInt(),
160-
(player.location.z + z).toInt()
161-
)
162-
163-
block.sync { original, corr ->
164-
if (original.type != corr.type) corr.blockData =
165-
original.blockData.clone()
166-
}
167-
}
146+
for (x in -range..range) for (y in -range..range) for (z in -range..range) {
147+
val block = player.world.getBlockAt(
148+
(player.location.x + x).toInt(),
149+
(player.location.y + y).toInt(),
150+
(player.location.z + z).toInt()
151+
)
152+
153+
block.sync { original, corr ->
154+
if (original.type != corr.type) corr.blockData = original.blockData.clone()
168155
}
169156
}
170157

src/main/kotlin/com/mineinabyss/deeperworld/listeners/PlayerListener.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import org.bukkit.GameMode.CREATIVE
99
import org.bukkit.event.EventHandler
1010
import org.bukkit.event.Listener
1111
import org.bukkit.event.player.PlayerTeleportEvent
12-
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.CHORUS_FRUIT
1312
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.ENDER_PEARL
1413
import org.bukkit.event.vehicle.VehicleEnterEvent
1514
import org.bukkit.event.vehicle.VehicleExitEvent
@@ -18,7 +17,7 @@ object PlayerListener : Listener {
1817
@EventHandler
1918
fun PlayerTeleportEvent.onPlayerTeleport() {
2019
if (player.gameMode == CREATIVE || !player.canMoveSections) return
21-
if (cause != ENDER_PEARL && cause != CHORUS_FRUIT) return
20+
if (cause != ENDER_PEARL && cause != PlayerTeleportEvent.TeleportCause.CONSUMABLE_EFFECT) return
2221
if (to.section != null && to.section == player.location.section && !to.inSectionTransition) return
2322

2423
player.error("Teleportation is disabled between Layers and Sections.")

src/main/kotlin/com/mineinabyss/deeperworld/movement/TransitionTeleportHandler.kt

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,10 @@ class TransitionTeleportHandler(val teleportEntity: Entity, val from: Location,
2525
}
2626

2727
private val teleportFlags: Array<TeleportFlag> = listOf(
28-
TeleportFlag.Relative.YAW,
29-
TeleportFlag.Relative.PITCH,
30-
TeleportFlag.Relative.X,
31-
TeleportFlag.Relative.Y,
32-
TeleportFlag.Relative.Z,
33-
TeleportFlag.EntityState.RETAIN_PASSENGERS,
34-
TeleportFlag.EntityState.RETAIN_VEHICLE
28+
TeleportFlag.Relative.VELOCITY_ROTATION,
29+
TeleportFlag.Relative.VELOCITY_X,
30+
TeleportFlag.Relative.VELOCITY_Y,
31+
TeleportFlag.Relative.VELOCITY_Z
3532
).toTypedArray()
3633

3734
override fun handleTeleport() {
@@ -100,13 +97,14 @@ class TransitionTeleportHandler(val teleportEntity: Entity, val from: Location,
10097
// Max leashed entity range is 10 blocks, therefore these parameter values
10198
return when (teleportEntity) {
10299
is Player -> mapOf(
103-
teleportEntity to teleportEntity.location
104-
.getNearbyEntitiesByType(LivingEntity::class.java, 20.0)
105-
.filter { it.isLeashed && it.leashHolder.uniqueId == teleportEntity.uniqueId }.toSet())
100+
teleportEntity to teleportEntity.location.getNearbyEntitiesByType(LivingEntity::class.java, 20.0) {
101+
it.isLeashed && it.leashHolder.uniqueId == teleportEntity.uniqueId
102+
}.toSet())
106103

107104
else -> teleportEntity.passengers.filterIsInstance<Player>().associateWith { player ->
108-
player.location.getNearbyEntitiesByType(LivingEntity::class.java, 20.0)
109-
.filter { it.isLeashed && it.leashHolder.uniqueId == player.uniqueId }.toSet()
105+
player.location.getNearbyEntitiesByType(LivingEntity::class.java, 20.0) {
106+
it.isLeashed && it.leashHolder.uniqueId == player.uniqueId
107+
}.toSet()
110108
}
111109
}
112110
}

0 commit comments

Comments
 (0)