drop item

Discussion in 'Plugin Development' started by Moon_werewolf, Jan 31, 2011.

Thread Status:
Not open for further replies.
  1. Offline

    Moon_werewolf

    how do i make a item drop in front of a players feet?
     
  2. Offline

    xpansive

    ItemStack item = whatever item you want
    world.dropItem(player.getLocation(), item);
     
    MarinD99, StefanXX and com. BOY like this.
  3. Offline

    xDUBSTEPx

    Please help this ant working
    Code:
    ItemStack item = COOKIE
    world.dropItem(player.getLocation(), item);
     
  4. Offline

    Jogy34

    @xDUBSTEPx I believe it would be
    Code:
    ItemStack item = Material.COOKIE;
     
  5. Offline

    DeadlyScone


    Code:
    ItemStack drop = new ItemStack(block.getType());
                    drop.setAmount(1);
                    drop.setType(Material.FIRE);
    
    world.dropItem("put LOCATION here", drop);
    basicaly this will drop 1 of the block FIRE at the specified location.
    you can also change ItemStack(block.getType()); to ItemStack(block.getID());
    if you want to use the data value of the block
    ie: 50 || TORCH
     
  6. Offline

    xDUBSTEPx

    Cool but the only location i want is any were in front of u
    and i have 2 errors world and block
     
  7. Offline

    Kaikz

    I HIGHLY suggest you go and learn Java, before attempting Bukkit plugins. You've obviously proven that you don't know what you're doing.
     
  8. Offline

    DeadlyScone

    dude, come on learn a bit of java. obviously block and world is a variable. you have to take the code i provided you and make it fit your situation, i cant spoon feed you unless you honestly want me to... which is... ya...

    Block block;
    World world;

    can you take a look at my problem iam having? it seems nobody wants too :'(

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

    xDUBSTEPx

    No i see don't spood feed me ill find some way around nvm
     
  10. Offline

    DeadlyScone

    but i suppose you will never learn if you never see how it works.
    what event are you trying to call this on?
     
  11. Offline

    xDUBSTEPx

    well you type /egg and u drop an egg
    so you can be like a chicken
     
  12. Offline

    Kaikz

    Code:
    ItemStack drop = new ItemStack(Material.EGG, 1);
    World world = player.getWorld();
    
    world.dropItem(player.getLocation()), drop);
    world.spawnCreature(player.getLocation(), CreatureType.CHICKEN);
    
    Now go learn Java.
     
    com. BOY and DancingCactus like this.
  13. Offline

    DeadlyScone

    well i'am not a big know it all on commands.. but to save me time go look at plugins that use commands that drop items. if their source is not available then download a program call jd-gui, once done download the plugin then open it in jd-gui and look at the commands. best way to learn. :)
     
  14. Offline

    xDUBSTEPx

    THATS!!! what i use jd-gui to see whats inside plugins i tryed that but know one had any plugins that droped stuff in front of you

    Just Checking last thing would this work
    Code:
    ItemStack drop = new ItemStack(Material.EGG, 1);
                            World world = ((Entity) player).getWorld();
    
                            world.dropItem(((Entity) player).getLocation(), drop);
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 8, 2016
  15. Offline

    Kaikz

    Why are you casting player to Entity? Get player from event.getPlayer() or the CommandSender.
     
    com. BOY likes this.
  16. Offline

    xDUBSTEPx

    i have lots of errors when i run the server ill show you my code
    Code:
    public boolean onCommand(CommandSender sender, Command cmd, String command, String[] args) {
    
            if (command.equalsIgnoreCase("egg") && args.length == 1) {
                        Player Egg = getServer().getPlayer(args[0]);
                        if (egg != null) {
                            ItemStack drop = new ItemStack(Material.EGG, 1);
                            World world =  player).getWorld();
    
                            world.dropItem player).getLocation(), drop);
                        }
                            sender.sendMessage(ChatColor.GRAY + "Egg");
     
  17. Offline

    Kaikz

    Change egg to Egg.
    Change player) to Egg.
    Change player) to Egg.
    Change sender to (Player) sender. You may need to do checks to see if the CommandSender is console or not.
     
    Limeth likes this.
  18. Offline

    xDUBSTEPx

    That Gave Me More Errors :'(
    Most Of Them Look Like This
    Syntax error on token "dropItem", ( expected after this token
    wait no thats now the only error
     
  19. Offline

    Kaikz

    Because you haven't got brackets in the right place.

    I'm trying not to throw myself out the window right now. You seriously need to learn the basics of Java before even attempting a plugin.
     
  20. Offline

    xDUBSTEPx

    Well iv added everything and when i type /egg nothing happens like it says theres no errors with the command please help
     
  21. Offline

    Kaikz

  22. Offline

    xDUBSTEPx

    :'( nvm @Kaikz your from NewZealand and so am i
     
  23. Offline

    DeadlyScone

    lol, woooshhhhhh........
     
  24. Offline

    xDUBSTEPx

    Oh yeah theres nothing on the page about how to drop an egg :confused:
     
  25. Offline

    Kaikz

    They're not Bukkit tutorials, they're Java tutorials. You don't even know what Java is and what you're trying to do...
     
    ChipDev, com. BOY, MuttsNuts and 3 others like this.
  26. Offline

    xDUBSTEPx

    Nvm btw you really dont care about others trying to make plugins you think of your self to much i really think that the happy cat as you pic on your profile does not suit your personalty and you can laugh at this as much as you want but i find it hard to understand java tuts this is as far as i have ever gotten at being good at something sure your not here to show me how to learn java but have some respect that i want to try to make a plugin i will try as hard as i can to learn java and one day i might be able to help people like me who struggle to make plugins and your right i need to Help myself are you going to read this no are you going to care No your not im just another blank person in the corner of your screen :(
     
  27. Offline

    Kaikz

    No, that's not the case at all. I tried to help you, but you showed a lack of basic understanding of the Java syntax. You cannot, ever, code something without knowing the basic syntax. I referred you to a very, very simple Java tutorial series and obviously didn't get the message (I made my first plugin within hours of watching said series).

    This isn't a forum dedicated to learn Java, this is a forum for learning to code plugins USING Java. Any other developer here will definitely tell you that you need to know the basics.
     
    ChipDev, com. BOY, rtainc and 7 others like this.
  28. Offline

    xDUBSTEPx

    I fixed that mistake before you told me i was stupid you act like i have never made a plugin before i have made one plugin that /help and it bring up a basic help message and i was so happy when i posted that but it didn't get accepted i dont want to give up now. im sorry but is it hard for you to understand that i may not know much about java but i managed to start a small plugin by my self. i came here to see if anyone was kind enough to lend me the code that drops an egg in front of you the code you gave me was false because it did nothing
    there were 3 different types of code that people gave me they may be for a different reason nothing is easy coming to this page to find information i need and i get accused of not knowing java before i can do anything people join in and i get ganged up on this is happened so many times before i need to stop doing this sorry for offending you on not knowing java
     
  29. Offline

    Jogy34

    Honestly if what Kaikz is saying is true and you don't actually know much of how to program in java then you really need to learn. Once you learn more then go back to your code and you should easily be able to understand the errors that you are given unless it is an error with the bukkit methods. If you do know java then sorry but you seem like you are being naive to your mistakes.
     
  30. Offline

    mindless728

    its not that you are offending us, its we can't really help you if you don't know the language you are programming in, we tell this time and time again to people looking to develop plugins that they need to have a good knowledge of java before starting
     
Thread Status:
Not open for further replies.

Share This Page