use paper custom name methods
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>me.youhavetrouble</groupId>
|
||||
<artifactId>Entiddy</artifactId>
|
||||
<version>1.2.0</version>
|
||||
<version>2.0.0-pre</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>Entiddy</name>
|
||||
|
||||
@@ -5,6 +5,7 @@ import me.youhavetrouble.entiddy.SpecialEntities.JebSheep;
|
||||
import me.youhavetrouble.entiddy.SpecialEntities.Johnny;
|
||||
import me.youhavetrouble.entiddy.SpecialEntities.KillerBunny;
|
||||
import me.youhavetrouble.entiddy.SpecialEntities.Toast;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -57,7 +58,7 @@ public enum Entiddy {
|
||||
*/
|
||||
public static void upsideDown(@NotNull LivingEntity entity) {
|
||||
if (entity instanceof Player) return;
|
||||
entity.setCustomName("Grumm");
|
||||
entity.customName(Component.text("Grumm"));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
package me.youhavetrouble.entiddy.SpecialEntities;
|
||||
|
||||
import me.youhavetrouble.entiddy.EntiddyInterface;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Rabbit;
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class JebSheep implements EntiddyInterface {
|
||||
|
||||
@Override
|
||||
@@ -16,12 +16,13 @@ public class JebSheep implements EntiddyInterface {
|
||||
if (location.getWorld() == null) {
|
||||
throw new NullPointerException("World cannot be null");
|
||||
}
|
||||
return location.getWorld().spawnEntity(location, EntityType.SHEEP, spawnReason, (entity) -> entity.setCustomName("jeb_"));
|
||||
return location.getWorld().spawnEntity(location, EntityType.SHEEP, spawnReason,
|
||||
(entity) -> entity.customName(Component.text("jeb_")));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInstance(@NotNull LivingEntity entity) {
|
||||
if (!(entity instanceof Rabbit)) return false;
|
||||
return entity.getCustomName() != null && entity.getCustomName().equals("jeb_");
|
||||
if (!(entity instanceof Sheep)) return false;
|
||||
return entity.customName() != null && Objects.equals(entity.customName(), Component.text("jeb_"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package me.youhavetrouble.entiddy.SpecialEntities;
|
||||
|
||||
import me.youhavetrouble.entiddy.EntiddyInterface;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
@@ -16,7 +17,8 @@ public class Toast implements EntiddyInterface {
|
||||
if (location.getWorld() == null) {
|
||||
throw new NullPointerException("World cannot be null");
|
||||
}
|
||||
return location.getWorld().spawnEntity(location, EntityType.RABBIT, spawnReason, (entity) -> entity.setCustomName("Toast"));
|
||||
return location.getWorld().spawnEntity(location, EntityType.RABBIT, spawnReason,
|
||||
(entity) -> entity.customName(Component.text("Toast")));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user