Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package me.Afro_.SpecialArrows;
- import org.bukkit.Bukkit;
- import org.bukkit.ChatColor;
- import org.bukkit.Location;
- import org.bukkit.Material;
- import org.bukkit.entity.Arrow;
- import org.bukkit.entity.Entity;
- import org.bukkit.entity.Monster;
- import org.bukkit.entity.Player;
- import org.bukkit.entity.Projectile;
- import org.bukkit.event.EventHandler;
- import org.bukkit.event.Listener;
- import org.bukkit.event.entity.ProjectileHitEvent;
- import org.bukkit.event.inventory.InventoryClickEvent;
- import org.bukkit.inventory.Inventory;
- import org.bukkit.inventory.ItemStack;
- import org.bukkit.inventory.meta.ItemMeta;
- import org.bukkit.potion.PotionEffect;
- import org.bukkit.potion.PotionEffectType;
- public class Listen implements Listener {
- Inventory inv = Bukkit.getServer().createInventory(null, 18,
- ChatColor.BLUE + "Arrow Effect Toggler");
- public void openGUI(Player player) {
- ItemStack explodei = new ItemStack(Material.TNT);
- ItemMeta explodeiMeta = explodei.getItemMeta();
- ItemStack lightningi = new ItemStack(Material.GOLD_AXE);
- ItemMeta lightningiMeta = lightningi.getItemMeta();
- ItemStack teleporti = new ItemStack(Material.ENDER_PEARL);
- ItemMeta teleportiMeta = teleporti.getItemMeta();
- ItemStack radiatei = new ItemStack(Material.ROTTEN_FLESH);
- ItemMeta radiateiMeta = radiatei.getItemMeta();
- ItemStack torchi = new ItemStack(Material.TORCH);
- ItemMeta torchiMeta = torchi.getItemMeta();
- explodeiMeta.setDisplayName(ChatColor.RED + "Explode");
- explodei.setItemMeta(explodeiMeta);
- lightningiMeta.setDisplayName(ChatColor.GOLD + "Lightning");
- lightningi.setItemMeta(lightningiMeta);
- teleportiMeta.setDisplayName(ChatColor.LIGHT_PURPLE + "Teleport");
- teleporti.setItemMeta(teleportiMeta);
- radiateiMeta.setDisplayName(ChatColor.DARK_GREEN + "Radiate");
- radiatei.setItemMeta(radiateiMeta);
- torchiMeta.setDisplayName(ChatColor.YELLOW + "Torch");
- torchi.setItemMeta(torchiMeta);
- // -2-4-6-8-
- inv.setItem(1, explodei);
- inv.setItem(3, lightningi);
- inv.setItem(5, teleporti);
- inv.setItem(7, radiatei);
- inv.setItem(13, torchi);
- player.openInventory(inv);
- }
- @EventHandler
- public void p(ProjectileHitEvent e) {
- Projectile proj = e.getEntity();
- Arrow arrow = (Arrow) proj;
- final Player p = (Player) arrow.getShooter();
- if (proj instanceof Arrow) {
- if (arrow.getShooter() instanceof Player) {
- if (Main.explode.contains(p.getName())) {
- if (p.hasPermission("specialarrows.explode")) {
- if (Main.cooldown.contains(p.getName())) {
- p.sendMessage(ChatColor.RED
- + "You must wait before using an effect again.");
- return;
- }
- arrow.getWorld()
- .createExplosion(arrow.getLocation(), 5);
- Main.cooldown.add(p.getName());
- Bukkit.getServer().getScheduler()
- .scheduleSyncDelayedTask(plugin, new Runnable() {
- public void run() {
- Main.cooldown.remove(p.getName());
- }
- }, 120);
- }
- }
- if (Main.lightning.contains(p.getName())) {
- if (p.hasPermission("specialarrows.lightning")) {
- if (Main.cooldown.contains(p.getName())) {
- p.sendMessage(ChatColor.RED
- + "You must wait before using an effect again.");
- return;
- }
- arrow.getWorld().strikeLightning(arrow.getLocation());
- Main.cooldown.add(p.getName());
- Bukkit.getServer().getScheduler()
- .scheduleSyncDelayedTask(plugin, new Runnable() {
- public void run() {
- Main.cooldown.remove(p.getName());
- }
- }, 120);
- }
- }
- if (Main.teleport.contains(p.getName())) {
- if (p.hasPermission("specialarrows.teleport")) {
- if (Main.cooldown.contains(p.getName())) {
- p.sendMessage(ChatColor.RED
- + "You must wait before using an effect again.");
- return;
- }
- p.teleport(arrow.getLocation());
- p.sendMessage(ChatColor.BLUE
- + "You have been teleported!");
- Main.cooldown.add(p.getName());
- Bukkit.getServer().getScheduler()
- .scheduleSyncDelayedTask(plugin, new Runnable() {
- public void run() {
- Main.cooldown.remove(p.getName());
- }
- }, 120);
- // 20 ticks = 1 second
- }
- }
- if (Main.radiate.contains(p.getName())) {
- if (p.hasPermission("specialarrows.radiate")) {
- if (Main.cooldown.contains(p.getName())) {
- p.sendMessage(ChatColor.RED
- + "You must wait before using an effect again.");
- return;
- }
- for (Entity en : arrow.getNearbyEntities(5, 5, 5)) {
- if (en instanceof Player || en instanceof Monster) {
- ((Player) en).addPotionEffect(new PotionEffect(
- PotionEffectType.POISON, 200, 1));
- ((Monster) en)
- .addPotionEffect(new PotionEffect(
- PotionEffectType.POISON, 200, 1));
- ParticleEffect.SMOKE_LARGE.display(0, 0, 0, 5, 30, arrow.getLocation(), 10);
- Main.cooldown.add(p.getName());
- Bukkit.getServer()
- .getScheduler()
- .scheduleSyncDelayedTask(plugin,
- new Runnable() {
- public void run() {
- Main.cooldown.remove(p
- .getName());
- }
- }, 120);
- }
- }
- }
- }
- if (Main.torch.contains(p.getName())) {
- if (p.hasPermission("specialarrows.torch")) {
- if (Main.cooldown.contains(p.getName())) {
- p.sendMessage(ChatColor.RED
- + "You must wait before using an effect again.");
- return;
- }
- Location loc = arrow.getLocation();
- loc.getBlock().setType(Material.TORCH);
- Bukkit.getServer().getScheduler()
- .scheduleSyncDelayedTask(plugin, new Runnable() {
- public void run() {
- Main.cooldown.remove(p.getName());
- }
- }, 240);
- }
- }
- }
- }
- }
- @EventHandler
- public void onInventoryClick(InventoryClickEvent e) {
- if (!e.getInventory().equals(inv))
- return;
- else
- e.setCancelled(true);
- if (e.getCurrentItem().getItemMeta().getDisplayName()
- .contains("Explode")) {
- if (Main.lightning.contains(e.getWhoClicked().getName())
- || Main.teleport.contains(e.getWhoClicked().getName())
- || Main.radiate.contains(e.getWhoClicked().getName())
- || Main.torch.contains(e.getWhoClicked().getName())) {
- e.getWhoClicked().sendMessage(
- ChatColor.RED
- + "You can only have one toggled at a time!");
- } else if (!Main.explode.contains(e.getWhoClicked().getName())) {
- Main.explode.add(e.getWhoClicked().getName());
- e.getWhoClicked()
- .sendMessage(
- ChatColor.GREEN
- + "Exploding arrows have been enabled!");
- } else {
- Main.explode.remove(e.getWhoClicked().getName());
- e.getWhoClicked().sendMessage(
- ChatColor.RED + "Exploding arrows have been disabled.");
- }
- }
- if (e.getCurrentItem().getItemMeta().getDisplayName()
- .contains("Lightning")) {
- if (Main.teleport.contains(e.getWhoClicked().getName())
- || Main.explode.contains(e.getWhoClicked().getName())
- || Main.radiate.contains(e.getWhoClicked().getName())
- || Main.torch.contains(e.getWhoClicked().getName())) {
- e.getWhoClicked().sendMessage(
- ChatColor.RED
- + "You can only have one toggled at a time!");
- } else if (!Main.lightning.contains(e.getWhoClicked().getName())) {
- Main.lightning.add(e.getWhoClicked().getName());
- e.getWhoClicked()
- .sendMessage(
- ChatColor.GREEN
- + "Lightning arrows have been enabled!");
- } else {
- Main.lightning.remove(e.getWhoClicked().getName());
- e.getWhoClicked().sendMessage(
- ChatColor.RED + "Lightning arrows have been disabled.");
- }
- }
- if (e.getCurrentItem().getItemMeta().getDisplayName()
- .contains("Teleport")) {
- if (Main.lightning.contains(e.getWhoClicked().getName())
- || Main.explode.contains(e.getWhoClicked().getName())
- || Main.radiate.contains(e.getWhoClicked().getName())
- || Main.torch.contains(e.getWhoClicked().getName())) {
- e.getWhoClicked().sendMessage(
- ChatColor.RED
- + "You can only have one toggled at a time!");
- } else if (!Main.teleport.contains(e.getWhoClicked().getName())) {
- Main.teleport.add(e.getWhoClicked().getName());
- e.getWhoClicked().sendMessage(
- ChatColor.GREEN
- + "Teleporting arrows have been enabled!");
- } else {
- Main.teleport.remove(e.getWhoClicked().getName());
- e.getWhoClicked().sendMessage(
- ChatColor.RED
- + "Teleporting arrows have been disabled.");
- }
- }
- if (e.getCurrentItem().getItemMeta().getDisplayName()
- .contains("Radiate")) {
- if (Main.teleport.contains(e.getWhoClicked().getName())
- || Main.explode.contains(e.getWhoClicked().getName())
- || Main.lightning.contains(e.getWhoClicked().getName())
- || Main.torch.contains(e.getWhoClicked().getName())) {
- e.getWhoClicked().sendMessage(
- ChatColor.RED
- + "You can only have one toggled at a time!");
- } else if (!Main.radiate.contains(e.getWhoClicked().getName())) {
- Main.radiate.add(e.getWhoClicked().getName());
- e.getWhoClicked().sendMessage(
- ChatColor.GREEN + "Radiate arrows have been enabled!");
- } else {
- Main.radiate.remove(e.getWhoClicked().getName());
- e.getWhoClicked().sendMessage(
- ChatColor.RED + "Radiate arrows have been disabled.");
- }
- }
- if (e.getCurrentItem().getItemMeta().getDisplayName().contains("Torch")) {
- if (Main.teleport.contains(e.getWhoClicked().getName())
- || Main.explode.contains(e.getWhoClicked().getName())
- || Main.lightning.contains(e.getWhoClicked().getName())
- || Main.radiate.contains(e.getWhoClicked().getName())) {
- e.getWhoClicked().sendMessage(
- ChatColor.RED
- + "You can only have one toggled at a time!");
- } else if (!Main.torch.contains(e.getWhoClicked().getName())) {
- Main.torch.add(e.getWhoClicked().getName());
- e.getWhoClicked().sendMessage(
- ChatColor.GREEN + "Torch arrows have been enabled!");
- } else {
- Main.torch.remove(e.getWhoClicked().getName());
- e.getWhoClicked().sendMessage(
- ChatColor.RED + "Torch arrows have been disabled.");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement