1.0.3
Added: - Axolotl Support
This commit is contained in:
1 parent
e941a578c7
commit
935c8c2530
5 files changed
+105
-1
No files matched your search
+1
-1
@@ -5,7 +5,7 @@ plugins {
|
||||
}
|
||||
|
||||
group = "com.rsscripting"
|
||||
version = "1.0.2"
|
||||
version = "1.0.3"
|
||||
val pluginVersion = version.toString()
|
||||
|
||||
repositories {
|
||||
|
||||
@@ -12,6 +12,7 @@ Each supported mob may have its own handling for variants, appearance, or other
|
||||
|
||||
RS-MobCages supports the following mobs:
|
||||
|
||||
- Axolotl
|
||||
- Bee
|
||||
- Cat
|
||||
- Cave Spider
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
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 net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Axolotl;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class AxolotlDescriptor implements MobDescriptor {
|
||||
|
||||
@Override
|
||||
public boolean supports(LivingEntity entity) {
|
||||
return entity instanceof Axolotl;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CaptureResult beforeCapture(LivingEntity entity, Player player) {
|
||||
return CaptureResult.allowed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName(LivingEntity entity) {
|
||||
return MobAgeUtil.getAgePrefix(entity) + "Axolotl";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MobAttribute> getAttributes(LivingEntity entity) {
|
||||
|
||||
Axolotl axolotl = (Axolotl) entity;
|
||||
|
||||
return List.of(
|
||||
new MobAttribute(
|
||||
"Variant",
|
||||
MobDescriptionFormatter.formatEnumName(
|
||||
axolotl.getVariant().toString()
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void release(Location location, List<Component> lore) {
|
||||
|
||||
PlainTextComponentSerializer plain =
|
||||
PlainTextComponentSerializer.plainText();
|
||||
|
||||
boolean baby = false;
|
||||
Axolotl.Variant variant = Axolotl.Variant.LUCY;
|
||||
|
||||
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 Axolotl");
|
||||
}
|
||||
|
||||
if (line.equals("Variant:") && i + 1 < lore.size()) {
|
||||
variant = getVariant(
|
||||
plain.serialize(lore.get(i + 1))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Axolotl axolotl = (Axolotl) location.getWorld().spawnEntity(
|
||||
location,
|
||||
EntityType.AXOLOTL
|
||||
);
|
||||
|
||||
if (baby) {
|
||||
axolotl.setBaby();
|
||||
} else {
|
||||
axolotl.setAdult();
|
||||
}
|
||||
|
||||
axolotl.setVariant(variant);
|
||||
}
|
||||
|
||||
private Axolotl.Variant getVariant(String variant) {
|
||||
|
||||
return switch (variant) {
|
||||
case "Wild" -> Axolotl.Variant.WILD;
|
||||
case "Gold" -> Axolotl.Variant.GOLD;
|
||||
case "Cyan" -> Axolotl.Variant.CYAN;
|
||||
case "Blue" -> Axolotl.Variant.BLUE;
|
||||
case "Lucy" -> Axolotl.Variant.LUCY;
|
||||
default -> Axolotl.Variant.LUCY;
|
||||
};
|
||||
}
|
||||
}
|
||||
+1
@@ -7,6 +7,7 @@ import java.util.List;
|
||||
public final class MobDescriptorRegistry {
|
||||
|
||||
private static final List<MobDescriptor> DESCRIPTORS = List.of(
|
||||
new AxolotlDescriptor(),
|
||||
new BeeDescriptor(),
|
||||
new CatDescriptor(),
|
||||
new CaveSpiderDescriptor(),
|
||||
|
||||
@@ -61,6 +61,9 @@ public class MobReleaseListener implements Listener {
|
||||
|
||||
switch (contains) {
|
||||
|
||||
case "Axolotl", "Baby Axolotl" ->
|
||||
new AxolotlDescriptor().release(location, lore);
|
||||
|
||||
case "Bee", "Baby Bee" ->
|
||||
new BeeDescriptor().release(location, lore);
|
||||
|
||||
|
||||
Reference in new issue
Block a user