Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@
import com.eternalcode.core.feature.warp.WarpSettings;
import com.eternalcode.core.injector.annotations.Bean;
import com.eternalcode.core.injector.annotations.component.ConfigurationFile;
import com.eternalcode.core.placeholder.PlaceholdersConfig;
import com.eternalcode.core.placeholder.PlaceholdersSettings;
import com.eternalcode.core.translation.TranslationConfig;
import com.eternalcode.core.translation.TranslationSettings;
import eu.okaeri.configs.OkaeriConfig;
Expand Down Expand Up @@ -213,6 +215,12 @@ public static class Format extends OkaeriConfig {
@Comment("# Settings responsible for player vanish functionality")
VanishConfig vanish = new VanishConfig();

@Bean(proxied = PlaceholdersSettings.class)
@Comment("")
@Comment("# Placeholders Configuration")
@Comment("# Settings that define various placeholders used across the plugin")
PlaceholdersConfig placeholders = new PlaceholdersConfig();

@Override
public File getConfigFile(File dataFolder) {
return new File(dataFolder, "config.yml");
Expand Down
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)
Comment on lines +11 to +12
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@Getter
@Accessors(fluent = true)

Copy link
Member

@Jakubk15 Jakubk15 Nov 2, 2025

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 the PlaceholdersSettings interface.

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The explicit implementation of the placeholders() method is redundant. The class-level @Getter and @Accessors(fluent = true) annotations will instruct Lombok to generate an identical method that correctly implements the PlaceholdersSettings interface. Removing this manual override will make the code cleaner and less verbose, fully leveraging Lombok's capabilities for boilerplate reduction.

}
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 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ogolnie Settings odbieramy jako dane a nie zachowanie (MA SENS) w tym przypadku ten interfejs nie ma sensu dodaje tylko zloznosc bez zadnej wartosci bo nadal zalezy od konceptu Settings. Settings to tak naprawde tzw. Value object czyli javowy rekord/klasa. Interfejs to tylko kontrakt dla zachowan. Sens sie pojawia kiedy masz rozne zrodla konfiguracji wtedy Settings sam w sobie nadal jest value objectem

Copy link
Contributor

Choose a reason for hiding this comment

The 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
Expand Up @@ -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;
Expand All @@ -24,9 +23,9 @@
class PlaceholdersSetup {

@Subscribe(EternalInitializeEvent.class)
void setUp(PlaceholderRegistry placeholders, PlaceholdersConfiguration config) {
Copy link
Member

Choose a reason for hiding this comment

The 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 implementation to jest zwykly wyciek abstrakcji niekontrolowany

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 + "}")));
}
}

Expand Down