Very easy plugin

Discussion in 'Archived: Plugin Requests' started by sajagrules, Dec 1, 2012.

  1. Offline

    sajagrules

    Hello, my name is Sajag. I need a very easy plugin that will only take 2 seconds to make.

    What it will do:
    1. You hold item in hand- any item. For example 1 diamond.
    2. You type /fix.
    3. It will delete the item in your hand and respawn it in inventory.
    If you typed /fix and you had one diamond in your hand it will respawn only one diamond. If you type /fix and there is a stack of 2 diamonds. Then it will spawn back 2 diamonds in your inventory.
    Why? Well, I am using a shop plugin I found that uses vault, but whenever someone buys with it- the item comes into their inventory, but they cant use it for crafting or anything, even if they transfer it to another player. I bought 1 coal and made some sticks out of some wood I cut- it wouldn't work. So, i just need a plugin that respawns the item, because then the item works with crafting.
    Perms- no perms needed!
    Please help me! It's very easy!
    If you want to talk to me, my server IP is: play.mc.sajagworld.com
     
  2. Offline

    Staartvin

    You should contact the owner of the plugin you're using about this bug.
     
  3. Offline

    Latzafs


    Erm. I could make this, but wouldn't you rather have a shop plugin that works?
     
    chasechocolate and Codex Arcanum like this.
  4. Offline

    sajagrules

    Please do. I will make you a coder on my server- play.mc.sajagworld.com once you are done. Yes, i would rather have that, but its a Vault bug and I am looking into it right now, but for the time being- can you please make this! It would be great! Just one simple command /fix and it would remove the item in your hand and respawn the same amount into your inventory.

    I will try doing that, but I think its a vault bug so I will file a ticket with them.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 30, 2016
  5. Offline

    Latzafs

    Yay. Bribery, a coder on some server for such a simple task. I'll start on it right now, should be done in 3o minutes if something else doesn't disrupt me.

    I have it done, but I just checked it out, and I can't even get my server to run. Great. T_T I'm a bit worried of what errors your server gets however when you try to get an item to be able to craft. Can you give me any erros for the server if you have any?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 30, 2016
  6. Offline

    KeybordPiano459

  7. Offline

    RashoodKrisb

  8. Offline

    sajagrules

    I don't usually get any errors except I get a java exception that says PlayerMoveEvent for the EpicSurvival plugin which started after I installed the SkyBlock Trading Plugin. Otherwise, I have not had any errors in my console. I run a variety of plugins, but the last time I posted them, someone copied my entire server and got all the credit and people thought I copied of them not visa versa, so not happening again, but if you want, I can PM you a list.
     
  9. Offline

    sajagrules

    I got the code for the plugin, except I am not very good with editing java. Please, someone, help me program this plugin, I need it urgently. Here is the code, I believe, to make the plugin.

    public class ItemRespawn extends JavaPlugin{

    public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args){
    if(cmd.getName().equalsIgnoreCase("fix")){
    if(sender instanceof Player){
    Player p = (Player)sender;
    ItemStack is = p.getItemInHand();
    p.getItemInHand().setType(Material.AIR);
    p.getInventory.addItem(is);
    }
    }
    }


    }
     
  10. Offline

    eccentric_nz

    Try this: https://dl.dropbox.com/u/53758864/ItemResapwnFix-1.0.jar
    It's not perfect, as sometimes the items bounce back to the slot they were taken from...

    Here's the code
    Code:
    public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
            if (cmd.getName().equalsIgnoreCase("fix")) {
                if (sender instanceof Player) {
                    Player p = (Player) sender;
                    ItemStack is = p.getItemInHand();
                    Inventory inv = p.getInventory();
                    int empty = inv.firstEmpty();
                    if (empty < 0) {
                        sender.sendMessage("[ItemRespawnFix] You must have an empty inventory slot!");
                        return false;
                    }
                    p.getInventory().setItemInHand(new ItemStack(Material.AIR));
                    inv.setItem(empty, is);
                    p.updateInventory();
                    return true;
                }
            }
            return false;
        }
     
  11. Offline

    Tirelessly

    Why would the inventory need to be empty if you're freeing a slot...
     
  12. Offline

    eccentric_nz

    Because when I didn't the item doesn't disappear from the player's hand
     
  13. Offline

    sajagrules

    When I tried it, it didn't work. It just moved the item to the next free slot. I need it to delete the old item and spawn the same item back. I found this code- will it work? I am not sure. You most likely will have to edit it and add some stuff like p.updateInventory();.

    Code:
    [INDENT][FONT=Georgia][I][FONT=Consolas]public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args){
    if(cmd.getName().equalsIgnoreCase("fix")){
    if(sender instanceof Player){
    Player p = (Player)sender;
    ItemStack is = p.getItemInHand();
    p.getItemInHand().setType(Material.AIR);
    p.getInventory.addItem(is);
    }
    }
    }
    
    
    }
    [/FONT][/I][/FONT][/INDENT]
     
  14. Offline

    Latzafs

    Erm...
    for a easy plugin this is awfully difficult.
    Eccentric had it basically alright, but all he needed to do is:
    Code:
    Itemstack is = new Itemstack();
    is=... (Normal)
    Block block=is[0].getTypeId
    is."Code for deleting the object"
    p.getInventory.......block
    Notice, this isn't the exact coding, but that's all that has to be changed.
     
  15. Offline

    sajagrules

    Also, I need the plugin not to repair tools and armor so that they can't get free repairs. Please join the server at play.mc.sajagworld.com or reply to this thread. We really need this plugin ASAP. It has already been 2 weeks.

    Thanks,
    Sajag

    **The Coder position on the server is still open**
     
  16. Offline

    Latzafs

    Can't test it currently, so I can only offer code that MAY work.
     
  17. Offline

    fredghostkyle1

    lolz code.

    release it and i will test it :D... if i see it come out :p
     

Share This Page