Skip to content

Commit

Permalink
use fallbacks even on object-root tags
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Jan 19, 2019
1 parent 37c7932 commit ccbca5a
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions src/main/java/net/aufdemrand/denizencore/tags/TagManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,10 @@ public static void fetchObject(ReplaceableTagEvent event) {
Class object_class = ObjectFetcher.getObjectClass(object_type);

if (object_class == null) {
dB.echoError("Invalid object type! Could not fetch '" + object_type + "'!");
event.setReplaced("null");
if (!event.hasAlternative()) {
dB.echoError("Invalid object type! Could not fetch '" + object_type + "'!");
event.setReplaced("null");
}
return;
}

Expand All @@ -270,19 +272,23 @@ public static void fetchObject(ReplaceableTagEvent event) {

if (!ObjectFetcher.checkMatch(object_class, event.hasNameContext() ? event.getAttributes().attributes[0].rawKey + '[' + event.getNameContext() + ']'
: event.getAttributes().attributes[0].rawKey)) {
dB.echoDebug(event.getScriptEntry(), "Returning null. '" + event.getAttributes().attributes[0].rawKey
+ "' is an invalid " + object_class.getSimpleName() + ".");
event.setReplaced("null");
if (!event.hasAlternative()) {
dB.echoDebug(event.getScriptEntry(), "Returning null. '" + event.getAttributes().attributes[0].rawKey
+ "' is an invalid " + object_class.getSimpleName() + ".");
event.setReplaced("null");
}
return;
}

arg = ObjectFetcher.getObjectFrom(object_class, event.hasNameContext() ? event.getAttributes().attributes[0].rawKey + '[' + event.getNameContext() + ']'
: event.getAttributes().attributes[0].rawKey, DenizenCore.getImplementation().getTagContext(event.getScriptEntry()));

if (arg == null) {
dB.echoError(((event.hasNameContext() ? event.getAttributes().attributes[0].rawKey + '[' + event.getNameContext() + ']'
: event.getAttributes().attributes[0].rawKey) + " is an invalid dObject!"));
event.setReplaced("null");
if (!event.hasAlternative()) {
dB.echoError(((event.hasNameContext() ? event.getAttributes().attributes[0].rawKey + '[' + event.getNameContext() + ']'
: event.getAttributes().attributes[0].rawKey) + " is an invalid dObject!"));
event.setReplaced("null");
}
return;
}

Expand All @@ -292,7 +298,9 @@ public static void fetchObject(ReplaceableTagEvent event) {
catch (Exception e) {
dB.echoError("Uh oh! Report this to the Denizen developers! Err: TagManagerObjectReflection");
dB.echoError(e);
event.setReplaced("null");
if (!event.hasAlternative()) {
event.setReplaced("null");
}
}
}

Expand Down

0 comments on commit ccbca5a

Please sign in to comment.