Configurable config.yml

Discussion in 'Plugin Development' started by EpicCraft21, Jan 14, 2015.

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

    EpicCraft21

    Hi, i'm trying to make a plugin which converts obsidian to lava. But now, I can't seem to figure out how to use the config.yml. Basically, what I'm trying to do is this:
    Admin goes into config.yml and changes some random variable or whatnot to (for example)6.
    Player makes obsidian, so he gets lava.
    Player repeats 6 times a s shown above.
    Player fails again, and therefore cannot change obsidian back to lava again.

    Code:
    Show Spoiler

    Code:
    package me.epiccraft21.core;
    
    import org.bukkit.Material;
    import org.bukkit.block.Block;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.block.Action;
    import org.bukkit.event.player.PlayerInteractEvent;
    import org.bukkit.inventory.ItemStack;
    import org.bukkit.plugin.java.JavaPlugin;
    
    public class Main extends JavaPlugin implements Listener{
       
        @EventHandler
          public void onClickBlock(PlayerInteractEvent e) {
              Player p = e.getPlayer();
              if (p.getItemInHand().getType().equals(Material.BUCKET)) {
              if (e.getAction().equals(Action.RIGHT_CLICK_BLOCK)) {
                  Block b = e.getClickedBlock();
                  if (b.getType().equals(Material.OBSIDIAN)) {
                      if (p.getItemInHand().getAmount() > 1) {
                          p.getItemInHand().setAmount(p.getItemInHand().getAmount() -1);
                          p.getInventory().addItem(new ItemStack(Material.LAVA_BUCKET));
                          b.setType(Material.AIR);
                      } else {
                          p.getInventory().remove(p.getItemInHand());
                          p.getInventory().addItem(new ItemStack(Material.LAVA_BUCKET));
                          b.setType(Material.AIR);
                      }
                  }
              }
          }
       }
    }
    


    Help is appreciated! :D
    BTW: I also don't know how to make or use the config.yml, this is my first time doing so.
     
  2. Offline

    Lolmewn

    Have you tried reading the tutorial on the wiki?
     
  3. Offline

    mythbusterma

  4. Offline

    EpicCraft21

    Yes, I read over it but I can't seem to find what i'm looking for.
     
  5. Offline

    nverdier

  6. Offline

    EpicCraft21

    Basically how to make a config.yml, how to get the server owner to be able to change the data, and using that data to set a limit.
     
  7. Offline

    Konato_K

  8. Offline

    EpicCraft21

  9. Offline

    Konato_K

  10. Offline

    EpicCraft21

    I did, I'm asking what chapter I'm supposed to read, as I don't understand anything because I never used or seen a config.yml before.
     
  11. Offline

    Konato_K

    @EpicCraft21 Read everything, if you don't understand that then you should learn java before.
     
  12. Offline

    EpicCraft21

    Ok.
    I know java, just not config.yml itself.
     
  13. Offline

    mythbusterma

    @EpicCraft21

    Then that page explains everything you need to know about it.
     
  14. Offline

    teej107

    The config api reference won't show you how to do that ^^^ but it can show you how to get values from the config. Also the Bukkit documentation can show you how to get values from the config as well. http://jd.bukkit.org/rb/apidocs/org/bukkit/configuration/MemorySection.html
     
Thread Status:
Not open for further replies.

Share This Page