Merge branch 'version/7.0.x'

This commit is contained in:
Joo200 2023-06-18 18:47:29 +02:00
commit 8cbce96a2c
17 changed files with 87 additions and 25 deletions

View File

@ -1,5 +1,10 @@
# Changelog
## 7.0.9
* Add support for MC 1.20
* Made entities spawned via the `/summon` command get treated as plugin-spawned entities
* Add sniffer egg trample protection options
## 7.0.8
* Add support for MC 1.19
* Add skulk-growth flag and config option

View File

@ -23,7 +23,7 @@ A Bukkit server implementation (such as [Paper](https://papermc.io)) and the [Wo
Compiling
---------
The project is written for Java 16 and our build process makes use of
The project is written for Java 17 and our build process makes use of
[Gradle](http://gradle.org).
Dependencies are automatically handled by Gradle.
@ -40,8 +40,8 @@ Submissions must be licensed under the GNU Lesser General Public License v3.
Links
-----
* [Homepage](http://enginehub.org/worldguard)
* [Homepage](https://enginehub.org/worldguard)
* [Discord](https://discord.gg/enginehub)
* [Issue tracker](https://github.com/EngineHub/WorldGuard/issues)
* [Continuous integration](http://builds.enginehub.org) [![Build Status](https://ci.enginehub.org/app/rest/builds/buildType:bt11,branch:master/statusIcon.svg)](http://ci.enginehub.org/viewType.html?buildTypeId=bt11&guest=1)
* [Continuous integration](https://builds.enginehub.org) [![Build Status](https://ci.enginehub.org/app/rest/builds/buildType:bt11,branch:master/statusIcon.svg)](http://ci.enginehub.org/viewType.html?buildTypeId=bt11&guest=1)
* [End-user documentation](https://worldguard.enginehub.org/en/latest/)

View File

@ -1,7 +1,7 @@
object Versions {
// const val PISTON = "0.4.3"
// const val AUTO_VALUE = "1.6.5"
const val WORLDEDIT = "7.2.12"
const val WORLDEDIT = "7.2.14"
const val JUNIT = "5.9.1"
const val MOCKITO = "4.9.0"
const val SQUIRRELID = "0.3.2"

Binary file not shown.

View File

@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

7
gradlew vendored
View File

@ -85,9 +85,6 @@ done
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
@ -197,6 +194,10 @@ if "$cygwin" || "$msys" ; then
done
fi
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in

View File

@ -20,8 +20,8 @@ configurations {
dependencies {
"api"(project(":worldguard-core"))
"compileOnly"("io.papermc.paper:paper-api:1.19.3-R0.1-SNAPSHOT")
"runtimeOnly"("org.spigotmc:spigot-api:1.19.3-R0.1-SNAPSHOT") {
"compileOnly"("io.papermc.paper:paper-api:1.20-R0.1-SNAPSHOT")
"runtimeOnly"("org.spigotmc:spigot-api:1.20-R0.1-SNAPSHOT") {
exclude("junit", "junit")
}
"api"("com.sk89q.worldedit:worldedit-bukkit:${Versions.WORLDEDIT}") { isTransitive = false }

View File

@ -256,6 +256,8 @@ public class BukkitWorldConfiguration extends YamlWorldConfiguration {
disableCreatureTurtleEggTrampling = getBoolean("turtle-egg.disable-creature-trampling", false);
disablePlayerTurtleEggTrampling = getBoolean("turtle-egg.disable-player-trampling", false);
disableCreatureSnifferEggTrampling = getBoolean("sniffer-egg.disable-creature-trampling", false);
disablePlayerSnifferEggTrampling = getBoolean("sniffer-egg.disable-player-trampling", false);
disallowedLightningBlocks = new HashSet<>(convertLegacyBlocks(getStringList("weather.prevent-lightning-strike-blocks", null)));
preventLightningFire = getBoolean("weather.disable-lightning-strike-fire", false);

View File

@ -454,7 +454,9 @@ public class EventAbstractionListener extends AbstractListener {
switch (event.getAction()) {
case PHYSICAL:
if (event.useInteractedBlock() != Result.DENY) {
if (clicked.getType() == Material.FARMLAND || clicked.getType() == Material.TURTLE_EGG) {
if (clicked.getType() == Material.FARMLAND ||
clicked.getType() == Material.TURTLE_EGG ||
clicked.getType() == Material.SNIFFER_EGG) {
BreakBlockEvent breakDelagate = new BreakBlockEvent(event, cause, clicked);
breakDelagate.setSilent(true);
breakDelagate.getRelevantFlags().add(Flags.TRAMPLE_BLOCKS);
@ -600,9 +602,7 @@ public class EventAbstractionListener extends AbstractListener {
@EventHandler(ignoreCancelled = true)
public void onSignChange(SignChangeEvent event) {
Events.fireToCancel(event, new UseBlockEvent(event, create(event.getPlayer()), event.getBlock()));
if (event.isCancelled()) {
if (Events.fireToCancel(event, new PlaceBlockEvent(event, create(event.getPlayer()), event.getBlock()))) {
playDenyEffect(event.getPlayer(), event.getBlock().getLocation().add(0.5, 0.5, 0.5));
}
}

View File

@ -120,6 +120,10 @@ public class WorldGuardEntityListener extends AbstractListener {
event.setCancelled(true);
return;
}
if (block.getType() == Material.SNIFFER_EGG && wcfg.disableCreatureSnifferEggTrampling) {
event.setCancelled(true);
return;
}
}
@EventHandler(priority = EventPriority.HIGH)
@ -603,7 +607,7 @@ public class WorldGuardEntityListener extends AbstractListener {
WorldConfiguration wcfg = getWorldConfig(event.getEntity().getWorld());
// allow spawning of creatures from plugins
if (!wcfg.blockPluginSpawning && event.getSpawnReason() == CreatureSpawnEvent.SpawnReason.CUSTOM) {
if (!wcfg.blockPluginSpawning && Entities.isPluginSpawning(event.getSpawnReason())) {
return;
}

View File

@ -307,6 +307,10 @@ public class WorldGuardPlayerListener extends AbstractListener {
event.setCancelled(true);
return;
}
if (type == Material.SNIFFER_EGG && wcfg.disablePlayerSnifferEggTrampling) {
event.setCancelled(true);
return;
}
}
@EventHandler(priority = EventPriority.HIGHEST)

View File

@ -44,6 +44,7 @@ import org.bukkit.entity.TNTPrimed;
import org.bukkit.entity.Tameable;
import org.bukkit.entity.Vehicle;
import org.bukkit.entity.minecart.ExplosiveMinecart;
import org.bukkit.event.entity.CreatureSpawnEvent;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.projectiles.ProjectileSource;
@ -230,4 +231,18 @@ public final class Entities {
public static boolean isAoECloud(EntityType type) {
return type == EntityType.AREA_EFFECT_CLOUD;
}
/**
* Check whether the spawn reason should be considered as a "plugin spawning".
* This is true for custom creations or the summon command.
*
* @param spawnReason the reason
* @return true if considerd plugin spawning
*/
public static boolean isPluginSpawning(CreatureSpawnEvent.SpawnReason spawnReason) {
return switch (spawnReason) {
case CUSTOM, COMMAND -> true;
default -> false;
};
}
}

View File

@ -820,15 +820,30 @@ public final class Materials {
MATERIAL_FLAGS.put(Material.ECHO_SHARD, 0);
MATERIAL_FLAGS.put(Material.REINFORCED_DEEPSLATE, 0);
// 1.19.3: Try to register those things
// 1.20
try {
SIGNS_TAG = Tag.ALL_SIGNS;
MATERIAL_FLAGS.put(Material.BAMBOO_MOSAIC, 0);
MATERIAL_FLAGS.put(Material.BAMBOO_BLOCK, 0);
MATERIAL_FLAGS.put(Material.STRIPPED_BAMBOO_BLOCK, 0);
MATERIAL_FLAGS.put(Material.SUSPICIOUS_SAND, 0);
MATERIAL_FLAGS.put(Material.SUSPICIOUS_GRAVEL, 0);
MATERIAL_FLAGS.put(Material.PITCHER_PLANT, 0);
MATERIAL_FLAGS.put(Material.CHISELED_BOOKSHELF, MODIFIED_ON_RIGHT);
MATERIAL_FLAGS.put(Material.DECORATED_POT, MODIFIED_ON_RIGHT);
MATERIAL_FLAGS.put(Material.BRUSH, 0);
MATERIAL_FLAGS.put(Material.SNIFFER_EGG, 0);
MATERIAL_FLAGS.put(Material.CALIBRATED_SCULK_SENSOR, 0);
MATERIAL_FLAGS.put(Material.PIGLIN_HEAD, 0);
MATERIAL_FLAGS.put(Material.PIGLIN_WALL_HEAD, 0);
MATERIAL_FLAGS.put(Material.TORCHFLOWER_SEEDS, 0);
MATERIAL_FLAGS.put(Material.TORCHFLOWER_CROP, 0);
MATERIAL_FLAGS.put(Material.PITCHER_CROP, 0);
MATERIAL_FLAGS.put(Material.PINK_PETALS, 0);
MATERIAL_FLAGS.put(Material.PITCHER_POD, 0);
MATERIAL_FLAGS.put(Material.NETHERITE_UPGRADE_SMITHING_TEMPLATE, 0);
} catch (NoSuchFieldError ignored) {
SIGNS_TAG = Tag.SIGNS;
}
// Generated via tag
@ -868,6 +883,12 @@ public final class Materials {
putMaterialTag(Tag.CANDLES, MODIFIED_ON_RIGHT);
putMaterialTag(Tag.CANDLE_CAKES, MODIFIED_ON_RIGHT);
putMaterialTag(Tag.CAULDRONS, MODIFIED_ON_RIGHT);
try {
// 1.20
putMaterialTag(Tag.ITEMS_TRIM_TEMPLATES, 0);
putMaterialTag(Tag.ITEMS_DECORATED_POT_SHERDS, 0);
} catch (NoSuchFieldError ignored) {
}
Stream.concat(Stream.concat(
Tag.CORAL_BLOCKS.getValues().stream(),
@ -882,7 +903,6 @@ public final class Materials {
// Check for missing items/blocks
for (Material material : Material.values()) {
//noinspection deprecation
if (material.isLegacy()) continue;
// Add spawn eggs
if (isSpawnEgg(material)) {
@ -1113,6 +1133,7 @@ public final class Materials {
|| material == Material.BARREL
|| material == Material.BLAST_FURNACE
|| material == Material.SMOKER
|| material == Material.CHISELED_BOOKSHELF
|| Tag.ITEMS_CHEST_BOATS.isTagged(material)
|| Tag.SHULKER_BOXES.isTagged(material);
}
@ -1176,6 +1197,7 @@ public final class Materials {
case SKELETON_HORSE_SPAWN_EGG -> EntityType.SKELETON_HORSE;
case SKELETON_SPAWN_EGG -> EntityType.SKELETON;
case SLIME_SPAWN_EGG -> EntityType.SLIME;
case SNIFFER_SPAWN_EGG -> EntityType.SNIFFER;
case SNOW_GOLEM_SPAWN_EGG -> EntityType.SNOWMAN;
case SQUID_SPAWN_EGG -> EntityType.SQUID;
case STRAY_SPAWN_EGG -> EntityType.STRAY;
@ -1435,7 +1457,12 @@ public final class Materials {
case INK_SAC:
return SIGNS_TAG.isTagged(targetMaterial);
case HONEYCOMB:
return isUnwaxedCopper(targetMaterial);
return isUnwaxedCopper(targetMaterial) || SIGNS_TAG.isTagged(targetMaterial);
case BRUSH:
return switch (targetMaterial) {
case SUSPICIOUS_GRAVEL, SUSPICIOUS_SAND -> true;
default -> false;
};
default:
return false;
}

View File

@ -8,7 +8,7 @@ dependencies {
"api"(project(":worldguard-libs:core"))
"api"("com.sk89q.worldedit:worldedit-core:${Versions.WORLDEDIT}")
"implementation"("org.flywaydb:flyway-core:3.0")
"implementation"("org.yaml:snakeyaml:1.33")
"implementation"("org.yaml:snakeyaml:2.0")
"implementation"("com.google.guava:guava:${Versions.GUAVA}")
"compileOnly"("com.google.code.findbugs:jsr305:${Versions.FINDBUGS}")

View File

@ -139,6 +139,8 @@ public abstract class WorldConfiguration {
public boolean disablePlayerCropTrampling;
public boolean disableCreatureTurtleEggTrampling;
public boolean disablePlayerTurtleEggTrampling;
public boolean disableCreatureSnifferEggTrampling;
public boolean disablePlayerSnifferEggTrampling;
public boolean preventLightningFire;
public Set<String> disallowedLightningBlocks;
public boolean disableThunder;

View File

@ -43,6 +43,7 @@ import com.sk89q.worldguard.protection.regions.ProtectedPolygonalRegion;
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
import org.yaml.snakeyaml.DumperOptions;
import org.yaml.snakeyaml.DumperOptions.FlowStyle;
import org.yaml.snakeyaml.LoaderOptions;
import org.yaml.snakeyaml.Yaml;
import org.yaml.snakeyaml.constructor.SafeConstructor;
import org.yaml.snakeyaml.parser.ParserException;
@ -91,7 +92,7 @@ public class YamlRegionFile implements RegionDatabase {
options.setIndent(4);
options.setDefaultFlowStyle(FlowStyle.AUTO);
ERROR_DUMP_YAML = new Yaml(new SafeConstructor(), new Representer(), options);
ERROR_DUMP_YAML = new Yaml(new SafeConstructor(new LoaderOptions()), new Representer(new DumperOptions()), options);
}
/**
@ -338,7 +339,7 @@ public class YamlRegionFile implements RegionDatabase {
}
/**
* Create a YAML processer instance.
* Create a YAML processor instance.
*
* @param file the file
* @return a processor instance
@ -352,7 +353,7 @@ public class YamlRegionFile implements RegionDatabase {
* Dump the given object as YAML for debugging purposes.
*
* @param object the object
* @return the YAML string or an error string if dumping fals
* @return the YAML string or an error string if dumping fails
*/
private static String toYamlOutput(Object object) {
try {

View File

@ -32,6 +32,7 @@ import com.sk89q.worldguard.util.io.Closer;
import com.sk89q.worldguard.util.sql.DataSourceConfig;
import org.yaml.snakeyaml.DumperOptions;
import org.yaml.snakeyaml.DumperOptions.FlowStyle;
import org.yaml.snakeyaml.LoaderOptions;
import org.yaml.snakeyaml.Yaml;
import org.yaml.snakeyaml.constructor.SafeConstructor;
import org.yaml.snakeyaml.representer.Representer;
@ -191,11 +192,11 @@ class SQLRegionDatabase implements RegionDatabase {
DumperOptions options = new DumperOptions();
options.setIndent(2);
options.setDefaultFlowStyle(FlowStyle.FLOW);
Representer representer = new Representer();
Representer representer = new Representer(options);
representer.setDefaultFlowStyle(FlowStyle.FLOW);
// We have to use this in order to properly save non-string values
return new Yaml(new SafeConstructor(), new Representer(), options);
return new Yaml(new SafeConstructor(new LoaderOptions()), representer, options);
}
@Override