mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-12-28 11:37:39 +01:00
Fixed Arrow Retrieval dropping only one arrow
This commit is contained in:
parent
3e91bc8c1e
commit
6dc522a044
@ -144,12 +144,10 @@ public class EntityListener implements Listener {
|
|||||||
@EventHandler (priority = EventPriority.MONITOR)
|
@EventHandler (priority = EventPriority.MONITOR)
|
||||||
public void onEntityDeath(EntityDeathEvent event) {
|
public void onEntityDeath(EntityDeathEvent event) {
|
||||||
LivingEntity entity = event.getEntity();
|
LivingEntity entity = event.getEntity();
|
||||||
|
|
||||||
entity.setFireTicks(0);
|
entity.setFireTicks(0);
|
||||||
|
|
||||||
/* Remove bleed track */
|
|
||||||
BleedTimer.remove(entity);
|
BleedTimer.remove(entity);
|
||||||
|
Archery.arrowRetrievalCheck(entity);
|
||||||
Archery.arrowRetrievalCheck(entity, plugin);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -32,7 +32,6 @@ import org.bukkit.plugin.PluginManager;
|
|||||||
import org.bukkit.scheduler.BukkitScheduler;
|
import org.bukkit.scheduler.BukkitScheduler;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
import org.bukkit.entity.Entity;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class mcMMO extends JavaPlugin {
|
public class mcMMO extends JavaPlugin {
|
||||||
@ -43,7 +42,6 @@ public class mcMMO extends JavaPlugin {
|
|||||||
private final HardcoreListener hardcoreListener = new HardcoreListener();
|
private final HardcoreListener hardcoreListener = new HardcoreListener();
|
||||||
|
|
||||||
public HashMap<String, String> aliasMap = new HashMap<String, String>(); //Alias - Command
|
public HashMap<String, String> aliasMap = new HashMap<String, String>(); //Alias - Command
|
||||||
public HashMap<Entity, Integer> arrowTracker = new HashMap<Entity, Integer>();
|
|
||||||
public HashMap<Integer, Player> tntTracker = new HashMap<Integer, Player>();
|
public HashMap<Integer, Player> tntTracker = new HashMap<Integer, Player>();
|
||||||
|
|
||||||
public static File versionFile;
|
public static File versionFile;
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
package com.gmail.nossr50.skills.combat;
|
package com.gmail.nossr50.skills.combat;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -18,6 +22,7 @@ import com.gmail.nossr50.util.Users;
|
|||||||
|
|
||||||
public class Archery {
|
public class Archery {
|
||||||
|
|
||||||
|
public static Map<Entity, Integer> arrowTracker = new HashMap<Entity, Integer>();
|
||||||
private static Random random = new Random();
|
private static Random random = new Random();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -31,12 +36,15 @@ public class Archery {
|
|||||||
final int MAX_BONUS_LEVEL = 1000;
|
final int MAX_BONUS_LEVEL = 1000;
|
||||||
int skillLevel = PPa.getSkillLevel(SkillType.ARCHERY);
|
int skillLevel = PPa.getSkillLevel(SkillType.ARCHERY);
|
||||||
|
|
||||||
if (!plugin.arrowTracker.containsKey(entity)) {
|
|
||||||
plugin.arrowTracker.put(entity, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (skillLevel > MAX_BONUS_LEVEL || (random.nextInt(1000) <= skillLevel)) {
|
if (skillLevel > MAX_BONUS_LEVEL || (random.nextInt(1000) <= skillLevel)) {
|
||||||
plugin.arrowTracker.put(entity, 1);
|
for (Entry<Entity, Integer> entry : arrowTracker.entrySet()) {
|
||||||
|
if (entry.getKey() == entity) {
|
||||||
|
entry.setValue(entry.getValue() + 1);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
arrowTracker.put(entity, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,13 +80,16 @@ public class Archery {
|
|||||||
* Check for arrow retrieval.
|
* Check for arrow retrieval.
|
||||||
*
|
*
|
||||||
* @param entity The entity hit by the arrows
|
* @param entity The entity hit by the arrows
|
||||||
* @param plugin mcMMO plugin instance
|
|
||||||
*/
|
*/
|
||||||
public static void arrowRetrievalCheck(Entity entity, mcMMO plugin) {
|
public static void arrowRetrievalCheck(Entity entity) {
|
||||||
if (plugin.arrowTracker.containsKey(entity)) {
|
for (Iterator<Map.Entry<Entity, Integer>> it = arrowTracker.entrySet().iterator() ; it.hasNext() ; ) {
|
||||||
Misc.mcDropItems(entity.getLocation(), new ItemStack(Material.ARROW), plugin.arrowTracker.get(entity));
|
Entry<Entity, Integer> entry = it.next();
|
||||||
}
|
|
||||||
|
|
||||||
plugin.arrowTracker.remove(entity);
|
if (entry.getKey() == entity) {
|
||||||
|
Misc.mcDropItem(entity.getLocation(), new ItemStack(Material.ARROW, entry.getValue()));
|
||||||
|
it.remove();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user