Advertisement
Guest User

bunggecord part of eventbug

a guest
May 13th, 2013
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. package net.alpenblock.bungee.eventbug;
  2.  
  3. import net.md_5.bungee.BungeeCord;
  4. import net.md_5.bungee.api.connection.ProxiedPlayer;
  5. import net.md_5.bungee.api.event.PermissionCheckEvent;
  6. import net.md_5.bungee.api.event.PluginMessageEvent;
  7. import net.md_5.bungee.api.plugin.Listener;
  8. import net.md_5.bungee.api.plugin.Plugin;
  9.  
  10. import com.google.common.eventbus.Subscribe;
  11.  
  12. public class BugPlugin extends Plugin implements Listener
  13. {
  14. String channel;
  15.  
  16. public void onLoad()
  17. {
  18. channel="bugchannel";
  19. }
  20. public void onEnable()
  21. {
  22. BungeeCord.getInstance().registerChannel(channel);
  23. BungeeCord.getInstance().getPluginManager().registerListener(this, this);
  24. }
  25. public void onDisable()
  26. {
  27. BungeeCord.getInstance().unregisterChannel(channel);
  28. }
  29. @Subscribe
  30. public void onPluginMessage(PluginMessageEvent e)
  31. {
  32. if(!e.getTag().equalsIgnoreCase(this.channel))
  33. {
  34. return;
  35. }
  36. String msg=new String(e.getData()); //data contains "server main"
  37. ProxiedPlayer pp=(ProxiedPlayer) e.getReceiver(); //msg is send by a spigot server to bungeecord -> receiver is a player's client
  38. BungeeCord.getInstance().getPluginManager().dispatchCommand(pp, msg); //perm gets checked -> no perm although it's granted
  39. e.setCancelled(true);
  40. }
  41.  
  42. @Subscribe
  43. public void onPermissionCheck(PermissionCheckEvent e)
  44. {
  45. e.setHasPermission(true); //grant every permission to the command sender; just for this test case; this will fail
  46. }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement