diff --git a/buildSrc/src/main/kotlin/Versions.kt b/buildSrc/src/main/kotlin/Versions.kt
index 22074a2e..534a0311 100644
--- a/buildSrc/src/main/kotlin/Versions.kt
+++ b/buildSrc/src/main/kotlin/Versions.kt
@@ -9,12 +9,12 @@ object Versions {
const val JETBRAINS_ANNOTATIONS = "24.1.0"
const val ETERNALCODE_COMMONS = "1.1.3"
- // TODO: Multification.
+ const val MULTIFICATION = "1.1.4"
const val ADVENTURE_PLATFORM_BUKKIT = "4.3.4"
- const val ADVENTURE_TEXT_MINIMESSAGE = "4.17.0"
+ const val ADVENTURE_API = "4.17.0"
- const val LITE_COMMANDS = "3.5.0"
+ const val LITE_COMMANDS = "3.7.0"
const val OKAERI_CONFIGS_YAML_BUKKIT = "5.0.3"
const val OKAERI_CONFIGS_SERDES_COMMONS = "5.0.3"
const val OKAERI_CONFIGS_SERDES_BUKKIT = "5.0.3"
diff --git a/eternalcombat-plugin/build.gradle.kts b/eternalcombat-plugin/build.gradle.kts
index 16039c64..49fa05d7 100644
--- a/eternalcombat-plugin/build.gradle.kts
+++ b/eternalcombat-plugin/build.gradle.kts
@@ -12,7 +12,12 @@ dependencies {
// kyori
implementation("net.kyori:adventure-platform-bukkit:${Versions.ADVENTURE_PLATFORM_BUKKIT}")
- implementation("net.kyori:adventure-text-minimessage:${Versions.ADVENTURE_TEXT_MINIMESSAGE}")
+ implementation("net.kyori:adventure-text-minimessage:${Versions.ADVENTURE_API}")
+ implementation("net.kyori:adventure-api") {
+ version {
+ strictly(Versions.ADVENTURE_API)
+ }
+ }
// litecommands
implementation("dev.rollczi:litecommands-bukkit:${Versions.LITE_COMMANDS}")
@@ -45,6 +50,10 @@ dependencies {
// PlaceholderAPI
compileOnly("me.clip:placeholderapi:${Versions.PLACEHOLDER_API}")
+
+ // Multification
+ implementation("com.eternalcode:multification-bukkit:${Versions.MULTIFICATION}")
+ implementation("com.eternalcode:multification-okaeri:${Versions.MULTIFICATION}")
}
bukkit {
@@ -92,7 +101,8 @@ tasks.shadowJar {
"org.apache.commons",
"javassist",
"com.github.benmanes.caffeine",
- "com.eternalcode.commons"
+ "com.eternalcode.commons",
+ "com.eternalcode.multification"
).forEach { pack ->
relocate(pack, "$prefix.$pack")
}
diff --git a/eternalcombat-plugin/src/main/java/com/eternalcode/combat/CombatPlugin.java b/eternalcombat-plugin/src/main/java/com/eternalcode/combat/CombatPlugin.java
index c948ea00..c1ece2b0 100644
--- a/eternalcombat-plugin/src/main/java/com/eternalcode/combat/CombatPlugin.java
+++ b/eternalcombat-plugin/src/main/java/com/eternalcode/combat/CombatPlugin.java
@@ -25,7 +25,6 @@
import com.eternalcode.combat.event.EventCaller;
import com.eternalcode.combat.fight.FightManagerImpl;
import com.eternalcode.combat.fight.FightTask;
-import com.eternalcode.combat.fight.bossbar.FightBossBarService;
import com.eternalcode.combat.fight.effect.FightEffectServiceImpl;
import com.eternalcode.combat.fight.logout.LogoutController;
import com.eternalcode.combat.fight.logout.LogoutService;
@@ -41,6 +40,7 @@
import com.eternalcode.combat.updater.UpdaterService;
import com.eternalcode.commons.adventure.AdventureLegacyColorPostProcessor;
import com.eternalcode.commons.adventure.AdventureLegacyColorPreProcessor;
+import com.eternalcode.multification.notice.Notice;
import com.google.common.base.Stopwatch;
import dev.rollczi.litecommands.LiteCommands;
import dev.rollczi.litecommands.bukkit.LiteBukkitFactory;
@@ -108,13 +108,12 @@ public void onEnable() {
.preProcessor(new AdventureLegacyColorPreProcessor())
.build();
- FightBossBarService fightBossBarService = new FightBossBarService(this.pluginConfig, this.audienceProvider, miniMessage);
-
BridgeService bridgeService = new BridgeService(this.pluginConfig, server.getPluginManager(), this.getLogger(), this);
bridgeService.init(this.fightManager, server);
this.regionProvider = bridgeService.getRegionProvider();
- NotificationAnnouncer notificationAnnouncer = new NotificationAnnouncer(this.audienceProvider, miniMessage);
+
+ NotificationAnnouncer notificationAnnouncer = new NotificationAnnouncer(this.audienceProvider, this.pluginConfig, miniMessage);
this.liteCommands = LiteBukkitFactory.builder(FALLBACK_PREFIX, this, server)
.message(LiteBukkitMessages.PLAYER_NOT_FOUND, this.pluginConfig.messages.playerNotFound)
@@ -129,9 +128,14 @@ public void onEnable() {
new EternalCombatReloadCommand(configService, notificationAnnouncer)
)
+ .result(Notice.class, (invocation, result, chain) -> notificationAnnouncer.create()
+ .viewer(invocation.sender())
+ .notice(result)
+ .send())
+
.build();
- FightTask fightTask = new FightTask(server, this.pluginConfig, this.fightManager, fightBossBarService, notificationAnnouncer);
+ FightTask fightTask = new FightTask(server, this.pluginConfig, this.fightManager, notificationAnnouncer);
this.getServer().getScheduler().runTaskTimer(this, fightTask, 20L, 20L);
new Metrics(this, BSTATS_METRICS_ID);
@@ -153,7 +157,7 @@ public void onEnable() {
new RegionController(notificationAnnouncer, this.regionProvider, this.fightManager, this.pluginConfig),
new FightEffectController(this.pluginConfig.effect, this.fightEffectService, this.fightManager, this.getServer()),
new FightTagOutController(this.fightTagOutService),
- new FightMessageController(this.fightManager, notificationAnnouncer, fightBossBarService, this.pluginConfig, this.getServer())
+ new FightMessageController(this.fightManager, notificationAnnouncer, this.pluginConfig, this.getServer())
).forEach(listener -> this.getServer().getPluginManager().registerEvents(listener, this));
EternalCombatProvider.initialize(this);
diff --git a/eternalcombat-plugin/src/main/java/com/eternalcode/combat/EternalCombatReloadCommand.java b/eternalcombat-plugin/src/main/java/com/eternalcode/combat/EternalCombatReloadCommand.java
index 40209b03..7b23d10c 100644
--- a/eternalcombat-plugin/src/main/java/com/eternalcode/combat/EternalCombatReloadCommand.java
+++ b/eternalcombat-plugin/src/main/java/com/eternalcode/combat/EternalCombatReloadCommand.java
@@ -2,6 +2,8 @@
import com.eternalcode.combat.config.ConfigService;
import com.eternalcode.combat.notification.NotificationAnnouncer;
+import com.eternalcode.multification.bukkit.notice.BukkitNotice;
+import com.eternalcode.multification.notice.Notice;
import com.google.common.base.Stopwatch;
import dev.rollczi.litecommands.annotations.async.Async;
import dev.rollczi.litecommands.annotations.command.Command;
@@ -10,13 +12,14 @@
import dev.rollczi.litecommands.annotations.permission.Permission;
import java.time.Duration;
import org.bukkit.command.CommandSender;
-import panda.utilities.text.Formatter;
@Command(name = "combatlog", aliases = "combat")
@Permission("eternalcombat.reload")
public class EternalCombatReloadCommand {
- private static final String RELOAD_MESSAGE = "EternalCombat: Reloaded EternalCombat in {TIME}ms!";
+ private static final Notice RELOAD_MESSAGE = BukkitNotice.builder()
+ .chat("EternalCombat: Reloaded EternalCombat in {TIME}ms!")
+ .build();
private final ConfigService configService;
private final NotificationAnnouncer announcer;
@@ -33,7 +36,11 @@ void execute(@Context CommandSender sender) {
this.configService.reload();
Duration elapsed = stopwatch.elapsed();
- Formatter format = new Formatter().register("{TIME}", elapsed.toMillis());
- this.announcer.sendMessage(sender, format.format(RELOAD_MESSAGE));
+ this.announcer.create()
+ .viewer(sender)
+ .notice(RELOAD_MESSAGE)
+ .placeholder("{TIME}", String.valueOf(elapsed.toMillis()))
+ .send();
+
}
}
diff --git a/eternalcombat-plugin/src/main/java/com/eternalcode/combat/config/ConfigService.java b/eternalcombat-plugin/src/main/java/com/eternalcode/combat/config/ConfigService.java
index 53bfb06a..7a556464 100644
--- a/eternalcombat-plugin/src/main/java/com/eternalcode/combat/config/ConfigService.java
+++ b/eternalcombat-plugin/src/main/java/com/eternalcode/combat/config/ConfigService.java
@@ -1,6 +1,10 @@
package com.eternalcode.combat.config;
import com.eternalcode.combat.notification.serializer.NotificationSerializer;
+import com.eternalcode.multification.bukkit.notice.resolver.sound.SoundBukkitResolver;
+import com.eternalcode.multification.notice.resolver.NoticeResolverDefaults;
+import com.eternalcode.multification.notice.resolver.NoticeResolverRegistry;
+import com.eternalcode.multification.okaeri.MultificationSerdesPack;
import eu.okaeri.configs.ConfigManager;
import eu.okaeri.configs.OkaeriConfig;
import eu.okaeri.configs.serdes.commons.SerdesCommons;
@@ -18,10 +22,13 @@ public class ConfigService {
public T create(Class config, File file) {
T configFile = ConfigManager.create(config);
- configFile.withConfigurer(new YamlBukkitConfigurer(), new SerdesCommons(), new SerdesBukkit());
- configFile.withSerdesPack(registry -> {
- registry.register(new NotificationSerializer());
- });
+ YamlBukkitConfigurer yamlBukkitConfigurer = new YamlBukkitConfigurer();
+ NoticeResolverRegistry noticeRegistry = NoticeResolverDefaults.createRegistry()
+ .registerResolver(new SoundBukkitResolver());
+
+ configFile.withConfigurer(yamlBukkitConfigurer, new SerdesCommons(), new SerdesBukkit());
+ configFile.withConfigurer(yamlBukkitConfigurer, new MultificationSerdesPack(noticeRegistry));
+ configFile.withSerdesPack(registry -> registry.register(new NotificationSerializer()));
configFile.withBindFile(file);
configFile.withRemoveOrphans(true);
diff --git a/eternalcombat-plugin/src/main/java/com/eternalcode/combat/config/implementation/PluginConfig.java b/eternalcombat-plugin/src/main/java/com/eternalcode/combat/config/implementation/PluginConfig.java
index c4bc3716..dbdcb0e5 100644
--- a/eternalcombat-plugin/src/main/java/com/eternalcode/combat/config/implementation/PluginConfig.java
+++ b/eternalcombat-plugin/src/main/java/com/eternalcode/combat/config/implementation/PluginConfig.java
@@ -4,11 +4,13 @@
import com.eternalcode.combat.fight.drop.DropSettings;
import com.eternalcode.combat.fight.effect.FightEffectSettings;
import com.eternalcode.combat.fight.pearl.FightPearlSettings;
-import com.eternalcode.combat.notification.Notification;
-import com.eternalcode.combat.notification.implementation.ActionBarNotification;
+import com.eternalcode.multification.bukkit.notice.BukkitNotice;
+import com.eternalcode.multification.notice.Notice;
import eu.okaeri.configs.OkaeriConfig;
import eu.okaeri.configs.annotation.Comment;
import org.bukkit.Material;
+import org.bukkit.Sound;
+import org.bukkit.SoundCategory;
import org.bukkit.entity.EntityType;
import org.bukkit.event.entity.EntityDamageEvent;
@@ -21,13 +23,13 @@ public class PluginConfig extends OkaeriConfig {
@Comment("# Do you want to change the plugin settings?")
public Settings settings = new Settings();
- @Comment({" ", "# Ender pearl settings"})
+ @Comment({ " ", "# Ender pearl settings" })
public FightPearlSettings pearl = new FightPearlSettings();
- @Comment({" ", "# Custom effects settings"})
+ @Comment({ " ", "# Custom effects settings" })
public FightEffectSettings effect = new FightEffectSettings();
- @Comment({" ", "# Set a custom way for a player's items to drop on death (if in combat)"})
+ @Comment({ " ", "# Set a custom way for a player's items to drop on death (if in combat)" })
public DropSettings dropSettings = new DropSettings();
public static class Settings extends OkaeriConfig {
@@ -53,7 +55,7 @@ public static class Settings extends OkaeriConfig {
})
public double blockedRegionKnockMultiplier = 1;
- @Comment({"# Should the player be prevented from entering regions with WorldGuard flag PVP set to DENY "})
+ @Comment({ "# Should the player be prevented from entering regions with WorldGuard flag PVP set to DENY " })
public boolean shouldPreventPvpRegions = true;
@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 {
@Comment("# Release attacker after victim dies?")
public boolean shouldReleaseAttacker = true;
- @Comment({"# If you want to exclude admins from combat, ",
+ @Comment({ "# If you want to exclude admins from combat, ",
"# Setting this to true - admins cannot be tagged and will not tag other players on hit",
"# Setting this to false - admins can be tagged and can tag other players on hit"
})
@@ -150,7 +152,7 @@ public enum BlockPlacingMode {
}
- @Comment({" ", "# Do you want to change the plugin messages?"})
+ @Comment({ " ", "# Do you want to change the plugin messages?" })
public Messages messages = new Messages();
public static class Messages extends OkaeriConfig {
@@ -168,85 +170,88 @@ public static class Messages extends OkaeriConfig {
"# BossBar colors: https://javadoc.io/static/net.kyori/adventure-api/4.14.0/net/kyori/adventure/bossbar/BossBar.Color.html",
"# BossBar overlays: https://javadoc.io/static/net.kyori/adventure-api/4.14.0/net/kyori/adventure/bossbar/BossBar.Overlay.html"
})
- public Notification combatNotification = new ActionBarNotification("&dCombat ends in: &f{TIME}");
+ public Notice combatNotification = BukkitNotice.builder()
+ .actionBar("&dCombat ends in: &f{TIME}")
+ .sound(Sound.ENTITY_EXPERIENCE_ORB_PICKUP, SoundCategory.PLAYERS, 2.0F, 1.0F)
+ .build();
@Comment("# Message sent when the player does not have permission to perform a command")
- public String noPermission = "&cYou don't have permission to perform this command!";
+ public Notice noPermission = Notice.chat("&cYou don't have permission \"{PERMISSION}\" to perform this command!");
@Comment("# Message sent when the specified player could not be found")
- public String playerNotFound = "&cThe specified player could not be found!";
+ public Notice playerNotFound = Notice.chat("&cThe specified player could not be found!");
@Comment("# Message sent when the player enters combat")
- public String playerTagged = "&cYou are in combat, do not leave the server!";
+ public Notice playerTagged = Notice.chat("&cYou are in combat, do not leave the server!");
@Comment("# Message sent when the player leaves combat")
- public String playerUntagged = "&aYou are no longer in combat! You can safely leave the server.";
+ public Notice playerUntagged = Notice.chat("&aYou are no longer in combat! You can safely leave the server.");
@Comment("# This is broadcast when the player is in combat and logs out")
- public String playerLoggedOutDuringCombat = "&c{PLAYER} logged off during the fight!";
+ public Notice playerLoggedOutDuringCombat = Notice.chat("&c{PLAYER} logged off during the fight!");
@Comment({
"# Message sent when the player is in combat and tries to use a disabled command",
"# you can configure the list of disabled commands in the blockedCommands section of the config.yml file"
})
- public String commandDisabledDuringCombat = "&cUsing this command during combat is prohibited!";
+ public Notice commandDisabledDuringCombat = Notice.chat("&cUsing this command during combat is prohibited!");
@Comment("# Message sent when player tries to use a command with invalid arguments")
- public String invalidCommandUsage = "&7Correct usage: &e{USAGE}";
+ public Notice invalidCommandUsage = Notice.chat("&7Correct usage: &e{USAGE}");
@Comment("# Message sent when player tries to open inventory, but the inventory open is blocked")
- public String inventoryBlockedDuringCombat = "&cYou cannot open this inventory during combat!";
+ public Notice inventoryBlockedDuringCombat = Notice.chat("&cYou cannot open this inventory during combat!");
- @Comment({"# Message sent when player tries to place a block, but the block place is blocked",
- "# Placeholder {Y} is replaced with the Y coordinate set in the config",
- "# Placeholder {MODE} is replaced with the mode set in the config"})
- public String blockPlacingBlockedDuringCombat = "&cYou cannot place {MODE} {Y} coordinate during combat!";
+ @Comment({ "# Message sent when player tries to place a block, but the block place is blocked",
+ "# Placeholder {Y} is replaced with the Y coordinate set in the config",
+ "# Placeholder {MODE} is replaced with the mode set in the config" })
+ public Notice blockPlacingBlockedDuringCombat = Notice.chat("&cYou cannot place {MODE} {Y} coordinate during combat!");
@Comment("# Message sent when player tries to enter a region")
- public String cantEnterOnRegion = "&cYou can't enter this region during combat!";
+ public Notice cantEnterOnRegion = Notice.chat("&cYou can't enter this region during combat!");
public static class AdminMessages extends OkaeriConfig {
@Comment("# Message sent when console tries to use a command that is only for players")
- public String onlyForPlayers = "&cThis command is only available to players!";
+ public Notice onlyForPlayers = Notice.chat("&cThis command is only available to players!");
@Comment("# Message sent to admin when they tag a player")
- public String adminTagPlayer = "&7You have tagged &e{PLAYER}";
+ public Notice adminTagPlayer = Notice.chat("&7You have tagged &e{PLAYER}");
@Comment("# Message sent when a player is tagged by an admin")
- public String adminTagMultiplePlayers = "&7You have tagged &e{FIRST_PLAYER}&7 and &e{SECOND_PLAYER}&7.";
+ public Notice adminTagMultiplePlayers = Notice.chat("&7You have tagged &e{FIRST_PLAYER}&7 and &e{SECOND_PLAYER}&7.");
@Comment("# Message sent to admin when they remove a player from combat")
- public String adminUntagPlayer = "&7You have removed &e{PLAYER}&7 from the fight.";
+ public Notice adminUntagPlayer = Notice.chat("&7You have removed &e{PLAYER}&7 from the fight.");
@Comment("# Message sent when the player is not in combat")
- public String adminPlayerNotInCombat = "&cThis player is not in combat!";
+ public Notice adminPlayerNotInCombat = Notice.chat("&cThis player is not in combat!");
@Comment("# Message sent when the player is in combat")
- public String playerInCombat = "&c{PLAYER} is currently in combat!";
+ public Notice playerInCombat = Notice.chat("&c{PLAYER} is currently in combat!");
@Comment("# Message sent when a player is not in combat")
- public String playerNotInCombat = "&a{PLAYER} is not currently in combat.";
+ public Notice playerNotInCombat = Notice.chat("&a{PLAYER} is not currently in combat.");
@Comment("# Message sent when an admin tries to tag themselves")
- public String adminCannotTagSelf = "&cYou cannot tag yourself!";
+ public Notice adminCannotTagSelf = Notice.chat("&cYou cannot tag yourself!");
@Comment("# Message sent when an admin disables the ability to get tagged for some time")
- public String adminTagOutSelf = "&7Successfully disabled tag for Yourself! You will be taggable after &e{TIME} ";
+ public Notice adminTagOutSelf = Notice.chat("&7Successfully disabled tag for Yourself! You will be taggable after &e{TIME} ");
@Comment("# Message sent when an admin disables the ability to get tagged for some time for other player")
- public String adminTagOut = "&7Successfully disabled tag for &e{PLAYER}! They will be taggable after &e{TIME} ";
+ public Notice adminTagOut = Notice.chat("&7Successfully disabled tag for &e{PLAYER}! They will be taggable after &e{TIME} ");
@Comment("# Message sent to the player whom the ability to get tagged for some time has been disabled")
- public String playerTagOut = "&7You will be taggable in &e{TIME} !";
+ public Notice playerTagOut = Notice.chat("&7You will be taggable in &e{TIME} !");
@Comment("# Message sent when an admin reenables the ability to get tagged for the player")
- public String adminTagOutOff = "&7Successfully enabled tag for &e{PLAYER}!";
+ public Notice adminTagOutOff = Notice.chat("&7Successfully enabled tag for &e{PLAYER}!");
@Comment("# Message sent to the player whom the ability to get tagged has been reenabled")
- public String playerTagOutOff = "&7You are now taggable!";
+ public Notice playerTagOutOff = Notice.chat("&7You are now taggable!");
@Comment("# Message sent when player cannot be tagged because they have enabled tag-out")
- public String adminTagOutCanceled = "&cCannot tag this player due to tag-out!";
+ public Notice adminTagOutCanceled = Notice.chat("&cCannot tag this player due to tag-out!");
}
}
}
diff --git a/eternalcombat-plugin/src/main/java/com/eternalcode/combat/fight/FightTagCommand.java b/eternalcombat-plugin/src/main/java/com/eternalcode/combat/fight/FightTagCommand.java
index 6fe5b198..c409d8a0 100644
--- a/eternalcombat-plugin/src/main/java/com/eternalcode/combat/fight/FightTagCommand.java
+++ b/eternalcombat-plugin/src/main/java/com/eternalcode/combat/fight/FightTagCommand.java
@@ -12,11 +12,12 @@
import dev.rollczi.litecommands.annotations.context.Context;
import dev.rollczi.litecommands.annotations.execute.Execute;
import dev.rollczi.litecommands.annotations.permission.Permission;
+import dev.rollczi.litecommands.annotations.priority.Priority;
+import dev.rollczi.litecommands.annotations.priority.PriorityValue;
import java.time.Duration;
import java.util.UUID;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
-import panda.utilities.text.Formatter;
@Command(name = "combatlog", aliases = "combat")
public class FightTagCommand {
@@ -35,40 +36,41 @@ public FightTagCommand(FightManager fightManager, NotificationAnnouncer announce
@Permission("eternalcombat.status")
void status(@Context CommandSender sender, @Arg Player target) {
UUID targetUniqueId = target.getUniqueId();
- PluginConfig.Messages messages = this.config.messages;
- Formatter formatter = new Formatter()
- .register("{PLAYER}", target.getName());
+ this.announcer.create()
+ .notice(this.fightManager.isInCombat(targetUniqueId)
+ ? this.config.messages.admin.playerInCombat
+ : this.config.messages.admin.playerNotInCombat
+ )
+ .placeholder("{PLAYER}", target.getName())
+ .viewer(sender)
+ .send();
- this.announcer.sendMessage(sender, this.fightManager.isInCombat(targetUniqueId)
- ? formatter.format(messages.admin.playerInCombat)
- : formatter.format(messages.admin.playerNotInCombat));
}
@Execute(name = "tag")
@Permission("eternalcombat.tag")
+ @Priority(PriorityValue.HIGH)
void tag(@Context CommandSender sender, @Arg Player target) {
- UUID targetUniqueId = target.getUniqueId();
+ UUID targetUniqueId = target.getUniqueId();
Duration time = this.config.settings.combatDuration;
- Formatter formatter = new Formatter()
- .register("{PLAYER}", target.getName());
-
FightTagEvent event = this.fightManager.tag(targetUniqueId, time, CauseOfTag.COMMAND);
if (event.isCancelled()) {
CancelTagReason cancelReason = event.getCancelReason();
- if (cancelReason == CancelTagReason.TAGOUT) {
- this.announcer.sendMessage(sender, this.config.messages.admin.adminTagOutCanceled);
- return;
- }
+ this.tagoutReasonHandler(sender, cancelReason, this.config.messages);
return;
}
- String format = formatter.format(this.config.messages.admin.adminTagPlayer);
- this.announcer.sendMessage(sender, format);
+ this.announcer.create()
+ .notice(this.config.messages.admin.adminTagPlayer)
+ .placeholder("{PLAYER}", target.getName())
+ .viewer(sender)
+ .send();
+
}
@Execute(name = "tag")
@@ -76,28 +78,24 @@ void tag(@Context CommandSender sender, @Arg Player target) {
void tagMultiple(@Context CommandSender sender, @Arg Player firstTarget, @Arg Player secondTarget) {
Duration combatTime = this.config.settings.combatDuration;
PluginConfig.Messages messages = this.config.messages;
-
+
if (sender.equals(firstTarget) || sender.equals(secondTarget)) {
- this.announcer.sendMessage(sender, messages.admin.adminCannotTagSelf);
+
+ this.announcer.create()
+ .notice(messages.admin.adminCannotTagSelf)
+ .viewer(sender)
+ .send();
+
return;
}
FightTagEvent firstTagEvent = this.fightManager.tag(firstTarget.getUniqueId(), combatTime, CauseOfTag.COMMAND);
FightTagEvent secondTagEvent = this.fightManager.tag(secondTarget.getUniqueId(), combatTime, CauseOfTag.COMMAND);
- Formatter formatter = new Formatter()
- .register("{FIRST_PLAYER}", firstTarget.getName())
- .register("{SECOND_PLAYER}", secondTarget.getName());
-
- String format = formatter.format(messages.admin.adminTagMultiplePlayers);
-
if (firstTagEvent.isCancelled()) {
CancelTagReason cancelReason = firstTagEvent.getCancelReason();
- if (cancelReason == CancelTagReason.TAGOUT) {
- this.announcer.sendMessage(sender, this.config.messages.admin.adminTagOutCanceled);
- return;
- }
+ this.tagoutReasonHandler(sender, cancelReason, messages);
return;
}
@@ -105,10 +103,7 @@ void tagMultiple(@Context CommandSender sender, @Arg Player firstTarget, @Arg Pl
if (secondTagEvent.isCancelled()) {
CancelTagReason cancelReason = secondTagEvent.getCancelReason();
- if (cancelReason == CancelTagReason.TAGOUT) {
- this.announcer.sendMessage(sender, this.config.messages.admin.adminTagOutCanceled);
- return;
- }
+ this.tagoutReasonHandler(sender, cancelReason, messages);
return;
}
@@ -117,7 +112,13 @@ void tagMultiple(@Context CommandSender sender, @Arg Player firstTarget, @Arg Pl
return;
}
- this.announcer.sendMessage(sender, format);
+ this.announcer.create()
+ .notice(messages.admin.adminTagMultiplePlayers)
+ .placeholder("{FIRST_PLAYER}", firstTarget.getName())
+ .placeholder("{SECOND_PLAYER}", secondTarget.getName())
+ .viewer(sender)
+ .send();
+
}
@Execute(name = "untag")
@@ -126,7 +127,10 @@ void untag(@Context Player sender, @Arg Player target) {
UUID targetUniqueId = target.getUniqueId();
if (!this.fightManager.isInCombat(targetUniqueId)) {
- this.announcer.sendMessage(sender, this.config.messages.admin.adminPlayerNotInCombat);
+ this.announcer.create()
+ .viewer(sender)
+ .notice(this.config.messages.admin.adminPlayerNotInCombat)
+ .send();
return;
}
@@ -135,11 +139,21 @@ void untag(@Context Player sender, @Arg Player target) {
return;
}
- Formatter formatter = new Formatter()
- .register("{PLAYER}", target.getName());
- String format = formatter.format(this.config.messages.admin.adminUntagPlayer);
+ this.announcer.create()
+ .notice(this.config.messages.admin.adminUntagPlayer)
+ .placeholder("{PLAYER}", target.getName())
+ .viewer(sender)
+ .send();
+ }
+
+ private void tagoutReasonHandler(CommandSender sender, CancelTagReason cancelReason, PluginConfig.Messages messages) {
+ if (cancelReason == CancelTagReason.TAGOUT) {
+ this.announcer.create()
+ .notice(messages.admin.adminTagOutCanceled)
+ .viewer(sender)
+ .send();
- this.announcer.sendMessage(sender, format);
+ }
}
}
diff --git a/eternalcombat-plugin/src/main/java/com/eternalcode/combat/fight/FightTask.java b/eternalcombat-plugin/src/main/java/com/eternalcode/combat/fight/FightTask.java
index 0ffe7bd9..67f5db47 100644
--- a/eternalcombat-plugin/src/main/java/com/eternalcode/combat/fight/FightTask.java
+++ b/eternalcombat-plugin/src/main/java/com/eternalcode/combat/fight/FightTask.java
@@ -1,15 +1,11 @@
package com.eternalcode.combat.fight;
import com.eternalcode.combat.config.implementation.PluginConfig;
-import com.eternalcode.combat.fight.bossbar.FightBossBarService;
import com.eternalcode.combat.fight.event.CauseOfUnTag;
-import com.eternalcode.combat.notification.Notification;
import com.eternalcode.combat.notification.NotificationAnnouncer;
-import com.eternalcode.combat.notification.implementation.BossBarNotification;
import com.eternalcode.combat.util.DurationUtil;
import org.bukkit.Server;
import org.bukkit.entity.Player;
-import panda.utilities.text.Formatter;
import java.time.Duration;
import java.util.UUID;
@@ -19,14 +15,12 @@ public class FightTask implements Runnable {
private final Server server;
private final PluginConfig config;
private final FightManager fightManager;
- private final FightBossBarService bossBarService;
private final NotificationAnnouncer announcer;
- public FightTask(Server server, PluginConfig config, FightManager fightManager, FightBossBarService bossBarService, NotificationAnnouncer announcer) {
+ public FightTask(Server server, PluginConfig config, FightManager fightManager, NotificationAnnouncer announcer) {
this.server = server;
this.config = config;
this.fightManager = fightManager;
- this.bossBarService = bossBarService;
this.announcer = announcer;
}
@@ -47,21 +41,13 @@ public void run() {
}
Duration remaining = fightTag.getRemainingDuration();
- Formatter formatter = new Formatter()
- .register("{TIME}", DurationUtil.format(remaining));
- Notification combatNotification = this.config.messages.combatNotification;
+ this.announcer.create()
+ .player(player.getUniqueId())
+ .notice(this.config.messages.combatNotification)
+ .placeholder("{TIME}", DurationUtil.format(remaining))
+ .send();
- this.sendFightNotification(player, fightTag, combatNotification, formatter);
}
}
-
- private void sendFightNotification(Player player, FightTag fightTag, Notification notification, Formatter formatter) {
- if (notification instanceof BossBarNotification bossBarNotification) {
- this.bossBarService.send(player, fightTag, bossBarNotification, formatter);
- return;
- }
-
- this.announcer.send(player, notification, formatter);
- }
}
diff --git a/eternalcombat-plugin/src/main/java/com/eternalcode/combat/fight/bossbar/FightBossBar.java b/eternalcombat-plugin/src/main/java/com/eternalcode/combat/fight/bossbar/FightBossBar.java
deleted file mode 100644
index 430cca22..00000000
--- a/eternalcombat-plugin/src/main/java/com/eternalcode/combat/fight/bossbar/FightBossBar.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package com.eternalcode.combat.fight.bossbar;
-
-import net.kyori.adventure.audience.Audience;
-import net.kyori.adventure.bossbar.BossBar;
-
-import java.time.Duration;
-
-public record FightBossBar(Audience audience, BossBar bossBar, float progress, Duration combatDuration) {
-}
diff --git a/eternalcombat-plugin/src/main/java/com/eternalcode/combat/fight/bossbar/FightBossBarRegistry.java b/eternalcombat-plugin/src/main/java/com/eternalcode/combat/fight/bossbar/FightBossBarRegistry.java
deleted file mode 100644
index b113a317..00000000
--- a/eternalcombat-plugin/src/main/java/com/eternalcode/combat/fight/bossbar/FightBossBarRegistry.java
+++ /dev/null
@@ -1,27 +0,0 @@
-package com.eternalcode.combat.fight.bossbar;
-
-import java.util.Map;
-import java.util.Optional;
-import java.util.UUID;
-import java.util.concurrent.ConcurrentHashMap;
-
-class FightBossBarRegistry {
-
- private final Map fightBossBars = new ConcurrentHashMap<>();
-
- void add(UUID uuid, FightBossBar fightBossBar) {
- this.fightBossBars.put(uuid, fightBossBar);
- }
-
- void remove(UUID uuid) {
- this.fightBossBars.remove(uuid);
- }
-
- boolean hasFightBossBar(UUID uuid) {
- return this.fightBossBars.containsKey(uuid);
- }
-
- Optional getFightBossBar(UUID uuid) {
- return Optional.ofNullable(this.fightBossBars.get(uuid));
- }
-}
diff --git a/eternalcombat-plugin/src/main/java/com/eternalcode/combat/fight/bossbar/FightBossBarService.java b/eternalcombat-plugin/src/main/java/com/eternalcode/combat/fight/bossbar/FightBossBarService.java
deleted file mode 100644
index e7fcb6de..00000000
--- a/eternalcombat-plugin/src/main/java/com/eternalcode/combat/fight/bossbar/FightBossBarService.java
+++ /dev/null
@@ -1,112 +0,0 @@
-package com.eternalcode.combat.fight.bossbar;
-
-import com.eternalcode.combat.config.implementation.PluginConfig;
-import com.eternalcode.combat.fight.FightTag;
-import com.eternalcode.combat.notification.implementation.BossBarNotification;
-import net.kyori.adventure.audience.Audience;
-import net.kyori.adventure.bossbar.BossBar;
-import net.kyori.adventure.platform.AudienceProvider;
-import net.kyori.adventure.text.Component;
-import net.kyori.adventure.text.minimessage.MiniMessage;
-import org.bukkit.entity.Player;
-import panda.utilities.text.Formatter;
-
-import java.time.Duration;
-import java.util.Optional;
-import java.util.UUID;
-
-public class FightBossBarService {
-
- private final PluginConfig pluginConfig;
- private final FightBossBarRegistry bossBarRegistry = new FightBossBarRegistry();
- private final AudienceProvider audienceProvider;
- private final MiniMessage miniMessage;
-
- public FightBossBarService(PluginConfig pluginConfig, AudienceProvider audienceProvider, MiniMessage miniMessage) {
- this.pluginConfig = pluginConfig;
- this.audienceProvider = audienceProvider;
- this.miniMessage = miniMessage;
- }
-
- public void hide(FightTag fightTag, FightBossBar fightBossBar) {
- Audience audience = fightBossBar.audience();
- BossBar bossBar = fightBossBar.bossBar();
- UUID taggedPlayer = fightTag.getTaggedPlayer();
-
- audience.hideBossBar(bossBar);
- this.bossBarRegistry.remove(taggedPlayer);
- }
-
- public void hide(UUID playerUuid) {
- Optional bossBar = this.bossBarRegistry.getFightBossBar(playerUuid);
-
- if (bossBar.isPresent()) {
- FightBossBar fightBossBar = bossBar.get();
- Audience audience = fightBossBar.audience();
- BossBar bar = fightBossBar.bossBar();
-
- audience.hideBossBar(bar);
- this.bossBarRegistry.remove(playerUuid);
- }
- }
-
- public void send(Player player, FightTag fightTag, BossBarNotification bossBarNotification, Formatter formatter) {
- UUID playerUniqueId = player.getUniqueId();
-
- FightBossBar fightBossBar = this.bossBarRegistry.getFightBossBar(playerUniqueId)
- .orElseGet(() -> this.create(player, bossBarNotification, formatter));
-
- if (!this.bossBarRegistry.hasFightBossBar(playerUniqueId)) {
- this.show(player, fightBossBar);
- return;
- }
-
- String message = formatter.format(bossBarNotification.message());
-
- this.update(fightTag, fightBossBar, message);
- }
-
- private void update(FightTag fightTag, FightBossBar fightBossBar, String message) {
- if (fightTag.isExpired()) {
- this.hide(fightTag, fightBossBar);
- return;
- }
-
- BossBar bossBar = fightBossBar.bossBar();
-
- long combatDurationMillis = this.pluginConfig.settings.combatDuration.toMillis();
- long remainingDurationMillis = fightTag.getRemainingDuration().toMillis();
-
- float progress = (float) remainingDurationMillis / combatDurationMillis;
-
- if (progress > 1.0F) {
- progress = 1.0F;
- }
-
- Component name = this.miniMessage.deserialize(message);
- bossBar.name(name);
- bossBar.progress(progress);
- }
-
- private void show(Player player, FightBossBar fightBossBar) {
- UUID playerUniqueId = player.getUniqueId();
-
- Audience audience = this.audienceProvider.player(playerUniqueId);
- BossBar bossBar = fightBossBar.bossBar();
-
- audience.showBossBar(bossBar);
- this.bossBarRegistry.add(playerUniqueId, fightBossBar);
- }
-
- private FightBossBar create(Player player, BossBarNotification bossBarNotification, Formatter formatter) {
- Audience audience = this.audienceProvider.player(player.getUniqueId());
-
- Component name = this.miniMessage.deserialize(formatter.format(bossBarNotification.message()));
- BossBar bossBar = bossBarNotification.create(name);
-
- float progress = bossBarNotification.progress();
- Duration combatDuration = this.pluginConfig.settings.combatDuration;
-
- return new FightBossBar(audience, bossBar, progress, combatDuration);
- }
-}
diff --git a/eternalcombat-plugin/src/main/java/com/eternalcode/combat/fight/controller/FightActionBlockerController.java b/eternalcombat-plugin/src/main/java/com/eternalcode/combat/fight/controller/FightActionBlockerController.java
index ff3b7459..8d987754 100644
--- a/eternalcombat-plugin/src/main/java/com/eternalcode/combat/fight/controller/FightActionBlockerController.java
+++ b/eternalcombat-plugin/src/main/java/com/eternalcode/combat/fight/controller/FightActionBlockerController.java
@@ -18,7 +18,6 @@
import java.util.List;
import java.util.UUID;
-import panda.utilities.text.Formatter;
public class FightActionBlockerController implements Listener {
@@ -52,20 +51,29 @@ void onPlace(BlockPlaceEvent event) {
boolean isPlacementBlocked = this.isPlacementBlocked(level);
- Formatter formatter = new Formatter()
- .register("{Y}", this.config.settings.blockPlacingYCoordinate)
- .register("{MODE}", this.config.settings.blockPlacingModeName);
-
if (isPlacementBlocked && specificBlocksToPreventPlacing.isEmpty()) {
event.setCancelled(true);
- this.announcer.sendMessage(player, formatter.format(this.config.messages.blockPlacingBlockedDuringCombat));
+ this.announcer.create()
+ .player(uniqueId)
+ .notice(this.config.messages.blockPlacingBlockedDuringCombat)
+ .placeholder("{Y}", String.valueOf(this.config.settings.blockPlacingYCoordinate))
+ .placeholder("{MODE}", this.config.settings.blockPlacingModeName)
+ .send();
+
}
Material blockMaterial = block.getType();
boolean isBlockInDisabledList = specificBlocksToPreventPlacing.contains(blockMaterial);
if (isPlacementBlocked && isBlockInDisabledList) {
event.setCancelled(true);
- this.announcer.sendMessage(player, formatter.format(this.config.messages.blockPlacingBlockedDuringCombat));
+
+ this.announcer.create()
+ .player(uniqueId)
+ .notice(this.config.messages.blockPlacingBlockedDuringCombat)
+ .placeholder("{Y}", String.valueOf(this.config.settings.blockPlacingYCoordinate))
+ .placeholder("{MODE}", this.config.settings.blockPlacingModeName)
+ .send();
+
}
}
@@ -146,7 +154,11 @@ void onOpenInventory(InventoryOpenEvent event) {
event.setCancelled(true);
- this.announcer.sendMessage(player, this.config.messages.inventoryBlockedDuringCombat);
+ this.announcer.create()
+ .player(uniqueId)
+ .notice(this.config.messages.inventoryBlockedDuringCombat)
+ .send();
+
}
@EventHandler
@@ -169,7 +181,11 @@ void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
if (shouldCancel) {
event.setCancelled(true);
- this.announcer.sendMessage(player, this.config.messages.commandDisabledDuringCombat);
+ this.announcer.create()
+ .player(playerUniqueId)
+ .notice(this.config.messages.commandDisabledDuringCombat)
+ .send();
+
}
}
}
diff --git a/eternalcombat-plugin/src/main/java/com/eternalcode/combat/fight/controller/FightMessageController.java b/eternalcombat-plugin/src/main/java/com/eternalcode/combat/fight/controller/FightMessageController.java
index 99d5af57..c66566cd 100644
--- a/eternalcombat-plugin/src/main/java/com/eternalcode/combat/fight/controller/FightMessageController.java
+++ b/eternalcombat-plugin/src/main/java/com/eternalcode/combat/fight/controller/FightMessageController.java
@@ -2,7 +2,6 @@
import com.eternalcode.combat.config.implementation.PluginConfig;
import com.eternalcode.combat.fight.FightManager;
-import com.eternalcode.combat.fight.bossbar.FightBossBarService;
import com.eternalcode.combat.fight.event.FightTagEvent;
import com.eternalcode.combat.fight.event.FightUntagEvent;
import com.eternalcode.combat.notification.NotificationAnnouncer;
@@ -16,14 +15,12 @@ public class FightMessageController implements Listener {
private final FightManager fightManager;
private final NotificationAnnouncer announcer;
- private final FightBossBarService bossBarService;
private final PluginConfig config;
private final Server server;
- public FightMessageController(FightManager fightManager, NotificationAnnouncer announcer, FightBossBarService bossBarService, PluginConfig config, Server server) {
+ public FightMessageController(FightManager fightManager, NotificationAnnouncer announcer, PluginConfig config, Server server) {
this.fightManager = fightManager;
this.announcer = announcer;
- this.bossBarService = bossBarService;
this.config = config;
this.server = server;
}
@@ -40,7 +37,10 @@ void onTag(FightTagEvent event) {
return;
}
- this.announcer.sendMessage(player, this.config.messages.playerTagged);
+ this.announcer.create()
+ .player(player.getUniqueId())
+ .notice(this.config.messages.playerTagged)
+ .send();
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
@@ -51,7 +51,10 @@ void onUnTag(FightUntagEvent event) {
throw new IllegalStateException("Player cannot be null!");
}
- this.announcer.sendMessage(player, this.config.messages.playerUntagged);
- this.bossBarService.hide(event.getPlayer());
+ this.announcer.create()
+ .player(player.getUniqueId())
+ .notice(this.config.messages.playerUntagged)
+ .send();
+
}
}
diff --git a/eternalcombat-plugin/src/main/java/com/eternalcode/combat/fight/logout/LogoutController.java b/eternalcombat-plugin/src/main/java/com/eternalcode/combat/fight/logout/LogoutController.java
index c870fa38..12ed80e3 100644
--- a/eternalcombat-plugin/src/main/java/com/eternalcode/combat/fight/logout/LogoutController.java
+++ b/eternalcombat-plugin/src/main/java/com/eternalcode/combat/fight/logout/LogoutController.java
@@ -8,7 +8,6 @@
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerQuitEvent;
-import panda.utilities.text.Formatter;
public class LogoutController implements Listener {
@@ -36,11 +35,11 @@ void onQuit(PlayerQuitEvent event) {
this.logoutService.punishForLogout(player);
player.setHealth(0.0);
- Formatter formatter = new Formatter()
- .register("{PLAYER}", player.getName());
-
- String format = formatter.format(this.config.messages.playerLoggedOutDuringCombat);
- this.announcer.broadcast(format);
+ this.announcer.create()
+ .notice(this.config.messages.playerLoggedOutDuringCombat)
+ .placeholder("{PLAYER}", player.getName())
+ .all()
+ .send();
}
diff --git a/eternalcombat-plugin/src/main/java/com/eternalcode/combat/fight/pearl/FightPearlController.java b/eternalcombat-plugin/src/main/java/com/eternalcode/combat/fight/pearl/FightPearlController.java
index 8343bc24..52d98222 100644
--- a/eternalcombat-plugin/src/main/java/com/eternalcode/combat/fight/pearl/FightPearlController.java
+++ b/eternalcombat-plugin/src/main/java/com/eternalcode/combat/fight/pearl/FightPearlController.java
@@ -14,7 +14,6 @@
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
-import panda.utilities.text.Formatter;
import java.time.Duration;
import java.util.UUID;
@@ -58,7 +57,11 @@ void onInteract(PlayerInteractEvent event) {
if (this.settings.pearlThrowDelay.isZero()) {
event.setCancelled(true);
- this.announcer.sendMessage(player, this.settings.pearlThrowBlockedDuringCombat);
+ this.announcer.create()
+ .player(uniqueId)
+ .notice(this.settings.pearlThrowBlockedDuringCombat)
+ .send();
+
return;
}
@@ -67,11 +70,12 @@ void onInteract(PlayerInteractEvent event) {
Duration remainingPearlDelay = this.fightPearlService.getRemainingDelay(uniqueId);
- Formatter formatter = new Formatter()
- .register("{TIME}", DurationUtil.format(remainingPearlDelay));
+ this.announcer.create()
+ .player(uniqueId)
+ .notice(this.settings.pearlThrowBlockedDelayDuringCombat)
+ .placeholder("{TIME}", DurationUtil.format(remainingPearlDelay))
+ .send();
- String format = formatter.format(this.settings.pearlThrowBlockedDelayDuringCombat);
- this.announcer.sendMessage(player, format);
return;
}
diff --git a/eternalcombat-plugin/src/main/java/com/eternalcode/combat/fight/pearl/FightPearlSettings.java b/eternalcombat-plugin/src/main/java/com/eternalcode/combat/fight/pearl/FightPearlSettings.java
index 62fa6e04..b607f775 100644
--- a/eternalcombat-plugin/src/main/java/com/eternalcode/combat/fight/pearl/FightPearlSettings.java
+++ b/eternalcombat-plugin/src/main/java/com/eternalcode/combat/fight/pearl/FightPearlSettings.java
@@ -1,5 +1,7 @@
package com.eternalcode.combat.fight.pearl;
+import com.eternalcode.multification.bukkit.notice.BukkitNotice;
+import com.eternalcode.multification.notice.Notice;
import eu.okaeri.configs.OkaeriConfig;
import eu.okaeri.configs.annotation.Comment;
@@ -21,9 +23,13 @@ public class FightPearlSettings extends OkaeriConfig {
public Duration pearlThrowDelay = Duration.ofSeconds(3);
@Comment("# Message sent when player tries to throw ender pearl, but are disabled")
- public String pearlThrowBlockedDuringCombat = "&cThrowing ender pearls is prohibited during combat!";
+ public Notice pearlThrowBlockedDuringCombat = BukkitNotice.builder()
+ .chat("&cThrowing ender pearls is prohibited during combat!")
+ .build();
@Comment("# Message sent when player tries to throw ender pearl, but has delay")
- public String pearlThrowBlockedDelayDuringCombat = "&cYou must wait {TIME} before next throw!";
+ public Notice pearlThrowBlockedDelayDuringCombat = BukkitNotice.builder()
+ .chat("&cYou must wait {TIME} before next throw!")
+ .build();
}
diff --git a/eternalcombat-plugin/src/main/java/com/eternalcode/combat/fight/tagout/FightTagOutCommand.java b/eternalcombat-plugin/src/main/java/com/eternalcode/combat/fight/tagout/FightTagOutCommand.java
index f9654786..1934dfd9 100644
--- a/eternalcombat-plugin/src/main/java/com/eternalcode/combat/fight/tagout/FightTagOutCommand.java
+++ b/eternalcombat-plugin/src/main/java/com/eternalcode/combat/fight/tagout/FightTagOutCommand.java
@@ -9,11 +9,10 @@
import dev.rollczi.litecommands.annotations.execute.Execute;
import dev.rollczi.litecommands.annotations.permission.Permission;
import java.time.Duration;
-import java.time.Instant;
import java.util.UUID;
import org.bukkit.entity.Player;
-import panda.utilities.text.Formatter;
+@Permission("eternalcombat.tagout")
@Command(name = "tagout", aliases = "tagimmunity")
public class FightTagOutCommand {
@@ -32,67 +31,72 @@ public FightTagOutCommand(
}
@Execute
- @Permission("eternalcombat.tagout")
void tagout(@Context Player sender, @Arg Duration time) {
UUID targetUniqueId = sender.getUniqueId();
- Formatter formatter = new Formatter()
- .register("{PLAYER}", sender.getName())
- .register("{TIME}", DurationUtil.format(time));
-
this.fightTagOutService.tagOut(targetUniqueId, time);
- String format = formatter.format(this.config.messages.admin.adminTagOutSelf);
- this.announcer.sendMessage(sender, format);
+ this.announcer.create()
+ .notice(this.config.messages.admin.adminTagOutSelf)
+ .placeholder("{TIME}", DurationUtil.format(time))
+ .viewer(sender)
+ .send();
+
}
@Execute
- @Permission("eternalcombat.tagout")
void tagout(@Context Player sender, @Arg Player target, @Arg Duration time) {
UUID targetUniqueId = target.getUniqueId();
- Instant now = Instant.now();
- Duration remaining = Duration.between(now, now.plus(time));
-
- Formatter formatter = new Formatter()
- .register("{PLAYER}", target.getName())
- .register("{TIME}", DurationUtil.format(remaining));
-
this.fightTagOutService.tagOut(targetUniqueId, time);
- String adminTagOutFormat = formatter.format(this.config.messages.admin.adminTagOut);
- this.announcer.sendMessage(sender, adminTagOutFormat);
+ this.announcer.create()
+ .notice(this.config.messages.admin.adminTagOut)
+ .placeholder("{PLAYER}", target.getName())
+ .placeholder("{TIME}", DurationUtil.format(time))
+ .viewer(sender)
+ .send();
+
+ this.announcer.create()
+ .notice(this.config.messages.admin.playerTagOut)
+ .placeholder("{TIME}", DurationUtil.format(time))
+ .player(target.getUniqueId())
+ .send();
- String playerTagOutFormat = formatter.format(this.config.messages.admin.playerTagOut);
- this.announcer.sendMessage(target, playerTagOutFormat);
}
@Execute(name = "remove")
- @Permission("eternalcombat.tagout")
void untagout(@Context Player sender, @Arg Player target) {
UUID targetUniqueId = target.getUniqueId();
this.fightTagOutService.unTagOut(targetUniqueId);
- Formatter formatter = new Formatter()
- .register("{PLAYER}", target.getName());
if (!targetUniqueId.equals(sender.getUniqueId())) {
- String adminUnTagOutFormat = formatter.format(this.config.messages.admin.adminTagOutOff);
- this.announcer.sendMessage(sender, adminUnTagOutFormat);
+ this.announcer.create()
+ .notice(this.config.messages.admin.adminTagOutOff)
+ .placeholder("{PLAYER}", target.getName())
+ .viewer(sender)
+ .send();
}
- this.announcer.sendMessage(target, this.config.messages.admin.playerTagOutOff);
+ this.announcer.create()
+ .notice(this.config.messages.admin.playerTagOutOff)
+ .player(targetUniqueId)
+ .send();
}
@Execute(name = "remove")
- @Permission("eternalcombat.tagout")
void untagout(@Context Player sender) {
UUID senderUniqueId = sender.getUniqueId();
this.fightTagOutService.unTagOut(senderUniqueId);
- this.announcer.sendMessage(sender, this.config.messages.admin.playerTagOutOff);
+ this.announcer.create()
+ .notice(this.config.messages.admin.playerTagOutOff)
+ .viewer(sender)
+ .send();
+
}
}
diff --git a/eternalcombat-plugin/src/main/java/com/eternalcode/combat/handler/InvalidUsageHandlerImpl.java b/eternalcombat-plugin/src/main/java/com/eternalcode/combat/handler/InvalidUsageHandlerImpl.java
index a9546f74..5600748c 100644
--- a/eternalcombat-plugin/src/main/java/com/eternalcode/combat/handler/InvalidUsageHandlerImpl.java
+++ b/eternalcombat-plugin/src/main/java/com/eternalcode/combat/handler/InvalidUsageHandlerImpl.java
@@ -8,7 +8,6 @@
import dev.rollczi.litecommands.invocation.Invocation;
import dev.rollczi.litecommands.schematic.Schematic;
import org.bukkit.command.CommandSender;
-import panda.utilities.text.Formatter;
public class InvalidUsageHandlerImpl implements InvalidUsageHandler {
@@ -29,10 +28,12 @@ public void handle(
Schematic schematic = commandSenderInvalidUsage.getSchematic();
for (String usage : schematic.all()) {
- Formatter formatter = new Formatter()
- .register("{USAGE}", usage);
-
- this.announcer.sendMessage(invocation.sender(), formatter.format(this.config.messages.invalidCommandUsage));
+ this.announcer.create()
+ .viewer(invocation.sender())
+ .notice(this.config.messages.invalidCommandUsage)
+ .placeholder("{USAGE}", usage)
+ .send();
}
+
}
}
diff --git a/eternalcombat-plugin/src/main/java/com/eternalcode/combat/handler/MissingPermissionHandlerImpl.java b/eternalcombat-plugin/src/main/java/com/eternalcode/combat/handler/MissingPermissionHandlerImpl.java
index 0466f22b..1b99b2b6 100644
--- a/eternalcombat-plugin/src/main/java/com/eternalcode/combat/handler/MissingPermissionHandlerImpl.java
+++ b/eternalcombat-plugin/src/main/java/com/eternalcode/combat/handler/MissingPermissionHandlerImpl.java
@@ -7,7 +7,6 @@
import dev.rollczi.litecommands.permission.MissingPermissions;
import dev.rollczi.litecommands.permission.MissingPermissionsHandler;
import org.bukkit.command.CommandSender;
-import panda.utilities.text.Formatter;
public class MissingPermissionHandlerImpl implements MissingPermissionsHandler {
@@ -27,9 +26,13 @@ public void handle(
) {
String joinedText = missingPermissions.asJoinedText();
- Formatter formatter = new Formatter()
- .register("{PERMISSION}", joinedText);
- this.announcer.sendMessage(invocation.sender(), formatter.format(this.config.messages.noPermission));
+ this.announcer.create()
+ .viewer(invocation.sender())
+ .notice(this.config.messages.noPermission)
+ .placeholder("{PERMISSION}", joinedText)
+ .send();
+
}
}
+
diff --git a/eternalcombat-plugin/src/main/java/com/eternalcode/combat/notification/NotificationAnnouncer.java b/eternalcombat-plugin/src/main/java/com/eternalcode/combat/notification/NotificationAnnouncer.java
index 47de9228..8644e02f 100644
--- a/eternalcombat-plugin/src/main/java/com/eternalcode/combat/notification/NotificationAnnouncer.java
+++ b/eternalcombat-plugin/src/main/java/com/eternalcode/combat/notification/NotificationAnnouncer.java
@@ -1,78 +1,48 @@
package com.eternalcode.combat.notification;
-import com.eternalcode.combat.notification.implementation.BossBarNotification;
-import net.kyori.adventure.audience.Audience;
-import net.kyori.adventure.bossbar.BossBar;
+import com.eternalcode.combat.config.implementation.PluginConfig;
+import com.eternalcode.multification.adventure.AudienceConverter;
+import com.eternalcode.multification.bukkit.BukkitMultification;
+import com.eternalcode.multification.translation.TranslationProvider;
import net.kyori.adventure.platform.AudienceProvider;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.minimessage.MiniMessage;
-import net.kyori.adventure.title.Title;
+import net.kyori.adventure.text.serializer.ComponentSerializer;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
-import panda.utilities.text.Formatter;
+import org.jetbrains.annotations.NotNull;
-public final class NotificationAnnouncer {
+public final class NotificationAnnouncer extends BukkitMultification {
private final AudienceProvider audienceProvider;
+ private final PluginConfig pluginConfig;
private final MiniMessage miniMessage;
- public NotificationAnnouncer(AudienceProvider audienceProvider, MiniMessage miniMessage) {
+ public NotificationAnnouncer(AudienceProvider audienceProvider, PluginConfig pluginConfig, MiniMessage miniMessage) {
this.audienceProvider = audienceProvider;
+ this.pluginConfig = pluginConfig;
this.miniMessage = miniMessage;
}
- public void send(CommandSender sender, Notification notification, Formatter formatter) {
- Audience audience = this.audience(sender);
- Component message = this.miniMessage.deserialize(formatter.format(notification.message()));
-
- NotificationType type = notification.type();
-
- switch (type) {
- case CHAT -> audience.sendMessage(message);
- case ACTION_BAR -> audience.sendActionBar(message);
-
- case TITLE -> {
- Title title = Title.title(message, Component.empty());
-
- audience.showTitle(title);
- }
-
- case SUB_TITLE -> {
- Title subTitle = Title.title(Component.empty(), message);
-
- audience.showTitle(subTitle);
- }
-
- case BOSS_BAR -> {
- BossBarNotification bossBarNotification = (BossBarNotification) notification;
- BossBar bossBar = bossBarNotification.create(message);
-
- audience.showBossBar(bossBar);
- }
-
- default -> throw new IllegalStateException("Unknown notification type: " + type);
- }
+ @Override
+ protected @NotNull TranslationProvider translationProvider() {
+ return locale -> this.pluginConfig;
}
- public void sendMessage(CommandSender commandSender, String text) {
- Audience audience = this.audience(commandSender);
- Component message = this.miniMessage.deserialize(text);
-
- audience.sendMessage(message);
+ @Override
+ protected @NotNull ComponentSerializer serializer() {
+ return this.miniMessage;
}
- public void broadcast(String text) {
- Audience audience = this.audienceProvider.all();
- Component message = this.miniMessage.deserialize(text);
-
- audience.sendMessage(message);
- }
+ @Override
+ protected @NotNull AudienceConverter audienceConverter() {
+ return commandSender -> {
+ if (commandSender instanceof Player player) {
+ return this.audienceProvider.player(player.getUniqueId());
+ }
- private Audience audience(CommandSender sender) {
- if (sender instanceof Player player) {
- return this.audienceProvider.player(player.getUniqueId());
- }
+ return this.audienceProvider.console();
+ };
- return this.audienceProvider.console();
}
}
diff --git a/eternalcombat-plugin/src/main/java/com/eternalcode/combat/region/RegionController.java b/eternalcombat-plugin/src/main/java/com/eternalcode/combat/region/RegionController.java
index 1023c981..65711a66 100644
--- a/eternalcombat-plugin/src/main/java/com/eternalcode/combat/region/RegionController.java
+++ b/eternalcombat-plugin/src/main/java/com/eternalcode/combat/region/RegionController.java
@@ -62,7 +62,11 @@ void onPlayerMove(PlayerMoveEvent event) {
player.setVelocity(knockbackVector.multiply(configuredVector));
- this.announcer.sendMessage(player, this.pluginConfig.messages.cantEnterOnRegion);
+ this.announcer.create()
+ .player(player.getUniqueId())
+ .notice(this.pluginConfig.messages.cantEnterOnRegion)
+ .send();
+
}
}
@@ -78,7 +82,10 @@ public void onPlayerTeleport(PlayerTeleportEvent event) {
if (this.regionProvider.isInRegion(targetLocation)) {
event.setCancelled(true);
- this.announcer.sendMessage(player, this.pluginConfig.messages.cantEnterOnRegion);
+ this.announcer.create()
+ .player(player.getUniqueId())
+ .notice(this.pluginConfig.messages.cantEnterOnRegion)
+ .send();
}
}
}
diff --git a/eternalcombat-plugin/src/main/java/com/eternalcode/combat/updater/UpdaterService.java b/eternalcombat-plugin/src/main/java/com/eternalcode/combat/updater/UpdaterService.java
index bf5d665c..e5700829 100644
--- a/eternalcombat-plugin/src/main/java/com/eternalcode/combat/updater/UpdaterService.java
+++ b/eternalcombat-plugin/src/main/java/com/eternalcode/combat/updater/UpdaterService.java
@@ -4,8 +4,8 @@
import com.eternalcode.gitcheck.GitCheckResult;
import com.eternalcode.gitcheck.git.GitRepository;
import com.eternalcode.gitcheck.git.GitTag;
+import dev.rollczi.litecommands.shared.Lazy;
import org.bukkit.plugin.PluginDescriptionFile;
-import panda.std.Lazy;
import java.util.concurrent.CompletableFuture;