Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package net.alpenblock.bungee.eventbug;
- import net.md_5.bungee.BungeeCord;
- import net.md_5.bungee.api.connection.ProxiedPlayer;
- import net.md_5.bungee.api.event.PermissionCheckEvent;
- import net.md_5.bungee.api.event.PluginMessageEvent;
- import net.md_5.bungee.api.plugin.Listener;
- import net.md_5.bungee.api.plugin.Plugin;
- import com.google.common.eventbus.Subscribe;
- public class BugPlugin extends Plugin implements Listener
- {
- String channel;
- public void onLoad()
- {
- channel="bugchannel";
- }
- public void onEnable()
- {
- BungeeCord.getInstance().registerChannel(channel);
- BungeeCord.getInstance().getPluginManager().registerListener(this, this);
- }
- public void onDisable()
- {
- BungeeCord.getInstance().unregisterChannel(channel);
- }
- @Subscribe
- public void onPluginMessage(PluginMessageEvent e)
- {
- if(!e.getTag().equalsIgnoreCase(this.channel))
- {
- return;
- }
- String msg=new String(e.getData()); //data contains "server main"
- ProxiedPlayer pp=(ProxiedPlayer) e.getReceiver(); //msg is send by a spigot server to bungeecord -> receiver is a player's client
- BungeeCord.getInstance().getPluginManager().dispatchCommand(pp, msg); //perm gets checked -> no perm although it's granted
- e.setCancelled(true);
- }
- @Subscribe
- public void onPermissionCheck(PermissionCheckEvent e)
- {
- e.setHasPermission(true); //grant every permission to the command sender; just for this test case; this will fail
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement