geforkt von Mirrors/HeadDB
bugfix
Dieser Commit ist enthalten in:
Ursprung
7b08613c7a
Commit
832672b74f
2
pom.xml
2
pom.xml
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<groupId>tsp.headdb</groupId>
|
<groupId>tsp.headdb</groupId>
|
||||||
<artifactId>HeadDB</artifactId>
|
<artifactId>HeadDB</artifactId>
|
||||||
<version>2.4.3</version>
|
<version>2.4.4</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>HeadDB</name>
|
<name>HeadDB</name>
|
||||||
|
@ -8,6 +8,7 @@ import org.json.simple.parser.JSONParser;
|
|||||||
import org.json.simple.parser.ParseException;
|
import org.json.simple.parser.ParseException;
|
||||||
import tsp.headdb.api.Head;
|
import tsp.headdb.api.Head;
|
||||||
import tsp.headdb.util.Log;
|
import tsp.headdb.util.Log;
|
||||||
|
import tsp.headdb.util.Utils;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -166,8 +167,13 @@ public class HeadDatabase {
|
|||||||
JSONArray array = (JSONArray) parser.parse(response.toString());
|
JSONArray array = (JSONArray) parser.parse(response.toString());
|
||||||
for (Object o : array) {
|
for (Object o : array) {
|
||||||
JSONObject obj = (JSONObject) o;
|
JSONObject obj = (JSONObject) o;
|
||||||
UUID uuid = UUID.fromString(obj.get("uuid").toString());
|
String rawUUID = obj.get("uuid").toString();
|
||||||
if (uuid.toString().length() != 36) {
|
|
||||||
|
UUID uuid;
|
||||||
|
if (Utils.validateUniqueId(rawUUID)) {
|
||||||
|
uuid = UUID.fromString(rawUUID);
|
||||||
|
} else {
|
||||||
|
Log.debug("UUID " + rawUUID + " is invalid. Using random one for head id: " + id);
|
||||||
uuid = UUID.randomUUID();
|
uuid = UUID.randomUUID();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,8 +3,23 @@ package tsp.headdb.util;
|
|||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
public class Utils {
|
public class Utils {
|
||||||
|
|
||||||
|
|
||||||
|
public static final Pattern UUID_PATTERN = Pattern.compile("[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validate a UUID (version 4)
|
||||||
|
*
|
||||||
|
* @param uuid UUID to be validated
|
||||||
|
* @return Returns true if the string is a valid UUID
|
||||||
|
*/
|
||||||
|
public static boolean validateUniqueId(String uuid) {
|
||||||
|
return UUID_PATTERN.matcher(uuid).matches();
|
||||||
|
}
|
||||||
|
|
||||||
public static void sendMessage(CommandSender sender, String message) {
|
public static void sendMessage(CommandSender sender, String message) {
|
||||||
sender.sendMessage(colorize(message));
|
sender.sendMessage(colorize(message));
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren