Merge branch 'version/7.0.x'

# Conflicts:
#	buildSrc/build.gradle.kts
#	buildSrc/src/main/kotlin/PlatformConfig.kt
#	buildSrc/src/main/kotlin/Versions.kt
This commit is contained in:
Joo200 2022-09-19 11:56:50 +02:00
commit 741f9e231b
23 changed files with 257 additions and 270 deletions

View File

@ -1,5 +1,10 @@
# Changelog
## 7.0.8 (beta)
* Add support for MC 1.19
* Add skulk-growth flag and config option
* Fix possible error when using Paper's entity origin API.
## 7.0.7
* Add rock-growth flag for budding amethyst and pointed dripstone.
* Add /rg migrateheights command. See https://worldguard.enginehub.org/en/latest/regions/commands/#migrate-region-heights

View File

@ -1,11 +1,11 @@
Compiling
=========
You can compile WorldGuard as long as you have some version of Java greater than or equal to 16 installed. Gradle will download JDK 16 specifically if needed,
You can compile WorldGuard as long as you have some version of Java greater than or equal to 17 installed. Gradle will download JDK 17 specifically if needed,
but it needs some version of Java to bootstrap from.
Note that if you have JRE 16 installed, Gradle will currently attempt to use that to compile, which will not work. It is easiest to uninstall JRE 16 and
replace it with JDK 16.
Note that if you have JRE 17 installed, Gradle will currently attempt to use that to compile, which will not work. It is easiest to uninstall JRE 16 and
replace it with JDK 17.
The build process uses Gradle, which you do *not* need to download. WorldGuard is a multi-module project with three modules:

View File

