SHOW:
|
|
- or go back to the newest paste.
| 1 | package com.core.mayodwarf.pokeballers.shop; | |
| 2 | ||
| 3 | import net.milkbowl.vault.economy.Economy; | |
| 4 | ||
| 5 | - | import org.bukkit.Material; |
| 5 | + | |
| 6 | import org.bukkit.block.Sign; | |
| 7 | import org.bukkit.command.Command; | |
| 8 | import org.bukkit.command.CommandSender; | |
| 9 | import org.bukkit.configuration.file.FileConfiguration; | |
| 10 | import org.bukkit.event.EventHandler; | |
| 11 | import org.bukkit.event.Listener; | |
| 12 | import org.bukkit.event.inventory.InventoryAction; | |
| 13 | import org.bukkit.event.inventory.InventoryClickEvent; | |
| 14 | import org.bukkit.event.player.PlayerInteractEvent; | |
| 15 | import org.bukkit.inventory.ItemStack; | |
| 16 | import org.bukkit.inventory.meta.ItemMeta; | |
| 17 | import org.bukkit.plugin.RegisteredServiceProvider; | |
| 18 | import org.bukkit.plugin.java.JavaPlugin; | |
| 19 | import org.bukkit.entity.Player; | |
| 20 | ||
| 21 | - | import javax.sound.midi.SysexMessage; |
| 21 | + | |
| 22 | - | import java.util.ArrayList; |
| 22 | + | |
| 23 | /** | |
| 24 | * Created with IntelliJ IDEA. | |
| 25 | * User: MayoDwarf | |
| 26 | * Date: 1/31/14 | |
| 27 | * Time: 5:27 PM | |
| 28 | * To change this template use File | Settings | File Templates. | |
| 29 | */ | |
| 30 | ||
| 31 | @SuppressWarnings("unchecked")
| |
| 32 | public class Main extends JavaPlugin implements Listener {
| |
| 33 | - | public FileConfiguration config; |
| 33 | + | public FileConfiguration config; |
| 34 | - | public static Economy economy= null; |
| 34 | + | public static Economy economy= null; |
| 35 | - | private Shop shop; |
| 35 | + | private Shop shop; |
| 36 | - | public void onEnable() {
|
| 36 | + | public void onEnable() {
|
| 37 | - | this.saveDefaultConfig(); |
| 37 | + | this.saveDefaultConfig(); |
| 38 | - | shop = new Shop(this); |
| 38 | + | shop = new Shop(this); |
| 39 | - | getServer().getPluginManager().registerEvents(this, this); |
| 39 | + | getServer().getPluginManager().registerEvents(this, this); |
| 40 | - | setupEconomy(); |
| 40 | + | setupEconomy(); |
| 41 | - | } |
| 41 | + | } |
| 42 | - | public void onDisable() {}
|
| 42 | + | public void onDisable() {}
|
| 43 | - | /* [1/31/14, 7:43:44 PM] [Developer] Jared: You type /shop and it opens up a gui with different shops you guys can make with commands. To add the items you do |
| 43 | + | /* [1/31/14, 7:43:44 PM] [Developer] Jared: You type /shop and it opens up a gui with different shops you guys can make with commands. To add the items you do |
| 44 | - | * "/shop <name> add <price> <buy or sell>" and that will add the item in your hand with right amount and enchantments and stuff and |
| 44 | + | * "/shop <name> add <price> <buy or sell>" and that will add the item in your hand with right amount and enchantments and stuff and |
| 45 | - | * if it is buy or sell with the price you specify. |
| 45 | + | * if it is buy or sell with the price you specify. |
| 46 | - | * |
| 46 | + | * |
| 47 | - | * [1/31/14, 7:44:56 PM] [Developer] Jared: Add a new shop "/shop new <name>". |
| 47 | + | * [1/31/14, 7:44:56 PM] [Developer] Jared: Add a new shop "/shop new <name>". |
| 48 | - | * They wouldn't be able to use a shop without the permission "Shop.use.<name of shop>" |
| 48 | + | * They wouldn't be able to use a shop without the permission "Shop.use.<name of shop>" |
| 49 | - | */ |
| 49 | + | */ |
| 50 | - | public boolean setupEconomy() |
| 50 | + | public boolean setupEconomy() |
| 51 | - | {
|
| 51 | + | {
|
| 52 | - | RegisteredServiceProvider<Economy> economyProvider = getServer().getServicesManager().getRegistration(net.milkbowl.vault.economy.Economy.class); |
| 52 | + | RegisteredServiceProvider<Economy> economyProvider = getServer().getServicesManager().getRegistration(net.milkbowl.vault.economy.Economy.class); |
| 53 | - | if (economyProvider != null) {
|
| 53 | + | if (economyProvider != null) {
|
| 54 | - | economy = economyProvider.getProvider(); |
| 54 | + | economy = economyProvider.getProvider(); |
| 55 | - | } |
| 55 | + | } |
| 56 | ||
| 57 | - | return (economy != null); |
| 57 | + | return (economy != null); |
| 58 | - | } |
| 58 | + | } |
| 59 | - | public boolean onCommand (CommandSender sender, Command cmd, String commandLabel, String[] args) {
|
| 59 | + | public boolean onCommand (CommandSender sender, Command cmd, String commandLabel, String[] args) {
|
| 60 | - | Player p = (Player) sender; |
| 60 | + | Player p = (Player) sender; |
| 61 | - | if(cmd.getName().equalsIgnoreCase("setLore")) {
|
| 61 | + | if(cmd.getName().equalsIgnoreCase("setLore")) {
|
| 62 | - | if(p.hasPermission("Shops.setlore")) {
|
| 62 | + | if(p.hasPermission("Shops.setlore")) {
|
| 63 | - | StringBuilder sb = new StringBuilder("");
|
| 63 | + | StringBuilder sb = new StringBuilder("");
|
| 64 | - | for(String strings : args) {
|
| 64 | + | for(String strings : args) {
|
| 65 | - | sb.append(args).append(" ");
|
| 65 | + | sb.append(strings).append(" ");
|
| 66 | - | } |
| 66 | + | } |
| 67 | - | String words = sb.toString(); |
| 67 | + | String words = sb.toString(); |
| 68 | - | shop.setLore(p.getItemInHand(), words, p); |
| 68 | + | shop.setLore(p.getItemInHand(), words, p); |
| 69 | - | } |
| 69 | + | } |
| 70 | - | } |
| 70 | + | } |
| 71 | - | if (cmd.getName().equalsIgnoreCase("shop")) {
|
| 71 | + | if (cmd.getName().equalsIgnoreCase("shop")) {
|
| 72 | - | if (args.length == 0) {
|
| 72 | + | if (args.length == 0) {
|
| 73 | - | if (p.hasPermission("Shops.Admin")) {
|
| 73 | + | if (p.hasPermission("Shops.Admin")) {
|
| 74 | - | shop.openShopMenu(p); |
| 74 | + | shop.openShopMenu(p); |
| 75 | - | } |
| 75 | + | } |
| 76 | - | } |
| 76 | + | } |
| 77 | - | if (args.length == 1) {
|
| 77 | + | if (args.length == 1) {
|
| 78 | - | //If the args is a shop name |
| 78 | + | //If the args is a shop name |
| 79 | - | List<String> list = (List<String>) getConfig().getList("Shops");
|
| 79 | + | List<String> list = (List<String>) getConfig().getList("Shops");
|
| 80 | - | for (String strings : list) {
|
| 80 | + | for (String strings : list) {
|
| 81 | - | if (args[0].equals(strings)) {
|
| 81 | + | if (args[0].equals(strings)) {
|
| 82 | - | //Open up the args[0] shop |
| 82 | + | //Open up the args[0] shop |
| 83 | - | if (p.hasPermission("Shops.use."+strings)) {
|
| 83 | + | if (p.hasPermission("Shops.use."+strings)) {
|
| 84 | - | shop.openShop(args[0], (Player)sender); |
| 84 | + | shop.openShop(args[0], (Player)sender); |
| 85 | - | } |
| 85 | + | } |
| 86 | - | } |
| 86 | + | } |
| 87 | - | } |
| 87 | + | } |
| 88 | - | if (args[0].equalsIgnoreCase("reload")) {
|
| 88 | + | if (args[0].equalsIgnoreCase("reload")) {
|
| 89 | - | if (p.hasPermission("Shops.Admin")) {
|
| 89 | + | if (p.hasPermission("Shops.Admin")) {
|
| 90 | - | shop.reloadCfg(); |
| 90 | + | shop.reloadCfg(); |
| 91 | - | p.sendMessage(ChatColor.RED+"The config has been reloaded for "+ChatColor.GOLD+"PokeballersShop"+ChatColor.RED+"!"); |
| 91 | + | p.sendMessage(ChatColor.RED+"The config has been reloaded for "+ChatColor.GOLD+"PokeballersShop"+ChatColor.RED+"!"); |
| 92 | - | } |
| 92 | + | } |
| 93 | - | } |
| 93 | + | } |
| 94 | - | if (args[0].equalsIgnoreCase("output")) {
|
| 94 | + | if (args[0].equalsIgnoreCase("output")) {
|
| 95 | - | shop.outPut(p.getItemInHand()); |
| 95 | + | shop.outPut(p.getItemInHand()); |
| 96 | - | p.sendMessage(ChatColor.RED+"The output for "+ChatColor.GOLD+""+p.getItemInHand().getType().toString()+ChatColor.RED+" has been added!"); |
| 96 | + | p.sendMessage(ChatColor.RED+"The output for "+ChatColor.GOLD+""+p.getItemInHand().getType().toString()+ChatColor.RED+" has been added!"); |
| 97 | - | } |
| 97 | + | } |
| 98 | - | } |
| 98 | + | } |
| 99 | - | if (args.length == 3) {
|
| 99 | + | if (args.length == 3) {
|
| 100 | - | if (args[0].equalsIgnoreCase("new")) {
|
| 100 | + | if (args[0].equalsIgnoreCase("new")) {
|
| 101 | - | shop.newShop(args[1], p, args[2], p.getItemInHand()); |
| 101 | + | shop.newShop(args[1], p, args[2], p.getItemInHand()); |
| 102 | - | } |
| 102 | + | } |
| 103 | - | } |
| 103 | + | } |
| 104 | - | if (args.length == 3 || args.length == 4) {
|
| 104 | + | if (args.length == 3 || args.length == 4) {
|
| 105 | - | if (args[0].equalsIgnoreCase("add")) {
|
| 105 | + | if (args[0].equalsIgnoreCase("add")) {
|
| 106 | - | if (p.hasPermission("Shops.Admin")) {
|
| 106 | + | if (p.hasPermission("Shops.Admin")) {
|
| 107 | - | p.sendMessage(ChatColor.RED+"Invalid arguments! Correct: ./shop add <shop> <buy/sell> <price> <spot>"); |
| 107 | + | p.sendMessage(ChatColor.RED+"Invalid arguments! Correct: ./shop add <shop> <buy/sell> <price> <spot>"); |
| 108 | - | } |
| 108 | + | } |
| 109 | - | } |
| 109 | + | } |
| 110 | - | } |
| 110 | + | } |
| 111 | - | if (args.length == 5) {
|
| 111 | + | if (args.length == 5) {
|
| 112 | - | if (p.hasPermission("Shops.Admin")) {
|
| 112 | + | if (p.hasPermission("Shops.Admin")) {
|
| 113 | - | if (args[0].equalsIgnoreCase("add")) {
|
| 113 | + | if (args[0].equalsIgnoreCase("add")) {
|
| 114 | - | if (args[2].equalsIgnoreCase("buy") || args[2].equalsIgnoreCase("sell")) {
|
| 114 | + | if (args[2].equalsIgnoreCase("buy") || args[2].equalsIgnoreCase("sell")) {
|
| 115 | - | if (getConfig().getList("Shops").contains(args[1])) {
|
| 115 | + | if (getConfig().getList("Shops").contains(args[1])) {
|
| 116 | - | shop.add(p.getItemInHand(), p, args[3], args[1], args[2], args[4]); |
| 116 | + | shop.add(p.getItemInHand(), p, args[3], args[1], args[2], args[4]); |
| 117 | - | //shop add <shop> <buy/sell> <price> <spot> |
| 117 | + | //shop add <shop> <buy/sell> <price> <spot> |
| 118 | - | // 0 1 2 3 4 |
| 118 | + | // 0 1 2 3 4 |
| 119 | - | } |
| 119 | + | } |
| 120 | - | } |
| 120 | + | } |
| 121 | - | } |
| 121 | + | } |
| 122 | - | } |
| 122 | + | } |
| 123 | - | } |
| 123 | + | } |
| 124 | - | } |
| 124 | + | } |
| 125 | - | return true; |
| 125 | + | return true; |
| 126 | - | } |
| 126 | + | } |
| 127 | - | @EventHandler |
| 127 | + | @EventHandler |
| 128 | - | public void onInteract(PlayerInteractEvent evt) {
|
| 128 | + | public void onInteract(PlayerInteractEvent evt) {
|
| 129 | - | if (evt.getClickedBlock().getState() instanceof Sign) {
|
| 129 | + | if (evt.getClickedBlock().getState() instanceof Sign) {
|
| 130 | - | Sign sign = (Sign) evt.getClickedBlock().getState(); |
| 130 | + | Sign sign = (Sign) evt.getClickedBlock().getState(); |
| 131 | - | if (ChatColor.stripColor(sign.getLine(0)).equals("PokeShop")) {
|
| 131 | + | if (ChatColor.stripColor(sign.getLine(0)).equals("PokeShop")) {
|
| 132 | - | List<String> list = (List<String>) getConfig().get("Shops");
|
| 132 | + | List<String> list = (List<String>) getConfig().get("Shops");
|
| 133 | - | for (String strings : list) {
|
| 133 | + | for (String strings : list) {
|
| 134 | - | if (ChatColor.stripColor(sign.getLine(1)).equalsIgnoreCase(strings)) {
|
| 134 | + | if (ChatColor.stripColor(sign.getLine(1)).equalsIgnoreCase(strings)) {
|
| 135 | - | if (evt.getPlayer().hasPermission("Shops.use."+ChatColor.stripColor(sign.getLine(1)))) {
|
| 135 | + | if (evt.getPlayer().hasPermission("Shops.use."+ChatColor.stripColor(sign.getLine(1)))) {
|
| 136 | - | evt.getPlayer().performCommand("shop "+ChatColor.stripColor(sign.getLine(1)));
|
| 136 | + | evt.getPlayer().performCommand("shop "+ChatColor.stripColor(sign.getLine(1)));
|
| 137 | - | } |
| 137 | + | } |
| 138 | - | } |
| 138 | + | } |
| 139 | - | } |
| 139 | + | } |
| 140 | - | } |
| 140 | + | } |
| 141 | - | } |
| 141 | + | } |
| 142 | - | } |
| 142 | + | } |
| 143 | ||
| 144 | ||
| 145 | ||
| 146 | ||
| 147 | - | @EventHandler |
| 147 | + | @EventHandler |
| 148 | - | public void onClick(InventoryClickEvent evt) {
|
| 148 | + | public void onClick(InventoryClickEvent evt) {
|
| 149 | - | Player p = (Player) evt.getWhoClicked(); |
| 149 | + | Player p = (Player) evt.getWhoClicked(); |
| 150 | - | if (evt.getInventory().getTitle().toString().equalsIgnoreCase(ChatColor.AQUA+"Shops")) {
|
| 150 | + | if (evt.getInventory().getTitle().toString().equalsIgnoreCase(ChatColor.AQUA+"Shops")) {
|
| 151 | - | //Shop gui |
| 151 | + | //Shop gui |
| 152 | - | evt.setCancelled(true); |
| 152 | + | evt.setCancelled(true); |
| 153 | - | p.closeInventory(); |
| 153 | + | p.closeInventory(); |
| 154 | - | evt.setCancelled(true); |
| 154 | + | evt.setCancelled(true); |
| 155 | - | shop.openShop(evt.getCurrentItem().getItemMeta().getDisplayName().toString(), p); |
| 155 | + | shop.openShop(evt.getCurrentItem().getItemMeta().getDisplayName().toString(), p); |
| 156 | - | } |
| 156 | + | } |
| 157 | - | List<String> shops = (List<String>) getConfig().get("Shops");
|
| 157 | + | List<String> shops = (List<String>) getConfig().get("Shops");
|
| 158 | - | for(String strings : shops) {
|
| 158 | + | for(String strings : shops) {
|
| 159 | - | if (ChatColor.stripColor(evt.getInventory().getTitle().toString()).equalsIgnoreCase(strings)) {
|
| 159 | + | if (ChatColor.stripColor(evt.getInventory().getTitle().toString()).equalsIgnoreCase(strings)) {
|
| 160 | - | ItemStack item = evt.getCurrentItem(); |
| 160 | + | ItemStack item = evt.getCurrentItem(); |
| 161 | - | ItemMeta im = item.getItemMeta(); evt.setCancelled(true); |
| 161 | + | ItemMeta im = item.getItemMeta(); evt.setCancelled(true); |
| 162 | - | if(im !=null) {
|
| 162 | + | if(im !=null) {
|
| 163 | - | String priceC = ChatColor.stripColor(im.getDisplayName()); |
| 163 | + | String priceC = ChatColor.stripColor(im.getDisplayName()); |
| 164 | - | String priceD = priceC.replace("$", "");
|
| 164 | + | String priceD = priceC.replace("$", "");
|
| 165 | - | Integer price = Integer.parseInt(priceD); |
| 165 | + | Integer price = Integer.parseInt(priceD); |
| 166 | - | if(im.getLore().get(0) !=null) {
|
| 166 | + | if(im.getLore().get(0) !=null) {
|
| 167 | - | String typeC = ChatColor.stripColor(im.getLore().get(0).toString()); |
| 167 | + | String typeC = ChatColor.stripColor(im.getLore().get(0).toString()); |
| 168 | - | evt.setCancelled(true); |
| 168 | + | evt.setCancelled(true); |
| 169 | - | if (typeC.equalsIgnoreCase("buy")) {
|
| 169 | + | if (typeC.equalsIgnoreCase("buy")) {
|
| 170 | - | if(economy.getBalance(p.getName()) >= price) {
|
| 170 | + | ItemStack returnItem = null; |
| 171 | - | if(evt.getAction() == InventoryAction.PICKUP_ALL) {
|
| 171 | + | for(ItemStack items: (List<ItemStack>) this.getConfig().getList("Outputs")){
|
| 172 | - | //Give them 1 of item |
| 172 | + | if(items.getType()==item.getType() && items.getDurability()==item.getDurability()){
|
| 173 | - | for(ItemStack items : (List<ItemStack>) getConfig().getList("Outputs")) {
|
| 173 | + | returnItem = items.clone(); |
| 174 | - | if(!(items.getType() == item.getType()) && !(items.getDurability() == item.getDurability())) {
|
| 174 | + | break; |
| 175 | - | p.getInventory().addItem(new ItemStack(item.getType(), 1, item.getDurability())); |
| 175 | + | } |
| 176 | - | economy.withdrawPlayer(p.getName(), price); |
| 176 | + | } |
| 177 | - | evt.setCancelled(true); |
| 177 | + | if(returnItem==null){ //No item found
|
| 178 | - | break; |
| 178 | + | return; |
| 179 | - | } else if(items.getType() == item.getType() && items.getDurability() == item.getDurability()) {
|
| 179 | + | } |
| 180 | - | //Output adding 1 |
| 180 | + | int amount; |
| 181 | - | List<ItemStack> outputs = (List<ItemStack>) getConfig().get("Outputs");
|
| 181 | + | switch(evt.getAction()){
|
| 182 | - | for(ItemStack itemss : outputs) {
|
| 182 | + | case PICKUP_ALL: amount = 1; |
| 183 | - | if(itemss.getType() == item.getType() && itemss.getDurability() == item.getDurability()) {
|
| 183 | + | case PICKUP_HALF: amount = 16; |
| 184 | - | //Do stuff |
| 184 | + | default: |
| 185 | - | p.getInventory().addItem(itemss); |
| 185 | + | amount = 1; |
| 186 | - | evt.setCancelled(true); |
| 186 | + | } |
| 187 | - | economy.withdrawPlayer(p.getName(), price); |
| 187 | + | if(!economy.has(p.getName(), price*amount)){
|
| 188 | - | } |
| 188 | + | p.sendMessage("You are a broke man nigga");
|
| 189 | - | } |
| 189 | + | return; |
| 190 | - | } |
| 190 | + | } |
| 191 | - | } |
| 191 | + | returnItem.setAmount(amount); |
| 192 | - | } else if(evt.getAction() == InventoryAction.PICKUP_HALF) {
|
| 192 | + | p.getInventory().addItem(returnItem); |
| 193 | - | //Give them 16 of item |
| 193 | + | |
| 194 | - | for(ItemStack items : (List<ItemStack>) getConfig().getList("Outputs")) {
|
| 194 | + | /*if(economy.getBalance(p.getName()) >= price) {
|
| 195 | - | if(!(items.getType() == item.getType()) && !(items.getDurability() == item.getDurability())) {
|
| 195 | + | if(evt.getAction() == InventoryAction.PICKUP_ALL) {
|
| 196 | - | for(int j=0;j<16;j++) {
|
| 196 | + | //Give them 1 of item |
| 197 | - | p.getInventory().addItem(item); |
| 197 | + | for(ItemStack items : (List<ItemStack>) getConfig().getList("Outputs")) {
|
| 198 | - | } |
| 198 | + | if(!(items.getType() == item.getType()) && !(items.getDurability() == item.getDurability())) {
|
| 199 | - | economy.withdrawPlayer(p.getName(), price*16); |
| 199 | + | p.getInventory().addItem(new ItemStack(item.getType(), 1, item.getDurability())); |
| 200 | - | evt.setCancelled(true); |
| 200 | + | economy.withdrawPlayer(p.getName(), price); |
| 201 | - | break; |
| 201 | + | evt.setCancelled(true); |
| 202 | - | } else if(item.getType() == items.getType() && item.getDurability() == items.getDurability()) {
|
| 202 | + | break; |
| 203 | - | //Output adding 16 |
| 203 | + | } else if(items.getType() == item.getType() && items.getDurability() == item.getDurability()) {
|
| 204 | - | List<ItemStack> outputs = (List<ItemStack>) getConfig().get("Outputs");
|
| 204 | + | //Output adding 1 |
| 205 | - | for(ItemStack itemss : outputs) {
|
| 205 | + | List<ItemStack> outputs = (List<ItemStack>) getConfig().get("Outputs");
|
| 206 | - | if(itemss.getType() == item.getType() && itemss.getDurability() == item.getDurability()) {
|
| 206 | + | for(ItemStack itemss : outputs) {
|
| 207 | - | //Do stuff |
| 207 | + | if(itemss.getType() == item.getType() && itemss.getDurability() == item.getDurability()) {
|
| 208 | - | for(int i=0;i<16;i++) {
|
| 208 | + | //Do stuff |
| 209 | - | p.getInventory().addItem(itemss); |
| 209 | + | p.getInventory().addItem(itemss); |
| 210 | - | } |
| 210 | + | evt.setCancelled(true); |
| 211 | - | evt.setCancelled(true); |
| 211 | + | economy.withdrawPlayer(p.getName(), price); |
| 212 | - | economy.withdrawPlayer(p.getName(), price*16); |
| 212 | + | } |
| 213 | - | } |
| 213 | + | } |
| 214 | - | } |
| 214 | + | } |
| 215 | - | } |
| 215 | + | } |
| 216 | - | } |
| 216 | + | } else if(evt.getAction() == InventoryAction.PICKUP_HALF) {
|
| 217 | - | } |
| 217 | + | //Give them 16 of item |
| 218 | - | } else {
|
| 218 | + | for(ItemStack items : (List<ItemStack>) getConfig().getList("Outputs")) {
|
| 219 | - | p.sendMessage(ChatColor.RED+"You do not have enough cash for this item!"); p.closeInventory(); evt.setCancelled(true); |
| 219 | + | if(!(items.getType() == item.getType()) && !(items.getDurability() == item.getDurability())) {
|
| 220 | - | } |
| 220 | + | for(int j=0;j<16;j++) {
|
| 221 | - | } else |
| 221 | + | p.getInventory().addItem(item); |
| 222 | - | if (typeC.equalsIgnoreCase("sell")) {
|
| 222 | + | } |
| 223 | - | if (p.getInventory().contains(new ItemStack(item.getType(), item.getDurability()))) {
|
| 223 | + | economy.withdrawPlayer(p.getName(), price*16); |
| 224 | - | if(evt.getAction() == InventoryAction.PICKUP_ALL) {
|
| 224 | + | evt.setCancelled(true); |
| 225 | - | //Take 1 |
| 225 | + | break; |
| 226 | - | p.getInventory().removeItem(item); |
| 226 | + | } else if(item.getType() == items.getType() && item.getDurability() == items.getDurability()) {
|
| 227 | - | evt.setCancelled(true); |
| 227 | + | //Output adding 16 |
| 228 | - | economy.depositPlayer(p.getName(), price); |
| 228 | + | List<ItemStack> outputs = (List<ItemStack>) getConfig().get("Outputs");
|
| 229 | - | } else if(evt.getAction() == InventoryAction.PICKUP_HALF) {
|
| 229 | + | for(ItemStack itemss : outputs) {
|
| 230 | - | //Take 16 of them |
| 230 | + | if(itemss.getType() == item.getType() && itemss.getDurability() == item.getDurability()) {
|
| 231 | - | for(int d=0;d<16;d++) {
|
| 231 | + | //Do stuff |
| 232 | - | p.getInventory().removeItem(item); |
| 232 | + | for(int i=0;i<16;i++) {
|
| 233 | - | } |
| 233 | + | p.getInventory().addItem(itemss); |
| 234 | - | evt.setCancelled(true); |
| 234 | + | } |
| 235 | - | economy.depositPlayer(p.getName(), price*16); |
| 235 | + | evt.setCancelled(true); |
| 236 | - | } |
| 236 | + | economy.withdrawPlayer(p.getName(), price*16); |
| 237 | - | } else {
|
| 237 | + | } |
| 238 | - | p.sendMessage(ChatColor.RED+"You do not have enough of this item to sell!"); p.closeInventory(); |
| 238 | + | } |
| 239 | - | } |
| 239 | + | } |
| 240 | - | } |
| 240 | + | } |
| 241 | - | } |
| 241 | + | } |
| 242 | - | } |
| 242 | + | } else {
|
| 243 | - | } |
| 243 | + | p.sendMessage(ChatColor.RED+"You do not have enough cash for this item!"); p.closeInventory(); evt.setCancelled(true); |
| 244 | - | } |
| 244 | + | }*/ |
| 245 | - | } |
| 245 | + | } else |
| 246 | if (typeC.equalsIgnoreCase("sell")) {
| |
| 247 | if (p.getInventory().contains(new ItemStack(item.getType(), item.getDurability()))) {
| |
| 248 | if(evt.getAction() == InventoryAction.PICKUP_ALL) {
| |
| 249 | //Take 1 | |
| 250 | p.getInventory().removeItem(item); | |
| 251 | evt.setCancelled(true); | |
| 252 | economy.depositPlayer(p.getName(), price); | |
| 253 | } else if(evt.getAction() == InventoryAction.PICKUP_HALF) {
| |
| 254 | //Take 16 of them | |
| 255 | for(int d=0;d<16;d++) {
| |
| 256 | p.getInventory().removeItem(item); | |
| 257 | } | |
| 258 | evt.setCancelled(true); | |
| 259 | economy.depositPlayer(p.getName(), price*16); | |
| 260 | } | |
| 261 | } else {
| |
| 262 | p.sendMessage(ChatColor.RED+"You do not have enough of this item to sell!"); p.closeInventory(); | |
| 263 | } | |
| 264 | } | |
| 265 | } | |
| 266 | } | |
| 267 | } | |
| 268 | } | |
| 269 | } | |
| 270 | } |