mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-26 23:26:45 +01:00
Fix for combat XP gain
This commit is contained in:
parent
c3e1cf8681
commit
7c3b6b9fb3
@ -59,12 +59,7 @@ public class Combat {
|
|||||||
applyAbilityAoE(attacker, target, damage, pluginx, SkillType.SWORDS);
|
applyAbilityAoE(attacker, target, damage, pluginx, SkillType.SWORDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (targetType.equals(EntityType.PLAYER)) {
|
startGainXp(attacker, PPa, target, SkillType.SWORDS, pluginx);
|
||||||
PvPExperienceGain(attacker, PPa, (Player) target, damage, SkillType.SWORDS);
|
|
||||||
}
|
|
||||||
else if (!pluginx.misc.mobSpawnerList.contains(target.getEntityId())){
|
|
||||||
PvEExperienceGain(attacker, PPa, target, damage, SkillType.SWORDS);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (ItemChecks.isAxe(itemInHand) && mcPermissions.getInstance().axes(attacker)) {
|
else if (ItemChecks.isAxe(itemInHand) && mcPermissions.getInstance().axes(attacker)) {
|
||||||
Axes.axesBonus(attacker, event);
|
Axes.axesBonus(attacker, event);
|
||||||
@ -74,13 +69,8 @@ public class Combat {
|
|||||||
if (PPa.getSkullSplitterMode()) {
|
if (PPa.getSkullSplitterMode()) {
|
||||||
applyAbilityAoE(attacker, target, damage, pluginx, SkillType.AXES);
|
applyAbilityAoE(attacker, target, damage, pluginx, SkillType.AXES);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (targetType.equals(EntityType.PLAYER)) {
|
startGainXp(attacker, PPa, target, SkillType.AXES, 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())) {
|
|
||||||
PvEExperienceGain(attacker, PPa, target, event.getDamage(), SkillType.AXES); //use getDamage because damage is modified in earlier functions
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (itemInHand.getType().equals(Material.AIR) && mcPermissions.getInstance().unarmed(attacker)) {
|
else if (itemInHand.getType().equals(Material.AIR) && mcPermissions.getInstance().unarmed(attacker)) {
|
||||||
Unarmed.unarmedBonus(attacker, event);
|
Unarmed.unarmedBonus(attacker, event);
|
||||||
@ -91,11 +81,9 @@ public class Combat {
|
|||||||
|
|
||||||
if (targetType.equals(EntityType.PLAYER)) {
|
if (targetType.equals(EntityType.PLAYER)) {
|
||||||
Unarmed.disarmProcCheck(attacker, (Player) target);
|
Unarmed.disarmProcCheck(attacker, (Player) target);
|
||||||
PvPExperienceGain(attacker, PPa, (Player) 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); //use getDamage because damage is modified in earlier functions
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
startGainXp(attacker, PPa, target, SkillType.UNARMED, pluginx);
|
||||||
}
|
}
|
||||||
else if (itemInHand.getType().equals(Material.BONE) && mcPermissions.getInstance().taming(attacker) && targetType.equals(EntityType.WOLF)) {
|
else if (itemInHand.getType().equals(Material.BONE) && mcPermissions.getInstance().taming(attacker) && targetType.equals(EntityType.WOLF)) {
|
||||||
Wolf wolf = (Wolf) target;
|
Wolf wolf = (Wolf) target;
|
||||||
@ -126,7 +114,8 @@ public class Combat {
|
|||||||
Taming.fastFoodService(PPo, wolf, event);
|
Taming.fastFoodService(PPo, wolf, event);
|
||||||
Taming.sharpenedClaws(PPo, event);
|
Taming.sharpenedClaws(PPo, event);
|
||||||
Taming.gore(PPo, event, master, pluginx);
|
Taming.gore(PPo, event, master, pluginx);
|
||||||
Taming.rewardXp(event, pluginx, master);
|
|
||||||
|
startGainXp(master, PPo, target, SkillType.TAMING, pluginx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -173,10 +162,10 @@ public class Combat {
|
|||||||
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();
|
||||||
LivingEntity shooter = arrow.getShooter();
|
LivingEntity shooter = arrow.getShooter();
|
||||||
Entity entity = event.getEntity();
|
LivingEntity target = (LivingEntity) event.getEntity();
|
||||||
|
|
||||||
if (entity instanceof Player) {
|
if (target instanceof Player) {
|
||||||
Player defender = (Player) entity;
|
Player defender = (Player) target;
|
||||||
PlayerProfile PPd = Users.getProfile(defender);
|
PlayerProfile PPd = Users.getProfile(defender);
|
||||||
boolean deflect = false;
|
boolean deflect = false;
|
||||||
|
|
||||||
@ -202,16 +191,13 @@ public class Combat {
|
|||||||
int damage = event.getDamage();
|
int damage = event.getDamage();
|
||||||
|
|
||||||
if (mcPermissions.getInstance().archery(attacker) && damage > 0) {
|
if (mcPermissions.getInstance().archery(attacker) && damage > 0) {
|
||||||
Archery.trackArrows(pluginx, entity, PPa);
|
Archery.trackArrows(pluginx, target, PPa);
|
||||||
Archery.ignitionCheck(entity, attacker);
|
Archery.ignitionCheck(target, attacker);
|
||||||
|
|
||||||
if (!pluginx.misc.mobSpawnerList.contains(entity.getEntityId())) {
|
startGainXp(attacker, PPa, target, SkillType.ARCHERY, pluginx);
|
||||||
int xp = getXp((LivingEntity) entity, damage);
|
|
||||||
PPa.addXP(SkillType.ARCHERY, xp*10, attacker);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (entity instanceof Player) {
|
if (target instanceof Player) {
|
||||||
Player defender = (Player) entity;
|
Player defender = (Player) target;
|
||||||
PlayerProfile PPd = Users.getProfile(defender);
|
PlayerProfile PPd = Users.getProfile(defender);
|
||||||
|
|
||||||
if (PPa.inParty() && PPd.inParty() && Party.getInstance().inSameParty(defender, attacker)) {
|
if (PPa.inParty() && PPd.inParty() && Party.getInstance().inSameParty(defender, attacker)) {
|
||||||
@ -219,16 +205,9 @@ public class Combat {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (LoadProperties.pvpxp && (((PPd.getLastLogin() + 5) * 1000) < System.currentTimeMillis()) && !attacker.getName().equals(defender.getName())) {
|
|
||||||
int xp = (damage * 2) * 10; //What's the 2 for? Should this be a multiplier from file instead?
|
|
||||||
PPa.addXP(SkillType.ARCHERY, xp, attacker);
|
|
||||||
}
|
|
||||||
|
|
||||||
Archery.dazeCheck(defender, attacker);
|
Archery.dazeCheck(defender, attacker);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Skills.XpCheckSkill(SkillType.ARCHERY, attacker);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -288,149 +267,6 @@ public class Combat {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Process PVP experience gain.
|
|
||||||
*
|
|
||||||
* @param attacker The attacking player
|
|
||||||
* @param PPa The profile of the attacking player
|
|
||||||
* @param defender The defending player
|
|
||||||
* @param damage The initial damage amount
|
|
||||||
* @param skillType The skill being used
|
|
||||||
*/
|
|
||||||
private static void PvPExperienceGain(Player attacker, PlayerProfile PPa, Player defender, int damage, SkillType skillType) {
|
|
||||||
if (!LoadProperties.pvpxp) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
PlayerProfile PPd = Users.getProfile(defender);
|
|
||||||
int health = defender.getHealth();
|
|
||||||
|
|
||||||
if ((System.currentTimeMillis() >= (PPd.getRespawnATS()*1000) + 5000) && (((PPd.getLastLogin()+5)*1000) < System.currentTimeMillis()) && health >= 1) {
|
|
||||||
int xp = capXP(health, damage);
|
|
||||||
|
|
||||||
xp = (int) (xp * 2 * LoadProperties.pvpxprewardmodifier);
|
|
||||||
PPa.addXP(skillType, xp * 10, attacker);
|
|
||||||
Skills.XpCheckSkill(skillType, attacker);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Process PVE experience gain.
|
|
||||||
*
|
|
||||||
* @param attacker The attacking player
|
|
||||||
* @param PPa The profile of the attacking player
|
|
||||||
* @param target The defending entity
|
|
||||||
* @param damage The initial damage amount
|
|
||||||
* @param skillType The skill being used
|
|
||||||
*/
|
|
||||||
private static void PvEExperienceGain(Player attacker, PlayerProfile PPa, LivingEntity target, int damage, SkillType skillType) {
|
|
||||||
int xp = getXp(target, damage);
|
|
||||||
|
|
||||||
PPa.addXP(skillType, xp * 10, attacker);
|
|
||||||
Skills.XpCheckSkill(skillType, attacker);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Cap the XP based on the remaining health of an entity.
|
|
||||||
*
|
|
||||||
* @param hpLeft Amount of HP remaining
|
|
||||||
* @param damage Amount of damage being dealt
|
|
||||||
* @return the modified XP amount
|
|
||||||
*/
|
|
||||||
private static int capXP(int hpLeft, int damage) {
|
|
||||||
int xp;
|
|
||||||
|
|
||||||
if (hpLeft < damage) {
|
|
||||||
if (hpLeft > 0) {
|
|
||||||
xp = hpLeft;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
xp = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
xp = damage;
|
|
||||||
}
|
|
||||||
|
|
||||||
return xp;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the XP gained from damaging a non-player mob
|
|
||||||
*
|
|
||||||
* @param entity Entity being damaged
|
|
||||||
* @param damage Damage to be dealt to the mob
|
|
||||||
* @return XP gained
|
|
||||||
*/
|
|
||||||
public static int getXp(LivingEntity entity, int damage) {
|
|
||||||
int xp = capXP(entity.getHealth(), damage);
|
|
||||||
|
|
||||||
if (entity instanceof Animals) {
|
|
||||||
xp = (int) (xp * LoadProperties.animalXP);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
EntityType type = entity.getType();
|
|
||||||
|
|
||||||
switch (type) {
|
|
||||||
case BLAZE:
|
|
||||||
xp = (int) (xp * LoadProperties.blazeXP);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case CAVE_SPIDER:
|
|
||||||
xp = (int) (xp * LoadProperties.cavespiderXP);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case CREEPER:
|
|
||||||
xp = (int) (xp * LoadProperties.creeperXP);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ENDER_DRAGON:
|
|
||||||
xp = (int) (xp * LoadProperties.enderdragonXP);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ENDERMAN:
|
|
||||||
xp = (int) (xp * LoadProperties.endermanXP);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case GHAST:
|
|
||||||
xp = (int) (xp * LoadProperties.ghastXP);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case MAGMA_CUBE:
|
|
||||||
xp = (int) (xp * LoadProperties.magmacubeXP);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case PIG_ZOMBIE:
|
|
||||||
xp = (int) (xp * LoadProperties.pigzombieXP);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SILVERFISH:
|
|
||||||
xp = (int) (xp * LoadProperties.silverfishXP);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SKELETON:
|
|
||||||
xp = (int) (xp * LoadProperties.skeletonXP);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SLIME:
|
|
||||||
xp = (int) (xp * LoadProperties.slimeXP);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SPIDER:
|
|
||||||
xp = (int) (xp * LoadProperties.spiderXP);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ZOMBIE:
|
|
||||||
xp = (int) (xp * LoadProperties.zombieXP);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return xp;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Apply Area-of-Effect ability actions.
|
* Apply Area-of-Effect ability actions.
|
||||||
*
|
*
|
||||||
@ -532,4 +368,128 @@ public class Combat {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Start the task that gives combat XP.
|
||||||
|
*
|
||||||
|
* @param attacker The attacking player
|
||||||
|
* @param PP The player's PlayerProfile
|
||||||
|
* @param target The defending entity
|
||||||
|
* @param skillType The skill being used
|
||||||
|
* @param plugin mcMMO plugin instance
|
||||||
|
*/
|
||||||
|
public static void startGainXp(Player attacker, PlayerProfile PP, LivingEntity target, SkillType skillType, mcMMO pluginx)
|
||||||
|
{
|
||||||
|
double baseXP = 0;
|
||||||
|
|
||||||
|
if (target instanceof Player) {
|
||||||
|
if (!LoadProperties.pvpxp) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Player defender = (Player) target;
|
||||||
|
PlayerProfile PPd = Users.getProfile(defender);
|
||||||
|
|
||||||
|
if (System.currentTimeMillis() >= (PPd.getRespawnATS() * 1000) + 5000 &&
|
||||||
|
((PPd.getLastLogin() + 5) * 1000) < System.currentTimeMillis() &&
|
||||||
|
defender.getHealth() >= 1) {
|
||||||
|
baseXP = 20 * LoadProperties.pvpxprewardmodifier;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (!pluginx.misc.mobSpawnerList.contains(target.getEntityId())) {
|
||||||
|
if (target instanceof Animals) {
|
||||||
|
baseXP = 10 * LoadProperties.animalXP;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
EntityType type = target.getType();
|
||||||
|
|
||||||
|
switch (type) {
|
||||||
|
case BLAZE:
|
||||||
|
baseXP = LoadProperties.blazeXP;
|
||||||
|
break;
|
||||||
|
case CAVE_SPIDER:
|
||||||
|
baseXP = LoadProperties.cavespiderXP;
|
||||||
|
break;
|
||||||
|
case CREEPER:
|
||||||
|
baseXP = LoadProperties.creeperXP;
|
||||||
|
break;
|
||||||
|
case ENDER_DRAGON:
|
||||||
|
baseXP = LoadProperties.enderdragonXP;
|
||||||
|
break;
|
||||||
|
case ENDERMAN:
|
||||||
|
baseXP = LoadProperties.endermanXP;
|
||||||
|
break;
|
||||||
|
case GHAST:
|
||||||
|
baseXP = LoadProperties.ghastXP;
|
||||||
|
break;
|
||||||
|
case MAGMA_CUBE:
|
||||||
|
baseXP = LoadProperties.magmacubeXP;
|
||||||
|
break;
|
||||||
|
case PIG_ZOMBIE:
|
||||||
|
baseXP = LoadProperties.pigzombieXP;
|
||||||
|
break;
|
||||||
|
case SILVERFISH:
|
||||||
|
baseXP = LoadProperties.silverfishXP;
|
||||||
|
break;
|
||||||
|
case SKELETON:
|
||||||
|
baseXP = LoadProperties.skeletonXP;
|
||||||
|
break;
|
||||||
|
case SLIME:
|
||||||
|
baseXP = LoadProperties.slimeXP;
|
||||||
|
break;
|
||||||
|
case SPIDER:
|
||||||
|
baseXP = LoadProperties.spiderXP;
|
||||||
|
break;
|
||||||
|
case ZOMBIE:
|
||||||
|
baseXP = LoadProperties.zombieXP;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
baseXP *= 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (baseXP != 0)
|
||||||
|
Bukkit.getScheduler().scheduleSyncDelayedTask(pluginx, new GainXp(attacker, PP, skillType, baseXP, target), 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
class GainXp implements Runnable
|
||||||
|
{
|
||||||
|
private Player player = null;
|
||||||
|
private PlayerProfile PP = null;
|
||||||
|
private double baseXp = 0;
|
||||||
|
private SkillType skillType = null;
|
||||||
|
private LivingEntity target = null;
|
||||||
|
private int baseHealth = 0;
|
||||||
|
|
||||||
|
public GainXp(Player player, PlayerProfile PP, SkillType skillType, double baseXp, LivingEntity target)
|
||||||
|
{
|
||||||
|
this.player = player;
|
||||||
|
this.PP = PP;
|
||||||
|
this.skillType = skillType;
|
||||||
|
this.baseXp = baseXp;
|
||||||
|
this.target = target;
|
||||||
|
baseHealth = target.getHealth();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
int health = target.getHealth();
|
||||||
|
int damage = baseHealth - health;
|
||||||
|
|
||||||
|
//May avoid negative xp, we don't know what other plugins do with the entity health
|
||||||
|
if (damage <= 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
//Don't reward the player for overkills
|
||||||
|
if (health < 0)
|
||||||
|
damage += health;
|
||||||
|
|
||||||
|
PP.addXP(skillType, (int) (damage * baseXp), player);
|
||||||
|
Skills.XpCheckSkill(skillType, player);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,187 +1,169 @@
|
|||||||
package com.gmail.nossr50.skills;
|
package com.gmail.nossr50.skills;
|
||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
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.EntityDamageEvent;
|
import org.bukkit.event.entity.EntityDamageEvent;
|
||||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import com.gmail.nossr50.Combat;
|
import com.gmail.nossr50.Users;
|
||||||
import com.gmail.nossr50.Users;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.config.LoadProperties;
|
||||||
import com.gmail.nossr50.config.LoadProperties;
|
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;
|
|
||||||
|
public class Taming
|
||||||
public class Taming
|
{
|
||||||
{
|
public static void fastFoodService(PlayerProfile PPo, Wolf theWolf, EntityDamageEvent event)
|
||||||
public static void rewardXp(EntityDamageEvent event, mcMMO pluginx, Player master)
|
{
|
||||||
{
|
int health = theWolf.getHealth();
|
||||||
Entity entity = event.getEntity();
|
int maxHealth = theWolf.getMaxHealth();
|
||||||
if(!pluginx.misc.mobSpawnerList.contains(entity.getEntityId()))
|
int damage = event.getDamage();
|
||||||
{
|
if(PPo.getSkillLevel(SkillType.TAMING) >= 50)
|
||||||
int xp = Combat.getXp((LivingEntity) entity, event.getDamage());
|
{
|
||||||
Users.getProfile(master).addXP(SkillType.TAMING, xp*10, master);
|
if(health < maxHealth)
|
||||||
|
{
|
||||||
if(entity instanceof Player)
|
if(Math.random() * 10 > 5)
|
||||||
{
|
{
|
||||||
xp = (event.getDamage() * 2);
|
if(health + damage <= maxHealth)
|
||||||
Users.getProfile(master).addXP(SkillType.TAMING, (int)((xp*10)*1.5), master);
|
theWolf.setHealth(health + damage);
|
||||||
}
|
else
|
||||||
Skills.XpCheckSkill(SkillType.TAMING, master);
|
theWolf.setHealth(maxHealth);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
public static void fastFoodService(PlayerProfile PPo, Wolf theWolf, EntityDamageEvent event)
|
}
|
||||||
{
|
|
||||||
int health = theWolf.getHealth();
|
public static void sharpenedClaws(PlayerProfile PPo, EntityDamageEvent event)
|
||||||
int maxHealth = theWolf.getMaxHealth();
|
{
|
||||||
int damage = event.getDamage();
|
if(PPo.getSkillLevel(SkillType.TAMING) >= 750)
|
||||||
if(PPo.getSkillLevel(SkillType.TAMING) >= 50)
|
{
|
||||||
{
|
event.setDamage(event.getDamage() + 2);
|
||||||
if(health < maxHealth)
|
}
|
||||||
{
|
}
|
||||||
if(Math.random() * 10 > 5)
|
|
||||||
{
|
public static void gore(PlayerProfile PPo, EntityDamageEvent event, Player master, mcMMO pluginx)
|
||||||
if(health + damage <= maxHealth)
|
{
|
||||||
theWolf.setHealth(health + damage);
|
if(Math.random() * 1000 <= PPo.getSkillLevel(SkillType.TAMING))
|
||||||
else
|
{
|
||||||
theWolf.setHealth(maxHealth);
|
Entity entity = event.getEntity();
|
||||||
}
|
event.setDamage(event.getDamage() * 2);
|
||||||
}
|
|
||||||
}
|
if(entity instanceof Player)
|
||||||
}
|
{
|
||||||
|
Player target = (Player)entity;
|
||||||
public static void sharpenedClaws(PlayerProfile PPo, EntityDamageEvent event)
|
target.sendMessage(mcLocale.getString("Combat.StruckByGore")); //$NON-NLS-1$
|
||||||
{
|
Users.getProfile(target).setBleedTicks(2);
|
||||||
if(PPo.getSkillLevel(SkillType.TAMING) >= 750)
|
}
|
||||||
{
|
else
|
||||||
event.setDamage(event.getDamage() + 2);
|
pluginx.misc.addToBleedQue((LivingEntity)entity);
|
||||||
}
|
|
||||||
}
|
master.sendMessage(mcLocale.getString("Combat.Gore")); //$NON-NLS-1$
|
||||||
|
}
|
||||||
public static void gore(PlayerProfile PPo, EntityDamageEvent event, Player master, mcMMO pluginx)
|
}
|
||||||
{
|
|
||||||
if(Math.random() * 1000 <= PPo.getSkillLevel(SkillType.TAMING))
|
public static String getOwnerName(Wolf theWolf)
|
||||||
{
|
{
|
||||||
Entity entity = event.getEntity();
|
Player owner = null;
|
||||||
event.setDamage(event.getDamage() * 2);
|
|
||||||
|
if (theWolf.getOwner() instanceof Player)
|
||||||
if(entity instanceof Player)
|
{
|
||||||
{
|
owner = (Player)theWolf.getOwner();
|
||||||
Player target = (Player)entity;
|
return owner.getName();
|
||||||
target.sendMessage(mcLocale.getString("Combat.StruckByGore")); //$NON-NLS-1$
|
}
|
||||||
Users.getProfile(target).setBleedTicks(2);
|
else
|
||||||
}
|
return "Offline Master";
|
||||||
else
|
}
|
||||||
pluginx.misc.addToBleedQue((LivingEntity)entity);
|
|
||||||
|
public static void preventDamage(EntityDamageEvent event, mcMMO plugin)
|
||||||
master.sendMessage(mcLocale.getString("Combat.Gore")); //$NON-NLS-1$
|
{
|
||||||
}
|
DamageCause cause = event.getCause();
|
||||||
}
|
Wolf wolf = (Wolf) event.getEntity();
|
||||||
|
Player master = (Player) wolf.getOwner();
|
||||||
public static String getOwnerName(Wolf theWolf)
|
int skillLevel = Users.getProfile(master).getSkillLevel(SkillType.TAMING);
|
||||||
{
|
|
||||||
Player owner = null;
|
switch(cause)
|
||||||
|
{
|
||||||
if (theWolf.getOwner() instanceof Player)
|
//Environmentally Aware
|
||||||
{
|
case CONTACT:
|
||||||
owner = (Player)theWolf.getOwner();
|
case LAVA:
|
||||||
return owner.getName();
|
case FIRE:
|
||||||
}
|
if(skillLevel >= 100)
|
||||||
else
|
{
|
||||||
return "Offline Master";
|
if(event.getDamage() >= wolf.getHealth())
|
||||||
}
|
return;
|
||||||
|
|
||||||
public static void preventDamage(EntityDamageEvent event, mcMMO plugin)
|
wolf.teleport(master.getLocation());
|
||||||
{
|
master.sendMessage(mcLocale.getString("mcEntityListener.WolfComesBack")); //$NON-NLS-1$
|
||||||
DamageCause cause = event.getCause();
|
}
|
||||||
Wolf wolf = (Wolf) event.getEntity();
|
break;
|
||||||
Player master = (Player) wolf.getOwner();
|
case FALL:
|
||||||
int skillLevel = Users.getProfile(master).getSkillLevel(SkillType.TAMING);
|
if(skillLevel >= 100)
|
||||||
|
event.setCancelled(true);
|
||||||
switch(cause)
|
break;
|
||||||
{
|
|
||||||
//Environmentally Aware
|
//Thick Fur
|
||||||
case CONTACT:
|
case FIRE_TICK:
|
||||||
case LAVA:
|
if(skillLevel >= 250)
|
||||||
case FIRE:
|
wolf.setFireTicks(0);
|
||||||
if(skillLevel >= 100)
|
break;
|
||||||
{
|
case ENTITY_ATTACK:
|
||||||
if(event.getDamage() >= wolf.getHealth())
|
case PROJECTILE:
|
||||||
return;
|
if(skillLevel >= 250)
|
||||||
|
event.setDamage(event.getDamage() / 2);
|
||||||
wolf.teleport(master.getLocation());
|
break;
|
||||||
master.sendMessage(mcLocale.getString("mcEntityListener.WolfComesBack")); //$NON-NLS-1$
|
|
||||||
}
|
//Shock Proof
|
||||||
break;
|
case ENTITY_EXPLOSION:
|
||||||
case FALL:
|
case BLOCK_EXPLOSION:
|
||||||
if(skillLevel >= 100)
|
if(skillLevel >= 500)
|
||||||
event.setCancelled(true);
|
event.setDamage(event.getDamage() / 6);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
//Thick Fur
|
}
|
||||||
case FIRE_TICK:
|
|
||||||
if(skillLevel >= 250)
|
public static void animalSummon(EntityType type, Player player)
|
||||||
wolf.setFireTicks(0);
|
{
|
||||||
break;
|
ItemStack item = player.getItemInHand();
|
||||||
case ENTITY_ATTACK:
|
Material summonItem = null;
|
||||||
case PROJECTILE:
|
int summonAmount = 0;
|
||||||
if(skillLevel >= 250)
|
|
||||||
event.setDamage(event.getDamage() / 2);
|
switch(type)
|
||||||
break;
|
{
|
||||||
|
case WOLF:
|
||||||
//Shock Proof
|
summonItem = Material.BONE;
|
||||||
case ENTITY_EXPLOSION:
|
summonAmount = LoadProperties.bonesConsumedByCOTW;
|
||||||
case BLOCK_EXPLOSION:
|
break;
|
||||||
if(skillLevel >= 500)
|
case OCELOT:
|
||||||
event.setDamage(event.getDamage() / 6);
|
summonItem = Material.RAW_FISH;
|
||||||
break;
|
summonAmount = LoadProperties.fishConsumedByCOTW;
|
||||||
}
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void animalSummon(EntityType type, Player player)
|
if(item.getType().equals(summonItem) && item.getAmount() >= summonAmount)
|
||||||
{
|
{
|
||||||
ItemStack item = player.getItemInHand();
|
for(Entity x : player.getNearbyEntities(40, 40, 40))
|
||||||
Material summonItem = null;
|
{
|
||||||
int summonAmount = 0;
|
if(x.getType().equals(type))
|
||||||
|
{
|
||||||
switch(type)
|
player.sendMessage(mcLocale.getString("m.TamingSummonFailed"));
|
||||||
{
|
return;
|
||||||
case WOLF:
|
}
|
||||||
summonItem = Material.BONE;
|
}
|
||||||
summonAmount = LoadProperties.bonesConsumedByCOTW;
|
|
||||||
break;
|
World world = player.getWorld();
|
||||||
case OCELOT:
|
world.spawnCreature(player.getLocation(), type);
|
||||||
summonItem = Material.RAW_FISH;
|
|
||||||
summonAmount = LoadProperties.fishConsumedByCOTW;
|
int amount = item.getAmount();
|
||||||
break;
|
amount = amount - summonAmount;
|
||||||
}
|
player.setItemInHand(new ItemStack(summonItem, amount));
|
||||||
|
player.sendMessage(mcLocale.getString("m.TamingSummon"));
|
||||||
if(item.getType().equals(summonItem) && item.getAmount() >= summonAmount)
|
}
|
||||||
{
|
}
|
||||||
for(Entity x : player.getNearbyEntities(40, 40, 40))
|
}
|
||||||
{
|
|
||||||
if(x.getType().equals(type))
|
|
||||||
{
|
|
||||||
player.sendMessage(mcLocale.getString("m.TamingSummonFailed"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
World world = player.getWorld();
|
|
||||||
world.spawnCreature(player.getLocation(), type);
|
|
||||||
|
|
||||||
int amount = item.getAmount();
|
|
||||||
amount = amount - summonAmount;
|
|
||||||
player.setItemInHand(new ItemStack(summonItem, amount));
|
|
||||||
player.sendMessage(mcLocale.getString("m.TamingSummon"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user