Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* 1: */ package com.tips48.kits.kits.impl;
- /* 2: */
- /* 3: */ import com.tips48.kits.kits.Kit;
- /* 4: */ import java.util.Random;
- /* 5: */ import org.bukkit.Material;
- /* 6: */ import org.bukkit.Server;
- /* 7: */ import org.bukkit.block.Block;
- /* 8: */ import org.bukkit.block.BlockFace;
- /* 9: */ import org.bukkit.enchantments.Enchantment;
- /* 10: */ import org.bukkit.entity.Entity;
- /* 11: */ import org.bukkit.entity.LivingEntity;
- /* 12: */ import org.bukkit.entity.Player;
- /* 13: */ import org.bukkit.event.EventHandler;
- /* 14: */ import org.bukkit.event.block.Action;
- /* 15: */ import org.bukkit.event.entity.EntityDamageByEntityEvent;
- /* 16: */ import org.bukkit.event.player.PlayerInteractEvent;
- /* 17: */ import org.bukkit.inventory.ItemStack;
- /* 18: */ import org.bukkit.plugin.Plugin;
- /* 19: */ import org.bukkit.potion.PotionEffect;
- /* 20: */ import org.bukkit.potion.PotionEffectType;
- /* 21: */ import org.bukkit.scheduler.BukkitScheduler;
- /* 22: */
- /* 23: */ public class Spider
- /* 24: */ extends Kit
- /* 25: */ {
- /* 26: 26 */ private static final Random random = new Random();
- /* 27: 28 */ private static final ItemStack[] armorSlots = { new ItemStack(Material.LEATHER_BOOTS, 1), new ItemStack(Material.LEATHER_LEGGINGS, 1), new ItemStack(Material.IRON_CHESTPLATE, 1), new ItemStack(Material.LEATHER_HELMET, 1) };
- /* 28: */ private final ItemStack stoneAxe;
- /* 29: */ private Block spiderWeb;
- /* 30: */
- /* 31: */ public Spider(Plugin plugin, String playerName)
- /* 32: */ {
- /* 33: 38 */ super(plugin, playerName);
- /* 34: */
- /* 35: 40 */ this.stoneAxe = new ItemStack(Material.STONE_AXE, 1);
- /* 36: 41 */ this.stoneAxe.addEnchantment(Enchantment.DAMAGE_ALL, 1);
- /* 37: */
- /* 38: 43 */ this.spiderWeb = null;
- /* 39: */ }
- /* 40: */
- /* 41: */ public String getName()
- /* 42: */ {
- /* 43: 48 */ return "Spider";
- /* 44: */ }
- /* 45: */
- /* 46: */ public ItemStack[] getArmorSlots()
- /* 47: */ {
- /* 48: 53 */ return armorSlots;
- /* 49: */ }
- /* 50: */
- /* 51: */ public ItemStack[] getInventory()
- /* 52: */ {
- /* 53: 58 */ return new ItemStack[] { this.stoneAxe };
- /* 54: */ }
- /* 55: */
- /* 56: */ @EventHandler
- /* 57: */ public void handle(EntityDamageByEntityEvent event)
- /* 58: */ {
- /* 59: 65 */ Entity entity = event.getDamager();
- /* 60: 66 */ if (!(entity instanceof Player)) {
- /* 61: 67 */ return;
- /* 62: */ }
- /* 63: 70 */ Player player = (Player)entity;
- /* 64: 71 */ if (!player.getName().equalsIgnoreCase(this.playerName)) {
- /* 65: 72 */ return;
- /* 66: */ }
- /* 67: 75 */ ItemStack hand = player.getItemInHand();
- /* 68: 76 */ if (hand.getType() != Material.STONE_AXE) {
- /* 69: 77 */ return;
- /* 70: */ }
- /* 71: 80 */ if (random.nextInt(5) == 0)
- /* 72: */ {
- /* 73: 81 */ Entity damaged = event.getEntity();
- /* 74: 82 */ if (!(damaged instanceof LivingEntity)) {
- /* 75: 83 */ return;
- /* 76: */ }
- /* 77: 85 */ LivingEntity living = (LivingEntity)damaged;
- /* 78: 86 */ PotionEffect effect = new PotionEffect(PotionEffectType.POISON, 100, 1);
- /* 79: 87 */ living.addPotionEffect(effect);
- /* 80: */ }
- /* 81: */ }
- /* 82: */
- /* 83: */ @EventHandler
- /* 84: */ public void handle(PlayerInteractEvent event)
- /* 85: */ {
- /* 86: 93 */ Action action = event.getAction();
- /* 87: 94 */ if (action != Action.RIGHT_CLICK_BLOCK) {
- /* 88: 95 */ return;
- /* 89: */ }
- /* 90: 98 */ Player player = event.getPlayer();
- /* 91: 99 */ if (!player.getName().equalsIgnoreCase(this.playerName)) {
- /* 92:100 */ return;
- /* 93: */ }
- /* 94:103 */ if (this.spiderWeb != null) {
- /* 95:104 */ return;
- /* 96: */ }
- /* 97:107 */ this.spiderWeb = event.getClickedBlock().getRelative(BlockFace.UP);
- /* 98:108 */ this.spiderWeb.setType(Material.WEB);
- /* 99: */
- /* 100:110 */ SpiderWebRunnable runnable = new SpiderWebRunnable(null);
- /* 101:111 */ this.plugin.getServer().getScheduler().scheduleSyncDelayedTask(this.plugin, runnable, 60L);
- /* 102: */ }
- /* 103: */
- /* 104: */ private class SpiderWebRunnable
- /* 105: */ implements Runnable
- /* 106: */ {
- /* 107: */ private SpiderWebRunnable() {}
- /* 108: */
- /* 109: */ public void run()
- /* 110: */ {
- /* 111:118 */ if (Spider.this.spiderWeb == null) {
- /* 112:119 */ return;
- /* 113: */ }
- /* 114:122 */ if (Spider.this.spiderWeb.getType() == Material.WEB) {
- /* 115:123 */ Spider.this.spiderWeb.setType(Material.AIR);
- /* 116: */ }
- /* 117:125 */ Spider.this.spiderWeb = null;
- /* 118: */ }
- /* 119: */ }
- /* 120: */ }
Advertisement
Add Comment
Please, Sign In to add comment