Skip to content

Commit 744e166

Browse files
authored
Update to 1.21.11, swap to Paper (#173)
1 parent 92cbb3b commit 744e166

42 files changed

Lines changed: 1827 additions & 831 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/auto-merge-dependabot.yml

Lines changed: 0 additions & 15 deletions
This file was deleted.

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ on:
88
jobs:
99
build:
1010
runs-on: ubuntu-latest
11-
name: Build Java 17
11+
name: Build Java 21
1212
steps:
1313
- uses: actions/checkout@v4
1414

1515
- name: Set up JDK
1616
uses: actions/setup-java@v4
1717
with:
1818
distribution: 'adopt'
19-
java-version: '17'
19+
java-version: '21'
2020
cache: 'maven'
2121

2222
- name: Cache SonarCloud packages

.github/workflows/pull_request.yml

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,33 @@ on:
66
jobs:
77
run-ci:
88
uses: Jikoo/PlanarActions/.github/workflows/ci_maven.yml@master
9-
store-dependabot-pr-data:
10-
if: "github.actor == 'dependabot[bot]' && github.event_name == 'pull_request'"
11-
uses: Jikoo/PlanarActions/.github/workflows/pr_automerge_prep.yml@master
12-
with:
13-
pr-number: ${{ github.event.number }}
9+
approve-and-merge-dependabot:
10+
if: "github.event_name == 'pull_request' && github.event.pull_request.user.login == 'dependabot[bot]'"
11+
needs: [ "run-ci" ]
12+
runs-on: "ubuntu-latest"
13+
permissions:
14+
contents: write
15+
pull-requests: write
16+
steps:
17+
# Always approve PRs from Dependabot.
18+
- name: Approve
19+
run: gh pr review --approve "$PR_URL"
20+
env:
21+
PR_URL: ${{github.event.pull_request.html_url}}
22+
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}
23+
24+
# Fetch Dependabot metadata for finer decisionmaking later.
25+
- name: Fetch Dependabot metadata
26+
id: metadata
27+
uses: dependabot/fetch-metadata@21025c705c08248db411dc16f3619e6b5f9ea21a
28+
with:
29+
github-token: "${{ secrets.GITHUB_TOKEN }}"
30+
31+
# Enable auto-merge for the PR.
32+
# Auto-merge is used rather than a direct merge so that any other required checks can pass.
33+
- name: Enable auto-merge for minor/patch updates
34+
if: steps.metadata.outputs.update-type == 'version-update:semver-patch' || steps.metadata.outputs.update-type == 'version-update:semver-minor'
35+
run: gh pr merge --auto --squash "$PR_URL"
36+
env:
37+
PR_URL: ${{github.event.pull_request.html_url}}
38+
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}

appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ install:
2222
build_script:
2323
- mvn clean package -B -DskipTests
2424
test_script:
25-
- mvn surefire:test -B
25+
- mvn dependency:properties surefire:test -B
2626
cache:
2727
- C:\Users\appveyor\.m2
2828
artifacts:

pom.xml

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,23 @@
77
<groupId>com.github.jikoo</groupId>
88
<artifactId>enchantableblocks</artifactId>
99
<name>EnchantableBlocks</name>
10-
<version>4.1.1-SNAPSHOT</version>
10+
<version>5.0.0-SNAPSHOT</version>
1111
<packaging>jar</packaging>
1212

1313
<properties>
1414
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1515
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
16-
<maven.compiler.source>17</maven.compiler.source>
17-
<maven.compiler.target>17</maven.compiler.target>
18-
<maven.compiler.release>17</maven.compiler.release>
16+
<maven.compiler.release>21</maven.compiler.release>
1917
<versions.fastutil>8.5.18</versions.fastutil>
18+
<!-- Required so ${argLine} can be evaluated and edited by plugins (i.e. jacoco) before surefire -->
19+
<argLine/>
2020
</properties>
2121

