2021-03-21 20:17:31 +01:00
|
|
|
package fr.pandacube.lib.core.util;
|
2016-07-04 16:57:23 +02:00
|
|
|
|
|
|
|
import java.nio.charset.Charset;
|
2021-04-17 00:04:06 +02:00
|
|
|
import java.util.Objects;
|
|
|
|
import java.util.Scanner;
|
2016-07-14 14:22:23 +02:00
|
|
|
import java.util.UUID;
|
2016-07-04 16:57:23 +02:00
|
|
|
|
|
|
|
public class OfflineUUID {
|
|
|
|
|
2016-07-14 14:22:23 +02:00
|
|
|
public static UUID getFromNickName(String nickname) {
|
2021-04-17 00:04:06 +02:00
|
|
|
byte[] from_str = ("OfflinePlayer:" + nickname).getBytes(Charset.forName("UTF-8"));
|
2016-07-14 14:22:23 +02:00
|
|
|
return UUID.nameUUIDFromBytes(from_str);
|
|
|
|
}
|
|
|
|
|
2019-10-26 23:15:49 +02:00
|
|
|
public static UUID[] getFromNickNames(String[] nicknames) {
|
2021-04-17 00:04:06 +02:00
|
|
|
Objects.requireNonNull(nicknames);
|
2016-07-14 14:22:23 +02:00
|
|
|
|
2016-07-04 16:57:23 +02:00
|
|
|
UUID[] uuids = new UUID[nicknames.length];
|
2016-07-14 14:22:23 +02:00
|
|
|
for (int i = 0; i < nicknames.length; i++)
|
2016-07-04 16:57:23 +02:00
|
|
|
uuids[i] = getFromNickName(nicknames[i]);
|
|
|
|
return uuids;
|
|
|
|
}
|
2021-04-17 00:04:06 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static void main(String[] args) {
|
|
|
|
if (args.length == 0) {
|
|
|
|
try (Scanner s = new Scanner(System.in)) {
|
|
|
|
for(;;) {
|
|
|
|
System.out.print("Please input a player name: ");
|
|
|
|
if (!s.hasNext())
|
|
|
|
break;
|
|
|
|
String line = s.nextLine();
|
|
|
|
System.out.println(getFromNickName(line));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
for (String arg : args)
|
|
|
|
System.out.println("" + arg + ":" + getFromNickName(arg));
|
|
|
|
}
|
|
|
|
}
|
2016-07-14 14:22:23 +02:00
|
|
|
}
|