diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index e1c3541..fde0b51 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -10,7 +10,6 @@ jobs: uses: actions/checkout@v3 with: path: Movecraft-ShipRules - ref: main - name: Set up JDK 17 uses: actions/setup-java@v3 with: diff --git a/src/main/java/net/countercraft/movecraft/rules/PilotListener.java b/src/main/java/net/countercraft/movecraft/rules/PilotListener.java index 74e4ccb..d0e1bea 100644 --- a/src/main/java/net/countercraft/movecraft/rules/PilotListener.java +++ b/src/main/java/net/countercraft/movecraft/rules/PilotListener.java @@ -4,6 +4,7 @@ import net.countercraft.movecraft.MovecraftLocation; import net.countercraft.movecraft.craft.Craft; import net.countercraft.movecraft.craft.PilotedCraft; +import net.countercraft.movecraft.craft.SubCraft; import net.countercraft.movecraft.craft.type.CraftType; import net.countercraft.movecraft.events.CraftDetectEvent; import net.countercraft.movecraft.libs.net.kyori.adventure.audience.Audience; @@ -27,9 +28,15 @@ public void onCraftPilot(CraftDetectEvent event) { Craft craft = event.getCraft(); // Ignore all of this if the player has permission to bypass the rules - if (!(craft instanceof PilotedCraft) + if (craft instanceof PilotedCraft && ((PilotedCraft) craft).getPilot().hasPermission("movecraft.rules.bypass")) return; + if (craft instanceof SubCraft) { + Craft parent = ((SubCraft) craft).getParent(); + if (parent instanceof PilotedCraft + && ((PilotedCraft) parent).getPilot().hasPermission("movecraft.rules.bypass")) + return; + } CraftType type = craft.getType(); @@ -41,6 +48,19 @@ public void onCraftPilot(CraftDetectEvent event) { // find a cruise sign. if (type.getBoolProperty(CraftType.CRUISE_ON_PILOT)) { direction = craft.getCruiseDirection(); + if (direction == null) { + // Movecraft hasn't yet set the direction based on the pilot, let's do that + // ourselves. + BlockState state = event.getStartLocation().toBukkit(craft.getWorld()).getBlock().getState(); + if ((state instanceof Sign)) { + Sign sign = (Sign) state; + if (sign.getBlockData() instanceof Directional) { + direction = CruiseDirection.fromBlockFace(((Directional) sign.getBlockData()).getFacing()); + } else { + direction = CruiseDirection.NONE; + } + } + } } else { boolean requireCruiseSignAlignment = type.getBoolProperty(TypeRules.REQUIRE_CRUISE_SIGN_ALIGNMENT); for (MovecraftLocation location : craft.getHitBox()) {