Skip to content

Commit

Permalink
Fix regex that de-sensitizes caps on script/key names. This fixes not…
Browse files Browse the repository at this point in the history
… being able to use -'s or :'s in script/key names.
  • Loading branch information
aufdemrand committed Apr 1, 2013
1 parent 2438f47 commit 5920161
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 11 deletions.
Expand Up @@ -114,7 +114,7 @@ private static String _concatenateCoreScripts() {

private static String yamlKeysToUpperCase(String string) {
StringBuffer sb = new StringBuffer();
Pattern pattern = Pattern.compile("(^[^:-]*?[^\\s]:)", Pattern.MULTILINE);
Pattern pattern = Pattern.compile("(^.*?[^\\s](:\\s))", Pattern.MULTILINE);
Matcher matcher = pattern.matcher(string);
while (matcher.find())
matcher.appendReplacement(sb, matcher.group().toUpperCase());
Expand Down
Expand Up @@ -210,7 +210,7 @@ public void start() {
if (isStarted) return;

// Start the queue
dB.log("Starting queue " + id + "... (Speed=" + ticks + "tpr)");
dB.echoDebug("Starting queue " + id + ". (Speed=" + ticks + "tpr)");
isStarted = true;

// If not an instant queue, set a bukkit repeating task with the speed
Expand Down
Expand Up @@ -92,7 +92,7 @@ public void execute(ScriptEntry scriptEntry) throws CommandExecutionException {
}

// Remember the item entity
displayed.put(location.dScriptArgValue(), location.getBlock().getLocation().getWorld().dropItem(location, item.getItemStack()));
displayed.put(location.dScriptArgValue(), location.getBlock().getLocation().add(0, 1, 0).getWorld().dropItem(location, item.getItemStack()));
displayed.get(location.dScriptArgValue()).setPickupDelay(Integer.MAX_VALUE);
displayed.get(location.dScriptArgValue()).setTicksLived(ticks);
}
Expand Down
Expand Up @@ -23,6 +23,9 @@ public void parseArgs(ScriptEntry scriptEntry) throws InvalidArgumentsException
if (aH.matchesArg("STOP", arg))
scriptEntry.addObject("stop", true);

if (aH.matchesValueArg("LEAD", arg, aH.ArgumentType.Double))
scriptEntry.addObject("lead", aH.getDoubleFrom(arg));

else throw new InvalidArgumentsException(dB.Messages.ERROR_UNKNOWN_ARGUMENT, arg);
}
}
Expand All @@ -31,19 +34,25 @@ public void parseArgs(ScriptEntry scriptEntry) throws InvalidArgumentsException
public void execute(ScriptEntry scriptEntry) throws CommandExecutionException {
// Get objects
Boolean stop = (Boolean) scriptEntry.getObject("stop");
Double lead = (Double) scriptEntry.getObject("lead");

// Report to dB
dB.report(getName(),
aH.debugObj("Player", scriptEntry.getPlayer().getName())
+ (stop == null ? aH.debugObj("Action", "FOLLOW")
: aH.debugObj("Action", "STOP")));
: aH.debugObj("Action", "STOP"))
+ (lead != null ? aH.debugObj("Lead", lead.toString()) : "" ));

if (lead != null)
scriptEntry.getNPC().getNavigator().getLocalParameters().distanceMargin(lead);

if (stop != null)
scriptEntry.getNPC().getNavigator()
.cancelNavigation();
else
scriptEntry.getNPC().getNavigator()
.setTarget(scriptEntry.getPlayer(), false);

}

}
Expand Up @@ -46,20 +46,20 @@ public String doEvent(String eventName, dNPC npc, Player player, Map<String, Str

for (WorldScriptContainer script : world_scripts.values()) {

if (script == null) continue;
if (!script.contains("EVENTS.ON " + eventName.toUpperCase())) continue;

// Fetch script from Event
List<ScriptEntry> entries = script.getEntries(player, npc, "events.on " + eventName);
if (entries.isEmpty()) continue;

dB.report("Event",
aH.debugObj("Type", "On " + eventName)
+ script.getAsScriptArg().debug()
+ (npc != null ? aH.debugObj("NPC", npc.toString()) : "")
+ (player != null ? aH.debugObj("Player", player.getName()) : "")
+ (context != null ? aH.debugObj("Context", context.toString()) : ""));

if (script == null) continue;
if (!script.contains("EVENTS.ON " + eventName.toUpperCase())) continue;

// Fetch script from Event
List<ScriptEntry> entries = script.getEntries(player, npc, "events.on " + eventName);
if (entries.isEmpty()) continue;

dB.echoDebug(dB.DebugElement.Header, "Building event 'On " + eventName.toUpperCase() + "' for " + script.getName());

if (context != null) {
Expand Down

0 comments on commit 5920161

Please sign in to comment.