Add support for 1.19 specific features. (#239)

* Added support for 1.19 specific features.

* Removed leftover import from testing

* Added missing sculk materials for the catalyst and changed user field to #sculk

* Reverted version to v21.2

Co-authored-by: Intelli <6790859+Intelli@users.noreply.github.com>
This commit is contained in:
Ryan Huston 2022-12-07 20:26:45 -05:00 committed by GitHub
parent 319d104622
commit 3b349c9d07
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 114 additions and 16 deletions

View file

@ -30,6 +30,7 @@ public class BukkitAdapter implements BukkitInterface {
public static final int BUKKIT_V1_16 = 16;
public static final int BUKKIT_V1_17 = 17;
public static final int BUKKIT_V1_18 = 18;
public static final int BUKKIT_V1_19 = 19;
public static void loadAdapter() {
switch (ConfigHandler.SERVER_VERSION) {
@ -47,9 +48,11 @@ public class BukkitAdapter implements BukkitInterface {
BukkitAdapter.ADAPTER = new Bukkit_v1_17();
break;
case BUKKIT_V1_18:
default:
BukkitAdapter.ADAPTER = new Bukkit_v1_18();
break;
case BUKKIT_V1_19:
default:
BukkitAdapter.ADAPTER = new Bukkit_v1_19();
}
}

View file

@ -0,0 +1,70 @@
package net.coreprotect.bukkit;
import net.coreprotect.model.BlockGroup;
import org.bukkit.Material;
import org.bukkit.entity.*;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
public class Bukkit_v1_19 extends Bukkit_v1_18 implements BukkitInterface {
public Bukkit_v1_19() {
BlockGroup.SCULK = new HashSet<>(Arrays.asList(Material.SCULK, Material.SCULK_VEIN, Material.SCULK_SENSOR, Material.SCULK_SHRIEKER));
}
@Override
public boolean getEntityMeta(LivingEntity entity, List<Object> info) {
if (entity instanceof Frog) {
Frog frog = (Frog) entity;
info.add(frog.getVariant());
}
else if (entity instanceof Goat) {
Goat goat = (Goat) entity;
info.add(goat.isScreaming());
info.add(goat.hasLeftHorn());
info.add(goat.hasRightHorn());
}
else if (super.getEntityMeta(entity, info)) {
return true;
}
else {
return false;
}
return true;
}
@Override
public boolean setEntityMeta(Entity entity, Object value, int count) {
if (entity instanceof Frog) {
Frog frog = (Frog) entity;
if (count == 0) {
Frog.Variant set = (Frog.Variant) value;
frog.setVariant(set);
}
}
else if (entity instanceof Goat) {
Goat goat = (Goat) entity;
boolean set = (Boolean) value;
if (count == 0) {
goat.setScreaming(set);
}
else if (count == 1) {
goat.setLeftHorn(set);
}
else if (count == 2) {
goat.setRightHorn(set);
}
}
else if (super.setEntityMeta(entity, value, count)) {
return true;
}
else {
return false;
}
return true;
}
}