Assistance with getting config path

Discussion in 'Plugin Development' started by JjStAr992_Gaming, Oct 15, 2014.

Thread Status:
Not open for further replies.
  1. Ok, that last post was a mess. Let's try again.

    Old post = [creeper]'d

    Hey guys,

    I'm developing a plugin where I need to access some information in a strange way.

    Say for example I had a sign that read:
    Line 1: [SellAll]
    Line 2: A
    Line 3: Anything
    Line 4: Anything

    I want to get the contents of line 2 and read the group.A which contains more items that I want to get later.

    Currently I'm doing this:
    Code:java
    1. if (config.getString("group." + sLine2 + ".type") != null)

    where config is a reference to MainClass.getInstance().getConfig(); (getInstance() is used to get an instance of the class so I don't have to put constructors everywhere :p) and sLine2 is the 2nd line of the sign.

    However, this doesn't seem to be working. I'm very new to Bukkit development, and I know absolutely NOTHING about reading configs. I don't know if I'm doing it completely wrong, or if I just need to tweak something, or what.

    If you need any more information, let me know and I'll try to supply it.

    Thanks in advance for any assistance!

    EDIT: Woops, forgot to do Java code block :p
     
  2. Offline

    TheCodingCat

    Listen for PlayerInteractEvent check if the clicked block is not null, if the action is RIGHT_CLICK_BLOCK, check if the block.getType() is a sign then do Sign sign = e.getClickedBlock().getState(); then get the requested line of that sign
    and check if its [buy] and so on.
     
  3. I've already done that. The SignChangeEvent is to make sure the sign is valid before putting it to use. I'm testing the validity of the sign with the SignChangeEvent when it's placed to make sure I don't run into any unhandled exceptions before someone actually uses the sign.

    *bump*

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 14, 2016
  4. Offline

    fireblast709

    This is the start of a bad habit: abusing static for lazy access.
    http://wiki.bukkit.org/Configuration_API_Reference
     
  5. Read that page, couldn't find anything that helps there.
     
  6. Nvm, it was a noob coding mistake. Was checking for null instead of "" ._.
     
Thread Status:
Not open for further replies.

Share This Page