Explorar o código

Changed Fishing to always give a fish on a successful catch

bm01 %!s(int64=12) %!d(string=hai) anos
pai
achega
188ad359fe
Modificáronse 2 ficheiros con 17 adicións e 13 borrados
  1. 4 0
      Changelog.txt
  2. 13 13
      src/main/java/com/gmail/nossr50/skills/fishing/Fishing.java

+ 4 - 0
Changelog.txt

@@ -25,9 +25,13 @@ Version 1.4.00-dev
  = Fixed Leaf Blower not respecting the unlock level set in advanced.yml
  = Fixed abilities activating with the wrong tool in hand
  = Fixed Experience.Gains.Mobspawners.Enabled not being used correctly (the check was inverted)
+<<<<<<< Upstream, based on origin/master
  = Fixed bug where Iron Grip was using the attacker's skill values rather than the defender's.
  = Fixed a bug where /party kick would trigger the PartyChangeEvent for the wrong player
  = Fixed a bug where party join messages weren't displayed
+=======
+ ! A Fishing catch will now always contains a fish even if a treasure is found
+>>>>>>> 1f7a94a Changed Fishing to always give a fish on a successful catch
  ! Changed how Berserk handles not picking up items to avoid listening to PlayerPickupItemEvent
  ! Moved Hylian Luck into a separate listener since it actually cancels the event and shouldn't just be on MONITOR.
  ! Changed how Tree Feller is handled, it should now put less stress on the CPU

+ 13 - 13
src/main/java/com/gmail/nossr50/skills/fishing/Fishing.java

@@ -116,27 +116,27 @@ public class Fishing {
                 }
             }
 
-            if (rewards.size() <= 0) {
+            if (rewards.isEmpty()) {
                 return;
             }
 
-            FishingTreasure foundTreasure = rewards.get(Misc.getRandom().nextInt(rewards.size()));
+            FishingTreasure treasure = rewards.get(Misc.getRandom().nextInt(rewards.size()));
+            ItemStack treasureDrop = treasure.getDrop();
 
             int activationChance = Misc.calculateActivationChance(Permissions.luckyFishing(player));
 
-            if (Misc.getRandom().nextDouble() * activationChance <= foundTreasure.getDropChance()) {
-                Users.getPlayer(player).addXP(SkillType.FISHING, foundTreasure.getXp());
-                theCatch.setItemStack(foundTreasure.getDrop());
-            }
-        }
-        else {
-            theCatch.setItemStack(new ItemStack(Material.RAW_FISH));
-        }
+            if (Misc.getRandom().nextDouble() * activationChance <= treasure.getDropChance()) {
+                player.getWorld().dropItem(player.getEyeLocation(), theCatch.getItemStack());  // Drop the original item
 
-        short maxDurability = theCatch.getItemStack().getType().getMaxDurability();
+                short maxDurability = treasureDrop.getType().getMaxDurability();
 
-        if (maxDurability > 0) {
-            theCatch.getItemStack().setDurability((short) (Misc.getRandom().nextInt(maxDurability))); // Change durability to random value
+                if (maxDurability > 0) {
+                    treasureDrop.setDurability((short) (Misc.getRandom().nextInt(maxDurability))); // Change durability to random value
+                }
+
+                theCatch.setItemStack(treasureDrop);
+                Users.getPlayer(player).addXP(SkillType.FISHING, treasure.getXp());
+            }
         }
 
         Skills.xpProcessing(player, profile, SkillType.FISHING, Config.getInstance().getFishingBaseXP());