mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-10-14 21:22:49 +00:00
Fix script not showing execution results.
This commit is contained in:
parent
8db0467f69
commit
338f534239
5 changed files with 88 additions and 7 deletions
|
|
@ -0,0 +1,54 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Brigadier.NET;
|
||||
using Brigadier.NET.ArgumentTypes;
|
||||
using Brigadier.NET.Context;
|
||||
using Brigadier.NET.Suggestion;
|
||||
|
||||
namespace MinecraftClient.CommandHandler.ArgumentType
|
||||
{
|
||||
public class ScriptNameArgumentType : ArgumentType<string>
|
||||
{
|
||||
public override string Parse(IStringReader reader)
|
||||
{
|
||||
string remaining = reader.Remaining;
|
||||
reader.Cursor += reader.RemainingLength;
|
||||
return remaining;
|
||||
}
|
||||
|
||||
public override Task<Suggestions> ListSuggestions<TSource>(CommandContext<TSource> context, SuggestionsBuilder builder)
|
||||
{
|
||||
try
|
||||
{
|
||||
string? dir = Path.GetDirectoryName(builder.Remaining);
|
||||
if (!string.IsNullOrEmpty(dir) && Path.Exists(dir))
|
||||
{
|
||||
foreach (string fileName in Directory.GetFiles(dir, "*.cs"))
|
||||
builder.Suggest(fileName);
|
||||
foreach (string fileName in Directory.GetFiles(dir, "*.txt"))
|
||||
builder.Suggest(fileName);
|
||||
}
|
||||
}
|
||||
catch (IOException) { }
|
||||
catch (ArgumentException) { }
|
||||
catch (UnauthorizedAccessException) { }
|
||||
|
||||
try
|
||||
{
|
||||
foreach (string fileName in Directory.GetFiles("." + Path.DirectorySeparatorChar, "*.cs"))
|
||||
builder.Suggest(fileName);
|
||||
foreach (string fileName in Directory.GetFiles("." + Path.DirectorySeparatorChar, "*.txt"))
|
||||
builder.Suggest(fileName);
|
||||
}
|
||||
catch (IOException) { }
|
||||
catch (ArgumentException) { }
|
||||
catch (UnauthorizedAccessException) { }
|
||||
|
||||
return builder.BuildFuture();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -110,5 +110,10 @@ namespace MinecraftClient.CommandHandler
|
|||
{
|
||||
return new HotbarSlotArgumentType();
|
||||
}
|
||||
|
||||
public static ScriptNameArgumentType ScriptName()
|
||||
{
|
||||
return new ScriptNameArgumentType();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue