Thread: rollback

Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 28
  1. #11  
    Registered Member
    Join Date
    Sep 2010
    Posts
    841
    Thanks given
    1
    Thanks received
    3
    Rep Power
    1
    Code:
    package server.util;
    
    import server.model.players.Client;
    import server.model.players.PlayerSave;
    import server.Server;
    
    public class ShutDownHook extends Thread {
    
    	@Override
    	public void run() {
    		System.out.println("Shutdown thread run.");
    		for (int j = 0; j < Server.playerHandler.players.length; j++) {
    			if (Server.playerHandler.players[j] != null) {
    				Client c = (Client)Server.playerHandler.players[j];
    				server.model.players.PlayerSave.saveGame(c);			
    			}		
    		}
    		System.out.println("Shutting down...");
    	}
    
    }
    That's my current Shutdownhook. I don't see a lot of changes compared to yours though, or am I wrong?
    Reply With Quote  
     

  2. #12  
    Registered Member
    Join Date
    Oct 2010
    Posts
    168
    Thanks given
    4
    Thanks received
    4
    Rep Power
    1
    Okay, your ShutDownHook is perfect, just make sure you have:
    Code:
    ShutDownHook shutdownhook = new ShutDownHook();
    Runtime.getRuntime().addShutdownHook(shutdownhook);
    In your Server class.

    If you do, and it's still rolling back, it's your saveGame boolean.
    Reply With Quote  
     

  3. #13  
    Registered Member
    Join Date
    Sep 2010
    Posts
    841
    Thanks given
    1
    Thanks received
    3
    Rep Power
    1
    Quote Originally Posted by EmulousGuru View Post
    Okay, your ShutDownHook is perfect, just make sure you have:
    Code:
    ShutDownHook shutdownhook = new ShutDownHook();
    Runtime.getRuntime().addShutdownHook(shutdownhook);
    In your Server class.

    If you do, and it's still rolling back, it's your saveGame boolean.
    Well, I just replaced my shutdownhook with yours. Now I need to add these 2:
    Code:
    ShutDownHook shutdownhook = new ShutDownHook();
    Runtime.getRuntime().addShutdownHook(shutdownhook);
    On top of my server class they are all put like this though;
    Code:
    	public static CastleWars castleWars = new CastleWars();
    	public static PestControl pestControl = new PestControl();
    	public static NPCDrops npcDrops = new NPCDrops();
    	public static ClanChatHandler clanChat = new ClanChatHandler();
    	public static FightCaves fightCaves = new FightCaves();
    So dont i need to put like public static orso, in front of it?

    because;

    Code:
    src\server\Server.java:71: <identifier> expected
            Runtime.getRuntime().addShutdownHook(shutdownhook);
                              ^
    src\server\Server.java:71: ';' expected
            Runtime.getRuntime().addShutdownHook(shutdownhook);
                                ^
    2 errors
    Reply With Quote  
     

  4. #14  
    Registered Member
    Join Date
    Oct 2010
    Posts
    168
    Thanks given
    4
    Thanks received
    4
    Rep Power
    1
    Sorry I wasn't clear, add them inside the main() void in Server class.
    Reply With Quote  
     

  5. #15  
    Registered Member
    Join Date
    Sep 2010
    Posts
    841
    Thanks given
    1
    Thanks received
    3
    Rep Power
    1
    Where in here?

    Code:
    	public static void main(java.lang.String args[]) throws NullPointerException, IOException {
    		/**
    		 * Starting Up Server
    		 */
    		 
    		System.setOut(new Logger(System.out));
    		System.setErr(new Logger(System.err));		
    		System.out.println("Launching Server...");
    		
    		/**
    		 * World Map Loader
    		 */
    		//if(!Config.SERVER_DEBUG)
    			//VirtualWorld.init();
    		//WorldMap.loadWorldMap();	
    
    		/**
    		 * Script Loader
    		 */
    		//ScriptManager.loadScripts();
    		
    		/**
    		 * Accepting Connections
    		 */
    		acceptor = new SocketAcceptor();
    		connectionHandler = new ConnectionHandler();
    		
    		SocketAcceptorConfig sac = new SocketAcceptorConfig();
    		sac.getSessionConfig().setTcpNoDelay(false);
    		sac.setReuseAddress(true);
    		sac.setBacklog(100);
    		
    		throttleFilter = new ConnectionThrottleFilter(Config.CONNECTION_DELAY);
    		sac.getFilterChain().addFirst("throttleFilter", throttleFilter);
    		acceptor.bind(new InetSocketAddress(serverlistenerPort), connectionHandler, sac);
    
    		/**
    		 * Initialise Handlers
    		 */
    		EventManager.initialize();
    		Connection.initialize();
    		//PlayerSaving.initialize();
    		//MysqlManager.createConnection();
    Reply With Quote  
     

  6. #16  
    Registered Member
    Join Date
    Oct 2010
    Posts
    168
    Thanks given
    4
    Thanks received
    4
    Rep Power
    1
    At the top of Server class, add this:
    Code:
    ShutDownHook shutdownhook = new ShutDownHook();
    With the imports, add this:
    Code:
    import java.lang.Runtime;
    And add this is the main void in Server clas:
    Code:
    Runtime.getRuntime().addShutdownHook(shutdownhook);
    Reply With Quote  
     

  7. #17  
    Registered Member
    Join Date
    Sep 2010
    Posts
    841
    Thanks given
    1
    Thanks received
    3
    Rep Power
    1
    Quote Originally Posted by EmulousGuru View Post
    At the top of Server class, add this:
    Code:
    ShutDownHook shutdownhook = new ShutDownHook();
    With the imports, add this:
    Code:
    import java.lang.Runtime;
    And add this is the main void in Server clas:
    Code:
    Runtime.getRuntime().addShutdownHook(shutdownhook);
    ok done the first 2, can you add the last 1 in for me?

    Code:
    	public static void main(java.lang.String args[]) throws NullPointerException, IOException {
    		/**
    		 * Starting Up Server
    		 */
    		 
    		System.setOut(new Logger(System.out));
    		System.setErr(new Logger(System.err));		
    		System.out.println("Launching Server...");
    		
    		/**
    		 * World Map Loader
    		 */
    		//if(!Config.SERVER_DEBUG)
    			//VirtualWorld.init();
    		//WorldMap.loadWorldMap();	
    
    		/**
    		 * Script Loader
    		 */
    		//ScriptManager.loadScripts();
    		
    		/**
    		 * Accepting Connections
    		 */
    		acceptor = new SocketAcceptor();
    		connectionHandler = new ConnectionHandler();
    		
    		SocketAcceptorConfig sac = new SocketAcceptorConfig();
    		sac.getSessionConfig().setTcpNoDelay(false);
    		sac.setReuseAddress(true);
    		sac.setBacklog(100);
    		
    		throttleFilter = new ConnectionThrottleFilter(Config.CONNECTION_DELAY);
    		sac.getFilterChain().addFirst("throttleFilter", throttleFilter);
    		acceptor.bind(new InetSocketAddress(serverlistenerPort), connectionHandler, sac);
    
    		/**
    		 * Initialise Handlers
    		 */
    		EventManager.initialize();
    		Connection.initialize();
    		//PlayerSaving.initialize();
    		//MysqlManager.createConnection();
    		
    		/**
    		 * Server Successfully Loaded 
    		 */
    		System.out.println("Server listening on port 0.0.0.0:" + serverlistenerPort);
    Reply With Quote  
     

  8. #18  
    Registered Member
    Join Date
    Oct 2010
    Posts
    168
    Thanks given
    4
    Thanks received
    4
    Rep Power
    1
    Right under
    Code:
    public static void main(java.lang.String args[]) throws NullPointerException, IOException {
    add
    Code:
    Runtime.getRuntime().addShutdownHook(shutdownhook);
    Reply With Quote  
     

  9. #19  
    Registered Member
    Join Date
    Sep 2010
    Posts
    841
    Thanks given
    1
    Thanks received
    3
    Rep Power
    1
    Code:
    	public static void main(java.lang.String args[]) throws NullPointerException, IOException {
    Runtime.getRuntime().addShutdownHook(shutdownhook);
    		/**
    		 * Starting Up Server
    		 */
    		 
    		System.setOut(new Logger(System.out));
    		System.setErr(new Logger(System.err));		
    		System.out.println("Launching Server...");

    Code:
    src\server\Server.java:94: non-static variable shutdownhook cannot be referenced
     from a static context
    Runtime.getRuntime().addShutdownHook(shutdownhook);
                                         ^
    Note: Some input files use unchecked or unsafe operations.
    Note: Recompile with -Xlint:unchecked for details.
    1 error
    Reply With Quote  
     

  10. #20  
    Registered Member
    Join Date
    Oct 2010
    Posts
    168
    Thanks given
    4
    Thanks received
    4
    Rep Power
    1
    When you added ShutDownHook shutdownhook = new ShutDownHook();

    Did you add it exactly like that, or like:
    Code:
    public static ShutDownHook shutdownhook = new ShutDownHook();
    ?
    Reply With Quote  
     

Page 2 of 3 FirstFirst 123 LastLast

Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. Rollback
    By R4nger 0wnz in forum Help
    Replies: 7
    Last Post: 07-25-2010, 10:57 PM
  2. Rollback
    By Runeman1010 in forum Help
    Replies: 3
    Last Post: 07-24-2010, 11:58 AM
  3. Rollback when dc
    By danny94 in forum Help
    Replies: 2
    Last Post: 02-27-2010, 07:48 PM
  4. Dc = rollback?
    By range to dds in forum Help
    Replies: 2
    Last Post: 08-29-2009, 12:12 AM
  5. Wow. Rollback...
    By Rugrats in forum Complaints
    Replies: 4
    Last Post: 04-09-2009, 01:33 AM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •