Added support for MC 1.21 block/entity types

This commit is contained in:
Intelli 2024-06-17 18:31:33 -06:00
parent 3e8083becf
commit 3d32320a33
9 changed files with 50 additions and 9 deletions

View File

@ -10,13 +10,13 @@ jobs:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Set up JDK 17
uses: actions/setup-java@v2
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '17'
java-version: '21'
distribution: 'temurin'
- name: Cache Maven packages
uses: actions/cache@v1

View File

@ -29,10 +29,10 @@ repositories {
}
dependencies {
implementation(platform("com.intellectualsites.bom:bom-newest:1.44")) // Ref: https://github.com/IntellectualSites/bom
implementation(platform("com.intellectualsites.bom:bom-newest:1.45")) // Ref: https://github.com/IntellectualSites/bom
compileOnly("com.fastasyncworldedit:FastAsyncWorldEdit-Core")
compileOnly("com.fastasyncworldedit:FastAsyncWorldEdit-Bukkit")
compileOnly 'io.papermc.paper:paper-api:1.20.4-R0.1-SNAPSHOT'
compileOnly 'io.papermc.paper:paper-api:1.21-R0.1-SNAPSHOT'
implementation 'org.bstats:bstats-bukkit-lite:1.8'
implementation 'com.zaxxer:HikariCP:5.0.1'
}

View File

@ -106,7 +106,7 @@
<dependency>
<groupId>com.intellectualsites.bom</groupId>
<artifactId>bom-newest</artifactId> <!-- Ref: https://github.com/IntellectualSites/bom -->
<version>1.44</version>
<version>1.45</version>
<scope>import</scope>
<type>pom</type>
</dependency>
@ -122,7 +122,7 @@
<dependency>
<groupId>io.papermc.paper</groupId>
<artifactId>paper-api</artifactId>
<version>1.20.4-R0.1-SNAPSHOT</version>
<version>1.21-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>

View File

@ -42,6 +42,7 @@ public class BukkitAdapter implements BukkitInterface {
public static final int BUKKIT_V1_18 = 18;
public static final int BUKKIT_V1_19 = 19;
public static final int BUKKIT_V1_20 = 20;
public static final int BUKKIT_V1_21 = 21;
public static void loadAdapter() {
switch (ConfigHandler.SERVER_VERSION) {
@ -63,9 +64,12 @@ public class BukkitAdapter implements BukkitInterface {
BukkitAdapter.ADAPTER = new Bukkit_v1_19();
break;
case BUKKIT_V1_20:
default:
BukkitAdapter.ADAPTER = new Bukkit_v1_20();
break;
case BUKKIT_V1_21:
default:
BukkitAdapter.ADAPTER = new Bukkit_v1_21();
break;
}
}

View File

@ -0,0 +1,25 @@
package net.coreprotect.bukkit;
import org.bukkit.Material;
import org.bukkit.Tag;
import net.coreprotect.model.BlockGroup;
public class Bukkit_v1_21 extends Bukkit_v1_20 implements BukkitInterface {
public Bukkit_v1_21() {
for (Material value : Tag.TRAPDOORS.getValues()) {
if (value == Material.IRON_TRAPDOOR) {
continue;
}
if (!BlockGroup.INTERACT_BLOCKS.contains(value)) {
BlockGroup.INTERACT_BLOCKS.add(value);
}
if (!BlockGroup.SAFE_INTERACT_BLOCKS.contains(value)) {
BlockGroup.SAFE_INTERACT_BLOCKS.add(value);
}
}
}
}

View File

@ -835,6 +835,12 @@ public final class PlayerInteractListener extends Queue implements Listener {
if (event.useItemInHand() != Event.Result.DENY) {
List<Material> entityBlockTypes = Arrays.asList(Material.ARMOR_STAND, Material.END_CRYSTAL, Material.BOW, Material.CROSSBOW, Material.TRIDENT, Material.EXPERIENCE_BOTTLE, Material.SPLASH_POTION, Material.LINGERING_POTION, Material.ENDER_PEARL, Material.FIREWORK_ROCKET, Material.EGG, Material.SNOWBALL);
try {
entityBlockTypes.add(Material.valueOf("WIND_CHARGE"));
}
catch (Exception e) {
// not running MC 1.21+
}
ItemStack handItem = null;
ItemStack mainHand = player.getInventory().getItemInMainHand();
ItemStack offHand = player.getInventory().getItemInOffHand();

View File

@ -23,6 +23,7 @@ public class PaperAdapter implements PaperInterface {
public static final int PAPER_V1_18 = BukkitAdapter.BUKKIT_V1_18;
public static final int PAPER_V1_19 = BukkitAdapter.BUKKIT_V1_19;
public static final int PAPER_V1_20 = BukkitAdapter.BUKKIT_V1_20;
public static final int PAPER_V1_21 = BukkitAdapter.BUKKIT_V1_21;
public static void loadAdapter() {
int paperVersion = ConfigHandler.SERVER_VERSION;
@ -48,6 +49,7 @@ public class PaperAdapter implements PaperInterface {
PaperAdapter.ADAPTER = new Paper_v1_17();
break;
case PAPER_V1_20:
case PAPER_V1_21:
default:
PaperAdapter.ADAPTER = new Paper_v1_20();
break;

View File

@ -21,6 +21,7 @@ public class SpigotAdapter implements SpigotInterface {
public static final int SPIGOT_V1_18 = BukkitAdapter.BUKKIT_V1_18;
public static final int SPIGOT_V1_19 = BukkitAdapter.BUKKIT_V1_19;
public static final int SPIGOT_V1_20 = BukkitAdapter.BUKKIT_V1_20;
public static final int SPIGOT_V1_21 = BukkitAdapter.BUKKIT_V1_21;
public static void loadAdapter() {
int spigotVersion = ConfigHandler.SERVER_VERSION;
@ -42,6 +43,7 @@ public class SpigotAdapter implements SpigotInterface {
case SPIGOT_V1_18:
case SPIGOT_V1_19:
case SPIGOT_V1_20:
case SPIGOT_V1_21:
default:
SpigotAdapter.ADAPTER = new Spigot_v1_16();
break;

View File

@ -942,6 +942,8 @@ public class Util extends Queue {
return Material.EGG;
case "SNOWBALL":
return Material.SNOWBALL;
case "WIND_CHARGE":
return Material.valueOf("WIND_CHARGE");
default:
return BukkitAdapter.ADAPTER.getFrameType(type);
}