Advertisement
Guest User

SlimeKits.Methods

a guest
May 16th, 2013
24
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 7.27 KB | None | 0 0
  1. package com.theaetherserver.kits;
  2.  
  3. import java.util.ArrayList;
  4. import org.bukkit.Bukkit;
  5. import org.bukkit.ChatColor;
  6. import org.bukkit.Location;
  7. import org.bukkit.Material;
  8. import org.bukkit.entity.Player;
  9. import org.bukkit.inventory.Inventory;
  10. import org.bukkit.inventory.InventoryHolder;
  11. import org.bukkit.inventory.ItemStack;
  12. import org.bukkit.inventory.PlayerInventory;
  13. import org.bukkit.inventory.meta.BookMeta;
  14. import org.bukkit.inventory.meta.ItemMeta;
  15. import org.bukkit.util.Vector;
  16.  
  17.  
  18. public class Methods {
  19.     @SuppressWarnings("unused")
  20.     static private Main plugin;
  21.     private static InventoryHolder player;
  22.     public static Inventory inv = Bukkit.createInventory(player, 9, ChatColor.BLUE +  "SlimeKits");
  23.     public static Inventory select = Bukkit.createInventory(player, 18, ChatColor.BLUE + "Select a Kit");
  24.  
  25.     public static void teleport(Player from, Player to){
  26.         Vector vect1 = from.getLocation().toVector();
  27.         Vector vect2 = to.getLocation().toVector();
  28.         Vector vector = vect2.subtract(vect1).normalize();
  29.         double distance = from.getLocation().distance(to.getLocation());
  30.         for(double i = 1.0D; i < distance; i += 1.0D){
  31.             vect1.add(vector);
  32.             double x = vect1.getX();
  33.             double y = vect1.getY();
  34.             double z = vect1.getZ();
  35.             from.teleport(new Location(from.getWorld(), x, y + 0.25D, z, from.getLocation().getYaw(), from.getLocation().getPitch()));
  36.             waitTicks(25L);
  37.         }
  38.     }
  39.    
  40.     public static void waitTicks(long n){
  41.         long t0 = System.currentTimeMillis();
  42.         long t1;
  43.         do
  44.             t1 = System.currentTimeMillis();
  45.         while(
  46.             t1 - t0 < n);
  47.        
  48.     }
  49.  
  50.     public static boolean isInt(String str){
  51.         try{
  52.             Integer.parseInt(str);
  53.             return true;
  54.         }catch(NumberFormatException e){
  55.             return false;
  56.         }
  57.     }
  58.  
  59.     public static boolean isDouble(String str){
  60.         try{
  61.             Double.parseDouble(str);
  62.             return true;
  63.         }catch(NumberFormatException e){
  64.             return false;
  65.         }
  66.     }
  67.    
  68.     public static void createMenu(){
  69.         ItemStack kits = new ItemStack(Material.DIAMOND_SWORD);
  70.         ItemMeta kitsMeta = kits.getItemMeta();
  71.         kitsMeta.setDisplayName(ChatColor.AQUA + "Kits");
  72.         ArrayList<String> kitsLore = new ArrayList<String>();
  73.         kitsLore.add(ChatColor.DARK_PURPLE + "Choose a kit to play!");
  74.         kitsMeta.setLore(kitsLore);
  75.         kits.setItemMeta(kitsMeta);
  76.        
  77.         ItemStack book = new ItemStack(Material.WRITTEN_BOOK);
  78.         BookMeta bookMeta = (BookMeta) book.getItemMeta();
  79.         bookMeta.setAuthor("SlimeKits");
  80.         bookMeta.setTitle(ChatColor.DARK_AQUA + "Info");
  81.         book.setItemMeta(bookMeta);
  82.        
  83.         ItemStack rules = new ItemStack(Material.WRITTEN_BOOK);
  84.         BookMeta rulesMeta = (BookMeta) rules.getItemMeta();
  85.         rulesMeta.setAuthor("SlimeKits");
  86.         rulesMeta.setTitle(ChatColor.RED + "Rules");
  87.         rules.setItemMeta(rulesMeta);
  88.        
  89.         inv.addItem(kits);
  90.         inv.addItem(book);
  91.         inv.setItem(8, rules);
  92.         Main.inst();
  93.         Main.log.info("Kits menu created");
  94.     }
  95.    
  96.     public static void createSelectMenu(){
  97.         ItemStack archer = new ItemStack(Material.BOW);
  98.         ItemMeta archerMeta = archer.getItemMeta();
  99.         archerMeta.setDisplayName(ChatColor.LIGHT_PURPLE + "Archer");
  100.         archer.setItemMeta(archerMeta);
  101.        
  102.         ItemStack tank = new ItemStack(Material.DIAMOND_SWORD);
  103.         ItemMeta tankMeta = tank.getItemMeta();
  104.         tankMeta.setDisplayName(ChatColor.AQUA + "Tank");
  105.         tank.setItemMeta(tankMeta);
  106.  
  107.         select.setItem(0, archer);
  108.         select.setItem(1, tank);
  109.         Main.inst();
  110.         Main.log.info("Select menu created");
  111.     }
  112.    
  113.     public static void openMenu(Player player){
  114.         player.openInventory(inv);
  115.     }
  116.    
  117.     public static void openSelectMenu(Player player){
  118.         player.openInventory(select);
  119.     }
  120.    
  121.     public static void giveInfo(Player player){
  122.         PlayerInventory inventory = player.getInventory();
  123.         // INFO
  124.         ItemStack book = new ItemStack(Material.WRITTEN_BOOK);
  125.         BookMeta bookMeta = (BookMeta) book.getItemMeta();
  126.         bookMeta.setAuthor("SlimeKits");
  127.         bookMeta.setTitle(ChatColor.DARK_AQUA + "Info");
  128.         ArrayList<String> bookPage = new ArrayList<String>(); // Pages
  129.         bookPage.add("Kits Info:\n" + ChatColor.DARK_GREEN + "Contents\n" + ChatColor.GREEN + "------------\n" + ChatColor.LIGHT_PURPLE + "Archer - 1\n" + ChatColor.AQUA + "Tank - 2\n" + ChatColor.DARK_RED + "Knight - 3\n" + ChatColor.GOLD + "Ninja - 4\n" + ChatColor.DARK_GREEN + "Spider - 5\n" + ChatColor.DARK_GRAY + "Trickster - 6\n" + ChatColor.GOLD + "Blaze - 7\n" + ChatColor.DARK_AQUA + "Turtle - 8\n" + ChatColor.DARK_PURPLE + "Dwarf - 9\n" + ChatColor.RED + "Fisherman - 10"); // Page 1
  130.         bookPage.add(ChatColor.LIGHT_PURPLE + "Archer\n------------\nStart with a bow enchanted with:\nUnreaking 10\nInfinity 1\nSharpness 1\nPower 2\n" + "\nYou also have Chainmail armour.");
  131.         bookPage.add(ChatColor.AQUA + "Tank\n------------\nStart with a diamond sword enchanted with Sharpness 1 and Iron Armour.\nYou also get Resistance 1.");
  132.         bookPage.add(ChatColor.DARK_RED + "Knight\n------------\nStart with an iron sword enchanted with Unbreaking 10 and diamond armour.");
  133.         bookPage.add(ChatColor.GOLD + "Ninja\n------------\nStart with a gold sword enchanted with Unbreaking 10 and Sharpness 3. You also get 8 enderpearls and gold boots enchanted with Protection 5, Unbreaking 10, and Feather Falling 10. You also get Swiftness 2.");
  134.         bookPage.add(ChatColor.DARK_GREEN + "Spider\n------------\nStart with a gold sword enchanted with Unbreaking 10 and a spider eye.\nHitting a player with your spider eye gives them poison.\nStart with a Leather cap, Chainmail chest, Gold leggings and Leather Boots.");
  135.         bookPage.add(ChatColor.DARK_GRAY + "Trickster\n------------\nStart with a gold sword enchanted with Unbreaking 10 and a redstone torch.\nHitting a player with your redstone torch makes them turn around.\nYou also have iron armour.");
  136.         bookPage.add(ChatColor.GOLD + "Blaze\n------------\nStart with an iron sword enchanted with Unbreaking 10 and a blaze rod.\nHitting a player with your blaze rod will ignite them!\nYou also have leather armour.");
  137.         bookPage.add(ChatColor.DARK_AQUA + "Turtle\n------------\nAs turtle you start with two swords. Your iron sword and a stone defender.\nShifting will give you Resistance and shifting while blocking with your defender gives you Resistance 4!");
  138.         bookPage.add(ChatColor.DARK_PURPLE + "Dwarf\n------------\nStart with a Sharpness 2, Knockback 1, Iron Axe.\n Your armour is a Diamond helmet, Iron chestplate, Leather leggings and Gold boots.");
  139.         bookPage.add(ChatColor.RED + "Fisherman\n------------\nYou start with a Knockback 1 diamond sword and a fishing rod.\nUse your fishing rod to reel opponents in!\nYour armour is leather.");
  140.         bookMeta.setPages(bookPage);
  141.         book.setItemMeta(bookMeta);
  142.        
  143.         inventory.addItem(book);       
  144.     }
  145.    
  146.     public static void giveRules(Player player){
  147.         PlayerInventory inventory = player.getInventory();
  148.         // RULES
  149.         ItemStack rules = new ItemStack(Material.WRITTEN_BOOK);
  150.         BookMeta rulesMeta = (BookMeta) rules.getItemMeta();
  151.         rulesMeta.setAuthor("SlimeKits");
  152.         rulesMeta.setTitle(ChatColor.RED + "Rules");
  153.         ArrayList<String> rulesPage = new ArrayList<String>();
  154.         rulesPage.add(ChatColor.LIGHT_PURPLE + "Kits Rules:\n1. No hacks.\n2. No bug abuse. If you are caught, a ban may be dealt.\n3. Flying is allowed. However it would be smart to remember that if you get hit or deal a hit, you will lose flight.");
  155.         rulesMeta.setPages(rulesPage);
  156.         rules.setItemMeta(rulesMeta);
  157.        
  158.         inventory.addItem(rules);
  159.     }
  160. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement