Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ratedpvp.commands;
- import java.util.HashSet;
- import org.bukkit.ChatColor;
- import org.bukkit.Color;
- import org.bukkit.Material;
- import org.bukkit.command.Command;
- import org.bukkit.command.CommandExecutor;
- import org.bukkit.command.CommandSender;
- import org.bukkit.entity.Player;
- import org.bukkit.event.inventory.InventoryClickEvent;
- import org.bukkit.inventory.ItemStack;
- import net.milkbowl.vault.economy.Economy;
- import ratedpvp.RatedPvP;
- import ratedpvp.utilities.Item;
- import ratedpvp.utilities.ItemBuilder;
- import ratedpvp.utilities.Menu;
- import ratedpvp.utilities.Vault;
- public class ShopCmd implements CommandExecutor {
- private RatedPvP plugin;
- private HashSet<String> cdl = new HashSet<String>();
- private String sn = ChatColor.DARK_GRAY + "[" + ChatColor.RED + "Shop" + ChatColor.DARK_GRAY + "]: ";
- private Economy eco;
- public Menu shopMain;
- public Menu blocks;
- public Menu cb1;
- public Menu cb2;
- public Menu resources;
- public Menu mobdrops;
- public Menu potionmats;
- public Menu farming;
- public Menu food;
- public Menu redstone;
- public Menu pots;
- public Menu spawners;
- public ShopCmd(RatedPvP plugin) {
- this.plugin = plugin;
- eco = Vault.economy;
- shopMain = new Menu(ChatColor.DARK_RED + "" + ChatColor.BOLD + "Shop", 2, plugin.mm);
- blocks = new Menu(ChatColor.DARK_RED + "" + ChatColor.BOLD + "Shop" + ChatColor.DARK_GRAY + "" + ChatColor.BOLD + " > Blocks", 6, plugin.mm);
- cb1 = new Menu(ChatColor.DARK_RED + "" + ChatColor.BOLD + "Shop" + ChatColor.DARK_GRAY + "" + ChatColor.BOLD + " > Color Blocks 1", 6, plugin.mm);
- cb2 = new Menu(ChatColor.DARK_RED + "" + ChatColor.BOLD + "Shop" + ChatColor.DARK_GRAY + "" + ChatColor.BOLD + " > Color Blocks 2", 6, plugin.mm);
- resources = new Menu(ChatColor.DARK_RED + "" + ChatColor.BOLD + "Shop" + ChatColor.DARK_GRAY + "" + ChatColor.BOLD + " > Resources", 6, plugin.mm);
- mobdrops = new Menu(ChatColor.DARK_RED + "" + ChatColor.BOLD + "Shop" + ChatColor.DARK_GRAY + "" + ChatColor.BOLD + " > Mob Drops", 6, plugin.mm);
- potionmats = new Menu(ChatColor.DARK_RED + "" + ChatColor.BOLD + "Shop" + ChatColor.DARK_GRAY + "" + ChatColor.BOLD + " > Potion Materials", 6, plugin.mm);
- farming = new Menu(ChatColor.DARK_RED + "" + ChatColor.BOLD + "Shop" + ChatColor.DARK_GRAY + "" + ChatColor.BOLD + " > Farming", 6, plugin.mm);
- food = new Menu(ChatColor.DARK_RED + "" + ChatColor.BOLD + "Shop" + ChatColor.DARK_GRAY + "" + ChatColor.BOLD + " > Food", 6, plugin.mm);
- redstone = new Menu(ChatColor.DARK_RED + "" + ChatColor.BOLD + "Shop" + ChatColor.DARK_GRAY + "" + ChatColor.BOLD + " > Redstone", 6, plugin.mm);
- pots = new Menu(ChatColor.DARK_RED + "" + ChatColor.BOLD + "Shop" + ChatColor.DARK_GRAY + "" + ChatColor.BOLD + " > Potions", 6, plugin.mm);
- spawners = new Menu(ChatColor.DARK_RED + "" + ChatColor.BOLD + "Shop" + ChatColor.DARK_GRAY + "" + ChatColor.BOLD + " > Spawners", 6, plugin.mm);
- shopMenuItem(0, shopMain, Material.COBBLESTONE, "Blocks", blocks);
- shopMenuItem(1, shopMain, Material.STAINED_CLAY, "Color Blocks 1", cb1);
- shopMenuItem(2, shopMain, Material.HARD_CLAY, "Color Blocks 2", cb2);
- shopMenuItem(3, shopMain, Material.DIAMOND, "Resources", resources);
- shopMenuItem(4, shopMain, Material.SULPHUR, "Mob Drops", mobdrops);
- shopMenuItem(5, shopMain, Material.BREWING_STAND_ITEM, "Potion Materials", potionmats);
- shopMenuItem(6, shopMain, Material.WHEAT, "Farming", farming);
- shopMenuItem(7, shopMain, Material.COOKED_BEEF, "Food", food);
- shopMenuItem(8, shopMain, Material.REDSTONE, "Redstone", redstone);
- shopMenuItem(9, shopMain, Material.POTION, "Potions", pots);
- shopMenuItem(10, shopMain, Material.MOB_SPAWNER, "Spawners", spawners);
- shopBSItem(0, shopMain, blocks, Material.COBBLESTONE, "Cobblestone", new ItemBuilder(Material.COBBLESTONE).make(), 64, 150, 1, 0.93, 64, 59.52);
- shopBSItem(1, shopMain, blocks, Material.STONE, "Stone", new ItemBuilder(Material.STONE).make(), 64, 175, 1, 0.93, 64, 59.52);
- shopBSItem(2, shopMain, blocks, Material.LOG, "Oak Log", new ItemBuilder(Material.LOG).make(), 8, 25, 1, 1.5, 64, 96);
- shopBSOItem(3, shopMain, blocks, Material.LOG, 1, "Spruce Log", new ItemBuilder(Material.LOG).data(1).make(), 8, 25, 1, 1.5, 64, 96);
- shopBSOItem(4, shopMain, blocks, Material.LOG, 2, "Birch Log", new ItemBuilder(Material.LOG).data(2).make(), 8, 25, 1, 1.5, 64, 96);
- shopBSOItem(5, shopMain, blocks, Material.LOG, 3, "Jungle Log", new ItemBuilder(Material.LOG).data(3).make(), 8, 25, 1, 1.5, 64, 96);
- shopBSItem(6, shopMain, blocks, Material.LOG_2, "Dark Oak Log", new ItemBuilder(Material.LOG).make(), 8, 25, 1, 1.5, 64, 96);
- shopBSOItem(7, shopMain, blocks, Material.LOG_2, 1, "Acacia Log", new ItemBuilder(Material.LOG).data(1).make(), 8, 25, 1, 1.5, 64, 96);
- shopBSItem(8, shopMain, blocks, Material.PACKED_ICE, "Packed Ice", new ItemBuilder(Material.PACKED_ICE).make(), 8, 150, 1, 3, 64, 192);
- shopBSItem(9, shopMain, blocks, Material.SANDSTONE, "Sand Stone", new ItemBuilder(Material.SANDSTONE).make(), 16, 100, 1, 1, 32, 32);
- shopBSOItem(10, shopMain, blocks, Material.SANDSTONE, 1, "Chiseled Sand Stone", new ItemBuilder(Material.SANDSTONE).data(1).make(), 16, 100, 1, 1, 32, 32);
- shopBSOItem(11, shopMain, blocks, Material.SANDSTONE, 2, "Smooth Sand Stone", new ItemBuilder(Material.SANDSTONE).data(2).make(), 16, 100, 1, 1, 32, 32);
- /*
- shopBSItem(, shopMain, blocks, Material, title + "", player, new ItemBuilder(Material).make(), , , , , , );
- shopBSItem(, shopMain, blocks, Material, title + "", player, new ItemBuilder(Material).make(), , , , , , );
- shopBSItem(, shopMain, blocks, Material, title + "", player, new ItemBuilder(Material).make(), , , , , , );
- shopBSItem(, shopMain, blocks, Material, title + "", player, new ItemBuilder(Material).make(), , , , , , );
- shopBSItem(, shopMain, blocks, Material, title + "", player, new ItemBuilder(Material).make(), , , , , , );
- shopBSItem(, shopMain, blocks, Material, title + "", player, new ItemBuilder(Material).make(), , , , , , );
- shopBSItem(, shopMain, blocks, Material, title + "", player, new ItemBuilder(Material).make(), , , , , , )
- shopBSItem(, shopMain, blocks, Material, title + "", player, new ItemBuilder(Material).make(), , , , , , );
- shopBSItem(, shopMain, blocks, Material, title + "", player, new ItemBuilder(Material).make(), , , , , , );
- shopBSItem(, shopMain, blocks, Material, title + "", player, new ItemBuilder(Material).make(), , , , , , );
- shopBSItem(, shopMain, blocks, Material, title + "", player, new ItemBuilder(Material).make(), , , , , , );
- shopBSItem(, shopMain, blocks, Material, title + "", player, new ItemBuilder(Material).make(), , , , , , );
- shopBSItem(, shopMain, blocks, Material, title + "", player, new ItemBuilder(Material).make(), , , , , , );
- shopBSItem(, shopMain, blocks, Material, title + "", player, new ItemBuilder(Material).make(), , , , , , );
- shopBSItem(, shopMain, blocks, Material, title + "", player, new ItemBuilder(Material).make(), , , , , , );
- shopBSItem(, shopMain, blocks, Material, title + "", player, new ItemBuilder(Material).make(), , , , , , );
- shopBSItem(, shopMain, blocks, Material, title + "", player, new ItemBuilder(Material).make(), , , , , , );
- shopBSItem(, shopMain, blocks, Material, title + "", player, new ItemBuilder(Material).make(), , , , , , );
- shopBSItem(, shopMain, blocks, Material, title + "", player, new ItemBuilder(Material).make(), , , , , , );
- shopBSItem(, shopMain, blocks, Material, title + "", player, new ItemBuilder(Material).make(), , , , , , );
- */
- }
- @Override
- public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
- if (sender instanceof Player) {
- Player player = (Player) sender;
- shopMain.show(player);
- return true;
- } else {
- sender.sendMessage(sn + ChatColor.RED + "You cannot use this from console!");
- return true;
- }
- }
- public void cooldown(final String player) {
- player.toLowerCase();
- plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
- public void run() {
- cdl.remove(player);
- }
- }, 10L);
- }
- public void shopBSItem(int slot, Menu main, Menu cat, Material mat, String name, ItemStack i, int a1, double p1, int a2, double p2, int a3, double p3) {
- String[] lores = {ChatColor.GREEN + "[L] Buy: $" + p1 + " (" + a1 + ")",
- ChatColor.RED + "[R] Sell: $" + p2 + " {" + a2 + ")",
- ChatColor.RED + "[R] Sell: $" + p3 + " {" + a3 + ") [SHIFT]"};
- cat.setItem(slot, new ItemBuilder(mat).name(ChatColor.WHITE + "" + ChatColor.BOLD + "" + name).lores(lores).make(), new Item() {
- @Override
- public void clickEvent(InventoryClickEvent event) {
- event.setCancelled(true);
- Player player = (Player) event.getWhoClicked();
- boolean cd = cdl.contains(player.getName().toLowerCase());
- if (!cd) {
- if (event.isLeftClick()) {
- double bal = eco.getBalance(player);
- if (bal >= p1) {
- i.setAmount(a1);
- player.getInventory().addItem(i);
- eco.withdrawPlayer(player, p1);
- cdl.add(player.getName().toLowerCase());
- cooldown(player.getName());
- player.updateInventory();
- emsg(player, "You have purchased " + a1 + " " + name + " for $" + p1 + "!");
- } else {
- emsg(player, "You do not have enough money to purchase this!");
- }
- } else if (event.isRightClick()) {
- if (player.getInventory().containsAtLeast(i, a2)) {
- i.setAmount(a2);
- // Look into this more later \/
- player.getInventory().removeItem(i);
- eco.depositPlayer(player, p2);
- cdl.add(player.getName().toLowerCase());
- cooldown(player.getName());
- player.updateInventory();
- smsg(player, "You have sold " + a2 + " " + name + " for $" + p2 + "!");
- } else {
- emsg(player, "You do not have enough " + name + " to sell!");
- }
- } else if (event.isShiftClick()) {
- i.setAmount(a3);
- // Look into this more later \/
- player.getInventory().removeItem(i);
- eco.depositPlayer(player, p3);
- cdl.add(player.getName().toLowerCase());
- cooldown(player.getName());
- player.updateInventory();
- smsg(player, "You have sold " + a3 + " " + name + " for $" + p3 + "!");
- } else if (event.isCancelled()) {
- main.show(player);
- }
- }
- }
- });
- }
- public void shopBSOItem(int slot, Menu main, Menu cat, Material mat, int num, String name, ItemStack i, int a1, double p1, int a2, double p2, int a3, double p3) {
- String[] lores = {ChatColor.GREEN + "[L] Buy: $" + p1 + " (" + a1 + ")",
- ChatColor.RED + "[R] Sell: $" + p2 + " {" + a2 + ")",
- ChatColor.RED + "[R] Sell: $" + p3 + " {" + a3 + ") [SHIFT]"};
- cat.setItem(slot, new ItemBuilder(mat).data(num).name(ChatColor.WHITE + "" + ChatColor.BOLD + "" + name).lores(lores).make(), new Item() {
- @Override
- public void clickEvent(InventoryClickEvent event) {
- event.setCancelled(true);
- Player player = (Player) event.getWhoClicked();
- boolean cd = cdl.contains(player.getName().toLowerCase());
- if (!cd) {
- if (event.isLeftClick()) {
- double bal = eco.getBalance(player);
- if (bal >= p1) {
- i.setAmount(a1);
- player.getInventory().addItem(i);
- eco.withdrawPlayer(player, p1);
- cdl.add(player.getName().toLowerCase());
- cooldown(player.getName());
- player.updateInventory();
- emsg(player, "You have purchased " + a1 + " " + name + " for $" + p1 + "!");
- } else {
- emsg(player, "You do not have enough money to purchase this!");
- }
- } else if (event.isRightClick()) {
- if (player.getInventory().containsAtLeast(i, a2)) {
- i.setAmount(a2);
- // Look into this more later \/
- player.getInventory().removeItem(i);
- eco.depositPlayer(player, p2);
- cdl.add(player.getName().toLowerCase());
- cooldown(player.getName());
- player.updateInventory();
- smsg(player, "You have sold " + a2 + " " + name + " for $" + p2 + "!");
- } else {
- emsg(player, "You do not have enough " + name + " to sell!");
- }
- } else if (event.isShiftClick()) {
- i.setAmount(a3);
- // Look into this more later \/
- player.getInventory().removeItem(i);
- eco.depositPlayer(player, p3);
- cdl.add(player.getName().toLowerCase());
- cooldown(player.getName());
- player.updateInventory();
- smsg(player, "You have sold " + a3 + " " + name + " for $" + p3 + "!");
- }
- }
- }
- });
- }
- public void shopBSCItem(int slot, Menu main, Menu cat, Material mat, Color c, String name, ItemStack i, int a1, double p1, int a2, double p2, int a3, double p3) {
- String[] lores = {ChatColor.GREEN + "[L] Buy: $" + p1 + " (" + a1 + ")",
- ChatColor.RED + "[R] Sell: $" + p2 + " {" + a2 + ")",
- ChatColor.RED + "[R] Sell: $" + p3 + " {" + a3 + ") [SHIFT]"};
- cat.setItem(slot, new ItemBuilder(mat).name(ChatColor.WHITE + "" + ChatColor.BOLD + "" + name).lores(lores).color(c).make(), new Item() {
- @Override
- public void clickEvent(InventoryClickEvent event) {
- event.setCancelled(true);
- Player player = (Player) event.getWhoClicked();
- boolean cd = cdl.contains(player.getName().toLowerCase());
- if (!cd) {
- if (event.isLeftClick()) {
- double bal = eco.getBalance(player);
- if (bal >= p1) {
- i.setAmount(a1);
- player.getInventory().addItem(i);
- eco.withdrawPlayer(player, p1);
- cdl.add(player.getName().toLowerCase());
- cooldown(player.getName());
- player.updateInventory();
- emsg(player, "You have purchased " + a1 + " " + name + " for $" + p1 + "!");
- } else {
- emsg(player, "You do not have enough money to purchase this!");
- }
- } else if (event.isRightClick()) {
- if (player.getInventory().containsAtLeast(i, a2)) {
- i.setAmount(a2);
- // Look into this more later \/
- player.getInventory().removeItem(i);
- eco.depositPlayer(player, p2);
- cdl.add(player.getName().toLowerCase());
- cooldown(player.getName());
- player.updateInventory();
- smsg(player, "You have sold " + a2 + " " + name + " for $" + p2 + "!");
- } else {
- emsg(player, "You do not have enough " + name + " to sell!");
- }
- } else if (event.isShiftClick()) {
- i.setAmount(a3);
- // Look into this more later \/
- player.getInventory().removeItem(i);
- eco.depositPlayer(player, p3);
- cdl.add(player.getName().toLowerCase());
- cooldown(player.getName());
- player.updateInventory();
- smsg(player, "You have sold " + a3 + " " + name + " for $" + p3 + "!");
- }
- }
- }
- });
- }
- public void shopBItem(int slot, Menu main, Menu cat, Material mat, String name, ItemStack i, int a, double p) {
- String[] lores = {ChatColor.GREEN + "[L] Buy: $" + p + " (" + a + ")"};
- cat.setItem(slot, new ItemBuilder(mat).name(ChatColor.WHITE + "" + ChatColor.BOLD + "" + name).lores(lores).make(), new Item() {
- @Override
- public void clickEvent(InventoryClickEvent event) {
- event.setCancelled(true);
- if (event.isLeftClick()) {
- Player player = (Player) event.getWhoClicked();
- double bal = eco.getBalance(player);
- if (bal >= p) {
- i.setAmount(a);
- player.getInventory().addItem(i);
- eco.withdrawPlayer(player, p);
- cdl.add(player.getName().toLowerCase());
- cooldown(player.getName());
- player.updateInventory();
- emsg(player, "You have purchased " + a + " " + name + " for $" + p + "!");
- } else {
- emsg(player, "You do not have enough money to purchase this!");
- }
- }
- }
- });
- }
- public void shopMenuItem(int slot, Menu main, Material mat, String name, Menu next) {
- main.setItem(slot, new ItemBuilder(mat).name(ChatColor.WHITE + "" + ChatColor.BOLD + "" + name).make(), new Item() {
- @Override
- public void clickEvent(InventoryClickEvent event) {
- event.setCancelled(true);
- Player player = (Player) event.getWhoClicked();
- if (event.getClick().isLeftClick()) {
- next.show(player);
- }
- }
- });
- }
- public void smsg(Player player, String s) {
- player.sendMessage(sn + ChatColor.GREEN + s);
- }
- public void emsg(Player player, String s) {
- player.sendMessage(sn + ChatColor.RED + s);
- }
- public void msg(Player player, String s) {
- player.sendMessage(sn + ChatColor.GRAY + s);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement