Placeholderapi support, making config now

This commit is contained in:
5vl 2022-04-07 10:44:26 +02:00
parent a2aa6e3aa4
commit a9d81942f6
No known key found for this signature in database
GPG Key ID: DA8938F22548E4D5
6 changed files with 34 additions and 3 deletions

10
pom.xml
View File

@ -103,6 +103,10 @@
<id>sonatype</id> <id>sonatype</id>
<url>https://oss.sonatype.org/content/groups/public/</url> <url>https://oss.sonatype.org/content/groups/public/</url>
</repository> </repository>
<repository>
<id>placeholderapi</id>
<url>https://repo.extendedclip.com/content/repositories/placeholderapi/</url>
</repository>
</repositories> </repositories>
<dependencies> <dependencies>
@ -123,5 +127,11 @@
<version>${kotlin.version}</version> <version>${kotlin.version}</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>me.clip</groupId>
<artifactId>placeholderapi</artifactId>
<version>2.11.1</version>
<scope>provided</scope>
</dependency>
</dependencies> </dependencies>
</project> </project>

View File

@ -0,0 +1,7 @@
package me.fivevl.staff
import org.bukkit.configuration.file.FileConfiguration
object Config {
var config: FileConfiguration? = null
}

View File

@ -5,8 +5,10 @@ import org.bukkit.plugin.java.JavaPlugin
class Main : JavaPlugin() { class Main : JavaPlugin() {
override fun onEnable() { override fun onEnable() {
logger.info("Staff plugin enabled.") saveDefaultConfig()
Config.config = config
getCommand("staffmode")!!.setExecutor(StaffModeCommand()) getCommand("staffmode")!!.setExecutor(StaffModeCommand())
logger.info("Staff plugin enabled.")
} }
override fun onDisable() { override fun onDisable() {
@ -17,12 +19,11 @@ class Main : JavaPlugin() {
/* /*
FEATURES: FEATURES:
DONE: DONE:
- PlaceholderAPI support
NOT DONE: NOT DONE:
- Staff mode (Invisibility/vanish, fly, items) - Staff mode (Invisibility/vanish, fly, items)
- Freeze (Command and freeze wand in staff mode) - Freeze (Command and freeze wand in staff mode)
- Open inventory (Command and wand in staff mode) with permission for being able to edit it - 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) - Knockback Stick (Extra, useful to check if the player has no kb)
- PlaceholderAPI support
*/ */
} }

View File

@ -1,7 +1,9 @@
package me.fivevl.staff package me.fivevl.staff
import me.clip.placeholderapi.PlaceholderAPI
import net.md_5.bungee.api.ChatColor import net.md_5.bungee.api.ChatColor
import org.bukkit.entity.Player
import java.util.regex.Pattern import java.util.regex.Pattern
object Utils { object Utils {
@ -17,4 +19,7 @@ object Utils {
} }
return ChatColor.translateAlternateColorCodes('&', s2) return ChatColor.translateAlternateColorCodes('&', s2)
} }
fun getPlaceholders(p: Player?, s: String): String {
return PlaceholderAPI.setPlaceholders(p, s)
}
} }

View File

@ -1,11 +1,18 @@
package me.fivevl.staff.commands package me.fivevl.staff.commands
import me.fivevl.staff.Utils
import org.bukkit.command.Command import org.bukkit.command.Command
import org.bukkit.command.CommandExecutor import org.bukkit.command.CommandExecutor
import org.bukkit.command.CommandSender import org.bukkit.command.CommandSender
import org.bukkit.entity.Player
class StaffModeCommand : CommandExecutor { class StaffModeCommand : CommandExecutor {
override fun onCommand(sender: CommandSender, command: Command, label: String, args: Array<out String>): Boolean { override fun onCommand(sender: CommandSender, command: Command, label: String, args: Array<out String>): 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 return true
} }
} }

View File

@ -0,0 +1 @@
must-be-player: "&cYou must be a player to use this command!"