Why wont this work? Getting "Unknown console command" Code:java public void onPlayerCommandPreprocess(PlayerChatEvent event) { if (event.getMessage().toLowerCase().startsWith("/m") || event.getMessage().toLowerCase().startsWith("/msg")) { event.getPlayer().sendMessage("WHY WONT THIS WORK?????"); }}
First of all, look at the parameter of your method. Should seem weird ... And you don't make commands with that event, use onCommand http://wiki.bukkit.org/HUGE_Plugin_Tutorial#Commands
@Bone008 , @Relick nvm that, onto the problem! I'm trying to make a PM plugin (will probably never be released...) The PM part is working fine, but i want people to be able to spy on the conversation with "/mlog <playername>" That part wont work... Code here: https://github.com/stelar7/messenger
Now if you would bother to tell us what exactly does not work it would help us to help you ... Don't always make us help you help us help you
That's more like it. Now look at your main class. Especially those two lines: Code: public static HashMap<Player, List<Player>> players = new HashMap<Player, List<Player>>(); public static List<Player> spies; While you can successfully access the "players" member, trying to do something with "spies" fails. Not what is the huge difference between those two lines? (apart from the fact that one is a Map and the other a List, that's not what I mean here) Hint: It has something to with the "=" char ...
@Bone008 Wow, that was a fail :/ Ok, now there's no errors. But it still wont work... Mind giving me a few hints?
Code:java Main.spies.add(watched);Main.players .put(player, Main.spies);Main.spies.clear(); That is what you use to define who spies who. However, not only do you not use a reverse method of this to post the messages, it isn't a very good way of going about it. Your HashMap should be <Player, Player> with the first Player being who is being spied, and the second being who the spyer is. E.g. I type /spy bob, it records into the hashmap 'bob', 'zantom07' Then when you check, here: Code:java Player spy = (Player) Main.players.get(msender);if (Main.players.containsKey(sender) && spy.isOnline() && spy != null) { // send to spyer} It should be: Code:java if (Main.players.containsKey(msender) { Player spy = (Player) Main.players.get(msender); if (spy.isOnline() && spy != null) { //send to spyer }} Now it checks to see if 'bob' is the sender, if he is, and 'zantom07' is online, then send the message to 'zantom07' There is also an even better way of doing it, so that multiple people can spy on bob, but I'll only tell you if you really can't figure it out. EDIT by Moderator: merged posts, please use the edit button instead of double posting.