mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-24 14:16:45 +01:00
More optimization
This commit is contained in:
parent
9a7ea3b6d0
commit
87723bd06d
@ -58,17 +58,17 @@ public class Combat
|
|||||||
ItemStack itemInHand = attacker.getItemInHand();
|
ItemStack itemInHand = attacker.getItemInHand();
|
||||||
PlayerProfile PPa = Users.getProfile(attacker);
|
PlayerProfile PPa = Users.getProfile(attacker);
|
||||||
|
|
||||||
//If there are any abilities to activate
|
|
||||||
combatAbilityChecks(attacker, PPa);
|
|
||||||
|
|
||||||
//Damage modifiers and proc checks
|
//Damage modifiers and proc checks
|
||||||
if(m.isSwords(itemInHand) && mcPermissions.getInstance().swords(attacker))
|
if(m.isSwords(itemInHand) && mcPermissions.getInstance().swords(attacker))
|
||||||
{
|
{
|
||||||
|
if(PPa.getSwordsPreparationMode())
|
||||||
|
Skills.abilityCheck(attacker, PPa, SkillType.SWORDS);
|
||||||
|
|
||||||
if(!pluginx.misc.bleedTracker.contains(target)) //Bleed
|
if(!pluginx.misc.bleedTracker.contains(target)) //Bleed
|
||||||
Swords.bleedCheck(attacker, target, pluginx);
|
Swords.bleedCheck(attacker, PPa.getSkillLevel(SkillType.SWORDS), target, pluginx);
|
||||||
|
|
||||||
if (!(event instanceof FakeEntityDamageByEntityEvent) && PPa.getSerratedStrikesMode())
|
if (!(event instanceof FakeEntityDamageByEntityEvent) && PPa.getSerratedStrikesMode())
|
||||||
Swords.applySerratedStrikes(attacker, event, pluginx);
|
Swords.applySerratedStrikes(attacker, target, damage, pluginx);
|
||||||
|
|
||||||
if(target instanceof Player)
|
if(target instanceof Player)
|
||||||
PvPExperienceGain(attacker, PPa, (Player) target, damage, SkillType.SWORDS);
|
PvPExperienceGain(attacker, PPa, (Player) target, damage, SkillType.SWORDS);
|
||||||
@ -77,35 +77,41 @@ public class Combat
|
|||||||
}
|
}
|
||||||
else if(m.isAxes(itemInHand) && mcPermissions.getInstance().axes(attacker))
|
else if(m.isAxes(itemInHand) && mcPermissions.getInstance().axes(attacker))
|
||||||
{
|
{
|
||||||
Axes.axesBonus(attacker, event);
|
if(PPa.getAxePreparationMode())
|
||||||
|
Skills.abilityCheck(attacker, PPa, SkillType.AXES);
|
||||||
|
|
||||||
Axes.axeCriticalCheck(attacker, event, pluginx); //Critical hit
|
damage += Axes.axesBonus(attacker, PPa);
|
||||||
|
|
||||||
|
damage *= Axes.axeCriticalBonus(attacker, PPa.getSkillLevel(SkillType.AXES), target, pluginx); //Critical hit
|
||||||
|
|
||||||
//Impact
|
//Impact
|
||||||
if(event.getEntity() instanceof LivingEntity)
|
Axes.impact(attacker, target);
|
||||||
Axes.impact(attacker, (LivingEntity)event.getEntity());
|
|
||||||
|
|
||||||
if (!(event instanceof FakeEntityDamageByEntityEvent) && PPa.getSkullSplitterMode())
|
if (!(event instanceof FakeEntityDamageByEntityEvent) && PPa.getSkullSplitterMode())
|
||||||
Axes.applyAoeDamage(attacker, event, pluginx);
|
Axes.applyAoeDamage(attacker, target, damage, pluginx);
|
||||||
|
|
||||||
if(target instanceof Player)
|
if(target instanceof Player)
|
||||||
PvPExperienceGain(attacker, PPa, (Player) target, event.getDamage(), SkillType.AXES);
|
PvPExperienceGain(attacker, PPa, (Player) target, damage, SkillType.AXES);
|
||||||
else if(!pluginx.misc.mobSpawnerList.contains(target.getEntityId()))
|
else if(!pluginx.misc.mobSpawnerList.contains(target.getEntityId()))
|
||||||
PvEExperienceGain(attacker, PPa, target, event.getDamage(), SkillType.AXES);
|
PvEExperienceGain(attacker, PPa, target, damage, SkillType.AXES);
|
||||||
}
|
}
|
||||||
else if(itemInHand.getTypeId() == 0 && mcPermissions.getInstance().unarmed(attacker)) //Unarmed
|
else if(itemInHand.getTypeId() == 0 && mcPermissions.getInstance().unarmed(attacker)) //Unarmed
|
||||||
{
|
{
|
||||||
Unarmed.unarmedBonus(attacker, event);
|
if(PPa.getFistsPreparationMode())
|
||||||
|
Skills.abilityCheck(attacker, PPa, SkillType.UNARMED);
|
||||||
|
|
||||||
|
damage += Unarmed.unarmedBonus(PPa.getSkillLevel(SkillType.UNARMED));
|
||||||
|
|
||||||
if(PPa.getBerserkMode())
|
if(PPa.getBerserkMode())
|
||||||
event.setDamage(event.getDamage() + (event.getDamage() / 2));
|
damage *= 1.5;
|
||||||
|
|
||||||
if(target instanceof Player)
|
if(target instanceof Player)
|
||||||
Unarmed.disarmProcCheck(attacker, (Player) target); //Disarm
|
Unarmed.disarmProcCheck(attacker, PPa.getSkillLevel(SkillType.UNARMED), (Player) target); //Disarm
|
||||||
|
|
||||||
if(target instanceof Player)
|
if(target instanceof Player)
|
||||||
PvPExperienceGain(attacker, PPa, (Player) target, event.getDamage(), SkillType.UNARMED);
|
PvPExperienceGain(attacker, PPa, (Player) target, damage, SkillType.UNARMED);
|
||||||
else if(!pluginx.misc.mobSpawnerList.contains(target.getEntityId()))
|
else if(!pluginx.misc.mobSpawnerList.contains(target.getEntityId()))
|
||||||
PvEExperienceGain(attacker, PPa, target, event.getDamage(), SkillType.UNARMED);
|
PvEExperienceGain(attacker, PPa, target, damage, SkillType.UNARMED);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Player use bone on wolf.
|
//Player use bone on wolf.
|
||||||
@ -116,6 +122,7 @@ public class Combat
|
|||||||
if(itemInHand.getTypeId() == 352 && mcPermissions.getInstance().taming(attacker))
|
if(itemInHand.getTypeId() == 352 && mcPermissions.getInstance().taming(attacker))
|
||||||
{
|
{
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
|
||||||
if(wolf.isTamed())
|
if(wolf.isTamed())
|
||||||
attacker.sendMessage(mcLocale.getString("Combat.BeastLore")+" "+
|
attacker.sendMessage(mcLocale.getString("Combat.BeastLore")+" "+
|
||||||
mcLocale.getString("Combat.BeastLoreOwner", new Object[] {Taming.getOwnerName(wolf)})+" "+
|
mcLocale.getString("Combat.BeastLoreOwner", new Object[] {Taming.getOwnerName(wolf)})+" "+
|
||||||
@ -125,6 +132,8 @@ public class Combat
|
|||||||
mcLocale.getString("Combat.BeastLoreHealthWolf", new Object[] {wolf.getHealth()}));
|
mcLocale.getString("Combat.BeastLoreHealthWolf", new Object[] {wolf.getHealth()}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
event.setDamage(damage);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -182,17 +191,6 @@ public class Combat
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void combatAbilityChecks(Player attacker, PlayerProfile PPa)
|
|
||||||
{
|
|
||||||
//Check to see if any abilities need to be activated
|
|
||||||
if(PPa.getAxePreparationMode())
|
|
||||||
Skills.abilityCheck(attacker, SkillType.AXES);
|
|
||||||
if(PPa.getSwordsPreparationMode())
|
|
||||||
Skills.abilityCheck(attacker, SkillType.SWORDS);
|
|
||||||
if(PPa.getFistsPreparationMode())
|
|
||||||
Skills.abilityCheck(attacker, SkillType.UNARMED);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void archeryCheck(EntityDamageByEntityEvent event, mcMMO pluginx)
|
public static void archeryCheck(EntityDamageByEntityEvent event, mcMMO pluginx)
|
||||||
{
|
{
|
||||||
Arrow arrow = (Arrow)event.getDamager();
|
Arrow arrow = (Arrow)event.getDamager();
|
||||||
@ -322,7 +320,6 @@ public class Combat
|
|||||||
EntityDamageEvent ede = (EntityDamageByEntityEvent) new FakeEntityDamageByEntityEvent(attacker, target, EntityDamageEvent.DamageCause.ENTITY_ATTACK, dmg);
|
EntityDamageEvent ede = (EntityDamageByEntityEvent) new FakeEntityDamageByEntityEvent(attacker, target, EntityDamageEvent.DamageCause.ENTITY_ATTACK, dmg);
|
||||||
Bukkit.getPluginManager().callEvent(ede);
|
Bukkit.getPluginManager().callEvent(ede);
|
||||||
if(ede.isCancelled()) return;
|
if(ede.isCancelled()) return;
|
||||||
|
|
||||||
target.damage(ede.getDamage());
|
target.damage(ede.getDamage());
|
||||||
} else {
|
} else {
|
||||||
target.damage(dmg);
|
target.damage(dmg);
|
||||||
|
@ -144,7 +144,7 @@ public class mcBlockListener implements Listener
|
|||||||
|
|
||||||
//Green Terra
|
//Green Terra
|
||||||
if(PP.getHoePreparationMode() && mcPermissions.getInstance().herbalismAbility(player) && ((id == 59 && block.getData() == (byte) 0x07) || Herbalism.canBeGreenTerra(block)))
|
if(PP.getHoePreparationMode() && mcPermissions.getInstance().herbalismAbility(player) && ((id == 59 && block.getData() == (byte) 0x07) || Herbalism.canBeGreenTerra(block)))
|
||||||
Skills.abilityCheck(player, SkillType.HERBALISM);
|
Skills.abilityCheck(player, PP, SkillType.HERBALISM);
|
||||||
|
|
||||||
//Wheat && Triple drops
|
//Wheat && Triple drops
|
||||||
if(PP.getGreenTerraMode() && Herbalism.canBeGreenTerra(block))
|
if(PP.getGreenTerraMode() && Herbalism.canBeGreenTerra(block))
|
||||||
@ -220,17 +220,17 @@ public class mcBlockListener implements Listener
|
|||||||
if(m.abilityBlockCheck(block))
|
if(m.abilityBlockCheck(block))
|
||||||
{
|
{
|
||||||
if(PP.getHoePreparationMode() && Herbalism.canBeGreenTerra(block))
|
if(PP.getHoePreparationMode() && Herbalism.canBeGreenTerra(block))
|
||||||
Skills.abilityCheck(player, SkillType.HERBALISM);
|
Skills.abilityCheck(player, PP, SkillType.HERBALISM);
|
||||||
if(PP.getAxePreparationMode() && id == 17 && mcPermissions.getInstance().woodCuttingAbility(player))
|
if(PP.getAxePreparationMode() && id == 17 && mcPermissions.getInstance().woodCuttingAbility(player))
|
||||||
Skills.abilityCheck(player, SkillType.WOODCUTTING);
|
Skills.abilityCheck(player, PP, SkillType.WOODCUTTING);
|
||||||
if(PP.getPickaxePreparationMode() && Mining.canBeSuperBroken(block))
|
if(PP.getPickaxePreparationMode() && Mining.canBeSuperBroken(block))
|
||||||
Skills.abilityCheck(player, SkillType.MINING);
|
Skills.abilityCheck(player, PP, SkillType.MINING);
|
||||||
if(PP.getShovelPreparationMode() && Excavation.canBeGigaDrillBroken(block))
|
if(PP.getShovelPreparationMode() && Excavation.canBeGigaDrillBroken(block))
|
||||||
Skills.abilityCheck(player, SkillType.EXCAVATION);
|
Skills.abilityCheck(player, PP, SkillType.EXCAVATION);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(PP.getFistsPreparationMode() && (Excavation.canBeGigaDrillBroken(block) || id == 78))
|
if(PP.getFistsPreparationMode() && (Excavation.canBeGigaDrillBroken(block) || id == 78))
|
||||||
Skills.abilityCheck(player, SkillType.UNARMED);
|
Skills.abilityCheck(player, PP, SkillType.UNARMED);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* TREE FELLER STUFF
|
* TREE FELLER STUFF
|
||||||
|
@ -22,75 +22,66 @@ import org.bukkit.entity.Entity;
|
|||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.entity.Wolf;
|
import org.bukkit.entity.Wolf;
|
||||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.plugin.Plugin;
|
|
||||||
import com.gmail.nossr50.Combat;
|
import com.gmail.nossr50.Combat;
|
||||||
import com.gmail.nossr50.Users;
|
import com.gmail.nossr50.Users;
|
||||||
import com.gmail.nossr50.m;
|
import com.gmail.nossr50.m;
|
||||||
import com.gmail.nossr50.mcPermissions;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||||
import com.gmail.nossr50.datatypes.SkillType;
|
import com.gmail.nossr50.datatypes.SkillType;
|
||||||
import com.gmail.nossr50.locale.mcLocale;
|
import com.gmail.nossr50.locale.mcLocale;
|
||||||
import com.gmail.nossr50.party.Party;
|
import com.gmail.nossr50.party.Party;
|
||||||
|
|
||||||
public class Axes {
|
public class Axes
|
||||||
public static void axesBonus(Player attacker, EntityDamageByEntityEvent event)
|
{
|
||||||
|
public static int axesBonus(Player attacker, PlayerProfile PP)
|
||||||
{
|
{
|
||||||
int bonus = 0;
|
|
||||||
|
|
||||||
//Add 1 DMG for every 50 skill levels
|
//Add 1 DMG for every 50 skill levels
|
||||||
bonus += Users.getProfile(attacker).getSkillLevel(SkillType.AXES)/50;
|
int bonus = PP.getSkillLevel(SkillType.AXES) / 50;
|
||||||
|
|
||||||
if(bonus > 4)
|
if(bonus > 4)
|
||||||
bonus = 4;
|
bonus = 4;
|
||||||
|
|
||||||
event.setDamage(event.getDamage() + bonus);
|
return bonus;
|
||||||
}
|
}
|
||||||
public static void axeCriticalCheck(Player attacker, EntityDamageByEntityEvent event, Plugin pluginx)
|
|
||||||
{
|
|
||||||
Entity x = event.getEntity();
|
|
||||||
|
|
||||||
if(x instanceof Wolf){
|
public static double axeCriticalBonus(Player attacker, int skillLevel, LivingEntity target, mcMMO pluginx)
|
||||||
Wolf wolf = (Wolf)x;
|
|
||||||
if(Taming.getOwner(wolf, pluginx) != null)
|
|
||||||
{
|
{
|
||||||
if(Taming.getOwner(wolf, pluginx) == attacker)
|
if(target instanceof Wolf)
|
||||||
return;
|
{
|
||||||
if(Party.getInstance().inSameParty(attacker, Taming.getOwner(wolf, pluginx)))
|
if(Taming.isFriendlyWolf(attacker, (Wolf) target, pluginx))
|
||||||
return;
|
return 1.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
double criticalBonus = 0.0;
|
||||||
|
|
||||||
|
if(skillLevel >= 750)
|
||||||
|
{
|
||||||
|
if(Math.random() * 1000 <= 750)
|
||||||
|
{
|
||||||
|
if(target instanceof Player)
|
||||||
|
{
|
||||||
|
criticalBonus = 1.5;
|
||||||
|
((Player) target).sendMessage(ChatColor.DARK_RED + "You were CRITICALLY hit!");
|
||||||
}
|
}
|
||||||
PlayerProfile PPa = Users.getProfile(attacker);
|
else
|
||||||
if(m.isAxes(attacker.getItemInHand()) && mcPermissions.getInstance().axes(attacker)){
|
criticalBonus = 2.0;
|
||||||
if(PPa.getSkillLevel(SkillType.AXES) >= 750){
|
|
||||||
if(Math.random() * 1000 <= 750 && !x.isDead()){
|
|
||||||
if(x instanceof Player){
|
|
||||||
int damage = (event.getDamage() * 2) - (event.getDamage() / 2);
|
|
||||||
event.setDamage(damage);
|
|
||||||
Player player = (Player)x;
|
|
||||||
player.sendMessage(ChatColor.DARK_RED + "You were CRITICALLY hit!");
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
int damage = event.getDamage() * 2;
|
|
||||||
event.setDamage(damage);
|
|
||||||
}
|
|
||||||
attacker.sendMessage(ChatColor.RED+"CRITICAL HIT!");
|
|
||||||
}
|
|
||||||
} else if(Math.random() * 1000 <= PPa.getSkillLevel(SkillType.AXES) && !x.isDead()){
|
|
||||||
if(x instanceof Player){
|
|
||||||
int damage = (event.getDamage() * 2) - (event.getDamage() / 2);
|
|
||||||
event.setDamage(damage);
|
|
||||||
Player player = (Player)x;
|
|
||||||
player.sendMessage(ChatColor.DARK_RED + "You were CRITICALLY hit!");
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
int damage = event.getDamage() * 2;
|
|
||||||
event.setDamage(damage);
|
|
||||||
}
|
|
||||||
attacker.sendMessage(ChatColor.RED+"CRITICAL HIT!");
|
attacker.sendMessage(ChatColor.RED+"CRITICAL HIT!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if(Math.random() * 1000 <= skillLevel)
|
||||||
|
{
|
||||||
|
if(target instanceof Player)
|
||||||
|
{
|
||||||
|
criticalBonus = 1.5;
|
||||||
|
((Player) target).sendMessage(ChatColor.DARK_RED + "You were CRITICALLY hit!");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
criticalBonus = 2.0;
|
||||||
|
attacker.sendMessage(ChatColor.RED+"CRITICAL HIT!");
|
||||||
|
}
|
||||||
|
|
||||||
|
return criticalBonus;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void impact(Player attacker, LivingEntity target)
|
public static void impact(Player attacker, LivingEntity target)
|
||||||
@ -146,68 +137,60 @@ public class Axes {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void applyAoeDamage(Player attacker, EntityDamageByEntityEvent event, Plugin pluginx)
|
public static void applyAoeDamage(Player attacker, LivingEntity target, int damage, mcMMO pluginx)
|
||||||
{
|
{
|
||||||
int targets = 0;
|
int targets = 0;
|
||||||
|
|
||||||
int dmgAmount = (event.getDamage()/2);
|
int dmgAmount = damage / 2;
|
||||||
|
|
||||||
//Setup minimum damage
|
//Setup minimum damage
|
||||||
if(dmgAmount < 1)
|
if(dmgAmount < 1)
|
||||||
dmgAmount = 1;
|
dmgAmount = 1;
|
||||||
|
|
||||||
if(event.getEntity() instanceof LivingEntity)
|
|
||||||
{
|
|
||||||
LivingEntity x = (LivingEntity) event.getEntity();
|
|
||||||
targets = m.getTier(attacker);
|
targets = m.getTier(attacker);
|
||||||
|
|
||||||
for(Entity derp : x.getNearbyEntities(2.5, 2.5, 2.5))
|
for(Entity derp : target.getNearbyEntities(2.5, 2.5, 2.5))
|
||||||
{
|
{
|
||||||
//Make sure the Wolf is not friendly
|
//Make sure the Wolf is not friendly
|
||||||
if(derp instanceof Wolf)
|
if(derp instanceof Wolf)
|
||||||
{
|
{
|
||||||
Wolf hurrDurr = (Wolf)derp;
|
if (Taming.isFriendlyWolf(attacker, (Wolf) derp, pluginx))
|
||||||
if(Taming.getOwner(hurrDurr, pluginx) == attacker)
|
|
||||||
continue;
|
|
||||||
if(Party.getInstance().inSameParty(attacker, Taming.getOwner(hurrDurr, pluginx)))
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Damage nearby LivingEntities
|
//Damage nearby LivingEntities
|
||||||
if(derp instanceof LivingEntity && targets >= 1)
|
else if(derp instanceof LivingEntity && targets >= 1)
|
||||||
{
|
{
|
||||||
if(derp instanceof Player)
|
if(derp instanceof Player)
|
||||||
{
|
{
|
||||||
Player target = (Player)derp;
|
Player nearbyPlayer = (Player) derp;
|
||||||
|
|
||||||
if(Users.getProfile(target).getGodMode())
|
if(Users.getProfile(nearbyPlayer).getGodMode())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if(target.getName().equals(attacker.getName()))
|
if(nearbyPlayer.getName().equals(attacker.getName()))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if(Party.getInstance().inSameParty(attacker, target))
|
if(Party.getInstance().inSameParty(attacker, nearbyPlayer))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if(target.isDead())
|
if(target.isDead())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if(targets >= 1 && derp.getWorld().getPVP())
|
if(targets >= 1 && nearbyPlayer.getWorld().getPVP())
|
||||||
{
|
{
|
||||||
Combat.dealDamage(target, dmgAmount, attacker);
|
Combat.dealDamage(nearbyPlayer, dmgAmount, attacker);
|
||||||
target.sendMessage(ChatColor.DARK_RED+"Struck by CLEAVE!");
|
nearbyPlayer.sendMessage(ChatColor.DARK_RED+"Struck by CLEAVE!");
|
||||||
targets--;
|
targets--;
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LivingEntity target = (LivingEntity)derp;
|
LivingEntity nearbyLivingEntity = (LivingEntity) derp;
|
||||||
Combat.dealDamage(target, dmgAmount, attacker);
|
Combat.dealDamage(nearbyLivingEntity, dmgAmount, attacker);
|
||||||
targets--;
|
targets--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@ -275,9 +275,8 @@ public class Skills
|
|||||||
* @param player The player activating the ability
|
* @param player The player activating the ability
|
||||||
* @param type The skill the ability is based on
|
* @param type The skill the ability is based on
|
||||||
*/
|
*/
|
||||||
public static void abilityCheck(Player player, SkillType type)
|
public static void abilityCheck(Player player, PlayerProfile PP, SkillType type)
|
||||||
{
|
{
|
||||||
PlayerProfile PP = Users.getProfile(player);
|
|
||||||
AbilityType ability = type.getAbility();
|
AbilityType ability = type.getAbility();
|
||||||
if(type.getTool().inHand(player.getItemInHand()))
|
if(type.getTool().inHand(player.getItemInHand()))
|
||||||
{
|
{
|
||||||
|
@ -33,112 +33,93 @@ import com.gmail.nossr50.party.Party;
|
|||||||
|
|
||||||
public class Swords
|
public class Swords
|
||||||
{
|
{
|
||||||
public static void bleedCheck(Player attacker, LivingEntity x, mcMMO pluginx)
|
public static void bleedCheck(Player attacker, int skillLevel, LivingEntity target, mcMMO pluginx)
|
||||||
{
|
{
|
||||||
PlayerProfile PPa = Users.getProfile(attacker);
|
if(target instanceof Wolf)
|
||||||
|
{
|
||||||
|
if(Taming.isFriendlyWolf(attacker, (Wolf) target, pluginx))
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if(x instanceof Wolf)
|
if(skillLevel >= 750)
|
||||||
{
|
|
||||||
Wolf wolf = (Wolf)x;
|
|
||||||
if(Taming.getOwner(wolf, pluginx) != null)
|
|
||||||
{
|
|
||||||
if(Taming.getOwner(wolf, pluginx) == attacker)
|
|
||||||
return;
|
|
||||||
if(Party.getInstance().inSameParty(attacker, Taming.getOwner(wolf, pluginx)))
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(mcPermissions.getInstance().swords(attacker) && m.isSwords(attacker.getItemInHand())){
|
|
||||||
if(PPa.getSkillLevel(SkillType.SWORDS) >= 750)
|
|
||||||
{
|
{
|
||||||
if(Math.random() * 1000 <= 750)
|
if(Math.random() * 1000 <= 750)
|
||||||
{
|
{
|
||||||
if(!(x instanceof Player))
|
if(!(target instanceof Player))
|
||||||
pluginx.misc.addToBleedQue(x);
|
pluginx.misc.addToBleedQue(target);
|
||||||
if(x instanceof Player)
|
else if(target instanceof Player)
|
||||||
{
|
Users.getProfile((Player) target).addBleedTicks(3);
|
||||||
Player target = (Player)x;
|
|
||||||
Users.getProfile(target).addBleedTicks(3);
|
|
||||||
}
|
|
||||||
attacker.sendMessage(ChatColor.GREEN+"**ENEMY BLEEDING**");
|
attacker.sendMessage(ChatColor.GREEN+"**ENEMY BLEEDING**");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (Math.random() * 1000 <= PPa.getSkillLevel(SkillType.SWORDS))
|
else if(Math.random() * 1000 <= skillLevel)
|
||||||
{
|
{
|
||||||
if(!(x instanceof Player))
|
if(!(target instanceof Player))
|
||||||
pluginx.misc.addToBleedQue(x);
|
pluginx.misc.addToBleedQue(target);
|
||||||
if(x instanceof Player)
|
else if(target instanceof Player)
|
||||||
{
|
Users.getProfile((Player) target).addBleedTicks(2);
|
||||||
Player target = (Player)x;
|
|
||||||
Users.getProfile(target).addBleedTicks(2);
|
|
||||||
}
|
|
||||||
attacker.sendMessage(ChatColor.GREEN+"**ENEMY BLEEDING**");
|
attacker.sendMessage(ChatColor.GREEN+"**ENEMY BLEEDING**");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
public static void applySerratedStrikes(Player attacker, EntityDamageByEntityEvent event, mcMMO pluginx)
|
public static void applySerratedStrikes(Player attacker, LivingEntity target, int damage, mcMMO pluginx)
|
||||||
{
|
{
|
||||||
int targets = 0;
|
int targets = 0;
|
||||||
|
|
||||||
int dmgAmount = (event.getDamage()/4);
|
int dmgAmount = damage / 4;
|
||||||
|
|
||||||
//Setup minimum damage
|
//Setup minimum damage
|
||||||
if(dmgAmount < 1)
|
if(dmgAmount < 1)
|
||||||
dmgAmount = 1;
|
dmgAmount = 1;
|
||||||
|
|
||||||
if(event.getEntity() instanceof LivingEntity)
|
|
||||||
{
|
|
||||||
LivingEntity x = (LivingEntity) event.getEntity();
|
|
||||||
targets = m.getTier(attacker);
|
targets = m.getTier(attacker);
|
||||||
|
|
||||||
for(Entity derp : x.getNearbyEntities(2.5, 2.5, 2.5))
|
for(Entity derp : target.getNearbyEntities(2.5, 2.5, 2.5))
|
||||||
{
|
{
|
||||||
//Make sure the Wolf is not friendly
|
//Make sure the Wolf is not friendly
|
||||||
if(derp instanceof Wolf)
|
if(derp instanceof Wolf)
|
||||||
{
|
{
|
||||||
Wolf hurrDurr = (Wolf)derp;
|
if (Taming.isFriendlyWolf(attacker, (Wolf) target, pluginx))
|
||||||
if(Taming.getOwner(hurrDurr, pluginx) == attacker)
|
|
||||||
continue;
|
|
||||||
if(Party.getInstance().inSameParty(attacker, Taming.getOwner(hurrDurr, pluginx)))
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Damage nearby LivingEntities
|
//Damage nearby LivingEntities
|
||||||
if(derp instanceof LivingEntity && targets >= 1)
|
if(derp instanceof LivingEntity && targets >= 1)
|
||||||
{
|
{
|
||||||
if(derp instanceof Player)
|
if(derp instanceof Player)
|
||||||
{
|
{
|
||||||
Player target = (Player)derp;
|
Player nearbyPlayer = (Player) derp;
|
||||||
|
|
||||||
if(target.getName().equals(attacker.getName()))
|
if(nearbyPlayer.getName().equals(attacker.getName()))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if(Users.getProfile(target).getGodMode())
|
if(Users.getProfile(nearbyPlayer).getGodMode())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if(Party.getInstance().inSameParty(attacker, target))
|
if(Party.getInstance().inSameParty(attacker, nearbyPlayer))
|
||||||
continue;
|
continue;
|
||||||
if(targets >= 1 && derp.getWorld().getPVP())
|
|
||||||
|
if(targets >= 1 && nearbyPlayer.getWorld().getPVP())
|
||||||
{
|
{
|
||||||
Combat.dealDamage(target, dmgAmount, attacker);
|
Combat.dealDamage(nearbyPlayer, dmgAmount, attacker);
|
||||||
target.sendMessage(ChatColor.DARK_RED+"Struck by Serrated Strikes!");
|
nearbyPlayer.sendMessage(ChatColor.DARK_RED+"Struck by Serrated Strikes!");
|
||||||
Users.getProfile(target).addBleedTicks(5);
|
Users.getProfile(nearbyPlayer).addBleedTicks(5);
|
||||||
targets--;
|
targets--;
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(!pluginx.misc.bleedTracker.contains(derp))
|
LivingEntity neabyLivingEntity = (LivingEntity) derp;
|
||||||
pluginx.misc.addToBleedQue((LivingEntity)derp);
|
|
||||||
|
|
||||||
LivingEntity target = (LivingEntity)derp;
|
if(!pluginx.misc.bleedTracker.contains(neabyLivingEntity))
|
||||||
Combat.dealDamage(target, dmgAmount, attacker);
|
pluginx.misc.addToBleedQue(neabyLivingEntity);
|
||||||
|
|
||||||
|
Combat.dealDamage(neabyLivingEntity, dmgAmount, attacker);
|
||||||
targets--;
|
targets--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public static void counterAttackChecks(EntityDamageByEntityEvent event)
|
public static void counterAttackChecks(EntityDamageByEntityEvent event)
|
||||||
{
|
{
|
||||||
@ -210,9 +191,7 @@ public class Swords
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
|
||||||
Combat.dealDamage(x, 2);
|
Combat.dealDamage(x, 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@ -31,6 +31,7 @@ import com.gmail.nossr50.mcMMO;
|
|||||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||||
import com.gmail.nossr50.datatypes.SkillType;
|
import com.gmail.nossr50.datatypes.SkillType;
|
||||||
import com.gmail.nossr50.locale.mcLocale;
|
import com.gmail.nossr50.locale.mcLocale;
|
||||||
|
import com.gmail.nossr50.party.Party;
|
||||||
|
|
||||||
public class Taming
|
public class Taming
|
||||||
{
|
{
|
||||||
@ -169,4 +170,11 @@ public class Taming
|
|||||||
if(cause == DamageCause.FIRE_TICK)
|
if(cause == DamageCause.FIRE_TICK)
|
||||||
event.getEntity().setFireTicks(0);
|
event.getEntity().setFireTicks(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isFriendlyWolf(Player player, Wolf wolf, mcMMO pluginx)
|
||||||
|
{
|
||||||
|
if(getOwner(wolf, pluginx) == player || Party.getInstance().inSameParty(player, getOwner(wolf, pluginx)))
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,31 +18,25 @@ package com.gmail.nossr50.skills;
|
|||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import com.gmail.nossr50.Users;
|
|
||||||
import com.gmail.nossr50.m;
|
import com.gmail.nossr50.m;
|
||||||
import com.gmail.nossr50.datatypes.SkillType;
|
|
||||||
import com.gmail.nossr50.locale.mcLocale;
|
import com.gmail.nossr50.locale.mcLocale;
|
||||||
|
|
||||||
public class Unarmed {
|
public class Unarmed
|
||||||
|
{
|
||||||
public static void unarmedBonus(Player attacker, EntityDamageByEntityEvent event)
|
public static int unarmedBonus(int skillLevel)
|
||||||
{
|
{
|
||||||
int bonus = 3;
|
|
||||||
|
|
||||||
//Add 1 DMG for every 50 skill levels
|
//Add 1 DMG for every 50 skill levels
|
||||||
bonus += Users.getProfile(attacker).getSkillLevel(SkillType.UNARMED)/50;
|
int bonus = skillLevel / 50;
|
||||||
|
|
||||||
if(bonus > 8)
|
if(bonus > 8)
|
||||||
bonus = 8;
|
bonus = 8;
|
||||||
|
|
||||||
event.setDamage(event.getDamage() + bonus);
|
return bonus;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void disarmProcCheck(Player attacker, Player defender)
|
public static void disarmProcCheck(Player attacker, int skillLevel, Player defender)
|
||||||
{
|
{
|
||||||
int skillLevel = Users.getProfile(attacker).getSkillLevel(SkillType.UNARMED);
|
|
||||||
if(defender.getItemInHand() != null && defender.getItemInHand().getType() != Material.AIR)
|
if(defender.getItemInHand() != null && defender.getItemInHand().getType() != Material.AIR)
|
||||||
{
|
{
|
||||||
if(skillLevel >= 1000)
|
if(skillLevel >= 1000)
|
||||||
|
Loading…
Reference in New Issue
Block a user