mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-12-27 02:58:03 +01:00
Minor cleanup / refactoring
This commit is contained in:
parent
0bb5f9f297
commit
73902d5f92
@ -13,7 +13,6 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
@ -21,24 +20,24 @@ import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class Archery {
|
||||
|
||||
public static Map<Entity, Integer> arrowTracker = new HashMap<Entity, Integer>();
|
||||
private static Random random = new Random();
|
||||
public static Map<Entity, Integer> arrowTracker = new HashMap<Entity, Integer>();
|
||||
|
||||
/**
|
||||
* Track arrows fired for later retrieval.
|
||||
*
|
||||
* @param plugin mcMMO plugin instance
|
||||
* @param entity Entity damaged by the arrow
|
||||
* @param PPa PlayerProfile of the player firing the arrow
|
||||
*/
|
||||
public static void trackArrows(mcMMO plugin, Entity entity, PlayerProfile PPa) {
|
||||
public static void trackArrows(Entity entity, PlayerProfile PPa) {
|
||||
final int MAX_BONUS_LEVEL = 1000;
|
||||
int skillLevel = PPa.getSkillLevel(SkillType.ARCHERY);
|
||||
|
||||
if (skillLevel > MAX_BONUS_LEVEL || (random.nextInt(1000) <= skillLevel)) {
|
||||
int skillLevel = PPa.getSkillLevel(SkillType.ARCHERY);
|
||||
int skillCheck = Misc.skillCheck(skillLevel, MAX_BONUS_LEVEL);
|
||||
|
||||
if (random.nextInt(1000) <= skillCheck) {
|
||||
for (Entry<Entity, Integer> entry : arrowTracker.entrySet()) {
|
||||
if (entry.getKey() == entity) {
|
||||
if (entry.getKey() == entity) { //Shouldn't we be using .equals() here?
|
||||
entry.setValue(entry.getValue() + 1);
|
||||
return;
|
||||
}
|
||||
@ -59,18 +58,18 @@ public class Archery {
|
||||
final int MAX_BONUS_LEVEL = 1000;
|
||||
|
||||
int skillLevel = Users.getProfile(attacker).getSkillLevel(SkillType.ARCHERY);
|
||||
Location loc = defender.getLocation();
|
||||
Location location = defender.getLocation();
|
||||
int skillCheck = Misc.skillCheck(skillLevel, MAX_BONUS_LEVEL);
|
||||
|
||||
if (random.nextInt(10) > 5) {
|
||||
loc.setPitch(90);
|
||||
location.setPitch(90);
|
||||
}
|
||||
else {
|
||||
loc.setPitch(-90);
|
||||
location.setPitch(-90);
|
||||
}
|
||||
|
||||
if (random.nextInt(2000) <= skillCheck) {
|
||||
defender.teleport(loc);
|
||||
defender.teleport(location);
|
||||
event.setDamage(event.getDamage() + 4);
|
||||
defender.sendMessage(LocaleLoader.getString("Combat.TouchedFuzzy"));
|
||||
attacker.sendMessage(LocaleLoader.getString("Combat.TargetDazed"));
|
||||
@ -83,10 +82,10 @@ public class Archery {
|
||||
* @param entity The entity hit by the arrows
|
||||
*/
|
||||
public static void arrowRetrievalCheck(Entity entity) {
|
||||
for (Iterator<Map.Entry<Entity, Integer>> it = arrowTracker.entrySet().iterator() ; it.hasNext() ; ) {
|
||||
for (Iterator<Map.Entry<Entity, Integer>> it = arrowTracker.entrySet().iterator() ; it.hasNext() ; ) { //This is a wee bit confusing...
|
||||
Entry<Entity, Integer> entry = it.next();
|
||||
|
||||
if (entry.getKey() == entity) {
|
||||
if (entry.getKey() == entity) { //Shouldn't we be using .equals() here?
|
||||
Misc.dropItems(entity.getLocation(), new ItemStack(Material.ARROW), entry.getValue());
|
||||
it.remove();
|
||||
return;
|
||||
|
@ -80,8 +80,7 @@ public class Axes {
|
||||
|
||||
if (entity instanceof Player){
|
||||
event.setDamage((int) (damage * PVP_MODIFIER));
|
||||
Player player = (Player) entity;
|
||||
player.sendMessage(LocaleLoader.getString("Axes.Combat.CritStruck"));
|
||||
((Player) entity).sendMessage(LocaleLoader.getString("Axes.Combat.CritStruck"));
|
||||
}
|
||||
else {
|
||||
event.setDamage(damage * PVE_MODIFIER);
|
||||
|
@ -286,7 +286,7 @@ public class Combat {
|
||||
}
|
||||
|
||||
if (permInstance.trackArrows(attacker)) {
|
||||
Archery.trackArrows(pluginx, target, PPa);
|
||||
Archery.trackArrows(target, PPa);
|
||||
}
|
||||
|
||||
if (target != attacker) {
|
||||
|
Loading…
Reference in New Issue
Block a user