2
0
Эх сурвалжийг харах

Tweak a few more things with Salvage.

GJ 12 жил өмнө
parent
commit
7a0f8ea2dd

+ 1 - 1
Changelog.txt

@@ -27,7 +27,7 @@ Version 1.4.00-dev
  + Added methods to check if a player is in party or admin chat to the ChatAPI
  + Added methods to check if a player is in party or admin chat to the ChatAPI
  + Added /mcpurge functionality for Flatfile users
  + Added /mcpurge functionality for Flatfile users
  + Added basic support for Mo' Creatures (and other entity mods) - specify mob info in entities.yml
  + Added basic support for Mo' Creatures (and other entity mods) - specify mob info in entities.yml
- + Added Shears, Buckets, Fishing rods and Bows to the list of items that can be Salvaged
+ + Added Shears, Buckets, Fishing Rods, Flint & Steel, Carrot Sticks, and Bows to the list of items that can be Salvaged
  = Fixed multiple commands not working properly on offline players
  = Fixed multiple commands not working properly on offline players
  = Fixed /mmoedit not giving feedback when modifying another players stats
  = Fixed /mmoedit not giving feedback when modifying another players stats
  = Fixed the guide usage string showing up every time /skillname was called
  = Fixed the guide usage string showing up every time /skillname was called

+ 56 - 27
src/main/java/com/gmail/nossr50/skills/repair/Salvage.java

@@ -37,15 +37,13 @@ public class Salvage {
                 return;
                 return;
             }
             }
 
 
-            final float currentdura = item.getDurability();
-
-            if (currentdura == 0) {
-                final int salvagedAmount = getSalvagedAmount(item);
-                final int itemID = getSalvagedItemID(item);
+            final float currentDurability = item.getDurability();
 
 
+            if (currentDurability == 0) {
                 player.setItemInHand(new ItemStack(Material.AIR));
                 player.setItemInHand(new ItemStack(Material.AIR));
                 location.setY(location.getY() + 1);
                 location.setY(location.getY() + 1);
-                Misc.dropItem(location, new ItemStack(itemID, salvagedAmount));
+
+                Misc.dropItems(location, new ItemStack(getSalvagedItem(item)), getSalvagedAmount(item));
 
 
                 player.playSound(player.getLocation(), Sound.ANVIL_USE, Misc.ANVIL_USE_VOLUME, Misc.ANVIL_USE_PITCH);
                 player.playSound(player.getLocation(), Sound.ANVIL_USE, Misc.ANVIL_USE_VOLUME, Misc.ANVIL_USE_PITCH);
                 player.sendMessage(LocaleLoader.getString("Repair.Skills.SalvageSuccess"));
                 player.sendMessage(LocaleLoader.getString("Repair.Skills.SalvageSuccess"));
@@ -73,7 +71,8 @@ public class Salvage {
                 if (spoutPlayer.isSpoutCraftEnabled()) {
                 if (spoutPlayer.isSpoutCraftEnabled()) {
                     spoutPlayer.sendNotification("[mcMMO] Anvil Placed", "Right click to salvage!", Material.getMaterial(anvilID));
                     spoutPlayer.sendNotification("[mcMMO] Anvil Placed", "Right click to salvage!", Material.getMaterial(anvilID));
                 }
                 }
-            } else {
+            }
+            else {
                 player.sendMessage(LocaleLoader.getString("Repair.Listener.Anvil2"));
                 player.sendMessage(LocaleLoader.getString("Repair.Listener.Anvil2"));
             }
             }
 
 
@@ -82,28 +81,58 @@ public class Salvage {
         }
         }
     }
     }
 
 
