mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2024-11-15 23:25:21 +01:00
Update Protections to 1.20
* add new materials * add protections for sniffer eggs * add protection for signs
This commit is contained in:
parent
c61e9f1fe0
commit
853631139d
@ -256,6 +256,8 @@ public void loadConfiguration() {
|
||||
|
||||
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);
|
||||
|
@ -454,7 +454,9 @@ public void onPlayerInteract(PlayerInteractEvent event) {
|
||||
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 void onBlockIgnite(BlockIgniteEvent event) {
|
||||
|
||||
@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));
|
||||
}
|
||||
}
|
||||
|
@ -120,6 +120,10 @@ public void onEntityInteract(EntityInteractEvent event) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if (block.getType() == Material.SNIFFER_EGG && wcfg.disableCreatureSnifferEggTrampling) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
|
@ -307,6 +307,10 @@ private void handlePhysicalInteract(PlayerInteractEvent event) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if (type == Material.SNIFFER_EGG && wcfg.disablePlayerSnifferEggTrampling) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
|
@ -820,15 +820,30 @@ private static void putMaterialTag(Tag<Material> tag, Integer value) {
|
||||
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 @@ private static void putMaterialTag(Tag<Material> tag, Integer value) {
|
||||
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 @@ private static void putMaterialTag(Tag<Material> tag, Integer value) {
|
||||
|
||||
// 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 static boolean isInventoryBlock(Material material) {
|
||||
|| 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 static EntityType getEntitySpawnEgg(Material material) {
|
||||
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 static boolean isToolApplicable(Material toolMaterial, Material targetMat
|
||||
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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user