-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GH-187 Separate commands to a different classes
- Loading branch information
Showing
5 changed files
with
69 additions
and
37 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
eternalcombat-api/src/main/java/com/eternalcode/combat/command/CombatStatusCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package com.eternalcode.combat.command; | ||
|
||
import com.eternalcode.combat.config.implementation.PluginConfig; | ||
import com.eternalcode.combat.fight.FightManager; | ||
import com.eternalcode.combat.notification.NotificationAnnouncer; | ||
import dev.rollczi.litecommands.annotations.argument.Arg; | ||
import dev.rollczi.litecommands.annotations.command.Command; | ||
import dev.rollczi.litecommands.annotations.context.Context; | ||
import dev.rollczi.litecommands.annotations.execute.Execute; | ||
import dev.rollczi.litecommands.annotations.permission.Permission; | ||
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 CombatStatusCommand { | ||
|
||
private final FightManager fightManager; | ||
private final NotificationAnnouncer announcer; | ||
private final PluginConfig config; | ||
|
||
public CombatStatusCommand(FightManager fightManager, NotificationAnnouncer announcer, PluginConfig config) { | ||
this.fightManager = fightManager; | ||
this.announcer = announcer; | ||
this.config = config; | ||
} | ||
|
||
@Execute(name = "status") | ||
@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.sendMessage(sender, this.fightManager.isInCombat(targetUniqueId) | ||
? formatter.format(messages.admin.playerInCombat) | ||
: formatter.format(messages.admin.playerNotInCombat)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters