Placed my last message in the wrong place, sorry! Anyway, I was just wondering what code you would have to write to disallow commands, such as ban, kick etc.. I've gotten this far @EventHandler public void PlayerCommand(PlayerCommandPreprocessEvent event) { Player p = event.getPlayer(); event.setCancelled(true);
lug Use the PlayerCommandPreprocessEvent#getMessage() method to get the command and compare that to the commands you want to disallow.
Please could you send me all the code, for an example of /ban? I can't seem to do it, thanks for the response
We aren't going to spoonfeed code. And why even code? Just revoke the permission from the players that you don't want using it. EDIT: Googlelover1234 RIP commands that start with "/ban" but doesn't equal /ban.
lug No, sorry. If you can't follow the crystal clear instructions then spoonfeeding you would only cause harm. The getMessage() method returns a String. You can then compare this String to another String with String#equals(anotherString). In this case, anotherString would be the command you want to block.
teej107 Well, ban commands usually take arguments, what if the message isn't just "/ban", but perhaps "/ban Hacker Hacking"
Googlelover1234 What if I made a command like: /banner, /banana, /ban I couldn't think of anything else but here: http://www.scrabblefinder.com/starts-with/ban/ EDIT: Ninja'D by Assist. but that's the idea. Actually not really.
teej107 Alright, but let's think about this. If we use the "equals" method, you would say "e.getMessage().equals("/ban")" and block that. That's all fine and dandy, /ban would be blocked. But would it work if someone typed "/ban someone"? EDIT: I see what Assist said. That would work then
lug This right here, gentlemen, is exactly why you should learn at least the very basics of Java before attempting to create plugins. It doesn't take too long to go through the "official" Java tutorial basics.
Could you please give me the code so I can see at least what is down, and seen how you have done it? Please?
Code:java String player = "lug";if (!player.getName().equals("n00b") {player.getPlayer().sendMessage("You are eligible for spoonfeeding!");}else {player.getPlayer().kickPlayer("We do not spoonfeed noobs");}
SleepyDog Since when has String had a getName() and getPlayer() methods? And don't you think you're being a bit harsh?
Spoonfeeding gets you nowhere. To answer your question, NO! Learn Java or request for someone who does know Java to make the plugin.