Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.theaetherserver.kits;
- import java.util.ArrayList;
- import org.bukkit.Bukkit;
- import org.bukkit.ChatColor;
- import org.bukkit.Location;
- import org.bukkit.Material;
- import org.bukkit.entity.Player;
- import org.bukkit.inventory.Inventory;
- import org.bukkit.inventory.InventoryHolder;
- import org.bukkit.inventory.ItemStack;
- import org.bukkit.inventory.PlayerInventory;
- import org.bukkit.inventory.meta.BookMeta;
- import org.bukkit.inventory.meta.ItemMeta;
- import org.bukkit.util.Vector;
- public class Methods {
- @SuppressWarnings("unused")
- static private Main plugin;
- private static InventoryHolder player;
- public static Inventory inv = Bukkit.createInventory(player, 9, ChatColor.BLUE + "SlimeKits");
- public static Inventory select = Bukkit.createInventory(player, 18, ChatColor.BLUE + "Select a Kit");
- public static void teleport(Player from, Player to){
- Vector vect1 = from.getLocation().toVector();
- Vector vect2 = to.getLocation().toVector();
- Vector vector = vect2.subtract(vect1).normalize();
- double distance = from.getLocation().distance(to.getLocation());
- for(double i = 1.0D; i < distance; i += 1.0D){
- vect1.add(vector);
- double x = vect1.getX();
- double y = vect1.getY();
- double z = vect1.getZ();
- from.teleport(new Location(from.getWorld(), x, y + 0.25D, z, from.getLocation().getYaw(), from.getLocation().getPitch()));
- waitTicks(25L);
- }
- }
- public static void waitTicks(long n){
- long t0 = System.currentTimeMillis();
- long t1;
- do
- t1 = System.currentTimeMillis();
- while(
- t1 - t0 < n);
- }
- public static boolean isInt(String str){
- try{
- Integer.parseInt(str);
- return true;
- }catch(NumberFormatException e){
- return false;
- }
- }
- public static boolean isDouble(String str){
- try{
- Double.parseDouble(str);
- return true;
- }catch(NumberFormatException e){
- return false;
- }
- }
- public static void createMenu(){
- ItemStack kits = new ItemStack(Material.DIAMOND_SWORD);
- ItemMeta kitsMeta = kits.getItemMeta();
- kitsMeta.setDisplayName(ChatColor.AQUA + "Kits");
- ArrayList<String> kitsLore = new ArrayList<String>();
- kitsLore.add(ChatColor.DARK_PURPLE + "Choose a kit to play!");
- kitsMeta.setLore(kitsLore);
- kits.setItemMeta(kitsMeta);
- ItemStack book = new ItemStack(Material.WRITTEN_BOOK);
- BookMeta bookMeta = (BookMeta) book.getItemMeta();
- bookMeta.setAuthor("SlimeKits");
- bookMeta.setTitle(ChatColor.DARK_AQUA + "Info");
- book.setItemMeta(bookMeta);
- ItemStack rules = new ItemStack(Material.WRITTEN_BOOK);
- BookMeta rulesMeta = (BookMeta) rules.getItemMeta();
- rulesMeta.setAuthor("SlimeKits");
- rulesMeta.setTitle(ChatColor.RED + "Rules");
- rules.setItemMeta(rulesMeta);
- inv.addItem(kits);
- inv.addItem(book);
- inv.setItem(8, rules);
- Main.inst();
- Main.log.info("Kits menu created");
- }
- public static void createSelectMenu(){
- ItemStack archer = new ItemStack(Material.BOW);
- ItemMeta archerMeta = archer.getItemMeta();
- archerMeta.setDisplayName(ChatColor.LIGHT_PURPLE + "Archer");
- archer.setItemMeta(archerMeta);
- ItemStack tank = new ItemStack(Material.DIAMOND_SWORD);
- ItemMeta tankMeta = tank.getItemMeta();
- tankMeta.setDisplayName(ChatColor.AQUA + "Tank");
- tank.setItemMeta(tankMeta);
- select.setItem(0, archer);
- select.setItem(1, tank);
- Main.inst();
- Main.log.info("Select menu created");
- }
- public static void openMenu(Player player){
- player.openInventory(inv);
- }
- public static void openSelectMenu(Player player){
- player.openInventory(select);
- }
- public static void giveInfo(Player player){
- PlayerInventory inventory = player.getInventory();
- // INFO
- ItemStack book = new ItemStack(Material.WRITTEN_BOOK);
- BookMeta bookMeta = (BookMeta) book.getItemMeta();
- bookMeta.setAuthor("SlimeKits");
- bookMeta.setTitle(ChatColor.DARK_AQUA + "Info");
- ArrayList<String> bookPage = new ArrayList<String>(); // Pages
- 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
- 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.");
- bookPage.add(ChatColor.AQUA + "Tank\n------------\nStart with a diamond sword enchanted with Sharpness 1 and Iron Armour.\nYou also get Resistance 1.");
- bookPage.add(ChatColor.DARK_RED + "Knight\n------------\nStart with an iron sword enchanted with Unbreaking 10 and diamond armour.");
- 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.");
- 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.");
- 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.");
- 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.");
- 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!");
- 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.");
- 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.");
- bookMeta.setPages(bookPage);
- book.setItemMeta(bookMeta);
- inventory.addItem(book);
- }
- public static void giveRules(Player player){
- PlayerInventory inventory = player.getInventory();
- // RULES
- ItemStack rules = new ItemStack(Material.WRITTEN_BOOK);
- BookMeta rulesMeta = (BookMeta) rules.getItemMeta();
- rulesMeta.setAuthor("SlimeKits");
- rulesMeta.setTitle(ChatColor.RED + "Rules");
- ArrayList<String> rulesPage = new ArrayList<String>();
- 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.");
- rulesMeta.setPages(rulesPage);
- rules.setItemMeta(rulesMeta);
- inventory.addItem(rules);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement