forked from SuperRicky14/TpaPlusPlus
-
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.
feat(command): Add ReloadCommand.kt to reload language config
- Loading branch information
1 parent
b60c3e8
commit c323891
Showing
10 changed files
with
58 additions
and
0 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
40 changes: 40 additions & 0 deletions
40
src/main/kotlin/net/superricky/tpaplusplus/command/subcommands/ReloadCommand.kt
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,40 @@ | ||
package net.superricky.tpaplusplus.command.subcommands | ||
|
||
import net.minecraft.server.command.CommandManager.literal | ||
import net.superricky.tpaplusplus.GlobalConst.PERMISSION_LEVEL | ||
import net.superricky.tpaplusplus.command.BuildableCommand | ||
import net.superricky.tpaplusplus.command.CommandResult | ||
import net.superricky.tpaplusplus.config.config.CommonSpec | ||
import net.superricky.tpaplusplus.config.config.Config.get | ||
import net.superricky.tpaplusplus.config.language.LanguageConfig | ||
import net.superricky.tpaplusplus.config.language.LanguageConfig.getMutableText | ||
import net.superricky.tpaplusplus.config.language.SystemSpec | ||
import net.superricky.tpaplusplus.utility.Context | ||
import net.superricky.tpaplusplus.utility.LiteralNode | ||
import net.superricky.tpaplusplus.utility.TextColorPallet | ||
|
||
object ReloadCommand : BuildableCommand { | ||
override fun build(): LiteralNode = | ||
literal("reload") | ||
.requires { | ||
it.hasPermissionLevel(PERMISSION_LEVEL) | ||
} | ||
.then( | ||
literal("message") | ||
.executes { reloadMessage(it) } | ||
) | ||
.executes { | ||
reloadMessage(it) | ||
} | ||
.build() | ||
|
||
private fun reloadMessage(context: Context): Int { | ||
val source = context.source | ||
val sender = source.player | ||
sender ?: return CommandResult.SENDER_NOT_EXIST.status | ||
sender.sendMessage(SystemSpec.reloadStart.getMutableText().setStyle(TextColorPallet.primary)) | ||
LanguageConfig.loadLangFile(CommonSpec.language.get().lowercase()) | ||
sender.sendMessage(SystemSpec.reloadFinish.getMutableText().setStyle(TextColorPallet.primary)) | ||
return CommandResult.NORMAL.status | ||
} | ||
} |
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
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