You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
917 B
Java

package com.zivilon.dungeontools;
import org.bukkit.ChatColor;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
public class TrackedEntity {
public final EntityType type;
public final String name;
public TrackedEntity(EntityType type, String name) {
this.type = type;
this.name = name;
}
public boolean matches(LivingEntity entity) {
if (entity.getType() != type) {
return false;
}
if (name == null) {
return true;
}
return name.equals(entity.getCustomName());
}
public static TrackedEntity parseTrackedEntity(String s) {
String[] split = s.split(":", 2);
EntityType type = EntityType.valueOf(split[0]);
String name = split.length > 1 ? ChatColor.translateAlternateColorCodes('&', split[1]) : null;
return new TrackedEntity(type, name);
}
}