From 8c668fccc100f37a0c3a67aa329d8dbd2b17a783 Mon Sep 17 00:00:00 2001 From: sigonasr2 Date: Tue, 26 Nov 2013 06:08:51 -0700 Subject: [PATCH] Add in new ItemSet references. --- BankEconomyMod/src/me/kaZep/Base/.gitignore | 2 + BankEconomyMod/src/sig/ItemSets/ColorSet.java | 24 +++ BankEconomyMod/src/sig/ItemSets/ItemSet.java | 30 ++++ .../src/sig/ItemSets/ItemSetList.java | 151 ++++++++++++++++++ 4 files changed, 207 insertions(+) create mode 100644 BankEconomyMod/src/me/kaZep/Base/.gitignore create mode 100644 BankEconomyMod/src/sig/ItemSets/ColorSet.java create mode 100644 BankEconomyMod/src/sig/ItemSets/ItemSet.java create mode 100644 BankEconomyMod/src/sig/ItemSets/ItemSetList.java diff --git a/BankEconomyMod/src/me/kaZep/Base/.gitignore b/BankEconomyMod/src/me/kaZep/Base/.gitignore new file mode 100644 index 0000000..92e82b9 --- /dev/null +++ b/BankEconomyMod/src/me/kaZep/Base/.gitignore @@ -0,0 +1,2 @@ +/._PlayerListener.java1265619304918501342.tmp +/._PlayerListener.java3998199996590245987.tmp diff --git a/BankEconomyMod/src/sig/ItemSets/ColorSet.java b/BankEconomyMod/src/sig/ItemSets/ColorSet.java new file mode 100644 index 0000000..515ee47 --- /dev/null +++ b/BankEconomyMod/src/sig/ItemSets/ColorSet.java @@ -0,0 +1,24 @@ +package sig.ItemSets; + +import org.bukkit.Color; + + +/** + * A collection of colors that defines an item set. + */ +public class ColorSet { + Color helmet, chestplate, leggings, boots; + /** + * + * @param helmet The helmet's Color. + * @param chestplate The chestplate's Color. + * @param leggings The leggings' Color. + * @param boots The boots' Color. + */ + public ColorSet(Color helmet, Color chestplate, Color leggings, Color boots) { + this.helmet=helmet; + this.chestplate=chestplate; + this.leggings=leggings; + this.boots=boots; + } +} \ No newline at end of file diff --git a/BankEconomyMod/src/sig/ItemSets/ItemSet.java b/BankEconomyMod/src/sig/ItemSets/ItemSet.java new file mode 100644 index 0000000..8c933a1 --- /dev/null +++ b/BankEconomyMod/src/sig/ItemSets/ItemSet.java @@ -0,0 +1,30 @@ +package sig.ItemSets; + +import org.bukkit.Color; + +public class ItemSet { + String name = ""; //The name of the ItemSet. + String description = ""; //The description of the ItemSet. + String[] effectlist = {"","",""}; + ColorSet colors = null; + public ItemSet(String name, ColorSet colors, String description, + String effect1, String effect2, String effect3) { + this.name=name; + this.colors=colors; + this.description=description; + this.effectlist[0]=effect1; + this.effectlist[1]=effect2; + this.effectlist[2]=effect3; + } + /* + private static String[] sets = {"Acrobat", "Angel", "Berserker", "Blackguard", "Chilling", "Flaming", + "Glacial", "Guardian", "Holy", "Meteoric", "Monk", "Nature", "Priest", "Ruby", "Sapphire", "Spiritual", + "Summoner", "Trickster", "Venomous", "Visionary", "Warrior", "Witch-hunter"}; //Holds all the sets that exist. + private static ColorSet[] colorsets = { ColorSet(Color.AQUA,Color.AQUA,Color.AQUA,Color.AQUA), + + }; + private static ColorSet ColorSet(Color col1, Color col2, Color col3, + Color col4) { + return ColorSet(col1,col2,col3,col4); + }*/ +} \ No newline at end of file diff --git a/BankEconomyMod/src/sig/ItemSets/ItemSetList.java b/BankEconomyMod/src/sig/ItemSets/ItemSetList.java new file mode 100644 index 0000000..5f79238 --- /dev/null +++ b/BankEconomyMod/src/sig/ItemSets/ItemSetList.java @@ -0,0 +1,151 @@ +package sig.ItemSets; + +import java.util.ArrayList; +import java.util.List; + +import org.bukkit.ChatColor; +import org.bukkit.Color; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; + +public class ItemSetList { + enum Armor {HELMET, CHESTPLATE, LEGGINGS, BOOTS}; + List itemsetlist = null; + /** + * Initializes the Item Set list for adding data and manipulating. + */ + public void Init() { + itemsetlist = new ArrayList(); + } + /** + * + * @param set The ItemSet to add to the list. + * @return Returns the size of the item set list after adding in the ItemSet. + */ + public int addSet(ItemSet set) { + itemsetlist.add(set); + return itemsetlist.size(); + } + /** + * + * @param title The title of the item set. + * @return Returns the size of the item list after removing the ItemSet. + */ + public int removeSet(String title) { + int itemset_slot=-1; + if ((itemset_slot=getSetSlot(title))!=-1) { + itemsetlist.remove(itemset_slot); + } + return itemsetlist.size(); + } + /** + * Generates a random set item. + * @return Returns the ItemStack of the new set item. + */ + public ItemStack randomizeSetItem() { + + } + /** + * The function that hooks into the rest of the item sets. + * @param item The ItemStack to check. + * @return Returns true if this item is identified as a set item, + * false otherwise. + */ + public boolean isSetItem(ItemStack item) { + //A set item is identified by its name. It could be unidentified too. + if (item.hasItemMeta()) { + ItemMeta meta = item.getItemMeta(); + String name = meta.getDisplayName(); + //Parse the name and see if it has the characteristics of a set item. + if (name.contains(ChatColor.GREEN+"") || name.contains(ChatColor.GREEN+""+ChatColor.MAGIC+"")) { + //It is considered a set item. + return true; + } else { + return false; + } + } else { + //If it has no metadata, it can't possible be a set item. + return false; + } + } + /** + * Extracts the set name from the item. + * @param item The ItemStack to extract the item from. + * @return Returns the name of the set. Returns null + * if this item is not a set item. + */ + public String getSetName(ItemStack item) { + if (item.hasItemMeta()) { + ItemMeta meta = item.getItemMeta(); + String name = meta.getDisplayName(); + //Parse the name and see if it has the characteristics of a set item. + if (name.contains(ChatColor.GREEN+"") || name.contains(ChatColor.GREEN+""+ChatColor.MAGIC+"")) { + //Return the first name. + if (name.contains(ChatColor.GREEN+""+ChatColor.MAGIC+"")) { + return name.substring(name.indexOf(ChatColor.GREEN+""+ChatColor.MAGIC+""), name.indexOf(" ")); + } else { + return name.substring(name.indexOf(ChatColor.GREEN+""), name.indexOf(" ")); + } + } else { + return null; + } + } else { + //If it has no metadata, it can't possible be a set item. + return null; + } + } + /** + * + * @param set_slot The slot in the item set list. + * @return Returns the title of the item set. + */ + public String getSetTitle(int set_slot) { + return itemsetlist.get(set_slot).name; + } + /** + * + * @param title The title of the set. + * @param type The armor type. + * @return Returns the color of the specified armor type in the item set. + * Returns null if it couldn't find the item set or an invalid armor + * type was provided. + */ + public Color getSetColor(String title,Armor type) { + int set_slot=-1; + if ((set_slot=getSetSlot(title))!=-1) { + switch (type) { + case HELMET: { + return itemsetlist.get(set_slot).colors.helmet; + } + case CHESTPLATE: { + return itemsetlist.get(set_slot).colors.chestplate; + } + case LEGGINGS: { + return itemsetlist.get(set_slot).colors.leggings; + } + case BOOTS: { + return itemsetlist.get(set_slot).colors.boots; + } + default:{ + return null; + } + } + } else { + return null; + } + } + /** + * + * @param title A title of an item set. + * @return Returns the number of the slot in the itemsetlist if it is found. + * Otherwise returns -1. + */ + private int getSetSlot(String title) { + for (int i=0;i