use of com.magmaguy.elitemobs.mobconstructor.EliteMobEntity in project GDHooks by bloodmc.
the class EliteMobsProvider method getEliteMobId.
public String getEliteMobId(Entity entity) {
final EliteMobEntity eliteMobEntity = EntityTracker.getEliteMobEntity(entity);
if (eliteMobEntity == null) {
return null;
}
String eliteMobName = eliteMobEntity.getName();
if (eliteMobName == null) {
final EliteMobProperties eliteMobProperties = EliteMobProperties.getPluginData(entity.getType());
eliteMobName = eliteMobProperties.getName();
}
String id = "elitemobs:" + ChatColor.stripColor(eliteMobName).replace(" ", "_").replace(String.valueOf(eliteMobEntity.getLevel()), "").replace("Lvl_$level_", "").replaceAll("[^A-Za-z0-9_]", "").toLowerCase();
if (id.startsWith("_")) {
id = id.substring(1);
}
return id;
}
use of com.magmaguy.elitemobs.mobconstructor.EliteMobEntity in project GDHooks by bloodmc.
the class EliteMobsProvider method onEliteMobSpawn.
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onEliteMobSpawn(EliteMobSpawnEvent event) {
final Entity entity = event.getEntity();
final World world = entity.getWorld();
if (!GriefDefender.getCore().isEnabled(world.getUID())) {
return;
}
final EliteMobEntity eliteMobEntity = event.getEliteMobEntity();
final Claim claim = GriefDefender.getCore().getClaimAt(entity.getLocation());
final Set<Context> contexts = this.getEliteMobContexts(entity, eliteMobEntity);
contexts.add(new Context("source", "spawnreason:" + event.getReason().name().toLowerCase()));
contexts.add(new Context("source", "spawnreason:" + event.getReason().name().toLowerCase()));
final EliteMobProperties eliteMobProperties = EliteMobProperties.getPluginData(entity.getType());
final String name = "elitemobs:" + ChatColor.stripColor(eliteMobProperties.getName()).replace(" ", "_").replace(String.valueOf(eliteMobEntity.getLevel()), "").replace("Lvl_$level_", "").replaceAll("[^A-Za-z0-9_]", "").toLowerCase();
contexts.add(new Context("target", name));
final Tristate result = GriefDefender.getPermissionManager().getActiveFlagPermissionValue(event, entity.getLocation(), claim, null, Flags.ENTITY_SPAWN, event.getReason(), entity, contexts, null, true);
if (result == Tristate.FALSE) {
event.setCancelled(true);
}
}
Aggregations