itzg / docker-minecraft-server

Docker image that provides a Minecraft Server that will automatically download selected version at startup
https://docker-minecraft-server.readthedocs.io/
Apache License 2.0
9.25k stars 1.53k forks source link

OPS list seem to not work #2930

Closed doman18 closed 1 month ago

doman18 commented 3 months ago

Describe the problem

Im trying to execute /gamerule keepinventory true in my game. But it complains that command is not complete or wrong. Im in the OPS list. Ive tried to execute send-command but it seems it is not included in java edition? Also there is no permissions.json file as ive read here https://github.com/itzg/docker-minecraft-bedrock-server/issues/316. Theres only ops.json

All i want to enable keepinventory so my kid and i can play together casually.

# docker exec -it surv-easy bash

root@66483571be87:/data# printenv | sort
DEBUG=TRUE
DIFFICULTY=easy
EULA=TRUE
GID=1000
HOME=/root
HOSTNAME=66483571be87
JAVA_HOME=/opt/java/openjdk
JAVA_VERSION=jdk-21.0.3+9
LANG=en_US.UTF-8
LANGUAGE=en_US:en
LC_ALL=en_US.UTF-8
LESSCLOSE=/usr/bin/lesspipe %s %s
LESSOPEN=| /usr/bin/lesspipe %s
ONLINE_MODE=FALSE
OPS=tata
PATH=/opt/java/openjdk/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
PWD=/data
SHLVL=0
SNOOPER_ENABLED=FALSE
TERM=xterm
TYPE=VANILLA
UID=1000
_=/usr/bin/printenv
VERSION=LATEST

root@66483571be87:/data# ls
banned-ips.json  banned-players.json  eula.txt  libraries  logs  minecraft_server.1.21.jar  ops.json  server.properties  usercache.json  versions  whitelist.json  world

root@66483571be87:/data# cat ops.json 
[
  {
    "uuid": "c557d99e-9a65-48df-8bac-3429f592d595",
    "name": "tata",
    "level": 4,
    "bypassesPlayerLimit": false
  }
]root@66483571be87:/data#

Container definition

services:
  my-service:
    container_name: surv-easy
    image: itzg/minecraft-server:${DOCKER_MINECRAFT_VERSION}
    tty: true
    stdin_open: true
    environment:
      - EULA=TRUE
      - SNOOPER_ENABLED=FALSE
      - ONLINE_MODE=FALSE
      - DIFFICULTY=$DIFFICULTY
      - OPS=$OPS
      - DEBUG=TRUE
    volumes:
      - surv-easy-vol:/data
    ports:
      - "55555:25565"
    restart: always

volumes:
  surv-easy-vol:

.env

DOCKER_MINECRAFT_VERSION=latest

#https://docker-minecraft-server.readthedocs.io/en/latest/configuration/server-properties
DIFFICULTY=easy
OPS=tata

Container logs

