[Req] Repair tools with currency (Smithy)

Discussion in 'Archived: Plugin Requests' started by kalez, Nov 21, 2011.

  1. Offline

    kalez

    I loved the MrFixit plugin http://forums.bukkit.org/threads/me...ls-and-armor-using-a-crafting-grid-953.21453/ , but it seems to have been abandoned. I would greatly appreciate it if someone would either pick it up, or make a new one, but with some changes:

    - The original allowed you to fix your tools anywhere, including in your 2x2 crafting table. This could be an option if someone wanted the old way, otherwise...
    - Option to require that repairs can only be done at a 3x3 crafting table (probably with a sign above it, or a chest + sign? whatever works best)
    - Optional money cost to repair, amount per item defined in config
    - Optional item cost to repair, amount per item defined in config (so could cost money and/or repair items)
    - If the item is enchanted, it keeps its enchantments. Maybe add an option for a % cost increase of an item if it is enchanted.
    - I use BOSEconomy, so please make it use that (if repair costs money option is true) but add whatever other economy plugins you want, or Register
    - Default Op only true/false permissions (include additional permissions if you wish, we dont use permissions)
    - Release to the public if you wish

    Look&feel:
    If sign is used:
    [Repair]
    Right click to
    repair tools
    and armor.

    Chat after right clicking: (if iron sword is in hand)
    Repair Iron Sword cost: 2 iron, $50
    Right click again/type OK to accept charge.

    Anything else you feel should be added feel free, I just loved this plugin and would love to see it brought back to life, or something similar, with these things added. Thanks!
     
  2. Offline

    kalez

    I hope its alright to bump this after 6 days, i would really like this plugin.
     
  3. Offline

    Chugs

    Argh... I was hoping to find an updated mr fixit plugin... i guess you're having the same problems...
     
  4. Offline

    thepig

    I've been trying to recreate this....maybe if you give me some time I can recreate it, but no promises.
     
  5. Offline

    kalez

    Sure! no rush! well, maybe a little rush lol.

    Edit: If you cant please let me know.
     
  6. Offline

    thepig

    Some updates: I got kinda lazy XD, and found the source code, which was....beyond my level of coding. So, I'm currently fixing all the errors there are. I will learn from this coding and others before I can get to your needs, so if an updated version of MrFixit, which I will call MrFixer, the brother of it, will do, I can get you that pretty soon.
     
  7. Offline

    kalez

    that would be great if you can restrict it somehow, at least from the 2x2 crafting table. otherwise we can wait for the full version :). the original MrFixit surprisingly still worked last time we used it. not sure about 1337 though.
     
  8. Offline

    thepig

    I don't know if restricting it from the 2x2 crafting grid would work, because I think that it can't tell the difference between the crafting grid in the player's inventory and a crafting table.

    Unfortunately, I cannot repair the code, if someone else would like to try, here is the source code:
    Code:
    package com.msc.MrFixit;
    
    import java.io.*;
    import java.util.HashMap;
    import java.util.Map;
    import java.util.logging.Level;
    import java.util.logging.Logger;
    import org.bukkit.Material;
    import org.bukkit.Server;
    import org.bukkit.inventory.ItemStack;
    import org.bukkit.inventory.ShapelessRecipe;
    import org.bukkit.material.MaterialData;
    import org.bukkit.plugin.java.JavaPlugin;
    import org.bukkit.util.config.Configuration;
    
    public class MrFixit extends JavaPlugin
    {
    
        public MrFixit()
        {
        }
    
        public static Material getMaterial(String name)
        {
            if(materials == null)
            {
                materials = new HashMap();
                materials.put("flint", Material.FLINT);
                materials.put("string", Material.STRING);
                materials.put("stick", Material.STICK);
                materials.put("leather", Material.LEATHER);
                materials.put("wood", Material.WOOD);
                materials.put("cobblestone", Material.COBBLESTONE);
                materials.put("smoothstone", Material.STONE);
                materials.put("iron", Material.IRON_INGOT);
                materials.put("gold", Material.GOLD_INGOT);
                materials.put("diamond", Material.DIAMOND);
            }
            return (Material)materials.get(name.toLowerCase());
        }
    
        public void onDisable()
        {
        }
    
        public void onEnable()
        {
            server = getServer();
            logger = server.getLogger();
            logger.log(Level.INFO, "[MrFixit] v1.0 now enabled!");
            try
            {
                loadConfig();
            }
            catch(Exception e)
            {
                logger.log(Level.SEVERE, (new StringBuilder("[MrFixit] Setup failed. ")).append(nRecipes != 0 ? ((Object) (Integer.valueOf(nRecipes))) : "No").append(" recipe").append(nRecipes != 1 ? "s " : " ").append(" added.").toString());
            }
        }
    
        private void loadConfig()
        {
            config = openConfigFile(new File(getDataFolder(), "config.yml"));
            int l1 = tTypes.length;
            int l2 = tools.length;
            for(int j = 0; j < l2; j++)
            {
                Material mL[] = tMaterials[j];
                String s1 = tools[j];
                for(int i = 0; i < l1; i++)
                    loadRecipe((new StringBuilder(String.valueOf(tTypes[i]))).append(s1).toString(), mL[i]);
    
            }
    
            l1 = aTypes.length;
            l2 = armor.length;
            for(int j = 0; j < l2; j++)
            {
                Material mL[] = aMaterials[j];
                String s1 = armor[j];
                for(int i = 0; i < l1; i++)
                    loadRecipe((new StringBuilder(String.valueOf(aTypes[i]))).append(s1).toString(), mL[i]);
    
            }
    
            loadRecipe("flintandsteel", Material.FLINT_AND_STEEL);
            loadRecipe("fishingrod", Material.FISHING_ROD);
            logger.log(Level.INFO, (new StringBuilder("[MrFixit] Added ")).append(nRecipes).append(" recipe").append(nRecipes != 1 ? "s." : ".").toString());
        }
    
        private void loadRecipe(String node, Material t)
        {
            String ss = config.getString(node);
            String rs[];
            Material m;
            int n;
            if(ss != null && (rs = ss.split(" ")) != null && rs.length == 2 && (m = getMaterial(rs[0])) != null && (n = Integer.valueOf(rs[1]).intValue()) > 0)
            {
                ShapelessRecipe recipe = new ShapelessRecipe(new ItemStack(t, 1, (short)0, Byte.valueOf((byte)0)));
                recipe.addIngredient(n, m);
                recipe.addIngredient(new MaterialData(t, (byte)-1));
                server.addRecipe(recipe);
                nRecipes++;
            }
        }
    
        private Configuration openConfigFile(File f)
        {
            Configuration cfg;
            InputStream istr;
            OutputStream ostr;
            cfg = new Configuration(f);
            if(f.exists())
                break MISSING_BLOCK_LABEL_295;
            f.getParentFile().mkdirs();
            istr = null;
            ostr = null;
            Configuration configuration;
            istr = com/msc/MrFixit/MrFixit.getResourceAsStream("/config.yml");
            if(istr != null)
                break MISSING_BLOCK_LABEL_97;
            logger.log(Level.WARNING, "[MrFixit] Can't load default configuration from JAR. Configuration file not created.");
            configuration = cfg;
            try
            {
                if(istr != null)
                    istr.close();
                if(ostr != null)
                    ostr.close();
            }
            catch(Exception e)
            {
                logger.log(Level.SEVERE, "[MrFixit] Attempt to create configuration file failed horribly.");
                return cfg;
            }
            return configuration;
            try
            {
                ostr = new FileOutputStream(f);
                byte buf[] = new byte[1024];
                int len;
                while((len = istr.read(buf)) > 0)
                    ostr.write(buf, 0, len);
                logger.log(Level.INFO, "[MrFixit] Created default configuration file.");
                cfg.load();
                break MISSING_BLOCK_LABEL_251;
            }
            catch(Exception e)
            {
                logger.log(Level.WARNING, "[MrFixit] Attempt to create configuration file failed.");
            }
            try
            {
                if(istr != null)
                    istr.close();
                if(ostr != null)
                    ostr.close();
            }
            catch(Exception e)
            {
                logger.log(Level.SEVERE, "[MrFixit] Attempt to create configuration file failed horribly.");
                return cfg;
            }
            break MISSING_BLOCK_LABEL_288;
            Exception exception;
            exception;
            try
            {
                if(istr != null)
                    istr.close();
                if(ostr != null)
                    ostr.close();
            }
            catch(Exception e)
            {
                logger.log(Level.SEVERE, "[MrFixit] Attempt to create configuration file failed horribly.");
                return cfg;
            }
            throw exception;
            try
            {
                if(istr != null)
                    istr.close();
                if(ostr != null)
                    ostr.close();
            }
            catch(Exception e)
            {
                logger.log(Level.SEVERE, "[MrFixit] Attempt to create configuration file failed horribly.");
                return cfg;
            }
            cfg.load();
            break MISSING_BLOCK_LABEL_311;
            cfg.load();
            logger.log(Level.INFO, "[MrFixit] Loaded configuration file.");
            return cfg;
        }
    
        static Map materials;
        static Server server;
        static Configuration config;
        static Logger logger;
        static int nRecipes = 0;
        public static final String tTypes[] = {
            "wooden", "stone", "iron", "gold", "diamond"
        };
        public static final String tools[] = {
            "sword", "shovel", "pickaxe", "axe", "hoe"
        };
        public static final Material tMaterials[][];
        public static final String aTypes[] = {
            "leather", "chainmail", "iron", "gold", "diamond"
        };
        public static final String armor[] = {
            "helmet", "chestplate", "leggings", "boots"
        };
        public static final Material aMaterials[][];
    
        static
        {
            tMaterials = (new Material[][] {
                new Material[] {
                    Material.WOOD_SWORD, Material.STONE_SWORD, Material.IRON_SWORD, Material.GOLD_SWORD, Material.DIAMOND_SWORD
                }, new Material[] {
                    Material.WOOD_SPADE, Material.STONE_SPADE, Material.IRON_SPADE, Material.GOLD_SPADE, Material.DIAMOND_SPADE
                }, new Material[] {
                    Material.WOOD_PICKAXE, Material.STONE_PICKAXE, Material.IRON_PICKAXE, Material.GOLD_PICKAXE, Material.DIAMOND_PICKAXE
                }, new Material[] {
                    Material.WOOD_AXE, Material.STONE_AXE, Material.IRON_AXE, Material.GOLD_AXE, Material.DIAMOND_AXE
                }, new Material[] {
                    Material.WOOD_HOE, Material.STONE_HOE, Material.IRON_HOE, Material.GOLD_HOE, Material.DIAMOND_HOE
                }
            });
            aMaterials = (new Material[][] {
                new Material[] {
                    Material.LEATHER_HELMET, Material.CHAINMAIL_HELMET, Material.IRON_HELMET, Material.GOLD_HELMET, Material.DIAMOND_HELMET
                }, new Material[] {
                    Material.LEATHER_CHESTPLATE, Material.CHAINMAIL_CHESTPLATE, Material.IRON_CHESTPLATE, Material.GOLD_CHESTPLATE, Material.DIAMOND_CHESTPLATE
                }, new Material[] {
                    Material.LEATHER_LEGGINGS, Material.CHAINMAIL_LEGGINGS, Material.IRON_LEGGINGS, Material.GOLD_LEGGINGS, Material.DIAMOND_LEGGINGS
                }, new Material[] {
                    Material.LEATHER_BOOTS, Material.CHAINMAIL_BOOTS, Material.IRON_BOOTS, Material.GOLD_BOOTS, Material.DIAMOND_BOOTS
                }
            });
        }
    }
    
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 21, 2016
  9. Offline

    kalez

    Awe, thanks for trying though! And you may want to put that in code tags :p

    Anyone, please, i would really like to have this!
     
  10. Offline

    thepig

    Does it work on build 1337?
     
  11. Offline

    Jessica1988

    I'm a newbie here too...[​IMG]
     
  12. Offline

    kalez

    You mean the original MrFixit?
     
  13. Offline

    thepig

  14. Offline

    kalez

    Seems to, I just tried it on our server and saw no errors.
     
  15. Offline

    thepig

    So....Do you have any ideas for a plugin? I don't have any ._.
     
  16. Offline

    kalez

  17. Offline

    Chugs

    Awww.. was a shame he couldn't get this up im very glad he tried tho
     
  18. Offline

    -_Husky_-

    Might TRY make one.. dont know about money tho, will items be fine? I was thinking gold ingot + command = repaired.
     
  19. Offline

    kalez

    No, that's what I'm trying to avoid. Ones exactly like that already exists, and the main purpose of this is to make it require money at a specific location, via chest, sign, and/or crafting table. No commands needed. Sorry, but that would be the opposite of what we want. Thanks anyway.
     
  20. Offline

    -_Husky_-

    ok.
     
  21. Offline

    kalez

    Still need this if anyone can make it please!
     
  22. @kalez . Will look into this tonight. If I get it right (simple first version with only a sign because table's are hard to do without client mod):
    • A sign with the text [Repair]
    • Right click the sign to get cost
    • Right click again to repair and substract money/items
    Is this what you want?

    Edit: Doesn't this already excists?!
     
  23. Offline

    kalez

    Not that i know of. If you find one like it, great! The only one i found uses gold ingots, which imo, is dumb.

    But, yes, that will suffice nicely! Or have them type "OK" to accept the repair cost, or whatever you think works best =b Here is what i imagine for that method:
    Sign:
    [Repair]
    Right click to
    repair tools
    and armor.

    Chat: (if iron sword is in hand)
    Repair Iron Sword cost: 2 iron, $50
    Right click again/type ok to accept charge.

    As much configuration as possible is nice (including text and such), but the only things i require to be configurable are are:
    - default Op only true/false (we dont use permissions, but add them as an option for others if you want)
    - per tool item and/or $ cost for repair

    and typing something or walking away should cancel the transaction.
     
  24. Sorry. Couldn't get to it yesterday. But will take my time this weekend for this!
     
  25. Offline

    kalez

    np! were still messing around on a temporary world while we wait for bukkit's 1.0 version anyway.

    Edit: any updates? just curious
     
  26. Offline

    retsrif

    Try my plugin Blacksmith, haven't updated it in a while, but one user has and has posted it on my thread (check my sig).
     
  27. Offline

    kalez

    If it still works, that will be nice substitue for now. Only reason i hadnt used yours was because it was outdated. Ill check it out, but would still like this made if anyone can.
    Thanks for the info retsrif =b
     
  28. Offline

    retsrif

    No problem :)
     
  29. @kalez I'm very sorry. I was too busy with my other plugin TotalQuest this weekend. Your request shouldn't take more than an evening to make but I need to get some free time for it. I won't make any promisses again as I would only disappoint you. Will keep this topic in mind and when I find the time I will be working on it!
     
  30. Offline

    kalez

    dont worry about it! though as soon as you can would be great. as you know bukkit just updated and now we are starting our new world :p obviously this isnt a necessary plugin, but its one we really want.
     

Share This Page