-
-
Notifications
You must be signed in to change notification settings - Fork 21
GH-973 Rename and restructure placeholders configuration classes #1225
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| package com.eternalcode.core.placeholder; | ||
|
|
||
| import eu.okaeri.configs.OkaeriConfig; | ||
| import eu.okaeri.configs.annotation.Comment; | ||
| import lombok.Getter; | ||
| import lombok.experimental.Accessors; | ||
|
|
||
| import java.util.Map; | ||
|
|
||
|
|
||
| @Getter | ||
| @Accessors(fluent = true) | ||
| public class PlaceholdersConfig extends OkaeriConfig implements PlaceholdersSettings { | ||
|
|
||
| @Comment("# Map of available placeholders and their default values") | ||
| public Map<String, String> placeholders = Map.of( | ||
| "prefix", "&7", | ||
| "online_count", "{ONLINE}" | ||
| ); | ||
|
|
||
| @Override | ||
| public Map<String, String> placeholders() { | ||
| return placeholders; | ||
| } | ||
|
Comment on lines
+21
to
+24
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The explicit implementation of the |
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| package com.eternalcode.core.placeholder; | ||
|
|
||
| import java.util.Map; | ||
|
|
||
| public interface PlaceholdersSettings { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ogolnie
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think an interface isn’t needed here. This is just a placeholders config, and at this point, I’m overengineering it. |
||
| Map<String, String> placeholders(); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,7 +3,6 @@ | |
| import com.eternalcode.annotations.scan.placeholder.PlaceholdersDocs; | ||
| import com.eternalcode.annotations.scan.placeholder.PlaceholdersDocs.Entry; | ||
| import com.eternalcode.annotations.scan.placeholder.PlaceholdersDocs.Entry.Type; | ||
| import com.eternalcode.core.configuration.implementation.PlaceholdersConfiguration; | ||
| import com.eternalcode.core.feature.vanish.VanishService; | ||
| import com.eternalcode.core.injector.annotations.component.Controller; | ||
| import com.eternalcode.core.publish.event.EternalInitializeEvent; | ||
|
|
@@ -24,9 +23,9 @@ | |
| class PlaceholdersSetup { | ||
|
|
||
| @Subscribe(EternalInitializeEvent.class) | ||
| void setUp(PlaceholderRegistry placeholders, PlaceholdersConfiguration config) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Musimy tez wiedziec czym jest Configuration vs Config bo raz jest tak raz tak sama w sobie paczka |
||
| for (String key : config.placeholders.keySet()) { | ||
| placeholders.register(Placeholder.of(key, player -> config.placeholders.getOrDefault(key, "{" + key + "}"))); | ||
| void setUp(PlaceholderRegistry placeholders, PlaceholdersSettings config) { | ||
| for (String key : config.placeholders().keySet()) { | ||
| placeholders.register(Placeholder.of(key, player -> config.placeholders().getOrDefault(key, "{" + key + "}"))); | ||
| } | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, instead the author should remove the
placeholders()getter explicitly. Annotations should be kept unless we are getting rid of thePlaceholdersSettingsinterface.