mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2026-08-29 13:04:59 +00:00
Bug fix
This commit is contained in:
parent
127978615c
commit
94a3c92b36
62 changed files with 371 additions and 297 deletions
|
|
@ -10,7 +10,7 @@ namespace MinecraftClient.Commands
|
|||
public override string CmdUsage { get { return "animation <mainhand|offhand>"; } }
|
||||
public override string CmdDesc { get { return Translations.cmd_animation_desc; } }
|
||||
|
||||
public override void RegisterCommand(McClient handler, CommandDispatcher<CmdResult> dispatcher)
|
||||
public override void RegisterCommand(CommandDispatcher<CmdResult> dispatcher)
|
||||
{
|
||||
dispatcher.Register(l => l.Literal("help")
|
||||
.Then(l => l.Literal(CmdName)
|
||||
|
|
@ -23,11 +23,11 @@ namespace MinecraftClient.Commands
|
|||
);
|
||||
|
||||
dispatcher.Register(l => l.Literal(CmdName)
|
||||
.Executes(r => DoAnimation(r.Source, handler, mainhand: true))
|
||||
.Executes(r => DoAnimation(r.Source, mainhand: true))
|
||||
.Then(l => l.Literal("mainhand")
|
||||
.Executes(r => DoAnimation(r.Source, handler, mainhand: true)))
|
||||
.Executes(r => DoAnimation(r.Source, mainhand: true)))
|
||||
.Then(l => l.Literal("offhand")
|
||||
.Executes(r => DoAnimation(r.Source, handler, mainhand: false)))
|
||||
.Executes(r => DoAnimation(r.Source, mainhand: false)))
|
||||
.Then(l => l.Literal("_help")
|
||||
.Redirect(dispatcher.GetRoot().GetChild("help").GetChild(CmdName)))
|
||||
);
|
||||
|
|
@ -45,8 +45,9 @@ namespace MinecraftClient.Commands
|
|||
});
|
||||
}
|
||||
|
||||
private static int DoAnimation(CmdResult r, McClient handler, bool mainhand)
|
||||
private static int DoAnimation(CmdResult r, bool mainhand)
|
||||
{
|
||||
McClient handler = CmdResult.currentHandler!;
|
||||
return r.SetAndReturn(handler.DoAnimation(mainhand ? 1 : 0));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ namespace MinecraftClient.Commands
|
|||
public override string CmdUsage { get { return "bed leave|sleep <x> <y> <z>|sleep <radius>"; } }
|
||||
public override string CmdDesc { get { return Translations.cmd_bed_desc; } }
|
||||
|
||||
public override void RegisterCommand(McClient handler, CommandDispatcher<CmdResult> dispatcher)
|
||||
public override void RegisterCommand(CommandDispatcher<CmdResult> dispatcher)
|
||||
{
|
||||
dispatcher.Register(l => l.Literal("help")
|
||||
.Then(l => l.Literal(CmdName)
|
||||
|
|
@ -30,12 +30,12 @@ namespace MinecraftClient.Commands
|
|||
|
||||
dispatcher.Register(l => l.Literal(CmdName)
|
||||
.Then(l => l.Literal("leave")
|
||||
.Executes(r => DoLeaveBed(r.Source, handler)))
|
||||
.Executes(r => DoLeaveBed(r.Source)))
|
||||
.Then(l => l.Literal("sleep")
|
||||
.Then(l => l.Argument("Location", MccArguments.Location())
|
||||
.Executes(r => DoSleepBedWithLocation(r.Source, handler, MccArguments.GetLocation(r, "Location"))))
|
||||
.Executes(r => DoSleepBedWithLocation(r.Source, MccArguments.GetLocation(r, "Location"))))
|
||||
.Then(l => l.Argument("Radius", Arguments.Double())
|
||||
.Executes(r => DoSleepBedWithRadius(r.Source, handler, Arguments.GetDouble(r, "Radius")))))
|
||||
.Executes(r => DoSleepBedWithRadius(r.Source, Arguments.GetDouble(r, "Radius")))))
|
||||
.Then(l => l.Literal("_help")
|
||||
.Redirect(dispatcher.GetRoot().GetChild("help").GetChild(CmdName)))
|
||||
);
|
||||
|
|
@ -53,13 +53,15 @@ namespace MinecraftClient.Commands
|
|||
});
|
||||
}
|
||||
|
||||
private static int DoLeaveBed(CmdResult r, McClient handler)
|
||||
private static int DoLeaveBed(CmdResult r)
|
||||
{
|
||||
McClient handler = CmdResult.currentHandler!;
|
||||
return r.SetAndReturn(Translations.cmd_bed_leaving, handler.SendEntityAction(Protocol.EntityActionType.LeaveBed));
|
||||
}
|
||||
|
||||
private static int DoSleepBedWithRadius(CmdResult r, McClient handler, double radius)
|
||||
private static int DoSleepBedWithRadius(CmdResult r, double radius)
|
||||
{
|
||||
McClient handler = CmdResult.currentHandler!;
|
||||
if (!handler.GetTerrainEnabled())
|
||||
return r.SetAndReturn(Status.FailNeedTerrain);
|
||||
|
||||
|
|
@ -153,8 +155,9 @@ namespace MinecraftClient.Commands
|
|||
}
|
||||
}
|
||||
|
||||
private static int DoSleepBedWithLocation(CmdResult r, McClient handler, Location block)
|
||||
private static int DoSleepBedWithLocation(CmdResult r, Location block)
|
||||
{
|
||||
McClient handler = CmdResult.currentHandler!;
|
||||
if (!handler.GetTerrainEnabled())
|
||||
return r.SetAndReturn(Status.FailNeedTerrain);
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ namespace MinecraftClient.Commands
|
|||
public override string CmdUsage { get { return "blockinfo <x> <y> <z> [-s]"; } }
|
||||
public override string CmdDesc { get { return Translations.cmd_blockinfo_desc; } }
|
||||
|
||||
public override void RegisterCommand(McClient handler, CommandDispatcher<CmdResult> dispatcher)
|
||||
public override void RegisterCommand(CommandDispatcher<CmdResult> dispatcher)
|
||||
{
|
||||
dispatcher.Register(l => l.Literal("help")
|
||||
.Then(l => l.Literal(CmdName)
|
||||
|
|
@ -24,13 +24,13 @@ namespace MinecraftClient.Commands
|
|||
);
|
||||
|
||||
dispatcher.Register(l => l.Literal(CmdName)
|
||||
.Executes(r => LogBlockInfo(r.Source, handler, handler.GetCurrentLocation(), false))
|
||||
.Executes(r => LogBlockInfo(r.Source, null, false))
|
||||
.Then(l => l.Literal("-s")
|
||||
.Executes(r => LogBlockInfo(r.Source, handler, handler.GetCurrentLocation(), true)))
|
||||
.Executes(r => LogBlockInfo(r.Source, null, true)))
|
||||
.Then(l => l.Argument("Location", MccArguments.Location())
|
||||
.Executes(r => LogBlockInfo(r.Source, handler, MccArguments.GetLocation(r, "Location"), false))
|
||||
.Executes(r => LogBlockInfo(r.Source, MccArguments.GetLocation(r, "Location"), false))
|
||||
.Then(l => l.Literal("-s")
|
||||
.Executes(r => LogBlockInfo(r.Source, handler, MccArguments.GetLocation(r, "Location"), true))))
|
||||
.Executes(r => LogBlockInfo(r.Source, MccArguments.GetLocation(r, "Location"), true))))
|
||||
.Then(l => l.Literal("_help")
|
||||
.Redirect(dispatcher.GetRoot().GetChild("help").GetChild(CmdName)))
|
||||
);
|
||||
|
|
@ -47,13 +47,18 @@ namespace MinecraftClient.Commands
|
|||
});
|
||||
}
|
||||
|
||||
private static int LogBlockInfo(CmdResult r, McClient handler, Location targetBlock, bool reportSurrounding)
|
||||
private static int LogBlockInfo(CmdResult r, Location? targetBlock, bool reportSurrounding)
|
||||
{
|
||||
McClient handler = CmdResult.currentHandler!;
|
||||
if (!handler.GetTerrainEnabled())
|
||||
return r.SetAndReturn(Status.FailNeedTerrain);
|
||||
|
||||
targetBlock.ToAbsolute(handler.GetCurrentLocation());
|
||||
Block block = handler.GetWorld().GetBlock(targetBlock);
|
||||
if (targetBlock.HasValue)
|
||||
targetBlock.Value.ToAbsolute(handler.GetCurrentLocation());
|
||||
else
|
||||
targetBlock = handler.GetCurrentLocation();
|
||||
|
||||
Block block = handler.GetWorld().GetBlock(targetBlock.Value);
|
||||
|
||||
handler.Log.Info($"{Translations.cmd_blockinfo_BlockType}: {block.GetTypeString()}");
|
||||
if (reportSurrounding)
|
||||
|
|
@ -61,12 +66,13 @@ namespace MinecraftClient.Commands
|
|||
StringBuilder sb = new();
|
||||
sb.AppendLine($"{Translations.cmd_blockinfo_BlocksAround}:");
|
||||
|
||||
Block blockXPositive = handler.GetWorld().GetBlock(new Location(targetBlock.X + 1, targetBlock.Y, targetBlock.Z));
|
||||
Block blockXNegative = handler.GetWorld().GetBlock(new Location(targetBlock.X - 1, targetBlock.Y, targetBlock.Z));
|
||||
Block blockYPositive = handler.GetWorld().GetBlock(new Location(targetBlock.X, targetBlock.Y + 1, targetBlock.Z));
|
||||
Block blockYNegative = handler.GetWorld().GetBlock(new Location(targetBlock.X, targetBlock.Y - 1, targetBlock.Z));
|
||||
Block blockZPositive = handler.GetWorld().GetBlock(new Location(targetBlock.X, targetBlock.Y, targetBlock.Z + 1));
|
||||
Block blockZNegative = handler.GetWorld().GetBlock(new Location(targetBlock.X, targetBlock.Y, targetBlock.Z - 1));
|
||||
double X = targetBlock.Value.X, Y = targetBlock.Value.Y, Z = targetBlock.Value.Z;
|
||||
Block blockXPositive = handler.GetWorld().GetBlock(new Location(X + 1, Y, Z));
|
||||
Block blockXNegative = handler.GetWorld().GetBlock(new Location(X - 1, Y, Z));
|
||||
Block blockYPositive = handler.GetWorld().GetBlock(new Location(X, Y + 1, Z));
|
||||
Block blockYNegative = handler.GetWorld().GetBlock(new Location(X, Y - 1, Z));
|
||||
Block blockZPositive = handler.GetWorld().GetBlock(new Location(X, Y, Z + 1));
|
||||
Block blockZNegative = handler.GetWorld().GetBlock(new Location(X, Y, Z - 1));
|
||||
|
||||
sb.AppendLine($"[X {Translations.cmd_blockinfo_Positive}] {Translations.cmd_blockinfo_BlockType}: {blockXPositive.GetTypeString()}");
|
||||
sb.AppendLine($"[X {Translations.cmd_blockinfo_Negative}] {Translations.cmd_blockinfo_BlockType}: {blockXNegative.GetTypeString()}");
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ namespace MinecraftClient.Commands
|
|||
public override string CmdUsage { get { return "bots [list|unload <bot name|all>]"; } }
|
||||
public override string CmdDesc { get { return Translations.cmd_bots_desc; } }
|
||||
|
||||
public override void RegisterCommand(McClient handler, CommandDispatcher<CmdResult> dispatcher)
|
||||
public override void RegisterCommand(CommandDispatcher<CmdResult> dispatcher)
|
||||
{
|
||||
dispatcher.Register(l => l.Literal("help")
|
||||
.Then(l => l.Literal(CmdName)
|
||||
|
|
@ -26,12 +26,12 @@ namespace MinecraftClient.Commands
|
|||
);
|
||||
|
||||
dispatcher.Register(l => l.Literal(CmdName)
|
||||
.Executes(r => DoListBot(r.Source, handler))
|
||||
.Executes(r => DoListBot(r.Source))
|
||||
.Then(l => l.Literal("list")
|
||||
.Executes(r => DoListBot(r.Source, handler)))
|
||||
.Executes(r => DoListBot(r.Source)))
|
||||
.Then(l => l.Literal("unload")
|
||||
.Then(l => l.Argument("BotName", MccArguments.BotName())
|
||||
.Executes(r => DoUnloadBot(r.Source, handler, Arguments.GetString(r, "BotName")))))
|
||||
.Executes(r => DoUnloadBot(r.Source, Arguments.GetString(r, "BotName")))))
|
||||
.Then(l => l.Literal("_help")
|
||||
.Redirect(dispatcher.GetRoot().GetChild("help").GetChild(CmdName)))
|
||||
);
|
||||
|
|
@ -49,8 +49,9 @@ namespace MinecraftClient.Commands
|
|||
});
|
||||
}
|
||||
|
||||
private int DoListBot(CmdResult r, McClient handler)
|
||||
private int DoListBot(CmdResult r)
|
||||
{
|
||||
McClient handler = CmdResult.currentHandler!;
|
||||
int length = handler.GetLoadedChatBots().Count;
|
||||
if (length == 0)
|
||||
return r.SetAndReturn(CmdResult.Status.Fail, Translations.cmd_bots_noloaded);
|
||||
|
|
@ -66,8 +67,9 @@ namespace MinecraftClient.Commands
|
|||
return r.SetAndReturn(CmdResult.Status.Done, Translations.cmd_bots_list + ": " + sb.ToString());
|
||||
}
|
||||
|
||||
private int DoUnloadBot(CmdResult r, McClient handler, string botName)
|
||||
private int DoUnloadBot(CmdResult r, string botName)
|
||||
{
|
||||
McClient handler = CmdResult.currentHandler!;
|
||||
if (botName.ToLower().Equals("all", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
if (handler.GetLoadedChatBots().Count == 0)
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ namespace MinecraftClient.Commands
|
|||
public override string CmdUsage { get { return "changeslot <1-9>"; } }
|
||||
public override string CmdDesc { get { return Translations.cmd_changeSlot_desc; } }
|
||||
|
||||
public override void RegisterCommand(McClient handler, CommandDispatcher<CmdResult> dispatcher)
|
||||
public override void RegisterCommand(CommandDispatcher<CmdResult> dispatcher)
|
||||
{
|
||||
dispatcher.Register(l => l.Literal("help")
|
||||
.Then(l => l.Literal(CmdName)
|
||||
|
|
@ -21,7 +21,7 @@ namespace MinecraftClient.Commands
|
|||
|
||||
dispatcher.Register(l => l.Literal(CmdName)
|
||||
.Then(l => l.Argument("Slot", MccArguments.HotbarSlot())
|
||||
.Executes(r => DoChangeSlot(r.Source, handler, Arguments.GetInteger(r, "Slot"))))
|
||||
.Executes(r => DoChangeSlot(r.Source, Arguments.GetInteger(r, "Slot"))))
|
||||
.Then(l => l.Literal("_help")
|
||||
.Redirect(dispatcher.GetRoot().GetChild("help").GetChild(CmdName)))
|
||||
);
|
||||
|
|
@ -37,8 +37,9 @@ namespace MinecraftClient.Commands
|
|||
});
|
||||
}
|
||||
|
||||
private int DoChangeSlot(CmdResult r, McClient handler, int slot)
|
||||
private int DoChangeSlot(CmdResult r, int slot)
|
||||
{
|
||||
McClient handler = CmdResult.currentHandler!;
|
||||
if (!handler.GetInventoryEnabled())
|
||||
return r.SetAndReturn(Status.FailNeedInventory);
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ namespace MinecraftClient.Commands
|
|||
public override string CmdUsage { get { return "chunk status [chunkX chunkZ|locationX locationY locationZ]"; } }
|
||||
public override string CmdDesc { get { return Translations.cmd_chunk_desc; } }
|
||||
|
||||
public override void RegisterCommand(McClient handler, CommandDispatcher<CmdResult> dispatcher)
|
||||
public override void RegisterCommand(CommandDispatcher<CmdResult> dispatcher)
|
||||
{
|
||||
dispatcher.Register(l => l.Literal("help")
|
||||
.Then(l => l.Literal(CmdName)
|
||||
|
|
@ -32,26 +32,26 @@ namespace MinecraftClient.Commands
|
|||
|
||||
dispatcher.Register(l => l.Literal(CmdName)
|
||||
.Then(l => l.Literal("status")
|
||||
.Executes(r => LogChunkStatus(r.Source, handler))
|
||||
.Executes(r => LogChunkStatus(r.Source))
|
||||
.Then(l => l.Argument("Location", MccArguments.Location())
|
||||
.Executes(r => LogChunkStatus(r.Source, handler, pos: MccArguments.GetLocation(r, "Location"))))
|
||||
.Executes(r => LogChunkStatus(r.Source, pos: MccArguments.GetLocation(r, "Location"))))
|
||||
.Then(l => l.Argument("Chunk", MccArguments.Tuple())
|
||||
.Executes(r => LogChunkStatus(r.Source, handler, markedChunkPos: MccArguments.GetTuple(r, "Chunk")))))
|
||||
.Executes(r => LogChunkStatus(r.Source, markedChunkPos: MccArguments.GetTuple(r, "Chunk")))))
|
||||
.Then(l => l.Literal("_setloading")
|
||||
.Then(l => l.Argument("Location", MccArguments.Location())
|
||||
.Executes(r => DebugSetLoading(r.Source, handler, pos: MccArguments.GetLocation(r, "Location"))))
|
||||
.Executes(r => DebugSetLoading(r.Source, pos: MccArguments.GetLocation(r, "Location"))))
|
||||
.Then(l => l.Argument("Chunk", MccArguments.Tuple())
|
||||
.Executes(r => DebugSetLoading(r.Source, handler, markedChunkPos: MccArguments.GetTuple(r, "Chunk")))))
|
||||
.Executes(r => DebugSetLoading(r.Source, markedChunkPos: MccArguments.GetTuple(r, "Chunk")))))
|
||||
.Then(l => l.Literal("_setloaded")
|
||||
.Then(l => l.Argument("Location", MccArguments.Location())
|
||||
.Executes(r => DebugSetLoaded(r.Source, handler, pos: MccArguments.GetLocation(r, "Location"))))
|
||||
.Executes(r => DebugSetLoaded(r.Source, pos: MccArguments.GetLocation(r, "Location"))))
|
||||
.Then(l => l.Argument("Chunk", MccArguments.Tuple())
|
||||
.Executes(r => DebugSetLoaded(r.Source, handler, markedChunkPos: MccArguments.GetTuple(r, "Chunk")))))
|
||||
.Executes(r => DebugSetLoaded(r.Source, markedChunkPos: MccArguments.GetTuple(r, "Chunk")))))
|
||||
.Then(l => l.Literal("_delete")
|
||||
.Then(l => l.Argument("Location", MccArguments.Location())
|
||||
.Executes(r => DebugDelete(r.Source, handler, pos: MccArguments.GetLocation(r, "Location"))))
|
||||
.Executes(r => DebugDelete(r.Source, pos: MccArguments.GetLocation(r, "Location"))))
|
||||
.Then(l => l.Argument("Chunk", MccArguments.Tuple())
|
||||
.Executes(r => DebugDelete(r.Source, handler, markedChunkPos: MccArguments.GetTuple(r, "Chunk")))))
|
||||
.Executes(r => DebugDelete(r.Source, markedChunkPos: MccArguments.GetTuple(r, "Chunk")))))
|
||||
.Then(l => l.Literal("_help")
|
||||
.Redirect(dispatcher.GetRoot().GetChild("help").GetChild(CmdName)))
|
||||
);
|
||||
|
|
@ -71,8 +71,9 @@ namespace MinecraftClient.Commands
|
|||
});
|
||||
}
|
||||
|
||||
private static int LogChunkStatus(CmdResult r, McClient handler, Location? pos = null, Tuple<int, int>? markedChunkPos = null)
|
||||
private static int LogChunkStatus(CmdResult r, Location? pos = null, Tuple<int, int>? markedChunkPos = null)
|
||||
{
|
||||
McClient handler = CmdResult.currentHandler!;
|
||||
if (!handler.GetTerrainEnabled())
|
||||
return r.SetAndReturn(Status.FailNeedTerrain);
|
||||
|
||||
|
|
@ -225,8 +226,9 @@ namespace MinecraftClient.Commands
|
|||
return r.SetAndReturn(Status.Done);
|
||||
}
|
||||
|
||||
private static int DebugSetLoading(CmdResult r, McClient handler, Location? pos = null, Tuple<int, int>? markedChunkPos = null)
|
||||
private static int DebugSetLoading(CmdResult r, Location? pos = null, Tuple<int, int>? markedChunkPos = null)
|
||||
{
|
||||
McClient handler = CmdResult.currentHandler!;
|
||||
if (!handler.GetTerrainEnabled())
|
||||
return r.SetAndReturn(Status.FailNeedTerrain);
|
||||
|
||||
|
|
@ -244,8 +246,9 @@ namespace MinecraftClient.Commands
|
|||
return r.SetAndReturn(Status.Done, string.Format("Successfully marked chunk ({0}, {1}) as loading.", chunkX, chunkZ));
|
||||
}
|
||||
|
||||
private static int DebugSetLoaded(CmdResult r, McClient handler, Location? pos = null, Tuple<int, int>? markedChunkPos = null)
|
||||
private static int DebugSetLoaded(CmdResult r, Location? pos = null, Tuple<int, int>? markedChunkPos = null)
|
||||
{
|
||||
McClient handler = CmdResult.currentHandler!;
|
||||
if (!handler.GetTerrainEnabled())
|
||||
return r.SetAndReturn(Status.FailNeedTerrain);
|
||||
|
||||
|
|
@ -263,8 +266,9 @@ namespace MinecraftClient.Commands
|
|||
return r.SetAndReturn(Status.Done, string.Format("Successfully marked chunk ({0}, {1}) as loaded.", chunkX, chunkZ));
|
||||
}
|
||||
|
||||
private static int DebugDelete(CmdResult r, McClient handler, Location? pos = null, Tuple<int, int>? markedChunkPos = null)
|
||||
private static int DebugDelete(CmdResult r, Location? pos = null, Tuple<int, int>? markedChunkPos = null)
|
||||
{
|
||||
McClient handler = CmdResult.currentHandler!;
|
||||
if (!handler.GetTerrainEnabled())
|
||||
return r.SetAndReturn(Status.FailNeedTerrain);
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ namespace MinecraftClient.Commands
|
|||
public override string CmdUsage { get { return "connect <server> [account]"; } }
|
||||
public override string CmdDesc { get { return Translations.cmd_connect_desc; } }
|
||||
|
||||
public override void RegisterCommand(McClient handler, CommandDispatcher<CmdResult> dispatcher)
|
||||
public override void RegisterCommand(CommandDispatcher<CmdResult> dispatcher)
|
||||
{
|
||||
dispatcher.Register(l => l.Literal("help")
|
||||
.Then(l => l.Literal(CmdName)
|
||||
|
|
@ -21,9 +21,9 @@ namespace MinecraftClient.Commands
|
|||
|
||||
dispatcher.Register(l => l.Literal(CmdName)
|
||||
.Then(l => l.Argument("ServerNick", MccArguments.ServerNick())
|
||||
.Executes(r => DoConnect(r.Source, handler, Arguments.GetString(r, "ServerNick"), string.Empty))
|
||||
.Executes(r => DoConnect(r.Source, Arguments.GetString(r, "ServerNick"), string.Empty))
|
||||
.Then(l => l.Argument("AccountNick", MccArguments.AccountNick())
|
||||
.Executes(r => DoConnect(r.Source, handler, Arguments.GetString(r, "ServerNick"), Arguments.GetString(r, "AccountNick")))))
|
||||
.Executes(r => DoConnect(r.Source, Arguments.GetString(r, "ServerNick"), Arguments.GetString(r, "AccountNick")))))
|
||||
.Then(l => l.Literal("_help")
|
||||
.Redirect(dispatcher.GetRoot().GetChild("help").GetChild(CmdName)))
|
||||
);
|
||||
|
|
@ -39,7 +39,7 @@ namespace MinecraftClient.Commands
|
|||
});
|
||||
}
|
||||
|
||||
private int DoConnect(CmdResult r, McClient handler, string server, string account)
|
||||
private int DoConnect(CmdResult r, string server, string account)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(account) && !Settings.Config.Main.Advanced.SetAccount(account))
|
||||
return r.SetAndReturn(Status.Fail, string.Format(Translations.cmd_connect_unknown, account));
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ namespace MinecraftClient.Commands
|
|||
public override string CmdUsage { get { return "debug [on|off]"; } }
|
||||
public override string CmdDesc { get { return Translations.cmd_debug_desc; } }
|
||||
|
||||
public override void RegisterCommand(McClient handler, CommandDispatcher<CmdResult> dispatcher)
|
||||
public override void RegisterCommand(CommandDispatcher<CmdResult> dispatcher)
|
||||
{
|
||||
dispatcher.Register(l => l.Literal("help")
|
||||
.Then(l => l.Literal(CmdName)
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ namespace MinecraftClient.Commands
|
|||
public override string CmdUsage { get { return "dig <x> <y> <z>"; } }
|
||||
public override string CmdDesc { get { return Translations.cmd_dig_desc; } }
|
||||
|
||||
public override void RegisterCommand(McClient handler, CommandDispatcher<CmdResult> dispatcher)
|
||||
public override void RegisterCommand(CommandDispatcher<CmdResult> dispatcher)
|
||||
{
|
||||
dispatcher.Register(l => l.Literal("help")
|
||||
.Then(l => l.Literal(CmdName)
|
||||
|
|
@ -22,9 +22,9 @@ namespace MinecraftClient.Commands
|
|||
);
|
||||
|
||||
dispatcher.Register(l => l.Literal(CmdName)
|
||||
.Executes(r => DigLookAt(r.Source, handler))
|
||||
.Executes(r => DigLookAt(r.Source))
|
||||
.Then(l => l.Argument("Location", MccArguments.Location())
|
||||
.Executes(r => DigAt(r.Source, handler, MccArguments.GetLocation(r, "Location"))))
|
||||
.Executes(r => DigAt(r.Source, MccArguments.GetLocation(r, "Location"))))
|
||||
.Then(l => l.Literal("_help")
|
||||
.Redirect(dispatcher.GetRoot().GetChild("help").GetChild(CmdName)))
|
||||
);
|
||||
|
|
@ -40,8 +40,9 @@ namespace MinecraftClient.Commands
|
|||
});
|
||||
}
|
||||
|
||||
private int DigAt(CmdResult r, McClient handler, Location blockToBreak)
|
||||
private int DigAt(CmdResult r, Location blockToBreak)
|
||||
{
|
||||
McClient handler = CmdResult.currentHandler!;
|
||||
if (!handler.GetTerrainEnabled())
|
||||
return r.SetAndReturn(Status.FailNeedTerrain);
|
||||
|
||||
|
|
@ -61,8 +62,9 @@ namespace MinecraftClient.Commands
|
|||
return r.SetAndReturn(Status.Fail, Translations.cmd_dig_fail);
|
||||
}
|
||||
|
||||
private int DigLookAt(CmdResult r, McClient handler)
|
||||
private int DigLookAt(CmdResult r)
|
||||
{
|
||||
McClient handler = CmdResult.currentHandler!;
|
||||
if (!handler.GetTerrainEnabled())
|
||||
return r.SetAndReturn(Status.FailNeedTerrain);
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ namespace MinecraftClient.Commands
|
|||
public override string CmdUsage { get { return "dropitem <itemtype>"; } }
|
||||
public override string CmdDesc { get { return Translations.cmd_dropItem_desc; } }
|
||||
|
||||
public override void RegisterCommand(McClient handler, CommandDispatcher<CmdResult> dispatcher)
|
||||
public override void RegisterCommand(CommandDispatcher<CmdResult> dispatcher)
|
||||
{
|
||||
dispatcher.Register(l => l.Literal("help")
|
||||
.Then(l => l.Literal(CmdName)
|
||||
|
|
@ -24,7 +24,7 @@ namespace MinecraftClient.Commands
|
|||
|
||||
dispatcher.Register(l => l.Literal(CmdName)
|
||||
.Then(l => l.Argument("ItemType", MccArguments.ItemType())
|
||||
.Executes(r => DoDropItem(r.Source, handler, MccArguments.GetItemType(r, "ItemType"))))
|
||||
.Executes(r => DoDropItem(r.Source, MccArguments.GetItemType(r, "ItemType"))))
|
||||
.Then(l => l.Literal("_help")
|
||||
.Redirect(dispatcher.GetRoot().GetChild("help").GetChild(CmdName)))
|
||||
);
|
||||
|
|
@ -40,8 +40,9 @@ namespace MinecraftClient.Commands
|
|||
});
|
||||
}
|
||||
|
||||
private int DoDropItem(CmdResult r, McClient handler, ItemType itemType)
|
||||
private int DoDropItem(CmdResult r, ItemType itemType)
|
||||
{
|
||||
McClient handler = CmdResult.currentHandler!;
|
||||
if (!handler.GetInventoryEnabled())
|
||||
return r.SetAndReturn(Status.FailNeedTerrain);
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ namespace MinecraftClient.Commands
|
|||
public override string CmdUsage { get { return "enchant <top|middle|bottom>"; } }
|
||||
public override string CmdDesc { get { return Translations.cmd_enchant_desc; } }
|
||||
|
||||
public override void RegisterCommand(McClient handler, CommandDispatcher<CmdResult> dispatcher)
|
||||
public override void RegisterCommand(CommandDispatcher<CmdResult> dispatcher)
|
||||
{
|
||||
dispatcher.Register(l => l.Literal("help")
|
||||
.Then(l => l.Literal(CmdName)
|
||||
|
|
@ -28,11 +28,11 @@ namespace MinecraftClient.Commands
|
|||
|
||||
dispatcher.Register(l => l.Literal(CmdName)
|
||||
.Then(l => l.Literal("top")
|
||||
.Executes(r => DoEnchant(r.Source, handler, slotId: 0)))
|
||||
.Executes(r => DoEnchant(r.Source, slotId: 0)))
|
||||
.Then(l => l.Literal("middle")
|
||||
.Executes(r => DoEnchant(r.Source, handler, slotId: 1)))
|
||||
.Executes(r => DoEnchant(r.Source, slotId: 1)))
|
||||
.Then(l => l.Literal("bottom")
|
||||
.Executes(r => DoEnchant(r.Source, handler, slotId: 2)))
|
||||
.Executes(r => DoEnchant(r.Source, slotId: 2)))
|
||||
.Then(l => l.Literal("_help")
|
||||
.Redirect(dispatcher.GetRoot().GetChild("help").GetChild(CmdName)))
|
||||
);
|
||||
|
|
@ -51,8 +51,9 @@ namespace MinecraftClient.Commands
|
|||
});
|
||||
}
|
||||
|
||||
private int DoEnchant(CmdResult r, McClient handler, int slotId)
|
||||
private int DoEnchant(CmdResult r, int slotId)
|
||||
{
|
||||
McClient handler = CmdResult.currentHandler!;
|
||||
Container? enchantingTable = null;
|
||||
|
||||
foreach (var (id, container) in handler.GetInventories())
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ namespace MinecraftClient.Commands
|
|||
|
||||
private enum ActionType { Attack, Use, List };
|
||||
|
||||
public override void RegisterCommand(McClient handler, CommandDispatcher<CmdResult> dispatcher)
|
||||
public override void RegisterCommand(CommandDispatcher<CmdResult> dispatcher)
|
||||
{
|
||||
dispatcher.Register(l => l.Literal("help")
|
||||
.Then(l => l.Literal(CmdName)
|
||||
|
|
@ -36,41 +36,41 @@ namespace MinecraftClient.Commands
|
|||
);
|
||||
|
||||
dispatcher.Register(l => l.Literal(CmdName)
|
||||
.Executes(r => GetFullEntityList(r.Source, handler))
|
||||
.Executes(r => GetFullEntityList(r.Source))
|
||||
.Then(l => l.Literal("near")
|
||||
.Executes(r => GetClosetEntityList(r.Source, handler))
|
||||
.Executes(r => GetClosetEntityList(r.Source))
|
||||
.Then(l => l.Argument("EntityID", Arguments.Integer())
|
||||
.Executes(r => OperateWithId(r.Source, handler, Arguments.GetInteger(r, "EntityID"), ActionType.List))
|
||||
.Executes(r => OperateWithId(r.Source, Arguments.GetInteger(r, "EntityID"), ActionType.List))
|
||||
.Then(l => l.Literal("attack")
|
||||
.Executes(r => OperateWithId(r.Source, handler, Arguments.GetInteger(r, "EntityID"), ActionType.Attack)))
|
||||
.Executes(r => OperateWithId(r.Source, Arguments.GetInteger(r, "EntityID"), ActionType.Attack)))
|
||||
.Then(l => l.Literal("use")
|
||||
.Executes(r => OperateWithId(r.Source, handler, Arguments.GetInteger(r, "EntityID"), ActionType.Use)))
|
||||
.Executes(r => OperateWithId(r.Source, Arguments.GetInteger(r, "EntityID"), ActionType.Use)))
|
||||
.Then(l => l.Literal("list")
|
||||
.Executes(r => OperateWithId(r.Source, handler, Arguments.GetInteger(r, "EntityID"), ActionType.List))))
|
||||
.Executes(r => OperateWithId(r.Source, Arguments.GetInteger(r, "EntityID"), ActionType.List))))
|
||||
.Then(l => l.Argument("EntityType", MccArguments.EntityType())
|
||||
.Executes(r => OperateWithType(r.Source, handler, true, MccArguments.GetEntityType(r, "EntityType"), ActionType.List))
|
||||
.Executes(r => OperateWithType(r.Source, true, MccArguments.GetEntityType(r, "EntityType"), ActionType.List))
|
||||
.Then(l => l.Literal("attack")
|
||||
.Executes(r => OperateWithType(r.Source, handler, near: true, MccArguments.GetEntityType(r, "EntityType"), ActionType.Attack)))
|
||||
.Executes(r => OperateWithType(r.Source, near: true, MccArguments.GetEntityType(r, "EntityType"), ActionType.Attack)))
|
||||
.Then(l => l.Literal("use")
|
||||
.Executes(r => OperateWithType(r.Source, handler, near: true, MccArguments.GetEntityType(r, "EntityType"), ActionType.Use)))
|
||||
.Executes(r => OperateWithType(r.Source, near: true, MccArguments.GetEntityType(r, "EntityType"), ActionType.Use)))
|
||||
.Then(l => l.Literal("list")
|
||||
.Executes(r => OperateWithType(r.Source, handler, near: true, MccArguments.GetEntityType(r, "EntityType"), ActionType.List)))))
|
||||
.Executes(r => OperateWithType(r.Source, near: true, MccArguments.GetEntityType(r, "EntityType"), ActionType.List)))))
|
||||
.Then(l => l.Argument("EntityID", Arguments.Integer())
|
||||
.Executes(r => OperateWithId(r.Source, handler, Arguments.GetInteger(r, "EntityID"), ActionType.List))
|
||||
.Executes(r => OperateWithId(r.Source, Arguments.GetInteger(r, "EntityID"), ActionType.List))
|
||||
.Then(l => l.Literal("attack")
|
||||
.Executes(r => OperateWithId(r.Source, handler, Arguments.GetInteger(r, "EntityID"), ActionType.Attack)))
|
||||
.Executes(r => OperateWithId(r.Source, Arguments.GetInteger(r, "EntityID"), ActionType.Attack)))
|
||||
.Then(l => l.Literal("use")
|
||||
.Executes(r => OperateWithId(r.Source, handler, Arguments.GetInteger(r, "EntityID"), ActionType.Use)))
|
||||
.Executes(r => OperateWithId(r.Source, Arguments.GetInteger(r, "EntityID"), ActionType.Use)))
|
||||
.Then(l => l.Literal("list")
|
||||
.Executes(r => OperateWithId(r.Source, handler, Arguments.GetInteger(r, "EntityID"), ActionType.List))))
|
||||
.Executes(r => OperateWithId(r.Source, Arguments.GetInteger(r, "EntityID"), ActionType.List))))
|
||||
.Then(l => l.Argument("EntityType", MccArguments.EntityType())
|
||||
.Executes(r => OperateWithType(r.Source, handler, true, MccArguments.GetEntityType(r, "EntityType"), ActionType.List))
|
||||
.Executes(r => OperateWithType(r.Source, true, MccArguments.GetEntityType(r, "EntityType"), ActionType.List))
|
||||
.Then(l => l.Literal("attack")
|
||||
.Executes(r => OperateWithType(r.Source, handler, near: false, MccArguments.GetEntityType(r, "EntityType"), ActionType.Attack)))
|
||||
.Executes(r => OperateWithType(r.Source, near: false, MccArguments.GetEntityType(r, "EntityType"), ActionType.Attack)))
|
||||
.Then(l => l.Literal("use")
|
||||
.Executes(r => OperateWithType(r.Source, handler, near: false, MccArguments.GetEntityType(r, "EntityType"), ActionType.Use)))
|
||||
.Executes(r => OperateWithType(r.Source, near: false, MccArguments.GetEntityType(r, "EntityType"), ActionType.Use)))
|
||||
.Then(l => l.Literal("list")
|
||||
.Executes(r => OperateWithType(r.Source, handler, near: false, MccArguments.GetEntityType(r, "EntityType"), ActionType.List))))
|
||||
.Executes(r => OperateWithType(r.Source, near: false, MccArguments.GetEntityType(r, "EntityType"), ActionType.List))))
|
||||
.Then(l => l.Literal("_help")
|
||||
.Redirect(dispatcher.GetRoot().GetChild("help").GetChild(CmdName)))
|
||||
);
|
||||
|
|
@ -90,8 +90,9 @@ namespace MinecraftClient.Commands
|
|||
});
|
||||
}
|
||||
|
||||
private int GetFullEntityList(CmdResult r, McClient handler)
|
||||
private int GetFullEntityList(CmdResult r)
|
||||
{
|
||||
McClient handler = CmdResult.currentHandler!;
|
||||
if (!handler.GetEntityHandlingEnabled())
|
||||
return r.SetAndReturn(Status.FailNeedEntity);
|
||||
|
||||
|
|
@ -106,8 +107,9 @@ namespace MinecraftClient.Commands
|
|||
return r.SetAndReturn(Status.Done);
|
||||
}
|
||||
|
||||
private int GetClosetEntityList(CmdResult r, McClient handler)
|
||||
private int GetClosetEntityList(CmdResult r)
|
||||
{
|
||||
McClient handler = CmdResult.currentHandler!;
|
||||
if (!handler.GetEntityHandlingEnabled())
|
||||
return r.SetAndReturn(Status.FailNeedEntity);
|
||||
|
||||
|
|
@ -120,8 +122,9 @@ namespace MinecraftClient.Commands
|
|||
return r.SetAndReturn(Status.Fail, Translations.cmd_entityCmd_not_found);
|
||||
}
|
||||
|
||||
private int OperateWithId(CmdResult r, McClient handler, int entityID, ActionType action)
|
||||
private int OperateWithId(CmdResult r, int entityID, ActionType action)
|
||||
{
|
||||
McClient handler = CmdResult.currentHandler!;
|
||||
if (!handler.GetEntityHandlingEnabled())
|
||||
return r.SetAndReturn(Status.FailNeedEntity);
|
||||
|
||||
|
|
@ -134,8 +137,9 @@ namespace MinecraftClient.Commands
|
|||
return r.SetAndReturn(Status.Fail, Translations.cmd_entityCmd_not_found);
|
||||
}
|
||||
|
||||
private int OperateWithType(CmdResult r, McClient handler, bool near, EntityType entityType, ActionType action)
|
||||
private int OperateWithType(CmdResult r, bool near, EntityType entityType, ActionType action)
|
||||
{
|
||||
McClient handler = CmdResult.currentHandler!;
|
||||
if (!handler.GetEntityHandlingEnabled())
|
||||
return r.SetAndReturn(Status.FailNeedEntity);
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ namespace MinecraftClient.Commands
|
|||
public override string CmdUsage { get { return "execif \"<condition/expression>\" \"<command>\""; } }
|
||||
public override string CmdDesc { get { return Translations.cmd_execif_desc; } }
|
||||
|
||||
public override void RegisterCommand(McClient handler, CommandDispatcher<CmdResult> dispatcher)
|
||||
public override void RegisterCommand(CommandDispatcher<CmdResult> dispatcher)
|
||||
{
|
||||
dispatcher.Register(l => l.Literal("help")
|
||||
.Then(l => l.Literal(CmdName)
|
||||
|
|
@ -24,7 +24,7 @@ namespace MinecraftClient.Commands
|
|||
dispatcher.Register(l => l.Literal(CmdName)
|
||||
.Then(l => l.Argument("Condition", Arguments.String())
|
||||
.Then(l => l.Argument("Command", Arguments.String())
|
||||
.Executes(r => HandleCommand(r.Source, handler, Arguments.GetString(r, "Condition"), Arguments.GetString(r, "Command")))))
|
||||
.Executes(r => HandleCommand(r.Source, Arguments.GetString(r, "Condition"), Arguments.GetString(r, "Command")))))
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -38,8 +38,9 @@ namespace MinecraftClient.Commands
|
|||
});
|
||||
}
|
||||
|
||||
private int HandleCommand(CmdResult r, McClient handler, string expressionText, string resultCommand)
|
||||
private int HandleCommand(CmdResult r, string expressionText, string resultCommand)
|
||||
{
|
||||
McClient handler = CmdResult.currentHandler!;
|
||||
try
|
||||
{
|
||||
var interpreter = new Interpreter();
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ namespace MinecraftClient.Commands
|
|||
public override string CmdUsage { get { return "execmulti <command 1> -> <command2> -> <command 3> -> ..."; } }
|
||||
public override string CmdDesc { get { return Translations.cmd_execmulti_desc; } }
|
||||
|
||||
public override void RegisterCommand(McClient handler, CommandDispatcher<CmdResult> dispatcher)
|
||||
public override void RegisterCommand(CommandDispatcher<CmdResult> dispatcher)
|
||||
{
|
||||
dispatcher.Register(l => l.Literal("help")
|
||||
.Then(l => l.Literal(CmdName)
|
||||
|
|
@ -23,7 +23,7 @@ namespace MinecraftClient.Commands
|
|||
|
||||
dispatcher.Register(l => l.Literal(CmdName)
|
||||
.Then(l => l.Argument("Commands", Arguments.GreedyString())
|
||||
.Executes(r => HandleCommand(r.Source, handler, Arguments.GetString(r, "Commands"))))
|
||||
.Executes(r => HandleCommand(r.Source, Arguments.GetString(r, "Commands"))))
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -37,8 +37,9 @@ namespace MinecraftClient.Commands
|
|||
});
|
||||
}
|
||||
|
||||
private int HandleCommand(CmdResult r, McClient handler, string commandsString)
|
||||
private int HandleCommand(CmdResult r, string commandsString)
|
||||
{
|
||||
McClient handler = CmdResult.currentHandler!;
|
||||
if (commandsString.Contains("execmulti", StringComparison.OrdinalIgnoreCase) || commandsString.Contains("execif", StringComparison.OrdinalIgnoreCase))
|
||||
return r.SetAndReturn(CmdResult.Status.Fail, Translations.cmd_execmulti_prevent);
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ namespace MinecraftClient.Commands
|
|||
public override string CmdUsage { get { return "exit"; } }
|
||||
public override string CmdDesc { get { return Translations.cmd_exit_desc; } }
|
||||
|
||||
public override void RegisterCommand(McClient handler, CommandDispatcher<CmdResult> dispatcher)
|
||||
public override void RegisterCommand(CommandDispatcher<CmdResult> dispatcher)
|
||||
{
|
||||
dispatcher.Register(l => l.Literal("help")
|
||||
.Then(l => l.Literal(CmdName)
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ namespace MinecraftClient.Commands
|
|||
public override string CmdUsage { get { return "health"; } }
|
||||
public override string CmdDesc { get { return Translations.cmd_health_desc; } }
|
||||
|
||||
public override void RegisterCommand(McClient handler, CommandDispatcher<CmdResult> dispatcher)
|
||||
public override void RegisterCommand(CommandDispatcher<CmdResult> dispatcher)
|
||||
{
|
||||
dispatcher.Register(l => l.Literal("help")
|
||||
.Then(l => l.Literal(CmdName)
|
||||
|
|
@ -19,7 +19,7 @@ namespace MinecraftClient.Commands
|
|||
);
|
||||
|
||||
dispatcher.Register(l => l.Literal(CmdName)
|
||||
.Executes(r => LogHealth(r.Source, handler))
|
||||
.Executes(r => LogHealth(r.Source))
|
||||
.Then(l => l.Literal("_help")
|
||||
.Redirect(dispatcher.GetRoot().GetChild("help").GetChild(CmdName)))
|
||||
);
|
||||
|
|
@ -35,8 +35,9 @@ namespace MinecraftClient.Commands
|
|||
});
|
||||
}
|
||||
|
||||
private int LogHealth(CmdResult r, McClient handler)
|
||||
private int LogHealth(CmdResult r)
|
||||
{
|
||||
McClient handler = CmdResult.currentHandler!;
|
||||
return r.SetAndReturn(CmdResult.Status.Done, string.Format(Translations.cmd_health_response, handler.GetHealth(), handler.GetSaturation(), handler.GetLevel(), handler.GetTotalExperience()));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,16 +12,17 @@ namespace MinecraftClient.Commands
|
|||
public override string CmdDesc => throw new NotImplementedException();
|
||||
public override string CmdUsage => throw new NotImplementedException();
|
||||
|
||||
public override void RegisterCommand(McClient handler, CommandDispatcher<CmdResult> dispatcher)
|
||||
public override void RegisterCommand(CommandDispatcher<CmdResult> dispatcher)
|
||||
{
|
||||
dispatcher.Register(l =>
|
||||
l.Literal("help")
|
||||
.Executes(r => LogHelp(r.Source, handler, dispatcher))
|
||||
.Executes(r => LogHelp(r.Source, dispatcher))
|
||||
);
|
||||
}
|
||||
|
||||
private int LogHelp(CmdResult r, McClient handler, CommandDispatcher<CmdResult> dispatcher)
|
||||
private int LogHelp(CmdResult r, CommandDispatcher<CmdResult> dispatcher)
|
||||
{
|
||||
McClient handler = CmdResult.currentHandler!;
|
||||
var usage = dispatcher.GetSmartUsage(dispatcher.GetRoot(), CmdResult.Empty);
|
||||
StringBuilder sb = new();
|
||||
foreach (var item in usage)
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ namespace MinecraftClient.Commands
|
|||
public override string CmdUsage { get { return GetBasicUsage(); } }
|
||||
public override string CmdDesc { get { return Translations.cmd_inventory_desc; } }
|
||||
|
||||
public override void RegisterCommand(McClient handler, CommandDispatcher<CmdResult> dispatcher)
|
||||
public override void RegisterCommand(CommandDispatcher<CmdResult> dispatcher)
|
||||
{
|
||||
dispatcher.Register(l => l.Literal("help")
|
||||
.Then(l => l.Literal(CmdName)
|
||||
|
|
@ -42,65 +42,65 @@ namespace MinecraftClient.Commands
|
|||
);
|
||||
|
||||
dispatcher.Register(l => l.Literal(CmdName)
|
||||
.Executes(r => ListAllInventories(r.Source, handler))
|
||||
.Executes(r => ListAllInventories(r.Source))
|
||||
.Then(l => l.Literal("creativegive")
|
||||
.Then(l => l.Argument("Slot", MccArguments.InventorySlot())
|
||||
.Then(l => l.Argument("ItemType", MccArguments.ItemType())
|
||||
.Then(l => l.Argument("Count", Arguments.Integer(min: 1))
|
||||
.Executes(r => DoCreativeGive(r.Source, handler, Arguments.GetInteger(r, "Slot"), MccArguments.GetItemType(r, "ItemType"), Arguments.GetInteger(r, "Count")))))))
|
||||
.Executes(r => DoCreativeGive(r.Source, Arguments.GetInteger(r, "Slot"), MccArguments.GetItemType(r, "ItemType"), Arguments.GetInteger(r, "Count")))))))
|
||||
.Then(l => l.Literal("creativedelete")
|
||||
.Then(l => l.Argument("Slot", MccArguments.InventorySlot())
|
||||
.Executes(r => DoCreativeDelete(r.Source, handler, Arguments.GetInteger(r, "Slot")))))
|
||||
.Executes(r => DoCreativeDelete(r.Source, Arguments.GetInteger(r, "Slot")))))
|
||||
.Then(l => l.Literal("inventories")
|
||||
.Executes(r => ListAvailableInventories(r.Source, handler)))
|
||||
.Executes(r => ListAvailableInventories(r.Source)))
|
||||
.Then(l => l.Literal("search")
|
||||
.Then(l => l.Argument("ItemType", MccArguments.ItemType())
|
||||
.Executes(r => SearchItem(r.Source, handler, MccArguments.GetItemType(r, "ItemType"), null))
|
||||
.Executes(r => SearchItem(r.Source, MccArguments.GetItemType(r, "ItemType"), null))
|
||||
.Then(l => l.Argument("Count", Arguments.Integer(0, 64))
|
||||
.Executes(r => SearchItem(r.Source, handler, MccArguments.GetItemType(r, "ItemType"), Arguments.GetInteger(r, "Count"))))))
|
||||
.Executes(r => SearchItem(r.Source, MccArguments.GetItemType(r, "ItemType"), Arguments.GetInteger(r, "Count"))))))
|
||||
.Then(l => l.Argument("InventoryId", MccArguments.InventoryId())
|
||||
.Then(l => l.Literal("close")
|
||||
.Executes(r => DoCloseAction(r.Source, handler, Arguments.GetInteger(r, "InventoryId"))))
|
||||
.Executes(r => DoCloseAction(r.Source, Arguments.GetInteger(r, "InventoryId"))))
|
||||
.Then(l => l.Literal("list")
|
||||
.Executes(r => DoListAction(r.Source, handler, Arguments.GetInteger(r, "InventoryId"))))
|
||||
.Executes(r => DoListAction(r.Source, Arguments.GetInteger(r, "InventoryId"))))
|
||||
.Then(l => l.Literal("click")
|
||||
.Then(l => l.Argument("Slot", MccArguments.InventorySlot())
|
||||
.Executes(r => DoClickAction(r.Source, handler, Arguments.GetInteger(r, "InventoryId"), Arguments.GetInteger(r, "Slot"), WindowActionType.LeftClick))
|
||||
.Executes(r => DoClickAction(r.Source, Arguments.GetInteger(r, "InventoryId"), Arguments.GetInteger(r, "Slot"), WindowActionType.LeftClick))
|
||||
.Then(l => l.Argument("Action", MccArguments.InventoryAction())
|
||||
.Executes(r => DoClickAction(r.Source, handler, Arguments.GetInteger(r, "InventoryId"), Arguments.GetInteger(r, "Slot"), MccArguments.GetInventoryAction(r, "Action"))))))
|
||||
.Executes(r => DoClickAction(r.Source, Arguments.GetInteger(r, "InventoryId"), Arguments.GetInteger(r, "Slot"), MccArguments.GetInventoryAction(r, "Action"))))))
|
||||
.Then(l => l.Literal("drop")
|
||||
.Then(l => l.Argument("Slot", MccArguments.InventorySlot())
|
||||
.Executes(r => DoDropAction(r.Source, handler, Arguments.GetInteger(r, "InventoryId"), Arguments.GetInteger(r, "Slot"), WindowActionType.DropItem))
|
||||
.Executes(r => DoDropAction(r.Source, Arguments.GetInteger(r, "InventoryId"), Arguments.GetInteger(r, "Slot"), WindowActionType.DropItem))
|
||||
.Then(l => l.Literal("all")
|
||||
.Executes(r => DoDropAction(r.Source, handler, Arguments.GetInteger(r, "InventoryId"), Arguments.GetInteger(r, "Slot"), WindowActionType.DropItemStack))))))
|
||||
.Executes(r => DoDropAction(r.Source, Arguments.GetInteger(r, "InventoryId"), Arguments.GetInteger(r, "Slot"), WindowActionType.DropItemStack))))))
|
||||
.Then(l => l.Literal("player")
|
||||
.Then(l => l.Literal("list")
|
||||
.Executes(r => DoListAction(r.Source, handler, inventoryId: 0)))
|
||||
.Executes(r => DoListAction(r.Source, inventoryId: 0)))
|
||||
.Then(l => l.Literal("click")
|
||||
.Then(l => l.Argument("Slot", MccArguments.InventorySlot())
|
||||
.Executes(r => DoClickAction(r.Source, handler, inventoryId: 0, Arguments.GetInteger(r, "Slot"), WindowActionType.LeftClick))
|
||||
.Executes(r => DoClickAction(r.Source, inventoryId: 0, Arguments.GetInteger(r, "Slot"), WindowActionType.LeftClick))
|
||||
.Then(l => l.Argument("Action", MccArguments.InventoryAction())
|
||||
.Executes(r => DoClickAction(r.Source, handler, inventoryId: 0, Arguments.GetInteger(r, "Slot"), MccArguments.GetInventoryAction(r, "Action"))))))
|
||||
.Executes(r => DoClickAction(r.Source, inventoryId: 0, Arguments.GetInteger(r, "Slot"), MccArguments.GetInventoryAction(r, "Action"))))))
|
||||
.Then(l => l.Literal("drop")
|
||||
.Then(l => l.Argument("Slot", MccArguments.InventorySlot())
|
||||
.Executes(r => DoDropAction(r.Source, handler, inventoryId: 0, Arguments.GetInteger(r, "Slot"), WindowActionType.DropItem))
|
||||
.Executes(r => DoDropAction(r.Source, inventoryId: 0, Arguments.GetInteger(r, "Slot"), WindowActionType.DropItem))
|
||||
.Then(l => l.Literal("all")
|
||||
.Executes(r => DoDropAction(r.Source, handler, inventoryId: 0, Arguments.GetInteger(r, "Slot"), WindowActionType.DropItemStack))))))
|
||||
.Executes(r => DoDropAction(r.Source, inventoryId: 0, Arguments.GetInteger(r, "Slot"), WindowActionType.DropItemStack))))))
|
||||
.Then(l => l.Literal("container")
|
||||
.Then(l => l.Literal("close")
|
||||
.Executes(r => DoCloseAction(r.Source, handler, inventoryId: null)))
|
||||
.Executes(r => DoCloseAction(r.Source, inventoryId: null)))
|
||||
.Then(l => l.Literal("list")
|
||||
.Executes(r => DoListAction(r.Source, handler, inventoryId: null)))
|
||||
.Executes(r => DoListAction(r.Source, inventoryId: null)))
|
||||
.Then(l => l.Literal("click")
|
||||
.Then(l => l.Argument("Slot", MccArguments.InventorySlot())
|
||||
.Executes(r => DoClickAction(r.Source, handler, inventoryId: null, Arguments.GetInteger(r, "Slot"), WindowActionType.LeftClick))
|
||||
.Executes(r => DoClickAction(r.Source, inventoryId: null, Arguments.GetInteger(r, "Slot"), WindowActionType.LeftClick))
|
||||
.Then(l => l.Argument("Action", MccArguments.InventoryAction())
|
||||
.Executes(r => DoClickAction(r.Source, handler, inventoryId: null, Arguments.GetInteger(r, "Slot"), MccArguments.GetInventoryAction(r, "Action"))))))
|
||||
.Executes(r => DoClickAction(r.Source, inventoryId: null, Arguments.GetInteger(r, "Slot"), MccArguments.GetInventoryAction(r, "Action"))))))
|
||||
.Then(l => l.Literal("drop")
|
||||
.Then(l => l.Argument("Slot", MccArguments.InventorySlot())
|
||||
.Executes(r => DoDropAction(r.Source, handler, inventoryId: null, Arguments.GetInteger(r, "Slot"), WindowActionType.DropItem))
|
||||
.Executes(r => DoDropAction(r.Source, inventoryId: null, Arguments.GetInteger(r, "Slot"), WindowActionType.DropItem))
|
||||
.Then(l => l.Literal("all")
|
||||
.Executes(r => DoDropAction(r.Source, handler, inventoryId: null, Arguments.GetInteger(r, "Slot"), WindowActionType.DropItemStack))))))
|
||||
.Executes(r => DoDropAction(r.Source, inventoryId: null, Arguments.GetInteger(r, "Slot"), WindowActionType.DropItemStack))))))
|
||||
.Then(l => l.Literal("_help")
|
||||
.Redirect(dispatcher.GetRoot().GetChild("help").GetChild(CmdName)))
|
||||
);
|
||||
|
|
@ -133,8 +133,9 @@ namespace MinecraftClient.Commands
|
|||
return availableIds.Max(); // use foreground container
|
||||
}
|
||||
|
||||
private int ListAllInventories(CmdResult r, McClient handler)
|
||||
private int ListAllInventories(CmdResult r)
|
||||
{
|
||||
McClient handler = CmdResult.currentHandler!;
|
||||
if (!handler.GetInventoryEnabled())
|
||||
{
|
||||
handler.Log.Info(Translations.extra_inventory_required);
|
||||
|
|
@ -149,8 +150,9 @@ namespace MinecraftClient.Commands
|
|||
return r.SetAndReturn(CmdResult.Status.Done);
|
||||
}
|
||||
|
||||
private int DoCreativeGive(CmdResult r, McClient handler, int slot, ItemType itemType, int count)
|
||||
private int DoCreativeGive(CmdResult r, int slot, ItemType itemType, int count)
|
||||
{
|
||||
McClient handler = CmdResult.currentHandler!;
|
||||
if (!handler.GetInventoryEnabled())
|
||||
return r.SetAndReturn(CmdResult.Status.FailNeedInventory);
|
||||
|
||||
|
|
@ -167,8 +169,9 @@ namespace MinecraftClient.Commands
|
|||
}
|
||||
}
|
||||
|
||||
private int DoCreativeDelete(CmdResult r, McClient handler, int slot)
|
||||
private int DoCreativeDelete(CmdResult r, int slot)
|
||||
{
|
||||
McClient handler = CmdResult.currentHandler!;
|
||||
if (!handler.GetInventoryEnabled())
|
||||
return r.SetAndReturn(CmdResult.Status.FailNeedInventory);
|
||||
|
||||
|
|
@ -185,8 +188,9 @@ namespace MinecraftClient.Commands
|
|||
}
|
||||
}
|
||||
|
||||
private int ListAvailableInventories(CmdResult r, McClient handler)
|
||||
private int ListAvailableInventories(CmdResult r)
|
||||
{
|
||||
McClient handler = CmdResult.currentHandler!;
|
||||
if (!handler.GetInventoryEnabled())
|
||||
return r.SetAndReturn(CmdResult.Status.FailNeedInventory);
|
||||
|
||||
|
|
@ -202,8 +206,9 @@ namespace MinecraftClient.Commands
|
|||
return r.SetAndReturn(CmdResult.Status.Done);
|
||||
}
|
||||
|
||||
private int SearchItem(CmdResult r, McClient handler, ItemType itemType, int? itemCount)
|
||||
private int SearchItem(CmdResult r, ItemType itemType, int? itemCount)
|
||||
{
|
||||
McClient handler = CmdResult.currentHandler!;
|
||||
if (!handler.GetInventoryEnabled())
|
||||
return r.SetAndReturn(CmdResult.Status.FailNeedInventory);
|
||||
|
||||
|
|
@ -256,8 +261,9 @@ namespace MinecraftClient.Commands
|
|||
return r.SetAndReturn(CmdResult.Status.Done);
|
||||
}
|
||||
|
||||
private int DoCloseAction(CmdResult r, McClient handler, int? inventoryId)
|
||||
private int DoCloseAction(CmdResult r, int? inventoryId)
|
||||
{
|
||||
McClient handler = CmdResult.currentHandler!;
|
||||
if (!handler.GetInventoryEnabled())
|
||||
return r.SetAndReturn(CmdResult.Status.FailNeedInventory);
|
||||
|
||||
|
|
@ -278,8 +284,9 @@ namespace MinecraftClient.Commands
|
|||
return r.SetAndReturn(CmdResult.Status.Fail, string.Format(Translations.cmd_inventory_close_fail, inventoryId));
|
||||
}
|
||||
|
||||
private int DoListAction(CmdResult r, McClient handler, int? inventoryId)
|
||||
private int DoListAction(CmdResult r, int? inventoryId)
|
||||
{
|
||||
McClient handler = CmdResult.currentHandler!;
|
||||
if (!handler.GetInventoryEnabled())
|
||||
return r.SetAndReturn(CmdResult.Status.FailNeedInventory);
|
||||
|
||||
|
|
@ -320,8 +327,9 @@ namespace MinecraftClient.Commands
|
|||
return r.SetAndReturn(CmdResult.Status.Done);
|
||||
}
|
||||
|
||||
private int DoClickAction(CmdResult r, McClient handler, int? inventoryId, int slot, WindowActionType actionType)
|
||||
private int DoClickAction(CmdResult r, int? inventoryId, int slot, WindowActionType actionType)
|
||||
{
|
||||
McClient handler = CmdResult.currentHandler!;
|
||||
if (!handler.GetInventoryEnabled())
|
||||
return r.SetAndReturn(CmdResult.Status.FailNeedInventory);
|
||||
|
||||
|
|
@ -349,8 +357,9 @@ namespace MinecraftClient.Commands
|
|||
return r.SetAndReturn(handler.DoWindowAction(inventoryId.Value, slot, actionType));
|
||||
}
|
||||
|
||||
private int DoDropAction(CmdResult r, McClient handler, int? inventoryId, int slot, WindowActionType actionType)
|
||||
private int DoDropAction(CmdResult r, int? inventoryId, int slot, WindowActionType actionType)
|
||||
{
|
||||
McClient handler = CmdResult.currentHandler!;
|
||||
if (!handler.GetInventoryEnabled())
|
||||
return r.SetAndReturn(CmdResult.Status.FailNeedInventory);
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ namespace MinecraftClient.Commands
|
|||
public override string CmdUsage { get { return "list"; } }
|
||||
public override string CmdDesc { get { return Translations.cmd_list_desc; } }
|
||||
|
||||
public override void RegisterCommand(McClient handler, CommandDispatcher<CmdResult> dispatcher)
|
||||
public override void RegisterCommand(CommandDispatcher<CmdResult> dispatcher)
|
||||
{
|
||||
dispatcher.Register(l => l.Literal("help")
|
||||
.Then(l => l.Literal(CmdName)
|
||||
|
|
@ -20,7 +20,7 @@ namespace MinecraftClient.Commands
|
|||
);
|
||||
|
||||
dispatcher.Register(l => l.Literal(CmdName)
|
||||
.Executes(r => DoListPlayers(r.Source, handler))
|
||||
.Executes(r => DoListPlayers(r.Source))
|
||||
.Then(l => l.Literal("_help")
|
||||
.Redirect(dispatcher.GetRoot().GetChild("help").GetChild(CmdName)))
|
||||
);
|
||||
|
|
@ -36,8 +36,9 @@ namespace MinecraftClient.Commands
|
|||
});
|
||||
}
|
||||
|
||||
private int DoListPlayers(CmdResult r, McClient handler)
|
||||
private int DoListPlayers(CmdResult r)
|
||||
{
|
||||
McClient handler = CmdResult.currentHandler!;
|
||||
return r.SetAndReturn(CmdResult.Status.Done, string.Format(Translations.cmd_list_players, String.Join(", ", handler.GetOnlinePlayers())));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ namespace MinecraftClient.Commands
|
|||
public override string CmdUsage { get { return "log <text>"; } }
|
||||
public override string CmdDesc { get { return Translations.cmd_log_desc; } }
|
||||
|
||||
public override void RegisterCommand(McClient handler, CommandDispatcher<CmdResult> dispatcher)
|
||||
public override void RegisterCommand(CommandDispatcher<CmdResult> dispatcher)
|
||||
{
|
||||
dispatcher.Register(l => l.Literal("help")
|
||||
.Then(l => l.Literal(CmdName)
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ namespace MinecraftClient.Commands
|
|||
public override string CmdUsage { get { return "look <x y z|yaw pitch|up|down|east|west|north|south>"; } }
|
||||
public override string CmdDesc { get { return Translations.cmd_look_desc; } }
|
||||
|
||||
public override void RegisterCommand(McClient handler, CommandDispatcher<CmdResult> dispatcher)
|
||||
public override void RegisterCommand(CommandDispatcher<CmdResult> dispatcher)
|
||||
{
|
||||
dispatcher.Register(l => l.Literal("help")
|
||||
.Then(l => l.Literal(CmdName)
|
||||
|
|
@ -28,24 +28,24 @@ namespace MinecraftClient.Commands
|
|||
);
|
||||
|
||||
dispatcher.Register(l => l.Literal(CmdName)
|
||||
.Executes(r => LogCurrentLooking(r.Source, handler))
|
||||
.Executes(r => LogCurrentLooking(r.Source))
|
||||
.Then(l => l.Literal("up")
|
||||
.Executes(r => LookAtDirection(r.Source, handler, Direction.Up)))
|
||||
.Executes(r => LookAtDirection(r.Source, Direction.Up)))
|
||||
.Then(l => l.Literal("down")
|
||||
.Executes(r => LookAtDirection(r.Source, handler, Direction.Down)))
|
||||
.Executes(r => LookAtDirection(r.Source, Direction.Down)))
|
||||
.Then(l => l.Literal("east")
|
||||
.Executes(r => LookAtDirection(r.Source, handler, Direction.East)))
|
||||
.Executes(r => LookAtDirection(r.Source, Direction.East)))
|
||||
.Then(l => l.Literal("west")
|
||||
.Executes(r => LookAtDirection(r.Source, handler, Direction.West)))
|
||||
.Executes(r => LookAtDirection(r.Source, Direction.West)))
|
||||
.Then(l => l.Literal("north")
|
||||
.Executes(r => LookAtDirection(r.Source, handler, Direction.North)))
|
||||
.Executes(r => LookAtDirection(r.Source, Direction.North)))
|
||||
.Then(l => l.Literal("south")
|
||||
.Executes(r => LookAtDirection(r.Source, handler, Direction.South)))
|
||||
.Executes(r => LookAtDirection(r.Source, Direction.South)))
|
||||
.Then(l => l.Argument("Yaw", Arguments.Float())
|
||||
.Then(l => l.Argument("Pitch", Arguments.Float())
|
||||
.Executes(r => LookAtAngle(r.Source, handler, Arguments.GetFloat(r, "Yaw"), Arguments.GetFloat(r, "Pitch")))))
|
||||
.Executes(r => LookAtAngle(r.Source, Arguments.GetFloat(r, "Yaw"), Arguments.GetFloat(r, "Pitch")))))
|
||||
.Then(l => l.Argument("Location", MccArguments.Location())
|
||||
.Executes(r => LookAtLocation(r.Source, handler, MccArguments.GetLocation(r, "Location"))))
|
||||
.Executes(r => LookAtLocation(r.Source, MccArguments.GetLocation(r, "Location"))))
|
||||
.Then(l => l.Literal("_help")
|
||||
.Redirect(dispatcher.GetRoot().GetChild("help").GetChild(CmdName)))
|
||||
);
|
||||
|
|
@ -64,8 +64,9 @@ namespace MinecraftClient.Commands
|
|||
});
|
||||
}
|
||||
|
||||
private int LogCurrentLooking(CmdResult r, McClient handler)
|
||||
private int LogCurrentLooking(CmdResult r)
|
||||
{
|
||||
McClient handler = CmdResult.currentHandler!;
|
||||
if (!handler.GetTerrainEnabled())
|
||||
return r.SetAndReturn(Status.FailNeedTerrain);
|
||||
|
||||
|
|
@ -83,8 +84,9 @@ namespace MinecraftClient.Commands
|
|||
}
|
||||
}
|
||||
|
||||
private int LookAtDirection(CmdResult r, McClient handler, Direction direction)
|
||||
private int LookAtDirection(CmdResult r, Direction direction)
|
||||
{
|
||||
McClient handler = CmdResult.currentHandler!;
|
||||
if (!handler.GetTerrainEnabled())
|
||||
return r.SetAndReturn(Status.FailNeedTerrain);
|
||||
|
||||
|
|
@ -92,8 +94,9 @@ namespace MinecraftClient.Commands
|
|||
return r.SetAndReturn(Status.Done, "Looking " + direction.ToString());
|
||||
}
|
||||
|
||||
private int LookAtAngle(CmdResult r, McClient handler, float yaw, float pitch)
|
||||
private int LookAtAngle(CmdResult r, float yaw, float pitch)
|
||||
{
|
||||
McClient handler = CmdResult.currentHandler!;
|
||||
if (!handler.GetTerrainEnabled())
|
||||
return r.SetAndReturn(Status.FailNeedTerrain);
|
||||
|
||||
|
|
@ -101,8 +104,9 @@ namespace MinecraftClient.Commands
|
|||
return r.SetAndReturn(Status.Done, string.Format(Translations.cmd_look_at, yaw.ToString("0.00"), pitch.ToString("0.00")));
|
||||
}
|
||||
|
||||
private int LookAtLocation(CmdResult r, McClient handler, Location location)
|
||||
private int LookAtLocation(CmdResult r, Location location)
|
||||
{
|
||||
McClient handler = CmdResult.currentHandler!;
|
||||
if (!handler.GetTerrainEnabled())
|
||||
return r.SetAndReturn(Status.FailNeedTerrain);
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ namespace MinecraftClient.Commands
|
|||
public override string CmdUsage { get { return "move <on|off|get|up|down|east|west|north|south|center|x y z|gravity [on|off]> [-f]"; } }
|
||||
public override string CmdDesc { get { return Translations.cmd_move_desc + " \"-f\": " + Translations.cmd_move_desc_force; } }
|
||||
|
||||
public override void RegisterCommand(McClient handler, CommandDispatcher<CmdResult> dispatcher)
|
||||
public override void RegisterCommand(CommandDispatcher<CmdResult> dispatcher)
|
||||
{
|
||||
dispatcher.Register(l => l.Literal("help")
|
||||
.Then(l => l.Literal(CmdName)
|
||||
|
|
@ -37,47 +37,47 @@ namespace MinecraftClient.Commands
|
|||
|
||||
dispatcher.Register(l => l.Literal(CmdName)
|
||||
.Then(l => l.Literal("on")
|
||||
.Executes(r => SetMovementEnable(r.Source, handler, enable: true)))
|
||||
.Executes(r => SetMovementEnable(r.Source, enable: true)))
|
||||
.Then(l => l.Literal("off")
|
||||
.Executes(r => SetMovementEnable(r.Source, handler, enable: false)))
|
||||
.Executes(r => SetMovementEnable(r.Source, enable: false)))
|
||||
.Then(l => l.Literal("gravity")
|
||||
.Executes(r => SetGravityEnable(r.Source, handler, enable: null))
|
||||
.Executes(r => SetGravityEnable(r.Source, enable: null))
|
||||
.Then(l => l.Literal("on")
|
||||
.Executes(r => SetGravityEnable(r.Source, handler, enable: true)))
|
||||
.Executes(r => SetGravityEnable(r.Source, enable: true)))
|
||||
.Then(l => l.Literal("off")
|
||||
.Executes(r => SetGravityEnable(r.Source, handler, enable: false))))
|
||||
.Executes(r => SetGravityEnable(r.Source, enable: false))))
|
||||
.Then(l => l.Literal("up")
|
||||
.Executes(r => MoveOnDirection(r.Source, handler, Direction.Up, false))
|
||||
.Executes(r => MoveOnDirection(r.Source, Direction.Up, false))
|
||||
.Then(l => l.Literal("-f")
|
||||
.Executes(r => MoveOnDirection(r.Source, handler, Direction.Up, true))))
|
||||
.Executes(r => MoveOnDirection(r.Source, Direction.Up, true))))
|
||||
.Then(l => l.Literal("down")
|
||||
.Executes(r => MoveOnDirection(r.Source, handler, Direction.Down, false))
|
||||
.Executes(r => MoveOnDirection(r.Source, Direction.Down, false))
|
||||
.Then(l => l.Literal("-f")
|
||||
.Executes(r => MoveOnDirection(r.Source, handler, Direction.Down, true))))
|
||||
.Executes(r => MoveOnDirection(r.Source, Direction.Down, true))))
|
||||
.Then(l => l.Literal("east")
|
||||
.Executes(r => MoveOnDirection(r.Source, handler, Direction.East, false))
|
||||
.Executes(r => MoveOnDirection(r.Source, Direction.East, false))
|
||||
.Then(l => l.Literal("-f")
|
||||
.Executes(r => MoveOnDirection(r.Source, handler, Direction.East, true))))
|
||||
.Executes(r => MoveOnDirection(r.Source, Direction.East, true))))
|
||||
.Then(l => l.Literal("west")
|
||||
.Executes(r => MoveOnDirection(r.Source, handler, Direction.West, false))
|
||||
.Executes(r => MoveOnDirection(r.Source, Direction.West, false))
|
||||
.Then(l => l.Literal("-f")
|
||||
.Executes(r => MoveOnDirection(r.Source, handler, Direction.West, true))))
|
||||
.Executes(r => MoveOnDirection(r.Source, Direction.West, true))))
|
||||
.Then(l => l.Literal("north")
|
||||
.Executes(r => MoveOnDirection(r.Source, handler, Direction.North, false))
|
||||
.Executes(r => MoveOnDirection(r.Source, Direction.North, false))
|
||||
.Then(l => l.Literal("-f")
|
||||
.Executes(r => MoveOnDirection(r.Source, handler, Direction.North, true))))
|
||||
.Executes(r => MoveOnDirection(r.Source, Direction.North, true))))
|
||||
.Then(l => l.Literal("south")
|
||||
.Executes(r => MoveOnDirection(r.Source, handler, Direction.South, false))
|
||||
.Executes(r => MoveOnDirection(r.Source, Direction.South, false))
|
||||
.Then(l => l.Literal("-f")
|
||||
.Executes(r => MoveOnDirection(r.Source, handler, Direction.South, true))))
|
||||
.Executes(r => MoveOnDirection(r.Source, Direction.South, true))))
|
||||
.Then(l => l.Literal("center")
|
||||
.Executes(r => MoveToCenter(r.Source, handler)))
|
||||
.Executes(r => MoveToCenter(r.Source)))
|
||||
.Then(l => l.Literal("get")
|
||||
.Executes(r => GetCurrentLocation(r.Source, handler)))
|
||||
.Executes(r => GetCurrentLocation(r.Source)))
|
||||
.Then(l => l.Argument("location", MccArguments.Location())
|
||||
.Executes(r => MoveToLocation(r.Source, handler, MccArguments.GetLocation(r, "location"), false))
|
||||
.Executes(r => MoveToLocation(r.Source, MccArguments.GetLocation(r, "location"), false))
|
||||
.Then(l => l.Literal("-f")
|
||||
.Executes(r => MoveToLocation(r.Source, handler, MccArguments.GetLocation(r, "location"), true))))
|
||||
.Executes(r => MoveToLocation(r.Source, MccArguments.GetLocation(r, "location"), true))))
|
||||
.Then(l => l.Literal("_help")
|
||||
.Redirect(dispatcher.GetRoot().GetChild("help").GetChild(CmdName)))
|
||||
);
|
||||
|
|
@ -100,8 +100,9 @@ namespace MinecraftClient.Commands
|
|||
});
|
||||
}
|
||||
|
||||
private int SetMovementEnable(CmdResult r, McClient handler, bool enable)
|
||||
private int SetMovementEnable(CmdResult r, bool enable)
|
||||
{
|
||||
McClient handler = CmdResult.currentHandler!;
|
||||
if (enable)
|
||||
{
|
||||
handler.SetTerrainEnabled(true);
|
||||
|
|
@ -114,8 +115,9 @@ namespace MinecraftClient.Commands
|
|||
}
|
||||
}
|
||||
|
||||
private int SetGravityEnable(CmdResult r, McClient handler, bool? enable)
|
||||
private int SetGravityEnable(CmdResult r, bool? enable)
|
||||
{
|
||||
McClient handler = CmdResult.currentHandler!;
|
||||
if (enable.HasValue)
|
||||
Settings.InternalConfig.GravityEnabled = enable.Value;
|
||||
|
||||
|
|
@ -125,16 +127,18 @@ namespace MinecraftClient.Commands
|
|||
return r.SetAndReturn(CmdResult.Status.Done, Translations.cmd_move_gravity_disabled);
|
||||
}
|
||||
|
||||
private int GetCurrentLocation(CmdResult r, McClient handler)
|
||||
private int GetCurrentLocation(CmdResult r)
|
||||
{
|
||||
McClient handler = CmdResult.currentHandler!;
|
||||
if (!handler.GetTerrainEnabled())
|
||||
return r.SetAndReturn(Status.FailNeedTerrain);
|
||||
|
||||
return r.SetAndReturn(Status.Done, handler.GetCurrentLocation().ToString());
|
||||
}
|
||||
|
||||
private int MoveToCenter(CmdResult r, McClient handler)
|
||||
private int MoveToCenter(CmdResult r)
|
||||
{
|
||||
McClient handler = CmdResult.currentHandler!;
|
||||
if (!handler.GetTerrainEnabled())
|
||||
return r.SetAndReturn(Status.FailNeedTerrain);
|
||||
|
||||
|
|
@ -144,8 +148,9 @@ namespace MinecraftClient.Commands
|
|||
return r.SetAndReturn(Status.Done, string.Format(Translations.cmd_move_walk, currentCenter, current));
|
||||
}
|
||||
|
||||
private int MoveOnDirection(CmdResult r, McClient handler, Direction direction, bool takeRisk)
|
||||
private int MoveOnDirection(CmdResult r, Direction direction, bool takeRisk)
|
||||
{
|
||||
McClient handler = CmdResult.currentHandler!;
|
||||
if (!handler.GetTerrainEnabled())
|
||||
return r.SetAndReturn(Status.FailNeedTerrain);
|
||||
|
||||
|
|
@ -167,8 +172,9 @@ namespace MinecraftClient.Commands
|
|||
}
|
||||
}
|
||||
|
||||
private int MoveToLocation(CmdResult r, McClient handler, Location goal, bool takeRisk)
|
||||
private int MoveToLocation(CmdResult r, Location goal, bool takeRisk)
|
||||
{
|
||||
McClient handler = CmdResult.currentHandler!;
|
||||
if (!handler.GetTerrainEnabled())
|
||||
return r.SetAndReturn(Status.FailNeedTerrain);
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ namespace MinecraftClient.Commands
|
|||
public override string CmdUsage { get { return "reco [account]"; } }
|
||||
public override string CmdDesc { get { return Translations.cmd_reco_desc; } }
|
||||
|
||||
public override void RegisterCommand(McClient handler, CommandDispatcher<CmdResult> dispatcher)
|
||||
public override void RegisterCommand(CommandDispatcher<CmdResult> dispatcher)
|
||||
{
|
||||
dispatcher.Register(l => l.Literal("help")
|
||||
.Then(l => l.Literal(CmdName)
|
||||
|
|
@ -40,7 +40,7 @@ namespace MinecraftClient.Commands
|
|||
|
||||
private int DoReconnect(CmdResult r, string account)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(account))
|
||||
if (!string.IsNullOrWhiteSpace(account))
|
||||
{
|
||||
account = account.Trim();
|
||||
if (!Settings.Config.Main.Advanced.SetAccount(account))
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ namespace MinecraftClient.Commands
|
|||
public override string CmdUsage { get { return "reload"; } }
|
||||
public override string CmdDesc { get { return Translations.cmd_reload_desc; } }
|
||||
|
||||
public override void RegisterCommand(McClient handler, CommandDispatcher<CmdResult> dispatcher)
|
||||
public override void RegisterCommand(CommandDispatcher<CmdResult> dispatcher)
|
||||
{
|
||||
dispatcher.Register(l => l.Literal("help")
|
||||
.Then(l => l.Literal(CmdName)
|
||||
|
|
@ -19,7 +19,7 @@ namespace MinecraftClient.Commands
|
|||
);
|
||||
|
||||
dispatcher.Register(l => l.Literal(CmdName)
|
||||
.Executes(r => DoReload(r.Source, handler))
|
||||
.Executes(r => DoReload(r.Source))
|
||||
.Then(l => l.Literal("_help")
|
||||
.Redirect(dispatcher.GetRoot().GetChild("help").GetChild(CmdName)))
|
||||
);
|
||||
|
|
@ -35,8 +35,9 @@ namespace MinecraftClient.Commands
|
|||
});
|
||||
}
|
||||
|
||||
private int DoReload(CmdResult r, McClient handler)
|
||||
private int DoReload(CmdResult r)
|
||||
{
|
||||
McClient handler = CmdResult.currentHandler!;
|
||||
handler.Log.Info(Translations.cmd_reload_started);
|
||||
handler.ReloadSettings();
|
||||
handler.Log.Warn(Translations.cmd_reload_warning1);
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ namespace MinecraftClient.Commands
|
|||
public override string CmdUsage { get { return "respawn"; } }
|
||||
public override string CmdDesc { get { return Translations.cmd_respawn_desc; } }
|
||||
|
||||
public override void RegisterCommand(McClient handler, CommandDispatcher<CmdResult> dispatcher)
|
||||
public override void RegisterCommand(CommandDispatcher<CmdResult> dispatcher)
|
||||
{
|
||||
dispatcher.Register(l => l.Literal("help")
|
||||
.Then(l => l.Literal(CmdName)
|
||||
|
|
@ -19,7 +19,7 @@ namespace MinecraftClient.Commands
|
|||
);
|
||||
|
||||
dispatcher.Register(l => l.Literal(CmdName)
|
||||
.Executes(r => DoRespawn(r.Source, handler))
|
||||
.Executes(r => DoRespawn(r.Source))
|
||||
.Then(l => l.Literal("_help")
|
||||
.Redirect(dispatcher.GetRoot().GetChild("help").GetChild(CmdName)))
|
||||
);
|
||||
|
|
@ -35,8 +35,9 @@ namespace MinecraftClient.Commands
|
|||
});
|
||||
}
|
||||
|
||||
private int DoRespawn(CmdResult r, McClient handler)
|
||||
private int DoRespawn(CmdResult r)
|
||||
{
|
||||
McClient handler = CmdResult.currentHandler!;
|
||||
handler.SendRespawnPacket();
|
||||
return r.SetAndReturn(CmdResult.Status.Done, Translations.cmd_respawn_done);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ namespace MinecraftClient.Commands
|
|||
public override string CmdUsage { get { return "script <scriptname>"; } }
|
||||
public override string CmdDesc { get { return Translations.cmd_script_desc; } }
|
||||
|
||||
public override void RegisterCommand(McClient handler, CommandDispatcher<CmdResult> dispatcher)
|
||||
public override void RegisterCommand(CommandDispatcher<CmdResult> dispatcher)
|
||||
{
|
||||
dispatcher.Register(l => l.Literal("help")
|
||||
.Then(l => l.Literal(CmdName)
|
||||
|
|
@ -21,7 +21,7 @@ namespace MinecraftClient.Commands
|
|||
|
||||
dispatcher.Register(l => l.Literal(CmdName)
|
||||
.Then(l => l.Argument("Script", Arguments.GreedyString())
|
||||
.Executes(r => DoExecuteScript(r.Source, handler, Arguments.GetString(r, "Script"), null)))
|
||||
.Executes(r => DoExecuteScript(r.Source, Arguments.GetString(r, "Script"), null)))
|
||||
.Then(l => l.Literal("_help")
|
||||
.Redirect(dispatcher.GetRoot().GetChild("help").GetChild(CmdName)))
|
||||
);
|
||||
|
|
@ -37,8 +37,9 @@ namespace MinecraftClient.Commands
|
|||
});
|
||||
}
|
||||
|
||||
private int DoExecuteScript(CmdResult r, McClient handler, string command, Dictionary<string, object>? localVars)
|
||||
private int DoExecuteScript(CmdResult r, string command, Dictionary<string, object>? localVars)
|
||||
{
|
||||
McClient handler = CmdResult.currentHandler!;
|
||||
handler.BotLoad(new ChatBots.Script(command.Trim(), null, localVars));
|
||||
return r.SetAndReturn(CmdResult.Status.Done);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ namespace MinecraftClient.Commands
|
|||
public override string CmdUsage { get { return "send <text>"; } }
|
||||
public override string CmdDesc { get { return Translations.cmd_send_desc; } }
|
||||
|
||||
public override void RegisterCommand(McClient handler, CommandDispatcher<CmdResult> dispatcher)
|
||||
public override void RegisterCommand(CommandDispatcher<CmdResult> dispatcher)
|
||||
{
|
||||
dispatcher.Register(l => l.Literal("help")
|
||||
.Then(l => l.Literal(CmdName)
|
||||
|
|
@ -20,7 +20,7 @@ namespace MinecraftClient.Commands
|
|||
|
||||
dispatcher.Register(l => l.Literal(CmdName)
|
||||
.Then(l => l.Argument("any", Arguments.GreedyString())
|
||||
.Executes(r => DoSendText(r.Source, handler, Arguments.GetString(r, "any"))))
|
||||
.Executes(r => DoSendText(r.Source, Arguments.GetString(r, "any"))))
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -34,8 +34,9 @@ namespace MinecraftClient.Commands
|
|||
});
|
||||
}
|
||||
|
||||
private int DoSendText(CmdResult r, McClient handler, string command)
|
||||
private int DoSendText(CmdResult r, string command)
|
||||
{
|
||||
McClient handler = CmdResult.currentHandler!;
|
||||
handler.SendText(command);
|
||||
return r.SetAndReturn(CmdResult.Status.Done);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ namespace MinecraftClient.Commands
|
|||
public override string CmdUsage { get { return "set varname=value"; } }
|
||||
public override string CmdDesc { get { return Translations.cmd_set_desc; } }
|
||||
|
||||
public override void RegisterCommand(McClient handler, CommandDispatcher<CmdResult> dispatcher)
|
||||
public override void RegisterCommand(CommandDispatcher<CmdResult> dispatcher)
|
||||
{
|
||||
dispatcher.Register(l => l.Literal("help")
|
||||
.Then(l => l.Literal(CmdName)
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ namespace MinecraftClient.Commands
|
|||
public override string CmdDesc { get { return Translations.cmd_setrnd_desc; } }
|
||||
private static readonly Random rand = new();
|
||||
|
||||
public override void RegisterCommand(McClient handler, CommandDispatcher<CmdResult> dispatcher)
|
||||
public override void RegisterCommand(CommandDispatcher<CmdResult> dispatcher)
|
||||
{
|
||||
dispatcher.Register(l => l.Literal("help")
|
||||
.Then(l => l.Literal(CmdName)
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ namespace MinecraftClient.Commands
|
|||
public override string CmdUsage { get { return "sneak"; } }
|
||||
public override string CmdDesc { get { return Translations.cmd_sneak_desc; } }
|
||||
|
||||
public override void RegisterCommand(McClient handler, CommandDispatcher<CmdResult> dispatcher)
|
||||
public override void RegisterCommand(CommandDispatcher<CmdResult> dispatcher)
|
||||
{
|
||||
dispatcher.Register(l => l.Literal("help")
|
||||
.Then(l => l.Literal(CmdName)
|
||||
|
|
@ -20,7 +20,7 @@ namespace MinecraftClient.Commands
|
|||
);
|
||||
|
||||
dispatcher.Register(l => l.Literal(CmdName)
|
||||
.Executes(r => DoSneak(r.Source, handler))
|
||||
.Executes(r => DoSneak(r.Source))
|
||||
.Then(l => l.Literal("_help")
|
||||
.Redirect(dispatcher.GetRoot().GetChild("help").GetChild(CmdName)))
|
||||
);
|
||||
|
|
@ -36,8 +36,9 @@ namespace MinecraftClient.Commands
|
|||
});
|
||||
}
|
||||
|
||||
private int DoSneak(CmdResult r, McClient handler)
|
||||
private int DoSneak(CmdResult r)
|
||||
{
|
||||
McClient handler = CmdResult.currentHandler!;
|
||||
if (sneaking)
|
||||
{
|
||||
var result = handler.SendEntityAction(Protocol.EntityActionType.StopSneaking);
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ namespace MinecraftClient.Commands
|
|||
public override string CmdUsage { get { return "tps"; } }
|
||||
public override string CmdDesc { get { return Translations.cmd_tps_desc; } }
|
||||
|
||||
public override void RegisterCommand(McClient handler, CommandDispatcher<CmdResult> dispatcher)
|
||||
public override void RegisterCommand(CommandDispatcher<CmdResult> dispatcher)
|
||||
{
|
||||
dispatcher.Register(l => l.Literal("help")
|
||||
.Then(l => l.Literal(CmdName)
|
||||
|
|
@ -20,7 +20,7 @@ namespace MinecraftClient.Commands
|
|||
);
|
||||
|
||||
dispatcher.Register(l => l.Literal(CmdName)
|
||||
.Executes(r => DoLogTps(r.Source, handler))
|
||||
.Executes(r => DoLogTps(r.Source))
|
||||
.Then(l => l.Literal("_help")
|
||||
.Redirect(dispatcher.GetRoot().GetChild("help").GetChild(CmdName)))
|
||||
);
|
||||
|
|
@ -36,8 +36,9 @@ namespace MinecraftClient.Commands
|
|||
});
|
||||
}
|
||||
|
||||
private int DoLogTps(CmdResult r, McClient handler)
|
||||
private int DoLogTps(CmdResult r)
|
||||
{
|
||||
McClient handler = CmdResult.currentHandler!;
|
||||
var tps = Math.Round(handler.GetServerTPS(), 2);
|
||||
string color;
|
||||
if (tps < 10)
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ namespace MinecraftClient.Commands
|
|||
public override string CmdUsage { get { return "upgrade [-f|check|cancel|download]"; } }
|
||||
public override string CmdDesc { get { return string.Empty; } }
|
||||
|
||||
public override void RegisterCommand(McClient handler, CommandDispatcher<CmdResult> dispatcher)
|
||||
public override void RegisterCommand(CommandDispatcher<CmdResult> dispatcher)
|
||||
{
|
||||
dispatcher.Register(l => l.Literal("help")
|
||||
.Then(l => l.Literal(CmdName)
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ namespace MinecraftClient.Commands
|
|||
public override string CmdUsage { get { return "useitem"; } }
|
||||
public override string CmdDesc { get { return Translations.cmd_useitem_desc; } }
|
||||
|
||||
public override void RegisterCommand(McClient handler, CommandDispatcher<CmdResult> dispatcher)
|
||||
public override void RegisterCommand(CommandDispatcher<CmdResult> dispatcher)
|
||||
{
|
||||
dispatcher.Register(l => l.Literal("help")
|
||||
.Then(l => l.Literal(CmdName)
|
||||
|
|
@ -20,7 +20,7 @@ namespace MinecraftClient.Commands
|
|||
);
|
||||
|
||||
dispatcher.Register(l => l.Literal(CmdName)
|
||||
.Executes(r => DoUseItem(r.Source, handler))
|
||||
.Executes(r => DoUseItem(r.Source))
|
||||
.Then(l => l.Literal("_help")
|
||||
.Redirect(dispatcher.GetRoot().GetChild("help").GetChild(CmdName)))
|
||||
);
|
||||
|
|
@ -36,8 +36,9 @@ namespace MinecraftClient.Commands
|
|||
});
|
||||
}
|
||||
|
||||
private int DoUseItem(CmdResult r, McClient handler)
|
||||
private int DoUseItem(CmdResult r)
|
||||
{
|
||||
McClient handler = CmdResult.currentHandler!;
|
||||
if (!handler.GetInventoryEnabled())
|
||||
return r.SetAndReturn(Status.FailNeedInventory);
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ namespace MinecraftClient.Commands
|
|||
public override string CmdUsage { get { return "useblock <x> <y> <z>"; } }
|
||||
public override string CmdDesc { get { return Translations.cmd_useblock_desc; } }
|
||||
|
||||
public override void RegisterCommand(McClient handler, CommandDispatcher<CmdResult> dispatcher)
|
||||
public override void RegisterCommand(CommandDispatcher<CmdResult> dispatcher)
|
||||
{
|
||||
dispatcher.Register(l => l.Literal("help")
|
||||
.Then(l => l.Literal(CmdName)
|
||||
|
|
@ -22,7 +22,7 @@ namespace MinecraftClient.Commands
|
|||
|
||||
dispatcher.Register(l => l.Literal(CmdName)
|
||||
.Then(l => l.Argument("Location", MccArguments.Location())
|
||||
.Executes(r => UseBlockAtLocation(r.Source, handler, MccArguments.GetLocation(r, "Location"))))
|
||||
.Executes(r => UseBlockAtLocation(r.Source, MccArguments.GetLocation(r, "Location"))))
|
||||
.Then(l => l.Literal("_help")
|
||||
.Redirect(dispatcher.GetRoot().GetChild("help").GetChild(CmdName)))
|
||||
);
|
||||
|
|
@ -38,8 +38,9 @@ namespace MinecraftClient.Commands
|
|||
});
|
||||
}
|
||||
|
||||
private int UseBlockAtLocation(CmdResult r, McClient handler, Location block)
|
||||
private int UseBlockAtLocation(CmdResult r, Location block)
|
||||
{
|
||||
McClient handler = CmdResult.currentHandler!;
|
||||
if (!handler.GetTerrainEnabled())
|
||||
return r.SetAndReturn(Status.FailNeedTerrain);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue