mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-10-14 21:22:49 +00:00
48 lines
1.5 KiB
C#
48 lines
1.5 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using Brigadier.NET;
|
|
|
|
namespace MinecraftClient.Commands
|
|
{
|
|
class ChangeSlot : Command
|
|
{
|
|
public override string CmdName { get { return "changeslot"; } }
|
|
public override string CmdUsage { get { return "changeslot <1-9>"; } }
|
|
public override string CmdDesc { get { return "cmd.changeSlot.desc"; } }
|
|
|
|
public override void RegisterCommand(McClient handler, CommandDispatcher<CommandSource> dispatcher)
|
|
{
|
|
}
|
|
|
|
public override string Run(McClient handler, string command, Dictionary<string, object>? localVars)
|
|
{
|
|
if (!handler.GetInventoryEnabled())
|
|
return Translations.Get("extra.inventory_required");
|
|
|
|
if (HasArg(command))
|
|
{
|
|
short slot;
|
|
try
|
|
{
|
|
slot = Convert.ToInt16(GetArg(command));
|
|
}
|
|
catch (FormatException)
|
|
{
|
|
return Translations.Get("cmd.changeSlot.nan");
|
|
}
|
|
if (slot >= 1 && slot <= 9)
|
|
{
|
|
if (handler.ChangeSlot(slot -= 1))
|
|
{
|
|
return Translations.Get("cmd.changeSlot.changed", (slot += 1));
|
|
}
|
|
else
|
|
{
|
|
return Translations.Get("cmd.changeSlot.fail");
|
|
}
|
|
}
|
|
}
|
|
return GetCmdDescTranslated();
|
|
}
|
|
}
|
|
}
|