Skip to content

Commit

Permalink
Merge pull request #8 from 4drian3d/check
Browse files Browse the repository at this point in the history
Added check for enabled compatible plugins
  • Loading branch information
linsaftw authored Jul 8, 2021
2 parents facb5c0 + d5106f0 commit b937054
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/dev/_2lstudios/viarewindpotions/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.comphenix.protocol.ProtocolLibrary;
import com.comphenix.protocol.ProtocolManager;

import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;

Expand All @@ -19,8 +20,19 @@ public void onEnable() {
final PluginManager pluginManager = getServer().getPluginManager();
final ProtocolManager protocolManager = ProtocolLibrary.getProtocolManager();

if (pluginManager.getPlugin("ViaRewind-Legacy-Support") == null || !configurationUtil.getConfiguration("%datafolder%/ViaRewind-Legacy-Support/config.yml").getBoolean("area-effect-cloud-particles"))
if (pluginManager.isPluginEnabled("ProtocolSupport") || pluginManager.isPluginEnabled("ViaRewind")) {
getLogger().info("ViaRewind/ProtocolSupport detected, enabling integration.");
} else if (pluginManager.isPluginEnabled("ViaBackwards")) {
getLogger().warning("ViaBackwards detected. In order to make ViaPotions work correctly, it is required that you have ViaRewind installed.");
} else {
getLogger().severe("No compatible plugins have been detected, disabling the plugin.");
getLogger().severe("In order to make ViaPotions functional, ViaRewind or ProtocolSupport must be installed.");
pluginManager.disablePlugin(this);
}

if (pluginManager.getPlugin("ViaRewind-Legacy-Support") == null || !configurationUtil.getConfiguration("%datafolder%/ViaRewind-Legacy-Support/config.yml").getBoolean("area-effect-cloud-particles")) {
pluginManager.registerEvents(new AreaEffectCloudListener(this, versionUtil), this);
}

protocolManager.addPacketListener(new SpawnEntityListener(this, versionUtil));
protocolManager.addPacketListener(new WorldEventAdapter(this, versionUtil));
Expand Down

0 comments on commit b937054

Please sign in to comment.