Skip to content

Commit

Permalink
Add warnings for using %player% without using the UUID config setting. (
Browse files Browse the repository at this point in the history
#6271)

* Update VariableString.java

* messed up imports

* Catch offline players
  • Loading branch information
sovdeeth authored Jan 1, 2024
1 parent 7d2a5b5 commit 5bc25d6
Showing 1 changed file with 20 additions and 14 deletions.
34 changes: 20 additions & 14 deletions src/main/java/ch/njol/skript/lang/VariableString.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,8 @@
*/
package ch.njol.skript.lang;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.stream.Collectors;

import org.bukkit.ChatColor;
import org.bukkit.event.Event;
import org.eclipse.jdt.annotation.Nullable;
import org.jetbrains.annotations.NotNull;
import org.skriptlang.skript.lang.script.Script;

import com.google.common.collect.Lists;

import ch.njol.skript.Skript;
import ch.njol.skript.SkriptConfig;
import ch.njol.skript.classes.Changer.ChangeMode;
import ch.njol.skript.classes.ClassInfo;
import ch.njol.skript.expressions.ExprColoured;
Expand All @@ -54,6 +41,19 @@
import ch.njol.util.StringUtils;
import ch.njol.util.coll.CollectionUtils;
import ch.njol.util.coll.iterator.SingleItemIterator;
import com.google.common.collect.Lists;
import org.bukkit.ChatColor;
import org.bukkit.OfflinePlayer;
import org.bukkit.event.Event;
import org.eclipse.jdt.annotation.Nullable;
import org.jetbrains.annotations.NotNull;
import org.skriptlang.skript.lang.script.Script;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.stream.Collectors;

/**
* Represents a string that may contain expressions, and is thus "variable".
Expand Down Expand Up @@ -229,6 +229,12 @@ public static VariableString newInstance(String orig, StringMode mode) {
log.printErrors("Can't understand this expression: " + s.substring(c + 1, c2));
return null;
} else {
if (!SkriptConfig.usePlayerUUIDsInVariableNames.value() && OfflinePlayer.class.isAssignableFrom(expr.getReturnType())) {
Skript.warning(
"In the future, players in variable names will use the player's UUID instead of their name. " +
"For information on how to make sure your scripts won't be impacted by this change, see https://github.com/SkriptLang/Skript/discussions/6270."
);
}
string.add(expr);
}
log.printLog();
Expand Down

0 comments on commit 5bc25d6

Please sign in to comment.