SHARE
TWEET

Untitled

a guest Jun 17th, 2019 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package me.unknown.ddosplugin.util;
  2.  
  3. import org.bukkit.Bukkit;
  4. import org.bukkit.ChatColor;
  5. import org.bukkit.Material;
  6. import org.bukkit.entity.Player;
  7. import org.bukkit.inventory.Inventory;
  8. import org.bukkit.inventory.ItemStack;
  9. import org.bukkit.inventory.meta.ItemMeta;
  10.  
  11. import java.util.ArrayList;
  12. import java.util.HashMap;
  13. import java.util.UUID;
  14.  
  15. public class ScrollerInventory {
  16.  
  17.     public ArrayList<Inventory> pages = new ArrayList<Inventory>();
  18.     public UUID id;
  19.     public int currpage = 0;
  20.     public static HashMap<UUID, ScrollerInventory> users = new HashMap<UUID, ScrollerInventory>();
  21.  
  22.     //Running this will open a paged inventory for the specified player, with the items in the arraylist specified.
  23.     public ScrollerInventory(ArrayList<ItemStack> items, String name, Player p) {
  24.         this.id = UUID.randomUUID();
  25. //create new blank page
  26.         Inventory page = getBlankPage(name);
  27.         //According to the items in the arraylist, add items to the ScrollerInventory
  28.         for (int i = 0; i < items.size(); i++) {
  29.             //If the current page is full, add the page to the inventory's pages arraylist, and create a new page to add the items.
  30.             if (page.firstEmpty() == 46) {
  31.                 pages.add(page);
  32.                 page = getBlankPage(name);
  33.                 page.addItem(items.get(i));
  34.             } else {
  35. //Add the item to the current page as per normal
  36.                 page.addItem(items.get(i));
  37.             }
  38.         }
  39.         pages.add(page);
  40. //open page 0 for the specified player
  41.         p.openInventory(pages.get(currpage));
  42.         users.put(p.getUniqueId(), this);
  43.     }
  44.  
  45.  
  46.     public static final String nextPageName = "┬žaNext Page";
  47.     public static final String previousPageName = "┬žcPrevious Page";
  48.  
  49.     //This creates a blank page with the next and prev buttons
  50.     private Inventory getBlankPage(String name) {
  51.         Inventory page = Bukkit.createInventory(null, 54, name);
  52.  
  53.         ItemStack nextpage = new ItemStack(Material.STAINED_GLASS_PANE, 1, (byte) 5);
  54.         ItemMeta meta = nextpage.getItemMeta();
  55.         meta.setDisplayName(nextPageName);
  56.         nextpage.setItemMeta(meta);
  57.  
  58.         ItemStack prevpage = new ItemStack(Material.STAINED_GLASS_PANE, 1, (byte) 14);
  59.         meta = prevpage.getItemMeta();
  60.         meta.setDisplayName(previousPageName);
  61.         prevpage.setItemMeta(meta);
  62.  
  63.  
  64.         page.setItem(53, nextpage);
  65.         page.setItem(45, prevpage);
  66.         return page;
  67.     }
  68. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top