Skip to content

Commit c3d9a6c

Browse files
committed
Merge branch 'refs/heads/walshy/mc-1.21' into walshy/mc-1.21-itemstacks-of
# Conflicts: # pom.xml # src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/ExplosiveTool.java
2 parents 3cd90ba + 00da02c commit c3d9a6c

File tree

18 files changed

+253
-50
lines changed

18 files changed

+253
-50
lines changed

Makefile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
default: help
2+
3+
.PHONY: help
4+
help:
5+
@echo " * gen-biomes version=<version> - Generate biomes for the given version"
6+
7+
.PHONY: gen-biomes
8+
gen-biomes:
9+
@echo "Generating biomes for $(version)"
10+
@curl "https://raw.githubusercontent.com/MockBukkit/MockBukkit/refs/heads/v$(version)/src/main/resources/keyed/worldgen/biome.json" -s \
11+
| jq '[ .values[].key]' \
12+
> "src/test/resources/biomes/$(version).x.json"

jitpack.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
before_install:
2-
- sdk install java 17.0.1-open
3-
- sdk use java 17.0.1-open
2+
- sdk install java 21.0.2-open
3+
- sdk use java 21.0.2-open
4+
- sdk install maven
45

56
jdk:
6-
- openjdk17
7+
- openjdk21

pom.xml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@
238238
<!-- Javadocs -->
239239
<groupId>org.apache.maven.plugins</groupId>
240240
<artifactId>maven-javadoc-plugin</artifactId>
241-
<version>3.7.0</version>
241+
<version>3.10.0</version>
242242

243243
<configuration>
244244
<reportOutputDirectory>${project.basedir}</reportOutputDirectory>
@@ -251,7 +251,7 @@
251251

252252
<links>
253253
<!-- We can reference the Spigot API in our Javadocs -->
254-
<link>${spigot.javadocs}</link>
254+
<link>${paper.javadocs}</link>
255255
</links>
256256

257257
<!-- We can group packages together in our Javadocs -->
@@ -371,7 +371,8 @@
371371
<dependency>
372372
<groupId>io.papermc.paper</groupId>
373373
<artifactId>paper-api</artifactId>
374-
<version>1.21.1-R0.1-SNAPSHOT</version>
374+
<version>${paper.version}-R0.1-SNAPSHOT</version>
375+
<scope>provided</scope>
375376
</dependency>
376377

377378
<!-- Testing dependencies -->
@@ -394,10 +395,9 @@
394395
</dependency>
395396
<!-- This needs to be before Spigot because MockBukkit will fail otherwise. -->
396397
<dependency>
397-
<groupId>com.github.seeseemelk</groupId>
398+
<groupId>com.github.MockBukkit</groupId>
398399
<artifactId>MockBukkit</artifactId>
399-
<!-- <version>3.123.0</version> -->
400-
<version>dev-3fec4e7b</version>
400+
<version>v3.130.2</version>
401401
<scope>test</scope>
402402

403403
<exclusions>

