How to make random loot chests appear?

Discussion in 'Plugin Development' started by finyxt, Apr 11, 2013.

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

    finyxt

    Sorry for asking this... I'm very, very, very new to Java and Plugin Developement, but I want to make a RPG server and I can't find the right plugins.
    I want to make a plugin that makes like chests appear in chunks - like 2 chests/chunk - in the areas I define with WorldGuard or something like that. These chests contain predefined loot, which I define using another chest (or in a config file, but I don't know how to get custom items in the config) and those chests to be level sorted, and one-time use (sorta like Dungeon Realms). After you get those items, the chest will disapear. And by "level sorted" I mean like in the Plains of Minecraftia (name of the starter area) there should be a 12 - 15 DMG weapons. And in the advanced zone, 50 - 100 DMG weapons.
    Can somebody who knows Java, and Plugin Developement in Bukkit, help me... Or anybody. Help and tips are very much appreciated. And when I release the server, I'll make everybody who responded to this topic a "Developer", be sure to include your IGN.
    Thank You!
     
  2. Offline

    Nitnelave

    This is something WAAAAY too big for a first plugin. Start by making a few very simple plugins, like displaying "Hello World" when the player logs in, or a custom message loaded from the config, or spawn a random chest in front of the player when he logs in... You will learn a lot.

    When you feel you are ready to take on the bigger problem, come back with more specific questions like "How to load items from the config?"
     
  3. Offline

    macguy8

    finyxt
    I agree with what Nitnelave says that it's a starter plugin, but I'll write some pseudo code so you know what to do when you learn enough about coding to make this.

    For it to happen in every chunk:
    Every X seconds, loop through all the chunks out there.
    Check to see if the chunk already contains2 full loot chests.
    In each chunk, make 2 random numbers from 0 - 16.
    Set that block in that chunk to the chest type.
    Cast the chest's block state you just created above into an InventoryHolder.
    Randomly fill up that loot chest. Maybe items[r.nextInt(items.length)];
    To destroy chests when they're looted:
    Listen for inventory click event:
    Check if the inventory of the clicked chest is empty.
    If it is, destroy the chest. (b.setTypeId(0))
     
  4. Offline

    finyxt

    Thanks guys! Now... As both of you said... I need to learn more java.
    macguy8 I'll note that pseudo-code and return to it when i'm ready. :(

    Thanks!
     
  5. Offline

    LucasEmanuel

    I have what i call a "ChestManager" which i use where i need chests to be randomized. It is mostly written as a separate module which means you could pretty much copy and paste the entire java file with minimal alteration and use it straight away.

    It randomizes a given chest based on items in a configuration file. The chance of an item spawning is based on the "weight" defined to the item in the config. The heavier the item, the more often it spawns. Items will also be randomly enchanted if possible based on a list of enchantments in the config.

    You can use it in your plugin or just look at the code for inspiration if you want. :)
    https://github.com/Chilinot/Surviva...valgamesmultiverse/managers/ChestManager.java
     
  6. Offline

    finyxt

  7. Offline

    LucasEmanuel

    Just PM me if you want help understanding it :)
     
Thread Status:
Not open for further replies.

Share This Page