2020-03-26 15:01:42 +08:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
|
|
|
|
namespace MinecraftClient.Commands
|
|
|
|
|
|
{
|
|
|
|
|
|
class ChangeSlot : Command
|
|
|
|
|
|
{
|
2020-10-17 19:41:31 +08:00
|
|
|
|
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"; } }
|
2020-03-26 15:01:42 +08:00
|
|
|
|
|
2022-10-02 18:31:08 +08:00
|
|
|
|
public override string Run(McClient handler, string command, Dictionary<string, object>? localVars)
|
2020-03-26 15:01:42 +08:00
|
|
|
|
{
|
2020-08-17 23:08:50 +08:00
|
|
|
|
if (!handler.GetInventoryEnabled())
|
2020-10-17 19:41:31 +08:00
|
|
|
|
return Translations.Get("extra.inventory_required");
|
2020-06-20 21:30:23 +02:00
|
|
|
|
|
2022-10-02 18:31:08 +08:00
|
|
|
|
if (HasArg(command))
|
2020-03-26 15:01:42 +08:00
|
|
|
|
{
|
|
|
|
|
|
short slot;
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
2022-10-02 18:31:08 +08:00
|
|
|
|
slot = Convert.ToInt16(GetArg(command));
|
2020-03-26 15:01:42 +08:00
|
|
|
|
}
|
|
|
|
|
|
catch (FormatException)
|
|
|
|
|
|
{
|
2020-10-17 19:41:31 +08:00
|
|
|
|
return Translations.Get("cmd.changeSlot.nan");
|
2020-03-26 15:01:42 +08:00
|
|
|
|
}
|
|
|
|
|
|
if (slot >= 1 && slot <= 9)
|
|
|
|
|
|
{
|
2022-10-02 18:31:08 +08:00
|
|
|
|
if (handler.ChangeSlot(slot -= 1))
|
2020-03-26 15:01:42 +08:00
|
|
|
|
{
|
2022-10-02 18:31:08 +08:00
|
|
|
|
return Translations.Get("cmd.changeSlot.changed", (slot += 1));
|
2020-03-26 15:01:42 +08:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2020-10-17 19:41:31 +08:00
|
|
|
|
return Translations.Get("cmd.changeSlot.fail");
|
2020-03-26 15:01:42 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2020-10-17 19:41:31 +08:00
|
|
|
|
return GetCmdDescTranslated();
|
2020-03-26 15:01:42 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|