Merge branch 'master' into 1.17
# Conflicts: # src/main/java/carpet/script/utils/ShapeDispatcher.java
This commit is contained in:
commit
8ed4561a98
5 files changed
+93
-71
No files matched your search
@@ -319,20 +319,20 @@ public abstract class CommandArgument
|
||||
return suffix;
|
||||
}
|
||||
|
||||
public static CommandArgument buildFromConfig(String suffix, Map<String, Value> config, CarpetScriptHost host)
|
||||
public static CommandArgument buildFromConfig(String suffix, Map<String, Value> config, CarpetScriptHost host) throws CommandSyntaxException
|
||||
{
|
||||
if (!config.containsKey("type"))
|
||||
throw new InternalExpressionException("Custom type "+suffix+" should at least specify the type");
|
||||
throw CommandArgument.error("Custom type "+suffix+" should at least specify the type");
|
||||
String baseType = config.get("type").getString();
|
||||
if (!builtIns.containsKey(baseType))
|
||||
throw new InternalExpressionException("Unknown base type "+baseType+" for custom type "+suffix);
|
||||
throw CommandArgument.error("Unknown base type "+baseType+" for custom type "+suffix);
|
||||
CommandArgument variant = builtIns.get(baseType).factory().get();
|
||||
variant.suffix = suffix;
|
||||
variant.configure(config, host);
|
||||
return variant;
|
||||
}
|
||||
|
||||
protected void configure(Map<String, Value> config, CarpetScriptHost host)
|
||||
protected void configure(Map<String, Value> config, CarpetScriptHost host) throws CommandSyntaxException
|
||||
{
|
||||
caseSensitive = config.getOrDefault("case_sensitive", Value.TRUE).getBoolean();
|
||||
if (config.containsKey("suggester"))
|
||||
@@ -341,9 +341,9 @@ public abstract class CommandArgument
|
||||
}
|
||||
if (config.containsKey("suggest"))
|
||||
{
|
||||
if (config.containsKey("suggester")) throw new InternalExpressionException("Attempted to provide 'suggest' list while 'suggester' is present"+" for custom type "+suffix);
|
||||
if (config.containsKey("suggester")) throw error("Attempted to provide 'suggest' list while 'suggester' is present"+" for custom type "+suffix);
|
||||
Value suggestionValue = config.get("suggest");
|
||||
if (!(suggestionValue instanceof ListValue)) throw new InternalExpressionException("Argument suggestions needs to be a list"+" for custom type "+suffix);
|
||||
if (!(suggestionValue instanceof ListValue)) throw error("Argument suggestions needs to be a list"+" for custom type "+suffix);
|
||||
examples = ((ListValue) suggestionValue).getItems().stream()
|
||||
.map(Value::getString)
|
||||
.collect(Collectors.toSet());
|
||||
@@ -442,13 +442,13 @@ public abstract class CommandArgument
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configure(Map<String, Value> config, CarpetScriptHost host)
|
||||
protected void configure(Map<String, Value> config, CarpetScriptHost host) throws CommandSyntaxException
|
||||
{
|
||||
super.configure(config, host);
|
||||
if (config.containsKey("options"))
|
||||
{
|
||||
Value optionsValue = config.get("options");
|
||||
if (!(optionsValue instanceof ListValue)) throw new InternalExpressionException("Custom string type requires options passed as a list"+" for custom type "+suffix);
|
||||
if (!(optionsValue instanceof ListValue)) throw error("Custom string type requires options passed as a list"+" for custom type "+suffix);
|
||||
validOptions = ((ListValue) optionsValue).getItems().stream()
|
||||
.map(v -> caseSensitive?v.getString():(v.getString().toLowerCase(Locale.ROOT)))
|
||||
.collect(Collectors.toSet());
|
||||
@@ -508,7 +508,7 @@ public abstract class CommandArgument
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configure(Map<String, Value> config, CarpetScriptHost host)
|
||||
protected void configure(Map<String, Value> config, CarpetScriptHost host) throws CommandSyntaxException
|
||||
{
|
||||
super.configure(config, host);
|
||||
mustBeLoaded = config.getOrDefault("loaded", Value.FALSE).getBoolean();
|
||||
@@ -543,7 +543,7 @@ public abstract class CommandArgument
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configure(Map<String, Value> config, CarpetScriptHost host)
|
||||
protected void configure(Map<String, Value> config, CarpetScriptHost host) throws CommandSyntaxException
|
||||
{
|
||||
super.configure(config, host);
|
||||
blockCentered = config.getOrDefault("block_centered", Value.TRUE).getBoolean();
|
||||
@@ -591,7 +591,7 @@ public abstract class CommandArgument
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configure(Map<String, Value> config, CarpetScriptHost host)
|
||||
protected void configure(Map<String, Value> config, CarpetScriptHost host) throws CommandSyntaxException
|
||||
{
|
||||
super.configure(config, host);
|
||||
onlyFans = config.getOrDefault("players", Value.FALSE).getBoolean();
|
||||
@@ -632,7 +632,7 @@ public abstract class CommandArgument
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configure(Map<String, Value> config, CarpetScriptHost host)
|
||||
protected void configure(Map<String, Value> config, CarpetScriptHost host) throws CommandSyntaxException
|
||||
{
|
||||
super.configure(config, host);
|
||||
single = config.getOrDefault("single", Value.FALSE).getBoolean();
|
||||
@@ -673,7 +673,7 @@ public abstract class CommandArgument
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configure(Map<String, Value> config, CarpetScriptHost host)
|
||||
protected void configure(Map<String, Value> config, CarpetScriptHost host) throws CommandSyntaxException
|
||||
{
|
||||
super.configure(config, host);
|
||||
single = config.getOrDefault("single", Value.FALSE).getBoolean();
|
||||
@@ -710,7 +710,7 @@ public abstract class CommandArgument
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configure(Map<String, Value> config, CarpetScriptHost host)
|
||||
protected void configure(Map<String, Value> config, CarpetScriptHost host) throws CommandSyntaxException
|
||||
{
|
||||
super.configure(config, host);
|
||||
mapRequired = !config.getOrDefault("allow_element", Value.FALSE).getBoolean();
|
||||
@@ -756,13 +756,13 @@ public abstract class CommandArgument
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configure(Map<String, Value> config, CarpetScriptHost host)
|
||||
protected void configure(Map<String, Value> config, CarpetScriptHost host) throws CommandSyntaxException
|
||||
{
|
||||
super.configure(config, host);
|
||||
if (config.containsKey("options"))
|
||||
{
|
||||
Value optionsValue = config.get("options");
|
||||
if (!(optionsValue instanceof ListValue)) throw new InternalExpressionException("Custom sting type requires options passed as a list"+" for custom type "+suffix);
|
||||
if (!(optionsValue instanceof ListValue)) throw error("Custom sting type requires options passed as a list"+" for custom type "+suffix);
|
||||
validOptions = ((ListValue) optionsValue).getItems().stream().map(v -> new Identifier(v.getString())).collect(Collectors.toSet());
|
||||
}
|
||||
}
|
||||
@@ -798,7 +798,7 @@ public abstract class CommandArgument
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configure(Map<String, Value> config, CarpetScriptHost host)
|
||||
protected void configure(Map<String, Value> config, CarpetScriptHost host) throws CommandSyntaxException
|
||||
{
|
||||
super.configure(config, host);
|
||||
if (config.containsKey("min"))
|
||||
@@ -809,7 +809,7 @@ public abstract class CommandArgument
|
||||
{
|
||||
max = NumericValue.asNumber(config.get("max"), "max").getDouble();
|
||||
}
|
||||
if (max != null && min == null) throw new InternalExpressionException("Double types cannot be only upper-bounded"+" for custom type "+suffix);
|
||||
if (max != null && min == null) throw error("Double types cannot be only upper-bounded"+" for custom type "+suffix);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -849,7 +849,7 @@ public abstract class CommandArgument
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configure(Map<String, Value> config, CarpetScriptHost host)
|
||||
protected void configure(Map<String, Value> config, CarpetScriptHost host) throws CommandSyntaxException
|
||||
{
|
||||
super.configure(config, host);
|
||||
if (config.containsKey("min"))
|
||||
@@ -860,7 +860,7 @@ public abstract class CommandArgument
|
||||
{
|
||||
max = NumericValue.asNumber(config.get("max"), "max").getLong();
|
||||
}
|
||||
if (max != null && min == null) throw new InternalExpressionException("Double types cannot be only upper-bounded"+" for custom type "+suffix);
|
||||
if (max != null && min == null) throw error("Double types cannot be only upper-bounded"+" for custom type "+suffix);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -939,7 +939,7 @@ public abstract class CommandArgument
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configure(Map<String, Value> config, CarpetScriptHost host)
|
||||
protected void configure(Map<String, Value> config, CarpetScriptHost host) throws CommandSyntaxException
|
||||
{
|
||||
super.configure(config, host);
|
||||
if (config.containsKey("restrict"))
|
||||
@@ -947,7 +947,7 @@ public abstract class CommandArgument
|
||||
restrict = config.get("restrict").getString().toLowerCase(Locale.ROOT);
|
||||
needsMatching = true;
|
||||
if (!RESTRICTED_CONTAINERS.containsKey(restrict))
|
||||
throw new InternalExpressionException("Incorrect slot restriction "+restrict+" for custom type "+suffix);
|
||||
throw error("Incorrect slot restriction "+restrict+" for custom type "+suffix);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user