1
mirror of https://github.com/StarWishsama/Slimefun4.git synced 2024-09-19 19:25:48 +00:00

Merge pull request #3369 from Slimefun/wip/1.18

Added 1.18 support
This commit is contained in:
TheBusyBiscuit 2021-12-18 13:01:49 +01:00 committed by GitHub
commit 863b8d6425
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 228 additions and 36 deletions

View File

@ -20,11 +20,11 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v2.4.0
- name: Set up Java JDK 11
- name: Set up Java JDK 16
uses: actions/setup-java@v2.4.0
with:
distribution: 'adopt'
java-version: '11'
java-version: '16'
java-package: jdk
architecture: x64

View File

@ -23,11 +23,13 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set up JDK 1.8
- name: Set up JDK 16
uses: actions/setup-java@v2.4.0
with:
distribution: 'adopt'
java-version: '8'
java-version: '16'
java-package: jdk
architecture: x64
- name: Cache Maven packages
uses: actions/cache@v2

View File

@ -20,11 +20,13 @@ jobs:
with:
fetch-depth: 0
- name: Set up JDK 11
- name: Set up JDK 16
uses: actions/setup-java@v2.4.0
with:
distribution: 'adopt'
java-version: '11'
java-version: '16'
java-package: jdk
architecture: x64
- name: Cache SonarCloud packages
uses: actions/cache@v2

View File

@ -36,6 +36,7 @@
* Added a ton of wiki links to the guide
* (API) Added "GRAVITY_AFFECTED_BLOCKS" tag
* (API) Added "Biome-Maps" for more in-depth GEO resource configuration (developers only for now)
* Added support for 1.18
#### Changes
* GEO resource distributions have been slightly adjusted

View File

