From 04452475ac6a5a0514bcf3472f71f563865d495a Mon Sep 17 00:00:00 2001 From: JDIALIA Date: Tue, 16 Nov 2021 07:27:40 +1100 Subject: [PATCH 01/23] #674: Optimize and cleanup PermissibleBase --- .../org/bukkit/permissions/PermissibleBase.java | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/main/java/org/bukkit/permissions/PermissibleBase.java b/src/main/java/org/bukkit/permissions/PermissibleBase.java index 497775f7..728fc46d 100644 --- a/src/main/java/org/bukkit/permissions/PermissibleBase.java +++ b/src/main/java/org/bukkit/permissions/PermissibleBase.java @@ -16,17 +16,14 @@ import org.jetbrains.annotations.Nullable; * Base Permissible for use in any Permissible object via proxy or extension */ public class PermissibleBase implements Permissible { - private ServerOperator opable; - private Permissible parent = this; + private final ServerOperator opable; + private final Permissible parent; private final List attachments = new LinkedList(); private final Map permissions = new HashMap(); public PermissibleBase(@Nullable ServerOperator opable) { this.opable = opable; - - if (opable instanceof Permissible) { - this.parent = (Permissible) opable; - } + this.parent = (opable instanceof Permissible) ? (Permissible) opable : this; recalculatePermissions(); } @@ -144,8 +141,7 @@ public class PermissibleBase implements Permissible { throw new IllegalArgumentException("Attachment cannot be null"); } - if (attachments.contains(attachment)) { - attachments.remove(attachment); + if (attachments.remove(attachment)) { PermissionRemovedExecutor ex = attachment.getRemovalCallback(); if (ex != null) { @@ -253,7 +249,7 @@ public class PermissibleBase implements Permissible { } private static class RemoveAttachmentRunnable implements Runnable { - private PermissionAttachment attachment; + private final PermissionAttachment attachment; public RemoveAttachmentRunnable(@NotNull PermissionAttachment attachment) { this.attachment = attachment; From d32e3c764edd6a449ddd220720185d266c2193f9 Mon Sep 17 00:00:00 2001 From: Cerus Date: Thu, 18 Nov 2021 08:14:50 +1100 Subject: [PATCH 02/23] #675: Fix typo in ItemFrame#setFixed --- src/main/java/org/bukkit/entity/ItemFrame.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/bukkit/entity/ItemFrame.java b/src/main/java/org/bukkit/entity/ItemFrame.java index 1568bd66..b688b385 100644 --- a/src/main/java/org/bukkit/entity/ItemFrame.java +++ b/src/main/java/org/bukkit/entity/ItemFrame.java @@ -106,7 +106,7 @@ public interface ItemFrame extends Hanging { * damage, interaction, pistons, or missing supporting blocks), rotate the * item or place/remove items. * - * @param visible whether the item frame is fixed or not + * @param fixed whether the item frame is fixed or not */ - void setFixed(boolean visible); + void setFixed(boolean fixed); } From 27bcdd12f74d23dbc87265d78282c40147d0fd11 Mon Sep 17 00:00:00 2001 From: md_5 Date: Mon, 22 Nov 2021 09:00:00 +1100 Subject: [PATCH 03/23] Update to Minecraft 1.18-pre5 --- pom.xml | 14 ++-- src/main/java/org/bukkit/Bukkit.java | 9 +++ src/main/java/org/bukkit/Material.java | 6 +- src/main/java/org/bukkit/Particle.java | 3 +- src/main/java/org/bukkit/Server.java | 7 ++ src/main/java/org/bukkit/Sound.java | 13 ++++ src/main/java/org/bukkit/Tag.java | 78 +++++++++++++++++-- src/main/java/org/bukkit/block/Biome.java | 54 ++++--------- .../java/org/bukkit/scoreboard/Objective.java | 2 +- .../org/bukkit/scoreboard/Scoreboard.java | 6 +- 10 files changed, 133 insertions(+), 59 deletions(-) diff --git a/pom.xml b/pom.xml index dabff817..6b8339c4 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.bukkit bukkit - 1.17.1-R0.1-SNAPSHOT + 1.18-pre5-R0.1-SNAPSHOT jar Bukkit @@ -41,14 +41,14 @@ com.google.guava guava - 21.0 + 31.0.1-jre compile com.google.code.gson gson - 2.8.0 + 2.8.8 compile @@ -136,7 +136,7 @@ org.eclipse.jdt ecj - 3.26.0 + 3.27.0 @@ -183,10 +183,10 @@ org.apache.maven.plugins maven-javadoc-plugin - 3.3.0 + 3.3.1 - https://guava.dev/releases/21.0/api/docs/ + https://guava.dev/releases/31.0.1-jre/api/docs/ https://javadoc.io/doc/org.yaml/snakeyaml/1.28/ https://javadoc.io/doc/org.jetbrains/annotations-java5/21.0.1/ @@ -223,7 +223,7 @@ com.puppycrawl.tools checkstyle - 8.44 + 9.1 diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java index 7fd1eb5b..f78e6848 100644 --- a/src/main/java/org/bukkit/Bukkit.java +++ b/src/main/java/org/bukkit/Bukkit.java @@ -178,6 +178,15 @@ public final class Bukkit { return server.getViewDistance(); } + /** + * Get the simulation distance from this server. + * + * @return the simulation distance from this server. + */ + public static int getSimulationDistance() { + return server.getSimulationDistance(); + } + /** * Get the IP that this server is bound to, or empty string if not * specified. diff --git a/src/main/java/org/bukkit/Material.java b/src/main/java/org/bukkit/Material.java index e12e319b..41c34903 100644 --- a/src/main/java/org/bukkit/Material.java +++ b/src/main/java/org/bukkit/Material.java @@ -442,7 +442,7 @@ public enum Material implements Keyed { /** * BlockData: {@link Leaves} */ - FLOWERING_AZALEA_LEAVES(20893, Leaves.class), + FLOWERING_AZALEA_LEAVES(7139, Leaves.class), SPONGE(15860), WET_SPONGE(9043), GLASS(6195), @@ -2400,12 +2400,13 @@ public enum Material implements Keyed { MUSIC_DISC_WARD(24026, 1), MUSIC_DISC_11(27426, 1), MUSIC_DISC_WAIT(26499, 1), + MUSIC_DISC_OTHERSIDE(12974, 1), MUSIC_DISC_PIGSTEP(21323, 1), TRIDENT(7534, 1, 250), PHANTOM_MEMBRANE(18398), NAUTILUS_SHELL(19989), HEART_OF_THE_SEA(11807), - CROSSBOW(4340, 1, 326), + CROSSBOW(4340, 1, 465), SUSPICIOUS_STEW(8173, 1), /** * BlockData: {@link Directional} @@ -5201,6 +5202,7 @@ public enum Material implements Keyed { case MUSIC_DISC_FAR: case MUSIC_DISC_MALL: case MUSIC_DISC_MELLOHI: + case MUSIC_DISC_OTHERSIDE: case MUSIC_DISC_PIGSTEP: case MUSIC_DISC_STAL: case MUSIC_DISC_STRAD: diff --git a/src/main/java/org/bukkit/Particle.java b/src/main/java/org/bukkit/Particle.java index c5315ee1..dc514246 100644 --- a/src/main/java/org/bukkit/Particle.java +++ b/src/main/java/org/bukkit/Particle.java @@ -41,7 +41,6 @@ public enum Particle { SNOW_SHOVEL, SLIME, HEART, - BARRIER, ITEM_CRACK(ItemStack.class), BLOCK_CRACK(BlockData.class), BLOCK_DUST(BlockData.class), @@ -82,7 +81,6 @@ public enum Particle { LANDING_OBSIDIAN_TEAR, REVERSE_PORTAL, WHITE_ASH, - LIGHT, DUST_COLOR_TRANSITION(DustTransition.class), VIBRATION(Vibration.class), FALLING_SPORE_BLOSSOM, @@ -99,6 +97,7 @@ public enum Particle { WAX_OFF, ELECTRIC_SPARK, SCRAPE, + BLOCK_MARKER(BlockData.class), // ----- Legacy Separator ----- LEGACY_BLOCK_CRACK(MaterialData.class), LEGACY_BLOCK_DUST(MaterialData.class), diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java index 3fdabd26..1394f3bf 100644 --- a/src/main/java/org/bukkit/Server.java +++ b/src/main/java/org/bukkit/Server.java @@ -149,6 +149,13 @@ public interface Server extends PluginMessageRecipient { */ public int getViewDistance(); + /** + * Get the simulation distance from this server. + * + * @return the simulation distance from this server. + */ + public int getSimulationDistance(); + /** * Get the IP that this server is bound to, or empty string if not * specified. diff --git a/src/main/java/org/bukkit/Sound.java b/src/main/java/org/bukkit/Sound.java index 2c8cc0c2..77553fe2 100644 --- a/src/main/java/org/bukkit/Sound.java +++ b/src/main/java/org/bukkit/Sound.java @@ -229,6 +229,7 @@ public enum Sound implements Keyed { BLOCK_GRAVEL_PLACE("block.gravel.place"), BLOCK_GRAVEL_STEP("block.gravel.step"), BLOCK_GRINDSTONE_USE("block.grindstone.use"), + BLOCK_GROWING_PLANT_CROP("block.growing_plant.crop"), BLOCK_HANGING_ROOTS_BREAK("block.hanging_roots.break"), BLOCK_HANGING_ROOTS_FALL("block.hanging_roots.fall"), BLOCK_HANGING_ROOTS_HIT("block.hanging_roots.hit"), @@ -1130,6 +1131,9 @@ public enum Sound implements Keyed { ITEM_BUCKET_FILL_FISH("item.bucket.fill_fish"), ITEM_BUCKET_FILL_LAVA("item.bucket.fill_lava"), ITEM_BUCKET_FILL_POWDER_SNOW("item.bucket.fill_powder_snow"), + ITEM_BUNDLE_DROP_CONTENTS("item.bundle.drop_contents"), + ITEM_BUNDLE_INSERT("item.bundle.insert"), + ITEM_BUNDLE_REMOVE_ONE("item.bundle.remove_one"), ITEM_CHORUS_FRUIT_TELEPORT("item.chorus_fruit.teleport"), ITEM_CROP_PLANT("item.crop.plant"), ITEM_CROSSBOW_HIT("item.crossbow.hit"), @@ -1175,6 +1179,7 @@ public enum Sound implements Keyed { MUSIC_DISC_FAR("music_disc.far"), MUSIC_DISC_MALL("music_disc.mall"), MUSIC_DISC_MELLOHI("music_disc.mellohi"), + MUSIC_DISC_OTHERSIDE("music_disc.otherside"), MUSIC_DISC_PIGSTEP("music_disc.pigstep"), MUSIC_DISC_STAL("music_disc.stal"), MUSIC_DISC_STRAD("music_disc.strad"), @@ -1189,6 +1194,14 @@ public enum Sound implements Keyed { MUSIC_NETHER_NETHER_WASTES("music.nether.nether_wastes"), MUSIC_NETHER_SOUL_SAND_VALLEY("music.nether.soul_sand_valley"), MUSIC_NETHER_WARPED_FOREST("music.nether.warped_forest"), + MUSIC_OVERWORLD_DRIPSTONE_CAVES("music.overworld.dripstone_caves"), + MUSIC_OVERWORLD_FROZEN_PEAKS("music.overworld.frozen_peaks"), + MUSIC_OVERWORLD_GROVE("music.overworld.grove"), + MUSIC_OVERWORLD_JAGGED_PEAKS("music.overworld.jagged_peaks"), + MUSIC_OVERWORLD_LUSH_CAVES("music.overworld.lush_caves"), + MUSIC_OVERWORLD_MEADOW("music.overworld.meadow"), + MUSIC_OVERWORLD_SNOWY_SLOPES("music.overworld.snowy_slopes"), + MUSIC_OVERWORLD_STONY_PEAKS("music.overworld.stony_peaks"), MUSIC_UNDER_WATER("music.under_water"), PARTICLE_SOUL_ESCAPE("particle.soul_escape"), UI_BUTTON_CLICK("ui.button.click"), diff --git a/src/main/java/org/bukkit/Tag.java b/src/main/java/org/bukkit/Tag.java index c86ac9f4..5a25301a 100644 --- a/src/main/java/org/bukkit/Tag.java +++ b/src/main/java/org/bukkit/Tag.java @@ -235,6 +235,10 @@ public interface Tag extends Keyed { * Vanilla block tag representing all dirt. */ Tag DIRT = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("dirt"), Material.class); + /** + * Vanilla block tag representing all terracotta. + */ + Tag TERRACOTTA = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("terracotta"), Material.class); /** * Vanilla block tag denoting blocks that enderman may pick up and hold. */ @@ -332,7 +336,8 @@ public interface Tag extends Keyed { */ Tag BEACON_BASE_BLOCKS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("beacon_base_blocks"), Material.class); /** - * Vanilla block tag representing all blocks affected by the soul speed enchantment. + * Vanilla block tag representing all blocks affected by the soul speed + * enchantment. */ Tag SOUL_SPEED_BLOCKS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("soul_speed_blocks"), Material.class); /** @@ -405,7 +410,8 @@ public interface Tag extends Keyed { */ Tag STONE_ORE_REPLACEABLES = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("stone_ore_replaceables"), Material.class); /** - * Vanilla block tag representing all blocks that may be replaced by deepslate ores. + * Vanilla block tag representing all blocks that may be replaced by + * deepslate ores. */ Tag DEEPSLATE_ORE_REPLACEABLES = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("deepslate_ore_replaceables"), Material.class); /** @@ -433,7 +439,8 @@ public interface Tag extends Keyed { */ Tag OCCLUDES_VIBRATION_SIGNALS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("occludes_vibration_signals"), Material.class); /** - * Vanilla block tag representing all blocks that are replaceable by dripstone. + * Vanilla block tag representing all blocks that are replaceable by + * dripstone. */ Tag DRIPSTONE_REPLACEABLE = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("dripstone_replaceable_blocks"), Material.class); /** @@ -449,9 +456,19 @@ public interface Tag extends Keyed { */ Tag LUSH_GROUND_REPLACEABLE = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("lush_ground_replaceable"), Material.class); /** - * Vanilla block tag representing all blocks which small dripleaf can be placed on. + * Vanilla block tag representing all blocks replaceable by azalea root. + */ + Tag AZALEA_ROOT_REPLACEABLE = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("azalea_root_replaceable"), Material.class); + /** + * Vanilla block tag representing all blocks which small dripleaf can be + * placed on. */ Tag SMALL_DRIPLEAF_PLACEABLE = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("small_dripleaf_placeable"), Material.class); + /** + * Vanilla block tag representing all blocks which big dripleaf can be + * placed on. + */ + Tag BIG_DRIPLEAF_PLACEABLE = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("big_dripleaf_placeable"), Material.class); /** * Vanilla block tag representing all snow blocks. */ @@ -485,17 +502,64 @@ public interface Tag extends Keyed { */ Tag NEEDS_STONE_TOOL = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("needs_stone_tool"), Material.class); /** - * Vanilla block tag representing all blocks which will not be replaced by world generation features. + * Vanilla block tag representing all blocks which will not be replaced by + * world generation features. */ Tag FEATURES_CANNOT_REPLACE = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("features_cannot_replace"), Material.class); /** - * Vanilla block tag representing all blocks which lava pools will not replace. + * Vanilla block tag representing all blocks which lava pools will not + * replace. */ - Tag LAVA_POOL_STONE_CANNOT_REPLACE = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("lava_pool_stone_replaceables"), Material.class); + Tag LAVA_POOL_STONE_CANNOT_REPLACE = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("lava_pool_stone_cannot_replace"), Material.class); /** * Vanilla block tag representing all blocks which geodes will not spawn in. */ Tag GEODE_INVALID_BLOCKS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("geode_invalid_blocks"), Material.class); + /** + * Vanilla block tag representing all blocks which animals will spawn on. + */ + Tag ANIMALS_SPAWNABLE_ON = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("animals_spawnable_on"), Material.class); + /** + * Vanilla block tag representing all blocks which axolotls will spawn on. + */ + Tag AXOLOTLS_SPAWNABLE_ON = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("axolotls_spawnable_on"), Material.class); + /** + * Vanilla block tag representing all blocks which goats will spawn on. + */ + Tag GOATS_SPAWNABLE_ON = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("goats_spawnable_on"), Material.class); + /** + * Vanilla block tag representing all blocks which mooshrooms will spawn on. + */ + Tag MOOSHROOMS_SPAWNABLE_ON = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("mooshrooms_spawnable_on"), Material.class); + /** + * Vanilla block tag representing all blocks which parrots will spawn on. + */ + Tag PARROTS_SPAWNABLE_ON = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("parrots_spawnable_on"), Material.class); + /** + * Vanilla block tag representing all blocks which polar bears will spawn + * on. + */ + Tag POLAR_BEARS_SPAWNABLE_ON_IN_FROZEN_OCEAN = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("polar_bears_spawnable_on_in_frozen_ocean"), Material.class); + /** + * Vanilla block tag representing all blocks which rabbits will spawn on. + */ + Tag RABBITS_SPAWNABLE_ON = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("rabbits_spawnable_on"), Material.class); + /** + * Vanilla block tag representing all blocks which foxes will spawn on. + */ + Tag FOXES_SPAWNABLE_ON = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("foxes_spawnable_on"), Material.class); + /** + * Vanilla block tag representing all blocks which wolves will spawn on. + */ + Tag WOLVES_SPAWNABLE_ON = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("wolves_spawnable_on"), Material.class); + /** + * Vanilla block tag representing all blocks which azaleas will grow on. + */ + Tag AZALEA_GROWS_ON = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("azalea_grows_on"), Material.class); + /** + * Vanilla block tag representing all plant blocks which may be replaced. + */ + Tag REPLACEABLE_PLANTS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("replaceable_plants"), Material.class); /** * Key for the built in item registry. */ diff --git a/src/main/java/org/bukkit/block/Biome.java b/src/main/java/org/bukkit/block/Biome.java index 2d28eeed..d14102bd 100644 --- a/src/main/java/org/bukkit/block/Biome.java +++ b/src/main/java/org/bukkit/block/Biome.java @@ -12,7 +12,7 @@ public enum Biome implements Keyed { OCEAN, PLAINS, DESERT, - MOUNTAINS, + WINDSWEPT_HILLS, FOREST, TAIGA, SWAMP, @@ -21,34 +21,23 @@ public enum Biome implements Keyed { THE_END, FROZEN_OCEAN, FROZEN_RIVER, - SNOWY_TUNDRA, - SNOWY_MOUNTAINS, + SNOWY_PLAINS, MUSHROOM_FIELDS, - MUSHROOM_FIELD_SHORE, BEACH, - DESERT_HILLS, - WOODED_HILLS, - TAIGA_HILLS, - MOUNTAIN_EDGE, JUNGLE, - JUNGLE_HILLS, - JUNGLE_EDGE, + SPARSE_JUNGLE, DEEP_OCEAN, - STONE_SHORE, + STONY_SHORE, SNOWY_BEACH, BIRCH_FOREST, - BIRCH_FOREST_HILLS, DARK_FOREST, SNOWY_TAIGA, - SNOWY_TAIGA_HILLS, - GIANT_TREE_TAIGA, - GIANT_TREE_TAIGA_HILLS, - WOODED_MOUNTAINS, + OLD_GROWTH_PINE_TAIGA, + WINDSWEPT_FOREST, SAVANNA, SAVANNA_PLATEAU, BADLANDS, - WOODED_BADLANDS_PLATEAU, - BADLANDS_PLATEAU, + WOODED_BADLANDS, SMALL_END_ISLANDS, END_MIDLANDS, END_HIGHLANDS, @@ -56,40 +45,31 @@ public enum Biome implements Keyed { WARM_OCEAN, LUKEWARM_OCEAN, COLD_OCEAN, - DEEP_WARM_OCEAN, DEEP_LUKEWARM_OCEAN, DEEP_COLD_OCEAN, DEEP_FROZEN_OCEAN, THE_VOID, SUNFLOWER_PLAINS, - DESERT_LAKES, - GRAVELLY_MOUNTAINS, + WINDSWEPT_GRAVELLY_HILLS, FLOWER_FOREST, - TAIGA_MOUNTAINS, - SWAMP_HILLS, ICE_SPIKES, - MODIFIED_JUNGLE, - MODIFIED_JUNGLE_EDGE, - TALL_BIRCH_FOREST, - TALL_BIRCH_HILLS, - DARK_FOREST_HILLS, - SNOWY_TAIGA_MOUNTAINS, - GIANT_SPRUCE_TAIGA, - GIANT_SPRUCE_TAIGA_HILLS, - MODIFIED_GRAVELLY_MOUNTAINS, - SHATTERED_SAVANNA, - SHATTERED_SAVANNA_PLATEAU, + OLD_GROWTH_BIRCH_FOREST, + OLD_GROWTH_SPRUCE_TAIGA, + WINDSWEPT_SAVANNA, ERODED_BADLANDS, - MODIFIED_WOODED_BADLANDS_PLATEAU, - MODIFIED_BADLANDS_PLATEAU, BAMBOO_JUNGLE, - BAMBOO_JUNGLE_HILLS, SOUL_SAND_VALLEY, CRIMSON_FOREST, WARPED_FOREST, BASALT_DELTAS, DRIPSTONE_CAVES, LUSH_CAVES, + MEADOW, + GROVE, + SNOWY_SLOPES, + FROZEN_PEAKS, + JAGGED_PEAKS, + STONY_PEAKS, /** * Represents a custom Biome */ diff --git a/src/main/java/org/bukkit/scoreboard/Objective.java b/src/main/java/org/bukkit/scoreboard/Objective.java index 7277f62d..ff3fcb26 100644 --- a/src/main/java/org/bukkit/scoreboard/Objective.java +++ b/src/main/java/org/bukkit/scoreboard/Objective.java @@ -130,7 +130,7 @@ public interface Objective { * @return Score tracking the Objective and entry specified * @throws IllegalArgumentException if entry is null * @throws IllegalStateException if this objective has been unregistered - * @throws IllegalArgumentException if entry is longer than 40 characters. + * @throws IllegalArgumentException if entry is longer than 32767 characters. */ @NotNull Score getScore(@NotNull String entry) throws IllegalArgumentException, IllegalStateException; diff --git a/src/main/java/org/bukkit/scoreboard/Scoreboard.java b/src/main/java/org/bukkit/scoreboard/Scoreboard.java index d283f694..5c855dbd 100644 --- a/src/main/java/org/bukkit/scoreboard/Scoreboard.java +++ b/src/main/java/org/bukkit/scoreboard/Scoreboard.java @@ -17,7 +17,7 @@ public interface Scoreboard { * @param criteria Criteria for the Objective * @return The registered Objective * @throws IllegalArgumentException if name is null - * @throws IllegalArgumentException if name is longer than 16 + * @throws IllegalArgumentException if name is longer than 32767 * characters. * @throws IllegalArgumentException if criteria is null * @throws IllegalArgumentException if an objective by that name already @@ -36,7 +36,7 @@ public interface Scoreboard { * @param displayName Name displayed to players for the Objective. * @return The registered Objective * @throws IllegalArgumentException if name is null - * @throws IllegalArgumentException if name is longer than 16 + * @throws IllegalArgumentException if name is longer than 32767 * characters. * @throws IllegalArgumentException if criteria is null * @throws IllegalArgumentException if displayName is null @@ -57,7 +57,7 @@ public interface Scoreboard { * @param renderType Manner of rendering the Objective * @return The registered Objective * @throws IllegalArgumentException if name is null - * @throws IllegalArgumentException if name is longer than 16 + * @throws IllegalArgumentException if name is longer than 32767 * characters. * @throws IllegalArgumentException if criteria is null * @throws IllegalArgumentException if displayName is null From 6c45a80e2ea268983d5a98b9f98b17e67496ca5a Mon Sep 17 00:00:00 2001 From: Perzan Date: Mon, 22 Nov 2021 15:03:24 +1100 Subject: [PATCH 04/23] #592: Add Player#sendEquipmentChange --- src/main/java/org/bukkit/entity/Player.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java index cd4599b0..929bdede 100644 --- a/src/main/java/org/bukkit/entity/Player.java +++ b/src/main/java/org/bukkit/entity/Player.java @@ -21,6 +21,7 @@ import org.bukkit.conversations.Conversable; import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockDropItemEvent; import org.bukkit.event.player.PlayerResourcePackStatusEvent; +import org.bukkit.inventory.EquipmentSlot; import org.bukkit.inventory.ItemStack; import org.bukkit.map.MapView; import org.bukkit.plugin.Plugin; @@ -459,6 +460,17 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM */ public void sendBlockDamage(@NotNull Location loc, float progress); + /** + * Send the equipment change of an entity. This fakes the equipment change + * of an entity for a user. This will not actually change the inventory of + * the specified entity in any way. + * + * @param entity The entity that the player will see the change for + * @param slot The slot of the spoofed equipment change + * @param item The ItemStack to display for the player + */ + public void sendEquipmentChange(@NotNull LivingEntity entity, @NotNull EquipmentSlot slot, @NotNull ItemStack item); + /** * Send a chunk change. This fakes a chunk change packet for a user at a * certain location. The updated cuboid must be entirely within a single From 24313a161e7b25a7ac9a7bb4c567293c4025f9eb Mon Sep 17 00:00:00 2001 From: md_5 Date: Mon, 22 Nov 2021 15:08:47 +1100 Subject: [PATCH 05/23] Remove Player#sendChunkChange Method is specified according to an obsolete internal format and has not been implemented for nearly 10 years. --- src/main/java/org/bukkit/entity/Player.java | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java index 929bdede..e97e8be2 100644 --- a/src/main/java/org/bukkit/entity/Player.java +++ b/src/main/java/org/bukkit/entity/Player.java @@ -471,26 +471,6 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM */ public void sendEquipmentChange(@NotNull LivingEntity entity, @NotNull EquipmentSlot slot, @NotNull ItemStack item); - /** - * Send a chunk change. This fakes a chunk change packet for a user at a - * certain location. The updated cuboid must be entirely within a single - * chunk. This will not actually change the world in any way. - *

