Feel free to share this code with the Vulcan dev so they can identify if there is any issue.
package dev.lone.itemsadder.Core.OtherPlugins.vulcan;
import dev.lone.itemsadder.Core.OtherPlugins.RetPar;
import me.frep.vulcan.api.VulcanAPI;
import me.frep.vulcan.api.check.Check;
import me.frep.vulcan.api.event.VulcanFlagEvent;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.plugin.Plugin;
import java.util.function.Consumer;
@SuppressWarnings("FieldCanBeLocal")
public class VulcanHook implements Listener
{
private final RetPar<Player, Boolean> isPlayerProtected;
private final Consumer<String> msg;
public static void register(Plugin plugin, RetPar<Player, Boolean> isPlayerProtected, Consumer<String> msg)
{
new VulcanHook(plugin, isPlayerProtected, msg);
}
VulcanHook(Plugin plugin, RetPar<Player, Boolean> isPlayerProtected, Consumer<String> msg)
{
this.isPlayerProtected = isPlayerProtected;
this.msg = msg;
try
{
if(VulcanAPI.Factory.getApi().getEnabledChecks().containsKey("BadPacketsV"))
{
Bukkit.getPluginManager().registerEvents(this, plugin);
FileConfiguration vulcan = Bukkit.getPluginManager().getPlugin("Vulcan").getConfig();
if(!(vulcan.getBoolean("settings.enable-api") || vulcan.getBoolean("enable-api")))
{
msg.accept("Please set 'enable-api: true' in Vulcan anticheat config.yml in order to enable compatibility and run '/vulcan reload'.");
}
}
}
catch (Throwable ex)
{
msg.accept("Failed to check Vulcan anticheat compatibility");
ex.printStackTrace();
}
}
@EventHandler(priority = EventPriority.MONITOR)
private void onVulcanFlag(VulcanFlagEvent e)
{
Check check = e.getCheck();
if(check.getName().equals("badpackets") && check.getType() == 'v')
{
if(isPlayerProtected.call(e.getPlayer()))
e.setCancelled(true);
}
}
}