Created
January 13, 2017 01:35
-
-
Save heinrichquirit/677e8f8d3b7dba4e86d59eb4001191b1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
hidden-commands: | |
- '/bukkit:help' | |
- '/icanhasbukkit' | |
- '/?' | |
- '/bukkit:' | |
- '/plugins' | |
- '/bukkit:plugins' | |
- '/pl' | |
- '/bukkit:pl' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package io.github.heinrichquirit.commandhider; | |
import net.md_5.bungee.api.ChatColor; | |
import org.bukkit.entity.Player; | |
import org.bukkit.event.EventHandler; | |
import org.bukkit.event.Listener; | |
import org.bukkit.event.player.PlayerCommandPreprocessEvent; | |
import org.bukkit.plugin.java.JavaPlugin; | |
import java.util.List; | |
/** | |
* User: Heinrich Quirit | |
* Last Modified: 1/13/2017 | |
* Time: 12:16 PM | |
*/ | |
public class CommandHiderPlugin extends JavaPlugin implements Listener { | |
private String BYPASS = "commandhider.bypass"; | |
private List<String> hiddenCommands; | |
public void onEnable() { | |
saveDefaultConfig(); | |
hiddenCommands = getConfig().getStringList("hidden-commands"); | |
getServer().getPluginManager().registerEvents(this, this); | |
} | |
@EventHandler | |
public void onCommandProcess(PlayerCommandPreprocessEvent e) { | |
Player p = e.getPlayer(); | |
String processedCmd = e.getMessage(); | |
if (hiddenCommands.contains(processedCmd)) { | |
if (!p.hasPermission(BYPASS)) { | |
p.sendMessage(ChatColor.RED + "You can't use this command!"); | |
e.setCancelled(true); | |
} | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CommandHider | |
main: io.github.heinrichquirit.commandhider.CommandHiderPlugin | |
version: 1.0 | |
author: BigBadHenz |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment