From 80713fe0ac909f67cef1b1bbf94774c203c459e6 Mon Sep 17 00:00:00 2001 From: Mgazul Date: Fri, 22 Nov 2019 23:06:18 +0800 Subject: [PATCH] api --- .../co/aikar/timings/ThreadAssertion.java | 17 - .../main/java/co/aikar/timings/Timing.java | 12 +- .../java/co/aikar/timings/TimingHandler.java | 117 +-- .../java/co/aikar/timings/TimingHistory.java | 4 +- .../java/co/aikar/timings/TimingsExport.java | 10 +- .../destroystokyo/paper/HeightmapType.java | 35 + .../com/destroystokyo/paper/MaterialTags.java | 16 +- .../paper/VersionHistoryManager.java | 144 ---- .../paper/block/BlockSoundGroup.java | 52 ++ .../event/player/PlayerHandshakeEvent.java | 1 + .../paper/event/server/GS4QueryEvent.java | 1 + .../event/server/ServerExceptionEvent.java | 2 + .../paper/util/VersionFetcher.java | 44 + .../server/api/event/PlayerAttachedEvent.java | 10 - .../server/api/event/WorldAttachedEvent.java | 11 - .../akarin/server/api/structure/Village.java | 7 - .../server/core/AkarinGlobalConfig.java | 227 ----- api/src/main/java/org/bukkit/Achievement.java | 4 +- api/src/main/java/org/bukkit/Art.java | 18 +- api/src/main/java/org/bukkit/BanEntry.java | 3 +- api/src/main/java/org/bukkit/BanList.java | 5 +- api/src/main/java/org/bukkit/Bukkit.java | 56 +- api/src/main/java/org/bukkit/ChatColor.java | 60 +- api/src/main/java/org/bukkit/Chunk.java | 90 +- .../main/java/org/bukkit/ChunkSnapshot.java | 8 + api/src/main/java/org/bukkit/CoalType.java | 5 +- api/src/main/java/org/bukkit/Color.java | 5 +- api/src/main/java/org/bukkit/CropState.java | 5 +- api/src/main/java/org/bukkit/Difficulty.java | 5 +- api/src/main/java/org/bukkit/DyeColor.java | 11 +- api/src/main/java/org/bukkit/Effect.java | 4 +- .../main/java/org/bukkit/EntityEffect.java | 5 +- .../main/java/org/bukkit/FireworkEffect.java | 12 +- api/src/main/java/org/bukkit/GameMode.java | 12 +- api/src/main/java/org/bukkit/GameRule.java | 10 +- .../main/java/org/bukkit/GrassSpecies.java | 5 +- api/src/main/java/org/bukkit/Instrument.java | 31 +- api/src/main/java/org/bukkit/Location.java | 112 ++- api/src/main/java/org/bukkit/Material.java | 795 +++++++++++++++++- .../main/java/org/bukkit/NamespacedKey.java | 6 +- api/src/main/java/org/bukkit/Note.java | 6 +- .../main/java/org/bukkit/OfflinePlayer.java | 3 +- api/src/main/java/org/bukkit/Particle.java | 8 + api/src/main/java/org/bukkit/Raid.java | 134 +++ api/src/main/java/org/bukkit/Registry.java | 196 +++++ .../main/java/org/bukkit/SandstoneType.java | 5 +- api/src/main/java/org/bukkit/Server.java | 55 +- api/src/main/java/org/bukkit/Sound.java | 133 +++ api/src/main/java/org/bukkit/Statistic.java | 24 +- .../main/java/org/bukkit/StructureType.java | 42 +- api/src/main/java/org/bukkit/Tag.java | 55 +- api/src/main/java/org/bukkit/TravelAgent.java | 100 --- api/src/main/java/org/bukkit/TreeSpecies.java | 5 +- .../main/java/org/bukkit/UnsafeValues.java | 19 +- api/src/main/java/org/bukkit/Warning.java | 3 +- api/src/main/java/org/bukkit/World.java | 344 ++++++-- .../main/java/org/bukkit/WorldCreator.java | 5 + api/src/main/java/org/bukkit/WorldType.java | 5 +- .../advancement/AdvancementProgress.java | 5 +- .../bukkit/attribute/AttributeInstance.java | 3 +- .../main/java/org/bukkit/block/Banner.java | 5 +- .../main/java/org/bukkit/block/Barrel.java | 8 + .../main/java/org/bukkit/block/Beacon.java | 11 +- api/src/main/java/org/bukkit/block/Bed.java | 2 +- api/src/main/java/org/bukkit/block/Bell.java | 6 + api/src/main/java/org/bukkit/block/Biome.java | 23 +- .../java/org/bukkit/block/BlastFurnace.java | 6 + api/src/main/java/org/bukkit/block/Block.java | 18 +- .../java/org/bukkit/block/BrewingStand.java | 3 +- .../main/java/org/bukkit/block/Campfire.java | 75 ++ api/src/main/java/org/bukkit/block/Chest.java | 6 +- .../java/org/bukkit/block/CommandBlock.java | 2 +- .../java/org/bukkit/block/Comparator.java | 2 +- .../main/java/org/bukkit/block/Conduit.java | 2 +- .../main/java/org/bukkit/block/Container.java | 5 +- .../org/bukkit/block/CreatureSpawner.java | 16 +- .../org/bukkit/block/DaylightDetector.java | 2 +- .../java/org/bukkit/block/DoubleChest.java | 1 + .../main/java/org/bukkit/block/Dropper.java | 7 +- .../org/bukkit/block/EnchantingTable.java | 2 +- .../java/org/bukkit/block/EndGateway.java | 12 +- .../java/org/bukkit/block/EnderChest.java | 2 +- .../main/java/org/bukkit/block/Furnace.java | 3 +- .../main/java/org/bukkit/block/Hopper.java | 3 +- .../main/java/org/bukkit/block/Jigsaw.java | 6 + .../main/java/org/bukkit/block/Jukebox.java | 2 +- .../main/java/org/bukkit/block/Lectern.java | 45 + .../org/bukkit/block/PistonMoveReaction.java | 3 +- .../java/org/bukkit/block/ShulkerBox.java | 3 +- api/src/main/java/org/bukkit/block/Sign.java | 3 +- api/src/main/java/org/bukkit/block/Skull.java | 2 +- .../main/java/org/bukkit/block/Smoker.java | 6 + .../main/java/org/bukkit/block/Structure.java | 2 +- .../main/java/org/bukkit/block/TileState.java | 39 + .../org/bukkit/block/banner/PatternType.java | 10 +- .../main/java/org/bukkit/block/data/Rail.java | 3 +- .../org/bukkit/block/data/type/Bamboo.java | 44 + .../java/org/bukkit/block/data/type/Bell.java | 48 ++ .../org/bukkit/block/data/type/Campfire.java | 25 + .../org/bukkit/block/data/type/Lantern.java | 23 + .../org/bukkit/block/data/type/Lectern.java | 18 + .../bukkit/block/data/type/Scaffolding.java | 49 ++ .../main/java/org/bukkit/boss/BossBar.java | 4 +- .../main/java/org/bukkit/command/Command.java | 4 +- .../org/bukkit/command/PluginCommand.java | 2 +- .../command/PluginCommandYamlParser.java | 1 - .../org/bukkit/command/SimpleCommandMap.java | 14 +- .../java/org/bukkit/command/TabCompleter.java | 5 +- .../command/defaults/BukkitCommand.java | 1 - .../bukkit/command/defaults/HelpCommand.java | 4 +- .../command/defaults/ReloadCommand.java | 1 - .../command/defaults/VersionCommand.java | 202 ++--- .../bukkit/configuration/Configuration.java | 4 +- .../configuration/ConfigurationSection.java | 48 +- .../configuration/MemoryConfiguration.java | 6 +- .../bukkit/configuration/MemorySection.java | 78 +- .../configuration/file/FileConfiguration.java | 9 +- .../file/FileConfigurationOptions.java | 3 +- .../configuration/file/YamlConfiguration.java | 1 - .../configuration/file/YamlConstructor.java | 6 +- .../configuration/file/YamlRepresenter.java | 2 - .../ConfigurationSerializable.java | 3 +- .../ConfigurationSerialization.java | 3 +- .../DelegateDeserialization.java | 3 +- .../serialization/SerializableAs.java | 3 +- .../bukkit/conversations/Conversation.java | 7 +- .../ConversationAbandonedEvent.java | 3 +- .../ConversationAbandonedListener.java | 3 +- .../conversations/ConversationContext.java | 3 +- .../conversations/ConversationFactory.java | 10 +- .../ExactMatchConversationCanceller.java | 5 +- .../bukkit/conversations/FixedSetPrompt.java | 8 +- .../InactivityConversationCanceller.java | 4 + ...anuallyAbandonedConversationCanceller.java | 3 + .../bukkit/conversations/MessagePrompt.java | 2 + .../conversations/NullConversationPrefix.java | 1 + .../PluginNameConversationPrefix.java | 9 +- .../org/bukkit/conversations/RegexPrompt.java | 4 +- .../bukkit/conversations/StringPrompt.java | 1 + .../conversations/ValidatingPrompt.java | 2 + .../org/bukkit/enchantments/Enchantment.java | 16 +- .../bukkit/enchantments/EnchantmentOffer.java | 8 +- .../enchantments/EnchantmentTarget.java | 10 + .../java/org/bukkit/entity/AbstractArrow.java | 164 ++++ .../java/org/bukkit/entity/AbstractHorse.java | 2 +- .../org/bukkit/entity/AbstractVillager.java | 24 + .../main/java/org/bukkit/entity/Ageable.java | 4 +- .../java/org/bukkit/entity/AnimalTamer.java | 3 +- .../main/java/org/bukkit/entity/Animals.java | 3 +- .../org/bukkit/entity/AreaEffectCloud.java | 3 +- .../main/java/org/bukkit/entity/Arrow.java | 233 ++--- api/src/main/java/org/bukkit/entity/Boat.java | 4 +- api/src/main/java/org/bukkit/entity/Cat.java | 57 ++ .../bukkit/entity/ComplexLivingEntity.java | 3 +- .../main/java/org/bukkit/entity/Creeper.java | 34 +- .../java/org/bukkit/entity/Damageable.java | 16 + .../java/org/bukkit/entity/EnderDragon.java | 4 +- .../org/bukkit/entity/EnderDragonPart.java | 1 + .../main/java/org/bukkit/entity/Entity.java | 62 +- .../java/org/bukkit/entity/EntityType.java | 64 +- .../java/org/bukkit/entity/ExperienceOrb.java | 4 + .../main/java/org/bukkit/entity/Firework.java | 18 + api/src/main/java/org/bukkit/entity/Fox.java | 53 ++ .../main/java/org/bukkit/entity/Golem.java | 2 +- .../main/java/org/bukkit/entity/Guardian.java | 4 +- .../main/java/org/bukkit/entity/Horse.java | 2 +- .../java/org/bukkit/entity/HumanEntity.java | 11 +- .../main/java/org/bukkit/entity/Illager.java | 2 +- .../org/bukkit/entity/LightningStrike.java | 2 +- .../org/bukkit/entity/LingeringPotion.java | 2 + .../java/org/bukkit/entity/LivingEntity.java | 34 +- .../main/java/org/bukkit/entity/Minecart.java | 2 +- .../java/org/bukkit/entity/MushroomCow.java | 30 + .../main/java/org/bukkit/entity/Ocelot.java | 5 +- .../main/java/org/bukkit/entity/Panda.java | 66 ++ .../main/java/org/bukkit/entity/Pillager.java | 8 + .../main/java/org/bukkit/entity/Player.java | 63 +- api/src/main/java/org/bukkit/entity/Pose.java | 37 + .../main/java/org/bukkit/entity/Raider.java | 36 + .../main/java/org/bukkit/entity/Ravager.java | 6 + .../main/java/org/bukkit/entity/Skeleton.java | 2 +- .../java/org/bukkit/entity/SpectralArrow.java | 6 +- .../java/org/bukkit/entity/SplashPotion.java | 3 + .../java/org/bukkit/entity/ThrownPotion.java | 1 - .../java/org/bukkit/entity/TippedArrow.java | 102 +-- .../java/org/bukkit/entity/TraderLlama.java | 6 + .../main/java/org/bukkit/entity/Trident.java | 2 +- .../main/java/org/bukkit/entity/Vehicle.java | 2 + .../main/java/org/bukkit/entity/Villager.java | 337 +++----- .../org/bukkit/entity/WanderingTrader.java | 6 + .../main/java/org/bukkit/entity/Weather.java | 6 - .../main/java/org/bukkit/entity/Witch.java | 4 +- api/src/main/java/org/bukkit/entity/Wolf.java | 4 +- .../main/java/org/bukkit/entity/Zombie.java | 4 +- .../org/bukkit/entity/ZombieVillager.java | 19 + .../org/bukkit/entity/memory/MemoryKey.java | 76 ++ .../entity/minecart/HopperMinecart.java | 6 +- .../java/org/bukkit/event/EventHandler.java | 4 +- .../java/org/bukkit/event/HandlerList.java | 55 +- .../bukkit/event/block/BlockBreakEvent.java | 2 + .../bukkit/event/block/BlockBurnEvent.java | 2 + .../event/block/BlockCanBuildEvent.java | 2 +- .../bukkit/event/block/BlockCookEvent.java | 74 ++ .../bukkit/event/block/BlockDamageEvent.java | 2 + .../event/block/BlockDispenseEvent.java | 2 + .../event/block/BlockDropItemEvent.java | 9 - .../org/bukkit/event/block/BlockEvent.java | 6 +- .../org/bukkit/event/block/BlockExpEvent.java | 1 + .../bukkit/event/block/BlockExplodeEvent.java | 5 +- .../bukkit/event/block/BlockFadeEvent.java | 2 + .../event/block/BlockFertilizeEvent.java | 1 - .../bukkit/event/block/BlockFromToEvent.java | 2 + .../bukkit/event/block/BlockGrowEvent.java | 3 + .../bukkit/event/block/BlockIgniteEvent.java | 6 + .../event/block/BlockMultiPlaceEvent.java | 3 +- .../bukkit/event/block/BlockPhysicsEvent.java | 6 +- .../bukkit/event/block/BlockPistonEvent.java | 2 + .../event/block/BlockPistonExtendEvent.java | 1 - .../event/block/BlockPistonRetractEvent.java | 6 +- .../bukkit/event/block/BlockPlaceEvent.java | 2 + .../event/block/BlockShearEntityEvent.java | 67 ++ .../event/block/EntityBlockFormEvent.java | 2 +- .../bukkit/event/block/LeavesDecayEvent.java | 2 + .../org/bukkit/event/block/NotePlayEvent.java | 2 + .../bukkit/event/block/SignChangeEvent.java | 2 + .../bukkit/event/block/SpongeAbsorbEvent.java | 4 +- .../event/enchantment/EnchantItemEvent.java | 14 +- .../entity/AreaEffectCloudApplyEvent.java | 1 - .../event/entity/CreatureSpawnEvent.java | 20 + .../event/entity/CreeperPowerEvent.java | 2 + .../entity/EnderDragonChangePhaseEvent.java | 8 +- .../event/entity/EntityChangeBlockEvent.java | 2 + .../event/entity/EntityCombustEvent.java | 2 + .../event/entity/EntityCreatePortalEvent.java | 6 + .../entity/EntityDamageByBlockEvent.java | 3 +- .../entity/EntityDamageByEntityEvent.java | 3 +- .../event/entity/EntityDamageEvent.java | 10 +- .../org/bukkit/event/entity/EntityEvent.java | 6 +- .../event/entity/EntityExplodeEvent.java | 6 +- .../event/entity/EntityInteractEvent.java | 2 + .../event/entity/EntityPickupItemEvent.java | 2 + .../event/entity/EntityPortalEnterEvent.java | 2 +- .../event/entity/EntityPortalEvent.java | 59 +- .../event/entity/EntityPortalExitEvent.java | 4 +- .../event/entity/EntityPoseChangeEvent.java | 44 + .../event/entity/EntityShootBowEvent.java | 8 +- .../bukkit/event/entity/EntityTameEvent.java | 2 + .../event/entity/EntityTargetEvent.java | 9 +- .../entity/EntityTargetLivingEntityEvent.java | 2 + .../event/entity/EntityTeleportEvent.java | 4 +- .../event/entity/ExplosionPrimeEvent.java | 2 + .../event/entity/FoodLevelChangeEvent.java | 20 + .../bukkit/event/entity/HorseJumpEvent.java | 4 +- .../bukkit/event/entity/ItemDespawnEvent.java | 2 + .../bukkit/event/entity/ItemSpawnEvent.java | 1 - .../entity/LingeringPotionSplashEvent.java | 7 +- .../org/bukkit/event/entity/PigZapEvent.java | 2 + .../bukkit/event/entity/PlayerDeathEvent.java | 9 +- .../event/entity/PlayerLeashEntityEvent.java | 2 + .../event/entity/PotionSplashEvent.java | 3 +- .../event/entity/ProjectileLaunchEvent.java | 2 + .../event/entity/SheepDyeWoolEvent.java | 2 + .../event/entity/SheepRegrowWoolEvent.java | 2 + .../bukkit/event/entity/SlimeSplitEvent.java | 4 +- .../entity/VillagerAcquireTradeEvent.java | 8 +- .../entity/VillagerCareerChangeEvent.java | 92 ++ .../entity/VillagerReplenishTradeEvent.java | 8 +- .../event/hanging/HangingBreakEvent.java | 2 + .../bukkit/event/hanging/HangingEvent.java | 6 +- .../event/hanging/HangingPlaceEvent.java | 2 + .../org/bukkit/event/inventory/BrewEvent.java | 2 + .../event/inventory/FurnaceBurnEvent.java | 2 + .../event/inventory/FurnaceSmeltEvent.java | 63 +- .../event/inventory/InventoryClickEvent.java | 10 +- .../inventory/InventoryCreativeEvent.java | 12 +- .../event/inventory/InventoryDragEvent.java | 8 +- .../event/inventory/InventoryEvent.java | 15 +- .../inventory/InventoryInteractEvent.java | 16 +- .../inventory/InventoryMoveItemEvent.java | 2 + .../event/inventory/InventoryOpenEvent.java | 4 +- .../inventory/InventoryPickupItemEvent.java | 2 + .../bukkit/event/inventory/InventoryType.java | 44 +- .../event/inventory/PrepareAnvilEvent.java | 10 +- .../inventory/PrepareItemCraftEvent.java | 10 +- .../event/inventory/TradeSelectEvent.java | 62 ++ .../event/player/AsyncPlayerChatEvent.java | 3 +- .../player/AsyncPlayerPreLoginEvent.java | 3 +- .../player/PlayerAchievementAwardedEvent.java | 2 + .../event/player/PlayerAnimationEvent.java | 2 + .../PlayerArmorStandManipulateEvent.java | 4 +- .../event/player/PlayerBucketEmptyEvent.java | 9 + .../event/player/PlayerBucketEvent.java | 30 +- .../event/player/PlayerBucketFillEvent.java | 10 + .../bukkit/event/player/PlayerChatEvent.java | 3 +- .../player/PlayerChatTabCompleteEvent.java | 1 - .../player/PlayerCommandPreprocessEvent.java | 3 +- .../event/player/PlayerDropItemEvent.java | 2 + .../event/player/PlayerEditBookEvent.java | 2 + .../org/bukkit/event/player/PlayerEvent.java | 6 +- .../bukkit/event/player/PlayerFishEvent.java | 14 +- .../player/PlayerGameModeChangeEvent.java | 2 + .../player/PlayerInteractAtEntityEvent.java | 3 + .../player/PlayerInteractEntityEvent.java | 2 + .../event/player/PlayerInteractEvent.java | 14 +- .../event/player/PlayerItemConsumeEvent.java | 2 + .../event/player/PlayerItemHeldEvent.java | 2 + .../bukkit/event/player/PlayerJoinEvent.java | 11 +- .../bukkit/event/player/PlayerKickEvent.java | 2 + .../bukkit/event/player/PlayerLoginEvent.java | 5 +- .../bukkit/event/player/PlayerMoveEvent.java | 4 +- .../event/player/PlayerPickupArrowEvent.java | 8 +- .../event/player/PlayerPickupItemEvent.java | 2 + .../event/player/PlayerPortalEvent.java | 60 +- .../event/player/PlayerPreLoginEvent.java | 1 - .../bukkit/event/player/PlayerQuitEvent.java | 7 +- .../event/player/PlayerShearEntityEvent.java | 2 + .../player/PlayerStatisticIncrementEvent.java | 2 + .../player/PlayerTakeLecternBookEvent.java | 67 ++ .../event/player/PlayerToggleFlightEvent.java | 2 + .../event/player/PlayerToggleSneakEvent.java | 2 + .../event/player/PlayerToggleSprintEvent.java | 2 + .../player/PlayerUnleashEntityEvent.java | 2 + .../event/player/PlayerVelocityEvent.java | 2 + .../java/org/bukkit/event/raid/RaidEvent.java | 29 + .../bukkit/event/raid/RaidFinishEvent.java | 48 ++ .../bukkit/event/raid/RaidSpawnWaveEvent.java | 58 ++ .../org/bukkit/event/raid/RaidStopEvent.java | 66 ++ .../bukkit/event/raid/RaidTriggerEvent.java | 56 ++ .../event/server/BroadcastMessageEvent.java | 11 + .../org/bukkit/event/server/ServerEvent.java | 11 +- .../event/server/ServerListPingEvent.java | 7 +- .../org/bukkit/event/server/ServiceEvent.java | 2 +- .../event/vehicle/VehicleDamageEvent.java | 2 + .../event/vehicle/VehicleDestroyEvent.java | 2 + .../event/vehicle/VehicleEnterEvent.java | 2 + .../vehicle/VehicleEntityCollisionEvent.java | 2 + .../bukkit/event/vehicle/VehicleEvent.java | 6 +- .../event/vehicle/VehicleExitEvent.java | 2 + .../event/weather/LightningStrikeEvent.java | 2 + .../event/weather/ThunderChangeEvent.java | 2 + .../event/weather/WeatherChangeEvent.java | 2 + .../bukkit/event/weather/WeatherEvent.java | 4 +- .../bukkit/event/world/ChunkUnloadEvent.java | 12 +- .../bukkit/event/world/PortalCreateEvent.java | 50 +- .../bukkit/event/world/SpawnChangeEvent.java | 2 +- .../event/world/StructureGrowEvent.java | 2 + .../bukkit/event/world/WorldUnloadEvent.java | 2 + .../org/bukkit/generator/ChunkGenerator.java | 46 +- .../bukkit/help/GenericCommandHelpTopic.java | 3 +- .../main/java/org/bukkit/help/HelpMap.java | 9 +- .../org/bukkit/help/HelpTopicComparator.java | 9 +- .../java/org/bukkit/help/IndexHelpTopic.java | 5 +- .../org/bukkit/inventory/BlastingRecipe.java | 19 + .../inventory/BlockInventoryHolder.java | 21 + .../org/bukkit/inventory/BrewerInventory.java | 1 + .../org/bukkit/inventory/CampfireRecipe.java | 19 + .../inventory/CartographyInventory.java | 6 + .../org/bukkit/inventory/CookingRecipe.java | 173 ++++ .../inventory/DoubleChestInventory.java | 1 + .../org/bukkit/inventory/EntityEquipment.java | 14 +- .../bukkit/inventory/FurnaceInventory.java | 1 + .../org/bukkit/inventory/FurnaceRecipe.java | 137 +-- .../bukkit/inventory/GrindstoneInventory.java | 6 + .../java/org/bukkit/inventory/Inventory.java | 24 - .../org/bukkit/inventory/InventoryView.java | 32 +- .../org/bukkit/inventory/ItemFactory.java | 2 +- .../java/org/bukkit/inventory/ItemStack.java | 11 +- .../bukkit/inventory/LecternInventory.java | 14 + .../org/bukkit/inventory/LoomInventory.java | 6 + .../java/org/bukkit/inventory/Merchant.java | 5 +- .../bukkit/inventory/MerchantInventory.java | 9 + .../org/bukkit/inventory/MerchantRecipe.java | 57 +- .../org/bukkit/inventory/PlayerInventory.java | 1 + .../org/bukkit/inventory/RecipeChoice.java | 14 +- .../org/bukkit/inventory/ShapedRecipe.java | 5 +- .../org/bukkit/inventory/ShapelessRecipe.java | 5 +- .../org/bukkit/inventory/SmokingRecipe.java | 19 + .../inventory/StonecutterInventory.java | 6 + .../bukkit/inventory/StonecuttingRecipe.java | 127 +++ .../bukkit/inventory/meta/BlockDataMeta.java | 37 + .../bukkit/inventory/meta/BlockStateMeta.java | 2 +- .../org/bukkit/inventory/meta/BookMeta.java | 2 +- .../bukkit/inventory/meta/CrossbowMeta.java | 44 + .../meta/EnchantmentStorageMeta.java | 2 +- .../inventory/meta/FireworkEffectMeta.java | 1 + .../bukkit/inventory/meta/FireworkMeta.java | 2 +- .../org/bukkit/inventory/meta/ItemMeta.java | 51 +- .../inventory/meta/LeatherArmorMeta.java | 1 + .../org/bukkit/inventory/meta/MapMeta.java | 1 + .../org/bukkit/inventory/meta/PotionMeta.java | 5 +- .../org/bukkit/inventory/meta/SkullMeta.java | 1 + .../inventory/meta/SuspiciousStewMeta.java | 67 ++ .../meta/TropicalFishBucketMeta.java | 1 + .../meta/tags/CustomItemTagContainer.java | 5 + .../meta/tags/ItemTagAdapterContext.java | 6 + .../inventory/meta/tags/ItemTagType.java | 8 +- .../main/java/org/bukkit/loot/LootTable.java | 5 +- .../main/java/org/bukkit/loot/LootTables.java | 45 +- .../main/java/org/bukkit/map/MapCanvas.java | 3 +- .../main/java/org/bukkit/map/MapCursor.java | 2 +- .../org/bukkit/map/MapCursorCollection.java | 5 +- .../main/java/org/bukkit/map/MapPalette.java | 5 +- .../main/java/org/bukkit/map/MapRenderer.java | 4 +- api/src/main/java/org/bukkit/map/MapView.java | 34 + .../main/java/org/bukkit/material/Banner.java | 8 + .../main/java/org/bukkit/material/Bed.java | 6 + .../main/java/org/bukkit/material/Button.java | 9 +- .../main/java/org/bukkit/material/Cake.java | 5 + .../java/org/bukkit/material/Cauldron.java | 4 + .../main/java/org/bukkit/material/Chest.java | 4 + .../main/java/org/bukkit/material/Coal.java | 4 + .../java/org/bukkit/material/CocoaPlant.java | 7 + .../java/org/bukkit/material/Command.java | 5 + .../java/org/bukkit/material/Comparator.java | 4 + .../main/java/org/bukkit/material/Crops.java | 4 + .../org/bukkit/material/DetectorRail.java | 5 + .../main/java/org/bukkit/material/Diode.java | 4 + .../bukkit/material/DirectionalContainer.java | 6 + .../java/org/bukkit/material/Dispenser.java | 6 + .../main/java/org/bukkit/material/Door.java | 8 + .../main/java/org/bukkit/material/Dye.java | 6 + .../java/org/bukkit/material/EnderChest.java | 4 + .../org/bukkit/material/ExtendedRails.java | 4 + .../java/org/bukkit/material/Furnace.java | 4 + .../bukkit/material/FurnaceAndDispenser.java | 4 + .../main/java/org/bukkit/material/Gate.java | 8 + .../main/java/org/bukkit/material/Hopper.java | 4 + .../main/java/org/bukkit/material/Ladder.java | 8 +- .../main/java/org/bukkit/material/Leaves.java | 4 + .../main/java/org/bukkit/material/Lever.java | 9 +- .../java/org/bukkit/material/LongGrass.java | 4 + .../org/bukkit/material/MaterialData.java | 5 +- .../java/org/bukkit/material/MonsterEggs.java | 5 +- .../java/org/bukkit/material/Mushroom.java | 5 +- .../java/org/bukkit/material/NetherWarts.java | 4 + .../java/org/bukkit/material/Observer.java | 4 + .../bukkit/material/PistonBaseMaterial.java | 10 +- .../material/PistonExtensionMaterial.java | 7 + .../java/org/bukkit/material/PoweredRail.java | 5 + .../org/bukkit/material/PressurePlate.java | 5 + .../java/org/bukkit/material/Pumpkin.java | 6 + .../main/java/org/bukkit/material/Rails.java | 4 + .../org/bukkit/material/RedstoneTorch.java | 5 + .../org/bukkit/material/RedstoneWire.java | 5 + .../java/org/bukkit/material/Sandstone.java | 4 + .../java/org/bukkit/material/Sapling.java | 4 + .../main/java/org/bukkit/material/Sign.java | 9 +- .../SimpleAttachableMaterialData.java | 5 + .../main/java/org/bukkit/material/Skull.java | 6 + .../java/org/bukkit/material/SmoothBrick.java | 5 +- .../main/java/org/bukkit/material/Stairs.java | 6 + .../main/java/org/bukkit/material/Step.java | 5 +- .../org/bukkit/material/TexturedMaterial.java | 5 +- .../main/java/org/bukkit/material/Torch.java | 8 +- .../java/org/bukkit/material/TrapDoor.java | 8 + .../main/java/org/bukkit/material/Tree.java | 4 + .../java/org/bukkit/material/Tripwire.java | 4 + .../org/bukkit/material/TripwireHook.java | 7 + .../main/java/org/bukkit/material/Vine.java | 5 +- .../main/java/org/bukkit/material/Wood.java | 6 +- .../java/org/bukkit/material/WoodenStep.java | 4 + .../main/java/org/bukkit/material/Wool.java | 5 + .../material/types/MushroomBlockTexture.java | 11 +- .../bukkit/metadata/LazyMetadataValue.java | 5 +- .../org/bukkit/metadata/MetadataStore.java | 3 +- .../bukkit/metadata/MetadataStoreBase.java | 13 +- .../bukkit/metadata/MetadataValueAdapter.java | 10 +- .../java/org/bukkit/metadata/Metadatable.java | 3 +- .../bukkit/permissions/PermissibleBase.java | 14 + .../org/bukkit/permissions/Permission.java | 1 - .../bukkit/permissions/PermissionDefault.java | 7 +- .../PersistentDataAdapterContext.java | 18 + .../persistence/PersistentDataContainer.java | 141 ++++ .../persistence/PersistentDataHolder.java | 23 + .../persistence/PersistentDataType.java | 153 ++++ .../main/java/org/bukkit/plugin/Plugin.java | 1 - .../java/org/bukkit/plugin/PluginBase.java | 1 + .../bukkit/plugin/PluginDescriptionFile.java | 14 +- .../java/org/bukkit/plugin/PluginLoader.java | 1 - .../java/org/bukkit/plugin/PluginLogger.java | 3 +- .../java/org/bukkit/plugin/PluginManager.java | 1 - .../org/bukkit/plugin/RegisteredListener.java | 6 +- .../plugin/RegisteredServiceProvider.java | 1 + .../org/bukkit/plugin/ServicesManager.java | 5 +- .../bukkit/plugin/SimplePluginManager.java | 242 +++--- .../bukkit/plugin/SimpleServicesManager.java | 24 +- .../org/bukkit/plugin/java/JavaPlugin.java | 4 +- .../bukkit/plugin/java/JavaPluginLoader.java | 9 +- .../bukkit/plugin/java/PluginClassLoader.java | 1 - .../bukkit/plugin/messaging/Messenger.java | 2 +- .../plugin/messaging/StandardMessenger.java | 19 + .../main/java/org/bukkit/potion/Potion.java | 11 - .../java/org/bukkit/potion/PotionBrewer.java | 3 +- .../java/org/bukkit/potion/PotionEffect.java | 5 +- .../org/bukkit/potion/PotionEffectType.java | 15 +- .../java/org/bukkit/potion/PotionType.java | 30 +- .../org/bukkit/scheduler/BukkitScheduler.java | 7 +- .../java/org/bukkit/scoreboard/Criterias.java | 16 +- .../org/bukkit/scoreboard/Scoreboard.java | 1 - .../bukkit/scoreboard/ScoreboardManager.java | 3 +- .../main/java/org/bukkit/scoreboard/Team.java | 1 - .../java/org/bukkit/util/BlockIterator.java | 11 +- .../java/org/bukkit/util/ChatPaginator.java | 7 +- .../main/java/org/bukkit/util/FileUtil.java | 5 +- .../java/org/bukkit/util/RayTraceResult.java | 1 - api/src/main/java/org/bukkit/util/Vector.java | 4 +- .../util/io/BukkitObjectInputStream.java | 1 - .../util/io/BukkitObjectOutputStream.java | 1 - .../main/java/org/bukkit/util/io/Wrapper.java | 6 +- .../org/bukkit/util/noise/NoiseGenerator.java | 2 +- .../util/noise/PerlinNoiseGenerator.java | 4 +- .../util/noise/SimplexNoiseGenerator.java | 4 +- 512 files changed, 6986 insertions(+), 2814 deletions(-) delete mode 100644 api/src/main/java/co/aikar/timings/ThreadAssertion.java create mode 100644 api/src/main/java/com/destroystokyo/paper/HeightmapType.java delete mode 100644 api/src/main/java/com/destroystokyo/paper/VersionHistoryManager.java create mode 100644 api/src/main/java/com/destroystokyo/paper/block/BlockSoundGroup.java create mode 100644 api/src/main/java/com/destroystokyo/paper/util/VersionFetcher.java delete mode 100644 api/src/main/java/io/akarin/server/api/event/PlayerAttachedEvent.java delete mode 100644 api/src/main/java/io/akarin/server/api/event/WorldAttachedEvent.java delete mode 100644 api/src/main/java/io/akarin/server/api/structure/Village.java delete mode 100644 api/src/main/java/io/akarin/server/core/AkarinGlobalConfig.java create mode 100644 api/src/main/java/org/bukkit/Raid.java create mode 100644 api/src/main/java/org/bukkit/Registry.java delete mode 100644 api/src/main/java/org/bukkit/TravelAgent.java create mode 100644 api/src/main/java/org/bukkit/block/Barrel.java create mode 100644 api/src/main/java/org/bukkit/block/Bell.java create mode 100644 api/src/main/java/org/bukkit/block/BlastFurnace.java create mode 100644 api/src/main/java/org/bukkit/block/Campfire.java create mode 100644 api/src/main/java/org/bukkit/block/Jigsaw.java create mode 100644 api/src/main/java/org/bukkit/block/Lectern.java create mode 100644 api/src/main/java/org/bukkit/block/Smoker.java create mode 100644 api/src/main/java/org/bukkit/block/TileState.java create mode 100644 api/src/main/java/org/bukkit/block/data/type/Bamboo.java create mode 100644 api/src/main/java/org/bukkit/block/data/type/Bell.java create mode 100644 api/src/main/java/org/bukkit/block/data/type/Campfire.java create mode 100644 api/src/main/java/org/bukkit/block/data/type/Lantern.java create mode 100644 api/src/main/java/org/bukkit/block/data/type/Lectern.java create mode 100644 api/src/main/java/org/bukkit/block/data/type/Scaffolding.java create mode 100644 api/src/main/java/org/bukkit/entity/AbstractArrow.java create mode 100644 api/src/main/java/org/bukkit/entity/AbstractVillager.java create mode 100644 api/src/main/java/org/bukkit/entity/Cat.java create mode 100644 api/src/main/java/org/bukkit/entity/Fox.java create mode 100644 api/src/main/java/org/bukkit/entity/Panda.java create mode 100644 api/src/main/java/org/bukkit/entity/Pillager.java create mode 100644 api/src/main/java/org/bukkit/entity/Pose.java create mode 100644 api/src/main/java/org/bukkit/entity/Raider.java create mode 100644 api/src/main/java/org/bukkit/entity/Ravager.java create mode 100644 api/src/main/java/org/bukkit/entity/TraderLlama.java create mode 100644 api/src/main/java/org/bukkit/entity/WanderingTrader.java delete mode 100644 api/src/main/java/org/bukkit/entity/Weather.java create mode 100644 api/src/main/java/org/bukkit/entity/memory/MemoryKey.java create mode 100644 api/src/main/java/org/bukkit/event/block/BlockCookEvent.java create mode 100644 api/src/main/java/org/bukkit/event/block/BlockShearEntityEvent.java create mode 100644 api/src/main/java/org/bukkit/event/entity/EntityPoseChangeEvent.java create mode 100644 api/src/main/java/org/bukkit/event/entity/VillagerCareerChangeEvent.java create mode 100644 api/src/main/java/org/bukkit/event/inventory/TradeSelectEvent.java create mode 100644 api/src/main/java/org/bukkit/event/player/PlayerTakeLecternBookEvent.java create mode 100644 api/src/main/java/org/bukkit/event/raid/RaidEvent.java create mode 100644 api/src/main/java/org/bukkit/event/raid/RaidFinishEvent.java create mode 100644 api/src/main/java/org/bukkit/event/raid/RaidSpawnWaveEvent.java create mode 100644 api/src/main/java/org/bukkit/event/raid/RaidStopEvent.java create mode 100644 api/src/main/java/org/bukkit/event/raid/RaidTriggerEvent.java create mode 100644 api/src/main/java/org/bukkit/inventory/BlastingRecipe.java create mode 100644 api/src/main/java/org/bukkit/inventory/BlockInventoryHolder.java create mode 100644 api/src/main/java/org/bukkit/inventory/CampfireRecipe.java create mode 100644 api/src/main/java/org/bukkit/inventory/CartographyInventory.java create mode 100644 api/src/main/java/org/bukkit/inventory/CookingRecipe.java create mode 100644 api/src/main/java/org/bukkit/inventory/GrindstoneInventory.java create mode 100644 api/src/main/java/org/bukkit/inventory/LecternInventory.java create mode 100644 api/src/main/java/org/bukkit/inventory/LoomInventory.java create mode 100644 api/src/main/java/org/bukkit/inventory/SmokingRecipe.java create mode 100644 api/src/main/java/org/bukkit/inventory/StonecutterInventory.java create mode 100644 api/src/main/java/org/bukkit/inventory/StonecuttingRecipe.java create mode 100644 api/src/main/java/org/bukkit/inventory/meta/BlockDataMeta.java create mode 100644 api/src/main/java/org/bukkit/inventory/meta/CrossbowMeta.java create mode 100644 api/src/main/java/org/bukkit/inventory/meta/SuspiciousStewMeta.java create mode 100644 api/src/main/java/org/bukkit/persistence/PersistentDataAdapterContext.java create mode 100644 api/src/main/java/org/bukkit/persistence/PersistentDataContainer.java create mode 100644 api/src/main/java/org/bukkit/persistence/PersistentDataHolder.java create mode 100644 api/src/main/java/org/bukkit/persistence/PersistentDataType.java diff --git a/api/src/main/java/co/aikar/timings/ThreadAssertion.java b/api/src/main/java/co/aikar/timings/ThreadAssertion.java deleted file mode 100644 index adc4c5efc..000000000 --- a/api/src/main/java/co/aikar/timings/ThreadAssertion.java +++ /dev/null @@ -1,17 +0,0 @@ -package co.aikar.timings; - -public class ThreadAssertion { - private static boolean mainThread; - - public static boolean is() { - return mainThread; - } - - static void start() { - mainThread = true; - } - - public static void close() { - mainThread = false; - } -} diff --git a/api/src/main/java/co/aikar/timings/Timing.java b/api/src/main/java/co/aikar/timings/Timing.java index 0ea5422bf..a21e5ead5 100644 --- a/api/src/main/java/co/aikar/timings/Timing.java +++ b/api/src/main/java/co/aikar/timings/Timing.java @@ -23,8 +23,8 @@ */ package co.aikar.timings; -import javax.annotation.Nonnull; // Akarin - javax.annotation -import javax.annotation.Nullable; // Akarin - javax.annotation +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Provides an ability to time sections of code within the Minecraft Server @@ -35,10 +35,8 @@ public interface Timing extends AutoCloseable { * * @return Timing */ - @Nonnull // Akarin - javax.annotation + @NotNull Timing startTiming(); - default Timing startTiming(boolean assertThread) { return startTiming(); }; // Akarin - default Timing startTimingUnsafe() { return startTiming(); }; // Akarin /** *

Stops timing and records the data. Propagates the data up to group handlers.

@@ -46,7 +44,6 @@ public interface Timing extends AutoCloseable { * Will automatically be called when this Timing is used with try-with-resources */ void stopTiming(); - default void stopTimingUnsafe() { stopTiming(); }; // Akarin /** * Starts timing the execution until {@link #stopTiming()} is called. @@ -55,9 +52,8 @@ public interface Timing extends AutoCloseable { * * @return Timing */ - @Nonnull // Akarin - javax.annotation + @NotNull Timing startTimingIfSync(); - default Timing startTimingIfSync(boolean assertThread) { return startTimingIfSync(); }; // Akarin /** *

Stops timing and records the data. Propagates the data up to group handlers.

diff --git a/api/src/main/java/co/aikar/timings/TimingHandler.java b/api/src/main/java/co/aikar/timings/TimingHandler.java index 42bb3113d..cc0390c06 100644 --- a/api/src/main/java/co/aikar/timings/TimingHandler.java +++ b/api/src/main/java/co/aikar/timings/TimingHandler.java @@ -24,7 +24,6 @@ package co.aikar.timings; import co.aikar.util.LoadingIntMap; -import io.akarin.server.core.AkarinGlobalConfig; import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; import java.util.ArrayDeque; @@ -33,10 +32,9 @@ import java.util.concurrent.atomic.AtomicInteger; import java.util.logging.Level; import java.util.logging.Logger; -import javax.annotation.Nonnull; // Akarin - javax.annotation -import javax.annotation.Nullable; // Akarin - javax.annotation - import org.bukkit.Bukkit; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; class TimingHandler implements Timing { @@ -50,6 +48,7 @@ class TimingHandler implements Timing { private final Int2ObjectOpenHashMap children = new LoadingIntMap<>(TimingData::new); final TimingData record; + private TimingHandler startParent; private final TimingHandler groupHandler; private long start = 0; @@ -58,7 +57,7 @@ class TimingHandler implements Timing { private boolean timed; private boolean enabled; - TimingHandler(@Nonnull TimingIdentifier id) { // Akarin - javax.annotation + TimingHandler(@NotNull TimingIdentifier id) { this.identifier = id; this.verbose = id.name.startsWith("##"); this.record = new TimingData(this.id); @@ -85,17 +84,10 @@ class TimingHandler implements Timing { } } - @Nonnull // Akarin - javax.annotation + @NotNull @Override public Timing startTimingIfSync() { - // Akarin start - return startTiming(false); - } - @Nonnull // Akarin - javax.annotation - @Override - public Timing startTimingIfSync(boolean assertThread) { - startTiming(assertThread); - // Akarin end + startTiming(); return this; } @@ -104,70 +96,49 @@ class TimingHandler implements Timing { stopTiming(); } - @Nonnull // Akarin - javax.annotation + @NotNull public Timing startTiming() { - // Akarin start - return startTiming(false); - } - - @Override - public Timing startTimingUnsafe() { - if (enabled && ++timingDepth == 1) { - ThreadAssertion.close(); - // Akarin end - start = System.nanoTime(); - TIMING_STACK.addLast(this); + if (!enabled || !Bukkit.isPrimaryThread()) { + return this; } + if (++timingDepth == 1) { + startParent = TIMING_STACK.peekLast(); + start = System.nanoTime(); + } + TIMING_STACK.addLast(this); return this; } - // Akarin start - @Override - public Timing startTiming(boolean assertThread) { - if (enabled && (ThreadAssertion.is() || Bukkit.isPrimaryThread()) && ++timingDepth == 1) { - start = System.nanoTime(); - TIMING_STACK.addLast(this); - if (assertThread && AkarinGlobalConfig.lazyThreadAssertion) - ThreadAssertion.start(); - } - return this; - } - - @Override - public void stopTimingUnsafe() { - if (enabled && timingDepth > 0 && --timingDepth == 0 && start != 0) { - TimingHandler last = TIMING_STACK.removeLast(); - if (last != this) { - Logger.getGlobal().log(Level.SEVERE, "TIMING_STACK_CORRUPTION - Report this to Paper! ( " + this.identifier + ":" + last +")", new Throwable()); - TIMING_STACK.addLast(last); // Add it back - } - addDiff(System.nanoTime() - start, TIMING_STACK.peekLast()); - - start = 0; - ThreadAssertion.close(); - } - } - // Akarin end public void stopTiming() { - if (enabled && timingDepth > 0 && (ThreadAssertion.is() || Bukkit.isPrimaryThread()) && --timingDepth == 0 && start != 0) { // Akarin - TimingHandler last; - while ((last = TIMING_STACK.removeLast()) != this) { - last.timingDepth = 0; - String reportTo; - if ("minecraft".equals(last.identifier.group)) { - reportTo = "Paper! This is a potential bug in Paper"; - } else { - reportTo = "the plugin " + last.identifier.group + "(Look for errors above this in the logs)"; - } - Logger.getGlobal().log(Level.SEVERE, "TIMING_STACK_CORRUPTION - Report this to " + reportTo + " (" + last.identifier +" did not stopTiming)", new Throwable()); - } - addDiff(System.nanoTime() - start, TIMING_STACK.peekLast()); + if (!enabled || timingDepth <= 0 || start == 0 || !Bukkit.isPrimaryThread()) { + return; + } + popTimingStack(); + if (--timingDepth == 0) { + addDiff(System.nanoTime() - start, startParent); + startParent = null; start = 0; - // Akarin start - if (AkarinGlobalConfig.lazyThreadAssertion) - ThreadAssertion.close(); - // Akarin end + } + } + + private void popTimingStack() { + TimingHandler last; + while ((last = TIMING_STACK.removeLast()) != this) { + last.timingDepth = 0; + String reportTo; + if ("Minecraft".equalsIgnoreCase(last.identifier.group)) { + reportTo = "Paper! This is a potential bug in Paper"; + } else { + reportTo = "the plugin " + last.identifier.group + "(Look for errors above this in the logs)"; + } + Logger.getGlobal().log(Level.SEVERE, "TIMING_STACK_CORRUPTION - Report this to " + reportTo + " (" + last.identifier + " did not stopTiming)", new Throwable()); + boolean found = TIMING_STACK.contains(this); + if (!found) { + // We aren't even in the stack... Don't pop everything + TIMING_STACK.addLast(last); + break; + } } } @@ -208,7 +179,7 @@ class TimingHandler implements Timing { checkEnabled(); } - @Nonnull // Akarin - javax.annotation + @NotNull @Override public TimingHandler getTimingHandler() { return this; @@ -229,7 +200,7 @@ class TimingHandler implements Timing { */ @Override public void close() { - if (ThreadAssertion.is()) stopTimingUnsafe(); else stopTimingIfSync(); // Akarin + stopTimingIfSync(); } public boolean isSpecial() { @@ -244,7 +215,7 @@ class TimingHandler implements Timing { return enabled; } - @Nonnull // Akarin - javax.annotation + @NotNull TimingData[] cloneChildren() { final TimingData[] clonedChildren = new TimingData[children.size()]; int i = 0; diff --git a/api/src/main/java/co/aikar/timings/TimingHistory.java b/api/src/main/java/co/aikar/timings/TimingHistory.java index 99815866b..203cda0f9 100644 --- a/api/src/main/java/co/aikar/timings/TimingHistory.java +++ b/api/src/main/java/co/aikar/timings/TimingHistory.java @@ -144,7 +144,7 @@ public class TimingHistory { public JSONPair apply(Map.Entry entry) { entityTypeSet.add(entry.getKey()); return pair( - String.valueOf(entry.getKey().getTypeId()), + String.valueOf(entry.getKey().ordinal()), entry.getValue().count() ); } @@ -157,7 +157,7 @@ public class TimingHistory { public JSONPair apply(Map.Entry entry) { tileEntityTypeSet.add(entry.getKey()); return pair( - String.valueOf(entry.getKey().getId()), + String.valueOf(entry.getKey().ordinal()), entry.getValue().count() ); } diff --git a/api/src/main/java/co/aikar/timings/TimingsExport.java b/api/src/main/java/co/aikar/timings/TimingsExport.java index 65d312b02..23eb8c65c 100644 --- a/api/src/main/java/co/aikar/timings/TimingsExport.java +++ b/api/src/main/java/co/aikar/timings/TimingsExport.java @@ -111,7 +111,7 @@ class TimingsExport extends Thread { ); if (!TimingsManager.privacy) { appendObjectData(parent, - pair("server", Bukkit.getServerName()), + pair("server", Bukkit.getUnsafe().getTimingsServerName()), pair("motd", Bukkit.getServer().getMotd()), pair("online-mode", Bukkit.getServer().getOnlineMode()), pair("icon", Bukkit.getServer().getServerIcon().getData()) @@ -184,9 +184,9 @@ class TimingsExport extends Thread { pair("handlers", handlers), pair("worlds", toObjectMapper(TimingHistory.worldMap.entrySet(), input -> pair(input.getValue(), input.getKey()))), pair("tileentity", - toObjectMapper(tileEntityTypeSet, input -> pair(input.getId(), input.name()))), + toObjectMapper(tileEntityTypeSet, input -> pair(input.ordinal(), input.name()))), pair("entity", - toObjectMapper(entityTypeSet, input -> pair(input.getTypeId(), input.name()))) + toObjectMapper(entityTypeSet, input -> pair(input.ordinal(), input.name()))) )); // Information about loaded plugins @@ -288,8 +288,8 @@ class TimingsExport extends Thread { String hostName = "BrokenHost"; try { hostName = InetAddress.getLocalHost().getHostName(); - } catch(Exception ignored) {} - con.setRequestProperty("User-Agent", "Paper/" + Bukkit.getServerName() + "/" + hostName); + } catch (Exception ignored) {} + con.setRequestProperty("User-Agent", "Paper/" + Bukkit.getUnsafe().getTimingsServerName() + "/" + hostName); con.setRequestMethod("POST"); con.setInstanceFollowRedirects(false); diff --git a/api/src/main/java/com/destroystokyo/paper/HeightmapType.java b/api/src/main/java/com/destroystokyo/paper/HeightmapType.java new file mode 100644 index 000000000..4cd9b5ed0 --- /dev/null +++ b/api/src/main/java/com/destroystokyo/paper/HeightmapType.java @@ -0,0 +1,35 @@ +package com.destroystokyo.paper; + +import org.bukkit.World; + +/** + * Enumeration of different heightmap types maintained by the server. Generally using these maps is much faster + * than using an iterative search for a block in a given x, z coordinate. + */ +public enum HeightmapType { + + /** + * The highest block used for lighting in the world. Also the block returned by {@link World#getHighestBlockYAt(int, int)}} + */ + LIGHT_BLOCKING, + + /** + * References the highest block in the world. + */ + ANY, + + /** + * References the highest solid block in a world. + */ + SOLID, + + /** + * References the highest solid or liquid block in a world. + */ + SOLID_OR_LIQUID, + + /** + * References the highest solid or liquid block in a world, excluding leaves. + */ + SOLID_OR_LIQUID_NO_LEAVES; +} diff --git a/api/src/main/java/com/destroystokyo/paper/MaterialTags.java b/api/src/main/java/com/destroystokyo/paper/MaterialTags.java index 660191c24..ef1e2c191 100644 --- a/api/src/main/java/com/destroystokyo/paper/MaterialTags.java +++ b/api/src/main/java/com/destroystokyo/paper/MaterialTags.java @@ -100,14 +100,6 @@ public class MaterialTags { */ public static final MaterialSetTag DYES = new MaterialSetTag(keyFor("dyes")) .endsWith("_DYE") - .add(Material.BONE_MEAL, - Material.CACTUS_GREEN, - Material.COCOA_BEANS, - Material.DANDELION_YELLOW, - Material.INK_SAC, - Material.LAPIS_LAZULI, - Material.ROSE_RED - ) .ensureSize("DYES", 16); /** @@ -181,7 +173,7 @@ public class MaterialTags { */ public static final MaterialSetTag HORSE_ARMORS = new MaterialSetTag(keyFor("horse_armors")) .endsWith("_HORSE_ARMOR") - .ensureSize("HORSE_ARMORS", 3); + .ensureSize("HORSE_ARMORS", 4); /** * Covers the 6 variants of infested blocks. @@ -316,7 +308,7 @@ public class MaterialTags { */ public static final MaterialSetTag SPAWN_EGGS = new MaterialSetTag(keyFor("spawn_eggs")) .endsWith("_SPAWN_EGG") - .ensureSize("SPAWN_EGGS", 51); + .ensureSize("SPAWN_EGGS", 58); /** * Covers all 16 colors of stained glass. @@ -364,8 +356,8 @@ public class MaterialTags { .ensureSize("PURPUR", 4); public static final MaterialSetTag SIGNS = new MaterialSetTag(keyFor("signs")) - .add(Material.SIGN, Material.WALL_SIGN) - .ensureSize("SIGNS", 2); + .endsWith("_SIGN") + .ensureSize("SIGNS", 12); public static final MaterialSetTag TORCH = new MaterialSetTag(keyFor("torch")) .add(Material.TORCH, Material.WALL_TORCH) diff --git a/api/src/main/java/com/destroystokyo/paper/VersionHistoryManager.java b/api/src/main/java/com/destroystokyo/paper/VersionHistoryManager.java deleted file mode 100644 index 648b247ef..000000000 --- a/api/src/main/java/com/destroystokyo/paper/VersionHistoryManager.java +++ /dev/null @@ -1,144 +0,0 @@ -package com.destroystokyo.paper; - -import com.google.common.base.MoreObjects; -import com.google.gson.Gson; -import com.google.gson.JsonSyntaxException; -import java.io.BufferedReader; -import java.io.BufferedWriter; -import java.io.IOException; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.nio.file.StandardOpenOption; -import java.util.Objects; -import java.util.logging.Level; -import java.util.logging.Logger; -import org.bukkit.Bukkit; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -public enum VersionHistoryManager { - INSTANCE; - - private final Gson gson = new Gson(); - - private final Logger logger = Bukkit.getLogger(); - - private VersionData currentData = null; - - VersionHistoryManager() { - final Path path = Paths.get("version_history.json"); - - if (Files.exists(path)) { - // Basic file santiy checks - if (!Files.isRegularFile(path)) { - if (Files.isDirectory(path)) { - logger.severe(path + " is a directory, cannot be used for version history"); - } else { - logger.severe(path + " is not a regular file, cannot be used for version history"); - } - // We can't continue - return; - } - - try (final BufferedReader reader = Files.newBufferedReader(path, StandardCharsets.UTF_8)) { - currentData = gson.fromJson(reader, VersionData.class); - } catch (final IOException e) { - logger.log(Level.SEVERE, "Failed to read version history file '" + path + "'", e); - return; - } catch (final JsonSyntaxException e) { - logger.log(Level.SEVERE, "Invalid json syntax for file '" + path + "'", e); - return; - } - - final String version = Bukkit.getVersion(); - if (version == null) { - logger.severe("Failed to retrieve current version"); - return; - } - - if (!version.equals(currentData.getCurrentVersion())) { - // The version appears to have changed - currentData.setOldVersion(currentData.getCurrentVersion()); - currentData.setCurrentVersion(version); - writeFile(path); - } - } else { - // File doesn't exist, start fresh - currentData = new VersionData(); - // oldVersion is null - currentData.setCurrentVersion(Bukkit.getVersion()); - writeFile(path); - } - } - - private void writeFile(@NotNull final Path path) { - try (final BufferedWriter writer = Files.newBufferedWriter( - path, - StandardCharsets.UTF_8, - StandardOpenOption.WRITE, - StandardOpenOption.CREATE, - StandardOpenOption.TRUNCATE_EXISTING - )) { - gson.toJson(currentData, writer); - } catch (final IOException e) { - logger.log(Level.SEVERE, "Failed to write to version history file", e); - } - } - - @Nullable - public VersionData getVersionData() { - return currentData; - } - - public static class VersionData { - private String oldVersion; - - private String currentVersion; - - @Nullable - public String getOldVersion() { - return oldVersion; - } - - public void setOldVersion(@Nullable String oldVersion) { - this.oldVersion = oldVersion; - } - - @Nullable - public String getCurrentVersion() { - return currentVersion; - } - - public void setCurrentVersion(@Nullable String currentVersion) { - this.currentVersion = currentVersion; - } - - @Override - public String toString() { - return MoreObjects.toStringHelper(this) - .add("oldVersion", oldVersion) - .add("currentVersion", currentVersion) - .toString(); - } - - @Override - public boolean equals(@Nullable Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - final VersionData versionData = (VersionData) o; - return Objects.equals(oldVersion, versionData.oldVersion) && - Objects.equals(currentVersion, versionData.currentVersion); - } - - @Override - public int hashCode() { - return Objects.hash(oldVersion, currentVersion); - } - } -} diff --git a/api/src/main/java/com/destroystokyo/paper/block/BlockSoundGroup.java b/api/src/main/java/com/destroystokyo/paper/block/BlockSoundGroup.java new file mode 100644 index 000000000..8cf87d228 --- /dev/null +++ b/api/src/main/java/com/destroystokyo/paper/block/BlockSoundGroup.java @@ -0,0 +1,52 @@ +package com.destroystokyo.paper.block; + +import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.jetbrains.annotations.NotNull; + +/** + * Represents the sounds that a {@link Block} makes in certain situations + *

+ * The sound group includes break, step, place, hit, and fall sounds. + */ +public interface BlockSoundGroup { + /** + * Gets the sound that plays when breaking this block + * + * @return The break sound + */ + @NotNull + Sound getBreakSound(); + + /** + * Gets the sound that plays when stepping on this block + * + * @return The step sound + */ + @NotNull + Sound getStepSound(); + + /** + * Gets the sound that plays when placing this block + * + * @return The place sound + */ + @NotNull + Sound getPlaceSound(); + + /** + * Gets the sound that plays when hitting this block + * + * @return The hit sound + */ + @NotNull + Sound getHitSound(); + + /** + * Gets the sound that plays when this block falls + * + * @return The fall sound + */ + @NotNull + Sound getFallSound(); +} diff --git a/api/src/main/java/com/destroystokyo/paper/event/player/PlayerHandshakeEvent.java b/api/src/main/java/com/destroystokyo/paper/event/player/PlayerHandshakeEvent.java index 46d6f6ad6..f0bb4e31c 100644 --- a/api/src/main/java/com/destroystokyo/paper/event/player/PlayerHandshakeEvent.java +++ b/api/src/main/java/com/destroystokyo/paper/event/player/PlayerHandshakeEvent.java @@ -36,6 +36,7 @@ public class PlayerHandshakeEvent extends Event implements Cancellable { * @param cancelled if this event is enabled */ public PlayerHandshakeEvent(@NotNull String originalHandshake, boolean cancelled) { + super(true); this.originalHandshake = originalHandshake; this.cancelled = cancelled; } diff --git a/api/src/main/java/com/destroystokyo/paper/event/server/GS4QueryEvent.java b/api/src/main/java/com/destroystokyo/paper/event/server/GS4QueryEvent.java index 2ead0466e..77a19995f 100644 --- a/api/src/main/java/com/destroystokyo/paper/event/server/GS4QueryEvent.java +++ b/api/src/main/java/com/destroystokyo/paper/event/server/GS4QueryEvent.java @@ -27,6 +27,7 @@ public final class GS4QueryEvent extends Event { private QueryResponse response; public GS4QueryEvent(@NotNull QueryType queryType, @NotNull InetAddress querierAddress, @NotNull QueryResponse response) { + super(true); // should always be called async this.queryType = Preconditions.checkNotNull(queryType, "queryType"); this.querierAddress = Preconditions.checkNotNull(querierAddress, "querierAddress"); this.response = Preconditions.checkNotNull(response, "response"); diff --git a/api/src/main/java/com/destroystokyo/paper/event/server/ServerExceptionEvent.java b/api/src/main/java/com/destroystokyo/paper/event/server/ServerExceptionEvent.java index d3b00f741..2f573299a 100644 --- a/api/src/main/java/com/destroystokyo/paper/event/server/ServerExceptionEvent.java +++ b/api/src/main/java/com/destroystokyo/paper/event/server/ServerExceptionEvent.java @@ -2,6 +2,7 @@ package com.destroystokyo.paper.event.server; import com.google.common.base.Preconditions; import org.apache.commons.lang.Validate; +import org.bukkit.Bukkit; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; import com.destroystokyo.paper.exception.ServerException; @@ -15,6 +16,7 @@ public class ServerExceptionEvent extends Event { @NotNull private ServerException exception; public ServerExceptionEvent(@NotNull ServerException exception) { + super(!Bukkit.isPrimaryThread()); this.exception = Preconditions.checkNotNull(exception, "exception"); } diff --git a/api/src/main/java/com/destroystokyo/paper/util/VersionFetcher.java b/api/src/main/java/com/destroystokyo/paper/util/VersionFetcher.java new file mode 100644 index 000000000..2a2651299 --- /dev/null +++ b/api/src/main/java/com/destroystokyo/paper/util/VersionFetcher.java @@ -0,0 +1,44 @@ +package com.destroystokyo.paper.util; + +import org.bukkit.Bukkit; +import org.jetbrains.annotations.NotNull; + +public interface VersionFetcher { + /** + * Amount of time to cache results for in milliseconds + *

+ * Negative values will never cache. + * + * @return cache time + */ + long getCacheTime(); + + /** + * Gets the version message to cache and show to command senders. Multiple messages can be sent using newlines (\n) + * in the string. The string will be split on these newlines and sent as individual messages. + *

+ * NOTE: This is run in a new thread separate from that of the command processing thread + * + * @param serverVersion the current version of the server (will match {@link Bukkit#getVersion()}) + * @return the message to show when requesting a version + */ + @NotNull + String getVersionMessage(@NotNull String serverVersion); + + class DummyVersionFetcher implements VersionFetcher { + + @Override + public long getCacheTime() { + return -1; + } + + @NotNull + @Override + public String getVersionMessage(@NotNull String serverVersion) { + Bukkit.getLogger().warning("Version provider has not been set, cannot check for updates!"); + Bukkit.getLogger().info("Override the default implementation of org.bukkit.UnsafeValues#getVersionFetcher()"); + new Throwable().printStackTrace(); + return "Unable to check for updates. No version provider set."; + } + } +} diff --git a/api/src/main/java/io/akarin/server/api/event/PlayerAttachedEvent.java b/api/src/main/java/io/akarin/server/api/event/PlayerAttachedEvent.java deleted file mode 100644 index 47c19b026..000000000 --- a/api/src/main/java/io/akarin/server/api/event/PlayerAttachedEvent.java +++ /dev/null @@ -1,10 +0,0 @@ -package io.akarin.server.api.event; - -import org.bukkit.entity.Player; - -/** - * Represents event with a player attached - */ -public interface PlayerAttachedEvent { - public Player getPlayer(); -} diff --git a/api/src/main/java/io/akarin/server/api/event/WorldAttachedEvent.java b/api/src/main/java/io/akarin/server/api/event/WorldAttachedEvent.java deleted file mode 100644 index 15908bd69..000000000 --- a/api/src/main/java/io/akarin/server/api/event/WorldAttachedEvent.java +++ /dev/null @@ -1,11 +0,0 @@ -package io.akarin.server.api.event; - -import org.bukkit.World; -import org.bukkit.entity.Player; - -/** - * Represents event with a world attached - */ -public interface WorldAttachedEvent { - public World getWorld(); -} diff --git a/api/src/main/java/io/akarin/server/api/structure/Village.java b/api/src/main/java/io/akarin/server/api/structure/Village.java deleted file mode 100644 index 85383f950..000000000 --- a/api/src/main/java/io/akarin/server/api/structure/Village.java +++ /dev/null @@ -1,7 +0,0 @@ -package io.akarin.server.api.structure; - -/** - * Represents a village structure - */ -public interface Village { -} diff --git a/api/src/main/java/io/akarin/server/core/AkarinGlobalConfig.java b/api/src/main/java/io/akarin/server/core/AkarinGlobalConfig.java deleted file mode 100644 index b8c2f9760..000000000 --- a/api/src/main/java/io/akarin/server/core/AkarinGlobalConfig.java +++ /dev/null @@ -1,227 +0,0 @@ -package io.akarin.server.core; - -import com.google.common.base.Throwables; -import java.io.File; -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.lang.reflect.Modifier; -import java.util.List; -import java.util.concurrent.TimeUnit; -import java.util.logging.Level; -import java.util.logging.LogManager; -import java.util.logging.Logger; -import java.util.regex.Pattern; - -import org.bukkit.Bukkit; -import org.bukkit.configuration.InvalidConfigurationException; -import org.bukkit.configuration.file.YamlConfiguration; - -@SuppressWarnings({"UnusedIsStillUsed", "unused"}) -public class AkarinGlobalConfig { - private final static Logger LOGGER = Logger.getLogger("Akarin"); - - private static File CONFIG_FILE; - private static final String HEADER = "This is the global configuration file for Akarin.\n" - + "Some options may impact gameplay, so use with caution,\n" - + "and make sure you know what each option does before configuring.\n" - + "\n" - + "Akarin website: https://akarin.io/ \n"; - /*========================================================================*/ - public static YamlConfiguration config; - static int version; - /*========================================================================*/ - public static void init(File configFile) { - CONFIG_FILE = configFile; - config = new YamlConfiguration(); - try { - config.load(CONFIG_FILE); - } catch (IOException ex) { - } catch (InvalidConfigurationException ex) { - LOGGER.log(Level.SEVERE, "Could not load akarin.yml, please correct your syntax errors"); - ex.printStackTrace(); - throw Throwables.propagate(ex); - } - config.options().header(HEADER); - config.options().copyDefaults(true); - - version = getInt("config-version", 3); - set("config-version", 3); - readConfig(AkarinGlobalConfig.class, null); - } - - static void readConfig(Class clazz, Object instance) { - for (Method method : clazz.getDeclaredMethods()) { - if (Modifier.isPrivate(method.getModifiers())) { - if (method.getParameterTypes().length == 0 && method.getReturnType() == Void.TYPE) { - try { - method.setAccessible(true); - method.invoke(instance); - } catch (InvocationTargetException ex) { - throw Throwables.propagate(ex.getCause()); - } catch (Exception ex) { - LOGGER.log(Level.SEVERE, "Error invoking " + method); - ex.printStackTrace(); - } - } - } - } - - try { - config.save(CONFIG_FILE); - } catch (IOException ex) { - LOGGER.log(Level.SEVERE, "Could not save " + CONFIG_FILE); - ex.printStackTrace(); - } - } - - private static final Pattern SPACE = Pattern.compile(" "); - private static final Pattern NOT_NUMERIC = Pattern.compile("[^-\\d.]"); - public static int getSeconds(String str) { - str = SPACE.matcher(str).replaceAll(""); - final char unit = str.charAt(str.length() - 1); - str = NOT_NUMERIC.matcher(str).replaceAll(""); - double num; - try { - num = Double.parseDouble(str); - } catch (Exception e) { - num = 0D; - } - switch (unit) { - case 'd': num *= (double) 60*60*24; break; - case 'h': num *= (double) 60*60; break; - case 'm': num *= 60; break; - default: case 's': break; - } - return (int) num; - } - - protected static String timeSummary(int seconds) { - String time = ""; - - if (seconds > 60 * 60 * 24) { - time += TimeUnit.SECONDS.toDays(seconds) + "d"; - seconds %= 60 * 60 * 24; - } - - if (seconds > 60 * 60) { - time += TimeUnit.SECONDS.toHours(seconds) + "h"; - seconds %= 60 * 60; - } - - if (seconds > 0) { - time += TimeUnit.SECONDS.toMinutes(seconds) + "m"; - } - return time; - } - - public static void set(String path, Object val) { - config.set(path, val); - } - - private static boolean getBoolean(String path, boolean def) { - config.addDefault(path, def); - return config.getBoolean(path, config.getBoolean(path)); - } - - private static double getDouble(String path, double def) { - config.addDefault(path, def); - return config.getDouble(path, config.getDouble(path)); - } - - private static float getFloat(String path, float def) { - // TODO: Figure out why getFloat() always returns the default value. - return (float) getDouble(path, def); - } - - private static int getInt(String path, int def) { - config.addDefault(path, def); - return config.getInt(path, config.getInt(path)); - } - - private static List getList(String path, T def) { - config.addDefault(path, def); - return config.getList(path, config.getList(path)); - } - - private static String getString(String path, String def) { - config.addDefault(path, def); - return config.getString(path, config.getString(path)); - } - /*========================================================================*/ - public static boolean noResponseDoGC = true; - private static void noResponseDoGC() { - noResponseDoGC = getBoolean("alternative.gc-before-stuck-restart", noResponseDoGC); - } - - public static String serverBrandName = ""; - private static void serverBrandName() { - serverBrandName = getString("alternative.modified-server-brand-name", serverBrandName); - } - - public static int fileIOThreads = 2; - private static void fileIOThreads() { - fileIOThreads = getInt("core.chunk-save-threads", fileIOThreads); - fileIOThreads = fileIOThreads < 1 ? 1 : fileIOThreads; - fileIOThreads = fileIOThreads > 8 ? 8 : fileIOThreads; - } - - public static boolean fixPhysicsEventBehaviour = false; - private static void fixPhysicsEventBehavior() { - fixPhysicsEventBehaviour = getBoolean("alternative.fix-physics-event-behaviour", fixPhysicsEventBehaviour); - } - - public static boolean lazyThreadAssertion = true; - private static void lazyThreadAssertion() { - lazyThreadAssertion = getBoolean("core.lazy-thread-assertion", lazyThreadAssertion); - } - - public static double blockbreakAnimationVisibleDistance = 1024; - private static void blockbreakAnimationVisibleDistance() { - double def = 32.00; - if (version == 2) - def = getDouble("alternative.block-break-animation-visible-distance", def); - - blockbreakAnimationVisibleDistance = Math.sqrt(getDouble("core.block-break-animation-visible-distance", def)); - } - - public static boolean enableAsyncLighting = true; - private static void enableAsyncLighting() { - enableAsyncLighting = getBoolean("core.async-lighting.enable", enableAsyncLighting); - } - - public static String yggdrasilServerURL = "https://api.mojang.com/"; - private static void yggdrasilServerURL() { - yggdrasilServerURL = getString("alternative.yggdrasil.url", yggdrasilServerURL); - } - - public static boolean disallowBeforeLogin = false; - private static void disallowBeforeLogin() { - disallowBeforeLogin = getBoolean("alternative.disallow-before-login-event", disallowBeforeLogin); - } - - public static boolean allowExcessiveSigns = false; - private static void allowExcessiveSigns() { - allowExcessiveSigns = getBoolean("alternative.allow-excessive-signs", allowExcessiveSigns); - } - - public static boolean ignoreRayTraceForSeatableBlocks = false; - private static void ignoreRayTraceForSeatableBlocks() { - ignoreRayTraceForSeatableBlocks = getBoolean("alternative.ignore-ray-trace-for-seatable-blocks", ignoreRayTraceForSeatableBlocks); - } - - public static boolean improvedMobSpawnMechanics = false; - private static void improvedMobSpawnMechanics() { - improvedMobSpawnMechanics = getBoolean("core.improved-mob-spawn-mechanics.enable", improvedMobSpawnMechanics); - } - - public static int userCacheExpireDays = 30; - private static void enableModernUserCaches() { - userCacheExpireDays = getSeconds(getString("core.user-cache-expire-time", "30d")); - } - - public static boolean spinningAwaitTicking = true; - private static void spinningAwaitTicking() { - spinningAwaitTicking = getBoolean("core.spinning-tick-await", spinningAwaitTicking); - } -} \ No newline at end of file diff --git a/api/src/main/java/org/bukkit/Achievement.java b/api/src/main/java/org/bukkit/Achievement.java index edc388ffe..0080e0fea 100644 --- a/api/src/main/java/org/bukkit/Achievement.java +++ b/api/src/main/java/org/bukkit/Achievement.java @@ -56,7 +56,7 @@ public enum Achievement { /** * Returns whether or not this achievement has a parent achievement. - * + * * @return whether the achievement has a parent achievement */ public boolean hasParent() { @@ -65,7 +65,7 @@ public enum Achievement { /** * Returns the parent achievement of this achievement, or null if none. - * + * * @return the parent achievement or null */ @Nullable diff --git a/api/src/main/java/org/bukkit/Art.java b/api/src/main/java/org/bukkit/Art.java index cfbcaf72d..e7563acf4 100644 --- a/api/src/main/java/org/bukkit/Art.java +++ b/api/src/main/java/org/bukkit/Art.java @@ -1,17 +1,15 @@ package org.bukkit; -import java.util.HashMap; - -import org.apache.commons.lang.Validate; - import com.google.common.collect.Maps; +import java.util.HashMap; +import org.apache.commons.lang.Validate; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; /** * Represents the art on a painting */ -public enum Art { +public enum Art implements Keyed { KEBAB(0, 1, 1), AZTEC(1, 1, 1), ALBAN(2, 1, 1), @@ -39,7 +37,8 @@ public enum Art { SKELETON(24, 4, 3), DONKEY_KONG(25, 4, 3); - private int id, width, height; + private final int id, width, height; + private final NamespacedKey key; private static final HashMap BY_NAME = Maps.newHashMap(); private static final HashMap BY_ID = Maps.newHashMap(); @@ -47,6 +46,7 @@ public enum Art { this.id = id; this.width = width; this.height = height; + this.key = NamespacedKey.minecraft(name().toLowerCase(java.util.Locale.ENGLISH)); } /** @@ -78,6 +78,12 @@ public enum Art { return id; } + @NotNull + @Override + public NamespacedKey getKey() { + return key; + } + /** * Get a painting by its numeric ID * diff --git a/api/src/main/java/org/bukkit/BanEntry.java b/api/src/main/java/org/bukkit/BanEntry.java index 30c8b0a0c..2cf11ca4f 100644 --- a/api/src/main/java/org/bukkit/BanEntry.java +++ b/api/src/main/java/org/bukkit/BanEntry.java @@ -1,10 +1,9 @@ package org.bukkit; +import java.util.Date; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.Date; - /** * A single entry from a ban list. This may represent either a player ban or * an IP ban. diff --git a/api/src/main/java/org/bukkit/BanList.java b/api/src/main/java/org/bukkit/BanList.java index f506b644a..96ef22fe8 100644 --- a/api/src/main/java/org/bukkit/BanList.java +++ b/api/src/main/java/org/bukkit/BanList.java @@ -1,10 +1,9 @@ package org.bukkit; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - import java.util.Date; import java.util.Set; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * A ban list, containing bans of some {@link Type}. diff --git a/api/src/main/java/org/bukkit/Bukkit.java b/api/src/main/java/org/bukkit/Bukkit.java index 5ed9726c8..231bc6e31 100644 --- a/api/src/main/java/org/bukkit/Bukkit.java +++ b/api/src/main/java/org/bukkit/Bukkit.java @@ -1,5 +1,6 @@ package org.bukkit; +import com.google.common.collect.ImmutableList; import java.awt.image.BufferedImage; import java.io.File; import java.io.Serializable; @@ -12,8 +13,8 @@ import java.util.Set; import java.util.UUID; import java.util.function.Consumer; import java.util.logging.Logger; - import org.bukkit.Warning.WarningState; +import org.bukkit.advancement.Advancement; import org.bukkit.block.data.BlockData; import org.bukkit.boss.BarColor; import org.bukkit.boss.BarFlag; @@ -28,12 +29,15 @@ import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.event.inventory.InventoryType; import org.bukkit.event.server.ServerListPingEvent; +import org.bukkit.generator.ChunkGenerator; import org.bukkit.help.HelpMap; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.InventoryHolder; +import org.bukkit.inventory.ItemFactory; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.Merchant; import org.bukkit.inventory.Recipe; +import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.loot.LootTable; import org.bukkit.map.MapView; import org.bukkit.permissions.Permissible; @@ -43,13 +47,6 @@ import org.bukkit.plugin.messaging.Messenger; import org.bukkit.scheduler.BukkitScheduler; import org.bukkit.scoreboard.ScoreboardManager; import org.bukkit.util.CachedServerIcon; - -import com.google.common.collect.ImmutableList; -import org.bukkit.advancement.Advancement; -import org.bukkit.generator.ChunkGenerator; - -import org.bukkit.inventory.ItemFactory; -import org.bukkit.inventory.meta.ItemMeta; import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -192,31 +189,6 @@ public final class Bukkit { return server.getIp(); } - /** - * Get the name of this server. - * - * @return the name of this server - * @deprecated not a standard server property - */ - @Deprecated - @NotNull - public static String getServerName() { - return server.getServerName(); - } - - /** - * Get an ID of this server. The ID is a simple generally alphanumeric ID - * that can be used for uniquely identifying this server. - * - * @return the ID of this server - * @deprecated not a standard server property - */ - @Deprecated - @NotNull - public static String getServerId() { - return server.getServerId(); - } - /** * Get world type (level-type setting) for default world. * @@ -981,11 +953,9 @@ public final class Bukkit { } /** - * Creates an empty inventory with the specified type and title. If the type + * Creates an empty inventory with the specified type. If the type * is {@link InventoryType#CHEST}, the new inventory has a size of 27; - * otherwise the new inventory has the normal size for its type.
- * It should be noted that some inventory types do not support titles and - * may not render with said titles on the Minecraft client. + * otherwise the new inventory has the normal size for its type. *
* {@link InventoryType#WORKBENCH} will not process crafting recipes if * created with this method. Use @@ -1260,12 +1230,12 @@ public final class Bukkit { /** * Create a ChunkData for use in a generator. - * + * * See {@link ChunkGenerator#generateChunkData(org.bukkit.World, java.util.Random, int, int, org.bukkit.generator.ChunkGenerator.BiomeGrid)} - * + * * @param world the world to create the ChunkData for * @return a new ChunkData for the world - * + * */ @NotNull public static ChunkGenerator.ChunkData createChunkData(@NotNull World world) { @@ -1533,9 +1503,7 @@ public final class Bukkit { * no further guarantees are made. * @throws IllegalArgumentException if the selector is malformed in any way * or a parameter is null - * @deprecated draft API */ - @Deprecated @NotNull public static List selectEntities(@NotNull CommandSender sender, @NotNull String selector) throws IllegalArgumentException { return server.selectEntities(sender, selector); @@ -1631,6 +1599,10 @@ public final class Bukkit { public static com.destroystokyo.paper.profile.PlayerProfile createProfile(@Nullable UUID uuid, @Nullable String name) { return server.createProfile(uuid, name); } + + public static int getCurrentTick() { + return server.getCurrentTick(); + } // Paper end @NotNull diff --git a/api/src/main/java/org/bukkit/ChatColor.java b/api/src/main/java/org/bukkit/ChatColor.java index 3ab8e9414..b2c82940c 100644 --- a/api/src/main/java/org/bukkit/ChatColor.java +++ b/api/src/main/java/org/bukkit/ChatColor.java @@ -1,11 +1,9 @@ package org.bukkit; +import com.google.common.collect.Maps; import java.util.Map; import java.util.regex.Pattern; - import org.apache.commons.lang.Validate; - -import com.google.common.collect.Maps; import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -13,7 +11,7 @@ import org.jetbrains.annotations.Nullable; /** * All supported color values for chat */ -public enum ChatColor{ +public enum ChatColor { /** * Represents black */ @@ -27,7 +25,7 @@ public enum ChatColor{ /** * Represents dark blue */ - DARK_BLUE('1', 0x1){ + DARK_BLUE('1', 0x1) { @NotNull @Override public net.md_5.bungee.api.ChatColor asBungee() { @@ -37,7 +35,7 @@ public enum ChatColor{ /** * Represents dark green */ - DARK_GREEN('2', 0x2){ + DARK_GREEN('2', 0x2) { @NotNull @Override public net.md_5.bungee.api.ChatColor asBungee() { @@ -47,7 +45,7 @@ public enum ChatColor{ /** * Represents dark blue (aqua) */ - DARK_AQUA('3', 0x3){ + DARK_AQUA('3', 0x3) { @NotNull @Override public net.md_5.bungee.api.ChatColor asBungee() { @@ -57,7 +55,7 @@ public enum ChatColor{ /** * Represents dark red */ - DARK_RED('4', 0x4){ + DARK_RED('4', 0x4) { @NotNull @Override public net.md_5.bungee.api.ChatColor asBungee() { @@ -67,7 +65,7 @@ public enum ChatColor{ /** * Represents dark purple */ - DARK_PURPLE('5', 0x5){ + DARK_PURPLE('5', 0x5) { @NotNull @Override public net.md_5.bungee.api.ChatColor asBungee() { @@ -77,7 +75,7 @@ public enum ChatColor{ /** * Represents gold */ - GOLD('6', 0x6){ + GOLD('6', 0x6) { @NotNull @Override public net.md_5.bungee.api.ChatColor asBungee() { @@ -87,7 +85,7 @@ public enum ChatColor{ /** * Represents gray */ - GRAY('7', 0x7){ + GRAY('7', 0x7) { @NotNull @Override public net.md_5.bungee.api.ChatColor asBungee() { @@ -97,7 +95,7 @@ public enum ChatColor{ /** * Represents dark gray */ - DARK_GRAY('8', 0x8){ + DARK_GRAY('8', 0x8) { @NotNull @Override public net.md_5.bungee.api.ChatColor asBungee() { @@ -107,7 +105,7 @@ public enum ChatColor{ /** * Represents blue */ - BLUE('9', 0x9){ + BLUE('9', 0x9) { @NotNull @Override public net.md_5.bungee.api.ChatColor asBungee() { @@ -117,7 +115,7 @@ public enum ChatColor{ /** * Represents green */ - GREEN('a', 0xA){ + GREEN('a', 0xA) { @NotNull @Override public net.md_5.bungee.api.ChatColor asBungee() { @@ -127,7 +125,7 @@ public enum ChatColor{ /** * Represents aqua */ - AQUA('b', 0xB){ + AQUA('b', 0xB) { @NotNull @Override public net.md_5.bungee.api.ChatColor asBungee() { @@ -137,7 +135,7 @@ public enum ChatColor{ /** * Represents red */ - RED('c', 0xC){ + RED('c', 0xC) { @NotNull @Override public net.md_5.bungee.api.ChatColor asBungee() { @@ -147,7 +145,7 @@ public enum ChatColor{ /** * Represents light purple */ - LIGHT_PURPLE('d', 0xD){ + LIGHT_PURPLE('d', 0xD) { @NotNull @Override public net.md_5.bungee.api.ChatColor asBungee() { @@ -157,7 +155,7 @@ public enum ChatColor{ /** * Represents yellow */ - YELLOW('e', 0xE){ + YELLOW('e', 0xE) { @NotNull @Override public net.md_5.bungee.api.ChatColor asBungee() { @@ -167,7 +165,7 @@ public enum ChatColor{ /** * Represents white */ - WHITE('f', 0xF){ + WHITE('f', 0xF) { @NotNull @Override public net.md_5.bungee.api.ChatColor asBungee() { @@ -177,7 +175,7 @@ public enum ChatColor{ /** * Represents magical characters that change around randomly */ - MAGIC('k', 0x10, true){ + MAGIC('k', 0x10, true) { @NotNull @Override public net.md_5.bungee.api.ChatColor asBungee() { @@ -187,7 +185,7 @@ public enum ChatColor{ /** * Makes the text bold. */ - BOLD('l', 0x11, true){ + BOLD('l', 0x11, true) { @NotNull @Override public net.md_5.bungee.api.ChatColor asBungee() { @@ -197,7 +195,7 @@ public enum ChatColor{ /** * Makes a line appear through the text. */ - STRIKETHROUGH('m', 0x12, true){ + STRIKETHROUGH('m', 0x12, true) { @NotNull @Override public net.md_5.bungee.api.ChatColor asBungee() { @@ -207,7 +205,7 @@ public enum ChatColor{ /** * Makes the text appear underlined. */ - UNDERLINE('n', 0x13, true){ + UNDERLINE('n', 0x13, true) { @NotNull @Override public net.md_5.bungee.api.ChatColor asBungee() { @@ -217,7 +215,7 @@ public enum ChatColor{ /** * Makes the text italic. */ - ITALIC('o', 0x14, true){ + ITALIC('o', 0x14, true) { @NotNull @Override public net.md_5.bungee.api.ChatColor asBungee() { @@ -227,7 +225,7 @@ public enum ChatColor{ /** * Resets all previous chat colors or formats. */ - RESET('r', 0x15){ + RESET('r', 0x15) { @NotNull @Override public net.md_5.bungee.api.ChatColor asBungee() { @@ -246,8 +244,8 @@ public enum ChatColor{ private final char code; private final boolean isFormat; private final String toString; - private final static Map BY_ID = Maps.newHashMap(); - private final static Map BY_CHAR = Maps.newHashMap(); + private static final Map BY_ID = Maps.newHashMap(); + private static final Map BY_CHAR = Maps.newHashMap(); private ChatColor(char code, int intCode) { this(code, intCode, false); @@ -282,7 +280,7 @@ public enum ChatColor{ /** * Checks if this code is a format code as opposed to a color code. - * + * * @return whether this ChatColor is a format code */ public boolean isFormat() { @@ -291,7 +289,7 @@ public enum ChatColor{ /** * Checks if this code is a color code as opposed to a format code. - * + * * @return whether this ChatColor is a color code */ public boolean isColor() { @@ -353,6 +351,8 @@ public enum ChatColor{ */ @NotNull public static String translateAlternateColorCodes(char altColorChar, @NotNull String textToTranslate) { + Validate.notNull(textToTranslate, "Cannot translate null text"); + char[] b = textToTranslate.toCharArray(); for (int i = 0; i < b.length - 1; i++) { if (b[i] == altColorChar && "0123456789AaBbCcDdEeFfKkLlMmNnOoRr".indexOf(b[i+1]) > -1) { @@ -371,6 +371,8 @@ public enum ChatColor{ */ @NotNull public static String getLastColors(@NotNull String input) { + Validate.notNull(input, "Cannot get last colors from null text"); + String result = ""; int length = input.length(); diff --git a/api/src/main/java/org/bukkit/Chunk.java b/api/src/main/java/org/bukkit/Chunk.java index 22ff63e52..7909caef7 100644 --- a/api/src/main/java/org/bukkit/Chunk.java +++ b/api/src/main/java/org/bukkit/Chunk.java @@ -1,8 +1,11 @@ package org.bukkit; +import java.util.Collection; import org.bukkit.block.Block; import org.bukkit.block.BlockState; +import org.bukkit.block.data.BlockData; import org.bukkit.entity.Entity; +import org.bukkit.plugin.Plugin; import org.jetbrains.annotations.NotNull; /** @@ -143,18 +146,6 @@ public interface Chunk { */ boolean load(); - /** - * Unloads and optionally saves the Chunk - * - * @param save Controls whether the chunk is saved - * @param safe Controls whether to unload the chunk when players are - * nearby - * @return true if the chunk has unloaded successfully, otherwise false - * @deprecated it is never safe to remove a chunk in use - */ - @Deprecated - boolean unload(boolean save, boolean safe); - /** * Unloads and optionally saves the Chunk * @@ -194,8 +185,81 @@ public interface Chunk { *

* A force loaded chunk will not be unloaded due to lack of player activity. * - * @param forced + * @param forced force load status * @see World#setChunkForceLoaded(int, int, boolean) */ void setForceLoaded(boolean forced); + + /** + * Adds a plugin ticket for this chunk, loading this chunk if it is not + * already loaded. + *

+ * A plugin ticket will prevent a chunk from unloading until it is + * explicitly removed. A plugin instance may only have one ticket per chunk, + * but each chunk can have multiple plugin tickets. + *

+ * + * @param plugin Plugin which owns the ticket + * @return {@code true} if a plugin ticket was added, {@code false} if the + * ticket already exists for the plugin + * @throws IllegalStateException If the specified plugin is not enabled + * @see World#addPluginChunkTicket(int, int, Plugin) + */ + boolean addPluginChunkTicket(@NotNull Plugin plugin); + + /** + * Removes the specified plugin's ticket for this chunk + *

+ * A plugin ticket will prevent a chunk from unloading until it is + * explicitly removed. A plugin instance may only have one ticket per chunk, + * but each chunk can have multiple plugin tickets. + *

+ * + * @param plugin Plugin which owns the ticket + * @return {@code true} if the plugin ticket was removed, {@code false} if + * there is no plugin ticket for the chunk + * @see World#removePluginChunkTicket(int, int, Plugin) + */ + boolean removePluginChunkTicket(@NotNull Plugin plugin); + + /** + * Retrieves a collection specifying which plugins have tickets for this + * chunk. This collection is not updated when plugin tickets are added or + * removed to this chunk. + *

+ * A plugin ticket will prevent a chunk from unloading until it is + * explicitly removed. A plugin instance may only have one ticket per chunk, + * but each chunk can have multiple plugin tickets. + *

+ * + * @return unmodifiable collection containing which plugins have tickets for + * this chunk + * @see World#getPluginChunkTickets(int, int) + */ + @NotNull + Collection getPluginChunkTickets(); + + /** + * Gets the amount of time in ticks that this chunk has been inhabited. + * + * Note that the time is incremented once per tick per player in the chunk. + * + * @return inhabited time + */ + long getInhabitedTime(); + + /** + * Sets the amount of time in ticks that this chunk has been inhabited. + * + * @param ticks new inhabited time + */ + void setInhabitedTime(long ticks); + + /** + * Tests if this chunk contains the specified block. + * + * @param block block to test + * @return if the block is contained within + */ + boolean contains(@NotNull BlockData block); } diff --git a/api/src/main/java/org/bukkit/ChunkSnapshot.java b/api/src/main/java/org/bukkit/ChunkSnapshot.java index 153d72b0e..dc5e6918d 100644 --- a/api/src/main/java/org/bukkit/ChunkSnapshot.java +++ b/api/src/main/java/org/bukkit/ChunkSnapshot.java @@ -131,4 +131,12 @@ public interface ChunkSnapshot { * @return true if empty, false if not */ boolean isSectionEmpty(int sy); + + /** + * Tests if this snapshot contains the specified block. + * + * @param block block to test + * @return if the block is contained within + */ + boolean contains(@NotNull BlockData block); } diff --git a/api/src/main/java/org/bukkit/CoalType.java b/api/src/main/java/org/bukkit/CoalType.java index 9e59a7ba1..c07499dbd 100644 --- a/api/src/main/java/org/bukkit/CoalType.java +++ b/api/src/main/java/org/bukkit/CoalType.java @@ -1,8 +1,7 @@ package org.bukkit; -import java.util.Map; - import com.google.common.collect.Maps; +import java.util.Map; import org.jetbrains.annotations.Nullable; /** @@ -13,7 +12,7 @@ public enum CoalType { CHARCOAL(0x1); private final byte data; - private final static Map BY_DATA = Maps.newHashMap(); + private static final Map BY_DATA = Maps.newHashMap(); private CoalType(final int data) { this.data = (byte) data; diff --git a/api/src/main/java/org/bukkit/Color.java b/api/src/main/java/org/bukkit/Color.java index fbad45905..78be0f3b9 100644 --- a/api/src/main/java/org/bukkit/Color.java +++ b/api/src/main/java/org/bukkit/Color.java @@ -1,12 +1,10 @@ package org.bukkit; +import com.google.common.collect.ImmutableMap; import java.util.Map; - import org.apache.commons.lang.Validate; import org.bukkit.configuration.serialization.ConfigurationSerializable; import org.bukkit.configuration.serialization.SerializableAs; - -import com.google.common.collect.ImmutableMap; import org.jetbrains.annotations.NotNull; /** @@ -319,6 +317,7 @@ public final class Color implements ConfigurationSerializable { return asRGB() ^ Color.class.hashCode(); } + @Override @NotNull public Map serialize() { return ImmutableMap.of( diff --git a/api/src/main/java/org/bukkit/CropState.java b/api/src/main/java/org/bukkit/CropState.java index 9a3990dff..fb4832fb7 100644 --- a/api/src/main/java/org/bukkit/CropState.java +++ b/api/src/main/java/org/bukkit/CropState.java @@ -1,8 +1,7 @@ package org.bukkit; -import java.util.Map; - import com.google.common.collect.Maps; +import java.util.Map; import org.jetbrains.annotations.Nullable; /** @@ -44,7 +43,7 @@ public enum CropState { RIPE(0x7); private final byte data; - private final static Map BY_DATA = Maps.newHashMap(); + private static final Map BY_DATA = Maps.newHashMap(); private CropState(final int data) { this.data = (byte) data; diff --git a/api/src/main/java/org/bukkit/Difficulty.java b/api/src/main/java/org/bukkit/Difficulty.java index 19367a700..3f6cbefc2 100644 --- a/api/src/main/java/org/bukkit/Difficulty.java +++ b/api/src/main/java/org/bukkit/Difficulty.java @@ -1,8 +1,7 @@ package org.bukkit; -import java.util.Map; - import com.google.common.collect.Maps; +import java.util.Map; import org.jetbrains.annotations.Nullable; /** @@ -35,7 +34,7 @@ public enum Difficulty { HARD(3); private final int value; - private final static Map BY_ID = Maps.newHashMap(); + private static final Map BY_ID = Maps.newHashMap(); private Difficulty(final int value) { this.value = value; diff --git a/api/src/main/java/org/bukkit/DyeColor.java b/api/src/main/java/org/bukkit/DyeColor.java index ac75be657..bd213cabd 100644 --- a/api/src/main/java/org/bukkit/DyeColor.java +++ b/api/src/main/java/org/bukkit/DyeColor.java @@ -1,8 +1,7 @@ package org.bukkit; -import java.util.Map; - import com.google.common.collect.ImmutableMap; +import java.util.Map; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -80,10 +79,10 @@ public enum DyeColor { private final byte dyeData; private final Color color; private final Color firework; - private final static DyeColor[] BY_WOOL_DATA; - private final static DyeColor[] BY_DYE_DATA; - private final static Map BY_COLOR; - private final static Map BY_FIREWORK; + private static final DyeColor[] BY_WOOL_DATA; + private static final DyeColor[] BY_DYE_DATA; + private static final Map BY_COLOR; + private static final Map BY_FIREWORK; private DyeColor(final int woolData, final int dyeData, /*@NotNull*/ Color color, /*@NotNull*/ Color firework) { this.woolData = (byte) woolData; diff --git a/api/src/main/java/org/bukkit/Effect.java b/api/src/main/java/org/bukkit/Effect.java index e476de658..87911e08b 100644 --- a/api/src/main/java/org/bukkit/Effect.java +++ b/api/src/main/java/org/bukkit/Effect.java @@ -1,9 +1,7 @@ package org.bukkit; -import java.util.Map; - import com.google.common.collect.Maps; - +import java.util.Map; import org.bukkit.block.BlockFace; import org.bukkit.potion.Potion; import org.jetbrains.annotations.NotNull; diff --git a/api/src/main/java/org/bukkit/EntityEffect.java b/api/src/main/java/org/bukkit/EntityEffect.java index b7576f681..4cec72688 100644 --- a/api/src/main/java/org/bukkit/EntityEffect.java +++ b/api/src/main/java/org/bukkit/EntityEffect.java @@ -1,8 +1,7 @@ package org.bukkit; -import java.util.Map; - import com.google.common.collect.Maps; +import java.util.Map; import org.bukkit.entity.Ageable; import org.bukkit.entity.ArmorStand; import org.bukkit.entity.Entity; @@ -153,7 +152,7 @@ public enum EntityEffect { private final byte data; private final Class applicable; - private final static Map BY_DATA = Maps.newHashMap(); + private static final Map BY_DATA = Maps.newHashMap(); EntityEffect(final int data, /*@NotNull*/ Class clazz) { this.data = (byte) data; diff --git a/api/src/main/java/org/bukkit/FireworkEffect.java b/api/src/main/java/org/bukkit/FireworkEffect.java index 524dc9989..31e14b0ce 100644 --- a/api/src/main/java/org/bukkit/FireworkEffect.java +++ b/api/src/main/java/org/bukkit/FireworkEffect.java @@ -1,14 +1,12 @@ package org.bukkit; -import java.util.List; -import java.util.Map; - -import org.apache.commons.lang.Validate; -import org.bukkit.configuration.serialization.ConfigurationSerializable; -import org.bukkit.configuration.serialization.SerializableAs; - import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; +import java.util.List; +import java.util.Map; +import org.apache.commons.lang.Validate; +import org.bukkit.configuration.serialization.ConfigurationSerializable; +import org.bukkit.configuration.serialization.SerializableAs; import org.jetbrains.annotations.NotNull; /** diff --git a/api/src/main/java/org/bukkit/GameMode.java b/api/src/main/java/org/bukkit/GameMode.java index 4cfc7762e..938c3217f 100644 --- a/api/src/main/java/org/bukkit/GameMode.java +++ b/api/src/main/java/org/bukkit/GameMode.java @@ -1,10 +1,8 @@ package org.bukkit; -import java.util.Map; - -import org.bukkit.entity.HumanEntity; - import com.google.common.collect.Maps; +import java.util.Map; +import org.bukkit.entity.HumanEntity; import org.jetbrains.annotations.Nullable; /** @@ -29,14 +27,14 @@ public enum GameMode { ADVENTURE(2), /** - * Spectator mode cannot interact with the world in anyway and is - * invisible to normal players. This grants the player the + * Spectator mode cannot interact with the world in anyway and is + * invisible to normal players. This grants the player the * ability to no-clip through the world. */ SPECTATOR(3); private final int value; - private final static Map BY_ID = Maps.newHashMap(); + private static final Map BY_ID = Maps.newHashMap(); private GameMode(final int value) { this.value = value; diff --git a/api/src/main/java/org/bukkit/GameRule.java b/api/src/main/java/org/bukkit/GameRule.java index da49c26c5..ee7ae56f9 100644 --- a/api/src/main/java/org/bukkit/GameRule.java +++ b/api/src/main/java/org/bukkit/GameRule.java @@ -1,11 +1,10 @@ package org.bukkit; import com.google.common.base.Preconditions; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - import java.util.HashMap; import java.util.Map; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * GameRules dictate certain behavior within Minecraft itself @@ -117,6 +116,11 @@ public final class GameRule { */ public static final GameRule SPECTATORS_GENERATE_CHUNKS = new GameRule<>("spectatorsGenerateChunks", Boolean.class); + /** + * Whether pillager raids are enabled or not. + */ + public static final GameRule DISABLE_RAIDS = new GameRule<>("disableRaids", Boolean.class); + // Numerical rules /** * How often a random block tick occurs (such as plant growth, leaf decay, diff --git a/api/src/main/java/org/bukkit/GrassSpecies.java b/api/src/main/java/org/bukkit/GrassSpecies.java index 5943eddd3..f9c9ae463 100644 --- a/api/src/main/java/org/bukkit/GrassSpecies.java +++ b/api/src/main/java/org/bukkit/GrassSpecies.java @@ -1,8 +1,7 @@ package org.bukkit; -import java.util.Map; - import com.google.common.collect.Maps; +import java.util.Map; import org.jetbrains.annotations.Nullable; /** @@ -24,7 +23,7 @@ public enum GrassSpecies { FERN_LIKE(0x2); private final byte data; - private final static Map BY_DATA = Maps.newHashMap(); + private static final Map BY_DATA = Maps.newHashMap(); private GrassSpecies(final int data) { this.data = (byte) data; diff --git a/api/src/main/java/org/bukkit/Instrument.java b/api/src/main/java/org/bukkit/Instrument.java index f21497fff..92194803b 100644 --- a/api/src/main/java/org/bukkit/Instrument.java +++ b/api/src/main/java/org/bukkit/Instrument.java @@ -1,8 +1,7 @@ package org.bukkit; -import java.util.Map; - import com.google.common.collect.Maps; +import java.util.Map; import org.jetbrains.annotations.Nullable; public enum Instrument { @@ -51,10 +50,34 @@ public enum Instrument { /** * Xylophone is normally played when a note block is on top of a bone block. */ - XYLOPHONE(0x9); + XYLOPHONE(0x9), + /** + * Iron Xylophone is normally played when a note block is on top of a iron block. + */ + IRON_XYLOPHONE(0xA), + /** + * Cow Bell is normally played when a note block is on top of a soul sand block. + */ + COW_BELL(0xB), + /** + * Didgeridoo is normally played when a note block is on top of a pumpkin block. + */ + DIDGERIDOO(0xC), + /** + * Bit is normally played when a note block is on top of a emerald block. + */ + BIT(0xD), + /** + * Banjo is normally played when a note block is on top of a hay block. + */ + BANJO(0xE), + /** + * Pling is normally played when a note block is on top of a glowstone block. + */ + PLING(0xF); private final byte type; - private final static Map BY_DATA = Maps.newHashMap(); + private static final Map BY_DATA = Maps.newHashMap(); private Instrument(final int type) { this.type = (byte) type; diff --git a/api/src/main/java/org/bukkit/Location.java b/api/src/main/java/org/bukkit/Location.java index 8352b77c5..3e1ca4c9f 100644 --- a/api/src/main/java/org/bukkit/Location.java +++ b/api/src/main/java/org/bukkit/Location.java @@ -1,9 +1,11 @@ package org.bukkit; +import com.google.common.base.Preconditions; +import java.lang.ref.Reference; +import java.lang.ref.WeakReference; import com.google.common.base.Preconditions; // Paper import java.util.HashMap; import java.util.Map; - import org.bukkit.block.Block; import org.bukkit.configuration.serialization.ConfigurationSerializable; import org.bukkit.entity.Entity; // Paper @@ -29,7 +31,7 @@ import org.bukkit.entity.Player; * representation by the implementation. */ public class Location implements Cloneable, ConfigurationSerializable { - private World world; + private Reference world; private double x; private double y; private double z; @@ -58,8 +60,11 @@ public class Location implements Cloneable, ConfigurationSerializable { * @param yaw The absolute rotation on the x-plane, in degrees * @param pitch The absolute rotation on the y-plane, in degrees */ - public Location(@UndefinedNullability final World world, final double x, final double y, final double z, final float yaw, final float pitch) { // Paper - this.world = world; + public Location(@UndefinedNullability final World world, final double x, final double y, final double z, final float yaw, final float pitch) { + if (world != null) { + this.world = new WeakReference<>(world); + } + this.x = x; this.y = y; this.z = z; @@ -73,16 +78,38 @@ public class Location implements Cloneable, ConfigurationSerializable { * @param world New world that this location resides in */ public void setWorld(@Nullable World world) { - this.world = world; + this.world = (world == null) ? null : new WeakReference<>(world); + } + + /** + * Checks if world in this location is present and loaded. + * + * @return true if is loaded, otherwise false + */ + public boolean isWorldLoaded() { + if (this.world == null) { + return false; + } + + World world = this.world.get(); + return world != null && Bukkit.getWorld(world.getUID()) != null; } /** * Gets the world that this location resides in * - * @return World that contains this location + * @return World that contains this location, or {@code null} if it is not set + * @throws IllegalArgumentException when world is unloaded + * @see #isWorldLoaded() */ @UndefinedNullability public World getWorld() { + if (this.world == null) { + return null; + } + + World world = this.world.get(); + Preconditions.checkArgument(world != null, "World unloaded"); return world; } @@ -93,7 +120,7 @@ public class Location implements Cloneable, ConfigurationSerializable { */ @NotNull public Chunk getChunk() { - return world.getChunkAt(this); + return getWorld().getChunkAt(this); } /** @@ -103,7 +130,7 @@ public class Location implements Cloneable, ConfigurationSerializable { */ @NotNull public Block getBlock() { - return world.getBlockAt(this); + return getWorld().getBlockAt(this); } /** @@ -285,7 +312,7 @@ public class Location implements Cloneable, ConfigurationSerializable { /** * Sets the {@link #getYaw() yaw} and {@link #getPitch() pitch} to point * in the direction of the vector. - * + * * @param vector the direction vector * @return the same location */ @@ -516,7 +543,7 @@ public class Location implements Cloneable, ConfigurationSerializable { return this; } - public boolean isChunkLoaded() { return world.isChunkLoaded(locToBlock(x) >> 4, locToBlock(z) >> 4); } // Paper + public boolean isChunkLoaded() { return this.getWorld().isChunkLoaded(locToBlock(x) >> 4, locToBlock(z) >> 4); } // Paper // Paper start /** @@ -525,6 +552,7 @@ public class Location implements Cloneable, ConfigurationSerializable { * @return true if a chunk has been generated at this location */ public boolean isGenerated() { + World world = this.getWorld(); Preconditions.checkNotNull(world, "Location has no world!"); return world.isChunkGenerated(locToBlock(x) >> 4, locToBlock(z) >> 4); } @@ -610,6 +638,33 @@ public class Location implements Cloneable, ConfigurationSerializable { return centerLoc; } + // Paper start - Add heightmap api + + /** + * Returns a copy of this location except with y = getWorld().getHighestBlockYAt(this.getBlockX(), this.getBlockZ()) + * @return A copy of this location except with y = getWorld().getHighestBlockYAt(this.getBlockX(), this.getBlockZ()) + * @throws NullPointerException if {{@link #getWorld()}} is {@code null} + */ + @NotNull + public Location toHighestLocation() { + return this.toHighestLocation(com.destroystokyo.paper.HeightmapType.LIGHT_BLOCKING); + } + + /** + * Returns a copy of this location except with y = getWorld().getHighestBlockYAt(this.getBlockX(), this.getBlockZ(), heightmap) + * @param heightmap The heightmap to use for finding the highest y location. + * @return A copy of this location except with y = getWorld().getHighestBlockYAt(this.getBlockX(), this.getBlockZ(), heightmap) + * @throws NullPointerException if {{@link #getWorld()}} is {@code null} + * @throws UnsupportedOperationException if {@link World#getHighestBlockYAt(int, int, com.destroystokyo.paper.HeightmapType)} does not support the specified heightmap + */ + @NotNull + public Location toHighestLocation(@NotNull final com.destroystokyo.paper.HeightmapType heightmap) { + final Location ret = this.clone(); + ret.setY(this.getWorld().getHighestBlockYAt(this, heightmap)); + return ret; + } + // Paper end + /** * Creates explosion at this location with given power * @@ -619,7 +674,7 @@ public class Location implements Cloneable, ConfigurationSerializable { * @return false if explosion was canceled, otherwise true */ public boolean createExplosion(float power) { - return world.createExplosion(this, power); + return this.getWorld().createExplosion(this, power); } /** @@ -633,7 +688,7 @@ public class Location implements Cloneable, ConfigurationSerializable { * @return false if explosion was canceled, otherwise true */ public boolean createExplosion(float power, boolean setFire) { - return world.createExplosion(this, power, setFire); + return this.getWorld().createExplosion(this, power, setFire); } /** @@ -646,7 +701,7 @@ public class Location implements Cloneable, ConfigurationSerializable { * @return false if explosion was canceled, otherwise true */ public boolean createExplosion(float power, boolean setFire, boolean breakBlocks) { - return world.createExplosion(this, power, setFire, breakBlocks); + return this.getWorld().createExplosion(this, power, setFire, breakBlocks); } /** @@ -659,7 +714,7 @@ public class Location implements Cloneable, ConfigurationSerializable { * @return false if explosion was canceled, otherwise true */ public boolean createExplosion(@Nullable Entity source, float power) { - return world.createExplosion(source, this, power, true, true); + return this.getWorld().createExplosion(source, this, power, true, true); } /** @@ -674,7 +729,7 @@ public class Location implements Cloneable, ConfigurationSerializable { * @return false if explosion was canceled, otherwise true */ public boolean createExplosion(@Nullable Entity source, float power, boolean setFire) { - return world.createExplosion(source, this, power, setFire, true); + return this.getWorld().createExplosion(source, this, power, setFire, true); } /** @@ -688,7 +743,7 @@ public class Location implements Cloneable, ConfigurationSerializable { * @return false if explosion was canceled, otherwise true */ public boolean createExplosion(@NotNull Entity source, float power, boolean setFire, boolean breakBlocks) { - return world.createExplosion(source, source.getLocation(), power, setFire, breakBlocks); + return this.getWorld().createExplosion(source, source.getLocation(), power, setFire, breakBlocks); } /** @@ -703,6 +758,7 @@ public class Location implements Cloneable, ConfigurationSerializable { */ @NotNull public Collection getNearbyEntities(double x, double y, double z) { + World world = this.getWorld(); if (world == null) { throw new IllegalArgumentException("Location has no world"); } @@ -925,6 +981,7 @@ public class Location implements Cloneable, ConfigurationSerializable { */ @NotNull public Collection getNearbyEntitiesByType(@Nullable Class clazz, double xRadius, double yRadius, double zRadius, @Nullable Predicate predicate) { + World world = this.getWorld(); if (world == null) { throw new IllegalArgumentException("Location has no world"); } @@ -941,7 +998,9 @@ public class Location implements Cloneable, ConfigurationSerializable { } final Location other = (Location) obj; - if (this.world != other.world && (this.world == null || !this.world.equals(other.world))) { + World world = (this.world == null) ? null : this.world.get(); + World otherWorld = (other.world == null) ? null : other.world.get(); + if (world != otherWorld && (world == null || !world.equals(otherWorld))) { return false; } if (Double.doubleToLongBits(this.x) != Double.doubleToLongBits(other.x)) { @@ -966,7 +1025,8 @@ public class Location implements Cloneable, ConfigurationSerializable { public int hashCode() { int hash = 3; - hash = 19 * hash + (this.world != null ? this.world.hashCode() : 0); + World world = (this.world == null) ? null : this.world.get(); + hash = 19 * hash + (world != null ? world.hashCode() : 0); hash = 19 * hash + (int) (Double.doubleToLongBits(this.x) ^ (Double.doubleToLongBits(this.x) >>> 32)); hash = 19 * hash + (int) (Double.doubleToLongBits(this.y) ^ (Double.doubleToLongBits(this.y) >>> 32)); hash = 19 * hash + (int) (Double.doubleToLongBits(this.z) ^ (Double.doubleToLongBits(this.z) >>> 32)); @@ -977,6 +1037,7 @@ public class Location implements Cloneable, ConfigurationSerializable { @Override public String toString() { + World world = (this.world == null) ? null : this.world.get(); return "Location{" + "world=" + world + ",x=" + x + ",y=" + y + ",z=" + z + ",pitch=" + pitch + ",yaw=" + yaw + '}'; } @@ -1025,11 +1086,15 @@ public class Location implements Cloneable, ConfigurationSerializable { return NumberConversions.floor(loc); } + @Override @Utility @NotNull public Map serialize() { Map data = new HashMap(); - data.put("world", this.world.getName()); + + if (this.world != null) { + data.put("world", getWorld().getName()); + } data.put("x", this.x); data.put("y", this.y); @@ -1051,9 +1116,12 @@ public class Location implements Cloneable, ConfigurationSerializable { */ @NotNull public static Location deserialize(@NotNull Map args) { - World world = Bukkit.getWorld((String) args.get("world")); - if (world == null) { - throw new IllegalArgumentException("unknown world"); + World world = null; + if (args.containsKey("world")) { + world = Bukkit.getWorld((String) args.get("world")); + if (world == null) { + throw new IllegalArgumentException("unknown world"); + } } return new Location(world, NumberConversions.toDouble(args.get("x")), NumberConversions.toDouble(args.get("y")), NumberConversions.toDouble(args.get("z")), NumberConversions.toFloat(args.get("yaw")), NumberConversions.toFloat(args.get("pitch"))); diff --git a/api/src/main/java/org/bukkit/Material.java b/api/src/main/java/org/bukkit/Material.java index c628a9349..bb0833f62 100644 --- a/api/src/main/java/org/bukkit/Material.java +++ b/api/src/main/java/org/bukkit/Material.java @@ -16,14 +16,17 @@ import org.bukkit.block.data.Lightable; import org.bukkit.block.data.MultipleFacing; import org.bukkit.block.data.Orientable; import org.bukkit.block.data.Powerable; +import org.bukkit.block.data.Rail; import org.bukkit.block.data.Rotatable; import org.bukkit.block.data.Snowable; -import org.bukkit.block.data.Rail; import org.bukkit.block.data.Waterlogged; +import org.bukkit.block.data.type.Bamboo; import org.bukkit.block.data.type.Bed; +import org.bukkit.block.data.type.Bell; import org.bukkit.block.data.type.BrewingStand; import org.bukkit.block.data.type.BubbleColumn; import org.bukkit.block.data.type.Cake; +import org.bukkit.block.data.type.Campfire; import org.bukkit.block.data.type.Chest; import org.bukkit.block.data.type.Cocoa; import org.bukkit.block.data.type.CommandBlock; @@ -43,7 +46,9 @@ import org.bukkit.block.data.type.GlassPane; import org.bukkit.block.data.type.Hopper; import org.bukkit.block.data.type.Jukebox; import org.bukkit.block.data.type.Ladder; +import org.bukkit.block.data.type.Lantern; import org.bukkit.block.data.type.Leaves; +import org.bukkit.block.data.type.Lectern; import org.bukkit.block.data.type.NoteBlock; import org.bukkit.block.data.type.Observer; import org.bukkit.block.data.type.Piston; @@ -53,6 +58,7 @@ import org.bukkit.block.data.type.RedstoneWallTorch; import org.bukkit.block.data.type.RedstoneWire; import org.bukkit.block.data.type.Repeater; import org.bukkit.block.data.type.Sapling; +import org.bukkit.block.data.type.Scaffolding; import org.bukkit.block.data.type.SeaPickle; import org.bukkit.block.data.type.Sign; import org.bukkit.block.data.type.Slab; @@ -111,6 +117,10 @@ public enum Material implements Keyed { * BlockData: {@link Sapling} */ ACACIA_SAPLING(20806, Sapling.class), + /** + * BlockData: {@link Sign} + */ + ACACIA_SIGN(29808, 16, Sign.class), /** * BlockData: {@link Slab} */ @@ -123,6 +133,10 @@ public enum Material implements Keyed { * BlockData: {@link TrapDoor} */ ACACIA_TRAPDOOR(18343, TrapDoor.class), + /** + * BlockData: {@link WallSign} + */ + ACACIA_WALL_SIGN(20316, 16, WallSign.class), /** * BlockData: {@link Orientable} */ @@ -134,6 +148,18 @@ public enum Material implements Keyed { AIR(9648, 0), ALLIUM(6871), ANDESITE(25975), + /** + * BlockData: {@link Slab} + */ + ANDESITE_SLAB(32124, Slab.class), + /** + * BlockData: {@link Stairs} + */ + ANDESITE_STAIRS(17747, Stairs.class), + /** + * BlockData: {@link Fence} + */ + ANDESITE_WALL(14938, Fence.class), /** * BlockData: {@link Directional} */ @@ -151,6 +177,15 @@ public enum Material implements Keyed { ATTACHED_PUMPKIN_STEM(12724, Directional.class), AZURE_BLUET(17608), BAKED_POTATO(14624), + /** + * BlockData: {@link Bamboo} + */ + BAMBOO(18728, Bamboo.class), + BAMBOO_SAPLING(8478), + /** + * BlockData: {@link Directional} + */ + BARREL(22396, Directional.class), BARRIER(26453), BAT_SPAWN_EGG(14607), BEACON(6608), @@ -163,6 +198,10 @@ public enum Material implements Keyed { BEETROOTS(22075, Ageable.class), BEETROOT_SEEDS(21282), BEETROOT_SOUP(16036, 1), + /** + * BlockData: {@link Bell} + */ + BELL(20000, Bell.class), BIRCH_BOAT(28104, 1), /** * BlockData: {@link Switch} @@ -197,6 +236,10 @@ public enum Material implements Keyed { * BlockData: {@link Sapling} */ BIRCH_SAPLING(31533, Sapling.class), + /** + * BlockData: {@link Sign} + */ + BIRCH_SIGN(11351, 16, Sign.class), /** * BlockData: {@link Slab} */ @@ -209,6 +252,10 @@ public enum Material implements Keyed { * BlockData: {@link TrapDoor} */ BIRCH_TRAPDOOR(32585, TrapDoor.class), + /** + * BlockData: {@link WallSign} + */ + BIRCH_WALL_SIGN(9887, 16, WallSign.class), /** * BlockData: {@link Orientable} */ @@ -224,6 +271,7 @@ public enum Material implements Keyed { BLACK_CARPET(6056), BLACK_CONCRETE(13338), BLACK_CONCRETE_POWDER(16150), + BLACK_DYE(6202), /** * BlockData: {@link Directional} */ @@ -243,6 +291,10 @@ public enum Material implements Keyed { */ BLACK_WALL_BANNER(4919, Directional.class), BLACK_WOOL(16693), + /** + * BlockData: {@link Furnace} + */ + BLAST_FURNACE(31157, Furnace.class), BLAZE_POWDER(18941), BLAZE_ROD(8289), BLAZE_SPAWN_EGG(4759), @@ -257,6 +309,7 @@ public enum Material implements Keyed { BLUE_CARPET(13292), BLUE_CONCRETE(18756), BLUE_CONCRETE_POWDER(17773), + BLUE_DYE(11588), /** * BlockData: {@link Directional} */ @@ -316,6 +369,10 @@ public enum Material implements Keyed { * BlockData: {@link Stairs} */ BRICK_STAIRS(21534, Stairs.class), + /** + * BlockData: {@link Fence} + */ + BRICK_WALL(18995, Fence.class), /** * BlockData: {@link Rotatable} */ @@ -327,6 +384,7 @@ public enum Material implements Keyed { BROWN_CARPET(23352), BROWN_CONCRETE(19006), BROWN_CONCRETE_POWDER(21485), + BROWN_DYE(7648), /** * BlockData: {@link Directional} */ @@ -373,21 +431,26 @@ public enum Material implements Keyed { * BlockData: {@link Ageable} */ CACTUS(12191, Ageable.class), - CACTUS_GREEN(17296), /** * BlockData: {@link Cake} */ CAKE(27048, 1, Cake.class), + /** + * BlockData: {@link Campfire} + */ + CAMPFIRE(8488, Campfire.class), CARROT(22824), /** * BlockData: {@link Ageable} */ CARROTS(17258, Ageable.class), CARROT_ON_A_STICK(27809, 1, 25), + CARTOGRAPHY_TABLE(28529), /** * BlockData: {@link Directional} */ CARVED_PUMPKIN(25833, Directional.class), + CAT_SPAWN_EGG(29583), /** * BlockData: {@link Levelled} */ @@ -466,6 +529,10 @@ public enum Material implements Keyed { */ COMPARATOR(18911, Comparator.class), COMPASS(24139), + /** + * BlockData: {@link Levelled} + */ + COMPOSTER(31247, Levelled.class), /** * BlockData: {@link Waterlogged} */ @@ -478,9 +545,11 @@ public enum Material implements Keyed { COOKED_RABBIT(4454), COOKED_SALMON(5615), COOKIE(27431), + CORNFLOWER(15405), COW_SPAWN_EGG(14761), CRACKED_STONE_BRICKS(27869), CRAFTING_TABLE(20706), + CREEPER_BANNER_PATTERN(15774, 1), /** * BlockData: {@link Rotatable} */ @@ -490,8 +559,17 @@ public enum Material implements Keyed { * BlockData: {@link Directional} */ CREEPER_WALL_HEAD(30123, Directional.class), + CROSSBOW(4340, 1, 326), CUT_RED_SANDSTONE(26842), + /** + * BlockData: {@link Slab} + */ + CUT_RED_SANDSTONE_SLAB(7220, Slab.class), CUT_SANDSTONE(6118), + /** + * BlockData: {@link Slab} + */ + CUT_SANDSTONE_SLAB(30944, Slab.class), /** * BlockData: {@link Rotatable} */ @@ -528,7 +606,6 @@ public enum Material implements Keyed { */ DAMAGED_ANVIL(10274, Directional.class), DANDELION(30558), - DANDELION_YELLOW(21789), DARK_OAK_BOAT(28618, 1), /** * BlockData: {@link Switch} @@ -563,6 +640,10 @@ public enum Material implements Keyed { * BlockData: {@link Sapling} */ DARK_OAK_SAPLING(14933, Sapling.class), + /** + * BlockData: {@link Sign} + */ + DARK_OAK_SIGN(15127, 16, Sign.class), /** * BlockData: {@link Slab} */ @@ -575,6 +656,10 @@ public enum Material implements Keyed { * BlockData: {@link TrapDoor} */ DARK_OAK_TRAPDOOR(10355, TrapDoor.class), + /** + * BlockData: {@link WallSign} + */ + DARK_OAK_WALL_SIGN(9508, 16, WallSign.class), /** * BlockData: {@link Orientable} */ @@ -677,6 +762,18 @@ public enum Material implements Keyed { DIAMOND_SHOVEL(25415, 1, 1561), DIAMOND_SWORD(27707, 1, 1561), DIORITE(24688), + /** + * BlockData: {@link Slab} + */ + DIORITE_SLAB(10715, Slab.class), + /** + * BlockData: {@link Stairs} + */ + DIORITE_STAIRS(13134, Stairs.class), + /** + * BlockData: {@link Fence} + */ + DIORITE_WALL(17412, Fence.class), DIRT(10580), /** * BlockData: {@link Dispenser} @@ -731,6 +828,18 @@ public enum Material implements Keyed { END_ROD(24832, Directional.class), END_STONE(29686), END_STONE_BRICKS(20314), + /** + * BlockData: {@link Slab} + */ + END_STONE_BRICK_SLAB(23239, Slab.class), + /** + * BlockData: {@link Stairs} + */ + END_STONE_BRICK_STAIRS(28831, Stairs.class), + /** + * BlockData: {@link Fence} + */ + END_STONE_BRICK_WALL(27225, Fence.class), EVOKER_SPAWN_EGG(21271), EXPERIENCE_BOTTLE(12858), /** @@ -762,9 +871,12 @@ public enum Material implements Keyed { */ FIRE_CORAL_WALL_FAN(20100, CoralWallFan.class), FISHING_ROD(4167, 1, 64), + FLETCHING_TABLE(30838), FLINT(23596), FLINT_AND_STEEL(28620, 1, 64), + FLOWER_BANNER_PATTERN(5762, 1), FLOWER_POT(30567), + FOX_SPAWN_EGG(22376), /** * BlockData: {@link Ageable} */ @@ -779,10 +891,11 @@ public enum Material implements Keyed { GLASS(6195), GLASS_BOTTLE(6116), /** - * BlockData: {@link GlassPane} + * BlockData: {@link Fence} */ - GLASS_PANE(5709, GlassPane.class), + GLASS_PANE(5709, Fence.class), GLISTERING_MELON_SLICE(20158), + GLOBE_BANNER_PATTERN(27753, 1), GLOWSTONE(32713), GLOWSTONE_DUST(6665), GOLDEN_APPLE(27732), @@ -802,6 +915,18 @@ public enum Material implements Keyed { GOLD_NUGGET(28814), GOLD_ORE(32625), GRANITE(21091), + /** + * BlockData: {@link Slab} + */ + GRANITE_SLAB(25898, Slab.class), + /** + * BlockData: {@link Stairs} + */ + GRANITE_STAIRS(21840, Stairs.class), + /** + * BlockData: {@link Fence} + */ + GRANITE_WALL(23279, Fence.class), GRASS(6155), /** * BlockData: {@link Snowable} @@ -851,6 +976,7 @@ public enum Material implements Keyed { GREEN_CARPET(7780), GREEN_CONCRETE(17949), GREEN_CONCRETE_POWDER(6904), + GREEN_DYE(23215), /** * BlockData: {@link Directional} */ @@ -870,6 +996,10 @@ public enum Material implements Keyed { */ GREEN_WALL_BANNER(15046, Directional.class), GREEN_WOOL(25085), + /** + * BlockData: {@link Directional} + */ + GRINDSTONE(26260, Directional.class), GUARDIAN_SPAWN_EGG(20113), GUNPOWDER(29974), /** @@ -940,6 +1070,10 @@ public enum Material implements Keyed { * BlockData: {@link Directional} */ JACK_O_LANTERN(31612, Directional.class), + /** + * BlockData: {@link Directional} + */ + JIGSAW(17398, Directional.class), /** * BlockData: {@link Jukebox} */ @@ -978,6 +1112,10 @@ public enum Material implements Keyed { * BlockData: {@link Sapling} */ JUNGLE_SAPLING(17951, Sapling.class), + /** + * BlockData: {@link Sign} + */ + JUNGLE_SIGN(24717, 16, Sign.class), /** * BlockData: {@link Slab} */ @@ -990,6 +1128,10 @@ public enum Material implements Keyed { * BlockData: {@link TrapDoor} */ JUNGLE_TRAPDOOR(8626, TrapDoor.class), + /** + * BlockData: {@link WallSign} + */ + JUNGLE_WALL_SIGN(29629, 16, WallSign.class), /** * BlockData: {@link Orientable} */ @@ -1004,6 +1146,10 @@ public enum Material implements Keyed { * BlockData: {@link Ladder} */ LADDER(23599, Ladder.class), + /** + * BlockData: {@link Lantern} + */ + LANTERN(5992, Lantern.class), LAPIS_BLOCK(14485), LAPIS_LAZULI(11075), LAPIS_ORE(22934), @@ -1021,7 +1167,12 @@ public enum Material implements Keyed { LEATHER_BOOTS(15282, 1, 65), LEATHER_CHESTPLATE(29275, 1, 80), LEATHER_HELMET(11624, 1, 55), + LEATHER_HORSE_ARMOR(30667, 1), LEATHER_LEGGINGS(28210, 1, 75), + /** + * BlockData: {@link Lectern} + */ + LECTERN(23490, Lectern.class), /** * BlockData: {@link Switch} */ @@ -1096,6 +1247,7 @@ public enum Material implements Keyed { * BlockData: {@link Bisected} */ LILAC(22837, Bisected.class), + LILY_OF_THE_VALLEY(7185), LILY_PAD(19271), /** * BlockData: {@link Rotatable} @@ -1130,6 +1282,10 @@ public enum Material implements Keyed { LIME_WOOL(10443), LINGERING_POTION(25857, 1), LLAMA_SPAWN_EGG(23640), + /** + * BlockData: {@link Directional} + */ + LOOM(14276, Directional.class), /** * BlockData: {@link Rotatable} */ @@ -1174,16 +1330,37 @@ public enum Material implements Keyed { MELON_STEM(8247, Ageable.class), MILK_BUCKET(9680, 1), MINECART(14352, 1), + MOJANG_BANNER_PATTERN(11903, 1), MOOSHROOM_SPAWN_EGG(22125), /** * BlockData: {@link MultipleFacing} */ MOSSY_COBBLESTONE(21900, MultipleFacing.class), + /** + * BlockData: {@link Slab} + */ + MOSSY_COBBLESTONE_SLAB(12139, Slab.class), + /** + * BlockData: {@link Stairs} + */ + MOSSY_COBBLESTONE_STAIRS(29210, Stairs.class), /** * BlockData: {@link Fence} */ MOSSY_COBBLESTONE_WALL(11536, Fence.class), MOSSY_STONE_BRICKS(16415), + /** + * BlockData: {@link Slab} + */ + MOSSY_STONE_BRICK_SLAB(14002, Slab.class), + /** + * BlockData: {@link Stairs} + */ + MOSSY_STONE_BRICK_STAIRS(27578, Stairs.class), + /** + * BlockData: {@link Fence} + */ + MOSSY_STONE_BRICK_WALL(18259, Fence.class), /** * BlockData: {@link TechnicalPiston} */ @@ -1228,6 +1405,10 @@ public enum Material implements Keyed { * BlockData: {@link Stairs} */ NETHER_BRICK_STAIRS(12085, Stairs.class), + /** + * BlockData: {@link Fence} + */ + NETHER_BRICK_WALL(10398, Fence.class), /** * BlockData: {@link Orientable} */ @@ -1277,6 +1458,10 @@ public enum Material implements Keyed { * BlockData: {@link Sapling} */ OAK_SAPLING(9636, Sapling.class), + /** + * BlockData: {@link Sign} + */ + OAK_SIGN(8192, 16, Sign.class), /** * BlockData: {@link Slab} */ @@ -1289,6 +1474,10 @@ public enum Material implements Keyed { * BlockData: {@link TrapDoor} */ OAK_TRAPDOOR(16927, TrapDoor.class), + /** + * BlockData: {@link WallSign} + */ + OAK_WALL_SIGN(12984, 16, WallSign.class), /** * BlockData: {@link Orientable} */ @@ -1334,6 +1523,7 @@ public enum Material implements Keyed { OXEYE_DAISY(11709), PACKED_ICE(28993), PAINTING(23945), + PANDA_SPAWN_EGG(23759), PAPER(9923), PARROT_SPAWN_EGG(23614), /** @@ -1347,6 +1537,7 @@ public enum Material implements Keyed { PHANTOM_MEMBRANE(18398), PHANTOM_SPAWN_EGG(24648), PIG_SPAWN_EGG(22584), + PILLAGER_SPAWN_EGG(28659), /** * BlockData: {@link Rotatable} */ @@ -1402,8 +1593,32 @@ public enum Material implements Keyed { POISONOUS_POTATO(32640), POLAR_BEAR_SPAWN_EGG(17015), POLISHED_ANDESITE(8335), + /** + * BlockData: {@link Slab} + */ + POLISHED_ANDESITE_SLAB(24573, Slab.class), + /** + * BlockData: {@link Stairs} + */ + POLISHED_ANDESITE_STAIRS(7573, Stairs.class), POLISHED_DIORITE(31615), + /** + * BlockData: {@link Slab} + */ + POLISHED_DIORITE_SLAB(18303, Slab.class), + /** + * BlockData: {@link Stairs} + */ + POLISHED_DIORITE_STAIRS(4625, Stairs.class), POLISHED_GRANITE(5477), + /** + * BlockData: {@link Slab} + */ + POLISHED_GRANITE_SLAB(4521, Slab.class), + /** + * BlockData: {@link Stairs} + */ + POLISHED_GRANITE_STAIRS(29588, Stairs.class), POPPED_CHORUS_FRUIT(27844), POPPY(12851), PORKCHOP(30896), @@ -1416,15 +1631,18 @@ public enum Material implements Keyed { POTTED_ACACIA_SAPLING(14096), POTTED_ALLIUM(13184), POTTED_AZURE_BLUET(8754), + POTTED_BAMBOO(22542), POTTED_BIRCH_SAPLING(32484), POTTED_BLUE_ORCHID(6599), POTTED_BROWN_MUSHROOM(14481), POTTED_CACTUS(8777), + POTTED_CORNFLOWER(28917), POTTED_DANDELION(9727), POTTED_DARK_OAK_SAPLING(6486), POTTED_DEAD_BUSH(13020), POTTED_FERN(23315), POTTED_JUNGLE_SAPLING(7525), + POTTED_LILY_OF_THE_VALLEY(9364), POTTED_OAK_SAPLING(11905), POTTED_ORANGE_TULIP(28807), POTTED_OXEYE_DAISY(19707), @@ -1434,6 +1652,7 @@ public enum Material implements Keyed { POTTED_RED_TULIP(28594), POTTED_SPRUCE_SAPLING(29498), POTTED_WHITE_TULIP(24330), + POTTED_WITHER_ROSE(26876), /** * BlockData: {@link RedstoneRail} */ @@ -1458,9 +1677,13 @@ public enum Material implements Keyed { * BlockData: {@link Stairs} */ PRISMARINE_STAIRS(19217, Stairs.class), + /** + * BlockData: {@link Fence} + */ + PRISMARINE_WALL(18184, Fence.class), PUFFERFISH(8115), PUFFERFISH_BUCKET(8861, 1), - PUFFERFISH_SPAWN_EGG(24573), + PUFFERFISH_SPAWN_EGG(24570), PUMPKIN(19170), PUMPKIN_PIE(28725), PUMPKIN_SEEDS(28985), @@ -1535,6 +1758,7 @@ public enum Material implements Keyed { * BlockData: {@link Rail} */ RAIL(13285, Rail.class), + RAVAGER_SPAWN_EGG(8726), REDSTONE(11233), REDSTONE_BLOCK(19496), /** @@ -1568,6 +1792,7 @@ public enum Material implements Keyed { RED_CARPET(5424), RED_CONCRETE(8032), RED_CONCRETE_POWDER(13286), + RED_DYE(5728), /** * BlockData: {@link Directional} */ @@ -1578,6 +1803,18 @@ public enum Material implements Keyed { */ RED_MUSHROOM_BLOCK(20766, MultipleFacing.class), RED_NETHER_BRICKS(18056), + /** + * BlockData: {@link Slab} + */ + RED_NETHER_BRICK_SLAB(12462, Slab.class), + /** + * BlockData: {@link Stairs} + */ + RED_NETHER_BRICK_STAIRS(26374, Stairs.class), + /** + * BlockData: {@link Fence} + */ + RED_NETHER_BRICK_WALL(4580, Fence.class), RED_SAND(16279), RED_SANDSTONE(9092), /** @@ -1588,6 +1825,10 @@ public enum Material implements Keyed { * BlockData: {@link Stairs} */ RED_SANDSTONE_STAIRS(25466, Stairs.class), + /** + * BlockData: {@link Fence} + */ + RED_SANDSTONE_WALL(4753, Fence.class), /** * BlockData: {@link Directional} */ @@ -1616,7 +1857,6 @@ public enum Material implements Keyed { * BlockData: {@link Bisected} */ ROSE_BUSH(6080, Bisected.class), - ROSE_RED(15694), ROTTEN_FLESH(21591), SADDLE(30206, 1), SALMON(18516), @@ -1632,6 +1872,14 @@ public enum Material implements Keyed { * BlockData: {@link Stairs} */ SANDSTONE_STAIRS(18474, Stairs.class), + /** + * BlockData: {@link Fence} + */ + SANDSTONE_WALL(18470, Fence.class), + /** + * BlockData: {@link Scaffolding} + */ + SCAFFOLDING(15757, Scaffolding.class), SCUTE(11914), SEAGRASS(23942), SEA_LANTERN(16984), @@ -1648,10 +1896,6 @@ public enum Material implements Keyed { SHULKER_BOX(7776, 1, Directional.class), SHULKER_SHELL(27848), SHULKER_SPAWN_EGG(31848), - /** - * BlockData: {@link Sign} - */ - SIGN(16918, 16, Sign.class), SILVERFISH_SPAWN_EGG(14537), SKELETON_HORSE_SPAWN_EGG(21356), /** @@ -1663,13 +1907,47 @@ public enum Material implements Keyed { * BlockData: {@link Directional} */ SKELETON_WALL_SKULL(31650, Directional.class), + SKULL_BANNER_PATTERN(7680, 1), SLIME_BALL(5242), SLIME_BLOCK(31892), SLIME_SPAWN_EGG(6550), + SMITHING_TABLE(9082), + /** + * BlockData: {@link Furnace} + */ + SMOKER(24781, Furnace.class), SMOOTH_QUARTZ(14415), + /** + * BlockData: {@link Slab} + */ + SMOOTH_QUARTZ_SLAB(26543, Slab.class), + /** + * BlockData: {@link Stairs} + */ + SMOOTH_QUARTZ_STAIRS(19560, Stairs.class), SMOOTH_RED_SANDSTONE(25180), + /** + * BlockData: {@link Slab} + */ + SMOOTH_RED_SANDSTONE_SLAB(16304, Slab.class), + /** + * BlockData: {@link Stairs} + */ + SMOOTH_RED_SANDSTONE_STAIRS(17561, Stairs.class), SMOOTH_SANDSTONE(30039), + /** + * BlockData: {@link Slab} + */ + SMOOTH_SANDSTONE_SLAB(9030, Slab.class), + /** + * BlockData: {@link Stairs} + */ + SMOOTH_SANDSTONE_STAIRS(21183, Stairs.class), SMOOTH_STONE(21910), + /** + * BlockData: {@link Slab} + */ + SMOOTH_STONE_SLAB(24129, Slab.class), /** * BlockData: {@link Snow} */ @@ -1717,6 +1995,10 @@ public enum Material implements Keyed { * BlockData: {@link Sapling} */ SPRUCE_SAPLING(19874, Sapling.class), + /** + * BlockData: {@link Sign} + */ + SPRUCE_SIGN(21502, 16, Sign.class), /** * BlockData: {@link Slab} */ @@ -1729,6 +2011,10 @@ public enum Material implements Keyed { * BlockData: {@link TrapDoor} */ SPRUCE_TRAPDOOR(10289, TrapDoor.class), + /** + * BlockData: {@link WallSign} + */ + SPRUCE_WALL_SIGN(7352, 16, WallSign.class), /** * BlockData: {@link Orientable} */ @@ -1740,6 +2026,10 @@ public enum Material implements Keyed { */ STICKY_PISTON(18127, Piston.class), STONE(22948), + /** + * BlockData: {@link Directional} + */ + STONECUTTER(25170, Directional.class), STONE_AXE(6338, 1, 131), STONE_BRICKS(6962), /** @@ -1750,6 +2040,10 @@ public enum Material implements Keyed { * BlockData: {@link Stairs} */ STONE_BRICK_STAIRS(27032, Stairs.class), + /** + * BlockData: {@link Fence} + */ + STONE_BRICK_WALL(29073, Fence.class), /** * BlockData: {@link Switch} */ @@ -1765,6 +2059,10 @@ public enum Material implements Keyed { * BlockData: {@link Slab} */ STONE_SLAB(19838, Slab.class), + /** + * BlockData: {@link Stairs} + */ + STONE_STAIRS(23784, Stairs.class), STONE_SWORD(25084, 1, 131), STRAY_SPAWN_EGG(30153), STRING(12806), @@ -1830,6 +2128,12 @@ public enum Material implements Keyed { * BlockData: {@link Bisected} */ SUNFLOWER(7408, Bisected.class), + SUSPICIOUS_STEW(8173, 1), + SWEET_BERRIES(19747), + /** + * BlockData: {@link Ageable} + */ + SWEET_BERRY_BUSH(11958, Ageable.class), /** * BlockData: {@link Bisected} */ @@ -1847,6 +2151,7 @@ public enum Material implements Keyed { TNT_MINECART(4277, 1), TORCH(6063), TOTEM_OF_UNDYING(10139, 1), + TRADER_LLAMA_SPAWN_EGG(8439), /** * BlockData: {@link Chest} */ @@ -1890,14 +2195,11 @@ public enum Material implements Keyed { */ VINE(14564, MultipleFacing.class), VOID_AIR(13668), - /** - * BlockData: {@link WallSign} - */ - WALL_SIGN(10644, WallSign.class), /** * BlockData: {@link Directional} */ WALL_TORCH(25890, Directional.class), + WANDERING_TRADER_SPAWN_EGG(17904), /** * BlockData: {@link Levelled} */ @@ -1920,6 +2222,7 @@ public enum Material implements Keyed { WHITE_CARPET(15117), WHITE_CONCRETE(6281), WHITE_CONCRETE_POWDER(10363), + WHITE_DYE(10758), /** * BlockData: {@link Directional} */ @@ -1941,6 +2244,7 @@ public enum Material implements Keyed { WHITE_WALL_BANNER(15967, Directional.class), WHITE_WOOL(8624), WITCH_SPAWN_EGG(11837), + WITHER_ROSE(8619), /** * BlockData: {@link Rotatable} */ @@ -1969,6 +2273,7 @@ public enum Material implements Keyed { YELLOW_CARPET(18149), YELLOW_CONCRETE(15722), YELLOW_CONCRETE_POWDER(10655), + YELLOW_DYE(5952), /** * BlockData: {@link Directional} */ @@ -2939,7 +3244,7 @@ public enum Material implements Keyed { private final int id; private final Constructor ctor; - private final static Map BY_NAME = Maps.newHashMap(); + private static final Map BY_NAME = Maps.newHashMap(); private final int maxStack; private final short durability; public final Class data; @@ -3011,6 +3316,7 @@ public enum Material implements Keyed { */ @Deprecated public int getId() { + Validate.isTrue(legacy, "Cannot get ID of Modern Material"); return id; } @@ -3142,22 +3448,31 @@ public enum Material implements Keyed { case ACACIA_PLANKS: case ACACIA_PRESSURE_PLATE: case ACACIA_SAPLING: + case ACACIA_SIGN: case ACACIA_SLAB: case ACACIA_STAIRS: case ACACIA_TRAPDOOR: + case ACACIA_WALL_SIGN: case ACACIA_WOOD: case ACTIVATOR_RAIL: case AIR: case ALLIUM: case ANDESITE: + case ANDESITE_SLAB: + case ANDESITE_STAIRS: + case ANDESITE_WALL: case ANVIL: case ATTACHED_MELON_STEM: case ATTACHED_PUMPKIN_STEM: case AZURE_BLUET: + case BAMBOO: + case BAMBOO_SAPLING: + case BARREL: case BARRIER: case BEACON: case BEDROCK: case BEETROOTS: + case BELL: case BIRCH_BUTTON: case BIRCH_DOOR: case BIRCH_FENCE: @@ -3167,9 +3482,11 @@ public enum Material implements Keyed { case BIRCH_PLANKS: case BIRCH_PRESSURE_PLATE: case BIRCH_SAPLING: + case BIRCH_SIGN: case BIRCH_SLAB: case BIRCH_STAIRS: case BIRCH_TRAPDOOR: + case BIRCH_WALL_SIGN: case BIRCH_WOOD: case BLACK_BANNER: case BLACK_BED: @@ -3183,6 +3500,7 @@ public enum Material implements Keyed { case BLACK_TERRACOTTA: case BLACK_WALL_BANNER: case BLACK_WOOL: + case BLAST_FURNACE: case BLUE_BANNER: case BLUE_BED: case BLUE_CARPET: @@ -3207,6 +3525,7 @@ public enum Material implements Keyed { case BRICKS: case BRICK_SLAB: case BRICK_STAIRS: + case BRICK_WALL: case BROWN_BANNER: case BROWN_BED: case BROWN_CARPET: @@ -3228,7 +3547,9 @@ public enum Material implements Keyed { case BUBBLE_CORAL_WALL_FAN: case CACTUS: case CAKE: + case CAMPFIRE: case CARROTS: + case CARTOGRAPHY_TABLE: case CARVED_PUMPKIN: case CAULDRON: case CAVE_AIR: @@ -3253,13 +3574,17 @@ public enum Material implements Keyed { case COCOA: case COMMAND_BLOCK: case COMPARATOR: + case COMPOSTER: case CONDUIT: + case CORNFLOWER: case CRACKED_STONE_BRICKS: case CRAFTING_TABLE: case CREEPER_HEAD: case CREEPER_WALL_HEAD: case CUT_RED_SANDSTONE: + case CUT_RED_SANDSTONE_SLAB: case CUT_SANDSTONE: + case CUT_SANDSTONE_SLAB: case CYAN_BANNER: case CYAN_BED: case CYAN_CARPET: @@ -3283,9 +3608,11 @@ public enum Material implements Keyed { case DARK_OAK_PLANKS: case DARK_OAK_PRESSURE_PLATE: case DARK_OAK_SAPLING: + case DARK_OAK_SIGN: case DARK_OAK_SLAB: case DARK_OAK_STAIRS: case DARK_OAK_TRAPDOOR: + case DARK_OAK_WALL_SIGN: case DARK_OAK_WOOD: case DARK_PRISMARINE: case DARK_PRISMARINE_SLAB: @@ -3316,6 +3643,9 @@ public enum Material implements Keyed { case DIAMOND_BLOCK: case DIAMOND_ORE: case DIORITE: + case DIORITE_SLAB: + case DIORITE_STAIRS: + case DIORITE_WALL: case DIRT: case DISPENSER: case DRAGON_EGG: @@ -3333,6 +3663,9 @@ public enum Material implements Keyed { case END_ROD: case END_STONE: case END_STONE_BRICKS: + case END_STONE_BRICK_SLAB: + case END_STONE_BRICK_STAIRS: + case END_STONE_BRICK_WALL: case FARMLAND: case FERN: case FIRE: @@ -3340,6 +3673,7 @@ public enum Material implements Keyed { case FIRE_CORAL_BLOCK: case FIRE_CORAL_FAN: case FIRE_CORAL_WALL_FAN: + case FLETCHING_TABLE: case FLOWER_POT: case FROSTED_ICE: case FURNACE: @@ -3349,6 +3683,9 @@ public enum Material implements Keyed { case GOLD_BLOCK: case GOLD_ORE: case GRANITE: + case GRANITE_SLAB: + case GRANITE_STAIRS: + case GRANITE_WALL: case GRASS: case GRASS_BLOCK: case GRASS_PATH: @@ -3377,6 +3714,7 @@ public enum Material implements Keyed { case GREEN_TERRACOTTA: case GREEN_WALL_BANNER: case GREEN_WOOL: + case GRINDSTONE: case HAY_BLOCK: case HEAVY_WEIGHTED_PRESSURE_PLATE: case HOPPER: @@ -3397,6 +3735,7 @@ public enum Material implements Keyed { case IRON_ORE: case IRON_TRAPDOOR: case JACK_O_LANTERN: + case JIGSAW: case JUKEBOX: case JUNGLE_BUTTON: case JUNGLE_DOOR: @@ -3407,17 +3746,21 @@ public enum Material implements Keyed { case JUNGLE_PLANKS: case JUNGLE_PRESSURE_PLATE: case JUNGLE_SAPLING: + case JUNGLE_SIGN: case JUNGLE_SLAB: case JUNGLE_STAIRS: case JUNGLE_TRAPDOOR: + case JUNGLE_WALL_SIGN: case JUNGLE_WOOD: case KELP: case KELP_PLANT: case LADDER: + case LANTERN: case LAPIS_BLOCK: case LAPIS_ORE: case LARGE_FERN: case LAVA: + case LECTERN: case LEVER: case LIGHT_BLUE_BANNER: case LIGHT_BLUE_BED: @@ -3445,6 +3788,7 @@ public enum Material implements Keyed { case LIGHT_GRAY_WOOL: case LIGHT_WEIGHTED_PRESSURE_PLATE: case LILAC: + case LILY_OF_THE_VALLEY: case LILY_PAD: case LIME_BANNER: case LIME_BED: @@ -3458,6 +3802,7 @@ public enum Material implements Keyed { case LIME_TERRACOTTA: case LIME_WALL_BANNER: case LIME_WOOL: + case LOOM: case MAGENTA_BANNER: case MAGENTA_BED: case MAGENTA_CARPET: @@ -3474,8 +3819,13 @@ public enum Material implements Keyed { case MELON: case MELON_STEM: case MOSSY_COBBLESTONE: + case MOSSY_COBBLESTONE_SLAB: + case MOSSY_COBBLESTONE_STAIRS: case MOSSY_COBBLESTONE_WALL: case MOSSY_STONE_BRICKS: + case MOSSY_STONE_BRICK_SLAB: + case MOSSY_STONE_BRICK_STAIRS: + case MOSSY_STONE_BRICK_WALL: case MOVING_PISTON: case MUSHROOM_STEM: case MYCELIUM: @@ -3484,6 +3834,7 @@ public enum Material implements Keyed { case NETHER_BRICK_FENCE: case NETHER_BRICK_SLAB: case NETHER_BRICK_STAIRS: + case NETHER_BRICK_WALL: case NETHER_PORTAL: case NETHER_QUARTZ_ORE: case NETHER_WART: @@ -3498,9 +3849,11 @@ public enum Material implements Keyed { case OAK_PLANKS: case OAK_PRESSURE_PLATE: case OAK_SAPLING: + case OAK_SIGN: case OAK_SLAB: case OAK_STAIRS: case OAK_TRAPDOOR: + case OAK_WALL_SIGN: case OAK_WOOD: case OBSERVER: case OBSIDIAN: @@ -3540,22 +3893,31 @@ public enum Material implements Keyed { case PLAYER_WALL_HEAD: case PODZOL: case POLISHED_ANDESITE: + case POLISHED_ANDESITE_SLAB: + case POLISHED_ANDESITE_STAIRS: case POLISHED_DIORITE: + case POLISHED_DIORITE_SLAB: + case POLISHED_DIORITE_STAIRS: case POLISHED_GRANITE: + case POLISHED_GRANITE_SLAB: + case POLISHED_GRANITE_STAIRS: case POPPY: case POTATOES: case POTTED_ACACIA_SAPLING: case POTTED_ALLIUM: case POTTED_AZURE_BLUET: + case POTTED_BAMBOO: case POTTED_BIRCH_SAPLING: case POTTED_BLUE_ORCHID: case POTTED_BROWN_MUSHROOM: case POTTED_CACTUS: + case POTTED_CORNFLOWER: case POTTED_DANDELION: case POTTED_DARK_OAK_SAPLING: case POTTED_DEAD_BUSH: case POTTED_FERN: case POTTED_JUNGLE_SAPLING: + case POTTED_LILY_OF_THE_VALLEY: case POTTED_OAK_SAPLING: case POTTED_ORANGE_TULIP: case POTTED_OXEYE_DAISY: @@ -3565,6 +3927,7 @@ public enum Material implements Keyed { case POTTED_RED_TULIP: case POTTED_SPRUCE_SAPLING: case POTTED_WHITE_TULIP: + case POTTED_WITHER_ROSE: case POWERED_RAIL: case PRISMARINE: case PRISMARINE_BRICKS: @@ -3572,6 +3935,7 @@ public enum Material implements Keyed { case PRISMARINE_BRICK_STAIRS: case PRISMARINE_SLAB: case PRISMARINE_STAIRS: + case PRISMARINE_WALL: case PUMPKIN: case PUMPKIN_STEM: case PURPLE_BANNER: @@ -3610,10 +3974,14 @@ public enum Material implements Keyed { case RED_MUSHROOM: case RED_MUSHROOM_BLOCK: case RED_NETHER_BRICKS: + case RED_NETHER_BRICK_SLAB: + case RED_NETHER_BRICK_STAIRS: + case RED_NETHER_BRICK_WALL: case RED_SAND: case RED_SANDSTONE: case RED_SANDSTONE_SLAB: case RED_SANDSTONE_STAIRS: + case RED_SANDSTONE_WALL: case RED_SHULKER_BOX: case RED_STAINED_GLASS: case RED_STAINED_GLASS_PANE: @@ -3628,18 +3996,28 @@ public enum Material implements Keyed { case SANDSTONE: case SANDSTONE_SLAB: case SANDSTONE_STAIRS: + case SANDSTONE_WALL: + case SCAFFOLDING: case SEAGRASS: case SEA_LANTERN: case SEA_PICKLE: case SHULKER_BOX: - case SIGN: case SKELETON_SKULL: case SKELETON_WALL_SKULL: case SLIME_BLOCK: + case SMITHING_TABLE: + case SMOKER: case SMOOTH_QUARTZ: + case SMOOTH_QUARTZ_SLAB: + case SMOOTH_QUARTZ_STAIRS: case SMOOTH_RED_SANDSTONE: + case SMOOTH_RED_SANDSTONE_SLAB: + case SMOOTH_RED_SANDSTONE_STAIRS: case SMOOTH_SANDSTONE: + case SMOOTH_SANDSTONE_SLAB: + case SMOOTH_SANDSTONE_STAIRS: case SMOOTH_STONE: + case SMOOTH_STONE_SLAB: case SNOW: case SNOW_BLOCK: case SOUL_SAND: @@ -3654,18 +4032,23 @@ public enum Material implements Keyed { case SPRUCE_PLANKS: case SPRUCE_PRESSURE_PLATE: case SPRUCE_SAPLING: + case SPRUCE_SIGN: case SPRUCE_SLAB: case SPRUCE_STAIRS: case SPRUCE_TRAPDOOR: + case SPRUCE_WALL_SIGN: case SPRUCE_WOOD: case STICKY_PISTON: case STONE: + case STONECUTTER: case STONE_BRICKS: case STONE_BRICK_SLAB: case STONE_BRICK_STAIRS: + case STONE_BRICK_WALL: case STONE_BUTTON: case STONE_PRESSURE_PLATE: case STONE_SLAB: + case STONE_STAIRS: case STRIPPED_ACACIA_LOG: case STRIPPED_ACACIA_WOOD: case STRIPPED_BIRCH_LOG: @@ -3682,6 +4065,7 @@ public enum Material implements Keyed { case STRUCTURE_VOID: case SUGAR_CANE: case SUNFLOWER: + case SWEET_BERRY_BUSH: case TALL_GRASS: case TALL_SEAGRASS: case TERRACOTTA: @@ -3697,7 +4081,6 @@ public enum Material implements Keyed { case TURTLE_EGG: case VINE: case VOID_AIR: - case WALL_SIGN: case WALL_TORCH: case WATER: case WET_SPONGE: @@ -3715,6 +4098,7 @@ public enum Material implements Keyed { case WHITE_TULIP: case WHITE_WALL_BANNER: case WHITE_WOOL: + case WITHER_ROSE: case WITHER_SKELETON_SKULL: case WITHER_SKELETON_WALL_SKULL: case YELLOW_BANNER: @@ -3781,6 +4165,8 @@ public enum Material implements Keyed { case ROTTEN_FLESH: case SALMON: case SPIDER_EYE: + case SUSPICIOUS_STEW: + case SWEET_BERRIES: case TROPICAL_FISH: // ----- Legacy Separator ----- case LEGACY_BREAD: @@ -3948,15 +4334,23 @@ public enum Material implements Keyed { case ACACIA_LOG: case ACACIA_PLANKS: case ACACIA_PRESSURE_PLATE: + case ACACIA_SIGN: case ACACIA_SLAB: case ACACIA_STAIRS: case ACACIA_TRAPDOOR: + case ACACIA_WALL_SIGN: case ACACIA_WOOD: case ANDESITE: + case ANDESITE_SLAB: + case ANDESITE_STAIRS: + case ANDESITE_WALL: case ANVIL: + case BAMBOO: + case BARREL: case BARRIER: case BEACON: case BEDROCK: + case BELL: case BIRCH_DOOR: case BIRCH_FENCE: case BIRCH_FENCE_GATE: @@ -3964,9 +4358,11 @@ public enum Material implements Keyed { case BIRCH_LOG: case BIRCH_PLANKS: case BIRCH_PRESSURE_PLATE: + case BIRCH_SIGN: case BIRCH_SLAB: case BIRCH_STAIRS: case BIRCH_TRAPDOOR: + case BIRCH_WALL_SIGN: case BIRCH_WOOD: case BLACK_BANNER: case BLACK_BED: @@ -3979,6 +4375,7 @@ public enum Material implements Keyed { case BLACK_TERRACOTTA: case BLACK_WALL_BANNER: case BLACK_WOOL: + case BLAST_FURNACE: case BLUE_BANNER: case BLUE_BED: case BLUE_CONCRETE: @@ -3998,6 +4395,7 @@ public enum Material implements Keyed { case BRICKS: case BRICK_SLAB: case BRICK_STAIRS: + case BRICK_WALL: case BROWN_BANNER: case BROWN_BED: case BROWN_CONCRETE: @@ -4013,6 +4411,8 @@ public enum Material implements Keyed { case BUBBLE_CORAL_BLOCK: case CACTUS: case CAKE: + case CAMPFIRE: + case CARTOGRAPHY_TABLE: case CARVED_PUMPKIN: case CAULDRON: case CHAIN_COMMAND_BLOCK: @@ -4031,11 +4431,14 @@ public enum Material implements Keyed { case COBBLESTONE_STAIRS: case COBBLESTONE_WALL: case COMMAND_BLOCK: + case COMPOSTER: case CONDUIT: case CRACKED_STONE_BRICKS: case CRAFTING_TABLE: case CUT_RED_SANDSTONE: + case CUT_RED_SANDSTONE_SLAB: case CUT_SANDSTONE: + case CUT_SANDSTONE_SLAB: case CYAN_BANNER: case CYAN_BED: case CYAN_CONCRETE: @@ -4055,9 +4458,11 @@ public enum Material implements Keyed { case DARK_OAK_LOG: case DARK_OAK_PLANKS: case DARK_OAK_PRESSURE_PLATE: + case DARK_OAK_SIGN: case DARK_OAK_SLAB: case DARK_OAK_STAIRS: case DARK_OAK_TRAPDOOR: + case DARK_OAK_WALL_SIGN: case DARK_OAK_WOOD: case DARK_PRISMARINE: case DARK_PRISMARINE_SLAB: @@ -4086,6 +4491,9 @@ public enum Material implements Keyed { case DIAMOND_BLOCK: case DIAMOND_ORE: case DIORITE: + case DIORITE_SLAB: + case DIORITE_STAIRS: + case DIORITE_WALL: case DIRT: case DISPENSER: case DRAGON_EGG: @@ -4098,8 +4506,12 @@ public enum Material implements Keyed { case END_PORTAL_FRAME: case END_STONE: case END_STONE_BRICKS: + case END_STONE_BRICK_SLAB: + case END_STONE_BRICK_STAIRS: + case END_STONE_BRICK_WALL: case FARMLAND: case FIRE_CORAL_BLOCK: + case FLETCHING_TABLE: case FROSTED_ICE: case FURNACE: case GLASS: @@ -4108,6 +4520,9 @@ public enum Material implements Keyed { case GOLD_BLOCK: case GOLD_ORE: case GRANITE: + case GRANITE_SLAB: + case GRANITE_STAIRS: + case GRANITE_WALL: case GRASS_BLOCK: case GRASS_PATH: case GRAVEL: @@ -4133,6 +4548,7 @@ public enum Material implements Keyed { case GREEN_TERRACOTTA: case GREEN_WALL_BANNER: case GREEN_WOOL: + case GRINDSTONE: case HAY_BLOCK: case HEAVY_WEIGHTED_PRESSURE_PLATE: case HOPPER: @@ -4150,6 +4566,7 @@ public enum Material implements Keyed { case IRON_ORE: case IRON_TRAPDOOR: case JACK_O_LANTERN: + case JIGSAW: case JUKEBOX: case JUNGLE_DOOR: case JUNGLE_FENCE: @@ -4158,12 +4575,16 @@ public enum Material implements Keyed { case JUNGLE_LOG: case JUNGLE_PLANKS: case JUNGLE_PRESSURE_PLATE: + case JUNGLE_SIGN: case JUNGLE_SLAB: case JUNGLE_STAIRS: case JUNGLE_TRAPDOOR: + case JUNGLE_WALL_SIGN: case JUNGLE_WOOD: + case LANTERN: case LAPIS_BLOCK: case LAPIS_ORE: + case LECTERN: case LIGHT_BLUE_BANNER: case LIGHT_BLUE_BED: case LIGHT_BLUE_CONCRETE: @@ -4198,6 +4619,7 @@ public enum Material implements Keyed { case LIME_TERRACOTTA: case LIME_WALL_BANNER: case LIME_WOOL: + case LOOM: case MAGENTA_BANNER: case MAGENTA_BED: case MAGENTA_CONCRETE: @@ -4212,8 +4634,13 @@ public enum Material implements Keyed { case MAGMA_BLOCK: case MELON: case MOSSY_COBBLESTONE: + case MOSSY_COBBLESTONE_SLAB: + case MOSSY_COBBLESTONE_STAIRS: case MOSSY_COBBLESTONE_WALL: case MOSSY_STONE_BRICKS: + case MOSSY_STONE_BRICK_SLAB: + case MOSSY_STONE_BRICK_STAIRS: + case MOSSY_STONE_BRICK_WALL: case MOVING_PISTON: case MUSHROOM_STEM: case MYCELIUM: @@ -4222,6 +4649,7 @@ public enum Material implements Keyed { case NETHER_BRICK_FENCE: case NETHER_BRICK_SLAB: case NETHER_BRICK_STAIRS: + case NETHER_BRICK_WALL: case NETHER_QUARTZ_ORE: case NETHER_WART_BLOCK: case NOTE_BLOCK: @@ -4232,9 +4660,11 @@ public enum Material implements Keyed { case OAK_LOG: case OAK_PLANKS: case OAK_PRESSURE_PLATE: + case OAK_SIGN: case OAK_SLAB: case OAK_STAIRS: case OAK_TRAPDOOR: + case OAK_WALL_SIGN: case OAK_WOOD: case OBSERVER: case OBSIDIAN: @@ -4266,14 +4696,21 @@ public enum Material implements Keyed { case PISTON_HEAD: case PODZOL: case POLISHED_ANDESITE: + case POLISHED_ANDESITE_SLAB: + case POLISHED_ANDESITE_STAIRS: case POLISHED_DIORITE: + case POLISHED_DIORITE_SLAB: + case POLISHED_DIORITE_STAIRS: case POLISHED_GRANITE: + case POLISHED_GRANITE_SLAB: + case POLISHED_GRANITE_STAIRS: case PRISMARINE: case PRISMARINE_BRICKS: case PRISMARINE_BRICK_SLAB: case PRISMARINE_BRICK_STAIRS: case PRISMARINE_SLAB: case PRISMARINE_STAIRS: + case PRISMARINE_WALL: case PUMPKIN: case PURPLE_BANNER: case PURPLE_BED: @@ -4304,10 +4741,14 @@ public enum Material implements Keyed { case RED_GLAZED_TERRACOTTA: case RED_MUSHROOM_BLOCK: case RED_NETHER_BRICKS: + case RED_NETHER_BRICK_SLAB: + case RED_NETHER_BRICK_STAIRS: + case RED_NETHER_BRICK_WALL: case RED_SAND: case RED_SANDSTONE: case RED_SANDSTONE_SLAB: case RED_SANDSTONE_STAIRS: + case RED_SANDSTONE_WALL: case RED_SHULKER_BOX: case RED_STAINED_GLASS: case RED_STAINED_GLASS_PANE: @@ -4319,14 +4760,23 @@ public enum Material implements Keyed { case SANDSTONE: case SANDSTONE_SLAB: case SANDSTONE_STAIRS: + case SANDSTONE_WALL: case SEA_LANTERN: case SHULKER_BOX: - case SIGN: case SLIME_BLOCK: + case SMITHING_TABLE: + case SMOKER: case SMOOTH_QUARTZ: + case SMOOTH_QUARTZ_SLAB: + case SMOOTH_QUARTZ_STAIRS: case SMOOTH_RED_SANDSTONE: + case SMOOTH_RED_SANDSTONE_SLAB: + case SMOOTH_RED_SANDSTONE_STAIRS: case SMOOTH_SANDSTONE: + case SMOOTH_SANDSTONE_SLAB: + case SMOOTH_SANDSTONE_STAIRS: case SMOOTH_STONE: + case SMOOTH_STONE_SLAB: case SNOW_BLOCK: case SOUL_SAND: case SPAWNER: @@ -4338,17 +4788,22 @@ public enum Material implements Keyed { case SPRUCE_LOG: case SPRUCE_PLANKS: case SPRUCE_PRESSURE_PLATE: + case SPRUCE_SIGN: case SPRUCE_SLAB: case SPRUCE_STAIRS: case SPRUCE_TRAPDOOR: + case SPRUCE_WALL_SIGN: case SPRUCE_WOOD: case STICKY_PISTON: case STONE: + case STONECUTTER: case STONE_BRICKS: case STONE_BRICK_SLAB: case STONE_BRICK_STAIRS: + case STONE_BRICK_WALL: case STONE_PRESSURE_PLATE: case STONE_SLAB: + case STONE_STAIRS: case STRIPPED_ACACIA_LOG: case STRIPPED_ACACIA_WOOD: case STRIPPED_BIRCH_LOG: @@ -4367,7 +4822,6 @@ public enum Material implements Keyed { case TRAPPED_CHEST: case TUBE_CORAL_BLOCK: case TURTLE_EGG: - case WALL_SIGN: case WET_SPONGE: case WHITE_BANNER: case WHITE_BED: @@ -4598,6 +5052,26 @@ public enum Material implements Keyed { } } + /** + * Check if the material is an air block. + * + * @return True if this material is an air block. + */ + public boolean isAir() { + switch (this) { + // + case AIR: + case CAVE_AIR: + case VOID_AIR: + // ----- Legacy Separator ----- + case LEGACY_AIR: + // + return true; + default: + return false; + } + } + /** * Check if the material is a block and does not block any light * @@ -4813,10 +5287,15 @@ public enum Material implements Keyed { case ACACIA_LOG: case ACACIA_PLANKS: case ACACIA_PRESSURE_PLATE: + case ACACIA_SIGN: case ACACIA_SLAB: case ACACIA_STAIRS: case ACACIA_TRAPDOOR: + case ACACIA_WALL_SIGN: case ACACIA_WOOD: + case BAMBOO: + case BAMBOO_SAPLING: + case BARREL: case BIRCH_DOOR: case BIRCH_FENCE: case BIRCH_FENCE_GATE: @@ -4824,9 +5303,11 @@ public enum Material implements Keyed { case BIRCH_LOG: case BIRCH_PLANKS: case BIRCH_PRESSURE_PLATE: + case BIRCH_SIGN: case BIRCH_SLAB: case BIRCH_STAIRS: case BIRCH_TRAPDOOR: + case BIRCH_WALL_SIGN: case BIRCH_WOOD: case BLACK_BANNER: case BLACK_BED: @@ -4845,7 +5326,10 @@ public enum Material implements Keyed { case BROWN_MUSHROOM_BLOCK: case BROWN_WALL_BANNER: case BROWN_WOOL: + case CAMPFIRE: + case CARTOGRAPHY_TABLE: case CHEST: + case COMPOSTER: case CRAFTING_TABLE: case CYAN_BANNER: case CYAN_BED: @@ -4859,13 +5343,16 @@ public enum Material implements Keyed { case DARK_OAK_LOG: case DARK_OAK_PLANKS: case DARK_OAK_PRESSURE_PLATE: + case DARK_OAK_SIGN: case DARK_OAK_SLAB: case DARK_OAK_STAIRS: case DARK_OAK_TRAPDOOR: + case DARK_OAK_WALL_SIGN: case DARK_OAK_WOOD: case DAYLIGHT_DETECTOR: case DEAD_BUSH: case FERN: + case FLETCHING_TABLE: case GRASS: case GRAY_BANNER: case GRAY_BED: @@ -4885,11 +5372,14 @@ public enum Material implements Keyed { case JUNGLE_LOG: case JUNGLE_PLANKS: case JUNGLE_PRESSURE_PLATE: + case JUNGLE_SIGN: case JUNGLE_SLAB: case JUNGLE_STAIRS: case JUNGLE_TRAPDOOR: + case JUNGLE_WALL_SIGN: case JUNGLE_WOOD: case LARGE_FERN: + case LECTERN: case LIGHT_BLUE_BANNER: case LIGHT_BLUE_BED: case LIGHT_BLUE_CARPET: @@ -4906,6 +5396,7 @@ public enum Material implements Keyed { case LIME_CARPET: case LIME_WALL_BANNER: case LIME_WOOL: + case LOOM: case MAGENTA_BANNER: case MAGENTA_BED: case MAGENTA_CARPET: @@ -4920,9 +5411,11 @@ public enum Material implements Keyed { case OAK_LOG: case OAK_PLANKS: case OAK_PRESSURE_PLATE: + case OAK_SIGN: case OAK_SLAB: case OAK_STAIRS: case OAK_TRAPDOOR: + case OAK_WALL_SIGN: case OAK_WOOD: case ORANGE_BANNER: case ORANGE_BED: @@ -4947,7 +5440,7 @@ public enum Material implements Keyed { case RED_WALL_BANNER: case RED_WOOL: case ROSE_BUSH: - case SIGN: + case SMITHING_TABLE: case SPRUCE_DOOR: case SPRUCE_FENCE: case SPRUCE_FENCE_GATE: @@ -4955,9 +5448,11 @@ public enum Material implements Keyed { case SPRUCE_LOG: case SPRUCE_PLANKS: case SPRUCE_PRESSURE_PLATE: + case SPRUCE_SIGN: case SPRUCE_SLAB: case SPRUCE_STAIRS: case SPRUCE_TRAPDOOR: + case SPRUCE_WALL_SIGN: case SPRUCE_WOOD: case STRIPPED_ACACIA_LOG: case STRIPPED_ACACIA_WOOD: @@ -4976,7 +5471,6 @@ public enum Material implements Keyed { case TNT: case TRAPPED_CHEST: case VINE: - case WALL_SIGN: case WHITE_BANNER: case WHITE_BED: case WHITE_CARPET: @@ -5071,6 +5565,7 @@ public enum Material implements Keyed { case ACACIA_WOOD: case ALLIUM: case AZURE_BLUET: + case BAMBOO: case BIRCH_FENCE: case BIRCH_FENCE_GATE: case BIRCH_LEAVES: @@ -5088,6 +5583,8 @@ public enum Material implements Keyed { case BROWN_CARPET: case BROWN_WOOL: case COAL_BLOCK: + case COMPOSTER: + case CORNFLOWER: case CYAN_CARPET: case CYAN_WOOL: case DANDELION: @@ -5117,11 +5614,13 @@ public enum Material implements Keyed { case JUNGLE_STAIRS: case JUNGLE_WOOD: case LARGE_FERN: + case LECTERN: case LIGHT_BLUE_CARPET: case LIGHT_BLUE_WOOL: case LIGHT_GRAY_CARPET: case LIGHT_GRAY_WOOL: case LILAC: + case LILY_OF_THE_VALLEY: case LIME_CARPET: case LIME_WOOL: case MAGENTA_CARPET: @@ -5149,6 +5648,7 @@ public enum Material implements Keyed { case RED_TULIP: case RED_WOOL: case ROSE_BUSH: + case SCAFFOLDING: case SPRUCE_FENCE: case SPRUCE_FENCE_GATE: case SPRUCE_LEAVES: @@ -5170,12 +5670,14 @@ public enum Material implements Keyed { case STRIPPED_SPRUCE_LOG: case STRIPPED_SPRUCE_WOOD: case SUNFLOWER: + case SWEET_BERRY_BUSH: case TALL_GRASS: case TNT: case VINE: case WHITE_CARPET: case WHITE_TULIP: case WHITE_WOOL: + case WITHER_ROSE: case YELLOW_CARPET: case YELLOW_WOOL: // ----- Legacy Separator ----- @@ -5240,10 +5742,13 @@ public enum Material implements Keyed { case ACACIA_PLANKS: case ACACIA_PRESSURE_PLATE: case ACACIA_SAPLING: + case ACACIA_SIGN: case ACACIA_SLAB: case ACACIA_STAIRS: case ACACIA_TRAPDOOR: case ACACIA_WOOD: + case BAMBOO: + case BARREL: case BIRCH_BOAT: case BIRCH_BUTTON: case BIRCH_DOOR: @@ -5253,6 +5758,7 @@ public enum Material implements Keyed { case BIRCH_PLANKS: case BIRCH_PRESSURE_PLATE: case BIRCH_SAPLING: + case BIRCH_SIGN: case BIRCH_SLAB: case BIRCH_STAIRS: case BIRCH_TRAPDOOR: @@ -5270,11 +5776,14 @@ public enum Material implements Keyed { case BROWN_BANNER: case BROWN_CARPET: case BROWN_WOOL: + case CARTOGRAPHY_TABLE: case CHARCOAL: case CHEST: case COAL: case COAL_BLOCK: + case COMPOSTER: case CRAFTING_TABLE: + case CROSSBOW: case CYAN_BANNER: case CYAN_CARPET: case CYAN_WOOL: @@ -5287,13 +5796,16 @@ public enum Material implements Keyed { case DARK_OAK_PLANKS: case DARK_OAK_PRESSURE_PLATE: case DARK_OAK_SAPLING: + case DARK_OAK_SIGN: case DARK_OAK_SLAB: case DARK_OAK_STAIRS: case DARK_OAK_TRAPDOOR: case DARK_OAK_WOOD: case DAYLIGHT_DETECTOR: + case DEAD_BUSH: case DRIED_KELP_BLOCK: case FISHING_ROD: + case FLETCHING_TABLE: case GRAY_BANNER: case GRAY_CARPET: case GRAY_WOOL: @@ -5310,12 +5822,14 @@ public enum Material implements Keyed { case JUNGLE_PLANKS: case JUNGLE_PRESSURE_PLATE: case JUNGLE_SAPLING: + case JUNGLE_SIGN: case JUNGLE_SLAB: case JUNGLE_STAIRS: case JUNGLE_TRAPDOOR: case JUNGLE_WOOD: case LADDER: case LAVA_BUCKET: + case LECTERN: case LIGHT_BLUE_BANNER: case LIGHT_BLUE_CARPET: case LIGHT_BLUE_WOOL: @@ -5325,6 +5839,7 @@ public enum Material implements Keyed { case LIME_BANNER: case LIME_CARPET: case LIME_WOOL: + case LOOM: case MAGENTA_BANNER: case MAGENTA_CARPET: case MAGENTA_WOOL: @@ -5338,6 +5853,7 @@ public enum Material implements Keyed { case OAK_PLANKS: case OAK_PRESSURE_PLATE: case OAK_SAPLING: + case OAK_SIGN: case OAK_SLAB: case OAK_STAIRS: case OAK_TRAPDOOR: @@ -5354,7 +5870,8 @@ public enum Material implements Keyed { case RED_BANNER: case RED_CARPET: case RED_WOOL: - case SIGN: + case SCAFFOLDING: + case SMITHING_TABLE: case SPRUCE_BOAT: case SPRUCE_BUTTON: case SPRUCE_DOOR: @@ -5364,6 +5881,7 @@ public enum Material implements Keyed { case SPRUCE_PLANKS: case SPRUCE_PRESSURE_PLATE: case SPRUCE_SAPLING: + case SPRUCE_SIGN: case SPRUCE_SLAB: case SPRUCE_STAIRS: case SPRUCE_TRAPDOOR: @@ -5479,6 +5997,7 @@ public enum Material implements Keyed { case ACACIA_PLANKS: case ACACIA_WOOD: case ANDESITE: + case BARREL: case BARRIER: case BEDROCK: case BIRCH_LOG: @@ -5487,12 +6006,15 @@ public enum Material implements Keyed { case BLACK_CONCRETE: case BLACK_CONCRETE_POWDER: case BLACK_GLAZED_TERRACOTTA: + case BLACK_SHULKER_BOX: case BLACK_TERRACOTTA: case BLACK_WOOL: + case BLAST_FURNACE: case BLUE_CONCRETE: case BLUE_CONCRETE_POWDER: case BLUE_GLAZED_TERRACOTTA: case BLUE_ICE: + case BLUE_SHULKER_BOX: case BLUE_TERRACOTTA: case BLUE_WOOL: case BONE_BLOCK: @@ -5503,9 +6025,11 @@ public enum Material implements Keyed { case BROWN_CONCRETE_POWDER: case BROWN_GLAZED_TERRACOTTA: case BROWN_MUSHROOM_BLOCK: + case BROWN_SHULKER_BOX: case BROWN_TERRACOTTA: case BROWN_WOOL: case BUBBLE_CORAL_BLOCK: + case CARTOGRAPHY_TABLE: case CARVED_PUMPKIN: case CHAIN_COMMAND_BLOCK: case CHISELED_QUARTZ_BLOCK: @@ -5525,6 +6049,7 @@ public enum Material implements Keyed { case CYAN_CONCRETE: case CYAN_CONCRETE_POWDER: case CYAN_GLAZED_TERRACOTTA: + case CYAN_SHULKER_BOX: case CYAN_TERRACOTTA: case CYAN_WOOL: case DARK_OAK_LOG: @@ -5548,6 +6073,7 @@ public enum Material implements Keyed { case END_STONE: case END_STONE_BRICKS: case FIRE_CORAL_BLOCK: + case FLETCHING_TABLE: case FURNACE: case GOLD_BLOCK: case GOLD_ORE: @@ -5557,11 +6083,13 @@ public enum Material implements Keyed { case GRAY_CONCRETE: case GRAY_CONCRETE_POWDER: case GRAY_GLAZED_TERRACOTTA: + case GRAY_SHULKER_BOX: case GRAY_TERRACOTTA: case GRAY_WOOL: case GREEN_CONCRETE: case GREEN_CONCRETE_POWDER: case GREEN_GLAZED_TERRACOTTA: + case GREEN_SHULKER_BOX: case GREEN_TERRACOTTA: case GREEN_WOOL: case HAY_BLOCK: @@ -5575,6 +6103,7 @@ public enum Material implements Keyed { case IRON_BLOCK: case IRON_ORE: case JACK_O_LANTERN: + case JIGSAW: case JUKEBOX: case JUNGLE_LOG: case JUNGLE_PLANKS: @@ -5584,21 +6113,26 @@ public enum Material implements Keyed { case LIGHT_BLUE_CONCRETE: case LIGHT_BLUE_CONCRETE_POWDER: case LIGHT_BLUE_GLAZED_TERRACOTTA: + case LIGHT_BLUE_SHULKER_BOX: case LIGHT_BLUE_TERRACOTTA: case LIGHT_BLUE_WOOL: case LIGHT_GRAY_CONCRETE: case LIGHT_GRAY_CONCRETE_POWDER: case LIGHT_GRAY_GLAZED_TERRACOTTA: + case LIGHT_GRAY_SHULKER_BOX: case LIGHT_GRAY_TERRACOTTA: case LIGHT_GRAY_WOOL: case LIME_CONCRETE: case LIME_CONCRETE_POWDER: case LIME_GLAZED_TERRACOTTA: + case LIME_SHULKER_BOX: case LIME_TERRACOTTA: case LIME_WOOL: + case LOOM: case MAGENTA_CONCRETE: case MAGENTA_CONCRETE_POWDER: case MAGENTA_GLAZED_TERRACOTTA: + case MAGENTA_SHULKER_BOX: case MAGENTA_TERRACOTTA: case MAGENTA_WOOL: case MAGMA_BLOCK: @@ -5619,12 +6153,14 @@ public enum Material implements Keyed { case ORANGE_CONCRETE: case ORANGE_CONCRETE_POWDER: case ORANGE_GLAZED_TERRACOTTA: + case ORANGE_SHULKER_BOX: case ORANGE_TERRACOTTA: case ORANGE_WOOL: case PACKED_ICE: case PINK_CONCRETE: case PINK_CONCRETE_POWDER: case PINK_GLAZED_TERRACOTTA: + case PINK_SHULKER_BOX: case PINK_TERRACOTTA: case PINK_WOOL: case PODZOL: @@ -5637,6 +6173,7 @@ public enum Material implements Keyed { case PURPLE_CONCRETE: case PURPLE_CONCRETE_POWDER: case PURPLE_GLAZED_TERRACOTTA: + case PURPLE_SHULKER_BOX: case PURPLE_TERRACOTTA: case PURPLE_WOOL: case PURPUR_BLOCK: @@ -5652,12 +6189,16 @@ public enum Material implements Keyed { case RED_NETHER_BRICKS: case RED_SAND: case RED_SANDSTONE: + case RED_SHULKER_BOX: case RED_TERRACOTTA: case RED_WOOL: case REPEATING_COMMAND_BLOCK: case SAND: case SANDSTONE: + case SHULKER_BOX: case SLIME_BLOCK: + case SMITHING_TABLE: + case SMOKER: case SMOOTH_QUARTZ: case SMOOTH_RED_SANDSTONE: case SMOOTH_SANDSTONE: @@ -5690,11 +6231,13 @@ public enum Material implements Keyed { case WHITE_CONCRETE: case WHITE_CONCRETE_POWDER: case WHITE_GLAZED_TERRACOTTA: + case WHITE_SHULKER_BOX: case WHITE_TERRACOTTA: case WHITE_WOOL: case YELLOW_CONCRETE: case YELLOW_CONCRETE_POWDER: case YELLOW_GLAZED_TERRACOTTA: + case YELLOW_SHULKER_BOX: case YELLOW_TERRACOTTA: case YELLOW_WOOL: // ----- Legacy Separator ----- @@ -5855,9 +6398,12 @@ public enum Material implements Keyed { public boolean isItem() { switch (this) { // + case ACACIA_WALL_SIGN: case ATTACHED_MELON_STEM: case ATTACHED_PUMPKIN_STEM: + case BAMBOO_SAPLING: case BEETROOTS: + case BIRCH_WALL_SIGN: case BLACK_WALL_BANNER: case BLUE_WALL_BANNER: case BRAIN_CORAL_WALL_FAN: @@ -5869,6 +6415,7 @@ public enum Material implements Keyed { case COCOA: case CREEPER_WALL_HEAD: case CYAN_WALL_BANNER: + case DARK_OAK_WALL_SIGN: case DEAD_BRAIN_CORAL_WALL_FAN: case DEAD_BUBBLE_CORAL_WALL_FAN: case DEAD_FIRE_CORAL_WALL_FAN: @@ -5883,6 +6430,7 @@ public enum Material implements Keyed { case GRAY_WALL_BANNER: case GREEN_WALL_BANNER: case HORN_CORAL_WALL_FAN: + case JUNGLE_WALL_SIGN: case KELP_PLANT: case LAVA: case LIGHT_BLUE_WALL_BANNER: @@ -5892,6 +6440,7 @@ public enum Material implements Keyed { case MELON_STEM: case MOVING_PISTON: case NETHER_PORTAL: + case OAK_WALL_SIGN: case ORANGE_WALL_BANNER: case PINK_WALL_BANNER: case PISTON_HEAD: @@ -5900,15 +6449,18 @@ public enum Material implements Keyed { case POTTED_ACACIA_SAPLING: case POTTED_ALLIUM: case POTTED_AZURE_BLUET: + case POTTED_BAMBOO: case POTTED_BIRCH_SAPLING: case POTTED_BLUE_ORCHID: case POTTED_BROWN_MUSHROOM: case POTTED_CACTUS: + case POTTED_CORNFLOWER: case POTTED_DANDELION: case POTTED_DARK_OAK_SAPLING: case POTTED_DEAD_BUSH: case POTTED_FERN: case POTTED_JUNGLE_SAPLING: + case POTTED_LILY_OF_THE_VALLEY: case POTTED_OAK_SAPLING: case POTTED_ORANGE_TULIP: case POTTED_OXEYE_DAISY: @@ -5918,17 +6470,19 @@ public enum Material implements Keyed { case POTTED_RED_TULIP: case POTTED_SPRUCE_SAPLING: case POTTED_WHITE_TULIP: + case POTTED_WITHER_ROSE: case PUMPKIN_STEM: case PURPLE_WALL_BANNER: case REDSTONE_WALL_TORCH: case REDSTONE_WIRE: case RED_WALL_BANNER: case SKELETON_WALL_SKULL: + case SPRUCE_WALL_SIGN: + case SWEET_BERRY_BUSH: case TALL_SEAGRASS: case TRIPWIRE: case TUBE_CORAL_WALL_FAN: case VOID_AIR: - case WALL_SIGN: case WALL_TORCH: case WATER: case WHITE_WALL_BANNER: @@ -6018,18 +6572,26 @@ public enum Material implements Keyed { case ACACIA_DOOR: case ACACIA_FENCE: case ACACIA_FENCE_GATE: + case ACACIA_SIGN: case ACACIA_STAIRS: case ACACIA_TRAPDOOR: + case ACACIA_WALL_SIGN: + case ANDESITE_STAIRS: case ANVIL: + case BARREL: case BEACON: + case BELL: case BIRCH_BUTTON: case BIRCH_DOOR: case BIRCH_FENCE: case BIRCH_FENCE_GATE: + case BIRCH_SIGN: case BIRCH_STAIRS: case BIRCH_TRAPDOOR: + case BIRCH_WALL_SIGN: case BLACK_BED: case BLACK_SHULKER_BOX: + case BLAST_FURNACE: case BLUE_BED: case BLUE_SHULKER_BOX: case BREWING_STAND: @@ -6037,6 +6599,8 @@ public enum Material implements Keyed { case BROWN_BED: case BROWN_SHULKER_BOX: case CAKE: + case CAMPFIRE: + case CARTOGRAPHY_TABLE: case CAULDRON: case CHAIN_COMMAND_BLOCK: case CHEST: @@ -6044,6 +6608,7 @@ public enum Material implements Keyed { case COBBLESTONE_STAIRS: case COMMAND_BLOCK: case COMPARATOR: + case COMPOSTER: case CRAFTING_TABLE: case CYAN_BED: case CYAN_SHULKER_BOX: @@ -6052,31 +6617,42 @@ public enum Material implements Keyed { case DARK_OAK_DOOR: case DARK_OAK_FENCE: case DARK_OAK_FENCE_GATE: + case DARK_OAK_SIGN: case DARK_OAK_STAIRS: case DARK_OAK_TRAPDOOR: + case DARK_OAK_WALL_SIGN: case DARK_PRISMARINE_STAIRS: case DAYLIGHT_DETECTOR: + case DIORITE_STAIRS: case DISPENSER: case DRAGON_EGG: case DROPPER: case ENCHANTING_TABLE: case ENDER_CHEST: + case END_STONE_BRICK_STAIRS: + case FLETCHING_TABLE: case FLOWER_POT: case FURNACE: + case GRANITE_STAIRS: case GRAY_BED: case GRAY_SHULKER_BOX: case GREEN_BED: case GREEN_SHULKER_BOX: + case GRINDSTONE: case HOPPER: case IRON_DOOR: case IRON_TRAPDOOR: + case JIGSAW: case JUKEBOX: case JUNGLE_BUTTON: case JUNGLE_DOOR: case JUNGLE_FENCE: case JUNGLE_FENCE_GATE: + case JUNGLE_SIGN: case JUNGLE_STAIRS: case JUNGLE_TRAPDOOR: + case JUNGLE_WALL_SIGN: + case LECTERN: case LEVER: case LIGHT_BLUE_BED: case LIGHT_BLUE_SHULKER_BOX: @@ -6084,8 +6660,11 @@ public enum Material implements Keyed { case LIGHT_GRAY_SHULKER_BOX: case LIME_BED: case LIME_SHULKER_BOX: + case LOOM: case MAGENTA_BED: case MAGENTA_SHULKER_BOX: + case MOSSY_COBBLESTONE_STAIRS: + case MOSSY_STONE_BRICK_STAIRS: case MOVING_PISTON: case NETHER_BRICK_FENCE: case NETHER_BRICK_STAIRS: @@ -6094,24 +6673,32 @@ public enum Material implements Keyed { case OAK_DOOR: case OAK_FENCE: case OAK_FENCE_GATE: + case OAK_SIGN: case OAK_STAIRS: case OAK_TRAPDOOR: + case OAK_WALL_SIGN: case ORANGE_BED: case ORANGE_SHULKER_BOX: case PINK_BED: case PINK_SHULKER_BOX: + case POLISHED_ANDESITE_STAIRS: + case POLISHED_DIORITE_STAIRS: + case POLISHED_GRANITE_STAIRS: case POTTED_ACACIA_SAPLING: case POTTED_ALLIUM: case POTTED_AZURE_BLUET: + case POTTED_BAMBOO: case POTTED_BIRCH_SAPLING: case POTTED_BLUE_ORCHID: case POTTED_BROWN_MUSHROOM: case POTTED_CACTUS: + case POTTED_CORNFLOWER: case POTTED_DANDELION: case POTTED_DARK_OAK_SAPLING: case POTTED_DEAD_BUSH: case POTTED_FERN: case POTTED_JUNGLE_SAPLING: + case POTTED_LILY_OF_THE_VALLEY: case POTTED_OAK_SAPLING: case POTTED_ORANGE_TULIP: case POTTED_OXEYE_DAISY: @@ -6121,6 +6708,7 @@ public enum Material implements Keyed { case POTTED_RED_TULIP: case POTTED_SPRUCE_SAPLING: case POTTED_WHITE_TULIP: + case POTTED_WITHER_ROSE: case PRISMARINE_BRICK_STAIRS: case PRISMARINE_STAIRS: case PUMPKIN: @@ -6130,25 +6718,34 @@ public enum Material implements Keyed { case QUARTZ_STAIRS: case REDSTONE_ORE: case RED_BED: + case RED_NETHER_BRICK_STAIRS: case RED_SANDSTONE_STAIRS: case RED_SHULKER_BOX: case REPEATER: case REPEATING_COMMAND_BLOCK: case SANDSTONE_STAIRS: case SHULKER_BOX: - case SIGN: + case SMITHING_TABLE: + case SMOKER: + case SMOOTH_QUARTZ_STAIRS: + case SMOOTH_RED_SANDSTONE_STAIRS: + case SMOOTH_SANDSTONE_STAIRS: case SPRUCE_BUTTON: case SPRUCE_DOOR: case SPRUCE_FENCE: case SPRUCE_FENCE_GATE: + case SPRUCE_SIGN: case SPRUCE_STAIRS: case SPRUCE_TRAPDOOR: + case SPRUCE_WALL_SIGN: + case STONECUTTER: case STONE_BRICK_STAIRS: case STONE_BUTTON: + case STONE_STAIRS: case STRUCTURE_BLOCK: + case SWEET_BERRY_BUSH: case TNT: case TRAPPED_CHEST: - case WALL_SIGN: case WHITE_BED: case WHITE_SHULKER_BOX: case YELLOW_BED: @@ -6180,6 +6777,7 @@ public enum Material implements Keyed { case END_GATEWAY: case END_PORTAL: case END_PORTAL_FRAME: + case JIGSAW: case MOVING_PISTON: case NETHER_PORTAL: case REPEATING_COMMAND_BLOCK: @@ -6330,6 +6928,7 @@ public enum Material implements Keyed { case YELLOW_CONCRETE_POWDER: return 0.5F; case CLAY: + case COMPOSTER: case FARMLAND: case GRASS_BLOCK: case GRAVEL: @@ -6354,6 +6953,9 @@ public enum Material implements Keyed { case CUT_SANDSTONE: case CYAN_WOOL: case END_STONE_BRICKS: + case END_STONE_BRICK_SLAB: + case END_STONE_BRICK_STAIRS: + case END_STONE_BRICK_WALL: case GRAY_WOOL: case GREEN_WOOL: case LIGHT_BLUE_WOOL: @@ -6369,12 +6971,20 @@ public enum Material implements Keyed { case QUARTZ_STAIRS: case RED_SANDSTONE: case RED_SANDSTONE_STAIRS: + case RED_SANDSTONE_WALL: case RED_WOOL: case SANDSTONE: case SANDSTONE_STAIRS: + case SANDSTONE_WALL: case WHITE_WOOL: case YELLOW_WOOL: return 0.8F; + case ACACIA_SIGN: + case ACACIA_WALL_SIGN: + case BAMBOO: + case BAMBOO_SAPLING: + case BIRCH_SIGN: + case BIRCH_WALL_SIGN: case BLACK_BANNER: case BLACK_WALL_BANNER: case BLUE_BANNER: @@ -6386,6 +6996,8 @@ public enum Material implements Keyed { case CREEPER_WALL_HEAD: case CYAN_BANNER: case CYAN_WALL_BANNER: + case DARK_OAK_SIGN: + case DARK_OAK_WALL_SIGN: case DRAGON_HEAD: case DRAGON_WALL_HEAD: case GRAY_BANNER: @@ -6393,6 +7005,8 @@ public enum Material implements Keyed { case GREEN_BANNER: case GREEN_WALL_BANNER: case JACK_O_LANTERN: + case JUNGLE_SIGN: + case JUNGLE_WALL_SIGN: case LIGHT_BLUE_BANNER: case LIGHT_BLUE_WALL_BANNER: case LIGHT_GRAY_BANNER: @@ -6403,6 +7017,8 @@ public enum Material implements Keyed { case MAGENTA_WALL_BANNER: case MELON: case NETHER_WART_BLOCK: + case OAK_SIGN: + case OAK_WALL_SIGN: case ORANGE_BANNER: case ORANGE_WALL_BANNER: case PINK_BANNER: @@ -6414,10 +7030,10 @@ public enum Material implements Keyed { case PURPLE_WALL_BANNER: case RED_BANNER: case RED_WALL_BANNER: - case SIGN: case SKELETON_SKULL: case SKELETON_WALL_SKULL: - case WALL_SIGN: + case SPRUCE_SIGN: + case SPRUCE_WALL_SIGN: case WHITE_BANNER: case WHITE_WALL_BANNER: case WITHER_SKELETON_SKULL: @@ -6463,6 +7079,9 @@ public enum Material implements Keyed { case YELLOW_GLAZED_TERRACOTTA: return 1.4F; case ANDESITE: + case ANDESITE_SLAB: + case ANDESITE_STAIRS: + case ANDESITE_WALL: case BOOKSHELF: case BRAIN_CORAL_BLOCK: case BUBBLE_CORAL_BLOCK: @@ -6477,25 +7096,43 @@ public enum Material implements Keyed { case DEAD_HORN_CORAL_BLOCK: case DEAD_TUBE_CORAL_BLOCK: case DIORITE: + case DIORITE_SLAB: + case DIORITE_STAIRS: + case DIORITE_WALL: case FIRE_CORAL_BLOCK: case GRANITE: + case GRANITE_SLAB: + case GRANITE_STAIRS: + case GRANITE_WALL: case HORN_CORAL_BLOCK: case MOSSY_STONE_BRICKS: + case MOSSY_STONE_BRICK_SLAB: + case MOSSY_STONE_BRICK_STAIRS: + case MOSSY_STONE_BRICK_WALL: case POLISHED_ANDESITE: + case POLISHED_ANDESITE_SLAB: + case POLISHED_ANDESITE_STAIRS: case POLISHED_DIORITE: + case POLISHED_DIORITE_SLAB: + case POLISHED_DIORITE_STAIRS: case POLISHED_GRANITE: + case POLISHED_GRANITE_SLAB: + case POLISHED_GRANITE_STAIRS: case PRISMARINE: case PRISMARINE_BRICKS: case PRISMARINE_BRICK_SLAB: case PRISMARINE_BRICK_STAIRS: case PRISMARINE_SLAB: case PRISMARINE_STAIRS: + case PRISMARINE_WALL: case PURPUR_BLOCK: case PURPUR_PILLAR: case PURPUR_STAIRS: case STONE: case STONE_BRICKS: case STONE_BRICK_STAIRS: + case STONE_BRICK_WALL: + case STONE_STAIRS: case TUBE_CORAL_BLOCK: return 1.5F; case BLACK_CONCRETE: @@ -6535,12 +7172,16 @@ public enum Material implements Keyed { case BRICKS: case BRICK_SLAB: case BRICK_STAIRS: + case BRICK_WALL: case BROWN_SHULKER_BOX: + case CAMPFIRE: case CAULDRON: case COBBLESTONE: case COBBLESTONE_SLAB: case COBBLESTONE_STAIRS: case COBBLESTONE_WALL: + case CUT_RED_SANDSTONE_SLAB: + case CUT_SANDSTONE_SLAB: case CYAN_SHULKER_BOX: case DARK_OAK_FENCE: case DARK_OAK_FENCE_GATE: @@ -6551,6 +7192,7 @@ public enum Material implements Keyed { case DARK_OAK_WOOD: case GRAY_SHULKER_BOX: case GREEN_SHULKER_BOX: + case GRINDSTONE: case JUKEBOX: case JUNGLE_FENCE: case JUNGLE_FENCE_GATE: @@ -6564,11 +7206,14 @@ public enum Material implements Keyed { case LIME_SHULKER_BOX: case MAGENTA_SHULKER_BOX: case MOSSY_COBBLESTONE: + case MOSSY_COBBLESTONE_SLAB: + case MOSSY_COBBLESTONE_STAIRS: case MOSSY_COBBLESTONE_WALL: case NETHER_BRICKS: case NETHER_BRICK_FENCE: case NETHER_BRICK_SLAB: case NETHER_BRICK_STAIRS: + case NETHER_BRICK_WALL: case OAK_FENCE: case OAK_FENCE_GATE: case OAK_LOG: @@ -6583,14 +7228,24 @@ public enum Material implements Keyed { case PURPUR_SLAB: case QUARTZ_SLAB: case RED_NETHER_BRICKS: + case RED_NETHER_BRICK_SLAB: + case RED_NETHER_BRICK_STAIRS: + case RED_NETHER_BRICK_WALL: case RED_SANDSTONE_SLAB: case RED_SHULKER_BOX: case SANDSTONE_SLAB: case SHULKER_BOX: case SMOOTH_QUARTZ: + case SMOOTH_QUARTZ_SLAB: + case SMOOTH_QUARTZ_STAIRS: case SMOOTH_RED_SANDSTONE: + case SMOOTH_RED_SANDSTONE_SLAB: + case SMOOTH_RED_SANDSTONE_STAIRS: case SMOOTH_SANDSTONE: + case SMOOTH_SANDSTONE_SLAB: + case SMOOTH_SANDSTONE_STAIRS: case SMOOTH_STONE: + case SMOOTH_STONE_SLAB: case SPRUCE_FENCE: case SPRUCE_FENCE_GATE: case SPRUCE_LOG: @@ -6615,8 +7270,14 @@ public enum Material implements Keyed { case WHITE_SHULKER_BOX: case YELLOW_SHULKER_BOX: return 2.0F; + case BARREL: + case CARTOGRAPHY_TABLE: case CHEST: case CRAFTING_TABLE: + case FLETCHING_TABLE: + case LECTERN: + case LOOM: + case SMITHING_TABLE: case TRAPPED_CHEST: return 2.5F; case BLUE_ICE: @@ -6650,13 +7311,18 @@ public enum Material implements Keyed { case SPRUCE_DOOR: case SPRUCE_TRAPDOOR: return 3.0F; + case BLAST_FURNACE: case DISPENSER: case DROPPER: case FURNACE: + case LANTERN: + case SMOKER: + case STONECUTTER: return 3.5F; case COBWEB: return 4.0F; case ANVIL: + case BELL: case CHIPPED_ANVIL: case COAL_BLOCK: case DAMAGED_ANVIL: @@ -6840,6 +7506,7 @@ public enum Material implements Keyed { case YELLOW_CONCRETE_POWDER: return 0.5F; case CLAY: + case COMPOSTER: case FARMLAND: case GRASS_BLOCK: case GRAVEL: @@ -6871,6 +7538,9 @@ public enum Material implements Keyed { case CUT_SANDSTONE: case CYAN_WOOL: case END_STONE_BRICKS: + case END_STONE_BRICK_SLAB: + case END_STONE_BRICK_STAIRS: + case END_STONE_BRICK_WALL: case GRAY_WOOL: case GREEN_WOOL: case LIGHT_BLUE_WOOL: @@ -6886,12 +7556,20 @@ public enum Material implements Keyed { case QUARTZ_STAIRS: case RED_SANDSTONE: case RED_SANDSTONE_STAIRS: + case RED_SANDSTONE_WALL: case RED_WOOL: case SANDSTONE: case SANDSTONE_STAIRS: + case SANDSTONE_WALL: case WHITE_WOOL: case YELLOW_WOOL: return 0.8F; + case ACACIA_SIGN: + case ACACIA_WALL_SIGN: + case BAMBOO: + case BAMBOO_SAPLING: + case BIRCH_SIGN: + case BIRCH_WALL_SIGN: case BLACK_BANNER: case BLACK_WALL_BANNER: case BLUE_BANNER: @@ -6903,6 +7581,8 @@ public enum Material implements Keyed { case CREEPER_WALL_HEAD: case CYAN_BANNER: case CYAN_WALL_BANNER: + case DARK_OAK_SIGN: + case DARK_OAK_WALL_SIGN: case DRAGON_HEAD: case DRAGON_WALL_HEAD: case GRAY_BANNER: @@ -6910,6 +7590,8 @@ public enum Material implements Keyed { case GREEN_BANNER: case GREEN_WALL_BANNER: case JACK_O_LANTERN: + case JUNGLE_SIGN: + case JUNGLE_WALL_SIGN: case LIGHT_BLUE_BANNER: case LIGHT_BLUE_WALL_BANNER: case LIGHT_GRAY_BANNER: @@ -6920,6 +7602,8 @@ public enum Material implements Keyed { case MAGENTA_WALL_BANNER: case MELON: case NETHER_WART_BLOCK: + case OAK_SIGN: + case OAK_WALL_SIGN: case ORANGE_BANNER: case ORANGE_WALL_BANNER: case PINK_BANNER: @@ -6931,10 +7615,10 @@ public enum Material implements Keyed { case PURPLE_WALL_BANNER: case RED_BANNER: case RED_WALL_BANNER: - case SIGN: case SKELETON_SKULL: case SKELETON_WALL_SKULL: - case WALL_SIGN: + case SPRUCE_SIGN: + case SPRUCE_WALL_SIGN: case WHITE_BANNER: case WHITE_WALL_BANNER: case WITHER_SKELETON_SKULL: @@ -6988,6 +7672,7 @@ public enum Material implements Keyed { case BLUE_SHULKER_BOX: case BONE_BLOCK: case BROWN_SHULKER_BOX: + case CAMPFIRE: case CAULDRON: case CYAN_SHULKER_BOX: case DARK_OAK_LOG: @@ -7024,9 +7709,15 @@ public enum Material implements Keyed { case WHITE_SHULKER_BOX: case YELLOW_SHULKER_BOX: return 2.0F; + case BARREL: + case CARTOGRAPHY_TABLE: case CHEST: case CRAFTING_TABLE: case DRIED_KELP_BLOCK: + case FLETCHING_TABLE: + case LECTERN: + case LOOM: + case SMITHING_TABLE: case TRAPPED_CHEST: return 2.5F; case BLUE_ICE: @@ -7087,9 +7778,13 @@ public enum Material implements Keyed { case SPRUCE_STAIRS: case SPRUCE_TRAPDOOR: return 3.0F; + case BLAST_FURNACE: case DISPENSER: case DROPPER: case FURNACE: + case LANTERN: + case SMOKER: + case STONECUTTER: return 3.5F; case COBWEB: return 4.0F; @@ -7113,15 +7808,20 @@ public enum Material implements Keyed { return 4.2F; case HOPPER: return 4.8F; + case BELL: case IRON_DOOR: case IRON_TRAPDOOR: case SPAWNER: return 5.0F; case ANDESITE: + case ANDESITE_SLAB: + case ANDESITE_STAIRS: + case ANDESITE_WALL: case BRAIN_CORAL_BLOCK: case BRICKS: case BRICK_SLAB: case BRICK_STAIRS: + case BRICK_WALL: case BUBBLE_CORAL_BLOCK: case CHISELED_STONE_BRICKS: case COAL_BLOCK: @@ -7130,6 +7830,8 @@ public enum Material implements Keyed { case COBBLESTONE_STAIRS: case COBBLESTONE_WALL: case CRACKED_STONE_BRICKS: + case CUT_RED_SANDSTONE_SLAB: + case CUT_SANDSTONE_SLAB: case DARK_PRISMARINE: case DARK_PRISMARINE_SLAB: case DARK_PRISMARINE_STAIRS: @@ -7140,31 +7842,51 @@ public enum Material implements Keyed { case DEAD_TUBE_CORAL_BLOCK: case DIAMOND_BLOCK: case DIORITE: + case DIORITE_SLAB: + case DIORITE_STAIRS: + case DIORITE_WALL: case EMERALD_BLOCK: case FIRE_CORAL_BLOCK: case GOLD_BLOCK: case GRANITE: + case GRANITE_SLAB: + case GRANITE_STAIRS: + case GRANITE_WALL: + case GRINDSTONE: case HORN_CORAL_BLOCK: case IRON_BARS: case IRON_BLOCK: case JUKEBOX: case MOSSY_COBBLESTONE: + case MOSSY_COBBLESTONE_SLAB: + case MOSSY_COBBLESTONE_STAIRS: case MOSSY_COBBLESTONE_WALL: case MOSSY_STONE_BRICKS: + case MOSSY_STONE_BRICK_SLAB: + case MOSSY_STONE_BRICK_STAIRS: + case MOSSY_STONE_BRICK_WALL: case NETHER_BRICKS: case NETHER_BRICK_FENCE: case NETHER_BRICK_SLAB: case NETHER_BRICK_STAIRS: + case NETHER_BRICK_WALL: case PETRIFIED_OAK_SLAB: case POLISHED_ANDESITE: + case POLISHED_ANDESITE_SLAB: + case POLISHED_ANDESITE_STAIRS: case POLISHED_DIORITE: + case POLISHED_DIORITE_SLAB: + case POLISHED_DIORITE_STAIRS: case POLISHED_GRANITE: + case POLISHED_GRANITE_SLAB: + case POLISHED_GRANITE_STAIRS: case PRISMARINE: case PRISMARINE_BRICKS: case PRISMARINE_BRICK_SLAB: case PRISMARINE_BRICK_STAIRS: case PRISMARINE_SLAB: case PRISMARINE_STAIRS: + case PRISMARINE_WALL: case PURPUR_BLOCK: case PURPUR_PILLAR: case PURPUR_SLAB: @@ -7172,17 +7894,29 @@ public enum Material implements Keyed { case QUARTZ_SLAB: case REDSTONE_BLOCK: case RED_NETHER_BRICKS: + case RED_NETHER_BRICK_SLAB: + case RED_NETHER_BRICK_STAIRS: + case RED_NETHER_BRICK_WALL: case RED_SANDSTONE_SLAB: case SANDSTONE_SLAB: case SMOOTH_QUARTZ: + case SMOOTH_QUARTZ_SLAB: + case SMOOTH_QUARTZ_STAIRS: case SMOOTH_RED_SANDSTONE: + case SMOOTH_RED_SANDSTONE_SLAB: + case SMOOTH_RED_SANDSTONE_STAIRS: case SMOOTH_SANDSTONE: + case SMOOTH_SANDSTONE_SLAB: + case SMOOTH_SANDSTONE_STAIRS: case SMOOTH_STONE: + case SMOOTH_STONE_SLAB: case STONE: case STONE_BRICKS: case STONE_BRICK_SLAB: case STONE_BRICK_STAIRS: + case STONE_BRICK_WALL: case STONE_SLAB: + case STONE_STAIRS: case TUBE_CORAL_BLOCK: return 6.0F; case DRAGON_EGG: @@ -7205,6 +7939,7 @@ public enum Material implements Keyed { case END_GATEWAY: case END_PORTAL: case END_PORTAL_FRAME: + case JIGSAW: case REPEATING_COMMAND_BLOCK: case STRUCTURE_BLOCK: return 3600000.0F; diff --git a/api/src/main/java/org/bukkit/NamespacedKey.java b/api/src/main/java/org/bukkit/NamespacedKey.java index 8648e8fb6..620a962df 100644 --- a/api/src/main/java/org/bukkit/NamespacedKey.java +++ b/api/src/main/java/org/bukkit/NamespacedKey.java @@ -39,8 +39,8 @@ public final class NamespacedKey implements com.destroystokyo.paper.Namespaced { /** * Create a key in a specific namespace. * - * @param namespace String representing a grouping of keys - * @param key Name for this specific key + * @param namespace namespace + * @param key key * @deprecated should never be used by plugins, for internal use only!! */ @Deprecated @@ -72,7 +72,7 @@ public final class NamespacedKey implements com.destroystokyo.paper.Namespaced { Preconditions.checkArgument(key != null, "Key cannot be null"); this.namespace = plugin.getName().toLowerCase(Locale.ROOT); - this.key = key.toLowerCase().toLowerCase(Locale.ROOT); + this.key = key.toLowerCase(Locale.ROOT); // Check validity after normalization Preconditions.checkArgument(VALID_NAMESPACE.matcher(this.namespace).matches(), "Invalid namespace. Must be [a-z0-9._-]: %s", this.namespace); diff --git a/api/src/main/java/org/bukkit/Note.java b/api/src/main/java/org/bukkit/Note.java index 6aa02542b..b1c86aefb 100644 --- a/api/src/main/java/org/bukkit/Note.java +++ b/api/src/main/java/org/bukkit/Note.java @@ -1,10 +1,8 @@ package org.bukkit; -import java.util.Map; - -import org.apache.commons.lang.Validate; - import com.google.common.collect.Maps; +import java.util.Map; +import org.apache.commons.lang.Validate; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/api/src/main/java/org/bukkit/OfflinePlayer.java b/api/src/main/java/org/bukkit/OfflinePlayer.java index 30195c045..3ab914fb2 100644 --- a/api/src/main/java/org/bukkit/OfflinePlayer.java +++ b/api/src/main/java/org/bukkit/OfflinePlayer.java @@ -1,7 +1,6 @@ package org.bukkit; import java.util.UUID; - import org.bukkit.configuration.serialization.ConfigurationSerializable; import org.bukkit.entity.AnimalTamer; import org.bukkit.entity.Player; @@ -26,6 +25,7 @@ public interface OfflinePlayer extends ServerOperator, AnimalTamer, Configuratio * * @return Player name or null if we have not seen a name for this player yet */ + @Override @Nullable public String getName(); @@ -34,6 +34,7 @@ public interface OfflinePlayer extends ServerOperator, AnimalTamer, Configuratio * * @return Player UUID */ + @Override @NotNull public UUID getUniqueId(); diff --git a/api/src/main/java/org/bukkit/Particle.java b/api/src/main/java/org/bukkit/Particle.java index a919c6d5b..69aae30a3 100644 --- a/api/src/main/java/org/bukkit/Particle.java +++ b/api/src/main/java/org/bukkit/Particle.java @@ -60,6 +60,14 @@ public enum Particle { BUBBLE_COLUMN_UP, NAUTILUS, DOLPHIN, + SNEEZE, + CAMPFIRE_COSY_SMOKE, + CAMPFIRE_SIGNAL_SMOKE, + COMPOSTER, + FLASH, + FALLING_LAVA, + LANDING_LAVA, + FALLING_WATER, // ----- Legacy Separator ----- LEGACY_BLOCK_CRACK(MaterialData.class), LEGACY_BLOCK_DUST(MaterialData.class), diff --git a/api/src/main/java/org/bukkit/Raid.java b/api/src/main/java/org/bukkit/Raid.java new file mode 100644 index 000000000..983a8c20a --- /dev/null +++ b/api/src/main/java/org/bukkit/Raid.java @@ -0,0 +1,134 @@ +package org.bukkit; + +import java.util.List; +import java.util.Set; +import java.util.UUID; +import org.bukkit.entity.Raider; +import org.jetbrains.annotations.NotNull; + +/** + * Represents a raid event. + */ +public interface Raid { + + /** + * Get whether this raid started. + * + * @return whether raid is started + */ + boolean isStarted(); + + /** + * Gets the amount of ticks this raid has existed. + * + * @return active ticks + */ + long getActiveTicks(); + + /** + * Gets the Bad Omen level of this raid. + * + * @return Bad Omen level (between 0 and 5) + */ + int getBadOmenLevel(); + + /** + * Sets the Bad Omen level. + *
+ * If the level is higher than 1, there will be an additional wave that as + * strong as the final wave. + * + * @param badOmenLevel new Bad Omen level (from 0-5) + * @throws IllegalArgumentException if invalid Bad Omen level + */ + void setBadOmenLevel(int badOmenLevel); + + /** + * Gets the center location where the raid occurs. + * + * @return location + */ + @NotNull + Location getLocation(); + + /** + * Gets the current status of the raid. + *
+ * Do not use this method to check if the raid has been started, call + * {@link #isStarted()} instead. + * + * @return Raids status + */ + @NotNull + RaidStatus getStatus(); + + /** + * Gets the number of raider groups which have spawned. + * + * @return total spawned groups + */ + int getSpawnedGroups(); + + /** + * Gets the number of raider groups which would spawn. + *
+ * This also includes the group which spawns in the additional wave (if + * present). + * + * @return total groups + */ + int getTotalGroups(); + + /** + * Gets the number of waves in this raid (exclude the additional wave). + * + * @return number of waves + */ + int getTotalWaves(); + + /** + * Gets the sum of all raider's health. + * + * @return total raiders health + */ + float getTotalHealth(); + + /** + * Get the UUID of all heroes in this raid. + * + * @return a set of unique ids + */ + @NotNull + Set getHeroes(); + + /** + * Gets all remaining {@link Raider} in the present wave. + * + * @return a list of current raiders + */ + @NotNull + List getRaiders(); + + /** + * Represents the status of a {@link Raid}. + */ + public enum RaidStatus { + + /** + * The raid is in progress. + */ + ONGOING, + /** + * The raid was beaten by heroes. + */ + VICTORY, + /** + * The village has fallen (i.e. all villagers died). + */ + LOSS, + /** + * The raid was terminated. + */ + STOPPED; + } +} diff --git a/api/src/main/java/org/bukkit/Registry.java b/api/src/main/java/org/bukkit/Registry.java new file mode 100644 index 000000000..9d0d0d745 --- /dev/null +++ b/api/src/main/java/org/bukkit/Registry.java @@ -0,0 +1,196 @@ +package org.bukkit; + +import com.google.common.base.Predicates; +import com.google.common.collect.ImmutableMap; +import java.util.Arrays; +import java.util.Iterator; +import java.util.Map; +import java.util.function.Predicate; +import org.bukkit.advancement.Advancement; +import org.bukkit.block.Biome; +import org.bukkit.boss.KeyedBossBar; +import org.bukkit.enchantments.Enchantment; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Villager; +import org.bukkit.entity.memory.MemoryKey; +import org.bukkit.loot.LootTables; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * Represents a registry of Bukkit objects that may be retrieved by + * {@link NamespacedKey}. + * + * @param type of item in the registry + */ +public interface Registry extends Iterable { + + /** + * Server advancements. + * + * @see Bukkit#getAdvancement(org.bukkit.NamespacedKey) + * @see Bukkit#advancementIterator() + */ + Registry ADVANCEMENT = new Registry() { + + @Nullable + @Override + public Advancement get(@NotNull NamespacedKey key) { + return Bukkit.getAdvancement(key); + } + + @NotNull + @Override + public Iterator iterator() { + return Bukkit.advancementIterator(); + } + }; + /** + * Server art. + * + * @see Art + */ + Registry ART = new SimpleRegistry<>(Art.class); + /** + * Server biomes. + * + * @see Biome + */ + Registry BIOME = new SimpleRegistry<>(Biome.class); + /** + * Custom boss bars. + * + * @see Bukkit#getBossBar(org.bukkit.NamespacedKey) + * @see Bukkit#getBossBars() + */ + Registry BOSS_BARS = new Registry() { + + @Nullable + @Override + public KeyedBossBar get(@NotNull NamespacedKey key) { + return Bukkit.getBossBar(key); + } + + @NotNull + @Override + public Iterator iterator() { + return Bukkit.getBossBars(); + } + }; + /** + * Server enchantments. + * + * @see Enchantment#getByKey(org.bukkit.NamespacedKey) + */ + Registry ENCHANTMENT = new Registry() { + + @Nullable + @Override + public Enchantment get(@NotNull NamespacedKey key) { + return Enchantment.getByKey(key); + } + + @NotNull + @Override + public Iterator iterator() { + return Arrays.asList(Enchantment.values()).iterator(); + } + }; + /** + * Server entity types. + * + * @see EntityType + */ + Registry ENTITY_TYPE = new SimpleRegistry<>(EntityType.class, (entity) -> entity != EntityType.UNKNOWN); + /** + * Default server loot tables. + * + * @see LootTables + */ + Registry LOOT_TABLES = new SimpleRegistry<>(LootTables.class); + /** + * Server materials. + * + * @see Material + */ + Registry MATERIAL = new SimpleRegistry<>(Material.class, (mat) -> !mat.isLegacy()); + /** + * Server statistics. + * + * @see Statistic + */ + Registry STATISTIC = new SimpleRegistry<>(Statistic.class); + /** + * Villager profession. + * + * @see Villager.Profession + */ + Registry VILLAGER_PROFESSION = new SimpleRegistry<>(Villager.Profession.class); + /** + * Villager type. + * + * @see Villager.Type + */ + Registry VILLAGER_TYPE = new SimpleRegistry<>(Villager.Type.class); + /** + * Memory Keys. + * + * @see MemoryKey + */ + Registry MEMORY_MODULE_TYPE = new Registry() { + + @NotNull + @Override + public Iterator iterator() { + return MemoryKey.values().iterator(); + } + + @Nullable + @Override + public MemoryKey get(@NotNull NamespacedKey key) { + return MemoryKey.getByKey(key); + } + }; + + /** + * Get the object by its key. + * + * @param key non-null key + * @return item or null if does not exist + */ + @Nullable + T get(@NotNull NamespacedKey key); + + static final class SimpleRegistry & Keyed> implements Registry { + + private final Map map; + + protected SimpleRegistry(@NotNull Class type) { + this(type, Predicates.alwaysTrue()); + } + + protected SimpleRegistry(@NotNull Class type, @NotNull Predicate predicate) { + ImmutableMap.Builder builder = ImmutableMap.builder(); + + for (T entry : type.getEnumConstants()) { + if (predicate.test(entry)) { + builder.put(entry.getKey(), entry); + } + } + + map = builder.build(); + } + + @Nullable + @Override + public T get(@NotNull NamespacedKey key) { + return map.get(key); + } + + @NotNull + @Override + public Iterator iterator() { + return map.values().iterator(); + } + } +} diff --git a/api/src/main/java/org/bukkit/SandstoneType.java b/api/src/main/java/org/bukkit/SandstoneType.java index 3b3a4a7cc..6277451c3 100644 --- a/api/src/main/java/org/bukkit/SandstoneType.java +++ b/api/src/main/java/org/bukkit/SandstoneType.java @@ -1,8 +1,7 @@ package org.bukkit; -import java.util.Map; - import com.google.common.collect.Maps; +import java.util.Map; import org.jetbrains.annotations.Nullable; /** @@ -14,7 +13,7 @@ public enum SandstoneType { SMOOTH(0x2); private final byte data; - private final static Map BY_DATA = Maps.newHashMap(); + private static final Map BY_DATA = Maps.newHashMap(); private SandstoneType(final int data) { this.data = (byte) data; diff --git a/api/src/main/java/org/bukkit/Server.java b/api/src/main/java/org/bukkit/Server.java index eb23417b7..314704790 100644 --- a/api/src/main/java/org/bukkit/Server.java +++ b/api/src/main/java/org/bukkit/Server.java @@ -1,5 +1,6 @@ package org.bukkit; +import com.google.common.collect.ImmutableList; import java.awt.image.BufferedImage; import java.io.File; import java.io.Serializable; @@ -12,8 +13,8 @@ import java.util.Set; import java.util.UUID; import java.util.function.Consumer; import java.util.logging.Logger; - import org.bukkit.Warning.WarningState; +import org.bukkit.advancement.Advancement; import org.bukkit.block.data.BlockData; import org.bukkit.boss.BarColor; import org.bukkit.boss.BarFlag; @@ -28,12 +29,15 @@ import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.event.inventory.InventoryType; import org.bukkit.event.server.ServerListPingEvent; +import org.bukkit.generator.ChunkGenerator; import org.bukkit.help.HelpMap; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.InventoryHolder; +import org.bukkit.inventory.ItemFactory; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.Merchant; import org.bukkit.inventory.Recipe; +import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.loot.LootTable; import org.bukkit.map.MapView; import org.bukkit.permissions.Permissible; @@ -44,13 +48,6 @@ import org.bukkit.plugin.messaging.PluginMessageRecipient; import org.bukkit.scheduler.BukkitScheduler; import org.bukkit.scoreboard.ScoreboardManager; import org.bukkit.util.CachedServerIcon; - -import com.google.common.collect.ImmutableList; -import org.bukkit.advancement.Advancement; -import org.bukkit.generator.ChunkGenerator; - -import org.bukkit.inventory.ItemFactory; -import org.bukkit.inventory.meta.ItemMeta; import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -161,27 +158,6 @@ public interface Server extends PluginMessageRecipient { @NotNull public String getIp(); - /** - * Get the name of this server. - * - * @return the name of this server - * @deprecated not a standard server property - */ - @Deprecated - @NotNull - public String getServerName(); - - /** - * Get an ID of this server. The ID is a simple generally alphanumeric ID - * that can be used for uniquely identifying this server. - * - * @return the ID of this server - * @deprecated not a standard server property - */ - @Deprecated - @NotNull - public String getServerId(); - /** * Get world type (level-type setting) for default world. * @@ -814,11 +790,9 @@ public interface Server extends PluginMessageRecipient { public HelpMap getHelpMap(); /** - * Creates an empty inventory with the specified type and title. If the type + * Creates an empty inventory with the specified type. If the type * is {@link InventoryType#CHEST}, the new inventory has a size of 27; - * otherwise the new inventory has the normal size for its type.
- * It should be noted that some inventory types do not support titles and - * may not render with said titles on the Minecraft client. + * otherwise the new inventory has the normal size for its type. *
* {@link InventoryType#WORKBENCH} will not process crafting recipes if * created with this method. Use @@ -1053,12 +1027,12 @@ public interface Server extends PluginMessageRecipient { /** * Create a ChunkData for use in a generator. - * + * * See {@link ChunkGenerator#generateChunkData(org.bukkit.World, java.util.Random, int, int, org.bukkit.generator.ChunkGenerator.BiomeGrid)} - * + * * @param world the world to create the ChunkData for * @return a new ChunkData for the world - * + * */ @NotNull public ChunkGenerator.ChunkData createChunkData(@NotNull World world); @@ -1305,9 +1279,7 @@ public interface Server extends PluginMessageRecipient { * no further guarantees are made. * @throws IllegalArgumentException if the selector is malformed in any way * or a parameter is null - * @deprecated draft API */ - @Deprecated @NotNull List selectEntities(@NotNull CommandSender sender, @NotNull String selector) throws IllegalArgumentException; @@ -1426,5 +1398,12 @@ public interface Server extends PluginMessageRecipient { */ @NotNull com.destroystokyo.paper.profile.PlayerProfile createProfile(@Nullable UUID uuid, @Nullable String name); + + /** + * Get the current internal server tick + * + * @return Current tick + */ + int getCurrentTick(); // Paper end } diff --git a/api/src/main/java/org/bukkit/Sound.java b/api/src/main/java/org/bukkit/Sound.java index d84ad5b90..91e5f0f09 100644 --- a/api/src/main/java/org/bukkit/Sound.java +++ b/api/src/main/java/org/bukkit/Sound.java @@ -24,22 +24,40 @@ public enum Sound { BLOCK_ANVIL_PLACE, BLOCK_ANVIL_STEP, BLOCK_ANVIL_USE, + BLOCK_BAMBOO_BREAK, + BLOCK_BAMBOO_FALL, + BLOCK_BAMBOO_HIT, + BLOCK_BAMBOO_PLACE, + BLOCK_BAMBOO_SAPLING_BREAK, + BLOCK_BAMBOO_SAPLING_HIT, + BLOCK_BAMBOO_SAPLING_PLACE, + BLOCK_BAMBOO_STEP, + BLOCK_BARREL_CLOSE, + BLOCK_BARREL_OPEN, BLOCK_BEACON_ACTIVATE, BLOCK_BEACON_AMBIENT, BLOCK_BEACON_DEACTIVATE, BLOCK_BEACON_POWER_SELECT, + BLOCK_BELL_RESONATE, + BLOCK_BELL_USE, + BLOCK_BLASTFURNACE_FIRE_CRACKLE, BLOCK_BREWING_STAND_BREW, BLOCK_BUBBLE_COLUMN_BUBBLE_POP, BLOCK_BUBBLE_COLUMN_UPWARDS_AMBIENT, BLOCK_BUBBLE_COLUMN_UPWARDS_INSIDE, BLOCK_BUBBLE_COLUMN_WHIRLPOOL_AMBIENT, BLOCK_BUBBLE_COLUMN_WHIRLPOOL_INSIDE, + BLOCK_CAMPFIRE_CRACKLE, BLOCK_CHEST_CLOSE, BLOCK_CHEST_LOCKED, BLOCK_CHEST_OPEN, BLOCK_CHORUS_FLOWER_DEATH, BLOCK_CHORUS_FLOWER_GROW, BLOCK_COMPARATOR_CLICK, + BLOCK_COMPOSTER_EMPTY, + BLOCK_COMPOSTER_FILL, + BLOCK_COMPOSTER_FILL_SUCCESS, + BLOCK_COMPOSTER_READY, BLOCK_CONDUIT_ACTIVATE, BLOCK_CONDUIT_AMBIENT, BLOCK_CONDUIT_AMBIENT_SHORT, @@ -50,6 +68,7 @@ public enum Sound { BLOCK_CORAL_BLOCK_HIT, BLOCK_CORAL_BLOCK_PLACE, BLOCK_CORAL_BLOCK_STEP, + BLOCK_CROP_BREAK, BLOCK_DISPENSER_DISPENSE, BLOCK_DISPENSER_FAIL, BLOCK_DISPENSER_LAUNCH, @@ -79,6 +98,7 @@ public enum Sound { BLOCK_GRAVEL_HIT, BLOCK_GRAVEL_PLACE, BLOCK_GRAVEL_STEP, + BLOCK_GRINDSTONE_USE, BLOCK_IRON_DOOR_CLOSE, BLOCK_IRON_DOOR_OPEN, BLOCK_IRON_TRAPDOOR_CLOSE, @@ -88,6 +108,11 @@ public enum Sound { BLOCK_LADDER_HIT, BLOCK_LADDER_PLACE, BLOCK_LADDER_STEP, + BLOCK_LANTERN_BREAK, + BLOCK_LANTERN_FALL, + BLOCK_LANTERN_HIT, + BLOCK_LANTERN_PLACE, + BLOCK_LANTERN_STEP, BLOCK_LAVA_AMBIENT, BLOCK_LAVA_EXTINGUISH, BLOCK_LAVA_POP, @@ -100,14 +125,20 @@ public enum Sound { BLOCK_METAL_PRESSURE_PLATE_CLICK_OFF, BLOCK_METAL_PRESSURE_PLATE_CLICK_ON, BLOCK_METAL_STEP, + BLOCK_NETHER_WART_BREAK, + BLOCK_NOTE_BLOCK_BANJO, BLOCK_NOTE_BLOCK_BASEDRUM, BLOCK_NOTE_BLOCK_BASS, BLOCK_NOTE_BLOCK_BELL, + BLOCK_NOTE_BLOCK_BIT, BLOCK_NOTE_BLOCK_CHIME, + BLOCK_NOTE_BLOCK_COW_BELL, + BLOCK_NOTE_BLOCK_DIDGERIDOO, BLOCK_NOTE_BLOCK_FLUTE, BLOCK_NOTE_BLOCK_GUITAR, BLOCK_NOTE_BLOCK_HARP, BLOCK_NOTE_BLOCK_HAT, + BLOCK_NOTE_BLOCK_IRON_XYLOPHONE, BLOCK_NOTE_BLOCK_PLING, BLOCK_NOTE_BLOCK_SNARE, BLOCK_NOTE_BLOCK_XYLOPHONE, @@ -123,6 +154,11 @@ public enum Sound { BLOCK_SAND_HIT, BLOCK_SAND_PLACE, BLOCK_SAND_STEP, + BLOCK_SCAFFOLDING_BREAK, + BLOCK_SCAFFOLDING_FALL, + BLOCK_SCAFFOLDING_HIT, + BLOCK_SCAFFOLDING_PLACE, + BLOCK_SCAFFOLDING_STEP, BLOCK_SHULKER_BOX_CLOSE, BLOCK_SHULKER_BOX_OPEN, BLOCK_SLIME_BLOCK_BREAK, @@ -130,6 +166,7 @@ public enum Sound { BLOCK_SLIME_BLOCK_HIT, BLOCK_SLIME_BLOCK_PLACE, BLOCK_SLIME_BLOCK_STEP, + BLOCK_SMOKER_SMOKE, BLOCK_SNOW_BREAK, BLOCK_SNOW_FALL, BLOCK_SNOW_HIT, @@ -144,6 +181,8 @@ public enum Sound { BLOCK_STONE_PRESSURE_PLATE_CLICK_OFF, BLOCK_STONE_PRESSURE_PLATE_CLICK_ON, BLOCK_STONE_STEP, + BLOCK_SWEET_BERRY_BUSH_BREAK, + BLOCK_SWEET_BERRY_BUSH_PLACE, BLOCK_TRIPWIRE_ATTACH, BLOCK_TRIPWIRE_CLICK_OFF, BLOCK_TRIPWIRE_CLICK_ON, @@ -193,11 +232,14 @@ public enum Sound { ENTITY_BOAT_PADDLE_LAND, ENTITY_BOAT_PADDLE_WATER, ENTITY_CAT_AMBIENT, + ENTITY_CAT_BEG_FOR_FOOD, ENTITY_CAT_DEATH, + ENTITY_CAT_EAT, ENTITY_CAT_HISS, ENTITY_CAT_HURT, ENTITY_CAT_PURR, ENTITY_CAT_PURREOW, + ENTITY_CAT_STRAY_AMBIENT, ENTITY_CHICKEN_AMBIENT, ENTITY_CHICKEN_DEATH, ENTITY_CHICKEN_EGG, @@ -270,6 +312,7 @@ public enum Sound { ENTITY_ENDER_PEARL_THROW, ENTITY_EVOKER_AMBIENT, ENTITY_EVOKER_CAST_SPELL, + ENTITY_EVOKER_CELEBRATE, ENTITY_EVOKER_DEATH, ENTITY_EVOKER_FANGS_ATTACK, ENTITY_EVOKER_HURT, @@ -290,6 +333,16 @@ public enum Sound { ENTITY_FISHING_BOBBER_SPLASH, ENTITY_FISHING_BOBBER_THROW, ENTITY_FISH_SWIM, + ENTITY_FOX_AGGRO, + ENTITY_FOX_AMBIENT, + ENTITY_FOX_BITE, + ENTITY_FOX_DEATH, + ENTITY_FOX_EAT, + ENTITY_FOX_HURT, + ENTITY_FOX_SCREECH, + ENTITY_FOX_SLEEP, + ENTITY_FOX_SNIFF, + ENTITY_FOX_SPIT, ENTITY_GENERIC_BIG_FALL, ENTITY_GENERIC_BURN, ENTITY_GENERIC_DEATH, @@ -380,13 +433,31 @@ public enum Sound { ENTITY_MAGMA_CUBE_SQUISH_SMALL, ENTITY_MINECART_INSIDE, ENTITY_MINECART_RIDING, + ENTITY_MOOSHROOM_CONVERT, + ENTITY_MOOSHROOM_EAT, + ENTITY_MOOSHROOM_MILK, ENTITY_MOOSHROOM_SHEAR, + ENTITY_MOOSHROOM_SUSPICIOUS_MILK, ENTITY_MULE_AMBIENT, ENTITY_MULE_CHEST, ENTITY_MULE_DEATH, ENTITY_MULE_HURT, + ENTITY_OCELOT_AMBIENT, + ENTITY_OCELOT_DEATH, + ENTITY_OCELOT_HURT, ENTITY_PAINTING_BREAK, ENTITY_PAINTING_PLACE, + ENTITY_PANDA_AGGRESSIVE_AMBIENT, + ENTITY_PANDA_AMBIENT, + ENTITY_PANDA_BITE, + ENTITY_PANDA_CANT_BREED, + ENTITY_PANDA_DEATH, + ENTITY_PANDA_EAT, + ENTITY_PANDA_HURT, + ENTITY_PANDA_PRE_SNEEZE, + ENTITY_PANDA_SNEEZE, + ENTITY_PANDA_STEP, + ENTITY_PANDA_WORRIED_AMBIENT, ENTITY_PARROT_AMBIENT, ENTITY_PARROT_DEATH, ENTITY_PARROT_EAT, @@ -401,11 +472,15 @@ public enum Sound { ENTITY_PARROT_IMITATE_ENDER_DRAGON, ENTITY_PARROT_IMITATE_EVOKER, ENTITY_PARROT_IMITATE_GHAST, + ENTITY_PARROT_IMITATE_GUARDIAN, ENTITY_PARROT_IMITATE_HUSK, ENTITY_PARROT_IMITATE_ILLUSIONER, ENTITY_PARROT_IMITATE_MAGMA_CUBE, + ENTITY_PARROT_IMITATE_PANDA, ENTITY_PARROT_IMITATE_PHANTOM, + ENTITY_PARROT_IMITATE_PILLAGER, ENTITY_PARROT_IMITATE_POLAR_BEAR, + ENTITY_PARROT_IMITATE_RAVAGER, ENTITY_PARROT_IMITATE_SHULKER, ENTITY_PARROT_IMITATE_SILVERFISH, ENTITY_PARROT_IMITATE_SKELETON, @@ -433,6 +508,10 @@ public enum Sound { ENTITY_PIG_HURT, ENTITY_PIG_SADDLE, ENTITY_PIG_STEP, + ENTITY_PILLAGER_AMBIENT, + ENTITY_PILLAGER_CELEBRATE, + ENTITY_PILLAGER_DEATH, + ENTITY_PILLAGER_HURT, ENTITY_PLAYER_ATTACK_CRIT, ENTITY_PLAYER_ATTACK_KNOCKBACK, ENTITY_PLAYER_ATTACK_NODAMAGE, @@ -446,6 +525,7 @@ public enum Sound { ENTITY_PLAYER_HURT, ENTITY_PLAYER_HURT_DROWN, ENTITY_PLAYER_HURT_ON_FIRE, + ENTITY_PLAYER_HURT_SWEET_BERRY_BUSH, ENTITY_PLAYER_LEVELUP, ENTITY_PLAYER_SMALL_FALL, ENTITY_PLAYER_SPLASH, @@ -469,6 +549,14 @@ public enum Sound { ENTITY_RABBIT_DEATH, ENTITY_RABBIT_HURT, ENTITY_RABBIT_JUMP, + ENTITY_RAVAGER_AMBIENT, + ENTITY_RAVAGER_ATTACK, + ENTITY_RAVAGER_CELEBRATE, + ENTITY_RAVAGER_DEATH, + ENTITY_RAVAGER_HURT, + ENTITY_RAVAGER_ROAR, + ENTITY_RAVAGER_STEP, + ENTITY_RAVAGER_STUNNED, ENTITY_SALMON_AMBIENT, ENTITY_SALMON_DEATH, ENTITY_SALMON_FLOP, @@ -555,15 +643,41 @@ public enum Sound { ENTITY_VEX_DEATH, ENTITY_VEX_HURT, ENTITY_VILLAGER_AMBIENT, + ENTITY_VILLAGER_CELEBRATE, ENTITY_VILLAGER_DEATH, ENTITY_VILLAGER_HURT, ENTITY_VILLAGER_NO, ENTITY_VILLAGER_TRADE, + ENTITY_VILLAGER_WORK_ARMORER, + ENTITY_VILLAGER_WORK_BUTCHER, + ENTITY_VILLAGER_WORK_CARTOGRAPHER, + ENTITY_VILLAGER_WORK_CLERIC, + ENTITY_VILLAGER_WORK_FARMER, + ENTITY_VILLAGER_WORK_FISHERMAN, + ENTITY_VILLAGER_WORK_FLETCHER, + ENTITY_VILLAGER_WORK_LEATHERWORKER, + ENTITY_VILLAGER_WORK_LIBRARIAN, + ENTITY_VILLAGER_WORK_MASON, + ENTITY_VILLAGER_WORK_SHEPHERD, + ENTITY_VILLAGER_WORK_TOOLSMITH, + ENTITY_VILLAGER_WORK_WEAPONSMITH, ENTITY_VILLAGER_YES, ENTITY_VINDICATOR_AMBIENT, + ENTITY_VINDICATOR_CELEBRATE, ENTITY_VINDICATOR_DEATH, ENTITY_VINDICATOR_HURT, + ENTITY_WANDERING_TRADER_AMBIENT, + ENTITY_WANDERING_TRADER_DEATH, + ENTITY_WANDERING_TRADER_DISAPPEARED, + ENTITY_WANDERING_TRADER_DRINK_MILK, + ENTITY_WANDERING_TRADER_DRINK_POTION, + ENTITY_WANDERING_TRADER_HURT, + ENTITY_WANDERING_TRADER_NO, + ENTITY_WANDERING_TRADER_REAPPEARED, + ENTITY_WANDERING_TRADER_TRADE, + ENTITY_WANDERING_TRADER_YES, ENTITY_WITCH_AMBIENT, + ENTITY_WITCH_CELEBRATE, ENTITY_WITCH_DEATH, ENTITY_WITCH_DRINK, ENTITY_WITCH_HURT, @@ -610,6 +724,7 @@ public enum Sound { ENTITY_ZOMBIE_VILLAGER_DEATH, ENTITY_ZOMBIE_VILLAGER_HURT, ENTITY_ZOMBIE_VILLAGER_STEP, + EVENT_RAID_HORN, ITEM_ARMOR_EQUIP_CHAIN, ITEM_ARMOR_EQUIP_DIAMOND, ITEM_ARMOR_EQUIP_ELYTRA, @@ -619,6 +734,8 @@ public enum Sound { ITEM_ARMOR_EQUIP_LEATHER, ITEM_ARMOR_EQUIP_TURTLE, ITEM_AXE_STRIP, + ITEM_BOOK_PAGE_TURN, + ITEM_BOOK_PUT, ITEM_BOTTLE_EMPTY, ITEM_BOTTLE_FILL, ITEM_BOTTLE_FILL_DRAGONBREATH, @@ -629,13 +746,24 @@ public enum Sound { ITEM_BUCKET_FILL_FISH, ITEM_BUCKET_FILL_LAVA, ITEM_CHORUS_FRUIT_TELEPORT, + ITEM_CROP_PLANT, + ITEM_CROSSBOW_HIT, + ITEM_CROSSBOW_LOADING_END, + ITEM_CROSSBOW_LOADING_MIDDLE, + ITEM_CROSSBOW_LOADING_START, + ITEM_CROSSBOW_QUICK_CHARGE_1, + ITEM_CROSSBOW_QUICK_CHARGE_2, + ITEM_CROSSBOW_QUICK_CHARGE_3, + ITEM_CROSSBOW_SHOOT, ITEM_ELYTRA_FLYING, ITEM_FIRECHARGE_USE, ITEM_FLINTANDSTEEL_USE, ITEM_HOE_TILL, + ITEM_NETHER_WART_PLANT, ITEM_SHIELD_BLOCK, ITEM_SHIELD_BREAK, ITEM_SHOVEL_FLATTEN, + ITEM_SWEET_BERRIES_PICK_FROM_BUSH, ITEM_TOTEM_USE, ITEM_TRIDENT_HIT, ITEM_TRIDENT_HIT_GROUND, @@ -666,6 +794,11 @@ public enum Sound { MUSIC_NETHER, MUSIC_UNDER_WATER, UI_BUTTON_CLICK, + UI_CARTOGRAPHY_TABLE_TAKE_RESULT, + UI_LOOM_SELECT_PATTERN, + UI_LOOM_TAKE_RESULT, + UI_STONECUTTER_SELECT_RECIPE, + UI_STONECUTTER_TAKE_RESULT, UI_TOAST_CHALLENGE_COMPLETE, UI_TOAST_IN, UI_TOAST_OUT, diff --git a/api/src/main/java/org/bukkit/Statistic.java b/api/src/main/java/org/bukkit/Statistic.java index f5a834fea..c54c00128 100644 --- a/api/src/main/java/org/bukkit/Statistic.java +++ b/api/src/main/java/org/bukkit/Statistic.java @@ -1,11 +1,12 @@ package org.bukkit; +import java.util.Locale; import org.jetbrains.annotations.NotNull; /** * Represents a countable statistic, which is tracked by the server. */ -public enum Statistic { +public enum Statistic implements Keyed { DAMAGE_DEALT, DAMAGE_TAKEN, DEATHS, @@ -74,9 +75,21 @@ public enum Statistic { DAMAGE_BLOCKED_BY_SHIELD, DAMAGE_ABSORBED, DAMAGE_RESISTED, - CLEAN_SHULKER_BOX; + CLEAN_SHULKER_BOX, + OPEN_BARREL, + INTERACT_WITH_BLAST_FURNACE, + INTERACT_WITH_SMOKER, + INTERACT_WITH_LECTERN, + INTERACT_WITH_CAMPFIRE, + INTERACT_WITH_CARTOGRAPHY_TABLE, + INTERACT_WITH_LOOM, + INTERACT_WITH_STONECUTTER, + BELL_RING, + RAID_TRIGGER, + RAID_WIN; private final Type type; + private final NamespacedKey key; private Statistic() { this(Type.UNTYPED); @@ -84,6 +97,7 @@ public enum Statistic { private Statistic(/*@NotNull*/ Type type) { this.type = type; + this.key = NamespacedKey.minecraft(name().toLowerCase(Locale.ROOT)); } /** @@ -123,6 +137,12 @@ public enum Statistic { return type == Type.BLOCK; } + @NotNull + @Override + public NamespacedKey getKey() { + return key; + } + /** * The type of statistic. * diff --git a/api/src/main/java/org/bukkit/StructureType.java b/api/src/main/java/org/bukkit/StructureType.java index 02d795451..e062c90ea 100644 --- a/api/src/main/java/org/bukkit/StructureType.java +++ b/api/src/main/java/org/bukkit/StructureType.java @@ -2,15 +2,14 @@ package org.bukkit; import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableMap; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; import org.apache.commons.lang.Validate; import org.bukkit.map.MapCursor; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - /** * This class handles the creation and storage of all structure types for * Bukkit. Structure Types are the different kinds of structures that can be @@ -20,7 +19,7 @@ import java.util.Objects; * The registration of new {@link StructureType}s is case-sensitive. */ // Order is retrieved from WorldGenFactory -public class StructureType { +public final class StructureType { private static final Map structureTypeMap = new HashMap<>(); @@ -31,7 +30,7 @@ public class StructureType { * They are the only place where cave spider spawners and minecarts with * chests can be found naturally. */ - public static final StructureType MINESHAFT = register(new StructureType("Mineshaft", MapCursor.Type.RED_X)); + public static final StructureType MINESHAFT = register(new StructureType("mineshaft", MapCursor.Type.RED_X)); /** * Villages are naturally generating structures that form above ground. @@ -39,7 +38,7 @@ public class StructureType { * They are usually generated in desert, plains, taiga, and savanna biomes * and are a site for villager spawns, with whom the player can trade. */ - public static final StructureType VILLAGE = register(new StructureType("Village", MapCursor.Type.MANSION)); + public static final StructureType VILLAGE = register(new StructureType("village", MapCursor.Type.MANSION)); /** * Nether fortresses are very large complexes that mainly consist of @@ -48,7 +47,7 @@ public class StructureType { * They contain blaze spawners, nether wart farms, and loot chests. They are * only generated in the nether dimension. */ - public static final StructureType NETHER_FORTRESS = register(new StructureType("Fortress", MapCursor.Type.RED_X)); + public static final StructureType NETHER_FORTRESS = register(new StructureType("fortress", MapCursor.Type.RED_X)); /** * Strongholds are underground structures that consist of many rooms, @@ -56,7 +55,7 @@ public class StructureType { *
* They can be found using an {@link Material#ENDER_EYE}. */ - public static final StructureType STRONGHOLD = register(new StructureType("Stronghold", MapCursor.Type.MANSION)); + public static final StructureType STRONGHOLD = register(new StructureType("stronghold", MapCursor.Type.MANSION)); /** * Jungle pyramids (also known as jungle temples) are found in jungles. @@ -65,7 +64,7 @@ public class StructureType { * consist of three floors, with the bottom floor containing treasure * chests. */ - public static final StructureType JUNGLE_PYRAMID = register(new StructureType("Jungle_Pyramid", MapCursor.Type.RED_X)); + public static final StructureType JUNGLE_PYRAMID = register(new StructureType("jungle_pyramid", MapCursor.Type.RED_X)); /** * Ocean ruins are clusters of many different blocks that generate @@ -74,27 +73,27 @@ public class StructureType { * They come in my different variations. The cold variants consist primarily * of stone brick, and the warm variants consist of sandstone. */ - public static final StructureType OCEAN_RUIN = register(new StructureType("Ocean_Ruin", MapCursor.Type.TEMPLE)); + public static final StructureType OCEAN_RUIN = register(new StructureType("ocean_ruin", MapCursor.Type.TEMPLE)); /** * Desert pyramids (also known as desert temples) are found in deserts. *
* They are usually composed of sandstone and stained terracotta. */ - public static final StructureType DESERT_PYRAMID = register(new StructureType("Desert_Pyramid", MapCursor.Type.RED_X)); + public static final StructureType DESERT_PYRAMID = register(new StructureType("desert_pyramid", MapCursor.Type.RED_X)); /** * Igloos are structures that generate in snowy biomes. *
* They consist of the house, as well as a basement. */ - public static final StructureType IGLOO = register(new StructureType("Igloo", MapCursor.Type.RED_X)); + public static final StructureType IGLOO = register(new StructureType("igloo", MapCursor.Type.RED_X)); /** * Swamp huts (also known as witch huts) generate in swamp biomes and have * the ability to spawn witches. */ - public static final StructureType SWAMP_HUT = register(new StructureType("Swamp_Hut", MapCursor.Type.RED_X)); + public static final StructureType SWAMP_HUT = register(new StructureType("swamp_hut", MapCursor.Type.RED_X)); /** * Ocean monuments are underwater structures. @@ -103,7 +102,7 @@ public class StructureType { * lanterns. They are the only place guardians and elder guardians spawn * naturally. */ - public static final StructureType OCEAN_MONUMENT = register(new StructureType("Monument", MapCursor.Type.TEMPLE)); + public static final StructureType OCEAN_MONUMENT = register(new StructureType("monument", MapCursor.Type.TEMPLE)); /** * End Cities are tall castle-like structures that generate in the outer @@ -112,7 +111,7 @@ public class StructureType { * They consist primarily of end stone bricks, purpur blocks, and end rods. * They are the only place where shulkers can be found. */ - public static final StructureType END_CITY = register(new StructureType("EndCity", MapCursor.Type.RED_X)); + public static final StructureType END_CITY = register(new StructureType("endcity", MapCursor.Type.RED_X)); /** * Mansions (also known as woodland mansions) are massive house structures @@ -121,13 +120,13 @@ public class StructureType { * They are the only place where evokers, vindicators, and vexes spawn * naturally (but only once) */ - public static final StructureType WOODLAND_MANSION = register(new StructureType("Mansion", MapCursor.Type.MANSION)); + public static final StructureType WOODLAND_MANSION = register(new StructureType("mansion", MapCursor.Type.MANSION)); /** * Buried treasure consists of a single chest buried in the beach sand or * gravel, with random loot in it. */ - public static final StructureType BURIED_TREASURE = register(new StructureType("Buried_Treasure", MapCursor.Type.RED_X)); + public static final StructureType BURIED_TREASURE = register(new StructureType("buried_treasure", MapCursor.Type.RED_X)); /** * Shipwrecks are structures that generate on the floor of oceans or @@ -136,7 +135,12 @@ public class StructureType { * They are made up of wood materials, and contain 1-3 loot chests. They can * generate sideways, upside-down, or upright. */ - public static final StructureType SHIPWRECK = register(new StructureType("Shipwreck", MapCursor.Type.RED_X)); + public static final StructureType SHIPWRECK = register(new StructureType("shipwreck", MapCursor.Type.RED_X)); + + /** + * Pillager outposts may contain crossbows. + */ + public static final StructureType PILLAGER_OUTPOST = register(new StructureType("pillager_outpost", MapCursor.Type.RED_X)); /* **************** * STRUCTURE TYPES REGISTERED ABOVE THIS diff --git a/api/src/main/java/org/bukkit/Tag.java b/api/src/main/java/org/bukkit/Tag.java index 03d1f2583..1d9021b0b 100644 --- a/api/src/main/java/org/bukkit/Tag.java +++ b/api/src/main/java/org/bukkit/Tag.java @@ -1,8 +1,7 @@ package org.bukkit; -import org.jetbrains.annotations.NotNull; - import java.util.Set; +import org.jetbrains.annotations.NotNull; /** * Represents a tag that may be defined by the server or a resource pack to @@ -57,6 +56,10 @@ public interface Tag extends Keyed { * Vanilla block tag representing all wooden slabs. */ Tag WOODEN_SLABS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("wooden_slabs"), Material.class); + /** + * Vanilla block tag representing all wooden fences. + */ + Tag WOODEN_FENCES = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("wooden_fences"), Material.class); /** * Vanilla block tag representing all wooden pressure plates. */ @@ -118,6 +121,10 @@ public interface Tag extends Keyed { * Vanilla block tag representing all slabs. */ Tag SLABS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("slabs"), Material.class); + /** + * Vanilla block tag representing all walls. + */ + Tag WALLS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("walls"), Material.class); /** * Vanilla block tag representing all damaged and undamaged anvils. */ @@ -139,6 +146,18 @@ public interface Tag extends Keyed { * Vanilla block tag representing all empty and filled flower pots. */ Tag FLOWER_POTS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("flower_pots"), Material.class); + /** + * Vanilla block tag representing all small flowers. + */ + Tag SMALL_FLOWERS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("small_flowers"), Material.class); + /** + * Vanilla block tag representing all beds. + */ + Tag BEDS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("beds"), Material.class); + /** + * Vanilla block tag representing all fences. + */ + Tag FENCES = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("fences"), Material.class); /** * Vanilla block tag denoting blocks that enderman may pick up and hold. */ @@ -175,6 +194,26 @@ public interface Tag extends Keyed { * Vanilla block tag representing all coral. */ Tag CORALS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("corals"), Material.class); + /** + * Vanilla block tag denoting all blocks bamboo may be planted on. + */ + Tag BAMBOO_PLANTABLE_ON = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("bamboo_plantable_on"), Material.class); + /** + * Vanilla block tag denoting dirt like blocks. + */ + Tag DIRT_LIKE = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("dirt_like"), Material.class); + /** + * Vanilla block tag representing all standing signs. + */ + Tag STANDING_SIGNS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("standing_signs"), Material.class); + /** + * Vanilla block tag representing all wall signs. + */ + Tag WALL_SIGNS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("wall_signs"), Material.class); + /** + * Vanilla block tag representing all signs. + */ + Tag SIGNS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("signs"), Material.class); /** * Key for the built in item registry. */ @@ -191,6 +230,18 @@ public interface Tag extends Keyed { * Vanilla item tag representing all fish items. */ Tag ITEMS_FISHES = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("fishes"), Material.class); + /** + * Vanilla item tag representing all music disc items. + */ + Tag ITEMS_MUSIC_DISCS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("music_discs"), Material.class); + /** + * Vanilla item tag representing all coal items. + */ + Tag ITEMS_COALS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("coals"), Material.class); + /** + * Vanilla item tag representing all arrow items. + */ + Tag ITEMS_ARROWS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("arrows"), Material.class); /** * Returns whether or not this tag has an entry for the specified item. diff --git a/api/src/main/java/org/bukkit/TravelAgent.java b/api/src/main/java/org/bukkit/TravelAgent.java deleted file mode 100644 index f1a89e7c8..000000000 --- a/api/src/main/java/org/bukkit/TravelAgent.java +++ /dev/null @@ -1,100 +0,0 @@ -package org.bukkit; - -import org.jetbrains.annotations.NotNull; - -/** - * The Travel Agent handles the creation and the research of Nether and End - * portals when Entities try to use one. - *

- * It is used in {@link org.bukkit.event.entity.EntityPortalEvent} and in - * {@link org.bukkit.event.player.PlayerPortalEvent} to help developers - * reproduce and/or modify Vanilla behaviour. - */ -public interface TravelAgent { - - /** - * Set the Block radius to search in for available portals. - * - * @param radius the radius in which to search for a portal from the - * location - * @return this travel agent - */ - @NotNull - public TravelAgent setSearchRadius(int radius); - - /** - * Gets the search radius value for finding an available portal. - * - * @return the currently set search radius - */ - public int getSearchRadius(); - - /** - * Sets the maximum radius from the given location to create a portal. - * - * @param radius the radius in which to create a portal from the location - * @return this travel agent - */ - @NotNull - public TravelAgent setCreationRadius(int radius); - - /** - * Gets the maximum radius from the given location to create a portal. - * - * @return the currently set creation radius - */ - public int getCreationRadius(); - - /** - * Returns whether the TravelAgent will attempt to create a destination - * portal or not. - * - * @return whether the TravelAgent should create a destination portal or - * not - */ - public boolean getCanCreatePortal(); - - /** - * Sets whether the TravelAgent should attempt to create a destination - * portal or not. - * - * @param create Sets whether the TravelAgent should create a destination - * portal or not - */ - public void setCanCreatePortal(boolean create); - - /** - * Attempt to find a portal near the given location, if a portal is not - * found it will attempt to create one. - * - * @param location the location where the search for a portal should begin - * @return the location of a portal which has been found or returns the - * location passed to the method if unsuccessful - * @see #createPortal(Location) - */ - @NotNull - public Location findOrCreate(@NotNull Location location); - - /** - * Attempt to find a portal near the given location. - * - * @param location the desired location of the portal - * @return the location of the nearest portal to the location - */ - @NotNull - public Location findPortal(@NotNull Location location); - - /** - * Attempt to create a portal near the given location. - *

- * In the case of a Nether portal teleportation, this will attempt to - * create a Nether portal. - *

- * In the case of an Ender portal teleportation, this will (re-)create the - * obsidian platform and clean blocks above it. - * - * @param location the desired location of the portal - * @return true if a portal was successfully created - */ - public boolean createPortal(@NotNull Location location); -} diff --git a/api/src/main/java/org/bukkit/TreeSpecies.java b/api/src/main/java/org/bukkit/TreeSpecies.java index a18e23a4d..2b177f98a 100644 --- a/api/src/main/java/org/bukkit/TreeSpecies.java +++ b/api/src/main/java/org/bukkit/TreeSpecies.java @@ -1,8 +1,7 @@ package org.bukkit; -import java.util.Map; - import com.google.common.collect.Maps; +import java.util.Map; import org.jetbrains.annotations.Nullable; /** @@ -37,7 +36,7 @@ public enum TreeSpecies { ; private final byte data; - private final static Map BY_DATA = Maps.newHashMap(); + private static final Map BY_DATA = Maps.newHashMap(); private TreeSpecies(final int data) { this.data = (byte) data; diff --git a/api/src/main/java/org/bukkit/UnsafeValues.java b/api/src/main/java/org/bukkit/UnsafeValues.java index f462b631b..b173e2ece 100644 --- a/api/src/main/java/org/bukkit/UnsafeValues.java +++ b/api/src/main/java/org/bukkit/UnsafeValues.java @@ -28,6 +28,8 @@ public interface UnsafeValues { BlockData fromLegacy(Material material, byte data); + Material getMaterial(String material, int version); + int getDataVersion(); ItemStack modifyItemStack(ItemStack stack, String arguments); @@ -68,9 +70,22 @@ public interface UnsafeValues { */ boolean removeAdvancement(NamespacedKey key); - // Paper start - Add legacy check util + // Paper start + /** + * Server name to report to timings v2 + * @return name + */ + String getTimingsServerName(); + + /** + * Called once by the version command on first use, then cached. + */ + default com.destroystokyo.paper.util.VersionFetcher getVersionFetcher() { + return new com.destroystokyo.paper.util.VersionFetcher.DummyVersionFetcher(); + } + static boolean isLegacyPlugin(org.bukkit.plugin.Plugin plugin) { - return !("1.13".equals(plugin.getDescription().getAPIVersion())); + return !"1.13".equals(plugin.getDescription().getAPIVersion()) && !"1.14".equals(plugin.getDescription().getAPIVersion()); } // Paper end } diff --git a/api/src/main/java/org/bukkit/Warning.java b/api/src/main/java/org/bukkit/Warning.java index f86f25a0d..91c9cb8fa 100644 --- a/api/src/main/java/org/bukkit/Warning.java +++ b/api/src/main/java/org/bukkit/Warning.java @@ -1,12 +1,11 @@ package org.bukkit; +import com.google.common.collect.ImmutableMap; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import java.util.Map; - -import com.google.common.collect.ImmutableMap; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/api/src/main/java/org/bukkit/World.java b/api/src/main/java/org/bukkit/World.java index b22895c22..2d22ab30a 100644 --- a/api/src/main/java/org/bukkit/World.java +++ b/api/src/main/java/org/bukkit/World.java @@ -10,15 +10,24 @@ import java.util.List; import java.util.Map; import java.util.UUID; import java.util.function.Predicate; - import org.bukkit.block.Biome; import org.bukkit.block.Block; import org.bukkit.block.data.BlockData; -import org.bukkit.entity.*; +import org.bukkit.entity.AbstractArrow; +import org.bukkit.entity.Arrow; +import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.FallingBlock; +import org.bukkit.entity.Item; +import org.bukkit.entity.LightningStrike; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; import org.bukkit.generator.BlockPopulator; +import org.bukkit.generator.ChunkGenerator; import org.bukkit.inventory.ItemStack; import org.bukkit.material.MaterialData; import org.bukkit.metadata.Metadatable; +import org.bukkit.plugin.Plugin; import org.bukkit.plugin.messaging.PluginMessageRecipient; import org.bukkit.util.BoundingBox; import org.bukkit.util.Consumer; @@ -33,22 +42,6 @@ import org.jetbrains.annotations.Nullable; */ public interface World extends PluginMessageRecipient, Metadatable { - // Akarin start - /** - * Get the nearest village of the location in range. - * - * @return The nearest village, null if there is no village in range. - */ - public io.akarin.server.api.structure.Village getNearestVillage(@NotNull Location location, double xRadius, double yRadius, double zRadius); - - /** - * Get villages which are near by the location in range. - * - * @return All the villages in range, an empty list if there is no village in range. - */ - public List getVillagesInRange(@NotNull Location location, double xRadius, double yRadius, double zRadius); - // Akarin end - // Paper start /** * @return The amount of Entities in this world @@ -169,6 +162,79 @@ public interface World extends PluginMessageRecipient, Metadatable { @NotNull public Block getHighestBlockAt(@NotNull Location location); + // Paper start - Add heightmap API + /** + * Returns the highest block's y-coordinate at the specified block coordinates that match the specified heightmap's conditions. + *

+ * implNote: Implementations are recommended to use an iterative search as a fallback before resorting to + * throwing an {@code UnsupportedOperationException}. + *

+ * + * @param x The block's x-coordinate. + * @param z The block's z-coordinate. + * @param heightmap The specified heightmap to use. See {@link com.destroystokyo.paper.HeightmapType} + * @return The highest block's y-coordinate at (x, z) that matches the specified heightmap's conditions. + * @throws UnsupportedOperationException If the heightmap type is not supported. + * + * @see com.destroystokyo.paper.HeightmapType + */ + public int getHighestBlockYAt(int x, int z, @NotNull com.destroystokyo.paper.HeightmapType heightmap) throws UnsupportedOperationException; + + /** + * Returns the highest block's y-coordinate at the specified block coordinates that match the specified heightmap's conditions. + * Note that the y-coordinate of the specified location is ignored. + *

+ * implNote: Implementations are recommended to use an iterative search as a fallback before resorting to + * throwing an {@code UnsupportedOperationException}. + *

+ * + * @param location The specified block coordinates. + * @param heightmap The specified heightmap to use. See {@link com.destroystokyo.paper.HeightmapType} + * @return The highest block's y-coordinate at {@code location} that matches the specified heightmap's conditions. + * @throws UnsupportedOperationException If the heightmap type is not supported. + * @see com.destroystokyo.paper.HeightmapType + */ + default int getHighestBlockYAt(@NotNull Location location, @NotNull com.destroystokyo.paper.HeightmapType heightmap) throws UnsupportedOperationException { + return this.getHighestBlockYAt(location.getBlockX(), location.getBlockZ(), heightmap); + } + + /** + * Returns the highest {@link Block} at the specified block coordinates that match the specified heightmap's conditions. + *

+ * implNote: Implementations are recommended to use an iterative search as a fallback before resorting to + * throwing an {@code UnsupportedOperationException}. + *

+ * @param x The block's x-coordinate. + * @param z The block's z-coordinate. + * @param heightmap The specified heightmap to use. See {@link com.destroystokyo.paper.HeightmapType} + * @return The highest {@link Block} at (x, z) that matches the specified heightmap's conditions. + * @throws UnsupportedOperationException If the heightmap type is not supported. + * @see com.destroystokyo.paper.HeightmapType + */ + @NotNull + default Block getHighestBlockAt(int x, int z, @NotNull com.destroystokyo.paper.HeightmapType heightmap) throws UnsupportedOperationException { + return this.getBlockAt(x, this.getHighestBlockYAt(x, z, heightmap), z); + } + + /** + * Returns the highest {@link Block} at the specified block coordinates that match the specified heightmap's conditions. + * Note that the y-coordinate of the specified location is ignored. + *

+ * implNote: Implementations are recommended to use an iterative search as a fallback before resorting to + * throwing an {@code UnsupportedOperationException}. + *

+ * @param location The specified block coordinates. + * @param heightmap The specified heightmap to use. See {@link com.destroystokyo.paper.HeightmapType} + * @return The highest {@link Block} at {@code location} that matches the specified heightmap's conditions. + * @throws UnsupportedOperationException If the heightmap type is not supported. + * @see com.destroystokyo.paper.HeightmapType + */ + @NotNull + default Block getHighestBlockAt(@NotNull Location location, @NotNull com.destroystokyo.paper.HeightmapType heightmap) throws UnsupportedOperationException { + return this.getHighestBlockAt(location.getBlockX(), location.getBlockZ(), heightmap); + } + // Paper end + /** * Gets the {@link Chunk} at the given coordinates * @@ -593,7 +659,11 @@ public interface World extends PluginMessageRecipient, Metadatable { public Chunk[] getLoadedChunks(); /** - * Loads the specified {@link Chunk} + * Loads the specified {@link Chunk}. + *

+ * This method will keep the specified chunk loaded until one of the + * unload methods is manually called. Callers are advised to instead use + * getChunkAt which will only temporarily load the requested chunk. * * @param chunk The chunk to load */ @@ -625,11 +695,19 @@ public interface World extends PluginMessageRecipient, Metadatable { * @param z Z-coordinate of the chunk * @return true if the chunk is loaded and in use by one or more players, * otherwise false + * @deprecated This method was added to facilitate chunk garbage collection. + * As of the current Minecraft version chunks are now strictly managed and + * will not be loaded for more than 1 tick unless they are in use. */ + @Deprecated public boolean isChunkInUse(int x, int z); /** - * Loads the {@link Chunk} at the specified coordinates + * Loads the {@link Chunk} at the specified coordinates. + *

+ * This method will keep the specified chunk loaded until one of the + * unload methods is manually called. Callers are advised to instead use + * getChunkAt which will only temporarily load the requested chunk. *

* If the chunk does not exist, it will be generated. *

@@ -642,7 +720,11 @@ public interface World extends PluginMessageRecipient, Metadatable { public void loadChunk(int x, int z); /** - * Loads the {@link Chunk} at the specified coordinates + * Loads the {@link Chunk} at the specified coordinates. + *

+ * This method will keep the specified chunk loaded until one of the + * unload methods is manually called. Callers are advised to instead use + * getChunkAt which will only temporarily load the requested chunk. * * @param x X-coordinate of the chunk * @param z Z-coordinate of the chunk @@ -655,8 +737,8 @@ public interface World extends PluginMessageRecipient, Metadatable { /** * Safely unloads and saves the {@link Chunk} at the specified coordinates *

- * This method is analogous to {@link #unloadChunk(int, int, boolean, - * boolean)} where safe and save is true + * This method is analogous to {@link #unloadChunk(int, int, boolean)} + * where save is true. * * @param chunk the chunk to unload * @return true if the chunk has unloaded successfully, otherwise false @@ -666,8 +748,8 @@ public interface World extends PluginMessageRecipient, Metadatable { /** * Safely unloads and saves the {@link Chunk} at the specified coordinates *

- * This method is analogous to {@link #unloadChunk(int, int, boolean, - * boolean)} where safe and saveis true + * This method is analogous to {@link #unloadChunk(int, int, boolean)} + * where save is true. * * @param x X-coordinate of the chunk * @param z Z-coordinate of the chunk @@ -677,10 +759,7 @@ public interface World extends PluginMessageRecipient, Metadatable { /** * Safely unloads and optionally saves the {@link Chunk} at the specified - * coordinates - *

- * This method is analogous to {@link #unloadChunk(int, int, boolean, - * boolean)} where save is true + * coordinates. * * @param x X-coordinate of the chunk * @param z Z-coordinate of the chunk @@ -689,27 +768,9 @@ public interface World extends PluginMessageRecipient, Metadatable { */ public boolean unloadChunk(int x, int z, boolean save); - /** - * Unloads and optionally saves the {@link Chunk} at the specified - * coordinates - * - * @param x X-coordinate of the chunk - * @param z Z-coordinate of the chunk - * @param save Controls whether the chunk is saved - * @param safe Controls whether to unload the chunk when players are - * nearby - * @return true if the chunk has unloaded successfully, otherwise false - * @deprecated it is never safe to remove a chunk in use - */ - @Deprecated - public boolean unloadChunk(int x, int z, boolean save, boolean safe); - /** * Safely queues the {@link Chunk} at the specified coordinates for - * unloading - *

- * This method is analogous to {@link #unloadChunkRequest(int, int, - * boolean)} where safe is true + * unloading. * * @param x X-coordinate of the chunk * @param z Z-coordinate of the chunk @@ -717,18 +778,6 @@ public interface World extends PluginMessageRecipient, Metadatable { */ public boolean unloadChunkRequest(int x, int z); - /** - * Queues the {@link Chunk} at the specified coordinates for unloading - * - * @param x X-coordinate of the chunk - * @param z Z-coordinate of the chunk - * @param safe Controls whether to queue the chunk when players are nearby - * @return Whether the chunk was actually queued - * @deprecated it is never safe to remove a chunk in use - */ - @Deprecated - public boolean unloadChunkRequest(int x, int z, boolean safe); - /** * Regenerates the {@link Chunk} at the specified coordinates * @@ -749,7 +798,7 @@ public interface World extends PluginMessageRecipient, Metadatable { * @param x X-coordinate of the chunk * @param z Z-coordinate of the chunk * @return Whether the chunk was actually refreshed - * + * * @deprecated This method is not guaranteed to work suitably across all client implementations. */ @Deprecated @@ -775,7 +824,7 @@ public interface World extends PluginMessageRecipient, Metadatable { * * @param x X-coordinate of the chunk * @param z Z-coordinate of the chunk - * @param forced + * @param forced force load status */ public void setChunkForceLoaded(int x, int z, boolean forced); @@ -789,6 +838,94 @@ public interface World extends PluginMessageRecipient, Metadatable { @NotNull public Collection getForceLoadedChunks(); + /** + * Adds a plugin ticket for the specified chunk, loading the chunk if it is + * not already loaded. + *

+ * A plugin ticket will prevent a chunk from unloading until it is + * explicitly removed. A plugin instance may only have one ticket per chunk, + * but each chunk can have multiple plugin tickets. + *

+ * + * @param x X-coordinate of the chunk + * @param z Z-coordinate of the chunk + * @param plugin Plugin which owns the ticket + * @return {@code true} if a plugin ticket was added, {@code false} if the + * ticket already exists for the plugin + * @throws IllegalStateException If the specified plugin is not enabled + * @see #removePluginChunkTicket(int, int, Plugin) + */ + public boolean addPluginChunkTicket(int x, int z, @NotNull Plugin plugin); + + /** + * Removes the specified plugin's ticket for the specified chunk + *

+ * A plugin ticket will prevent a chunk from unloading until it is + * explicitly removed. A plugin instance may only have one ticket per chunk, + * but each chunk can have multiple plugin tickets. + *

+ * + * @param x X-coordinate of the chunk + * @param z Z-coordinate of the chunk + * @param plugin Plugin which owns the ticket + * @return {@code true} if the plugin ticket was removed, {@code false} if + * there is no plugin ticket for the chunk + * @see #addPluginChunkTicket(int, int, Plugin) + */ + public boolean removePluginChunkTicket(int x, int z, @NotNull Plugin plugin); + + /** + * Removes all plugin tickets for the specified plugin + *

+ * A plugin ticket will prevent a chunk from unloading until it is + * explicitly removed. A plugin instance may only have one ticket per chunk, + * but each chunk can have multiple plugin tickets. + *

+ * + * @param plugin Specified plugin + * @see #addPluginChunkTicket(int, int, Plugin) + * @see #removePluginChunkTicket(int, int, Plugin) + */ + public void removePluginChunkTickets(@NotNull Plugin plugin); + + /** + * Retrieves a collection specifying which plugins have tickets for the + * specified chunk. This collection is not updated when plugin tickets are + * added or removed to the chunk. + *

+ * A plugin ticket will prevent a chunk from unloading until it is + * explicitly removed. A plugin instance may only have one ticket per chunk, + * but each chunk can have multiple plugin tickets. + *

+ * + * @param x X-coordinate of the chunk + * @param z Z-coordinate of the chunk + * @return unmodifiable collection containing which plugins have tickets for + * the chunk + * @see #addPluginChunkTicket(int, int, Plugin) + * @see #removePluginChunkTicket(int, int, Plugin) + */ + @NotNull + public Collection getPluginChunkTickets(int x, int z); + + /** + * Returns a map of which plugins have tickets for what chunks. The returned + * map is not updated when plugin tickets are added or removed to chunks. If + * a plugin has no tickets, it will be absent from the map. + *

+ * A plugin ticket will prevent a chunk from unloading until it is + * explicitly removed. A plugin instance may only have one ticket per chunk, + * but each chunk can have multiple plugin tickets. + *

+ * + * @return unmodifiable map containing which plugins have tickets for what + * chunks + * @see #addPluginChunkTicket(int, int, Plugin) + * @see #removePluginChunkTicket(int, int, Plugin) + */ + @NotNull + public Map> getPluginChunkTickets(); + /** * Drops an item at the specified {@link Location} * @@ -834,7 +971,7 @@ public interface World extends PluginMessageRecipient, Metadatable { * @return Arrow entity spawned as a result of this method */ @NotNull - public T spawnArrow(@NotNull Location location, @NotNull Vector direction, float speed, float spread, @NotNull Class clazz); + public T spawnArrow(@NotNull Location location, @NotNull Vector direction, float speed, float spread, @NotNull Class clazz); /** * Creates a tree at the given {@link Location} @@ -916,7 +1053,7 @@ public interface World extends PluginMessageRecipient, Metadatable { /** * Get a collection of all entities in this World matching the given * class/interface - * + * * @param an entity subclass * @param cls The class representing the type of entity to match * @return A List of all Entities currently residing in this world that @@ -1638,6 +1775,21 @@ public interface World extends PluginMessageRecipient, Metadatable { */ public boolean createExplosion(double x, double y, double z, float power, boolean setFire, boolean breakBlocks); + /** + * Creates explosion at given coordinates with given power and optionally + * setting blocks on fire or breaking blocks. + * + * @param x X coordinate + * @param y Y coordinate + * @param z Z coordinate + * @param power The power of explosion, where 4F is TNT + * @param setFire Whether or not to set blocks on fire + * @param breakBlocks Whether or not to have blocks be destroyed + * @param source the source entity, used for tracking damage + * @return false if explosion was canceled, otherwise true + */ + public boolean createExplosion(double x, double y, double z, float power, boolean setFire, boolean breakBlocks, @Nullable Entity source); + /** * Creates explosion at given coordinates with given power * @@ -1738,9 +1890,10 @@ public interface World extends PluginMessageRecipient, Metadatable { public default boolean createExplosion(@NotNull Entity source, float power) { return createExplosion(source, source.getLocation(), power, true, true); } + // Paper end /** - * Creates explosion at given location with given power and optionally + * Creates explosion at given coordinates with given power and optionally * setting blocks on fire or breaking blocks. * * @param loc Location to blow up @@ -1749,10 +1902,20 @@ public interface World extends PluginMessageRecipient, Metadatable { * @param breakBlocks Whether or not to have blocks be destroyed * @return false if explosion was canceled, otherwise true */ - public default boolean createExplosion(@NotNull Location loc, float power, boolean setFire, boolean breakBlocks) { - return createExplosion(loc.getX(), loc.getY(), loc.getZ(), power, setFire, breakBlocks); - } - // Paper end + public boolean createExplosion(@NotNull Location loc, float power, boolean setFire, boolean breakBlocks); + + /** + * Creates explosion at given coordinates with given power and optionally + * setting blocks on fire or breaking blocks. + * + * @param loc Location to blow up + * @param power The power of explosion, where 4F is TNT + * @param setFire Whether or not to set blocks on fire + * @param breakBlocks Whether or not to have blocks be destroyed + * @param source the source entity, used for tracking damage + * @return false if explosion was canceled, otherwise true + */ + public boolean createExplosion(@NotNull Location loc, float power, boolean setFire, boolean breakBlocks, @Nullable Entity source); /** * Gets the {@link Environment} type of this world @@ -2230,7 +2393,7 @@ public interface World extends PluginMessageRecipient, Metadatable { *

* Note: If set to a negative number the world will use the * server-wide spawn limit instead. - * + * * @param limit the new mob limit */ void setMonsterSpawnLimit(int limit); @@ -2249,7 +2412,7 @@ public interface World extends PluginMessageRecipient, Metadatable { *

* Note: If set to a negative number the world will use the * server-wide spawn limit instead. - * + * * @param limit the new mob limit */ void setAnimalSpawnLimit(int limit); @@ -2268,7 +2431,7 @@ public interface World extends PluginMessageRecipient, Metadatable { *

* Note: If set to a negative number the world will use the * server-wide spawn limit instead. - * + * * @param limit the new mob limit */ void setWaterAnimalSpawnLimit(int limit); @@ -2287,7 +2450,7 @@ public interface World extends PluginMessageRecipient, Metadatable { *

* Note: If set to a negative number the world will use the * server-wide spawn limit instead. - * + * * @param limit the new mob limit */ void setAmbientSpawnLimit(int limit); @@ -2457,6 +2620,7 @@ public interface World extends PluginMessageRecipient, Metadatable { * Spawns the particle (the number of times specified by count) * at the target location. * + * @param type of particle data (see {@link Particle#getDataType()} * @param particle the particle to spawn * @param location the location to spawn at * @param count the number of particles @@ -2471,6 +2635,7 @@ public interface World extends PluginMessageRecipient, Metadatable { * Spawns the particle (the number of times specified by count) * at the target location. * + * @param type of particle data (see {@link Particle#getDataType()} * @param particle the particle to spawn * @param x the position on the x axis to spawn at * @param y the position on the y axis to spawn at @@ -2520,6 +2685,7 @@ public interface World extends PluginMessageRecipient, Metadatable { * randomized positively and negatively by the offset parameters * on each axis. * + * @param type of particle data (see {@link Particle#getDataType()} * @param particle the particle to spawn * @param location the location to spawn at * @param count the number of particles @@ -2538,6 +2704,7 @@ public interface World extends PluginMessageRecipient, Metadatable { * randomized positively and negatively by the offset parameters * on each axis. * + * @param type of particle data (see {@link Particle#getDataType()} * @param particle the particle to spawn * @param x the position on the x axis to spawn at * @param y the position on the y axis to spawn at @@ -2594,6 +2761,7 @@ public interface World extends PluginMessageRecipient, Metadatable { * randomized positively and negatively by the offset parameters * on each axis. * + * @param type of particle data (see {@link Particle#getDataType()} * @param particle the particle to spawn * @param location the location to spawn at * @param count the number of particles @@ -2614,6 +2782,7 @@ public interface World extends PluginMessageRecipient, Metadatable { * randomized positively and negatively by the offset parameters * on each axis. * + * @param type of particle data (see {@link Particle#getDataType()} * @param particle the particle to spawn * @param x the position on the x axis to spawn at * @param y the position on the y axis to spawn at @@ -2686,6 +2855,7 @@ public interface World extends PluginMessageRecipient, Metadatable { * randomized positively and negatively by the offset parameters * on each axis. * + * @param type of particle data (see {@link Particle#getDataType()} * @param particle the particle to spawn * @param location the location to spawn at * @param count the number of particles @@ -2709,6 +2879,7 @@ public interface World extends PluginMessageRecipient, Metadatable { * randomized positively and negatively by the offset parameters * on each axis. * + * @param type of particle data (see {@link Particle#getDataType()} * @param particle the particle to spawn * @param x the position on the x axis to spawn at * @param y the position on the y axis to spawn at @@ -2755,6 +2926,15 @@ public interface World extends PluginMessageRecipient, Metadatable { @Nullable public Location locateNearestStructure(@NotNull Location origin, @NotNull StructureType structureType, int radius, boolean findUnexplored); + // Spigot start + /** + * Returns the view distance used for this world. + * + * @return the view distance used for this world + */ + int getViewDistance(); + // Spigot end + // Spigot start public class Spigot { @@ -2790,6 +2970,24 @@ public interface World extends PluginMessageRecipient, Metadatable { Spigot spigot(); // Spigot end + /** + * Finds the nearest raid close to the given location. + * + * @param location the origin location + * @param radius the radius + * @return the closest {@link Raid}, or null if no raids were found + */ + @Nullable + public Raid locateNearestRaid(@NotNull Location location, int radius); + + /** + * Gets all raids that are going on over this world. + * + * @return the list of all active raids + */ + @NotNull + public List getRaids(); + /** * Represents various map environment types that a world may be */ diff --git a/api/src/main/java/org/bukkit/WorldCreator.java b/api/src/main/java/org/bukkit/WorldCreator.java index a9b29b6e2..435fce5b0 100644 --- a/api/src/main/java/org/bukkit/WorldCreator.java +++ b/api/src/main/java/org/bukkit/WorldCreator.java @@ -48,6 +48,8 @@ public class WorldCreator { seed = world.getSeed(); environment = world.getEnvironment(); generator = world.getGenerator(); + type = world.getWorldType(); + generateStructures = world.canGenerateStructures(); return this; } @@ -67,6 +69,9 @@ public class WorldCreator { seed = creator.seed(); environment = creator.environment(); generator = creator.generator(); + type = creator.type(); + generateStructures = creator.generateStructures(); + generatorSettings = creator.generatorSettings(); return this; } diff --git a/api/src/main/java/org/bukkit/WorldType.java b/api/src/main/java/org/bukkit/WorldType.java index e82fe0767..f98b13e71 100644 --- a/api/src/main/java/org/bukkit/WorldType.java +++ b/api/src/main/java/org/bukkit/WorldType.java @@ -1,11 +1,10 @@ package org.bukkit; import com.google.common.collect.Maps; +import java.util.Map; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.Map; - /** * Represents various types of worlds that may exist */ @@ -18,7 +17,7 @@ public enum WorldType { CUSTOMIZED("CUSTOMIZED"), BUFFET("BUFFET"); - private final static Map BY_NAME = Maps.newHashMap(); + private static final Map BY_NAME = Maps.newHashMap(); private final String name; private WorldType(/*@NotNull*/ String name) { diff --git a/api/src/main/java/org/bukkit/advancement/AdvancementProgress.java b/api/src/main/java/org/bukkit/advancement/AdvancementProgress.java index 00823dc9b..f9bc179da 100644 --- a/api/src/main/java/org/bukkit/advancement/AdvancementProgress.java +++ b/api/src/main/java/org/bukkit/advancement/AdvancementProgress.java @@ -1,10 +1,9 @@ package org.bukkit.advancement; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - import java.util.Collection; import java.util.Date; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * The individual status of an advancement for a player. This class is not diff --git a/api/src/main/java/org/bukkit/attribute/AttributeInstance.java b/api/src/main/java/org/bukkit/attribute/AttributeInstance.java index 18bafb04e..f08ee26cc 100644 --- a/api/src/main/java/org/bukkit/attribute/AttributeInstance.java +++ b/api/src/main/java/org/bukkit/attribute/AttributeInstance.java @@ -1,8 +1,7 @@ package org.bukkit.attribute; -import org.jetbrains.annotations.NotNull; - import java.util.Collection; +import org.jetbrains.annotations.NotNull; /** * Represents a mutable instance of an attribute and its associated modifiers diff --git a/api/src/main/java/org/bukkit/block/Banner.java b/api/src/main/java/org/bukkit/block/Banner.java index befa9da6f..e6eb3c04b 100644 --- a/api/src/main/java/org/bukkit/block/Banner.java +++ b/api/src/main/java/org/bukkit/block/Banner.java @@ -1,15 +1,14 @@ package org.bukkit.block; +import java.util.List; import org.bukkit.DyeColor; import org.bukkit.block.banner.Pattern; import org.jetbrains.annotations.NotNull; -import java.util.List; - /** * Represents a captured state of a banner. */ -public interface Banner extends BlockState { +public interface Banner extends TileState { /** * Returns the base color for this banner diff --git a/api/src/main/java/org/bukkit/block/Barrel.java b/api/src/main/java/org/bukkit/block/Barrel.java new file mode 100644 index 000000000..5eacc44ac --- /dev/null +++ b/api/src/main/java/org/bukkit/block/Barrel.java @@ -0,0 +1,8 @@ +package org.bukkit.block; + +import org.bukkit.loot.Lootable; + +/** + * Represents a captured state of a Barrel. + */ +public interface Barrel extends Container, Lootable { } diff --git a/api/src/main/java/org/bukkit/block/Beacon.java b/api/src/main/java/org/bukkit/block/Beacon.java index e5332c0a7..6349fa9da 100644 --- a/api/src/main/java/org/bukkit/block/Beacon.java +++ b/api/src/main/java/org/bukkit/block/Beacon.java @@ -3,7 +3,6 @@ package org.bukkit.block; import java.util.Collection; import org.bukkit.Nameable; import org.bukkit.entity.LivingEntity; -import org.bukkit.inventory.BeaconInventory; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; import org.jetbrains.annotations.NotNull; @@ -12,15 +11,7 @@ import org.jetbrains.annotations.Nullable; /** * Represents a captured state of a beacon. */ -public interface Beacon extends Container, Nameable { - - @NotNull - @Override - BeaconInventory getInventory(); - - @NotNull - @Override - BeaconInventory getSnapshotInventory(); +public interface Beacon extends TileState, Lockable, Nameable { /** * Returns the list of players within the beacon's range of effect. diff --git a/api/src/main/java/org/bukkit/block/Bed.java b/api/src/main/java/org/bukkit/block/Bed.java index a2393852e..f9bd74f9c 100644 --- a/api/src/main/java/org/bukkit/block/Bed.java +++ b/api/src/main/java/org/bukkit/block/Bed.java @@ -7,4 +7,4 @@ import org.bukkit.material.Colorable; * @deprecated does not provide useful information beyond the material itself */ @Deprecated -public interface Bed extends BlockState, Colorable { } +public interface Bed extends TileState, Colorable { } diff --git a/api/src/main/java/org/bukkit/block/Bell.java b/api/src/main/java/org/bukkit/block/Bell.java new file mode 100644 index 000000000..6fee356a3 --- /dev/null +++ b/api/src/main/java/org/bukkit/block/Bell.java @@ -0,0 +1,6 @@ +package org.bukkit.block; + +/** + * Represents a captured state of Bell. + */ +public interface Bell extends TileState { } diff --git a/api/src/main/java/org/bukkit/block/Biome.java b/api/src/main/java/org/bukkit/block/Biome.java index a3b310b73..55386ffe0 100644 --- a/api/src/main/java/org/bukkit/block/Biome.java +++ b/api/src/main/java/org/bukkit/block/Biome.java @@ -1,9 +1,14 @@ package org.bukkit.block; +import java.util.Locale; +import org.bukkit.Keyed; +import org.bukkit.NamespacedKey; +import org.jetbrains.annotations.NotNull; + /** * Holds all accepted Biomes in the default server */ -public enum Biome { +public enum Biome implements Keyed { OCEAN, PLAINS, DESERT, @@ -76,5 +81,19 @@ public enum Biome { SHATTERED_SAVANNA_PLATEAU, ERODED_BADLANDS, MODIFIED_WOODED_BADLANDS_PLATEAU, - MODIFIED_BADLANDS_PLATEAU + MODIFIED_BADLANDS_PLATEAU, + BAMBOO_JUNGLE, + BAMBOO_JUNGLE_HILLS; + + private final NamespacedKey key; + + private Biome() { + this.key = NamespacedKey.minecraft(name().toLowerCase(Locale.ROOT)); + } + + @NotNull + @Override + public NamespacedKey getKey() { + return key; + } } diff --git a/api/src/main/java/org/bukkit/block/BlastFurnace.java b/api/src/main/java/org/bukkit/block/BlastFurnace.java new file mode 100644 index 000000000..3c4d8571b --- /dev/null +++ b/api/src/main/java/org/bukkit/block/BlastFurnace.java @@ -0,0 +1,6 @@ +package org.bukkit.block; + +/** + * Represents a captured state of a blast furnace. + */ +public interface BlastFurnace extends Furnace { } diff --git a/api/src/main/java/org/bukkit/block/Block.java b/api/src/main/java/org/bukkit/block/Block.java index c20f903a9..038de5a64 100644 --- a/api/src/main/java/org/bukkit/block/Block.java +++ b/api/src/main/java/org/bukkit/block/Block.java @@ -170,20 +170,16 @@ public interface Block extends Metadatable { * The return value can be computed as follows: *
* {@code long value = ((long)x & 0x7FFFFFF) | (((long)z & 0x7FFFFFF) << 27) | ((long)y << 54);} - *
*

* *

* And may be unpacked as follows: *
* {@code int x = (int) ((packed << 37) >> 37);} - *
*
* {@code int y = (int) (packed >>> 54);} - *
*
* {@code int z = (int) ((packed << 10) >> 37);} - *
*

* * @return This block's x, y, and z coordinates packed into a long value @@ -311,7 +307,7 @@ public interface Block extends Metadatable { /** * Gets the face relation of this block compared to the given block. *

- * For example: + * For example: *

{@code
      * Block current = world.getBlockAt(100, 100, 100);
      * Block target = world.getBlockAt(100, 101, 100);
@@ -532,4 +528,16 @@ public interface Block extends Metadatable {
      */
     @NotNull
     BoundingBox getBoundingBox();
+
+    // Paper start
+    /**
+     * Gets the {@link com.destroystokyo.paper.block.BlockSoundGroup} for this block.
+     * 

+ * This object contains the block, step, place, hit, and fall sounds. + * + * @return the sound group for this block + */ + @NotNull + com.destroystokyo.paper.block.BlockSoundGroup getSoundGroup(); + // Paper end } diff --git a/api/src/main/java/org/bukkit/block/BrewingStand.java b/api/src/main/java/org/bukkit/block/BrewingStand.java index 7611a126c..fe155f14d 100644 --- a/api/src/main/java/org/bukkit/block/BrewingStand.java +++ b/api/src/main/java/org/bukkit/block/BrewingStand.java @@ -1,13 +1,12 @@ package org.bukkit.block; -import org.bukkit.Nameable; import org.bukkit.inventory.BrewerInventory; import org.jetbrains.annotations.NotNull; /** * Represents a captured state of a brewing stand. */ -public interface BrewingStand extends Container, Nameable { +public interface BrewingStand extends Container { /** * How much time is left in the brewing cycle. diff --git a/api/src/main/java/org/bukkit/block/Campfire.java b/api/src/main/java/org/bukkit/block/Campfire.java new file mode 100644 index 000000000..09522d5e8 --- /dev/null +++ b/api/src/main/java/org/bukkit/block/Campfire.java @@ -0,0 +1,75 @@ +package org.bukkit.block; + +import org.bukkit.inventory.Inventory; +import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.Nullable; + +/** + * Represents a captured state of a campfire. + */ +public interface Campfire extends TileState { + + /** + * @see Inventory#getSize() + * + * @return The size of the inventory + */ + int getSize(); + + /** + * @see Inventory#getItem(int) + * + * @param index The index of the Slot's ItemStack to return + * @return The ItemStack in the slot + */ + @Nullable + ItemStack getItem(int index); + + /** + * @see Inventory#setItem(int, org.bukkit.inventory.ItemStack) + * + * @param index The index where to put the ItemStack + * @param item The ItemStack to set + */ + void setItem(int index, @Nullable ItemStack item); + + /** + * Get cook time. + * + * This is the amount of time the item has been cooking for. + * + * @param index item slot index + * @return Cook time + */ + int getCookTime(int index); + + /** + * Set cook time. + * + * This is the amount of time the item has been cooking for. + * + * @param index item slot index + * @param cookTime Cook time + */ + void setCookTime(int index, int cookTime); + + /** + * Get cook time total. + * + * This is the amount of time the item is required to cook for. + * + * @param index item slot index + * @return Cook time total + */ + int getCookTimeTotal(int index); + + /** + * Set cook time. + * + * This is the amount of time the item is required to cook for. + * + * @param index item slot index + * @param cookTimeTotal Cook time total + */ + void setCookTimeTotal(int index, int cookTimeTotal); +} diff --git a/api/src/main/java/org/bukkit/block/Chest.java b/api/src/main/java/org/bukkit/block/Chest.java index eb475ec84..a569c7b63 100644 --- a/api/src/main/java/org/bukkit/block/Chest.java +++ b/api/src/main/java/org/bukkit/block/Chest.java @@ -1,7 +1,7 @@ package org.bukkit.block; -import com.destroystokyo.paper.loottable.LootableBlockInventory; -import org.bukkit.Nameable; +import com.destroystokyo.paper.loottable.LootableBlockInventory; // Paper +import org.bukkit.Nameable; // Paper import org.bukkit.inventory.Inventory; import org.bukkit.loot.Lootable; import org.jetbrains.annotations.NotNull; @@ -9,7 +9,7 @@ import org.jetbrains.annotations.NotNull; /** * Represents a captured state of a chest. */ -public interface Chest extends Container, Nameable, LootableBlockInventory { // Paper +public interface Chest extends Container, LootableBlockInventory { // Paper /** * Gets the inventory of the chest block represented by this block state. diff --git a/api/src/main/java/org/bukkit/block/CommandBlock.java b/api/src/main/java/org/bukkit/block/CommandBlock.java index b7ee5bc94..372c0bd5a 100644 --- a/api/src/main/java/org/bukkit/block/CommandBlock.java +++ b/api/src/main/java/org/bukkit/block/CommandBlock.java @@ -6,7 +6,7 @@ import org.jetbrains.annotations.Nullable; /** * Represents a captured state of a command block. */ -public interface CommandBlock extends BlockState { +public interface CommandBlock extends TileState { /** * Gets the command that this CommandBlock will run when powered. diff --git a/api/src/main/java/org/bukkit/block/Comparator.java b/api/src/main/java/org/bukkit/block/Comparator.java index c9acc916d..6fb4c1a94 100644 --- a/api/src/main/java/org/bukkit/block/Comparator.java +++ b/api/src/main/java/org/bukkit/block/Comparator.java @@ -3,4 +3,4 @@ package org.bukkit.block; /** * Represents a captured state of an on / off comparator. */ -public interface Comparator extends BlockState { } +public interface Comparator extends TileState { } diff --git a/api/src/main/java/org/bukkit/block/Conduit.java b/api/src/main/java/org/bukkit/block/Conduit.java index d889f41b7..554316553 100644 --- a/api/src/main/java/org/bukkit/block/Conduit.java +++ b/api/src/main/java/org/bukkit/block/Conduit.java @@ -3,4 +3,4 @@ package org.bukkit.block; /** * Represents a captured state of a conduit. */ -public interface Conduit extends BlockState { } +public interface Conduit extends TileState { } diff --git a/api/src/main/java/org/bukkit/block/Container.java b/api/src/main/java/org/bukkit/block/Container.java index 96888ba89..bc06199f0 100644 --- a/api/src/main/java/org/bukkit/block/Container.java +++ b/api/src/main/java/org/bukkit/block/Container.java @@ -1,13 +1,14 @@ package org.bukkit.block; +import org.bukkit.Nameable; +import org.bukkit.inventory.BlockInventoryHolder; import org.bukkit.inventory.Inventory; -import org.bukkit.inventory.InventoryHolder; import org.jetbrains.annotations.NotNull; /** * Represents a captured state of a container block. */ -public interface Container extends BlockState, InventoryHolder, Lockable { +public interface Container extends TileState, BlockInventoryHolder, Lockable, Nameable { /** * Gets the inventory of the block represented by this block state. diff --git a/api/src/main/java/org/bukkit/block/CreatureSpawner.java b/api/src/main/java/org/bukkit/block/CreatureSpawner.java index 5773e99ee..2ff0f24d5 100644 --- a/api/src/main/java/org/bukkit/block/CreatureSpawner.java +++ b/api/src/main/java/org/bukkit/block/CreatureSpawner.java @@ -6,7 +6,7 @@ import org.jetbrains.annotations.NotNull; /** * Represents a captured state of a creature spawner. */ -public interface CreatureSpawner extends BlockState { +public interface CreatureSpawner extends TileState { /** * Get the spawner's creature type. @@ -199,4 +199,18 @@ public interface CreatureSpawner extends BlockState { * @param spawnRange the new spawn range */ public void setSpawnRange(int spawnRange); + + // Paper start + /** + * Check if spawner is activated (a player is close enough) + * + * @return True if a player is close enough to activate it + */ + public boolean isActivated(); + + /** + * Resets the spawn delay timer within the min/max range + */ + public void resetTimer(); + // Paper end } diff --git a/api/src/main/java/org/bukkit/block/DaylightDetector.java b/api/src/main/java/org/bukkit/block/DaylightDetector.java index ea4117ea8..702ee7fbe 100644 --- a/api/src/main/java/org/bukkit/block/DaylightDetector.java +++ b/api/src/main/java/org/bukkit/block/DaylightDetector.java @@ -3,4 +3,4 @@ package org.bukkit.block; /** * Represents a captured state of a (possibly inverted) daylight detector. */ -public interface DaylightDetector extends BlockState { } +public interface DaylightDetector extends TileState { } diff --git a/api/src/main/java/org/bukkit/block/DoubleChest.java b/api/src/main/java/org/bukkit/block/DoubleChest.java index 97153adfa..83a464211 100644 --- a/api/src/main/java/org/bukkit/block/DoubleChest.java +++ b/api/src/main/java/org/bukkit/block/DoubleChest.java @@ -18,6 +18,7 @@ public class DoubleChest implements InventoryHolder { inventory = chest; } + @Override @NotNull public Inventory getInventory() { return inventory; diff --git a/api/src/main/java/org/bukkit/block/Dropper.java b/api/src/main/java/org/bukkit/block/Dropper.java index 47737b590..c76202321 100644 --- a/api/src/main/java/org/bukkit/block/Dropper.java +++ b/api/src/main/java/org/bukkit/block/Dropper.java @@ -1,13 +1,12 @@ package org.bukkit.block; import com.destroystokyo.paper.loottable.LootableBlockInventory; -import org.bukkit.Nameable; import org.bukkit.loot.Lootable; /** * Represents a captured state of a dropper. */ -public interface Dropper extends Container, Nameable, LootableBlockInventory { // Paper +public interface Dropper extends Container, LootableBlockInventory { // Paper /** * Tries to drop a randomly selected item from the dropper's inventory, @@ -16,7 +15,7 @@ public interface Dropper extends Container, Nameable, LootableBlockInventory { / * Normal behavior of a dropper is as follows: *

* If the block that the dropper is facing is an InventoryHolder, - * the randomly selected ItemStack is placed within that + * the randomly selected ItemStack is placed within that * Inventory in the first slot that's available, starting with 0 and * counting up. If the inventory is full, nothing happens. *

@@ -26,7 +25,7 @@ public interface Dropper extends Container, Nameable, LootableBlockInventory { / *

* If the block represented by this state is no longer a dropper, this will * do nothing. - * + * * @throws IllegalStateException if this block state is not placed */ public void drop(); diff --git a/api/src/main/java/org/bukkit/block/EnchantingTable.java b/api/src/main/java/org/bukkit/block/EnchantingTable.java index 9f5aa6c6c..68b9e034a 100644 --- a/api/src/main/java/org/bukkit/block/EnchantingTable.java +++ b/api/src/main/java/org/bukkit/block/EnchantingTable.java @@ -5,4 +5,4 @@ import org.bukkit.Nameable; /** * Represents a captured state of an enchanting table. */ -public interface EnchantingTable extends BlockState, Nameable { } +public interface EnchantingTable extends TileState, Nameable { } diff --git a/api/src/main/java/org/bukkit/block/EndGateway.java b/api/src/main/java/org/bukkit/block/EndGateway.java index e737f2db2..5e76a1cf4 100644 --- a/api/src/main/java/org/bukkit/block/EndGateway.java +++ b/api/src/main/java/org/bukkit/block/EndGateway.java @@ -6,14 +6,14 @@ import org.jetbrains.annotations.Nullable; /** * Represents a captured state of an end gateway. */ -public interface EndGateway extends BlockState { +public interface EndGateway extends TileState { /** - * Gets the location that entities are teleported to when + * Gets the location that entities are teleported to when * entering the gateway portal. *

* If this block state is not placed the location's world will be null. - * + * * @return the gateway exit location */ @Nullable @@ -24,7 +24,7 @@ public interface EndGateway extends BlockState { * they enter the gateway portal. *

* If this block state is not placed the location's world has to be null. - * + * * @param location the new exit location * @throws IllegalArgumentException for differing worlds */ @@ -33,7 +33,7 @@ public interface EndGateway extends BlockState { /** * Gets whether this gateway will teleport entities directly to * the exit location instead of finding a nearby location. - * + * * @return true if the gateway is teleporting to the exact location */ boolean isExactTeleport(); @@ -41,7 +41,7 @@ public interface EndGateway extends BlockState { /** * Sets whether this gateway will teleport entities directly to * the exit location instead of finding a nearby location. - * + * * @param exact whether to teleport to the exact location */ void setExactTeleport(boolean exact); diff --git a/api/src/main/java/org/bukkit/block/EnderChest.java b/api/src/main/java/org/bukkit/block/EnderChest.java index e0eb2560f..17843e338 100644 --- a/api/src/main/java/org/bukkit/block/EnderChest.java +++ b/api/src/main/java/org/bukkit/block/EnderChest.java @@ -3,4 +3,4 @@ package org.bukkit.block; /** * Represents a captured state of an ender chest. */ -public interface EnderChest extends BlockState { } +public interface EnderChest extends TileState { } diff --git a/api/src/main/java/org/bukkit/block/Furnace.java b/api/src/main/java/org/bukkit/block/Furnace.java index 97b25dbd9..9063cf370 100644 --- a/api/src/main/java/org/bukkit/block/Furnace.java +++ b/api/src/main/java/org/bukkit/block/Furnace.java @@ -1,13 +1,12 @@ package org.bukkit.block; -import org.bukkit.Nameable; import org.bukkit.inventory.FurnaceInventory; import org.jetbrains.annotations.NotNull; /** * Represents a captured state of a furnace. */ -public interface Furnace extends Container, Nameable { +public interface Furnace extends Container { /** * Get burn time. diff --git a/api/src/main/java/org/bukkit/block/Hopper.java b/api/src/main/java/org/bukkit/block/Hopper.java index 221123e8c..7ade312f1 100644 --- a/api/src/main/java/org/bukkit/block/Hopper.java +++ b/api/src/main/java/org/bukkit/block/Hopper.java @@ -1,10 +1,9 @@ package org.bukkit.block; import com.destroystokyo.paper.loottable.LootableBlockInventory; -import org.bukkit.Nameable; import org.bukkit.loot.Lootable; /** * Represents a captured state of a hopper. */ -public interface Hopper extends Container, Nameable, LootableBlockInventory { } // Paper +public interface Hopper extends Container, LootableBlockInventory { } // Paper diff --git a/api/src/main/java/org/bukkit/block/Jigsaw.java b/api/src/main/java/org/bukkit/block/Jigsaw.java new file mode 100644 index 000000000..02c7fa58e --- /dev/null +++ b/api/src/main/java/org/bukkit/block/Jigsaw.java @@ -0,0 +1,6 @@ +package org.bukkit.block; + +/** + * Represents a captured state of a jigsaw. + */ +public interface Jigsaw extends TileState { } diff --git a/api/src/main/java/org/bukkit/block/Jukebox.java b/api/src/main/java/org/bukkit/block/Jukebox.java index 1203182f3..363294cff 100644 --- a/api/src/main/java/org/bukkit/block/Jukebox.java +++ b/api/src/main/java/org/bukkit/block/Jukebox.java @@ -8,7 +8,7 @@ import org.jetbrains.annotations.Nullable; /** * Represents a captured state of a jukebox. */ -public interface Jukebox extends BlockState { +public interface Jukebox extends TileState { /** * Gets the record inserted into the jukebox. diff --git a/api/src/main/java/org/bukkit/block/Lectern.java b/api/src/main/java/org/bukkit/block/Lectern.java new file mode 100644 index 000000000..78107207b --- /dev/null +++ b/api/src/main/java/org/bukkit/block/Lectern.java @@ -0,0 +1,45 @@ +package org.bukkit.block; + +import org.bukkit.inventory.BlockInventoryHolder; +import org.bukkit.inventory.Inventory; +import org.jetbrains.annotations.NotNull; + +/** + * Represents a captured state of a lectern. + */ +public interface Lectern extends TileState, BlockInventoryHolder { + + /** + * Get the current lectern page. + * + * @return current page + */ + int getPage(); + + /** + * Set the current lectern page. + * + * If the page is greater than the number of pages of the book currently in + * the inventory, then behavior is undefined. + * + * @param page new page + */ + void setPage(int page); + + /** + * @see Container#getInventory() + * + * @return inventory + */ + @NotNull + @Override + Inventory getInventory(); + + /** + * @see Container#getSnapshotInventory() + * + * @return snapshot inventory + */ + @NotNull + Inventory getSnapshotInventory(); +} diff --git a/api/src/main/java/org/bukkit/block/PistonMoveReaction.java b/api/src/main/java/org/bukkit/block/PistonMoveReaction.java index 02df88682..b90f5dc34 100644 --- a/api/src/main/java/org/bukkit/block/PistonMoveReaction.java +++ b/api/src/main/java/org/bukkit/block/PistonMoveReaction.java @@ -1,9 +1,8 @@ package org.bukkit.block; -import org.jetbrains.annotations.Nullable; - import java.util.HashMap; import java.util.Map; +import org.jetbrains.annotations.Nullable; /** * Represents how a block or entity will react when interacting with a piston diff --git a/api/src/main/java/org/bukkit/block/ShulkerBox.java b/api/src/main/java/org/bukkit/block/ShulkerBox.java index 8c8811d4d..42f5b4ea3 100644 --- a/api/src/main/java/org/bukkit/block/ShulkerBox.java +++ b/api/src/main/java/org/bukkit/block/ShulkerBox.java @@ -2,14 +2,13 @@ package org.bukkit.block; import com.destroystokyo.paper.loottable.LootableBlockInventory; import org.bukkit.DyeColor; -import org.bukkit.Nameable; import org.bukkit.loot.Lootable; import org.jetbrains.annotations.NotNull; /** * Represents a captured state of a ShulkerBox. */ -public interface ShulkerBox extends Container, Nameable, LootableBlockInventory { // Paper +public interface ShulkerBox extends Container, LootableBlockInventory { // Paper /** * Get the {@link DyeColor} corresponding to this ShulkerBox diff --git a/api/src/main/java/org/bukkit/block/Sign.java b/api/src/main/java/org/bukkit/block/Sign.java index 74db5efcb..7e3cf00e4 100644 --- a/api/src/main/java/org/bukkit/block/Sign.java +++ b/api/src/main/java/org/bukkit/block/Sign.java @@ -1,11 +1,12 @@ package org.bukkit.block; +import org.bukkit.material.Colorable; import org.jetbrains.annotations.NotNull; /** * Represents a captured state of either a SignPost or a WallSign. */ -public interface Sign extends BlockState { +public interface Sign extends TileState, Colorable { /** * Gets all the lines of text currently on this sign. diff --git a/api/src/main/java/org/bukkit/block/Skull.java b/api/src/main/java/org/bukkit/block/Skull.java index 27675ecd1..a6914f01e 100644 --- a/api/src/main/java/org/bukkit/block/Skull.java +++ b/api/src/main/java/org/bukkit/block/Skull.java @@ -12,7 +12,7 @@ import com.destroystokyo.paper.profile.PlayerProfile; // Paper /** * Represents a captured state of a skull block. */ -public interface Skull extends BlockState { +public interface Skull extends TileState { /** * Checks to see if the skull has an owner diff --git a/api/src/main/java/org/bukkit/block/Smoker.java b/api/src/main/java/org/bukkit/block/Smoker.java new file mode 100644 index 000000000..7601c30d7 --- /dev/null +++ b/api/src/main/java/org/bukkit/block/Smoker.java @@ -0,0 +1,6 @@ +package org.bukkit.block; + +/** + * Represents a captured state of a smoker. + */ +public interface Smoker extends Furnace { } diff --git a/api/src/main/java/org/bukkit/block/Structure.java b/api/src/main/java/org/bukkit/block/Structure.java index d0f1d507e..dc4006955 100644 --- a/api/src/main/java/org/bukkit/block/Structure.java +++ b/api/src/main/java/org/bukkit/block/Structure.java @@ -11,7 +11,7 @@ import org.jetbrains.annotations.NotNull; * Represents a structure block that can save and load blocks from a file. They * can only be used by OPs, and are not obtainable in survival. */ -public interface Structure extends BlockState { +public interface Structure extends TileState { /** * The name of this structure. diff --git a/api/src/main/java/org/bukkit/block/TileState.java b/api/src/main/java/org/bukkit/block/TileState.java new file mode 100644 index 000000000..3b10fcc13 --- /dev/null +++ b/api/src/main/java/org/bukkit/block/TileState.java @@ -0,0 +1,39 @@ +package org.bukkit.block; + +import org.bukkit.persistence.PersistentDataContainer; +import org.bukkit.persistence.PersistentDataHolder; +import org.jetbrains.annotations.NotNull; + +/** + * Represents a block state that also hosts a tile entity at the given location. + * + * This interface alone is merely a marker that does not provide any data. + * + * Data about the tile entities is provided by the respective interface for each + * tile entity type. + * + * After modifying the data provided by a TileState, {@link #update()} needs to + * be called to store the data. + */ +public interface TileState extends BlockState, PersistentDataHolder { + + /** + * Returns a custom tag container capable of storing tags on the object. + * + * Note that the tags stored on this container are all stored under their + * own custom namespace therefore modifying default tags using this + * {@link PersistentDataHolder} is impossible. + *

+ * This {@link PersistentDataHolder} is only linked to the snapshot instance + * stored by the {@link BlockState}. + * + * When storing changes on the {@link PersistentDataHolder}, the updated + * content will only be applied to the actual tile entity after one of the + * {@link #update()} methods is called. + * + * @return the custom tag container + */ + @NotNull + @Override + PersistentDataContainer getPersistentDataContainer(); +} diff --git a/api/src/main/java/org/bukkit/block/banner/PatternType.java b/api/src/main/java/org/bukkit/block/banner/PatternType.java index 95f55a446..754582aa0 100644 --- a/api/src/main/java/org/bukkit/block/banner/PatternType.java +++ b/api/src/main/java/org/bukkit/block/banner/PatternType.java @@ -1,11 +1,10 @@ package org.bukkit.block.banner; -import org.jetbrains.annotations.Contract; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - import java.util.HashMap; import java.util.Map; +import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; public enum PatternType { BASE("b"), @@ -46,7 +45,8 @@ public enum PatternType { BRICKS("bri"), SKULL("sku"), FLOWER("flo"), - MOJANG("moj"); + MOJANG("moj"), + GLOBE("glb"); private final String identifier; private static final Map byString = new HashMap(); diff --git a/api/src/main/java/org/bukkit/block/data/Rail.java b/api/src/main/java/org/bukkit/block/data/Rail.java index e8300a741..b89938800 100644 --- a/api/src/main/java/org/bukkit/block/data/Rail.java +++ b/api/src/main/java/org/bukkit/block/data/Rail.java @@ -1,8 +1,7 @@ package org.bukkit.block.data; -import org.jetbrains.annotations.NotNull; - import java.util.Set; +import org.jetbrains.annotations.NotNull; /** * 'shape' represents the current layout of a minecart rail. diff --git a/api/src/main/java/org/bukkit/block/data/type/Bamboo.java b/api/src/main/java/org/bukkit/block/data/type/Bamboo.java new file mode 100644 index 000000000..96b5add29 --- /dev/null +++ b/api/src/main/java/org/bukkit/block/data/type/Bamboo.java @@ -0,0 +1,44 @@ +package org.bukkit.block.data.type; + +import org.bukkit.block.data.Ageable; +import org.jetbrains.annotations.NotNull; + +/** + * 'leaves' represents the size of the leaves on this bamboo block. + */ +public interface Bamboo extends Ageable, Sapling { + + /** + * Gets the value of the 'leaves' property. + * + * @return the 'leaves' value + */ + @NotNull + Leaves getLeaves(); + + /** + * Sets the value of the 'leaves' property. + * + * @param leaves the new 'leaves' value + */ + void setLeaves(@NotNull Leaves leaves); + + /** + * Bamboo leaf size. + */ + public enum Leaves { + + /** + * No leaves. + */ + NONE, + /** + * Small leaves. + */ + SMALL, + /** + * Large leaves. + */ + LARGE; + } +} diff --git a/api/src/main/java/org/bukkit/block/data/type/Bell.java b/api/src/main/java/org/bukkit/block/data/type/Bell.java new file mode 100644 index 000000000..e83f41b23 --- /dev/null +++ b/api/src/main/java/org/bukkit/block/data/type/Bell.java @@ -0,0 +1,48 @@ +package org.bukkit.block.data.type; + +import org.bukkit.block.data.Directional; +import org.jetbrains.annotations.NotNull; + +/** + * 'attachment' denotes how the bell is attached to its block. + */ +public interface Bell extends Directional { + + /** + * Gets the value of the 'attachment' property. + * + * @return the 'attachment' value + */ + @NotNull + Attachment getAttachment(); + + /** + * Sets the value of the 'attachment' property. + * + * @param attachment the new 'attachment' value + */ + void setAttachment(@NotNull Attachment attachment); + + /** + * What the bell is attached to. + */ + public enum Attachment { + + /** + * Placed on floor. + */ + FLOOR, + /** + * Placed on ceiling. + */ + CEILING, + /** + * Placed on one wall. + */ + SINGLE_WALL, + /** + * Placed between two walls. + */ + DOUBLE_WALL; + } +} diff --git a/api/src/main/java/org/bukkit/block/data/type/Campfire.java b/api/src/main/java/org/bukkit/block/data/type/Campfire.java new file mode 100644 index 000000000..bc5159b40 --- /dev/null +++ b/api/src/main/java/org/bukkit/block/data/type/Campfire.java @@ -0,0 +1,25 @@ +package org.bukkit.block.data.type; + +import org.bukkit.block.data.Lightable; +import org.bukkit.block.data.Waterlogged; + +/** + * 'signal_fire' denotes whether the fire is extra smokey due to having a hay + * bale placed beneath it. + */ +public interface Campfire extends Lightable, Waterlogged { + + /** + * Gets the value of the 'signal_fire' property. + * + * @return the 'signal_fire' value + */ + boolean isSignalFire(); + + /** + * Sets the value of the 'signal_fire' property. + * + * @param signalFire the new 'signal_fire' value + */ + void setSignalFire(boolean signalFire); +} diff --git a/api/src/main/java/org/bukkit/block/data/type/Lantern.java b/api/src/main/java/org/bukkit/block/data/type/Lantern.java new file mode 100644 index 000000000..a6c35655a --- /dev/null +++ b/api/src/main/java/org/bukkit/block/data/type/Lantern.java @@ -0,0 +1,23 @@ +package org.bukkit.block.data.type; + +import org.bukkit.block.data.BlockData; + +/** + * 'hanging' denotes whether the lantern is hanging from a block. + */ +public interface Lantern extends BlockData { + + /** + * Gets the value of the 'hanging' property. + * + * @return the 'hanging' value + */ + boolean isHanging(); + + /** + * Sets the value of the 'hanging' property. + * + * @param hanging the new 'hanging' value + */ + void setHanging(boolean hanging); +} diff --git a/api/src/main/java/org/bukkit/block/data/type/Lectern.java b/api/src/main/java/org/bukkit/block/data/type/Lectern.java new file mode 100644 index 000000000..11b4a173f --- /dev/null +++ b/api/src/main/java/org/bukkit/block/data/type/Lectern.java @@ -0,0 +1,18 @@ +package org.bukkit.block.data.type; + +import org.bukkit.block.data.Directional; +import org.bukkit.block.data.Powerable; + +/** + * 'has_book' is a quick flag to check whether this lectern has a book inside + * it. + */ +public interface Lectern extends Directional, Powerable { + + /** + * Gets the value of the 'has_book' property. + * + * @return the 'has_book' value + */ + boolean hasBook(); +} diff --git a/api/src/main/java/org/bukkit/block/data/type/Scaffolding.java b/api/src/main/java/org/bukkit/block/data/type/Scaffolding.java new file mode 100644 index 000000000..1f6859eee --- /dev/null +++ b/api/src/main/java/org/bukkit/block/data/type/Scaffolding.java @@ -0,0 +1,49 @@ +package org.bukkit.block.data.type; + +import org.bukkit.block.data.Waterlogged; + +/** + * 'bottom' indicates whether the scaffolding is floating or not. + *
+ * 'distance' indicates the distance from a scaffolding block placed above a + * 'bottom' scaffold. + *
+ * When 'distance' reaches {@link #getMaximumDistance()} the block will drop. + */ +public interface Scaffolding extends Waterlogged { + + /** + * Gets the value of the 'bottom' property. + * + * @return the 'bottom' value + */ + boolean isBottom(); + + /** + * Sets the value of the 'bottom' property. + * + * @param bottom the new 'bottom' value + */ + void setBottom(boolean bottom); + + /** + * Gets the value of the 'distance' property. + * + * @return the 'distance' value + */ + int getDistance(); + + /** + * Sets the value of the 'distance' property. + * + * @param distance the new 'distance' value + */ + void setDistance(int distance); + + /** + * Gets the maximum allowed value of the 'distance' property. + * + * @return the maximum 'distance' value + */ + int getMaximumDistance(); +} diff --git a/api/src/main/java/org/bukkit/boss/BossBar.java b/api/src/main/java/org/bukkit/boss/BossBar.java index acaf8ff0b..70274f2e2 100644 --- a/api/src/main/java/org/bukkit/boss/BossBar.java +++ b/api/src/main/java/org/bukkit/boss/BossBar.java @@ -1,12 +1,10 @@ package org.bukkit.boss; +import java.util.List; import org.bukkit.entity.Player; -import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.List; - public interface BossBar { /** diff --git a/api/src/main/java/org/bukkit/command/Command.java b/api/src/main/java/org/bukkit/command/Command.java index f0222fc27..0b0d1bd7c 100644 --- a/api/src/main/java/org/bukkit/command/Command.java +++ b/api/src/main/java/org/bukkit/command/Command.java @@ -1,10 +1,10 @@ package org.bukkit.command; +import com.google.common.collect.ImmutableList; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Set; - import org.apache.commons.lang.Validate; import org.bukkit.Bukkit; import org.bukkit.ChatColor; @@ -16,8 +16,6 @@ import org.bukkit.entity.minecart.CommandMinecart; import org.bukkit.permissions.Permissible; import org.bukkit.plugin.PluginDescriptionFile; import org.bukkit.util.StringUtil; - -import com.google.common.collect.ImmutableList; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/api/src/main/java/org/bukkit/command/PluginCommand.java b/api/src/main/java/org/bukkit/command/PluginCommand.java index e420b7902..1e126487d 100644 --- a/api/src/main/java/org/bukkit/command/PluginCommand.java +++ b/api/src/main/java/org/bukkit/command/PluginCommand.java @@ -1,7 +1,6 @@ package org.bukkit.command; import java.util.List; - import org.apache.commons.lang.Validate; import org.bukkit.plugin.Plugin; import org.jetbrains.annotations.NotNull; @@ -103,6 +102,7 @@ public final class PluginCommand extends Command implements PluginIdentifiableCo * * @return Plugin that owns this command */ + @Override @NotNull public Plugin getPlugin() { return owningPlugin; diff --git a/api/src/main/java/org/bukkit/command/PluginCommandYamlParser.java b/api/src/main/java/org/bukkit/command/PluginCommandYamlParser.java index 92b3f7997..a542c4bb3 100644 --- a/api/src/main/java/org/bukkit/command/PluginCommandYamlParser.java +++ b/api/src/main/java/org/bukkit/command/PluginCommandYamlParser.java @@ -4,7 +4,6 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Map.Entry; - import org.bukkit.Bukkit; import org.bukkit.plugin.Plugin; import org.jetbrains.annotations.NotNull; diff --git a/api/src/main/java/org/bukkit/command/SimpleCommandMap.java b/api/src/main/java/org/bukkit/command/SimpleCommandMap.java index b78f3d69d..460fda05a 100644 --- a/api/src/main/java/org/bukkit/command/SimpleCommandMap.java +++ b/api/src/main/java/org/bukkit/command/SimpleCommandMap.java @@ -15,7 +15,11 @@ import com.destroystokyo.paper.exception.ServerTabCompleteException; import org.apache.commons.lang.Validate; import org.bukkit.Location; import org.bukkit.Server; -import org.bukkit.command.defaults.*; +import org.bukkit.command.defaults.BukkitCommand; +import org.bukkit.command.defaults.HelpCommand; +import org.bukkit.command.defaults.PluginsCommand; +import org.bukkit.command.defaults.ReloadCommand; +import org.bukkit.command.defaults.VersionCommand; import org.bukkit.entity.Player; import org.bukkit.util.StringUtil; import org.jetbrains.annotations.NotNull; @@ -44,6 +48,7 @@ public class SimpleCommandMap implements CommandMap { /** * {@inheritDoc} */ + @Override public void registerAll(@NotNull String fallbackPrefix, @NotNull List commands) { if (commands != null) { for (Command c : commands) { @@ -55,6 +60,7 @@ public class SimpleCommandMap implements CommandMap { /** * {@inheritDoc} */ + @Override public boolean register(@NotNull String fallbackPrefix, @NotNull Command command) { return register(command.getName(), fallbackPrefix, command); } @@ -62,6 +68,7 @@ public class SimpleCommandMap implements CommandMap { /** * {@inheritDoc} */ + @Override public boolean register(@NotNull String label, @NotNull String fallbackPrefix, @NotNull Command command) { command.timings = co.aikar.timings.TimingsManager.getCommandTiming(fallbackPrefix, command); // Paper label = label.toLowerCase(java.util.Locale.ENGLISH).trim(); @@ -125,6 +132,7 @@ public class SimpleCommandMap implements CommandMap { /** * {@inheritDoc} */ + @Override public boolean dispatch(@NotNull CommandSender sender, @NotNull String commandLine) throws CommandException { String[] args = commandLine.split(" "); @@ -165,6 +173,7 @@ public class SimpleCommandMap implements CommandMap { return true; } + @Override public synchronized void clearCommands() { for (Map.Entry entry : knownCommands.entrySet()) { entry.getValue().unregister(this); @@ -173,17 +182,20 @@ public class SimpleCommandMap implements CommandMap { setDefaultCommands(); } + @Override @Nullable public Command getCommand(@NotNull String name) { Command target = knownCommands.get(name.toLowerCase(java.util.Locale.ENGLISH)); return target; } + @Override @Nullable public List tabComplete(@NotNull CommandSender sender, @NotNull String cmdLine) { return tabComplete(sender, cmdLine, null); } + @Override @Nullable public List tabComplete(@NotNull CommandSender sender, @NotNull String cmdLine, @Nullable Location location) { Validate.notNull(sender, "Sender cannot be null"); diff --git a/api/src/main/java/org/bukkit/command/TabCompleter.java b/api/src/main/java/org/bukkit/command/TabCompleter.java index 04c0e8749..e9cf71f5c 100644 --- a/api/src/main/java/org/bukkit/command/TabCompleter.java +++ b/api/src/main/java/org/bukkit/command/TabCompleter.java @@ -1,10 +1,9 @@ package org.bukkit.command; +import java.util.List; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.List; - /** * Represents a class which can suggest tab completions for commands. */ @@ -15,7 +14,7 @@ public interface TabCompleter { * * @param sender Source of the command. For players tab-completing a * command inside of a command block, this will be the player, not - * the command block. + * the command block. * @param command Command which was executed * @param alias The alias used * @param args The arguments passed to the command, including final diff --git a/api/src/main/java/org/bukkit/command/defaults/BukkitCommand.java b/api/src/main/java/org/bukkit/command/defaults/BukkitCommand.java index 1d8249da2..cb032d038 100644 --- a/api/src/main/java/org/bukkit/command/defaults/BukkitCommand.java +++ b/api/src/main/java/org/bukkit/command/defaults/BukkitCommand.java @@ -1,7 +1,6 @@ package org.bukkit.command.defaults; import java.util.List; - import org.bukkit.command.Command; import org.jetbrains.annotations.NotNull; diff --git a/api/src/main/java/org/bukkit/command/defaults/HelpCommand.java b/api/src/main/java/org/bukkit/command/defaults/HelpCommand.java index 391283bd4..3ec11eb29 100644 --- a/api/src/main/java/org/bukkit/command/defaults/HelpCommand.java +++ b/api/src/main/java/org/bukkit/command/defaults/HelpCommand.java @@ -1,5 +1,6 @@ package org.bukkit.command.defaults; +import com.google.common.collect.ImmutableList; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; @@ -7,7 +8,6 @@ import java.util.List; import java.util.Map; import java.util.Set; import java.util.TreeSet; - import org.apache.commons.lang.ArrayUtils; import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.Validate; @@ -21,8 +21,6 @@ import org.bukkit.help.HelpTopic; import org.bukkit.help.HelpTopicComparator; import org.bukkit.help.IndexHelpTopic; import org.bukkit.util.ChatPaginator; - -import com.google.common.collect.ImmutableList; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/api/src/main/java/org/bukkit/command/defaults/ReloadCommand.java b/api/src/main/java/org/bukkit/command/defaults/ReloadCommand.java index 607323a83..af8ab73fe 100644 --- a/api/src/main/java/org/bukkit/command/defaults/ReloadCommand.java +++ b/api/src/main/java/org/bukkit/command/defaults/ReloadCommand.java @@ -3,7 +3,6 @@ package org.bukkit.command.defaults; import java.util.Arrays; import java.util.Collections; import java.util.List; - import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.command.Command; diff --git a/api/src/main/java/org/bukkit/command/defaults/VersionCommand.java b/api/src/main/java/org/bukkit/command/defaults/VersionCommand.java index 7dce1eae2..0486abd19 100644 --- a/api/src/main/java/org/bukkit/command/defaults/VersionCommand.java +++ b/api/src/main/java/org/bukkit/command/defaults/VersionCommand.java @@ -1,10 +1,22 @@ package org.bukkit.command.defaults; +import com.destroystokyo.paper.util.VersionFetcher; // Paper - version supplier import com.google.common.base.Charsets; +import com.google.common.collect.ImmutableList; +import com.google.common.io.Resources; +import com.google.gson.Gson; +import com.google.gson.JsonObject; +import com.google.gson.JsonSyntaxException; +import java.io.BufferedReader; +import java.io.IOException; +import java.net.URL; +import java.net.URLEncoder; import java.util.ArrayList; import java.util.Arrays; +import java.util.HashSet; import java.util.List; - +import java.util.Set; +import java.util.concurrent.locks.ReentrantLock; import org.apache.commons.lang.Validate; import org.bukkit.Bukkit; import org.bukkit.ChatColor; @@ -12,28 +24,19 @@ import org.bukkit.command.CommandSender; import org.bukkit.plugin.Plugin; import org.bukkit.plugin.PluginDescriptionFile; import org.bukkit.util.StringUtil; - -import com.google.common.collect.ImmutableList; -import com.google.common.io.Resources; -import java.io.BufferedReader; -import java.io.IOException; -import java.net.URL; -import java.net.URLEncoder; -import java.util.HashSet; -import java.util.Set; -import java.util.concurrent.locks.ReentrantLock; -import org.json.simple.JSONObject; -import org.json.simple.parser.JSONParser; -import org.json.simple.parser.ParseException; - -// Paper start -import java.io.InputStreamReader; -import java.net.HttpURLConnection; -import com.destroystokyo.paper.VersionHistoryManager; -// Paper end +import org.jetbrains.annotations.NotNull; public class VersionCommand extends BukkitCommand { - public VersionCommand(String name) { + private VersionFetcher versionFetcher; + private VersionFetcher getVersionFetcher() { // lazy load because unsafe isn't available at command registration + if (versionFetcher == null) { + versionFetcher = Bukkit.getUnsafe().getVersionFetcher(); + } + + return versionFetcher; + } + + public VersionCommand(@NotNull String name) { super(name); this.description = "Gets the version of this server including any plugins in use"; @@ -43,12 +46,11 @@ public class VersionCommand extends BukkitCommand { } @Override - public boolean execute(CommandSender sender, String currentAlias, String[] args) { + public boolean execute(@NotNull CommandSender sender, @NotNull String currentAlias, @NotNull String[] args) { if (!testPermission(sender)) return true; if (args.length == 0) { sender.sendMessage("This server is running " + Bukkit.getName() + " version " + Bukkit.getVersion() + " (Implementing API version " + Bukkit.getBukkitVersion() + ")"); - tellHistory(sender); // Paper sendVersion(sender); } else { StringBuilder name = new StringBuilder(); @@ -85,23 +87,7 @@ public class VersionCommand extends BukkitCommand { return true; } - // Paper start - show version history - private void tellHistory(final CommandSender sender) { - final VersionHistoryManager.VersionData data = VersionHistoryManager.INSTANCE.getVersionData(); - if (data == null) { - return; - } - - final String oldVersion = data.getOldVersion(); - if (oldVersion == null) { - return; - } - - sender.sendMessage("Previous version: " + oldVersion); - } - // Paper end - - private void describeToSender(Plugin plugin, CommandSender sender) { + private void describeToSender(@NotNull Plugin plugin, @NotNull CommandSender sender) { PluginDescriptionFile desc = plugin.getDescription(); sender.sendMessage(ChatColor.GREEN + desc.getName() + ChatColor.WHITE + " version " + ChatColor.GREEN + desc.getVersion()); @@ -122,7 +108,8 @@ public class VersionCommand extends BukkitCommand { } } - private String getAuthors(final PluginDescriptionFile desc) { + @NotNull + private String getAuthors(@NotNull final PluginDescriptionFile desc) { StringBuilder result = new StringBuilder(); List authors = desc.getAuthors(); @@ -144,8 +131,9 @@ public class VersionCommand extends BukkitCommand { return result.toString(); } + @NotNull @Override - public List tabComplete(CommandSender sender, String alias, String[] args) { + public List tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) { Validate.notNull(sender, "Sender cannot be null"); Validate.notNull(args, "Arguments cannot be null"); Validate.notNull(alias, "Alias cannot be null"); @@ -170,20 +158,20 @@ public class VersionCommand extends BukkitCommand { private boolean versionTaskStarted = false; private long lastCheck = 0; - private void sendVersion(CommandSender sender) { + private void sendVersion(@NotNull CommandSender sender) { if (hasVersion) { - if (System.currentTimeMillis() - lastCheck > 7200000) { // Paper - Lower to 2 hours + if (System.currentTimeMillis() - lastCheck > getVersionFetcher().getCacheTime()) { // Paper - use version supplier lastCheck = System.currentTimeMillis(); hasVersion = false; } else { - sender.sendMessage(versionMessage); + sendMessages(versionMessage, sender); // Paper - allow \n for multiple messages return; } } versionLock.lock(); try { if (hasVersion) { - sender.sendMessage(versionMessage); + sendMessages(versionMessage, sender); // Paper - allow \n for multiple messages return; } versionWaiters.add(sender); @@ -203,28 +191,29 @@ public class VersionCommand extends BukkitCommand { } } - // Paper start private void obtainVersion() { String version = Bukkit.getVersion(); - if (version == null) version = "Custom"; - if (version.startsWith("git-Akarin-")) { // Akarin - String[] parts = version.substring("git-Akarin-".length()).split("[-\\s]"); // Akarin - int distance = getDistance(null, parts[0]); - switch (distance) { - case -1: - setVersionMessage("Error obtaining version information"); - break; - case 0: + // Paper start + if (version.startsWith("null")) { // running from ide? + setVersionMessage("Unknown version, custom build?"); + return; + } + /* + if (version.startsWith("git-Spigot-")) { + String[] parts = version.substring("git-Spigot-".length()).split("-"); + int cbVersions = getDistance("craftbukkit", parts[1].substring(0, parts[1].indexOf(' '))); + int spigotVersions = getDistance("spigot", parts[0]); + if (cbVersions == -1 || spigotVersions == -1) { + setVersionMessage("Error obtaining version information"); + } else { + if (cbVersions == 0 && spigotVersions == 0) { setVersionMessage("You are running the latest version"); - break; - case -2: - setVersionMessage("Unknown version"); - break; - default: - setVersionMessage("You are " + distance + " version(s) behind"); + } else { + setVersionMessage("You are " + (cbVersions + spigotVersions) + " version(s) behind"); + } } + } else if (version.startsWith("git-Bukkit-")) { - // Paper end version = version.substring("git-Bukkit-".length()); int cbVersions = getDistance("craftbukkit", version.substring(0, version.indexOf(' '))); if (cbVersions == -1) { @@ -239,17 +228,25 @@ public class VersionCommand extends BukkitCommand { } else { setVersionMessage("Unknown version, custom build?"); } + */ + setVersionMessage(getVersionFetcher().getVersionMessage(version)); + // Paper end } - private void setVersionMessage(String msg) { + private void setVersionMessage(@NotNull String msg) { lastCheck = System.currentTimeMillis(); versionMessage = msg; versionLock.lock(); try { hasVersion = true; versionTaskStarted = false; + // Paper - allow \n for multiple messages + String[] messages = versionMessage.split("\n"); for (CommandSender sender : versionWaiters) { - sender.sendMessage(versionMessage); + for (String message : messages) { + sender.sendMessage(message); + } + // Paper end } versionWaiters.clear(); } finally { @@ -258,81 +255,32 @@ public class VersionCommand extends BukkitCommand { } // Paper start - private static int getDistance(String repo, String verInfo) { - // Akarin start - //try { - // int currentVer = Integer.decode(verInfo); - // return getFromJenkins(currentVer); - //} catch (NumberFormatException ex) { - // Akarin end - verInfo = verInfo.replace("\"", ""); - return getFromRepo("Akarin-project/Akarin", "master", verInfo); // Akarin - //} // Akarin - /* + private void sendMessages(String toSplit, CommandSender target) { + String[] messages = toSplit.split("\n"); + for (String message : messages) { + target.sendMessage(message); + } + } + // Paper end + + private static int getDistance(@NotNull String repo, @NotNull String hash) { + try { BufferedReader reader = Resources.asCharSource( new URL("https://hub.spigotmc.org/stash/rest/api/1.0/projects/SPIGOT/repos/" + repo + "/commits?since=" + URLEncoder.encode(hash, "UTF-8") + "&withCounts=true"), Charsets.UTF_8 ).openBufferedStream(); try { - JSONObject obj = (JSONObject) new JSONParser().parse(reader); - return ((Number) obj.get("totalCount")).intValue(); - } catch (ParseException ex) { + JsonObject obj = new Gson().fromJson(reader, JsonObject.class); + return obj.get("totalCount").getAsInt(); + } catch (JsonSyntaxException ex) { ex.printStackTrace(); return -1; } finally { reader.close(); } - */ - } - - private static int getFromJenkins(int currentVer) { - try { - BufferedReader reader = Resources.asCharSource( - new URL("https://ci.destroystokyo.com/job/Paper-1.13/lastSuccessfulBuild/buildNumber"), // Paper - Charsets.UTF_8 - ).openBufferedStream(); - try { - int newVer = Integer.decode(reader.readLine()); - return newVer - currentVer; - } catch (NumberFormatException ex) { - ex.printStackTrace(); - return -2; - } finally { - reader.close(); - } } catch (IOException e) { e.printStackTrace(); return -1; } } - - // Contributed by Techcable in GH PR #65 - private static int getFromRepo(String repo, String branch, String hash) { - try { - HttpURLConnection connection = (HttpURLConnection) new URL("https://api.github.com/repos/" + repo + "/compare/" + branch + "..." + hash).openConnection(); - connection.connect(); - if (connection.getResponseCode() == HttpURLConnection.HTTP_NOT_FOUND) return -2; // Unknown commit - try ( - BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream(), Charsets.UTF_8)) - ) { - JSONObject obj = (JSONObject) new JSONParser().parse(reader); - String status = (String) obj.get("status"); - switch (status) { - case "identical": - return 0; - case "behind": - return ((Number) obj.get("behind_by")).intValue(); - default: - return -1; - } - } catch (ParseException | NumberFormatException e) { - e.printStackTrace(); - return -1; - } - } catch (IOException e) { - e.printStackTrace(); - return -1; - } - } - // Paper end } diff --git a/api/src/main/java/org/bukkit/configuration/Configuration.java b/api/src/main/java/org/bukkit/configuration/Configuration.java index 7f7e3ff71..f12a98b1b 100644 --- a/api/src/main/java/org/bukkit/configuration/Configuration.java +++ b/api/src/main/java/org/bukkit/configuration/Configuration.java @@ -1,10 +1,9 @@ package org.bukkit.configuration; +import java.util.Map; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.Map; - /** * Represents a source of configurable options and settings */ @@ -23,6 +22,7 @@ public interface Configuration extends ConfigurationSection { * @param value Value to set the default to. * @throws IllegalArgumentException Thrown if path is null. */ + @Override public void addDefault(@NotNull String path, @Nullable Object value); /** diff --git a/api/src/main/java/org/bukkit/configuration/ConfigurationSection.java b/api/src/main/java/org/bukkit/configuration/ConfigurationSection.java index e83de68ac..5a6e621d5 100644 --- a/api/src/main/java/org/bukkit/configuration/ConfigurationSection.java +++ b/api/src/main/java/org/bukkit/configuration/ConfigurationSection.java @@ -1,14 +1,14 @@ package org.bukkit.configuration; +import java.util.List; import java.util.Map; import java.util.Set; -import java.util.List; - import org.bukkit.Color; +import org.bukkit.Location; import org.bukkit.OfflinePlayer; import org.bukkit.configuration.serialization.ConfigurationSerializable; -import org.bukkit.util.Vector; import org.bukkit.inventory.ItemStack; +import org.bukkit.util.Vector; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -883,6 +883,48 @@ public interface ConfigurationSection { */ public boolean isColor(@NotNull String path); + /** + * Gets the requested Location by path. + *

+ * If the Location does not exist but a default value has been specified, + * this will return the default value. If the Location does not exist and no + * default value was specified, this will return null. + * + * @param path Path of the Location to get. + * @return Requested Location. + */ + @Nullable + public Location getLocation(@NotNull String path); + + /** + * Gets the requested {@link Location} by path, returning a default value if + * not found. + *

+ * If the Location does not exist then the specified default value will + * returned regardless of if a default has been identified in the root + * {@link Configuration}. + * + * @param path Path of the Location to get. + * @param def The default value to return if the path is not found or is not + * a Location. + * @return Requested Location. + */ + @Nullable + public Location getLocation(@NotNull String path, @Nullable Location def); + + /** + * Checks if the specified path is a Location. + *

+ * If the path exists but is not a Location, this will return false. If the + * path does not exist, this will return false. If the path does not exist + * but a default value has been specified, this will check if that default + * value is a Location and return appropriately. + * + * @param path Path of the Location to check. + * @return Whether or not the specified path is a Location. + */ + public boolean isLocation(@NotNull String path); + /** * Gets the requested ConfigurationSection by path. *

diff --git a/api/src/main/java/org/bukkit/configuration/MemoryConfiguration.java b/api/src/main/java/org/bukkit/configuration/MemoryConfiguration.java index e03108b12..010a97fee 100644 --- a/api/src/main/java/org/bukkit/configuration/MemoryConfiguration.java +++ b/api/src/main/java/org/bukkit/configuration/MemoryConfiguration.java @@ -1,7 +1,6 @@ package org.bukkit.configuration; import java.util.Map; - import org.apache.commons.lang.Validate; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -42,6 +41,7 @@ public class MemoryConfiguration extends MemorySection implements Configuration defaults.set(path, value); } + @Override public void addDefaults(@NotNull Map defaults) { Validate.notNull(defaults, "Defaults may not be null"); @@ -50,18 +50,21 @@ public class MemoryConfiguration extends MemorySection implements Configuration } } + @Override public void addDefaults(@NotNull Configuration defaults) { Validate.notNull(defaults, "Defaults may not be null"); addDefaults(defaults.getValues(true)); } + @Override public void setDefaults(@NotNull Configuration defaults) { Validate.notNull(defaults, "Defaults may not be null"); this.defaults = defaults; } + @Override @Nullable public Configuration getDefaults() { return defaults; @@ -73,6 +76,7 @@ public class MemoryConfiguration extends MemorySection implements Configuration return null; } + @Override @NotNull public MemoryConfigurationOptions options() { if (options == null) { diff --git a/api/src/main/java/org/bukkit/configuration/MemorySection.java b/api/src/main/java/org/bukkit/configuration/MemorySection.java index 37bb1c67a..e9b6a12a8 100644 --- a/api/src/main/java/org/bukkit/configuration/MemorySection.java +++ b/api/src/main/java/org/bukkit/configuration/MemorySection.java @@ -1,16 +1,15 @@ package org.bukkit.configuration; import static org.bukkit.util.NumberConversions.*; - import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.LinkedHashSet; import java.util.List; import java.util.Map; import java.util.Set; - import org.apache.commons.lang.Validate; import org.bukkit.Color; +import org.bukkit.Location; import org.bukkit.OfflinePlayer; import org.bukkit.configuration.serialization.ConfigurationSerializable; import org.bukkit.inventory.ItemStack; @@ -71,6 +70,7 @@ public class MemorySection implements ConfigurationSection { this.fullPath = createPath(parent, path); } + @Override @NotNull public Set getKeys(boolean deep) { Set result = new LinkedHashSet(); @@ -89,6 +89,7 @@ public class MemorySection implements ConfigurationSection { return result; } + @Override @NotNull public Map getValues(boolean deep) { Map result = new LinkedHashMap(); @@ -107,14 +108,17 @@ public class MemorySection implements ConfigurationSection { return result; } + @Override public boolean contains(@NotNull String path) { return contains(path, false); } + @Override public boolean contains(@NotNull String path, boolean ignoreDefault) { return ((ignoreDefault) ? get(path, null) : get(path)) != null; } + @Override public boolean isSet(@NotNull String path) { Configuration root = getRoot(); if (root == null) { @@ -126,26 +130,31 @@ public class MemorySection implements ConfigurationSection { return get(path, null) != null; } + @Override @NotNull public String getCurrentPath() { return fullPath; } + @Override @NotNull public String getName() { return path; } + @Override @Nullable public Configuration getRoot() { return root; } + @Override @Nullable public ConfigurationSection getParent() { return parent; } + @Override public void addDefault(@NotNull String path, @Nullable Object value) { Validate.notNull(path, "Path cannot be null"); @@ -159,6 +168,7 @@ public class MemorySection implements ConfigurationSection { root.addDefault(createPath(this, path), value); } + @Override @Nullable public ConfigurationSection getDefaultSection() { Configuration root = getRoot(); @@ -173,6 +183,7 @@ public class MemorySection implements ConfigurationSection { return null; } + @Override public void set(@NotNull String path, @Nullable Object value) { Validate.notEmpty(path, "Cannot set to an empty path"); @@ -212,11 +223,13 @@ public class MemorySection implements ConfigurationSection { } } + @Override @Nullable public Object get(@NotNull String path) { return get(path, getDefault(path)); } + @Override @Nullable public Object get(@NotNull String path, @Nullable Object def) { Validate.notNull(path, "Path cannot be null"); @@ -250,6 +263,7 @@ public class MemorySection implements ConfigurationSection { return section.get(key, def); } + @Override @NotNull public ConfigurationSection createSection(@NotNull String path) { Validate.notEmpty(path, "Cannot create section at empty path"); @@ -282,6 +296,7 @@ public class MemorySection implements ConfigurationSection { return section.createSection(key); } + @Override @NotNull public ConfigurationSection createSection(@NotNull String path, @NotNull Map map) { ConfigurationSection section = createSection(path); @@ -298,101 +313,120 @@ public class MemorySection implements ConfigurationSection { } // Primitives + @Override @Nullable public String getString(@NotNull String path) { Object def = getDefault(path); return getString(path, def != null ? def.toString() : null); } + @Override @Nullable public String getString(@NotNull String path, @Nullable String def) { Object val = get(path, def); return (val != null) ? val.toString() : def; } + @Override public boolean isString(@NotNull String path) { Object val = get(path); return val instanceof String; } + @Override public int getInt(@NotNull String path) { Object def = getDefault(path); return getInt(path, (def instanceof Number) ? toInt(def) : 0); } + @Override public int getInt(@NotNull String path, int def) { Object val = get(path, def); return (val instanceof Number) ? toInt(val) : def; } + @Override public boolean isInt(@NotNull String path) { Object val = get(path); return val instanceof Integer; } + @Override public boolean getBoolean(@NotNull String path) { Object def = getDefault(path); return getBoolean(path, (def instanceof Boolean) ? (Boolean) def : false); } + @Override public boolean getBoolean(@NotNull String path, boolean def) { Object val = get(path, def); return (val instanceof Boolean) ? (Boolean) val : def; } + @Override public boolean isBoolean(@NotNull String path) { Object val = get(path); return val instanceof Boolean; } + @Override public double getDouble(@NotNull String path) { Object def = getDefault(path); return getDouble(path, (def instanceof Number) ? toDouble(def) : 0); } + @Override public double getDouble(@NotNull String path, double def) { Object val = get(path, def); return (val instanceof Number) ? toDouble(val) : def; } + @Override public boolean isDouble(@NotNull String path) { Object val = get(path); return val instanceof Double; } + @Override public long getLong(@NotNull String path) { Object def = getDefault(path); return getLong(path, (def instanceof Number) ? toLong(def) : 0); } + @Override public long getLong(@NotNull String path, long def) { Object val = get(path, def); return (val instanceof Number) ? toLong(val) : def; } + @Override public boolean isLong(@NotNull String path) { Object val = get(path); return val instanceof Long; } // Java + @Override @Nullable public List getList(@NotNull String path) { Object def = getDefault(path); return getList(path, (def instanceof List) ? (List) def : null); } + @Override @Nullable public List getList(@NotNull String path, @Nullable List def) { Object val = get(path, def); return (List) ((val instanceof List) ? val : def); } + @Override public boolean isList(@NotNull String path) { Object val = get(path); return val instanceof List; } + @Override @NotNull public List getStringList(@NotNull String path) { List list = getList(path); @@ -412,6 +446,7 @@ public class MemorySection implements ConfigurationSection { return result; } + @Override @NotNull public List getIntegerList(@NotNull String path) { List list = getList(path); @@ -440,6 +475,7 @@ public class MemorySection implements ConfigurationSection { return result; } + @Override @NotNull public List getBooleanList(@NotNull String path) { List list = getList(path); @@ -465,6 +501,7 @@ public class MemorySection implements ConfigurationSection { return result; } + @Override @NotNull public List getDoubleList(@NotNull String path) { List list = getList(path); @@ -493,6 +530,7 @@ public class MemorySection implements ConfigurationSection { return result; } + @Override @NotNull public List getFloatList(@NotNull String path) { List list = getList(path); @@ -521,6 +559,7 @@ public class MemorySection implements ConfigurationSection { return result; } + @Override @NotNull public List getLongList(@NotNull String path) { List list = getList(path); @@ -549,6 +588,7 @@ public class MemorySection implements ConfigurationSection { return result; } + @Override @NotNull public List getByteList(@NotNull String path) { List list = getList(path); @@ -577,6 +617,7 @@ public class MemorySection implements ConfigurationSection { return result; } + @Override @NotNull public List getCharacterList(@NotNull String path) { List list = getList(path); @@ -604,6 +645,7 @@ public class MemorySection implements ConfigurationSection { return result; } + @Override @NotNull public List getShortList(@NotNull String path) { List list = getList(path); @@ -632,6 +674,7 @@ public class MemorySection implements ConfigurationSection { return result; } + @Override @NotNull public List> getMapList(@NotNull String path) { List list = getList(path); @@ -679,62 +722,92 @@ public class MemorySection implements ConfigurationSection { return getObject(path, clazz, def); } + @Override @Nullable public Vector getVector(@NotNull String path) { return getSerializable(path, Vector.class); } + @Override @Nullable public Vector getVector(@NotNull String path, @Nullable Vector def) { return getSerializable(path, Vector.class, def); } + @Override public boolean isVector(@NotNull String path) { return getSerializable(path, Vector.class) != null; } + @Override @Nullable public OfflinePlayer getOfflinePlayer(@NotNull String path) { return getSerializable(path, OfflinePlayer.class); } + @Override @Nullable public OfflinePlayer getOfflinePlayer(@NotNull String path, @Nullable OfflinePlayer def) { return getSerializable(path, OfflinePlayer.class, def); } + @Override public boolean isOfflinePlayer(@NotNull String path) { return getSerializable(path, OfflinePlayer.class) != null; } + @Override @Nullable public ItemStack getItemStack(@NotNull String path) { return getSerializable(path, ItemStack.class); } + @Override @Nullable public ItemStack getItemStack(@NotNull String path, @Nullable ItemStack def) { return getSerializable(path, ItemStack.class, def); } + @Override public boolean isItemStack(@NotNull String path) { return getSerializable(path, ItemStack.class) != null; } + @Override @Nullable public Color getColor(@NotNull String path) { return getSerializable(path, Color.class); } + @Override @Nullable public Color getColor(@NotNull String path, @Nullable Color def) { return getSerializable(path, Color.class, def); } + @Override public boolean isColor(@NotNull String path) { return getSerializable(path, Color.class) != null; } + @Override + @Nullable + public Location getLocation(@NotNull String path) { + return getSerializable(path, Location.class); + } + + @Override + @Nullable + public Location getLocation(@NotNull String path, @Nullable Location def) { + return getSerializable(path, Location.class, def); + } + + @Override + public boolean isLocation(@NotNull String path) { + return getSerializable(path, Location.class) != null; + } + + @Override @Nullable public ConfigurationSection getConfigurationSection(@NotNull String path) { Object val = get(path, null); @@ -746,6 +819,7 @@ public class MemorySection implements ConfigurationSection { return (val instanceof ConfigurationSection) ? createSection(path) : null; } + @Override public boolean isConfigurationSection(@NotNull String path) { Object val = get(path); return val instanceof ConfigurationSection; diff --git a/api/src/main/java/org/bukkit/configuration/file/FileConfiguration.java b/api/src/main/java/org/bukkit/configuration/file/FileConfiguration.java index ba3c93fe4..581889ffa 100644 --- a/api/src/main/java/org/bukkit/configuration/file/FileConfiguration.java +++ b/api/src/main/java/org/bukkit/configuration/file/FileConfiguration.java @@ -2,10 +2,6 @@ package org.bukkit.configuration.file; import com.google.common.base.Charsets; import com.google.common.io.Files; - -import org.apache.commons.lang.Validate; -import org.bukkit.configuration.InvalidConfigurationException; - import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; @@ -16,8 +12,9 @@ import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.Reader; import java.io.Writer; - +import org.apache.commons.lang.Validate; import org.bukkit.configuration.Configuration; +import org.bukkit.configuration.InvalidConfigurationException; import org.bukkit.configuration.MemoryConfiguration; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -226,4 +223,4 @@ public abstract class FileConfiguration extends MemoryConfiguration { return (FileConfigurationOptions) options; } -} \ No newline at end of file +} diff --git a/api/src/main/java/org/bukkit/configuration/file/FileConfigurationOptions.java b/api/src/main/java/org/bukkit/configuration/file/FileConfigurationOptions.java index 4919f6c93..eaa0aface 100644 --- a/api/src/main/java/org/bukkit/configuration/file/FileConfigurationOptions.java +++ b/api/src/main/java/org/bukkit/configuration/file/FileConfigurationOptions.java @@ -1,6 +1,7 @@ package org.bukkit.configuration.file; -import org.bukkit.configuration.*; +import org.bukkit.configuration.MemoryConfiguration; +import org.bukkit.configuration.MemoryConfigurationOptions; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/api/src/main/java/org/bukkit/configuration/file/YamlConfiguration.java b/api/src/main/java/org/bukkit/configuration/file/YamlConfiguration.java index 441e7ff98..dc8cb1937 100644 --- a/api/src/main/java/org/bukkit/configuration/file/YamlConfiguration.java +++ b/api/src/main/java/org/bukkit/configuration/file/YamlConfiguration.java @@ -6,7 +6,6 @@ import java.io.IOException; import java.io.Reader; import java.util.Map; import java.util.logging.Level; - import org.apache.commons.lang.Validate; import org.bukkit.Bukkit; import org.bukkit.configuration.Configuration; diff --git a/api/src/main/java/org/bukkit/configuration/file/YamlConstructor.java b/api/src/main/java/org/bukkit/configuration/file/YamlConstructor.java index 397b58c53..c8466a29a 100644 --- a/api/src/main/java/org/bukkit/configuration/file/YamlConstructor.java +++ b/api/src/main/java/org/bukkit/configuration/file/YamlConstructor.java @@ -2,16 +2,14 @@ package org.bukkit.configuration.file; import java.util.LinkedHashMap; import java.util.Map; - +import org.bukkit.configuration.serialization.ConfigurationSerialization; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import org.yaml.snakeyaml.nodes.Node; import org.yaml.snakeyaml.constructor.SafeConstructor; import org.yaml.snakeyaml.error.YAMLException; +import org.yaml.snakeyaml.nodes.Node; import org.yaml.snakeyaml.nodes.Tag; -import org.bukkit.configuration.serialization.ConfigurationSerialization; - public class YamlConstructor extends SafeConstructor { public YamlConstructor() { diff --git a/api/src/main/java/org/bukkit/configuration/file/YamlRepresenter.java b/api/src/main/java/org/bukkit/configuration/file/YamlRepresenter.java index 63cb35555..f03da3622 100644 --- a/api/src/main/java/org/bukkit/configuration/file/YamlRepresenter.java +++ b/api/src/main/java/org/bukkit/configuration/file/YamlRepresenter.java @@ -2,11 +2,9 @@ package org.bukkit.configuration.file; import java.util.LinkedHashMap; import java.util.Map; - import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.serialization.ConfigurationSerializable; import org.bukkit.configuration.serialization.ConfigurationSerialization; - import org.jetbrains.annotations.NotNull; import org.yaml.snakeyaml.nodes.Node; import org.yaml.snakeyaml.representer.Representer; diff --git a/api/src/main/java/org/bukkit/configuration/serialization/ConfigurationSerializable.java b/api/src/main/java/org/bukkit/configuration/serialization/ConfigurationSerializable.java index a666db15e..177944d4e 100644 --- a/api/src/main/java/org/bukkit/configuration/serialization/ConfigurationSerializable.java +++ b/api/src/main/java/org/bukkit/configuration/serialization/ConfigurationSerializable.java @@ -1,8 +1,7 @@ package org.bukkit.configuration.serialization; -import org.jetbrains.annotations.NotNull; - import java.util.Map; +import org.jetbrains.annotations.NotNull; /** * Represents an object that may be serialized. diff --git a/api/src/main/java/org/bukkit/configuration/serialization/ConfigurationSerialization.java b/api/src/main/java/org/bukkit/configuration/serialization/ConfigurationSerialization.java index 76d9b9662..8c9b4f696 100644 --- a/api/src/main/java/org/bukkit/configuration/serialization/ConfigurationSerialization.java +++ b/api/src/main/java/org/bukkit/configuration/serialization/ConfigurationSerialization.java @@ -8,7 +8,6 @@ import java.util.HashMap; import java.util.Map; import java.util.logging.Level; import java.util.logging.Logger; - import org.apache.commons.lang.Validate; import org.bukkit.Color; import org.bukkit.FireworkEffect; @@ -18,8 +17,8 @@ import org.bukkit.block.banner.Pattern; import org.bukkit.configuration.Configuration; import org.bukkit.inventory.ItemStack; import org.bukkit.potion.PotionEffect; -import org.bukkit.util.BoundingBox; import org.bukkit.util.BlockVector; +import org.bukkit.util.BoundingBox; import org.bukkit.util.Vector; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/api/src/main/java/org/bukkit/configuration/serialization/DelegateDeserialization.java b/api/src/main/java/org/bukkit/configuration/serialization/DelegateDeserialization.java index 2fa5d2dfe..138396116 100644 --- a/api/src/main/java/org/bukkit/configuration/serialization/DelegateDeserialization.java +++ b/api/src/main/java/org/bukkit/configuration/serialization/DelegateDeserialization.java @@ -1,11 +1,10 @@ package org.bukkit.configuration.serialization; -import org.jetbrains.annotations.NotNull; - import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; +import org.jetbrains.annotations.NotNull; /** * Applies to a {@link ConfigurationSerializable} that will delegate all diff --git a/api/src/main/java/org/bukkit/configuration/serialization/SerializableAs.java b/api/src/main/java/org/bukkit/configuration/serialization/SerializableAs.java index 9f4e79504..725685ed3 100644 --- a/api/src/main/java/org/bukkit/configuration/serialization/SerializableAs.java +++ b/api/src/main/java/org/bukkit/configuration/serialization/SerializableAs.java @@ -1,11 +1,10 @@ package org.bukkit.configuration.serialization; -import org.jetbrains.annotations.NotNull; - import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; +import org.jetbrains.annotations.NotNull; /** * Represents an "alias" that a {@link ConfigurationSerializable} may be diff --git a/api/src/main/java/org/bukkit/conversations/Conversation.java b/api/src/main/java/org/bukkit/conversations/Conversation.java index cb77dbd3c..bf2407c83 100644 --- a/api/src/main/java/org/bukkit/conversations/Conversation.java +++ b/api/src/main/java/org/bukkit/conversations/Conversation.java @@ -1,13 +1,12 @@ package org.bukkit.conversations; -import org.bukkit.plugin.Plugin; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; +import org.bukkit.plugin.Plugin; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * The Conversation class is responsible for tracking the current state of a diff --git a/api/src/main/java/org/bukkit/conversations/ConversationAbandonedEvent.java b/api/src/main/java/org/bukkit/conversations/ConversationAbandonedEvent.java index 5c634789d..0d67fe0c0 100644 --- a/api/src/main/java/org/bukkit/conversations/ConversationAbandonedEvent.java +++ b/api/src/main/java/org/bukkit/conversations/ConversationAbandonedEvent.java @@ -1,10 +1,9 @@ package org.bukkit.conversations; +import java.util.EventObject; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.EventObject; - /** * ConversationAbandonedEvent contains information about an abandoned * conversation. diff --git a/api/src/main/java/org/bukkit/conversations/ConversationAbandonedListener.java b/api/src/main/java/org/bukkit/conversations/ConversationAbandonedListener.java index 48585ce53..451121e7d 100644 --- a/api/src/main/java/org/bukkit/conversations/ConversationAbandonedListener.java +++ b/api/src/main/java/org/bukkit/conversations/ConversationAbandonedListener.java @@ -1,8 +1,7 @@ package org.bukkit.conversations; -import org.jetbrains.annotations.NotNull; - import java.util.EventListener; +import org.jetbrains.annotations.NotNull; /** */ diff --git a/api/src/main/java/org/bukkit/conversations/ConversationContext.java b/api/src/main/java/org/bukkit/conversations/ConversationContext.java index b192b03be..5bc0d36fe 100644 --- a/api/src/main/java/org/bukkit/conversations/ConversationContext.java +++ b/api/src/main/java/org/bukkit/conversations/ConversationContext.java @@ -1,11 +1,10 @@ package org.bukkit.conversations; +import java.util.Map; import org.bukkit.plugin.Plugin; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.Map; - /** * A ConversationContext provides continuity between nodes in the prompt graph * by giving the developer access to the subject of the conversation and a diff --git a/api/src/main/java/org/bukkit/conversations/ConversationFactory.java b/api/src/main/java/org/bukkit/conversations/ConversationFactory.java index efaaa7d94..58009e1e7 100644 --- a/api/src/main/java/org/bukkit/conversations/ConversationFactory.java +++ b/api/src/main/java/org/bukkit/conversations/ConversationFactory.java @@ -1,14 +1,13 @@ package org.bukkit.conversations; -import org.bukkit.entity.Player; -import org.bukkit.plugin.Plugin; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; +import org.bukkit.entity.Player; +import org.bukkit.plugin.Plugin; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * A ConversationFactory is responsible for creating a {@link Conversation} @@ -226,6 +225,7 @@ public class ConversationFactory { private class NotPlayerMessagePrompt extends MessagePrompt { + @Override @NotNull public String getPromptText(@NotNull ConversationContext context) { return playerOnlyMessage; diff --git a/api/src/main/java/org/bukkit/conversations/ExactMatchConversationCanceller.java b/api/src/main/java/org/bukkit/conversations/ExactMatchConversationCanceller.java index 9a30914b6..6b54ee877 100644 --- a/api/src/main/java/org/bukkit/conversations/ExactMatchConversationCanceller.java +++ b/api/src/main/java/org/bukkit/conversations/ExactMatchConversationCanceller.java @@ -18,13 +18,16 @@ public class ExactMatchConversationCanceller implements ConversationCanceller { public ExactMatchConversationCanceller(@NotNull String escapeSequence) { this.escapeSequence = escapeSequence; } - + + @Override public void setConversation(@NotNull Conversation conversation) {} + @Override public boolean cancelBasedOnInput(@NotNull ConversationContext context, @NotNull String input) { return input.equals(escapeSequence); } + @Override @NotNull public ConversationCanceller clone() { return new ExactMatchConversationCanceller(escapeSequence); diff --git a/api/src/main/java/org/bukkit/conversations/FixedSetPrompt.java b/api/src/main/java/org/bukkit/conversations/FixedSetPrompt.java index a1dd10285..9bf3336fa 100644 --- a/api/src/main/java/org/bukkit/conversations/FixedSetPrompt.java +++ b/api/src/main/java/org/bukkit/conversations/FixedSetPrompt.java @@ -1,18 +1,16 @@ package org.bukkit.conversations; -import org.apache.commons.lang.StringUtils; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - import java.util.Arrays; import java.util.List; +import org.apache.commons.lang.StringUtils; +import org.jetbrains.annotations.NotNull; /** * FixedSetPrompt is the base class for any prompt that requires a fixed set * response from the user. */ public abstract class FixedSetPrompt extends ValidatingPrompt { - + protected List fixedSet; /** diff --git a/api/src/main/java/org/bukkit/conversations/InactivityConversationCanceller.java b/api/src/main/java/org/bukkit/conversations/InactivityConversationCanceller.java index cfe2b69f6..fd8daa020 100644 --- a/api/src/main/java/org/bukkit/conversations/InactivityConversationCanceller.java +++ b/api/src/main/java/org/bukkit/conversations/InactivityConversationCanceller.java @@ -24,11 +24,13 @@ public class InactivityConversationCanceller implements ConversationCanceller { this.timeoutSeconds = timeoutSeconds; } + @Override public void setConversation(@NotNull Conversation conversation) { this.conversation = conversation; startTimer(); } + @Override public boolean cancelBasedOnInput(@NotNull ConversationContext context, @NotNull String input) { // Reset the inactivity timer stopTimer(); @@ -36,6 +38,7 @@ public class InactivityConversationCanceller implements ConversationCanceller { return false; } + @Override @NotNull public ConversationCanceller clone() { return new InactivityConversationCanceller(plugin, timeoutSeconds); @@ -46,6 +49,7 @@ public class InactivityConversationCanceller implements ConversationCanceller { */ private void startTimer() { taskId = plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { + @Override public void run() { if (conversation.getState() == Conversation.ConversationState.UNSTARTED) { startTimer(); diff --git a/api/src/main/java/org/bukkit/conversations/ManuallyAbandonedConversationCanceller.java b/api/src/main/java/org/bukkit/conversations/ManuallyAbandonedConversationCanceller.java index 2c351a065..0a289564a 100644 --- a/api/src/main/java/org/bukkit/conversations/ManuallyAbandonedConversationCanceller.java +++ b/api/src/main/java/org/bukkit/conversations/ManuallyAbandonedConversationCanceller.java @@ -8,14 +8,17 @@ import org.jetbrains.annotations.NotNull; * abandoned by programmatically calling the abandon() method on it. */ public class ManuallyAbandonedConversationCanceller implements ConversationCanceller { + @Override public void setConversation(@NotNull Conversation conversation) { throw new UnsupportedOperationException(); } + @Override public boolean cancelBasedOnInput(@NotNull ConversationContext context, @NotNull String input) { throw new UnsupportedOperationException(); } + @Override @NotNull public ConversationCanceller clone() { throw new UnsupportedOperationException(); diff --git a/api/src/main/java/org/bukkit/conversations/MessagePrompt.java b/api/src/main/java/org/bukkit/conversations/MessagePrompt.java index 69b19b920..e066166e5 100644 --- a/api/src/main/java/org/bukkit/conversations/MessagePrompt.java +++ b/api/src/main/java/org/bukkit/conversations/MessagePrompt.java @@ -19,6 +19,7 @@ public abstract class MessagePrompt implements Prompt { * @param context Context information about the conversation. * @return Always false. */ + @Override public boolean blocksForInput(@NotNull ConversationContext context) { return false; } @@ -31,6 +32,7 @@ public abstract class MessagePrompt implements Prompt { * @param input Ignored. * @return The next prompt in the prompt graph. */ + @Override @Nullable public Prompt acceptInput(@NotNull ConversationContext context, @Nullable String input) { return getNextPrompt(context); diff --git a/api/src/main/java/org/bukkit/conversations/NullConversationPrefix.java b/api/src/main/java/org/bukkit/conversations/NullConversationPrefix.java index ce1b20cde..6ee8ebb1e 100644 --- a/api/src/main/java/org/bukkit/conversations/NullConversationPrefix.java +++ b/api/src/main/java/org/bukkit/conversations/NullConversationPrefix.java @@ -14,6 +14,7 @@ public class NullConversationPrefix implements ConversationPrefix { * @param context Context information about the conversation. * @return An empty string. */ + @Override @NotNull public String getPrefix(@NotNull ConversationContext context) { return ""; diff --git a/api/src/main/java/org/bukkit/conversations/PluginNameConversationPrefix.java b/api/src/main/java/org/bukkit/conversations/PluginNameConversationPrefix.java index ed1f3b686..5911944fe 100644 --- a/api/src/main/java/org/bukkit/conversations/PluginNameConversationPrefix.java +++ b/api/src/main/java/org/bukkit/conversations/PluginNameConversationPrefix.java @@ -9,17 +9,17 @@ import org.jetbrains.annotations.NotNull; * that displays the plugin name in front of conversation output. */ public class PluginNameConversationPrefix implements ConversationPrefix { - + protected String separator; protected ChatColor prefixColor; protected Plugin plugin; - + private String cachedPrefix; - + public PluginNameConversationPrefix(@NotNull Plugin plugin) { this(plugin, " > ", ChatColor.LIGHT_PURPLE); } - + public PluginNameConversationPrefix(@NotNull Plugin plugin, @NotNull String separator, @NotNull ChatColor prefixColor) { this.separator = separator; this.prefixColor = prefixColor; @@ -34,6 +34,7 @@ public class PluginNameConversationPrefix implements ConversationPrefix { * @param context Context information about the conversation. * @return An empty string. */ + @Override @NotNull public String getPrefix(@NotNull ConversationContext context) { return cachedPrefix; diff --git a/api/src/main/java/org/bukkit/conversations/RegexPrompt.java b/api/src/main/java/org/bukkit/conversations/RegexPrompt.java index a081c19ae..6b3f1e459 100644 --- a/api/src/main/java/org/bukkit/conversations/RegexPrompt.java +++ b/api/src/main/java/org/bukkit/conversations/RegexPrompt.java @@ -1,9 +1,7 @@ package org.bukkit.conversations; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - import java.util.regex.Pattern; +import org.jetbrains.annotations.NotNull; /** * RegexPrompt is the base class for any prompt that requires an input diff --git a/api/src/main/java/org/bukkit/conversations/StringPrompt.java b/api/src/main/java/org/bukkit/conversations/StringPrompt.java index 89efb9131..f9b86d6d5 100644 --- a/api/src/main/java/org/bukkit/conversations/StringPrompt.java +++ b/api/src/main/java/org/bukkit/conversations/StringPrompt.java @@ -14,6 +14,7 @@ public abstract class StringPrompt implements Prompt { * @param context Context information about the conversation. * @return True. */ + @Override public boolean blocksForInput(@NotNull ConversationContext context) { return true; } diff --git a/api/src/main/java/org/bukkit/conversations/ValidatingPrompt.java b/api/src/main/java/org/bukkit/conversations/ValidatingPrompt.java index 3ecfa59a4..c57b6cb47 100644 --- a/api/src/main/java/org/bukkit/conversations/ValidatingPrompt.java +++ b/api/src/main/java/org/bukkit/conversations/ValidatingPrompt.java @@ -23,6 +23,7 @@ public abstract class ValidatingPrompt implements Prompt { * @param input The input text from the user. * @return This prompt or the next Prompt in the prompt graph. */ + @Override @Nullable public Prompt acceptInput(@NotNull ConversationContext context, @Nullable String input) { if (isInputValid(context, input)) { @@ -43,6 +44,7 @@ public abstract class ValidatingPrompt implements Prompt { * @param context Context information about the conversation. * @return True. */ + @Override public boolean blocksForInput(@NotNull ConversationContext context) { return true; } diff --git a/api/src/main/java/org/bukkit/enchantments/Enchantment.java b/api/src/main/java/org/bukkit/enchantments/Enchantment.java index 705b948e1..d1885f178 100644 --- a/api/src/main/java/org/bukkit/enchantments/Enchantment.java +++ b/api/src/main/java/org/bukkit/enchantments/Enchantment.java @@ -2,7 +2,6 @@ package org.bukkit.enchantments; import java.util.HashMap; import java.util.Map; - import org.bukkit.Keyed; import org.bukkit.NamespacedKey; import org.bukkit.inventory.ItemStack; @@ -176,6 +175,21 @@ public abstract class Enchantment implements Keyed { */ public static final Enchantment CHANNELING = new EnchantmentWrapper("channeling"); + /** + * Shoot multiple arrows from crossbows + */ + public static final Enchantment MULTISHOT = new EnchantmentWrapper("multishot"); + + /** + * Charges crossbows quickly + */ + public static final Enchantment QUICK_CHARGE = new EnchantmentWrapper("quick_charge"); + + /** + * Crossbow projectiles pierce entities + */ + public static final Enchantment PIERCING = new EnchantmentWrapper("piercing"); + /** * Allows mending the item using experience orbs */ diff --git a/api/src/main/java/org/bukkit/enchantments/EnchantmentOffer.java b/api/src/main/java/org/bukkit/enchantments/EnchantmentOffer.java index a830610dc..76761b4b4 100644 --- a/api/src/main/java/org/bukkit/enchantments/EnchantmentOffer.java +++ b/api/src/main/java/org/bukkit/enchantments/EnchantmentOffer.java @@ -60,8 +60,8 @@ public class EnchantmentOffer { } /** - * Gets the cost in experience levels the player has to pay to enchant his - * item with this enchantment. + * Gets the cost (minimum level) which is displayed as a number on the right + * hand side of the enchantment offer. * * @return cost for this enchantment */ @@ -70,8 +70,8 @@ public class EnchantmentOffer { } /** - * Sets the cost in experience levels the player has to pay to enchant his - * item with this enchantment + * Sets the cost (minimum level) which is displayed as a number on the right + * hand side of the enchantment offer. * * @param cost cost for this enchantment */ diff --git a/api/src/main/java/org/bukkit/enchantments/EnchantmentTarget.java b/api/src/main/java/org/bukkit/enchantments/EnchantmentTarget.java index 9f30c869e..8ff0901cf 100644 --- a/api/src/main/java/org/bukkit/enchantments/EnchantmentTarget.java +++ b/api/src/main/java/org/bukkit/enchantments/EnchantmentTarget.java @@ -191,6 +191,16 @@ public enum EnchantmentTarget { public boolean includes(@NotNull Material item) { return item.equals(Material.TRIDENT); } + }, + + /** + * Allow the Enchantment to be placed on crossbows. + */ + CROSSBOW { + @Override + public boolean includes(@NotNull Material item) { + return item.equals(Material.CROSSBOW); + } }; /** diff --git a/api/src/main/java/org/bukkit/entity/AbstractArrow.java b/api/src/main/java/org/bukkit/entity/AbstractArrow.java new file mode 100644 index 000000000..b2bf62a50 --- /dev/null +++ b/api/src/main/java/org/bukkit/entity/AbstractArrow.java @@ -0,0 +1,164 @@ +package org.bukkit.entity; + +import org.bukkit.block.Block; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * Represents an arrow. + */ +public interface AbstractArrow extends Projectile { + + /** + * Gets the knockback strength for an arrow, which is the + * {@link org.bukkit.enchantments.Enchantment#KNOCKBACK KnockBack} level + * of the bow that shot it. + * + * @return the knockback strength value + */ + public int getKnockbackStrength(); + + /** + * Sets the knockback strength for an arrow. + * + * @param knockbackStrength the knockback strength value + */ + public void setKnockbackStrength(int knockbackStrength); + + /** + * Gets the base amount of damage this arrow will do. + * + * Defaults to 2.0 for a normal arrow with + * 0.5 * (1 + power level) added for arrows fired from + * enchanted bows. + * + * @return base damage amount + */ + public double getDamage(); + + /** + * Sets the base amount of damage this arrow will do. + * + * @param damage new damage amount + */ + public void setDamage(double damage); + + /** + * Gets the number of times this arrow can pierce through an entity. + * + * @return pierce level + */ + public int getPierceLevel(); + + /** + * Sets the number of times this arrow can pierce through an entity. + * + * Must be between 0 and 127 times. + * + * @param pierceLevel new pierce level + */ + public void setPierceLevel(int pierceLevel); + + /** + * Gets whether this arrow is critical. + *

+ * Critical arrows have increased damage and cause particle effects. + *

+ * Critical arrows generally occur when a player fully draws a bow before + * firing. + * + * @return true if it is critical + */ + public boolean isCritical(); + + /** + * Sets whether or not this arrow should be critical. + * + * @param critical whether or not it should be critical + */ + public void setCritical(boolean critical); + + /** + * Gets whether this arrow is in a block or not. + *

+ * Arrows in a block are motionless and may be picked up by players. + * + * @return true if in a block + */ + public boolean isInBlock(); + + /** + * Gets the block to which this arrow is attached. + * + * @return the attached block or null if not attached + */ + @Nullable + public Block getAttachedBlock(); + + /** + * Gets the current pickup status of this arrow. + * + * @return the pickup status of this arrow. + */ + @NotNull + public PickupStatus getPickupStatus(); + + /** + * Sets the current pickup status of this arrow. + * + * @param status new pickup status of this arrow. + */ + public void setPickupStatus(@NotNull PickupStatus status); + + /** + * Represents the pickup status of this arrow. + */ + public enum PickupStatus { + /** + * The arrow cannot be picked up. + */ + DISALLOWED, + /** + * The arrow can be picked up. + */ + ALLOWED, + /** + * The arrow can only be picked up by players in creative mode. + */ + CREATIVE_ONLY + } + + // Paper start + /** + * Gets the {@link PickupRule} for this arrow. + * + *

This is generally {@link PickupRule#ALLOWED} only if the arrow was + * not fired from a bow with the infinity enchantment.

+ * + * @return The pickup rule + * @deprecated Use {@link Arrow#getPickupStatus()} as an upstream compatible replacement for this function + */ + @Deprecated + default PickupRule getPickupRule() { + return PickupRule.valueOf(this.getPickupStatus().name()); + } + + /** + * Set the rule for which players can pickup this arrow as an item. + * + * @param rule The pickup rule + * @deprecated Use {@link Arrow#setPickupStatus(PickupStatus)} with {@link PickupStatus} as an upstream compatible replacement for this function + */ + @Deprecated + default void setPickupRule(PickupRule rule) { + this.setPickupStatus(PickupStatus.valueOf(rule.name())); + } + + @Deprecated + enum PickupRule { + DISALLOWED, + ALLOWED, + CREATIVE_ONLY; + } + // Paper end +} diff --git a/api/src/main/java/org/bukkit/entity/AbstractHorse.java b/api/src/main/java/org/bukkit/entity/AbstractHorse.java index 234aa9dd2..87f3c1f22 100644 --- a/api/src/main/java/org/bukkit/entity/AbstractHorse.java +++ b/api/src/main/java/org/bukkit/entity/AbstractHorse.java @@ -25,7 +25,7 @@ public interface AbstractHorse extends Animals, Vehicle, InventoryHolder, Tameab public Horse.Variant getVariant(); /** - * @param variant Variant to set + * @param variant variant * @deprecated you are required to spawn a different entity */ @Deprecated diff --git a/api/src/main/java/org/bukkit/entity/AbstractVillager.java b/api/src/main/java/org/bukkit/entity/AbstractVillager.java new file mode 100644 index 000000000..8fde1f4bb --- /dev/null +++ b/api/src/main/java/org/bukkit/entity/AbstractVillager.java @@ -0,0 +1,24 @@ +package org.bukkit.entity; + +import org.bukkit.inventory.Inventory; +import org.bukkit.inventory.InventoryHolder; +import org.bukkit.inventory.Merchant; +import org.jetbrains.annotations.NotNull; + +/** + * Represents a villager NPC + */ +public interface AbstractVillager extends Ageable, NPC, InventoryHolder, Merchant { + + /** + * Gets this villager's inventory. + *
+ * Note that this inventory is not the Merchant inventory, rather, it is the + * items that a villager might have collected (from harvesting crops, etc.) + * + * {@inheritDoc} + */ + @NotNull + @Override + Inventory getInventory(); +} diff --git a/api/src/main/java/org/bukkit/entity/Ageable.java b/api/src/main/java/org/bukkit/entity/Ageable.java index e9fccb294..3756a9730 100644 --- a/api/src/main/java/org/bukkit/entity/Ageable.java +++ b/api/src/main/java/org/bukkit/entity/Ageable.java @@ -3,7 +3,7 @@ package org.bukkit.entity; /** * Represents an entity that can age and breed. */ -public interface Ageable extends Creature { +public interface Ageable extends Creature { /** * Gets the age of this animal. * @@ -49,7 +49,7 @@ public interface Ageable extends Creature { * @return return true if the animal is an adult */ public boolean isAdult(); - + /** * Return the ability to breed of the animal. * diff --git a/api/src/main/java/org/bukkit/entity/AnimalTamer.java b/api/src/main/java/org/bukkit/entity/AnimalTamer.java index 9f1eed9ba..2e17b2d4f 100644 --- a/api/src/main/java/org/bukkit/entity/AnimalTamer.java +++ b/api/src/main/java/org/bukkit/entity/AnimalTamer.java @@ -1,10 +1,9 @@ package org.bukkit.entity; +import java.util.UUID; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.UUID; - public interface AnimalTamer { /** diff --git a/api/src/main/java/org/bukkit/entity/Animals.java b/api/src/main/java/org/bukkit/entity/Animals.java index 3d4f8c3d4..1047481e4 100644 --- a/api/src/main/java/org/bukkit/entity/Animals.java +++ b/api/src/main/java/org/bukkit/entity/Animals.java @@ -1,8 +1,7 @@ package org.bukkit.entity; -import org.jetbrains.annotations.Nullable; - import java.util.UUID; +import org.jetbrains.annotations.Nullable; /** * Represents an Animal. diff --git a/api/src/main/java/org/bukkit/entity/AreaEffectCloud.java b/api/src/main/java/org/bukkit/entity/AreaEffectCloud.java index 123d87954..bca9d3659 100644 --- a/api/src/main/java/org/bukkit/entity/AreaEffectCloud.java +++ b/api/src/main/java/org/bukkit/entity/AreaEffectCloud.java @@ -138,6 +138,7 @@ public interface AreaEffectCloud extends Entity { /** * Sets the particle which this cloud will be composed of * + * @param type of particle data (see {@link Particle#getDataType()} * @param particle the new particle type * @param data the data to use for the particle or null, * the type of this depends on {@link Particle#getDataType()} @@ -227,7 +228,7 @@ public interface AreaEffectCloud extends Entity { /** * Retrieve the original source of this cloud. - * + * * @return the {@link ProjectileSource} that threw the LingeringPotion */ @Nullable diff --git a/api/src/main/java/org/bukkit/entity/Arrow.java b/api/src/main/java/org/bukkit/entity/Arrow.java index b63f2fd9d..ec8443b67 100644 --- a/api/src/main/java/org/bukkit/entity/Arrow.java +++ b/api/src/main/java/org/bukkit/entity/Arrow.java @@ -1,186 +1,97 @@ package org.bukkit.entity; -import org.bukkit.block.Block; +import java.util.List; +import org.bukkit.Color; +import org.bukkit.potion.PotionData; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -/** - * Represents an arrow. - */ -public interface Arrow extends Projectile { +public interface Arrow extends AbstractArrow { /** - * Gets the knockback strength for an arrow, which is the - * {@link org.bukkit.enchantments.Enchantment#KNOCKBACK KnockBack} level - * of the bow that shot it. + * Sets the underlying potion data * - * @return the knockback strength value + * @param data PotionData to set the base potion state to */ - public int getKnockbackStrength(); + void setBasePotionData(@NotNull PotionData data); /** - * Sets the knockback strength for an arrow. + * Returns the potion data about the base potion * - * @param knockbackStrength the knockback strength value - */ - public void setKnockbackStrength(int knockbackStrength); - - /** - * Gets the base amount of damage this arrow will do. - * - * Defaults to 2.0 for a normal arrow with - * 0.5 * (1 + power level) added for arrows fired from - * enchanted bows. - * - * @return base damage amount - */ - public double getDamage(); - - /** - * Sets the base amount of damage this arrow will do. - * - * @param damage new damage amount - */ - public void setDamage(double damage); - - /** - * Gets whether this arrow is critical. - *

- * Critical arrows have increased damage and cause particle effects. - *

- * Critical arrows generally occur when a player fully draws a bow before - * firing. - * - * @return true if it is critical - */ - public boolean isCritical(); - - /** - * Sets whether or not this arrow should be critical. - * - * @param critical whether or not it should be critical - */ - public void setCritical(boolean critical); - - /** - * Gets whether this arrow is in a block or not. - *

- * Arrows in a block are motionless and may be picked up by players. - * - * @return true if in a block - */ - public boolean isInBlock(); - - /** - * Gets the block to which this arrow is attached. - * - * @return the attached block or null if not attached - */ - @Nullable - public Block getAttachedBlock(); - - /** - * Gets the current pickup status of this arrow. - * - * @return the pickup status of this arrow. + * @return a PotionData object */ @NotNull - public PickupStatus getPickupStatus(); + PotionData getBasePotionData(); /** - * Sets the current pickup status of this arrow. + * Gets the color of this arrow. * - * @param status new pickup status of this arrow. + * @return arrow color */ - public void setPickupStatus(@NotNull PickupStatus status); - - /** - * Represents the pickup status of this arrow. - */ - public enum PickupStatus { - /** - * The arrow cannot be picked up. - */ - DISALLOWED, - /** - * The arrow can be picked up. - */ - ALLOWED, - /** - * The arrow can only be picked up by players in creative mode. - */ - CREATIVE_ONLY - } - - // Spigot start - public class Spigot extends Entity.Spigot - { - - /** - * Gets the base amount of damage this arrow will do. - * - * Defaults to 2.0 for a normal arrow with - * 0.5 * (1 + power level) added for arrows fired from - * enchanted bows. - * - * @return base damage amount - * @deprecated {@link Arrow#getDamage()} - */ - @Deprecated - public double getDamage() - { - throw new UnsupportedOperationException( "Not supported yet." ); - } - - /** - * Sets the base amount of damage this arrow will do. - * - * @param damage new damage amount - * @deprecated {@link Arrow#setDamage(double)} - */ - @Deprecated - public void setDamage(double damage) - { - throw new UnsupportedOperationException( "Not supported yet." ); - } - } - @NotNull - @Override - Spigot spigot(); - // Spigot end - - // Paper start - /** - * Gets the {@link PickupRule} for this arrow. - * - *

This is generally {@link PickupRule#ALLOWED} only if the arrow was - * not fired from a bow with the infinity enchantment.

- * - * @return The pickup rule - * @deprecated Use {@link Arrow#getPickupStatus()} as an upstream compatible replacement for this function - */ - @Deprecated - default PickupRule getPickupRule() { - return PickupRule.valueOf(this.getPickupStatus().name()); - } + Color getColor(); /** - * Set the rule for which players can pickup this arrow as an item. + * Sets the color of this arrow. Will be applied as a tint to its particles. * - * @param rule The pickup rule - * @deprecated Use {@link Arrow#setPickupStatus(PickupStatus)} with {@link PickupStatus} as an upstream compatible replacement for this function + * @param color arrow color */ - @Deprecated - default void setPickupRule(PickupRule rule) { - this.setPickupStatus(PickupStatus.valueOf(rule.name())); - } + void setColor(@NotNull Color color); - @Deprecated - enum PickupRule { - DISALLOWED, - ALLOWED, - CREATIVE_ONLY; - } - // Paper end + /** + * Checks for the presence of custom potion effects. + * + * @return true if custom potion effects are applied + */ + boolean hasCustomEffects(); + + /** + * Gets an immutable list containing all custom potion effects applied to + * this arrow. + *

+ * Plugins should check that hasCustomEffects() returns true before calling + * this method. + * + * @return the immutable list of custom potion effects + */ + @NotNull + List getCustomEffects(); + + /** + * Adds a custom potion effect to this arrow. + * + * @param effect the potion effect to add + * @param overwrite true if any existing effect of the same type should be + * overwritten + * @return true if the effect was added as a result of this call + */ + boolean addCustomEffect(@NotNull PotionEffect effect, boolean overwrite); + + /** + * Removes a custom potion effect from this arrow. + * + * @param type the potion effect type to remove + * @return true if the an effect was removed as a result of this call + * @throws IllegalArgumentException if this operation would leave the Arrow + * in a state with no Custom Effects and PotionType.UNCRAFTABLE + */ + boolean removeCustomEffect(@NotNull PotionEffectType type); + + /** + * Checks for a specific custom potion effect type on this arrow. + * + * @param type the potion effect type to check for + * @return true if the potion has this effect + */ + boolean hasCustomEffect(@Nullable PotionEffectType type); + + /** + * Removes all custom potion effects from this arrow. + * + * @throws IllegalArgumentException if this operation would leave the Arrow + * in a state with no Custom Effects and PotionType.UNCRAFTABLE + */ + void clearCustomEffects(); } diff --git a/api/src/main/java/org/bukkit/entity/Boat.java b/api/src/main/java/org/bukkit/entity/Boat.java index 00001621b..24751b5c4 100644 --- a/api/src/main/java/org/bukkit/entity/Boat.java +++ b/api/src/main/java/org/bukkit/entity/Boat.java @@ -10,7 +10,7 @@ public interface Boat extends Vehicle { /** * Gets the wood type of the boat. - * + * * @return the wood type */ @NotNull @@ -18,7 +18,7 @@ public interface Boat extends Vehicle { /** * Sets the wood type of the boat. - * + * * @param species the new wood type */ void setWoodType(@NotNull TreeSpecies species); diff --git a/api/src/main/java/org/bukkit/entity/Cat.java b/api/src/main/java/org/bukkit/entity/Cat.java new file mode 100644 index 000000000..a29aefeaa --- /dev/null +++ b/api/src/main/java/org/bukkit/entity/Cat.java @@ -0,0 +1,57 @@ +package org.bukkit.entity; + +import org.bukkit.DyeColor; +import org.jetbrains.annotations.NotNull; + +/** + * Meow. + */ +public interface Cat extends Animals, Tameable, Sittable { + + /** + * Gets the current type of this cat. + * + * @return Type of the cat. + */ + @NotNull + public Type getCatType(); + + /** + * Sets the current type of this cat. + * + * @param type New type of this cat. + */ + public void setCatType(@NotNull Type type); + + /** + * Get the collar color of this cat + * + * @return the color of the collar + */ + @NotNull + public DyeColor getCollarColor(); + + /** + * Set the collar color of this cat + * + * @param color the color to apply + */ + public void setCollarColor(@NotNull DyeColor color); + + /** + * Represents the various different cat types there are. + */ + public enum Type { + TABBY, + BLACK, + RED, + SIAMESE, + BRITISH_SHORTHAIR, + CALICO, + PERSIAN, + RAGDOLL, + WHITE, + JELLIE, + ALL_BLACK; + } +} diff --git a/api/src/main/java/org/bukkit/entity/ComplexLivingEntity.java b/api/src/main/java/org/bukkit/entity/ComplexLivingEntity.java index 038bcb6dc..2151e3bac 100644 --- a/api/src/main/java/org/bukkit/entity/ComplexLivingEntity.java +++ b/api/src/main/java/org/bukkit/entity/ComplexLivingEntity.java @@ -1,8 +1,7 @@ package org.bukkit.entity; -import org.jetbrains.annotations.NotNull; - import java.util.Set; +import org.jetbrains.annotations.NotNull; /** * Represents a complex living entity - one that is made up of various smaller diff --git a/api/src/main/java/org/bukkit/entity/Creeper.java b/api/src/main/java/org/bukkit/entity/Creeper.java index b9877fb88..faaeb44a9 100644 --- a/api/src/main/java/org/bukkit/entity/Creeper.java +++ b/api/src/main/java/org/bukkit/entity/Creeper.java @@ -20,8 +20,8 @@ public interface Creeper extends Monster { public void setPowered(boolean value); /** - * Set the maximum fuse ticks for this Creeper, where the maximum ticks - * is the amount of time in which a creeper is allowed to be in the + * Set the maximum fuse ticks for this Creeper, where the maximum ticks + * is the amount of time in which a creeper is allowed to be in the * primed state before exploding. * * @param ticks the new maximum fuse ticks @@ -29,8 +29,8 @@ public interface Creeper extends Monster { public void setMaxFuseTicks(int ticks); /** - * Get the maximum fuse ticks for this Creeper, where the maximum ticks - * is the amount of time in which a creeper is allowed to be in the + * Get the maximum fuse ticks for this Creeper, where the maximum ticks + * is the amount of time in which a creeper is allowed to be in the * primed state before exploding. * * @return the maximum fuse ticks @@ -51,7 +51,28 @@ public interface Creeper extends Monster { */ public int getExplosionRadius(); + /** + * Makes this Creeper explode instantly. + * + * The resulting explosion can be cancelled by an + * {@link org.bukkit.event.entity.ExplosionPrimeEvent} and obeys the mob + * griefing gamerule. + */ + public void explode(); + + /** + * Ignites this Creeper, beginning its fuse. + * + * The amount of time the Creeper takes to explode will depend on what + * {@link #setMaxFuseTicks} is set as. + * + * The resulting explosion can be cancelled by an + * {@link org.bukkit.event.entity.ExplosionPrimeEvent} and obeys the mob + * griefing gamerule. + */ + public void ignite(); // Paper start + /** * Set whether creeper is ignited or not (armed to explode) * @@ -72,10 +93,5 @@ public interface Creeper extends Monster { * @return Ticks creeper has been ignited */ public int getFuseTicks(); - - /** - * Make the creeper explode (no waiting for fuse) - */ - public void explode(); // Paper end } diff --git a/api/src/main/java/org/bukkit/entity/Damageable.java b/api/src/main/java/org/bukkit/entity/Damageable.java index b0fe04423..fc4d3bcd9 100644 --- a/api/src/main/java/org/bukkit/entity/Damageable.java +++ b/api/src/main/java/org/bukkit/entity/Damageable.java @@ -40,6 +40,22 @@ public interface Damageable extends Entity { */ void setHealth(double health); + /** + * Gets the entity's absorption amount. + * + * @return absorption amount from 0 + */ + double getAbsorptionAmount(); + + /** + * Sets the entity's absorption amount. + * + * @param amount new absorption amount from 0 + * @throws IllegalArgumentException thrown if health is {@literal < 0} or + * non-finite. + */ + void setAbsorptionAmount(double amount); + /** * Gets the maximum health this entity has. * diff --git a/api/src/main/java/org/bukkit/entity/EnderDragon.java b/api/src/main/java/org/bukkit/entity/EnderDragon.java index e800259a2..ddef550bb 100644 --- a/api/src/main/java/org/bukkit/entity/EnderDragon.java +++ b/api/src/main/java/org/bukkit/entity/EnderDragon.java @@ -41,8 +41,8 @@ public interface EnderDragon extends ComplexLivingEntity, Boss, org.bukkit.entit BREATH_ATTACK, /** * The dragon will search for a player to attack with dragon breath. - * If no player is close enough to the dragon for 5 seconds, the - * dragon will charge at a player within 150 blocks or will take off + * If no player is close enough to the dragon for 5 seconds, the + * dragon will charge at a player within 150 blocks or will take off * and begin circling if no player is found. */ SEARCH_FOR_BREATH_ATTACK_TARGET, diff --git a/api/src/main/java/org/bukkit/entity/EnderDragonPart.java b/api/src/main/java/org/bukkit/entity/EnderDragonPart.java index 77fc93378..d0ac89bab 100644 --- a/api/src/main/java/org/bukkit/entity/EnderDragonPart.java +++ b/api/src/main/java/org/bukkit/entity/EnderDragonPart.java @@ -6,6 +6,7 @@ import org.jetbrains.annotations.NotNull; * Represents an ender dragon part */ public interface EnderDragonPart extends ComplexEntityPart, Damageable { + @Override @NotNull public EnderDragon getParent(); } diff --git a/api/src/main/java/org/bukkit/entity/Entity.java b/api/src/main/java/org/bukkit/entity/Entity.java index 058fe67d9..98b26cd93 100644 --- a/api/src/main/java/org/bukkit/entity/Entity.java +++ b/api/src/main/java/org/bukkit/entity/Entity.java @@ -1,25 +1,24 @@ package org.bukkit.entity; -import org.bukkit.Chunk; -import org.bukkit.Location; +import java.util.List; +import java.util.Set; +import java.util.UUID; +import org.bukkit.Chunk; // Paper import org.bukkit.EntityEffect; import org.bukkit.Location; import org.bukkit.Nameable; import org.bukkit.Server; import org.bukkit.World; import org.bukkit.block.BlockFace; -import org.bukkit.event.entity.EntityDamageEvent; -import org.bukkit.material.Directional; -import org.bukkit.metadata.Metadatable; -import org.bukkit.util.BoundingBox; -import org.bukkit.util.Vector; - -import java.util.List; -import java.util.Set; -import java.util.UUID; import org.bukkit.block.PistonMoveReaction; import org.bukkit.command.CommandSender; +import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; +import org.bukkit.material.Directional; +import org.bukkit.metadata.Metadatable; +import org.bukkit.persistence.PersistentDataHolder; +import org.bukkit.util.BoundingBox; +import org.bukkit.util.Vector; import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -27,9 +26,9 @@ import org.jetbrains.annotations.Nullable; /** * Represents a base entity in the world */ -public interface Entity extends Metadatable, CommandSender, Nameable { +public interface Entity extends Metadatable, CommandSender, Nameable, PersistentDataHolder { - /** + /* * Gets the entity's current position * * @return a new copy of Location containing the position of this entity @@ -249,6 +248,7 @@ public interface Entity extends Metadatable, CommandSender, Nameable { * * @return Server instance running this Entity */ + @Override @NotNull public Server getServer(); @@ -473,6 +473,9 @@ public interface Entity extends Metadatable, CommandSender, Nameable { /** * Sets whether the entity has a team colored (default: white) glow. * + * nb: this refers to the 'Glowing' entity property, not whether a + * glowing potion effect is applied + * * @param flag if the entity is glowing */ void setGlowing(boolean flag); @@ -480,6 +483,9 @@ public interface Entity extends Metadatable, CommandSender, Nameable { /** * Gets whether the entity is glowing or not. * + * nb: this refers to the 'Glowing' entity property, not whether a + * glowing potion effect is applied + * * @return whether the entity is glowing */ boolean isGlowing(); @@ -598,6 +604,18 @@ public interface Entity extends Metadatable, CommandSender, Nameable { @NotNull BlockFace getFacing(); + /** + * Gets the entity's current pose. + * + * Note that the pose is only updated at the end of a tick, so may be + * inconsistent with other methods. eg {@link Player#isSneaking()} being + * true does not imply the current pose will be {@link Pose#SNEAKING} + * + * @return current pose + */ + @NotNull + Pose getPose(); + // Spigot start public class Spigot extends CommandSender.Spigot { @@ -652,22 +670,4 @@ public interface Entity extends Metadatable, CommandSender, Nameable { @NotNull org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason getEntitySpawnReason(); // Paper end - - // Akarin start - /** - * Get the nearest village of this entity in range. - * - * @return The nearest village, null if there is no village in range. - */ - @Nullable - public io.akarin.server.api.structure.Village getNearestVillage(double xRadius, double yRadius, double zRadius); - - /** - * Get villages which are near by this entity in range. - * - * @return All the villages in range, an empty list if there is no village in range. - */ - @NotNull - public List getVillagesInRange(double xRadius, double yRadius, double zRadius); - // Akarin end } diff --git a/api/src/main/java/org/bukkit/entity/EntityType.java b/api/src/main/java/org/bukkit/entity/EntityType.java index 395f74c1c..527cb045f 100644 --- a/api/src/main/java/org/bukkit/entity/EntityType.java +++ b/api/src/main/java/org/bukkit/entity/EntityType.java @@ -1,23 +1,26 @@ package org.bukkit.entity; +import com.google.common.base.Preconditions; import java.util.HashMap; import java.util.Map; - +import org.bukkit.Keyed; +import org.bukkit.Location; +import org.bukkit.NamespacedKey; +import org.bukkit.World; import org.bukkit.entity.minecart.CommandMinecart; -import org.bukkit.entity.minecart.HopperMinecart; -import org.bukkit.entity.minecart.SpawnerMinecart; -import org.bukkit.entity.minecart.RideableMinecart; import org.bukkit.entity.minecart.ExplosiveMinecart; +import org.bukkit.entity.minecart.HopperMinecart; import org.bukkit.entity.minecart.PoweredMinecart; +import org.bukkit.entity.minecart.RideableMinecart; +import org.bukkit.entity.minecart.SpawnerMinecart; import org.bukkit.entity.minecart.StorageMinecart; import org.bukkit.inventory.ItemStack; -import org.bukkit.Location; -import org.bukkit.World; import org.bukkit.potion.PotionEffectType; import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -public enum EntityType { +public enum EntityType implements Keyed { // These strings MUST match the strings in nms.EntityTypes and are case sensitive. /** @@ -86,7 +89,7 @@ public enum EntityType { /** * A flying splash potion. */ - SPLASH_POTION("potion", SplashPotion.class, 16, false), + SPLASH_POTION("potion", ThrownPotion.class, 16, false), /** * A flying experience bottle. */ @@ -116,7 +119,7 @@ public enum EntityType { */ HUSK("husk", Husk.class, 23), /** - * Like {@link #TIPPED_ARROW} but causes the {@link PotionEffectType#GLOWING} effect on all team members. + * Like {@link #ARROW} but causes the {@link PotionEffectType#GLOWING} effect on all team members. */ SPECTRAL_ARROW("spectral_arrow", SpectralArrow.class, 24), /** @@ -250,11 +253,13 @@ public enum EntityType { TROPICAL_FISH("tropical_fish", TropicalFish.class, -1), DROWNED("drowned", Drowned.class, -1), DOLPHIN("dolphin", Dolphin.class, -1), - // These don't have an entity ID in nms.EntityTypes. - /** - * A flying lingering potion - */ - LINGERING_POTION(null, LingeringPotion.class, -1, false), + CAT("cat", Cat.class, -1), + PANDA("panda", Panda.class, -1), + PILLAGER("pillager", Pillager.class, -1), + RAVAGER("ravager", Ravager.class, -1), + TRADER_LLAMA("trader_llama", TraderLlama.class, -1), + WANDERING_TRADER("wandering_trader", WanderingTrader.class, -1), + FOX("fox", Fox.class, -1), /** * A fishing line and bobber. */ @@ -265,23 +270,17 @@ public enum EntityType { * Spawn with {@link World#strikeLightning(Location)}. */ LIGHTNING("lightning_bolt", LightningStrike.class, -1, false), - WEATHER(null, Weather.class, -1, false), PLAYER("player", Player.class, -1, false), - COMPLEX_PART(null, ComplexEntityPart.class, -1, false), - /** - * Like {@link #ARROW} but tipped with a specific potion which is applied on - * contact. - */ - TIPPED_ARROW(null, TippedArrow.class, -1), /** * An unknown entity without an Entity Class */ UNKNOWN(null, null, -1, false); - private String name; - private Class clazz; - private short typeId; - private boolean independent, living; + private final String name; + private final Class clazz; + private final short typeId; + private final boolean independent, living; + private final NamespacedKey key; private static final Map NAME_MAP = new HashMap(); private static final Map ID_MAP = new HashMap(); @@ -320,9 +319,8 @@ public enum EntityType { this.clazz = clazz; this.typeId = (short) typeId; this.independent = independent; - if (clazz != null) { - this.living = LivingEntity.class.isAssignableFrom(clazz); - } + this.living = clazz != null && LivingEntity.class.isAssignableFrom(clazz); + this.key = (name == null) ? null : NamespacedKey.minecraft(name); } /** @@ -336,6 +334,14 @@ public enum EntityType { return name; } + @NotNull + @Override + public NamespacedKey getKey() { + Preconditions.checkArgument(key != null, "EntityType doesn't have key! Is it UNKNOWN?"); + + return key; + } + @Nullable public Class getEntityClass() { return clazz; @@ -343,7 +349,7 @@ public enum EntityType { /** * - * @return the raw type id + * @return the raw type id * @deprecated Magic value */ @Deprecated diff --git a/api/src/main/java/org/bukkit/entity/ExperienceOrb.java b/api/src/main/java/org/bukkit/entity/ExperienceOrb.java index 57029d9bc..dec70bbfa 100644 --- a/api/src/main/java/org/bukkit/entity/ExperienceOrb.java +++ b/api/src/main/java/org/bukkit/entity/ExperienceOrb.java @@ -74,6 +74,10 @@ public interface ExperienceOrb extends Entity { * Spawned by a player throwing an experience points bottle */ EXP_BOTTLE, + /** + * Spawned by a player using a grindstone + */ + GRINDSTONE, /** * We do not know why it was spawned */ diff --git a/api/src/main/java/org/bukkit/entity/Firework.java b/api/src/main/java/org/bukkit/entity/Firework.java index 7df26cf7f..e8c04c138 100644 --- a/api/src/main/java/org/bukkit/entity/Firework.java +++ b/api/src/main/java/org/bukkit/entity/Firework.java @@ -29,6 +29,24 @@ public interface Firework extends Entity { */ void detonate(); + /** + * Gets if the firework was shot at an angle (i.e. from a crossbow). + * + * A firework which was not shot at an angle will fly straight upwards. + * + * @return shot at angle status + */ + boolean isShotAtAngle(); + + /** + * Sets if the firework was shot at an angle (i.e. from a crossbow). + * + * A firework which was not shot at an angle will fly straight upwards. + * + * @param shotAtAngle the new shotAtAngle + */ + void setShotAtAngle(boolean shotAtAngle); + // Paper start @Nullable public UUID getSpawningEntity(); diff --git a/api/src/main/java/org/bukkit/entity/Fox.java b/api/src/main/java/org/bukkit/entity/Fox.java new file mode 100644 index 000000000..89f65032d --- /dev/null +++ b/api/src/main/java/org/bukkit/entity/Fox.java @@ -0,0 +1,53 @@ +package org.bukkit.entity; + +import org.jetbrains.annotations.NotNull; + +/** + * What does the fox say? + */ +public interface Fox extends Animals, Sittable { + + /** + * Gets the current type of this fox. + * + * @return Type of the fox. + */ + @NotNull + public Type getFoxType(); + + /** + * Sets the current type of this fox. + * + * @param type New type of this fox. + */ + public void setFoxType(@NotNull Type type); + + /** + * Checks if this animal is crouching + * + * @return true if crouching + */ + boolean isCrouching(); + + /** + * Sets if this animal is crouching. + * + * @param crouching true if crouching + */ + void setCrouching(boolean crouching); + + /** + * Sets if this animal is sleeping. + * + * @param sleeping true if sleeping + */ + void setSleeping(boolean sleeping); + + /** + * Represents the various different fox types there are. + */ + public enum Type { + RED, + SNOW; + } +} diff --git a/api/src/main/java/org/bukkit/entity/Golem.java b/api/src/main/java/org/bukkit/entity/Golem.java index 4165977e7..4b43c3631 100644 --- a/api/src/main/java/org/bukkit/entity/Golem.java +++ b/api/src/main/java/org/bukkit/entity/Golem.java @@ -4,5 +4,5 @@ package org.bukkit.entity; * A mechanical creature that may harm enemies. */ public interface Golem extends Creature { - + } diff --git a/api/src/main/java/org/bukkit/entity/Guardian.java b/api/src/main/java/org/bukkit/entity/Guardian.java index ec6890ae6..4da9f3c5f 100644 --- a/api/src/main/java/org/bukkit/entity/Guardian.java +++ b/api/src/main/java/org/bukkit/entity/Guardian.java @@ -4,7 +4,7 @@ public interface Guardian extends Monster { /** * Check if the Guardian is an elder Guardian - * + * * @return true if the Guardian is an Elder Guardian, false if not * @deprecated should check if instance of {@link ElderGuardian}. */ @@ -12,7 +12,7 @@ public interface Guardian extends Monster { public boolean isElder(); /** - * @param shouldBeElder Sets whether the Guardian is an Elder + * @param shouldBeElder shouldBeElder * @deprecated Must spawn a new {@link ElderGuardian}. */ @Deprecated diff --git a/api/src/main/java/org/bukkit/entity/Horse.java b/api/src/main/java/org/bukkit/entity/Horse.java index 5efa4e606..9e1bb136c 100644 --- a/api/src/main/java/org/bukkit/entity/Horse.java +++ b/api/src/main/java/org/bukkit/entity/Horse.java @@ -154,7 +154,7 @@ public interface Horse extends AbstractHorse { public boolean isCarryingChest(); /** - * @param chest Sets whether the Horse is carrying a chest + * @param chest chest * @deprecated see {@link ChestedHorse} */ @Deprecated diff --git a/api/src/main/java/org/bukkit/entity/HumanEntity.java b/api/src/main/java/org/bukkit/entity/HumanEntity.java index a372c74b8..f25c73155 100644 --- a/api/src/main/java/org/bukkit/entity/HumanEntity.java +++ b/api/src/main/java/org/bukkit/entity/HumanEntity.java @@ -5,12 +5,12 @@ import org.bukkit.GameMode; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.NamespacedKey; -import org.bukkit.inventory.MainHand; -import org.bukkit.inventory.Merchant; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.InventoryHolder; import org.bukkit.inventory.InventoryView; import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.MainHand; +import org.bukkit.inventory.Merchant; import org.bukkit.inventory.PlayerInventory; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -232,13 +232,6 @@ public interface HumanEntity extends LivingEntity, AnimalTamer, InventoryHolder */ public void setCooldown(@NotNull Material material, int ticks); - /** - * Returns whether this player is slumbering. - * - * @return slumber state - */ - public boolean isSleeping(); - /** * Get the sleep ticks of the player. This value may be capped. * diff --git a/api/src/main/java/org/bukkit/entity/Illager.java b/api/src/main/java/org/bukkit/entity/Illager.java index b723fbac3..a288dfa26 100644 --- a/api/src/main/java/org/bukkit/entity/Illager.java +++ b/api/src/main/java/org/bukkit/entity/Illager.java @@ -3,4 +3,4 @@ package org.bukkit.entity; /** * Represents a type of "Illager". */ -public interface Illager extends Monster { } +public interface Illager extends Raider { } diff --git a/api/src/main/java/org/bukkit/entity/LightningStrike.java b/api/src/main/java/org/bukkit/entity/LightningStrike.java index cbc5ee8fe..5904ed87a 100644 --- a/api/src/main/java/org/bukkit/entity/LightningStrike.java +++ b/api/src/main/java/org/bukkit/entity/LightningStrike.java @@ -5,7 +5,7 @@ import org.jetbrains.annotations.NotNull; /** * Represents an instance of a lightning strike. May or may not do damage. */ -public interface LightningStrike extends Weather { +public interface LightningStrike extends Entity { /** * Returns whether the strike is an effect that does no damage. diff --git a/api/src/main/java/org/bukkit/entity/LingeringPotion.java b/api/src/main/java/org/bukkit/entity/LingeringPotion.java index 5aca7cb84..f124b35ec 100644 --- a/api/src/main/java/org/bukkit/entity/LingeringPotion.java +++ b/api/src/main/java/org/bukkit/entity/LingeringPotion.java @@ -2,5 +2,7 @@ package org.bukkit.entity; /** * Represents a thrown lingering potion bottle + * + * @deprecated lingering status depends on only on the potion item. */ public interface LingeringPotion extends ThrownPotion { } diff --git a/api/src/main/java/org/bukkit/entity/LivingEntity.java b/api/src/main/java/org/bukkit/entity/LivingEntity.java index 956d68867..a78f390d7 100644 --- a/api/src/main/java/org/bukkit/entity/LivingEntity.java +++ b/api/src/main/java/org/bukkit/entity/LivingEntity.java @@ -3,13 +3,13 @@ package org.bukkit.entity; import java.util.Collection; import java.util.List; import java.util.Set; - import org.bukkit.FluidCollisionMode; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.World; import org.bukkit.attribute.Attributable; import org.bukkit.block.Block; +import org.bukkit.entity.memory.MemoryKey; import org.bukkit.inventory.EntityEquipment; import org.bukkit.inventory.ItemStack; import org.bukkit.potion.PotionEffect; @@ -558,6 +558,13 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource */ public boolean isRiptiding(); + /** + * Returns whether this entity is slumbering. + * + * @return slumber state + */ + public boolean isSleeping(); + /** * Sets whether an entity will have AI. * @@ -594,6 +601,31 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource */ boolean isCollidable(); + /** + * Returns the value of the memory specified. + *

+ * Note that the value is null when the specific entity does not have that + * value by default. + * + * @param memoryKey memory to access + * @param the type of the return value + * @return a instance of the memory section value or null if not present + */ + @Nullable + T getMemory(@NotNull MemoryKey memoryKey); + + /** + * Sets the value of the memory specified. + *

+ * Note that the value will not be persisted when the specific entity does + * not have that value by default. + * + * @param memoryKey the memory to access + * @param memoryValue a typed memory value + * @param the type of the passed value + */ + void setMemory(@NotNull MemoryKey memoryKey, @Nullable T memoryValue); + // Paper start /** * Get the number of arrows stuck in this entity diff --git a/api/src/main/java/org/bukkit/entity/Minecart.java b/api/src/main/java/org/bukkit/entity/Minecart.java index 5a07493ad..95c79c5fa 100644 --- a/api/src/main/java/org/bukkit/entity/Minecart.java +++ b/api/src/main/java/org/bukkit/entity/Minecart.java @@ -139,7 +139,7 @@ public interface Minecart extends Vehicle { /** * Gets the offset of the display block. - * + * * @return the current block offset for this minecart. */ public int getDisplayBlockOffset(); diff --git a/api/src/main/java/org/bukkit/entity/MushroomCow.java b/api/src/main/java/org/bukkit/entity/MushroomCow.java index 84154de1a..939a3dbfc 100644 --- a/api/src/main/java/org/bukkit/entity/MushroomCow.java +++ b/api/src/main/java/org/bukkit/entity/MushroomCow.java @@ -1,8 +1,38 @@ package org.bukkit.entity; +import org.jetbrains.annotations.NotNull; + /** * Represents a mushroom {@link Cow} */ public interface MushroomCow extends Cow { + /** + * Get the variant of this cow. + * + * @return cow variant + */ + @NotNull + public Variant getVariant(); + + /** + * Set the variant of this cow. + * + * @param variant cow variant + */ + public void setVariant(@NotNull Variant variant); + + /** + * Represents the variant of a cow - ie its color. + */ + public enum Variant { + /** + * Red mushroom cow. + */ + RED, + /** + * Brown mushroom cow. + */ + BROWN; + } } diff --git a/api/src/main/java/org/bukkit/entity/Ocelot.java b/api/src/main/java/org/bukkit/entity/Ocelot.java index fe75169e5..c20b8e559 100644 --- a/api/src/main/java/org/bukkit/entity/Ocelot.java +++ b/api/src/main/java/org/bukkit/entity/Ocelot.java @@ -7,7 +7,7 @@ import org.jetbrains.annotations.Nullable; /** * A wild tameable cat */ -public interface Ocelot extends Animals, Tameable, Sittable { +public interface Ocelot extends Animals { /** * Gets the current type of this cat. @@ -26,7 +26,10 @@ public interface Ocelot extends Animals, Tameable, Sittable { /** * Represents the various different cat types there are. + * + * @deprecated Cats are now a separate entity. */ + @Deprecated public enum Type { WILD_OCELOT(0), BLACK_CAT(1), diff --git a/api/src/main/java/org/bukkit/entity/Panda.java b/api/src/main/java/org/bukkit/entity/Panda.java new file mode 100644 index 000000000..a6a7429ed --- /dev/null +++ b/api/src/main/java/org/bukkit/entity/Panda.java @@ -0,0 +1,66 @@ +package org.bukkit.entity; + +import org.jetbrains.annotations.NotNull; + +/** + * Panda entity. + */ +public interface Panda extends Animals { + + /** + * Gets this Panda's main gene. + * + * @return main gene + */ + @NotNull + Gene getMainGene(); + + /** + * Sets this Panda's main gene. + * + * @param gene main gene + */ + void setMainGene(@NotNull Gene gene); + + /** + * Gets this Panda's hidden gene. + * + * @return hidden gene + */ + @NotNull + Gene getHiddenGene(); + + /** + * Sets this Panda's hidden gene. + * + * @param gene hidden gene + */ + void setHiddenGene(@NotNull Gene gene); + + public enum Gene { + + NORMAL(false), + LAZY(false), + WORRIED(false), + PLAYFUL(false), + BROWN(true), + WEAK(true), + AGGRESSIVE(false); + + private final boolean recessive; + + private Gene(boolean recessive) { + this.recessive = recessive; + } + + /** + * Gets whether this gene is recessive, i.e. required in both parents to + * propagate to children. + * + * @return recessive status + */ + public boolean isRecessive() { + return recessive; + } + } +} diff --git a/api/src/main/java/org/bukkit/entity/Pillager.java b/api/src/main/java/org/bukkit/entity/Pillager.java new file mode 100644 index 000000000..9a2252fef --- /dev/null +++ b/api/src/main/java/org/bukkit/entity/Pillager.java @@ -0,0 +1,8 @@ +package org.bukkit.entity; + +import org.bukkit.inventory.InventoryHolder; + +/** + * Illager entity. + */ +public interface Pillager extends Illager, InventoryHolder { } diff --git a/api/src/main/java/org/bukkit/entity/Player.java b/api/src/main/java/org/bukkit/entity/Player.java index 1b3a6a91c..8d8d89576 100644 --- a/api/src/main/java/org/bukkit/entity/Player.java +++ b/api/src/main/java/org/bukkit/entity/Player.java @@ -1,15 +1,15 @@ package org.bukkit.entity; import java.net.InetSocketAddress; -import java.util.Date; +import java.util.Date; // Paper import com.destroystokyo.paper.Title; import com.destroystokyo.paper.profile.PlayerProfile; import org.bukkit.Achievement; -import org.bukkit.BanEntry; -import org.bukkit.BanList; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; +import org.bukkit.BanEntry; // Paper +import org.bukkit.BanList; // Paper +import org.bukkit.Bukkit; // Paper +import org.bukkit.DyeColor; import org.bukkit.Effect; import org.bukkit.GameMode; import org.bukkit.Instrument; @@ -27,6 +27,7 @@ import org.bukkit.advancement.AdvancementProgress; import org.bukkit.block.data.BlockData; import org.bukkit.conversations.Conversable; import org.bukkit.event.player.PlayerResourcePackStatusEvent; +import org.bukkit.inventory.ItemStack; import org.bukkit.map.MapView; import org.bukkit.plugin.Plugin; import org.bukkit.plugin.messaging.PluginMessageRecipient; @@ -146,6 +147,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM * * @param message Message to be displayed */ + @Override public void sendRawMessage(@NotNull String message); /** @@ -420,6 +422,26 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM */ public void sendSignChange(@NotNull Location loc, @Nullable String[] lines) throws IllegalArgumentException; + + /** + * 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. + * This method will use a sign at the location's block or a faked sign + * sent via + * {@link #sendBlockChange(org.bukkit.Location, org.bukkit.Material, byte)}. + *

+ * If the client does not have a sign at the given location it will + * display an error message to the user. + * + * @param loc the location of the sign + * @param lines the new text on the sign or null to clear it + * @param dyeColor the color of the sign + * @throws IllegalArgumentException if location is null + * @throws IllegalArgumentException if dyeColor is null + * @throws IllegalArgumentException if lines is non-null and has a length less than 4 + */ + public void sendSignChange(@NotNull Location loc, @Nullable String[] lines, @NotNull DyeColor dyeColor) throws IllegalArgumentException; + /** * Render a map and send it to the player in its entirety. This may be * used when streaming the map in the normal manner is not desirable. @@ -1610,6 +1632,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM * Spawns the particle (the number of times specified by count) * at the target location. * + * @param type of particle data (see {@link Particle#getDataType()} * @param particle the particle to spawn * @param location the location to spawn at * @param count the number of particles @@ -1624,6 +1647,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM * Spawns the particle (the number of times specified by count) * at the target location. * + * @param type of particle data (see {@link Particle#getDataType()} * @param particle the particle to spawn * @param x the position on the x axis to spawn at * @param y the position on the y axis to spawn at @@ -1673,6 +1697,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM * randomized positively and negatively by the offset parameters * on each axis. * + * @param type of particle data (see {@link Particle#getDataType()} * @param particle the particle to spawn * @param location the location to spawn at * @param count the number of particles @@ -1691,6 +1716,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM * randomized positively and negatively by the offset parameters * on each axis. * + * @param type of particle data (see {@link Particle#getDataType()} * @param particle the particle to spawn * @param x the position on the x axis to spawn at * @param y the position on the y axis to spawn at @@ -1747,6 +1773,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM * randomized positively and negatively by the offset parameters * on each axis. * + * @param type of particle data (see {@link Particle#getDataType()} * @param particle the particle to spawn * @param location the location to spawn at * @param count the number of particles @@ -1767,6 +1794,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM * randomized positively and negatively by the offset parameters * on each axis. * + * @param type of particle data (see {@link Particle#getDataType()} * @param particle the particle to spawn * @param x the position on the x axis to spawn at * @param y the position on the y axis to spawn at @@ -1830,15 +1858,6 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM * @param affects Whether the player can affect mob spawning */ public void setAffectsSpawning(boolean affects); - // Paper end - - /** - * Update the list of commands sent to the client. - *
- * Generally useful to ensure the client has a complete list of commands - * after permission changes are done. - */ - public void updateCommands(); /** * Gets the view distance for this player @@ -1853,6 +1872,22 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM * @param viewDistance the player's view distance */ public void setViewDistance(int viewDistance); + // Paper end + + /** + * Update the list of commands sent to the client. + *
+ * Generally useful to ensure the client has a complete list of commands + * after permission changes are done. + */ + public void updateCommands(); + + /** + * Open a {@link Material#WRITTEN_BOOK} for a Player + * + * @param book The book to open for this player + */ + public void openBook(@NotNull ItemStack book); // Paper start /** diff --git a/api/src/main/java/org/bukkit/entity/Pose.java b/api/src/main/java/org/bukkit/entity/Pose.java new file mode 100644 index 000000000..b6e0c6f53 --- /dev/null +++ b/api/src/main/java/org/bukkit/entity/Pose.java @@ -0,0 +1,37 @@ +package org.bukkit.entity; + +/** + * Represents an entity body pose. + */ +public enum Pose { + + /** + * Entity is standing normally. + * + */ + STANDING, + /** + * Entity is gliding. + */ + FALL_FLYING, + /** + * Entity is sleeping. + */ + SLEEPING, + /** + * Entity is swimming. + */ + SWIMMING, + /** + * Entity is riptiding with a trident. + */ + SPIN_ATTACK, + /** + * Entity is sneaking. + */ + SNEAKING, + /** + * Entity is dead. + */ + DYING; +} diff --git a/api/src/main/java/org/bukkit/entity/Raider.java b/api/src/main/java/org/bukkit/entity/Raider.java new file mode 100644 index 000000000..ac73eaf36 --- /dev/null +++ b/api/src/main/java/org/bukkit/entity/Raider.java @@ -0,0 +1,36 @@ +package org.bukkit.entity; + +import org.bukkit.block.Block; +import org.jetbrains.annotations.Nullable; + +public interface Raider extends Monster { + + /** + * Gets the block the raider is targeting to patrol. + * + * @return target block or null + */ + @Nullable + Block getPatrolTarget(); + + /** + * Sets the block the raider is targeting to patrol. + * + * @param block target block or null. Must be in same world as the entity + */ + void setPatrolTarget(@Nullable Block block); + + /** + * Gets whether this entity is a patrol leader. + * + * @return patrol leader status + */ + boolean isPatrolLeader(); + + /** + * Sets whether this entity is a patrol leader. + * + * @param leader patrol leader status + */ + void setPatrolLeader(boolean leader); +} diff --git a/api/src/main/java/org/bukkit/entity/Ravager.java b/api/src/main/java/org/bukkit/entity/Ravager.java new file mode 100644 index 000000000..4374d5206 --- /dev/null +++ b/api/src/main/java/org/bukkit/entity/Ravager.java @@ -0,0 +1,6 @@ +package org.bukkit.entity; + +/** + * Illager beast. + */ +public interface Ravager extends Raider { } diff --git a/api/src/main/java/org/bukkit/entity/Skeleton.java b/api/src/main/java/org/bukkit/entity/Skeleton.java index d42a4e12c..1c367f78e 100644 --- a/api/src/main/java/org/bukkit/entity/Skeleton.java +++ b/api/src/main/java/org/bukkit/entity/Skeleton.java @@ -20,7 +20,7 @@ public interface Skeleton extends Monster, RangedEntity { // Paper public SkeletonType getSkeletonType(); /** - * @param type Type to set + * @param type type * @deprecated Must spawn a new subtype variant */ @Deprecated diff --git a/api/src/main/java/org/bukkit/entity/SpectralArrow.java b/api/src/main/java/org/bukkit/entity/SpectralArrow.java index 1a32341c3..b02ec168b 100644 --- a/api/src/main/java/org/bukkit/entity/SpectralArrow.java +++ b/api/src/main/java/org/bukkit/entity/SpectralArrow.java @@ -3,19 +3,19 @@ package org.bukkit.entity; /** * Represents a spectral arrow. */ -public interface SpectralArrow extends Arrow { +public interface SpectralArrow extends AbstractArrow { /** * Returns the amount of time that this arrow will apply * the glowing effect for. - * + * * @return the glowing effect ticks */ int getGlowingTicks(); /** * Sets the amount of time to apply the glowing effect for. - * + * * @param duration the glowing effect ticks */ void setGlowingTicks(int duration); diff --git a/api/src/main/java/org/bukkit/entity/SplashPotion.java b/api/src/main/java/org/bukkit/entity/SplashPotion.java index 2a2102542..9cb08fe72 100644 --- a/api/src/main/java/org/bukkit/entity/SplashPotion.java +++ b/api/src/main/java/org/bukkit/entity/SplashPotion.java @@ -2,5 +2,8 @@ package org.bukkit.entity; /** * Represents a thrown splash potion bottle + * + * @deprecated splash status depends on only on the potion item. */ +@Deprecated public interface SplashPotion extends ThrownPotion { } diff --git a/api/src/main/java/org/bukkit/entity/ThrownPotion.java b/api/src/main/java/org/bukkit/entity/ThrownPotion.java index 02218457a..10a3c297b 100644 --- a/api/src/main/java/org/bukkit/entity/ThrownPotion.java +++ b/api/src/main/java/org/bukkit/entity/ThrownPotion.java @@ -1,7 +1,6 @@ package org.bukkit.entity; import java.util.Collection; - import org.bukkit.inventory.ItemStack; import org.bukkit.potion.PotionEffect; import org.jetbrains.annotations.NotNull; diff --git a/api/src/main/java/org/bukkit/entity/TippedArrow.java b/api/src/main/java/org/bukkit/entity/TippedArrow.java index d53b40d34..3193cc8a0 100644 --- a/api/src/main/java/org/bukkit/entity/TippedArrow.java +++ b/api/src/main/java/org/bukkit/entity/TippedArrow.java @@ -1,98 +1,8 @@ package org.bukkit.entity; -import java.util.List; - -import org.bukkit.Color; -import org.bukkit.potion.PotionData; -import org.bukkit.potion.PotionEffect; -import org.bukkit.potion.PotionEffectType; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -public interface TippedArrow extends Arrow { - - /** - * Sets the underlying potion data - * - * @param data PotionData to set the base potion state to - */ - void setBasePotionData(@NotNull PotionData data); - - /** - * Returns the potion data about the base potion - * - * @return a PotionData object - */ - @NotNull - PotionData getBasePotionData(); - - /** - * Gets the color of this arrow. - * - * @return arrow color - */ - @NotNull - Color getColor(); - - /** - * Sets the color of this arrow. Will be applied as a tint to its particles. - * - * @param color arrow color - */ - void setColor(@NotNull Color color); - - /** - * Checks for the presence of custom potion effects. - * - * @return true if custom potion effects are applied - */ - boolean hasCustomEffects(); - - /** - * Gets an immutable list containing all custom potion effects applied to - * this arrow. - *

- * Plugins should check that hasCustomEffects() returns true before calling - * this method. - * - * @return the immutable list of custom potion effects - */ - @NotNull - List getCustomEffects(); - - /** - * Adds a custom potion effect to this arrow. - * - * @param effect the potion effect to add - * @param overwrite true if any existing effect of the same type should be - * overwritten - * @return true if the effect was added as a result of this call - */ - boolean addCustomEffect(@NotNull PotionEffect effect, boolean overwrite); - - /** - * Removes a custom potion effect from this arrow. - * - * @param type the potion effect type to remove - * @return true if the an effect was removed as a result of this call - * @throws IllegalArgumentException if this operation would leave the Arrow - * in a state with no Custom Effects and PotionType.UNCRAFTABLE - */ - boolean removeCustomEffect(@NotNull PotionEffectType type); - - /** - * Checks for a specific custom potion effect type on this arrow. - * - * @param type the potion effect type to check for - * @return true if the potion has this effect - */ - boolean hasCustomEffect(@Nullable PotionEffectType type); - - /** - * Removes all custom potion effects from this arrow. - * - * @throws IllegalArgumentException if this operation would leave the Arrow - * in a state with no Custom Effects and PotionType.UNCRAFTABLE - */ - void clearCustomEffects(); -} +/** + * @deprecated tipped status depends only on base potion type not being + * UNCRAFTABLE and effects being empty. + */ +@Deprecated +public interface TippedArrow extends Arrow { } diff --git a/api/src/main/java/org/bukkit/entity/TraderLlama.java b/api/src/main/java/org/bukkit/entity/TraderLlama.java new file mode 100644 index 000000000..78966d19c --- /dev/null +++ b/api/src/main/java/org/bukkit/entity/TraderLlama.java @@ -0,0 +1,6 @@ +package org.bukkit.entity; + +/** + * Represents a trader Llama. + */ +public interface TraderLlama extends Llama { } diff --git a/api/src/main/java/org/bukkit/entity/Trident.java b/api/src/main/java/org/bukkit/entity/Trident.java index 7af949eac..3379ef9ba 100644 --- a/api/src/main/java/org/bukkit/entity/Trident.java +++ b/api/src/main/java/org/bukkit/entity/Trident.java @@ -3,4 +3,4 @@ package org.bukkit.entity; /** * Represents a thrown trident. */ -public interface Trident extends Arrow { } +public interface Trident extends AbstractArrow { } diff --git a/api/src/main/java/org/bukkit/entity/Vehicle.java b/api/src/main/java/org/bukkit/entity/Vehicle.java index c73ee6cbd..771a27304 100644 --- a/api/src/main/java/org/bukkit/entity/Vehicle.java +++ b/api/src/main/java/org/bukkit/entity/Vehicle.java @@ -13,6 +13,7 @@ public interface Vehicle extends Entity { * * @return velocity vector */ + @Override @NotNull public Vector getVelocity(); @@ -21,5 +22,6 @@ public interface Vehicle extends Entity { * * @param vel velocity vector */ + @Override public void setVelocity(@NotNull Vector vel); } diff --git a/api/src/main/java/org/bukkit/entity/Villager.java b/api/src/main/java/org/bukkit/entity/Villager.java index a3c94a17f..ef48ad9b2 100644 --- a/api/src/main/java/org/bukkit/entity/Villager.java +++ b/api/src/main/java/org/bukkit/entity/Villager.java @@ -1,21 +1,15 @@ package org.bukkit.entity; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.LinkedListMultimap; -import com.google.common.collect.Multimap; - -import java.util.List; - -import org.bukkit.inventory.Inventory; -import org.bukkit.inventory.InventoryHolder; -import org.bukkit.inventory.Merchant; +import java.util.Locale; +import org.bukkit.Keyed; +import org.bukkit.Location; +import org.bukkit.NamespacedKey; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; /** * Represents a villager NPC */ -public interface Villager extends Ageable, NPC, InventoryHolder, Merchant { +public interface Villager extends AbstractVillager { /** * Gets the current profession of this villager. @@ -33,242 +27,187 @@ public interface Villager extends Ageable, NPC, InventoryHolder, Merchant { public void setProfession(@NotNull Profession profession); /** - * Get the current {@link Career} for this Villager. + * Gets the current type of this villager. * - * @return the {@link Career} + * @return Current type. */ @NotNull - public Career getCareer(); + public Type getVillagerType(); /** - * Set the new {@link Career} for this Villager. - * This method will reset the villager's trades to the new career. + * Sets the new type of this villager. * - * @param career the new career, or null to clear the career to a random one - * @throws IllegalArgumentException when the new {@link Career} cannot be - * used with this Villager's current {@link Profession}. + * @param type New type. */ - public void setCareer(@Nullable Career career); + public void setVillagerType(@NotNull Type type); /** - * Set the new {@link Career} for this Villager. + * Gets the level of this villager. * - * @param career the new career, or null to clear the career to a random one - * @param resetTrades true to reset this Villager's trades to the new - * career's (if any) - * @throws IllegalArgumentException when the new {@link Career} cannot be - * used with this Villager's current {@link Profession}. + * A villager with a level of 1 and no experience is liable to lose its + * profession. + * + * @return this villager's level */ - public void setCareer(@Nullable Career career, boolean resetTrades); + public int getVillagerLevel(); /** - * Gets this villager's inventory. + * Sets the level of this villager. + * + * A villager with a level of 1 and no experience is liable to lose its + * profession. + * + * @param level the new level + * @throws IllegalArgumentException if level not between [1, 5] + */ + public void setVillagerLevel(int level); + + /** + * Gets the trading experience of this villager. + * + * @return trading experience + */ + public int getVillagerExperience(); + + /** + * Sets the trading experience of this villager. + * + * @param experience new experience + * @throws IllegalArgumentException if experience < 0 + */ + public void setVillagerExperience(int experience); + + /** + * Attempts to make this villager sleep at the given location. *
- * Note that this inventory is not the Merchant inventory, rather, it is the - * items that a villager might have collected (from harvesting crops, etc.) + * The location must be in the current world and have a bed placed at the + * location. The villager will put its head on the specified block while + * sleeping. * - * {@inheritDoc} + * @param location the location of the bed + * @return whether the sleep was successful */ - @NotNull - @Override - Inventory getInventory(); + public boolean sleep(@NotNull Location location); /** - * Gets this villager's riches, the number of emeralds this villager has - * been given. + * Causes this villager to wake up if he's currently sleeping. * - * @return the villager's riches + * @throws IllegalStateException if not sleeping */ - int getRiches(); + public void wakeup(); /** - * Sets this villager's riches. - * - * @see Villager#getRiches() - * - * @param riches the new riches + * Represents Villager type, usually corresponding to what biome they spawn + * in. */ - void setRiches(int riches); + public enum Type implements Keyed { + + DESERT, + JUNGLE, + PLAINS, + SAVANNA, + SNOW, + SWAMP, + TAIGA; + private final NamespacedKey key; + + private Type() { + this.key = NamespacedKey.minecraft(this.name().toLowerCase(Locale.ROOT)); + } + + @NotNull + @Override + public NamespacedKey getKey() { + return key; + } + } /** * Represents the various different Villager professions there may be. * Villagers have different trading options depending on their profession, */ - public enum Profession { + public enum Profession implements Keyed { + NONE, /** - * Normal. Reserved for Zombies. - * @deprecated Unused + * Armorer profession. Wears a black apron. Armorers primarily trade for + * iron armor, chainmail armor, and sometimes diamond armor. */ - @Deprecated - NORMAL(true), + ARMORER, /** - * Farmer profession. Wears a brown robe. + * Butcher profession. Wears a white apron. Butchers primarily trade for + * raw and cooked food. */ - FARMER(false), + BUTCHER, /** - * Librarian profession. Wears a white robe. + * Cartographer profession. Wears a white robe. Cartographers primarily + * trade for explorer maps and some paper. */ - LIBRARIAN(false), + CARTOGRAPHER, /** - * Priest profession. Wears a purple robe. + * Cleric profession. Wears a purple robe. Clerics primarily trade for + * rotten flesh, gold ingot, redstone, lapis, ender pearl, glowstone, + * and bottle o' enchanting. */ - PRIEST(false), + CLERIC, /** - * Blacksmith profession. Wears a black apron. + * Farmer profession. Wears a brown robe. Farmers primarily trade for + * food-related items. */ - BLACKSMITH(false), + FARMER, /** - * Butcher profession. Wears a white apron. + * Fisherman profession. Wears a brown robe. Fisherman primarily trade + * for fish, as well as possibly selling string and/or coal. */ - BUTCHER(false), + FISHERMAN, /** - * Nitwit profession. Wears a green apron, cannot trade. + * Fletcher profession. Wears a brown robe. Fletchers primarily trade + * for string, bows, and arrows. */ - NITWIT(false), + FLETCHER, /** - * Husk. Reserved for Zombies - * @deprecated Unused + * Leatherworker profession. Wears a white apron. Leatherworkers + * primarily trade for leather, and leather armor, as well as saddles. */ - @Deprecated - HUSK(true); - private final boolean zombie; + LEATHERWORKER, + /** + * Librarian profession. Wears a white robe. Librarians primarily trade + * for paper, books, and enchanted books. + */ + LIBRARIAN, + /** + * Mason profession. + */ + MASON, + /** + * Nitwit profession. Wears a green apron, cannot trade. Nitwit + * villagers do not do anything. They do not have any trades by default. + */ + NITWIT, + /** + * Sheperd profession. Wears a brown robe. Shepherds primarily trade for + * wool items, and shears. + */ + SHEPHERD, + /** + * Toolsmith profession. Wears a black apron. Tool smiths primarily + * trade for iron and diamond tools. + */ + TOOLSMITH, + /** + * Weaponsmith profession. Wears a black apron. Weapon smiths primarily + * trade for iron and diamond weapons, sometimes enchanted. + */ + WEAPONSMITH; + private final NamespacedKey key; - private Profession(boolean zombie) { - this.zombie = zombie; + private Profession() { + this.key = NamespacedKey.minecraft(this.name().toLowerCase(Locale.ROOT)); } - /** - * Returns if this profession can only be used by zombies. - * - * @return zombie profession status - * @deprecated Unused - */ - @Deprecated - public boolean isZombie() { - return zombie; - } - - /** - * Get an immutable list of {@link Career} belonging to this Profession. - * - * @return an immutable list of careers for this profession, or an empty - * map if this Profession has no careers. - */ @NotNull - public List getCareers() { - return Career.getCareers(this); - } - } - - /** - * The Career of this Villager. - * Each {@link Profession} has a set of careers it is applicable to. Each - * career dictates the trading options that are generated. - */ - public enum Career { - /* - NOTE: The Career entries are order-specific. They should be maintained in the numerical order they are used in the CB implementation. - (e.g. Farmer careers are 1,2,3,4 so Career should reflect that numerical order in their ordinal status) - */ - // Farmer careers - /** - * Farmers primarily trade for food-related items. - */ - FARMER(Profession.FARMER), - /** - * Fisherman primarily trade for fish, as well as possibly selling - * string and/or coal. - */ - FISHERMAN(Profession.FARMER), - /** - * Shepherds primarily trade for wool items, and shears. - */ - SHEPHERD(Profession.FARMER), - /** - * Fletchers primarily trade for string, bows, and arrows. - */ - FLETCHER(Profession.FARMER), - // Librarian careers - /** - * Librarians primarily trade for paper, books, and enchanted books. - */ - LIBRARIAN(Profession.LIBRARIAN), - /** - * Cartographers primarily trade for explorer maps and some paper. - */ - CARTOGRAPHER(Profession.LIBRARIAN), - // Priest careers - /** - * Clerics primarily trade for rotten flesh, gold ingot, redstone, - * lapis, ender pearl, glowstone, and bottle o' enchanting. - */ - CLERIC(Profession.PRIEST), - // Blacksmith careers - /** - * Armorers primarily trade for iron armor, chainmail armor, and - * sometimes diamond armor. - */ - ARMORER(Profession.BLACKSMITH), - /** - * Weapon smiths primarily trade for iron and diamond weapons, sometimes - * enchanted. - */ - WEAPON_SMITH(Profession.BLACKSMITH), - /** - * Tool smiths primarily trade for iron and diamond tools. - */ - TOOL_SMITH(Profession.BLACKSMITH), - // Butcher careers - /** - * Butchers primarily trade for raw and cooked food. - */ - BUTCHER(Profession.BUTCHER), - /** - * Leatherworkers primarily trade for leather, and leather armor, as - * well as saddles. - */ - LEATHERWORKER(Profession.BUTCHER), - // Nitwit - /** - * Nitwit villagers do not do anything. They do not have any trades by - * default. - */ - NITWIT(Profession.NITWIT); - - private static final Multimap careerMap = LinkedListMultimap.create(); - private final Profession profession; - - private Career(/*@NotNull*/ Profession profession) { - this.profession = profession; - } - - /** - * Get the {@link Profession} this {@link Career} belongs to. - * - * @return the {@link Profession}. - */ - @NotNull - public Profession getProfession() { - return profession; - } - - /** - * Get an immutable list of {@link Career}s that can be used with a - * given {@link Profession} - * - * @param profession the profession to get careers for - * @return an immutable list of Careers that can be used by a - * profession, or an empty map if the profession was not found - */ - @NotNull - public static List getCareers(@NotNull Profession profession) { - return careerMap.containsKey(profession) ? ImmutableList.copyOf(careerMap.get(profession)) : ImmutableList.of(); - } - - static { - for (Career career : Career.values()) { - careerMap.put(career.profession, career); - } + @Override + public NamespacedKey getKey() { + return key; } } } diff --git a/api/src/main/java/org/bukkit/entity/WanderingTrader.java b/api/src/main/java/org/bukkit/entity/WanderingTrader.java new file mode 100644 index 000000000..3547e159b --- /dev/null +++ b/api/src/main/java/org/bukkit/entity/WanderingTrader.java @@ -0,0 +1,6 @@ +package org.bukkit.entity; + +/** + * Represents a wandering trader NPC + */ +public interface WanderingTrader extends AbstractVillager { } diff --git a/api/src/main/java/org/bukkit/entity/Weather.java b/api/src/main/java/org/bukkit/entity/Weather.java deleted file mode 100644 index 6d77851f9..000000000 --- a/api/src/main/java/org/bukkit/entity/Weather.java +++ /dev/null @@ -1,6 +0,0 @@ -package org.bukkit.entity; - -/** - * Represents a Weather related entity, such as a storm - */ -public interface Weather extends Entity {} diff --git a/api/src/main/java/org/bukkit/entity/Witch.java b/api/src/main/java/org/bukkit/entity/Witch.java index 1828b2ced..cd8d0a20e 100644 --- a/api/src/main/java/org/bukkit/entity/Witch.java +++ b/api/src/main/java/org/bukkit/entity/Witch.java @@ -10,8 +10,8 @@ import org.jetbrains.annotations.Nullable; /** * Represents a Witch */ -// Paper start -public interface Witch extends Monster, RangedEntity { +public interface Witch extends Raider, RangedEntity { // Paper + // Paper start /** * Check if Witch is drinking a potion * diff --git a/api/src/main/java/org/bukkit/entity/Wolf.java b/api/src/main/java/org/bukkit/entity/Wolf.java index f07d51941..0390558b8 100644 --- a/api/src/main/java/org/bukkit/entity/Wolf.java +++ b/api/src/main/java/org/bukkit/entity/Wolf.java @@ -18,9 +18,7 @@ public interface Wolf extends Animals, Tameable, Sittable { /** * Sets the anger of this wolf. *

- * An angry wolf can not be fed or tamed, and must have a target to attack. - * If a target is not set the wolf will quickly revert to its non-angry - * state. + * An angry wolf can not be fed or tamed. * * @param angry true if angry * @see #setTarget(org.bukkit.entity.LivingEntity) diff --git a/api/src/main/java/org/bukkit/entity/Zombie.java b/api/src/main/java/org/bukkit/entity/Zombie.java index 74d6529a1..fa7a43c35 100644 --- a/api/src/main/java/org/bukkit/entity/Zombie.java +++ b/api/src/main/java/org/bukkit/entity/Zombie.java @@ -32,7 +32,7 @@ public interface Zombie extends Monster { public boolean isVillager(); /** - * @param flag Sets whether the Zombie is a villager + * @param flag flag * @deprecated must spawn {@link ZombieVillager}. */ @Deprecated @@ -40,7 +40,7 @@ public interface Zombie extends Monster { public void setVillager(boolean flag); /** - * @param profession Sets the ZombieVillager's profession + * @param profession profession * @see ZombieVillager#getVillagerProfession() */ @Deprecated diff --git a/api/src/main/java/org/bukkit/entity/ZombieVillager.java b/api/src/main/java/org/bukkit/entity/ZombieVillager.java index f8ff3b655..a8ec860ea 100644 --- a/api/src/main/java/org/bukkit/entity/ZombieVillager.java +++ b/api/src/main/java/org/bukkit/entity/ZombieVillager.java @@ -1,5 +1,6 @@ package org.bukkit.entity; +import org.bukkit.OfflinePlayer; import org.jetbrains.annotations.Nullable; /** @@ -55,4 +56,22 @@ public interface ZombieVillager extends Zombie { */ @Override void setConversionTime(int time); + + /** + * Gets the player who initiated the conversion. + * + * @return the player, or null if the player is unknown or the + * entity isn't converting currently + */ + @Nullable + OfflinePlayer getConversionPlayer(); + + /** + * Sets the player who initiated the conversion. + *

+ * This has no effect if this entity isn't converting currently. + * + * @param conversionPlayer the player + */ + void setConversionPlayer(@Nullable OfflinePlayer conversionPlayer); } diff --git a/api/src/main/java/org/bukkit/entity/memory/MemoryKey.java b/api/src/main/java/org/bukkit/entity/memory/MemoryKey.java new file mode 100644 index 000000000..dd33800d9 --- /dev/null +++ b/api/src/main/java/org/bukkit/entity/memory/MemoryKey.java @@ -0,0 +1,76 @@ +package org.bukkit.entity.memory; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; +import org.bukkit.Keyed; +import org.bukkit.Location; +import org.bukkit.NamespacedKey; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * Represents a key used for accessing memory values of a + * {@link org.bukkit.entity.LivingEntity}. + * + * @param the class type of the memory value + */ +public final class MemoryKey implements Keyed { + + private final NamespacedKey namespacedKey; + private final Class tClass; + + private MemoryKey(NamespacedKey namespacedKey, Class tClass) { + this.namespacedKey = namespacedKey; + this.tClass = tClass; + MEMORY_KEYS.put(namespacedKey, this); + } + + @NotNull + @Override + public NamespacedKey getKey() { + return namespacedKey; + } + + /** + * Gets the class of values associated with this memory. + * + * @return the class of value objects + */ + @NotNull + public Class getMemoryClass() { + return tClass; + } + + private static final Map MEMORY_KEYS = new HashMap<>(); + // + public static final MemoryKey HOME = new MemoryKey<>(NamespacedKey.minecraft("home"), Location.class); + public static final MemoryKey MEETING_POINT = new MemoryKey<>(NamespacedKey.minecraft("meeting_point"), Location.class); + public static final MemoryKey JOB_SITE = new MemoryKey<>(NamespacedKey.minecraft("job_site"), Location.class); + public static final MemoryKey LAST_SLEPT = new MemoryKey<>(NamespacedKey.minecraft("last_slept"), Long.class); + public static final MemoryKey LAST_WORKED_AT_POI = new MemoryKey<>(NamespacedKey.minecraft("last_worked_at_poi"), Long.class); + + /** + * Returns a {@link MemoryKey} by a {@link NamespacedKey}. + * + * @param namespacedKey the {@link NamespacedKey} referencing a + * {@link MemoryKey} + * @return the {@link MemoryKey} or null when no {@link MemoryKey} is + * available under that key + */ + @Nullable + public static MemoryKey getByKey(@NotNull NamespacedKey namespacedKey) { + return MEMORY_KEYS.get(namespacedKey); + } + + /** + * Returns the set of all MemoryKeys. + * + * @return the memoryKeys + */ + @NotNull + public static Set values() { + return new HashSet<>(MEMORY_KEYS.values()); + } +} diff --git a/api/src/main/java/org/bukkit/entity/minecart/HopperMinecart.java b/api/src/main/java/org/bukkit/entity/minecart/HopperMinecart.java index 865885501..db69687a7 100644 --- a/api/src/main/java/org/bukkit/entity/minecart/HopperMinecart.java +++ b/api/src/main/java/org/bukkit/entity/minecart/HopperMinecart.java @@ -11,16 +11,16 @@ import org.bukkit.loot.Lootable; public interface HopperMinecart extends Minecart, InventoryHolder, LootableEntityInventory { /** - * Checks whether or not this Minecart will pick up + * Checks whether or not this Minecart will pick up * items into its inventory. - * + * * @return true if the Minecart will pick up items */ boolean isEnabled(); /** * Sets whether this Minecart will pick up items. - * + * * @param enabled new enabled state */ void setEnabled(boolean enabled); diff --git a/api/src/main/java/org/bukkit/event/EventHandler.java b/api/src/main/java/org/bukkit/event/EventHandler.java index 4c9fb3cde..cc06f480b 100644 --- a/api/src/main/java/org/bukkit/event/EventHandler.java +++ b/api/src/main/java/org/bukkit/event/EventHandler.java @@ -24,7 +24,7 @@ public @interface EventHandler { *

  • HIGHEST *
  • MONITOR * - * + * * @return the priority */ EventPriority priority() default EventPriority.NORMAL; @@ -34,7 +34,7 @@ public @interface EventHandler { *

    * If ignoreCancelled is true and the event is cancelled, the method is * not called. Otherwise, the method is always called. - * + * * @return whether cancelled events should be ignored */ boolean ignoreCancelled() default false; diff --git a/api/src/main/java/org/bukkit/event/HandlerList.java b/api/src/main/java/org/bukkit/event/HandlerList.java index d05c2159a..ed78cca71 100644 --- a/api/src/main/java/org/bukkit/event/HandlerList.java +++ b/api/src/main/java/org/bukkit/event/HandlerList.java @@ -1,10 +1,14 @@ package org.bukkit.event; +import java.util.ArrayList; +import java.util.Collection; +import java.util.EnumMap; +import java.util.List; +import java.util.ListIterator; +import java.util.Map.Entry; import org.bukkit.plugin.Plugin; import org.bukkit.plugin.RegisteredListener; - -import java.util.*; -import java.util.Map.Entry; +import org.jetbrains.annotations.NotNull; /** * A list of event handlers, stored per-event. Based on lahwran's fevents. @@ -15,8 +19,7 @@ public class HandlerList { * Handler array. This field being an array is the key to this system's * speed. */ - private RegisteredListener[] handlers = null; // Akarin - remove volatile - private boolean dirty = true; // Akarin + private volatile RegisteredListener[] handlers = null; /** * Dynamic handler lists. These are changed using register() and @@ -53,7 +56,7 @@ public class HandlerList { for (List list : h.handlerslots.values()) { list.clear(); } - h.dirty = true; // Akarin + h.handlers = null; } } } @@ -64,7 +67,7 @@ public class HandlerList { * * @param plugin plugin to unregister */ - public static void unregisterAll(Plugin plugin) { + public static void unregisterAll(@NotNull Plugin plugin) { synchronized (allLists) { for (HandlerList h : allLists) { h.unregister(plugin); @@ -77,7 +80,7 @@ public class HandlerList { * * @param listener listener to unregister */ - public static void unregisterAll(Listener listener) { + public static void unregisterAll(@NotNull Listener listener) { synchronized (allLists) { for (HandlerList h : allLists) { h.unregister(listener); @@ -105,10 +108,10 @@ public class HandlerList { * * @param listener listener to register */ - public synchronized void register(RegisteredListener listener) { + public synchronized void register(@NotNull RegisteredListener listener) { if (handlerslots.get(listener.getPriority()).contains(listener)) throw new IllegalStateException("This listener is already registered to priority " + listener.getPriority().toString()); - dirty = true; // Akarin + handlers = null; handlerslots.get(listener.getPriority()).add(listener); } @@ -117,7 +120,7 @@ public class HandlerList { * * @param listeners listeners to register */ - public void registerAll(Collection listeners) { + public void registerAll(@NotNull Collection listeners) { for (RegisteredListener listener : listeners) { register(listener); } @@ -128,9 +131,9 @@ public class HandlerList { * * @param listener listener to remove */ - public synchronized void unregister(RegisteredListener listener) { + public synchronized void unregister(@NotNull RegisteredListener listener) { if (handlerslots.get(listener.getPriority()).remove(listener)) { - dirty = true; // Akarin + handlers = null; } } @@ -139,7 +142,7 @@ public class HandlerList { * * @param plugin plugin to remove */ - public synchronized void unregister(Plugin plugin) { + public synchronized void unregister(@NotNull Plugin plugin) { boolean changed = false; for (List list : handlerslots.values()) { for (ListIterator i = list.listIterator(); i.hasNext();) { @@ -149,7 +152,7 @@ public class HandlerList { } } } - if (changed) dirty = true; // Akarin + if (changed) handlers = null; } /** @@ -157,7 +160,7 @@ public class HandlerList { * * @param listener listener to remove */ - public synchronized void unregister(Listener listener) { + public synchronized void unregister(@NotNull Listener listener) { boolean changed = false; for (List list : handlerslots.values()) { for (ListIterator i = list.listIterator(); i.hasNext();) { @@ -167,20 +170,19 @@ public class HandlerList { } } } - if (changed) dirty = true; // Akarin + if (changed) handlers = null; } /** * Bake HashMap and ArrayLists to 2d array - does nothing if not necessary */ - public synchronized RegisteredListener[] bake() { // Akarin - add return value - if (!dirty) return handlers; // don't re-bake when still valid // Akarin - dirty = false; // Akarin - mark dirty to prevent any rebaking + public synchronized void bake() { + if (handlers != null) return; // don't re-bake when still valid List entries = new ArrayList(); for (Entry> entry : handlerslots.entrySet()) { entries.addAll(entry.getValue()); } - return handlers = entries.toArray(new RegisteredListener[entries.size()]); + handlers = entries.toArray(new RegisteredListener[entries.size()]); } /** @@ -188,10 +190,11 @@ public class HandlerList { * * @return the array of registered listeners */ + @NotNull public RegisteredListener[] getRegisteredListeners() { - //RegisteredListener[] handlers; // Akarin - //while ((handlers = this.handlers) == null) bake(); // This prevents fringe cases of returning null // Akarin - return dirty ? bake() : handlers; + RegisteredListener[] handlers; + while ((handlers = this.handlers) == null) bake(); // This prevents fringe cases of returning null + return handlers; } /** @@ -201,7 +204,8 @@ public class HandlerList { * @param plugin the plugin to get the listeners of * @return the list of registered listeners */ - public static ArrayList getRegisteredListeners(Plugin plugin) { + @NotNull + public static ArrayList getRegisteredListeners(@NotNull Plugin plugin) { ArrayList listeners = new ArrayList(); synchronized (allLists) { for (HandlerList h : allLists) { @@ -225,6 +229,7 @@ public class HandlerList { * @return the list of all handler lists */ @SuppressWarnings("unchecked") + @NotNull public static ArrayList getHandlerLists() { synchronized (allLists) { return (ArrayList) allLists.clone(); diff --git a/api/src/main/java/org/bukkit/event/block/BlockBreakEvent.java b/api/src/main/java/org/bukkit/event/block/BlockBreakEvent.java index ef5048ef1..c05cd9cad 100644 --- a/api/src/main/java/org/bukkit/event/block/BlockBreakEvent.java +++ b/api/src/main/java/org/bukkit/event/block/BlockBreakEvent.java @@ -66,10 +66,12 @@ public class BlockBreakEvent extends BlockExpEvent implements Cancellable { return this.dropItems; } + @Override public boolean isCancelled() { return cancel; } + @Override public void setCancelled(boolean cancel) { this.cancel = cancel; } diff --git a/api/src/main/java/org/bukkit/event/block/BlockBurnEvent.java b/api/src/main/java/org/bukkit/event/block/BlockBurnEvent.java index 3fc9c5716..c0c38df36 100644 --- a/api/src/main/java/org/bukkit/event/block/BlockBurnEvent.java +++ b/api/src/main/java/org/bukkit/event/block/BlockBurnEvent.java @@ -38,10 +38,12 @@ public class BlockBurnEvent extends BlockEvent implements Cancellable { return ignitingBlock; } + @Override public boolean isCancelled() { return cancelled; } + @Override public void setCancelled(boolean cancel) { this.cancelled = cancel; } diff --git a/api/src/main/java/org/bukkit/event/block/BlockCanBuildEvent.java b/api/src/main/java/org/bukkit/event/block/BlockCanBuildEvent.java index 3c9903c04..977eb8d39 100644 --- a/api/src/main/java/org/bukkit/event/block/BlockCanBuildEvent.java +++ b/api/src/main/java/org/bukkit/event/block/BlockCanBuildEvent.java @@ -1,7 +1,7 @@ package org.bukkit.event.block; -import org.bukkit.block.Block; import org.bukkit.Material; +import org.bukkit.block.Block; import org.bukkit.block.data.BlockData; import org.bukkit.entity.Player; import org.bukkit.event.HandlerList; diff --git a/api/src/main/java/org/bukkit/event/block/BlockCookEvent.java b/api/src/main/java/org/bukkit/event/block/BlockCookEvent.java new file mode 100644 index 000000000..be7af5440 --- /dev/null +++ b/api/src/main/java/org/bukkit/event/block/BlockCookEvent.java @@ -0,0 +1,74 @@ +package org.bukkit.event.block; + +import org.bukkit.block.Block; +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; +import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; + +/** + * Called when an ItemStack is successfully cooked in a block. + */ +public class BlockCookEvent extends BlockEvent implements Cancellable { + private static final HandlerList handlers = new HandlerList(); + private final ItemStack source; + private ItemStack result; + private boolean cancelled; + + public BlockCookEvent(@NotNull final Block block, @NotNull final ItemStack source, @NotNull final ItemStack result) { + super(block); + this.source = source; + this.result = result; + this.cancelled = false; + } + + /** + * Gets the smelted ItemStack for this event + * + * @return smelting source ItemStack + */ + @NotNull + public ItemStack getSource() { + return source; + } + + /** + * Gets the resultant ItemStack for this event + * + * @return smelting result ItemStack + */ + @NotNull + public ItemStack getResult() { + return result; + } + + /** + * Sets the resultant ItemStack for this event + * + * @param result new result ItemStack + */ + public void setResult(@NotNull ItemStack result) { + this.result = result; + } + + @Override + public boolean isCancelled() { + return cancelled; + } + + @Override + public void setCancelled(boolean cancel) { + this.cancelled = cancel; + } + + @NotNull + @Override + public HandlerList getHandlers() { + return handlers; + } + + @NotNull + public static HandlerList getHandlerList() { + return handlers; + } +} diff --git a/api/src/main/java/org/bukkit/event/block/BlockDamageEvent.java b/api/src/main/java/org/bukkit/event/block/BlockDamageEvent.java index 9fbe23ab2..f70871e1a 100644 --- a/api/src/main/java/org/bukkit/event/block/BlockDamageEvent.java +++ b/api/src/main/java/org/bukkit/event/block/BlockDamageEvent.java @@ -67,10 +67,12 @@ public class BlockDamageEvent extends BlockEvent implements Cancellable { return itemstack; } + @Override public boolean isCancelled() { return cancel; } + @Override public void setCancelled(boolean cancel) { this.cancel = cancel; } diff --git a/api/src/main/java/org/bukkit/event/block/BlockDispenseEvent.java b/api/src/main/java/org/bukkit/event/block/BlockDispenseEvent.java index 23c428d2d..6e8be28f6 100644 --- a/api/src/main/java/org/bukkit/event/block/BlockDispenseEvent.java +++ b/api/src/main/java/org/bukkit/event/block/BlockDispenseEvent.java @@ -68,10 +68,12 @@ public class BlockDispenseEvent extends BlockEvent implements Cancellable { velocity = vel; } + @Override public boolean isCancelled() { return cancelled; } + @Override public void setCancelled(boolean cancel) { cancelled = cancel; } diff --git a/api/src/main/java/org/bukkit/event/block/BlockDropItemEvent.java b/api/src/main/java/org/bukkit/event/block/BlockDropItemEvent.java index 6328e66bd..129b412ee 100644 --- a/api/src/main/java/org/bukkit/event/block/BlockDropItemEvent.java +++ b/api/src/main/java/org/bukkit/event/block/BlockDropItemEvent.java @@ -78,15 +78,6 @@ public class BlockDropItemEvent extends BlockEvent implements Cancellable { return items; } - /** - * @deprecated very temporary compatibility measure - */ - @Deprecated - @NotNull - public Item getItem() { - return items.get(0); - } - @Override public boolean isCancelled() { return cancel; diff --git a/api/src/main/java/org/bukkit/event/block/BlockEvent.java b/api/src/main/java/org/bukkit/event/block/BlockEvent.java index 2a496f7a8..62a4d1345 100644 --- a/api/src/main/java/org/bukkit/event/block/BlockEvent.java +++ b/api/src/main/java/org/bukkit/event/block/BlockEvent.java @@ -1,18 +1,14 @@ package org.bukkit.event.block; -import org.bukkit.World; import org.bukkit.block.Block; import org.bukkit.event.Event; import org.jetbrains.annotations.NotNull; -import io.akarin.server.api.event.WorldAttachedEvent; - /** * Represents a block related event. */ -public abstract class BlockEvent extends Event implements WorldAttachedEvent { +public abstract class BlockEvent extends Event { protected Block block; - @Override @NotNull public World getWorld() { return block.getWorld(); } // Akarin public BlockEvent(@NotNull final Block theBlock) { block = theBlock; diff --git a/api/src/main/java/org/bukkit/event/block/BlockExpEvent.java b/api/src/main/java/org/bukkit/event/block/BlockExpEvent.java index c5d9bf3c2..21b902655 100644 --- a/api/src/main/java/org/bukkit/event/block/BlockExpEvent.java +++ b/api/src/main/java/org/bukkit/event/block/BlockExpEvent.java @@ -36,6 +36,7 @@ public class BlockExpEvent extends BlockEvent { this.exp = exp; } + @Override @NotNull public HandlerList getHandlers() { return handlers; diff --git a/api/src/main/java/org/bukkit/event/block/BlockExplodeEvent.java b/api/src/main/java/org/bukkit/event/block/BlockExplodeEvent.java index 635d4bc0e..44f7f6939 100644 --- a/api/src/main/java/org/bukkit/event/block/BlockExplodeEvent.java +++ b/api/src/main/java/org/bukkit/event/block/BlockExplodeEvent.java @@ -1,12 +1,11 @@ package org.bukkit.event.block; +import java.util.List; import org.bukkit.block.Block; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; import org.jetbrains.annotations.NotNull; -import java.util.List; - /** * Called when a block explodes */ @@ -23,10 +22,12 @@ public class BlockExplodeEvent extends BlockEvent implements Cancellable { this.cancel = false; } + @Override public boolean isCancelled() { return cancel; } + @Override public void setCancelled(boolean cancel) { this.cancel = cancel; } diff --git a/api/src/main/java/org/bukkit/event/block/BlockFadeEvent.java b/api/src/main/java/org/bukkit/event/block/BlockFadeEvent.java index 844dc823f..362643de4 100644 --- a/api/src/main/java/org/bukkit/event/block/BlockFadeEvent.java +++ b/api/src/main/java/org/bukkit/event/block/BlockFadeEvent.java @@ -44,10 +44,12 @@ public class BlockFadeEvent extends BlockEvent implements Cancellable { return newState; } + @Override public boolean isCancelled() { return cancelled; } + @Override public void setCancelled(boolean cancel) { this.cancelled = cancel; } diff --git a/api/src/main/java/org/bukkit/event/block/BlockFertilizeEvent.java b/api/src/main/java/org/bukkit/event/block/BlockFertilizeEvent.java index 1d12e68cc..695309b4b 100644 --- a/api/src/main/java/org/bukkit/event/block/BlockFertilizeEvent.java +++ b/api/src/main/java/org/bukkit/event/block/BlockFertilizeEvent.java @@ -1,7 +1,6 @@ package org.bukkit.event.block; import java.util.List; - import org.bukkit.block.Block; import org.bukkit.block.BlockState; import org.bukkit.entity.Player; diff --git a/api/src/main/java/org/bukkit/event/block/BlockFromToEvent.java b/api/src/main/java/org/bukkit/event/block/BlockFromToEvent.java index 2fb4a214a..1af392805 100644 --- a/api/src/main/java/org/bukkit/event/block/BlockFromToEvent.java +++ b/api/src/main/java/org/bukkit/event/block/BlockFromToEvent.java @@ -55,10 +55,12 @@ public class BlockFromToEvent extends BlockEvent implements Cancellable { return to; } + @Override public boolean isCancelled() { return cancel; } + @Override public void setCancelled(boolean cancel) { this.cancel = cancel; } diff --git a/api/src/main/java/org/bukkit/event/block/BlockGrowEvent.java b/api/src/main/java/org/bukkit/event/block/BlockGrowEvent.java index d3679795a..73d5375d2 100644 --- a/api/src/main/java/org/bukkit/event/block/BlockGrowEvent.java +++ b/api/src/main/java/org/bukkit/event/block/BlockGrowEvent.java @@ -41,14 +41,17 @@ public class BlockGrowEvent extends BlockEvent implements Cancellable { return newState; } + @Override public boolean isCancelled() { return cancelled; } + @Override public void setCancelled(boolean cancel) { this.cancelled = cancel; } + @Override @NotNull public HandlerList getHandlers() { return handlers; diff --git a/api/src/main/java/org/bukkit/event/block/BlockIgniteEvent.java b/api/src/main/java/org/bukkit/event/block/BlockIgniteEvent.java index 5dc2bc1f5..1593c3716 100644 --- a/api/src/main/java/org/bukkit/event/block/BlockIgniteEvent.java +++ b/api/src/main/java/org/bukkit/event/block/BlockIgniteEvent.java @@ -37,10 +37,12 @@ public class BlockIgniteEvent extends BlockEvent implements Cancellable { this.cancel = false; } + @Override public boolean isCancelled() { return cancel; } + @Override public void setCancelled(boolean cancel) { this.cancel = cancel; } @@ -122,6 +124,10 @@ public class BlockIgniteEvent extends BlockEvent implements Cancellable { * Block ignition caused by explosion. */ EXPLOSION, + /** + * Block ignition caused by a flaming arrow. + */ + ARROW, } @NotNull diff --git a/api/src/main/java/org/bukkit/event/block/BlockMultiPlaceEvent.java b/api/src/main/java/org/bukkit/event/block/BlockMultiPlaceEvent.java index e4f7ca66d..fe2ec79dd 100644 --- a/api/src/main/java/org/bukkit/event/block/BlockMultiPlaceEvent.java +++ b/api/src/main/java/org/bukkit/event/block/BlockMultiPlaceEvent.java @@ -1,14 +1,13 @@ package org.bukkit.event.block; import com.google.common.collect.ImmutableList; +import java.util.List; import org.bukkit.block.Block; import org.bukkit.block.BlockState; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; -import java.util.List; - /** * Fired when a single block placement action of a player triggers the * creation of multiple blocks(e.g. placing a bed block). The block returned diff --git a/api/src/main/java/org/bukkit/event/block/BlockPhysicsEvent.java b/api/src/main/java/org/bukkit/event/block/BlockPhysicsEvent.java index a28731dc2..c382f9fc2 100644 --- a/api/src/main/java/org/bukkit/event/block/BlockPhysicsEvent.java +++ b/api/src/main/java/org/bukkit/event/block/BlockPhysicsEvent.java @@ -1,7 +1,7 @@ package org.bukkit.event.block; -import org.bukkit.block.Block; import org.bukkit.Material; +import org.bukkit.block.Block; import org.bukkit.block.data.BlockData; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; @@ -51,7 +51,7 @@ public class BlockPhysicsEvent extends BlockEvent implements Cancellable { /** * Gets the source block that triggered this event. - * + * * Note: This will default to block if not set. * * @return The source block @@ -71,10 +71,12 @@ public class BlockPhysicsEvent extends BlockEvent implements Cancellable { return changed.getMaterial(); } + @Override public boolean isCancelled() { return cancel; } + @Override public void setCancelled(boolean cancel) { this.cancel = cancel; } diff --git a/api/src/main/java/org/bukkit/event/block/BlockPistonEvent.java b/api/src/main/java/org/bukkit/event/block/BlockPistonEvent.java index 47191c8f2..2cdf2919e 100644 --- a/api/src/main/java/org/bukkit/event/block/BlockPistonEvent.java +++ b/api/src/main/java/org/bukkit/event/block/BlockPistonEvent.java @@ -18,10 +18,12 @@ public abstract class BlockPistonEvent extends BlockEvent implements Cancellable this.direction = direction; } + @Override public boolean isCancelled() { return this.cancelled; } + @Override public void setCancelled(boolean cancelled) { this.cancelled = cancelled; } diff --git a/api/src/main/java/org/bukkit/event/block/BlockPistonExtendEvent.java b/api/src/main/java/org/bukkit/event/block/BlockPistonExtendEvent.java index 51bca6515..40ddc3649 100644 --- a/api/src/main/java/org/bukkit/event/block/BlockPistonExtendEvent.java +++ b/api/src/main/java/org/bukkit/event/block/BlockPistonExtendEvent.java @@ -3,7 +3,6 @@ package org.bukkit.event.block; import java.util.ArrayList; import java.util.Collections; import java.util.List; - import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.event.HandlerList; diff --git a/api/src/main/java/org/bukkit/event/block/BlockPistonRetractEvent.java b/api/src/main/java/org/bukkit/event/block/BlockPistonRetractEvent.java index 4744e0fa5..340fa397e 100644 --- a/api/src/main/java/org/bukkit/event/block/BlockPistonRetractEvent.java +++ b/api/src/main/java/org/bukkit/event/block/BlockPistonRetractEvent.java @@ -13,10 +13,10 @@ import org.jetbrains.annotations.NotNull; public class BlockPistonRetractEvent extends BlockPistonEvent { private static final HandlerList handlers = new HandlerList(); private List blocks; - + public BlockPistonRetractEvent(@NotNull final Block block, @NotNull final List blocks, @NotNull final BlockFace direction) { super(block, direction); - + this.blocks = blocks; } @@ -31,7 +31,7 @@ public class BlockPistonRetractEvent extends BlockPistonEvent { public Location getRetractLocation() { return getBlock().getRelative(getDirection(), 2).getLocation(); } - + /** * Get an immutable list of the blocks which will be moved by the * extending. diff --git a/api/src/main/java/org/bukkit/event/block/BlockPlaceEvent.java b/api/src/main/java/org/bukkit/event/block/BlockPlaceEvent.java index 586e3c8ed..be0a2d1f2 100644 --- a/api/src/main/java/org/bukkit/event/block/BlockPlaceEvent.java +++ b/api/src/main/java/org/bukkit/event/block/BlockPlaceEvent.java @@ -40,10 +40,12 @@ public class BlockPlaceEvent extends BlockEvent implements Cancellable { cancel = false; } + @Override public boolean isCancelled() { return cancel; } + @Override public void setCancelled(boolean cancel) { this.cancel = cancel; } diff --git a/api/src/main/java/org/bukkit/event/block/BlockShearEntityEvent.java b/api/src/main/java/org/bukkit/event/block/BlockShearEntityEvent.java new file mode 100644 index 000000000..71c0af937 --- /dev/null +++ b/api/src/main/java/org/bukkit/event/block/BlockShearEntityEvent.java @@ -0,0 +1,67 @@ +package org.bukkit.event.block; + +import org.bukkit.block.Block; +import org.bukkit.entity.Entity; +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; +import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; + +/** + * Event fired when a dispenser shears a nearby sheep. + */ +public class BlockShearEntityEvent extends BlockEvent implements Cancellable { + + private static final HandlerList handlers = new HandlerList(); + // + private final Entity sheared; + private final ItemStack tool; + private boolean cancelled; + + public BlockShearEntityEvent(@NotNull Block dispenser, @NotNull Entity sheared, @NotNull ItemStack tool) { + super(dispenser); + this.sheared = sheared; + this.tool = tool; + } + + /** + * Gets the entity that was sheared. + * + * @return the entity that was sheared. + */ + @NotNull + public Entity getEntity() { + return sheared; + } + + /** + * Gets the item used to shear this sheep. + * + * @return the item used to shear this sheep. + */ + @NotNull + public ItemStack getTool() { + return tool.clone(); + } + + @Override + public boolean isCancelled() { + return cancelled; + } + + @Override + public void setCancelled(boolean cancelled) { + this.cancelled = cancelled; + } + + @NotNull + @Override + public HandlerList getHandlers() { + return handlers; + } + + @NotNull + public static HandlerList getHandlerList() { + return handlers; + } +} diff --git a/api/src/main/java/org/bukkit/event/block/EntityBlockFormEvent.java b/api/src/main/java/org/bukkit/event/block/EntityBlockFormEvent.java index 741aead8b..3baed1c43 100644 --- a/api/src/main/java/org/bukkit/event/block/EntityBlockFormEvent.java +++ b/api/src/main/java/org/bukkit/event/block/EntityBlockFormEvent.java @@ -32,4 +32,4 @@ public class EntityBlockFormEvent extends BlockFormEvent { public Entity getEntity() { return entity; } -} \ No newline at end of file +} diff --git a/api/src/main/java/org/bukkit/event/block/LeavesDecayEvent.java b/api/src/main/java/org/bukkit/event/block/LeavesDecayEvent.java index 538e4246c..c33f9cb80 100644 --- a/api/src/main/java/org/bukkit/event/block/LeavesDecayEvent.java +++ b/api/src/main/java/org/bukkit/event/block/LeavesDecayEvent.java @@ -18,10 +18,12 @@ public class LeavesDecayEvent extends BlockEvent implements Cancellable { super(block); } + @Override public boolean isCancelled() { return cancel; } + @Override public void setCancelled(boolean cancel) { this.cancel = cancel; } diff --git a/api/src/main/java/org/bukkit/event/block/NotePlayEvent.java b/api/src/main/java/org/bukkit/event/block/NotePlayEvent.java index ad8b89e2b..a3887067d 100644 --- a/api/src/main/java/org/bukkit/event/block/NotePlayEvent.java +++ b/api/src/main/java/org/bukkit/event/block/NotePlayEvent.java @@ -24,10 +24,12 @@ public class NotePlayEvent extends BlockEvent implements Cancellable { this.note = note; } + @Override public boolean isCancelled() { return cancelled; } + @Override public void setCancelled(boolean cancel) { this.cancelled = cancel; } diff --git a/api/src/main/java/org/bukkit/event/block/SignChangeEvent.java b/api/src/main/java/org/bukkit/event/block/SignChangeEvent.java index 8b78d4de5..7190db11e 100644 --- a/api/src/main/java/org/bukkit/event/block/SignChangeEvent.java +++ b/api/src/main/java/org/bukkit/event/block/SignChangeEvent.java @@ -70,10 +70,12 @@ public class SignChangeEvent extends BlockEvent implements Cancellable { lines[index] = line; } + @Override public boolean isCancelled() { return cancel; } + @Override public void setCancelled(boolean cancel) { this.cancel = cancel; } diff --git a/api/src/main/java/org/bukkit/event/block/SpongeAbsorbEvent.java b/api/src/main/java/org/bukkit/event/block/SpongeAbsorbEvent.java index ab98bba61..7029cfcd0 100644 --- a/api/src/main/java/org/bukkit/event/block/SpongeAbsorbEvent.java +++ b/api/src/main/java/org/bukkit/event/block/SpongeAbsorbEvent.java @@ -1,11 +1,11 @@ package org.bukkit.event.block; +import java.util.List; +import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.BlockState; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; -import java.util.List; -import org.bukkit.Material; import org.jetbrains.annotations.NotNull; /** diff --git a/api/src/main/java/org/bukkit/event/enchantment/EnchantItemEvent.java b/api/src/main/java/org/bukkit/event/enchantment/EnchantItemEvent.java index ac1b1cb9a..69b74647e 100644 --- a/api/src/main/java/org/bukkit/event/enchantment/EnchantItemEvent.java +++ b/api/src/main/java/org/bukkit/event/enchantment/EnchantItemEvent.java @@ -2,7 +2,7 @@ package org.bukkit.event.enchantment; import java.util.HashMap; import java.util.Map; - +import org.apache.commons.lang.Validate; import org.bukkit.block.Block; import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Player; @@ -25,7 +25,7 @@ public class EnchantItemEvent extends InventoryEvent implements Cancellable { private boolean cancelled; private final Map enchants; private final Player enchanter; - private int button; + private final int button; public EnchantItemEvent(@NotNull final Player enchanter, @NotNull final InventoryView view, @NotNull final Block table, @NotNull final ItemStack item, final int level, @NotNull final Map enchants, final int i) { super(view); @@ -69,7 +69,8 @@ public class EnchantItemEvent extends InventoryEvent implements Cancellable { } /** - * Get cost in exp levels of the enchantment + * Gets the cost (minimum level) which is displayed as a number on the right + * hand side of the enchantment offer. * * @return experience level cost */ @@ -78,11 +79,14 @@ public class EnchantItemEvent extends InventoryEvent implements Cancellable { } /** - * Set cost in exp levels of the enchantment + * Sets the cost (minimum level) which is displayed as a number on the right + * hand side of the enchantment offer. * * @param level - cost in levels */ public void setExpLevelCost(int level) { + Validate.isTrue(level > 0, "The cost must be greater than 0!"); + this.level = level; } @@ -107,10 +111,12 @@ public class EnchantItemEvent extends InventoryEvent implements Cancellable { return button; } + @Override public boolean isCancelled() { return cancelled; } + @Override public void setCancelled(boolean cancel) { this.cancelled = cancel; } diff --git a/api/src/main/java/org/bukkit/event/entity/AreaEffectCloudApplyEvent.java b/api/src/main/java/org/bukkit/event/entity/AreaEffectCloudApplyEvent.java index 618db8ed3..a37febd0d 100644 --- a/api/src/main/java/org/bukkit/event/entity/AreaEffectCloudApplyEvent.java +++ b/api/src/main/java/org/bukkit/event/entity/AreaEffectCloudApplyEvent.java @@ -1,7 +1,6 @@ package org.bukkit.event.entity; import java.util.List; - import org.bukkit.entity.AreaEffectCloud; import org.bukkit.entity.LivingEntity; import org.bukkit.event.Cancellable; diff --git a/api/src/main/java/org/bukkit/event/entity/CreatureSpawnEvent.java b/api/src/main/java/org/bukkit/event/entity/CreatureSpawnEvent.java index 3c48c2a3d..f7049face 100644 --- a/api/src/main/java/org/bukkit/event/entity/CreatureSpawnEvent.java +++ b/api/src/main/java/org/bukkit/event/entity/CreatureSpawnEvent.java @@ -1,6 +1,8 @@ package org.bukkit.event.entity; +import org.bukkit.Chunk; import org.bukkit.entity.LivingEntity; +import org.bukkit.event.world.ChunkLoadEvent; import org.jetbrains.annotations.NotNull; /** @@ -49,7 +51,13 @@ public class CreatureSpawnEvent extends EntitySpawnEvent { JOCKEY, /** * When a creature spawns due to chunk generation + * + * @deprecated no longer called, chunks are generated with entities + * already existing. Consider using {@link ChunkLoadEvent}, + * {@link ChunkLoadEvent#isNewChunk()} and {@link Chunk#getEntities()} + * for similar effect. */ + @Deprecated CHUNK_GEN, /** * When a creature spawns from a spawner @@ -149,6 +157,18 @@ public class CreatureSpawnEvent extends EntitySpawnEvent { * When an cow is spawned by shearing a mushroom cow */ SHEARED, + /** + * When eg an effect cloud is spawned as a result of a creeper exploding + */ + EXPLOSION, + /** + * When an entity is spawned as part of a raid + */ + RAID, + /** + * When an entity is spawned as part of a patrol + */ + PATROL, /** * When a creature is spawned by plugins */ diff --git a/api/src/main/java/org/bukkit/event/entity/CreeperPowerEvent.java b/api/src/main/java/org/bukkit/event/entity/CreeperPowerEvent.java index 5828a52b1..4295baf51 100644 --- a/api/src/main/java/org/bukkit/event/entity/CreeperPowerEvent.java +++ b/api/src/main/java/org/bukkit/event/entity/CreeperPowerEvent.java @@ -28,10 +28,12 @@ public class CreeperPowerEvent extends EntityEvent implements Cancellable { this.cause = cause; } + @Override public boolean isCancelled() { return canceled; } + @Override public void setCancelled(boolean cancel) { canceled = cancel; } diff --git a/api/src/main/java/org/bukkit/event/entity/EnderDragonChangePhaseEvent.java b/api/src/main/java/org/bukkit/event/entity/EnderDragonChangePhaseEvent.java index 1b654fa99..631ca54dc 100644 --- a/api/src/main/java/org/bukkit/event/entity/EnderDragonChangePhaseEvent.java +++ b/api/src/main/java/org/bukkit/event/entity/EnderDragonChangePhaseEvent.java @@ -30,9 +30,9 @@ public class EnderDragonChangePhaseEvent extends EntityEvent implements Cancella } /** - * Gets the current phase that the dragon is in. This method will return null + * Gets the current phase that the dragon is in. This method will return null * when a dragon is first spawned and hasn't yet been assigned a phase. - * + * * @return the current dragon phase */ @Nullable @@ -42,7 +42,7 @@ public class EnderDragonChangePhaseEvent extends EntityEvent implements Cancella /** * Gets the new phase that the dragon will switch to. - * + * * @return the new dragon phase */ @NotNull @@ -52,7 +52,7 @@ public class EnderDragonChangePhaseEvent extends EntityEvent implements Cancella /** * Sets the new phase for the ender dragon. - * + * * @param newPhase the new dragon phase */ public void setNewPhase(@NotNull EnderDragon.Phase newPhase) { diff --git a/api/src/main/java/org/bukkit/event/entity/EntityChangeBlockEvent.java b/api/src/main/java/org/bukkit/event/entity/EntityChangeBlockEvent.java index 62fba99a0..e79fc76bb 100644 --- a/api/src/main/java/org/bukkit/event/entity/EntityChangeBlockEvent.java +++ b/api/src/main/java/org/bukkit/event/entity/EntityChangeBlockEvent.java @@ -34,10 +34,12 @@ public class EntityChangeBlockEvent extends EntityEvent implements Cancellable { return block; } + @Override public boolean isCancelled() { return cancel; } + @Override public void setCancelled(boolean cancel) { this.cancel = cancel; } diff --git a/api/src/main/java/org/bukkit/event/entity/EntityCombustEvent.java b/api/src/main/java/org/bukkit/event/entity/EntityCombustEvent.java index 4b4c7bb52..eea9aa7bf 100644 --- a/api/src/main/java/org/bukkit/event/entity/EntityCombustEvent.java +++ b/api/src/main/java/org/bukkit/event/entity/EntityCombustEvent.java @@ -21,10 +21,12 @@ public class EntityCombustEvent extends EntityEvent implements Cancellable { this.cancel = false; } + @Override public boolean isCancelled() { return cancel; } + @Override public void setCancelled(boolean cancel) { this.cancel = cancel; } diff --git a/api/src/main/java/org/bukkit/event/entity/EntityCreatePortalEvent.java b/api/src/main/java/org/bukkit/event/entity/EntityCreatePortalEvent.java index 4de098341..397baaefd 100644 --- a/api/src/main/java/org/bukkit/event/entity/EntityCreatePortalEvent.java +++ b/api/src/main/java/org/bukkit/event/entity/EntityCreatePortalEvent.java @@ -6,11 +6,15 @@ import org.bukkit.block.BlockState; import org.bukkit.entity.LivingEntity; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.bukkit.event.world.PortalCreateEvent; import org.jetbrains.annotations.NotNull; /** * Thrown when a Living Entity creates a portal in a world. + * + * @deprecated Use {@link PortalCreateEvent} */ +@Deprecated public class EntityCreatePortalEvent extends EntityEvent implements Cancellable { private static final HandlerList handlers = new HandlerList(); private final List blocks; @@ -40,10 +44,12 @@ public class EntityCreatePortalEvent extends EntityEvent implements Cancellable return blocks; } + @Override public boolean isCancelled() { return cancelled; } + @Override public void setCancelled(boolean cancel) { this.cancelled = cancel; } diff --git a/api/src/main/java/org/bukkit/event/entity/EntityDamageByBlockEvent.java b/api/src/main/java/org/bukkit/event/entity/EntityDamageByBlockEvent.java index 4c519eba8..461727dc7 100644 --- a/api/src/main/java/org/bukkit/event/entity/EntityDamageByBlockEvent.java +++ b/api/src/main/java/org/bukkit/event/entity/EntityDamageByBlockEvent.java @@ -1,8 +1,7 @@ package org.bukkit.event.entity; -import java.util.Map; - import com.google.common.base.Function; +import java.util.Map; import org.bukkit.block.Block; import org.bukkit.entity.Entity; import org.jetbrains.annotations.NotNull; diff --git a/api/src/main/java/org/bukkit/event/entity/EntityDamageByEntityEvent.java b/api/src/main/java/org/bukkit/event/entity/EntityDamageByEntityEvent.java index b6e866962..869bad740 100644 --- a/api/src/main/java/org/bukkit/event/entity/EntityDamageByEntityEvent.java +++ b/api/src/main/java/org/bukkit/event/entity/EntityDamageByEntityEvent.java @@ -1,8 +1,7 @@ package org.bukkit.event.entity; -import java.util.Map; - import com.google.common.base.Function; +import java.util.Map; import org.bukkit.entity.Entity; import org.jetbrains.annotations.NotNull; diff --git a/api/src/main/java/org/bukkit/event/entity/EntityDamageEvent.java b/api/src/main/java/org/bukkit/event/entity/EntityDamageEvent.java index 477ecfbc8..4d1b4d1f8 100644 --- a/api/src/main/java/org/bukkit/event/entity/EntityDamageEvent.java +++ b/api/src/main/java/org/bukkit/event/entity/EntityDamageEvent.java @@ -1,18 +1,16 @@ package org.bukkit.event.entity; +import com.google.common.base.Function; +import com.google.common.base.Functions; +import com.google.common.collect.ImmutableMap; import java.util.EnumMap; import java.util.Map; - import org.apache.commons.lang.Validate; import org.bukkit.Material; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; - -import com.google.common.base.Function; -import com.google.common.base.Functions; -import com.google.common.collect.ImmutableMap; import org.jetbrains.annotations.NotNull; /** @@ -45,10 +43,12 @@ public class EntityDamageEvent extends EntityEvent implements Cancellable { this.modifierFunctions = modifierFunctions; } + @Override public boolean isCancelled() { return cancelled; } + @Override public void setCancelled(boolean cancel) { cancelled = cancel; } diff --git a/api/src/main/java/org/bukkit/event/entity/EntityEvent.java b/api/src/main/java/org/bukkit/event/entity/EntityEvent.java index 3d7bb2b0e..e3a9e3293 100644 --- a/api/src/main/java/org/bukkit/event/entity/EntityEvent.java +++ b/api/src/main/java/org/bukkit/event/entity/EntityEvent.java @@ -1,19 +1,15 @@ package org.bukkit.event.entity; -import org.bukkit.World; import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; import org.bukkit.event.Event; import org.jetbrains.annotations.NotNull; -import io.akarin.server.api.event.WorldAttachedEvent; - /** * Represents an Entity-related event */ -public abstract class EntityEvent extends Event implements WorldAttachedEvent { // Akarin +public abstract class EntityEvent extends Event { protected Entity entity; - @Override @NotNull public World getWorld() { return entity.getWorld(); } // Akarin public EntityEvent(@NotNull final Entity what) { entity = what; diff --git a/api/src/main/java/org/bukkit/event/entity/EntityExplodeEvent.java b/api/src/main/java/org/bukkit/event/entity/EntityExplodeEvent.java index 21eb09293..10d0e18df 100644 --- a/api/src/main/java/org/bukkit/event/entity/EntityExplodeEvent.java +++ b/api/src/main/java/org/bukkit/event/entity/EntityExplodeEvent.java @@ -1,14 +1,12 @@ package org.bukkit.event.entity; +import java.util.List; import org.bukkit.Location; import org.bukkit.block.Block; import org.bukkit.entity.Entity; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.util.List; /** * Called when an entity explodes @@ -28,10 +26,12 @@ public class EntityExplodeEvent extends EntityEvent implements Cancellable { this.cancel = false; } + @Override public boolean isCancelled() { return cancel; } + @Override public void setCancelled(boolean cancel) { this.cancel = cancel; } diff --git a/api/src/main/java/org/bukkit/event/entity/EntityInteractEvent.java b/api/src/main/java/org/bukkit/event/entity/EntityInteractEvent.java index 97ef2481d..e2c0cb339 100644 --- a/api/src/main/java/org/bukkit/event/entity/EntityInteractEvent.java +++ b/api/src/main/java/org/bukkit/event/entity/EntityInteractEvent.java @@ -19,10 +19,12 @@ public class EntityInteractEvent extends EntityEvent implements Cancellable { this.block = block; } + @Override public boolean isCancelled() { return cancelled; } + @Override public void setCancelled(boolean cancel) { cancelled = cancel; } diff --git a/api/src/main/java/org/bukkit/event/entity/EntityPickupItemEvent.java b/api/src/main/java/org/bukkit/event/entity/EntityPickupItemEvent.java index b583accbb..c866df03d 100644 --- a/api/src/main/java/org/bukkit/event/entity/EntityPickupItemEvent.java +++ b/api/src/main/java/org/bukkit/event/entity/EntityPickupItemEvent.java @@ -46,10 +46,12 @@ public class EntityPickupItemEvent extends EntityEvent implements Cancellable { return remaining; } + @Override public boolean isCancelled() { return cancel; } + @Override public void setCancelled(boolean cancel) { this.cancel = cancel; } diff --git a/api/src/main/java/org/bukkit/event/entity/EntityPortalEnterEvent.java b/api/src/main/java/org/bukkit/event/entity/EntityPortalEnterEvent.java index e949072ba..6818e9f0b 100644 --- a/api/src/main/java/org/bukkit/event/entity/EntityPortalEnterEvent.java +++ b/api/src/main/java/org/bukkit/event/entity/EntityPortalEnterEvent.java @@ -1,7 +1,7 @@ package org.bukkit.event.entity; -import org.bukkit.entity.Entity; import org.bukkit.Location; +import org.bukkit.entity.Entity; import org.bukkit.event.HandlerList; import org.jetbrains.annotations.NotNull; diff --git a/api/src/main/java/org/bukkit/event/entity/EntityPortalEvent.java b/api/src/main/java/org/bukkit/event/entity/EntityPortalEvent.java index ec759948f..7fdfe3c5a 100644 --- a/api/src/main/java/org/bukkit/event/entity/EntityPortalEvent.java +++ b/api/src/main/java/org/bukkit/event/entity/EntityPortalEvent.java @@ -1,7 +1,6 @@ package org.bukkit.event.entity; import org.bukkit.Location; -import org.bukkit.TravelAgent; import org.bukkit.entity.Entity; import org.bukkit.event.HandlerList; import org.jetbrains.annotations.NotNull; @@ -15,63 +14,9 @@ import org.jetbrains.annotations.Nullable; */ public class EntityPortalEvent extends EntityTeleportEvent { private static final HandlerList handlers = new HandlerList(); - protected boolean useTravelAgent = true; - protected TravelAgent travelAgent; - public EntityPortalEvent(@NotNull final Entity entity, @NotNull final Location from, @Nullable final Location to, @NotNull final TravelAgent pta) { + public EntityPortalEvent(@NotNull final Entity entity, @NotNull final Location from, @Nullable final Location to) { super(entity, from, to); - this.travelAgent = pta; - } - - /** - * Sets whether or not the Travel Agent will be used. - *

    - * If this is set to true, the TravelAgent will try to find a Portal at - * the {@link #getTo()} Location, and will try to create one if there is - * none. - *

    - * If this is set to false, the {@link #getEntity()} will only be - * teleported to the {@link #getTo()} Location. - * - * @param useTravelAgent whether to use the Travel Agent - */ - public void useTravelAgent(boolean useTravelAgent) { - this.useTravelAgent = useTravelAgent; - } - - /** - * Gets whether or not the Travel Agent will be used. - *

    - * If this is set to true, the TravelAgent will try to find a Portal at - * the {@link #getTo()} Location, and will try to create one if there is - * none. - *

    - * If this is set to false, the {@link #getEntity()} will only be - * teleported to the {@link #getTo()} Location. - * - * @return whether to use the Travel Agent - */ - public boolean useTravelAgent() { - return useTravelAgent; - } - - /** - * Gets the Travel Agent used (or not) in this event. - * - * @return the Travel Agent used (or not) in this event - */ - @NotNull - public TravelAgent getPortalTravelAgent() { - return this.travelAgent; - } - - /** - * Sets the Travel Agent used (or not) in this event. - * - * @param travelAgent the Travel Agent used (or not) in this event - */ - public void setPortalTravelAgent(@NotNull TravelAgent travelAgent) { - this.travelAgent = travelAgent; } @NotNull @@ -84,4 +29,4 @@ public class EntityPortalEvent extends EntityTeleportEvent { public static HandlerList getHandlerList() { return handlers; } -} \ No newline at end of file +} diff --git a/api/src/main/java/org/bukkit/event/entity/EntityPortalExitEvent.java b/api/src/main/java/org/bukkit/event/entity/EntityPortalExitEvent.java index f124d43f0..869ad3b12 100644 --- a/api/src/main/java/org/bukkit/event/entity/EntityPortalExitEvent.java +++ b/api/src/main/java/org/bukkit/event/entity/EntityPortalExitEvent.java @@ -47,7 +47,7 @@ public class EntityPortalExitEvent extends EntityTeleportEvent { /** * Sets the velocity that the entity will have after exiting the portal. - * + * * @param after the velocity after exiting the portal */ public void setAfter(@NotNull Vector after) { @@ -64,4 +64,4 @@ public class EntityPortalExitEvent extends EntityTeleportEvent { public static HandlerList getHandlerList() { return handlers; } -} \ No newline at end of file +} diff --git a/api/src/main/java/org/bukkit/event/entity/EntityPoseChangeEvent.java b/api/src/main/java/org/bukkit/event/entity/EntityPoseChangeEvent.java new file mode 100644 index 000000000..6fb2b02ac --- /dev/null +++ b/api/src/main/java/org/bukkit/event/entity/EntityPoseChangeEvent.java @@ -0,0 +1,44 @@ +package org.bukkit.event.entity; + +import org.bukkit.entity.Entity; +import org.bukkit.entity.Pose; +import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; + +/** + * Called when an entity changes its pose. + * + * @see Entity#getPose() + */ +public class EntityPoseChangeEvent extends EntityEvent { + + private static final HandlerList handlers = new HandlerList(); + // + private final Pose pose; + + public EntityPoseChangeEvent(@NotNull Entity who, @NotNull Pose pose) { + super(who); + this.pose = pose; + } + + /** + * Gets the entity's new pose. + * + * @return the new pose + */ + @NotNull + public Pose getPose() { + return pose; + } + + @NotNull + @Override + public HandlerList getHandlers() { + return handlers; + } + + @NotNull + public static HandlerList getHandlerList() { + return handlers; + } +} diff --git a/api/src/main/java/org/bukkit/event/entity/EntityShootBowEvent.java b/api/src/main/java/org/bukkit/event/entity/EntityShootBowEvent.java index efde16174..37dbc12eb 100644 --- a/api/src/main/java/org/bukkit/event/entity/EntityShootBowEvent.java +++ b/api/src/main/java/org/bukkit/event/entity/EntityShootBowEvent.java @@ -2,7 +2,7 @@ package org.bukkit.event.entity; import org.bukkit.entity.Entity; import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Projectile; +import org.bukkit.entity.Projectile; // Paper import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; import org.bukkit.inventory.ItemStack; @@ -34,11 +34,11 @@ public class EntityShootBowEvent extends EntityEvent implements Cancellable { } @Deprecated - public EntityShootBowEvent(@NotNull final LivingEntity shooter, @Nullable final ItemStack bow, @NotNull final Projectile projectile, final float force) { + public EntityShootBowEvent(@NotNull final LivingEntity shooter, @Nullable final ItemStack bow, @NotNull final Entity projectile, final float force) { this(shooter, bow, new ItemStack(org.bukkit.Material.AIR), projectile, force); } - public EntityShootBowEvent(@NotNull final LivingEntity shooter, @Nullable final ItemStack bow, @NotNull ItemStack arrowItem, @NotNull final Projectile projectile, final float force) { + public EntityShootBowEvent(@NotNull final LivingEntity shooter, @Nullable final ItemStack bow, @NotNull ItemStack arrowItem, @NotNull final Entity projectile, final float force) { super(shooter); this.arrowItem = arrowItem; // Paper end @@ -91,10 +91,12 @@ public class EntityShootBowEvent extends EntityEvent implements Cancellable { return force; } + @Override public boolean isCancelled() { return cancelled; } + @Override public void setCancelled(boolean cancel) { cancelled = cancel; } diff --git a/api/src/main/java/org/bukkit/event/entity/EntityTameEvent.java b/api/src/main/java/org/bukkit/event/entity/EntityTameEvent.java index 0698fa693..c410b48c2 100644 --- a/api/src/main/java/org/bukkit/event/entity/EntityTameEvent.java +++ b/api/src/main/java/org/bukkit/event/entity/EntityTameEvent.java @@ -25,10 +25,12 @@ public class EntityTameEvent extends EntityEvent implements Cancellable { return (LivingEntity) entity; } + @Override public boolean isCancelled() { return cancelled; } + @Override public void setCancelled(boolean cancel) { cancelled = cancel; } diff --git a/api/src/main/java/org/bukkit/event/entity/EntityTargetEvent.java b/api/src/main/java/org/bukkit/event/entity/EntityTargetEvent.java index 37d0ffa1b..dee186e99 100644 --- a/api/src/main/java/org/bukkit/event/entity/EntityTargetEvent.java +++ b/api/src/main/java/org/bukkit/event/entity/EntityTargetEvent.java @@ -21,10 +21,12 @@ public class EntityTargetEvent extends EntityEvent implements Cancellable { this.reason = reason; } + @Override public boolean isCancelled() { return cancel; } + @Override public void setCancelled(boolean cancel) { this.cancel = cancel; } @@ -107,9 +109,6 @@ public class EntityTargetEvent extends EntityEvent implements Cancellable { PIG_ZOMBIE_TARGET, /** * When the target is forgotten for whatever reason. - *

    - * Currently only occurs in with spiders when there is a high - * brightness. */ FORGOT_TARGET, /** @@ -151,6 +150,10 @@ public class EntityTargetEvent extends EntityEvent implements Cancellable { * entity */ CLOSEST_ENTITY, + /** + * When a raiding entity selects the same target as one of its compatriots. + */ + FOLLOW_LEADER, /** * When another entity tempts this entity by having a desired item such * as wheat in it's hand. diff --git a/api/src/main/java/org/bukkit/event/entity/EntityTargetLivingEntityEvent.java b/api/src/main/java/org/bukkit/event/entity/EntityTargetLivingEntityEvent.java index f309986f3..6fe47c8cc 100644 --- a/api/src/main/java/org/bukkit/event/entity/EntityTargetLivingEntityEvent.java +++ b/api/src/main/java/org/bukkit/event/entity/EntityTargetLivingEntityEvent.java @@ -14,6 +14,7 @@ public class EntityTargetLivingEntityEvent extends EntityTargetEvent{ super(entity, target, reason); } + @Override @Nullable public LivingEntity getTarget() { return (LivingEntity) super.getTarget(); @@ -29,6 +30,7 @@ public class EntityTargetLivingEntityEvent extends EntityTargetEvent{ * * @param target The entity to target */ + @Override public void setTarget(@Nullable Entity target) { if (target == null || target instanceof LivingEntity) { super.setTarget(target); diff --git a/api/src/main/java/org/bukkit/event/entity/EntityTeleportEvent.java b/api/src/main/java/org/bukkit/event/entity/EntityTeleportEvent.java index 310259fe8..a7918049a 100644 --- a/api/src/main/java/org/bukkit/event/entity/EntityTeleportEvent.java +++ b/api/src/main/java/org/bukkit/event/entity/EntityTeleportEvent.java @@ -26,10 +26,12 @@ public class EntityTeleportEvent extends EntityEvent implements Cancellable { this.cancel = false; } + @Override public boolean isCancelled() { return cancel; } + @Override public void setCancelled(boolean cancel) { this.cancel = cancel; } @@ -82,4 +84,4 @@ public class EntityTeleportEvent extends EntityEvent implements Cancellable { public static HandlerList getHandlerList() { return handlers; } -} \ No newline at end of file +} diff --git a/api/src/main/java/org/bukkit/event/entity/ExplosionPrimeEvent.java b/api/src/main/java/org/bukkit/event/entity/ExplosionPrimeEvent.java index 31fdb3014..6db5dad71 100644 --- a/api/src/main/java/org/bukkit/event/entity/ExplosionPrimeEvent.java +++ b/api/src/main/java/org/bukkit/event/entity/ExplosionPrimeEvent.java @@ -26,10 +26,12 @@ public class ExplosionPrimeEvent extends EntityEvent implements Cancellable { this(explosive, explosive.getYield(), explosive.isIncendiary()); } + @Override public boolean isCancelled() { return cancel; } + @Override public void setCancelled(boolean cancel) { this.cancel = cancel; } diff --git a/api/src/main/java/org/bukkit/event/entity/FoodLevelChangeEvent.java b/api/src/main/java/org/bukkit/event/entity/FoodLevelChangeEvent.java index f5b990612..7f4c5ea86 100644 --- a/api/src/main/java/org/bukkit/event/entity/FoodLevelChangeEvent.java +++ b/api/src/main/java/org/bukkit/event/entity/FoodLevelChangeEvent.java @@ -3,7 +3,9 @@ package org.bukkit.event.entity; import org.bukkit.entity.HumanEntity; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Called when a human entity's food level changes @@ -12,10 +14,16 @@ public class FoodLevelChangeEvent extends EntityEvent implements Cancellable { private static final HandlerList handlers = new HandlerList(); private boolean cancel = false; private int level; + private final ItemStack item; public FoodLevelChangeEvent(@NotNull final HumanEntity what, final int level) { + this(what, level, null); + } + + public FoodLevelChangeEvent(@NotNull final HumanEntity what, final int level, @Nullable final ItemStack item) { super(what); this.level = level; + this.item = item; } @NotNull @@ -24,6 +32,16 @@ public class FoodLevelChangeEvent extends EntityEvent implements Cancellable { return (HumanEntity) entity; } + /** + * Gets the item that triggered this event, if any. + * + * @return an ItemStack for the item being consumed + */ + @Nullable + public ItemStack getItem() { + return (item == null) ? null : item.clone(); + } + /** * Gets the resultant food level that the entity involved in this event * should be set to. @@ -49,10 +67,12 @@ public class FoodLevelChangeEvent extends EntityEvent implements Cancellable { this.level = level; } + @Override public boolean isCancelled() { return cancel; } + @Override public void setCancelled(boolean cancel) { this.cancel = cancel; } diff --git a/api/src/main/java/org/bukkit/event/entity/HorseJumpEvent.java b/api/src/main/java/org/bukkit/event/entity/HorseJumpEvent.java index 74588fc8f..65b1ddb2b 100644 --- a/api/src/main/java/org/bukkit/event/entity/HorseJumpEvent.java +++ b/api/src/main/java/org/bukkit/event/entity/HorseJumpEvent.java @@ -1,8 +1,8 @@ package org.bukkit.event.entity; +import org.bukkit.entity.AbstractHorse; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; -import org.bukkit.entity.AbstractHorse; import org.jetbrains.annotations.NotNull; /** @@ -18,6 +18,7 @@ public class HorseJumpEvent extends EntityEvent implements Cancellable { this.power = power; } + @Override public boolean isCancelled() { return cancelled; } @@ -25,6 +26,7 @@ public class HorseJumpEvent extends EntityEvent implements Cancellable { /** * @deprecated horse jumping was moved client side. */ + @Override @Deprecated public void setCancelled(boolean cancel) { cancelled = cancel; diff --git a/api/src/main/java/org/bukkit/event/entity/ItemDespawnEvent.java b/api/src/main/java/org/bukkit/event/entity/ItemDespawnEvent.java index 93e6f5ee7..6fc66197e 100644 --- a/api/src/main/java/org/bukkit/event/entity/ItemDespawnEvent.java +++ b/api/src/main/java/org/bukkit/event/entity/ItemDespawnEvent.java @@ -23,10 +23,12 @@ public class ItemDespawnEvent extends EntityEvent implements Cancellable { location = loc; } + @Override public boolean isCancelled() { return canceled; } + @Override public void setCancelled(boolean cancel) { canceled = cancel; } diff --git a/api/src/main/java/org/bukkit/event/entity/ItemSpawnEvent.java b/api/src/main/java/org/bukkit/event/entity/ItemSpawnEvent.java index 657589da8..faf98bb59 100644 --- a/api/src/main/java/org/bukkit/event/entity/ItemSpawnEvent.java +++ b/api/src/main/java/org/bukkit/event/entity/ItemSpawnEvent.java @@ -1,7 +1,6 @@ package org.bukkit.event.entity; import org.bukkit.Location; -import org.bukkit.UndefinedNullability; import org.bukkit.entity.Item; import org.jetbrains.annotations.NotNull; diff --git a/api/src/main/java/org/bukkit/event/entity/LingeringPotionSplashEvent.java b/api/src/main/java/org/bukkit/event/entity/LingeringPotionSplashEvent.java index 31606399a..a10dab167 100644 --- a/api/src/main/java/org/bukkit/event/entity/LingeringPotionSplashEvent.java +++ b/api/src/main/java/org/bukkit/event/entity/LingeringPotionSplashEvent.java @@ -1,7 +1,6 @@ package org.bukkit.event.entity; import org.bukkit.entity.AreaEffectCloud; -import org.bukkit.entity.LingeringPotion; import org.bukkit.entity.ThrownPotion; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; @@ -22,8 +21,8 @@ public class LingeringPotionSplashEvent extends ProjectileHitEvent implements Ca @NotNull @Override - public LingeringPotion getEntity() { - return (LingeringPotion) super.getEntity(); + public ThrownPotion getEntity() { + return (ThrownPotion) super.getEntity(); } /** @@ -36,10 +35,12 @@ public class LingeringPotionSplashEvent extends ProjectileHitEvent implements Ca return entity; } + @Override public boolean isCancelled() { return cancelled; } + @Override public void setCancelled(boolean cancel) { cancelled = cancel; } diff --git a/api/src/main/java/org/bukkit/event/entity/PigZapEvent.java b/api/src/main/java/org/bukkit/event/entity/PigZapEvent.java index 0eaa8df94..d3949edfc 100644 --- a/api/src/main/java/org/bukkit/event/entity/PigZapEvent.java +++ b/api/src/main/java/org/bukkit/event/entity/PigZapEvent.java @@ -25,10 +25,12 @@ public class PigZapEvent extends EntityZapEvent implements Cancellable { this.pigzombie = pigzombie; } + @Override public boolean isCancelled() { return canceled; } + @Override public void setCancelled(boolean cancel) { canceled = cancel; } diff --git a/api/src/main/java/org/bukkit/event/entity/PlayerDeathEvent.java b/api/src/main/java/org/bukkit/event/entity/PlayerDeathEvent.java index 16f015500..1e97d04b3 100644 --- a/api/src/main/java/org/bukkit/event/entity/PlayerDeathEvent.java +++ b/api/src/main/java/org/bukkit/event/entity/PlayerDeathEvent.java @@ -1,7 +1,6 @@ package org.bukkit.event.entity; import java.util.List; - import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; @@ -169,9 +168,9 @@ public class PlayerDeathEvent extends EntityDeathEvent { *

    * This overrides all other EXP settings *

    - * This doesn't prevent prevent the EXP from dropping. + * This doesn't prevent prevent the EXP from dropping. * {@link #setDroppedExp(int)} should be used stop the - * EXP from dropping. + * EXP from dropping. * * @param keepLevel True to keep all current value levels */ @@ -181,6 +180,10 @@ public class PlayerDeathEvent extends EntityDeathEvent { /** * Sets if the Player keeps inventory on death. + *

    + * This doesn't prevent prevent the items from dropping. + * {@code getDrops().clear()} should be used stop the + * items from dropping. * * @param keepInventory True to keep the inventory */ diff --git a/api/src/main/java/org/bukkit/event/entity/PlayerLeashEntityEvent.java b/api/src/main/java/org/bukkit/event/entity/PlayerLeashEntityEvent.java index e087e1418..cbf0c736b 100644 --- a/api/src/main/java/org/bukkit/event/entity/PlayerLeashEntityEvent.java +++ b/api/src/main/java/org/bukkit/event/entity/PlayerLeashEntityEvent.java @@ -64,10 +64,12 @@ public class PlayerLeashEntityEvent extends Event implements Cancellable { return handlers; } + @Override public boolean isCancelled() { return this.cancelled; } + @Override public void setCancelled(boolean cancel) { this.cancelled = cancel; } diff --git a/api/src/main/java/org/bukkit/event/entity/PotionSplashEvent.java b/api/src/main/java/org/bukkit/event/entity/PotionSplashEvent.java index 45d224ec9..90d7e8141 100644 --- a/api/src/main/java/org/bukkit/event/entity/PotionSplashEvent.java +++ b/api/src/main/java/org/bukkit/event/entity/PotionSplashEvent.java @@ -3,7 +3,6 @@ package org.bukkit.event.entity; import java.util.ArrayList; import java.util.Collection; import java.util.Map; - import org.apache.commons.lang.Validate; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.ThrownPotion; @@ -79,10 +78,12 @@ public class PotionSplashEvent extends ProjectileHitEvent implements Cancellable } } + @Override public boolean isCancelled() { return cancelled; } + @Override public void setCancelled(boolean cancel) { cancelled = cancel; } diff --git a/api/src/main/java/org/bukkit/event/entity/ProjectileLaunchEvent.java b/api/src/main/java/org/bukkit/event/entity/ProjectileLaunchEvent.java index f7a4bc4bd..c5fc3c558 100644 --- a/api/src/main/java/org/bukkit/event/entity/ProjectileLaunchEvent.java +++ b/api/src/main/java/org/bukkit/event/entity/ProjectileLaunchEvent.java @@ -15,10 +15,12 @@ public class ProjectileLaunchEvent extends EntitySpawnEvent implements Cancellab super(what); } + @Override public boolean isCancelled() { return cancelled; } + @Override public void setCancelled(boolean cancel) { cancelled = cancel; } diff --git a/api/src/main/java/org/bukkit/event/entity/SheepDyeWoolEvent.java b/api/src/main/java/org/bukkit/event/entity/SheepDyeWoolEvent.java index 60c648ee6..4db826e4d 100644 --- a/api/src/main/java/org/bukkit/event/entity/SheepDyeWoolEvent.java +++ b/api/src/main/java/org/bukkit/event/entity/SheepDyeWoolEvent.java @@ -20,10 +20,12 @@ public class SheepDyeWoolEvent extends EntityEvent implements Cancellable { this.color = color; } + @Override public boolean isCancelled() { return cancel; } + @Override public void setCancelled(boolean cancel) { this.cancel = cancel; } diff --git a/api/src/main/java/org/bukkit/event/entity/SheepRegrowWoolEvent.java b/api/src/main/java/org/bukkit/event/entity/SheepRegrowWoolEvent.java index 428ca4c9c..05264b31a 100644 --- a/api/src/main/java/org/bukkit/event/entity/SheepRegrowWoolEvent.java +++ b/api/src/main/java/org/bukkit/event/entity/SheepRegrowWoolEvent.java @@ -17,10 +17,12 @@ public class SheepRegrowWoolEvent extends EntityEvent implements Cancellable { this.cancel = false; } + @Override public boolean isCancelled() { return cancel; } + @Override public void setCancelled(boolean cancel) { this.cancel = cancel; } diff --git a/api/src/main/java/org/bukkit/event/entity/SlimeSplitEvent.java b/api/src/main/java/org/bukkit/event/entity/SlimeSplitEvent.java index 6e634dd7f..02b659847 100644 --- a/api/src/main/java/org/bukkit/event/entity/SlimeSplitEvent.java +++ b/api/src/main/java/org/bukkit/event/entity/SlimeSplitEvent.java @@ -18,10 +18,12 @@ public class SlimeSplitEvent extends EntityEvent implements Cancellable { this.count = count; } + @Override public boolean isCancelled() { return cancel; } + @Override public void setCancelled(boolean cancel) { this.cancel = cancel; } @@ -60,4 +62,4 @@ public class SlimeSplitEvent extends EntityEvent implements Cancellable { public static HandlerList getHandlerList() { return handlers; } -} \ No newline at end of file +} diff --git a/api/src/main/java/org/bukkit/event/entity/VillagerAcquireTradeEvent.java b/api/src/main/java/org/bukkit/event/entity/VillagerAcquireTradeEvent.java index 95740eb7f..58155105d 100644 --- a/api/src/main/java/org/bukkit/event/entity/VillagerAcquireTradeEvent.java +++ b/api/src/main/java/org/bukkit/event/entity/VillagerAcquireTradeEvent.java @@ -1,6 +1,6 @@ package org.bukkit.event.entity; -import org.bukkit.entity.Villager; +import org.bukkit.entity.AbstractVillager; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; import org.bukkit.inventory.MerchantRecipe; @@ -16,7 +16,7 @@ public class VillagerAcquireTradeEvent extends EntityEvent implements Cancellabl // private MerchantRecipe recipe; - public VillagerAcquireTradeEvent(@NotNull Villager what, @NotNull MerchantRecipe recipe) { + public VillagerAcquireTradeEvent(@NotNull AbstractVillager what, @NotNull MerchantRecipe recipe) { super(what); this.recipe = recipe; } @@ -52,8 +52,8 @@ public class VillagerAcquireTradeEvent extends EntityEvent implements Cancellabl @NotNull @Override - public Villager getEntity() { - return (Villager) super.getEntity(); + public AbstractVillager getEntity() { + return (AbstractVillager) super.getEntity(); } @NotNull diff --git a/api/src/main/java/org/bukkit/event/entity/VillagerCareerChangeEvent.java b/api/src/main/java/org/bukkit/event/entity/VillagerCareerChangeEvent.java new file mode 100644 index 000000000..b550029cf --- /dev/null +++ b/api/src/main/java/org/bukkit/event/entity/VillagerCareerChangeEvent.java @@ -0,0 +1,92 @@ +package org.bukkit.event.entity; + +import org.bukkit.entity.Villager; +import org.bukkit.entity.Villager.Profession; +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; + +public class VillagerCareerChangeEvent extends EntityEvent implements Cancellable { + + private static final HandlerList handlers = new HandlerList(); + private boolean cancelled; + private Profession profession; + private final ChangeReason reason; + + public VillagerCareerChangeEvent(@NotNull Villager what, @NotNull Profession profession, @NotNull ChangeReason reason) { + super(what); + this.profession = profession; + this.reason = reason; + } + + @NotNull + @Override + public Villager getEntity() { + return (Villager) super.getEntity(); + } + + /** + * Gets the future profession of the villager. + * + * @return The profession the villager will change to + */ + @NotNull + public Profession getProfession() { + return profession; + } + + /** + * Sets the profession the villager will become from this event. + * + * @param profession new profession + */ + public void setProfession(@NotNull Profession profession) { + this.profession = profession; + } + + /** + * Gets the reason for why the villager's career is changing. + * + * @return Reason for villager's profession changing + */ + @NotNull + public ChangeReason getReason() { + return reason; + } + + @Override + public boolean isCancelled() { + return cancelled; + } + + @Override + public void setCancelled(@NotNull boolean cancel) { + cancelled = cancel; + } + + @NotNull + @Override + public HandlerList getHandlers() { + return handlers; + } + + @NotNull + public static HandlerList getHandlerList() { + return handlers; + } + + /** + * Reasons for the villager's profession changing. + */ + public enum ChangeReason { + + /** + * Villager lost their job due to too little experience. + */ + LOSING_JOB, + /** + * Villager gained employment. + */ + EMPLOYED; + } +} diff --git a/api/src/main/java/org/bukkit/event/entity/VillagerReplenishTradeEvent.java b/api/src/main/java/org/bukkit/event/entity/VillagerReplenishTradeEvent.java index 738469dd3..ff5f484cf 100644 --- a/api/src/main/java/org/bukkit/event/entity/VillagerReplenishTradeEvent.java +++ b/api/src/main/java/org/bukkit/event/entity/VillagerReplenishTradeEvent.java @@ -1,6 +1,6 @@ package org.bukkit.event.entity; -import org.bukkit.entity.Villager; +import org.bukkit.entity.AbstractVillager; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; import org.bukkit.inventory.MerchantRecipe; @@ -20,7 +20,7 @@ public class VillagerReplenishTradeEvent extends EntityEvent implements Cancella private MerchantRecipe recipe; private int bonus; - public VillagerReplenishTradeEvent(@NotNull Villager what, @NotNull MerchantRecipe recipe, int bonus) { + public VillagerReplenishTradeEvent(@NotNull AbstractVillager what, @NotNull MerchantRecipe recipe, int bonus) { super(what); this.recipe = recipe; this.bonus = bonus; @@ -77,8 +77,8 @@ public class VillagerReplenishTradeEvent extends EntityEvent implements Cancella @NotNull @Override - public Villager getEntity() { - return (Villager) super.getEntity(); + public AbstractVillager getEntity() { + return (AbstractVillager) super.getEntity(); } @NotNull diff --git a/api/src/main/java/org/bukkit/event/hanging/HangingBreakEvent.java b/api/src/main/java/org/bukkit/event/hanging/HangingBreakEvent.java index 8c43c890e..16d8196e1 100644 --- a/api/src/main/java/org/bukkit/event/hanging/HangingBreakEvent.java +++ b/api/src/main/java/org/bukkit/event/hanging/HangingBreakEvent.java @@ -28,10 +28,12 @@ public class HangingBreakEvent extends HangingEvent implements Cancellable { return cause; } + @Override public boolean isCancelled() { return cancelled; } + @Override public void setCancelled(boolean cancel) { this.cancelled = cancel; } diff --git a/api/src/main/java/org/bukkit/event/hanging/HangingEvent.java b/api/src/main/java/org/bukkit/event/hanging/HangingEvent.java index 6abf76f21..f01a1a0f0 100644 --- a/api/src/main/java/org/bukkit/event/hanging/HangingEvent.java +++ b/api/src/main/java/org/bukkit/event/hanging/HangingEvent.java @@ -1,18 +1,14 @@ package org.bukkit.event.hanging; -import org.bukkit.World; import org.bukkit.entity.Hanging; import org.bukkit.event.Event; import org.jetbrains.annotations.NotNull; -import io.akarin.server.api.event.WorldAttachedEvent; - /** * Represents a hanging entity-related event. */ -public abstract class HangingEvent extends Event implements WorldAttachedEvent { // Akarin +public abstract class HangingEvent extends Event { protected Hanging hanging; - @Override @NotNull public World getWorld() { return hanging.getWorld(); } // Akarin protected HangingEvent(@NotNull final Hanging painting) { this.hanging = painting; diff --git a/api/src/main/java/org/bukkit/event/hanging/HangingPlaceEvent.java b/api/src/main/java/org/bukkit/event/hanging/HangingPlaceEvent.java index 8ce33024f..959b9f3fb 100644 --- a/api/src/main/java/org/bukkit/event/hanging/HangingPlaceEvent.java +++ b/api/src/main/java/org/bukkit/event/hanging/HangingPlaceEvent.java @@ -56,10 +56,12 @@ public class HangingPlaceEvent extends HangingEvent implements Cancellable { return blockFace; } + @Override public boolean isCancelled() { return cancelled; } + @Override public void setCancelled(boolean cancel) { this.cancelled = cancel; } diff --git a/api/src/main/java/org/bukkit/event/inventory/BrewEvent.java b/api/src/main/java/org/bukkit/event/inventory/BrewEvent.java index 140fc9208..8fbfad91b 100644 --- a/api/src/main/java/org/bukkit/event/inventory/BrewEvent.java +++ b/api/src/main/java/org/bukkit/event/inventory/BrewEvent.java @@ -42,10 +42,12 @@ public class BrewEvent extends BlockEvent implements Cancellable { return fuelLevel; } + @Override public boolean isCancelled() { return cancelled; } + @Override public void setCancelled(boolean cancel) { cancelled = cancel; } diff --git a/api/src/main/java/org/bukkit/event/inventory/FurnaceBurnEvent.java b/api/src/main/java/org/bukkit/event/inventory/FurnaceBurnEvent.java index 46a67e671..bc71bc2d3 100644 --- a/api/src/main/java/org/bukkit/event/inventory/FurnaceBurnEvent.java +++ b/api/src/main/java/org/bukkit/event/inventory/FurnaceBurnEvent.java @@ -71,10 +71,12 @@ public class FurnaceBurnEvent extends BlockEvent implements Cancellable { this.burning = burning; } + @Override public boolean isCancelled() { return cancelled; } + @Override public void setCancelled(boolean cancel) { this.cancelled = cancel; } diff --git a/api/src/main/java/org/bukkit/event/inventory/FurnaceSmeltEvent.java b/api/src/main/java/org/bukkit/event/inventory/FurnaceSmeltEvent.java index 98196837b..066e7dd9a 100644 --- a/api/src/main/java/org/bukkit/event/inventory/FurnaceSmeltEvent.java +++ b/api/src/main/java/org/bukkit/event/inventory/FurnaceSmeltEvent.java @@ -1,73 +1,16 @@ package org.bukkit.event.inventory; import org.bukkit.block.Block; -import org.bukkit.event.Cancellable; -import org.bukkit.event.HandlerList; -import org.bukkit.event.block.BlockEvent; +import org.bukkit.event.block.BlockCookEvent; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; /** * Called when an ItemStack is successfully smelted in a furnace. */ -public class FurnaceSmeltEvent extends BlockEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); - private final ItemStack source; - private ItemStack result; - private boolean cancelled; +public class FurnaceSmeltEvent extends BlockCookEvent { public FurnaceSmeltEvent(@NotNull final Block furnace, @NotNull final ItemStack source, @NotNull final ItemStack result) { - super(furnace); - this.source = source; - this.result = result; - this.cancelled = false; - } - - /** - * Gets the smelted ItemStack for this event - * - * @return smelting source ItemStack - */ - @NotNull - public ItemStack getSource() { - return source; - } - - /** - * Gets the resultant ItemStack for this event - * - * @return smelting result ItemStack - */ - @NotNull - public ItemStack getResult() { - return result; - } - - /** - * Sets the resultant ItemStack for this event - * - * @param result new result ItemStack - */ - public void setResult(@NotNull ItemStack result) { - this.result = result; - } - - public boolean isCancelled() { - return cancelled; - } - - public void setCancelled(boolean cancel) { - this.cancelled = cancel; - } - - @NotNull - @Override - public HandlerList getHandlers() { - return handlers; - } - - @NotNull - public static HandlerList getHandlerList() { - return handlers; + super(furnace, source, result); } } diff --git a/api/src/main/java/org/bukkit/event/inventory/InventoryClickEvent.java b/api/src/main/java/org/bukkit/event/inventory/InventoryClickEvent.java index 5aec15a90..02766d933 100644 --- a/api/src/main/java/org/bukkit/event/inventory/InventoryClickEvent.java +++ b/api/src/main/java/org/bukkit/event/inventory/InventoryClickEvent.java @@ -1,15 +1,15 @@ package org.bukkit.event.inventory; -import org.bukkit.inventory.Inventory; -import org.bukkit.inventory.InventoryView; +import org.bukkit.Location; import org.bukkit.entity.HumanEntity; import org.bukkit.entity.Player; import org.bukkit.event.HandlerList; import org.bukkit.event.inventory.InventoryType.SlotType; -import org.bukkit.Location; +import org.bukkit.inventory.Inventory; +import org.bukkit.inventory.InventoryView; import org.bukkit.inventory.ItemStack; -import org.bukkit.scheduler.BukkitScheduler; import org.bukkit.plugin.Plugin; +import org.bukkit.scheduler.BukkitScheduler; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -29,7 +29,7 @@ import org.jetbrains.annotations.Nullable; *

  • {@link HumanEntity#openEnchanting(Location, boolean)} *
  • {@link InventoryView#close()} * - * To invoke one of these methods, schedule a task using + * To invoke one of these methods, schedule a task using * {@link BukkitScheduler#runTask(Plugin, Runnable)}, which will run the task * on the next tick. Also be aware that this is not an exhaustive list, and * other methods could potentially create issues as well. diff --git a/api/src/main/java/org/bukkit/event/inventory/InventoryCreativeEvent.java b/api/src/main/java/org/bukkit/event/inventory/InventoryCreativeEvent.java index bef9a4149..9c6db8be4 100644 --- a/api/src/main/java/org/bukkit/event/inventory/InventoryCreativeEvent.java +++ b/api/src/main/java/org/bukkit/event/inventory/InventoryCreativeEvent.java @@ -1,36 +1,30 @@ package org.bukkit.event.inventory; -import org.bukkit.entity.Player; import org.bukkit.event.inventory.InventoryType.SlotType; import org.bukkit.inventory.InventoryView; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; -import io.akarin.server.api.event.PlayerAttachedEvent; - /** * This event is called when a player in creative mode puts down or picks up * an item in their inventory / hotbar and when they drop items from their * Inventory while in creative mode. */ -public class InventoryCreativeEvent extends InventoryClickEvent implements PlayerAttachedEvent { // Akarin +public class InventoryCreativeEvent extends InventoryClickEvent { private ItemStack item; - // Akarin start - @NotNull - @Override - public Player getPlayer() { return (Player) transaction.getPlayer(); } - // Akarin end public InventoryCreativeEvent(@NotNull InventoryView what, @NotNull SlotType type, int slot, @NotNull ItemStack newItem) { super(what, type, slot, ClickType.CREATIVE, InventoryAction.PLACE_ALL); this.item = newItem; } + @Override @NotNull public ItemStack getCursor() { return item; } + @Override public void setCursor(@NotNull ItemStack item) { this.item = item; } diff --git a/api/src/main/java/org/bukkit/event/inventory/InventoryDragEvent.java b/api/src/main/java/org/bukkit/event/inventory/InventoryDragEvent.java index 1716369a7..856e945c5 100644 --- a/api/src/main/java/org/bukkit/event/inventory/InventoryDragEvent.java +++ b/api/src/main/java/org/bukkit/event/inventory/InventoryDragEvent.java @@ -1,9 +1,9 @@ package org.bukkit.event.inventory; +import com.google.common.collect.ImmutableSet; import java.util.Collections; import java.util.Map; import java.util.Set; - import org.apache.commons.lang.Validate; import org.bukkit.Location; import org.bukkit.entity.HumanEntity; @@ -14,15 +14,13 @@ import org.bukkit.inventory.InventoryView; import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.Plugin; import org.bukkit.scheduler.BukkitScheduler; - -import com.google.common.collect.ImmutableSet; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; /** * This event is called when the player drags an item in their cursor across * the inventory. The ItemStack is distributed across the slots the - * HumanEntity dragged over. The method of distribution is described by the + * HumanEntity dragged over. The method of distribution is described by the * DragType returned by {@link #getType()}. *

    * Canceling this event will result in none of the changes described in @@ -41,7 +39,7 @@ import org.jetbrains.annotations.Nullable; *

  • {@link HumanEntity#openEnchanting(Location, boolean)} *
  • {@link InventoryView#close()} * - * To invoke one of these methods, schedule a task using + * To invoke one of these methods, schedule a task using * {@link BukkitScheduler#runTask(Plugin, Runnable)}, which will run the task * on the next tick. Also be aware that this is not an exhaustive list, and * other methods could potentially create issues as well. diff --git a/api/src/main/java/org/bukkit/event/inventory/InventoryEvent.java b/api/src/main/java/org/bukkit/event/inventory/InventoryEvent.java index 49de73a72..5d3fe64ab 100644 --- a/api/src/main/java/org/bukkit/event/inventory/InventoryEvent.java +++ b/api/src/main/java/org/bukkit/event/inventory/InventoryEvent.java @@ -2,30 +2,19 @@ package org.bukkit.event.inventory; import java.util.List; - -import org.bukkit.event.HandlerList; -import org.bukkit.World; import org.bukkit.entity.HumanEntity; import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.InventoryView; import org.jetbrains.annotations.NotNull; -import io.akarin.server.api.event.WorldAttachedEvent; - /** * Represents a player related inventory event */ -public class InventoryEvent extends Event implements WorldAttachedEvent { // Akarin +public class InventoryEvent extends Event { private static final HandlerList handlers = new HandlerList(); protected InventoryView transaction; - // Akarin start - @NotNull - @Override - public World getWorld() { return transaction.getPlayer().getWorld(); } - @NotNull - public HumanEntity getWhoClicked() { return transaction.getPlayer(); } - // Akarin end public InventoryEvent(@NotNull InventoryView transaction) { this.transaction = transaction; diff --git a/api/src/main/java/org/bukkit/event/inventory/InventoryInteractEvent.java b/api/src/main/java/org/bukkit/event/inventory/InventoryInteractEvent.java index d3cf4bb09..707b4381e 100644 --- a/api/src/main/java/org/bukkit/event/inventory/InventoryInteractEvent.java +++ b/api/src/main/java/org/bukkit/event/inventory/InventoryInteractEvent.java @@ -1,24 +1,16 @@ package org.bukkit.event.inventory; import org.bukkit.entity.HumanEntity; -import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.inventory.InventoryView; import org.jetbrains.annotations.NotNull; -import io.akarin.server.api.event.PlayerAttachedEvent; - /** * An abstract base class for events that describe an interaction between a * HumanEntity and the contents of an Inventory. */ -public abstract class InventoryInteractEvent extends InventoryEvent implements Cancellable, PlayerAttachedEvent { // Akarin +public abstract class InventoryInteractEvent extends InventoryEvent implements Cancellable { private Result result = Result.DEFAULT; - // Akarin start - @NotNull - @Override - public Player getPlayer() { return (Player) transaction.getPlayer(); } - // Akarin end public InventoryInteractEvent(@NotNull InventoryView transaction) { super(transaction); @@ -67,19 +59,21 @@ public abstract class InventoryInteractEvent extends InventoryEvent implements C * * @return whether the event is cancelled */ + @Override public boolean isCancelled() { return getResult() == Result.DENY; } /** - * Proxy method to {@link #setResult(Event.Result)} for the Cancellable - * interface. {@link #setResult(Event.Result)} is preferred, as it allows + * Proxy method to {@link #setResult(org.bukkit.event.Event.Result)} for the Cancellable + * interface. {@link #setResult(org.bukkit.event.Event.Result)} is preferred, as it allows * you to specify the Result beyond Result.DENY and Result.ALLOW. *

    * {@inheritDoc} * * @param toCancel result becomes DENY if true, ALLOW if false */ + @Override public void setCancelled(boolean toCancel) { setResult(toCancel ? Result.DENY : Result.ALLOW); } diff --git a/api/src/main/java/org/bukkit/event/inventory/InventoryMoveItemEvent.java b/api/src/main/java/org/bukkit/event/inventory/InventoryMoveItemEvent.java index f0a16d3c2..04d4a83bf 100644 --- a/api/src/main/java/org/bukkit/event/inventory/InventoryMoveItemEvent.java +++ b/api/src/main/java/org/bukkit/event/inventory/InventoryMoveItemEvent.java @@ -98,10 +98,12 @@ public class InventoryMoveItemEvent extends Event implements Cancellable { return didSourceInitiate ? sourceInventory : destinationInventory; } + @Override public boolean isCancelled() { return cancelled; } + @Override public void setCancelled(boolean cancel) { this.cancelled = cancel; } diff --git a/api/src/main/java/org/bukkit/event/inventory/InventoryOpenEvent.java b/api/src/main/java/org/bukkit/event/inventory/InventoryOpenEvent.java index 331a1bd73..9013d0435 100644 --- a/api/src/main/java/org/bukkit/event/inventory/InventoryOpenEvent.java +++ b/api/src/main/java/org/bukkit/event/inventory/InventoryOpenEvent.java @@ -1,9 +1,9 @@ package org.bukkit.event.inventory; -import org.bukkit.inventory.InventoryView; import org.bukkit.entity.HumanEntity; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.bukkit.inventory.InventoryView; import org.jetbrains.annotations.NotNull; /** @@ -37,6 +37,7 @@ public class InventoryOpenEvent extends InventoryEvent implements Cancellable { * * @return true if this event is cancelled */ + @Override public boolean isCancelled() { return cancelled; } @@ -50,6 +51,7 @@ public class InventoryOpenEvent extends InventoryEvent implements Cancellable { * * @param cancel true if you wish to cancel this event */ + @Override public void setCancelled(boolean cancel) { cancelled = cancel; } diff --git a/api/src/main/java/org/bukkit/event/inventory/InventoryPickupItemEvent.java b/api/src/main/java/org/bukkit/event/inventory/InventoryPickupItemEvent.java index b761c0224..1ffac4d58 100644 --- a/api/src/main/java/org/bukkit/event/inventory/InventoryPickupItemEvent.java +++ b/api/src/main/java/org/bukkit/event/inventory/InventoryPickupItemEvent.java @@ -42,10 +42,12 @@ public class InventoryPickupItemEvent extends Event implements Cancellable { return item; } + @Override public boolean isCancelled() { return cancelled; } + @Override public void setCancelled(boolean cancel) { this.cancelled = cancel; } diff --git a/api/src/main/java/org/bukkit/event/inventory/InventoryType.java b/api/src/main/java/org/bukkit/event/inventory/InventoryType.java index d69ce3ec7..75e719ae8 100644 --- a/api/src/main/java/org/bukkit/event/inventory/InventoryType.java +++ b/api/src/main/java/org/bukkit/event/inventory/InventoryType.java @@ -11,7 +11,8 @@ import org.jetbrains.annotations.NotNull; * The current list of inventories that cannot be created via * {@link org.bukkit.Bukkit#createInventory} are:
    *

    - * {@link InventoryType#CREATIVE} and {@link InventoryType#CRAFTING} + * {@link InventoryType#CREATIVE}, {@link InventoryType#CRAFTING} and + * {@link InventoryType#MERCHANT} *
    * * See {@link org.bukkit.Bukkit#createInventory} for more information. @@ -53,7 +54,7 @@ public enum InventoryType { */ ENCHANTING(2,"Enchanting"), /** - * A brewing stand inventory, with one FUEL slot and three CRAFTING slots. + * A brewing stand inventory, with one FUEL slot and four CRAFTING slots. */ BREWING(5,"Brewing"), /** @@ -69,7 +70,7 @@ public enum InventoryType { */ CREATIVE(9,"Creative", false), /** - * The merchant inventory, with 2 TRADE-IN slots, and 1 RESULT slot. + * The merchant inventory, with 2 CRAFTING slots, and 1 RESULT slot. */ MERCHANT(3,"Villager", false), /** @@ -92,6 +93,39 @@ public enum InventoryType { * A shulker box inventory, with 27 slots of type CONTAINER. */ SHULKER_BOX(27, "Shulker Box"), + /** + * A barrel box inventory, with 27 slots of type CONTAINER. + */ + BARREL(27, "Barrel"), + /** + * A blast furnace inventory, with a RESULT slot, a CRAFTING slot, and a + * FUEL slot. + */ + BLAST_FURNACE(3, "Blast Furnace"), + /** + * A lectern inventory, with 1 BOOK slot. + */ + LECTERN(1, "Lectern"), + /** + * A smoker inventory, with a RESULT slot, a CRAFTING slot, and a FUEL slot. + */ + SMOKER(3, "Smoker"), + /** + * Loom inventory, with 3 CRAFTING slots, and 1 RESULT slot. + */ + LOOM(4, "Loom"), + /** + * Cartography inventory with 2 CRAFTING slots, and 1 RESULT slot. + */ + CARTOGRAPHY(3, "Cartography Table"), + /** + * Grindstone inventory with 2 CRAFTING slots, and 1 RESULT slot. + */ + GRINDSTONE(3, "Repair & Disenchant"), + /** + * Stonecutter inventory with 1 CRAFTING slot, and 1 RESULT slot. + */ + STONECUTTER(2, "Stonecutter") ; private final int size; @@ -133,9 +167,7 @@ public enum InventoryType { */ RESULT, /** - * A slot in the crafting matrix, or the input slot in a furnace - * inventory, the potion slot in the brewing stand, or the enchanting - * slot. + * A slot in the crafting matrix, or an 'input' slot. */ CRAFTING, /** diff --git a/api/src/main/java/org/bukkit/event/inventory/PrepareAnvilEvent.java b/api/src/main/java/org/bukkit/event/inventory/PrepareAnvilEvent.java index 3ef9bc269..77109a07f 100644 --- a/api/src/main/java/org/bukkit/event/inventory/PrepareAnvilEvent.java +++ b/api/src/main/java/org/bukkit/event/inventory/PrepareAnvilEvent.java @@ -1,6 +1,5 @@ package org.bukkit.event.inventory; -import org.bukkit.entity.Player; import org.bukkit.event.HandlerList; import org.bukkit.inventory.AnvilInventory; import org.bukkit.inventory.InventoryView; @@ -8,20 +7,13 @@ import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import io.akarin.server.api.event.PlayerAttachedEvent; - /** * Called when an item is put in a slot for repair by an anvil. */ -public class PrepareAnvilEvent extends InventoryEvent implements PlayerAttachedEvent { // Akarin +public class PrepareAnvilEvent extends InventoryEvent { private static final HandlerList handlers = new HandlerList(); private ItemStack result; - // Akarin start - @NotNull - @Override - public Player getPlayer() { return (Player) transaction.getPlayer(); } - // Akarin end public PrepareAnvilEvent(@NotNull InventoryView inventory, @Nullable ItemStack result) { super(inventory); diff --git a/api/src/main/java/org/bukkit/event/inventory/PrepareItemCraftEvent.java b/api/src/main/java/org/bukkit/event/inventory/PrepareItemCraftEvent.java index ba76f6596..efd29d198 100644 --- a/api/src/main/java/org/bukkit/event/inventory/PrepareItemCraftEvent.java +++ b/api/src/main/java/org/bukkit/event/inventory/PrepareItemCraftEvent.java @@ -1,6 +1,5 @@ package org.bukkit.event.inventory; -import org.bukkit.entity.Player; import org.bukkit.event.HandlerList; import org.bukkit.inventory.CraftingInventory; import org.bukkit.inventory.InventoryView; @@ -8,17 +7,10 @@ import org.bukkit.inventory.Recipe; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import io.akarin.server.api.event.PlayerAttachedEvent; - -public class PrepareItemCraftEvent extends InventoryEvent implements PlayerAttachedEvent { // Akarin +public class PrepareItemCraftEvent extends InventoryEvent { private static final HandlerList handlers = new HandlerList(); private boolean repair; private CraftingInventory matrix; - // Akarin start - @NotNull - @Override - public Player getPlayer() { return (Player) transaction.getPlayer(); } - // Akarin end public PrepareItemCraftEvent(@NotNull CraftingInventory what, @NotNull InventoryView view, boolean isRepair) { super(view); diff --git a/api/src/main/java/org/bukkit/event/inventory/TradeSelectEvent.java b/api/src/main/java/org/bukkit/event/inventory/TradeSelectEvent.java new file mode 100644 index 000000000..3bddf946d --- /dev/null +++ b/api/src/main/java/org/bukkit/event/inventory/TradeSelectEvent.java @@ -0,0 +1,62 @@ +package org.bukkit.event.inventory; + +import org.bukkit.event.HandlerList; +import org.bukkit.inventory.InventoryView; +import org.bukkit.inventory.Merchant; +import org.bukkit.inventory.MerchantInventory; +import org.jetbrains.annotations.NotNull; + +/** + * This event is called whenever a player clicks a new trade on the trades + * sidebar. + *

    + * This event allows the user to get the index of the trade, letting them get + * the MerchantRecipe via the Merchant. + */ +public class TradeSelectEvent extends InventoryInteractEvent { + + private static final HandlerList handlers = new HandlerList(); + // + private final int index; + + public TradeSelectEvent(@NotNull InventoryView transaction, int newIndex) { + super(transaction); + this.index = newIndex; + } + + /** + * Used to get the index of the trade the player clicked on. + * + * @return The index of the trade clicked by the player + */ + public int getIndex() { + return index; + } + + @NotNull + @Override + public MerchantInventory getInventory() { + return (MerchantInventory) super.getInventory(); + } + + /** + * Get the Merchant involved. + * + * @return the Merchant + */ + @NotNull + public Merchant getMerchant() { + return getInventory().getMerchant(); + } + + @NotNull + @Override + public HandlerList getHandlers() { + return handlers; + } + + @NotNull + public static HandlerList getHandlerList() { + return handlers; + } +} diff --git a/api/src/main/java/org/bukkit/event/player/AsyncPlayerChatEvent.java b/api/src/main/java/org/bukkit/event/player/AsyncPlayerChatEvent.java index cc3049e82..ab129b058 100644 --- a/api/src/main/java/org/bukkit/event/player/AsyncPlayerChatEvent.java +++ b/api/src/main/java/org/bukkit/event/player/AsyncPlayerChatEvent.java @@ -2,7 +2,6 @@ package org.bukkit.event.player; import java.util.IllegalFormatException; import java.util.Set; - import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; @@ -125,10 +124,12 @@ public class AsyncPlayerChatEvent extends PlayerEvent implements Cancellable { return recipients; } + @Override public boolean isCancelled() { return cancel; } + @Override public void setCancelled(boolean cancel) { this.cancel = cancel; } diff --git a/api/src/main/java/org/bukkit/event/player/AsyncPlayerPreLoginEvent.java b/api/src/main/java/org/bukkit/event/player/AsyncPlayerPreLoginEvent.java index 6c09ea6c6..76c4a1a6e 100644 --- a/api/src/main/java/org/bukkit/event/player/AsyncPlayerPreLoginEvent.java +++ b/api/src/main/java/org/bukkit/event/player/AsyncPlayerPreLoginEvent.java @@ -42,8 +42,7 @@ public class AsyncPlayerPreLoginEvent extends Event { return profile; } - /** - * Changes the PlayerProfile the player will login as + /* * Changes the PlayerProfile the player will login as * @param profile The profile to use */ public void setPlayerProfile(@NotNull PlayerProfile profile) { diff --git a/api/src/main/java/org/bukkit/event/player/PlayerAchievementAwardedEvent.java b/api/src/main/java/org/bukkit/event/player/PlayerAchievementAwardedEvent.java index fae6a901b..07fa439a4 100644 --- a/api/src/main/java/org/bukkit/event/player/PlayerAchievementAwardedEvent.java +++ b/api/src/main/java/org/bukkit/event/player/PlayerAchievementAwardedEvent.java @@ -30,10 +30,12 @@ public class PlayerAchievementAwardedEvent extends PlayerEvent implements Cancel return achievement; } + @Override public boolean isCancelled() { return isCancelled; } + @Override public void setCancelled(boolean cancel) { this.isCancelled = cancel; } diff --git a/api/src/main/java/org/bukkit/event/player/PlayerAnimationEvent.java b/api/src/main/java/org/bukkit/event/player/PlayerAnimationEvent.java index 4affca127..6cd236cd1 100644 --- a/api/src/main/java/org/bukkit/event/player/PlayerAnimationEvent.java +++ b/api/src/main/java/org/bukkit/event/player/PlayerAnimationEvent.java @@ -35,10 +35,12 @@ public class PlayerAnimationEvent extends PlayerEvent implements Cancellable { return animationType; } + @Override public boolean isCancelled() { return this.isCancelled; } + @Override public void setCancelled(boolean cancel) { this.isCancelled = cancel; } diff --git a/api/src/main/java/org/bukkit/event/player/PlayerArmorStandManipulateEvent.java b/api/src/main/java/org/bukkit/event/player/PlayerArmorStandManipulateEvent.java index 1263dffbe..f72dd3ccf 100644 --- a/api/src/main/java/org/bukkit/event/player/PlayerArmorStandManipulateEvent.java +++ b/api/src/main/java/org/bukkit/event/player/PlayerArmorStandManipulateEvent.java @@ -1,9 +1,9 @@ package org.bukkit.event.player; -import org.bukkit.inventory.EquipmentSlot; -import org.bukkit.entity.Player; import org.bukkit.entity.ArmorStand; +import org.bukkit.entity.Player; import org.bukkit.event.HandlerList; +import org.bukkit.inventory.EquipmentSlot; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; diff --git a/api/src/main/java/org/bukkit/event/player/PlayerBucketEmptyEvent.java b/api/src/main/java/org/bukkit/event/player/PlayerBucketEmptyEvent.java index 5e93f1bbb..25bd8153e 100644 --- a/api/src/main/java/org/bukkit/event/player/PlayerBucketEmptyEvent.java +++ b/api/src/main/java/org/bukkit/event/player/PlayerBucketEmptyEvent.java @@ -15,14 +15,23 @@ import org.jetbrains.annotations.NotNull; public class PlayerBucketEmptyEvent extends PlayerBucketEvent { private static final HandlerList handlers = new HandlerList(); + @Deprecated public PlayerBucketEmptyEvent(@NotNull final Player who, @NotNull final Block blockClicked, @NotNull final BlockFace blockFace, @NotNull final Material bucket, @NotNull final ItemStack itemInHand) { super(who, blockClicked, blockFace, bucket, itemInHand); } + public PlayerBucketEmptyEvent(@NotNull final Player who, @NotNull final Block block, @NotNull final Block blockClicked, @NotNull final BlockFace blockFace, @NotNull final Material bucket, @NotNull final ItemStack itemInHand) { + super(who, block, blockClicked, blockFace, bucket, itemInHand); + } // Paper start - add EquipmentSlot + @Deprecated public PlayerBucketEmptyEvent(@NotNull final Player who, @NotNull final Block blockClicked, @NotNull final BlockFace blockFace, @NotNull final Material bucket, @NotNull final ItemStack itemInHand, @org.jetbrains.annotations.Nullable final EquipmentSlot hand) { super(who, blockClicked, blockFace, bucket, itemInHand, hand); } + + public PlayerBucketEmptyEvent(@NotNull final Player who, @NotNull final Block block, @NotNull final Block blockClicked, @NotNull final BlockFace blockFace, @NotNull final Material bucket, @NotNull final ItemStack itemInHand, @org.jetbrains.annotations.Nullable final EquipmentSlot hand) { + super(who, block, blockClicked, blockFace, bucket, itemInHand, hand); + } // Paper end @NotNull diff --git a/api/src/main/java/org/bukkit/event/player/PlayerBucketEvent.java b/api/src/main/java/org/bukkit/event/player/PlayerBucketEvent.java index 280ca87bb..1e0f7ee7d 100644 --- a/api/src/main/java/org/bukkit/event/player/PlayerBucketEvent.java +++ b/api/src/main/java/org/bukkit/event/player/PlayerBucketEvent.java @@ -16,19 +16,31 @@ import org.jetbrains.annotations.Nullable; public abstract class PlayerBucketEvent extends PlayerEvent implements Cancellable { private ItemStack itemStack; private boolean cancelled = false; + private final Block block; private final Block blockClicked; private final BlockFace blockFace; private final Material bucket; private final EquipmentSlot hand; // Paper - add EquipmentSlot + @Deprecated public PlayerBucketEvent(@NotNull final Player who, @NotNull final Block blockClicked, @NotNull final BlockFace blockFace, @NotNull final Material bucket, @NotNull final ItemStack itemInHand) { - // Paper start - add EquipmentSlot - this(who, blockClicked, blockFace, bucket, itemInHand, null); + this(who, null, blockClicked.getRelative(blockFace), blockFace, bucket, itemInHand); } - public PlayerBucketEvent(@NotNull final Player who, @NotNull final Block blockClicked, @NotNull final BlockFace blockFace, @NotNull final Material bucket, @NotNull final ItemStack itemInHand, @Nullable final EquipmentSlot hand) { + public PlayerBucketEvent(@NotNull final Player who, @NotNull final Block block, @NotNull final Block blockClicked, @NotNull final BlockFace blockFace, @NotNull final Material bucket, @NotNull final ItemStack itemInHand) { + // Paper start - add EquipmentSlot + this(who, block, blockClicked, blockFace, bucket, itemInHand, null); + } + + @Deprecated + public PlayerBucketEvent(@NotNull final Player who,@NotNull final Block blockClicked, @NotNull final BlockFace blockFace, @NotNull final Material bucket, @NotNull final ItemStack itemInHand, @Nullable final EquipmentSlot hand) { + this(who, null, blockClicked, blockFace, bucket, itemInHand, hand); + } + + public PlayerBucketEvent(@NotNull final Player who, @NotNull final Block block, @NotNull final Block blockClicked, @NotNull final BlockFace blockFace, @NotNull final Material bucket, @NotNull final ItemStack itemInHand, @Nullable final EquipmentSlot hand) { // Paper end super(who); + this.block = block; this.blockClicked = blockClicked; this.blockFace = blockFace; this.itemStack = itemInHand; @@ -65,6 +77,16 @@ public abstract class PlayerBucketEvent extends PlayerEvent implements Cancellab this.itemStack = itemStack; } + /** + * Gets the block involved in this event. + * + * @return The Block which block is involved in this event + */ + @NotNull + public final Block getBlock() { + return block; + } + /** * Return the block clicked * @@ -97,10 +119,12 @@ public abstract class PlayerBucketEvent extends PlayerEvent implements Cancellab } // Paper end + @Override public boolean isCancelled() { return cancelled; } + @Override public void setCancelled(boolean cancel) { this.cancelled = cancel; } diff --git a/api/src/main/java/org/bukkit/event/player/PlayerBucketFillEvent.java b/api/src/main/java/org/bukkit/event/player/PlayerBucketFillEvent.java index 15be7128b..56f1cc2d7 100644 --- a/api/src/main/java/org/bukkit/event/player/PlayerBucketFillEvent.java +++ b/api/src/main/java/org/bukkit/event/player/PlayerBucketFillEvent.java @@ -15,15 +15,25 @@ import org.jetbrains.annotations.NotNull; public class PlayerBucketFillEvent extends PlayerBucketEvent { private static final HandlerList handlers = new HandlerList(); + @Deprecated public PlayerBucketFillEvent(@NotNull final Player who, @NotNull final Block blockClicked, @NotNull final BlockFace blockFace, @NotNull final Material bucket, @NotNull final ItemStack itemInHand) { super(who, blockClicked, blockFace, bucket, itemInHand); } + public PlayerBucketFillEvent(@NotNull final Player who, @NotNull final Block block, @NotNull final Block blockClicked, @NotNull final BlockFace blockFace, @NotNull final Material bucket, @NotNull final ItemStack itemInHand) { + super(who, block, blockClicked, blockFace, bucket, itemInHand); + } // Paper start - add EquipmentSlot + @Deprecated public PlayerBucketFillEvent(@NotNull final Player who, @NotNull final Block blockClicked, @NotNull final BlockFace blockFace, @NotNull final Material bucket, @NotNull final ItemStack itemInHand, @org.jetbrains.annotations.Nullable final EquipmentSlot hand) { super(who, blockClicked, blockFace, bucket, itemInHand, hand); } + + // Paper start - add EquipmentSlot + public PlayerBucketFillEvent(@NotNull final Player who, @NotNull Block block, @NotNull final Block blockClicked, @NotNull final BlockFace blockFace, @NotNull final Material bucket, @NotNull final ItemStack itemInHand, @org.jetbrains.annotations.Nullable final EquipmentSlot hand) { + super(who, block, blockClicked, blockFace, bucket, itemInHand, hand); + } // Paper end @NotNull diff --git a/api/src/main/java/org/bukkit/event/player/PlayerChatEvent.java b/api/src/main/java/org/bukkit/event/player/PlayerChatEvent.java index fec303c9c..26966167b 100644 --- a/api/src/main/java/org/bukkit/event/player/PlayerChatEvent.java +++ b/api/src/main/java/org/bukkit/event/player/PlayerChatEvent.java @@ -2,7 +2,6 @@ package org.bukkit.event.player; import java.util.HashSet; import java.util.Set; - import org.apache.commons.lang.Validate; import org.bukkit.Warning; import org.bukkit.entity.Player; @@ -43,10 +42,12 @@ public class PlayerChatEvent extends PlayerEvent implements Cancellable { this.recipients = recipients; } + @Override public boolean isCancelled() { return cancel; } + @Override public void setCancelled(boolean cancel) { this.cancel = cancel; } diff --git a/api/src/main/java/org/bukkit/event/player/PlayerChatTabCompleteEvent.java b/api/src/main/java/org/bukkit/event/player/PlayerChatTabCompleteEvent.java index c3ac37928..0b99c7fb2 100644 --- a/api/src/main/java/org/bukkit/event/player/PlayerChatTabCompleteEvent.java +++ b/api/src/main/java/org/bukkit/event/player/PlayerChatTabCompleteEvent.java @@ -1,7 +1,6 @@ package org.bukkit.event.player; import java.util.Collection; - import org.apache.commons.lang.Validate; import org.bukkit.Warning; import org.bukkit.entity.Player; diff --git a/api/src/main/java/org/bukkit/event/player/PlayerCommandPreprocessEvent.java b/api/src/main/java/org/bukkit/event/player/PlayerCommandPreprocessEvent.java index 66c930da0..a6dae9107 100644 --- a/api/src/main/java/org/bukkit/event/player/PlayerCommandPreprocessEvent.java +++ b/api/src/main/java/org/bukkit/event/player/PlayerCommandPreprocessEvent.java @@ -2,7 +2,6 @@ package org.bukkit.event.player; import java.util.HashSet; import java.util.Set; - import org.apache.commons.lang.Validate; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; @@ -64,10 +63,12 @@ public class PlayerCommandPreprocessEvent extends PlayerEvent implements Cancell this.message = message; } + @Override public boolean isCancelled() { return cancel; } + @Override public void setCancelled(boolean cancel) { this.cancel = cancel; } diff --git a/api/src/main/java/org/bukkit/event/player/PlayerDropItemEvent.java b/api/src/main/java/org/bukkit/event/player/PlayerDropItemEvent.java index 4ac31e122..aca500f32 100644 --- a/api/src/main/java/org/bukkit/event/player/PlayerDropItemEvent.java +++ b/api/src/main/java/org/bukkit/event/player/PlayerDropItemEvent.java @@ -29,10 +29,12 @@ public class PlayerDropItemEvent extends PlayerEvent implements Cancellable { return drop; } + @Override public boolean isCancelled() { return cancel; } + @Override public void setCancelled(boolean cancel) { this.cancel = cancel; } diff --git a/api/src/main/java/org/bukkit/event/player/PlayerEditBookEvent.java b/api/src/main/java/org/bukkit/event/player/PlayerEditBookEvent.java index 44e62e61b..c8fda418b 100644 --- a/api/src/main/java/org/bukkit/event/player/PlayerEditBookEvent.java +++ b/api/src/main/java/org/bukkit/event/player/PlayerEditBookEvent.java @@ -122,10 +122,12 @@ public class PlayerEditBookEvent extends PlayerEvent implements Cancellable { return handlers; } + @Override public boolean isCancelled() { return cancel; } + @Override public void setCancelled(boolean cancel) { this.cancel = cancel; } diff --git a/api/src/main/java/org/bukkit/event/player/PlayerEvent.java b/api/src/main/java/org/bukkit/event/player/PlayerEvent.java index 66193e0cc..793b661b6 100644 --- a/api/src/main/java/org/bukkit/event/player/PlayerEvent.java +++ b/api/src/main/java/org/bukkit/event/player/PlayerEvent.java @@ -1,18 +1,14 @@ package org.bukkit.event.player; -import org.bukkit.World; import org.bukkit.entity.Player; import org.bukkit.event.Event; import org.jetbrains.annotations.NotNull; -import io.akarin.server.api.event.WorldAttachedEvent; - /** * Represents a player related event */ -public abstract class PlayerEvent extends Event implements WorldAttachedEvent { // Akarin +public abstract class PlayerEvent extends Event { protected Player player; - @Override @NotNull public World getWorld() { return player.getWorld(); } // Akarin public PlayerEvent(@NotNull final Player who) { player = who; diff --git a/api/src/main/java/org/bukkit/event/player/PlayerFishEvent.java b/api/src/main/java/org/bukkit/event/player/PlayerFishEvent.java index e31c1492c..4d3ff7b29 100644 --- a/api/src/main/java/org/bukkit/event/player/PlayerFishEvent.java +++ b/api/src/main/java/org/bukkit/event/player/PlayerFishEvent.java @@ -1,9 +1,9 @@ package org.bukkit.event.player; -import org.bukkit.entity.Player; -import org.bukkit.event.Cancellable; import org.bukkit.entity.Entity; import org.bukkit.entity.FishHook; +import org.bukkit.entity.Player; +import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -50,10 +50,12 @@ public class PlayerFishEvent extends PlayerEvent implements Cancellable { return hookEntity; } + @Override public boolean isCancelled() { return cancel; } + @Override public void setCancelled(boolean cancel) { this.cancel = cancel; } @@ -129,10 +131,14 @@ public class PlayerFishEvent extends PlayerEvent implements Cancellable { */ IN_GROUND, /** - * When a player fails to catch anything while fishing usually due to - * poor aiming or timing. + * When a player fails to catch a bite while fishing usually due to + * poor timing. */ FAILED_ATTEMPT, + /** + * When a player reels in their hook without receiving any bites. + */ + REEL_IN, /** * Called when there is a bite on the hook and it is ready to be reeled * in. diff --git a/api/src/main/java/org/bukkit/event/player/PlayerGameModeChangeEvent.java b/api/src/main/java/org/bukkit/event/player/PlayerGameModeChangeEvent.java index 020faee1c..4b96e0573 100644 --- a/api/src/main/java/org/bukkit/event/player/PlayerGameModeChangeEvent.java +++ b/api/src/main/java/org/bukkit/event/player/PlayerGameModeChangeEvent.java @@ -19,10 +19,12 @@ public class PlayerGameModeChangeEvent extends PlayerEvent implements Cancellabl this.newGameMode = newGameMode; } + @Override public boolean isCancelled() { return cancelled; } + @Override public void setCancelled(boolean cancel) { this.cancelled = cancel; } diff --git a/api/src/main/java/org/bukkit/event/player/PlayerInteractAtEntityEvent.java b/api/src/main/java/org/bukkit/event/player/PlayerInteractAtEntityEvent.java index 1075dbb81..3f24d302e 100644 --- a/api/src/main/java/org/bukkit/event/player/PlayerInteractAtEntityEvent.java +++ b/api/src/main/java/org/bukkit/event/player/PlayerInteractAtEntityEvent.java @@ -13,6 +13,9 @@ import org.jetbrains.annotations.NotNull; *
    * Note that the client may sometimes spuriously send this packet in addition to {@link PlayerInteractEntityEvent}. * Users are advised to listen to this (parent) class unless specifically required. + *
    + * Note that interacting with Armor Stands fires this event only and not its parent and as such users are expressly required + * to listen to this event for that scenario. */ public class PlayerInteractAtEntityEvent extends PlayerInteractEntityEvent { private static final HandlerList handlers = new HandlerList(); diff --git a/api/src/main/java/org/bukkit/event/player/PlayerInteractEntityEvent.java b/api/src/main/java/org/bukkit/event/player/PlayerInteractEntityEvent.java index c4406610f..1d3d62969 100644 --- a/api/src/main/java/org/bukkit/event/player/PlayerInteractEntityEvent.java +++ b/api/src/main/java/org/bukkit/event/player/PlayerInteractEntityEvent.java @@ -26,10 +26,12 @@ public class PlayerInteractEntityEvent extends PlayerEvent implements Cancellabl this.hand = hand; } + @Override public boolean isCancelled() { return cancelled; } + @Override public void setCancelled(boolean cancel) { this.cancelled = cancel; } diff --git a/api/src/main/java/org/bukkit/event/player/PlayerInteractEvent.java b/api/src/main/java/org/bukkit/event/player/PlayerInteractEvent.java index 3563aac37..1208e1f8c 100644 --- a/api/src/main/java/org/bukkit/event/player/PlayerInteractEvent.java +++ b/api/src/main/java/org/bukkit/event/player/PlayerInteractEvent.java @@ -1,15 +1,15 @@ package org.bukkit.event.player; +import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; -import org.bukkit.event.HandlerList; -import org.bukkit.inventory.ItemStack; -import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; import org.bukkit.event.block.Action; import org.bukkit.event.block.BlockCanBuildEvent; import org.bukkit.inventory.EquipmentSlot; +import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -66,7 +66,14 @@ public class PlayerInteractEvent extends PlayerEvent implements Cancellable { * prevent buckets from placing water and so forth * * @return boolean cancellation state + * @deprecated This event has two possible cancellation states, one for + * {@link #useInteractedBlock()} and one for {@link #useItemInHand()}. It is + * possible a call might have the former false, but the latter true, eg in + * the case of using a firework whilst gliding. Callers should check the + * relevant methods individually. */ + @Deprecated + @Override public boolean isCancelled() { return useInteractedBlock() == Result.DENY; } @@ -81,6 +88,7 @@ public class PlayerInteractEvent extends PlayerEvent implements Cancellable { * * @param cancel true if you wish to cancel this event */ + @Override public void setCancelled(boolean cancel) { setUseInteractedBlock(cancel ? Result.DENY : useInteractedBlock() == Result.DENY ? Result.DEFAULT : useInteractedBlock()); setUseItemInHand(cancel ? Result.DENY : useItemInHand() == Result.DENY ? Result.DEFAULT : useItemInHand()); diff --git a/api/src/main/java/org/bukkit/event/player/PlayerItemConsumeEvent.java b/api/src/main/java/org/bukkit/event/player/PlayerItemConsumeEvent.java index 864c0a9e6..373f4b5b5 100644 --- a/api/src/main/java/org/bukkit/event/player/PlayerItemConsumeEvent.java +++ b/api/src/main/java/org/bukkit/event/player/PlayerItemConsumeEvent.java @@ -82,10 +82,12 @@ public class PlayerItemConsumeEvent extends PlayerEvent implements Cancellable { } // Paper end + @Override public boolean isCancelled() { return this.isCancelled; } + @Override public void setCancelled(boolean cancel) { this.isCancelled = cancel; } diff --git a/api/src/main/java/org/bukkit/event/player/PlayerItemHeldEvent.java b/api/src/main/java/org/bukkit/event/player/PlayerItemHeldEvent.java index d5100d8fe..39048573a 100644 --- a/api/src/main/java/org/bukkit/event/player/PlayerItemHeldEvent.java +++ b/api/src/main/java/org/bukkit/event/player/PlayerItemHeldEvent.java @@ -38,10 +38,12 @@ public class PlayerItemHeldEvent extends PlayerEvent implements Cancellable { return current; } + @Override public boolean isCancelled() { return cancel; } + @Override public void setCancelled(boolean cancel) { this.cancel = cancel; } diff --git a/api/src/main/java/org/bukkit/event/player/PlayerJoinEvent.java b/api/src/main/java/org/bukkit/event/player/PlayerJoinEvent.java index 4c0920e21..d06684aba 100644 --- a/api/src/main/java/org/bukkit/event/player/PlayerJoinEvent.java +++ b/api/src/main/java/org/bukkit/event/player/PlayerJoinEvent.java @@ -3,6 +3,7 @@ package org.bukkit.event.player; import org.bukkit.entity.Player; import org.bukkit.event.HandlerList; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Called when a player joins a server @@ -11,7 +12,7 @@ public class PlayerJoinEvent extends PlayerEvent { private static final HandlerList handlers = new HandlerList(); private String joinMessage; - public PlayerJoinEvent(@NotNull final Player playerJoined, @NotNull final String joinMessage) { + public PlayerJoinEvent(@NotNull final Player playerJoined, @Nullable final String joinMessage) { super(playerJoined); this.joinMessage = joinMessage; } @@ -19,9 +20,9 @@ public class PlayerJoinEvent extends PlayerEvent { /** * Gets the join message to send to all online players * - * @return string join message + * @return string join message. Can be null */ - @NotNull + @Nullable public String getJoinMessage() { return joinMessage; } @@ -29,9 +30,9 @@ public class PlayerJoinEvent extends PlayerEvent { /** * Sets the join message to send to all online players * - * @param joinMessage join message + * @param joinMessage join message. If null, no message will be sent */ - public void setJoinMessage(@NotNull String joinMessage) { + public void setJoinMessage(@Nullable String joinMessage) { this.joinMessage = joinMessage; } diff --git a/api/src/main/java/org/bukkit/event/player/PlayerKickEvent.java b/api/src/main/java/org/bukkit/event/player/PlayerKickEvent.java index fa1105f4e..14c337f15 100644 --- a/api/src/main/java/org/bukkit/event/player/PlayerKickEvent.java +++ b/api/src/main/java/org/bukkit/event/player/PlayerKickEvent.java @@ -41,10 +41,12 @@ public class PlayerKickEvent extends PlayerEvent implements Cancellable { return leaveMessage; } + @Override public boolean isCancelled() { return cancel; } + @Override public void setCancelled(boolean cancel) { this.cancel = cancel; } diff --git a/api/src/main/java/org/bukkit/event/player/PlayerLoginEvent.java b/api/src/main/java/org/bukkit/event/player/PlayerLoginEvent.java index b493173e2..084ca8cfc 100644 --- a/api/src/main/java/org/bukkit/event/player/PlayerLoginEvent.java +++ b/api/src/main/java/org/bukkit/event/player/PlayerLoginEvent.java @@ -1,7 +1,6 @@ package org.bukkit.event.player; import java.net.InetAddress; - import org.bukkit.entity.Player; import org.bukkit.event.HandlerList; import org.jetbrains.annotations.NotNull; @@ -29,7 +28,7 @@ public class PlayerLoginEvent extends PlayerEvent { * @param hostname The hostname that was used to connect to the server * @param address The address the player used to connect, provided for * timing issues - * @param realAddress The unspoofed, actual address, that the player used to connect + * @param realAddress the actual, unspoofed connecting address */ public PlayerLoginEvent(@NotNull final Player player, @NotNull final String hostname, @NotNull final InetAddress address, final @NotNull InetAddress realAddress) { // Spigot super(player); @@ -53,7 +52,7 @@ public class PlayerLoginEvent extends PlayerEvent { * timing issues * @param result The result status for this event * @param message The message to be displayed if result denies login - * @param realAddress The unspoofed, actual address, that the player used to connect + * @param realAddress the actual, unspoofed connecting address */ public PlayerLoginEvent(@NotNull final Player player, @NotNull String hostname, @NotNull final InetAddress address, @NotNull final Result result, @NotNull final String message, @NotNull final InetAddress realAddress) { // Spigot this(player, hostname, address, realAddress); // Spigot diff --git a/api/src/main/java/org/bukkit/event/player/PlayerMoveEvent.java b/api/src/main/java/org/bukkit/event/player/PlayerMoveEvent.java index 8b9018451..1a58734d9 100644 --- a/api/src/main/java/org/bukkit/event/player/PlayerMoveEvent.java +++ b/api/src/main/java/org/bukkit/event/player/PlayerMoveEvent.java @@ -33,6 +33,7 @@ public class PlayerMoveEvent extends PlayerEvent implements Cancellable { * * @return true if this event is cancelled */ + @Override public boolean isCancelled() { return cancel; } @@ -47,6 +48,7 @@ public class PlayerMoveEvent extends PlayerEvent implements Cancellable { * * @param cancel true if you wish to cancel this event */ + @Override public void setCancelled(boolean cancel) { this.cancel = cancel; } @@ -76,7 +78,7 @@ public class PlayerMoveEvent extends PlayerEvent implements Cancellable { * * @return Location the player moved to */ - @Nullable + @NotNull // Paper public Location getTo() { return to; } diff --git a/api/src/main/java/org/bukkit/event/player/PlayerPickupArrowEvent.java b/api/src/main/java/org/bukkit/event/player/PlayerPickupArrowEvent.java index 01870a063..c9a866394 100644 --- a/api/src/main/java/org/bukkit/event/player/PlayerPickupArrowEvent.java +++ b/api/src/main/java/org/bukkit/event/player/PlayerPickupArrowEvent.java @@ -1,6 +1,6 @@ package org.bukkit.event.player; -import org.bukkit.entity.Arrow; +import org.bukkit.entity.AbstractArrow; import org.bukkit.entity.Item; import org.bukkit.entity.Player; import org.jetbrains.annotations.NotNull; @@ -10,9 +10,9 @@ import org.jetbrains.annotations.NotNull; */ public class PlayerPickupArrowEvent extends PlayerPickupItemEvent { - private final Arrow arrow; + private final AbstractArrow arrow; - public PlayerPickupArrowEvent(@NotNull final Player player, @NotNull final Item item, @NotNull final Arrow arrow) { + public PlayerPickupArrowEvent(@NotNull final Player player, @NotNull final Item item, @NotNull final AbstractArrow arrow) { super(player, item, 0); this.arrow = arrow; } @@ -23,7 +23,7 @@ public class PlayerPickupArrowEvent extends PlayerPickupItemEvent { * @return The arrow being picked up */ @NotNull - public Arrow getArrow() { + public AbstractArrow getArrow() { return arrow; } } diff --git a/api/src/main/java/org/bukkit/event/player/PlayerPickupItemEvent.java b/api/src/main/java/org/bukkit/event/player/PlayerPickupItemEvent.java index 5777d3802..18d82c111 100644 --- a/api/src/main/java/org/bukkit/event/player/PlayerPickupItemEvent.java +++ b/api/src/main/java/org/bukkit/event/player/PlayerPickupItemEvent.java @@ -67,10 +67,12 @@ public class PlayerPickupItemEvent extends PlayerEvent implements Cancellable { } // Paper End + @Override public boolean isCancelled() { return cancel; } + @Override public void setCancelled(boolean cancel) { this.cancel = cancel; this.flyAtPlayer = !cancel; // Paper diff --git a/api/src/main/java/org/bukkit/event/player/PlayerPortalEvent.java b/api/src/main/java/org/bukkit/event/player/PlayerPortalEvent.java index f8821c78e..5b7550781 100644 --- a/api/src/main/java/org/bukkit/event/player/PlayerPortalEvent.java +++ b/api/src/main/java/org/bukkit/event/player/PlayerPortalEvent.java @@ -1,7 +1,6 @@ package org.bukkit.event.player; import org.bukkit.Location; -import org.bukkit.TravelAgent; import org.bukkit.entity.Player; import org.bukkit.event.HandlerList; import org.jetbrains.annotations.NotNull; @@ -15,68 +14,13 @@ import org.jetbrains.annotations.Nullable; */ public class PlayerPortalEvent extends PlayerTeleportEvent { private static final HandlerList handlers = new HandlerList(); - protected boolean useTravelAgent = true; - protected TravelAgent travelAgent; - public PlayerPortalEvent(@NotNull final Player player, @NotNull final Location from, @Nullable final Location to, @NotNull final TravelAgent pta) { + public PlayerPortalEvent(@NotNull final Player player, @NotNull final Location from, @Nullable final Location to) { super(player, from, to); - this.travelAgent = pta; } - public PlayerPortalEvent(@NotNull Player player, @NotNull Location from, @Nullable Location to, @NotNull TravelAgent pta, @NotNull TeleportCause cause) { + public PlayerPortalEvent(@NotNull Player player, @NotNull Location from, @Nullable Location to, @NotNull TeleportCause cause) { super(player, from, to, cause); - this.travelAgent = pta; - } - - /** - * Sets whether or not the Travel Agent will be used. - *

    - * If this is set to true, the TravelAgent will try to find a Portal at - * the {@link #getTo()} Location, and will try to create one if there is - * none. - *

    - * If this is set to false, the {@link #getPlayer()} will only be - * teleported to the {@link #getTo()} Location. - * - * @param useTravelAgent whether to use the Travel Agent - */ - public void useTravelAgent(boolean useTravelAgent) { - this.useTravelAgent = useTravelAgent; - } - - /** - * Gets whether or not the Travel Agent will be used. - *

    - * If this is set to true, the TravelAgent will try to find a Portal at - * the {@link #getTo()} Location, and will try to create one if there is - * none. - *

    - * If this is set to false, the {@link #getPlayer()}} will only be - * teleported to the {@link #getTo()} Location. - * - * @return whether to use the Travel Agent - */ - public boolean useTravelAgent() { - return useTravelAgent && travelAgent != null; - } - - /** - * Gets the Travel Agent used (or not) in this event. - * - * @return the Travel Agent used (or not) in this event - */ - @NotNull - public TravelAgent getPortalTravelAgent() { - return this.travelAgent; - } - - /** - * Sets the Travel Agent used (or not) in this event. - * - * @param travelAgent the Travel Agent used (or not) in this event - */ - public void setPortalTravelAgent(@NotNull TravelAgent travelAgent) { - this.travelAgent = travelAgent; } @NotNull diff --git a/api/src/main/java/org/bukkit/event/player/PlayerPreLoginEvent.java b/api/src/main/java/org/bukkit/event/player/PlayerPreLoginEvent.java index a23a06a4b..63a963202 100644 --- a/api/src/main/java/org/bukkit/event/player/PlayerPreLoginEvent.java +++ b/api/src/main/java/org/bukkit/event/player/PlayerPreLoginEvent.java @@ -2,7 +2,6 @@ package org.bukkit.event.player; import java.net.InetAddress; import java.util.UUID; - import org.bukkit.Warning; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; diff --git a/api/src/main/java/org/bukkit/event/player/PlayerQuitEvent.java b/api/src/main/java/org/bukkit/event/player/PlayerQuitEvent.java index 8e55e8393..d70c25f40 100644 --- a/api/src/main/java/org/bukkit/event/player/PlayerQuitEvent.java +++ b/api/src/main/java/org/bukkit/event/player/PlayerQuitEvent.java @@ -3,6 +3,7 @@ package org.bukkit.event.player; import org.bukkit.entity.Player; import org.bukkit.event.HandlerList; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Called when a player leaves a server @@ -11,7 +12,7 @@ public class PlayerQuitEvent extends PlayerEvent { private static final HandlerList handlers = new HandlerList(); private String quitMessage; - public PlayerQuitEvent(@NotNull final Player who, @NotNull final String quitMessage) { + public PlayerQuitEvent(@NotNull final Player who, @Nullable final String quitMessage) { super(who); this.quitMessage = quitMessage; } @@ -21,7 +22,7 @@ public class PlayerQuitEvent extends PlayerEvent { * * @return string quit message */ - @NotNull + @Nullable public String getQuitMessage() { return quitMessage; } @@ -31,7 +32,7 @@ public class PlayerQuitEvent extends PlayerEvent { * * @param quitMessage quit message */ - public void setQuitMessage(@NotNull String quitMessage) { + public void setQuitMessage(@Nullable String quitMessage) { this.quitMessage = quitMessage; } diff --git a/api/src/main/java/org/bukkit/event/player/PlayerShearEntityEvent.java b/api/src/main/java/org/bukkit/event/player/PlayerShearEntityEvent.java index 874349138..93429c533 100644 --- a/api/src/main/java/org/bukkit/event/player/PlayerShearEntityEvent.java +++ b/api/src/main/java/org/bukkit/event/player/PlayerShearEntityEvent.java @@ -20,10 +20,12 @@ public class PlayerShearEntityEvent extends PlayerEvent implements Cancellable { this.what = what; } + @Override public boolean isCancelled() { return cancel; } + @Override public void setCancelled(boolean cancel) { this.cancel = cancel; } diff --git a/api/src/main/java/org/bukkit/event/player/PlayerStatisticIncrementEvent.java b/api/src/main/java/org/bukkit/event/player/PlayerStatisticIncrementEvent.java index ae7d0e6e3..f971844bf 100644 --- a/api/src/main/java/org/bukkit/event/player/PlayerStatisticIncrementEvent.java +++ b/api/src/main/java/org/bukkit/event/player/PlayerStatisticIncrementEvent.java @@ -102,10 +102,12 @@ public class PlayerStatisticIncrementEvent extends PlayerEvent implements Cancel return material; } + @Override public boolean isCancelled() { return isCancelled; } + @Override public void setCancelled(boolean cancel) { this.isCancelled = cancel; } diff --git a/api/src/main/java/org/bukkit/event/player/PlayerTakeLecternBookEvent.java b/api/src/main/java/org/bukkit/event/player/PlayerTakeLecternBookEvent.java new file mode 100644 index 000000000..5ef664a65 --- /dev/null +++ b/api/src/main/java/org/bukkit/event/player/PlayerTakeLecternBookEvent.java @@ -0,0 +1,67 @@ +package org.bukkit.event.player; + +import org.bukkit.block.Lectern; +import org.bukkit.entity.Player; +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; +import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * This event is called when a player clicks the button to take a book of a + * Lectern. If this event is cancelled the book remains on the lectern. + */ +public class PlayerTakeLecternBookEvent extends PlayerEvent implements Cancellable { + + private static final HandlerList handlers = new HandlerList(); + // + private boolean cancelled; + private final Lectern lectern; + + public PlayerTakeLecternBookEvent(@NotNull Player who, @NotNull Lectern lectern) { + super(who); + this.lectern = lectern; + } + + /** + * Gets the lectern involved. + * + * @return the Lectern + */ + @NotNull + public Lectern getLectern() { + return lectern; + } + + /** + * Gets the current ItemStack on the lectern. + * + * @return the ItemStack on the Lectern + */ + @Nullable + public ItemStack getBook() { + return lectern.getInventory().getItem(0); + } + + @Override + public boolean isCancelled() { + return cancelled; + } + + @Override + public void setCancelled(boolean cancel) { + this.cancelled = cancel; + } + + @NotNull + @Override + public HandlerList getHandlers() { + return handlers; + } + + @NotNull + public static HandlerList getHandlerList() { + return handlers; + } +} diff --git a/api/src/main/java/org/bukkit/event/player/PlayerToggleFlightEvent.java b/api/src/main/java/org/bukkit/event/player/PlayerToggleFlightEvent.java index 3e53cf9c4..9c200f8ac 100644 --- a/api/src/main/java/org/bukkit/event/player/PlayerToggleFlightEvent.java +++ b/api/src/main/java/org/bukkit/event/player/PlayerToggleFlightEvent.java @@ -27,10 +27,12 @@ public class PlayerToggleFlightEvent extends PlayerEvent implements Cancellable return isFlying; } + @Override public boolean isCancelled() { return cancel; } + @Override public void setCancelled(boolean cancel) { this.cancel = cancel; } diff --git a/api/src/main/java/org/bukkit/event/player/PlayerToggleSneakEvent.java b/api/src/main/java/org/bukkit/event/player/PlayerToggleSneakEvent.java index 68d902ae2..348e5b5e5 100644 --- a/api/src/main/java/org/bukkit/event/player/PlayerToggleSneakEvent.java +++ b/api/src/main/java/org/bukkit/event/player/PlayerToggleSneakEvent.java @@ -27,10 +27,12 @@ public class PlayerToggleSneakEvent extends PlayerEvent implements Cancellable { return isSneaking; } + @Override public boolean isCancelled() { return cancel; } + @Override public void setCancelled(boolean cancel) { this.cancel = cancel; } diff --git a/api/src/main/java/org/bukkit/event/player/PlayerToggleSprintEvent.java b/api/src/main/java/org/bukkit/event/player/PlayerToggleSprintEvent.java index 3b84960d6..dc8cf2197 100644 --- a/api/src/main/java/org/bukkit/event/player/PlayerToggleSprintEvent.java +++ b/api/src/main/java/org/bukkit/event/player/PlayerToggleSprintEvent.java @@ -27,10 +27,12 @@ public class PlayerToggleSprintEvent extends PlayerEvent implements Cancellable return isSprinting; } + @Override public boolean isCancelled() { return cancel; } + @Override public void setCancelled(boolean cancel) { this.cancel = cancel; } diff --git a/api/src/main/java/org/bukkit/event/player/PlayerUnleashEntityEvent.java b/api/src/main/java/org/bukkit/event/player/PlayerUnleashEntityEvent.java index e2672aac1..cf78950b5 100644 --- a/api/src/main/java/org/bukkit/event/player/PlayerUnleashEntityEvent.java +++ b/api/src/main/java/org/bukkit/event/player/PlayerUnleashEntityEvent.java @@ -28,10 +28,12 @@ public class PlayerUnleashEntityEvent extends EntityUnleashEvent implements Canc return player; } + @Override public boolean isCancelled() { return cancelled; } + @Override public void setCancelled(boolean cancel) { this.cancelled = cancel; } diff --git a/api/src/main/java/org/bukkit/event/player/PlayerVelocityEvent.java b/api/src/main/java/org/bukkit/event/player/PlayerVelocityEvent.java index c081c03ee..dee4a8e6f 100644 --- a/api/src/main/java/org/bukkit/event/player/PlayerVelocityEvent.java +++ b/api/src/main/java/org/bukkit/event/player/PlayerVelocityEvent.java @@ -19,10 +19,12 @@ public class PlayerVelocityEvent extends PlayerEvent implements Cancellable { this.velocity = velocity; } + @Override public boolean isCancelled() { return cancel; } + @Override public void setCancelled(boolean cancel) { this.cancel = cancel; } diff --git a/api/src/main/java/org/bukkit/event/raid/RaidEvent.java b/api/src/main/java/org/bukkit/event/raid/RaidEvent.java new file mode 100644 index 000000000..b2ff4bc33 --- /dev/null +++ b/api/src/main/java/org/bukkit/event/raid/RaidEvent.java @@ -0,0 +1,29 @@ +package org.bukkit.event.raid; + +import org.bukkit.Raid; +import org.bukkit.World; +import org.bukkit.event.world.WorldEvent; +import org.jetbrains.annotations.NotNull; + +/** + * Represents events related to raids. + */ +public abstract class RaidEvent extends WorldEvent { + + private final Raid raid; + + protected RaidEvent(@NotNull Raid raid, @NotNull World world) { + super(world); + this.raid = raid; + } + + /** + * Returns the raid involved with this event. + * + * @return Raid + */ + @NotNull + public Raid getRaid() { + return raid; + } +} diff --git a/api/src/main/java/org/bukkit/event/raid/RaidFinishEvent.java b/api/src/main/java/org/bukkit/event/raid/RaidFinishEvent.java new file mode 100644 index 000000000..f0d280b8c --- /dev/null +++ b/api/src/main/java/org/bukkit/event/raid/RaidFinishEvent.java @@ -0,0 +1,48 @@ +package org.bukkit.event.raid; + +import java.util.Collections; +import java.util.List; +import org.bukkit.Raid; +import org.bukkit.World; +import org.bukkit.entity.Player; +import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; + +/** + * This event is called when a {@link Raid} was complete with a clear result. + */ +public class RaidFinishEvent extends RaidEvent { + + private static final HandlerList handlers = new HandlerList(); + // + private final List winners; + + public RaidFinishEvent(@NotNull Raid raid, @NotNull World world, @NotNull List winners) { + super(raid, world); + this.winners = winners; + } + + /** + * Returns an immutable list contains all winners. + *
    + * Note: Players who are considered as heroes but were not online at the + * end would not be included in this list. + * + * @return winners + */ + @NotNull + public List getWinners() { + return Collections.unmodifiableList(winners); + } + + @NotNull + @Override + public HandlerList getHandlers() { + return handlers; + } + + @NotNull + public static HandlerList getHandlerList() { + return handlers; + } +} diff --git a/api/src/main/java/org/bukkit/event/raid/RaidSpawnWaveEvent.java b/api/src/main/java/org/bukkit/event/raid/RaidSpawnWaveEvent.java new file mode 100644 index 000000000..cd58dd7de --- /dev/null +++ b/api/src/main/java/org/bukkit/event/raid/RaidSpawnWaveEvent.java @@ -0,0 +1,58 @@ +package org.bukkit.event.raid; + +import java.util.Collections; +import java.util.List; +import org.bukkit.Raid; +import org.bukkit.World; +import org.bukkit.entity.Raider; +import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * Called when a raid wave spawns. + */ +public class RaidSpawnWaveEvent extends RaidEvent { + + private static final HandlerList handlers = new HandlerList(); + // + private final List raiders; + private final Raider leader; + + public RaidSpawnWaveEvent(@NotNull Raid raid, @NotNull World world, @Nullable Raider leader, @NotNull List raiders) { + super(raid, world); + this.raiders = raiders; + this.leader = leader; + } + + /** + * Returns the patrol leader. + * + * @return {@link Raider} + */ + @Nullable + public Raider getPatrolLeader() { + return leader; + } + + /** + * Returns all {@link Raider} that spawned in this wave. + * + * @return an immutable list of raiders + */ + @NotNull + public List getRaiders() { + return Collections.unmodifiableList(raiders); + } + + @NotNull + @Override + public HandlerList getHandlers() { + return handlers; + } + + @NotNull + public static HandlerList getHandlerList() { + return handlers; + } +} diff --git a/api/src/main/java/org/bukkit/event/raid/RaidStopEvent.java b/api/src/main/java/org/bukkit/event/raid/RaidStopEvent.java new file mode 100644 index 000000000..9e852ac97 --- /dev/null +++ b/api/src/main/java/org/bukkit/event/raid/RaidStopEvent.java @@ -0,0 +1,66 @@ +package org.bukkit.event.raid; + +import org.bukkit.Raid; +import org.bukkit.World; +import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; + +/** + * Called when a {@link Raid} is stopped. + */ +public class RaidStopEvent extends RaidEvent { + + private static final HandlerList handlers = new HandlerList(); + // + private final Reason reason; + + public RaidStopEvent(@NotNull Raid raid, @NotNull World world, @NotNull Reason reason) { + super(raid, world); + this.reason = reason; + } + + /** + * Returns the stop reason. + * + * @return Reason + */ + @NotNull + public Reason getReason() { + return reason; + } + + @NotNull + @Override + public HandlerList getHandlers() { + return handlers; + } + + @NotNull + public static HandlerList getHandlerList() { + return handlers; + } + + public enum Reason { + + /** + * Because the difficulty has been changed to peaceful. + */ + PEACE, + /** + * The raid took a long time without a final result. + */ + TIMEOUT, + /** + * Finished the raid. + */ + FINISHED, + /** + * Couldn't find a suitable place to spawn raiders. + */ + UNSPAWNABLE, + /** + * The place where the raid occurs no longer be a village. + */ + NOT_IN_VILLAGE + } +} diff --git a/api/src/main/java/org/bukkit/event/raid/RaidTriggerEvent.java b/api/src/main/java/org/bukkit/event/raid/RaidTriggerEvent.java new file mode 100644 index 000000000..128e43cf1 --- /dev/null +++ b/api/src/main/java/org/bukkit/event/raid/RaidTriggerEvent.java @@ -0,0 +1,56 @@ +package org.bukkit.event.raid; + +import org.bukkit.Raid; +import org.bukkit.World; +import org.bukkit.entity.Player; +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; + +/** + * Called when a {@link Raid} is triggered (e.g: a player with Bad Omen effect + * enters a village). + */ +public class RaidTriggerEvent extends RaidEvent implements Cancellable { + + private static final HandlerList handlers = new HandlerList(); + // + private final Player player; + private boolean cancel; + + public RaidTriggerEvent(@NotNull Raid raid, @NotNull World world, @NotNull Player player) { + super(raid, world); + this.player = player; + } + + /** + * Returns the player who triggered the raid. + * + * @return triggering player + */ + @NotNull + public Player getPlayer() { + return player; + } + + @Override + public boolean isCancelled() { + return cancel; + } + + @Override + public void setCancelled(boolean cancel) { + this.cancel = cancel; + } + + @NotNull + @Override + public HandlerList getHandlers() { + return handlers; + } + + @NotNull + public static HandlerList getHandlerList() { + return handlers; + } +} diff --git a/api/src/main/java/org/bukkit/event/server/BroadcastMessageEvent.java b/api/src/main/java/org/bukkit/event/server/BroadcastMessageEvent.java index 4bf9d5d82..03bfca9d3 100644 --- a/api/src/main/java/org/bukkit/event/server/BroadcastMessageEvent.java +++ b/api/src/main/java/org/bukkit/event/server/BroadcastMessageEvent.java @@ -4,11 +4,16 @@ import java.util.Set; import org.bukkit.command.CommandSender; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.bukkit.event.player.AsyncPlayerChatEvent; import org.jetbrains.annotations.NotNull; /** * Event triggered for server broadcast messages such as from * {@link org.bukkit.Server#broadcast(String, String)}. + * + * This event behaves similarly to {@link AsyncPlayerChatEvent} in that it + * should be async if fired from an async thread. Please see that event for + * further information. */ public class BroadcastMessageEvent extends ServerEvent implements Cancellable { @@ -17,7 +22,13 @@ public class BroadcastMessageEvent extends ServerEvent implements Cancellable { private final Set recipients; private boolean cancelled = false; + @Deprecated public BroadcastMessageEvent(@NotNull String message, @NotNull Set recipients) { + this(false, message, recipients); + } + + public BroadcastMessageEvent(boolean isAsync, @NotNull String message, @NotNull Set recipients) { + super(isAsync); this.message = message; this.recipients = recipients; } diff --git a/api/src/main/java/org/bukkit/event/server/ServerEvent.java b/api/src/main/java/org/bukkit/event/server/ServerEvent.java index 70416c811..05167fb34 100644 --- a/api/src/main/java/org/bukkit/event/server/ServerEvent.java +++ b/api/src/main/java/org/bukkit/event/server/ServerEvent.java @@ -7,13 +7,12 @@ import org.bukkit.event.Event; * Miscellaneous server events */ public abstract class ServerEvent extends Event { - // Paper start + + public ServerEvent() { + super(!Bukkit.isPrimaryThread()); // Paper + } + public ServerEvent(boolean isAsync) { super(isAsync); } - - public ServerEvent() { - super(!Bukkit.isPrimaryThread()); - } - // Paper end } diff --git a/api/src/main/java/org/bukkit/event/server/ServerListPingEvent.java b/api/src/main/java/org/bukkit/event/server/ServerListPingEvent.java index b68d7b2f8..7a2a58bac 100644 --- a/api/src/main/java/org/bukkit/event/server/ServerListPingEvent.java +++ b/api/src/main/java/org/bukkit/event/server/ServerListPingEvent.java @@ -2,7 +2,6 @@ package org.bukkit.event.server; import java.net.InetAddress; import java.util.Iterator; - import org.apache.commons.lang.Validate; import org.bukkit.UndefinedNullability; import org.bukkit.entity.Player; @@ -23,7 +22,7 @@ public class ServerListPingEvent extends ServerEvent implements Iterable private int maxPlayers; public ServerListPingEvent(@NotNull final InetAddress address, @NotNull final String motd, final int numPlayers, final int maxPlayers) { - super(); // Paper - Is this event being fired async? + super(true); Validate.isTrue(numPlayers >= 0, "Cannot have negative number of players online", numPlayers); this.address = address; this.motd = motd; @@ -35,13 +34,13 @@ public class ServerListPingEvent extends ServerEvent implements Iterable * This constructor is intended for implementations that provide the * {@link #iterator()} method, thus provided the {@link #getNumPlayers()} * count. - * + * * @param address the address of the pinger * @param motd the message of the day * @param maxPlayers the max number of players */ protected ServerListPingEvent(@NotNull final InetAddress address, @NotNull final String motd, final int maxPlayers) { - super(); // Paper - Is this event being fired async? + super(true); this.numPlayers = MAGIC_PLAYER_COUNT; this.address = address; this.motd = motd; diff --git a/api/src/main/java/org/bukkit/event/server/ServiceEvent.java b/api/src/main/java/org/bukkit/event/server/ServiceEvent.java index bbc2de504..55e278cd0 100644 --- a/api/src/main/java/org/bukkit/event/server/ServiceEvent.java +++ b/api/src/main/java/org/bukkit/event/server/ServiceEvent.java @@ -18,4 +18,4 @@ public abstract class ServiceEvent extends ServerEvent { public RegisteredServiceProvider getProvider() { return provider; } -} \ No newline at end of file +} diff --git a/api/src/main/java/org/bukkit/event/vehicle/VehicleDamageEvent.java b/api/src/main/java/org/bukkit/event/vehicle/VehicleDamageEvent.java index ced91e4e4..45da51d59 100644 --- a/api/src/main/java/org/bukkit/event/vehicle/VehicleDamageEvent.java +++ b/api/src/main/java/org/bukkit/event/vehicle/VehicleDamageEvent.java @@ -50,10 +50,12 @@ public class VehicleDamageEvent extends VehicleEvent implements Cancellable { this.damage = damage; } + @Override public boolean isCancelled() { return cancelled; } + @Override public void setCancelled(boolean cancel) { this.cancelled = cancel; } diff --git a/api/src/main/java/org/bukkit/event/vehicle/VehicleDestroyEvent.java b/api/src/main/java/org/bukkit/event/vehicle/VehicleDestroyEvent.java index 2ee6ffd0f..26bc6898f 100644 --- a/api/src/main/java/org/bukkit/event/vehicle/VehicleDestroyEvent.java +++ b/api/src/main/java/org/bukkit/event/vehicle/VehicleDestroyEvent.java @@ -32,10 +32,12 @@ public class VehicleDestroyEvent extends VehicleEvent implements Cancellable { return attacker; } + @Override public boolean isCancelled() { return cancelled; } + @Override public void setCancelled(boolean cancel) { this.cancelled = cancel; } diff --git a/api/src/main/java/org/bukkit/event/vehicle/VehicleEnterEvent.java b/api/src/main/java/org/bukkit/event/vehicle/VehicleEnterEvent.java index 066992f0a..64f21f684 100644 --- a/api/src/main/java/org/bukkit/event/vehicle/VehicleEnterEvent.java +++ b/api/src/main/java/org/bukkit/event/vehicle/VehicleEnterEvent.java @@ -29,10 +29,12 @@ public class VehicleEnterEvent extends VehicleEvent implements Cancellable { return entered; } + @Override public boolean isCancelled() { return cancelled; } + @Override public void setCancelled(boolean cancel) { this.cancelled = cancel; } diff --git a/api/src/main/java/org/bukkit/event/vehicle/VehicleEntityCollisionEvent.java b/api/src/main/java/org/bukkit/event/vehicle/VehicleEntityCollisionEvent.java index 235c68727..6bafc62e2 100644 --- a/api/src/main/java/org/bukkit/event/vehicle/VehicleEntityCollisionEvent.java +++ b/api/src/main/java/org/bukkit/event/vehicle/VehicleEntityCollisionEvent.java @@ -26,10 +26,12 @@ public class VehicleEntityCollisionEvent extends VehicleCollisionEvent implement return entity; } + @Override public boolean isCancelled() { return cancelled; } + @Override public void setCancelled(boolean cancel) { this.cancelled = cancel; } diff --git a/api/src/main/java/org/bukkit/event/vehicle/VehicleEvent.java b/api/src/main/java/org/bukkit/event/vehicle/VehicleEvent.java index 72d827caf..63df27056 100644 --- a/api/src/main/java/org/bukkit/event/vehicle/VehicleEvent.java +++ b/api/src/main/java/org/bukkit/event/vehicle/VehicleEvent.java @@ -1,18 +1,14 @@ package org.bukkit.event.vehicle; -import org.bukkit.World; import org.bukkit.entity.Vehicle; import org.bukkit.event.Event; import org.jetbrains.annotations.NotNull; -import io.akarin.server.api.event.WorldAttachedEvent; - /** * Represents a vehicle-related event. */ -public abstract class VehicleEvent extends Event implements WorldAttachedEvent { // Akarin +public abstract class VehicleEvent extends Event { protected Vehicle vehicle; - @Override @NotNull public World getWorld() { return vehicle.getWorld(); } // Akarin public VehicleEvent(@NotNull final Vehicle vehicle) { this.vehicle = vehicle; diff --git a/api/src/main/java/org/bukkit/event/vehicle/VehicleExitEvent.java b/api/src/main/java/org/bukkit/event/vehicle/VehicleExitEvent.java index f0c0bae56..a976c32de 100644 --- a/api/src/main/java/org/bukkit/event/vehicle/VehicleExitEvent.java +++ b/api/src/main/java/org/bukkit/event/vehicle/VehicleExitEvent.java @@ -37,10 +37,12 @@ public class VehicleExitEvent extends VehicleEvent implements Cancellable { return exited; } + @Override public boolean isCancelled() { return cancelled; } + @Override public void setCancelled(boolean cancel) { // Paper start if (cancel && !isCancellable) { diff --git a/api/src/main/java/org/bukkit/event/weather/LightningStrikeEvent.java b/api/src/main/java/org/bukkit/event/weather/LightningStrikeEvent.java index 45f26a7b3..418f9391d 100644 --- a/api/src/main/java/org/bukkit/event/weather/LightningStrikeEvent.java +++ b/api/src/main/java/org/bukkit/event/weather/LightningStrikeEvent.java @@ -26,10 +26,12 @@ public class LightningStrikeEvent extends WeatherEvent implements Cancellable { this.cause = cause; } + @Override public boolean isCancelled() { return canceled; } + @Override public void setCancelled(boolean cancel) { canceled = cancel; } diff --git a/api/src/main/java/org/bukkit/event/weather/ThunderChangeEvent.java b/api/src/main/java/org/bukkit/event/weather/ThunderChangeEvent.java index 641769dfe..6cdf83476 100644 --- a/api/src/main/java/org/bukkit/event/weather/ThunderChangeEvent.java +++ b/api/src/main/java/org/bukkit/event/weather/ThunderChangeEvent.java @@ -18,10 +18,12 @@ public class ThunderChangeEvent extends WeatherEvent implements Cancellable { this.to = to; } + @Override public boolean isCancelled() { return canceled; } + @Override public void setCancelled(boolean cancel) { canceled = cancel; } diff --git a/api/src/main/java/org/bukkit/event/weather/WeatherChangeEvent.java b/api/src/main/java/org/bukkit/event/weather/WeatherChangeEvent.java index db19e7909..d562d87e7 100644 --- a/api/src/main/java/org/bukkit/event/weather/WeatherChangeEvent.java +++ b/api/src/main/java/org/bukkit/event/weather/WeatherChangeEvent.java @@ -18,10 +18,12 @@ public class WeatherChangeEvent extends WeatherEvent implements Cancellable { this.to = to; } + @Override public boolean isCancelled() { return canceled; } + @Override public void setCancelled(boolean cancel) { canceled = cancel; } diff --git a/api/src/main/java/org/bukkit/event/weather/WeatherEvent.java b/api/src/main/java/org/bukkit/event/weather/WeatherEvent.java index 669a297ea..e1854d807 100644 --- a/api/src/main/java/org/bukkit/event/weather/WeatherEvent.java +++ b/api/src/main/java/org/bukkit/event/weather/WeatherEvent.java @@ -4,12 +4,10 @@ import org.bukkit.World; import org.bukkit.event.Event; import org.jetbrains.annotations.NotNull; -import io.akarin.server.api.event.WorldAttachedEvent; - /** * Represents a Weather-related event */ -public abstract class WeatherEvent extends Event implements WorldAttachedEvent { // Akarin +public abstract class WeatherEvent extends Event { protected World world; public WeatherEvent(@NotNull final World where) { diff --git a/api/src/main/java/org/bukkit/event/world/ChunkUnloadEvent.java b/api/src/main/java/org/bukkit/event/world/ChunkUnloadEvent.java index 145cbe2eb..5d8271626 100644 --- a/api/src/main/java/org/bukkit/event/world/ChunkUnloadEvent.java +++ b/api/src/main/java/org/bukkit/event/world/ChunkUnloadEvent.java @@ -1,16 +1,14 @@ package org.bukkit.event.world; import org.bukkit.Chunk; -import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; import org.jetbrains.annotations.NotNull; /** * Called when a chunk is unloaded */ -public class ChunkUnloadEvent extends ChunkEvent implements Cancellable { +public class ChunkUnloadEvent extends ChunkEvent { private static final HandlerList handlers = new HandlerList(); - private boolean cancel = false; private boolean saveChunk; public ChunkUnloadEvent(@NotNull final Chunk chunk) { @@ -40,14 +38,6 @@ public class ChunkUnloadEvent extends ChunkEvent implements Cancellable { this.saveChunk = saveChunk; } - public boolean isCancelled() { - return cancel; - } - - public void setCancelled(boolean cancel) { - this.cancel = cancel; - } - @NotNull @Override public HandlerList getHandlers() { diff --git a/api/src/main/java/org/bukkit/event/world/PortalCreateEvent.java b/api/src/main/java/org/bukkit/event/world/PortalCreateEvent.java index 714272662..579f01747 100644 --- a/api/src/main/java/org/bukkit/event/world/PortalCreateEvent.java +++ b/api/src/main/java/org/bukkit/event/world/PortalCreateEvent.java @@ -1,13 +1,13 @@ package org.bukkit.event.world; -import org.bukkit.block.Block; +import java.util.List; import org.bukkit.World; +import org.bukkit.block.BlockState; +import org.bukkit.entity.Entity; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; import org.jetbrains.annotations.NotNull; - -import java.util.ArrayList; -import java.util.Collection; +import org.jetbrains.annotations.Nullable; /** * Called when a portal is created @@ -15,13 +15,20 @@ import java.util.Collection; public class PortalCreateEvent extends WorldEvent implements Cancellable { private static final HandlerList handlers = new HandlerList(); private boolean cancel = false; - private final ArrayList blocks = new ArrayList(); - private CreateReason reason = CreateReason.FIRE; + private final List blocks; + private final Entity entity; + private final CreateReason reason; - public PortalCreateEvent(@NotNull final Collection blocks, @NotNull final World world, @NotNull CreateReason reason) { + @Deprecated + public PortalCreateEvent(@NotNull final List blocks, @NotNull final World world, @NotNull CreateReason reason) { + this(blocks, world, null, reason); + } + + public PortalCreateEvent(@NotNull final List blocks, @NotNull final World world, @Nullable Entity entity, @NotNull CreateReason reason) { super(world); - this.blocks.addAll(blocks); + this.blocks = blocks; + this.entity = entity; this.reason = reason; } @@ -31,14 +38,26 @@ public class PortalCreateEvent extends WorldEvent implements Cancellable { * @return array list of all the blocks associated with the created portal */ @NotNull - public ArrayList getBlocks() { + public List getBlocks() { return this.blocks; } + /** + * Returns the Entity that triggered this portal creation (if available) + * + * @return Entity involved in this event + */ + @Nullable + public Entity getEntity() { + return entity; + } + + @Override public boolean isCancelled() { return cancel; } + @Override public void setCancelled(boolean cancel) { this.cancel = cancel; } @@ -69,14 +88,19 @@ public class PortalCreateEvent extends WorldEvent implements Cancellable { */ public enum CreateReason { /** - * When a portal is created 'traditionally' due to a portal frame + * When the blocks inside a portal are created due to a portal frame * being set on fire. */ FIRE, /** - * When a portal is created as a destination for an existing portal - * when using the custom PortalTravelAgent + * When a nether portal frame and portal is created at the exit of an + * entered nether portal. */ - OBC_DESTINATION + NETHER_PAIR, + /** + * When the target end platform is created as a result of a player + * entering an end portal. + */ + END_PLATFORM } } diff --git a/api/src/main/java/org/bukkit/event/world/SpawnChangeEvent.java b/api/src/main/java/org/bukkit/event/world/SpawnChangeEvent.java index 4c49c7619..9ce93d009 100644 --- a/api/src/main/java/org/bukkit/event/world/SpawnChangeEvent.java +++ b/api/src/main/java/org/bukkit/event/world/SpawnChangeEvent.java @@ -1,7 +1,7 @@ package org.bukkit.event.world; -import org.bukkit.World; import org.bukkit.Location; +import org.bukkit.World; import org.bukkit.event.HandlerList; import org.jetbrains.annotations.NotNull; diff --git a/api/src/main/java/org/bukkit/event/world/StructureGrowEvent.java b/api/src/main/java/org/bukkit/event/world/StructureGrowEvent.java index 578337699..7af8d6e51 100644 --- a/api/src/main/java/org/bukkit/event/world/StructureGrowEvent.java +++ b/api/src/main/java/org/bukkit/event/world/StructureGrowEvent.java @@ -83,10 +83,12 @@ public class StructureGrowEvent extends WorldEvent implements Cancellable { return blocks; } + @Override public boolean isCancelled() { return cancelled; } + @Override public void setCancelled(boolean cancel) { cancelled = cancel; } diff --git a/api/src/main/java/org/bukkit/event/world/WorldUnloadEvent.java b/api/src/main/java/org/bukkit/event/world/WorldUnloadEvent.java index d1cb72116..8eeeada87 100644 --- a/api/src/main/java/org/bukkit/event/world/WorldUnloadEvent.java +++ b/api/src/main/java/org/bukkit/event/world/WorldUnloadEvent.java @@ -16,10 +16,12 @@ public class WorldUnloadEvent extends WorldEvent implements Cancellable { super(world); } + @Override public boolean isCancelled() { return this.isCancelled; } + @Override public void setCancelled(boolean cancel) { this.isCancelled = cancel; } diff --git a/api/src/main/java/org/bukkit/generator/ChunkGenerator.java b/api/src/main/java/org/bukkit/generator/ChunkGenerator.java index 9a18a05bb..3fe6a22e0 100644 --- a/api/src/main/java/org/bukkit/generator/ChunkGenerator.java +++ b/api/src/main/java/org/bukkit/generator/ChunkGenerator.java @@ -17,7 +17,15 @@ import org.jetbrains.annotations.Nullable; /** * A chunk generator is responsible for the initial shaping of an entire * chunk. For example, the nether chunk generator should shape netherrack and - * soulsand + * soulsand. + * + * By default only one thread will call + * {@link #generateChunkData(org.bukkit.World, java.util.Random, int, int, org.bukkit.generator.ChunkGenerator.BiomeGrid)} + * at a time, although this may not necessarily be the main server thread. + * + * If your generator is capable of fully asynchronous generation, then + * {@link #isParallelCapable()} should be overriden accordingly to allow + * multiple concurrent callers. */ public abstract class ChunkGenerator { @@ -52,7 +60,7 @@ public abstract class ChunkGenerator { /** * Shapes the chunk for the given coordinates. - * + * * This method must return a ChunkData. *

    * Notes: @@ -64,7 +72,7 @@ public abstract class ChunkGenerator { * been returned. *

    * This method must return a ChunkData returned by {@link ChunkGenerator#createChunkData(org.bukkit.World)} - * + * * @param world The world this chunk will be used for * @param random The random generator to use * @param x The X-coordinate of the chunk @@ -76,7 +84,10 @@ public abstract class ChunkGenerator { */ @NotNull public ChunkData generateChunkData(@NotNull World world, @NotNull Random random, int x, int z, @NotNull BiomeGrid biome) { - throw new UnsupportedOperationException("Custom generator is missing required method generateChunkData"); + // Paper start - More helpful custom chunk gen exceptions + final String generatorClass = world.getGenerator() != null ? world.getGenerator().getClass().getName() : "null"; + throw new UnsupportedOperationException("Custom generator is missing required method generateChunkData: " + generatorClass); + // Paper end } /** @@ -138,15 +149,26 @@ public abstract class ChunkGenerator { return null; } + /** + * Gets if this ChunkGenerator is parallel capable. + * + * See {@link ChunkGenerator} for more information. + * + * @return parallel capable status + */ + public boolean isParallelCapable() { + return false; + } + /** * Data for a Chunk. */ public static interface ChunkData { /** * Get the maximum height for the chunk. - * + * * Setting blocks at or above this height will do nothing. - * + * * @return the maximum height */ public int getMaxHeight(); @@ -174,7 +196,7 @@ public abstract class ChunkGenerator { * @param material the type to set the block to */ public void setBlock(int x, int y, int z, @NotNull MaterialData material); - + /** * Set the block at x,y,z in the chunk data to material. * @@ -202,7 +224,7 @@ public abstract class ChunkGenerator { * @param material the type to set the blocks to */ public void setRegion(int xMin, int yMin, int zMin, int xMax, int yMax, int zMax, @NotNull Material material); - + /** * Set a region of this chunk from xMin, yMin, zMin (inclusive) * to xMax, yMax, zMax (exclusive) to material. @@ -218,7 +240,7 @@ public abstract class ChunkGenerator { * @param material the type to set the blocks to */ public void setRegion(int xMin, int yMin, int zMin, int xMax, int yMax, int zMax, @NotNull MaterialData material); - + /** * Set a region of this chunk from xMin, yMin, zMin (inclusive) to xMax, * yMax, zMax (exclusive) to material. @@ -247,7 +269,7 @@ public abstract class ChunkGenerator { */ @NotNull public Material getType(int x, int y, int z); - + /** * Get the type and data of the block at x, y, z. * @@ -260,7 +282,7 @@ public abstract class ChunkGenerator { */ @NotNull public MaterialData getTypeAndData(int x, int y, int z); - + /** * Get the type and data of the block at x, y, z. * @@ -273,7 +295,7 @@ public abstract class ChunkGenerator { */ @NotNull public BlockData getBlockData(int x, int y, int z); - + /** * Get the block data at x,y,z in the chunk data. * diff --git a/api/src/main/java/org/bukkit/help/GenericCommandHelpTopic.java b/api/src/main/java/org/bukkit/help/GenericCommandHelpTopic.java index b05f570a8..1d862c23d 100644 --- a/api/src/main/java/org/bukkit/help/GenericCommandHelpTopic.java +++ b/api/src/main/java/org/bukkit/help/GenericCommandHelpTopic.java @@ -1,9 +1,9 @@ package org.bukkit.help; +import org.apache.commons.lang.StringUtils; import org.bukkit.ChatColor; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; -import org.apache.commons.lang.StringUtils; import org.bukkit.command.ConsoleCommandSender; import org.jetbrains.annotations.NotNull; @@ -59,6 +59,7 @@ public class GenericCommandHelpTopic extends HelpTopic { fullText = sb.toString(); } + @Override public boolean canSee(@NotNull CommandSender sender) { if (!command.isRegistered()) { // Unregistered commands should not show up in the help diff --git a/api/src/main/java/org/bukkit/help/HelpMap.java b/api/src/main/java/org/bukkit/help/HelpMap.java index 45845238e..48997b5c8 100644 --- a/api/src/main/java/org/bukkit/help/HelpMap.java +++ b/api/src/main/java/org/bukkit/help/HelpMap.java @@ -1,16 +1,15 @@ package org.bukkit.help; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - import java.util.Collection; import java.util.List; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * The HelpMap tracks all help topics registered in a Bukkit server. When the * server starts up or is reloaded, help is processed and topics are added in * the following order: - * + * *

      *
    1. General topics are loaded from the help.yml *
    2. Plugins load and optionally call {@code addTopic()} @@ -37,7 +36,7 @@ public interface HelpMap { */ @NotNull public Collection getHelpTopics(); - + /** * Adds a topic to the server's help index. * diff --git a/api/src/main/java/org/bukkit/help/HelpTopicComparator.java b/api/src/main/java/org/bukkit/help/HelpTopicComparator.java index e586826d9..75bb69283 100644 --- a/api/src/main/java/org/bukkit/help/HelpTopicComparator.java +++ b/api/src/main/java/org/bukkit/help/HelpTopicComparator.java @@ -1,8 +1,7 @@ package org.bukkit.help; -import org.jetbrains.annotations.NotNull; - import java.util.Comparator; +import org.jetbrains.annotations.NotNull; /** * Used to impose a custom total ordering on help topics. @@ -10,7 +9,7 @@ import java.util.Comparator; * All topics are listed in alphabetic order, but topics that start with a * slash come after topics that don't. */ -public class HelpTopicComparator implements Comparator { +public final class HelpTopicComparator implements Comparator { // Singleton implementations private static final TopicNameComparator tnc = new TopicNameComparator(); @@ -27,13 +26,15 @@ public class HelpTopicComparator implements Comparator { private HelpTopicComparator() {} + @Override public int compare(@NotNull HelpTopic lhs, @NotNull HelpTopic rhs) { return tnc.compare(lhs.getName(), rhs.getName()); } - public static class TopicNameComparator implements Comparator { + public static final class TopicNameComparator implements Comparator { private TopicNameComparator(){} + @Override public int compare(@NotNull String lhs, @NotNull String rhs) { boolean lhsStartSlash = lhs.startsWith("/"); boolean rhsStartSlash = rhs.startsWith("/"); diff --git a/api/src/main/java/org/bukkit/help/IndexHelpTopic.java b/api/src/main/java/org/bukkit/help/IndexHelpTopic.java index 2914c9f8a..88a812d66 100644 --- a/api/src/main/java/org/bukkit/help/IndexHelpTopic.java +++ b/api/src/main/java/org/bukkit/help/IndexHelpTopic.java @@ -1,5 +1,6 @@ package org.bukkit.help; +import java.util.Collection; import org.bukkit.ChatColor; import org.bukkit.command.CommandSender; import org.bukkit.command.ConsoleCommandSender; @@ -8,8 +9,6 @@ import org.bukkit.util.ChatPaginator; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.Collection; - /** * This help topic generates a list of other help topics. This class is useful * for adding your own index help topics. To enforce a particular order, use a @@ -45,6 +44,7 @@ public class IndexHelpTopic extends HelpTopic { this.allTopics = topics; } + @Override public boolean canSee(@NotNull CommandSender sender) { if (sender instanceof ConsoleCommandSender) { return true; @@ -60,6 +60,7 @@ public class IndexHelpTopic extends HelpTopic { permission = amendedPermission; } + @Override @NotNull public String getFullText(@NotNull CommandSender sender) { StringBuilder sb = new StringBuilder(); diff --git a/api/src/main/java/org/bukkit/inventory/BlastingRecipe.java b/api/src/main/java/org/bukkit/inventory/BlastingRecipe.java new file mode 100644 index 000000000..74a025a90 --- /dev/null +++ b/api/src/main/java/org/bukkit/inventory/BlastingRecipe.java @@ -0,0 +1,19 @@ +package org.bukkit.inventory; + +import org.bukkit.Material; +import org.bukkit.NamespacedKey; +import org.jetbrains.annotations.NotNull; + +/** + * Represents a campfire recipe. + */ +public class BlastingRecipe extends CookingRecipe { + + public BlastingRecipe(@NotNull NamespacedKey key, @NotNull ItemStack result, @NotNull Material source, float experience, int cookingTime) { + super(key, result, source, experience, cookingTime); + } + + public BlastingRecipe(@NotNull NamespacedKey key, @NotNull ItemStack result, @NotNull RecipeChoice input, float experience, int cookingTime) { + super(key, result, input, experience, cookingTime); + } +} diff --git a/api/src/main/java/org/bukkit/inventory/BlockInventoryHolder.java b/api/src/main/java/org/bukkit/inventory/BlockInventoryHolder.java new file mode 100644 index 000000000..86fbc1be4 --- /dev/null +++ b/api/src/main/java/org/bukkit/inventory/BlockInventoryHolder.java @@ -0,0 +1,21 @@ +package org.bukkit.inventory; + +import org.bukkit.block.Block; +import org.jetbrains.annotations.NotNull; + +/** + * Represents a block inventory holder - either a BlockState, or a regular + * Block. + */ +public interface BlockInventoryHolder extends InventoryHolder { + + /** + * Gets the block associated with this holder. + * + * @return the block associated with this holder + * @throws IllegalStateException if the holder is a block state and is not + * placed + */ + @NotNull + Block getBlock(); +} diff --git a/api/src/main/java/org/bukkit/inventory/BrewerInventory.java b/api/src/main/java/org/bukkit/inventory/BrewerInventory.java index df45423e6..d8a52b59e 100644 --- a/api/src/main/java/org/bukkit/inventory/BrewerInventory.java +++ b/api/src/main/java/org/bukkit/inventory/BrewerInventory.java @@ -40,6 +40,7 @@ public interface BrewerInventory extends Inventory { */ void setFuel(@Nullable ItemStack fuel); + @Override @Nullable BrewingStand getHolder(); } diff --git a/api/src/main/java/org/bukkit/inventory/CampfireRecipe.java b/api/src/main/java/org/bukkit/inventory/CampfireRecipe.java new file mode 100644 index 000000000..a1bd3a68d --- /dev/null +++ b/api/src/main/java/org/bukkit/inventory/CampfireRecipe.java @@ -0,0 +1,19 @@ +package org.bukkit.inventory; + +import org.bukkit.Material; +import org.bukkit.NamespacedKey; +import org.jetbrains.annotations.NotNull; + +/** + * Represents a campfire recipe. + */ +public class CampfireRecipe extends CookingRecipe { + + public CampfireRecipe(@NotNull NamespacedKey key, @NotNull ItemStack result, @NotNull Material source, float experience, int cookingTime) { + super(key, result, source, experience, cookingTime); + } + + public CampfireRecipe(@NotNull NamespacedKey key, @NotNull ItemStack result, @NotNull RecipeChoice input, float experience, int cookingTime) { + super(key, result, input, experience, cookingTime); + } +} diff --git a/api/src/main/java/org/bukkit/inventory/CartographyInventory.java b/api/src/main/java/org/bukkit/inventory/CartographyInventory.java new file mode 100644 index 000000000..29c9b2682 --- /dev/null +++ b/api/src/main/java/org/bukkit/inventory/CartographyInventory.java @@ -0,0 +1,6 @@ +package org.bukkit.inventory; + +/** + * Interface to the inventory of a Cartography table. + */ +public interface CartographyInventory extends Inventory { } diff --git a/api/src/main/java/org/bukkit/inventory/CookingRecipe.java b/api/src/main/java/org/bukkit/inventory/CookingRecipe.java new file mode 100644 index 000000000..6f251252a --- /dev/null +++ b/api/src/main/java/org/bukkit/inventory/CookingRecipe.java @@ -0,0 +1,173 @@ +package org.bukkit.inventory; + +import com.google.common.base.Preconditions; +import java.util.Collections; +import org.bukkit.Keyed; +import org.bukkit.Material; +import org.bukkit.NamespacedKey; +import org.jetbrains.annotations.NotNull; + +/** + * Represents a cooking recipe. + * @param type of recipe + */ +public abstract class CookingRecipe implements Recipe, Keyed { + private final NamespacedKey key; + private ItemStack output; + private RecipeChoice ingredient; + private float experience; + private int cookingTime; + private String group = ""; + + /** + * Create a cooking recipe to craft the specified ItemStack. + * + * @param key The unique recipe key + * @param result The item you want the recipe to create. + * @param source The input material. + * @param experience The experience given by this recipe + * @param cookingTime The cooking time (in ticks) + */ + public CookingRecipe(@NotNull NamespacedKey key, @NotNull ItemStack result, @NotNull Material source, float experience, int cookingTime) { + this(key, result, new RecipeChoice.MaterialChoice(Collections.singletonList(source)), experience, cookingTime); + } + + /** + * Create a cooking recipe to craft the specified ItemStack. + * + * @param key The unique recipe key + * @param result The item you want the recipe to create. + * @param input The input choices. + * @param experience The experience given by this recipe + * @param cookingTime The cooking time (in ticks) + */ + public CookingRecipe(@NotNull NamespacedKey key, @NotNull ItemStack result, @NotNull RecipeChoice input, float experience, int cookingTime) { + Preconditions.checkArgument(result.getType() != Material.AIR, "Recipe must have non-AIR result."); + this.key = key; + this.output = new ItemStack(result); + this.ingredient = input; + this.experience = experience; + this.cookingTime = cookingTime; + } + + /** + * Sets the input of this cooking recipe. + * + * @param input The input material. + * @return The changed recipe, so you can chain calls. + */ + @NotNull + public CookingRecipe setInput(@NotNull Material input) { + this.ingredient = new RecipeChoice.MaterialChoice(Collections.singletonList(input)); + return this; + } + + /** + * Get the input material. + * + * @return The input material. + */ + @NotNull + public ItemStack getInput() { + return this.ingredient.getItemStack(); + } + + /** + * Sets the input of this cooking recipe. + * + * @param input The input choice. + * @return The changed recipe, so you can chain calls. + */ + @NotNull + public T setInputChoice(@NotNull RecipeChoice input) { + this.ingredient = input; + return (T) this; + } + + /** + * Get the input choice. + * + * @return The input choice. + */ + @NotNull + public RecipeChoice getInputChoice() { + return this.ingredient.clone(); + } + + /** + * Get the result of this recipe. + * + * @return The resulting stack. + */ + @NotNull + @Override + public ItemStack getResult() { + return output.clone(); + } + + /** + * Sets the experience given by this recipe. + * + * @param experience the experience level + */ + public void setExperience(float experience) { + this.experience = experience; + } + + /** + * Get the experience given by this recipe. + * + * @return experience level + */ + public float getExperience() { + return experience; + } + + /** + * Set the cooking time for this recipe in ticks. + * + * @param cookingTime new cooking time + */ + public void setCookingTime(int cookingTime) { + Preconditions.checkArgument(cookingTime >= 0, "cookingTime must be >= 0"); + this.cookingTime = cookingTime; + } + + /** + * Get the cooking time for this recipe in ticks. + * + * @return cooking time + */ + public int getCookingTime() { + return cookingTime; + } + + @NotNull + @Override + public NamespacedKey getKey() { + return key; + } + + /** + * Get the group of this recipe. Recipes with the same group may be grouped + * together when displayed in the client. + * + * @return recipe group. An empty string denotes no group. May not be null. + */ + @NotNull + public String getGroup() { + return group; + } + + /** + * Set the group of this recipe. Recipes with the same group may be grouped + * together when displayed in the client. + * + * @param group recipe group. An empty string denotes no group. May not be + * null. + */ + public void setGroup(@NotNull String group) { + Preconditions.checkArgument(group != null, "group"); + this.group = group; + } +} diff --git a/api/src/main/java/org/bukkit/inventory/DoubleChestInventory.java b/api/src/main/java/org/bukkit/inventory/DoubleChestInventory.java index ca18cc8af..6d0067cbc 100644 --- a/api/src/main/java/org/bukkit/inventory/DoubleChestInventory.java +++ b/api/src/main/java/org/bukkit/inventory/DoubleChestInventory.java @@ -25,6 +25,7 @@ public interface DoubleChestInventory extends Inventory { @NotNull Inventory getRightSide(); + @Override @Nullable DoubleChest getHolder(); } diff --git a/api/src/main/java/org/bukkit/inventory/EntityEquipment.java b/api/src/main/java/org/bukkit/inventory/EntityEquipment.java index 6875dbc72..1fd9f79de 100644 --- a/api/src/main/java/org/bukkit/inventory/EntityEquipment.java +++ b/api/src/main/java/org/bukkit/inventory/EntityEquipment.java @@ -234,7 +234,7 @@ public interface EntityEquipment { /** * Sets the chance of the helmet being dropped upon this creature's death. - * + * *
        *
      • A drop chance of 0.0F will never drop *
      • A drop chance of 1.0F will always drop @@ -248,7 +248,7 @@ public interface EntityEquipment { /** * Gets the chance of the chest plate being dropped upon this creature's * death. - * + * *
          *
        • A drop chance of 0.0F will never drop *
        • A drop chance of 1.0F will always drop @@ -261,7 +261,7 @@ public interface EntityEquipment { /** * Sets the chance of the chest plate being dropped upon this creature's * death. - * + * *
            *
          • A drop chance of 0.0F will never drop *
          • A drop chance of 1.0F will always drop @@ -275,7 +275,7 @@ public interface EntityEquipment { /** * Gets the chance of the leggings being dropped upon this creature's * death. - * + * *
              *
            • A drop chance of 0.0F will never drop *
            • A drop chance of 1.0F will always drop @@ -288,7 +288,7 @@ public interface EntityEquipment { /** * Sets the chance of the leggings being dropped upon this creature's * death. - * + * *
                *
              • A drop chance of 0.0F will never drop *
              • A drop chance of 1.0F will always drop @@ -301,7 +301,7 @@ public interface EntityEquipment { /** * Gets the chance of the boots being dropped upon this creature's death. - * + * *
                  *
                • A drop chance of 0.0F will never drop *
                • A drop chance of 1.0F will always drop @@ -313,7 +313,7 @@ public interface EntityEquipment { /** * Sets the chance of the boots being dropped upon this creature's death. - * + * *
                    *
                  • A drop chance of 0.0F will never drop *
                  • A drop chance of 1.0F will always drop diff --git a/api/src/main/java/org/bukkit/inventory/FurnaceInventory.java b/api/src/main/java/org/bukkit/inventory/FurnaceInventory.java index 65d8fa437..3f46259c1 100644 --- a/api/src/main/java/org/bukkit/inventory/FurnaceInventory.java +++ b/api/src/main/java/org/bukkit/inventory/FurnaceInventory.java @@ -53,6 +53,7 @@ public interface FurnaceInventory extends Inventory { */ void setSmelting(@Nullable ItemStack stack); + @Override @Nullable Furnace getHolder(); } diff --git a/api/src/main/java/org/bukkit/inventory/FurnaceRecipe.java b/api/src/main/java/org/bukkit/inventory/FurnaceRecipe.java index d40ffbe79..1d442dc16 100644 --- a/api/src/main/java/org/bukkit/inventory/FurnaceRecipe.java +++ b/api/src/main/java/org/bukkit/inventory/FurnaceRecipe.java @@ -1,23 +1,15 @@ package org.bukkit.inventory; -import com.google.common.base.Preconditions; import java.util.Collections; -import org.bukkit.Keyed; import org.bukkit.Material; import org.bukkit.NamespacedKey; import org.bukkit.material.MaterialData; import org.jetbrains.annotations.NotNull; /** - * Represents a smelting recipe. + * Represents a furnace recipe. */ -public class FurnaceRecipe implements Recipe, Keyed { - private final NamespacedKey key; - private ItemStack output; - private RecipeChoice ingredient; - private float experience; - private int cookingTime; - private String group = ""; +public class FurnaceRecipe extends CookingRecipe { @Deprecated public FurnaceRecipe(@NotNull ItemStack result, @NotNull Material source) { @@ -67,11 +59,7 @@ public class FurnaceRecipe implements Recipe, Keyed { * @param cookingTime The cooking time (in ticks) */ public FurnaceRecipe(@NotNull NamespacedKey key, @NotNull ItemStack result, @NotNull RecipeChoice input, float experience, int cookingTime) { - this.key = key; - this.output = new ItemStack(result); - this.ingredient = input; - this.experience = experience; - this.cookingTime = cookingTime; + super(key, result, input, experience, cookingTime); } /** @@ -85,15 +73,10 @@ public class FurnaceRecipe implements Recipe, Keyed { return setInput(input.getItemType(), input.getData()); } - /** - * Sets the input of this furnace recipe. - * - * @param input The input material. - * @return The changed recipe, so you can chain calls. - */ @NotNull + @Override public FurnaceRecipe setInput(@NotNull Material input) { - return setInput(input, 0); + return (FurnaceRecipe) super.setInput(input); } /** @@ -106,117 +89,13 @@ public class FurnaceRecipe implements Recipe, Keyed { * @deprecated Magic value */ @Deprecated - @NotNull public FurnaceRecipe setInput(@NotNull Material input, int data) { - this.ingredient = new RecipeChoice.MaterialChoice(Collections.singletonList(input)); - return this; - } - - /** - * Get the input material. - * - * @return The input material. - */ - @NotNull - public ItemStack getInput() { - return this.ingredient.getItemStack(); - } - - /** - * Sets the input of this furnace recipe. - * - * @param input The input choice. - * @return The changed recipe, so you can chain calls. - */ - @NotNull - public FurnaceRecipe setInputChoice(@NotNull RecipeChoice input) { - this.ingredient = input; - return this; - } - - /** - * Get the input choice. - * - * @return The input choice. - */ - @NotNull - public RecipeChoice getInputChoice() { - return this.ingredient.clone(); - } - - /** - * Get the result of this recipe. - * - * @return The resulting stack. - */ - @NotNull - public ItemStack getResult() { - return output.clone(); - } - - /** - * Sets the experience given by this recipe. - * - * @param experience the experience level - */ - public void setExperience(float experience) { - this.experience = experience; - } - - /** - * Get the experience given by this recipe. - * - * @return experience level - */ - public float getExperience() { - return experience; - } - - /** - * Set the cooking time for this recipe in ticks. - * - * @param cookingTime new cooking time - */ - public void setCookingTime(int cookingTime) { - Preconditions.checkArgument(cookingTime >= 0, "cookingTime must be >= 0"); - this.cookingTime = cookingTime; - } - - /** - * Get the cooking time for this recipe in ticks. - * - * @return cooking time - */ - public int getCookingTime() { - return cookingTime; + return setInputChoice(new RecipeChoice.MaterialChoice(Collections.singletonList(input))); } @NotNull @Override - public NamespacedKey getKey() { - return key; - } - - /** - * Get the group of this recipe. Recipes with the same group may be grouped - * together when displayed in the client. - * - * @return recipe group. An empty string denotes no group. May not be null. - */ - @NotNull - public String getGroup() { - return group; - } - - /** - * Set the group of this recipe. Recipes with the same group may be grouped - * together when displayed in the client. - * - * @param group recipe group. An empty string denotes no group. May not be - * null. - */ - public void setGroup(@NotNull String group) { - Preconditions.checkArgument(group != null, "group"); - this.group = group; + public FurnaceRecipe setInputChoice(@NotNull RecipeChoice input) { + return (FurnaceRecipe) super.setInputChoice(input); } } diff --git a/api/src/main/java/org/bukkit/inventory/GrindstoneInventory.java b/api/src/main/java/org/bukkit/inventory/GrindstoneInventory.java new file mode 100644 index 000000000..9048892c8 --- /dev/null +++ b/api/src/main/java/org/bukkit/inventory/GrindstoneInventory.java @@ -0,0 +1,6 @@ +package org.bukkit.inventory; + +/** + * Interface to the inventory of a Grindstone. + */ +public interface GrindstoneInventory extends Inventory { } diff --git a/api/src/main/java/org/bukkit/inventory/Inventory.java b/api/src/main/java/org/bukkit/inventory/Inventory.java index a358e9014..01fe217df 100644 --- a/api/src/main/java/org/bukkit/inventory/Inventory.java +++ b/api/src/main/java/org/bukkit/inventory/Inventory.java @@ -3,7 +3,6 @@ package org.bukkit.inventory; import java.util.HashMap; import java.util.List; import java.util.ListIterator; - import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.entity.HumanEntity; @@ -60,18 +59,6 @@ public interface Inventory extends Iterable { */ public void setMaxStackSize(int size); - /** - * Returns the name of the inventory - * - * @return The String with the name of the inventory - * @deprecated different instances of the same inventory may have different names; - * it is not clear what this method is meant to return - * @see InventoryView#getTitle() - */ - @Deprecated - @NotNull - public String getName(); - /** * Returns the ItemStack found in the slot at the given index * @@ -373,17 +360,6 @@ public interface Inventory extends Iterable { @NotNull public List getViewers(); - /** - * Returns the title of this inventory. - * - * @return A String with the title. - * @deprecated different instances of the same inventory may have different titles - * @see InventoryView#getTitle() - */ - @Deprecated - @NotNull - public String getTitle(); - /** * Returns what type of inventory this is. * diff --git a/api/src/main/java/org/bukkit/inventory/InventoryView.java b/api/src/main/java/org/bukkit/inventory/InventoryView.java index 38b9132f4..62d79142a 100644 --- a/api/src/main/java/org/bukkit/inventory/InventoryView.java +++ b/api/src/main/java/org/bukkit/inventory/InventoryView.java @@ -15,7 +15,7 @@ import org.jetbrains.annotations.Nullable; * as it should. */ public abstract class InventoryView { - public final static int OUTSIDE = -999; + public static final int OUTSIDE = -999; /** * Represents various extra properties of certain inventory windows. */ @@ -98,7 +98,11 @@ public abstract class InventoryView { /** * The repair's cost in xp levels */ - REPAIR_COST(0, InventoryType.ANVIL); + REPAIR_COST(0, InventoryType.ANVIL), + /** + * The lectern's current open book page + */ + BOOK_PAGE(0, InventoryType.LECTERN); int id; InventoryType style; private Property(int id, /*@NotNull*/ InventoryType appliesTo) { @@ -325,7 +329,9 @@ public abstract class InventoryView { InventoryType.SlotType type = InventoryType.SlotType.CONTAINER; if (slot >= 0 && slot < this.getTopInventory().getSize()) { switch(this.getType()) { + case BLAST_FURNACE: case FURNACE: + case SMOKER: if (slot == 2) { type = InventoryType.SlotType.RESULT; } else if(slot == 1) { @@ -352,6 +358,12 @@ public abstract class InventoryView { type = InventoryType.SlotType.CRAFTING; } break; + case BEACON: + type = InventoryType.SlotType.CRAFTING; + break; + case ANVIL: + case CARTOGRAPHY: + case GRINDSTONE: case MERCHANT: if (slot == 2) { type = InventoryType.SlotType.RESULT; @@ -359,11 +371,15 @@ public abstract class InventoryView { type = InventoryType.SlotType.CRAFTING; } break; - case BEACON: - type = InventoryType.SlotType.CRAFTING; + case STONECUTTER: + if (slot == 1) { + type = InventoryType.SlotType.RESULT; + } else { + type = InventoryType.SlotType.CRAFTING; + } break; - case ANVIL: - if (slot == 2) { + case LOOM: + if (slot == 3) { type = InventoryType.SlotType.RESULT; } else { type = InventoryType.SlotType.CRAFTING; @@ -427,7 +443,5 @@ public abstract class InventoryView { * @return The title. */ @NotNull - public final String getTitle() { - return getTopInventory().getTitle(); - } + public abstract String getTitle(); } diff --git a/api/src/main/java/org/bukkit/inventory/ItemFactory.java b/api/src/main/java/org/bukkit/inventory/ItemFactory.java index 56734f8ee..03ba22659 100644 --- a/api/src/main/java/org/bukkit/inventory/ItemFactory.java +++ b/api/src/main/java/org/bukkit/inventory/ItemFactory.java @@ -136,7 +136,7 @@ public interface ItemFactory { * @param meta meta * @param material material * @return updated material - * @throws IllegalArgumentException exception + * @throws IllegalArgumentException if bad material or data * @deprecated for internal use only */ @Deprecated diff --git a/api/src/main/java/org/bukkit/inventory/ItemStack.java b/api/src/main/java/org/bukkit/inventory/ItemStack.java index 1d3b0a312..495161f62 100644 --- a/api/src/main/java/org/bukkit/inventory/ItemStack.java +++ b/api/src/main/java/org/bukkit/inventory/ItemStack.java @@ -2,10 +2,9 @@ package org.bukkit.inventory; import com.google.common.collect.ImmutableMap; import java.util.LinkedHashMap; -import java.util.List; +import java.util.List; // Paper import java.util.Map; -import java.util.Set; - +import java.util.Set; // Paper import org.apache.commons.lang.Validate; import org.bukkit.Bukkit; import org.bukkit.Material; @@ -20,7 +19,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; /** - * Represents a stack of items + * Represents a stack of item */ public class ItemStack implements Cloneable, ConfigurationSerializable { private Material type = Material.AIR; @@ -434,6 +433,7 @@ public class ItemStack implements Cloneable, ConfigurationSerializable { return level; } + @Override @NotNull @Utility public Map serialize() { @@ -483,7 +483,7 @@ public class ItemStack implements Cloneable, ConfigurationSerializable { damage = 0; } } else { - type = Material.getMaterial((String) args.get("type")); + type = Bukkit.getUnsafe().getMaterial((String) args.get("type"), version); } if (args.containsKey("amount")) { @@ -509,6 +509,7 @@ public class ItemStack implements Cloneable, ConfigurationSerializable { } else if (args.containsKey("meta")) { // We cannot and will not have meta when enchantments (pre-ItemMeta) exist Object raw = args.get("meta"); if (raw instanceof ItemMeta) { + ((ItemMeta) raw).setVersion(version); result.setItemMeta((ItemMeta) raw); } } diff --git a/api/src/main/java/org/bukkit/inventory/LecternInventory.java b/api/src/main/java/org/bukkit/inventory/LecternInventory.java new file mode 100644 index 000000000..4a0c43acc --- /dev/null +++ b/api/src/main/java/org/bukkit/inventory/LecternInventory.java @@ -0,0 +1,14 @@ +package org.bukkit.inventory; + +import org.bukkit.block.Lectern; +import org.jetbrains.annotations.Nullable; + +/** + * Interface to the inventory of a Lectern. + */ +public interface LecternInventory extends Inventory { + + @Nullable + @Override + public Lectern getHolder(); +} diff --git a/api/src/main/java/org/bukkit/inventory/LoomInventory.java b/api/src/main/java/org/bukkit/inventory/LoomInventory.java new file mode 100644 index 000000000..9801b59e2 --- /dev/null +++ b/api/src/main/java/org/bukkit/inventory/LoomInventory.java @@ -0,0 +1,6 @@ +package org.bukkit.inventory; + +/** + * Interface to the inventory of a Loom. + */ +public interface LoomInventory extends Inventory { } diff --git a/api/src/main/java/org/bukkit/inventory/Merchant.java b/api/src/main/java/org/bukkit/inventory/Merchant.java index 5ff1f93d1..9861bcedd 100644 --- a/api/src/main/java/org/bukkit/inventory/Merchant.java +++ b/api/src/main/java/org/bukkit/inventory/Merchant.java @@ -1,7 +1,6 @@ package org.bukkit.inventory; import java.util.List; - import org.bukkit.entity.HumanEntity; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -35,7 +34,7 @@ public interface Merchant { * * @param i the index * @return the recipe - * @throws IndexOutOfBoundsException Throws when specified index is larger than Merchant's inventory + * @throws IndexOutOfBoundsException if recipe index out of bounds */ @NotNull MerchantRecipe getRecipe(int i) throws IndexOutOfBoundsException; @@ -45,7 +44,7 @@ public interface Merchant { * * @param i the index * @param recipe the recipe - * @throws IndexOutOfBoundsException Throws when specified index is larger than Merchant's inventory + * @throws IndexOutOfBoundsException if recipe index out of bounds */ void setRecipe(int i, @NotNull MerchantRecipe recipe) throws IndexOutOfBoundsException; diff --git a/api/src/main/java/org/bukkit/inventory/MerchantInventory.java b/api/src/main/java/org/bukkit/inventory/MerchantInventory.java index edc67fecc..808635602 100644 --- a/api/src/main/java/org/bukkit/inventory/MerchantInventory.java +++ b/api/src/main/java/org/bukkit/inventory/MerchantInventory.java @@ -1,5 +1,6 @@ package org.bukkit.inventory; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; /** @@ -30,4 +31,12 @@ public interface MerchantInventory extends Inventory { */ @Nullable MerchantRecipe getSelectedRecipe(); + + /** + * Gets the Merchant associated with this inventory. + * + * @return merchant + */ + @NotNull + Merchant getMerchant(); } diff --git a/api/src/main/java/org/bukkit/inventory/MerchantRecipe.java b/api/src/main/java/org/bukkit/inventory/MerchantRecipe.java index dabbdf252..1fb4a1c53 100644 --- a/api/src/main/java/org/bukkit/inventory/MerchantRecipe.java +++ b/api/src/main/java/org/bukkit/inventory/MerchantRecipe.java @@ -1,10 +1,9 @@ package org.bukkit.inventory; import com.google.common.base.Preconditions; -import org.jetbrains.annotations.NotNull; - import java.util.ArrayList; import java.util.List; +import org.jetbrains.annotations.NotNull; /** * Represents a merchant's trade. @@ -27,16 +26,24 @@ public class MerchantRecipe implements Recipe { private int uses; private int maxUses; private boolean experienceReward; + private int villagerExperience; + private float priceMultiplier; public MerchantRecipe(@NotNull ItemStack result, int maxUses) { this(result, 0, maxUses, false); } public MerchantRecipe(@NotNull ItemStack result, int uses, int maxUses, boolean experienceReward) { + this(result, uses, maxUses, experienceReward, 0, 0.0F); + } + + public MerchantRecipe(@NotNull ItemStack result, int uses, int maxUses, boolean experienceReward, int villagerExperience, float priceMultiplier) { this.result = result; this.uses = uses; this.maxUses = maxUses; this.experienceReward = experienceReward; + this.villagerExperience = villagerExperience; + this.priceMultiplier = priceMultiplier; } @NotNull @@ -111,20 +118,58 @@ public class MerchantRecipe implements Recipe { } /** - * Whether to reward experience for the trade. + * Whether to reward experience to the player for the trade. * - * @return whether to reward experience for completing this trade + * @return whether to reward experience to the player for completing this + * trade */ public boolean hasExperienceReward() { return experienceReward; } /** - * Set whether to reward experience for the trade. + * Set whether to reward experience to the player for the trade. * - * @param flag whether to reward experience for completing this trade + * @param flag whether to reward experience to the player for completing + * this trade */ public void setExperienceReward(boolean flag) { this.experienceReward = flag; } + + /** + * Gets the amount of experience the villager earns from this trade. + * + * @return villager experience + */ + public int getVillagerExperience() { + return villagerExperience; + } + + /** + * Sets the amount of experience the villager earns from this trade. + * + * @param villagerExperience new experience amount + */ + public void setVillagerExperience(int villagerExperience) { + this.villagerExperience = villagerExperience; + } + + /** + * Gets the additive price multiplier for the cost of this trade. + * + * @return price multiplier + */ + public float getPriceMultiplier() { + return priceMultiplier; + } + + /** + * Sets the additive price multiplier for the cost of this trade. + * + * @param priceMultiplier new price multiplier + */ + public void setPriceMultiplier(float priceMultiplier) { + this.priceMultiplier = priceMultiplier; + } } diff --git a/api/src/main/java/org/bukkit/inventory/PlayerInventory.java b/api/src/main/java/org/bukkit/inventory/PlayerInventory.java index eb71f01e4..96916ec95 100644 --- a/api/src/main/java/org/bukkit/inventory/PlayerInventory.java +++ b/api/src/main/java/org/bukkit/inventory/PlayerInventory.java @@ -212,6 +212,7 @@ public interface PlayerInventory extends Inventory { */ public void setHeldItemSlot(int slot); + @Override @Nullable public HumanEntity getHolder(); diff --git a/api/src/main/java/org/bukkit/inventory/RecipeChoice.java b/api/src/main/java/org/bukkit/inventory/RecipeChoice.java index 3d2c2b83a..3d325cab6 100644 --- a/api/src/main/java/org/bukkit/inventory/RecipeChoice.java +++ b/api/src/main/java/org/bukkit/inventory/RecipeChoice.java @@ -8,6 +8,7 @@ import java.util.List; import java.util.Objects; import java.util.function.Predicate; import org.bukkit.Material; +import org.bukkit.Tag; import org.jetbrains.annotations.NotNull; /** @@ -49,6 +50,17 @@ public interface RecipeChoice extends Predicate, Cloneable { this(Arrays.asList(choices)); } + /** + * Constructs a MaterialChoice with the current values of the specified + * tag. + * + * @param choices the tag + */ + public MaterialChoice(@NotNull Tag choices) { + Preconditions.checkArgument(choices != null, "choices"); + this.choices = new ArrayList<>(choices.getValues()); + } + public MaterialChoice(@NotNull List choices) { Preconditions.checkArgument(choices != null, "choices"); Preconditions.checkArgument(!choices.isEmpty(), "Must have at least one choice"); @@ -135,7 +147,7 @@ public interface RecipeChoice extends Predicate, Cloneable { * Represents a choice that will be valid only one of the stacks is exactly * matched (aside from stack size). *
                    - * Not valid for shapeless recipes + * Only valid for shaped recipes * * @deprecated draft API */ diff --git a/api/src/main/java/org/bukkit/inventory/ShapedRecipe.java b/api/src/main/java/org/bukkit/inventory/ShapedRecipe.java index 76b2dd7cb..222a12baa 100644 --- a/api/src/main/java/org/bukkit/inventory/ShapedRecipe.java +++ b/api/src/main/java/org/bukkit/inventory/ShapedRecipe.java @@ -4,9 +4,7 @@ import com.google.common.base.Preconditions; import java.util.Collections; import java.util.HashMap; import java.util.Map; - import org.apache.commons.lang.Validate; - import org.bukkit.Keyed; import org.bukkit.Material; import org.bukkit.NamespacedKey; @@ -25,6 +23,7 @@ public class ShapedRecipe implements Recipe, Keyed { @Deprecated public ShapedRecipe(@NotNull ItemStack result) { + Preconditions.checkArgument(result.getType() != Material.AIR, "Recipe must have non-AIR result."); this.key = NamespacedKey.randomKey(); new Throwable("Warning: A plugin is creating a recipe using a Deprecated method. This will cause you to receive warnings stating 'Tried to load unrecognized recipe: bukkit:'. Please ask the author to give their recipe a static key using NamespacedKey.").printStackTrace(); this.output = new ItemStack(result); @@ -44,6 +43,7 @@ public class ShapedRecipe implements Recipe, Keyed { */ public ShapedRecipe(@NotNull NamespacedKey key, @NotNull ItemStack result) { Preconditions.checkArgument(key != null, "key"); + Preconditions.checkArgument(result.getType() != Material.AIR, "Recipe must have non-AIR result."); this.key = key; this.output = new ItemStack(result); @@ -199,6 +199,7 @@ public class ShapedRecipe implements Recipe, Keyed { * * @return The result stack. */ + @Override @NotNull public ItemStack getResult() { return output.clone(); diff --git a/api/src/main/java/org/bukkit/inventory/ShapelessRecipe.java b/api/src/main/java/org/bukkit/inventory/ShapelessRecipe.java index 818bf2936..ddcf84e66 100644 --- a/api/src/main/java/org/bukkit/inventory/ShapelessRecipe.java +++ b/api/src/main/java/org/bukkit/inventory/ShapelessRecipe.java @@ -5,10 +5,8 @@ import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; import java.util.List; - import org.apache.commons.lang.Validate; import org.bukkit.Keyed; - import org.bukkit.Material; import org.bukkit.NamespacedKey; import org.bukkit.material.MaterialData; @@ -26,6 +24,7 @@ public class ShapelessRecipe implements Recipe, Keyed { @Deprecated public ShapelessRecipe(@NotNull ItemStack result) { + Preconditions.checkArgument(result.getType() != Material.AIR, "Recipe must have non-AIR result."); this.key = NamespacedKey.randomKey(); new Throwable("Warning: A plugin is creating a recipe using a Deprecated method. This will cause you to receive warnings stating 'Tried to load unrecognized recipe: bukkit:'. Please ask the author to give their recipe a static key using NamespacedKey.").printStackTrace(); this.output = new ItemStack(result); @@ -46,6 +45,7 @@ public class ShapelessRecipe implements Recipe, Keyed { * @see ShapelessRecipe#addIngredient(int,Material,int) */ public ShapelessRecipe(@NotNull NamespacedKey key, @NotNull ItemStack result) { + Preconditions.checkArgument(result.getType() != Material.AIR, "Recipe must have non-AIR result."); this.key = key; this.output = new ItemStack(result); } @@ -290,6 +290,7 @@ public class ShapelessRecipe implements Recipe, Keyed { * * @return The result stack. */ + @Override @NotNull public ItemStack getResult() { return output.clone(); diff --git a/api/src/main/java/org/bukkit/inventory/SmokingRecipe.java b/api/src/main/java/org/bukkit/inventory/SmokingRecipe.java new file mode 100644 index 000000000..1073d9aec --- /dev/null +++ b/api/src/main/java/org/bukkit/inventory/SmokingRecipe.java @@ -0,0 +1,19 @@ +package org.bukkit.inventory; + +import org.bukkit.Material; +import org.bukkit.NamespacedKey; +import org.jetbrains.annotations.NotNull; + +/** + * Represents a campfire recipe. + */ +public class SmokingRecipe extends CookingRecipe { + + public SmokingRecipe(@NotNull NamespacedKey key, @NotNull ItemStack result, @NotNull Material source, float experience, int cookingTime) { + super(key, result, source, experience, cookingTime); + } + + public SmokingRecipe(@NotNull NamespacedKey key, @NotNull ItemStack result, @NotNull RecipeChoice input, float experience, int cookingTime) { + super(key, result, input, experience, cookingTime); + } +} diff --git a/api/src/main/java/org/bukkit/inventory/StonecutterInventory.java b/api/src/main/java/org/bukkit/inventory/StonecutterInventory.java new file mode 100644 index 000000000..dbb034fae --- /dev/null +++ b/api/src/main/java/org/bukkit/inventory/StonecutterInventory.java @@ -0,0 +1,6 @@ +package org.bukkit.inventory; + +/** + * Interface to the inventory of a Stonecutter. + */ +public interface StonecutterInventory extends Inventory { } diff --git a/api/src/main/java/org/bukkit/inventory/StonecuttingRecipe.java b/api/src/main/java/org/bukkit/inventory/StonecuttingRecipe.java new file mode 100644 index 000000000..d8ef781d6 --- /dev/null +++ b/api/src/main/java/org/bukkit/inventory/StonecuttingRecipe.java @@ -0,0 +1,127 @@ +package org.bukkit.inventory; + +import com.google.common.base.Preconditions; +import java.util.Collections; +import org.bukkit.Keyed; +import org.bukkit.Material; +import org.bukkit.NamespacedKey; +import org.jetbrains.annotations.NotNull; + +/** + * Represents a Stonecutting recipe. + */ +public class StonecuttingRecipe implements Recipe, Keyed { + private final NamespacedKey key; + private ItemStack output; + private RecipeChoice ingredient; + private String group = ""; + + /** + * Create a Stonecutting recipe to craft the specified ItemStack. + * + * @param key The unique recipe key + * @param result The item you want the recipe to create. + * @param source The input material. + */ + public StonecuttingRecipe(@NotNull NamespacedKey key, @NotNull ItemStack result, @NotNull Material source) { + this(key, result, new RecipeChoice.MaterialChoice(Collections.singletonList(source))); + } + + /** + * Create a cooking recipe to craft the specified ItemStack. + * + * @param key The unique recipe key + * @param result The item you want the recipe to create. + * @param input The input choices. + */ + public StonecuttingRecipe(@NotNull NamespacedKey key, @NotNull ItemStack result, @NotNull RecipeChoice input) { + Preconditions.checkArgument(result.getType() != Material.AIR, "Recipe must have non-AIR result."); + this.key = key; + this.output = new ItemStack(result); + this.ingredient = input; + } + + /** + * Sets the input of this cooking recipe. + * + * @param input The input material. + * @return The changed recipe, so you can chain calls. + */ + @NotNull + public StonecuttingRecipe setInput(@NotNull Material input) { + this.ingredient = new RecipeChoice.MaterialChoice(Collections.singletonList(input)); + return this; + } + + /** + * Get the input material. + * + * @return The input material. + */ + @NotNull + public ItemStack getInput() { + return this.ingredient.getItemStack(); + } + + /** + * Sets the input of this cooking recipe. + * + * @param input The input choice. + * @return The changed recipe, so you can chain calls. + */ + @NotNull + public StonecuttingRecipe setInputChoice(@NotNull RecipeChoice input) { + this.ingredient = input; + return (StonecuttingRecipe) this; + } + + /** + * Get the input choice. + * + * @return The input choice. + */ + @NotNull + public RecipeChoice getInputChoice() { + return this.ingredient.clone(); + } + + /** + * Get the result of this recipe. + * + * @return The resulting stack. + */ + @NotNull + @Override + public ItemStack getResult() { + return output.clone(); + } + + @NotNull + @Override + public NamespacedKey getKey() { + return key; + } + + /** + * Get the group of this recipe. Recipes with the same group may be grouped + * together when displayed in the client. + * + * @return recipe group. An empty string denotes no group. May not be null. + */ + @NotNull + public String getGroup() { + return group; + } + + /** + * Set the group of this recipe. Recipes with the same group may be grouped + * together when displayed in the client. + * + * @param group recipe group. An empty string denotes no group. May not be + * null. + */ + public void setGroup(@NotNull String group) { + Preconditions.checkArgument(group != null, "group"); + this.group = group; + } +} diff --git a/api/src/main/java/org/bukkit/inventory/meta/BlockDataMeta.java b/api/src/main/java/org/bukkit/inventory/meta/BlockDataMeta.java new file mode 100644 index 000000000..473c72dcd --- /dev/null +++ b/api/src/main/java/org/bukkit/inventory/meta/BlockDataMeta.java @@ -0,0 +1,37 @@ +package org.bukkit.inventory.meta; + +import org.bukkit.Material; +import org.bukkit.block.data.BlockData; +import org.jetbrains.annotations.NotNull; + +public interface BlockDataMeta extends ItemMeta { + + /** + * Returns whether the item has block data currently attached to it. + * + * @return whether block data is already attached + */ + boolean hasBlockData(); + + /** + * Returns the currently attached block data for this item or creates a new + * one if one doesn't exist. + * + * The state is a copy, it must be set back (or to another item) with + * {@link #setBlockData(org.bukkit.block.data.BlockData)} + * + * @param material the material we wish to get this data in the context of + * @return the attached data or new data + */ + @NotNull + BlockData getBlockData(@NotNull Material material); + + /** + * Attaches a copy of the passed block data to the item. + * + * @param blockData the block data to attach to the block. + * @throws IllegalArgumentException if the blockData is null or invalid for + * this item. + */ + void setBlockData(@NotNull BlockData blockData); +} diff --git a/api/src/main/java/org/bukkit/inventory/meta/BlockStateMeta.java b/api/src/main/java/org/bukkit/inventory/meta/BlockStateMeta.java index d71a4eaf1..e7d905b11 100644 --- a/api/src/main/java/org/bukkit/inventory/meta/BlockStateMeta.java +++ b/api/src/main/java/org/bukkit/inventory/meta/BlockStateMeta.java @@ -9,7 +9,7 @@ public interface BlockStateMeta extends ItemMeta { /** * Returns whether the item has a block state currently * attached to it. - * + * * @return whether a block state is already attached */ boolean hasBlockState(); diff --git a/api/src/main/java/org/bukkit/inventory/meta/BookMeta.java b/api/src/main/java/org/bukkit/inventory/meta/BookMeta.java index 92c149a33..43fb418a8 100644 --- a/api/src/main/java/org/bukkit/inventory/meta/BookMeta.java +++ b/api/src/main/java/org/bukkit/inventory/meta/BookMeta.java @@ -2,7 +2,6 @@ package org.bukkit.inventory.meta; import java.util.List; import net.md_5.bungee.api.chat.BaseComponent; - import org.bukkit.Material; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -184,6 +183,7 @@ public interface BookMeta extends ItemMeta { */ int getPageCount(); + @Override @NotNull BookMeta clone(); diff --git a/api/src/main/java/org/bukkit/inventory/meta/CrossbowMeta.java b/api/src/main/java/org/bukkit/inventory/meta/CrossbowMeta.java new file mode 100644 index 000000000..35c6594fd --- /dev/null +++ b/api/src/main/java/org/bukkit/inventory/meta/CrossbowMeta.java @@ -0,0 +1,44 @@ +package org.bukkit.inventory.meta; + +import java.util.List; +import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public interface CrossbowMeta extends ItemMeta { + + /** + * Returns whether the item has any charged projectiles. + * + * @return whether charged projectiles are present + */ + boolean hasChargedProjectiles(); + + /** + * Returns an immutable list of the projectiles charged on this item. + * + * @return charged projectiles + */ + @NotNull + List getChargedProjectiles(); + + /** + * Sets the projectiles charged on this item. + * + * Removes all projectiles when given null. + * + * @param projectiles the projectiles to set + * @throws IllegalArgumentException if one of the projectiles is not an + * arrow or firework rocket + */ + void setChargedProjectiles(@Nullable List projectiles); + + /** + * Adds a charged projectile to this item. + * + * @param item projectile + * @throws IllegalArgumentException if the projectile is not an arrow or + * firework rocket + */ + void addChargedProjectile(@NotNull ItemStack item); +} diff --git a/api/src/main/java/org/bukkit/inventory/meta/EnchantmentStorageMeta.java b/api/src/main/java/org/bukkit/inventory/meta/EnchantmentStorageMeta.java index c44a227e0..aae2ed2ec 100644 --- a/api/src/main/java/org/bukkit/inventory/meta/EnchantmentStorageMeta.java +++ b/api/src/main/java/org/bukkit/inventory/meta/EnchantmentStorageMeta.java @@ -1,7 +1,6 @@ package org.bukkit.inventory.meta; import java.util.Map; - import org.bukkit.Material; import org.bukkit.enchantments.Enchantment; import org.jetbrains.annotations.NotNull; @@ -77,6 +76,7 @@ public interface EnchantmentStorageMeta extends ItemMeta { */ boolean hasConflictingStoredEnchant(@NotNull Enchantment ench); + @Override @NotNull EnchantmentStorageMeta clone(); } diff --git a/api/src/main/java/org/bukkit/inventory/meta/FireworkEffectMeta.java b/api/src/main/java/org/bukkit/inventory/meta/FireworkEffectMeta.java index e50a029df..ce0f148d2 100644 --- a/api/src/main/java/org/bukkit/inventory/meta/FireworkEffectMeta.java +++ b/api/src/main/java/org/bukkit/inventory/meta/FireworkEffectMeta.java @@ -33,6 +33,7 @@ public interface FireworkEffectMeta extends ItemMeta { @Nullable FireworkEffect getEffect(); + @Override @NotNull FireworkEffectMeta clone(); } diff --git a/api/src/main/java/org/bukkit/inventory/meta/FireworkMeta.java b/api/src/main/java/org/bukkit/inventory/meta/FireworkMeta.java index f1fe2b074..fe2394817 100644 --- a/api/src/main/java/org/bukkit/inventory/meta/FireworkMeta.java +++ b/api/src/main/java/org/bukkit/inventory/meta/FireworkMeta.java @@ -1,7 +1,6 @@ package org.bukkit.inventory.meta; import java.util.List; - import org.bukkit.FireworkEffect; import org.bukkit.Material; import org.jetbrains.annotations.NotNull; @@ -92,6 +91,7 @@ public interface FireworkMeta extends ItemMeta { */ void setPower(int power) throws IllegalArgumentException; + @Override @NotNull FireworkMeta clone(); } diff --git a/api/src/main/java/org/bukkit/inventory/meta/ItemMeta.java b/api/src/main/java/org/bukkit/inventory/meta/ItemMeta.java index 3ed7ea06a..595df539b 100644 --- a/api/src/main/java/org/bukkit/inventory/meta/ItemMeta.java +++ b/api/src/main/java/org/bukkit/inventory/meta/ItemMeta.java @@ -1,11 +1,10 @@ package org.bukkit.inventory.meta; +import com.google.common.collect.Multimap; import java.util.Collection; import java.util.List; import java.util.Map; import java.util.Set; - -import com.google.common.collect.Multimap; import org.bukkit.attribute.Attribute; import org.bukkit.attribute.AttributeModifier; import org.bukkit.configuration.serialization.ConfigurationSerializable; @@ -13,6 +12,7 @@ import org.bukkit.enchantments.Enchantment; import org.bukkit.inventory.EquipmentSlot; import org.bukkit.inventory.ItemFlag; import org.bukkit.inventory.meta.tags.CustomItemTagContainer; +import org.bukkit.persistence.PersistentDataHolder; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -22,7 +22,7 @@ import org.jetbrains.annotations.Nullable; * An implementation will handle the creation and application for ItemMeta. * This class should not be implemented by a plugin in a live environment. */ -public interface ItemMeta extends Cloneable, ConfigurationSerializable { +public interface ItemMeta extends Cloneable, ConfigurationSerializable, PersistentDataHolder { /** * Checks for existence of a display name. @@ -100,6 +100,39 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable { */ void setLore(@Nullable List lore); + /** + * Checks for existence of custom model data. + *

                    + * CustomModelData is an integer that may be associated client side with a + * custom item model. + * + * @return true if this has custom model data + */ + boolean hasCustomModelData(); + + /** + * Gets the custom model data that is set. + *

                    + * CustomModelData is an integer that may be associated client side with a + * custom item model. + *

                    + * Plugins should check that hasCustomModelData() returns true + * before calling this method. + * + * @return the localized name that is set + */ + int getCustomModelData(); + + /** + * Sets the custom model data. + *

                    + * CustomModelData is an integer that may be associated client side with a + * custom item model. + * + * @param data the data to set, or null to clear + */ + void setCustomModelData(@Nullable Integer data); + /** * Checks for the existence of any enchantments. * @@ -336,10 +369,22 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable { * These tags can also be modified by the client once in creative mode * * @return the custom tag container + * @deprecated this API part has been replaced by the {@link PersistentDataHolder} API. + * Please use {@link PersistentDataHolder#getPersistentDataContainer()} instead of this. */ @NotNull + @Deprecated CustomItemTagContainer getCustomTagContainer(); + /** + * Internal use only! Do not use under any circumstances! + * + * @param version version + * @deprecated + */ + @Deprecated + void setVersion(int version); + @SuppressWarnings("javadoc") @NotNull ItemMeta clone(); diff --git a/api/src/main/java/org/bukkit/inventory/meta/LeatherArmorMeta.java b/api/src/main/java/org/bukkit/inventory/meta/LeatherArmorMeta.java index 0b6779c6d..c1676991c 100644 --- a/api/src/main/java/org/bukkit/inventory/meta/LeatherArmorMeta.java +++ b/api/src/main/java/org/bukkit/inventory/meta/LeatherArmorMeta.java @@ -30,6 +30,7 @@ public interface LeatherArmorMeta extends ItemMeta { */ void setColor(@Nullable Color color); + @Override @NotNull LeatherArmorMeta clone(); } diff --git a/api/src/main/java/org/bukkit/inventory/meta/MapMeta.java b/api/src/main/java/org/bukkit/inventory/meta/MapMeta.java index c90ad2379..8fca3ba23 100644 --- a/api/src/main/java/org/bukkit/inventory/meta/MapMeta.java +++ b/api/src/main/java/org/bukkit/inventory/meta/MapMeta.java @@ -156,6 +156,7 @@ public interface MapMeta extends ItemMeta { */ void setColor(@Nullable Color color); + @Override @NotNull MapMeta clone(); } diff --git a/api/src/main/java/org/bukkit/inventory/meta/PotionMeta.java b/api/src/main/java/org/bukkit/inventory/meta/PotionMeta.java index f26ec165f..1056849dc 100644 --- a/api/src/main/java/org/bukkit/inventory/meta/PotionMeta.java +++ b/api/src/main/java/org/bukkit/inventory/meta/PotionMeta.java @@ -1,14 +1,13 @@ package org.bukkit.inventory.meta; +import java.util.List; import org.bukkit.Color; +import org.bukkit.potion.PotionData; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; -import org.bukkit.potion.PotionData; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.List; - /** * Represents a potion or item that can have custom effects. */ diff --git a/api/src/main/java/org/bukkit/inventory/meta/SkullMeta.java b/api/src/main/java/org/bukkit/inventory/meta/SkullMeta.java index 43cdc4c66..8b2465ea2 100644 --- a/api/src/main/java/org/bukkit/inventory/meta/SkullMeta.java +++ b/api/src/main/java/org/bukkit/inventory/meta/SkullMeta.java @@ -71,6 +71,7 @@ public interface SkullMeta extends ItemMeta { */ boolean setOwningPlayer(@Nullable OfflinePlayer owner); + @Override @NotNull SkullMeta clone(); } diff --git a/api/src/main/java/org/bukkit/inventory/meta/SuspiciousStewMeta.java b/api/src/main/java/org/bukkit/inventory/meta/SuspiciousStewMeta.java new file mode 100644 index 000000000..c2f4282c1 --- /dev/null +++ b/api/src/main/java/org/bukkit/inventory/meta/SuspiciousStewMeta.java @@ -0,0 +1,67 @@ +package org.bukkit.inventory.meta; + +import java.util.List; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; +import org.jetbrains.annotations.NotNull; + +/** + * Represents a suspicious stew that can have custom effects. + */ +public interface SuspiciousStewMeta extends ItemMeta { + + /** + * Checks for the presence of custom potion effects. + * + * @return true if custom potion effects are applied + */ + boolean hasCustomEffects(); + + /** + * Gets an immutable list containing all custom potion effects applied to + * this suspicious stew. + *

                    + * Plugins should check that hasCustomEffects() returns true before calling + * this method. + * + * @return the immutable list of custom potion effects + */ + @NotNull + List getCustomEffects(); + + /** + * Adds a custom potion effect to this suspicious stew. + * + * @param effect the potion effect to add + * @param overwrite true if any existing effect of the same type should be + * overwritten + * @return true if the suspicious stew meta changed as a result of this call + */ + boolean addCustomEffect(@NotNull PotionEffect effect, boolean overwrite); + + /** + * Removes a custom potion effect from this suspicious stew. + * + * @param type the potion effect type to remove + * @return true if the suspicious stew meta changed as a result of this call + */ + boolean removeCustomEffect(@NotNull PotionEffectType type); + + /** + * Checks for a specific custom potion effect type on this suspicious stew. + * + * @param type the potion effect type to check for + * @return true if the suspicious stew has this effect + */ + boolean hasCustomEffect(@NotNull PotionEffectType type); + + /** + * Removes all custom potion effects from this suspicious stew. + * + * @return true if the suspicious stew meta changed as a result of this call + */ + boolean clearCustomEffects(); + + @Override + SuspiciousStewMeta clone(); +} diff --git a/api/src/main/java/org/bukkit/inventory/meta/TropicalFishBucketMeta.java b/api/src/main/java/org/bukkit/inventory/meta/TropicalFishBucketMeta.java index 86db7cfa2..268b92e34 100644 --- a/api/src/main/java/org/bukkit/inventory/meta/TropicalFishBucketMeta.java +++ b/api/src/main/java/org/bukkit/inventory/meta/TropicalFishBucketMeta.java @@ -80,6 +80,7 @@ public interface TropicalFishBucketMeta extends ItemMeta { */ boolean hasVariant(); + @Override @NotNull TropicalFishBucketMeta clone(); } diff --git a/api/src/main/java/org/bukkit/inventory/meta/tags/CustomItemTagContainer.java b/api/src/main/java/org/bukkit/inventory/meta/tags/CustomItemTagContainer.java index e3b77998f..f46e2978b 100644 --- a/api/src/main/java/org/bukkit/inventory/meta/tags/CustomItemTagContainer.java +++ b/api/src/main/java/org/bukkit/inventory/meta/tags/CustomItemTagContainer.java @@ -8,7 +8,12 @@ import org.jetbrains.annotations.Nullable; /** * This interface represents a map like object, capable of storing custom tags * in it. + * + * @deprecated this API part has been replaced by the + * {@link org.bukkit.persistence.PersistentDataHolder} API. Please use + * {@link org.bukkit.persistence.PersistentDataHolder} instead of this. */ +@Deprecated public interface CustomItemTagContainer { /** diff --git a/api/src/main/java/org/bukkit/inventory/meta/tags/ItemTagAdapterContext.java b/api/src/main/java/org/bukkit/inventory/meta/tags/ItemTagAdapterContext.java index 9de37daa3..97e6c96ef 100644 --- a/api/src/main/java/org/bukkit/inventory/meta/tags/ItemTagAdapterContext.java +++ b/api/src/main/java/org/bukkit/inventory/meta/tags/ItemTagAdapterContext.java @@ -1,11 +1,17 @@ package org.bukkit.inventory.meta.tags; +import org.bukkit.persistence.PersistentDataAdapterContext; +import org.bukkit.persistence.PersistentDataHolder; import org.jetbrains.annotations.NotNull; /** * This interface represents the context in which the {@link ItemTagType} can * serialize and deserialize the passed values. + * + * @deprecated this API part has been replaced by {@link PersistentDataHolder}. + * Please use {@link PersistentDataAdapterContext} instead of this. */ +@Deprecated public interface ItemTagAdapterContext { /** diff --git a/api/src/main/java/org/bukkit/inventory/meta/tags/ItemTagType.java b/api/src/main/java/org/bukkit/inventory/meta/tags/ItemTagType.java index eab84fe86..09082d481 100644 --- a/api/src/main/java/org/bukkit/inventory/meta/tags/ItemTagType.java +++ b/api/src/main/java/org/bukkit/inventory/meta/tags/ItemTagType.java @@ -1,5 +1,6 @@ package org.bukkit.inventory.meta.tags; +import org.bukkit.persistence.PersistentDataType; import org.jetbrains.annotations.NotNull; /** @@ -10,7 +11,7 @@ import org.jetbrains.annotations.NotNull; * different complex types. This may be useful for the likes of a * UUIDItemTagType: *

                    - * {@code
                    + * {@code
                      * public class UUIDItemTagType implements ItemTagType {
                      *
                      *         {@literal @Override}
                    @@ -38,11 +39,14 @@ import org.jetbrains.annotations.NotNull;
                      *             long secondLong = bb.getLong();
                      *             return new UUID(firstLong, secondLong);
                      *         }
                    - *     }}
                    + * }}
  • * * @param the primary object type that is stored in the given tag * @param the retrieved object type when applying this item tag type + * + * @deprecated please use {@link PersistentDataType} as this part of the api is being replaced */ +@Deprecated public interface ItemTagType { /* diff --git a/api/src/main/java/org/bukkit/loot/LootTable.java b/api/src/main/java/org/bukkit/loot/LootTable.java index b391b55de..73aa119b6 100644 --- a/api/src/main/java/org/bukkit/loot/LootTable.java +++ b/api/src/main/java/org/bukkit/loot/LootTable.java @@ -1,13 +1,12 @@ package org.bukkit.loot; +import java.util.Collection; +import java.util.Random; import org.bukkit.Keyed; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; -import java.util.Collection; -import java.util.Random; - /** * LootTables are technical files that represent what items should be in * naturally generated containers, what items should be dropped when killing a diff --git a/api/src/main/java/org/bukkit/loot/LootTables.java b/api/src/main/java/org/bukkit/loot/LootTables.java index 7b7dcfa27..7e8307399 100644 --- a/api/src/main/java/org/bukkit/loot/LootTables.java +++ b/api/src/main/java/org/bukkit/loot/LootTables.java @@ -25,6 +25,7 @@ public enum LootTables implements Keyed { JUNGLE_TEMPLE("chests/jungle_temple"), JUNGLE_TEMPLE_DISPENSER("chests/jungle_temple_dispenser"), NETHER_BRIDGE("chests/nether_bridge"), + PILLAGER_OUTPOST("chests/pillager_outpost"), SHIPWRECK_MAP("chests/shipwreck_map"), SHIPWRECK_SUPPLY("chests/shipwreck_supply"), SHIPWRECK_TREASURE("chests/shipwreck_treasure"), @@ -35,11 +36,28 @@ public enum LootTables implements Keyed { STRONGHOLD_LIBRARY("chests/stronghold_library"), UNDERWATER_RUIN_BIG("chests/underwater_ruin_big"), UNDERWATER_RUIN_SMALL("chests/underwater_ruin_small"), - VILLAGE_BLACKSMITH("chests/village_blacksmith"), + VILLAGE_ARMORER("chests/village/village_armorer"), + VILLAGE_BUTCHER("chests/village/village_butcher"), + VILLAGE_CARTOGRAPHER("chests/village/village_cartographer"), + VILLAGE_DESERT_HOUSE("chests/village/village_desert_house"), + VILLAGE_FISHER("chests/village/village_fisher"), + VILLAGE_FLETCHER("chests/village/village_fletcher"), + VILLAGE_MASON("chests/village/village_mason"), + VILLAGE_PLAINS_HOUSE("chests/village/village_plains_house"), + VILLAGE_SAVANNA_HOUSE("chests/village/village_savanna_house"), + VILLAGE_SHEPHERD("chests/village/village_shepherd"), + VILLAGE_SNOWY_HOUSE("chests/village/village_snowy_house"), + VILLAGE_TAIGA_HOUSE("chests/village/village_taiga_house"), + VILLAGE_TANNERY("chests/village/village_tannery"), + VILLAGE_TEMPLE("chests/village/village_temple"), + VILLAGE_TOOLSMITH("chests/village/village_toolsmith"), + VILLAGE_WEAPONSMITH("chests/village/village_weaponsmith"), WOODLAND_MANSION("chests/woodland_mansion"), // Entities + ARMOR_STAND("entities/armor_stand"), BAT("entities/bat"), BLAZE("entities/blaze"), + CAT("entities/cat"), CAVE_SPIDER("entities/cave_spider"), CHICKEN("entities/chicken"), COD("entities/cod"), @@ -53,23 +71,28 @@ public enum LootTables implements Keyed { ENDERMITE("entities/endermite"), ENDER_DRAGON("entities/ender_dragon"), EVOKER("entities/evoker"), + FOX("entities/fox"), GHAST("entities/ghast"), GIANT("entities/giant"), GUARDIAN("entities/guardian"), HORSE("entities/horse"), HUSK("entities/husk"), + ILLUSIONER("entities/illusioner"), IRON_GOLEM("entities/iron_golem"), LLAMA("entities/llama"), MAGMA_CUBE("entities/magma_cube"), + MOOSHROOM("entities/mooshroom"), MULE("entities/mule"), - MUSHROOM_COW("entities/mushroom_cow"), OCELOT("entities/ocelot"), + PANDA("entities/panda"), PARROT("entities/parrot"), PHANTOM("entities/phantom"), PIG("entities/pig"), + PILLAGER("entities/pillager"), POLAR_BEAR("entities/polar_bear"), PUFFERFISH("entities/pufferfish"), RABBIT("entities/rabbit"), + RAVAGER("entities/ravager"), SALMON("entities/salmon"), // Sheep entry here, moved below for organizational purposes SHULKER("entities/shulker"), @@ -81,12 +104,15 @@ public enum LootTables implements Keyed { SPIDER("entities/spider"), SQUID("entities/squid"), STRAY("entities/stray"), + TRADER_LLAMA("entities/trader_llama"), TROPICAL_FISH("entities/tropical_fish"), TURTLE("entities/turtle"), VEX("entities/vex"), VILLAGER("entities/villager"), VINDICATOR("entities/vindicator"), + WANDERING_TRADER("entities/wandering_trader"), WITCH("entities/witch"), + WITHER("entities/wither"), WITHER_SKELETON("entities/wither_skeleton"), WOLF("entities/wolf"), ZOMBIE("entities/zombie"), @@ -94,10 +120,24 @@ public enum LootTables implements Keyed { ZOMBIE_PIGMAN("entities/zombie_pigman"), ZOMBIE_VILLAGER("entities/zombie_villager"), // Gameplay + ARMORER_GIFT("gameplay/hero_of_the_village/armorer_gift"), + BUTCHER_GIFT("gameplay/hero_of_the_village/butcher_gift"), + CARTOGRAPHER_GIFT("gameplay/hero_of_the_village/cartographer_gift"), + CAT_MORNING_GIFT("gameplay/cat_morning_gift"), + CLERIC_GIFT("gameplay/hero_of_the_village/cleric_gift"), + FARMER_GIFT("gameplay/hero_of_the_village/farmer_gift"), + FISHERMAN_GIFT("gameplay/hero_of_the_village/fisherman_gift"), FISHING("gameplay/fishing"), FISHING_FISH("gameplay/fishing/fish"), FISHING_JUNK("gameplay/fishing/junk"), FISHING_TREASURE("gameplay/fishing/treasure"), + FLETCHER_GIFT("gameplay/hero_of_the_village/fletcher_gift"), + LEATHERWORKER_GIFT("gameplay/hero_of_the_village/leatherworker_gift"), + LIBRARIAN_GIFT("gameplay/hero_of_the_village/librarian_gift"), + MASON_GIFT("gameplay/hero_of_the_village/mason_gift"), + SHEPHERD_GIFT("gameplay/hero_of_the_village/shepherd_gift"), + TOOLSMITH_GIFT("gameplay/hero_of_the_village/toolsmith_gift"), + WEAPONSMITH_GIFT("gameplay/hero_of_the_village/weaponsmith_gift"), // Sheep SHEEP("entities/sheep"), SHEEP_BLACK("entities/sheep/black"), @@ -107,6 +147,7 @@ public enum LootTables implements Keyed { SHEEP_GRAY("entities/sheep/gray"), SHEEP_GREEN("entities/sheep/green"), SHEEP_LIGHT_BLUE("entities/sheep/light_blue"), + SHEEP_LIGHT_GRAY("entities/sheep/light_gray"), SHEEP_LIME("entities/sheep/lime"), SHEEP_MAGENTA("entities/sheep/magenta"), SHEEP_ORANGE("entities/sheep/orange"), diff --git a/api/src/main/java/org/bukkit/map/MapCanvas.java b/api/src/main/java/org/bukkit/map/MapCanvas.java index f04b01088..cc1714019 100644 --- a/api/src/main/java/org/bukkit/map/MapCanvas.java +++ b/api/src/main/java/org/bukkit/map/MapCanvas.java @@ -1,8 +1,7 @@ package org.bukkit.map; -import org.jetbrains.annotations.NotNull; - import java.awt.Image; +import org.jetbrains.annotations.NotNull; /** * Represents a canvas for drawing to a map. Each canvas is associated with a diff --git a/api/src/main/java/org/bukkit/map/MapCursor.java b/api/src/main/java/org/bukkit/map/MapCursor.java index 264c17820..29f979945 100644 --- a/api/src/main/java/org/bukkit/map/MapCursor.java +++ b/api/src/main/java/org/bukkit/map/MapCursor.java @@ -262,7 +262,7 @@ public final class MapCursor { /** * - * @return the value + * @return the value * @deprecated Magic value */ @Deprecated diff --git a/api/src/main/java/org/bukkit/map/MapCursorCollection.java b/api/src/main/java/org/bukkit/map/MapCursorCollection.java index be0683ba6..4dba721ae 100644 --- a/api/src/main/java/org/bukkit/map/MapCursorCollection.java +++ b/api/src/main/java/org/bukkit/map/MapCursorCollection.java @@ -1,10 +1,9 @@ package org.bukkit.map; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - import java.util.ArrayList; import java.util.List; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Represents all the map cursors on a {@link MapCanvas}. Like MapCanvas, a diff --git a/api/src/main/java/org/bukkit/map/MapPalette.java b/api/src/main/java/org/bukkit/map/MapPalette.java index afe727e24..8c3016d47 100644 --- a/api/src/main/java/org/bukkit/map/MapPalette.java +++ b/api/src/main/java/org/bukkit/map/MapPalette.java @@ -1,12 +1,11 @@ package org.bukkit.map; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - import java.awt.Color; import java.awt.Graphics2D; import java.awt.Image; import java.awt.image.BufferedImage; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Represents the palette that map items use. diff --git a/api/src/main/java/org/bukkit/map/MapRenderer.java b/api/src/main/java/org/bukkit/map/MapRenderer.java index 93aeaf7e5..cb7040876 100644 --- a/api/src/main/java/org/bukkit/map/MapRenderer.java +++ b/api/src/main/java/org/bukkit/map/MapRenderer.java @@ -34,7 +34,7 @@ public abstract class MapRenderer { * * @return True if contextual, false otherwise. */ - final public boolean isContextual() { + public final boolean isContextual() { return contextual; } @@ -52,6 +52,6 @@ public abstract class MapRenderer { * @param canvas The canvas to use for rendering. * @param player The player who triggered the rendering. */ - abstract public void render(@NotNull MapView map, @NotNull MapCanvas canvas, @NotNull Player player); + public abstract void render(@NotNull MapView map, @NotNull MapCanvas canvas, @NotNull Player player); } diff --git a/api/src/main/java/org/bukkit/map/MapView.java b/api/src/main/java/org/bukkit/map/MapView.java index 29dd573ac..9b8b68b66 100644 --- a/api/src/main/java/org/bukkit/map/MapView.java +++ b/api/src/main/java/org/bukkit/map/MapView.java @@ -158,6 +158,22 @@ public interface MapView { */ public boolean removeRenderer(@Nullable MapRenderer renderer); + /** + * Gets whether a position cursor should be shown when the map is near its + * center. + * + * @return tracking status + */ + boolean isTrackingPosition(); + + /** + * Sets whether a position cursor should be shown when the map is near its + * center. + * + * @param trackingPosition tracking status + */ + void setTrackingPosition(boolean trackingPosition); + /** * Whether the map will show a smaller position cursor (true), or no * position cursor (false) when cursor is outside of map's range. @@ -173,4 +189,22 @@ public interface MapView { * @param unlimited tracking state */ void setUnlimitedTracking(boolean unlimited); + + /** + * Gets whether the map is locked or not. + * + * A locked map may not be explored further. + * + * @return lock status + */ + boolean isLocked(); + + /** + * Gets whether the map is locked or not. + * + * A locked map may not be explored further. + * + * @param locked status + */ + void setLocked(boolean locked); } diff --git a/api/src/main/java/org/bukkit/material/Banner.java b/api/src/main/java/org/bukkit/material/Banner.java index 5f1843f9f..02d5fb67f 100644 --- a/api/src/main/java/org/bukkit/material/Banner.java +++ b/api/src/main/java/org/bukkit/material/Banner.java @@ -3,6 +3,11 @@ package org.bukkit.material; import org.bukkit.Material; import org.bukkit.block.BlockFace; +/** + * @deprecated all usage of MaterialData is deprecated and subject to removal. + * Use {@link org.bukkit.block.data.BlockData}. + */ +@Deprecated public class Banner extends MaterialData implements Attachable { public Banner() { @@ -28,6 +33,7 @@ public class Banner extends MaterialData implements Attachable { return getItemType() == Material.LEGACY_WALL_BANNER; } + @Override public BlockFace getAttachedFace() { if (isWallBanner()) { byte data = getData(); @@ -52,6 +58,7 @@ public class Banner extends MaterialData implements Attachable { } } + @Override public BlockFace getFacing() { byte data = getData(); @@ -112,6 +119,7 @@ public class Banner extends MaterialData implements Attachable { } } + @Override public void setFacingDirection(BlockFace face) { byte data; diff --git a/api/src/main/java/org/bukkit/material/Bed.java b/api/src/main/java/org/bukkit/material/Bed.java index 63965682d..c5256129e 100644 --- a/api/src/main/java/org/bukkit/material/Bed.java +++ b/api/src/main/java/org/bukkit/material/Bed.java @@ -5,7 +5,11 @@ import org.bukkit.block.BlockFace; /** * Represents a bed. + * + * @deprecated all usage of MaterialData is deprecated and subject to removal. + * Use {@link org.bukkit.block.data.BlockData}. */ +@Deprecated public class Bed extends MaterialData implements Directional { /** @@ -61,6 +65,7 @@ public class Bed extends MaterialData implements Directional { * Set which direction the head of the bed is facing. Note that this will * only affect one of the two blocks the bed is made of. */ + @Override public void setFacingDirection(BlockFace face) { byte data; @@ -94,6 +99,7 @@ public class Bed extends MaterialData implements Directional { * * @return the direction the head of the bed is facing */ + @Override public BlockFace getFacing() { byte data = (byte) (getData() & 0x7); diff --git a/api/src/main/java/org/bukkit/material/Button.java b/api/src/main/java/org/bukkit/material/Button.java index 62c499a10..da7d016cf 100644 --- a/api/src/main/java/org/bukkit/material/Button.java +++ b/api/src/main/java/org/bukkit/material/Button.java @@ -1,11 +1,15 @@ package org.bukkit.material; -import org.bukkit.block.BlockFace; import org.bukkit.Material; +import org.bukkit.block.BlockFace; /** * Represents a button + * + * @deprecated all usage of MaterialData is deprecated and subject to removal. + * Use {@link org.bukkit.block.data.BlockData}. */ +@Deprecated public class Button extends SimpleAttachableMaterialData implements Redstone { public Button() { super(Material.LEGACY_STONE_BUTTON); @@ -31,6 +35,7 @@ public class Button extends SimpleAttachableMaterialData implements Redstone { * * @return true if powered, otherwise false */ + @Override public boolean isPowered() { return (getData() & 0x8) == 0x8; } @@ -50,6 +55,7 @@ public class Button extends SimpleAttachableMaterialData implements Redstone { * * @return BlockFace attached to */ + @Override public BlockFace getAttachedFace() { byte data = (byte) (getData() & 0x7); @@ -79,6 +85,7 @@ public class Button extends SimpleAttachableMaterialData implements Redstone { /** * Sets the direction this button is pointing toward */ + @Override public void setFacingDirection(BlockFace face) { byte data = (byte) (getData() & 0x8); diff --git a/api/src/main/java/org/bukkit/material/Cake.java b/api/src/main/java/org/bukkit/material/Cake.java index 25e3db486..d39dd4916 100644 --- a/api/src/main/java/org/bukkit/material/Cake.java +++ b/api/src/main/java/org/bukkit/material/Cake.java @@ -2,6 +2,11 @@ package org.bukkit.material; import org.bukkit.Material; +/** + * @deprecated all usage of MaterialData is deprecated and subject to removal. + * Use {@link org.bukkit.block.data.BlockData}. + */ +@Deprecated public class Cake extends MaterialData { public Cake() { super(Material.LEGACY_CAKE_BLOCK); diff --git a/api/src/main/java/org/bukkit/material/Cauldron.java b/api/src/main/java/org/bukkit/material/Cauldron.java index 90e7a5aff..f998396c3 100644 --- a/api/src/main/java/org/bukkit/material/Cauldron.java +++ b/api/src/main/java/org/bukkit/material/Cauldron.java @@ -4,7 +4,11 @@ import org.bukkit.Material; /** * Represents a cauldron + * + * @deprecated all usage of MaterialData is deprecated and subject to removal. + * Use {@link org.bukkit.block.data.BlockData}. */ +@Deprecated public class Cauldron extends MaterialData { private static final int CAULDRON_FULL = 3; private static final int CAULDRON_EMPTY = 0; diff --git a/api/src/main/java/org/bukkit/material/Chest.java b/api/src/main/java/org/bukkit/material/Chest.java index 48ef0b8cc..4d120d3c3 100644 --- a/api/src/main/java/org/bukkit/material/Chest.java +++ b/api/src/main/java/org/bukkit/material/Chest.java @@ -5,7 +5,11 @@ import org.bukkit.block.BlockFace; /** * Represents a chest + * + * @deprecated all usage of MaterialData is deprecated and subject to removal. + * Use {@link org.bukkit.block.data.BlockData}. */ +@Deprecated public class Chest extends DirectionalContainer { public Chest() { diff --git a/api/src/main/java/org/bukkit/material/Coal.java b/api/src/main/java/org/bukkit/material/Coal.java index 1ac6faaf6..fb842cfa7 100644 --- a/api/src/main/java/org/bukkit/material/Coal.java +++ b/api/src/main/java/org/bukkit/material/Coal.java @@ -5,7 +5,11 @@ import org.bukkit.Material; /** * Represents the different types of coals. + * + * @deprecated all usage of MaterialData is deprecated and subject to removal. + * Use {@link org.bukkit.block.data.BlockData}. */ +@Deprecated public class Coal extends MaterialData { public Coal() { super(Material.LEGACY_COAL); diff --git a/api/src/main/java/org/bukkit/material/CocoaPlant.java b/api/src/main/java/org/bukkit/material/CocoaPlant.java index 298222006..b1b1c729d 100644 --- a/api/src/main/java/org/bukkit/material/CocoaPlant.java +++ b/api/src/main/java/org/bukkit/material/CocoaPlant.java @@ -5,7 +5,11 @@ import org.bukkit.block.BlockFace; /** * Represents the cocoa plant + * + * @deprecated all usage of MaterialData is deprecated and subject to removal. + * Use {@link org.bukkit.block.data.BlockData}. */ +@Deprecated public class CocoaPlant extends MaterialData implements Directional, Attachable { public enum CocoaPlantSize { @@ -75,10 +79,12 @@ public class CocoaPlant extends MaterialData implements Directional, Attachable setData((byte) dat); } + @Override public BlockFace getAttachedFace() { return getFacing().getOppositeFace(); } + @Override public void setFacingDirection(BlockFace face) { int dat = getData() & 0xC; switch (face) { @@ -98,6 +104,7 @@ public class CocoaPlant extends MaterialData implements Directional, Attachable setData((byte) dat); } + @Override public BlockFace getFacing() { switch (getData() & 0x3) { case 0: diff --git a/api/src/main/java/org/bukkit/material/Command.java b/api/src/main/java/org/bukkit/material/Command.java index 7f6a88d5d..bcac1b082 100644 --- a/api/src/main/java/org/bukkit/material/Command.java +++ b/api/src/main/java/org/bukkit/material/Command.java @@ -4,7 +4,11 @@ import org.bukkit.Material; /** * Represents a command block + * + * @deprecated all usage of MaterialData is deprecated and subject to removal. + * Use {@link org.bukkit.block.data.BlockData}. */ +@Deprecated public class Command extends MaterialData implements Redstone { public Command() { super(Material.LEGACY_COMMAND); @@ -30,6 +34,7 @@ public class Command extends MaterialData implements Redstone { * * @return true if powered, otherwise false */ + @Override public boolean isPowered() { return (getData() & 1) != 0; } diff --git a/api/src/main/java/org/bukkit/material/Comparator.java b/api/src/main/java/org/bukkit/material/Comparator.java index 3464e8b70..49d32d544 100644 --- a/api/src/main/java/org/bukkit/material/Comparator.java +++ b/api/src/main/java/org/bukkit/material/Comparator.java @@ -8,7 +8,11 @@ import org.bukkit.block.BlockFace; * * @see Material#LEGACY_REDSTONE_COMPARATOR_OFF * @see Material#LEGACY_REDSTONE_COMPARATOR_ON + * + * @deprecated all usage of MaterialData is deprecated and subject to removal. + * Use {@link org.bukkit.block.data.BlockData}. */ +@Deprecated public class Comparator extends MaterialData implements Directional, Redstone { protected static final BlockFace DEFAULT_DIRECTION = BlockFace.NORTH; protected static final boolean DEFAULT_SUBTRACTION_MODE = false; diff --git a/api/src/main/java/org/bukkit/material/Crops.java b/api/src/main/java/org/bukkit/material/Crops.java index 0706f7a2e..4cf3de5fb 100644 --- a/api/src/main/java/org/bukkit/material/Crops.java +++ b/api/src/main/java/org/bukkit/material/Crops.java @@ -11,7 +11,11 @@ import org.bukkit.Material; * @see Material#LEGACY_POTATO * @see Material#LEGACY_BEETROOT_BLOCK * @see Material#LEGACY_NETHER_WARTS + * + * @deprecated all usage of MaterialData is deprecated and subject to removal. + * Use {@link org.bukkit.block.data.BlockData}. */ +@Deprecated public class Crops extends MaterialData { protected static final Material DEFAULT_TYPE = Material.LEGACY_CROPS; protected static final CropState DEFAULT_STATE = CropState.SEEDED; diff --git a/api/src/main/java/org/bukkit/material/DetectorRail.java b/api/src/main/java/org/bukkit/material/DetectorRail.java index 32d5db523..e8ab29042 100644 --- a/api/src/main/java/org/bukkit/material/DetectorRail.java +++ b/api/src/main/java/org/bukkit/material/DetectorRail.java @@ -4,7 +4,11 @@ import org.bukkit.Material; /** * Represents a detector rail + * + * @deprecated all usage of MaterialData is deprecated and subject to removal. + * Use {@link org.bukkit.block.data.BlockData}. */ +@Deprecated public class DetectorRail extends ExtendedRails implements PressureSensor { public DetectorRail() { super(Material.LEGACY_DETECTOR_RAIL); @@ -24,6 +28,7 @@ public class DetectorRail extends ExtendedRails implements PressureSensor { super(type, data); } + @Override public boolean isPressed() { return (getData() & 0x8) == 0x8; } diff --git a/api/src/main/java/org/bukkit/material/Diode.java b/api/src/main/java/org/bukkit/material/Diode.java index 9b7d02ef6..36a62258b 100644 --- a/api/src/main/java/org/bukkit/material/Diode.java +++ b/api/src/main/java/org/bukkit/material/Diode.java @@ -9,7 +9,11 @@ import org.bukkit.block.BlockFace; * * @see Material#LEGACY_DIODE_BLOCK_OFF * @see Material#LEGACY_DIODE_BLOCK_ON + * + * @deprecated all usage of MaterialData is deprecated and subject to removal. + * Use {@link org.bukkit.block.data.BlockData}. */ +@Deprecated public class Diode extends MaterialData implements Directional, Redstone { protected static final BlockFace DEFAULT_DIRECTION = BlockFace.NORTH; diff --git a/api/src/main/java/org/bukkit/material/DirectionalContainer.java b/api/src/main/java/org/bukkit/material/DirectionalContainer.java index 514336318..0190e5f3d 100644 --- a/api/src/main/java/org/bukkit/material/DirectionalContainer.java +++ b/api/src/main/java/org/bukkit/material/DirectionalContainer.java @@ -5,7 +5,11 @@ import org.bukkit.block.BlockFace; /** * Represents a furnace or a dispenser. + * + * @deprecated all usage of MaterialData is deprecated and subject to removal. + * Use {@link org.bukkit.block.data.BlockData}. */ +@Deprecated public class DirectionalContainer extends MaterialData implements Directional { public DirectionalContainer(final Material type) { @@ -22,6 +26,7 @@ public class DirectionalContainer extends MaterialData implements Directional { super(type, data); } + @Override public void setFacingDirection(BlockFace face) { byte data; @@ -46,6 +51,7 @@ public class DirectionalContainer extends MaterialData implements Directional { setData(data); } + @Override public BlockFace getFacing() { byte data = getData(); diff --git a/api/src/main/java/org/bukkit/material/Dispenser.java b/api/src/main/java/org/bukkit/material/Dispenser.java index d078664a6..b12993a93 100644 --- a/api/src/main/java/org/bukkit/material/Dispenser.java +++ b/api/src/main/java/org/bukkit/material/Dispenser.java @@ -5,7 +5,11 @@ import org.bukkit.block.BlockFace; /** * Represents a dispenser. + * + * @deprecated all usage of MaterialData is deprecated and subject to removal. + * Use {@link org.bukkit.block.data.BlockData}. */ +@Deprecated public class Dispenser extends FurnaceAndDispenser { public Dispenser() { @@ -31,6 +35,7 @@ public class Dispenser extends FurnaceAndDispenser { super(type, data); } + @Override public void setFacingDirection(BlockFace face) { byte data; @@ -63,6 +68,7 @@ public class Dispenser extends FurnaceAndDispenser { setData(data); } + @Override public BlockFace getFacing() { int data = getData() & 0x7; diff --git a/api/src/main/java/org/bukkit/material/Door.java b/api/src/main/java/org/bukkit/material/Door.java index 15f2928e6..d04ece5ab 100644 --- a/api/src/main/java/org/bukkit/material/Door.java +++ b/api/src/main/java/org/bukkit/material/Door.java @@ -18,7 +18,11 @@ import org.bukkit.block.BlockFace; * @see Material#LEGACY_JUNGLE_DOOR * @see Material#LEGACY_ACACIA_DOOR * @see Material#LEGACY_DARK_OAK_DOOR + * + * @deprecated all usage of MaterialData is deprecated and subject to removal. + * Use {@link org.bukkit.block.data.BlockData}. */ +@Deprecated public class Door extends MaterialData implements Directional, Openable { // This class breaks API contracts on Directional and Openable because @@ -200,6 +204,7 @@ public class Door extends MaterialData implements Directional, Openable { /** * Result is undefined if isTopHalf() is true. */ + @Override public boolean isOpen() { return ((getData() & 0x4) == 0x4); } @@ -207,6 +212,7 @@ public class Door extends MaterialData implements Directional, Openable { /** * Set whether the door is open. Undefined if isTopHalf() is true. */ + @Override public void setOpen(boolean isOpen) { setData((byte) (isOpen ? (getData() | 0x4) : (getData() & ~0x4))); } @@ -248,6 +254,7 @@ public class Door extends MaterialData implements Directional, Openable { * * @param face the direction */ + @Override public void setFacingDirection(BlockFace face) { byte data = (byte) (getData() & 0xC); switch (face) { @@ -274,6 +281,7 @@ public class Door extends MaterialData implements Directional, Openable { * * @return the direction */ + @Override public BlockFace getFacing() { byte data = (byte) (getData() & 0x3); switch (data) { diff --git a/api/src/main/java/org/bukkit/material/Dye.java b/api/src/main/java/org/bukkit/material/Dye.java index 5752be0ee..f34f23da7 100644 --- a/api/src/main/java/org/bukkit/material/Dye.java +++ b/api/src/main/java/org/bukkit/material/Dye.java @@ -5,7 +5,11 @@ import org.bukkit.Material; /** * Represents dye + * + * @deprecated all usage of MaterialData is deprecated and subject to removal. + * Use {@link org.bukkit.block.data.BlockData}. */ +@Deprecated public class Dye extends MaterialData implements Colorable { public Dye() { super(Material.LEGACY_INK_SACK); @@ -37,6 +41,7 @@ public class Dye extends MaterialData implements Colorable { * * @return DyeColor of this dye */ + @Override public DyeColor getColor() { return DyeColor.getByDyeData(getData()); } @@ -46,6 +51,7 @@ public class Dye extends MaterialData implements Colorable { * * @param color New color of this dye */ + @Override public void setColor(DyeColor color) { setData(color.getDyeData()); } diff --git a/api/src/main/java/org/bukkit/material/EnderChest.java b/api/src/main/java/org/bukkit/material/EnderChest.java index c03eb018f..ad232cacd 100644 --- a/api/src/main/java/org/bukkit/material/EnderChest.java +++ b/api/src/main/java/org/bukkit/material/EnderChest.java @@ -5,7 +5,11 @@ import org.bukkit.block.BlockFace; /** * Represents an ender chest + * + * @deprecated all usage of MaterialData is deprecated and subject to removal. + * Use {@link org.bukkit.block.data.BlockData}. */ +@Deprecated public class EnderChest extends DirectionalContainer { public EnderChest() { diff --git a/api/src/main/java/org/bukkit/material/ExtendedRails.java b/api/src/main/java/org/bukkit/material/ExtendedRails.java index 9d7906c11..5f70e5bde 100644 --- a/api/src/main/java/org/bukkit/material/ExtendedRails.java +++ b/api/src/main/java/org/bukkit/material/ExtendedRails.java @@ -6,7 +6,11 @@ import org.bukkit.block.BlockFace; /** * This is the superclass for the {@link DetectorRail} and {@link PoweredRail} * classes + * + * @deprecated all usage of MaterialData is deprecated and subject to removal. + * Use {@link org.bukkit.block.data.BlockData}. */ +@Deprecated public class ExtendedRails extends Rails { public ExtendedRails(final Material type) { diff --git a/api/src/main/java/org/bukkit/material/Furnace.java b/api/src/main/java/org/bukkit/material/Furnace.java index 1a9190fe8..380f7f4b1 100644 --- a/api/src/main/java/org/bukkit/material/Furnace.java +++ b/api/src/main/java/org/bukkit/material/Furnace.java @@ -5,7 +5,11 @@ import org.bukkit.block.BlockFace; /** * Represents a furnace. + * + * @deprecated all usage of MaterialData is deprecated and subject to removal. + * Use {@link org.bukkit.block.data.BlockData}. */ +@Deprecated public class Furnace extends FurnaceAndDispenser { public Furnace() { diff --git a/api/src/main/java/org/bukkit/material/FurnaceAndDispenser.java b/api/src/main/java/org/bukkit/material/FurnaceAndDispenser.java index fbe408308..effa0d8a9 100644 --- a/api/src/main/java/org/bukkit/material/FurnaceAndDispenser.java +++ b/api/src/main/java/org/bukkit/material/FurnaceAndDispenser.java @@ -4,7 +4,11 @@ import org.bukkit.Material; /** * Represents a furnace or dispenser, two types of directional containers + * + * @deprecated all usage of MaterialData is deprecated and subject to removal. + * Use {@link org.bukkit.block.data.BlockData}. */ +@Deprecated public class FurnaceAndDispenser extends DirectionalContainer { public FurnaceAndDispenser(final Material type) { diff --git a/api/src/main/java/org/bukkit/material/Gate.java b/api/src/main/java/org/bukkit/material/Gate.java index ff0420610..fc67fc59a 100644 --- a/api/src/main/java/org/bukkit/material/Gate.java +++ b/api/src/main/java/org/bukkit/material/Gate.java @@ -5,7 +5,11 @@ import org.bukkit.block.BlockFace; /** * Represents a fence gate + * + * @deprecated all usage of MaterialData is deprecated and subject to removal. + * Use {@link org.bukkit.block.data.BlockData}. */ +@Deprecated public class Gate extends MaterialData implements Directional, Openable { private static final byte OPEN_BIT = 0x4; private static final byte DIR_BIT = 0x3; @@ -32,6 +36,7 @@ public class Gate extends MaterialData implements Directional, Openable { super(Material.LEGACY_FENCE_GATE, data); } + @Override public void setFacingDirection(BlockFace face) { byte data = (byte) (getData() & ~DIR_BIT); @@ -54,6 +59,7 @@ public class Gate extends MaterialData implements Directional, Openable { setData(data); } + @Override public BlockFace getFacing() { switch (getData() & DIR_BIT) { case GATE_SOUTH: @@ -69,10 +75,12 @@ public class Gate extends MaterialData implements Directional, Openable { return BlockFace.EAST; } + @Override public boolean isOpen() { return (getData() & OPEN_BIT) > 0; } + @Override public void setOpen(boolean isOpen) { byte data = getData(); diff --git a/api/src/main/java/org/bukkit/material/Hopper.java b/api/src/main/java/org/bukkit/material/Hopper.java index 832d148a7..cfd32666c 100644 --- a/api/src/main/java/org/bukkit/material/Hopper.java +++ b/api/src/main/java/org/bukkit/material/Hopper.java @@ -8,7 +8,11 @@ import org.bukkit.block.BlockFace; * specific direction. * * @see Material#HOPPER + * + * @deprecated all usage of MaterialData is deprecated and subject to removal. + * Use {@link org.bukkit.block.data.BlockData}. */ +@Deprecated public class Hopper extends MaterialData implements Directional, Redstone { protected static final BlockFace DEFAULT_DIRECTION = BlockFace.DOWN; diff --git a/api/src/main/java/org/bukkit/material/Ladder.java b/api/src/main/java/org/bukkit/material/Ladder.java index b4f9db90f..de2635308 100644 --- a/api/src/main/java/org/bukkit/material/Ladder.java +++ b/api/src/main/java/org/bukkit/material/Ladder.java @@ -1,11 +1,15 @@ package org.bukkit.material; -import org.bukkit.block.BlockFace; import org.bukkit.Material; +import org.bukkit.block.BlockFace; /** * Represents Ladder data + * + * @deprecated all usage of MaterialData is deprecated and subject to removal. + * Use {@link org.bukkit.block.data.BlockData}. */ +@Deprecated public class Ladder extends SimpleAttachableMaterialData { public Ladder() { super(Material.LEGACY_LADDER); @@ -30,6 +34,7 @@ public class Ladder extends SimpleAttachableMaterialData { * * @return BlockFace attached to */ + @Override public BlockFace getAttachedFace() { byte data = getData(); @@ -53,6 +58,7 @@ public class Ladder extends SimpleAttachableMaterialData { /** * Sets the direction this ladder is facing */ + @Override public void setFacingDirection(BlockFace face) { byte data = (byte) 0x0; diff --git a/api/src/main/java/org/bukkit/material/Leaves.java b/api/src/main/java/org/bukkit/material/Leaves.java index f118fbab1..923a794ac 100644 --- a/api/src/main/java/org/bukkit/material/Leaves.java +++ b/api/src/main/java/org/bukkit/material/Leaves.java @@ -9,7 +9,11 @@ import org.bukkit.TreeSpecies; * * @see Material#LEGACY_LEAVES * @see Material#LEGACY_LEAVES_2 + * + * @deprecated all usage of MaterialData is deprecated and subject to removal. + * Use {@link org.bukkit.block.data.BlockData}. */ +@Deprecated public class Leaves extends Wood { protected static final Material DEFAULT_TYPE = Material.LEGACY_LEAVES; protected static final boolean DEFAULT_DECAYABLE = true; diff --git a/api/src/main/java/org/bukkit/material/Lever.java b/api/src/main/java/org/bukkit/material/Lever.java index 5bc835332..09f290f88 100644 --- a/api/src/main/java/org/bukkit/material/Lever.java +++ b/api/src/main/java/org/bukkit/material/Lever.java @@ -1,11 +1,15 @@ package org.bukkit.material; -import org.bukkit.block.BlockFace; import org.bukkit.Material; +import org.bukkit.block.BlockFace; /** * Represents a lever + * + * @deprecated all usage of MaterialData is deprecated and subject to removal. + * Use {@link org.bukkit.block.data.BlockData}. */ +@Deprecated public class Lever extends SimpleAttachableMaterialData implements Redstone { public Lever() { super(Material.LEGACY_LEVER); @@ -31,6 +35,7 @@ public class Lever extends SimpleAttachableMaterialData implements Redstone { * * @return true if powered, otherwise false */ + @Override public boolean isPowered() { return (getData() & 0x8) == 0x8; } @@ -49,6 +54,7 @@ public class Lever extends SimpleAttachableMaterialData implements Redstone { * * @return BlockFace attached to */ + @Override public BlockFace getAttachedFace() { byte data = (byte) (getData() & 0x7); @@ -81,6 +87,7 @@ public class Lever extends SimpleAttachableMaterialData implements Redstone { /** * Sets the direction this lever is pointing in */ + @Override public void setFacingDirection(BlockFace face) { byte data = (byte) (getData() & 0x8); BlockFace attach = getAttachedFace(); diff --git a/api/src/main/java/org/bukkit/material/LongGrass.java b/api/src/main/java/org/bukkit/material/LongGrass.java index 7592ca7ff..497857ec3 100644 --- a/api/src/main/java/org/bukkit/material/LongGrass.java +++ b/api/src/main/java/org/bukkit/material/LongGrass.java @@ -5,7 +5,11 @@ import org.bukkit.Material; /** * Represents the different types of long grasses. + * + * @deprecated all usage of MaterialData is deprecated and subject to removal. + * Use {@link org.bukkit.block.data.BlockData}. */ +@Deprecated public class LongGrass extends MaterialData { public LongGrass() { super(Material.LEGACY_LONG_GRASS); diff --git a/api/src/main/java/org/bukkit/material/MaterialData.java b/api/src/main/java/org/bukkit/material/MaterialData.java index 9f6a0ca66..ccaddb879 100644 --- a/api/src/main/java/org/bukkit/material/MaterialData.java +++ b/api/src/main/java/org/bukkit/material/MaterialData.java @@ -1,14 +1,13 @@ package org.bukkit.material; -import org.bukkit.inventory.ItemStack; import org.bukkit.Material; -import org.bukkit.block.data.BlockData; +import org.bukkit.inventory.ItemStack; /** * Handles specific metadata for certain items or blocks * * @deprecated all usage of MaterialData is deprecated and subject to removal. - * Use {@link BlockData}. + * Use {@link org.bukkit.block.data.BlockData}. */ @Deprecated public class MaterialData implements Cloneable { diff --git a/api/src/main/java/org/bukkit/material/MonsterEggs.java b/api/src/main/java/org/bukkit/material/MonsterEggs.java index 3e483fdf1..2fac218f1 100644 --- a/api/src/main/java/org/bukkit/material/MonsterEggs.java +++ b/api/src/main/java/org/bukkit/material/MonsterEggs.java @@ -2,12 +2,15 @@ package org.bukkit.material; import java.util.ArrayList; import java.util.List; - import org.bukkit.Material; /** * Represents the different types of monster eggs + * + * @deprecated all usage of MaterialData is deprecated and subject to removal. + * Use {@link org.bukkit.block.data.BlockData}. */ +@Deprecated public class MonsterEggs extends TexturedMaterial { private static final List textures = new ArrayList(); diff --git a/api/src/main/java/org/bukkit/material/Mushroom.java b/api/src/main/java/org/bukkit/material/Mushroom.java index cbc7d9bf4..543b76c8a 100644 --- a/api/src/main/java/org/bukkit/material/Mushroom.java +++ b/api/src/main/java/org/bukkit/material/Mushroom.java @@ -2,7 +2,6 @@ package org.bukkit.material; import java.util.EnumSet; import java.util.Set; - import org.apache.commons.lang.Validate; import org.bukkit.Material; import org.bukkit.block.BlockFace; @@ -14,7 +13,11 @@ import org.bukkit.material.types.MushroomBlockTexture; * * @see Material#LEGACY_HUGE_MUSHROOM_1 * @see Material#LEGACY_HUGE_MUSHROOM_2 + * + * @deprecated all usage of MaterialData is deprecated and subject to removal. + * Use {@link org.bukkit.block.data.BlockData}. */ +@Deprecated public class Mushroom extends MaterialData { private static final byte NORTH_LIMIT = 4; private static final byte SOUTH_LIMIT = 6; diff --git a/api/src/main/java/org/bukkit/material/NetherWarts.java b/api/src/main/java/org/bukkit/material/NetherWarts.java index 09d5a9f89..1fed8b937 100644 --- a/api/src/main/java/org/bukkit/material/NetherWarts.java +++ b/api/src/main/java/org/bukkit/material/NetherWarts.java @@ -5,7 +5,11 @@ import org.bukkit.NetherWartsState; /** * Represents nether wart + * + * @deprecated all usage of MaterialData is deprecated and subject to removal. + * Use {@link org.bukkit.block.data.BlockData}. */ +@Deprecated public class NetherWarts extends MaterialData { public NetherWarts() { super(Material.LEGACY_NETHER_WARTS); diff --git a/api/src/main/java/org/bukkit/material/Observer.java b/api/src/main/java/org/bukkit/material/Observer.java index afedb9304..843790b33 100644 --- a/api/src/main/java/org/bukkit/material/Observer.java +++ b/api/src/main/java/org/bukkit/material/Observer.java @@ -5,7 +5,11 @@ import org.bukkit.block.BlockFace; /** * Represents an observer. + * + * @deprecated all usage of MaterialData is deprecated and subject to removal. + * Use {@link org.bukkit.block.data.BlockData}. */ +@Deprecated public class Observer extends MaterialData implements Directional, Redstone { public Observer() { diff --git a/api/src/main/java/org/bukkit/material/PistonBaseMaterial.java b/api/src/main/java/org/bukkit/material/PistonBaseMaterial.java index 805f9e57c..8165e9433 100644 --- a/api/src/main/java/org/bukkit/material/PistonBaseMaterial.java +++ b/api/src/main/java/org/bukkit/material/PistonBaseMaterial.java @@ -5,18 +5,22 @@ import org.bukkit.block.BlockFace; /** * Material data for the piston base block + * + * @deprecated all usage of MaterialData is deprecated and subject to removal. + * Use {@link org.bukkit.block.data.BlockData}. */ +@Deprecated public class PistonBaseMaterial extends MaterialData implements Directional, Redstone { - + public PistonBaseMaterial(final Material type) { super(type); } /** * Constructs a PistonBaseMaterial. - * + * * @param type the material type to use - * @param data the raw data value + * @param data the raw data value * @deprecated Magic value */ @Deprecated diff --git a/api/src/main/java/org/bukkit/material/PistonExtensionMaterial.java b/api/src/main/java/org/bukkit/material/PistonExtensionMaterial.java index f293b9ca3..e7cfc7158 100644 --- a/api/src/main/java/org/bukkit/material/PistonExtensionMaterial.java +++ b/api/src/main/java/org/bukkit/material/PistonExtensionMaterial.java @@ -5,7 +5,11 @@ import org.bukkit.block.BlockFace; /** * Material data for the piston extension block + * + * @deprecated all usage of MaterialData is deprecated and subject to removal. + * Use {@link org.bukkit.block.data.BlockData}. */ +@Deprecated public class PistonExtensionMaterial extends MaterialData implements Attachable { public PistonExtensionMaterial(final Material type) { @@ -22,6 +26,7 @@ public class PistonExtensionMaterial extends MaterialData implements Attachable super(type, data); } + @Override public void setFacingDirection(BlockFace face) { byte data = (byte) (getData() & 0x8); @@ -45,6 +50,7 @@ public class PistonExtensionMaterial extends MaterialData implements Attachable setData(data); } + @Override public BlockFace getFacing() { byte dir = (byte) (getData() & 7); @@ -84,6 +90,7 @@ public class PistonExtensionMaterial extends MaterialData implements Attachable setData((byte) (sticky ? (getData() | 0x8) : (getData() & ~0x8))); } + @Override public BlockFace getAttachedFace() { return getFacing().getOppositeFace(); } diff --git a/api/src/main/java/org/bukkit/material/PoweredRail.java b/api/src/main/java/org/bukkit/material/PoweredRail.java index bdccff944..feebc5c73 100644 --- a/api/src/main/java/org/bukkit/material/PoweredRail.java +++ b/api/src/main/java/org/bukkit/material/PoweredRail.java @@ -4,7 +4,11 @@ import org.bukkit.Material; /** * Represents a powered rail + * + * @deprecated all usage of MaterialData is deprecated and subject to removal. + * Use {@link org.bukkit.block.data.BlockData}. */ +@Deprecated public class PoweredRail extends ExtendedRails implements Redstone { public PoweredRail() { super(Material.LEGACY_POWERED_RAIL); @@ -24,6 +28,7 @@ public class PoweredRail extends ExtendedRails implements Redstone { super(type, data); } + @Override public boolean isPowered() { return (getData() & 0x8) == 0x8; } diff --git a/api/src/main/java/org/bukkit/material/PressurePlate.java b/api/src/main/java/org/bukkit/material/PressurePlate.java index 95ce6648f..ffababbc1 100644 --- a/api/src/main/java/org/bukkit/material/PressurePlate.java +++ b/api/src/main/java/org/bukkit/material/PressurePlate.java @@ -4,7 +4,11 @@ import org.bukkit.Material; /** * Represents a pressure plate + * + * @deprecated all usage of MaterialData is deprecated and subject to removal. + * Use {@link org.bukkit.block.data.BlockData}. */ +@Deprecated public class PressurePlate extends MaterialData implements PressureSensor { public PressurePlate() { super(Material.LEGACY_WOOD_PLATE); @@ -24,6 +28,7 @@ public class PressurePlate extends MaterialData implements PressureSensor { super(type, data); } + @Override public boolean isPressed() { return getData() == 0x1; } diff --git a/api/src/main/java/org/bukkit/material/Pumpkin.java b/api/src/main/java/org/bukkit/material/Pumpkin.java index 1fad246bf..7c1b5eea0 100644 --- a/api/src/main/java/org/bukkit/material/Pumpkin.java +++ b/api/src/main/java/org/bukkit/material/Pumpkin.java @@ -5,7 +5,11 @@ import org.bukkit.block.BlockFace; /** * Represents a pumpkin. + * + * @deprecated all usage of MaterialData is deprecated and subject to removal. + * Use {@link org.bukkit.block.data.BlockData}. */ +@Deprecated public class Pumpkin extends MaterialData implements Directional { public Pumpkin() { @@ -40,6 +44,7 @@ public class Pumpkin extends MaterialData implements Directional { return getItemType() == Material.LEGACY_JACK_O_LANTERN; } + @Override public void setFacingDirection(BlockFace face) { byte data; @@ -64,6 +69,7 @@ public class Pumpkin extends MaterialData implements Directional { setData(data); } + @Override public BlockFace getFacing() { byte data = getData(); diff --git a/api/src/main/java/org/bukkit/material/Rails.java b/api/src/main/java/org/bukkit/material/Rails.java index 2c2420efe..0b041ee66 100644 --- a/api/src/main/java/org/bukkit/material/Rails.java +++ b/api/src/main/java/org/bukkit/material/Rails.java @@ -5,7 +5,11 @@ import org.bukkit.block.BlockFace; /** * Represents minecart rails. + * + * @deprecated all usage of MaterialData is deprecated and subject to removal. + * Use {@link org.bukkit.block.data.BlockData}. */ +@Deprecated public class Rails extends MaterialData { public Rails() { diff --git a/api/src/main/java/org/bukkit/material/RedstoneTorch.java b/api/src/main/java/org/bukkit/material/RedstoneTorch.java index b42ec940d..409569143 100644 --- a/api/src/main/java/org/bukkit/material/RedstoneTorch.java +++ b/api/src/main/java/org/bukkit/material/RedstoneTorch.java @@ -4,7 +4,11 @@ import org.bukkit.Material; /** * Represents a redstone torch + * + * @deprecated all usage of MaterialData is deprecated and subject to removal. + * Use {@link org.bukkit.block.data.BlockData}. */ +@Deprecated public class RedstoneTorch extends Torch implements Redstone { public RedstoneTorch() { super(Material.LEGACY_REDSTONE_TORCH_ON); @@ -30,6 +34,7 @@ public class RedstoneTorch extends Torch implements Redstone { * * @return true if powered, otherwise false */ + @Override public boolean isPowered() { return getItemType() == Material.LEGACY_REDSTONE_TORCH_ON; } diff --git a/api/src/main/java/org/bukkit/material/RedstoneWire.java b/api/src/main/java/org/bukkit/material/RedstoneWire.java index 709c395a5..8877ef48e 100644 --- a/api/src/main/java/org/bukkit/material/RedstoneWire.java +++ b/api/src/main/java/org/bukkit/material/RedstoneWire.java @@ -4,7 +4,11 @@ import org.bukkit.Material; /** * Represents redstone wire + * + * @deprecated all usage of MaterialData is deprecated and subject to removal. + * Use {@link org.bukkit.block.data.BlockData}. */ +@Deprecated public class RedstoneWire extends MaterialData implements Redstone { public RedstoneWire() { super(Material.LEGACY_REDSTONE_WIRE); @@ -30,6 +34,7 @@ public class RedstoneWire extends MaterialData implements Redstone { * * @return true if powered, otherwise false */ + @Override public boolean isPowered() { return getData() > 0; } diff --git a/api/src/main/java/org/bukkit/material/Sandstone.java b/api/src/main/java/org/bukkit/material/Sandstone.java index c2f882c22..8d8673edc 100644 --- a/api/src/main/java/org/bukkit/material/Sandstone.java +++ b/api/src/main/java/org/bukkit/material/Sandstone.java @@ -5,7 +5,11 @@ import org.bukkit.SandstoneType; /** * Represents the different types of sandstone. + * + * @deprecated all usage of MaterialData is deprecated and subject to removal. + * Use {@link org.bukkit.block.data.BlockData}. */ +@Deprecated public class Sandstone extends MaterialData { public Sandstone() { super(Material.LEGACY_SANDSTONE); diff --git a/api/src/main/java/org/bukkit/material/Sapling.java b/api/src/main/java/org/bukkit/material/Sapling.java index db2bae9ff..c615a0022 100644 --- a/api/src/main/java/org/bukkit/material/Sapling.java +++ b/api/src/main/java/org/bukkit/material/Sapling.java @@ -7,7 +7,11 @@ import org.bukkit.TreeSpecies; * Represents the different types of Tree block that face a direction. * * @see Material#LEGACY_SAPLING + * + * @deprecated all usage of MaterialData is deprecated and subject to removal. + * Use {@link org.bukkit.block.data.BlockData}. */ +@Deprecated public class Sapling extends Wood { /** diff --git a/api/src/main/java/org/bukkit/material/Sign.java b/api/src/main/java/org/bukkit/material/Sign.java index d33b8ed21..3b32679b4 100644 --- a/api/src/main/java/org/bukkit/material/Sign.java +++ b/api/src/main/java/org/bukkit/material/Sign.java @@ -1,11 +1,15 @@ package org.bukkit.material; -import org.bukkit.block.BlockFace; import org.bukkit.Material; +import org.bukkit.block.BlockFace; /** * MaterialData for signs + * + * @deprecated all usage of MaterialData is deprecated and subject to removal. + * Use {@link org.bukkit.block.data.BlockData}. */ +@Deprecated public class Sign extends MaterialData implements Attachable { public Sign() { super(Material.LEGACY_SIGN_POST); @@ -40,6 +44,7 @@ public class Sign extends MaterialData implements Attachable { * * @return BlockFace attached to */ + @Override public BlockFace getAttachedFace() { if (isWallSign()) { byte data = getData(); @@ -69,6 +74,7 @@ public class Sign extends MaterialData implements Attachable { * * @return BlockFace indicating where this sign is facing */ + @Override public BlockFace getFacing() { byte data = getData(); @@ -129,6 +135,7 @@ public class Sign extends MaterialData implements Attachable { } } + @Override public void setFacingDirection(BlockFace face) { byte data; diff --git a/api/src/main/java/org/bukkit/material/SimpleAttachableMaterialData.java b/api/src/main/java/org/bukkit/material/SimpleAttachableMaterialData.java index fb92f6587..6267d81ba 100644 --- a/api/src/main/java/org/bukkit/material/SimpleAttachableMaterialData.java +++ b/api/src/main/java/org/bukkit/material/SimpleAttachableMaterialData.java @@ -5,7 +5,11 @@ import org.bukkit.block.BlockFace; /** * Simple utility class for attachable MaterialData subclasses + * + * @deprecated all usage of MaterialData is deprecated and subject to removal. + * Use {@link org.bukkit.block.data.BlockData}. */ +@Deprecated public abstract class SimpleAttachableMaterialData extends MaterialData implements Attachable { public SimpleAttachableMaterialData(Material type, BlockFace direction) { @@ -27,6 +31,7 @@ public abstract class SimpleAttachableMaterialData extends MaterialData implemen super(type, data); } + @Override public BlockFace getFacing() { BlockFace attachedFace = getAttachedFace(); return attachedFace == null ? null : attachedFace.getOppositeFace(); diff --git a/api/src/main/java/org/bukkit/material/Skull.java b/api/src/main/java/org/bukkit/material/Skull.java index a0abe7483..a73ad6246 100644 --- a/api/src/main/java/org/bukkit/material/Skull.java +++ b/api/src/main/java/org/bukkit/material/Skull.java @@ -5,7 +5,11 @@ import org.bukkit.block.BlockFace; /** * Represents a skull. + * + * @deprecated all usage of MaterialData is deprecated and subject to removal. + * Use {@link org.bukkit.block.data.BlockData}. */ +@Deprecated public class Skull extends MaterialData implements Directional { public Skull() { super(Material.LEGACY_SKULL); @@ -35,6 +39,7 @@ public class Skull extends MaterialData implements Directional { super(type, data); } + @Override public void setFacingDirection(BlockFace face) { int data; @@ -63,6 +68,7 @@ public class Skull extends MaterialData implements Directional { setData((byte) data); } + @Override public BlockFace getFacing() { int data = getData(); diff --git a/api/src/main/java/org/bukkit/material/SmoothBrick.java b/api/src/main/java/org/bukkit/material/SmoothBrick.java index 3e4a8525a..e4812b7ce 100644 --- a/api/src/main/java/org/bukkit/material/SmoothBrick.java +++ b/api/src/main/java/org/bukkit/material/SmoothBrick.java @@ -2,12 +2,15 @@ package org.bukkit.material; import java.util.ArrayList; import java.util.List; - import org.bukkit.Material; /** * Represents the different types of smooth bricks. + * + * @deprecated all usage of MaterialData is deprecated and subject to removal. + * Use {@link org.bukkit.block.data.BlockData}. */ +@Deprecated public class SmoothBrick extends TexturedMaterial { private static final List textures = new ArrayList(); diff --git a/api/src/main/java/org/bukkit/material/Stairs.java b/api/src/main/java/org/bukkit/material/Stairs.java index 29ef66c4f..e5db60bd0 100644 --- a/api/src/main/java/org/bukkit/material/Stairs.java +++ b/api/src/main/java/org/bukkit/material/Stairs.java @@ -5,7 +5,11 @@ import org.bukkit.block.BlockFace; /** * Represents stairs. + * + * @deprecated all usage of MaterialData is deprecated and subject to removal. + * Use {@link org.bukkit.block.data.BlockData}. */ +@Deprecated public class Stairs extends MaterialData implements Directional { public Stairs(final Material type) { @@ -54,6 +58,7 @@ public class Stairs extends MaterialData implements Directional { /** * Set the direction the stair part of the block is facing */ + @Override public void setFacingDirection(BlockFace face) { byte data; @@ -82,6 +87,7 @@ public class Stairs extends MaterialData implements Directional { /** * @return the direction the stair part of the block is facing */ + @Override public BlockFace getFacing() { return getDescendingDirection(); } diff --git a/api/src/main/java/org/bukkit/material/Step.java b/api/src/main/java/org/bukkit/material/Step.java index 8c255ba06..8b92ec4e8 100644 --- a/api/src/main/java/org/bukkit/material/Step.java +++ b/api/src/main/java/org/bukkit/material/Step.java @@ -2,12 +2,15 @@ package org.bukkit.material; import java.util.ArrayList; import java.util.List; - import org.bukkit.Material; /** * Represents the different types of steps. + * + * @deprecated all usage of MaterialData is deprecated and subject to removal. + * Use {@link org.bukkit.block.data.BlockData}. */ +@Deprecated public class Step extends TexturedMaterial { private static final List textures = new ArrayList(); static { diff --git a/api/src/main/java/org/bukkit/material/TexturedMaterial.java b/api/src/main/java/org/bukkit/material/TexturedMaterial.java index ea3433ac8..6e0a83479 100644 --- a/api/src/main/java/org/bukkit/material/TexturedMaterial.java +++ b/api/src/main/java/org/bukkit/material/TexturedMaterial.java @@ -1,12 +1,15 @@ package org.bukkit.material; import java.util.List; - import org.bukkit.Material; /** * Represents textured materials like steps and smooth bricks + * + * @deprecated all usage of MaterialData is deprecated and subject to removal. + * Use {@link org.bukkit.block.data.BlockData}. */ +@Deprecated public abstract class TexturedMaterial extends MaterialData { public TexturedMaterial(Material m) { diff --git a/api/src/main/java/org/bukkit/material/Torch.java b/api/src/main/java/org/bukkit/material/Torch.java index 0c34004d1..a4f0c62dc 100644 --- a/api/src/main/java/org/bukkit/material/Torch.java +++ b/api/src/main/java/org/bukkit/material/Torch.java @@ -1,11 +1,15 @@ package org.bukkit.material; -import org.bukkit.block.BlockFace; import org.bukkit.Material; +import org.bukkit.block.BlockFace; /** * MaterialData for torches + * + * @deprecated all usage of MaterialData is deprecated and subject to removal. + * Use {@link org.bukkit.block.data.BlockData}. */ +@Deprecated public class Torch extends SimpleAttachableMaterialData { public Torch() { super(Material.LEGACY_TORCH); @@ -30,6 +34,7 @@ public class Torch extends SimpleAttachableMaterialData { * * @return BlockFace attached to */ + @Override public BlockFace getAttachedFace() { byte data = getData(); @@ -52,6 +57,7 @@ public class Torch extends SimpleAttachableMaterialData { } } + @Override public void setFacingDirection(BlockFace face) { byte data; diff --git a/api/src/main/java/org/bukkit/material/TrapDoor.java b/api/src/main/java/org/bukkit/material/TrapDoor.java index 2bbfe2b31..effedfc71 100644 --- a/api/src/main/java/org/bukkit/material/TrapDoor.java +++ b/api/src/main/java/org/bukkit/material/TrapDoor.java @@ -5,7 +5,11 @@ import org.bukkit.block.BlockFace; /** * Represents a trap door + * + * @deprecated all usage of MaterialData is deprecated and subject to removal. + * Use {@link org.bukkit.block.data.BlockData}. */ +@Deprecated public class TrapDoor extends SimpleAttachableMaterialData implements Openable { public TrapDoor() { super(Material.LEGACY_TRAP_DOOR); @@ -25,10 +29,12 @@ public class TrapDoor extends SimpleAttachableMaterialData implements Openable { super(type, data); } + @Override public boolean isOpen() { return ((getData() & 0x4) == 0x4); } + @Override public void setOpen(boolean isOpen) { byte data = getData(); @@ -63,6 +69,7 @@ public class TrapDoor extends SimpleAttachableMaterialData implements Openable { setData((byte) dat); } + @Override public BlockFace getAttachedFace() { byte data = (byte) (getData() & 0x3); @@ -84,6 +91,7 @@ public class TrapDoor extends SimpleAttachableMaterialData implements Openable { } + @Override public void setFacingDirection(BlockFace face) { byte data = (byte) (getData() & 0xC); diff --git a/api/src/main/java/org/bukkit/material/Tree.java b/api/src/main/java/org/bukkit/material/Tree.java index 2c4b0c40d..e759f5033 100644 --- a/api/src/main/java/org/bukkit/material/Tree.java +++ b/api/src/main/java/org/bukkit/material/Tree.java @@ -9,7 +9,11 @@ import org.bukkit.block.BlockFace; * * @see Material#LEGACY_LOG * @see Material#LEGACY_LOG_2 + * + * @deprecated all usage of MaterialData is deprecated and subject to removal. + * Use {@link org.bukkit.block.data.BlockData}. */ +@Deprecated public class Tree extends Wood { protected static final Material DEFAULT_TYPE = Material.LEGACY_LOG; protected static final BlockFace DEFAULT_DIRECTION = BlockFace.UP; diff --git a/api/src/main/java/org/bukkit/material/Tripwire.java b/api/src/main/java/org/bukkit/material/Tripwire.java index 89b85a614..e5ffa4db8 100644 --- a/api/src/main/java/org/bukkit/material/Tripwire.java +++ b/api/src/main/java/org/bukkit/material/Tripwire.java @@ -4,7 +4,11 @@ import org.bukkit.Material; /** * Represents the tripwire + * + * @deprecated all usage of MaterialData is deprecated and subject to removal. + * Use {@link org.bukkit.block.data.BlockData}. */ +@Deprecated public class Tripwire extends MaterialData { public Tripwire() { diff --git a/api/src/main/java/org/bukkit/material/TripwireHook.java b/api/src/main/java/org/bukkit/material/TripwireHook.java index 97f97eab8..80aa1c7bc 100644 --- a/api/src/main/java/org/bukkit/material/TripwireHook.java +++ b/api/src/main/java/org/bukkit/material/TripwireHook.java @@ -5,7 +5,11 @@ import org.bukkit.block.BlockFace; /** * Represents the tripwire hook + * + * @deprecated all usage of MaterialData is deprecated and subject to removal. + * Use {@link org.bukkit.block.data.BlockData}. */ +@Deprecated public class TripwireHook extends SimpleAttachableMaterialData implements Redstone { public TripwireHook() { @@ -71,6 +75,7 @@ public class TripwireHook extends SimpleAttachableMaterialData implements Redsto setData((byte) dat); } + @Override public void setFacingDirection(BlockFace face) { int dat = getData() & 0xC; switch (face) { @@ -90,6 +95,7 @@ public class TripwireHook extends SimpleAttachableMaterialData implements Redsto setData((byte) dat); } + @Override public BlockFace getAttachedFace() { switch (getData() & 0x3) { case 0: @@ -104,6 +110,7 @@ public class TripwireHook extends SimpleAttachableMaterialData implements Redsto return null; } + @Override public boolean isPowered() { return isActivated(); } diff --git a/api/src/main/java/org/bukkit/material/Vine.java b/api/src/main/java/org/bukkit/material/Vine.java index abfc211c9..07a4f3b15 100644 --- a/api/src/main/java/org/bukkit/material/Vine.java +++ b/api/src/main/java/org/bukkit/material/Vine.java @@ -2,13 +2,16 @@ package org.bukkit.material; import java.util.Arrays; import java.util.EnumSet; - import org.bukkit.Material; import org.bukkit.block.BlockFace; /** * Represents a vine + * + * @deprecated all usage of MaterialData is deprecated and subject to removal. + * Use {@link org.bukkit.block.data.BlockData}. */ +@Deprecated public class Vine extends MaterialData { private static final int VINE_NORTH = 0x4; private static final int VINE_EAST = 0x8; diff --git a/api/src/main/java/org/bukkit/material/Wood.java b/api/src/main/java/org/bukkit/material/Wood.java index c77664ee8..5d51c9286 100644 --- a/api/src/main/java/org/bukkit/material/Wood.java +++ b/api/src/main/java/org/bukkit/material/Wood.java @@ -9,7 +9,11 @@ import org.bukkit.TreeSpecies; * @see Material#LEGACY_WOOD * @see Material#LEGACY_SAPLING * @see Material#LEGACY_WOOD_DOUBLE_STEP + * + * @deprecated all usage of MaterialData is deprecated and subject to removal. + * Use {@link org.bukkit.block.data.BlockData}. */ +@Deprecated public class Wood extends MaterialData { protected static final Material DEFAULT_TYPE = Material.LEGACY_WOOD; protected static final TreeSpecies DEFAULT_SPECIES = TreeSpecies.GENERIC; @@ -23,7 +27,7 @@ public class Wood extends MaterialData { /** * Constructs a wood block of the given tree species. - * + * * @param species the species of the wood block */ public Wood(TreeSpecies species) { diff --git a/api/src/main/java/org/bukkit/material/WoodenStep.java b/api/src/main/java/org/bukkit/material/WoodenStep.java index 34886cfcb..b99a9a304 100644 --- a/api/src/main/java/org/bukkit/material/WoodenStep.java +++ b/api/src/main/java/org/bukkit/material/WoodenStep.java @@ -7,7 +7,11 @@ import org.bukkit.TreeSpecies; * Represents the different types of wooden steps. * * @see Material#LEGACY_WOOD_STEP + * + * @deprecated all usage of MaterialData is deprecated and subject to removal. + * Use {@link org.bukkit.block.data.BlockData}. */ +@Deprecated public class WoodenStep extends Wood { protected static final Material DEFAULT_TYPE = Material.LEGACY_WOOD_STEP; protected static final boolean DEFAULT_INVERTED = false; diff --git a/api/src/main/java/org/bukkit/material/Wool.java b/api/src/main/java/org/bukkit/material/Wool.java index 87f35f588..3b17409a9 100644 --- a/api/src/main/java/org/bukkit/material/Wool.java +++ b/api/src/main/java/org/bukkit/material/Wool.java @@ -5,7 +5,10 @@ import org.bukkit.Material; /** * Represents a Wool/Cloth block + * @deprecated all usage of MaterialData is deprecated and subject to removal. + * Use {@link org.bukkit.block.data.BlockData}. */ +@Deprecated public class Wool extends MaterialData implements Colorable { public Wool() { super(Material.LEGACY_WOOL); @@ -35,6 +38,7 @@ public class Wool extends MaterialData implements Colorable { * * @return DyeColor of this dye */ + @Override public DyeColor getColor() { return DyeColor.getByWoolData(getData()); } @@ -44,6 +48,7 @@ public class Wool extends MaterialData implements Colorable { * * @param color New color of this dye */ + @Override public void setColor(DyeColor color) { setData(color.getWoolData()); } diff --git a/api/src/main/java/org/bukkit/material/types/MushroomBlockTexture.java b/api/src/main/java/org/bukkit/material/types/MushroomBlockTexture.java index b36a10bfb..0ea9c6b24 100644 --- a/api/src/main/java/org/bukkit/material/types/MushroomBlockTexture.java +++ b/api/src/main/java/org/bukkit/material/types/MushroomBlockTexture.java @@ -1,11 +1,8 @@ package org.bukkit.material.types; -import java.util.Map; - -import org.bukkit.block.BlockFace; - import com.google.common.collect.Maps; -import org.jetbrains.annotations.NotNull; +import java.util.Map; +import org.bukkit.block.BlockFace; import org.jetbrains.annotations.Nullable; /** @@ -66,8 +63,8 @@ public enum MushroomBlockTexture { * Stem texture on all faces. */ ALL_STEM(15, null); - private final static Map BY_DATA = Maps.newHashMap(); - private final static Map BY_BLOCKFACE = Maps.newHashMap(); + private static final Map BY_DATA = Maps.newHashMap(); + private static final Map BY_BLOCKFACE = Maps.newHashMap(); private final Byte data; private final BlockFace capFace; diff --git a/api/src/main/java/org/bukkit/metadata/LazyMetadataValue.java b/api/src/main/java/org/bukkit/metadata/LazyMetadataValue.java index 820b22ca9..86e0e3767 100644 --- a/api/src/main/java/org/bukkit/metadata/LazyMetadataValue.java +++ b/api/src/main/java/org/bukkit/metadata/LazyMetadataValue.java @@ -2,7 +2,6 @@ package org.bukkit.metadata; import java.lang.ref.SoftReference; import java.util.concurrent.Callable; - import org.apache.commons.lang.Validate; import org.bukkit.plugin.Plugin; import org.jetbrains.annotations.NotNull; @@ -58,13 +57,14 @@ public class LazyMetadataValue extends MetadataValueAdapter { /** * Protected special constructor used by FixedMetadataValue to bypass * standard setup. - * + * * @param owningPlugin the owning plugin */ protected LazyMetadataValue(@NotNull Plugin owningPlugin) { super(owningPlugin); } + @Override @Nullable public Object value() { eval(); @@ -95,6 +95,7 @@ public class LazyMetadataValue extends MetadataValueAdapter { } } + @Override public synchronized void invalidate() { if (cacheStrategy != CacheStrategy.CACHE_ETERNALLY) { internalValue.clear(); diff --git a/api/src/main/java/org/bukkit/metadata/MetadataStore.java b/api/src/main/java/org/bukkit/metadata/MetadataStore.java index 1ebba41f4..29f86fa93 100644 --- a/api/src/main/java/org/bukkit/metadata/MetadataStore.java +++ b/api/src/main/java/org/bukkit/metadata/MetadataStore.java @@ -1,10 +1,9 @@ package org.bukkit.metadata; +import java.util.List; import org.bukkit.plugin.Plugin; import org.jetbrains.annotations.NotNull; -import java.util.List; - public interface MetadataStore { /** * Adds a metadata value to an object. diff --git a/api/src/main/java/org/bukkit/metadata/MetadataStoreBase.java b/api/src/main/java/org/bukkit/metadata/MetadataStoreBase.java index b634b124e..0e8cd85c7 100644 --- a/api/src/main/java/org/bukkit/metadata/MetadataStoreBase.java +++ b/api/src/main/java/org/bukkit/metadata/MetadataStoreBase.java @@ -1,14 +1,19 @@ package org.bukkit.metadata; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.Iterator; // Paper +import java.util.List; +import java.util.Map; +import java.util.WeakHashMap; import org.apache.commons.lang.Validate; import org.bukkit.plugin.Plugin; import org.jetbrains.annotations.NotNull; -import java.util.*; -import java.util.concurrent.ConcurrentHashMap; - public abstract class MetadataStoreBase { - private Map> metadataMap = new ConcurrentHashMap>(); // Paper + private Map> metadataMap = new java.util.concurrent.ConcurrentHashMap>(); // Paper /** * Adds a metadata value to an object. Each metadata value is owned by a diff --git a/api/src/main/java/org/bukkit/metadata/MetadataValueAdapter.java b/api/src/main/java/org/bukkit/metadata/MetadataValueAdapter.java index f88299103..b90d09f57 100644 --- a/api/src/main/java/org/bukkit/metadata/MetadataValueAdapter.java +++ b/api/src/main/java/org/bukkit/metadata/MetadataValueAdapter.java @@ -1,7 +1,6 @@ package org.bukkit.metadata; import java.lang.ref.WeakReference; - import org.apache.commons.lang.Validate; import org.bukkit.plugin.Plugin; import org.bukkit.util.NumberConversions; @@ -23,35 +22,43 @@ public abstract class MetadataValueAdapter implements MetadataValue { this.owningPlugin = new WeakReference(owningPlugin); } + @Override @Nullable public Plugin getOwningPlugin() { return owningPlugin.get(); } + @Override public int asInt() { return NumberConversions.toInt(value()); } + @Override public float asFloat() { return NumberConversions.toFloat(value()); } + @Override public double asDouble() { return NumberConversions.toDouble(value()); } + @Override public long asLong() { return NumberConversions.toLong(value()); } + @Override public short asShort() { return NumberConversions.toShort(value()); } + @Override public byte asByte() { return NumberConversions.toByte(value()); } + @Override public boolean asBoolean() { Object value = value(); if (value instanceof Boolean) { @@ -69,6 +76,7 @@ public abstract class MetadataValueAdapter implements MetadataValue { return value != null; } + @Override @NotNull public String asString() { Object value = value(); diff --git a/api/src/main/java/org/bukkit/metadata/Metadatable.java b/api/src/main/java/org/bukkit/metadata/Metadatable.java index 891e51608..b35f41a15 100644 --- a/api/src/main/java/org/bukkit/metadata/Metadatable.java +++ b/api/src/main/java/org/bukkit/metadata/Metadatable.java @@ -1,10 +1,9 @@ package org.bukkit.metadata; +import java.util.List; import org.bukkit.plugin.Plugin; import org.jetbrains.annotations.NotNull; -import java.util.List; - /** * This interface is implemented by all objects that can provide metadata * about themselves. diff --git a/api/src/main/java/org/bukkit/permissions/PermissibleBase.java b/api/src/main/java/org/bukkit/permissions/PermissibleBase.java index 72fff64e0..c94e4cdb5 100644 --- a/api/src/main/java/org/bukkit/permissions/PermissibleBase.java +++ b/api/src/main/java/org/bukkit/permissions/PermissibleBase.java @@ -31,6 +31,7 @@ public class PermissibleBase implements Permissible { recalculatePermissions(); } + @Override public boolean isOp() { if (opable == null) { return false; @@ -39,6 +40,7 @@ public class PermissibleBase implements Permissible { } } + @Override public void setOp(boolean value) { if (opable == null) { throw new UnsupportedOperationException("Cannot change op value as no ServerOperator is set"); @@ -47,6 +49,7 @@ public class PermissibleBase implements Permissible { } } + @Override public boolean isPermissionSet(@NotNull String name) { if (name == null) { throw new IllegalArgumentException("Permission name cannot be null"); @@ -55,6 +58,7 @@ public class PermissibleBase implements Permissible { return permissions.containsKey(name.toLowerCase(java.util.Locale.ENGLISH)); } + @Override public boolean isPermissionSet(@NotNull Permission perm) { if (perm == null) { throw new IllegalArgumentException("Permission cannot be null"); @@ -63,6 +67,7 @@ public class PermissibleBase implements Permissible { return isPermissionSet(perm.getName()); } + @Override public boolean hasPermission(@NotNull String inName) { if (inName == null) { throw new IllegalArgumentException("Permission name cannot be null"); @@ -86,6 +91,7 @@ public class PermissibleBase implements Permissible { } } + @Override public boolean hasPermission(@NotNull Permission perm) { if (perm == null) { throw new IllegalArgumentException("Permission cannot be null"); @@ -102,6 +108,7 @@ public class PermissibleBase implements Permissible { return perm.getDefault().getValue(isOp()); } + @Override @NotNull public synchronized PermissionAttachment addAttachment(@NotNull Plugin plugin, @NotNull String name, boolean value) { // Paper - synchronized if (name == null) { @@ -120,6 +127,7 @@ public class PermissibleBase implements Permissible { return result; } + @Override @NotNull public synchronized PermissionAttachment addAttachment(@NotNull Plugin plugin) { // Paper - synchronized if (plugin == null) { @@ -136,6 +144,7 @@ public class PermissibleBase implements Permissible { return result; } + @Override public synchronized void removeAttachment(@NotNull PermissionAttachment attachment) { // Paper - synchronized if (attachment == null) { throw new IllegalArgumentException("Attachment cannot be null"); @@ -155,6 +164,7 @@ public class PermissibleBase implements Permissible { } } + @Override public synchronized void recalculatePermissions() { // Paper - synchronized clearPermissions(); Set defaults = Bukkit.getServer().getPluginManager().getDefaultPermissions(isOp()); @@ -202,6 +212,7 @@ public class PermissibleBase implements Permissible { } } + @Override @Nullable public synchronized PermissionAttachment addAttachment(@NotNull Plugin plugin, @NotNull String name, boolean value, int ticks) { // Paper if (name == null) { @@ -221,6 +232,7 @@ public class PermissibleBase implements Permissible { return result; } + @Override @Nullable public synchronized PermissionAttachment addAttachment(@NotNull Plugin plugin, int ticks) { // Paper - synchronized if (plugin == null) { @@ -240,6 +252,7 @@ public class PermissibleBase implements Permissible { } } + @Override @NotNull public synchronized Set getEffectivePermissions() { // Paper - synchronized return new HashSet(permissions.values()); @@ -252,6 +265,7 @@ public class PermissibleBase implements Permissible { this.attachment = attachment; } + @Override public void run() { attachment.remove(); } diff --git a/api/src/main/java/org/bukkit/permissions/Permission.java b/api/src/main/java/org/bukkit/permissions/Permission.java index 09eb28cce..91d45b965 100644 --- a/api/src/main/java/org/bukkit/permissions/Permission.java +++ b/api/src/main/java/org/bukkit/permissions/Permission.java @@ -6,7 +6,6 @@ import java.util.List; import java.util.Map; import java.util.Set; import java.util.logging.Level; - import org.apache.commons.lang.Validate; import org.bukkit.Bukkit; import org.bukkit.plugin.PluginManager; diff --git a/api/src/main/java/org/bukkit/permissions/PermissionDefault.java b/api/src/main/java/org/bukkit/permissions/PermissionDefault.java index c36f52f95..449df7c79 100644 --- a/api/src/main/java/org/bukkit/permissions/PermissionDefault.java +++ b/api/src/main/java/org/bukkit/permissions/PermissionDefault.java @@ -1,10 +1,9 @@ package org.bukkit.permissions; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - import java.util.HashMap; import java.util.Map; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Represents the possible default values for permissions @@ -16,7 +15,7 @@ public enum PermissionDefault { NOT_OP("!op", "notop", "!operator", "notoperator", "!admin", "notadmin"); private final String[] names; - private final static Map lookup = new HashMap(); + private static final Map lookup = new HashMap(); private PermissionDefault(/*@NotNull*/ String... names) { this.names = names; diff --git a/api/src/main/java/org/bukkit/persistence/PersistentDataAdapterContext.java b/api/src/main/java/org/bukkit/persistence/PersistentDataAdapterContext.java new file mode 100644 index 000000000..8face93f3 --- /dev/null +++ b/api/src/main/java/org/bukkit/persistence/PersistentDataAdapterContext.java @@ -0,0 +1,18 @@ +package org.bukkit.persistence; + +import org.jetbrains.annotations.NotNull; + +/** + * This interface represents the context in which the {@link PersistentDataType} can + * serialize and deserialize the passed values. + */ +public interface PersistentDataAdapterContext { + + /** + * Creates a new and empty meta container instance. + * + * @return the fresh container instance + */ + @NotNull + PersistentDataContainer newPersistentDataContainer(); +} diff --git a/api/src/main/java/org/bukkit/persistence/PersistentDataContainer.java b/api/src/main/java/org/bukkit/persistence/PersistentDataContainer.java new file mode 100644 index 000000000..05a93aa31 --- /dev/null +++ b/api/src/main/java/org/bukkit/persistence/PersistentDataContainer.java @@ -0,0 +1,141 @@ +package org.bukkit.persistence; + +import org.bukkit.NamespacedKey; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * This interface represents a map like object, capable of storing custom tags + * in it. + */ +public interface PersistentDataContainer { + + /** + * Stores a metadata value on the {@link PersistentDataHolder} instance. + *

    + * This API cannot be used to manipulate minecraft data, as the values will + * be stored using your namespace. This method will override any existing + * value the {@link PersistentDataHolder} may have stored under the provided + * key. + * + * @param key the key this value will be stored under + * @param type the type this tag uses + * @param value the value stored in the tag + * @param the generic java type of the tag value + * @param the generic type of the object to store + * + * @throws NullPointerException if the key is null + * @throws NullPointerException if the type is null + * @throws NullPointerException if the value is null. Removing a tag should + * be done using {@link #remove(NamespacedKey)} + * @throws IllegalArgumentException if no suitable adapter will be found for + * the {@link PersistentDataType#getPrimitiveType()} + */ + void set(@NotNull NamespacedKey key, @NotNull PersistentDataType type, @NotNull Z value); + + /** + * Returns if the persistent metadata provider has metadata registered + * matching the provided parameters. + *

    + * This method will only return if the found value has the same primitive + * data type as the provided key. + *

    + * Storing a value using a custom {@link PersistentDataType} implementation + * will not store the complex data type. Therefore storing a UUID (by + * storing a byte[]) will match has("key" , + * {@link PersistentDataType#BYTE_ARRAY}). Likewise a stored byte[] will + * always match your UUID {@link PersistentDataType} even if it is not 16 + * bytes long. + *

    + * This method is only usable for custom object keys. Overwriting existing + * tags, like the the display name, will not work as the values are stored + * using your namespace. + * + * @param key the key the value is stored under + * @param type the type which primitive storage type has to match the value + * @param the generic type of the stored primitive + * @param the generic type of the eventually created complex object + * + * @return if a value + * + * @throws NullPointerException if the key to look up is null + * @throws NullPointerException if the type to cast the found object to is + * null + */ + boolean has(@NotNull NamespacedKey key, @NotNull PersistentDataType type); + + /** + * Returns the metadata value that is stored on the + * {@link PersistentDataHolder} instance. + * + * @param key the key to look up in the custom tag map + * @param type the type the value must have and will be casted to + * @param the generic type of the stored primitive + * @param the generic type of the eventually created complex object + * + * @return the value or {@code null} if no value was mapped under the given + * value + * + * @throws NullPointerException if the key to look up is null + * @throws NullPointerException if the type to cast the found object to is + * null + * @throws IllegalArgumentException if the value exists under the given key, + * but cannot be access using the given type + * @throws IllegalArgumentException if no suitable adapter will be found for + * the {@link + * PersistentDataType#getPrimitiveType()} + */ + @Nullable + Z get(@NotNull NamespacedKey key, @NotNull PersistentDataType type); + + /** + * Returns the metadata value that is stored on the + * {@link PersistentDataHolder} instance. If the value does not exist in the + * container, the default value provided is returned. + * + * @param key the key to look up in the custom tag map + * @param type the type the value must have and will be casted to + * @param defaultValue the default value to return if no value was found for + * the provided key + * @param the generic type of the stored primitive + * @param the generic type of the eventually created complex object + * + * @return the value or the default value if no value was mapped under the + * given value + * + * @throws NullPointerException if the key to look up is null + * @throws NullPointerException if the type to cast the found object to is + * null + * @throws IllegalArgumentException if the value exists under the given key, + * but cannot be access using the given type + * @throws IllegalArgumentException if no suitable adapter will be found for + * the {@link PersistentDataType#getPrimitiveType()} + */ + @NotNull + Z getOrDefault(@NotNull NamespacedKey key, @NotNull PersistentDataType type, @NotNull Z defaultValue); + + /** + * Removes a custom key from the {@link PersistentDataHolder} instance. + * + * @param key the key + * + * @throws NullPointerException if the provided key is null + */ + void remove(@NotNull NamespacedKey key); + + /** + * Returns if the container instance is empty, therefore has no entries + * inside it. + * + * @return the boolean + */ + boolean isEmpty(); + + /** + * Returns the adapter context this tag container uses. + * + * @return the tag context + */ + @NotNull + PersistentDataAdapterContext getAdapterContext(); +} diff --git a/api/src/main/java/org/bukkit/persistence/PersistentDataHolder.java b/api/src/main/java/org/bukkit/persistence/PersistentDataHolder.java new file mode 100644 index 000000000..80b277cc5 --- /dev/null +++ b/api/src/main/java/org/bukkit/persistence/PersistentDataHolder.java @@ -0,0 +1,23 @@ +package org.bukkit.persistence; + +import org.jetbrains.annotations.NotNull; + +/** + * The {@link PersistentDataHolder} interface defines an object that can store + * custom persistent meta data on it. + */ +public interface PersistentDataHolder { + + /** + * Returns a custom tag container capable of storing tags on the object. + * + * Note that the tags stored on this container are all stored under their + * own custom namespace therefore modifying default tags using this + * {@link PersistentDataHolder} is impossible. + * + * @return the persistent metadata container + */ + @NotNull + PersistentDataContainer getPersistentDataContainer(); + +} diff --git a/api/src/main/java/org/bukkit/persistence/PersistentDataType.java b/api/src/main/java/org/bukkit/persistence/PersistentDataType.java new file mode 100644 index 000000000..b229b4440 --- /dev/null +++ b/api/src/main/java/org/bukkit/persistence/PersistentDataType.java @@ -0,0 +1,153 @@ +package org.bukkit.persistence; + +import org.jetbrains.annotations.NotNull; + +/** + * This class represents an enum with a generic content type. It defines the + * types a custom tag can have. + *

    + * This interface can be used to create your own custom + * {@link PersistentDataType} with different complex types. This may be useful + * for the likes of a UUIDTagType: + *

    + * {@code
    + * public class UUIDTagType implements PersistentDataType {
    + *
    + *         {@literal @Override}
    + *         public Class getPrimitiveType() {
    + *             return byte[].class;
    + *         }
    + *
    + *         {@literal @Override}
    + *         public Class getComplexType() {
    + *             return UUID.class;
    + *         }
    + *
    + *         {@literal @Override}
    + *         public byte[] toPrimitive(UUID complex, PersistentDataAdapterContext context) {
    + *             ByteBuffer bb = ByteBuffer.wrap(new byte[16]);
    + *             bb.putLong(complex.getMostSignificantBits());
    + *             bb.putLong(complex.getLeastSignificantBits());
    + *             return bb.array();
    + *         }
    + *
    + *         {@literal @Override}
    + *         public UUID fromPrimitive(byte[] primitive, PersistentDataAdapterContext context) {
    + *             ByteBuffer bb = ByteBuffer.wrap(primitive);
    + *             long firstLong = bb.getLong();
    + *             long secondLong = bb.getLong();
    + *             return new UUID(firstLong, secondLong);
    + *         }
    + *     }}
    + * + * @param the primary object type that is stored in the given tag + * @param the retrieved object type when applying this tag type + */ +public interface PersistentDataType { + + /* + The primitive one value types. + */ + PersistentDataType BYTE = new PrimitivePersistentDataType<>(Byte.class); + PersistentDataType SHORT = new PrimitivePersistentDataType<>(Short.class); + PersistentDataType INTEGER = new PrimitivePersistentDataType<>(Integer.class); + PersistentDataType LONG = new PrimitivePersistentDataType<>(Long.class); + PersistentDataType FLOAT = new PrimitivePersistentDataType<>(Float.class); + PersistentDataType DOUBLE = new PrimitivePersistentDataType<>(Double.class); + + /* + String. + */ + PersistentDataType STRING = new PrimitivePersistentDataType<>(String.class); + + /* + Primitive Arrays. + */ + PersistentDataType BYTE_ARRAY = new PrimitivePersistentDataType<>(byte[].class); + PersistentDataType INTEGER_ARRAY = new PrimitivePersistentDataType<>(int[].class); + PersistentDataType LONG_ARRAY = new PrimitivePersistentDataType<>(long[].class); + + /* + Nested PersistentDataContainer. + */ + PersistentDataType TAG_CONTAINER = new PrimitivePersistentDataType<>(PersistentDataContainer.class); + + /** + * Returns the primitive data type of this tag. + * + * @return the class + */ + @NotNull + Class getPrimitiveType(); + + /** + * Returns the complex object type the primitive value resembles. + * + * @return the class type + */ + @NotNull + Class getComplexType(); + + /** + * Returns the primitive data that resembles the complex object passed to + * this method. + * + * @param complex the complex object instance + * @param context the context this operation is running in + * @return the primitive value + */ + @NotNull + T toPrimitive(@NotNull Z complex, @NotNull PersistentDataAdapterContext context); + + /** + * Creates a complex object based of the passed primitive value + * + * @param primitive the primitive value + * @param context the context this operation is running in + * @return the complex object instance + */ + @NotNull + Z fromPrimitive(@NotNull T primitive, @NotNull PersistentDataAdapterContext context); + + /** + * A default implementation that simply exists to pass on the retrieved or + * inserted value to the next layer. + *

    + * This implementation does not add any kind of logic, but is used to + * provide default implementations for the primitive types. + * + * @param the generic type of the primitive objects + */ + class PrimitivePersistentDataType implements PersistentDataType { + + private final Class primitiveType; + + PrimitivePersistentDataType(@NotNull Class primitiveType) { + this.primitiveType = primitiveType; + } + + @NotNull + @Override + public Class getPrimitiveType() { + return primitiveType; + } + + @NotNull + @Override + public Class getComplexType() { + return primitiveType; + } + + @NotNull + @Override + public T toPrimitive(@NotNull T complex, @NotNull PersistentDataAdapterContext context) { + return complex; + } + + @NotNull + @Override + public T fromPrimitive(@NotNull T primitive, @NotNull PersistentDataAdapterContext context) { + return primitive; + } + } +} diff --git a/api/src/main/java/org/bukkit/plugin/Plugin.java b/api/src/main/java/org/bukkit/plugin/Plugin.java index b4882f48b..79890c68f 100644 --- a/api/src/main/java/org/bukkit/plugin/Plugin.java +++ b/api/src/main/java/org/bukkit/plugin/Plugin.java @@ -3,7 +3,6 @@ package org.bukkit.plugin; import java.io.File; import java.io.InputStream; import java.util.logging.Logger; - import org.bukkit.Server; import org.bukkit.command.TabExecutor; import org.bukkit.configuration.file.FileConfiguration; diff --git a/api/src/main/java/org/bukkit/plugin/PluginBase.java b/api/src/main/java/org/bukkit/plugin/PluginBase.java index 70c53a24d..94f8ceb96 100644 --- a/api/src/main/java/org/bukkit/plugin/PluginBase.java +++ b/api/src/main/java/org/bukkit/plugin/PluginBase.java @@ -28,6 +28,7 @@ public abstract class PluginBase implements Plugin { return getName().equals(((Plugin) obj).getName()); } + @Override @NotNull public final String getName() { return getDescription().getName(); diff --git a/api/src/main/java/org/bukkit/plugin/PluginDescriptionFile.java b/api/src/main/java/org/bukkit/plugin/PluginDescriptionFile.java index 4574a965e..cb31a6d5a 100644 --- a/api/src/main/java/org/bukkit/plugin/PluginDescriptionFile.java +++ b/api/src/main/java/org/bukkit/plugin/PluginDescriptionFile.java @@ -1,5 +1,8 @@ package org.bukkit.plugin; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; import java.io.InputStream; import java.io.Reader; import java.io.Writer; @@ -9,16 +12,15 @@ import java.util.List; import java.util.Map; import java.util.Set; import java.util.regex.Pattern; - import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.command.PluginCommand; import org.bukkit.command.TabCompleter; -import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.permissions.Permissible; import org.bukkit.permissions.Permission; import org.bukkit.permissions.PermissionDefault; +import org.bukkit.plugin.java.JavaPlugin; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.yaml.snakeyaml.Yaml; @@ -27,10 +29,6 @@ import org.yaml.snakeyaml.constructor.SafeConstructor; import org.yaml.snakeyaml.nodes.Node; import org.yaml.snakeyaml.nodes.Tag; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; - /** * This type is the runtime-container for the information in the plugin.yml. * All plugins must have a respective plugin.yml. For plugins written in java @@ -784,7 +782,7 @@ public final class PluginDescriptionFile { * * Another example, with nested definitions, can be found here. - * + * * @return the permissions this plugin will register */ @NotNull @@ -829,7 +827,7 @@ public final class PluginDescriptionFile { * not included in the API. Any unrecognized * awareness (one unsupported or in a future version) will cause a dummy * object to be created instead of failing. - * + * *

      *
    • Currently only supports the enumerated values in {@link * PluginAwareness.Flags}. diff --git a/api/src/main/java/org/bukkit/plugin/PluginLoader.java b/api/src/main/java/org/bukkit/plugin/PluginLoader.java index fbd65e8b0..6ab9cd821 100644 --- a/api/src/main/java/org/bukkit/plugin/PluginLoader.java +++ b/api/src/main/java/org/bukkit/plugin/PluginLoader.java @@ -4,7 +4,6 @@ import java.io.File; import java.util.Map; import java.util.Set; import java.util.regex.Pattern; - import org.bukkit.event.Event; import org.bukkit.event.Listener; import org.jetbrains.annotations.NotNull; diff --git a/api/src/main/java/org/bukkit/plugin/PluginLogger.java b/api/src/main/java/org/bukkit/plugin/PluginLogger.java index 533f0b6f8..018237001 100644 --- a/api/src/main/java/org/bukkit/plugin/PluginLogger.java +++ b/api/src/main/java/org/bukkit/plugin/PluginLogger.java @@ -1,10 +1,9 @@ package org.bukkit.plugin; -import org.jetbrains.annotations.NotNull; - import java.util.logging.Level; import java.util.logging.LogRecord; import java.util.logging.Logger; +import org.jetbrains.annotations.NotNull; /** * The PluginLogger class is a modified {@link Logger} that prepends all diff --git a/api/src/main/java/org/bukkit/plugin/PluginManager.java b/api/src/main/java/org/bukkit/plugin/PluginManager.java index ba4ed7ed7..86cc5025a 100644 --- a/api/src/main/java/org/bukkit/plugin/PluginManager.java +++ b/api/src/main/java/org/bukkit/plugin/PluginManager.java @@ -2,7 +2,6 @@ package org.bukkit.plugin; import java.io.File; import java.util.Set; - import org.bukkit.event.Event; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; diff --git a/api/src/main/java/org/bukkit/plugin/RegisteredListener.java b/api/src/main/java/org/bukkit/plugin/RegisteredListener.java index a3b3a056b..419aec56b 100644 --- a/api/src/main/java/org/bukkit/plugin/RegisteredListener.java +++ b/api/src/main/java/org/bukkit/plugin/RegisteredListener.java @@ -1,6 +1,10 @@ package org.bukkit.plugin; -import org.bukkit.event.*; +import org.bukkit.event.Cancellable; +import org.bukkit.event.Event; +import org.bukkit.event.EventException; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; import org.jetbrains.annotations.NotNull; /** diff --git a/api/src/main/java/org/bukkit/plugin/RegisteredServiceProvider.java b/api/src/main/java/org/bukkit/plugin/RegisteredServiceProvider.java index cbcdadd49..f45171937 100644 --- a/api/src/main/java/org/bukkit/plugin/RegisteredServiceProvider.java +++ b/api/src/main/java/org/bukkit/plugin/RegisteredServiceProvider.java @@ -41,6 +41,7 @@ public class RegisteredServiceProvider implements Comparable other) { if (priority.ordinal() == other.getPriority().ordinal()) { return 0; diff --git a/api/src/main/java/org/bukkit/plugin/ServicesManager.java b/api/src/main/java/org/bukkit/plugin/ServicesManager.java index 185b644b1..9e2f00572 100644 --- a/api/src/main/java/org/bukkit/plugin/ServicesManager.java +++ b/api/src/main/java/org/bukkit/plugin/ServicesManager.java @@ -1,10 +1,9 @@ package org.bukkit.plugin; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - import java.util.Collection; import java.util.List; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Manages services and service providers. Services are an interface diff --git a/api/src/main/java/org/bukkit/plugin/SimplePluginManager.java b/api/src/main/java/org/bukkit/plugin/SimplePluginManager.java index 2a43182bb..d0e735bc3 100644 --- a/api/src/main/java/org/bukkit/plugin/SimplePluginManager.java +++ b/api/src/main/java/org/bukkit/plugin/SimplePluginManager.java @@ -1,11 +1,11 @@ package org.bukkit.plugin; +import com.google.common.collect.ImmutableSet; import java.io.File; import java.lang.reflect.Constructor; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Collection; -import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; @@ -20,14 +20,12 @@ import java.util.logging.Level; import java.util.regex.Matcher; import java.util.regex.Pattern; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - import com.destroystokyo.paper.event.server.ServerExceptionEvent; import com.destroystokyo.paper.exception.ServerEventException; import com.destroystokyo.paper.exception.ServerPluginEnableDisableException; import org.apache.commons.lang.Validate; import org.bukkit.Server; +import org.bukkit.World; import org.bukkit.command.Command; import org.bukkit.command.PluginCommandYamlParser; import org.bukkit.command.SimpleCommandMap; @@ -39,43 +37,31 @@ import org.bukkit.permissions.Permissible; import org.bukkit.permissions.Permission; import org.bukkit.permissions.PermissionDefault; import org.bukkit.util.FileUtil; - -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Maps; -import com.koloboke.collect.map.hash.HashIntObjMap; -import com.koloboke.collect.map.hash.HashIntObjMaps; -import com.koloboke.collect.map.hash.HashObjObjMap; -import com.koloboke.collect.map.hash.HashObjObjMaps; -import com.koloboke.collect.set.hash.HashObjSets; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Handles all plugin management from the Server */ public final class SimplePluginManager implements PluginManager { private final Server server; - private final Map fileAssociations = HashObjObjMaps.newMutableMap(); // Akarin + private final Map fileAssociations = new HashMap(); private final List plugins = new ArrayList(); - private final Map lookupNames = HashObjObjMaps.newMutableMap(); // Akarin + private final Map lookupNames = new HashMap(); private File updateDirectory; private final SimpleCommandMap commandMap; - private Map permissions = Collections.emptyMap(); // Akarin - private final Object permissionsLock = new Object(); - private Map> defaultPerms; // Akarin - private final Map> permSubs = HashObjObjMaps.newMutableMap(); // Akarin - private final Object permSubsLock = new Object(); - private final Map> defSubs = HashObjObjMaps.newMutableMap(); // Akarin + private final Map permissions = new HashMap(); + private final Map> defaultPerms = new LinkedHashMap>(); + private final Map> permSubs = new HashMap>(); + private final Map> defSubs = new HashMap>(); private boolean useTimings = false; - public SimplePluginManager(@Nonnull Server instance, @Nonnull SimpleCommandMap commandMap) { // Akarin - javax.annotation + public SimplePluginManager(@NotNull Server instance, @NotNull SimpleCommandMap commandMap) { server = instance; this.commandMap = commandMap; - // Akarin start - HashObjObjMap> defaultPerms = HashObjObjMaps.newUpdatableMap(); - defaultPerms.put(Boolean.TRUE, HashObjSets.newUpdatableSet()); - defaultPerms.put(Boolean.FALSE, HashObjSets.newUpdatableSet()); - this.defaultPerms = defaultPerms; - // Akarin end + defaultPerms.put(true, new LinkedHashSet()); + defaultPerms.put(false, new LinkedHashSet()); } /** @@ -85,7 +71,8 @@ public final class SimplePluginManager implements PluginManager { * @throws IllegalArgumentException Thrown when the given Class is not a * valid PluginLoader */ - public void registerInterface(@Nonnull Class loader) throws IllegalArgumentException { // Akarin - javax.annotation + @Override + public void registerInterface(@NotNull Class loader) throws IllegalArgumentException { PluginLoader instance; if (PluginLoader.class.isAssignableFrom(loader)) { @@ -120,8 +107,9 @@ public final class SimplePluginManager implements PluginManager { * @param directory Directory to check for plugins * @return A list of all plugins loaded */ - @Nonnull // Akarin - javax.annotation - public Plugin[] loadPlugins(@Nonnull File directory) { // Akarin - javax.annotation + @Override + @NotNull + public Plugin[] loadPlugins(@NotNull File directory) { Validate.notNull(directory, "Directory cannot be null"); Validate.isTrue(directory.isDirectory(), "Directory must be a directory"); @@ -132,10 +120,10 @@ public final class SimplePluginManager implements PluginManager { updateDirectory = new File(directory, server.getUpdateFolder()); } - Map plugins = HashObjObjMaps.newMutableMap(); // Akarin - Set loadedPlugins = HashObjSets.newMutableSet(); // Akarin - Map> dependencies = HashObjObjMaps.newMutableMap(); // Akarin - Map> softDependencies = HashObjObjMaps.newMutableMap(); // Akarin + Map plugins = new HashMap(); + Set loadedPlugins = new HashSet(); + Map> dependencies = new HashMap>(); + Map> softDependencies = new HashMap>(); // This is where it figures out all possible plugins for (File file : directory.listFiles()) { @@ -329,8 +317,9 @@ public final class SimplePluginManager implements PluginManager { * @throws UnknownDependencyException If a required dependency could not * be found */ + @Override @Nullable - public synchronized Plugin loadPlugin(@Nonnull File file) throws InvalidPluginException, UnknownDependencyException { // Akarin - javax.annotation + public synchronized Plugin loadPlugin(@NotNull File file) throws InvalidPluginException, UnknownDependencyException { Validate.notNull(file, "File cannot be null"); checkUpdate(file); @@ -357,7 +346,7 @@ public final class SimplePluginManager implements PluginManager { return result; } - private void checkUpdate(@Nonnull File file) { // Akarin - javax.annotation + private void checkUpdate(@NotNull File file) { if (updateDirectory == null || !updateDirectory.isDirectory()) { return; } @@ -376,12 +365,14 @@ public final class SimplePluginManager implements PluginManager { * @param name Name of the plugin to check * @return Plugin if it exists, otherwise null */ + @Override @Nullable - public synchronized Plugin getPlugin(@Nonnull String name) { // Akarin - javax.annotation + public synchronized Plugin getPlugin(@NotNull String name) { return lookupNames.get(name.replace(' ', '_').toLowerCase(java.util.Locale.ENGLISH)); // Paper } - @Nonnull // Akarin - javax.annotation + @Override + @NotNull public synchronized Plugin[] getPlugins() { return plugins.toArray(new Plugin[plugins.size()]); } @@ -394,7 +385,8 @@ public final class SimplePluginManager implements PluginManager { * @param name Name of the plugin to check * @return true if the plugin is enabled, otherwise false */ - public boolean isPluginEnabled(@Nonnull String name) { // Akarin - javax.annotation + @Override + public boolean isPluginEnabled(@NotNull String name) { Plugin plugin = getPlugin(name); return isPluginEnabled(plugin); @@ -406,6 +398,7 @@ public final class SimplePluginManager implements PluginManager { * @param plugin Plugin to check * @return true if the plugin is enabled, otherwise false */ + @Override public synchronized boolean isPluginEnabled(@Nullable Plugin plugin) { // Paper - synchronize if ((plugin != null) && (plugins.contains(plugin))) { return plugin.isEnabled(); @@ -414,7 +407,8 @@ public final class SimplePluginManager implements PluginManager { } } - public synchronized void enablePlugin(@Nonnull final Plugin plugin) { // Paper - synchronize // Akarin - javax.annotation + @Override + public synchronized void enablePlugin(@NotNull final Plugin plugin) { // Paper - synchronize if (!plugin.isEnabled()) { List pluginCommands = PluginCommandYamlParser.parse(plugin); @@ -433,7 +427,7 @@ public final class SimplePluginManager implements PluginManager { } } - // Paper start - close Classloader on disable + @Override public void disablePlugins() { disablePlugins(false); } @@ -446,12 +440,13 @@ public final class SimplePluginManager implements PluginManager { } } - // Paper start - close Classloader on disable - public void disablePlugin(@Nonnull final Plugin plugin) { // Akarin - javax.annotation + @Override + public void disablePlugin(@NotNull final Plugin plugin) { disablePlugin(plugin, false); } - public synchronized void disablePlugin(@Nonnull final Plugin plugin, boolean closeClassloader) { // Paper - synchronize // Akarin - javax.annotation + @Override + public synchronized void disablePlugin(@NotNull final Plugin plugin, boolean closeClassloader) { // Paper - synchronize // Paper end - close Classloader on disable if (plugin.isEnabled()) { try { @@ -489,6 +484,14 @@ public final class SimplePluginManager implements PluginManager { handlePluginException("Error occurred (in the plugin loader) while unregistering plugin channels for " + plugin.getDescription().getFullName() + " (Is it up to date?)", ex, plugin); // Paper } + + try { + for (World world : server.getWorlds()) { + world.removePluginChunkTickets(plugin); + } + } catch (Throwable ex) { + server.getLogger().log(Level.SEVERE, "Error occurred (in the plugin loader) while removing chunk tickets for " + plugin.getDescription().getFullName() + " (Is it up to date?)", ex); + } } } @@ -499,6 +502,7 @@ public final class SimplePluginManager implements PluginManager { } // Paper end + @Override public void clearPlugins() { synchronized (this) { disablePlugins(true); // Paper - close Classloader on disable @@ -506,15 +510,9 @@ public final class SimplePluginManager implements PluginManager { lookupNames.clear(); HandlerList.unregisterAll(); fileAssociations.clear(); - synchronized (permissionsLock) { permissions = Collections.emptyMap(); } // Akarin - // Akarin start - //defaultPerms.get(true).clear(); - //defaultPerms.get(false).clear(); - HashObjObjMap> defaultPerms = HashObjObjMaps.newUpdatableMap(); - defaultPerms.put(Boolean.TRUE, HashObjSets.newUpdatableSet()); - defaultPerms.put(Boolean.FALSE, HashObjSets.newUpdatableSet()); - this.defaultPerms = defaultPerms; - // Akarin end + permissions.clear(); + defaultPerms.get(true).clear(); + defaultPerms.get(false).clear(); } } private void fireEvent(Event event) { callEvent(event); } // Paper - support old method incase plugin uses reflection @@ -526,8 +524,15 @@ public final class SimplePluginManager implements PluginManager { * * @param event Event details */ - public void callEvent(@Nonnull Event event) { // Akarin - javax.annotation + @Override + public void callEvent(@NotNull Event event) { // Paper - replace callEvent by merging to below method + if (event.isAsynchronous() && server.isPrimaryThread()) { + throw new IllegalStateException(event.getEventName() + " may only be triggered asynchronously."); + } else if (!event.isAsynchronous() && !server.isPrimaryThread()) { + throw new IllegalStateException(event.getEventName() + " may only be triggered synchronously."); + } + HandlerList handlers = event.getHandlers(); RegisteredListener[] listeners = handlers.getRegisteredListeners(); @@ -563,7 +568,8 @@ public final class SimplePluginManager implements PluginManager { } } - public void registerEvents(@Nonnull Listener listener, @Nonnull Plugin plugin) { // Akarin - javax.annotation + @Override + public void registerEvents(@NotNull Listener listener, @NotNull Plugin plugin) { if (!plugin.isEnabled()) { throw new IllegalPluginAccessException("Plugin attempted to register " + listener + " while not enabled"); } @@ -574,7 +580,8 @@ public final class SimplePluginManager implements PluginManager { } - public void registerEvent(@Nonnull Class event, @Nonnull Listener listener, @Nonnull EventPriority priority, @Nonnull EventExecutor executor, @Nonnull Plugin plugin) { // Akarin - javax.annotation + @Override + public void registerEvent(@NotNull Class event, @NotNull Listener listener, @NotNull EventPriority priority, @NotNull EventExecutor executor, @NotNull Plugin plugin) { registerEvent(event, listener, priority, executor, plugin, false); } @@ -590,7 +597,8 @@ public final class SimplePluginManager implements PluginManager { * @param ignoreCancelled Do not call executor if event was already * cancelled */ - public void registerEvent(@Nonnull Class event, @Nonnull Listener listener, @Nonnull EventPriority priority, @Nonnull EventExecutor executor, @Nonnull Plugin plugin, boolean ignoreCancelled) { // Akarin - javax.annotation + @Override + public void registerEvent(@NotNull Class event, @NotNull Listener listener, @NotNull EventPriority priority, @NotNull EventExecutor executor, @NotNull Plugin plugin, boolean ignoreCancelled) { Validate.notNull(listener, "Listener cannot be null"); Validate.notNull(priority, "Priority cannot be null"); Validate.notNull(executor, "Executor cannot be null"); @@ -608,8 +616,8 @@ public final class SimplePluginManager implements PluginManager { } } - @Nonnull // Akarin - javax.annotation - private HandlerList getEventListeners(@Nonnull Class type) { // Akarin - javax.annotation + @NotNull + private HandlerList getEventListeners(@NotNull Class type) { try { Method method = getRegistrationClass(type).getDeclaredMethod("getHandlerList"); method.setAccessible(true); @@ -619,8 +627,8 @@ public final class SimplePluginManager implements PluginManager { } } - @Nonnull // Akarin - javax.annotation - private Class getRegistrationClass(@Nonnull Class clazz) { // Akarin - javax.annotation + @NotNull + private Class getRegistrationClass(@NotNull Class clazz) { try { clazz.getDeclaredMethod("getHandlerList"); return clazz; @@ -635,92 +643,64 @@ public final class SimplePluginManager implements PluginManager { } } + @Override @Nullable - public Permission getPermission(@Nonnull String name) { // Akarin - javax.annotation + public Permission getPermission(@NotNull String name) { return permissions.get(name.toLowerCase(java.util.Locale.ENGLISH)); } - public void addPermission(@Nonnull Permission perm) { // Akarin - javax.annotation + @Override + public void addPermission(@NotNull Permission perm) { addPermission(perm, true); } @Deprecated - public void addPermission(@Nonnull Permission perm, boolean dirty) { // Akarin - javax.annotation + public void addPermission(@NotNull Permission perm, boolean dirty) { String name = perm.getName().toLowerCase(java.util.Locale.ENGLISH); if (permissions.containsKey(name)) { throw new IllegalArgumentException("The permission " + name + " is already defined!"); } - // Akarin start - synchronized (permissionsLock) { - HashObjObjMap toImmutable = HashObjObjMaps.newUpdatableMap(permissions); - toImmutable.put(name, perm); - permissions = HashObjObjMaps.newImmutableMap(toImmutable); - } - // Akarin end + permissions.put(name, perm); calculatePermissionDefault(perm, dirty); } - @Nonnull // Akarin - javax.annotation + @Override + @NotNull public Set getDefaultPermissions(boolean op) { - return defaultPerms.get(op); + return ImmutableSet.copyOf(defaultPerms.get(op)); } - public void removePermission(@Nonnull Permission perm) { // Akarin - javax.annotation + @Override + public void removePermission(@NotNull Permission perm) { removePermission(perm.getName()); } - public void removePermission(@Nonnull String name) { // Akarin - javax.annotation - // Akarin start - synchronized (permissionsLock) { - HashObjObjMap toImmutable = HashObjObjMaps.newMutableMap(permissions); - toImmutable.remove(name.toLowerCase(java.util.Locale.ENGLISH)); - permissions = HashObjObjMaps.newImmutableMap(toImmutable); - } - // Akarin end + @Override + public void removePermission(@NotNull String name) { + permissions.remove(name.toLowerCase(java.util.Locale.ENGLISH)); } - public void recalculatePermissionDefaults(@Nonnull Permission perm) { // Akarin - javax.annotation + @Override + public void recalculatePermissionDefaults(@NotNull Permission perm) { if (perm != null && permissions.containsKey(perm.getName().toLowerCase(java.util.Locale.ENGLISH))) { - // Akarin start - HashObjObjMap> toImmutable = HashObjObjMaps.newUpdatableMap(defaultPerms); - Set toImmutableValueOp = HashObjSets.newMutableSet(defaultPerms.get(Boolean.TRUE)); - toImmutableValueOp.remove(perm); - toImmutable.put(Boolean.TRUE, HashObjSets.newImmutableSet(toImmutableValueOp)); - - Set toImmutableValue = HashObjSets.newMutableSet(defaultPerms.get(Boolean.FALSE)); - toImmutableValue.remove(perm); - toImmutable.put(Boolean.FALSE, HashObjSets.newImmutableSet(toImmutableValue)); - - defaultPerms = toImmutable; - // Akarin end + defaultPerms.get(true).remove(perm); + defaultPerms.get(false).remove(perm); calculatePermissionDefault(perm, true); } } - private void calculatePermissionDefault(@Nonnull Permission perm, boolean dirty) { // Akarin - javax.annotation + private void calculatePermissionDefault(@NotNull Permission perm, boolean dirty) { if ((perm.getDefault() == PermissionDefault.OP) || (perm.getDefault() == PermissionDefault.TRUE)) { - // Akarin start - HashObjObjMap> toImmutable = HashObjObjMaps.newUpdatableMap(defaultPerms); - Set toImmutableValue = HashObjSets.newUpdatableSet(defaultPerms.get(Boolean.TRUE)); - toImmutableValue.add(perm); - toImmutable.put(Boolean.TRUE, HashObjSets.newImmutableSet(toImmutableValue)); - defaultPerms = toImmutable; - // Akarin end + defaultPerms.get(true).add(perm); if (dirty) { dirtyPermissibles(true); } } if ((perm.getDefault() == PermissionDefault.NOT_OP) || (perm.getDefault() == PermissionDefault.TRUE)) { - // Akarin start - HashObjObjMap> toImmutable = HashObjObjMaps.newUpdatableMap(defaultPerms); - Set toImmutableValue = HashObjSets.newUpdatableSet(defaultPerms.get(Boolean.FALSE)); - toImmutableValue.add(perm); - toImmutable.put(Boolean.FALSE, HashObjSets.newImmutableSet(toImmutableValue)); - defaultPerms = toImmutable; - // Akarin end + defaultPerms.get(false).add(perm); if (dirty) { dirtyPermissibles(false); } @@ -741,9 +721,9 @@ public final class SimplePluginManager implements PluginManager { } } - public void subscribeToPermission(@Nonnull String permission, @Nonnull Permissible permissible) { // Akarin - javax.annotation + @Override + public void subscribeToPermission(@NotNull String permission, @NotNull Permissible permissible) { String name = permission.toLowerCase(java.util.Locale.ENGLISH); - synchronized (permSubsLock) { // Akarin Map map = permSubs.get(name); if (map == null) { @@ -752,12 +732,11 @@ public final class SimplePluginManager implements PluginManager { } map.put(permissible, true); - } // Akarin } - public void unsubscribeFromPermission(@Nonnull String permission, @Nonnull Permissible permissible) { // Akarin - javax.annotation + @Override + public void unsubscribeFromPermission(@NotNull String permission, @NotNull Permissible permissible) { String name = permission.toLowerCase(java.util.Locale.ENGLISH); - synchronized (permSubsLock) { // Akarin Map map = permSubs.get(name); if (map != null) { @@ -767,13 +746,12 @@ public final class SimplePluginManager implements PluginManager { permSubs.remove(name); } } - } // Akarin } - @Nonnull // Akarin - javax.annotation - public Set getPermissionSubscriptions(@Nonnull String permission) { // Akarin - javax.annotation + @Override + @NotNull + public Set getPermissionSubscriptions(@NotNull String permission) { String name = permission.toLowerCase(java.util.Locale.ENGLISH); - synchronized (permSubsLock) { // Akarin Map map = permSubs.get(name); if (map == null) { @@ -781,10 +759,10 @@ public final class SimplePluginManager implements PluginManager { } else { return ImmutableSet.copyOf(map.keySet()); } - } // Akarin } - public void subscribeToDefaultPerms(boolean op, @Nonnull Permissible permissible) { // Akarin - javax.annotation + @Override + public void subscribeToDefaultPerms(boolean op, @NotNull Permissible permissible) { Map map = defSubs.get(op); if (map == null) { @@ -795,7 +773,8 @@ public final class SimplePluginManager implements PluginManager { map.put(permissible, true); } - public void unsubscribeFromDefaultPerms(boolean op, @Nonnull Permissible permissible) { // Akarin - javax.annotation + @Override + public void unsubscribeFromDefaultPerms(boolean op, @NotNull Permissible permissible) { Map map = defSubs.get(op); if (map != null) { @@ -807,7 +786,8 @@ public final class SimplePluginManager implements PluginManager { } } - @Nonnull // Akarin - javax.annotation + @Override + @NotNull public Set getDefaultPermSubscriptions(boolean op) { Map map = defSubs.get(op); @@ -818,11 +798,13 @@ public final class SimplePluginManager implements PluginManager { } } - @Nonnull // Akarin - javax.annotation + @Override + @NotNull public Set getPermissions() { return new HashSet(permissions.values()); } + @Override public boolean useTimings() { return co.aikar.timings.Timings.isTimingsEnabled(); // Spigot } @@ -838,15 +820,9 @@ public final class SimplePluginManager implements PluginManager { // Paper start public void clearPermissions() { - synchronized (permissionsLock) { permissions = Collections.emptyMap(); } // Akarin - // Akarin start - //defaultPerms.get(true).clear(); - //defaultPerms.get(false).clear(); - HashObjObjMap> defaultPerms = HashObjObjMaps.newUpdatableMap(); - defaultPerms.put(Boolean.TRUE, HashObjSets.newUpdatableSet()); - defaultPerms.put(Boolean.FALSE, HashObjSets.newUpdatableSet()); - this.defaultPerms = defaultPerms; - // Akarin end + permissions.clear(); + defaultPerms.get(true).clear(); + defaultPerms.get(false).clear(); } // Paper end diff --git a/api/src/main/java/org/bukkit/plugin/SimpleServicesManager.java b/api/src/main/java/org/bukkit/plugin/SimpleServicesManager.java index 6514d4ef1..f3dd84902 100644 --- a/api/src/main/java/org/bukkit/plugin/SimpleServicesManager.java +++ b/api/src/main/java/org/bukkit/plugin/SimpleServicesManager.java @@ -1,22 +1,20 @@ package org.bukkit.plugin; -import org.bukkit.Bukkit; -import org.bukkit.event.server.ServiceRegisterEvent; -import org.bukkit.event.server.ServiceUnregisterEvent; - import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.Iterator; -import java.util.Map; import java.util.List; +import java.util.Map; import java.util.NoSuchElementException; import java.util.Set; +import org.bukkit.Bukkit; +import org.bukkit.event.server.ServiceRegisterEvent; +import org.bukkit.event.server.ServiceUnregisterEvent; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * A simple services manager. @@ -37,6 +35,7 @@ public class SimpleServicesManager implements ServicesManager { * @param plugin plugin with the provider * @param priority priority of the provider */ + @Override public void register(@NotNull Class service, @NotNull T provider, @NotNull Plugin plugin, @NotNull ServicePriority priority) { RegisteredServiceProvider registeredProvider = null; synchronized (providers) { @@ -65,6 +64,7 @@ public class SimpleServicesManager implements ServicesManager { * * @param plugin The plugin */ + @Override public void unregisterAll(@NotNull Plugin plugin) { ArrayList unregisteredEvents = new ArrayList(); synchronized (providers) { @@ -107,6 +107,7 @@ public class SimpleServicesManager implements ServicesManager { * @param service The service interface * @param provider The service provider implementation */ + @Override public void unregister(@NotNull Class service, @NotNull Object provider) { ArrayList unregisteredEvents = new ArrayList(); synchronized (providers) { @@ -154,6 +155,7 @@ public class SimpleServicesManager implements ServicesManager { * * @param provider The service provider implementation */ + @Override public void unregister(@NotNull Object provider) { ArrayList unregisteredEvents = new ArrayList(); synchronized (providers) { @@ -198,6 +200,7 @@ public class SimpleServicesManager implements ServicesManager { * @param service The service interface * @return provider or null */ + @Override @Nullable public T load(@NotNull Class service) { synchronized (providers) { @@ -220,6 +223,7 @@ public class SimpleServicesManager implements ServicesManager { * @param service The service interface * @return provider registration or null */ + @Override @Nullable @SuppressWarnings("unchecked") public RegisteredServiceProvider getRegistration(@NotNull Class service) { @@ -241,6 +245,7 @@ public class SimpleServicesManager implements ServicesManager { * @param plugin The plugin * @return provider registrations */ + @Override @NotNull public List> getRegistrations(@NotNull Plugin plugin) { ImmutableList.Builder> ret = ImmutableList.>builder(); @@ -264,6 +269,7 @@ public class SimpleServicesManager implements ServicesManager { * @param service The service interface * @return a copy of the list of registrations */ + @Override @NotNull @SuppressWarnings("unchecked") public List> getRegistrations(@NotNull Class service) { @@ -291,6 +297,7 @@ public class SimpleServicesManager implements ServicesManager { * * @return a copy of the set of known services */ + @Override @NotNull public Set> getKnownServices() { synchronized (providers) { @@ -305,6 +312,7 @@ public class SimpleServicesManager implements ServicesManager { * @param service service to check * @return true if and only if there are registered providers */ + @Override public boolean isProvidedFor(@NotNull Class service) { synchronized (providers) { return providers.containsKey(service); diff --git a/api/src/main/java/org/bukkit/plugin/java/JavaPlugin.java b/api/src/main/java/org/bukkit/plugin/java/JavaPlugin.java index 96ebe72ca..04fa3991f 100644 --- a/api/src/main/java/org/bukkit/plugin/java/JavaPlugin.java +++ b/api/src/main/java/org/bukkit/plugin/java/JavaPlugin.java @@ -1,5 +1,6 @@ package org.bukkit.plugin.java; +import com.google.common.base.Charsets; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; @@ -12,7 +13,6 @@ import java.net.URLConnection; import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; - import org.apache.commons.lang.Validate; import org.bukkit.Server; import org.bukkit.command.Command; @@ -25,8 +25,6 @@ import org.bukkit.plugin.PluginBase; import org.bukkit.plugin.PluginDescriptionFile; import org.bukkit.plugin.PluginLoader; import org.bukkit.plugin.PluginLogger; - -import com.google.common.base.Charsets; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/api/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java b/api/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java index e91cb2c78..31a70b294 100644 --- a/api/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java +++ b/api/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java @@ -18,7 +18,6 @@ import java.util.jar.JarEntry; import java.util.jar.JarFile; import java.util.logging.Level; import java.util.regex.Pattern; - import org.apache.commons.lang.Validate; import org.bukkit.Server; import org.bukkit.Warning; @@ -57,7 +56,7 @@ public final class JavaPluginLoader implements PluginLoader { /** * This class was not meant to be constructed explicitly - * + * * @param instance the server instance */ @Deprecated @@ -66,6 +65,7 @@ public final class JavaPluginLoader implements PluginLoader { server = instance; } + @Override @NotNull public Plugin loadPlugin(@NotNull final File file) throws InvalidPluginException { Validate.notNull(file, "File cannot be null"); @@ -143,6 +143,7 @@ public final class JavaPluginLoader implements PluginLoader { return loader.plugin; } + @Override @NotNull public PluginDescriptionFile getPluginDescription(@NotNull File file) throws InvalidDescriptionException { Validate.notNull(file, "File cannot be null"); @@ -182,6 +183,7 @@ public final class JavaPluginLoader implements PluginLoader { } } + @Override @NotNull public Pattern[] getPluginFileFilters() { return fileFilters.clone(); @@ -231,6 +233,7 @@ public final class JavaPluginLoader implements PluginLoader { } } + @Override @NotNull public Map, Set> createRegisteredListeners(@NotNull Listener listener, @NotNull final Plugin plugin) { Validate.notNull(plugin, "Plugin can not be null"); @@ -308,6 +311,7 @@ public final class JavaPluginLoader implements PluginLoader { return ret; } + @Override public void enablePlugin(@NotNull final Plugin plugin) { Validate.isTrue(plugin instanceof JavaPlugin, "Plugin is not associated with this PluginLoader"); @@ -346,6 +350,7 @@ public final class JavaPluginLoader implements PluginLoader { } } + @Override public void disablePlugin(@NotNull Plugin plugin) { // Paper start - close Classloader on disable disablePlugin(plugin, false); // Retain old behavior unless requested diff --git a/api/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java b/api/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java index 0df1926fa..6f39f571d 100644 --- a/api/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java +++ b/api/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java @@ -15,7 +15,6 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.jar.JarEntry; import java.util.jar.JarFile; import java.util.jar.Manifest; - import org.apache.commons.lang.Validate; import org.bukkit.plugin.InvalidPluginException; import org.bukkit.plugin.PluginDescriptionFile; diff --git a/api/src/main/java/org/bukkit/plugin/messaging/Messenger.java b/api/src/main/java/org/bukkit/plugin/messaging/Messenger.java index ea9b525ff..682c77188 100644 --- a/api/src/main/java/org/bukkit/plugin/messaging/Messenger.java +++ b/api/src/main/java/org/bukkit/plugin/messaging/Messenger.java @@ -24,7 +24,7 @@ public interface Messenger { /** * Represents the largest size that a Plugin Channel may be. */ - public static final int MAX_CHANNEL_SIZE = 32; + public static final int MAX_CHANNEL_SIZE = Integer.getInteger("paper.maxCustomChannelName", 64); // Paper /** * Checks if the specified channel is a reserved name. diff --git a/api/src/main/java/org/bukkit/plugin/messaging/StandardMessenger.java b/api/src/main/java/org/bukkit/plugin/messaging/StandardMessenger.java index cc750eb3e..6fda7f3aa 100644 --- a/api/src/main/java/org/bukkit/plugin/messaging/StandardMessenger.java +++ b/api/src/main/java/org/bukkit/plugin/messaging/StandardMessenger.java @@ -168,12 +168,14 @@ public class StandardMessenger implements Messenger { } } + @Override public boolean isReservedChannel(@NotNull String channel) { channel = validateAndCorrectChannel(channel); return channel.equals("minecraft:register") || channel.equals("minecraft:unregister"); // Paper } + @Override public void registerOutgoingPluginChannel(@NotNull Plugin plugin, @NotNull String channel) { if (plugin == null) { throw new IllegalArgumentException("Plugin cannot be null"); @@ -186,6 +188,7 @@ public class StandardMessenger implements Messenger { addToOutgoing(plugin, channel); } + @Override public void unregisterOutgoingPluginChannel(@NotNull Plugin plugin, @NotNull String channel) { if (plugin == null) { throw new IllegalArgumentException("Plugin cannot be null"); @@ -195,6 +198,7 @@ public class StandardMessenger implements Messenger { removeFromOutgoing(plugin, channel); } + @Override public void unregisterOutgoingPluginChannel(@NotNull Plugin plugin) { if (plugin == null) { throw new IllegalArgumentException("Plugin cannot be null"); @@ -203,6 +207,7 @@ public class StandardMessenger implements Messenger { removeFromOutgoing(plugin); } + @Override @NotNull public PluginMessageListenerRegistration registerIncomingPluginChannel(@NotNull Plugin plugin, @NotNull String channel, @NotNull PluginMessageListener listener) { if (plugin == null) { @@ -223,6 +228,7 @@ public class StandardMessenger implements Messenger { return result; } + @Override public void unregisterIncomingPluginChannel(@NotNull Plugin plugin, @NotNull String channel, @NotNull PluginMessageListener listener) { if (plugin == null) { throw new IllegalArgumentException("Plugin cannot be null"); @@ -235,6 +241,7 @@ public class StandardMessenger implements Messenger { removeFromIncoming(new PluginMessageListenerRegistration(this, plugin, channel, listener)); } + @Override public void unregisterIncomingPluginChannel(@NotNull Plugin plugin, @NotNull String channel) { if (plugin == null) { throw new IllegalArgumentException("Plugin cannot be null"); @@ -244,6 +251,7 @@ public class StandardMessenger implements Messenger { removeFromIncoming(plugin, channel); } + @Override public void unregisterIncomingPluginChannel(@NotNull Plugin plugin) { if (plugin == null) { throw new IllegalArgumentException("Plugin cannot be null"); @@ -252,6 +260,7 @@ public class StandardMessenger implements Messenger { removeFromIncoming(plugin); } + @Override @NotNull public Set getOutgoingChannels() { synchronized (outgoingLock) { @@ -260,6 +269,7 @@ public class StandardMessenger implements Messenger { } } + @Override @NotNull public Set getOutgoingChannels(@NotNull Plugin plugin) { if (plugin == null) { @@ -277,6 +287,7 @@ public class StandardMessenger implements Messenger { } } + @Override @NotNull public Set getIncomingChannels() { synchronized (incomingLock) { @@ -285,6 +296,7 @@ public class StandardMessenger implements Messenger { } } + @Override @NotNull public Set getIncomingChannels(@NotNull Plugin plugin) { if (plugin == null) { @@ -308,6 +320,7 @@ public class StandardMessenger implements Messenger { } } + @Override @NotNull public Set getIncomingChannelRegistrations(@NotNull Plugin plugin) { if (plugin == null) { @@ -325,6 +338,7 @@ public class StandardMessenger implements Messenger { } } + @Override @NotNull public Set getIncomingChannelRegistrations(@NotNull String channel) { channel = validateAndCorrectChannel(channel); @@ -340,6 +354,7 @@ public class StandardMessenger implements Messenger { } } + @Override @NotNull public Set getIncomingChannelRegistrations(@NotNull Plugin plugin, @NotNull String channel) { if (plugin == null) { @@ -366,6 +381,7 @@ public class StandardMessenger implements Messenger { } } + @Override public boolean isRegistrationValid(@NotNull PluginMessageListenerRegistration registration) { if (registration == null) { throw new IllegalArgumentException("Registration cannot be null"); @@ -382,6 +398,7 @@ public class StandardMessenger implements Messenger { } } + @Override public boolean isIncomingChannelRegistered(@NotNull Plugin plugin, @NotNull String channel) { if (plugin == null) { throw new IllegalArgumentException("Plugin cannot be null"); @@ -403,6 +420,7 @@ public class StandardMessenger implements Messenger { } } + @Override public boolean isOutgoingChannelRegistered(@NotNull Plugin plugin, @NotNull String channel) { if (plugin == null) { throw new IllegalArgumentException("Plugin cannot be null"); @@ -420,6 +438,7 @@ public class StandardMessenger implements Messenger { } } + @Override public void dispatchIncomingMessage(@NotNull Player source, @NotNull String channel, @NotNull byte[] message) { if (source == null) { throw new IllegalArgumentException("Player source cannot be null"); diff --git a/api/src/main/java/org/bukkit/potion/Potion.java b/api/src/main/java/org/bukkit/potion/Potion.java index a57f70ec6..3c400a046 100644 --- a/api/src/main/java/org/bukkit/potion/Potion.java +++ b/api/src/main/java/org/bukkit/potion/Potion.java @@ -1,7 +1,6 @@ package org.bukkit.potion; import java.util.Collection; - import org.apache.commons.lang.Validate; import org.bukkit.Material; import org.bukkit.entity.LivingEntity; @@ -27,7 +26,6 @@ public class Potion { * water bottle. * * @param type The potion type - * @see #Potion(int) */ public Potion(@NotNull PotionType type) { Validate.notNull(type, "Null PotionType"); @@ -78,15 +76,6 @@ public class Potion { this.extended = extended; } - /** - * @param name Unused, always uses {@link PotionType#WATER} - * @deprecated - */ - @Deprecated - public Potion(int name) { - this(PotionType.WATER); - } - /** * Chain this to the constructor to make the potion a splash potion. * diff --git a/api/src/main/java/org/bukkit/potion/PotionBrewer.java b/api/src/main/java/org/bukkit/potion/PotionBrewer.java index 254bd6f3e..d21f407cc 100644 --- a/api/src/main/java/org/bukkit/potion/PotionBrewer.java +++ b/api/src/main/java/org/bukkit/potion/PotionBrewer.java @@ -1,8 +1,7 @@ package org.bukkit.potion; -import org.jetbrains.annotations.NotNull; - import java.util.Collection; +import org.jetbrains.annotations.NotNull; /** * Represents a brewer that can create {@link PotionEffect}s. diff --git a/api/src/main/java/org/bukkit/potion/PotionEffect.java b/api/src/main/java/org/bukkit/potion/PotionEffect.java index 4125a024e..0193e0754 100644 --- a/api/src/main/java/org/bukkit/potion/PotionEffect.java +++ b/api/src/main/java/org/bukkit/potion/PotionEffect.java @@ -1,15 +1,13 @@ package org.bukkit.potion; +import com.google.common.collect.ImmutableMap; import java.util.Map; import java.util.NoSuchElementException; - import org.apache.commons.lang.Validate; import org.bukkit.Color; import org.bukkit.configuration.serialization.ConfigurationSerializable; import org.bukkit.configuration.serialization.SerializableAs; import org.bukkit.entity.LivingEntity; - -import com.google.common.collect.ImmutableMap; import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -156,6 +154,7 @@ public class PotionEffect implements ConfigurationSerializable { return def; } + @Override @NotNull public Map serialize() { return ImmutableMap.builder() diff --git a/api/src/main/java/org/bukkit/potion/PotionEffectType.java b/api/src/main/java/org/bukkit/potion/PotionEffectType.java index 059c77d3c..b5790aaac 100644 --- a/api/src/main/java/org/bukkit/potion/PotionEffectType.java +++ b/api/src/main/java/org/bukkit/potion/PotionEffectType.java @@ -3,7 +3,6 @@ package org.bukkit.potion; import java.util.Arrays; import java.util.HashMap; import java.util.Map; - import org.apache.commons.lang.Validate; import org.bukkit.Color; import org.jetbrains.annotations.NotNull; @@ -165,6 +164,16 @@ public abstract class PotionEffectType { */ public static final PotionEffectType DOLPHINS_GRACE = new PotionEffectTypeWrapper(30); + /** + * oof. + */ + public static final PotionEffectType BAD_OMEN = new PotionEffectTypeWrapper(31); + + /** + * \o/. + */ + public static final PotionEffectType HERO_OF_THE_VILLAGE = new PotionEffectTypeWrapper(32); + private final int id; protected PotionEffectType(int id) { @@ -189,7 +198,9 @@ public abstract class PotionEffectType { * Returns the duration modifier applied to effects of this type. * * @return duration modifier + * @deprecated unused, always 1.0 */ + @Deprecated public abstract double getDurationModifier(); /** @@ -251,7 +262,7 @@ public abstract class PotionEffectType { return "PotionEffectType[" + id + ", " + getName() + "]"; } - private static final PotionEffectType[] byId = new PotionEffectType[31]; + private static final PotionEffectType[] byId = new PotionEffectType[33]; private static final Map byName = new HashMap(); // will break on updates. private static boolean acceptingNew = true; diff --git a/api/src/main/java/org/bukkit/potion/PotionType.java b/api/src/main/java/org/bukkit/potion/PotionType.java index e83e4b4fd..af7dea669 100644 --- a/api/src/main/java/org/bukkit/potion/PotionType.java +++ b/api/src/main/java/org/bukkit/potion/PotionType.java @@ -1,6 +1,5 @@ package org.bukkit.potion; -import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.Nullable; /** @@ -54,7 +53,7 @@ public enum PotionType { * Checks if the potion type has an upgraded state. * This refers to whether or not the potion type can be Tier 2, * such as Potion of Fire Resistance II. - * + * * @return true if the potion type can be upgraded; */ public boolean isUpgradeable() { @@ -64,41 +63,20 @@ public enum PotionType { /** * Checks if the potion type has an extended state. * This refers to the extended duration potions - * + * * @return true if the potion type can be extended */ public boolean isExtendable() { return extendable; } - /** - * @return Damage value associated with this PotionType, broken - * @deprecated Non-functional - */ - @Deprecated - public int getDamageValue() { - return this.ordinal(); - } - public int getMaxLevel() { return upgradeable ? 2 : 1; } /** - * @param damage Damage value associated with a PotionType - * @return PotionType for given damage value, broken - * @deprecated Non-functional - */ - @Deprecated - @Nullable - @Contract("_ -> null") - public static PotionType getByDamageValue(int damage) { - return null; - } - - /** - * @param effectType EffectType - * @return Associated PotionType + * @param effectType the effect to get by + * @return the matching potion type * @deprecated Misleading */ @Deprecated diff --git a/api/src/main/java/org/bukkit/scheduler/BukkitScheduler.java b/api/src/main/java/org/bukkit/scheduler/BukkitScheduler.java index acbd23687..ac140fc2c 100644 --- a/api/src/main/java/org/bukkit/scheduler/BukkitScheduler.java +++ b/api/src/main/java/org/bukkit/scheduler/BukkitScheduler.java @@ -1,12 +1,11 @@ package org.bukkit.scheduler; -import org.bukkit.plugin.Plugin; -import org.jetbrains.annotations.NotNull; - +import java.util.List; import java.util.concurrent.Callable; import java.util.concurrent.Future; -import java.util.List; import java.util.function.Consumer; +import org.bukkit.plugin.Plugin; +import org.jetbrains.annotations.NotNull; public interface BukkitScheduler { diff --git a/api/src/main/java/org/bukkit/scoreboard/Criterias.java b/api/src/main/java/org/bukkit/scoreboard/Criterias.java index cd81c87f8..413430928 100644 --- a/api/src/main/java/org/bukkit/scoreboard/Criterias.java +++ b/api/src/main/java/org/bukkit/scoreboard/Criterias.java @@ -3,18 +3,12 @@ package org.bukkit.scoreboard; /** * Criteria names which trigger an objective to be modified by actions in-game */ -public class Criterias { - public static final String HEALTH; - public static final String PLAYER_KILLS; - public static final String TOTAL_KILLS; - public static final String DEATHS; +public final class Criterias { - static { - HEALTH="health"; - PLAYER_KILLS="playerKillCount"; - TOTAL_KILLS="totalKillCount"; - DEATHS="deathCount"; - } + public static final String HEALTH = "health"; + public static final String PLAYER_KILLS = "playerKillCount"; + public static final String TOTAL_KILLS = "totalKillCount"; + public static final String DEATHS = "deathCount"; private Criterias() {} } diff --git a/api/src/main/java/org/bukkit/scoreboard/Scoreboard.java b/api/src/main/java/org/bukkit/scoreboard/Scoreboard.java index fa35d7d59..aeab2425e 100644 --- a/api/src/main/java/org/bukkit/scoreboard/Scoreboard.java +++ b/api/src/main/java/org/bukkit/scoreboard/Scoreboard.java @@ -1,7 +1,6 @@ package org.bukkit.scoreboard; import java.util.Set; - import org.bukkit.OfflinePlayer; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/api/src/main/java/org/bukkit/scoreboard/ScoreboardManager.java b/api/src/main/java/org/bukkit/scoreboard/ScoreboardManager.java index 255977c2f..3c0740797 100644 --- a/api/src/main/java/org/bukkit/scoreboard/ScoreboardManager.java +++ b/api/src/main/java/org/bukkit/scoreboard/ScoreboardManager.java @@ -1,8 +1,7 @@ package org.bukkit.scoreboard; -import org.jetbrains.annotations.NotNull; - import java.lang.ref.WeakReference; +import org.jetbrains.annotations.NotNull; /** * Manager of Scoreboards diff --git a/api/src/main/java/org/bukkit/scoreboard/Team.java b/api/src/main/java/org/bukkit/scoreboard/Team.java index f75dbe846..dc20daae9 100644 --- a/api/src/main/java/org/bukkit/scoreboard/Team.java +++ b/api/src/main/java/org/bukkit/scoreboard/Team.java @@ -1,7 +1,6 @@ package org.bukkit.scoreboard; import java.util.Set; - import org.bukkit.ChatColor; import org.bukkit.OfflinePlayer; import org.bukkit.potion.PotionEffectType; diff --git a/api/src/main/java/org/bukkit/util/BlockIterator.java b/api/src/main/java/org/bukkit/util/BlockIterator.java index 8e6887ae7..8a377e141 100644 --- a/api/src/main/java/org/bukkit/util/BlockIterator.java +++ b/api/src/main/java/org/bukkit/util/BlockIterator.java @@ -1,17 +1,15 @@ package org.bukkit.util; import static org.bukkit.util.NumberConversions.*; - -import org.bukkit.World; +import java.util.Iterator; +import java.util.NoSuchElementException; import org.bukkit.Location; +import org.bukkit.World; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.entity.LivingEntity; import org.jetbrains.annotations.NotNull; -import java.util.Iterator; -import java.util.NoSuchElementException; - /** * This class performs ray tracing and iterates along blocks on a line */ @@ -295,6 +293,7 @@ public class BlockIterator implements Iterator { * Returns true if the iteration has more elements */ + @Override public boolean hasNext() { scan(); return currentBlock != -1; @@ -305,6 +304,7 @@ public class BlockIterator implements Iterator { * * @return the next Block in the trace */ + @Override @NotNull public Block next() throws NoSuchElementException { scan(); @@ -315,6 +315,7 @@ public class BlockIterator implements Iterator { } } + @Override public void remove() { throw new UnsupportedOperationException("[BlockIterator] doesn't support block removal"); } diff --git a/api/src/main/java/org/bukkit/util/ChatPaginator.java b/api/src/main/java/org/bukkit/util/ChatPaginator.java index 04358f17e..1f5102118 100644 --- a/api/src/main/java/org/bukkit/util/ChatPaginator.java +++ b/api/src/main/java/org/bukkit/util/ChatPaginator.java @@ -1,12 +1,11 @@ package org.bukkit.util; -import org.bukkit.ChatColor; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - import java.util.Arrays; import java.util.LinkedList; import java.util.List; +import org.bukkit.ChatColor; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * The ChatPaginator takes a raw string of arbitrary length and breaks it down diff --git a/api/src/main/java/org/bukkit/util/FileUtil.java b/api/src/main/java/org/bukkit/util/FileUtil.java index af75ce2e7..6e2352a30 100644 --- a/api/src/main/java/org/bukkit/util/FileUtil.java +++ b/api/src/main/java/org/bukkit/util/FileUtil.java @@ -1,12 +1,11 @@ package org.bukkit.util; -import org.jetbrains.annotations.NotNull; - -import java.nio.channels.FileChannel; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; +import java.nio.channels.FileChannel; +import org.jetbrains.annotations.NotNull; /** * Class containing file utilities diff --git a/api/src/main/java/org/bukkit/util/RayTraceResult.java b/api/src/main/java/org/bukkit/util/RayTraceResult.java index 054630191..19c52a2a6 100644 --- a/api/src/main/java/org/bukkit/util/RayTraceResult.java +++ b/api/src/main/java/org/bukkit/util/RayTraceResult.java @@ -1,7 +1,6 @@ package org.bukkit.util; import java.util.Objects; - import org.apache.commons.lang.Validate; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; diff --git a/api/src/main/java/org/bukkit/util/Vector.java b/api/src/main/java/org/bukkit/util/Vector.java index b218a1dc8..143579bb3 100644 --- a/api/src/main/java/org/bukkit/util/Vector.java +++ b/api/src/main/java/org/bukkit/util/Vector.java @@ -1,6 +1,7 @@ package org.bukkit.util; import com.google.common.base.Preconditions; +import com.google.common.primitives.Doubles; import java.util.LinkedHashMap; import java.util.Map; import java.util.Random; @@ -202,7 +203,7 @@ public class Vector implements Cloneable, ConfigurationSerializable { * @return angle in radians */ public float angle(@NotNull Vector other) { - double dot = dot(other) / (length() * other.length()); + double dot = Doubles.constrainToRange(dot(other) / (length() * other.length()), -1.0, 1.0); return (float) Math.acos(dot); } @@ -846,6 +847,7 @@ public class Vector implements Cloneable, ConfigurationSerializable { return new Vector(random.nextDouble(), random.nextDouble(), random.nextDouble()); } + @Override @NotNull public Map serialize() { Map result = new LinkedHashMap(); diff --git a/api/src/main/java/org/bukkit/util/io/BukkitObjectInputStream.java b/api/src/main/java/org/bukkit/util/io/BukkitObjectInputStream.java index 13725531f..d05aaaa46 100644 --- a/api/src/main/java/org/bukkit/util/io/BukkitObjectInputStream.java +++ b/api/src/main/java/org/bukkit/util/io/BukkitObjectInputStream.java @@ -3,7 +3,6 @@ package org.bukkit.util.io; import java.io.IOException; import java.io.InputStream; import java.io.ObjectInputStream; - import org.bukkit.configuration.serialization.ConfigurationSerializable; import org.bukkit.configuration.serialization.ConfigurationSerialization; diff --git a/api/src/main/java/org/bukkit/util/io/BukkitObjectOutputStream.java b/api/src/main/java/org/bukkit/util/io/BukkitObjectOutputStream.java index 845285025..0b073f26d 100644 --- a/api/src/main/java/org/bukkit/util/io/BukkitObjectOutputStream.java +++ b/api/src/main/java/org/bukkit/util/io/BukkitObjectOutputStream.java @@ -4,7 +4,6 @@ import java.io.IOException; import java.io.ObjectOutputStream; import java.io.OutputStream; import java.io.Serializable; - import org.bukkit.configuration.serialization.ConfigurationSerializable; /** diff --git a/api/src/main/java/org/bukkit/util/io/Wrapper.java b/api/src/main/java/org/bukkit/util/io/Wrapper.java index 51dd951b0..c3496dc8b 100644 --- a/api/src/main/java/org/bukkit/util/io/Wrapper.java +++ b/api/src/main/java/org/bukkit/util/io/Wrapper.java @@ -1,15 +1,13 @@ package org.bukkit.util.io; +import com.google.common.collect.ImmutableMap; import java.io.Serializable; import java.util.Map; - import org.bukkit.configuration.serialization.ConfigurationSerializable; import org.bukkit.configuration.serialization.ConfigurationSerialization; - -import com.google.common.collect.ImmutableMap; import org.jetbrains.annotations.NotNull; -class Wrapper & Serializable> implements Serializable { +final class Wrapper & Serializable> implements Serializable { private static final long serialVersionUID = -986209235411767547L; final T map; diff --git a/api/src/main/java/org/bukkit/util/noise/NoiseGenerator.java b/api/src/main/java/org/bukkit/util/noise/NoiseGenerator.java index 72c92f33c..aa2d70414 100644 --- a/api/src/main/java/org/bukkit/util/noise/NoiseGenerator.java +++ b/api/src/main/java/org/bukkit/util/noise/NoiseGenerator.java @@ -4,7 +4,7 @@ package org.bukkit.util.noise; * Base class for all noise generators */ public abstract class NoiseGenerator { - protected final int perm[] = new int[512]; + protected final int[] perm= new int[512]; protected double offsetX; protected double offsetY; protected double offsetZ; diff --git a/api/src/main/java/org/bukkit/util/noise/PerlinNoiseGenerator.java b/api/src/main/java/org/bukkit/util/noise/PerlinNoiseGenerator.java index f481286b8..520b65f9e 100644 --- a/api/src/main/java/org/bukkit/util/noise/PerlinNoiseGenerator.java +++ b/api/src/main/java/org/bukkit/util/noise/PerlinNoiseGenerator.java @@ -11,13 +11,13 @@ import org.jetbrains.annotations.NotNull; * different results */ public class PerlinNoiseGenerator extends NoiseGenerator { - protected static final int grad3[][] = {{1, 1, 0}, {-1, 1, 0}, {1, -1, 0}, {-1, -1, 0}, + protected static final int[][] grad3 = {{1, 1, 0}, {-1, 1, 0}, {1, -1, 0}, {-1, -1, 0}, {1, 0, 1}, {-1, 0, 1}, {1, 0, -1}, {-1, 0, -1}, {0, 1, 1}, {0, -1, 1}, {0, 1, -1}, {0, -1, -1}}; private static final PerlinNoiseGenerator instance = new PerlinNoiseGenerator(); protected PerlinNoiseGenerator() { - int p[] = {151, 160, 137, 91, 90, 15, 131, 13, 201, + int[] p = {151, 160, 137, 91, 90, 15, 131, 13, 201, 95, 96, 53, 194, 233, 7, 225, 140, 36, 103, 30, 69, 142, 8, 99, 37, 240, 21, 10, 23, 190, 6, 148, 247, 120, 234, 75, 0, 26, 197, 62, 94, 252, 219, 203, 117, 35, 11, 32, 57, 177, 33, 88, 237, 149, 56, diff --git a/api/src/main/java/org/bukkit/util/noise/SimplexNoiseGenerator.java b/api/src/main/java/org/bukkit/util/noise/SimplexNoiseGenerator.java index 850604a4d..afe8fa954 100644 --- a/api/src/main/java/org/bukkit/util/noise/SimplexNoiseGenerator.java +++ b/api/src/main/java/org/bukkit/util/noise/SimplexNoiseGenerator.java @@ -25,7 +25,7 @@ public class SimplexNoiseGenerator extends PerlinNoiseGenerator { protected static final double G42 = G4 * 2.0; protected static final double G43 = G4 * 3.0; protected static final double G44 = G4 * 4.0 - 1.0; - protected static final int grad4[][] = {{0, 1, 1, 1}, {0, 1, 1, -1}, {0, 1, -1, 1}, {0, 1, -1, -1}, + protected static final int[][] grad4 = {{0, 1, 1, 1}, {0, 1, 1, -1}, {0, 1, -1, 1}, {0, 1, -1, -1}, {0, -1, 1, 1}, {0, -1, 1, -1}, {0, -1, -1, 1}, {0, -1, -1, -1}, {1, 0, 1, 1}, {1, 0, 1, -1}, {1, 0, -1, 1}, {1, 0, -1, -1}, {-1, 0, 1, 1}, {-1, 0, 1, -1}, {-1, 0, -1, 1}, {-1, 0, -1, -1}, @@ -33,7 +33,7 @@ public class SimplexNoiseGenerator extends PerlinNoiseGenerator { {-1, 1, 0, 1}, {-1, 1, 0, -1}, {-1, -1, 0, 1}, {-1, -1, 0, -1}, {1, 1, 1, 0}, {1, 1, -1, 0}, {1, -1, 1, 0}, {1, -1, -1, 0}, {-1, 1, 1, 0}, {-1, 1, -1, 0}, {-1, -1, 1, 0}, {-1, -1, -1, 0}}; - protected static final int simplex[][] = { + protected static final int[][] simplex = { {0, 1, 2, 3}, {0, 1, 3, 2}, {0, 0, 0, 0}, {0, 2, 3, 1}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {1, 2, 3, 0}, {0, 2, 1, 3}, {0, 0, 0, 0}, {0, 3, 1, 2}, {0, 3, 2, 1}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {1, 3, 2, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0},