Skip to content

Commit 8fdd3da

Browse files
authored
Merge branch 'Slimefun:master' into master
2 parents 59b41d5 + eb4d23e commit 8fdd3da

12 files changed

Lines changed: 144 additions & 57 deletions

File tree

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
/.settings/
66
/.idea/
77
/.vscode/
8-
/data-store/
8+
/data-storage/
99

1010
dependency-reduced-pom.xml
1111

docs/sop/update.md

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# Update Procedure
2+
3+
Date: 2024-01-15
4+
Last updated: 2024-01-15
5+
6+
## Goal
7+
8+
This SOP will go over updating Slimefun to the newest Minecraft version, most of this will only apply to major versions, but we have also seen minor versions break things. So please read through the whole SOP and make sure you do everything applicable.
9+
10+
## Updating
11+
12+
### Updating Bukkit/Spigot
13+
14+
The first step is just updating Spigot in the pom.xml. This should only be done in 2 cases:
15+
* There's a new major version (well, MC major - 1.19 -> 1.20 is a major)
16+
* There was a change within MC or Bukkit/Spigot that broke the API
17+
18+
To update the Spigot version, you will need to go to the `pom.xml` and find the `spigot.version` property, this will be within the `properties` property. Simply make this the MC version (e.g. `1.20` or in the case of minor `1.20.4`).
19+
20+
Once updated, **make sure to run a build** to check for compilation failures with `mvn clean package -DskipTests=true`. We will go over the tests next.
21+
22+
### Updating tests
23+
24+
The next step is making sure our tests are still working correctly as is. This can be done by running `mvn test` and verifying that all tests pass correctly without any failures or errors.
25+
26+
If there are any failures you will need to investigate these, it's best to run them one at a time, so you don't have the potential for cross-test contamination. If you find any issues with the tests, please fix them and make sure to add a comment to the PR explaining why the test was changed.
27+
28+
If you need any help fixing tests feel free to join the [Discord](https://discord.gg/slimefun).
29+
30+
Once all the tests are passed, check to see if there's a new version of [MockBukkit](https://github.com/MockBukkit/MockBukkit), this is the framework handling the Bukkit side of our tests. There very well may not be a new version, they usually lag updates a bit. If not, that's perfectly ok, just make sure to note it on the PR.
31+
32+
### Testing in game
33+
34+
The final and most important step is testing this in game. While I'd love for our tests to be perfect, they are not (especially if MockBukkit hasn't had an update yet). We need to ensure that everything is working in-game before we can ship a new version release.
35+
36+
To do this, you will need to build the plugin with `mvn clean package` and then copy the jar from `target/` to your server's `plugins/` folder. Once you've done this, start the server. You will want to test various things but the things we always want covered are:
37+
* Commands, verify running a few commands work
38+
* `/sf versions`
39+
* `/sf cheat`
40+
* `/sf search`
41+
* Items, verify you can use a few items (you can grab these from `/sf cheat`)
42+
* Wind staff
43+
* One of the talismans
44+
* One of the backpacks
45+
* Blocks, verify you can place, break and ensure they all work
46+
* Ancient altar
47+
* Ore washer
48+
* Coal generator
49+
50+
It is important to verify heads are still working (part of the energy network and the coal generator). If head skins are not loading, consider it as a bug: try figuring out what the issue is, and ask in the [Discord](https://discord.gg/slimefun) if you are not sure what the cause may be.
51+
52+
Also make sure to verify that there are no errors in the console, any errors here should be investigated and fixed.
53+
54+
If you find any issues, please fix them and make sure to add a comment to the PR explaining why the fix was needed.
55+
56+
> **Note**
57+
> An issue here usually means that we need to update Dough. If this is the case, please open a PR to Dough and then update the Dough version in the `pom.xml` to the new version. Once you've done this, make sure to run a build to verify everything is working correctly.
58+
59+
### Final steps
60+
61+
Once you've verified everything is working, you can go ahead and open the PR. We will get to this as soon as we can :)
62+
63+
While the PR is open, make sure to verify the E2E tests are passing, and you should also verify the output of these. If the E2E tests look good then finally we will update these.
64+
65+
#### Updating E2E tests
66+
67+
**This is only needed in a major version**
68+
69+
In the `e2e-testing.yml` file you will need to update the matrix strategy, please add the latest version of the old major (e.g. if 1.21 came out, add 1.20.x where x is the latest released version). If MC is requiring a new Java version make sure that is updated too in the `latest` version.
70+
71+
Once updated, push and re-verify that the E2E tests are still passing.

pom.xml

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
<maven.compiler.target>16</maven.compiler.target>
2727

2828
<!-- Spigot properties -->
29-
<spigot.version>1.20</spigot.version>
29+
<spigot.version>1.20.4</spigot.version>
3030
<spigot.javadocs>https://hub.spigotmc.org/javadocs/spigot/</spigot.javadocs>
3131

3232
<!-- Default settings for sonarcloud.io -->
@@ -334,13 +334,7 @@
334334
</build>
335335

336336
<dependencies>
337-
<!-- Hard dependencies -->
338-
<dependency>
339-
<groupId>org.spigotmc</groupId>
340-
<artifactId>spigot-api</artifactId>
341-
<version>${spigot.version}-R0.1-SNAPSHOT</version>
342-
<scope>provided</scope>
343-
</dependency>
337+
344338

345339
<!-- Development dependencies -->
346340
<dependency>
@@ -355,7 +349,7 @@
355349
<dependency>
356350
<groupId>com.github.baked-libs.dough</groupId>
357351
<artifactId>dough-api</artifactId>
358-
<version>c4231a4d1a</version>
352+
<version>a2364de77c</version>
359353
<scope>compile</scope>
360354
</dependency>
361355
<dependency>
@@ -398,10 +392,11 @@
398392
<version>2.0.9</version>
399393
<scope>test</scope>
400394
</dependency>
395+
<!-- This needs to be before Spigot because MockBukkit will fail otherwise. -->
401396
<dependency>
402397
<groupId>com.github.seeseemelk</groupId>
403-
<artifactId>MockBukkit-v1.18</artifactId>
404-
<version>2.0.0</version>
398+
<artifactId>MockBukkit-v1.20</artifactId>
399+
<version>3.65.0</version>
405400
<scope>test</scope>
406401

407402
<exclusions>
@@ -513,18 +508,31 @@
513508
</exclusion>
514509
</exclusions>
515510
</dependency>
516-
<dependency>
517-
<groupId>com.mojang</groupId>
518-
<artifactId>authlib</artifactId>
519-
<version>1.5.25</version>
520-
<scope>provided</scope>
521-
</dependency>
522511
<!-- TODO: Remove this dependency -->
523512
<dependency>
524513
<groupId>commons-lang</groupId>
525514
<artifactId>commons-lang</artifactId>
526515
<version>2.6</version>
527516
<scope>compile</scope>
528517
</dependency>
518+
<dependency>
519+
<groupId>org.spigotmc</groupId>
520+
<artifactId>spigot-api</artifactId>
521+
<version>${spigot.version}-R0.1-SNAPSHOT</version>
522+
<scope>provided</scope>
523+
</dependency>
524+
<dependency>
525+
<groupId>com.mojang</groupId>
526+
<artifactId>authlib</artifactId>
527+
<version>6.0.52</version>
528+
<scope>provided</scope>
529+
<exclusions>
530+
<exclusion>
531+
<!-- We don't need any of the dependencies -->
532+
<groupId>*</groupId>
533+
<artifactId>*</artifactId>
534+
</exclusion>
535+
</exclusions>
536+
</dependency>
529537
</dependencies>
530538
</project>

src/main/java/io/github/thebusybiscuit/slimefun4/implementation/Slimefun.java

Lines changed: 10 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
import javax.annotation.Nonnull;
1515
import javax.annotation.Nullable;
16-
import javax.annotation.ParametersAreNonnullByDefault;
1716

1817
import io.github.thebusybiscuit.slimefun4.storage.Storage;
1918
import io.github.thebusybiscuit.slimefun4.storage.backend.legacy.LegacyStorage;
@@ -29,7 +28,6 @@
2928
import org.bukkit.plugin.Plugin;
3029
import org.bukkit.plugin.PluginDescriptionFile;
3130
import org.bukkit.plugin.java.JavaPlugin;
32-
import org.bukkit.plugin.java.JavaPluginLoader;
3331
import org.bukkit.scheduler.BukkitTask;
3432

3533
import io.github.bakedlibs.dough.config.Config;
@@ -120,17 +118,16 @@
120118
import io.github.thebusybiscuit.slimefun4.implementation.setup.PostSetup;
121119
import io.github.thebusybiscuit.slimefun4.implementation.setup.ResearchSetup;
122120
import io.github.thebusybiscuit.slimefun4.implementation.setup.SlimefunItemSetup;
121+
import io.github.thebusybiscuit.slimefun4.implementation.tasks.SlimefunStartupTask;
122+
import io.github.thebusybiscuit.slimefun4.implementation.tasks.TickerTask;
123123
import io.github.thebusybiscuit.slimefun4.implementation.tasks.armor.RadiationTask;
124124
import io.github.thebusybiscuit.slimefun4.implementation.tasks.armor.RainbowArmorTask;
125125
import io.github.thebusybiscuit.slimefun4.implementation.tasks.armor.SlimefunArmorTask;
126126
import io.github.thebusybiscuit.slimefun4.implementation.tasks.armor.SolarHelmetTask;
127-
import io.github.thebusybiscuit.slimefun4.implementation.tasks.SlimefunStartupTask;
128-
import io.github.thebusybiscuit.slimefun4.implementation.tasks.TickerTask;
129127
import io.github.thebusybiscuit.slimefun4.integrations.IntegrationsManager;
130128
import io.github.thebusybiscuit.slimefun4.utils.NumberUtils;
131129
import io.github.thebusybiscuit.slimefun4.utils.tags.SlimefunTag;
132130
import io.papermc.lib.PaperLib;
133-
134131
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.MenuListener;
135132
import me.mrCookieSlime.Slimefun.api.BlockStorage;
136133
import me.mrCookieSlime.Slimefun.api.inventory.UniversalBlockMenu;
@@ -141,7 +138,7 @@
141138
*
142139
* @author TheBusyBiscuit
143140
*/
144-
public final class Slimefun extends JavaPlugin implements SlimefunAddon {
141+
public class Slimefun extends JavaPlugin implements SlimefunAddon {
145142

146143
/**
147144
* This is the Java version we recommend server owners to use.
@@ -209,30 +206,17 @@ public final class Slimefun extends JavaPlugin implements SlimefunAddon {
209206
private final SlimefunBowListener bowListener = new SlimefunBowListener();
210207

211208
/**
212-
* Our default constructor for {@link Slimefun}.
209+
* This constructor is invoked by Bukkit and within unit tests.
210+
* Therefore we need to figure out if we're within unit tests or not.
213211
*/
214212
public Slimefun() {
215213
super();
216-
}
217214

218-
/**
219-
* This constructor is invoked in Unit Test environments only.
220-
*
221-
* @param loader
222-
* Our {@link JavaPluginLoader}
223-
* @param description
224-
* A {@link PluginDescriptionFile}
225-
* @param dataFolder
226-
* The data folder
227-
* @param file
228-
* A {@link File} for this {@link Plugin}
229-
*/
230-
@ParametersAreNonnullByDefault
231-
public Slimefun(JavaPluginLoader loader, PluginDescriptionFile description, File dataFolder, File file) {
232-
super(loader, description, dataFolder, file);
233-
234-
// This is only invoked during a Unit Test
235-
minecraftVersion = MinecraftVersion.UNIT_TEST;
215+
// Check that we got loaded by MockBukkit rather than Bukkit's loader
216+
// TODO: This is very much a hack and we can hopefully move to a more native way in the future
217+
if (getClassLoader().getClass().getPackageName().startsWith("be.seeseemelk.mockbukkit")) {
218+
minecraftVersion = MinecraftVersion.UNIT_TEST;
219+
}
236220
}
237221

238222
/**
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package io.github.thebusybiscuit.slimefun4.utils;
2+
3+
import java.io.File;
4+
5+
public class FileUtils {
6+
7+
public static boolean deleteDirectory(File folder) {
8+
if (folder.isDirectory()) {
9+
File[] files = folder.listFiles();
10+
11+
if (files != null) {
12+
for (File file : files) {
13+
// Recursive call to delete files and subfolders
14+
if (!deleteDirectory(file)) {
15+
return false;
16+
}
17+
}
18+
}
19+
}
20+
21+
// Delete the folder itself
22+
return folder.delete();
23+
}
24+
}

src/test/java/io/github/thebusybiscuit/slimefun4/api/events/TestSlimefunBlockPlaceEvent.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ void testEventIsFired() {
6565
int x = TestUtilities.randomInt();
6666
int z = TestUtilities.randomInt();
6767
Block block = new BlockMock(Material.GREEN_TERRACOTTA, new Location(world, x, 0, z));
68-
Block blockAgainst = new BlockMock(Material.GRASS, new Location(world, x, 1, z));
68+
Block blockAgainst = new BlockMock(Material.GRASS_BLOCK, new Location(world, x, 1, z));
6969

7070
Slimefun.getRegistry().getWorlds().put("my_world", new BlockStorage(world));
7171

@@ -88,7 +88,7 @@ void testGetters() {
8888
int x = TestUtilities.randomInt();
8989
int z = TestUtilities.randomInt();
9090
Block block = new BlockMock(Material.GREEN_TERRACOTTA, new Location(world, x, 0, z));
91-
Block blockAgainst = new BlockMock(Material.GRASS, new Location(world, x, 1, z));
91+
Block blockAgainst = new BlockMock(Material.GRASS_BLOCK, new Location(world, x, 1, z));
9292

9393
Slimefun.getRegistry().getWorlds().put("my_world", new BlockStorage(world));
9494

@@ -125,7 +125,7 @@ public void onBlockPlace(SlimefunBlockPlaceEvent event) {
125125
int x = TestUtilities.randomInt();
126126
int z = TestUtilities.randomInt();
127127
Block block = new BlockMock(Material.GREEN_TERRACOTTA, new Location(world, x, 0, z));
128-
Block blockAgainst = new BlockMock(Material.GRASS, new Location(world, x, 1, z));
128+
Block blockAgainst = new BlockMock(Material.GRASS_BLOCK, new Location(world, x, 1, z));
129129

130130
Slimefun.getRegistry().getWorlds().put("my_world", new BlockStorage(world));
131131

@@ -153,7 +153,7 @@ void testBlockPlacementBeforeFullDeletion() {
153153
int x = TestUtilities.randomInt();
154154
int z = TestUtilities.randomInt();
155155
Block firstBlock = new BlockMock(Material.GREEN_TERRACOTTA, new Location(world, x, 0, z));
156-
Block firstBlockAgainst = new BlockMock(Material.GRASS, new Location(world, x, 1, z));
156+
Block firstBlockAgainst = new BlockMock(Material.GRASS_BLOCK, new Location(world, x, 1, z));
157157

158158
Slimefun.getRegistry().getWorlds().put("my_world", new BlockStorage(world));
159159

@@ -176,7 +176,7 @@ void testBlockPlacementBeforeFullDeletion() {
176176

177177
// Place second block in the same location
178178
Block secondBlock = new BlockMock(Material.GREEN_TERRACOTTA, new Location(world, x, 0, z));
179-
Block secondBlockAgainst = new BlockMock(Material.GRASS, new Location(world, x, 1, z));
179+
Block secondBlockAgainst = new BlockMock(Material.GRASS_BLOCK, new Location(world, x, 1, z));
180180

181181
BlockPlaceEvent secondBlockPlaceEvent = new BlockPlaceEvent(
182182
secondBlock, secondBlock.getState(), secondBlockAgainst, itemStack, player, true, EquipmentSlot.HAND

src/test/java/io/github/thebusybiscuit/slimefun4/api/events/TestTalismanActivateEvent.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ void activateAnvilTalisman(boolean enderVariant, boolean inEnderChest) {
5555
ItemStack breakableItem = new ItemStack(Material.IRON_PICKAXE);
5656

5757
if (inEnderChest) {
58-
player.getEnderChest().addItem(talismanItem);
58+
player.getEnderChest().setItem(9, talismanItem);
5959
} else {
60-
player.getInventory().addItem(talismanItem);
60+
player.getInventory().setItem(9, talismanItem);
6161
}
6262

6363
player.getInventory().setItemInMainHand(breakableItem);

src/test/java/io/github/thebusybiscuit/slimefun4/api/gps/TestWaypoints.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import java.io.File;
44
import java.io.IOException;
55

6-
import org.apache.commons.io.FileUtils;
76
import org.bukkit.entity.Player;
87
import org.junit.jupiter.api.AfterAll;
98
import org.junit.jupiter.api.Assertions;
@@ -15,6 +14,7 @@
1514
import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile;
1615
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
1716
import io.github.thebusybiscuit.slimefun4.test.TestUtilities;
17+
import io.github.thebusybiscuit.slimefun4.utils.FileUtils;
1818

1919
import be.seeseemelk.mockbukkit.MockBukkit;
2020
import be.seeseemelk.mockbukkit.ServerMock;

src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestCargoNodeListener.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ void testGrassPlacement() {
8484

8585
Location l = new Location(player.getWorld(), 300, 25, 1200);
8686
Block b = l.getBlock();
87-
b.setType(Material.GRASS);
87+
b.setType(Material.GRASS_BLOCK);
8888

8989
ItemGroup itemGroup = TestUtilities.getItemGroup(plugin, "cargo_test");
9090
SlimefunItemStack item = new SlimefunItemStack("MOCK_CARGO_NODE_2", new CustomItemStack(Material.PLAYER_HEAD, "&4Cargo node!"));

src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestSlimefunGuideListener.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ void testFirstJoin(boolean hasPlayedBefore, boolean giveSlimefunGuide) {
4545
PlayerMock player = new PlayerMock(server, "CanIHazGuide");
4646

4747
if (hasPlayedBefore) {
48-
player.setLastPlayed(System.currentTimeMillis());
48+
server.getPlayerList().setLastSeen(player.getUniqueId(), System.currentTimeMillis());
4949
}
5050

5151
PlayerJoinEvent event = new PlayerJoinEvent(player, "CanIHazGuide has joined and wants sum guide");

0 commit comments

Comments
 (0)