Skip to content

Instantly share code, notes, and snippets.

@whilb
Created February 5, 2014 00:07
Show Gist options
  • Save whilb/8815021 to your computer and use it in GitHub Desktop.
Save whilb/8815021 to your computer and use it in GitHub Desktop.
Kits Example
public enum KitType {
MEMBER,
VIP,
VIPPLUS,
MVP,
}
@EventHandler
public void onInventoryClick(InventoryClickEvent e) {
Player p = e.getWhoClicked();
PlayerInventory pInv = p.getInventory();
if(e.getItem().getItemMeta().getDisplayName().equalsIgnoreCase("Member") {
p.setInventory(fillInventory(p, KitType.MEMBER));
}
if(e.getItem().getItemMeta().getDisplayName().equalsIgnoreCase("VIP") {
p.setInventory(fillInventory(p, KitType.VIP));
}
if(e.getItem().getItemMeta().getDisplayName().equalsIgnoreCase("VIP+") {
p.setInventory(fillInventory(p, KitType.VIPPLUS));
}
if(e.getItem().getItemMeta().getDisplayName().equalsIgnoreCase("MVP") {
p.setInventory(fillInventory(p, KitType.MVP));
}
}
public Inventory fillInventory(Inventory inv, KitType type) {
ItemStack helmet;
ItemStack chestplate;
ItemStack pants;
ItemStack boots;
ItemStack sword;
//declare special things as appropriate in the right places
switch(type) {
case MEMBER:
//do stuff
break;
case VIP:
//do more stuff
break;
default:
//do other stuff
break;
}
inv.addItem(helmet); // this will be null if nothing is assigned to it, so your test is to prevent that.
inv.addItem(chestplate);
inv.addItem(pants);
inv.addItem(boots);
inv.addItem(sword);
return inv;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment