Remove debugging, don't use metrics for internal traits

This commit is contained in:
fullwall 2012-07-21 23:28:19 +08:00
parent 91424d425c
commit 64c630784d
2 changed files with 10 additions and 10 deletions

View File

@ -1,14 +1,15 @@
package net.citizensnpcs.npc;
import java.util.Map;
import java.util.Set;
import net.citizensnpcs.Metrics;
import net.citizensnpcs.Metrics.Graph;
import net.citizensnpcs.api.CitizensAPI;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.api.trait.Trait;
import net.citizensnpcs.api.trait.TraitInfo;
import net.citizensnpcs.api.trait.TraitFactory;
import net.citizensnpcs.api.trait.TraitInfo;
import net.citizensnpcs.api.trait.trait.Equipment;
import net.citizensnpcs.api.trait.trait.Inventory;
import net.citizensnpcs.api.trait.trait.MobType;
@ -29,6 +30,7 @@ import net.citizensnpcs.trait.waypoint.Waypoints;
import com.google.common.base.Preconditions;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
public class CitizensTraitFactory implements TraitFactory {
private final Map<String, Class<? extends Trait>> registered = Maps.newHashMap();
@ -52,10 +54,17 @@ public class CitizensTraitFactory implements TraitFactory {
registerTrait(TraitInfo.create(WoolColor.class).withName("woolcolor"));
registerTrait(TraitInfo.create(Controllable.class).withName("controllable"));
registerTrait(TraitInfo.create(Behaviour.class).withName("behaviour"));
for (String trait : registered.keySet())
INTERNAL_TRAITS.add(trait);
}
private static final Set<String> INTERNAL_TRAITS = Sets.newHashSet();
public void addPlotters(Graph graph) {
for (Map.Entry<String, Class<? extends Trait>> entry : registered.entrySet()) {
if (INTERNAL_TRAITS.contains(entry.getKey()))
continue;
final Class<? extends Trait> traitClass = entry.getValue();
graph.addPlotter(new Metrics.Plotter(entry.getKey()) {
@Override

View File

@ -2,7 +2,6 @@ package net.citizensnpcs.npc.ai;
import java.lang.reflect.Field;
import java.util.Map;
import java.util.Set;
import net.citizensnpcs.api.ai.EntityTarget;
import net.citizensnpcs.api.ai.Navigator;
@ -11,7 +10,6 @@ import net.citizensnpcs.api.ai.event.NavigationBeginEvent;
import net.citizensnpcs.api.ai.event.NavigationCancelEvent;
import net.citizensnpcs.api.ai.event.NavigationReplaceEvent;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.util.Messaging;
import net.minecraft.server.EntityLiving;
import org.bukkit.Bukkit;
@ -20,7 +18,6 @@ import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
public class CitizensNavigator implements Navigator {
private PathStrategy executing;
@ -100,16 +97,10 @@ public class CitizensNavigator implements Navigator {
public void setTarget(Location target) {
if (!npc.isSpawned())
throw new IllegalStateException("npc is not spawned");
if (!logged.contains(target)) {
Messaging.log(target);
logged.add(target);
}
PathStrategy newStrategy = new MCNavigationStrategy(npc, target, speed);
switchStrategyTo(newStrategy);
}
private final Set<Location> logged = Sets.newHashSet();
private void switchStrategyTo(PathStrategy newStrategy) {
if (executing != null)
Bukkit.getPluginManager().callEvent(new NavigationReplaceEvent(this));