gamingod

World Chat - Main Class

Feb 16th, 2014
1,706
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package me.gamingod;
  2.  
  3. import java.util.Set;
  4.  
  5. import org.bukkit.Bukkit;
  6. import org.bukkit.entity.Player;
  7. import org.bukkit.event.EventHandler;
  8. import org.bukkit.event.Listener;
  9. import org.bukkit.event.player.AsyncPlayerChatEvent;
  10. import org.bukkit.plugin.java.JavaPlugin;
  11.  
  12. public class Main extends JavaPlugin implements Listener {
  13.    
  14.     @Override
  15.     public void onEnable() {
  16.         Bukkit.getServer().getPluginManager().registerEvents(this, this);
  17.     }
  18.    
  19.     @EventHandler
  20.     public void onChat(AsyncPlayerChatEvent e) {
  21.         Player sender = e.getPlayer();
  22.         Set<Player> r = e.getRecipients();
  23.         for (Player pls : Bukkit.getServer().getOnlinePlayers()) {
  24.                 if (!pls.getWorld().getName().equals(sender.getWorld().getName())) {
  25.                         r.remove(pls);
  26.                 }
  27.         }
  28. }
  29.    
  30. }
RAW Paste Data