From 8564b0bafe781ddb512adc2ac8a49a945c188312 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=9D=8F=E9=BB=91?= Date: Sat, 23 Jun 2018 23:31:43 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=A0=E4=BA=86=E4=B8=80=E4=B8=AA=E5=A4=A7?= =?UTF-8?q?=E5=B1=81=E7=9C=BC=E5=AD=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/me/skymc/taboolib/translateuuid/TranslateUUID.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/me/skymc/taboolib/translateuuid/TranslateUUID.java b/src/main/java/me/skymc/taboolib/translateuuid/TranslateUUID.java index c32d170..4e008fc 100644 --- a/src/main/java/me/skymc/taboolib/translateuuid/TranslateUUID.java +++ b/src/main/java/me/skymc/taboolib/translateuuid/TranslateUUID.java @@ -118,16 +118,22 @@ public class TranslateUUID { ScheduledExecutorService threadPool = Executors.newScheduledThreadPool(32); AtomicInteger i = new AtomicInteger(); + AtomicInteger fail = new AtomicInteger(); int size = playerDataFolder.listFiles().length; TLogger.getGlobalLogger().info("Start importing the local data..."); for (File file : playerDataFolder.listFiles()) { + if (fail.get() > 10) { + TLogger.getGlobalLogger().info("The number of failures exceeds the threshold! import stopped.."); + break; + } threadPool.submit(() -> { try { String username = getUsernameInDatFile(file); updateUsername(UUID.fromString(file.getName().split("\\.")[0]), username); TLogger.getGlobalLogger().info("importing... " + username + "(" + i.getAndIncrement() + "/" + size + ")"); } catch (Exception ignored) { + fail.getAndIncrement(); } }); }