58 lines
1.8 KiB
Java
58 lines
1.8 KiB
Java
package eu.univento.lobby.listeners;
|
|
|
|
import eu.univento.core.api.player.CustomPlayer;
|
|
import eu.univento.lobby.utils.Inventorys;
|
|
import org.bukkit.Material;
|
|
import org.bukkit.Sound;
|
|
import org.bukkit.event.EventHandler;
|
|
import org.bukkit.event.Listener;
|
|
import org.bukkit.event.block.Action;
|
|
import org.bukkit.event.player.PlayerInteractEvent;
|
|
import org.bukkit.inventory.ItemStack;
|
|
|
|
/**
|
|
* opens menus
|
|
* @author joethei
|
|
* @version 1.0
|
|
*/
|
|
public class Menu implements Listener{
|
|
|
|
/**
|
|
* opens and creates menus
|
|
* @param e PlayerInteract
|
|
*/
|
|
@EventHandler
|
|
public void onInteract(PlayerInteractEvent e) {
|
|
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer().getName());
|
|
if(e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
|
ItemStack item = p.getItemInHand();
|
|
if(!p.hasOpenInventory()) {
|
|
Inventorys invs = new Inventorys(p);
|
|
if(item.getType() == Material.WORKBENCH) {
|
|
p.setOpenInventory(true);
|
|
p.openInventory(invs.getNavigatorInventory());
|
|
}
|
|
if(item.getType() == Material.CHEST) {
|
|
p.setOpenInventory(true);
|
|
p.openInventory(invs.getFunChestInventory());
|
|
e.getPlayer().playSound(p.getEyeLocation(), Sound.BLOCK_CHEST_OPEN, 10.0F, 1.0F);
|
|
}
|
|
if(item.getType() == Material.SKULL_ITEM) {
|
|
p.setOpenInventory(true);
|
|
p.openInventory(invs.getProfileInventory());
|
|
}
|
|
if(item.getType() == Material.EXP_BOTTLE) {
|
|
e.setCancelled(true);
|
|
invs.setYoutuberInventory();
|
|
}
|
|
if(item.getType() == Material.BARRIER) {
|
|
invs.setMainInventory(true);
|
|
}if(item.getType() == Material.BLAZE_ROD) {
|
|
p.setOpenInventory(true);
|
|
p.openInventory(invs.getLobbySwitcherInventory());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
} |