diff --git a/src/main/java/com/Acrobot/ChestShop/Configuration/Properties.java b/src/main/java/com/Acrobot/ChestShop/Configuration/Properties.java index 61e7210..03424ce 100644 --- a/src/main/java/com/Acrobot/ChestShop/Configuration/Properties.java +++ b/src/main/java/com/Acrobot/ChestShop/Configuration/Properties.java @@ -191,6 +191,9 @@ public class Properties { @ConfigurationComment("How many decimal places are allowed at a maximum for prices?") public static int PRICE_PRECISION = 2; + @ConfigurationComment("This makes sure that the UUIDs of player shop accounts match the server's online-mode setting. Disabling this might lead to issues with offline players and is therefore unsupported!") + public static boolean ENSURE_CORRECT_PLAYERID = true; + @PrecededBySpace @ConfigurationComment("Should we block shops that sell things for more than they buy? (This prevents newbies from creating shops that would be exploited)") public static boolean BLOCK_SHOPS_WITH_SELL_PRICE_HIGHER_THAN_BUY_PRICE = true; diff --git a/src/main/java/com/Acrobot/ChestShop/UUIDs/NameManager.java b/src/main/java/com/Acrobot/ChestShop/UUIDs/NameManager.java index e03c38a..fcc321c 100644 --- a/src/main/java/com/Acrobot/ChestShop/UUIDs/NameManager.java +++ b/src/main/java/com/Acrobot/ChestShop/UUIDs/NameManager.java @@ -79,7 +79,9 @@ public class NameManager implements Listener { public static Account getOrCreateAccount(UUID id, String name) { Validate.notNull(id, "UUID of player is null?"); Validate.notNull(name, "Name of player " + id + " is null?"); - Validate.isTrue(uuidVersion < 0 || id.version() == uuidVersion, "Invalid OfflinePlayer! " + id + " is not of server version " + uuidVersion); + Validate.isTrue(!Properties.ENSURE_CORRECT_PLAYERID || uuidVersion < 0 || id.version() == uuidVersion, + "Invalid OfflinePlayer! " + id + " has version " + id.version() + " and not server version " + uuidVersion + ". " + + "If you believe that is an error and your setup allows such UUIDs then set the ENSURE_CORRECT_PLAYERID config option to false."); Account account = getAccount(id); if (account == null) { @@ -191,7 +193,7 @@ public class NameManager implements Listener { // no account with that shortname was found, try to get an offline player with that name OfflinePlayer offlinePlayer = ChestShop.getBukkitServer().getOfflinePlayer(shortName); if (offlinePlayer != null && offlinePlayer.getName() != null && offlinePlayer.getUniqueId() != null - && offlinePlayer.getUniqueId().version() == uuidVersion) { + && (!Properties.ENSURE_CORRECT_PLAYERID || offlinePlayer.getUniqueId().version() == uuidVersion)) { account = storeUsername(new PlayerDTO(offlinePlayer.getUniqueId(), offlinePlayer.getName())); } else { invalidPlayers.put(shortName.toLowerCase(Locale.ROOT), true); @@ -415,8 +417,12 @@ public class NameManager implements Listener { } public static void load() { - if (getUuidVersion() < 0 && !Bukkit.getOnlinePlayers().isEmpty()) { - setUuidVersion(Bukkit.getOnlinePlayers().iterator().next().getUniqueId().version()); + if (getUuidVersion() < 0) { + if (Bukkit.getOnlineMode()) { + setUuidVersion(4); + } else if (!Bukkit.getOnlinePlayers().isEmpty()) { + setUuidVersion(Bukkit.getOnlinePlayers().iterator().next().getUniqueId().version()); + } } try { accounts = DaoCreator.getDaoAndCreateTable(Account.class);