Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

Sign up now!

Advice needed on improving some code

Banned for Scamming
Joined
May 25, 2016
Messages
352
Alright so What this does is When you are in a certain location it initiates a Timer, & if you aren't in that location the timer is canceled and is removed. I need some advice on how I could improve this.

JavaScript:
package com.rs.game.player.wilderness;

import com.rs.game.player.Player;
import com.rs.game.player.controlers.Wilderness;
import com.rs.game.tasks.WorldTask;
import com.rs.game.tasks.WorldTasksManager;

/**
*
* @author Tafanii
* Wilderness Time count
* @Sketchy ass timer lmao
*
*/
public class Timer {
  
    private Player c;
  
    public Timer(Player c) {
        this.c = c;
    }
  
    public String chat(String text) {
        return text + "";
    }
  
    public void sendTimer() {
        c.cancelTimer = false;
        System.out.println("Timer Initiated - "+c.timeCount);
        c.getPackets().sendHideIComponent(745, 6, true);
        c.getPackets().sendIComponentText(745, 5, "" + c.timeCount);
        chat("PvP Timer: "+c.timeCount);
    }
  
    public void hideTimer() {
        //hide timer
    }
  
    public boolean isAtDitch() {
        if (c.getX() >= 3039 && c.getY() >= 3523 &&
            c.getX() <= 3303 && c.getY() <= 3524) {
            return true;
        }
        return false;
    }
  
    public boolean cancelTimer() {
        System.out.println("Timer Canceled");
        c.timeCount = -1;
        hideTimer();
        return false;
    }
  
    public void callTimer() {
        chat("Timer inited.");
        c.timeCount = 10;
        countDown();
    }
  
    public void countDown() {
        WorldTasksManager.schedule(new WorldTask() {

            @Override
            public void run() {
                if (c.timeCount <= -1) {
                    System.out.println("[PvP Timer] has Reached ending sequence state");
                    hideTimer();
                    c.getPackets().sendHideIComponent(745, 3, false);
                    stop();
                }
                if (c.getControlerManager().getControler() instanceof Wilderness) {
                    if (!isAtDitch()) {
                        c.getPackets().sendHideIComponent(745, 3, false);
                        c.timeCount = -1;
                        return;
                    }
          
                }
                sendTimer();
                c.timeCount--;
          
            }          
        }, 0, 1);
    }
  
}
 
Top