Added WitherChest, Interactive GUI

This commit is contained in:
night0721 2022-07-04 00:07:27 +01:00
parent 3e0cf3ce33
commit c99dbcfa6c
4 changed files with 50 additions and 1 deletions

View file

@ -40,6 +40,7 @@ public final class Main extends JavaPlugin implements Listener {
BarStyle.SEGMENTED_12
);
Bukkit.getPluginManager().registerEvents(this, this);
Bukkit.getPluginManager().registerEvents(new MenuListener(), this);
}
@EventHandler

View file

@ -0,0 +1,37 @@
package com.night.nullvalkyrie;
import com.night.nullvalkyrie.commands.MenuCommand;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent;
public class MenuListener implements Listener {
@EventHandler
public void onClick(InventoryClickEvent e) {
if(e.getInventory().equals(MenuCommand.inv) && e.getCurrentItem() != null) {
e.setCancelled(true);
Player player = (Player) e.getWhoClicked();
switch (e.getRawSlot()) {
case 0:
break;
case 20:
player.setHealth(0);
player.sendMessage(ChatColor.RED + "又做兵 抵死");
break;
case 22:
break;
case 24:
player.closeInventory();
player.openInventory(WitherChest.witherchest);
return;
default:
return;
}
player.closeInventory();
}
}
}

View file

@ -0,0 +1,9 @@
package com.night.nullvalkyrie;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.inventory.Inventory;
public class WitherChest {
public static Inventory witherchest = Bukkit.createInventory(null,54, ChatColor.DARK_AQUA + "Whiter Chest");
}

View file

@ -14,11 +14,13 @@ import org.bukkit.inventory.meta.ItemMeta;
import java.util.Arrays;
public class MenuCommand implements CommandExecutor {
public static Inventory inv = Bukkit.createInventory(null, 45, ChatColor.DARK_BLUE.toString() + ChatColor.BOLD + "Valkyrie Menu");
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if(sender instanceof Player) {
Player player = (Player) sender;
Inventory inv = Bukkit.createInventory(player,45, ChatColor.DARK_BLUE.toString() + ChatColor.BOLD + "Valkyrie Menu");
inv = Bukkit.createInventory(player,45, ChatColor.DARK_BLUE.toString() + ChatColor.BOLD + "Valkyrie Menu");
ItemStack KYS = new ItemStack(Material.WOODEN_SWORD);
ItemMeta KYSmeta = KYS.getItemMeta();