-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
462 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
src/main/java/gigaherz/guidebook/guidebook/BookParsingException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package gigaherz.guidebook.guidebook; | ||
|
||
public class BookParsingException extends RuntimeException | ||
{ | ||
public BookParsingException(String message) | ||
{ | ||
super(message); | ||
} | ||
|
||
public BookParsingException(String message, Throwable cause) | ||
{ | ||
super(message, cause); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
src/main/java/gigaherz/guidebook/guidebook/conditions/AdvancementCondition.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package gigaherz.guidebook.guidebook.conditions; | ||
|
||
import com.google.common.base.Strings; | ||
import gigaherz.guidebook.guidebook.BookParsingException; | ||
import org.w3c.dom.Node; | ||
|
||
public abstract class AdvancementCondition implements IDisplayCondition | ||
{ | ||
public final String stageName; | ||
|
||
protected AdvancementCondition(String stageName) | ||
{ | ||
this.stageName = stageName; | ||
} | ||
|
||
public static void register() | ||
{ | ||
ConditionManager.register("advancement-locked", (doc, node) -> new Locked(parseStageName(node))); | ||
ConditionManager.register("advancement-unlocked", (doc, node) -> new Unlocked(parseStageName(node))); | ||
} | ||
|
||
public static class Locked extends AdvancementCondition | ||
{ | ||
|
||
public Locked(String stageName) | ||
{ | ||
super(stageName); | ||
} | ||
|
||
@Override | ||
public boolean test(ConditionContext conditionContext) | ||
{ | ||
return false; // !Advancement.getStageData(conditionContext.getPlayer()).hasUnlockedStage(stageName); | ||
} | ||
} | ||
|
||
public static class Unlocked extends AdvancementCondition | ||
{ | ||
|
||
public Unlocked(String stageName) | ||
{ | ||
super(stageName); | ||
} | ||
|
||
@Override | ||
public boolean test(ConditionContext conditionContext) | ||
{ | ||
return false; // Advancement.getStageData(conditionContext.getPlayer()).hasUnlockedStage(stageName); | ||
} | ||
} | ||
|
||
private static String parseStageName(Node xmlNode) | ||
{ | ||
Node attr = xmlNode.getAttributes().getNamedItem("advancement"); | ||
if (attr == null) | ||
throw new BookParsingException("Missing required XML attribute 'advancement'."); | ||
|
||
String stageName = attr.getTextContent(); | ||
if (Strings.isNullOrEmpty(stageName)) | ||
throw new BookParsingException("Missing required XML attribute 'advancement'."); | ||
return stageName; | ||
} | ||
} |
Oops, something went wrong.