- * At least one of the dimensions of the cuboid must be even. The size of - * the data buffer must be 2.5*sx*sy*sz and formatted in accordance with - * the Packet51 format. - * - * @param loc The location of the cuboid - * @param sx The x size of the cuboid - * @param sy The y size of the cuboid - * @param sz The z size of the cuboid - * @param data The data to be sent - * @return true if the chunk change packet was sent - * @deprecated Magic value - */ - @Deprecated - public boolean sendChunkChange(@NotNull Location loc, int sx, int sy, int sz, @NotNull byte[] data); - /** * Send a sign change. This fakes a sign change packet for a user at * a certain location. This will not actually change the world in any way. From 0a35cb18fc92be8858f7abc3a23ed19fb4dfa326 Mon Sep 17 00:00:00 2001 From: md_5 Date: Mon, 22 Nov 2021 15:27:06 +1100 Subject: [PATCH 06/23] Downgrade to Checkstyle 8.x as 9.x series has much larger memory usage --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 6b8339c4..2cba38de 100644 --- a/pom.xml +++ b/pom.xml @@ -223,7 +223,7 @@ com.puppycrawl.tools checkstyle - 9.1 + 8.45.1 From 4e9f199ac68600d3da79121e06fbd77173038ce6 Mon Sep 17 00:00:00 2001 From: BlackHole Date: Tue, 23 Nov 2021 08:06:39 +1100 Subject: [PATCH 07/23] SPIGOT-6801: Wrong BlockData classes in Material enum for SOUL_FIRE and SOUL_TORCH --- src/main/java/org/bukkit/Material.java | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/bukkit/Material.java b/src/main/java/org/bukkit/Material.java index 41c34903..2a0773e0 100644 --- a/src/main/java/org/bukkit/Material.java +++ b/src/main/java/org/bukkit/Material.java @@ -753,10 +753,7 @@ public enum Material implements Keyed { */ POLISHED_BASALT(11659, Orientable.class), SMOOTH_BASALT(13617), - /** - * BlockData: {@link Lightable} - */ - SOUL_TORCH(14292, Lightable.class), + SOUL_TORCH(14292), GLOWSTONE(32713), INFESTED_STONE(18440), INFESTED_COBBLESTONE(4348), @@ -2631,10 +2628,7 @@ public enum Material implements Keyed { * BlockData: {@link Fire} */ FIRE(16396, Fire.class), - /** - * BlockData: {@link Fire} - */ - SOUL_FIRE(30163, Fire.class), + SOUL_FIRE(30163), /** * BlockData: {@link RedstoneWire} */ From b991b6c75415bb88190a06b4d4c75362731af883 Mon Sep 17 00:00:00 2001 From: Noah van der Aa Date: Tue, 23 Nov 2021 08:56:03 +1100 Subject: [PATCH 08/23] #677: Add "Allow Server Listings" API --- src/main/java/org/bukkit/entity/Player.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java index e97e8be2..7f1d1d9a 100644 --- a/src/main/java/org/bukkit/entity/Player.java +++ b/src/main/java/org/bukkit/entity/Player.java @@ -1307,4 +1307,11 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM * @param book The book to open for this player */ public void openBook(@NotNull ItemStack book); + + /** + * Gets whether the player has the "Allow Server Listings" setting enabled. + * + * @return whether the player allows server listings + */ + public boolean isAllowingServerListings(); } From 64c8bd39e019135647e27f919b19ea03de2e6d92 Mon Sep 17 00:00:00 2001 From: Doc Date: Mon, 22 Nov 2021 22:30:30 -0300 Subject: [PATCH 09/23] #679: Add getHideOnlinePlayers --- src/main/java/org/bukkit/Bukkit.java | 9 +++++++++ src/main/java/org/bukkit/Server.java | 7 +++++++ 2 files changed, 16 insertions(+) diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java index f78e6848..3b150b96 100644 --- a/src/main/java/org/bukkit/Bukkit.java +++ b/src/main/java/org/bukkit/Bukkit.java @@ -912,6 +912,15 @@ public final class Bukkit { server.setSpawnRadius(value); } + /** + * Gets whether the Server hide online players in server status. + * + * @return true if the server hide online players, false otherwise + */ + public static boolean getHideOnlinePlayers() { + return server.getHideOnlinePlayers(); + } + /** * Gets whether the Server is in online mode or not. * diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java index 1394f3bf..7d2ba1f5 100644 --- a/src/main/java/org/bukkit/Server.java +++ b/src/main/java/org/bukkit/Server.java @@ -768,6 +768,13 @@ public interface Server extends PluginMessageRecipient { */ public void setSpawnRadius(int value); + /** + * Gets whether the Server hide online players in server status. + * + * @return true if the server hide online players, false otherwise + */ + public boolean getHideOnlinePlayers(); + /** * Gets whether the Server is in online mode or not. * From 07a055315ce10d9e6134b9367443ddeeda501236 Mon Sep 17 00:00:00 2001 From: coll1234567 Date: Tue, 23 Nov 2021 18:49:11 +1100 Subject: [PATCH 10/23] SPIGOT-6781: Add Block#canPlace --- src/main/java/org/bukkit/block/Block.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main/java/org/bukkit/block/Block.java b/src/main/java/org/bukkit/block/Block.java index da0964b1..ce1e1e6c 100644 --- a/src/main/java/org/bukkit/block/Block.java +++ b/src/main/java/org/bukkit/block/Block.java @@ -511,4 +511,13 @@ public interface Block extends Metadatable { */ @NotNull VoxelShape getCollisionShape(); + + /** + * Checks if this block is a valid placement location for the specified + * block data. + * + * @param data the block data to check + * @return true if the block data can be placed here + */ + boolean canPlace(@NotNull BlockData data); } From ea30a299e948f5545b0ad042bd8e11716aeaa7f2 Mon Sep 17 00:00:00 2001 From: Doc Date: Wed, 24 Nov 2021 07:30:57 +1100 Subject: [PATCH 11/23] Add docs in ServerListPingEvent based on changes from 1.18 --- .../java/org/bukkit/event/server/ServerListPingEvent.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/java/org/bukkit/event/server/ServerListPingEvent.java b/src/main/java/org/bukkit/event/server/ServerListPingEvent.java index 7a2a58ba..cc5e2fef 100644 --- a/src/main/java/org/bukkit/event/server/ServerListPingEvent.java +++ b/src/main/java/org/bukkit/event/server/ServerListPingEvent.java @@ -3,6 +3,7 @@ package org.bukkit.event.server; import java.net.InetAddress; import java.util.Iterator; import org.apache.commons.lang.Validate; +import org.bukkit.Bukkit; import org.bukkit.UndefinedNullability; import org.bukkit.entity.Player; import org.bukkit.event.HandlerList; @@ -12,6 +13,9 @@ import org.jetbrains.annotations.NotNull; /** * Called when a server list ping is coming in. Displayed players can be * checked and removed by {@link #iterator() iterating} over this event. + *
+ * Note: The players in {@link #iterator()} will not be shown in the + * server info if {@link Bukkit#getHideOnlinePlayers()} is true. */ public class ServerListPingEvent extends ServerEvent implements Iterable { private static final int MAGIC_PLAYER_COUNT = Integer.MIN_VALUE; @@ -142,6 +146,9 @@ public class ServerListPingEvent extends ServerEvent implements Iterable * player to not be displayed on the player list, decrease the size * returned by {@link #getNumPlayers()}, and will not be returned again by * any new iterator. + *
+ * Note: The players here will not be shown in the server info if + * {@link Bukkit#getHideOnlinePlayers()} is true. * * @throws UnsupportedOperationException if the caller of this event does * not support removing players From d25437bce34e0cb0b7c895867183dc949ea41667 Mon Sep 17 00:00:00 2001 From: md_5 Date: Thu, 25 Nov 2021 08:00:00 +1100 Subject: [PATCH 12/23] Update to Minecraft 1.18-pre8 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 2cba38de..67e7e4a2 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.bukkit bukkit - 1.18-pre5-R0.1-SNAPSHOT + 1.18-pre8-R0.1-SNAPSHOT jar Bukkit From 57e7e952153bdabb61fdadab76d38247c7e36a64 Mon Sep 17 00:00:00 2001 From: coll1234567 Date: Fri, 26 Nov 2021 10:13:40 +1100 Subject: [PATCH 13/23] #683: Add Player#showDemoScreen --- src/main/java/org/bukkit/entity/Player.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java index 7f1d1d9a..347b4a78 100644 --- a/src/main/java/org/bukkit/entity/Player.java +++ b/src/main/java/org/bukkit/entity/Player.java @@ -1308,6 +1308,14 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM */ public void openBook(@NotNull ItemStack book); + /** + * Shows the demo screen to the player, this screen is normally only seen in + * the demo version of the game. + *
+ * Servers can modify the text on this screen using a resource pack. + */ + public void showDemoScreen(); + /** * Gets whether the player has the "Allow Server Listings" setting enabled. * From ca6f8942a46bf5b7ceb6a35587d5f962a073330a Mon Sep 17 00:00:00 2001 From: md_5 Date: Sat, 27 Nov 2021 08:00:00 +1100 Subject: [PATCH 14/23] Update to Minecraft 1.18-rc3 --- pom.xml | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 67e7e4a2..61e82a33 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.bukkit bukkit - 1.18-pre8-R0.1-SNAPSHOT + 1.18-rc3-R0.1-SNAPSHOT jar Bukkit @@ -30,6 +30,20 @@ + + + sonatype-nexus-snapshots + Sonatype Nexus Snapshots + https://oss.sonatype.org/content/repositories/snapshots/ + + false + + + true + + + + commons-lang @@ -54,7 +68,7 @@ org.yaml snakeyaml - 1.28 + 1.30-SNAPSHOT compile From 716b4fce8443809ed39119dbffdd21c04fcea04a Mon Sep 17 00:00:00 2001 From: md_5 Date: Sat, 27 Nov 2021 09:11:04 +1100 Subject: [PATCH 15/23] Revert SnakeYAML upgrade --- pom.xml | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/pom.xml b/pom.xml index 61e82a33..1a8f5faa 100644 --- a/pom.xml +++ b/pom.xml @@ -30,20 +30,6 @@ - - - sonatype-nexus-snapshots - Sonatype Nexus Snapshots - https://oss.sonatype.org/content/repositories/snapshots/ - - false - - - true - - - - commons-lang @@ -68,7 +54,7 @@ org.yaml snakeyaml - 1.30-SNAPSHOT + 1.28 compile From c9b35cdb66761dfbda6f0b860bdb3c2edfda8679 Mon Sep 17 00:00:00 2001 From: coll1234567 Date: Sun, 28 Nov 2021 11:49:39 +1100 Subject: [PATCH 16/23] #684: Make PotionEffectType implement Keyed --- .../org/bukkit/potion/PotionEffectType.java | 95 ++++++++++++------- .../potion/PotionEffectTypeWrapper.java | 5 +- 2 files changed, 63 insertions(+), 37 deletions(-) diff --git a/src/main/java/org/bukkit/potion/PotionEffectType.java b/src/main/java/org/bukkit/potion/PotionEffectType.java index 3c005c50..3dc59b17 100644 --- a/src/main/java/org/bukkit/potion/PotionEffectType.java +++ b/src/main/java/org/bukkit/potion/PotionEffectType.java @@ -5,179 +5,184 @@ import java.util.HashMap; import java.util.Map; import org.apache.commons.lang.Validate; import org.bukkit.Color; +import org.bukkit.Keyed; +import org.bukkit.NamespacedKey; +import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; /** * Represents a type of potion and its effect on an entity. */ -public abstract class PotionEffectType { +public abstract class PotionEffectType implements Keyed { /** * Increases movement speed. */ - public static final PotionEffectType SPEED = new PotionEffectTypeWrapper(1); + public static final PotionEffectType SPEED = new PotionEffectTypeWrapper(1, "speed"); /** * Decreases movement speed. */ - public static final PotionEffectType SLOW = new PotionEffectTypeWrapper(2); + public static final PotionEffectType SLOW = new PotionEffectTypeWrapper(2, "slowness"); /** * Increases dig speed. */ - public static final PotionEffectType FAST_DIGGING = new PotionEffectTypeWrapper(3); + public static final PotionEffectType FAST_DIGGING = new PotionEffectTypeWrapper(3, "haste"); /** * Decreases dig speed. */ - public static final PotionEffectType SLOW_DIGGING = new PotionEffectTypeWrapper(4); + public static final PotionEffectType SLOW_DIGGING = new PotionEffectTypeWrapper(4, "mining_fatigue"); /** * Increases damage dealt. */ - public static final PotionEffectType INCREASE_DAMAGE = new PotionEffectTypeWrapper(5); + public static final PotionEffectType INCREASE_DAMAGE = new PotionEffectTypeWrapper(5, "strength"); /** * Heals an entity. */ - public static final PotionEffectType HEAL = new PotionEffectTypeWrapper(6); + public static final PotionEffectType HEAL = new PotionEffectTypeWrapper(6, "instant_health"); /** * Hurts an entity. */ - public static final PotionEffectType HARM = new PotionEffectTypeWrapper(7); + public static final PotionEffectType HARM = new PotionEffectTypeWrapper(7, "instant_damage"); /** * Increases jump height. */ - public static final PotionEffectType JUMP = new PotionEffectTypeWrapper(8); + public static final PotionEffectType JUMP = new PotionEffectTypeWrapper(8, "jump_boost"); /** * Warps vision on the client. */ - public static final PotionEffectType CONFUSION = new PotionEffectTypeWrapper(9); + public static final PotionEffectType CONFUSION = new PotionEffectTypeWrapper(9, "nausea"); /** * Regenerates health. */ - public static final PotionEffectType REGENERATION = new PotionEffectTypeWrapper(10); + public static final PotionEffectType REGENERATION = new PotionEffectTypeWrapper(10, "regeneration"); /** * Decreases damage dealt to an entity. */ - public static final PotionEffectType DAMAGE_RESISTANCE = new PotionEffectTypeWrapper(11); + public static final PotionEffectType DAMAGE_RESISTANCE = new PotionEffectTypeWrapper(11, "resistance"); /** * Stops fire damage. */ - public static final PotionEffectType FIRE_RESISTANCE = new PotionEffectTypeWrapper(12); + public static final PotionEffectType FIRE_RESISTANCE = new PotionEffectTypeWrapper(12, "fire_resistance"); /** * Allows breathing underwater. */ - public static final PotionEffectType WATER_BREATHING = new PotionEffectTypeWrapper(13); + public static final PotionEffectType WATER_BREATHING = new PotionEffectTypeWrapper(13, "water_breathing"); /** * Grants invisibility. */ - public static final PotionEffectType INVISIBILITY = new PotionEffectTypeWrapper(14); + public static final PotionEffectType INVISIBILITY = new PotionEffectTypeWrapper(14, "invisibility"); /** * Blinds an entity. */ - public static final PotionEffectType BLINDNESS = new PotionEffectTypeWrapper(15); + public static final PotionEffectType BLINDNESS = new PotionEffectTypeWrapper(15, "blindness"); /** * Allows an entity to see in the dark. */ - public static final PotionEffectType NIGHT_VISION = new PotionEffectTypeWrapper(16); + public static final PotionEffectType NIGHT_VISION = new PotionEffectTypeWrapper(16, "night_vision"); /** * Increases hunger. */ - public static final PotionEffectType HUNGER = new PotionEffectTypeWrapper(17); + public static final PotionEffectType HUNGER = new PotionEffectTypeWrapper(17, "hunger"); /** * Decreases damage dealt by an entity. */ - public static final PotionEffectType WEAKNESS = new PotionEffectTypeWrapper(18); + public static final PotionEffectType WEAKNESS = new PotionEffectTypeWrapper(18, "weakness"); /** * Deals damage to an entity over time. */ - public static final PotionEffectType POISON = new PotionEffectTypeWrapper(19); + public static final PotionEffectType POISON = new PotionEffectTypeWrapper(19, "poison"); /** * Deals damage to an entity over time and gives the health to the * shooter. */ - public static final PotionEffectType WITHER = new PotionEffectTypeWrapper(20); + public static final PotionEffectType WITHER = new PotionEffectTypeWrapper(20, "wither"); /** * Increases the maximum health of an entity. */ - public static final PotionEffectType HEALTH_BOOST = new PotionEffectTypeWrapper(21); + public static final PotionEffectType HEALTH_BOOST = new PotionEffectTypeWrapper(21, "health_boost"); /** * Increases the maximum health of an entity with health that cannot be * regenerated, but is refilled every 30 seconds. */ - public static final PotionEffectType ABSORPTION = new PotionEffectTypeWrapper(22); + public static final PotionEffectType ABSORPTION = new PotionEffectTypeWrapper(22, "absorption"); /** * Increases the food level of an entity each tick. */ - public static final PotionEffectType SATURATION = new PotionEffectTypeWrapper(23); + public static final PotionEffectType SATURATION = new PotionEffectTypeWrapper(23, "saturation"); /** * Outlines the entity so that it can be seen from afar. */ - public static final PotionEffectType GLOWING = new PotionEffectTypeWrapper(24); + public static final PotionEffectType GLOWING = new PotionEffectTypeWrapper(24, "glowing"); /** * Causes the entity to float into the air. */ - public static final PotionEffectType LEVITATION = new PotionEffectTypeWrapper(25); + public static final PotionEffectType LEVITATION = new PotionEffectTypeWrapper(25, "levitation"); /** * Loot table luck. */ - public static final PotionEffectType LUCK = new PotionEffectTypeWrapper(26); + public static final PotionEffectType LUCK = new PotionEffectTypeWrapper(26, "luck"); /** * Loot table unluck. */ - public static final PotionEffectType UNLUCK = new PotionEffectTypeWrapper(27); + public static final PotionEffectType UNLUCK = new PotionEffectTypeWrapper(27, "unluck"); /** * Slows entity fall rate. */ - public static final PotionEffectType SLOW_FALLING = new PotionEffectTypeWrapper(28); + public static final PotionEffectType SLOW_FALLING = new PotionEffectTypeWrapper(28, "slow_falling"); /** * Effects granted by a nearby conduit. Includes enhanced underwater abilities. */ - public static final PotionEffectType CONDUIT_POWER = new PotionEffectTypeWrapper(29); + public static final PotionEffectType CONDUIT_POWER = new PotionEffectTypeWrapper(29, "conduit_power"); /** * Squee'ek uh'k kk'kkkk squeek eee'eek. */ - public static final PotionEffectType DOLPHINS_GRACE = new PotionEffectTypeWrapper(30); + public static final PotionEffectType DOLPHINS_GRACE = new PotionEffectTypeWrapper(30, "dolphins_grace"); /** * oof. */ - public static final PotionEffectType BAD_OMEN = new PotionEffectTypeWrapper(31); + public static final PotionEffectType BAD_OMEN = new PotionEffectTypeWrapper(31, "bad_omen"); /** * \o/. */ - public static final PotionEffectType HERO_OF_THE_VILLAGE = new PotionEffectTypeWrapper(32); + public static final PotionEffectType HERO_OF_THE_VILLAGE = new PotionEffectTypeWrapper(32, "hero_of_the_village"); private final int id; + private final NamespacedKey key; - protected PotionEffectType(int id) { + protected PotionEffectType(int id, @NotNull NamespacedKey key) { this.id = id; + this.key = key; } /** @@ -214,6 +219,12 @@ public abstract class PotionEffectType { return id; } + @NotNull + @Override + public NamespacedKey getKey() { + return key; + } + /** * Returns the name of this effect type. * @@ -264,9 +275,22 @@ public abstract class PotionEffectType { private static final PotionEffectType[] byId = new PotionEffectType[33]; private static final Map byName = new HashMap(); + private static final Map byKey = new HashMap(); // will break on updates. private static boolean acceptingNew = true; + /** + * Gets the PotionEffectType at the specified key + * + * @param key key to fetch + * @return Resulting PotionEffectType, or null if not found + */ + @Contract("null -> null") + @Nullable + public static PotionEffectType getByKey(@Nullable NamespacedKey key) { + return byKey.get(key); + } + /** * Gets the effect type specified by the unique id. * @@ -302,7 +326,7 @@ public abstract class PotionEffectType { * @param type PotionType to register */ public static void registerPotionEffectType(@NotNull PotionEffectType type) { - if (byId[type.id] != null || byName.containsKey(type.getName().toLowerCase(java.util.Locale.ENGLISH))) { + if (byId[type.id] != null || byName.containsKey(type.getName().toLowerCase(java.util.Locale.ENGLISH)) || byKey.containsKey(type.key)) { throw new IllegalArgumentException("Cannot set already-set type"); } else if (!acceptingNew) { throw new IllegalStateException( @@ -311,6 +335,7 @@ public abstract class PotionEffectType { byId[type.id] = type; byName.put(type.getName().toLowerCase(java.util.Locale.ENGLISH), type); + byKey.put(type.key, type); } /** diff --git a/src/main/java/org/bukkit/potion/PotionEffectTypeWrapper.java b/src/main/java/org/bukkit/potion/PotionEffectTypeWrapper.java index 47d46edc..c3a86bb1 100644 --- a/src/main/java/org/bukkit/potion/PotionEffectTypeWrapper.java +++ b/src/main/java/org/bukkit/potion/PotionEffectTypeWrapper.java @@ -1,11 +1,12 @@ package org.bukkit.potion; import org.bukkit.Color; +import org.bukkit.NamespacedKey; import org.jetbrains.annotations.NotNull; public class PotionEffectTypeWrapper extends PotionEffectType { - protected PotionEffectTypeWrapper(int id) { - super(id); + protected PotionEffectTypeWrapper(int id, @NotNull String name) { + super(id, NamespacedKey.minecraft(name)); } @Override From 810cb078fd22fde8bf94b5a23ed3329f0b1f68db Mon Sep 17 00:00:00 2001 From: md_5 Date: Mon, 29 Nov 2021 09:17:57 +1100 Subject: [PATCH 17/23] Add hideEntity / showEntity API --- src/main/java/org/bukkit/entity/Player.java | 33 +++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java index 347b4a78..95a02cb8 100644 --- a/src/main/java/org/bukkit/entity/Player.java +++ b/src/main/java/org/bukkit/entity/Player.java @@ -770,6 +770,39 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM */ public boolean canSee(@NotNull Player player); + /** + * Visually hides an entity from this player. + * + * @param plugin Plugin that wants to hide the player + * @param entity Player to hide + * @deprecated draft API + */ + @Deprecated + public void hideEntity(@NotNull Plugin plugin, @NotNull Entity entity); + + /** + * Allows this player to see an entity that was previously hidden. If + * another another plugin had hidden the player too, then the player will + * remain hidden until the other plugin calls this method too. + * + * @param plugin Plugin that wants to show the player + * @param entity Player to show + * @deprecated draft API + */ + @Deprecated + public void showEntity(@NotNull Plugin plugin, @NotNull Entity entity); + + /** + * Checks to see if an entity has been visually hidden from this player. + * + * @param entity Player to check + * @return True if the provided player is not being hidden from this + * player + * @deprecated draft API + */ + @Deprecated + public boolean canSee(@NotNull Entity entity); + /** * Checks to see if this player is currently flying or not. * From ab6e73a20eca8ecd0fef8720edc81e746595dd98 Mon Sep 17 00:00:00 2001 From: md_5 Date: Mon, 29 Nov 2021 15:59:20 +1100 Subject: [PATCH 18/23] Correct copied javadoc from previous commit --- src/main/java/org/bukkit/entity/Player.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java index 95a02cb8..13ac8b10 100644 --- a/src/main/java/org/bukkit/entity/Player.java +++ b/src/main/java/org/bukkit/entity/Player.java @@ -773,8 +773,8 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM /** * Visually hides an entity from this player. * - * @param plugin Plugin that wants to hide the player - * @param entity Player to hide + * @param plugin Plugin that wants to hide the entity + * @param entity Entity to hide * @deprecated draft API */ @Deprecated @@ -782,11 +782,11 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM /** * Allows this player to see an entity that was previously hidden. If - * another another plugin had hidden the player too, then the player will + * another another plugin had hidden the entity too, then the entity will * remain hidden until the other plugin calls this method too. * - * @param plugin Plugin that wants to show the player - * @param entity Player to show + * @param plugin Plugin that wants to show the entity + * @param entity Entity to show * @deprecated draft API */ @Deprecated @@ -795,8 +795,8 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM /** * Checks to see if an entity has been visually hidden from this player. * - * @param entity Player to check - * @return True if the provided player is not being hidden from this + * @param entity Entity to check + * @return True if the provided entity is not being hidden from this * player * @deprecated draft API */ From b46ac671a310f2cd48d532d583d79ef12d9d77f2 Mon Sep 17 00:00:00 2001 From: md_5 Date: Wed, 1 Dec 2021 03:00:00 +1100 Subject: [PATCH 19/23] Update to Minecraft 1.18 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 1a8f5faa..78afc6c1 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.bukkit bukkit - 1.18-rc3-R0.1-SNAPSHOT + 1.18-R0.1-SNAPSHOT jar Bukkit From fc0fe05559f00c0ef5c45d9140097c0622368b90 Mon Sep 17 00:00:00 2001 From: md_5 Date: Wed, 1 Dec 2021 10:29:25 +1100 Subject: [PATCH 20/23] SPIGOT-6822: Ensure library loader has same parent as plugin loader This behaviour may need to be revisted in future to achieve greater isolation of plugins/libraries --- src/main/java/org/bukkit/plugin/java/LibraryLoader.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/bukkit/plugin/java/LibraryLoader.java b/src/main/java/org/bukkit/plugin/java/LibraryLoader.java index 939afec1..6d634b0e 100644 --- a/src/main/java/org/bukkit/plugin/java/LibraryLoader.java +++ b/src/main/java/org/bukkit/plugin/java/LibraryLoader.java @@ -121,7 +121,7 @@ class LibraryLoader } ); } - URLClassLoader loader = new URLClassLoader( jarFiles.toArray( new URL[ jarFiles.size() ] ) ); + URLClassLoader loader = new URLClassLoader( jarFiles.toArray( new URL[ jarFiles.size() ] ), getClass().getClassLoader() ); return loader; } From f023e77ad7343fa11812d3118efc956b67cdd242 Mon Sep 17 00:00:00 2001 From: md_5 Date: Wed, 1 Dec 2021 14:58:04 +1100 Subject: [PATCH 21/23] =?UTF-8?q?SPIGOT-6825:=20MapFont#getWidth=20ignores?= =?UTF-8?q?=20=C2=A7,=20but=20not=20the=20color-byte=20and=20semicolon=20f?= =?UTF-8?q?ollowing=20it?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/org/bukkit/map/MapFont.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/bukkit/map/MapFont.java b/src/main/java/org/bukkit/map/MapFont.java index 2d599c8f..a45ce819 100644 --- a/src/main/java/org/bukkit/map/MapFont.java +++ b/src/main/java/org/bukkit/map/MapFont.java @@ -63,7 +63,14 @@ public class MapFont { int result = 0; for (int i = 0; i < text.length(); ++i) { char ch = text.charAt(i); - if (ch == ChatColor.COLOR_CHAR) continue; + if (ch == ChatColor.COLOR_CHAR) { + int j = text.indexOf(';', i); + if (j >= 0) { + i = j; + continue; + } + throw new IllegalArgumentException("Text contains unterminated color string"); + } result += chars.get(ch).getWidth(); } result += text.length() - 1; // Account for 1px spacing between characters From 9115281ff1762658109d43c1bd4fca8b7814d7f2 Mon Sep 17 00:00:00 2001 From: md_5 Date: Sat, 4 Dec 2021 08:10:14 +1100 Subject: [PATCH 22/23] SPIGOT-6832: Improve Player#getPing docs --- src/main/java/org/bukkit/entity/Player.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java index 13ac8b10..38459110 100644 --- a/src/main/java/org/bukkit/entity/Player.java +++ b/src/main/java/org/bukkit/entity/Player.java @@ -1300,8 +1300,8 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM /** * Gets the player's estimated ping in milliseconds. * - * In Vanilla this value represents the average of the response time to the - * last four application layer ping packets sent. This value does not + * In Vanilla this value represents a weighted average of the response time + * to the last four application layer ping packets sent. This value does not * represent the network round trip time and as such may have less * granularity and be impacted by other sources. For these reasons it * should not be used for anti-cheat purposes. Its recommended use is From 1c9ca4054853af6e4210a63cb71fc537d4d4af95 Mon Sep 17 00:00:00 2001 From: md_5 Date: Sat, 4 Dec 2021 08:19:20 +1100 Subject: [PATCH 23/23] SPIGOT-6832: Further improve Player#getPing docs --- src/main/java/org/bukkit/entity/Player.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java index 38459110..0213fe48 100644 --- a/src/main/java/org/bukkit/entity/Player.java +++ b/src/main/java/org/bukkit/entity/Player.java @@ -1301,12 +1301,12 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM * Gets the player's estimated ping in milliseconds. * * In Vanilla this value represents a weighted average of the response time - * to the last four application layer ping packets sent. This value does not - * represent the network round trip time and as such may have less - * granularity and be impacted by other sources. For these reasons it - * should not be used for anti-cheat purposes. Its recommended use is - * only as a qualitative indicator of connection quality (Vanilla - * uses it for this purpose in the tab list). + * to application layer ping packets sent. This value does not represent the + * network round trip time and as such may have less granularity and be + * impacted by other sources. For these reasons it should not be used + * for anti-cheat purposes. Its recommended use is only as a + * qualitative indicator of connection quality (Vanilla uses it for + * this purpose in the tab list). * * @return player ping */