src/main/java/io/github/thebusybiscuit/slimefun4/api/MinecraftVersion.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,12 @@ public enum MinecraftVersion {
5555
*/
5656
MINECRAFT_1_20_5(20, 5, "1.20.5+"),
5757

58+
/**
59+
* This constant represents Minecraft (Java Edition) Version 1.21
60+
* ("Tricky Trials")
61+
*/
62+
MINECRAFT_1_21(21, 0, "1.21.x"),
63+
5864
/**
5965
* This constant represents Minecraft (Java Edition) Version 1.21
6066
* ("Tricky Trials")

src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/FireworksOption.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package io.github.thebusybiscuit.slimefun4.core.guide.options;
22

3+
import java.util.List;
34
import java.util.Optional;
45

56
import org.bukkit.Material;
@@ -31,7 +32,13 @@ public Optional<ItemStack> getDisplayItem(Player p, ItemStack guide) {
3132

3233
if (registry.isResearchingEnabled() && registry.isResearchFireworkEnabled()) {
3334
boolean enabled = getSelectedOption(p, guide).orElse(true);
34-
ItemStack item = new CustomItemStack(Material.FIREWORK_ROCKET, "&bFireworks: &" + (enabled ? "aYes" : "4No"), "", "&7You can now toggle whether you", "&7will be presented with a big firework", "&7upon researching an item.", "", "&7\u21E8 &eClick to " + (enabled ? "disable" : "enable") + " your fireworks");
35+
36+
String optionState = enabled ? "enabled" : "disabled";
37+
List<String> lore = Slimefun.getLocalization().getMessages(p, "guide.options.fireworks." + optionState + ".text");
38+
lore.add("");
39+
lore.add("&7\u21E8 " + Slimefun.getLocalization().getMessage(p, "guide.options.fireworks." + optionState + ".click"));
40+
41+
ItemStack item = new CustomItemStack(Material.FIREWORK_ROCKET, lore);
3542
return Optional.of(item);
3643
} else {
3744
return Optional.empty();

src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/GuideModeOption.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,15 @@ public Optional<ItemStack> getDisplayItem(Player p, ItemStack guide) {
5757
}
5858

5959
ItemMeta meta = item.getItemMeta();
60-
meta.setDisplayName(ChatColor.GRAY + "Slimefun Guide Type: " + ChatColor.YELLOW + ChatUtils.humanize(selectedMode.name()));
60+
meta.setDisplayName(ChatColor.GRAY + Slimefun.getLocalization().getMessage(p, "guide.modes.selected") +
61+
ChatColor.YELLOW + Slimefun.getLocalization().getMessage(p, "guide.modes." + selectedMode.name()));
6162
List<String> lore = new ArrayList<>();
6263
lore.add("");
63-
lore.add((selectedMode == SlimefunGuideMode.SURVIVAL_MODE ? ChatColor.GREEN : ChatColor.GRAY) + "Survival Mode");
64-
lore.add((selectedMode == SlimefunGuideMode.CHEAT_MODE ? ChatColor.GREEN : ChatColor.GRAY) + "Cheat Sheet");
64+
lore.add((selectedMode == SlimefunGuideMode.SURVIVAL_MODE ? ChatColor.GREEN : ChatColor.GRAY) + Slimefun.getLocalization().getMessage(p, "guide.modes.SURVIVAL_MODE"));
65+
lore.add((selectedMode == SlimefunGuideMode.CHEAT_MODE ? ChatColor.GREEN : ChatColor.GRAY) + Slimefun.getLocalization().getMessage(p, "guide.modes.CHEAT_MODE"));
6566

6667
lore.add("");
67-
lore.add(ChatColor.GRAY + "\u21E8 " + ChatColor.YELLOW + "Click to change the type");
68+
lore.add(ChatColor.GRAY + "\u21E8 " + ChatColor.YELLOW + Slimefun.getLocalization().getMessage(p, "guide.modes.change"));
6869
meta.setLore(lore);
6970
item.setItemMeta(meta);
7071

@@ -115,4 +116,4 @@ public void setSelectedOption(Player p, ItemStack guide, SlimefunGuideMode value
115116
guide.setItemMeta(SlimefunGuide.getItem(value).getItemMeta());
116117
}
117118

118-
}
119+
}

src/main/java/io/github/thebusybiscuit/slimefun4/core/services/MetricsService.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,6 @@ private boolean download(int version) {
235235
downloadMonitor(HttpResponse.BodyHandlers.ofFile(file.toPath()))
236236
);
237237

238-
239238
if (response.statusCode() >= 200 && response.statusCode() < 300) {
240239
plugin.getLogger().log(Level.INFO, "Successfully downloaded {0} build: #{1}", new Object[] { JAR_NAME, version });
241240

@@ -246,6 +245,8 @@ private boolean download(int version) {
246245
metricVersion = String.valueOf(version);
247246
hasDownloadedUpdate = true;
248247
return true;
248+
} else {
249+
plugin.getLogger().log(Level.WARNING, "Failed to download the latest jar file from GitHub. Response code: {0}", response.statusCode());
249250
}
250251
} catch (InterruptedException | JsonParseException e) {
251252
plugin.getLogger().log(Level.WARNING, "Failed to fetch the latest jar file from the builds page. Perhaps GitHub is down? Response: {0}", e.getMessage());

src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/runes/EnchantmentRune.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public EnchantmentRune(ItemGroup itemGroup, SlimefunItemStack item, RecipeType r
5151
super(itemGroup, item, recipeType, recipe);
5252

5353
for (Material mat : Material.values()) {
54-
if (Slimefun.instance().isUnitTest() && mat.isLegacy()) continue;
54+
if (mat.isLegacy() || !mat.isItem()) continue;
5555

5656
List<Enchantment> enchantments = new ArrayList<>();
5757

src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/ExplosiveTool.java

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
package io.github.thebusybiscuit.slimefun4.implementation.items.tools;
22

3+
import java.lang.reflect.Constructor;
34
import java.util.ArrayList;
45
import java.util.List;
6+
import java.util.logging.Level;
57

68
import javax.annotation.Nonnull;
79
import javax.annotation.ParametersAreNonnullByDefault;
@@ -18,6 +20,7 @@
1820
import org.bukkit.inventory.ItemStack;
1921

2022
import io.github.bakedlibs.dough.protection.Interaction;
23+
import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion;
2124
import io.github.thebusybiscuit.slimefun4.api.events.ExplosiveToolBreakBlocksEvent;
2225
import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup;
2326
import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting;
@@ -49,6 +52,17 @@ public class ExplosiveTool extends SimpleSlimefunItem<ToolUseHandler> implements
4952
private final ItemSetting<Boolean> damageOnUse = new ItemSetting<>(this, "damage-on-use", true);
5053
private final ItemSetting<Boolean> callExplosionEvent = new ItemSetting<>(this, "call-explosion-event", false);
5154

55+
private static Constructor<?> pre21ExplodeEventConstructor;
56+
static {
57+
if (Slimefun.getMinecraftVersion().isBefore(MinecraftVersion.MINECRAFT_1_21)) {
58+
try {
59+
pre21ExplodeEventConstructor = BlockExplodeEvent.class.getConstructor(Block.class, List.class, float.class);
60+
} catch (Exception e) {
61+
Slimefun.logger().log(Level.SEVERE, "Could not find constructor for BlockExplodeEvent", e);
62+
}
63+
}
64+
}
65+
5266
@ParametersAreNonnullByDefault
5367
public ExplosiveTool(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
5468
super(itemGroup, item, recipeType, recipe);
@@ -192,7 +206,19 @@ private BlockExplodeEvent createNewBlockExplodeEvent(
192206
List<Block> blocks,
193207
float yield
194208
) {
195-
// TODO: Support older vers
196-
return new BlockExplodeEvent(block, block.getState(), blocks, yield, ExplosionResult.DESTROY);
209+
var version = Slimefun.getMinecraftVersion();
210+
if (version.isAtLeast(MinecraftVersion.MINECRAFT_1_21)) {
211+
return new BlockExplodeEvent(block, block.getState(), blocks, yield, ExplosionResult.DESTROY);
212+
} else if (pre21ExplodeEventConstructor != null) {
213+
try {
214+
return (BlockExplodeEvent) pre21ExplodeEventConstructor.newInstance(block, blocks, yield);
215+
} catch (Exception e) {
216+
Slimefun.logger().log(Level.SEVERE, "Could not find constructor for BlockExplodeEvent", e);
217+
}
218+
219+
return null;
220+
} else {
221+
throw new IllegalStateException("BlockExplodeEvent constructor not found");
222+
}
197223
}
198224
}

src/main/java/me/mrCookieSlime/Slimefun/api/BlockInfoConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,4 +118,4 @@ public String toJSON() {
118118
return new GsonBuilder().create().toJson(data);
119119
}
120120

121-
}
121+
}

0 commit comments

Comments
 (0)