From d480048ebba746ff45fbe6d70c1b2ceafa203239 Mon Sep 17 00:00:00 2001 From: Allink Date: Thu, 19 May 2022 19:47:56 +0100 Subject: [PATCH] Revert "Revert "Revert "Revert "Revert "https://media.discordapp.net/attachments/968519299763413022/976916680032800868/caption.gif""""" This reverts commit 7fdd008ae7d12315b9ddb2074d3b49333c6debdf. --- src/main/java/dev/plex/nush/Message.java | 7 +- src/main/java/dev/plex/nush/NushAction.java | 47 ++++---- src/main/java/dev/plex/nush/NushModule.java | 53 ++++---- .../plex/nush/command/impl/NUSHCommand.java | 113 ++++++++---------- .../java/dev/plex/nush/handler/Handler.java | 5 +- .../plex/nush/handler/impl/ActionHandler.java | 106 ++++++++-------- .../nush/handler/impl/CommandHandler.java | 12 +- .../nush/handler/impl/ListenerHandler.java | 14 +-- .../plex/nush/listener/impl/ChatListener.java | 88 +++++++------- .../plex/nush/listener/impl/JoinListener.java | 27 ++--- .../dev/plex/nush/util/ReflectionsUtil.java | 82 ++++++------- 11 files changed, 247 insertions(+), 307 deletions(-) diff --git a/src/main/java/dev/plex/nush/Message.java b/src/main/java/dev/plex/nush/Message.java index ac25a37..5aaf8c7 100644 --- a/src/main/java/dev/plex/nush/Message.java +++ b/src/main/java/dev/plex/nush/Message.java @@ -7,9 +7,8 @@ import net.kyori.adventure.text.Component; @Data @AllArgsConstructor -public class Message -{ +public class Message { - UUID sender; - Component message; + UUID sender; + Component message; } diff --git a/src/main/java/dev/plex/nush/NushAction.java b/src/main/java/dev/plex/nush/NushAction.java index 3c3afbd..54bc1b9 100644 --- a/src/main/java/dev/plex/nush/NushAction.java +++ b/src/main/java/dev/plex/nush/NushAction.java @@ -2,34 +2,29 @@ package dev.plex.nush; import javax.annotation.Nullable; -public enum NushAction -{ - MUTE("Mute Player", 0), - CANCEL("Cancel", 1), - SMITE("Smite", 2), - BAN("Ban Player", 3), - ACCEPT("Accept", 4); +public enum NushAction { + MUTE("Mute Player", 0), + CANCEL("Cancel", 1), + SMITE("Smite", 2), + BAN("Ban Player", 3), + ACCEPT("Accept", 4); - public final String humanReadable; - public final int ordinal; + public final String humanReadable; + public final int ordinal; - NushAction(String humanReadable, int ordinal) - { - this.humanReadable = humanReadable; - this.ordinal = ordinal; - } + NushAction(String humanReadable, int ordinal) { + this.humanReadable = humanReadable; + this.ordinal = ordinal; + } - @Nullable - public static NushAction fromOrdinal(int ordinal) - { - for (NushAction value : NushAction.values()) - { - if (value.ordinal == ordinal) - { - return value; - } - } + @Nullable + public static NushAction fromOrdinal(int ordinal) { + for (NushAction value : NushAction.values()) { + if (value.ordinal == ordinal) { + return value; + } + } - return null; - } + return null; + } } diff --git a/src/main/java/dev/plex/nush/NushModule.java b/src/main/java/dev/plex/nush/NushModule.java index 14d589c..8b0e6c1 100644 --- a/src/main/java/dev/plex/nush/NushModule.java +++ b/src/main/java/dev/plex/nush/NushModule.java @@ -8,38 +8,33 @@ import dev.plex.nush.handler.impl.ListenerHandler; import java.util.Map; import java.util.Map.Entry; -public class NushModule extends PlexModule -{ +public class NushModule extends PlexModule { - public static final Map messages = Map.ofEntries( - Map.entry("nushToggled", "{0} - {1} NUSH."), - Map.entry("nushApply", "Applying {0} to {1}!")); - public static boolean enabled = false; - private static NushModule INSTANCE; + public static final Map messages = Map.ofEntries( + Map.entry("nushToggled", "{0} - {1} NUSH."), + Map.entry("nushApply", "Applying {0} to {1}!")); + public static boolean enabled = false; + private static NushModule INSTANCE; - public static NushModule getInstance() - { - return INSTANCE; - } + public static NushModule getInstance() { + return INSTANCE; + } - @Override - public void enable() - { - INSTANCE = this; - Plex plex = getPlex(); - for (Entry entry : messages.entrySet()) - { - plex.messages.addDefault(entry.getKey(), entry.getValue()); - } + @Override + public void enable() { + INSTANCE = this; + Plex plex = getPlex(); + for (Entry entry : messages.entrySet()) { + plex.messages.addDefault(entry.getKey(), entry.getValue()); + } - new ActionHandler().init(this); - new CommandHandler().init(this); - new ListenerHandler().init(this); - } + new ActionHandler().init(this); + new CommandHandler().init(this); + new ListenerHandler().init(this); + } - @Override - public void disable() - { - // Unregistering listeners / commands is handled by Plex - } + @Override + public void disable() { + // Unregistering listeners / commands is handled by Plex + } } diff --git a/src/main/java/dev/plex/nush/command/impl/NUSHCommand.java b/src/main/java/dev/plex/nush/command/impl/NUSHCommand.java index e726356..3a6f5f6 100644 --- a/src/main/java/dev/plex/nush/command/impl/NUSHCommand.java +++ b/src/main/java/dev/plex/nush/command/impl/NUSHCommand.java @@ -18,83 +18,68 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; + import static dev.plex.nush.NushAction.ACCEPT; import static dev.plex.nush.NushAction.CANCEL; @CommandParameters(name = "nush", aliases = "raidmode", description = "Toggle NUSH on or off.", usage = "/ [on | enable | off | disable | toggle]") @CommandPermissions(level = Rank.ADMIN, permission = "plex.nush.command") -public class NUSHCommand extends PlexCommand -{ +public class NUSHCommand extends PlexCommand { - @Override - protected Component execute(@NotNull CommandSender commandSender, @Nullable Player player, - @NotNull String[] args) - { - if (args.length == 0) - { - NushModule.enabled = !NushModule.enabled; - } - else if (args.length == 1) - { - switch (args[0].toLowerCase()) - { - case "on", "enable" -> NushModule.enabled = true; - case "off", "disable" -> NushModule.enabled = false; - case "toggle" -> NushModule.enabled = !NushModule.enabled; - } - } - else - { - if (args[0].equalsIgnoreCase("work")) - { - try - { - UUID nushIdentifier = UUID.fromString(args[1]); - Message nushMessage = ActionHandler.MAP.get(nushIdentifier); + @Override + protected Component execute(@NotNull CommandSender commandSender, @Nullable Player player, + @NotNull String[] args) { + if (args.length == 0) { + NushModule.enabled = !NushModule.enabled; + } else if (args.length == 1) { + switch (args[0].toLowerCase()) { + case "on", "enable" -> NushModule.enabled = true; + case "off", "disable" -> NushModule.enabled = false; + case "toggle" -> NushModule.enabled = !NushModule.enabled; + } + } else { + if (args[0].equalsIgnoreCase("work")) { + try { + UUID nushIdentifier = UUID.fromString(args[1]); + Message nushMessage = ActionHandler.MAP.get(nushIdentifier); - if (nushMessage == null) - { - return null; - } + if (nushMessage == null) { + return null; + } - NushAction action = NushAction.fromOrdinal(Integer.parseInt(args[2])); - if (action == null) - { - return null; - } + NushAction action = NushAction.fromOrdinal(Integer.parseInt(args[2])); + if (action == null) { + return null; + } - if (action == ACCEPT || action == CANCEL) - { - ActionHandler.resolve(nushIdentifier, action); - return Component.text(action.humanReadable, NamedTextColor.YELLOW); - } + if (action == ACCEPT || action == CANCEL) { + ActionHandler.resolve(nushIdentifier, action); + return Component.text(action.humanReadable, NamedTextColor.YELLOW); + } - StringBuilder command = new StringBuilder(); + StringBuilder command = new StringBuilder(); - command.append(action.name().toLowerCase()); - command.append(" "); - command.append(nushMessage.getSender()); + command.append(action.name().toLowerCase()); + command.append(" "); + command.append(nushMessage.getSender()); - if (!command.toString().trim().isEmpty()) - { - PlexLog.debug("Dispatching command: {0}", command.toString()); - Bukkit.dispatchCommand(commandSender, command.toString()); - } + if (!command.toString().trim().isEmpty()) { + PlexLog.debug("Dispatching command: {0}", command.toString()); + Bukkit.dispatchCommand(commandSender, command.toString()); + } - ActionHandler.resolve(nushIdentifier, action); - return Component.text(action.humanReadable, NamedTextColor.YELLOW); - } - catch (Exception ignored) - { - return null; - } - } + ActionHandler.resolve(nushIdentifier, action); + return Component.text(action.humanReadable, NamedTextColor.YELLOW); + } catch (Exception ignored) { + return null; + } + } - return null; - } + return null; + } - PlexUtils.broadcastToAdmins(messageComponent("nushToggled", commandSender.getName(), - NushModule.enabled ? "Enabling" : "Disabling")); - return null; - } + PlexUtils.broadcastToAdmins(messageComponent("nushToggled", commandSender.getName(), + NushModule.enabled ? "Enabling" : "Disabling")); + return null; + } } diff --git a/src/main/java/dev/plex/nush/handler/Handler.java b/src/main/java/dev/plex/nush/handler/Handler.java index 651d913..e4325c3 100644 --- a/src/main/java/dev/plex/nush/handler/Handler.java +++ b/src/main/java/dev/plex/nush/handler/Handler.java @@ -2,8 +2,7 @@ package dev.plex.nush.handler; import dev.plex.nush.NushModule; -public interface Handler -{ +public interface Handler { - void init(NushModule module); + void init(NushModule module); } diff --git a/src/main/java/dev/plex/nush/handler/impl/ActionHandler.java b/src/main/java/dev/plex/nush/handler/impl/ActionHandler.java index 9add708..d0cfefc 100644 --- a/src/main/java/dev/plex/nush/handler/impl/ActionHandler.java +++ b/src/main/java/dev/plex/nush/handler/impl/ActionHandler.java @@ -12,6 +12,7 @@ import dev.plex.util.minimessage.SafeMiniMessage; import java.util.HashMap; import java.util.Map; import java.util.UUID; +import net.kyori.adventure.audience.Audience; import net.kyori.adventure.identity.Identity; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.TextReplacementConfig; @@ -23,67 +24,58 @@ import net.kyori.adventure.text.minimessage.tag.standard.StandardTags; import org.bukkit.Bukkit; import org.bukkit.entity.Player; -public class ActionHandler implements Handler -{ +public class ActionHandler implements Handler { - public static final Map MAP = new HashMap<>(); - private final static TextReplacementConfig URL_REPLACEMENT_CONFIG = TextReplacementConfig.builder() - .match("(https?|ftp|file)://[-a-zA-Z0-9+&@#/%?=~_|!:,.;]*[-a-zA-Z0-9+&@#/%=~_|]") - .replacement( - (matchResult, builder) -> Component.empty().content(matchResult.group()).clickEvent( - ClickEvent.openUrl(matchResult.group()))).build(); - private static NushModule MODULE; + public static final Map MAP = new HashMap<>(); + private final static TextReplacementConfig URL_REPLACEMENT_CONFIG = TextReplacementConfig.builder() + .match("(https?|ftp|file)://[-a-zA-Z0-9+&@#/%?=~_|!:,.;]*[-a-zA-Z0-9+&@#/%=~_|]") + .replacement( + (matchResult, builder) -> Component.empty().content(matchResult.group()).clickEvent( + ClickEvent.openUrl(matchResult.group()))).build(); + private static NushModule MODULE; - public static void resolve(UUID uuid, NushAction action) - { - Message message = MAP.get(uuid); - if (message == null) - { - return; - } - if (action == NushAction.ACCEPT) - { - for (Player player : Bukkit.getOnlinePlayers()) - { - if (player.getUniqueId() != message.getSender()) - { - player.sendMessage(Identity.identity(message.getSender()), getMessage(message)); - } - } - } - MAP.remove(uuid); - } + public static void resolve(UUID uuid, NushAction action) { + Message message = MAP.get(uuid); + if (message == null) { + return; + } + if (action == NushAction.ACCEPT) { + for (Player player : Bukkit.getOnlinePlayers()) { + if (player.getUniqueId() != message.getSender()) { + player.sendMessage(Identity.identity(message.getSender()), getMessage(message)); + } + } + } + MAP.remove(uuid); + } - public static Component getMessage(Message message) - { - String text = PlexUtils.getTextFromComponent(message.getMessage()); - Plex plex = MODULE.getPlex(); - PlexPlayer plexPlayer = DataUtils.getPlayer(message.getSender()); - Component prefix = plex.getRankManager().getPrefix(plexPlayer); - Component component = Component.empty(); + public static Component getMessage(Message message) { + String text = PlexUtils.getTextFromComponent(message.getMessage()); + Plex plex = MODULE.getPlex(); + PlexPlayer plexPlayer = DataUtils.getPlayer(message.getSender()); + Component prefix = plex.getRankManager().getPrefix(plexPlayer); + Component component = Component.empty(); - if (prefix != null) - { - component = component.append(prefix); - } + if (prefix != null) { + component = component.append(prefix); + } - return component.append(Component.space()).append( - PlexUtils.mmDeserialize(plex.config.getString("chat.name-color", "") + - MiniMessage.builder().tags( - TagResolver.resolver(StandardTags.color(), StandardTags.rainbow(), - StandardTags.decorations(), StandardTags.gradient(), - StandardTags.transition() - )).build().serialize(plexPlayer.getPlayer().displayName()))) - .append(Component.space()) - .append(Component.text("»").color(NamedTextColor.GRAY)).append(Component.space()) - .append( - SafeMiniMessage.mmDeserializeWithoutEvents(text)) - .replaceText(URL_REPLACEMENT_CONFIG); - } + return component.append(Component.space()).append( + PlexUtils.mmDeserialize(plex.config.getString("chat.name-color", "") + + MiniMessage.builder().tags( + TagResolver.resolver(StandardTags.color(), StandardTags.rainbow(), + StandardTags.decorations(), StandardTags.gradient(), + StandardTags.transition() + )).build().serialize(plexPlayer.getPlayer().displayName()))) + .append(Component.space()) + .append(Component.text("»").color(NamedTextColor.GRAY)).append(Component.space()) + .append( + SafeMiniMessage.mmDeserializeWithoutEvents(text)) + .replaceText(URL_REPLACEMENT_CONFIG); + } - @Override - public void init(NushModule module) - { - MODULE = NushModule.getInstance(); - } + @Override + public void init(NushModule module) { + MODULE = NushModule.getInstance(); + } } diff --git a/src/main/java/dev/plex/nush/handler/impl/CommandHandler.java b/src/main/java/dev/plex/nush/handler/impl/CommandHandler.java index d8d5ad3..b439e81 100644 --- a/src/main/java/dev/plex/nush/handler/impl/CommandHandler.java +++ b/src/main/java/dev/plex/nush/handler/impl/CommandHandler.java @@ -4,12 +4,10 @@ import dev.plex.nush.NushModule; import dev.plex.nush.command.impl.NUSHCommand; import dev.plex.nush.handler.Handler; -public class CommandHandler implements Handler -{ +public class CommandHandler implements Handler { - @Override - public void init(NushModule module) - { - module.registerCommand(new NUSHCommand()); - } + @Override + public void init(NushModule module) { + module.registerCommand(new NUSHCommand()); + } } diff --git a/src/main/java/dev/plex/nush/handler/impl/ListenerHandler.java b/src/main/java/dev/plex/nush/handler/impl/ListenerHandler.java index 2208403..16976c4 100644 --- a/src/main/java/dev/plex/nush/handler/impl/ListenerHandler.java +++ b/src/main/java/dev/plex/nush/handler/impl/ListenerHandler.java @@ -5,13 +5,11 @@ import dev.plex.nush.handler.Handler; import dev.plex.nush.listener.impl.ChatListener; import dev.plex.nush.listener.impl.JoinListener; -public class ListenerHandler implements Handler -{ +public class ListenerHandler implements Handler { - @Override - public void init(NushModule module) - { - module.registerListener(new ChatListener()); - module.registerListener(new JoinListener()); - } + @Override + public void init(NushModule module) { + module.registerListener(new ChatListener()); + module.registerListener(new JoinListener()); + } } diff --git a/src/main/java/dev/plex/nush/listener/impl/ChatListener.java b/src/main/java/dev/plex/nush/listener/impl/ChatListener.java index 6d29eb5..cfda211 100644 --- a/src/main/java/dev/plex/nush/listener/impl/ChatListener.java +++ b/src/main/java/dev/plex/nush/listener/impl/ChatListener.java @@ -22,60 +22,52 @@ import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; -public class ChatListener extends PlexListener -{ +public class ChatListener extends PlexListener { - @EventHandler(priority = EventPriority.HIGHEST) - public void onChat(AsyncChatEvent event) - { - if (event.isCancelled()) - { - return; - } - Player player = event.getPlayer(); - Instant firstJoined = Instant.ofEpochMilli(player.getFirstPlayed()); - Instant rightNow = Instant.now(); - long difference = (Duration.between(firstJoined, rightNow).getSeconds() / 60); - if (difference >= 15) - { - PlexLog.debug("{0} has been on the server for {1} minutes, so Nush will skip them.", player.getName(), difference); - return; - } + @EventHandler(priority = EventPriority.HIGHEST) + public void onChat(AsyncChatEvent event) { + if(event.isCancelled()) return; + Player player = event.getPlayer(); + Instant firstJoined = Instant.ofEpochMilli(player.getFirstPlayed()); + Instant rightNow = Instant.now(); + long difference = (Duration.between(firstJoined, rightNow).getSeconds() / 60); + if (difference >= 15) { + PlexLog.debug("{0} has been on the server for {1} minutes, so Nush will skip them.", player.getName(), difference); + return; + } - NushModule module = NushModule.getInstance(); - Plex plex = module.getPlex(); - PlexPlayer plexPlayer = DataUtils.getPlayer(player.getUniqueId()); - RankManager rankManager = plex.getRankManager(); + NushModule module = NushModule.getInstance(); + Plex plex = module.getPlex(); + PlexPlayer plexPlayer = DataUtils.getPlayer(player.getUniqueId()); + RankManager rankManager = plex.getRankManager(); - if (rankManager.isAdmin(plexPlayer)) - { - PlexLog.debug("{0} is an admin so Nush will skip them.", player.getName()); - return; // we needn't process the chat message if they're an admin - } + if (rankManager.isAdmin(plexPlayer)) { + PlexLog.debug("{0} is an admin so Nush will skip them.", player.getName()); + return; // we needn't process the chat message if they're an admin + } - event.setCancelled(true); - UUID key = UUID.randomUUID(); - Message message = new Message(event.getPlayer().getUniqueId(), event.originalMessage()); - ActionHandler.MAP.put(key, message); - Component component = ActionHandler.getMessage(message); + event.setCancelled(true); + UUID key = UUID.randomUUID(); + Message message = new Message(event.getPlayer().getUniqueId(), event.originalMessage()); + ActionHandler.MAP.put(key, message); + Component component = ActionHandler.getMessage(message); - // Send the user the message so they think it got sent - player.sendMessage(component); + // Send the user the message so they think it got sent + player.sendMessage(component); - component = component.append(Component.text("\n")); + component = component.append(Component.text("\n")); - for (NushAction value : NushAction.values()) - { - String command = String.format("/nush work %s %d", key, value.ordinal); - component = component.append( - Component.text(String.format("[%s] ", value.humanReadable)) - .clickEvent(ClickEvent.runCommand(command)) - .hoverEvent( - Component.text(command, NamedTextColor.YELLOW) - ) - ); - } + for (NushAction value : NushAction.values()) { + String command = String.format("/nush work %s %d", key, value.ordinal); + component = component.append( + Component.text(String.format("[%s] ", value.humanReadable)) + .clickEvent(ClickEvent.runCommand(command)) + .hoverEvent( + Component.text(command, NamedTextColor.YELLOW) + ) + ); + } - PlexUtils.broadcastToAdmins(component); - } + PlexUtils.broadcastToAdmins(component); + } } diff --git a/src/main/java/dev/plex/nush/listener/impl/JoinListener.java b/src/main/java/dev/plex/nush/listener/impl/JoinListener.java index d90b732..334d783 100644 --- a/src/main/java/dev/plex/nush/listener/impl/JoinListener.java +++ b/src/main/java/dev/plex/nush/listener/impl/JoinListener.java @@ -10,25 +10,22 @@ import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.player.PlayerJoinEvent; -public class JoinListener extends PlexListener -{ +public class JoinListener extends PlexListener { - @EventHandler - public void onPlayerJoin(PlayerJoinEvent event) - { - Player player = event.getPlayer(); - NushModule module = NushModule.getInstance(); - Plex plex = module.getPlex(); - PlexPlayer plexPlayer = DataUtils.getPlayer(player.getUniqueId()); - RankManager rankManager = plex.getRankManager(); + @EventHandler + public void onPlayerJoin(PlayerJoinEvent event) { + Player player = event.getPlayer(); + NushModule module = NushModule.getInstance(); + Plex plex = module.getPlex(); + PlexPlayer plexPlayer = DataUtils.getPlayer(player.getUniqueId()); + RankManager rankManager = plex.getRankManager(); - if (!rankManager.isAdmin(plexPlayer)) - { - return; // we only want to add admins - } + if (!rankManager.isAdmin(plexPlayer)) { + return; // we only want to add admins + } /*if (ChatListener.work.containsKey()) { }*/ - } + } } diff --git a/src/main/java/dev/plex/nush/util/ReflectionsUtil.java b/src/main/java/dev/plex/nush/util/ReflectionsUtil.java index dfaee89..1e8f941 100644 --- a/src/main/java/dev/plex/nush/util/ReflectionsUtil.java +++ b/src/main/java/dev/plex/nush/util/ReflectionsUtil.java @@ -10,52 +10,42 @@ import java.util.Collections; import java.util.HashSet; import java.util.Set; -public class ReflectionsUtil -{ +public class ReflectionsUtil { - @SuppressWarnings("UnstableApiUsage") - public static Set> getClassesFrom(String packageName) - { - Set> classes = new HashSet<>(); - try - { - ClassPath path = ClassPath.from(Plex.class.getClassLoader()); - ImmutableSet infoSet = path.getTopLevelClasses(packageName); - infoSet.forEach(info -> - { - try - { - Class clazz = Class.forName(info.getName()); - classes.add(clazz); - } - catch (ClassNotFoundException ex) - { - PlexLog.error("Unable to find class " + info.getName() + " in " + packageName); - } - }); - } - catch (IOException ex) - { - PlexLog.error("Something went wrong while fetching classes from " + packageName); - throw new RuntimeException(ex); - } - return Collections.unmodifiableSet(classes); - } + @SuppressWarnings("UnstableApiUsage") + public static Set> getClassesFrom(String packageName) { + Set> classes = new HashSet<>(); + try { + ClassPath path = ClassPath.from(Plex.class.getClassLoader()); + ImmutableSet infoSet = path.getTopLevelClasses(packageName); + infoSet.forEach(info -> + { + try { + Class clazz = Class.forName(info.getName()); + classes.add(clazz); + } catch (ClassNotFoundException ex) { + PlexLog.error("Unable to find class " + info.getName() + " in " + packageName); + } + }); + } catch (IOException ex) { + PlexLog.error("Something went wrong while fetching classes from " + packageName); + throw new RuntimeException(ex); + } + return Collections.unmodifiableSet(classes); + } - @SuppressWarnings("unchecked") - public static Set> getClassesBySubType(String packageName, - Class subType) - { - Set> loadedClasses = getClassesFrom(packageName); - Set> classes = new HashSet<>(); - loadedClasses.forEach(clazz -> - { - if (clazz.getSuperclass() == subType || Arrays.asList(clazz.getInterfaces()) - .contains(subType)) - { - classes.add((Class)clazz); - } - }); - return Collections.unmodifiableSet(classes); - } + @SuppressWarnings("unchecked") + public static Set> getClassesBySubType(String packageName, + Class subType) { + Set> loadedClasses = getClassesFrom(packageName); + Set> classes = new HashSet<>(); + loadedClasses.forEach(clazz -> + { + if (clazz.getSuperclass() == subType || Arrays.asList(clazz.getInterfaces()) + .contains(subType)) { + classes.add((Class) clazz); + } + }); + return Collections.unmodifiableSet(classes); + } } \ No newline at end of file