Skip to content
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/eternalcombat-java.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ plugins {
}

group = "com.eternalcode"
version = "2.2.0"
version = "2.2.1-SNAPSHOT"

tasks.compileJava {
options.compilerArgs = listOf("-Xlint:deprecation", "-parameters")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
import dev.rollczi.litecommands.LiteCommands;
import dev.rollczi.litecommands.bukkit.LiteBukkitFactory;
import dev.rollczi.litecommands.bukkit.LiteBukkitMessages;
import dev.rollczi.litecommands.permission.PermissionResolver;
import net.kyori.adventure.platform.AudienceProvider;
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
import net.kyori.adventure.text.minimessage.MiniMessage;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import org.bukkit.command.CommandSender;

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

private static final Notice RELOAD_MESSAGE = BukkitNotice.builder()
Expand All @@ -31,6 +30,7 @@ public EternalCombatReloadCommand(ConfigService configService, NoticeService not

@Async
@Execute(name = "reload")
@Permission("eternalcombat.reload")
void execute(@Context CommandSender sender) {
Stopwatch stopwatch = Stopwatch.createStarted();
this.configService.reload();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public void init(Server server) {

initialize(
"PlaceholderAPI",
() -> new FightTagPlaceholder(this.fightManager, server, this.plugin).register(),
() -> new FightTagPlaceholder(this.config.placeholder, this.fightManager, server, this.plugin).register(),
() -> this.logger.warning("PlaceholderAPI not found; skipping placeholders.")
);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.eternalcode.combat.bridge.placeholder;

import com.eternalcode.combat.config.implementation.PlaceholderSettings;
import com.eternalcode.combat.fight.FightManager;
import com.eternalcode.combat.fight.FightTag;
import com.eternalcode.combat.util.DurationUtil;
Expand All @@ -14,12 +15,14 @@

public class FightTagPlaceholder extends PlaceholderExpansion {

private static final String IDENTIFIER = "eternalcombat";
private final PlaceholderSettings placeholderSettings;
private final FightManager fightManager;
private final Server server;
private final Plugin plugin;
private static final String IDENTIFIER = "eternalcombat";

public FightTagPlaceholder(FightManager fightManager, Server server, Plugin plugin) {
public FightTagPlaceholder(PlaceholderSettings placeholderSettings, FightManager fightManager, Server server, Plugin plugin) {
this.placeholderSettings = placeholderSettings;
this.fightManager = fightManager;
this.server = server;
this.plugin = plugin;
Expand All @@ -30,7 +33,6 @@ public boolean canRegister() {
return true;
}


@Override
public @NotNull String getIdentifier() {
return IDENTIFIER;
Expand Down Expand Up @@ -71,6 +73,16 @@ public String onRequest(OfflinePlayer player, String identifier) {
.map(tagger -> String.format("%.2f", tagger.getHealth()))
.orElse("");
}
if (identifier.equals("isInCombat")) {
return this.getFightTag(player)
.map(fightTag -> "true")
.orElse("false");
}
if (identifier.equals("isInCombat_formatted")) {
return this.getFightTag(player)
.map(fightTag -> this.placeholderSettings.isInCombatFormattedTrue)
.orElse(this.placeholderSettings.isInCombatFormattedFalse);
}

return null;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.eternalcode.combat.config.implementation;

import eu.okaeri.configs.OkaeriConfig;

public class PlaceholderSettings extends OkaeriConfig {

public String isInCombatFormattedTrue = "In Combat";
public String isInCombatFormattedFalse = "Not In Combat";

}
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,13 @@ public class PluginConfig extends OkaeriConfig {
})
public CombatSettings combat = new CombatSettings();

@Comment({
" ",
"# Settings related to placeholders used in the plugin.",
"# Now only for isInCombat_formatted"
})
public PlaceholderSettings placeholder = new PlaceholderSettings();

@Comment({
" ",
"# Customize the messages displayed by the plugin.",
Expand Down
Loading