2222
<profiles>
2323
<profile>
2424
<id>sonarcloud</id>
2525
<properties>
26-
<maven.compiler.source>17</maven.compiler.source>
27-
<maven.compiler.target>17</maven.compiler.target>
28-
<sonar.projectKey>Jikoo_EnchantableBlocks</sonar.projectKey>
26+
<sonar.projectKey>jikoo_enchantableblocks</sonar.projectKey>
2927
<sonar.organization>jikoo</sonar.organization>
3028
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
3129
<sonar.language>java</sonar.language>
@@ -61,8 +59,8 @@
6159

6260
<repositories>
6361
<repository>
64-
<id>spigot-repo</id>
65-
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
62+
<id>papermc</id>
63+
<url>https://repo.papermc.io/repository/maven-public/</url>
6664
</repository>
6765
<repository>
6866
<id>jitpack.io</id>
@@ -78,9 +76,9 @@
7876
<scope>provided</scope>
7977
</dependency>
8078
<dependency>
81-
<groupId>org.spigotmc</groupId>
82-
<artifactId>spigot-api</artifactId>
83-
<version>1.21-R0.1-SNAPSHOT</version>
79+
<groupId>io.papermc.paper</groupId>
80+
<artifactId>paper-api</artifactId>
81+
<version>1.21.11-R0.1-SNAPSHOT</version>
8482
<scope>provided</scope>
8583
</dependency>
8684
<dependency>
@@ -93,7 +91,7 @@
9391
<dependency>
9492
<groupId>com.github.jikoo</groupId>
9593
<artifactId>planarenchanting</artifactId>
96-
<version>2.0.1</version>
94+
<version>fe946163f8</version>
9795
<scope>compile</scope>
9896
</dependency>
9997
<dependency>
@@ -144,13 +142,25 @@
144142
<artifactId>maven-compiler-plugin</artifactId>
145143
<version>3.14.1</version>
146144
</plugin>
145+
<plugin>
146+
<groupId>org.apache.maven.plugins</groupId>
147+
<artifactId>maven-dependency-plugin</artifactId>
148+
<executions>
149+
<execution>
150+
<goals>
151+
<goal>properties</goal>
152+
</goals>
153+
</execution>
154+
</executions>
155+
</plugin>
147156
<plugin>
148157
<groupId>org.apache.maven.plugins</groupId>
149158
<artifactId>maven-surefire-plugin</artifactId>
150159
<version>3.5.4</version>
151160
<configuration>
152161
<forkCount>2</forkCount>
153162
<reuseForks>false</reuseForks>
163+
<argLine>@{argLine} -javaagent:${org.mockito:mockito-core:jar} -Xshare:off</argLine>
154164
</configuration>
155165
</plugin>
156166
<plugin>
@@ -165,11 +175,6 @@
165175
</goals>
166176
<configuration>
167177
<minimizeJar>true</minimizeJar>
168-
<!--
169-
~ Unfortunately, the minimizeJar option actually breaks build.
170-
~ As a (hopefully temporary) workaround, explicitly declare classes used.
171-
~ Watch MSHADE-366 for a fix.
172-
-->
173178
<filters>
174179
<filter>
175180
<artifact>com.github.jikoo:*</artifact>

