Skip to content

Commit adab889

Browse files
committed
MythicMobs Support
1 parent b7c24ff commit adab889

File tree

5 files changed

+99
-4
lines changed

5 files changed

+99
-4
lines changed

pom.xml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>us.thezircon.play</groupId>
88
<artifactId>AutoPickup</artifactId>
9-
<version>1.4.0-SNAPSHOT</version>
9+
<version>1.4.1-SNAPSHOT</version>
1010
<packaging>jar</packaging>
1111

1212
<name>AutoPickup</name>
@@ -71,6 +71,12 @@
7171
<id>placeholderapi</id>
7272
<url>https://repo.extendedclip.com/content/repositories/placeholderapi/</url>
7373
</repository>
74+
<repository>
75+
<id>nexus</id>
76+
<name>Lumine Releases</name>
77+
<url>https://mvn.lumine.io/repository/maven-public/</url>
78+
</repository>
79+
7480
</repositories>
7581

7682
<dependencies>
@@ -98,5 +104,11 @@
98104
<version>2.10.9</version>
99105
<scope>provided</scope>
100106
</dependency>
107+
<dependency>
108+
<groupId>io.lumine</groupId>
109+
<artifactId>Mythic-Dist</artifactId>
110+
<version>5.2.0</version>
111+
<scope>provided</scope>
112+
</dependency>
101113
</dependencies>
102114
</project>

src/main/java/us/thezircon/play/autopickup/AutoPickup.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ public final class AutoPickup extends JavaPlugin {
3636
public static boolean usingQuickShop = false; //QuickShop - Ghost_chu (reremake)
3737
public static boolean usingEpicFurnaces = false; //EpicFurnaces - Songoda
3838
public static boolean usingWildChests = false; // WildChests - BG Development
39+
public static boolean usingMythicMobs = false; // MythicMobs
3940

4041
public static boolean usingPFHoppers = false; // Play.PeacefulFarms.Net
4142
public static boolean usingPFMoreHoppers = false; // Patch for PF
@@ -99,6 +100,11 @@ public void onEnable() {
99100
usingPlaceholderAPI = true;
100101
}
101102

103+
// MythicMobs
104+
if ((getServer().getPluginManager().getPlugin("MythicMobs") != null)) {
105+
usingMythicMobs = true;
106+
}
107+
102108
// Peaceful Farms - Hoppers Patch
103109
// PFHoppers
104110
if ((getServer().getPluginManager().getPlugin("PFHoppers") != null)) {
@@ -120,6 +126,10 @@ public void onEnable() {
120126
getServer().getPluginManager().registerEvents(new PlayerDropItemEventListener(), this);
121127
getServer().getPluginManager().registerEvents(new ItemSpawnEventListener(), this);
122128

129+
if (usingMythicMobs) {
130+
getServer().getPluginManager().registerEvents(new MythicMobListener(), this);
131+
}
132+
123133
// Commands
124134
getCommand("autopickup").setExecutor(new Auto());
125135
getCommand("autodrops").setExecutor(new AutoDrops());
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
package us.thezircon.play.autopickup.listeners;
2+
3+
import io.lumine.mythic.bukkit.events.MythicMobDeathEvent;
4+
import org.bukkit.Location;
5+
import org.bukkit.entity.EntityType;
6+
import org.bukkit.entity.LivingEntity;
7+
import org.bukkit.entity.Player;
8+
import org.bukkit.event.EventHandler;
9+
import org.bukkit.event.Listener;
10+
import org.bukkit.inventory.ItemStack;
11+
import us.thezircon.play.autopickup.AutoPickup;
12+
13+
import java.util.HashMap;
14+
import java.util.Iterator;
15+
import java.util.List;
16+
17+
import static us.thezircon.play.autopickup.listeners.BlockBreakEventListener.mend;
18+
19+
public class MythicMobListener implements Listener {
20+
21+
private static final AutoPickup PLUGIN = AutoPickup.getPlugin(AutoPickup.class);
22+
23+
@EventHandler
24+
public void onDeath(MythicMobDeathEvent e) {
25+
26+
if (e.getKiller()==null) {
27+
return;
28+
}
29+
30+
Player player;
31+
if (e.getKiller() instanceof Player) {
32+
player = (Player) e.getKiller();
33+
} else {
34+
return;
35+
}
36+
37+
boolean doFullInvMSG = PLUGIN.getConfig().getBoolean("doFullInvMSG");
38+
39+
Location loc = e.getKiller().getLocation();
40+
if (AutoPickup.worldsBlacklist!=null && AutoPickup.worldsBlacklist.contains(loc.getWorld().getName())) {
41+
return;
42+
}
43+
44+
if (PLUGIN.getBlacklistConf().contains("BlacklistedEntities", true)) {
45+
boolean doBlacklist = PLUGIN.getBlacklistConf().getBoolean("doBlacklistedEntities");
46+
List<String> blacklist = PLUGIN.getBlacklistConf().getStringList("BlacklistedEntities");
47+
48+
if (doBlacklist && blacklist.contains(e.getMobType().toString())) {
49+
return;
50+
}
51+
}
52+
53+
if (PLUGIN.autopickup_list_mobs.contains(player)) {
54+
// Drops
55+
Iterator<ItemStack> iter = e.getDrops().iterator();
56+
while (iter.hasNext()) {
57+
ItemStack drops = iter.next();
58+
HashMap<Integer, ItemStack> leftOver = player.getInventory().addItem(drops);
59+
iter.remove();
60+
if (leftOver.keySet().size()>0) {
61+
for (ItemStack item : leftOver.values()) {
62+
player.getWorld().dropItemNaturally(loc, item);
63+
}
64+
if (doFullInvMSG) {
65+
player.sendMessage(PLUGIN.getMsg().getPrefix() + " " + PLUGIN.getMsg().getFullInventory());
66+
}
67+
}
68+
}
69+
e.getDrops().clear();
70+
}
71+
}
72+
73+
}

src/main/resources/plugin.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ authors: [BUTTERFIELD8]
66
description: Automatically pickup broken blocks.
77
website: https://discord.gg/ncHH4FP
88
api-version: 1.13
9-
softdepend: [BentoBox, LockettePro, UpgradeableHoppers, PlaceholderAPI, Jobs]
9+
softdepend: [BentoBox, LockettePro, UpgradeableHoppers, PlaceholderAPI, Jobs, MythicMobs]
1010
commands:
1111
autopickup:
1212
description: Toggles the ability to automaticly pickup blocks when you mine them.

target/classes/plugin.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
name: AutoPickup
2-
version: 1.4.0-SNAPSHOT
2+
version: 1.4.1-SNAPSHOT
33
main: us.thezircon.play.autopickup.AutoPickup
44
prefix: AutoPickup
55
authors: [BUTTERFIELD8]
66
description: Automatically pickup broken blocks.
77
website: https://discord.gg/ncHH4FP
88
api-version: 1.13
9-
softdepend: [BentoBox, LockettePro, UpgradeableHoppers, PlaceholderAPI, Jobs]
9+
softdepend: [BentoBox, LockettePro, UpgradeableHoppers, PlaceholderAPI, Jobs, MythicMobs]
1010
commands:
1111
autopickup:
1212
description: Toggles the ability to automaticly pickup blocks when you mine them.

0 commit comments

Comments
 (0)