Advertisement
broken-arrow

Untitled

Jul 25th, 2021
774
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.53 KB | None | 0 0
  1. import org.broken.cheststorage.inventoryholders.InventoryHolder;
  2. import org.broken.cheststorage.inventoryholders.InventoryHolderDefultchest;
  3. import org.broken.cheststorage.inventoryholders.InventoryHolderStorageUnit;
  4. import org.bukkit.Location;
  5. import org.bukkit.entity.Player;
  6.  
  7. import java.util.HashMap;
  8. import java.util.Map;
  9.  
  10. public class ClassInstance {
  11.  
  12.     public static Map<Class<?>, InventoryHolder> classes = new HashMap<>();
  13.  
  14.     public static InventoryHolder setInventoryHolder(String containerType, Location location, Player player) {
  15.  
  16.  
  17.         if (containerType.equals("bigchest") && !classes.containsKey(InventoryHolderStorageUnit.class)) {
  18.             classes.put(InventoryHolderStorageUnit.class, new InventoryHolderStorageUnit(location, player));
  19.  
  20.             return new InventoryHolderDefultchest(location, player);
  21.         } else if (!containerType.equals("hopper") && !classes.containsKey(InventoryHolderDefultchest.class)) {
  22.             classes.put(InventoryHolderDefultchest.class, new InventoryHolderDefultchest(location, player));
  23.             System.out.println("test" + classes.keySet() + classes.get(InventoryHolderDefultchest.class));
  24.             return new InventoryHolderDefultchest(location, player);
  25.  
  26.         } else
  27.             return getInventoryHolder(containerType);
  28.  
  29.     }
  30.  
  31.     public static InventoryHolder getInventoryHolder(String containerType) {
  32.         if (containerType.equals("bigchest")) {
  33.             return classes.get(InventoryHolderStorageUnit.class);
  34.         } else if (!containerType.equals("hopper")) {
  35.             return classes.get(InventoryHolderDefultchest.class);
  36.         }
  37.         return null;
  38.     }
  39.  
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement