Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.ByteArrayOutputStream;
- import java.io.DataOutputStream;
- import java.io.IOException;
- import java.util.HashSet;
- import java.util.Set;
- import org.bukkit.Bukkit;
- import org.bukkit.Color;
- import org.bukkit.Location;
- import org.bukkit.Material;
- import org.bukkit.Sound;
- import org.bukkit.World;
- import org.bukkit.entity.Player;
- import org.bukkit.inventory.ItemStack;
- import org.bukkit.inventory.meta.LeatherArmorMeta;
- public class Functions {
- /* ===== BungeeCord ===== */
- public static void goToHub(Player p){
- Bukkit.getMessenger().registerOutgoingPluginChannel(Main.plugin, "BungeeCord");
- ByteArrayOutputStream b = new ByteArrayOutputStream();
- DataOutputStream out = new DataOutputStream(b);
- try {
- out.writeUTF("Connect");
- out.writeUTF("lobby");
- } catch (IOException ex) {}
- p.sendPluginMessage(Main.plugin, "BungeeCord", b.toByteArray());
- }
- /* ===== Sound ==== */
- static void xpSound(){
- for(Player p : Bukkit.getOnlinePlayers()){
- p.playSound(p.getLocation(), Sound.ORB_PICKUP, 1, 0);
- }
- }
- static void noteboxSound(){
- for(Player p : Bukkit.getOnlinePlayers()){
- p.playSound(p.getLocation(), Sound.NOTE_PLING, 1, 0);
- }
- }
- static void firworksSound(){
- for(Player p : Bukkit.getOnlinePlayers()){
- p.playSound(p.getLocation(), Sound.FIREWORK_LAUNCH, 1, 0);
- }
- }
- static ItemStack colorChestplate(Color color){
- ItemStack helmet = new ItemStack(Material.LEATHER_CHESTPLATE, 1);
- LeatherArmorMeta meta = (LeatherArmorMeta) helmet.getItemMeta();
- meta.setColor(color);
- helmet.setItemMeta(meta);
- return helmet;
- }
- static ItemStack colorBoots(Color color){
- ItemStack helmet = new ItemStack(Material.LEATHER_BOOTS, 1);
- LeatherArmorMeta meta = (LeatherArmorMeta) helmet.getItemMeta();
- meta.setColor(color);
- helmet.setItemMeta(meta);
- return helmet;
- }
- static ItemStack colorHelmet(Color color){
- ItemStack helmet = new ItemStack(Material.LEATHER_HELMET, 1);
- LeatherArmorMeta meta = (LeatherArmorMeta) helmet.getItemMeta();
- meta.setColor(color);
- helmet.setItemMeta(meta);
- return helmet;
- }
- static ItemStack colorLeggings(Color color){
- ItemStack helmet = new ItemStack(Material.LEATHER_LEGGINGS, 1);
- LeatherArmorMeta meta = (LeatherArmorMeta) helmet.getItemMeta();
- meta.setColor(color);
- helmet.setItemMeta(meta);
- return helmet;
- }
- public static String locationToString(Location l){
- Double x = l.getX();
- Double y = l.getY();
- Double z = l.getZ();
- return x + "," + y + "," + z;
- }
- public static Location stringToLocation(String monde, String s){
- World world = Bukkit.getWorld(monde);
- String[] str = s.split(",");
- Double x = Double.parseDouble(str[0]);
- Double y = Double.parseDouble(str[1]);
- Double z = Double.parseDouble(str[2]);
- Location loc = new Location(world, x, y, z);
- if(str.length == 4) loc.setYaw(Integer.parseInt(str[3]));
- return loc;
- }
- public static Set<Location> cube(final Location center, final double radius) {
- final Set<Location> blocks = new HashSet<Location>();
- for (double x = -radius; x <= radius; x++)
- for (double y = -radius; y <= radius; y++)
- for (double z = -radius; z <= radius; z++)
- blocks.add(center.clone().add(x, y, z).getBlock().getLocation());
- return blocks;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement