diff --git a/pom.xml b/pom.xml index 0b3eb56..874a851 100644 --- a/pom.xml +++ b/pom.xml @@ -103,6 +103,10 @@ sonatype https://oss.sonatype.org/content/groups/public/ + + placeholderapi + https://repo.extendedclip.com/content/repositories/placeholderapi/ + @@ -123,5 +127,11 @@ ${kotlin.version} test + + me.clip + placeholderapi + 2.11.1 + provided + diff --git a/src/main/java/me/fivevl/staff/Config.kt b/src/main/java/me/fivevl/staff/Config.kt new file mode 100644 index 0000000..3f33d58 --- /dev/null +++ b/src/main/java/me/fivevl/staff/Config.kt @@ -0,0 +1,7 @@ +package me.fivevl.staff + +import org.bukkit.configuration.file.FileConfiguration + +object Config { + var config: FileConfiguration? = null +} \ No newline at end of file diff --git a/src/main/java/me/fivevl/staff/Main.kt b/src/main/java/me/fivevl/staff/Main.kt index 0a62374..3ee4ed0 100644 --- a/src/main/java/me/fivevl/staff/Main.kt +++ b/src/main/java/me/fivevl/staff/Main.kt @@ -5,8 +5,10 @@ import org.bukkit.plugin.java.JavaPlugin class Main : JavaPlugin() { override fun onEnable() { - logger.info("Staff plugin enabled.") + saveDefaultConfig() + Config.config = config getCommand("staffmode")!!.setExecutor(StaffModeCommand()) + logger.info("Staff plugin enabled.") } override fun onDisable() { @@ -17,12 +19,11 @@ class Main : JavaPlugin() { /* FEATURES: DONE: - + - PlaceholderAPI support NOT DONE: - Staff mode (Invisibility/vanish, fly, items) - Freeze (Command and freeze wand in staff mode) - Open inventory (Command and wand in staff mode) with permission for being able to edit it - Knockback Stick (Extra, useful to check if the player has no kb) - - PlaceholderAPI support */ } diff --git a/src/main/java/me/fivevl/staff/Utils.kt b/src/main/java/me/fivevl/staff/Utils.kt index ee7f121..65e3334 100644 --- a/src/main/java/me/fivevl/staff/Utils.kt +++ b/src/main/java/me/fivevl/staff/Utils.kt @@ -1,7 +1,9 @@ package me.fivevl.staff +import me.clip.placeholderapi.PlaceholderAPI import net.md_5.bungee.api.ChatColor +import org.bukkit.entity.Player import java.util.regex.Pattern object Utils { @@ -17,4 +19,7 @@ object Utils { } return ChatColor.translateAlternateColorCodes('&', s2) } + fun getPlaceholders(p: Player?, s: String): String { + return PlaceholderAPI.setPlaceholders(p, s) + } } \ No newline at end of file diff --git a/src/main/java/me/fivevl/staff/commands/StaffModeCommand.kt b/src/main/java/me/fivevl/staff/commands/StaffModeCommand.kt index 4691a47..69e98fc 100644 --- a/src/main/java/me/fivevl/staff/commands/StaffModeCommand.kt +++ b/src/main/java/me/fivevl/staff/commands/StaffModeCommand.kt @@ -1,11 +1,18 @@ package me.fivevl.staff.commands +import me.fivevl.staff.Utils import org.bukkit.command.Command import org.bukkit.command.CommandExecutor import org.bukkit.command.CommandSender +import org.bukkit.entity.Player class StaffModeCommand : CommandExecutor { override fun onCommand(sender: CommandSender, command: Command, label: String, args: Array): Boolean { + if (sender !is Player) { + sender.sendMessage(Utils.hex(Utils.getPlaceholders(null, "&cYou must be a player to use this command!"))) + return true + } + val p = sender.player return true } } \ No newline at end of file diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml new file mode 100644 index 0000000..fb97945 --- /dev/null +++ b/src/main/resources/config.yml @@ -0,0 +1 @@ +must-be-player: "&cYou must be a player to use this command!" \ No newline at end of file