-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #129 from SpigotBasics/executor-per-path
Allow CommandContextExecutors per ArgumentPath!
- Loading branch information
Showing
20 changed files
with
149 additions
and
25 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
9 changes: 9 additions & 0 deletions
9
core/src/main/kotlin/com/github/spigotbasics/core/command/parsed/arguments/IntArg.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 |
---|---|---|
@@ -1,10 +1,19 @@ | ||
package com.github.spigotbasics.core.command.parsed.arguments | ||
|
||
import com.github.spigotbasics.core.Basics | ||
import com.github.spigotbasics.core.messages.Message | ||
import org.bukkit.command.CommandSender | ||
|
||
open class IntArg(name: String) : CommandArgument<Int>(name) { | ||
override fun parse( | ||
sender: CommandSender, | ||
value: String, | ||
): Int? = value.toIntOrNull() | ||
|
||
override fun errorMessage( | ||
sender: CommandSender, | ||
value: String, | ||
): Message { | ||
return Basics.messages.invalidValueForArgumentMustBeInteger(name, value) | ||
} | ||
} |
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
8 changes: 6 additions & 2 deletions
8
core/src/main/kotlin/com/github/spigotbasics/core/permission/CorePermissions.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
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
14 changes: 14 additions & 0 deletions
14
.../main/kotlin/com/github/spigotbasics/modules/basicscore/commands/DebugFallbackExecutor.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,14 @@ | ||
package com.github.spigotbasics.modules.basicscore.commands | ||
|
||
import com.github.spigotbasics.core.command.parsed.CommandContextExecutor | ||
import com.github.spigotbasics.core.command.parsed.context.MapContext | ||
import org.bukkit.command.CommandSender | ||
|
||
class DebugFallbackExecutor : CommandContextExecutor<MapContext> { | ||
override fun execute( | ||
sender: CommandSender, | ||
context: MapContext, | ||
) { | ||
throw IllegalStateException("This command should never be executed") | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
...ain/kotlin/com/github/spigotbasics/modules/basicscore/commands/PrintPermissionsCommand.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,16 @@ | ||
package com.github.spigotbasics.modules.basicscore.commands | ||
|
||
import com.github.spigotbasics.core.command.parsed.CommandContextExecutor | ||
import com.github.spigotbasics.core.command.parsed.context.MapContext | ||
import org.bukkit.command.CommandSender | ||
|
||
class PrintPermissionsCommand : CommandContextExecutor<MapContext> { | ||
override fun execute( | ||
sender: CommandSender, | ||
context: MapContext, | ||
) { | ||
for (permission in sender.server.pluginManager.permissions.filter { it.name.startsWith("basics.") }.sortedBy { it.name }) { | ||
sender.sendMessage(permission.name + " - " + permission.description + " - " + permission.default.toString()) | ||
} | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
...ain/kotlin/com/github/spigotbasics/modules/basicscore/commands/SetDebugLogLevelCommand.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,16 @@ | ||
package com.github.spigotbasics.modules.basicscore.commands | ||
|
||
import com.github.spigotbasics.core.command.parsed.CommandContextExecutor | ||
import com.github.spigotbasics.core.command.parsed.context.MapContext | ||
import com.github.spigotbasics.core.logger.BasicsLogger | ||
import org.bukkit.command.CommandSender | ||
|
||
class SetDebugLogLevelCommand : CommandContextExecutor<MapContext> { | ||
override fun execute( | ||
sender: CommandSender, | ||
context: MapContext, | ||
) { | ||
BasicsLogger.debugLogLevel = context["level"] as Int | ||
sender.sendMessage("Debug log level set to ${context["level"]}") | ||
} | ||
} |
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