update migrator

This commit is contained in:
Ryder Belserion 2024-08-22 13:43:54 -04:00
parent f18a162897
commit 65d0f9b6ce
No known key found for this signature in database
2 changed files with 12 additions and 3 deletions

View File

@ -70,7 +70,7 @@ public class CrazyAuctions extends JavaPlugin {
final String uuid = configuration.getString("OutOfTime/Cancelled." + key + ".Seller");
if (uuid != null) {
OfflinePlayer player = Methods.getOfflinePlayer(uuid);
OfflinePlayer player = Methods.getOfflinePlayer(uuid, false);
configuration.set("OutOfTime/Cancelled." + key + ".Seller", player.getUniqueId().toString());
@ -92,7 +92,7 @@ public class CrazyAuctions extends JavaPlugin {
final String uuid = configuration.getString("Items." + key + ".Seller");
if (uuid != null) {
OfflinePlayer player = Methods.getOfflinePlayer(uuid);
OfflinePlayer player = Methods.getOfflinePlayer(uuid, false);
if (!uuid.equals(player.getUniqueId().toString())) {
configuration.set("Items." + key + ".Seller", player.getUniqueId().toString());
@ -104,7 +104,7 @@ public class CrazyAuctions extends JavaPlugin {
final String bidder = configuration.getString("Items." + key + ".TopBidder");
if (bidder != null && !bidder.equals("None")) {
OfflinePlayer player = Methods.getOfflinePlayer(bidder);
OfflinePlayer player = Methods.getOfflinePlayer(bidder, false);
if (!bidder.equals(player.getUniqueId().toString())) {
configuration.set("Items." + key + ".TopBidder", player.getUniqueId().toString());

View File

@ -11,6 +11,7 @@ import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@ -84,6 +85,14 @@ public class Methods {
}
public static OfflinePlayer getOfflinePlayer(String name) {
return getOfflinePlayer(name, true);
}
public static OfflinePlayer getOfflinePlayer(String name, boolean fetchUUID) {
if (!fetchUUID) {
return CompletableFuture.supplyAsync(() -> plugin.getServer().getOfflinePlayer(name)).join();
}
return plugin.getServer().getOfflinePlayer(UUID.fromString(name));
}