allow for more characters in file names.

This commit is contained in:
gnembon committed 2020-06-18 13:52:31 -03:00
1 parent 9b59b000a4
commit 639283fce3
2 files changed
+4 -3

No files matched your search

+1 -1
View File
@@ -200,7 +200,7 @@ With the specified `resource` in the scripts folder, of a specific `type`, write
content, or deletes the resource.
Resource is identified by a path to the file.
A path can contain letters, numbers and folder separator: `'/'`. Any other characters are stripped
A path can contain letters, numbers, characters `-`, `+`, or `_`, and a folder separator: `'/'`. Any other characters are stripped
from the name. Empty descriptors are invalid. Do not add file extensions to the descriptor - extensions are inferred
based on the `type` of the file.
@@ -1396,13 +1396,14 @@ public class CarpetExpression
});
this.expr.addLazyFunction("scoreboard_remove", -1, (c, t, lv)-> {
if (lv.size()==0) throw new InternalExpressionException("'scoreboard_remove' requires at least one parameter");
CarpetContext cc = (CarpetContext)c;
Scoreboard scoreboard = cc.s.getMinecraftServer().getScoreboard();
String objectiveName = lv.get(0).evalValue(c).getString();
ScoreboardObjective objective = scoreboard.getObjective(objectiveName);
if (objective == null)
return LazyValue.FALSE;
if (lv.size() == 0)
if (lv.size() == 1)
{
scoreboard.removeObjective(objective);
return LazyValue.TRUE;
@@ -2621,7 +2622,7 @@ public class CarpetExpression
public static String recognizeResource(Value value)
{
String origfile = value.getString();
String file = origfile.toLowerCase(Locale.ROOT).replaceAll("[^A-Za-z0-9/]", "");
String file = origfile.toLowerCase(Locale.ROOT).replaceAll("[^A-Za-z0-9\\-+_/]", "");
file = Arrays.stream(file.split("/+")).filter(s -> !s.isEmpty()).collect(Collectors.joining("/"));
if (file.isEmpty())
{