Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private static int mcoins;
- @EventHandler
- public void OnPlayerJoin(PlayerJoinEvent e) {
- CoinsAPI.createPlayer(e.getPlayer().getUniqueId().toString());
- }
- @EventHandler
- public void OnInvClick(InventoryClickEvent e) {
- if ((e.getInventory() != null) &&
- (e.getInventory().getTitle().equals(Utils.getTitle()))) {
- Player p = (Player)e.getWhoClicked();
- for (int i = 0; i < 28; i++) {
- if (Utils.getitem(i, p) != null) {
- if (e.getCurrentItem().equals(Utils.getitem(i, p))) {
- String player = p.getUniqueId().toString();
- if (CoinsAPI.getCoins(player).intValue() >= Utils.getPrice(i, p)) {
- p.closeInventory();
- CoinsAPI.removeCoins(player, Utils.getPrice(i, p));
- p.sendMessage(Utils.getprefix() + ChatColor.GRAY + " You Bought an Item From The Shop!");
- java.util.List<String> command = MainCoins.getInstance().getConfig().getStringList("Shop." + i + ".Commands");
- for (String cmd : command) {
- org.bukkit.Bukkit.getServer().dispatchCommand(org.bukkit.Bukkit.getServer().getConsoleSender(), cmd.replace("%player%", e.getWhoClicked().getName()));
- }
- } else {
- p.closeInventory();
- p.sendMessage(Utils.getprefix() + ChatColor.GRAY + " You don't have enough Mobcoins!");
- }
- } else {
- Shop.reloadBals();
- p.updateInventory();
- e.setCancelled(true);
- }
- }
- }
- }
- }
- @SuppressWarnings("deprecation")
- @EventHandler
- public void OnEntityDeath(EntityDeathEvent e)
- {
- if ((e.getEntity().getKiller() != null) &&
- (e.getEntityType() != null) && (e.getEntityType().getName() != null) &&
- (Utils.hasmob(e.getEntityType().getName().toUpperCase()).booleanValue())) {
- Random object = new Random();
- int i = 1 + object.nextInt(100);
- if (i <= Utils.getChange(e.getEntityType().getName().toUpperCase())) {
- Player p = e.getEntity().getKiller();
- if (p == null) return;
- String player = p.getUniqueId().toString();
- MobCoinsGiveEvent event = new MobCoinsGiveEvent(p, 1);
- org.bukkit.Bukkit.getPluginManager().callEvent(event);
- if (event.getAmount().intValue() > 1) {
- p.sendMessage(Utils.getprefix() + ChatColor.GRAY + " You Killed A " + e.getEntityType().getName() + " and Gained " + event.getAmount() + " Mobcoins!");
- } else {
- p.sendMessage(Utils.getprefix() + ChatColor.GRAY + " You Killed A " + e.getEntityType().getName() + " and Gained " + event.getAmount() + " Mobcoin!");
- }
- CoinsAPI.addCoins(player, event.getAmount().intValue());
- }
- }
- }
- private final java.io.File bal = new java.io.File("plugins//MobCoinss//Balances.yml");
- private final YamlConfiguration bal1 = YamlConfiguration.loadConfiguration(bal);
- @EventHandler
- public void onPlayerJoin(PlayerJoinEvent e) {
- Player p = e.getPlayer();
- String player = p.getUniqueId().toString();
- if (!bal1.contains(player)) {
- bal1.set(player, 0);
- MainCoins.getInstance().saveCustomYml(bal1, bal);
- }
- }
- public static int getItemAmount(ItemStack ie, Player p){
- ItemStack item = p.getItemInHand();
- ItemMeta itemm = item.getItemMeta();
- if(itemm.getLore() != null && item != null){
- for(String line : itemm.getLore()) {
- if(line.startsWith("Amount: ")){
- String level = line.replace("Amount: ", "");
- level = ChatColor.stripColor(level);
- item.setItemMeta(itemm);
- Events.mcoins = Integer.parseInt(level);
- }
- }
- }
- return Events.mcoins;
- }
- @EventHandler
- public void onpi(PlayerInteractEvent e) {
- Player p = e.getPlayer();
- if (e.getAction() == Action.RIGHT_CLICK_AIR) {
- p.sendMessage("1");
- if (e.getPlayer().getItemInHand().getItemMeta().getDisplayName().contains(ChatColor.translateAlternateColorCodes('&', "&6&lMob Coin &7(Right Click)"))) {
- ItemStack item = p.getItemInHand();
- Events.getItemAmount(item, p);
- p.sendMessage( "there is " + mcoins);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement