Improve error message when commands fail to be added and make commands using the new system check for masking (#1404)
* Improve error message when command already exists * Add app's name to the message * Add app name to any command load failure and fix commands from new system masking existing ones * Fix duplicated app name in an error * Update to recent snapshot changes
This commit is contained in:
1 parent
286dbead14
commit
41991b0346
2 files changed
+9
-4
No files matched your search
@@ -389,6 +389,11 @@ public class CarpetScriptHost extends ScriptHost
|
|||||||
}
|
}
|
||||||
if (appConfig.get(StringValue.of("commands")) != null)
|
if (appConfig.get(StringValue.of("commands")) != null)
|
||||||
{
|
{
|
||||||
|
if (scriptServer().isInvalidCommandRoot(getName()))
|
||||||
|
{
|
||||||
|
notifier.accept(Messenger.c("g A command with the app's name already exists in vanilla or an installed mod."));
|
||||||
|
return null;
|
||||||
|
}
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
LiteralArgumentBuilder<CommandSourceStack> command = readCommands(commandValidator);
|
LiteralArgumentBuilder<CommandSourceStack> command = readCommands(commandValidator);
|
||||||
@@ -404,7 +409,7 @@ public class CarpetScriptHost extends ScriptHost
|
|||||||
catch (CommandSyntaxException cse)
|
catch (CommandSyntaxException cse)
|
||||||
{
|
{
|
||||||
// failed
|
// failed
|
||||||
notifier.accept(Messenger.c("r Failed to build command system for "+getName()+" thus failed to load the app: ", cse.getRawMessage()));
|
notifier.accept(Messenger.c("r Failed to build command system: ", cse.getRawMessage()));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -451,7 +456,7 @@ public class CarpetScriptHost extends ScriptHost
|
|||||||
|
|
||||||
if (scriptServer().isInvalidCommandRoot(getName()))
|
if (scriptServer().isInvalidCommandRoot(getName()))
|
||||||
{
|
{
|
||||||
notifier.accept(Messenger.c("gi Tried to mask vanilla command."));
|
notifier.accept(Messenger.c("g A command with the app's name already exists in vanilla or an installed mod."));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -295,9 +295,9 @@ public class CarpetScriptServer extends ScriptServer
|
|||||||
//addEvents(source, name);
|
//addEvents(source, name);
|
||||||
String action = (installer!=null)?(reload?"reinstalled":"installed"):(reload?"reloaded":"loaded");
|
String action = (installer!=null)?(reload?"reinstalled":"installed"):(reload?"reloaded":"loaded");
|
||||||
|
|
||||||
|
String finalName = name;
|
||||||
Boolean isCommandAdded = newHost.addAppCommands(s -> {
|
Boolean isCommandAdded = newHost.addAppCommands(s -> {
|
||||||
if (!isRuleApp) Messenger.m(source, s);
|
if (!isRuleApp) Messenger.m(source, Messenger.c("r Failed to add app '" + finalName + "': ", s));
|
||||||
});
|
});
|
||||||
if (isCommandAdded == null) // error should be dispatched
|
if (isCommandAdded == null) // error should be dispatched
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in new issue
Block a user