From 1c358f7b2e807c3813998d8187148f48fedc600d Mon Sep 17 00:00:00 2001 From: TPGamesNL <29547183+TPGamesNL@users.noreply.github.com> Date: Mon, 25 Jan 2021 17:28:31 +0100 Subject: [PATCH 1/4] Update VariableString.java --- .../ch/njol/skript/lang/VariableString.java | 28 +------------------ 1 file changed, 1 insertion(+), 27 deletions(-) diff --git a/src/main/java/ch/njol/skript/lang/VariableString.java b/src/main/java/ch/njol/skript/lang/VariableString.java index ee0e4849190..c3d352f3bf1 100644 --- a/src/main/java/ch/njol/skript/lang/VariableString.java +++ b/src/main/java/ch/njol/skript/lang/VariableString.java @@ -261,33 +261,7 @@ public static VariableString newInstance(final String orig, final StringMode mod log.printErrors("Can't understand this expression: " + s.substring(c + 1, c2)); return null; } else { - if (mode != StringMode.MESSAGE) { - string.add(expr); - } else { - final ExpressionInfo i = new ExpressionInfo(expr); - if (c2 <= s.length() - 2 && s.charAt(c2 + 1) == 's' && (c2 == s.length() - 2 || !Character.isLetter(s.charAt(c2 + 2)))) { - i.flags |= Language.F_PLURAL; - c2++; // remove the 's' - } - if (string.size() > 0 && string.get(string.size() - 1) instanceof String) { - final String last = (String) string.get(string.size() - 1); - if (c2 <= s.length() - 2 && s.charAt(c2 + 1) == '>' && last.endsWith("<")) { - i.toChatStyle = true; - string.set(string.size() - 1, last.substring(0, last.length() - 1)); - c2++; // remove the '>' - } else { - final int l = last.lastIndexOf(' ', last.endsWith(" ") ? last.length() - 2 : last.length() - 1); - final String lastWord = "" + last.substring(l + 1).trim(); - if (Noun.isLocalIndefiniteArticle(lastWord)) - i.flags |= Language.F_INDEFINITE_ARTICLE; - else if (Noun.isLocalDefiniteArticle(lastWord)) - i.flags |= Language.F_DEFINITE_ARTICLE; - if ((i.flags & (Language.F_INDEFINITE_ARTICLE | Language.F_DEFINITE_ARTICLE)) != 0) - string.set(string.size() - 1, last.substring(0, l + 1)); - } - } - string.add(i); - } + string.add(expr); } log.printLog(); } finally { From cc7d6c9054dbef194e858cdf44e7123428c29994 Mon Sep 17 00:00:00 2001 From: TPGamesNL <29547183+TPGamesNL@users.noreply.github.com> Date: Mon, 25 Jan 2021 17:37:55 +0100 Subject: [PATCH 2/4] Update SectionNode.java --- src/main/java/ch/njol/skript/config/SectionNode.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/ch/njol/skript/config/SectionNode.java b/src/main/java/ch/njol/skript/config/SectionNode.java index 54f26008721..6eb865789cb 100644 --- a/src/main/java/ch/njol/skript/config/SectionNode.java +++ b/src/main/java/ch/njol/skript/config/SectionNode.java @@ -438,7 +438,7 @@ HashMap toMap(final String prefix, final String separator) { /** * @param other * @param excluded keys and sections to exclude - * @return false iff this and the other SectionNode contain the exact same set of keys + * @return false if this and the other SectionNode contain the exact same set of keys */ public boolean setValues(final SectionNode other, final String... excluded) { boolean r = false; From ce6c70250bea09ff80379becc5c69b33fc2395d0 Mon Sep 17 00:00:00 2001 From: TPGamesNL <29547183+TPGamesNL@users.noreply.github.com> Date: Mon, 25 Jan 2021 17:38:11 +0100 Subject: [PATCH 3/4] Update TriggerItem.java --- src/main/java/ch/njol/skript/lang/TriggerItem.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/ch/njol/skript/lang/TriggerItem.java b/src/main/java/ch/njol/skript/lang/TriggerItem.java index c4baff30ec4..997d89aca4e 100644 --- a/src/main/java/ch/njol/skript/lang/TriggerItem.java +++ b/src/main/java/ch/njol/skript/lang/TriggerItem.java @@ -78,7 +78,7 @@ protected TriggerItem walk(final Event e) { /** * @param start * @param e - * @return false iff an exception occurred + * @return false if an exception occurred */ public static boolean walk(final TriggerItem start, final Event e) { assert start != null && e != null; From c23b8878e2623e34df929dea28c7f5d37612df56 Mon Sep 17 00:00:00 2001 From: TPGamesNL <29547183+TPGamesNL@users.noreply.github.com> Date: Sat, 20 Feb 2021 16:04:07 +0100 Subject: [PATCH 4/4] Remove some leftover code --- .../ch/njol/skript/lang/VariableString.java | 70 ++----------------- 1 file changed, 4 insertions(+), 66 deletions(-) diff --git a/src/main/java/ch/njol/skript/lang/VariableString.java b/src/main/java/ch/njol/skript/lang/VariableString.java index c3d352f3bf1..d5f7ad7628f 100644 --- a/src/main/java/ch/njol/skript/lang/VariableString.java +++ b/src/main/java/ch/njol/skript/lang/VariableString.java @@ -41,8 +41,6 @@ import ch.njol.skript.expressions.ExprColoured; import ch.njol.skript.lang.SkriptParser.ParseResult; import ch.njol.skript.lang.util.SimpleExpression; -import ch.njol.skript.localization.Language; -import ch.njol.skript.localization.Noun; import ch.njol.skript.log.BlockingLogHandler; import ch.njol.skript.log.RetainingLogHandler; import ch.njol.skript.log.SkriptLogger; @@ -65,16 +63,6 @@ */ public class VariableString implements Expression { - private final static class ExpressionInfo { - ExpressionInfo(final Expression expr) { - this.expr = expr; - } - - final Expression expr; - int flags = 0; - boolean toChatStyle = false; - } - private final String orig; @Nullable @@ -294,10 +282,10 @@ public static VariableString newInstance(final String orig, final StringMode mod final Object[] sa = string.toArray(); assert sa != null; - if (string.size() == 1 && string.get(0) instanceof ExpressionInfo && - ((ExpressionInfo) string.get(0)).expr.getReturnType() == String.class && - ((ExpressionInfo) string.get(0)).expr.isSingle()) { - String expr = ((ExpressionInfo) string.get(0)).expr.toString(null, false); + if (string.size() == 1 && string.get(0) instanceof Expression && + ((Expression) string.get(0)).getReturnType() == String.class && + ((Expression) string.get(0)).isSingle()) { + String expr = ((Expression) string.get(0)).toString(null, false); Skript.warning(expr + " is already a text, so you should not put it in one (e.g. " + expr + " instead of " + "\"%" + expr.replace("\"", "\"\"") + "%\")"); } return new VariableString(orig, sa, mode); @@ -436,19 +424,6 @@ public String toString(@Nullable final Event e) { if (o instanceof Expression) { assert mode != StringMode.MESSAGE; b.append(Classes.toString(((Expression) o).getArray(e), true, mode)); - } else if (o instanceof ExpressionInfo) { - assert mode == StringMode.MESSAGE; - final ExpressionInfo info = (ExpressionInfo) o; - int flags = info.flags; - if ((flags & Language.F_PLURAL) == 0 && b.length() > 0 && Math.abs(StringUtils.numberBefore(b, b.length() - 1)) != 1) - flags |= Language.F_PLURAL; - if (info.toChatStyle) { - final String s = Classes.toString(info.expr.getArray(e), flags, getLastColor(b)); - final String style = Utils.getChatStyle(s); - b.append(style == null ? "<" + s + ">" : style); - } else { - b.append(Classes.toString(info.expr.getArray(e), flags, getLastColor(b))); - } } else { b.append(o); } @@ -475,19 +450,6 @@ public String toUnformattedString(final Event e) { if (o instanceof Expression) { assert mode != StringMode.MESSAGE; b.append(Classes.toString(((Expression) o).getArray(e), true, mode)); - } else if (o instanceof ExpressionInfo) { - assert mode == StringMode.MESSAGE; - final ExpressionInfo info = (ExpressionInfo) o; - int flags = info.flags; - if ((flags & Language.F_PLURAL) == 0 && b.length() > 0 && Math.abs(StringUtils.numberBefore(b, b.length() - 1)) != 1) - flags |= Language.F_PLURAL; - if (info.toChatStyle) { - final String s = Classes.toString(info.expr.getArray(e), flags, null); - final String style = Utils.getChatStyle(s); - b.append(style == null ? "<" + s + ">" : style); - } else { - b.append(Classes.toString(info.expr.getArray(e), flags, null)); - } } else { b.append(o); } @@ -534,28 +496,6 @@ public List getMessageComponents(Event e) { } else if (o instanceof Expression) { assert mode != StringMode.MESSAGE; text = Classes.toString(((Expression) o).getArray(e), true, mode); - } else if (o instanceof ExpressionInfo) { - assert mode == StringMode.MESSAGE; - final ExpressionInfo info = (ExpressionInfo) o; - int flags = info.flags; - - // TODO plural handling? -// if ((flags & Language.F_PLURAL) == 0 && b.length() > 0 && Math.abs(StringUtils.numberBefore(b, b.length() - 1)) != 1) -// flags |= Language.F_PLURAL; - if (info.toChatStyle) { - final String s = Classes.toString(info.expr.getArray(e), flags, null); - final String style = Utils.getChatStyle(s); - text = style == null ? "<" + s + ">" : style; - } else { - if (info.expr instanceof ExprColoured && ((ExprColoured) info.expr).isUnsafeFormat()) { // Special case: user wants to process formatting - String unformatted = ((ExprColoured) info.expr).getSingle(e); - if (unformatted != null) { - message.addAll(ChatMessages.parse(unformatted)); - } - continue; - } - text = Classes.toString(info.expr.getArray(e), flags, null); - } } else { assert false; } @@ -639,8 +579,6 @@ public String toString(final @Nullable Event e, final boolean debug) { for (final Object o : string) { if (o instanceof Expression) { b.append("%").append(((Expression) o).toString(e, debug)).append("%"); - } else if (o instanceof ExpressionInfo) { - b.append("%").append(((ExpressionInfo) o).expr.toString(e, debug)).append("%"); } else { b.append(o); }