Skip to content

Commit

Permalink
Merge pull request drfiveminusmint#6 from TylerS1066/main
Browse files Browse the repository at this point in the history
Fix things
  • Loading branch information
drfiveminusmint authored May 5, 2024
2 parents 94116b0 + 74a46c5 commit de8e3b3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
1 change: 0 additions & 1 deletion .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();

Expand All @@ -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()) {
Expand Down

0 comments on commit de8e3b3

Please sign in to comment.