@ -1,5 +1,5 @@
object Versions {
const val WORLDEDIT = "7.2.9"
const val WORLDEDIT = "7.2.10"
const val PISTON = "0.5.7"
const val AUTO_VALUE = "1.9"
const val JUNIT = "5.8.1"

View File

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

View File

@ -244,7 +244,7 @@ public void loadConfiguration() {
disableDeathMessages = getBoolean("player-damage.disable-death-messages", false);
signChestProtection = getBoolean("chest-protection.enable", false);
disableSignChestProtectionCheck = getBoolean("chest-protection.disable-off-check", false);
disableSignChestProtectionCheck = getBoolean("chest-protection.disable-off-check", true);
if (signChestProtection) {
log.warning("Sign-based chest protection is deprecated for removal in a future version. See https://worldguard.enginehub.org/en/latest/chest-protection/ for details.");
} else {
@ -277,6 +277,7 @@ public void loadConfiguration() {
disableMyceliumSpread = getBoolean("dynamics.disable-mycelium-spread", false);
disableVineGrowth = getBoolean("dynamics.disable-vine-growth", false);
disableRockGrowth = getBoolean("dynamics.disable-rock-growth", false);
disableSculkGrowth = getBoolean("dynamics.disable-sculk-growth", false);
disableCropGrowth = getBoolean("dynamics.disable-crop-growth", false);
disableSoilDehydration = getBoolean("dynamics.disable-soil-dehydration", false);
disableCoralBlockFade = getBoolean("dynamics.disable-coral-block-fade", false);

View File

@ -146,6 +146,7 @@ public void load() {
@Override
public void unload() {
sessionManager.shutdown();
configuration.unload();
regionContainer.shutdown();
}

View File

@ -158,11 +158,9 @@ public void onEnable() {
reg.register(ToggleCommands.class);
reg.register(ProtectionCommands.class);
getServer().getScheduler().scheduleSyncDelayedTask(this, () -> {
if (!platform.getGlobalStateManager().hasCommandBookGodMode()) {
reg.register(GeneralCommands.class);
}
}, 0L);
if (!platform.getGlobalStateManager().hasCommandBookGodMode()) {
reg.register(GeneralCommands.class);
}
getServer().getScheduler().scheduleSyncRepeatingTask(this, sessionManager, BukkitSessionManager.RUN_DELAY, BukkitSessionManager.RUN_DELAY);

View File

@ -135,7 +135,8 @@ protected RegionAssociable createRegionAssociable(Cause cause) {
Location loc;
if (PaperLib.isPaper() && config.usePaperEntityOrigin) {
loc = entity.getOrigin();
if (loc == null) {
// Origin world may be null, and thus a Location with a null world created, which cannot be adapted to a WorldEdit location
if (loc == null || loc.getWorld() == null) {
loc = entity.getLocation();
}
} else {

View File

@ -1215,8 +1215,7 @@ private static <T extends Event & Cancellable> void handleInventoryHolderUse(T o
return;
}
if (holder instanceof Entity) {
Entity entity = (Entity) holder;
if (holder instanceof Entity entity) {
Material mat = Materials.getRelatedMaterial((entity).getType());
UseEntityEvent useEntityEvent = new UseEntityEvent(originalEvent, cause, entity);
if (mat != null && hasInteractBypass((entity).getWorld(), mat)) {
@ -1224,8 +1223,7 @@ private static <T extends Event & Cancellable> void handleInventoryHolderUse(T o
}
Events.fireToCancel(originalEvent, useEntityEvent);
} else {
if (holder instanceof BlockState) {
final BlockState block = (BlockState) holder;
if (holder instanceof BlockState block && block.isPlaced()) {
final UseBlockEvent useBlockEvent = new UseBlockEvent(originalEvent, cause, block.getBlock());
if (hasInteractBypass(block.getWorld(), block.getType())) {
useBlockEvent.setAllowed(true);

View File

@ -148,6 +148,8 @@ public void onPlayerQuit(PlayerQuitEvent event) {
if (loc != null) {
player.teleport(BukkitAdapter.adapt(loc));
}
session.uninitialize(localPlayer);
}
private class EntityMountListener implements Listener {

View File

@ -588,7 +588,7 @@ public void onBlockSpread(BlockSpreadEvent event) {
}
}
if (newType == Material.BUDDING_AMETHYST || newType == Material.POINTED_DRIPSTONE) {
if (Materials.isAmethystGrowth(newType) || newType == Material.POINTED_DRIPSTONE) {
if (wcfg.disableRockGrowth) {
event.setCancelled(true);
return;
@ -601,6 +601,19 @@ public void onBlockSpread(BlockSpreadEvent event) {
}
}
if (Materials.isSculkGrowth(newType)) {
if (wcfg.disableSculkGrowth) {
event.setCancelled(true);
return;
}
if (wcfg.useRegions && !StateFlag.test(WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery()
.queryState(BukkitAdapter.adapt(event.getBlock().getLocation()), (RegionAssociable) null, Flags.SCULK_GROWTH))) {
event.setCancelled(true);
return;
}
}
handleGrow(event, event.getBlock().getLocation(), newType);
}

View File

@ -100,4 +100,11 @@ public boolean isUsingTimings() {
public void setUsingTimings(boolean useTimings) {
this.useTimings = useTimings;
}
public void shutdown() {
for (Player player : Bukkit.getServer().getOnlinePlayers()) {
LocalPlayer localPlayer = WorldGuardPlugin.inst().wrapPlayer(player);
get(localPlayer).uninitialize(localPlayer);
}
}
}

View File

@ -101,8 +101,20 @@ public static boolean isRiddenOnUse(Entity entity) {
* @return true if the type is a vehicle type
*/
public static boolean isVehicle(EntityType type) {
return type == EntityType.BOAT
|| isMinecart(type);
return isBoat(type) || isMinecart(type);
}
/**
* Test whether the given entity type is a Boat type.
*
* @param type the type
* @return true if the type is a Boat type
*/
public static boolean isBoat(EntityType type) {
return switch(type) {
case BOAT, CHEST_BOAT -> true;
default -> false;
};
}
/**
@ -112,13 +124,11 @@ public static boolean isVehicle(EntityType type) {
* @return true if the type is a Minecart type
*/
public static boolean isMinecart(EntityType type) {
return type == EntityType.MINECART
|| type == EntityType.MINECART_CHEST
|| type == EntityType.MINECART_COMMAND
|| type == EntityType.MINECART_FURNACE
|| type == EntityType.MINECART_HOPPER
|| type == EntityType.MINECART_MOB_SPAWNER
|| type == EntityType.MINECART_TNT;
return switch(type) {
case MINECART, MINECART_CHEST, MINECART_COMMAND, MINECART_FURNACE,
MINECART_HOPPER, MINECART_MOB_SPAWNER, MINECART_TNT -> true;
default -> false;
};
}
/**

View File

@ -794,6 +794,27 @@ public final class Materials {
MATERIAL_FLAGS.put(Material.HANGING_ROOTS, 0);
MATERIAL_FLAGS.put(Material.POINTED_DRIPSTONE, 0);
// 1.19
MATERIAL_FLAGS.put(Material.MUD, 0);
MATERIAL_FLAGS.put(Material.MANGROVE_ROOTS, 0);
MATERIAL_FLAGS.put(Material.MUDDY_MANGROVE_ROOTS, 0);
MATERIAL_FLAGS.put(Material.PACKED_MUD, 0);
MATERIAL_FLAGS.put(Material.MUD_BRICKS, 0);
MATERIAL_FLAGS.put(Material.SCULK, 0);
MATERIAL_FLAGS.put(Material.SCULK_VEIN, 0);
MATERIAL_FLAGS.put(Material.SCULK_CATALYST, 0);
MATERIAL_FLAGS.put(Material.SCULK_SHRIEKER, 0);
MATERIAL_FLAGS.put(Material.TADPOLE_BUCKET, 0);
MATERIAL_FLAGS.put(Material.RECOVERY_COMPASS, 0);
MATERIAL_FLAGS.put(Material.DISC_FRAGMENT_5, 0);
MATERIAL_FLAGS.put(Material.GOAT_HORN, 0);
MATERIAL_FLAGS.put(Material.OCHRE_FROGLIGHT, 0);
MATERIAL_FLAGS.put(Material.VERDANT_FROGLIGHT, 0);
MATERIAL_FLAGS.put(Material.PEARLESCENT_FROGLIGHT, 0);
MATERIAL_FLAGS.put(Material.FROGSPAWN, 0);
MATERIAL_FLAGS.put(Material.ECHO_SHARD, 0);
MATERIAL_FLAGS.put(Material.REINFORCED_DEEPSLATE, 0);
// Generated via tag
for (Material woodenDoor : Tag.WOODEN_DOORS.getValues()) {
MATERIAL_FLAGS.put(woodenDoor, MODIFIED_ON_RIGHT);
@ -816,7 +837,7 @@ public final class Materials {
for (Material plank : Tag.PLANKS.getValues()) {
MATERIAL_FLAGS.put(plank, 0);
}
for (Material carpet : Tag.CARPETS.getValues()) {
for (Material carpet : Tag.WOOL_CARPETS.getValues()) {
MATERIAL_FLAGS.put(carpet, 0);
}
for (Material sapling : Tag.SAPLINGS.getValues()) {
@ -956,6 +977,7 @@ public final class Materials {
// DAMAGE_EFFECTS.add(PotionEffectType.DOLPHINS_GRACE);
DAMAGE_EFFECTS.add(PotionEffectType.BAD_OMEN);
// DAMAGE_EFFECTS.add(PotionEffectType.HERO_OF_THE_VILLAGE);
DAMAGE_EFFECTS.add(PotionEffectType.DARKNESS);
}
private Materials() {
@ -1143,86 +1165,38 @@ public static boolean isInventoryBlock(Material material) {
|| material == Material.BARREL
|| material == Material.BLAST_FURNACE
|| material == Material.SMOKER
|| Tag.ITEMS_CHEST_BOATS.isTagged(material)
|| Tag.SHULKER_BOXES.isTagged(material);
}
public static boolean isSpawnEgg(Material material) {
switch (material) {
case AXOLOTL_SPAWN_EGG:
case BAT_SPAWN_EGG:
case BEE_SPAWN_EGG:
case BLAZE_SPAWN_EGG:
case CAT_SPAWN_EGG:
case CAVE_SPIDER_SPAWN_EGG:
case CHICKEN_SPAWN_EGG:
case COD_SPAWN_EGG:
case COW_SPAWN_EGG:
case CREEPER_SPAWN_EGG:
case DOLPHIN_SPAWN_EGG:
case DONKEY_SPAWN_EGG:
case DROWNED_SPAWN_EGG:
case ELDER_GUARDIAN_SPAWN_EGG:
case ENDERMAN_SPAWN_EGG:
case ENDERMITE_SPAWN_EGG:
case EVOKER_SPAWN_EGG:
case FOX_SPAWN_EGG:
case GHAST_SPAWN_EGG:
case GLOW_SQUID_SPAWN_EGG:
case GOAT_SPAWN_EGG:
case GUARDIAN_SPAWN_EGG:
case HOGLIN_SPAWN_EGG:
case HORSE_SPAWN_EGG:
case HUSK_SPAWN_EGG:
case LLAMA_SPAWN_EGG:
case MAGMA_CUBE_SPAWN_EGG:
case MOOSHROOM_SPAWN_EGG:
case MULE_SPAWN_EGG:
case OCELOT_SPAWN_EGG:
case PANDA_SPAWN_EGG:
case PARROT_SPAWN_EGG:
case PHANTOM_SPAWN_EGG:
case PIGLIN_BRUTE_SPAWN_EGG:
case PIGLIN_SPAWN_EGG:
case PIG_SPAWN_EGG:
case PILLAGER_SPAWN_EGG:
case POLAR_BEAR_SPAWN_EGG:
case PUFFERFISH_SPAWN_EGG:
case RABBIT_SPAWN_EGG:
case RAVAGER_SPAWN_EGG:
case SALMON_SPAWN_EGG:
case SHEEP_SPAWN_EGG:
case SHULKER_SPAWN_EGG:
case SILVERFISH_SPAWN_EGG:
case SKELETON_HORSE_SPAWN_EGG:
case SKELETON_SPAWN_EGG:
case SLIME_SPAWN_EGG:
case SPIDER_SPAWN_EGG:
case SQUID_SPAWN_EGG:
case STRAY_SPAWN_EGG:
case STRIDER_SPAWN_EGG:
case TRADER_LLAMA_SPAWN_EGG:
case TROPICAL_FISH_SPAWN_EGG:
case TURTLE_SPAWN_EGG:
case VEX_SPAWN_EGG:
case VILLAGER_SPAWN_EGG:
case VINDICATOR_SPAWN_EGG:
case WANDERING_TRADER_SPAWN_EGG:
case WITCH_SPAWN_EGG:
case WITHER_SKELETON_SPAWN_EGG:
case WOLF_SPAWN_EGG:
case ZOGLIN_SPAWN_EGG:
case ZOMBIE_HORSE_SPAWN_EGG:
case ZOMBIFIED_PIGLIN_SPAWN_EGG:
case ZOMBIE_SPAWN_EGG:
case ZOMBIE_VILLAGER_SPAWN_EGG:
return true;
default:
return false;
}
return switch (material) {
case AXOLOTL_SPAWN_EGG, BAT_SPAWN_EGG, BEE_SPAWN_EGG, BLAZE_SPAWN_EGG, CAT_SPAWN_EGG,
CAVE_SPIDER_SPAWN_EGG, CHICKEN_SPAWN_EGG, COD_SPAWN_EGG, COW_SPAWN_EGG, CREEPER_SPAWN_EGG,
DOLPHIN_SPAWN_EGG, DONKEY_SPAWN_EGG, DROWNED_SPAWN_EGG, ELDER_GUARDIAN_SPAWN_EGG,
ENDERMAN_SPAWN_EGG, ENDERMITE_SPAWN_EGG, EVOKER_SPAWN_EGG, FOX_SPAWN_EGG,
GHAST_SPAWN_EGG, GLOW_SQUID_SPAWN_EGG, GOAT_SPAWN_EGG, GUARDIAN_SPAWN_EGG,
HOGLIN_SPAWN_EGG, HORSE_SPAWN_EGG, HUSK_SPAWN_EGG, LLAMA_SPAWN_EGG, MAGMA_CUBE_SPAWN_EGG,
MOOSHROOM_SPAWN_EGG, MULE_SPAWN_EGG, OCELOT_SPAWN_EGG, PANDA_SPAWN_EGG, PARROT_SPAWN_EGG,
PHANTOM_SPAWN_EGG, PIGLIN_BRUTE_SPAWN_EGG, PIGLIN_SPAWN_EGG, PIG_SPAWN_EGG, PILLAGER_SPAWN_EGG,
POLAR_BEAR_SPAWN_EGG, PUFFERFISH_SPAWN_EGG, RABBIT_SPAWN_EGG, RAVAGER_SPAWN_EGG,
SALMON_SPAWN_EGG, SHEEP_SPAWN_EGG, SHULKER_SPAWN_EGG, SILVERFISH_SPAWN_EGG,
SKELETON_HORSE_SPAWN_EGG, SKELETON_SPAWN_EGG, SLIME_SPAWN_EGG, SPIDER_SPAWN_EGG,
SQUID_SPAWN_EGG, STRAY_SPAWN_EGG, STRIDER_SPAWN_EGG, TRADER_LLAMA_SPAWN_EGG,
TROPICAL_FISH_SPAWN_EGG, TURTLE_SPAWN_EGG, VEX_SPAWN_EGG, VILLAGER_SPAWN_EGG,
VINDICATOR_SPAWN_EGG, WANDERING_TRADER_SPAWN_EGG, WITCH_SPAWN_EGG, WITHER_SKELETON_SPAWN_EGG,
WOLF_SPAWN_EGG, ZOGLIN_SPAWN_EGG, ZOMBIE_HORSE_SPAWN_EGG, ZOMBIFIED_PIGLIN_SPAWN_EGG,
ZOMBIE_SPAWN_EGG, ZOMBIE_VILLAGER_SPAWN_EGG, ALLAY_SPAWN_EGG, FROG_SPAWN_EGG, TADPOLE_SPAWN_EGG,
WARDEN_SPAWN_EGG ->
true;
default -> false;
};
}
public static EntityType getEntitySpawnEgg(Material material) {
switch (material) {
case ALLAY_SPAWN_EGG:
return EntityType.ALLAY;
case AXOLOTL_SPAWN_EGG:
return EntityType.AXOLOTL;
case SPIDER_SPAWN_EGG:
@ -1261,6 +1235,8 @@ public static EntityType getEntitySpawnEgg(Material material) {
return EntityType.EVOKER;
case FOX_SPAWN_EGG:
return EntityType.FOX;
case FROG_SPAWN_EGG:
return EntityType.FROG;
case GHAST_SPAWN_EGG:
return EntityType.GHAST;
case GLOW_SQUID_SPAWN_EGG:
@ -1325,6 +1301,8 @@ public static EntityType getEntitySpawnEgg(Material material) {
return EntityType.STRAY;
case STRIDER_SPAWN_EGG:
return EntityType.STRIDER;
case TADPOLE_SPAWN_EGG:
return EntityType.TADPOLE;
case TRADER_LLAMA_SPAWN_EGG:
return EntityType.TRADER_LLAMA;
case TROPICAL_FISH_SPAWN_EGG:
@ -1339,6 +1317,8 @@ public static EntityType getEntitySpawnEgg(Material material) {
return EntityType.VINDICATOR;
case WANDERING_TRADER_SPAWN_EGG:
return EntityType.WANDERING_TRADER;
case WARDEN_SPAWN_EGG:
return EntityType.WARDEN;
case WITCH_SPAWN_EGG:
return EntityType.WITCH;
case WITHER_SKELETON_SPAWN_EGG:
@ -1380,26 +1360,13 @@ public static boolean isCoral(Material material) {
* @return true if the material is a crop
*/
public static boolean isCrop(Material type) {
switch (type) {
case WHEAT:
case CARROTS:
case POTATOES:
case BEETROOTS:
case MELON_STEM:
case PUMPKIN_STEM:
case PUMPKIN:
case MELON:
case CACTUS:
case SUGAR_CANE:
case BAMBOO:
case BAMBOO_SAPLING:
case SWEET_BERRY_BUSH:
case NETHER_WART:
case CAVE_VINES:
case CAVE_VINES_PLANT:
return true;
}
return false;
return switch (type) {
case WHEAT, CARROTS, POTATOES, BEETROOTS, MELON_STEM, PUMPKIN_STEM,
PUMPKIN, MELON, CACTUS, SUGAR_CANE, BAMBOO, BAMBOO_SAPLING,
SWEET_BERRY_BUSH, NETHER_WART, CAVE_VINES, CAVE_VINES_PLANT ->
true;
default -> false;
};
}
/**
@ -1434,18 +1401,11 @@ public static boolean isUseFlagApplicable(Material material) {
|| Tag.PRESSURE_PLATES.isTagged(material)) {
return true;
}
switch (material) {
case LEVER:
case LECTERN:
case ENCHANTING_TABLE:
case BELL:
case LOOM:
case CARTOGRAPHY_TABLE:
case STONECUTTER:
case GRINDSTONE:
return true;
default: return false;
}
return switch (material) {
case LEVER, LECTERN, ENCHANTING_TABLE, BELL, LOOM,
CARTOGRAPHY_TABLE, STONECUTTER, GRINDSTONE -> true;
default -> false;
};
}
/**
@ -1524,37 +1484,17 @@ public static boolean hasDamageEffect(Collection<PotionEffect> effects) {
* @return true if equippable armor
*/
public static boolean isArmor(Material type) {
switch (type) {
case LEATHER_HELMET:
case LEATHER_CHESTPLATE:
case LEATHER_LEGGINGS:
case LEATHER_BOOTS:
case CHAINMAIL_HELMET:
case CHAINMAIL_CHESTPLATE:
case CHAINMAIL_LEGGINGS:
case CHAINMAIL_BOOTS:
case IRON_HELMET:
case IRON_CHESTPLATE:
case IRON_LEGGINGS:
case IRON_BOOTS:
case DIAMOND_HELMET:
case DIAMOND_CHESTPLATE:
case DIAMOND_LEGGINGS:
case DIAMOND_BOOTS:
case GOLDEN_HELMET:
case GOLDEN_CHESTPLATE:
case GOLDEN_LEGGINGS:
case GOLDEN_BOOTS:
case NETHERITE_HELMET:
case NETHERITE_CHESTPLATE:
case NETHERITE_LEGGINGS:
case NETHERITE_BOOTS:
case TURTLE_HELMET:
case ELYTRA:
return true;
default:
return false;
}
return switch (type) {
case LEATHER_HELMET, LEATHER_CHESTPLATE, LEATHER_LEGGINGS, LEATHER_BOOTS,
CHAINMAIL_HELMET, CHAINMAIL_CHESTPLATE, CHAINMAIL_LEGGINGS, CHAINMAIL_BOOTS,
IRON_HELMET, IRON_CHESTPLATE, IRON_LEGGINGS, IRON_BOOTS,
DIAMOND_HELMET, DIAMOND_CHESTPLATE, DIAMOND_LEGGINGS, DIAMOND_BOOTS,
GOLDEN_HELMET, GOLDEN_CHESTPLATE, GOLDEN_LEGGINGS, GOLDEN_BOOTS,
NETHERITE_HELMET, NETHERITE_CHESTPLATE, NETHERITE_LEGGINGS, NETHERITE_BOOTS,
TURTLE_HELMET, ELYTRA ->
true;
default -> false;
};
}
/**
@ -1575,15 +1515,12 @@ public static boolean isToolApplicable(Material toolMaterial, Material targetMat
case GOLDEN_HOE:
case DIAMOND_HOE:
case NETHERITE_HOE:
switch (targetMaterial) {
case GRASS_BLOCK:
case DIRT:
case DIRT_PATH:
case ROOTED_DIRT:
// case COARSE_DIRT: // already handled by the server...
return true;
}
return false;
return switch (targetMaterial) {
case GRASS_BLOCK, DIRT, DIRT_PATH, ROOTED_DIRT ->
// case COARSE_DIRT: // already handled by the server...
true;
default -> false;
};
case WOODEN_AXE:
case STONE_AXE:
case IRON_AXE:
@ -1592,47 +1529,28 @@ public static boolean isToolApplicable(Material toolMaterial, Material targetMat
case NETHERITE_AXE:
if (isWaxedCopper(targetMaterial))
return true;
switch (targetMaterial) {
case OAK_LOG:
case DARK_OAK_LOG:
case ACACIA_LOG:
case BIRCH_LOG:
case SPRUCE_LOG:
case JUNGLE_LOG:
case OAK_WOOD:
case DARK_OAK_WOOD:
case ACACIA_WOOD:
case BIRCH_WOOD:
case SPRUCE_WOOD:
case JUNGLE_WOOD:
case CRIMSON_STEM:
case WARPED_STEM:
case CRIMSON_HYPHAE:
case WARPED_HYPHAE:
return true;
}
return false;
return switch (targetMaterial) {
case OAK_LOG, DARK_OAK_LOG, ACACIA_LOG, BIRCH_LOG, SPRUCE_LOG, JUNGLE_LOG,
OAK_WOOD, DARK_OAK_WOOD, ACACIA_WOOD, BIRCH_WOOD, SPRUCE_WOOD,
JUNGLE_WOOD, CRIMSON_STEM, WARPED_STEM, CRIMSON_HYPHAE, WARPED_HYPHAE ->
true;
default -> false;
};
case WOODEN_SHOVEL:
case STONE_SHOVEL:
case IRON_SHOVEL:
case GOLDEN_SHOVEL:
case DIAMOND_SHOVEL:
case NETHERITE_SHOVEL:
switch (targetMaterial) {
case GRASS_BLOCK:
case CAMPFIRE:
case SOUL_CAMPFIRE:
return true;
}
return false;
return switch (targetMaterial) {
case GRASS_BLOCK, CAMPFIRE, SOUL_CAMPFIRE -> true;
default -> false;
};
case SHEARS:
switch (targetMaterial) {
case PUMPKIN:
case BEE_NEST:
case BEEHIVE:
return true;
}
return false;
return switch (targetMaterial) {
case PUMPKIN, BEE_NEST, BEEHIVE -> true;
default -> false;
};
case BLACK_DYE:
case BLUE_DYE:
case BROWN_DYE:
@ -1664,48 +1582,37 @@ public static boolean isFire(Material type) {
}
public static boolean isWaxedCopper(Material type) {
switch (type) {
case WAXED_COPPER_BLOCK:
case WAXED_EXPOSED_COPPER:
case WAXED_WEATHERED_COPPER:
case WAXED_OXIDIZED_COPPER:
case WAXED_CUT_COPPER:
case WAXED_EXPOSED_CUT_COPPER:
case WAXED_WEATHERED_CUT_COPPER:
case WAXED_OXIDIZED_CUT_COPPER:
case WAXED_CUT_COPPER_STAIRS:
case WAXED_EXPOSED_CUT_COPPER_STAIRS:
case WAXED_WEATHERED_CUT_COPPER_STAIRS:
case WAXED_OXIDIZED_CUT_COPPER_STAIRS:
case WAXED_CUT_COPPER_SLAB:
case WAXED_EXPOSED_CUT_COPPER_SLAB:
case WAXED_WEATHERED_CUT_COPPER_SLAB:
case WAXED_OXIDIZED_CUT_COPPER_SLAB:
return true;
}
return false;
return switch (type) {
case WAXED_COPPER_BLOCK, WAXED_EXPOSED_COPPER, WAXED_WEATHERED_COPPER, WAXED_OXIDIZED_COPPER,
WAXED_CUT_COPPER, WAXED_EXPOSED_CUT_COPPER, WAXED_WEATHERED_CUT_COPPER,
WAXED_OXIDIZED_CUT_COPPER, WAXED_CUT_COPPER_STAIRS, WAXED_EXPOSED_CUT_COPPER_STAIRS,
WAXED_WEATHERED_CUT_COPPER_STAIRS, WAXED_OXIDIZED_CUT_COPPER_STAIRS, WAXED_CUT_COPPER_SLAB,
WAXED_EXPOSED_CUT_COPPER_SLAB, WAXED_WEATHERED_CUT_COPPER_SLAB, WAXED_OXIDIZED_CUT_COPPER_SLAB ->
true;
default -> false;
};
}
public static boolean isUnwaxedCopper(Material type) {
switch (type) {
case COPPER_BLOCK:
case EXPOSED_COPPER:
case WEATHERED_COPPER:
case OXIDIZED_COPPER:
case CUT_COPPER:
case EXPOSED_CUT_COPPER:
case WEATHERED_CUT_COPPER:
case OXIDIZED_CUT_COPPER:
case CUT_COPPER_STAIRS:
case EXPOSED_CUT_COPPER_STAIRS:
case WEATHERED_CUT_COPPER_STAIRS:
case OXIDIZED_CUT_COPPER_STAIRS:
case CUT_COPPER_SLAB:
case EXPOSED_CUT_COPPER_SLAB:
case WEATHERED_CUT_COPPER_SLAB:
case OXIDIZED_CUT_COPPER_SLAB:
return true;
}
return false;
return switch (type) {
case COPPER_BLOCK, EXPOSED_COPPER, WEATHERED_COPPER, OXIDIZED_COPPER, CUT_COPPER,
EXPOSED_CUT_COPPER, WEATHERED_CUT_COPPER, OXIDIZED_CUT_COPPER, CUT_COPPER_STAIRS,
EXPOSED_CUT_COPPER_STAIRS, WEATHERED_CUT_COPPER_STAIRS, OXIDIZED_CUT_COPPER_STAIRS,
CUT_COPPER_SLAB, EXPOSED_CUT_COPPER_SLAB, WEATHERED_CUT_COPPER_SLAB, OXIDIZED_CUT_COPPER_SLAB ->
true;
default -> false;
};
}
public static boolean isAmethystGrowth(Material mat) {
return mat == Material.BUDDING_AMETHYST
|| mat == Material.AMETHYST_CLUSTER
|| mat == Material.LARGE_AMETHYST_BUD
|| mat == Material.MEDIUM_AMETHYST_BUD
|| mat == Material.SMALL_AMETHYST_BUD;
}
public static boolean isSculkGrowth(Material mat) {
return mat == Material.SCULK || mat == Material.SCULK_VEIN;
}
}

View File

@ -20,6 +20,7 @@
package com.sk89q.worldguard.bukkit.util.report;
import com.sk89q.worldedit.util.report.DataReport;
import io.papermc.lib.PaperLib;
import org.bukkit.Bukkit;
import org.bukkit.Server;
@ -33,9 +34,18 @@ public ServerReport() {
append("Bukkit Version", server.getBukkitVersion());
append("Implementation", server.getName() + " " + server.getVersion());
append("Player Count", "%d/%d", Bukkit.getOnlinePlayers().size(), server.getMaxPlayers());
append("Server Class Source", server.getClass().getProtectionDomain().getCodeSource().getLocation());
DataReport onlineMode = new DataReport("Online Mode");
onlineMode.append("enabled?", server.getOnlineMode());
if (PaperLib.isSpigot()) {
onlineMode.append("BungeeCord support?", Bukkit.spigot().getConfig().getBoolean("settings.bungeecord", false));
}
if (PaperLib.isPaper()) {
onlineMode.append("Velocity support?", Bukkit.spigot().getPaperConfig().getBoolean("settings.velocity-support.enabled", false));
}
append(onlineMode.getTitle(), onlineMode);
DataReport spawning = new DataReport("Spawning");
spawning.append("Ambient Spawn Limit", server.getAmbientSpawnLimit());
spawning.append("Animal Spawn Limit", server.getAnimalSpawnLimit());

View File

@ -3,4 +3,4 @@ main: com.sk89q.worldguard.bukkit.WorldGuardPlugin
version: "${internalVersion}"
depend: [WorldEdit]
softdepend: [CommandBook]
api-version: 1.17
api-version: 1.19

View File

@ -330,17 +330,9 @@ public void claim(CommandContext args, Actor sender) throws CommandException {
}
}
RegionAdder task = new RegionAdder(manager, region);
task.setLocatorPolicy(UserLocatorPolicy.UUID_ONLY);
task.setOwnersInput(new String[]{player.getName()});
final String description = String.format("Claiming region '%s'", id);
AsyncCommandBuilder.wrap(task, sender)
.registerWithSupervisor(WorldGuard.getInstance().getSupervisor(), description)
.sendMessageAfterDelay("(Please wait... " + description + ")")
.onSuccess(TextComponent.of(String.format("A new region has been claimed named '%s'.", id)), null)
.onFailure("Failed to claim region", WorldGuard.getInstance().getExceptionConverter())
.buildAndExec(WorldGuard.getInstance().getExecutorService());
region.getOwners().addPlayer(player);
manager.addRegion(region);
player.print(TextComponent.of(String.format("A new region has been claimed named '%s'.", id)));
}
/**
@ -1200,7 +1192,7 @@ public void teleport(CommandContext args, Actor sender) throws CommandException
// TODO: Add some method to create a safe teleport location.
// The method AbstractPlayerActor$findFreePoisition(Location loc) is no good way for this.
// It doesn't return the found location and it can't be checked if the location is inside the region.
throw new CommandException("Center teleport is only availible in Spectator gamemode.");
throw new CommandException("Center teleport is only available in Spectator gamemode.");
}
} else {
teleportLocation = FlagValueCalculator.getEffectiveFlagOf(existing, Flags.TELE_LOC, player);

View File

@ -159,6 +159,7 @@ public abstract class WorldConfiguration {
public boolean disableMyceliumSpread;
public boolean disableVineGrowth;
public boolean disableRockGrowth;
public boolean disableSculkGrowth;
public boolean disableCropGrowth;
public boolean disableEndermanGriefing;
public boolean disableSnowmanTrails;

View File

@ -409,15 +409,18 @@ private Component toPlayersComponent(ProfileCache cache) {
final TextComponent.Builder builder = TextComponent.builder("");
final Iterator<TextComponent> profiles = profileMap.keySet().stream().sorted().map(name -> {
final UUID uuid = profileMap.get(name);
final TextComponent component = TextComponent.of(name, TextColor.YELLOW)
.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, uuid == null
? TextComponent.of("Name only", TextColor.GRAY)
: TextComponent.of("Last known name of uuid: ", TextColor.GRAY)
.append(TextComponent.of(uuid.toString(), TextColor.WHITE))));
if (uuid == null) {
return component;
return TextComponent.of(name, TextColor.YELLOW)
.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Name only", TextColor.GRAY)
.append(TextComponent.newline()).append(TextComponent.of("Click to copy"))))
.clickEvent(ClickEvent.of(ClickEvent.Action.COPY_TO_CLIPBOARD, name));
} else {
return TextComponent.of(name, TextColor.YELLOW)
.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Last known name of uuid: ", TextColor.GRAY)
.append(TextComponent.of(uuid.toString(), TextColor.WHITE))
.append(TextComponent.newline()).append(TextComponent.of("Click to copy"))))
.clickEvent(ClickEvent.of(ClickEvent.Action.COPY_TO_CLIPBOARD, uuid.toString()));
}
return component.clickEvent(ClickEvent.of(ClickEvent.Action.SUGGEST_COMMAND, uuid.toString()));
}).iterator();
while (profiles.hasNext()) {
builder.append(profiles.next());
@ -428,9 +431,11 @@ private Component toPlayersComponent(ProfileCache cache) {
if (!uuids.isEmpty()) {
builder.append(TextComponent.of(uuids.size() + " unknown uuid" + (uuids.size() == 1 ? "" : "s"), TextColor.GRAY)
.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TextComponent.of(String.join("\n", uuids))
.append(TextComponent.newline().append(TextComponent.of("Click to select")))))
.clickEvent(ClickEvent.of(ClickEvent.Action.SUGGEST_COMMAND, String.join(",", uuids))));
.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Unable to resolve the name for:", TextColor.GRAY)
.append(TextComponent.newline())
.append(TextComponent.of(String.join("\n", uuids), TextColor.WHITE))
.append(TextComponent.newline().append(TextComponent.of("Click to copy")))))
.clickEvent(ClickEvent.of(ClickEvent.Action.COPY_TO_CLIPBOARD, String.join(",", uuids))));
}

View File

@ -121,6 +121,7 @@ public final class Flags {
public static final StateFlag MYCELIUM_SPREAD = register(new StateFlag("mycelium-spread", true));
public static final StateFlag VINE_GROWTH = register(new StateFlag("vine-growth", true));
public static final StateFlag ROCK_GROWTH = register(new StateFlag("rock-growth", true));
public static final StateFlag SCULK_GROWTH = register (new StateFlag("sculk-growth", true));
public static final StateFlag CROP_GROWTH = register(new StateFlag("crop-growth", true));
public static final StateFlag SOIL_DRY = register(new StateFlag("soil-dry", true));
public static final StateFlag CORAL_FADE = register(new StateFlag("coral-fade", true));

View File

@ -120,6 +120,21 @@ public void initialize(LocalPlayer player) {
}
}
/**
* Uninitialize the session.
*
* @param player The player
*/
public void uninitialize(LocalPlayer player) {
RegionQuery query = WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery();
Location location = player.getLocation();
ApplicableRegionSet set = query.getApplicableRegions(location);
for (Handler handler : handlers.values()) {
handler.uninitialize(player, location, set);
}
}
/**
* Tick the session.
*

View File

@ -45,6 +45,12 @@ public final void initialize(LocalPlayer player, Location current, ApplicableReg
onInitialValue(player, set, lastValue);
}
@Override
public final void uninitialize(LocalPlayer player, Location current, ApplicableRegionSet set) {
onClearValue(player, set);
lastValue = null;
}
@Override
public boolean onCrossBoundary(LocalPlayer player, Location from, Location to, ApplicableRegionSet toSet, Set<ProtectedRegion> entered, Set<ProtectedRegion> exited, MoveType moveType) {
if (entered.isEmpty() && exited.isEmpty()
@ -74,4 +80,8 @@ public boolean onCrossBoundary(LocalPlayer player, Location from, Location to, A
protected abstract boolean onAbsentValue(LocalPlayer player, Location from, Location to, ApplicableRegionSet toSet, T lastValue, MoveType moveType);
protected void onClearValue(LocalPlayer player, ApplicableRegionSet set) {
Location current = player.getLocation();
onAbsentValue(player, current, current, set, lastValue, MoveType.OTHER_NON_CANCELLABLE);
}
}

View File

@ -74,6 +74,16 @@ public Session getSession() {
public void initialize(LocalPlayer player, Location current, ApplicableRegionSet set) {
}
/**
* Called when the session should clear its caches.
*
* @param player The player
* @param current The player's current location
* @param set The regions for the current location
*/
public void uninitialize(LocalPlayer player, Location current, ApplicableRegionSet set) {
}
/**
* Called when {@link Session#testMoveTo(LocalPlayer, Location, MoveType)} is called.
*