diff --git a/pom.xml b/pom.xml
index 7f22112..263d4ef 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
in.arcadelabs
LabAide
- 2.2
+ 2.3
jar
LabAide
@@ -144,7 +144,7 @@
dev.dejvokep
boosted-yaml
- 1.2
+ 1.3
-
\ No newline at end of file
+
diff --git a/src/main/java/in/arcadelabs/labaide/LabAide.java b/src/main/java/in/arcadelabs/labaide/LabAide.java
index 4ab2332..518a0d1 100644
--- a/src/main/java/in/arcadelabs/labaide/LabAide.java
+++ b/src/main/java/in/arcadelabs/labaide/LabAide.java
@@ -24,7 +24,6 @@
import lombok.SneakyThrows;
import net.kyori.adventure.text.minimessage.MiniMessage;
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
-import org.bukkit.Bukkit;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;
@@ -41,6 +40,7 @@ public class LabAide extends JavaPlugin {
private final MiniMessage miniMessage = MiniMessage.builder().build();
private final List dependants = new ArrayList<>();
private BStats metrics;
+ private LabAideHooked hooked;
public static Logger Logger() {
return logger;
@@ -55,26 +55,12 @@ public void onEnable() {
MiniMessage.miniMessage().deserialize(
"⌬ "),
null, null);
+ hooked = new LabAideHooked(logger);
logger.log(Logger.Level.INFO, MiniMessage.miniMessage().deserialize(
"" +
"LabAide up and functional!" +
""));
- final List serverPlugins = List.of(Bukkit.getPluginManager().getPlugins());
- for (final Plugin plugin : serverPlugins) {
- if (plugin.getDescription().getDepend().contains("LabAide")
- || plugin.getDescription().getSoftDepend().contains("LabAide")) dependants.add(plugin);
- }
- if (!dependants.isEmpty()) {
- final String pluralOrNot = dependants.size() > 1 ?
- "Hooked into " + dependants.size() + " plugins.\n Dependants: "
- + dependants.toString().substring(1, dependants.toString().length() - 1) :
- "Hooked into " + dependants.get(0);
- logger.log(Logger.Level.INFO, MiniMessage.miniMessage().deserialize(
- "" + pluralOrNot + ""));
- } else logger.log(Logger.Level.INFO, MiniMessage.miniMessage().deserialize(
- "No pluginspartners wanna hook with me," +
- " guess you and me are same afterall."));
}
@Override
@@ -82,4 +68,4 @@ public void onDisable() {
logger.log(Logger.Level.INFO, MiniMessage.miniMessage().deserialize(
"Adios..."));
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/in/arcadelabs/labaide/LabAideHooked.java b/src/main/java/in/arcadelabs/labaide/LabAideHooked.java
new file mode 100644
index 0000000..2eb99c9
--- /dev/null
+++ b/src/main/java/in/arcadelabs/labaide/LabAideHooked.java
@@ -0,0 +1,70 @@
+/*
+ * LabAide - Common utility library for our products.
+ * Copyright (C) 2022 ArcadeLabs Production.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package in.arcadelabs.labaide;
+
+import in.arcadelabs.labaide.logger.Logger;
+import net.kyori.adventure.text.minimessage.MiniMessage;
+import org.bukkit.Bukkit;
+import org.bukkit.plugin.Plugin;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class LabAideHooked {
+
+ private final List dependants = new ArrayList<>();
+
+ public LabAideHooked(final Logger logger) {
+
+ final Plugin[] serverPlugins = Bukkit.getPluginManager().getPlugins();
+ for (final Plugin plugin : serverPlugins) {
+ if (plugin.isEnabled()) {
+ if (plugin.getDescription().getDepend().contains("LabAide")
+ || plugin.getDescription().getSoftDepend().contains("LabAide")) dependants.add(plugin);
+ }
+ }
+ if (!dependants.isEmpty()) {
+ final String pluralOrNot = dependants.size() > 1 ?
+ "Hooked into " + dependants.size() + " plugins.\n Dependants: "
+ + getPluginList() :
+ "Hooked into " + dependants.get(0);
+ logger.log(Logger.Level.INFO, MiniMessage.miniMessage().deserialize(
+ "" + pluralOrNot + ""));
+ } else logger.log(Logger.Level.INFO, MiniMessage.miniMessage().deserialize(
+ "No one plugins wanna hook with me," +
+ " guess you and me are same afterall."));
+ }
+
+ private String getPluginList() {
+ StringBuilder pluginList = new StringBuilder();
+ Plugin[] plugins = Bukkit.getPluginManager().getPlugins();
+
+ for (Plugin plugin : plugins) {
+ if (pluginList.length() > 0) {
+ pluginList.append("");
+ pluginList.append(", ");
+ }
+ if (plugin.isEnabled()) {
+ if (plugin.getDescription().getDepend().contains("LabAide")
+ || plugin.getDescription().getSoftDepend().contains("LabAide")) dependants.add(plugin);
+ }
+ }
+ return pluginList.toString();
+ }
+}