Compare commits

...

5 Commits
1.0.0 ... 1.0.3

Author SHA1 Message Date
Auxilor
5bca33a9f5 Added protected getter for BaseConfig and updated to 1.0.3 2021-01-02 17:55:22 +00:00
Auxilor
1196fe8004 Updated to 1.0.2 2021-01-01 16:54:05 +00:00
Auxilor
98ae416fa7 Reduced loaded integration verbosity 2021-01-01 16:53:32 +00:00
Auxilor
9726ecefc8 Updated to 1.0.1 2021-01-01 15:27:40 +00:00
Auxilor
c4160d0cc5 Fixed PacketAdapter loading with no protocollib depend 2021-01-01 15:24:32 +00:00
3 changed files with 38 additions and 22 deletions

View File

@@ -98,5 +98,5 @@ build.dependsOn publishToMavenLocal
group = 'com.willfp' group = 'com.willfp'
archivesBaseName = project.name archivesBaseName = project.name
version = '1.0.0' version = '1.0.3'
java.sourceCompatibility = JavaVersion.VERSION_1_8 java.sourceCompatibility = JavaVersion.VERSION_1_8

View File

@@ -28,6 +28,7 @@ public abstract class BaseConfig extends PluginDependent implements ValueGetter
/** /**
* The physical config file, as stored on disk. * The physical config file, as stored on disk.
*/ */
@Getter(AccessLevel.PROTECTED)
private final File configFile; private final File configFile;
/** /**

View File

@@ -1,5 +1,6 @@
package com.willfp.eco.util.plugin; package com.willfp.eco.util.plugin;
import com.willfp.eco.util.ClassUtils;
import com.willfp.eco.util.arrows.ArrowDataListener; import com.willfp.eco.util.arrows.ArrowDataListener;
import com.willfp.eco.util.bukkit.events.EcoEventManager; import com.willfp.eco.util.bukkit.events.EcoEventManager;
import com.willfp.eco.util.bukkit.events.EventManager; import com.willfp.eco.util.bukkit.events.EventManager;
@@ -50,6 +51,7 @@ import org.jetbrains.annotations.NotNull;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@@ -85,6 +87,18 @@ public abstract class AbstractEcoPlugin extends JavaPlugin {
@Getter @Getter
private final String proxyPackage; private final String proxyPackage;
/**
* The color of the plugin, used in messages.
*/
@Getter
private final String color;
/**
* Loaded integrations.
*/
@Getter
private final Set<String> loadedIntegrations = new HashSet<>();
/** /**
* Set of external plugin integrations. * Set of external plugin integrations.
*/ */
@@ -158,15 +172,18 @@ public abstract class AbstractEcoPlugin extends JavaPlugin {
* @param resourceId The spigot resource ID for the plugin. * @param resourceId The spigot resource ID for the plugin.
* @param bStatsId The bStats resource ID for the plugin. * @param bStatsId The bStats resource ID for the plugin.
* @param proxyPackage The package where proxy implementations are stored. * @param proxyPackage The package where proxy implementations are stored.
* @param color The color of the plugin (used in messages, such as &a, &b)
*/ */
protected AbstractEcoPlugin(@NotNull final String pluginName, protected AbstractEcoPlugin(@NotNull final String pluginName,
final int resourceId, final int resourceId,
final int bStatsId, final int bStatsId,
@NotNull final String proxyPackage) { @NotNull final String proxyPackage,
@NotNull final String color) {
this.pluginName = pluginName; this.pluginName = pluginName;
this.resourceId = resourceId; this.resourceId = resourceId;
this.bStatsId = bStatsId; this.bStatsId = bStatsId;
this.proxyPackage = proxyPackage; this.proxyPackage = proxyPackage;
this.color = color;
this.log = new EcoLogger(this); this.log = new EcoLogger(this);
this.scheduler = new EcoScheduler(this); this.scheduler = new EcoScheduler(this);
@@ -186,10 +203,7 @@ public abstract class AbstractEcoPlugin extends JavaPlugin {
super.onLoad(); super.onLoad();
this.getLog().info("=========================================="); this.getLog().info("==========================================");
this.getLog().info(""); this.getLog().info("Loading " + this.color + this.pluginName);
this.getLog().info("Loading &a" + this.pluginName);
this.getLog().info("Made by &aAuxilor&f - willfp.com");
this.getLog().info("");
this.getLog().info("=========================================="); this.getLog().info("==========================================");
this.getEventManager().registerListener(new ArrowDataListener(this)); this.getEventManager().registerListener(new ArrowDataListener(this));
@@ -218,25 +232,24 @@ public abstract class AbstractEcoPlugin extends JavaPlugin {
Set<String> enabledPlugins = Arrays.stream(Bukkit.getPluginManager().getPlugins()).map(Plugin::getName).collect(Collectors.toSet()); Set<String> enabledPlugins = Arrays.stream(Bukkit.getPluginManager().getPlugins()).map(Plugin::getName).collect(Collectors.toSet());
this.getDefaultIntegrations().forEach((integrationLoader -> { this.getDefaultIntegrations().forEach((integrationLoader -> {
StringBuilder infoBuilder = new StringBuilder();
infoBuilder.append(integrationLoader.getPluginName()).append(": ");
if (enabledPlugins.contains(integrationLoader.getPluginName())) { if (enabledPlugins.contains(integrationLoader.getPluginName())) {
this.loadedIntegrations.add(integrationLoader.getPluginName());
integrationLoader.load(); integrationLoader.load();
infoBuilder.append("&aENABLED");
} else {
infoBuilder.append("&9DISABLED");
} }
this.getLog().info(infoBuilder.toString());
})); }));
this.getLog().info("Loaded integrations: " + String.join(", ", this.getLoadedIntegrations()));
this.getLog().info(""); this.getLog().info("");
Prerequisite.update(); Prerequisite.update();
this.getPacketAdapters().forEach(abstractPacketAdapter -> {
if (!abstractPacketAdapter.isPostLoad()) { if (ClassUtils.exists("com.comphenix.protocol.events.PacketAdapter")) {
abstractPacketAdapter.register(); this.getPacketAdapters().forEach(abstractPacketAdapter -> {
} if (!abstractPacketAdapter.isPostLoad()) {
}); abstractPacketAdapter.register();
}
});
}
updatableClasses.add(Configs.class); updatableClasses.add(Configs.class);
@@ -283,11 +296,13 @@ public abstract class AbstractEcoPlugin extends JavaPlugin {
* Default code to be executed after the server is up. * Default code to be executed after the server is up.
*/ */
public final void afterLoad() { public final void afterLoad() {
this.getPacketAdapters().forEach(abstractPacketAdapter -> { if (ClassUtils.exists("com.comphenix.protocol.events.PacketAdapter")) {
if (abstractPacketAdapter.isPostLoad()) { this.getPacketAdapters().forEach(abstractPacketAdapter -> {
abstractPacketAdapter.register(); if (abstractPacketAdapter.isPostLoad()) {
} abstractPacketAdapter.register();
}); }
});
}
if (!Prerequisite.HAS_PAPER.isMet()) { if (!Prerequisite.HAS_PAPER.isMet()) {
this.getLog().error(""); this.getLog().error("");