Advertisement
Guest User

Untitled

a guest
Feb 9th, 2016
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 207.77 KB | None | 0 0
  1. package com.shampaggon.crackshot;
  2.  
  3. import com.shampaggon.crackshot.events.WeaponAttachmentEvent;
  4. import com.shampaggon.crackshot.events.WeaponAttachmentToggleEvent;
  5. import com.shampaggon.crackshot.events.WeaponCapacityEvent;
  6. import com.shampaggon.crackshot.events.WeaponDamageEntityEvent;
  7. import com.shampaggon.crackshot.events.WeaponDualWieldEvent;
  8. import com.shampaggon.crackshot.events.WeaponExplodeEvent;
  9. import com.shampaggon.crackshot.events.WeaponFireRateEvent;
  10. import com.shampaggon.crackshot.events.WeaponHitBlockEvent;
  11. import com.shampaggon.crackshot.events.WeaponPlaceMineEvent;
  12. import com.shampaggon.crackshot.events.WeaponPreShootEvent;
  13. import com.shampaggon.crackshot.events.WeaponReloadCompleteEvent;
  14. import com.shampaggon.crackshot.events.WeaponReloadEvent;
  15. import com.shampaggon.crackshot.events.WeaponScopeEvent;
  16. import com.shampaggon.crackshot.events.WeaponShootEvent;
  17. import com.shampaggon.crackshot.events.WeaponTriggerEvent;
  18. import java.io.PrintStream;
  19. import java.util.ArrayDeque;
  20. import java.util.ArrayList;
  21. import java.util.Collection;
  22. import java.util.HashMap;
  23. import java.util.HashSet;
  24. import java.util.Iterator;
  25. import java.util.List;
  26. import java.util.Map;
  27. import java.util.Random;
  28. import java.util.Set;
  29. import java.util.UUID;
  30. import java.util.regex.Matcher;
  31. import java.util.regex.Pattern;
  32. import org.bukkit.Bukkit;
  33. import org.bukkit.ChatColor;
  34. import org.bukkit.Effect;
  35. import org.bukkit.EntityEffect;
  36. import org.bukkit.GameMode;
  37. import org.bukkit.Location;
  38. import org.bukkit.Material;
  39. import org.bukkit.Server;
  40. import org.bukkit.SkullType;
  41. import org.bukkit.Sound;
  42. import org.bukkit.World;
  43. import org.bukkit.block.Block;
  44. import org.bukkit.block.BlockFace;
  45. import org.bukkit.block.BlockState;
  46. import org.bukkit.block.Chest;
  47. import org.bukkit.block.DoubleChest;
  48. import org.bukkit.block.Sign;
  49. import org.bukkit.block.Skull;
  50. import org.bukkit.command.Command;
  51. import org.bukkit.command.CommandSender;
  52. import org.bukkit.configuration.file.FileConfiguration;
  53. import org.bukkit.enchantments.Enchantment;
  54. import org.bukkit.entity.Ageable;
  55. import org.bukkit.entity.AnimalTamer;
  56. import org.bukkit.entity.Arrow;
  57. import org.bukkit.entity.Creeper;
  58. import org.bukkit.entity.Egg;
  59. import org.bukkit.entity.Entity;
  60. import org.bukkit.entity.EntityType;
  61. import org.bukkit.entity.ExperienceOrb;
  62. import org.bukkit.entity.FallingBlock;
  63. import org.bukkit.entity.Horse;
  64. import org.bukkit.entity.Item;
  65. import org.bukkit.entity.ItemFrame;
  66. import org.bukkit.entity.LargeFireball;
  67. import org.bukkit.entity.LivingEntity;
  68. import org.bukkit.entity.Minecart;
  69. import org.bukkit.entity.Painting;
  70. import org.bukkit.entity.Player;
  71. import org.bukkit.entity.Projectile;
  72. import org.bukkit.entity.Skeleton;
  73. import org.bukkit.entity.Skeleton.SkeletonType;
  74. import org.bukkit.entity.Snowball;
  75. import org.bukkit.entity.TNTPrimed;
  76. import org.bukkit.entity.ThrownPotion;
  77. import org.bukkit.entity.Vehicle;
  78. import org.bukkit.entity.Villager;
  79. import org.bukkit.entity.WitherSkull;
  80. import org.bukkit.entity.Wolf;
  81. import org.bukkit.entity.Zombie;
  82. import org.bukkit.event.EventHandler;
  83. import org.bukkit.event.EventPriority;
  84. import org.bukkit.event.Listener;
  85. import org.bukkit.event.block.Action;
  86. import org.bukkit.event.block.BlockBreakEvent;
  87. import org.bukkit.event.block.BlockDispenseEvent;
  88. import org.bukkit.event.block.BlockFromToEvent;
  89. import org.bukkit.event.block.BlockPlaceEvent;
  90. import org.bukkit.event.block.SignChangeEvent;
  91. import org.bukkit.event.entity.EntityChangeBlockEvent;
  92. import org.bukkit.event.entity.EntityDamageByEntityEvent;
  93. import org.bukkit.event.entity.EntityDamageEvent;
  94. import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
  95. import org.bukkit.event.entity.EntityDeathEvent;
  96. import org.bukkit.event.entity.EntityExplodeEvent;
  97. import org.bukkit.event.entity.EntityInteractEvent;
  98. import org.bukkit.event.entity.EntityShootBowEvent;
  99. import org.bukkit.event.entity.ItemDespawnEvent;
  100. import org.bukkit.event.entity.ItemSpawnEvent;
  101. import org.bukkit.event.entity.PlayerDeathEvent;
  102. import org.bukkit.event.entity.PotionSplashEvent;
  103. import org.bukkit.event.entity.ProjectileHitEvent;
  104. import org.bukkit.event.inventory.CraftItemEvent;
  105. import org.bukkit.event.inventory.InventoryClickEvent;
  106. import org.bukkit.event.inventory.InventoryOpenEvent;
  107. import org.bukkit.event.inventory.InventoryPickupItemEvent;
  108. import org.bukkit.event.inventory.InventoryType;
  109. import org.bukkit.event.inventory.InventoryType.SlotType;
  110. import org.bukkit.event.player.PlayerDropItemEvent;
  111. import org.bukkit.event.player.PlayerEggThrowEvent;
  112. import org.bukkit.event.player.PlayerInteractEntityEvent;
  113. import org.bukkit.event.player.PlayerInteractEvent;
  114. import org.bukkit.event.player.PlayerItemHeldEvent;
  115. import org.bukkit.event.player.PlayerPickupItemEvent;
  116. import org.bukkit.event.player.PlayerQuitEvent;
  117. import org.bukkit.event.vehicle.VehicleDamageEvent;
  118. import org.bukkit.event.vehicle.VehicleEnterEvent;
  119. import org.bukkit.event.vehicle.VehicleEntityCollisionEvent;
  120. import org.bukkit.inventory.DoubleChestInventory;
  121. import org.bukkit.inventory.Inventory;
  122. import org.bukkit.inventory.ItemStack;
  123. import org.bukkit.inventory.PlayerInventory;
  124. import org.bukkit.inventory.Recipe;
  125. import org.bukkit.inventory.meta.ItemMeta;
  126. import org.bukkit.inventory.meta.SkullMeta;
  127. import org.bukkit.material.Dispenser;
  128. import org.bukkit.material.MaterialData;
  129. import org.bukkit.metadata.FixedMetadataValue;
  130. import org.bukkit.metadata.MetadataValue;
  131. import org.bukkit.permissions.PermissionAttachment;
  132. import org.bukkit.plugin.PluginManager;
  133. import org.bukkit.plugin.java.JavaPlugin;
  134. import org.bukkit.potion.PotionEffect;
  135. import org.bukkit.potion.PotionEffectType;
  136. import org.bukkit.scheduler.BukkitScheduler;
  137. import org.bukkit.util.BlockIterator;
  138. import org.bukkit.util.Vector;
  139.  
  140. public class CSDirector
  141.   extends JavaPlugin
  142.   implements Listener
  143. {
  144.   public Map<String, int[]> zoomStorage = new HashMap();
  145.   public Map<String, Collection<Integer>> burst_task_IDs = new HashMap();
  146.   public Map<String, Collection<Integer>> global_reload_IDs = new HashMap();
  147.   public Map<String, Set<String>> grouplist = new HashMap();
  148.   public Map<String, Boolean> morobust = new HashMap();
  149.   public FileConfiguration weaponConfig = null;
  150.   public Set<String> melees = new HashSet();
  151.   public CSDirector plugin = this;
  152.   public Map<String, Integer> rpm_ticks = new HashMap();
  153.   public Map<String, Integer> rpm_shots = new HashMap();
  154.   public Map<String, Map<Integer, Long>> last_shot_list = new HashMap();
  155.   public Map<String, Map<String, String>> c4_backup = new HashMap();
  156.   public Map<String, Integer> delayed_reload_IDs = new HashMap();
  157.   public Map<String, Map<String, Integer>> delay_list = new HashMap();
  158.   public Map<String, Map<String, ArrayDeque<Item>>> itembombs = new HashMap();
  159.   public Map<String, String> convIDs = new HashMap();
  160.   public Map<String, String[]> enchlist = new HashMap();
  161.   public Map<String, String> parentlist = new HashMap();
  162.   public Map<String, String> rdelist = new HashMap();
  163.   public Map<Integer, String> wlist = new HashMap();
  164.   public Map<String, String> boobs = new HashMap();
  165.   public static Map<String, Integer> ints = new HashMap();
  166.   public static Map<String, Double> dubs = new HashMap();
  167.   public static Map<String, Boolean> bools = new HashMap();
  168.   public static Map<String, String> strings = new HashMap();
  169.   public String[] disWorlds = { "0" };
  170.   public String heading = "�7? �c[-�l��c��lc�7�ls�7] �c- �7";
  171.   public String version = "0.98.5";
  172.   public final CSMinion csminion = new CSMinion(this);
  173.  
  174.   public void onEnable()
  175.   {
  176.     try
  177.     {
  178.       Class.forName("org.bukkit.projectiles.ProjectileSource");
  179.     }
  180.     catch (ClassNotFoundException e)
  181.     {
  182.       printM("Failed to load. Your version of CraftBukkit is outdated!");
  183.       setEnabled(false);
  184.       return;
  185.     }
  186.     this.csminion.loadWeapons(null);
  187.     this.csminion.loadGeneralConfig();
  188.     this.csminion.loadMessagesConfig();
  189.     this.csminion.customRecipes();
  190.     printM("Gun-mode activated. Boop!");
  191.     Bukkit.getPluginManager().registerEvents(this, this);
  192.   }
  193.  
  194.   public void onDisable()
  195.   {
  196.     Bukkit.getScheduler().cancelTasks(this);
  197.     Object localObject1;
  198.     int j = (localObject1 = Bukkit.getServer().getOnlinePlayers()).length;
  199.     for (int i = 0; i < j; i++)
  200.     {
  201.       Player player = localObject1[i];
  202.       removeInertReloadTag(player, 0, true);
  203.       unscopePlayer(player, new boolean[0]);
  204.       terminateAllBursts(player);
  205.       terminateReload(player);
  206.     }
  207.     for (Iterator localIterator = this.itembombs.values().iterator(); localIterator.hasNext(); ((Iterator)localObject1).hasNext())
  208.     {
  209.       Map<String, ArrayDeque<Item>> subList = (Map)localIterator.next();
  210.       localObject1 = subList.values().iterator(); continue;Object subSubList = (ArrayDeque)((Iterator)localObject1).next();
  211.       while (!((ArrayDeque)subSubList).isEmpty()) {
  212.         ((Item)((ArrayDeque)subSubList).removeFirst()).remove();
  213.       }
  214.     }
  215.     this.zoomStorage.clear();
  216.     this.burst_task_IDs.clear();
  217.     this.global_reload_IDs.clear();
  218.     bools.clear();
  219.     ints.clear();
  220.     strings.clear();
  221.     this.morobust.clear();
  222.     this.wlist.clear();
  223.     this.rdelist.clear();
  224.     this.boobs.clear();
  225.     dubs.clear();
  226.     this.grouplist.clear();
  227.     this.melees.clear();
  228.     this.enchlist.clear();
  229.     this.convIDs.clear();
  230.     this.parentlist.clear();
  231.     this.itembombs.clear();
  232.     this.last_shot_list.clear();
  233.     this.c4_backup.clear();
  234.     this.delayed_reload_IDs.clear();
  235.     this.delay_list.clear();
  236.     this.rpm_ticks.clear();
  237.     this.rpm_shots.clear();
  238.     CSMessages.messages.clear();
  239.    
  240.     this.csminion.clearRecipes();
  241.   }
  242.  
  243.   public void fillHashMaps(FileConfiguration config)
  244.   {
  245.     for (String string : config.getKeys(true))
  246.     {
  247.       Object obj = config.get(string);
  248.       if ((obj instanceof Boolean))
  249.       {
  250.         bools.put(string, (Boolean)obj);
  251.       }
  252.       else if ((obj instanceof Integer))
  253.       {
  254.         ints.put(string, (Integer)obj);
  255.       }
  256.       else if ((obj instanceof String))
  257.       {
  258.         obj = ((String)obj).replaceAll("&", "�");
  259.         strings.put(string, (String)obj);
  260.       }
  261.     }
  262.     for (String parent_node : config.getKeys(false))
  263.     {
  264.       String[] specials = { ".Item_Information.Item_Type", ".Ammo.Ammo_Item_ID", ".Shooting.Projectile_Subtype", ".Crafting.Ingredients", ".Explosive_Devices.Device_Info", ".Airstrikes.Block_Type", ".Cluster_Bombs.Bomblet_Type", ".Shrapnel.Block_Type", ".Explosions.Damage_Multiplier" };
  265.       String[] arrayOfString1;
  266.       int j = (arrayOfString1 = specials).length;
  267.       for (int i = 0; i < j; i++)
  268.       {
  269.         String spec = arrayOfString1[i];strings.put(parent_node + spec, config.getString(parent_node + spec));
  270.       }
  271.       String[] spread = { ".Shooting.Bullet_Spread", ".Sneak.Bullet_Spread", ".Scope.Zoom_Bullet_Spread" };
  272.       String[] arrayOfString2;
  273.       int k = (arrayOfString2 = spread).length;
  274.       for (j = 0; j < k; j++)
  275.       {
  276.         String spre = arrayOfString2[j];dubs.put(parent_node + spre, Double.valueOf(config.getDouble(parent_node + spre)));
  277.       }
  278.       String invCtrl = getString(parent_node + ".Item_Information.Inventory_Control");
  279.       if (invCtrl != null)
  280.       {
  281.         String[] groups = invCtrl.replaceAll(" ", "").split(",");
  282.         String[] arrayOfString3;
  283.         int n = (arrayOfString3 = groups).length;
  284.         for (int m = 0; m < n; m++)
  285.         {
  286.           String group = arrayOfString3[m];
  287.           if (this.grouplist.containsKey(group))
  288.           {
  289.             Object list = (Set)this.grouplist.get(group);
  290.             if (!((Set)list).contains(parent_node)) {
  291.               ((Set)list).add(parent_node);
  292.             }
  293.             this.grouplist.put(group, list);
  294.           }
  295.           else
  296.           {
  297.             Object list = new HashSet();
  298.             ((Set)list).add(parent_node);
  299.             this.grouplist.put(group, list);
  300.           }
  301.         }
  302.       }
  303.       String enchantKey = getString(parent_node + ".Item_Information.Enchantment_To_Check");
  304.       if (enchantKey != null)
  305.       {
  306.         String[] enchantInfo = enchantKey.split("-");
  307.         if (enchantInfo.length == 2) {
  308.           if (Enchantment.getByName(enchantInfo[0]) == null) {
  309.             printM("For the weapon '" + parent_node + "', the value provided for 'Enchantment_To_Check' does not contain a valid enchantment type.");
  310.           } else {
  311.             try
  312.             {
  313.               Integer.valueOf(enchantInfo[1]);
  314.               this.enchlist.put(parent_node, enchantInfo);
  315.             }
  316.             catch (NumberFormatException ex)
  317.             {
  318.               printM("For the weapon '" + parent_node + "', the value provided for 'Enchantment_To_Check' does not contain a valid enchantment level.");
  319.             }
  320.           }
  321.         }
  322.       }
  323.       boolean skipName = getBoolean(parent_node + ".Item_Information.Skip_Name_Check");
  324.       if (skipName)
  325.       {
  326.         String itemInfo = getString(parent_node + ".Item_Information.Item_Type");
  327.         ItemStack item = this.csminion.parseItemStack(itemInfo);
  328.         if (item != null) {
  329.           this.convIDs.put(item.getTypeId() + "-" + item.getDurability(), parent_node);
  330.         }
  331.       }
  332.       boolean accessory = false;
  333.       String attachType = getString(parent_node + ".Item_Information.Attachments.Type");
  334.       if ((attachType != null) && (attachType.equalsIgnoreCase("accessory"))) {
  335.         accessory = true;
  336.       }
  337.       if (!accessory)
  338.       {
  339.         String it = config.getString(parent_node + ".Item_Information.Item_Type");
  340.         String itemName = config.getString(parent_node + ".Item_Information.Item_Has_Durability");
  341.         if (it == null) {
  342.           printM("The weapon '" + parent_node + "' does not have a value for Item_Type.");
  343.         } else if ((itemName == null) && (this.csminion.durabilityCheck(it))) {
  344.           this.morobust.put(parent_node, Boolean.valueOf(true));
  345.         }
  346.       }
  347.       Object commandList = config.getStringList(parent_node + ".Extras.Run_Command");
  348.       if (!((List)commandList).isEmpty())
  349.       {
  350.         String stringList = "";
  351.         String delimiter = "???";
  352.         for (int i = 0; i < ((List)commandList).size(); i++)
  353.         {
  354.           String command = ((String)((List)commandList).get(i)).trim();
  355.           if (i != 0) {
  356.             stringList = stringList + delimiter;
  357.           }
  358.           if (command.startsWith("@")) {
  359.             stringList = stringList + "@" + command.substring(1).trim();
  360.           } else {
  361.             stringList = stringList + command.trim();
  362.           }
  363.         }
  364.         strings.put(parent_node + ".Extras.Run_Command", stringList.replaceAll("&", "�"));
  365.       }
  366.       String name = config.getString(parent_node + ".Item_Information.Item_Name");
  367.       if (accessory) {
  368.         name = "�f" + parent_node;
  369.       }
  370.       if (name == null)
  371.       {
  372.         printM("The weapon '" + parent_node + "' does not have a value for Item_Name.");
  373.       }
  374.       else
  375.       {
  376.         name = name.replaceAll("&", "�");
  377.        
  378.         String colorCodes = ChatColor.getLastColors(name);
  379.         if (colorCodes.length() > 1) {
  380.           name = name + "�" + colorCodes.substring(colorCodes.length() - 1);
  381.         } else if (colorCodes.length() == 0) {
  382.           name = "�f" + name + "�f";
  383.         }
  384.         strings.put(parent_node + ".Item_Information.Item_Name", name);
  385.         if (!this.parentlist.containsKey(name)) {
  386.           this.parentlist.put(name, parent_node);
  387.         } else if (!accessory) {
  388.           printM("Each weapon must have a unique name, but two or more weapons have '" + config.getString(new StringBuilder(String.valueOf(parent_node)).append(".Item_Information.Item_Name").toString()) + "' for Item_Name! Tip: '&eWeapon' and '&eWea&epon' are different, but both look the same.");
  389.         }
  390.       }
  391.       boolean meleeMode = getBoolean(parent_node + ".Item_Information.Melee_Mode");
  392.       String meleeAttach = getString(parent_node + ".Item_Information.Melee_Attachment");
  393.       if ((meleeAttach != null) || (meleeMode) || ((attachType != null) && (attachType.equalsIgnoreCase("main")))) {
  394.         this.melees.add(parent_node);
  395.       }
  396.       if (config.getBoolean(parent_node + ".Explosive_Devices.Enable"))
  397.       {
  398.         String rdeOre = config.getString(parent_node + ".Explosive_Devices.Device_Info");
  399.         if (rdeOre != null)
  400.         {
  401.           String[] rdeRefined = rdeOre.split("-");
  402.           if (rdeRefined.length == 3) {
  403.             this.rdelist.put(rdeRefined[1], parent_node);
  404.           }
  405.         }
  406.       }
  407.       if (config.getBoolean(parent_node + ".Explosive_Devices.Enable"))
  408.       {
  409.         String rdeInfo = config.getString(parent_node + ".Explosive_Devices.Device_Type");
  410.         if ((rdeInfo != null) && (rdeInfo.equalsIgnoreCase("trap"))) {
  411.           this.boobs.put(getString(parent_node + ".Item_Information.Item_Name"), parent_node);
  412.         }
  413.       }
  414.     }
  415.   }
  416.  
  417.   public boolean onCommand(CommandSender sender, Command command, String aliasUsed, String[] args)
  418.   {
  419.     if (!command.getName().equalsIgnoreCase("crackshot")) {
  420.       return false;
  421.     }
  422.     if ((args.length == 2) &&
  423.       (args[0].equalsIgnoreCase("config")) && (args[1].equalsIgnoreCase("reload")))
  424.     {
  425.       if (((sender instanceof Player)) && (!sender.hasPermission("crackshot.reloadplugin")))
  426.       {
  427.         sender.sendMessage(this.heading + "You do not have permission to do this.");
  428.         return true;
  429.       }
  430.       this.disWorlds = new String[] { "0" };
  431.       this.csminion.clearRecipes();
  432.      
  433.       bools.clear();
  434.       ints.clear();
  435.       strings.clear();
  436.       this.morobust.clear();
  437.       this.wlist.clear();
  438.       this.rdelist.clear();
  439.       this.boobs.clear();
  440.       dubs.clear();
  441.       this.grouplist.clear();
  442.       this.melees.clear();
  443.       this.enchlist.clear();
  444.       this.convIDs.clear();
  445.       this.parentlist.clear();
  446.       CSMessages.messages.clear();
  447.      
  448.       Player cmdReloader = (sender instanceof Player) ? (Player)sender : null;
  449.       this.csminion.loadWeapons(cmdReloader);
  450.       this.csminion.loadGeneralConfig();
  451.       this.csminion.loadMessagesConfig();
  452.       this.csminion.customRecipes();
  453.       if ((sender instanceof Player)) {
  454.         sender.sendMessage(this.heading + "Configuration reloaded.");
  455.       } else {
  456.         printM("Configuration reloaded.");
  457.       }
  458.       return true;
  459.     }
  460.     if (args.length == 0)
  461.     {
  462.       if (!(sender instanceof Player))
  463.       {
  464.         sender.sendMessage("[CrackShot] Version: " + this.version);
  465.         return true;
  466.       }
  467.       sender.sendMessage("�7? �c�l------�r�c[ -�l��c�crack�7shot �c]�l------");
  468.       sender.sendMessage("�7? �cAuthor: �7Shampaggon");
  469.       sender.sendMessage("�7? �cVersion: �7" + this.version);
  470.       sender.sendMessage("�7? �cAliases: �7/shot, /cra, /cs");
  471.       sender.sendMessage("�7? �cCommands:");
  472.       sender.sendMessage("�7? �c- �7/shot list [all �lOR�r�7 <page>]");
  473.       sender.sendMessage("�7? �c- �7/shot give <user> <weapon> <#>");
  474.       sender.sendMessage("�7? �c- �7/shot get <weapon> <#>");
  475.       sender.sendMessage("�7? �c- �7/shot reload");
  476.       sender.sendMessage("�7? �c- �7/shot config reload");
  477.       return true;
  478.     }
  479.     if (((args.length == 3) || (args.length == 4)) &&
  480.       (args[0].equalsIgnoreCase("give")))
  481.     {
  482.       String prefix = this.heading;
  483.       String amount = "1";
  484.       if (!(sender instanceof Player)) {
  485.         prefix = "[CrackShot] ";
  486.       }
  487.       if (args.length == 4) {
  488.         amount = args[3];
  489.       }
  490.       String parent_node = this.csminion.identifyWeapon(args[2]);
  491.       if (parent_node == null)
  492.       {
  493.         sender.sendMessage(prefix + "No weapon matches '" + args[2] + "'.");
  494.         return false;
  495.       }
  496.       if (((sender instanceof Player)) && (!sender.hasPermission("crackshot.give." + parent_node)) && (!sender.hasPermission("crackshot.give.all")))
  497.       {
  498.         sender.sendMessage(prefix + "You do not have permission to give this item.");
  499.         return false;
  500.       }
  501.       Player receiver = Bukkit.getServer().getPlayer(args[1]);
  502.       if (receiver != null)
  503.       {
  504.         if (receiver.getInventory().firstEmpty() != -1)
  505.         {
  506.           sender.sendMessage(prefix + "Package delivered to " + receiver.getName() + ".");
  507.           this.csminion.getWeaponCommand(receiver, parent_node, false, amount, true, false);
  508.           return true;
  509.         }
  510.         sender.sendMessage(prefix + receiver.getName() + "'s inventory is full.");
  511.         return false;
  512.       }
  513.       sender.sendMessage(prefix + "No player named '" + args[1] + "' was found.");
  514.       return false;
  515.     }
  516.     if (!(sender instanceof Player))
  517.     {
  518.       sender.sendMessage("[CrackShot] Invalid command.");
  519.       return false;
  520.     }
  521.     Player player = (Player)sender;
  522.     if (((args.length == 2) || (args.length == 3)) && (args[0].equalsIgnoreCase("get")))
  523.     {
  524.       String amount = "1";
  525.       if (args.length == 3) {
  526.         amount = args[2];
  527.       }
  528.       this.csminion.getWeaponCommand(player, args[1], true, amount, false, false);
  529.       return true;
  530.     }
  531.     if (args.length == 1) {
  532.       if (args[0].equalsIgnoreCase("reload"))
  533.       {
  534.         String parent_node = returnParentNode(player);
  535.         if (parent_node == null)
  536.         {
  537.           CSMessages.sendMessage(player, this.heading, CSMessages.Message.CANNOT_RELOAD.getMessage());
  538.           return true;
  539.         }
  540.         if ((!player.hasPermission("crackshot.use." + parent_node)) && (!player.hasPermission("crackshot.use.all")))
  541.         {
  542.           CSMessages.sendMessage(player, this.heading, CSMessages.Message.NP_WEAPON_USE.getMessage());
  543.           return false;
  544.         }
  545.         reloadAnimation(player, parent_node, new boolean[0]);
  546.         return true;
  547.       }
  548.     }
  549.     if (((args.length == 1) || (args.length == 2)) && (args[0].equalsIgnoreCase("list")))
  550.     {
  551.       if (!player.hasPermission("crackshot.list"))
  552.       {
  553.         player.sendMessage(this.heading + "You do not have permission to do this.");
  554.         return false;
  555.       }
  556.       this.csminion.listWeapons(player, args);
  557.       return true;
  558.     }
  559.     player.sendMessage(this.heading + "Invalid command.");
  560.    
  561.     return false;
  562.   }
  563.  
  564.   @EventHandler
  565.   public void OnPlayerInteract(PlayerInteractEvent event)
  566.   {
  567.     boolean rightShoot;
  568.     if (event.getAction() != Action.PHYSICAL)
  569.     {
  570.       if ((event.getAction() == Action.LEFT_CLICK_BLOCK) && (event.getClickedBlock().getType() == Material.WALL_SIGN) && (shopEvent(event))) {
  571.         return;
  572.       }
  573.       if ((event.getAction() == Action.LEFT_CLICK_BLOCK) && (event.getClickedBlock().getType() == Material.SKULL) && (event.getClickedBlock().hasMetadata("CS_transformers"))) {
  574.         event.setCancelled(true);
  575.       }
  576.       Player shooter = event.getPlayer();
  577.       ItemStack item = shooter.getItemInHand();
  578.       String parent_node = returnParentNode(shooter);
  579.       if (parent_node == null) {
  580.         return;
  581.       }
  582.       if ((!getBoolean(parent_node + ".Item_Information.Melee_Mode")) && (!validHotbar(shooter, parent_node))) {
  583.         return;
  584.       }
  585.       if (!regionAndPermCheck(shooter, parent_node, false)) {
  586.         return;
  587.       }
  588.       rightShoot = getBoolean(parent_node + ".Shooting.Right_Click_To_Shoot");
  589.       boolean dualWield = isDualWield(shooter, parent_node, item);
  590.       boolean leftClick = (event.getAction() == Action.LEFT_CLICK_AIR) || (event.getAction() == Action.LEFT_CLICK_BLOCK);
  591.       boolean rightClick = (event.getAction() == Action.RIGHT_CLICK_AIR) || (event.getAction() == Action.RIGHT_CLICK_BLOCK);
  592.      
  593.       boolean rdeEnable = getBoolean(parent_node + ".Explosive_Devices.Enable");
  594.       String[] attachTypeAndInfo = getAttachment(parent_node, item);
  595.       if (attachTypeAndInfo[0] != null)
  596.       {
  597.         if ((attachTypeAndInfo[0].equalsIgnoreCase("accessory")) && (rdeEnable))
  598.         {
  599.           shooter.sendMessage(this.heading + "The weapon '" + parent_node + "' is an attachment. It cannot use the Explosive_Devices module!");
  600.           return;
  601.         }
  602.         if (dualWield)
  603.         {
  604.           shooter.sendMessage(this.heading + "The weapon '" + parent_node + "' cannot use attachments and be dual wielded at the same time!");
  605.           return;
  606.         }
  607.       }
  608.       if (event.getAction() == Action.LEFT_CLICK_BLOCK)
  609.       {
  610.         boolean noBlockDmg = getBoolean(parent_node + ".Shooting.Cancel_Left_Click_Block_Damage");
  611.         if (noBlockDmg) {
  612.           event.setCancelled(true);
  613.         }
  614.       }
  615.       if ((event.getAction() == Action.RIGHT_CLICK_AIR) || (event.getAction() == Action.RIGHT_CLICK_BLOCK))
  616.       {
  617.         boolean rightInteract = getBoolean(parent_node + ".Shooting.Cancel_Right_Click_Interactions");
  618.         if (rightInteract) {
  619.           event.setCancelled(true);
  620.         }
  621.       }
  622.       if (!item.getItemMeta().getDisplayName().contains("�"))
  623.       {
  624.         shooter.setItemInHand(this.csminion.vendingMachine(parent_node));
  625.         event.setCancelled(true);
  626.         return;
  627.       }
  628.       if (!getBoolean(parent_node + ".Item_Information.Remove_Unused_Tag")) {
  629.         checkCorruption(item, attachTypeAndInfo[0] != null, dualWield);
  630.       }
  631.       if (((rightShoot) && (rightClick)) || ((!rightShoot) && (leftClick)) || (dualWield))
  632.       {
  633.         if (rdeEnable)
  634.         {
  635.           String type = getString(parent_node + ".Explosive_Devices.Device_Type");
  636.           if (type != null) {
  637.             if ((type.equalsIgnoreCase("remote")) || (type.equalsIgnoreCase("itembomb")))
  638.             {
  639.               detonateC4(shooter, item, parent_node, type);
  640.             }
  641.             else if ((type.equalsIgnoreCase("trap")) && (itemIsSafe(item)) && (item.getItemMeta().getDisplayName().contains("�?�")))
  642.             {
  643.               String itemName = getString(parent_node + ".Item_Information.Item_Name");
  644.               this.csminion.setItemName(shooter.getInventory().getItemInHand(), itemName + " �" + shooter.getName() + "�");
  645.               playSoundEffects(shooter, parent_node, ".Explosive_Devices.Sounds_Deploy", false, null, new String[0]);
  646.             }
  647.             else if (type.equalsIgnoreCase("landmine"))
  648.             {
  649.               this.csminion.oneTime(shooter);
  650.               playSoundEffects(shooter, parent_node, ".Explosive_Devices.Sounds_Deploy", false, null, new String[0]);
  651.               deployMine(shooter, parent_node, null);
  652.             }
  653.           }
  654.         }
  655.         else if (item.getType() != Material.BOW)
  656.         {
  657.           this.csminion.weaponInteraction(shooter, parent_node, leftClick);
  658.         }
  659.       }
  660.       else if ((!dualWield) && (((rightShoot) && (leftClick)) || ((!rightShoot) && (rightClick))))
  661.       {
  662.         if (getBoolean(parent_node + ".Reload.Reload_With_Mouse"))
  663.         {
  664.           reloadAnimation(shooter, parent_node, new boolean[0]);
  665.           return;
  666.         }
  667.         if (tossBomb(shooter, parent_node, item, rdeEnable)) {
  668.           return;
  669.         }
  670.         WeaponAttachmentToggleEvent toggleEvent;
  671.         if (attachTypeAndInfo[0] != null)
  672.         {
  673.           int gunSlot = shooter.getInventory().getHeldItemSlot();
  674.           boolean hasDelay = shooter.hasMetadata("togglesnoShooting" + gunSlot);
  675.           if (hasDelay) {
  676.             return;
  677.           }
  678.           boolean main = attachTypeAndInfo[0].equalsIgnoreCase("main");
  679.           boolean accessory = attachTypeAndInfo[0].equalsIgnoreCase("accessory");
  680.           if ((main) || (accessory))
  681.           {
  682.             if (main)
  683.             {
  684.               String attachValid = getString(attachTypeAndInfo[1] + ".Item_Information.Attachments.Type");
  685.               if (attachTypeAndInfo[1] == null)
  686.               {
  687.                 shooter.sendMessage(this.heading + "The weapon '" + parent_node + "' is missing the weapon title of an attachment!");
  688.                 return;
  689.               }
  690.               if (attachValid == null)
  691.               {
  692.                 shooter.sendMessage(this.heading + "The weapon '" + parent_node + "' has an invalid attachment. The weapon '" + attachTypeAndInfo[1] + "' has to be an accessory!");
  693.                 return;
  694.               }
  695.             }
  696.             int toggleDelay = getInt(parent_node + ".Item_Information.Attachments.Toggle_Delay");
  697.            
  698.             toggleEvent = new WeaponAttachmentToggleEvent(shooter, parent_node, item, toggleDelay);
  699.             getServer().getPluginManager().callEvent(toggleEvent);
  700.             if (toggleEvent.isCancelled()) {
  701.               return;
  702.             }
  703.             playSoundEffects(shooter, parent_node, ".Item_Information.Attachments.Sounds_Toggle", false, null, new String[0]);
  704.             reloadShootDelay(shooter, parent_node, gunSlot, toggleEvent.getToggleDelay(), new String[] { "noShooting", "toggles" });
  705.            
  706.             terminateAllBursts(shooter);
  707.             terminateReload(shooter);
  708.             removeInertReloadTag(shooter, 0, true);
  709.             if (itemIsSafe(item))
  710.             {
  711.               String itemName = item.getItemMeta().getDisplayName();
  712.               String triOne = String.valueOf('?');String triTwo = String.valueOf('?');String triThree = String.valueOf('?');String triFour = String.valueOf('?');
  713.               if (itemName.contains(triThree)) {
  714.                 this.csminion.setItemName(item, itemName.replaceAll(triThree + triTwo, triFour + triOne));
  715.               } else {
  716.                 this.csminion.setItemName(item, itemName.replaceAll(triFour + triOne, triThree + triTwo));
  717.               }
  718.             }
  719.             return;
  720.           }
  721.         }
  722.         boolean zoomEnable = getBoolean(parent_node + ".Scope.Enable");
  723.         boolean nightScope = getBoolean(parent_node + ".Scope.Night_Vision");
  724.         if ((!zoomEnable) || (shooter.hasMetadata("markOfTheReload"))) {
  725.           return;
  726.         }
  727.         int zoomAmount = getInt(parent_node + ".Scope.Zoom_Amount");
  728.         if ((zoomAmount < 0) || (zoomAmount == 0) || (zoomAmount > 10)) {
  729.           return;
  730.         }
  731.         WeaponScopeEvent scopeEvent = new WeaponScopeEvent(shooter, parent_node, !shooter.hasMetadata("ironsights"));
  732.         getServer().getPluginManager().callEvent(scopeEvent);
  733.         if (scopeEvent.isCancelled()) {
  734.           return;
  735.         }
  736.         playSoundEffects(shooter, parent_node, ".Scope.Sounds_Toggle_Zoom", false, null, new String[0]);
  737.         if (shooter.hasPotionEffect(PotionEffectType.SPEED))
  738.         {
  739.           for (PotionEffect pe : shooter.getActivePotionEffects()) {
  740.             if (pe.getType().toString().contains("SPEED"))
  741.             {
  742.               if (shooter.hasMetadata("ironsights"))
  743.               {
  744.                 unscopePlayer(shooter, new boolean[] { true });
  745.                 break;
  746.               }
  747.               if ((!shooter.hasPotionEffect(PotionEffectType.NIGHT_VISION)) && (nightScope))
  748.               {
  749.                 shooter.addPotionEffect(PotionEffectType.NIGHT_VISION.createEffect(2400, -1));
  750.                 shooter.setMetadata("night_scoping", new FixedMetadataValue(this, Boolean.valueOf(true)));
  751.               }
  752.               shooter.setMetadata("ironsights", new FixedMetadataValue(this, parent_node));
  753.               this.zoomStorage.put(shooter.getName(), new int[] { pe.getDuration(), pe.getAmplifier() });
  754.               shooter.removePotionEffect(PotionEffectType.SPEED);
  755.               shooter.addPotionEffect(PotionEffectType.SPEED.createEffect(2400, -zoomAmount));
  756.              
  757.               break;
  758.             }
  759.           }
  760.         }
  761.         else
  762.         {
  763.           if ((!shooter.hasPotionEffect(PotionEffectType.NIGHT_VISION)) && (nightScope))
  764.           {
  765.             shooter.addPotionEffect(PotionEffectType.NIGHT_VISION.createEffect(2400, -1));
  766.             shooter.setMetadata("night_scoping", new FixedMetadataValue(this, Boolean.valueOf(true)));
  767.           }
  768.           shooter.setMetadata("ironsights", new FixedMetadataValue(this, parent_node));
  769.           shooter.addPotionEffect(PotionEffectType.SPEED.createEffect(2400, -zoomAmount));
  770.         }
  771.       }
  772.     }
  773.     else if ((event.getClickedBlock().getType() == Material.WOOD_PLATE) || (event.getClickedBlock().getType() == Material.STONE_PLATE))
  774.     {
  775.       Player victim = event.getPlayer();
  776.       List<Entity> l = victim.getNearbyEntities(4.0D, 4.0D, 4.0D);
  777.       for (Entity e : l) {
  778.         if ((e instanceof ItemFrame)) {
  779.           this.csminion.boobyAction(event.getClickedBlock(), victim, ((ItemFrame)e).getItem());
  780.         }
  781.       }
  782.     }
  783.   }
  784.  
  785.   @EventHandler(priority=EventPriority.HIGHEST)
  786.   public void onDamage(EntityDamageByEntityEvent event)
  787.   {
  788.     Entity entVictim = event.getEntity();
  789.     Entity entDmger = event.getDamager();
  790.     boolean cancelMelee = false;
  791.     if (((entVictim instanceof Player)) && (entVictim.hasMetadata("CS_singed")))
  792.     {
  793.       cancelMelee = true;
  794.       if (!event.isCancelled())
  795.       {
  796.         entVictim.setMetadata("CS_singed", new FixedMetadataValue(this, Boolean.valueOf(true)));
  797.         event.setCancelled(true);
  798.       }
  799.       else
  800.       {
  801.         entVictim.removeMetadata("CS_singed", this);
  802.       }
  803.     }
  804.     if (((entVictim instanceof Player)) && (entVictim.hasMetadata("deep_fr1ed")))
  805.     {
  806.       cancelMelee = true;
  807.       String parent_node = null;
  808.       Player pPlayer = null;
  809.       boolean nodam = false;
  810.       Player victim = (Player)entVictim;
  811.       int damage = ((MetadataValue)victim.getMetadata("deep_fr1ed").get(0)).asInt();
  812.       victim.removeMetadata("deep_fr1ed", this);
  813.       if (victim.hasMetadata("CS_nodam")) {
  814.         nodam = true;
  815.       }
  816.       if ((victim.hasMetadata("CS_potex")) && (victim.getMetadata("CS_potex") != null)) {
  817.         parent_node = ((MetadataValue)victim.getMetadata("CS_potex").get(0)).asString();
  818.       }
  819.       if ((entDmger instanceof Player)) {
  820.         pPlayer = (Player)entDmger;
  821.       }
  822.       victim.removeMetadata("CS_potex", this);
  823.       if (!event.isCancelled())
  824.       {
  825.         this.csminion.explosionPackage(victim, parent_node, pPlayer);
  826.         if (!nodam) {
  827.           event.setDamage(damage);
  828.         } else {
  829.           event.setCancelled(true);
  830.         }
  831.       }
  832.     }
  833.     Vector direction;
  834.     if (((entDmger instanceof Player)) && ((entVictim instanceof LivingEntity)))
  835.     {
  836.       Player player = (Player)entDmger;
  837.       Location finalLoc = player.getEyeLocation();
  838.       direction = player.getEyeLocation().getDirection().normalize().multiply(0.5D);
  839.       for (int i = 0; i < 10; i++)
  840.       {
  841.         finalLoc.add(direction);
  842.         if (finalLoc.getBlock().getType() != Material.AIR)
  843.         {
  844.           OnPlayerInteract(new PlayerInteractEvent(player, Action.LEFT_CLICK_AIR, player.getItemInHand(), null, null));
  845.           break;
  846.         }
  847.       }
  848.     }
  849.     if (((entVictim instanceof LargeFireball)) && (entVictim.hasMetadata("CS_NoDeflect")))
  850.     {
  851.       event.setCancelled(true);
  852.       return;
  853.     }
  854.     if (((entDmger instanceof Player)) && (event.getDamage() == 8.0D) && (event.getCause() == EntityDamageEvent.DamageCause.ENTITY_ATTACK))
  855.     {
  856.       List<Entity> witherNet = entVictim.getNearbyEntities(4.0D, 4.0D, 4.0D);
  857.       label526:
  858.       for (direction = witherNet.iterator(); direction.hasNext(); event.setCancelled(true))
  859.       {
  860.         Entity closeEnt = (Entity)direction.next();
  861.         if ((!(closeEnt instanceof WitherSkull)) || (((Projectile)closeEnt).getShooter() != entDmger)) {
  862.           break label526;
  863.         }
  864.       }
  865.     }
  866.     if ((!cancelMelee) && ((entDmger instanceof Player)) && (event.getCause() == EntityDamageEvent.DamageCause.ENTITY_ATTACK) && (!event.isCancelled()) && ((entVictim instanceof LivingEntity)))
  867.     {
  868.       Player player = (Player)entDmger;
  869.       String parentNode = returnParentNode(player);
  870.       if ((parentNode != null) && (regionAndPermCheck(player, parentNode, true)))
  871.       {
  872.         int punchDelay = getInt(parentNode + ".Shooting.Delay_Between_Shots");
  873.         int gunSlot = player.getInventory().getHeldItemSlot();
  874.         if (!player.hasMetadata(parentNode + "meleeDelay" + gunSlot))
  875.         {
  876.           if (getBoolean(parentNode + ".Item_Information.Melee_Mode"))
  877.           {
  878.             ItemStack item = player.getItemInHand();
  879.             String ammoInfo = getString(parentNode + ".Ammo.Ammo_Item_ID");
  880.             boolean reloadOn = getBoolean(parentNode + ".Reload.Enable");
  881.             boolean ammoPerShot = getBoolean(parentNode + ".Ammo.Take_Ammo_Per_Shot");
  882.             boolean ammoEnable = getBoolean(parentNode + ".Ammo.Enable");
  883.             boolean takeAmmo = getBoolean(parentNode + ".Reload.Take_Ammo_On_Reload");
  884.             int detectedAmmo = getAmmoBetweenBrackets(player, parentNode, item);
  885.             if (!validHotbar(player, parentNode)) {
  886.               return;
  887.             }
  888.             player.setMetadata(parentNode + "meleeDelay" + gunSlot, new FixedMetadataValue(this, Boolean.valueOf(true)));
  889.             this.csminion.tempVars(player, parentNode + "meleeDelay" + gunSlot, Long.valueOf(punchDelay));
  890.             if (ammoEnable)
  891.             {
  892.               if ((!takeAmmo) && (!ammoPerShot))
  893.               {
  894.                 player.sendMessage(this.heading + "The weapon '" + parentNode + "' has enabled the Ammo module, but at least one of the following nodes need to be set to true: Take_Ammo_On_Reload, Take_Ammo_Per_Shot.");
  895.                 return;
  896.               }
  897.               if ((!this.csminion.containsItemStack(player, ammoInfo, 1, parentNode)) && ((ammoPerShot) || ((takeAmmo) && (detectedAmmo == 0))))
  898.               {
  899.                 playSoundEffects(player, parentNode, ".Ammo.Sounds_Shoot_With_No_Ammo", false, null, new String[0]);
  900.                 return;
  901.               }
  902.             }
  903.             if ((itemIsSafe(item)) && (item.getItemMeta().getDisplayName().contains(String.valueOf('?')))) {
  904.               if (detectedAmmo > 0)
  905.               {
  906.                 terminateReload(player);
  907.                 removeInertReloadTag(player, 0, true);
  908.               }
  909.               else
  910.               {
  911.                 reloadAnimation(player, parentNode, new boolean[0]);
  912.                 return;
  913.               }
  914.             }
  915.             if (reloadOn)
  916.             {
  917.               if (detectedAmmo > 0) {
  918.                 ammoOperation(player, parentNode, detectedAmmo, item);
  919.               } else {
  920.                 reloadAnimation(player, parentNode, new boolean[0]);
  921.               }
  922.             }
  923.             else
  924.             {
  925.               String itemName = item.getItemMeta().getDisplayName();
  926.               if ((itemName.contains("�")) && (!itemName.contains(String.valueOf('�')))) {
  927.                 this.csminion.replaceBrackets(item, String.valueOf('�'), parentNode);
  928.               }
  929.             }
  930.             dealDamage(player, (LivingEntity)entVictim, event, parentNode);
  931.           }
  932.           else
  933.           {
  934.             String meleeNode = getString(parentNode + ".Item_Information.Melee_Attachment");
  935.             if (meleeNode != null)
  936.             {
  937.               punchDelay = getInt(meleeNode + ".Shooting.Delay_Between_Shots");
  938.               if (this.melees.contains(meleeNode))
  939.               {
  940.                 if (validHotbar(player, parentNode))
  941.                 {
  942.                   player.setMetadata(parentNode + "meleeDelay" + gunSlot, new FixedMetadataValue(this, Boolean.valueOf(true)));
  943.                   this.csminion.tempVars(player, parentNode + "meleeDelay" + gunSlot, Long.valueOf(punchDelay));
  944.                   dealDamage(player, (LivingEntity)entVictim, event, meleeNode);
  945.                 }
  946.               }
  947.               else {
  948.                 player.sendMessage(this.heading + "The weapon '" + parentNode + "' has an unknown melee attachment. '" + meleeNode + "' could not be found!");
  949.               }
  950.             }
  951.           }
  952.         }
  953.         else {
  954.           event.setCancelled(true);
  955.         }
  956.       }
  957.     }
  958.     if ((((entDmger instanceof WitherSkull)) || ((entDmger instanceof LargeFireball))) && (event.getDamager().hasMetadata("projParentNode"))) {
  959.       event.setCancelled(true);
  960.     }
  961.     if (((entDmger instanceof Player)) && ((entVictim instanceof Player)) && (entVictim.hasMetadata("CS_Energy")) && (!event.isCancelled()))
  962.     {
  963.       dealDamage(entDmger, (LivingEntity)entVictim, event, ((MetadataValue)entVictim.getMetadata("CS_Energy").get(0)).asString());
  964.       entVictim.removeMetadata("CS_Energy", this);
  965.     }
  966.     if ((((entDmger instanceof Arrow)) || ((entDmger instanceof Egg)) || ((entDmger instanceof Snowball))) &&
  967.       (entDmger.hasMetadata("projParentNode")) && ((entVictim instanceof LivingEntity)) && (!event.isCancelled())) {
  968.       dealDamage(entDmger, (LivingEntity)entVictim, event, ((MetadataValue)entDmger.getMetadata("projParentNode").get(0)).asString());
  969.     }
  970.     if (((entDmger instanceof TNTPrimed)) && (entDmger.hasMetadata("CS_Label")))
  971.     {
  972.       if ((entDmger.hasMetadata("nullify")) && (
  973.         ((entVictim instanceof Painting)) || ((entVictim instanceof ItemFrame)) || ((entVictim instanceof Item)) || ((entVictim instanceof ExperienceOrb)))) {
  974.         event.setCancelled(true);
  975.       }
  976.       if ((entDmger.hasMetadata("CS_nodam")) || (entVictim.hasMetadata("CS_shrapnel")))
  977.       {
  978.         if ((entVictim instanceof Player))
  979.         {
  980.           entVictim.setMetadata("CS_nodam", new FixedMetadataValue(this, Boolean.valueOf(true)));
  981.           this.csminion.tempVars((Player)entVictim, "CS_nodam", Long.valueOf(2L));
  982.         }
  983.         event.setCancelled(true);
  984.       }
  985.       String parent_node = null;
  986.       double totalDmg = event.getDamage();
  987.       if (entDmger.hasMetadata("CS_potex"))
  988.       {
  989.         parent_node = ((MetadataValue)entDmger.getMetadata("CS_potex").get(0)).asString();
  990.         if ((event.getDamage() > 1.0D) && (parent_node != null)) {
  991.           try
  992.           {
  993.             String multiString = getString(parent_node + ".Explosions.Damage_Multiplier");
  994.             if (multiString != null)
  995.             {
  996.               double multiplier = Integer.valueOf(multiString).intValue() * 0.01D;
  997.               totalDmg *= multiplier;
  998.               totalDmg = this.csminion.getSuperDamage(entVictim.getType(), parent_node, totalDmg);
  999.             }
  1000.           }
  1001.           catch (IllegalArgumentException localIllegalArgumentException) {}
  1002.         }
  1003.       }
  1004.       int knockBack = getInt(parent_node + ".Explosions.Knockback");
  1005.       if ((knockBack != 0) && (!entVictim.hasMetadata("CS_shrapnel")))
  1006.       {
  1007.         Vector vector = this.csminion.getAlignedDirection(entDmger.getLocation(), entVictim.getLocation());
  1008.         entVictim.setVelocity(vector.multiply(knockBack * 0.1D));
  1009.       }
  1010.       String pName = "Player";
  1011.       Player pPlayer = null;
  1012.       if (entDmger.hasMetadata("CS_pName"))
  1013.       {
  1014.         pName = ((MetadataValue)entDmger.getMetadata("CS_pName").get(0)).asString();
  1015.         pPlayer = Bukkit.getServer().getPlayer(pName);
  1016.       }
  1017.       boolean noDam = ((entVictim instanceof Player)) && (entDmger.hasMetadata("0wner_nodam")) && (((Player)entVictim).getName().equals(pName));
  1018.       if (noDam) {
  1019.         totalDmg = 0.0D;
  1020.       }
  1021.       WeaponDamageEntityEvent weaponEvent = new WeaponDamageEntityEvent(pPlayer, entVictim, entDmger, parent_node, totalDmg, false, false, false);
  1022.       getServer().getPluginManager().callEvent(weaponEvent);
  1023.       event.setDamage(weaponEvent.getDamage());
  1024.       if (weaponEvent.isCancelled())
  1025.       {
  1026.         event.setCancelled(true);
  1027.       }
  1028.       else if ((entVictim instanceof Player))
  1029.       {
  1030.         Player victim = (Player)entVictim;
  1031.         if (noDam)
  1032.         {
  1033.           event.setCancelled(true);
  1034.           return;
  1035.         }
  1036.         victim.setNoDamageTicks(0);
  1037.         if (entDmger.hasMetadata("CS_ffcheck"))
  1038.         {
  1039.           if (victim.getName().equals(pName))
  1040.           {
  1041.             this.csminion.explosionPackage(victim, parent_node, pPlayer);
  1042.           }
  1043.           else if (pPlayer != null)
  1044.           {
  1045.             victim.setMetadata("deep_fr1ed", new FixedMetadataValue(this, Double.valueOf(event.getDamage())));
  1046.             if (parent_node != null) {
  1047.               victim.setMetadata("CS_potex", new FixedMetadataValue(this, parent_node));
  1048.             }
  1049.             this.csminion.illegalSlap(pPlayer, victim, 0);
  1050.             event.setCancelled(true);
  1051.           }
  1052.         }
  1053.         else {
  1054.           this.csminion.explosionPackage(victim, parent_node, pPlayer);
  1055.         }
  1056.       }
  1057.       else if ((entVictim instanceof LivingEntity))
  1058.       {
  1059.         ((LivingEntity)entVictim).setNoDamageTicks(0);
  1060.         this.csminion.explosionPackage((LivingEntity)entVictim, parent_node, pPlayer);
  1061.       }
  1062.     }
  1063.     if (((entVictim instanceof Player)) && (!event.isCancelled()))
  1064.     {
  1065.       Player blocker = (Player)entVictim;
  1066.       if (!blocker.isBlocking()) {
  1067.         return;
  1068.       }
  1069.       String parentNode = returnParentNode(blocker);
  1070.       if (parentNode == null) {
  1071.         return;
  1072.       }
  1073.       int durabPerHit = getInt(parentNode + ".Riot_Shield.Durability_Loss_Per_Hit");
  1074.       boolean riotEnable = getBoolean(parentNode + ".Riot_Shield.Enable");
  1075.       boolean durabDmg = getBoolean(parentNode + ".Riot_Shield.Durablity_Based_On_Damage");
  1076.       boolean noProj = getBoolean(parentNode + ".Riot_Shield.Do_Not_Block_Projectiles");
  1077.       boolean noMelee = getBoolean(parentNode + ".Riot_Shield.Do_Not_Block_Melee_Attacks");
  1078.       boolean forceField = getBoolean(parentNode + ".Riot_Shield.Forcefield_Mode");
  1079.       if ((!riotEnable) || (!regionAndPermCheck(blocker, parentNode, false))) {
  1080.         return;
  1081.       }
  1082.       if ((entDmger instanceof Projectile))
  1083.       {
  1084.         if (noProj) {
  1085.           return;
  1086.         }
  1087.         if (!forceField)
  1088.         {
  1089.           Projectile objProj = (Projectile)entDmger;
  1090.           double faceAngle = blocker.getLocation().getDirection().dot(((Entity)objProj.getShooter()).getLocation().getDirection());
  1091.           if (faceAngle > 0.0D) {
  1092.             if ((objProj.getShooter() instanceof Skeleton)) {}
  1093.           }
  1094.         }
  1095.       }
  1096.       else
  1097.       {
  1098.         if (noMelee) {
  1099.           return;
  1100.         }
  1101.         if (!forceField)
  1102.         {
  1103.           double faceAngle = blocker.getLocation().getDirection().dot(entDmger.getLocation().getDirection());
  1104.           if (faceAngle > 0.0D) {
  1105.             return;
  1106.           }
  1107.         }
  1108.       }
  1109.       if (durabDmg) {
  1110.         durabPerHit = (int)(durabPerHit * event.getDamage());
  1111.       }
  1112.       ItemStack shield = blocker.getInventory().getItemInHand();
  1113.       shield.setDurability((short)(shield.getDurability() + durabPerHit));
  1114.       playSoundEffects(blocker, parentNode, ".Riot_Shield.Sounds_Blocked", false, null, new String[0]);
  1115.       if (shield.getType().getMaxDurability() <= shield.getDurability())
  1116.       {
  1117.         playSoundEffects(blocker, parentNode, ".Riot_Shield.Sounds_Break", false, null, new String[0]);
  1118.         blocker.getInventory().clear(blocker.getInventory().getHeldItemSlot());
  1119.         blocker.updateInventory();
  1120.       }
  1121.       event.setCancelled(true);
  1122.     }
  1123.   }
  1124.  
  1125.   public void dealDamage(Entity entDmger, LivingEntity victim, EntityDamageByEntityEvent event, String parent_node)
  1126.   {
  1127.     boolean energyMode = (entDmger instanceof Player);
  1128.    
  1129.     Projectile objProj = null;
  1130.     Player shooter;
  1131.     if (!energyMode)
  1132.     {
  1133.       objProj = (Projectile)entDmger;
  1134.       Player shooter = (Player)objProj.getShooter();
  1135.       objProj.setMetadata("Collided", new FixedMetadataValue(this, Boolean.valueOf(true)));
  1136.     }
  1137.     else
  1138.     {
  1139.       shooter = (Player)entDmger;
  1140.     }
  1141.     if (shooter == null) {
  1142.       return;
  1143.     }
  1144.     double projSpeed = getInt(parent_node + ".Shooting.Projectile_Speed") * 0.1D;
  1145.     boolean hitEnable = getBoolean(parent_node + ".Hit_Events.Enable");
  1146.     boolean headShots = getBoolean(parent_node + ".Headshot.Enable");
  1147.     boolean bsEnable = getBoolean(parent_node + ".Backstab.Enable");
  1148.     boolean critEnable = getBoolean(parent_node + ".Critical_Hits.Enable");
  1149.     boolean fireEnable = getBoolean(parent_node + ".Shooting.Projectile_Incendiary.Enable");
  1150.     int fireDuration = getInt(parent_node + ".Shooting.Projectile_Incendiary.Duration");
  1151.     boolean zapEnable = getBoolean(parent_node + ".Lightning.Enable");
  1152.     boolean resetHits = getBoolean(parent_node + ".Abilities.Reset_Hit_Cooldown");
  1153.     boolean flightEnable = getBoolean(parent_node + ".Damage_Based_On_Flight_Time.Enable");
  1154.     String makeSpeak = getString(parent_node + ".Extras.Make_Victim_Speak");
  1155.     String makeRunCmd = getString(parent_node + ".Extras.Make_Victim_Run_Commmand");
  1156.     String runConsole = getString(parent_node + ".Extras.Run_Console_Command");
  1157.     int knockBack = getInt(parent_node + ".Abilities.Knockback");
  1158.     String bonusDrops = getString(parent_node + ".Abilities.Bonus_Drops");
  1159.     int activTime = getInt(parent_node + ".Explosions.Projectile_Activation_Time");
  1160.    
  1161.     int projFlight = 0;
  1162.     double projTotalDmg = getInt(parent_node + ".Shooting.Projectile_Damage");
  1163.    
  1164.     boolean BS = false;
  1165.     boolean crit = false;
  1166.     boolean boomHS = false;
  1167.     if ((flightEnable) && (!energyMode))
  1168.     {
  1169.       int dmgPerTick = getInt(parent_node + ".Damage_Based_On_Flight_Time.Bonus_Damage_Per_Tick");
  1170.       int flightMax = getInt(parent_node + ".Damage_Based_On_Flight_Time.Maximum_Damage");
  1171.       int flightMin = getInt(parent_node + ".Damage_Based_On_Flight_Time.Minimum_Damage");
  1172.       boolean negDmg = (dmgPerTick < 0) && (flightMax < 0);
  1173.      
  1174.       projFlight = objProj.getTicksLived();
  1175.       int tickDmgTotal = projFlight * dmgPerTick;
  1176.       if ((tickDmgTotal < flightMin) && (flightMin != 0)) {
  1177.         tickDmgTotal = 0;
  1178.       }
  1179.       if (!negDmg)
  1180.       {
  1181.         if ((tickDmgTotal > flightMax) && (flightMax != 0)) {
  1182.           tickDmgTotal = flightMax;
  1183.         }
  1184.       }
  1185.       else if ((tickDmgTotal < flightMax) && (flightMax != 0)) {
  1186.         tickDmgTotal = flightMax;
  1187.       }
  1188.       projTotalDmg += tickDmgTotal;
  1189.     }
  1190.     if (bsEnable)
  1191.     {
  1192.       int bsBonusDmg = getInt(parent_node + ".Backstab.Bonus_Damage");
  1193.      
  1194.       double faceAngle = victim.getLocation().getDirection().dot(shooter.getLocation().getDirection());
  1195.       if (faceAngle > 0.0D)
  1196.       {
  1197.         BS = true;
  1198.         projTotalDmg += bsBonusDmg;
  1199.       }
  1200.     }
  1201.     if (critEnable)
  1202.     {
  1203.       int critBonus = getInt(parent_node + ".Critical_Hits.Bonus_Damage");
  1204.       int critChance = getInt(parent_node + ".Critical_Hits.Chance");
  1205.      
  1206.       Random ranGen = new Random();
  1207.       int Chance = ranGen.nextInt(100);
  1208.       if (Chance <= critChance)
  1209.       {
  1210.         crit = true;
  1211.         projTotalDmg += critBonus;
  1212.       }
  1213.     }
  1214.     if ((headShots) && (!energyMode) && (this.csminion.isHesh(objProj, victim, projSpeed)))
  1215.     {
  1216.       boomHS = true;
  1217.       projTotalDmg += getInt(parent_node + ".Headshot.Bonus_Damage");
  1218.     }
  1219.     projTotalDmg = this.csminion.getSuperDamage(victim.getType(), parent_node, projTotalDmg);
  1220.     if (projTotalDmg < 0.0D) {
  1221.       projTotalDmg = 0.0D;
  1222.     }
  1223.     WeaponDamageEntityEvent weaponEvent = new WeaponDamageEntityEvent(shooter, victim, objProj, parent_node, projTotalDmg, boomHS, BS, crit);
  1224.     getServer().getPluginManager().callEvent(weaponEvent);
  1225.     if (weaponEvent.isCancelled())
  1226.     {
  1227.       if (event != null) {
  1228.         event.setCancelled(true);
  1229.       }
  1230.       return;
  1231.     }
  1232.     if (resetHits) {
  1233.       setTempVulnerability(victim);
  1234.     }
  1235.     if (event != null) {
  1236.       event.setDamage(weaponEvent.getDamage());
  1237.     } else {
  1238.       victim.damage(weaponEvent.getDamage(), shooter);
  1239.     }
  1240.     if (knockBack != 0) {
  1241.       victim.setVelocity(shooter.getLocation().getDirection().multiply(knockBack));
  1242.     }
  1243.     if ((energyMode) || (objProj.getTicksLived() >= activTime)) {
  1244.       projectileExplosion(victim, parent_node, false, shooter, false, false, null, null, false, 0);
  1245.     }
  1246.     if (zapEnable)
  1247.     {
  1248.       boolean zapNoDmg = getBoolean(parent_node + ".Lightning.No_Damage");
  1249.       this.csminion.projectileLightning(victim.getLocation(), zapNoDmg);
  1250.     }
  1251.     if ((fireEnable) && (fireDuration != 0)) {
  1252.       victim.setFireTicks(fireDuration);
  1253.     }
  1254.     String flyTime = String.valueOf(projFlight);
  1255.     String dmgTotal = String.valueOf(projTotalDmg);
  1256.     String nameShooter = shooter.getName();
  1257.     String nameVic = "Entity";
  1258.     if ((victim instanceof Player)) {
  1259.       nameVic = ((Player)victim).getName();
  1260.     } else if ((victim instanceof LivingEntity)) {
  1261.       nameVic = victim.getType().getName();
  1262.     }
  1263.     if (boomHS)
  1264.     {
  1265.       sendPlayerMessage(shooter, parent_node, ".Headshot.Message_Shooter", nameShooter, nameVic, flyTime, dmgTotal);
  1266.       sendPlayerMessage(victim, parent_node, ".Headshot.Message_Victim", nameShooter, nameVic, flyTime, dmgTotal);
  1267.       playSoundEffects(shooter, parent_node, ".Headshot.Sounds_Shooter", false, null, new String[0]);
  1268.       playSoundEffects(victim, parent_node, ".Headshot.Sounds_Victim", false, null, new String[0]);
  1269.       this.csminion.giveParticleEffects(victim, parent_node, ".Particles.Particle_Headshot", false, null);
  1270.       this.csminion.displayFireworks(victim, parent_node, ".Fireworks.Firework_Headshot");
  1271.       this.csminion.givePotionEffects(shooter, parent_node, ".Potion_Effects.Potion_Effect_Shooter", "head");
  1272.       this.csminion.givePotionEffects(victim, parent_node, ".Potion_Effects.Potion_Effect_Victim", "head");
  1273.     }
  1274.     if (crit)
  1275.     {
  1276.       sendPlayerMessage(shooter, parent_node, ".Critical_Hits.Message_Shooter", nameShooter, nameVic, flyTime, dmgTotal);
  1277.       sendPlayerMessage(victim, parent_node, ".Critical_Hits.Message_Victim", nameShooter, nameVic, flyTime, dmgTotal);
  1278.       playSoundEffects(shooter, parent_node, ".Critical_Hits.Sounds_Shooter", false, null, new String[0]);
  1279.       playSoundEffects(victim, parent_node, ".Critical_Hits.Sounds_Victim", false, null, new String[0]);
  1280.       this.csminion.giveParticleEffects(victim, parent_node, ".Particles.Particle_Critical", false, null);
  1281.       this.csminion.displayFireworks(victim, parent_node, ".Fireworks.Firework_Critical");
  1282.       this.csminion.givePotionEffects(shooter, parent_node, ".Potion_Effects.Potion_Effect_Shooter", "crit");
  1283.       this.csminion.givePotionEffects(victim, parent_node, ".Potion_Effects.Potion_Effect_Victim", "crit");
  1284.     }
  1285.     if (BS)
  1286.     {
  1287.       sendPlayerMessage(shooter, parent_node, ".Backstab.Message_Shooter", nameShooter, nameVic, flyTime, dmgTotal);
  1288.       sendPlayerMessage(victim, parent_node, ".Backstab.Message_Victim", nameShooter, nameVic, flyTime, dmgTotal);
  1289.       playSoundEffects(shooter, parent_node, ".Backstab.Sounds_Shooter", false, null, new String[0]);
  1290.       playSoundEffects(victim, parent_node, ".Backstab.Sounds_Victim", false, null, new String[0]);
  1291.       this.csminion.giveParticleEffects(victim, parent_node, ".Particles.Particle_Backstab", false, null);
  1292.       this.csminion.displayFireworks(victim, parent_node, ".Fireworks.Firework_Backstab");
  1293.       this.csminion.givePotionEffects(shooter, parent_node, ".Potion_Effects.Potion_Effect_Shooter", "back");
  1294.       this.csminion.givePotionEffects(victim, parent_node, ".Potion_Effects.Potion_Effect_Victim", "back");
  1295.     }
  1296.     if (hitEnable)
  1297.     {
  1298.       sendPlayerMessage(shooter, parent_node, ".Hit_Events.Message_Shooter", nameShooter, nameVic, flyTime, dmgTotal);
  1299.       sendPlayerMessage(victim, parent_node, ".Hit_Events.Message_Victim", nameShooter, nameVic, flyTime, dmgTotal);
  1300.       playSoundEffects(shooter, parent_node, ".Hit_Events.Sounds_Shooter", false, null, new String[0]);
  1301.       playSoundEffects(victim, parent_node, ".Hit_Events.Sounds_Victim", false, null, new String[0]);
  1302.     }
  1303.     this.csminion.giveParticleEffects(victim, parent_node, ".Particles.Particle_Impact_Anything", false, null);
  1304.     this.csminion.giveParticleEffects(victim, parent_node, ".Particles.Particle_Hit", false, null);
  1305.     this.csminion.displayFireworks(victim, parent_node, ".Fireworks.Firework_Hit");
  1306.     this.csminion.givePotionEffects(shooter, parent_node, ".Potion_Effects.Potion_Effect_Shooter", "hit");
  1307.     this.csminion.givePotionEffects(victim, parent_node, ".Potion_Effects.Potion_Effect_Victim", "hit");
  1308.     if (spawnEntities(victim, parent_node, ".Spawn_Entity_On_Hit.EntityType_Baby_Explode_Amount", shooter))
  1309.     {
  1310.       sendPlayerMessage(shooter, parent_node, ".Spawn_Entity_On_Hit.Message_Shooter", nameShooter, nameVic, flyTime, dmgTotal);
  1311.       sendPlayerMessage(victim, parent_node, ".Spawn_Entity_On_Hit.Message_Victim", nameShooter, nameVic, flyTime, dmgTotal);
  1312.     }
  1313.     if ((victim instanceof Player))
  1314.     {
  1315.       if (makeSpeak != null) {
  1316.         ((Player)victim).chat(variableParser(makeSpeak, nameShooter, nameVic, flyTime, dmgTotal));
  1317.       }
  1318.       if (makeRunCmd != null) {
  1319.         executeCommands(victim, parent_node, ".Extras.Make_Victim_Run_Commmand", nameShooter, nameVic, flyTime, dmgTotal, false);
  1320.       }
  1321.     }
  1322.     if (runConsole != null) {
  1323.       executeCommands(shooter, parent_node, ".Extras.Run_Console_Command", nameShooter, nameVic, flyTime, dmgTotal, true);
  1324.     }
  1325.     if ((!(victim instanceof Player)) && (victim.getHealth() <= 0.0D) && (bonusDrops != null))
  1326.     {
  1327.       String[] dropInfo = bonusDrops.split(",");
  1328.       String[] arrayOfString1;
  1329.       int j = (arrayOfString1 = dropInfo).length;
  1330.       for (int i = 0; i < j; i++)
  1331.       {
  1332.         String drop = arrayOfString1[i];
  1333.         try
  1334.         {
  1335.           shooter.getWorld().dropItemNaturally(victim.getLocation(), new ItemStack(Material.getMaterial(Integer.valueOf(drop).intValue())));
  1336.         }
  1337.         catch (IllegalArgumentException ex)
  1338.         {
  1339.           printM("'" + drop + "' of weapon '" + parent_node + "' for 'Bonus_Drops' is not a valid item ID!");
  1340.           break;
  1341.         }
  1342.       }
  1343.     }
  1344.   }
  1345.  
  1346.   public void setTempVulnerability(final LivingEntity ent)
  1347.   {
  1348.     final int maxNoDamageTicks = ent.getMaximumNoDamageTicks();
  1349.     ent.setMaximumNoDamageTicks(0);
  1350.     ent.setNoDamageTicks(0);
  1351.     if (!ent.hasMetadata("[CS] NHC"))
  1352.     {
  1353.       ent.setMetadata("[CS] NHC", new FixedMetadataValue(this, Boolean.valueOf(true)));
  1354.       Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable()
  1355.       {
  1356.         public void run()
  1357.         {
  1358.           ent.setMaximumNoDamageTicks(maxNoDamageTicks);
  1359.           ent.setNoDamageTicks(0);
  1360.           ent.removeMetadata("[CS] NHC", CSDirector.this.plugin);
  1361.         }
  1362.       }, 2L);
  1363.     }
  1364.   }
  1365.  
  1366.   @EventHandler
  1367.   public void onProjectileHit(ProjectileHitEvent event)
  1368.   {
  1369.     if ((((event.getEntity() instanceof Arrow)) || ((event.getEntity() instanceof Egg)) || ((event.getEntity() instanceof Snowball))) &&
  1370.       (event.getEntity().hasMetadata("projParentNode")) && ((event.getEntity().getShooter() instanceof Player)))
  1371.     {
  1372.       Player shooter = (Player)event.getEntity().getShooter();
  1373.       Projectile objProj = event.getEntity();
  1374.       String parentNode = ((MetadataValue)objProj.getMetadata("projParentNode").get(0)).asString();
  1375.       Location destLoc = objProj.getLocation();
  1376.      
  1377.       objProj.removeMetadata(parentNode, this);
  1378.      
  1379.       boolean collided = event.getEntity().hasMetadata("Collided");
  1380.       boolean terrain = getBoolean(parentNode + ".Particles.Particle_Terrain");
  1381.       boolean airstrike = getBoolean(parentNode + ".Airstrikes.Enable");
  1382.       boolean zapEnable = getBoolean(parentNode + ".Lightning.Enable");
  1383.       boolean zapNoDam = getBoolean(parentNode + ".Lightning.No_Damage");
  1384.       boolean zapImpact = getBoolean(parentNode + ".Lightning.On_Impact_With_Anything");
  1385.       boolean arrowImpact = getBoolean(parentNode + ".Shooting.Remove_Arrows_On_Impact");
  1386.       boolean explodeImpact = getBoolean(parentNode + ".Explosions.On_Impact_With_Anything");
  1387.       int actTime = getInt(parentNode + ".Explosions.Projectile_Activation_Time");
  1388.       String breakBlocks = getString(parentNode + ".Abilities.Break_Blocks");
  1389.       String[] blockList = breakBlocks == null ? null : breakBlocks.split("-");
  1390.      
  1391.       Block hitBlock = objProj.getLocation().getBlock();
  1392.       if (!collided)
  1393.       {
  1394.         double projSpeed = getInt(parentNode + ".Shooting.Projectile_Speed") * 0.1D;
  1395.         if (projSpeed > 256.0D) {
  1396.           projSpeed = 256.0D;
  1397.         }
  1398.         for (double i = 0.0D; i <= projSpeed; i += 1.0D)
  1399.         {
  1400.           Location finalLoc = objProj.getLocation();
  1401.           Vector direction = objProj.getVelocity().normalize();
  1402.           direction.multiply(i);
  1403.           finalLoc.add(direction);
  1404.           hitBlock = finalLoc.getBlock();
  1405.           if (hitBlock.getType() != Material.AIR)
  1406.           {
  1407.             if (terrain) {
  1408.               objProj.getWorld().playEffect(finalLoc, Effect.STEP_SOUND, hitBlock.getType());
  1409.             }
  1410.             if ((blockList == null) || (blockList.length != 2)) {
  1411.               break;
  1412.             }
  1413.             boolean passWhiteList = false;
  1414.             boolean whiteList = Boolean.parseBoolean(blockList[0]);
  1415.             String blockMat = String.valueOf(hitBlock.getTypeId());
  1416.             if (!this.csminion.regionCheck(objProj, parentNode)) {
  1417.               break;
  1418.             }
  1419.             String[] arrayOfString1;
  1420.             int j = (arrayOfString1 = blockList[1].split(",")).length;
  1421.             for (int i = 0; i < j; i++)
  1422.             {
  1423.               String compMat = arrayOfString1[i];
  1424.               boolean hasSecdat = compMat.contains("~");
  1425.               String[] secdat = hasSecdat ? compMat.split("~") : null;
  1426.               if ((blockMat.equals(hasSecdat ? secdat[0] : compMat)) && ((!hasSecdat) || (hitBlock.getData() == Byte.valueOf(secdat[1]).byteValue())))
  1427.               {
  1428.                 if (!whiteList)
  1429.                 {
  1430.                   List<Block> brokenBlocks = new ArrayList();
  1431.                   brokenBlocks.add(hitBlock);
  1432.                   EntityExplodeEvent breakBlockEvent = new EntityExplodeEvent(objProj, objProj.getLocation(), brokenBlocks, 0.0F);
  1433.                   getServer().getPluginManager().callEvent(breakBlockEvent);
  1434.                  
  1435.                   hitBlock.setType(Material.AIR);
  1436.                   break;
  1437.                 }
  1438.                 passWhiteList = true;
  1439.               }
  1440.             }
  1441.             if ((!whiteList) || (passWhiteList)) {
  1442.               break;
  1443.             }
  1444.             List<Block> brokenBlocks = new ArrayList();
  1445.             brokenBlocks.add(hitBlock);
  1446.             EntityExplodeEvent breakBlockEvent = new EntityExplodeEvent(objProj, objProj.getLocation(), brokenBlocks, 0.0F);
  1447.             getServer().getPluginManager().callEvent(breakBlockEvent);
  1448.            
  1449.             hitBlock.setType(Material.AIR);
  1450.            
  1451.             break;
  1452.           }
  1453.           destLoc = finalLoc;
  1454.         }
  1455.         if ((explodeImpact) && (objProj.getTicksLived() >= actTime))
  1456.         {
  1457.           Entity tempOrb = objProj.getWorld().spawn(destLoc, ExperienceOrb.class);
  1458.           projectileExplosion(tempOrb, parentNode, false, shooter, false, false, null, null, false, 0);
  1459.           tempOrb.remove();
  1460.         }
  1461.         if ((zapEnable) && (zapImpact)) {
  1462.           this.csminion.projectileLightning(destLoc, zapNoDam);
  1463.         }
  1464.         this.csminion.giveParticleEffects(null, parentNode, ".Particles.Particle_Impact_Anything", false, destLoc);
  1465.       }
  1466.       playSoundEffects(null, parentNode, ".Hit_Events.Sounds_Impact", false, destLoc, new String[0]);
  1467.       this.csminion.giveParticleEffects(null, parentNode, ".Airstrikes.Particle_Call_Airstrike", false, destLoc);
  1468.       if (airstrike) {
  1469.         this.csminion.callAirstrike(event.getEntity(), parentNode, shooter);
  1470.       }
  1471.       if ((arrowImpact) && (objProj.getType() == EntityType.ARROW)) {
  1472.         objProj.remove();
  1473.       }
  1474.       WeaponHitBlockEvent blockHitEvent = new WeaponHitBlockEvent(shooter, objProj, parentNode, hitBlock, destLoc.getBlock());
  1475.       getServer().getPluginManager().callEvent(blockHitEvent);
  1476.     }
  1477.   }
  1478.  
  1479.   @EventHandler
  1480.   public void onEntityExplode(EntityExplodeEvent event)
  1481.   {
  1482.     Entity boomer = event.getEntity();
  1483.     if ((boomer instanceof TNTPrimed))
  1484.     {
  1485.       if (boomer.hasMetadata("CS_potex"))
  1486.       {
  1487.         String parent_node = ((MetadataValue)boomer.getMetadata("CS_potex").get(0)).asString();
  1488.         playSoundEffects(boomer, parent_node, ".Explosions.Sounds_Explode", false, null, new String[0]);
  1489.       }
  1490.       if ((boomer.hasMetadata("nullify")) && (event.blockList() != null)) {
  1491.         event.blockList().clear();
  1492.       }
  1493.       if ((boomer.getLocation().getBlock().getType() == Material.SKULL) && (!boomer.hasMetadata("C4_Friendly")))
  1494.       {
  1495.         BlockState state = boomer.getLocation().getBlock().getState();
  1496.         if ((state instanceof Skull))
  1497.         {
  1498.           try
  1499.           {
  1500.             skull = (Skull)state;
  1501.           }
  1502.           catch (ClassCastException ex)
  1503.           {
  1504.             Skull skull;
  1505.             return;
  1506.           }
  1507.           Skull skull;
  1508.           if (skull.getOwner().contains("?"))
  1509.           {
  1510.             boomer.getLocation().getBlock().removeMetadata("CS_transformers", this);
  1511.             boomer.getLocation().getBlock().setType(Material.AIR);
  1512.           }
  1513.         }
  1514.       }
  1515.     }
  1516.     else if ((((boomer instanceof WitherSkull)) || ((boomer instanceof LargeFireball))) && (boomer.hasMetadata("projParentNode")) &&
  1517.       ((((Projectile)boomer).getShooter() instanceof Player)))
  1518.     {
  1519.       Player shooter = (Player)((Projectile)boomer).getShooter();
  1520.       String parent_node = ((MetadataValue)boomer.getMetadata("projParentNode").get(0)).asString();
  1521.       if (boomer.getTicksLived() >= getInt(parent_node + ".Explosions.Projectile_Activation_Time")) {
  1522.         projectileExplosion(boomer, parent_node, false, shooter, false, false, null, null, false, 0);
  1523.       }
  1524.       event.setCancelled(true);
  1525.     }
  1526.   }
  1527.  
  1528.   public void playSoundEffectsScaled(final Entity player, String parentNode, String childNode, boolean reload, double scale, String... customSounds)
  1529.   {
  1530.     String soundList = customSounds.length == 0 ? getString(parentNode + childNode) : customSounds[0];
  1531.     if (soundList == null) {
  1532.       return;
  1533.     }
  1534.     String[] arrayOfString1;
  1535.     int j = (arrayOfString1 = soundList.replaceAll(" ", "").split(",")).length;
  1536.     for (int i = 0; i < j; i++)
  1537.     {
  1538.       String soundStrip = arrayOfString1[i];
  1539.       String[] soundInfo = soundStrip.split("-");
  1540.       if (soundInfo.length != 4) {
  1541.         printM("'" + soundStrip + "' of weapon '" + parentNode + "' has an invalid format! The correct format is: Sound-Volume-Pitch-Delay!");
  1542.       } else {
  1543.         try
  1544.         {
  1545.           final Sound sound = Sound.valueOf(soundInfo[0].toUpperCase());
  1546.           final float volume = Float.parseFloat(soundInfo[1]);
  1547.           final float pitch = Float.parseFloat(soundInfo[2]);
  1548.           long delay = (Long.parseLong(soundInfo[3]) * scale);
  1549.          
  1550.           int taskID = Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable()
  1551.           {
  1552.             public void run()
  1553.             {
  1554.               player.getWorld().playSound(player.getLocation(), sound, volume, pitch);
  1555.             }
  1556.           }, delay);
  1557.           if (reload)
  1558.           {
  1559.             String playerName = ((Player)player).getName();
  1560.             Collection<Integer> taskIDs = (Collection)this.global_reload_IDs.get(playerName);
  1561.             if (taskIDs == null)
  1562.             {
  1563.               taskIDs = new ArrayList();
  1564.               this.global_reload_IDs.put(playerName, taskIDs);
  1565.             }
  1566.             taskIDs.add(Integer.valueOf(taskID));
  1567.           }
  1568.         }
  1569.         catch (IllegalArgumentException ex)
  1570.         {
  1571.           printM("'" + soundStrip + "' of weapon '" + parentNode + "' contains either an invalid number or sound!");
  1572.         }
  1573.       }
  1574.     }
  1575.   }
  1576.  
  1577.   public void playSoundEffects(final Entity player, String parentNode, String childNode, boolean reload, final Location givenCoord, String... customSounds)
  1578.   {
  1579.     String soundList = customSounds.length == 0 ? getString(parentNode + childNode) : customSounds[0];
  1580.     if (soundList == null) {
  1581.       return;
  1582.     }
  1583.     String[] arrayOfString1;
  1584.     int j = (arrayOfString1 = soundList.replaceAll(" ", "").split(",")).length;
  1585.     for (int i = 0; i < j; i++)
  1586.     {
  1587.       String soundStrip = arrayOfString1[i];
  1588.       String[] soundInfo = soundStrip.split("-");
  1589.       if (soundInfo.length != 4) {
  1590.         printM("'" + soundStrip + "' of weapon '" + parentNode + "' has an invalid format! The correct format is: Sound-Volume-Pitch-Delay!");
  1591.       } else {
  1592.         try
  1593.         {
  1594.           final Sound sound = Sound.valueOf(soundInfo[0].toUpperCase());
  1595.           final float volume = Float.parseFloat(soundInfo[1]);
  1596.           final float pitch = Float.parseFloat(soundInfo[2]);
  1597.           long delay = Long.parseLong(soundInfo[3]);
  1598.          
  1599.           int taskID = Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable()
  1600.           {
  1601.             public void run()
  1602.             {
  1603.               if (player == null) {
  1604.                 givenCoord.getWorld().playSound(givenCoord, sound, volume, pitch);
  1605.               } else {
  1606.                 player.getWorld().playSound(player.getLocation(), sound, volume, pitch);
  1607.               }
  1608.             }
  1609.           }, delay);
  1610.           if (reload)
  1611.           {
  1612.             String playerName = ((Player)player).getName();
  1613.             Collection<Integer> taskIDs = (Collection)this.global_reload_IDs.get(playerName);
  1614.             if (taskIDs == null)
  1615.             {
  1616.               taskIDs = new ArrayList();
  1617.               this.global_reload_IDs.put(playerName, taskIDs);
  1618.             }
  1619.             taskIDs.add(Integer.valueOf(taskID));
  1620.           }
  1621.         }
  1622.         catch (IllegalArgumentException ex)
  1623.         {
  1624.           printM("'" + soundStrip + "' of weapon '" + parentNode + "' contains either an invalid number or sound!");
  1625.         }
  1626.       }
  1627.     }
  1628.   }
  1629.  
  1630.   public void fireProjectile(final Player player, final String parentNode, final boolean leftClick)
  1631.   {
  1632.     int gunSlot = player.getInventory().getHeldItemSlot();
  1633.     int shootDelay = getInt(parentNode + ".Shooting.Delay_Between_Shots");
  1634.    
  1635.     int projAmount = getInt(parentNode + ".Shooting.Projectile_Amount");
  1636.     final boolean ammoEnable = getBoolean(parentNode + ".Ammo.Enable");
  1637.     final boolean oneTime = getBoolean(parentNode + ".Extras.One_Time_Use");
  1638.     String deviceType = getString(parentNode + ".Explosive_Devices.Device_Type");
  1639.     final String proType = getString(parentNode + ".Shooting.Projectile_Type");
  1640.    
  1641.     ItemStack item = player.getInventory().getItemInHand();
  1642.     final boolean isFullyAuto = getBoolean(parentNode + ".Fully_Automatic.Enable");
  1643.     int fireRate = getInt(parentNode + ".Fully_Automatic.Fire_Rate");
  1644.     boolean burstEnable = getBoolean(parentNode + ".Burstfire.Enable");
  1645.     int burstShots = getInt(parentNode + ".Burstfire.Shots_Per_Burst");
  1646.     int burstDelay = getInt(parentNode + ".Burstfire.Delay_Between_Shots_In_Burst");
  1647.     boolean meleeMode = getBoolean(parentNode + ".Item_Information.Melee_Mode");
  1648.     boolean shootDisable = getBoolean(parentNode + ".Shooting.Disable");
  1649.     final boolean reloadOn = getBoolean(parentNode + ".Reload.Enable");
  1650.     final boolean dualWield = isDualWield(player, parentNode, item);
  1651.     if ((shootDisable) || (meleeMode)) {
  1652.       return;
  1653.     }
  1654.     Vector shiftVector = determinePosition(player, dualWield, leftClick);
  1655.     final Location projLoc = player.getEyeLocation().toVector().add(shiftVector.multiply(0.2D)).toLocation(player.getWorld());
  1656.    
  1657.     final String actType = getString(parentNode + ".Firearm_Action.Type");
  1658.     final boolean tweakyAction = (actType != null) && ((actType.toLowerCase().contains("bolt")) || (actType.toLowerCase().contains("lever")) || (actType.toLowerCase().contains("pump")));
  1659.     if (player.hasMetadata(parentNode + "shootDelay" + gunSlot + leftClick)) {
  1660.       return;
  1661.     }
  1662.     if (player.hasMetadata(parentNode + "noShooting" + gunSlot)) {
  1663.       return;
  1664.     }
  1665.     if (player.hasMetadata("togglesnoShooting" + gunSlot)) {
  1666.       return;
  1667.     }
  1668.     if ((oneTime) && (ammoEnable))
  1669.     {
  1670.       player.sendMessage(this.heading + "For '" + parentNode + "' - the 'One_Time_Use' node is incompatible with weapons using the Ammo module.");
  1671.       return;
  1672.     }
  1673.     if ((proType != null) && ((proType.equalsIgnoreCase("grenade")) || (proType.equalsIgnoreCase("flare"))) && (projAmount == 0))
  1674.     {
  1675.       player.sendMessage(this.heading + "The weapon '" + parentNode + "' is missing a value for 'Projectile_Amount'.");
  1676.       return;
  1677.     }
  1678.     if (isFullyAuto)
  1679.     {
  1680.       if (burstEnable)
  1681.       {
  1682.         player.sendMessage(this.heading + "The weapon '" + parentNode + "' is using Fully_Automatic and Burstfire at the same time. Pick one; you cannot enable both!");
  1683.         return;
  1684.       }
  1685.       if (shootDelay > 1)
  1686.       {
  1687.         player.sendMessage(this.heading + "For '" + parentNode + "' - the Fully_Automatic module can only be used if 'Delay_Between_Shots' is removed or set to a value no greater than 1.");
  1688.         return;
  1689.       }
  1690.       if ((fireRate <= 0) || (fireRate > 16))
  1691.       {
  1692.         player.sendMessage(this.heading + "The weapon '" + parentNode + "' has an invalid value for 'Fire_Rate'. The accepted values are 1 to 16.");
  1693.         return;
  1694.       }
  1695.     }
  1696.     if ((itemIsSafe(item)) && (item.getItemMeta().getDisplayName().contains("?"))) {
  1697.       if (getAmmoBetweenBrackets(player, parentNode, item) > 0)
  1698.       {
  1699.         if (!dualWield)
  1700.         {
  1701.           terminateReload(player);
  1702.          
  1703.           removeInertReloadTag(player, 0, true);
  1704.         }
  1705.         else
  1706.         {
  1707.           int[] ammoReading = grabDualAmmo(item, parentNode);
  1708.           if (((ammoReading[0] > 0) && (leftClick)) || ((ammoReading[1] > 0) && (!leftClick)))
  1709.           {
  1710.             terminateReload(player);
  1711.             removeInertReloadTag(player, 0, true);
  1712.           }
  1713.         }
  1714.       }
  1715.       else
  1716.       {
  1717.         reloadAnimation(player, parentNode, new boolean[0]);
  1718.         return;
  1719.       }
  1720.     }
  1721.     if (player.hasMetadata(parentNode + "reloadShootDelay" + gunSlot)) {
  1722.       return;
  1723.     }
  1724.     if ((!tweakyAction) && ((actType == null) || (!actType.equalsIgnoreCase("slide")) || (!item.getItemMeta().getDisplayName().contains("?"))))
  1725.     {
  1726.       player.setMetadata(parentNode + "shootDelay" + gunSlot + leftClick, new FixedMetadataValue(this, Boolean.valueOf(true)));
  1727.       this.csminion.tempVars(player, parentNode + "shootDelay" + gunSlot + leftClick, Long.valueOf(shootDelay));
  1728.     }
  1729.     final String ammoInfo = getString(parentNode + ".Ammo.Ammo_Item_ID");
  1730.     final boolean ammoPerShot = getBoolean(parentNode + ".Ammo.Take_Ammo_Per_Shot");
  1731.     double zoomAcc = getDouble(parentNode + ".Scope.Zoom_Bullet_Spread");
  1732.     final boolean sneakOn = getBoolean(parentNode + ".Sneak.Enable");
  1733.     boolean sneakToShoot = getBoolean(parentNode + ".Sneak.Sneak_Before_Shooting");
  1734.     final boolean sneakNoRec = getBoolean(parentNode + ".Sneak.No_Recoil");
  1735.     final double sneakAcc = getDouble(parentNode + ".Sneak.Bullet_Spread");
  1736.     final boolean exploDevs = getBoolean(parentNode + ".Explosive_Devices.Enable");
  1737.     boolean takeAmmo = getBoolean(parentNode + ".Reload.Take_Ammo_On_Reload");
  1738.    
  1739.     String dragRemInfo = getString(parentNode + ".Shooting.Removal_Or_Drag_Delay");
  1740.     final String[] dragRem = dragRemInfo == null ? null : dragRemInfo.split("-");
  1741.     if (dragRem != null) {
  1742.       try
  1743.       {
  1744.         Integer.valueOf(dragRem[0]);
  1745.       }
  1746.       catch (NumberFormatException ex)
  1747.       {
  1748.         player.sendMessage(this.heading + "For the weapon '" + parentNode + "', the 'Removal_Or_Drag_Delay' node is incorrectly configured.");
  1749.         return;
  1750.       }
  1751.     }
  1752.     if (getBoolean(parentNode + ".Ammo.Take_Ammo_On_Reload"))
  1753.     {
  1754.       player.sendMessage(this.heading + "For the weapon '" + parentNode + "', the Ammo module does not support the 'Take_Ammo_On_Reload' node. Did you mean to place it in the Reload module?");
  1755.       return;
  1756.     }
  1757.     if (ammoEnable)
  1758.     {
  1759.       if ((!takeAmmo) && (!ammoPerShot))
  1760.       {
  1761.         player.sendMessage(this.heading + "The weapon '" + parentNode + "' has enabled the Ammo module, but at least one of the following nodes need to be set to true: Take_Ammo_On_Reload, Take_Ammo_Per_Shot.");
  1762.         return;
  1763.       }
  1764.       if (!this.csminion.containsItemStack(player, ammoInfo, 1, parentNode))
  1765.       {
  1766.         boolean isPumpOrBolt = (actType != null) && (!actType.equalsIgnoreCase("pump")) && (!actType.equalsIgnoreCase("bolt"));
  1767.         boolean hasLoadedChamber = item.getItemMeta().getDisplayName().contains("? �");
  1768.         if ((ammoPerShot) || ((takeAmmo) && (getAmmoBetweenBrackets(player, parentNode, item) == 0) && ((isPumpOrBolt) || (!hasLoadedChamber))))
  1769.         {
  1770.           playSoundEffects(player, parentNode, ".Ammo.Sounds_Shoot_With_No_Ammo", false, null, new String[0]);
  1771.           return;
  1772.         }
  1773.       }
  1774.     }
  1775.     if ((sneakToShoot) && ((!player.isSneaking()) || (player.getLocation().getBlock().getRelative(BlockFace.DOWN).getType() == Material.AIR))) {
  1776.       return;
  1777.     }
  1778.     if (checkBoltPosition(player, parentNode)) {
  1779.       return;
  1780.     }
  1781.     if (!burstEnable) {
  1782.       burstShots = 1;
  1783.     }
  1784.     if (isFullyAuto)
  1785.     {
  1786.       burstShots = 5;
  1787.       burstDelay = 1;
  1788.     }
  1789.     final double projSpeed = getInt(parentNode + ".Shooting.Projectile_Speed") * 0.1D;
  1790.    
  1791.     final boolean setOnFire = getBoolean(parentNode + ".Shooting.Projectile_Flames");
  1792.    
  1793.     boolean noBulletDrop = getBoolean(parentNode + ".Shooting.Remove_Bullet_Drop");
  1794.     if ((getBoolean(parentNode + ".Scope.Zoom_Before_Shooting")) && (!player.hasMetadata("ironsights"))) {
  1795.       return;
  1796.     }
  1797.     int shootReloadBuffer = getInt(parentNode + ".Reload.Shoot_Reload_Buffer");
  1798.     if (shootReloadBuffer > 0)
  1799.     {
  1800.       Map<Integer, Long> lastShot = (Map)this.last_shot_list.get(player.getName());
  1801.       if (lastShot == null)
  1802.       {
  1803.         lastShot = new HashMap();
  1804.         this.last_shot_list.put(player.getName(), lastShot);
  1805.       }
  1806.       lastShot.put(Integer.valueOf(gunSlot), Long.valueOf(System.currentTimeMillis()));
  1807.     }
  1808.     int burstStart = 0;
  1809.     if (isFullyAuto)
  1810.     {
  1811.       WeaponFireRateEvent event = new WeaponFireRateEvent(player, parentNode, item, fireRate);
  1812.       getServer().getPluginManager().callEvent(event);
  1813.       fireRate = event.getFireRate();
  1814.      
  1815.       String playerName = player.getName();
  1816.       if (!this.rpm_ticks.containsKey(playerName)) {
  1817.         this.rpm_ticks.put(playerName, Integer.valueOf(1));
  1818.       }
  1819.       if (!this.rpm_shots.containsKey(playerName)) {
  1820.         this.rpm_shots.put(playerName, Integer.valueOf(0));
  1821.       }
  1822.       burstStart = ((Integer)this.rpm_shots.get(playerName)).intValue();
  1823.      
  1824.       this.rpm_shots.put(playerName, Integer.valueOf(5));
  1825.     }
  1826.     final int fireRateFinal = fireRate;
  1827.    
  1828.     final int itemSlot = player.getInventory().getHeldItemSlot();
  1829.     for (int burst = burstStart; burst < burstShots; burst++)
  1830.     {
  1831.       final boolean isLastShot = burst >= burstShots - 1;
  1832.      
  1833.       int task_ID = Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable()
  1834.       {
  1835.         public void run()
  1836.         {
  1837.           if (isFullyAuto)
  1838.           {
  1839.             String playerName = player.getName();
  1840.             int shotsLeft = ((Integer)CSDirector.this.rpm_shots.get(playerName)).intValue() - 1;
  1841.             CSDirector.this.rpm_shots.put(playerName, Integer.valueOf(shotsLeft));
  1842.            
  1843.             int tick = ((Integer)CSDirector.this.rpm_ticks.get(playerName)).intValue();
  1844.             CSDirector.this.rpm_ticks.put(playerName, Integer.valueOf(tick >= 20 ? 1 : tick + 1));
  1845.             if (shotsLeft == 0) {
  1846.               CSDirector.this.burst_task_IDs.remove(playerName);
  1847.             }
  1848.             if (CSDirector.this.isValid(tick, fireRateFinal)) {}
  1849.           }
  1850.           else if (isLastShot)
  1851.           {
  1852.             CSDirector.this.burst_task_IDs.remove(player.getName());
  1853.           }
  1854.           ItemStack item = player.getInventory().getItemInHand();
  1855.           if (!oneTime)
  1856.           {
  1857.             if ((CSDirector.this.switchedTheItem(player, parentNode)) || (itemSlot != player.getInventory().getHeldItemSlot()))
  1858.             {
  1859.               CSDirector.this.unscopePlayer(player, new boolean[0]);
  1860.               CSDirector.this.terminateAllBursts(player);
  1861.               return;
  1862.             }
  1863.             boolean normalAction = false;
  1864.             if (actType == null)
  1865.             {
  1866.               normalAction = true;
  1867.               String attachType = CSDirector.this.getAttachment(parentNode, item)[0];
  1868.               String filter = item.getItemMeta().getDisplayName();
  1869.               if ((attachType == null) || (!attachType.equalsIgnoreCase("accessory"))) {
  1870.                 if (filter.contains("? �")) {
  1871.                   CSDirector.this.csminion.setItemName(item, filter.replaceAll("? �", "�"));
  1872.                 } else if (filter.contains("? �")) {
  1873.                   CSDirector.this.csminion.setItemName(item, filter.replaceAll("? �", "�"));
  1874.                 } else if (filter.contains("? �")) {
  1875.                   CSDirector.this.csminion.setItemName(item, filter.replaceAll("? �", "�"));
  1876.                 }
  1877.               }
  1878.             }
  1879.             else if (!tweakyAction)
  1880.             {
  1881.               normalAction = true;
  1882.             }
  1883.             if ((ammoEnable) && (ammoPerShot) && (!CSDirector.this.csminion.containsItemStack(player, ammoInfo, 1, parentNode)))
  1884.             {
  1885.               CSDirector.this.burst_task_IDs.remove(player.getName());
  1886.               return;
  1887.             }
  1888.             if (reloadOn)
  1889.             {
  1890.               if (item.getItemMeta().getDisplayName().contains("?")) {
  1891.                 return;
  1892.               }
  1893.               int detectedAmmo = CSDirector.this.getAmmoBetweenBrackets(player, parentNode, item);
  1894.               if (normalAction) {
  1895.                 if (detectedAmmo > 0)
  1896.                 {
  1897.                   if (!dualWield) {
  1898.                     CSDirector.this.ammoOperation(player, parentNode, detectedAmmo, item);
  1899.                   } else if (CSDirector.this.ammoSpecOps(player, parentNode, detectedAmmo, item, leftClick)) {}
  1900.                 }
  1901.                 else {
  1902.                   CSDirector.this.reloadAnimation(player, parentNode, new boolean[0]);
  1903.                 }
  1904.               }
  1905.             }
  1906.             else
  1907.             {
  1908.               String itemName = item.getItemMeta().getDisplayName();
  1909.               if ((itemName.contains("�")) && (!itemName.contains(String.valueOf('�'))) && (!exploDevs)) {
  1910.                 CSDirector.this.csminion.replaceBrackets(item, String.valueOf('�'), parentNode);
  1911.               }
  1912.             }
  1913.           }
  1914.           double bulletSpread = CSDirector.this.getDouble(parentNode + ".Shooting.Bullet_Spread");
  1915.           if ((player.isSneaking()) && (sneakOn)) {
  1916.             bulletSpread = sneakAcc;
  1917.           }
  1918.           if (player.hasMetadata("ironsights")) {
  1919.             bulletSpread = sneakNoRec;
  1920.           }
  1921.           if (bulletSpread == 0.0D) {
  1922.             bulletSpread = 0.1D;
  1923.           }
  1924.           boolean noVertRecoil = CSDirector.this.getBoolean(parentNode + ".Abilities.No_Vertical_Recoil");
  1925.           boolean jetPack = CSDirector.this.getBoolean(parentNode + ".Abilities.Jetpack_Mode");
  1926.           double recoilAmount = CSDirector.this.getInt(parentNode + ".Shooting.Recoil_Amount") * 0.1D;
  1927.           if ((recoilAmount != 0.0D) && ((!sneakOn) || (!proType) || (!player.isSneaking()))) {
  1928.             if (!jetPack)
  1929.             {
  1930.               Vector velToAdd = player.getLocation().getDirection().multiply(-recoilAmount);
  1931.               if (noVertRecoil) {
  1932.                 velToAdd.multiply(new Vector(1, 0, 1));
  1933.               }
  1934.               player.setVelocity(velToAdd);
  1935.             }
  1936.             else
  1937.             {
  1938.               player.setVelocity(new Vector(0.0D, recoilAmount, 0.0D));
  1939.             }
  1940.           }
  1941.           boolean clearFall = CSDirector.this.getBoolean(parentNode + ".Shooting.Reset_Fall_Distance");
  1942.           if (clearFall) {
  1943.             player.setFallDistance(0.0F);
  1944.           }
  1945.           CSDirector.this.csminion.giveParticleEffects(player, parentNode, ".Particles.Particle_Player_Shoot", true, null);
  1946.          
  1947.           CSDirector.this.csminion.givePotionEffects(player, parentNode, ".Potion_Effects.Potion_Effect_Shooter", "shoot");
  1948.          
  1949.           CSDirector.this.csminion.displayFireworks(player, parentNode, ".Fireworks.Firework_Player_Shoot");
  1950.          
  1951.           CSDirector.this.csminion.runCommand(player, parentNode);
  1952.           if (CSDirector.this.getBoolean(parentNode + ".Abilities.Hurt_Effect")) {
  1953.             player.playEffect(EntityEffect.HURT);
  1954.           }
  1955.           String projectile_type = CSDirector.this.getString(parentNode + ".Shooting.Projectile_Type");
  1956.          
  1957.           int timer = CSDirector.this.getInt(parentNode + ".Explosions.Explosion_Delay");
  1958.           boolean airstrike = CSDirector.this.getBoolean(parentNode + ".Airstrikes.Enable");
  1959.           if (airstrike) {
  1960.             timer = CSDirector.this.getInt(parentNode + ".Airstrikes.Flare_Activation_Delay");
  1961.           }
  1962.           String soundsShoot = CSDirector.this.getString(parentNode + ".Shooting.Sounds_Shoot");
  1963.           WeaponPreShootEvent event = new WeaponPreShootEvent(player, parentNode, soundsShoot, bulletSpread, leftClick);
  1964.           CSDirector.this.plugin.getServer().getPluginManager().callEvent(event);
  1965.          
  1966.           CSDirector.this.playSoundEffects(player, parentNode, null, false, null, new String[] { event.getSounds() });
  1967.           if (event.isCancelled()) {
  1968.             return;
  1969.           }
  1970.           bulletSpread = event.getBulletSpread();
  1971.           for (int i = 0; i < projSpeed; i++)
  1972.           {
  1973.             Random r = new Random();
  1974.             double yaw = Math.toRadians(-player.getLocation().getYaw() - 90.0F);
  1975.             double pitch = Math.toRadians(-player.getLocation().getPitch());
  1976.             double[] spread = { 1.0D, 1.0D, 1.0D };
  1977.             for (int t = 0; t < 3; t++) {
  1978.               spread[t] = ((r.nextDouble() - r.nextDouble()) * bulletSpread * 0.1D);
  1979.             }
  1980.             double x = Math.cos(pitch) * Math.cos(yaw) + spread[0];
  1981.             double y = Math.sin(pitch) + spread[1];
  1982.             double z = -Math.sin(yaw) * Math.cos(pitch) + spread[2];
  1983.             Vector dirVel = new Vector(x, y, z);
  1984.             if ((projLoc != null) && ((projLoc.equalsIgnoreCase("grenade")) || (projLoc.equalsIgnoreCase("flare"))))
  1985.             {
  1986.               CSDirector.this.launchGrenade(player, parentNode, timer, dirVel.multiply(setOnFire), null, 0);
  1987.             }
  1988.             else if (projLoc.equalsIgnoreCase("energy"))
  1989.             {
  1990.               PermissionAttachment attachment = player.addAttachment(CSDirector.this.plugin);
  1991.               attachment.setPermission("nocheatplus", true);
  1992.               attachment.setPermission("anticheat.check.exempt", true);
  1993.              
  1994.               String proOre = CSDirector.this.getString(parentNode + ".Shooting.Projectile_Subtype");
  1995.               if (proOre == null)
  1996.               {
  1997.                 player.sendMessage(CSDirector.this.heading + "The weapon '" + parentNode + "' does not have a value for 'Projectile_Subtype'.");
  1998.                 return;
  1999.               }
  2000.               String[] proInfo = proOre.split("-");
  2001.               if (proInfo.length != 4)
  2002.               {
  2003.                 player.sendMessage(CSDirector.this.heading + "The value provided for 'Projectile_Subtype' of the weapon '" + parentNode + "' has an incorrect format.");
  2004.                 return;
  2005.               }
  2006.               int wallLimit = 0;
  2007.              
  2008.               int hitCount = 0;
  2009.               int wallCount = 0;
  2010.               try
  2011.               {
  2012.                 int range = Integer.valueOf(proInfo[0]).intValue();
  2013.                 int hitLimit = Integer.valueOf(proInfo[3]).intValue();
  2014.                 if (proInfo[2].equalsIgnoreCase("all")) {
  2015.                   wallLimit = -1;
  2016.                 } else if (!proInfo[2].equalsIgnoreCase("none")) {
  2017.                   wallLimit = Integer.valueOf(proInfo[2]).intValue();
  2018.                 }
  2019.                 radius = Double.valueOf(proInfo[1]).doubleValue();
  2020.               }
  2021.               catch (NumberFormatException ex)
  2022.               {
  2023.                 double radius;
  2024.                 player.sendMessage(CSDirector.this.heading + "The value provided for 'Projectile_Subtype' of the weapon '" + parentNode + "' contains an invalid number.");
  2025.                 break;
  2026.               }
  2027.               double radius;
  2028.               int hitLimit;
  2029.               int range;
  2030.               Set<Block> hitBlocks = new HashSet();
  2031.               Set<Integer> hitMobs = new HashSet();
  2032.               Vector vecShift = dirVel.normalize().multiply(radius);
  2033.               Location locStart = player.getEyeLocation();
  2034.               for (double k = 0.0D; k < range; k += radius)
  2035.               {
  2036.                 locStart.add(vecShift);
  2037.                 Block hitBlock = locStart.getBlock();
  2038.                 if (hitBlock.getType() == Material.AIR)
  2039.                 {
  2040.                   FallingBlock tempEnt = player.getWorld().spawnFallingBlock(locStart, 0, (byte)0);
  2041.                   for (Entity ent : tempEnt.getNearbyEntities(radius, radius, radius)) {
  2042.                     if (((ent instanceof LivingEntity)) && (ent != player) && (!hitMobs.contains(Integer.valueOf(ent.getEntityId()))) && (!ent.isDead()))
  2043.                     {
  2044.                       if ((ent instanceof Player))
  2045.                       {
  2046.                         ent.setMetadata("CS_Energy", new FixedMetadataValue(CSDirector.this.plugin, parentNode));
  2047.                         ((LivingEntity)ent).damage(0.0D, player);
  2048.                       }
  2049.                       else
  2050.                       {
  2051.                         CSDirector.this.dealDamage(player, (LivingEntity)ent, null, parentNode);
  2052.                       }
  2053.                       hitMobs.add(Integer.valueOf(ent.getEntityId()));
  2054.                       hitCount++;
  2055.                       if ((hitLimit != 0) && (hitCount >= hitLimit)) {
  2056.                         break;
  2057.                       }
  2058.                     }
  2059.                   }
  2060.                   tempEnt.remove();
  2061.                 }
  2062.                 else if ((wallLimit != -1) && (!hitBlocks.contains(hitBlock)))
  2063.                 {
  2064.                   wallCount++;
  2065.                   if (wallCount > wallLimit) {
  2066.                     break;
  2067.                   }
  2068.                   hitBlocks.add(hitBlock);
  2069.                 }
  2070.               }
  2071.               CSDirector.this.callShootEvent(player, null, parentNode);
  2072.               CSDirector.this.playSoundEffects(player, parentNode, ".Shooting.Sounds_Projectile", false, null, new String[0]);
  2073.              
  2074.               player.removeAttachment(attachment);
  2075.             }
  2076.             else if (projLoc.equalsIgnoreCase("splash"))
  2077.             {
  2078.               ThrownPotion splashPot = (ThrownPotion)player.getWorld().spawn(dragRem, ThrownPotion.class);
  2079.               ItemStack potType = CSDirector.this.csminion.parseItemStack(CSDirector.this.getString(parentNode + ".Shooting.Projectile_Subtype"));
  2080.               if (potType != null) {
  2081.                 try
  2082.                 {
  2083.                   splashPot.setItem(potType);
  2084.                 }
  2085.                 catch (IllegalArgumentException ex)
  2086.                 {
  2087.                   player.sendMessage(CSDirector.this.heading + "The value for 'Projectile_Subtype' of weapon '" + parentNode + "' is not a splash potion!");
  2088.                 }
  2089.               }
  2090.               if (this.val$setOnFire) {
  2091.                 splashPot.setFireTicks(6000);
  2092.               }
  2093.               if (this.val$noBulletDrop) {
  2094.                 CSDirector.this.noArcInArchery(splashPot, dirVel.multiply(setOnFire));
  2095.               }
  2096.               splashPot.setShooter(player);
  2097.               splashPot.setMetadata("projParentNode", new FixedMetadataValue(CSDirector.this.plugin, parentNode));
  2098.               splashPot.setVelocity(dirVel.multiply(setOnFire));
  2099.               CSDirector.this.callShootEvent(player, splashPot, parentNode);
  2100.               if (this.val$dragRem != null) {
  2101.                 CSDirector.this.prepareTermination(splashPot, Boolean.parseBoolean(this.val$dragRem[1]), Long.valueOf(this.val$dragRem[0]));
  2102.               }
  2103.             }
  2104.             else
  2105.             {
  2106.               Projectile snowball;
  2107.               Projectile snowball;
  2108.               if (projectile_type.equalsIgnoreCase("arrow"))
  2109.               {
  2110.                 snowball = (Projectile)player.getWorld().spawnEntity(dragRem, EntityType.ARROW);
  2111.               }
  2112.               else if (projectile_type.equalsIgnoreCase("egg"))
  2113.               {
  2114.                 Projectile snowball = (Projectile)player.getWorld().spawnEntity(dragRem, EntityType.EGG);
  2115.                 snowball.setMetadata("CS_Hardboiled", new FixedMetadataValue(CSDirector.this.plugin, Boolean.valueOf(true)));
  2116.               }
  2117.               else if (projectile_type.equalsIgnoreCase("fireball"))
  2118.               {
  2119.                 Projectile snowball = player.launchProjectile(LargeFireball.class);
  2120.                 if (Boolean.parseBoolean(CSDirector.this.getString(parentNode + ".Shooting.Projectile_Subtype"))) {
  2121.                   snowball.setMetadata("CS_NoDeflect", new FixedMetadataValue(CSDirector.this.plugin, Boolean.valueOf(true)));
  2122.                 }
  2123.               }
  2124.               else
  2125.               {
  2126.                 Projectile snowball;
  2127.                 if (projectile_type.equalsIgnoreCase("witherskull")) {
  2128.                   snowball = player.launchProjectile(WitherSkull.class);
  2129.                 } else {
  2130.                   snowball = (Projectile)player.getWorld().spawnEntity(dragRem, EntityType.SNOWBALL);
  2131.                 }
  2132.               }
  2133.               if (this.val$setOnFire) {
  2134.                 snowball.setFireTicks(6000);
  2135.               }
  2136.               if (this.val$noBulletDrop) {
  2137.                 CSDirector.this.noArcInArchery(snowball, dirVel.multiply(setOnFire));
  2138.               }
  2139.               snowball.setShooter(player);
  2140.               snowball.setVelocity(dirVel.multiply(setOnFire));
  2141.               snowball.setMetadata("projParentNode", new FixedMetadataValue(CSDirector.this.plugin, parentNode));
  2142.               CSDirector.this.callShootEvent(player, snowball, parentNode);
  2143.               CSDirector.this.playSoundEffects(snowball, parentNode, ".Shooting.Sounds_Projectile", false, null, new String[0]);
  2144.               if (this.val$dragRem != null) {
  2145.                 CSDirector.this.prepareTermination(snowball, Boolean.parseBoolean(this.val$dragRem[1]), Long.valueOf(this.val$dragRem[0]));
  2146.               }
  2147.             }
  2148.           }
  2149.         }
  2150.       }, Long.valueOf(burstDelay * burst).longValue() + 1L);
  2151.       if ((oneTime) && (burst == 0) && ((deviceType == null) || ((!deviceType.equalsIgnoreCase("remote")) && (!deviceType.equalsIgnoreCase("trap"))))) {
  2152.         this.csminion.oneTime(player);
  2153.       }
  2154.       String user = player.getName();
  2155.       Collection<Integer> values = (Collection)this.burst_task_IDs.get(user);
  2156.       if (values == null)
  2157.       {
  2158.         values = new ArrayList();
  2159.         this.burst_task_IDs.put(user, values);
  2160.       }
  2161.       values.add(Integer.valueOf(task_ID));
  2162.     }
  2163.   }
  2164.  
  2165.   public void noArcInArchery(final Projectile proj, final Vector direction)
  2166.   {
  2167.     Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable()
  2168.     {
  2169.       public void run()
  2170.       {
  2171.         if (!proj.isDead())
  2172.         {
  2173.           proj.setVelocity(direction);
  2174.           CSDirector.this.noArcInArchery(proj, direction);
  2175.         }
  2176.       }
  2177.     }, 1L);
  2178.   }
  2179.  
  2180.   public void callShootEvent(Player player, Entity objProj, String weaponTitle)
  2181.   {
  2182.     WeaponShootEvent event = new WeaponShootEvent(player, objProj, weaponTitle);
  2183.     getServer().getPluginManager().callEvent(event);
  2184.   }
  2185.  
  2186.   public void reloadAnimation(final Player player, final String parent_node, boolean... reloadStart)
  2187.   {
  2188.     if ((!getBoolean(parent_node + ".Reload.Enable")) || (player.hasMetadata("markOfTheReload"))) {
  2189.       return;
  2190.     }
  2191.     String playerName = player.getName();
  2192.     if (this.delayed_reload_IDs.containsKey(playerName))
  2193.     {
  2194.       Bukkit.getScheduler().cancelTask(((Integer)this.delayed_reload_IDs.get(playerName)).intValue());
  2195.       this.delayed_reload_IDs.remove(playerName);
  2196.     }
  2197.     int relDuration = getInt(parent_node + ".Reload.Reload_Duration");
  2198.     ItemStack held = player.getItemInHand();
  2199.     boolean isStart = reloadStart.length == 0;
  2200.     final boolean takeAsMag = getBoolean(parent_node + ".Reload.Take_Ammo_As_Magazine");
  2201.     final boolean takeAmmo = getBoolean(parent_node + ".Reload.Take_Ammo_On_Reload");
  2202.     final boolean reloadIndie = getBoolean(parent_node + ".Reload.Reload_Bullets_Individually");
  2203.     final boolean ammoEnable = getBoolean(parent_node + ".Ammo.Enable");
  2204.     final String ammoInfo = getString(parent_node + ".Ammo.Ammo_Item_ID");
  2205.     int openTime = getInt(parent_node + ".Firearm_Action.Open_Duration");
  2206.     final int closeTime = getInt(parent_node + ".Firearm_Action.Close_Duration") + getInt(parent_node + ".Firearm_Action.Reload_Close_Delay");
  2207.     boolean akimboSingleReload = false;
  2208.    
  2209.     String reloadSound = ".Reload.Sounds_Reloading";
  2210.     final boolean dualWield = isDualWield(player, parent_node, held);
  2211.     final int reloadAmt = dualWield ? getReloadAmount(player, parent_node, held) * 2 : getReloadAmount(player, parent_node, held);
  2212.     final String replacer = dualWield ? reloadAmt / 2 + " | " + reloadAmt / 2 : String.valueOf(reloadAmt);
  2213.     String actionType = dualWield ? null : getString(parent_node + ".Firearm_Action.Type");
  2214.     if (reloadAmt <= 0)
  2215.     {
  2216.       player.sendMessage(this.heading + "The weapon '" + parent_node + "' is using the Reload module, but is missing a valid value for 'Reload_Amount'.");
  2217.       return;
  2218.     }
  2219.     if ((getBoolean(parent_node + ".Reload.Destroy_When_Empty")) && (held != null) && (held.getType() != Material.AIR) && (held.hasItemMeta()))
  2220.     {
  2221.       if (getAmmoBetweenBrackets(player, parent_node, held) == 0)
  2222.       {
  2223.         boolean validAction = (actionType == null) || (actionType.equalsIgnoreCase("slide")) || (actionType.equalsIgnoreCase("break")) || (actionType.equalsIgnoreCase("revolver"));
  2224.         if ((validAction) || (!held.getItemMeta().getDisplayName().contains("?"))) {
  2225.           player.setItemInHand(null);
  2226.         }
  2227.       }
  2228.       return;
  2229.     }
  2230.     if ((getBoolean("Merged_Reload.Disable")) && (held.getAmount() > 1))
  2231.     {
  2232.       String deniedMsg = getString("Merged_Reload.Message_Denied");
  2233.       if (deniedMsg != null) {
  2234.         player.sendMessage(deniedMsg);
  2235.       }
  2236.       playSoundEffects(player, "Merged_Reload", "Sounds_Denied", false, null, new String[0]);
  2237.       return;
  2238.     }
  2239.     boolean boltAct = false;
  2240.     final boolean pumpAct = (actionType != null) && (actionType.equalsIgnoreCase("pump"));
  2241.     boolean breakAct = false;
  2242.     boolean slide = false;
  2243.     if (actionType != null) {
  2244.       if ((actionType.equalsIgnoreCase("break")) || (actionType.equalsIgnoreCase("revolver"))) {
  2245.         breakAct = true;
  2246.       } else if (actionType.equalsIgnoreCase("slide")) {
  2247.         slide = true;
  2248.       } else if ((actionType.equalsIgnoreCase("bolt")) || (actionType.equalsIgnoreCase("lever"))) {
  2249.         boltAct = true;
  2250.       }
  2251.     }
  2252.     final boolean finalBreakAct = breakAct;
  2253.    
  2254.     boolean isSwitched = switchedTheItem(player, parent_node);
  2255.     boolean isOutOfAmmo = (takeAmmo) && (ammoEnable) && (!this.csminion.containsItemStack(player, ammoInfo, 1, parent_node));
  2256.     if ((isSwitched) || (isOutOfAmmo))
  2257.     {
  2258.       removeInertReloadTag(player, 0, true);
  2259.       if (isOutOfAmmo)
  2260.       {
  2261.         player.removeMetadata("markOfTheReload", this);
  2262.         if ((boltAct) && (!held.getItemMeta().getDisplayName().contains("?")) && (!held.getItemMeta().getDisplayName().contains("�0"))) {
  2263.           correctBoltPosition(player, parent_node, false, closeTime, false, true, pumpAct, false);
  2264.         }
  2265.       }
  2266.       return;
  2267.     }
  2268.     if (!dualWield)
  2269.     {
  2270.       String attachType = getAttachment(parent_node, held)[0];
  2271.       String displayName = held.getItemMeta().getDisplayName();
  2272.       boolean isAccessory = (attachType != null) && (attachType.equalsIgnoreCase("accessory"));
  2273.       boolean boltFull = (boltAct) && (displayName.contains("? �" + (reloadAmt - 1))) && (!isAccessory);
  2274.       if (boltFull)
  2275.       {
  2276.         player.removeMetadata("markOfTheReload", this);
  2277.         return;
  2278.       }
  2279.       if ((displayName.contains("�" + reloadAmt + "�")) || ((isAccessory) && (displayName.contains(reloadAmt + "�"))) || ((attachType != null) && (attachType.equalsIgnoreCase("main")) && (displayName.contains("�" + reloadAmt))))
  2280.       {
  2281.         if (finalBreakAct) {
  2282.           checkBoltPosition(player, parent_node);
  2283.         } else if (!displayName.contains("?")) {
  2284.           correctBoltPosition(player, parent_node, false, closeTime, false, true, pumpAct, false);
  2285.         }
  2286.         player.removeMetadata("markOfTheReload", this);
  2287.         return;
  2288.       }
  2289.       if ((slide) && (displayName.contains("?")) && (openTime > 0))
  2290.       {
  2291.         correctBoltPosition(player, parent_node, true, openTime, true, false, false, false);
  2292.         return;
  2293.       }
  2294.       if ((!pumpAct) && (!slide) && (!isAccessory))
  2295.       {
  2296.         if ((!finalBreakAct) && ((displayName.contains("?")) || (displayName.contains("?"))))
  2297.         {
  2298.           correctBoltPosition(player, parent_node, true, openTime, true, false, false, false);
  2299.           return;
  2300.         }
  2301.         if (displayName.contains("?")) {
  2302.           correctBoltPosition(player, parent_node, true, openTime, true, false, false, false);
  2303.         }
  2304.       }
  2305.     }
  2306.     else
  2307.     {
  2308.       int[] ammoReading = grabDualAmmo(held, parent_node);
  2309.       if (ammoReading[0] + ammoReading[1] >= reloadAmt)
  2310.       {
  2311.         player.removeMetadata("markOfTheReload", this);
  2312.         return;
  2313.       }
  2314.       boolean oneIsFull = (ammoReading[0] == reloadAmt / 2) || (ammoReading[1] == reloadAmt / 2);
  2315.       boolean oneAmmoOnly = (takeAmmo) && (ammoEnable) && (this.csminion.countItemStacks(player, ammoInfo, parent_node) == 1);
  2316.       if ((!reloadIndie) && ((oneIsFull) || (oneAmmoOnly)))
  2317.       {
  2318.         relDuration = getInt(parent_node + ".Reload.Dual_Wield.Single_Reload_Duration");
  2319.         reloadSound = ".Reload.Dual_Wield.Sounds_Single_Reload";
  2320.         akimboSingleReload = true;
  2321.       }
  2322.     }
  2323.     terminateReload(player);
  2324.     removeInertReloadTag(player, 0, true);
  2325.     unscopePlayer(player, new boolean[0]);
  2326.    
  2327.     player.setMetadata("markOfTheReload", new FixedMetadataValue(this, Boolean.valueOf(true)));
  2328.    
  2329.     terminateAllBursts(player);
  2330.     if (!held.getItemMeta().getDisplayName().contains("?")) {
  2331.       this.csminion.setItemName(held, held.getItemMeta().getDisplayName() + '?');
  2332.     }
  2333.     if ((reloadIndie) && (isStart)) {
  2334.       relDuration += getInt(parent_node + ".Reload.First_Reload_Delay");
  2335.     }
  2336.     int shootReloadBuffer = getInt(parent_node + ".Reload.Shoot_Reload_Buffer");
  2337.     if (shootReloadBuffer > 0)
  2338.     {
  2339.       Map<Integer, Long> map = (Map)this.last_shot_list.get(playerName);
  2340.       if (map != null)
  2341.       {
  2342.         Long lastShot = (Long)map.get(Integer.valueOf(player.getInventory().getHeldItemSlot()));
  2343.         if (lastShot != null)
  2344.         {
  2345.           int ticksPassed = (int)((System.currentTimeMillis() - lastShot.longValue()) / 50L);
  2346.           int ticksToWait = shootReloadBuffer - ticksPassed;
  2347.           if (ticksToWait > 0) {
  2348.             relDuration += ticksToWait;
  2349.           }
  2350.         }
  2351.       }
  2352.     }
  2353.     WeaponReloadEvent event = new WeaponReloadEvent(player, parent_node, getString(parent_node + reloadSound), relDuration);
  2354.     this.plugin.getServer().getPluginManager().callEvent(event);
  2355.    
  2356.     final String soundsReload = event.getSounds();
  2357.     relDuration = event.getReloadDuration();
  2358.     if (event.getReloadSpeed() != 1.0D)
  2359.     {
  2360.       double reloadSpeed = event.getReloadSpeed();
  2361.       relDuration = (int)(relDuration * reloadSpeed);
  2362.       if (!reloadIndie) {
  2363.         playSoundEffectsScaled(player, parent_node, null, true, reloadSpeed, new String[] { soundsReload });
  2364.       }
  2365.     }
  2366.     else if (!reloadIndie)
  2367.     {
  2368.       playSoundEffects(player, parent_node, null, true, null, new String[] { soundsReload });
  2369.     }
  2370.     final int reloadShootDelay = akimboSingleReload ? getInt(parent_node + ".Reload.Dual_Wield.Single_Reload_Shoot_Delay") : getInt(parent_node + ".Reload.Reload_Shoot_Delay");
  2371.    
  2372.     int task_ID = Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable()
  2373.     {
  2374.       public void run()
  2375.       {
  2376.         if ((takeAmmo) && (ammoEnable) && (!CSDirector.this.csminion.containsItemStack(player, ammoInfo, 1, parent_node)))
  2377.         {
  2378.           CSDirector.this.removeInertReloadTag(player, 0, true);
  2379.           return;
  2380.         }
  2381.         CSDirector.this.terminateReload(player);
  2382.         if (CSDirector.this.switchedTheItem(player, parent_node)) {
  2383.           return;
  2384.         }
  2385.         ItemStack item = player.getInventory().getItemInHand();
  2386.         if (item.getItemMeta().getDisplayName().contains("?"))
  2387.         {
  2388.           CSDirector.this.csminion.givePotionEffects(player, parent_node, ".Potion_Effects.Potion_Effect_Shooter", "reload");
  2389.           CSDirector.this.removeInertReloadTag(player, 0, true);
  2390.           int currentAmmo = CSDirector.this.getAmmoBetweenBrackets(player, parent_node, item);
  2391.           if ((takeAmmo) && (ammoEnable))
  2392.           {
  2393.             if (reloadIndie)
  2394.             {
  2395.               if (!dualWield)
  2396.               {
  2397.                 currentAmmo++;
  2398.                 CSDirector.this.csminion.replaceBrackets(item, String.valueOf(currentAmmo), parent_node);
  2399.               }
  2400.               else
  2401.               {
  2402.                 int[] ammoReading = CSDirector.this.grabDualAmmo(item, parent_node);
  2403.                 int leftGun = ammoReading[0];
  2404.                 int rightGun = ammoReading[1];
  2405.                 if ((leftGun == reloadAmt / 2) || (leftGun > rightGun)) {
  2406.                   rightGun++;
  2407.                 } else if ((rightGun == reloadAmt / 2) || (rightGun > leftGun) || (leftGun == rightGun)) {
  2408.                   leftGun++;
  2409.                 }
  2410.                 CSDirector.this.csminion.replaceBrackets(item, String.valueOf(leftGun + " | " + rightGun), parent_node);
  2411.               }
  2412.               CSDirector.this.reloadShootDelay(player, parent_node, player.getInventory().getHeldItemSlot(), reloadShootDelay, new String[0]);
  2413.               CSDirector.this.playSoundEffects(player, parent_node, null, false, null, new String[] { soundsReload });
  2414.               CSDirector.this.csminion.removeNamedItem(player, ammoInfo, 1, parent_node, false);
  2415.              
  2416.               WeaponReloadCompleteEvent event = new WeaponReloadCompleteEvent(player, parent_node);
  2417.               CSDirector.this.plugin.getServer().getPluginManager().callEvent(event);
  2418.              
  2419.               CSDirector.this.reloadAnimation(player, parent_node, new boolean[] { false });
  2420.               return;
  2421.             }
  2422.             if (!takeAsMag)
  2423.             {
  2424.               int invAmmo = CSDirector.this.csminion.countItemStacks(player, ammoInfo, parent_node);
  2425.               int fillAmt = reloadAmt - currentAmmo;
  2426.               currentAmmo += invAmmo;
  2427.               if (currentAmmo > reloadAmt) {
  2428.                 currentAmmo = reloadAmt;
  2429.               }
  2430.               if (!dualWield)
  2431.               {
  2432.                 CSDirector.this.csminion.replaceBrackets(item, String.valueOf(currentAmmo), parent_node);
  2433.               }
  2434.               else if (currentAmmo < reloadAmt)
  2435.               {
  2436.                 int[] ammoReading = CSDirector.this.grabDualAmmo(item, parent_node);
  2437.                 int leftGun = ammoReading[0];
  2438.                 int rightGun = ammoReading[1];
  2439.                 while (invAmmo > 0)
  2440.                 {
  2441.                   if ((leftGun == reloadAmt / 2) || (leftGun > rightGun)) {
  2442.                     rightGun++;
  2443.                   } else if ((rightGun == reloadAmt / 2) || (rightGun > leftGun) || (leftGun == rightGun)) {
  2444.                     leftGun++;
  2445.                   }
  2446.                   invAmmo--;
  2447.                 }
  2448.                 CSDirector.this.csminion.replaceBrackets(item, String.valueOf(leftGun + " | " + rightGun), parent_node);
  2449.               }
  2450.               else
  2451.               {
  2452.                 CSDirector.this.csminion.replaceBrackets(item, String.valueOf(replacer), parent_node);
  2453.               }
  2454.               CSDirector.this.csminion.removeNamedItem(player, ammoInfo, fillAmt, parent_node, false);
  2455.             }
  2456.             else if (!dualWield)
  2457.             {
  2458.               CSDirector.this.csminion.replaceBrackets(item, String.valueOf(replacer), parent_node);
  2459.               CSDirector.this.csminion.removeNamedItem(player, ammoInfo, 1, parent_node, false);
  2460.             }
  2461.             else
  2462.             {
  2463.               int invAmmo = CSDirector.this.csminion.countItemStacks(player, ammoInfo, parent_node);
  2464.               int[] ammoReading = CSDirector.this.grabDualAmmo(item, parent_node);
  2465.               int amtToRemove = 0;
  2466.               for (int i = 0; i < 2; i++) {
  2467.                 if ((ammoReading[i] != reloadAmt / 2) && (invAmmo > 0))
  2468.                 {
  2469.                   ammoReading[i] = (reloadAmt / 2);
  2470.                   amtToRemove++;
  2471.                   invAmmo--;
  2472.                 }
  2473.               }
  2474.               CSDirector.this.csminion.replaceBrackets(item, String.valueOf(ammoReading[0]) + " | " + String.valueOf(ammoReading[1]), parent_node);
  2475.               CSDirector.this.csminion.removeNamedItem(player, ammoInfo, amtToRemove, parent_node, false);
  2476.             }
  2477.             CSDirector.this.reloadShootDelay(player, parent_node, player.getInventory().getHeldItemSlot(), reloadShootDelay, new String[0]);
  2478.             if (finalBreakAct) {
  2479.               CSDirector.this.checkBoltPosition(player, parent_node);
  2480.             } else if (!item.getItemMeta().getDisplayName().contains("? �")) {
  2481.               CSDirector.this.correctBoltPosition(player, parent_node, false, closeTime, false, true, pumpAct, false);
  2482.             }
  2483.             CSDirector.this.removeInertReloadTag(player, 0, true);
  2484.            
  2485.             WeaponReloadCompleteEvent event = new WeaponReloadCompleteEvent(player, parent_node);
  2486.             CSDirector.this.plugin.getServer().getPluginManager().callEvent(event);
  2487.           }
  2488.           else
  2489.           {
  2490.             if (reloadIndie)
  2491.             {
  2492.               if (!dualWield)
  2493.               {
  2494.                 currentAmmo++;
  2495.                 CSDirector.this.csminion.replaceBrackets(item, String.valueOf(currentAmmo), parent_node);
  2496.               }
  2497.               else
  2498.               {
  2499.                 int[] ammoReading = CSDirector.this.grabDualAmmo(item, parent_node);
  2500.                 int leftGun = ammoReading[0];
  2501.                 int rightGun = ammoReading[1];
  2502.                 if ((leftGun == reloadAmt / 2) || (leftGun > rightGun)) {
  2503.                   rightGun++;
  2504.                 } else if ((rightGun == reloadAmt / 2) || (rightGun > leftGun) || (leftGun == rightGun)) {
  2505.                   leftGun++;
  2506.                 }
  2507.                 CSDirector.this.csminion.replaceBrackets(item, String.valueOf(leftGun + " | " + rightGun), parent_node);
  2508.               }
  2509.               CSDirector.this.reloadShootDelay(player, parent_node, player.getInventory().getHeldItemSlot(), reloadShootDelay, new String[0]);
  2510.               CSDirector.this.playSoundEffects(player, parent_node, null, false, null, new String[] { soundsReload });
  2511.              
  2512.               WeaponReloadCompleteEvent event = new WeaponReloadCompleteEvent(player, parent_node);
  2513.               CSDirector.this.plugin.getServer().getPluginManager().callEvent(event);
  2514.              
  2515.               CSDirector.this.reloadAnimation(player, parent_node, new boolean[] { false });
  2516.               return;
  2517.             }
  2518.             player.removeMetadata("markOfTheReload", CSDirector.this.plugin);
  2519.            
  2520.             CSDirector.this.reloadShootDelay(player, parent_node, player.getInventory().getHeldItemSlot(), reloadShootDelay, new String[0]);
  2521.            
  2522.             CSDirector.this.csminion.replaceBrackets(item, String.valueOf(replacer), parent_node);
  2523.             if (finalBreakAct) {
  2524.               CSDirector.this.checkBoltPosition(player, parent_node);
  2525.             } else if (!item.getItemMeta().getDisplayName().contains("? �")) {
  2526.               CSDirector.this.correctBoltPosition(player, parent_node, false, closeTime, false, true, pumpAct, false);
  2527.             }
  2528.             WeaponReloadCompleteEvent event = new WeaponReloadCompleteEvent(player, parent_node);
  2529.             CSDirector.this.plugin.getServer().getPluginManager().callEvent(event);
  2530.           }
  2531.         }
  2532.       }
  2533.     }, Long.valueOf(relDuration).longValue());
  2534.    
  2535.     String user = player.getName();
  2536.     Collection<Integer> values_reload = (Collection)this.global_reload_IDs.get(user);
  2537.     if (values_reload == null)
  2538.     {
  2539.       values_reload = new ArrayList();
  2540.       this.global_reload_IDs.put(user, values_reload);
  2541.     }
  2542.     values_reload.add(Integer.valueOf(task_ID));
  2543.   }
  2544.  
  2545.   public void reloadShootDelay(final Player player, String parentNode, int gunSlot, int delay, String... customTag)
  2546.   {
  2547.     if (delay < 1) {
  2548.       return;
  2549.     }
  2550.     final String playerName = player.getName();
  2551.     Map<String, Integer> tagsAndDelays = (Map)this.delay_list.get(playerName);
  2552.     if (tagsAndDelays == null)
  2553.     {
  2554.       tagsAndDelays = new HashMap();
  2555.       this.delay_list.put(playerName, tagsAndDelays);
  2556.     }
  2557.     final String metadataTag = (customTag.length > 1 ? customTag[1] : parentNode) + (customTag.length > 0 ? customTag[0] : "reloadShootDelay") + gunSlot;
  2558.     Integer prevTaskID = (Integer)tagsAndDelays.get(metadataTag);
  2559.     if (prevTaskID != null) {
  2560.       Bukkit.getScheduler().cancelTask(prevTaskID.intValue());
  2561.     }
  2562.     player.setMetadata(metadataTag, new FixedMetadataValue(this, Boolean.valueOf(true)));
  2563.    
  2564.     int newTaskID = Bukkit.getScheduler().scheduleSyncDelayedTask(this.plugin, new Runnable()
  2565.     {
  2566.       public void run()
  2567.       {
  2568.         player.removeMetadata(metadataTag, CSDirector.this.plugin);
  2569.        
  2570.         Map<String, Integer> tagsAndDelays = (Map)CSDirector.this.delay_list.get(playerName);
  2571.         if (tagsAndDelays != null) {
  2572.           tagsAndDelays.remove(metadataTag);
  2573.         }
  2574.       }
  2575.     }, Long.valueOf(delay).longValue());
  2576.    
  2577.     tagsAndDelays.put(metadataTag, Integer.valueOf(newTaskID));
  2578.   }
  2579.  
  2580.   public void projectileExplosion(final Entity objProj, final String parent_node, boolean grenade, final Player player, final boolean landmine, final boolean rde, final Location loc, final Block c4, final boolean trap, final int cTimes)
  2581.   {
  2582.     if ((!getBoolean(parent_node + ".Explosions.Enable")) || ((!rde) && (!this.csminion.regionCheck(objProj, parent_node)))) {
  2583.       return;
  2584.     }
  2585.     int delay = grenade ? 0 : getInt(parent_node + ".Explosions.Explosion_Delay");
  2586.    
  2587.     Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable()
  2588.     {
  2589.       public void run()
  2590.       {
  2591.         Location location = null;
  2592.         World world = null;
  2593.         if (!rde)
  2594.         {
  2595.           world = objProj.getWorld();
  2596.           location = objProj.getLocation().getBlock().getLocation().add(0.5D, 0.5D, 0.5D);
  2597.           if (((objProj instanceof WitherSkull)) || ((objProj instanceof LargeFireball)))
  2598.           {
  2599.             BlockIterator checker = new BlockIterator(world, objProj.getLocation().toVector(), objProj.getVelocity().normalize().multiply(-1), 0.0D, 4);
  2600.             Block block = null;
  2601.             while (checker.hasNext())
  2602.             {
  2603.               block = checker.next();
  2604.               if (block.getTypeId() == 0)
  2605.               {
  2606.                 location = block.getLocation().add(0.5D, 0.5D, 0.5D);
  2607.                 break;
  2608.               }
  2609.             }
  2610.           }
  2611.           if (landmine) {
  2612.             objProj.remove();
  2613.           }
  2614.         }
  2615.         else if (!trap)
  2616.         {
  2617.           c4.removeMetadata("CS_transformers", CSDirector.this.plugin);
  2618.           c4.setType(Material.AIR);
  2619.           location = loc;
  2620.           world = loc.getWorld();
  2621.         }
  2622.         else
  2623.         {
  2624.           c4.removeMetadata("CS_btrap", CSDirector.this.plugin);
  2625.           location = c4.getRelative(BlockFace.UP).getLocation().add(0.5D, 0.5D, 0.5D);
  2626.           world = c4.getLocation().getWorld();
  2627.         }
  2628.         boolean airstrike = CSDirector.this.getBoolean(parent_node + ".Airstrikes.Enable");
  2629.         boolean cEnable = CSDirector.this.getBoolean(parent_node + ".Cluster_Bombs.Enable");
  2630.         int cOfficialTimes = CSDirector.this.getInt(parent_node + ".Cluster_Bombs.Number_Of_Splits");
  2631.         if ((cEnable) && (!airstrike) && (cTimes < cOfficialTimes))
  2632.         {
  2633.           int cAmount = CSDirector.this.getInt(parent_node + ".Cluster_Bombs.Number_Of_Bomblets");
  2634.           int cSpeed = CSDirector.this.getInt(parent_node + ".Cluster_Bombs.Speed_Of_Bomblets");
  2635.          
  2636.           int timer = CSDirector.this.getInt(parent_node + ".Cluster_Bombs.Delay_Before_Detonation");
  2637.           Random r = new Random();
  2638.          
  2639.           int totalAmount = (int)Math.pow(cAmount, cOfficialTimes);
  2640.           if (totalAmount > 1000)
  2641.           {
  2642.             if (player != null) {
  2643.               player.sendMessage(CSDirector.this.heading + cAmount + " to the power of " + cOfficialTimes + " equates to " + totalAmount + " bomblets and consequent explosions! For your safety, CrackShot does not accept total bomblet amounts of over 1000. Please lower the value for 'Number_Of_Splits' and/or 'Number_Of_Bomblets' for the weapon '" + parent_node + "'.");
  2644.             }
  2645.             return;
  2646.           }
  2647.           for (int i = 0; i < cAmount; i++)
  2648.           {
  2649.             location.setPitch(-(r.nextInt(90) + r.nextInt(90)));
  2650.             location.setYaw(r.nextInt(360));
  2651.             double cSpeedF = cSpeed * ((100 - (r.nextInt(25) - r.nextInt(25))) * 0.001D);
  2652.             CSDirector.this.launchGrenade(player, parent_node, timer, location.getDirection().multiply(cSpeedF), location, cTimes + 1);
  2653.           }
  2654.           CSDirector.this.csminion.giveParticleEffects(null, parent_node, ".Cluster_Bombs.Particle_Release", false, location);
  2655.           CSDirector.this.playSoundEffects(null, parent_node, ".Cluster_Bombs.Sounds_Release", false, location, new String[0]);
  2656.          
  2657.           WeaponExplodeEvent explodeEvent = new WeaponExplodeEvent(player, location, parent_node, true, false);
  2658.           CSDirector.this.plugin.getServer().getPluginManager().callEvent(explodeEvent);
  2659.           return;
  2660.         }
  2661.         boolean shrapEnable = CSDirector.this.getBoolean(parent_node + ".Shrapnel.Enable");
  2662.         if (shrapEnable)
  2663.         {
  2664.           String shrapType = CSDirector.this.getString(parent_node + ".Shrapnel.Block_Type");
  2665.           int shrapAmount = CSDirector.this.getInt(parent_node + ".Shrapnel.Amount");
  2666.           int shrapSpeed = CSDirector.this.getInt(parent_node + ".Shrapnel.Speed");
  2667.          
  2668.           boolean placeBlocks = CSDirector.this.getBoolean(parent_node + ".Shrapnel.Place_Blocks");
  2669.          
  2670.           String[] blockInfo = shrapType.split("~");
  2671.           if (blockInfo.length < 2) {
  2672.             blockInfo = new String[] { blockInfo[0], "0" };
  2673.           }
  2674.           Material blockMat = Material.getMaterial(Integer.valueOf(blockInfo[0]).intValue());
  2675.           if (blockMat == null)
  2676.           {
  2677.             player.sendMessage(CSDirector.this.heading + "'" + shrapType + "' of weapon '" + parent_node + "' is not a valid block-type.");
  2678.             return;
  2679.           }
  2680.           try
  2681.           {
  2682.             secData = Byte.valueOf(blockInfo[1]);
  2683.           }
  2684.           catch (NumberFormatException ex)
  2685.           {
  2686.             Byte secData;
  2687.             player.sendMessage(CSDirector.this.heading + "'" + shrapType + "' of weapon '" + parent_node + "' has an invalid secondary data value."); return;
  2688.           }
  2689.           Byte secData;
  2690.           Random r = new Random();
  2691.           for (int i = 0; i < shrapAmount; i++)
  2692.           {
  2693.             location.setPitch(-(r.nextInt(90) + r.nextInt(90)));
  2694.             location.setYaw(r.nextInt(360));
  2695.             FallingBlock shrapnel = location.getWorld().spawnFallingBlock(location, blockMat, secData.byteValue());
  2696.             if (!placeBlocks) {
  2697.               shrapnel.setMetadata("CS_shrapnel", new FixedMetadataValue(CSDirector.this.plugin, Boolean.valueOf(true)));
  2698.             }
  2699.             shrapnel.setDropItem(false);
  2700.             double shrapSpeedF = shrapSpeed * ((100 - (r.nextInt(25) - r.nextInt(25))) * 0.001D);
  2701.             shrapnel.setVelocity(location.getDirection().multiply(shrapSpeedF));
  2702.           }
  2703.         }
  2704.         WeaponExplodeEvent explodeEvent = new WeaponExplodeEvent(player, location, parent_node, false, false);
  2705.         CSDirector.this.plugin.getServer().getPluginManager().callEvent(explodeEvent);
  2706.        
  2707.         CSDirector.this.csminion.displayFireworks(objProj, parent_node, ".Fireworks.Firework_Explode");
  2708.         boolean ownerNoDam = CSDirector.this.getBoolean(parent_node + ".Explosions.Enable_Owner_Immunity");
  2709.         boolean noDam = CSDirector.this.getBoolean(parent_node + ".Explosions.Explosion_No_Damage");
  2710.         boolean frenFire = CSDirector.this.getBoolean(parent_node + ".Explosions.Enable_Friendly_Fire");
  2711.         boolean noGrief = CSDirector.this.getBoolean(parent_node + ".Explosions.Explosion_No_Grief");
  2712.         boolean isFire = CSDirector.this.getBoolean(parent_node + ".Explosions.Explosion_Incendiary");
  2713.         int boomRadius = CSDirector.this.getInt(parent_node + ".Explosions.Explosion_Radius");
  2714.         if (boomRadius > 20) {
  2715.           boomRadius = 20;
  2716.         }
  2717.         TNTPrimed tnt = (TNTPrimed)location.getWorld().spawn(location, TNTPrimed.class);
  2718.         tnt.setYield(boomRadius);
  2719.         tnt.setIsIncendiary(isFire);
  2720.         tnt.setFuseTicks(0);
  2721.         tnt.setMetadata("CS_Label", new FixedMetadataValue(CSDirector.this.plugin, Boolean.valueOf(true)));
  2722.         tnt.setMetadata("CS_potex", new FixedMetadataValue(CSDirector.this.plugin, parent_node));
  2723.         if (!rde) {
  2724.           tnt.setMetadata("C4_Friendly", new FixedMetadataValue(CSDirector.this.plugin, Boolean.valueOf(true)));
  2725.         }
  2726.         if (noGrief) {
  2727.           tnt.setMetadata("nullify", new FixedMetadataValue(CSDirector.this.plugin, Boolean.valueOf(true)));
  2728.         }
  2729.         if (noDam) {
  2730.           tnt.setMetadata("CS_nodam", new FixedMetadataValue(CSDirector.this.plugin, Boolean.valueOf(true)));
  2731.         }
  2732.         if (player != null)
  2733.         {
  2734.           tnt.setMetadata("CS_pName", new FixedMetadataValue(CSDirector.this.plugin, player.getName()));
  2735.           if (!frenFire) {
  2736.             tnt.setMetadata("CS_ffcheck", new FixedMetadataValue(CSDirector.this.plugin, Boolean.valueOf(true)));
  2737.           }
  2738.           if (ownerNoDam) {
  2739.             tnt.setMetadata("0wner_nodam", new FixedMetadataValue(CSDirector.this.plugin, Boolean.valueOf(true)));
  2740.           }
  2741.         }
  2742.       }
  2743.     }, Long.valueOf(Math.abs(delay)).longValue());
  2744.   }
  2745.  
  2746.   public void prepareTermination(final Entity proj, final boolean remove, Long delay)
  2747.   {
  2748.     Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable()
  2749.     {
  2750.       public void run()
  2751.       {
  2752.         if (remove) {
  2753.           proj.remove();
  2754.         } else {
  2755.           proj.setVelocity(proj.getVelocity().multiply(0.25D));
  2756.         }
  2757.       }
  2758.     }, delay.longValue());
  2759.   }
  2760.  
  2761.   @EventHandler
  2762.   public void onPlayerItemHeld(PlayerItemHeldEvent event)
  2763.   {
  2764.     Player player = event.getPlayer();
  2765.     removeInertReloadTag(player, event.getPreviousSlot(), false);
  2766.     removeInertReloadTag(player, event.getNewSlot(), false);
  2767.     unscopePlayer(player, new boolean[0]);
  2768.     terminateAllBursts(player);
  2769.     terminateReload(player);
  2770.    
  2771.     ItemStack heldItem = player.getInventory().getItem(event.getNewSlot());
  2772.     if (heldItem != null)
  2773.     {
  2774.       String[] pc = itemParentNode(heldItem, player);
  2775.       if ((pc == null) || (!Boolean.valueOf(pc[1]).booleanValue())) {
  2776.         return;
  2777.       }
  2778.       ItemStack weapon = this.csminion.vendingMachine(pc[0]);
  2779.       weapon.setAmount(player.getInventory().getItem(event.getNewSlot()).getAmount());
  2780.       player.getInventory().setItem(event.getNewSlot(), weapon);
  2781.     }
  2782.   }
  2783.  
  2784.   @EventHandler
  2785.   public void onPlayerDisconnect(PlayerQuitEvent event)
  2786.   {
  2787.     Player player = event.getPlayer();
  2788.     removeInertReloadTag(player, 0, true);
  2789.     unscopePlayer(player, new boolean[0]);
  2790.     terminateAllBursts(player);
  2791.     terminateReload(player);
  2792.    
  2793.     String playerName = player.getName();
  2794.     if (this.itembombs.containsKey(playerName))
  2795.     {
  2796.       Map<String, ArrayDeque<Item>> subList = (Map)this.itembombs.get(playerName);
  2797.       ArrayDeque<Item> subSubList;
  2798.       for (Iterator localIterator = subList.values().iterator(); localIterator.hasNext(); !subSubList.isEmpty())
  2799.       {
  2800.         subSubList = (ArrayDeque)localIterator.next();
  2801.         continue;
  2802.         ((Item)subSubList.removeFirst()).remove();
  2803.       }
  2804.       this.itembombs.remove(playerName);
  2805.     }
  2806.     this.delay_list.remove(playerName);
  2807.     this.delayed_reload_IDs.remove(playerName);
  2808.     this.c4_backup.remove(playerName);
  2809.     this.last_shot_list.remove(playerName);
  2810.    
  2811.     this.rpm_ticks.remove(playerName);
  2812.   }
  2813.  
  2814.   @EventHandler(priority=EventPriority.HIGHEST)
  2815.   public void onGunThrow(PlayerDropItemEvent event)
  2816.   {
  2817.     ItemStack trash = event.getItemDrop().getItemStack();
  2818.     String[] pc = itemParentNode(trash, event.getPlayer());
  2819.     if (pc == null) {
  2820.       return;
  2821.     }
  2822.     if (!getBoolean(pc[0] + ".Reload.Enable")) {
  2823.       return;
  2824.     }
  2825.     if (getBoolean(pc[0] + ".Reload.Reload_With_Mouse")) {
  2826.       return;
  2827.     }
  2828.     Player player = event.getPlayer();
  2829.     player.getInventory().getHeldItemSlot();
  2830.     if (!player.hasMetadata("dr0p_authorised"))
  2831.     {
  2832.       event.setCancelled(true);
  2833.       delayedReload(player, pc[0], new long[0]);
  2834.     }
  2835.   }
  2836.  
  2837.   @EventHandler
  2838.   public void onPlayerDeath(PlayerDeathEvent event)
  2839.   {
  2840.     final Player player = event.getEntity();
  2841.     removeInertReloadTag(player, 0, true);
  2842.     unscopePlayer(player, new boolean[0]);
  2843.     terminateAllBursts(player);
  2844.     terminateReload(player);
  2845.    
  2846.     List<ItemStack> newInv = new ArrayList();
  2847.     Iterator<ItemStack> it = event.getDrops().iterator();
  2848.     while (it.hasNext())
  2849.     {
  2850.       ItemStack item = (ItemStack)it.next();
  2851.       if ((item != null) && (itemIsSafe(item)))
  2852.       {
  2853.         String[] parent_node = itemParentNode(item, player);
  2854.         if ((parent_node != null) && (getBoolean(parent_node[0] + ".Abilities.Death_No_Drop")))
  2855.         {
  2856.           newInv.add(item);
  2857.           it.remove();
  2858.         }
  2859.       }
  2860.     }
  2861.     if (!newInv.isEmpty())
  2862.     {
  2863.       final ItemStack[] newStack = (ItemStack[])newInv.toArray(new ItemStack[newInv.size()]);
  2864.       Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable()
  2865.       {
  2866.         public void run()
  2867.         {
  2868.           player.getInventory().setContents(newStack);
  2869.         }
  2870.       });
  2871.     }
  2872.     if (event.getDeathMessage() != null)
  2873.     {
  2874.       String message = event.getDeathMessage().replaceAll("(?<=�).*?(?=�)", "");
  2875.       message = message.replaceAll(" �", "");
  2876.       message = message.replaceAll(String.valueOf('?'), "");
  2877.       message = message.replaceAll("[�???]", "");
  2878.       event.setDeathMessage(message);
  2879.     }
  2880.     if ((event.getEntity().getKiller() instanceof Player))
  2881.     {
  2882.       Player shooter = event.getEntity().getKiller();
  2883.       String parent_node = returnParentNode(shooter);
  2884.       if (parent_node == null) {
  2885.         return;
  2886.       }
  2887.       String msg = getString(parent_node + ".Custom_Death_Message.Normal");
  2888.       if (msg == null) {
  2889.         return;
  2890.       }
  2891.       msg = msg.replaceAll("<shooter>", shooter.getName());
  2892.       msg = msg.replaceAll("<victim>", player.getName());
  2893.       event.setDeathMessage(msg);
  2894.     }
  2895.   }
  2896.  
  2897.   @EventHandler
  2898.   public void clickGun(InventoryClickEvent event)
  2899.   {
  2900.     if ((event.getWhoClicked() instanceof Player))
  2901.     {
  2902.       ItemStack currentItem = event.getCurrentItem();
  2903.       Player player = (Player)event.getWhoClicked();
  2904.       if (event.getSlotType() == InventoryType.SlotType.QUICKBAR)
  2905.       {
  2906.         removeInertReloadTag(player, event.getSlot(), false);
  2907.         unscopePlayer(player, new boolean[0]);
  2908.         terminateAllBursts(player);
  2909.         terminateReload(player);
  2910.       }
  2911.       if ((event.getSlot() != -1) && (currentItem != null))
  2912.       {
  2913.         String[] pc = itemParentNode(currentItem, player);
  2914.         if (pc == null) {
  2915.           return;
  2916.         }
  2917.         if ((event.getInventory().getType() == InventoryType.ANVIL) && (event.getSlot() == 2) && (event.getSlotType() == InventoryType.SlotType.RESULT))
  2918.         {
  2919.           player.playSound(player.getLocation(), Sound.WOOD_CLICK, 0.5F, 2.0F);
  2920.           event.setCancelled(true);
  2921.           return;
  2922.         }
  2923.         if (!Boolean.valueOf(pc[1]).booleanValue()) {
  2924.           return;
  2925.         }
  2926.         ItemStack weapon = this.csminion.vendingMachine(pc[0]);
  2927.         weapon.setAmount(currentItem.getAmount());
  2928.         event.setCurrentItem(weapon);
  2929.       }
  2930.       if (event.getSlot() == 64537)
  2931.       {
  2932.         ItemStack trash = event.getCursor();
  2933.         String[] pc = itemParentNode(trash, player);
  2934.         if (pc == null) {
  2935.           return;
  2936.         }
  2937.         player.setMetadata("dr0p_authorised", new FixedMetadataValue(this, Boolean.valueOf(true)));
  2938.         this.csminion.tempVars(player, "dr0p_authorised", Long.valueOf(1L));
  2939.       }
  2940.     }
  2941.   }
  2942.  
  2943.   public void unscopePlayer(Player player, boolean... manual)
  2944.   {
  2945.     if (player.hasMetadata("ironsights"))
  2946.     {
  2947.       String pName = player.getName();
  2948.       String parentNode = ((MetadataValue)player.getMetadata("ironsights").get(0)).asString();
  2949.       if (manual.length == 0)
  2950.       {
  2951.         WeaponScopeEvent scopeEvent = new WeaponScopeEvent(player, parentNode, false);
  2952.         getServer().getPluginManager().callEvent(scopeEvent);
  2953.         if (scopeEvent.isCancelled()) {
  2954.           return;
  2955.         }
  2956.       }
  2957.       player.removeMetadata("ironsights", this);
  2958.       player.removePotionEffect(PotionEffectType.SPEED);
  2959.       if (player.hasMetadata("night_scoping"))
  2960.       {
  2961.         player.removeMetadata("night_scoping", this);
  2962.         player.removePotionEffect(PotionEffectType.NIGHT_VISION);
  2963.       }
  2964.       if (this.zoomStorage.containsKey(pName))
  2965.       {
  2966.         int[] durAmp = (int[])this.zoomStorage.get(pName);
  2967.         player.addPotionEffect(PotionEffectType.SPEED.createEffect(durAmp[0], durAmp[1]));
  2968.       }
  2969.       this.zoomStorage.remove(pName);
  2970.     }
  2971.   }
  2972.  
  2973.   public void removeInertReloadTag(Player player, int item_slot, boolean no_slot)
  2974.   {
  2975.     ItemStack item = player.getInventory().getItem(item_slot);
  2976.     if (no_slot) {
  2977.       item = player.getInventory().getItemInHand();
  2978.     }
  2979.     if ((item != null) && (itemIsSafe(item)) && (item.getItemMeta().getDisplayName().contains(String.valueOf('?'))))
  2980.     {
  2981.       String cleaner = item.getItemMeta().getDisplayName().replaceAll(String.valueOf('?'), "");
  2982.       if (no_slot) {
  2983.         this.csminion.setItemName(player.getInventory().getItemInHand(), cleaner);
  2984.       } else {
  2985.         this.csminion.setItemName(player.getInventory().getItem(item_slot), cleaner);
  2986.       }
  2987.     }
  2988.   }
  2989.  
  2990.   public boolean switchedTheItem(Player player, String parent_node)
  2991.   {
  2992.     ItemStack item = player.getInventory().getItemInHand();
  2993.     String attachType = getAttachment(parent_node, item)[0];
  2994.     boolean attachment = (attachType != null) && (attachType.equalsIgnoreCase("accessory"));
  2995.     return (item == null) || (!itemIsSafe(item)) || ((!attachment) && (isDifferentItem(item, parent_node)));
  2996.   }
  2997.  
  2998.   public void terminateAllBursts(Player player)
  2999.   {
  3000.     Collection<Integer> values = (Collection)this.burst_task_IDs.get(player.getName());
  3001.     if (values != null) {
  3002.       for (Iterator localIterator = values.iterator(); localIterator.hasNext();)
  3003.       {
  3004.         int taskID = ((Integer)localIterator.next()).intValue();
  3005.         Bukkit.getScheduler().cancelTask(taskID);
  3006.       }
  3007.     }
  3008.     this.burst_task_IDs.remove(player.getName());
  3009.     this.rpm_shots.remove(player.getName());
  3010.   }
  3011.  
  3012.   public void terminateReload(Player player)
  3013.   {
  3014.     String playerName = player.getName();
  3015.     Collection<Integer> values = (Collection)this.global_reload_IDs.get(playerName);
  3016.     if (values != null) {
  3017.       for (Integer value : values) {
  3018.         Bukkit.getScheduler().cancelTask(value.intValue());
  3019.       }
  3020.     }
  3021.     this.global_reload_IDs.remove(playerName);
  3022.     player.removeMetadata("markOfTheReload", this);
  3023.     if (this.delayed_reload_IDs.containsKey(playerName))
  3024.     {
  3025.       Bukkit.getScheduler().cancelTask(((Integer)this.delayed_reload_IDs.get(playerName)).intValue());
  3026.       this.delayed_reload_IDs.remove(playerName);
  3027.     }
  3028.   }
  3029.  
  3030.   public int getAmmoBetweenBrackets(Player player, String parent_node, ItemStack item)
  3031.   {
  3032.     boolean reloadEnable = getBoolean(parent_node + ".Reload.Enable");
  3033.     boolean dualWield = isDualWield(player, parent_node, item);
  3034.     int reloadAmt = getReloadAmount(player, parent_node, item);
  3035.     String replacer = dualWield ? reloadAmt + " | " + reloadAmt : String.valueOf(reloadAmt);
  3036.     if (dualWield) {
  3037.       reloadAmt *= 2;
  3038.     }
  3039.     String attachType = getAttachment(parent_node, item)[0];
  3040.    
  3041.     String bracketInfo = this.csminion.extractReading(item.getItemMeta().getDisplayName());
  3042.     int detectedAmmo = reloadAmt;
  3043.     try
  3044.     {
  3045.       if (attachType != null)
  3046.       {
  3047.         int[] ammoReading = grabDualAmmo(item, parent_node);
  3048.         if (attachType.equalsIgnoreCase("main")) {
  3049.           detectedAmmo = ammoReading[0];
  3050.         } else if (attachType.equalsIgnoreCase("accessory")) {
  3051.           detectedAmmo = ammoReading[1];
  3052.         }
  3053.       }
  3054.       else if (dualWield)
  3055.       {
  3056.         String strInBracks = bracketInfo;
  3057.         strInBracks = strInBracks.replaceAll(" ", "");
  3058.         String[] dualAmmo = strInBracks.split("\\|");
  3059.         if ((dualAmmo[0].equals(String.valueOf('�'))) || (dualAmmo[1].equals(String.valueOf('�')))) {
  3060.           return 125622;
  3061.         }
  3062.         detectedAmmo = Integer.valueOf(dualAmmo[0]).intValue() + Integer.valueOf(dualAmmo[1]).intValue();
  3063.       }
  3064.       else
  3065.       {
  3066.         if ((bracketInfo.equals(String.valueOf('�'))) && (!reloadEnable)) {
  3067.           return 125622;
  3068.         }
  3069.         detectedAmmo = Integer.valueOf(bracketInfo).intValue();
  3070.       }
  3071.     }
  3072.     catch (Exception ex)
  3073.     {
  3074.       this.csminion.replaceBrackets(item, String.valueOf(replacer), parent_node);
  3075.     }
  3076.     if (detectedAmmo > reloadAmt) {
  3077.       this.csminion.replaceBrackets(item, String.valueOf(replacer), parent_node);
  3078.     }
  3079.     return detectedAmmo;
  3080.   }
  3081.  
  3082.   public void executeCommands(LivingEntity player, String parentNode, String childNode, String shooterName, String vicName, String flightTime, String totalDmg, boolean console)
  3083.   {
  3084.     String[] commandList = getString(parentNode + childNode).split("\\|");
  3085.     String[] arrayOfString1;
  3086.     int j = (arrayOfString1 = commandList).length;
  3087.     for (int i = 0; i < j; i++)
  3088.     {
  3089.       String cmd = arrayOfString1[i];
  3090.       if (console) {
  3091.         getServer().dispatchCommand(getServer().getConsoleSender(), variableParser(cmd, shooterName, vicName, flightTime, totalDmg));
  3092.       } else {
  3093.         ((Player)player).performCommand(variableParser(cmd, shooterName, vicName, flightTime, totalDmg));
  3094.       }
  3095.     }
  3096.   }
  3097.  
  3098.   public String variableParser(String filter, String shooter, String victim, String flightTime, String totalDmg)
  3099.   {
  3100.     filter = filter.replaceAll("<shooter>", shooter).replaceAll("<victim>", victim).replaceAll("<damage>", totalDmg).replaceAll("<flight>", flightTime);
  3101.     return filter;
  3102.   }
  3103.  
  3104.   public void sendPlayerMessage(LivingEntity player, String parentNode, String childNode, String shooterName, String vicName, String flightTime, String totalDmg)
  3105.   {
  3106.     String message = getString(parentNode + childNode);
  3107.     if (message == null) {
  3108.       return;
  3109.     }
  3110.     if ((player instanceof Player)) {
  3111.       ((Player)player).sendMessage(variableParser(message, shooterName, vicName, flightTime, totalDmg));
  3112.     }
  3113.   }
  3114.  
  3115.   public boolean spawnEntities(LivingEntity player, String parentNode, String childNode, LivingEntity tamer)
  3116.   {
  3117.     if (!getBoolean(parentNode + ".Spawn_Entity_On_Hit.Enable")) {
  3118.       return false;
  3119.     }
  3120.     String entName = getString(parentNode + ".Spawn_Entity_On_Hit.Mob_Name");
  3121.     String proType = getString(parentNode + ".Shooting.Projectile_Type");
  3122.     boolean targetVictim = getBoolean(parentNode + ".Spawn_Entity_On_Hit.Make_Entities_Target_Victim");
  3123.     boolean noDrop = getBoolean(parentNode + ".Spawn_Entity_On_Hit.Entity_Disable_Drops");
  3124.     int timedDeath = getInt(parentNode + ".Spawn_Entity_On_Hit.Timed_Death");
  3125.     int spawnChance = getInt(parentNode + ".Spawn_Entity_On_Hit.Chance");
  3126.     if (getString(parentNode + childNode) == null) {
  3127.       return false;
  3128.     }
  3129.     if (proType.equalsIgnoreCase("energy"))
  3130.     {
  3131.       printM("For the weapon '" + parentNode + "', the 'energy' projectile-type does not support the Spawn_Entity_On_Hit module.");
  3132.       return false;
  3133.     }
  3134.     Random generator = new Random();
  3135.     int diceRoll = generator.nextInt(100);
  3136.     if (diceRoll > spawnChance) {
  3137.       return false;
  3138.     }
  3139.     String[] entList = getString(parentNode + childNode).split(",");
  3140.     String[] arrayOfString1;
  3141.     int j = (arrayOfString1 = entList).length;
  3142.     for (int i = 0; i < j; i++)
  3143.     {
  3144.       String entity = arrayOfString1[i];
  3145.       String spaceFilter = entity.replace(" ", "");
  3146.       String[] args = spaceFilter.split("-");
  3147.       if (args.length == 4)
  3148.       {
  3149.         int entAmount = 0;
  3150.         try
  3151.         {
  3152.           entAmount = Integer.parseInt(args[3]);
  3153.         }
  3154.         catch (NumberFormatException ex)
  3155.         {
  3156.           printM("'" + entAmount + "' in the node 'EntityType_Baby_Explode_Amount' of weapon '" + parentNode + "' is not a valid number!");
  3157.           break;
  3158.         }
  3159.         for (int i = 0; i < entAmount; i++)
  3160.         {
  3161.           String mobEnum = args[0].toUpperCase();
  3162.           if (args[0].equals("ZOMBIE_VILLAGER")) {
  3163.             mobEnum = "ZOMBIE";
  3164.           } else if (args[0].equals("WITHER_SKELETON")) {
  3165.             mobEnum = "SKELETON";
  3166.           } else if (args[0].equals("TAMED_WOLF")) {
  3167.             mobEnum = "WOLF";
  3168.           }
  3169.           try
  3170.           {
  3171.             entType = EntityType.valueOf(mobEnum);
  3172.           }
  3173.           catch (IllegalArgumentException ex)
  3174.           {
  3175.             EntityType entType;
  3176.             printM("'" + args[0] + "' of weapon '" + parentNode + "' is not a valid entity!");
  3177.             break;
  3178.           }
  3179.           EntityType entType;
  3180.           final LivingEntity spawnedMob = (LivingEntity)player.getWorld().spawnEntity(player.getLocation(), entType);
  3181.           if (Boolean.parseBoolean(args[1])) {
  3182.             if ((spawnedMob instanceof Zombie)) {
  3183.               ((Zombie)spawnedMob).setBaby(true);
  3184.             } else if ((spawnedMob instanceof Creeper)) {
  3185.               ((Creeper)spawnedMob).setPowered(true);
  3186.             } else if ((spawnedMob instanceof Ageable)) {
  3187.               ((Ageable)spawnedMob).setBaby();
  3188.             }
  3189.           }
  3190.           if (args[0].equalsIgnoreCase("ZOMBIE_VILLAGER")) {
  3191.             ((Zombie)spawnedMob).setVillager(true);
  3192.           } else if (args[0].equalsIgnoreCase("WITHER_SKELETON")) {
  3193.             ((Skeleton)spawnedMob).setSkeletonType(Skeleton.SkeletonType.WITHER);
  3194.           } else if ((args[0].equalsIgnoreCase("TAMED_WOLF")) && ((tamer instanceof AnimalTamer))) {
  3195.             ((Wolf)spawnedMob).setOwner((AnimalTamer)tamer);
  3196.           }
  3197.           if (entName != null)
  3198.           {
  3199.             spawnedMob.setCustomName(entName);
  3200.             spawnedMob.setCustomNameVisible(true);
  3201.           }
  3202.           if (Boolean.parseBoolean(args[2])) {
  3203.             spawnedMob.setMetadata("CS_Boomer", new FixedMetadataValue(this, Boolean.valueOf(true)));
  3204.           }
  3205.           if (noDrop) {
  3206.             spawnedMob.setMetadata("CS_NoDrops", new FixedMetadataValue(this, Boolean.valueOf(true)));
  3207.           }
  3208.           if (targetVictim) {
  3209.             spawnedMob.damage(0.0D, player);
  3210.           }
  3211.           if (timedDeath != 0) {
  3212.             Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable()
  3213.             {
  3214.               public void run()
  3215.               {
  3216.                 spawnedMob.damage(400.0D);
  3217.               }
  3218.             }, Long.valueOf(timedDeath).longValue());
  3219.           }
  3220.         }
  3221.       }
  3222.       else
  3223.       {
  3224.         printM("'" + spaceFilter + "' of weapon '" + parentNode + "' has an invalid format!");
  3225.       }
  3226.     }
  3227.     return true;
  3228.   }
  3229.  
  3230.   @EventHandler
  3231.   public void onSpawnedEntityDeath(EntityDeathEvent event)
  3232.   {
  3233.     if (event.getEntity().hasMetadata("CS_Boomer"))
  3234.     {
  3235.       TNTPrimed tnt = (TNTPrimed)event.getEntity().getWorld().spawn(event.getEntity().getLocation(), TNTPrimed.class);
  3236.       tnt.setYield(2.0F);
  3237.       tnt.setFuseTicks(0);
  3238.       tnt.setMetadata("nullify", new FixedMetadataValue(this, Boolean.valueOf(true)));
  3239.     }
  3240.     if (event.getEntity().hasMetadata("CS_NoDrops"))
  3241.     {
  3242.       event.setDroppedExp(0);
  3243.       event.getDrops().clear();
  3244.     }
  3245.   }
  3246.  
  3247.   @EventHandler
  3248.   public void createGunShop(SignChangeEvent event)
  3249.   {
  3250.     String lineOne = event.getLine(0);
  3251.     if (!lineOne.contains("[CS]")) {
  3252.       return;
  3253.     }
  3254.     String filter = lineOne.replaceAll(Pattern.quote("[CS]"), "");
  3255.     try
  3256.     {
  3257.       Integer.valueOf(filter);
  3258.     }
  3259.     catch (NumberFormatException ex)
  3260.     {
  3261.       return;
  3262.     }
  3263.     for (String parent_node : this.parentlist.values()) {
  3264.       if (getBoolean(parent_node + ".SignShops.Enable"))
  3265.       {
  3266.         if ((!event.getPlayer().hasPermission("crackshot.shops." + parent_node)) && (!event.getPlayer().hasPermission("crackshot.shops.all")))
  3267.         {
  3268.           CSMessages.sendMessage(event.getPlayer(), this.heading, CSMessages.Message.NP_STORE_CREATE.getMessage());
  3269.           return;
  3270.         }
  3271.         int gunID = getInt(parent_node + ".SignShops.Sign_Gun_ID");
  3272.         if ((gunID != 0) && (gunID == Integer.valueOf(filter).intValue()))
  3273.         {
  3274.           event.setLine(0, "�fStore No? " + gunID);
  3275.           CSMessages.sendMessage(event.getPlayer(), this.heading, CSMessages.Message.STORE_CREATED.getMessage());
  3276.           break;
  3277.         }
  3278.       }
  3279.     }
  3280.   }
  3281.  
  3282.   public boolean shopEvent(PlayerInteractEvent event)
  3283.   {
  3284.     boolean retVal = false;
  3285.     Sign signState = (Sign)event.getClickedBlock().getState();
  3286.     if (signState.getLine(0).contains("�fStore No?"))
  3287.     {
  3288.       Player player = event.getPlayer();
  3289.       String signLineOne = signState.getLine(0).replaceAll("�fStore No? ", "");
  3290.       for (String parentNode : this.parentlist.values()) {
  3291.         if ((getBoolean(parentNode + ".SignShops.Enable")) && (getString(parentNode + ".SignShops.Price") != null))
  3292.         {
  3293.           int gunID = getInt(parentNode + ".SignShops.Sign_Gun_ID");
  3294.           String priceInfo = getString(parentNode + ".SignShops.Price");
  3295.           String[] signInfo = priceInfo.split("-");
  3296.           try
  3297.           {
  3298.             shopID = Integer.valueOf(signLineOne).intValue();
  3299.           }
  3300.           catch (NumberFormatException ex)
  3301.           {
  3302.             int shopID;
  3303.             break;
  3304.           }
  3305.           int shopID;
  3306.           try
  3307.           {
  3308.             int currency = Integer.valueOf(signInfo[0]).intValue();
  3309.             amount = Integer.valueOf(signInfo[1]).intValue();
  3310.           }
  3311.           catch (NumberFormatException ex)
  3312.           {
  3313.             int amount;
  3314.             player.sendMessage(this.heading + "'Price: " + priceInfo + "' of weapon '" + parentNode + "' does not contain a valid item ID and/or amount!");
  3315.             break;
  3316.           }
  3317.           int amount;
  3318.           int currency;
  3319.           if (gunID == shopID)
  3320.           {
  3321.             boolean creativeMode = player.getGameMode() != GameMode.CREATIVE;
  3322.             if ((creativeMode) || ((!player.hasPermission("crackshot.store." + parentNode)) && (!player.hasPermission("crackshot.store.all")))) {
  3323.               event.setCancelled(true);
  3324.             }
  3325.             if ((player.hasPermission("crackshot.buy." + parentNode)) || (player.hasPermission("crackshot.buy.all")))
  3326.             {
  3327.               if (!creativeMode) {
  3328.                 break;
  3329.               }
  3330.               if (this.csminion.countItemStacks(player, signInfo[0], parentNode) < amount)
  3331.               {
  3332.                 CSMessages.sendMessage(player, this.heading, CSMessages.Message.STORE_CANNOT_AFFORD.getMessage());
  3333.                
  3334.                 CSMessages.sendMessage(player, this.heading, CSMessages.Message.STORE_ITEMS_NEEDED.getMessage(amount, String.valueOf(Material.getMaterial(currency))));
  3335.                 break;
  3336.               }
  3337.               if (player.getInventory().firstEmpty() == -1) {
  3338.                 break;
  3339.               }
  3340.               this.csminion.removeNamedItem(player, signInfo[0], amount, parentNode, true);
  3341.               this.csminion.getWeaponCommand(player, parentNode, false, null, false, false);
  3342.              
  3343.               String milk = getString(parentNode + ".Item_Information.Item_Name");
  3344.              
  3345.               CSMessages.sendMessage(player, this.heading, CSMessages.Message.STORE_PURCHASED.getMessage(milk));
  3346.               retVal = true;
  3347.              
  3348.               break;
  3349.             }
  3350.             CSMessages.sendMessage(player, this.heading, CSMessages.Message.NP_STORE_PURCHASE.getMessage());
  3351.            
  3352.             break;
  3353.           }
  3354.         }
  3355.       }
  3356.     }
  3357.     return retVal;
  3358.   }
  3359.  
  3360.   public boolean checkBoltPosition(Player player, String parent_node)
  3361.   {
  3362.     ItemStack item = player.getInventory().getItemInHand();
  3363.     String actType = getString(parent_node + ".Firearm_Action.Type");
  3364.     if ((actType == null) || (isDualWield(player, parent_node, item))) {
  3365.       return false;
  3366.     }
  3367.     String[] validTypes = { "bolt", "lever", "pump", "break", "revolver", "slide" };
  3368.     String[] arrayOfString1;
  3369.     int j = (arrayOfString1 = validTypes).length;
  3370.     for (int i = 0; i < j; i++)
  3371.     {
  3372.       String str = arrayOfString1[i];
  3373.       if (actType.equalsIgnoreCase(str)) {
  3374.         break;
  3375.       }
  3376.       if (str.equals("slide"))
  3377.       {
  3378.         printM("'" + actType + "' of weapon '" + parent_node + "' is not a valid firearm action! The accepted values are slide, bolt, lever, pump, break or revolver!");
  3379.         return false;
  3380.       }
  3381.     }
  3382.     int openTime = getInt(parent_node + ".Firearm_Action.Open_Duration");
  3383.     int closeTime = getInt(parent_node + ".Firearm_Action.Close_Duration");
  3384.     if (!itemIsSafe(item)) {
  3385.       return false;
  3386.     }
  3387.     String itemName = item.getItemMeta().getDisplayName();
  3388.    
  3389.     int chamberPos = itemName.lastIndexOf("�") + 3;
  3390.     char chamber = itemName.charAt(chamberPos);
  3391.     if (chamber == '�') {
  3392.       this.csminion.setItemName(item, itemName.replace("�", "? �"));
  3393.     } else if ((chamber != '?') && (chamber != '?') && (chamber != '?')) {
  3394.       this.csminion.setItemName(item, itemName.substring(0, chamberPos) + '?' + itemName.substring(chamberPos + 1));
  3395.     }
  3396.     int detectedAmmo = getAmmoBetweenBrackets(player, parent_node, item);
  3397.     if ((actType.toLowerCase().contains("break")) || (actType.toLowerCase().contains("revolver")) || (actType.toLowerCase().contains("slide")))
  3398.     {
  3399.       if (detectedAmmo > 0)
  3400.       {
  3401.         if (chamber == '?')
  3402.         {
  3403.           correctBoltPosition(player, parent_node, false, closeTime, false, false, false, true);
  3404.           return true;
  3405.         }
  3406.       }
  3407.       else
  3408.       {
  3409.         reloadAnimation(player, parent_node, new boolean[0]);
  3410.        
  3411.         boolean ammoEnable = getBoolean(parent_node + ".Ammo.Enable");
  3412.         String ammoInfo = getString(parent_node + ".Ammo.Ammo_Item_ID");
  3413.         boolean takeAmmo = getBoolean(parent_node + ".Reload.Take_Ammo_On_Reload");
  3414.         if ((ammoEnable) && (takeAmmo) && (!this.csminion.containsItemStack(player, ammoInfo, 1, parent_node))) {
  3415.           playSoundEffects(player, parent_node, ".Ammo.Sounds_Shoot_With_No_Ammo", false, null, new String[0]);
  3416.         }
  3417.         return true;
  3418.       }
  3419.       return false;
  3420.     }
  3421.     boolean chamberFired = chamber == '?';
  3422.     boolean chamberOpened = chamber == '?';
  3423.     if (chamberFired) {
  3424.       this.csminion.setItemName(item, itemName.replace("?", "?"));
  3425.     }
  3426.     correctBoltPosition(player, parent_node, !chamberOpened, chamberOpened ? closeTime : openTime, detectedAmmo <= 0, false, false, false);
  3427.     return !chamberFired;
  3428.   }
  3429.  
  3430.   public void correctBoltPosition(final Player player, final String parent_node, final boolean boltPull, int delay, final boolean reloadPrep, final boolean reloadFin, final boolean pumpExit, final boolean breakAct)
  3431.   {
  3432.     final String actType = getString(parent_node + ".Firearm_Action.Type");
  3433.     if ((actType == null) || (isDualWield(player, parent_node, player.getItemInHand()))) {
  3434.       return;
  3435.     }
  3436.     String[] validTypes = { "bolt", "lever", "pump", "break", "revolver", "slide" };
  3437.     String[] arrayOfString1;
  3438.     int j = (arrayOfString1 = validTypes).length;
  3439.     for (int i = 0; i < j; i++)
  3440.     {
  3441.       String str = arrayOfString1[i];
  3442.       if (actType.equalsIgnoreCase(str)) {
  3443.         break;
  3444.       }
  3445.       if (str.equals("slide"))
  3446.       {
  3447.         printM("'" + actType + "' of weapon '" + parent_node + "' is not a valid firearm action! The accepted values are slide, bolt, lever, pump, break or revolver!");
  3448.         return;
  3449.       }
  3450.     }
  3451.     final int heldSlot = player.getInventory().getHeldItemSlot();
  3452.     if (player.hasMetadata("fiddling")) {
  3453.       return;
  3454.     }
  3455.     player.setMetadata("fiddling", new FixedMetadataValue(this, Boolean.valueOf(true)));
  3456.    
  3457.     Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable()
  3458.     {
  3459.       public void run()
  3460.       {
  3461.         player.removeMetadata("fiddling", CSDirector.this.plugin);
  3462.         ItemStack item = player.getInventory().getItemInHand();
  3463.         int currentSlot = player.getInventory().getHeldItemSlot();
  3464.         int closeTime = CSDirector.this.getInt(parent_node + ".Firearm_Action.Close_Duration");
  3465.         int closeShootDelay = CSDirector.this.getInt(parent_node + ".Firearm_Action.Close_Shoot_Delay");
  3466.         if (!CSDirector.this.itemIsSafe(item)) {
  3467.           return;
  3468.         }
  3469.         String itemName = item.getItemMeta().getDisplayName();
  3470.         if (CSDirector.this.isDifferentItem(item, parent_node)) {
  3471.           return;
  3472.         }
  3473.         int chamberPos = itemName.lastIndexOf("�") + 3;
  3474.         char chamber = itemName.charAt(chamberPos);
  3475.         if (chamber == '�')
  3476.         {
  3477.           CSDirector.this.csminion.setItemName(item, itemName.replace("�", "? �"));
  3478.           return;
  3479.         }
  3480.         if ((chamber != '?') && (chamber != '?') && (chamber != '?'))
  3481.         {
  3482.           CSDirector.this.csminion.setItemName(item, itemName.substring(0, chamberPos) + '?' + itemName.substring(chamberPos + 1));
  3483.           return;
  3484.         }
  3485.         boolean isAttachment = itemName.contains(String.valueOf('?'));
  3486.         boolean isReloading = itemName.contains(String.valueOf('?'));
  3487.         boolean switchedItems = (CSDirector.this.switchedTheItem(player, parent_node)) || (heldSlot != currentSlot);
  3488.         boolean isCocked = (reloadFin) && (chamber == '?');
  3489.         if ((isAttachment) || (isReloading) || (switchedItems) || (isCocked)) {
  3490.           return;
  3491.         }
  3492.         if (breakAct)
  3493.         {
  3494.           CSDirector.this.playSoundEffects(player, parent_node, ".Firearm_Action.Sound_Close", false, null, new String[0]);
  3495.           CSDirector.this.csminion.setItemName(item, itemName.replaceAll("?", "?"));
  3496.           CSDirector.this.reloadShootDelay(player, parent_node, currentSlot, closeShootDelay, new String[] { "noShooting" });
  3497.          
  3498.           return;
  3499.         }
  3500.         if ((pumpExit) && (chamber == '?'))
  3501.         {
  3502.           CSDirector.this.correctBoltPosition(player, parent_node, true, 0, false, false, false, false);
  3503.           return;
  3504.         }
  3505.         if (reloadPrep)
  3506.         {
  3507.           boolean isBreak = (actType.equalsIgnoreCase("break")) || (actType.equalsIgnoreCase("revolver"));
  3508.           String nameToSet = itemName.replaceAll("?", "?");
  3509.           if (!isBreak) {
  3510.             nameToSet = nameToSet.replaceAll("?", "?");
  3511.           }
  3512.           if (!itemName.contains("?")) {
  3513.             CSDirector.this.csminion.setItemName(item, nameToSet + '?');
  3514.           } else {
  3515.             CSDirector.this.csminion.setItemName(item, nameToSet);
  3516.           }
  3517.           int reloadOpenDelay = CSDirector.this.getInt(parent_node + ".Firearm_Action.Reload_Open_Delay");
  3518.           CSDirector.this.playSoundEffects(player, parent_node, ".Firearm_Action.Sound_Open", reloadOpenDelay > 0, null, new String[0]);
  3519.           if (reloadOpenDelay > 0)
  3520.           {
  3521.             CSDirector.this.delayedReload(player, parent_node, new long[] { Long.valueOf(reloadOpenDelay).longValue() });
  3522.            
  3523.             CSDirector.this.reloadShootDelay(player, parent_node, currentSlot, reloadOpenDelay, new String[] { "noShooting" });
  3524.           }
  3525.           else
  3526.           {
  3527.             CSDirector.this.reloadAnimation(player, parent_node, new boolean[0]);
  3528.           }
  3529.           return;
  3530.         }
  3531.         if (boltPull)
  3532.         {
  3533.           CSDirector.this.playSoundEffects(player, parent_node, ".Firearm_Action.Sound_Open", false, null, new String[0]);
  3534.           CSDirector.this.csminion.setItemName(item, itemName.replaceAll("?", "?"));
  3535.           CSDirector.this.correctBoltPosition(player, parent_node, false, closeTime, false, false, false, false);
  3536.         }
  3537.         else if ((actType.equalsIgnoreCase("slide")) && ((chamber == '?') || (chamber == '?')))
  3538.         {
  3539.           if (chamber == '?') {
  3540.             CSDirector.this.csminion.setItemName(item, itemName.replaceAll("?", "?"));
  3541.           } else {
  3542.             CSDirector.this.csminion.setItemName(item, itemName.replaceAll("?", "?"));
  3543.           }
  3544.           CSDirector.this.playSoundEffects(player, parent_node, ".Firearm_Action.Sound_Close", false, null, new String[0]);
  3545.           CSDirector.this.reloadShootDelay(player, parent_node, currentSlot, closeShootDelay, new String[] { "noShooting" });
  3546.         }
  3547.         else
  3548.         {
  3549.           int detectedAmmo = CSDirector.this.getAmmoBetweenBrackets(player, parent_node, item);
  3550.           if (detectedAmmo > 0)
  3551.           {
  3552.             CSDirector.this.csminion.setItemName(item, itemName.replaceAll("?", "?"));
  3553.             CSDirector.this.playSoundEffects(player, parent_node, ".Firearm_Action.Sound_Close", false, null, new String[0]);
  3554.            
  3555.             CSDirector.this.reloadShootDelay(player, parent_node, currentSlot, closeShootDelay, new String[] { "noShooting" });
  3556.             if (detectedAmmo != 125622) {
  3557.               CSDirector.this.ammoOperation(player, parent_node, detectedAmmo, item);
  3558.             }
  3559.           }
  3560.           else
  3561.           {
  3562.             CSDirector.this.reloadAnimation(player, parent_node, new boolean[0]);
  3563.           }
  3564.         }
  3565.       }
  3566.     }, Long.valueOf(delay).longValue());
  3567.   }
  3568.  
  3569.   public void ammoOperation(Player player, String parent_node, int detectedAmmo, ItemStack item)
  3570.   {
  3571.     boolean ammoEnable = getBoolean(parent_node + ".Ammo.Enable");
  3572.     String ammoInfo = getString(parent_node + ".Ammo.Ammo_Item_ID");
  3573.     boolean takeAmmo = getBoolean(parent_node + ".Ammo.Take_Ammo_Per_Shot");
  3574.    
  3575.     detectedAmmo--;
  3576.     this.csminion.replaceBrackets(item, String.valueOf(detectedAmmo), parent_node);
  3577.     if ((ammoEnable) && (takeAmmo)) {
  3578.       this.csminion.removeNamedItem(player, ammoInfo, 1, parent_node, false);
  3579.     }
  3580.     if (detectedAmmo == 0)
  3581.     {
  3582.       String actType = getString(parent_node + ".Firearm_Action.Type");
  3583.       playSoundEffects(player, parent_node, ".Reload.Sounds_Out_Of_Ammo", false, null, new String[0]);
  3584.       if (!itemIsSafe(item)) {
  3585.         return;
  3586.       }
  3587.       String itemName = item.getItemMeta().getDisplayName();
  3588.       if (actType != null)
  3589.       {
  3590.         if ((actType.equalsIgnoreCase("bolt")) || (actType.equalsIgnoreCase("lever")) || (actType.equalsIgnoreCase("pump")))
  3591.         {
  3592.           if (!itemName.contains("?")) {
  3593.             delayedReload(player, parent_node, new long[0]);
  3594.           }
  3595.         }
  3596.         else if ((actType.equalsIgnoreCase("break")) || (actType.equalsIgnoreCase("revolver")) || (actType.equalsIgnoreCase("slide")))
  3597.         {
  3598.           if ((actType.toLowerCase().contains("slide")) && (itemName.contains("?")))
  3599.           {
  3600.             int openTime = getInt(parent_node + ".Firearm_Action.Open_Duration");
  3601.             if (openTime < 1) {
  3602.               playSoundEffects(player, parent_node, ".Firearm_Action.Sound_Open", false, null, new String[0]);
  3603.             }
  3604.             this.csminion.setItemName(item, itemName.replaceAll("?", "?"));
  3605.           }
  3606.           delayedReload(player, parent_node, new long[0]);
  3607.         }
  3608.       }
  3609.       else {
  3610.         delayedReload(player, parent_node, new long[0]);
  3611.       }
  3612.     }
  3613.   }
  3614.  
  3615.   public boolean ammoSpecOps(Player player, String parentNode, int detectedAmmo, ItemStack item, boolean leftClick)
  3616.   {
  3617.     boolean ammoEnable = getBoolean(parentNode + ".Ammo.Enable");
  3618.     boolean takeAmmo = getBoolean(parentNode + ".Ammo.Take_Ammo_Per_Shot");
  3619.     String ammoInfo = getString(parentNode + ".Ammo.Ammo_Item_ID");
  3620.    
  3621.     int[] ammoReading = grabDualAmmo(item, parentNode);
  3622.     if (leftClick)
  3623.     {
  3624.       if (ammoReading[0] > 0)
  3625.       {
  3626.         int ammoAmount = ammoReading[0] - 1;
  3627.         this.csminion.replaceBrackets(item, ammoAmount + " | " + ammoReading[1], parentNode);
  3628.       }
  3629.       else
  3630.       {
  3631.         playSoundEffects(player, parentNode, ".Reload.Dual_Wield.Sounds_Shoot_With_No_Ammo", false, null, new String[0]);
  3632.         return false;
  3633.       }
  3634.     }
  3635.     else if (ammoReading[1] > 0)
  3636.     {
  3637.       int ammoAmount = ammoReading[1] - 1;
  3638.       this.csminion.replaceBrackets(item, ammoReading[0] + " | " + ammoAmount, parentNode);
  3639.     }
  3640.     else
  3641.     {
  3642.       playSoundEffects(player, parentNode, ".Reload.Dual_Wield.Sounds_Shoot_With_No_Ammo", false, null, new String[0]);
  3643.       return false;
  3644.     }
  3645.     int ammoAmount;
  3646.     if (ammoAmount <= 0) {
  3647.       playSoundEffects(player, parentNode, ".Reload.Sounds_Out_Of_Ammo", false, null, new String[0]);
  3648.     }
  3649.     if ((ammoEnable) && (takeAmmo)) {
  3650.       this.csminion.removeNamedItem(player, ammoInfo, 1, parentNode, false);
  3651.     }
  3652.     if (detectedAmmo - 1 == 0) {
  3653.       reloadAnimation(player, parentNode, new boolean[0]);
  3654.     }
  3655.     return true;
  3656.   }
  3657.  
  3658.   public int[] grabDualAmmo(ItemStack item, String parentNode)
  3659.   {
  3660.     try
  3661.     {
  3662.       String strInBracks = this.csminion.extractReading(item.getItemMeta().getDisplayName());
  3663.       String[] dualAmmo = strInBracks.split(" ");
  3664.       if (dualAmmo.length != 3)
  3665.       {
  3666.         this.csminion.resetItemName(item, parentNode);
  3667.         strInBracks = this.csminion.extractReading(item.getItemMeta().getDisplayName());
  3668.         dualAmmo = strInBracks.split(" ");
  3669.       }
  3670.       int leftGun;
  3671.       int leftGun;
  3672.       if (dualAmmo[0].equals(String.valueOf('�'))) {
  3673.         leftGun = 1;
  3674.       } else {
  3675.         leftGun = Integer.valueOf(dualAmmo[0]).intValue();
  3676.       }
  3677.       int rightGun;
  3678.       int rightGun;
  3679.       if (dualAmmo[2].equals(String.valueOf('�'))) {
  3680.         rightGun = 1;
  3681.       } else {
  3682.         rightGun = Integer.valueOf(dualAmmo[2]).intValue();
  3683.       }
  3684.       return new int[] { leftGun, rightGun };
  3685.     }
  3686.     catch (NumberFormatException ex) {}
  3687.     return new int[2];
  3688.   }
  3689.  
  3690.   @EventHandler
  3691.   public void explosiveTipCrossbow(EntityShootBowEvent event)
  3692.   {
  3693.     if (((event.getEntity() instanceof Player)) && (event.getForce() == 1.0F))
  3694.     {
  3695.       Player shooter = (Player)event.getEntity();
  3696.       String parentNode = returnParentNode(shooter);
  3697.       if (parentNode == null) {
  3698.         return;
  3699.       }
  3700.       event.setCancelled(true);
  3701.       if (!regionAndPermCheck(shooter, parentNode, false)) {
  3702.         return;
  3703.       }
  3704.       this.csminion.weaponInteraction(shooter, parentNode, false);
  3705.     }
  3706.   }
  3707.  
  3708.   public String isSkipNameItem(ItemStack item)
  3709.   {
  3710.     String itemInfo = item.getTypeId() + "-" + item.getDurability();
  3711.     return (String)this.convIDs.get(itemInfo);
  3712.   }
  3713.  
  3714.   public String convItem(ItemStack item)
  3715.   {
  3716.     String retNode = isSkipNameItem(item);
  3717.     if ((retNode == null) && (item.hasItemMeta()) && (item.getItemMeta().hasEnchants()))
  3718.     {
  3719.       Map<Enchantment, Integer> enchList = item.getEnchantments();
  3720.       for (String parentNode : this.enchlist.keySet())
  3721.       {
  3722.         String[] enchInfo = (String[])this.enchlist.get(parentNode);
  3723.         Enchantment givenEnch = Enchantment.getByName(enchInfo[0]);
  3724.         int enchLevel = Integer.valueOf(enchInfo[1]).intValue();
  3725.        
  3726.         ItemStack comp = this.csminion.parseItemStack(getString(parentNode + ".Item_Information.Item_Type"));
  3727.         boolean equal = (comp != null) && (comp.getTypeId() == item.getTypeId()) && ((comp.getDurability() == item.getDurability()) || (hasDurab(parentNode)));
  3728.         if ((equal) && (enchList.containsKey(givenEnch)) && (((Integer)enchList.get(givenEnch)).intValue() == enchLevel))
  3729.         {
  3730.           retNode = parentNode;
  3731.           break;
  3732.         }
  3733.       }
  3734.     }
  3735.     return retNode;
  3736.   }
  3737.  
  3738.   public String getPureName(String itemName)
  3739.   {
  3740.     int nameLength = itemName.length() - 1;
  3741.     int lastIndex = itemName.lastIndexOf("�");
  3742.     if ((lastIndex != -1) && (lastIndex + 2 <= nameLength)) {
  3743.       itemName = itemName.substring(0, lastIndex + 2);
  3744.     }
  3745.     return itemName;
  3746.   }
  3747.  
  3748.   public String returnParentNode(Player player)
  3749.   {
  3750.     String retNode = null;
  3751.     ItemStack item = player.getItemInHand();
  3752.     if (item == null) {
  3753.       return null;
  3754.     }
  3755.     if (itemIsSafe(item))
  3756.     {
  3757.       String parentNode = isSkipNameItem(item);
  3758.       if (parentNode == null) {
  3759.         parentNode = (String)this.parentlist.get(getPureName(item.getItemMeta().getDisplayName()));
  3760.       }
  3761.       if (parentNode != null) {
  3762.         if (player.getItemInHand().getItemMeta().getDisplayName().contains(String.valueOf('?')))
  3763.         {
  3764.           String attachInfo = getAttachment(parentNode, item)[1];
  3765.           retNode = attachInfo;
  3766.         }
  3767.         else
  3768.         {
  3769.           retNode = parentNode;
  3770.         }
  3771.       }
  3772.     }
  3773.     else
  3774.     {
  3775.       String convNode = convItem(item);
  3776.       if ((convNode != null) && (regionAndPermCheck(player, convNode, true)))
  3777.       {
  3778.         this.csminion.removeEnchantments(item);
  3779.         ItemStack weapon = this.csminion.vendingMachine(convNode);
  3780.         weapon.setAmount(player.getItemInHand().getAmount());
  3781.         player.setItemInHand(weapon);
  3782.       }
  3783.     }
  3784.     return retNode;
  3785.   }
  3786.  
  3787.   public String[] itemParentNode(ItemStack item, Player player)
  3788.   {
  3789.     String[] retVal = null;
  3790.     if (itemIsSafe(item))
  3791.     {
  3792.       String parentNode = isSkipNameItem(item);
  3793.       if (parentNode == null) {
  3794.         parentNode = (String)this.parentlist.get(getPureName(item.getItemMeta().getDisplayName()));
  3795.       }
  3796.       if (parentNode != null) {
  3797.         if (item.getItemMeta().getDisplayName().contains(String.valueOf('?')))
  3798.         {
  3799.           String attachInfo = getAttachment(parentNode, item)[1];
  3800.           retVal = new String[] { attachInfo, "false" };
  3801.         }
  3802.         else
  3803.         {
  3804.           retVal = new String[] { parentNode, "false" };
  3805.         }
  3806.       }
  3807.     }
  3808.     else
  3809.     {
  3810.       String convNode = convItem(item);
  3811.       if ((convNode != null) && (player != null) && (regionAndPermCheck(player, convNode, true)))
  3812.       {
  3813.         this.csminion.removeEnchantments(item);
  3814.         retVal = new String[] { convNode, "true" };
  3815.       }
  3816.     }
  3817.     return retVal;
  3818.   }
  3819.  
  3820.   @EventHandler
  3821.   public void onCraft(CraftItemEvent event)
  3822.   {
  3823.     for (String parent_node : this.parentlist.values()) {
  3824.       if (getBoolean(parent_node + ".Crafting.Enable"))
  3825.       {
  3826.         ItemStack weapon = this.csminion.vendingMachine(parent_node);
  3827.         if (event.getRecipe().getResult().isSimilar(weapon))
  3828.         {
  3829.           if (!(event.getWhoClicked() instanceof Player)) {
  3830.             break;
  3831.           }
  3832.           Player crafter = (Player)event.getWhoClicked();
  3833.           if ((crafter.hasPermission("crackshot.craft." + parent_node)) || (crafter.hasPermission("crackshot.craft.all"))) {
  3834.             break;
  3835.           }
  3836.           event.setCancelled(true);
  3837.           CSMessages.sendMessage(crafter, this.heading, CSMessages.Message.NP_WEAPON_CRAFT.getMessage());
  3838.          
  3839.           break;
  3840.         }
  3841.       }
  3842.     }
  3843.   }
  3844.  
  3845.   void printM(String msg)
  3846.   {
  3847.     System.out.print("[CrackShot] " + msg);
  3848.   }
  3849.  
  3850.   public double getDouble(String nodes)
  3851.   {
  3852.     Double result = (Double)dubs.get(nodes);
  3853.     return result != null ? result.doubleValue() : 0.0D;
  3854.   }
  3855.  
  3856.   public boolean getBoolean(String nodes)
  3857.   {
  3858.     Boolean result = (Boolean)bools.get(nodes);
  3859.     return result != null ? result.booleanValue() : false;
  3860.   }
  3861.  
  3862.   public int getInt(String nodes)
  3863.   {
  3864.     Integer result = (Integer)ints.get(nodes);
  3865.     return result != null ? result.intValue() : 0;
  3866.   }
  3867.  
  3868.   public String getString(String nodes)
  3869.   {
  3870.     String result = (String)strings.get(nodes);
  3871.     return result != null ? result : null;
  3872.   }
  3873.  
  3874.   public boolean hasDurab(String nodes)
  3875.   {
  3876.     Boolean result = (Boolean)this.morobust.get(nodes);
  3877.     return result != null ? result.booleanValue() : false;
  3878.   }
  3879.  
  3880.   public boolean regionAndPermCheck(Player shooter, String parentNode, boolean noMsg)
  3881.   {
  3882.     String[] arrayOfString;
  3883.     int j = (arrayOfString = this.disWorlds).length;
  3884.     for (int i = 0; i < j; i++)
  3885.     {
  3886.       String worName = arrayOfString[i];
  3887.       if (worName == null) {
  3888.         break;
  3889.       }
  3890.       World world = Bukkit.getWorld(worName);
  3891.       if (world == shooter.getWorld()) {
  3892.         return false;
  3893.       }
  3894.     }
  3895.     if ((!shooter.hasPermission("crackshot.use." + parentNode)) && (!shooter.hasPermission("crackshot.use.all")))
  3896.     {
  3897.       if (!noMsg) {
  3898.         CSMessages.sendMessage(shooter, this.heading, CSMessages.Message.NP_WEAPON_USE.getMessage());
  3899.       }
  3900.       return false;
  3901.     }
  3902.     if ((!shooter.hasPermission("crackshot.bypass." + parentNode)) && (!shooter.hasPermission("crackshot.bypass.all")) &&
  3903.       (!this.csminion.regionCheck(shooter, parentNode)))
  3904.     {
  3905.       if ((!noMsg) && (getString(parentNode + ".Region_Check.Message_Of_Denial") != null)) {
  3906.         shooter.sendMessage(getString(parentNode + ".Region_Check.Message_Of_Denial"));
  3907.       }
  3908.       return false;
  3909.     }
  3910.     return true;
  3911.   }
  3912.  
  3913.   @EventHandler
  3914.   public void onEggSplat(PlayerEggThrowEvent event)
  3915.   {
  3916.     if (event.getEgg().hasMetadata("CS_Hardboiled")) {
  3917.       event.setHatching(false);
  3918.     }
  3919.   }
  3920.  
  3921.   public void launchGrenade(final Player player, final String parent_node, int delay, Vector vel, Location splitLoc, final int cTimes)
  3922.   {
  3923.     boolean cEnable = getBoolean(parent_node + ".Cluster_Bombs.Enable");
  3924.     int cOfficialTimes = getInt(parent_node + ".Cluster_Bombs.Number_Of_Splits");
  3925.     String itemType = getString(parent_node + ".Shooting.Projectile_Subtype");
  3926.     String nodeName = "Projectile_Subtype:";
  3927.     if ((cEnable) && (cTimes != 0))
  3928.     {
  3929.       nodeName = "Bomblet_Type:";
  3930.       itemType = getString(parent_node + ".Cluster_Bombs.Bomblet_Type");
  3931.     }
  3932.     if (itemType == null)
  3933.     {
  3934.       player.sendMessage(this.heading + "The '" + nodeName + "' node of '" + parent_node + "' has not been defined.");
  3935.       return;
  3936.     }
  3937.     ItemStack item = this.csminion.parseItemStack(itemType);
  3938.     if (item == null)
  3939.     {
  3940.       player.sendMessage(this.heading + "The '" + nodeName + "' node of '" + parent_node + "' has an incorrect value.");
  3941.       return;
  3942.     }
  3943.     Location loc = player.getEyeLocation();
  3944.     if (splitLoc != null) {
  3945.       loc = splitLoc;
  3946.     }
  3947.     final Item grenade = player.getWorld().dropItem(loc, item);
  3948.     grenade.setVelocity(vel);
  3949.     grenade.setPickupDelay(delay + 20);
  3950.    
  3951.     ItemStack grenStack = grenade.getItemStack();
  3952.     this.csminion.setItemName(grenStack, "?" + String.valueOf(grenade.getUniqueId()));
  3953.     grenade.setItemStack(grenStack);
  3954.    
  3955.     callShootEvent(player, grenade, parent_node);
  3956.    
  3957.     final boolean airstrike = getBoolean(parent_node + ".Airstrikes.Enable");
  3958.     int cDelay = getInt(parent_node + ".Cluster_Bombs.Delay_Before_Split");
  3959.     int cDelayDiff = getInt(parent_node + ".Cluster_Bombs.Detonation_Delay_Variation");
  3960.     if ((cEnable) && (!airstrike) && (cTimes < cOfficialTimes))
  3961.     {
  3962.       if (cTimes == 0) {
  3963.         playSoundEffects(grenade, parent_node, ".Shooting.Sounds_Projectile", false, null, new String[0]);
  3964.       }
  3965.       delay = cDelay;
  3966.     }
  3967.     else if (cEnable)
  3968.     {
  3969.       if ((cDelay != 0) && (cDelayDiff != 0))
  3970.       {
  3971.         Random r = new Random();
  3972.         delay += r.nextInt(cDelayDiff) - r.nextInt(cDelayDiff);
  3973.       }
  3974.     }
  3975.     else
  3976.     {
  3977.       playSoundEffects(grenade, parent_node, ".Shooting.Sounds_Projectile", false, null, new String[0]);
  3978.     }
  3979.     Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable()
  3980.     {
  3981.       public void run()
  3982.       {
  3983.         boolean zapEnable = CSDirector.this.getBoolean(parent_node + ".Lightning.Enable");
  3984.         boolean zapNoDam = CSDirector.this.getBoolean(parent_node + ".Lightning.No_Damage");
  3985.         if (!airstrike)
  3986.         {
  3987.           if (zapEnable) {
  3988.             CSDirector.this.csminion.projectileLightning(grenade.getLocation(), zapNoDam);
  3989.           }
  3990.           CSDirector.this.projectileExplosion(grenade, parent_node, true, player, true, false, null, null, false, cTimes);
  3991.         }
  3992.         else
  3993.         {
  3994.           CSDirector.this.csminion.callAirstrike(grenade, parent_node, player);
  3995.         }
  3996.         grenade.remove();
  3997.       }
  3998.     }, Long.valueOf(delay).longValue());
  3999.   }
  4000.  
  4001.   @EventHandler
  4002.   public void onAnyDamage(EntityDamageEvent event)
  4003.   {
  4004.     if (((event.getEntity() instanceof Player)) && (event.getCause() == EntityDamageEvent.DamageCause.FALL))
  4005.     {
  4006.       Player shooter = (Player)event.getEntity();
  4007.       ItemStack heldItem = shooter.getItemInHand();
  4008.       if ((heldItem != null) && (itemIsSafe(heldItem)))
  4009.       {
  4010.         String parentNode = returnParentNode(shooter);
  4011.         if (parentNode == null) {
  4012.           return;
  4013.         }
  4014.         if (getBoolean(parentNode + ".Abilities.No_Fall_Damage")) {
  4015.           event.setCancelled(true);
  4016.         }
  4017.       }
  4018.     }
  4019.   }
  4020.  
  4021.   public void delayedReload(final Player player, final String parentNode, long... delay)
  4022.   {
  4023.     int taskID = Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable()
  4024.     {
  4025.       public void run()
  4026.       {
  4027.         CSDirector.this.reloadAnimation(player, parentNode, new boolean[0]);
  4028.         CSDirector.this.delayed_reload_IDs.remove(player.getName());
  4029.       }
  4030.     }, delay.length == 0 ? 1L : delay[0]);
  4031.    
  4032.     this.delayed_reload_IDs.put(player.getName(), Integer.valueOf(taskID));
  4033.   }
  4034.  
  4035.   @EventHandler
  4036.   public void onPickUp(PlayerPickupItemEvent event)
  4037.   {
  4038.     if (this.csminion.fastenSeatbelts(event.getItem()) != null)
  4039.     {
  4040.       this.csminion.reseatTag(event.getItem());
  4041.       event.setCancelled(true);
  4042.       if (!(event.getItem().getVehicle() instanceof Minecart)) {
  4043.         event.getItem().remove();
  4044.       }
  4045.     }
  4046.     else
  4047.     {
  4048.       ItemStack item = event.getItem().getItemStack();
  4049.       if (itemIsSafe(item))
  4050.       {
  4051.         String fullName = item.getItemMeta().getDisplayName();
  4052.         if (fullName.contains("?"))
  4053.         {
  4054.           event.setCancelled(true);
  4055.           event.getItem().remove();
  4056.         }
  4057.         else
  4058.         {
  4059.           String itemName = getPureName(fullName);
  4060.           if (this.boobs.containsKey(itemName))
  4061.           {
  4062.             String parentNode = (String)this.boobs.get(itemName);
  4063.             if (!this.csminion.getBoobean(2, parentNode)) {
  4064.               return;
  4065.             }
  4066.             Player picker = event.getPlayer();
  4067.             String detectedName = this.csminion.extractReading(fullName);
  4068.             if (detectedName.equals("?")) {
  4069.               return;
  4070.             }
  4071.             Player planter = Bukkit.getServer().getPlayer(detectedName);
  4072.             if (planter == picker) {
  4073.               return;
  4074.             }
  4075.             event.getItem().setPickupDelay(60);
  4076.            
  4077.             slapAndReaction(picker, planter, event.getItem().getLocation().getBlock(), parentNode, null, null, detectedName, event.getItem());
  4078.             event.setCancelled(true);
  4079.           }
  4080.         }
  4081.       }
  4082.     }
  4083.   }
  4084.  
  4085.   @EventHandler
  4086.   public void onItemSpawn(ItemSpawnEvent event)
  4087.   {
  4088.     ItemStack item = event.getEntity().getItemStack();
  4089.     if ((item.getType() == Material.SKULL_ITEM) && (item.hasItemMeta()))
  4090.     {
  4091.       SkullMeta skullMeta = (SkullMeta)item.getItemMeta();
  4092.       if ((skullMeta != null) && (skullMeta.hasOwner()) && (skullMeta.getOwner().contains("?")))
  4093.       {
  4094.         event.setCancelled(true);
  4095.         event.getEntity().remove();
  4096.       }
  4097.     }
  4098.   }
  4099.  
  4100.   @EventHandler
  4101.   public void onEntityInteract(PlayerInteractEntityEvent event)
  4102.   {
  4103.     Entity ent = event.getRightClicked();
  4104.     if ((ent instanceof Minecart))
  4105.     {
  4106.       this.csminion.reseatTag((Vehicle)event.getRightClicked());
  4107.       if ((ent.getPassenger() instanceof Item)) {
  4108.         event.setCancelled(true);
  4109.       }
  4110.     }
  4111.     else if (((ent instanceof Villager)) || ((ent instanceof Horse)))
  4112.     {
  4113.       Player player = event.getPlayer();
  4114.       ItemStack heldItem = player.getItemInHand();
  4115.       String parentNode = returnParentNode(player);
  4116.       if ((parentNode != null) && (getBoolean(parentNode + ".Shooting.Cancel_Right_Click_Interactions")))
  4117.       {
  4118.         OnPlayerInteract(new PlayerInteractEvent(player, Action.RIGHT_CLICK_AIR, heldItem, null, null));
  4119.         event.setCancelled(true);
  4120.       }
  4121.     }
  4122.   }
  4123.  
  4124.   @EventHandler
  4125.   public void tagDespawn(ItemDespawnEvent event)
  4126.   {
  4127.     if (this.csminion.fastenSeatbelts(event.getEntity()) != null) {
  4128.       event.setCancelled(true);
  4129.     }
  4130.     ItemStack item = event.getEntity().getItemStack();
  4131.     if (itemIsSafe(item))
  4132.     {
  4133.       String itemName = getPureName(item.getItemMeta().getDisplayName());
  4134.       if (itemName.contains("??"))
  4135.       {
  4136.         event.setCancelled(true);
  4137.       }
  4138.       else if (this.boobs.containsKey(itemName))
  4139.       {
  4140.         String parentNode = (String)this.boobs.get(itemName);
  4141.         if (this.csminion.getBoobean(5, parentNode)) {
  4142.           event.setCancelled(true);
  4143.         }
  4144.       }
  4145.     }
  4146.   }
  4147.  
  4148.   @EventHandler
  4149.   public void onMobShotgun(VehicleEnterEvent event)
  4150.   {
  4151.     if ((event.getVehicle() instanceof Minecart))
  4152.     {
  4153.       this.csminion.reseatTag(event.getVehicle());
  4154.       if ((event.getVehicle().getPassenger() instanceof Item)) {
  4155.         event.setCancelled(true);
  4156.       }
  4157.     }
  4158.   }
  4159.  
  4160.   @EventHandler
  4161.   public void onBoatMine(VehicleEntityCollisionEvent event)
  4162.   {
  4163.     if (!(event.getVehicle() instanceof Minecart)) {
  4164.       return;
  4165.     }
  4166.     this.csminion.reseatTag(event.getVehicle());
  4167.     if (((event.getVehicle().getPassenger() instanceof Item)) && ((event.getEntity() instanceof LivingEntity)))
  4168.     {
  4169.       Entity victim = event.getEntity();
  4170.       Item psngr = (Item)event.getVehicle().getPassenger();
  4171.       String[] seagullInfo = this.csminion.fastenSeatbelts(psngr);
  4172.       if (seagullInfo == null) {
  4173.         return;
  4174.       }
  4175.       event.setCancelled(true);
  4176.       Player fisherman = Bukkit.getServer().getPlayer(seagullInfo[1]);
  4177.      
  4178.       WeaponTriggerEvent trigEvent = new WeaponTriggerEvent(fisherman, (LivingEntity)victim, seagullInfo[2]);
  4179.       getServer().getPluginManager().callEvent(trigEvent);
  4180.       if (!trigEvent.isCancelled()) {
  4181.         if ((fisherman != null) && ((victim instanceof Player)))
  4182.         {
  4183.           if (((Player)victim).getName().equals(seagullInfo[1])) {
  4184.             event.setCancelled(false);
  4185.           } else {
  4186.             this.csminion.callAndResponse((Player)victim, fisherman, event.getVehicle(), seagullInfo, false);
  4187.           }
  4188.         }
  4189.         else {
  4190.           this.csminion.mineAction(event.getVehicle(), seagullInfo, fisherman, false, victim.getType().getName(), victim);
  4191.         }
  4192.       }
  4193.     }
  4194.   }
  4195.  
  4196.   @EventHandler
  4197.   public void onBoatMineShoot(VehicleDamageEvent event)
  4198.   {
  4199.     if (!(event.getVehicle() instanceof Minecart)) {
  4200.       return;
  4201.     }
  4202.     this.csminion.reseatTag(event.getVehicle());
  4203.     if ((event.getVehicle().getPassenger() instanceof Item))
  4204.     {
  4205.       Entity attacker = event.getAttacker();
  4206.       Item psngr = (Item)event.getVehicle().getPassenger();
  4207.       String[] seagullInfo = this.csminion.fastenSeatbelts(psngr);
  4208.       if (seagullInfo == null) {
  4209.         return;
  4210.       }
  4211.       event.setCancelled(true);
  4212.       Player fisherman = Bukkit.getServer().getPlayer(seagullInfo[1]);
  4213.       if ((attacker instanceof Player))
  4214.       {
  4215.         Player player = (Player)attacker;
  4216.         if (player.getName().equals(seagullInfo[1])) {
  4217.           this.csminion.mineAction(event.getVehicle(), seagullInfo, fisherman, true, null, attacker);
  4218.         } else {
  4219.           this.csminion.callAndResponse(player, fisherman, event.getVehicle(), seagullInfo, true);
  4220.         }
  4221.       }
  4222.       else
  4223.       {
  4224.         this.csminion.mineAction(event.getVehicle(), seagullInfo, fisherman, true, null, attacker);
  4225.       }
  4226.     }
  4227.   }
  4228.  
  4229.   public void deployMine(Player player, String parent_node, Location loc)
  4230.   {
  4231.     String nodeInfo = getString(parent_node + ".Explosive_Devices.Device_Info");
  4232.     String[] deviceInfo = nodeInfo == null ? null : nodeInfo.split(",");
  4233.     ItemStack fuseItem = this.csminion.parseItemStack(deviceInfo[0]);
  4234.     Location spawnLoc = loc == null ? player.getLocation().add(0.0D, 0.75D, 0.0D) : loc;
  4235.     if (fuseItem == null)
  4236.     {
  4237.       player.sendMessage(this.heading + "No valid item-ID for 'Device_Info' of the weapon '" + parent_node + "' has been provided.");
  4238.       return;
  4239.     }
  4240.     EntityType cartType = EntityType.MINECART;
  4241.     if (deviceInfo.length == 2) {
  4242.       try
  4243.       {
  4244.         cartType = EntityType.valueOf(deviceInfo[1].toUpperCase());
  4245.       }
  4246.       catch (IllegalArgumentException ex)
  4247.       {
  4248.         player.sendMessage(this.heading + "The 'Device_Info' node of the weapon '" + parent_node + "' contains '" + deviceInfo[1] + "', which is not a valid minecart type.");
  4249.       }
  4250.     }
  4251.     Entity mine = player.getWorld().spawnEntity(spawnLoc, cartType);
  4252.     ItemMeta metaPsngr = fuseItem.getItemMeta();
  4253.     metaPsngr.setDisplayName("�cS3AGULLL~" + player.getName() + "~" + parent_node + "~" + mine.getUniqueId().toString());
  4254.     fuseItem.setItemMeta(metaPsngr);
  4255.    
  4256.     Entity fusePassenger = player.getWorld().dropItem(spawnLoc, fuseItem);
  4257.     mine.setPassenger(fusePassenger);
  4258.    
  4259.     WeaponPlaceMineEvent event = new WeaponPlaceMineEvent(player, mine, parent_node);
  4260.     getServer().getPluginManager().callEvent(event);
  4261.   }
  4262.  
  4263.   @EventHandler
  4264.   public void airstrikeKaboom(EntityChangeBlockEvent event)
  4265.   {
  4266.     if (event.getEntity().hasMetadata("CS_strike"))
  4267.     {
  4268.       Entity bomb = event.getEntity();
  4269.       String info = ((MetadataValue)bomb.getMetadata("CS_strike").get(0)).asString();
  4270.       String[] parsedInfo = info.split("~");
  4271.       Player player = Bukkit.getServer().getPlayer(parsedInfo[1]);
  4272.      
  4273.       projectileExplosion(bomb, parsedInfo[0], false, player, true, false, null, null, false, 0);
  4274.       bomb.remove();
  4275.       event.setCancelled(true);
  4276.     }
  4277.     else if (event.getEntity().hasMetadata("CS_shrapnel"))
  4278.     {
  4279.       event.getEntity().remove();
  4280.       event.setCancelled(true);
  4281.     }
  4282.   }
  4283.  
  4284.   @EventHandler(priority=EventPriority.HIGHEST)
  4285.   public void onC4Place(BlockPlaceEvent event)
  4286.   {
  4287.     final Player placer = event.getPlayer();
  4288.     if (event.getItemInHand() == null) {
  4289.       return;
  4290.     }
  4291.     final String[] parent_node = itemParentNode(event.getItemInHand(), placer);
  4292.     if (parent_node == null) {
  4293.       return;
  4294.     }
  4295.     if ((!regionAndPermCheck(placer, parent_node[0], false)) || (!getBoolean(parent_node[0] + ".Explosive_Devices.Enable")))
  4296.     {
  4297.       event.setCancelled(true);
  4298.       return;
  4299.     }
  4300.     placer.updateInventory();
  4301.    
  4302.     String type = getString(parent_node[0] + ".Explosive_Devices.Device_Type");
  4303.     if ((type == null) || (!type.equalsIgnoreCase("remote"))) {
  4304.       return;
  4305.     }
  4306.     if ((itemIsSafe(event.getItemInHand())) && (event.getItemInHand().getItemMeta().getDisplayName().contains("�0�")))
  4307.     {
  4308.       event.setCancelled(true);
  4309.       return;
  4310.     }
  4311.     boolean placeAnywhere = getBoolean(parent_node[0] + ".Explosive_Devices.Remote_Bypass_Regions");
  4312.     boolean allowed = (!event.isCancelled()) && (event.canBuild());
  4313.     final Block block = event.getBlockPlaced();
  4314.     event.setCancelled(true);
  4315.     if ((allowed) || (placeAnywhere)) {
  4316.       Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable()
  4317.       {
  4318.         public void run()
  4319.         {
  4320.           CSDirector.this.setupC4(placer, block, parent_node);
  4321.         }
  4322.       });
  4323.     }
  4324.   }
  4325.  
  4326.   public void setupC4(Player placer, Block block, String[] parent_node)
  4327.   {
  4328.     block.setType(Material.SKULL);
  4329.     block.setData((byte)1);
  4330.     BlockState state = block.getState();
  4331.     if ((state instanceof Skull))
  4332.     {
  4333.       int capacity = 0;
  4334.       String uniqueID = null;
  4335.       try
  4336.       {
  4337.         skull = (Skull)state;
  4338.       }
  4339.       catch (ClassCastException ex)
  4340.       {
  4341.         Skull skull;
  4342.         return;
  4343.       }
  4344.       Skull skull;
  4345.       skull.setSkullType(SkullType.PLAYER);
  4346.      
  4347.       String[] refinedOre = this.csminion.returnRefinedOre(placer, parent_node[0]);
  4348.       if (refinedOre != null)
  4349.       {
  4350.         capacity = Integer.valueOf(refinedOre[0]).intValue();
  4351.         uniqueID = refinedOre[1];
  4352.       }
  4353.       String storedOwner = placer.getName();
  4354.       if (storedOwner.length() > 13) {
  4355.         storedOwner = storedOwner.substring(0, 12) + '?';
  4356.       }
  4357.       skull.setOwner(uniqueID + "?" + storedOwner);
  4358.       skull.setRotation(getBlockDirection(placer.getLocation().getYaw()));
  4359.       skull.update(true);
  4360.      
  4361.       String world = placer.getWorld().getName();
  4362.       String x = String.valueOf(block.getLocation().getBlockX());
  4363.       String y = String.valueOf(block.getLocation().getBlockY());
  4364.       String z = String.valueOf(block.getLocation().getBlockZ());
  4365.      
  4366.       Map<String, String> placedHeads = (Map)this.c4_backup.get(storedOwner);
  4367.       if (placedHeads == null)
  4368.       {
  4369.         placedHeads = new HashMap();
  4370.         this.c4_backup.put(storedOwner, placedHeads);
  4371.       }
  4372.       placedHeads.put(world + "," + x + "," + y + "," + z, uniqueID);
  4373.      
  4374.       ItemStack detonator = placer.getItemInHand();
  4375.      
  4376.       boolean ammoEnable = getBoolean(parent_node[0] + ".Ammo.Enable");
  4377.       String ammoInfo = getString(parent_node[0] + ".Ammo.Ammo_Item_ID");
  4378.       boolean takeAmmo = getBoolean(parent_node[0] + ".Ammo.Take_Ammo_Per_Shot");
  4379.      
  4380.       String bracketInfo = this.csminion.extractReading(detonator.getItemMeta().getDisplayName());
  4381.       int detectedAmmo = 0;
  4382.       try
  4383.       {
  4384.         detectedAmmo = Integer.valueOf(bracketInfo).intValue();
  4385.       }
  4386.       catch (NumberFormatException localNumberFormatException) {}
  4387.       if (detectedAmmo > 0)
  4388.       {
  4389.         if ((ammoEnable) && (takeAmmo))
  4390.         {
  4391.           if (!this.csminion.containsItemStack(placer, ammoInfo, 1, parent_node[0]))
  4392.           {
  4393.             playSoundEffects(placer, parent_node[0], ".Ammo.Sounds_Shoot_With_No_Ammo", false, null, new String[0]);
  4394.             block.setType(Material.AIR);
  4395.             return;
  4396.           }
  4397.           this.csminion.removeNamedItem(placer, ammoInfo, 1, parent_node[0], false);
  4398.         }
  4399.         this.csminion.replaceBrackets(detonator, String.valueOf(detectedAmmo - 1), parent_node[0]);
  4400.       }
  4401.       else
  4402.       {
  4403.         block.setType(Material.AIR);
  4404.         return;
  4405.       }
  4406.       if (detonator.getItemMeta().hasLore())
  4407.       {
  4408.         List<String> lore = detonator.getItemMeta().getLore();
  4409.         String lastLine = (String)lore.get(lore.size() - 1);
  4410.         if (lastLine.contains(String.valueOf('?')))
  4411.         {
  4412.           String numInBrack = lastLine.split("\\[")[1].split("\\]")[0];
  4413.           int lastNumber = Integer.valueOf(numInBrack).intValue();
  4414.           if (lastNumber >= capacity)
  4415.           {
  4416.             block.setType(Material.AIR);
  4417.             return;
  4418.           }
  4419.           lore.add("�e�l[" + (lastNumber + 1) + "]�r�e " + world.toUpperCase() + '?' + " " + x + ", " + y + ", " + z);
  4420.         }
  4421.         else
  4422.         {
  4423.           lore.add("�e�l[1]�r�e " + world.toUpperCase() + '?' + " " + x + ", " + y + ", " + z);
  4424.         }
  4425.         ItemMeta detmeta = detonator.getItemMeta();
  4426.         detmeta.setLore(lore);
  4427.         detonator.setItemMeta(detmeta);
  4428.         placer.getInventory().setItemInHand(detonator);
  4429.         playSoundEffects(placer, parent_node[0], ".Explosive_Devices.Sounds_Deploy", false, null, new String[0]);
  4430.       }
  4431.     }
  4432.   }
  4433.  
  4434.   @EventHandler(priority=EventPriority.HIGHEST)
  4435.   public void breakC4(BlockBreakEvent event)
  4436.   {
  4437.     if (event.getBlock().getType() == Material.SKULL)
  4438.     {
  4439.       BlockState state = event.getBlock().getState();
  4440.       if ((state instanceof Skull))
  4441.       {
  4442.         try
  4443.         {
  4444.           skull = (Skull)state;
  4445.         }
  4446.         catch (ClassCastException ex)
  4447.         {
  4448.           Skull skull;
  4449.           return;
  4450.         }
  4451.         Skull skull;
  4452.         String ownerOre = skull.getOwner();
  4453.         if ((ownerOre != null) && (ownerOre.contains("?")))
  4454.         {
  4455.           String[] refinedOwner = ownerOre.split("?");
  4456.           Block block = event.getBlock();
  4457.           Player breaker = event.getPlayer();
  4458.          
  4459.           Player placer = null;
  4460.           List<Player> candidates = Bukkit.matchPlayer(refinedOwner[1].replace(String.valueOf('?'), ""));
  4461.           if ((candidates != null) && (!candidates.isEmpty())) {
  4462.             placer = (Player)candidates.get(0);
  4463.           }
  4464.           String world = block.getWorld().getName();
  4465.           String x = String.valueOf(block.getLocation().getBlockX());
  4466.           String y = String.valueOf(block.getLocation().getBlockY());
  4467.           String z = String.valueOf(block.getLocation().getBlockZ());
  4468.           String[] itemInfo = { "-", world, x, y, z };
  4469.           for (String exploDevID : this.rdelist.keySet()) {
  4470.             if (exploDevID.equals(refinedOwner[0]))
  4471.             {
  4472.               String parent_node = (String)this.rdelist.get(exploDevID);
  4473.               boolean bypassRegions = getBoolean(parent_node + ".Explosive_Devices.Remote_Bypass_Regions");
  4474.               if ((event.isCancelled()) && (!bypassRegions)) {
  4475.                 break;
  4476.               }
  4477.               if (breaker != placer)
  4478.               {
  4479.                 this.csminion.callAndResponse(breaker, placer, null, itemInfo, false);
  4480.               }
  4481.               else
  4482.               {
  4483.                 String msg = getString(parent_node + ".Explosive_Devices.Message_Disarm");
  4484.                 if (msg != null) {
  4485.                   breaker.sendMessage(msg);
  4486.                 }
  4487.                 block.removeMetadata("CS_transformers", this);
  4488.                 block.setType(Material.AIR);
  4489.               }
  4490.               event.setCancelled(true);
  4491.              
  4492.               break;
  4493.             }
  4494.           }
  4495.         }
  4496.       }
  4497.     }
  4498.   }
  4499.  
  4500.   @EventHandler
  4501.   public void liquidContact(BlockFromToEvent event)
  4502.   {
  4503.     if (event.getToBlock().getType() == Material.SKULL)
  4504.     {
  4505.       BlockState state = event.getToBlock().getState();
  4506.       if ((state instanceof Skull))
  4507.       {
  4508.         try
  4509.         {
  4510.           skull = (Skull)state;
  4511.         }
  4512.         catch (ClassCastException ex)
  4513.         {
  4514.           Skull skull;
  4515.           return;
  4516.         }
  4517.         Skull skull;
  4518.         if ((skull.getOwner() != null) && (skull.getOwner().contains("?"))) {
  4519.           event.setCancelled(true);
  4520.         }
  4521.       }
  4522.     }
  4523.   }
  4524.  
  4525.   public Vector determinePosition(Player player, boolean dualWield, boolean leftClick)
  4526.   {
  4527.     int leftOrRight = 90;
  4528.     if ((dualWield) && (leftClick)) {
  4529.       leftOrRight = -90;
  4530.     }
  4531.     double playerYaw = (player.getLocation().getYaw() + 90.0F + leftOrRight) * 3.141592653589793D / 180.0D;
  4532.     double x = Math.cos(playerYaw);
  4533.     double y = Math.sin(playerYaw);
  4534.     Vector vector = new Vector(x, 0.0D, y);
  4535.    
  4536.     return vector;
  4537.   }
  4538.  
  4539.   public boolean itemIsSafe(ItemStack item)
  4540.   {
  4541.     return (item.hasItemMeta()) && (item.getItemMeta().getDisplayName() != null);
  4542.   }
  4543.  
  4544.   public float findNormal(float yaw)
  4545.   {
  4546.     while (yaw <= -180.0F) {
  4547.       yaw += 360.0F;
  4548.     }
  4549.     while (yaw > 180.0F) {
  4550.       yaw -= 360.0F;
  4551.     }
  4552.     return yaw;
  4553.   }
  4554.  
  4555.   public BlockFace getBlockDirection(float yaw)
  4556.   {
  4557.     yaw = findNormal(yaw);
  4558.     switch ((int)yaw)
  4559.     {
  4560.     case 0:
  4561.       return BlockFace.NORTH;
  4562.     case 90:
  4563.       return BlockFace.EAST;
  4564.     case 180:
  4565.       return BlockFace.SOUTH;
  4566.     case 270:
  4567.       return BlockFace.WEST;
  4568.     }
  4569.     if ((yaw >= -45.0F) && (yaw < 45.0F)) {
  4570.       return BlockFace.NORTH;
  4571.     }
  4572.     if ((yaw >= 45.0F) && (yaw < 135.0F)) {
  4573.       return BlockFace.EAST;
  4574.     }
  4575.     if ((yaw >= -135.0F) && (yaw < -45.0F)) {
  4576.       return BlockFace.WEST;
  4577.     }
  4578.     return BlockFace.SOUTH;
  4579.   }
  4580.  
  4581.   @EventHandler
  4582.   public void trapCard(InventoryOpenEvent event)
  4583.   {
  4584.     if ((event.getInventory().getType() != InventoryType.CHEST) || (!(event.getPlayer() instanceof Player)) || (this.boobs.isEmpty())) {
  4585.       return;
  4586.     }
  4587.     Player opener = (Player)event.getPlayer();
  4588.     Inventory chest = event.getInventory();
  4589.     Block block = null;
  4590.     if ((chest.getHolder() instanceof Chest))
  4591.     {
  4592.       Chest chestHolder = (Chest)chest.getHolder();
  4593.       if (chestHolder != null) {
  4594.         block = chestHolder.getBlock();
  4595.       }
  4596.     }
  4597.     else if ((chest.getHolder() instanceof DoubleChest))
  4598.     {
  4599.       DoubleChest chestHolder = ((DoubleChestInventory)chest).getHolder();
  4600.       if (chestHolder != null) {
  4601.         block = opener.getWorld().getBlockAt(new Location(opener.getWorld(), chestHolder.getX(), chestHolder.getY(), chestHolder.getZ()));
  4602.       }
  4603.     }
  4604.     if (block == null) {
  4605.       return;
  4606.     }
  4607.     if (block.hasMetadata("CS_btrap"))
  4608.     {
  4609.       event.setCancelled(true);
  4610.       return;
  4611.     }
  4612.     ItemStack[] contents = chest.getContents();
  4613.     ItemStack[] arrayOfItemStack1;
  4614.     int j = (arrayOfItemStack1 = contents).length;
  4615.     for (int i = 0; i < j; i++)
  4616.     {
  4617.       ItemStack susItem = arrayOfItemStack1[i];
  4618.       if ((susItem != null) && (itemIsSafe(susItem)))
  4619.       {
  4620.         String weaponTitle = getPureName(susItem.getItemMeta().getDisplayName());
  4621.         if (this.boobs.containsKey(weaponTitle))
  4622.         {
  4623.           String parentNode = (String)this.boobs.get(weaponTitle);
  4624.           if (!this.csminion.getBoobean(1, parentNode)) {
  4625.             return;
  4626.           }
  4627.           String ammoReading = this.csminion.extractReading(susItem.getItemMeta().getDisplayName());
  4628.           if (ammoReading.equals("?")) {
  4629.             break;
  4630.           }
  4631.           Player planter = Bukkit.getServer().getPlayer(ammoReading);
  4632.           if (planter == event.getPlayer()) {
  4633.             break;
  4634.           }
  4635.           if (!this.csminion.getBoobean(4, parentNode)) {
  4636.             susItem.setAmount(susItem.getAmount() - 1);
  4637.           }
  4638.           slapAndReaction(opener, planter, block, parentNode, chest, contents, ammoReading, null);
  4639.           return;
  4640.         }
  4641.       }
  4642.     }
  4643.   }
  4644.  
  4645.   public void slapAndReaction(final Player opener, final Player planter, final Block block, final String parent_node, final Inventory chest, final ItemStack[] content, final String planterName, final Item picked)
  4646.   {
  4647.     if (opener.hasMetadata("CS_trigDelay")) {
  4648.       return;
  4649.     }
  4650.     if (planter == null)
  4651.     {
  4652.       activateTrapCard(opener, planter, block, parent_node, chest, content, planterName, picked);
  4653.       return;
  4654.     }
  4655.     opener.setMetadata("CS_trigDelay", new FixedMetadataValue(this, Boolean.valueOf(false)));
  4656.     this.csminion.tempVars(opener, "CS_trigDelay", Long.valueOf(200L));
  4657.    
  4658.     opener.setMetadata("CS_singed", new FixedMetadataValue(this, Boolean.valueOf(false)));
  4659.     this.csminion.illegalSlap(planter, opener, 0);
  4660.    
  4661.     Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable()
  4662.     {
  4663.       public void run()
  4664.       {
  4665.         if ((opener.hasMetadata("CS_singed")) && (((MetadataValue)opener.getMetadata("CS_singed").get(0)).asBoolean()))
  4666.         {
  4667.           opener.removeMetadata("CS_singed", CSDirector.this.plugin);
  4668.           opener.removeMetadata("CS_trigDelay", CSDirector.this.plugin);
  4669.           CSDirector.this.activateTrapCard(opener, planter, block, parent_node, chest, content, planterName, picked);
  4670.         }
  4671.       }
  4672.     }, 1L);
  4673.   }
  4674.  
  4675.   public void activateTrapCard(Player opener, Player planter, Block block, String parent_node, Inventory chest, ItemStack[] content, String planterName, Item picked)
  4676.   {
  4677.     boolean unlimited = this.csminion.getBoobean(4, parent_node);
  4678.     if (planter != null)
  4679.     {
  4680.       sendPlayerMessage(planter, parent_node, ".Explosive_Devices.Message_Trigger_Placer", planterName, opener.getName(), "<flight>", "<damage>");
  4681.       playSoundEffects(planter, parent_node, ".Explosive_Devices.Sounds_Alert_Placer", false, null, new String[0]);
  4682.     }
  4683.     if (picked == null)
  4684.     {
  4685.       projectileExplosion(null, parent_node, false, planter, false, true, null, block, true, 0);
  4686.       block.setMetadata("CS_btrap", new FixedMetadataValue(this, Boolean.valueOf(false)));
  4687.       if (!unlimited) {
  4688.         chest.setContents(content);
  4689.       }
  4690.     }
  4691.     else
  4692.     {
  4693.       projectileExplosion(null, parent_node, false, planter, false, true, null, block.getRelative(BlockFace.DOWN), true, 0);
  4694.       if (!unlimited) {
  4695.         picked.remove();
  4696.       }
  4697.     }
  4698.     sendPlayerMessage(opener, parent_node, ".Explosive_Devices.Message_Trigger_Victim", planterName, opener.getName(), "<flight>", "<damage>");
  4699.     playSoundEffects(null, parent_node, ".Explosive_Devices.Sounds_Trigger", false, block.getLocation().add(0.5D, 0.5D, 0.5D), new String[0]);
  4700.   }
  4701.  
  4702.   @EventHandler
  4703.   public void onHopperGulp(InventoryPickupItemEvent event)
  4704.   {
  4705.     ItemStack item = event.getItem().getItemStack();
  4706.     if ((itemIsSafe(item)) && (item.getItemMeta().getDisplayName().contains("?")))
  4707.     {
  4708.       event.getItem().remove();
  4709.       event.setCancelled(true);
  4710.     }
  4711.   }
  4712.  
  4713.   @EventHandler
  4714.   public void onTrapDispense(BlockDispenseEvent event)
  4715.   {
  4716.     Block block = event.getBlock();
  4717.     if (block.getType() != Material.DISPENSER) {
  4718.       return;
  4719.     }
  4720.     MaterialData data = block.getState().getData();
  4721.     Dispenser dispenser = (Dispenser)data;
  4722.     BlockFace face = dispenser.getFacing();
  4723.     if (this.csminion.boobyAction(block.getRelative(face).getRelative(BlockFace.DOWN), null, event.getItem())) {
  4724.       event.setCancelled(true);
  4725.     }
  4726.   }
  4727.  
  4728.   @EventHandler
  4729.   public void onPressurePlate(EntityInteractEvent event)
  4730.   {
  4731.     if (((event.getBlock().getType() == Material.WOOD_PLATE) || (event.getBlock().getType() == Material.STONE_PLATE)) && ((event.getEntity() instanceof LivingEntity)))
  4732.     {
  4733.       List<Entity> l = event.getEntity().getNearbyEntities(4.0D, 4.0D, 4.0D);
  4734.       for (Entity e : l) {
  4735.         if ((e instanceof ItemFrame)) {
  4736.           this.csminion.boobyAction(event.getBlock(), event.getEntity(), ((ItemFrame)e).getItem());
  4737.         }
  4738.       }
  4739.     }
  4740.   }
  4741.  
  4742.   @EventHandler(priority=EventPriority.HIGHEST)
  4743.   public void onSplash(PotionSplashEvent event)
  4744.   {
  4745.     ThrownPotion splashPot = event.getEntity();
  4746.     if (splashPot.hasMetadata("projParentNode"))
  4747.     {
  4748.       Entity shooter = (Entity)splashPot.getShooter();
  4749.       if ((shooter != null) && ((shooter instanceof Player)))
  4750.       {
  4751.         PermissionAttachment attachment = ((Player)shooter).addAttachment(this);
  4752.         attachment.setPermission("nocheatplus", true);
  4753.         attachment.setPermission("anticheat.check.exempt", true);
  4754.        
  4755.         String parentNode = ((MetadataValue)splashPot.getMetadata("projParentNode").get(0)).asString();
  4756.         boolean enableExplode = getBoolean(parentNode + ".Explosions.Enable");
  4757.         boolean impactExplode = getBoolean(parentNode + ".Explosions.On_Impact_With_Anything");
  4758.         if ((enableExplode) && (impactExplode)) {
  4759.           projectileExplosion(null, parentNode, false, (Player)shooter, false, true, null, splashPot.getLocation().getBlock(), true, 0);
  4760.         }
  4761.         for (Entity ent : event.getAffectedEntities()) {
  4762.           if ((ent != shooter) && (!ent.isDead()) && (!event.isCancelled())) {
  4763.             if ((ent instanceof Player))
  4764.             {
  4765.               ent.setMetadata("CS_Energy", new FixedMetadataValue(this, parentNode));
  4766.               ((LivingEntity)ent).damage(0.0D, shooter);
  4767.             }
  4768.             else
  4769.             {
  4770.               dealDamage(shooter, (LivingEntity)ent, null, parentNode);
  4771.             }
  4772.           }
  4773.         }
  4774.         event.setCancelled(true);
  4775.        
  4776.         ((Player)shooter).removeAttachment(attachment);
  4777.       }
  4778.     }
  4779.   }
  4780.  
  4781.   public boolean validHotbar(Player shooter, String parent_node)
  4782.   {
  4783.     boolean retVal = true;
  4784.     String invCtrl = getString(parent_node + ".Item_Information.Inventory_Control");
  4785.     if (invCtrl != null)
  4786.     {
  4787.       Inventory playerInv = shooter.getInventory();
  4788.       String[] groupList = invCtrl.replaceAll(" ", "").split(",");
  4789.       String[] arrayOfString1;
  4790.       int j = (arrayOfString1 = groupList).length;
  4791.       for (int i = 0; i < j; i++)
  4792.       {
  4793.         String invGroup = arrayOfString1[i];
  4794.         int groupLimit = getInt(invGroup + ".Limit");
  4795.         int groupCount = 0;
  4796.         for (int i = 0; i < 9; i++)
  4797.         {
  4798.           ItemStack checkItem = playerInv.getItem(i);
  4799.           if ((checkItem != null) && (itemIsSafe(checkItem)))
  4800.           {
  4801.             String[] checkParent = itemParentNode(checkItem, shooter);
  4802.             if (checkParent != null)
  4803.             {
  4804.               String groupCheck = getString(checkParent[0] + ".Item_Information.Inventory_Control");
  4805.               if ((groupCheck != null) && (groupCheck.contains(invGroup))) {
  4806.                 groupCount++;
  4807.               }
  4808.             }
  4809.           }
  4810.         }
  4811.         if (groupCount > groupLimit)
  4812.         {
  4813.           sendPlayerMessage(shooter, invGroup, ".Message_Exceeded", "<shooter>", "<victim>", "<flight>", "<damage>");
  4814.           playSoundEffects(shooter, invGroup, ".Sounds_Exceeded", false, null, new String[0]);
  4815.           retVal = false;
  4816.         }
  4817.       }
  4818.     }
  4819.     return retVal;
  4820.   }
  4821.  
  4822.   public boolean tossBomb(Player player, String parentNode, ItemStack heldItem, boolean rdeEnable)
  4823.   {
  4824.     boolean retVal = false;
  4825.     String type = getString(parentNode + ".Explosive_Devices.Device_Type");
  4826.     if ((rdeEnable) && (type != null) && (type.equalsIgnoreCase("itembomb")))
  4827.     {
  4828.       int gunSlot = player.getInventory().getHeldItemSlot();
  4829.       String metaTag = parentNode + "shootDelay" + gunSlot;
  4830.       if (player.hasMetadata(metaTag)) {
  4831.         return false;
  4832.       }
  4833.       player.setMetadata(metaTag, new FixedMetadataValue(this, Boolean.valueOf(true)));
  4834.       this.csminion.tempVars(player, metaTag, Long.valueOf(getInt(parentNode + ".Shooting.Delay_Between_Shots")));
  4835.      
  4836.       String preInfo = getString(parentNode + ".Explosive_Devices.Device_Info");
  4837.       String[] deviceInfo = preInfo == null ? null : preInfo.split(",");
  4838.       if (this.csminion.bombIsInvalid(player, deviceInfo, parentNode)) {
  4839.         return true;
  4840.       }
  4841.       double speed = Double.valueOf(deviceInfo[1]).doubleValue() * 0.1D;
  4842.       ItemStack bombType = this.csminion.parseItemStack(deviceInfo[2]);
  4843.      
  4844.       boolean ammoEnable = getBoolean(parentNode + ".Ammo.Enable");
  4845.       String ammoInfo = getString(parentNode + ".Ammo.Ammo_Item_ID");
  4846.       boolean takeAmmo = getBoolean(parentNode + ".Ammo.Take_Ammo_Per_Shot");
  4847.       int detectedAmmo = 0;
  4848.       String bracketInfo = this.csminion.extractReading(heldItem.getItemMeta().getDisplayName());
  4849.       try
  4850.       {
  4851.         detectedAmmo = Integer.valueOf(bracketInfo).intValue();
  4852.       }
  4853.       catch (NumberFormatException localNumberFormatException) {}
  4854.       if (detectedAmmo > 0)
  4855.       {
  4856.         if ((ammoEnable) && (takeAmmo))
  4857.         {
  4858.           if (!this.csminion.containsItemStack(player, ammoInfo, 1, parentNode))
  4859.           {
  4860.             playSoundEffects(player, parentNode, ".Ammo.Sounds_Shoot_With_No_Ammo", false, null, new String[0]);
  4861.             return true;
  4862.           }
  4863.           this.csminion.replaceBrackets(heldItem, String.valueOf(detectedAmmo - 1), parentNode);
  4864.           this.csminion.removeNamedItem(player, ammoInfo, 1, parentNode, false);
  4865.         }
  4866.         else
  4867.         {
  4868.           this.csminion.replaceBrackets(heldItem, String.valueOf(detectedAmmo - 1), parentNode);
  4869.         }
  4870.       }
  4871.       else {
  4872.         return true;
  4873.       }
  4874.       Item itemBomb = player.getWorld().dropItem(player.getEyeLocation(), bombType);
  4875.       itemBomb.setVelocity(player.getEyeLocation().getDirection().multiply(speed));
  4876.       itemBomb.setPickupDelay(24000);
  4877.       playSoundEffects(player, parentNode, ".Explosive_Devices.Sounds_Deploy", false, null, new String[0]);
  4878.      
  4879.       String playerName = player.getName();
  4880.       Map<String, ArrayDeque<Item>> subList = (Map)this.itembombs.get(playerName);
  4881.       if (subList == null)
  4882.       {
  4883.         subList = new HashMap();
  4884.         this.itembombs.put(playerName, subList);
  4885.       }
  4886.       ArrayDeque<Item> subSubList = (ArrayDeque)subList.get(parentNode);
  4887.       if (subSubList == null)
  4888.       {
  4889.         subSubList = new ArrayDeque();
  4890.         subList.put(parentNode, subSubList);
  4891.       }
  4892.       subSubList.add(itemBomb);
  4893.       if (subSubList.size() > Integer.valueOf(deviceInfo[0]).intValue()) {
  4894.         ((Item)subSubList.removeFirst()).remove();
  4895.       }
  4896.       ItemStack grenStack = itemBomb.getItemStack();
  4897.       this.csminion.setItemName(grenStack, playerName + "??" + String.valueOf(itemBomb.getUniqueId()));
  4898.       itemBomb.setItemStack(grenStack);
  4899.      
  4900.       callShootEvent(player, itemBomb, parentNode);
  4901.      
  4902.       retVal = true;
  4903.     }
  4904.     return retVal;
  4905.   }
  4906.  
  4907.   public void detonateC4(Player shooter, ItemStack item, String parentNode, String deviceType)
  4908.   {
  4909.     List<String> lore = null;
  4910.     String[] deviceInfo = null;
  4911.     String playerName = shooter.getName();
  4912.     boolean rdeFound = false;boolean itemMode = false;boolean noneToBoom = true;
  4913.     if (deviceType.equalsIgnoreCase("itembomb"))
  4914.     {
  4915.       String itemName = item.getItemMeta().getDisplayName();
  4916.       String preInfo = getString(parentNode + ".Explosive_Devices.Device_Info");
  4917.       deviceInfo = preInfo == null ? null : preInfo.split(",");
  4918.       if ((this.csminion.bombIsInvalid(shooter, deviceInfo, parentNode)) || (itemName.contains("�" + deviceInfo[0] + "�"))) {
  4919.         return;
  4920.       }
  4921.       rdeFound = true;
  4922.       itemMode = true;
  4923.       if (this.itembombs.containsKey(playerName))
  4924.       {
  4925.         int delay = getInt(parentNode + ".Explosions.Explosion_Delay");
  4926.         ItemStack detItem = this.csminion.parseItemStack(deviceInfo[3]);
  4927.        
  4928.         ArrayDeque<Item> subSubList = (ArrayDeque)((Map)this.itembombs.get(playerName)).get(parentNode);
  4929.         if (subSubList != null)
  4930.         {
  4931.           while (!subSubList.isEmpty())
  4932.           {
  4933.             noneToBoom = false;
  4934.             Item bomb = (Item)subSubList.removeFirst();
  4935.             playSoundEffects(bomb, parentNode, ".Explosive_Devices.Sounds_Trigger", false, null, new String[0]);
  4936.             projectileExplosion(bomb, parentNode, false, shooter, false, false, null, null, false, 0);
  4937.             detItem.setItemMeta(bomb.getItemStack().getItemMeta());
  4938.             bomb.setItemStack(detItem);
  4939.             prepareTermination(bomb, true, Long.valueOf(delay));
  4940.           }
  4941.           ((Map)this.itembombs.get(playerName)).remove(parentNode);
  4942.         }
  4943.       }
  4944.     }
  4945.     else if (item.getItemMeta().hasLore())
  4946.     {
  4947.       lore = item.getItemMeta().getLore();
  4948.       Iterator<String> it = lore.iterator();
  4949.       while (it.hasNext())
  4950.       {
  4951.         String line = (String)it.next();
  4952.         if (line.contains(String.valueOf('?')))
  4953.         {
  4954.           line = line.replace(" ", "");
  4955.           String[] itemInfo = line.split("]�r�e|\\?|,");
  4956.           this.csminion.detonateRDE(shooter, null, itemInfo, true);
  4957.           it.remove();
  4958.           rdeFound = true;
  4959.         }
  4960.       }
  4961.     }
  4962.     if (rdeFound)
  4963.     {
  4964.       String capacity = "0";
  4965.       String[] refinedOre = itemMode ? deviceInfo : this.csminion.returnRefinedOre(shooter, parentNode);
  4966.       if (refinedOre != null) {
  4967.         capacity = refinedOre[0];
  4968.       }
  4969.       if ((!itemMode) || (!noneToBoom)) {
  4970.         playSoundEffects(shooter, parentNode, ".Explosive_Devices.Sounds_Alert_Placer", false, null, new String[0]);
  4971.       }
  4972.       if (!getBoolean(parentNode + ".Extras.One_Time_Use"))
  4973.       {
  4974.         this.csminion.replaceBrackets(item, capacity, parentNode);
  4975.       }
  4976.       else if ((item.getItemMeta().getDisplayName() != null) && (item.getItemMeta().getDisplayName().contains("�0�")))
  4977.       {
  4978.         shooter.getInventory().setItemInHand(null);
  4979.         shooter.updateInventory();
  4980.         return;
  4981.       }
  4982.       if (!itemMode)
  4983.       {
  4984.         ItemMeta detmeta = item.getItemMeta();
  4985.         detmeta.setLore(lore);
  4986.         item.setItemMeta(detmeta);
  4987.         shooter.getInventory().setItemInHand(item);
  4988.       }
  4989.     }
  4990.   }
  4991.  
  4992.   public void checkCorruption(ItemStack item, boolean isAttachment, boolean isDual)
  4993.   {
  4994.     String itemName = item.getItemMeta().getDisplayName();
  4995.     boolean noBracket = !itemName.contains("�");
  4996.     boolean noArrow = (isAttachment) && (!itemName.contains(String.valueOf('?'))) && (!itemName.contains(String.valueOf('?')));
  4997.     if ((noBracket) || (noArrow))
  4998.     {
  4999.       Pattern pattern = Pattern.compile("-?\\d+");
  5000.       int startingPos = (isAttachment) || (isDual) ? getLastChar(itemName, ' ', 3) : itemName.lastIndexOf(" ");
  5001.       String[] bracketInfo = itemName.substring(startingPos + 1).split(" ");
  5002.       String[] ammo = { "", "", "" };
  5003.       if ((isAttachment) || (isDual))
  5004.       {
  5005.         for (int i = 0; i < 3; i += 2)
  5006.         {
  5007.           Matcher matcher = pattern.matcher(bracketInfo[i]);
  5008.           ammo[i] = (matcher.find() ? matcher.group() : String.valueOf('�'));
  5009.         }
  5010.         String splitter = isDual ? " | " : " ?? ";
  5011.         itemName = itemName.substring(0, startingPos + 1) + "�" + ammo[0] + splitter + ammo[2] + "�";
  5012.       }
  5013.       else
  5014.       {
  5015.         Matcher matcher = pattern.matcher(bracketInfo[0]);
  5016.         ammo[0] = (matcher.find() ? matcher.group() : String.valueOf('�'));
  5017.         itemName = itemName.substring(0, startingPos + 1) + "�" + ammo[0] + "�";
  5018.       }
  5019.       this.csminion.setItemName(item, itemName);
  5020.     }
  5021.   }
  5022.  
  5023.   public static int getLastChar(String str, char c, int n)
  5024.   {
  5025.     int pos = str.lastIndexOf(c, str.length());
  5026.     while ((n-- > 1) && (pos != -1)) {
  5027.       pos = str.lastIndexOf(c, pos - 1);
  5028.     }
  5029.     return pos;
  5030.   }
  5031.  
  5032.   public int getReloadAmount(Player player, String weaponTitle, ItemStack item)
  5033.   {
  5034.     int capacity = getInt(weaponTitle + ".Reload.Reload_Amount");
  5035.    
  5036.     WeaponCapacityEvent event = new WeaponCapacityEvent(player, weaponTitle, item, capacity);
  5037.     getServer().getPluginManager().callEvent(event);
  5038.    
  5039.     return event.getCapacity();
  5040.   }
  5041.  
  5042.   public String[] getAttachment(String weaponTitle, ItemStack item)
  5043.   {
  5044.     String attachType = getString(weaponTitle + ".Item_Information.Attachments.Type");
  5045.     if ((attachType == null) || (attachType.equalsIgnoreCase("accessory"))) {
  5046.       return new String[] { attachType };
  5047.     }
  5048.     String attachment = getString(weaponTitle + ".Item_Information.Attachments.Info");
  5049.     WeaponAttachmentEvent event = new WeaponAttachmentEvent(weaponTitle, item, attachment);
  5050.     getServer().getPluginManager().callEvent(event);
  5051.    
  5052.     return new String[] { event.isCancelled() ? null : attachType, event.getAttachment() };
  5053.   }
  5054.  
  5055.   public boolean isDualWield(Player player, String weaponTitle, ItemStack item)
  5056.   {
  5057.     boolean dualWield = getBoolean(weaponTitle + ".Shooting.Dual_Wield");
  5058.    
  5059.     WeaponDualWieldEvent event = new WeaponDualWieldEvent(player, weaponTitle, item, dualWield);
  5060.     getServer().getPluginManager().callEvent(event);
  5061.    
  5062.     return event.isDualWield();
  5063.   }
  5064.  
  5065.   public boolean isDifferentItem(ItemStack item, String weaponTitle)
  5066.   {
  5067.     if (getBoolean(weaponTitle + ".Item_Information.Skip_Name_Check"))
  5068.     {
  5069.       String itemWeaponTitle = isSkipNameItem(item);
  5070.       return (itemWeaponTitle == null) || (!itemWeaponTitle.equals(weaponTitle));
  5071.     }
  5072.     String itemName = getString(weaponTitle + ".Item_Information.Item_Name");
  5073.     return !item.getItemMeta().getDisplayName().startsWith(itemName);
  5074.   }
  5075.  
  5076.   public boolean isValid(int tick, int fireRate)
  5077.   {
  5078.     switch (fireRate)
  5079.     {
  5080.     case 1:
  5081.       return tick % 4 == 1;
  5082.     case 2:
  5083.       tick %= 7;
  5084.       return (tick == 1) || (tick == 4);
  5085.     case 3:
  5086.       return tick % 3 == 1;
  5087.     case 4:
  5088.       tick %= 5;
  5089.       return (tick == 1) || (tick == 3);
  5090.     case 5:
  5091.       tick %= 7;
  5092.       return (tick == 1) || (tick == 3) || (tick == 5);
  5093.     case 6:
  5094.       return tick % 2 == 1;
  5095.     case 7:
  5096.       return (tick == 2) || (tick % 2 == 1);
  5097.     case 8:
  5098.       tick %= 5;
  5099.       return (tick == 1) || (tick == 2) || (tick == 4);
  5100.     case 9:
  5101.       tick %= 6;
  5102.       return (tick != 2) && (tick != 0);
  5103.     case 10:
  5104.       return tick % 3 != 0;
  5105.     case 11:
  5106.       return tick % 4 != 0;
  5107.     case 12:
  5108.       return tick % 5 != 0;
  5109.     case 13:
  5110.       return tick % 6 != 0;
  5111.     case 14:
  5112.       return tick % 10 != 0;
  5113.     case 15:
  5114.       return tick != 20;
  5115.     case 16:
  5116.       return true;
  5117.     }
  5118.     return true;
  5119.   }
  5120. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement