Skip to content

Add ChatCommands & New ConsoleCommands#939

Closed
KKNecmi wants to merge 23 commits intosmartcmd:mainfrom
KKNecmi:chatcommands
Closed

Add ChatCommands & New ConsoleCommands#939
KKNecmi wants to merge 23 commits intosmartcmd:mainfrom
KKNecmi:chatcommands

Conversation

@KKNecmi
Copy link
Contributor

@KKNecmi KKNecmi commented Mar 8, 2026

Description

it adds the chat commands was left not finished

Changes

Added arg parsing to handlecommand() to check added commands also changed minecraftserver.cpp to add some commands to console

Previous Behavior

the game was looking messages starts with / but wasnt doing anything with it before changing there was a comment "4J - TODO"

Root Cause

not finished command system

New Behavior

it checks some keywords like /kill /gamemode if handlechat() finds / in the message start and check right args if not give a sendmessage to show args for that command

Fix Implementation

added arg parser to handlecommand() and with if statemens looked available commands if not give a sendmessage "unkown command"

AI Use Disclosure

ai was used to format some hard bracket insides and mapping item,tile,entity names for giveitem,setblock/fill,summon for time saving

Related Issues

  • Fixes Nothing
  • Related to Nothing

@KKNecmi KKNecmi marked this pull request as draft March 8, 2026 10:41
@KKNecmi KKNecmi marked this pull request as ready for review March 9, 2026 02:53
@lspepinho
Copy link
Contributor

Could you add /tp to coordinates?

@KKNecmi
Copy link
Contributor Author

KKNecmi commented Mar 9, 2026

oh yeah i missed that completely im going to add /particle soon i will add that with this

@codeHusky
Copy link
Collaborator

This is too messy. 4J had the basics of a command system setup and this just guts it in favor of a lot of hard coded magic values and fixed strings. This isn't a super maintainable way to have a command system unfortunately. If you refactor this to use the actual command system we could consider this, but make sure the isolated dedicated server project isn't already doing this before you waste time doing what's already been done. Thanks for the contribution.

@codeHusky codeHusky closed this Mar 10, 2026
@KKNecmi
Copy link
Contributor Author

KKNecmi commented Mar 10, 2026

Thanks for the feedback. Could you pinpoint the code snippets for the "basics of a command system setup" you're talking about? I saw the "4J - TODO" on message 4J put on handlecommand, so thought that was the basic command system and just finished that part of the code. Also, could you specify more explicitly what numbers and variables you take issue with? I can add more comments to clarify what the variables, numbers, and some functions do, but I'm a little confused on what I'm doing wrong here. I checked the dedicated server fork and they haven't done anything for the ingame chat, just for commands input in the CMD terminal of the server. Aswell as this, the only non-server specific command they added was /gamemode, which is broken in the latest commit of the dedicated server.

Commands already in the source code:
/help, /stop, /list, /say, /save-all, /time, /weather, /tp, /give , /enchant, /kill, /gamemode (/gamemode wasn't implimented in -server)

Commands added by Kuwacoms dedicated server:
/ban, /ban-ip, /pardon, /pardon-ip, /banlist, /gamemode.

Commands added by me:
/summon, /effect.

Before my edits there weren't any chat commands, only ones that worked in -server, or when Minecraft.Server.exe was ran. Now with my edits all these commands run both in chat and in -server.
The only ones that don't work in chat are the ones in the dedicated server fork (which i can add), and some server exclusive commands (/help, /save-all, /say, /stop)

return true;
}

if (action == L"summon")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, this particular non-modular implementation of commands in addition to the various independent command .cpp/.h files is confusing and not very good architecturally. Ideally these should be unified and all of our commands should be implemented in their own files. Having this duplicate implementation is messy and just not good for maintainability long term.

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.

3 participants