-
Notifications
You must be signed in to change notification settings - Fork 0
Feat/add surf settings #13
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
Draft
TheBjoRedCraft
wants to merge
8
commits into
version/1.21.10
Choose a base branch
from
feat/add-surf-settings
base: version/1.21.10
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.
Draft
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
bba46f6
feat: implement settings management with SettingsService and sound to…
TheBjoRedCraft 573cea3
Merge remote-tracking branch 'origin/version/1.21.10' into feat/add-s…
TheBjoRedCraft 84b5ffb
feat: update surf-settings-api-common version and refactor sound sett…
TheBjoRedCraft 63d2214
chore: update version to 1.21.10-2.0.4-SNAPSHOT in gradle.properties
TheBjoRedCraft 205be40
feat: conditionally register settings service if settings API is avai…
TheBjoRedCraft 37c61c6
feat: add logging for surf-settings registration and check settings A…
TheBjoRedCraft 8f29416
feat: ensure sound plays for ender dragon growl in all conditions
TheBjoRedCraft 57fc360
Update src/main/kotlin/dev/slne/surf/essentials/service/SettingsServi…
TheBjoRedCraft 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,28 @@ | ||
| import dev.slne.surf.surfapi.gradle.util.registerSoft | ||
| import net.minecrell.pluginyml.paper.PaperPluginDescription | ||
|
|
||
| plugins { | ||
| id("dev.slne.surf.surfapi.gradle.paper-plugin") | ||
| } | ||
|
|
||
| group = "dev.slne.surf.essentials" | ||
| version = findProperty("version") as String | ||
|
|
||
| dependencies { | ||
| compileOnly("dev.slne.surf.settings:surf-settings-api-common:1.21.10-1.0.1") | ||
| } | ||
|
|
||
| surfPaperPluginApi { | ||
| mainClass("dev.slne.surf.essentials.PaperMain") | ||
| generateLibraryLoader(false) | ||
| foliaSupported(true) | ||
|
|
||
| serverDependencies { | ||
| registerSoft( | ||
| "surf-settings-paper", | ||
| loadOrder = PaperPluginDescription.RelativeLoadOrder.BEFORE | ||
| ) | ||
| } | ||
|
|
||
| authors.addAll("twisti", "red") | ||
| } |
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,4 +1,4 @@ | ||
| kotlin.code.style=official | ||
| kotlin.stdlib.default.dependency=false | ||
| org.gradle.parallel=true | ||
| version=1.21.10-2.0.3-SNAPSHOT | ||
| version=1.21.10-2.0.4-SNAPSHOT |
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
39 changes: 39 additions & 0 deletions
39
src/main/kotlin/dev/slne/surf/essentials/service/SettingsService.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 |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| package dev.slne.surf.essentials.service | ||
|
|
||
| import dev.slne.surf.settings.api.common.dsl.settings | ||
| import dev.slne.surf.settings.api.common.surfSettingApi | ||
| import dev.slne.surf.surfapi.core.api.util.logger | ||
| import java.util.* | ||
|
|
||
| class SettingsService { | ||
| suspend fun register() { | ||
| logger().atInfo().log("Hooking into surf-settings...") | ||
| settings { | ||
| setting { | ||
| identifier = SPECIAL_ITEM_SOUNDS | ||
| displayName = "Special Item Geräusche" | ||
| description = | ||
| "Aktiviert oder deaktiviert Geräusche, wenn ein Spieler einen besonderen Gegenstand erhält." | ||
| category = CATEGORY_ID | ||
| defaultValue = "true" | ||
| } | ||
| } | ||
| logger().atInfo().log("Successfully hooked into surf-settings.") | ||
| } | ||
|
|
||
| suspend fun hasSoundsEnabled(uuid: UUID): Boolean { | ||
| val setting = surfSettingApi.getSetting(SPECIAL_ITEM_SOUNDS) ?: return false | ||
| val value = surfSettingApi.getEntry(uuid, setting) | ||
|
|
||
| return value?.value?.toBooleanStrictOrNull() ?: false | ||
| } | ||
|
|
||
|
|
||
TheBjoRedCraft marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| companion object { | ||
| val INSTANCE = SettingsService() | ||
| const val CATEGORY_ID = "essentials" | ||
| const val SPECIAL_ITEM_SOUNDS = "essentials-special_item_sounds" | ||
| } | ||
| } | ||
|
|
||
| val settingsService get() = SettingsService.INSTANCE | ||
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.