Skip to content

Commit

Permalink
Fixed a bug with Volley that could result in arrow duplication
Browse files Browse the repository at this point in the history
  • Loading branch information
Taiterio authored and Taiterio committed May 17, 2015
1 parent 4886bee commit dabb70e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
9 changes: 9 additions & 0 deletions src/com/taiter/ce/CEListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerItemBreakEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerPickupItemEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
Expand Down Expand Up @@ -464,6 +465,14 @@ public void ProjectileLaunchEvent(ProjectileLaunchEvent e) {


//PLAYER

@EventHandler
public void PlayerPickupItemEvent(PlayerPickupItemEvent event) {
if(event.getItem().hasMetadata("ce.Volley")) {
event.getItem().remove();
event.setCancelled(true);
}
}

@EventHandler(priority = EventPriority.HIGHEST)
public void PlayerInteractEvent(PlayerInteractEvent e) {
Expand Down
4 changes: 3 additions & 1 deletion src/com/taiter/ce/Enchantments/Bow/Volley.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.bukkit.event.Event;
import org.bukkit.event.entity.EntityShootBowEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.metadata.FixedMetadataValue;
import org.bukkit.util.Vector;

import com.taiter.ce.Enchantments.CEnchantment;
Expand Down Expand Up @@ -73,7 +74,8 @@ private void volley(EntityShootBowEvent e, ItemStack item, int lvl) {
Arrow arrow = p.launchProjectile(Arrow.class);
arrow.setShooter(p);
// Need to make sure arrow has same speed as original arrow.
arrow.setVelocity(newDir.normalize().multiply(velocity.length()));
arrow.setVelocity(newDir.normalize().multiply(velocity.length()));
arrow.setMetadata("ce.Volley", new FixedMetadataValue(getPlugin(), null)); //Control metadata to prevent players from duplicating arrows
}
}

Expand Down

0 comments on commit dabb70e

Please sign in to comment.