@ -30,7 +30,7 @@ Here is a full summary of the differences between the two different versions of
| | development (latest) | "stable" |
| ------------------ | -------- | -------- |
| **Minecraft version(s)** | :video_game: **1.14.\* - 1.17.\*** | :video_game: **1.14.\* - 1.17.\*** |
| **Minecraft version(s)** | :video_game: **1.14.\* - 1.18.\*** | :video_game: **1.14.\* - 1.17.\*** |
| **automatic updates** | :heavy_check_mark: | :heavy_check_mark: |
| **frequent updates** | :heavy_check_mark: | :x: |
| **latest content** | :heavy_check_mark: | :x: |
@ -56,7 +56,7 @@ While "stable" builds most definitely contain more bugs than development builds
## :framed_picture: Screenshots
So what does Slimefun look like?<br>
Well, we asked some users on our [Discord server](#discord) to send us some screenshots, so see for yourself:
Well, we asked some users on our [Discord server](#headphones-discord) to send us some screenshots, so see for yourself:
| Reactors and electricity | Awesome factories | Magic and Altars |
| :-------------------------------------------: | :--------------------------------------: | :----------------------------------------: |
| ![](https://raw.githubusercontent.com/Slimefun/Slimefun-Wiki/master/images/showcase1.png) | ![](https://raw.githubusercontent.com/Slimefun/Slimefun-Wiki/master/images/showcase6.png) | ![](https://raw.githubusercontent.com/Slimefun/Slimefun-Wiki/master/images/showcase5.png) |

10
pom.xml
View File

@ -26,7 +26,7 @@
<maven.compiler.target>1.8</maven.compiler.target>
<!-- Spigot properties -->
<spigot.version>1.17</spigot.version>
<spigot.version>1.18.1</spigot.version>
<spigot.javadocs>https://hub.spigotmc.org/javadocs/spigot/</spigot.javadocs>
<!-- Default settings for sonarcloud.io -->
@ -350,7 +350,7 @@
<dependency>
<groupId>io.github.baked-libs</groupId>
<artifactId>dough-api</artifactId>
<version>1.0.3</version>
<version>1.1.1</version>
<scope>compile</scope>
</dependency>
<dependency>
@ -389,8 +389,8 @@
</dependency>
<dependency>
<groupId>com.github.seeseemelk</groupId>
<artifactId>MockBukkit-v1.16</artifactId>
<version>1.5.2</version>
<artifactId>MockBukkit-v1.18</artifactId>
<version>1.14.0</version>
<scope>test</scope>
<exclusions>
@ -503,4 +503,4 @@
</exclusions>
</dependency>
</dependencies>
</project>
</project>

View File

@ -40,10 +40,15 @@ public enum MinecraftVersion {
/**
* This constant represents Minecraft (Java Edition) Version 1.17
* (The "Caves and Cliffs: Part I" Update)
*
*/
MINECRAFT_1_17(17, "1.17.x"),
/**
* This constant represents Minecraft (Java Edition) Version 1.18
* (The "Caves and Cliffs: Part II" Update)
*/
MINECRAFT_1_18(18, "1.18.x"),
/**
* This constant represents an exceptional state in which we were unable
* to identify the Minecraft Version we are using

View File

@ -104,8 +104,7 @@ public class ResourceManager {
*
* @return An {@link OptionalInt}, either empty or containing the amount of the given {@link GEOResource}
*/
@Nonnull
public OptionalInt getSupplies(@Nonnull GEOResource resource, @Nonnull World world, int x, int z) {
public @Nonnull OptionalInt getSupplies(@Nonnull GEOResource resource, @Nonnull World world, int x, int z) {
Validate.notNull(resource, "Cannot get supplies for null");
Validate.notNull(world, "World must not be null");
@ -159,12 +158,12 @@ public class ResourceManager {
*
* @return The new supply value
*/
private int generate(@Nonnull GEOResource resource, @Nonnull World world, int x, int z) {
private int generate(@Nonnull GEOResource resource, @Nonnull World world, int x, int y, int z) {
Validate.notNull(resource, "Cannot generate resources for null");
Validate.notNull(world, "World cannot be null");
// Get the corresponding Block (and Biome)
Block block = world.getBlockAt(x << 4, 72, z << 4);
Block block = world.getBlockAt(x << 4, y, z << 4);
Biome biome = block.getBiome();
/*
@ -237,7 +236,7 @@ public class ResourceManager {
for (int i = page * 28; i < resources.size() && i < (page + 1) * 28; i++) {
GEOResource resource = resources.get(i);
OptionalInt optional = getSupplies(resource, block.getWorld(), x, z);
int supplies = optional.isPresent() ? optional.getAsInt() : generate(resource, block.getWorld(), x, z);
int supplies = optional.isPresent() ? optional.getAsInt() : generate(resource, block.getWorld(), x, block.getY(), z);
String suffix = Slimefun.getLocalization().getResourceString(p, supplies == 1 ? "tooltips.unit" : "tooltips.units");
ItemStack item = new CustomItemStack(resource.getItem(), "&f" + resource.getName(p), "&8\u21E8 &e" + supplies + ' ' + suffix);

View File

@ -112,7 +112,7 @@ public class GPSNetwork {
SlimefunItem item = BlockStorage.check(l);
if (item instanceof GPSTransmitter) {
level += ((GPSTransmitter) item).getMultiplier(l.getBlockY());
level += ((GPSTransmitter) item).getMultiplier(Math.max(l.getBlockY(),0));
}
}

View File

@ -133,6 +133,8 @@ import me.mrCookieSlime.Slimefun.api.inventory.UniversalBlockMenu;
*/
public final class Slimefun extends JavaPlugin implements SlimefunAddon {
private static final int RECOMMENDED_JAVA_VERSION = 17;
/**
* Our static instance of {@link Slimefun}.
* Make sure to clean this up in {@link #onDisable()}!
@ -263,9 +265,9 @@ public final class Slimefun extends JavaPlugin implements SlimefunAddon {
StartupWarnings.discourageCSCoreLib(logger);
}
// Encourage Java 16
if (NumberUtils.getJavaVersion() < 16) {
StartupWarnings.oldJavaVersion(logger);
// Encourage newer Java version
if (NumberUtils.getJavaVersion() < RECOMMENDED_JAVA_VERSION) {
StartupWarnings.oldJavaVersion(logger, RECOMMENDED_JAVA_VERSION);
}
// If the server has no "data-storage" folder, it's _probably_ a new install. So mark it for metrics.

View File

@ -59,17 +59,17 @@ final class StartupWarnings {
}
@ParametersAreNonnullByDefault
static void oldJavaVersion(Logger logger) {
static void oldJavaVersion(Logger logger, int recommendedJavaVersion) {
int javaVersion = NumberUtils.getJavaVersion();
logger.log(Level.WARNING, BORDER);
logger.log(Level.WARNING, PREFIX + "Your Java version (Java {0}) is out of date.", javaVersion);
logger.log(Level.WARNING, PREFIX);
logger.log(Level.WARNING, PREFIX + "We recommend you to update to Java 16.");
logger.log(Level.WARNING, PREFIX + "Java 16 is required as of Minecraft 1.17 and");
logger.log(Level.WARNING, PREFIX + "we would like to utilise all the new features");
logger.log(Level.WARNING, PREFIX + "We recommend you to update to Java {0}.", recommendedJavaVersion);
logger.log(Level.WARNING, PREFIX + "Java {0} is required for newer versions of Minecraft", recommendedJavaVersion);
logger.log(Level.WARNING, PREFIX + "and we would like to utilise all the new features");
logger.log(Level.WARNING, PREFIX + "that come with it as soon as possible.");
logger.log(Level.WARNING, PREFIX + "Slimefun will also require Java 16 in");
logger.log(Level.WARNING, PREFIX + "Slimefun will also require Java {0} in", recommendedJavaVersion);
logger.log(Level.WARNING, PREFIX + "the foreseeable future, so please update!");
logger.log(Level.WARNING, BORDER);
}

View File

@ -3,7 +3,9 @@ package io.github.thebusybiscuit.slimefun4.implementation.resources;
import org.bukkit.World.Environment;
import org.bukkit.block.Biome;
import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion;
import io.github.thebusybiscuit.slimefun4.api.geo.GEOResource;
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
import io.github.thebusybiscuit.slimefun4.implementation.items.geo.GEOMiner;
import io.github.thebusybiscuit.slimefun4.implementation.items.geo.OilPump;
@ -28,7 +30,14 @@ class OilResource extends AbstractResource {
OilResource() {
super("oil", "Oil", SlimefunItems.OIL_BUCKET, 8, false);
biomes = getBiomeMap(this, "/biome-maps/oil_v1.14.json");
MinecraftVersion version = Slimefun.getMinecraftVersion();
if (version.isAtLeast(MinecraftVersion.MINECRAFT_1_18)) {
// 1.18+ renamed most biomes
biomes = getBiomeMap(this, "/biome-maps/oil_v1.18.json");
} else {
biomes = getBiomeMap(this, "/biome-maps/oil_v1.14.json");
}
}
@Override
@ -39,5 +48,4 @@ class OilResource extends AbstractResource {
return biomes.getOrDefault(biome, DEFAULT_OVERWORLD_VALUE);
}
}
}

View File

@ -3,7 +3,9 @@ package io.github.thebusybiscuit.slimefun4.implementation.resources;
import org.bukkit.World.Environment;
import org.bukkit.block.Biome;
import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion;
import io.github.thebusybiscuit.slimefun4.api.geo.GEOResource;
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
import io.github.thebusybiscuit.slimefun4.utils.biomes.BiomeMap;
@ -22,8 +24,14 @@ class SaltResource extends AbstractResource {
SaltResource() {
super("salt", "Salt", SlimefunItems.SALT, 18, true);
MinecraftVersion version = Slimefun.getMinecraftVersion();
biomes = getBiomeMap(this, "/biome-maps/salt_v1.14.json");
if (version.isAtLeast(MinecraftVersion.MINECRAFT_1_18)) {
// 1.18+ renamed most biomes
biomes = getBiomeMap(this, "/biome-maps/salt_v1.18.json");
} else {
biomes = getBiomeMap(this, "/biome-maps/salt_v1.14.json");
}
}
@Override

View File

@ -26,7 +26,10 @@ class UraniumResource extends AbstractResource {
MinecraftVersion version = Slimefun.getMinecraftVersion();
if (version.isAtLeast(MinecraftVersion.MINECRAFT_1_17)) {
if (version.isAtLeast(MinecraftVersion.MINECRAFT_1_18)) {
// 1.18+ renamed most biomes
biomes = getBiomeMap(this, "/biome-maps/uranium_v1.18.json");
} else if (version.isAtLeast(MinecraftVersion.MINECRAFT_1_17)) {
// 1.17+ introduced cave biomes
biomes = getBiomeMap(this, "/biome-maps/uranium_v1.17.json");
} else if (version.isAtLeast(MinecraftVersion.MINECRAFT_1_16)) {

View File

@ -0,0 +1,83 @@
[
{
"value" : 6,
"biomes" : [
"minecraft:beach",
"minecraft:stony_shore"
]
},
{
"value" : 16,
"biomes" : [
"minecraft:river"
]
},
{
"value" : 20,
"biomes" : [
"minecraft:swamp"
]
},
{
"value" : 24,
"biomes" : [
"minecraft:ice_spikes",
"minecraft:frozen_ocean",
"minecraft:frozen_river",
"minecraft:frozen_peaks",
"minecraft:snowy_slopes"
]
},
{
"value" : 40,
"biomes" : [
"minecraft:badlands",
"minecraft:wooded_badlands",
"minecraft:eroded_badlands"
]
},
{
"value" : 45,
"biomes" : [
"minecraft:desert"
]
},
{
"value" : 64,
"biomes" : [
"minecraft:ocean",
"minecraft:cold_ocean",
"minecraft:warm_ocean",
"minecraft:lukewarm_ocean"
]
},
{
"value" : 72,
"biomes" : [
"minecraft:deep_ocean",
"minecraft:deep_cold_ocean",
"minecraft:deep_lukewarm_ocean"
]
},
{
"value" : 20,
"biomes" : [
"minecraft:windswept_hills",
"minecraft:windswept_gravelly_hills",
"minecraft:jagged_peaks"
]
},
{
"value" : 16,
"biomes" : [
"minecraft:snowy_plains",
"minecraft:snowy_taiga"
]
},
{
"value" : 20,
"biomes" : [
"minecraft:mushroom_fields"
]
}
]

View File

@ -0,0 +1,30 @@
[
{
"value" : 20,
"biomes" : [
"minecraft:swamp"
]
},
{
"value" : 40,
"biomes" : [
"minecraft:beach",
"minecraft:windswept_gravelly_hills",
"minecraft:stony_shore",
"minecraft:stony_peaks",
"minecraft:dripstone_caves"
]
},
{
"value" : 60,
"biomes" : [
"minecraft:ocean",
"minecraft:cold_ocean",
"minecraft:warm_ocean",
"minecraft:lukewarm_ocean",
"minecraft:deep_ocean",
"minecraft:deep_cold_ocean",
"minecraft:deep_lukewarm_ocean"
]
}
]

View File

@ -0,0 +1,34 @@
[
{
"value" : 5,
"biomes" : [
"minecraft:desert",
"minecraft:beach",
"minecraft:stony_shore"
]
},
{
"value" : 8,
"biomes" : [
"minecraft:jagged_peaks",
"minecraft:stony_peaks",
"minecraft:windswept_hills",
"minecraft:windswept_gravelly_hills"
]
},
{
"value" : 12,
"biomes" : [
"minecraft:badlands",
"minecraft:eroded_badlands",
"minecraft:wooded_badlands",
"minecraft:dripstone_caves"
]
},
{
"value" : 16,
"biomes" : [
"minecraft:basalt_deltas"
]
}
]

View File

@ -78,7 +78,7 @@ class TestResourceRegistration {
Assertions.assertNotEquals(0, resource.getDefaultSupply(Environment.NORMAL, Biome.BEACH));
Assertions.assertTrue(resource.getDefaultSupply(Environment.NORMAL, Biome.DESERT) > 10);
Assertions.assertTrue(resource.getDefaultSupply(Environment.NORMAL, Biome.MOUNTAINS) > 10);
// Assertions.assertTrue(resource.getDefaultSupply(Environment.NORMAL, Biome.MOUNTAINS) > 10);
Assertions.assertTrue(resource.getDefaultSupply(Environment.NORMAL, Biome.ICE_SPIKES) > 10);
Assertions.assertTrue(resource.getDefaultSupply(Environment.NORMAL, Biome.BADLANDS) > 10);
Assertions.assertTrue(resource.getDefaultSupply(Environment.NORMAL, Biome.OCEAN) > 10);
@ -102,7 +102,7 @@ class TestResourceRegistration {
NamespacedKey key = new NamespacedKey(plugin, "uranium");
GEOResource resource = testResource(key, "Small Chunks of Uranium", SlimefunItems.SMALL_URANIUM, true, 2);
Assertions.assertNotEquals(0, resource.getDefaultSupply(Environment.NORMAL, Biome.MOUNTAINS));
Assertions.assertNotEquals(0, resource.getDefaultSupply(Environment.NORMAL, Biome.COLD_OCEAN));
Assertions.assertEquals(0, resource.getDefaultSupply(Environment.NETHER, Biome.NETHER_WASTES));
Assertions.assertEquals(0, resource.getDefaultSupply(Environment.THE_END, Biome.THE_END));
}
@ -113,7 +113,9 @@ class TestResourceRegistration {
NamespacedKey key = new NamespacedKey(plugin, "salt");
GEOResource resource = testResource(key, "Salt", SlimefunItems.SALT, true, 18);
Assertions.assertNotEquals(0, resource.getDefaultSupply(Environment.NORMAL, Biome.MOUNTAINS));
Assertions.assertEquals(0, resource.getDefaultSupply(Environment.THE_END, Biome.THE_END));
Assertions.assertNotEquals(0, resource.getDefaultSupply(Environment.NORMAL, Biome.COLD_OCEAN));
Assertions.assertTrue(resource.getDefaultSupply(Environment.NORMAL, Biome.BEACH) > 10);
Assertions.assertTrue(resource.getDefaultSupply(Environment.NORMAL, Biome.OCEAN) > 10);
Assertions.assertTrue(resource.getDefaultSupply(Environment.NORMAL, Biome.SWAMP) > 10);

View File

@ -106,7 +106,8 @@ class TestBiomeMapCompatibility {
testCases.put("nether_ice_v1.16", new MinecraftVersion[] {
MinecraftVersion.MINECRAFT_1_16,
MinecraftVersion.MINECRAFT_1_17
MinecraftVersion.MINECRAFT_1_17,
MinecraftVersion.MINECRAFT_1_18
});
testCases.put("oil_v1.14", new MinecraftVersion[] {
@ -116,6 +117,10 @@ class TestBiomeMapCompatibility {
MinecraftVersion.MINECRAFT_1_17
});
testCases.put("oil_v1.18", new MinecraftVersion[] {
MinecraftVersion.MINECRAFT_1_18
});
testCases.put("salt_v1.14", new MinecraftVersion[] {
MinecraftVersion.MINECRAFT_1_14,
MinecraftVersion.MINECRAFT_1_15,
@ -123,6 +128,10 @@ class TestBiomeMapCompatibility {
MinecraftVersion.MINECRAFT_1_17
});
testCases.put("salt_v1.18", new MinecraftVersion[] {
MinecraftVersion.MINECRAFT_1_18
});
testCases.put("uranium_v1.14", new MinecraftVersion[] {
MinecraftVersion.MINECRAFT_1_14,
MinecraftVersion.MINECRAFT_1_15
@ -135,6 +144,10 @@ class TestBiomeMapCompatibility {
testCases.put("uranium_v1.17", new MinecraftVersion[] {
MinecraftVersion.MINECRAFT_1_17
});
testCases.put("uranium_v1.18", new MinecraftVersion[] {
MinecraftVersion.MINECRAFT_1_18
});
// @formatter:on
return testCases.entrySet().stream().flatMap(entry -> {