Skip to content

Commit

Permalink
Merge branch 'master' into cleanup/commands
Browse files Browse the repository at this point in the history
  • Loading branch information
WalshyDev authored Feb 11, 2024
2 parents 4801a32 + 98bc59e commit 45676bb
Show file tree
Hide file tree
Showing 34 changed files with 714 additions and 94 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/discord-webhook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
architecture: x64

- name: Cache Maven packages
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/maven-compiler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
architecture: x64

- name: Cache Maven packages
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
architecture: x64

- name: Cache Maven packages
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/sonarcloud.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ jobs:
architecture: x64

- name: Cache SonarCloud packages
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar

- name: Cache Maven packages
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/.settings/
/.idea/
/.vscode/
/data-store/
/data-storage/

dependency-reduced-pom.xml

Expand Down
71 changes: 71 additions & 0 deletions docs/sop/update.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Update Procedure

Date: 2024-01-15
Last updated: 2024-01-15

## Goal

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.

## Updating

### Updating Bukkit/Spigot

The first step is just updating Spigot in the pom.xml. This should only be done in 2 cases:
* There's a new major version (well, MC major - 1.19 -> 1.20 is a major)
* There was a change within MC or Bukkit/Spigot that broke the API

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`).

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.

### Updating tests

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.

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.

If you need any help fixing tests feel free to join the [Discord](https://discord.gg/slimefun).

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.

### Testing in game

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.

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:
* Commands, verify running a few commands work
* `/sf versions`
* `/sf cheat`
* `/sf search`
* Items, verify you can use a few items (you can grab these from `/sf cheat`)
* Wind staff
* One of the talismans
* One of the backpacks
* Blocks, verify you can place, break and ensure they all work
* Ancient altar
* Ore washer
* Coal generator

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.

Also make sure to verify that there are no errors in the console, any errors here should be investigated and fixed.

If you find any issues, please fix them and make sure to add a comment to the PR explaining why the fix was needed.

> **Note**
> 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.
### Final steps

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 :)

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.

#### Updating E2E tests

**This is only needed in a major version**

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.

Once updated, push and re-verify that the E2E tests are still passing.
57 changes: 39 additions & 18 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<maven.compiler.target>16</maven.compiler.target>

<!-- Spigot properties -->
<spigot.version>1.20</spigot.version>
<spigot.version>1.20.4</spigot.version>
<spigot.javadocs>https://hub.spigotmc.org/javadocs/spigot/</spigot.javadocs>

<!-- Default settings for sonarcloud.io -->
Expand Down Expand Up @@ -334,13 +334,7 @@
</build>

<dependencies>
<!-- Hard dependencies -->
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>${spigot.version}-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>


<!-- Development dependencies -->
<dependency>
Expand All @@ -355,7 +349,7 @@
<dependency>
<groupId>com.github.baked-libs.dough</groupId>
<artifactId>dough-api</artifactId>
<version>da42c2f268</version>
<version>1108163a49</version>
<scope>compile</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -389,7 +383,7 @@
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>5.8.0</version>
<version>5.9.0</version>
<scope>test</scope>
</dependency>
<dependency>
Expand All @@ -398,10 +392,11 @@
<version>2.0.9</version>
<scope>test</scope>
</dependency>
<!-- This needs to be before Spigot because MockBukkit will fail otherwise. -->
<dependency>
<groupId>com.github.seeseemelk</groupId>
<artifactId>MockBukkit-v1.18</artifactId>
<version>2.0.0</version>
<artifactId>MockBukkit-v1.20</artifactId>
<version>3.65.0</version>
<scope>test</scope>

<exclusions>
Expand All @@ -411,8 +406,21 @@
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
</exclusion>
<exclusion>
<groupId>io.papermc.paper</groupId>
<artifactId>paper-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- Override MockBukkit's Paper to a pinned slightly older version -->
<!-- This is because MockBukkit currently fails after this PR: -->
<!-- https://github.com/PaperMC/Paper/pull/9629 -->
<dependency>
<groupId>io.papermc.paper</groupId>
<artifactId>paper-api</artifactId>
<version>1.20.4-R0.1-20240205.114523-90</version>
<scope>test</scope>
</dependency>

<!-- Third party plugin integrations / soft dependencies -->
<dependency>
Expand Down Expand Up @@ -513,18 +521,31 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.mojang</groupId>
<artifactId>authlib</artifactId>
<version>1.5.25</version>
<scope>provided</scope>
</dependency>
<!-- TODO: Remove this dependency -->
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>${spigot.version}-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.mojang</groupId>
<artifactId>authlib</artifactId>
<version>6.0.52</version>
<scope>provided</scope>
<exclusions>
<exclusion>
<!-- We don't need any of the dependencies -->
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package io.github.thebusybiscuit.slimefun4.api.events;

import javax.annotation.Nonnull;

import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;

import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;


/**
* This {@link Event} is fired after {@link Slimefun} finishes loading the
* {@link SlimefunItem} registry. We recommend listening to this event if you
* want to register recipes using items from other addons.
*
* @author ProfElements
*/
public class SlimefunItemRegistryFinalizedEvent extends Event {

private static final HandlerList handlers = new HandlerList();

public SlimefunItemRegistryFinalizedEvent() {}

@Nonnull
public static HandlerList getHandlerList() {
return handlers;
}

@Nonnull
@Override
public HandlerList getHandlers() {
return getHandlerList();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1199,7 +1199,7 @@ public final int hashCode() {
* The {@link ItemStack} to check
* @return The {@link Optional} {@link SlimefunItem} associated with this {@link ItemStack} if present, otherwise empty
*/
public @Nonnull Optional<SlimefunItem> getOptionalByItem(@Nullable ItemStack item) {
public static @Nonnull Optional<SlimefunItem> getOptionalByItem(@Nullable ItemStack item) {
return Optional.ofNullable(getByItem(item));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import java.util.Set;
import java.util.UUID;
import java.util.function.Consumer;
import java.util.stream.IntStream;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
Expand All @@ -35,6 +34,8 @@
import io.github.thebusybiscuit.slimefun4.api.researches.Research;
import io.github.thebusybiscuit.slimefun4.core.attributes.ProtectionType;
import io.github.thebusybiscuit.slimefun4.core.attributes.ProtectiveArmor;
import io.github.thebusybiscuit.slimefun4.core.debug.Debug;
import io.github.thebusybiscuit.slimefun4.core.debug.TestCase;
import io.github.thebusybiscuit.slimefun4.core.guide.GuideHistory;
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
import io.github.thebusybiscuit.slimefun4.implementation.items.armor.SlimefunArmorPiece;
Expand Down Expand Up @@ -91,7 +92,10 @@ protected PlayerProfile(@Nonnull OfflinePlayer p, PlayerData data) {
* Only intended for internal usage.
*
* @return The {@link Config} associated with this {@link PlayerProfile}
*
* @deprecated Look at {@link PlayerProfile#getPlayerData()} instead for reading data.
*/
@Deprecated
public @Nonnull Config getConfig() {
return configFile;
}
Expand Down Expand Up @@ -234,21 +238,22 @@ public void removeWaypoint(@Nonnull Waypoint waypoint) {
* The profile can then be removed from RAM.
*/
public final void markForDeletion() {
Debug.log(TestCase.PLAYER_PROFILE_DATA, "Marking {} ({}) profile for deletion", name, ownerId);
markedForDeletion = true;
}

/**
* Call this method if this Profile has unsaved changes.
*/
public final void markDirty() {
Debug.log(TestCase.PLAYER_PROFILE_DATA, "Marking {} ({}) profile as dirty", name, ownerId);
dirty = true;
}

public @Nonnull PlayerBackpack createBackpack(int size) {
IntStream stream = IntStream.iterate(0, i -> i + 1).filter(i -> !configFile.contains("backpacks." + i + ".size"));
int id = stream.findFirst().getAsInt();
int nextId = this.data.getBackpacks().size(); // Size is not 0 indexed so next ID can just be the current size

PlayerBackpack backpack = PlayerBackpack.newBackpack(this.ownerId, id, size);
PlayerBackpack backpack = PlayerBackpack.newBackpack(this.ownerId, nextId, size);
this.data.addBackpack(backpack);

markDirty();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
import io.github.thebusybiscuit.slimefun4.api.researches.Research;
import io.github.thebusybiscuit.slimefun4.core.debug.TestCase;
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;

class SlimefunTabCompleter implements TabCompleter {
Expand All @@ -34,6 +35,13 @@ public SlimefunTabCompleter(@Nonnull SlimefunCommand command) {
public @Nullable List<String> onTabComplete(CommandSender sender, Command cmd, String label, String[] args) {
if (args.length == 1) {
return createReturnList(command.getSubCommandNames(), args[0]);
} else if (args.length == 2) {
if (args[0].equalsIgnoreCase("debug")) {
return createReturnList(TestCase.VALUES_LIST, args[1]);
} else {
// Returning null will make it fallback to the default arguments (all online players)
return null;
}
} else if (args.length == 3) {
if (args[0].equalsIgnoreCase("give")) {
return createReturnList(getSlimefunItems(), args[2]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,26 @@ public void onExecute(CommandSender sender, String[] args) {
.append(serverSoftware)
.color(ChatColor.GREEN)
.append(" " + Bukkit.getVersion() + '\n')
.color(ChatColor.DARK_GREEN)
.append("Slimefun ")
.color(ChatColor.GREEN)
.append(Slimefun.getVersion() + '\n')
.color(ChatColor.DARK_GREEN);

builder
.append("Slimefun ")
.color(ChatColor.GREEN)
.append(Slimefun.getVersion())
.color(ChatColor.DARK_GREEN);

if (!Slimefun.getUpdater().isLatestVersion()) {
builder
.append(" (").color(ChatColor.GRAY)
.append("Update available").color(ChatColor.RED).event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text(
"Your Slimefun version is out of date!\n" +
"Please update to get the latest bug fixes and performance improvements.\n" +
"Please do not report any bugs without updating first."
)))
.append(")").color(ChatColor.GRAY);
}

builder.append("\n");
// @formatter:on

if (Slimefun.getMetricsService().getVersion() != null) {
Expand Down
Loading

0 comments on commit 45676bb

Please sign in to comment.