diff --git a/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/ELDGDispatcher.java b/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/ELDGDispatcher.java index 70ec1c1..0f1e231 100644 --- a/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/ELDGDispatcher.java +++ b/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/ELDGDispatcher.java @@ -2,7 +2,7 @@ import com.ericlam.mc.eld.services.ConfigPoolService; import com.ericlam.mc.eld.services.ItemStackService; -import com.ericlam.mc.eldgui.manager.ReflectionCacheManager; +import com.ericlam.mc.eld.services.ReflectionService; import com.google.inject.Inject; import com.google.inject.Injector; import org.bukkit.entity.Player; @@ -36,7 +36,7 @@ public class ELDGDispatcher implements UIDispatcher, Listener { @Inject private ItemStackService itemStackService; @Inject - private ReflectionCacheManager reflectionCacheManager; + private ReflectionService reflectionService; public ELDGDispatcher( Object controller, @@ -52,7 +52,8 @@ public ELDGDispatcher( @Override public void openFor(Player player) { - this.openFor(player, s -> {}); + this.openFor(player, s -> { + }); } @Override @@ -74,7 +75,7 @@ public void openFor(Player player, Consumer initSession) { eldgmvcInstallation, configPoolService, itemStackService, - reflectionCacheManager + reflectionService ); this.guiSessionMap.put(player, eldgui); } @@ -91,22 +92,22 @@ public synchronized void onClose() { @EventHandler - public void onInventoryClick(InventoryClickEvent e){ + public void onInventoryClick(InventoryClickEvent e) { Optional.ofNullable(guiSessionMap.get((Player) e.getWhoClicked())).ifPresent(gui -> gui.onInventoryClick(e)); } @EventHandler - public void onInventoryDrag(InventoryDragEvent e){ + public void onInventoryDrag(InventoryDragEvent e) { Optional.ofNullable(guiSessionMap.get((Player) e.getWhoClicked())).ifPresent(gui -> gui.onInventoryDrag(e)); } @EventHandler - public void onInventoryClose(InventoryCloseEvent e){ + public void onInventoryClose(InventoryCloseEvent e) { Optional.ofNullable(guiSessionMap.get((Player) e.getPlayer())).ifPresent(gui -> gui.onInventoryClose(e)); } @EventHandler - public void onInventoryOpen(InventoryOpenEvent e){ + public void onInventoryOpen(InventoryOpenEvent e) { Optional.ofNullable(guiSessionMap.get((Player) e.getPlayer())).ifPresent(gui -> gui.onInventoryOpen(e)); } @@ -127,7 +128,7 @@ public void setAttribute(String key, Object value) { @Override public T pollAttribute(String key) { - return (T)this.attributes.remove(key); + return (T) this.attributes.remove(key); } } } diff --git a/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/ELDGInventoryService.java b/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/ELDGInventoryService.java index 789e5ab..97539da 100644 --- a/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/ELDGInventoryService.java +++ b/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/ELDGInventoryService.java @@ -18,7 +18,7 @@ public class ELDGInventoryService implements InventoryService { private final Map> uiControllerMap; @Inject - public ELDGInventoryService(ELDGMVCInstallation installation){ + public ELDGInventoryService(ELDGMVCInstallation installation) { this.uiControllerMap = installation.getControllerMap(); } diff --git a/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/ELDGPlugin.java b/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/ELDGPlugin.java index c85b659..6f1a051 100644 --- a/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/ELDGPlugin.java +++ b/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/ELDGPlugin.java @@ -14,7 +14,6 @@ import com.ericlam.mc.eldgui.demo.middlewares.RequireLogin; import com.ericlam.mc.eldgui.demo.test.TestController; import com.ericlam.mc.eldgui.demo.user.UserController; -import com.ericlam.mc.eldgui.manager.ReflectionCacheManager; @ELDBukkit( lifeCycle = ELDGLifeCycle.class, @@ -28,7 +27,6 @@ public final class ELDGPlugin extends ELDBukkitPlugin { @Override public void bindServices(ServiceCollection serviceCollection) { serviceCollection.bindService(InventoryService.class, ELDGInventoryService.class); - serviceCollection.addSingleton(ReflectionCacheManager.class); serviceCollection.addGroupConfiguration(DemoInventories.class); serviceCollection.addConfiguration(ELDGLanguage.class); serviceCollection.addConfiguration(ELDGConfig.class); diff --git a/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/ELDGUI.java b/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/ELDGUI.java index b761dde..b67009f 100644 --- a/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/ELDGUI.java +++ b/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/ELDGUI.java @@ -2,6 +2,7 @@ import com.ericlam.mc.eld.services.ConfigPoolService; import com.ericlam.mc.eld.services.ItemStackService; +import com.ericlam.mc.eld.services.ReflectionService; import com.ericlam.mc.eld.services.ScheduleService; import com.ericlam.mc.eldgui.component.AttributeController; import com.ericlam.mc.eldgui.controller.*; @@ -16,7 +17,6 @@ import com.ericlam.mc.eldgui.lifecycle.PreDestroyView; import com.ericlam.mc.eldgui.manager.LifeCycleManager; import com.ericlam.mc.eldgui.manager.MethodParseManager; -import com.ericlam.mc.eldgui.manager.ReflectionCacheManager; import com.ericlam.mc.eldgui.manager.ReturnTypeManager; import com.ericlam.mc.eldgui.middleware.MiddleWareManager; import com.ericlam.mc.eldgui.view.BukkitRedirectView; @@ -63,7 +63,7 @@ public final class ELDGUI { private final BukkitView loadingView; private final Method[] controllerMethods; - private final ReflectionCacheManager reflectionCacheManager; + private final ReflectionService reflectionService; private final MiddleWareManager middleWareManager; @@ -79,7 +79,7 @@ public ELDGUI( ELDGMVCInstallation eldgmvcInstallation, ConfigPoolService configPoolService, ItemStackService itemStackService, - ReflectionCacheManager reflectionCacheManager + ReflectionService reflectionService ) { this.session = session; @@ -90,20 +90,20 @@ public ELDGUI( this.eldgmvcInstallation = eldgmvcInstallation; this.configPoolService = configPoolService; this.itemStackService = itemStackService; - this.reflectionCacheManager = reflectionCacheManager; + this.reflectionService = reflectionService; - methodParseManager = new MethodParseManager(reflectionCacheManager); + methodParseManager = new MethodParseManager(reflectionService); this.initMethodParseManager(this.methodParseManager); - returnTypeManager = new ReturnTypeManager(reflectionCacheManager); + returnTypeManager = new ReturnTypeManager(reflectionService); this.initReturnTypeManager(this.returnTypeManager); this.lifeCycleManager = new LifeCycleManager(controller, methodParseManager); this.controllerCls = controller.getClass(); - this.controllerMethods = reflectionCacheManager.getMethods(controllerCls); + this.controllerMethods = reflectionService.getMethods(controllerCls); - this.middleWareManager = new MiddleWareManager(reflectionCacheManager, eldgmvcInstallation, injector, this.controllerCls, owner, session); + this.middleWareManager = new MiddleWareManager(reflectionService, eldgmvcInstallation, injector, this.controllerCls, owner, session); var customQualifier = eldgmvcInstallation.getQualifierMap(); this.eventHandlerMap.put(InventoryClickEvent.class, new ELDGClickEventHandler(controller, methodParseManager, returnTypeManager, middleWareManager, customQualifier, controllerMethods)); @@ -450,7 +450,7 @@ private void handleException(Exception ex) { Class exceptionViewHandler = exceptionViewHandlerOpt.orElseGet(eldgmvcInstallation::getDefaultExceptionHandler); ExceptionViewHandler viewHandlerIns = injector.getInstance(exceptionViewHandler); UIController fromController = controllerCls.getAnnotation(UIController.class); - Method[] declaredMethods = reflectionCacheManager.getMethods(exceptionViewHandler); + Method[] declaredMethods = reflectionService.getMethods(exceptionViewHandler); Arrays.stream(declaredMethods) .filter(m -> m.isAnnotationPresent(HandleException.class)) .filter(m -> Arrays.stream(m.getAnnotation(HandleException.class).value()).anyMatch(v -> { diff --git a/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/ELDGView.java b/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/ELDGView.java index 11bac4c..8ee32f6 100644 --- a/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/ELDGView.java +++ b/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/ELDGView.java @@ -293,7 +293,7 @@ public PatternComponentBuilder fill(Component component) { public PatternComponentBuilder components(Component... components) { for (Component component : components) { componentMap.putIfAbsent(pattern, new ArrayList<>()); - if (!inventoryContext.addItem(pattern, component)){ + if (!inventoryContext.addItem(pattern, component)) { LOGGER.warn("無法在界面 {} 的 Pattern {} 中新增組件 {}, 位置已滿。", view.getClass().getSimpleName(), pattern, component.getClass().getSimpleName() ); @@ -312,7 +312,7 @@ public PatternComponentBuilder components(Component... components) { @Override public PatternComponentBuilder component(int pos, Component component) { componentMap.putIfAbsent(pattern, new ArrayList<>()); - if (!inventoryContext.setItem(pattern, pos, component)){ + if (!inventoryContext.setItem(pattern, pos, component)) { LOGGER.warn("無法在界面 {} 的 Pattern {} 中設置組件 {} 到位置 {}, 此位置無效。", view.getClass().getSimpleName(), pattern, component.getClass().getSimpleName(), pos ); @@ -366,7 +366,7 @@ public Map getAsMap(ItemStack item) { public synchronized C getAttribute(ItemStack item, String key) { // instead of using persist data type, use map // return getObjectAttribute(item, key); - if (!item.hasItemMeta()){ + if (!item.hasItemMeta()) { LOGGER.warn("{} has no item meta, return null.", item.getType()); return null; } @@ -473,14 +473,14 @@ public List getItems(char pattern) { return List.copyOf(items); } - public Map getItemMap(char pattern){ + public Map getItemMap(char pattern) { var slots = patternMasks.get(pattern); if (slots == null) return Map.of(); Map items = new HashMap<>(); int order = 0; for (int s : slots) { var item = nativeInventory.getItem(s); - if (item != null){ + if (item != null) { items.put(order, item); } order++; diff --git a/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/component/AnimatedButton.java b/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/component/AnimatedButton.java index 46ca440..8bff69a 100644 --- a/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/component/AnimatedButton.java +++ b/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/component/AnimatedButton.java @@ -35,20 +35,20 @@ public AnimatedButton( this.displays = displays; this.numbers = numbers; this.seconds = seconds; - if (icons.length > 0){ + if (icons.length > 0) { itemFactory.material(icons[0]); } - if (displays.length > 0){ + if (displays.length > 0) { itemFactory.display(displays[0]); } - if (numbers.length > 0){ + if (numbers.length > 0) { itemFactory.amount(numbers[0]); } } @Override public void startAnimation() { - if (seconds > 0 && this.task == null){ + if (seconds > 0 && this.task == null) { this.task = new AnimatedRunnable().runTaskTimer(ELDGPlugin.getPlugin(ELDGPlugin.class), 0L, 20L); } } @@ -77,24 +77,24 @@ private class AnimatedRunnable extends BukkitRunnable { @Override public void run() { - if (timer % seconds == 0){ - if (displayIterator.hasNext()){ + if (timer % seconds == 0) { + if (displayIterator.hasNext()) { itemFactory.display(displayIterator.next()); } - if (loreIterator.hasNext()){ + if (loreIterator.hasNext()) { itemFactory.lore(Arrays.asList(loreIterator.next())); } - if (iconIterator.hasNext()){ + if (iconIterator.hasNext()) { itemFactory.material(iconIterator.next()); } - if (numberIterator.hasNext()){ + if (numberIterator.hasNext()) { itemFactory.amount(numberIterator.next()); } updateInventory(); } timer++; - if (timer == Long.MAX_VALUE){ + if (timer == Long.MAX_VALUE) { timer = 0; } } diff --git a/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/component/Button.java b/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/component/Button.java index c729afe..7d67e53 100644 --- a/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/component/Button.java +++ b/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/component/Button.java @@ -2,7 +2,7 @@ import com.ericlam.mc.eld.services.ItemStackService; -public final class Button extends AbstractComponent{ +public final class Button extends AbstractComponent { public Button(AttributeController attributeController, ItemStackService.ItemFactory itemFactory) { super(attributeController, itemFactory); diff --git a/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/component/Checkbox.java b/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/component/Checkbox.java index 0402d9a..37a1b75 100644 --- a/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/component/Checkbox.java +++ b/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/component/Checkbox.java @@ -32,7 +32,7 @@ public Checkbox( this.uncheckedShow = uncheckedShow; this.currentValue = (boolean) Optional.ofNullable(attributeController.getAttribute(getItem(), AttributeController.VALUE_TAG)).orElse(false); this.disabled = disabled; - itemFactory.lore("-> "+ (currentValue ? checkedShow : uncheckedShow)); + itemFactory.lore("-> " + (currentValue ? checkedShow : uncheckedShow)); itemFactory.lore("&cDisabled"); } @@ -40,7 +40,7 @@ public Checkbox( public void onClick(InventoryClickEvent event) { this.currentValue = !this.currentValue; attributeController.setAttribute(getItem(), AttributeController.VALUE_TAG, this.currentValue); - itemFactory.lore(List.of("-> "+(this.currentValue ? checkedShow : uncheckedShow))); + itemFactory.lore(List.of("-> " + (this.currentValue ? checkedShow : uncheckedShow))); itemFactory.material(this.currentValue ? checkedIcon : uncheckedIcon); this.updateInventory(); } diff --git a/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/component/DateSelector.java b/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/component/DateSelector.java index 81611eb..3362e84 100644 --- a/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/component/DateSelector.java +++ b/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/component/DateSelector.java @@ -79,9 +79,9 @@ private void updateItem() { int day = this.currentValue.getDayOfMonth(); itemFactory.lore(List.of("&7-> &f" + - (currentSelect == 1 ? "[" + year + "]" : year) + - "/" + (currentSelect == 2 ? "[" + month + "]" : month) + - "/" + (currentSelect == 3 ? "[" + day + "]" : day) + (currentSelect == 1 ? "[" + year + "]" : year) + + "/" + (currentSelect == 2 ? "[" + month + "]" : month) + + "/" + (currentSelect == 3 ? "[" + day + "]" : day) )); this.updateInventory(); @@ -94,18 +94,18 @@ public boolean shouldActivate(InventoryClickEvent e) { @Override public void onClick(InventoryClickEvent event) { - if (event.isShiftClick()){ - if (event.isLeftClick()){ + if (event.isShiftClick()) { + if (event.isLeftClick()) { this.currentSelect = selector.previous(); - }else if (event.isRightClick()){ + } else if (event.isRightClick()) { this.currentSelect = selector.next(); - }else{ + } else { return; } - }else{ + } else { try { this.handlerMap.get(currentSelect).accept(event); - } catch (DateTimeException e){ + } catch (DateTimeException e) { event.getWhoClicked().sendMessage(e.getMessage()); return; } @@ -131,7 +131,7 @@ public long getMaxWaitingTime() { @Override public void callBack(AsyncChatEvent event) { - String message = ((TextComponent)event.message()).content(); + String message = ((TextComponent) event.message()).content(); try { String[] args = message.split(" "); int year = Integer.parseInt(args[0]); @@ -140,7 +140,7 @@ public void callBack(AsyncChatEvent event) { this.currentValue = LocalDate.of(year, month, days); attributeController.setAttribute(getItem(), AttributeController.VALUE_TAG, this.currentValue); this.updateItem(); - }catch (RuntimeException e){ + } catch (RuntimeException e) { event.getPlayer().sendMessage(invalid); } } diff --git a/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/component/PasswordInputField.java b/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/component/PasswordInputField.java index 2a67114..ac36780 100644 --- a/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/component/PasswordInputField.java +++ b/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/component/PasswordInputField.java @@ -94,8 +94,8 @@ public long getMaxWaitingTime() { @Override public void callBack(AsyncChatEvent event) { - String message = ((TextComponent)event.message()).content(); - if (!regex.matcher(message).find()){ + String message = ((TextComponent) event.message()).content(); + if (!regex.matcher(message).find()) { event.getPlayer().sendMessage(invalidMessage); return; } @@ -111,7 +111,7 @@ public Class getEventClass() { } - private void updateItem(){ + private void updateItem() { itemFactory.lore(List.of( "&7-> &f" + (plainText == null ? "NONE" : (showText ? plainText : String.valueOf(mask).repeat(plainText.length()))), "&b中鍵以 " + (showText ? hidePasswordTxt : showPasswordTxt) diff --git a/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/component/RGBSelector.java b/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/component/RGBSelector.java index 2be0907..63a3626 100644 --- a/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/component/RGBSelector.java +++ b/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/component/RGBSelector.java @@ -114,22 +114,22 @@ public long getMaxWaitingTime() { @Override public void callBack(AsyncChatEvent event) { - String input = ((TextComponent)event.message()).content(); + String input = ((TextComponent) event.message()).content(); Color color; try { - if (input.startsWith("#") && input.length() == 7){ + if (input.startsWith("#") && input.length() == 7) { int rgb = Integer.parseInt(input.substring(1), 16); color = Color.fromRGB(rgb); - }else if (input.split(" ").length == 3){ + } else if (input.split(" ").length == 3) { String[] args = input.split(" "); int red = Integer.parseInt(args[0]); int green = Integer.parseInt(args[1]); int blue = Integer.parseInt(args[2]); color = Color.fromRGB(red, green, blue); - }else{ + } else { throw new IllegalArgumentException(); } - }catch (RuntimeException e){ + } catch (RuntimeException e) { event.getPlayer().sendMessage(invalidMessage); return; } diff --git a/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/component/TimeSelector.java b/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/component/TimeSelector.java index f77ffa8..1eb5d81 100644 --- a/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/component/TimeSelector.java +++ b/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/component/TimeSelector.java @@ -45,7 +45,7 @@ public TimeSelector( this.invalid = invalid; this.disabled = disabled; this.maxWait = maxWait; - this.currentValue = Optional.ofNullable((LocalTime)attributeController.getAttribute(getItem(), AttributeController.VALUE_TAG)).orElseGet(LocalTime::now); + this.currentValue = Optional.ofNullable((LocalTime) attributeController.getAttribute(getItem(), AttributeController.VALUE_TAG)).orElseGet(LocalTime::now); handlerMap.put(1, e -> { if (e.isLeftClick()) { @@ -71,7 +71,7 @@ public TimeSelector( this.updateItem(); } - private void updateItem(){ + private void updateItem() { int hour = this.currentValue.getHour(); int minute = this.currentValue.getMinute(); int second = this.currentValue.getSecond(); @@ -92,18 +92,18 @@ public boolean shouldActivate(InventoryClickEvent e) { @Override public void onClick(InventoryClickEvent event) { - if (event.isShiftClick()){ - if (event.isLeftClick()){ + if (event.isShiftClick()) { + if (event.isLeftClick()) { this.currentSelect = selector.previous(); - }else if (event.isRightClick()){ + } else if (event.isRightClick()) { this.currentSelect = selector.next(); - }else{ + } else { return; } - }else{ + } else { try { this.handlerMap.get(currentSelect).accept(event); - } catch (DateTimeException e){ + } catch (DateTimeException e) { event.getWhoClicked().sendMessage(e.getMessage()); return; } @@ -129,7 +129,7 @@ public long getMaxWaitingTime() { @Override public void callBack(AsyncChatEvent event) { - String message = ((TextComponent)event.message()).content(); + String message = ((TextComponent) event.message()).content(); try { String[] args = message.split(":"); int hour = Integer.parseInt(args[0]); @@ -138,7 +138,7 @@ public void callBack(AsyncChatEvent event) { this.currentValue = LocalTime.of(hour, minute, second); attributeController.setAttribute(getItem(), AttributeController.VALUE_TAG, this.currentValue); this.updateItem(); - }catch (RuntimeException e){ + } catch (RuntimeException e) { event.getPlayer().sendMessage(invalid); } } diff --git a/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/component/factory/ELDGBukkitItemFactory.java b/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/component/factory/ELDGBukkitItemFactory.java index 9e74f00..b8d1690 100644 --- a/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/component/factory/ELDGBukkitItemFactory.java +++ b/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/component/factory/ELDGBukkitItemFactory.java @@ -7,7 +7,7 @@ import java.util.function.Consumer; -public final class ELDGBukkitItemFactory extends AbstractComponentFactory implements BukkitItemFactory{ +public final class ELDGBukkitItemFactory extends AbstractComponentFactory implements BukkitItemFactory { public ELDGBukkitItemFactory(ItemStackService itemStackService, AttributeController attributeController) { super(itemStackService, attributeController); diff --git a/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/component/factory/ELDGDateSelectorFactory.java b/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/component/factory/ELDGDateSelectorFactory.java index b992bd9..457813a 100644 --- a/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/component/factory/ELDGDateSelectorFactory.java +++ b/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/component/factory/ELDGDateSelectorFactory.java @@ -7,7 +7,7 @@ import java.time.LocalDate; -public final class ELDGDateSelectorFactory extends AbstractComponentFactory implements DateSelectorFactory{ +public final class ELDGDateSelectorFactory extends AbstractComponentFactory implements DateSelectorFactory { private String input; private String invalid; diff --git a/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/component/factory/ELDGNumInputFactory.java b/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/component/factory/ELDGNumInputFactory.java index 5c18edf..6f9a987 100644 --- a/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/component/factory/ELDGNumInputFactory.java +++ b/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/component/factory/ELDGNumInputFactory.java @@ -7,7 +7,7 @@ import java.util.Optional; -public final class ELDGNumInputFactory extends AbstractComponentFactory implements NumInputFactory{ +public final class ELDGNumInputFactory extends AbstractComponentFactory implements NumInputFactory { private boolean disabled; private String inputMessage; @@ -40,7 +40,7 @@ public NumInputFactory label(String label) { @Override public NumberTypeFactory useNumberType(Class type) { - var f = new ELDNumberTypeFactory<>(type); + var f = new ELDNumberTypeFactory<>(type); this.typeFactory = f; return f; } @@ -104,7 +104,7 @@ public NumInputFactory.NumberTypeFactory bindInput(String field, T initValue) return this; } - public Component build(ItemStackService.ItemFactory itemFactory){ + public Component build(ItemStackService.ItemFactory itemFactory) { return new NumInputField( attributeController, itemFactory, diff --git a/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/component/factory/ELDGSelectionFactory.java b/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/component/factory/ELDGSelectionFactory.java index fc7a135..c215ea0 100644 --- a/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/component/factory/ELDGSelectionFactory.java +++ b/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/component/factory/ELDGSelectionFactory.java @@ -155,10 +155,10 @@ public SelectionFactory then() { .collect(Collectors.toList()) ); if (initValue == null) return; - if (amounts.containsKey(initValue)){ + if (amounts.containsKey(initValue)) { f.amount(amounts.get(initValue)); } - if (icons.containsKey(initValue)){ + if (icons.containsKey(initValue)) { f.material(icons.get(initValue)); } }); diff --git a/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/demo/DemoInventories.java b/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/demo/DemoInventories.java index d29fb53..4984d2f 100644 --- a/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/demo/DemoInventories.java +++ b/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/demo/DemoInventories.java @@ -5,7 +5,7 @@ @GroupResource( folder = "templates", - preloads = { "user", "user-list" } + preloads = {"user", "user-list"} ) public class DemoInventories extends InventoryTemplate { } diff --git a/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/demo/async/AsyncController.java b/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/demo/async/AsyncController.java index 5fb54f0..9bea594 100644 --- a/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/demo/async/AsyncController.java +++ b/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/demo/async/AsyncController.java @@ -22,7 +22,7 @@ public final class AsyncController { @Inject private ELDGPlugin plugin; - public ScheduleService.BukkitPromise> index(){ + public ScheduleService.BukkitPromise> index() { return scheduleService.runAsync(plugin, () -> { try { Thread.sleep(5000); @@ -36,7 +36,7 @@ public final class AsyncController { @AsyncLoadingView(CustomLoadingView.class) @ClickMapping(view = AsyncView.class, pattern = 'A') - public CompletableFuture> onClick(Player player){ + public CompletableFuture> onClick(Player player) { player.sendMessage("3 seconds to go to the user view with completableFuture"); return CompletableFuture.runAsync(() -> { try { diff --git a/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/demo/login/AuthService.java b/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/demo/login/AuthService.java index 5baed6b..0de28a2 100644 --- a/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/demo/login/AuthService.java +++ b/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/demo/login/AuthService.java @@ -38,24 +38,24 @@ public boolean authenticate(String username, String password) { return this.userStorage.get(username).equals(password); } - public boolean isAdmin(String username){ + public boolean isAdmin(String username) { return username.equals("admin1234"); } - public boolean isAdmin(LoginSession content){ + public boolean isAdmin(LoginSession content) { return this.isAdmin(content.username); } - public void saveSession(UUID player, LoginSession content){ + public void saveSession(UUID player, LoginSession content) { this.sessionStorage.put(player, content); } @Nullable - public LoginSession getSession(UUID player){ + public LoginSession getSession(UUID player) { return this.sessionStorage.get(player); } - public void removeSession(UUID player){ + public void removeSession(UUID player) { this.sessionStorage.remove(player); } diff --git a/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/demo/login/LoginController.java b/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/demo/login/LoginController.java index 03a71aa..a2da623 100644 --- a/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/demo/login/LoginController.java +++ b/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/demo/login/LoginController.java @@ -20,20 +20,20 @@ public class LoginController { private AuthService authService; @PostConstruct - public void beforeEnterView(UISession session, Player player){ + public void beforeEnterView(UISession session, Player player) { var s = authService.getSession(player.getUniqueId()); - if (s != null && session.getAttribute("session") == null){ + if (s != null && session.getAttribute("session") == null) { session.setAttribute("session", s); } } @RequireLogin - public BukkitView index(){ + public BukkitView index() { return new BukkitView<>(MainView.class); } @ClickMapping(view = LoginView.class, pattern = 'E') - public BukkitView login(UISession session, @MapAttribute('C') Map map, Player player){ + public BukkitView login(UISession session, @MapAttribute('C') Map map, Player player) { var username = (String) map.get("username"); var success = authService.authenticate(username, (String) map.get("password")); if (success) { @@ -50,13 +50,13 @@ public void beforeEnterView(UISession session, Player player){ @ClickMapping(view = LoginFailedView.class, pattern = 'C') - public BukkitView backToLogin(){ + public BukkitView backToLogin() { return new BukkitView<>(LoginView.class); } @RequireLogin @ClickMapping(view = MainView.class, pattern = 'C') - public BukkitView logout(UISession session, Player player){ + public BukkitView logout(UISession session, Player player) { session.pollAttribute("session"); authService.removeSession(player.getUniqueId()); player.sendMessage("登出成功。"); @@ -66,25 +66,25 @@ public void beforeEnterView(UISession session, Player player){ @RequireAdmin @RequireLogin @ClickMapping(view = MainView.class, pattern = 'D') - public BukkitView toAdminView(){ + public BukkitView toAdminView() { return new BukkitView<>(AdminContentView.class); } @RequireLogin @ClickMapping(view = AdminContentView.class, pattern = 'C') - public BukkitView backToMain(){ + public BukkitView backToMain() { return new BukkitView<>(MainView.class); } @RequireLogin @ClickMapping(view = UserProfileView.class, pattern = 'C') - public BukkitView backToMain2(){ + public BukkitView backToMain2() { return new BukkitView<>(MainView.class); } @RequireLogin @ClickMapping(view = MainView.class, pattern = 'E') - public BukkitView goToProfileView(UISession session, Player player){ + public BukkitView goToProfileView(UISession session, Player player) { LoginSession s = session.getAttribute("session"); if (s == null) throw new RuntimeException("session is null"); var admin = authService.isAdmin(s); diff --git a/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/demo/login/UserProfileView.java b/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/demo/login/UserProfileView.java index 6655f11..6ce857d 100644 --- a/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/demo/login/UserProfileView.java +++ b/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/demo/login/UserProfileView.java @@ -22,9 +22,9 @@ public void renderView(UserProfile model, UIContext context) { btn.icon(Material.PAPER) .title("&a你的個人資料") .lore( - "&e賬戶ID: &b"+model.username, - "&e賬戶名稱: &b"+model.playerName, - "&e是否管理員: &b"+model.isAdmin + "&e賬戶ID: &b" + model.username, + "&e賬戶名稱: &b" + model.playerName, + "&e是否管理員: &b" + model.isAdmin ) .create() ) diff --git a/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/demo/middlewares/AuthenticateMiddleWare.java b/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/demo/middlewares/AuthenticateMiddleWare.java index f051c2c..deb2158 100644 --- a/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/demo/middlewares/AuthenticateMiddleWare.java +++ b/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/demo/middlewares/AuthenticateMiddleWare.java @@ -14,7 +14,7 @@ public class AuthenticateMiddleWare implements MiddleWare { private final DebugLogger logger; @Inject - public AuthenticateMiddleWare(LoggingService loggingService){ + public AuthenticateMiddleWare(LoggingService loggingService) { this.logger = loggingService.getLogger(getClass()); } @@ -24,7 +24,7 @@ public void intercept(InterceptContext context, RequireLogin annotation) throws if (session == null) { logger.debugF("player %s is not login in, redirecting to login page", context.getPlayer().getName()); context.setRedirect(new BukkitView<>(LoginView.class)); - }else{ + } else { logger.debugF("player %s is login in, continue", context.getPlayer().getName()); } } diff --git a/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/demo/middlewares/AuthorizeMiddleWare.java b/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/demo/middlewares/AuthorizeMiddleWare.java index 36793c3..3101d49 100644 --- a/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/demo/middlewares/AuthorizeMiddleWare.java +++ b/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/demo/middlewares/AuthorizeMiddleWare.java @@ -17,7 +17,7 @@ public class AuthorizeMiddleWare implements MiddleWare { private final DebugLogger logger; @Inject - public AuthorizeMiddleWare(LoggingService loggingService){ + public AuthorizeMiddleWare(LoggingService loggingService) { this.logger = loggingService.getLogger(getClass()); } @@ -31,7 +31,7 @@ public void intercept(InterceptContext context, RequireAdmin annotation) throws context.getSession().setAttribute("exception", new Exception("you are not admin.")); context.getSession().setAttribute("from", "login"); context.setRedirect(new BukkitRedirectView("error")); - }else{ + } else { logger.debugF("player %s is admin, continue", context.getPlayer().getName()); } } diff --git a/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/demo/test/TestController.java b/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/demo/test/TestController.java index c85080f..d0ccc67 100644 --- a/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/demo/test/TestController.java +++ b/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/demo/test/TestController.java @@ -15,17 +15,17 @@ public class TestController { @PostConstruct - public void beforeCreate(Player player){ + public void beforeCreate(Player player) { player.sendMessage("life cycle: before create for test controller"); } - public BukkitView index(){ + public BukkitView index() { return new BukkitView<>(TestView.class); } @ClickMapping(view = TestView.class, pattern = 'A') - public BukkitView onClick(@ModelAttribute('Z') TestModel test, Player player, @MapAttribute('Z') Map map){ + public BukkitView onClick(@ModelAttribute('Z') TestModel test, Player player, @MapAttribute('Z') Map map) { player.sendMessage(test.toString()); player.sendMessage(map.toString()); return null; @@ -33,7 +33,7 @@ public void beforeCreate(Player player){ @PreDestroy - public void beforeDestroy(Player player){ + public void beforeDestroy(Player player) { player.sendMessage("life cycle: before destroy for test controller"); } } diff --git a/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/demo/user/UserController.java b/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/demo/user/UserController.java index fe74dd0..3f254da 100644 --- a/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/demo/user/UserController.java +++ b/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/demo/user/UserController.java @@ -36,7 +36,7 @@ public class UserController { } else { // try using throw exception -> try using pass controller //return new BukkitView<>(UserNotFoundView.class, username); - UserNotFoundException e = new UserNotFoundException(username); + UserNotFoundException e = new UserNotFoundException(username); session.setAttribute("exception", e); session.setAttribute("from", "user"); return new BukkitRedirectView("error"); @@ -83,7 +83,7 @@ public class UserController { @ClickMapping(view = UserUpdateView.class, pattern = 'B') public BukkitView onSave(@ModelAttribute('A') User user, Player player) { - player.sendMessage("Pre Saving: "+user.toString()); + player.sendMessage("Pre Saving: " + user.toString()); userService.save(user); player.sendMessage("Save Success"); return index(); @@ -91,12 +91,12 @@ public class UserController { @PostUpdateView(UserView.class) - public void updateToUserView(Player player){ + public void updateToUserView(Player player) { player.sendMessage("post update: user view"); } @PreDestroyView(UserListView.class) - public void preDestroyUserListView(Player player){ + public void preDestroyUserListView(Player player) { player.sendMessage("pre destroy: user list view"); } diff --git a/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/event/ELDGClickEventHandler.java b/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/event/ELDGClickEventHandler.java index 6f44cec..47fdde5 100644 --- a/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/event/ELDGClickEventHandler.java +++ b/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/event/ELDGClickEventHandler.java @@ -23,7 +23,7 @@ public ELDGClickEventHandler(Object controller, MethodParseManager parseManager, @Override protected Map loadAllHandlers(Method[] controllerMethods) { - return Arrays.stream(controllerMethods).parallel() + return Arrays.stream(controllerMethods).parallel() .filter(m -> m.isAnnotationPresent(ClickMapping.class)) .collect(Collectors.toMap(m -> m.getAnnotation(ClickMapping.class), m -> m)); } @@ -47,7 +47,7 @@ protected boolean slotTrigger(List slots, InventoryClickEvent event) { @Override protected RequestMapping toRequestMapping(ClickMapping annotation) { - return new RequestMapping(){ + return new RequestMapping() { @Override public Class> view() { diff --git a/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/event/ELDGEventHandler.java b/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/event/ELDGEventHandler.java index 4646192..f94e4eb 100644 --- a/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/event/ELDGEventHandler.java +++ b/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/event/ELDGEventHandler.java @@ -43,9 +43,9 @@ public ELDGEventHandler(Object controller, this.middleWareManager = middleWareManager; this.returnTypeManager = returnTypeManager; this.customQualifier = customQualifier; - if (controllerEventMap.containsKey(controller.getClass())){ + if (controllerEventMap.containsKey(controller.getClass())) { this.eventMap.putAll(controllerEventMap.get(controller.getClass())); - }else{ + } else { this.loadAllCommonHandlers(declaredMethods); this.loadAllHandlers(declaredMethods).forEach((k, v) -> eventMap.put(toRequestMapping(k), v)); controllerEventMap.put(controller.getClass(), ImmutableMap.copyOf(eventMap)); @@ -92,7 +92,7 @@ public boolean onEventHandle( } return requestMapper.pattern() == patternClicked && requestMapper.event() == e.getClass() - && ( requestMapper.view() == AnyView.class || requestMapper.view() == currentView.getClass() ); + && (requestMapper.view() == AnyView.class || requestMapper.view() == currentView.getClass()); }) .filter((en) -> { Method method = en.getValue(); diff --git a/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/manager/LifeCycleManager.java b/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/manager/LifeCycleManager.java index 22d8173..1b18f55 100644 --- a/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/manager/LifeCycleManager.java +++ b/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/manager/LifeCycleManager.java @@ -44,7 +44,7 @@ private void loadLifeCycle(Class lifeCycle) { } } - private void loadViewLifeCycle(Class lifeCycle, LifeCycleFilter filter){ + private void loadViewLifeCycle(Class lifeCycle, LifeCycleFilter filter) { this.viewLifeCycleFilterMap.put(lifeCycle, filter); List methods = Arrays.stream(controller.getClass().getMethods()).filter(m -> m.isAnnotationPresent(lifeCycle)).collect(Collectors.toList()); if (methods.isEmpty()) return; @@ -52,7 +52,7 @@ private void loadViewLifeCycle(Class lifeCycle, LifeCy } @SuppressWarnings("unchecked") - public > void onViewLifeCycle(Class lifeCycle, Class viewCls){ + public > void onViewLifeCycle(Class lifeCycle, Class viewCls) { Optional.ofNullable(this.viewLifeCycleMap.get(lifeCycle)).flatMap(methods -> methods.parallelStream().filter(m -> { A anno = m.getAnnotation(lifeCycle); return Optional diff --git a/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/manager/MethodParseManager.java b/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/manager/MethodParseManager.java index 392c022..b20a5a1 100644 --- a/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/manager/MethodParseManager.java +++ b/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/manager/MethodParseManager.java @@ -1,5 +1,6 @@ package com.ericlam.mc.eldgui.manager; +import com.ericlam.mc.eld.services.ReflectionService; import org.bukkit.event.inventory.InventoryEvent; import org.jetbrains.annotations.Nullable; @@ -16,9 +17,9 @@ public final class MethodParseManager { private final Map, MethodParser> supplierMap = new ConcurrentHashMap<>(); - private final ReflectionCacheManager cacheManager; + private final ReflectionService cacheManager; - public MethodParseManager(ReflectionCacheManager cacheManager) { + public MethodParseManager(ReflectionService cacheManager) { this.cacheManager = cacheManager; } diff --git a/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/manager/ReflectionCacheManager.java b/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/manager/ReflectionCacheManager.java deleted file mode 100644 index 772a90d..0000000 --- a/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/manager/ReflectionCacheManager.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.ericlam.mc.eldgui.manager; - -import java.lang.annotation.Annotation; -import java.lang.reflect.Method; -import java.lang.reflect.Type; -import java.util.HashMap; -import java.util.Map; - -public class ReflectionCacheManager { - private final Map methodAnnotationMap = new HashMap<>(); - private final Map, Annotation[]> classAnnotationMap = new HashMap<>(); - private final Map, Method[]> classMethodsMap = new HashMap<>(); - - private final Map methodParameterAnnotationMap = new HashMap<>(); - - private final Map methodParameterTypeMap = new HashMap<>(); - - public Annotation[] getDeclaredAnnotations(Method method) { - return methodAnnotationMap.computeIfAbsent(method, Method::getDeclaredAnnotations); - } - - public Annotation[] getDeclaredAnnotations(Class clazz) { - return classAnnotationMap.computeIfAbsent(clazz, Class::getDeclaredAnnotations); - } - - public Method[] getMethods(Class clazz) { - return classMethodsMap.computeIfAbsent(clazz, Class::getMethods); - } - - public Annotation[][] getParameterAnnotations(Method method) { - return methodParameterAnnotationMap.computeIfAbsent(method, Method::getParameterAnnotations); - } - - public Type[] getParameterTypes(Method method) { - return methodParameterTypeMap.computeIfAbsent(method, Method::getGenericParameterTypes); - } -} diff --git a/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/manager/ReturnTypeManager.java b/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/manager/ReturnTypeManager.java index cdbf29f..6a33d73 100644 --- a/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/manager/ReturnTypeManager.java +++ b/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/manager/ReturnTypeManager.java @@ -1,5 +1,6 @@ package com.ericlam.mc.eldgui.manager; +import com.ericlam.mc.eld.services.ReflectionService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -17,9 +18,9 @@ public final class ReturnTypeManager { private final Map, BiConsumer> supplierMap = new ConcurrentHashMap<>(); - private final ReflectionCacheManager cacheManager; + private final ReflectionService cacheManager; - public ReturnTypeManager(ReflectionCacheManager cacheManager) { + public ReturnTypeManager(ReflectionService cacheManager) { this.cacheManager = cacheManager; } diff --git a/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/middleware/MiddleWareManager.java b/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/middleware/MiddleWareManager.java index e880cf2..6530088 100644 --- a/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/middleware/MiddleWareManager.java +++ b/ELDependenci-MVC-plugin/src/main/java/com/ericlam/mc/eldgui/middleware/MiddleWareManager.java @@ -1,9 +1,8 @@ package com.ericlam.mc.eldgui.middleware; +import com.ericlam.mc.eld.services.ReflectionService; import com.ericlam.mc.eldgui.ELDGMVCInstallation; import com.ericlam.mc.eldgui.UISession; -import com.ericlam.mc.eldgui.controller.AsyncLoadingView; -import com.ericlam.mc.eldgui.manager.ReflectionCacheManager; import com.ericlam.mc.eldgui.view.BukkitView; import com.google.inject.Injector; import org.apache.commons.lang.ArrayUtils; @@ -12,7 +11,6 @@ import javax.annotation.Nullable; import java.lang.annotation.Annotation; import java.lang.reflect.Method; -import java.util.HashMap; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; @@ -21,12 +19,12 @@ public class MiddleWareManager { private final Annotation[] controllerAnnotations; - private final ReflectionCacheManager reflectionCacheManager; + private final ReflectionService reflectionCacheManager; private final Player player; private final UISession session; public MiddleWareManager( - ReflectionCacheManager reflectionCacheManager, + ReflectionService reflectionCacheManager, ELDGMVCInstallation installation, Injector injector, Class controllerCls, @@ -60,7 +58,7 @@ public MiddleWareManager( for (Annotation annotation : totalAnnotations) { if (!middleWareMap.containsKey(annotation.annotationType())) continue; invokeMiddleWare(annotation.annotationType(), annotation, context); - if (context.getView() != null){ + if (context.getView() != null) { return context.getView(); } } @@ -68,7 +66,6 @@ public MiddleWareManager( } - @SuppressWarnings("unchecked") private void invokeMiddleWare(Class type, Annotation annotation, ELDGInterceptContext context) throws Exception { var anno = type.cast(annotation); diff --git a/ELDependenci-MVC-plugin/src/test/java/how/to/use/in/external/TestMain.java b/ELDependenci-MVC-plugin/src/test/java/how/to/use/in/external/TestMain.java index 5181ff3..395b97d 100644 --- a/ELDependenci-MVC-plugin/src/test/java/how/to/use/in/external/TestMain.java +++ b/ELDependenci-MVC-plugin/src/test/java/how/to/use/in/external/TestMain.java @@ -8,7 +8,6 @@ import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.type.TypeFactory; import com.google.common.collect.Lists; import com.google.gson.Gson; @@ -49,7 +48,7 @@ public static void main(String[] args) { } - public static Map reflectToMap(T model) { + public static Map reflectToMap(T model) { if (model == null) return Map.of(); diff --git a/ELDependenci-MVC-plugin/src/test/java/how/to/use/in/external/UserController.java b/ELDependenci-MVC-plugin/src/test/java/how/to/use/in/external/UserController.java index 1614d7c..d6144de 100644 --- a/ELDependenci-MVC-plugin/src/test/java/how/to/use/in/external/UserController.java +++ b/ELDependenci-MVC-plugin/src/test/java/how/to/use/in/external/UserController.java @@ -18,13 +18,12 @@ public class UserController { @Inject private UserService userService; - public BukkitView index(){ + public BukkitView index() { List users = userService.findAll(); return new BukkitView<>(UserListView.class, users); } - @RequestMapping( view = UserListView.class, event = InventoryClickEvent.class, @@ -35,11 +34,11 @@ public class UserController { view = UserListView.class, pattern = 'A' ) - public BukkitView checkUserInfo(@ItemAttribute("id") String id, Player player){ + public BukkitView checkUserInfo(@ItemAttribute("id") String id, Player player) { Optional user = userService.findById(id); - if (user.isPresent()){ + if (user.isPresent()) { return new BukkitView<>(UserView.class, user.get()); - }else{ + } else { player.sendMessage("user not exist."); return index(); } diff --git a/ELDependenci-MVC-plugin/src/test/java/how/to/use/in/external/UserView.java b/ELDependenci-MVC-plugin/src/test/java/how/to/use/in/external/UserView.java index b6bdbdd..14c51e0 100644 --- a/ELDependenci-MVC-plugin/src/test/java/how/to/use/in/external/UserView.java +++ b/ELDependenci-MVC-plugin/src/test/java/how/to/use/in/external/UserView.java @@ -7,7 +7,7 @@ public class UserView implements View { @Override public void renderView(User model, UIContext context) { - System.out.println("show user info of "+model.username); + System.out.println("show user info of " + model.username); System.out.println(model); } diff --git a/pom.xml b/pom.xml index 4d79de8..f8f88fa 100644 --- a/pom.xml +++ b/pom.xml @@ -58,13 +58,13 @@ org.eldependenci eldependenci-bukkit - 2.0 + 2.0.1 provided org.eldependenci eldependenci-addon - 2.0 + 2.0.1 provided @@ -114,7 +114,7 @@ https://hub.spigotmc.org/javadocs/spigot/ - https://eldependenci.github.io/ELDependenci/eldependenci-bukkit + https://eldependenci.github.io/ELDependenci/javadocs/eldependenci-bukkit public false