mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-26 23:26:45 +01:00
The start of the great whitespace cleanup.
This commit is contained in:
parent
e822515403
commit
6733eb93f2
@ -1,425 +1,408 @@
|
|||||||
/*
|
/*
|
||||||
This file is part of mcMMO.
|
* Copyright (C) 2012 Matt 'The Yeti' Burnett & mcMMO Development
|
||||||
|
* Copyright (C) 2010-2011 'nossr50'
|
||||||
mcMMO is free software: you can redistribute it and/or modify
|
*
|
||||||
it under the terms of the GNU General Public License as published by
|
* This program is free software: you can redistribute it and/or modify
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
* it under the terms of the GNU General Public License as published by
|
||||||
(at your option) any later version.
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
mcMMO is distributed in the hope that it will be useful,
|
*
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* This program is distributed in the hope that it will be useful,
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
GNU General Public License for more details.
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
You should have received a copy of the GNU General Public License
|
*
|
||||||
along with mcMMO. If not, see <http://www.gnu.org/licenses/>.
|
* You should have received a copy of the GNU General Public License
|
||||||
*/
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
package com.gmail.nossr50;
|
*/
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
package com.gmail.nossr50;
|
||||||
import org.bukkit.entity.*;
|
|
||||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.event.entity.EntityDamageEvent;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
import org.bukkit.entity.*;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||||
|
import org.bukkit.event.entity.EntityDamageEvent;
|
||||||
import com.gmail.nossr50.config.LoadProperties;
|
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import com.gmail.nossr50.datatypes.SkillType;
|
|
||||||
import com.gmail.nossr50.events.FakeEntityDamageByEntityEvent;
|
import com.gmail.nossr50.config.LoadProperties;
|
||||||
import com.gmail.nossr50.events.FakeEntityDamageEvent;
|
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||||
import com.gmail.nossr50.locale.mcLocale;
|
import com.gmail.nossr50.datatypes.SkillType;
|
||||||
import com.gmail.nossr50.party.Party;
|
import com.gmail.nossr50.events.FakeEntityDamageByEntityEvent;
|
||||||
import com.gmail.nossr50.skills.Acrobatics;
|
import com.gmail.nossr50.events.FakeEntityDamageEvent;
|
||||||
import com.gmail.nossr50.skills.Archery;
|
import com.gmail.nossr50.locale.mcLocale;
|
||||||
import com.gmail.nossr50.skills.Axes;
|
import com.gmail.nossr50.party.Party;
|
||||||
import com.gmail.nossr50.skills.Skills;
|
import com.gmail.nossr50.skills.Acrobatics;
|
||||||
import com.gmail.nossr50.skills.Swords;
|
import com.gmail.nossr50.skills.Archery;
|
||||||
import com.gmail.nossr50.skills.Taming;
|
import com.gmail.nossr50.skills.Axes;
|
||||||
import com.gmail.nossr50.skills.Unarmed;
|
import com.gmail.nossr50.skills.Skills;
|
||||||
|
import com.gmail.nossr50.skills.Swords;
|
||||||
public class Combat
|
import com.gmail.nossr50.skills.Taming;
|
||||||
{
|
import com.gmail.nossr50.skills.Unarmed;
|
||||||
public static void combatChecks(EntityDamageByEntityEvent event, mcMMO pluginx)
|
|
||||||
{
|
public class Combat
|
||||||
if(event.getDamage() == 0 || event.getEntity().isDead())
|
{
|
||||||
return;
|
public static void combatChecks(EntityDamageByEntityEvent event, mcMMO pluginx)
|
||||||
|
{
|
||||||
//Declare Things
|
if (event.getDamage() == 0 || event.getEntity().isDead())
|
||||||
Entity damager = event.getDamager();
|
return;
|
||||||
LivingEntity target = (LivingEntity) event.getEntity();
|
|
||||||
int damage = event.getDamage();
|
Entity damager = event.getDamager();
|
||||||
|
LivingEntity target = (LivingEntity) event.getEntity();
|
||||||
/*
|
int damage = event.getDamage();
|
||||||
* PLAYER VERSUS ENTITIES
|
EntityType damagerType = damager.getType();
|
||||||
*/
|
EntityType targetType = target.getType();
|
||||||
if(damager instanceof Player)
|
|
||||||
{
|
switch (damagerType)
|
||||||
Player attacker = (Player) event.getDamager();
|
{
|
||||||
ItemStack itemInHand = attacker.getItemInHand();
|
case PLAYER:
|
||||||
PlayerProfile PPa = Users.getProfile(attacker);
|
Player attacker = (Player) event.getDamager();
|
||||||
|
ItemStack itemInHand = attacker.getItemInHand();
|
||||||
//If there are any abilities to activate
|
PlayerProfile PPa = Users.getProfile(attacker);
|
||||||
combatAbilityChecks(attacker, PPa);
|
|
||||||
|
combatAbilityChecks(attacker, PPa);
|
||||||
//Damage modifiers and proc checks
|
|
||||||
if(m.isSwords(itemInHand) && mcPermissions.getInstance().swords(attacker))
|
if (m.isSwords(itemInHand) && mcPermissions.getInstance().swords(attacker))
|
||||||
{
|
{
|
||||||
if(!pluginx.misc.bleedTracker.contains(target)) //Bleed
|
if (!pluginx.misc.bleedTracker.contains(target))
|
||||||
Swords.bleedCheck(attacker, target, pluginx);
|
Swords.bleedCheck(attacker, target, pluginx);
|
||||||
|
|
||||||
if (PPa.getSerratedStrikesMode())
|
if (PPa.getSerratedStrikesMode())
|
||||||
Swords.applySerratedStrikes(attacker, event, pluginx);
|
Swords.applySerratedStrikes(attacker, event, pluginx);
|
||||||
|
|
||||||
if(target instanceof Player)
|
if (targetType.equals(EntityType.PLAYER))
|
||||||
PvPExperienceGain(attacker, PPa, (Player) target, damage, SkillType.SWORDS);
|
PvPExperienceGain(attacker, PPa, (Player) target, damage, SkillType.SWORDS);
|
||||||
else if(!pluginx.misc.mobSpawnerList.contains(target.getEntityId()))
|
else if (!pluginx.misc.mobSpawnerList.contains(target.getEntityId()))
|
||||||
PvEExperienceGain(attacker, PPa, target, damage, SkillType.SWORDS);
|
PvEExperienceGain(attacker, PPa, target, damage, SkillType.SWORDS);
|
||||||
}
|
}
|
||||||
else if(m.isAxes(itemInHand) && mcPermissions.getInstance().axes(attacker))
|
else if (m.isAxes(itemInHand) && mcPermissions.getInstance().axes(attacker))
|
||||||
{
|
{
|
||||||
Axes.axesBonus(attacker, event);
|
Axes.axesBonus(attacker, event);
|
||||||
|
Axes.axeCriticalCheck(attacker, event, pluginx);
|
||||||
Axes.axeCriticalCheck(attacker, event, pluginx); //Critical hit
|
Axes.impact(attacker, target, event);
|
||||||
|
|
||||||
//Impact
|
if (PPa.getSkullSplitterMode())
|
||||||
Axes.impact(attacker, target, event);
|
Axes.applyAoeDamage(attacker, event, pluginx);
|
||||||
|
|
||||||
if (PPa.getSkullSplitterMode())
|
if (targetType.equals(EntityType.PLAYER))
|
||||||
Axes.applyAoeDamage(attacker, event, pluginx);
|
PvPExperienceGain(attacker, PPa, (Player) target, event.getDamage(), SkillType.AXES); //use getDamage because damage is modified in earlier functions
|
||||||
|
else if (!pluginx.misc.mobSpawnerList.contains(target.getEntityId()))
|
||||||
if(target instanceof Player)
|
PvEExperienceGain(attacker, PPa, target, event.getDamage(), SkillType.AXES); //use getDamage because damage is modified in earlier functions
|
||||||
PvPExperienceGain(attacker, PPa, (Player) target, event.getDamage(), SkillType.AXES);
|
}
|
||||||
else if(!pluginx.misc.mobSpawnerList.contains(target.getEntityId()))
|
else if (itemInHand.getType().equals(Material.AIR) && mcPermissions.getInstance().unarmed(attacker))
|
||||||
PvEExperienceGain(attacker, PPa, target, event.getDamage(), SkillType.AXES);
|
{
|
||||||
}
|
Unarmed.unarmedBonus(attacker, event);
|
||||||
else if(itemInHand.getTypeId() == 0 && mcPermissions.getInstance().unarmed(attacker)) //Unarmed
|
|
||||||
{
|
if (PPa.getBerserkMode())
|
||||||
Unarmed.unarmedBonus(attacker, event);
|
event.setDamage(damage + (damage / 2));
|
||||||
if(PPa.getBerserkMode())
|
|
||||||
event.setDamage(event.getDamage() + (event.getDamage() / 2));
|
if (targetType.equals(EntityType.PLAYER))
|
||||||
|
{
|
||||||
if(target instanceof Player)
|
Unarmed.disarmProcCheck(attacker, (Player) target);
|
||||||
Unarmed.disarmProcCheck(attacker, (Player) target); //Disarm
|
PvPExperienceGain(attacker, PPa, (Player) target, event.getDamage(), SkillType.UNARMED); //use getDamage because damage is modified in earlier functions
|
||||||
|
}
|
||||||
if(target instanceof Player)
|
else if (!pluginx.misc.mobSpawnerList.contains(target.getEntityId()))
|
||||||
PvPExperienceGain(attacker, PPa, (Player) target, event.getDamage(), SkillType.UNARMED);
|
PvEExperienceGain(attacker, PPa, target, event.getDamage(), SkillType.UNARMED); //use getDamage because damage is modified in earlier functions
|
||||||
else if(!pluginx.misc.mobSpawnerList.contains(target.getEntityId()))
|
}
|
||||||
PvEExperienceGain(attacker, PPa, target, event.getDamage(), SkillType.UNARMED);
|
else if (itemInHand.getType().equals(Material.BONE) && mcPermissions.getInstance().taming(attacker) && targetType.equals(EntityType.WOLF))
|
||||||
}
|
{
|
||||||
|
Wolf wolf = (Wolf) target;
|
||||||
//Player use bone on wolf.
|
String message = "Combat.BeastLore" + " ";
|
||||||
else if(target instanceof Wolf)
|
int health = wolf.getHealth();
|
||||||
{
|
event.setCancelled(true);
|
||||||
Wolf wolf = (Wolf) target;
|
|
||||||
|
if (wolf.isTamed())
|
||||||
if(itemInHand.getTypeId() == 352 && mcPermissions.getInstance().taming(attacker))
|
{
|
||||||
{
|
message.concat(mcLocale.getString("Combat.BeastLoreOwner", new Object[] {Taming.getOwnerName(wolf)}) + " ");
|
||||||
event.setCancelled(true);
|
message.concat(mcLocale.getString("Combat.BeastLoreHealthWolfTamed", new Object[] {health}));
|
||||||
if(wolf.isTamed())
|
}
|
||||||
attacker.sendMessage(mcLocale.getString("Combat.BeastLore")+" "+
|
else
|
||||||
mcLocale.getString("Combat.BeastLoreOwner", new Object[] {Taming.getOwnerName(wolf)})+" "+
|
message.concat(mcLocale.getString("Combat.BeastLoreHealthWolf", new Object[] {health}));
|
||||||
mcLocale.getString("Combat.BeastLoreHealthWolfTamed", new Object[] {wolf.getHealth()}));
|
|
||||||
else
|
attacker.sendMessage(message);
|
||||||
attacker.sendMessage(mcLocale.getString("Combat.BeastLore")+" "+
|
}
|
||||||
mcLocale.getString("Combat.BeastLoreHealthWolf", new Object[] {wolf.getHealth()}));
|
case WOLF:
|
||||||
}
|
{
|
||||||
}
|
Wolf wolf = (Wolf) damager;
|
||||||
}
|
|
||||||
|
if (wolf.isTamed() && wolf.getOwner() instanceof Player)
|
||||||
/*
|
{
|
||||||
* TAMING (WOLVES VERSUS ENTITIES)
|
Player master = (Player) wolf.getOwner();
|
||||||
*/
|
PlayerProfile PPo = Users.getProfile(master);
|
||||||
else if(damager instanceof Wolf)
|
|
||||||
{
|
if (mcPermissions.getInstance().taming(master))
|
||||||
Wolf wolf = (Wolf) damager;
|
{
|
||||||
|
Taming.fastFoodService(PPo, wolf, event);
|
||||||
if (wolf.isTamed() && (wolf.getOwner() instanceof Player))
|
Taming.sharpenedClaws(PPo, event);
|
||||||
{
|
Taming.gore(PPo, event, master, pluginx);
|
||||||
Player master = (Player) wolf.getOwner();
|
Taming.rewardXp(event, pluginx, master);
|
||||||
PlayerProfile PPo = Users.getProfile(master);
|
}
|
||||||
if(mcPermissions.getInstance().taming(master))
|
}
|
||||||
{
|
}
|
||||||
//Fast Food Service
|
|
||||||
Taming.fastFoodService(PPo, wolf, event);
|
case ARROW:
|
||||||
|
archeryCheck((EntityDamageByEntityEvent)event, pluginx);
|
||||||
//Sharpened Claws
|
}
|
||||||
Taming.sharpenedClaws(PPo, event);
|
|
||||||
|
if (targetType.equals(EntityType.PLAYER))
|
||||||
//Gore
|
{
|
||||||
Taming.gore(PPo, event, master, pluginx);
|
Swords.counterAttackChecks(event);
|
||||||
|
Acrobatics.dodgeChecks(event);
|
||||||
//Reward XP
|
}
|
||||||
Taming.rewardXp(event, pluginx, master);
|
}
|
||||||
}
|
|
||||||
}
|
public static void combatAbilityChecks(Player attacker, PlayerProfile PPa)
|
||||||
}
|
{
|
||||||
|
//Check to see if any abilities need to be activated
|
||||||
//Another offensive check for Archery
|
if(PPa.getAxePreparationMode())
|
||||||
else if(damager instanceof Arrow)
|
Skills.abilityCheck(attacker, SkillType.AXES);
|
||||||
archeryCheck((EntityDamageByEntityEvent)event, pluginx);
|
if(PPa.getSwordsPreparationMode())
|
||||||
|
Skills.abilityCheck(attacker, SkillType.SWORDS);
|
||||||
/*
|
if(PPa.getFistsPreparationMode())
|
||||||
* DEFENSIVE CHECKS
|
Skills.abilityCheck(attacker, SkillType.UNARMED);
|
||||||
*/
|
}
|
||||||
if(target instanceof Player)
|
|
||||||
{
|
public static void archeryCheck(EntityDamageByEntityEvent event, mcMMO pluginx)
|
||||||
Swords.counterAttackChecks(event);
|
{
|
||||||
Acrobatics.dodgeChecks(event);
|
Arrow arrow = (Arrow)event.getDamager();
|
||||||
}
|
Entity y = arrow.getShooter();
|
||||||
}
|
Entity x = event.getEntity();
|
||||||
|
if(x instanceof Player)
|
||||||
public static void combatAbilityChecks(Player attacker, PlayerProfile PPa)
|
{
|
||||||
{
|
Player defender = (Player)x;
|
||||||
//Check to see if any abilities need to be activated
|
PlayerProfile PPd = Users.getProfile(defender);
|
||||||
if(PPa.getAxePreparationMode())
|
if(PPd == null)
|
||||||
Skills.abilityCheck(attacker, SkillType.AXES);
|
Users.addUser(defender);
|
||||||
if(PPa.getSwordsPreparationMode())
|
if(mcPermissions.getInstance().unarmed(defender) && defender.getItemInHand().getTypeId() == 0)
|
||||||
Skills.abilityCheck(attacker, SkillType.SWORDS);
|
{
|
||||||
if(PPa.getFistsPreparationMode())
|
if(defender != null && PPd.getSkillLevel(SkillType.UNARMED) >= 1000)
|
||||||
Skills.abilityCheck(attacker, SkillType.UNARMED);
|
{
|
||||||
}
|
if(Math.random() * 1000 <= 500)
|
||||||
|
{
|
||||||
public static void archeryCheck(EntityDamageByEntityEvent event, mcMMO pluginx)
|
event.setCancelled(true);
|
||||||
{
|
defender.sendMessage(mcLocale.getString("Combat.ArrowDeflect")); //$NON-NLS-1$
|
||||||
Arrow arrow = (Arrow)event.getDamager();
|
return;
|
||||||
Entity y = arrow.getShooter();
|
}
|
||||||
Entity x = event.getEntity();
|
} else if(defender != null && Math.random() * 1000 <= (PPd.getSkillLevel(SkillType.UNARMED) / 2))
|
||||||
if(x instanceof Player)
|
{
|
||||||
{
|
event.setCancelled(true);
|
||||||
Player defender = (Player)x;
|
defender.sendMessage(mcLocale.getString("Combat.ArrowDeflect")); //$NON-NLS-1$
|
||||||
PlayerProfile PPd = Users.getProfile(defender);
|
return;
|
||||||
if(PPd == null)
|
}
|
||||||
Users.addUser(defender);
|
}
|
||||||
if(mcPermissions.getInstance().unarmed(defender) && defender.getItemInHand().getTypeId() == 0)
|
}
|
||||||
{
|
/*
|
||||||
if(defender != null && PPd.getSkillLevel(SkillType.UNARMED) >= 1000)
|
* If attacker is player
|
||||||
{
|
*/
|
||||||
if(Math.random() * 1000 <= 500)
|
if(y instanceof Player)
|
||||||
{
|
{
|
||||||
event.setCancelled(true);
|
Player attacker = (Player)y;
|
||||||
defender.sendMessage(mcLocale.getString("Combat.ArrowDeflect")); //$NON-NLS-1$
|
PlayerProfile PPa = Users.getProfile(attacker);
|
||||||
return;
|
int damage = event.getDamage();
|
||||||
}
|
if(mcPermissions.getInstance().archery(attacker) && damage > 0)
|
||||||
} else if(defender != null && Math.random() * 1000 <= (PPd.getSkillLevel(SkillType.UNARMED) / 2))
|
{
|
||||||
{
|
Archery.trackArrows(pluginx, x, PPa);
|
||||||
event.setCancelled(true);
|
|
||||||
defender.sendMessage(mcLocale.getString("Combat.ArrowDeflect")); //$NON-NLS-1$
|
/*
|
||||||
return;
|
* IGNITION
|
||||||
}
|
*/
|
||||||
}
|
Archery.ignitionCheck(x, attacker);
|
||||||
}
|
/*
|
||||||
/*
|
* Defender is Monster
|
||||||
* If attacker is player
|
*/
|
||||||
*/
|
if(!pluginx.misc.mobSpawnerList.contains(x.getEntityId()))
|
||||||
if(y instanceof Player)
|
{
|
||||||
{
|
int xp = getXp(x, damage);
|
||||||
Player attacker = (Player)y;
|
PPa.addXP(SkillType.ARCHERY, xp*10, attacker);
|
||||||
PlayerProfile PPa = Users.getProfile(attacker);
|
}
|
||||||
int damage = event.getDamage();
|
/*
|
||||||
if(mcPermissions.getInstance().archery(attacker) && damage > 0)
|
* Attacker is Player
|
||||||
{
|
*/
|
||||||
Archery.trackArrows(pluginx, x, PPa);
|
if(x instanceof Player){
|
||||||
|
Player defender = (Player)x;
|
||||||
/*
|
PlayerProfile PPd = Users.getProfile(defender);
|
||||||
* IGNITION
|
/*
|
||||||
*/
|
* Stuff for the daze proc
|
||||||
Archery.ignitionCheck(x, attacker);
|
*/
|
||||||
/*
|
if(PPa.inParty() && PPd.inParty())
|
||||||
* Defender is Monster
|
{
|
||||||
*/
|
if(Party.getInstance().inSameParty(defender, attacker))
|
||||||
if(!pluginx.misc.mobSpawnerList.contains(x.getEntityId()))
|
{
|
||||||
{
|
event.setCancelled(true);
|
||||||
int xp = getXp(x, damage);
|
return;
|
||||||
PPa.addXP(SkillType.ARCHERY, xp*10, attacker);
|
}
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* Attacker is Player
|
* PVP XP
|
||||||
*/
|
*/
|
||||||
if(x instanceof Player){
|
if(LoadProperties.pvpxp && ((PPd.getLastLogin()+5)*1000) < System.currentTimeMillis() && !attacker.getName().equals(defender.getName()))
|
||||||
Player defender = (Player)x;
|
{
|
||||||
PlayerProfile PPd = Users.getProfile(defender);
|
int xp = (int) ((damage * 2) * 10);
|
||||||
/*
|
PPa.addXP(SkillType.ARCHERY, xp, attacker);
|
||||||
* Stuff for the daze proc
|
}
|
||||||
*/
|
/*
|
||||||
if(PPa.inParty() && PPd.inParty())
|
* DAZE PROC
|
||||||
{
|
*/
|
||||||
if(Party.getInstance().inSameParty(defender, attacker))
|
Archery.dazeCheck(defender, attacker);
|
||||||
{
|
}
|
||||||
event.setCancelled(true);
|
}
|
||||||
return;
|
Skills.XpCheckSkill(SkillType.ARCHERY, attacker);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
* PVP XP
|
/**
|
||||||
*/
|
* Attempt to damage target for value dmg with reason CUSTOM
|
||||||
if(LoadProperties.pvpxp && ((PPd.getLastLogin()+5)*1000) < System.currentTimeMillis() && !attacker.getName().equals(defender.getName()))
|
*
|
||||||
{
|
* @param target LivingEntity which to attempt to damage
|
||||||
int xp = (int) ((damage * 2) * 10);
|
* @param dmg Amount of damage to attempt to do
|
||||||
PPa.addXP(SkillType.ARCHERY, xp, attacker);
|
*/
|
||||||
}
|
public static void dealDamage(LivingEntity target, int dmg){
|
||||||
/*
|
dealDamage(target, dmg, EntityDamageEvent.DamageCause.CUSTOM);
|
||||||
* DAZE PROC
|
}
|
||||||
*/
|
|
||||||
Archery.dazeCheck(defender, attacker);
|
/**
|
||||||
}
|
* Attempt to damage target for value dmg with reason cause
|
||||||
}
|
*
|
||||||
Skills.XpCheckSkill(SkillType.ARCHERY, attacker);
|
* @param target LivingEntity which to attempt to damage
|
||||||
}
|
* @param dmg Amount of damage to attempt to do
|
||||||
}
|
* @param cause DamageCause to pass to damage event
|
||||||
|
*/
|
||||||
/**
|
public static void dealDamage(LivingEntity target, int dmg, DamageCause cause) {
|
||||||
* Attempt to damage target for value dmg with reason CUSTOM
|
if(LoadProperties.eventCallback) {
|
||||||
*
|
EntityDamageEvent ede = (EntityDamageEvent) new FakeEntityDamageEvent(target, cause, dmg);
|
||||||
* @param target LivingEntity which to attempt to damage
|
Bukkit.getPluginManager().callEvent(ede);
|
||||||
* @param dmg Amount of damage to attempt to do
|
if(ede.isCancelled()) return;
|
||||||
*/
|
|
||||||
public static void dealDamage(LivingEntity target, int dmg){
|
target.damage(ede.getDamage());
|
||||||
dealDamage(target, dmg, EntityDamageEvent.DamageCause.CUSTOM);
|
} else {
|
||||||
}
|
target.damage(dmg);
|
||||||
|
}
|
||||||
/**
|
}
|
||||||
* Attempt to damage target for value dmg with reason cause
|
|
||||||
*
|
/**
|
||||||
* @param target LivingEntity which to attempt to damage
|
* Attempt to damage target for value dmg with reason ENTITY_ATTACK with damager attacker
|
||||||
* @param dmg Amount of damage to attempt to do
|
*
|
||||||
* @param cause DamageCause to pass to damage event
|
* @param target LivingEntity which to attempt to damage
|
||||||
*/
|
* @param dmg Amount of damage to attempt to do
|
||||||
public static void dealDamage(LivingEntity target, int dmg, DamageCause cause) {
|
* @param attacker Player to pass to event as damager
|
||||||
if(LoadProperties.eventCallback) {
|
*/
|
||||||
EntityDamageEvent ede = (EntityDamageEvent) new FakeEntityDamageEvent(target, cause, dmg);
|
public static void dealDamage(LivingEntity target, int dmg, Player attacker) {
|
||||||
Bukkit.getPluginManager().callEvent(ede);
|
if(LoadProperties.eventCallback) {
|
||||||
if(ede.isCancelled()) return;
|
EntityDamageEvent ede = (EntityDamageByEntityEvent) new FakeEntityDamageByEntityEvent(attacker, target, EntityDamageEvent.DamageCause.ENTITY_ATTACK, dmg);
|
||||||
|
Bukkit.getPluginManager().callEvent(ede);
|
||||||
target.damage(ede.getDamage());
|
if(ede.isCancelled()) return;
|
||||||
} else {
|
|
||||||
target.damage(dmg);
|
target.damage(ede.getDamage());
|
||||||
}
|
} else {
|
||||||
}
|
target.damage(dmg);
|
||||||
|
}
|
||||||
/**
|
}
|
||||||
* Attempt to damage target for value dmg with reason ENTITY_ATTACK with damager attacker
|
|
||||||
*
|
private static void PvPExperienceGain(Player attacker, PlayerProfile PPa, Player defender, int damage, SkillType skillType)
|
||||||
* @param target LivingEntity which to attempt to damage
|
{
|
||||||
* @param dmg Amount of damage to attempt to do
|
if (!LoadProperties.pvpxp)
|
||||||
* @param attacker Player to pass to event as damager
|
return;
|
||||||
*/
|
|
||||||
public static void dealDamage(LivingEntity target, int dmg, Player attacker) {
|
PlayerProfile PPd = Users.getProfile(defender);
|
||||||
if(LoadProperties.eventCallback) {
|
|
||||||
EntityDamageEvent ede = (EntityDamageByEntityEvent) new FakeEntityDamageByEntityEvent(attacker, target, EntityDamageEvent.DamageCause.ENTITY_ATTACK, dmg);
|
if(System.currentTimeMillis() >= (PPd.getRespawnATS()*1000) + 5000
|
||||||
Bukkit.getPluginManager().callEvent(ede);
|
&& ((PPd.getLastLogin()+5)*1000) < System.currentTimeMillis()
|
||||||
if(ede.isCancelled()) return;
|
&& defender.getHealth() >= 1)
|
||||||
|
{
|
||||||
target.damage(ede.getDamage());
|
//Prevent a ridiculous amount of XP being granted by capping it at the remaining health of the mob
|
||||||
} else {
|
int hpLeft = defender.getHealth(), xpinc = 0;
|
||||||
target.damage(dmg);
|
|
||||||
}
|
if(hpLeft < damage)
|
||||||
}
|
{
|
||||||
|
if(hpLeft > 0)
|
||||||
private static void PvPExperienceGain(Player attacker, PlayerProfile PPa, Player defender, int damage, SkillType skillType)
|
xpinc = hpLeft;
|
||||||
{
|
else
|
||||||
if (!LoadProperties.pvpxp)
|
xpinc = 0;
|
||||||
return;
|
} else
|
||||||
|
xpinc = damage;
|
||||||
PlayerProfile PPd = Users.getProfile(defender);
|
|
||||||
|
int xp = (int) (xpinc * 2 * LoadProperties.pvpxprewardmodifier);
|
||||||
if(System.currentTimeMillis() >= (PPd.getRespawnATS()*1000) + 5000
|
PPa.addXP(skillType, xp*10, attacker);
|
||||||
&& ((PPd.getLastLogin()+5)*1000) < System.currentTimeMillis()
|
Skills.XpCheckSkill(skillType, attacker);
|
||||||
&& defender.getHealth() >= 1)
|
}
|
||||||
{
|
}
|
||||||
//Prevent a ridiculous amount of XP being granted by capping it at the remaining health of the mob
|
|
||||||
int hpLeft = defender.getHealth(), xpinc = 0;
|
private static void PvEExperienceGain(Player attacker, PlayerProfile PPa, LivingEntity target, int damage, SkillType skillType)
|
||||||
|
{
|
||||||
if(hpLeft < damage)
|
int xp = getXp(target, damage);
|
||||||
{
|
PPa.addXP(skillType, xp*10, attacker);
|
||||||
if(hpLeft > 0)
|
Skills.XpCheckSkill(skillType, attacker);
|
||||||
xpinc = hpLeft;
|
}
|
||||||
else
|
|
||||||
xpinc = 0;
|
public static int getXp(Entity entity, int damage)
|
||||||
} else
|
{
|
||||||
xpinc = damage;
|
int xp = 0;
|
||||||
|
if(entity instanceof LivingEntity)
|
||||||
int xp = (int) (xpinc * 2 * LoadProperties.pvpxprewardmodifier);
|
{
|
||||||
PPa.addXP(skillType, xp*10, attacker);
|
LivingEntity le = (LivingEntity) entity;
|
||||||
Skills.XpCheckSkill(skillType, attacker);
|
//Prevent a ridiculous amount of XP being granted by capping it at the remaining health of the entity
|
||||||
}
|
int hpLeft = le.getHealth();
|
||||||
}
|
int xpinc = 0;
|
||||||
|
|
||||||
private static void PvEExperienceGain(Player attacker, PlayerProfile PPa, LivingEntity target, int damage, SkillType skillType)
|
if(hpLeft < damage)
|
||||||
{
|
{
|
||||||
int xp = getXp(target, damage);
|
if(hpLeft > 0)
|
||||||
PPa.addXP(skillType, xp*10, attacker);
|
xpinc = hpLeft;
|
||||||
Skills.XpCheckSkill(skillType, attacker);
|
else
|
||||||
}
|
xpinc = 0;
|
||||||
|
}
|
||||||
public static int getXp(Entity entity, int damage)
|
else
|
||||||
{
|
xpinc = damage;
|
||||||
int xp = 0;
|
|
||||||
if(entity instanceof LivingEntity)
|
if(entity instanceof Animals)
|
||||||
{
|
xp = (int) (xpinc * LoadProperties.animalXP);
|
||||||
LivingEntity le = (LivingEntity) entity;
|
else
|
||||||
//Prevent a ridiculous amount of XP being granted by capping it at the remaining health of the entity
|
{
|
||||||
int hpLeft = le.getHealth();
|
EntityType type = entity.getType();
|
||||||
int xpinc = 0;
|
switch(type){
|
||||||
|
case BLAZE:
|
||||||
if(hpLeft < damage)
|
xp = (int) (xpinc * LoadProperties.blazeXP);
|
||||||
{
|
break;
|
||||||
if(hpLeft > 0)
|
case CAVE_SPIDER:
|
||||||
xpinc = hpLeft;
|
xp = (int) (xpinc * LoadProperties.cavespiderXP);
|
||||||
else
|
break;
|
||||||
xpinc = 0;
|
case CREEPER:
|
||||||
}
|
xp = (int) (xpinc * LoadProperties.creeperXP);
|
||||||
else
|
break;
|
||||||
xpinc = damage;
|
case ENDER_DRAGON:
|
||||||
|
xp = (int) (xpinc * LoadProperties.enderdragonXP);
|
||||||
if(entity instanceof Animals)
|
break;
|
||||||
xp = (int) (xpinc * LoadProperties.animalXP);
|
case ENDERMAN:
|
||||||
else
|
xp = (int) (xpinc * LoadProperties.endermanXP);
|
||||||
{
|
break;
|
||||||
EntityType type = entity.getType();
|
case GHAST:
|
||||||
switch(type){
|
xp = (int) (xpinc * LoadProperties.ghastXP);
|
||||||
case BLAZE:
|
break;
|
||||||
xp = (int) (xpinc * LoadProperties.blazeXP);
|
case MAGMA_CUBE:
|
||||||
break;
|
xp = (int) (xpinc * LoadProperties.magmacubeXP);
|
||||||
case CAVE_SPIDER:
|
break;
|
||||||
xp = (int) (xpinc * LoadProperties.cavespiderXP);
|
case PIG_ZOMBIE:
|
||||||
break;
|
xp = (int) (xpinc * LoadProperties.pigzombieXP);
|
||||||
case CREEPER:
|
break;
|
||||||
xp = (int) (xpinc * LoadProperties.creeperXP);
|
case SILVERFISH:
|
||||||
break;
|
xp = (int) (xpinc * LoadProperties.silverfishXP);
|
||||||
case ENDER_DRAGON:
|
break;
|
||||||
xp = (int) (xpinc * LoadProperties.enderdragonXP);
|
case SKELETON:
|
||||||
break;
|
xp = (int) (xpinc * LoadProperties.skeletonXP);
|
||||||
case ENDERMAN:
|
break;
|
||||||
xp = (int) (xpinc * LoadProperties.endermanXP);
|
case SLIME:
|
||||||
break;
|
xp = (int) (xpinc * LoadProperties.slimeXP);
|
||||||
case GHAST:
|
break;
|
||||||
xp = (int) (xpinc * LoadProperties.ghastXP);
|
case SPIDER:
|
||||||
break;
|
xp = (int) (xpinc * LoadProperties.spiderXP);
|
||||||
case MAGMA_CUBE:
|
break;
|
||||||
xp = (int) (xpinc * LoadProperties.magmacubeXP);
|
case ZOMBIE:
|
||||||
break;
|
xp = (int) (xpinc * LoadProperties.zombieXP);
|
||||||
case PIG_ZOMBIE:
|
break;
|
||||||
xp = (int) (xpinc * LoadProperties.pigzombieXP);
|
}
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -178,7 +178,7 @@ public class Excavation
|
|||||||
{
|
{
|
||||||
PlayerAnimationEvent armswing = new PlayerAnimationEvent(player);
|
PlayerAnimationEvent armswing = new PlayerAnimationEvent(player);
|
||||||
Bukkit.getPluginManager().callEvent(armswing);
|
Bukkit.getPluginManager().callEvent(armswing);
|
||||||
Excavation.excavationProcCheck(block, player);
|
Excavation.excavationProcCheck(block, player);
|
||||||
Excavation.excavationProcCheck(block, player);
|
Excavation.excavationProcCheck(block, player);
|
||||||
Excavation.excavationProcCheck(block, player);
|
Excavation.excavationProcCheck(block, player);
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,7 @@ import com.gmail.nossr50.datatypes.SkillType;
|
|||||||
|
|
||||||
|
|
||||||
public class Mining
|
public class Mining
|
||||||
{
|
{
|
||||||
|
|
||||||
public static void miningDrops(Block block)
|
public static void miningDrops(Block block)
|
||||||
{
|
{
|
||||||
@ -125,7 +125,7 @@ public class Mining
|
|||||||
case SANDSTONE:
|
case SANDSTONE:
|
||||||
xp += LoadProperties.msandstone;
|
xp += LoadProperties.msandstone;
|
||||||
break;
|
break;
|
||||||
case STONE:
|
case STONE:
|
||||||
xp += LoadProperties.mstone;
|
xp += LoadProperties.mstone;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -135,7 +135,7 @@ public class Mining
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void blockProcSimulate(Block block, Player player)
|
public static void blockProcSimulate(Block block, Player player)
|
||||||
{
|
{
|
||||||
//Drop natural block with Silk Touch
|
//Drop natural block with Silk Touch
|
||||||
if(player.getItemInHand().containsEnchantment(Enchantment.SILK_TOUCH))
|
if(player.getItemInHand().containsEnchantment(Enchantment.SILK_TOUCH))
|
||||||
m.mcDropItem(block.getLocation(), new ItemStack(block.getType(), 1));
|
m.mcDropItem(block.getLocation(), new ItemStack(block.getType(), 1));
|
||||||
@ -186,7 +186,7 @@ public class Mining
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void SuperBreakerBlockCheck(Player player, Block block, mcMMO plugin)
|
public static void SuperBreakerBlockCheck(Player player, Block block, mcMMO plugin)
|
||||||
{
|
{
|
||||||
Material type = block.getType();
|
Material type = block.getType();
|
||||||
int tier = m.getTier(player);
|
int tier = m.getTier(player);
|
||||||
int durabilityLoss = LoadProperties.abilityDurabilityLoss;
|
int durabilityLoss = LoadProperties.abilityDurabilityLoss;
|
||||||
|
Loading…
Reference in New Issue
Block a user