I re-writed the hole plugin!!! and still having errors:
@error_dan_overflow @TrinityDEV @GingerGeek @rubik_cube_man @Joe Henry
package Gui.test;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.plugin.java.JavaPlugin;
public class Gui extends JavaPlugin implements Listener {
public void onEnable() {
getServer().getPluginManager().registerEvents(this, this);
}
public void openGUI(Player player) {
Inventory i = Bukkit.createInventory(null, 9, ChatColor.DARK_BLUE
+ "Kits!");
ItemStack PvP = new ItemStack(Material.DIAMOND_SWORD);
ItemMeta PvPMeta = PvP.getItemMeta();
ItemStack Archer = new ItemStack(Material.BOW);
ItemMeta ArcherMeta = Archer.getItemMeta();
PvPMeta.setDisplayName(ChatColor.WHITE + "PvP");
PvP.setItemMeta(PvPMeta);
ArcherMeta.setDisplayName(ChatColor.WHITE + "Archer");
Archer.setItemMeta(ArcherMeta);
i.setItem(3, PvP);
i.setItem(5, Archer);
player.openInventory(i);
}
@EventHandler
public void onInventoryClickEvent(InventoryClickEvent e) {
if (ChatColor.stripColor(e.getInventory().getName()).equalsIgnoreCase(
"Kits!"))
return;
Player player = (Player) e.getWhoClicked();
e.setCancelled(true);
if (e.getCurrentItem() == null
|| e.getCurrentItem().getType() == Material.AIR
|| !e.getCurrentItem().hasItemMeta()) {
player.closeInventory();
return;
}
switch (e.getCurrentItem().getType()){
case DIAMOND_SWORD:
player.performCommand("Help");
player.closeInventory();
player.sendMessage(String.format(
"%s You received the kit %sPvP%s!", ChatColor.GREEN,
ChatColor.AQUA, ChatColor.GREEN));
break;
case BOW:
player.performCommand("Spawn");
player.closeInventory();
player.sendMessage(String.format(
"%s You received the kit %sArcher%s!", ChatColor.GREEN,
ChatColor.AQUA, ChatColor.GREEN));
break;
default:
player.closeInventory();
break;
}
}
@EventHandler
public void onPlayerJoinEvent(PlayerJoinEvent e) {
e.getPlayer().getInventory().addItem(new ItemStack(Material.COMPASS));
}
@EventHandler
public void onPlayerInteract(PlayerInteractEvent e) {
Action a = e.getAction();
if (a == Action.PHYSICAL || e.getItem() == null
|| e.getItem().getType() == Material.AIR)
return;
if (e.getItem().getType() == Material.COMPASS) {
openGUI(e.getPlayer());
}
}
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.plugin.java.JavaPlugin;
public class Gui extends JavaPlugin implements Listener {
public void onEnable() {
getServer().getPluginManager().registerEvents(this, this);
}
public void openGUI(Player player) {
Inventory i = Bukkit.createInventory(null, 9, ChatColor.DARK_BLUE
+ "Kits!");
ItemStack PvP = new ItemStack(Material.DIAMOND_SWORD);
ItemMeta PvPMeta = PvP.getItemMeta();
ItemStack Archer = new ItemStack(Material.BOW);
ItemMeta ArcherMeta = Archer.getItemMeta();
PvPMeta.setDisplayName(ChatColor.WHITE + "PvP");
PvP.setItemMeta(PvPMeta);
ArcherMeta.setDisplayName(ChatColor.WHITE + "Archer");
Archer.setItemMeta(ArcherMeta);
i.setItem(3, PvP);
i.setItem(5, Archer);
player.openInventory(i);
}
@EventHandler
public void onInventoryClickEvent(InventoryClickEvent e) {
if (ChatColor.stripColor(e.getInventory().getName()).equalsIgnoreCase(
"Kits!"))
return;
Player player = (Player) e.getWhoClicked();
e.setCancelled(true);
if (e.getCurrentItem() == null
|| e.getCurrentItem().getType() == Material.AIR
|| !e.getCurrentItem().hasItemMeta()) {
player.closeInventory();
return;
}
switch (e.getCurrentItem().getType()){
case DIAMOND_SWORD:
player.performCommand("Help");
player.closeInventory();
player.sendMessage(String.format(
"%s You received the kit %sPvP%s!", ChatColor.GREEN,
ChatColor.AQUA, ChatColor.GREEN));
break;
case BOW:
player.performCommand("Spawn");
player.closeInventory();
player.sendMessage(String.format(
"%s You received the kit %sArcher%s!", ChatColor.GREEN,
ChatColor.AQUA, ChatColor.GREEN));
break;
default:
player.closeInventory();
break;
}
}
@EventHandler
public void onPlayerJoinEvent(PlayerJoinEvent e) {
e.getPlayer().getInventory().addItem(new ItemStack(Material.COMPASS));
}
@EventHandler
public void onPlayerInteract(PlayerInteractEvent e) {
Action a = e.getAction();
if (a == Action.PHYSICAL || e.getItem() == null
|| e.getItem().getType() == Material.AIR)
return;
if (e.getItem().getType() == Material.COMPASS) {
openGUI(e.getPlayer());
}
}