Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package fr.alexousd.pvp;
- import org.bukkit.Bukkit;
- import org.bukkit.Material;
- import org.bukkit.SkullType;
- import org.bukkit.enchantments.Enchantment;
- import org.bukkit.entity.Player;
- import org.bukkit.event.EventHandler;
- import org.bukkit.event.Listener;
- import org.bukkit.event.inventory.InventoryClickEvent;
- import org.bukkit.event.player.PlayerDropItemEvent;
- import org.bukkit.event.player.PlayerInteractEvent;
- import org.bukkit.event.player.PlayerJoinEvent;
- import org.bukkit.inventory.Inventory;
- import org.bukkit.inventory.ItemStack;
- import org.bukkit.inventory.meta.ItemMeta;
- import org.bukkit.inventory.meta.SkullMeta;
- public class pListener implements Listener {
- static int task;
- @EventHandler
- public void onJoin(PlayerJoinEvent e) {
- Player p = (Player) e.getPlayer();
- /*
- * Items quand le joueur rejoint le serveur
- */
- ItemStack epee = new ItemStack(Material.IRON_SWORD);
- ItemMeta epeeMeta = epee.getItemMeta();
- epeeMeta.setDisplayName("§6PvP Vanilla");
- epee.setItemMeta(epeeMeta);
- ItemStack heal = new ItemStack(Material.POTION, 1, (short) 8261);
- ItemMeta healMeta = heal.getItemMeta();
- healMeta.setDisplayName("§6PvP Potion");
- heal.setItemMeta(healMeta);
- ItemStack head = new ItemStack(Material.SKULL_ITEM, 1, (short)SkullType.PLAYER.ordinal());
- SkullMeta meta = (SkullMeta)head.getItemMeta();
- meta.setOwner(p.getName());
- meta.setDisplayName("§6Statistiques");
- head.setItemMeta(meta);
- ItemStack soup = new ItemStack(Material.MUSHROOM_SOUP);
- ItemMeta soupMeta = soup.getItemMeta();
- soupMeta.setDisplayName("§6PvP Soupe");
- soup.setItemMeta(soupMeta);
- ItemStack golden_apple = new ItemStack(Material.GOLDEN_APPLE);
- ItemMeta golden_appleMeta = golden_apple.getItemMeta();
- golden_appleMeta.setDisplayName("§6PvP Hardcore");
- golden_apple.setItemMeta(golden_appleMeta);
- p.getInventory().setItem(0, epee);
- p.getInventory().setItem(2, heal);
- p.getInventory().setItem(4, head);
- p.getInventory().setItem(6, soup);
- p.getInventory().setItem(8, golden_apple);
- }
- @EventHandler
- public void onDrop(PlayerDropItemEvent e) {
- /*
- * Supprime les drops
- */
- if (e.getItemDrop().getItemStack().getItemMeta().getDisplayName().equalsIgnoreCase("§6PvP Vanilla")) {
- e.setCancelled(true);
- }
- if (e.getItemDrop().getItemStack().getItemMeta().getDisplayName().equalsIgnoreCase("§6PvP Potion")) {
- e.setCancelled(true);
- }
- if (e.getItemDrop().getItemStack().getItemMeta().getDisplayName().equalsIgnoreCase("§6Statistiques")) {
- e.setCancelled(true);
- }
- if (e.getItemDrop().getItemStack().getItemMeta().getDisplayName().equalsIgnoreCase("§6PvP Soupe")) {
- e.setCancelled(true);
- }
- if (e.getItemDrop().getItemStack().getItemMeta().getDisplayName().equalsIgnoreCase("§6PvP Hardcore")) {
- e.setCancelled(true);
- }
- }
- @EventHandler
- public void onInventoryClick(InventoryClickEvent e) {
- Player p = (Player) e.getWhoClicked();
- switch (e.getCurrentItem().getType()) {
- case IRON_SWORD:
- if (e.getCurrentItem().getItemMeta().getDisplayName().equalsIgnoreCase("§6PvP Vanilla")) {
- e.setCancelled(true);
- menu(p);
- /*
- * En cliquant sur l'épée en fer, le menu principal s'ouvre
- * (Mis en place)
- */
- }
- break;
- default:
- break;
- }
- switch (e.getCurrentItem().getType()) {
- case POTION:
- if (e.getCurrentItem().getItemMeta().getDisplayName().equalsIgnoreCase("§6PvP Potion")) {
- e.setCancelled(true);
- menu(p);
- /*
- * En cliquant sur la potion de heal, le menu principal s'ouvre
- * (Mis en place)
- */
- }
- break;
- default:
- break;
- }
- switch (e.getCurrentItem().getType()) {
- case SKULL_ITEM:
- if (e.getCurrentItem().getItemMeta().getDisplayName().equalsIgnoreCase("§a1vs1")) {
- e.setCancelled(true);
- menu1vs1(p);
- /*
- * Le menu 1vs1 s'ouvre
- * (Mis en place)
- */
- }
- if (e.getCurrentItem().getItemMeta().getDisplayName().equalsIgnoreCase("§a2vs2")) {
- e.setCancelled(true);
- menu2vs2(p);
- /*
- * Le menu 2vs2 s'ouvre
- * (Mis en place)
- */
- }
- if (e.getCurrentItem().getItemMeta().getDisplayName().equalsIgnoreCase("§a3vs3")) {
- e.setCancelled(true);
- menu3vs3(p);
- /*
- * Le menu 3vs3 s'ouvre
- * (Mis en place)
- */
- }
- if (e.getCurrentItem().getItemMeta().getDisplayName().equalsIgnoreCase("§6Statistiques")) {
- e.setCancelled(true);
- p.closeInventory();
- p.sendMessage("§c§oLes statistiques ne sont pas encore mis en place...");
- /*
- * En cliquant sur la tête statistiques, ça lui dit dans le chat combien de coins il a, combien de kills il a fait
- * (Pas mis en place)
- */
- }
- break;
- default:
- break;
- }
- switch (e.getCurrentItem().getType()) {
- case MUSHROOM_SOUP:
- if (e.getCurrentItem().getItemMeta().getDisplayName().equalsIgnoreCase("§6PvP Soupe")) {
- e.setCancelled(true);
- menu(p);
- /*
- * En cliquant sur la soupe, le menu principal s'ouvre
- * (Mis en place)
- */
- }
- break;
- default:
- break;
- }
- switch (e.getCurrentItem().getType()) {
- case GOLDEN_APPLE:
- if (e.getCurrentItem().getItemMeta().getDisplayName().equalsIgnoreCase("§6PvP Hardcore")) {
- e.setCancelled(true);
- menu(p);
- /*
- * En cliquant sur la golden apple, le menu principal s'ouvre
- * (Mis en place)
- */
- }
- break;
- default:
- break;
- }
- switch (e.getCurrentItem().getType()) {
- case BOW:
- if (e.getCurrentItem().getItemMeta().getDisplayName().equalsIgnoreCase("§bBowPvP §7(1vs1)")) {
- e.setCancelled(true);
- p.closeInventory();
- /*
- * Le joueur rejoint la file d'attente en cliquant sur l'arc "BowPvP"
- * (Pas mis en place)
- */
- }
- break;
- default:
- break;
- }
- }
- public static void fileAttente(Player p) {
- task = Bukkit.getScheduler().scheduleSyncRepeatingTask(Bukkit.getPluginManager().getPlugin("AscensionPvP"), new Runnable() {
- @Override
- public void run() {
- // TODO Auto-generated method stub
- }
- }, 20, 20);
- }
- @EventHandler
- public void onInteract(PlayerInteractEvent e) {
- Player p = (Player) e.getPlayer();
- if (e.getItem().getItemMeta().getDisplayName().equalsIgnoreCase("§6PvP Vanilla")) {
- e.setCancelled(true);
- menu(p);
- /*
- * En interagissant avec l'item nommé "PvP Vanilla" le menu principal s'ouvre.
- */
- }
- if (e.getItem().getItemMeta().getDisplayName().equalsIgnoreCase("§6PvP Potion")) {
- e.setCancelled(true);
- menu(p);
- /*
- * En interagissant avec l'item nommé "PvP Potion" le menu principal s'ouvre.
- */
- }
- if (e.getItem().getItemMeta().getDisplayName().equalsIgnoreCase("§6PvP Soupe")) {
- e.setCancelled(true);
- menu(p);
- /*
- * En interagissant avec l'item nommé "PvP Soupe" le menu principal s'ouvre.
- */
- }
- if (e.getItem().getItemMeta().getDisplayName().equalsIgnoreCase("§6PvP Hardcore")) {
- e.setCancelled(true);
- menu(p);
- /*
- * En interagissant avec l'item nommé "PvP Hardcore" le menu principal s'ouvre.
- */
- }
- if (e.getItem().getItemMeta().getDisplayName().equalsIgnoreCase("§6Statistiques")) {
- e.setCancelled(true);
- p.sendMessage("§c§oLes statistiques ne sont pas encore mis en place...");
- /*
- * En interagissant avec l'item nommé "Statistiques" un message est envoyé au joueur qui lui dit son nombre de kills ainsi que ses coins et ses victoires.
- */
- }
- }
- public void menu(Player p) {
- /*
- * Menu principal
- */
- Inventory menu = Bukkit.createInventory(null, 27, "");
- /*
- * 1vs1
- */
- ItemStack vs1 = new ItemStack(Material.SKULL_ITEM, 1, (short)SkullType.PLAYER.ordinal());
- SkullMeta meta = (SkullMeta)vs1.getItemMeta();
- meta.setOwner(p.getName());
- meta.setDisplayName("§a1vs1");
- vs1.setItemMeta(meta);
- menu.setItem(11, vs1);
- /*
- * 2vs2
- */
- ItemStack vs2 = new ItemStack(Material.SKULL_ITEM, 2, (short)SkullType.PLAYER.ordinal());
- SkullMeta meta2 = (SkullMeta)vs2.getItemMeta();
- meta2.setOwner(p.getName());
- meta2.setDisplayName("§a2vs2");
- vs2.setItemMeta(meta2);
- menu.setItem(13, vs2);
- /*
- * 3vs3
- */
- ItemStack vs3 = new ItemStack(Material.SKULL_ITEM, 3, (short)SkullType.PLAYER.ordinal());
- SkullMeta meta3 = (SkullMeta)vs3.getItemMeta();
- meta3.setOwner(p.getName());
- meta3.setDisplayName("§a3vs3");
- vs3.setItemMeta(meta3);
- menu.setItem(15, vs3);
- p.openInventory(menu);
- }
- public void menu1vs1(Player p) {
- /*
- * Menu du 1vs1
- */
- Inventory menu1vs1 = Bukkit.createInventory(null, 27, "");
- ItemStack bowpvp = new ItemStack(Material.BOW);
- ItemMeta bowpvpMeta = bowpvp.getItemMeta();
- bowpvpMeta.setDisplayName("§bBowPvP §7(1vs1)");
- bowpvp.setItemMeta(bowpvpMeta);
- menu1vs1.setItem(0, bowpvp);
- ItemStack axepvp = new ItemStack(Material.IRON_AXE);
- ItemMeta axepvpMeta = axepvp.getItemMeta();
- axepvpMeta.setDisplayName("§bAxe PvP §7(1vs1)");
- axepvp.setItemMeta(axepvpMeta);
- menu1vs1.setItem(1, axepvp);
- ItemStack ironpvp = new ItemStack(Material.IRON_CHESTPLATE);
- ironpvp.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2);
- ItemMeta ironpvpMeta = ironpvp.getItemMeta();
- ironpvpMeta.setDisplayName("§bIron PvP §7(1vs1)");
- ironpvp.setItemMeta(ironpvpMeta);
- menu1vs1.setItem(2, ironpvp);
- ItemStack ironpvpno = new ItemStack(Material.IRON_CHESTPLATE);
- ItemMeta ironpvpnoMeta = ironpvpno.getItemMeta();
- ironpvpnoMeta.setDisplayName("§bIron PvP (No Enchant) §7(1vs1)");
- ironpvpno.setItemMeta(ironpvpnoMeta);
- menu1vs1.setItem(3, ironpvpno);
- ItemStack diamondpvp = new ItemStack(Material.DIAMOND_CHESTPLATE);
- diamondpvp.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
- ItemMeta diamondpvpMeta = diamondpvp.getItemMeta();
- diamondpvpMeta.setDisplayName("§bDiamond PvP §7(1vs1)");
- diamondpvp.setItemMeta(diamondpvpMeta);
- menu1vs1.setItem(4, diamondpvp);
- ItemStack diamondpvpno = new ItemStack(Material.DIAMOND_CHESTPLATE);
- ItemMeta diamondpvpnoMeta = diamondpvpno.getItemMeta();
- diamondpvpnoMeta.setDisplayName("§bDiamond PvP (No Enchant) §7(1vs1)");
- diamondpvpno.setItemMeta(diamondpvpnoMeta);
- menu1vs1.setItem(5, diamondpvpno);
- ItemStack diamondcheat = new ItemStack(Material.DIAMOND_SWORD);
- diamondcheat.addEnchantment(Enchantment.DAMAGE_ALL, 2);
- ItemMeta diamondcheatMeta = diamondcheat.getItemMeta();
- diamondcheatMeta.setDisplayName("§bDiamond Cheat §7(1vs1)");
- diamondcheat.setItemMeta(diamondcheatMeta);
- menu1vs1.setItem(6, diamondcheat);
- ItemStack ironcheat = new ItemStack(Material.IRON_SWORD);
- ironcheat.addEnchantment(Enchantment.DAMAGE_ALL, 2);
- ItemMeta ironcheatMeta = ironcheat.getItemMeta();
- ironcheatMeta.setDisplayName("§bIron Cheat §7(1vs1)");
- ironcheat.setItemMeta(ironcheatMeta);
- menu1vs1.setItem(7, ironcheat);
- ItemStack pvpcheat = new ItemStack(Material.DIAMOND_BLOCK);
- ItemMeta pvpcheatMeta = pvpcheat.getItemMeta();
- pvpcheatMeta.setDisplayName("§bIron Cheat §7(1vs1)");
- pvpcheat.setItemMeta(pvpcheatMeta);
- menu1vs1.setItem(8, pvpcheat);
- ItemStack oneshot = new ItemStack(Material.BOW);
- oneshot.addEnchantment(Enchantment.ARROW_INFINITE, 1);
- ItemMeta oneshotMeta = oneshot.getItemMeta();
- oneshotMeta.setDisplayName("§bOne Shot §7(1vs1)");
- oneshot.setItemMeta(oneshotMeta);
- menu1vs1.setItem(9, oneshot);
- ItemStack mortsubite = new ItemStack(Material.IRON_SWORD);
- mortsubite.addEnchantment(Enchantment.DAMAGE_ALL, 1);
- ItemMeta mortsubiteMeta = mortsubite.getItemMeta();
- mortsubiteMeta.setDisplayName("§bMort Subite §7(1vs1)");
- mortsubite.setItemMeta(mortsubiteMeta);
- menu1vs1.setItem(10, mortsubite);
- p.openInventory(menu1vs1);
- }
- public void menu2vs2(Player p) {
- /*
- * Menu du 2vs2
- */
- Inventory menu2vs2 = Bukkit.createInventory(null, 27, "");
- ItemStack bowpvp = new ItemStack(Material.BOW);
- ItemMeta bowpvpMeta = bowpvp.getItemMeta();
- bowpvpMeta.setDisplayName("§bBowPvP §7(2vs2)");
- bowpvp.setItemMeta(bowpvpMeta);
- menu2vs2.setItem(0, bowpvp);
- ItemStack axepvp = new ItemStack(Material.IRON_AXE);
- ItemMeta axepvpMeta = axepvp.getItemMeta();
- axepvpMeta.setDisplayName("§bAxe PvP §7(2vs2)");
- axepvp.setItemMeta(axepvpMeta);
- menu2vs2.setItem(1, axepvp);
- ItemStack ironpvp = new ItemStack(Material.IRON_CHESTPLATE);
- ironpvp.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2);
- ItemMeta ironpvpMeta = ironpvp.getItemMeta();
- ironpvpMeta.setDisplayName("§bIron PvP §7(2vs2)");
- ironpvp.setItemMeta(ironpvpMeta);
- menu2vs2.setItem(2, ironpvp);
- ItemStack ironpvpno = new ItemStack(Material.IRON_CHESTPLATE);
- ItemMeta ironpvpnoMeta = ironpvpno.getItemMeta();
- ironpvpnoMeta.setDisplayName("§bIron PvP (No Enchant) §7(2vs2)");
- ironpvpno.setItemMeta(ironpvpnoMeta);
- menu2vs2.setItem(3, ironpvpno);
- ItemStack diamondpvp = new ItemStack(Material.DIAMOND_CHESTPLATE);
- diamondpvp.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
- ItemMeta diamondpvpMeta = diamondpvp.getItemMeta();
- diamondpvpMeta.setDisplayName("§bDiamond PvP §7(2vs2)");
- diamondpvp.setItemMeta(diamondpvpMeta);
- menu2vs2.setItem(4, diamondpvp);
- ItemStack diamondpvpno = new ItemStack(Material.DIAMOND_CHESTPLATE);
- ItemMeta diamondpvpnoMeta = diamondpvpno.getItemMeta();
- diamondpvpnoMeta.setDisplayName("§bDiamond PvP (No Enchant) §7(2vs2)");
- diamondpvpno.setItemMeta(diamondpvpnoMeta);
- menu2vs2.setItem(5, diamondpvpno);
- ItemStack diamondcheat = new ItemStack(Material.DIAMOND_SWORD);
- diamondcheat.addEnchantment(Enchantment.DAMAGE_ALL, 2);
- ItemMeta diamondcheatMeta = diamondcheat.getItemMeta();
- diamondcheatMeta.setDisplayName("§bDiamond Cheat §7(2vs2)");
- diamondcheat.setItemMeta(diamondcheatMeta);
- menu2vs2.setItem(6, diamondcheat);
- ItemStack ironcheat = new ItemStack(Material.IRON_SWORD);
- ironcheat.addEnchantment(Enchantment.DAMAGE_ALL, 2);
- ItemMeta ironcheatMeta = ironcheat.getItemMeta();
- ironcheatMeta.setDisplayName("§bIron Cheat §7(2vs2)");
- ironcheat.setItemMeta(ironcheatMeta);
- menu2vs2.setItem(7, ironcheat);
- ItemStack pvpcheat = new ItemStack(Material.DIAMOND_BLOCK);
- ItemMeta pvpcheatMeta = pvpcheat.getItemMeta();
- pvpcheatMeta.setDisplayName("§bIron Cheat §7(2vs2)");
- pvpcheat.setItemMeta(pvpcheatMeta);
- menu2vs2.setItem(8, pvpcheat);
- ItemStack oneshot = new ItemStack(Material.BOW);
- oneshot.addEnchantment(Enchantment.ARROW_INFINITE, 1);
- ItemMeta oneshotMeta = oneshot.getItemMeta();
- oneshotMeta.setDisplayName("§bOne Shot §7(2vs2)");
- oneshot.setItemMeta(oneshotMeta);
- menu2vs2.setItem(9, oneshot);
- ItemStack mortsubite = new ItemStack(Material.IRON_SWORD);
- mortsubite.addEnchantment(Enchantment.DAMAGE_ALL, 1);
- ItemMeta mortsubiteMeta = mortsubite.getItemMeta();
- mortsubiteMeta.setDisplayName("§bMort Subite §7(2vs2)");
- mortsubite.setItemMeta(mortsubiteMeta);
- menu2vs2.setItem(10, mortsubite);
- p.openInventory(menu2vs2);
- }
- public void menu3vs3(Player p) {
- /*
- * Menu du 3vs3
- */
- Inventory menu3vs3 = Bukkit.createInventory(null, 27, "");
- ItemStack bowpvp = new ItemStack(Material.BOW);
- ItemMeta bowpvpMeta = bowpvp.getItemMeta();
- bowpvpMeta.setDisplayName("§bBowPvP §7(3vs3)");
- bowpvp.setItemMeta(bowpvpMeta);
- menu3vs3.setItem(0, bowpvp);
- ItemStack axepvp = new ItemStack(Material.IRON_AXE);
- ItemMeta axepvpMeta = axepvp.getItemMeta();
- axepvpMeta.setDisplayName("§bAxe PvP §7(3vs3)");
- axepvp.setItemMeta(axepvpMeta);
- menu3vs3.setItem(1, axepvp);
- ItemStack ironpvp = new ItemStack(Material.IRON_CHESTPLATE);
- ironpvp.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2);
- ItemMeta ironpvpMeta = ironpvp.getItemMeta();
- ironpvpMeta.setDisplayName("§bIron PvP §7(3vs3)");
- ironpvp.setItemMeta(ironpvpMeta);
- menu3vs3.setItem(2, ironpvp);
- ItemStack ironpvpno = new ItemStack(Material.IRON_CHESTPLATE);
- ItemMeta ironpvpnoMeta = ironpvpno.getItemMeta();
- ironpvpnoMeta.setDisplayName("§bIron PvP (No Enchant) §7(3vs3)");
- ironpvpno.setItemMeta(ironpvpnoMeta);
- menu3vs3.setItem(3, ironpvpno);
- ItemStack diamondpvp = new ItemStack(Material.DIAMOND_CHESTPLATE);
- diamondpvp.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
- ItemMeta diamondpvpMeta = diamondpvp.getItemMeta();
- diamondpvpMeta.setDisplayName("§bDiamond PvP §7(3vs3)");
- diamondpvp.setItemMeta(diamondpvpMeta);
- menu3vs3.setItem(4, diamondpvp);
- ItemStack diamondpvpno = new ItemStack(Material.DIAMOND_CHESTPLATE);
- ItemMeta diamondpvpnoMeta = diamondpvpno.getItemMeta();
- diamondpvpnoMeta.setDisplayName("§bDiamond PvP (No Enchant) §7(3vs3)");
- diamondpvpno.setItemMeta(diamondpvpnoMeta);
- menu3vs3.setItem(5, diamondpvpno);
- ItemStack diamondcheat = new ItemStack(Material.DIAMOND_SWORD);
- diamondcheat.addEnchantment(Enchantment.DAMAGE_ALL, 2);
- ItemMeta diamondcheatMeta = diamondcheat.getItemMeta();
- diamondcheatMeta.setDisplayName("§bDiamond Cheat §7(3vs3)");
- diamondcheat.setItemMeta(diamondcheatMeta);
- menu3vs3.setItem(6, diamondcheat);
- ItemStack ironcheat = new ItemStack(Material.IRON_SWORD);
- ironcheat.addEnchantment(Enchantment.DAMAGE_ALL, 2);
- ItemMeta ironcheatMeta = ironcheat.getItemMeta();
- ironcheatMeta.setDisplayName("§bIron Cheat §7(3vs3)");
- ironcheat.setItemMeta(ironcheatMeta);
- menu3vs3.setItem(7, ironcheat);
- ItemStack pvpcheat = new ItemStack(Material.DIAMOND_BLOCK);
- ItemMeta pvpcheatMeta = pvpcheat.getItemMeta();
- pvpcheatMeta.setDisplayName("§bIron Cheat §7(3vs3)");
- pvpcheat.setItemMeta(pvpcheatMeta);
- menu3vs3.setItem(8, pvpcheat);
- ItemStack oneshot = new ItemStack(Material.BOW);
- oneshot.addEnchantment(Enchantment.ARROW_INFINITE, 1);
- ItemMeta oneshotMeta = oneshot.getItemMeta();
- oneshotMeta.setDisplayName("§bOne Shot §7(3vs3)");
- oneshot.setItemMeta(oneshotMeta);
- menu3vs3.setItem(9, oneshot);
- ItemStack mortsubite = new ItemStack(Material.IRON_SWORD);
- mortsubite.addEnchantment(Enchantment.DAMAGE_ALL, 1);
- ItemMeta mortsubiteMeta = mortsubite.getItemMeta();
- mortsubiteMeta.setDisplayName("§bMort Subite §7(3vs3)");
- mortsubite.setItemMeta(mortsubiteMeta);
- menu3vs3.setItem(10, mortsubite);
- p.openInventory(menu3vs3);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement