Refactoring to asynchronous. (partially completed)

This commit is contained in:
BruceChen 2022-12-20 22:41:14 +08:00
parent 7ee08092d4
commit 096ea0c70c
72 changed files with 6033 additions and 5080 deletions

View file

@ -159,7 +159,7 @@ namespace MinecraftClient.Commands
if (handler.GetGamemode() == 1)
{
if (handler.DoCreativeGive(slot, itemType, count, null))
if (handler.DoCreativeGive(slot, itemType, count, null).Result)
return r.SetAndReturn(CmdResult.Status.Done, string.Format(Translations.cmd_inventory_creative_done, itemType, count, slot));
else
return r.SetAndReturn(CmdResult.Status.Fail, Translations.cmd_inventory_creative_fail);
@ -178,7 +178,7 @@ namespace MinecraftClient.Commands
if (handler.GetGamemode() == 1)
{
if (handler.DoCreativeGive(slot, ItemType.Null, 0, null))
if (handler.DoCreativeGive(slot, ItemType.Null, 0, null).Result)
return r.SetAndReturn(CmdResult.Status.Done, string.Format(Translations.cmd_inventory_creative_delete, slot));
else
return r.SetAndReturn(CmdResult.Status.Fail, Translations.cmd_inventory_creative_fail);
@ -279,7 +279,7 @@ namespace MinecraftClient.Commands
if (inventory == null)
return r.SetAndReturn(CmdResult.Status.Fail, string.Format(Translations.cmd_inventory_not_exist, inventoryId));
if (handler.CloseInventory(inventoryId.Value))
if (handler.CloseInventory(inventoryId.Value).Result)
return r.SetAndReturn(CmdResult.Status.Done, string.Format(Translations.cmd_inventory_close, inventoryId));
else
return r.SetAndReturn(CmdResult.Status.Fail, string.Format(Translations.cmd_inventory_close_fail, inventoryId));
@ -355,7 +355,9 @@ namespace MinecraftClient.Commands
};
handler.Log.Info(string.Format(Translations.cmd_inventory_clicking, keyName, slot, inventoryId));
return r.SetAndReturn(handler.DoWindowAction(inventoryId.Value, slot, actionType));
var task = handler.DoWindowAction(inventoryId.Value, slot, actionType);
task.Wait();
return r.SetAndReturn(task.Result);
}
private int DoDropAction(CmdResult r, int? inventoryId, int slot, WindowActionType actionType)
@ -379,7 +381,7 @@ namespace MinecraftClient.Commands
if (!inventory.Items.ContainsKey(slot))
return r.SetAndReturn(CmdResult.Status.Fail, string.Format(Translations.cmd_inventory_no_item, slot));
if (handler.DoWindowAction(inventoryId.Value, slot, actionType))
if (handler.DoWindowAction(inventoryId.Value, slot, actionType).Result)
{
if (actionType == WindowActionType.DropItemStack)
return r.SetAndReturn(CmdResult.Status.Done, string.Format(Translations.cmd_inventory_drop_stack, slot));