mirror of
https://github.com/PlayPro/CoreProtect.git
synced 2024-11-28 12:55:34 +01:00
Check that CampfireStartEvent exists before registering
This commit is contained in:
parent
d4997cca60
commit
c7cf035564
@ -3,8 +3,6 @@ package net.coreprotect.listener;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
|
||||
import net.coreprotect.CoreProtect;
|
||||
import net.coreprotect.bukkit.BukkitAdapter;
|
||||
import net.coreprotect.config.ConfigHandler;
|
||||
import net.coreprotect.listener.block.BlockBreakListener;
|
||||
import net.coreprotect.listener.block.BlockBurnListener;
|
||||
import net.coreprotect.listener.block.BlockDispenseListener;
|
||||
@ -86,9 +84,13 @@ public final class ListenerHandler {
|
||||
pluginManager.registerEvents(new BlockPistonListener(), plugin);
|
||||
pluginManager.registerEvents(new BlockPlaceListener(), plugin);
|
||||
pluginManager.registerEvents(new BlockSpreadListener(), plugin);
|
||||
if (ConfigHandler.SERVER_VERSION >= BukkitAdapter.BUKKIT_V1_20) {
|
||||
try {
|
||||
Class.forName("org.bukkit.event.block.CampfireStartEvent"); // Bukkit 1.20+
|
||||
pluginManager.registerEvents(new CampfireStartListener(), plugin);
|
||||
}
|
||||
catch (Exception e) {
|
||||
CampfireStartListener.useCampfireStartEvent = false;
|
||||
}
|
||||
|
||||
// Entity Listeners
|
||||
pluginManager.registerEvents(new CreatureSpawnListener(), plugin);
|
||||
|
@ -15,6 +15,8 @@ import net.coreprotect.utility.Util;
|
||||
|
||||
public final class CampfireStartListener extends Queue implements Listener {
|
||||
|
||||
public static boolean useCampfireStartEvent = true;
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
protected void onCampfireStart(CampfireStartEvent event) {
|
||||
Block block = event.getBlock();
|
||||
|
@ -52,6 +52,7 @@ import net.coreprotect.database.lookup.ChestTransactionLookup;
|
||||
import net.coreprotect.database.lookup.InteractionLookup;
|
||||
import net.coreprotect.database.lookup.SignMessageLookup;
|
||||
import net.coreprotect.language.Phrase;
|
||||
import net.coreprotect.listener.block.CampfireStartListener;
|
||||
import net.coreprotect.model.BlockGroup;
|
||||
import net.coreprotect.paper.PaperAdapter;
|
||||
import net.coreprotect.thread.CacheHandler;
|
||||
@ -640,7 +641,7 @@ public final class PlayerInteractListener extends Queue implements Listener {
|
||||
});
|
||||
*/
|
||||
}
|
||||
else if (type == Material.CAMPFIRE || type == Material.SOUL_CAMPFIRE) {
|
||||
else if ((type == Material.CAMPFIRE || type == Material.SOUL_CAMPFIRE) && CampfireStartListener.useCampfireStartEvent) {
|
||||
ItemStack handItem = null;
|
||||
ItemStack mainHand = player.getInventory().getItemInMainHand();
|
||||
ItemStack offHand = player.getInventory().getItemInOffHand();
|
||||
|
Loading…
Reference in New Issue
Block a user