am tired now bye gl

This commit is contained in:
5vl 2022-04-09 01:15:15 +02:00
parent c74afd6316
commit 8bed238ca2
No known key found for this signature in database
GPG Key ID: DA8938F22548E4D5
5 changed files with 49 additions and 0 deletions

View File

@ -12,4 +12,5 @@ object Config {
put(it.toInt(), config?.getString("staffmode-hotbar.$it")!!)
}
}
val toggleVanish = config?.getString("toggle-vanish")
}

View File

@ -1,13 +1,20 @@
package me.fivevl.staff
import me.fivevl.staff.commands.StaffModeCommand
import me.fivevl.staff.listeners.JoinListener
import org.bukkit.Bukkit
import org.bukkit.plugin.java.JavaPlugin
class Main : JavaPlugin() {
override fun onEnable() {
Utils.instance = this
saveDefaultConfig()
Config.config = config
getCommand("staffmode")!!.setExecutor(StaffModeCommand())
Bukkit.getPluginManager().registerEvents(JoinListener(), this)
logger.info("Staff plugin enabled.")
}
@ -20,6 +27,7 @@ class Main : JavaPlugin() {
FEATURES:
DONE:
- PlaceholderAPI support
- Config
NOT DONE:
- Staff mode (Invisibility/vanish, fly, items)
- Freeze (Command and freeze wand in staff mode)

View File

@ -2,6 +2,7 @@ package me.fivevl.staff
import me.clip.placeholderapi.PlaceholderAPI
import net.md_5.bungee.api.ChatColor
import org.bukkit.Bukkit
import org.bukkit.Material
import org.bukkit.entity.Player
import org.bukkit.inventory.ItemStack
@ -9,7 +10,9 @@ import org.bukkit.inventory.PlayerInventory
import java.util.regex.Pattern
object Utils {
var instance: Main? = null
private val inStaffmode = HashMap<Player, PlayerInventory>()
val inVanish = ArrayList<Player>()
@Suppress("deprecation")
fun hex(s: String): String {
var s2 = s
@ -47,4 +50,20 @@ object Utils {
}
p.sendMessage(hex(getPlaceholders(p, Config.toggleStaffmode!!)))
}
fun toggleVanish(p: Player) {
if (inVanish.contains(p)) {
for (ps in Bukkit.getOnlinePlayers()) {
ps.showPlayer(instance!!, p)
}
inVanish.remove(p)
p.sendMessage(hex(getPlaceholders(p, Config.toggleVanish!!)))
} else {
for (ps in Bukkit.getOnlinePlayers()) {
ps.hidePlayer(instance!!, p)
}
inVanish.add(p)
p.sendMessage(hex(getPlaceholders(p, Config.toggleVanish!!)))
}
}
}

View File

@ -0,0 +1,16 @@
package me.fivevl.staff.listeners
import me.fivevl.staff.Utils
import org.bukkit.event.EventHandler
import org.bukkit.event.Listener
import org.bukkit.event.player.PlayerJoinEvent
class JoinListener : Listener {
@EventHandler
fun onJoin(e: PlayerJoinEvent) {
val p = e.player
for (ps in Utils.inVanish) {
p.hidePlayer(Utils.instance!!, ps)
}
}
}

View File

@ -1,6 +1,11 @@
# In this section of the config you can change all the messages in the plugin.
must-be-player: "&cYou must be a player to use this command!" # Message shown when a player tries to use a command that requires them to be a player
no-permission: "&cYou don't have permission to use this command!" # Message shown when a player tries to use a command that they don't have permission to use
toggle-staffmode: "&aToggled staffmode!" # Message shown when a player toggles staffmode
toggle-vanish: "&aToggled vanish!" # Message shown when a player toggles vanish
toggle-fly: "&aToggled fly!" # Message shown when a player toggles fly
# In this section of the config you can change the items given to you in staffmode.
staffmode-hotbar: # List of items to give the player when they toggle staffmode, available items: "AIR", "DISABLE_STAFFMODE", "FREEZE_WAND", "INVENTORY_WAND", "KB_STICK", "VANISH_ITEM"
1: "AIR"
2: "AIR"