Skip to content

[Reference] PostgreSQL + Core Development #59

Open
MujyKun wants to merge 99 commits intoiw2d:mainfrom
MujyKun:main
Open

[Reference] PostgreSQL + Core Development #59
MujyKun wants to merge 99 commits intoiw2d:mainfrom
MujyKun:main

Conversation

@MujyKun
Copy link

@MujyKun MujyKun commented Oct 9, 2025

This PR is currently READY FOR REFERENCE.

It's not expected for this PR to be merged (given the difference in size), but is kept open to reference changes that may end up going to this repo.

This PR is to add PostgreSQL as an officially supported database.
In addition, it also adds a new command structure.

Generalized Changes:

  • Docker Compose has been combined for PostgreSQL and Cassandra
  • A .env.example file has been added and SHOULD be used. For Cassandra, a .env file is not needed due to default params favoring Cassandra, but I'd recommend adding it.
    -> getEnv functions have been updated to also use .env files, and will not raise an exception if there is no .env file.
  • Updated the README to include client downloads as well as proper docker setup.
  • Added a STAFF prefix command, and a player prefix command. (This will help setup for command factory changes incoming)

SRC Changes

  • Added Database parameters to ServerConstants
  • Added a forced database connection based on the database name.
  • Added some more robust constructors to the models that takes in all necessary parameters.
  • Added a type to inventories themselves.
  • Added PostgreSQL functions and Dao (Data Access Object) types to help manage server objects.
  • Added Hikari warning messages in Log4J config
  • Added !whereami command
  • Added logging for which port fails to bind to a channel.
  • Added utility/kill_ports.bat because oh help me god if I have to manually kill processes using up the server ports again.
  • Added default saveAll to GuildAccessor. Will save on shutdown. Helps since we don't insert to db when creating a BoardEntry or comment.
  • Added a way to access the data storages functions from anywhere in the code base (I looked around for a bit, and it seemed weird that there was no way to get users by their ID unless you had access to the central server node, but there was no way to get access to the central server node). This will definitely be needed in the future, so adding it now. When creating advanced commands or events, it'll be very useful. It seems this was already added to an open PR.
  • Added identifier to know if a user is in the cash shop.
  • Added an ItemAccessor specifically for relational DBs, does not affect NoSQL DBs. It seems like there will be cases where an item may need to be saved. There's a way to create a new item through the id accessor, but leaving an implementation there for saving. This also has the logic for deleting ghost items (items with no owner) on startup.
  • Made CharacterRankData an abstract database type since postgresql uses it as well. (src/main/java/kinoko/database/types/CharacterRankData)
  • Added new command structure.
  • Added new AdminLevel enum and added it to CharacterStat.
  • New characters in a dev environment (Tespia) automatically become Admin.

SN Generation:

Any SNs generated when using a relational database expect the default SN of an item to be <= 0 unless it is set by the database itself. There is careful management to make sure this doesn't go out of sync. For this Postgres implementation specifically, any item will be available in item.Items regardless if it is in a player's inventory, trunk, locker, wishlist, gifted, or dropped. This introduces a flaw where cleanup is not appropriately done on item.Items, but can easily be queried. My concern was that if a player has an item dropped, it still does contain that specific SN, and the database has no information on dropped objects. Most likely will have a function that does cleanup on initialization (server launch), when we know there are no dropped items.

Bug Fix:

  • If an account does not already exist and auto creation is on, then log the player in immediately instead of saying the account does not exist.
  • Fixed Console messages that did not show stack traces on errors in log4j.
  • [Critical] Fixed Player Shop Bug in PersonalShop.java. Say you had 50 apples. You attempt to put 30 in, it will not create a partial item, but rather use the original item. This means you have items with the same SN existing in more than one place simultaneously. The issue resided with the quantity of the original item getting updated before we did a conditional check on the amount the user had in their inventory. Stored a variable that holds the original quantity, now stacked items are partialItems.
  • If a player previews a pet in the cash shop, there are PetMove packets being sent for the character's real pets. This is unnecessary and is now being filtered out if the user is in the cash shop.
  • If PINs are disabled, do not request one when gifting an item in the cash shop.

In Game Checklist:

