From a19ddb46b6d80688d1b53a0e8acd3823e1caab30 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Tue, 2 Jul 2019 00:32:38 -0700 Subject: [PATCH] Fixing some bugs, tweaking some strings for COTW --- .../java/com/gmail/nossr50/config/Config.java | 1 - .../nossr50/skills/taming/TamingManager.java | 44 ++++++++++++------- .../skills/taming/TrackedTamingEntity.java | 3 +- .../nossr50/util/skills/CombatUtils.java | 1 - .../resources/locale/locale_en_US.properties | 4 +- 5 files changed, 30 insertions(+), 23 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/config/Config.java b/src/main/java/com/gmail/nossr50/config/Config.java index 692ae055c..d16ab6852 100644 --- a/src/main/java/com/gmail/nossr50/config/Config.java +++ b/src/main/java/com/gmail/nossr50/config/Config.java @@ -9,7 +9,6 @@ import com.gmail.nossr50.util.StringUtils; import org.bukkit.Material; import org.bukkit.block.data.BlockData; import org.bukkit.configuration.ConfigurationSection; -import org.bukkit.entity.EntityType; import java.util.ArrayList; import java.util.List; diff --git a/src/main/java/com/gmail/nossr50/skills/taming/TamingManager.java b/src/main/java/com/gmail/nossr50/skills/taming/TamingManager.java index 9d55c6057..45b58e919 100644 --- a/src/main/java/com/gmail/nossr50/skills/taming/TamingManager.java +++ b/src/main/java/com/gmail/nossr50/skills/taming/TamingManager.java @@ -27,7 +27,6 @@ import com.gmail.nossr50.util.sounds.SoundManager; import com.gmail.nossr50.util.sounds.SoundType; import org.bukkit.Location; import org.bukkit.Material; -import org.bukkit.Sound; import org.bukkit.entity.*; import org.bukkit.inventory.ItemStack; @@ -86,7 +85,7 @@ public class TamingManager extends SkillManager { for(CallOfTheWildType callOfTheWildType : CallOfTheWildType.values()) { Material itemSummonMaterial = Config.getInstance().getTamingCOTWMaterial(callOfTheWildType.getConfigEntityTypeEntry()); - int itemAmountRequired = Config.getInstance().getTamingCOTWAmount(callOfTheWildType.getConfigEntityTypeEntry()); + int itemAmountRequired = Config.getInstance().getTamingCOTWCost(callOfTheWildType.getConfigEntityTypeEntry()); int entitiesSummonedPerCOTW = Config.getInstance().getTamingCOTWAmount(callOfTheWildType.getConfigEntityTypeEntry()); int summonLifespanSeconds = Config.getInstance().getTamingCOTWLength(callOfTheWildType.getConfigEntityTypeEntry()); int perPlayerMaxAmount = Config.getInstance().getTamingCOTWMaxAmount(callOfTheWildType.getConfigEntityTypeEntry()); @@ -333,6 +332,8 @@ public class TamingManager extends SkillManager { CallOfTheWildType callOfTheWildType = summoningItems.get(itemInMainHand.getType()); TamingSummon tamingSummon = cotwSummonDataProperties.get(callOfTheWildType); + //Players will pay for the cost if at least one thing was summoned + int amountSummoned = 0; //Check to see if players have the correct amount of the item required to summon if(itemInMainHand.getAmount() >= tamingSummon.getItemAmountRequired()) { @@ -343,30 +344,37 @@ public class TamingManager extends SkillManager { for (int i = 0; i < tamingSummon.getEntitiesSummoned(); i++) { if (getAmountCurrentlySummoned(callOfTheWildType) >= tamingSummon.getSummonCap()) { - NotificationManager.sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE_FAILED, "Taming.Summon.COTW.Limit", String.valueOf(tamingSummon.getSummonCap())); + NotificationManager.sendPlayerInformationChatOnly(player, "Taming.Summon.COTW.Limit", + String.valueOf(tamingSummon.getSummonCap()), + StringUtils.getCapitalized(callOfTheWildType.toString())); break; } spawnLocation = Misc.getLocationOffset(spawnLocation, 1); spawnCOTWEntity(callOfTheWildType, spawnLocation, tamingSummon.getEntityType()); + + //Inform the player about what they have just done + if (tamingSummon.getSummonLifespan() > 0) { + NotificationManager.sendPlayerInformationChatOnly(player, "Taming.Summon.COTW.Success", + StringUtils.getCapitalized(callOfTheWildType.toString()), String.valueOf(tamingSummon.getSummonLifespan())); + } else { + NotificationManager.sendPlayerInformationChatOnly(player, "Taming.Summon.Complete"); + } + + //Send Sound + SoundManager.sendSound(player, player.getLocation(), SoundType.ABILITY_ACTIVATED_GENERIC); + + amountSummoned++; } - //Remove the items used to summon - int itemAmountAfterPayingCost = itemInMainHand.getAmount() - tamingSummon.getItemAmountRequired(); - itemInMainHand.setAmount(itemAmountAfterPayingCost); - player.updateInventory(); - - //Inform the player about what they have just done - if (tamingSummon.getSummonLifespan() > 0) { - NotificationManager.sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE, "Taming.Summon.COTW.Success", - StringUtils.getCapitalized(callOfTheWildType.toString()), String.valueOf(tamingSummon.getSummonLifespan())); - } else { - NotificationManager.sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE, "Taming.Summon.Complete"); + //Remove items from the player if they had at least one entity summoned successfully + if(amountSummoned >= 1) { + //Remove the items used to summon + int itemAmountAfterPayingCost = itemInMainHand.getAmount() - tamingSummon.getItemAmountRequired(); + itemInMainHand.setAmount(itemAmountAfterPayingCost); + player.updateInventory(); } - //Send Sound - SoundManager.sendSound(player, player.getLocation(), SoundType.ABILITY_ACTIVATED_GENERIC); - } else { //Player did not have enough of the item in their main hand int difference = tamingSummon.getItemAmountRequired() - itemInMainHand.getAmount(); @@ -449,6 +457,7 @@ public class TamingManager extends SkillManager { horse.setColor(Horse.Color.values()[Misc.getRandom().nextInt(Horse.Color.values().length)]); horse.setStyle(Horse.Style.values()[Misc.getRandom().nextInt(Horse.Style.values().length)]); horse.setJumpStrength(Math.max(AdvancedConfig.getInstance().getMinHorseJumpStrength(), Math.min(Math.min(Misc.getRandom().nextDouble(), Misc.getRandom().nextDouble()) * 2, AdvancedConfig.getInstance().getMaxHorseJumpStrength()))); + //TODO: setSpeed, once available callOfWildEntity.setCustomName(LocaleLoader.getString("Taming.Summon.Name.Format", getPlayer().getName(), StringUtils.getPrettyEntityTypeString(EntityType.HORSE))); @@ -546,6 +555,7 @@ public class TamingManager extends SkillManager { //Remove from existence if(livingEntity != null && livingEntity.isValid()) { + livingEntity.setHealth(0); livingEntity.remove(); } } diff --git a/src/main/java/com/gmail/nossr50/skills/taming/TrackedTamingEntity.java b/src/main/java/com/gmail/nossr50/skills/taming/TrackedTamingEntity.java index 6028d97c4..0a8e99637 100644 --- a/src/main/java/com/gmail/nossr50/skills/taming/TrackedTamingEntity.java +++ b/src/main/java/com/gmail/nossr50/skills/taming/TrackedTamingEntity.java @@ -4,12 +4,10 @@ import com.gmail.nossr50.config.Config; import com.gmail.nossr50.datatypes.skills.subskills.taming.CallOfTheWildType; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.Misc; -import com.gmail.nossr50.util.skills.CombatUtils; import com.gmail.nossr50.util.skills.ParticleEffectUtils; import org.bukkit.Location; import org.bukkit.Sound; import org.bukkit.entity.LivingEntity; -import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.scheduler.BukkitRunnable; import java.util.UUID; @@ -45,6 +43,7 @@ public class TrackedTamingEntity extends BukkitRunnable { if(tamingManagerRef != null) tamingManagerRef.removeFromTracker(this); + livingEntity.setHealth(0); livingEntity.remove(); } diff --git a/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java b/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java index cd3ffb75a..598310e41 100644 --- a/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java +++ b/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java @@ -17,7 +17,6 @@ import com.gmail.nossr50.skills.archery.ArcheryManager; import com.gmail.nossr50.skills.axes.AxesManager; import com.gmail.nossr50.skills.swords.SwordsManager; import com.gmail.nossr50.skills.taming.TamingManager; -import com.gmail.nossr50.skills.unarmed.Unarmed; import com.gmail.nossr50.skills.unarmed.UnarmedManager; import com.gmail.nossr50.util.*; import com.gmail.nossr50.util.player.NotificationManager; diff --git a/src/main/resources/locale/locale_en_US.properties b/src/main/resources/locale/locale_en_US.properties index e8ad00393..ff84cff18 100644 --- a/src/main/resources/locale/locale_en_US.properties +++ b/src/main/resources/locale/locale_en_US.properties @@ -484,8 +484,8 @@ Taming.Summon.Complete=[[GREEN]]Summoning complete Taming.Summon.COTW.Success=[[GREEN]](Call Of The Wild) [[GRAY]]You have summoned a [[GOLD]]{0}[[GRAY]] and it has a duration of [[GOLD]]{1}[[GRAY]] seconds. Taming.Summon.Lifespan= (Lifespan: {0}s) Taming.Summon.Fail.TooMany=[[RED]]You have reached the maximum limit of pets to summon. [[YELLOW]]({0}) -Taming.Summon.COTW.Limit=[[RED]]You can only summon up to {0} for this type of animal. Try again later. -Taming.Summon.COTW.TimeExpired=[[GREEN]](Call Of The Wild) [[GRAY]]Time is up, your temporary summon [[GOLD]]{0}[[GRAY]] departs. +Taming.Summon.COTW.Limit=[[GREEN]](Call Of The Wild) [[GRAY]]You can only have [[RED]]{0} [[GRAY]]summoned [[GRAY]]{1} pets at the same time. +Taming.Summon.COTW.TimeExpired=[[GREEN]](Call Of The Wild) [[GRAY]]Time is up, your [[GOLD]]{0}[[GRAY]] departs. Taming.Summon.COTW.BreedingDisallowed=[[GREEN]](Call Of The Wild) [[RED]]You cannot breed a summoned animal. Taming.Summon.Name.Format=[[GOLD]](COTW) [[WHITE]]{0}'s {1} #UNARMED