Skip to content
This repository has been archived by the owner on Jan 28, 2020. It is now read-only.

Made permission and command usage messages configurable through a setter #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.qrakn</groupId>
<artifactId>honcho</artifactId>
<version>1.2-SNAPSHOT</version>
<version>1.3-SNAPSHOT</version>

<properties>
<kotlin.version>1.3.11</kotlin.version>
Expand Down Expand Up @@ -39,6 +39,18 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

Expand Down
15 changes: 15 additions & 0 deletions src/main/kotlin/com/qrakn/honcho/Honcho.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,20 @@ package com.qrakn.honcho
import com.qrakn.honcho.command.adapter.CommandTypeAdapter
import com.qrakn.honcho.command.adapter.impl.PlayerTypeAdapter
import com.qrakn.honcho.command.adapter.impl.StringTypeAdapter
import org.bukkit.ChatColor
import org.bukkit.entity.Player
import org.bukkit.plugin.java.JavaPlugin
import org.omg.CORBA.NO_PERMISSION

class Honcho(val plugin: JavaPlugin) {

private val executor: HonchoExecutor = HonchoExecutor(this)

companion object {
var noPermission: String = "${ChatColor.RED}Insufficient permission."
var commandUsage: String = "${ChatColor.RED}Usage: {usage}"
}

init {
registerTypeAdapter(String::class.java, StringTypeAdapter())
registerTypeAdapter(Player::class.java, PlayerTypeAdapter())
Expand All @@ -33,4 +40,12 @@ class Honcho(val plugin: JavaPlugin) {
executor.adapters.putIfAbsent(clazz, adapter)
}

fun setPermissionMessage(value: String){
noPermission = value
}

fun setUsageMessage(value: String){
commandUsage = value
}

}
4 changes: 2 additions & 2 deletions src/main/kotlin/com/qrakn/honcho/HonchoExecutor.kt
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ internal class HonchoExecutor(private val honcho: Honcho) : CommandExecutor {
val instance = binding.command

if (meta.permission.isNotEmpty() && !sender.hasPermission(meta.permission)) {
sender.sendMessage("Nope.") // TODO send configurable no permission message (make command specific or impl specific?)
sender.sendMessage(Honcho.noPermission)
return true
}

Expand Down Expand Up @@ -120,7 +120,7 @@ internal class HonchoExecutor(private val honcho: Honcho) : CommandExecutor {
}
}

sender.sendMessage("${ChatColor.RED}Usage: ${command.usage}") // todo: make configurable
sender.sendMessage(Honcho.commandUsage.replace("{usage}", command.usage))
}
}

Expand Down