Skip to content

Commit 1525967

Browse files
vLuckyyyRollczi
andauthored
GH-134 GH-153 GH-155 Fix Wrong replacement, remove chatformatter.legacycolor permission (#156)
* GH-134 GH-153 Fix Wrong replacement, remove chatformatter.legacycolor permission. Signed-off-by: vLuckyyy <[email protected]> * Follow Ai Review Signed-off-by: vLuckyyy <[email protected]> * Add pride, score, shadow permission. Fix insertion permission typo. Fix GSON component serialization. Simplify PlaceholderRegistry. Remove code related to ampersand shadowing. Fix run paper. Make Vault and PlaceholderAPI softly dependent. Fix junit. --------- Signed-off-by: vLuckyyy <[email protected]> Co-authored-by: Rollczi <[email protected]>
1 parent 87e82b2 commit 1525967

25 files changed

+286
-382
lines changed

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@
44
*.iws
55
.idea/
66
.gradle/
7-
out/
87
build/
9-
node_modules/
108
dist/
119
run/
10+
.kotlin
1211

1312
.DS_Store
1413
[Dd]esktop.ini

README.md

Lines changed: 45 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -34,46 +34,51 @@
3434

3535
## 🔑 Permissions:
3636

37-
| **Permission** | **Access** |
38-
|:------------------------------------------|:------------------------------------------------------------------------|
39-
| `chatformatter.decorations.*` | `<bold>`, `<italic>`, `<underlined>`, `<strikethrough>`, `<obfuscated>` |
40-
| `chatformatter.decorations.bold` | `<bold>` |
41-
| `chatformatter.decorations.italic` | `<italic>` |
42-
| `chatformatter.decorations.underlined` | `<underlined>` |
43-
| `chatformatter.decorations.strikethrough` | `<strikethrough>` |
44-
| `chatformatter.decorations.obfuscated` | `<obfuscated>` |
45-
| `chatformatter.reset` | `<reset>` |
46-
| `chatformatter.gradient` | `<gradient>` |
47-
| `chatformatter.hover` | `<hover>` |
48-
| `chatformatter.click` | `<click>` |
49-
| `chatformatter.insertion` | `<insertion>` |
50-
| `chatformatter.font` | `<font>` |
51-
| `chatformatter.transition` | `<transition>` |
52-
| `chatformatter.translatable` | `<lang>` |
53-
| `chatformatter.selector` | `<selector>` |
54-
| `chatformatter.keybind` | `<key>` |
55-
| `chatformatter.newline` | `<newline>` |
56-
| `chatformatter.rainbow` | `<rainbow>` |
57-
| `chatformatter.color.*` | `<red>`, `<blue>`, etc. |
58-
| `chatformatter.legacycolor` | `&c`, `&4`, `&l`, etc. |
59-
| `chatformatter.color.black` | `<black>` |
60-
| `chatformatter.color.dark_blue` | `<dark_blue>` |
61-
| `chatformatter.color.dark_green` | `<dark_green>` |
62-
| `chatformatter.color.dark_aqua` | `<dark_aqua>` |
63-
| `chatformatter.color.dark_red` | `<dark_red>` |
64-
| `chatformatter.color.dark_purple` | `<dark_purple>` |
65-
| `chatformatter.color.gold` | `<gold>` |
66-
| `chatformatter.color.gray` | `<gray>` |
67-
| `chatformatter.color.dark_gray` | `<dark_gray>` |
68-
| `chatformatter.color.blue` | `<blue>` |
69-
| `chatformatter.color.green` | `<green>` |
70-
| `chatformatter.color.aqua` | `<aqua>` |
71-
| `chatformatter.color.red` | `<red>` |
72-
| `chatformatter.color.light_purple` | `<light_purple>` |
73-
| `chatformatter.color.yellow` | `<yellow>` |
74-
| `chatformatter.color.white` | `<white>` |
75-
| `chatformatter.reload` | `/chatformatter reload` |
76-
| `chatformatter.receiveupdates` | receive update announcements for this plugin |
37+
> **Note:** Each color and decoration permission (e.g., `chatformatter.color.white`, `chatformatter.reset`, `chatformatter.decorations.bold`) grants access to both the legacy code (e.g., `&f`, `&r`, `&l`) and the MiniMessage tag (e.g., `<white>`, `<reset>`, `<bold>`).
38+
39+
| **Permission** | **Access** |
40+
|:------------------------------------------|:------------------------------------------------------------------------------------------------------|
41+
| `chatformatter.decorations.*` | `<bold>`, `<italic>`, `<underlined>`, `<strikethrough>`, `<obfuscated>`, `&l`, `&o`, `&n`, `&m`, `&k` |
42+
| `chatformatter.decorations.bold` | `<bold>`, `<b>`, `&l` |
43+
| `chatformatter.decorations.italic` | `<italic>`, `<i>`, `<em>`, `&o` |
44+
| `chatformatter.decorations.underlined` | `<underlined>`, `&n` |
45+
| `chatformatter.decorations.strikethrough` | `<strikethrough>`, `<st>`, `&m` |
46+
| `chatformatter.decorations.obfuscated` | `<obfuscated>`, `<obf>`, `&k` |
47+
| `chatformatter.reset` | `<reset>`, `&r` |
48+
| `chatformatter.newline` | `<newline>`, `<br>` |
49+
| `chatformatter.shadow` | `<shadow>`, |
50+
| `chatformatter.gradient` | `<gradient>` |
51+
| `chatformatter.rainbow` | `<rainbow>` |
52+
| `chatformatter.pride` | `<pride>` |
53+
| `chatformatter.transition` | `<transition>` |
54+
| `chatformatter.hover` | `<hover>` |
55+
| `chatformatter.click` | `<click>` |
56+
| `chatformatter.insertion` | `<insertion>` |
57+
| `chatformatter.color.*` | All color codes: `<red>`, `<blue>`, `<#a568a9>`, `&c`, `&#a568a9`, etc. |
58+
| `chatformatter.color.black` | `<black>`, `&0` |
59+
| `chatformatter.color.dark_blue` | `<dark_blue>`, `&1` |
60+
| `chatformatter.color.dark_green` | `<dark_green>`, `&2` |
61+
| `chatformatter.color.dark_aqua` | `<dark_aqua>`, `&3` |
62+
| `chatformatter.color.dark_red` | `<dark_red>`, `&4` |
63+
| `chatformatter.color.dark_purple` | `<dark_purple>`, `&5` |
64+
| `chatformatter.color.gold` | `<gold>`, `&6` |
65+
| `chatformatter.color.gray` | `<gray>`, `&7` |
66+
| `chatformatter.color.dark_gray` | `<dark_gray>`, `&8` |
67+
| `chatformatter.color.blue` | `<blue>`, `&9` |
68+
| `chatformatter.color.green` | `<green>`, `&a` |
69+
| `chatformatter.color.aqua` | `<aqua>`, `&b` |
70+
| `chatformatter.color.red` | `<red>`, `&c` |
71+
| `chatformatter.color.light_purple` | `<light_purple>`, `&d` |
72+
| `chatformatter.color.yellow` | `<yellow>`, `&e` |
73+
| `chatformatter.color.white` | `<white>`, `&f` |
74+
| `chatformatter.score` | `<score>` |
75+
| `chatformatter.selector` | `<selector>` |
76+
| `chatformatter.font` | `<font>` |
77+
| `chatformatter.translatable` | `<lang>` |
78+
| `chatformatter.keybind` | `<key>` |
79+
| `chatformatter.nbt` | `<nbt>` |
80+
| `chatformatter.reload` | `/chatformatter reload` |
81+
| `chatformatter.receiveupdates` | receive update announcements for this plugin |
7782

7883
### config.yml
7984

build.gradle.kts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,4 +88,8 @@ tasks.runServer {
8888
minecraftVersion("1.21.4")
8989
dependsOn("shadowAll")
9090
pluginJars = files("/build/libs/ChatFormatter v${project.version}.jar")
91+
// We need to start the server with Java 21, but jar is built with Java 17
92+
javaLauncher.set(javaToolchains.launcherFor {
93+
languageVersion.set(JavaLanguageVersion.of(21))
94+
})
9195
}

chatformatter-core/build.gradle.kts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,15 @@ dependencies {
1111

1212
// Kyori Adventure & MiniMessage
1313
val adventureVersion = "4.4.0"
14-
val miniMessageVersion = "4.21.0"
15-
implementation("net.kyori:adventure-platform-bukkit:$adventureVersion")
14+
val miniMessageVersion = "4.23.0"
15+
implementation("net.kyori:adventure-api:$miniMessageVersion")
1616
implementation("net.kyori:adventure-text-minimessage:$miniMessageVersion")
17+
implementation("net.kyori:adventure-platform-bukkit:$adventureVersion")
1718
testImplementation("net.kyori:adventure-platform-bukkit:$adventureVersion")
1819
testImplementation("net.kyori:adventure-text-minimessage:$miniMessageVersion")
1920

2021
// CDN Configs
21-
val cdnVersion = "1.14.8"
22+
val cdnVersion = "1.14.9"
2223
implementation("net.dzikoysk:cdn:$cdnVersion")
2324
testImplementation("net.dzikoysk:cdn:$cdnVersion")
2425

@@ -33,9 +34,12 @@ dependencies {
3334
implementation("com.eternalcode:gitcheck:1.0.0")
3435

3536
// JUnit 5
36-
testImplementation("org.junit.jupiter:junit-jupiter-api:5.13.1")
37-
testImplementation("org.junit.jupiter:junit-jupiter-params:5.13.1")
38-
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.13.1")
37+
testImplementation(platform("org.junit:junit-bom:5.13.1"))
38+
testImplementation("org.junit.jupiter:junit-jupiter-api")
39+
testImplementation("org.junit.jupiter:junit-jupiter-params")
40+
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
41+
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine")
42+
3943
testImplementation("org.mockito:mockito-core:5.18.0")
4044
testImplementation("org.mockito:mockito-junit-jupiter:5.18.0")
4145
testImplementation("me.clip:placeholderapi:2.11.6")

chatformatter-core/src/main/java/com/eternalcode/formatter/ChatFormatterPlugin.java

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,19 @@
44
import com.eternalcode.formatter.config.PluginConfig;
55
import com.eternalcode.formatter.legacy.LegacyPostProcessor;
66
import com.eternalcode.formatter.legacy.LegacyPreProcessor;
7-
import com.eternalcode.formatter.placeholder.ConfiguredPlaceholderAPIStack;
8-
import com.eternalcode.formatter.placeholder.PlaceholderAPIStack;
7+
import com.eternalcode.formatter.placeholder.ConfiguredReplacer;
8+
import com.eternalcode.formatter.placeholderapi.PlaceholderAPIInitializer;
99
import com.eternalcode.formatter.placeholder.PlaceholderRegistry;
1010
import com.eternalcode.formatter.rank.ChatRankProvider;
11-
import com.eternalcode.formatter.rank.VaultRankProvider;
11+
import com.eternalcode.formatter.rank.VaultInitializer;
1212
import com.eternalcode.formatter.template.TemplateService;
1313
import com.eternalcode.formatter.updater.UpdaterController;
1414
import com.eternalcode.formatter.updater.UpdaterService;
1515
import com.google.common.base.Stopwatch;
1616
import net.kyori.adventure.platform.AudienceProvider;
1717
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
1818
import net.kyori.adventure.text.minimessage.MiniMessage;
19+
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
1920
import org.bstats.bukkit.Metrics;
2021
import org.bukkit.Server;
2122
import org.bukkit.plugin.Plugin;
@@ -40,15 +41,11 @@ public ChatFormatterPlugin(Plugin plugin) {
4041
PluginConfig pluginConfig = configManager.getPluginConfig();
4142

4243
this.placeholderRegistry = new PlaceholderRegistry();
43-
44-
PlaceholderAPIStack placeholderAPIStack = new PlaceholderAPIStack();
45-
this.placeholderRegistry.playerStack(new ConfiguredPlaceholderAPIStack(pluginConfig));
46-
this.placeholderRegistry.playerStack(placeholderAPIStack);
47-
this.placeholderRegistry.playerRelationalStack(placeholderAPIStack);
48-
44+
PlaceholderAPIInitializer.initialize(server, this.placeholderRegistry);
45+
this.placeholderRegistry.addReplacer(new ConfiguredReplacer(pluginConfig));
4946

5047
this.templateService = new TemplateService(pluginConfig);
51-
this.rankProvider = new VaultRankProvider(server);
48+
this.rankProvider = VaultInitializer.initialize(server);
5249
UpdaterService updaterService = new UpdaterService(plugin.getDescription());
5350

5451
AudienceProvider audienceProvider = BukkitAudiences.create(plugin);
@@ -58,7 +55,7 @@ public ChatFormatterPlugin(Plugin plugin) {
5855
.build();
5956

6057
// bStats metrics
61-
new Metrics((JavaPlugin) plugin, 15199);
58+
new Metrics(plugin, 15199);
6259

6360
this.chatHandler = new ChatHandlerImpl(miniMessage, pluginConfig, this.rankProvider, this.placeholderRegistry, this.templateService);
6461

0 commit comments

Comments
 (0)