readme.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
## EnchantableBlocks
22
[![Build](https://github.com/Jikoo/EnchantableBlocks/actions/workflows/ci.yml/badge.svg)](https://github.com/Jikoo/EnchantableBlocks/actions/workflows/ci.yml)
3-
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=Jikoo_EnchantableBlocks&metric=alert_status)](https://sonarcloud.io/dashboard?id=Jikoo_EnchantableBlocks)
4-
[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=Jikoo_EnchantableBlocks&metric=coverage)](https://sonarcloud.io/dashboard?id=Jikoo_EnchantableBlocks)
5-
[![Reliability Rating](https://sonarcloud.io/api/project_badges/measure?project=Jikoo_EnchantableBlocks&metric=reliability_rating)](https://sonarcloud.io/dashboard?id=Jikoo_EnchantableBlocks)
3+
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=jikoo_enchantableblocks&metric=alert_status)](https://sonarcloud.io/dashboard?id=jikoo_enchantableblocks)
4+
[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=jikoo_enchantableblocks&metric=coverage)](https://sonarcloud.io/dashboard?id=jikoo_enchantableblocks)
5+
[![Reliability Rating](https://sonarcloud.io/api/project_badges/measure?project=jikoo_enchantableblocks&metric=reliability_rating)](https://sonarcloud.io/dashboard?id=jikoo_enchantableblocks)
66

77
EnchantableBlocks is a Bukkit plugin adding effects for enchantments on blocks.
88

src/main/java/com/github/jikoo/enchantableblocks/EnchantableBlocksPlugin.java

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,11 @@
55
import com.github.jikoo.enchantableblocks.listener.TableEnchanter;
66
import com.github.jikoo.enchantableblocks.listener.WorldListener;
77
import com.github.jikoo.enchantableblocks.registry.EnchantableBlockManager;
8-
import java.io.File;
98
import org.bukkit.Chunk;
109
import org.bukkit.World;
1110
import org.bukkit.command.Command;
1211
import org.bukkit.command.CommandSender;
13-
import org.bukkit.plugin.PluginDescriptionFile;
1412
import org.bukkit.plugin.java.JavaPlugin;
15-
import org.bukkit.plugin.java.JavaPluginLoader;
1613
import org.jetbrains.annotations.NotNull;
1714

1815
/**
@@ -22,25 +19,22 @@ public class EnchantableBlocksPlugin extends JavaPlugin {
2219

2320
private EnchantableBlockManager blockManager;
2421

25-
public EnchantableBlocksPlugin() {
26-
super();
27-
}
28-
29-
public EnchantableBlocksPlugin(
30-
@NotNull JavaPluginLoader loader,
31-
@NotNull PluginDescriptionFile description,
32-
@NotNull File dataFolder,
33-
@NotNull File file) {
34-
super(loader, description, dataFolder, file);
35-
}
36-
3722
@Override
3823
public void onLoad() {
3924
this.blockManager = new EnchantableBlockManager(this);
4025
}
4126

4227
@Override
4328
public void onEnable() {
29+
try {
30+
Class.forName("io.papermc.paper.configuration.ServerConfiguration");
31+
} catch (ClassNotFoundException e) {
32+
getLogger().severe("EnchantableBlocks requires Paper; Spigot's enchantment API is missing features.");
33+
getLogger().severe("Please vote for https://hub.spigotmc.org/jira/browse/SPIGOT-7838 for Spigot support.");
34+
getServer().getPluginManager().disablePlugin(this);
35+
return;
36+
}
37+
4438
this.saveDefaultConfig();
4539

4640
// Register generic listeners for block management.
@@ -85,15 +79,15 @@ public boolean onCommand(
8579
@NotNull String label,
8680
@NotNull String @NotNull [] args) {
8781
if (args.length < 1 || !args[0].equalsIgnoreCase("reload")) {
88-
sender.sendMessage("EnchantableBlocks v" + getDescription().getVersion());
82+
sender.sendMessage("EnchantableBlocks v" + getPluginMeta().getVersion());
8983
return false;
9084
}
9185

9286
this.reloadConfig();
9387
this.blockManager.getRegistry().reload();
9488
sender.sendMessage(
9589
"[EnchantableBlocks v"
96-
+ getDescription().getVersion()
90+
+ getPluginMeta().getVersion()
9791
+ "] Reloaded config and registry cache.");
9892
return true;
9993
}

src/main/java/com/github/jikoo/enchantableblocks/block/impl/furnace/EnchantableFurnace.java

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -143,21 +143,25 @@ public boolean shouldPause(final @Nullable Event event) {
143143

144144
ItemStack input;
145145
ItemStack result;
146+
CookingRecipe<?> recipe;
146147
if (event instanceof FurnaceSmeltEvent smeltEvent) {
147148
// Special case FurnaceSmeltEvent: smelt has not completed, input and result are different.
148149
// Decrease input for post-smelt
149150
input = smeltEvent.getSource().clone();
150151
input.setAmount(input.getAmount() - 1);
151152
// Use post-smelt result
152153
result = smeltEvent.getResult();
154+
// FurnaceSmeltEvent is the only pause event that provides the active recipe.
155+
recipe = smeltEvent.getRecipe();
153156
} else {
154157
// In all other cases use current contents of furnace.
155158
FurnaceInventory inventory = furnace.getInventory();
156159
input = inventory.getSmelting();
157160
result = inventory.getResult();
161+
recipe = null;
158162
}
159163

160-
return shouldPause(furnace, input, result);
164+
return shouldPause(furnace, input, result, recipe);
161165
}
162166

163167
/**
@@ -172,7 +176,9 @@ public boolean shouldPause(final @Nullable Event event) {
172176
private boolean shouldPause(
173177
final @NotNull Furnace furnace,
174178
final @Nullable ItemStack input,
175-
final @Nullable ItemStack result) {
179+
final @Nullable ItemStack result,
180+
final @Nullable CookingRecipe<?> recipe
181+
) {
176182
if (!this.canPause()) {
177183
return false;
178184
}
@@ -182,13 +188,15 @@ private boolean shouldPause(
182188
return false;
183189
}
184190

185-
return isFreezableState(furnace.getInventory(), input, result);
191+
return isFreezableState(furnace.getInventory(), input, result, recipe);
186192
}
187193

188194
private boolean isFreezableState(
189195
final @NotNull FurnaceInventory inventory,
190196
final @Nullable ItemStack input,
191-
final @Nullable ItemStack result) {
197+
final @Nullable ItemStack result,
198+
@Nullable CookingRecipe<?> recipe
199+
) {
192200
// Is there no input?
193201
if (ItemUtil.isEmpty(input)) {
194202
return true;
@@ -202,7 +210,10 @@ private boolean isFreezableState(
202210
}
203211
}
204212

205-
CookingRecipe<?> recipe = getRegistration().getFurnaceRecipe(inventory);
213+
// If the recipe wasn't provided, look it up.
214+
if (recipe == null) {
215+
recipe = getRegistration().getFurnaceRecipe(inventory);
216+
}
206217

207218
// Does the current smelting item not have a recipe?
208219
if (recipe == null) {
@@ -263,7 +274,7 @@ public boolean resume(boolean checkState) {
263274
}
264275

265276
FurnaceInventory inventory = furnace.getInventory();
266-
if (checkState && isFreezableState(inventory, inventory.getSmelting(), inventory.getResult())) {
277+
if (checkState && isFreezableState(inventory, inventory.getSmelting(), inventory.getResult(), null)) {
267278
return false;
268279
}
269280

@@ -377,7 +388,7 @@ static void update(
377388

378389
plugin.getServer().getScheduler().runTask(plugin, () -> {
379390
boolean shouldPause =
380-
enchantableFurnace.shouldPause(furnace, inventory.getSmelting(), inventory.getResult());
391+
enchantableFurnace.shouldPause(furnace, inventory.getSmelting(), inventory.getResult(), null);
381392
if (enchantableFurnace.isPaused() == shouldPause) {
382393
enchantableFurnace.updating = false;
383394
return;

src/main/java/com/github/jikoo/enchantableblocks/block/impl/furnace/FurnaceListener.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package com.github.jikoo.enchantableblocks.block.impl.furnace;
22

33
import com.github.jikoo.enchantableblocks.registry.EnchantableBlockManager;
4-
import java.util.concurrent.ThreadLocalRandom;
5-
import java.util.function.IntSupplier;
64
import org.bukkit.block.Furnace;
75
import org.bukkit.event.EventHandler;
86
import org.bukkit.event.EventPriority;
@@ -19,6 +17,9 @@
1917
import org.jetbrains.annotations.NotNull;
2018
import org.jetbrains.annotations.VisibleForTesting;
2119

20+
import java.util.concurrent.ThreadLocalRandom;
21+
import java.util.function.IntSupplier;
22+
2223
/**
2324
* Listener for furnace-specific events.
2425
*/

0 commit comments

Comments
 (0)