11package com .gianlu .pyxreloaded ;
22
33import com .gianlu .pyxreloaded .cardcast .CardcastService ;
4- import com .gianlu .pyxreloaded .data .ConnectedUsers ;
5- import com .gianlu .pyxreloaded .data .Game ;
6- import com .gianlu .pyxreloaded .data .GameManager ;
7- import com .gianlu .pyxreloaded .db .LoadedCards ;
8- import com .gianlu .pyxreloaded .servlets .*;
9- import com .gianlu .pyxreloaded .servlets .Provider ;
4+ import com .gianlu .pyxreloaded .game .Game ;
5+ import com .gianlu .pyxreloaded .game .GameManager ;
6+ import com .gianlu .pyxreloaded .paths .AjaxPath ;
7+ import com .gianlu .pyxreloaded .paths .EventsPath ;
8+ import com .gianlu .pyxreloaded .server .Annotations ;
9+ import com .gianlu .pyxreloaded .server .CustomResourceHandler ;
10+ import com .gianlu .pyxreloaded .server .HttpsRedirect ;
11+ import com .gianlu .pyxreloaded .server .Provider ;
12+ import com .gianlu .pyxreloaded .singletons .*;
1013import com .gianlu .pyxreloaded .task .BroadcastGameListUpdateTask ;
1114import com .gianlu .pyxreloaded .task .RefreshAdminTokenTask ;
1215import com .gianlu .pyxreloaded .task .UserPingTask ;
@@ -45,11 +48,17 @@ public static void main(String[] args) throws IOException, SQLException, Unrecov
4548
4649 Providers .add (Annotations .Preferences .class , (Provider <Preferences >) () -> preferences );
4750
48- LoadedCards .load (preferences .getString ("pyxDb" , "pyx.sqlite" ));
51+ LoadedCards loadedCards = new LoadedCards (preferences .getString ("pyxDbUrl" , "jdbc:sqlite:pyx.sqlite" ));
52+ Providers .add (Annotations .LoadedCards .class , (Provider <LoadedCards >) () -> loadedCards );
4953
5054 ConnectedUsers connectedUsers = new ConnectedUsers (false , maxUsers );
5155 Providers .add (Annotations .ConnectedUsers .class , (Provider <ConnectedUsers >) () -> connectedUsers );
5256
57+ ServerDatabase serverDatabase = new ServerDatabase (preferences .getString ("serverDbUrl" , "jdbc:sqlite:server.sqlite" ));
58+
59+ BanList banList = new BanList (serverDatabase );
60+ Providers .add (Annotations .BanList .class , (Provider <BanList >) () -> banList );
61+
5362 BroadcastGameListUpdateTask updateGameListTask = new BroadcastGameListUpdateTask (connectedUsers );
5463 globalTimer .scheduleAtFixedRate (updateGameListTask , BROADCAST_UPDATE_START_DELAY , BROADCAST_UPDATE_DELAY , TimeUnit .MILLISECONDS );
5564
@@ -61,13 +70,13 @@ public static void main(String[] args) throws IOException, SQLException, Unrecov
6170 CardcastService cardcastService = new CardcastService ();
6271 Providers .add (Annotations .CardcastService .class , (Provider <CardcastService >) () -> cardcastService );
6372
64- GameManager gameManager = new GameManager ((manager , options ) -> new Game (GameManager .generateGameId (), options , connectedUsers , manager , globalTimer , preferences , cardcastService ), 100 , updateGameListTask );
73+ GameManager gameManager = new GameManager ((manager , options ) -> new Game (GameManager .generateGameId (), options , connectedUsers , manager , loadedCards , globalTimer , preferences , cardcastService ), 100 , updateGameListTask );
6574 Providers .add (Annotations .GameManager .class , (Provider <GameManager >) () -> gameManager );
6675
6776 ResourceHandler resourceHandler = new CustomResourceHandler (preferences );
6877 PathHandler pathHandler = new PathHandler (resourceHandler );
69- pathHandler .addExactPath ("/AjaxServlet" , new BaseAjaxHandler ())
70- .addExactPath ("/Events" , Handlers .websocket (new EventsHandler ()));
78+ pathHandler .addExactPath ("/AjaxServlet" , new AjaxPath ())
79+ .addExactPath ("/Events" , Handlers .websocket (new EventsPath ()));
7180
7281 RoutingHandler router = new RoutingHandler ();
7382 router .setFallbackHandler (pathHandler )
0 commit comments