mirror of
https://github.com/PlayPro/CoreProtect.git
synced 2024-11-24 12:16:36 +01:00
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:
parent
319d104622
commit
3b349c9d07
@ -34,7 +34,7 @@ dependencies {
|
||||
compileOnly('com.sk89q.worldedit:worldedit-bukkit:7.0.0-SNAPSHOT') {
|
||||
exclude group: 'org.bukkit'
|
||||
}
|
||||
compileOnly 'io.papermc.paper:paper-api:1.18.1-R0.1-SNAPSHOT'
|
||||
compileOnly 'io.papermc.paper:paper-api:1.19-R0.1-SNAPSHOT'
|
||||
implementation 'org.bstats:bstats-bukkit-lite:1.8'
|
||||
implementation 'com.zaxxer:HikariCP:4.0.3'
|
||||
}
|
||||
@ -85,4 +85,3 @@ processResources {
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
2
pom.xml
2
pom.xml
@ -94,7 +94,7 @@
|
||||
<dependency>
|
||||
<groupId>io.papermc.paper</groupId>
|
||||
<artifactId>paper-api</artifactId>
|
||||
<version>1.18.1-R0.1-SNAPSHOT</version>
|
||||
<version>1.19-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
70
src/main/java/net/coreprotect/bukkit/Bukkit_v1_19.java
Normal file
70
src/main/java/net/coreprotect/bukkit/Bukkit_v1_19.java
Normal 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;
|
||||
}
|
||||
}
|
@ -72,6 +72,7 @@ public class Config extends Language {
|
||||
public boolean TREE_GROWTH;
|
||||
public boolean MUSHROOM_GROWTH;
|
||||
public boolean VINE_GROWTH;
|
||||
public boolean SCULK_SPREAD;
|
||||
public boolean PORTALS;
|
||||
public boolean WATER_FLOW;
|
||||
public boolean LAVA_FLOW;
|
||||
@ -124,6 +125,7 @@ public class Config extends Language {
|
||||
DEFAULT_VALUES.put("tree-growth", "true");
|
||||
DEFAULT_VALUES.put("mushroom-growth", "true");
|
||||
DEFAULT_VALUES.put("vine-growth", "true");
|
||||
DEFAULT_VALUES.put("sculk-spread", "true");
|
||||
DEFAULT_VALUES.put("portals", "true");
|
||||
DEFAULT_VALUES.put("water-flow", "true");
|
||||
DEFAULT_VALUES.put("lava-flow", "true");
|
||||
@ -166,6 +168,7 @@ public class Config extends Language {
|
||||
HEADERS.put("tree-growth", new String[] { "# Logs tree growth. Trees are linked to the player who planted the sappling." });
|
||||
HEADERS.put("mushroom-growth", new String[] { "# Logs mushroom growth." });
|
||||
HEADERS.put("vine-growth", new String[] { "# Logs natural vine growth." });
|
||||
HEADERS.put("sculk-spread", new String[] { "# Logs the spread of sculk blocks from sculk catalysts." });
|
||||
HEADERS.put("portals", new String[] { "# Logs when portals such as Nether portals generate naturally." });
|
||||
HEADERS.put("water-flow", new String[] { "# Logs water flow. If water destroys other blocks, such as torches,", "# this allows it to be properly rolled back." });
|
||||
HEADERS.put("lava-flow", new String[] { "# Logs lava flow. If lava destroys other blocks, such as torches,", "# this allows it to be properly rolled back." });
|
||||
@ -224,6 +227,7 @@ public class Config extends Language {
|
||||
this.TREE_GROWTH = this.getBoolean("tree-growth");
|
||||
this.MUSHROOM_GROWTH = this.getBoolean("mushroom-growth");
|
||||
this.VINE_GROWTH = this.getBoolean("vine-growth");
|
||||
this.SCULK_SPREAD = this.getBoolean("sculk-spread");
|
||||
this.PORTALS = this.getBoolean("portals");
|
||||
this.WATER_FLOW = this.getBoolean("water-flow");
|
||||
this.LAVA_FLOW = this.getBoolean("lava-flow");
|
||||
|
@ -27,20 +27,18 @@ public final class BlockSpreadListener extends Queue implements Listener {
|
||||
* block-change: true
|
||||
*
|
||||
*/
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!event.isCancelled() && Config.getConfig(event.getBlock().getWorld()).VINE_GROWTH) {
|
||||
BlockState blockstate = event.getNewState();
|
||||
Material type = blockstate.getType();
|
||||
if (!BlockGroup.VINES.contains(type) && !BlockGroup.AMETHYST.contains(type) && type != Material.CHORUS_FLOWER && type != Material.BAMBOO) {
|
||||
return;
|
||||
}
|
||||
BlockState blockstate = event.getNewState();
|
||||
Material type = blockstate.getType();
|
||||
Block block = event.getBlock();
|
||||
|
||||
Block block = event.getBlock();
|
||||
Location location = block.getLocation();
|
||||
int timestamp = (int) (System.currentTimeMillis() / 1000L);
|
||||
Object[] cacheData = CacheHandler.spreadCache.get(location);
|
||||
CacheHandler.spreadCache.put(location, new Object[] { timestamp, type });
|
||||
if (cacheData != null && ((Material) cacheData[1]) == type) {
|
||||
if (Config.getConfig(event.getBlock().getWorld()).VINE_GROWTH &&
|
||||
(BlockGroup.VINES.contains(type) || BlockGroup.AMETHYST.contains(type)
|
||||
|| type == Material.CHORUS_FLOWER || type == Material.BAMBOO)) {
|
||||
if(checkCacheData(block, type)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -74,6 +72,25 @@ public final class BlockSpreadListener extends Queue implements Listener {
|
||||
Queue.queueBlockPlaceDelayed("#bamboo", block.getLocation(), type, null, block.getState(), 0);
|
||||
}
|
||||
}
|
||||
|
||||
if(Config.getConfig(event.getBlock().getWorld()).SCULK_SPREAD && BlockGroup.SCULK.contains(type)) {
|
||||
if(checkCacheData(block, type)) {
|
||||
return;
|
||||
}
|
||||
|
||||
queueBlockPlace("#sculk", block.getState(), block.getType(), block.getState(), type, -1, 0, blockstate.getBlockData().getAsString());
|
||||
}
|
||||
}
|
||||
|
||||
private boolean checkCacheData(Block block, Material type) {
|
||||
Location location = block.getLocation();
|
||||
int timestamp = (int) (System.currentTimeMillis() / 1000L);
|
||||
Object[] cacheData = CacheHandler.spreadCache.get(location);
|
||||
CacheHandler.spreadCache.put(location, new Object[] { timestamp, type });
|
||||
if (cacheData != null && ((Material) cacheData[1]) == type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -33,6 +33,7 @@ public final class BlockGroup {
|
||||
public static Set<Material> SAFE_INTERACT_BLOCKS = new HashSet<>(Arrays.asList(Material.LEVER, Material.ACACIA_TRAPDOOR, Material.BIRCH_TRAPDOOR, Material.DARK_OAK_TRAPDOOR, Material.JUNGLE_TRAPDOOR, Material.SPRUCE_TRAPDOOR, Material.OAK_TRAPDOOR, Material.OAK_FENCE_GATE, Material.SPRUCE_FENCE_GATE, Material.BIRCH_FENCE_GATE, Material.JUNGLE_FENCE_GATE, Material.DARK_OAK_FENCE_GATE, Material.ACACIA_FENCE_GATE));
|
||||
public static Set<Material> UPDATE_STATE = new HashSet<>(Arrays.asList(Material.TORCH, Material.WALL_TORCH, Material.REDSTONE_WIRE, Material.RAIL, Material.POWERED_RAIL, Material.DETECTOR_RAIL, Material.FURNACE, Material.BLAST_FURNACE, Material.SMOKER, Material.LEVER, Material.REDSTONE_TORCH, Material.REDSTONE_WALL_TORCH, Material.GLOWSTONE, Material.JACK_O_LANTERN, Material.REPEATER, Material.REDSTONE_LAMP, Material.BEACON, Material.COMPARATOR, Material.DAYLIGHT_DETECTOR, Material.REDSTONE_BLOCK, Material.HOPPER, Material.CHEST, Material.TRAPPED_CHEST, Material.ACTIVATOR_RAIL));
|
||||
public static Set<Material> NATURAL_BLOCKS = new HashSet<>(Arrays.asList(Material.STONE, Material.GOLD_ORE, Material.IRON_ORE, Material.COAL_ORE, Material.LAPIS_ORE, Material.SANDSTONE, Material.COBWEB, Material.FERN, Material.DEAD_BUSH, Material.DANDELION, Material.POPPY, Material.BLUE_ORCHID, Material.ALLIUM, Material.AZURE_BLUET, Material.RED_TULIP, Material.ORANGE_TULIP, Material.WHITE_TULIP, Material.PINK_TULIP, Material.OXEYE_DAISY, Material.BROWN_MUSHROOM, Material.RED_MUSHROOM, Material.OBSIDIAN, Material.DIAMOND_ORE, Material.WHEAT, Material.REDSTONE_ORE, Material.SNOW, Material.ICE, Material.CACTUS, Material.CLAY, Material.SUGAR_CANE, Material.PUMPKIN, Material.NETHERRACK, Material.SOUL_SAND, Material.MELON, Material.PUMPKIN_STEM, Material.MELON_STEM, Material.MYCELIUM, Material.LILY_PAD, Material.NETHER_WART, Material.END_STONE, Material.EMERALD_ORE, Material.CARROT, Material.POTATO, Material.KELP, Material.CHORUS_FLOWER, Material.CHORUS_PLANT, Material.CORNFLOWER, Material.LILY_OF_THE_VALLEY, Material.WITHER_ROSE, Material.SWEET_BERRY_BUSH));
|
||||
public static Set<Material> SCULK = new HashSet<>(Arrays.asList());
|
||||
|
||||
/* blocks that support vertical scanning */
|
||||
public static Set<Material> VERTICAL_TOP_BOTTOM = new HashSet<>(Arrays.asList());
|
||||
|
@ -17,6 +17,7 @@ public class PaperAdapter implements PaperInterface {
|
||||
public static final int PAPER_V1_16 = BukkitAdapter.BUKKIT_V1_16;
|
||||
public static final int PAPER_V1_17 = BukkitAdapter.BUKKIT_V1_17;
|
||||
public static final int PAPER_V1_18 = BukkitAdapter.BUKKIT_V1_18;
|
||||
public static final int PAPER_V1_19 = BukkitAdapter.BUKKIT_V1_19;
|
||||
|
||||
public static void loadAdapter() {
|
||||
int paperVersion = ConfigHandler.SERVER_VERSION;
|
||||
@ -36,6 +37,7 @@ public class PaperAdapter implements PaperInterface {
|
||||
case PAPER_V1_16:
|
||||
case PAPER_V1_17:
|
||||
case PAPER_V1_18:
|
||||
case PAPER_V1_19:
|
||||
default:
|
||||
PaperAdapter.ADAPTER = new Paper_v1_16();
|
||||
break;
|
||||
|
@ -19,6 +19,7 @@ public class SpigotAdapter implements SpigotInterface {
|
||||
public static final int SPIGOT_V1_16 = BukkitAdapter.BUKKIT_V1_16;
|
||||
public static final int SPIGOT_V1_17 = BukkitAdapter.BUKKIT_V1_17;
|
||||
public static final int SPIGOT_V1_18 = BukkitAdapter.BUKKIT_V1_18;
|
||||
public static final int SPIGOT_V1_19 = BukkitAdapter.BUKKIT_V1_19;
|
||||
|
||||
public static void loadAdapter() {
|
||||
int spigotVersion = ConfigHandler.SERVER_VERSION;
|
||||
@ -38,6 +39,7 @@ public class SpigotAdapter implements SpigotInterface {
|
||||
case SPIGOT_V1_16:
|
||||
case SPIGOT_V1_17:
|
||||
case SPIGOT_V1_18:
|
||||
case SPIGOT_V1_19:
|
||||
default:
|
||||
SpigotAdapter.ADAPTER = new Spigot_v1_16();
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user