Advertisement
Guest User

Untitled

a guest
Nov 29th, 2014
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 1.01 KB | None | 0 0
  1. package me.clip.ezprestige.gui;
  2.  
  3. import java.util.HashMap;
  4.  
  5. import org.bukkit.entity.Player;
  6.  
  7. import me.clip.ezprestige.EZPrestige;
  8.  
  9. public class InventoryMenuHandler {
  10.    
  11.     EZPrestige plugin;
  12.    
  13.     public InventoryMenuHandler(EZPrestige instance) {
  14.         plugin = instance;
  15.     }
  16.    
  17.     private static HashMap<String, EZInventoryMenu> inGUI = new HashMap<String, EZInventoryMenu>();
  18.    
  19.     public boolean hasGUI(Player p) {
  20.         if (inGUI == null) {
  21.             return false;
  22.         }
  23.         return inGUI.containsKey(p.getName()) && inGUI.get(p.getName()) != null;
  24.     }
  25.    
  26.     public EZInventoryMenu getGUI(Player p) {
  27.         if (!hasGUI(p)) {
  28.             return new EZInventoryMenu(p.getName());
  29.         }
  30.         return inGUI.get(p.getName());
  31.     }
  32.    
  33.     public void openGUI(Player p, EZInventoryMenu gui) {
  34.         gui.openInventory(p);
  35.         inGUI.put(p.getName(), gui);
  36.     }
  37.    
  38.     public void closeGUI(Player p, boolean close) {
  39.         if (!hasGUI(p)) {
  40.             return;
  41.         }
  42.        
  43.         if (close) {
  44.             getGUI(p).clear();
  45.             p.closeInventory();
  46.         }
  47.        
  48.         inGUI.remove(p.getName());
  49.     }
  50.  
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement