Skip to content

Commit 426299c

Browse files
committed
Merge branch 'master' into five
2 parents 7292c62 + 3660a04 commit 426299c

File tree

4 files changed

+95
-47
lines changed

4 files changed

+95
-47
lines changed

.github/workflows/gradle.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Gradle Build
2+
on: [push, pull_request, merge_group]
3+
4+
jobs:
5+
build:
6+
name: Build CraftBook on ${{ matrix.os }}
7+
runs-on: ${{ matrix.os }}
8+
strategy:
9+
fail-fast: false
10+
matrix:
11+
os: [ubuntu-latest, windows-latest]
12+
13+
steps:
14+
- uses: actions/checkout@v4
15+
16+
- name: Set up JDK
17+
uses: actions/setup-java@v4
18+
with:
19+
java-version: 21
20+
distribution: 'temurin'
21+
22+
- name: Setup Gradle
23+
uses: gradle/actions/setup-gradle@v3
24+
with:
25+
cache-read-only: ${{ !(github.ref == 'refs/heads/master' || github.ref == 'refs/heads/five') }}
26+
27+
- name: Execute Gradle build
28+
run: ./gradlew build -s
29+
30+
- uses: actions/upload-artifact@v4
31+
name: Archive Reports
32+
if: always()
33+
with:
34+
name: reports for ${{ matrix.os }}
35+
path: '**/build/reports/**'
36+
37+
- uses: actions/upload-artifact@v4
38+
name: Archive Logs
39+
if: always()
40+
with:
41+
name: logs for ${{ matrix.os }}
42+
path: '**/*.log'

craftbook-bukkit/src/main/java/org/enginehub/craftbook/mechanics/ic/gates/world/blocks/CombineHarvester.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ public boolean harvestable(Block block) {
101101
case COCOA:
102102
Ageable ageable = (Ageable) block.getBlockData();
103103
return ageable.getAge() == ageable.getMaximumAge();
104+
case CACTUS_FLOWER:
105+
return below == Material.CACTUS;
104106
case CACTUS:
105107
return below == Material.CACTUS && above != Material.CACTUS;
106108
case SUGAR_CANE:

craftbook-bukkit/src/main/java/org/enginehub/craftbook/mechanics/pipe/Pipes.java

Lines changed: 45 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -128,14 +128,15 @@ public void onSignChange(SignChangeEvent event) {
128128
}
129129

130130
private static boolean isPiston(Block block) {
131-
return block.getType() == Material.PISTON || block.getType() == Material.STICKY_PISTON;
131+
Material type = block.getType();
132+
return type == Material.PISTON || type == Material.STICKY_PISTON;
132133
}
133134

134135
private static ChangedSign getSignOnPiston(Block block) {
135136
BlockData blockData = block.getBlockData();
136137
BlockFace facing = BlockFace.SELF;
137-
if (blockData instanceof Directional) {
138-
facing = ((Directional) blockData).getFacing();
138+
if (blockData instanceof Directional directional) {
139+
facing = directional.getFacing();
139140
}
140141

141142
for (BlockFace face : LocationUtil.getDirectFaces()) {
@@ -166,7 +167,8 @@ private void searchNearbyPipes(Block block, Set<Vector> visitedPipes, List<ItemS
166167
//Use the queue to search blocks.
167168
while (!searchQueue.isEmpty()) {
168169
Block bl = searchQueue.poll();
169-
if (bl.getType() == Material.PISTON) {
170+
Material blType = bl.getType();
171+
if (blType == Material.PISTON) {
170172
Piston p = (Piston) bl.getBlockData();
171173

172174
ChangedSign sign = getSignOnPiston(bl);
@@ -229,7 +231,7 @@ private void searchNearbyPipes(Block block, Set<Vector> visitedPipes, List<ItemS
229231
items.removeAll(filteredItems);
230232
items.addAll(newItems);
231233
}
232-
} else if (bl.getType() == Material.DROPPER) {
234+
} else if (blType == Material.DROPPER) {
233235
ChangedSign sign = getSignOnPiston(bl);
234236

235237
HashSet<ItemStack> pFilters = new HashSet<>();
@@ -306,33 +308,35 @@ private void searchNearbyPipes(Block block, Set<Vector> visitedPipes, List<ItemS
306308
}
307309

308310
Block off = bl.getRelative(x, y, z);
311+
Material offType = off.getType();
309312

310-
if (!isValidPipeBlock(off)) continue;
313+
if (!isValidPipeBlock(offType)) continue;
311314

312315
if (visitedPipes.contains(off.getLocation().toVector())) continue;
313316
visitedPipes.add(off.getLocation().toVector());
314317

315-
if (ItemUtil.isStainedGlass(bl.getType()) && ItemUtil.isStainedGlass(off.getType()) && bl.getType() != off.getType())
318+
if (ItemUtil.isStainedGlass(blType) && ItemUtil.isStainedGlass(offType) && blType != offType)
316319
continue;
317320

318-
if (off.getType() == Material.GLASS || ItemUtil.isStainedGlass(off.getType())) {
321+
if (offType == Material.GLASS || ItemUtil.isStainedGlass(offType)) {
319322
searchQueue.add(off);
320-
} else if (off.getType() == Material.GLASS_PANE || ItemUtil.isStainedGlassPane(off.getType())) {
323+
} else if (offType == Material.GLASS_PANE || ItemUtil.isStainedGlassPane(offType)) {
321324
Block offsetBlock = off.getRelative(x, y, z);
322-
if (!isValidPipeBlock(offsetBlock)) continue;
323-
if (visitedPipes.contains(offsetBlock.getLocation().toVector()))
325+
Material offsetBlockType = offsetBlock.getType();
326+
if (!isValidPipeBlock(offsetBlockType))
324327
continue;
325-
if (ItemUtil.isStainedGlassPane(off.getType())) {
326-
if ((ItemUtil.isStainedGlass(bl.getType())
327-
|| ItemUtil.isStainedGlassPane(bl.getType())) && ItemUtil.getStainedColor(off.getType()) != ItemUtil
328-
.getStainedColor(offsetBlock.getType())
329-
|| (ItemUtil.isStainedGlass(offsetBlock.getType())
330-
|| ItemUtil.isStainedGlassPane(offsetBlock.getType())) && ItemUtil.getStainedColor(off.getType()) != ItemUtil
331-
.getStainedColor(offsetBlock.getType())) continue;
328+
if (visitedPipes.contains(offsetBlock.getLocation().toVector())) continue;
329+
if (ItemUtil.isStainedGlassPane(offType)) {
330+
if ((ItemUtil.isStainedGlass(blType)
331+
|| ItemUtil.isStainedGlassPane(blType)) && ItemUtil.getStainedColor(offType) != ItemUtil
332+
.getStainedColor(offsetBlockType)
333+
|| (ItemUtil.isStainedGlass(offsetBlockType)
334+
|| ItemUtil.isStainedGlassPane(offsetBlockType)) && ItemUtil.getStainedColor(offType) != ItemUtil
335+
.getStainedColor(offsetBlockType)) continue;
332336
}
333337
visitedPipes.add(offsetBlock.getLocation().toVector());
334338
searchQueue.add(off.getRelative(x, y, z));
335-
} else if (off.getType() == Material.PISTON)
339+
} else if (offType == Material.PISTON)
336340
searchQueue.addFirst(off); //Pistons are treated with higher priority.
337341
}
338342
}
@@ -341,19 +345,13 @@ private void searchNearbyPipes(Block block, Set<Vector> visitedPipes, List<ItemS
341345
}
342346
}
343347

344-
private static boolean isValidPipeBlock(Block block) {
345-
switch (block.getType()) {
346-
case GLASS:
347-
case PISTON:
348-
case STICKY_PISTON:
349-
case DROPPER:
350-
case GLASS_PANE:
351-
return true;
352-
default:
353-
return ItemUtil.isStainedGlass(block.getType())
354-
|| ItemUtil.isStainedGlassPane(block.getType())
355-
|| SignUtil.isWallSign(block);
356-
}
348+
private static boolean isValidPipeBlock(Material type) {
349+
return switch (type) {
350+
case GLASS, PISTON, STICKY_PISTON, DROPPER, GLASS_PANE -> true;
351+
default -> ItemUtil.isStainedGlass(type)
352+
|| ItemUtil.isStainedGlassPane(type)
353+
|| SignUtil.isWallSign(type);
354+
};
357355
}
358356

359357
private void startPipe(Block block, List<ItemStack> items, boolean request) {
@@ -383,17 +381,18 @@ private void startPipe(Block block, List<ItemStack> items, boolean request) {
383381

384382
Piston p = (Piston) block.getBlockData();
385383
Block fac = block.getRelative(p.getFacing());
386-
387-
if (fac.getType() == Material.CHEST
388-
|| fac.getType() == Material.TRAPPED_CHEST
389-
|| fac.getType() == Material.DROPPER
390-
|| fac.getType() == Material.DISPENSER
391-
|| fac.getType() == Material.HOPPER
392-
|| fac.getType() == Material.BARREL
393-
|| fac.getType() == Material.CHISELED_BOOKSHELF
394-
|| fac.getType() == Material.CRAFTER
395-
|| fac.getType() == Material.DECORATED_POT
396-
|| Tag.SHULKER_BOXES.isTagged(fac.getType())) {
384+
Material facType = fac.getType();
385+
386+
if (facType == Material.CHEST
387+
|| facType == Material.TRAPPED_CHEST
388+
|| facType == Material.DROPPER
389+
|| facType == Material.DISPENSER
390+
|| facType == Material.HOPPER
391+
|| facType == Material.BARREL
392+
|| facType == Material.CHISELED_BOOKSHELF
393+
|| facType == Material.CRAFTER
394+
|| facType == Material.DECORATED_POT
395+
|| Tag.SHULKER_BOXES.isTagged(facType)) {
397396
for (ItemStack stack : ((InventoryHolder) fac.getState()).getInventory().getContents()) {
398397

399398
if (!ItemUtil.isStackValid(stack))
@@ -418,7 +417,7 @@ private void startPipe(Block block, List<ItemStack> items, boolean request) {
418417
}
419418

420419
if (!items.isEmpty()) {
421-
if (fac.getType() == Material.CRAFTER) {
420+
if (facType == Material.CRAFTER) {
422421
leftovers.addAll(InventoryUtil.addItemsToCrafter((Crafter) fac.getState(), items.toArray(new ItemStack[items.size()])));
423422
} else {
424423
for (ItemStack item : items) {
@@ -429,7 +428,7 @@ private void startPipe(Block block, List<ItemStack> items, boolean request) {
429428
}
430429
}
431430
}
432-
} else if (fac.getType() == Material.FURNACE || fac.getType() == Material.BLAST_FURNACE || fac.getType() == Material.SMOKER) {
431+
} else if (facType == Material.FURNACE || facType == Material.BLAST_FURNACE || facType == Material.SMOKER) {
433432

434433
Furnace f = (Furnace) fac.getState();
435434

@@ -459,7 +458,7 @@ private void startPipe(Block block, List<ItemStack> items, boolean request) {
459458
leftovers.add(ItemUtil.addToStack(f.getInventory().getResult(), item));
460459
}
461460
} else f.getInventory().setResult(null);
462-
} else if (fac.getType() == Material.JUKEBOX) {
461+
} else if (facType == Material.JUKEBOX) {
463462

464463
Jukebox juke = (Jukebox) fac.getState();
465464

craftbook-bukkit/src/main/java/org/enginehub/craftbook/util/SignUtil.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
package org.enginehub.craftbook.util;
1717

18+
import org.bukkit.Material;
1819
import org.bukkit.Tag;
1920
import org.bukkit.block.Block;
2021
import org.bukkit.block.BlockFace;
@@ -55,7 +56,11 @@ public static boolean isStandingSign(Block block) {
5556
}
5657

5758
public static boolean isWallSign(Block block) {
58-
return Tag.WALL_SIGNS.isTagged(block.getType());
59+
return isWallSign(block.getType());
60+
}
61+
62+
public static boolean isWallSign(Material type) {
63+
return Tag.WALL_SIGNS.isTagged(type);
5964
}
6065

6166
/**

0 commit comments

Comments
 (0)