0

I understand using "this" returns different objects based on the scope you're currently in. How would I return the reference to my class, and not the function in this particular scenario?

public void create() {

    // Creates 10 second clock and timer that warps the teams to their respective maps to begin.
    map_factory.getMap(waiting_map).broadcastMessage(MaplePacketCreator.getClock(10));

    // Warps players to respective maps to begin the PQ.
    // Starts the scheduler to start spawning initial mobs.
    // Sets a timer for 10 minutes; after 10 minutes the end function will execute and end the game.
    this.schedule = TimerManager.getInstance().schedule(new Runnable() {
        public void run() {
            blue_party.warpParty(blue_map);
            red_party.warpParty(red_map);
            start_time = System.currentTimeMillis();
            execute();
            startTimer();
        }
    }, 10000);


}

This function is within my class. I'm trying to set start_time to the current time in milliseconds, but that just creates a local variable. start_time is actually a class variable. I wasn't sure what kind of syntax I would have to use to look up a question like this, so I thought it would be easier to ask. Perhaps a more testable example would be this:

public void foo() {
    this.schedule = TimerManager.getInstance().schedule(new Runnable() {
        public void run() {
            start_time = System.currentTimeMillis();
        }
    }, 10000);
}
Jacob Macallan
  • 959
  • 2
  • 8
  • 29

0 Answers0