Vinetos

BungeeCord | #7 - Messaging Chanel (Bungee-Bukkit) #2 - PluginListener.java

Jan 17th, 2016
883
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.12 KB | None | 0 0
  1. import com.google.common.io.ByteArrayDataInput;
  2. import com.google.common.io.ByteArrayDataOutput;
  3. import com.google.common.io.ByteStreams;
  4. import net.md_5.bungee.BungeeCord;
  5. import net.md_5.bungee.api.connection.ProxiedPlayer;
  6. import net.md_5.bungee.api.event.PluginMessageEvent;
  7. import net.md_5.bungee.api.plugin.Listener;
  8. import net.md_5.bungee.event.EventHandler;
  9.  
  10. /**
  11.  * Created by Vinetos on 17/01/2016.
  12.  */
  13. public class PluginListener implements Listener {
  14.  
  15.     @EventHandler
  16.     public void onPluginReceivedEvent(PluginMessageEvent e){
  17.         if(!e.getTag().equalsIgnoreCase("VChannel"))return;
  18.         ByteArrayDataInput in = ByteStreams.newDataInput(e.getData());
  19.         String subChannel = in.readUTF();
  20.         ProxiedPlayer p = BungeeCord.getInstance().getPlayer(e.getReceiver().toString());
  21.        
  22.         if(subChannel.equalsIgnoreCase("Message")){
  23.             ByteArrayDataOutput out = ByteStreams.newDataOutput();
  24.             out.writeUTF("Message");
  25.             out.writeUTF("§aUn coucou de §cBungeecord §a!");
  26.             p.getServer().getInfo().sendData("VChannel", out.toByteArray());
  27.            
  28.         }
  29.     }
  30.  
  31. }
Advertisement
Add Comment
Please, Sign In to add comment