Skip to content

Commit a5a6a43

Browse files
committed
Replace error in console when copper golem listener cannot be registered
Fixes #219
1 parent ea317a3 commit a5a6a43

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<modelVersion>4.0.0</modelVersion>
55
<groupId>nl.rutgerkok</groupId>
66
<artifactId>blocklocker</artifactId>
7-
<version>1.14</version>
7+
<version>1.14.1-SNAPSHOT</version>
88
<packaging>jar</packaging>
99
<name>BlockLocker</name>
1010
<url>https://github.com/rutgerkok/BlockLocker</url>

src/main/java/nl/rutgerkok/blocklocker/impl/BlockLockerPluginImpl.java

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import java.util.function.Consumer;
1212
import java.util.logging.Level;
1313

14+
import nl.rutgerkok.blocklocker.*;
1415
import nl.rutgerkok.blocklocker.impl.event.*;
1516
import org.bukkit.Bukkit;
1617
import org.bukkit.block.Block;
@@ -24,15 +25,6 @@
2425
import com.google.common.base.Charsets;
2526
import com.google.common.base.Preconditions;
2627

27-
import nl.rutgerkok.blocklocker.BlockLockerPlugin;
28-
import nl.rutgerkok.blocklocker.ChestSettings;
29-
import nl.rutgerkok.blocklocker.ProtectionCache;
30-
import nl.rutgerkok.blocklocker.ProfileFactory;
31-
import nl.rutgerkok.blocklocker.ProtectableBlocksSettings;
32-
import nl.rutgerkok.blocklocker.ProtectionFinder;
33-
import nl.rutgerkok.blocklocker.ProtectionUpdater;
34-
import nl.rutgerkok.blocklocker.SignParser;
35-
import nl.rutgerkok.blocklocker.Translator;
3628
import nl.rutgerkok.blocklocker.group.CombinedGroupSystem;
3729
import nl.rutgerkok.blocklocker.group.GroupSystem;
3830
import nl.rutgerkok.blocklocker.impl.blockfinder.BlockFinder;
@@ -246,7 +238,18 @@ private void registerEvents() {
246238
plugins.registerEvents(new BlockDestroyListener(this), this);
247239
plugins.registerEvents(new BlockPlaceListener(this), this);
248240
plugins.registerEvents(new InteractListener(this), this);
249-
plugins.registerEvents(new GolemListener(this), this);
241+
242+
// Copper golem listener is not available on Spigot & older Minecraft versions
243+
try {
244+
Class.forName("io.papermc.paper.event.entity.ItemTransportingEntityValidateTargetEvent");
245+
plugins.registerEvents(new GolemListener(this), this);
246+
} catch (ClassNotFoundException e) {
247+
if (!config.allowDestroyBy(AttackType.GOLEM)) {
248+
getLogger().warning("Failed to register copper golem listener. Paper 1.21.10+ is required for this" +
249+
" to function. Add GOLEM to allowDestroyBy in the config.yml to disable this warning.");
250+
}
251+
}
252+
250253
plugins.registerEvents(new SignChangeListener(this), this);
251254
getCommand(getName().toLowerCase(Locale.ROOT)).setExecutor(new BlockLockerCommand(this));
252255
}

0 commit comments

Comments
 (0)