From d2ef1c350a192cd596ac7e8969edba3b17d546c8 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Tue, 16 Dec 2014 15:15:59 +1100 Subject: [PATCH] Safer UUID provider --- .../plot/util/UUIDHandler.java | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/UUIDHandler.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/UUIDHandler.java index 1130fa27a..9b328ab08 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/UUIDHandler.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/UUIDHandler.java @@ -315,15 +315,24 @@ public class UUIDHandler { return uuidWrapper.getUUID(player); } + /** + * Safely provide the correct UUID provider. Ignores user preference if not possible rather than break the plugin. + */ public static UUID getUUID(OfflinePlayer player) { if (uuidWrapper == null) { - try { - getUUID(player); - uuidWrapper = new DefaultUUIDWrapper(); - } - catch (Throwable e) { + + if (Settings.OFFLINE_MODE) { uuidWrapper = new OfflineUUIDWrapper(); } + else { + try { + getUUID(player); + uuidWrapper = new DefaultUUIDWrapper(); + } + catch (Throwable e) { + uuidWrapper = new OfflineUUIDWrapper(); + } + } } try { return uuidWrapper.getUUID(player);