-    public static int getSalvagedItemID(final ItemStack inHand) {
-        int salvagedItem = 0;
-        if (ItemChecks.isDiamondTool(inHand) || ItemChecks.isDiamondArmor(inHand)) salvagedItem = 264;
-        else if (ItemChecks.isGoldTool(inHand) || ItemChecks.isGoldArmor(inHand)) salvagedItem = 266;
-        else if (ItemChecks.isIronTool(inHand) || ItemChecks.isIronArmor(inHand) || inHand.getType() == Material.BUCKET) salvagedItem = 265;
-        else if (ItemChecks.isStoneTool(inHand)) salvagedItem = 4;
-        else if (ItemChecks.isWoodTool(inHand)) salvagedItem = 5;
-        else if (ItemChecks.isLeatherArmor(inHand)) salvagedItem = 334;
-        else if (ItemChecks.isStringTool(inHand)) salvagedItem = 287;
-        return salvagedItem;
+    private static Material getSalvagedItem(final ItemStack inHand) {
+        if (ItemChecks.isDiamondTool(inHand) || ItemChecks.isDiamondArmor(inHand)) {
+            return Material.DIAMOND;
+        }
+        else if (ItemChecks.isGoldTool(inHand) || ItemChecks.isGoldArmor(inHand)) {
+            return Material.GOLD_INGOT;
+        }
+        else if (ItemChecks.isIronTool(inHand) || ItemChecks.isIronArmor(inHand)) {
+            return Material.IRON_INGOT;
+        }
+        else if (ItemChecks.isStoneTool(inHand)) {
+            return Material.COBBLESTONE;
+        }
+        else if (ItemChecks.isWoodTool(inHand)) {
+            return Material.WOOD;
+        }
+        else if (ItemChecks.isLeatherArmor(inHand)) {
+            return Material.LEATHER;
+        }
+        else if (ItemChecks.isStringTool(inHand)) {
+            return Material.STRING;
+        }
+        else {
+            return null;
+        }
     }
     }
 
 
-    public static int getSalvagedAmount(final ItemStack inHand) {
-        int salvagedAmount = 0;
-        if (ItemChecks.isPickaxe(inHand) || ItemChecks.isAxe(inHand) || inHand.getType() == Material.BOW || inHand.getType() == Material.BUCKET) salvagedAmount = 3;
-        else if (ItemChecks.isShovel(inHand)) salvagedAmount = 1;
-        else if (ItemChecks.isSword(inHand) || ItemChecks.isHoe(inHand) || inHand.getType() == Material.FISHING_ROD || inHand.getType() == Material.SHEARS) salvagedAmount = 2;
-        else if (ItemChecks.isHelmet(inHand)) salvagedAmount = 5;
-        else if (ItemChecks.isChestplate(inHand)) salvagedAmount = 8;
-        else if (ItemChecks.isPants(inHand)) salvagedAmount = 7;
-        else if (ItemChecks.isBoots(inHand)) salvagedAmount = 4;
-        return salvagedAmount;
+    private static int getSalvagedAmount(final ItemStack inHand) {
+        if (ItemChecks.isPickaxe(inHand) || ItemChecks.isAxe(inHand) || inHand.getType() == Material.BOW || inHand.getType() == Material.BUCKET) {
+            return 3;
+        }
+        else if (ItemChecks.isShovel(inHand) || inHand.getType() == Material.FLINT_AND_STEEL) {
+            return 1;
+        }
+        else if (ItemChecks.isSword(inHand) || ItemChecks.isHoe(inHand) || inHand.getType() == Material.CARROT_STICK || inHand.getType() == Material.FISHING_ROD || inHand.getType() == Material.SHEARS) {
+            return 2;
+        }
+        else if (ItemChecks.isHelmet(inHand)) {
+            return 5;
+        }
+        else if (ItemChecks.isChestplate(inHand)) {
+            return 8;
+        }
+        else if (ItemChecks.isPants(inHand)) {
+            return 7;
+        }
+        else if (ItemChecks.isBoots(inHand)) {
+            return 4;
+        }
+        else {
+            return 0;
+        }
     }
     }
     /**
     /**
      * Checks if the item is salvageable.
      * Checks if the item is salvageable.

+ 3 - 0
src/main/java/com/gmail/nossr50/util/ItemChecks.java

@@ -392,6 +392,7 @@ public class ItemChecks {
     public static boolean isStringTool(ItemStack is) {
     public static boolean isStringTool(ItemStack is) {
         switch (is.getType()) {
         switch (is.getType()) {
         case BOW:
         case BOW:
+        case CARROT_STICK:
         case FISHING_ROD:
         case FISHING_ROD:
             return true;
             return true;
 
 
@@ -429,6 +430,8 @@ public class ItemChecks {
      */
      */
     public static boolean isIronTool(ItemStack is) {
     public static boolean isIronTool(ItemStack is) {
         switch (is.getType()) {
         switch (is.getType()) {
+        case BUCKET:
+        case FLINT_AND_STEEL:
         case IRON_AXE:
         case IRON_AXE:
         case IRON_HOE:
         case IRON_HOE:
         case IRON_PICKAXE:
         case IRON_PICKAXE: