Updating a varible

Discussion in 'Plugin Development' started by unforgiven5232, Jul 22, 2013.

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

    unforgiven5232

    What i am wanting to do is to take the code below and make it "refresh" itself basically.
    Code:
    final Chunk chunk = world1.getChunkAt(blue.getLocation());
    
    and update it so the chunk gets the current chunk of the entity (blue is the entity). I thought a runnable would assist me in this but it seems that i cannot use the in the Runnable
     
  2. Offline

    JazzaG

    unforgiven5232

    Put it in the scope of the Runnable. Does it need to be outside?
     
  3. Offline

    unforgiven5232

    JazzaG
    I would ever much like it outside the Runnable
    Also what do you mean by "scope"
     
  4. Offline

    JazzaG

  5. Offline

    Eats_Rainbows

    Code:
    final Chunk chunk;
    getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
        public void run() {
            chunk = world1.getChunkAt(blue.getLocation());
        }
    }, 0L, 6000L);
    I believe this would 'refresh' the chunk data every five minutes. I haven't tested it or anything since I made it without an IDE.
     
  6. Offline

    unforgiven5232

    Eats_Rainbows
    Gives me an error, it wants me to define the chunk as null first. I'm not sure if it will cause an error, i'll try now.

    JazzaG
    You are referring to what Eats_Rainbows said?
     
  7. Offline

    JazzaG

  8. Offline

    unforgiven5232

    JazzaG
    Yeah and it makes me how to initialize it first, which would be null since its outside the method. Therefore it would give me an error because its searching for a null chunk.

    Unless i make it a public Chunk chunk;

    JazzaG Eats_Rainbows
    Lol help?

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

    Eats_Rainbows

    The chunk variable shouldn't be in any methods.
     
  10. Offline

    unforgiven5232

  11. Offline

    hubeb

    Code:java
    1. public class classname {
    2. plugin plugin;
    3. public classname(plugin instance){
    4. plugin = instance;
    5. }
    6. public Chunk chunk; //<- Here is where he means by "move to the class".
    7. public void fakemethod(){
    8. //chunk stuff here
    9. }
    10. }
     
  12. Offline

    unforgiven5232

    Code:java
    1.  
    2.  
    3. Thats what i have, i have the chunk variable outside of it. Yet its not actually updating the chunk
    4.  
    5. Note: im doing this to get the chunk
    6. [code]
    7. blue.getWorld().getChunkAt(blue.getLocation());
    8. [/code]
    9. the blue represents the zombie entity
    10.  
    11. EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 3, 2016
Thread Status:
Not open for further replies.

Share This Page