(shortened version)
[08:21:07] [ServerMain/INFO]: Environment: Environment[sessionHost=https://sessionserver.mojang.com, servicesHost=https://api.minecraftservices.com, name=PROD]
[08:21:09] [ServerMain/INFO]: No existing world data, creating new world
[08:21:09] [ServerMain/INFO]: Loaded 1290 recipes
[08:21:10] [ServerMain/INFO]: Loaded 1399 advancements
[08:21:10] [Server thread/INFO]: Starting minecraft server version 1.21
[08:21:10] [Server thread/INFO]: Loading properties
[08:21:10] [Server thread/INFO]: Default game type: SURVIVAL
[08:21:10] [Server thread/INFO]: Generating keypair
[08:21:10] [Server thread/INFO]: Starting Minecraft server on *:25565
[08:21:10] [Server thread/INFO]: Using epoll channel type
[08:21:11] [Server thread/WARN]: **** SERVER IS RUNNING IN OFFLINE/INSECURE MODE!
[08:21:11] [Server thread/WARN]: The server will make no attempt to authenticate usernames. Beware.
[08:21:11] [Server thread/WARN]: While this makes the game possible to play without internet access, it also opens up the ability for hackers to connect with any username they choose.
[08:21:11] [Server thread/WARN]: To change this, set "online-mode" to "true" in the server.properties file.
[08:21:11] [Server thread/INFO]: Preparing level "world"
[08:21:24] [Server thread/INFO]: Preparing start region for dimension minecraft:overworld
[08:21:24] [Worker-Main-1/INFO]: Preparing spawn area: 2%
[08:21:24] [Worker-Main-1/INFO]: Preparing spawn area: 2%
[08:21:25] [Worker-Main-1/INFO]: Preparing spawn area: 2%
[08:21:25] [Worker-Main-1/INFO]: Preparing spawn area: 2%
[08:21:26] [Worker-Main-1/INFO]: Preparing spawn area: 2%
[08:21:26] [Worker-Main-1/INFO]: Preparing spawn area: 2%
[08:21:27] [Worker-Main-1/INFO]: Preparing spawn area: 2%
[08:21:27] [Worker-Main-1/INFO]: Preparing spawn area: 2%
[08:21:28] [Worker-Main-1/INFO]: Preparing spawn area: 2%
[08:21:28] [Worker-Main-1/INFO]: Preparing spawn area: 2%
[08:21:29] [Worker-Main-1/INFO]: Preparing spawn area: 2%
[08:21:29] [Worker-Main-1/INFO]: Preparing spawn area: 2%
[08:21:30] [Worker-Main-1/INFO]: Preparing spawn area: 2%
[08:21:30] [Worker-Main-1/INFO]: Preparing spawn area: 2%
[08:21:31] [Worker-Main-1/INFO]: Preparing spawn area: 2%
[08:21:31] [Worker-Main-1/INFO]: Preparing spawn area: 6%
[08:21:32] [Worker-Main-1/INFO]: Preparing spawn area: 87%
[08:21:32] [Server thread/INFO]: Time elapsed: 8077 ms
[08:21:32] [Server thread/INFO]: Done (21.197s)! For help, type "help"
[08:21:32] [Server thread/INFO]: Starting remote control listener
[08:21:32] [Server thread/INFO]: Thread RCON Listener started
[08:21:32] [Server thread/INFO]: RCON running on 0.0.0.0:25575
[08:22:44] [Server thread/INFO]: tata[/192.168.5.63:47366] logged in with entity id 19 at (0.5, 65.0, 42.5)
[08:22:44] [Server thread/INFO]: tata joined the game
[08:23:53] [Server thread/INFO]: tata lost connection: Disconnected
[08:23:53] [Server thread/INFO]: tata left the game
itzg commented 3 months ago

Set the env var EXISTING_OPS_FILE to "SYNCHRONIZE"

https://docker-minecraft-server.readthedocs.io/en/latest/configuration/server-properties/#opadministrator-players

Unfortunately the default of "SKIP" is not immediately intuitive but was implemented as such for backward compatibility. Your issue makes me think I should change that default to improve the usability of more typical usage.

doman18 commented 3 months ago

Still doesn't work. I cant use any commands.

services:
  my-service:
    container_name: surv-easy
    # link to project
    # always use versioning to be able to rollback
    image: itzg/minecraft-server:${DOCKER_MINECRAFT_VERSION}
    tty: true
    stdin_open: true
    environment:
      - EULA=TRUE
      - SNOOPER_ENABLED=FALSE
      - ONLINE_MODE=FALSE
      - DIFFICULTY=$DIFFICULTY
      - OPS=$OPS
      - DEBUG=TRUE
      - EXISTING_OPS_FILE=SYNCHRONIZE
    volumes:
      - surv-easy-vol:/data
    ports:
      - "55555:25565"
    restart: always
root@10a705adda82:/data# printenv | sort
DEBUG=TRUE
DIFFICULTY=easy
EULA=TRUE
EXISTING_OPS_FILE=SYNCHRONIZE
GID=1000
HOME=/root
HOSTNAME=10a705adda82
JAVA_HOME=/opt/java/openjdk
JAVA_VERSION=jdk-21.0.3+9
LANG=en_US.UTF-8
LANGUAGE=en_US:en
LC_ALL=en_US.UTF-8
LESSCLOSE=/usr/bin/lesspipe %s %s
LESSOPEN=| /usr/bin/lesspipe %s
ONLINE_MODE=FALSE
OPS=tata
PATH=/opt/java/openjdk/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
PWD=/data
SHLVL=0
SNOOPER_ENABLED=FALSE
TERM=xterm
TYPE=VANILLA
UID=1000
_=/usr/bin/printenv
VERSION=LATEST
itzg commented 3 months ago

Can you check the contents of ops.json? All the container startup is doing is updating that file. Since you have debug enabled can you provide the container startup logs?

kawogi commented 3 months ago

Wild guess which might be irrelevant: what's the value of op-permission-level in your server.properties?

itzg commented 3 months ago

I just noticed you have

ONLINE_MODE=FALSE

That might be interfering with UUID matching of the connecting player. Speaking of UUID, you might need to provide a UUID rather than username for OPS. One way to identify that user's UUID is to watch the logs.

doman18 commented 3 months ago

Here are things you asked logs (last part)

Starting net.minecraft.server.Main
[17:52:11] [ServerMain/INFO]: Environment: Environment[sessionHost=https://sessionserver.mojang.com, servicesHost=https://api.minecraftservices.com, name=PROD]
[17:52:13] [ServerMain/INFO]: Loaded 1290 recipes
[17:52:13] [ServerMain/INFO]: Loaded 1399 advancements
[17:52:14] [Server thread/INFO]: Starting minecraft server version 1.21
[17:52:14] [Server thread/INFO]: Loading properties
[17:52:14] [Server thread/INFO]: Default game type: SURVIVAL
[17:52:14] [Server thread/INFO]: Generating keypair
[17:52:14] [Server thread/INFO]: Starting Minecraft server on *:25565
[17:52:14] [Server thread/INFO]: Using epoll channel type
[17:52:14] [Server thread/WARN]: **** SERVER IS RUNNING IN OFFLINE/INSECURE MODE!
[17:52:14] [Server thread/WARN]: The server will make no attempt to authenticate usernames. Beware.
[17:52:14] [Server thread/WARN]: While this makes the game possible to play without internet access, it also opens up the ability for hackers to connect with any username they choose.
[17:52:14] [Server thread/WARN]: To change this, set "online-mode" to "true" in the server.properties file.
[17:52:14] [Server thread/INFO]: Preparing level "world"
[17:52:23] [Server thread/INFO]: Preparing start region for dimension minecraft:overworld
[17:52:24] [Worker-Main-1/INFO]: Preparing spawn area: 0%
[17:52:24] [Worker-Main-1/INFO]: Preparing spawn area: 0%
[17:52:24] [Server thread/INFO]: Time elapsed: 697 ms
[17:52:24] [Server thread/INFO]: Done (10.245s)! For help, type "help"
[17:52:24] [Server thread/INFO]: Starting remote control listener
[17:52:24] [Server thread/INFO]: Thread RCON Listener started
[17:52:24] [Server thread/INFO]: RCON running on 0.0.0.0:25575
[17:53:24] [Server thread/INFO]: tata[/192.168.20.46:40506] logged in with entity id 32 at (-239.10308460159555, 64.0, -1320.6409633029562)
[17:53:24] [Server thread/INFO]: tata joined the game
[17:53:29] [Server thread/WARN]: Can't keep up! Is the server overloaded? Running 2015ms or 40 ticks behind
[17:54:50] [Server thread/INFO]: tata lost connection: Disconnected
[17:54:50] [Server thread/INFO]: tata left the game
[17:58:59] [Server thread/INFO]: tata[/192.168.20.46:59656] logged in with entity id 783 at (-180.26418320546216, 70.0, -1358.71058716503)
[17:58:59] [Server thread/INFO]: tata joined the game
[17:59:27] [Server thread/INFO]: tata lost connection: Disconnected
[17:59:27] [Server thread/INFO]: tata left the game
[18:07:14] [Server thread/INFO]: tata[/192.168.20.46:56844] logged in with entity id 1235 at (-180.26418320546216, 70.0, -1358.71058716503)
[18:07:14] [Server thread/INFO]: tata joined the game
[20:14:58] [Server thread/INFO]: tata lost connection: Disconnected
[20:14:58] [Server thread/INFO]: tata left the game
[21:45:51] [Server thread/WARN]: handleDisconnection() called twice
[06:16:26] [Server thread/WARN]: handleDisconnection() called twice
root@10a705adda82:/data# cat ops.json 
[
  {
    "uuid": "c557d99e-9a65-48df-8bac-3429f592d595",
    "name": "tata",
    "level": 4,
    "bypassesPlayerLimit": false
  }
]

root@10a705adda82:/data# cat server.properties 
#Minecraft server properties
#Mon Jul 01 17:52:11 UTC 2024
accepts-transfers=false
allow-flight=false
allow-nether=true
broadcast-console-to-ops=true
broadcast-rcon-to-ops=true
bug-report-link=
difficulty=easy
enable-command-block=false
enable-jmx-monitoring=false
enable-query=false
enable-rcon=true
enable-status=true
enforce-secure-profile=true
enforce-whitelist=false
entity-broadcast-range-percentage=100
force-gamemode=false
function-permission-level=2
gamemode=survival
generate-structures=true
generator-settings={}
hardcore=false
hide-online-players=false
initial-disabled-packs=
initial-enabled-packs=vanilla
level-name=world
level-seed=
level-type=minecraft\:normal
log-ips=true
max-chained-neighbor-updates=1000000
max-players=20
max-tick-time=60000
max-world-size=29999984
motd=A Minecraft Server
network-compression-threshold=256
online-mode=false
op-permission-level=4
player-idle-timeout=0
prevent-proxy-connections=false
pvp=true
query.port=25565
rate-limit=0
rcon.password=<censored>
rcon.port=25575
region-file-compression=deflate
require-resource-pack=false
resource-pack=
resource-pack-id=
resource-pack-prompt=
resource-pack-sha1=
server-ip=
server-port=25565
simulation-distance=10
snooper-enabled=false
spawn-animals=true
spawn-monsters=true
spawn-npcs=true
spawn-protection=16
sync-chunk-writes=true
text-filtering-config=
use-native-transport=true
view-distance=10
white-list=false

I just noticed you have

ONLINE_MODE=FALSE

That might be interfering with UUID matching of the connecting player. Speaking of UUID, you might need to provide a UUID rather than username for OPS. One way to identify that user's UUID is to watch the logs.

But as you see in the logs this id is changing. Few years ago i've been using this docker container and it worked with names in offline mode. I could use commands with no problem. Unfortunately i don't have that config anymore.

itzg commented 3 months ago

I'm sorry that the Minecraft server is not working the way it used to for you, but there's nothing I can do. Your ops.json has the correct content or if I'm missing something there then please point it out.

root@10a705adda82:/data# cat ops.json 
[
  {
    "uuid": "c557d99e-9a65-48df-8bac-3429f592d595",
    "name": "tata",
    "level": 4,
    "bypassesPlayerLimit": false
  }
]

That's all the container startup is responsible for. The remainder is behavior you'll need to report with Mojang; however, since you're running offline they probably don't provide support. Can you re-enable online mode perhaps? I'm guessing with 1.21 or otherwise recently they changed the entity ID handling of offline players.

github-actions[bot] commented 2 months ago

This issue is stale because it has been open 30 days with no activity. Please add a comment describing the reason to keep this issue open.