Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package eu.hyxperia.factions;
- import java.io.File;
- import java.util.List;
- import java.util.Random;
- import java.util.UUID;
- import net.md_5.bungee.api.ChatColor;
- import org.bukkit.Bukkit;
- import org.bukkit.Server;
- import org.bukkit.configuration.file.FileConfiguration;
- import org.bukkit.configuration.file.YamlConfiguration;
- import org.bukkit.entity.EntityType;
- import org.bukkit.entity.HumanEntity;
- import org.bukkit.entity.LivingEntity;
- import org.bukkit.entity.Player;
- import org.bukkit.event.EventHandler;
- import org.bukkit.event.Listener;
- import org.bukkit.event.entity.EntityDeathEvent;
- import org.bukkit.event.inventory.InventoryClickEvent;
- import org.bukkit.event.player.PlayerJoinEvent;
- import org.bukkit.inventory.Inventory;
- import org.bukkit.inventory.ItemStack;
- import org.bukkit.inventory.meta.ItemMeta;
- public class Events
- implements Listener
- {
- private static Main plugin;
- File CE = new File("plugins//CustomEnchants//config.yml");
- YamlConfiguration CEConfig = YamlConfiguration.loadConfiguration(this.CE);
- public Events(Main pl)
- {
- plugin = pl;
- }
- public static String convertPower(int i)
- {
- if (i <= 0) {
- return "I";
- }
- if (i == 1) {
- return "I";
- }
- if (i == 2) {
- return "II";
- }
- if (i == 3) {
- return "III";
- }
- if (i == 4) {
- return "IV";
- }
- if (i == 5) {
- return "V";
- }
- if (i == 6) {
- return "VI";
- }
- if (i == 7) {
- return "VII";
- }
- if (i == 8) {
- return "VIII";
- }
- if (i == 9) {
- return "IX";
- }
- if (i == 10) {
- return "X";
- }
- return i;
- }
- @EventHandler
- public void OnPlayerJoin(PlayerJoinEvent e)
- {
- Player p = e.getPlayer();
- String player = p.getUniqueId().toString();
- CoinsAPI.createPlayer(player);
- }
- @EventHandler
- public void OnInvClick(InventoryClickEvent e)
- {
- if (e.getInventory().getTitle().equals(Utils.getTitle()))
- {
- Player p = (Player)e.getWhoClicked();
- for (int i = 0; i < 28; i++) {
- 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 Brought an Item From The Shop!");
- List<String> command = plugin.getConfig().getStringList("Shop." + i + ".Commands");
- for (String cmd : command) {
- Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), cmd.replace("%player%", e.getWhoClicked().getName()));
- }
- }
- else
- {
- p.closeInventory();
- p.sendMessage(Utils.getprefix() + ChatColor.GRAY + " You dont have enough Mobcoins!");
- }
- }
- else
- {
- e.setCancelled(true);
- }
- }
- }
- }
- @EventHandler
- public void OnEntityDeath(EntityDeathEvent e)
- {
- if (e.getEntityType().equals(EntityType.GHAST))
- {
- Random object = new Random();
- for (int counter = 1; counter <= 1; counter++)
- {
- int i = 1 + object.nextInt(100);
- if (i <= Utils.getghast())
- {
- Player p = e.getEntity().getKiller();
- if (p == null) {
- return;
- }
- String player = p.getUniqueId().toString();
- if ((p.getItemInHand() != null) &&
- (p.getItemInHand().hasItemMeta()) &&
- (p.getItemInHand().getItemMeta().hasLore())) {
- for (int counter1 = 1; counter1 <= this.CEConfig.getInt("MaxPower.Coins"); counter1++) {
- if (Utils.hasenchant("Coins " + convertPower(counter1), p.getItemInHand()).booleanValue())
- {
- p.sendMessage(Utils.getprefix() + ChatColor.GRAY + " Hai ucciso un ghast, hai guadagnato " + (counter1 + 1) + " Mobcoins!");
- CoinsAPI.addCoins(player, counter1 + 1);
- return;
- }
- }
- }
- p.sendMessage(Utils.getprefix() + ChatColor.GRAY + " Hai ucciso un ghast ed hai guadagnato 1 Mobcoin!");
- CoinsAPI.addCoins(player, 1);
- }
- }
- }
- if (e.getEntityType().equals(EntityType.VILLAGER))
- {
- Random object = new Random();
- for (int counter = 1; counter <= 1; counter++)
- {
- int i = 1 + object.nextInt(100);
- if (i <= Utils.getvillager())
- {
- Player p = e.getEntity().getKiller();
- if (p == null) {
- return;
- }
- String player = p.getUniqueId().toString();
- if ((p.getItemInHand() != null) &&
- (p.getItemInHand().hasItemMeta()) &&
- (p.getItemInHand().getItemMeta().hasLore())) {
- for (int counter1 = 1; counter1 <= this.CEConfig.getInt("MaxPower.Coins"); counter1++) {
- if (Utils.hasenchant("Coins " + convertPower(counter1), p.getItemInHand()).booleanValue())
- {
- p.sendMessage(Utils.getprefix() + ChatColor.GRAY + " Hai ucciso un villager, hai guadagnato " + (counter1 + 1) + " Mobcoins!");
- CoinsAPI.addCoins(player, counter1 + 1);
- return;
- }
- }
- }
- p.sendMessage(Utils.getprefix() + ChatColor.GRAY + " Hai ucciso un villager ed hai guadagnato 1 Mobcoin!");
- CoinsAPI.addCoins(player, 1);
- }
- }
- }
- if (e.getEntityType().equals(EntityType.BLAZE))
- {
- Random object = new Random();
- for (int counter = 1; counter <= 1; counter++)
- {
- int i = 1 + object.nextInt(100);
- if (i <= Utils.getblaze())
- {
- Player p = e.getEntity().getKiller();
- if (p == null) {
- return;
- }
- String player = p.getUniqueId().toString();
- if ((p.getItemInHand() != null) &&
- (p.getItemInHand().hasItemMeta()) &&
- (p.getItemInHand().getItemMeta().hasLore())) {
- for (int counter1 = 1; counter1 <= this.CEConfig.getInt("MaxPower.Coins"); counter1++) {
- if (Utils.hasenchant("Coins " + convertPower(counter1), p.getItemInHand()).booleanValue())
- {
- p.sendMessage(Utils.getprefix() + ChatColor.GRAY + " Hai ucciso un ghast, hai guadagnato " + (counter1 + 1) + " Mobcoins!");
- CoinsAPI.addCoins(player, counter1 + 1);
- return;
- }
- }
- }
- p.sendMessage(Utils.getprefix() + ChatColor.GRAY + " Hai ucciso un blaze ed hai guadagnato 1 Mobcoin!");
- CoinsAPI.addCoins(player, 1);
- }
- }
- }
- if (e.getEntityType().equals(EntityType.MAGMA_CUBE))
- {
- Random object = new Random();
- for (int counter = 1; counter <= 1; counter++)
- {
- int i = 1 + object.nextInt(100);
- if (i <= Utils.getcube())
- {
- Player p = e.getEntity().getKiller();
- if (p == null) {
- return;
- }
- String player = p.getUniqueId().toString();
- if ((p.getItemInHand() != null) &&
- (p.getItemInHand().hasItemMeta()) &&
- (p.getItemInHand().getItemMeta().hasLore())) {
- for (int counter1 = 1; counter1 <= this.CEConfig.getInt("MaxPower.Coins"); counter1++) {
- if (Utils.hasenchant("Coins " + convertPower(counter1), p.getItemInHand()).booleanValue())
- {
- p.sendMessage(Utils.getprefix() + ChatColor.GRAY + " Hai ucciso un MAGMACUBE, hai guadagnato " + (counter1 + 1) + " Mobcoins!");
- CoinsAPI.addCoins(player, counter1 + 1);
- return;
- }
- }
- }
- p.sendMessage(Utils.getprefix() + ChatColor.GRAY + " Hai ucciso un MAGNACUBE ed hai guadagnato 1 Mobcoin!");
- CoinsAPI.addCoins(player, 1);
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement