im planning on adding a lot of rpg aspects to my server at some point. im planning on 1 server for normal PVE/PVP stuff. for my quest line stuff im wanting to have all of that set up on another server. when they accept the quest it will send them to the quest server. my issue is going to be syncing player inventory to the quest server then on disconnect or quest finish sending the player and new inventory back to the main server. will there be anyway to accomplish this? if no i need to plan differently.
move player inventory.
-
- English
- james1bow
- Thread is marked as Resolved.
-
-
The API unfortunately has no built-in methods for that, but there are various ways to sync data between two servers. If both servers are running on the same machine, you could create an SQLite database to read and write the data from both servers (this could be done whenever the player connects and disconnects). In WAL-mode, it should be possible to have two connections which can read and write concurrently.
Alternatively you could create a read-only connection to the world database (where the inventories are stored) and retrieve the inventory data from it (i.e. the quest server could read the inventory data from the main server when the player connects, and if you want to sync the inventory back, the main server could read the inventory from the quest server when the player connects there accordingly).
If the servers are running on different machines, you could use a MySQL server instead. Alternatively you could set up a webserver through Java: Java has a built-in HttpServer, and the API has methods to send http requests.
Sending a player to another server, however, isn't possible yet... But we could add a "ConnectToOtherServer()" method for the player It would first show a message box to the player where he has to confirm the server change, then he'll be disconnected from the server and reconnected to the other server.
-
A "ConnectToOtherServer()" method would be awesome. i intended to use an SQLite database. tinkering with java plugins i ran into a lot of db-locked errors and had been thinking of going to MySQL. i intend to release this part as a plugin for other servers to use as well. i think ill get to setting up a MySQL server!
-
The "ConnectToOtherServer()" method is on our to-do list, probably it will be available for the first API release
About the db-locked errors, the Java version SQLite connector was unfortunately using single-threaded mode, so if more than one thread accessed the database concurrently, there was a chance that this could end up in a db-locked error. The new version, on the other hand, runs SQLite in serialized mode, so it's fully thread safe^^
However, this error could also happen if a Statement / PreparedStatement or ResultSet was not closed after using it, for example (unless they were used in a try-with-resources-block, which closes them automatically). But this would also cause trouble in MySQL.
If you run into any db-locked errors or any other db-related issues in general (in SQLite or MySQL) with the new version, please let me know
Participate now!
Don’t have an account yet? Create a new account now and be part of our community!