diff --git a/lib/MobPlugin-1.15.0.jar b/lib/MobPlugin-1.15.0.jar
new file mode 100644
index 0000000..16e5e7f
Binary files /dev/null and b/lib/MobPlugin-1.15.0.jar differ
diff --git a/pom.xml b/pom.xml
index a42b325..bb68d6d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -106,6 +106,13 @@
5.0
provided
+
+ foo.bar
+ mobplugin
+ 1.15.0
+ system
+ ${basedir}/lib/MobPlugin-1.15.0.jar
+
org.json
json
@@ -200,6 +207,17 @@
shade
+
+ false
+
+
+ foo.bar:mobplugin:jar:1.15.0
+
+ *
+
+
+
+
diff --git a/src/main/java/com/larryTheCoder/ASkyBlock.java b/src/main/java/com/larryTheCoder/ASkyBlock.java
index cc446dc..529f4c2 100644
--- a/src/main/java/com/larryTheCoder/ASkyBlock.java
+++ b/src/main/java/com/larryTheCoder/ASkyBlock.java
@@ -39,12 +39,12 @@
import com.larryTheCoder.cache.FastCache;
import com.larryTheCoder.cache.settings.WorldSettings;
import com.larryTheCoder.command.Commands;
-import com.larryTheCoder.database.config.AbstractConfig;
-import com.larryTheCoder.database.config.MySQLConfig;
-import com.larryTheCoder.database.config.SQLiteConfig;
import com.larryTheCoder.database.Database;
import com.larryTheCoder.database.QueryDb;
import com.larryTheCoder.database.QueryInfo;
+import com.larryTheCoder.database.config.AbstractConfig;
+import com.larryTheCoder.database.config.MySQLConfig;
+import com.larryTheCoder.database.config.SQLiteConfig;
import com.larryTheCoder.island.GridManager;
import com.larryTheCoder.island.IslandManager;
import com.larryTheCoder.island.TeleportLogic;
@@ -54,6 +54,7 @@
import com.larryTheCoder.listener.LavaCheck;
import com.larryTheCoder.listener.PlayerEvent;
import com.larryTheCoder.listener.invitation.InvitationHandler;
+import com.larryTheCoder.listener.nms.MobPluginListener;
import com.larryTheCoder.locales.LocaleInstance;
import com.larryTheCoder.locales.LocaleManager;
import com.larryTheCoder.schematic.SchematicHandler;
@@ -221,6 +222,9 @@ private void initIslands() {
pm.registerEvents(new IslandListener(this), this);
pm.registerEvents(new LavaCheck(this), this);
pm.registerEvents(new PlayerEvent(this), this);
+ if (getServer().getPluginManager().getPlugin("MobPlugin") != null) {
+ pm.registerEvents(new MobPluginListener(this), this);
+ }
}
private void loadPermissionNodes() {
diff --git a/src/main/java/com/larryTheCoder/listener/IslandListener.java b/src/main/java/com/larryTheCoder/listener/IslandListener.java
index b03b8cf..e9bc3a4 100644
--- a/src/main/java/com/larryTheCoder/listener/IslandListener.java
+++ b/src/main/java/com/larryTheCoder/listener/IslandListener.java
@@ -27,8 +27,6 @@
package com.larryTheCoder.listener;
import cn.nukkit.Player;
-import cn.nukkit.block.Block;
-import cn.nukkit.block.BlockLava;
import cn.nukkit.entity.Entity;
import cn.nukkit.entity.item.EntityPrimedTNT;
import cn.nukkit.entity.mob.EntityMob;
@@ -43,7 +41,10 @@
import cn.nukkit.event.entity.EntityExplodeEvent;
import cn.nukkit.event.inventory.CraftItemEvent;
import cn.nukkit.event.inventory.InventoryPickupItemEvent;
-import cn.nukkit.event.player.*;
+import cn.nukkit.event.player.PlayerCommandPreprocessEvent;
+import cn.nukkit.event.player.PlayerDropItemEvent;
+import cn.nukkit.event.player.PlayerInteractEvent;
+import cn.nukkit.event.player.PlayerMoveEvent;
import cn.nukkit.utils.TextFormat;
import com.larryTheCoder.ASkyBlock;
import com.larryTheCoder.cache.IslandData;
@@ -158,20 +159,17 @@ public void onPlayerExecuteCommand(PlayerCommandPreprocessEvent event) {
}
}
- @EventHandler(priority = EventPriority.LOW)
+ @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onPlayerHitEvent(EntityDamageEvent e) {
Entity target = e.getEntity();
if (notInWorld(target)) return;
if (e instanceof EntityDamageByEntityEvent) {
- EntityDamageByEntityEvent damage = (EntityDamageByEntityEvent) e;
- Entity cause = damage.getDamager();
-
// Identifier for player mobs attack.
- if (!(cause instanceof Player)) {
- if (cause instanceof EntityAnimal) {
+ if (!(target instanceof Player)) {
+ if (target instanceof EntityAnimal) {
if (actionAllowed(target.getLocation(), SettingsFlag.HURT_MOBS)) return;
- } else if (cause instanceof EntityMob) {
+ } else if (target instanceof EntityMob) {
if (actionAllowed(target.getLocation(), SettingsFlag.HURT_MONSTERS)) return;
}
} else {
diff --git a/src/main/java/com/larryTheCoder/listener/nms/MobPluginListener.java b/src/main/java/com/larryTheCoder/listener/nms/MobPluginListener.java
new file mode 100644
index 0000000..151d1ec
--- /dev/null
+++ b/src/main/java/com/larryTheCoder/listener/nms/MobPluginListener.java
@@ -0,0 +1,87 @@
+/*
+ * Adapted from the Wizardry License
+ *
+ * Copyright (c) 2016-2020 larryTheCoder and contributors
+ *
+ * Permission is hereby granted to any persons and/or organizations
+ * using this software to copy, modify, merge, publish, and distribute it.
+ * Said persons and/or organizations are not allowed to use the software or
+ * any derivatives of the work for commercial use or any other means to generate
+ * income, nor are they allowed to claim this software as their own.
+ *
+ * The persons and/or organizations are also disallowed from sub-licensing
+ * and/or trademarking this software without explicit permission from larryTheCoder.
+ *
+ * Any persons and/or organizations using this software must disclose their
+ * source code and have it publicly available, include this license,
+ * provide sufficient credit to the original authors of the project (IE: larryTheCoder),
+ * as well as provide a link to the original project.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
+ * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR
+ * PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+package com.larryTheCoder.listener.nms;
+
+import cn.nukkit.Player;
+import cn.nukkit.entity.Entity;
+import cn.nukkit.entity.mob.EntityMob;
+import cn.nukkit.entity.passive.EntityAnimal;
+import cn.nukkit.event.EventHandler;
+import cn.nukkit.event.EventPriority;
+import cn.nukkit.event.Listener;
+import cn.nukkit.event.entity.EntityDamageByEntityEvent;
+import cn.nukkit.event.entity.EntityDamageEvent;
+import com.larryTheCoder.ASkyBlock;
+import com.larryTheCoder.listener.Action;
+import com.larryTheCoder.utils.SettingsFlag;
+import lombok.extern.log4j.Log4j2;
+import nukkitcoders.mobplugin.entities.animal.Animal;
+import nukkitcoders.mobplugin.entities.monster.Monster;
+
+@Log4j2
+public class MobPluginListener extends Action implements Listener {
+
+ public MobPluginListener(ASkyBlock plugin) {
+ super(plugin);
+
+ log.debug("Using MobPlugin");
+ }
+
+ @EventHandler(priority = EventPriority.LOWEST)
+ public void onPlayerHitEvent(EntityDamageEvent e) {
+ log.debug("DEBUG: " + e.getEventName());
+ log.debug("DEBUG: NMS MobPlugin notation.");
+
+ Entity target = e.getEntity();
+
+ if (notInWorld(target)) return;
+ if (e instanceof EntityDamageByEntityEvent) {
+ // Identifier for player mobs attack.
+ if (!(target instanceof Player)) {
+ log.debug("Target is not a player.");
+
+ if (target instanceof Animal) {
+ log.debug("Target is not an animal.");
+
+ if (actionAllowed(target.getLocation(), SettingsFlag.HURT_MOBS)) return;
+ } else if (target instanceof Monster) {
+ log.debug("Target is not a monster.");
+
+ if (actionAllowed(target.getLocation(), SettingsFlag.HURT_MONSTERS)) return;
+ }
+ } else {
+ log.debug("Target is a player");
+ if (actionAllowed(target.getLocation(), SettingsFlag.PVP)) return;
+ }
+
+ log.debug("Target cancelled.");
+
+ e.setCancelled();
+ }
+ }
+}
diff --git a/src/main/java/com/larryTheCoder/task/LevelCalcTask.java b/src/main/java/com/larryTheCoder/task/LevelCalcTask.java
index f2457f5..c80c605 100644
--- a/src/main/java/com/larryTheCoder/task/LevelCalcTask.java
+++ b/src/main/java/com/larryTheCoder/task/LevelCalcTask.java
@@ -27,7 +27,6 @@
package com.larryTheCoder.task;
-import cn.nukkit.Player;
import cn.nukkit.Server;
import cn.nukkit.block.Block;
import cn.nukkit.level.Level;
diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml
index 260c62a..70e0f95 100644
--- a/src/main/resources/plugin.yml
+++ b/src/main/resources/plugin.yml
@@ -18,6 +18,7 @@ softdepend:
- EconomyAPI
- LuckPerms
- DbLib
+ - MobPlugin
description: "Advanced minecraft PE SkyBlock plugin!"