initial commit
pluginhider v1
This commit is contained in:
76
src/main/kotlin/org/plughide/plughide/Plughide.kt
Normal file
76
src/main/kotlin/org/plughide/plughide/Plughide.kt
Normal file
@@ -0,0 +1,76 @@
|
||||
package org.plughide.plughide
|
||||
|
||||
import org.bukkit.Bukkit
|
||||
import org.bukkit.event.EventHandler
|
||||
import org.bukkit.event.EventPriority
|
||||
import org.bukkit.event.Listener
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent
|
||||
import org.bukkit.event.server.TabCompleteEvent
|
||||
import org.bukkit.plugin.java.JavaPlugin
|
||||
|
||||
class PlugHide : JavaPlugin(), Listener {
|
||||
|
||||
private val blockedCommands = listOf(
|
||||
"/pl", "/plugins", "/plugin", "/bukkit:pl", "/bukkit:plugins", "/bukkit:plugin",
|
||||
"/minecraft:pl", "/minecraft:plugins", "/minecraft:plugin",
|
||||
"/ver", "/version", "/bukkit:ver", "/bukkit:version",
|
||||
"/minecraft:ver", "/minecraft:version",
|
||||
"/about", "/bukkit:about", "/minecraft:about",
|
||||
"/help", "/bukkit:help", "/minecraft:help",
|
||||
"/?", "/bukkit:?", "/minecraft:?"
|
||||
)
|
||||
|
||||
override fun onEnable() {
|
||||
logger.info("PlugHide has been enabled!")
|
||||
server.pluginManager.registerEvents(this, this)
|
||||
}
|
||||
|
||||
override fun onDisable() {
|
||||
logger.info("PlugHide has been disabled!")
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
fun onPlayerCommand(event: PlayerCommandPreprocessEvent) {
|
||||
val player = event.player
|
||||
val command = event.message.split(" ")[0].lowercase()
|
||||
|
||||
// Allow OPs to use any command
|
||||
if (player.isOp) return
|
||||
|
||||
// Block restricted commands for non-OPs
|
||||
if (blockedCommands.contains(command)) {
|
||||
event.isCancelled = true
|
||||
player.sendMessage("§cUnknown command. Type \"/help\" for help.")
|
||||
logger.info("Player ${player.name} attempted to use blocked command: $command")
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
fun onTabComplete(event: TabCompleteEvent) {
|
||||
val sender = event.sender
|
||||
val buffer = event.buffer.lowercase()
|
||||
|
||||
// Don't filter tab completion for OPs
|
||||
if (sender.isOp) return
|
||||
|
||||
// Block tab completion for sensitive commands
|
||||
if (blockedCommands.any { buffer.startsWith(it) } ||
|
||||
buffer == "/" ||
|
||||
buffer.startsWith("/bukkit:") ||
|
||||
buffer.startsWith("/minecraft:")) {
|
||||
|
||||
// Filter out any plugin-related suggestions
|
||||
val filtered = event.completions.filter { completion ->
|
||||
val completionLower = completion.lowercase()
|
||||
!completionLower.contains("plugin") &&
|
||||
!completionLower.contains("version") &&
|
||||
!completionLower.contains("about") &&
|
||||
!completionLower.contains("bukkit") &&
|
||||
!completionLower.contains("spigot") &&
|
||||
!completionLower.contains("paper")
|
||||
}
|
||||
|
||||
event.completions = filtered
|
||||
}
|
||||
}
|
||||
}
|
||||
6
src/main/resources/plugin.yml
Normal file
6
src/main/resources/plugin.yml
Normal file
@@ -0,0 +1,6 @@
|
||||
name: PlugHide
|
||||
version: 1.0-SNAPSHOT
|
||||
main: org.plughide.plughide.PlugHide
|
||||
api-version: 1.21
|
||||
description: Hides plugin information and commands from non-OP players
|
||||
author: suckmyballs (rattatwinko)
|
||||
Reference in New Issue
Block a user