Sanity 436 Posted September 28, 2017 Report Share Posted September 28, 2017 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. 1 Link to comment Share on other sites More sharing options...
Archer 88 Posted October 3, 2017 Report Share Posted October 3, 2017 One of those features nobody notices until the lack of it causes problems, spread this like wildfire Link to comment Share on other sites More sharing options...
Macca187 8 Posted January 11, 2019 Report Share Posted January 11, 2019 cheers bro appreciate it Link to comment Share on other sites More sharing options...
LeakedMania 0 Posted March 22, 2019 Report Share Posted March 22, 2019 This is a great addition. Great release! Link to comment Share on other sites More sharing options...
2t bank 0 Posted June 2, 2019 Report Share Posted June 2, 2019 Nic Link to comment Share on other sites More sharing options...
brokenyouth 0 Posted March 31, 2020 Report Share Posted March 31, 2020 nice!! exactly what was looking for - Link to comment Share on other sites More sharing options...
khonqr 0 Posted April 14, 2022 Report Share Posted April 14, 2022 great as always, thanks Link to comment Share on other sites More sharing options...
promahmoud 0 Posted April 28, 2022 Report Share Posted April 28, 2022 Easy, thanks Link to comment Share on other sites More sharing options...
geraldpons97 0 Posted May 6, 2022 Report Share Posted May 6, 2022 thanks Link to comment Share on other sites More sharing options...
test710 0 Posted June 3, 2022 Report Share Posted June 3, 2022 Thanks for the addition Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now