Posted September 28, 20177 yr comment_13269 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.
October 3, 20177 yr comment_13458 One of those features nobody notices until the lack of it causes problems, spread this like wildfire
Create an account or sign in to comment