mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-10-14 21:22:49 +00:00
Code refactoring (related to #1024)
This commit is contained in:
parent
d120001d70
commit
23870711a0
11 changed files with 69 additions and 100 deletions
|
|
@ -9,7 +9,7 @@ namespace MinecraftClient.Commands
|
|||
class Inventory : Command
|
||||
{
|
||||
public override string CMDName { get { return "inventory"; } }
|
||||
public override string CMDDesc { get { return "inventory <<id>|player|container> <list|close|drop <slot> <1|all>|click <slot> <left|right|middle>|creativegive <slot> <itemtype> <count>>: Interact with inventories"; } }
|
||||
public override string CMDDesc { get { return "inventory <<id>|player|container> <list|close|drop <slot> <1|all>|click <slot> <left|right|middle>> | inventory creativegive <slot> <itemtype> <count>: Interact with inventories"; } }
|
||||
|
||||
public override string Run(McTcpClient handler, string command, Dictionary<string, object> localVars)
|
||||
{
|
||||
|
|
@ -34,6 +34,26 @@ namespace MinecraftClient.Commands
|
|||
inventoryId = availableIds[0]; // one container, use it
|
||||
else return "Cannot find container, please retry with explicit ID";
|
||||
}
|
||||
else if (args[0].ToLower() == "creativegive")
|
||||
{
|
||||
if (args.Length >= 4)
|
||||
{
|
||||
int slot = int.Parse(args[1]);
|
||||
ItemType itemType = ItemType.Stone;
|
||||
if (Enum.TryParse(args[2], out itemType))
|
||||
{
|
||||
int count = int.Parse(args[3]);
|
||||
if (handler.DoCreativeGive(slot, itemType, count))
|
||||
return "Requested " + itemType + " x" + count + " in slot #" + slot;
|
||||
else return "Failed to request Creative Give";
|
||||
}
|
||||
else
|
||||
{
|
||||
return CMDDesc;
|
||||
}
|
||||
}
|
||||
else return CMDDesc;
|
||||
}
|
||||
else inventoryId = int.Parse(args[0]);
|
||||
string action = args.Length > 1
|
||||
? args[1].ToLower()
|
||||
|
|
@ -110,32 +130,6 @@ namespace MinecraftClient.Commands
|
|||
}
|
||||
}
|
||||
else return CMDDesc;
|
||||
case "creativegive":
|
||||
if (args.Length >= 3)
|
||||
{
|
||||
int slot = int.Parse(args[2]);
|
||||
ItemType ItemType = ItemType.Stone;
|
||||
if (Enum.TryParse(args[3], out ItemType))
|
||||
{
|
||||
int count = int.Parse(args[4]);
|
||||
Dictionary<string, object> NBT = null;
|
||||
Item item = new Item((int)ItemType, count, NBT);
|
||||
|
||||
if (handler.DoCreativeInventoryAction(slot, item))
|
||||
{
|
||||
return "You have received " + ItemType + " x" + count + " in the slot #" + slot;
|
||||
}
|
||||
else
|
||||
{
|
||||
return "Failed";
|
||||
}
|
||||
}
|
||||
else;
|
||||
{
|
||||
return CMDDesc;
|
||||
}
|
||||
}
|
||||
else return CMDDesc;
|
||||
default:
|
||||
return CMDDesc;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue