mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-24 14:16:45 +01:00
again
This commit is contained in:
commit
8fe55812ef
@ -39,23 +39,30 @@ import com.gmail.nossr50.skills.Unarmed;
|
|||||||
|
|
||||||
public class Combat
|
public class Combat
|
||||||
{
|
{
|
||||||
public static void combatChecks(EntityDamageEvent event, mcMMO pluginx)
|
public static void combatChecks(EntityDamageByEntityEvent event, mcMMO pluginx)
|
||||||
{
|
{
|
||||||
if(event.isCancelled() || event.getDamage() == 0 || event.getEntity().isDead())
|
if(event.isCancelled() || event.getDamage() == 0 || event.getEntity().isDead())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(event instanceof EntityDamageByEntityEvent)
|
//Declare Things
|
||||||
{
|
Entity damager = event.getDamager();
|
||||||
//Declare Things
|
LivingEntity target = (LivingEntity) event.getEntity();
|
||||||
EntityDamageByEntityEvent eEvent = (EntityDamageByEntityEvent) event;
|
int damage = event.getDamage();
|
||||||
Entity damager = eEvent.getDamager();
|
|
||||||
LivingEntity target = (LivingEntity) eEvent.getEntity();
|
|
||||||
int damage = eEvent.getDamage();
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* PLAYER VERSUS ENTITIES
|
* PLAYER VERSUS ENTITIES
|
||||||
*/
|
*/
|
||||||
if(damager instanceof Player)
|
if(damager instanceof Player)
|
||||||
|
{
|
||||||
|
Player attacker = (Player) event.getDamager();
|
||||||
|
ItemStack itemInHand = attacker.getItemInHand();
|
||||||
|
PlayerProfile PPa = Users.getProfile(attacker);
|
||||||
|
|
||||||
|
//If there are any abilities to activate
|
||||||
|
combatAbilityChecks(attacker, PPa, pluginx);
|
||||||
|
|
||||||
|
//Damage modifiers and proc checks
|
||||||
|
if(m.isSwords(itemInHand) && mcPermissions.getInstance().swords(attacker))
|
||||||
{
|
{
|
||||||
Player attacker = (Player) eEvent.getDamager();
|
Player attacker = (Player) eEvent.getDamager();
|
||||||
ItemStack itemInHand = attacker.getItemInHand();
|
ItemStack itemInHand = attacker.getItemInHand();
|
||||||
@ -115,81 +122,104 @@ public class Combat
|
|||||||
PvEExperienceGain(attacker, PPa, target, damage, SkillType.UNARMED);
|
PvEExperienceGain(attacker, PPa, target, damage, SkillType.UNARMED);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Player use bone on wolf.
|
Axes.axeCriticalCheck(attacker, event, pluginx); //Critical hit
|
||||||
else if(target instanceof Wolf)
|
|
||||||
{
|
|
||||||
Wolf wolf = (Wolf) target;
|
|
||||||
|
|
||||||
if(itemInHand.getTypeId() == 352 && mcPermissions.getInstance().taming(attacker))
|
if (!(event instanceof FakeEntityDamageByEntityEvent) && PPa.getSkullSplitterMode())
|
||||||
{
|
Axes.applyAoeDamage(attacker, event, pluginx);
|
||||||
event.setCancelled(true);
|
|
||||||
if(wolf.isTamed())
|
if(target instanceof Player)
|
||||||
attacker.sendMessage(mcLocale.getString("Combat.BeastLore")+" "+
|
PvPExperienceGain(attacker, PPa, (Player) target, event.getDamage(), SkillType.AXES);
|
||||||
mcLocale.getString("Combat.BeastLoreOwner", new Object[] {Taming.getOwnerName(wolf)})+" "+
|
else if(!pluginx.misc.mobSpawnerList.contains(target.getEntityId()))
|
||||||
mcLocale.getString("Combat.BeastLoreHealthWolfTamed", new Object[] {wolf.getHealth()}));
|
PvEExperienceGain(attacker, PPa, target, event.getDamage(), SkillType.AXES);
|
||||||
else
|
|
||||||
attacker.sendMessage(mcLocale.getString("Combat.BeastLore")+" "+
|
|
||||||
mcLocale.getString("Combat.BeastLoreHealthWolf", new Object[] {wolf.getHealth()}));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
eEvent.setDamage(damage);
|
eEvent.setDamage(damage);
|
||||||
}
|
}
|
||||||
|
else if(itemInHand.getTypeId() == 0 && mcPermissions.getInstance().unarmed(attacker)) //Unarmed
|
||||||
/*
|
|
||||||
* TAMING (WOLVES VERSUS ENTITIES)
|
|
||||||
*/
|
|
||||||
else if(damager instanceof Wolf)
|
|
||||||
{
|
{
|
||||||
Wolf wolf = (Wolf) damager;
|
Unarmed.unarmedBonus(attacker, event);
|
||||||
|
if(PPa.getBerserkMode())
|
||||||
|
event.setDamage(event.getDamage() + (event.getDamage() / 2));
|
||||||
|
if(target instanceof Player)
|
||||||
|
Unarmed.disarmProcCheck(attacker, (Player) target); //Disarm
|
||||||
|
|
||||||
if (wolf.isTamed() && Taming.ownerOnline(wolf, pluginx))
|
if(target instanceof Player)
|
||||||
{
|
PvPExperienceGain(attacker, PPa, (Player) target, event.getDamage(), SkillType.UNARMED);
|
||||||
Player master = Taming.getOwner(wolf, pluginx);
|
else if(!pluginx.misc.mobSpawnerList.contains(target.getEntityId()))
|
||||||
if (master == null) //Can it really happen?
|
PvEExperienceGain(attacker, PPa, target, event.getDamage(), SkillType.UNARMED);
|
||||||
return;
|
|
||||||
|
|
||||||
PlayerProfile PPo = Users.getProfile(master);
|
|
||||||
if(mcPermissions.getInstance().taming(master))
|
|
||||||
{
|
|
||||||
//Fast Food Service
|
|
||||||
Taming.fastFoodService(PPo, wolf, event);
|
|
||||||
|
|
||||||
//Sharpened Claws
|
|
||||||
Taming.sharpenedClaws(PPo, event);
|
|
||||||
|
|
||||||
//Gore
|
|
||||||
Taming.gore(PPo, event, master, pluginx);
|
|
||||||
|
|
||||||
//Reward XP
|
|
||||||
Taming.rewardXp(event, pluginx, master);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Another offensive check for Archery
|
//Player use bone on wolf.
|
||||||
else if(damager instanceof Arrow)
|
|
||||||
archeryCheck((EntityDamageByEntityEvent)event, pluginx);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* DEFENSIVE CHECKS
|
|
||||||
*/
|
|
||||||
if(target instanceof Player)
|
|
||||||
{
|
|
||||||
Swords.counterAttackChecks(eEvent);
|
|
||||||
Acrobatics.dodgeChecks(eEvent);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* DEFENSIVE CHECKS FOR WOLVES
|
|
||||||
*/
|
|
||||||
else if(target instanceof Wolf)
|
else if(target instanceof Wolf)
|
||||||
{
|
{
|
||||||
Wolf wolf = (Wolf) target;
|
Wolf wolf = (Wolf) target;
|
||||||
if(wolf.isTamed() && Taming.ownerOnline(wolf, pluginx))
|
|
||||||
Taming.preventDamage(eEvent, pluginx);
|
if(itemInHand.getTypeId() == 352 && mcPermissions.getInstance().taming(attacker))
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
if(wolf.isTamed())
|
||||||
|
attacker.sendMessage(mcLocale.getString("Combat.BeastLore")+" "+
|
||||||
|
mcLocale.getString("Combat.BeastLoreOwner", new Object[] {Taming.getOwnerName(wolf)})+" "+
|
||||||
|
mcLocale.getString("Combat.BeastLoreHealthWolfTamed", new Object[] {wolf.getHealth()}));
|
||||||
|
else
|
||||||
|
attacker.sendMessage(mcLocale.getString("Combat.BeastLore")+" "+
|
||||||
|
mcLocale.getString("Combat.BeastLoreHealthWolf", new Object[] {wolf.getHealth()}));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* TAMING (WOLVES VERSUS ENTITIES)
|
||||||
|
*/
|
||||||
|
else if(damager instanceof Wolf)
|
||||||
|
{
|
||||||
|
Wolf wolf = (Wolf) damager;
|
||||||
|
|
||||||
|
if (wolf.isTamed() && Taming.ownerOnline(wolf, pluginx))
|
||||||
|
{
|
||||||
|
Player master = Taming.getOwner(wolf, pluginx);
|
||||||
|
if (master == null) //Can it really happen?
|
||||||
|
return;
|
||||||
|
|
||||||
|
PlayerProfile PPo = Users.getProfile(master);
|
||||||
|
if(mcPermissions.getInstance().taming(master))
|
||||||
|
{
|
||||||
|
//Fast Food Service
|
||||||
|
Taming.fastFoodService(PPo, wolf, event);
|
||||||
|
|
||||||
|
//Sharpened Claws
|
||||||
|
Taming.sharpenedClaws(PPo, event);
|
||||||
|
|
||||||
|
//Gore
|
||||||
|
Taming.gore(PPo, event, master, pluginx);
|
||||||
|
|
||||||
|
//Reward XP
|
||||||
|
Taming.rewardXp(event, pluginx, master);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Another offensive check for Archery
|
||||||
|
else if(damager instanceof Arrow)
|
||||||
|
archeryCheck((EntityDamageByEntityEvent)event, pluginx);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* DEFENSIVE CHECKS
|
||||||
|
*/
|
||||||
|
if(target instanceof Player)
|
||||||
|
{
|
||||||
|
Swords.counterAttackChecks(event);
|
||||||
|
Acrobatics.dodgeChecks(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* DEFENSIVE CHECKS FOR WOLVES
|
||||||
|
*/
|
||||||
|
else if(target instanceof Wolf)
|
||||||
|
{
|
||||||
|
Wolf wolf = (Wolf) target;
|
||||||
|
if(wolf.isTamed() && Taming.ownerOnline(wolf, pluginx))
|
||||||
|
Taming.preventDamage(event, pluginx);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void archeryCheck(EntityDamageByEntityEvent event, mcMMO pluginx)
|
public static void archeryCheck(EntityDamageByEntityEvent event, mcMMO pluginx)
|
||||||
@ -383,38 +413,54 @@ public class Combat
|
|||||||
else
|
else
|
||||||
xpinc = damage;
|
xpinc = damage;
|
||||||
|
|
||||||
if(entity instanceof Animals)
|
if(entity instanceof Animals)
|
||||||
xp = (int) (xpinc * LoadProperties.animalXP);
|
xp = (int) (xpinc * LoadProperties.animalXP);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(entity instanceof Enderman)
|
EntityType type = entity.getType();
|
||||||
xp = (int) (xpinc * LoadProperties.endermanXP);
|
switch(type){
|
||||||
else if(entity instanceof Creeper)
|
case BLAZE:
|
||||||
xp = (int) (xpinc * LoadProperties.creeperXP);
|
xp = (int) (xpinc * LoadProperties.blazeXP);
|
||||||
else if(entity instanceof Silverfish)
|
break;
|
||||||
xp = (int) (xpinc * LoadProperties.silverfishXP);
|
case CAVE_SPIDER:
|
||||||
else if(entity instanceof CaveSpider)
|
xp = (int) (xpinc * LoadProperties.cavespiderXP);
|
||||||
xp = (int) (xpinc * LoadProperties.cavespiderXP);
|
break;
|
||||||
else if(entity instanceof Spider)
|
case CREEPER:
|
||||||
xp = (int) (xpinc * LoadProperties.spiderXP);
|
xp = (int) (xpinc * LoadProperties.creeperXP);
|
||||||
else if(entity instanceof Skeleton)
|
break;
|
||||||
xp = (int) (xpinc * LoadProperties.skeletonXP);
|
case ENDER_DRAGON:
|
||||||
else if(entity instanceof Zombie)
|
xp = (int) (xpinc * LoadProperties.enderdragonXP);
|
||||||
xp = (int) (xpinc * LoadProperties.zombieXP);
|
break;
|
||||||
else if(entity instanceof PigZombie)
|
case ENDERMAN:
|
||||||
xp = (int) (xpinc * LoadProperties.pigzombieXP);
|
xp = (int) (xpinc * LoadProperties.endermanXP);
|
||||||
else if(entity instanceof Slime)
|
break;
|
||||||
xp = (int) (xpinc * LoadProperties.slimeXP);
|
case GHAST:
|
||||||
else if(entity instanceof Ghast)
|
xp = (int) (xpinc * LoadProperties.ghastXP);
|
||||||
xp = (int) (xpinc * LoadProperties.ghastXP);
|
break;
|
||||||
else if(entity instanceof Blaze)
|
case MAGMA_CUBE:
|
||||||
xp = (int) (xpinc * LoadProperties.blazeXP);
|
xp = (int) (xpinc * LoadProperties.magmacubeXP);
|
||||||
else if(entity instanceof EnderDragon)
|
break;
|
||||||
xp = (int) (xpinc * LoadProperties.enderdragonXP);
|
case PIG_ZOMBIE:
|
||||||
else if(entity instanceof MagmaCube)
|
xp = (int) (xpinc * LoadProperties.pigzombieXP);
|
||||||
xp = (int) (xpinc * LoadProperties.magmacubeXP);
|
break;
|
||||||
}
|
case SILVERFISH:
|
||||||
}
|
xp = (int) (xpinc * LoadProperties.silverfishXP);
|
||||||
return xp;
|
break;
|
||||||
|
case SKELETON:
|
||||||
|
xp = (int) (xpinc * LoadProperties.skeletonXP);
|
||||||
|
break;
|
||||||
|
case SLIME:
|
||||||
|
xp = (int) (xpinc * LoadProperties.slimeXP);
|
||||||
|
break;
|
||||||
|
case SPIDER:
|
||||||
|
xp = (int) (xpinc * LoadProperties.spiderXP);
|
||||||
|
break;
|
||||||
|
case ZOMBIE:
|
||||||
|
xp = (int) (xpinc * LoadProperties.zombieXP);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return xp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -125,7 +125,7 @@ public class mcEntityListener implements Listener
|
|||||||
if(Party.getInstance().inSameParty(defender, attacker))
|
if(Party.getInstance().inSameParty(defender, attacker))
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
Combat.combatChecks(event, plugin);
|
Combat.combatChecks(eventb, plugin);
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* Check to see if the defender took damage so we can apply recently hurt
|
* Check to see if the defender took damage so we can apply recently hurt
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
*/
|
*/
|
||||||
package com.gmail.nossr50.skills;
|
package com.gmail.nossr50.skills;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import com.gmail.nossr50.m;
|
import com.gmail.nossr50.m;
|
||||||
@ -49,7 +48,6 @@ public class Unarmed
|
|||||||
y.sendMessage(mcLocale.getString("Skills.BerserkPlayer", new Object[] {player.getName()}));
|
y.sendMessage(mcLocale.getString("Skills.BerserkPlayer", new Object[] {player.getName()}));
|
||||||
}
|
}
|
||||||
PPa.setSkillDATS(AbilityType.BERSERK, System.currentTimeMillis()+(ticks*1000));
|
PPa.setSkillDATS(AbilityType.BERSERK, System.currentTimeMillis()+(ticks*1000));
|
||||||
//System.out.println("getSkillDATS(): "+PPa.getSkillDATS(AbilityType.BERSERK));
|
|
||||||
PPa.setBerserkMode(true);
|
PPa.setBerserkMode(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user