From e5f812d94c2e571ca4e134ed36d950779bbd532e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=9D=8F=E9=BB=91?= Date: Sat, 26 Oct 2019 01:24:03 +0800 Subject: [PATCH] + update --- .../module/inject/TScheduleLoader.java | 31 +++++++++---------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/src/main/scala/io/izzel/taboolib/module/inject/TScheduleLoader.java b/src/main/scala/io/izzel/taboolib/module/inject/TScheduleLoader.java index 9b2f9d7..2688428 100644 --- a/src/main/scala/io/izzel/taboolib/module/inject/TScheduleLoader.java +++ b/src/main/scala/io/izzel/taboolib/module/inject/TScheduleLoader.java @@ -41,35 +41,32 @@ public class TScheduleLoader implements TabooLibLoader.Loader { if (annotation == null) { continue; } - method.setAccessible(true); if (plugin.equals(TabooLib.getPlugin())) { - run(plugin, new BukkitRunnable() { + method.setAccessible(true); + TInjectHelper.getInstance(method, pluginClass, plugin).forEach(instance -> run(plugin, new BukkitRunnable() { @Override public void run() { - for (Object i : TInjectHelper.getInstance(method, pluginClass, plugin)) { - try { - method.invoke(i); - } catch (Throwable t) { - t.printStackTrace(); - } + try { + method.invoke(instance); + } catch (Throwable t) { + t.printStackTrace(); } } - }, annotation.delay(), annotation.period(), annotation.async()); + }, annotation.delay(), annotation.period(), annotation.async())); } else { - schedules.computeIfAbsent(plugin.getName(), n -> Lists.newArrayList()).add(new TScheduleData(annotation, new BukkitRunnable() { + method.setAccessible(true); + TInjectHelper.getInstance(method, pluginClass, plugin).forEach(instance -> schedules.computeIfAbsent(plugin.getName(), n -> Lists.newArrayList()).add(new TScheduleData(annotation, new BukkitRunnable() { @Override public void run() { - for (Object i : TInjectHelper.getInstance(method, pluginClass, plugin)) { - try { - method.invoke(i); - } catch (Throwable t) { - t.printStackTrace(); - } + try { + method.invoke(instance); + } catch (Throwable t) { + t.printStackTrace(); } } - })); + }))); } } }