Jump to content
Existing user? Sign In

Sign In



Sign Up

[Vencillio] - Adding 2min Auto Save to Prevent Rollback


Sanity

Recommended Posts

This will add a 2 minute auto save to prevent rollback. This is literally if your vps goes down, you accidentally close eclipse or your server.bat, or if the server crashes.

Step One:

Open your Vencillio source, and navigate to

Src/Com/Vencillio/core/task/impl

You'll know you're in the right place if you see a file called "WalktoTask.java"

Create a new Java Document and call it PlayerBackupTask

Paste this code inside of it

package com.vencillio.core.task.impl;

import java.util.Arrays;
import java.util.Optional;

import com.vencillio.core.task.Task;
import com.vencillio.rs2.content.io.PlayerSave;
import com.vencillio.rs2.entity.World;
import com.vencillio.rs2.entity.player.Player;


public class PlayerBackupTask extends Task {
	

	
	//every 2 min
	public PlayerBackupTask() {
		super(650, true, StackType.NEVER_STACK, BreakType.NEVER, TaskIdentifier.CHARACTER_BACKUP);
	}

	@Override
	public void execute() {
		Thread t = new Thread(new Runnable() {
			@Override
			public void run() {
				backup();
				System.out.println("Starting up Anti-Rollback Task...");
			}
		});
		t.start();
		try {
			t.join();
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
	}

	@Override
	public void onStop() {
	}

	public static void backup() {
		Arrays.stream(World.getPlayers()).forEach(player -> {
			Optional<Player> node = Optional.ofNullable(player);
			node.ifPresent(p -> PlayerSave.save(p));
		});
	}
}

Save and Close the File.

Step Two:

Now navigate to

Src/Com/Vencillio/Core

And open up "GameThread.java"

Ctrl-F and search for

GameDataLoader.load();

You should see this

		logger.info("Loading game data..");

		GameDataLoader.load();

Directly under the GameDataLoader.load(); paste this

		logger.info("Turning on Player Backup System...");
		TaskQueue.queue(new PlayerBackupTask());

Don't close the file yet. If you're not using an IDE it wont suggest the import. If you are using an IDE when it will suggest the Import. Lets go ahead and manually add the import, unless you feel like IDE should do it.

At the top where you see all the imports add this import.

import com.vencillio.core.task.impl.PlayerBackupTask;

Save and Close the File.

Step Three:

Let me state this clearly because last snippet I got shit for this. If you're using an IDE it will compile your source automatically. If you're not using an IDE, Compile your server. 
Congratulations you're done.

Link to comment
Share on other sites

  • 1 year later...
  • 2 months later...
  • 2 months later...
  • 9 months later...
  • 2 years later...
  • 2 weeks later...
  • 4 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Contact

[email protected]

astra.security

What is a RSPS?

A RSPS, also known as RuneScape private server, is an online game based on RuneScape, and controlled by independent individuals.

Popular RSPS Servers

Runewild Ikov RedemptionRSPS

Disclaimer

Runesuite is not affiliated with runescape, jagex in any way & exists solely for educational purposes.

×
×
  • Create New...