-
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 #21 from Matt-MX/dev
merge dev
- Loading branch information
Showing
85 changed files
with
2,214 additions
and
574 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
51 changes: 5 additions & 46 deletions
51
api/src/main/kotlin/com/mattmx/ktgui/commands/DummyCommandExecutor.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,71 +1,30 @@ | ||
package com.mattmx.ktgui.commands | ||
|
||
import com.mattmx.ktgui.scheduling.not | ||
import com.mattmx.ktgui.utils.not | ||
import org.bukkit.command.Command | ||
import org.bukkit.command.CommandExecutor | ||
import org.bukkit.command.CommandSender | ||
import org.bukkit.command.TabCompleter | ||
import org.bukkit.entity.Player | ||
|
||
class DummyCommandExecutor( | ||
val cmd: SimpleCommandBuilder | ||
) : CommandExecutor, TabCompleter { | ||
// private val cooldowns = hashMapOf<String, Date>() | ||
cmd: SimpleCommandBuilder | ||
) : DummyCommand(cmd), CommandExecutor, TabCompleter { | ||
|
||
override fun onCommand( | ||
sender: CommandSender, | ||
command: Command, | ||
commandLabel: String, | ||
args: Array<out String> | ||
): Boolean { | ||
val current = if (args.isEmpty()) "" | ||
else args[if (args.size - 1 > 0) args.size - 1 else 0] | ||
|
||
cmd.getCommand(args.toMutableList())?.also { | ||
if (sender !is Player && it.playerOnly) { | ||
sender.sendMessage(!"&cPlayer only command.") | ||
return false | ||
} | ||
if (it.hasPermission(sender)) { | ||
// Check for cooldown restrictions | ||
// if (cooldowns.containsKey(sender.name) && cooldowns[sender.name]!!.after(Date())) { | ||
// it.cooldownCallback(CommandInvocation(sender, args.toList(), current, commandLabel, cooldowns[sender.name])) | ||
// return@also | ||
// } | ||
|
||
it.executeFor(sender, args.toList(), current, commandLabel) | ||
|
||
// if (it.cooldown != null) { | ||
// val now = Date().time | ||
// val cooldownExpire = now + it.cooldown!!.toMillis() | ||
// | ||
// cooldowns[sender.name] = Date(cooldownExpire) | ||
// } | ||
} else { | ||
cmd.noPermissions?.let { it1 -> it1(CommandInvocation(sender, args.toList(), current, commandLabel)) } | ||
sender.sendMessage(!"&cYou do not have permissions to execute this command.") | ||
} | ||
} ?: run { | ||
cmd.unknown(sender, args.toList(), current, commandLabel) | ||
} | ||
return false | ||
return execute(sender, commandLabel, args) | ||
} | ||
|
||
override fun onTabComplete( | ||
sender: CommandSender, | ||
command: Command, | ||
alias: String, | ||
args: Array<out String> | ||
): MutableList<String>? { | ||
val current = if (args.isEmpty()) "" | ||
else args[if (args.size - 1 > 0) args.size - 1 else 0] | ||
var argss = args.toMutableList() | ||
argss = if (argss.size - 1 < 0) mutableListOf("") else argss.subList(0, argss.size - 1) | ||
cmd.getCommand(argss)?.let { | ||
return it.getSuggestions(CommandInvocation(sender, args.toList(), current, alias)).toMutableList() | ||
} | ||
return mutableListOf() | ||
): MutableList<String> { | ||
return tabComplete(sender, alias, args) | ||
} | ||
|
||
} |
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
2 changes: 1 addition & 1 deletion
2
...mx/ktgui/commands/declarative/Argument.kt → ...m/mattmx/ktgui/commands/alpha/Argument.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,4 +1,4 @@ | ||
package com.mattmx.ktgui.commands.declarative | ||
package com.mattmx.ktgui.commands.alpha | ||
|
||
/** | ||
* Argument class | ||
|
2 changes: 1 addition & 1 deletion
2
...tgui/commands/declarative/ArgumentType.kt → ...ttmx/ktgui/commands/alpha/ArgumentType.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
2 changes: 1 addition & 1 deletion
2
...ui/commands/declarative/CommandContext.kt → ...mx/ktgui/commands/alpha/CommandContext.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
3 changes: 3 additions & 0 deletions
3
api/src/main/kotlin/com/mattmx/ktgui/commands/alpha/CommandSender.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,3 @@ | ||
package com.mattmx.ktgui.commands.alpha | ||
|
||
class CommandSender |
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
2 changes: 1 addition & 1 deletion
2
...attmx/ktgui/commands/declarative/tests.kt → .../com/mattmx/ktgui/commands/alpha/tests.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
Oops, something went wrong.