1.1.3
## Added - Goat - Skeleton
This commit is contained in:
1 parent
14d3e1a0a6
commit
6962a755f4
5 files changed
+137
-1
No files matched your search
@@ -0,0 +1,77 @@
|
||||
package com.rsscripting.mobcage.description.descriptor;
|
||||
|
||||
import com.rsscripting.mobcage.description.CaptureResult;
|
||||
import com.rsscripting.mobcage.description.MobAttribute;
|
||||
import com.rsscripting.mobcage.util.MobAgeUtil;
|
||||
import com.rsscripting.mobcage.util.MobHealthUtil;
|
||||
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.Goat;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class GoatDescriptor implements MobDescriptor {
|
||||
|
||||
@Override
|
||||
public boolean supports(LivingEntity entity) {
|
||||
return entity instanceof Goat;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CaptureResult beforeCapture(LivingEntity entity, Player player) {
|
||||
|
||||
CaptureResult result = MobHealthUtil.validateFullHealth(entity);
|
||||
|
||||
if (!result.isAllowed()) {
|
||||
return result;
|
||||
}
|
||||
|
||||
MobAgeUtil.normalize(entity);
|
||||
|
||||
return CaptureResult.allowed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName(LivingEntity entity) {
|
||||
return MobAgeUtil.getAgePrefix(entity) + "Goat";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MobAttribute> getAttributes(LivingEntity entity) {
|
||||
return List.of();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void release(Location location, List<Component> lore) {
|
||||
|
||||
PlainTextComponentSerializer plain =
|
||||
PlainTextComponentSerializer.plainText();
|
||||
|
||||
boolean baby = false;
|
||||
|
||||
for (int i = 0; i < lore.size(); i++) {
|
||||
|
||||
String line = plain.serialize(lore.get(i));
|
||||
|
||||
if (line.equals("Contains:") && i + 1 < lore.size()) {
|
||||
baby = plain.serialize(lore.get(i + 1))
|
||||
.equals("Baby Goat");
|
||||
}
|
||||
}
|
||||
|
||||
Goat goat = (Goat) location.getWorld().spawnEntity(
|
||||
location,
|
||||
EntityType.GOAT
|
||||
);
|
||||
|
||||
if (baby) {
|
||||
goat.setBaby();
|
||||
} else {
|
||||
goat.setAdult();
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
@@ -15,11 +15,13 @@ public final class MobDescriptorRegistry {
|
||||
new CowDescriptor(),
|
||||
new DonkeyDescriptor(),
|
||||
new FrogDescriptor(),
|
||||
new GoatDescriptor(),
|
||||
new HorseDescriptor(),
|
||||
new ParrotDescriptor(),
|
||||
new PigDescriptor(),
|
||||
new RabbitDescriptor(),
|
||||
new SheepDescriptor(),
|
||||
new SkeletonDescriptor(),
|
||||
new SpiderDescriptor(),
|
||||
new VillagerDescriptor(),
|
||||
new WolfDescriptor(),
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
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 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;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Skeleton;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class SkeletonDescriptor implements MobDescriptor {
|
||||
|
||||
@Override
|
||||
public boolean supports(LivingEntity entity) {
|
||||
return entity instanceof Skeleton;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CaptureResult beforeCapture(LivingEntity entity, Player player) {
|
||||
|
||||
return MobHealthUtil.validateFullHealth(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName(LivingEntity entity) {
|
||||
return "Skeleton";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MobAttribute> getAttributes(LivingEntity entity) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void release(Location location, List<Component> lore) {
|
||||
|
||||
PlainTextComponentSerializer plain =
|
||||
PlainTextComponentSerializer.plainText();
|
||||
|
||||
Skeleton skeleton = (Skeleton) location.getWorld().spawnEntity(
|
||||
location,
|
||||
EntityType.SKELETON
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -85,6 +85,9 @@ public class MobReleaseListener implements Listener {
|
||||
case "Frog", "Baby Frog" ->
|
||||
new FrogDescriptor().release(location, lore);
|
||||
|
||||
case "Goat", "Baby Goat" ->
|
||||
new GoatDescriptor().release(location, lore);
|
||||
|
||||
case "Horse", "Baby Horse" ->
|
||||
new HorseDescriptor().release(location, lore);
|
||||
|
||||
@@ -100,6 +103,9 @@ public class MobReleaseListener implements Listener {
|
||||
case "Sheep", "Baby Sheep" ->
|
||||
new SheepDescriptor().release(location, lore);
|
||||
|
||||
case "Skeleton", "Baby Skeleton" ->
|
||||
new SkeletonDescriptor().release(location, lore);
|
||||
|
||||
case "Spider" ->
|
||||
new SpiderDescriptor().release(location, lore);
|
||||
|
||||
|
||||
Reference in new issue
Block a user