From 299a569e6e37870bf7828500244916acefc3e1a0 Mon Sep 17 00:00:00 2001 From: syeyoung <42869671+cyoung06@users.noreply.github.com> Date: Mon, 14 Dec 2020 18:31:24 +0900 Subject: oneway and two way --- .../dungeon/mechanics/DungeonPressurePlate.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonPressurePlate.java') diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonPressurePlate.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonPressurePlate.java index 56826abd..a59b44b5 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonPressurePlate.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonPressurePlate.java @@ -8,10 +8,8 @@ import lombok.Data; import net.minecraft.util.BlockPos; import java.awt.*; -import java.util.ArrayList; -import java.util.HashSet; +import java.util.*; import java.util.List; -import java.util.Set; @Data public class DungeonPressurePlate implements DungeonMechanic { @@ -22,6 +20,8 @@ public class DungeonPressurePlate implements DungeonMechanic { @Override public Set getAction(String state, DungeonRoom dungeonRoom) { if (!("triggered".equalsIgnoreCase(state) || "untriggered".equalsIgnoreCase(state))) throw new IllegalArgumentException(state+" is not valid state for secret"); + if (state.equalsIgnoreCase(getCurrentState(dungeonRoom))) return Collections.emptySet(); + Set base; Set preRequisites = base = new HashSet(); if ("triggered".equalsIgnoreCase(state)) { @@ -76,4 +76,14 @@ public class DungeonPressurePlate implements DungeonMechanic { } } } + + @Override + public Set getPossibleStates(DungeonRoom dungeonRoom) { + String currentStatus = getCurrentState(dungeonRoom); + if (currentStatus.equalsIgnoreCase("triggered")) + return Collections.singleton("untriggered"); + else if (currentStatus.equalsIgnoreCase("untriggered")) + return Collections.singleton("triggered"); + return Collections.emptySet(); + } } -- cgit