Minecraft-Console-Client/MinecraftClient/Commands/ChangeSlot.cs
ORelio 00112e4c6a Give access to AutoRespond matches inside scripts
Available as %match_u%, %match_1% and so on
See #770 for initial suggestion
See #772 for in-progress implementation
2020-03-27 21:39:06 +01:00

42 lines
1.3 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace MinecraftClient.Commands
{
class ChangeSlot : Command
{
public override string CMDName { get { return "changeslot"; } }
public override string CMDDesc { get { return "changeslot <1-9>: Change hotbar"; } }
public override string Run(McTcpClient handler, string command, Dictionary<string, object> localVars)
{
if (!handler.GetInventoryEnabled()) return "Please enable InventoryHandling in the config file first.";
if (hasArg(command))
{
short slot;
try
{
slot = Convert.ToInt16(getArg(command));
}
catch (FormatException)
{
return "Could not change slot: Not a Number";
}
if (slot >= 1 && slot <= 9)
{
if (handler.ChangeSlot(slot-=1))
{
return "Changed to slot " + (slot+=1);
}
else
{
return "Could not change slot";
}
}
}
return CMDDesc;
}
}
}