Account Creation ✅
Character Creation ✅
Cash Shop Gifting ✅
Cash Shop Locker ✅
Storage Trunk ✅
Inventory Management ✅
Personal Player Shops ✅
-> Bundled Item SN carries through the player shop and shows the invetory item quantity in the player shop
-> This needs to be handled similar to player trades with the Item getting a new SN
Player Trades✅
Faming ✅
Quests ✅
-> In Progress Saves ✅
-> Completion Saves ✅
-> Works for the most part? Found a weird glitch at perion 20 stumps training quest that had reset it to 0. ⏳
Dropping and Picking up Batched & Unbatched Items on a diff char (Same ItemSN) ✅
Wild Hunter ✅
Map Transfer ❓idk how to test this, but it'll work.
Buddy List ✅
Guilds ✅
-> Creating Guilds ✅
-> Board Entries ✅
-> Loading Board Comments ✅
-> Saving Board Comments ✅
-> Board Notices ✅
-> Leaving Guild ✅
-> Joining Guild ✅
-> Disbanding Guild ✅
-> Kicking From Guild ✅
-> Editing/Saving Guild Positions/Grades ✅
-> Modifying Player Guild Grades ✅
-> Guild Main Announcement/Notice Message ✅
-> Expanding Guild ✅
-> Register Guild Emblem ✅
-> Delete Guild Emblem ✅
-> Modify Guild Emblem ✅
-> Change Guild Leader (Not possible yet?) ❌

Parties ✅
Guild Online Status ✅

Marriage Rings ✅
Friendship Rings ✅
Ability Point Stats ✅
Skill Saving✅
Available Skill Points ✅
Skill Macros ✅
Pets ✅
Multi-Pets ✅

In Game Commands for each AdminLevel ✅

In Code Checklist:

-> Ensure connections are appropriately closed ✅
-> Ensure transactions are appropriately handled to prevent dupes. ✅


  • Added Schema Updater
  • Added Bans
  • Renamed !find to !search and added find as an alias
  • Adding Lynx's scripts to Kinoko
  • Added BanInfo
  • Added Ban Commands
  • Added & refactored new commands from Lynx (online, goto, whodrops, heal, summon, dc, notice, noticeb, noticer, say, kill, killmap, healmap, hide, unhide)
  • Added high level functions to CentralServerNode, User, ChannelServerNode
  • Added storage of the full ChannelServerNodes for more appropriate high level functionality. This will make tasks such as warping players or getting all connected users much easier.
  • Replaced all user.write(MessagePacket.system(...)) with user.systemMessage
  • Implemented Families
  • Added Skill Handling for GM (900) | SUPER_GM (910)
  • Added Global EXP/DROP/MESOS rate modifiers.
  • Added Family EXP/DROP modifiers
  • Added Personal Family EXP/DROP modifiers.
  • Added high level family functions to CentralServerNode
  • Added Timing class to simplify commonly called timer related functions. Has convenient functions such as logDuration, to log how long it takes to complete a function.
  • Added THIS PR to fix cash exclusive body part items, where it was checking the wrong item position.
  • Added Alias !killall to !killmobs
  • Removed Unhide command, the Hide command is now a toggle.
  • Added GM / SUPERGM skills.
  • Added Field buffs (still restricted by skill range)

Note: Family database functions need to be added for Cassandra (but are implemented for Postgresql)
Note: BanInfo needs to be implemented for Cassandra.

@MujyKun MujyKun marked this pull request as draft October 9, 2025 19:34
@MujyKun MujyKun marked this pull request as ready for review October 14, 2025 23:16
@MujyKun MujyKun changed the title [WIP] Adding support for PostgreSQL as an alternate database. [READY] Adding support for PostgreSQL as an alternate database. Oct 14, 2025
Added & refactored new commands from Lynx (online, goto, whodrops, heal, summon, dc, notice, noticeb, noticer, say, kill, killmap, healmap, hide, unhide)
Added high level functions to CentralServerNode, User, ChannelServerNode
Added storage of the full ChannelServerNodes for more appropriate high level functionality. This will make tasks such as warping players or getting all connected users much easier.
Replaced all user.write(MessagePacket.system( with user.systemMessage(
@MujyKun MujyKun mentioned this pull request Nov 5, 2025
@MujyKun MujyKun changed the title [READY] Adding support for PostgreSQL as an alternate database. [Reference] PostgreSQL + Core Development Nov 24, 2025
@MujyKun MujyKun mentioned this pull request Nov 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants