K0bus / CreativeManager

Free Spigot plugin for manage action in Creative
6 stars 12 forks source link

Server config force-gamemode=true breaks inventory saving and loading #22

Closed dblblaster closed 1 year ago

dblblaster commented 2 years ago

Describe the bug My server.properties (papermc) has the force-gamemode=true and gamemode=survival. If within the game an op changes someone's gamemode to creative, and the user logs out and back in, the user's gamemode will be reset to survival.

This plugin doesn't detect this correctly and so the survival inventory gets wiped and the creative inventory gets copied as survival inventory.

To Reproduce Steps to reproduce the behavior:

  1. Server force-gamemode=true and gamemode=survival
  2. User logs in
  3. Op sets gamemode to creative
  4. User logs out
  5. User logs in
  6. User's original survival inventory is wiped and he will instead have the creative inventory copied (without CM restrictions, because he'll be in survival) - blocks placed from the inventory can still be mined.

From the log, it looks like the server changes the gamemode right after the user disconnects, which is not correctly caught by the plugin.

Expected behavior The change of gamemode between log-out and log-in is detected by the plugin, and correct inventory loaded.

Log

01.05 15:25:21 [Server] INFO Save inventory of user dblblaster in file fc5fea03-81c2-3ea5-8942-93293d0b7aed.yml for gamemode SURVIVAL
01.05 15:25:21 [Server] INFO Clear inventory for dblblaster (fc5fea03-81c2-3ea5-8942-93293d0b7aed) because no saved inventory found for gamemode CREATIVE
01.05 15:25:21 [Server] INFO Set dblblaster's game mode to Creative Mode
01.05 15:25:38 [Server] INFO Log saved to database ! [1]
01.05 15:26:16 [Disconnect] User dblblaster has disconnected, reason: Disconnected
01.05 15:26:16 [Server] INFO Save inventory of user dblblaster in file fc5fea03-81c2-3ea5-8942-93293d0b7aed.yml for gamemode CREATIVE
01.05 15:26:16 [Server] INFO dblblaster left the game
01.05 15:26:18 [Server] INFO UUID of player dblblaster is fc5fea03-81c2-3ea5-8942-93293d0b7aed
01.05 15:26:18 [Server] INFO Save inventory of user dblblaster in file fc5fea03-81c2-3ea5-8942-93293d0b7aed.yml for gamemode SURVIVAL
01.05 15:26:18 [Server] INFO Load inventory of user dblblaster in file fc5fea03-81c2-3ea5-8942-93293d0b7aed.yml for gamemode SURVIVAL
01.05 15:26:18 [Server] INFO Load inventory of user dblblaster in file fc5fea03-81c2-3ea5-8942-93293d0b7aed.yml for gamemode SURVIVAL
01.05 15:26:18 [Server] INFO dblblaster joined the game

Server informations: