listener based on time?

Discussion in 'Plugin Development' started by moose517, Aug 16, 2011.

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

    moose517

    I'm not sure exactly what i'm looking for here so i figured i would come ask. I'm developing a plugin that i want blocks to change at dawn and dusk. what listener do i need to do this? Also i have an arraylist of blocks. is this the best method i should be storing the blocks i mark in? i know everybody talks about hashmaps but its only one field i need stored.

    Yeah i'm totally lost on how to save, load a ArrayList of blocks.

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

    bassfader

    For the timechange:
    For the time change there is no event (as far as I know, please correct me someone if I am wrong there :)) I would setup a Bukkit Scheduler and let it check the time frequently.

    For the arraylist:
    You could store the blocks in an ArrayList and save it to file by just saving the blocks coordinates, something like this:

    (There may be errors included as I just wrote this down in 5 minutes in Notepad++ but it should at least give you a rough starting point ;) )

    Code:java
    1. try {
    2. BufferedWriter out = new BufferedWriter(new FileWriter("outfilename")); // Where "outfilename" is the name (and path) of/to your file
    3. for (Block block : YourArrayList) // Where YourArrayList is the array list you want to parse
    4. {
    5. out.writeln(block.getX().toString() + ";" + block.getZ().toString() + ";" + block.getY().toString());
    6. }
    7. out.close();
    8. } catch (IOException e) {
    9. }


    And you could from the file something like this:
    Code:java
    1. try {
    2. BufferedReader br = new BufferedReader(new FileReader("outfilename")); // Where "outfilename" is the name (and path) of/to your file
    3. String line;
    4. String[] data;
    5. World world; // The world from which the blocks are - you need to get that from somewhere
    6. YourArrayList = new List<Block>(); // Where YourArrayList is the array list you want to parse
    7. while ((line = br.readLine()) != null) {
    8. data = line.split(";");
    9. if (data.length == 2)
    10. {
    11. YourArrayList.add(world.getBlockAt(Integer.valueOf(data[0]), Integer.valueOf(data[2]), Integer.valueOf(data[1])));
    12. }
    13. }
    14. }
    15. catch (IOException e) {
    16. System.out.println("Error: " + e);
    17. }
     
  3. Offline

    moose517

    doh, i can't believe i forgot multiworlds LOL. Plugin was only intended to be used more or less once on my server for a project and that was the only place, however i guess i should add multiworld functionality. Back to the drawing board, gonna use a hashmap i guess with world being key and a arraylist of blocks. would that do it?
     
  4. Offline

    bassfader

    It should, you could just use a HashMap<World, List<Block>> or something like that, it should work as far as I know.
    Then just create one file per world and you should be good to go, or just store the worlds name within the file as another "parameter" per line ;)
     
  5. Offline

    moose517

    Yeah i'm working on the hashmap now, i thought i had it all worked out but it goes kaboom when i run it. I will get to the saving aspect here in a bit, need to get the marking working in game again first LOL. Anyways here is the code

    Code:java
    1.  
    2. private void add_block(World world, Block block) {
    3. // extract the ArrayList from the HashMap
    4. ArrayList<Block> blockArray = blockHash.get(world);
    5. // add the block to the list
    6. blockArray.add(block);
    7. // save the array back to the hashmap
    8. blockHash.put(world, blockArray);
    9. }


    when i view the stack trace in the console it points to the first line in the function
     
  6. Offline

    bassfader

    Try List<Block> blockArray instead of ArrayList<Block> blockArray
     
  7. Offline

    moose517

    same deal
     
  8. Offline

    bassfader

    Then post the error so I know whats going on / wrong and the code + line numbers of your code so I can see where the error occures. (or even better just the complete class, makes things easier)
     
  9. Offline

    moose517

    here is the player listener
    Code:java
    1.  
    2. package com.moosemanstudios.NightLight;
    3.  
    4. import java.io.File;
    5. import java.util.ArrayList;
    6. import java.util.HashMap;
    7. import org.bukkit.ChatColor;
    8. import org.bukkit.Material;
    9. import org.bukkit.World;
    10. import org.bukkit.block.Block;
    11. import org.bukkit.entity.Player;
    12. import org.bukkit.event.block.Action;
    13. import org.bukkit.event.player.PlayerInteractEvent;
    14. import org.bukkit.event.player.PlayerListener;
    15.  
    16. public class NLPlayerListener extends PlayerListener {
    17. public static NightLight plugin;
    18. private HashMap<World, ArrayList<Block>> blockHash = new HashMap<World, ArrayList<Block>>();
    19. static String mainDirectory = "plugins/NightLight"; // set main directory for easy reference
    20. static File saveFile = new File(mainDirectory + File.separator + "NightLight.dat");
    21. NLPlayerListener(NightLight instance) {
    22. plugin = instance;
    23. }
    24. public void onPlayerInteract(PlayerInteractEvent event) {
    25. Player player = event.getPlayer();
    26. if (event.getAction() == Action.RIGHT_CLICK_BLOCK){
    27. // see if they are in the hashmap
    28. if (plugin.enabled(player))
    29. {
    30. // get the block that was clicked as well as what world
    31. Block block = event.getClickedBlock();
    32. World world = player.getWorld();
    33.  
    34. // see if the block is glass or glowstone first
    35. Material blocktype = block.getType();
    36. if ( (blocktype == Material.GLASS) || (blocktype == Material.GLOWSTONE) ) {
    37. // see if the block is already in the hashmap
    38. if (enabled(world, block)) {
    39. // block is in list already, so remove it
    40. remove_block(world, block);
    41. player.sendMessage(ChatColor.YELLOW + world.getName() + " block removed");
    42. } else {
    43. // block needs added, so add it haha
    44. add_block(world, block);
    45. player.sendMessage(ChatColor.YELLOW + world.getName() + " block added");
    46. }
    47. } else {
    48. player.sendMessage(ChatColor.YELLOW + "wrong block type");
    49. }
    50. }
    51. }
    52. }
    53. private Boolean enabled(World world, Block block) {
    54. // see if the hashmap has a key for the current world
    55. if (blockHash.containsKey(world)) {
    56. // hash map contains the world, extract the arraylist
    57. ArrayList<Block> blockArray= blockHash.get(world);
    58. // now see if the arraylist contains the block we are asking about
    59. if (blockArray.contains(block)) {
    60. // block is there, return true
    61. return true;
    62. } else {
    63. // block isn't in the list, return false
    64. return false;
    65. }
    66. }
    67. // defaults to false, if the world isn't in the hashmap there is obviously no blocks enabled.
    68. return false;
    69. }
    70. private void add_block(World world, Block block) {
    71. // extract the ArrayList from the HashMap
    72. ArrayList<Block> blockArray = blockHash.get(world);
    73. // add the block to the list
    74. blockArray.add(block);
    75. // save the array back to the hashmap
    76. blockHash.put(world, blockArray);
    77. }
    78. private void remove_block(World world, Block block) {
    79. // extract the array from the hash
    80. ArrayList<Block> blockArray = blockHash.get(world);
    81. // remove the block from the list
    82. blockArray.remove(block);
    83. // save the array back to the hashmap
    84. blockHash.put(world, blockArray);
    85. }
    86.  
    87. public static void save() {
    88. }
    89. public static void load() {
    90.  
    91. }
    92.  
    93. }
    94.  


    and the error from the console
    Code:text
    1.  
    2. 18:03:26 [SEVERE] Could not pass event PLAYER_INTERACT to NightLight
    3. java.lang.NullPointerException
    4. at com.moosemanstudios.NightLight.NLPlayerListener.add_block(NLPlayerLis
    5. tener.java:81)
    6. at com.moosemanstudios.NightLight.NLPlayerListener.onPlayerInteract(NLPl
    7. ayerListener.java:46)
    8. at org.bukkit.plugin.java.JavaPluginLoader$11.execute(JavaPluginLoader.j
    9. ava:314)
    10. at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.jav
    11. a:58)
    12. at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.j
    13. ava:338)
    14. at org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerInteractEven
    15. t(CraftEventFactory.java:168)
    16. at net.minecraft.server.ItemInWorldManager.interact(ItemInWorldManager.j
    17. ava:210)
    18. at net.minecraft.server.NetServerHandler.a(NetServerHandler.java:573)
    19. at net.minecraft.server.Packet15Place.a(SourceFile:57)
    20. at net.minecraft.server.NetworkManager.b(NetworkManager.java:226)
    21. at net.minecraft.server.NetServerHandler.a(NetServerHandler.java:89)
    22. at net.minecraft.server.NetworkListenThread.a(SourceFile:105)
    23. at net.minecraft.server.MinecraftServer.h(MinecraftServer.java:454)
    24. at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:363)
    25. at net.minecraft.server.ThreadServerApplication.run(SourceFile:422)
    26.  


    line 83 in my code is a comment right before blockHash.put in add_block
     
  10. Offline

    bassfader

    You never check if world is actually allready in the HashMap but just do a "blockHash.get(world);" which will return null if the world is not in the hashmap. Then you are using the result and try to add something to it, which is not possible when its null. Try something like this (may also apply to the block_remove function):
    Code:
    private void add_block(World world, Block block) {
        ArrayList<Block> blockArray = blockHash.get(world);
        if (blockArray == null) { blockArray = new ArrayList<Block>(); }    
        blockArray.add(block);
        blockHash.put(world, blockArray);
    }
    Also I am pretty sure using lists is done like this (I am using them like that in my Plugins and it works like a charm ^^ - though it may be possible that your way also works, I never tried it, but the following is just how I learned it when I learned java at my apprenticeship):
    Code:
    public List<Player> playersAccepted = new ArrayList<Player>();
     
  11. Offline

    moose517

    doh, i should have known that. i really need some sleep today LOL.

    EDIT: that did it LOL. i'm doing one helluva facepalm right now. +9001 rep

    I'm back one last time for today LOL. In my main class in the onEnable and onDisable functions i call the NLplayerlistener load() and save() methods. however it says cannot make static reference to the non-static method load() from the type NLPlayerListener. I have the NLplayerListener in the main class as a public final. How in the world do i go about this. i know if i make the listener static then it creates errors in the listener itself.

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

    draeath

    It's not an event, but you can check and manipulate time here. Note that rapidly setting the time can completely mangle redstone, so be careful.

    look here.
    ./Bukkit/src/main/java/org/bukkit/World.java (starting at line 402 as per commit 79ac053ef657886be7c0)

    Code:
        /**
         * Gets the relative in-game time of this world.
         *
         * The relative time is analogous to hours * 1000
         *
         * @return The current relative time
         * @see #getFullTime() Returns an absolute time of this world
         */
        public long getTime();
    
        /**
         * Sets the relative in-game time on the server.
         *
         * The relative time is analogous to hours * 1000
         * <br /><br />
         * Note that setting the relative time below the current relative time will
         * actually move the clock forward a day. If you require to rewind time, please
         * see setFullTime
         *
         * @param time The new relative time to set the in-game time to (in hours*1000)
         * @see #setFullTime(long) Sets the absolute time of this world
         */
        public void setTime(long time);
    
        /**
         * Gets the full in-game time on this world
         *
         * @return The current absolute time
         * @see #getTime() Returns a relative time of this world
         */
        public long getFullTime();
    
        /**
         * Sets the in-game time on the server
         * <br /><br />
         * Note that this sets the full time of the world, which may cause adverse
         * effects such as breaking redstone clocks and any scheduled events
         *
         * @param time The new absolute time to set this world to
         * @see #setTime(long) Sets the relative time of this world
         */
        public void setFullTime(long time);
     
  13. Offline

    bassfader

    If its what I think it is (lol xD) then you need to create a NLPlayerListener Object first, then you can access these methods in that Object, like:
    Code:
    NLPlayerListener playerListener;
    
    public void onEnable() {
         playerListener = new NLPlayerListener(this);
         playerListener.load();
    }
    If that doesn't work, then please post the code again so I can take a look ;)
     
  14. Offline

    moose517

    FML. i was at work today thinking about what you said, got home and looked at the code and it jumped right too me. I was calling the actual class and not the instance i created. I'm telling ya i was tired yesterday LOL.

    Back with another question. I looked into schedulers but see a serious lack on any tutorials on how to use them so i just took a stab at one. I put this in the NLPlayerListener class as i wasn't sure where it should go. it works, but it lags the server out hardcore, i assume its because of the delay and period being set to 0. I plan on upping that of course, no need to check THAT often, maybe every 100 ticks at most. Anyways, is there a better place this should be or is that fine? I thought about splitting it out into its own class more than likely, seems to make sense to me.

    Code:java
    1.  
    2. plugin.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
    3. public void run() {
    4. // get list of worlds
    5. List<World> worlds = plugin.getServer().getWorlds();
    6. for (World world : worlds) {
    7. // see if the world is in the hashmap
    8. if (blockHash.containsKey(world)) {
    9. // get the time in the world
    10. long time = world.getTime();
    11. ArrayList<Block> blockArray = blockHash.get(world);
    12. for (Block block : blockArray) {
    13. if ((time > 12000) && (time < 22200)) {
    14. block.setType(Material.GLOWSTONE);
    15. } else {
    16. block.setType(Material.GLASS);
    17. }
    18. }
    19. }
    20. }
    21. }
    22. }, 0L, 0L);
    23.  


    Also if i can't figure out why my loading code won't work tomorrow evening i'll post that. it compiles, and it "loads" but somethigns not right as blocks that were saved when i first click them are added back in again.

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

    bassfader

    You indeed should increase the delay, as 0 means it will run with EVERY server tick, which is quite a lot, since you loop through all worlds, check a list/hashmap for each world if it contains the world, and parse every block in the blocks array for those world, and also change blocks everytime!

    To increase performance a bit:
    • You could do a crosscheck if it has to change the block at all, because if the block is allready glass or is allready glowstone there is no need to change it
    • Also I'd recommend to set the delay to several seconds (remember 20 ticks equals about a second), so maybe set it to 5 seconds = 5 * 20 = 100 ticks or even better to more, like 30 seconds = 30 * 20 = 600 ticks. The longer the delay the less heavy it will impact your servers performance, there is really no need to call that method that often ;)

    Since I don't really know where that code is located I cant really tell you if its placed good or bad ^^ Well you should at least make sure it will only be called once, otherwise you'd end up with many scheduled tasks when you really only need one :) (Which would be another performance killer xD)
    I'd personally put it into its own class, just for the sake of that beeing much more structured and easy to read, but I guess thats just my preference ^^
     
  16. Offline

    moose517

    Alright i'm back, had a few days that haven't been good to me. Anyways i split the scheduler out into a new class called NLTimeListener, here is the class

    Code:java
    1.  
    2. package com.moosemanstudios.NightLight;
    3.  
    4. import java.util.ArrayList;
    5. import java.util.List;
    6.  
    7. import org.bukkit.Material;
    8. import org.bukkit.World;
    9. import org.bukkit.block.Block;
    10.  
    11.  
    12. public class NLTimeListener {
    13. private static int NIGHT_END;
    14. private static int NIGHT_START;
    15. private static NightLight plugin;
    16.  
    17. public NLTimeListener(NightLight instance, int start, int end) {
    18. plugin = instance;
    19. NIGHT_END = end;
    20. NIGHT_START = start;
    21. }
    22. public void run() {
    23. plugin.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
    24. public void run() {
    25. // get list of worlds
    26. List<World> worlds = plugin.getServer().getWorlds();
    27. for (World world : worlds) {
    28. // see if the world is in the hashmap
    29. if (plugin.playerlistener.blockHash.containsKey(world)) {
    30. // get the time in the world
    31. long time = world.getTime();
    32. ArrayList<Block> blockArray = plugin.playerlistener.blockHash.get(world);
    33. for (Block block : blockArray) {
    34. if ((time > NIGHT_START) && (time < NIGHT_END)) {
    35. if (block.getType() != Material.GLOWSTONE) {
    36. block.setType(Material.GLOWSTONE);
    37. }
    38. } else {
    39. if (block.getType() != Material.GLASS){
    40. block.setType(Material.GLASS);
    41. }
    42. }
    43. }
    44. }
    45. }
    46. }
    47. }, 100L, 0L);
    48. }
    49. }
    50.  


    Then in the main class i declare at the class level a NLtimeListener instance with the times for dawn and dusk. In onEnable i then call timeListener.run() assuming thats how it should be done. Compiles fine and loads up fine no errors, however i still get a the system cannot keep up popping up real fast and my ram level maxes out in no time flat so i'm assuming its still creating a ton of the schedulers
     
  17. Offline

    bassfader

    Well you still have set the period to 0 which will cause it run every server tick, you just set the delay to 100 so it will start only after 100 ticks, but after that delay it will run every server tick. Set the period higher, and also please post your current main class so I can take a look at it.

    And BTW I meant it somewhat different to split it into a new class, but I'll show you that when you posted the main class too, sometime tomorrow ;) (Though I have to work on my own plugin so it may take some time, depending on how much I've got todo with my own Plugin)
     
  18. Offline

    moose517

    Well i finally got it working, no lag, not ram eating, i let the plugin run for an hour or so on my test server to make sure and RAM usage didn't climb like it was. Revamped a lot of code and must have fixed something in the process. Only one last to get working and its ready to be released. Not sure if i wanna release it publicly on here, there is only one plugin thats similar that i know of but i feel like i a noob haha. Anyways, that last issue. Saving works great, i verified that its saving the correct blocks in the file by walking to them in world, but on loading the file it doesn't seem to be correct. I'm including the entire class in case i'm just messing up the logic somewhere but i don't believe so.

    Code:java
    1.  
    2. package com.moosemanstudios.NightLight;
    3.  
    4. import java.io.BufferedReader;
    5. import java.io.BufferedWriter;
    6. import java.io.File;
    7. import java.io.FileReader;
    8. import java.io.FileWriter;
    9. import java.io.IOException;
    10. import java.util.ArrayList;
    11. import java.util.HashMap;
    12. import org.bukkit.ChatColor;
    13. import org.bukkit.Material;
    14. import org.bukkit.World;
    15. import org.bukkit.block.Block;
    16. import org.bukkit.entity.Player;
    17. import org.bukkit.event.block.Action;
    18. import org.bukkit.event.player.PlayerInteractEvent;
    19. import org.bukkit.event.player.PlayerListener;
    20.  
    21. public class NLPlayerListener extends PlayerListener {
    22. public static NightLight plugin;
    23. public HashMap<World, ArrayList<Block>> blockHash = new HashMap<World, ArrayList<Block>>();
    24. static String mainDirectory = "plugins/NightLight"; // set main directory
    25. // for easy reference
    26.  
    27. NLPlayerListener(NightLight instance) {
    28. plugin = instance;
    29. }
    30.  
    31. public void onPlayerInteract(PlayerInteractEvent event) {
    32. Player player = event.getPlayer();
    33.  
    34. if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
    35. // see if they are in the hashmap
    36. if (plugin.enabled(player)) {
    37. // get the block that was clicked as well as what world
    38. Block block = event.getClickedBlock();
    39. World world = player.getWorld();
    40.  
    41. // see if the block is glass or glowstone first
    42. Material blocktype = block.getType();
    43. if ((blocktype == Material.GLASS) || (blocktype == Material.GLOWSTONE)) {
    44. // see if the block is already in the hashmap
    45. if (enabled(world, block)) {
    46. // block is in list already, so remove it
    47. remove_block(world, block);
    48. player.sendMessage(ChatColor.YELLOW + world.getName() + " block removed");
    49. } else {
    50. // block needs added, so add it haha
    51. add_block(world, block);
    52. player.sendMessage(ChatColor.YELLOW + world.getName() + " block added");
    53. }
    54. } else {
    55. player.sendMessage(ChatColor.YELLOW + "wrong block type");
    56. }
    57. }
    58. }
    59. }
    60.  
    61. private Boolean enabled(World world, Block block) {
    62. // see if the hashmap has a key for the current world
    63. if (blockHash.containsKey(world)) {
    64. // hash map contains the world, extract the arraylist
    65. ArrayList<Block> blockArray = blockHash.get(world);
    66.  
    67. // now see if the arraylist contains the block we are asking about
    68. if (blockArray.contains(block)) {
    69. // block is there, return true
    70. return true;
    71. } else {
    72. // block isn't in the list, return false
    73. return false;
    74. }
    75. }
    76.  
    77. // defaults to false, if the world isn't in the hashmap there is
    78. // obviously no blocks enabled.
    79. return false;
    80. }
    81.  
    82. private void add_block(World world, Block block) {
    83. // extract the ArrayList from the HashMap
    84. ArrayList<Block> blockArray = blockHash.get(world);
    85.  
    86. // see if the blockarray is null
    87. if (blockArray == null) {
    88. blockArray = new ArrayList<Block>();
    89. }
    90.  
    91. // add the block to the list
    92. blockArray.add(block);
    93.  
    94. // save the array back to the hashmap
    95. blockHash.put(world, blockArray);
    96. }
    97.  
    98. private void remove_block(World world, Block block) {
    99. // extract the array from the hash
    100. ArrayList<Block> blockArray = blockHash.get(world);
    101.  
    102. // remove the block from the list
    103. blockArray.remove(block);
    104.  
    105. // save the array back to the hashmap
    106. blockHash.put(world, blockArray);
    107. }
    108.  
    109. public void save() {
    110. ArrayList<World> worlds = new ArrayList<World>(blockHash.keySet());
    111.  
    112. for (World world : worlds) {
    113. try {
    114. BufferedWriter out = new BufferedWriter(new FileWriter(mainDirectory + "/" + world.getName() + ".txt"));
    115.  
    116. // extract the arraylist from the hashmap
    117. ArrayList<Block> blockArray = blockHash.get(world);
    118.  
    119. // iterate through the blockarray and write to the file
    120. for (Block block : blockArray) {
    121. out.write(block.getX() + ";" + block.getY() + ";" + block.getZ());
    122. out.newLine();
    123. }
    124. // log the success
    125. plugin.log.info("[NightLight] world " + world.getName() + " saved.");
    126. out.close();
    127. } catch (IOException ex) {
    128. ex.printStackTrace();
    129. }
    130. }
    131. }
    132.  
    133. public void load() {
    134. // populate worlds with files read from the directory
    135. File dir = new File(mainDirectory);
    136. String[] files = dir.list();
    137. ArrayList<Block> blockArray = new ArrayList<Block>();
    138. blockHash.clear();
    139.  
    140. // iterate throught files to get the filenames and add to list
    141. for (int i = 0; i < files.length; i++) {
    142. try {
    143.  
    144. // see if the name of the file is config.yml, if so skip it ya noob LOL
    145. if (files[1] != "config.yml") {
    146.  
    147. // save the name of the world
    148. String worldName = getFileName(files[i]);
    149. World world = plugin.getServer().getWorld(worldName);
    150.  
    151. if (world != null) {
    152. // open the file to read, file opened will be the name of the world loaded
    153. BufferedReader in = new BufferedReader(new FileReader(mainDirectory + "/" + files[i]));
    154. // populate the arraylist with values read from the file
    155. blockArray.clear();
    156. // loop through the file to get all the blocks
    157. String line = null;
    158. while ((line = in.readLine()) != null) {
    159. // split the string up
    160. String[] data = line.split(";");
    161. // make sure the block isn't malformed
    162. if (data.length == 2) {
    163. blockArray.add(world.getBlockAt(Integer.valueOf(data[0]), Integer.valueOf(data[1]), Integer.valueOf(data[2])));
    164. }
    165. }
    166. // at this point, everything has been read in, close the
    167. // file
    168. in.close();
    169. // add the arraylist as well as world to the hashmap
    170. blockHash.put(world, blockArray);
    171. // let player know world was loaded
    172. plugin.log.info("[NightLight] world " + world.getName() + " loaded.");
    173. } else {
    174. plugin.log.info("[NightLight] Failed to load world: " + worldName);
    175. }
    176. }
    177. } catch (IOException ex) {
    178. ex.printStackTrace();
    179. }
    180. }
    181.  
    182. }
    183.  
    184. private String getFileName(String fullFileName) {
    185. return fullFileName.substring(0, fullFileName.lastIndexOf('.'));
    186. }
    187.  
    188. }
    189. [/i][/i]
     
  19. Offline

    bassfader

    Try to change the line:
    Code:
    if (files[1] != "config.yml") ...
    To:
    Code:
    if (files[i] != "config.yml") ...
    If that doesn't work: Where does it stop? Does it even print the plugin.log.info() stuff you have down there or does it skip the loading completely?
     
  20. Offline

    moose517

    it makes it all the way through and says it loaded the data but it apparantly doesn't.

    EDIT: LOL i didn't notice the 1 in there, i just added that last night but it still claimed to hvae loaded the world file.

    Giggity i got it LOL. It just dawned on me what the problem was after i added a line to show the block that was added in the console not actually showing any blocks added.
    Code:java
    1.  
    2. if (data.length == 2)
    3.  

    there are 3 coordinates not 2 LOL. It does load fine now. few more touches and i believe i'm ready to put it live :D. I really appreciate your help bassfader.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 18, 2016
Thread Status:
Not open for further replies.

Share This Page