Config.yml problem

Discussion in 'Plugin Development' started by Max604, Apr 18, 2014.

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

    Max604

    Hello Im wondering how I can get a string from a string from a string list.
    How to get a int from a string from a stringlist.
    How to get a string from a stringlist.

    Here is my code
    Code:java
    1. package net.darqy.WorldRestrict;
    2.  
    3. import org.bukkit.Bukkit;
    4. import org.bukkit.ChatColor;
    5. import org.bukkit.World;
    6. import org.bukkit.block.Sign;
    7. import org.bukkit.event.EventHandler;
    8. import org.bukkit.event.Listener;
    9. import org.bukkit.event.block.Action;
    10. import org.bukkit.event.block.SignChangeEvent;
    11. import org.bukkit.event.player.PlayerInteractEvent;
    12.  
    13. public class SignListener implements Listener {
    14.  
    15. WorldRestrict plugin;
    16.  
    17. public SignListener(WorldRestrict instance)
    18. {
    19. this.plugin = instance;
    20. }
    21.  
    22.  
    23. @EventHandler
    24. public void onSignChange(SignChangeEvent e) {
    25. World w = plugin.getServer().getWorld(e.getLine(1));
    26. if (e.getLine(0).equalsIgnoreCase(plugin.getConfig().getString("prefixes.", e.getLine(0)))) {
    27. if (e.getLine(1).equalsIgnoreCase(plugin.getConfig().getString("worlds.", e.getLine(1)))) {
    28. e.setLine(0 , e.getLine(0));
    29. e.setLine(1, e.getLine(1));
    30. e.setLine(2, e.getLine(2));
    31. e.setLine(3, w.getPlayers().size() + "/" + Integer.parseInt(plugin.getConfig().getString("worlds." + e.getLine(1))));
    32. e.getPlayer().sendMessage("This should work!");
    33. }
    34. e.getPlayer().sendMessage(ChatColor.RED + e.getLine(1) + " isn't a valid world!");
    35. }
    36. e.getPlayer().sendMessage("fail!");
    37. }
    38.  
    39. @EventHandler
    40. public void onPlayerInteract(PlayerInteractEvent e) {
    41. if (!(e.getAction() == Action.RIGHT_CLICK_BLOCK)) return;
    42. if (e.getClickedBlock().getState() instanceof Sign) {
    43. Sign s = (Sign) e.getClickedBlock().getState();
    44. if (s.getLine(0).equalsIgnoreCase("[WorldRestrict]")) {
    45. plugin.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "warp" + plugin.getConfig().getString("prefixes." + s.getLine(1)));
    46. }
    47. }
    48. }
    49.  
    50. }
    51.  


    Code:
    worlds:
      world: 30
      world_nether: 30
      world_the_end: 30
    deny_message: '&cYou can not enter &7<world>&c because it is full!'
    # Remember to put [] around prefix
    prefixes:
      [Parkour]: warp parkour
    Thanks Max
     
  2. Offline

    agent6262

    Need a little more to go off of, could you possibly comment in your code where you need help. and same with your .yml file or what ever file type you are using.
     
  3. Offline

    Max604

    On line 26 Im trying to see if line 0 is equal to one of the strings in prefixes: agent6262
     
  4. Offline

    agent6262

    Hope this helps some.
    Code:java
    1. @EventHandler
    2. public void onSignChange(SignChangeEvent e) {
    3. World w = plugin.getServer().getWorld(e.getLine(1));
    4. if(plugin.getConfig().contains("prefixes."+e.getLine(0)) && plugin.getConfig().contains("worlds."+e.getLine(1))){//Checks to see if sign has a valid prefix on line 0 and world on line 1 defined in config
    5. e.setLine(0 , e.getLine(0));
    6. e.setLine(1, e.getLine(1));
    7. e.setLine(2, e.getLine(2));
    8. e.setLine(3, w.getPlayers().size() + "/" + Integer.parseInt(plugin.getConfig().getString("worlds." + e.getLine(1))));
    9. e.getPlayer().sendMessage("This should work!");
    10. }
    11. e.getPlayer().sendMessage("fail!");
    12. }
     
  5. Offline

    Max604

  6. Offline

    agent6262

    Your welcome. And if you need any more help just let me know.
     
Thread Status:
Not open for further replies.

Share This Page