Conversation
…EffectiveCostResult
…agement and add reload command
…nd add dirty markers tracking
…d improve dirty markers handling
…s; fix inventory arrangement Co-authored-by: TheBjoRedCraft <143264463+TheBjoRedCraft@users.noreply.github.com>
…storage Compact binary storage for DirtyMarker & AwaitingProtectionModeConfig; fix inventory slot order
There was a problem hiding this comment.
Pull request overview
This PR introduces operational/admin additions around protection management, including persistence of in-progress “ProtectionMode” state across shutdowns, startup restoration of marker blocks, and an admin command suite for managing protections.
Changes:
- Add shutdown-safe persistence for unfinished protection mode sessions and “dirty” marker blocks, plus startup restoration logic.
- Introduce a new
protectionadmincommand (delete/teleport/reload) with dedicated permissions and a reusableProtectionArgument. - Consolidate duplicated “region item” UI builder logic into a shared menu util and extend region lore (e.g., center location).
Reviewed changes
Copilot reviewed 23 out of 23 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| src/main/kotlin/dev/slne/surf/protect/paper/util/util.kt | Adds formatting helper for nullable WorldGuard/WorldEdit teleport locations. |
| src/main/kotlin/dev/slne/surf/protect/paper/user/ProtectionUser.kt | Refactors region creation reset/restore flow and adds shutdown persistence hook. |
| src/main/kotlin/dev/slne/surf/protect/paper/user/ProtectionCooldownTracker.kt | Updates config import usage. |
| src/main/kotlin/dev/slne/surf/protect/paper/region/visual/Trail.kt | Updates config import usage. |
| src/main/kotlin/dev/slne/surf/protect/paper/region/visual/Marker.kt | Adds shutdown path to persist marker restoration data instead of editing blocks. |
| src/main/kotlin/dev/slne/surf/protect/paper/region/utils.kt | Updates config import usage. |
| src/main/kotlin/dev/slne/surf/protect/paper/region/ProtectionRegion.kt | Threads a shutdown flag through marker removal/cancel flow. |
| src/main/kotlin/dev/slne/surf/protect/paper/permission/ProtectPermissionRegistry.kt | Adds new admin permissions for the new command tree. |
| src/main/kotlin/dev/slne/surf/protect/paper/message/Messages.kt | Updates config import usage. |
| src/main/kotlin/dev/slne/surf/protect/paper/menu/view/sell/ProtectionSellConfirmView.kt | Removes duplicated region item builder (now shared). |
| src/main/kotlin/dev/slne/surf/protect/paper/menu/view/list/ProtectionListView.kt | Removes duplicated region item builder (now shared). |
| src/main/kotlin/dev/slne/surf/protect/paper/menu/view/book/ProtectionBook.kt | Updates config import usage. |
| src/main/kotlin/dev/slne/surf/protect/paper/menu/view/ProtectionInfoView.kt | Lore rendering tweaks and removes duplicated region item builder. |
| src/main/kotlin/dev/slne/surf/protect/paper/menu/util/view-util.kt | Adds shared createRegionItem builder and displays center location. |
| src/main/kotlin/dev/slne/surf/protect/paper/menu/dialog/ProtectionRenameDialog.kt | Updates config import usage. |
| src/main/kotlin/dev/slne/surf/protect/paper/math/Mth.kt | Adjusts effective cost rounding behavior and updates config import usage. |
| src/main/kotlin/dev/slne/surf/protect/paper/listener/listeners/ProtectionModeListener.kt | Restores awaiting protection mode state on player join. |
| src/main/kotlin/dev/slne/surf/protect/paper/config/ProtectionConfigManager.kt | Introduces a config manager wrapper for loading/editing/saving. |
| src/main/kotlin/dev/slne/surf/protect/paper/config/ProtectionConfig.kt | Adds Base64-blob config entries for dirty markers and awaiting protection sessions. |
| src/main/kotlin/dev/slne/surf/protect/paper/command/commands/protection/argument/ProtectionArgument.kt | Adds a custom CommandAPI argument for selecting protected regions. |
| src/main/kotlin/dev/slne/surf/protect/paper/command/commands/protection/ProtectionAdminCommand.kt | Adds admin delete/teleport/reload commands. |
| src/main/kotlin/dev/slne/surf/protect/paper/command/CommandManager.kt | Registers the new admin command and removes a legacy visualize command. |
| src/main/kotlin/dev/slne/surf/protect/paper/PaperMain.kt | Adds dirty marker restoration on enable and shutdown persistence wiring. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@TheBjoRedCraft I've opened a new pull request, #13, to work on those changes. Once the pull request is ready, I'll request review from you. |
… for player state mutations Co-authored-by: TheBjoRedCraft <143264463+TheBjoRedCraft@users.noreply.github.com>
…in ProtectionArgument
fix(user): ensure resetRegionCreation runs player state mutations on entity dispatcher
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 23 out of 23 changed files in this pull request and generated 11 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| val player = this.bukkitPlayer ?: return | ||
| withContext(plugin.entityDispatcher(player)) { | ||
| restorePlayerProperties( | ||
| player, | ||
| creation.startingInventoryContent.map { it ?: ItemStack.empty() }.toTypedArray() | ||
| ) | ||
| } | ||
|
|
||
| player.teleportAsync(creation.startLocation).await() | ||
| player.teleportAsync(creation.startLocation) | ||
| } |
| suspend fun cancelProtection(shutdown: Boolean = false) { | ||
| removeAllMarkers(shutdown) | ||
|
|
||
| protectionUser.bukkitPlayer?.sendText { | ||
| appendInfoPrefix() | ||
| info("Der Grundstückserstellungsprozess wurde abgebrochen.") | ||
| } | ||
| protectionUser.resetRegionCreation(true) | ||
|
|
||
| protectionUser.resetRegionCreation(true, shutdown) | ||
| } |
| player.teleportAsync(BukkitAdapter.adapt(protection.getFlag(Flags.TELE_LOC))) | ||
| .thenRun { | ||
| player.sendText { | ||
| appendSuccessPrefix() | ||
| success("Du wurdest zum Grundstück teleportiert.") |
| val location: Location | ||
| get() = decodeStream { din -> | ||
| val worldName = din.readUTF() | ||
| val x = din.readInt() | ||
| val y = din.readInt() | ||
| val z = din.readInt() | ||
| Location( | ||
| server.getWorld(worldName) ?: error("World '$worldName' not found"), | ||
| x.toDouble(), | ||
| y.toDouble(), | ||
| z.toDouble() | ||
| ) | ||
| } |
| val regionManager = protection.getRegionManagerOrNull() ?: run { | ||
| player.sendText { | ||
| appendErrorPrefix() | ||
| error("Das Grundstück existiert nicht.") | ||
| } | ||
| return@playerExecutor | ||
| } |
|
|
||
| configManager.edit { | ||
| dirtyMarkers.remove(marker) | ||
| } |
| val configManager = ProtectionConfigManager() | ||
| val config get() = configManager.protectionConfig | ||
|
|
||
| val plugin get() = JavaPlugin.getPlugin(PaperMain::class.java) |
| } | ||
| } | ||
|
|
||
| if (configManager.protectionConfig.dirtyMarkers.isNotEmpty()) { |
| suspend fun removeAllMarkers(shutdown: Boolean = false) { | ||
| coroutineScope { | ||
| markers.toObjectList().map { marker -> | ||
| async { | ||
| marker.restorePreviousData() | ||
| marker.restorePreviousData(shutdown) | ||
| } | ||
| }.awaitAll() | ||
| } |
| fun edit(actions: ProtectionConfig.() -> Unit) { | ||
| configManager.config = configManager.config.apply { actions() } | ||
| configManager.save() | ||
| } |
No description provided.