45 lines
1.6 KiB
Java
45 lines
1.6 KiB
Java
package tokarotik.giftapi;
|
|
|
|
import org.bukkit.Bukkit;
|
|
import org.bukkit.configuration.file.FileConfiguration;
|
|
import org.bukkit.entity.Player;
|
|
import org.bukkit.event.EventHandler;
|
|
import org.bukkit.event.Listener;
|
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
|
import org.bukkit.inventory.ItemStack;
|
|
|
|
import tokarotik.giftapi.inventory.InventoryManager;
|
|
|
|
public class APIManager implements Listener {
|
|
|
|
public final Main plugin;
|
|
private final InventoryManager inventoryManager;
|
|
|
|
public APIManager(Main plugin, FileConfiguration config, int inventory_slots)
|
|
{
|
|
this.plugin = plugin;
|
|
this.inventoryManager = new InventoryManager(
|
|
plugin.getCacheManager(),
|
|
inventory_slots,
|
|
ConfigPaths.getWithColor(config, ConfigPaths.GUINAME, "GiftAPI Menu"),
|
|
ConfigPaths.getWithColor(config, ConfigPaths.GUIRIGHT, "<<right"),
|
|
ConfigPaths.getWithColor(config, ConfigPaths.GUILEFT, "left>>"),
|
|
ConfigPaths.getWithColor(config, ConfigPaths.GUIEXIT, "quit")
|
|
);
|
|
|
|
Bukkit.getPluginManager().registerEvents(this.inventoryManager, this.plugin);
|
|
}
|
|
|
|
public synchronized void add(Player player, ItemStack item) { this.inventoryManager.add(player, item); }
|
|
|
|
public synchronized void remove(Player player, ItemStack item) { this.inventoryManager.remove(player, item); }
|
|
|
|
public synchronized void openInventory(Player player)
|
|
{
|
|
this.inventoryManager.openCustomInventory(player);
|
|
}
|
|
|
|
@EventHandler
|
|
public void onInventoryClick(InventoryClickEvent event) { this.inventoryManager.onInventoryClick(event); }
|
|
}
|