Skip to content

Commit dfc825c

Browse files
CitralFloRollczi
andauthored
GH-107 Multification setup (#197)
* Multification setup * Bump version of multification * Override adventure API. Bump LiteCommands * Fix import * Fix minor issues with notices * Change BukktiNotice to Notice * Resolve Rollczi's suggestions * MAJOR FIX * uncomment dev.rollczi.litecommands needed for testing --------- Co-authored-by: Rollczi <[email protected]>
1 parent 9203309 commit dfc825c

22 files changed

+285
-387
lines changed

buildSrc/src/main/kotlin/Versions.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ object Versions {
99
const val JETBRAINS_ANNOTATIONS = "24.1.0"
1010

1111
const val ETERNALCODE_COMMONS = "1.1.3"
12-
// TODO: Multification.
12+
const val MULTIFICATION = "1.1.4"
1313

1414
const val ADVENTURE_PLATFORM_BUKKIT = "4.3.4"
15-
const val ADVENTURE_TEXT_MINIMESSAGE = "4.17.0"
15+
const val ADVENTURE_API = "4.17.0"
1616

17-
const val LITE_COMMANDS = "3.5.0"
17+
const val LITE_COMMANDS = "3.7.0"
1818
const val OKAERI_CONFIGS_YAML_BUKKIT = "5.0.3"
1919
const val OKAERI_CONFIGS_SERDES_COMMONS = "5.0.3"
2020
const val OKAERI_CONFIGS_SERDES_BUKKIT = "5.0.3"

eternalcombat-plugin/build.gradle.kts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,12 @@ dependencies {
1212

1313
// kyori
1414
implementation("net.kyori:adventure-platform-bukkit:${Versions.ADVENTURE_PLATFORM_BUKKIT}")
15-
implementation("net.kyori:adventure-text-minimessage:${Versions.ADVENTURE_TEXT_MINIMESSAGE}")
15+
implementation("net.kyori:adventure-text-minimessage:${Versions.ADVENTURE_API}")
16+
implementation("net.kyori:adventure-api") {
17+
version {
18+
strictly(Versions.ADVENTURE_API)
19+
}
20+
}
1621

1722
// litecommands
1823
implementation("dev.rollczi:litecommands-bukkit:${Versions.LITE_COMMANDS}")
@@ -45,6 +50,10 @@ dependencies {
4550

4651
// PlaceholderAPI
4752
compileOnly("me.clip:placeholderapi:${Versions.PLACEHOLDER_API}")
53+
54+
// Multification
55+
implementation("com.eternalcode:multification-bukkit:${Versions.MULTIFICATION}")
56+
implementation("com.eternalcode:multification-okaeri:${Versions.MULTIFICATION}")
4857
}
4958

5059
bukkit {
@@ -92,7 +101,8 @@ tasks.shadowJar {
92101
"org.apache.commons",
93102
"javassist",
94103
"com.github.benmanes.caffeine",
95-
"com.eternalcode.commons"
104+
"com.eternalcode.commons",
105+
"com.eternalcode.multification"
96106
).forEach { pack ->
97107
relocate(pack, "$prefix.$pack")
98108
}

eternalcombat-plugin/src/main/java/com/eternalcode/combat/CombatPlugin.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import com.eternalcode.combat.event.EventCaller;
2626
import com.eternalcode.combat.fight.FightManagerImpl;
2727
import com.eternalcode.combat.fight.FightTask;
28-
import com.eternalcode.combat.fight.bossbar.FightBossBarService;
2928
import com.eternalcode.combat.fight.effect.FightEffectServiceImpl;
3029
import com.eternalcode.combat.fight.logout.LogoutController;
3130
import com.eternalcode.combat.fight.logout.LogoutService;
@@ -41,6 +40,7 @@
4140
import com.eternalcode.combat.updater.UpdaterService;
4241
import com.eternalcode.commons.adventure.AdventureLegacyColorPostProcessor;
4342
import com.eternalcode.commons.adventure.AdventureLegacyColorPreProcessor;
43+
import com.eternalcode.multification.notice.Notice;
4444
import com.google.common.base.Stopwatch;
4545
import dev.rollczi.litecommands.LiteCommands;
4646
import dev.rollczi.litecommands.bukkit.LiteBukkitFactory;
@@ -108,13 +108,12 @@ public void onEnable() {
108108
.preProcessor(new AdventureLegacyColorPreProcessor())
109109
.build();
110110

111-
FightBossBarService fightBossBarService = new FightBossBarService(this.pluginConfig, this.audienceProvider, miniMessage);
112-
113111
BridgeService bridgeService = new BridgeService(this.pluginConfig, server.getPluginManager(), this.getLogger(), this);
114112
bridgeService.init(this.fightManager, server);
115113
this.regionProvider = bridgeService.getRegionProvider();
116114

117-
NotificationAnnouncer notificationAnnouncer = new NotificationAnnouncer(this.audienceProvider, miniMessage);
115+
116+
NotificationAnnouncer notificationAnnouncer = new NotificationAnnouncer(this.audienceProvider, this.pluginConfig, miniMessage);
118117

119118
this.liteCommands = LiteBukkitFactory.builder(FALLBACK_PREFIX, this, server)
120119
.message(LiteBukkitMessages.PLAYER_NOT_FOUND, this.pluginConfig.messages.playerNotFound)
@@ -129,9 +128,14 @@ public void onEnable() {
129128
new EternalCombatReloadCommand(configService, notificationAnnouncer)
130129
)
131130

131+
.result(Notice.class, (invocation, result, chain) -> notificationAnnouncer.create()
132+
.viewer(invocation.sender())
133+
.notice(result)
134+
.send())
135+
132136
.build();
133137

134-
FightTask fightTask = new FightTask(server, this.pluginConfig, this.fightManager, fightBossBarService, notificationAnnouncer);
138+
FightTask fightTask = new FightTask(server, this.pluginConfig, this.fightManager, notificationAnnouncer);
135139
this.getServer().getScheduler().runTaskTimer(this, fightTask, 20L, 20L);
136140

137141
new Metrics(this, BSTATS_METRICS_ID);
@@ -153,7 +157,7 @@ public void onEnable() {
153157
new RegionController(notificationAnnouncer, this.regionProvider, this.fightManager, this.pluginConfig),
154158
new FightEffectController(this.pluginConfig.effect, this.fightEffectService, this.fightManager, this.getServer()),
155159
new FightTagOutController(this.fightTagOutService),
156-
new FightMessageController(this.fightManager, notificationAnnouncer, fightBossBarService, this.pluginConfig, this.getServer())
160+
new FightMessageController(this.fightManager, notificationAnnouncer, this.pluginConfig, this.getServer())
157161
).forEach(listener -> this.getServer().getPluginManager().registerEvents(listener, this));
158162

159163
EternalCombatProvider.initialize(this);

eternalcombat-plugin/src/main/java/com/eternalcode/combat/EternalCombatReloadCommand.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
import com.eternalcode.combat.config.ConfigService;
44
import com.eternalcode.combat.notification.NotificationAnnouncer;
5+
import com.eternalcode.multification.bukkit.notice.BukkitNotice;
6+
import com.eternalcode.multification.notice.Notice;
57
import com.google.common.base.Stopwatch;
68
import dev.rollczi.litecommands.annotations.async.Async;
79
import dev.rollczi.litecommands.annotations.command.Command;
@@ -10,13 +12,14 @@
1012
import dev.rollczi.litecommands.annotations.permission.Permission;
1113
import java.time.Duration;
1214
import org.bukkit.command.CommandSender;
13-
import panda.utilities.text.Formatter;
1415

1516
@Command(name = "combatlog", aliases = "combat")
1617
@Permission("eternalcombat.reload")
1718
public class EternalCombatReloadCommand {
1819

19-
private static final String RELOAD_MESSAGE = "<b><gradient:#8a1212:#fc6b03>EternalCombat:</gradient></b> Reloaded EternalCombat in <color:#fce303>{TIME}ms!</color>";
20+
private static final Notice RELOAD_MESSAGE = BukkitNotice.builder()
21+
.chat("<b><gradient:#8a1212:#fc6b03>EternalCombat:</gradient></b> Reloaded EternalCombat in <color:#fce303>{TIME}ms!</color>")
22+
.build();
2023

2124
private final ConfigService configService;
2225
private final NotificationAnnouncer announcer;
@@ -33,7 +36,11 @@ void execute(@Context CommandSender sender) {
3336
this.configService.reload();
3437

3538
Duration elapsed = stopwatch.elapsed();
36-
Formatter format = new Formatter().register("{TIME}", elapsed.toMillis());
37-
this.announcer.sendMessage(sender, format.format(RELOAD_MESSAGE));
39+
this.announcer.create()
40+
.viewer(sender)
41+
.notice(RELOAD_MESSAGE)
42+
.placeholder("{TIME}", String.valueOf(elapsed.toMillis()))
43+
.send();
44+
3845
}
3946
}

eternalcombat-plugin/src/main/java/com/eternalcode/combat/config/ConfigService.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
package com.eternalcode.combat.config;
22

33
import com.eternalcode.combat.notification.serializer.NotificationSerializer;
4+
import com.eternalcode.multification.bukkit.notice.resolver.sound.SoundBukkitResolver;
5+
import com.eternalcode.multification.notice.resolver.NoticeResolverDefaults;
6+
import com.eternalcode.multification.notice.resolver.NoticeResolverRegistry;
7+
import com.eternalcode.multification.okaeri.MultificationSerdesPack;
48
import eu.okaeri.configs.ConfigManager;
59
import eu.okaeri.configs.OkaeriConfig;
610
import eu.okaeri.configs.serdes.commons.SerdesCommons;
@@ -18,10 +22,13 @@ public class ConfigService {
1822
public <T extends OkaeriConfig> T create(Class<T> config, File file) {
1923
T configFile = ConfigManager.create(config);
2024

21-
configFile.withConfigurer(new YamlBukkitConfigurer(), new SerdesCommons(), new SerdesBukkit());
22-
configFile.withSerdesPack(registry -> {
23-
registry.register(new NotificationSerializer());
24-
});
25+
YamlBukkitConfigurer yamlBukkitConfigurer = new YamlBukkitConfigurer();
26+
NoticeResolverRegistry noticeRegistry = NoticeResolverDefaults.createRegistry()
27+
.registerResolver(new SoundBukkitResolver());
28+
29+
configFile.withConfigurer(yamlBukkitConfigurer, new SerdesCommons(), new SerdesBukkit());
30+
configFile.withConfigurer(yamlBukkitConfigurer, new MultificationSerdesPack(noticeRegistry));
31+
configFile.withSerdesPack(registry -> registry.register(new NotificationSerializer()));
2532

2633
configFile.withBindFile(file);
2734
configFile.withRemoveOrphans(true);

eternalcombat-plugin/src/main/java/com/eternalcode/combat/config/implementation/PluginConfig.java

Lines changed: 41 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@
44
import com.eternalcode.combat.fight.drop.DropSettings;
55
import com.eternalcode.combat.fight.effect.FightEffectSettings;
66
import com.eternalcode.combat.fight.pearl.FightPearlSettings;
7-
import com.eternalcode.combat.notification.Notification;
8-
import com.eternalcode.combat.notification.implementation.ActionBarNotification;
7+
import com.eternalcode.multification.bukkit.notice.BukkitNotice;
8+
import com.eternalcode.multification.notice.Notice;
99
import eu.okaeri.configs.OkaeriConfig;
1010
import eu.okaeri.configs.annotation.Comment;
1111
import org.bukkit.Material;
12+
import org.bukkit.Sound;
13+
import org.bukkit.SoundCategory;
1214
import org.bukkit.entity.EntityType;
1315
import org.bukkit.event.entity.EntityDamageEvent;
1416

@@ -21,13 +23,13 @@ public class PluginConfig extends OkaeriConfig {
2123
@Comment("# Do you want to change the plugin settings?")
2224
public Settings settings = new Settings();
2325

24-
@Comment({" ", "# Ender pearl settings"})
26+
@Comment({ " ", "# Ender pearl settings" })
2527
public FightPearlSettings pearl = new FightPearlSettings();
2628

27-
@Comment({" ", "# Custom effects settings"})
29+
@Comment({ " ", "# Custom effects settings" })
2830
public FightEffectSettings effect = new FightEffectSettings();
2931

30-
@Comment({" ", "# Set a custom way for a player's items to drop on death (if in combat)"})
32+
@Comment({ " ", "# Set a custom way for a player's items to drop on death (if in combat)" })
3133
public DropSettings dropSettings = new DropSettings();
3234

3335
public static class Settings extends OkaeriConfig {
@@ -53,7 +55,7 @@ public static class Settings extends OkaeriConfig {
5355
})
5456
public double blockedRegionKnockMultiplier = 1;
5557

56-
@Comment({"# Should the player be prevented from entering regions with WorldGuard flag PVP set to DENY "})
58+
@Comment({ "# Should the player be prevented from entering regions with WorldGuard flag PVP set to DENY " })
5759
public boolean shouldPreventPvpRegions = true;
5860

5961
@Comment("# Set the radius of the blocked region if you aren't using WorldGuard basen on default spawn region!")
@@ -62,7 +64,7 @@ public static class Settings extends OkaeriConfig {
6264
@Comment("# Release attacker after victim dies?")
6365
public boolean shouldReleaseAttacker = true;
6466

65-
@Comment({"# If you want to exclude admins from combat, ",
67+
@Comment({ "# If you want to exclude admins from combat, ",
6668
"# Setting this to true - admins cannot be tagged and will not tag other players on hit",
6769
"# Setting this to false - admins can be tagged and can tag other players on hit"
6870
})
@@ -150,7 +152,7 @@ public enum BlockPlacingMode {
150152

151153
}
152154

153-
@Comment({" ", "# Do you want to change the plugin messages?"})
155+
@Comment({ " ", "# Do you want to change the plugin messages?" })
154156
public Messages messages = new Messages();
155157

156158
public static class Messages extends OkaeriConfig {
@@ -168,85 +170,88 @@ public static class Messages extends OkaeriConfig {
168170
"# BossBar colors: https://javadoc.io/static/net.kyori/adventure-api/4.14.0/net/kyori/adventure/bossbar/BossBar.Color.html",
169171
"# BossBar overlays: https://javadoc.io/static/net.kyori/adventure-api/4.14.0/net/kyori/adventure/bossbar/BossBar.Overlay.html"
170172
})
171-
public Notification combatNotification = new ActionBarNotification("&dCombat ends in: &f{TIME}");
173+
public Notice combatNotification = BukkitNotice.builder()
174+
.actionBar("&dCombat ends in: &f{TIME}")
175+
.sound(Sound.ENTITY_EXPERIENCE_ORB_PICKUP, SoundCategory.PLAYERS, 2.0F, 1.0F)
176+
.build();
172177

173178
@Comment("# Message sent when the player does not have permission to perform a command")
174-
public String noPermission = "&cYou don't have permission to perform this command!";
179+
public Notice noPermission = Notice.chat("&cYou don't have permission \"{PERMISSION}\" to perform this command!");
175180

176181
@Comment("# Message sent when the specified player could not be found")
177-
public String playerNotFound = "&cThe specified player could not be found!";
182+
public Notice playerNotFound = Notice.chat("&cThe specified player could not be found!");
178183

179184
@Comment("# Message sent when the player enters combat")
180-
public String playerTagged = "&cYou are in combat, do not leave the server!";
185+
public Notice playerTagged = Notice.chat("&cYou are in combat, do not leave the server!");
181186

182187
@Comment("# Message sent when the player leaves combat")
183-
public String playerUntagged = "&aYou are no longer in combat! You can safely leave the server.";
188+
public Notice playerUntagged = Notice.chat("&aYou are no longer in combat! You can safely leave the server.");
184189

185190
@Comment("# This is broadcast when the player is in combat and logs out")
186-
public String playerLoggedOutDuringCombat = "&c{PLAYER} logged off during the fight!";
191+
public Notice playerLoggedOutDuringCombat = Notice.chat("&c{PLAYER} logged off during the fight!");
187192

188193
@Comment({
189194
"# Message sent when the player is in combat and tries to use a disabled command",
190195
"# you can configure the list of disabled commands in the blockedCommands section of the config.yml file"
191196
})
192-
public String commandDisabledDuringCombat = "&cUsing this command during combat is prohibited!";
197+
public Notice commandDisabledDuringCombat = Notice.chat("&cUsing this command during combat is prohibited!");
193198

194199
@Comment("# Message sent when player tries to use a command with invalid arguments")
195-
public String invalidCommandUsage = "&7Correct usage: &e{USAGE}";
200+
public Notice invalidCommandUsage = Notice.chat("&7Correct usage: &e{USAGE}");
196201

197202
@Comment("# Message sent when player tries to open inventory, but the inventory open is blocked")
198-
public String inventoryBlockedDuringCombat = "&cYou cannot open this inventory during combat!";
203+
public Notice inventoryBlockedDuringCombat = Notice.chat("&cYou cannot open this inventory during combat!");
199204

200-
@Comment({"# Message sent when player tries to place a block, but the block place is blocked",
201-
"# Placeholder {Y} is replaced with the Y coordinate set in the config",
202-
"# Placeholder {MODE} is replaced with the mode set in the config"})
203-
public String blockPlacingBlockedDuringCombat = "&cYou cannot place {MODE} {Y} coordinate during combat!";
205+
@Comment({ "# Message sent when player tries to place a block, but the block place is blocked",
206+
"# Placeholder {Y} is replaced with the Y coordinate set in the config",
207+
"# Placeholder {MODE} is replaced with the mode set in the config" })
208+
public Notice blockPlacingBlockedDuringCombat = Notice.chat("&cYou cannot place {MODE} {Y} coordinate during combat!");
204209

205210
@Comment("# Message sent when player tries to enter a region")
206-
public String cantEnterOnRegion = "&cYou can't enter this region during combat!";
211+
public Notice cantEnterOnRegion = Notice.chat("&cYou can't enter this region during combat!");
207212

208213
public static class AdminMessages extends OkaeriConfig {
209214
@Comment("# Message sent when console tries to use a command that is only for players")
210-
public String onlyForPlayers = "&cThis command is only available to players!";
215+
public Notice onlyForPlayers = Notice.chat("&cThis command is only available to players!");
211216

212217
@Comment("# Message sent to admin when they tag a player")
213-
public String adminTagPlayer = "&7You have tagged &e{PLAYER}";
218+
public Notice adminTagPlayer = Notice.chat("&7You have tagged &e{PLAYER}");
214219

215220
@Comment("# Message sent when a player is tagged by an admin")
216-
public String adminTagMultiplePlayers = "&7You have tagged &e{FIRST_PLAYER}&7 and &e{SECOND_PLAYER}&7.";
221+
public Notice adminTagMultiplePlayers = Notice.chat("&7You have tagged &e{FIRST_PLAYER}&7 and &e{SECOND_PLAYER}&7.");
217222

218223
@Comment("# Message sent to admin when they remove a player from combat")
219-
public String adminUntagPlayer = "&7You have removed &e{PLAYER}&7 from the fight.";
224+
public Notice adminUntagPlayer = Notice.chat("&7You have removed &e{PLAYER}&7 from the fight.");
220225

221226
@Comment("# Message sent when the player is not in combat")
222-
public String adminPlayerNotInCombat = "&cThis player is not in combat!";
227+
public Notice adminPlayerNotInCombat = Notice.chat("&cThis player is not in combat!");
223228

224229
@Comment("# Message sent when the player is in combat")
225-
public String playerInCombat = "&c{PLAYER} is currently in combat!";
230+
public Notice playerInCombat = Notice.chat("&c{PLAYER} is currently in combat!");
226231

227232
@Comment("# Message sent when a player is not in combat")
228-
public String playerNotInCombat = "&a{PLAYER} is not currently in combat.";
233+
public Notice playerNotInCombat = Notice.chat("&a{PLAYER} is not currently in combat.");
229234

230235
@Comment("# Message sent when an admin tries to tag themselves")
231-
public String adminCannotTagSelf = "&cYou cannot tag yourself!";
236+
public Notice adminCannotTagSelf = Notice.chat("&cYou cannot tag yourself!");
232237

233238
@Comment("# Message sent when an admin disables the ability to get tagged for some time")
234-
public String adminTagOutSelf = "&7Successfully disabled tag for Yourself! You will be taggable after &e{TIME} ";
239+
public Notice adminTagOutSelf = Notice.chat("&7Successfully disabled tag for Yourself! You will be taggable after &e{TIME} ");
235240

236241
@Comment("# Message sent when an admin disables the ability to get tagged for some time for other player")
237-
public String adminTagOut = "&7Successfully disabled tag for &e{PLAYER}! They will be taggable after &e{TIME} ";
242+
public Notice adminTagOut = Notice.chat("&7Successfully disabled tag for &e{PLAYER}! They will be taggable after &e{TIME} ");
238243

239244
@Comment("# Message sent to the player whom the ability to get tagged for some time has been disabled")
240-
public String playerTagOut = "&7You will be taggable in &e{TIME} !";
245+
public Notice playerTagOut = Notice.chat("&7You will be taggable in &e{TIME} !");
241246

242247
@Comment("# Message sent when an admin reenables the ability to get tagged for the player")
243-
public String adminTagOutOff = "&7Successfully enabled tag for &e{PLAYER}!";
248+
public Notice adminTagOutOff = Notice.chat("&7Successfully enabled tag for &e{PLAYER}!");
244249

245250
@Comment("# Message sent to the player whom the ability to get tagged has been reenabled")
246-
public String playerTagOutOff = "&7You are now taggable!";
251+
public Notice playerTagOutOff = Notice.chat("&7You are now taggable!");
247252

248253
@Comment("# Message sent when player cannot be tagged because they have enabled tag-out")
249-
public String adminTagOutCanceled = "&cCannot tag this player due to tag-out!";
254+
public Notice adminTagOutCanceled = Notice.chat("&cCannot tag this player due to tag-out!");
250255
}
251256
}
252257
}

0 commit comments

Comments
 (0)