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); } }