Advertisement
Guest User

Untitled

a guest
Aug 28th, 2015
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.83 KB | None | 0 0
  1. import java.io.ByteArrayOutputStream;
  2. import java.io.DataOutputStream;
  3. import java.io.IOException;
  4. import java.util.HashSet;
  5. import java.util.Set;
  6.  
  7. import org.bukkit.Bukkit;
  8. import org.bukkit.Color;
  9. import org.bukkit.Location;
  10. import org.bukkit.Material;
  11. import org.bukkit.Sound;
  12. import org.bukkit.World;
  13. import org.bukkit.entity.Player;
  14. import org.bukkit.inventory.ItemStack;
  15. import org.bukkit.inventory.meta.LeatherArmorMeta;
  16.  
  17. public class Functions {
  18.  
  19.     /* ===== BungeeCord ===== */
  20.     public static void goToHub(Player p){
  21.         Bukkit.getMessenger().registerOutgoingPluginChannel(Main.plugin, "BungeeCord");
  22.          
  23.         ByteArrayOutputStream b = new ByteArrayOutputStream();
  24.         DataOutputStream out = new DataOutputStream(b);
  25.                          
  26.         try {
  27.             out.writeUTF("Connect");
  28.             out.writeUTF("lobby");
  29.          } catch (IOException ex) {}
  30.          
  31.         p.sendPluginMessage(Main.plugin, "BungeeCord", b.toByteArray());    
  32.     }
  33.      
  34.     /* ===== Sound ==== */
  35.     static void xpSound(){
  36.         for(Player p : Bukkit.getOnlinePlayers()){
  37.             p.playSound(p.getLocation(), Sound.ORB_PICKUP, 1, 0);
  38.         }
  39.     }
  40.  
  41.     static void noteboxSound(){
  42.         for(Player p : Bukkit.getOnlinePlayers()){
  43.             p.playSound(p.getLocation(), Sound.NOTE_PLING, 1, 0);
  44.         }
  45.     }
  46.      
  47.     static void firworksSound(){
  48.         for(Player p : Bukkit.getOnlinePlayers()){
  49.             p.playSound(p.getLocation(), Sound.FIREWORK_LAUNCH, 1, 0);
  50.         }
  51.     }
  52.      
  53.     static ItemStack colorChestplate(Color color){
  54.         ItemStack helmet = new ItemStack(Material.LEATHER_CHESTPLATE, 1);
  55.         LeatherArmorMeta meta = (LeatherArmorMeta) helmet.getItemMeta();
  56.         meta.setColor(color);
  57.         helmet.setItemMeta(meta);
  58.          
  59.         return helmet;
  60.     }
  61.      
  62.     static ItemStack colorBoots(Color color){
  63.         ItemStack helmet = new ItemStack(Material.LEATHER_BOOTS, 1);
  64.         LeatherArmorMeta meta = (LeatherArmorMeta) helmet.getItemMeta();
  65.         meta.setColor(color);
  66.         helmet.setItemMeta(meta);
  67.          
  68.         return helmet;
  69.     }
  70.      
  71.     static ItemStack colorHelmet(Color color){
  72.         ItemStack helmet = new ItemStack(Material.LEATHER_HELMET, 1);
  73.         LeatherArmorMeta meta = (LeatherArmorMeta) helmet.getItemMeta();
  74.         meta.setColor(color);
  75.         helmet.setItemMeta(meta);
  76.          
  77.         return helmet;
  78.     }
  79.      
  80.     static ItemStack colorLeggings(Color color){
  81.         ItemStack helmet = new ItemStack(Material.LEATHER_LEGGINGS, 1);
  82.         LeatherArmorMeta meta = (LeatherArmorMeta) helmet.getItemMeta();
  83.         meta.setColor(color);
  84.         helmet.setItemMeta(meta);
  85.          
  86.         return helmet;
  87.     }
  88.      
  89.     public static String locationToString(Location l){
  90.         Double x = l.getX();
  91.         Double y = l.getY();
  92.         Double z = l.getZ();
  93.         return x + "," + y + "," + z;
  94.     }
  95.      
  96.     public static Location stringToLocation(String monde, String s){
  97.         World world = Bukkit.getWorld(monde);
  98.         String[] str = s.split(",");
  99.         Double x = Double.parseDouble(str[0]);
  100.         Double y = Double.parseDouble(str[1]);
  101.         Double z = Double.parseDouble(str[2]);  
  102.  
  103.         Location loc = new Location(world, x, y, z);
  104.         if(str.length == 4) loc.setYaw(Integer.parseInt(str[3]));
  105.         return loc;
  106.     }
  107.      
  108.     public static Set<Location> cube(final Location center, final double radius) {
  109.         final Set<Location> blocks = new HashSet<Location>();
  110.         for (double x = -radius; x <= radius; x++)
  111.             for (double y = -radius; y <= radius; y++)
  112.                 for (double z = -radius; z <= radius; z++)
  113.                     blocks.add(center.clone().add(x, y, z).getBlock().getLocation());
  114.         return blocks;
  115.     }
  116.  
  117. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement