-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
99 additions
and
3 deletions.
There are no files selected for viewing
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
42 changes: 42 additions & 0 deletions
42
src/main/java/city/thefloating/helios/server/MarkdownCommand.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 city.thefloating.helios.server; | ||
|
||
import city.thefloating.helios.config.LangConfig; | ||
import city.thefloating.helios.soul.Charon; | ||
import cloud.commandframework.meta.CommandMeta; | ||
import cloud.commandframework.paper.PaperCommandManager; | ||
import com.google.inject.Inject; | ||
import org.bukkit.command.CommandSender; | ||
import org.bukkit.entity.Player; | ||
import org.spongepowered.configurate.NodePath; | ||
|
||
public class MarkdownCommand { | ||
|
||
private final LangConfig langConfig; | ||
private final Charon charon; | ||
|
||
@Inject | ||
public MarkdownCommand( | ||
final LangConfig langConfig, | ||
final Charon charon | ||
) { | ||
this.langConfig = langConfig; | ||
this.charon = charon; | ||
} | ||
|
||
public void register(final PaperCommandManager<CommandSender> commandManager) { | ||
final var main = commandManager.commandBuilder("markdown") | ||
.meta(CommandMeta.DESCRIPTION, "Toggle markdown chat formatting.") | ||
.senderType(Player.class) | ||
.handler(c -> { | ||
final Player sender = (Player) c.getSender(); | ||
if (this.charon.grab(sender).toggleMarkdown()) { | ||
sender.sendMessage(this.langConfig.c(NodePath.path("markdown", "enabled"))); | ||
} else { | ||
sender.sendMessage(this.langConfig.c(NodePath.path("markdown", "disabled"))); | ||
} | ||
}); | ||
|
||
commandManager.command(main); | ||
} | ||
|
||
} |
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