commit 4bc6abfef8d852e78d31283a873bdce3be73d918 Author: sigonasr2 Date: Sat Jun 18 12:13:17 2016 -0500 Re-structure TwosideKeeper project such that it builds properly and has a proper build file. diff --git a/TwosideKeeper.jar b/TwosideKeeper.jar new file mode 100644 index 0000000..e677ef0 Binary files /dev/null and b/TwosideKeeper.jar differ diff --git a/projectBuilder.xml b/projectBuilder.xml new file mode 100644 index 0000000..c78ccc0 --- /dev/null +++ b/projectBuilder.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/src/plugin.yml b/src/plugin.yml new file mode 100644 index 0000000..aeb1b98 --- /dev/null +++ b/src/plugin.yml @@ -0,0 +1,39 @@ +name: TwosideKeeper +main: sig.plugin.TwosideKeeper.TwosideKeeper +version: 3.3.4 +commands: + money: + description: Tells the player the amount of money they are holding. + usage: /money + permission: TwosideKeeper.money + permission-message: You don't have permission to check your balance! + enchant_advanced: + description: Enchants items with more properties. + usage: /enchant_advanced + permission: TwosideKeeper.enchant + permission-message: No permissions! + harden_armor: + description: Hardens a piece of armor. + usage: /harden_armor + permission: TwosideKeeper.harden + permission-message: No permissions! + item_cube: + description: Sets this item as an item cube. + usage: /item_cube + permission: TwosideKeeper.item_cube + permission-message: No permissions! + artifact: + description: Gives the player an artifact. + usage: /artifact + permission: TwosideKeeper.artifact + permission-message: No permissions! + recyclingcenter: + description: Defines a new container for a Recycling Center. + usage: /recyclingcenter + permission: TwosideKeeper.recyclingcenter + permission-message: No permissions! + sound: + description: Toggle sound message notifications. + usage: /sound + permission: TwosideKeeper.sound + permission-message: No permissions! \ No newline at end of file diff --git a/src/sig/plugin/TwosideKeeper/Artifact.java b/src/sig/plugin/TwosideKeeper/Artifact.java new file mode 100644 index 0000000..c6eeb87 --- /dev/null +++ b/src/sig/plugin/TwosideKeeper/Artifact.java @@ -0,0 +1,176 @@ +package sig.plugin.TwosideKeeper; + +import java.util.ArrayList; +import java.util.List; + +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.enchantments.Enchantment; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; +import org.bukkit.material.MaterialData; + +import sig.plugin.TwosideKeeper.HelperStructures.ArtifactItem; + +public class Artifact { + public static ItemStack createArtifactItem(ArtifactItem type) { + ItemStack i = null; + switch (type) { + case ANCIENT_BASE: + i=new ItemStack(Material.CLAY_BALL); + break; + case ANCIENT_CORE: + i=new ItemStack(Material.MAGMA_CREAM); + break; + case ANCIENT_ESSENCE: + i=new ItemStack(Material.SUGAR); + break; + case ARTIFACT_BASE: + i=new ItemStack(Material.CLAY_BALL); + break; + case ARTIFACT_CORE: + i=new ItemStack(Material.MAGMA_CREAM); + break; + case ARTIFACT_ESSENCE: + i=new ItemStack(Material.SUGAR); + break; + case DIVINE_BASE: + i=new ItemStack(Material.CLAY_BALL); + break; + case DIVINE_CORE: + i=new ItemStack(Material.MAGMA_CREAM); + break; + case DIVINE_ESSENCE: + i=new ItemStack(Material.SUGAR); + break; + case LOST_BASE: + i=new ItemStack(Material.CLAY_BALL); + break; + case LOST_CORE: + i=new ItemStack(Material.MAGMA_CREAM); + break; + case LOST_ESSENCE: + i=new ItemStack(Material.SUGAR); + break; + case MALLEABLE_BASE: + i=new ItemStack(Material.INK_SACK,1,(short) 7); + break; + case MYSTERIOUS_ESSENCE: + i=new ItemStack(Material.PUMPKIN_SEEDS); + break; + default: + i=new ItemStack(Material.AIR); + break; + } + return convert(setName(i,type),type,true); + } + public static ItemStack setName(ItemStack i, ArtifactItem type) { + ItemMeta m = i.getItemMeta(); + switch (type) { + case ANCIENT_BASE: + m.setDisplayName(ChatColor.BOLD+""+ChatColor.BLUE+"Ancient Base"); + break; + case ANCIENT_CORE: + m.setDisplayName(ChatColor.BOLD+""+ChatColor.BLUE+"Ancient Core"); + break; + case ANCIENT_ESSENCE: + m.setDisplayName(ChatColor.BOLD+""+ChatColor.BLUE+"Ancient Essence"); + break; + case ARTIFACT_BASE: + m.setDisplayName(ChatColor.BOLD+""+ChatColor.BLUE+"Artifact Base"); + break; + case ARTIFACT_CORE: + m.setDisplayName(ChatColor.BOLD+""+ChatColor.BLUE+"Artifact Core"); + break; + case ARTIFACT_ESSENCE: + m.setDisplayName(ChatColor.BOLD+""+ChatColor.BLUE+"Artifact Essence"); + break; + case DIVINE_BASE: + m.setDisplayName(ChatColor.BOLD+""+ChatColor.BLUE+"Divine Base"); + break; + case DIVINE_CORE: + m.setDisplayName(ChatColor.BOLD+""+ChatColor.BLUE+"Divine Core"); + break; + case DIVINE_ESSENCE: + m.setDisplayName(ChatColor.BOLD+""+ChatColor.BLUE+"Divine Essence"); + break; + case LOST_BASE: + m.setDisplayName(ChatColor.BOLD+""+ChatColor.BLUE+"Lost Base"); + break; + case LOST_CORE: + m.setDisplayName(ChatColor.BOLD+""+ChatColor.BLUE+"Lost Core"); + break; + case LOST_ESSENCE: + m.setDisplayName(ChatColor.BOLD+""+ChatColor.BLUE+"Lost Essence"); + break; + case MALLEABLE_BASE: + m.setDisplayName(ChatColor.BOLD+""+ChatColor.BLUE+"Malleable Base"); + break; + case MYSTERIOUS_ESSENCE: + m.setDisplayName(ChatColor.BOLD+""+ChatColor.LIGHT_PURPLE+"Mysterious Essence"); + break; + } + i.setItemMeta(m); + return i; + } + public static ItemStack convert(ItemStack item, ArtifactItem type, boolean reprint_lore) { + //Converts an item to an artifact. + ItemMeta m = item.getItemMeta(); + List l = new ArrayList(); + if (item.getItemMeta().hasLore()) { + l = item.getItemMeta().getLore(); + } + if (reprint_lore) { + l.add(ChatColor.GOLD+""+ChatColor.ITALIC+"Artifact Crafting Item"); + if (type==ArtifactItem.MALLEABLE_BASE) { + l.add(ChatColor.YELLOW+" Right-click to activate"); + l.add(ChatColor.YELLOW+" this base."); + } + } + m.setLore(l); + item.setItemMeta(m); + if (type.toString().contains("ARTIFACT")) { + item.addUnsafeEnchantment(Enchantment.LUCK, 1); + } else + if (type.toString().contains("ANCIENT")) { + item.addUnsafeEnchantment(Enchantment.LUCK, 2); + } else + if (type.toString().contains("LOST")) { + item.addUnsafeEnchantment(Enchantment.LUCK, 3); + } else + if (type.toString().contains("DIVINE")) { + item.addUnsafeEnchantment(Enchantment.LUCK, 4); + } else { + item.addUnsafeEnchantment(Enchantment.LUCK, 10); + } + return item; + } + public static ItemStack convert(ItemStack item, boolean reprint_lore) { + //Converts an item to an artifact. + return convert(item, ArtifactItem.ARTIFACT_ESSENCE, reprint_lore); + } + public static ItemStack convert(ItemStack item) { + //Converts an item to an artifact. + return convert(item, ArtifactItem.ARTIFACT_ESSENCE, true); + } + public static boolean isArtifact(ItemStack item) { + if (item.hasItemMeta() && + item.getItemMeta().hasLore() && + item.getItemMeta().getLore().contains(ChatColor.GOLD+""+ChatColor.ITALIC+"Artifact Crafting Item")) { + //This is an artifact. + return true; + } else { + return false; + } + } + public static boolean isMalleableBase(ItemStack item) { + //Check for type of item, and if it's an artifact. + if (isArtifact(item) && + item.getType()==Material.INK_SACK && + item.getDurability()==7) { + return true; + } else { + return false; + } + } +} diff --git a/src/sig/plugin/TwosideKeeper/DeathManager.java b/src/sig/plugin/TwosideKeeper/DeathManager.java new file mode 100644 index 0000000..53c3644 --- /dev/null +++ b/src/sig/plugin/TwosideKeeper/DeathManager.java @@ -0,0 +1,155 @@ +package sig.plugin.TwosideKeeper; + +import java.util.ArrayList; +import java.util.List; + +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.enchantments.Enchantment; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.InventoryType; +import org.bukkit.inventory.Inventory; +import org.bukkit.inventory.InventoryView; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; + +import sig.plugin.TwosideKeeper.HelperStructures.DeathStructure; + +public class DeathManager { + static String Pick5Text = "Mercy (Pick 5 Lost Items)"; + static String Pick20Text = "Mercy (Pick 20 Lost Items Randomly)"; + static String BuybackText = "Buyback (Pay for Lost Items)"; + static String DropText = "Drop Items (At death point)"; + public static List ds = new ArrayList(); + + public static void addNewDeathStructure(List deathinv, Location deathloc, Player p) { + ds.add(new DeathStructure(deathinv,deathloc,p)); + } + public static void removeDeathStructure(Player p) { + ds.remove(getDeathStructure(p)); + } + public static boolean deathStructureExists(Player p) { + if (getDeathStructure(p)!=null) { + return true; + } else { + return false; + } + } + /* + public static void givePlayerDeathChoices(Player p) { + //Also stop the player from moving. + ItemStack pick_five = new ItemStack(Material.COMMAND); + ItemMeta meta = pick_five.getItemMeta(); + meta.setDisplayName(Pick5Text); + pick_five.setItemMeta(meta); + pick_five.addUnsafeEnchantment(Enchantment.LUCK, 1); + ItemStack pick_twenty = new ItemStack(Material.COMMAND_CHAIN); + meta = pick_twenty.getItemMeta(); + meta.setDisplayName(Pick20Text); + pick_twenty.setItemMeta(meta); + pick_twenty.addUnsafeEnchantment(Enchantment.LUCK, 1); + ItemStack buyback = new ItemStack(Material.COMMAND_REPEATING); + meta = buyback.getItemMeta(); + meta.setDisplayName(BuybackText); + buyback.setItemMeta(meta); + buyback.addUnsafeEnchantment(Enchantment.LUCK, 1); + ItemStack normaldrop = new ItemStack(Material.BARRIER); + meta = normaldrop.getItemMeta(); + meta.setDisplayName(DropText); + normaldrop.setItemMeta(meta); + normaldrop.addUnsafeEnchantment(Enchantment.LUCK, 1); + + + p.getInventory().addItem(pick_five); + p.getInventory().addItem(pick_twenty); + p.getInventory().addItem(buyback); + p.getInventory().addItem(normaldrop); + + p.addPotionEffect(new PotionEffect(PotionEffectType.SLOW,999999999,10)); + p.sendMessage(ChatColor.AQUA+"Place down the block indicating how you want to retrieve your lost items."); + }*/ + public static boolean isDeathBlock(ItemStack b) { + if (b.hasItemMeta() && + b.getItemMeta().hasDisplayName() && + b.containsEnchantment(Enchantment.LUCK)) { + return true; + } else { + return false; + } + } + + public static DeathStructure getDeathStructure(Player p) { + for (int i=0;i=36) { + if (pd.deathinventory.get(i).getType().toString().contains("BOOTS")) { + p.getInventory().setBoots(pd.deathinventory.get(i)); + } else + if (pd.deathinventory.get(i).getType().toString().contains("SHIELD")) { + p.getInventory().setItemInOffHand(pd.deathinventory.get(i)); + } else + if (pd.deathinventory.get(i).getType().toString().contains("LEGGINGS")) { + p.getInventory().setLeggings(pd.deathinventory.get(i)); + } else + if (pd.deathinventory.get(i).getType().toString().contains("CHESTPLATE")) { + p.getInventory().setChestplate(pd.deathinventory.get(i)); + } else + if (pd.deathinventory.get(i).getType().toString().contains("HELMET")) { + p.getInventory().setHelmet(pd.deathinventory.get(i)); + } else { + //What is this? Just drop it. + p.getLocation().getWorld().dropItem(p.getLocation(), pd.deathinventory.get(i)); + } + } else { + p.getInventory().addItem(pd.deathinventory.get(i)); + }*/ + if (structure.deathinventory.get(i)!=null && + structure.deathinventory.get(i).getType()!=Material.AIR) { + deathinv.addItem(structure.deathinventory.get(i)); + } + } + double totalmoney = TwosideKeeper.getPlayerMoney(p)+TwosideKeeper.getPlayerBankMoney(p); + int price = 1; + if (structure.deathloc.getBlockY()<=60) { + price += 24-(structure.deathloc.getBlockY()/2.5); + } + p.openInventory(deathinv); + p.sendMessage(ChatColor.AQUA+"You can buy back up to "+ChatColor.YELLOW+(int)(totalmoney/price)+ChatColor.AQUA+" items, costing $"+ChatColor.GREEN+price+ChatColor.WHITE+" per item."); + p.sendMessage(" The rest will drop at your death location."); + p.sendMessage(ChatColor.GRAY+"Close your inventory once you've picked your items."); + } + + public static int CalculateDeathPrice(Player p) { + DeathStructure ds = getDeathStructure(p); + return (int)(1+((ds.deathloc.getBlockY()<=60)?(24-(ds.deathloc.getBlockY()/2.5)):0)); + } + public static int CountOccupiedSlots(Inventory inv) { + int occupiedslots = 0; + for (int i=0;i deathinventory; + public Location deathloc; + public String p; + + public DeathStructure(List di, Location dl, Player p) { + this.deathinventory=di; + this.deathloc=dl; + this.p=p.getName(); + } +} diff --git a/src/sig/plugin/TwosideKeeper/HelperStructures/ItemRarity.java b/src/sig/plugin/TwosideKeeper/HelperStructures/ItemRarity.java new file mode 100644 index 0000000..4332f1e --- /dev/null +++ b/src/sig/plugin/TwosideKeeper/HelperStructures/ItemRarity.java @@ -0,0 +1,5 @@ +package sig.plugin.TwosideKeeper.HelperStructures; + +public enum ItemRarity { + VANILLA, RARE, EPIC, LEGENDARY; +} diff --git a/src/sig/plugin/TwosideKeeper/HelperStructures/MalleableBaseQuest.java b/src/sig/plugin/TwosideKeeper/HelperStructures/MalleableBaseQuest.java new file mode 100644 index 0000000..5a90aa6 --- /dev/null +++ b/src/sig/plugin/TwosideKeeper/HelperStructures/MalleableBaseQuest.java @@ -0,0 +1,288 @@ +package sig.plugin.TwosideKeeper.HelperStructures; + +import java.util.ArrayList; +import java.util.List; + +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; +import org.bukkit.plugin.Plugin; + +import sig.plugin.TwosideKeeper.Artifact; +import sig.plugin.TwosideKeeper.TwosideKeeper; + +public class MalleableBaseQuest { + + /*LORE FORMAT: + * FORMING IN PROGRESS + * Base requires 'ITEM_NAME' to + * continue forming... (5/30) + * 4893210801 <--Server Tick Time + * + * + */ + + public static ItemStack startQuest(ItemStack base) { + //Formats the item lore in preparation for the quest. + ItemMeta m = base.getItemMeta(); + List lore = new ArrayList(); + lore.add(ChatColor.RED+"FORMING IN PROGRESS"); + lore.add(ChatColor.BLUE+"Base requires "+ChatColor.AQUA+"'"+TwosideKeeper.UserFriendlyMaterialName(new ItemStack(selectItem()))+"'"+ChatColor.BLUE+" to"); + lore.add(ChatColor.BLUE+"continue forming... "+ChatColor.GREEN+"(0/30)"); + lore.add(ChatColor.BLUE+""+TwosideKeeper.getServerTickTime()); + m.setLore(lore); + base.setItemMeta(m); + return Artifact.convert(base); + + } + + public static ItemStack setTimeStarted(ItemStack base, long time) { + //The time started is always on the third line. + ItemMeta m = base.getItemMeta(); + List lore = m.getLore(); + lore.remove(2); + lore.add(2,ChatColor.BLUE+""+TwosideKeeper.getServerTickTime()); + m.setLore(lore); + base.setItemMeta(m); + return base; + } + public static ItemStack setItem(ItemStack base, Material mat) { + //Sets the material to this item instead. + ItemMeta m = base.getItemMeta(); + List lore = m.getLore(); + lore.remove(1); + lore.add(1,ChatColor.BLUE+"Base requires "+ChatColor.AQUA+"'"+mat.toString()+"'"+ChatColor.BLUE+" to"); + m.setLore(lore); + base.setItemMeta(m); + return base; + } + public static ItemStack advanceQuestProgress(ItemStack base) { + //This should occur when the base quest is ready to proceed. + //Advance the progress by one. + //Choose the next item randomly. + ItemMeta m = base.getItemMeta(); + List lore = m.getLore(); + lore.remove(1); + lore.add(1,ChatColor.BLUE+"Base requires "+ChatColor.AQUA+"'"+TwosideKeeper.UserFriendlyMaterialName(new ItemStack(selectItem()))+"'"+ChatColor.BLUE+" to"); + //Get the old quest progress. + int progress = getCurrentProgress(base); + lore.remove(2); + lore.add(2,ChatColor.BLUE+"continue forming... "+ChatColor.GREEN+"("+(progress+1)+"/30)"); + m.setLore(lore); + base.setItemMeta(m); + return Artifact.convert(base,false); + } + public static ItemStack completeQuest(ItemStack base) { + //Triggered when the quest is done. Turn into a base. + //Get the time now, and the time when we started the quest. + long starttime = getTimeStarted(base); + long currenttime = TwosideKeeper.getServerTickTime(); + + if (currenttime-starttime<=36000) { //30 min passed. Divine tier. + return Artifact.createArtifactItem(ArtifactItem.DIVINE_BASE); + } else + if (currenttime-starttime<=72000) { //1 hour passed. Lost tier. + return Artifact.createArtifactItem(ArtifactItem.LOST_BASE); + } else + if (currenttime-starttime<=144000) { //2 hours passed. Ancient tier. + return Artifact.createArtifactItem(ArtifactItem.ANCIENT_BASE); + } else + { //>2 hours passed. Artifact tier. + return Artifact.createArtifactItem(ArtifactItem.ARTIFACT_BASE); + }/* else //Too harsh. We are not going to make the player start all over. + { + //This failed. Turn it back into a Malleable base. + return Artifact.createArtifactItem(ArtifactItem.MALLEABLE_BASE); + }*/ + } + + public static String getItem(ItemStack base) { + //Get current item for this Base. + ItemMeta m = base.getItemMeta(); + List lore = m.getLore(); + String material_name = lore.get(1).split("'")[1]; + return material_name; + } + public static int getCurrentProgress(ItemStack base) { + //How many quest items have been completed already? + ItemMeta m = base.getItemMeta(); + List lore = m.getLore(); + String progress = lore.get(2).substring(lore.get(2).indexOf("(", 0)+1,lore.get(2).indexOf("/", 0)); + return Integer.parseInt(progress); + } + public static long getTimeStarted(ItemStack base) { + //Returns the server tick time this quest was started on. + ItemMeta m = base.getItemMeta(); + List lore = m.getLore(); + String timelore = lore.get(3).replace(ChatColor.BLUE+"", ""); + return Long.parseLong(timelore); + + } + public static QuestStatus getStatus(ItemStack base) { + ItemMeta m = base.getItemMeta(); + if (m.getLore().contains(ChatColor.RED+"FORMING IN PROGRESS")) { + return QuestStatus.IN_PROGRESS; + } else { + return QuestStatus.UNFORMED; + } + } + + public static void announceQuestItem(Plugin plug, final Player p, final ItemStack i) { + /*Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() { + @Override + public void run() { + setPlayerMaxHealth(player); + } + },1);*/ + p.sendMessage(ChatColor.AQUA+"The item you must obtain..."); + Bukkit.getScheduler().scheduleSyncDelayedTask(plug, new Runnable() { + @Override + public void run() { + p.sendMessage(ChatColor.AQUA+"is "+ChatColor.GREEN+getItem(i)); + } + },40); + Bukkit.getScheduler().scheduleSyncDelayedTask(plug, new Runnable() { + @Override + public void run() { + p.sendMessage(ChatColor.AQUA+"Right-click the base again once you have the item in your hotbar!"); + } + },80); + } + + public static Material selectItem() { + //Material.values(). + List blacklisted_items = new ArrayList(); + blacklisted_items.add(Material.ACACIA_DOOR); + blacklisted_items.add(Material.AIR); + blacklisted_items.add(Material.BARRIER); + blacklisted_items.add(Material.BED_BLOCK); + blacklisted_items.add(Material.BEDROCK); + blacklisted_items.add(Material.BEETROOT_BLOCK); + blacklisted_items.add(Material.BEETROOT); + blacklisted_items.add(Material.BIRCH_DOOR); + blacklisted_items.add(Material.BREWING_STAND); + blacklisted_items.add(Material.BURNING_FURNACE); + blacklisted_items.add(Material.CAKE_BLOCK); + blacklisted_items.add(Material.CARROT); + blacklisted_items.add(Material.CAULDRON); + blacklisted_items.add(Material.CHAINMAIL_BOOTS); + blacklisted_items.add(Material.CHAINMAIL_CHESTPLATE); + blacklisted_items.add(Material.CHAINMAIL_HELMET); + blacklisted_items.add(Material.CHAINMAIL_LEGGINGS); + blacklisted_items.add(Material.CHAINMAIL_BOOTS); + blacklisted_items.add(Material.CHORUS_PLANT); + blacklisted_items.add(Material.COCOA); + blacklisted_items.add(Material.COMMAND); + blacklisted_items.add(Material.COMMAND_CHAIN); + blacklisted_items.add(Material.COMMAND_MINECART); + blacklisted_items.add(Material.COMMAND_REPEATING); + blacklisted_items.add(Material.CROPS); + blacklisted_items.add(Material.DARK_OAK_DOOR); + blacklisted_items.add(Material.DAYLIGHT_DETECTOR_INVERTED); + blacklisted_items.add(Material.DEAD_BUSH); + blacklisted_items.add(Material.DIODE_BLOCK_OFF); + blacklisted_items.add(Material.DIODE_BLOCK_ON); + blacklisted_items.add(Material.DOUBLE_PLANT); + blacklisted_items.add(Material.DOUBLE_STEP); + blacklisted_items.add(Material.DOUBLE_STONE_SLAB2); + blacklisted_items.add(Material.DRAGON_EGG); + blacklisted_items.add(Material.DRAGONS_BREATH); + blacklisted_items.add(Material.EMERALD_ORE); + blacklisted_items.add(Material.COAL_ORE); + blacklisted_items.add(Material.END_CRYSTAL); + blacklisted_items.add(Material.END_GATEWAY); + blacklisted_items.add(Material.ENDER_PORTAL); + blacklisted_items.add(Material.ENDER_PORTAL_FRAME); + blacklisted_items.add(Material.EXP_BOTTLE); + blacklisted_items.add(Material.FIRE); + blacklisted_items.add(Material.FIREBALL); + blacklisted_items.add(Material.FLOWER_POT); + blacklisted_items.add(Material.FROSTED_ICE); + blacklisted_items.add(Material.GLOWING_REDSTONE_ORE); + blacklisted_items.add(Material.GOLD_RECORD); + blacklisted_items.add(Material.GRASS); + blacklisted_items.add(Material.GRASS_PATH); + blacklisted_items.add(Material.GREEN_RECORD); + blacklisted_items.add(Material.HUGE_MUSHROOM_1); + blacklisted_items.add(Material.HUGE_MUSHROOM_2); + blacklisted_items.add(Material.JUNGLE_DOOR); + blacklisted_items.add(Material.LAVA); + blacklisted_items.add(Material.LEAVES); + blacklisted_items.add(Material.LEAVES_2); + blacklisted_items.add(Material.LINGERING_POTION); + blacklisted_items.add(Material.LOG); + blacklisted_items.add(Material.LOG_2); + blacklisted_items.add(Material.LONG_GRASS); + blacklisted_items.add(Material.MAP); + blacklisted_items.add(Material.MELON_BLOCK); + blacklisted_items.add(Material.MELON_STEM); + blacklisted_items.add(Material.MOB_SPAWNER); + blacklisted_items.add(Material.MONSTER_EGG); + blacklisted_items.add(Material.MONSTER_EGGS); + blacklisted_items.add(Material.MYCEL); + blacklisted_items.add(Material.NAME_TAG); + blacklisted_items.add(Material.NETHER_STALK); + blacklisted_items.add(Material.NETHER_WARTS); + blacklisted_items.add(Material.MYCEL); + blacklisted_items.add(Material.PISTON_EXTENSION); + blacklisted_items.add(Material.PISTON_MOVING_PIECE); + blacklisted_items.add(Material.POISONOUS_POTATO); + blacklisted_items.add(Material.PORTAL); + blacklisted_items.add(Material.POTATO); + blacklisted_items.add(Material.PUMPKIN_STEM); + blacklisted_items.add(Material.PURPUR_DOUBLE_SLAB); + blacklisted_items.add(Material.QUARTZ_ORE); + blacklisted_items.add(Material.RECORD_10); + blacklisted_items.add(Material.RECORD_11); + blacklisted_items.add(Material.RECORD_12); + blacklisted_items.add(Material.RECORD_3); + blacklisted_items.add(Material.RECORD_4); + blacklisted_items.add(Material.RECORD_5); + blacklisted_items.add(Material.RECORD_6); + blacklisted_items.add(Material.RECORD_7); + blacklisted_items.add(Material.RECORD_8); + blacklisted_items.add(Material.RECORD_9); + blacklisted_items.add(Material.RED_ROSE); + blacklisted_items.add(Material.REDSTONE_COMPARATOR_OFF); + blacklisted_items.add(Material.REDSTONE_COMPARATOR_ON); + blacklisted_items.add(Material.REDSTONE_LAMP_OFF); + blacklisted_items.add(Material.REDSTONE_LAMP_ON); + blacklisted_items.add(Material.REDSTONE_ORE); + blacklisted_items.add(Material.REDSTONE_TORCH_OFF); + blacklisted_items.add(Material.REDSTONE_WIRE); + blacklisted_items.add(Material.SAPLING); + blacklisted_items.add(Material.SIGN_POST); + blacklisted_items.add(Material.WALL_SIGN); + blacklisted_items.add(Material.SKULL); + blacklisted_items.add(Material.SKULL_ITEM); + blacklisted_items.add(Material.SNOW); + blacklisted_items.add(Material.SOIL); + blacklisted_items.add(Material.SPONGE); + blacklisted_items.add(Material.SPRUCE_DOOR); + blacklisted_items.add(Material.STANDING_BANNER); + blacklisted_items.add(Material.STATIONARY_LAVA); + blacklisted_items.add(Material.STATIONARY_WATER); + blacklisted_items.add(Material.STEP); + blacklisted_items.add(Material.STONE_SLAB2); + blacklisted_items.add(Material.STRUCTURE_BLOCK); + blacklisted_items.add(Material.SUGAR_CANE_BLOCK); + blacklisted_items.add(Material.TRIPWIRE); + blacklisted_items.add(Material.VINE); + blacklisted_items.add(Material.WALL_BANNER); + blacklisted_items.add(Material.WATCH); + blacklisted_items.add(Material.WATER); + blacklisted_items.add(Material.WOOD_DOUBLE_STEP); + blacklisted_items.add(Material.WOODEN_DOOR); + blacklisted_items.add(Material.WOOD_DOOR); + blacklisted_items.add(Material.YELLOW_FLOWER); + Material selectedMat = Material.values()[(int)(Math.random()*Material.values().length)]; + while (blacklisted_items.contains(selectedMat)) { + //RE-roll if it's a black-listed item. + selectedMat = Material.values()[(int)(Math.random()*Material.values().length)]; + } + return selectedMat; + } +} \ No newline at end of file diff --git a/src/sig/plugin/TwosideKeeper/HelperStructures/MonsterDifficulty.java b/src/sig/plugin/TwosideKeeper/HelperStructures/MonsterDifficulty.java new file mode 100644 index 0000000..6ea2228 --- /dev/null +++ b/src/sig/plugin/TwosideKeeper/HelperStructures/MonsterDifficulty.java @@ -0,0 +1,8 @@ +package sig.plugin.TwosideKeeper.HelperStructures; + +public enum MonsterDifficulty { + NORMAL, + DANGEROUS, + DEADLY, + HELLFIRE +} diff --git a/src/sig/plugin/TwosideKeeper/HelperStructures/MonsterType.java b/src/sig/plugin/TwosideKeeper/HelperStructures/MonsterType.java new file mode 100644 index 0000000..ad74e9c --- /dev/null +++ b/src/sig/plugin/TwosideKeeper/HelperStructures/MonsterType.java @@ -0,0 +1,17 @@ +package sig.plugin.TwosideKeeper.HelperStructures; + +public enum MonsterType { + BLAZE, + CAVESPIDER, + CREEPER, + ENDERMAN, + GIANT, + GUARDIAN, + PIGZOMBIE, + SILVERFISH, + SKELETON, + SPIDER, + WITCH, + WITHER, + ZOMBIE +} diff --git a/src/sig/plugin/TwosideKeeper/HelperStructures/QuestStatus.java b/src/sig/plugin/TwosideKeeper/HelperStructures/QuestStatus.java new file mode 100644 index 0000000..2901d1f --- /dev/null +++ b/src/sig/plugin/TwosideKeeper/HelperStructures/QuestStatus.java @@ -0,0 +1,6 @@ +package sig.plugin.TwosideKeeper.HelperStructures; + +public enum QuestStatus { + UNFORMED, + IN_PROGRESS +} diff --git a/src/sig/plugin/TwosideKeeper/HelperStructures/Rank.java b/src/sig/plugin/TwosideKeeper/HelperStructures/Rank.java new file mode 100644 index 0000000..8821dd0 --- /dev/null +++ b/src/sig/plugin/TwosideKeeper/HelperStructures/Rank.java @@ -0,0 +1,37 @@ +package sig.plugin.TwosideKeeper.HelperStructures; + +import org.bukkit.Color; + +/** + * Rank structure + * + * Defines a rank a player can be on the server. + * Each rank has a color and a "canX" permission + * for each permission they can do. + * + * @author Joshua Sigona + * + */ +public class Rank { + public String name; + public Color color; + public boolean + canBreak, + canBuild, + canChat, + canFly, + canItemGive; + /** + * Rank sets up a rank. You have to define specific permissions with 'true' and 'false' separately. + * @param name + * @param color + */ + public Rank(String name, Color color) { + this.name = name; + this.color = color; + + //Set default permissions. + this.canBreak=this.canBuild=this.canChat=true; + this.canFly=this.canItemGive=false; + } +} diff --git a/src/sig/plugin/TwosideKeeper/HelperStructures/SessionState.java b/src/sig/plugin/TwosideKeeper/HelperStructures/SessionState.java new file mode 100644 index 0000000..ab20338 --- /dev/null +++ b/src/sig/plugin/TwosideKeeper/HelperStructures/SessionState.java @@ -0,0 +1,9 @@ +package sig.plugin.TwosideKeeper.HelperStructures; + +public enum SessionState { + CREATE, //Creating a shop. Asks for amount to put in. + PRICE, //Creating a shop. Asks for price of each unit. + EDIT, //Editing a shop. Asks for amount to put in or take out. + UPDATE, //Editing a shop. Asks for new price of each unit. + PURCHASE +} diff --git a/src/sig/plugin/TwosideKeeper/HelperStructures/ShopPurchase.java b/src/sig/plugin/TwosideKeeper/HelperStructures/ShopPurchase.java new file mode 100644 index 0000000..65205d7 --- /dev/null +++ b/src/sig/plugin/TwosideKeeper/HelperStructures/ShopPurchase.java @@ -0,0 +1,37 @@ +package sig.plugin.TwosideKeeper.HelperStructures; + +import java.text.DecimalFormat; + +import org.bukkit.ChatColor; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +import sig.plugin.TwosideKeeper.TwosideKeeper; + +public class ShopPurchase { + String player; + String customer; + String itemname; + double money; + int amt; + + public ShopPurchase(String p, Player customer, ItemStack item, double money, int amt) { + player = p; + this.customer=customer.getName(); + itemname = TwosideKeeper.GetItemName(item); + this.money = money; + this.amt=amt; + } + + public String getPlayer() { + return player; + } + public String getCustomer() { + return customer; + } + + public String announcementString() { + DecimalFormat df = new DecimalFormat("0.00"); + return "Player "+ChatColor.BLUE+customer+ChatColor.WHITE+" has purchased "+ChatColor.YELLOW+amt+ChatColor.WHITE+" of your "+ChatColor.YELLOW+itemname+". You have earned $"+df.format(money)+". "+ChatColor.GRAY+""+ChatColor.ITALIC+"(See /money)"; + } +} \ No newline at end of file diff --git a/src/sig/plugin/TwosideKeeper/HelperStructures/SpleefArena.java b/src/sig/plugin/TwosideKeeper/HelperStructures/SpleefArena.java new file mode 100644 index 0000000..445d2cc --- /dev/null +++ b/src/sig/plugin/TwosideKeeper/HelperStructures/SpleefArena.java @@ -0,0 +1,6 @@ +package sig.plugin.TwosideKeeper.HelperStructures; + +public enum SpleefArena { + //Three constants. + SMALL, LARGE, LAYERED +} diff --git a/src/sig/plugin/TwosideKeeper/HelperStructures/WorldShop.java b/src/sig/plugin/TwosideKeeper/HelperStructures/WorldShop.java new file mode 100644 index 0000000..5597e65 --- /dev/null +++ b/src/sig/plugin/TwosideKeeper/HelperStructures/WorldShop.java @@ -0,0 +1,258 @@ +package sig.plugin.TwosideKeeper.HelperStructures; + +import java.util.ArrayList; +import java.util.List; + +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.block.Sign; +import org.bukkit.enchantments.Enchantment; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.EnchantmentStorageMeta; +import org.bukkit.material.MaterialData; +import org.bukkit.potion.PotionType; + +import sig.plugin.TwosideKeeper.TwosideKeeper; + +public class WorldShop { + ItemStack item; + String owner; + double price; + int amt; + int id; + + public WorldShop (ItemStack i, int amt, double p, String player, int shopID) { + this.item=i; + this.price=p; + this.owner=player; + this.amt = amt; + this.id = shopID; + } + + public String GetItemName() { + if (this.item.hasItemMeta() && + this.item.getItemMeta().hasDisplayName()) { + return this.item.getItemMeta().getDisplayName(); + } else { + return TwosideKeeper.UserFriendlyMaterialName(this.item); + } + } + public void UpdateAmount(int amt) { + this.amt=amt; + } + public void UpdateUnitPrice(double price) { + this.price=price; + } + + public ItemStack GetItem() { + return item; + } + public double GetUnitPrice() { + return price; + } + public int getID() { + return id; + } + public int GetAmount() { + if (owner.equalsIgnoreCase("admin")) { + return 10000; + } else { + return amt; + } + } + public String GetOwner() { + return owner; + } + + public String toString() { + return "WorldShop:{Item:"+item.toString()+",Price:"+price+",Amount:"+amt+",Owner:"+owner+"}"; + } + + public static String GetItemInfo(ItemStack item) { + //Gets all the info about this item in one gigantic string. (Separated by new lines. Useful for tellraw()). + String message = ""; + for (int i=0;i=128) { + //This is a 95% chance this will despawn. + if (Math.random()<=0.95) { + ent.remove(); + return false; + } else { + if (isZombieLeader(ent)) { + Monster m = (Monster)ent; + m.setCustomName(ChatColor.WHITE+"Zombie Leader"); + } + return true; + } + } else + if (ylv>=64) { + //This is a 90% chance this will despawn. + if (Math.random()<=0.90) { + ent.remove(); + return false; + } else { + if (isZombieLeader(ent)) { + Monster m = (Monster)ent; + m.setCustomName(ChatColor.WHITE+"Zombie Leader"); + } + return true; + } + } else + if (ylv>=48) { + //"Normal" spawn rate. We're going to decrease it a bit for the time being. + //This is a 50% chance this will despawn. + if (Math.random()<=0.50) { + ent.remove(); + return false; + } else { + if (isZombieLeader(ent)) { + Monster m = (Monster)ent; + m.setCustomName(ChatColor.WHITE+"Zombie Leader"); + } + return true; + } + } else + if (ylv>=32) { + //Change mobs in this range to 'Dangerous' versions. Zombies and skeletons also get armor. + Monster m = (Monster)(ent); + MonsterDifficulty md = MonsterDifficulty.DANGEROUS; + convertMonster(m,md); + return true; + } else + if (ylv>=16) { + MonsterDifficulty md = MonsterDifficulty.DEADLY; + //Change mobs in this range to 'Dangerous' versions. Zombies and skeletons also get armor. + Monster m = (Monster)(ent); + convertMonster(m,md); + return true; + } else + { + //Change mobs in this range to 'Dangerous' versions. Zombies and skeletons also get armor. + MonsterDifficulty md = MonsterDifficulty.HELLFIRE; + Monster m = (Monster)(ent); + convertMonster(m,md); + return true; + } + } + private static void RandomizeEquipment(Monster m, int lv) { + /* + * Lv1: Leather/Iron Armor. + * Lv2: Iron/Diamond Armor. + * Lv3: Diamond Armor. + */ + switch (lv) { + case 1:{ + if (Math.random()<0.5) { + m.getEquipment().setHelmet(new ItemStack(Material.LEATHER_HELMET)); + m.getEquipment().getHelmet().setDurability((short)Math.round(Math.random()*128)); + } else { + m.getEquipment().setHelmet(new ItemStack(Material.IRON_HELMET)); + m.getEquipment().getHelmet().setDurability((short)Math.round(Math.random()*128)); + } + if (Math.random()<0.5) { + m.getEquipment().setChestplate(new ItemStack(Material.LEATHER_CHESTPLATE)); + m.getEquipment().getChestplate().setDurability((short)Math.round(Math.random()*128)); + } else { + m.getEquipment().setChestplate(new ItemStack(Material.IRON_CHESTPLATE)); + m.getEquipment().getChestplate().setDurability((short)Math.round(Math.random()*128)); + } + if (Math.random()<0.5) { + m.getEquipment().setLeggings(new ItemStack(Material.LEATHER_LEGGINGS)); + m.getEquipment().getLeggings().setDurability((short)Math.round(Math.random()*128)); + } else { + m.getEquipment().setLeggings(new ItemStack(Material.IRON_LEGGINGS)); + m.getEquipment().getLeggings().setDurability((short)Math.round(Math.random()*128)); + } + if (Math.random()<0.5) { + m.getEquipment().setBoots(new ItemStack(Material.LEATHER_BOOTS)); + m.getEquipment().getBoots().setDurability((short)Math.round(Math.random()*128)); + } else { + m.getEquipment().setBoots(new ItemStack(Material.IRON_BOOTS)); + m.getEquipment().getBoots().setDurability((short)Math.round(Math.random()*128)); + } + if (m.getEquipment().getHelmet()!=null && Math.random()<0.3) { + m.getEquipment().setHelmet(RandomizeEnchantments(m.getEquipment().getHelmet(),ItemRarity.RARE)); + if (Math.random()20) || + (md==MonsterDifficulty.DANGEROUS && ent.getMaxHealth()>20*2) || + (md==MonsterDifficulty.NORMAL && ent.getMaxHealth()>20*2) || + (md==MonsterDifficulty.NORMAL && ent.getMaxHealth()>20*4) + ) + { + return true; + } else { + return false; + } + } else { + return false; + } + } + + public static Monster convertMonster(Monster m) { + if (m.getLocation().getY()<48) { + if (m.getLocation().getY()>=32) + return convertMonster(m,MonsterDifficulty.DANGEROUS); + else if (m.getLocation().getY()>=16) + return convertMonster(m,MonsterDifficulty.DEADLY); + else + return convertMonster(m,MonsterDifficulty.HELLFIRE); + } else { + return convertMonster(m,MonsterDifficulty.NORMAL); + } + } + + public static MonsterDifficulty getMonsterDifficulty(Monster m) { + if (m.getCustomName()!=null) { + if (m.getCustomName().contains("Dangerous")) { + return MonsterDifficulty.DANGEROUS; + } else + if (m.getCustomName().contains("Deadly")) { + return MonsterDifficulty.DEADLY; + } else + if (m.getCustomName().contains("Hellfire")) { + return MonsterDifficulty.HELLFIRE; + } else + { + return MonsterDifficulty.NORMAL; + } + } else { + return MonsterDifficulty.NORMAL; + } + } + + public static Monster convertMonster(Monster m, MonsterDifficulty md) { + switch (md) { + case DANGEROUS: { + String MonsterName = m.getType().toString().toLowerCase(); + m.setCustomName(ChatColor.DARK_AQUA+"Dangerous "+TwosideKeeper.CapitalizeFirstLetters(MonsterName.replaceAll("_", " ")+(isZombieLeader(m)?" Leader":""))); + m.setMaxHealth(m.getMaxHealth()*2.0); + m.setHealth(m.getMaxHealth()); + if (isAllowedToEquipItems(m)) { + m.getEquipment().clear(); + RandomizeEquipment(m,1); + } + }break; + case DEADLY: { + String MonsterName = m.getType().toString().toLowerCase(); + m.setCustomName(ChatColor.GOLD+"Deadly "+TwosideKeeper.CapitalizeFirstLetters(MonsterName.replaceAll("_", " ")+(isZombieLeader(m)?" Leader":""))); + m.setMaxHealth(m.getMaxHealth()*2.0); + m.setHealth(m.getMaxHealth()); + if (isAllowedToEquipItems(m)) { + m.getEquipment().clear(); + RandomizeEquipment(m,2); + } + m.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE,99999,1)); + }break; + case HELLFIRE:{ + String MonsterName = m.getType().toString().toLowerCase(); + m.setCustomName(ChatColor.DARK_RED+"Hellfire "+TwosideKeeper.CapitalizeFirstLetters(MonsterName.replaceAll("_", " ")+(isZombieLeader(m)?" Leader":""))); + //m.setCustomName(ChatColor.DARK_AQUA+"Dangerous Mob"); + //m.setCustomNameVisible(true); + m.setMaxHealth(m.getMaxHealth()*4.0); + m.setHealth(m.getMaxHealth()); + m.setFireTicks(999999); + if (isAllowedToEquipItems(m)) { + m.getEquipment().clear(); + RandomizeEquipment(m,3); + } + m.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE,99999,1)); + m.addPotionEffect(new PotionEffect(PotionEffectType.FIRE_RESISTANCE,99999,1)); + if (Math.random()<=0.2) {m.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION,99999,1));} + }break; + default: { + if (isAllowedToEquipItems(m)) { + m.getEquipment().clear(); + RandomizeEquipment(m,0); + } + if (isZombieLeader(m)) { + m.setCustomName(ChatColor.WHITE+"Zombie Leader"); + } + }break; + } + return m; + } + + private static boolean isAllowedToEquipItems(Monster m) { + if (m.getType()==EntityType.ZOMBIE || + m.getType()==EntityType.PIG_ZOMBIE || + m.getType()==EntityType.SKELETON || + m.getType()==EntityType.GIANT) { + return true; + } else { + return false; + } + } + + public static Monster spawnAdjustedMonster(MonsterType mt,Location loc) { + EntityType et; + switch(mt) { + case BLAZE: + et=EntityType.BLAZE; + break; + case CAVESPIDER: + et=EntityType.CAVE_SPIDER; + break; + case CREEPER: + et=EntityType.CREEPER; + break; + case ENDERMAN: + et=EntityType.ENDERMAN; + break; + case GIANT: + et=EntityType.GIANT; + break; + case GUARDIAN: + et=EntityType.GUARDIAN; + break; + case PIGZOMBIE: + et=EntityType.PIG_ZOMBIE; + break; + case SILVERFISH: + et=EntityType.SILVERFISH; + break; + case SKELETON: + et=EntityType.SKELETON; + break; + case SPIDER: + et=EntityType.SPIDER; + break; + case WITCH: + et=EntityType.WITCH; + break; + case WITHER: + et=EntityType.WITHER; + break; + case ZOMBIE: + et=EntityType.ZOMBIE; + break; + default: + et=EntityType.ZOMBIE; + } + Monster m = (Monster)loc.getWorld().spawnEntity(loc, et); + return MonsterController.convertMonster(m); + } +} diff --git a/src/sig/plugin/TwosideKeeper/Party.java b/src/sig/plugin/TwosideKeeper/Party.java new file mode 100644 index 0000000..f89706d --- /dev/null +++ b/src/sig/plugin/TwosideKeeper/Party.java @@ -0,0 +1,211 @@ +package sig.plugin.TwosideKeeper; + +import java.util.ArrayList; +import java.util.List; + +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.Color; +import org.bukkit.Location; +import org.bukkit.entity.Player; +import org.bukkit.scoreboard.DisplaySlot; + +public class Party { + public List partyplayers; + int color; + Location region; + + Party(int color, Location rawPos) { + partyplayers = new ArrayList(); + rawPos.setX((int)(rawPos.getX()/(16*TwosideKeeper.PARTY_CHUNK_SIZE))*(16*TwosideKeeper.PARTY_CHUNK_SIZE)); + rawPos.setZ((int)(rawPos.getZ()/(16*TwosideKeeper.PARTY_CHUNK_SIZE))*(16*TwosideKeeper.PARTY_CHUNK_SIZE)); + region=rawPos; + Bukkit.getLogger().info(region.toString()); + Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "scoreboard objectives remove Party"+color); //Make sure the party is cleared out if it was used for something before... + //Bukkit.getScoreboardManager().getMainScoreboard().registerNewObjective("Party"+color, "dummy"); + Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "scoreboard objectives add Party"+color+" dummy Your Party"); + //Bukkit.getScoreboardManager().getMainScoreboard().getObjective("Party"+color).setDisplaySlot(DisplaySlot.SIDEBAR); + String color_txt = ""; + Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "scoreboard objectives setdisplay sidebar.team."+ConvertColor(color)+" Party"+color); + this.color=color; + } + + String ConvertColor(int val) { + + switch (val%16) { + case 0:{ + return "white"; + } + case 1:{ + return "yellow"; + } + case 2:{ + return "light_purple"; + } + case 3:{ + return "red"; + } + case 4:{ + return "aqua"; + } + case 5:{ + return "green"; + } + case 6:{ + return "blue"; + } + case 7:{ + return "dark_gray"; + } + case 8:{ + return "gray"; + } + case 9:{ + return "gold"; + } + case 10:{ + return "dark_purple"; + } + case 11:{ + return "dark_red"; + } + case 12:{ + return "dark_aqua"; + } + case 13:{ + return "dark_green"; + } + case 14:{ + return "dark_blue"; + } + case 15:{ + return "black"; + } + default:{ + return "white"; + } + } + } + + public void addPlayer(Player p) { + partyplayers.add(p); + for (int l=0;l=2) { + //partyplayers.get(l).sendMessage(ChatColor.ITALIC+""+ChatColor.GOLD+"Party Bonuses Applied: "+ChatColor.BLUE+"+"+(partyplayers.size()-1)+"0% damage + defense for "+partyplayers.size()+" party members. Drop Rate +"+(partyplayers.size()-1)+"0%"); + } + } + } + } + Bukkit.dispatchCommand(Bukkit.getServer().getConsoleSender(), "scoreboard players set "+p.getName().toLowerCase()+" Party"+color+" "+partyplayers.size()*-1); + Bukkit.dispatchCommand(Bukkit.getServer().getConsoleSender(), "scoreboard teams option "+p.getName().toLowerCase()+" color "+ConvertColor(color)); + } + + public void sortPlayers() { + //Sorts the players on the scoreboard by proper health values. + List sortedorder = new ArrayList(); + int lasti=-1; //The last player that had less health than you did. + for (int i=0;ipartyplayers.get(i).getHealth()) { + lasti=-1; + } else { + lasti=j; //This means our health is bigger. We go here. + break; + } + } + if (lasti==-1) { + //This just gets inserted. + sortedorder.add(partyplayers.get(i)); + } else { + sortedorder.add(lasti,partyplayers.get(i)); + } + } + for (int i=0;i=2) { + //partyplayers.get(i).sendMessage(ChatColor.DARK_GRAY+""+ChatColor.ITALIC+"Party buffs removed."); + } + partyplayers.remove(i); + i--; + } + } + if (prevsiz!=partyplayers.size()) { + for (int i=0;i item_ItemCube_lore = new ArrayList(); + item_ItemCube_lore.add("A storage container that can"); + item_ItemCube_lore.add("be carried around. "+ChatColor.GOLD+"Open by"); + item_ItemCube_lore.add(ChatColor.GOLD+"right-clicking."); + ItemMeta item_ItemCube_meta=item_ItemCube.getItemMeta(); + item_ItemCube_meta.setLore(item_ItemCube_lore); + item_ItemCube_meta.setDisplayName("Item Cube"); + item_ItemCube.setItemMeta(item_ItemCube_meta); + + ShapedRecipe ItemCube = new ShapedRecipe(item_ItemCube); + ItemCube.shape("ppp","pcp","ppp"); + ItemCube.setIngredient('p', Material.WOOD, -1); + ItemCube.setIngredient('c', Material.CHEST); + + Bukkit.addRecipe(ItemCube); + //------------------------------ + item_ItemCube = new ItemStack(Material.STORAGE_MINECART); + item_ItemCube_meta=item_ItemCube.getItemMeta(); + item_ItemCube_meta.setLore(item_ItemCube_lore); + item_ItemCube_meta.setDisplayName("Large Item Cube"); + item_ItemCube.setItemMeta(item_ItemCube_meta); + + ItemCube = new ShapedRecipe(item_ItemCube); + ItemCube.shape("ppp","gcg","ppp"); + ItemCube.setIngredient('p', Material.WOOD, -1); + ItemCube.setIngredient('g', Material.GOLD_BLOCK); + ItemCube.setIngredient('c', Material.CHEST); + + Bukkit.addRecipe(ItemCube); + //------------------------------ + item_ItemCube = new ItemStack(Material.ENDER_CHEST); + item_ItemCube_meta=item_ItemCube.getItemMeta(); + item_ItemCube_meta.setLore(item_ItemCube_lore); + item_ItemCube_meta.setDisplayName("Ender Item Cube"); + item_ItemCube.setItemMeta(item_ItemCube_meta); + + ItemCube = new ShapedRecipe(item_ItemCube); + ItemCube.shape("ooo","ece","ooo"); + ItemCube.setIngredient('o', Material.OBSIDIAN); + ItemCube.setIngredient('e', Material.EMERALD); + ItemCube.setIngredient('c', Material.ENDER_CHEST); + + Bukkit.addRecipe(ItemCube); + //------------------------------ + } + public static void Initialize_ArrowQuiver_Recipe() { + ItemStack arrow_quiver = new ItemStack(Material.TIPPED_ARROW); + + List arrow_quiver_lore = new ArrayList(); + arrow_quiver_lore.add("A quiver that holds many arrows."); + arrow_quiver_lore.add(ChatColor.GRAY+"Arrows Remaining: "+ChatColor.YELLOW+"5"); + ItemMeta arrow_quiver_meta=arrow_quiver.getItemMeta(); + arrow_quiver_meta.setLore(arrow_quiver_lore); + arrow_quiver_meta.setDisplayName(ChatColor.BLUE+"Arrow Quiver"); + arrow_quiver.setItemMeta(arrow_quiver_meta); + + arrow_quiver.addUnsafeEnchantment(Enchantment.ARROW_INFINITE, 5); + + arrow_quiver.setAmount(1); + + ShapedRecipe ArrowQuiver = new ShapedRecipe(arrow_quiver); + ArrowQuiver.shape("xle","lsl","xlx"); + ArrowQuiver.setIngredient('s', Material.SPECTRAL_ARROW); + ArrowQuiver.setIngredient('l', Material.LEATHER); + ArrowQuiver.setIngredient('e', Material.EMERALD_BLOCK); + + Bukkit.addRecipe(ArrowQuiver); + } + public static void Initialize_BlockArmor_Recipes() { + ItemStack blockarmorpc = new ItemStack(Material.IRON_HELMET); + + List blockarmorpc_lore = new ArrayList(); + blockarmorpc_lore.add(ChatColor.BLUE+""+ChatColor.ITALIC+"Hardened Armor"); + blockarmorpc_lore.add(ChatColor.GRAY+"Twice as strong"); + blockarmorpc_lore.add(ChatColor.GRAY+"Breaks Remaining: "+ChatColor.YELLOW+"4"); + ItemMeta blockarmorpc_meta=blockarmorpc.getItemMeta(); + blockarmorpc_meta.setLore(blockarmorpc_lore); + blockarmorpc_meta.setDisplayName(ChatColor.BLUE+"Hardened Iron Helmet"); + blockarmorpc.setItemMeta(blockarmorpc_meta); + + ShapedRecipe BlockArmor = new ShapedRecipe(blockarmorpc); + BlockArmor.shape("aaa","axa","xxx"); + BlockArmor.setIngredient('a', Material.IRON_BLOCK); + + Bukkit.addRecipe(BlockArmor); + //-------------------------------------------- + blockarmorpc = new ItemStack(Material.IRON_CHESTPLATE); + + blockarmorpc_lore = new ArrayList(); + blockarmorpc_lore.add(ChatColor.BLUE+""+ChatColor.ITALIC+"Hardened Armor"); + blockarmorpc_lore.add(ChatColor.GRAY+"Twice as strong"); + blockarmorpc_lore.add(ChatColor.GRAY+"Breaks Remaining: "+ChatColor.YELLOW+"4"); + blockarmorpc_meta=blockarmorpc.getItemMeta(); + blockarmorpc_meta.setLore(blockarmorpc_lore); + blockarmorpc_meta.setDisplayName(ChatColor.BLUE+"Hardened Iron Chestplate"); + blockarmorpc.setItemMeta(blockarmorpc_meta); + + BlockArmor = new ShapedRecipe(blockarmorpc); + BlockArmor.shape("axa","aaa","aaa"); + BlockArmor.setIngredient('a', Material.IRON_BLOCK); + + Bukkit.addRecipe(BlockArmor); + //-------------------------------------------- + blockarmorpc = new ItemStack(Material.IRON_LEGGINGS); + + blockarmorpc_lore = new ArrayList(); + blockarmorpc_lore.add(ChatColor.BLUE+""+ChatColor.ITALIC+"Hardened Armor"); + blockarmorpc_lore.add(ChatColor.GRAY+"Twice as strong"); + blockarmorpc_lore.add(ChatColor.GRAY+"Breaks Remaining: "+ChatColor.YELLOW+"4"); + blockarmorpc_meta=blockarmorpc.getItemMeta(); + blockarmorpc_meta.setLore(blockarmorpc_lore); + blockarmorpc_meta.setDisplayName(ChatColor.BLUE+"Hardened Iron Leggings"); + blockarmorpc.setItemMeta(blockarmorpc_meta); + + BlockArmor = new ShapedRecipe(blockarmorpc); + BlockArmor.shape("aaa","axa","axa"); + BlockArmor.setIngredient('a', Material.IRON_BLOCK); + + Bukkit.addRecipe(BlockArmor); + //-------------------------------------------- + blockarmorpc = new ItemStack(Material.IRON_BOOTS); + + blockarmorpc_lore = new ArrayList(); + blockarmorpc_lore.add(ChatColor.BLUE+""+ChatColor.ITALIC+"Hardened Armor"); + blockarmorpc_lore.add(ChatColor.GRAY+"Twice as strong"); + blockarmorpc_lore.add(ChatColor.GRAY+"Breaks Remaining: "+ChatColor.YELLOW+"4"); + blockarmorpc_meta=blockarmorpc.getItemMeta(); + blockarmorpc_meta.setLore(blockarmorpc_lore); + blockarmorpc_meta.setDisplayName(ChatColor.BLUE+"Hardened Iron Boots"); + blockarmorpc.setItemMeta(blockarmorpc_meta); + + BlockArmor = new ShapedRecipe(blockarmorpc); + BlockArmor.shape("axa","axa"); + BlockArmor.setIngredient('a', Material.IRON_BLOCK); + + Bukkit.addRecipe(BlockArmor); + //-------------------------------------------- + blockarmorpc = new ItemStack(Material.GOLD_HELMET); + + blockarmorpc_lore = new ArrayList(); + blockarmorpc_lore.add(ChatColor.BLUE+""+ChatColor.ITALIC+"Hardened Armor"); + blockarmorpc_lore.add(ChatColor.GRAY+"Twice as strong"); + blockarmorpc_lore.add(ChatColor.GRAY+"Breaks Remaining: "+ChatColor.YELLOW+"4"); + blockarmorpc_meta=blockarmorpc.getItemMeta(); + blockarmorpc_meta.setLore(blockarmorpc_lore); + blockarmorpc_meta.setDisplayName(ChatColor.BLUE+"Hardened Gold Helmet"); + blockarmorpc.setItemMeta(blockarmorpc_meta); + + BlockArmor = new ShapedRecipe(blockarmorpc); + BlockArmor.shape("aaa","axa","xxx"); + BlockArmor.setIngredient('a', Material.GOLD_BLOCK); + + Bukkit.addRecipe(BlockArmor); + //-------------------------------------------- + blockarmorpc = new ItemStack(Material.GOLD_CHESTPLATE); + + blockarmorpc_lore = new ArrayList(); + blockarmorpc_lore.add(ChatColor.BLUE+""+ChatColor.ITALIC+"Hardened Armor"); + blockarmorpc_lore.add(ChatColor.GRAY+"Twice as strong"); + blockarmorpc_lore.add(ChatColor.GRAY+"Breaks Remaining: "+ChatColor.YELLOW+"4"); + blockarmorpc_meta=blockarmorpc.getItemMeta(); + blockarmorpc_meta.setLore(blockarmorpc_lore); + blockarmorpc_meta.setDisplayName(ChatColor.BLUE+"Hardened Gold Chestplate"); + blockarmorpc.setItemMeta(blockarmorpc_meta); + + BlockArmor = new ShapedRecipe(blockarmorpc); + BlockArmor.shape("axa","aaa","aaa"); + BlockArmor.setIngredient('a', Material.GOLD_BLOCK); + + Bukkit.addRecipe(BlockArmor); + //-------------------------------------------- + blockarmorpc = new ItemStack(Material.GOLD_LEGGINGS); + + blockarmorpc_lore = new ArrayList(); + blockarmorpc_lore.add(ChatColor.BLUE+""+ChatColor.ITALIC+"Hardened Armor"); + blockarmorpc_lore.add(ChatColor.GRAY+"Twice as strong"); + blockarmorpc_lore.add(ChatColor.GRAY+"Breaks Remaining: "+ChatColor.YELLOW+"4"); + blockarmorpc_meta=blockarmorpc.getItemMeta(); + blockarmorpc_meta.setLore(blockarmorpc_lore); + blockarmorpc_meta.setDisplayName(ChatColor.BLUE+"Hardened Gold Leggings"); + blockarmorpc.setItemMeta(blockarmorpc_meta); + + BlockArmor = new ShapedRecipe(blockarmorpc); + BlockArmor.shape("aaa","axa","axa"); + BlockArmor.setIngredient('a', Material.GOLD_BLOCK); + + Bukkit.addRecipe(BlockArmor); + //-------------------------------------------- + blockarmorpc = new ItemStack(Material.GOLD_BOOTS); + + blockarmorpc_lore = new ArrayList(); + blockarmorpc_lore.add(ChatColor.BLUE+""+ChatColor.ITALIC+"Hardened Armor"); + blockarmorpc_lore.add(ChatColor.GRAY+"Twice as strong"); + blockarmorpc_lore.add(ChatColor.GRAY+"Breaks Remaining: "+ChatColor.YELLOW+"4"); + blockarmorpc_meta=blockarmorpc.getItemMeta(); + blockarmorpc_meta.setLore(blockarmorpc_lore); + blockarmorpc_meta.setDisplayName(ChatColor.BLUE+"Hardened Gold Boots"); + blockarmorpc.setItemMeta(blockarmorpc_meta); + + BlockArmor = new ShapedRecipe(blockarmorpc); + BlockArmor.shape("axa","axa"); + BlockArmor.setIngredient('a', Material.GOLD_BLOCK); + + Bukkit.addRecipe(BlockArmor); + //-------------------------------------------- + blockarmorpc = new ItemStack(Material.DIAMOND_HELMET); + + blockarmorpc_lore = new ArrayList(); + blockarmorpc_lore.add(ChatColor.BLUE+""+ChatColor.ITALIC+"Hardened Armor"); + blockarmorpc_lore.add(ChatColor.GRAY+"Twice as strong"); + blockarmorpc_lore.add(ChatColor.GRAY+"Breaks Remaining: "+ChatColor.YELLOW+"4"); + blockarmorpc_meta=blockarmorpc.getItemMeta(); + blockarmorpc_meta.setLore(blockarmorpc_lore); + blockarmorpc_meta.setDisplayName(ChatColor.BLUE+"Hardened Diamond Helmet"); + blockarmorpc.setItemMeta(blockarmorpc_meta); + + BlockArmor = new ShapedRecipe(blockarmorpc); + BlockArmor.shape("aaa","axa","xxx"); + BlockArmor.setIngredient('a', Material.DIAMOND_BLOCK); + + Bukkit.addRecipe(BlockArmor); + //-------------------------------------------- + blockarmorpc = new ItemStack(Material.DIAMOND_CHESTPLATE); + + blockarmorpc_lore = new ArrayList(); + blockarmorpc_lore.add(ChatColor.BLUE+""+ChatColor.ITALIC+"Hardened Armor"); + blockarmorpc_lore.add(ChatColor.GRAY+"Twice as strong"); + blockarmorpc_lore.add(ChatColor.GRAY+"Breaks Remaining: "+ChatColor.YELLOW+"4"); + blockarmorpc_meta=blockarmorpc.getItemMeta(); + blockarmorpc_meta.setLore(blockarmorpc_lore); + blockarmorpc_meta.setDisplayName(ChatColor.BLUE+"Hardened Diamond Chestplate"); + blockarmorpc.setItemMeta(blockarmorpc_meta); + + BlockArmor = new ShapedRecipe(blockarmorpc); + BlockArmor.shape("axa","aaa","aaa"); + BlockArmor.setIngredient('a', Material.DIAMOND_BLOCK); + + Bukkit.addRecipe(BlockArmor); + //-------------------------------------------- + blockarmorpc = new ItemStack(Material.DIAMOND_LEGGINGS); + + blockarmorpc_lore = new ArrayList(); + blockarmorpc_lore.add(ChatColor.BLUE+""+ChatColor.ITALIC+"Hardened Armor"); + blockarmorpc_lore.add(ChatColor.GRAY+"Twice as strong"); + blockarmorpc_lore.add(ChatColor.GRAY+"Breaks Remaining: "+ChatColor.YELLOW+"4"); + blockarmorpc_meta=blockarmorpc.getItemMeta(); + blockarmorpc_meta.setLore(blockarmorpc_lore); + blockarmorpc_meta.setDisplayName(ChatColor.BLUE+"Hardened Diamond Leggings"); + blockarmorpc.setItemMeta(blockarmorpc_meta); + + BlockArmor = new ShapedRecipe(blockarmorpc); + BlockArmor.shape("aaa","axa","axa"); + BlockArmor.setIngredient('a', Material.DIAMOND_BLOCK); + + Bukkit.addRecipe(BlockArmor); + //-------------------------------------------- + blockarmorpc = new ItemStack(Material.DIAMOND_BOOTS); + + blockarmorpc_lore = new ArrayList(); + blockarmorpc_lore.add(ChatColor.BLUE+""+ChatColor.ITALIC+"Hardened Armor"); + blockarmorpc_lore.add(ChatColor.GRAY+"Twice as strong"); + blockarmorpc_lore.add(ChatColor.GRAY+"Breaks Remaining: "+ChatColor.YELLOW+"4"); + blockarmorpc_meta=blockarmorpc.getItemMeta(); + blockarmorpc_meta.setLore(blockarmorpc_lore); + blockarmorpc_meta.setDisplayName(ChatColor.BLUE+"Hardened Diamond Boots"); + blockarmorpc.setItemMeta(blockarmorpc_meta); + + BlockArmor = new ShapedRecipe(blockarmorpc); + BlockArmor.shape("axa","axa"); + BlockArmor.setIngredient('a', Material.DIAMOND_BLOCK); + + Bukkit.addRecipe(BlockArmor); + //-------------------------------------------- + } + public static void Initialize_ItemDeconstruction_Recipes() { + ShapelessRecipe decons_recipe = new ShapelessRecipe(new ItemStack(Material.LEATHER,4)); + decons_recipe.addIngredient(Material.LEATHER_BOOTS); + Bukkit.addRecipe(decons_recipe); + decons_recipe = new ShapelessRecipe(new ItemStack(Material.LEATHER,7)); + decons_recipe.addIngredient(Material.LEATHER_LEGGINGS); + Bukkit.addRecipe(decons_recipe); + decons_recipe = new ShapelessRecipe(new ItemStack(Material.LEATHER,8)); + decons_recipe.addIngredient(Material.LEATHER_CHESTPLATE); + Bukkit.addRecipe(decons_recipe); + decons_recipe = new ShapelessRecipe(new ItemStack(Material.LEATHER,5)); + decons_recipe.addIngredient(Material.LEATHER_HELMET); + Bukkit.addRecipe(decons_recipe); + decons_recipe = new ShapelessRecipe(new ItemStack(Material.WOOD,2)); + decons_recipe.addIngredient(Material.WOOD_SWORD); + Bukkit.addRecipe(decons_recipe); + decons_recipe = new ShapelessRecipe(new ItemStack(Material.WOOD,3)); + decons_recipe.addIngredient(Material.WOOD_AXE); + Bukkit.addRecipe(decons_recipe); + decons_recipe = new ShapelessRecipe(new ItemStack(Material.WOOD,3)); + decons_recipe.addIngredient(Material.WOOD_PICKAXE); + Bukkit.addRecipe(decons_recipe); + decons_recipe = new ShapelessRecipe(new ItemStack(Material.WOOD,2)); + decons_recipe.addIngredient(Material.WOOD_HOE); + Bukkit.addRecipe(decons_recipe); + decons_recipe = new ShapelessRecipe(new ItemStack(Material.WOOD,1)); + decons_recipe.addIngredient(Material.WOOD_SPADE); + Bukkit.addRecipe(decons_recipe); + decons_recipe = new ShapelessRecipe(new ItemStack(Material.COBBLESTONE,2)); + decons_recipe.addIngredient(Material.STONE_SWORD); + Bukkit.addRecipe(decons_recipe); + decons_recipe = new ShapelessRecipe(new ItemStack(Material.COBBLESTONE,3)); + decons_recipe.addIngredient(Material.STONE_AXE); + Bukkit.addRecipe(decons_recipe); + decons_recipe = new ShapelessRecipe(new ItemStack(Material.COBBLESTONE,3)); + decons_recipe.addIngredient(Material.STONE_PICKAXE); + Bukkit.addRecipe(decons_recipe); + decons_recipe = new ShapelessRecipe(new ItemStack(Material.COBBLESTONE,2)); + decons_recipe.addIngredient(Material.STONE_HOE); + Bukkit.addRecipe(decons_recipe); + decons_recipe = new ShapelessRecipe(new ItemStack(Material.COBBLESTONE,1)); + decons_recipe.addIngredient(Material.STONE_SPADE); + Bukkit.addRecipe(decons_recipe); + decons_recipe = new ShapelessRecipe(new ItemStack(Material.IRON_INGOT,4)); + decons_recipe.addIngredient(Material.IRON_BOOTS); + Bukkit.addRecipe(decons_recipe); + decons_recipe = new ShapelessRecipe(new ItemStack(Material.IRON_INGOT,7)); + decons_recipe.addIngredient(Material.IRON_LEGGINGS); + Bukkit.addRecipe(decons_recipe); + decons_recipe = new ShapelessRecipe(new ItemStack(Material.IRON_INGOT,8)); + decons_recipe.addIngredient(Material.IRON_CHESTPLATE); + Bukkit.addRecipe(decons_recipe); + decons_recipe = new ShapelessRecipe(new ItemStack(Material.IRON_INGOT,5)); + decons_recipe.addIngredient(Material.IRON_HELMET); + Bukkit.addRecipe(decons_recipe); + decons_recipe = new ShapelessRecipe(new ItemStack(Material.IRON_INGOT,2)); + decons_recipe.addIngredient(Material.IRON_SWORD); + Bukkit.addRecipe(decons_recipe); + decons_recipe = new ShapelessRecipe(new ItemStack(Material.IRON_INGOT,3)); + decons_recipe.addIngredient(Material.IRON_AXE); + Bukkit.addRecipe(decons_recipe); + decons_recipe = new ShapelessRecipe(new ItemStack(Material.IRON_INGOT,3)); + decons_recipe.addIngredient(Material.IRON_PICKAXE); + Bukkit.addRecipe(decons_recipe); + decons_recipe = new ShapelessRecipe(new ItemStack(Material.IRON_INGOT,2)); + decons_recipe.addIngredient(Material.IRON_HOE); + Bukkit.addRecipe(decons_recipe); + decons_recipe = new ShapelessRecipe(new ItemStack(Material.IRON_INGOT,1)); + decons_recipe.addIngredient(Material.IRON_SPADE); + Bukkit.addRecipe(decons_recipe); + decons_recipe = new ShapelessRecipe(new ItemStack(Material.GOLD_INGOT,4)); + decons_recipe.addIngredient(Material.GOLD_BOOTS); + Bukkit.addRecipe(decons_recipe); + decons_recipe = new ShapelessRecipe(new ItemStack(Material.GOLD_INGOT,7)); + decons_recipe.addIngredient(Material.GOLD_LEGGINGS); + Bukkit.addRecipe(decons_recipe); + decons_recipe = new ShapelessRecipe(new ItemStack(Material.GOLD_INGOT,8)); + decons_recipe.addIngredient(Material.GOLD_CHESTPLATE); + Bukkit.addRecipe(decons_recipe); + decons_recipe = new ShapelessRecipe(new ItemStack(Material.GOLD_INGOT,5)); + decons_recipe.addIngredient(Material.GOLD_HELMET); + Bukkit.addRecipe(decons_recipe); + decons_recipe = new ShapelessRecipe(new ItemStack(Material.GOLD_INGOT,2)); + decons_recipe.addIngredient(Material.GOLD_SWORD); + Bukkit.addRecipe(decons_recipe); + decons_recipe = new ShapelessRecipe(new ItemStack(Material.GOLD_INGOT,3)); + decons_recipe.addIngredient(Material.GOLD_AXE); + Bukkit.addRecipe(decons_recipe); + decons_recipe = new ShapelessRecipe(new ItemStack(Material.GOLD_INGOT,3)); + decons_recipe.addIngredient(Material.GOLD_PICKAXE); + Bukkit.addRecipe(decons_recipe); + decons_recipe = new ShapelessRecipe(new ItemStack(Material.GOLD_INGOT,2)); + decons_recipe.addIngredient(Material.GOLD_HOE); + Bukkit.addRecipe(decons_recipe); + decons_recipe = new ShapelessRecipe(new ItemStack(Material.GOLD_INGOT,1)); + decons_recipe.addIngredient(Material.GOLD_SPADE); + Bukkit.addRecipe(decons_recipe); + decons_recipe = new ShapelessRecipe(new ItemStack(Material.DIAMOND,4)); + decons_recipe.addIngredient(Material.DIAMOND_BOOTS); + Bukkit.addRecipe(decons_recipe); + decons_recipe = new ShapelessRecipe(new ItemStack(Material.DIAMOND,7)); + decons_recipe.addIngredient(Material.DIAMOND_LEGGINGS); + Bukkit.addRecipe(decons_recipe); + decons_recipe = new ShapelessRecipe(new ItemStack(Material.DIAMOND,8)); + decons_recipe.addIngredient(Material.DIAMOND_CHESTPLATE); + Bukkit.addRecipe(decons_recipe); + decons_recipe = new ShapelessRecipe(new ItemStack(Material.DIAMOND,5)); + decons_recipe.addIngredient(Material.DIAMOND_HELMET); + Bukkit.addRecipe(decons_recipe); + decons_recipe = new ShapelessRecipe(new ItemStack(Material.DIAMOND,2)); + decons_recipe.addIngredient(Material.DIAMOND_SWORD); + Bukkit.addRecipe(decons_recipe); + decons_recipe = new ShapelessRecipe(new ItemStack(Material.DIAMOND,3)); + decons_recipe.addIngredient(Material.DIAMOND_AXE); + Bukkit.addRecipe(decons_recipe); + decons_recipe = new ShapelessRecipe(new ItemStack(Material.DIAMOND,3)); + decons_recipe.addIngredient(Material.DIAMOND_PICKAXE); + Bukkit.addRecipe(decons_recipe); + decons_recipe = new ShapelessRecipe(new ItemStack(Material.DIAMOND,2)); + decons_recipe.addIngredient(Material.DIAMOND_HOE); + Bukkit.addRecipe(decons_recipe); + decons_recipe = new ShapelessRecipe(new ItemStack(Material.DIAMOND,1)); + decons_recipe.addIngredient(Material.DIAMOND_SPADE); + Bukkit.addRecipe(decons_recipe); + } + public static void Initialize_WoolRecolor_Recipes() { + for (int i=0;i<16;i++) { + ShapedRecipe wool_recolor_recipe = new ShapedRecipe(new ItemStack(Material.WOOL,8,(byte)(15-i))); + wool_recolor_recipe.shape("www","wdw","www"); + wool_recolor_recipe.setIngredient('w', Material.WOOL, -1); + wool_recolor_recipe.setIngredient('d', Material.getMaterial(351), i); + Bukkit.addRecipe(wool_recolor_recipe); + } + } + public static void Initialize_SlabReconstruction_Recipes() { + for (int i=0;i<=5;i++) { + ShapelessRecipe plank_construction_recipe = new ShapelessRecipe(new ItemStack(Material.WOOD,1,(byte)i)); + plank_construction_recipe.addIngredient(2, Material.getMaterial(126), i); + Bukkit.addRecipe(plank_construction_recipe); + } + ShapelessRecipe sandstone_construction_recipe = new ShapelessRecipe(new ItemStack(Material.RED_SANDSTONE,1)); + sandstone_construction_recipe.addIngredient(2, Material.getMaterial(182)); + Bukkit.addRecipe(sandstone_construction_recipe); + ShapelessRecipe stone_construction_recipe = new ShapelessRecipe(new ItemStack(Material.STONE,1)); + stone_construction_recipe.addIngredient(2, Material.getMaterial(44), 0); + Bukkit.addRecipe(stone_construction_recipe); + stone_construction_recipe = new ShapelessRecipe(new ItemStack(Material.SANDSTONE,1)); + stone_construction_recipe.addIngredient(2, Material.getMaterial(44), 1); + Bukkit.addRecipe(stone_construction_recipe); + stone_construction_recipe = new ShapelessRecipe(new ItemStack(Material.WOOD,1)); + stone_construction_recipe.addIngredient(2, Material.getMaterial(44), 2); + Bukkit.addRecipe(stone_construction_recipe); + stone_construction_recipe = new ShapelessRecipe(new ItemStack(Material.COBBLESTONE,1)); + stone_construction_recipe.addIngredient(2, Material.getMaterial(44), 3); + Bukkit.addRecipe(stone_construction_recipe); + stone_construction_recipe = new ShapelessRecipe(new ItemStack(Material.BRICK,1)); + stone_construction_recipe.addIngredient(2, Material.getMaterial(44), 4); + Bukkit.addRecipe(stone_construction_recipe); + stone_construction_recipe = new ShapelessRecipe(new ItemStack(Material.getMaterial(98),1)); + stone_construction_recipe.addIngredient(2, Material.getMaterial(44), 5); + Bukkit.addRecipe(stone_construction_recipe); + stone_construction_recipe = new ShapelessRecipe(new ItemStack(Material.NETHER_BRICK,1)); + stone_construction_recipe.addIngredient(2, Material.getMaterial(44), 6); + Bukkit.addRecipe(stone_construction_recipe); + stone_construction_recipe = new ShapelessRecipe(new ItemStack(Material.QUARTZ_BLOCK,1)); + stone_construction_recipe.addIngredient(2, Material.getMaterial(44), 7); + Bukkit.addRecipe(stone_construction_recipe); + stone_construction_recipe = new ShapelessRecipe(new ItemStack(Material.PURPUR_BLOCK,1)); + stone_construction_recipe.addIngredient(2, Material.PURPUR_SLAB); + Bukkit.addRecipe(stone_construction_recipe); + ItemStack modded_plank = new ItemStack(Material.STEP,1); + modded_plank.setDurability((short)2); + ItemMeta m = modded_plank.getItemMeta(); + m.setDisplayName("Fireproof Oak Wood Slab"); + modded_plank.setItemMeta(m); + stone_construction_recipe = new ShapelessRecipe(modded_plank); + stone_construction_recipe.addIngredient(1, Material.WOOD_STEP); + stone_construction_recipe.addIngredient(1, Material.SLIME_BALL); + Bukkit.addRecipe(stone_construction_recipe); + } +} diff --git a/src/sig/plugin/TwosideKeeper/RecyclingCenter.java b/src/sig/plugin/TwosideKeeper/RecyclingCenter.java new file mode 100644 index 0000000..9e36d64 --- /dev/null +++ b/src/sig/plugin/TwosideKeeper/RecyclingCenter.java @@ -0,0 +1,100 @@ +package sig.plugin.TwosideKeeper; + +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.Vector; + +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.World; +import org.bukkit.configuration.file.FileConfiguration; +import org.bukkit.configuration.file.YamlConfiguration; +import org.bukkit.inventory.ItemStack; + +public class RecyclingCenter { + //Each Recycling center has nodes which contain all the chests. + List nodes; + + boolean choosing = false; + + public RecyclingCenter() { + nodes = new ArrayList(); + } + + public void AddNode(World world, int locx,int locy,int locz) { + nodes.add(new Location(world,locx,locy,locz)); + } + + /** + * + * @param numb The number in the list of the node you want. + * @return The Location of the node requested. + */ + public Location getNodeLocation(int numb) { + return nodes.get(numb); + } + + public Location getRandomNode() { + return nodes.get((int)(Math.floor(Math.random()*nodes.size()))); + } + + public int getNumberOfNodes() { + return nodes.size(); + } + + public boolean IsItemAllowed(ItemStack item) { + //Artifact type of items are not allowed to be sent to the Recycling Center. + if (Artifact.isArtifact(item)) { + return false; + } + return true; + } + + public void loadConfig() { + File config= new File(TwosideKeeper.filesave,"recyclingcenters.data"); + if (config.exists()) { + Bukkit.getLogger().info("Config exists. Entering."); + FileConfiguration workable = YamlConfiguration.loadConfiguration(config); + + /*workable.addDefault("recyclingcenter.count", 0); + + int total = workable.getInt("recyclingcenter.count");*/ + //Bukkit.getLogger().info("Recycling center count: "+total+" ("+workable.getKeys(false).size()+")"); + for (int i=0;i players = new ArrayList(); //The players involved with this spleef game. + List registered_players = new ArrayList(); //The players involved with this spleef game. + TwosideKeeper plugin; + SpleefArena id; //The ID of this spleef game. + Location corner1; //The location of the first corner of the arena. + //Going outside it automatically terminates the game. + Location corner2; //The location of the second corner of the arena. + //Going outside it automatically terminates the game. + Location shovel_chest; //The location of the chest the spleef shovel is supposed to be in. + Location shovel_chest2; //The location of the chest the spleef shovel is supposed to be in. + Location sign; //The location of the sign to register for this spleef arena. + long registrationtime; //If it takes more than 60 seconds for players to register for a spleef game, the registration will be cancelled. + long starttime; //The starting time of the match. + long last_destroyed; //Time the last block was destroyed. + + public SpleefGame(TwosideKeeper plug, SpleefArena id, Location corner1, Location corner2, Location shovel_chest, Location sign) { + this.plugin=plug; + this.id=id; + this.corner1=corner1; + this.corner2=corner2; + this.shovel_chest=shovel_chest; + this.sign=sign; + + this.registrationtime=0; + } + public SpleefGame(TwosideKeeper plug, SpleefArena id, Location corner1, Location corner2, Location shovel_chest, Location shovel_chest2, Location sign) { + this.plugin=plug; + this.id=id; + this.corner1=corner1; + this.corner2=corner2; + this.shovel_chest=shovel_chest; + this.shovel_chest2=shovel_chest2; + this.sign=sign; + + this.registrationtime=0; + } + public String toString() { + return "SpleefGame: "+id.toString()+" From "+this.corner1.toString()+" to "+this.corner2.toString()+".\n" + + "Shovel Chest Loc: "+shovel_chest.toString()+";"+((shovel_chest2!=null)?"Shovel Chest 2 Loc: "+shovel_chest2.toString()+";":"")+ " Registration Sign Loc: "+sign.toString(); + } + + public boolean isActive() { + return active; + } + + public void EventListener(Event e) { + + //A listener for all events passed here. + + if (e instanceof BlockBreakEvent) { + BlockBreakEvent ev = (BlockBreakEvent)e; + + if (active) { + + if (ev.getBlock().getLocation().getBlockX()==corner1.getBlockX() || + ev.getBlock().getLocation().getBlockX()==corner2.getBlockX() || + ev.getBlock().getLocation().getBlockZ()==corner1.getBlockZ() || + ev.getBlock().getLocation().getBlockZ()==corner2.getBlockZ()) { + //We are not allowed to break blocks on the borders. + //This is a border block. Prevent destruction. + ev.setCancelled(true); + } + if (BlockIsInside(ev.getBlock().getLocation(),corner1,corner2)) { + //This is a block inside the field. Now see if it's a registered player. + boolean not_allowed=true; + for (int i=0;i=2) { + plugin.getServer().broadcastMessage(ChatColor.GOLD+"Player "+ChatColor.GREEN+ev.getPlayer().getName()+ChatColor.GOLD+" has registered to play in the "+ChatColor.AQUA+id.toString()+ChatColor.GOLD+" Spleef Arena!"); + plugin.getServer().broadcastMessage(ChatColor.BLUE+" 10 seconds left to register!"); + starttime=TwosideKeeper.getServerTickTime()+200; + } else { //We only have one player. Wait for more. + plugin.getServer().broadcastMessage(ChatColor.GOLD+"Player "+ChatColor.GREEN+ev.getPlayer().getName()+ChatColor.GOLD+" has registered to play in the "+ChatColor.AQUA+id.toString()+ChatColor.GOLD+" Spleef Arena!"); + plugin.getServer().broadcastMessage(ChatColor.BLUE+" Looking for at least one more player!"); + //De-register from other Spleef Arenas. + for (int i=0;i=2 && starttime<=TwosideKeeper.getServerTickTime()) + { //Start the game! + //Teleport players to the arena at a random position, clear their inventories, + //set their health, and their hunger. + //Setup the arena with the proper blocks, if the dirt blocks are not filled in already. + if (corner1.getBlockX()>corner2.getBlockX()) { + if (corner1.getBlockZ()>corner2.getBlockZ()) { + for (int i=corner2.getBlockX();i<=corner1.getBlockX();i++) { + for (int j=corner2.getBlockZ();j<=corner1.getBlockZ();j++) { + if (Bukkit.getWorld("world").getBlockAt(i,corner1.getBlockY(),j)!=null && + Bukkit.getWorld("world").getBlockAt(i,corner1.getBlockY(),j).getType()==Material.AIR) { + Bukkit.getWorld("world").getBlockAt(i,corner1.getBlockY(),j).setType(Material.DIRT); + } + if (id==SpleefArena.LAYERED && + i!=corner2.getBlockX() && + i!=corner1.getBlockX() && + j!=corner1.getBlockZ() && + j!=corner2.getBlockZ()) { + for (int k=0;k<3;k++) { + Bukkit.getWorld("world").getBlockAt(i,corner1.getBlockY()+k+1,j).setType(Material.GRAVEL); + } + } + } + } + } else { + for (int i=corner2.getBlockX();i<=corner1.getBlockX();i++) { + for (int j=corner1.getBlockZ();j<=corner2.getBlockZ();j++) { + if (Bukkit.getWorld("world").getBlockAt(i,corner1.getBlockY(),j)!=null && + Bukkit.getWorld("world").getBlockAt(i,corner1.getBlockY(),j).getType()==Material.AIR) { + Bukkit.getWorld("world").getBlockAt(i,corner1.getBlockY(),j).setType(Material.DIRT); + } + if (id==SpleefArena.LAYERED && + i!=corner2.getBlockX() && + i!=corner1.getBlockX() && + j!=corner1.getBlockZ() && + j!=corner2.getBlockZ()) { + for (int k=0;k<3;k++) { + Bukkit.getWorld("world").getBlockAt(i,corner1.getBlockY()+k+1,j).setType(Material.GRAVEL); + } + } + } + } + } + } else { + if (corner1.getBlockZ()>corner2.getBlockZ()) { + for (int i=corner1.getBlockX();i<=corner2.getBlockX();i++) { + for (int j=corner2.getBlockZ();j<=corner1.getBlockZ();j++) { + if (Bukkit.getWorld("world").getBlockAt(i,corner1.getBlockY(),j)!=null && + Bukkit.getWorld("world").getBlockAt(i,corner1.getBlockY(),j).getType()==Material.AIR) { + Bukkit.getWorld("world").getBlockAt(i,corner1.getBlockY(),j).setType(Material.DIRT); + } + if (id==SpleefArena.LAYERED && + i!=corner2.getBlockX() && + i!=corner1.getBlockX() && + j!=corner1.getBlockZ() && + j!=corner2.getBlockZ()) { + for (int k=0;k<3;k++) { + Bukkit.getWorld("world").getBlockAt(i,corner1.getBlockY()+k+1,j).setType(Material.GRAVEL); + } + } + } + } + } else { + for (int i=corner1.getBlockX();i<=corner2.getBlockX();i++) { + for (int j=corner1.getBlockZ();j<=corner2.getBlockZ();j++) { + if (Bukkit.getWorld("world").getBlockAt(i,corner1.getBlockY(),j)!=null && + Bukkit.getWorld("world").getBlockAt(i,corner1.getBlockY(),j).getType()==Material.AIR) { + Bukkit.getWorld("world").getBlockAt(i,corner1.getBlockY(),j).setType(Material.DIRT); + } + if (id==SpleefArena.LAYERED && + i!=corner2.getBlockX() && + i!=corner1.getBlockX() && + j!=corner1.getBlockZ() && + j!=corner2.getBlockZ()) { + for (int k=0;k<3;k++) { + Bukkit.getWorld("world").getBlockAt(i,corner1.getBlockY()+k+1,j).setType(Material.GRAVEL); + } + } + } + } + } + } + + //For the block above the chest, turn it into a wooden plank. + Bukkit.getWorld("world").getBlockAt(shovel_chest.clone().add(0,1,0)).setType(Material.WOOD); + //Insert a Spleef shovel in the chest. + //We will clear out the contents first. + if (Bukkit.getWorld("world").getBlockAt(shovel_chest).getState() instanceof Chest) { + Chest spleef_chest = (Chest)Bukkit.getWorld("world").getBlockAt(shovel_chest).getState(); + spleef_chest.getInventory().clear(); + spleef_chest.getInventory().setItem((int)(Math.random()*27), new ItemStack(Material.WOOD_SPADE)); + } + //And a second one if it exists. + if (shovel_chest2!=null) { + Bukkit.getWorld("world").getBlockAt(shovel_chest2.clone().add(0,1,0)).setType(Material.WOOD); + if (Bukkit.getWorld("world").getBlockAt(shovel_chest2).getState() instanceof Chest) { + Chest spleef_chest2 = (Chest)Bukkit.getWorld("world").getBlockAt(shovel_chest2).getState(); + spleef_chest2.getInventory().clear(); + spleef_chest2.getInventory().setItem((int)(Math.random()*27), new ItemStack(Material.WOOD_SPADE)); + } + } + + //Insert spleef shovel into the chest~! + + String matchup=""; //Set the string for the match-up. + for (int i=0;icorner2.getBlockX())?(corner1.getBlockX()-2-(Math.random()*(corner1.getBlockX()-corner2.getBlockX()-4))):(corner2.getBlockX()-2-(Math.random()*(corner2.getBlockX()-corner1.getBlockX()-4))), + (corner1.getBlockY()>corner2.getBlockY())?(corner1.getBlockY()+4):(corner2.getBlockY()+4), + (corner1.getBlockZ()>corner2.getBlockZ())?(corner1.getBlockZ()-2-(Math.random()*(corner1.getBlockZ()-corner2.getBlockZ()-4))):(corner2.getBlockZ()-2-(Math.random()*(corner2.getBlockZ()-corner1.getBlockZ()-4))) + ), TeleportCause.PLUGIN); + //Give players Resistance 100 so they can never die. + Bukkit.getServer().getPlayer(players.get(i).player).addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE,99999,100)); + } + active=true; + starttime=TwosideKeeper.getServerTickTime(); + //registered_players=players; //Registered players include every single player that joined in. This is to manage ranking and + //who is allowed to help break blocks after losing. + last_destroyed=TwosideKeeper.getServerTickTime(); + + Bukkit.getServer().broadcastMessage(ChatColor.GOLD+"The spleef matchup between "+ChatColor.GREEN+matchup+ChatColor.GOLD+" has begun!"); + } + + if (active && starttime+100highest_count) { + highest_count=players.get(i).blocks_destroyed; + winner=players.get(i); + } + } + + Bukkit.getServer().broadcastMessage(ChatColor.GOLD+"The Spleef Match has stalled, and the winner has been decided!"); + Bukkit.getServer().broadcastMessage(ChatColor.BLUE+""+ChatColor.ITALIC+" With "+ChatColor.GREEN+highest_count+ChatColor.BLUE+" blocks destroyed..."); + //We will have the winner. End the Match. + if (winner!=null) { + EndMatch(winner); + } else { + EndMatch(players.get(0)); //Something went wrong?? + } + } + } + + void RemovePlayer(Player p, RemovePlayerReason rs) { + for (int i=0;icorner2.getBlockX())?(corner1.getBlockX()-(Math.random()*(corner1.getBlockX()-corner2.getBlockX()))):(corner2.getBlockX()-(Math.random()*(corner2.getBlockX()-corner1.getBlockX()))), + (corner1.getBlockY()>corner2.getBlockY())?(corner1.getBlockY()-2):(corner2.getBlockY()-2), + (corner1.getBlockZ()>corner2.getBlockZ())?(corner1.getBlockZ()-(Math.random()*(corner1.getBlockZ()-corner2.getBlockZ()))):(corner2.getBlockZ()-(Math.random()*(corner2.getBlockZ()-corner1.getBlockZ()))) + ), TeleportCause.PLUGIN); + if (rs==RemovePlayerReason.OUTOFBOUNDS || + rs==RemovePlayerReason.QUIT) { + for (int i=0;ib2.getBlockX()) { + if (b1.getBlockZ()>b2.getBlockZ()) { + if (l.getBlockX()>b2.getBlockX() && + l.getBlockX()b2.getBlockZ() && + l.getBlockZ()b2.getBlockX() && + l.getBlockX()b1.getBlockZ()) { + return true; + } else { + return false; + } + } + } else { + if (b1.getBlockZ()>b2.getBlockZ()) { + if (l.getBlockX()b1.getBlockX() && + l.getBlockZ()>b2.getBlockZ() && + l.getBlockZ()b1.getBlockX() && + l.getBlockZ()b1.getBlockZ()) { + return true; + } else { + return false; + } + } + } + } +} + +enum RemovePlayerReason { + QUIT,OUTOFBOUNDS,GENERAL; +} + +class SpleefPlayerData { + String player; //The name of the player. + ItemStack player_equipment_helmet; + ItemStack player_equipment_chestplate; + ItemStack player_equipment_leggings; + ItemStack player_equipment_boots; + ItemStack player_equipment_shield; + List player_inventory = new ArrayList(); + TwosideKeeper plug; + int blocks_destroyed; + SpleefPlayerData(TwosideKeeper plug, Player player) { + this.plug=plug; + this.player=player.getName(); + this.blocks_destroyed=0; + /* + */ + } + public void RestoreInventory() { + //Gives the player back their inventory. + for (int i=0;icorner2.getBlockX())?corner2.getBlockX():corner1.getBlockX(), + xbound2=(corner1.getBlockX()>corner2.getBlockX())?corner1.getBlockX():corner2.getBlockX(), + zbound1=(corner1.getBlockZ()>corner2.getBlockZ())?corner2.getBlockZ():corner1.getBlockZ(), + zbound2=(corner1.getBlockZ()>corner2.getBlockZ())?corner1.getBlockZ():corner2.getBlockZ(); + if (p.getLocation().getBlockX()<=xbound1 || + p.getLocation().getBlockX()>=xbound2 || + p.getLocation().getBlockZ()<=zbound1 || + p.getLocation().getBlockZ()>=zbound2 || + p.getLocation().getBlockY() spleef_game_list; + TwosideKeeper plugin; + public SpleefManager(TwosideKeeper plug) { + plugin = plug; + spleef_game_list = new ArrayList(); + } + public List GetSpleefGames() { + return spleef_game_list; + } + public List GetActiveSpleefGames() { + List active_spleef_game_list = new ArrayList(); + for (int i=0;i playerdata; + public static SpleefManager TwosideSpleefGames; + public WorldShopManager TwosideShops; + + public int TeamCounter = 0; + public List PartyList = new ArrayList(); + public List colors_used = new ArrayList(); + + public RecyclingCenter TwosideRecyclingCenter; + + //Bank timers and users. + public String withdrawUser=""; + public long withdrawTime=0; + public String depositUser=""; + public long depositTime=0; + public String conversionUser=""; + public long conversionTime=0; + public int sleepingPlayers=0; + + int[] lampblocks = {1626,71,-255, //List of all lamp blocks in the city to be lit. + 1628,70,-223, + 1626,70,-265, + 1624,70,-267, + 1635,71,-269, + 1612,69,-269, + 1610,69,-271, + 1595,67,-267, + 1595,66,-269, + 1577,66,-271, + 1610,71,-282, + 1608,71,-295, + 1610,67,-317, + 1610,67,-338, + 1610,67,-340, + 1632,71,-342, + 1601,67,-342, + 1587,67,-340}; + + boolean lamps_are_turned_on = false; + + @Override + public void onEnable() { + // TODO Insert logic to be performed when the plugin is enabled + Bukkit.getPluginManager().registerEvents(this, this); + + loadConfig(); + + sig.plugin.TwosideKeeper.Recipes.Initialize_ItemCube_Recipes(); + sig.plugin.TwosideKeeper.Recipes.Initialize_ArrowQuiver_Recipe(); + sig.plugin.TwosideKeeper.Recipes.Initialize_BlockArmor_Recipes(); + sig.plugin.TwosideKeeper.Recipes.Initialize_ItemDeconstruction_Recipes(); + sig.plugin.TwosideKeeper.Recipes.Initialize_WoolRecolor_Recipes(); + sig.plugin.TwosideKeeper.Recipes.Initialize_SlabReconstruction_Recipes(); + + filesave=getDataFolder(); //Store the location of where our data folder is. + getLogger().info("Data folder at "+filesave+"."); + + STARTTIME=Bukkit.getWorld("world").getFullTime(); + LASTSERVERCHECK=getServerTickTime(); + + TwosideRecyclingCenter = new RecyclingCenter(); + TwosideRecyclingCenter.loadConfig(); + Bukkit.getLogger().info("Recycling Centers Loaded: "+TwosideRecyclingCenter.getNumberOfNodes()); + + //Create Spleef Games. + TwosideSpleefGames = new SpleefManager(this); + + TwosideSpleefGames.SetupSpleefArena( + SpleefArena.SMALL, //Spleef Arena Type + new Location(Bukkit.getWorld("world"),1616,86,53), //Corner 1 + new Location(Bukkit.getWorld("world"),1627,86,64), //Corner 2 + new Location(Bukkit.getWorld("world"),1622,85,58), //Shovel Chest + new Location(Bukkit.getWorld("world"),1620,83,45) //Registration Sign + ); + TwosideSpleefGames.SetupSpleefArena( + SpleefArena.LARGE, //Spleef Arena Type + new Location(Bukkit.getWorld("world"),1585,86,24), //Corner 1 + new Location(Bukkit.getWorld("world"),1600,86,39), //Corner 2 + new Location(Bukkit.getWorld("world"),1593,85,34), //Shovel Chest + new Location(Bukkit.getWorld("world"),1593,85,29), //Shovel Chest 2 + new Location(Bukkit.getWorld("world"),1608,83,34) //Registration Sign + ); + TwosideSpleefGames.SetupSpleefArena( + SpleefArena.LAYERED, //Spleef Arena Type + new Location(Bukkit.getWorld("world"),1658,87,27), //Corner 1 + new Location(Bukkit.getWorld("world"),1646,87,39), //Corner 2 + new Location(Bukkit.getWorld("world"),1652,86,34), //Shovel Chest + new Location(Bukkit.getWorld("world"),1635,83,31) //Registration Sign + ); + + TwosideShops = new WorldShopManager(); + + //Initialize Player Data structure. + playerdata = new ArrayList(); + + //This is the constant timing method. + getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable(){ + public void run(){ + //getLogger().info("Server time passed: "+(Bukkit.getWorld("world").getFullTime()-STARTTIME)+". New Server Time: "+(Bukkit.getWorld("world").getFullTime()-STARTTIME+SERVERTICK)); + Bukkit.getWorld("world").setFullTime(Bukkit.getWorld("world").getFullTime()-10); + //WORK IN PROGRESS: Lamp updating code TO GO HERE. + + //SAVE SERVER SETTINGS. + if (getServerTickTime()-LASTSERVERCHECK>=SERVERCHECKERTICKS) { //15 MINUTES (DEFAULT) + saveOurData(); + + + //Advertisement messages could go here. + //MOTD: "Thanks for playing on Sig's Minecraft!\n*bCheck out http://z-gamers.net/mc for update info!\n*aReport any bugs you find at http://zgamers.domain.com/mc/" + getMOTD(); + getServer().broadcastMessage(ChatColor.translateAlternateColorCodes('*', MOTD)); + /* + getServer().broadcastMessage("Thanks for playing on Sig's Minecraft!"); + getServer().broadcastMessage(ChatColor.AQUA+"Check out http://z-gamers.net/mc for update info!"); + getServer().broadcastMessage(" "); + */ + //End Advertisements. + + LASTSERVERCHECK=getServerTickTime(); + } + + //Check our deposit and withdraw terminals for lingering timers. + if (!withdrawUser.equalsIgnoreCase("") && getServerTickTime()-withdrawTime>TERMINALTIME) { + //This is occupied still when it's supposed to time out. + Player p = Bukkit.getPlayer(withdrawUser); + if (p!=null) { + p.sendMessage(ChatColor.RED+"RAN OUT OF TIME! "+ChatColor.WHITE+"Cancelled out of Withdraw terminal."); + } + withdrawUser=""; + } + if (!depositUser.equalsIgnoreCase("") && getServerTickTime()-depositTime>TERMINALTIME) { + //This is occupied still when it's supposed to time out. + Player p = Bukkit.getPlayer(depositUser); + if (p!=null) { + p.sendMessage(ChatColor.RED+"RAN OUT OF TIME! "+ChatColor.WHITE+"Cancelled out of Deposit terminal."); + } + depositUser=""; + } + if (!conversionUser.equalsIgnoreCase("") && getServerTickTime()-conversionTime>TERMINALTIME) { + //This is occupied still when it's supposed to time out. + Player p = Bukkit.getPlayer(conversionUser); + if (p!=null) { + p.sendMessage(ChatColor.RED+"RAN OUT OF TIME! "+ChatColor.WHITE+"Cancelled out of Conversion terminal."); + } + conversionUser=""; + } + + if (Bukkit.getWorld("world").getTime()>=12000) { + Collection players = (Collection) getServer().getOnlinePlayers(); + //Count the number of players sleeping. Compare to "sleepingplayers" count. + //getLogger().info("[DEBUG] Time: "+Bukkit.getWorld("world").getTime()+" Full Time: "+Bukkit.getWorld("world").getFullTime() + " SERVERTICKTIME: "+getServerTickTime()); + if (players.size()>=2) { //This functionality only makes sense when two or more players are on. + int sleeping=0; + for (int i=0;i=players.size()/2) { + //Make it the next day. + getServer().broadcastMessage(ChatColor.GOLD+"Enough Players sleeping! It's now morning!"); + + SERVERTICK=getServerTickTime(); + Bukkit.getWorld("world").setTime(0); + STARTTIME=Bukkit.getWorld("world").getFullTime(); + LASTSERVERCHECK=getServerTickTime(); + //Make sure we keep SERVERTICK in check. + sleepingPlayers=0; + } + } + } + + //See if each player needs to regenerate their health. + for (int i=0;i=16) { + p.setHealth((p.getHealth()+1+(p.getMaxHealth()*0.05)>p.getMaxHealth())?p.getMaxHealth():p.getHealth()+1+(p.getMaxHealth()*0.05)); + } + } + //See if this player is sleeping. + if (p.isSleeping()) { + p.setHealth(Bukkit.getPlayer(pd.name).getMaxHealth()); //Heals the player fully when sleeping. + } + //We need to see if this player's damage reduction has changed recently. If so, notify them. + //Check damage reduction by sending an artifical "1" damage to the player. + if (!p.isDead()) {setPlayerMaxHealth(p);} + p.getScoreboard().getTeam(p.getName().toLowerCase()).setSuffix(createHealthbar(((p.getHealth())/p.getMaxHealth())*100,p)); + if (CalculateDamageReduction(1,p,p)!=pd.damagereduction) { + pd.damagereduction=CalculateDamageReduction(1,p,p); + p.sendMessage(ChatColor.GRAY+""+ChatColor.ITALIC+"Damage Reduction modified: "+ChatColor.RESET+""+ChatColor.DARK_AQUA+Math.round((1.0-pd.damagereduction)*100)+"%"); + } + + + //Try to fit into an already existing party. + boolean inParty=false; + for (int j=0;j lore = meta.getLore(); + lore.add(ChatColor.GRAY+"Breaks Remaining: "+ChatColor.YELLOW+args[0]); + meta.setLore(lore); + } else { + List lore = new ArrayList(); + lore.add(ChatColor.GRAY+"Breaks Remaining: "+ChatColor.YELLOW+args[0]); + meta.setLore(lore); + if (lore.size()>=1) { + sender.sendMessage("Updated Lore."); + } + } + item.setItemMeta(meta); + p.getEquipment().setItemInMainHand(item); + } else { + sender.sendMessage("Wrong arguments!"); + } + } else { + sender.sendMessage("Cannot harden nothing!"); + } + return true; + } else + if (cmd.getName().equalsIgnoreCase("item_cube")) { + //sender.sendMessage("You are currently holding "+ChatColor.GREEN+"$"+getPlayerMoney((Player)sender)); + //sender.sendMessage("You are currently holding "+ChatColor.GREEN+"$"+getPlayerMoney((Player)sender)); + Player p = (Player)sender; + if (p.getEquipment().getItemInMainHand()!=null) { + if (args.length==1) { + ItemStack item = p.getEquipment().getItemInMainHand(); + ItemMeta meta = item.getItemMeta(); + if (meta.hasLore()) { + List lore = meta.getLore(); + lore.clear(); + lore.add(" "); + lore.add(" "); + lore.add(" "); + lore.add(ChatColor.DARK_PURPLE+"ID#"+args[0]); + meta.setLore(lore); + } else { + List lore = new ArrayList(); + lore.clear(); + lore.add(" "); + lore.add(" "); + lore.add(" "); + lore.add(ChatColor.DARK_PURPLE+"ID#"+args[0]); + meta.setLore(lore); + } + item.setItemMeta(meta); + p.getEquipment().setItemInMainHand(item); + } else { + sender.sendMessage("Wrong arguments!"); + } + } else { + sender.sendMessage("Cannot convert nothing!"); + } + return true; + } else + if (cmd.getName().equalsIgnoreCase("artifact")) { + Player p = (Player)sender; + if (args.length==1) { + p.getInventory().addItem(Artifact.createArtifactItem(ArtifactItem.valueOf(args[0]))); + } else { + sender.sendMessage("Wrong arguments!"); + } + } else + if (cmd.getName().equalsIgnoreCase("recyclingcenter")) { + Player p = (Player)sender; + TwosideRecyclingCenter.setChoosingRecyclingCenter(!TwosideRecyclingCenter.isChoosingRecyclingCenter()); + if (TwosideRecyclingCenter.isChoosingRecyclingCenter()) { + p.sendMessage(ChatColor.GREEN+"Click on a Chest to set up a new Recycling Center Node."); + } else { + p.sendMessage(ChatColor.RED+"Cancelled Recycling Center selection mode."); + } + } else + if (cmd.getName().equalsIgnoreCase("sound")) { + Player p = (Player)sender; + for (int i=0;i=1) { + //See if we're using a bank terminal. + Player thisp = ev.getPlayer(); + if (withdrawUser.equalsIgnoreCase(thisp.getName())) { + //See if this message is a number. + if (isNumeric(ev.getMessage())) { + DecimalFormat df = new DecimalFormat("0.00"); + Double value=Double.parseDouble(ev.getMessage()); + value=Double.parseDouble(df.format(Double.valueOf(value))); + if (value>=0.01) { + if (getPlayerBankMoney(thisp)>=value) { + //Withdraw the money. Credit it to the player. + givePlayerBankMoney(thisp,-value); + givePlayerMoney(thisp,value); + ev.getPlayer().sendMessage(ChatColor.GOLD+"WITHDRAW COMPLETE!"); + ev.getPlayer().sendMessage(" Now Holding: "+ChatColor.GREEN+"$"+df.format(getPlayerMoney(ev.getPlayer()))); + } else { + thisp.sendMessage(ChatColor.RED+"Your account does not have that much money! You can withdraw a maximum of "+ChatColor.WHITE+"$"+getPlayerBankMoney(thisp)); + thisp.sendMessage(ChatColor.WHITE+" Cancelled out of Withdraw terminal."); + } + } else { + thisp.sendMessage(ChatColor.RED+"You must withdraw at least "+ChatColor.WHITE+"$0.01 or more."); + thisp.sendMessage(ChatColor.WHITE+" Cancelled out of Withdraw terminal."); + } + } else { + thisp.sendMessage(ChatColor.RED+"Invalid Number!"); + thisp.sendMessage(ChatColor.WHITE+" Cancelled out of Withdraw terminal."); + } + withdrawUser=""; + ev.setMessage(""); + ev.setCancelled(true); + } else + if (depositUser.equalsIgnoreCase(thisp.getName())) { + //See if this message is a number. + if (isNumeric(ev.getMessage())) { + DecimalFormat df = new DecimalFormat("0.00"); + Double value=Double.parseDouble(ev.getMessage()); + value=Double.parseDouble(df.format(Double.valueOf(value))); + if (value>=0.01) { + if (getPlayerMoney(thisp)>=value) { + //Withdraw the money. Credit it to the player. + givePlayerBankMoney(thisp,value); + givePlayerMoney(thisp,-value); + ev.getPlayer().sendMessage(ChatColor.GOLD+"DEPOSIT COMPLETE!"); + ev.getPlayer().sendMessage(" Now In Bank: "+ChatColor.BLUE+"$"+df.format(getPlayerBankMoney(ev.getPlayer()))); + } else { + thisp.sendMessage(ChatColor.RED+"You are not holding that much money! You can deposit a maximum of "+ChatColor.WHITE+"$"+getPlayerMoney(thisp)); + thisp.sendMessage(ChatColor.WHITE+" Cancelled out of Deposit terminal."); + } + } else { + thisp.sendMessage(ChatColor.RED+"You must deposit at least "+ChatColor.WHITE+"$0.01 or more."); + thisp.sendMessage(ChatColor.WHITE+" Cancelled out of Deposit terminal."); + } + } else { + thisp.sendMessage(ChatColor.RED+"Invalid Number!"); + thisp.sendMessage(ChatColor.WHITE+" Cancelled out of Deposit terminal."); + } + depositUser=""; + ev.setMessage(""); + ev.setCancelled(true); + } else + if (conversionUser.equalsIgnoreCase(thisp.getName())) { + //See if this message is a number. + if (isNumeric(ev.getMessage())) { + DecimalFormat df = new DecimalFormat("0.00"); + Integer value=Integer.parseInt(ev.getMessage()); + if (value>=1) { + if (thisp.getLevel()>=value) { + //Take that amount of exp away from the player. Give them money in return. + int startlv = thisp.getLevel(); + for (int i=startlv;i>=startlv-value;i--) { + switch (i) { + case 0: + case 1: + case 2: + case 3: + case 4: + case 5: + case 6: + case 7: + case 8: + case 9: + case 10: + case 11: + case 12: + case 13: + case 14: + case 15: + case 16: + { + givePlayerMoney(thisp,(2*i+7)*XP_CONVERSION_RATE); + }break; + case 17: + case 18: + case 19: + case 20: + case 21: + case 22: + case 23: + case 24: + case 25: + case 26: + case 27: + case 28: + case 29: + case 30: + case 31: + { + givePlayerMoney(thisp,(5*i-38)*XP_CONVERSION_RATE); + }break; + default:{ + givePlayerMoney(thisp,(9*i-158)*XP_CONVERSION_RATE); + } + } + } + thisp.setLevel(thisp.getLevel()-value); + ev.getPlayer().sendMessage(ChatColor.GOLD+"CONVERSION COMPLETE!"); + ev.getPlayer().sendMessage(" Now Holding: "+ChatColor.BLUE+"$"+df.format(getPlayerMoney(ev.getPlayer()))); + } else { + thisp.sendMessage(ChatColor.RED+"You do not have that many levels. You can convert as many as "+ChatColor.WHITE+thisp.getLevel()+ChatColor.RED+" levels."); + thisp.sendMessage(ChatColor.WHITE+" Cancelled out of Conversion terminal."); + } + } else { + thisp.sendMessage(ChatColor.RED+"You must convert at least "+ChatColor.WHITE+"1 level."); + thisp.sendMessage(ChatColor.WHITE+" Cancelled out of Conversion terminal."); + } + } else { + thisp.sendMessage(ChatColor.RED+"Invalid Number!"); + thisp.sendMessage(ChatColor.WHITE+" Cancelled out of Conversion terminal."); + } + conversionUser=""; + ev.setMessage(""); + ev.setCancelled(true); + } else + if (TwosideShops.IsPlayerUsingTerminal(ev.getPlayer())) { + final WorldShopSession current_session = TwosideShops.GetSession(ev.getPlayer()); + current_session.UpdateTime(); //Make sure our session does not expire. + switch (current_session.GetSessionType()) { + case CREATE: + if (isNumeric(ev.getMessage())) { + int amt = Integer.parseInt(ev.getMessage()); + if (amt<=CountItems(ev.getPlayer(), current_session.getItem()) && amt>0) { + current_session.SetAmt(amt); + ev.getPlayer().sendMessage("Input how much each "+ChatColor.GREEN+TwosideKeeper.GetItemName(current_session.getItem())+ChatColor.WHITE+" will cost:"); + current_session.SetSession(SessionState.PRICE); + } else { + if (amt<=0) { + ev.getPlayer().sendMessage("You cannot sell a non-existent amount of items. Please try again."); + } else { + ev.getPlayer().sendMessage("You only have "+CountItems(ev.getPlayer(), current_session.getItem())+" of "+ChatColor.GREEN+TwosideKeeper.GetItemName(current_session.getItem())+ChatColor.WHITE+". Please try again with a lower amount."); + } + } + } else { + ev.getPlayer().sendMessage("That is not a valid number! Please try again."); + } + break; + case PRICE: + if (isNumeric(ev.getMessage())) { + final DecimalFormat df = new DecimalFormat("0.00"); + final double amt = Double.parseDouble(ev.getMessage()); + if (amt>0 && amt<=999999999999.99) { + ev.getPlayer().sendMessage(ChatColor.DARK_BLUE+"Shop has been successfully created!"); + Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() { + @Override + public void run() { + TwosideShops.SaveWorldShopData( + TwosideShops.CreateWorldShop(current_session.GetSign(), current_session.getItem(), current_session.getAmt(), Double.parseDouble(df.format(amt)), ev.getPlayer().getName()) + ); + RemoveItemAmount(ev.getPlayer(), current_session.getItem(), current_session.getAmt()); + TwosideShops.RemoveSession(ev.getPlayer()); + } + },1); + + } else { + if (amt>999999999999.99) { + ev.getPlayer().sendMessage("You cannot sell an item for that ridiculous amount. Please try again."); + } else { + ev.getPlayer().sendMessage("You cannot sell an item for free. Please try again."); + } + } + } else { + ev.getPlayer().sendMessage("That is not a valid number! Please try again."); + } + break; + case EDIT: + if (isNumeric(ev.getMessage())) { + int amt = Integer.parseInt(ev.getMessage()); + DecimalFormat df = new DecimalFormat("0.00"); + WorldShop shop = TwosideShops.LoadWorldShopData(TwosideShops.GetShopID(current_session.GetSign())); + if (amt>=0) { + if (amt<=CountItems(ev.getPlayer(), shop.GetItem())) { + shop.UpdateAmount(shop.GetAmount()+amt); + RemoveItemAmount(ev.getPlayer(), shop.GetItem(), amt); + TwosideShops.SaveWorldShopData(shop); + TwosideShops.UpdateSign(shop, TwosideShops.GetShopID(current_session.GetSign()), current_session.GetSign()); + ev.getPlayer().sendMessage("Added "+ChatColor.AQUA+amt+ChatColor.WHITE+" more "+ChatColor.GREEN+shop.GetItemName()+ChatColor.WHITE+" to your shop!"); + ev.getPlayer().sendMessage("Input how much each "+ChatColor.GREEN+shop.GetItemName()+ChatColor.WHITE+" will cost (Old value - "+ChatColor.YELLOW+"$"+df.format(shop.GetUnitPrice())+ChatColor.WHITE+":"); + + current_session.SetSession(SessionState.UPDATE); + } else { + if (amt<=0) { + ev.getPlayer().sendMessage("You cannot add a non-existent amount of items. Please try again."); + } else { + ev.getPlayer().sendMessage("You only have "+CountItems(ev.getPlayer(), shop.GetItem())+" of "+ChatColor.GREEN+shop.GetItemName()+ChatColor.WHITE+". Please try again with a lower amount."); + } + } + } else { + if (-amt<=shop.GetAmount()) { + //Take out these items from the shop. + amt*=-1; + shop.UpdateAmount(shop.GetAmount()-amt); + ItemStack drop = shop.GetItem(); + int dropAmt = amt; + //ev.getPlayer().getWorld().dropItemNaturally(ev.getPlayer().getLocation(), drop).setPickupDelay(0); + final Player p = ev.getPlayer(); + while (dropAmt>0) { + if (dropAmt>shop.GetItem().getMaxStackSize()) { + drop.setAmount(shop.GetItem().getMaxStackSize()); + final ItemStack dropitem = drop; + Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() { + @Override + public void run() { + p.getWorld().dropItemNaturally(p.getLocation(), dropitem).setPickupDelay(0); + } + },1); + dropAmt-=shop.GetItem().getMaxStackSize(); + } else { + drop.setAmount(dropAmt); + final ItemStack dropitem = drop; + Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() { + @Override + public void run() { + p.getWorld().dropItemNaturally(p.getLocation(), dropitem).setPickupDelay(0); + } + },1); + dropAmt=0; + } + } + Bukkit.getLogger().info("Dropped item."); + //ev.getPlayer().getWorld().dropItemNaturally(ev.getPlayer().getLocation(), drop).setPickupDelay(0); + TwosideShops.SaveWorldShopData(shop); + TwosideShops.UpdateSign(shop, TwosideShops.GetShopID(current_session.GetSign()), current_session.GetSign()); + + if (shop.GetAmount()>0) { + current_session.SetSession(SessionState.UPDATE); + ev.getPlayer().sendMessage("Input how much each "+ChatColor.GREEN+shop.GetItemName()+ChatColor.WHITE+" will cost (Old value - "+ChatColor.YELLOW+"$"+df.format(shop.GetUnitPrice())+ChatColor.WHITE+":"); + } else { + ev.getPlayer().sendMessage(ChatColor.DARK_BLUE+"Shop successfully updated!"); + TwosideShops.RemoveSession(ev.getPlayer()); + } + } else { + ev.getPlayer().sendMessage("You only have "+shop.GetAmount()+" of "+ChatColor.GREEN+shop.GetItemName()+ChatColor.WHITE+" in the shop. Please try again."); + } + } + } else { + ev.getPlayer().sendMessage("That is not a valid number! Please try again."); + } + break; + case UPDATE: + if (isNumeric(ev.getMessage())) { + double amt = Double.parseDouble(ev.getMessage()); + WorldShop shop = TwosideShops.LoadWorldShopData(TwosideShops.GetShopID(current_session.GetSign())); + if (amt>0 && amt<=999999999999.99) { + shop.UpdateUnitPrice(amt); + TwosideShops.SaveWorldShopData(shop); + TwosideShops.UpdateSign(shop, TwosideShops.GetShopID(current_session.GetSign()), current_session.GetSign()); + ev.getPlayer().sendMessage(ChatColor.DARK_BLUE+"Shop successfully updated!"); + TwosideShops.RemoveSession(ev.getPlayer()); + } else { + if (amt>999999999999.99) { + ev.getPlayer().sendMessage("You cannot sell an item for that ridiculous amount. Please try again."); + } else { + ev.getPlayer().sendMessage("You cannot sell an item for free. Please try again."); + } + } + } else { + ev.getPlayer().sendMessage("That is not a valid number! Please try again."); + } + break; + case PURCHASE: + if (isNumeric(ev.getMessage())) { + DecimalFormat df = new DecimalFormat("0.00"); + int amt = Integer.parseInt(ev.getMessage()); + if (amt>0) { + int shopID = TwosideShops.GetShopID(current_session.GetSign()); + WorldShop shop = TwosideShops.LoadWorldShopData(shopID); + if (amt<=shop.GetAmount()) { + if (getPlayerMoney(ev.getPlayer())>=amt*shop.GetUnitPrice()) { + ev.getPlayer().sendMessage(ChatColor.DARK_BLUE+"Successfully bought "+amt+" "+ChatColor.GREEN+shop.GetItemName()+ChatColor.WHITE+"!"); + shop.UpdateAmount(shop.GetAmount()-amt); + ItemStack shopItem = shop.GetItem(); + int dropAmt = amt; + while (dropAmt>0) { + if (dropAmt>shop.GetItem().getMaxStackSize()) { + shopItem.setAmount(shop.GetItem().getMaxStackSize()); + final ItemStack dropitem = shopItem; + Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() { + @Override + public void run() { + ev.getPlayer().getWorld().dropItemNaturally(ev.getPlayer().getLocation(), dropitem).setPickupDelay(0); + } + },1); + dropAmt-=shop.GetItem().getMaxStackSize(); + } else { + shopItem.setAmount(dropAmt); + final ItemStack dropitem = shopItem; + Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() { + @Override + public void run() { + ev.getPlayer().getWorld().dropItemNaturally(ev.getPlayer().getLocation(), dropitem).setPickupDelay(0); + } + },1); + dropAmt=0; + } + } + TwosideShops.UpdateSign(shop, shopID, current_session.GetSign()); + TwosideShops.SaveWorldShopData(shop); + TwosideShops.RemoveSession(ev.getPlayer()); + givePlayerMoney(ev.getPlayer(), -amt*shop.GetUnitPrice()); + TwosideShops.AddNewPurchase(shop.GetOwner(), ev.getPlayer(), shop.GetItem(), amt*shop.GetUnitPrice(), amt); + if (Bukkit.getPlayer(shop.GetOwner())!=null) { + givePlayerMoney(Bukkit.getPlayer(shop.GetOwner()), amt*shop.GetUnitPrice()); + } else { + givePlayerMoney(shop.GetOwner(), amt*shop.GetUnitPrice()); + } + } else { + ev.getPlayer().sendMessage("You do not have enough money to buy that many (You can buy "+ChatColor.GREEN+(int)(getPlayerMoney(ev.getPlayer())/shop.GetUnitPrice())+ChatColor.WHITE+" of them)! Please try again."); + } + } else { + ev.getPlayer().sendMessage("There are only "+shop.GetAmount()+" of this item in the shop! Please try again."); + } + } else { + ev.getPlayer().sendMessage(ChatColor.RED+"Decided not to buy anything."); + TwosideShops.RemoveSession(ev.getPlayer()); + } + } else { + ev.getPlayer().sendMessage("That is not a valid number! Please try again."); + } + break; + default: + break; + } + ev.setMessage(""); + ev.setCancelled(true); + } else + for (int i=0;i-1) { + pos = ev.getMessage().indexOf("[]"); + ev.setMessage(ev.getMessage().replace("[]", "")); + //getLogger().info("pos is "+pos+" message is: {"+ev.getMessage()+"}"); + Bukkit.dispatchCommand(Bukkit.getConsoleSender(),"tellraw @a [\"\",{\"text\":\"<"+ev.getPlayer().getName()+"> \"},{\"text\":\""+ev.getMessage().substring(0, pos)+"\"},{\"text\":\""+ChatColor.GREEN+"["+ChatColor.stripColor(TwosideKeeper.GetItemName(ev.getPlayer().getEquipment().getItemInMainHand()))+ChatColor.GREEN+"]"+ChatColor.WHITE+"\",\"hoverEvent\":{\"action\":\"show_text\",\"value\":\""+TwosideKeeper.GetItemName(ev.getPlayer().getEquipment().getItemInMainHand())+"\n"+WorldShop.GetItemInfo(ev.getPlayer().getEquipment().getItemInMainHand()).replace("\"", "\\\"")+"\"}},{\"text\":\""+ev.getMessage().substring(pos)+"\"}]"); + ev.setCancelled(true); + } + //Bukkit.dispatchCommand(Bukkit.getConsoleSender(),"tellraw @a [\"\",{\"text\":\""+ChatColor.GREEN+"[Item]"+ChatColor.WHITE+"\",\"hoverEvent\":{\"action\":\"show_text\",\"value\":\""+(ev.getPlayer().getEquipment().getItemInMainHand().getType())+"\"}},{\"text\":\" "+ev.getMessage().substring(0, pos)+" \"}]"); + + } + } + + @EventHandler(priority=EventPriority.LOW) + public void onPlayerInteract(PlayerInteractEvent ev) { + Block b = ev.getClickedBlock(); + //getLogger().info("Interacting "+ev.getAction().toString()); + + //Pass along this event to Spleef Games. + TwosideSpleefGames.PassEvent(ev); + + final Player player = ev.getPlayer(); + Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() { + @Override + public void run() { + setPlayerMaxHealth(player); + } + },1); + + if (ev.getClickedBlock()!=null && ev.getClickedBlock().getType()==Material.CHEST && + TwosideRecyclingCenter.isChoosingRecyclingCenter() && + ev.getPlayer().hasPermission("TwosideKeeper.recyclingcenter")) { + TwosideRecyclingCenter.setChoosingRecyclingCenter(false); + //Create a new Recycling Center. + TwosideRecyclingCenter.AddNode(ev.getClickedBlock().getWorld(), ev.getClickedBlock().getLocation().getBlockX(), ev.getClickedBlock().getLocation().getBlockY(), ev.getClickedBlock().getLocation().getBlockZ()); + ev.getPlayer().sendMessage(ChatColor.DARK_BLUE+"New Recycling Center successfully created at "+ev.getClickedBlock().getLocation().toString()); + } + + //Shield related stuff in here. + if (ev.getAction()==Action.RIGHT_CLICK_AIR || + ev.getAction()==Action.RIGHT_CLICK_BLOCK) { + //See if this player is blocking. If so, give them absorption. + //Player p = ev.getPlayer(); + Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() { + @Override + public void run() { + if (player.isBlocking()) { + //Give absorption hearts. + if (isDefender(player)) { + player.addPotionEffect(new PotionEffect(PotionEffectType.ABSORPTION,200,1)); + + List entities = player.getNearbyEntities(16, 16, 16); + for (int i=0;i entities = ev.getPlayer().getWorld().getNearbyEntities(newloc, 1, 1, 1); + for (int i=0;i0) { + player.sendMessage("How many "+ChatColor.GREEN+shop.GetItemName()+ChatColor.WHITE+" would you like to buy? "+ChatColor.GREEN+"(MAX: "+((getPlayerMoney(player)<(shop.GetAmount()*shop.GetUnitPrice()))?(int)(getPlayerMoney(player)/shop.GetUnitPrice()):shop.GetAmount())+")"); + + //Initiate buying session. + TwosideShops.AddSession(SessionState.PURCHASE, player, s); + getLogger().info("Added a session."); + shop.sendItemInfo(player); + } else { + player.sendMessage(ChatColor.GOLD+"Sorry! "+ChatColor.WHITE+"This shop is sold out! Let "+ChatColor.LIGHT_PURPLE+shop.GetOwner()+ChatColor.WHITE+" know to restock the shop!"); + } + } + } + } + //Determine if this is a bank sign. + if (s.getLine(0).equalsIgnoreCase(ChatColor.AQUA+"-- BANK --")) { + //This is indeed a bank sign. Now figure out which one. + if (s.getLine(1).equalsIgnoreCase(ChatColor.GREEN+"CHECK BALANCE")) { + //Display the balance to the user. + DecimalFormat df = new DecimalFormat("0.00"); + ev.getPlayer().sendMessage("Your Bank Account currently has: "+ChatColor.BLUE+"$"+df.format(getPlayerBankMoney(ev.getPlayer()))); + } else + if (s.getLine(1).equalsIgnoreCase(ChatColor.DARK_RED+"WITHDRAW")) { + if (withdrawUser.equalsIgnoreCase("")) { + if (!depositUser.equalsIgnoreCase(ev.getPlayer().getName()) && + !conversionUser.equalsIgnoreCase(ev.getPlayer().getName())) { + ev.getPlayer().sendMessage(ChatColor.GOLD+"Say/Type the amount you want to WITHDRAW today."); + ev.getPlayer().sendMessage(" In Bank: "+ChatColor.BLUE+"$"+getPlayerBankMoney(ev.getPlayer())); + //Activate the terminal. + withdrawUser=ev.getPlayer().getName(); + withdrawTime=getServerTickTime(); + } else { + //Can't use if we're already using another terminal. + ev.getPlayer().sendMessage(ChatColor.RED+"You're already using another terminal. "+ChatColor.WHITE+"Please finish that operation first."); + } + } else { + if (!withdrawUser.equalsIgnoreCase(ev.getPlayer().getName())) { + ev.getPlayer().sendMessage(ChatColor.RED+"TERMINAL IS BEING USED. "+ChatColor.WHITE+"Please try again later."); + } + } + } else + if (s.getLine(1).equalsIgnoreCase(ChatColor.DARK_BLUE+"DEPOSIT")) { + if (depositUser.equalsIgnoreCase("")) { + if (!withdrawUser.equalsIgnoreCase(ev.getPlayer().getName()) && + !conversionUser.equalsIgnoreCase(ev.getPlayer().getName())) { + ev.getPlayer().sendMessage(ChatColor.GOLD+"Say/Type the amount you want to DEPOSIT today."); + ev.getPlayer().sendMessage(" Currently Holding: "+ChatColor.GREEN+"$"+getPlayerMoney(ev.getPlayer())); + //Activate the terminal. + depositUser=ev.getPlayer().getName(); + depositTime=getServerTickTime(); + } else { + //Can't use if we're already using another terminal. + ev.getPlayer().sendMessage(ChatColor.RED+"You're already using another terminal. "+ChatColor.WHITE+"Please finish that operation first."); + } + } else { + if (!depositUser.equalsIgnoreCase(ev.getPlayer().getName())) { + ev.getPlayer().sendMessage(ChatColor.RED+"TERMINAL IS BEING USED. "+ChatColor.WHITE+"Please try again later."); + } + } + } else + if (s.getLine(1).equalsIgnoreCase(ChatColor.DARK_BLUE+"EXP CONVERSION")) { + if (conversionUser.equalsIgnoreCase("")) { + if (!withdrawUser.equalsIgnoreCase(ev.getPlayer().getName()) && + !depositUser.equalsIgnoreCase(ev.getPlayer().getName())) { + ev.getPlayer().sendMessage(ChatColor.GOLD+"Say/Type the amount of experience you want to convert today."); + ev.getPlayer().sendMessage(" Currently Have: "+ChatColor.GREEN+ev.getPlayer().getLevel()+" levels"); + //Activate the terminal. + conversionUser=ev.getPlayer().getName(); + conversionTime=getServerTickTime(); + } else { + //Can't use if we're already using another terminal. + ev.getPlayer().sendMessage(ChatColor.RED+"You're already using another terminal. "+ChatColor.WHITE+"Please finish that operation first."); + } + } else { + if (!conversionUser.equalsIgnoreCase(ev.getPlayer().getName())) { + ev.getPlayer().sendMessage(ChatColor.RED+"TERMINAL IS BEING USED. "+ChatColor.WHITE+"Please try again later."); + } + } + } + } + } + } + + @EventHandler(priority=EventPriority.LOW) + public void onBlockPlace(BlockPlaceEvent ev) { + + TwosideSpleefGames.PassEvent(ev); + + if (ev.getItemInHand().hasItemMeta() && + ev.getItemInHand().getItemMeta().hasLore() && + ev.getItemInHand().getItemMeta().getLore().size()==4 && + ev.getItemInHand().getItemMeta().getLore().get(3).contains(ChatColor.DARK_PURPLE+"ID#")) { + //This is an item cube. + ev.setCancelled(true); + } + } + + @EventHandler(priority=EventPriority.LOW) + public void onPlayerDeath(PlayerDeathEvent ev) { + //Modify the death message. This is a fix for getting rid of the healthbar from the player name. + final Player p = ev.getEntity(); + if (!DeathManager.deathStructureExists(p)) { + String[] parsed_msg = ev.getDeathMessage().split(" "); + //Get rid of the name. + //NOTE: If you change how the suffix looks YOU MUST UPDATE THIS! + String newDeathMsg=""; + for (int i=2;i item_lore = ev.getCurrentItem().getItemMeta().getLore(); + if (item_lore.size()!=4) { + //Make sure it doesn't already have an ID. + item_lore.add(ChatColor.DARK_PURPLE+"ID#"+ITEMCUBEID); + item_meta.setLore(item_lore); + ev.getCurrentItem().setItemMeta(item_meta); + if (ev.getCurrentItem().getItemMeta().getDisplayName().contains("Ender Item Cube")) { + ev.getCurrentItem().setAmount(2); + } + CubeType cubetype; + if (ev.getCurrentItem().getItemMeta().getDisplayName().contains("Ender Item Cube")) { + cubetype=CubeType.ENDER; + } else if (ev.getCurrentItem().getItemMeta().getDisplayName().contains("Large Item Cube")) { + cubetype=CubeType.LARGE; + } else { + cubetype=CubeType.NORMAL; + } + itemCube_saveConfig(ITEMCUBEID, new ArrayList(), cubetype); + ITEMCUBEID++; + } + } + } + } + } + + @EventHandler(priority=EventPriority.LOW) + public void onPlayerDropItem(PlayerDropItemEvent ev) { + if (ev.getItemDrop().getItemStack().hasItemMeta()) { + if (ev.getItemDrop().getItemStack().getItemMeta().hasLore()) { + if (ev.getItemDrop().getItemStack().getItemMeta().getLore().size()==4) { + if (ev.getItemDrop().getItemStack().getItemMeta().getLore().get(3).contains(ChatColor.DARK_PURPLE+"ID#")) { + //We have an item cube. + int itemcube_id=Integer.parseInt(ev.getItemDrop().getItemStack().getItemMeta().getLore().get(3).split("#")[1]); + //Now we need to see if an item cube inventory of that ID is opened. + if (ev.getPlayer().getOpenInventory().getTitle().split("#").length>1 && itemcube_id==Integer.parseInt(ev.getPlayer().getOpenInventory().getTitle().split("#")[1])) { + //We have the same item cube opened. Save and close it immediately. + List itemlist = new ArrayList(); + for (int i=0;i itemcube_contents = itemCube_loadConfig(id); + for (int i=0;i0) { + ev.getInventory().setItem(i, itemcube_contents.get(i)); + } else { + ev.getInventory().setItem(i, new ItemStack(Material.AIR)); + } + } + } + } + } + } + + @EventHandler(priority=EventPriority.LOW) + public void onInventoryClose(InventoryCloseEvent ev) { + if (ev.getPlayer() instanceof Player) { + Player p = (Player)ev.getPlayer(); + if (ev.getInventory().getTitle().contains("Death Loot")) { + Location deathloc = DeathManager.getDeathStructure(p).deathloc; + //Whatever is left drops at the death location. + if (DeathManager.CountOccupiedSlots(p.getOpenInventory().getTopInventory())>0) { + p.sendMessage(ChatColor.GOLD+"The rest of your items have dropped at your death location!"); + } + double amounttotake = DeathManager.CountOccupiedSlots(p.getInventory())*DeathManager.CalculateDeathPrice(p); + if (getPlayerMoney(p)>=amounttotake) { + givePlayerMoney(p,getPlayerMoney(p)-amounttotake); + } else { + double diff = amounttotake-getPlayerMoney(p); + givePlayerMoney(p,-getPlayerMoney(p)); + amounttotake = diff; + givePlayerBankMoney(p,-amounttotake); + } + for (int i=0;i itemcube_contents = new ArrayList(); + for (int i=0;i0 && pd.saturation<20) { + pd.saturation+=2; + ((Player)ev.getEntity()).setSaturation(((Player)ev.getEntity()).getSaturation()-1); + getLogger().info("Saturation increased to "+pd.saturation+". Old saturation: "+((Player)ev.getEntity()).getSaturation()); + } + } + } + //((Player)ev.getEntity()).setSaturation(((Player)ev.getEntity()).getSaturation()+1.0f); + //We will never use saturation to heal. + } + } + + @EventHandler(priority=EventPriority.LOW) + public void onFoodLevelChange(FoodLevelChangeEvent ev) { + if (ev.getEntityType()==EntityType.PLAYER) { + Player p = (Player)ev.getEntity(); + if (p.getFoodLevel()ev.getFoodLevel()) { + //Find the player that is losing food level. + for (int i=0;i0) { + pd.saturation--; + ev.setFoodLevel(ev.getFoodLevel()+1); + getLogger().info("Saturation level is now "+(pd.saturation)+". Food level is now "+p.getFoodLevel()); + } + } + } + } + } + } + + @EventHandler(priority=EventPriority.LOW) + public void onInventoryClick(InventoryClickEvent ev) { + final Player player = (Player)ev.getWhoClicked(); + //Bukkit.getLogger().info("Clicked: "+ev.getRawSlot()); + Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() { + @Override + public void run() { + setPlayerMaxHealth(player); + } + },1); + + if (ev.getInventory().getTitle().equalsIgnoreCase("Death Loot")) { + //See how many items are in our inventory. Determine final balance. + //Count the occupied slots. + if (getPlayerMoney(player)+getPlayerBankMoney(player)-DeathManager.CalculateDeathPrice(player)*DeathManager.CountOccupiedSlots(player.getInventory())>=DeathManager.CalculateDeathPrice(player)) { + //player.getInventory().addItem(ev.getCurrentItem()); + player.getLocation().getWorld().dropItemNaturally(player.getLocation(), ev.getCurrentItem()).setPickupDelay(0); + ev.setCurrentItem(new ItemStack(Material.AIR)); + + final DecimalFormat df = new DecimalFormat("0.00"); + Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() { + @Override + public void run() { + player.sendMessage(ChatColor.BLUE+"New Balance: "+ChatColor.GREEN+"$"+df.format((getPlayerMoney(player)+getPlayerBankMoney(player)-DeathManager.CalculateDeathPrice(player)*DeathManager.CountOccupiedSlots(player.getInventory())))); + } + },5); + } else { + player.sendMessage(ChatColor.RED+"You cannot afford to salvage any more items!"); + } + ev.setCancelled(true); + } + //Check for a left click for an arrow quiver. + if (ev.getClick()==ClickType.LEFT) { + //Tries to take out 1 stack of arrows. + //We're going to try to deposit arrows. + if (ev.getCursor()!=null && ev.getCursor().getAmount()>0 && + ev.getCursor().getType()==Material.ARROW) { + Player p = (Player)ev.getWhoClicked(); + if (playerHasArrowQuiver(p)) { + boolean foundquiver=false; + int slot=-1; + if (p.getInventory().getItem(ev.getSlot())!=null && + p.getInventory().getItem(ev.getSlot()).getType()==Material.TIPPED_ARROW && + p.getInventory().getItem(ev.getSlot()).getEnchantmentLevel(Enchantment.ARROW_INFINITE)==5) { + //This is an arrow quiver. + foundquiver=true; + slot=ev.getSlot(); + } + if (foundquiver) { + //getLogger().info("An arrow quiver was right clicked."); + //Continue. + //Deposit the arrows we are holding. + + int amt=playerGetArrowQuiverAmt(p, slot); + playerInsertArrowQuiver(p, slot , ev.getCursor().getAmount()); + p.sendMessage(ChatColor.DARK_GRAY+""+ev.getCursor().getAmount()+" arrow"+((ev.getCursor().getAmount()==1)?"":"s")+" "+((ev.getCursor().getAmount()==1)?"was":"were")+" added to your arrow quiver. Arrow Count: "+ChatColor.GRAY+playerGetArrowQuiverAmt(p,playerGetArrowQuiver(p))); + ev.setCursor(new ItemStack(Material.AIR)); + //Cancel this click event. + ev.setCancelled(true); + ev.setResult(Result.DENY); + + } + } + } + } + + //Check for a right click for an arrow quiver. + if (ev.getClick()==ClickType.RIGHT && + ev.getCursor().getType()==Material.AIR) { + //Tries to take out 1 stack of arrows. + Player p = (Player)ev.getWhoClicked(); + if (playerHasArrowQuiver(p)) { + boolean foundquiver=false; + int slot=-1; + if (p.getInventory().getItem(ev.getSlot())!=null && + p.getInventory().getItem(ev.getSlot()).getType()==Material.TIPPED_ARROW && + p.getInventory().getItem(ev.getSlot()).getEnchantmentLevel(Enchantment.ARROW_INFINITE)==5) { + //This is an arrow quiver. + foundquiver=true; + slot=ev.getSlot(); + } + if (foundquiver) { + //getLogger().info("An arrow quiver was right clicked."); + //Continue. + //Try to withdraw 64 arrows. + int amt=playerGetArrowQuiverAmt(p, slot); + playerRemoveArrowQuiver(p, slot , (amt>64)?64:amt); + //Cancel this click event so we can grab the arrows inside. + ev.setCancelled(true); + ev.setResult(Result.DENY); + ItemStack arrow = new ItemStack(Material.ARROW,(amt>64)?64:amt); + ev.setCursor(arrow); + } + } + } + + //LEFT CLICK STUFF. + //WARNING! This only happens for ITEM CUBES! Do not add other items in here! + final InventoryClickEvent store = ev; + if ((ev.getInventory().getType()!=InventoryType.WORKBENCH || + (ev.getInventory().getType()==InventoryType.WORKBENCH && ev.getRawSlot()>9)) && ev.getInventory().getTitle().contains("Item Cube #")) { + //getLogger().info("Item Cube window identified."); + final int id=Integer.parseInt(ev.getInventory().getTitle().split("#")[1]); + //Check to see if the cursor item is an item cube. + Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() { + @Override + public void run() { + /* + if ((store.getCursor().getType()==Material.CHEST || + store.getCursor().getType()==Material.STORAGE_MINECART || + store.getCursor().getType()==Material.ENDER_CHEST) && + store.getCursor().hasItemMeta() && + store.getCursor().getItemMeta().hasLore()) { + getLogger().info("The clicked item has lore..."); + for (int i=0;i itemlist = new ArrayList(); + Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() { + @Override + public void run() { + for (int i=0;i9)) && ev.isLeftClick() && ev.getCurrentItem()!=null && ev.getCursor()!=null) { + if (ev.getCurrentItem().hasItemMeta() && (ev.getCursor().getType()!=Material.AIR)) { + ItemMeta item_meta = ev.getCurrentItem().getItemMeta(); + if (item_meta.hasLore()) { + List item_meta_lore = item_meta.getLore(); + if (item_meta_lore.size()==4 && item_meta_lore.get(3).contains(ChatColor.DARK_PURPLE+"ID#")) { + int idnumb = Integer.parseInt(item_meta_lore.get(3).split("#")[1]); + int itemcubeid = -1; //This is the ID of the window we are looking at, if one exists. + CubeType cubetype = CubeType.NORMAL; + //This is an Item Cube. + ev.setCancelled(true); + ev.setResult(Result.DENY); + + int size; + if (ev.getCurrentItem().getType()==Material.CHEST) { + size=9; + cubetype=CubeType.NORMAL; + } else { + size=27; + if (ev.getCurrentItem().getType()==Material.STORAGE_MINECART) { + cubetype=CubeType.LARGE; + } else { + cubetype=CubeType.ENDER; + } + } + + //See if we're looking at an Item Cube inventory already. + if (ev.getInventory().getTitle().contains("Item Cube")) { + //Check to see what the Item Cube ID is. + itemcubeid=Integer.parseInt(ev.getInventory().getTitle().split("#")[1]); + } + + //Check to see if the cursor item is an item cube. + if ((ev.getCursor().getType()==Material.CHEST || + ev.getCursor().getType()==Material.STORAGE_MINECART || + ev.getCursor().getType()==Material.ENDER_CHEST) && + ev.getCursor().hasItemMeta() && + ev.getCursor().getItemMeta().hasLore()) { + //getLogger().info("The clicked item has lore..."); + for (int i=0;i virtual_inventory = itemCube_loadConfig(idnumb); + boolean stack_available=false; + //Now we will see if there are any places to stack blocks on. + int quantity=ev.getCursor().getAmount(); + //getLogger().info("Amount held: "+quantity); + for (int i=0;ivirtual_inventory.get(i).getAmount()) { + //getLogger().info("Entered Loop"); + //This is the same, and we have room to throw some in. + int space=virtual_inventory.get(i).getMaxStackSize()-virtual_inventory.get(i).getAmount(); //How much space is here. + //getLogger().info("There is space for "+space+" blocks."); + if (space>=quantity) { + //We are done, because we can store everything. + virtual_inventory.get(i).setAmount(virtual_inventory.get(i).getAmount()+quantity); + quantity=0; + final int ider = idnumb; + final List items = virtual_inventory; + final CubeType type = cubetype; + + if (itemCube_getCubeType(idnumb)==CubeType.ENDER) { + //getLogger().info("This is an Ender Item Cube transfer click."); + //We are going to look at all players and see if they have this inventory open. + final int id = idnumb; + for (int j=0;j0) { + //We can't fit this anywhere else. So we put the rest back to the cursor. + ev.getCursor().setAmount(quantity); + } else { + stack_available=true; + } + + if (stack_available) { + ev.setCursor(new ItemStack(Material.AIR)); + itemCube_saveConfig(idnumb,virtual_inventory,cubetype); + } else { + //Look for an empty space. + for (int i=0;i items = virtual_inventory; + final CubeType type = cubetype; + + if (itemCube_getCubeType(idnumb)==CubeType.ENDER) { + //getLogger().info("This is an Ender Item Cube transfer click."); + //We are going to look at all players and see if they have this inventory open. + final int id = idnumb; + for (int j=0;jev.getView().getTopInventory().getItem(i).getAmount()) { + //getLogger().info("Entered Loop"); + //This is the same, and we have room to throw some in. + int space=ev.getView().getTopInventory().getItem(i).getMaxStackSize()-ev.getView().getTopInventory().getItem(i).getAmount(); //How much space is here. + //getLogger().info("There is space for "+space+" blocks."); + if (space>=quantity) { + //We are done, because we can store everything. + ev.getView().getTopInventory().getItem(i).setAmount(ev.getView().getTopInventory().getItem(i).getAmount()+quantity); + quantity=0; + List itemlist = new ArrayList(); + for (int j=0;j items = itemlist; + final CubeType type = cubetype; + if (itemCube_getCubeType(idnumb)==CubeType.ENDER) { + //getLogger().info("This is an Ender Item Cube transfer click."); + //We are going to look at all players and see if they have this inventory open. + final int id = idnumb; + for (int j=0;j itemlist = new ArrayList(); + for (int j=0;j items = itemlist; + final CubeType type = cubetype; + Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() { + @Override + public void run() { + itemCube_saveConfig(ider,items,type); + } + },2); + } + } + } + } + if (quantity>0) { + //We can't fit this anywhere else. So we put the rest back to the cursor. + ev.getCursor().setAmount(quantity); + } else { + stack_available=true; + } + + if (stack_available) { + ev.setCursor(new ItemStack(Material.AIR)); + } else { + for (int i=0;i9)) && ev.isRightClick() && ev.getCurrentItem()!=null && ev.getCurrentItem().getAmount()==1) { + //getLogger().info(ev.getCurrentItem().toString()); + if (ev.getCurrentItem().hasItemMeta()) { + //getLogger().info("Item Meta: "+ev.getCurrentItem().getItemMeta().toString()); + ItemMeta item_meta = ev.getCurrentItem().getItemMeta(); + if (item_meta.hasLore()) { + List item_meta_lore = item_meta.getLore(); + if (item_meta_lore.size()==4 && item_meta_lore.get(3).contains(ChatColor.DARK_PURPLE+"ID#")) { + int idnumb = Integer.parseInt(item_meta_lore.get(3).split("#")[1]); + //getLogger().info("This is an Item Cube."); + List viewers = ev.getViewers(); + for (int i=0;i0 && Math.random()*100=4) { + if (Math.abs(arrowLoc.getY()-monsterHead.getY())<=0.165/HEADSHOT_ACC) { + //getLogger().info("Height discrepancy is good."); + if (Math.abs(arrowLoc.getZ()-monsterHead.getZ())<=3.0/HEADSHOT_ACC && + Math.abs(arrowLoc.getX()-monsterHead.getX())<=3.0/HEADSHOT_ACC) { + ev.setDamage(ev.getDamage()*8.0); + p.sendMessage(ChatColor.DARK_RED+"Headshot! x8 Damage"); + headshot=true; + } + } + } + + //Make this monster the player's new target. + for (int i=0;i lore = new ArrayList(); + lore.add(ChatColor.GRAY+"Breaks Remaining: "+ChatColor.YELLOW+"2"); + sword_meta.setLore(lore); + } + raresword.setItemMeta(sword_meta); + raresword.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 10); + raresword.addUnsafeEnchantment(Enchantment.DAMAGE_ARTHROPODS, 10); + raresword.addUnsafeEnchantment(Enchantment.DAMAGE_UNDEAD, 10); + ev.getDrops().add(raresword); + } + if (Math.random()<0.00390625*dropmult) { + ev.getDrops().add(Artifact.createArtifactItem(ArtifactItem.ANCIENT_ESSENCE)); + } + } + } + if (m.getCustomName().contains("Deadly")) { + m.getWorld().playSound(m.getLocation(), Sound.ENTITY_CREEPER_PRIMED, 1.0f, 1.0f); + Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() { + public void run() { + if (m.getLocation().getBlockY()<48) { + m.getWorld().createExplosion(m.getLocation().getBlockX(), m.getLocation().getBlockY(), m.getLocation().getBlockZ(), 3.0f, false, true); + } else { + m.getWorld().createExplosion(m.getLocation().getBlockX(), m.getLocation().getBlockY(), m.getLocation().getBlockZ(), 6.0f, false, false); + } + }} + ,20); + if (m.getKiller()!=null) { //Make sure a player actually killed this. + ev.setDroppedExp(ev.getDroppedExp()*8); + + if (Math.random()<0.5*dropmult) { + //m.getWorld().dropItemNaturally(m.getLocation(), new ItemStack(Material.DIAMOND)); + ev.getDrops().add(new ItemStack(Material.DIAMOND)); + } + if (Math.random() lore = new ArrayList(); + lore.add(ChatColor.GRAY+"Breaks Remaining: "+ChatColor.YELLOW+((int)(Math.random()*6)+2)); + sword_meta.setLore(lore); + } + raresword.setItemMeta(sword_meta); + raresword.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 10); + raresword.addUnsafeEnchantment(Enchantment.DAMAGE_ARTHROPODS, 10); + raresword.addUnsafeEnchantment(Enchantment.DAMAGE_UNDEAD, 10); + ev.getDrops().add(raresword); + } + if (Math.random() lore = new ArrayList(); + lore.add(ChatColor.GRAY+"Breaks Remaining: "+ChatColor.YELLOW+((int)(Math.random()*6)+2)); + sword_meta.setLore(lore); + } + raresword.setItemMeta(sword_meta); + raresword.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 10); + raresword.addUnsafeEnchantment(Enchantment.DAMAGE_ARTHROPODS, 10); + raresword.addUnsafeEnchantment(Enchantment.DAMAGE_UNDEAD, 10); + raresword.addUnsafeEnchantment(Enchantment.DURABILITY, 10); + ev.getDrops().add(raresword); + } + if (Math.random() lore = new ArrayList(); + lore.add(ChatColor.BLUE+""+ChatColor.ITALIC+"Hardened Armor"); + lore.add(ChatColor.GRAY+"Twice as strong"); + lore.add(ChatColor.GRAY+"Breaks Remaining: "+ChatColor.YELLOW+((int)(Math.random()*6)+2)); + sword_meta.setLore(lore); + } + raresword.setItemMeta(sword_meta); + raresword.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 10); + raresword.addUnsafeEnchantment(Enchantment.PROTECTION_EXPLOSIONS, 10); + raresword.addUnsafeEnchantment(Enchantment.PROTECTION_FALL, 10); + raresword.addUnsafeEnchantment(Enchantment.PROTECTION_FIRE, 10); + raresword.addUnsafeEnchantment(Enchantment.PROTECTION_PROJECTILE, 10); + raresword.addUnsafeEnchantment(Enchantment.DURABILITY, 10); + ev.getDrops().add(raresword); + } + if (Math.random() lore = new ArrayList(); + lore.add(ChatColor.BLUE+""+ChatColor.ITALIC+"Hardened Armor"); + lore.add(ChatColor.GRAY+"Twice as strong"); + lore.add(ChatColor.GRAY+"Breaks Remaining: "+ChatColor.YELLOW+((int)(Math.random()*6)+2)); + sword_meta.setLore(lore); + } + raresword.setItemMeta(sword_meta); + raresword.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 10); + raresword.addUnsafeEnchantment(Enchantment.PROTECTION_EXPLOSIONS, 10); + raresword.addUnsafeEnchantment(Enchantment.PROTECTION_FALL, 10); + raresword.addUnsafeEnchantment(Enchantment.PROTECTION_FIRE, 10); + raresword.addUnsafeEnchantment(Enchantment.PROTECTION_PROJECTILE, 10); + raresword.addUnsafeEnchantment(Enchantment.DURABILITY, 10); + ev.getDrops().add(raresword); + } + if (Math.random() lore = new ArrayList(); + lore.add(ChatColor.BLUE+""+ChatColor.ITALIC+"Hardened Armor"); + lore.add(ChatColor.GRAY+"Twice as strong"); + lore.add(ChatColor.GRAY+"Breaks Remaining: "+ChatColor.YELLOW+((int)(Math.random()*6)+2)); + sword_meta.setLore(lore); + } + raresword.setItemMeta(sword_meta); + raresword.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 10); + raresword.addUnsafeEnchantment(Enchantment.PROTECTION_EXPLOSIONS, 10); + raresword.addUnsafeEnchantment(Enchantment.PROTECTION_FALL, 10); + raresword.addUnsafeEnchantment(Enchantment.PROTECTION_FIRE, 10); + raresword.addUnsafeEnchantment(Enchantment.PROTECTION_PROJECTILE, 10); + raresword.addUnsafeEnchantment(Enchantment.DURABILITY, 10); + ev.getDrops().add(raresword); + } + if (Math.random() lore = new ArrayList(); + lore.add(ChatColor.BLUE+""+ChatColor.ITALIC+"Hardened Armor"); + lore.add(ChatColor.GRAY+"Twice as strong"); + lore.add(ChatColor.GRAY+"Breaks Remaining: "+ChatColor.YELLOW+((int)(Math.random()*6)+2)); + sword_meta.setLore(lore); + } + raresword.setItemMeta(sword_meta); + raresword.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 10); + raresword.addUnsafeEnchantment(Enchantment.PROTECTION_EXPLOSIONS, 10); + raresword.addUnsafeEnchantment(Enchantment.PROTECTION_FALL, 10); + raresword.addUnsafeEnchantment(Enchantment.PROTECTION_FIRE, 10); + raresword.addUnsafeEnchantment(Enchantment.PROTECTION_PROJECTILE, 10); + raresword.addUnsafeEnchantment(Enchantment.DURABILITY, 10); + ev.getDrops().add(raresword); + } + if (Math.random() lore = new ArrayList(); + lore.add(ChatColor.GRAY+"Breaks Remaining: "+ChatColor.YELLOW+((int)(Math.random()*6)+2)); + sword_meta.setLore(lore); + } + raresword.setItemMeta(sword_meta); + raresword.addUnsafeEnchantment(Enchantment.DIG_SPEED, 10); + raresword.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 10); + raresword.addUnsafeEnchantment(Enchantment.LOOT_BONUS_BLOCKS, 10); + raresword.addUnsafeEnchantment(Enchantment.KNOCKBACK, 1); + raresword.addUnsafeEnchantment(Enchantment.DURABILITY, 10); + ev.getDrops().add(raresword); + } + if (Math.random() lore = new ArrayList(); + lore.add(ChatColor.GRAY+"Breaks Remaining: "+ChatColor.YELLOW+((int)(Math.random()*6)+2)); + sword_meta.setLore(lore); + } + raresword.setItemMeta(sword_meta); + raresword.addUnsafeEnchantment(Enchantment.DIG_SPEED, 10); + raresword.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 10); + raresword.addUnsafeEnchantment(Enchantment.LOOT_BONUS_MOBS, 10); + raresword.addUnsafeEnchantment(Enchantment.KNOCKBACK, 1); + raresword.addUnsafeEnchantment(Enchantment.DURABILITY, 10); + ev.getDrops().add(raresword); + } + if (Math.random() lore = new ArrayList(); + lore.add(ChatColor.GRAY+"Breaks Remaining: "+ChatColor.YELLOW+((int)(Math.random()*6)+2)); + sword_meta.setLore(lore); + } + raresword.setItemMeta(sword_meta); + raresword.addUnsafeEnchantment(Enchantment.DIG_SPEED, 10); + raresword.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 10); + raresword.addUnsafeEnchantment(Enchantment.LOOT_BONUS_BLOCKS, 10); + raresword.addUnsafeEnchantment(Enchantment.KNOCKBACK, 1); + raresword.addUnsafeEnchantment(Enchantment.DURABILITY, 10); + ev.getDrops().add(raresword); + } + if (Math.random() lore = new ArrayList(); + lore.add(ChatColor.GRAY+"Breaks Remaining: "+ChatColor.YELLOW+((int)(Math.random()*6)+2)); + sword_meta.setLore(lore); + } + raresword.setItemMeta(sword_meta); + raresword.addUnsafeEnchantment(Enchantment.DIG_SPEED, 10); + raresword.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 10); + raresword.addUnsafeEnchantment(Enchantment.LOOT_BONUS_MOBS, 10); + raresword.addUnsafeEnchantment(Enchantment.KNOCKBACK, 10); + raresword.addUnsafeEnchantment(Enchantment.DURABILITY, 10); + ev.getDrops().add(raresword); + } + if (Math.random()<0.00390625*dropmult) { + ev.getDrops().add(Artifact.createArtifactItem(ArtifactItem.LOST_ESSENCE)); + } + final List drops = new ArrayList(); + drops.addAll(ev.getDrops()); + ev.getDrops().clear(); + Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() { + public void run() { + for (int i=0;i lore = new ArrayList(); + lore.add(ChatColor.GRAY+"Breaks Remaining: "+ChatColor.YELLOW+((int)(Math.random()*7)+4)); + sword_meta.setLore(lore); + } + raresword.setItemMeta(sword_meta); + raresword.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 10); + raresword.addUnsafeEnchantment(Enchantment.DAMAGE_ARTHROPODS, 10); + raresword.addUnsafeEnchantment(Enchantment.DAMAGE_UNDEAD, 10); + raresword.addUnsafeEnchantment(Enchantment.DURABILITY, 10); + ev.getDrops().add(raresword); + } + if (Math.random() lore = new ArrayList(); + lore.add(ChatColor.BLUE+""+ChatColor.ITALIC+"Hardened Armor"); + lore.add(ChatColor.GRAY+"Twice as strong"); + lore.add(ChatColor.GRAY+"Breaks Remaining: "+ChatColor.YELLOW+((int)(Math.random()*7)+4)); + sword_meta.setLore(lore); + } + raresword.setItemMeta(sword_meta); + raresword.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 10); + raresword.addUnsafeEnchantment(Enchantment.PROTECTION_EXPLOSIONS, 10); + raresword.addUnsafeEnchantment(Enchantment.PROTECTION_FALL, 10); + raresword.addUnsafeEnchantment(Enchantment.PROTECTION_FIRE, 10); + raresword.addUnsafeEnchantment(Enchantment.PROTECTION_PROJECTILE, 10); + raresword.addUnsafeEnchantment(Enchantment.DURABILITY, 10); + ev.getDrops().add(raresword); + } + if (Math.random() lore = new ArrayList(); + lore.add(ChatColor.BLUE+""+ChatColor.ITALIC+"Hardened Armor"); + lore.add(ChatColor.GRAY+"Twice as strong"); + lore.add(ChatColor.GRAY+"Breaks Remaining: "+ChatColor.YELLOW+((int)(Math.random()*7)+4)); + sword_meta.setLore(lore); + } + raresword.setItemMeta(sword_meta); + raresword.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 10); + raresword.addUnsafeEnchantment(Enchantment.PROTECTION_EXPLOSIONS, 10); + raresword.addUnsafeEnchantment(Enchantment.PROTECTION_FALL, 10); + raresword.addUnsafeEnchantment(Enchantment.PROTECTION_FIRE, 10); + raresword.addUnsafeEnchantment(Enchantment.PROTECTION_PROJECTILE, 10); + raresword.addUnsafeEnchantment(Enchantment.DURABILITY, 10); + ev.getDrops().add(raresword); + } + if (Math.random() lore = new ArrayList(); + lore.add(ChatColor.BLUE+""+ChatColor.ITALIC+"Hardened Armor"); + lore.add(ChatColor.GRAY+"Twice as strong"); + lore.add(ChatColor.GRAY+"Breaks Remaining: "+ChatColor.YELLOW+((int)(Math.random()*7)+4)); + sword_meta.setLore(lore); + } + raresword.setItemMeta(sword_meta); + raresword.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 10); + raresword.addUnsafeEnchantment(Enchantment.PROTECTION_EXPLOSIONS, 10); + raresword.addUnsafeEnchantment(Enchantment.PROTECTION_FALL, 10); + raresword.addUnsafeEnchantment(Enchantment.PROTECTION_FIRE, 10); + raresword.addUnsafeEnchantment(Enchantment.PROTECTION_PROJECTILE, 10); + raresword.addUnsafeEnchantment(Enchantment.DURABILITY, 10); + ev.getDrops().add(raresword); + } + if (Math.random() lore = new ArrayList(); + lore.add(ChatColor.BLUE+""+ChatColor.ITALIC+"Hardened Armor"); + lore.add(ChatColor.GRAY+"Twice as strong"); + lore.add(ChatColor.GRAY+"Breaks Remaining: "+ChatColor.YELLOW+((int)(Math.random()*7)+4)); + sword_meta.setLore(lore); + } + raresword.setItemMeta(sword_meta); + raresword.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 10); + raresword.addUnsafeEnchantment(Enchantment.PROTECTION_EXPLOSIONS, 10); + raresword.addUnsafeEnchantment(Enchantment.PROTECTION_FALL, 10); + raresword.addUnsafeEnchantment(Enchantment.PROTECTION_FIRE, 10); + raresword.addUnsafeEnchantment(Enchantment.PROTECTION_PROJECTILE, 10); + raresword.addUnsafeEnchantment(Enchantment.DURABILITY, 10); + ev.getDrops().add(raresword); + } + if (Math.random() lore = new ArrayList(); + lore.add(ChatColor.BLUE+""+ChatColor.ITALIC+"Hardened Armor"); + lore.add(ChatColor.GRAY+"Twice as strong"); + lore.add(ChatColor.GRAY+"Breaks Remaining: "+ChatColor.YELLOW+((int)(Math.random()*14)+8)); + sword_meta.setLore(lore); + } + raresword.setItemMeta(sword_meta); + raresword.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 10); + raresword.addUnsafeEnchantment(Enchantment.PROTECTION_EXPLOSIONS, 10); + raresword.addUnsafeEnchantment(Enchantment.PROTECTION_FALL, 10); + raresword.addUnsafeEnchantment(Enchantment.PROTECTION_FIRE, 10); + raresword.addUnsafeEnchantment(Enchantment.PROTECTION_PROJECTILE, 10); + raresword.addUnsafeEnchantment(Enchantment.DURABILITY, 10); + ev.getDrops().add(raresword); + } + if (Math.random() lore = new ArrayList(); + lore.add(ChatColor.BLUE+""+ChatColor.ITALIC+"Hardened Armor"); + lore.add(ChatColor.GRAY+"Twice as strong"); + lore.add(ChatColor.GRAY+"Breaks Remaining: "+ChatColor.YELLOW+((int)(Math.random()*14)+8)); + sword_meta.setLore(lore); + } + raresword.setItemMeta(sword_meta); + raresword.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 10); + raresword.addUnsafeEnchantment(Enchantment.PROTECTION_EXPLOSIONS, 10); + raresword.addUnsafeEnchantment(Enchantment.PROTECTION_FALL, 10); + raresword.addUnsafeEnchantment(Enchantment.PROTECTION_FIRE, 10); + raresword.addUnsafeEnchantment(Enchantment.PROTECTION_PROJECTILE, 10); + raresword.addUnsafeEnchantment(Enchantment.DURABILITY, 10); + ev.getDrops().add(raresword); + } + if (Math.random() lore = new ArrayList(); + lore.add(ChatColor.BLUE+""+ChatColor.ITALIC+"Hardened Armor"); + lore.add(ChatColor.GRAY+"Twice as strong"); + lore.add(ChatColor.GRAY+"Breaks Remaining: "+ChatColor.YELLOW+((int)(Math.random()*14)+8)); + sword_meta.setLore(lore); + } + raresword.setItemMeta(sword_meta); + raresword.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 10); + raresword.addUnsafeEnchantment(Enchantment.PROTECTION_EXPLOSIONS, 10); + raresword.addUnsafeEnchantment(Enchantment.PROTECTION_FALL, 10); + raresword.addUnsafeEnchantment(Enchantment.PROTECTION_FIRE, 10); + raresword.addUnsafeEnchantment(Enchantment.PROTECTION_PROJECTILE, 10); + raresword.addUnsafeEnchantment(Enchantment.DURABILITY, 10); + ev.getDrops().add(raresword); + } + if (Math.random() lore = new ArrayList(); + lore.add(ChatColor.BLUE+""+ChatColor.ITALIC+"Hardened Armor"); + lore.add(ChatColor.GRAY+"Twice as strong"); + lore.add(ChatColor.GRAY+"Breaks Remaining: "+ChatColor.YELLOW+((int)(Math.random()*14)+8)); + sword_meta.setLore(lore); + } + raresword.setItemMeta(sword_meta); + raresword.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 10); + raresword.addUnsafeEnchantment(Enchantment.PROTECTION_EXPLOSIONS, 10); + raresword.addUnsafeEnchantment(Enchantment.PROTECTION_FALL, 10); + raresword.addUnsafeEnchantment(Enchantment.PROTECTION_FIRE, 10); + raresword.addUnsafeEnchantment(Enchantment.PROTECTION_PROJECTILE, 10); + raresword.addUnsafeEnchantment(Enchantment.DURABILITY, 10); + ev.getDrops().add(raresword); + } + if (Math.random() lore = new ArrayList(); + lore.add(ChatColor.GRAY+"Breaks Remaining: "+ChatColor.YELLOW+((int)(Math.random()*14)+8)); + sword_meta.setLore(lore); + } + raresword.setItemMeta(sword_meta); + raresword.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 10); + raresword.addUnsafeEnchantment(Enchantment.DAMAGE_ARTHROPODS, 10); + raresword.addUnsafeEnchantment(Enchantment.DAMAGE_UNDEAD, 10); + raresword.addUnsafeEnchantment(Enchantment.DURABILITY, 10); + ev.getDrops().add(raresword); + } + + if (Math.random() lore = new ArrayList(); + lore.add(ChatColor.GRAY+"Breaks Remaining: "+ChatColor.YELLOW+((int)(Math.random()*6)+2)); + sword_meta.setLore(lore); + } + raresword.setItemMeta(sword_meta); + raresword.addUnsafeEnchantment(Enchantment.DIG_SPEED, 10); + raresword.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 10); + raresword.addUnsafeEnchantment(Enchantment.LOOT_BONUS_BLOCKS, 10); + raresword.addUnsafeEnchantment(Enchantment.KNOCKBACK, 1); + raresword.addUnsafeEnchantment(Enchantment.DURABILITY, 10); + ev.getDrops().add(raresword); + } + if (Math.random() lore = new ArrayList(); + lore.add(ChatColor.GRAY+"Breaks Remaining: "+ChatColor.YELLOW+((int)(Math.random()*6)+2)); + sword_meta.setLore(lore); + } + raresword.setItemMeta(sword_meta); + raresword.addUnsafeEnchantment(Enchantment.DIG_SPEED, 10); + raresword.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 10); + raresword.addUnsafeEnchantment(Enchantment.LOOT_BONUS_MOBS, 10); + raresword.addUnsafeEnchantment(Enchantment.KNOCKBACK, 1); + raresword.addUnsafeEnchantment(Enchantment.DURABILITY, 10); + ev.getDrops().add(raresword); + } + if (Math.random() lore = new ArrayList(); + lore.add(ChatColor.GRAY+"Breaks Remaining: "+ChatColor.YELLOW+((int)(Math.random()*6)+2)); + sword_meta.setLore(lore); + } + raresword.setItemMeta(sword_meta); + raresword.addUnsafeEnchantment(Enchantment.DIG_SPEED, 10); + raresword.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 10); + raresword.addUnsafeEnchantment(Enchantment.LOOT_BONUS_BLOCKS, 10); + raresword.addUnsafeEnchantment(Enchantment.KNOCKBACK, 1); + raresword.addUnsafeEnchantment(Enchantment.DURABILITY, 10); + ev.getDrops().add(raresword); + } + if (Math.random() lore = new ArrayList(); + lore.add(ChatColor.GRAY+"Breaks Remaining: "+ChatColor.YELLOW+((int)(Math.random()*6)+2)); + sword_meta.setLore(lore); + } + raresword.setItemMeta(sword_meta); + raresword.addUnsafeEnchantment(Enchantment.DIG_SPEED, 10); + raresword.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 10); + raresword.addUnsafeEnchantment(Enchantment.LOOT_BONUS_MOBS, 10); + raresword.addUnsafeEnchantment(Enchantment.KNOCKBACK, 10); + raresword.addUnsafeEnchantment(Enchantment.DURABILITY, 10); + ev.getDrops().add(raresword); + } + if (Math.random() lore = new ArrayList(); + lore.add(ChatColor.GRAY+"Breaks Remaining: "+ChatColor.YELLOW+((int)(Math.random()*7)+4)); + sword_meta.setLore(lore); + } + raresword.setItemMeta(sword_meta); + raresword.addUnsafeEnchantment(Enchantment.ARROW_DAMAGE, 10); + raresword.addUnsafeEnchantment(Enchantment.ARROW_KNOCKBACK, 2); + raresword.addUnsafeEnchantment(Enchantment.DURABILITY, 10); + ev.getDrops().add(raresword); + } + if (Math.random()<0.00390625*dropmult) { + ev.getDrops().add(Artifact.createArtifactItem(ArtifactItem.DIVINE_ESSENCE)); + } + } + final List drops = new ArrayList(); + drops.addAll(ev.getDrops()); + ev.getDrops().clear(); + Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() { + public void run() { + for (int i=0;i0) { + //item.setAmount(1); + breakHardenedItem(item); + } else + { + p.sendMessage(ChatColor.DARK_RED+"Your "+ChatColor.YELLOW+item.getType().toString().replaceAll("_", " ")+ChatColor.DARK_RED+" has broken!"); + } + + } + + @EventHandler(priority=EventPriority.LOW) + public void onBlockBreak(BlockBreakEvent ev) { + + TwosideSpleefGames.PassEvent(ev); + + Player p = ev.getPlayer(); + if (p!=null) { + getLogger().info(p.getName()+" has broken block "+TwosideKeeper.UserFriendlyMaterialName(new ItemStack(ev.getBlock().getType()))); + } + + if (ev.getBlock().getType()==Material.WALL_SIGN) { + //We're going to make sure if it's a shop or not. + Sign s = (Sign)(ev.getBlock().getState()); + if (s.getLine(0).equalsIgnoreCase(ChatColor.BLUE+"-- SHOP --")) { + //This is a shop. Let's find out who the owner is. + int shopID = TwosideShops.GetShopID(s); + WorldShop shop = TwosideShops.LoadWorldShopData(shopID); + String owner = shop.GetOwner(); + if (owner.equalsIgnoreCase(p.getName()) || p.isOp()) { + //We are going to see if this shop had items in it. + if (shop.GetAmount()>0) { + //It did, we are going to release those items. + ItemStack drop = shop.GetItem(); + int dropAmt = shop.GetAmount(); + while (dropAmt>0) { + if (dropAmt>shop.GetItem().getMaxStackSize()) { + drop.setAmount(shop.GetItem().getMaxStackSize()); + ev.getPlayer().getWorld().dropItemNaturally(ev.getPlayer().getLocation(), drop).setPickupDelay(0); + dropAmt-=shop.GetItem().getMaxStackSize(); + } else { + drop.setAmount(dropAmt); + ev.getPlayer().getWorld().dropItemNaturally(ev.getPlayer().getLocation(), drop).setPickupDelay(0); + dropAmt=0; + } + } + //ev.getPlayer().getLocation().getWorld().dropItemNaturally(ev.getPlayer().getLocation(), drop).setPickupDelay(0); + } + //Remove the itemstack that represented this item. + Collection nearby = ev.getPlayer().getWorld().getNearbyEntities(ev.getBlock().getLocation(), 3, 3, 3); + for (int i=0;i arrow_quiver_lore = new ArrayList(); + arrow_quiver_lore.add("A quiver that holds many arrows."); + arrow_quiver_lore.add(ChatColor.GRAY+"Arrows Remaining: "+ChatColor.YELLOW+(ArrowQuiver_amt-1)); + ItemMeta arrow_quiver_meta=ArrowQuiver.getItemMeta(); + arrow_quiver_meta.setLore(arrow_quiver_lore); + arrow_quiver_meta.setDisplayName(ChatColor.BLUE+"Arrow Quiver"); + ArrowQuiver.setItemMeta(arrow_quiver_meta); + + ArrowQuiver.addUnsafeEnchantment(Enchantment.ARROW_INFINITE, 5); + + ArrowQuiver.setAmount(1); + if (!offhand) {p.getInventory().addItem(ArrowQuiver);} else {p.getInventory().setItemInOffHand(ArrowQuiver);} + } else { + p.sendMessage(ChatColor.ITALIC+""+ChatColor.GRAY+"If you are trying to shoot a regular arrow, put it inside your quiver and shoot again."); + } + } + }} + ,5); + } + } + + } + } + + + @EventHandler(priority=EventPriority.LOW) + public void onItemCraftEvent(PrepareItemCraftEvent ev) { + ItemStack result = ev.getInventory().getResult(); + if (result.getType()==Material.TNT) { + result.setAmount(result.getAmount()*5); //TNT recipes are 5 times as effective. + } + } + + @EventHandler(priority=EventPriority.LOW) + public void MinecartExitEvent(VehicleExitEvent ev) { + if (ev.getExited() instanceof Player && + ev.getVehicle().getType()==EntityType.MINECART) { + Player p = (Player)(ev.getExited()); + //p.sendMessage("Off."); + //Drop a minecart at the position. + ev.getVehicle().getWorld().dropItemNaturally(ev.getVehicle().getLocation().add(0,1,0), new ItemStack(Material.MINECART)); + ev.getVehicle().remove(); + } + } + + @EventHandler(priority=EventPriority.LOW) + public void onTeleportEvent(PlayerTeleportEvent ev) { + if (ev.getCause().equals(TeleportCause.END_PORTAL)) { + Player p = ev.getPlayer(); + for (int i=0;i=10000) {weather="\u263D";} else {weather="\u2600";}} + if (time>0 && time<=3000) { + ev.setMotd("\u00A7bsig's Minecraft!\n"+weather+" \u00A7fCurrently: \u00A7eMORNING"); + } else + if (time>3000 && time<=10000) { + ev.setMotd("\u00A7bsig's Minecraft!\n"+weather+" \u00A7fCurrently: \u00A76AFTERNOON"); + } else + if (time>10000 && time<=13000) { + ev.setMotd("\u00A7bsig's Minecraft!\n"+weather+" \u00A7fCurrently: \u00A73EVENING"); + } else + if (time>13000 && time<23000) { + ev.setMotd("\u00A7bsig's Minecraft!\n"+weather+" \u00A7fCurrently: \u00A79NIGHT"); + } else { + ev.setMotd("\u00A7bsig's Minecraft!\n"+weather+" \u00A7fCurrently: \u00A7dDAWN"); + } + } + + public void saveOurData(){ + getConfig().set("SERVERTICK", getServerTickTime()); //Add to how many ticks we've used. + getConfig().set("DAYMULT", DAYMULT); + getConfig().set("SERVERCHECKERTICKS", SERVERCHECKERTICKS); + getConfig().set("TERMINALTIME", TERMINALTIME); + getConfig().set("DEATHPENALTY", DEATHPENALTY); + getConfig().set("RECYCLECHANCE", RECYCLECHANCE); + getConfig().set("RECYCLEDECAYAMT", RECYCLEDECAYAMT); + getConfig().set("ITEMCUBEID", ITEMCUBEID); + getConfig().set("ARMOR/ARMOR_LEATHER_HP", ARMOR_LEATHER_HP); + getConfig().set("ARMOR/ARMOR_IRON_HP", ARMOR_IRON_HP); + getConfig().set("ARMOR/ARMOR_GOLD_HP", ARMOR_GOLD_HP); + getConfig().set("ARMOR/ARMOR_DIAMOND_HP", ARMOR_DIAMOND_HP); + getConfig().set("ARMOR/ARMOR_IRONBLOCK_HP", ARMOR_IRON2_HP); + getConfig().set("ARMOR/ARMOR_GOLDBLOCK_HP", ARMOR_GOLD2_HP); + getConfig().set("ARMOR/ARMOR_DIAMONDBLOCK_HP", ARMOR_DIAMOND2_HP); + getConfig().set("HEALTH/HEALTH_REGENERATION_RATE", HEALTH_REGENERATION_RATE); + getConfig().set("HEALTH/FOOD_HEAL_AMT", FOOD_HEAL_AMT); + getConfig().set("ENEMY/ENEMY_DMG_MULT", ENEMY_DMG_MULT); + getConfig().set("ENEMY/EXPLOSION_DMG_MULT", EXPLOSION_DMG_MULT); + getConfig().set("ENEMY/HEADSHOT_ACC", HEADSHOT_ACC); + getConfig().set("ITEM/RARE_DROP_RATE", RARE_DROP_RATE); + getConfig().set("PARTY_CHUNK_SIZE", PARTY_CHUNK_SIZE); + getConfig().set("XP_CONVERSION_RATE", XP_CONVERSION_RATE); + getConfig().set("WORLD_SHOP_ID", WORLD_SHOP_ID); + //getConfig().set("MOTD", MOTD); //It makes no sense to save the MOTD as it will never be modified in-game. + saveConfig(); + + TwosideRecyclingCenter.saveConfig(); + + //Save user configs here too. + saveAllUserConfigs(); + + getLogger().info("[TASK] Configurations have been saved successfully."); + } + + public void saveAllUserConfigs() { + for (int i=0;i itemCube_loadConfig(int id){ + List ItemCube_items = new ArrayList(); + File config; + config = new File(TwosideKeeper.filesave,"itemcubes/ItemCube"+id+".data"); + FileConfiguration workable = YamlConfiguration.loadConfiguration(config); + + for (int i=0;i<27;i++) { + ItemCube_items.add(workable.getItemStack("item"+i, new ItemStack(Material.AIR))); + } + return ItemCube_items; + } + public CubeType itemCube_getCubeType(int id){ + List ItemCube_items = new ArrayList(); + File config; + config = new File(TwosideKeeper.filesave,"itemcubes/ItemCube"+id+".data"); + FileConfiguration workable = YamlConfiguration.loadConfiguration(config); + + switch (workable.getInt("cubetype")) { + case 0:{return CubeType.NORMAL;} + case 1:{return CubeType.LARGE;} + case 2:{return CubeType.ENDER;} + default:{return CubeType.NORMAL;} + } + } + + //Item Cube Saving. + public void itemCube_saveConfig(int id, List items){ + List ItemCube_items = new ArrayList(); + File config; + config = new File(TwosideKeeper.filesave,"itemcubes/ItemCube"+id+".data"); + FileConfiguration workable = YamlConfiguration.loadConfiguration(config); + + for (int i=0;i items, CubeType cubetype){ + List ItemCube_items = new ArrayList(); + File config; + config = new File(TwosideKeeper.filesave,"itemcubes/ItemCube"+id+".data"); + FileConfiguration workable = YamlConfiguration.loadConfiguration(config); + + for (int i=0;i100) {pcthp=100;} + while (pcthp>=20) { + pcthp-=20; + bar+=Character.toString((char)0x2588); + length++; + } + if (pcthp>=16) { + bar+=Character.toString((char)0x2588); + length++; + } else + if (pcthp>=12) { + bar+=Character.toString((char)0x2593); + length++; + } else + if (pcthp>=8) { + bar+=Character.toString((char)0x2592); + length++; + } else + if (pcthp>=1) { + bar+=Character.toString((char)0x2591); + length++; + } else { + bar+=" "; + length++; + } + while (length<6) { + bar+=" "; + length++; + }*/ + + boolean hasDebuff=false; + boolean isHungry=(p.getFoodLevel()<=16)?true:false; + boolean inNether=(p.getWorld().getName().equalsIgnoreCase("world_nether"))?true:false; + boolean inEnd=(p.getWorld().getName().equalsIgnoreCase("world_the_end"))?true:false; + //getLogger().info(p.getWorld().getName().toString()); + int absorptionlv=0; + + for (int i=0;i66) {bar += ((isHungry)?ChatColor.DARK_GREEN:ChatColor.GREEN)+""+Math.round(p.getHealth())+""+Character.toString((char)0x2665);} + else if (pcthp>33) {bar += ((isHungry)?ChatColor.GOLD:ChatColor.YELLOW)+""+Math.round(p.getHealth())+""+Character.toString((char)0x2665);} + else {bar += ((isHungry)?ChatColor.DARK_RED:ChatColor.RED)+""+Math.round(p.getHealth())+""+Character.toString((char)0x2665);} + + /* + if (absorptionlv>0) { + bar+=" "+ChatColor.ITALIC+""+ChatColor.LIGHT_PURPLE+"+"+(absorptionlv*4)+Character.toString((char)0x2665); + }*/ + + if (hasDebuff||isHungry||inNether) { + bar+=" "; + } + + if (hasDebuff) { + bar+=ChatColor.GRAY+"!"; + } + /*if (isHungry) { + bar+=ChatColor.RED+""+ChatColor.BOLD+"!"; + }*/ + if (inNether) { + /* 058D:Counter-clockwise portal + * 058E:Clockwise portal + */ + bar+=ChatColor.DARK_PURPLE+""+Character.toString((char)0x25CA); + //bar+=ChatColor.DARK_PURPLE+""+"¤"; + } else + if (inEnd) { + /* 058D:Counter-clockwise portal + * 058E:Clockwise portal + */ + bar+=ChatColor.DARK_BLUE+""+Character.toString((char)0x25CA); + //bar+=ChatColor.DARK_PURPLE+""+"¤"; + } + + return bar; + } + + //Returns if a player has an arrow quiver in their inventory. + public boolean playerHasArrowQuiver(Player p) { + //getLogger().info("Checking an inventory of size "+p.getInventory().getSize()); + for (int i=0;i newlore = ArrowQuiver.getItemMeta().getLore(); + newlore.set(1, ChatColor.GRAY+"Arrows Remaining: "+ChatColor.YELLOW+ArrowQuiver_amt); + ArrowQuiver_meta.setLore(newlore); + ArrowQuiver.setItemMeta(ArrowQuiver_meta); + } + + public int playerGetArrowQuiverAmt(Player p, int slot) { + ItemStack ArrowQuiver = p.getInventory().getItem(slot); + ItemMeta ArrowQuiver_meta = ArrowQuiver.getItemMeta(); + int ArrowQuiver_amt = Integer.parseInt(ArrowQuiver.getItemMeta().getLore().get(1).split(": "+ChatColor.YELLOW)[1]); + return ArrowQuiver_amt; + } + + //Removes amt arrows in the arrow quiver in slot slot. If there's not enough arrows, sets the amount to 0. + //Returns how many arrows are left, or 0 if it's now empty. + public int playerRemoveArrowQuiver(Player p, int slot, int amt) { + ItemStack ArrowQuiver = p.getInventory().getItem(slot); + ItemMeta ArrowQuiver_meta = ArrowQuiver.getItemMeta(); + int ArrowQuiver_amt = Integer.parseInt(ArrowQuiver.getItemMeta().getLore().get(1).split(": "+ChatColor.YELLOW)[1]); + ArrowQuiver_amt -= amt; + if (ArrowQuiver_amt<0) {ArrowQuiver_amt=0;} + List newlore = ArrowQuiver.getItemMeta().getLore(); + newlore.set(1, ChatColor.GRAY+"Arrows Remaining: "+ChatColor.YELLOW+ArrowQuiver_amt); + ArrowQuiver_meta.setLore(newlore); + ArrowQuiver.setItemMeta(ArrowQuiver_meta); + return ArrowQuiver_amt; + } + + + + ///////////////ALL PLAYER RELATED FUNCTIONS GO DOWN HERE. + public static double getPlayerMoney(Player p) { + //Tells a player how much money they have. + for (int i=0;i20) { + while (health>20) { + color1++; + color2++; + health-=20; + } + } + for (int i=0;i20) { + for (int i=0;i<10;i++) { + heartdisplay+=Character.toString((char)0x2665); + } + } else { + for (int i=0;i0) { + //getLogger().info("Monster "+target.getEntityId()+" has Protection "+monsterEquipment[i].getEnchantmentLevel(Enchantment.PROTECTION_ENVIRONMENTAL)); + protectionlevel+=monsterEquipment[i].getEnchantmentLevel(Enchantment.PROTECTION_ENVIRONMENTAL); + //Protection is 1% damage reduction per level of protection. + } + + switch (monsterEquipment[i].getType()) { + case LEATHER_HELMET:{ + dmgreduction+=3.0*((isMonster)?2:1); //We multiply it all by 2 since we are giving them the "block" version of the armor. + }break; + case LEATHER_CHESTPLATE:{ + dmgreduction+=3.0*((isMonster)?2:1); + }break; + case LEATHER_LEGGINGS:{ + dmgreduction+=3.0*((isMonster)?2:1); + }break; + case LEATHER_BOOTS:{ + dmgreduction+=3.0*((isMonster)?2:1); + }break; + case IRON_HELMET:{ + dmgreduction+=5.0*((isMonster)?2:1); + }break; + case IRON_CHESTPLATE:{ + dmgreduction+=5.0*((isMonster)?2:1); + }break; + case IRON_LEGGINGS:{ + dmgreduction+=5.0*((isMonster)?2:1); + }break; + case IRON_BOOTS:{ + dmgreduction+=5.0*((isMonster)?2:1); + }break; + case GOLD_HELMET:{ + dmgreduction+=10.0*((isMonster)?2:1); + }break; + case GOLD_CHESTPLATE:{ + dmgreduction+=10.0*((isMonster)?2:1); + }break; + case GOLD_LEGGINGS:{ + dmgreduction+=10.0*((isMonster)?2:1); + }break; + case GOLD_BOOTS:{ + dmgreduction+=10.0*((isMonster)?2:1); + }break; + case DIAMOND_HELMET:{ + dmgreduction+=8.0*((isMonster)?2:1); + }break; + case DIAMOND_CHESTPLATE:{ + dmgreduction+=8.0*((isMonster)?2:1); + }break; + case DIAMOND_LEGGINGS:{ + dmgreduction+=8.0*((isMonster)?2:1); + }break; + case DIAMOND_BOOTS:{ + dmgreduction+=8.0*((isMonster)?2:1); + }break; + default: { + dmgreduction+=0.0*((isMonster)?2:1); + } + } + } + } + + //Now apply resistances if any. + //Resistance effect reduces damage by 10% per level of resistance. + int resistlevel = 0; + int strengthlevel = 0; + int weaknesslevel = 0; + int partylevel = 0; + + Collection target_effects = target.getActivePotionEffects(); + for (int i=0;i player_effects = p.getActivePotionEffects(); + for (int i=0;i0) { + partylevel = playerdata.get(j).partybonus; + getLogger().info("Party level is "+partylevel); + if (partylevel>9) {partylevel=9;} + } + } + + int sharpnesslevel=0; + //Apply player enchantments next. + //Each sharpness level increases damage by 0.5. + //Both Smite and Bane of Arthropods increases damage by 1.0 per level. + if (p.getEquipment().getItemInMainHand()!=null) { + if (p.getEquipment().getItemInMainHand().getEnchantmentLevel(Enchantment.DAMAGE_ALL)>0) { + sharpnesslevel+=p.getEquipment().getItemInMainHand().getEnchantmentLevel(Enchantment.DAMAGE_ALL); + //getLogger().info("Player "+p.getName()+" has Sharpness "+p.getEquipment().getItemInMainHand().getEnchantmentLevel(Enchantment.DAMAGE_ALL)+"."); + } else + if ((target.getType()==EntityType.ZOMBIE || target.getType()==EntityType.PIG_ZOMBIE || + target.getType()==EntityType.WITHER || target.getType()==EntityType.SKELETON) && + p.getEquipment().getItemInMainHand().getEnchantmentLevel(Enchantment.DAMAGE_UNDEAD)>0) { + sharpnesslevel+=p.getEquipment().getItemInMainHand().getEnchantmentLevel(Enchantment.DAMAGE_ALL)*2; + //getLogger().info("Player "+p.getName()+" has Smite "+p.getEquipment().getItemInMainHand().getEnchantmentLevel(Enchantment.DAMAGE_ALL)+"."); + } else + if ((target.getType()==EntityType.SPIDER || target.getType()==EntityType.CAVE_SPIDER || + target.getType()==EntityType.SILVERFISH || target.getType()==EntityType.ENDERMITE) && + p.getEquipment().getItemInMainHand().getEnchantmentLevel(Enchantment.DAMAGE_UNDEAD)>0) { + sharpnesslevel+=p.getEquipment().getItemInMainHand().getEnchantmentLevel(Enchantment.DAMAGE_ALL)*2; + //getLogger().info("Player "+p.getName()+" has Bane of Arthropods "+p.getEquipment().getItemInMainHand().getEnchantmentLevel(Enchantment.DAMAGE_ALL)+"."); + } + } + + boolean hasShield=false; + + //Check if our enemy has a shield. + //Shields reduce damage by another 5%. + if (target.getEquipment().getItemInOffHand().getType()==Material.SHIELD) { + hasShield=true; + } + + final double dmgamt = ( + basedmg + +sharpnesslevel*0.5 + -(basedmg*(dmgreduction/100.0d)) + ) + *((10-resistlevel)*0.1) + /((10-strengthlevel)*0.1) + *((10-weaknesslevel)*0.1) + /((10-partylevel)*0.1) + *((100-protectionlevel)*0.01) + *((hasShield)?0.95:1.00); //Calculated damage amount. + + getLogger().info("Final damage is "+dmgamt); + + final LivingEntity pp = p; + final LivingEntity m = target; + + if (m.getHealth()>dmgamt) { + m.setHealth(m.getHealth()-dmgamt); + } else { + m.setHealth(0.0); + } + /* + Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() { + public void run() { + if (m!=null) { + //getLogger().info(pp.getName()+" Dealt "+dmgamt+" modified dmg to "+m.getName()+"."); + //m.damage(dmgamt); //Finally, damage the enemy. + if (m.getHealth()>dmgamt) { + m.setHealth(m.getHealth()-dmgamt); + } else { + m.setHealth(0.0); + } + getLogger().info(m.getKiller().getName()); + } + }} + ,1);*/ + } + + public double CalculateDamageReduction(double basedmg,LivingEntity target,Entity damager) { + ItemStack[] armor = target.getEquipment().getArmorContents(); + double dmgreduction = 0.0; + + int protectionlevel = 0; + int resistlevel = 0; + int partylevel = 0; + + for (int i=0;i0) { + protectionlevel+=armor[i].getEnchantmentLevel(Enchantment.PROTECTION_ENVIRONMENTAL); + } + if ((damager instanceof Arrow) && armor[i].getEnchantmentLevel(Enchantment.PROTECTION_PROJECTILE)>0) { + protectionlevel+=armor[i].getEnchantmentLevel(Enchantment.PROTECTION_PROJECTILE); + } + if ((damager instanceof Creeper) && armor[i].getEnchantmentLevel(Enchantment.PROTECTION_EXPLOSIONS)>0) { + protectionlevel+=armor[i].getEnchantmentLevel(Enchantment.PROTECTION_EXPLOSIONS); + } + + boolean isBlockArmor = IsBlockArmor(armor[i]); + switch (armor[i].getType()) { + case LEATHER_BOOTS: + case LEATHER_LEGGINGS: + case LEATHER_CHESTPLATE: + case LEATHER_HELMET: { + dmgreduction+=3*((isBlockArmor)?2:1); + }break; + case IRON_BOOTS: + case IRON_LEGGINGS: + case IRON_CHESTPLATE: + case IRON_HELMET: { + dmgreduction+=5*((isBlockArmor)?2:1); + }break; + case GOLD_BOOTS: + case GOLD_LEGGINGS: + case GOLD_CHESTPLATE: + case GOLD_HELMET: { + dmgreduction+=10*((isBlockArmor)?2:1); + }break; + case DIAMOND_BOOTS: + case DIAMOND_LEGGINGS: + case DIAMOND_CHESTPLATE: + case DIAMOND_HELMET: { + dmgreduction+=8*((isBlockArmor)?2:1); + }break; + } + } + } + + //Check for resistance effect. + Collection target_effects = target.getActivePotionEffects(); + for (int i=0;i0) { + partylevel = playerdata.get(j).partybonus; + if (partylevel>9) {partylevel=9;} + } + } + } + + //Blocking: -((p.isBlocking())?ev.getDamage()*0.33:0) //33% damage will be reduced if we are blocking. + //Shield: -((p.getEquipment().getItemInOffHand()!=null && p.getEquipment().getItemInOffHand().getType()==Material.SHIELD)?ev.getDamage()*0.05:0) //5% damage will be reduced if we are holding a shield. + + + double finaldmg=(basedmg-(basedmg*(dmgreduction/100.0d))) + *((10-resistlevel)*0.1) + *((100-protectionlevel)*0.01) + *((10-partylevel)*0.1) + *((target instanceof Player && ((Player)target).isBlocking())?(isDefender((Player)target))?0.30:0.50:1) + *((isDefender(target))?0.9:(target.getEquipment().getItemInOffHand()!=null && target.getEquipment().getItemInOffHand().getType()==Material.SHIELD)?0.95:1); + + //getLogger().info("Dealt "+finaldmg+" modified damage."); + return finaldmg; + } + + public boolean IsBlockArmor(ItemStack armor) { + //Checks if this block is a block armor version. If so, it will + //have double the normal damage reduction. + //It will say ChatColor.BLUE+""+ChatColor.ITALIC+"Hardened Armor" on a lore line. + if (armor!=null) { + if (armor.hasItemMeta() && + armor.getItemMeta().hasLore()) { + //Loop through the lore to see if this line exists. + for (int i=0;i lore = new ArrayList(); + if (meta.hasLore()) { + lore.addAll(meta.getLore()); + } + if (isArmor(item)) { + lore.add(ChatColor.BLUE+""+ChatColor.ITALIC+"Hardened Armor"); + lore.add(ChatColor.GRAY+"Twice as strong"); + } else + if (isTool(item)) { + lore.add(ChatColor.BLUE+""+ChatColor.ITALIC+"Hardened Weapon"); + lore.add(ChatColor.GRAY+"Twice as strong"); + } + lore.add(ChatColor.GRAY+"Breaks Remaining: "+ChatColor.YELLOW+breaks); + meta.setLore(lore); + item.setItemMeta(meta); + } + return item; + } + + /** + * This function will return the number of items of this type + * that exist in your inventory. It will not include your + * equipment. + * @param p + * @param item + * @return + */ + public static int CountItems(Player p, ItemStack item) { + int totalcount=0; + for (int i=0;i='a') { + first = (char)(temp[i].charAt(0)-32); + } else { + first = temp[i].charAt(0); + } + finalname+=(finalname.equals("")?"":" ")+first+temp[i].toLowerCase().substring(1); + } + return finalname; + } else { + if (s.charAt(0)>='a') { + char first = (char)(s.charAt(0)-32); + return first+s.toLowerCase().substring(1); + } else { + char first = (char)(s.charAt(0)); + return first+s.toLowerCase().substring(1); + } + } + } + + public static int getHardenedItemBreaks(ItemStack item) { + if (item.hasItemMeta() && + item.getItemMeta().hasLore()) { + ItemMeta item_meta = item.getItemMeta(); + int breaks_remaining=-1; + int loreline=-1; + for (int i=0;i0) { + ItemMeta m = item.getItemMeta(); + List lore = item.getItemMeta().getLore(); + for (int i=0;i sessions = new ArrayList(); + List purchases = new ArrayList(); + + //Save itemstack in file. + //Reference an ID. + + /** + * Creates a World shop. + * @param s The sign the shop is created on. + * @param item The item being sold. + * @param price The unit price of the item. + * @param owner Owner of the shop. + */ + public WorldShop CreateWorldShop(Sign s, ItemStack item, int amt, double price, String owner) { + //Convert the sign. + String[] lines = s.getLines(); + List sign_lines = new ArrayList(); + WorldShop newshop = new WorldShop(item, amt, price, owner, TwosideKeeper.WORLD_SHOP_ID); + if (lines[0].equalsIgnoreCase("shop")) { + UpdateSign(newshop, TwosideKeeper.WORLD_SHOP_ID, s); + } + TwosideKeeper.WORLD_SHOP_ID++; + return newshop; + } + + public void UpdateSign(WorldShop shop, int id, Sign s) { + //Convert the sign. + String[] lines = s.getLines(); + List sign_lines = new ArrayList(); + //Create a shop out of this. + sign_lines.add(ChatColor.BLUE+"-- SHOP --"); + if (shop.GetItem().hasItemMeta() && + shop.GetItem().getItemMeta().hasDisplayName()) { + sign_lines.add(shop.GetItem().getItemMeta().getDisplayName()); + } else { + sign_lines.add(TwosideKeeper.UserFriendlyMaterialName(shop.GetItem())); + } + DecimalFormat df = new DecimalFormat("0.00"); + sign_lines.add("$"+df.format(shop.GetUnitPrice())+ChatColor.DARK_BLUE+" [x"+shop.GetAmount()+"]"); + DecimalFormat df2 = new DecimalFormat("000000"); + sign_lines.add(ChatColor.DARK_GRAY+df2.format(id)); + for (int i=0;i<4;i++) { + s.setLine(i, sign_lines.get(i)); + } + s.update(); + } + + public int GetShopID(Sign s) { + return Integer.parseInt(s.getLines()[3].replace(ChatColor.DARK_GRAY+"", "")); + } + + public WorldShop LoadWorldShopData(int id) { + File config; + config = new File(TwosideKeeper.filesave,"worldshop.data"); + FileConfiguration workable = YamlConfiguration.loadConfiguration(config); + + return new WorldShop(workable.getItemStack("item"+id),workable.getInt("amt"+id),workable.getDouble("item_price"+id),workable.getString("owner"+id),id); + } + + public void SaveWorldShopData(WorldShop shop) { + File config; + config = new File(TwosideKeeper.filesave,"worldshop.data"); + FileConfiguration workable = YamlConfiguration.loadConfiguration(config); + + int id = shop.getID(); + + workable.set("item"+id,shop.GetItem()); + workable.set("item_price"+id,shop.GetUnitPrice()); + workable.set("amt"+id,shop.GetAmount()); + workable.set("owner"+id,shop.GetOwner()); + + try { + workable.save(config); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + public List GetSessions() { + return sessions; + } + public WorldShopSession GetSession(int session) { + return sessions.get(session); + } + public WorldShopSession GetSession(Player p) { + return sessions.get(GetPlayerTerminal(p)); + } + public boolean IsPlayerUsingTerminal(Player p) { + for (int i=0;i