1.1.0
26.3 Verified
This commit is contained in:
1 parent
3c31fd05b7
commit
14d3e1a0a6
5 files changed
+113
-1
No files matched your search
+1
-1
@@ -5,7 +5,7 @@ plugins {
|
||||
}
|
||||
|
||||
group = "com.rsscripting"
|
||||
version = "1.0.4"
|
||||
version = "1.1.0"
|
||||
val pluginVersion = version.toString()
|
||||
|
||||
repositories {
|
||||
|
||||
@@ -19,6 +19,7 @@ RS-MobCages supports the following mobs:
|
||||
- Cow
|
||||
- Chicken
|
||||
- Donkey
|
||||
- Frog
|
||||
- Horse
|
||||
- Parrot
|
||||
- Pig
|
||||
|
||||
@@ -0,0 +1,107 @@
|
||||
package com.rsscripting.mobcage.description.descriptor;
|
||||
|
||||
import com.rsscripting.mobcage.description.CaptureResult;
|
||||
import com.rsscripting.mobcage.description.MobAttribute;
|
||||
import com.rsscripting.mobcage.description.MobDescriptionFormatter;
|
||||
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.Frog;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class FrogDescriptor implements MobDescriptor {
|
||||
|
||||
@Override
|
||||
public boolean supports(LivingEntity entity) {
|
||||
return entity instanceof Frog;
|
||||
}
|
||||
|
||||
@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) + "Frog";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MobAttribute> getAttributes(LivingEntity entity) {
|
||||
|
||||
Frog frog = (Frog) entity;
|
||||
|
||||
return List.of(
|
||||
new MobAttribute(
|
||||
"Variant",
|
||||
MobDescriptionFormatter.formatEnumName(
|
||||
frog.getVariant().getKey().getKey()
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void release(Location location, List<Component> lore) {
|
||||
|
||||
PlainTextComponentSerializer plain =
|
||||
PlainTextComponentSerializer.plainText();
|
||||
|
||||
boolean baby = false;
|
||||
Frog.Variant variant = Frog.Variant.TEMPERATE;
|
||||
|
||||
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 Frog");
|
||||
}
|
||||
|
||||
if (line.equals("Variant:") && i + 1 < lore.size()) {
|
||||
variant = getVariant(
|
||||
plain.serialize(lore.get(i + 1))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Frog frog = (Frog) location.getWorld().spawnEntity(
|
||||
location,
|
||||
EntityType.FROG
|
||||
);
|
||||
|
||||
if (baby) {
|
||||
frog.setBaby();
|
||||
} else {
|
||||
frog.setAdult();
|
||||
}
|
||||
|
||||
frog.setVariant(variant);
|
||||
}
|
||||
|
||||
private Frog.Variant getVariant(String value) {
|
||||
|
||||
return switch (value) {
|
||||
case "Cold" -> Frog.Variant.COLD;
|
||||
case "Temperate" -> Frog.Variant.TEMPERATE;
|
||||
case "Warm" -> Frog.Variant.WARM;
|
||||
default -> Frog.Variant.TEMPERATE;
|
||||
};
|
||||
}
|
||||
}
|
||||
+1
@@ -14,6 +14,7 @@ public final class MobDescriptorRegistry {
|
||||
new ChickenDescriptor(),
|
||||
new CowDescriptor(),
|
||||
new DonkeyDescriptor(),
|
||||
new FrogDescriptor(),
|
||||
new HorseDescriptor(),
|
||||
new ParrotDescriptor(),
|
||||
new PigDescriptor(),
|
||||
|
||||
@@ -82,6 +82,9 @@ public class MobReleaseListener implements Listener {
|
||||
case "Donkey", "Baby Donkey" ->
|
||||
new DonkeyDescriptor().release(location, lore);
|
||||
|
||||
case "Frog", "Baby Frog" ->
|
||||
new FrogDescriptor().release(location, lore);
|
||||
|
||||
case "Horse", "Baby Horse" ->
|
||||
new HorseDescriptor().release(location, lore);
|
||||
|
||||
|
||||
Reference in new issue
Block a user