1.1.3
## Fixed - Skeleton not dropping equipment - Skeleton had a chance of releasing with equipment.
This commit is contained in:
1 parent
6962a755f4
commit
3b3f976a35
1 file changed
+24
-5
+24
-5
@@ -3,8 +3,9 @@ package com.rsscripting.mobcage.description.descriptor;
|
||||
import com.rsscripting.mobcage.description.CaptureResult;
|
||||
import com.rsscripting.mobcage.description.MobAttribute;
|
||||
import com.rsscripting.mobcage.util.MobHealthUtil;
|
||||
import com.rsscripting.mobcage.MobCage;
|
||||
import com.rsscripting.mobcage.util.MobEquipmentUtil;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
@@ -24,7 +25,19 @@ public class SkeletonDescriptor implements MobDescriptor {
|
||||
@Override
|
||||
public CaptureResult beforeCapture(LivingEntity entity, Player player) {
|
||||
|
||||
return MobHealthUtil.validateFullHealth(entity);
|
||||
CaptureResult result = MobHealthUtil.validateFullHealth(entity);
|
||||
|
||||
if (!result.isAllowed()) {
|
||||
return result;
|
||||
}
|
||||
|
||||
MobEquipmentUtil.handleEquipmentOnCapture(
|
||||
MobCage.getInstance(),
|
||||
entity,
|
||||
player
|
||||
);
|
||||
|
||||
return CaptureResult.allowed();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -40,12 +53,18 @@ public class SkeletonDescriptor implements MobDescriptor {
|
||||
@Override
|
||||
public void release(Location location, List<Component> lore) {
|
||||
|
||||
PlainTextComponentSerializer plain =
|
||||
PlainTextComponentSerializer.plainText();
|
||||
|
||||
Skeleton skeleton = (Skeleton) location.getWorld().spawnEntity(
|
||||
location,
|
||||
EntityType.SKELETON
|
||||
);
|
||||
|
||||
MobCage.getInstance().getServer().getScheduler().runTask(
|
||||
MobCage.getInstance(),
|
||||
() -> {
|
||||
if (skeleton.getEquipment() != null) {
|
||||
skeleton.getEquipment().clear();
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user