mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-26 07:06:45 +01:00
Check the range in a seperate function
This commit is contained in:
parent
df2defe969
commit
78f2e0a064
@ -178,17 +178,13 @@ public class TamingManager extends SkillManager {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
double range = Config.getInstance().getTamingCOTWRange();
|
if (!rangeCheck(type)) {
|
||||||
if (range > 0) {
|
|
||||||
for (Entity entity : player.getNearbyEntities(range, range, range)) {
|
|
||||||
if (entity.getType() == type) {
|
|
||||||
player.sendMessage(Taming.getCallOfTheWildFailureMessage(type));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int amount = Config.getInstance().getTamingCOTWAmount(type);
|
int amount = Config.getInstance().getTamingCOTWAmount(type);
|
||||||
|
|
||||||
|
// TODO: Validate in config instead
|
||||||
if (amount <= 0) {
|
if (amount <= 0) {
|
||||||
amount = 1;
|
amount = 1;
|
||||||
}
|
}
|
||||||
@ -199,16 +195,22 @@ public class TamingManager extends SkillManager {
|
|||||||
entity.setMetadata(mcMMO.entityMetadataKey, mcMMO.metadataValue);
|
entity.setMetadata(mcMMO.entityMetadataKey, mcMMO.metadataValue);
|
||||||
((Tameable) entity).setOwner(player);
|
((Tameable) entity).setOwner(player);
|
||||||
|
|
||||||
if (type == EntityType.OCELOT) {
|
switch (type) {
|
||||||
|
case OCELOT:
|
||||||
((Ocelot) entity).setCatType(Ocelot.Type.getType(1 + Misc.getRandom().nextInt(3)));
|
((Ocelot) entity).setCatType(Ocelot.Type.getType(1 + Misc.getRandom().nextInt(3)));
|
||||||
}
|
break;
|
||||||
else {
|
|
||||||
entity.setMaxHealth(20);
|
case WOLF:
|
||||||
|
entity.setMaxHealth(20.0);
|
||||||
entity.setHealth(entity.getMaxHealth());
|
entity.setHealth(entity.getMaxHealth());
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Permissions.renamePets(player)) {
|
if (Permissions.renamePets(player)) {
|
||||||
entity.setCustomName(LocaleLoader.getString("Taming.Summon.Name.Format", player.getName(), StringUtils.getPrettyEntityTypeString(entity.getType())));
|
entity.setCustomName(LocaleLoader.getString("Taming.Summon.Name.Format", player.getName(), StringUtils.getPrettyEntityTypeString(type)));
|
||||||
entity.setCustomNameVisible(true);
|
entity.setCustomNameVisible(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -216,4 +218,22 @@ public class TamingManager extends SkillManager {
|
|||||||
player.setItemInHand(new ItemStack(heldItem.getType(), heldItemAmount - summonAmount));
|
player.setItemInHand(new ItemStack(heldItem.getType(), heldItemAmount - summonAmount));
|
||||||
player.sendMessage(LocaleLoader.getString("Taming.Summon.Complete"));
|
player.sendMessage(LocaleLoader.getString("Taming.Summon.Complete"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user