Skip to content

Commit

Permalink
v2.2.1:
Browse files Browse the repository at this point in the history
- Fixed bug
  • Loading branch information
randombyte-developer committed Jun 13, 2018
1 parent e004e53 commit 73e1fa8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ if (!isJitpack) {
}

group "de.randombyte"
version "2.2.0"
version "2.2.1"

repositories {
jcenter()
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/de/randombyte/commandutils/CommandUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class CommandUtils @Inject constructor(
companion object {
const val ID = "command-utils"
const val NAME = "CommandUtils"
const val VERSION = "2.2.0"
const val VERSION = "2.2.1"
const val AUTHOR = "RandomByte"

const val PLACEHOLDER_API_ID = "placeholderapi"
Expand Down
16 changes: 12 additions & 4 deletions src/main/kotlin/de/randombyte/commandutils/utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,24 @@ fun executeCommand(
val unprefixedCommand = command.removePrefix(EXECUTE_AS_CONSOLE_PREFIX)
val executeAsConsole = command.startsWith(EXECUTE_AS_CONSOLE_PREFIX)

val processedCommand = unprefixedCommand.tryReplacePlaceholders(source = target)

// Any additional custom replacements(like the alias arguments, or the legacy '$p')
val replacedCommand = processedCommand.replace(replacements)
val replacedCommand = unprefixedCommand.replace(replacements)

// cu execute parsed
val splits = replacedCommand.split(" ")
val processedCommand = if (splits[1] == "execute" && splits[2] == "parsed") {
// This command doesn't need external placeholder processing, it is done in the command itself
replacedCommand
} else {
// No internal placeholder parsing will done, so we do it here
replacedCommand.tryReplacePlaceholders(source = target)
}

val finalCommandSource = if (executeAsConsole) Sponge.getServer().console else commandSource

Task.builder()
.execute { ->
val commandResult = finalCommandSource.executeCommand(replacedCommand)
val commandResult = finalCommandSource.executeCommand(processedCommand)
commandResultCallback(commandResult)
}
.delayTicks(1)
Expand Down

0 comments on commit 73e1fa8

Please sign in to comment.