Skip to content

Commit

Permalink
Fix mechanism stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Mar 16, 2018
1 parent 1c1c826 commit dba64ef
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
Expand Up @@ -47,6 +47,11 @@ public class dEntity implements dObject, Adjustable {
// STATIC METHODS
/////////////////

// List a mechanism here if it can be safely run before spawn.
public static HashSet<String> earlyValidMechanisms = new HashSet<String>(Arrays.asList(
"max_health", "health_data", "health"
));

private static final Map<UUID, Entity> rememberedEntities = new HashMap<UUID, Entity>();

public static void rememberEntity(Entity entity) {
Expand Down
Expand Up @@ -2,6 +2,7 @@

import net.aufdemrand.denizen.objects.dEntity;
import net.aufdemrand.denizencore.objects.Mechanism;
import net.aufdemrand.denizencore.utilities.CoreUtilities;
import org.bukkit.Location;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
Expand All @@ -20,10 +21,12 @@ public static <T extends Entity> Entity spawn(Location location, EntityType bukk
@Override
public void accept(Entity bukkitEntity) {
dEntity entity = new dEntity(bukkitEntity);
for (Mechanism mechanism : mechanisms) {
entity.adjust(mechanism);
for (Mechanism mechanism : new ArrayList<Mechanism>(mechanisms)) {
if (dEntity.earlyValidMechanisms.contains(CoreUtilities.toLowerCase(mechanism.getName()))) {
entity.adjust(mechanism);
mechanisms.remove(mechanism);
}
}
mechanisms.clear();
}
};
return location.getWorld().spawn(location, (Class<T>) bukkitEntityType.getEntityClass(), (Consumer<T>) consumer);
Expand Down

0 comments on commit dba64ef

Please sign in to comment.