Skip to content

Commit

Permalink
Update tags, Flagmanager
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Jan 12, 2015
1 parent d113a6d commit 0c86940
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 21 deletions.
23 changes: 12 additions & 11 deletions src/main/java/net/aufdemrand/denizen/flags/FlagManager.java
@@ -1,11 +1,12 @@
package net.aufdemrand.denizen.flags;

import net.aufdemrand.denizen.BukkitScriptEntryData;
import net.aufdemrand.denizen.Denizen;
import net.aufdemrand.denizen.events.EventManager;
import net.aufdemrand.denizencore.events.OldEventManager;
import net.aufdemrand.denizen.events.core.FlagSmartEvent;
import net.aufdemrand.denizen.objects.*;
import net.aufdemrand.denizen.utilities.DenizenAPI;
import net.aufdemrand.denizencore.objects.Duration;
import net.aufdemrand.denizencore.objects.*;
import org.bukkit.configuration.ConfigurationSection;

import java.util.*;
Expand Down Expand Up @@ -356,15 +357,15 @@ else if (npc != null) {
world_script_events.add(type + " flag cleared");
world_script_events.add(type + " flag " + OldName + " cleared");

context.put("owner", Element.valueOf(OldOwner));
context.put("name", Element.valueOf(OldName));
context.put("type", Element.valueOf(type));
context.put("owner", new Element(OldOwner));
context.put("name", new Element(OldName));
context.put("type", new Element(type));
context.put("old_value", OldValue);

world_script_events.add("flag cleared");

EventManager.doEvents(world_script_events,
npc, player, context);
OldEventManager.doEvents(world_script_events,
new BukkitScriptEntryData(player, npc), context);
}
}

Expand Down Expand Up @@ -607,8 +608,8 @@ else if (npc != null) {

world_script_events.add("flag changed");

EventManager.doEvents(world_script_events,
npc, player, context);
OldEventManager.doEvents(world_script_events,
new BukkitScriptEntryData(player, npc), context);
}

}
Expand Down Expand Up @@ -699,8 +700,8 @@ else if (npc != null) {

world_script_events.add("flag expires");

EventManager.doEvents(world_script_events,
npc, player, context);
OldEventManager.doEvents(world_script_events,
new BukkitScriptEntryData(player, npc), context);
}
return true;
}
Expand Down
23 changes: 13 additions & 10 deletions src/main/java/net/aufdemrand/denizen/tags/core/NPCTags.java
@@ -1,7 +1,7 @@
package net.aufdemrand.denizen.tags.core;

import net.aufdemrand.denizen.BukkitScriptEntryData;
import net.aufdemrand.denizen.Denizen;
import net.aufdemrand.denizencore.events.EventManager;
import net.aufdemrand.denizen.tags.BukkitTagContext;
import net.aufdemrand.denizencore.events.OldEventManager;
import net.aufdemrand.denizencore.objects.Element;
Expand Down Expand Up @@ -29,6 +29,7 @@

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class NPCTags implements Listener {
Expand Down Expand Up @@ -110,7 +111,7 @@ public void navComplete(NavigationCompleteEvent event) {
// Do world script event 'On NPC Completes Navigation'
if (NPCNavigationSmartEvent.IsActive())
OldEventManager.doEvents(Arrays.asList
("npc completes navigation"), npc, null, null);
("npc completes navigation"), new BukkitScriptEntryData(null, npc), null);

// Do the assignment script action
if (!event.getNPC().hasTrait(AssignmentTrait.class)) return;
Expand Down Expand Up @@ -149,7 +150,7 @@ public void navBegin(NavigationBeginEvent event) {
// Do world script event 'On NPC Completes Navigation'
if (NPCNavigationSmartEvent.IsActive())
OldEventManager.doEvents(Arrays.asList
("npc begins navigation"), npc, null, null);
("npc begins navigation"), new BukkitScriptEntryData(null, npc), null);

if (!event.getNPC().hasTrait(AssignmentTrait.class)) return;
npc.action("begin navigation", null);
Expand Down Expand Up @@ -205,7 +206,7 @@ public void navCancel(NavigationCancelEvent event) {

if (NPCNavigationSmartEvent.IsActive())
OldEventManager.doEvents(Arrays.asList
("npc cancels navigation"), npc, null, null);
("npc cancels navigation"), new BukkitScriptEntryData(null, npc), null);

if (!event.getNPC().hasTrait(AssignmentTrait.class)) return;
npc.action("cancel navigation", null);
Expand Down Expand Up @@ -251,12 +252,14 @@ public void navStuck(NavigationStuckEvent event) {

// Do world script event 'On NPC stuck'
if (NPCNavigationSmartEvent.IsActive()) {
String determination = OldEventManager.doEvents(Arrays.asList
("npc stuck"), npc, null, context);
if (determination.equalsIgnoreCase("none"))
event.setAction(null);
if (determination.equalsIgnoreCase("teleport"))
event.setAction(TeleportStuckAction.INSTANCE);
List<String> determinations = OldEventManager.doEvents(Arrays.asList
("npc stuck"), new BukkitScriptEntryData(null, npc), context);
for (String determination: determinations) {
if (determination.equalsIgnoreCase("none"))
event.setAction(null);
if (determination.equalsIgnoreCase("teleport"))
event.setAction(TeleportStuckAction.INSTANCE);
}
}

// Do the assignment script action
Expand Down

0 comments on commit 0c86940

Please sign in to comment.