Removed unused imports
Fixed invalid SQL statement
Check the player had an inventory before trying to apply the data.