Browse Source

Fixing some bugs, tweaking some strings for COTW

nossr50 6 years ago
parent
commit
a19ddb46b6

+ 0 - 1
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.Material;
 import org.bukkit.block.data.BlockData;
 import org.bukkit.block.data.BlockData;
 import org.bukkit.configuration.ConfigurationSection;
 import org.bukkit.configuration.ConfigurationSection;
-import org.bukkit.entity.EntityType;
 
 
 import java.util.ArrayList;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.List;

+ 27 - 17
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 com.gmail.nossr50.util.sounds.SoundType;
 import org.bukkit.Location;
 import org.bukkit.Location;
 import org.bukkit.Material;
 import org.bukkit.Material;
-import org.bukkit.Sound;
 import org.bukkit.entity.*;
 import org.bukkit.entity.*;
 import org.bukkit.inventory.ItemStack;
 import org.bukkit.inventory.ItemStack;
 
 
@@ -86,7 +85,7 @@ public class TamingManager extends SkillManager {
 
 
             for(CallOfTheWildType callOfTheWildType : CallOfTheWildType.values()) {
             for(CallOfTheWildType callOfTheWildType : CallOfTheWildType.values()) {
                 Material itemSummonMaterial = Config.getInstance().getTamingCOTWMaterial(callOfTheWildType.getConfigEntityTypeEntry());
                 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 entitiesSummonedPerCOTW = Config.getInstance().getTamingCOTWAmount(callOfTheWildType.getConfigEntityTypeEntry());
                 int summonLifespanSeconds = Config.getInstance().getTamingCOTWLength(callOfTheWildType.getConfigEntityTypeEntry());
                 int summonLifespanSeconds = Config.getInstance().getTamingCOTWLength(callOfTheWildType.getConfigEntityTypeEntry());
                 int perPlayerMaxAmount = Config.getInstance().getTamingCOTWMaxAmount(callOfTheWildType.getConfigEntityTypeEntry());
                 int perPlayerMaxAmount = Config.getInstance().getTamingCOTWMaxAmount(callOfTheWildType.getConfigEntityTypeEntry());
@@ -333,6 +332,8 @@ public class TamingManager extends SkillManager {
             CallOfTheWildType callOfTheWildType = summoningItems.get(itemInMainHand.getType());
             CallOfTheWildType callOfTheWildType = summoningItems.get(itemInMainHand.getType());
             TamingSummon tamingSummon = cotwSummonDataProperties.get(callOfTheWildType);
             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
             //Check to see if players have the correct amount of the item required to summon
             if(itemInMainHand.getAmount() >= tamingSummon.getItemAmountRequired()) {
             if(itemInMainHand.getAmount() >= tamingSummon.getItemAmountRequired()) {
@@ -343,29 +344,36 @@ public class TamingManager extends SkillManager {
                 for (int i = 0; i < tamingSummon.getEntitiesSummoned(); i++) {
                 for (int i = 0; i < tamingSummon.getEntitiesSummoned(); i++) {
 
 
                     if (getAmountCurrentlySummoned(callOfTheWildType) >= tamingSummon.getSummonCap()) {
                     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;
                         break;
                     }
                     }
 
 
                     spawnLocation = Misc.getLocationOffset(spawnLocation, 1);
                     spawnLocation = Misc.getLocationOffset(spawnLocation, 1);
                     spawnCOTWEntity(callOfTheWildType, spawnLocation, tamingSummon.getEntityType());
                     spawnCOTWEntity(callOfTheWildType, spawnLocation, tamingSummon.getEntityType());
-                }
 
 
-                //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");
+                    //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++;
                 }
                 }
 
 
-                //Send Sound
-                SoundManager.sendSound(player, player.getLocation(), SoundType.ABILITY_ACTIVATED_GENERIC);
+                //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();
+                }
 
 
             } else {
             } else {
                 //Player did not have enough of the item in their main hand
                 //Player did not have enough of the item in their main hand
@@ -449,6 +457,7 @@ public class TamingManager extends SkillManager {
         horse.setColor(Horse.Color.values()[Misc.getRandom().nextInt(Horse.Color.values().length)]);
         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.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())));
         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
         //TODO: setSpeed, once available
 
 
         callOfWildEntity.setCustomName(LocaleLoader.getString("Taming.Summon.Name.Format", getPlayer().getName(), StringUtils.getPrettyEntityTypeString(EntityType.HORSE)));
         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
                 //Remove from existence
                 if(livingEntity != null && livingEntity.isValid()) {
                 if(livingEntity != null && livingEntity.isValid()) {
+                    livingEntity.setHealth(0);
                     livingEntity.remove();
                     livingEntity.remove();
                 }
                 }
             }
             }

+ 1 - 2
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.datatypes.skills.subskills.taming.CallOfTheWildType;
 import com.gmail.nossr50.mcMMO;
 import com.gmail.nossr50.mcMMO;
 import com.gmail.nossr50.util.Misc;
 import com.gmail.nossr50.util.Misc;
-import com.gmail.nossr50.util.skills.CombatUtils;
 import com.gmail.nossr50.util.skills.ParticleEffectUtils;
 import com.gmail.nossr50.util.skills.ParticleEffectUtils;
 import org.bukkit.Location;
 import org.bukkit.Location;
 import org.bukkit.Sound;
 import org.bukkit.Sound;
 import org.bukkit.entity.LivingEntity;
 import org.bukkit.entity.LivingEntity;
-import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
 import org.bukkit.scheduler.BukkitRunnable;
 import org.bukkit.scheduler.BukkitRunnable;
 
 
 import java.util.UUID;
 import java.util.UUID;
@@ -45,6 +43,7 @@ public class TrackedTamingEntity extends BukkitRunnable {
             if(tamingManagerRef != null)
             if(tamingManagerRef != null)
                 tamingManagerRef.removeFromTracker(this);
                 tamingManagerRef.removeFromTracker(this);
 
 
+            livingEntity.setHealth(0);
             livingEntity.remove();
             livingEntity.remove();
         }
         }
 
 

+ 0 - 1
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.axes.AxesManager;
 import com.gmail.nossr50.skills.swords.SwordsManager;
 import com.gmail.nossr50.skills.swords.SwordsManager;
 import com.gmail.nossr50.skills.taming.TamingManager;
 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.skills.unarmed.UnarmedManager;
 import com.gmail.nossr50.util.*;
 import com.gmail.nossr50.util.*;
 import com.gmail.nossr50.util.player.NotificationManager;
 import com.gmail.nossr50.util.player.NotificationManager;

+ 2 - 2
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.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.Lifespan= (Lifespan: {0}s)
 Taming.Summon.Fail.TooMany=[[RED]]You have reached the maximum limit of pets to summon. [[YELLOW]]({0})
 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.COTW.BreedingDisallowed=[[GREEN]](Call Of The Wild) [[RED]]You cannot breed a summoned animal.
 Taming.Summon.Name.Format=[[GOLD]](COTW) [[WHITE]]{0}'s {1}
 Taming.Summon.Name.Format=[[GOLD]](COTW) [[WHITE]]{0}'s {1}
 #UNARMED
 #UNARMED