2013-03-01 06:52:01 +01:00
|
|
|
package com.gmail.nossr50.skills.taming;
|
|
|
|
|
2013-09-17 00:55:38 +02:00
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.List;
|
|
|
|
|
2013-09-13 01:22:54 +02:00
|
|
|
import org.bukkit.Location;
|
|
|
|
import org.bukkit.Sound;
|
2013-03-01 21:49:24 +01:00
|
|
|
import org.bukkit.entity.Entity;
|
2013-03-01 06:52:01 +01:00
|
|
|
import org.bukkit.entity.EntityType;
|
2013-10-31 22:30:05 +01:00
|
|
|
import org.bukkit.entity.Horse;
|
2013-03-01 06:52:01 +01:00
|
|
|
import org.bukkit.entity.LivingEntity;
|
2013-03-01 21:49:24 +01:00
|
|
|
import org.bukkit.entity.Ocelot;
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
import org.bukkit.entity.Tameable;
|
2013-03-01 06:52:01 +01:00
|
|
|
import org.bukkit.entity.Wolf;
|
|
|
|
import org.bukkit.inventory.ItemStack;
|
|
|
|
|
2013-03-01 21:49:24 +01:00
|
|
|
import com.gmail.nossr50.mcMMO;
|
2013-11-10 19:54:45 +01:00
|
|
|
import com.gmail.nossr50.config.AdvancedConfig;
|
2013-03-01 06:52:01 +01:00
|
|
|
import com.gmail.nossr50.config.Config;
|
2017-04-15 06:04:07 +02:00
|
|
|
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
2013-03-01 06:52:01 +01:00
|
|
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
2013-11-22 18:48:53 +01:00
|
|
|
import com.gmail.nossr50.datatypes.skills.SecondaryAbility;
|
2013-03-01 06:52:01 +01:00
|
|
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
2014-05-18 17:06:50 +02:00
|
|
|
import com.gmail.nossr50.datatypes.skills.XPGainReason;
|
2014-03-03 18:27:45 +01:00
|
|
|
import com.gmail.nossr50.events.fake.FakeEntityTameEvent;
|
2013-09-17 00:55:38 +02:00
|
|
|
import com.gmail.nossr50.events.skills.secondaryabilities.SecondaryAbilityWeightedActivationCheckEvent;
|
2013-03-01 21:49:24 +01:00
|
|
|
import com.gmail.nossr50.locale.LocaleLoader;
|
|
|
|
import com.gmail.nossr50.runnables.skills.BleedTimerTask;
|
2013-03-01 06:52:01 +01:00
|
|
|
import com.gmail.nossr50.skills.SkillManager;
|
|
|
|
import com.gmail.nossr50.util.Misc;
|
|
|
|
import com.gmail.nossr50.util.Permissions;
|
2013-03-01 21:49:24 +01:00
|
|
|
import com.gmail.nossr50.util.StringUtils;
|
2016-03-01 19:08:11 +01:00
|
|
|
import com.gmail.nossr50.util.adapter.SoundAdapter;
|
2013-09-17 00:55:38 +02:00
|
|
|
import com.gmail.nossr50.util.player.UserManager;
|
2013-09-13 01:22:54 +02:00
|
|
|
import com.gmail.nossr50.util.skills.ParticleEffectUtils;
|
2013-03-01 06:52:01 +01:00
|
|
|
import com.gmail.nossr50.util.skills.SkillUtils;
|
|
|
|
|
|
|
|
public class TamingManager extends SkillManager {
|
|
|
|
public TamingManager(McMMOPlayer mcMMOPlayer) {
|
|
|
|
super(mcMMOPlayer, SkillType.TAMING);
|
|
|
|
}
|
|
|
|
|
2013-09-17 00:55:38 +02:00
|
|
|
private static HashMap<EntityType, List<TrackedTamingEntity>> summonedEntities = new HashMap<EntityType, List<TrackedTamingEntity>>();
|
|
|
|
|
2013-03-01 21:49:24 +01:00
|
|
|
public boolean canUseThickFur() {
|
2013-11-22 18:48:53 +01:00
|
|
|
return getSkillLevel() >= Taming.thickFurUnlockLevel && Permissions.secondaryAbilityEnabled(getPlayer(), SecondaryAbility.THICK_FUR);
|
2013-03-01 21:49:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public boolean canUseEnvironmentallyAware() {
|
2013-11-22 18:48:53 +01:00
|
|
|
return getSkillLevel() >= Taming.environmentallyAwareUnlockLevel && Permissions.secondaryAbilityEnabled(getPlayer(), SecondaryAbility.ENVIROMENTALLY_AWARE);
|
2013-03-01 21:49:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public boolean canUseShockProof() {
|
2013-11-22 18:48:53 +01:00
|
|
|
return getSkillLevel() >= Taming.shockProofUnlockLevel && Permissions.secondaryAbilityEnabled(getPlayer(), SecondaryAbility.SHOCK_PROOF);
|
2013-03-01 21:49:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public boolean canUseHolyHound() {
|
2013-11-22 18:48:53 +01:00
|
|
|
return getSkillLevel() >= Taming.holyHoundUnlockLevel && Permissions.secondaryAbilityEnabled(getPlayer(), SecondaryAbility.HOLY_HOUND);
|
2013-03-01 21:49:24 +01:00
|
|
|
}
|
|
|
|
|
2013-03-04 15:40:03 +01:00
|
|
|
public boolean canUseFastFoodService() {
|
2013-11-22 18:48:53 +01:00
|
|
|
return getSkillLevel() >= Taming.fastFoodServiceUnlockLevel && Permissions.secondaryAbilityEnabled(getPlayer(), SecondaryAbility.FAST_FOOD);
|
2013-03-04 15:40:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public boolean canUseSharpenedClaws() {
|
2013-11-22 18:48:53 +01:00
|
|
|
return getSkillLevel() >= Taming.sharpenedClawsUnlockLevel && Permissions.secondaryAbilityEnabled(getPlayer(), SecondaryAbility.SHARPENED_CLAWS);
|
2013-03-04 15:40:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public boolean canUseGore() {
|
2013-11-22 18:48:53 +01:00
|
|
|
return Permissions.secondaryAbilityEnabled(getPlayer(), SecondaryAbility.GORE);
|
2013-03-04 15:40:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public boolean canUseBeastLore() {
|
2013-11-22 18:48:53 +01:00
|
|
|
return Permissions.secondaryAbilityEnabled(getPlayer(), SecondaryAbility.BEAST_LORE);
|
2013-03-03 07:31:14 +01:00
|
|
|
}
|
|
|
|
|
2013-03-01 06:52:01 +01:00
|
|
|
/**
|
|
|
|
* Award XP for taming.
|
|
|
|
*
|
2013-08-10 20:10:45 +02:00
|
|
|
* @param entity The LivingEntity to award XP for
|
2013-03-01 06:52:01 +01:00
|
|
|
*/
|
|
|
|
public void awardTamingXP(LivingEntity entity) {
|
2017-04-15 06:04:07 +02:00
|
|
|
applyXpGain(ExperienceConfig.getInstance().getTamingXP(entity.getType()), XPGainReason.PVE);
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Apply the Fast Food Service ability.
|
|
|
|
*
|
|
|
|
* @param wolf The wolf using the ability
|
|
|
|
* @param damage The damage being absorbed by the wolf
|
|
|
|
*/
|
2013-07-11 18:43:36 +02:00
|
|
|
public void fastFoodService(Wolf wolf, double damage) {
|
2014-05-11 14:58:08 +02:00
|
|
|
if (!SkillUtils.activationSuccessful(SecondaryAbility.FAST_FOOD, getPlayer(), Taming.fastFoodServiceActivationChance, activationChance)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
double health = wolf.getHealth();
|
|
|
|
double maxHealth = wolf.getMaxHealth();
|
|
|
|
|
|
|
|
if (health < maxHealth) {
|
|
|
|
double newHealth = health + damage;
|
|
|
|
wolf.setHealth(Math.min(newHealth, maxHealth));
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Apply the Gore ability.
|
|
|
|
*
|
2013-08-10 20:10:45 +02:00
|
|
|
* @param target The LivingEntity to apply Gore on
|
|
|
|
* @param damage The initial damage
|
2013-03-01 06:52:01 +01:00
|
|
|
*/
|
2014-06-29 16:38:40 +02:00
|
|
|
public double gore(LivingEntity target, double damage) {
|
2013-11-22 18:48:53 +01:00
|
|
|
if (!SkillUtils.activationSuccessful(SecondaryAbility.GORE, getPlayer(), getSkillLevel(), activationChance)) {
|
2013-09-12 17:52:34 +02:00
|
|
|
return 0;
|
2013-08-23 16:58:50 +02:00
|
|
|
}
|
2013-03-01 21:49:24 +01:00
|
|
|
|
2013-08-23 16:58:50 +02:00
|
|
|
BleedTimerTask.add(target, Taming.goreBleedTicks);
|
2013-03-01 06:52:01 +01:00
|
|
|
|
2013-08-23 16:58:50 +02:00
|
|
|
if (target instanceof Player) {
|
|
|
|
((Player) target).sendMessage(LocaleLoader.getString("Combat.StruckByGore"));
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
2013-03-01 21:49:24 +01:00
|
|
|
|
2013-08-23 16:58:50 +02:00
|
|
|
getPlayer().sendMessage(LocaleLoader.getString("Combat.Gore"));
|
|
|
|
|
|
|
|
damage = (damage * Taming.goreModifier) - damage;
|
2014-06-29 16:38:40 +02:00
|
|
|
return damage;
|
2013-08-23 16:58:50 +02:00
|
|
|
}
|
|
|
|
|
2014-06-29 16:38:40 +02:00
|
|
|
public double sharpenedClaws() {
|
|
|
|
return Taming.sharpenedClawsBonusDamage;
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Summon an ocelot to your side.
|
|
|
|
*/
|
|
|
|
public void summonOcelot() {
|
2013-08-30 19:50:34 +02:00
|
|
|
if (!Permissions.callOfTheWild(getPlayer(), EntityType.OCELOT)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-03-23 14:31:51 +01:00
|
|
|
callOfTheWild(EntityType.OCELOT, Config.getInstance().getTamingCOTWCost(EntityType.OCELOT));
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Summon a wolf to your side.
|
|
|
|
*/
|
|
|
|
public void summonWolf() {
|
2013-08-30 19:50:34 +02:00
|
|
|
if (!Permissions.callOfTheWild(getPlayer(), EntityType.WOLF)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-03-23 14:31:51 +01:00
|
|
|
callOfTheWild(EntityType.WOLF, Config.getInstance().getTamingCOTWCost(EntityType.WOLF));
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
|
2013-08-30 20:25:46 +02:00
|
|
|
/**
|
|
|
|
* Summon a horse to your side.
|
|
|
|
*/
|
|
|
|
public void summonHorse() {
|
|
|
|
if (!Permissions.callOfTheWild(getPlayer(), EntityType.HORSE)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-03-23 14:31:51 +01:00
|
|
|
callOfTheWild(EntityType.HORSE, Config.getInstance().getTamingCOTWCost(EntityType.HORSE));
|
2013-08-30 20:25:46 +02:00
|
|
|
}
|
|
|
|
|
2013-03-01 06:52:01 +01:00
|
|
|
/**
|
|
|
|
* Handle the Beast Lore ability.
|
|
|
|
*
|
2013-03-01 21:49:24 +01:00
|
|
|
* @param target The entity to examine
|
2013-03-01 06:52:01 +01:00
|
|
|
*/
|
2013-03-01 21:49:24 +01:00
|
|
|
public void beastLore(LivingEntity target) {
|
|
|
|
Player player = getPlayer();
|
|
|
|
Tameable beast = (Tameable) target;
|
|
|
|
|
|
|
|
String message = LocaleLoader.getString("Combat.BeastLore") + " ";
|
|
|
|
|
2013-07-22 11:35:48 +02:00
|
|
|
if (beast.isTamed() && beast.getOwner() != null) {
|
2013-03-03 21:22:40 +01:00
|
|
|
message = message.concat(LocaleLoader.getString("Combat.BeastLoreOwner", beast.getOwner().getName()) + " ");
|
2013-03-01 21:49:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
message = message.concat(LocaleLoader.getString("Combat.BeastLoreHealth", target.getHealth(), target.getMaxHealth()));
|
|
|
|
player.sendMessage(message);
|
|
|
|
}
|
|
|
|
|
2013-07-11 18:43:36 +02:00
|
|
|
public void processEnvironmentallyAware(Wolf wolf, double damage) {
|
2013-03-01 21:49:24 +01:00
|
|
|
if (damage > wolf.getHealth()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
Player owner = getPlayer();
|
|
|
|
|
|
|
|
wolf.teleport(owner);
|
|
|
|
owner.sendMessage(LocaleLoader.getString("Taming.Listener.Wolf"));
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
|
2013-09-17 00:55:38 +02:00
|
|
|
public void pummel(LivingEntity target, Wolf wolf) {
|
|
|
|
double chance = 10 / activationChance;
|
|
|
|
SecondaryAbilityWeightedActivationCheckEvent event = new SecondaryAbilityWeightedActivationCheckEvent(getPlayer(), SecondaryAbility.PUMMEL, chance);
|
|
|
|
mcMMO.p.getServer().getPluginManager().callEvent(event);
|
|
|
|
if ((event.getChance() * activationChance) <= Misc.getRandom().nextInt(activationChance)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ParticleEffectUtils.playGreaterImpactEffect(target);
|
|
|
|
target.setVelocity(wolf.getLocation().getDirection().normalize().multiply(1.5D));
|
|
|
|
|
|
|
|
if (target instanceof Player) {
|
|
|
|
Player defender = (Player) target;
|
|
|
|
|
|
|
|
if (UserManager.getPlayer(defender).useChatNotifications()) {
|
|
|
|
defender.sendMessage("Wolf pummeled at you");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-04-18 23:15:20 +02:00
|
|
|
public void attackTarget(LivingEntity target) {
|
|
|
|
double range = 5;
|
|
|
|
Player player = getPlayer();
|
|
|
|
|
|
|
|
for (Entity entity : player.getNearbyEntities(range, range, range)) {
|
|
|
|
if (entity.getType() != EntityType.WOLF) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
Wolf wolf = (Wolf) entity;
|
|
|
|
|
|
|
|
if (!wolf.isTamed() || (wolf.getOwner() != player) || wolf.isSitting()) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
wolf.setTarget(target);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-01 06:52:01 +01:00
|
|
|
/**
|
|
|
|
* Handle the Call of the Wild ability.
|
|
|
|
*
|
|
|
|
* @param type The type of entity to summon.
|
|
|
|
* @param summonAmount The amount of material needed to summon the entity
|
|
|
|
*/
|
|
|
|
private void callOfTheWild(EntityType type, int summonAmount) {
|
2013-03-01 21:49:24 +01:00
|
|
|
Player player = getPlayer();
|
|
|
|
|
2016-03-11 15:20:23 +01:00
|
|
|
ItemStack heldItem = player.getInventory().getItemInMainHand();
|
2013-03-01 21:49:24 +01:00
|
|
|
int heldItemAmount = heldItem.getAmount();
|
2013-09-13 01:22:54 +02:00
|
|
|
Location location = player.getLocation();
|
2013-03-01 21:49:24 +01:00
|
|
|
|
|
|
|
if (heldItemAmount < summonAmount) {
|
2013-09-05 20:55:08 +02:00
|
|
|
player.sendMessage(LocaleLoader.getString("Skills.NeedMore", StringUtils.getPrettyItemString(heldItem.getType())));
|
2013-03-01 06:52:01 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-07-24 20:13:58 +02:00
|
|
|
if (!rangeCheck(type)) {
|
|
|
|
return;
|
2013-03-01 21:49:24 +01:00
|
|
|
}
|
2013-03-01 06:52:01 +01:00
|
|
|
|
2013-07-24 20:01:16 +02:00
|
|
|
int amount = Config.getInstance().getTamingCOTWAmount(type);
|
2013-09-13 01:22:54 +02:00
|
|
|
int tamingCOTWLength = Config.getInstance().getTamingCOTWLength(type);
|
2013-07-24 20:13:58 +02:00
|
|
|
|
2013-07-24 20:01:16 +02:00
|
|
|
for (int i = 0; i < amount; i++) {
|
2013-09-17 00:55:38 +02:00
|
|
|
if (!summonAmountCheck(type)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-12-20 19:11:08 +01:00
|
|
|
location = Misc.getLocationOffset(location, 1);
|
2013-09-13 01:22:54 +02:00
|
|
|
LivingEntity entity = (LivingEntity) player.getWorld().spawnEntity(location, type);
|
2014-02-28 18:04:00 +01:00
|
|
|
|
|
|
|
FakeEntityTameEvent event = new FakeEntityTameEvent(entity, player);
|
|
|
|
mcMMO.p.getServer().getPluginManager().callEvent(event);
|
|
|
|
|
|
|
|
if (event.isCancelled()) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2013-07-24 20:01:16 +02:00
|
|
|
entity.setMetadata(mcMMO.entityMetadataKey, mcMMO.metadataValue);
|
|
|
|
((Tameable) entity).setOwner(player);
|
2014-02-28 17:50:14 +01:00
|
|
|
entity.setRemoveWhenFarAway(false);
|
2013-03-01 21:49:24 +01:00
|
|
|
|
2013-09-17 00:55:38 +02:00
|
|
|
addToTracker(entity);
|
2013-09-13 01:22:54 +02:00
|
|
|
|
2013-07-24 20:13:58 +02:00
|
|
|
switch (type) {
|
|
|
|
case OCELOT:
|
2013-09-13 15:11:34 +02:00
|
|
|
((Ocelot) entity).setCatType(Ocelot.Type.values()[1 + Misc.getRandom().nextInt(3)]);
|
2013-07-24 20:13:58 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WOLF:
|
|
|
|
entity.setMaxHealth(20.0);
|
|
|
|
entity.setHealth(entity.getMaxHealth());
|
|
|
|
break;
|
|
|
|
|
2013-09-23 21:57:28 +02:00
|
|
|
case HORSE:
|
2013-09-26 16:43:45 +02:00
|
|
|
Horse horse = (Horse) entity;
|
|
|
|
|
|
|
|
entity.setMaxHealth(15.0 + (Misc.getRandom().nextDouble() * 15));
|
2013-09-23 21:57:28 +02:00
|
|
|
entity.setHealth(entity.getMaxHealth());
|
2013-09-26 16:43:45 +02:00
|
|
|
horse.setColor(Horse.Color.values()[Misc.getRandom().nextInt(Horse.Color.values().length)]);
|
|
|
|
horse.setStyle(Horse.Style.values()[Misc.getRandom().nextInt(Horse.Style.values().length)]);
|
2014-03-23 13:41:31 +01:00
|
|
|
horse.setJumpStrength(Math.max(AdvancedConfig.getInstance().getMinHorseJumpStrength(), Math.min(Math.min(Misc.getRandom().nextDouble(), Misc.getRandom().nextDouble()) * 2, AdvancedConfig.getInstance().getMaxHorseJumpStrength())));
|
2013-09-26 16:43:45 +02:00
|
|
|
//TODO: setSpeed, once available
|
2013-09-23 21:57:28 +02:00
|
|
|
break;
|
|
|
|
|
2013-07-24 20:13:58 +02:00
|
|
|
default:
|
|
|
|
break;
|
2013-07-24 20:01:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (Permissions.renamePets(player)) {
|
2013-07-24 20:13:58 +02:00
|
|
|
entity.setCustomName(LocaleLoader.getString("Taming.Summon.Name.Format", player.getName(), StringUtils.getPrettyEntityTypeString(type)));
|
2013-07-24 20:01:16 +02:00
|
|
|
}
|
2013-09-13 01:22:54 +02:00
|
|
|
|
|
|
|
ParticleEffectUtils.playCallOfTheWildEffect(entity);
|
2013-04-18 23:04:27 +02:00
|
|
|
}
|
|
|
|
|
2016-03-11 15:20:23 +01:00
|
|
|
player.getInventory().setItemInMainHand(heldItemAmount == summonAmount ? null : new ItemStack(heldItem.getType(), heldItemAmount - summonAmount));
|
2013-09-13 01:22:54 +02:00
|
|
|
|
|
|
|
String lifeSpan = "";
|
|
|
|
if (tamingCOTWLength > 0) {
|
|
|
|
lifeSpan = LocaleLoader.getString("Taming.Summon.Lifespan", tamingCOTWLength);
|
|
|
|
}
|
|
|
|
|
|
|
|
player.sendMessage(LocaleLoader.getString("Taming.Summon.Complete") + lifeSpan);
|
2016-03-01 19:08:11 +01:00
|
|
|
player.playSound(location, SoundAdapter.FIREWORK_BLAST_FAR, 1F, 0.5F);
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
2013-07-24 20:13:58 +02:00
|
|
|
|
|
|
|
private boolean rangeCheck(EntityType type) {
|
|
|
|
double range = Config.getInstance().getTamingCOTWRange();
|
|
|
|
Player player = getPlayer();
|
|
|
|
|
|
|
|
if (range == 0) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (Entity entity : player.getNearbyEntities(range, range, range)) {
|
|
|
|
if (entity.getType() == type) {
|
|
|
|
player.sendMessage(Taming.getCallOfTheWildFailureMessage(type));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2013-09-17 00:55:38 +02:00
|
|
|
|
|
|
|
private boolean summonAmountCheck(EntityType entityType) {
|
|
|
|
Player player = getPlayer();
|
|
|
|
|
|
|
|
int maxAmountSummons = Config.getInstance().getTamingCOTWMaxAmount(entityType);
|
|
|
|
|
|
|
|
if (maxAmountSummons <= 0) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-04-21 15:19:37 +02:00
|
|
|
List<TrackedTamingEntity> trackedEntities = getTrackedEntities(entityType);
|
|
|
|
int summonAmount = trackedEntities == null ? 0 : trackedEntities.size();
|
2013-09-17 00:55:38 +02:00
|
|
|
|
|
|
|
if (summonAmount >= maxAmountSummons) {
|
|
|
|
player.sendMessage(LocaleLoader.getString("Taming.Summon.Fail.TooMany", maxAmountSummons));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected static void addToTracker(LivingEntity livingEntity) {
|
|
|
|
TrackedTamingEntity trackedEntity = new TrackedTamingEntity(livingEntity);
|
|
|
|
|
|
|
|
if (!summonedEntities.containsKey(livingEntity.getType())) {
|
|
|
|
summonedEntities.put(livingEntity.getType(), new ArrayList<TrackedTamingEntity>());
|
|
|
|
}
|
|
|
|
|
|
|
|
summonedEntities.get(livingEntity.getType()).add(trackedEntity);
|
|
|
|
}
|
|
|
|
|
2014-04-21 15:19:37 +02:00
|
|
|
protected static List<TrackedTamingEntity> getTrackedEntities(EntityType entityType) {
|
|
|
|
return summonedEntities.get(entityType);
|
|
|
|
}
|
|
|
|
|
2013-09-17 00:55:38 +02:00
|
|
|
protected static void removeFromTracker(TrackedTamingEntity trackedEntity) {
|
|
|
|
summonedEntities.get(trackedEntity.getLivingEntity().getType()).remove(trackedEntity);
|
|
|
|
}
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|