From 787a10763d7ee8258e5fe21d0e63a6d5e3f829ac Mon Sep 17 00:00:00 2001 From: Wolf2323 Date: Fri, 3 Nov 2023 16:03:31 +0100 Subject: [PATCH] added Stage Event --- .../quest/event/stage/StageEvent.java | 39 +++++++++++++++++++ .../quest/event/stage/StageEventFactory.java | 13 +++++++ .../quest/event/stage/package-info.java | 4 ++ 3 files changed, 56 insertions(+) create mode 100644 src/main/java/org/betonquest/betonquest/quest/event/stage/StageEvent.java create mode 100644 src/main/java/org/betonquest/betonquest/quest/event/stage/StageEventFactory.java create mode 100644 src/main/java/org/betonquest/betonquest/quest/event/stage/package-info.java diff --git a/src/main/java/org/betonquest/betonquest/quest/event/stage/StageEvent.java b/src/main/java/org/betonquest/betonquest/quest/event/stage/StageEvent.java new file mode 100644 index 0000000000..9c39eeda17 --- /dev/null +++ b/src/main/java/org/betonquest/betonquest/quest/event/stage/StageEvent.java @@ -0,0 +1,39 @@ +package org.betonquest.betonquest.quest.event.stage; + +import org.betonquest.betonquest.VariableString; +import org.betonquest.betonquest.api.profiles.Profile; +import org.betonquest.betonquest.api.quest.event.Event; +import org.betonquest.betonquest.exceptions.QuestRuntimeException; +import org.betonquest.betonquest.objectives.StageObjective; + +/** + * The StageEvent class to set the players stage. + */ +public class StageEvent implements Event { + /** + * The stage objective. + */ + private final StageObjective stage; + + /** + * The target stage to set. + */ + private final VariableString targetStage; + + /** + * Creates the stage event. + * + * @param stage the stage objective. + * @param targetStage the target stage to set. + */ + public StageEvent(final StageObjective stage, final VariableString targetStage) { + this.stage = stage; + this.targetStage = targetStage; + } + + @Override + public void execute(final Profile profile) throws QuestRuntimeException { + stage.setStage(profile, targetStage.getString(profile)); + } + +} diff --git a/src/main/java/org/betonquest/betonquest/quest/event/stage/StageEventFactory.java b/src/main/java/org/betonquest/betonquest/quest/event/stage/StageEventFactory.java new file mode 100644 index 0000000000..68300ef299 --- /dev/null +++ b/src/main/java/org/betonquest/betonquest/quest/event/stage/StageEventFactory.java @@ -0,0 +1,13 @@ +package org.betonquest.betonquest.quest.event.stage; + +import org.betonquest.betonquest.Instruction; +import org.betonquest.betonquest.api.quest.event.Event; +import org.betonquest.betonquest.api.quest.event.EventFactory; +import org.betonquest.betonquest.exceptions.InstructionParseException; + +public class StageEventFactory implements EventFactory { + @Override + public Event parseEvent(final Instruction instruction) throws InstructionParseException { + return null; + } +} diff --git a/src/main/java/org/betonquest/betonquest/quest/event/stage/package-info.java b/src/main/java/org/betonquest/betonquest/quest/event/stage/package-info.java new file mode 100644 index 0000000000..7a959ae0a9 --- /dev/null +++ b/src/main/java/org/betonquest/betonquest/quest/event/stage/package-info.java @@ -0,0 +1,4 @@ +/** + * {@link org.betonquest.betonquest.api.quest.event.Event Event} implementation of the stage event. + */ +package org.betonquest.betonquest.quest.event.stage;