|
@@ -1,5 +1,7 @@
|
|
|
package com.gmail.nossr50.skills.taming;
|
|
|
|
|
|
+import org.bukkit.Location;
|
|
|
+import org.bukkit.Sound;
|
|
|
import org.bukkit.entity.Entity;
|
|
|
import org.bukkit.entity.EntityType;
|
|
|
import org.bukkit.entity.Horse;
|
|
@@ -24,6 +26,7 @@ import com.gmail.nossr50.skills.SkillManager;
|
|
|
import com.gmail.nossr50.util.Misc;
|
|
|
import com.gmail.nossr50.util.Permissions;
|
|
|
import com.gmail.nossr50.util.StringUtils;
|
|
|
+import com.gmail.nossr50.util.skills.ParticleEffectUtils;
|
|
|
import com.gmail.nossr50.util.skills.SkillUtils;
|
|
|
|
|
|
public class TamingManager extends SkillManager {
|
|
@@ -208,6 +211,7 @@ public class TamingManager extends SkillManager {
|
|
|
|
|
|
ItemStack heldItem = player.getItemInHand();
|
|
|
int heldItemAmount = heldItem.getAmount();
|
|
|
+ Location location = player.getLocation();
|
|
|
|
|
|
if (heldItemAmount < summonAmount) {
|
|
|
player.sendMessage(LocaleLoader.getString("Skills.NeedMore", StringUtils.getPrettyItemString(heldItem.getType())));
|
|
@@ -219,9 +223,10 @@ public class TamingManager extends SkillManager {
|
|
|
}
|
|
|
|
|
|
int amount = Config.getInstance().getTamingCOTWAmount(type);
|
|
|
+ int tamingCOTWLength = Config.getInstance().getTamingCOTWLength(type);
|
|
|
|
|
|
for (int i = 0; i < amount; i++) {
|
|
|
- LivingEntity entity = (LivingEntity) player.getWorld().spawnEntity(player.getLocation(), type);
|
|
|
+ LivingEntity entity = (LivingEntity) player.getWorld().spawnEntity(location, type);
|
|
|
|
|
|
FakeEntityTameEvent event = new FakeEntityTameEvent(entity, player);
|
|
|
mcMMO.p.getServer().getPluginManager().callEvent(event);
|
|
@@ -234,6 +239,10 @@ public class TamingManager extends SkillManager {
|
|
|
((Tameable) entity).setOwner(player);
|
|
|
entity.setRemoveWhenFarAway(false);
|
|
|
|
|
|
+ if (tamingCOTWLength > 0) {
|
|
|
+ Taming.addToTracker(entity);
|
|
|
+ }
|
|
|
+
|
|
|
switch (type) {
|
|
|
case OCELOT:
|
|
|
((Ocelot) entity).setCatType(Ocelot.Type.values()[1 + Misc.getRandom().nextInt(3)]);
|
|
@@ -263,10 +272,19 @@ public class TamingManager extends SkillManager {
|
|
|
entity.setCustomName(LocaleLoader.getString("Taming.Summon.Name.Format", player.getName(), StringUtils.getPrettyEntityTypeString(type)));
|
|
|
entity.setCustomNameVisible(true);
|
|
|
}
|
|
|
+
|
|
|
+ ParticleEffectUtils.playCallOfTheWildEffect(entity);
|
|
|
}
|
|
|
|
|
|
player.setItemInHand(heldItemAmount == summonAmount ? null : new ItemStack(heldItem.getType(), heldItemAmount - summonAmount));
|
|
|
- player.sendMessage(LocaleLoader.getString("Taming.Summon.Complete"));
|
|
|
+
|
|
|
+ String lifeSpan = "";
|
|
|
+ if (tamingCOTWLength > 0) {
|
|
|
+ lifeSpan = LocaleLoader.getString("Taming.Summon.Lifespan", tamingCOTWLength);
|
|
|
+ }
|
|
|
+
|
|
|
+ player.sendMessage(LocaleLoader.getString("Taming.Summon.Complete") + lifeSpan);
|
|
|
+ player.playSound(location, Sound.FIREWORK_LARGE_BLAST2, 1F, 0.5F);
|
|
|
}
|
|
|
|
|
|
private boolean rangeCheck(EntityType type) {
|