From 75078a5fa138cef2be675b039e298cdd906cc418 Mon Sep 17 00:00:00 2001 From: P0nk Date: Mon, 24 May 2021 08:25:41 +0200 Subject: [PATCH 1/3] Add sql script for basic admin account --- sql/4-db-admin.sql | 87 ++++++++++++++++++++++++++++++++++++++++++++++ sql/readme.txt | 7 ++-- 2 files changed, 91 insertions(+), 3 deletions(-) create mode 100644 sql/4-db-admin.sql diff --git a/sql/4-db-admin.sql b/sql/4-db-admin.sql new file mode 100644 index 0000000000..cd18ff31c1 --- /dev/null +++ b/sql/4-db-admin.sql @@ -0,0 +1,87 @@ +-- MySQL dump 10.13 Distrib 8.0.22, for Win64 (x86_64) +-- +-- Host: 127.0.0.1 Database: cosmic +-- ------------------------------------------------------ +-- Server version 8.0.19 + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!50503 SET NAMES utf8 */; +/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; +/*!40103 SET TIME_ZONE='+00:00' */; +/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; +/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; + +USE `cosmic`; + +-- +-- Dumping data for table `accounts` +-- + +LOCK TABLES `accounts` WRITE; +/*!40000 ALTER TABLE `accounts` DISABLE KEYS */; +INSERT INTO `accounts` VALUES (1,'admin','$2y$12$aFD9BDeUocDMY1X4tDYDyeJw/HhkQwCQWs3KAY7gCaRG0cpqJcaL.','0000','000000',0,'2021-05-24 00:00:01','2021-05-24 00:00:02','2005-05-11',0,NULL,NULL,1000000,1000000,1000000,3,0,'2005-05-11 03:00:00',0,1,NULL,0,NULL,0,NULL,NULL,0,0,'1234-5678',2); +/*!40000 ALTER TABLE `accounts` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Dumping data for table `characters` +-- + +LOCK TABLES `characters` WRITE; +/*!40000 ALTER TABLE `characters` DISABLE KEYS */; +INSERT INTO `characters` VALUES (1,1,0,'Admin',1,0,0,12,5,4,4,50,5,50,5,0,0,0,0,0,0,0,30030,20000,0,'0,0,0,0,0,0,0,0,0,0',10000,2,6,-1,25,'2021-05-24 00:00:03',1,0,1,0,0,5,0,4,1,0,0,0,0,0,0,0,0,0,0,24,24,24,24,-1,0,5,0,0,0,0,0,0,0,0,0,0,0,'','2021-05-24 00:00:04','2015-01-01 05:00:00',1,0); +/*!40000 ALTER TABLE `characters` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Dumping data for table `inventoryequipment` +-- + +LOCK TABLES `inventoryequipment` WRITE; +/*!40000 ALTER TABLE `inventoryequipment` DISABLE KEYS */; +INSERT INTO `inventoryequipment` VALUES (17,22,7,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0,0,0,0,1,0,-1),(18,23,7,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,1,0,-1),(19,24,5,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,1,0,-1),(20,25,7,0,0,0,0,0,0,0,17,0,0,0,0,0,0,0,0,0,0,1,0,-1); +/*!40000 ALTER TABLE `inventoryequipment` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Dumping data for table `inventoryitems` +-- + +LOCK TABLES `inventoryitems` WRITE; +/*!40000 ALTER TABLE `inventoryitems` DISABLE KEYS */; +INSERT INTO `inventoryitems` VALUES (21,1,1,NULL,4161001,4,1,1,'',-1,0,-1,''),(22,1,1,NULL,1040002,-1,-5,1,'',-1,0,-1,''),(23,1,1,NULL,1060002,-1,-6,1,'',-1,0,-1,''),(24,1,1,NULL,1072001,-1,-7,1,'',-1,0,-1,''),(25,1,1,NULL,1302000,-1,-11,1,'',-1,0,-1,''); +/*!40000 ALTER TABLE `inventoryitems` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Dumping data for table `keymap` +-- + +LOCK TABLES `keymap` WRITE; +/*!40000 ALTER TABLE `keymap` DISABLE KEYS */; +INSERT INTO `keymap` VALUES (161,1,18,4,0),(162,1,65,6,106),(163,1,2,4,10),(164,1,23,4,1),(165,1,3,4,12),(166,1,4,4,13),(167,1,5,4,18),(168,1,6,4,24),(169,1,16,4,8),(170,1,17,4,5),(171,1,19,4,4),(172,1,25,4,19),(173,1,26,4,14),(174,1,27,4,15),(175,1,31,4,2),(176,1,34,4,17),(177,1,35,4,11),(178,1,37,4,3),(179,1,38,4,20),(180,1,40,4,16),(181,1,43,4,9),(182,1,44,5,50),(183,1,45,5,51),(184,1,46,4,6),(185,1,50,4,7),(186,1,56,5,53),(187,1,59,6,100),(188,1,60,6,101),(189,1,61,6,102),(190,1,62,6,103),(191,1,63,6,104),(192,1,64,6,105),(193,1,57,5,54),(194,1,48,4,22),(195,1,29,5,52),(196,1,7,4,21),(197,1,24,4,25),(198,1,33,4,26),(199,1,41,4,23),(200,1,39,4,27); +/*!40000 ALTER TABLE `keymap` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Dumping data for table `storages` +-- + +LOCK TABLES `storages` WRITE; +/*!40000 ALTER TABLE `storages` DISABLE KEYS */; +INSERT INTO `storages` VALUES (1,1,0,4,0); +/*!40000 ALTER TABLE `storages` ENABLE KEYS */; +UNLOCK TABLES; +/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; + +/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; +/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; +/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; +/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; diff --git a/sql/readme.txt b/sql/readme.txt index c47cb542f9..3f452914be 100644 --- a/sql/readme.txt +++ b/sql/readme.txt @@ -1,6 +1,7 @@ ---- Cosmic MySQL Database ---- These SQL files must be executed IN ORDER to set up the database: - - db_database.sql - - db_drops.sql - - db_shopupdate.sql (optional & require provided WZs) \ No newline at end of file + - 1-db_database.sql (Tables and some data) + - 2-db_drops.sql (Remaining data: monster drops, reactor drops) + - 3-db_shopupdate.sql (Custom shops - optional, requires provided WZs) + - 4-db_admin (Basic admin account - optional) \ No newline at end of file From c514c303c76f242f58ee828ab58dc3bb4c27aa49 Mon Sep 17 00:00:00 2001 From: P0nk Date: Mon, 24 May 2021 20:26:18 +0200 Subject: [PATCH 2/3] Increase db init timeout 60 seconds might not be enough during the initial Docker db setup, but 90 seconds should be plenty. --- config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.yaml b/config.yaml index 34a13ef794..04f7da318f 100644 --- a/config.yaml +++ b/config.yaml @@ -166,7 +166,7 @@ server: DB_HOST: "localhost" DB_USER: "cosmic_server" DB_PASS: "snailshell" - INIT_CONNECTION_POOL_TIMEOUT: 60 # Seconds + INIT_CONNECTION_POOL_TIMEOUT: 90 # Seconds #Login Configuration WORLDS: 1 #Initial number of worlds on the server. From ef12275f35991456a68e62e0857539834770a80e Mon Sep 17 00:00:00 2001 From: P0nk Date: Mon, 24 May 2021 20:29:59 +0200 Subject: [PATCH 3/3] Move db stuff to its own directory, update README --- .gitignore | 1 - README.md | 29 +++++++++++++++-------- database/docker-db-data/.gitignore | 3 +++ {sql => database/sql}/1-db_database.sql | 0 {sql => database/sql}/2-db_drops.sql | 0 {sql => database/sql}/3-db_shopupdate.sql | 0 {sql => database/sql}/4-db-admin.sql | 0 {sql => database/sql}/errors.txt | 0 {sql => database/sql}/readme.txt | 0 docker-compose.yml | 4 ++-- 10 files changed, 24 insertions(+), 13 deletions(-) create mode 100644 database/docker-db-data/.gitignore rename {sql => database/sql}/1-db_database.sql (100%) rename {sql => database/sql}/2-db_drops.sql (100%) rename {sql => database/sql}/3-db_shopupdate.sql (100%) rename {sql => database/sql}/4-db-admin.sql (100%) rename {sql => database/sql}/errors.txt (100%) rename {sql => database/sql}/readme.txt (100%) diff --git a/.gitignore b/.gitignore index d13e4644ed..99c411b1fa 100644 --- a/.gitignore +++ b/.gitignore @@ -2,7 +2,6 @@ .idea/ *.iml /target -/docker-db-data # build files diff --git a/README.md b/README.md index 822baf68d6..bfd2b8a7c1 100644 --- a/README.md +++ b/README.md @@ -136,7 +136,7 @@ If you are using Docker (quick start): #### Configuring the project -The easiest way to set up your project is to load the repository directly into a new IntelliJ project. +The easiest way to set up your project is to clone the repository directly into a new IntelliJ project. 1. Install IntelliJ 2. Create a new "Project from Version Control..." @@ -147,19 +147,20 @@ The easiest way to set up your project is to load the repository directly into a 1. Install MySQL Server 8 and MySQL Workbench 8. 2. Using Workbench, create a new user with username "cosmic_server" and password "snailshell". - These are the defaults used in Cosmic. + This the default configuration in Cosmic. * (Optional) Restrict the Schema Privileges for this new user for improved security. Add a new entry with "Schemas matching pattern: cosmic" and only select "SELECT", "INSERT", "UPDATE", "DELETE" under "Object Rights" -3. Run the sql scripts in the "sql" directory of the project in the order indicated by their names. - * Make sure you are connected to the database with the "root" user. - * Run scripts through the menu: "File" -> "Run SQL Script" -> select the script file to run -> "Run" +3. Run the sql scripts in the "database/sql" directory of the project in the order indicated by their names. + * Make sure you are connected to the database with the "root" user to be able to run the scripts. + * Run scripts one by one through the menu: "File" -> "Run SQL Script" -> select the script file to run -> "Run" * The 3rd script "3-db_shopupdate" is optional. It adds custom shop items for certain NPCs. + * The 4th script "4-db_admin" is also optional, but recommended if you are new. It adds an admin account to simplify the setup. Use this info when you connect to MySQL Server for the first time: * Server Host: localhost * Port: 3306 * Username: root -* Password: whatever you entered in during the installation of MySQL Server +* Password: At the end of the execution of these sql scripts, you should have installed a database schema named "cosmic". REGISTER YOUR FIRST ACCOUNT to be used in-game by **manually creating** an entry in the table "accounts" in the database with a username and password. @@ -173,7 +174,7 @@ Alternatively, you can use the IP given by Hamachi to use on a Hamachi network, To launch the server, you may either: * Launch inside IntelliJ -* Launch a jar file +* Launch a built jar file * Launch with Docker #### Launch inside IntelliJ @@ -185,17 +186,25 @@ To launch the server, you may either: #### Launch a jar file 1. Create the jar file * The jar file is created by the Maven assembly plugin in the package lifecycle. - * If you have Maven installed on your computer, simply run the command "mvn clean install" to create the jar file. - * IntelliJ also comes with built in Maven support. Open a new terminal window inside IntelliJ, type "mvn clean install" (your command should be marked green), then Ctrl+Enter to create the jar file. + * If you already have Maven installed, simply run the command "mvn clean install" to create the jar file. + * IntelliJ also comes with built-in Maven support. Open a new terminal window inside IntelliJ, type "mvn clean install" (your command should now be marked green), then Ctrl+Enter to build the jar file. 2. Launch the jar file * Double click on "launch.bat" #### Launch with Docker -Run the command "docker compose up" at the root of the project. +1. Start Docker +2. Run the command "docker compose up" at the root of the project. + * If you make any changes to the code, make sure you append the "--build" option at the end of the command to force rebuild the server image. --- ### Creating an account and logging into the game +If you ran the admin sql script, there already exists an account in your database with an admin character on it. You don't need to change its GM level. Log in using these credentials: +* Username: "admin" +* Password: "admin" +* Pin: "0000" +* Pic: "000000" + By default, the server source is set to allow AUTO-REGISTERING. This means that, by simply typing in a "Login ID" and a "Password", you're able to create a new account. After creating a character, experiment typing in all-chat "@commands". diff --git a/database/docker-db-data/.gitignore b/database/docker-db-data/.gitignore new file mode 100644 index 0000000000..e7a210ec7d --- /dev/null +++ b/database/docker-db-data/.gitignore @@ -0,0 +1,3 @@ +* +*/ +!.gitignore \ No newline at end of file diff --git a/sql/1-db_database.sql b/database/sql/1-db_database.sql similarity index 100% rename from sql/1-db_database.sql rename to database/sql/1-db_database.sql diff --git a/sql/2-db_drops.sql b/database/sql/2-db_drops.sql similarity index 100% rename from sql/2-db_drops.sql rename to database/sql/2-db_drops.sql diff --git a/sql/3-db_shopupdate.sql b/database/sql/3-db_shopupdate.sql similarity index 100% rename from sql/3-db_shopupdate.sql rename to database/sql/3-db_shopupdate.sql diff --git a/sql/4-db-admin.sql b/database/sql/4-db-admin.sql similarity index 100% rename from sql/4-db-admin.sql rename to database/sql/4-db-admin.sql diff --git a/sql/errors.txt b/database/sql/errors.txt similarity index 100% rename from sql/errors.txt rename to database/sql/errors.txt diff --git a/sql/readme.txt b/database/sql/readme.txt similarity index 100% rename from sql/readme.txt rename to database/sql/readme.txt diff --git a/docker-compose.yml b/docker-compose.yml index 449b5039da..e6861b0004 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -28,5 +28,5 @@ services: MYSQL_USER: "cosmic_server" MYSQL_PASSWORD: "snailshell" volumes: - - ./docker-db-data:/var/lib/mysql - - ./sql:/docker-entrypoint-initdb.d + - ./database/docker-db-data:/var/lib/mysql + - ./database/sql:/docker-entrypoint-initdb.d