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 command (Not yet implemented, just register them)
- Loading branch information
1 parent
1fe42dd
commit af5ff5a
Showing
22 changed files
with
311 additions
and
46 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
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
7 changes: 7 additions & 0 deletions
7
src/main/kotlin/net/superricky/tpaplusplus/command/BuildableCommand.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,7 @@ | ||
package net.superricky.tpaplusplus.command | ||
|
||
import net.superricky.tpaplusplus.utility.LiteralNode | ||
|
||
interface BuildableCommand { | ||
fun build(): LiteralNode | ||
} |
22 changes: 22 additions & 0 deletions
22
src/main/kotlin/net/superricky/tpaplusplus/command/CommandRegister.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,22 @@ | ||
package net.superricky.tpaplusplus.command | ||
|
||
import net.superricky.tpaplusplus.command.commands.* | ||
import net.superricky.tpaplusplus.command.subcommands.RootCommand | ||
import net.superricky.tpaplusplus.utility.Dispatcher | ||
|
||
object CommandRegister { | ||
fun registerCommands(dispatcher: Dispatcher) { | ||
val rootNode = RootCommand.build() | ||
|
||
dispatcher.root.addChild(rootNode) | ||
|
||
dispatcher.root.addChild(AcceptCommand.build()) | ||
dispatcher.root.addChild(BackCommand.build()) | ||
dispatcher.root.addChild(CancelCommand.build()) | ||
dispatcher.root.addChild(DenyCommand.build()) | ||
dispatcher.root.addChild(ToggleCommand.build()) | ||
dispatcher.root.addChild(TpaCommand.build()) | ||
dispatcher.root.addChild(TpaHereCommand.build()) | ||
dispatcher.root.addChild(UnblockCommand.build()) | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
src/main/kotlin/net/superricky/tpaplusplus/command/commands/AcceptCommand.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,13 @@ | ||
package net.superricky.tpaplusplus.command.commands | ||
|
||
import net.minecraft.server.command.CommandManager.literal | ||
import net.superricky.tpaplusplus.command.BuildableCommand | ||
import net.superricky.tpaplusplus.config.Config | ||
import net.superricky.tpaplusplus.config.command.CommandNameSpec | ||
import net.superricky.tpaplusplus.utility.LiteralNode | ||
|
||
object AcceptCommand : BuildableCommand { | ||
override fun build(): LiteralNode = | ||
literal(Config.getConfig()[CommandNameSpec.tpaacceptCommand]) | ||
.build() | ||
} |
13 changes: 13 additions & 0 deletions
13
src/main/kotlin/net/superricky/tpaplusplus/command/commands/BackCommand.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,13 @@ | ||
package net.superricky.tpaplusplus.command.commands | ||
|
||
import net.minecraft.server.command.CommandManager.literal | ||
import net.superricky.tpaplusplus.command.BuildableCommand | ||
import net.superricky.tpaplusplus.config.Config | ||
import net.superricky.tpaplusplus.config.command.CommandNameSpec | ||
import net.superricky.tpaplusplus.utility.LiteralNode | ||
|
||
object BackCommand : BuildableCommand { | ||
override fun build(): LiteralNode = | ||
literal(Config.getConfig()[CommandNameSpec.backCommand]) | ||
.build() | ||
} |
13 changes: 13 additions & 0 deletions
13
src/main/kotlin/net/superricky/tpaplusplus/command/commands/BlockCommand.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,13 @@ | ||
package net.superricky.tpaplusplus.command.commands | ||
|
||
import net.minecraft.server.command.CommandManager.literal | ||
import net.superricky.tpaplusplus.command.BuildableCommand | ||
import net.superricky.tpaplusplus.config.Config | ||
import net.superricky.tpaplusplus.config.command.CommandNameSpec | ||
import net.superricky.tpaplusplus.utility.LiteralNode | ||
|
||
object BlockCommand : BuildableCommand { | ||
override fun build(): LiteralNode = | ||
literal(Config.getConfig()[CommandNameSpec.tpablockCommand]) | ||
.build() | ||
} |
13 changes: 13 additions & 0 deletions
13
src/main/kotlin/net/superricky/tpaplusplus/command/commands/CancelCommand.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,13 @@ | ||
package net.superricky.tpaplusplus.command.commands | ||
|
||
import net.minecraft.server.command.CommandManager.literal | ||
import net.superricky.tpaplusplus.command.BuildableCommand | ||
import net.superricky.tpaplusplus.config.Config | ||
import net.superricky.tpaplusplus.config.command.CommandNameSpec | ||
import net.superricky.tpaplusplus.utility.LiteralNode | ||
|
||
object CancelCommand : BuildableCommand { | ||
override fun build(): LiteralNode = | ||
literal(Config.getConfig()[CommandNameSpec.tpacancelCommand]) | ||
.build() | ||
} |
13 changes: 13 additions & 0 deletions
13
src/main/kotlin/net/superricky/tpaplusplus/command/commands/DenyCommand.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,13 @@ | ||
package net.superricky.tpaplusplus.command.commands | ||
|
||
import net.minecraft.server.command.CommandManager.literal | ||
import net.superricky.tpaplusplus.command.BuildableCommand | ||
import net.superricky.tpaplusplus.config.Config | ||
import net.superricky.tpaplusplus.config.command.CommandNameSpec | ||
import net.superricky.tpaplusplus.utility.LiteralNode | ||
|
||
object DenyCommand : BuildableCommand { | ||
override fun build(): LiteralNode = | ||
literal(Config.getConfig()[CommandNameSpec.tpadenyCommand]) | ||
.build() | ||
} |
13 changes: 13 additions & 0 deletions
13
src/main/kotlin/net/superricky/tpaplusplus/command/commands/ToggleCommand.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,13 @@ | ||
package net.superricky.tpaplusplus.command.commands | ||
|
||
import net.minecraft.server.command.CommandManager.literal | ||
import net.superricky.tpaplusplus.command.BuildableCommand | ||
import net.superricky.tpaplusplus.config.Config | ||
import net.superricky.tpaplusplus.config.command.CommandNameSpec | ||
import net.superricky.tpaplusplus.utility.LiteralNode | ||
|
||
object ToggleCommand : BuildableCommand { | ||
override fun build(): LiteralNode = | ||
literal(Config.getConfig()[CommandNameSpec.tpatoggleCommand]) | ||
.build() | ||
} |
13 changes: 13 additions & 0 deletions
13
src/main/kotlin/net/superricky/tpaplusplus/command/commands/TpaCommand.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,13 @@ | ||
package net.superricky.tpaplusplus.command.commands | ||
|
||
import net.minecraft.server.command.CommandManager.literal | ||
import net.superricky.tpaplusplus.command.BuildableCommand | ||
import net.superricky.tpaplusplus.config.Config | ||
import net.superricky.tpaplusplus.config.command.CommandNameSpec | ||
import net.superricky.tpaplusplus.utility.LiteralNode | ||
|
||
object TpaCommand : BuildableCommand { | ||
override fun build(): LiteralNode = | ||
literal(Config.getConfig()[CommandNameSpec.tpaCommand]) | ||
.build() | ||
} |
13 changes: 13 additions & 0 deletions
13
src/main/kotlin/net/superricky/tpaplusplus/command/commands/TpaHereCommand.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,13 @@ | ||
package net.superricky.tpaplusplus.command.commands | ||
|
||
import net.minecraft.server.command.CommandManager.literal | ||
import net.superricky.tpaplusplus.command.BuildableCommand | ||
import net.superricky.tpaplusplus.config.Config | ||
import net.superricky.tpaplusplus.config.command.CommandNameSpec | ||
import net.superricky.tpaplusplus.utility.LiteralNode | ||
|
||
object TpaHereCommand : BuildableCommand { | ||
override fun build(): LiteralNode = | ||
literal(Config.getConfig()[CommandNameSpec.tpahereCommand]) | ||
.build() | ||
} |
13 changes: 13 additions & 0 deletions
13
src/main/kotlin/net/superricky/tpaplusplus/command/commands/UnblockCommand.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,13 @@ | ||
package net.superricky.tpaplusplus.command.commands | ||
|
||
import net.minecraft.server.command.CommandManager.literal | ||
import net.superricky.tpaplusplus.command.BuildableCommand | ||
import net.superricky.tpaplusplus.config.Config | ||
import net.superricky.tpaplusplus.config.command.CommandNameSpec | ||
import net.superricky.tpaplusplus.utility.LiteralNode | ||
|
||
object UnblockCommand : BuildableCommand { | ||
override fun build(): LiteralNode = | ||
literal(Config.getConfig()[CommandNameSpec.tpaunblockCommand]) | ||
.build() | ||
} |
79 changes: 79 additions & 0 deletions
79
src/main/kotlin/net/superricky/tpaplusplus/command/subcommands/RootCommand.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,79 @@ | ||
package net.superricky.tpaplusplus.command.subcommands | ||
|
||
import net.minecraft.server.command.CommandManager.literal | ||
import net.minecraft.text.ClickEvent | ||
import net.minecraft.text.Text | ||
import net.superricky.tpaplusplus.GlobalConst | ||
import net.superricky.tpaplusplus.TpaPlusPlus | ||
import net.superricky.tpaplusplus.command.BuildableCommand | ||
import net.superricky.tpaplusplus.utility.* | ||
|
||
object RootCommand : BuildableCommand { | ||
override fun build(): LiteralNode = | ||
literal("tpaplusplus") | ||
.executes { showMetaData(it) } | ||
.build() | ||
|
||
@Suppress("LongMethod") | ||
private fun showMetaData(context: Context): Int { | ||
val source = context.source | ||
source.sendFeedback( | ||
{ | ||
Text.translatable( | ||
"system.version", | ||
TpaPlusPlus.version.friendlyString.literal() | ||
.setStyle(TextColorPallet.secondaryVariant) | ||
).setStyle(TextColorPallet.primaryVariant) | ||
}, | ||
false | ||
) | ||
source.sendFeedback( | ||
{ | ||
Text.translatable( | ||
"system.github", | ||
"system.github.view".translate() | ||
.setStyle(TextColorPallet.secondaryVariant) | ||
.styled { | ||
it.withClickEvent( | ||
ClickEvent(ClickEvent.Action.OPEN_URL, GlobalConst.GITHUB_URL) | ||
) | ||
} | ||
).setStyle(TextColorPallet.primaryVariant) | ||
}, | ||
false | ||
) | ||
source.sendFeedback( | ||
{ | ||
Text.translatable( | ||
"system.modrinth", | ||
"system.modrinth.view".translate() | ||
.setStyle(TextColorPallet.secondaryVariant) | ||
.styled { | ||
it.withClickEvent( | ||
ClickEvent(ClickEvent.Action.OPEN_URL, GlobalConst.MODRINTH_URL) | ||
) | ||
} | ||
) | ||
.setStyle(TextColorPallet.primaryVariant) | ||
}, | ||
false | ||
) | ||
source.sendFeedback( | ||
{ | ||
Text.translatable( | ||
"system.courseforge", | ||
"system.courseforge.view".translate() | ||
.setStyle(TextColorPallet.secondaryVariant) | ||
.styled { | ||
it.withClickEvent( | ||
ClickEvent(ClickEvent.Action.OPEN_URL, GlobalConst.COURSE_FORGE_URL) | ||
) | ||
} | ||
) | ||
.setStyle(TextColorPallet.primaryVariant) | ||
}, | ||
false | ||
) | ||
return 1 | ||
} | ||
} |
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
10 changes: 10 additions & 0 deletions
10
src/main/kotlin/net/superricky/tpaplusplus/utility/Aliases.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,10 @@ | ||
package net.superricky.tpaplusplus.utility | ||
|
||
import com.mojang.brigadier.CommandDispatcher | ||
import com.mojang.brigadier.context.CommandContext | ||
import com.mojang.brigadier.tree.LiteralCommandNode | ||
import net.minecraft.server.command.ServerCommandSource | ||
|
||
typealias Dispatcher = CommandDispatcher<ServerCommandSource> | ||
typealias LiteralNode = LiteralCommandNode<ServerCommandSource> | ||
typealias Context = CommandContext<ServerCommandSource> |
Oops, something went wrong.