code cleanup and respect command return type

This commit is contained in:
Jonas_Jones 2023-09-07 20:23:05 +02:00
parent 3ea416faea
commit 076017bec5
3 changed files with 5 additions and 4 deletions

View file

@ -8,7 +8,7 @@ yarn_mappings=1.20.1+build.10
loader_version=0.14.22
# Mod Properties
mod_version = 0.0.1+alpha-build03
mod_version = 0.0.1+alpha-build04
maven_group = me.jonasjones
archives_base_name = betterconsolemc

View file

@ -6,6 +6,7 @@ import me.jonasjones.betterconsolemc.BetterConsoleMC;
import me.jonasjones.betterconsolemc.cmdconfig.CmdConfigHandler;
import me.jonasjones.betterconsolemc.system.ShellCommand;
import me.jonasjones.betterconsolemc.util.CommandPreRegistry;
import me.jonasjones.betterconsolemc.util.Constants;
import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback;
import net.minecraft.command.CommandRegistryAccess;
import net.minecraft.server.command.CommandManager;
@ -29,7 +30,9 @@ public class GameCommandHandler {
serverCommandSourceCommandDispatcher.register((CommandManager.literal(commandPreRegistry.getIngamecommand()).requires(source -> source.hasPermissionLevel(commandPreRegistry.getPermissionLevel()))
.executes((context -> {
context.getSource().sendFeedback(() -> runCommand(commandPreRegistry, context), commandPreRegistry.doBroadcastToOp());
if (commandPreRegistry.getCommandmode() == Constants.CmdMode.RETURN) {
context.getSource().sendFeedback(() -> runCommand(commandPreRegistry, context), commandPreRegistry.doBroadcastToOp());
}
return 1;
})))
);

View file

@ -36,8 +36,6 @@ public class ShellCommand {
GameCommandHandler.returnCommandOutput(command.getCommand(), line, context);
}
//get the ingame command name
output.append("[").append(command.getIngamecommand()).append("]").append(line).append("\n");
}