Skip to content

Commit a0ebf4c

Browse files
authored
feat: allow Mimic custom items in allowedTools (#443)
1 parent cc679d7 commit a0ebf4c

File tree

4 files changed

+35
-1
lines changed

4 files changed

+35
-1
lines changed

modules/SilkSpawners/pom.xml

+6
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,12 @@
103103
</exclusion>
104104
</exclusions>
105105
</dependency>
106+
<dependency>
107+
<groupId>ru.endlesscode.mimic</groupId>
108+
<artifactId>mimic-bukkit-api</artifactId>
109+
<version>0.8.0</version>
110+
<scope>provided</scope>
111+
</dependency>
106112
<dependency>
107113
<groupId>org.bstats</groupId>
108114
<artifactId>bstats-bukkit</artifactId>

modules/SilkSpawners/src/main/java/de/dustplanet/util/SilkUtil.java

+25
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
import lombok.Getter;
5151
import lombok.Setter;
5252
import me.confuser.barapi.BarAPI;
53+
import ru.endlesscode.mimic.Mimic;
5354

5455
/**
5556
* This is the util class where all the magic happens.
@@ -93,6 +94,11 @@ public class SilkUtil {
9394
*/
9495
private WorldGuardPlugin wg;
9596

97+
/**
98+
* Mimic instance, may be null
99+
*/
100+
private Mimic mimic;
101+
96102
/**
97103
* BarAPI usage toggle.
98104
*/
@@ -130,6 +136,7 @@ public SilkUtil(final SilkSpawners instance) {
130136
}
131137

132138
getWorldGuard();
139+
getMimic();
133140
final boolean nmsProviderFound = setupNMSProvider();
134141

135142
if (nmsProviderFound) {
@@ -837,6 +844,10 @@ public boolean isValidItemAndHasSilkTouch(final ItemStack tool) {
837844
toolAllowed = true;
838845
break;
839846
}
847+
if (mimic != null && mimic.getItemsRegistry().isSameItem(tool, allowedTool)) {
848+
toolAllowed = true;
849+
break;
850+
}
840851
}
841852
if (!toolAllowed) {
842853
plugin.getLogger().log(Level.FINE, "Tool not allowed: {0}", tool.getType());
@@ -910,6 +921,20 @@ private void getWorldGuard() {
910921
wg = (WorldGuardPlugin) worldGuard;
911922
}
912923

924+
private void getMimic() {
925+
if (!plugin.getConfig().getBoolean("useMimic", true)) {
926+
plugin.getLogger().info("Mimic support is disabled due to config setting");
927+
return;
928+
}
929+
final Plugin mimicPlugin = plugin.getServer().getPluginManager().getPlugin("Mimic");
930+
if (mimicPlugin == null) {
931+
plugin.getLogger().info("Mimic was not found and support is disabled");
932+
return;
933+
}
934+
mimic = Mimic.getInstance();
935+
plugin.getLogger().info("Mimic was found and support is enabled");
936+
}
937+
913938
/**
914939
* Checks if a player can build here (WorldGuard).
915940
*

modules/SilkSpawners/src/main/resources/config.yml

+3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ permissionExplode: false
99
# Should be checked for WorldGuard build ability to change spawners
1010
useWorldGuard: true
1111

12+
useMimic: true
13+
# Allows you to use Mimic item IDs in allowedTools
14+
1215
# Percentage of dropping a spawner block when TNT or creepers explode
1316
explosionDropChance: 30
1417

modules/SilkSpawners/src/main/resources/plugin.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,5 +50,5 @@ permissions:
5050
silkspawners.help:
5151
description: Allows you to see the help menu
5252
default: true
53-
softdepend: [WorldGuard, BarAPI, Factions]
53+
softdepend: [WorldGuard, BarAPI, Factions, Mimic]
5454
loadbefore: [MergedSpawner, ShopGUIPlus]

0 commit comments

Comments
 (0)