Bläddra i källkod

More Spout tool stuff.

GJ 13 år sedan
förälder
incheckning
7ada587df3

+ 1 - 1
Changelog.txt

@@ -10,7 +10,7 @@ Key:
 Version 1.3.09
  + Added compatibility with AntiCheat (Which I highly recommend to prevent cheating)
  + Added several permission nodes to give individual users special perks (Double/Triple/Quadruple XP)
- + Added API for plugins to add custom tools directly via Spout
+ + Added API for plugins to add custom tools directly via Spout - repair / abilities do not work ATM
  = Fixed issue with NoCheatPlus and Serrated Strikes / Skull Splitter (fight.noswing)
  = Fixed bug where you could receive Archery XP from Potions
  = Fixed bug with duping blocks via piston pushing

+ 34 - 4
src/main/java/com/gmail/nossr50/api/SpoutToolsAPI.java

@@ -5,17 +5,47 @@ import java.util.List;
 
 import org.bukkit.inventory.ItemStack;
 
+import com.gmail.nossr50.datatypes.ToolType;
+
 public class SpoutToolsAPI {
     public static List<ItemStack> spoutSwords = new ArrayList<ItemStack>();
+    public static List<ItemStack> spoutAxes = new ArrayList<ItemStack>();
+    public static List<ItemStack> spoutPickaxes = new ArrayList<ItemStack>();
+    public static List<ItemStack> spoutHoes = new ArrayList<ItemStack>();
+    public static List<ItemStack> spoutShovels = new ArrayList<ItemStack>();
 
     /**
-     * Add a custom Spout sword to mcMMO for XP gain & ability use.
+     * Add a custom Spout tool to mcMMO for XP gain & ability use.
      * </br>
      * This function is designed for API usage.
      *
-     * @param spoutSword The sword to add
+     * @param spoutTool The tool to add
+     * @param type The type of tool to add
      */
-    public void addCustomSword(ItemStack spoutSword) {
-        spoutSwords.add(spoutSword);
+    public void addCustomTool(ItemStack spoutTool, ToolType type) {
+        switch (type) {
+        case AXE:
+            spoutAxes.add(spoutTool);
+            break;
+
+        case HOE:
+            spoutHoes.add(spoutTool);
+            break;
+
+        case PICKAXE:
+            spoutPickaxes.add(spoutTool);
+            break;
+
+        case SHOVEL:
+            spoutShovels.add(spoutTool);
+            break;
+
+        case SWORD:
+            spoutSwords.add(spoutTool);
+            break;
+
+        default:
+            break;
+        }
     }
 }

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

@@ -60,6 +60,9 @@ public class ItemChecks {
             if (customToolsEnabled && CustomToolsConfig.getInstance().customHoeIDs.contains(is.getTypeId())) {
                 return true;
             }
+            else if (mcMMO.p.spoutEnabled && SpoutToolsAPI.spoutHoes.contains(is)) {
+                return true;
+            }
             else {
                 return false;
             }
@@ -85,6 +88,9 @@ public class ItemChecks {
             if (customToolsEnabled && CustomToolsConfig.getInstance().customShovelIDs.contains(is.getTypeId())) {
                 return true;
             }
+            else if (mcMMO.p.spoutEnabled && SpoutToolsAPI.spoutShovels.contains(is)) {
+                return true;
+            }
             else {
                 return false;
             }
@@ -110,6 +116,9 @@ public class ItemChecks {
             if (customToolsEnabled && CustomToolsConfig.getInstance().customAxeIDs.contains(is.getTypeId())) {
                 return true;
             }
+            else if (mcMMO.p.spoutEnabled && SpoutToolsAPI.spoutAxes.contains(is)) {
+                return true;
+            }
             else {
                 return false;
             }
@@ -135,6 +144,9 @@ public class ItemChecks {
             if (customToolsEnabled && CustomToolsConfig.getInstance().customPickaxeIDs.contains(is.getTypeId())) {
                 return true;
             }
+            else if (mcMMO.p.spoutEnabled && SpoutToolsAPI.spoutPickaxes.contains(is)) {
+                return true;
+            }
             else {
                 return false;
             }