-
Notifications
You must be signed in to change notification settings - Fork 2
Feat/some updates #24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
TheBjoRedCraft
wants to merge
18
commits into
version/1.21.11
Choose a base branch
from
feat/some-updates
base: version/1.21.11
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
888a6db
feat: add ParentPhase class and update phase parents to use it
ammodev ac5ca0a
feat: update version to 1.21.11-1.0.5-SNAPSHOT and enhance relocation…
TheBjoRedCraft 4771a6a
feat: add relocation height validation to PlayerSession
TheBjoRedCraft 9de077a
fix: remove unnecessary newline and simplify player spawn condition
TheBjoRedCraft 4873cb0
Merge remote-tracking branch 'refs/remotes/origin/chore/add-parent-we…
TheBjoRedCraft 427ceb2
feat: add leaderboard placeholders and integrate LuckPerms for player…
TheBjoRedCraft 917eed0
feat: implement island reset functionality and add leaderboard placeh…
TheBjoRedCraft 3b4d57d
Revert "feat: add ParentPhase class and update phase parents to use it"
TheBjoRedCraft 120e867
fix: adjust distance threshold for nearby islands check
TheBjoRedCraft 51cd0ec
feat: rename placeholder for top ten leaderboard check
TheBjoRedCraft f11ffc4
fix: correct German grammar in relocation error messages
TheBjoRedCraft 679d3a8
feat: update leaderboard placeholders for top ten and own place checks
TheBjoRedCraft da75a83
feat: enhance player name serialization with miniMessage support
TheBjoRedCraft a012c1e
feat: implement player stats flushing on quit and save events
TheBjoRedCraft 13498cb
feat: implement configuration migration for phase parents to enhance …
twisti-dev d885e1c
feat: enhance phase configuration loading with error handling and ref…
twisti-dev 61d707b
feat: update island structure placement logic to use region dispatche…
twisti-dev fbe0774
feat: update database column types to use nativeUuid for improved com…
twisti-dev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
...nts/surf-oneblock/src/main/kotlin/dev/slne/surf/event/oneblock/command/OneBlockCommand.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
119 changes: 67 additions & 52 deletions
119
...nts/surf-oneblock/src/main/kotlin/dev/slne/surf/event/oneblock/command/RelocateCommand.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,76 +1,91 @@ | ||
| package dev.slne.surf.event.oneblock.command | ||
|
|
||
| import com.github.shynixn.mccoroutine.folia.launch | ||
| import dev.jorel.commandapi.arguments.LocationType | ||
| import dev.jorel.commandapi.kotlindsl.* | ||
| import dev.jorel.commandapi.kotlindsl.commandTree | ||
| import dev.jorel.commandapi.kotlindsl.literalArgument | ||
| import dev.jorel.commandapi.kotlindsl.playerExecutor | ||
| import dev.slne.surf.event.oneblock.db.IslandService | ||
| import dev.slne.surf.event.oneblock.permission.OneBlockPermissions | ||
| import dev.slne.surf.event.oneblock.plugin | ||
| import dev.slne.surf.event.oneblock.session.PlayerSession | ||
| import org.bukkit.Location | ||
| import org.bukkit.command.CommandSender | ||
| import org.bukkit.entity.Player | ||
| import java.util.function.Predicate | ||
| import dev.slne.surf.surfapi.core.api.messages.adventure.clickCallback | ||
| import dev.slne.surf.surfapi.core.api.messages.adventure.sendText | ||
| import java.util.* | ||
| import java.util.concurrent.ConcurrentHashMap | ||
| import kotlin.time.Duration.Companion.minutes | ||
|
|
||
| private val isRelocatingPredicate = Predicate<CommandSender> { sender -> | ||
| if (sender is Player) { | ||
| PlayerSession[sender.uniqueId].isRelocating | ||
| } else { | ||
| false | ||
| } | ||
| } | ||
| private val lastTimeRelocated = ConcurrentHashMap<UUID, Long>() | ||
| private val relocatingMillis = 5.minutes.inWholeMilliseconds | ||
|
|
||
| fun relocateCommand() = commandTree("relocate") { | ||
| withPermission(OneBlockPermissions.RELOCATE_COMMAND) | ||
|
|
||
| playerExecutor { sender, args -> | ||
| startRelocate(sender) | ||
| } | ||
| literalArgument("here") { | ||
| playerExecutor { player, _ -> | ||
| val location = player.location | ||
|
|
||
| literalArgument("place") { | ||
| withRequirement(isRelocatingPredicate) | ||
| if (IslandService.anyNearIslands(location)) { | ||
| player.sendText { | ||
| appendErrorPrefix() | ||
| error("In der Nähe gibt es bereits einen OneBlock. Bitte wähle einen anderen Ort.") | ||
| } | ||
| return@playerExecutor | ||
| } | ||
|
|
||
| locationArgument("location", LocationType.BLOCK_POSITION) { | ||
| playerExecutor { sender, args -> | ||
| val location: Location by args | ||
| finishRelocate(sender, location) | ||
| if (System.currentTimeMillis() - (lastTimeRelocated[player.uniqueId] | ||
| ?: 0) < relocatingMillis | ||
| ) { | ||
| player.sendText { | ||
| appendErrorPrefix() | ||
| error("Bitte warte noch ") | ||
| variableValue( | ||
| formatRemaining( | ||
| relocatingMillis - (System.currentTimeMillis() - (lastTimeRelocated[player.uniqueId] | ||
| ?: 0)) | ||
| ) | ||
| ) | ||
| error(" bevor du deinen OneBlock erneut verschieben kannst.") | ||
| } | ||
| return@playerExecutor | ||
| } | ||
| } | ||
| } | ||
|
|
||
| literalArgument("abort") { | ||
| withRequirement(isRelocatingPredicate) | ||
| playerExecutor { sender, args -> | ||
| abortRelocate(sender) | ||
| } | ||
| } | ||
| } | ||
| player.sendText { | ||
| appendInfoPrefix() | ||
| info("Möchtest du deinen Oneblock hierhin verschieben? ") | ||
| append { | ||
| darkSpacer("[") | ||
| success("Verschieben") | ||
| darkSpacer("]") | ||
| clickCallback { | ||
| plugin.launch { | ||
| val session = PlayerSession[player.uniqueId] | ||
| val result = session.relocate(location) | ||
|
|
||
| private fun startRelocate(player: Player) { | ||
| plugin.launch { | ||
| val session = PlayerSession[player.uniqueId] | ||
| val result = session.startRelocate(player) | ||
| player.sendMessage(result) | ||
| if (result.isSuccess()) { | ||
| lastTimeRelocated[player.uniqueId] = System.currentTimeMillis() | ||
| } | ||
|
|
||
| if (result == PlayerSession.RelocateResult.START_RELOCATING) { | ||
| player.updateCommands() | ||
| player.sendText { | ||
| append(result) | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| private fun finishRelocate(player: Player, loc: Location) { | ||
| plugin.launch { | ||
| val session = PlayerSession[player.uniqueId] | ||
| val result = session.finishRelocate(player, loc) | ||
| player.sendMessage(result) | ||
| player.updateCommands() | ||
| } | ||
| } | ||
| private fun formatRemaining(remainingMillis: Long) = buildString { | ||
| val seconds = remainingMillis / 1000 | ||
| val minutes = seconds / 60 | ||
| val remainingSeconds = seconds % 60 | ||
|
|
||
| private fun abortRelocate(player: Player) { | ||
| plugin.launch { | ||
| val session = PlayerSession[player.uniqueId] | ||
| session.abortRelocate() | ||
| player.sendMessage(PlayerSession.RelocateResult.ABORTED) | ||
| player.updateCommands() | ||
| if (minutes > 0) { | ||
| append("$minutes Minuten") | ||
| } | ||
| if (remainingSeconds > 0) { | ||
| if (minutes > 0) append(" und ") | ||
| append("$remainingSeconds Sekunden") | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.