From 2d955d1ff741356b48917b458736448e7f833c6f Mon Sep 17 00:00:00 2001 From: Daniel Naylor Date: Thu, 11 Mar 2021 22:22:27 +0000 Subject: [PATCH] Remove "get" prefixes from API methods Co-authored-by: Riley Park --- SpongeAPI | 2 +- .../spongepowered/common/launch/Launch.java | 6 +- .../common/AbstractResourceKeyed.java | 2 +- .../spongepowered/common/SpongeBootstrap.java | 2 +- .../spongepowered/common/SpongeCommon.java | 14 +- .../org/spongepowered/common/SpongeGame.java | 43 ++-- .../spongepowered/common/SpongeLifecycle.java | 56 ++--- .../common/SpongeMinecraftVersion.java | 4 +- .../spongepowered/common/SpongePlatform.java | 22 +- .../spongepowered/common/SpongeServer.java | 7 +- .../advancement/SpongeAdvancementBuilder.java | 10 +- .../advancement/SpongeCriterionTrigger.java | 6 +- .../advancement/SpongeDisplayInfoBuilder.java | 8 +- .../advancement/SpongeFilteredTrigger.java | 4 +- .../SpongeFilteredTriggerBuilder.java | 4 +- .../common/advancement/SpongeTreeLayout.java | 24 +- .../advancement/SpongeTriggerBuilder.java | 6 +- .../criterion/AbstractCriterionBuilder.java | 4 +- .../criterion/SpongeAndCriterionProgress.java | 6 +- .../criterion/SpongeEmptyCriterion.java | 4 +- .../criterion/SpongeOperatorCriterion.java | 14 +- .../SpongeOperatorCriterionProgress.java | 6 +- .../criterion/SpongeOrCriterionProgress.java | 10 +- .../criterion/SpongeScoreCriterion.java | 8 +- .../SpongeScoreCriterionBuilder.java | 2 +- .../SpongeScoreCriterionProgress.java | 30 +-- .../adventure/AdventureRegistryImpl.java | 20 +- .../common/adventure/SpongeCallback.java | 10 +- .../adventure/SpongeResolveOperation.java | 2 +- .../common/asset/SpongeAsset.java | 4 +- .../common/asset/SpongeAssetManager.java | 6 +- .../common/ban/SpongeBanBuilder.java | 14 +- .../common/ban/SpongeBanType.java | 2 +- .../common/block/SpongeBlockSnapshot.java | 22 +- .../block/SpongeBlockSnapshotBuilder.java | 28 +-- .../common/block/SpongeBlockStateBuilder.java | 3 +- .../entity/SpongeBlockEntityArchetype.java | 18 +- .../SpongeBlockEntityArchetypeBuilder.java | 12 +- .../explosives/FusedExplosiveBridge.java | 16 +- .../common/client/SpongeClient.java | 2 +- .../command/SpongeParameterizedCommand.java | 18 +- .../SpongeParameterizedCommandBuilder.java | 28 +-- .../SpongeImmutableArgumentReader.java | 41 ++- .../brigadier/SpongeParameterTranslator.java | 36 +-- .../command/brigadier/SpongeStringReader.java | 45 +++- .../argument/AbstractArgumentParser.java | 6 +- .../argument/CustomArgumentParser.java | 8 +- .../ResourceKeyedArgumentValueParser.java | 2 +- ...esourceKeyedZeroAdvanceValueParameter.java | 4 +- .../argument/StandardArgumentParser.java | 2 +- .../StandardCatalogedArgumentParser.java | 2 +- .../context/SpongeCommandContext.java | 37 ++- .../context/SpongeCommandContextBuilder.java | 42 ++-- ...pongeCommandContextBuilderTransaction.java | 7 +- .../dispatcher/SpongeCommandDispatcher.java | 2 +- .../dispatcher/SpongeNodePermissionCache.java | 4 +- .../tree/SpongeArgumentCommandNode.java | 4 +- .../tree/SpongeCommandExecutorWrapper.java | 4 +- .../manager/SpongeCommandCauseFactory.java | 20 +- .../command/manager/SpongeCommandManager.java | 58 ++--- .../command/manager/SpongeCommandMapping.java | 8 +- .../parameter/SpongeDefaultValueParser.java | 6 +- .../command/parameter/SpongeParameterKey.java | 4 +- .../parameter/SpongeParameterValue.java | 28 +-- .../SpongeParameterValueBuilder.java | 20 +- .../command/parameter/flag/SpongeFlag.java | 8 +- .../builder/SpongeDynamicChoicesBuilder.java | 8 +- .../managed/builder/SpongeLiteralBuilder.java | 4 +- .../builder/SpongeNumberRangeBuilder.java | 4 +- .../SpongeRegistryEntryParameterBuilder.java | 6 +- .../builder/SpongeStaticChoicesBuilder.java | 4 +- .../builder/SpongeTextParameterBuilder.java | 8 +- .../SpongeVariableValueParametersFactory.java | 6 +- .../SpongeBigDecimalValueParameter.java | 2 +- .../SpongeBigIntegerValueParameter.java | 2 +- .../SpongeCatalogedElementValueParameter.java | 8 +- .../standard/SpongeChoicesValueParameter.java | 2 +- .../standard/SpongeColorValueParameter.java | 4 +- .../SpongeDataContainerValueParameter.java | 2 +- .../SpongeDateTimeValueParameter.java | 2 +- .../SpongeDurationValueParameter.java | 2 +- .../SpongeGameProfileValueParameter.java | 6 +- .../SpongeIPAddressValueParameter.java | 2 +- .../standard/SpongeLiteralValueParameter.java | 4 +- .../standard/SpongeNoneValueParameter.java | 6 +- .../SpongePluginContainerValueParameter.java | 6 +- .../SpongeServerLocationValueParameter.java | 22 +- .../SpongeTargetBlockValueParameter.java | 6 +- .../SpongeTargetEntityValueParameter.java | 6 +- .../standard/SpongeTextValueParameter.java | 4 +- .../standard/SpongeUserValueParameter.java | 14 +- .../parameter/multi/SpongeMultiParameter.java | 2 +- .../subcommand/SpongeSubcommandParameter.java | 4 +- .../SpongeSubcommandParameterBuilder.java | 4 +- .../registrar/BrigadierCommandRegistrar.java | 16 +- .../SpongeCommandRegistrarTypes.java | 2 +- .../SpongeParameterizedCommandRegistrar.java | 6 +- .../registrar/SpongeRawCommandRegistrar.java | 4 +- .../key/SpongeEntityClientCompletionKey.java | 2 +- .../command/result/SpongeCommandResult.java | 4 +- .../result/SpongeCommandResultBuilder.java | 2 +- .../sponge/CommandAliasesParameter.java | 9 +- .../FilteredPluginContainerParameter.java | 4 +- .../common/command/sponge/SpongeCommand.java | 194 +++++++------- .../common/config/PluginConfigManager.java | 8 +- .../common/config/PluginConfigRoot.java | 12 +- .../common/config/SpongeGameConfigs.java | 8 +- .../CustomDataRegistrationCategory.java | 2 +- .../data/ByteToBooleanContentUpdater.java | 13 +- .../common/data/DataUpdaterDelegate.java | 4 +- .../spongepowered/common/data/DataUtil.java | 8 +- .../common/data/MemoryDataContainer.java | 4 +- .../common/data/MemoryDataView.java | 74 +++--- .../common/data/SpongeDataManager.java | 36 +-- .../common/data/SpongeDataRegistration.java | 8 +- .../data/SpongeDataRegistrationBuilder.java | 6 +- .../common/data/SpongeKeyValueMatcher.java | 14 +- .../data/SpongeKeyValueMatcherBuilder.java | 8 +- .../item/SpongeFireworkEffectDataBuilder.java | 2 +- .../SpongeItemStackSnapshotDataBuilder.java | 2 +- .../meta/SpongePatternLayerBuilder.java | 8 +- .../datasync/entity/EntityBabyConverter.java | 2 +- .../entity/EntityCustomNameConverter.java | 2 +- .../EntityCustomNameVisibleConverter.java | 2 +- .../datasync/entity/EntityFlagsConverter.java | 10 +- .../entity/EntityNoGravityConverter.java | 2 +- .../entity/EntitySilentConverter.java | 2 +- .../LivingEntityArrowCountConverter.java | 2 +- .../entity/MobEntityAIFlagsConverter.java | 2 +- .../common/data/holder/SpongeDataHolder.java | 10 +- .../holder/SpongeImmutableDataHolder.java | 8 +- .../holder/SpongeLocationBaseDataHolder.java | 8 +- .../data/holder/SpongeMutableDataHolder.java | 22 +- .../common/data/key/KeyBasedDataListener.java | 2 +- .../common/data/key/SpongeKey.java | 10 +- .../MutableDataManipulatorFactory.java | 2 +- .../manipulator/SpongeDataManipulator.java | 2 +- .../common/data/meta/SpongePatternLayer.java | 12 +- .../data/nbt/validation/ValidationTypes.java | 2 +- .../persistence/ConfigurateTranslator.java | 8 +- .../data/persistence/DataSerializers.java | 48 ++-- .../data/persistence/JsonDataFormat.java | 2 +- .../data/persistence/NBTTranslator.java | 4 +- .../datastore/DataStoreRegistry.java | 6 +- .../datastore/SpongeDataStore.java | 6 +- .../datastore/SpongeDataStoreBuilder.java | 38 +-- .../datastore/VanillaDataStore.java | 6 +- .../schematic/SchematicUpdater1_to_2.java | 4 +- .../data/provider/AbstractDataProvider.java | 2 +- .../data/provider/CustomDataProvider.java | 8 +- .../provider/DataProviderRegistrator.java | 15 +- .../data/provider/DataProviderRegistry.java | 6 +- .../data/provider/DelegateDataProvider.java | 6 +- .../data/provider/EmptyDataProvider.java | 2 +- .../GenericImmutableDataProviderBase.java | 4 +- .../GenericMutableDataProviderBase.java | 8 +- .../data/provider/ImmutableDataProvider.java | 2 +- .../block/entity/AbstractFurnaceData.java | 6 +- .../block/entity/BrewingStandData.java | 2 +- .../provider/block/entity/EndGatewayData.java | 4 +- .../provider/block/entity/HopperData.java | 2 +- .../provider/block/entity/MobSpawnerData.java | 18 +- .../data/provider/block/entity/SignData.java | 4 +- .../block/location/ServerLocationData.java | 28 +-- .../provider/block/state/NoteBlockData.java | 4 +- .../provider/block/state/TerracottaData.java | 6 +- .../data/provider/entity/AgeableData.java | 4 +- .../provider/entity/AreaEffectCloudData.java | 10 +- .../data/provider/entity/ArmorStandData.java | 2 +- .../data/provider/entity/ArrowData.java | 4 +- .../common/data/provider/entity/BedData.java | 2 +- .../common/data/provider/entity/CatData.java | 4 +- .../data/provider/entity/ChickenData.java | 2 +- .../data/provider/entity/EndermiteData.java | 2 +- .../data/provider/entity/EntityData.java | 6 +- .../data/provider/entity/EyeOfEnderData.java | 2 +- .../provider/entity/FallingBlockData.java | 2 +- .../provider/entity/FireworkRocketData.java | 2 +- .../provider/entity/FusedExplosiveData.java | 4 +- .../data/provider/entity/GrieferData.java | 4 +- .../data/provider/entity/HorseData.java | 8 +- .../provider/entity/IdentifiableData.java | 16 +- .../common/data/provider/entity/ItemData.java | 4 +- .../data/provider/entity/ItemFrameData.java | 2 +- .../provider/entity/LightningBoltData.java | 4 +- .../data/provider/entity/PandaData.java | 6 +- .../data/provider/entity/ParrotData.java | 4 +- .../data/provider/entity/RabbitData.java | 4 +- .../data/provider/entity/RavagerData.java | 6 +- .../provider/entity/ServerPlayerData.java | 4 +- .../data/provider/entity/TraderLlamaData.java | 4 +- .../common/data/provider/entity/VexData.java | 2 +- .../provider/inventory/InventoryData.java | 2 +- .../item/stack/BookPagesItemStackData.java | 6 +- .../provider/item/stack/CompassItemData.java | 2 +- .../stack/IDyeableArmorItemStackData.java | 2 +- .../item/stack/MapInfoItemStackData.java | 2 +- .../item/stack/PotionItemStackData.java | 2 +- .../item/stack/ShieldItemStackData.java | 10 +- .../common/data/provider/map/MapInfoData.java | 17 +- .../common/data/type/SpongeNotePitch.java | 2 +- .../common/data/type/SpongeSkinPart.java | 2 +- .../value/ImmutableSpongeCollectionValue.java | 2 +- .../data/value/ImmutableSpongeListValue.java | 10 +- .../data/value/ImmutableSpongeMapValue.java | 10 +- .../data/value/ImmutableSpongeSetValue.java | 10 +- .../data/value/ImmutableSpongeValue.java | 4 +- ...mmutableSpongeWeightedCollectionValue.java | 12 +- .../value/MutableSpongeCollectionValue.java | 2 +- .../data/value/MutableSpongeListValue.java | 8 +- .../data/value/MutableSpongeMapValue.java | 8 +- .../data/value/MutableSpongeSetValue.java | 8 +- .../common/data/value/MutableSpongeValue.java | 4 +- .../MutableSpongeWeightedCollectionValue.java | 10 +- .../common/data/value/SpongeValue.java | 2 +- .../data/value/ValueConstructorFactory.java | 4 +- .../common/datapack/DataPackSerializer.java | 4 +- .../datapack/SpongeDataPackManager.java | 4 +- .../common/datapack/SpongeDataPackType.java | 12 +- .../recipe/RecipeDataPackSerializer.java | 2 +- .../particle/NumericalParticleType.java | 4 +- .../effect/particle/SpongeParticleEffect.java | 8 +- .../particle/SpongeParticleEffectBuilder.java | 15 +- .../effect/particle/SpongeParticleHelper.java | 30 +-- .../effect/particle/SpongeParticleOption.java | 2 +- .../effect/potion/SpongePotionBuilder.java | 8 +- .../common/effect/record/SpongeMusicDisc.java | 2 +- .../common/entity/EntityUtil.java | 4 +- .../common/entity/SpongeEntityArchetype.java | 28 +-- .../entity/SpongeEntityArchetypeBuilder.java | 8 +- .../common/entity/SpongeEntitySnapshot.java | 38 +-- .../entity/SpongeEntitySnapshotBuilder.java | 46 ++-- .../ai/SpongeWatchClosestAIBuilder.java | 6 +- .../common/entity/ai/goal/SpongeGoalType.java | 2 +- .../goal/builtin/SpongeSwimGoalBuilder.java | 2 +- .../SpongeAttackLivingGoalBuilder.java | 2 +- .../SpongeAvoidLivingGoalBuilder.java | 8 +- .../SpongeRandomWalkingGoalBuilder.java | 4 +- ...geRangedAttackAgainstAgentGoalBuilder.java | 6 +- .../SpongeRunAroundLikeCrazyAIBuilder.java | 2 +- ...indNearestAttackableTargetGoalBuilder.java | 6 +- .../entity/living/human/HumanEntity.java | 5 +- .../common/entity/player/SpongeUser.java | 116 ++++----- .../entity/player/tab/SpongeTabList.java | 25 +- .../entity/player/tab/SpongeTabListEntry.java | 12 +- .../player/tab/TabListEntryBuilder.java | 10 +- .../projectile/DispenserSourceLogic.java | 2 +- .../entity/projectile/ProjectileUtil.java | 42 ++-- .../projectile/SimpleEntityLaunchLogic.java | 2 +- .../event/SpongeCommonEventFactory.java | 134 +++++----- .../common/event/SpongeEventContextKey.java | 4 +- .../common/event/SpongeEventManager.java | 6 +- .../event/cause/entity/SpongeSpawnTypes.java | 2 +- .../entity/damage/DamageEventHandler.java | 16 +- .../SpongeBlockDamageSourceBuilder.java | 2 +- .../damage/SpongeCommonDamageSource.java | 2 +- .../SpongeCommonEntityDamageSource.java | 4 +- ...pongeCommonIndirectEntityDamageSource.java | 4 +- .../cause/entity/damage/SpongeDamageType.java | 2 +- .../SpongeEntityDamageSourceBuilder.java | 4 +- .../SpongeFallingBlockDamgeSourceBuilder.java | 4 +- ...ongeIndirectEntityDamageSourceBuilder.java | 6 +- .../common/event/filter/FilterGenerator.java | 4 +- .../delegate/CauseFilterSourceDelegate.java | 2 +- .../inventory/InventoryEventFactory.java | 106 ++++---- .../event/inventory/UpdateAnvilEventCost.java | 12 +- .../lifecycle/AbstractLifecycleEvent.java | 6 +- .../AbstractProvideServiceEventImpl.java | 2 +- .../AbstractRegisterRegistryEvent.java | 6 +- .../AbstractRegisterRegistryValueEvent.java | 6 +- .../lifecycle/RegisterBuilderEventImpl.java | 2 +- .../lifecycle/RegisterFactoryEventImpl.java | 2 +- .../common/event/tracking/IPhaseState.java | 4 +- .../common/event/tracking/PhasePrinter.java | 6 +- .../event/tracking/PhaseStateProxy.java | 2 +- .../common/event/tracking/PhaseTracker.java | 10 +- .../event/tracking/SpongeCauseStackFrame.java | 8 +- .../common/event/tracking/TrackingUtil.java | 12 +- .../transaction/AddBlockEventTransaction.java | 2 +- .../context/transaction/AddTileEntity.java | 2 +- .../BlockEventBasedTransaction.java | 6 +- .../context/transaction/ChangeBlock.java | 6 +- .../EntityPerformingDropsTransaction.java | 2 +- .../transaction/NeighborNotification.java | 3 +- .../PrepareBlockDropsTransaction.java | 2 +- .../context/transaction/RemoveTileEntity.java | 2 +- .../transaction/ReplaceTileEntity.java | 2 +- .../transaction/SpawnEntityTransaction.java | 2 +- .../TransactionalCaptureSupplier.java | 4 +- .../type/BlockTransactionType.java | 12 +- .../transaction/type/TransactionTypes.java | 2 +- .../phase/block/GrowablePhaseContext.java | 4 +- .../tracking/phase/general/CommandState.java | 6 +- .../phase/general/ExplosionState.java | 2 +- .../phase/packet/PacketPhaseUtil.java | 10 +- .../tracking/phase/packet/PacketState.java | 10 +- .../drag/MiddleDragInventoryStopState.java | 2 +- .../drag/PrimaryDragInventoryStopState.java | 2 +- .../drag/SecondaryDragInventoryStopState.java | 2 +- .../inventory/BasicInventoryPacketState.java | 14 +- .../packet/inventory/CloseWindowState.java | 2 +- .../inventory/DoubleClickInventoryState.java | 2 +- .../inventory/DropItemOutsideWindowState.java | 6 +- .../inventory/DropItemWithHotkeyState.java | 12 +- .../inventory/EnchantItemPacketState.java | 20 +- .../inventory/MiddleInventoryClickState.java | 2 +- .../packet/inventory/OpenInventoryState.java | 10 +- .../inventory/PlaceRecipePacketState.java | 16 +- .../inventory/PrimaryInventoryClickState.java | 4 +- .../inventory/PrimaryInventoryShiftClick.java | 2 +- .../SecondaryInventoryClickState.java | 2 +- .../SecondaryInventoryShiftClickState.java | 2 +- .../packet/inventory/SwapHandItemsState.java | 4 +- .../SwitchHotbarNumberPressState.java | 2 +- .../inventory/SwitchHotbarScrollState.java | 8 +- .../phase/packet/player/ChatPacketState.java | 2 +- .../packet/player/PacketCommandState.java | 6 +- .../packet/player/PlaceBlockPacketState.java | 12 +- .../packet/player/ResourcePackState.java | 2 +- .../packet/player/UseItemPacketState.java | 14 +- .../phase/plugin/ListenerPhaseState.java | 2 +- .../plugin/WorldTickListenerContext.java | 2 +- .../phase/plugin/WorldTickListenerState.java | 2 +- .../phase/tick/BlockEventTickPhaseState.java | 4 +- .../tracking/phase/tick/BlockTickContext.java | 4 +- .../phase/tick/EntityTickPhaseState.java | 4 +- .../tracking/phase/tick/FluidTickContext.java | 4 +- .../phase/tick/FluidTickPhaseState.java | 2 +- .../tick/LocationBasedTickPhaseState.java | 4 +- .../phase/tick/PlayerTickPhaseState.java | 4 +- .../phase/tick/TileEntityTickPhaseState.java | 6 +- .../common/fluid/SpongeFluidStack.java | 14 +- .../common/fluid/SpongeFluidStackBuilder.java | 6 +- .../fluid/SpongeFluidStackSnapshot.java | 10 +- .../SpongeFluidStackSnapshotBuilder.java | 8 +- .../common/fluid/SpongeFluidStateBuilder.java | 4 +- .../common/hooks/DimensionHooks.java | 2 +- .../common/hooks/EventHooks.java | 4 +- .../common/hooks/GeneralHooks.java | 2 +- .../inject/provider/PluginAssetProvider.java | 2 +- .../provider/PluginConfigurationModule.java | 39 ++- .../inventory/DefaultSingleBlockCarrier.java | 25 +- .../common/inventory/EmptyInventoryImpl.java | 2 +- .../InventoryTransactionResultImpl.java | 26 +- .../inventory/SpongeBlockEntityCarrier.java | 6 +- .../inventory/SpongeLocationCarrier.java | 8 +- .../inventory/adapter/impl/AdapterLogic.java | 10 +- .../DefaultImplementedAdapterInventory.java | 2 +- .../impl/comp/CraftingInventoryAdapter.java | 4 +- .../impl/comp/EquipmentInventoryAdapter.java | 4 +- .../impl/comp/GridInventoryAdapter.java | 14 +- .../adapter/impl/comp/HotbarAdapter.java | 2 +- .../adapter/impl/comp/Inventory2DAdapter.java | 2 +- .../comp/PrimaryPlayerInventoryAdapter.java | 4 +- .../adapter/impl/slots/SlotAdapter.java | 12 +- .../inventory/custom/CustomInventory.java | 6 +- .../inventory/custom/SpongeInventoryMenu.java | 14 +- .../SpongeViewableInventoryBuilder.java | 6 +- .../lens/impl/comp/ArmorInventoryLens.java | 2 +- .../impl/comp/EquipmentInventoryLens.java | 2 +- .../minecraft/LargeChestInventoryLens.java | 2 +- .../impl/minecraft/PlayerInventoryLens.java | 4 +- .../lens/impl/slot/SlotLensCollection.java | 4 +- .../inventory/query/SpongeQueryTypes.java | 6 +- .../inventory/query/type/GridQuery.java | 2 +- .../inventory/query/type/ItemTypeQuery.java | 2 +- .../query/type/KeyValueMatcherQuery.java | 2 +- .../common/inventory/util/ContainerUtil.java | 2 +- .../common/inventory/util/InventoryUtil.java | 20 +- .../velocity/VelocityForwardingInfo.java | 2 +- ...ckSnapshotDuplicateManipulatorUpdater.java | 6 +- .../common/item/SpongeFireworkEffect.java | 12 +- .../item/SpongeFireworkEffectBuilder.java | 6 +- .../common/item/SpongeItemStackBuilder.java | 20 +- .../common/item/SpongeItemStackSnapshot.java | 30 +-- .../item/enchantment/SpongeEnchantment.java | 10 +- .../enchantment/SpongeEnchantmentBuilder.java | 4 +- .../SpongeRandomEnchantmentListBuilder.java | 2 +- .../merchant/SpongeTradeOfferBuilder.java | 16 +- .../merchant/SpongeTradeOfferGenerator.java | 6 +- .../item/recipe/SpongeRecipeRegistration.java | 4 +- .../crafting/custom/SpongeSpecialRecipe.java | 2 +- .../SpongeItemStackComparatorFactory.java | 8 +- .../common/map/SpongeMapStorage.java | 16 +- .../common/map/canvas/SpongeEmptyCanvas.java | 4 +- .../map/canvas/SpongeMapByteCanvas.java | 12 +- .../map/canvas/SpongeMapCanvasBuilder.java | 8 +- .../common/map/color/SpongeMapColor.java | 16 +- .../map/color/SpongeMapColorBuilder.java | 6 +- .../common/map/color/SpongeMapColorType.java | 2 +- .../SpongeMapDecorationBuilder.java | 8 +- .../common/network/channel/PacketSender.java | 6 +- .../common/network/channel/SpongeChannel.java | 12 +- .../SpongeChannelExceptionHandlerFactory.java | 2 +- .../channel/SpongeChannelRegistry.java | 18 +- .../channel/packet/AbstractPacketChannel.java | 14 +- .../packet/SpongeBasicPacketChannel.java | 22 +- ...SpongeFixedTransactionalPacketBinding.java | 6 +- .../channel/packet/SpongePacketBinding.java | 4 +- .../channel/packet/SpongePacketChannel.java | 48 ++-- .../SpongeTransactionalPacketBinding.java | 4 +- .../channel/raw/SpongeRawDataChannel.java | 2 +- .../raw/SpongeRawLoginDataChannel.java | 2 +- .../channel/raw/SpongeRawPlayDataChannel.java | 4 +- .../network/packet/SpongePacketHandler.java | 8 +- .../common/network/status/SpongeFavicon.java | 2 +- .../status/SpongeLegacyMinecraftVersion.java | 4 +- .../status/SpongeLegacyStatusClient.java | 6 +- .../network/status/SpongeStatusClient.java | 6 +- .../network/status/SpongeStatusResponse.java | 30 +-- .../SpongePlaceholderComponent.java | 4 +- .../SpongePlaceholderComponentBuilder.java | 4 +- .../placeholder/SpongePlaceholderContext.java | 4 +- .../SpongePlaceholderContextBuilder.java | 24 +- .../common/profile/SpongeGameProfile.java | 30 +-- .../profile/SpongeGameProfileManager.java | 28 +-- .../profile/UncachedGameProfileProvider.java | 12 +- .../common/raid/SpongeRaidWave.java | 4 +- .../common/registry/SpongeGameRegistry.java | 6 +- .../registry/SpongeRegistryLoaders.java | 18 +- .../registry/VanillaRegistryLoader.java | 4 +- .../co/aikar/timings/SpongeTimings.java | 11 +- .../co/aikar/timings/TimingHistory.java | 22 +- .../co/aikar/timings/TimingsExport.java | 14 +- .../co/aikar/timings/TimingsManager.java | 8 +- .../co/aikar/timings/WorldTimingsHandler.java | 2 +- .../resourcepack/SpongeResourcePack.java | 6 +- .../resourcepack/SpongeURIResourcePack.java | 4 +- .../resourcepack/SpongeWorldResourcePack.java | 4 +- .../common/scheduler/AsyncScheduler.java | 4 +- .../common/scheduler/ServerScheduler.java | 2 +- .../common/scheduler/SpongeScheduledTask.java | 6 +- .../common/scheduler/SpongeScheduler.java | 30 +-- .../common/scheduler/SpongeTask.java | 22 +- .../common/scheduler/SpongeTaskBuilder.java | 12 +- .../scheduler/SpongeTaskExecutorService.java | 8 +- .../common/scoreboard/SpongeDisplaySlot.java | 2 +- .../common/scoreboard/SpongeObjective.java | 38 +-- .../common/scoreboard/SpongeScore.java | 6 +- .../builder/SpongeScoreboardBuilder.java | 4 +- .../scoreboard/builder/SpongeTeamBuilder.java | 18 +- .../common/server/BootstrapProperties.java | 4 +- .../server/ServerConsoleSystemSubject.java | 2 +- .../common/service/SpongeServiceProvider.java | 9 +- .../pagination/SpongePaginationBuilder.java | 10 +- .../game/pagination/SpongePaginationList.java | 16 +- .../pagination/SpongePaginationService.java | 40 +-- .../service/server/ban/SpongeBanService.java | 56 ++--- .../service/server/ban/SpongeIPBanList.java | 14 +- .../service/server/ban/SpongeUserBanList.java | 15 +- .../server/permission/BridgeSubject.java | 44 ++-- .../permission/DataFactoryCollection.java | 26 +- .../FixedParentMemorySubjectData.java | 4 +- .../permission/GlobalMemorySubjectData.java | 4 +- .../server/permission/OpLevelCollection.java | 16 +- .../SingleParentMemorySubjectData.java | 2 +- .../server/permission/SpongeBaseSubject.java | 34 +-- .../SpongePermissionDescription.java | 14 +- .../permission/SpongePermissionService.java | 28 +-- .../server/permission/SpongePermissions.java | 8 +- .../server/permission/SpongeSubject.java | 6 +- .../permission/SpongeSubjectCollection.java | 38 +-- .../permission/SpongeSubjectReference.java | 4 +- .../permission/SpongeSystemSubject.java | 2 +- .../server/permission/SubjectHelper.java | 10 +- .../server/permission/UserCollection.java | 9 +- .../server/permission/UserSubject.java | 24 +- .../server/rcon/MinecraftRconService.java | 2 +- .../server/whitelist/SpongeUserWhiteList.java | 12 +- .../whitelist/SpongeWhitelistService.java | 2 +- .../common/sql/SpongeSqlManager.java | 12 +- .../state/AbstractSpongeStateMatcher.java | 2 +- .../common/state/SpongeBlockStateMatcher.java | 2 +- .../common/state/SpongeFluidStateMatcher.java | 2 +- .../common/user/ServerUserProvider.java | 18 +- .../common/user/SpongeUserManager.java | 18 +- .../spongepowered/common/util/BookUtil.java | 4 +- .../spongepowered/common/util/Constants.java | 4 +- .../spongepowered/common/util/DataUtil.java | 6 +- .../spongepowered/common/util/EngineUtil.java | 8 +- .../common/util/FireworkUtil.java | 14 +- .../common/util/ParticleOptionUtil.java | 2 +- .../spongepowered/common/util/SpongeAABB.java | 14 +- .../common/util/SpongeCriterionUtil.java | 16 +- .../common/util/SpongeMinecraftDayTime.java | 8 +- .../common/util/SpongeOrientation.java | 2 +- .../common/util/SpongeRange.java | 4 +- .../common/util/SpongeTicks.java | 10 +- .../common/util/SpongeTransform.java | 24 +- .../common/util/UsernameCache.java | 2 +- .../spongepowered/common/util/VecHelper.java | 4 +- .../metric/SpongeMetricsConfigManager.java | 4 +- .../util/raytrace/AbstractSpongeRayTrace.java | 13 +- .../util/raytrace/SpongeBlockRayTrace.java | 2 +- .../util/raytrace/SpongeEntityRayTrace.java | 2 +- .../util/raytrace/SpongeRayTraceFactory.java | 2 +- .../util/raytrace/SpongeRayTraceResult.java | 4 +- .../common/world/SpongeExplosionBuilder.java | 16 +- .../common/world/SpongeLocation.java | 58 ++--- .../biome/SpongeBiomeProviderFactory.java | 2 +- .../world/border/PlayerOwnBorderListener.java | 2 +- .../border/SpongeWorldBorderBuilder.java | 12 +- .../SpongeFlatGeneratorConfigBuilder.java | 6 +- .../config/SpongeNoiseGeneratorConfig.java | 4 +- .../config/flat/SpongeLayerConfigFactory.java | 2 +- .../common/world/portal/EndPortalType.java | 2 +- .../common/world/portal/NetherPortalType.java | 18 +- .../common/world/portal/VanillaPortal.java | 6 +- .../schematic/ImmutableBimapPalette.java | 8 +- .../world/schematic/MutableBimapPalette.java | 16 +- .../world/schematic/SpongePaletteType.java | 4 +- .../world/schematic/SpongeSchematic.java | 120 ++++----- .../world/server/SpongeLocatableBlock.java | 14 +- .../server/SpongeLocatableBlockBuilder.java | 20 +- .../world/server/SpongeServerLocation.java | 78 +++--- .../world/server/SpongeWorldManager.java | 9 +- .../world/server/SpongeWorldTemplate.java | 4 +- .../world/server/SpongeWorldTypeTemplate.java | 4 +- .../common/world/server/WorldMigrator.java | 2 +- .../world/storage/SpongeChunkLayout.java | 10 +- .../world/storage/SpongePlayerData.java | 4 +- .../storage/SpongePlayerDataManager.java | 2 +- .../teleport/ConfigTeleportHelperFilter.java | 8 +- .../world/teleport/SpongeTeleportHelper.java | 12 +- .../SurfaceOnlyTeleportHelperFilter.java | 2 +- .../world/volume/SpongeVolumeStream.java | 82 +++--- .../world/volume/VolumeStreamUtils.java | 2 +- .../entity/SpongeEntityArchetypeEntry.java | 4 +- .../block/SpongeBlockVolumeFactory.java | 16 +- .../volume/buffer/AbstractVolumeBuffer.java | 6 +- .../archetype/SpongeArchetypeVolume.java | 72 +++--- ...ractMutableBlockEntityArchetypeBuffer.java | 22 +- ...eArrayBasedBlockEntityArchetypeBuffer.java | 6 +- .../MutableMapBlockEntityArchetypeBuffer.java | 8 +- ...jectArrayMutableEntityArchetypeBuffer.java | 28 +-- .../biome/ByteArrayImmutableBiomeBuffer.java | 16 +- .../biome/ByteArrayMutableBiomeBuffer.java | 20 +- .../ObjectArrayImmutableBiomeBuffer.java | 10 +- .../biome/ObjectArrayMutableBiomeBuffer.java | 8 +- .../block/ArrayImmutableBlockBuffer.java | 24 +- .../buffer/block/ArrayMutableBlockBuffer.java | 42 ++-- .../AbstractMutableBlockEntityBuffer.java | 20 +- .../ObjectArrayMutableBlockEntityBuffer.java | 16 +- .../ObjectArrayMutableEntityBuffer.java | 56 ++--- .../common/world/weather/SpongeWeather.java | 8 +- .../entity/living/HumanEntityMixin_API.java | 2 +- .../MinecraftBlockDamageSourceMixin_API.java | 8 +- ...raftFallingBlockDamageSourceMixin_API.java | 8 +- .../entity/ai/goal/AbstractGoalMixin_API.java | 2 +- .../common/AbstractDamageSourceMixin_API.java | 4 +- .../AbstractEntityDamageSourceMixin_API.java | 6 +- ...ctIndirectEntityDamageSourceMixin_API.java | 6 +- .../api/item/merchant/MerchantMixin_API.java | 4 +- .../advancements/AdvancementMixin_API.java | 18 +- .../AdvancementProgressMixin_API.java | 20 +- .../mcp/advancements/CriterionMixin_API.java | 4 +- .../CriterionProgressMixin_API.java | 10 +- .../CriterionTriggerInstanceMixin_API.java | 4 +- .../CriterionTriggerMixin_API.java | 4 +- .../advancements/DisplayInfoMixin_API.java | 12 +- .../mcp/advancements/FrameTypeMixin_API.java | 2 +- .../api/mcp/block/AbstractBlockMixin_API.java | 2 +- .../mixin/api/mcp/block/BlockMixin_API.java | 8 +- .../api/mcp/client/MinecraftMixin_API.java | 16 +- .../ClientPacketListenerMixin_API.java | 2 +- .../network/ClientNetHandlerMixin_API.java | 4 +- .../server/IntegratedServerMixin_API.java | 2 +- .../commands/CommandSourceStackMixin_API.java | 42 ++-- .../selector/EntitySelectorMixin_API.java | 6 +- .../EntitySelectorParserMixin_API.java | 112 ++++----- .../core/particles/ParticleTypeMixin_API.java | 4 +- .../api/mcp/map/MapDecorationMixin_API.java | 8 +- .../mixin/api/mcp/map/MapInfoMixin_API.java | 10 +- .../status/ServerStatusMixin_API.java | 8 +- .../status/ServerStatus_PlayersMixin_API.java | 6 +- .../status/ServerStatus_VersionMixin_API.java | 4 +- .../mcp/server/MinecraftServerMixin_API.java | 60 ++--- .../mcp/server/ServerScoreboardMixin_API.java | 31 ++- .../dedicated/DedicatedServerMixin_API.java | 2 +- .../server/level/ServerLevelMixin_API.java | 47 ++-- .../server/level/ServerPlayerMixin_API.java | 42 ++-- ...ServerGamePacketListenerImplMixin_API.java | 10 +- ...erverLoginPacketListenerImplMixin_API.java | 6 +- .../server/players/BanListEntryMixin_API.java | 8 +- .../players/GameProfileCacheMixin_API.java | 18 +- .../players/IpBanListEntryMixin_API.java | 4 +- .../players/UserBanListEntryMixin_API.java | 4 +- .../rcon/RconConsoleSourceMixin_API.java | 2 +- .../rcon/thread/RconClientMixin_API.java | 4 +- .../api/mcp/sounds/SoundEventMixin_API.java | 5 - .../api/mcp/state/PropertyMixin_API.java | 19 +- .../mixin/api/mcp/stats/StatMixin_API.java | 4 +- .../api/mcp/stats/StatTypeMixin_API.java | 2 +- .../api/mcp/util/DamageSourceMixin_API.java | 4 +- .../mcp/util/EntityDamageSourceMixin_API.java | 2 +- .../IndirectEntityDamageSourceMixin_API.java | 2 +- .../IWorldGenerationBaseReaderMixin_API.java | 4 +- .../effect/MobEffectInstanceMixin_API.java | 17 +- .../api/mcp/world/entity/EntityMixin_API.java | 75 +++--- .../world/entity/LivingEntityMixin_API.java | 4 +- .../api/mcp/world/entity/MobMixin_API.java | 2 +- .../AttributeInstanceMixin_API.java | 16 +- .../ai/attributes/AttributeMixin_API.java | 5 +- .../AttributeModifierMixin_API.java | 13 +- .../attributes/RangedAttributeMixin_API.java | 4 +- .../ai/goal/AvoidEntityGoalMixin_API.java | 8 +- .../entity/ai/goal/FloatGoalMixin_API.java | 2 +- .../world/entity/ai/goal/GoalMixin_API.java | 4 +- .../entity/ai/goal/GoalSelectorMixin_API.java | 10 +- .../ai/goal/LookAtPlayerGoalMixin_API.java | 6 +- .../ai/goal/MeleeAttackGoalMixin_API.java | 2 +- .../ai/goal/RandomStrollGoalMixin_API.java | 4 +- .../ai/goal/RangedAttackGoalMixin_API.java | 6 +- .../goal/RunAroundLikeCrazyGoalMixin_API.java | 2 +- .../NearestAttackableTargetGoalMixin_API.java | 6 +- .../world/entity/animal/AnimalMixin_API.java | 25 ++ .../mcp/world/entity/animal/CatMixin_API.java | 2 +- .../mcp/world/entity/animal/FoxMixin_API.java | 3 +- .../entity/animal/MushroomCowMixin_API.java | 2 +- .../world/entity/animal/ParrotMixin_API.java | 2 +- .../world/entity/animal/RabbitMixin_API.java | 2 +- .../entity/animal/horse/LlamaMixin_API.java | 2 +- .../entity/boss/EnderDragonPartMixin_API.java | 2 +- .../enderdragon/EnderDragonMixin_API.java | 4 +- .../phases/DragonPhaseInstanceMixin_API.java | 4 +- .../EnderDragonPhaseManagerMixin_API.java | 2 +- .../decoration/HangingEntityMixin_API.java | 2 +- .../entity/decoration/MotiveMixin_API.java | 9 +- .../entity/monster/ShulkerMixin_API.java | 2 +- .../monster/ZombieVillagerMixin_API.java | 3 +- .../entity/npc/AbstractVillagerMixin_API.java | 2 +- .../world/entity/npc/VillagerMixin_API.java | 2 +- .../world/entity/player/PlayerMixin_API.java | 7 +- .../projectile/ShulkerBulletMixin_API.java | 2 +- .../mcp/world/entity/raid/RaidMixin_API.java | 14 +- .../world/entity/vehicle/BoatMixin_API.java | 2 +- .../entity/vehicle/Boat_TypeMixin_API.java | 2 +- .../MinecartCommandBlockMixin_API.java | 2 +- .../world/item/ArmorMaterialsMixin_API.java | 2 +- .../api/mcp/world/item/DyeColorMixin_API.java | 2 +- .../world/item/ItemCooldownsMixin_API.java | 4 +- .../api/mcp/world/item/ItemMixin_API.java | 4 +- .../mcp/world/item/ItemStackMixin_API.java | 16 +- .../api/mcp/world/item/TiersMixin_API.java | 2 +- .../world/item/alchemy/PotionMixin_API.java | 2 +- .../AbstractCookingRecipeMixin_API.java | 17 +- .../crafting/CraftingRecipeMixin_API.java | 7 +- .../item/crafting/CustomRecipeMixin_API.java | 2 +- .../item/crafting/RecipeManagerMixin_API.java | 10 +- .../world/item/crafting/RecipeMixin_API.java | 26 +- .../item/crafting/ShapedRecipeMixin_API.java | 8 +- .../crafting/ShapelessRecipeMixin_API.java | 2 +- .../crafting/StonecutterRecipeMixin_API.java | 2 +- .../enchantment/EnchantmentMixin_API.java | 10 +- .../item/trading/MerchantOfferMixin_API.java | 31 ++- .../mcp/world/level/BlockGetterMixin_API.java | 27 +- .../world/level/EntityGetterMixin_API.java | 14 +- .../mcp/world/level/ExplosionMixin_API.java | 12 +- .../world/level/GameRules_KeyMixin_API.java | 6 +- .../world/level/LevelAccessorMixin_API.java | 20 +- .../api/mcp/world/level/LevelMixin_API.java | 38 +-- .../mcp/world/level/LevelReaderMixin_API.java | 29 ++- .../mcp/world/level/biome/BiomeMixin_API.java | 4 +- .../world/level/block/RotationMixin_API.java | 2 +- .../entity/BeaconBlockEntityMixin_API.java | 2 +- .../block/entity/BlockEntityMixin_API.java | 23 +- .../entity/BlockEntityTypeMixin_API.java | 2 +- .../entity/ChestBlockEntityMixin_API.java | 2 +- .../entity/CommandBlockEntityMixin_API.java | 4 +- ...lockBehaviour_BlockStateBaseMixin_API.java | 4 +- .../block/state/BlockStateMixin_API.java | 14 +- .../block/state/StateHolderMixin_API.java | 12 +- .../NoteBlockInstrumentMixin_API.java | 2 +- .../level/border/WorldBorderMixin_API.java | 20 +- .../level/chunk/LevelChunkMixin_API.java | 33 +-- .../dimension/DimensionTypeMixin_API.java | 2 +- .../world/level/material/FluidMixin_API.java | 8 +- .../level/material/FluidStateMixin_API.java | 6 +- .../level/storage/LevelDataMixin_API.java | 6 +- .../storage/PrimaryLevelDataMixin_API.java | 4 +- .../storage/ServerLevelDataMixin_API.java | 13 +- .../mcp/world/scores/PlayerTeamMixin_API.java | 22 +- .../criteria/ObjectiveCriteriaMixin_API.java | 2 +- .../world/storage/MapItemSavedDataMixin.java | 2 +- .../authlib/properties/PropertyMixin_API.java | 18 +- .../world/gen/Heightmap_TypeMixin_API.java | 2 +- ...InstanceMultiMapMixin_ConcurrentCheck.java | 4 +- .../core/advancements/AdvancementMixin.java | 2 +- .../AdvancementProgressMixin.java | 46 ++-- .../core/advancements/CriterionMixin.java | 2 +- .../CriterionTrigger_ListenerMixin.java | 10 +- .../advancements/TreeNodePositionMixin.java | 4 +- .../authlib/properties/PropertyMixin.java | 4 +- .../mixin/core/client/MinecraftMixin.java | 10 +- .../commands/CommandSourceStackMixin.java | 18 +- .../core/data/SpongeDataHolderMixin.java | 2 +- .../mixin/core/item/ItemEmptyMapMixin.java | 6 +- .../ClientboundResourcePackPacketMixin.java | 2 +- .../syncher/SynchedEntityDataMixin.java | 6 +- .../core/server/MinecraftServerMixin.java | 14 +- .../core/server/PlayerAdvancementsMixin.java | 14 +- .../core/server/ServerScoreboardMixin.java | 26 +- .../server/commands/TeleportCommandMixin.java | 32 +-- .../dedicated/DedicatedPlayerListMixin.java | 14 +- .../dedicated/DedicatedServerMixin.java | 2 +- .../core/server/level/ChunkMapMixin.java | 8 +- .../core/server/level/ServerLevelMixin.java | 6 +- .../core/server/level/ServerPlayerMixin.java | 96 +++---- .../ServerGamePacketListenerImplMixin.java | 38 +-- .../ServerLoginPacketListenerImplMixin.java | 2 +- .../server/players/BanListEntryMixin.java | 4 +- .../server/players/GameProfileCacheMixin.java | 10 +- .../core/server/players/PlayerListMixin.java | 32 +-- .../server/rcon/thread/RconClientMixin.java | 6 +- .../world/damagesource/DamageSourceMixin.java | 4 +- .../damagesource/EntityDamageSourceMixin.java | 2 +- .../IndirectEntityDamageSourceMixin.java | 2 +- .../core/world/entity/AgableMobMixin.java | 2 +- .../mixin/core/world/entity/EntityMixin.java | 66 ++--- .../core/world/entity/LightningBoltMixin.java | 8 +- .../core/world/entity/LivingEntityMixin.java | 56 ++--- .../mixin/core/world/entity/MobMixin.java | 10 +- .../world/entity/ai/goal/BreedGoalMixin.java | 4 +- .../entity/ai/goal/GoalSelectorMixin.java | 6 +- .../ai/goal/RunAroundLikeCrazyGoalMixin.java | 2 +- .../core/world/entity/animal/AnimalMixin.java | 2 +- .../core/world/entity/animal/OcelotMixin.java | 2 +- .../core/world/entity/animal/ParrotMixin.java | 2 +- .../core/world/entity/animal/WolfMixin.java | 2 +- .../world/entity/animal/horse/LlamaMixin.java | 4 +- .../entity/decoration/ArmorStandMixin.java | 12 +- .../entity/decoration/HangingEntityMixin.java | 2 +- .../entity/decoration/ItemFrameMixin.java | 2 +- .../world/entity/item/ItemEntityMixin.java | 2 +- .../EnderMan_EndermanLeaveBlockGoalMixin.java | 2 +- .../core/world/entity/player/PlayerMixin.java | 18 +- .../projectile/FireworkRocketEntityMixin.java | 2 +- .../entity/projectile/FishingHookMixin.java | 6 +- .../projectile/ThrownEnderpearlMixin.java | 8 +- .../entity/vehicle/AbstractMinecartMixin.java | 2 +- .../entity/vehicle/MinecartTNTMixin.java | 2 +- .../core/world/item/EnderEyeItemMixin.java | 4 +- .../world/item/FireworkRocketItemMixin.java | 2 +- .../core/world/item/FishingRodItemMixin.java | 2 +- .../world/item/ServerItemCooldownsMixin.java | 13 +- .../core/world/level/ExplosionMixin.java | 6 +- .../world/level/block/CommandBlockMixin.java | 2 +- .../world/level/block/FallingBlockMixin.java | 2 +- .../world/level/block/NoteBlockMixin.java | 6 +- .../AbstractFurnaceBlockEntityMixin.java | 14 +- .../level/block/entity/BlockEntityMixin.java | 2 +- .../entity/CampfireBlockEntityMixin.java | 4 +- .../block/entity/SkullBlockEntityMixin.java | 6 +- .../entity/TheEndGatewayBlockEntityMixin.java | 2 +- .../world/level/dimension/LevelStemMixin.java | 2 +- .../level/storage/PlayerDataStorageMixin.java | 2 +- .../level/storage/PrimaryLevelDataMixin.java | 2 +- .../core/world/scores/PlayerTeamMixin.java | 4 +- .../entity/EntityMixin_EntityCollision.java | 16 +- .../block/BlockMixin_EntityCollision.java | 6 +- .../LevelChunkMixin_EntityCollision.java | 2 +- ...aitMixin_ArmorEquipable_Inventory_API.java | 20 +- .../api/TraitMixin_Carried_Inventory_API.java | 2 +- .../TraitMixin_Equipable_Inventory_API.java | 2 +- .../TraitMixin_Viewable_Inventory_API.java | 2 +- ...pongeUserInventoryMixin_Inventory_API.java | 10 +- .../ContainerMixin_Inventory_API.java | 12 +- ...rverPlayerMixin_Carrier_Inventory_API.java | 2 +- .../ServerPlayerMixin_Inventory_API.java | 12 +- ...dContainerMixin_Carried_Inventory_API.java | 2 +- ...dContainerMixin_Carrier_Inventory_API.java | 26 +- .../EquipmentSlotMixin_Inventory_API.java | 2 +- ...tractHorseMixin_Carrier_Inventory_API.java | 2 +- .../PillagerMixin_Carrier_Inventory_API.java | 2 +- ...ctVillagerMixin_Carrier_Inventory_API.java | 2 +- .../InventoryMixin_Carried_Inventory_API.java | 2 +- .../player/InventoryMixin_Inventory_API.java | 8 +- .../player/PlayerMixin_Inventory_API.java | 8 +- ...tContainerMixin_Carried_Inventory_API.java | 2 +- ...tContainerMixin_Carrier_Inventory_API.java | 2 +- ...lMenuMixin_BlockCarrier_Inventory_API.java | 4 +- .../CraftingContainerMixin_Inventory_API.java | 4 +- ...gMenuMixin_BlockCarrier_Inventory_API.java | 4 +- ...tMenuMixin_BlockCarrier_Inventory_API.java | 6 +- ...nMenuMixin_BlockCarrier_Inventory_API.java | 8 +- ...mMenuMixin_BlockCarrier_Inventory_API.java | 4 +- ...rMenuMixin_BlockCarrier_Inventory_API.java | 4 +- ...lockEntityMixin_Carried_Inventory_API.java | 4 +- ...lockEntityMixin_Carrier_Inventory_API.java | 6 +- ...lockEntityMixin_Carried_Inventory_API.java | 4 +- ...lockEntityMixin_Carrier_Inventory_API.java | 6 +- .../ChestBlockEntityMixin_Inventory_API.java | 2 +- .../entity/LivingEntityMixin_Inventory.java | 4 +- .../player/PlayerEntityMixin_Inventory.java | 6 +- ...GamePacketListenerImplMixin_Inventory.java | 10 +- .../AbstractContainerMenuMixin_Inventory.java | 4 +- .../inventory/AnvilMenuMixin_Inventory.java | 8 +- .../inventory/ResultSlotMixin_Inventory.java | 6 +- ...ractContainerMenuMixin_Menu_Inventory.java | 2 +- .../tracker/CreatorTrackedMixin_Tracker.java | 18 +- .../server/level/ChunkMapMixin_Tracker.java | 2 +- .../level/ServerLevelMixin_Tracker.java | 10 +- .../ServerPlayerGameModeMixin_Tracker.java | 4 +- .../entity/player/InventoryMixin_Tracker.java | 6 +- .../world/level/ExplosionMixin_Tracker.java | 4 +- .../block/DispenserBlockMixin_Tracker.java | 2 +- .../level/chunk/LevelChunkMixin_Tracker.java | 2 +- .../common/data/persistence/SimpleData.java | 2 +- .../common/util/ReflectionTest.java | 6 +- .../common/util/SpongeAABBTest.java | 18 +- .../spongepowered/test/LoadableModule.java | 2 +- .../org/spongepowered/test/TestPlugin.java | 26 +- .../test/advancement/AdvancementTest.java | 45 ++-- .../test/archetype/ArchetypeTest.java | 18 +- .../test/changeblock/ChangeBlockTest.java | 36 +-- .../test/channel/ChannelTest.java | 10 +- .../org/spongepowered/test/chat/ChatTest.java | 34 +-- .../test/chunk/ChunkEventTest.java | 16 +- .../test/command/CommandTest.java | 236 +++++++++--------- .../test/command/RawCommandTest.java | 12 +- .../spongepowered/test/config/ConfigTest.java | 2 +- .../test/customdata/CustomDataTest.java | 58 ++--- .../org/spongepowered/test/data/DataTest.java | 196 +++++++-------- .../spongepowered/test/human/HumanTest.java | 28 +-- .../test/interact/InteractTest.java | 38 +-- .../test/inventory/InventoryTest.java | 48 ++-- .../org/spongepowered/test/map/MapTest.java | 236 +++++++++--------- .../test/movement/MovementTest.java | 24 +- .../notifyneighbor/NotifyNeighborTest.java | 10 +- .../test/particle/ParticleTest.java | 14 +- .../test/projectile/ProjectileTest.java | 62 ++--- .../test/raytrace/RayTraceTest.java | 22 +- .../spongepowered/test/recipe/RecipeTest.java | 38 +-- .../test/scaledhealth/ScaledHealthTest.java | 68 ++--- .../spongepowered/test/trades/TradeTest.java | 10 +- .../test/volumestream/VolumeStreamTest.java | 74 +++--- .../spongepowered/test/world/WorldTest.java | 173 +++++++------ .../vanilla/launch/IntegrationTestLaunch.java | 2 +- .../vanilla/launch/VanillaLaunch.java | 3 +- .../launch/plugin/VanillaPluginManager.java | 4 +- .../spongepowered/vanilla/VanillaServer.java | 2 +- .../client/gui/screen/PluginScreen.java | 4 +- .../vanilla/world/VanillaWorldManager.java | 62 ++--- .../MinecraftServerMixin_Vanilla_API.java | 2 +- .../mixin/core/CrashReportMixin_Vanilla.java | 2 +- ...dshakePacketListenerImplMixin_Vanilla.java | 2 +- .../ClientPacketListenerMixin_Vanilla.java | 2 +- .../server/IntegratedServerMixin_Vanilla.java | 2 +- .../DedicatedServerMixin_Vanilla.java | 2 +- ...erGamePacketListenerImplMixin_Vanilla.java | 8 +- ...rLoginPacketListenerImplMixin_Vanilla.java | 8 +- 851 files changed, 4957 insertions(+), 4993 deletions(-) diff --git a/SpongeAPI b/SpongeAPI index bea03431744..bcc994fd840 160000 --- a/SpongeAPI +++ b/SpongeAPI @@ -1 +1 @@ -Subproject commit bea03431744f5f9be3f6af80074c90c8eb435ba6 +Subproject commit bcc994fd84049ff7630d9f241bedefa2d7ba815e diff --git a/src/launch/java/org/spongepowered/common/launch/Launch.java b/src/launch/java/org/spongepowered/common/launch/Launch.java index 62a791b90d3..06381bdbf2e 100644 --- a/src/launch/java/org/spongepowered/common/launch/Launch.java +++ b/src/launch/java/org/spongepowered/common/launch/Launch.java @@ -89,7 +89,7 @@ public final boolean isDeveloperEnvironment() { public final PluginContainer getMinecraftPlugin() { if (this.minecraftPlugin == null) { - this.minecraftPlugin = this.pluginManager.getPlugin("minecraft").orElse(null); + this.minecraftPlugin = this.pluginManager.plugin("minecraft").orElse(null); if (this.minecraftPlugin == null) { throw new RuntimeException("Could not find the plugin representing Minecraft, this is a serious issue!"); @@ -101,7 +101,7 @@ public final PluginContainer getMinecraftPlugin() { public final PluginContainer getApiPlugin() { if (this.apiPlugin == null) { - this.apiPlugin = this.pluginManager.getPlugin("spongeapi").orElse(null); + this.apiPlugin = this.pluginManager.plugin("spongeapi").orElse(null); if (this.apiPlugin == null) { throw new RuntimeException("Could not find the plugin representing SpongeAPI, this is a serious issue!"); @@ -113,7 +113,7 @@ public final PluginContainer getApiPlugin() { public final PluginContainer getCommonPlugin() { if (this.commonPlugin == null) { - this.commonPlugin = this.pluginManager.getPlugin("sponge").orElse(null); + this.commonPlugin = this.pluginManager.plugin("sponge").orElse(null); if (this.commonPlugin == null) { throw new RuntimeException("Could not find the plugin representing Sponge, this is a serious issue!"); diff --git a/src/main/java/org/spongepowered/common/AbstractResourceKeyed.java b/src/main/java/org/spongepowered/common/AbstractResourceKeyed.java index bfa46799965..863350ebe71 100644 --- a/src/main/java/org/spongepowered/common/AbstractResourceKeyed.java +++ b/src/main/java/org/spongepowered/common/AbstractResourceKeyed.java @@ -36,7 +36,7 @@ public AbstractResourceKeyed(final ResourceKey key) { } @Override - public final ResourceKey getKey() { + public final ResourceKey key() { return this.key; } } diff --git a/src/main/java/org/spongepowered/common/SpongeBootstrap.java b/src/main/java/org/spongepowered/common/SpongeBootstrap.java index 52e317a25ce..6f5a835f9ab 100644 --- a/src/main/java/org/spongepowered/common/SpongeBootstrap.java +++ b/src/main/java/org/spongepowered/common/SpongeBootstrap.java @@ -70,7 +70,7 @@ public static void perform(final String engineName, final Runnable engineStart) SpongeBootstrap.lifecycle.establishGameServices(); SpongeBootstrap.lifecycle.establishDataKeyListeners(); - SpongePacketHandler.init((SpongeChannelRegistry) Sponge.getChannelRegistry()); + SpongePacketHandler.init((SpongeChannelRegistry) Sponge.channelRegistry()); Launch.getInstance().getLogger().info("Loading Minecraft {}, please wait...", engineName); engineStart.run(); diff --git a/src/main/java/org/spongepowered/common/SpongeCommon.java b/src/main/java/org/spongepowered/common/SpongeCommon.java index 66384ca5fe2..6aa1b82976b 100644 --- a/src/main/java/org/spongepowered/common/SpongeCommon.java +++ b/src/main/java/org/spongepowered/common/SpongeCommon.java @@ -69,7 +69,7 @@ private SpongeCommon() { final @Nullable SpongeGame game = SpongeCommon.game; if (game != null) { try { - game.getConfigManager().close(); + game.configManager().close(); } catch (final IOException e) { SpongeCommon.getLogger().error("Failed to shut down configuration watch service", e); } @@ -95,19 +95,19 @@ public static SpongeGame getGame() { } public static MinecraftServer getServer() { - return (MinecraftServer) Sponge.getServer(); + return (MinecraftServer) Sponge.server(); } public static SpongeGameRegistry getRegistry() { - return (SpongeGameRegistry) Sponge.getRegistry(); + return (SpongeGameRegistry) Sponge.registry(); } public static ServerScheduler getServerScheduler() { - return (ServerScheduler) Sponge.getServer().getScheduler(); + return (ServerScheduler) Sponge.server().scheduler(); } public static AsyncScheduler getAsyncScheduler() { - return SpongeCommon.getGame().getAsyncScheduler(); + return SpongeCommon.getGame().asyncScheduler(); } public static Path getGameDirectory() { @@ -157,12 +157,12 @@ public static void setActivePlugin(@Nullable final PluginContainer plugin) { * @return True if the event is cancellable and is cancelled, false if not cancelled */ public static boolean postEvent(Event event) { - return Sponge.getEventManager().post(event); + return Sponge.eventManager().post(event); } @Deprecated public static boolean postEvent(Event event, boolean allowClientThread) { - return Sponge.getEventManager().post(event); + return Sponge.eventManager().post(event); } public static int directionToIndex(Direction direction) { diff --git a/src/main/java/org/spongepowered/common/SpongeGame.java b/src/main/java/org/spongepowered/common/SpongeGame.java index 0a04e9831b8..4c523a075eb 100644 --- a/src/main/java/org/spongepowered/common/SpongeGame.java +++ b/src/main/java/org/spongepowered/common/SpongeGame.java @@ -33,7 +33,6 @@ import org.spongepowered.api.Platform; import org.spongepowered.api.Server; import org.spongepowered.api.asset.AssetManager; -import org.spongepowered.api.command.manager.CommandManager; import org.spongepowered.api.data.DataManager; import org.spongepowered.api.event.EventManager; import org.spongepowered.api.network.channel.ChannelRegistry; @@ -106,12 +105,12 @@ public SpongeGame(final Platform platform, final GameRegistry registry, final Bu } @Override - public Path getGameDirectory() { + public Path gameDirectory() { return SpongeCommon.getGameDirectory(); } @Override - public ServerConsoleSystemSubject getSystemSubject() { + public ServerConsoleSystemSubject systemSubject() { if (this.systemSubject == null) { this.systemSubject = new ServerConsoleSystemSubject(); } @@ -119,93 +118,93 @@ public ServerConsoleSystemSubject getSystemSubject() { } @Override - public Platform getPlatform() { + public Platform platform() { return this.platform; } @Override - public GameRegistry getRegistry() { + public GameRegistry registry() { return this.registry; } @Override - public BuilderProvider getBuilderProvider() { + public BuilderProvider builderProvider() { return this.builderProvider; } @Override - public FactoryProvider getFactoryProvider() { + public FactoryProvider factoryProvider() { return this.factoryProvider; } @Override - public DataManager getDataManager() { + public DataManager dataManager() { return this.dataManager; } @Override - public PluginManager getPluginManager() { + public PluginManager pluginManager() { return this.pluginManager; } @Override - public EventManager getEventManager() { + public EventManager eventManager() { return this.eventManager; } @Override - public AssetManager getAssetManager() { + public AssetManager assetManager() { return this.assetManager; } @Override - public PluginConfigManager getConfigManager() { + public PluginConfigManager configManager() { return this.configManager; } @Override - public ChannelRegistry getChannelRegistry() { + public ChannelRegistry channelRegistry() { return this.channelRegistry; } @Override - public MetricsConfigManager getMetricsConfigManager() { + public MetricsConfigManager metricsConfigManager() { return this.metricsConfigManager; } @Override - public SqlManager getSqlManager() { + public SqlManager sqlManager() { return this.sqlManager; } @Override - public ServiceProvider.GameScoped getServiceProvider() { + public ServiceProvider.GameScoped serviceProvider() { return this.serviceProvider; } @Override - public AsyncScheduler getAsyncScheduler() { + public AsyncScheduler asyncScheduler() { return this.asyncScheduler; } @Override - public Locale getLocale(final String locale) { + public Locale locale(final String locale) { return LocaleCache.getLocale(Preconditions.checkNotNull(locale)); } @Override public boolean isServerAvailable() { if (this.client != null) { - return this.client.getServer().isPresent(); + return this.client.server().isPresent(); } return this.server != null; } @Override - public Server getServer() { + public Server server() { if (this.client != null) { - return this.client.getServer().orElseThrow(() -> new IllegalStateException("The singleplayer server is not available!")); + return this.client.server().orElseThrow(() -> new IllegalStateException("The singleplayer server is not available!")); } Preconditions.checkState(this.server != null, "The dedicated server is not available!"); @@ -222,7 +221,7 @@ public boolean isClientAvailable() { } @Override - public Client getClient() { + public Client client() { Preconditions.checkState(this.client != null, "The client is not available!"); return this.client; } diff --git a/src/main/java/org/spongepowered/common/SpongeLifecycle.java b/src/main/java/org/spongepowered/common/SpongeLifecycle.java index 0e052cdf93a..07cc1c7f1e3 100644 --- a/src/main/java/org/spongepowered/common/SpongeLifecycle.java +++ b/src/main/java/org/spongepowered/common/SpongeLifecycle.java @@ -78,20 +78,20 @@ public SpongeLifecycle(final Game game, final Injector injector) { } public void establishFactories() { - ((SpongeFactoryProvider) this.game.getFactoryProvider()).registerDefaultFactories(); + ((SpongeFactoryProvider) this.game.factoryProvider()).registerDefaultFactories(); } public void establishBuilders() { - ((SpongeBuilderProvider) this.game.getBuilderProvider()).registerDefaultBuilders(); - ((SpongeDataManager) this.game.getDataManager()).registerDefaultBuilders(); + ((SpongeBuilderProvider) this.game.builderProvider()).registerDefaultBuilders(); + ((SpongeDataManager) this.game.dataManager()).registerDefaultBuilders(); } public void callRegisterFactoryEvent() { - this.game.getEventManager().post(new RegisterFactoryEventImpl(Cause.of(EventContext.empty(), this.game), this.game)); + this.game.eventManager().post(new RegisterFactoryEventImpl(Cause.of(EventContext.empty(), this.game), this.game)); } public void callRegisterBuilderEvent() { - this.game.getEventManager().post(new RegisterBuilderEventImpl(Cause.of(EventContext.empty(), this.game), this.game)); + this.game.eventManager().post(new RegisterBuilderEventImpl(Cause.of(EventContext.empty(), this.game), this.game)); } public void establishGlobalRegistries() { @@ -101,21 +101,21 @@ public void establishGlobalRegistries() { SpongeRegistries.registerGlobalRegistries((SpongeRegistryHolder) this.game.registries()); - this.game.getEventManager().post(new AbstractRegisterRegistryEvent.GameScopedImpl(Cause.of(EventContext.empty(), this.game), this.game)); - this.game.getEventManager().post(new AbstractRegisterRegistryValueEvent.GameScopedImpl(Cause.of(EventContext.empty(), this.game), this.game)); + this.game.eventManager().post(new AbstractRegisterRegistryEvent.GameScopedImpl(Cause.of(EventContext.empty(), this.game), this.game)); + this.game.eventManager().post(new AbstractRegisterRegistryValueEvent.GameScopedImpl(Cause.of(EventContext.empty(), this.game), this.game)); } public void callRegisterDataEvent() { - this.game.getEventManager().post(new RegisterDataEventImpl(Cause.of(EventContext.empty(), Sponge.getGame()), Sponge.getGame(), - (SpongeDataManager) this.game.getDataManager())); + this.game.eventManager().post(new RegisterDataEventImpl(Cause.of(EventContext.empty(), Sponge.game()), Sponge.game(), + (SpongeDataManager) this.game.dataManager())); } public void establishDataProviders() { - ((SpongeDataManager) this.game.getDataManager()).registerDefaultProviders(); + ((SpongeDataManager) this.game.dataManager()).registerDefaultProviders(); } public void establishDataKeyListeners() { - ((SpongeDataManager) this.game.getDataManager()).registerKeyListeners(); + ((SpongeDataManager) this.game.dataManager()).registerKeyListeners(); } public void callRegisterDataPackValueEvent(final Path datapackDir) { @@ -129,24 +129,24 @@ public void callRegisterDataPackValueEvent(final Path datapackDir) { } public void callRegisterChannelEvent() { - ((SpongeChannelRegistry) this.game.getChannelRegistry()).postRegistryEvent(); + ((SpongeChannelRegistry) this.game.channelRegistry()).postRegistryEvent(); } public void initTimings() { - ((SpongeTimingsFactory) this.game.getFactoryProvider().provide(TimingsFactory.class)).init(); + ((SpongeTimingsFactory) this.game.factoryProvider().provide(TimingsFactory.class)).init(); } public void establishGameServices() { - ((SpongeServiceProvider) this.game.getServiceProvider()).init(); + ((SpongeServiceProvider) this.game.serviceProvider()).init(); } public void establishServerServices() { - ((MinecraftServerBridge) this.game.getServer()).bridge$initServices(this.game, this.injector); + ((MinecraftServerBridge) this.game.server()).bridge$initServices(this.game, this.injector); } public void establishServerFeatures() { // Yes this looks odd but prevents having to do sided lifecycle solely to always point at the Server - ((SpongeServer) this.game.getServer()).getUsernameCache().load(); + ((SpongeServer) this.game.server()).getUsernameCache().load(); } public SpongeCommandManager createCommandManager() { @@ -156,16 +156,16 @@ public SpongeCommandManager createCommandManager() { } public void registerPluginListeners() { - for (final PluginContainer plugin : this.filterInternalPlugins(this.game.getPluginManager().getPlugins())) { - this.game.getEventManager().registerListeners(plugin, plugin.getInstance()); + for (final PluginContainer plugin : this.filterInternalPlugins(this.game.pluginManager().plugins())) { + this.game.eventManager().registerListeners(plugin, plugin.getInstance()); } } // Methods are in order of the SpongeCommon lifecycle public void callConstructEvent() { - for (final PluginContainer plugin : this.filterInternalPlugins(this.game.getPluginManager().getPlugins())) { - ((SpongeEventManager) this.game.getEventManager()).post(SpongeEventFactory.createConstructPluginEvent(Cause.of(EventContext.empty(), + for (final PluginContainer plugin : this.filterInternalPlugins(this.game.pluginManager().plugins())) { + ((SpongeEventManager) this.game.eventManager()).post(SpongeEventFactory.createConstructPluginEvent(Cause.of(EventContext.empty(), this.game), this.game, plugin), plugin); } } @@ -173,37 +173,37 @@ public void callConstructEvent() { public void establishServerRegistries(final Server server) { SpongeRegistries.registerServerRegistries((SpongeRegistryHolder) server.registries()); - this.game.getEventManager().post(new AbstractRegisterRegistryEvent.EngineScopedImpl<>(Cause.of(EventContext.empty(), this.game), this.game, + this.game.eventManager().post(new AbstractRegisterRegistryEvent.EngineScopedImpl<>(Cause.of(EventContext.empty(), this.game), this.game, server)); - this.game.getEventManager().post(new AbstractRegisterRegistryValueEvent.EngineScopedImpl<>(Cause.of(EventContext.empty(), this.game), + this.game.eventManager().post(new AbstractRegisterRegistryValueEvent.EngineScopedImpl<>(Cause.of(EventContext.empty(), this.game), this.game, server)); } public void establishClientRegistries(final Client client) { - this.game.getEventManager().post(new AbstractRegisterRegistryEvent.EngineScopedImpl<>(Cause.of(EventContext.empty(), this.game), this.game, + this.game.eventManager().post(new AbstractRegisterRegistryEvent.EngineScopedImpl<>(Cause.of(EventContext.empty(), this.game), this.game, client)); - this.game.getEventManager().post(new AbstractRegisterRegistryValueEvent.EngineScopedImpl<>(Cause.of(EventContext.empty(), this.game), + this.game.eventManager().post(new AbstractRegisterRegistryValueEvent.EngineScopedImpl<>(Cause.of(EventContext.empty(), this.game), this.game, client)); } public void callStartingEngineEvent(final Engine engine) { - this.game.getEventManager().post(SpongeEventFactory.createStartingEngineEvent(PhaseTracker.getCauseStackManager().getCurrentCause(), + this.game.eventManager().post(SpongeEventFactory.createStartingEngineEvent(PhaseTracker.getCauseStackManager().currentCause(), engine, this.game, (TypeToken) TypeToken.get(engine.getClass()))); } public void callStartedEngineEvent(final Engine engine) { - this.game.getEventManager().post(SpongeEventFactory.createStartedEngineEvent(PhaseTracker.getCauseStackManager().getCurrentCause(), + this.game.eventManager().post(SpongeEventFactory.createStartedEngineEvent(PhaseTracker.getCauseStackManager().currentCause(), engine, this.game, (TypeToken) TypeToken.get(engine.getClass()))); } public void callLoadedGameEvent() { - this.game.getEventManager().post(SpongeEventFactory.createLoadedGameEvent(PhaseTracker.getCauseStackManager().getCurrentCause(), this.game)); + this.game.eventManager().post(SpongeEventFactory.createLoadedGameEvent(PhaseTracker.getCauseStackManager().currentCause(), this.game)); } public void callStoppingEngineEvent(final Engine engine) { - this.game.getEventManager().post(SpongeEventFactory.createStoppingEngineEvent(PhaseTracker.getCauseStackManager().getCurrentCause(), + this.game.eventManager().post(SpongeEventFactory.createStoppingEngineEvent(PhaseTracker.getCauseStackManager().currentCause(), engine, this.game, (TypeToken) TypeToken.get(engine.getClass()))); } diff --git a/src/main/java/org/spongepowered/common/SpongeMinecraftVersion.java b/src/main/java/org/spongepowered/common/SpongeMinecraftVersion.java index c35ebcd7996..da54941fde9 100644 --- a/src/main/java/org/spongepowered/common/SpongeMinecraftVersion.java +++ b/src/main/java/org/spongepowered/common/SpongeMinecraftVersion.java @@ -51,7 +51,7 @@ public static int compare(ProtocolMinecraftVersion version, MinecraftVersion to) } @Override - public String getName() { + public String name() { return this.name; } @@ -66,7 +66,7 @@ public boolean isLegacy() { } @Override - public OptionalInt getDataVersion() { + public OptionalInt dataVersion() { return OptionalInt.of(Constants.MINECRAFT_DATA_VERSION); } diff --git a/src/main/java/org/spongepowered/common/SpongePlatform.java b/src/main/java/org/spongepowered/common/SpongePlatform.java index 84e80b705a9..ad7987ab358 100644 --- a/src/main/java/org/spongepowered/common/SpongePlatform.java +++ b/src/main/java/org/spongepowered/common/SpongePlatform.java @@ -67,27 +67,27 @@ public SpongePlatform(MinecraftVersion minecraftVersion) { this.minecraftPlugin = Launch.getInstance().getMinecraftPlugin(); final PluginContainer common = Launch.getInstance().getCommonPlugin(); - this.platformMap.put("Type", this.getType()); + this.platformMap.put("Type", this.type()); this.platformMap.put("ApiName", this.apiPlugin.getMetadata().getName()); this.platformMap.put("ApiVersion", this.apiPlugin.getMetadata().getVersion()); this.platformMap.put("CommonName", common.getMetadata().getName()); this.platformMap.put("CommonVersion", common.getMetadata().getVersion()); this.platformMap.put("ImplementationName", this.platformPlugin.getMetadata().getName()); this.platformMap.put("ImplementationVersion", this.platformPlugin.getMetadata().getVersion()); - this.platformMap.put("MinecraftVersion", this.getMinecraftVersion()); + this.platformMap.put("MinecraftVersion", this.minecraftVersion()); } @Override - public Type getType() { + public Type type() { return !Launch.getInstance().isDedicatedServer() ? Type.CLIENT : Type.SERVER; } @Override - public Type getExecutionType() { - if (Sponge.isServerAvailable() && Sponge.getServer().onMainThread()) { + public Type executionType() { + if (Sponge.isServerAvailable() && Sponge.server().onMainThread()) { return Type.SERVER; } - if (Sponge.isClientAvailable() && Sponge.getClient().onMainThread()) { + if (Sponge.isClientAvailable() && Sponge.client().onMainThread()) { return Type.CLIENT; } @@ -95,7 +95,7 @@ public Type getExecutionType() { } @Override - public PluginContainer getContainer(Component component) { + public PluginContainer container(Component component) { switch (component) { case API: return this.apiPlugin; @@ -109,7 +109,7 @@ public PluginContainer getContainer(Component component) { } @Override - public final MinecraftVersion getMinecraftVersion() { + public final MinecraftVersion minecraftVersion() { return this.minecraftVersion; } @@ -121,11 +121,11 @@ public final Map asMap() { @Override public String toString() { return MoreObjects.toStringHelper(this) - .add("type", this.getType()) - .add("executionType", this.getExecutionType()) + .add("type", this.type()) + .add("executionType", this.executionType()) .add("api", this.apiPlugin.getMetadata().getId()) .add("implementation", this.platformPlugin.getMetadata().getId()) - .add("minecraftVersion", this.getMinecraftVersion()) + .add("minecraftVersion", this.minecraftVersion()) .toString(); } } diff --git a/src/main/java/org/spongepowered/common/SpongeServer.java b/src/main/java/org/spongepowered/common/SpongeServer.java index dcd29799664..7cd22834443 100644 --- a/src/main/java/org/spongepowered/common/SpongeServer.java +++ b/src/main/java/org/spongepowered/common/SpongeServer.java @@ -34,14 +34,15 @@ public interface SpongeServer extends SpongeEngine, Server { @Override - ServerScheduler getScheduler(); + ServerScheduler scheduler(); @Override - SpongeWorldManager getWorldManager(); + SpongeWorldManager worldManager(); SpongePlayerDataManager getPlayerDataManager(); UsernameCache getUsernameCache(); - SpongeCommandManager getCommandManager(); + @Override + SpongeCommandManager commandManager(); } diff --git a/src/main/java/org/spongepowered/common/advancement/SpongeAdvancementBuilder.java b/src/main/java/org/spongepowered/common/advancement/SpongeAdvancementBuilder.java index a83bc6c0741..51be743c087 100644 --- a/src/main/java/org/spongepowered/common/advancement/SpongeAdvancementBuilder.java +++ b/src/main/java/org/spongepowered/common/advancement/SpongeAdvancementBuilder.java @@ -103,17 +103,17 @@ public Advancement build0() { final ResourceLocation resourceLocation = (ResourceLocation) (Object) key; final net.minecraft.advancements.DisplayInfo displayInfo = this.displayInfo == null ? null : new net.minecraft.advancements.DisplayInfo( - ItemStackUtil.fromSnapshotToNative(this.displayInfo.getIcon()), - SpongeAdventure.asVanilla(this.displayInfo.getTitle()), - SpongeAdventure.asVanilla(this.displayInfo.getDescription()), + ItemStackUtil.fromSnapshotToNative(this.displayInfo.icon()), + SpongeAdventure.asVanilla(this.displayInfo.title()), + SpongeAdventure.asVanilla(this.displayInfo.description()), this.backgroundPath, - (FrameType) (Object) this.displayInfo.getType(), + (FrameType) (Object) this.displayInfo.type(), this.displayInfo.doesShowToast(), this.displayInfo.doesAnnounceToChat(), this.displayInfo.isHidden()); final net.minecraft.advancements.Advancement parent = (net.minecraft.advancements.Advancement) this.parent; final Advancement advancement = (Advancement) new net.minecraft.advancements.Advancement( - resourceLocation, parent, displayInfo, rewards, result.getFirst(), result.getSecond()); + resourceLocation, parent, displayInfo, rewards, result.first(), result.second()); ((AdvancementBridge) advancement).bridge$setCriterion(this.criterion); return advancement; } diff --git a/src/main/java/org/spongepowered/common/advancement/SpongeCriterionTrigger.java b/src/main/java/org/spongepowered/common/advancement/SpongeCriterionTrigger.java index d2f52b0d06e..7fb28b8db29 100644 --- a/src/main/java/org/spongepowered/common/advancement/SpongeCriterionTrigger.java +++ b/src/main/java/org/spongepowered/common/advancement/SpongeCriterionTrigger.java @@ -105,7 +105,7 @@ public SpongeFilteredTrigger createInstance(final JsonObject json, final Deseria @Override public void bridge$trigger(final ServerPlayer player) { final PlayerAdvancements playerAdvancements = ((net.minecraft.server.level.ServerPlayer) player).getAdvancements(); - final Cause cause = PhaseTracker.getCauseStackManager().getCurrentCause(); + final Cause cause = PhaseTracker.getCauseStackManager().currentCause(); @SuppressWarnings("unchecked") // correct type verified in builder final TypeToken typeToken = (TypeToken) TypeToken.get(this.triggerConfigurationType); @@ -118,12 +118,12 @@ public SpongeFilteredTrigger createInstance(final JsonObject json, final Deseria typeToken, player, (FilteredTrigger) listener.getTriggerInstance(), this.eventHandler == null); if (this.eventHandler != null) { this.eventHandler.accept(event); - if (!event.getResult()) { + if (!event.result()) { continue; } } SpongeCommon.postEvent(event); - if (event.getResult()) { + if (event.result()) { listener.run(playerAdvancements); } } diff --git a/src/main/java/org/spongepowered/common/advancement/SpongeDisplayInfoBuilder.java b/src/main/java/org/spongepowered/common/advancement/SpongeDisplayInfoBuilder.java index 7a52a16bb82..a3110e18ecb 100644 --- a/src/main/java/org/spongepowered/common/advancement/SpongeDisplayInfoBuilder.java +++ b/src/main/java/org/spongepowered/common/advancement/SpongeDisplayInfoBuilder.java @@ -110,13 +110,13 @@ public DisplayInfo build() { @Override public DisplayInfo.Builder from(final DisplayInfo value) { - this.icon = value.getIcon(); - this.description = value.getDescription(); - this.advancementType = value.getType(); + this.icon = value.icon(); + this.description = value.description(); + this.advancementType = value.type(); this.announceToChat = value.doesAnnounceToChat(); this.hidden = value.isHidden(); this.showToast = value.doesShowToast(); - this.title = value.getTitle(); + this.title = value.title(); return this; } diff --git a/src/main/java/org/spongepowered/common/advancement/SpongeFilteredTrigger.java b/src/main/java/org/spongepowered/common/advancement/SpongeFilteredTrigger.java index 5ef06f9e0f7..28e9c1287b7 100644 --- a/src/main/java/org/spongepowered/common/advancement/SpongeFilteredTrigger.java +++ b/src/main/java/org/spongepowered/common/advancement/SpongeFilteredTrigger.java @@ -57,12 +57,12 @@ public ResourceLocation getCriterion() { } @Override - public Trigger getType() { + public Trigger type() { return (Trigger) this.triggerType; } @Override - public FilteredTriggerConfiguration getConfiguration() { + public FilteredTriggerConfiguration configuration() { return this.configuration; } diff --git a/src/main/java/org/spongepowered/common/advancement/SpongeFilteredTriggerBuilder.java b/src/main/java/org/spongepowered/common/advancement/SpongeFilteredTriggerBuilder.java index b411883937e..ffb6348ab57 100644 --- a/src/main/java/org/spongepowered/common/advancement/SpongeFilteredTriggerBuilder.java +++ b/src/main/java/org/spongepowered/common/advancement/SpongeFilteredTriggerBuilder.java @@ -60,8 +60,8 @@ public FilteredTrigger build() { @Override public FilteredTrigger.Builder from(final FilteredTrigger value) { - this.config = value.getConfiguration(); - this.type = value.getType(); + this.config = value.configuration(); + this.type = value.type(); return this; } diff --git a/src/main/java/org/spongepowered/common/advancement/SpongeTreeLayout.java b/src/main/java/org/spongepowered/common/advancement/SpongeTreeLayout.java index f69d5384260..7b7b1731fbb 100644 --- a/src/main/java/org/spongepowered/common/advancement/SpongeTreeLayout.java +++ b/src/main/java/org/spongepowered/common/advancement/SpongeTreeLayout.java @@ -44,35 +44,35 @@ public SpongeTreeLayout(final AdvancementTree tree) { } @Override - public AdvancementTree getTree() { + public AdvancementTree tree() { return this.tree; } @Override - public Collection getElements() { + public Collection elements() { final ImmutableSet.Builder elements = ImmutableSet.builder(); - SpongeTreeLayout.collectElements(this.tree.getRootAdvancement(), elements); + SpongeTreeLayout.collectElements(this.tree.rootAdvancement(), elements); return elements.build(); } private static void collectElements(final Advancement advancement, final ImmutableSet.Builder elements) { - advancement.getDisplayInfo().ifPresent(displayInfo -> elements.add((TreeLayoutElement) displayInfo)); - advancement.getChildren().forEach(child -> SpongeTreeLayout.collectElements(child, elements)); + advancement.displayInfo().ifPresent(displayInfo -> elements.add((TreeLayoutElement) displayInfo)); + advancement.children().forEach(child -> SpongeTreeLayout.collectElements(child, elements)); } @Override - public Optional getElement(final Advancement advancement) { - final Optional tree = advancement.getTree(); - if (!tree.isPresent() || !advancement.getDisplayInfo().isPresent() || !tree.get().equals(this.tree)) { + public Optional element(final Advancement advancement) { + final Optional tree = advancement.tree(); + if (!tree.isPresent() || !advancement.displayInfo().isPresent() || !tree.get().equals(this.tree)) { return Optional.empty(); } - return SpongeTreeLayout.findElementInfo(this.tree.getRootAdvancement(), advancement.getKey()).map(TreeLayoutElement.class::cast); + return SpongeTreeLayout.findElementInfo(this.tree.rootAdvancement(), advancement.key()).map(TreeLayoutElement.class::cast); } private static Optional findElementInfo(Advancement advancement, ResourceKey key) { - if (advancement.getKey().equals(key)) { - return advancement.getDisplayInfo(); + if (advancement.key().equals(key)) { + return advancement.displayInfo(); } - for (Advancement child : advancement.getChildren()) { + for (Advancement child : advancement.children()) { final Optional info = SpongeTreeLayout.findElementInfo(child, key); if (info.isPresent()) { return info; diff --git a/src/main/java/org/spongepowered/common/advancement/SpongeTriggerBuilder.java b/src/main/java/org/spongepowered/common/advancement/SpongeTriggerBuilder.java index 64cf2d742a7..ac1fc87d901 100644 --- a/src/main/java/org/spongepowered/common/advancement/SpongeTriggerBuilder.java +++ b/src/main/java/org/spongepowered/common/advancement/SpongeTriggerBuilder.java @@ -86,7 +86,7 @@ public Trigger.Build private static ConfigurationOptions defaultOptions() { return ConfigurationOptions.defaults() - .serializers(SpongeCommon.getGame().getConfigManager().getSerializers()); + .serializers(SpongeCommon.getGame().configManager().serializers()); } @Override @@ -178,7 +178,7 @@ public Trigger build0() { @Override public Trigger.Builder from(final Trigger value) { - this.configType = value.getConfigurationType(); + this.configType = value.configurationType(); if (value instanceof SpongeCriterionTrigger) { this.constructor = (Function) ((SpongeCriterionTrigger) value).constructor; this.eventHandler = (Consumer) ((SpongeCriterionTrigger) value).getEventHandler(); @@ -223,7 +223,7 @@ private DataSerializableConstructor(final Class dataConfigClass) { @Override public C apply(final JsonObject jsonObject) { - final DataBuilder builder = Sponge.getDataManager().getBuilder(this.dataConfigClass).get(); + final DataBuilder builder = Sponge.dataManager().builder(this.dataConfigClass).get(); try { final DataView dataView = JsonDataFormat.serialize(SpongeTriggerBuilder.GSON, jsonObject); return builder.build(dataView).get(); diff --git a/src/main/java/org/spongepowered/common/advancement/criterion/AbstractCriterionBuilder.java b/src/main/java/org/spongepowered/common/advancement/criterion/AbstractCriterionBuilder.java index 802fbeea3ce..2c5381c32fe 100644 --- a/src/main/java/org/spongepowered/common/advancement/criterion/AbstractCriterionBuilder.java +++ b/src/main/java/org/spongepowered/common/advancement/criterion/AbstractCriterionBuilder.java @@ -64,8 +64,8 @@ public T build() { @Override public B from(T value) { - this.trigger = value.getTrigger().orElse(null); - this.name = value.getName(); + this.trigger = value.trigger().orElse(null); + this.name = value.name(); return (B) this; } diff --git a/src/main/java/org/spongepowered/common/advancement/criterion/SpongeAndCriterionProgress.java b/src/main/java/org/spongepowered/common/advancement/criterion/SpongeAndCriterionProgress.java index 8f005486f24..84314436d97 100644 --- a/src/main/java/org/spongepowered/common/advancement/criterion/SpongeAndCriterionProgress.java +++ b/src/main/java/org/spongepowered/common/advancement/criterion/SpongeAndCriterionProgress.java @@ -37,14 +37,14 @@ public SpongeAndCriterionProgress(final AdvancementProgress progress, final Spon } @Override - public SpongeAndCriterion getCriterion() { - return (SpongeAndCriterion) super.getCriterion(); + public SpongeAndCriterion criterion() { + return (SpongeAndCriterion) super.criterion(); } @Override public Optional get0() { Optional time = Optional.empty(); - for (final AdvancementCriterion criterion : this.getCriterion().getCriteria()) { + for (final AdvancementCriterion criterion : this.criterion().criteria()) { final Optional time1 = this.progress.get(criterion).get().get(); if (!time1.isPresent()) { return Optional.empty(); diff --git a/src/main/java/org/spongepowered/common/advancement/criterion/SpongeEmptyCriterion.java b/src/main/java/org/spongepowered/common/advancement/criterion/SpongeEmptyCriterion.java index abcb2d46be6..4f05ef56c98 100644 --- a/src/main/java/org/spongepowered/common/advancement/criterion/SpongeEmptyCriterion.java +++ b/src/main/java/org/spongepowered/common/advancement/criterion/SpongeEmptyCriterion.java @@ -31,12 +31,12 @@ public final class SpongeEmptyCriterion implements DefaultedAdvancementCriterion { @Override - public String getName() { + public String name() { return "empty"; } @Override - public Optional> getTrigger() { + public Optional> trigger() { return Optional.empty(); } } diff --git a/src/main/java/org/spongepowered/common/advancement/criterion/SpongeOperatorCriterion.java b/src/main/java/org/spongepowered/common/advancement/criterion/SpongeOperatorCriterion.java index 80fadbde056..6f5f5e13f5f 100644 --- a/src/main/java/org/spongepowered/common/advancement/criterion/SpongeOperatorCriterion.java +++ b/src/main/java/org/spongepowered/common/advancement/criterion/SpongeOperatorCriterion.java @@ -44,17 +44,17 @@ public class SpongeOperatorCriterion implements OperatorCriterion, DefaultedAdva @Nullable private Collection leafChildrenCriteria; SpongeOperatorCriterion(final String namePrefix, final Collection criteria) { - this.name = namePrefix + Arrays.toString(criteria.stream().map(AdvancementCriterion::getName).toArray(String[]::new)); + this.name = namePrefix + Arrays.toString(criteria.stream().map(AdvancementCriterion::name).toArray(String[]::new)); this.criteria = ImmutableSet.copyOf(criteria); } @Override - public String getName() { + public String name() { return this.name; } @Override - public Optional> getTrigger() { + public Optional> trigger() { return Optional.empty(); } @@ -79,12 +79,12 @@ private Collection getRecursiveChildren() { } @Override - public Collection getCriteria() { + public Collection criteria() { return this.criteria; } @Override - public Collection getLeafCriteria() { + public Collection leafCriteria() { if (this.leafChildrenCriteria == null) { this.leafChildrenCriteria = this.getAllChildrenCriteria0(true); } @@ -94,13 +94,13 @@ public Collection getLeafCriteria() { @Override public Collection find(final String name) { return this.getRecursiveChildren().stream() - .filter(c -> c.getName().equals(name)).collect(ImmutableSet.toImmutableSet()); + .filter(c -> c.name().equals(name)).collect(ImmutableSet.toImmutableSet()); } @Override public Optional findFirst(final String name) { return this.getRecursiveChildren().stream() - .filter(c -> c.getName().equals(name)).findFirst(); + .filter(c -> c.name().equals(name)).findFirst(); } @Override diff --git a/src/main/java/org/spongepowered/common/advancement/criterion/SpongeOperatorCriterionProgress.java b/src/main/java/org/spongepowered/common/advancement/criterion/SpongeOperatorCriterionProgress.java index 431a037ea26..49e97a955c8 100644 --- a/src/main/java/org/spongepowered/common/advancement/criterion/SpongeOperatorCriterionProgress.java +++ b/src/main/java/org/spongepowered/common/advancement/criterion/SpongeOperatorCriterionProgress.java @@ -47,7 +47,7 @@ public abstract class SpongeOperatorCriterionProgress implements ImplementationB } @Override - public SpongeOperatorCriterion getCriterion() { + public SpongeOperatorCriterion criterion() { return this.criterion; } @@ -64,7 +64,7 @@ public Optional get() { @Override public Instant grant() { Instant time = null; - for (final AdvancementCriterion criterion : this.criterion.getCriteria()) { + for (final AdvancementCriterion criterion : this.criterion.criteria()) { final Instant time1 = this.progress.get(criterion).get().grant(); if (time == null || time1.isAfter(time)) { time = time1; @@ -77,7 +77,7 @@ public Instant grant() { @Override public Optional revoke() { final Optional previousState = this.get(); - for (final AdvancementCriterion criterion : this.criterion.getCriteria()) { + for (final AdvancementCriterion criterion : this.criterion.criteria()) { this.progress.get(criterion).get().revoke(); } return previousState; diff --git a/src/main/java/org/spongepowered/common/advancement/criterion/SpongeOrCriterionProgress.java b/src/main/java/org/spongepowered/common/advancement/criterion/SpongeOrCriterionProgress.java index 8c9ff5a6916..f4ea9bce007 100644 --- a/src/main/java/org/spongepowered/common/advancement/criterion/SpongeOrCriterionProgress.java +++ b/src/main/java/org/spongepowered/common/advancement/criterion/SpongeOrCriterionProgress.java @@ -26,8 +26,6 @@ import org.spongepowered.api.advancement.AdvancementProgress; import org.spongepowered.api.advancement.criteria.AdvancementCriterion; -import org.spongepowered.common.advancement.criterion.SpongeOperatorCriterionProgress; -import org.spongepowered.common.advancement.criterion.SpongeOrCriterion; import java.time.Instant; import java.util.Optional; @@ -39,13 +37,13 @@ public SpongeOrCriterionProgress(final AdvancementProgress progress, final Spong } @Override - public SpongeOrCriterion getCriterion() { - return (SpongeOrCriterion) super.getCriterion(); + public SpongeOrCriterion criterion() { + return (SpongeOrCriterion) super.criterion(); } @Override public boolean achieved() { - for (final AdvancementCriterion criterion : this.getCriterion().getCriteria()) { + for (final AdvancementCriterion criterion : this.criterion().criteria()) { final Optional time = this.progress.get(criterion).get().get(); if (time.isPresent()) { return true; @@ -57,7 +55,7 @@ public boolean achieved() { @Override public Optional get0() { Optional time = Optional.empty(); - for (final AdvancementCriterion criterion : this.getCriterion().getCriteria()) { + for (final AdvancementCriterion criterion : this.criterion().criteria()) { final Optional time1 = this.progress.get(criterion).get().get(); if (time1.isPresent() && (!time.isPresent() || time1.get().isAfter(time.get()))) { time = time1; diff --git a/src/main/java/org/spongepowered/common/advancement/criterion/SpongeScoreCriterion.java b/src/main/java/org/spongepowered/common/advancement/criterion/SpongeScoreCriterion.java index 018db68f34f..02caa87c0e9 100644 --- a/src/main/java/org/spongepowered/common/advancement/criterion/SpongeScoreCriterion.java +++ b/src/main/java/org/spongepowered/common/advancement/criterion/SpongeScoreCriterion.java @@ -67,19 +67,19 @@ public SpongeScoreCriterion(final String name, final List> getTrigger() { + public Optional> trigger() { // The first internal criterion holds the trigger - return this.internalCriteria.get(0).getTrigger(); + return this.internalCriteria.get(0).trigger(); } @Override diff --git a/src/main/java/org/spongepowered/common/advancement/criterion/SpongeScoreCriterionBuilder.java b/src/main/java/org/spongepowered/common/advancement/criterion/SpongeScoreCriterionBuilder.java index 57d0684e026..c4aeead89a5 100644 --- a/src/main/java/org/spongepowered/common/advancement/criterion/SpongeScoreCriterionBuilder.java +++ b/src/main/java/org/spongepowered/common/advancement/criterion/SpongeScoreCriterionBuilder.java @@ -45,7 +45,7 @@ ScoreAdvancementCriterion build0() { @Override public ScoreAdvancementCriterion.Builder from(final ScoreAdvancementCriterion value) { - this.goal = value.getGoal(); + this.goal = value.goal(); return super.from(value); } diff --git a/src/main/java/org/spongepowered/common/advancement/criterion/SpongeScoreCriterionProgress.java b/src/main/java/org/spongepowered/common/advancement/criterion/SpongeScoreCriterionProgress.java index 014ff8f44e2..79bb20ba350 100644 --- a/src/main/java/org/spongepowered/common/advancement/criterion/SpongeScoreCriterionProgress.java +++ b/src/main/java/org/spongepowered/common/advancement/criterion/SpongeScoreCriterionProgress.java @@ -57,12 +57,12 @@ public SpongeScoreCriterionProgress(final AdvancementProgress progress, final Sp } @Override - public ScoreAdvancementCriterion getCriterion() { + public ScoreAdvancementCriterion criterion() { return this.criterion; } @Override - public int getScore() { + public int score() { if (this.score == -1) { this.score = 0; for (final AdvancementCriterion criterion : this.criterion.internalCriteria) { @@ -77,31 +77,31 @@ public int getScore() { @Override public Optional set(final int score) { - checkState(score >= 0 && score <= this.getGoal(), "Score cannot be negative or greater than the goal."); - int lastScore = this.getScore(); + checkState(score >= 0 && score <= this.goal(), "Score cannot be negative or greater than the goal."); + int lastScore = this.score(); if (lastScore == score) { return this.get(); } final CriterionEvent.Score.Change event; - final Cause cause = PhaseTracker.getCauseStackManager().getCurrentCause(); - final Advancement advancement = this.progress.getAdvancement(); + final Cause cause = PhaseTracker.getCauseStackManager().currentCause(); + final Advancement advancement = this.progress.advancement(); final ServerPlayer player = ((PlayerAdvancementsBridge) ((AdvancementProgressBridge) this.progress).bridge$getPlayerAdvancements()).bridge$getPlayer(); - if (lastScore == this.getGoal()) { + if (lastScore == this.goal()) { event = SpongeEventFactory.createCriterionEventScoreRevoke( - cause, advancement, this.getCriterion(), player, lastScore, score); - } else if (score == this.getGoal()) { + cause, advancement, this.criterion(), player, lastScore, score); + } else if (score == this.goal()) { event = SpongeEventFactory.createCriterionEventScoreGrant( - cause, advancement, this.getCriterion(), player, Instant.now(), lastScore, score); + cause, advancement, this.criterion(), player, Instant.now(), lastScore, score); } else { event = SpongeEventFactory.createCriterionEventScoreChange( - cause, advancement, this.getCriterion(), player, lastScore, score); + cause, advancement, this.criterion(), player, lastScore, score); } if (SpongeCommon.postEvent(event)) { return this.get(); } SpongeScoreCriterion.BYPASS_EVENT = true; // This is the only case a instant will be returned - if (score == this.getGoal()) { + if (score == this.goal()) { Instant instant = null; for (final AdvancementCriterion criterion : this.criterion.internalCriteria) { final org.spongepowered.api.advancement.criteria.CriterionProgress progress = this.progress.get(criterion).get(); @@ -136,12 +136,12 @@ public Optional set(final int score) { @Override public Optional add(final int score) { - return this.set(Mth.clamp(this.getScore() + score, 0, this.getGoal())); + return this.set(Mth.clamp(this.score() + score, 0, this.goal())); } @Override public Optional remove(final int score) { - return this.set(Mth.clamp(this.getScore() - score, 0, this.getGoal())); + return this.set(Mth.clamp(this.score() - score, 0, this.goal())); } @Override @@ -160,7 +160,7 @@ public Optional get() { @Override public Instant grant() { - return this.set(this.getGoal()).get(); + return this.set(this.goal()).get(); } @Override diff --git a/src/main/java/org/spongepowered/common/adventure/AdventureRegistryImpl.java b/src/main/java/org/spongepowered/common/adventure/AdventureRegistryImpl.java index 2c65d7efb91..787d834a733 100644 --- a/src/main/java/org/spongepowered/common/adventure/AdventureRegistryImpl.java +++ b/src/main/java/org/spongepowered/common/adventure/AdventureRegistryImpl.java @@ -49,42 +49,42 @@ public final class AdventureRegistryImpl implements AdventureRegistry { private final OfType soundSources = new ForIndex<>(Sound.Source.NAMES); @Override - public OfType getDecorations() { + public OfType decorations() { return this.decorations; } @Override - public OfType getNamedColors() { + public OfType namedColors() { return this.namedColors; } @Override - public OfType getClickEventActions() { + public OfType clickEventActions() { return this.clickEventActions; } @Override - public OfType> getHoverEventActions() { + public OfType> hoverEventActions() { return this.hoverEventActions; } @Override - public OfType getBossBarColors() { + public OfType bossBarColors() { return this.bossBarColors; } @Override - public OfType getBossBarOverlays() { + public OfType bossBarOverlays() { return this.bossBarOverlays; } @Override - public OfType getBossBarFlags() { + public OfType bossBarFlags() { return this.bossBarFlags; } @Override - public OfType getSoundSources() { + public OfType soundSources() { return this.soundSources; } @@ -96,12 +96,12 @@ static class ForIndex implements OfType { } @Override - public String getKey(final T value) { + public String key(final T value) { return this.registry.key(value); } @Override - public Optional getValue(final String key) { + public Optional value(final String key) { return Optional.ofNullable(this.registry.value(key)); } diff --git a/src/main/java/org/spongepowered/common/adventure/SpongeCallback.java b/src/main/java/org/spongepowered/common/adventure/SpongeCallback.java index b64a7116ff9..f6bd09ebd20 100644 --- a/src/main/java/org/spongepowered/common/adventure/SpongeCallback.java +++ b/src/main/java/org/spongepowered/common/adventure/SpongeCallback.java @@ -62,9 +62,9 @@ public Command.Parameterized createCommand() { this.executors.invalidateAll(); return Command.builder() - .setShortDescription(Component.text("Execute a callback registered as part of a TextComponent. Primarily for internal use")) - .parameter(Parameter.builder(TypeTokens.COMMAND_CAUSE_CONSUMER).setKey(this.executorKey).parser(new CallbackValueParameter()).build()) - .setExecutor(this::commandCallback) + .shortDescription(Component.text("Execute a callback registered as part of a TextComponent. Primarily for internal use")) + .addParameter(Parameter.builder(TypeTokens.COMMAND_CAUSE_CONSUMER).key(this.executorKey).addParser(new CallbackValueParameter()).build()) + .executor(this::commandCallback) .build(); } @@ -75,7 +75,7 @@ public UUID registerCallback(final Consumer causeConsumer) { } public CommandResult commandCallback(@NonNull final CommandContext context) throws CommandException { - context.requireOne(this.executorKey).accept(context.getCause()); + context.requireOne(this.executorKey).accept(context.cause()); return CommandResult.success(); } @@ -90,7 +90,7 @@ public List complete(@NonNull final CommandContext context, final String @Override @NonNull - public Optional> getValue( + public Optional> parseValue( final Parameter.@NonNull Key> parameterKey, final ArgumentReader.@NonNull Mutable reader, final CommandContext.@NonNull Builder context) throws ArgumentParseException { diff --git a/src/main/java/org/spongepowered/common/adventure/SpongeResolveOperation.java b/src/main/java/org/spongepowered/common/adventure/SpongeResolveOperation.java index 96c0d96a784..f1cffa0dd28 100644 --- a/src/main/java/org/spongepowered/common/adventure/SpongeResolveOperation.java +++ b/src/main/java/org/spongepowered/common/adventure/SpongeResolveOperation.java @@ -50,7 +50,7 @@ public static SpongeResolveOperation newCustomTranslations() { return new SpongeResolveOperation() { @Override public Component resolve(final Component input, final CommandCause senderContext, final @Nullable Entity viewer) { - final Locale targetLocale = viewer instanceof ServerPlayer ? ((ServerPlayer) viewer).getLocale() : Locale.getDefault(); + final Locale targetLocale = viewer instanceof ServerPlayer ? ((ServerPlayer) viewer).locale() : Locale.getDefault(); return GlobalTranslator.render(input, targetLocale); } }; diff --git a/src/main/java/org/spongepowered/common/asset/SpongeAsset.java b/src/main/java/org/spongepowered/common/asset/SpongeAsset.java index 4699002dca2..37e038734c0 100644 --- a/src/main/java/org/spongepowered/common/asset/SpongeAsset.java +++ b/src/main/java/org/spongepowered/common/asset/SpongeAsset.java @@ -40,12 +40,12 @@ public final class SpongeAsset implements Asset { } @Override - public PluginContainer getOwner() { + public PluginContainer owner() { return this.plugin; } @Override - public URL getUrl() { + public URL url() { return this.url; } } diff --git a/src/main/java/org/spongepowered/common/asset/SpongeAssetManager.java b/src/main/java/org/spongepowered/common/asset/SpongeAssetManager.java index 08fd6cd5c4b..5461134d3d3 100644 --- a/src/main/java/org/spongepowered/common/asset/SpongeAssetManager.java +++ b/src/main/java/org/spongepowered/common/asset/SpongeAssetManager.java @@ -44,7 +44,7 @@ public final class SpongeAssetManager implements AssetManager { private static final ClassLoader CLASS_LOADER = Sponge.class.getClassLoader(); @Override - public Optional getAsset(final PluginContainer container, final String name) { + public Optional asset(final PluginContainer container, final String name) { checkNotNull(container); checkNotNull(name); checkArgument(!name.isEmpty(), "name cannot be empty"); @@ -57,7 +57,7 @@ public Optional getAsset(final PluginContainer container, final String na } @Override - public Optional getAsset(String name) { - return this.getAsset(SpongeCommon.getPlugin(), name); + public Optional asset(String name) { + return this.asset(SpongeCommon.getPlugin(), name); } } diff --git a/src/main/java/org/spongepowered/common/ban/SpongeBanBuilder.java b/src/main/java/org/spongepowered/common/ban/SpongeBanBuilder.java index 2b9e5d82f28..cb9e2da252b 100644 --- a/src/main/java/org/spongepowered/common/ban/SpongeBanBuilder.java +++ b/src/main/java/org/spongepowered/common/ban/SpongeBanBuilder.java @@ -138,18 +138,18 @@ private Date toDate(final Instant instant) { @Override public Ban.Builder from(final Ban ban) { this.reset(); - this.banType = ban.getType(); + this.banType = ban.type(); if (this.banType.equals(BanTypes.PROFILE.get())) { - this.profile = ((Ban.Profile) ban).getProfile(); + this.profile = ((Ban.Profile) ban).profile(); } else { - this.address = ((Ban.IP) ban).getAddress(); + this.address = ((Ban.IP) ban).address(); } - this.reason = ban.getReason().orElse(null); - this.start = ban.getCreationDate(); - this.end = ban.getExpirationDate().orElse(null); - this.source = ban.getBanSource().orElse(null); + this.reason = ban.reason().orElse(null); + this.start = ban.creationDate(); + this.end = ban.expirationDate().orElse(null); + this.source = ban.banSource().orElse(null); return this; } diff --git a/src/main/java/org/spongepowered/common/ban/SpongeBanType.java b/src/main/java/org/spongepowered/common/ban/SpongeBanType.java index 925999c59e3..10174f7494b 100644 --- a/src/main/java/org/spongepowered/common/ban/SpongeBanType.java +++ b/src/main/java/org/spongepowered/common/ban/SpongeBanType.java @@ -36,7 +36,7 @@ public SpongeBanType(final Class banClass) { } @Override - public Class getBanClass() { + public Class banClass() { return this.banClass; } } diff --git a/src/main/java/org/spongepowered/common/block/SpongeBlockSnapshot.java b/src/main/java/org/spongepowered/common/block/SpongeBlockSnapshot.java index 12ecefa681a..3489d3d0501 100644 --- a/src/main/java/org/spongepowered/common/block/SpongeBlockSnapshot.java +++ b/src/main/java/org/spongepowered/common/block/SpongeBlockSnapshot.java @@ -96,7 +96,7 @@ public final class SpongeBlockSnapshot implements BlockSnapshot, SpongeImmutable } @Override - public BlockState getState() { + public BlockState state() { return this.blockState; } @@ -111,17 +111,17 @@ public BlockSnapshot withContainer(final DataContainer container) { } @Override - public ResourceKey getWorld() { + public ResourceKey world() { return this.worldKey; } @Override - public Vector3i getPosition() { + public Vector3i position() { return this.pos; } @Override - public Optional getLocation() { + public Optional location() { return this.getServerWorld() .map(world -> ServerLocation.of((org.spongepowered.api.world.server.ServerWorld) world, this.pos)); } @@ -214,12 +214,12 @@ public boolean restore(final boolean force, final BlockChangeFlag flag) { } @Override - public Optional getCreator() { + public Optional creator() { return Optional.empty(); } @Override - public Optional getNotifier() { + public Optional notifier() { return Optional.empty(); } @@ -244,20 +244,20 @@ public BlockSnapshot copy() { } @Override - public int getContentVersion() { + public int contentVersion() { return 1; } @Override public DataContainer toContainer() { final DataContainer container = DataContainer.createNew() - .set(Queries.CONTENT_VERSION, getContentVersion()) + .set(Queries.CONTENT_VERSION, contentVersion()) .set(Queries.WORLD_KEY, this.worldKey.asString()) .createView(Constants.Sponge.SNAPSHOT_WORLD_POSITION) .set(Queries.POSITION_X, this.pos.getX()) .set(Queries.POSITION_Y, this.pos.getY()) .set(Queries.POSITION_Z, this.pos.getZ()) - .getContainer() + .container() .set(Constants.Block.BLOCK_STATE, this.blockState); if (this.compound != null) { container.set(Constants.Sponge.UNSAFE_NBT, NBTTranslator.INSTANCE.translateFrom(this.compound)); @@ -268,7 +268,7 @@ public DataContainer toContainer() { public Optional getServerWorld() { @Nullable ServerLevel world = this.world != null ? this.world.get() : null; if (world == null) { - world = (ServerLevel) Sponge.getServer().getWorldManager().world(this.worldKey).orElse(null); + world = (ServerLevel) Sponge.server().worldManager().world(this.worldKey).orElse(null); if (world != null) { this.world = new WeakReference<>(world); } @@ -322,7 +322,7 @@ public SpongeBlockSnapshotBuilder createBuilder() { @Override public List impl$delegateDataHolder() { - return Arrays.asList(this, this.getState()); + return Arrays.asList(this, this.state()); } @Override diff --git a/src/main/java/org/spongepowered/common/block/SpongeBlockSnapshotBuilder.java b/src/main/java/org/spongepowered/common/block/SpongeBlockSnapshotBuilder.java index 64e56a46c6e..ed393ae2bc3 100644 --- a/src/main/java/org/spongepowered/common/block/SpongeBlockSnapshotBuilder.java +++ b/src/main/java/org/spongepowered/common/block/SpongeBlockSnapshotBuilder.java @@ -96,7 +96,7 @@ private SpongeBlockSnapshotBuilder(final boolean pooled) { @Override @NonNull public SpongeBlockSnapshotBuilder world(@NonNull final ServerWorldProperties worldProperties) { - this.worldKey = Objects.requireNonNull(worldProperties).getKey(); + this.worldKey = Objects.requireNonNull(worldProperties).key(); return this; } @@ -106,7 +106,7 @@ public SpongeBlockSnapshotBuilder world(final ResourceKey key) { } public SpongeBlockSnapshotBuilder world(final ServerLevel world) { - this.worldKey = ((org.spongepowered.api.world.server.ServerWorld) Objects.requireNonNull(world)).getKey(); + this.worldKey = ((org.spongepowered.api.world.server.ServerWorld) Objects.requireNonNull(world)).key(); this.worldRef = new WeakReference<>(world); return this; } @@ -172,7 +172,7 @@ public BlockSnapshot empty() { this.blockState = this.blockState.with(key, value) .orElseThrow(() -> new IllegalArgumentException(String.format("Key %s is not supported for block state %s", - key.getKey().asString(), + key.key().asString(), this.blockState.toString()))); return this; } @@ -182,26 +182,26 @@ public BlockSnapshot empty() { public SpongeBlockSnapshotBuilder from(final BlockSnapshot holder) { Objects.requireNonNull(holder); - this.blockState = holder.getState(); - this.worldKey = holder.getWorld(); - if (holder.getCreator().isPresent()) { - this.creatorUniqueId = holder.getCreator().get(); + this.blockState = holder.state(); + this.worldKey = holder.world(); + if (holder.creator().isPresent()) { + this.creatorUniqueId = holder.creator().get(); } - if (holder.getNotifier().isPresent()) { - this.notifierUniqueId = holder.getNotifier().get(); + if (holder.notifier().isPresent()) { + this.notifierUniqueId = holder.notifier().get(); } - this.coordinates = holder.getPosition(); + this.coordinates = holder.position(); return this; } public SpongeBlockSnapshotBuilder from(final SpongeBlockSnapshot snapshot) { Objects.requireNonNull(snapshot); - this.blockState = snapshot.getState(); - this.worldKey = snapshot.getWorld(); + this.blockState = snapshot.state(); + this.worldKey = snapshot.world(); this.worldRef = snapshot.world; this.compound = snapshot.compound; - this.coordinates = snapshot.getPosition(); + this.coordinates = snapshot.position(); this.flag = snapshot.getChangeFlag(); return this; } @@ -277,7 +277,7 @@ protected Optional buildContent(final DataView container) throws return Optional.empty(); } final UUID uuid = UUID.fromString(container.getString(Constants.Sponge.BlockSnapshot.WORLD_UUID).get()); - Sponge.getServer().getWorldManager().worldKey(uuid).ifPresent(worldKey -> container.set(Queries.WORLD_KEY, worldKey)); + Sponge.server().worldManager().worldKey(uuid).ifPresent(worldKey -> container.set(Queries.WORLD_KEY, worldKey)); } DataUtil.checkDataExists(container, Constants.Block.BLOCK_STATE); diff --git a/src/main/java/org/spongepowered/common/block/SpongeBlockStateBuilder.java b/src/main/java/org/spongepowered/common/block/SpongeBlockStateBuilder.java index cb9a904707a..c246db4876c 100644 --- a/src/main/java/org/spongepowered/common/block/SpongeBlockStateBuilder.java +++ b/src/main/java/org/spongepowered/common/block/SpongeBlockStateBuilder.java @@ -27,7 +27,6 @@ import org.checkerframework.checker.nullness.qual.NonNull; import org.spongepowered.api.block.BlockState; import org.spongepowered.api.block.BlockType; -import org.spongepowered.api.block.BlockTypes; import org.spongepowered.api.data.Key; import org.spongepowered.api.data.persistence.AbstractDataBuilder; import org.spongepowered.api.data.persistence.DataView; @@ -49,7 +48,7 @@ public SpongeBlockStateBuilder() { @Override public BlockState.@NonNull Builder blockType(@NonNull final BlockType blockType) { - this.blockState = Objects.requireNonNull(blockType).getDefaultState(); + this.blockState = Objects.requireNonNull(blockType).defaultState(); return this; } diff --git a/src/main/java/org/spongepowered/common/block/entity/SpongeBlockEntityArchetype.java b/src/main/java/org/spongepowered/common/block/entity/SpongeBlockEntityArchetype.java index c8f21e643e9..456849b5bac 100644 --- a/src/main/java/org/spongepowered/common/block/entity/SpongeBlockEntityArchetype.java +++ b/src/main/java/org/spongepowered/common/block/entity/SpongeBlockEntityArchetype.java @@ -68,26 +68,26 @@ public final class SpongeBlockEntityArchetype extends AbstractArchetype apply(final ServerLocation location) { - final BlockState currentState = location.getBlock(); + final BlockState currentState = location.block(); final Block currentBlock = ((net.minecraft.world.level.block.state.BlockState) currentState).getBlock(); final Block newBlock = ((net.minecraft.world.level.block.state.BlockState) this.blockState).getBlock(); - final Level minecraftWorld = (net.minecraft.world.level.Level) location.getWorld(); + final Level minecraftWorld = (net.minecraft.world.level.Level) location.world(); final BlockPos blockpos = VecHelper.toBlockPos(location); if (currentBlock != newBlock) { @@ -113,13 +113,13 @@ public BlockSnapshot toSnapshot(final ServerLocation location) { final SpongeBlockSnapshotBuilder builder = SpongeBlockSnapshotBuilder.pooled(); return builder.blockState(this.blockState) .addUnsafeCompound(this.data.copy()) - .world(location.getWorldKey()) - .position(location.getBlockPosition()) + .world(location.worldKey()) + .position(location.blockPosition()) .build(); } @Override - public int getContentVersion() { + public int contentVersion() { return Constants.Sponge.BlockEntityArchetype.BASE_VERSION; } @@ -128,7 +128,7 @@ public DataContainer toContainer() { return DataContainer.createNew() .set(Constants.Sponge.BlockEntityArchetype.BLOCK_ENTITY_TYPE, this.type) .set(Constants.Sponge.BlockEntityArchetype.BLOCK_STATE, this.blockState) - .set(Constants.Sponge.BlockEntityArchetype.BLOCK_ENTITY_DATA, this.getBlockEntityData()) + .set(Constants.Sponge.BlockEntityArchetype.BLOCK_ENTITY_DATA, this.blockEntityData()) ; } diff --git a/src/main/java/org/spongepowered/common/block/entity/SpongeBlockEntityArchetypeBuilder.java b/src/main/java/org/spongepowered/common/block/entity/SpongeBlockEntityArchetypeBuilder.java index bead97772d2..25365f2227e 100644 --- a/src/main/java/org/spongepowered/common/block/entity/SpongeBlockEntityArchetypeBuilder.java +++ b/src/main/java/org/spongepowered/common/block/entity/SpongeBlockEntityArchetypeBuilder.java @@ -71,9 +71,9 @@ public BlockEntityArchetype.Builder add(final Key> key, f @Override public BlockEntityArchetype.Builder from(final BlockEntityArchetype value) { - this.type = value.getBlockEntityType(); - this.blockState = value.getState(); - this.data = value.getBlockEntityData(); + this.type = value.blockEntityType(); + this.blockState = value.state(); + this.data = value.blockEntityData(); return this; } @@ -98,7 +98,7 @@ public BlockEntityArchetype.Builder blockEntity(final BlockEntityType blockEntit @Override public BlockEntityArchetype.Builder from(final ServerLocation location) { - final BlockEntity tileEntity = location.getBlockEntity() + final BlockEntity tileEntity = location.blockEntity() .orElseThrow(() -> new IllegalArgumentException("There is no block entity available at the provided location: " + location)); return this.blockEntity(tileEntity); @@ -118,8 +118,8 @@ public BlockEntityArchetype.Builder blockEntity(final BlockEntity blockEntity) { compound.remove("id"); compound.putString(Constants.Sponge.BlockEntityArchetype.TILE_ENTITY_ID, tileId); this.data = NBTTranslator.INSTANCE.translate(compound); - this.blockState = blockEntity.getBlock(); - this.type = blockEntity.getType(); + this.blockState = blockEntity.block(); + this.type = blockEntity.type(); return this; } diff --git a/src/main/java/org/spongepowered/common/bridge/explosives/FusedExplosiveBridge.java b/src/main/java/org/spongepowered/common/bridge/explosives/FusedExplosiveBridge.java index 9dde34fea0e..659d4eb9137 100644 --- a/src/main/java/org/spongepowered/common/bridge/explosives/FusedExplosiveBridge.java +++ b/src/main/java/org/spongepowered/common/bridge/explosives/FusedExplosiveBridge.java @@ -45,8 +45,8 @@ public interface FusedExplosiveBridge { default boolean bridge$shouldPrime() { if (ShouldFire.PRIME_EXPLOSIVE_EVENT_PRE) { final PrimeExplosiveEvent.Pre event = SpongeEventFactory.createPrimeExplosiveEventPre( - PhaseTracker.getCauseStackManager().getCurrentCause(), (FusedExplosive) this); - return !Sponge.getEventManager().post(event); + PhaseTracker.getCauseStackManager().currentCause(), (FusedExplosive) this); + return !Sponge.eventManager().post(event); } return true; } @@ -54,16 +54,16 @@ public interface FusedExplosiveBridge { default void bridge$postPrime() { if (ShouldFire.PRIME_EXPLOSIVE_EVENT_POST) { final PrimeExplosiveEvent.Post event = SpongeEventFactory.createPrimeExplosiveEventPost( - PhaseTracker.getCauseStackManager().getCurrentCause(), (FusedExplosive) this); - Sponge.getEventManager().post(event); + PhaseTracker.getCauseStackManager().currentCause(), (FusedExplosive) this); + Sponge.eventManager().post(event); } } default boolean bridge$shouldDefuse() { if (ShouldFire.DEFUSE_EXPLOSIVE_EVENT_PRE) { final DefuseExplosiveEvent.Pre event = SpongeEventFactory.createDefuseExplosiveEventPre( - PhaseTracker.getCauseStackManager().getCurrentCause(), (FusedExplosive) this); - return !Sponge.getEventManager().post(event); + PhaseTracker.getCauseStackManager().currentCause(), (FusedExplosive) this); + return !Sponge.eventManager().post(event); } return true; } @@ -71,8 +71,8 @@ public interface FusedExplosiveBridge { default void bridge$postDefuse() { if (ShouldFire.DEFUSE_EXPLOSIVE_EVENT_POST) { final DefuseExplosiveEvent.Post event = SpongeEventFactory.createDefuseExplosiveEventPost( - PhaseTracker.getCauseStackManager().getCurrentCause(), (FusedExplosive) this); - Sponge.getEventManager().post(event); + PhaseTracker.getCauseStackManager().currentCause(), (FusedExplosive) this); + Sponge.eventManager().post(event); } } } diff --git a/src/main/java/org/spongepowered/common/client/SpongeClient.java b/src/main/java/org/spongepowered/common/client/SpongeClient.java index d28d275ef81..d0382e7888e 100644 --- a/src/main/java/org/spongepowered/common/client/SpongeClient.java +++ b/src/main/java/org/spongepowered/common/client/SpongeClient.java @@ -31,5 +31,5 @@ public interface SpongeClient extends SpongeEngine, Client { @Override - ClientScheduler getScheduler(); + ClientScheduler scheduler(); } diff --git a/src/main/java/org/spongepowered/common/command/SpongeParameterizedCommand.java b/src/main/java/org/spongepowered/common/command/SpongeParameterizedCommand.java index cdbdc310b8f..c7413baa844 100644 --- a/src/main/java/org/spongepowered/common/command/SpongeParameterizedCommand.java +++ b/src/main/java/org/spongepowered/common/command/SpongeParameterizedCommand.java @@ -93,9 +93,9 @@ public void setCommandManager(final SpongeCommandManager commandManager) { @Override @NonNull - public List getSuggestions(final @NonNull CommandCause cause, final ArgumentReader.@NonNull Mutable arguments) { + public List suggestions(final @NonNull CommandCause cause, final ArgumentReader.@NonNull Mutable arguments) { final SpongeCommandDispatcher dispatcher = this.getCachedDispatcher(); - final String input = arguments.getRemaining(); + final String input = arguments.remaining(); final ParseResults parseResults = dispatcher.parse((StringReader) arguments, (CommandSourceStack) cause); final Suggestions suggestions = dispatcher.getCompletionSuggestions(parseResults).join(); return suggestions.getList().stream().map(x -> x.apply(input)).collect(Collectors.toList()); @@ -103,23 +103,23 @@ public List getSuggestions(final @NonNull CommandCause cause, final Argu @Override public boolean canExecute(@NonNull final CommandCause cause) { - return this.getExecutionRequirements().test(cause); + return this.executionRequirements().test(cause); } @Override @NonNull - public Optional getShortDescription(@NonNull final CommandCause cause) { + public Optional shortDescription(@NonNull final CommandCause cause) { return this.shortDescription.apply(cause); } @Override @NonNull - public Optional getExtendedDescription(@NonNull final CommandCause cause) { + public Optional extendedDescription(@NonNull final CommandCause cause) { return this.extendedDescription.apply(cause); } @Override - public @NonNull Component getUsage(final @NonNull CommandCause cause) { + public @NonNull Component usage(final @NonNull CommandCause cause) { final Collection usage = Arrays.stream(this.getCachedDispatcher().getAllUsage(this.getCachedDispatcher().getRoot(), (CommandSourceStack) cause, true)) .map(Component::text).collect(Collectors.toList()); @@ -149,7 +149,7 @@ public boolean isTerminal() { @Override @NonNull - public Predicate getExecutionRequirements() { + public Predicate executionRequirements() { return this.executionRequirements; } @@ -157,11 +157,11 @@ public Predicate getExecutionRequirements() { @NonNull public CommandContext parseArguments(@NonNull final CommandCause cause, final ArgumentReader.@NonNull Mutable arguments) { final ParseResults results = this.getCachedDispatcher().parse((SpongeStringReader) arguments, (CommandSourceStack) cause); - return (CommandContext) results.getContext().build(arguments.getInput()); + return (CommandContext) results.getContext().build(arguments.input()); } @Override - public Optional getExecutor() { + public Optional executor() { return Optional.ofNullable(this.executor); } diff --git a/src/main/java/org/spongepowered/common/command/SpongeParameterizedCommandBuilder.java b/src/main/java/org/spongepowered/common/command/SpongeParameterizedCommandBuilder.java index e57da9edf39..b8b50a5d5e0 100644 --- a/src/main/java/org/spongepowered/common/command/SpongeParameterizedCommandBuilder.java +++ b/src/main/java/org/spongepowered/common/command/SpongeParameterizedCommandBuilder.java @@ -61,7 +61,7 @@ public final class SpongeParameterizedCommandBuilder implements Command.Paramete private boolean isTerminal = false; @Override - public Command.@NonNull Builder child(final Command.@NonNull Parameterized child, @NonNull final Iterable aliases) { + public Command.@NonNull Builder addChild(final Command.@NonNull Parameterized child, @NonNull final Iterable aliases) { for (final String alias : aliases) { if (this.claimedSubcommands.contains(alias.toLowerCase())) { throw new IllegalStateException("The alias " + alias + " already has an associated subcommand."); @@ -76,32 +76,32 @@ public final class SpongeParameterizedCommandBuilder implements Command.Paramete } @Override - public Command.@NonNull Builder flag(@NonNull final Flag flag) { - for (final String alias : flag.getAliases()) { + public Command.@NonNull Builder addFlag(@NonNull final Flag flag) { + for (final String alias : flag.aliases()) { if (this.flagAliases.contains(alias)) { throw new IllegalArgumentException("The alias " + alias + " is already in use."); } } this.flags.add(flag); - this.flagAliases.addAll(flag.getAliases()); + this.flagAliases.addAll(flag.aliases()); return this; } @Override - public Command.@NonNull Builder parameter(@NonNull final Parameter parameter) { + public Command.@NonNull Builder addParameter(@NonNull final Parameter parameter) { this.parameters.add(parameter); return this; } @Override - public Command.@NonNull Builder setExecutor(@NonNull final CommandExecutor executor) { + public Command.@NonNull Builder executor(@NonNull final CommandExecutor executor) { this.commandExecutor = executor; return this; } @Override - public Command.@NonNull Builder setExtendedDescription(@Nullable final Function> extendedDescriptionFunction) { + public Command.@NonNull Builder extendedDescription(@Nullable final Function> extendedDescriptionFunction) { if (extendedDescriptionFunction == null) { this.extendedDescription = cause -> Optional.empty(); } else { @@ -111,7 +111,7 @@ public final class SpongeParameterizedCommandBuilder implements Command.Paramete } @Override - public Command.@NonNull Builder setShortDescription(@Nullable final Function> descriptionFunction) { + public Command.@NonNull Builder shortDescription(@Nullable final Function> descriptionFunction) { if (descriptionFunction == null) { this.shortDescription = cause -> Optional.empty(); } else { @@ -121,21 +121,21 @@ public final class SpongeParameterizedCommandBuilder implements Command.Paramete } @Override - public Command.@NonNull Builder setPermission(@Nullable final String permission) { + public Command.@NonNull Builder permission(@Nullable final String permission) { if (permission == null) { - return this.setExecutionRequirements(null); + return this.executionRequirements(null); } - return this.setExecutionRequirements(commandCause -> commandCause.hasPermission(permission)); + return this.executionRequirements(commandCause -> commandCause.hasPermission(permission)); } @Override - public Command.@NonNull Builder setExecutionRequirements(@Nullable final Predicate executionRequirements) { + public Command.@NonNull Builder executionRequirements(@Nullable final Predicate executionRequirements) { this.executionRequirements = executionRequirements; return this; } @Override - public Command.@NonNull Builder setTerminal(final boolean terminal) { + public Command.@NonNull Builder terminal(final boolean terminal) { this.isTerminal = terminal; return this; } @@ -152,7 +152,7 @@ public final class SpongeParameterizedCommandBuilder implements Command.Paramete final List subcommands = this.subcommands.entrySet().stream() - .map(x -> new SpongeSubcommandParameterBuilder().aliases(x.getValue()).setSubcommand(x.getKey()).build()) + .map(x -> new SpongeSubcommandParameterBuilder().aliases(x.getValue()).subcommand(x.getKey()).build()) .collect(Collectors.toList()); // build the node. diff --git a/src/main/java/org/spongepowered/common/command/brigadier/SpongeImmutableArgumentReader.java b/src/main/java/org/spongepowered/common/command/brigadier/SpongeImmutableArgumentReader.java index 337ebf62b8b..fe3cab2cb28 100644 --- a/src/main/java/org/spongepowered/common/command/brigadier/SpongeImmutableArgumentReader.java +++ b/src/main/java/org/spongepowered/common/command/brigadier/SpongeImmutableArgumentReader.java @@ -50,30 +50,55 @@ public String getString() { return this.input; } + @Override + public int getRemainingLength() { + return this.remainingLength(); + } + + @Override + public int getTotalLength() { + return this.totalLength(); + } + + @Override + public int getCursor() { + return this.cursor; + } + + @Override + public String getRead() { + return this.parsed(); + } + + @Override + public String getRemaining() { + return this.remaining(); + } + @Override @NonNull - public String getInput() { + public String input() { return this.input; } @Override - public int getRemainingLength() { + public int remainingLength() { return this.remaining; } @Override - public int getTotalLength() { + public int totalLength() { return this.length; } @Override - public int getCursor() { + public int cursor() { return this.cursor; } @Override @NonNull - public String getRead() { + public String parsed() { if (this.cursor == 0) { return ""; } @@ -82,7 +107,7 @@ public String getRead() { @Override @NonNull - public String getRemaining() { + public String remaining() { return this.input.substring(this.cursor); } @@ -107,7 +132,7 @@ public char peekCharacter() { @Override @NonNull public ArgumentParseException createException(@NonNull final Component errorMessage) { - return new ArgumentParseException(errorMessage, this.getInput(), this.getCursor()); + return new ArgumentParseException(errorMessage, this.input(), this.cursor()); } @Override @@ -122,7 +147,7 @@ public char peek(final int offset) { @Override @SuppressWarnings("ConstantConditions") // suppressed due to ArgumentReader.Mutable being mixed into StringReader. - public ArgumentReader.@NonNull Mutable getMutable() { + public ArgumentReader.@NonNull Mutable mutable() { final StringReader reader = new StringReader(this.input); reader.setCursor(this.cursor); return (ArgumentReader.Mutable) reader; diff --git a/src/main/java/org/spongepowered/common/command/brigadier/SpongeParameterTranslator.java b/src/main/java/org/spongepowered/common/command/brigadier/SpongeParameterTranslator.java index 920b4a5e340..34a736aecaf 100644 --- a/src/main/java/org/spongepowered/common/command/brigadier/SpongeParameterTranslator.java +++ b/src/main/java/org/spongepowered/common/command/brigadier/SpongeParameterTranslator.java @@ -73,12 +73,12 @@ public Collection> createCommandTree(fina final Iterator aliasIterator = sortedAliases.iterator(); final String baseAlias = aliasIterator.next(); - final SpongeCommandExecutorWrapper executor = command.getExecutor().map(SpongeCommandExecutorWrapper::new).orElse(null); + final SpongeCommandExecutorWrapper executor = command.executor().map(SpongeCommandExecutorWrapper::new).orElse(null); // Create the defining characteristics of the node. final LiteralArgumentBuilder basicNode = LiteralArgumentBuilder.literal(baseAlias); - basicNode.requires((Predicate) command.getExecutionRequirements()); + basicNode.requires((Predicate) command.executionRequirements()); if (command.isTerminal() && executor != null) { basicNode.executes(executor); } @@ -90,7 +90,7 @@ public Collection> createCommandTree(fina for (final Parameter.Subcommand subcommand : command.subcommands()) { final Collection> builtSubcommand = - this.createCommandTree(subcommand.getCommand(), subcommand.getAliases()); + this.createCommandTree(subcommand.command(), subcommand.aliases()); builtSubcommand.forEach(commandNode::addChild); } @@ -115,15 +115,15 @@ private void createFlags(final LiteralCommandNode node, fina final Collection> nodesToAddChildrenTo = new ArrayList<>(); for (final Flag flag : flags) { // first create the literal. - final Iterator aliasIterator = flag.getAliases().iterator(); + final Iterator aliasIterator = flag.aliases().iterator(); final LiteralArgumentBuilder flagLiteral = LiteralArgumentBuilder.literal(aliasIterator.next()); - flagLiteral.requires((Predicate) flag.getRequirement()); + flagLiteral.requires((Predicate) flag.requirement()); final Collection> toBeRedirected; final SpongeFlagLiteralCommandNode flagNode = new SpongeFlagLiteralCommandNode(flagLiteral, flag); - if (flag.getAssociatedParameter().isPresent()) { + if (flag.associatedParameter().isPresent()) { toBeRedirected = this.createAndAttachNode( Collections.singleton(flagNode), - Collections.singletonList(flag.getAssociatedParameter().get()), + Collections.singletonList(flag.associatedParameter().get()), wrapper, node.getCommand() != null, false @@ -184,7 +184,7 @@ private Collection> createAndAttachNod final Parameter.Subcommand subcommands = ((Parameter.Subcommand) parameter); if (!allowSubcommands) { throw new IllegalStateException("Subcommands are not allowed for this element (subcommands were " + - String.join(", ", subcommands.getAliases() + ")!")); + String.join(", ", subcommands.aliases() + ")!")); } if (hasNext) { // this is a failure condition because there cannot be a parameter after a subcommand. @@ -193,8 +193,8 @@ private Collection> createAndAttachNod // If the child is a subcommand, get the subcommand and attach it. At this point, // we're done with the chain and we break out. final Collection> nodes = this.createCommandTree( - subcommands.getCommand(), - subcommands.getAliases() + subcommands.command(), + subcommands.aliases() ); for (final LiteralCommandNode node : nodes) { nodesToAttachTo.forEach(x -> x.addChild(node)); @@ -212,7 +212,7 @@ private Collection> createAndAttachNod if (parameter instanceof SpongeFirstOfParameter) { // take each parameter in turn and evaluate it, returns the terminal nodes of each block parametersToAttachTo = new ArrayList<>(); - for (final Parameter p : ((SpongeFirstOfParameter) parameter).getChildParameters()) { + for (final Parameter p : ((SpongeFirstOfParameter) parameter).childParameters()) { final Collection> branchNodesToAttachTo = this.createAndAttachNode( nodesToAttachTo, Collections.singletonList(p), @@ -225,7 +225,7 @@ private Collection> createAndAttachNod // not so fancy stuff, it's a sequence, returns the terminal nodes of the block parametersToAttachTo = new ArrayList<>(this.createAndAttachNode( nodesToAttachTo, - ((SpongeMultiParameter) parameter).getChildParameters(), + ((SpongeMultiParameter) parameter).childParameters(), executorWrapper, !hasNext || parameter.isTerminal(), allowSubcommands)); @@ -250,7 +250,7 @@ private Collection> createAndAttachNod .flatMap(x -> x.getChildren().stream()) .map(CommandNode::getName) .collect(Collectors.toSet()); - String key = valueParameter.getKey().key(); + String key = valueParameter.key().key(); while (names.contains(key)) { if (suffix == null) { suffix = new StringBuilder(String.valueOf(names.size())); @@ -311,18 +311,18 @@ private static SpongeArgumentCommandNodeBuilder createArgumentN ArgumentParser type = parameter.getArgumentTypeIfStandard(); if (type == null) { - type = new CustomArgumentParser<>(parameter.getParsers(), parameter.getCompleter(), false); + type = new CustomArgumentParser<>(parameter.parsers(), parameter.completer(), false); } final SpongeArgumentCommandNodeBuilder argumentBuilder = new SpongeArgumentCommandNodeBuilder<>( - SpongeParameterKey.getSpongeKey(parameter.getKey()), + SpongeParameterKey.getSpongeKey(parameter.key()), type, - parameter.getCompleter(), - parameter.getValueUsage().orElse(null), + parameter.completer(), + parameter.valueUsage().orElse(null), suffix ); // CommandCause is mixed into CommandSource, so this is okay. - argumentBuilder.requires((Predicate) parameter.getRequirement()); + argumentBuilder.requires((Predicate) parameter.requirement()); return argumentBuilder; } diff --git a/src/main/java/org/spongepowered/common/command/brigadier/SpongeStringReader.java b/src/main/java/org/spongepowered/common/command/brigadier/SpongeStringReader.java index 5ff60e00239..7052950c68b 100644 --- a/src/main/java/org/spongepowered/common/command/brigadier/SpongeStringReader.java +++ b/src/main/java/org/spongepowered/common/command/brigadier/SpongeStringReader.java @@ -40,7 +40,7 @@ import org.spongepowered.common.adventure.SpongeAdventure; import org.spongepowered.common.data.persistence.NBTTranslator; -// ArgumentReader.Mutable specifies a non null getRead() method, StringReader suggests its +// ArgumentReader.Mutable specifies a non null read() method, StringReader suggests its // nullable - but it isn't. So we just need to suppress the warning. // With elements from JsonToNBT for allow this to parse Json for users. @SuppressWarnings("NullableProblems") @@ -66,10 +66,39 @@ public void unskipWhitespace() { @Override @NonNull - public String getInput() { + public String input() { return this.getString(); } + @Override + public int remainingLength() { + return this.getRemainingLength(); + } + + @Override + public int totalLength() { + return this.getTotalLength(); + } + + @Override + public int cursor() { + return this.getCursor(); + } + + @Override + public String parsed() { + final int cursor = this.getCursor(); + if (cursor == 0) { + return ""; + } + return this.getString().substring(0, cursor); + } + + @Override + public String remaining() { + return this.getRemaining(); + } + @Override public char peekCharacter() { if (this.canRead()) { @@ -177,7 +206,7 @@ public String parseNBTString() throws ArgumentParseException { ); } final int endCursor = this.getCursor(); // this will be just after a } - return this.getInput().substring(startCursor, endCursor); + return this.input().substring(startCursor, endCursor); } @Override @@ -191,14 +220,14 @@ public DataContainer parseDataContainer() throws ArgumentParseException { @Override @NonNull - public SpongeImmutableArgumentReader getImmutable() { + public SpongeImmutableArgumentReader immutable() { return new SpongeImmutableArgumentReader(this.getString(), this.getCursor()); } @Override public void setState(@NonNull final ArgumentReader state) throws IllegalArgumentException { - if (state.getInput().equals(this.getString())) { - this.setCursor(state.getCursor()); + if (state.input().equals(this.getString())) { + this.setCursor(state.cursor()); } else { throw new IllegalArgumentException("The provided ArgumentReader does not match this ArgumentReader"); } @@ -207,12 +236,12 @@ public void setState(@NonNull final ArgumentReader state) throws IllegalArgument @Override @NonNull public ArgumentParseException createException(@NonNull final Component errorMessage) { - return new ArgumentParseException(errorMessage, this.getInput(), this.getCursor()); + return new ArgumentParseException(errorMessage, this.input(), this.getCursor()); } @NonNull public ArgumentParseException createException(@NonNull final Component errorMessage, @NonNull final Throwable inner) { - return new ArgumentParseException(errorMessage, inner, this.getInput(), this.getCursor()); + return new ArgumentParseException(errorMessage, inner, this.input(), this.getCursor()); } private ResourceKey readResourceLocation(@Nullable final String defaultNamespace) throws ArgumentParseException { diff --git a/src/main/java/org/spongepowered/common/command/brigadier/argument/AbstractArgumentParser.java b/src/main/java/org/spongepowered/common/command/brigadier/argument/AbstractArgumentParser.java index 9507d737cc4..4d3a3c8ebf6 100644 --- a/src/main/java/org/spongepowered/common/command/brigadier/argument/AbstractArgumentParser.java +++ b/src/main/java/org/spongepowered/common/command/brigadier/argument/AbstractArgumentParser.java @@ -52,10 +52,10 @@ public abstract class AbstractArgumentParser implements ArgumentParser, Su @Override public T parse(final Parameter.Key key, final SpongeCommandContextBuilder contextBuilder, final SpongeStringReader reader) throws CommandSyntaxException { - final ArgumentReader.Immutable state = reader.getImmutable(); + final ArgumentReader.Immutable state = reader.immutable(); final org.spongepowered.api.command.parameter.CommandContext.Builder.Transaction transaction = contextBuilder.startTransaction(); try { - final Optional value = this.getValue(key, reader, contextBuilder); + final Optional value = this.parseValue(key, reader, contextBuilder); contextBuilder.commit(transaction); if (value.isPresent()) { return value.get(); @@ -65,7 +65,7 @@ public T parse(final Parameter.Key key, final SpongeCommandContextBui reader.setState(state); contextBuilder.rollback(transaction); throw CommandSyntaxException.BUILT_IN_EXCEPTIONS.dispatcherParseException() - .createWithContext(reader, e.getSuperText()); + .createWithContext(reader, e.superText()); } return null; } diff --git a/src/main/java/org/spongepowered/common/command/brigadier/argument/CustomArgumentParser.java b/src/main/java/org/spongepowered/common/command/brigadier/argument/CustomArgumentParser.java index 745dfba2855..92e6e55e1c1 100644 --- a/src/main/java/org/spongepowered/common/command/brigadier/argument/CustomArgumentParser.java +++ b/src/main/java/org/spongepowered/common/command/brigadier/argument/CustomArgumentParser.java @@ -68,7 +68,7 @@ public CustomArgumentParser(final Collection> parsers, this.parsers = parsers; this.completer = completer; this.doesNotRead = - doesNotRead || parsers.stream().allMatch(x -> x.getClientCompletionType().contains(ClientCompletionTypes.NONE.get())); + doesNotRead || parsers.stream().allMatch(x -> x.clientCompletionType().contains(ClientCompletionTypes.NONE.get())); // indicates that we should try to parse this even if there is nothing else to parse. if (this.parsers.size() == 1) { final ValueParser parser = this.parsers.iterator().next(); @@ -77,7 +77,7 @@ public CustomArgumentParser(final Collection> parsers, } else if (this.doesNotRead) { this.types = ImmutableList.of(Constants.Command.STANDARD_STRING_ARGUMENT_TYPE); } else { - this.types = parser.getClientCompletionType().stream() + this.types = parser.clientCompletionType().stream() .map(x -> ((SpongeClientCompletionType) x).getType()) .filter(Objects::nonNull) .collect(ImmutableList.toImmutableList()); @@ -91,12 +91,12 @@ public CustomArgumentParser(final Collection> parsers, public T parse(final Parameter.Key key, final SpongeCommandContextBuilder contextBuilder, final SpongeStringReader reader) throws CommandSyntaxException { List exceptions = null; - final ArgumentReader.Immutable state = reader.getImmutable(); + final ArgumentReader.Immutable state = reader.immutable(); Optional value; for (final ValueParser parser : this.parsers) { final org.spongepowered.api.command.parameter.CommandContext.Builder.Transaction transaction = contextBuilder.startTransaction(); try { - value = parser.getValue(key, reader, contextBuilder); + value = parser.parseValue(key, reader, contextBuilder); contextBuilder.commit(transaction); return value.orElse(null); } catch (final Exception e) { diff --git a/src/main/java/org/spongepowered/common/command/brigadier/argument/ResourceKeyedArgumentValueParser.java b/src/main/java/org/spongepowered/common/command/brigadier/argument/ResourceKeyedArgumentValueParser.java index b5ee50b4a6c..384ec2e2ebe 100644 --- a/src/main/java/org/spongepowered/common/command/brigadier/argument/ResourceKeyedArgumentValueParser.java +++ b/src/main/java/org/spongepowered/common/command/brigadier/argument/ResourceKeyedArgumentValueParser.java @@ -36,7 +36,7 @@ public ResourceKeyedArgumentValueParser(final ResourceKey key) { } @Override - public final ResourceKey getKey() { + public final ResourceKey key() { return this.key; } } diff --git a/src/main/java/org/spongepowered/common/command/brigadier/argument/ResourceKeyedZeroAdvanceValueParameter.java b/src/main/java/org/spongepowered/common/command/brigadier/argument/ResourceKeyedZeroAdvanceValueParameter.java index 3eb32da002f..f33972e2aa4 100644 --- a/src/main/java/org/spongepowered/common/command/brigadier/argument/ResourceKeyedZeroAdvanceValueParameter.java +++ b/src/main/java/org/spongepowered/common/command/brigadier/argument/ResourceKeyedZeroAdvanceValueParameter.java @@ -57,7 +57,7 @@ public final List complete(@NonNull final CommandContext context, @NonNu @Override @NonNull - public final Optional getValue( + public final Optional parseValue( final Parameter.@NonNull Key parameterKey, final ArgumentReader.@NonNull Mutable reader, final CommandContext.@NonNull Builder context) @@ -70,7 +70,7 @@ public abstract Optional getValue(final CommandContext.@NonNull Bui @Override @NonNull - public final List getClientCompletionType() { + public final List clientCompletionType() { return ResourceKeyedZeroAdvanceValueParameter.NONE_KEY; } diff --git a/src/main/java/org/spongepowered/common/command/brigadier/argument/StandardArgumentParser.java b/src/main/java/org/spongepowered/common/command/brigadier/argument/StandardArgumentParser.java index eb1b87aa558..d57cad7468c 100644 --- a/src/main/java/org/spongepowered/common/command/brigadier/argument/StandardArgumentParser.java +++ b/src/main/java/org/spongepowered/common/command/brigadier/argument/StandardArgumentParser.java @@ -114,7 +114,7 @@ public List complete(@NonNull final CommandContext context, final String @Override @NonNull - public Optional getValue(final Parameter.@NonNull Key parameterKey, final ArgumentReader.@NonNull Mutable reader, + public Optional parseValue(final Parameter.@NonNull Key parameterKey, final ArgumentReader.@NonNull Mutable reader, final CommandContext.@NonNull Builder context) throws ArgumentParseException { try { diff --git a/src/main/java/org/spongepowered/common/command/brigadier/argument/StandardCatalogedArgumentParser.java b/src/main/java/org/spongepowered/common/command/brigadier/argument/StandardCatalogedArgumentParser.java index 30edc8358f9..d80a5013f2a 100644 --- a/src/main/java/org/spongepowered/common/command/brigadier/argument/StandardCatalogedArgumentParser.java +++ b/src/main/java/org/spongepowered/common/command/brigadier/argument/StandardCatalogedArgumentParser.java @@ -63,7 +63,7 @@ private StandardCatalogedArgumentParser( @Override @NonNull - public ResourceKey getKey() { + public ResourceKey key() { return this.key; } diff --git a/src/main/java/org/spongepowered/common/command/brigadier/context/SpongeCommandContext.java b/src/main/java/org/spongepowered/common/command/brigadier/context/SpongeCommandContext.java index 9b99f59ebe2..377d2f23a63 100644 --- a/src/main/java/org/spongepowered/common/command/brigadier/context/SpongeCommandContext.java +++ b/src/main/java/org/spongepowered/common/command/brigadier/context/SpongeCommandContext.java @@ -46,7 +46,6 @@ import org.spongepowered.api.service.permission.Subject; import java.util.Collection; -import java.util.Collections; import java.util.List; import java.util.Map; import java.util.NoSuchElementException; @@ -91,13 +90,13 @@ public SpongeCommandContext( @Override @NonNull - public Optional getExecutedCommand() { + public Optional executedCommand() { return Optional.ofNullable(this.targetCommand); } @Override @NonNull - public CommandCause getCause() { + public CommandCause cause() { return (CommandCause) this.getSource(); } @@ -108,17 +107,17 @@ public boolean hasFlag(@NonNull final String flagAlias) { @Override public boolean hasFlag(@NonNull final Flag flag) { - return this.flagMap.containsKey(flag.getUnprefixedAliases().iterator().next()); + return this.flagMap.containsKey(flag.unprefixedAliases().iterator().next()); } @Override - public int getFlagInvocationCount(@NonNull final String flagKey) { + public int flagInvocationCount(@NonNull final String flagKey) { return this.flagMap.getOrDefault(flagKey, 0); } @Override - public int getFlagInvocationCount(@NonNull final Flag flag) { - return this.flagMap.getOrDefault(flag.getUnprefixedAliases().iterator().next(), 0); + public int flagInvocationCount(@NonNull final Flag flag) { + return this.flagMap.getOrDefault(flag.unprefixedAliases().iterator().next(), 0); } @Override @@ -132,7 +131,7 @@ public boolean hasAny(final Parameter.@NonNull Key key) { @Override @NonNull - public Optional getOne(final Parameter.@NonNull Key key) { + public Optional one(final Parameter.@NonNull Key key) { return Optional.ofNullable(this.getValue(key)); } @@ -150,7 +149,7 @@ public T requireOne(final Parameter.@NonNull Key key) throws NoSuchElemen @Override @NonNull @SuppressWarnings("unchecked") - public Collection getAll(final Parameter.@NonNull Key key) { + public Collection all(final Parameter.@NonNull Key key) { final Collection values = (Collection) this.argumentMap.get(key); if (values == null) { return ImmutableList.of(); @@ -161,32 +160,32 @@ public Collection getAll(final Parameter.@NonNull Key key) { @Override public boolean hasAny(Parameter.Value parameter) { - return this.hasAny(parameter.getKey()); + return this.hasAny(parameter.key()); } @Override - public Optional getOne(Parameter.Value parameter) throws IllegalArgumentException { - return this.getOne(parameter.getKey()); + public Optional one(Parameter.Value parameter) throws IllegalArgumentException { + return this.one(parameter.key()); } @Override public T requireOne(Parameter.Value parameter) throws NoSuchElementException, IllegalArgumentException { - return this.requireOne(parameter.getKey()); + return this.requireOne(parameter.key()); } @Override - public Collection getAll(Parameter.Value parameter) { - return this.getAll(parameter.getKey()); + public Collection all(Parameter.Value parameter) { + return this.all(parameter.key()); } @Override public void sendMessage(@NonNull final Identified identity, @NonNull final Component message) { - this.getCause().sendMessage(identity, message); + this.cause().sendMessage(identity, message); } @Override public void sendMessage(@NonNull final Identity identity, @NonNull final Component message) { - this.getCause().sendMessage(identity, message); + this.cause().sendMessage(identity, message); } @Override @@ -224,8 +223,8 @@ private T getValue(final Parameter.Key key) { } @Override - public Subject getSubject() { - return this.getCause().getSubject(); + public Subject subject() { + return this.cause().subject(); } } diff --git a/src/main/java/org/spongepowered/common/command/brigadier/context/SpongeCommandContextBuilder.java b/src/main/java/org/spongepowered/common/command/brigadier/context/SpongeCommandContextBuilder.java index 8b28b87680e..6d0aeb41d69 100644 --- a/src/main/java/org/spongepowered/common/command/brigadier/context/SpongeCommandContextBuilder.java +++ b/src/main/java/org/spongepowered/common/command/brigadier/context/SpongeCommandContextBuilder.java @@ -278,18 +278,18 @@ public SpongeCommandContextBuilder copy() { @Override @NonNull - public Optional getExecutedCommand() { + public Optional executedCommand() { if (this.transaction != null && !this.transaction.isEmpty()) { - return this.transaction.peek().getCopyBuilder().getExecutedCommand(); + return this.transaction.peek().getCopyBuilder().executedCommand(); } return Optional.ofNullable(this.currentTargetCommand); } @Override @NonNull - public CommandCause getCause() { + public CommandCause cause() { if (this.transaction != null && !this.transaction.isEmpty()) { - return this.transaction.peek().getCopyBuilder().getCause(); + return this.transaction.peek().getCopyBuilder().cause(); } return (CommandCause) this.getSource(); } @@ -301,17 +301,17 @@ public boolean hasFlag(@NonNull final String flagAlias) { @Override public boolean hasFlag(@NonNull final Flag flag) { - return this.flagMap.containsKey(flag.getUnprefixedAliases().iterator().next()); + return this.flagMap.containsKey(flag.unprefixedAliases().iterator().next()); } @Override - public int getFlagInvocationCount(@NonNull final String flagKey) { + public int flagInvocationCount(@NonNull final String flagKey) { return this.flagMap.getOrDefault(flagKey, 0); } @Override - public int getFlagInvocationCount(@NonNull final Flag flag) { - return this.flagMap.getOrDefault(flag.getUnprefixedAliases().iterator().next(), 0); + public int flagInvocationCount(@NonNull final Flag flag) { + return this.flagMap.getOrDefault(flag.unprefixedAliases().iterator().next(), 0); } @Override @@ -325,7 +325,7 @@ public boolean hasAny(final Parameter.@NonNull Key key) { @Override @NonNull @SuppressWarnings("unchecked") - public Optional getOne(final Parameter.@NonNull Key key) { + public Optional one(final Parameter.@NonNull Key key) { final SpongeParameterKey spongeParameterKey = SpongeParameterKey.getSpongeKey(key); final Collection collection = this.getFrom(spongeParameterKey); if (collection.size() > 1) { @@ -355,38 +355,38 @@ public T requireOne(final Parameter.@NonNull Key key) throws NoSuchElemen @Override @NonNull @SuppressWarnings("unchecked") - public Collection getAll(final Parameter.@NonNull Key key) { + public Collection all(final Parameter.@NonNull Key key) { return (Collection) this.getFrom(SpongeParameterKey.getSpongeKey(key)); } @Override public boolean hasAny(Parameter.Value parameter) { - return this.hasAny(parameter.getKey()); + return this.hasAny(parameter.key()); } @Override - public Optional getOne(Parameter.Value parameter) throws IllegalArgumentException { - return this.getOne(parameter.getKey()); + public Optional one(Parameter.Value parameter) throws IllegalArgumentException { + return this.one(parameter.key()); } @Override public T requireOne(Parameter.Value parameter) throws NoSuchElementException, IllegalArgumentException { - return this.requireOne(parameter.getKey()); + return this.requireOne(parameter.key()); } @Override - public Collection getAll(Parameter.Value parameter) { - return this.getAll(parameter.getKey()); + public Collection all(Parameter.Value parameter) { + return this.all(parameter.key()); } @Override public void sendMessage(@NonNull final Identified identity, @NonNull final Component message) { - this.getCause().sendMessage(identity, message); + this.cause().sendMessage(identity, message); } @Override public void sendMessage(@NonNull final Identity identity, @NonNull final Component message) { - this.getCause().sendMessage(identity, message); + this.cause().sendMessage(identity, message); } Collection getFrom(final SpongeParameterKey key) { @@ -410,7 +410,7 @@ public void addFlagInvocation(@NonNull final Flag flag) { if (this.transaction != null && !this.transaction.isEmpty()) { this.transaction.peek().addFlagInvocation(flag); } else { - flag.getUnprefixedAliases().forEach(x -> this.flagMap.addTo(x, 1)); + flag.unprefixedAliases().forEach(x -> this.flagMap.addTo(x, 1)); } } @@ -509,8 +509,8 @@ private static boolean checkNodeCannotBeEmpty(final CommandNode void putEntryAbusingGenerics(@NonNull final SpongeCommandContextBuil } public void addFlagInvocation(final Flag flag) { - flag.getUnprefixedAliases().forEach(x -> this.flagCapture.addTo(x, 1)); + flag.unprefixedAliases().forEach(x -> this.flagCapture.addTo(x, 1)); this.copyBuilder.addFlagInvocation(flag); } @@ -180,10 +179,10 @@ public void commit() { if (builderRef != null) { this.withArgumentCapture.forEach(x -> builderRef.withArgumentInternal(x.name, x.parsedArgument, x.addToSponge)); this.withSourceCapture.forEach(builderRef::withSource); - this.withNodeCapture.forEach(x -> builderRef.withNode(x.getFirst(), x.getSecond())); + this.withNodeCapture.forEach(x -> builderRef.withNode(x.first(), x.second())); this.withChildCapture.forEach(builderRef::withChild); this.withCommandCapture.forEach(builderRef::withCommand); - this.putEntryCapture.forEach(x -> this.putEntryAbusingGenerics(builderRef, x.getFirst(), x.getSecond())); + this.putEntryCapture.forEach(x -> this.putEntryAbusingGenerics(builderRef, x.first(), x.second())); this.flagCapture.forEach(builderRef::addFlagInvocation); if (this.currentTargetCommandCapture != null) { builderRef.setCurrentTargetCommand(this.currentTargetCommandCapture); diff --git a/src/main/java/org/spongepowered/common/command/brigadier/dispatcher/SpongeCommandDispatcher.java b/src/main/java/org/spongepowered/common/command/brigadier/dispatcher/SpongeCommandDispatcher.java index b00788eef18..c2c9c71434f 100644 --- a/src/main/java/org/spongepowered/common/command/brigadier/dispatcher/SpongeCommandDispatcher.java +++ b/src/main/java/org/spongepowered/common/command/brigadier/dispatcher/SpongeCommandDispatcher.java @@ -114,7 +114,7 @@ public int execute(final StringReader input, final CommandSourceStack source) th final CommandSourceStackBridge sourceBridge = (CommandSourceStackBridge) source; frame.addContext(EventContextKeys.COMMAND, input.getString()); sourceBridge.bridge$updateFrameFromCommandSource(frame); - return this.commandManager.process(sourceBridge.bridge$withCurrentCause(), input.getRemaining()).getResult(); + return this.commandManager.process(sourceBridge.bridge$withCurrentCause(), input.getRemaining()).result(); } catch (final CommandException e) { throw new net.minecraft.commands.CommandRuntimeException(SpongeAdventure.asVanilla(e.componentMessage())); } diff --git a/src/main/java/org/spongepowered/common/command/brigadier/dispatcher/SpongeNodePermissionCache.java b/src/main/java/org/spongepowered/common/command/brigadier/dispatcher/SpongeNodePermissionCache.java index 25b8c58e4ec..45fa9bcfa1c 100644 --- a/src/main/java/org/spongepowered/common/command/brigadier/dispatcher/SpongeNodePermissionCache.java +++ b/src/main/java/org/spongepowered/common/command/brigadier/dispatcher/SpongeNodePermissionCache.java @@ -96,8 +96,8 @@ public static String createFromNode( } else { final String original = path.iterator().next(); pluginId = dispatcher.getCommandManager() - .getCommandMapping(original) - .map(x -> x.getPlugin().getMetadata().getId()).orElseGet(() -> { + .commandMapping(original) + .map(x -> x.plugin().getMetadata().getId()).orElseGet(() -> { SpongeCommon.getLogger().error("Root command /{} does not have an associated plugin!", original); return "unknown"; }); diff --git a/src/main/java/org/spongepowered/common/command/brigadier/tree/SpongeArgumentCommandNode.java b/src/main/java/org/spongepowered/common/command/brigadier/tree/SpongeArgumentCommandNode.java index 4f0a90d6cbc..01dd8afc7c0 100644 --- a/src/main/java/org/spongepowered/common/command/brigadier/tree/SpongeArgumentCommandNode.java +++ b/src/main/java/org/spongepowered/common/command/brigadier/tree/SpongeArgumentCommandNode.java @@ -277,14 +277,14 @@ public Command getCommand() { @Override public String getUsageText() { if (this.usage != null) { - return this.usage.getUsage(this.key.key()); + return this.usage.usage(this.key.key()); } return super.getUsageText(); } private String getUsageTextForClient() { if (this.usage != null) { - return this.usage.getUsage(this.key.key()); + return this.usage.usage(this.key.key()); } return this.getName(); } diff --git a/src/main/java/org/spongepowered/common/command/brigadier/tree/SpongeCommandExecutorWrapper.java b/src/main/java/org/spongepowered/common/command/brigadier/tree/SpongeCommandExecutorWrapper.java index d79deb1e2ea..0ea189c6c69 100644 --- a/src/main/java/org/spongepowered/common/command/brigadier/tree/SpongeCommandExecutorWrapper.java +++ b/src/main/java/org/spongepowered/common/command/brigadier/tree/SpongeCommandExecutorWrapper.java @@ -52,12 +52,12 @@ public int run(final CommandContext context) throws CommandS final CommandResult result = Objects.requireNonNull(this.executor.execute(spongeCommandContext), "A CommandResult was expected, but the command returned null instead. Report this to the plugin author!"); if (!result.isSuccess()) { - final Component errorMessage = result.getErrorMessage().orElse( + final Component errorMessage = result.errorMessage().orElse( Component.text("An unknown error occurred while executing the command ") .append(Component.text(context.getInput()))); throw new SpongeCommandSyntaxException(new CommandException(errorMessage), spongeCommandContext); } - return result.getResult(); + return result.result(); } catch (final CommandException e) { throw new SpongeCommandSyntaxException(e, spongeCommandContext); } diff --git a/src/main/java/org/spongepowered/common/command/manager/SpongeCommandCauseFactory.java b/src/main/java/org/spongepowered/common/command/manager/SpongeCommandCauseFactory.java index e702869333b..a20c2abbe9c 100644 --- a/src/main/java/org/spongepowered/common/command/manager/SpongeCommandCauseFactory.java +++ b/src/main/java/org/spongepowered/common/command/manager/SpongeCommandCauseFactory.java @@ -56,9 +56,9 @@ public final class SpongeCommandCauseFactory implements CommandCause.Factory { @NonNull public CommandCause create() { try (final CauseStackManager.StackFrame frame = PhaseTracker.getCauseStackManager().pushCauseFrame()) { - final Cause cause = frame.getCurrentCause(); + final Cause cause = frame.currentCause(); final CommandSource iCommandSource = - cause.first(CommandSource.class).orElseGet(() -> SpongeCommon.getGame().getSystemSubject()); + cause.first(CommandSource.class).orElseGet(() -> SpongeCommon.getGame().systemSubject()); final CommandSourceStack commandSource; if (iCommandSource instanceof CommandSourceProviderBridge) { // We know about this one so we can create it using the factory method on the source. @@ -66,30 +66,30 @@ public CommandCause create() { } else { // try to create a command cause from the given ICommandSource, but as Mojang did not see fit to // put any identifying characteristics on the object, we have to go it alone... - final EventContext context = cause.getContext(); + final EventContext context = cause.context(); final @Nullable Locatable locatable = iCommandSource instanceof Locatable ? (Locatable) iCommandSource : null; final Component displayName; if (iCommandSource instanceof Entity) { displayName = ((Entity) iCommandSource).get(Keys.DISPLAY_NAME).map(SpongeAdventure::asVanilla) .orElseGet(() -> new TextComponent( - iCommandSource instanceof Nameable ? ((Nameable) iCommandSource).getName() : + iCommandSource instanceof Nameable ? ((Nameable) iCommandSource).name() : iCommandSource.getClass().getSimpleName())); } else { displayName = new TextComponent( - iCommandSource instanceof Nameable ? ((Nameable) iCommandSource).getName() : + iCommandSource instanceof Nameable ? ((Nameable) iCommandSource).name() : iCommandSource.getClass().getSimpleName()); } final String name = displayName.getString(); commandSource = new CommandSourceStack( iCommandSource, - context.get(EventContextKeys.LOCATION).map(x -> VecHelper.toVanillaVector3d(x.getPosition())) - .orElseGet(() -> locatable == null ? Vec3.ZERO : VecHelper.toVanillaVector3d(locatable.getLocation().getPosition())), + context.get(EventContextKeys.LOCATION).map(x -> VecHelper.toVanillaVector3d(x.position())) + .orElseGet(() -> locatable == null ? Vec3.ZERO : VecHelper.toVanillaVector3d(locatable.location().position())), context.get(EventContextKeys.ROTATION) .map(x -> new Vec2((float) x.getX(), (float) x.getY())) .orElse(Vec2.ZERO), - context.get(EventContextKeys.LOCATION).map(x -> (ServerLevel) x.getWorld()) + context.get(EventContextKeys.LOCATION).map(x -> (ServerLevel) x.world()) .orElseGet(() -> locatable == null ? SpongeCommon.getServer().getLevel(Level.OVERWORLD) : - (ServerLevel) locatable.getServerLocation().getWorld()), + (ServerLevel) locatable.serverLocation().world()), 4, name, displayName, @@ -101,7 +101,7 @@ public CommandCause create() { // We don't want the command source to have altered the cause here (unless there is the special case of the // server), so we reset it back to what it was (in the ctor of CommandSource, it will add the current source // to the cause - that's for if the source is created elsewhere, not here) - ((CommandSourceStackBridge) commandSource).bridge$setCause(frame.getCurrentCause()); + ((CommandSourceStackBridge) commandSource).bridge$setCause(frame.currentCause()); return (CommandCause) commandSource; } } diff --git a/src/main/java/org/spongepowered/common/command/manager/SpongeCommandManager.java b/src/main/java/org/spongepowered/common/command/manager/SpongeCommandManager.java index 411d4f481c1..df48f466d0b 100644 --- a/src/main/java/org/spongepowered/common/command/manager/SpongeCommandManager.java +++ b/src/main/java/org/spongepowered/common/command/manager/SpongeCommandManager.java @@ -141,7 +141,7 @@ public BrigadierCommandRegistrar getBrigadierRegistrar() { } @Override - public @NonNull Set getKnownAliases() { + public @NonNull Set knownAliases() { return ImmutableSet.copyOf(this.commandMappings.keySet()); } @@ -260,13 +260,13 @@ public CommandMapping registerAliasWithNamespacing( @Override @NonNull - public Collection getPlugins() { + public Collection plugins() { return ImmutableSet.copyOf(this.pluginToCommandMap.keySet()); } @Override @NonNull - public Optional getCommandMapping(final String alias) { + public Optional commandMapping(final String alias) { return Optional.ofNullable(this.commandMappings.get(alias.toLowerCase())); } @@ -309,7 +309,7 @@ public CommandResult process(final CommandCause cause, final String arguments) t final String command; final String args; final ExecuteCommandEvent.Pre preEvent = SpongeEventFactory.createExecuteCommandEventPre( - cause.getCause(), + cause.cause(), originalArgs, originalArgs, originalCommand, @@ -318,11 +318,11 @@ public CommandResult process(final CommandCause cause, final String arguments) t Optional.empty(), false ); - if (this.game.getEventManager().post(preEvent)) { - return preEvent.getResult().orElse(CommandResult.empty()); + if (this.game.eventManager().post(preEvent)) { + return preEvent.result().orElse(CommandResult.empty()); } - command = preEvent.getCommand(); - args = preEvent.getArguments(); + command = preEvent.command(); + args = preEvent.arguments(); final SpongeCommandMapping mapping = this.commandMappings.get(command.toLowerCase()); if (mapping == null) { @@ -331,7 +331,7 @@ public CommandResult process(final CommandCause cause, final String arguments) t throw new CommandException(Component.text("Unknown command. Type /help for a list of commands.")); } // For when the phase tracker comes back online - final Object source = cause.getCause().root(); + final Object source = cause.cause().root(); final CommandResult result; // final TrackedInventoryBridge inventory = source instanceof EntityPlayer ? @@ -341,7 +341,7 @@ public CommandResult process(final CommandCause cause, final String arguments) t .source(source) .command(args)) { if (source instanceof ServerPlayer) { - final User sourceUser = ((ServerPlayer) source).getUser(); + final User sourceUser = ((ServerPlayer) source).user(); context.creator(sourceUser); context.notifier(sourceUser); } @@ -352,9 +352,9 @@ public CommandResult process(final CommandCause cause, final String arguments) t //} context.buildAndSwitch(); try { - result = mapping.getRegistrar().process(cause, mapping, command, args); + result = mapping.registrar().process(cause, mapping, command, args); } catch (final CommandException exception) { - final CommandResult errorResult = CommandResult.builder().setResult(0).error( + final CommandResult errorResult = CommandResult.builder().result(0).error( exception.componentMessage()).build(); this.postExecuteCommandPostEvent(cause, originalArgs, args, originalCommand, command, errorResult); if (SpongeCommandManager.ALWAYS_PRINT_STACKTRACES) { @@ -362,7 +362,7 @@ public CommandResult process(final CommandCause cause, final String arguments) t } throw exception; } catch (final net.minecraft.commands.CommandRuntimeException ex) { - final CommandResult errorResult = CommandResult.builder().setResult(0).error( + final CommandResult errorResult = CommandResult.builder().result(0).error( SpongeAdventure.asAdventure(ex.getComponent())).build(); this.postExecuteCommandPostEvent(cause, originalArgs, args, originalCommand, command, errorResult); if (SpongeCommandManager.ALWAYS_PRINT_STACKTRACES) { @@ -395,7 +395,7 @@ public CommandResult process(final CommandCause cause, final String arguments) t } this.postExecuteCommandPostEvent(cause, originalArgs, args, originalCommand, command, result); - result.getErrorMessage().ifPresent(x -> cause.sendMessage(Identity.nil(), x)); + result.errorMessage().ifPresent(x -> cause.sendMessage(Identity.nil(), x)); return result; } } @@ -432,8 +432,8 @@ private void postExecuteCommandPostEvent( final String originalCommand, final String command, final CommandResult result) { - this.game.getEventManager().post(SpongeEventFactory.createExecuteCommandEventPost( - cause.getCause(), + this.game.eventManager().post(SpongeEventFactory.createExecuteCommandEventPost( + cause.cause(), originalArgs, args, originalCommand, @@ -460,8 +460,8 @@ private void prettyPrintThrowableError(final Throwable thr, final String command .hr() .add() .add("Command: %s", commandString) - .add("Owning Plugin: %s", mapping.getPlugin().getMetadata().getId()) - .add("Owning Registrar: %s", mapping.getRegistrar().getClass().getName()) + .add("Owning Plugin: %s", mapping.plugin().getMetadata().getId()) + .add("Owning Registrar: %s", mapping.registrar().getClass().getName()) .add() .add("Exception Details: "); if (thr instanceof SpongeCommandSyntaxException) { // we know the inner exception was wrapped by us. @@ -471,7 +471,7 @@ private void prettyPrintThrowableError(final Throwable thr, final String command } prettyPrinter.add() .add("CommandCause details: ") - .addWrapped(cause.getCause().toString()) + .addWrapped(cause.cause().toString()) .log(SpongeCommon.getLogger(), Level.ERROR); } @@ -491,7 +491,7 @@ public List suggest(@NonNull final String arguments) { return Collections.emptyList(); } - return mapping.getRegistrar().suggestions(CommandCause.create(), mapping, command, splitArg[1]); + return mapping.registrar().suggestions(CommandCause.create(), mapping, command, splitArg[1]); } return this.commandMappings.keySet() @@ -529,9 +529,9 @@ public List suggest( } public void init() { - final Cause cause = PhaseTracker.getCauseStackManager().getCurrentCause(); + final Cause cause = PhaseTracker.getCauseStackManager().currentCause(); final Set> usedTokens = new HashSet<>(); - Sponge.getGame().registries().registry(RegistryTypes.COMMAND_REGISTRAR_TYPE).streamEntries().forEach(entry -> { + Sponge.game().registries().registry(RegistryTypes.COMMAND_REGISTRAR_TYPE).streamEntries().forEach(entry -> { final CommandRegistrarType type = entry.value(); // someone's gonna do it, let's not let them take us down. final TypeToken handledType = type.handledType(); @@ -547,7 +547,7 @@ public void init() { this.registerInternalCommands((SpongeParameterizedCommandRegistrar) registrar); } - this.game.getEventManager().post(this.createEvent(cause, this.game, registrar)); + this.game.eventManager().post(this.createEvent(cause, this.game, registrar)); } else { SpongeCommon.getLogger() .warn("Command type '{}' has already been collected, skipping request from {}", @@ -571,7 +571,7 @@ private void registerInternalCommands(final CommandRegistrar regi throw new RuntimeException("Failed to create root Sponge command!", ex); } try { - final PaginationService paginationService = Sponge.getServiceProvider().paginationService(); + final PaginationService paginationService = Sponge.serviceProvider().paginationService(); if (paginationService instanceof SpongePaginationService) { registrar.register( Launch.getInstance().getCommonPlugin(), @@ -597,13 +597,13 @@ public Collection> getNonBrigadierSuggesti // create tree from primary mapping final CommandNode node = entry.getValue() - .createArgumentTree(cause, LiteralArgumentBuilder.literal(mapping.getPrimaryAlias())); + .createArgumentTree(cause, LiteralArgumentBuilder.literal(mapping.primaryAlias())); if (node != null) { final Command executableCommand = node.getCommand(); final CommandNode toRedirectTo = node.getRedirect() == null ? node : node.getRedirect(); suggestions.add(node); - for (final String alias : mapping.getAllAliases()) { - if (!alias.equals(mapping.getPrimaryAlias())) { + for (final String alias : mapping.allAliases()) { + if (!alias.equals(mapping.primaryAlias())) { suggestions.add(LiteralArgumentBuilder.literal(alias) .executes(executableCommand).redirect(toRedirectTo).build()); } @@ -619,7 +619,7 @@ public Collection getAliasesThatStartWithForCause(final CommandCause cau final Object2BooleanMap testedMappings = new Object2BooleanOpenHashMap<>(); for (final Map.Entry mappingEntry : this.commandMappings.entrySet()) { if (mappingEntry.getKey().startsWith(toCompare)) { - if (testedMappings.computeBooleanIfAbsent(mappingEntry.getValue(), mapping -> mapping.getRegistrar().canExecute(cause, mapping))) { + if (testedMappings.computeBooleanIfAbsent(mappingEntry.getValue(), mapping -> mapping.registrar().canExecute(cause, mapping))) { aliases.add(toCompare); } } @@ -630,7 +630,7 @@ public Collection getAliasesThatStartWithForCause(final CommandCause cau public Collection getAliasesForCause(final CommandCause cause) { final List aliases = new ArrayList<>(); for (final SpongeCommandMapping mapping : this.inverseCommandMappings.keySet()) { - if (mapping.getRegistrar().canExecute(cause, mapping)) { + if (mapping.registrar().canExecute(cause, mapping)) { aliases.addAll(this.inverseCommandMappings.get(mapping)); } } diff --git a/src/main/java/org/spongepowered/common/command/manager/SpongeCommandMapping.java b/src/main/java/org/spongepowered/common/command/manager/SpongeCommandMapping.java index 1dc1333791b..0afcbc52c37 100644 --- a/src/main/java/org/spongepowered/common/command/manager/SpongeCommandMapping.java +++ b/src/main/java/org/spongepowered/common/command/manager/SpongeCommandMapping.java @@ -53,25 +53,25 @@ public SpongeCommandMapping(final String alias, @Override @NonNull - public String getPrimaryAlias() { + public String primaryAlias() { return this.alias; } @Override @NonNull - public Set getAllAliases() { + public Set allAliases() { return this.allAliases; } @Override @NonNull - public PluginContainer getPlugin() { + public PluginContainer plugin() { return this.container; } @Override @NonNull - public CommandRegistrar getRegistrar() { + public CommandRegistrar registrar() { return this.registrar; } diff --git a/src/main/java/org/spongepowered/common/command/parameter/SpongeDefaultValueParser.java b/src/main/java/org/spongepowered/common/command/parameter/SpongeDefaultValueParser.java index 9f3b0832f07..6000dfcfab0 100644 --- a/src/main/java/org/spongepowered/common/command/parameter/SpongeDefaultValueParser.java +++ b/src/main/java/org/spongepowered/common/command/parameter/SpongeDefaultValueParser.java @@ -51,14 +51,14 @@ public SpongeDefaultValueParser(final Function defaultFunction) } @Override - public Optional getValue( + public Optional parseValue( final Parameter.Key parameterKey, final ArgumentReader.Mutable reader, final CommandContext.Builder context) throws ArgumentParseException { final T result; try { - result = this.defaultFunction.apply(context.getCause()); + result = this.defaultFunction.apply(context.cause()); } catch (final Exception ex) { throw ((SpongeStringReader) reader) .createException(Component.text("An exception was thrown obtaining a default value for " + parameterKey.key()), ex); @@ -70,7 +70,7 @@ public Optional getValue( } @Override - public List getClientCompletionType() { + public List clientCompletionType() { return SpongeDefaultValueParser.CLIENT_COMPLETION_TYPE; } } diff --git a/src/main/java/org/spongepowered/common/command/parameter/SpongeParameterKey.java b/src/main/java/org/spongepowered/common/command/parameter/SpongeParameterKey.java index b67b7dcd7e8..fe72b013630 100644 --- a/src/main/java/org/spongepowered/common/command/parameter/SpongeParameterKey.java +++ b/src/main/java/org/spongepowered/common/command/parameter/SpongeParameterKey.java @@ -51,7 +51,7 @@ public static SpongeParameterKey getSpongeKey(final Parameter.@NonNull Ke private SpongeParameterKey(final Parameter.@NonNull Key parameterKey) { this.key = parameterKey.key(); - this.type = parameterKey.getType(); + this.type = parameterKey.type(); } public SpongeParameterKey(final @NonNull String key, final @NonNull Type type) { @@ -67,7 +67,7 @@ public String key() { @Override @NonNull - public Type getType() { + public Type type() { return this.type; } diff --git a/src/main/java/org/spongepowered/common/command/parameter/SpongeParameterValue.java b/src/main/java/org/spongepowered/common/command/parameter/SpongeParameterValue.java index 6c46bb73d7e..904445011d7 100644 --- a/src/main/java/org/spongepowered/common/command/parameter/SpongeParameterValue.java +++ b/src/main/java/org/spongepowered/common/command/parameter/SpongeParameterValue.java @@ -79,7 +79,7 @@ public SpongeParameterValue( @Override public void parse(final ArgumentReader.@NonNull Mutable args, final CommandContext.@NonNull Builder context) throws ArgumentParseException { - final ArgumentReader.Immutable readerState = args.getImmutable(); + final ArgumentReader.Immutable readerState = args.immutable(); final CommandContext.Builder.Transaction transaction = context.startTransaction(); try { @@ -105,11 +105,11 @@ private void parseInternal( final CommandContext.Builder context) throws ArgumentParseException { List currentExceptions = null; - final ArgumentReader.Immutable state = args.getImmutable(); + final ArgumentReader.Immutable state = args.immutable(); final CommandContext.Builder.Transaction transaction = context.startTransaction(); for (final ValueParser parser : this.parsers) { try { - parser.getValue(this.key, args, context).ifPresent(t -> context.putEntry(this.key, t)); + parser.parseValue(this.key, args, context).ifPresent(t -> context.putEntry(this.key, t)); context.commit(transaction); return; // something parsed, so we exit. } catch (final ArgumentParseException ex) { @@ -126,33 +126,33 @@ private void parseInternal( // If we get this far, we failed to parse, return the exceptions if (currentExceptions == null) { throw new CommandRuntimeException(new TextComponent("Could not parse element")); - // throw new ArgumentParseException(t("Could not parse element"), args.getInput(), args.getCursor()); + // throw new ArgumentParseException(t("Could not parse element"), args.getInput(), args.cursor()); } else if (currentExceptions.size() == 1) { throw currentExceptions.get(0); } else { - final List errors = currentExceptions.stream().map(ArgumentParseException::getSuperText).collect(Collectors.toList()); - throw new ArgumentParseException(Component.join(Component.newline(), errors), args.getInput(), args.getCursor()); + final List errors = currentExceptions.stream().map(ArgumentParseException::superText).collect(Collectors.toList()); + throw new ArgumentParseException(Component.join(Component.newline(), errors), args.input(), args.cursor()); } } @Override @NonNull - public Key getKey() { + public Key key() { return this.key; } @Override @NonNull public List complete(final ArgumentReader.@NonNull Immutable reader, @NonNull final CommandContext context) { - return this.completer.complete(context, reader.getRemaining()); + return this.completer.complete(context, reader.remaining()); } @Override @NonNull - public String getUsage(@NonNull final CommandCause cause) { + public String usage(@NonNull final CommandCause cause) { if (this.usage != null) { - return this.usage.getUsage(this.key.key()); + return this.usage.usage(this.key.key()); } final String usage = this.key.key(); @@ -165,24 +165,24 @@ public String getUsage(@NonNull final CommandCause cause) { @Override @NonNull - public Collection> getParsers() { + public Collection> parsers() { return this.parsers; } @Override @NonNull - public ValueCompleter getCompleter() { + public ValueCompleter completer() { return this.completer; } @Override - public Optional getValueUsage() { + public Optional valueUsage() { return Optional.ofNullable(this.usage); } @Override @NonNull - public Predicate getRequirement() { + public Predicate requirement() { return this.requirement; } diff --git a/src/main/java/org/spongepowered/common/command/parameter/SpongeParameterValueBuilder.java b/src/main/java/org/spongepowered/common/command/parameter/SpongeParameterValueBuilder.java index 5fe438d4726..9a7fe17f94f 100644 --- a/src/main/java/org/spongepowered/common/command/parameter/SpongeParameterValueBuilder.java +++ b/src/main/java/org/spongepowered/common/command/parameter/SpongeParameterValueBuilder.java @@ -59,45 +59,45 @@ public SpongeParameterValueBuilder(@NonNull final Type token) { } @Override - public Parameter.Value.@NonNull Builder setKey(@NonNull final String key) { - return this.setKey(new SpongeParameterKey<>(key, this.typeToken)); + public Parameter.Value.@NonNull Builder key(@NonNull final String key) { + return this.key(new SpongeParameterKey<>(key, this.typeToken)); } - @Override public Parameter.Value.@NonNull Builder setKey(final Parameter.@NonNull Key key) { + @Override public Parameter.Value.@NonNull Builder key(final Parameter.@NonNull Key key) { Objects.requireNonNull(key, "The key cannot be null"); this.key = key; return this; } @Override - public Parameter.Value.@NonNull Builder parser(@NonNull final ValueParser parser) { + public Parameter.Value.@NonNull Builder addParser(@NonNull final ValueParser parser) { this.parsers.add(Objects.requireNonNull(parser, "The ValueParser may not be null")); return this; } @Override - public Parameter.Value.@NonNull Builder setSuggestions(@Nullable final ValueCompleter completer) { + public Parameter.Value.@NonNull Builder suggestions(@Nullable final ValueCompleter completer) { this.completer = completer; return this; } @Override - public Parameter.Value.@NonNull Builder setUsage(@Nullable final ValueUsage usage) { + public Parameter.Value.@NonNull Builder usage(@Nullable final ValueUsage usage) { this.usage = usage; return this; } @Override - public Parameter.Value.@NonNull Builder setRequiredPermission(@Nullable final String permission) { + public Parameter.Value.@NonNull Builder requiredPermission(@Nullable final String permission) { if (permission == null) { - return this.setRequirements(null); + return this.requirements(null); } else { - return this.setRequirements(commandCause -> commandCause.getSubject().hasPermission(permission)); + return this.requirements(commandCause -> commandCause.subject().hasPermission(permission)); } } @Override - public Parameter.Value.@NonNull Builder setRequirements(@Nullable final Predicate executionRequirements) { + public Parameter.Value.@NonNull Builder requirements(@Nullable final Predicate executionRequirements) { this.executionRequirements = executionRequirements; return this; } diff --git a/src/main/java/org/spongepowered/common/command/parameter/flag/SpongeFlag.java b/src/main/java/org/spongepowered/common/command/parameter/flag/SpongeFlag.java index a66387a5b26..ff0590f070f 100644 --- a/src/main/java/org/spongepowered/common/command/parameter/flag/SpongeFlag.java +++ b/src/main/java/org/spongepowered/common/command/parameter/flag/SpongeFlag.java @@ -56,25 +56,25 @@ public SpongeFlag( @Override @NonNull - public Collection getUnprefixedAliases() { + public Collection unprefixedAliases() { return ImmutableSet.copyOf(this.keys); } @Override @NonNull - public Collection getAliases() { + public Collection aliases() { return ImmutableSet.copyOf(this.aliases); } @Override @NonNull - public Predicate getRequirement() { + public Predicate requirement() { return this.requirement; } @Override @NonNull - public Optional getAssociatedParameter() { + public Optional associatedParameter() { return Optional.ofNullable(this.associatedParameter); } diff --git a/src/main/java/org/spongepowered/common/command/parameter/managed/builder/SpongeDynamicChoicesBuilder.java b/src/main/java/org/spongepowered/common/command/parameter/managed/builder/SpongeDynamicChoicesBuilder.java index e86fcce3445..08ac98a38c5 100644 --- a/src/main/java/org/spongepowered/common/command/parameter/managed/builder/SpongeDynamicChoicesBuilder.java +++ b/src/main/java/org/spongepowered/common/command/parameter/managed/builder/SpongeDynamicChoicesBuilder.java @@ -43,26 +43,26 @@ public final class SpongeDynamicChoicesBuilder implements VariableValueParame private boolean showInUsage = false; @Override - public VariableValueParameters.@NonNull DynamicChoicesBuilder setChoicesAndResults(@NonNull final Supplier> choices) { + public VariableValueParameters.@NonNull DynamicChoicesBuilder choicesAndResults(@NonNull final Supplier> choices) { this.choices = () -> choices.get().keySet(); this.results = x -> choices.get().get(x); return this; } @Override - public VariableValueParameters.@NonNull DynamicChoicesBuilder setChoices(final Supplier> choices) { + public VariableValueParameters.@NonNull DynamicChoicesBuilder choices(final Supplier> choices) { this.choices = choices; return this; } @Override - public VariableValueParameters.@NonNull DynamicChoicesBuilder setResults(@NonNull final Function results) { + public VariableValueParameters.@NonNull DynamicChoicesBuilder results(@NonNull final Function results) { this.results = results; return this; } @Override - public VariableValueParameters.@NonNull DynamicChoicesBuilder setShowInUsage(final boolean showInUsage) { + public VariableValueParameters.@NonNull DynamicChoicesBuilder showInUsage(final boolean showInUsage) { this.showInUsage = showInUsage; return this; } diff --git a/src/main/java/org/spongepowered/common/command/parameter/managed/builder/SpongeLiteralBuilder.java b/src/main/java/org/spongepowered/common/command/parameter/managed/builder/SpongeLiteralBuilder.java index a4a24bbda8e..d070d73498a 100644 --- a/src/main/java/org/spongepowered/common/command/parameter/managed/builder/SpongeLiteralBuilder.java +++ b/src/main/java/org/spongepowered/common/command/parameter/managed/builder/SpongeLiteralBuilder.java @@ -39,13 +39,13 @@ public final class SpongeLiteralBuilder implements VariableValueParameters.Li @Nullable private Supplier returnValue; @Override - public VariableValueParameters.@NonNull LiteralBuilder setLiteral(@NonNull final Supplier> literalSupplier) { + public VariableValueParameters.@NonNull LiteralBuilder literal(@NonNull final Supplier> literalSupplier) { this.strings = literalSupplier; return this; } @Override - public VariableValueParameters.@NonNull LiteralBuilder setReturnValue(@NonNull final Supplier returnValueSupplier) { + public VariableValueParameters.@NonNull LiteralBuilder returnValue(@NonNull final Supplier returnValueSupplier) { this.returnValue = returnValueSupplier; return this; } diff --git a/src/main/java/org/spongepowered/common/command/parameter/managed/builder/SpongeNumberRangeBuilder.java b/src/main/java/org/spongepowered/common/command/parameter/managed/builder/SpongeNumberRangeBuilder.java index d382c953060..2214127b405 100644 --- a/src/main/java/org/spongepowered/common/command/parameter/managed/builder/SpongeNumberRangeBuilder.java +++ b/src/main/java/org/spongepowered/common/command/parameter/managed/builder/SpongeNumberRangeBuilder.java @@ -118,13 +118,13 @@ private SpongeNumberRangeBuilder(final T min, final T max, final Definition d } @Override - public VariableValueParameters.@NonNull NumberRangeBuilder setMin(@NonNull final T min) { + public VariableValueParameters.@NonNull NumberRangeBuilder min(@NonNull final T min) { this.min = Objects.requireNonNull(min); return this; } @Override - public VariableValueParameters.@NonNull NumberRangeBuilder setMax(@NonNull final T max) { + public VariableValueParameters.@NonNull NumberRangeBuilder max(@NonNull final T max) { this.max = Objects.requireNonNull(max); return this; } diff --git a/src/main/java/org/spongepowered/common/command/parameter/managed/builder/SpongeRegistryEntryParameterBuilder.java b/src/main/java/org/spongepowered/common/command/parameter/managed/builder/SpongeRegistryEntryParameterBuilder.java index 66165279843..4f681982fb4 100644 --- a/src/main/java/org/spongepowered/common/command/parameter/managed/builder/SpongeRegistryEntryParameterBuilder.java +++ b/src/main/java/org/spongepowered/common/command/parameter/managed/builder/SpongeRegistryEntryParameterBuilder.java @@ -38,7 +38,7 @@ import java.util.function.Function; public final class SpongeRegistryEntryParameterBuilder - implements VariableValueParameters.CatalogedTypeBuilder { + implements VariableValueParameters.RegistryEntryBuilder { private final Function> registryFunction; private final List prefixes = new ArrayList<>(); @@ -48,7 +48,7 @@ public SpongeRegistryEntryParameterBuilder(final Function defaultNamespace(@NonNull final String prefix) { + public VariableValueParameters.@NonNull RegistryEntryBuilder defaultNamespace(@NonNull final String prefix) { this.prefixes.add(Objects.requireNonNull(prefix, "Prefix cannot be null!")); return this; } @@ -60,7 +60,7 @@ public ValueParameter build() { } @Override - public VariableValueParameters.@NonNull CatalogedTypeBuilder reset() { + public VariableValueParameters.@NonNull RegistryEntryBuilder reset() { this.prefixes.clear(); return this; } diff --git a/src/main/java/org/spongepowered/common/command/parameter/managed/builder/SpongeStaticChoicesBuilder.java b/src/main/java/org/spongepowered/common/command/parameter/managed/builder/SpongeStaticChoicesBuilder.java index 60b6b276a01..4560d416ef9 100644 --- a/src/main/java/org/spongepowered/common/command/parameter/managed/builder/SpongeStaticChoicesBuilder.java +++ b/src/main/java/org/spongepowered/common/command/parameter/managed/builder/SpongeStaticChoicesBuilder.java @@ -40,7 +40,7 @@ public final class SpongeStaticChoicesBuilder implements VariableValueParamet private boolean showInUsage = false; @Override - public VariableValueParameters.@NonNull StaticChoicesBuilder choices( + public VariableValueParameters.@NonNull StaticChoicesBuilder addChoices( @NonNull final Iterable choices, @NonNull final Supplier returnedObjectSupplier) { @@ -51,7 +51,7 @@ public final class SpongeStaticChoicesBuilder implements VariableValueParamet } @Override - public VariableValueParameters.@NonNull StaticChoicesBuilder setShowInUsage(final boolean showInUsage) { + public VariableValueParameters.@NonNull StaticChoicesBuilder showInUsage(final boolean showInUsage) { this.showInUsage = showInUsage; return this; } diff --git a/src/main/java/org/spongepowered/common/command/parameter/managed/builder/SpongeTextParameterBuilder.java b/src/main/java/org/spongepowered/common/command/parameter/managed/builder/SpongeTextParameterBuilder.java index 5236b63d9da..e2da6aa343a 100644 --- a/src/main/java/org/spongepowered/common/command/parameter/managed/builder/SpongeTextParameterBuilder.java +++ b/src/main/java/org/spongepowered/common/command/parameter/managed/builder/SpongeTextParameterBuilder.java @@ -41,19 +41,19 @@ public final class SpongeTextParameterBuilder implements VariableValueParameters private boolean consumeAllArguments; @Override - public VariableValueParameters.@NonNull TextBuilder setSerializer(@NonNull final ComponentSerializer serializer) { + public VariableValueParameters.@NonNull TextBuilder serializer(@NonNull final ComponentSerializer serializer) { Preconditions.checkNotNull(serializer, "The serializer cannot be null"); - return this.setSerializerSupplier(() -> serializer); + return this.serializerSupplier(() -> serializer); } @Override - public VariableValueParameters.@NonNull TextBuilder setSerializerSupplier(@NonNull final Supplier> serializerSupplier) { + public VariableValueParameters.@NonNull TextBuilder serializerSupplier(@NonNull final Supplier> serializerSupplier) { this.textSerializer = serializerSupplier.get(); return this; } @Override - public VariableValueParameters.@NonNull TextBuilder setConsumeAllArguments(final boolean allArguments) { + public VariableValueParameters.@NonNull TextBuilder consumeAllArguments(final boolean allArguments) { this.consumeAllArguments = allArguments; return this; } diff --git a/src/main/java/org/spongepowered/common/command/parameter/managed/factory/SpongeVariableValueParametersFactory.java b/src/main/java/org/spongepowered/common/command/parameter/managed/factory/SpongeVariableValueParametersFactory.java index 5c13680999c..1f10d7697e0 100644 --- a/src/main/java/org/spongepowered/common/command/parameter/managed/factory/SpongeVariableValueParametersFactory.java +++ b/src/main/java/org/spongepowered/common/command/parameter/managed/factory/SpongeVariableValueParametersFactory.java @@ -75,7 +75,7 @@ public > ValueParameter createEnumParameter(@NonNull final } @Override - public VariableValueParameters.@NonNull CatalogedTypeBuilder createRegistryEntryBuilder( + public VariableValueParameters.@NonNull RegistryEntryBuilder createRegistryEntryBuilder( @NonNull final Function holderProvider, final RegistryType registryKey) { return new SpongeRegistryEntryParameterBuilder<>(in -> { @@ -88,13 +88,13 @@ public > ValueParameter createEnumParameter(@NonNull final } @Override - public VariableValueParameters.@NonNull CatalogedTypeBuilder createRegistryEntryBuilder( + public VariableValueParameters.@NonNull RegistryEntryBuilder createRegistryEntryBuilder( @NonNull final Function> returnType) { return new SpongeRegistryEntryParameterBuilder<>(returnType); } @Override - public VariableValueParameters.CatalogedTypeBuilder createRegistryEntryBuilder(final DefaultedRegistryType type) { + public VariableValueParameters.RegistryEntryBuilder createRegistryEntryBuilder(final DefaultedRegistryType type) { return new SpongeRegistryEntryParameterBuilder<>(in -> type.get()); } diff --git a/src/main/java/org/spongepowered/common/command/parameter/managed/standard/SpongeBigDecimalValueParameter.java b/src/main/java/org/spongepowered/common/command/parameter/managed/standard/SpongeBigDecimalValueParameter.java index 5cc4a43a8ae..20010a97cf3 100644 --- a/src/main/java/org/spongepowered/common/command/parameter/managed/standard/SpongeBigDecimalValueParameter.java +++ b/src/main/java/org/spongepowered/common/command/parameter/managed/standard/SpongeBigDecimalValueParameter.java @@ -52,7 +52,7 @@ public List complete(@NonNull final CommandContext context, final String @Override @NonNull - public Optional getValue( + public Optional parseValue( final Parameter.@NonNull Key parameterKey, final ArgumentReader.@NonNull Mutable reader, final CommandContext.@NonNull Builder context) throws ArgumentParseException { diff --git a/src/main/java/org/spongepowered/common/command/parameter/managed/standard/SpongeBigIntegerValueParameter.java b/src/main/java/org/spongepowered/common/command/parameter/managed/standard/SpongeBigIntegerValueParameter.java index dd766f81850..0dde65e1742 100644 --- a/src/main/java/org/spongepowered/common/command/parameter/managed/standard/SpongeBigIntegerValueParameter.java +++ b/src/main/java/org/spongepowered/common/command/parameter/managed/standard/SpongeBigIntegerValueParameter.java @@ -46,7 +46,7 @@ public SpongeBigIntegerValueParameter(final ResourceKey key) { @Override @NonNull - public Optional getValue( + public Optional parseValue( final Parameter.@NonNull Key parameterKey, final ArgumentReader.@NonNull Mutable reader, final CommandContext.@NonNull Builder context) throws ArgumentParseException { diff --git a/src/main/java/org/spongepowered/common/command/parameter/managed/standard/SpongeCatalogedElementValueParameter.java b/src/main/java/org/spongepowered/common/command/parameter/managed/standard/SpongeCatalogedElementValueParameter.java index 8dd10bc11c9..77b60d1ead2 100644 --- a/src/main/java/org/spongepowered/common/command/parameter/managed/standard/SpongeCatalogedElementValueParameter.java +++ b/src/main/java/org/spongepowered/common/command/parameter/managed/standard/SpongeCatalogedElementValueParameter.java @@ -58,14 +58,14 @@ public SpongeCatalogedElementValueParameter(final List prefixes, @NonNull @Override - public Optional getValue(final Parameter.@NonNull Key parameterKey, + public Optional parseValue(final Parameter.@NonNull Key parameterKey, final ArgumentReader.@NonNull Mutable reader, final CommandContext.@NonNull Builder context) throws ArgumentParseException { final Registry registry = this.registryFunction.apply(context); if (registry == null) { throw reader.createException(Component.text("The registry associated with this parameter is not currently active.")); } - final ArgumentReader.Immutable snapshot = reader.getImmutable(); + final ArgumentReader.Immutable snapshot = reader.immutable(); try { final ResourceKey resourceKey = reader.parseResourceKey(); final Optional result = registry.findValue(resourceKey); @@ -107,8 +107,8 @@ public List complete(@NonNull final CommandContext context, @NonNull fin .map(x -> { if (x.asString().startsWith(lowerCase)) { return x.asString(); - } else if (this.prefixes.contains(x.getNamespace()) && x.getValue().startsWith(lowerCase)) { - return x.getValue(); + } else if (this.prefixes.contains(x.namespace()) && x.value().startsWith(lowerCase)) { + return x.value(); } return null; }).filter(Objects::nonNull).collect(Collectors.toList()); diff --git a/src/main/java/org/spongepowered/common/command/parameter/managed/standard/SpongeChoicesValueParameter.java b/src/main/java/org/spongepowered/common/command/parameter/managed/standard/SpongeChoicesValueParameter.java index fa59b669e95..0fe1ae604d9 100644 --- a/src/main/java/org/spongepowered/common/command/parameter/managed/standard/SpongeChoicesValueParameter.java +++ b/src/main/java/org/spongepowered/common/command/parameter/managed/standard/SpongeChoicesValueParameter.java @@ -79,7 +79,7 @@ public List complete(@NonNull final CommandContext context, final String @Override @NonNull - public Optional getValue( + public Optional parseValue( final Parameter.@NonNull Key parameterKey, final ArgumentReader.@NonNull Mutable reader, final CommandContext.@NonNull Builder context) throws ArgumentParseException { diff --git a/src/main/java/org/spongepowered/common/command/parameter/managed/standard/SpongeColorValueParameter.java b/src/main/java/org/spongepowered/common/command/parameter/managed/standard/SpongeColorValueParameter.java index 4a8d2480e1e..bcc0d1aae01 100644 --- a/src/main/java/org/spongepowered/common/command/parameter/managed/standard/SpongeColorValueParameter.java +++ b/src/main/java/org/spongepowered/common/command/parameter/managed/standard/SpongeColorValueParameter.java @@ -75,12 +75,12 @@ public List complete(@NonNull final CommandContext context, final String @Override @NonNull - public Optional getValue( + public Optional parseValue( final Parameter.@NonNull Key parameterKey, final ArgumentReader.@NonNull Mutable reader, final CommandContext.@NonNull Builder context) throws ArgumentParseException { - final ArgumentReader.Immutable state = reader.getImmutable(); + final ArgumentReader.Immutable state = reader.immutable(); // First, is the argument type giving the correct return type? try { final ChatFormatting formatting = this.colorArgumentType.parse((StringReader) reader); diff --git a/src/main/java/org/spongepowered/common/command/parameter/managed/standard/SpongeDataContainerValueParameter.java b/src/main/java/org/spongepowered/common/command/parameter/managed/standard/SpongeDataContainerValueParameter.java index d5d485ef1ba..ee5a7879ca8 100644 --- a/src/main/java/org/spongepowered/common/command/parameter/managed/standard/SpongeDataContainerValueParameter.java +++ b/src/main/java/org/spongepowered/common/command/parameter/managed/standard/SpongeDataContainerValueParameter.java @@ -61,7 +61,7 @@ public List> getClientCompletionArgumentType() { @Override @NonNull - public Optional getValue(final Parameter.@NonNull Key parameterKey, + public Optional parseValue(final Parameter.@NonNull Key parameterKey, final ArgumentReader.@NonNull Mutable reader, final CommandContext.@NonNull Builder context) throws ArgumentParseException { return Optional.of(reader.parseDataContainer()); diff --git a/src/main/java/org/spongepowered/common/command/parameter/managed/standard/SpongeDateTimeValueParameter.java b/src/main/java/org/spongepowered/common/command/parameter/managed/standard/SpongeDateTimeValueParameter.java index 1c15e5993a9..1955559a028 100644 --- a/src/main/java/org/spongepowered/common/command/parameter/managed/standard/SpongeDateTimeValueParameter.java +++ b/src/main/java/org/spongepowered/common/command/parameter/managed/standard/SpongeDateTimeValueParameter.java @@ -55,7 +55,7 @@ public List complete(@NonNull final CommandContext context, final String @Override @NonNull - public Optional getValue( + public Optional parseValue( final Parameter.@NonNull Key parameterKey, final ArgumentReader.@NonNull Mutable reader, final CommandContext.@NonNull Builder context) throws ArgumentParseException { diff --git a/src/main/java/org/spongepowered/common/command/parameter/managed/standard/SpongeDurationValueParameter.java b/src/main/java/org/spongepowered/common/command/parameter/managed/standard/SpongeDurationValueParameter.java index 5b0e3ff78be..362cfe467d5 100644 --- a/src/main/java/org/spongepowered/common/command/parameter/managed/standard/SpongeDurationValueParameter.java +++ b/src/main/java/org/spongepowered/common/command/parameter/managed/standard/SpongeDurationValueParameter.java @@ -53,7 +53,7 @@ public List complete(@NonNull final CommandContext context, final String @Override @NonNull - public Optional getValue( + public Optional parseValue( final Parameter.@NonNull Key parameterKey, final ArgumentReader.@NonNull Mutable reader, final CommandContext.@NonNull Builder context) throws ArgumentParseException { diff --git a/src/main/java/org/spongepowered/common/command/parameter/managed/standard/SpongeGameProfileValueParameter.java b/src/main/java/org/spongepowered/common/command/parameter/managed/standard/SpongeGameProfileValueParameter.java index 6c1414bb3c7..6ac1c0712e3 100644 --- a/src/main/java/org/spongepowered/common/command/parameter/managed/standard/SpongeGameProfileValueParameter.java +++ b/src/main/java/org/spongepowered/common/command/parameter/managed/standard/SpongeGameProfileValueParameter.java @@ -73,13 +73,13 @@ public List complete(@NonNull final CommandContext context, @NonNull fin } @Override - public Optional getValue( + public Optional parseValue( final Parameter.@NonNull Key parameterKey, final ArgumentReader.@NonNull Mutable reader, final CommandContext.@NonNull Builder context) throws ArgumentParseException { try { final Collection profileCollection = - this.argument.parse((StringReader) reader).getNames((CommandSourceStack) context.getCause()); + this.argument.parse((StringReader) reader).getNames((CommandSourceStack) context.cause()); if (profileCollection.size() == 1) { return Optional.of(SpongeGameProfile.of(profileCollection.iterator().next())); } else if (profileCollection.isEmpty()) { @@ -88,7 +88,7 @@ public Optional getValue( throw reader.createException(Component.text("Many game profiles were selected when only one was requested.")); } } catch (final CommandSyntaxException e) { - throw new ArgumentParseException(Component.text(e.getMessage()), e, reader.getInput(), reader.getCursor()); + throw new ArgumentParseException(Component.text(e.getMessage()), e, reader.input(), reader.cursor()); } } diff --git a/src/main/java/org/spongepowered/common/command/parameter/managed/standard/SpongeIPAddressValueParameter.java b/src/main/java/org/spongepowered/common/command/parameter/managed/standard/SpongeIPAddressValueParameter.java index f092496f11e..4515a13b271 100644 --- a/src/main/java/org/spongepowered/common/command/parameter/managed/standard/SpongeIPAddressValueParameter.java +++ b/src/main/java/org/spongepowered/common/command/parameter/managed/standard/SpongeIPAddressValueParameter.java @@ -53,7 +53,7 @@ public List complete(@NonNull final CommandContext context, final String @Override @NonNull - public Optional getValue( + public Optional parseValue( final Parameter.@NonNull Key parameterKey, final ArgumentReader.@NonNull Mutable reader, final CommandContext.@NonNull Builder context) throws ArgumentParseException { diff --git a/src/main/java/org/spongepowered/common/command/parameter/managed/standard/SpongeLiteralValueParameter.java b/src/main/java/org/spongepowered/common/command/parameter/managed/standard/SpongeLiteralValueParameter.java index 90b88bc4725..ba496a0769b 100644 --- a/src/main/java/org/spongepowered/common/command/parameter/managed/standard/SpongeLiteralValueParameter.java +++ b/src/main/java/org/spongepowered/common/command/parameter/managed/standard/SpongeLiteralValueParameter.java @@ -56,7 +56,7 @@ public SpongeLiteralValueParameter(final Supplier> @Override @NonNull - public Optional getValue( + public Optional parseValue( final Parameter.@NonNull Key parameterKey, final ArgumentReader.@NonNull Mutable reader, final CommandContext.@NonNull Builder context) throws ArgumentParseException { @@ -90,7 +90,7 @@ public List complete(@NonNull final CommandContext context, @NonNull fin @Override @NonNull - public String getUsage(@NonNull final String key) { + public String usage(@NonNull final String key) { return String.join(" ", this.literalSupplier.get()); } diff --git a/src/main/java/org/spongepowered/common/command/parameter/managed/standard/SpongeNoneValueParameter.java b/src/main/java/org/spongepowered/common/command/parameter/managed/standard/SpongeNoneValueParameter.java index 2e3307f4517..36e07796a73 100644 --- a/src/main/java/org/spongepowered/common/command/parameter/managed/standard/SpongeNoneValueParameter.java +++ b/src/main/java/org/spongepowered/common/command/parameter/managed/standard/SpongeNoneValueParameter.java @@ -52,7 +52,7 @@ public List complete(@NonNull final CommandContext context, final String @Override @NonNull - public Optional getValue( + public Optional parseValue( final Parameter.@NonNull Key parameterKey, final ArgumentReader.@NonNull Mutable reader, final CommandContext.@NonNull Builder context) throws ArgumentParseException { @@ -61,13 +61,13 @@ public Optional getValue( @Override @NonNull - public String getUsage(@NonNull final String key) { + public String usage(@NonNull final String key) { return ""; } @Override @NonNull - public List getClientCompletionType() { + public List clientCompletionType() { return ImmutableList.of(ClientCompletionTypes.NONE.get()); } diff --git a/src/main/java/org/spongepowered/common/command/parameter/managed/standard/SpongePluginContainerValueParameter.java b/src/main/java/org/spongepowered/common/command/parameter/managed/standard/SpongePluginContainerValueParameter.java index 12aee52157d..7e1e4ad38dd 100644 --- a/src/main/java/org/spongepowered/common/command/parameter/managed/standard/SpongePluginContainerValueParameter.java +++ b/src/main/java/org/spongepowered/common/command/parameter/managed/standard/SpongePluginContainerValueParameter.java @@ -48,19 +48,19 @@ public SpongePluginContainerValueParameter(final ResourceKey key) { @Override @NonNull public List complete(@NonNull final CommandContext context, final String currentInput) { - return Launch.getInstance().getPluginManager().getPlugins().stream().map(x -> x.getMetadata().getId()).filter(x -> x.startsWith(currentInput)) + return Launch.getInstance().getPluginManager().plugins().stream().map(x -> x.getMetadata().getId()).filter(x -> x.startsWith(currentInput)) .collect(Collectors.toList()); } @Override @NonNull - public Optional getValue( + public Optional parseValue( final Parameter.@NonNull Key parameterKey, final ArgumentReader.@NonNull Mutable reader, final CommandContext.@NonNull Builder context) throws ArgumentParseException { final String id = reader.parseString(); - final Optional container = Launch.getInstance().getPluginManager().getPlugin(id); + final Optional container = Launch.getInstance().getPluginManager().plugin(id); if (container.isPresent()) { return container; } diff --git a/src/main/java/org/spongepowered/common/command/parameter/managed/standard/SpongeServerLocationValueParameter.java b/src/main/java/org/spongepowered/common/command/parameter/managed/standard/SpongeServerLocationValueParameter.java index eace52ebb18..49d6fb8cffb 100644 --- a/src/main/java/org/spongepowered/common/command/parameter/managed/standard/SpongeServerLocationValueParameter.java +++ b/src/main/java/org/spongepowered/common/command/parameter/managed/standard/SpongeServerLocationValueParameter.java @@ -74,36 +74,36 @@ public List complete(@NonNull final CommandContext context, @NonNull fin } private List complete(final String currentInput) { - return SpongeCommon.getGame().getServer().getWorldManager().worlds() + return SpongeCommon.getGame().server().worldManager().worlds() .stream() - .map(ServerWorld::getKey) - .map(ResourceKey::getFormatted) + .map(ServerWorld::key) + .map(ResourceKey::formatted) .filter(x -> x.startsWith(currentInput)) .collect(Collectors.toList()); } @Override @NonNull - public Optional getValue( + public Optional parseValue( final Parameter.@NonNull Key parameterKey, final ArgumentReader.@NonNull Mutable reader, final CommandContext.@NonNull Builder context) throws ArgumentParseException { - final ArgumentReader.Immutable state = reader.getImmutable(); + final ArgumentReader.Immutable state = reader.immutable(); ServerWorld serverWorld; try { final ResourceKey resourceLocation = reader.parseResourceKey("minecraft"); - serverWorld = SpongeCommon.getGame().getServer().getWorldManager() + serverWorld = SpongeCommon.getGame().server().worldManager() .world(resourceLocation) .orElseThrow(() -> reader.createException( Component.text("Could not get world with key \"" + resourceLocation.toString() + "\""))); } catch (final ArgumentParseException e) { - final Optional location = context.getCause().getLocation(); + final Optional location = context.cause().location(); if (location.isPresent()) { // do this as late as possible to prevent expense of regex. - if (!SpongeServerLocationValueParameter.STARTS_WITH_NUMBER.matcher(state.getRemaining()).find()) { + if (!SpongeServerLocationValueParameter.STARTS_WITH_NUMBER.matcher(state.remaining()).find()) { throw e; } - serverWorld = location.get().getWorld(); + serverWorld = location.get().world(); } else { throw e; } @@ -112,8 +112,8 @@ public Optional getValue( try { reader.skipWhitespace(); - final Vec3 vec3d = SpongeServerLocationValueParameter.VEC_3_ARGUMENT.parse((StringReader) reader).getPosition((CommandSourceStack) context.getCause()); - return Optional.of(serverWorld.getLocation(VecHelper.toVector3d(vec3d))); + final Vec3 vec3d = SpongeServerLocationValueParameter.VEC_3_ARGUMENT.parse((StringReader) reader).getPosition((CommandSourceStack) context.cause()); + return Optional.of(serverWorld.location(VecHelper.toVector3d(vec3d))); } catch (final CommandSyntaxException e) { throw reader.createException(Component.text(e.getMessage())); } diff --git a/src/main/java/org/spongepowered/common/command/parameter/managed/standard/SpongeTargetBlockValueParameter.java b/src/main/java/org/spongepowered/common/command/parameter/managed/standard/SpongeTargetBlockValueParameter.java index c65c4105373..e3d54304970 100644 --- a/src/main/java/org/spongepowered/common/command/parameter/managed/standard/SpongeTargetBlockValueParameter.java +++ b/src/main/java/org/spongepowered/common/command/parameter/managed/standard/SpongeTargetBlockValueParameter.java @@ -51,20 +51,20 @@ public Optional getValue(final CommandContext.@NonNull final ArgumentReader.@NonNull Mutable reader) throws ArgumentParseException { - final Object root = context.getCause().getCause().root(); + final Object root = context.cause().cause().root(); if (root instanceof Living) { final Living living = (Living) root; final Optional> rayTraceResult = RayTrace.block() .sourceEyePosition(living) - .direction(living.getHeadDirection()) + .direction(living.headDirection()) .limit(30) .continueWhileBlock(RayTrace.onlyAir()) .select(RayTrace.nonAir()) .continueWhileEntity(r -> false) .execute(); if (rayTraceResult.isPresent()) { - return rayTraceResult.map(x -> x.getSelectedObject().getServerLocation()); + return rayTraceResult.map(x -> x.selectedObject().serverLocation()); } throw reader.createException(Component.text("The cause root is not looking at a block!")); diff --git a/src/main/java/org/spongepowered/common/command/parameter/managed/standard/SpongeTargetEntityValueParameter.java b/src/main/java/org/spongepowered/common/command/parameter/managed/standard/SpongeTargetEntityValueParameter.java index 76baf767524..16b754401e9 100644 --- a/src/main/java/org/spongepowered/common/command/parameter/managed/standard/SpongeTargetEntityValueParameter.java +++ b/src/main/java/org/spongepowered/common/command/parameter/managed/standard/SpongeTargetEntityValueParameter.java @@ -54,20 +54,20 @@ public Optional getValue( final CommandContext.@NonNull Builder context, final ArgumentReader.@NonNull Mutable reader) throws ArgumentParseException { - final Object root = context.getCause().getCause().root(); + final Object root = context.cause().cause().root(); if (root instanceof Living) { final Living living = (Living) root; final Optional> rayTraceResult = RayTrace.entity() .sourceEyePosition(living) - .direction(living.getHeadDirection()) + .direction(living.headDirection()) .limit(30) .continueWhileBlock(RayTrace.onlyAir()) .select(this.isPlayerOnly ? entity -> entity instanceof Player : entity -> true) .continueWhileEntity(r -> false) // if we hit an entity first, it obscures a player. .execute(); if (rayTraceResult.isPresent()) { - return rayTraceResult.map(RayTraceResult::getSelectedObject); + return rayTraceResult.map(RayTraceResult::selectedObject); } throw reader.createException(Component.text("The cause root is not looking at a entity!")); diff --git a/src/main/java/org/spongepowered/common/command/parameter/managed/standard/SpongeTextValueParameter.java b/src/main/java/org/spongepowered/common/command/parameter/managed/standard/SpongeTextValueParameter.java index 4ddee03bc88..aba5b7909fa 100644 --- a/src/main/java/org/spongepowered/common/command/parameter/managed/standard/SpongeTextValueParameter.java +++ b/src/main/java/org/spongepowered/common/command/parameter/managed/standard/SpongeTextValueParameter.java @@ -66,14 +66,14 @@ public List complete(@NonNull final CommandContext context, final String @Override @NonNull - public Optional getValue( + public Optional parseValue( final Parameter.@NonNull Key parameterKey, final ArgumentReader.@NonNull Mutable reader, final CommandContext.@NonNull Builder context) throws ArgumentParseException { final String toConvert; if (this.consumeAll) { - toConvert = reader.getRemaining(); + toConvert = reader.remaining(); while (reader.canRead()) { reader.parseString(); } diff --git a/src/main/java/org/spongepowered/common/command/parameter/managed/standard/SpongeUserValueParameter.java b/src/main/java/org/spongepowered/common/command/parameter/managed/standard/SpongeUserValueParameter.java index 14c020260a8..ed64fff65e2 100644 --- a/src/main/java/org/spongepowered/common/command/parameter/managed/standard/SpongeUserValueParameter.java +++ b/src/main/java/org/spongepowered/common/command/parameter/managed/standard/SpongeUserValueParameter.java @@ -69,13 +69,13 @@ public CompletableFuture listSuggestions( @Override @NonNull public List complete(@NonNull final CommandContext context, @NonNull final String currentInput) { - return Sponge.getServer().getUserManager().streamOfMatches(currentInput).filter(GameProfile::hasName) - .map(x -> x.getName().orElse("")).collect(Collectors.toList()); + return Sponge.server().userManager().streamOfMatches(currentInput).filter(GameProfile::hasName) + .map(x -> x.name().orElse("")).collect(Collectors.toList()); } @Override @NonNull - public Optional getValue( + public Optional parseValue( final Parameter.@NonNull Key parameterKey, final ArgumentReader.@NonNull Mutable reader, final CommandContext.@NonNull Builder context) @@ -86,20 +86,20 @@ public Optional getValue( final ServerPlayer entity = (ServerPlayer) (this.selectorArgumentType.parse((StringReader) reader) .findSingleEntity(((SpongeCommandContextBuilder) context).getSource())); - return Optional.of(entity.getUser()); + return Optional.of(entity.user()); } catch (final CommandSyntaxException e) { throw reader.createException(Component.text(e.getContext())); } } - final UserManager userManager = SpongeCommon.getGame().getServer().getUserManager(); + final UserManager userManager = SpongeCommon.getGame().server().userManager(); Optional user; try { final UUID uuid = UUID.fromString(reader.parseString()); - user = userManager.get(uuid); + user = userManager.find(uuid); } catch (final Exception e) { // if no UUID, get the name. We've already advanced the reader at this point. - user = userManager.get(peek); + user = userManager.find(peek); } if (user.isPresent()) { diff --git a/src/main/java/org/spongepowered/common/command/parameter/multi/SpongeMultiParameter.java b/src/main/java/org/spongepowered/common/command/parameter/multi/SpongeMultiParameter.java index 8ffc119c505..2bf449db60a 100644 --- a/src/main/java/org/spongepowered/common/command/parameter/multi/SpongeMultiParameter.java +++ b/src/main/java/org/spongepowered/common/command/parameter/multi/SpongeMultiParameter.java @@ -43,7 +43,7 @@ protected SpongeMultiParameter(final List parameterCandidates, final } @Override - public List getChildParameters() { + public List childParameters() { // put subcommands first. return this.parameterCandidates.stream().sorted((x1, x2) -> { final boolean firstIs = x1 instanceof Parameter.Subcommand; diff --git a/src/main/java/org/spongepowered/common/command/parameter/subcommand/SpongeSubcommandParameter.java b/src/main/java/org/spongepowered/common/command/parameter/subcommand/SpongeSubcommandParameter.java index afabe32c561..b6305d9fd5a 100644 --- a/src/main/java/org/spongepowered/common/command/parameter/subcommand/SpongeSubcommandParameter.java +++ b/src/main/java/org/spongepowered/common/command/parameter/subcommand/SpongeSubcommandParameter.java @@ -53,13 +53,13 @@ public boolean isTerminal() { } @Override - public Command.@NonNull Parameterized getCommand() { + public Command.@NonNull Parameterized command() { return this.command; } @Override @NonNull - public Set getAliases() { + public Set aliases() { return ImmutableSet.copyOf(this.aliases); } diff --git a/src/main/java/org/spongepowered/common/command/parameter/subcommand/SpongeSubcommandParameterBuilder.java b/src/main/java/org/spongepowered/common/command/parameter/subcommand/SpongeSubcommandParameterBuilder.java index d8c8b392bf8..49604490f89 100644 --- a/src/main/java/org/spongepowered/common/command/parameter/subcommand/SpongeSubcommandParameterBuilder.java +++ b/src/main/java/org/spongepowered/common/command/parameter/subcommand/SpongeSubcommandParameterBuilder.java @@ -41,7 +41,7 @@ public final class SpongeSubcommandParameterBuilder implements Parameter.Subcomm private Command.@Nullable Parameterized command; @Override - public Parameter.Subcommand.@NonNull Builder alias(@NonNull final String alias) { + public Parameter.Subcommand.@NonNull Builder addAlias(@NonNull final String alias) { this.aliases.add(alias); return this; } @@ -52,7 +52,7 @@ public SpongeSubcommandParameterBuilder aliases(@NonNull final Collection register(final LiteralArgumentBuilder command) { // Get the plugin container - final PluginContainer container = PhaseTracker.getCauseStackManager().getCurrentCause().first(PluginContainer.class) + final PluginContainer container = PhaseTracker.getCauseStackManager().currentCause().first(PluginContainer.class) .orElseThrow(() -> new IllegalStateException("Cannot register command without knowing its origin.")); return this.registerInternal(this, container, this.applyNamespace(container, command, false), new String[0], - true).getSecond(); + true).second(); } @Override @@ -107,7 +107,7 @@ public CommandMapping register( @NonNull final String primaryAlias, final String @NonNull... secondaryAliases) throws CommandFailedRegistrationException { - return this.register(container, command, secondaryAliases).getFirst(); + return this.register(container, command, secondaryAliases).first(); } /** @@ -136,7 +136,7 @@ private Tuple> registerIn // Get the builder and the first literal. final String requestedAlias = namespacedCommand.getLiteral(); - final Optional existingMapping = this.manager.getCommandMapping(requestedAlias); + final Optional existingMapping = this.manager.commandMapping(requestedAlias); if (allowDuplicates && existingMapping.isPresent()) { // then we just let it go, the requirements will be of the old node. this.dispatcher.register(namespacedCommand); @@ -155,7 +155,7 @@ private Tuple> registerIn this.dispatcher.register(namespacedCommand); // Redirect aliases - for (final String alias : mapping.getAllAliases()) { + for (final String alias : mapping.allAliases()) { if (!alias.equals(namespacedCommand.getLiteral())) { final LiteralArgumentBuilder redirecting = LiteralArgumentBuilder.literal(alias) .executes(namespacedCommand.getCommand()) @@ -182,7 +182,7 @@ public CommandResult process( @NonNull final String arguments) throws CommandException { try { final int result = this.dispatcher.execute(this.dispatcher.parse(this.createCommandString(command, arguments), (CommandSourceStack) cause)); - return CommandResult.builder().setResult(result).build(); + return CommandResult.builder().result(result).build(); } catch (final CommandSyntaxException e) { throw new CommandException(Component.text(e.getMessage()), e); } @@ -205,7 +205,7 @@ public List suggestions( @Override @NonNull public Optional help(@NonNull final CommandCause cause, @NonNull final CommandMapping mapping) { - final CommandNode node = this.dispatcher.findNode(Collections.singletonList(mapping.getPrimaryAlias())); + final CommandNode node = this.dispatcher.findNode(Collections.singletonList(mapping.primaryAlias())); if (node != null) { return Optional.of(Component.text(this.dispatcher.getSmartUsage(node, (CommandSourceStack) cause).toString())); } @@ -215,7 +215,7 @@ public Optional help(@NonNull final CommandCause cause, @NonNull fina @Override public boolean canExecute(final CommandCause cause, final CommandMapping mapping) { - return this.dispatcher.findNode(Collections.singletonList(mapping.getPrimaryAlias())).getRequirement().test((CommandSourceStack) cause); + return this.dispatcher.findNode(Collections.singletonList(mapping.primaryAlias())).getRequirement().test((CommandSourceStack) cause); } public SpongeCommandDispatcher getDispatcher() { diff --git a/src/main/java/org/spongepowered/common/command/registrar/SpongeCommandRegistrarTypes.java b/src/main/java/org/spongepowered/common/command/registrar/SpongeCommandRegistrarTypes.java index 4eeb0f0b314..794143b950a 100644 --- a/src/main/java/org/spongepowered/common/command/registrar/SpongeCommandRegistrarTypes.java +++ b/src/main/java/org/spongepowered/common/command/registrar/SpongeCommandRegistrarTypes.java @@ -55,6 +55,6 @@ private SpongeCommandRegistrarTypes() { } private static DefaultedRegistryReference> key(final ResourceKey location) { - return RegistryKey.of(RegistryTypes.COMMAND_REGISTRAR_TYPE, location).asDefaultedReference(() -> Sponge.getGame().registries()); + return RegistryKey.of(RegistryTypes.COMMAND_REGISTRAR_TYPE, location).asDefaultedReference(() -> Sponge.game().registries()); } } diff --git a/src/main/java/org/spongepowered/common/command/registrar/SpongeParameterizedCommandRegistrar.java b/src/main/java/org/spongepowered/common/command/registrar/SpongeParameterizedCommandRegistrar.java index f32aa368dfa..54586780083 100644 --- a/src/main/java/org/spongepowered/common/command/registrar/SpongeParameterizedCommandRegistrar.java +++ b/src/main/java/org/spongepowered/common/command/registrar/SpongeParameterizedCommandRegistrar.java @@ -116,7 +116,7 @@ public CommandResult process( @NonNull final String arguments) throws CommandException { try { final SpongeCommandDispatcher dispatcher = this.commandManager().getDispatcher(); - return CommandResult.builder().setResult( + return CommandResult.builder().result( dispatcher.execute( dispatcher.parse(this.createCommandString(command, arguments), (CommandSourceStack) cause))).build(); } catch (final SpongeCommandSyntaxException ex) { @@ -154,7 +154,7 @@ public Optional help(@NonNull final CommandCause cause, @NonNull fina throw new IllegalArgumentException(command + " is not a valid a valid command!"); } - return commandEntry.getHelp(cause); + return commandEntry.help(cause); } @Override @@ -174,7 +174,7 @@ private Collection> createNode(final Comm if (!(command instanceof SpongeParameterizedCommand)) { throw new IllegalArgumentException("Command must be a SpongeParameterizedCommand!"); } - return ((SpongeParameterizedCommand) command).buildWithAliases(mapping.getAllAliases()); + return ((SpongeParameterizedCommand) command).buildWithAliases(mapping.allAliases()); } } diff --git a/src/main/java/org/spongepowered/common/command/registrar/SpongeRawCommandRegistrar.java b/src/main/java/org/spongepowered/common/command/registrar/SpongeRawCommandRegistrar.java index fb8ce0c8d79..06e4a948201 100644 --- a/src/main/java/org/spongepowered/common/command/registrar/SpongeRawCommandRegistrar.java +++ b/src/main/java/org/spongepowered/common/command/registrar/SpongeRawCommandRegistrar.java @@ -95,7 +95,7 @@ public CommandResult process(final CommandCause cause, final CommandMapping mapp public List suggestions(final CommandCause cause, final CommandMapping mapping, final String command, final String arguments) throws CommandException { final Command.Raw commandToExecute = this.commands.get(mapping); if (commandToExecute.canExecute(cause)) { - return commandToExecute.getSuggestions(cause, new SpongeStringReader(arguments)); + return commandToExecute.suggestions(cause, new SpongeStringReader(arguments)); } return Collections.emptyList(); } @@ -104,7 +104,7 @@ public List suggestions(final CommandCause cause, final CommandMapping m public Optional help(final CommandCause cause, final CommandMapping mapping) { final Command.Raw commandToExecute = this.commands.get(mapping); if (commandToExecute.canExecute(cause)) { - return commandToExecute.getHelp(cause); + return commandToExecute.help(cause); } return Optional.empty(); } diff --git a/src/main/java/org/spongepowered/common/command/registrar/tree/key/SpongeEntityClientCompletionKey.java b/src/main/java/org/spongepowered/common/command/registrar/tree/key/SpongeEntityClientCompletionKey.java index 712099f114b..4da43a057d5 100644 --- a/src/main/java/org/spongepowered/common/command/registrar/tree/key/SpongeEntityClientCompletionKey.java +++ b/src/main/java/org/spongepowered/common/command/registrar/tree/key/SpongeEntityClientCompletionKey.java @@ -45,7 +45,7 @@ public SpongeEntityClientCompletionKey(final ResourceKey key) { @Override @NonNull - public ResourceKey getKey() { + public ResourceKey key() { return this.key; } diff --git a/src/main/java/org/spongepowered/common/command/result/SpongeCommandResult.java b/src/main/java/org/spongepowered/common/command/result/SpongeCommandResult.java index 22cc2948780..8c1851fcef3 100644 --- a/src/main/java/org/spongepowered/common/command/result/SpongeCommandResult.java +++ b/src/main/java/org/spongepowered/common/command/result/SpongeCommandResult.java @@ -52,13 +52,13 @@ public boolean isSuccess() { } @Override - public int getResult() { + public int result() { return this.result; } @Override @NonNull - public Optional getErrorMessage() { + public Optional errorMessage() { return Optional.ofNullable(this.errorMessage); } diff --git a/src/main/java/org/spongepowered/common/command/result/SpongeCommandResultBuilder.java b/src/main/java/org/spongepowered/common/command/result/SpongeCommandResultBuilder.java index 7d4cd29ae3c..3a4a0087014 100644 --- a/src/main/java/org/spongepowered/common/command/result/SpongeCommandResultBuilder.java +++ b/src/main/java/org/spongepowered/common/command/result/SpongeCommandResultBuilder.java @@ -36,7 +36,7 @@ public final class SpongeCommandResultBuilder implements CommandResult.Builder { @Nullable private Component errorMessage; @Override - public CommandResult.@NonNull Builder setResult(final int result) { + public CommandResult.@NonNull Builder result(final int result) { this.result = result; return this; } diff --git a/src/main/java/org/spongepowered/common/command/sponge/CommandAliasesParameter.java b/src/main/java/org/spongepowered/common/command/sponge/CommandAliasesParameter.java index 85c50319321..cd7ea030338 100644 --- a/src/main/java/org/spongepowered/common/command/sponge/CommandAliasesParameter.java +++ b/src/main/java/org/spongepowered/common/command/sponge/CommandAliasesParameter.java @@ -45,11 +45,11 @@ public final class CommandAliasesParameter implements ValueParameter complete(final CommandContext context, final String input) { - return Sponge.getGame().getServer().getCommandManager().getKnownAliases().stream().filter(x -> x.startsWith(input)).collect(Collectors.toList()); + return Sponge.game().server().commandManager().knownAliases().stream().filter(x -> x.startsWith(input)).collect(Collectors.toList()); } @Override - public Optional getValue( + public Optional parseValue( final Parameter.Key parameterKey, final ArgumentReader.Mutable reader, final CommandContext.Builder context) throws ArgumentParseException { @@ -57,8 +57,7 @@ public Optional getValue( if (reader.canRead() && reader.peekCharacter() == ':') { alias += reader.parseChar() + reader.parseUnquotedString(); } - final Optional mapping = - Sponge.getGame().getServer().getCommandManager().getCommandMapping(alias); + final Optional mapping = Sponge.game().server().commandManager().commandMapping(alias); if (mapping.isPresent()) { return mapping; } @@ -66,7 +65,7 @@ public Optional getValue( } @Override - public List getClientCompletionType() { + public List clientCompletionType() { return Collections.singletonList(ClientCompletionTypes.RESOURCE_KEY.get()); } diff --git a/src/main/java/org/spongepowered/common/command/sponge/FilteredPluginContainerParameter.java b/src/main/java/org/spongepowered/common/command/sponge/FilteredPluginContainerParameter.java index f3252a370a8..15fac1ffdb9 100644 --- a/src/main/java/org/spongepowered/common/command/sponge/FilteredPluginContainerParameter.java +++ b/src/main/java/org/spongepowered/common/command/sponge/FilteredPluginContainerParameter.java @@ -45,7 +45,7 @@ public final class FilteredPluginContainerParameter implements ValueParameter validPluginContainers = FilteredPluginContainerParameter.getValidContainers(); private static Map getValidContainers() { - return Launch.getInstance().getPluginManager().getPlugins() + return Launch.getInstance().getPluginManager().plugins() .stream() .filter(x -> !(x instanceof DummyPluginContainer)) .collect(Collectors.toMap(x -> x.getMetadata().getId(), x -> x)); @@ -57,7 +57,7 @@ public List complete(final CommandContext context, String currentInput) } @Override - public Optional getValue( + public Optional parseValue( final Parameter.Key parameterKey, final ArgumentReader.Mutable reader, final CommandContext.Builder context) throws ArgumentParseException { diff --git a/src/main/java/org/spongepowered/common/command/sponge/SpongeCommand.java b/src/main/java/org/spongepowered/common/command/sponge/SpongeCommand.java index f82522b82bb..d88935ba6a2 100644 --- a/src/main/java/org/spongepowered/common/command/sponge/SpongeCommand.java +++ b/src/main/java/org/spongepowered/common/command/sponge/SpongeCommand.java @@ -90,9 +90,9 @@ public class SpongeCommand { public Command.Parameterized createSpongeCommand() { // /sponge audit final Command.Parameterized auditCommand = Command.builder() - .setPermission("sponge.command.audit") - .setShortDescription(Component.text("Audit mixin classes for implementation")) - .setExecutor(this::auditSubcommandExecutor) + .permission("sponge.command.audit") + .shortDescription(Component.text("Audit mixin classes for implementation")) + .executor(this::auditSubcommandExecutor) .build(); // /sponge chunks @@ -100,38 +100,38 @@ public Command.Parameterized createSpongeCommand() { // /sponge heap final Command.Parameterized heapCommand = Command.builder() - .setPermission("sponge.command.heap") - .setShortDescription(Component.text("Dump live JVM heap")) - .setExecutor(this::heapSubcommandExecutor) + .permission("sponge.command.heap") + .shortDescription(Component.text("Dump live JVM heap")) + .executor(this::heapSubcommandExecutor) .build(); // /sponge plugins final Command.Parameterized pluginsReloadCommand = Command.builder() - .setPermission("sponge.command.plugins.refresh") - .setShortDescription(Component.text("Refreshes supported plugins, typically causing plugin configuration reloads.")) - .parameter(Parameter.builder(PluginContainer.class) + .permission("sponge.command.plugins.refresh") + .shortDescription(Component.text("Refreshes supported plugins, typically causing plugin configuration reloads.")) + .addParameter(Parameter.builder(PluginContainer.class) .optional() - .parser(new FilteredPluginContainerParameter()) - .setKey(this.pluginContainerKey) + .addParser(new FilteredPluginContainerParameter()) + .key(this.pluginContainerKey) .build()) - .setExecutor(this::pluginsRefreshSubcommandExecutor) + .executor(this::pluginsRefreshSubcommandExecutor) .build(); final Command.Parameterized pluginsListCommand = Command.builder() - .setPermission("sponge.command.plugins.list") - .setShortDescription(Component.text("Lists all currently installed plugins.")) - .setExecutor(this::pluginsListSubcommand) + .permission("sponge.command.plugins.list") + .shortDescription(Component.text("Lists all currently installed plugins.")) + .executor(this::pluginsListSubcommand) .build(); final Command.Parameterized pluginsInfoCommand = Command.builder() - .setPermission("sponge.command.plugins.info") - .setShortDescription(Component.text("Displays information about a specific plugin.")) - .parameter(Parameter.plugin().setKey(this.pluginContainerKey).build()) - .setExecutor(this::pluginsInfoSubcommand) + .permission("sponge.command.plugins.info") + .shortDescription(Component.text("Displays information about a specific plugin.")) + .addParameter(Parameter.plugin().key(this.pluginContainerKey).build()) + .executor(this::pluginsInfoSubcommand) .build(); final Command.Parameterized pluginsCommand = Command.builder() - .child(pluginsReloadCommand, "refresh") - .child(pluginsListCommand, "list") - .child(pluginsInfoCommand, "info") + .addChild(pluginsReloadCommand, "refresh") + .addChild(pluginsListCommand, "list") + .addChild(pluginsInfoCommand, "info") .build(); // /sponge timings @@ -139,59 +139,59 @@ public Command.Parameterized createSpongeCommand() { // /sponge tps final Command.Parameterized tpsCommand = Command.builder() - .setPermission("sponge.command.tps") - .setShortDescription(Component.text("Provides TPS (ticks per second) data for loaded worlds.")) - .setExecutor(this::tpsExecutor) + .permission("sponge.command.tps") + .shortDescription(Component.text("Provides TPS (ticks per second) data for loaded worlds.")) + .executor(this::tpsExecutor) .build(); // /sponge version final Command.Parameterized versionCommand = Command.builder() - .setPermission("sponge.command.version") - .setShortDescription(Component.text("Display Sponge's current version")) - .setExecutor(this::versionExecutor) + .permission("sponge.command.version") + .shortDescription(Component.text("Display Sponge's current version")) + .executor(this::versionExecutor) .build(); // /sponge which final Command.Parameterized whichCommand = Command.builder() - .setPermission("sponge.command.which") - .parameter(Parameter.builder(CommandMapping.class).setKey(this.commandMappingKey).parser(new CommandAliasesParameter()).build()) - .setShortDescription(Component.text("Find the plugin that owns a specific command")) - .setExecutor(this::whichExecutor) + .permission("sponge.command.which") + .addParameter(Parameter.builder(CommandMapping.class).key(this.commandMappingKey).addParser(new CommandAliasesParameter()).build()) + .shortDescription(Component.text("Find the plugin that owns a specific command")) + .executor(this::whichExecutor) .build(); // /sponge reload global|world [id] final Command.Parameterized reloadGlobalCommand = Command.builder() - .setPermission("sponge.command.reload.global") - .setShortDescription(Component.text("Reload Sponge's common configuration")) - .setExecutor(this::reloadGlobalExecutor) + .permission("sponge.command.reload.global") + .shortDescription(Component.text("Reload Sponge's common configuration")) + .executor(this::reloadGlobalExecutor) .build(); final Command.Parameterized reloadWorldCommand = Command.builder() - .setPermission("sponge.command.reload.world") - .parameter(Parameter.world().setKey(this.worldKey).build()) - .setShortDescription(Component.text("Reload Sponge's configuration for a single world")) - .setExecutor(this::reloadWorldExecutor) + .permission("sponge.command.reload.world") + .addParameter(Parameter.world().key(this.worldKey).build()) + .shortDescription(Component.text("Reload Sponge's configuration for a single world")) + .executor(this::reloadWorldExecutor) .build(); final Command.Parameterized reloadCommand = Command.builder() - .child(reloadGlobalCommand, "global") - .child(reloadWorldCommand, "world") + .addChild(reloadGlobalCommand, "global") + .addChild(reloadWorldCommand, "world") .build(); // /sponge final Command.Builder commandBuilder = Command.builder() - .setPermission("sponge.command.root") - .setExecutor(this::rootCommand) - .child(auditCommand, "audit") - .child(chunksCommand, "chunks") - .child(heapCommand, "heap") - .child(pluginsCommand, "plugins") - .child(timingsCommand, "timings") - .child(tpsCommand, "tps") - .child(versionCommand, "version") - .child(whichCommand, "which") - .child(reloadCommand, "reload"); + .permission("sponge.command.root") + .executor(this::rootCommand) + .addChild(auditCommand, "audit") + .addChild(chunksCommand, "chunks") + .addChild(heapCommand, "heap") + .addChild(pluginsCommand, "plugins") + .addChild(timingsCommand, "timings") + .addChild(tpsCommand, "tps") + .addChild(versionCommand, "version") + .addChild(whichCommand, "which") + .addChild(reloadCommand, "reload"); this.additionalActions(commandBuilder); return commandBuilder.build(); @@ -217,13 +217,13 @@ private CommandResult rootCommand(final CommandContext context) { ).build() ); - final Optional parameterized = context.getExecutedCommand(); + final Optional parameterized = context.executedCommand(); if (parameterized.isPresent()) { final String subcommands = parameterized.get() .subcommands() .stream() - .filter(x -> x.getCommand().canExecute(context.getCause())) - .flatMap(x -> x.getAliases().stream()) + .filter(x -> x.command().canExecute(context.cause())) + .flatMap(x -> x.aliases().stream()) .collect(Collectors.joining(", ")); if (!subcommands.isEmpty()) { context.sendMessage(Identity.nil(), Component.text().append( @@ -247,10 +247,10 @@ private CommandResult auditSubcommandExecutor(final CommandContext context) { private Command.Parameterized chunksSubcommand() { final Command.Parameterized globalCommand = Command.builder() - .setExecutor(context -> { - for (final ServerWorld world : SpongeCommon.getGame().getServer().getWorldManager().worlds()) { + .executor(context -> { + for (final ServerWorld world : SpongeCommon.getGame().server().worldManager().worlds()) { context.sendMessage(Identity.nil(), Component.text().content("World ") - .append(Component.text(world.getKey().toString(), Style.style(TextDecoration.BOLD))) + .append(Component.text(world.key().toString(), Style.style(TextDecoration.BOLD))) .append(this.getChunksInfo(world)) .build()); } @@ -258,11 +258,11 @@ private Command.Parameterized chunksSubcommand() { }) .build(); final Command.Parameterized worldCommand = Command.builder() - .parameter(CommonParameters.WORLD) - .setExecutor(context -> { + .addParameter(CommonParameters.WORLD) + .executor(context -> { final ServerWorld world = context.requireOne(CommonParameters.WORLD); context.sendMessage(Identity.nil(), Component.text().content("World ") - .append(Component.text(world.getKey().toString(), Style.style(TextDecoration.BOLD))) + .append(Component.text(world.key().toString(), Style.style(TextDecoration.BOLD))) .append(this.getChunksInfo(world)) .build()); return CommandResult.success(); @@ -270,8 +270,8 @@ private Command.Parameterized chunksSubcommand() { .build(); final Parameter.Key dumpAllKey = Parameter.key("dumpAll", Boolean.class); final Command.Parameterized dumpCommand = Command.builder() - .parameter(Parameter.literal(Boolean.class, true, "all").optional().setKey(dumpAllKey).build()) - .setExecutor(context -> { + .addParameter(Parameter.literal(Boolean.class, true, "all").optional().key(dumpAllKey).build()) + .executor(context -> { final File file = new File(new File(new File("."), "chunk-dumps"), "chunk-info-" + DateTimeFormatter.ofPattern("yyyy-MM-dd_HH.mm.ss").format(LocalDateTime.now()) + "-server.txt"); context.sendMessage(Identity.nil(), Component.text("Writing chunk info to: " + file.getAbsolutePath())); @@ -281,10 +281,10 @@ private Command.Parameterized chunksSubcommand() { }) .build(); return Command.builder() - .child(globalCommand, "global") - .child(worldCommand, "world") - .child(dumpCommand, "dump") - .setPermission("sponge.command.chunk") + .addChild(globalCommand, "global") + .addChild(worldCommand, "world") + .addChild(dumpCommand, "dump") + .permission("sponge.command.chunk") .build(); } @@ -314,7 +314,7 @@ private CommandResult heapSubcommandExecutor(final CommandContext context) { @NonNull private CommandResult pluginsListSubcommand(final CommandContext context) { - final Collection plugins = Launch.getInstance().getPluginManager().getPlugins(); + final Collection plugins = Launch.getInstance().getPluginManager().plugins(); context.sendMessage(Identity.nil(), this.title("Plugins (" + plugins.size() + ")")); for (final PluginContainer specificContainer : plugins) { final PluginMetadata metadata = specificContainer.getMetadata(); @@ -337,18 +337,18 @@ private CommandResult pluginsInfoSubcommand(final CommandContext context) { @NonNull private CommandResult pluginsRefreshSubcommandExecutor(final CommandContext context) { - final Optional pluginContainer = context.getOne(this.pluginContainerKey); + final Optional pluginContainer = context.one(this.pluginContainerKey); final RefreshGameEvent event = SpongeEventFactory.createRefreshGameEvent( - PhaseTracker.getCauseStackManager().getCurrentCause(), + PhaseTracker.getCauseStackManager().currentCause(), SpongeCommon.getGame() ); if (pluginContainer.isPresent()) { // just send the reload event to that context.sendMessage(Identity.nil(), Component.text("Sending refresh event to" + pluginContainer.get().getMetadata().getId() + ", please wait...")); - ((SpongeEventManager) SpongeCommon.getGame().getEventManager()).post(event, pluginContainer.get()); + ((SpongeEventManager) SpongeCommon.getGame().eventManager()).post(event, pluginContainer.get()); } else { context.sendMessage(Identity.nil(), Component.text("Sending refresh event to all plugins, please wait...")); - SpongeCommon.getGame().getEventManager().post(event); + SpongeCommon.getGame().eventManager().post(event); } context.sendMessage(Identity.nil(), Component.text("Completed plugin refresh.")); @@ -357,10 +357,10 @@ private CommandResult pluginsRefreshSubcommandExecutor(final CommandContext cont private Command.@NonNull Parameterized timingsSubcommand() { return Command.builder() - .setPermission("sponge.command.timings") - .setShortDescription(Component.text("Manages Sponge Timings data to see performance of the server.")) - .child(Command.builder() - .setExecutor(context -> { + .permission("sponge.command.timings") + .shortDescription(Component.text("Manages Sponge Timings data to see performance of the server.")) + .addChild(Command.builder() + .executor(context -> { if (!Timings.isTimingsEnabled()) { context.sendMessage(Identity.nil(), Component.text("Please enable timings by typing /sponge timings on")); return CommandResult.empty(); @@ -370,32 +370,32 @@ private CommandResult pluginsRefreshSubcommandExecutor(final CommandContext cont return CommandResult.success(); }) .build(), "reset") - .child(Command.builder() - .setExecutor(context -> { + .addChild(Command.builder() + .executor(context -> { if (!Timings.isTimingsEnabled()) { context.sendMessage(Identity.nil(), Component.text("Please enable timings by typing /sponge timings on")); return CommandResult.empty(); } - Timings.generateReport(context.getCause().getAudience()); + Timings.generateReport(context.cause().audience()); return CommandResult.success(); }) .build(), "report", "paste") - .child(Command.builder() - .setExecutor(context -> { + .addChild(Command.builder() + .executor(context -> { Timings.setTimingsEnabled(true); context.sendMessage(Identity.nil(), Component.text("Enabled Timings & Reset")); return CommandResult.success(); }) .build(), "on") - .child(Command.builder() - .setExecutor(context -> { + .addChild(Command.builder() + .executor(context -> { Timings.setTimingsEnabled(false); context.sendMessage(Identity.nil(), Component.text("Disabled Timings")); return CommandResult.success(); }) .build(), "off") - .child(Command.builder() - .setExecutor(context -> { + .addChild(Command.builder() + .executor(context -> { if (!Timings.isTimingsEnabled()) { context.sendMessage(Identity.nil(), Component.text("Please enable timings by typing /sponge timings on")); return CommandResult.empty(); @@ -405,8 +405,8 @@ private CommandResult pluginsRefreshSubcommandExecutor(final CommandContext cont return CommandResult.success(); }) .build(), "verbon") - .child(Command.builder() - .setExecutor(context -> { + .addChild(Command.builder() + .executor(context -> { if (!Timings.isTimingsEnabled()) { context.sendMessage(Identity.nil(), Component.text("Please enable timings by typing /sponge timings on")); return CommandResult.empty(); @@ -416,8 +416,8 @@ private CommandResult pluginsRefreshSubcommandExecutor(final CommandContext cont return CommandResult.success(); }) .build(), "verboff") - .child(Command.builder() - .setExecutor(context -> { + .addChild(Command.builder() + .executor(context -> { if (!Timings.isTimingsEnabled()) { context.sendMessage(Identity.nil(), Component.text("Please enable timings by typing /sponge timings on")); return CommandResult.empty(); @@ -432,7 +432,7 @@ private CommandResult pluginsRefreshSubcommandExecutor(final CommandContext cont private CommandResult tpsExecutor(final CommandContext context) { final List tps = new ArrayList<>(); // Uncomment when per-world TPS is in and working. -// for (final ServerWorld world : Sponge.getServer().getWorldManager().getWorlds()) { +// for (final ServerWorld world : Sponge.getServer().worldManager().getWorlds()) { // // Add code to get the average here. // final TextComponent.Builder builder = // TextComponent.builder("World [") @@ -443,13 +443,13 @@ private CommandResult tpsExecutor(final CommandContext context) { tps.add(this.appendTickTime(SpongeCommon.getServer().tickTimes, Component.text().content("Overall TPS: ")).build()); - SpongeCommon.getGame().getServiceProvider() + SpongeCommon.getGame().serviceProvider() .paginationService() .builder() .contents(tps) .title(Component.text("Server TPS", NamedTextColor.WHITE)) .padding(Component.text("-", NamedTextColor.WHITE)) - .sendTo(context.getCause().getAudience()); + .sendTo(context.cause().audience()); return CommandResult.success(); } @@ -518,10 +518,10 @@ private CommandResult whichExecutor(final CommandContext context) { context.sendMessage(Identity.nil(), Component.text().append( this.title("Aliases: "), Component.join(Component.text(", "), - mapping.getAllAliases().stream().map(x -> Component.text(x, NamedTextColor.YELLOW)).collect(Collectors.toList())), + mapping.allAliases().stream().map(x -> Component.text(x, NamedTextColor.YELLOW)).collect(Collectors.toList())), Component.newline(), this.title("Owned by: "), - this.hl(mapping.getPlugin().getMetadata().getName().orElseGet(() -> mapping.getPlugin().getMetadata().getId()))) + this.hl(mapping.plugin().getMetadata().getName().orElseGet(() -> mapping.plugin().getMetadata().getId()))) .build()); return CommandResult.success(); } @@ -541,7 +541,7 @@ private CommandResult whichExecutor(final CommandContext context) { private @NonNull CommandResult reloadWorldExecutor(final CommandContext context) { final ServerWorld target = context.requireOne(this.worldKey); - final ResourceKey worldId = target.getKey(); + final ResourceKey worldId = target.key(); SpongeGameConfigs.getForWorld(target).reload() .whenComplete(($, error) -> { if (error != null) { @@ -563,14 +563,14 @@ private CommandResult whichExecutor(final CommandContext context) { // -- protected Component getChunksInfo(final ServerWorld worldserver) { - if (((WorldBridge) worldserver).bridge$isFake() || worldserver.getWorldStorage().getWorldProperties() == null) { + if (((WorldBridge) worldserver).bridge$isFake() || worldserver.worldStorage().worldProperties() == null) { return Component.text().append(Component.newline(), Component.text("Fake world")).build(); } return Component.text().append(Component.newline(), Component.text("chunk stuff here")).build(); /* key("DimensionId: "), value(((WorldServerBridge) worldserver).bridge$getDimensionId()), TextComponent.newline(), key("Loaded chunks: "), value(worldserver.getChunkProvider().getLoadedChunkCount()), TextComponent.newline(), - key("Active chunks: "), value(worldserver.getChunkProvider().getLoadedChunks().size()), TextComponent.newline(), + key("Active chunks: "), value(worldserver.getChunkProvider().loadedChunks().size()), TextComponent.newline(), key("Entities: "), value(worldserver.loadedEntityList.size()), TextComponent.newline(), key("Tile Entities: "), value(worldserver.loadedTileEntityList.size()), TextComponent.newline(), key("Removed Entities:"), value(((WorldAccessor) worldserver).accessor$getUnloadedEntityList().size()), TextComponent.newline(), diff --git a/src/main/java/org/spongepowered/common/config/PluginConfigManager.java b/src/main/java/org/spongepowered/common/config/PluginConfigManager.java index 6863acd3be4..861ac40d1d0 100644 --- a/src/main/java/org/spongepowered/common/config/PluginConfigManager.java +++ b/src/main/java/org/spongepowered/common/config/PluginConfigManager.java @@ -64,24 +64,24 @@ public final class PluginConfigManager implements ConfigManager { } @Override - public ConfigRoot getSharedConfig(final PluginContainer container) { + public ConfigRoot sharedConfig(final PluginContainer container) { return new PluginConfigRoot(this.serializers, container.getMetadata().getId().toLowerCase(), SpongeCommon.getPluginConfigDirectory()); } @Override - public ConfigRoot getPluginConfig(final PluginContainer container) { + public ConfigRoot pluginConfig(final PluginContainer container) { return new PluginConfigRoot(this.serializers, container.getMetadata().getId().toLowerCase(), SpongeCommon.getPluginConfigDirectory().resolve(container.getMetadata().getId().toLowerCase())); } @Override - public TypeSerializerCollection getSerializers() { + public TypeSerializerCollection serializers() { return this.serializers; } @Override - public WatchServiceListener getWatchServiceListener() { + public WatchServiceListener watchServiceListener() { return this.listener; } diff --git a/src/main/java/org/spongepowered/common/config/PluginConfigRoot.java b/src/main/java/org/spongepowered/common/config/PluginConfigRoot.java index 4d5beddf6cc..6ad402b5a90 100644 --- a/src/main/java/org/spongepowered/common/config/PluginConfigRoot.java +++ b/src/main/java/org/spongepowered/common/config/PluginConfigRoot.java @@ -51,7 +51,7 @@ public final class PluginConfigRoot implements ConfigRoot { } @Override - public Path getConfigPath() { + public Path configPath() { final Path configFile = this.baseDir.resolve(this.pluginName + ".conf"); try { Files.createDirectories(this.baseDir); @@ -62,20 +62,20 @@ public Path getConfigPath() { } @Override - public ConfigurationLoader getConfig() { - return this.getConfig(PluginConfigManager.getOptions(this.serializers)); + public ConfigurationLoader config() { + return this.config(PluginConfigManager.getOptions(this.serializers)); } @Override - public ConfigurationLoader getConfig(final ConfigurationOptions options) { + public ConfigurationLoader config(final ConfigurationOptions options) { return HoconConfigurationLoader.builder() - .path(this.getConfigPath()) + .path(this.configPath()) .defaultOptions(options) .build(); } @Override - public Path getDirectory() { + public Path directory() { return this.baseDir; } } diff --git a/src/main/java/org/spongepowered/common/config/SpongeGameConfigs.java b/src/main/java/org/spongepowered/common/config/SpongeGameConfigs.java index 0b4ee783246..7ec11f395dc 100644 --- a/src/main/java/org/spongepowered/common/config/SpongeGameConfigs.java +++ b/src/main/java/org/spongepowered/common/config/SpongeGameConfigs.java @@ -85,18 +85,18 @@ public static InheritableConfigHandle getForWorld(final net.minecra } public static boolean doesWorldConfigExist(final ResourceKey world) { - final Path configPath = SpongeConfigs.getDirectory().resolve(Paths.get("worlds", world.getNamespace(), world.getValue() + ".conf")); + final Path configPath = SpongeConfigs.getDirectory().resolve(Paths.get("worlds", world.namespace(), world.value() + ".conf")); return Files.exists(configPath); } public static InheritableConfigHandle createWorld(final @Nullable ResourceKey dimensionTypeKey, final ResourceKey world) { // Path format: config/sponge/worlds//.conf - final Path configPath = SpongeConfigs.getDirectory().resolve(Paths.get("worlds", world.getNamespace(), world.getValue() + ".conf")); + final Path configPath = SpongeConfigs.getDirectory().resolve(Paths.get("worlds", world.namespace(), world.value() + ".conf")); if (dimensionTypeKey != null) { // Legacy config path: config/sponge/worlds////world.conf final String legacyName = SpongeGameConfigs.getLegacyWorldName(world); if (legacyName != null) { - final Path legacyPath = SpongeConfigs.getDirectory().resolve(Paths.get("worlds", dimensionTypeKey.getNamespace(), + final Path legacyPath = SpongeConfigs.getDirectory().resolve(Paths.get("worlds", dimensionTypeKey.namespace(), SpongeGameConfigs.getLegacyValue(dimensionTypeKey), legacyName, "world.conf")); if (legacyPath.toFile().isFile() && !configPath.toFile().isFile()) { try { @@ -131,7 +131,7 @@ private static String getLegacyValue(final ResourceKey dimensionType) { if (dimensionType.equals(Level.NETHER.location())) { return "nether"; } else { - return dimensionType.getValue(); + return dimensionType.value(); } } diff --git a/src/main/java/org/spongepowered/common/config/customdata/CustomDataRegistrationCategory.java b/src/main/java/org/spongepowered/common/config/customdata/CustomDataRegistrationCategory.java index ff941093e18..74f663b4ff0 100644 --- a/src/main/java/org/spongepowered/common/config/customdata/CustomDataRegistrationCategory.java +++ b/src/main/java/org/spongepowered/common/config/customdata/CustomDataRegistrationCategory.java @@ -98,7 +98,7 @@ public final class CustomDataRegistrationCategory { public void populateRegistrations(final Collection stores) { this.registeredData.clear(); for (final SpongeDataStore store : stores) { - this.registeredData.add(store.getDataStoreKey().getFormatted()); + this.registeredData.add(store.getDataStoreKey().formatted()); } } diff --git a/src/main/java/org/spongepowered/common/data/ByteToBooleanContentUpdater.java b/src/main/java/org/spongepowered/common/data/ByteToBooleanContentUpdater.java index dc45d27cd16..7c3cbbf1797 100644 --- a/src/main/java/org/spongepowered/common/data/ByteToBooleanContentUpdater.java +++ b/src/main/java/org/spongepowered/common/data/ByteToBooleanContentUpdater.java @@ -40,25 +40,26 @@ public final class ByteToBooleanContentUpdater implements DataContentUpdater { private final int to; private final List queries; - public ByteToBooleanContentUpdater(int from, int to, Key>... booleanKeys) { + @SafeVarargs + public ByteToBooleanContentUpdater(final int from, final int to, final Key>... booleanKeys) { this.from = from; this.to = to; - this.queries = Arrays.stream(booleanKeys).map(k -> DataQuery.of(k.getKey().getValue())).collect(Collectors.toList()); + this.queries = Arrays.stream(booleanKeys).map(k -> DataQuery.of(k.key().value())).collect(Collectors.toList()); } @Override - public int getInputVersion() { + public int inputVersion() { return this.from; } @Override - public int getOutputVersion() { + public int outputVersion() { return this.to; } @Override - public DataView update(DataView content) { - for (DataQuery query : this.queries) { + public DataView update(final DataView content) { + for (final DataQuery query : this.queries) { final byte aByte = content.getByte(query).orElse((byte) 1); content.remove(query); // Delete boolean saved as byte content.set(query, aByte == 1); diff --git a/src/main/java/org/spongepowered/common/data/DataUpdaterDelegate.java b/src/main/java/org/spongepowered/common/data/DataUpdaterDelegate.java index c0263529316..bf1e255df60 100644 --- a/src/main/java/org/spongepowered/common/data/DataUpdaterDelegate.java +++ b/src/main/java/org/spongepowered/common/data/DataUpdaterDelegate.java @@ -41,12 +41,12 @@ public DataUpdaterDelegate(ImmutableList updaters, int from, } @Override - public int getInputVersion() { + public int inputVersion() { return this.from; } @Override - public int getOutputVersion() { + public int outputVersion() { return this.to; } diff --git a/src/main/java/org/spongepowered/common/data/DataUtil.java b/src/main/java/org/spongepowered/common/data/DataUtil.java index c1e8584867b..a856c8b547c 100644 --- a/src/main/java/org/spongepowered/common/data/DataUtil.java +++ b/src/main/java/org/spongepowered/common/data/DataUtil.java @@ -71,9 +71,9 @@ public static void deser // Run content-updaters and collect failed data final Class typeToken = dataHolder.getClass().asSubclass(DataHolder.class); allData.getView(Constants.Sponge.Data.V3.SPONGE_DATA_ROOT).ifPresent(customData -> { - for (DataQuery keyNamespace : customData.getKeys(false)) { + for (DataQuery keyNamespace : customData.keys(false)) { final DataView keyedData = customData.getView(keyNamespace).get(); - for (DataQuery keyValue : keyedData.getKeys(false)) { + for (DataQuery keyValue : keyedData.keys(false)) { final ResourceKey dataStoreKey = ResourceKey.of(keyNamespace.asString("."), keyValue.asString(".")); final DataView dataStoreData = keyedData.getView(keyValue).get(); final Integer contentVersion = dataStoreData.getInt(Constants.Sponge.Data.V3.CONTENT_VERSION).orElse(1); @@ -128,7 +128,7 @@ private static void upgradeV2CustomData(CompoundTag compound, DataContainer allD // Build new custom data structure // sponeg-data///{version|content} - final DataView dataStoreData = spongeDataV3.createView(DataQuery.of(key.getNamespace(), key.getValue())); + final DataView dataStoreData = spongeDataV3.createView(DataQuery.of(key.namespace(), key.value())); dataStoreData.set(Constants.Sponge.Data.V3.CONTENT_VERSION, contentVersion); dataStoreData.set(Constants.Sponge.Data.V3.CONTENT, data); SpongeCommon.getLogger().info("Upgraded custom data for datastore: {}", key); @@ -140,7 +140,7 @@ private static void upgradeV2CustomData(CompoundTag compound, DataContainer allD spongeDataV2.remove(Constants.Sponge.Data.V2.CUSTOM_MANIPULATOR_LIST); // convert sponge data v2 to v3 - for (DataQuery spongeDataKey : spongeDataV2.getKeys(false)) { + for (DataQuery spongeDataKey : spongeDataV2.keys(false)) { final DataQuery query = SpongeDataManager.INSTANCE.legacySpongeDataQuery(spongeDataKey.toString()); if (query == null) { SpongeCommon.getLogger().error("Missing legacy sponge data query mapping {}", spongeDataKey.toString()); diff --git a/src/main/java/org/spongepowered/common/data/MemoryDataContainer.java b/src/main/java/org/spongepowered/common/data/MemoryDataContainer.java index 6d118fcfd49..76f6346ea78 100644 --- a/src/main/java/org/spongepowered/common/data/MemoryDataContainer.java +++ b/src/main/java/org/spongepowered/common/data/MemoryDataContainer.java @@ -59,12 +59,12 @@ public MemoryDataContainer(final DataView.SafetyMode safety) { } @Override - public Optional getParent() { + public Optional parent() { return Optional.empty(); } @Override - public final DataContainer getContainer() { + public final DataContainer container() { return this; } diff --git a/src/main/java/org/spongepowered/common/data/MemoryDataView.java b/src/main/java/org/spongepowered/common/data/MemoryDataView.java index 383c5275ce3..a5925b2e7fc 100644 --- a/src/main/java/org/spongepowered/common/data/MemoryDataView.java +++ b/src/main/java/org/spongepowered/common/data/MemoryDataView.java @@ -83,36 +83,36 @@ public class MemoryDataView implements DataView { } private MemoryDataView(final DataView parent, final DataQuery path, final DataView.SafetyMode safety) { - checkArgument(path.getParts().size() >= 1, "Path must have at least one part"); + checkArgument(path.parts().size() >= 1, "Path must have at least one part"); this.parent = parent; - this.container = parent.getContainer(); - this.path = parent.getCurrentPath().then(path); + this.container = parent.container(); + this.path = parent.currentPath().then(path); this.safety = Objects.requireNonNull(safety, "Safety mode"); } @Override - public DataContainer getContainer() { + public DataContainer container() { return this.container; } @Override - public DataQuery getCurrentPath() { + public DataQuery currentPath() { return this.path; } @Override - public String getName() { - final List parts = this.path.getParts(); + public String name() { + final List parts = this.path.parts(); return parts.isEmpty() ? "" : parts.get(parts.size() - 1); } @Override - public Optional getParent() { + public Optional parent() { return Optional.ofNullable(this.parent); } @Override - public Set getKeys(final boolean deep) { + public Set keys(final boolean deep) { final ImmutableSet.Builder builder = ImmutableSet.builder(); for (final Map.Entry entry : this.map.entrySet()) { @@ -121,7 +121,7 @@ public Set getKeys(final boolean deep) { if (deep) { for (final Map.Entry entry : this.map.entrySet()) { if (entry.getValue() instanceof DataView) { - for (final DataQuery query : ((DataView) entry.getValue()).getKeys(true)) { + for (final DataQuery query : ((DataView) entry.getValue()).keys(true)) { builder.add(DataQuery.of(entry.getKey()).then(query)); } } @@ -131,12 +131,12 @@ public Set getKeys(final boolean deep) { } @Override - public Map getValues(final boolean deep) { + public Map values(final boolean deep) { final ImmutableMap.Builder builder = ImmutableMap.builder(); - for (final DataQuery query : this.getKeys(deep)) { + for (final DataQuery query : this.keys(deep)) { final Object value = this.get(query).get(); if (value instanceof DataView) { - builder.put(query, ((DataView) value).getValues(deep)); + builder.put(query, ((DataView) value).values(deep)); } else { builder.put(query, this.get(query).get()); } @@ -147,7 +147,7 @@ public Map getValues(final boolean deep) { @Override public final boolean contains(final DataQuery path) { Objects.requireNonNull(path, "path"); - final List queryParts = path.getParts(); + final List queryParts = path.parts(); final String key = queryParts.get(0); if (queryParts.size() == 1) { @@ -180,7 +180,7 @@ public boolean contains(final DataQuery path, final DataQuery... paths) { @Override public Optional get(final DataQuery path) { Objects.requireNonNull(path, "path"); - final List queryParts = path.getParts(); + final List queryParts = path.parts(); final int sz = queryParts.size(); @@ -232,18 +232,18 @@ public DataView set(final DataQuery path, final Object value) { Objects.requireNonNull(path, "path"); Objects.requireNonNull(value, "value"); checkState(this.container != null); - checkState(!path.getParts().isEmpty(), "The path is empty"); + checkState(!path.parts().isEmpty(), "The path is empty"); @Nullable DataManager manager; - // TODO: this call to getDataManager each set can be cleaned up + // TODO: this call to dataManager each set can be cleaned up try { - manager = Sponge.getDataManager(); + manager = Sponge.dataManager(); } catch (final Exception e) { manager = null; } - final List parts = path.getParts(); + final List parts = path.parts(); final String key = parts.get(0); if (parts.size() > 1) { final DataQuery subQuery = DataQuery.of(key); @@ -270,7 +270,7 @@ public DataView set(final DataQuery path, final Object value) { this.copyDataView(path, valueContainer); } else if (SpongeDataManager.INSTANCE.findRegistryTypeFor(value.getClass()).isPresent()) { final RegistryType registry = SpongeDataManager.INSTANCE.findRegistryTypeFor(value.getClass()).get(); - final ResourceKey valueKey = Sponge.getGame().registries().registry(registry).valueKey(value); + final ResourceKey valueKey = Sponge.game().registries().registry(registry).valueKey(value); // TODO if we serialize into a DataView - deserialize needs to do it too // final DataView view = this.createView(path); // view.set(DataQuery.of("registryroot"), registry.root()); @@ -281,8 +281,8 @@ public DataView set(final DataQuery path, final Object value) { } else if (value instanceof ResourceKey) { return this.set(path, value.toString()); - } else if (manager != null && manager.getTranslator(value.getClass()).isPresent()) { - final DataTranslator serializer = manager.getTranslator(value.getClass()).get(); + } else if (manager != null && manager.translator(value.getClass()).isPresent()) { + final DataTranslator serializer = manager.translator(value.getClass()).get(); final DataContainer container = serializer.translate(value); checkArgument(!container.equals(this), "Cannot insert self-referencing Objects!"); // see above for why this is copied @@ -325,7 +325,7 @@ private void setCollection(final String key, final Collection value) { @Nullable DataManager manager; try { - manager = Sponge.getDataManager(); + manager = Sponge.dataManager(); } catch (final Exception e) { manager = null; } @@ -337,7 +337,7 @@ private void setCollection(final String key, final Collection value) { if (this.safety == org.spongepowered.api.data.persistence.DataView.SafetyMode.ALL_DATA_CLONED || this.safety == org.spongepowered.api.data.persistence.DataView.SafetyMode.CLONED_ON_SET) { final MemoryDataView view = new MemoryDataContainer(this.safety); final DataView internalView = (DataView) object; - for (final Map.Entry entry : internalView.getValues(false).entrySet()) { + for (final Map.Entry entry : internalView.values(false).entrySet()) { view.set(entry.getKey(), entry.getValue()); } builder.add(view); @@ -352,7 +352,7 @@ private void setCollection(final String key, final Collection value) { builder.add(this.ensureSerialization((Collection) object)); } else { if (manager != null) { - final Optional> translatorOptional = manager.getTranslator( + final Optional> translatorOptional = manager.translator( object.getClass()); if (translatorOptional.isPresent()) { final DataTranslator translator = translatorOptional.get(); @@ -412,7 +412,7 @@ private void setMap(final String key, final Map value) { } private void copyDataView(final DataQuery path, final DataView value) { - final Collection valueKeys = value.getKeys(true); + final Collection valueKeys = value.keys(true); for (final DataQuery oldKey : valueKeys) { this.set(path.then(oldKey), value.get(oldKey).get()); } @@ -421,7 +421,7 @@ private void copyDataView(final DataQuery path, final DataView value) { @Override public DataView remove(final DataQuery path) { Objects.requireNonNull(path, "path"); - final List parts = path.getParts(); + final List parts = path.parts(); if (parts.size() > 1) { final String subKey = parts.get(0); final DataQuery subQuery = DataQuery.of(subKey); @@ -440,7 +440,7 @@ public DataView remove(final DataQuery path) { @Override public DataView createView(final DataQuery path) { Objects.requireNonNull(path, "path"); - final List queryParts = path.getParts(); + final List queryParts = path.parts(); final int sz = queryParts.size(); @@ -489,7 +489,7 @@ public Optional getView(final DataQuery path) { if (val.isPresent()) { if (val.get() instanceof DataView) { final ImmutableMap.Builder builder = ImmutableMap.builder(); - for (final Map.Entry entry : ((DataView) val.get()).getValues(false).entrySet()) { + for (final Map.Entry entry : ((DataView) val.get()).values(false).entrySet()) { builder.put(entry.getKey().asString('.'), this.ensureMappingOf(entry.getValue())); } return Optional.of(builder.build()); @@ -504,7 +504,7 @@ public Optional getView(final DataQuery path) { private Object ensureMappingOf(final Object object) { if (object instanceof DataView) { final ImmutableMap.Builder builder = ImmutableMap.builder(); - for (final Map.Entry entry : ((DataView) object).getValues(false).entrySet()) { + for (final Map.Entry entry : ((DataView) object).values(false).entrySet()) { builder.put(entry.getKey().asString('.'), this.ensureMappingOf(entry.getValue())); } return builder.build(); @@ -729,7 +729,7 @@ public Optional getSerializable(final DataQuery Objects.requireNonNull(path, "path"); Objects.requireNonNull(clazz, "clazz"); - return this.getUnsafeView(path).flatMap(view -> Sponge.getDataManager().getBuilder(clazz).flatMap(builder -> builder.build(view))); + return this.getUnsafeView(path).flatMap(view -> Sponge.dataManager().builder(clazz).flatMap(builder -> builder.build(view))); } @SuppressWarnings("unchecked") @@ -739,7 +739,7 @@ public Optional> getSerializableList(final Objects.requireNonNull(clazz, "clazz"); return Stream.>>>of( () -> this.getViewList(path).flatMap(list -> - Sponge.getDataManager().getBuilder(clazz).map(builder -> + Sponge.dataManager().builder(clazz).map(builder -> list.stream() .map(builder::build) .filter(Optional::isPresent) @@ -801,7 +801,7 @@ public Optional>>> getDataKeyList(final DataQuery pa @Override public Optional getObject(final DataQuery path, final Class objectClass) { return this.getView(path).flatMap(view -> - Sponge.getDataManager().getTranslator(objectClass) + Sponge.dataManager().translator(objectClass) .flatMap(serializer -> Optional.of(serializer.translate(view))) ); } @@ -809,7 +809,7 @@ public Optional getObject(final DataQuery path, final Class objectClas @Override public Optional> getObjectList(final DataQuery path, final Class objectClass) { return this.getViewList(path).flatMap(viewList -> - Sponge.getDataManager().getTranslator(objectClass).map(serializer -> + Sponge.dataManager().translator(objectClass).map(serializer -> viewList.stream() .map(serializer::translate) .collect(Collectors.toList()) @@ -820,7 +820,7 @@ public Optional> getObjectList(final DataQuery path, final Class @Override public DataContainer copy() { final DataContainer container = new MemoryDataContainer(this.safety); - this.getKeys(false) + this.keys(false) .forEach(query -> this.get(query).ifPresent(obj -> container.set(query, obj) @@ -832,7 +832,7 @@ public DataContainer copy() { @Override public DataContainer copy(final org.spongepowered.api.data.persistence.DataView.SafetyMode safety) { final DataContainer container = new MemoryDataContainer(safety); - this.getKeys(false) + this.keys(false) .forEach(query -> this.get(query).ifPresent(obj -> container.set(query, obj) @@ -847,7 +847,7 @@ public boolean isEmpty() { } @Override - public org.spongepowered.api.data.persistence.DataView.SafetyMode getSafetyMode() { + public org.spongepowered.api.data.persistence.DataView.SafetyMode safetyMode() { return this.safety; } diff --git a/src/main/java/org/spongepowered/common/data/SpongeDataManager.java b/src/main/java/org/spongepowered/common/data/SpongeDataManager.java index 358efa3b8a6..e6afa07992a 100644 --- a/src/main/java/org/spongepowered/common/data/SpongeDataManager.java +++ b/src/main/java/org/spongepowered/common/data/SpongeDataManager.java @@ -147,7 +147,7 @@ public void registerCustomDataContentUpdater(final DataContentUpdater updater) { } @Override - public Optional getWrappedContentUpdater(final Class clazz, final int fromVersion, + public Optional wrappedContentUpdater(final Class clazz, final int fromVersion, final int toVersion) { if (fromVersion == toVersion) { throw new IllegalArgumentException("Attempting to convert to the same version!"); @@ -170,11 +170,11 @@ private static Optional getWrappedContentUpdater(final Class ImmutableList.Builder builder = ImmutableList.builder(); int version = fromVersion; for (DataContentUpdater updater : updaters) { - if (updater.getInputVersion() == version) { - if (updater.getOutputVersion() > toVersion) { + if (updater.inputVersion() == version) { + if (updater.outputVersion() > toVersion) { continue; } - version = updater.getOutputVersion(); + version = updater.outputVersion(); builder.add(updater); } } @@ -191,7 +191,7 @@ private static Optional getWrappedContentUpdater(final Class @Override @SuppressWarnings({"unchecked"}) - public Optional> getBuilder(final Class clazz) { + public Optional> builder(final Class clazz) { final DataBuilder dataBuilder = this.builders.get(clazz); if (dataBuilder != null) { return Optional.of((DataBuilder) dataBuilder); @@ -203,7 +203,7 @@ public Optional> getBuilder(final Cl public Optional deserialize(final Class clazz, final DataView dataView) { Objects.requireNonNull(dataView); - return this.getBuilder(clazz).flatMap(builder -> builder.build(dataView)); + return this.builder(clazz).flatMap(builder -> builder.build(dataView)); } @Override @@ -218,12 +218,12 @@ public , B extends DataHolderBuilder.Immutable @SuppressWarnings("unchecked") @Override - public , B extends DataHolderBuilder.Immutable> Optional getImmutableBuilder(final Class holderClass) { + public , B extends DataHolderBuilder.Immutable> Optional immutableBuilder(final Class holderClass) { return Optional.ofNullable((B) this.immutableDataBuilderMap.get(Objects.requireNonNull(holderClass))); } @Override - public Optional> getTranslator(final Class objectClass) { + public Optional> translator(final Class objectClass) { return DataTranslatorProvider.INSTANCE.getSerializer(objectClass); } @@ -233,7 +233,7 @@ public void registerKeyListeners() { } private void registerKeyListener0(final KeyBasedDataListener listener) { - Sponge.getEventManager().registerListener(listener.getOwner(), ChangeDataHolderEvent.ValueChange.class, listener); + Sponge.eventManager().registerListener(listener.getOwner(), ChangeDataHolderEvent.ValueChange.class, listener); } @Override @@ -270,19 +270,19 @@ public void registerKeyListener(final KeyBasedDataListene @SuppressWarnings({"unchecked", "rawtypes"}) public void registerCustomDataRegistration(final SpongeDataRegistration registration) { for (final DataStore dataStore : registration.getDataStores()) { - this.dataStoreRegistry.register(dataStore, registration.getKeys()); + this.dataStoreRegistry.register(dataStore, registration.keys()); } - for (final Key key : registration.getKeys()) { + for (final Key key : registration.keys()) { this.registerCustomDataProviderForKey(registration, key); } } private , E> void registerCustomDataProviderForKey(final SpongeDataRegistration registration, final Key key) { - final Collection> providers = registration.getProvidersFor(key); + final Collection> providers = registration.providersFor(key); final Set dataStoreSupportedTokens = new HashSet<>(); - this.dataStoreRegistry.getDataStores(key).stream().map(DataStore::getSupportedTypes).forEach(dataStoreSupportedTokens::addAll); + this.dataStoreRegistry.getDataStores(key).stream().map(DataStore::supportedTypes).forEach(dataStoreSupportedTokens::addAll); for (final DataProvider provider : providers) { this.dataProviderRegistry.register(provider); @@ -298,10 +298,10 @@ private , E> void registerCustomDataProviderForKey(final Spon @SuppressWarnings({"unchecked", "rawtypes"}) public void registerDataRegistration(final SpongeDataRegistration registration) { for (final DataStore dataStore : registration.getDataStores()) { - this.dataStoreRegistry.register(dataStore, registration.getKeys()); + this.dataStoreRegistry.register(dataStore, registration.keys()); } - for (final Key key : registration.getKeys()) { - final Collection> providers = registration.getProvidersFor(key); + for (final Key key : registration.keys()) { + final Collection> providers = registration.providersFor(key); for (DataProvider provider : providers) { this.dataProviderRegistry.register(provider); } @@ -361,8 +361,8 @@ public Optional> findRegistryTypeFor(Class type) { } public void registerLegacySpongeData(String nbtKey, ResourceKey dataStoreKey, Key> dataKey) { - this.legacySpongeData.put(nbtKey, DataQuery.of(dataStoreKey.getNamespace(), dataStoreKey.getValue()).then(Constants.Sponge.Data.V3.CONTENT) - .then(dataKey.getKey().getValue())); + this.legacySpongeData.put(nbtKey, DataQuery.of(dataStoreKey.namespace(), dataStoreKey.value()).then(Constants.Sponge.Data.V3.CONTENT) + .then(dataKey.key().value())); } public @Nullable DataQuery legacySpongeDataQuery(String nbtKey) { diff --git a/src/main/java/org/spongepowered/common/data/SpongeDataRegistration.java b/src/main/java/org/spongepowered/common/data/SpongeDataRegistration.java index 4b421bc2d8b..5a42a79c5a9 100644 --- a/src/main/java/org/spongepowered/common/data/SpongeDataRegistration.java +++ b/src/main/java/org/spongepowered/common/data/SpongeDataRegistration.java @@ -55,17 +55,17 @@ public final class SpongeDataRegistration implements DataRegistration { @Override @SuppressWarnings("unchecked") - public , E> Collection> getProvidersFor(Key key) throws UnregisteredKeyException { + public , E> Collection> providersFor(Key key) throws UnregisteredKeyException { return (Collection) this.dataProviderMap.get(key); } @Override - public Optional getDataStore(final TypeToken token) { + public Optional dataStore(final TypeToken token) { return this.getDataStore0(token.getType()); } @Override - public Optional getDataStore(final Class token) { + public Optional dataStore(final Class token) { return this.getDataStore0(token); } @@ -85,7 +85,7 @@ private Optional getDataStore0(final Type type) { } @Override - public Iterable> getKeys() { + public Iterable> keys() { return this.keys; } diff --git a/src/main/java/org/spongepowered/common/data/SpongeDataRegistrationBuilder.java b/src/main/java/org/spongepowered/common/data/SpongeDataRegistrationBuilder.java index 65cab269115..aeecb69aab1 100644 --- a/src/main/java/org/spongepowered/common/data/SpongeDataRegistrationBuilder.java +++ b/src/main/java/org/spongepowered/common/data/SpongeDataRegistrationBuilder.java @@ -26,14 +26,12 @@ import com.google.common.collect.HashMultimap; import com.google.common.collect.Multimap; -import org.spongepowered.api.ResourceKey; import org.spongepowered.api.data.DataProvider; import org.spongepowered.api.data.DataRegistration; import org.spongepowered.api.data.DuplicateDataStoreException; import org.spongepowered.api.data.DuplicateProviderException; import org.spongepowered.api.data.Key; import org.spongepowered.api.data.persistence.DataStore; -import org.spongepowered.common.SpongeCommon; import java.lang.reflect.Type; import java.util.ArrayList; @@ -51,7 +49,7 @@ public final class SpongeDataRegistrationBuilder implements DataRegistration.Bui @Override public DataRegistration.Builder store(final DataStore store) throws DuplicateDataStoreException { - for (final Type holderType : store.getSupportedTypes()) { + for (final Type holderType : store.supportedTypes()) { this.dataStoreMap.put(holderType, store); } return this; @@ -59,7 +57,7 @@ public DataRegistration.Builder store(final DataStore store) throws DuplicateDat @Override public DataRegistration.Builder provider(final DataProvider provider) throws DuplicateProviderException { - this.dataProviderMap.put(provider.getKey(), provider); + this.dataProviderMap.put(provider.key(), provider); return this; } diff --git a/src/main/java/org/spongepowered/common/data/SpongeKeyValueMatcher.java b/src/main/java/org/spongepowered/common/data/SpongeKeyValueMatcher.java index 1a21d604964..54fed9ef4f0 100644 --- a/src/main/java/org/spongepowered/common/data/SpongeKeyValueMatcher.java +++ b/src/main/java/org/spongepowered/common/data/SpongeKeyValueMatcher.java @@ -51,17 +51,17 @@ public SpongeKeyValueMatcher(final Key> key, final Operator o } @Override - public Key> getKey() { + public Key> key() { return this.key; } @Override - public Operator getOperator() { + public Operator operator() { return this.operator; } @Override - public Optional getValue() { + public Optional value() { return Optional.ofNullable(this.value); } @@ -93,7 +93,7 @@ private boolean includes(final @Nullable V value) { if (this.value == null || value == null) { return false; } - final BiPredicate predicate = (BiPredicate) this.key.getElementIncludesTester(); + final BiPredicate predicate = (BiPredicate) this.key.elementIncludesTester(); return predicate.test(this.value, value); } @@ -108,19 +108,19 @@ private int compare(final @Nullable V value) { if (this.value == null) { return -1; } - final Comparator comparator = (Comparator) this.key.getElementComparator(); + final Comparator comparator = (Comparator) this.key.elementComparator(); return -comparator.compare(this.value, value); } @Override - public int getContentVersion() { + public int contentVersion() { return 1; } @Override public DataContainer toContainer() { final DataContainer container = DataContainer.createNew() - .set(Queries.CONTENT_VERSION, this.getContentVersion()) + .set(Queries.CONTENT_VERSION, this.contentVersion()) .set(Constants.KeyValueMatcher.KEY, this.key) .set(Constants.KeyValueMatcher.OPERATOR, this.operator.toString().toLowerCase()); if (this.value != null) { diff --git a/src/main/java/org/spongepowered/common/data/SpongeKeyValueMatcherBuilder.java b/src/main/java/org/spongepowered/common/data/SpongeKeyValueMatcherBuilder.java index ae0bbb2da4d..fd90040b8d5 100644 --- a/src/main/java/org/spongepowered/common/data/SpongeKeyValueMatcherBuilder.java +++ b/src/main/java/org/spongepowered/common/data/SpongeKeyValueMatcherBuilder.java @@ -70,9 +70,9 @@ public KeyValueMatcher.Builder value(final @Nullable Value valu @Override public KeyValueMatcher.Builder from(final KeyValueMatcher value) { - this.key = value.getKey(); - this.value = value.getValue().orElse(null); - this.operator = value.getOperator(); + this.key = value.key(); + this.value = value.value().orElse(null); + this.operator = value.operator(); return this; } @@ -102,7 +102,7 @@ public Optional> build(final DataView container) throws Inval if (!operator.isPresent()) { return Optional.empty(); } - final Optional value = (Optional) container.getObject(Constants.KeyValueMatcher.VALUE, GenericTypeReflector.erase(key.getElementType())); + final Optional value = (Optional) container.getObject(Constants.KeyValueMatcher.VALUE, GenericTypeReflector.erase(key.elementType())); if (!value.isPresent()) { return Optional.empty(); } diff --git a/src/main/java/org/spongepowered/common/data/builder/item/SpongeFireworkEffectDataBuilder.java b/src/main/java/org/spongepowered/common/data/builder/item/SpongeFireworkEffectDataBuilder.java index 22e13384a8c..655eb8b0813 100644 --- a/src/main/java/org/spongepowered/common/data/builder/item/SpongeFireworkEffectDataBuilder.java +++ b/src/main/java/org/spongepowered/common/data/builder/item/SpongeFireworkEffectDataBuilder.java @@ -52,7 +52,7 @@ protected Optional buildContent(DataView container) throws Inval if (container.contains(Constants.Item.Fireworks.FIREWORK_SHAPE, Constants.Item.Fireworks.FIREWORK_COLORS, Constants.Item.Fireworks.FIREWORK_FADE_COLORS, Constants.Item.Fireworks.FIREWORK_FLICKERS, Constants.Item.Fireworks.FIREWORK_TRAILS)) { final ResourceKey key = container.getResourceKey(Constants.Item.Fireworks.FIREWORK_SHAPE).get(); - final Optional shapeOptional = Sponge.getGame().registries().registry(RegistryTypes.FIREWORK_SHAPE).findValue(key); + final Optional shapeOptional = Sponge.game().registries().registry(RegistryTypes.FIREWORK_SHAPE).findValue(key); if (!shapeOptional.isPresent()) { throw new InvalidDataException("Could not find the FireworkShape for the provided id: " + key); } diff --git a/src/main/java/org/spongepowered/common/data/builder/item/SpongeItemStackSnapshotDataBuilder.java b/src/main/java/org/spongepowered/common/data/builder/item/SpongeItemStackSnapshotDataBuilder.java index fa26f704d4e..6ca34ab5fe9 100644 --- a/src/main/java/org/spongepowered/common/data/builder/item/SpongeItemStackSnapshotDataBuilder.java +++ b/src/main/java/org/spongepowered/common/data/builder/item/SpongeItemStackSnapshotDataBuilder.java @@ -55,7 +55,7 @@ public SpongeItemStackSnapshotDataBuilder() { @Override protected Optional buildContent(DataView container) throws InvalidDataException { if (container.contains(Constants.ItemStack.TYPE, Constants.ItemStack.COUNT)) { - final ItemType itemType = container.getRegistryValue(Constants.ItemStack.TYPE, RegistryTypes.ITEM_TYPE, Sponge.getGame().registries()).get(); + final ItemType itemType = container.getRegistryValue(Constants.ItemStack.TYPE, RegistryTypes.ITEM_TYPE, Sponge.game().registries()).get(); if (itemType == ItemTypes.AIR.get()) { return Optional.of(ItemStackSnapshot.empty()); } diff --git a/src/main/java/org/spongepowered/common/data/builder/meta/SpongePatternLayerBuilder.java b/src/main/java/org/spongepowered/common/data/builder/meta/SpongePatternLayerBuilder.java index 83561feb7fe..6544cdfc83b 100644 --- a/src/main/java/org/spongepowered/common/data/builder/meta/SpongePatternLayerBuilder.java +++ b/src/main/java/org/spongepowered/common/data/builder/meta/SpongePatternLayerBuilder.java @@ -61,12 +61,12 @@ protected Optional buildContent(final DataView container) th return Optional.empty(); } final BannerPatternShape shape = container.getRegistryValue(Constants.TileEntity.Banner.SHAPE, RegistryTypes.BANNER_PATTERN_SHAPE, - Sponge.getGame().registries()) + Sponge.game().registries()) .orElseThrow(() -> new InvalidDataException("The provided container has an invalid banner pattern shape entry!")); // Now we need to validate the dye color of course... - final DyeColor color = container.getRegistryValue(Constants.TileEntity.Banner.COLOR, RegistryTypes.DYE_COLOR, Sponge.getGame().registries()) + final DyeColor color = container.getRegistryValue(Constants.TileEntity.Banner.COLOR, RegistryTypes.DYE_COLOR, Sponge.game().registries()) .orElseThrow(() -> new InvalidDataException("The provided container has an invalid dye color entry!")); return Optional.of(new SpongePatternLayer(shape, color)); @@ -93,8 +93,8 @@ public BannerPatternLayer.Builder color(final DyeColor color) { @Override public BannerPatternLayer.Builder from(final BannerPatternLayer value) { - this.shape = value.getShape(); - this.color = value.getColor(); + this.shape = value.shape(); + this.color = value.color(); return this; } diff --git a/src/main/java/org/spongepowered/common/data/datasync/entity/EntityBabyConverter.java b/src/main/java/org/spongepowered/common/data/datasync/entity/EntityBabyConverter.java index e8fc5b859b7..bc8fc991468 100644 --- a/src/main/java/org/spongepowered/common/data/datasync/entity/EntityBabyConverter.java +++ b/src/main/java/org/spongepowered/common/data/datasync/entity/EntityBabyConverter.java @@ -52,7 +52,7 @@ public Optional createTransaction(final Entity entity, fi @Override public Boolean getValueFromEvent(final Boolean originalValue, final List> immutableValues) { for (final Immutable value : immutableValues) { - if (value.getKey() == Keys.IS_ADULT) { + if (value.key() == Keys.IS_ADULT) { return !(Boolean) value.get(); } } diff --git a/src/main/java/org/spongepowered/common/data/datasync/entity/EntityCustomNameConverter.java b/src/main/java/org/spongepowered/common/data/datasync/entity/EntityCustomNameConverter.java index faa4261212a..4567895e607 100644 --- a/src/main/java/org/spongepowered/common/data/datasync/entity/EntityCustomNameConverter.java +++ b/src/main/java/org/spongepowered/common/data/datasync/entity/EntityCustomNameConverter.java @@ -57,7 +57,7 @@ public Optional createTransaction(final Entity entity, fi @Override public String getValueFromEvent(final String originalValue, final List> immutableValues) { for (final Immutable value : immutableValues) { - if (value.getKey() == Keys.DISPLAY_NAME) { + if (value.key() == Keys.DISPLAY_NAME) { try { return SpongeAdventure.legacySection((Component) value.get()); } catch (Exception e) { diff --git a/src/main/java/org/spongepowered/common/data/datasync/entity/EntityCustomNameVisibleConverter.java b/src/main/java/org/spongepowered/common/data/datasync/entity/EntityCustomNameVisibleConverter.java index 5c2b58bd9be..42766e4e36b 100644 --- a/src/main/java/org/spongepowered/common/data/datasync/entity/EntityCustomNameVisibleConverter.java +++ b/src/main/java/org/spongepowered/common/data/datasync/entity/EntityCustomNameVisibleConverter.java @@ -52,7 +52,7 @@ public Optional createTransaction(final Entity entity, fi @Override public Boolean getValueFromEvent(final Boolean originalValue, final List> immutableValues) { for (final Immutable immutableValue : immutableValues) { - if (immutableValue.getKey() == Keys.IS_CUSTOM_NAME_VISIBLE) { + if (immutableValue.key() == Keys.IS_CUSTOM_NAME_VISIBLE) { return (Boolean) immutableValue.get(); } } diff --git a/src/main/java/org/spongepowered/common/data/datasync/entity/EntityFlagsConverter.java b/src/main/java/org/spongepowered/common/data/datasync/entity/EntityFlagsConverter.java index 324c5effb7b..91a3d738092 100644 --- a/src/main/java/org/spongepowered/common/data/datasync/entity/EntityFlagsConverter.java +++ b/src/main/java/org/spongepowered/common/data/datasync/entity/EntityFlagsConverter.java @@ -102,19 +102,19 @@ public Byte getValueFromEvent(final Byte originalValue, final List> boolean newGlowing = this.getFlag(originalValue, EntityFlagsConverter.GLOWING_MASK); boolean newElytra = this.getFlag(originalValue, EntityFlagsConverter.FLYING_ELYTRA_MASK); for (final Immutable immutableValue : immutableValues) { - if (immutableValue.getKey() == Keys.IS_SNEAKING) { + if (immutableValue.key() == Keys.IS_SNEAKING) { newIsSneaking = ((Boolean) immutableValue.get()); } - if (immutableValue.getKey() == Keys.IS_SPRINTING) { + if (immutableValue.key() == Keys.IS_SPRINTING) { newSprinting = ((Boolean) immutableValue.get()); } - if (immutableValue.getKey() == Keys.IS_INVISIBLE) { + if (immutableValue.key() == Keys.IS_INVISIBLE) { newInvisible = (Boolean) immutableValue.get(); } - if (immutableValue.getKey() == Keys.IS_GLOWING) { + if (immutableValue.key() == Keys.IS_GLOWING) { newGlowing = (Boolean) immutableValue.get(); } - if (immutableValue.getKey() == Keys.IS_ELYTRA_FLYING) { + if (immutableValue.key() == Keys.IS_ELYTRA_FLYING) { newElytra = (Boolean) immutableValue.get(); } } diff --git a/src/main/java/org/spongepowered/common/data/datasync/entity/EntityNoGravityConverter.java b/src/main/java/org/spongepowered/common/data/datasync/entity/EntityNoGravityConverter.java index d4b34cc8647..51211219326 100644 --- a/src/main/java/org/spongepowered/common/data/datasync/entity/EntityNoGravityConverter.java +++ b/src/main/java/org/spongepowered/common/data/datasync/entity/EntityNoGravityConverter.java @@ -52,7 +52,7 @@ public Optional createTransaction(final Entity entity, fi @Override public Boolean getValueFromEvent(final Boolean originalValue, final List> immutableValues) { for (final Immutable immutableValue : immutableValues) { - if (immutableValue.getKey() == Keys.IS_GRAVITY_AFFECTED) { + if (immutableValue.key() == Keys.IS_GRAVITY_AFFECTED) { return !(Boolean) immutableValue.get(); } } diff --git a/src/main/java/org/spongepowered/common/data/datasync/entity/EntitySilentConverter.java b/src/main/java/org/spongepowered/common/data/datasync/entity/EntitySilentConverter.java index 29b361a8efb..adee2fae831 100644 --- a/src/main/java/org/spongepowered/common/data/datasync/entity/EntitySilentConverter.java +++ b/src/main/java/org/spongepowered/common/data/datasync/entity/EntitySilentConverter.java @@ -52,7 +52,7 @@ public Optional createTransaction(final Entity entity, fi @Override public Boolean getValueFromEvent(final Boolean originalValue, final List> immutableValues) { for (final Immutable immutableValue : immutableValues) { - if (immutableValue.getKey() == Keys.IS_SILENT) { + if (immutableValue.key() == Keys.IS_SILENT) { return (Boolean) immutableValue.get(); } } diff --git a/src/main/java/org/spongepowered/common/data/datasync/entity/LivingEntityArrowCountConverter.java b/src/main/java/org/spongepowered/common/data/datasync/entity/LivingEntityArrowCountConverter.java index 55d13d1df3a..012dec8be0f 100644 --- a/src/main/java/org/spongepowered/common/data/datasync/entity/LivingEntityArrowCountConverter.java +++ b/src/main/java/org/spongepowered/common/data/datasync/entity/LivingEntityArrowCountConverter.java @@ -52,7 +52,7 @@ public Optional createTransaction(final Entity entity, fi @Override public Integer getValueFromEvent(final Integer originalValue, final List> immutableValues) { for (final Immutable immutableValue : immutableValues) { - if (immutableValue.getKey() == Keys.STUCK_ARROWS) { + if (immutableValue.key() == Keys.STUCK_ARROWS) { return (Integer) immutableValue.get(); } } diff --git a/src/main/java/org/spongepowered/common/data/datasync/entity/MobEntityAIFlagsConverter.java b/src/main/java/org/spongepowered/common/data/datasync/entity/MobEntityAIFlagsConverter.java index e462eeb859c..f8ce41de652 100644 --- a/src/main/java/org/spongepowered/common/data/datasync/entity/MobEntityAIFlagsConverter.java +++ b/src/main/java/org/spongepowered/common/data/datasync/entity/MobEntityAIFlagsConverter.java @@ -54,7 +54,7 @@ public Optional createTransaction(final Entity entity, fi @Override public Byte getValueFromEvent(Byte originalValue, final List> immutableValues) { for (final Immutable immutableValue : immutableValues) { - if (immutableValue.getKey() == Keys.IS_AI_ENABLED) { + if (immutableValue.key() == Keys.IS_AI_ENABLED) { final Boolean hasAi = (Boolean) immutableValue.get(); originalValue = hasAi ? (byte) (originalValue & -2) : (byte) (originalValue | 1); } diff --git a/src/main/java/org/spongepowered/common/data/holder/SpongeDataHolder.java b/src/main/java/org/spongepowered/common/data/holder/SpongeDataHolder.java index b183bc0c82d..4becbcf9e82 100644 --- a/src/main/java/org/spongepowered/common/data/holder/SpongeDataHolder.java +++ b/src/main/java/org/spongepowered/common/data/holder/SpongeDataHolder.java @@ -98,23 +98,23 @@ default Optional get(Key> key) { @Override default > Optional getValue(Key key) { - return this.impl$apply(key, DataProvider::getValue, Optional::empty); + return this.impl$apply(key, DataProvider::value, Optional::empty); } default Map, Object> impl$getMappedValues() { return this.impl$delegateDataHolder().stream() .flatMap(dh -> this.impl$getAllProviders(dh).stream() - .map(provider -> provider.getValue(dh).orElse(null)) + .map(provider -> provider.value(dh).orElse(null)) .filter(Objects::nonNull) .map(Value::asImmutable)) - .collect(ImmutableMap.toImmutableMap(Value::getKey, Value::get)); + .collect(ImmutableMap.toImmutableMap(Value::key, Value::get)); } @Override default Set> getKeys() { return this.impl$delegateDataHolder().stream() .flatMap(dh -> this.impl$getAllProviders(dh).stream() - .filter(provider -> provider.get(dh).isPresent()).map(DataProvider::getKey)) + .filter(provider -> provider.get(dh).isPresent()).map(DataProvider::key)) .collect(ImmutableSet.toImmutableSet()); } @@ -122,7 +122,7 @@ default Set> getKeys() { default Set> getValues() { return this.impl$delegateDataHolder().stream() .flatMap(dh -> this.impl$getAllProviders(dh).stream() - .map(provider -> provider.getValue(dh).orElse(null)) + .map(provider -> provider.value(dh).orElse(null)) .filter(Objects::nonNull) .map(Value::asImmutable)) .collect(ImmutableSet.toImmutableSet()); diff --git a/src/main/java/org/spongepowered/common/data/holder/SpongeImmutableDataHolder.java b/src/main/java/org/spongepowered/common/data/holder/SpongeImmutableDataHolder.java index 430b4d09cee..7449460a77b 100644 --- a/src/main/java/org/spongepowered/common/data/holder/SpongeImmutableDataHolder.java +++ b/src/main/java/org/spongepowered/common/data/holder/SpongeImmutableDataHolder.java @@ -55,7 +55,7 @@ default Optional with(Key> key, E value) { @Override default Optional with(Value value) { - return this.impl$getProviderFor((Key>) value.getKey(), this).with((I) this, value.get()); + return this.impl$getProviderFor((Key>) value.key(), this).with((I) this, value.get()); } @Override @@ -76,7 +76,7 @@ default I mergeWith(I that, MergeFunction function) { } } else if (function == MergeFunction.ORIGINAL_PREFERRED) { for (final Value value : that.getValues()) { - if (this.get(value.getKey()).isPresent()) { + if (this.get(value.key()).isPresent()) { continue; } final Optional optionalResult = result.with(value); @@ -86,9 +86,9 @@ default I mergeWith(I that, MergeFunction function) { } } else { for (final Value value : that.getValues()) { - final Key> key = (Key>) value.getKey(); + final Key> key = (Key>) value.key(); final DataProvider provider = this.impl$getProviderFor(key, this); - @Nullable final Value original = provider.getValue(this).map(Value::asImmutable).orElse(null); + @Nullable final Value original = provider.value(this).map(Value::asImmutable).orElse(null); final Value merged = function.merge(original, (Value) value); final Optional optionalResult = result.with(merged); if (optionalResult.isPresent()) { diff --git a/src/main/java/org/spongepowered/common/data/holder/SpongeLocationBaseDataHolder.java b/src/main/java/org/spongepowered/common/data/holder/SpongeLocationBaseDataHolder.java index 7113f2c315a..57f4a2683a5 100644 --- a/src/main/java/org/spongepowered/common/data/holder/SpongeLocationBaseDataHolder.java +++ b/src/main/java/org/spongepowered/common/data/holder/SpongeLocationBaseDataHolder.java @@ -50,7 +50,7 @@ default Optional get(final int x, final int y, final int z, final Key key) { + default boolean supports(final int x, final int y, final int z, final Key key) { return this.impl$dataholder(x, y, z).supports(key); } @@ -61,17 +61,17 @@ default DataTransactionResult remove(final int x, final int y, final int z, fina @Override - default > Optional getValue(int x, int y, int z, Key key) { + default > Optional getValue(final int x, final int y, final int z, final Key key) { return this.impl$dataholder(x, y, z).getValue(key); } @Override - default Set> getKeys(int x, int y, int z) { + default Set> keys(final int x, final int y, final int z) { return this.impl$dataholder(x, y, z).getKeys(); } @Override - default Set> getValues(int x, int y, int z) { + default Set> getValues(final int x, final int y, final int z) { return this.impl$dataholder(x, y, z).getValues(); } diff --git a/src/main/java/org/spongepowered/common/data/holder/SpongeMutableDataHolder.java b/src/main/java/org/spongepowered/common/data/holder/SpongeMutableDataHolder.java index fed7fa4daf8..9c4556bcb12 100644 --- a/src/main/java/org/spongepowered/common/data/holder/SpongeMutableDataHolder.java +++ b/src/main/java/org/spongepowered/common/data/holder/SpongeMutableDataHolder.java @@ -81,7 +81,7 @@ default DataTransactionResult offer(Key> key, E value) { @Override default DataTransactionResult offer(Value value) { - return this.impl$applyTransaction(value.getKey(), (p, m) -> ((DataProvider, ?>) p).offerValue(m, value), + return this.impl$applyTransaction(value.key(), (p, m) -> ((DataProvider, ?>) p).offerValue(m, value), () -> DataTransactionResult.failResult(value.asImmutable())); } @@ -218,7 +218,7 @@ default DataTransactionResult remove(Key key) { @Override default DataTransactionResult remove(Value value) { - return this.impl$applyTransaction(value.getKey(), (p, m) -> { + return this.impl$applyTransaction(value.key(), (p, m) -> { final Optional opt = p.get(m); if (opt.isPresent() && opt.get().equals(value.get())) { return p.remove(m); @@ -245,7 +245,7 @@ default DataTransactionResult copyFrom(ValueContainer that, MergeFunction functi } else if (function == MergeFunction.ORIGINAL_PREFERRED) { // Produce less garbage if we know we don't have to merge any values for (final Value replacement : that.getValues()) { - final Key> key = replacement.getKey(); + final Key> key = replacement.key(); if (this.get(key).isPresent()) { continue; } @@ -258,7 +258,7 @@ default DataTransactionResult copyFrom(ValueContainer that, MergeFunction functi } } else { for (final Value replacement : that.getValues()) { - final Key> key = replacement.getKey(); + final Key> key = replacement.key(); @Nullable final Value original = this.getValue(key).map(Value::asImmutable).orElse(null); final Value merged = function.merge(original, replacement); final DataTransactionResult result = this.offer(merged); @@ -278,14 +278,14 @@ default DataTransactionResult copyFrom(ValueContainer that, MergeFunction functi @Override default DataTransactionResult undo(DataTransactionResult result) { - if (result.getReplacedData().isEmpty() && result.getSuccessfulData().isEmpty()) { + if (result.replacedData().isEmpty() && result.successfulData().isEmpty()) { return DataTransactionResult.successNoData(); } final DataTransactionResult.Builder builder = DataTransactionResult.builder(); - for (final Value value : result.getReplacedData()) { + for (final Value value : result.replacedData()) { builder.absorbResult(this.offer(value)); } - for (final Value value : result.getSuccessfulData()) { + for (final Value value : result.successfulData()) { builder.absorbResult(this.remove(value)); } return DataTransactionResult.failNoData(); @@ -304,22 +304,22 @@ default DataTransactionResult tryOffer(Key> key, E value) @Override default DataTransactionResult offerAll(CollectionValue value) { - return this.offerAll((Key>) value.getKey(), value.get()); + return this.offerAll((Key>) value.key(), value.get()); } @Override default DataTransactionResult offerAll(MapValue value) { - return this.offerAll((Key>) value.getKey(), value.get()); + return this.offerAll((Key>) value.key(), value.get()); } @Override default DataTransactionResult removeAll(CollectionValue value) { - return this.removeAll((Key>) value.getKey(), value.get()); + return this.removeAll((Key>) value.key(), value.get()); } @Override default DataTransactionResult removeAll(MapValue value) { - return this.removeAll((Key>) value.getKey(), value.get()); + return this.removeAll((Key>) value.key(), value.get()); } } diff --git a/src/main/java/org/spongepowered/common/data/key/KeyBasedDataListener.java b/src/main/java/org/spongepowered/common/data/key/KeyBasedDataListener.java index 850d4e23bc8..0c8e706af4a 100644 --- a/src/main/java/org/spongepowered/common/data/key/KeyBasedDataListener.java +++ b/src/main/java/org/spongepowered/common/data/key/KeyBasedDataListener.java @@ -46,7 +46,7 @@ public final class KeyBasedDataListener implements EventLi @Override public void handle(final ChangeDataHolderEvent.ValueChange event) throws Exception { - if (this.holderType.isInstance(event.getTargetHolder()) && event.getEndResult().getSuccessfulData().stream().anyMatch(v -> v.getKey() == this.key)) { + if (this.holderType.isInstance(event.targetHolder()) && event.endResult().successfulData().stream().anyMatch(v -> v.key() == this.key)) { this.listener.handle(event); } } diff --git a/src/main/java/org/spongepowered/common/data/key/SpongeKey.java b/src/main/java/org/spongepowered/common/data/key/SpongeKey.java index 954c1f36335..2f98655e508 100644 --- a/src/main/java/org/spongepowered/common/data/key/SpongeKey.java +++ b/src/main/java/org/spongepowered/common/data/key/SpongeKey.java @@ -68,29 +68,29 @@ public SpongeKey(final ResourceKey key, final Type valueType, final Type element } @Override - public Type getValueType() { + public Type valueType() { return this.valueType; } @Override - public Type getElementType() { + public Type elementType() { return this.elementType; } @Override - public Comparator getElementComparator() { + public Comparator elementComparator() { return this.elementComparator; } @Override - public BiPredicate getElementIncludesTester() { + public BiPredicate elementIncludesTester() { return this.elementIncludesTester; } @Override public void registerEvent(final PluginContainer plugin, final Class holderFilter, final EventListener listener) { - ((SpongeDataManager) Sponge.getGame().getDataManager()).registerKeyListener(new KeyBasedDataListener<>(plugin, holderFilter, this, listener)); + ((SpongeDataManager) Sponge.game().dataManager()).registerKeyListener(new KeyBasedDataListener<>(plugin, holderFilter, this, listener)); } public ValueConstructor getValueConstructor() { diff --git a/src/main/java/org/spongepowered/common/data/manipulator/MutableDataManipulatorFactory.java b/src/main/java/org/spongepowered/common/data/manipulator/MutableDataManipulatorFactory.java index 554dac8ddf1..b8dfb9c3cf8 100644 --- a/src/main/java/org/spongepowered/common/data/manipulator/MutableDataManipulatorFactory.java +++ b/src/main/java/org/spongepowered/common/data/manipulator/MutableDataManipulatorFactory.java @@ -51,7 +51,7 @@ static Map, Object> mapValues(final Iterable> values) final Map, Object> mappedValues = new HashMap<>(); for (final Value value : values) { - mappedValues.put(value.getKey(), CopyHelper.copy(value.get())); + mappedValues.put(value.key(), CopyHelper.copy(value.get())); } return mappedValues; } diff --git a/src/main/java/org/spongepowered/common/data/manipulator/SpongeDataManipulator.java b/src/main/java/org/spongepowered/common/data/manipulator/SpongeDataManipulator.java index 0bfb3c80106..07d8b9dad90 100644 --- a/src/main/java/org/spongepowered/common/data/manipulator/SpongeDataManipulator.java +++ b/src/main/java/org/spongepowered/common/data/manipulator/SpongeDataManipulator.java @@ -85,7 +85,7 @@ public Set> getValues() { public String toString() { final MoreObjects.ToStringHelper builder = MoreObjects.toStringHelper(this); for (final Map.Entry, Object> entry : this.values.entrySet()) { - builder.add(entry.getKey().getKey().toString(), entry.getValue()); + builder.add(entry.getKey().key().toString(), entry.getValue()); } return builder.toString(); } diff --git a/src/main/java/org/spongepowered/common/data/meta/SpongePatternLayer.java b/src/main/java/org/spongepowered/common/data/meta/SpongePatternLayer.java index 41cd4d282f2..8d0fe53e09b 100644 --- a/src/main/java/org/spongepowered/common/data/meta/SpongePatternLayer.java +++ b/src/main/java/org/spongepowered/common/data/meta/SpongePatternLayer.java @@ -45,26 +45,26 @@ public SpongePatternLayer(final BannerPatternShape id, final DyeColor color) { } @Override - public BannerPatternShape getShape() { + public BannerPatternShape shape() { return this.id; } @Override - public DyeColor getColor() { + public DyeColor color() { return this.color; } @Override - public int getContentVersion() { + public int contentVersion() { return 1; } @Override public DataContainer toContainer() { - final ResourceKey idKey = Sponge.getGame().registries().registry(RegistryTypes.BANNER_PATTERN_SHAPE).valueKey(this.id); - final ResourceKey colorKey = Sponge.getGame().registries().registry(RegistryTypes.DYE_COLOR).valueKey(this.color); + final ResourceKey idKey = Sponge.game().registries().registry(RegistryTypes.BANNER_PATTERN_SHAPE).valueKey(this.id); + final ResourceKey colorKey = Sponge.game().registries().registry(RegistryTypes.DYE_COLOR).valueKey(this.color); return DataContainer.createNew() - .set(Queries.CONTENT_VERSION, this.getContentVersion()) + .set(Queries.CONTENT_VERSION, this.contentVersion()) .set(Constants.TileEntity.Banner.SHAPE, idKey) .set(Constants.TileEntity.Banner.COLOR, colorKey); } diff --git a/src/main/java/org/spongepowered/common/data/nbt/validation/ValidationTypes.java b/src/main/java/org/spongepowered/common/data/nbt/validation/ValidationTypes.java index 9ef5039ca2c..72b275653b6 100644 --- a/src/main/java/org/spongepowered/common/data/nbt/validation/ValidationTypes.java +++ b/src/main/java/org/spongepowered/common/data/nbt/validation/ValidationTypes.java @@ -48,6 +48,6 @@ private ValidationTypes() { } private static DefaultedRegistryReference key(final ResourceKey location) { - return RegistryKey.of(SpongeRegistryTypes.VALIDATION_TYPE, location).asDefaultedReference(() -> Sponge.getGame().registries()); + return RegistryKey.of(SpongeRegistryTypes.VALIDATION_TYPE, location).asDefaultedReference(() -> Sponge.game().registries()); } } diff --git a/src/main/java/org/spongepowered/common/data/persistence/ConfigurateTranslator.java b/src/main/java/org/spongepowered/common/data/persistence/ConfigurateTranslator.java index 3f1b10fc712..b53bcf90d6d 100644 --- a/src/main/java/org/spongepowered/common/data/persistence/ConfigurateTranslator.java +++ b/src/main/java/org/spongepowered/common/data/persistence/ConfigurateTranslator.java @@ -35,8 +35,6 @@ import org.spongepowered.api.data.persistence.DataView; import org.spongepowered.api.data.persistence.InvalidDataException; import org.spongepowered.common.adventure.SpongeAdventure; -import org.spongepowered.common.data.persistence.ConfigurateTranslator.ToDataView; -import org.spongepowered.common.data.persistence.ConfigurateTranslator.VisitState; import org.spongepowered.configurate.BasicConfigurationNode; import org.spongepowered.configurate.ConfigurationNode; import org.spongepowered.configurate.ConfigurationOptions; @@ -86,7 +84,7 @@ private ConfigurateTranslator() { } @Override - public TypeToken getToken() { + public TypeToken token() { return ConfigurateTranslator.TOKEN; } @@ -109,9 +107,9 @@ public void translateDataToNode(final ConfigurationNode node, final DataView vie // Unvisited hijinks to preserve any comments that may be present final Set unvisitedKeys = new HashSet<>(originalMap.keySet()); - for (final DataQuery key : view.getKeys(false)) { + for (final DataQuery key : view.keys(false)) { this.valueToNode(node.node(key), view.get(key).orElse(null)); - unvisitedKeys.remove(key.getParts().get(0)); + unvisitedKeys.remove(key.parts().get(0)); } for (final Object unusedChild : unvisitedKeys) { diff --git a/src/main/java/org/spongepowered/common/data/persistence/DataSerializers.java b/src/main/java/org/spongepowered/common/data/persistence/DataSerializers.java index 0e8fa9ccb8c..ff14a593757 100644 --- a/src/main/java/org/spongepowered/common/data/persistence/DataSerializers.java +++ b/src/main/java/org/spongepowered/common/data/persistence/DataSerializers.java @@ -98,7 +98,7 @@ public final class DataSerializers { final TypeToken token = TypeToken.get(Component.class); @Override - public TypeToken getToken() { + public TypeToken token() { return this.token; } @@ -125,7 +125,7 @@ public DataContainer translate(final Component obj) throws InvalidDataException final TypeToken token = TypeToken.get(UUID.class); @Override - public TypeToken getToken() { + public TypeToken token() { return this.token; } @@ -154,7 +154,7 @@ public DataView addTo(UUID obj, DataView dataView) { final TypeToken token = TypeToken.get(Vector2d.class); @Override - public TypeToken getToken() { + public TypeToken token() { return this.token; } @@ -182,7 +182,7 @@ public DataView addTo(Vector2d obj, DataView dataView) { final TypeToken token = TypeToken.get(Vector2f.class); @Override - public TypeToken getToken() { + public TypeToken token() { return this.token; } @@ -210,7 +210,7 @@ public DataView addTo(Vector2f obj, DataView dataView) { final TypeToken token = TypeToken.get(Vector2i.class); @Override - public TypeToken getToken() { + public TypeToken token() { return this.token; } @@ -239,7 +239,7 @@ public DataView addTo(Vector2i obj, DataView dataView) { final TypeToken token = TypeToken.get(Vector2l.class); @Override - public TypeToken getToken() { + public TypeToken token() { return this.token; } @@ -267,7 +267,7 @@ public DataView addTo(Vector2l obj, DataView dataView) { final TypeToken token = TypeToken.get(Vector3d.class); @Override - public TypeToken getToken() { + public TypeToken token() { return this.token; } @@ -299,7 +299,7 @@ public DataView addTo(Vector3d obj, DataView dataView) { final TypeToken token = TypeToken.get(Vector3f.class); @Override - public TypeToken getToken() { + public TypeToken token() { return this.token; } @@ -331,7 +331,7 @@ public DataView addTo(Vector3f obj, DataView dataView) { final TypeToken token = TypeToken.get(Vector3i.class); @Override - public TypeToken getToken() { + public TypeToken token() { return this.token; } @@ -363,7 +363,7 @@ public DataView addTo(Vector3i obj, DataView dataView) { final TypeToken token = TypeToken.get(Vector3l.class); @Override - public TypeToken getToken() { + public TypeToken token() { return this.token; } @@ -395,7 +395,7 @@ public DataView addTo(Vector3l obj, DataView dataView) { final TypeToken token = TypeToken.get(Vector4f.class); @Override - public TypeToken getToken() { + public TypeToken token() { return this.token; } @@ -430,7 +430,7 @@ public DataView addTo(Vector4f obj, DataView dataView) { final TypeToken token = TypeToken.get(Vector4i.class); @Override - public TypeToken getToken() { + public TypeToken token() { return this.token; } @@ -465,7 +465,7 @@ public DataView addTo(Vector4i obj, DataView dataView) { final TypeToken token = TypeToken.get(Vector4l.class); @Override - public TypeToken getToken() { + public TypeToken token() { return this.token; } @@ -500,7 +500,7 @@ public DataView addTo(Vector4l obj, DataView dataView) { final TypeToken token = TypeToken.get(Vector4d.class); @Override - public TypeToken getToken() { + public TypeToken token() { return this.token; } @@ -535,7 +535,7 @@ public DataView addTo(Vector4d obj, DataView dataView) { final TypeToken token = TypeToken.get(Complexd.class); @Override - public TypeToken getToken() { + public TypeToken token() { return this.token; } @@ -564,7 +564,7 @@ public DataView addTo(Complexd obj, DataView dataView) { final TypeToken token = TypeToken.get(Complexf.class); @Override - public TypeToken getToken() { + public TypeToken token() { return this.token; } @@ -592,7 +592,7 @@ public DataView addTo(Complexf obj, DataView dataView) { final TypeToken token = TypeToken.get(Quaterniond.class); @Override - public TypeToken getToken() { + public TypeToken token() { return this.token; } @@ -626,7 +626,7 @@ public DataView addTo(Quaterniond obj, DataView dataView) { final TypeToken token = TypeToken.get(Quaternionf.class); @Override - public TypeToken getToken() { + public TypeToken token() { return this.token; } @@ -660,7 +660,7 @@ public DataView addTo(Quaternionf obj, DataView dataView) { final TypeToken token = TypeToken.get(LocalTime.class); @Override - public TypeToken getToken() { + public TypeToken token() { return this.token; } @@ -708,7 +708,7 @@ public DataView addTo(LocalTime obj, DataView dataView) { final TypeToken token = TypeToken.get(LocalDate.class); @Override - public TypeToken getToken() { + public TypeToken token() { return this.token; } @@ -748,7 +748,7 @@ public DataView addTo(LocalDate obj, DataView dataView) { final TypeToken token = TypeToken.get(LocalDateTime.class); @Override - public TypeToken getToken() { + public TypeToken token() { return this.token; } @@ -814,7 +814,7 @@ public DataView addTo(LocalDateTime obj, DataView dataView) { final TypeToken token = TypeToken.get(ZonedDateTime.class); @Override - public TypeToken getToken() { + public TypeToken token() { return this.token; } @@ -887,7 +887,7 @@ public DataView addTo(ZonedDateTime obj, DataView dataView) { final TypeToken token = TypeToken.get(Instant.class); @Override - public TypeToken getToken() { + public TypeToken token() { return this.token; } @@ -955,7 +955,7 @@ public DataView addTo(Instant obj, DataView dataView) { final TypeToken token = TypeToken.get(Month.class); @Override - public TypeToken getToken() { + public TypeToken token() { return this.token; } diff --git a/src/main/java/org/spongepowered/common/data/persistence/JsonDataFormat.java b/src/main/java/org/spongepowered/common/data/persistence/JsonDataFormat.java index 027ed12083f..b2f7877f361 100644 --- a/src/main/java/org/spongepowered/common/data/persistence/JsonDataFormat.java +++ b/src/main/java/org/spongepowered/common/data/persistence/JsonDataFormat.java @@ -183,7 +183,7 @@ public void writeTo(Writer output, DataView data) throws IOException { private static void writeView(JsonWriter writer, DataView view) throws IOException { writer.beginObject(); - for (Map.Entry entry : view.getValues(false).entrySet()) { + for (Map.Entry entry : view.values(false).entrySet()) { writer.name(entry.getKey().asString('.')); JsonDataFormat.write(writer, entry.getValue()); } diff --git a/src/main/java/org/spongepowered/common/data/persistence/NBTTranslator.java b/src/main/java/org/spongepowered/common/data/persistence/NBTTranslator.java index 21f5ff18428..0a8579cbf9e 100644 --- a/src/main/java/org/spongepowered/common/data/persistence/NBTTranslator.java +++ b/src/main/java/org/spongepowered/common/data/persistence/NBTTranslator.java @@ -73,7 +73,7 @@ private static void containerToCompound(final DataView container, final Compound // from the instance of checks. checkNotNull(container); checkNotNull(compound); - for (Map.Entry entry : container.getValues(false).entrySet()) { + for (Map.Entry entry : container.values(false).entrySet()) { Object value = entry.getValue(); String key = entry.getKey().asString('.'); if (value instanceof DataView) { @@ -293,7 +293,7 @@ public DataContainer translateFrom(CompoundTag node) { } @Override - public TypeToken getToken() { + public TypeToken token() { return NBTTranslator.TOKEN; } diff --git a/src/main/java/org/spongepowered/common/data/persistence/datastore/DataStoreRegistry.java b/src/main/java/org/spongepowered/common/data/persistence/datastore/DataStoreRegistry.java index fbcb602be39..75e5b1e187e 100644 --- a/src/main/java/org/spongepowered/common/data/persistence/datastore/DataStoreRegistry.java +++ b/src/main/java/org/spongepowered/common/data/persistence/datastore/DataStoreRegistry.java @@ -89,7 +89,7 @@ public Optional getDataStore(final ResourceKey key, final Type holder private DataStore loadDataStore(final LookupKey lookupKey) { final List dataStores = filterDataStoreCandidates(this.dataStoreByValueKey.get(lookupKey.key), lookupKey.holderType); if (dataStores.size() > 1) { - throw new IllegalStateException("Multiple data-stores registered for the same data-key (" + lookupKey.key.getKey() + ") and data-holder " + lookupKey.holderType.toString()); + throw new IllegalStateException("Multiple data-stores registered for the same data-key (" + lookupKey.key.key() + ") and data-holder " + lookupKey.holderType.toString()); } if (dataStores.isEmpty()) { dataStores.add(this.NO_OP_DATASTORE); @@ -99,14 +99,14 @@ private DataStore loadDataStore(final LookupKey lookupKey) { private List filterDataStoreCandidates(Collection candidates, Type holderType) { return candidates.stream() - .filter(ds -> ds.getSupportedTypes().stream().anyMatch(token -> GenericTypeReflector.isSuperType(token, holderType))) + .filter(ds -> ds.supportedTypes().stream().anyMatch(token -> GenericTypeReflector.isSuperType(token, holderType))) .collect(Collectors.toList()); } public Collection getDataStoresForType(Class holderType) { if (!this.dataStoreByTokenCache.containsKey(holderType)) { for (DataStore dataStore : this.allDataStores) { - if (dataStore.getSupportedTypes().stream().anyMatch(token -> GenericTypeReflector.isSuperType(token, holderType))) { + if (dataStore.supportedTypes().stream().anyMatch(token -> GenericTypeReflector.isSuperType(token, holderType))) { this.dataStoreByTokenCache.put(holderType, dataStore); } } diff --git a/src/main/java/org/spongepowered/common/data/persistence/datastore/SpongeDataStore.java b/src/main/java/org/spongepowered/common/data/persistence/datastore/SpongeDataStore.java index 2f8d7d39dee..3e5ffe561ea 100644 --- a/src/main/java/org/spongepowered/common/data/persistence/datastore/SpongeDataStore.java +++ b/src/main/java/org/spongepowered/common/data/persistence/datastore/SpongeDataStore.java @@ -67,11 +67,11 @@ public Optional getUpdaterFor(Integer fromVersion) { ImmutableList.Builder builder = ImmutableList.builder(); int version = fromVersion; for (DataContentUpdater updater : this.updaters) { - if (updater.getInputVersion() == version) { - if (updater.getOutputVersion() > toVersion) { + if (updater.inputVersion() == version) { + if (updater.outputVersion() > toVersion) { continue; } - version = updater.getOutputVersion(); + version = updater.outputVersion(); builder.add(updater); } } diff --git a/src/main/java/org/spongepowered/common/data/persistence/datastore/SpongeDataStoreBuilder.java b/src/main/java/org/spongepowered/common/data/persistence/datastore/SpongeDataStoreBuilder.java index c3090170f24..897eecf3f25 100644 --- a/src/main/java/org/spongepowered/common/data/persistence/datastore/SpongeDataStoreBuilder.java +++ b/src/main/java/org/spongepowered/common/data/persistence/datastore/SpongeDataStoreBuilder.java @@ -75,7 +75,7 @@ public final class SpongeDataStoreBuilder implements DataStore.Builder, DataStor @Override public > SpongeDataStoreBuilder key(final Key key, final DataQuery dataQuery) { - final BiFunction> deserializer = this.getDeserializer(key.getElementType()); + final BiFunction> deserializer = this.getDeserializer(key.elementType()); return this.key(key, (view, value) -> view.set(dataQuery, value), v -> deserializer.apply(v, dataQuery)); } @@ -92,7 +92,7 @@ public BiFunction> getDeserializer(final Ty if (registryTypeForValue.isPresent()) { return (view, dataQuery) -> (Optional) registryTypeForValue.flatMap(regType -> view.getRegistryValue(dataQuery, regType)); } - if (Sponge.getGame().getDataManager().getTranslator(rawType).isPresent()) { + if (Sponge.game().dataManager().translator(rawType).isPresent()) { return (view, dataQuery) -> (Optional) view.getObject(dataQuery, rawType); } if (Set.class.isAssignableFrom(rawType)) { @@ -121,7 +121,7 @@ public BiFunction> getDeserializer(final Ty final Function> keyDeserializer; final Optional> registryTypeForKey = SpongeDataManager.INSTANCE.findRegistryTypeFor((Class) keyType); if (registryTypeForKey.isPresent()) { - keyDeserializer = key -> registryTypeForKey.flatMap(regType -> Sponge.getGame().registries().findRegistry(regType)) + keyDeserializer = key -> registryTypeForKey.flatMap(regType -> Sponge.game().registries().findRegistry(regType)) .flatMap(r -> r.findValue(ResourceKey.resolve(key.toString()))); } else if (((Class) keyType).isEnum()) { keyDeserializer = key -> Optional.ofNullable(Enum.valueOf(((Class) keyType), key.toString())); @@ -137,7 +137,7 @@ public BiFunction> getDeserializer(final Ty final BiFunction> valueDeserializer = this.getDeserializer(valueType); return (view, dataQuery) -> (Optional) view.getView(dataQuery).map(mapView -> { final Map resultMap = new HashMap<>(); - for (final DataQuery key : mapView.getKeys(false)) { + for (final DataQuery key : mapView.keys(false)) { final Object mapKey = keyDeserializer.apply(key) .orElseThrow(() -> new UnsupportedOperationException("Key not found " + key + " as " + keyType)); final Optional mapValue = valueDeserializer.apply(mapView, key); @@ -150,7 +150,7 @@ public BiFunction> getDeserializer(final Ty } @SuppressWarnings("unchecked") - private static Optional> deserializeList(Class listType, DataView view, DataQuery dataQuery) { + private static Optional> deserializeList(final Class listType, final DataView view, final DataQuery dataQuery) { if (DataView.class.isAssignableFrom(listType)) { return (Optional) view.getViewList(dataQuery); } @@ -162,13 +162,13 @@ private static Optional> deserializeList(Class listType, DataView if (fromRegistry.isPresent()) { return (Optional) fromRegistry; } - if (Sponge.getGame().getDataManager().getTranslator(listType).isPresent()) { + if (Sponge.game().dataManager().translator(listType).isPresent()) { return view.getObjectList(dataQuery, listType); } return (Optional) view.getList(dataQuery); } - private AT[] listToArray(Class componentType, List list) { + private AT[] listToArray(final Class componentType, final List list) { return list.toArray((AT[])Array.newInstance(componentType, list.size())); } @@ -184,7 +184,7 @@ public List getDataHolderTypes() { @SuppressWarnings("rawtypes") public > SpongeDataStoreBuilder key(final Key key, final BiConsumer serializer, final Function> deserializer) { if (this.key != null) { - final DataQuery query = DataQuery.of(this.key.getNamespace(), this.key.getValue()); + final DataQuery query = DataQuery.of(this.key.namespace(), this.key.value()); final SpongeDataSerializer customSerializer = new SpongeDataSerializer<>(serializer, this.version, query); final SpongeDataDeserializer customDeserializer = new SpongeDataDeserializer<>(deserializer, this.version, query); this.serializers.put(key, (Tuple) Tuple.of(customSerializer, customDeserializer)); @@ -197,10 +197,10 @@ public > SpongeDataStoreBuilder key(final Key key, fina @Override @SuppressWarnings({"rawtypes", "unchecked"}) - public EndStep keys(Key key, Key... moreKeys) { - this.key((Key) key, key.getKey().getValue()); - for (Key moreKey : moreKeys) { - this.key((Key) moreKey, moreKey.getKey().getValue()); + public EndStep keys(final Key key, final Key... moreKeys) { + this.key((Key) key, key.key().value()); + for (final Key moreKey : moreKeys) { + this.key((Key) moreKey, moreKey.key().value()); } return this; } @@ -232,20 +232,20 @@ public SpongeDataStoreBuilder holder(final Class... classe } @Override - public SpongeDataStoreBuilder pluginData(ResourceKey key) { + public SpongeDataStoreBuilder pluginData(final ResourceKey key) { this.key = key; return this; } @Override - public SpongeDataStoreBuilder pluginData(ResourceKey key, int version) { + public SpongeDataStoreBuilder pluginData(final ResourceKey key, final int version) { this.pluginData(key); this.version = version; return this; } @Override - public HolderStep updater(DataContentUpdater... updaters) { + public HolderStep updater(final DataContentUpdater... updaters) { this.updaters = updaters; return this; } @@ -271,14 +271,14 @@ private static class SpongeDataSerializer implements BiConsumer private final DataQuery key; private final int version; - public SpongeDataSerializer(BiConsumer serializer, int version, DataQuery key) { + public SpongeDataSerializer(final BiConsumer serializer, final int version, final DataQuery key) { this.serializer = serializer; this.key = key; this.version = version; } @Override - public void accept(DataView view, T v) { + public void accept(final DataView view, final T v) { final DataView data = DataUtil.getSpongeData(view, this.key, this.version).orElse(DataContainer.createNew()); this.serializer.accept(data, v); if (data.isEmpty()) { @@ -294,14 +294,14 @@ private static class SpongeDataDeserializer implements Function> deserializer, int version, DataQuery key) { + public SpongeDataDeserializer(final Function> deserializer, final int version, final DataQuery key) { this.deserializer = deserializer; this.key = key; this.version = version; } @Override - public Optional apply(DataView view) { + public Optional apply(final DataView view) { return DataUtil.getSpongeData(view, this.key, this.version).flatMap(this.deserializer); } } diff --git a/src/main/java/org/spongepowered/common/data/persistence/datastore/VanillaDataStore.java b/src/main/java/org/spongepowered/common/data/persistence/datastore/VanillaDataStore.java index e58c5da6ceb..2f8c169fb61 100644 --- a/src/main/java/org/spongepowered/common/data/persistence/datastore/VanillaDataStore.java +++ b/src/main/java/org/spongepowered/common/data/persistence/datastore/VanillaDataStore.java @@ -49,7 +49,7 @@ public VanillaDataStore(final Map, Tuple, Functio } @Override - public Collection getSupportedTypes() { + public Collection supportedTypes() { return this.tokens; } @@ -57,7 +57,7 @@ public Collection getSupportedTypes() { @SuppressWarnings(value = {"unchecked", "rawtypes"}) public DataView serialize(DataManipulator dataManipulator, DataView view) { for (Map.Entry, Tuple, Function>>> entry : this.queriesByKey.entrySet()) { - final BiConsumer serializer = entry.getValue().getFirst(); + final BiConsumer serializer = entry.getValue().first(); dataManipulator.get((Key) entry.getKey()).ifPresent(value -> serializer.accept(view, value)); } return view; @@ -67,7 +67,7 @@ public DataView serialize(DataManipulator dataManipulator, DataView view) { @SuppressWarnings(value = {"unchecked", "rawtypes"}) public void deserialize(DataManipulator.Mutable dataManipulator, DataView view) { for (Map.Entry, Tuple, Function>>> entry : this.queriesByKey.entrySet()) { - final Function> deserializer = entry.getValue().getSecond(); + final Function> deserializer = entry.getValue().second(); deserializer.apply(view).ifPresent(value -> dataManipulator.set((Key) entry.getKey(), value)); } } diff --git a/src/main/java/org/spongepowered/common/data/persistence/schematic/SchematicUpdater1_to_2.java b/src/main/java/org/spongepowered/common/data/persistence/schematic/SchematicUpdater1_to_2.java index 64f1d0f0db2..7440c9ec479 100644 --- a/src/main/java/org/spongepowered/common/data/persistence/schematic/SchematicUpdater1_to_2.java +++ b/src/main/java/org/spongepowered/common/data/persistence/schematic/SchematicUpdater1_to_2.java @@ -33,12 +33,12 @@ public final class SchematicUpdater1_to_2 implements DataContentUpdater { @Override - public int getInputVersion() { + public int inputVersion() { return 1; } @Override - public int getOutputVersion() { + public int outputVersion() { return 2; } diff --git a/src/main/java/org/spongepowered/common/data/provider/AbstractDataProvider.java b/src/main/java/org/spongepowered/common/data/provider/AbstractDataProvider.java index d80efbca5d6..9ddcee69e8f 100644 --- a/src/main/java/org/spongepowered/common/data/provider/AbstractDataProvider.java +++ b/src/main/java/org/spongepowered/common/data/provider/AbstractDataProvider.java @@ -38,7 +38,7 @@ public AbstractDataProvider(Key key) { } @Override - public Key getKey() { + public Key key() { return this.key; } diff --git a/src/main/java/org/spongepowered/common/data/provider/CustomDataProvider.java b/src/main/java/org/spongepowered/common/data/provider/CustomDataProvider.java index 9d996b0a3e6..978eb61065a 100644 --- a/src/main/java/org/spongepowered/common/data/provider/CustomDataProvider.java +++ b/src/main/java/org/spongepowered/common/data/provider/CustomDataProvider.java @@ -50,7 +50,7 @@ public CustomDataProvider(final Key key, final Set supportedTokens) { public Optional get(DataHolder dataHolder) { if (this.isSupported(dataHolder)) { final SpongeDataHolderBridge customDataHolder = CustomDataProvider.getCustomDataHolder(dataHolder); - return customDataHolder.bridge$get(this.getKey()); + return customDataHolder.bridge$get(this.key()); } return Optional.empty(); } @@ -58,7 +58,7 @@ public Optional get(DataHolder dataHolder) { private static SpongeDataHolderBridge getCustomDataHolder(DataHolder dataHolder) { final SpongeDataHolderBridge customDataHolder; if (dataHolder instanceof ServerLocation) { - customDataHolder = (SpongeDataHolderBridge) ((ServerLocation) dataHolder).getBlockEntity().get(); + customDataHolder = (SpongeDataHolderBridge) ((ServerLocation) dataHolder).blockEntity().get(); } else { customDataHolder = (SpongeDataHolderBridge) dataHolder; } @@ -105,7 +105,7 @@ public boolean isSupported(final Type dataHolder) { @Override public DataTransactionResult offer(DataHolder.Mutable dataHolder, E element) { if (this.isSupported(dataHolder)) { - return CustomDataProvider.getCustomDataHolder(dataHolder).bridge$offer(this.getKey(), element); + return CustomDataProvider.getCustomDataHolder(dataHolder).bridge$offer(this.key(), element); } return DataTransactionResult.failNoData(); } @@ -113,7 +113,7 @@ public DataTransactionResult offer(DataHolder.Mutable dataHolder, E element) { @Override public DataTransactionResult remove(DataHolder.Mutable dataHolder) { if (this.isSupported(dataHolder)) { - return CustomDataProvider.getCustomDataHolder(dataHolder).bridge$remove(this.getKey()); + return CustomDataProvider.getCustomDataHolder(dataHolder).bridge$remove(this.key()); } return DataTransactionResult.failNoData(); } diff --git a/src/main/java/org/spongepowered/common/data/provider/DataProviderRegistrator.java b/src/main/java/org/spongepowered/common/data/provider/DataProviderRegistrator.java index e0348ba0c33..629a42c38f1 100644 --- a/src/main/java/org/spongepowered/common/data/provider/DataProviderRegistrator.java +++ b/src/main/java/org/spongepowered/common/data/provider/DataProviderRegistrator.java @@ -53,9 +53,6 @@ import java.lang.reflect.Type; import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.List; import java.util.Optional; import java.util.function.BiConsumer; import java.util.function.BiFunction; @@ -102,7 +99,7 @@ public void spongeDataStore(final ResourceKey datastoreKey, final int version, f builder.updater(contentUpdater); builder.holder(dataHolder); for (Key dataKey : dataKeys) { - builder.key(dataKey, dataKey.getKey().getValue()); + builder.key(dataKey, dataKey.key().value()); } SpongeDataManager.getDatastoreRegistry().register(builder.build(), Arrays.asList(dataKeys)); } @@ -167,7 +164,7 @@ public void buildAndRegister() { if (!this.dataStoreBuilder.isEmpty()) { this.registrationBuilder.store(this.dataStoreBuilder.buildVanillaDataStore()); } - ((SpongeDataManager) Sponge.getGame().getDataManager()).registerDataRegistration((SpongeDataRegistration) this.registrationBuilder.build()); + ((SpongeDataManager) Sponge.game().dataManager()).registerDataRegistration((SpongeDataRegistration) this.registrationBuilder.build()); } @@ -205,7 +202,7 @@ public MutableRegistration create(final Key> key) { @SuppressWarnings({"unchecked", "UnstableApiUsage"}) protected > MutableRegistrator register(final MutableRegistration registration) { final DataProvider provider = registration.build(this.target); - this.registrationBuilder.dataKey(provider.getKey()).provider(provider); + this.registrationBuilder.dataKey(provider.key()).provider(provider); return this; } } @@ -244,7 +241,7 @@ public ImmutableRegistration create(final Key> key) @SuppressWarnings({"unchecked", "UnstableApiUsage"}) protected ImmutableRegistrator register(final ImmutableRegistration registration) { final DataProvider provider = registration.build(this.target); - this.registrationBuilder.dataKey(provider.getKey()).provider(provider); + this.registrationBuilder.dataKey(provider.key()).provider(provider); return this; } } @@ -329,7 +326,7 @@ public R supports(final Function supports) { public DataProvider build(Class target) { final MutableRegistrationBase registration = this; return new GenericMutableDataProvider(registration.key, target) { - final boolean isBooleanKey = registration.key.getElementType() == Boolean.class; + final boolean isBooleanKey = registration.key.elementType() == Boolean.class; @Override protected Value constructValue(final H dataHolder, final E element) { @@ -478,7 +475,7 @@ public R supports(final Function supports) { public DataProvider build(final Class target) { final ImmutableRegistrationBase registration = this; return new GenericImmutableDataProvider(registration.key, target) { - final boolean isBooleanKey = GenericTypeReflector.erase(registration.key.getElementType())== Boolean.class; + final boolean isBooleanKey = GenericTypeReflector.erase(registration.key.elementType())== Boolean.class; @Override protected Value constructValue(final H dataHolder, final E element) { diff --git a/src/main/java/org/spongepowered/common/data/provider/DataProviderRegistry.java b/src/main/java/org/spongepowered/common/data/provider/DataProviderRegistry.java index 77ccc993b68..04bd9fa6f6b 100644 --- a/src/main/java/org/spongepowered/common/data/provider/DataProviderRegistry.java +++ b/src/main/java/org/spongepowered/common/data/provider/DataProviderRegistry.java @@ -104,7 +104,7 @@ private DataProviderLookup loadProviderLookup(final Class holderType) { final Stream stream = this.dataProviders.keySet().stream() .map(key -> this.getProvider((Key) key, holderType)) .filter(provider -> !(provider instanceof EmptyDataProvider)); - final Map, DataProvider> map = stream.collect(Collectors.toMap(p -> (Key) p.getKey(), p -> (DataProvider) p)); + final Map, DataProvider> map = stream.collect(Collectors.toMap(p -> (Key) p.key(), p -> (DataProvider) p)); return new DataProviderLookup(map); } @@ -148,7 +148,7 @@ public DataProviderLookup getProviderLookup(final Class dataHolderType) { public DataProviderLookup buildLookup(final Predicate> predicate) { final Stream stream = this.dataProviders.keySet().stream() .map(key -> DataProviderRegistry.buildDelegateProvider((Key) key, (List) this.dataProviders.get(key).stream().filter(predicate))); - final Map, DataProvider> map = stream.collect(Collectors.toMap(p -> (Key) p.getKey(), p -> (DataProvider) p)); + final Map, DataProvider> map = stream.collect(Collectors.toMap(p -> (Key) p.key(), p -> (DataProvider) p)); return new DataProviderLookup(map); } @@ -200,7 +200,7 @@ public , E> DataProvider getProvider(final Key key, * @param provider The data provider */ public void register(final DataProvider provider) { - this.dataProviders.put(provider.getKey(), provider); + this.dataProviders.put(provider.key(), provider); this.dataProviderCache.clear(); this.dataProviderLookupCache.clear(); } diff --git a/src/main/java/org/spongepowered/common/data/provider/DelegateDataProvider.java b/src/main/java/org/spongepowered/common/data/provider/DelegateDataProvider.java index 278a946fa27..9d6eb51acce 100644 --- a/src/main/java/org/spongepowered/common/data/provider/DelegateDataProvider.java +++ b/src/main/java/org/spongepowered/common/data/provider/DelegateDataProvider.java @@ -45,7 +45,7 @@ class DelegateDataProvider, E> implements DataProvider } @Override - public Key getKey() { + public Key key() { return this.key; } @@ -76,7 +76,7 @@ public boolean isSupported(final Type dataHolder) { public DataTransactionResult offer(DataHolder.Mutable dataHolder, E element) { return this.providers.stream() .map(provider -> provider.offer(dataHolder, element)) - .filter(result -> result.getType() != DataTransactionResult.Type.FAILURE) + .filter(result -> result.type() != DataTransactionResult.Type.FAILURE) .findFirst() .orElseGet(() -> DataTransactionResult.errorResult(Value.immutableOf(this.key, element))); } @@ -85,7 +85,7 @@ public DataTransactionResult offer(DataHolder.Mutable dataHolder, E element) { public DataTransactionResult remove(DataHolder.Mutable dataHolder) { return this.providers.stream() .map(provider -> provider.remove(dataHolder)) - .filter(result -> result.getType() != DataTransactionResult.Type.FAILURE) + .filter(result -> result.type() != DataTransactionResult.Type.FAILURE) .findFirst() .orElseGet(DataTransactionResult::failNoData); } diff --git a/src/main/java/org/spongepowered/common/data/provider/EmptyDataProvider.java b/src/main/java/org/spongepowered/common/data/provider/EmptyDataProvider.java index 62c9d090ea3..15985d61c7d 100644 --- a/src/main/java/org/spongepowered/common/data/provider/EmptyDataProvider.java +++ b/src/main/java/org/spongepowered/common/data/provider/EmptyDataProvider.java @@ -42,7 +42,7 @@ public EmptyDataProvider(Key key) { } @Override - public Key getKey() { + public Key key() { return this.key; } diff --git a/src/main/java/org/spongepowered/common/data/provider/GenericImmutableDataProviderBase.java b/src/main/java/org/spongepowered/common/data/provider/GenericImmutableDataProviderBase.java index 2e3f8b94021..7d782698857 100644 --- a/src/main/java/org/spongepowered/common/data/provider/GenericImmutableDataProviderBase.java +++ b/src/main/java/org/spongepowered/common/data/provider/GenericImmutableDataProviderBase.java @@ -94,7 +94,7 @@ protected boolean supports(final H dataHolder) { * @return The value */ protected V constructValue(final H dataHolder, final E element) { - return Value.genericImmutableOf(this.getKey(), element); + return Value.genericImmutableOf(this.key(), element); } /** @@ -116,7 +116,7 @@ public final Optional get(final DataHolder dataHolder) { } @Override - public Optional getValue(final DataHolder dataHolder) { + public Optional value(final DataHolder dataHolder) { return this.get(dataHolder).map(e -> this.constructValue((H) dataHolder, e)); } diff --git a/src/main/java/org/spongepowered/common/data/provider/GenericMutableDataProviderBase.java b/src/main/java/org/spongepowered/common/data/provider/GenericMutableDataProviderBase.java index 56342fc8b79..f9b0777d09a 100644 --- a/src/main/java/org/spongepowered/common/data/provider/GenericMutableDataProviderBase.java +++ b/src/main/java/org/spongepowered/common/data/provider/GenericMutableDataProviderBase.java @@ -119,7 +119,7 @@ protected boolean set(final H dataHolder, final E value) { protected DataTransactionResult setAndGetResult(final H dataHolder, final E value) { final Optional> originalValue = this.getFrom(dataHolder) .map(e -> this.constructValue(dataHolder, e).asImmutable()); - final Value.Immutable replacementValue = Value.immutableOf(this.getKey(), value); + final Value.Immutable replacementValue = Value.immutableOf(this.key(), value); try { if (this.set(dataHolder, value)) { final DataTransactionResult.Builder builder = DataTransactionResult.builder(); @@ -141,7 +141,7 @@ protected DataTransactionResult setAndGetResult(final H dataHolder, final E valu * @return The value */ protected V constructValue(final H dataHolder, final E element) { - return Value.genericImmutableOf(this.getKey(), element); + return Value.genericImmutableOf(this.key(), element); } /** @@ -183,7 +183,7 @@ public boolean isSupported(final Type dataHolder) { } @Override - public final Optional getValue(final DataHolder dataHolder) { + public final Optional value(final DataHolder dataHolder) { if (!this.isSupported(dataHolder)) { return Optional.empty(); } @@ -223,7 +223,7 @@ public final DataTransactionResult offerValue(final DataHolder.Mutable dataHolde @Override public final DataTransactionResult offer(final DataHolder.Mutable dataHolder, final E element) { if (!this.isSupported(dataHolder)) { - return DataTransactionResult.failResult(Value.immutableOf(this.getKey(), element)); + return DataTransactionResult.failResult(Value.immutableOf(this.key(), element)); } return this.setAndGetResult((H) dataHolder, element); } diff --git a/src/main/java/org/spongepowered/common/data/provider/ImmutableDataProvider.java b/src/main/java/org/spongepowered/common/data/provider/ImmutableDataProvider.java index 0a24f72568b..ef7d75c0c89 100644 --- a/src/main/java/org/spongepowered/common/data/provider/ImmutableDataProvider.java +++ b/src/main/java/org/spongepowered/common/data/provider/ImmutableDataProvider.java @@ -43,7 +43,7 @@ public boolean allowsAsynchronousAccess(DataHolder dataHolder) { @Override public DataTransactionResult offer(DataHolder.Mutable dataHolder, E element) { - return DataTransactionResult.failResult(Value.immutableOf(this.getKey(), element)); + return DataTransactionResult.failResult(Value.immutableOf(this.key(), element)); } @Override diff --git a/src/main/java/org/spongepowered/common/data/provider/block/entity/AbstractFurnaceData.java b/src/main/java/org/spongepowered/common/data/provider/block/entity/AbstractFurnaceData.java index 25383a40c2d..38e05a42c58 100644 --- a/src/main/java/org/spongepowered/common/data/provider/block/entity/AbstractFurnaceData.java +++ b/src/main/java/org/spongepowered/common/data/provider/block/entity/AbstractFurnaceData.java @@ -49,14 +49,14 @@ public static void register(final DataProviderRegistrator registrator) { }) .create(Keys.MAX_BURN_TIME) .get(x -> new SpongeTicks(x.accessor$litDuration())) - .set((h, v) -> h.accessor$litDuration((int) v.getTicks())) + .set((h, v) -> h.accessor$litDuration((int) v.ticks())) .create(Keys.MAX_COOK_TIME) .get(x -> new SpongeTicks(x.accessor$cookingTotalTime())) - .set((h, v) -> h.accessor$cookingTotalTime((int) v.getTicks())) + .set((h, v) -> h.accessor$cookingTotalTime((int) v.ticks())) .create(Keys.PASSED_COOK_TIME) .get(x -> new SpongeTicks(x.accessor$cookingProgress())) .set((h, v) -> { - final int ticks = (int) v.getTicks(); + final int ticks = (int) v.ticks(); if (ticks < h.accessor$cookingTotalTime()) { h.accessor$cookingProgress(ticks); } diff --git a/src/main/java/org/spongepowered/common/data/provider/block/entity/BrewingStandData.java b/src/main/java/org/spongepowered/common/data/provider/block/entity/BrewingStandData.java index 967fa3f1ba5..d9bb4860b77 100644 --- a/src/main/java/org/spongepowered/common/data/provider/block/entity/BrewingStandData.java +++ b/src/main/java/org/spongepowered/common/data/provider/block/entity/BrewingStandData.java @@ -51,7 +51,7 @@ public static void register(final DataProviderRegistrator registrator) { .get(h -> h.invoker$isBrewable() ? new SpongeTicks(h.accessor$brewTime()) : null) .set((h, v) -> { if (h.invoker$isBrewable()) { - h.accessor$brewTime((int) v.getTicks()); + h.accessor$brewTime((int) v.ticks()); } }); } diff --git a/src/main/java/org/spongepowered/common/data/provider/block/entity/EndGatewayData.java b/src/main/java/org/spongepowered/common/data/provider/block/entity/EndGatewayData.java index c83e21de241..78afa8ce22f 100644 --- a/src/main/java/org/spongepowered/common/data/provider/block/entity/EndGatewayData.java +++ b/src/main/java/org/spongepowered/common/data/provider/block/entity/EndGatewayData.java @@ -42,7 +42,7 @@ public static void register(final DataProviderRegistrator registrator) { .create(Keys.COOLDOWN) .get(x -> new SpongeTicks(x.accessor$teleportCooldown())) .setAnd((h, v) -> { - final int ticks = (int) v.getTicks(); + final int ticks = (int) v.ticks(); if (ticks < 0) { return false; } @@ -55,7 +55,7 @@ public static void register(final DataProviderRegistrator registrator) { .create(Keys.END_GATEWAY_AGE) .get(x -> new SpongeTicks(x.accessor$age())) .setAnd((h, v) -> { - final long ticks = v.getTicks(); + final long ticks = v.ticks(); if (ticks < 0) { return false; } diff --git a/src/main/java/org/spongepowered/common/data/provider/block/entity/HopperData.java b/src/main/java/org/spongepowered/common/data/provider/block/entity/HopperData.java index b612ff3eb2e..44f71870267 100644 --- a/src/main/java/org/spongepowered/common/data/provider/block/entity/HopperData.java +++ b/src/main/java/org/spongepowered/common/data/provider/block/entity/HopperData.java @@ -41,7 +41,7 @@ public static void register(final DataProviderRegistrator registrator) { .create(Keys.COOLDOWN) .get(h -> new SpongeTicks(Math.max(h.accessor$cooldownTime(), 0))) .setAnd((h, v) -> { - final int ticks = (int) v.getTicks(); + final int ticks = (int) v.ticks(); if (ticks < 0) { return false; } diff --git a/src/main/java/org/spongepowered/common/data/provider/block/entity/MobSpawnerData.java b/src/main/java/org/spongepowered/common/data/provider/block/entity/MobSpawnerData.java index 770f46e5707..7317c1cc3b4 100644 --- a/src/main/java/org/spongepowered/common/data/provider/block/entity/MobSpawnerData.java +++ b/src/main/java/org/spongepowered/common/data/provider/block/entity/MobSpawnerData.java @@ -60,16 +60,16 @@ public static void register(final DataProviderRegistrator registrator) { .set((h, v) -> ((BaseSpawnerAccessor) h.accessor$spawner()).accessor$maxNearbyEntities(v)) .create(Keys.MAX_SPAWN_DELAY) .get(h -> new SpongeTicks(((BaseSpawnerAccessor) h.accessor$spawner()).accessor$maxSpawnDelay())) - .set((h, v) -> ((BaseSpawnerAccessor) h.accessor$spawner()).accessor$maxSpawnDelay((int) v.getTicks())) + .set((h, v) -> ((BaseSpawnerAccessor) h.accessor$spawner()).accessor$maxSpawnDelay((int) v.ticks())) .create(Keys.MIN_SPAWN_DELAY) .get(h -> new SpongeTicks(((BaseSpawnerAccessor) h.accessor$spawner()).accessor$minSpawnDelay())) - .set((h, v) -> ((BaseSpawnerAccessor) h.accessor$spawner()).accessor$minSpawnDelay((int) v.getTicks())) + .set((h, v) -> ((BaseSpawnerAccessor) h.accessor$spawner()).accessor$minSpawnDelay((int) v.ticks())) .create(Keys.NEXT_ENTITY_TO_SPAWN) .get(h -> MobSpawnerData.getNextEntity((BaseSpawnerAccessor) h.accessor$spawner())) .set((h, v) -> MobSpawnerData.setNextEntity(h.accessor$spawner(), v)) .create(Keys.REMAINING_SPAWN_DELAY) .get(h -> new SpongeTicks(((BaseSpawnerAccessor) h.accessor$spawner()).accessor$spawnDelay())) - .set((h, v) -> ((BaseSpawnerAccessor) h.accessor$spawner()).accessor$spawnDelay((int) v.getTicks())) + .set((h, v) -> ((BaseSpawnerAccessor) h.accessor$spawner()).accessor$spawnDelay((int) v.ticks())) .create(Keys.REQUIRED_PLAYER_RANGE) .get(h -> (double) ((BaseSpawnerAccessor) h.accessor$spawner()).accessor$requiredPlayerRange()) .set((h, v) -> ((BaseSpawnerAccessor) h.accessor$spawner()).accessor$requiredPlayerRange(v.intValue())) @@ -107,14 +107,14 @@ private static WeightedSerializableObject getNextEntity(final B } private static void setNextEntity(final BaseSpawner logic, final WeightedSerializableObject value) { - final CompoundTag compound = NBTTranslator.INSTANCE.translate(value.get().getEntityData()); + final CompoundTag compound = NBTTranslator.INSTANCE.translate(value.get().entityData()); if (!compound.contains(Constants.Entity.ENTITY_TYPE_ID)) { final ResourceKey key = (ResourceKey) (Object) net.minecraft.world.entity.EntityType.getKey((net.minecraft.world.entity.EntityType) value.get() - .getType()); + .type()); compound.putString(Constants.Entity.ENTITY_TYPE_ID, key.toString()); } - logic.setNextSpawnData(new SpawnData((int) value.getWeight(), compound)); + logic.setNextSpawnData(new SpawnData((int) value.weight(), compound)); } private static WeightedTable getEntities(final BaseSpawner logic) { @@ -147,15 +147,15 @@ private static void setEntities(final BaseSpawnerAccessor logic, final WeightedT } final WeightedObject object = (WeightedObject) entry; - final CompoundTag compound = NBTTranslator.INSTANCE.translate(object.get().getEntityData()); + final CompoundTag compound = NBTTranslator.INSTANCE.translate(object.get().entityData()); if (!compound.contains(Constants.Entity.ENTITY_TYPE_ID)) { final ResourceKey key = (ResourceKey) (Object) net.minecraft.world.entity.EntityType.getKey((net.minecraft.world.entity.EntityType) object - .get().getType()); + .get().type()); compound.putString(Constants.Entity.ENTITY_TYPE_ID, key.toString()); } - logic.accessor$spawnPotentials().add(new SpawnData((int) entry.getWeight(), compound)); + logic.accessor$spawnPotentials().add(new SpawnData((int) entry.weight(), compound)); } } } diff --git a/src/main/java/org/spongepowered/common/data/provider/block/entity/SignData.java b/src/main/java/org/spongepowered/common/data/provider/block/entity/SignData.java index ed231b53b7e..fcf731e9125 100644 --- a/src/main/java/org/spongepowered/common/data/provider/block/entity/SignData.java +++ b/src/main/java/org/spongepowered/common/data/provider/block/entity/SignData.java @@ -79,12 +79,12 @@ public static void register(final DataProviderRegistrator registrator) { .get(SignData::getSignLines) .set(SignData::setSignLines) .delete(h -> SignData.setSignLines(h, Collections.emptyList())) - .supports(loc -> loc.getBlockEntity().map(b -> b instanceof SignBlockEntity).orElse(false)); + .supports(loc -> loc.blockEntity().map(b -> b instanceof SignBlockEntity).orElse(false)); } // @formatter:on private static SignBlockEntity toSignTileEntity(final ServerLocation holder) { - return (SignBlockEntity) holder.getBlockEntity().get(); + return (SignBlockEntity) holder.blockEntity().get(); } private static void setSignLines(final ServerLocation holder, final List value) { diff --git a/src/main/java/org/spongepowered/common/data/provider/block/location/ServerLocationData.java b/src/main/java/org/spongepowered/common/data/provider/block/location/ServerLocationData.java index 462007bf21a..16ae8621640 100644 --- a/src/main/java/org/spongepowered/common/data/provider/block/location/ServerLocationData.java +++ b/src/main/java/org/spongepowered/common/data/provider/block/location/ServerLocationData.java @@ -50,53 +50,53 @@ public static void register(final DataProviderRegistrator registrator) { .asMutable(ServerLocation.class) .create(Keys.BIOME_TEMPERATURE) .get(h -> { - final Level world = (Level) h.getWorld(); + final Level world = (Level) h.world(); final BlockPos pos = VecHelper.toBlockPos(h); final Biome biome = world.getBiome(pos); return (double) biome.getBaseTemperature(); }) .create(Keys.BLOCK_LIGHT) .get(h -> { - final Level world = (Level) h.getWorld(); + final Level world = (Level) h.world(); return world.getBrightness(LightLayer.BLOCK, VecHelper.toBlockPos(h)); }) .create(Keys.BLOCK_TEMPERATURE) .get(h -> { - final Level world = (Level) h.getWorld(); + final Level world = (Level) h.world(); final BlockPos pos = VecHelper.toBlockPos(h); final Biome biome = world.getBiome(pos); return (double) biome.getTemperature(pos); }) .create(Keys.SKY_LIGHT) .get(h -> { - final Level world = (Level) h.getWorld(); + final Level world = (Level) h.world(); final BlockPos pos = VecHelper.toBlockPos(h); return world.getBrightness(LightLayer.SKY, pos); }) .create(Keys.IS_FULL_BLOCK) .get(h -> { - final BlockState block = (BlockState) h.getBlock(); - final Level world = (Level) h.getWorld(); - final BlockPos pos = VecHelper.toBlockPos(h.getPosition()); + final BlockState block = (BlockState) h.block(); + final Level world = (Level) h.world(); + final BlockPos pos = VecHelper.toBlockPos(h.position()); return block.isSolidRender(world, pos); }) .create(Keys.IS_INDIRECTLY_POWERED) .get(h -> { - final Level world = (Level) h.getWorld(); + final Level world = (Level) h.world(); final BlockPos pos = VecHelper.toBlockPos(h); return world.getBestNeighborSignal(pos) > 0; }) .create(Keys.DISPLAY_NAME) - .get(h -> SpongeAdventure.asAdventure(((Nameable)h.getBlockEntity().get()).getDisplayName())) - .supports(h -> h.getBlockEntity().isPresent() && h.getBlockEntity().get() instanceof NameableBlockEntity) + .get(h -> SpongeAdventure.asAdventure(((Nameable)h.blockEntity().get()).getDisplayName())) + .supports(h -> h.blockEntity().isPresent() && h.blockEntity().get() instanceof NameableBlockEntity) .create(Keys.CUSTOM_NAME) .get(h -> { - final BlockEntity blockEntity = h.getBlockEntity().get(); + final BlockEntity blockEntity = h.blockEntity().get(); return ((Nameable) blockEntity).hasCustomName() ? SpongeAdventure.asAdventure(((Nameable)blockEntity).getCustomName()) : null; }) - .set((h, v) -> (((CustomNameableBridge)h.getBlockEntity().get())).bridge$setCustomDisplayName(SpongeAdventure.asVanilla(v))) - .delete(h -> (((CustomNameableBridge)h.getBlockEntity().get())).bridge$setCustomDisplayName(null)) - .supports(h -> h.getBlockEntity().isPresent() && h.getBlockEntity().get() instanceof NameableBlockEntity); + .set((h, v) -> (((CustomNameableBridge)h.blockEntity().get())).bridge$setCustomDisplayName(SpongeAdventure.asVanilla(v))) + .delete(h -> (((CustomNameableBridge)h.blockEntity().get())).bridge$setCustomDisplayName(null)) + .supports(h -> h.blockEntity().isPresent() && h.blockEntity().get() instanceof NameableBlockEntity); ; } // @formatter:on diff --git a/src/main/java/org/spongepowered/common/data/provider/block/state/NoteBlockData.java b/src/main/java/org/spongepowered/common/data/provider/block/state/NoteBlockData.java index 4a531dd5916..049ab600f75 100644 --- a/src/main/java/org/spongepowered/common/data/provider/block/state/NoteBlockData.java +++ b/src/main/java/org/spongepowered/common/data/provider/block/state/NoteBlockData.java @@ -50,11 +50,11 @@ public static void register(final DataProviderRegistrator registrator) { .supports(h -> h.getBlock() instanceof NoteBlock) .create(Keys.NOTE_PITCH) .get(h -> { - final MappedRegistry registry = (MappedRegistry) (Object) Sponge.getGame().registries().registry(RegistryTypes.NOTE_PITCH); + final MappedRegistry registry = (MappedRegistry) (Object) Sponge.game().registries().registry(RegistryTypes.NOTE_PITCH); return registry.byId(h.getValue(NoteBlock.NOTE)); }) .set((h, v) -> { - final MappedRegistry registry = (MappedRegistry) (Object) Sponge.getGame().registries().registry(RegistryTypes.NOTE_PITCH); + final MappedRegistry registry = (MappedRegistry) (Object) Sponge.game().registries().registry(RegistryTypes.NOTE_PITCH); return h.setValue(NoteBlock.NOTE, registry.getId(v)); }) .supports(h -> h.getBlock() instanceof NoteBlock); diff --git a/src/main/java/org/spongepowered/common/data/provider/block/state/TerracottaData.java b/src/main/java/org/spongepowered/common/data/provider/block/state/TerracottaData.java index fb04f2cf17f..8c04a358c2e 100644 --- a/src/main/java/org/spongepowered/common/data/provider/block/state/TerracottaData.java +++ b/src/main/java/org/spongepowered/common/data/provider/block/state/TerracottaData.java @@ -47,12 +47,12 @@ public static void register(final DataProviderRegistrator registrator) { .create(Keys.DYE_COLOR) .get(h -> (DyeColor) (Object) DyeColorUtil.COLOR_BY_TERRACOTTA.get(h.getBlock())) .supports(h -> { - final ResourceKey key = Sponge.getGame().registries().registry(RegistryTypes.BLOCK_TYPE).valueKey(((BlockType)h.getBlock())); - if (!key.getNamespace().equals(PluginManager.MINECRAFT_PLUGIN_ID)) { + final ResourceKey key = Sponge.game().registries().registry(RegistryTypes.BLOCK_TYPE).valueKey(((BlockType)h.getBlock())); + if (!key.namespace().equals(PluginManager.MINECRAFT_PLUGIN_ID)) { return false; } - return key.getValue().endsWith("_terracotta"); + return key.value().endsWith("_terracotta"); }); } // @formatter:on diff --git a/src/main/java/org/spongepowered/common/data/provider/entity/AgeableData.java b/src/main/java/org/spongepowered/common/data/provider/entity/AgeableData.java index ee8d67e0f21..7f3e555fd84 100644 --- a/src/main/java/org/spongepowered/common/data/provider/entity/AgeableData.java +++ b/src/main/java/org/spongepowered/common/data/provider/entity/AgeableData.java @@ -42,7 +42,7 @@ public static void register(final DataProviderRegistrator registrator) { .create(Keys.BABY_TICKS) .get(h -> h.getAge() < 0 ? new SpongeTicks(-h.getAge()) : null) .setAnd((h, v) -> { - final int ticks = (int) v.getTicks(); + final int ticks = (int) v.ticks(); if (ticks < 0) { return false; } @@ -52,7 +52,7 @@ public static void register(final DataProviderRegistrator registrator) { .create(Keys.BREEDING_COOLDOWN) .get(h -> h.getAge() >= 0 ? new SpongeTicks(h.getAge()) : null) .setAnd((h, v) -> { - final int ticks = (int) v.getTicks(); + final int ticks = (int) v.ticks(); if (ticks < 0) { return false; } diff --git a/src/main/java/org/spongepowered/common/data/provider/entity/AreaEffectCloudData.java b/src/main/java/org/spongepowered/common/data/provider/entity/AreaEffectCloudData.java index ecc3e645034..60bd72f3501 100644 --- a/src/main/java/org/spongepowered/common/data/provider/entity/AreaEffectCloudData.java +++ b/src/main/java/org/spongepowered/common/data/provider/entity/AreaEffectCloudData.java @@ -44,11 +44,11 @@ public static void register(final DataProviderRegistrator registrator) { .asMutable(AreaEffectCloud.class) .create(Keys.COLOR) .get(h -> Color.ofRgb(h.getColor())) - .set((h, v) -> h.setFixedColor(v.getRgb())) + .set((h, v) -> h.setFixedColor(v.rgb())) .create(Keys.DURATION) .get(x -> new SpongeTicks(x.getDuration())) .setAnd((h, v) -> { - final int ticks = (int) v.getTicks(); + final int ticks = (int) v.ticks(); if (ticks < 0) { return false; } @@ -73,17 +73,17 @@ public static void register(final DataProviderRegistrator registrator) { .set((h, v) -> h.setRadiusPerTick(v.floatValue())) .create(Keys.WAIT_TIME) .get(h -> new SpongeTicks(((AreaEffectCloudAccessor) h).accessor$waitTime())) - .set((h, v) -> h.setWaitTime((int) v.getTicks())) + .set((h, v) -> h.setWaitTime((int) v.ticks())) .asMutable(AreaEffectCloudAccessor.class) .create(Keys.DURATION_ON_USE) .get(h -> new SpongeTicks(h.accessor$durationOnUse())) - .set((h, v) -> h.accessor$durationOnUse((int) v.getTicks())) + .set((h, v) -> h.accessor$durationOnUse((int) v.ticks())) .create(Keys.POTION_EFFECTS) .get(h -> PotionEffectUtil.copyAsPotionEffects(h.accessor$effects())) .set((h, v) -> h.accessor$effects(PotionEffectUtil.copyAsEffectInstances(v))) .create(Keys.REAPPLICATION_DELAY) .get(h -> new SpongeTicks(h.accessor$reapplicationDelay())) - .set((h, v) -> h.accessor$reapplicationDelay((int) v.getTicks())); + .set((h, v) -> h.accessor$reapplicationDelay((int) v.ticks())); } // @formatter:on } diff --git a/src/main/java/org/spongepowered/common/data/provider/entity/ArmorStandData.java b/src/main/java/org/spongepowered/common/data/provider/entity/ArmorStandData.java index e3854690bb7..718590d2824 100644 --- a/src/main/java/org/spongepowered/common/data/provider/entity/ArmorStandData.java +++ b/src/main/java/org/spongepowered/common/data/provider/entity/ArmorStandData.java @@ -89,7 +89,7 @@ public static void register(final DataProviderRegistrator registrator) { .get(h -> VecHelper.toVector3d(h.getHeadPose())) .set((h, v) -> h.setHeadPose(VecHelper.toRotation(v))) .create(Keys.IS_PLACING_DISABLED) - .get(h -> Sponge.getGame().registries().registry(RegistryTypes.EQUIPMENT_TYPE) + .get(h -> Sponge.game().registries().registry(RegistryTypes.EQUIPMENT_TYPE) .streamEntries() .map(RegistryEntry::value) .collect(Collectors.toMap(k -> k, v -> ((ArmorStandAccessor) h).invoker$isDisabled((EquipmentSlot) (Object) v))) diff --git a/src/main/java/org/spongepowered/common/data/provider/entity/ArrowData.java b/src/main/java/org/spongepowered/common/data/provider/entity/ArrowData.java index 7225996a5b9..a2686cadf51 100644 --- a/src/main/java/org/spongepowered/common/data/provider/entity/ArrowData.java +++ b/src/main/java/org/spongepowered/common/data/provider/entity/ArrowData.java @@ -57,8 +57,8 @@ public static void register(final DataProviderRegistrator registrator) { .set((h, v) -> { ((ArrowAccessor) h).accessor$effects().clear(); for (final PotionEffect effect : v) { - final MobEffectInstance mcEffect = new MobEffectInstance(((MobEffectInstance) effect).getEffect(), effect.getDuration(), - effect.getAmplifier(), effect.isAmbient(), effect.showsParticles()); + final MobEffectInstance mcEffect = new MobEffectInstance(((MobEffectInstance) effect).getEffect(), effect.duration(), + effect.amplifier(), effect.isAmbient(), effect.showsParticles()); h.addEffect(mcEffect); } }); diff --git a/src/main/java/org/spongepowered/common/data/provider/entity/BedData.java b/src/main/java/org/spongepowered/common/data/provider/entity/BedData.java index dd863c1d665..7265052a345 100644 --- a/src/main/java/org/spongepowered/common/data/provider/entity/BedData.java +++ b/src/main/java/org/spongepowered/common/data/provider/entity/BedData.java @@ -41,7 +41,7 @@ public static void register(final DataProviderRegistrator registrator) { .get(BedLocationHolderBridge::bridge$getBedlocations) .set(BedLocationHolderBridge::bridge$setBedLocations) .delete(BedLocationHolderBridge::bridge$removeAllBeds); - registrator.spongeDataStore(Keys.RESPAWN_LOCATIONS.getKey(), BedLocationHolderBridge.class, Keys.RESPAWN_LOCATIONS); + registrator.spongeDataStore(Keys.RESPAWN_LOCATIONS.key(), BedLocationHolderBridge.class, Keys.RESPAWN_LOCATIONS); } // @formatter:on } diff --git a/src/main/java/org/spongepowered/common/data/provider/entity/CatData.java b/src/main/java/org/spongepowered/common/data/provider/entity/CatData.java index c344c9d2720..9b8695b83cc 100644 --- a/src/main/java/org/spongepowered/common/data/provider/entity/CatData.java +++ b/src/main/java/org/spongepowered/common/data/provider/entity/CatData.java @@ -46,9 +46,9 @@ public static void register(final DataProviderRegistrator registrator) { .create(Keys.CAT_TYPE) .get(h -> { final int type = h.getCatType(); - return ((MappedRegistry) (Object) Sponge.getGame().registries().registry(RegistryTypes.CAT_TYPE)).byId(type); + return ((MappedRegistry) (Object) Sponge.game().registries().registry(RegistryTypes.CAT_TYPE)).byId(type); }) - .set((h, v) -> h.setCatType(((MappedRegistry) (Object) Sponge.getGame().registries().registry(RegistryTypes.CAT_TYPE)).getId(v))) + .set((h, v) -> h.setCatType(((MappedRegistry) (Object) Sponge.game().registries().registry(RegistryTypes.CAT_TYPE)).getId(v))) .create(Keys.DYE_COLOR) .get(h -> (DyeColor) (Object) h.getCollarColor()) .set((h, v) -> h.setCollarColor((net.minecraft.world.item.DyeColor) (Object) v)) diff --git a/src/main/java/org/spongepowered/common/data/provider/entity/ChickenData.java b/src/main/java/org/spongepowered/common/data/provider/entity/ChickenData.java index d915c8e8301..e5ea302047c 100644 --- a/src/main/java/org/spongepowered/common/data/provider/entity/ChickenData.java +++ b/src/main/java/org/spongepowered/common/data/provider/entity/ChickenData.java @@ -41,7 +41,7 @@ public static void register(final DataProviderRegistrator registrator) { .create(Keys.EGG_TIME) .get(h -> new SpongeTicks(h.eggTime)) .setAnd((h, v) -> { - final int ticks = (int) v.getTicks(); + final int ticks = (int) v.ticks(); if (ticks < 0) { return false; } diff --git a/src/main/java/org/spongepowered/common/data/provider/entity/EndermiteData.java b/src/main/java/org/spongepowered/common/data/provider/entity/EndermiteData.java index b69bb59b8d7..b26ca09500c 100644 --- a/src/main/java/org/spongepowered/common/data/provider/entity/EndermiteData.java +++ b/src/main/java/org/spongepowered/common/data/provider/entity/EndermiteData.java @@ -52,7 +52,7 @@ public static void register(final DataProviderRegistrator registrator) { if (h.isPersistenceRequired()) { return false; } - final int ticks = (int) v.getTicks(); + final int ticks = (int) v.ticks(); if (ticks < 0 || ticks > EndermiteData.DESPAWN_DELAY_MAX) { return false; } diff --git a/src/main/java/org/spongepowered/common/data/provider/entity/EntityData.java b/src/main/java/org/spongepowered/common/data/provider/entity/EntityData.java index 1a3ca46c9d5..71614af325a 100644 --- a/src/main/java/org/spongepowered/common/data/provider/entity/EntityData.java +++ b/src/main/java/org/spongepowered/common/data/provider/entity/EntityData.java @@ -90,7 +90,7 @@ public static void register(final DataProviderRegistrator registrator) { .create(Keys.FIRE_DAMAGE_DELAY) .get(h -> new SpongeTicks(((EntityAccessor) h).invoker$getFireImmuneTicks())) .setAnd((h, v) -> { - final int ticks = (int) v.getTicks(); + final int ticks = (int) v.ticks(); if (ticks < 1 || ticks > Short.MAX_VALUE) { return false; } @@ -100,7 +100,7 @@ public static void register(final DataProviderRegistrator registrator) { .create(Keys.FIRE_TICKS) .get(h -> ((EntityAccessor) h).accessor$remainingFireTicks() > 0 ? Ticks.of(((EntityAccessor) h).accessor$remainingFireTicks()) : null) .set((h, v) -> { - final int ticks = (int) v.getTicks(); + final int ticks = (int) v.ticks(); ((EntityAccessor) h).accessor$remainingFireTicks(Math.max(ticks, Constants.Entity.MINIMUM_FIRE_TICKS)); }) .deleteAndGet(h -> { @@ -121,7 +121,7 @@ public static void register(final DataProviderRegistrator registrator) { .create(Keys.INVULNERABILITY_TICKS) .get(h -> new SpongeTicks(h.invulnerableTime)) .setAnd((h, v) -> { - final int ticks = (int) v.getTicks(); + final int ticks = (int) v.ticks(); if (ticks < 0) { return false; } diff --git a/src/main/java/org/spongepowered/common/data/provider/entity/EyeOfEnderData.java b/src/main/java/org/spongepowered/common/data/provider/entity/EyeOfEnderData.java index 76f54ff2b7a..0c2b6a1a60c 100644 --- a/src/main/java/org/spongepowered/common/data/provider/entity/EyeOfEnderData.java +++ b/src/main/java/org/spongepowered/common/data/provider/entity/EyeOfEnderData.java @@ -44,7 +44,7 @@ public static void register(final DataProviderRegistrator registrator) { .set((h, v) -> h.accessor$surviveAfterDeath(!v)) .create(Keys.DESPAWN_DELAY) .get(h -> new SpongeTicks(Constants.Sponge.Entity.EyeOfEnder.DESPAWN_TIMER_MAX - h.accessor$life())) - .set((h, v) -> h.accessor$life(Constants.Sponge.Entity.EyeOfEnder.DESPAWN_TIMER_MAX - (int) v.getTicks())); + .set((h, v) -> h.accessor$life(Constants.Sponge.Entity.EyeOfEnder.DESPAWN_TIMER_MAX - (int) v.ticks())); } // @formatter:on } diff --git a/src/main/java/org/spongepowered/common/data/provider/entity/FallingBlockData.java b/src/main/java/org/spongepowered/common/data/provider/entity/FallingBlockData.java index 89440671bc3..551d0a5c600 100644 --- a/src/main/java/org/spongepowered/common/data/provider/entity/FallingBlockData.java +++ b/src/main/java/org/spongepowered/common/data/provider/entity/FallingBlockData.java @@ -59,7 +59,7 @@ public static void register(final DataProviderRegistrator registrator) { .create(Keys.FALL_TIME) .get(x -> new SpongeTicks(x.accessor$time())) .setAnd((h, v) -> { - final int ticks = (int) v.getTicks(); + final int ticks = (int) v.ticks(); if (ticks < 0) { return false; } diff --git a/src/main/java/org/spongepowered/common/data/provider/entity/FireworkRocketData.java b/src/main/java/org/spongepowered/common/data/provider/entity/FireworkRocketData.java index c48f6150d02..44746942f05 100644 --- a/src/main/java/org/spongepowered/common/data/provider/entity/FireworkRocketData.java +++ b/src/main/java/org/spongepowered/common/data/provider/entity/FireworkRocketData.java @@ -59,7 +59,7 @@ public static void register(final DataProviderRegistrator registrator) { return null; }) .setAnd((h, v) -> { - final int ticks = (int) v.getTicks(); + final int ticks = (int) v.ticks(); if (ticks < 0 || ticks > Byte.MAX_VALUE) { return false; } diff --git a/src/main/java/org/spongepowered/common/data/provider/entity/FusedExplosiveData.java b/src/main/java/org/spongepowered/common/data/provider/entity/FusedExplosiveData.java index 174e974b2d3..0c702a3e3b7 100644 --- a/src/main/java/org/spongepowered/common/data/provider/entity/FusedExplosiveData.java +++ b/src/main/java/org/spongepowered/common/data/provider/entity/FusedExplosiveData.java @@ -42,7 +42,7 @@ public static void register(final DataProviderRegistrator registrator) { .create(Keys.FUSE_DURATION) .get(h -> new SpongeTicks(((FusedExplosiveBridge) h).bridge$getFuseDuration())) .setAnd((h, v) -> { - final int ticks = (int) v.getTicks(); + final int ticks = (int) v.ticks(); if (ticks < 0) { return false; } @@ -52,7 +52,7 @@ public static void register(final DataProviderRegistrator registrator) { .create(Keys.TICKS_REMAINING) .get(h -> new SpongeTicks(((FusedExplosiveBridge) h).bridge$getFuseTicksRemaining())) .setAnd((h, v) -> { - final int ticks = (int) v.getTicks(); + final int ticks = (int) v.ticks(); if (ticks < 0) { return false; } diff --git a/src/main/java/org/spongepowered/common/data/provider/entity/GrieferData.java b/src/main/java/org/spongepowered/common/data/provider/entity/GrieferData.java index 0a082efe6b7..8dd16f0b6a6 100644 --- a/src/main/java/org/spongepowered/common/data/provider/entity/GrieferData.java +++ b/src/main/java/org/spongepowered/common/data/provider/entity/GrieferData.java @@ -47,8 +47,8 @@ public static void register(final DataProviderRegistrator registrator) { .get(GrieferBridge::bridge$canGrief) .set(GrieferBridge::bridge$setCanGrief) .supports(GrieferBridge::bridge$isGriefer); - registrator.spongeDataStore(Keys.CAN_GRIEF.getKey(), 2, new DataContentUpdater[]{GrieferData.CAN_GRIEF_UPDATER_BYTE_TO_BOOL_FIX}, GrieferBridge.class, Keys.CAN_GRIEF); - SpongeDataManager.INSTANCE.registerLegacySpongeData(Constants.Sponge.Entity.CAN_GRIEF, Keys.CAN_GRIEF.getKey(), Keys.CAN_GRIEF); + registrator.spongeDataStore(Keys.CAN_GRIEF.key(), 2, new DataContentUpdater[]{GrieferData.CAN_GRIEF_UPDATER_BYTE_TO_BOOL_FIX}, GrieferBridge.class, Keys.CAN_GRIEF); + SpongeDataManager.INSTANCE.registerLegacySpongeData(Constants.Sponge.Entity.CAN_GRIEF, Keys.CAN_GRIEF.key(), Keys.CAN_GRIEF); } // @formatter:on } diff --git a/src/main/java/org/spongepowered/common/data/provider/entity/HorseData.java b/src/main/java/org/spongepowered/common/data/provider/entity/HorseData.java index b2b44ca153a..f9bc900c95c 100644 --- a/src/main/java/org/spongepowered/common/data/provider/entity/HorseData.java +++ b/src/main/java/org/spongepowered/common/data/provider/entity/HorseData.java @@ -45,23 +45,23 @@ public static void register(final DataProviderRegistrator registrator) { .asMutable(Horse.class) .create(Keys.HORSE_COLOR) .get(h -> { - final MappedRegistry registry = (MappedRegistry) (Object) Sponge.getGame().registries().registry(RegistryTypes.HORSE_COLOR); + final MappedRegistry registry = (MappedRegistry) (Object) Sponge.game().registries().registry(RegistryTypes.HORSE_COLOR); return registry.byId(HorseData.getHorseColor(h)); }) .set((h, v) -> { final int style = HorseData.getHorseStyle(h); - final MappedRegistry registry = (MappedRegistry) (Object) Sponge.getGame().registries().registry(RegistryTypes.HORSE_COLOR); + final MappedRegistry registry = (MappedRegistry) (Object) Sponge.game().registries().registry(RegistryTypes.HORSE_COLOR); final int metadata = registry.getId(v); ((HorseAccessor) h).invoker$setTypeVariant(metadata | style); }) .create(Keys.HORSE_STYLE) .get(h -> { - final MappedRegistry registry = (MappedRegistry) (Object) Sponge.getGame().registries().registry(RegistryTypes.HORSE_STYLE); + final MappedRegistry registry = (MappedRegistry) (Object) Sponge.game().registries().registry(RegistryTypes.HORSE_STYLE); return registry.byId(HorseData.getHorseStyle(h)); }) .set((h, v) -> { final int color = HorseData.getHorseColor(h); - final MappedRegistry registry = (MappedRegistry) (Object) Sponge.getGame().registries().registry(RegistryTypes.HORSE_STYLE); + final MappedRegistry registry = (MappedRegistry) (Object) Sponge.game().registries().registry(RegistryTypes.HORSE_STYLE); final int metadata = registry.getId(v); ((HorseAccessor) h).invoker$setTypeVariant((color | (metadata << 8))); }); diff --git a/src/main/java/org/spongepowered/common/data/provider/entity/IdentifiableData.java b/src/main/java/org/spongepowered/common/data/provider/entity/IdentifiableData.java index 63b55338c4b..1c42e70a816 100644 --- a/src/main/java/org/spongepowered/common/data/provider/entity/IdentifiableData.java +++ b/src/main/java/org/spongepowered/common/data/provider/entity/IdentifiableData.java @@ -45,19 +45,19 @@ public static void register(final DataProviderRegistrator registrator) { registrator .asMutable(Identifiable.class) .create(Keys.FIRST_DATE_JOINED) - .get(h -> ((SpongeServer) Sponge.getServer()).getPlayerDataManager().getFirstJoined(h.getUniqueId()).orElse(null)) + .get(h -> ((SpongeServer) Sponge.server()).getPlayerDataManager().getFirstJoined(h.uniqueId()).orElse(null)) .set((h, v) -> { - final UUID id = h.getUniqueId(); - final Instant played = ((SpongeServer) Sponge.getServer()).getPlayerDataManager().getFirstJoined(id).orElse(v); - ((SpongeServer) Sponge.getServer()).getPlayerDataManager().setPlayerInfo(id, played, v); + final UUID id = h.uniqueId(); + final Instant played = ((SpongeServer) Sponge.server()).getPlayerDataManager().getFirstJoined(id).orElse(v); + ((SpongeServer) Sponge.server()).getPlayerDataManager().setPlayerInfo(id, played, v); }) .supports(h -> h instanceof Player || h instanceof SpongeUser) .create(Keys.LAST_DATE_PLAYED) - .get(h -> ((SpongeServer) Sponge.getServer()).getPlayerDataManager().getLastPlayed(h.getUniqueId()).orElse(null)) + .get(h -> ((SpongeServer) Sponge.server()).getPlayerDataManager().getLastPlayed(h.uniqueId()).orElse(null)) .set((h, v) -> { - final UUID id = h.getUniqueId(); - final Instant played = ((SpongeServer) Sponge.getServer()).getPlayerDataManager().getFirstJoined(id).orElse(v); - ((SpongeServer) Sponge.getServer()).getPlayerDataManager().setPlayerInfo(id, played, v); + final UUID id = h.uniqueId(); + final Instant played = ((SpongeServer) Sponge.server()).getPlayerDataManager().getFirstJoined(id).orElse(v); + ((SpongeServer) Sponge.server()).getPlayerDataManager().setPlayerInfo(id, played, v); }) .supports(h -> h instanceof Player || h instanceof SpongeUser); } diff --git a/src/main/java/org/spongepowered/common/data/provider/entity/ItemData.java b/src/main/java/org/spongepowered/common/data/provider/entity/ItemData.java index aee5b6280d7..e4cd6e3bb62 100644 --- a/src/main/java/org/spongepowered/common/data/provider/entity/ItemData.java +++ b/src/main/java/org/spongepowered/common/data/provider/entity/ItemData.java @@ -60,7 +60,7 @@ public static void register(final DataProviderRegistrator registrator) { .create(Keys.DESPAWN_DELAY) .get(h -> new SpongeTicks(h.bridge$getDespawnDelay())) .setAnd((h, v) -> { - final int ticks = (int) v.getTicks(); + final int ticks = (int) v.ticks(); if (ticks < 0) { return false; } @@ -75,7 +75,7 @@ public static void register(final DataProviderRegistrator registrator) { .set((h, v) -> h.bridge$setPickupDelay(h.bridge$getPickupDelay(), v)) .create(Keys.PICKUP_DELAY) .get(h -> new SpongeTicks(h.bridge$getPickupDelay())) - .set((h, v) -> h.bridge$setPickupDelay((int) v.getTicks(), false)) + .set((h, v) -> h.bridge$setPickupDelay((int) v.ticks(), false)) // Only for internal use .create(ItemData.PREVIOUS_PICKUP_DELAY) .get(v -> -1) diff --git a/src/main/java/org/spongepowered/common/data/provider/entity/ItemFrameData.java b/src/main/java/org/spongepowered/common/data/provider/entity/ItemFrameData.java index 19adbdb8853..604043e1e6c 100644 --- a/src/main/java/org/spongepowered/common/data/provider/entity/ItemFrameData.java +++ b/src/main/java/org/spongepowered/common/data/provider/entity/ItemFrameData.java @@ -44,7 +44,7 @@ public static void register(final DataProviderRegistrator registrator) { .set((h, v) -> h.setItem(ItemStackUtil.fromSnapshotToNative(v))) .create(Keys.ORIENTATION) .get(h -> Orientation.fromDegrees(h.getRotation() * 45).orElse(null)) - .set((h, v) -> h.setRotation(v.getAngle() / 45)); + .set((h, v) -> h.setRotation(v.angle() / 45)); } // @formatter:on } diff --git a/src/main/java/org/spongepowered/common/data/provider/entity/LightningBoltData.java b/src/main/java/org/spongepowered/common/data/provider/entity/LightningBoltData.java index 35b721625a0..b5a718428ec 100644 --- a/src/main/java/org/spongepowered/common/data/provider/entity/LightningBoltData.java +++ b/src/main/java/org/spongepowered/common/data/provider/entity/LightningBoltData.java @@ -41,10 +41,10 @@ public static void register(final DataProviderRegistrator registrator) { .create(Keys.DESPAWN_DELAY) .get(x -> new SpongeTicks(x.accessor$life())) .setAnd((h, v) -> { - if (v.getTicks() < 0) { + if (v.ticks() < 0) { return false; } - h.accessor$life((int) v.getTicks()); + h.accessor$life((int) v.ticks()); return true; }) .create(Keys.IS_EFFECT_ONLY) diff --git a/src/main/java/org/spongepowered/common/data/provider/entity/PandaData.java b/src/main/java/org/spongepowered/common/data/provider/entity/PandaData.java index fcb684eabfd..446829a0004 100644 --- a/src/main/java/org/spongepowered/common/data/provider/entity/PandaData.java +++ b/src/main/java/org/spongepowered/common/data/provider/entity/PandaData.java @@ -64,14 +64,14 @@ public static void register(final DataProviderRegistrator registrator) { .set((h, v) -> h.setMainGene((Panda.Gene) (Object) v)) .create(Keys.SNEEZING_TIME) .get(x -> new SpongeTicks(x.getSneezeCounter())) - .set((h, v) -> h.setSneezeCounter((int) v.getTicks())) + .set((h, v) -> h.setSneezeCounter((int) v.ticks())) .create(Keys.UNHAPPY_TIME) .get(x -> new SpongeTicks(x.getUnhappyCounter())) - .set((h, v) -> h.setUnhappyCounter((int) v.getTicks())) + .set((h, v) -> h.setUnhappyCounter((int) v.ticks())) .asMutable(PandaAccessor.class) .create(Keys.EATING_TIME) .get(x -> new SpongeTicks(x.invoker$getEatCounter())) - .set((h, v) -> h.invoker$setEatCounter((int) v.getTicks())); + .set((h, v) -> h.invoker$setEatCounter((int) v.ticks())); } // @formatter:on } diff --git a/src/main/java/org/spongepowered/common/data/provider/entity/ParrotData.java b/src/main/java/org/spongepowered/common/data/provider/entity/ParrotData.java index fade62e6f19..7ac167bf731 100644 --- a/src/main/java/org/spongepowered/common/data/provider/entity/ParrotData.java +++ b/src/main/java/org/spongepowered/common/data/provider/entity/ParrotData.java @@ -44,11 +44,11 @@ public static void register(final DataProviderRegistrator registrator) { .create(Keys.PARROT_TYPE) .get(h -> { final int type = h.getVariant(); - final MappedRegistry registry = (MappedRegistry) (Object) Sponge.getGame().registries().registry(RegistryTypes.PARROT_TYPE); + final MappedRegistry registry = (MappedRegistry) (Object) Sponge.game().registries().registry(RegistryTypes.PARROT_TYPE); return registry.byId(type); }) .set((h, v) -> { - final MappedRegistry registry = (MappedRegistry) (Object) Sponge.getGame().registries().registry(RegistryTypes.PARROT_TYPE); + final MappedRegistry registry = (MappedRegistry) (Object) Sponge.game().registries().registry(RegistryTypes.PARROT_TYPE); h.setVariant(registry.getId(v)); }); } diff --git a/src/main/java/org/spongepowered/common/data/provider/entity/RabbitData.java b/src/main/java/org/spongepowered/common/data/provider/entity/RabbitData.java index 8a801b09a70..2fbea2bfb4e 100644 --- a/src/main/java/org/spongepowered/common/data/provider/entity/RabbitData.java +++ b/src/main/java/org/spongepowered/common/data/provider/entity/RabbitData.java @@ -44,11 +44,11 @@ public static void register(final DataProviderRegistrator registrator) { .create(Keys.RABBIT_TYPE) .get(h -> { final int type = h.getRabbitType(); - final MappedRegistry registry = (MappedRegistry) (Object) Sponge.getGame().registries().registry(RegistryTypes.RABBIT_TYPE); + final MappedRegistry registry = (MappedRegistry) (Object) Sponge.game().registries().registry(RegistryTypes.RABBIT_TYPE); return registry.byId(type); }) .set((h, v) -> { - final MappedRegistry registry = (MappedRegistry) (Object) Sponge.getGame().registries().registry(RegistryTypes.RABBIT_TYPE); + final MappedRegistry registry = (MappedRegistry) (Object) Sponge.game().registries().registry(RegistryTypes.RABBIT_TYPE); h.setRabbitType(registry.getId(v)); }); } diff --git a/src/main/java/org/spongepowered/common/data/provider/entity/RavagerData.java b/src/main/java/org/spongepowered/common/data/provider/entity/RavagerData.java index 4b202774d1a..df993511c90 100644 --- a/src/main/java/org/spongepowered/common/data/provider/entity/RavagerData.java +++ b/src/main/java/org/spongepowered/common/data/provider/entity/RavagerData.java @@ -40,7 +40,7 @@ public static void register(final DataProviderRegistrator registrator) { .asMutable(RavagerAccessor.class) .create(Keys.ATTACK_TIME) .get(x -> new SpongeTicks(x.accessor$attackTick())) - .set((h, v) -> h.accessor$attackTick((int) v.getTicks())) + .set((h, v) -> h.accessor$attackTick((int) v.ticks())) .create(Keys.IS_IMMOBILIZED) .get(h -> h.accessor$attackTick() > 0 || h.accessor$stunnedTick() > 0 || h.accessor$roarTick() > 0) .create(Keys.IS_ROARING) @@ -49,10 +49,10 @@ public static void register(final DataProviderRegistrator registrator) { .get(h -> h.accessor$stunnedTick() > 0) .create(Keys.ROARING_TIME) .get(x -> new SpongeTicks(x.accessor$roarTick())) - .set((h, v) -> h.accessor$roarTick((int) v.getTicks())) + .set((h, v) -> h.accessor$roarTick((int) v.ticks())) .create(Keys.STUNNED_TIME) .get(x -> new SpongeTicks(x.accessor$stunnedTick())) - .set((h, v) -> h.accessor$stunnedTick((int) v.getTicks())); + .set((h, v) -> h.accessor$stunnedTick((int) v.ticks())); } // @formatter:on } diff --git a/src/main/java/org/spongepowered/common/data/provider/entity/ServerPlayerData.java b/src/main/java/org/spongepowered/common/data/provider/entity/ServerPlayerData.java index ea76731980e..53d38abe062 100644 --- a/src/main/java/org/spongepowered/common/data/provider/entity/ServerPlayerData.java +++ b/src/main/java/org/spongepowered/common/data/provider/entity/ServerPlayerData.java @@ -99,8 +99,8 @@ public static void register(final DataProviderRegistrator registrator) { .create(Keys.SKIN_PARTS) .get(ServerPlayerBridge::bridge$getSkinParts); - registrator.spongeDataStore(Keys.HEALTH_SCALE.getKey(), ServerPlayerEntityHealthScaleBridge.class, Keys.HEALTH_SCALE); - SpongeDataManager.INSTANCE.registerLegacySpongeData(Constants.Sponge.Entity.Player.HEALTH_SCALE, Keys.HEALTH_SCALE.getKey(), Keys.HEALTH_SCALE); + registrator.spongeDataStore(Keys.HEALTH_SCALE.key(), ServerPlayerEntityHealthScaleBridge.class, Keys.HEALTH_SCALE); + SpongeDataManager.INSTANCE.registerLegacySpongeData(Constants.Sponge.Entity.Player.HEALTH_SCALE, Keys.HEALTH_SCALE.key(), Keys.HEALTH_SCALE); } // @formatter:on } diff --git a/src/main/java/org/spongepowered/common/data/provider/entity/TraderLlamaData.java b/src/main/java/org/spongepowered/common/data/provider/entity/TraderLlamaData.java index 8796099f60b..2f8573c4128 100644 --- a/src/main/java/org/spongepowered/common/data/provider/entity/TraderLlamaData.java +++ b/src/main/java/org/spongepowered/common/data/provider/entity/TraderLlamaData.java @@ -41,10 +41,10 @@ public static void register(final DataProviderRegistrator registrator) { .create(Keys.DESPAWN_DELAY) .get(x -> Ticks.of(x.accessor$despawnDelay())) .setAnd((h, v) -> { - if (v.getTicks() < 0) { + if (v.ticks() < 0) { return false; } - h.accessor$despawnDelay((int) v.getTicks()); + h.accessor$despawnDelay((int) v.ticks()); return true; }); } diff --git a/src/main/java/org/spongepowered/common/data/provider/entity/VexData.java b/src/main/java/org/spongepowered/common/data/provider/entity/VexData.java index c1e031d6879..79b45b36569 100644 --- a/src/main/java/org/spongepowered/common/data/provider/entity/VexData.java +++ b/src/main/java/org/spongepowered/common/data/provider/entity/VexData.java @@ -41,7 +41,7 @@ public static void register(final DataProviderRegistrator registrator) { .asMutable(Vex.class) .create(Keys.LIFE_TICKS) .get(h -> Ticks.of(((VexAccessor) h).accessor$limitedLifeTicks())) - .set((h, v) -> h.setLimitedLife((int) v.getTicks())); + .set((h, v) -> h.setLimitedLife((int) v.ticks())); } // @formatter:on } diff --git a/src/main/java/org/spongepowered/common/data/provider/inventory/InventoryData.java b/src/main/java/org/spongepowered/common/data/provider/inventory/InventoryData.java index f49bc9706d4..3141096f44c 100644 --- a/src/main/java/org/spongepowered/common/data/provider/inventory/InventoryData.java +++ b/src/main/java/org/spongepowered/common/data/provider/inventory/InventoryData.java @@ -62,7 +62,7 @@ public static void register(final DataProviderRegistrator registrator) { private static Component findDisplayName(Inventory inventory) { if (inventory instanceof Container) { - for (Inventory viewed : ((Container) inventory).getViewed()) { + for (Inventory viewed : ((Container) inventory).viewed()) { inventory = viewed; break; } diff --git a/src/main/java/org/spongepowered/common/data/provider/item/stack/BookPagesItemStackData.java b/src/main/java/org/spongepowered/common/data/provider/item/stack/BookPagesItemStackData.java index f641a32e3cd..19ede827a96 100644 --- a/src/main/java/org/spongepowered/common/data/provider/item/stack/BookPagesItemStackData.java +++ b/src/main/java/org/spongepowered/common/data/provider/item/stack/BookPagesItemStackData.java @@ -62,7 +62,7 @@ public static void register(final DataProviderRegistrator registrator) { .asMutable(ItemStack.class) .create(Keys.APPLIED_ENCHANTMENTS) .get(h -> BookPagesItemStackData.get(h, BookPagesItemStackData.NBTKeyAppliedEnchantments)) - .set((h, v) -> BookPagesItemStackData.set(h, v, iv -> iv.stream().filter(Predicates.distinctBy(Enchantment::getType)), BookPagesItemStackData.NBTKeyAppliedEnchantments)) + .set((h, v) -> BookPagesItemStackData.set(h, v, iv -> iv.stream().filter(Predicates.distinctBy(Enchantment::type)), BookPagesItemStackData.NBTKeyAppliedEnchantments)) .delete(h -> BookPagesItemStackData.delete(h, BookPagesItemStackData.NBTKeyAppliedEnchantments)) .create(Keys.STORED_ENCHANTMENTS) .get(h -> BookPagesItemStackData.get(h, BookPagesItemStackData.NBTKeyStoredEnchantments)) @@ -114,9 +114,9 @@ private static Enchantment enchantmentFromNbt(final CompoundTag compound) { private static CompoundTag enchantmentToNbt(final Enchantment enchantment) { final CompoundTag compound = new CompoundTag(); - final String enchantmentId = String.valueOf(Registry.ENCHANTMENT.getKey((net.minecraft.world.item.enchantment.Enchantment) enchantment.getType())); + final String enchantmentId = String.valueOf(Registry.ENCHANTMENT.getKey((net.minecraft.world.item.enchantment.Enchantment) enchantment.type())); compound.putString(Constants.Item.ITEM_ENCHANTMENT_ID, enchantmentId); - compound.putShort(Constants.Item.ITEM_ENCHANTMENT_LEVEL, (short) ((byte) enchantment.getLevel())); + compound.putShort(Constants.Item.ITEM_ENCHANTMENT_LEVEL, (short) ((byte) enchantment.level())); return compound; } } diff --git a/src/main/java/org/spongepowered/common/data/provider/item/stack/CompassItemData.java b/src/main/java/org/spongepowered/common/data/provider/item/stack/CompassItemData.java index 4c6702e3e58..569d4b3c01c 100644 --- a/src/main/java/org/spongepowered/common/data/provider/item/stack/CompassItemData.java +++ b/src/main/java/org/spongepowered/common/data/provider/item/stack/CompassItemData.java @@ -64,7 +64,7 @@ static void register(final DataProviderRegistrator registrator) { .set((stack, location) -> { final CompoundTag tag = stack.getOrCreateTag(); tag.put("LodestonePos", NbtUtils.writeBlockPos(VecHelper.toBlockPos(location))); - Level.RESOURCE_KEY_CODEC.encodeStart(NbtOps.INSTANCE, ((net.minecraft.server.level.ServerLevel) location.getWorld()).dimension()) + Level.RESOURCE_KEY_CODEC.encodeStart(NbtOps.INSTANCE, ((net.minecraft.server.level.ServerLevel) location.world()).dimension()) .resultOrPartial(SpongeCommon.getLogger()::error).ifPresent(dimension -> tag.put("LodestoneDimension", dimension)); tag.putBoolean("LodestoneTracked", true); }) diff --git a/src/main/java/org/spongepowered/common/data/provider/item/stack/IDyeableArmorItemStackData.java b/src/main/java/org/spongepowered/common/data/provider/item/stack/IDyeableArmorItemStackData.java index 36e89fbeeda..4e0a6eb6e9a 100644 --- a/src/main/java/org/spongepowered/common/data/provider/item/stack/IDyeableArmorItemStackData.java +++ b/src/main/java/org/spongepowered/common/data/provider/item/stack/IDyeableArmorItemStackData.java @@ -49,7 +49,7 @@ public static void register(final DataProviderRegistrator registrator) { if (v == null) { item.clearColor(h); } else { - item.setColor(h, (((v.getRed() << 8) + v.getGreen()) << 8) + v.getBlue()); + item.setColor(h, (((v.red() << 8) + v.green()) << 8) + v.blue()); } }) .delete(h -> ((DyeableLeatherItem) h.getItem()).clearColor(h)) diff --git a/src/main/java/org/spongepowered/common/data/provider/item/stack/MapInfoItemStackData.java b/src/main/java/org/spongepowered/common/data/provider/item/stack/MapInfoItemStackData.java index 1bfa36a90fb..acbe9f57a97 100644 --- a/src/main/java/org/spongepowered/common/data/provider/item/stack/MapInfoItemStackData.java +++ b/src/main/java/org/spongepowered/common/data/provider/item/stack/MapInfoItemStackData.java @@ -52,7 +52,7 @@ public static void register(final DataProviderRegistrator registrator) { if (itemStack.getTag() == null) { return null; } - return (MapInfo) ((Level)Sponge.getServer().getWorldManager().defaultWorld()) + return (MapInfo) ((Level)Sponge.server().worldManager().defaultWorld()) .getMapData(Constants.Map.MAP_PREFIX + itemStack.getTag().getInt(Constants.Map.MAP_ID)); }) // Nullable .set((itemStack, mapInfo) -> { diff --git a/src/main/java/org/spongepowered/common/data/provider/item/stack/PotionItemStackData.java b/src/main/java/org/spongepowered/common/data/provider/item/stack/PotionItemStackData.java index 669ccd36aad..748ac1a02cf 100644 --- a/src/main/java/org/spongepowered/common/data/provider/item/stack/PotionItemStackData.java +++ b/src/main/java/org/spongepowered/common/data/provider/item/stack/PotionItemStackData.java @@ -57,7 +57,7 @@ public static void register(final DataProviderRegistrator registrator) { .get(h -> Color.ofRgb(PotionUtils.getColor(h))) .set((h, v) -> { final CompoundTag tag = h.getOrCreateTag(); - tag.putInt(Constants.Item.CUSTOM_POTION_COLOR, v.getRgb()); + tag.putInt(Constants.Item.CUSTOM_POTION_COLOR, v.rgb()); }) .delete(h -> h.removeTagKey(Constants.Item.CUSTOM_POTION_COLOR)) .supports(h -> h.getItem() == Items.POTION || h.getItem() == Items.SPLASH_POTION || h.getItem() == Items.LINGERING_POTION) diff --git a/src/main/java/org/spongepowered/common/data/provider/item/stack/ShieldItemStackData.java b/src/main/java/org/spongepowered/common/data/provider/item/stack/ShieldItemStackData.java index 64bcce428c8..3bae0742f44 100644 --- a/src/main/java/org/spongepowered/common/data/provider/item/stack/ShieldItemStackData.java +++ b/src/main/java/org/spongepowered/common/data/provider/item/stack/ShieldItemStackData.java @@ -89,15 +89,15 @@ public static void register(final DataProviderRegistrator registrator) { }) .set((h, v) -> { final ListTag layersTag = v.stream() - .filter(layer -> layer.getShape() != BannerPatternShapes.BASE.get()) + .filter(layer -> layer.shape() != BannerPatternShapes.BASE.get()) .map(ShieldItemStackData::layerToNbt) .collect(NBTCollectors.toTagList()); final CompoundTag blockEntity = h.getOrCreateTagElement(Constants.Item.BLOCK_ENTITY_TAG); blockEntity.put(Constants.TileEntity.Banner.BANNER_PATTERNS, layersTag); if (h.getItem() instanceof ShieldItem) { // TODO reject BannerPatternShapes.BASE for BannerItem? - v.stream().filter(layer -> layer.getShape() == BannerPatternShapes.BASE.get()).forEach(layer -> { - blockEntity.putInt(Constants.TileEntity.Banner.BANNER_BASE, ((net.minecraft.world.item.DyeColor) (Object) layer.getColor()).getId()); + v.stream().filter(layer -> layer.shape() == BannerPatternShapes.BASE.get()).forEach(layer -> { + blockEntity.putInt(Constants.TileEntity.Banner.BANNER_BASE, ((net.minecraft.world.item.DyeColor) (Object) layer.color()).getId()); }); } }) @@ -113,8 +113,8 @@ public static BannerPatternLayer layerFromNbt(final CompoundTag nbt) { public static CompoundTag layerToNbt(final BannerPatternLayer layer) { final CompoundTag nbt = new CompoundTag(); - nbt.putString(Constants.TileEntity.Banner.BANNER_PATTERN_ID, ((BannerPattern) (Object) layer.getShape()).getHashname()); - nbt.putInt(Constants.TileEntity.Banner.BANNER_PATTERN_COLOR, ((net.minecraft.world.item.DyeColor) (Object) layer.getColor()).getId()); + nbt.putString(Constants.TileEntity.Banner.BANNER_PATTERN_ID, ((BannerPattern) (Object) layer.shape()).getHashname()); + nbt.putInt(Constants.TileEntity.Banner.BANNER_PATTERN_COLOR, ((net.minecraft.world.item.DyeColor) (Object) layer.color()).getId()); return nbt; } } diff --git a/src/main/java/org/spongepowered/common/data/provider/map/MapInfoData.java b/src/main/java/org/spongepowered/common/data/provider/map/MapInfoData.java index 2069eb2fab0..03fd724a80d 100644 --- a/src/main/java/org/spongepowered/common/data/provider/map/MapInfoData.java +++ b/src/main/java/org/spongepowered/common/data/provider/map/MapInfoData.java @@ -30,26 +30,13 @@ import org.spongepowered.api.ResourceKey; import org.spongepowered.api.Sponge; import org.spongepowered.api.data.Keys; -import org.spongepowered.api.data.persistence.DataQuery; -import org.spongepowered.api.data.persistence.DataView; import org.spongepowered.api.map.MapInfo; -import org.spongepowered.api.map.decoration.MapDecoration; -import org.spongepowered.common.adventure.SpongeAdventure; import org.spongepowered.common.bridge.world.storage.MapItemSavedDataBridge; import org.spongepowered.common.data.provider.DataProviderRegistrator; -import org.spongepowered.common.entity.SpongeEntityArchetype; -import org.spongepowered.common.entity.SpongeEntitySnapshot; import org.spongepowered.common.map.canvas.SpongeMapByteCanvas; import org.spongepowered.common.map.canvas.SpongeMapCanvas; -import org.spongepowered.common.util.Constants; import org.spongepowered.math.vector.Vector2i; -import java.util.Collections; -import java.util.List; -import java.util.Optional; -import java.util.Set; -import java.util.stream.Collectors; - public final class MapInfoData { private MapInfoData() { @@ -99,14 +86,14 @@ public static void register(final DataProviderRegistrator registrator) { .get(mapData -> { final int id = ((MapItemSavedDataBridge)mapData).bridge$getMapId(); if (mapData.dimension == null) { - LogManager.getLogger().error("Map with id: {}, uuid: {} has an null world. This will probably cause more errors later/on save", id, ((MapInfo)mapData).getUniqueId()); + LogManager.getLogger().error("Map with id: {}, uuid: {} has an null world. This will probably cause more errors later/on save", id, ((MapInfo)mapData).uniqueId()); return null; } return (ResourceKey) (Object) mapData.dimension.location(); }) .set((mapData, key) -> { - mapData.dimension = ((Level) Sponge.getServer().getWorldManager().world(key).get()).dimension(); + mapData.dimension = ((Level) Sponge.server().worldManager().world(key).get()).dimension(); mapData.setDirty(); }) .asMutable(MapItemSavedDataBridge.class) diff --git a/src/main/java/org/spongepowered/common/data/type/SpongeNotePitch.java b/src/main/java/org/spongepowered/common/data/type/SpongeNotePitch.java index f6da3cef159..f1dd5e6a74d 100644 --- a/src/main/java/org/spongepowered/common/data/type/SpongeNotePitch.java +++ b/src/main/java/org/spongepowered/common/data/type/SpongeNotePitch.java @@ -34,7 +34,7 @@ public final class SpongeNotePitch implements NotePitch { @Override public NotePitch cycleNext() { - final MappedRegistry registry = (MappedRegistry) (Object) Sponge.getGame().registries().registry(RegistryTypes.NOTE_PITCH); + final MappedRegistry registry = (MappedRegistry) (Object) Sponge.game().registries().registry(RegistryTypes.NOTE_PITCH); final int value = registry.getId(this) + 1; NotePitch next = registry.byId(value); if (next == null) { diff --git a/src/main/java/org/spongepowered/common/data/type/SpongeSkinPart.java b/src/main/java/org/spongepowered/common/data/type/SpongeSkinPart.java index 25db996f354..df7d5c858d4 100644 --- a/src/main/java/org/spongepowered/common/data/type/SpongeSkinPart.java +++ b/src/main/java/org/spongepowered/common/data/type/SpongeSkinPart.java @@ -48,7 +48,7 @@ public boolean test(final int flags) { } public int getMask() { - final MappedRegistry registry = (MappedRegistry) (Object) Sponge.getGame().registries().registry(RegistryTypes.SKIN_PART); + final MappedRegistry registry = (MappedRegistry) (Object) Sponge.game().registries().registry(RegistryTypes.SKIN_PART); return 1 << registry.getId(this); } } diff --git a/src/main/java/org/spongepowered/common/data/value/ImmutableSpongeCollectionValue.java b/src/main/java/org/spongepowered/common/data/value/ImmutableSpongeCollectionValue.java index 223dc54e61b..a0a52ebf715 100644 --- a/src/main/java/org/spongepowered/common/data/value/ImmutableSpongeCollectionValue.java +++ b/src/main/java/org/spongepowered/common/data/value/ImmutableSpongeCollectionValue.java @@ -68,7 +68,7 @@ public boolean containsAll(Iterable iterable) { } @Override - public C getAll() { + public C all() { return this.get(); } diff --git a/src/main/java/org/spongepowered/common/data/value/ImmutableSpongeListValue.java b/src/main/java/org/spongepowered/common/data/value/ImmutableSpongeListValue.java index e495d33b156..4e7922358cd 100644 --- a/src/main/java/org/spongepowered/common/data/value/ImmutableSpongeListValue.java +++ b/src/main/java/org/spongepowered/common/data/value/ImmutableSpongeListValue.java @@ -44,8 +44,8 @@ public ImmutableSpongeListValue( @Override @SuppressWarnings("unchecked") - public SpongeKey, List> getKey() { - return (SpongeKey, List>) super.getKey(); + public SpongeKey, List> key() { + return (SpongeKey, List>) super.key(); } @Override @@ -94,16 +94,16 @@ protected ListValue.Immutable modifyCollection(Consumer> consumer) { list = new ArrayList<>(this.element); consumer.accept(list); } - return this.getKey().getValueConstructor().getRawImmutable(list).asImmutable(); + return this.key().getValueConstructor().getRawImmutable(list).asImmutable(); } @Override public ListValue.Immutable with(List value) { - return this.getKey().getValueConstructor().getImmutable(value).asImmutable(); + return this.key().getValueConstructor().getImmutable(value).asImmutable(); } @Override public ListValue.Mutable asMutable() { - return new MutableSpongeListValue<>(this.getKey(), this.get()); + return new MutableSpongeListValue<>(this.key(), this.get()); } } diff --git a/src/main/java/org/spongepowered/common/data/value/ImmutableSpongeMapValue.java b/src/main/java/org/spongepowered/common/data/value/ImmutableSpongeMapValue.java index 4c3cdf38079..b05f5db86f1 100644 --- a/src/main/java/org/spongepowered/common/data/value/ImmutableSpongeMapValue.java +++ b/src/main/java/org/spongepowered/common/data/value/ImmutableSpongeMapValue.java @@ -49,8 +49,8 @@ public ImmutableSpongeMapValue(Key>> key, @Override @SuppressWarnings("unchecked") - public SpongeKey, Map> getKey() { - return (SpongeKey, Map>) super.getKey(); + public SpongeKey, Map> key() { + return (SpongeKey, Map>) super.key(); } @Override @@ -90,7 +90,7 @@ public MapValue.Immutable transform(Function, Map> functio @Override public MapValue.Immutable with(Map value) { - return this.getKey().getValueConstructor().getImmutable(value).asImmutable(); + return this.key().getValueConstructor().getImmutable(value).asImmutable(); } @Override @@ -111,7 +111,7 @@ private MapValue.Immutable modifyMap(Consumer> consumer) { map = new HashMap<>(this.element); consumer.accept(map); } - return this.getKey().getValueConstructor().getRawImmutable(map).asImmutable(); + return this.key().getValueConstructor().getRawImmutable(map).asImmutable(); } @Override @@ -142,6 +142,6 @@ public MapValue.Immutable withoutAll(Predicate> predicate) @Override public MapValue.Mutable asMutable() { - return new MutableSpongeMapValue<>(this.getKey(), this.get()); + return new MutableSpongeMapValue<>(this.key(), this.get()); } } diff --git a/src/main/java/org/spongepowered/common/data/value/ImmutableSpongeSetValue.java b/src/main/java/org/spongepowered/common/data/value/ImmutableSpongeSetValue.java index 4842f87a6e7..1f9172d9ecd 100644 --- a/src/main/java/org/spongepowered/common/data/value/ImmutableSpongeSetValue.java +++ b/src/main/java/org/spongepowered/common/data/value/ImmutableSpongeSetValue.java @@ -45,8 +45,8 @@ public ImmutableSpongeSetValue( @Override @SuppressWarnings("unchecked") - public SpongeKey, Set> getKey() { - return (SpongeKey, Set>) super.getKey(); + public SpongeKey, Set> key() { + return (SpongeKey, Set>) super.key(); } @Override @@ -63,16 +63,16 @@ protected SetValue.Immutable modifyCollection(Consumer> consumer) { set = new HashSet<>(this.element); consumer.accept(set); } - return this.getKey().getValueConstructor().getRawImmutable(set).asImmutable(); + return this.key().getValueConstructor().getRawImmutable(set).asImmutable(); } @Override public SetValue.Immutable with(Set value) { - return this.getKey().getValueConstructor().getImmutable(value).asImmutable(); + return this.key().getValueConstructor().getImmutable(value).asImmutable(); } @Override public SetValue.Mutable asMutable() { - return new MutableSpongeSetValue<>(this.getKey(), this.get()); + return new MutableSpongeSetValue<>(this.key(), this.get()); } } diff --git a/src/main/java/org/spongepowered/common/data/value/ImmutableSpongeValue.java b/src/main/java/org/spongepowered/common/data/value/ImmutableSpongeValue.java index 6231e8762cf..5b6717926de 100644 --- a/src/main/java/org/spongepowered/common/data/value/ImmutableSpongeValue.java +++ b/src/main/java/org/spongepowered/common/data/value/ImmutableSpongeValue.java @@ -37,7 +37,7 @@ public ImmutableSpongeValue(Key> key, E element) { @Override public Immutable with(E value) { - return this.getKey().getValueConstructor().getImmutable(value).asImmutable(); + return this.key().getValueConstructor().getImmutable(value).asImmutable(); } @Override @@ -47,6 +47,6 @@ public Immutable transform(Function function) { @Override public Mutable asMutable() { - return new MutableSpongeValue<>(this.getKey(), this.get()); + return new MutableSpongeValue<>(this.key(), this.get()); } } diff --git a/src/main/java/org/spongepowered/common/data/value/ImmutableSpongeWeightedCollectionValue.java b/src/main/java/org/spongepowered/common/data/value/ImmutableSpongeWeightedCollectionValue.java index 6d596c483d8..adc4d1ee7a6 100644 --- a/src/main/java/org/spongepowered/common/data/value/ImmutableSpongeWeightedCollectionValue.java +++ b/src/main/java/org/spongepowered/common/data/value/ImmutableSpongeWeightedCollectionValue.java @@ -44,8 +44,8 @@ public ImmutableSpongeWeightedCollectionValue( @Override @SuppressWarnings("unchecked") - public SpongeKey, WeightedTable> getKey() { - return (SpongeKey, WeightedTable>) super.getKey(); + public SpongeKey, WeightedTable> key() { + return (SpongeKey, WeightedTable>) super.key(); } @Override @@ -55,19 +55,19 @@ public List get(Random random) { @Override protected WeightedCollectionValue.Immutable modifyCollection(Consumer> consumer) { - final WeightedTable table = new WeightedTable<>(this.element.getRolls()); + final WeightedTable table = new WeightedTable<>(this.element.rolls()); table.addAll(this.element); consumer.accept(table); - return this.getKey().getValueConstructor().getRawImmutable(table).asImmutable(); + return this.key().getValueConstructor().getRawImmutable(table).asImmutable(); } @Override public WeightedCollectionValue.Immutable with(WeightedTable value) { - return this.getKey().getValueConstructor().getImmutable(value).asImmutable(); + return this.key().getValueConstructor().getImmutable(value).asImmutable(); } @Override public WeightedCollectionValue.Mutable asMutable() { - return new MutableSpongeWeightedCollectionValue<>(this.getKey(), this.get()); + return new MutableSpongeWeightedCollectionValue<>(this.key(), this.get()); } } diff --git a/src/main/java/org/spongepowered/common/data/value/MutableSpongeCollectionValue.java b/src/main/java/org/spongepowered/common/data/value/MutableSpongeCollectionValue.java index 8cf1812591c..675bbef253a 100644 --- a/src/main/java/org/spongepowered/common/data/value/MutableSpongeCollectionValue.java +++ b/src/main/java/org/spongepowered/common/data/value/MutableSpongeCollectionValue.java @@ -68,7 +68,7 @@ public boolean containsAll(Iterable iterable) { } @Override - public C getAll() { + public C all() { return this.element; } diff --git a/src/main/java/org/spongepowered/common/data/value/MutableSpongeListValue.java b/src/main/java/org/spongepowered/common/data/value/MutableSpongeListValue.java index 9f396b05d93..141d9b1d498 100644 --- a/src/main/java/org/spongepowered/common/data/value/MutableSpongeListValue.java +++ b/src/main/java/org/spongepowered/common/data/value/MutableSpongeListValue.java @@ -43,8 +43,8 @@ public MutableSpongeListValue(Key> key, List element) @Override @SuppressWarnings("unchecked") - public SpongeKey, List> getKey() { - return (SpongeKey, List>) super.getKey(); + public SpongeKey, List> key() { + return (SpongeKey, List>) super.key(); } @Override @@ -84,12 +84,12 @@ public ListValue.Mutable set(int index, E element) { @Override public ListValue.Immutable asImmutable() { - return this.getKey().getValueConstructor().getImmutable(this.element).asImmutable(); + return this.key().getValueConstructor().getImmutable(this.element).asImmutable(); } @Override public ListValue.Mutable copy() { - return new MutableSpongeListValue<>(this.getKey(), CopyHelper.copy(this.element)); + return new MutableSpongeListValue<>(this.key(), CopyHelper.copy(this.element)); } @Override diff --git a/src/main/java/org/spongepowered/common/data/value/MutableSpongeMapValue.java b/src/main/java/org/spongepowered/common/data/value/MutableSpongeMapValue.java index 7393426c40b..81cffe1b94d 100644 --- a/src/main/java/org/spongepowered/common/data/value/MutableSpongeMapValue.java +++ b/src/main/java/org/spongepowered/common/data/value/MutableSpongeMapValue.java @@ -46,8 +46,8 @@ public MutableSpongeMapValue(Key> key, Map elemen @Override @SuppressWarnings("unchecked") - public SpongeKey, Map> getKey() { - return (SpongeKey, Map>) super.getKey(); + public SpongeKey, Map> key() { + return (SpongeKey, Map>) super.key(); } @Override @@ -134,11 +134,11 @@ public MapValue.Mutable transform(Function, Map> function) @Override public MapValue.Mutable copy() { - return new MutableSpongeMapValue<>(this.getKey(), CopyHelper.copy(this.get())); + return new MutableSpongeMapValue<>(this.key(), CopyHelper.copy(this.get())); } @Override public MapValue.Immutable asImmutable() { - return this.getKey().getValueConstructor().getImmutable(this.get()).asImmutable(); + return this.key().getValueConstructor().getImmutable(this.get()).asImmutable(); } } diff --git a/src/main/java/org/spongepowered/common/data/value/MutableSpongeSetValue.java b/src/main/java/org/spongepowered/common/data/value/MutableSpongeSetValue.java index 016e593dfe7..701865441dc 100644 --- a/src/main/java/org/spongepowered/common/data/value/MutableSpongeSetValue.java +++ b/src/main/java/org/spongepowered/common/data/value/MutableSpongeSetValue.java @@ -43,18 +43,18 @@ public MutableSpongeSetValue(Key> key, Set element) { @Override @SuppressWarnings("unchecked") - public SpongeKey, Set> getKey() { - return (SpongeKey, Set>) super.getKey(); + public SpongeKey, Set> key() { + return (SpongeKey, Set>) super.key(); } @Override public SetValue.Immutable asImmutable() { - return this.getKey().getValueConstructor().getImmutable(this.element).asImmutable(); + return this.key().getValueConstructor().getImmutable(this.element).asImmutable(); } @Override public SetValue.Mutable copy() { - return new MutableSpongeSetValue<>(this.getKey(), CopyHelper.copy(this.element)); + return new MutableSpongeSetValue<>(this.key(), CopyHelper.copy(this.element)); } @Override diff --git a/src/main/java/org/spongepowered/common/data/value/MutableSpongeValue.java b/src/main/java/org/spongepowered/common/data/value/MutableSpongeValue.java index 0356faa656c..19910081b9e 100644 --- a/src/main/java/org/spongepowered/common/data/value/MutableSpongeValue.java +++ b/src/main/java/org/spongepowered/common/data/value/MutableSpongeValue.java @@ -43,11 +43,11 @@ public Mutable transform(Function function) { @Override public Immutable asImmutable() { - return this.getKey().getValueConstructor().getImmutable(this.element).asImmutable(); + return this.key().getValueConstructor().getImmutable(this.element).asImmutable(); } @Override public Mutable copy() { - return new MutableSpongeValue<>(this.getKey(), CopyHelper.copy(this.element)); + return new MutableSpongeValue<>(this.key(), CopyHelper.copy(this.element)); } } diff --git a/src/main/java/org/spongepowered/common/data/value/MutableSpongeWeightedCollectionValue.java b/src/main/java/org/spongepowered/common/data/value/MutableSpongeWeightedCollectionValue.java index 64b382ad398..a91bdec624a 100644 --- a/src/main/java/org/spongepowered/common/data/value/MutableSpongeWeightedCollectionValue.java +++ b/src/main/java/org/spongepowered/common/data/value/MutableSpongeWeightedCollectionValue.java @@ -45,8 +45,8 @@ public MutableSpongeWeightedCollectionValue(Key, WeightedTable> getKey() { - return (SpongeKey, WeightedTable>) super.getKey(); + public SpongeKey, WeightedTable> key() { + return (SpongeKey, WeightedTable>) super.key(); } @Override @@ -56,19 +56,19 @@ public List get(Random random) { @Override public WeightedCollectionValue.Immutable asImmutable() { - return this.getKey().getValueConstructor().getImmutable(this.element).asImmutable(); + return this.key().getValueConstructor().getImmutable(this.element).asImmutable(); } @Override public WeightedCollectionValue.Mutable copy() { - return new MutableSpongeWeightedCollectionValue<>(this.getKey(), CopyHelper.copy(this.element)); + return new MutableSpongeWeightedCollectionValue<>(this.key(), CopyHelper.copy(this.element)); } @Override protected WeightedCollectionValue.Mutable modifyCollection(Consumer> consumer) { final WeightedTable table = this.element; if (table instanceof UnmodifiableWeightedTable) { - final WeightedTable temp = new WeightedTable<>(table.getRolls()); + final WeightedTable temp = new WeightedTable<>(table.rolls()); temp.addAll(table); consumer.accept(temp); this.set(new UnmodifiableWeightedTable<>(temp)); diff --git a/src/main/java/org/spongepowered/common/data/value/SpongeValue.java b/src/main/java/org/spongepowered/common/data/value/SpongeValue.java index 7d6aff144c1..ea50aa71690 100644 --- a/src/main/java/org/spongepowered/common/data/value/SpongeValue.java +++ b/src/main/java/org/spongepowered/common/data/value/SpongeValue.java @@ -46,7 +46,7 @@ public E get() { } @Override - public SpongeKey, E> getKey() { + public SpongeKey, E> key() { return this.key; } diff --git a/src/main/java/org/spongepowered/common/data/value/ValueConstructorFactory.java b/src/main/java/org/spongepowered/common/data/value/ValueConstructorFactory.java index 41be2567715..31d2fe52339 100644 --- a/src/main/java/org/spongepowered/common/data/value/ValueConstructorFactory.java +++ b/src/main/java/org/spongepowered/common/data/value/ValueConstructorFactory.java @@ -42,7 +42,7 @@ public final class ValueConstructorFactory { public static , E> ValueConstructor getConstructor(final SpongeKey key) { - final Class valueType = GenericTypeReflector.erase(key.getValueType()); + final Class valueType = GenericTypeReflector.erase(key.valueType()); ValueConstructor valueConstructor; if (ListValue.class.isAssignableFrom(valueType)) { valueConstructor = new SimpleValueConstructor(key, @@ -66,7 +66,7 @@ public static , E> ValueConstructor getConstructor(fina valueConstructor = new SimpleValueConstructor(key, (key1, value) -> new MutableSpongeValue((Key) key1, value), (key1, value) -> new ImmutableSpongeValue((Key) key1, value)); - final Class elementType = GenericTypeReflector.erase(key.getElementType()); + final Class elementType = GenericTypeReflector.erase(key.elementType()); if (Enum.class.isAssignableFrom(elementType)) { valueConstructor = new CachedEnumValueConstructor(valueConstructor, elementType); } else if (elementType == Boolean.class) { diff --git a/src/main/java/org/spongepowered/common/datapack/DataPackSerializer.java b/src/main/java/org/spongepowered/common/datapack/DataPackSerializer.java index 0ce6db6e405..727f6051f64 100644 --- a/src/main/java/org/spongepowered/common/datapack/DataPackSerializer.java +++ b/src/main/java/org/spongepowered/common/datapack/DataPackSerializer.java @@ -59,8 +59,8 @@ protected boolean serialize(final SpongeDataPackType<@NonNull ?, T> type, final // Write our objects for (final T object : objects) { - final Path namespacedDataDirectory = datapackDir.resolve("data").resolve(object.getKey().getNamespace()); - final Path objectFile = namespacedDataDirectory.resolve(this.typeDirectoryName).resolve(object.getKey().getValue() + ".json"); + final Path namespacedDataDirectory = datapackDir.resolve("data").resolve(object.getKey().namespace()); + final Path objectFile = namespacedDataDirectory.resolve(this.typeDirectoryName).resolve(object.getKey().value() + ".json"); Files.createDirectories(objectFile.getParent()); DataPackSerializer.writeFile(objectFile, object.getObject()); diff --git a/src/main/java/org/spongepowered/common/datapack/SpongeDataPackManager.java b/src/main/java/org/spongepowered/common/datapack/SpongeDataPackManager.java index 7fdf23aabeb..22c3bf1d331 100644 --- a/src/main/java/org/spongepowered/common/datapack/SpongeDataPackManager.java +++ b/src/main/java/org/spongepowered/common/datapack/SpongeDataPackManager.java @@ -46,7 +46,7 @@ public final class SpongeDataPackManager { - public static SpongeDataPackManager INSTANCE = new SpongeDataPackManager(Sponge.getGame()); + public static SpongeDataPackManager INSTANCE = new SpongeDataPackManager(Sponge.game()); private final Game game; private final Map> serializables; @@ -102,7 +102,7 @@ public void serialize(final Path dataPacksDirectory, Collection dataPack private Map, List> callRegisterDataPackValueEvent(final SpongeDataPackType type) { final RegisterDataPackValueEventImpl event = new RegisterDataPackValueEventImpl<>(Cause.of(EventContext.empty(), this.game), this.game, type); - this.game.getEventManager().post(event); + this.game.eventManager().post(event); return event.serializables(); } diff --git a/src/main/java/org/spongepowered/common/datapack/SpongeDataPackType.java b/src/main/java/org/spongepowered/common/datapack/SpongeDataPackType.java index 9e5c1fd158d..bdd74b75aa7 100644 --- a/src/main/java/org/spongepowered/common/datapack/SpongeDataPackType.java +++ b/src/main/java/org/spongepowered/common/datapack/SpongeDataPackType.java @@ -96,30 +96,30 @@ public static final class FactoryImpl implements DataPackType.Factory { private final SpongeDataPackType<@NonNull Advancement, DataPackSerializedObject> advancement = new SpongeDataPackType<>(TypeToken.get(Advancement.class), new DataPackSerializer<>("Advancements", "advancements"), s -> ((net.minecraft.advancements.Advancement) s).deconstruct().serializeToJson(), - (i1, i2) -> new DataPackSerializedObject(i1.getKey(), i2), + (i1, i2) -> new DataPackSerializedObject(i1.key(), i2), false ); private final SpongeDataPackType<@NonNull RecipeRegistration, RecipeSerializedObject> recipe = new SpongeDataPackType<>(TypeToken.get(RecipeRegistration.class), new RecipeDataPackSerializer(), s -> ((FinishedRecipe) s).serializeRecipe(), - (i1, i2) -> new RecipeSerializedObject(i1.getKey(), i2, new DataPackSerializedObject(i1.getKey(), ((FinishedRecipe) i1).serializeAdvancement())), + (i1, i2) -> new RecipeSerializedObject(i1.key(), i2, new DataPackSerializedObject(i1.key(), ((FinishedRecipe) i1).serializeAdvancement())), false ); private final SpongeDataPackType<@NonNull WorldTypeTemplate, DataPackSerializedObject> worldType = new SpongeDataPackType<>(TypeToken.get(WorldTypeTemplate.class), new DataPackSerializer<>("Dimension Types", "dimension_type"), s -> { - final OptionalLong fixedTime = !s.fixedTime().isPresent() ? OptionalLong.empty() : OptionalLong.of(s.fixedTime().get().asTicks().getTicks()); + final OptionalLong fixedTime = !s.fixedTime().isPresent() ? OptionalLong.empty() : OptionalLong.of(s.fixedTime().get().asTicks().ticks()); final DimensionType type = DimensionTypeAccessor.invoker$new(fixedTime, s.hasSkylight(), s.hasCeiling(), s.scorching(), s.natural(), s.coordinateMultiplier(), s.createDragonFight(), s.piglinSafe(), s.bedsUsable(), s.respawnAnchorsUsable(), s.hasRaids(), s.logicalHeight(), (BiomeZoomer) s.biomeSampler(), (ResourceLocation) (Object) ((SpongeWorldTypeTemplate) s).infiniburn, - (ResourceLocation) (Object) s.effect().getKey(), s.ambientLighting()); + (ResourceLocation) (Object) s.effect().key(), s.ambientLighting()); return SpongeWorldTypeTemplate.DIRECT_CODEC.encodeStart(RegistryWriteOps.create(JsonOps.INSTANCE, BootstrapProperties.registries), type).getOrThrow(false, e -> {}); }, - (i1, i2) -> new DataPackSerializedObject(i1.getKey(), i2), + (i1, i2) -> new DataPackSerializedObject(i1.key(), i2), true ); @@ -131,7 +131,7 @@ public static final class FactoryImpl implements DataPackType.Factory { ((LevelStemBridge) (Object) template).bridge$populateFromTemplate((SpongeWorldTemplate) s); return SpongeWorldTemplate.DIRECT_CODEC.encodeStart(RegistryWriteOps.create(JsonOps.INSTANCE, BootstrapProperties.registries), template).getOrThrow(false, e -> {}); }, - (i1, i2) -> new DataPackSerializedObject(i1.getKey(), i2), + (i1, i2) -> new DataPackSerializedObject(i1.key(), i2), true ); diff --git a/src/main/java/org/spongepowered/common/datapack/recipe/RecipeDataPackSerializer.java b/src/main/java/org/spongepowered/common/datapack/recipe/RecipeDataPackSerializer.java index 0c46cd6450e..87826b686a0 100644 --- a/src/main/java/org/spongepowered/common/datapack/recipe/RecipeDataPackSerializer.java +++ b/src/main/java/org/spongepowered/common/datapack/recipe/RecipeDataPackSerializer.java @@ -39,7 +39,7 @@ public RecipeDataPackSerializer() { @Override protected void serializeAdditional(final Path dataDirectory, final RecipeSerializedObject object) throws IOException { if (object.getAdvancementObject() != null) { - final Path advancementFile = dataDirectory.resolve("advancements").resolve(object.getAdvancementObject().getKey().getValue() + ".json"); + final Path advancementFile = dataDirectory.resolve("advancements").resolve(object.getAdvancementObject().getKey().value() + ".json"); Files.createDirectories(advancementFile.getParent()); this.writeFile(advancementFile, object.getAdvancementObject().getObject()); } diff --git a/src/main/java/org/spongepowered/common/effect/particle/NumericalParticleType.java b/src/main/java/org/spongepowered/common/effect/particle/NumericalParticleType.java index 59f4302b1f7..3f488389aa9 100644 --- a/src/main/java/org/spongepowered/common/effect/particle/NumericalParticleType.java +++ b/src/main/java/org/spongepowered/common/effect/particle/NumericalParticleType.java @@ -58,12 +58,12 @@ public int getId() { @SuppressWarnings("unchecked") @Override - public Optional getDefaultOption(final ParticleOption option) { + public Optional defaultOption(final ParticleOption option) { return Optional.ofNullable((V) this.defaultOptions.get(option)); } @Override - public Map, Object> getDefaultOptions() { + public Map, Object> defaultOptions() { return this.defaultOptions; } diff --git a/src/main/java/org/spongepowered/common/effect/particle/SpongeParticleEffect.java b/src/main/java/org/spongepowered/common/effect/particle/SpongeParticleEffect.java index d0863dffbdc..c568dd4366f 100644 --- a/src/main/java/org/spongepowered/common/effect/particle/SpongeParticleEffect.java +++ b/src/main/java/org/spongepowered/common/effect/particle/SpongeParticleEffect.java @@ -49,23 +49,23 @@ public SpongeParticleEffect(ParticleType type, Map, Object> op } @Override - public ParticleType getType() { + public ParticleType type() { return this.type; } @SuppressWarnings("unchecked") @Override - public Optional getOption(ParticleOption option) { + public Optional option(ParticleOption option) { return Optional.ofNullable((V) this.options.get(option)); } @Override - public Map, Object> getOptions() { + public Map, Object> options() { return this.options; } @Override - public int getContentVersion() { + public int contentVersion() { return 1; } diff --git a/src/main/java/org/spongepowered/common/effect/particle/SpongeParticleEffectBuilder.java b/src/main/java/org/spongepowered/common/effect/particle/SpongeParticleEffectBuilder.java index 6a8ac524ae5..56328a0cb74 100644 --- a/src/main/java/org/spongepowered/common/effect/particle/SpongeParticleEffectBuilder.java +++ b/src/main/java/org/spongepowered/common/effect/particle/SpongeParticleEffectBuilder.java @@ -37,7 +37,6 @@ import org.spongepowered.api.effect.particle.ParticleOption; import org.spongepowered.api.effect.particle.ParticleType; import org.spongepowered.api.registry.RegistryTypes; -import org.spongepowered.common.SpongeCommon; import org.spongepowered.common.util.Constants; import java.util.HashMap; @@ -62,15 +61,15 @@ protected Optional buildContent(DataView container) throws Inval return Optional.empty(); } ParticleType particleType = - container.getRegistryValue(Constants.Particles.PARTICLE_TYPE, RegistryTypes.PARTICLE_TYPE, Sponge.getGame().registries()).get(); + container.getRegistryValue(Constants.Particles.PARTICLE_TYPE, RegistryTypes.PARTICLE_TYPE, Sponge.game().registries()).get(); Map, Object> options = new HashMap<>(); container.getViewList(Constants.Particles.PARTICLE_OPTIONS).get().forEach(view -> { - ParticleOption option = view.getRegistryValue(Constants.Particles.PARTICLE_OPTION_KEY, RegistryTypes.PARTICLE_OPTION, Sponge.getGame().registries()).get(); + ParticleOption option = view.getRegistryValue(Constants.Particles.PARTICLE_OPTION_KEY, RegistryTypes.PARTICLE_OPTION, Sponge.game().registries()).get(); Object value; - if (option.getValueType().isAssignableFrom(DataSerializable.class)) { - value = view.getSerializable(Constants.Particles.PARTICLE_OPTION_VALUE, (Class) option.getValueType()).get(); + if (option.valueType().isAssignableFrom(DataSerializable.class)) { + value = view.getSerializable(Constants.Particles.PARTICLE_OPTION_VALUE, (Class) option.valueType()).get(); } else { - value = view.getObject(Constants.Particles.PARTICLE_OPTION_VALUE, option.getValueType()).get(); + value = view.getObject(Constants.Particles.PARTICLE_OPTION_VALUE, option.valueType()).get(); } options.put(option, value); }); @@ -79,8 +78,8 @@ protected Optional buildContent(DataView container) throws Inval @Override public ParticleEffect.Builder from(ParticleEffect particleEffect) { - this.type = particleEffect.getType(); - this.options = new HashMap<>(particleEffect.getOptions()); + this.type = particleEffect.type(); + this.options = new HashMap<>(particleEffect.options()); return this; } diff --git a/src/main/java/org/spongepowered/common/effect/particle/SpongeParticleHelper.java b/src/main/java/org/spongepowered/common/effect/particle/SpongeParticleHelper.java index 72a3237f6a5..a4a1b00f0ba 100644 --- a/src/main/java/org/spongepowered/common/effect/particle/SpongeParticleHelper.java +++ b/src/main/java/org/spongepowered/common/effect/particle/SpongeParticleHelper.java @@ -84,7 +84,7 @@ public static List> toPackets(final ParticleEffect effect, final Vecto } public static CachedParticlePacket getCachedPacket(final SpongeParticleEffect effect) { - final ParticleType type = effect.getType(); + final ParticleType type = effect.type(); if (type instanceof NumericalParticleType) { // Special cased particle types with numerical IDs. @@ -104,9 +104,9 @@ private static CachedParticlePacket getNumericalPacket(final ParticleEffect effe @SuppressWarnings({"unchecked", "ConstantConditions"}) private static CachedParticlePacket getNamedPacket(final ParticleEffect effect, final net.minecraft.core.particles.ParticleType internalType) { // Named particles always support OFFSET and QUANTITY. - final Vector3f offset = effect.getOptionOrDefault(ParticleOptions.OFFSET).get().toFloat(); - final int quantity = effect.getOptionOrDefault(ParticleOptions.QUANTITY).get(); - final Vector3f velocity = effect.getOptionOrDefault(ParticleOptions.VELOCITY).orElse(Vector3d.ZERO).toFloat(); + final Vector3f offset = effect.optionOrDefault(ParticleOptions.OFFSET).get().toFloat(); + final int quantity = effect.optionOrDefault(ParticleOptions.QUANTITY).get(); + final Vector3f velocity = effect.optionOrDefault(ParticleOptions.VELOCITY).orElse(Vector3d.ZERO).toFloat(); if (internalType instanceof SimpleParticleType) { // Simple named particle without any additional supported options. @@ -118,25 +118,25 @@ private static CachedParticlePacket getNamedPacket(final ParticleEffect effect, // If only mojang had some type akin to our ParticleEffect... if (internalType.getDeserializer() == BlockParticleOption.DESERIALIZER) { // This particle type supports a block state option. - final BlockState state = effect.getOptionOrDefault(ParticleOptions.BLOCK_STATE).get(); + final BlockState state = effect.optionOrDefault(ParticleOptions.BLOCK_STATE).get(); final BlockParticleOption particleData = new BlockParticleOption( (net.minecraft.core.particles.ParticleType) internalType, (net.minecraft.world.level.block.state.BlockState) state); return new NamedCachedPacket(particleData, offset, quantity, velocity); } else if (internalType.getDeserializer() == ItemParticleOption.DESERIALIZER) { // This particle type supports an item option. - final ItemStackSnapshot snapshot = effect.getOptionOrDefault(ParticleOptions.ITEM_STACK_SNAPSHOT).get(); + final ItemStackSnapshot snapshot = effect.optionOrDefault(ParticleOptions.ITEM_STACK_SNAPSHOT).get(); final ItemParticleOption particleData = new ItemParticleOption( (net.minecraft.core.particles.ParticleType) internalType, (net.minecraft.world.item.ItemStack) (Object) snapshot.createStack()); return new NamedCachedPacket(particleData, offset, quantity, velocity); } else if (internalType.getDeserializer() == DustParticleOptions.DESERIALIZER) { // This particle type supports a color option. - final Color color = effect.getOptionOrDefault(ParticleOptions.COLOR).get(); + final Color color = effect.optionOrDefault(ParticleOptions.COLOR).get(); final DustParticleOptions particleData = new DustParticleOptions( - (float) color.getRed() / 255, - (float) color.getGreen() / 255, - (float) color.getBlue() / 255, + (float) color.red() / 255, + (float) color.green() / 255, + (float) color.blue() / 255, 1.0f); return new NamedCachedPacket(particleData, offset, quantity, velocity); } @@ -147,7 +147,7 @@ private static CachedParticlePacket getNamedPacket(final ParticleEffect effect, public static int getDirectionId(Direction direction) { if (direction.isSecondaryOrdinal()) { - direction = Direction.getClosest(direction.asOffset(), Direction.Division.ORDINAL); + direction = Direction.closest(direction.asOffset(), Direction.Division.ORDINAL); } switch (direction) { case SOUTHEAST: @@ -172,18 +172,18 @@ public static int getDirectionId(Direction direction) { } public static int getBlockStateId(final ParticleEffect effect, final Optional defaultBlockState) { - final Optional blockState = effect.getOption(ParticleOptions.BLOCK_STATE); + final Optional blockState = effect.option(ParticleOptions.BLOCK_STATE); if (blockState.isPresent()) { // Use the provided block state option. return Block.getId((net.minecraft.world.level.block.state.BlockState) blockState.get()); } - final Optional itemSnapshot = effect.getOption(ParticleOptions.ITEM_STACK_SNAPSHOT); + final Optional itemSnapshot = effect.option(ParticleOptions.ITEM_STACK_SNAPSHOT); if (itemSnapshot.isPresent()) { // Try to convert the item into a usable block state. - final Optional blockType = itemSnapshot.get().getType().getBlock(); + final Optional blockType = itemSnapshot.get().type().block(); // TODO: correct behavior? - return blockType.map(type -> Block.getId((net.minecraft.world.level.block.state.BlockState) type.getDefaultState())) + return blockType.map(type -> Block.getId((net.minecraft.world.level.block.state.BlockState) type.defaultState())) .orElse(0); } diff --git a/src/main/java/org/spongepowered/common/effect/particle/SpongeParticleOption.java b/src/main/java/org/spongepowered/common/effect/particle/SpongeParticleOption.java index f95d05b6556..100bb82c4c4 100644 --- a/src/main/java/org/spongepowered/common/effect/particle/SpongeParticleOption.java +++ b/src/main/java/org/spongepowered/common/effect/particle/SpongeParticleOption.java @@ -54,7 +54,7 @@ public IllegalArgumentException validateValue(V value) { } @Override - public Class getValueType() { + public Class valueType() { return this.valueType; } } \ No newline at end of file diff --git a/src/main/java/org/spongepowered/common/effect/potion/SpongePotionBuilder.java b/src/main/java/org/spongepowered/common/effect/potion/SpongePotionBuilder.java index 42940012029..1cc60edb666 100644 --- a/src/main/java/org/spongepowered/common/effect/potion/SpongePotionBuilder.java +++ b/src/main/java/org/spongepowered/common/effect/potion/SpongePotionBuilder.java @@ -57,9 +57,9 @@ public SpongePotionBuilder() { @Override public PotionEffect.Builder from(PotionEffect holder) { - this.potionType = checkNotNull(holder).getType(); - this.duration = holder.getDuration(); - this.amplifier = holder.getAmplifier(); + this.potionType = checkNotNull(holder).type(); + this.duration = holder.duration(); + this.amplifier = holder.amplifier(); this.isAmbient = holder.isAmbient(); this.showParticles = holder.showsParticles(); this.showIcon = holder.showsIcon(); @@ -75,7 +75,7 @@ protected Optional buildContent(DataView container) throws Invalid return Optional.empty(); } String effectName = container.getString(Constants.Item.Potions.POTION_TYPE).get(); - Optional optional = Sponge.getGame().registries().registry(RegistryTypes.POTION_EFFECT_TYPE).findValue(ResourceKey.resolve(effectName)); + Optional optional = Sponge.game().registries().registry(RegistryTypes.POTION_EFFECT_TYPE).findValue(ResourceKey.resolve(effectName)); if (!optional.isPresent()) { throw new InvalidDataException("The container has an invalid potion type name: " + effectName); } diff --git a/src/main/java/org/spongepowered/common/effect/record/SpongeMusicDisc.java b/src/main/java/org/spongepowered/common/effect/record/SpongeMusicDisc.java index 1e55dec9cff..b1326c76682 100644 --- a/src/main/java/org/spongepowered/common/effect/record/SpongeMusicDisc.java +++ b/src/main/java/org/spongepowered/common/effect/record/SpongeMusicDisc.java @@ -58,7 +58,7 @@ public int getId() { } @Override - public SoundType getSound() { + public SoundType sound() { return (SoundType) ((RecordItemAccessor) this.item).accessor$sound(); } diff --git a/src/main/java/org/spongepowered/common/entity/EntityUtil.java b/src/main/java/org/spongepowered/common/entity/EntityUtil.java index 6a6d4ad45ae..94228ae7423 100644 --- a/src/main/java/org/spongepowered/common/entity/EntityUtil.java +++ b/src/main/java/org/spongepowered/common/entity/EntityUtil.java @@ -150,7 +150,7 @@ public static boolean isEntityDead(final net.minecraft.world.entity.Entity entit public static boolean processEntitySpawnsFromEvent(final SpawnEntityEvent event, final Supplier> entityCreatorSupplier) { boolean spawnedAny = false; - for (final org.spongepowered.api.entity.Entity entity : event.getEntities()) { + for (final org.spongepowered.api.entity.Entity entity : event.entities()) { // Here is where we need to handle the custom items potentially having custom entities spawnedAny = EntityUtil.processEntitySpawn(entity, entityCreatorSupplier); } @@ -196,7 +196,7 @@ public static boolean processEntitySpawn(final org.spongepowered.api.entity.Enti } }); // Allowed to call force spawn directly since we've applied creator and custom item logic already - ((net.minecraft.world.level.Level) entity.getWorld()).addFreshEntity((Entity) entity); + ((net.minecraft.world.level.Level) entity.world()).addFreshEntity((Entity) entity); return true; } diff --git a/src/main/java/org/spongepowered/common/entity/SpongeEntityArchetype.java b/src/main/java/org/spongepowered/common/entity/SpongeEntityArchetype.java index eb292cbf107..0a8982f2833 100644 --- a/src/main/java/org/spongepowered/common/entity/SpongeEntityArchetype.java +++ b/src/main/java/org/spongepowered/common/entity/SpongeEntityArchetype.java @@ -78,7 +78,7 @@ public class SpongeEntityArchetype extends AbstractArchetype getType() { + public EntityType type() { return this.type; } @@ -113,7 +113,7 @@ public Optional getPosition() { @Override public DataContainer data$getDataContainer() { - return this.getEntityData(); + return this.entityData(); } @Override @@ -122,7 +122,7 @@ public Optional getPosition() { } @Override - public DataContainer getEntityData() { + public DataContainer entityData() { return NBTTranslator.INSTANCE.translateFrom(this.data); } @@ -131,14 +131,14 @@ public Optional apply(final ServerLocation if (!PlatformHooks.INSTANCE.getGeneralHooks().onServerThread()) { return Optional.empty(); } - final org.spongepowered.api.world.server.ServerWorld spongeWorld = location.getWorld(); + final org.spongepowered.api.world.server.ServerWorld spongeWorld = location.world(); final ServerLevel worldServer = (ServerLevel) spongeWorld; final Entity entity = ((net.minecraft.world.entity.EntityType) this.type).create(worldServer); if (entity == null) { return Optional.empty(); } - entity.setPos(location.getX(), location.getY(), location.getZ()); // Set initial position + entity.setPos(location.x(), location.y(), location.z()); // Set initial position final boolean requiresInitialSpawn; if (this.data.contains(Constants.Sponge.EntityArchetype.REQUIRES_EXTRA_INITIAL_SPAWN)) { @@ -164,10 +164,10 @@ public Optional apply(final ServerLocation mergedNbt.merge(this.data); mergedNbt.remove(Constants.Sponge.EntityArchetype.REQUIRES_EXTRA_INITIAL_SPAWN); - mergedNbt.putString(Constants.Sponge.World.WORLD_KEY, location.getWorldKey().getFormatted()); + mergedNbt.putString(Constants.Sponge.World.WORLD_KEY, location.worldKey().formatted()); mergedNbt.putUUID(Constants.Entity.ENTITY_UUID, uniqueID); // TODO can we avoid this when the entity is only spawned once? entity.load(mergedNbt); // Read in all data - entity.setPos(location.getX(), location.getY(), location.getZ()); + entity.setPos(location.x(), location.y(), location.z()); // Finished building the entity. Now spawn it if not cancelled. final org.spongepowered.api.entity.Entity spongeEntity = (org.spongepowered.api.entity.Entity) entity; @@ -175,8 +175,8 @@ public Optional apply(final ServerLocation entities.add(spongeEntity); // We require spawn types. This is more of a sanity check to throw an IllegalStateException otherwise for the plugin developer to properly associate the type. - final SpawnType require = PhaseTracker.getCauseStackManager().getCurrentContext().require(EventContextKeys.SPAWN_TYPE); - final SpawnEntityEvent.Custom event = SpongeEventFactory.createSpawnEntityEventCustom(PhaseTracker.getCauseStackManager().getCurrentCause(), entities); + final SpawnType require = PhaseTracker.getCauseStackManager().currentContext().require(EventContextKeys.SPAWN_TYPE); + final SpawnEntityEvent.Custom event = SpongeEventFactory.createSpawnEntityEventCustom(PhaseTracker.getCauseStackManager().currentCause(), entities); if (!event.isCancelled()) { worldServer.addFreshEntity(entity); return Optional.of(spongeEntity); @@ -189,11 +189,11 @@ public EntitySnapshot toSnapshot(final ServerLocation location) { final SpongeEntitySnapshotBuilder builder = new SpongeEntitySnapshotBuilder(); builder.entityType = this.type; final CompoundTag newCompound = this.data.copy(); - final Vector3d pos = location.getPosition(); + final Vector3d pos = location.position(); newCompound.put(Constants.Entity.ENTITY_POSITION, Constants.NBT.newDoubleNBTList(pos.getX(), pos.getY(), pos.getZ())); - newCompound.putString(Constants.Sponge.World.WORLD_KEY, location.getWorldKey().getFormatted()); + newCompound.putString(Constants.Sponge.World.WORLD_KEY, location.worldKey().formatted()); builder.compound = newCompound; - builder.worldKey = location.getWorld().getProperties().getKey(); + builder.worldKey = location.world().properties().key(); builder.position = pos; builder.rotation = this.getRotation(); builder.scale = Vector3d.ONE; @@ -208,7 +208,7 @@ private Vector3d getRotation() { } @Override - public int getContentVersion() { + public int contentVersion() { return Constants.Sponge.EntityArchetype.BASE_VERSION; } @@ -216,7 +216,7 @@ public int getContentVersion() { public DataContainer toContainer() { return DataContainer.createNew() .set(Constants.Sponge.EntityArchetype.ENTITY_TYPE, this.type) - .set(Constants.Sponge.EntityArchetype.ENTITY_DATA, this.getEntityData()); + .set(Constants.Sponge.EntityArchetype.ENTITY_DATA, this.entityData()); } @Override diff --git a/src/main/java/org/spongepowered/common/entity/SpongeEntityArchetypeBuilder.java b/src/main/java/org/spongepowered/common/entity/SpongeEntityArchetypeBuilder.java index b1de8dd3b47..5d21aa54c5d 100644 --- a/src/main/java/org/spongepowered/common/entity/SpongeEntityArchetypeBuilder.java +++ b/src/main/java/org/spongepowered/common/entity/SpongeEntityArchetypeBuilder.java @@ -66,8 +66,8 @@ public EntityArchetype.Builder reset() { @Override public EntityArchetype.Builder from(final EntityArchetype value) { - this.entityType = value.getType(); - this.entityData = value.getEntityData(); + this.entityType = value.type(); + this.entityData = value.entityData(); this.manipulator = null; return this; } @@ -76,7 +76,7 @@ public EntityArchetype.Builder from(final EntityArchetype value) { protected Optional buildContent(final DataView container) throws InvalidDataException { final SpongeEntityArchetypeBuilder builder = new SpongeEntityArchetypeBuilder(); if (container.contains(Constants.Sponge.EntityArchetype.ENTITY_TYPE)) { - builder.type(container.getRegistryValue(Constants.Sponge.EntityArchetype.ENTITY_TYPE, RegistryTypes.ENTITY_TYPE, Sponge.getGame().registries()) + builder.type(container.getRegistryValue(Constants.Sponge.EntityArchetype.ENTITY_TYPE, RegistryTypes.ENTITY_TYPE, Sponge.game().registries()) .orElseThrow(() -> new InvalidDataException("Could not deserialize an EntityType!"))); } else { throw new InvalidDataException("Missing the EntityType! Cannot re-construct an EntityArchetype!"); @@ -103,7 +103,7 @@ public EntityArchetype.Builder type(final EntityType type) { @Override public EntityArchetype.Builder from(final Entity entity) { Objects.requireNonNull(entity, "Cannot build an EntityArchetype for a null entity!"); - this.entityType = Objects.requireNonNull(entity.getType(), "Entity is returning a null EntityType!"); + this.entityType = Objects.requireNonNull(entity.type(), "Entity is returning a null EntityType!"); final net.minecraft.world.entity.Entity minecraftEntity = (net.minecraft.world.entity.Entity) entity; final CompoundTag compound = new CompoundTag(); minecraftEntity.saveAsPassenger(compound); diff --git a/src/main/java/org/spongepowered/common/entity/SpongeEntitySnapshot.java b/src/main/java/org/spongepowered/common/entity/SpongeEntitySnapshot.java index ff3dc1f168d..08328e48d81 100644 --- a/src/main/java/org/spongepowered/common/entity/SpongeEntitySnapshot.java +++ b/src/main/java/org/spongepowered/common/entity/SpongeEntitySnapshot.java @@ -96,24 +96,24 @@ public WeakReference getEntityReference() { } @Override - public Optional getUniqueId() { + public Optional uniqueId() { return Optional.ofNullable(this.uniqueId); } @Override - public Optional getTransform() { + public Optional transform() { final Transform transform = Transform.of(this.position, this.rotation); return Optional.of(transform); } @Override - public EntityType getType() { + public EntityType type() { return this.entityType; } @Override - public Optional getLocation() { - final Optional optional = SpongeCommon.getGame().getServer().getWorldManager().world(this.worldKey); + public Optional location() { + final Optional optional = SpongeCommon.getGame().server().worldManager().world(this.worldKey); if (optional.isPresent()) { final ServerLocation location = ServerLocation.of(optional.get(), this.position); return Optional.of(location); @@ -122,7 +122,7 @@ public Optional getLocation() { } @Override - public int getContentVersion() { + public int contentVersion() { return 1; } @@ -130,23 +130,23 @@ public int getContentVersion() { public DataContainer toContainer() { final DataContainer unsafeNbt = NBTTranslator.INSTANCE.translateFrom(this.compound == null ? new CompoundTag() : this.compound); final DataContainer container = DataContainer.createNew() - .set(Queries.CONTENT_VERSION, this.getContentVersion()) - .set(Queries.WORLD_KEY, this.worldKey.getFormatted()) + .set(Queries.CONTENT_VERSION, this.contentVersion()) + .set(Queries.WORLD_KEY, this.worldKey.formatted()) .createView(Constants.Sponge.SNAPSHOT_WORLD_POSITION) .set(Queries.POSITION_X, this.position.getX()) .set(Queries.POSITION_Y, this.position.getY()) .set(Queries.POSITION_Z, this.position.getZ()) - .getContainer() + .container() .createView(Constants.Entity.ROTATION) .set(Queries.POSITION_X, this.rotation.getX()) .set(Queries.POSITION_Y, this.rotation.getY()) .set(Queries.POSITION_Z, this.rotation.getZ()) - .getContainer() + .container() .createView(Constants.Entity.SCALE) .set(Queries.POSITION_X, this.scale.getX()) .set(Queries.POSITION_Y, this.scale.getY()) .set(Queries.POSITION_Z, this.scale.getZ()) - .getContainer() + .container() .set(Constants.Entity.TYPE, net.minecraft.world.entity.EntityType.getKey((net.minecraft.world.entity.EntityType) this.entityType)) .set(Constants.Sponge.UNSAFE_NBT, unsafeNbt); @@ -173,12 +173,12 @@ public EntitySnapshot copy() { } @Override - public ResourceKey getWorld() { + public ResourceKey world() { return this.worldKey; } @Override - public Vector3i getPosition() { + public Vector3i position() { return this.position.toInt(); } @@ -186,15 +186,15 @@ public Vector3i getPosition() { public EntitySnapshot withLocation(final ServerLocation location) { Objects.requireNonNull(location, "location"); final SpongeEntitySnapshotBuilder builder = this.createBuilder(); - builder.position = location.getPosition(); - builder.worldKey = location.getWorld().getKey(); + builder.position = location.position(); + builder.worldKey = location.world().key(); builder.compound = new CompoundTag(); return builder.build(); } private SpongeEntitySnapshotBuilder createBuilder() { return new SpongeEntitySnapshotBuilder() - .type(this.getType()) + .type(this.type()) .rotation(this.rotation) .scale(this.scale); } @@ -214,19 +214,19 @@ public Optional restore() { return Optional.of(entity); } } - final Optional world = Sponge.getServer().getWorldManager().world(this.worldKey); + final Optional world = Sponge.server().worldManager().world(this.worldKey); if (!world.isPresent()) { return Optional.empty(); } if (this.uniqueId != null) { - final Optional entity = world.get().getEntity(this.uniqueId); + final Optional entity = world.get().entity(this.uniqueId); if (entity.isPresent()) { return entity; } } try (final StackFrame frame = PhaseTracker.getCauseStackManager().pushCauseFrame()) { frame.addContext(EventContextKeys.SPAWN_TYPE, SpawnTypes.PLUGIN); - final Entity newEntity = world.get().createEntity(this.getType(), this.position); + final Entity newEntity = world.get().createEntity(this.type(), this.position); if (newEntity != null) { final net.minecraft.world.entity.Entity nmsEntity = (net.minecraft.world.entity.Entity) newEntity; if (this.compound != null) { diff --git a/src/main/java/org/spongepowered/common/entity/SpongeEntitySnapshotBuilder.java b/src/main/java/org/spongepowered/common/entity/SpongeEntitySnapshotBuilder.java index 3610934c980..a3f132f1ba3 100644 --- a/src/main/java/org/spongepowered/common/entity/SpongeEntitySnapshotBuilder.java +++ b/src/main/java/org/spongepowered/common/entity/SpongeEntitySnapshotBuilder.java @@ -74,7 +74,7 @@ public SpongeEntitySnapshotBuilder() { @Override public SpongeEntitySnapshotBuilder world(final ServerWorldProperties worldProperties) { - this.worldKey = Objects.requireNonNull(worldProperties).getKey(); + this.worldKey = Objects.requireNonNull(worldProperties).key(); return this; } @@ -112,12 +112,12 @@ public SpongeEntitySnapshotBuilder id(final UUID entityId) { public SpongeEntitySnapshotBuilder from(final Entity entity) { this.reset(); this.entityReference = new WeakReference<>(entity); - this.worldKey = entity.getServerLocation().getWorldKey(); - this.position = entity.getTransform().getPosition(); - this.rotation = entity.getTransform().getRotation(); - this.scale = entity.getTransform().getScale(); - this.entityType = entity.getType(); - this.uniqueId = entity.getUniqueId(); + this.worldKey = entity.serverLocation().worldKey(); + this.position = entity.transform().position(); + this.rotation = entity.transform().rotation(); + this.scale = entity.transform().scale(); + this.entityType = entity.type(); + this.uniqueId = entity.uniqueId(); this.manipulator = ((SpongeDataHolderBridge) entity).bridge$getManipulator().copy(); this.compound = new CompoundTag(); ((net.minecraft.world.entity.Entity) entity).saveWithoutId(this.compound); @@ -139,17 +139,17 @@ public EntitySnapshot.Builder add(final Key> key, final V @Override public SpongeEntitySnapshotBuilder from(final EntitySnapshot holder) { this.reset(); - this.entityType = holder.getType(); - this.worldKey = holder.getWorld(); - if (holder.getUniqueId().isPresent()) { - this.uniqueId = holder.getUniqueId().get(); + this.entityType = holder.type(); + this.worldKey = holder.world(); + if (holder.uniqueId().isPresent()) { + this.uniqueId = holder.uniqueId().get(); } - this.position = holder.getPosition().toDouble(); - final Optional optional = holder.getTransform(); + this.position = holder.position().toDouble(); + final Optional optional = holder.transform(); if (optional.isPresent()) { - this.position = optional.get().getPosition(); - this.rotation = optional.get().getRotation(); - this.scale = optional.get().getScale(); + this.position = optional.get().position(); + this.rotation = optional.get().rotation(); + this.scale = optional.get().scale(); } this.manipulator = DataManipulator.mutableOf(holder); if (holder instanceof SpongeEntitySnapshot) { @@ -159,13 +159,13 @@ public SpongeEntitySnapshotBuilder from(final EntitySnapshot holder) { } public SpongeEntitySnapshotBuilder from(final net.minecraft.world.entity.Entity minecraftEntity) { - this.entityType = ((Entity) minecraftEntity).getType(); - this.worldKey = ((Entity) minecraftEntity).getServerLocation().getWorldKey(); + this.entityType = ((Entity) minecraftEntity).type(); + this.worldKey = ((Entity) minecraftEntity).serverLocation().worldKey(); this.uniqueId = minecraftEntity.getUUID(); - final Transform transform = ((Entity) minecraftEntity).getTransform(); - this.position = transform.getPosition(); - this.rotation = transform.getRotation(); - this.scale = transform.getScale(); + final Transform transform = ((Entity) minecraftEntity).transform(); + this.position = transform.position(); + this.rotation = transform.rotation(); + this.scale = transform.scale(); this.manipulator = DataManipulator.mutableOf((Entity) minecraftEntity); this.compound = new CompoundTag(); minecraftEntity.saveWithoutId(this.compound); @@ -230,7 +230,7 @@ protected Optional buildContent(final DataView container) throws this.rotation = DataUtil.getPosition3d(container, Constants.Entity.ROTATION); this.scale = DataUtil.getPosition3d(container, Constants.Entity.SCALE); final String entityTypeId = container.getString(Constants.Entity.TYPE).get(); - this.entityType = Sponge.getGame().registries().registry(RegistryTypes.ENTITY_TYPE).value(ResourceKey.resolve(entityTypeId)); + this.entityType = Sponge.game().registries().registry(RegistryTypes.ENTITY_TYPE).value(ResourceKey.resolve(entityTypeId)); this.manipulator = null; // lazy read from nbt if (container.contains(Constants.Sponge.UNSAFE_NBT)) { this.compound = NBTTranslator.INSTANCE.translate(container.getView(Constants.Sponge.UNSAFE_NBT).get()); diff --git a/src/main/java/org/spongepowered/common/entity/ai/SpongeWatchClosestAIBuilder.java b/src/main/java/org/spongepowered/common/entity/ai/SpongeWatchClosestAIBuilder.java index 86a1b8b4106..b5ffa00860f 100644 --- a/src/main/java/org/spongepowered/common/entity/ai/SpongeWatchClosestAIBuilder.java +++ b/src/main/java/org/spongepowered/common/entity/ai/SpongeWatchClosestAIBuilder.java @@ -61,9 +61,9 @@ public LookAtGoal.Builder chance(float chance) { @Override public LookAtGoal.Builder from(LookAtGoal value) { - return this.watch(value.getWatchedClass()) - .maxDistance(value.getMaxDistance()) - .chance(value.getChance()); + return this.watch(value.watchedClass()) + .maxDistance(value.maxDistance()) + .chance(value.chance()); } @Override diff --git a/src/main/java/org/spongepowered/common/entity/ai/goal/SpongeGoalType.java b/src/main/java/org/spongepowered/common/entity/ai/goal/SpongeGoalType.java index 761e5918e9a..40102837431 100644 --- a/src/main/java/org/spongepowered/common/entity/ai/goal/SpongeGoalType.java +++ b/src/main/java/org/spongepowered/common/entity/ai/goal/SpongeGoalType.java @@ -37,7 +37,7 @@ public SpongeGoalType(final Class> goalClass) { } @Override - public Class> getGoalClass() { + public Class> goalClass() { return this.goalClass; } } diff --git a/src/main/java/org/spongepowered/common/entity/ai/goal/builtin/SpongeSwimGoalBuilder.java b/src/main/java/org/spongepowered/common/entity/ai/goal/builtin/SpongeSwimGoalBuilder.java index 511604016bd..30bb524e91b 100644 --- a/src/main/java/org/spongepowered/common/entity/ai/goal/builtin/SpongeSwimGoalBuilder.java +++ b/src/main/java/org/spongepowered/common/entity/ai/goal/builtin/SpongeSwimGoalBuilder.java @@ -47,7 +47,7 @@ public SwimGoal.Builder swimChance(float chance) { @Override public SwimGoal.Builder from(SwimGoal value) { checkNotNull(value); - return this.swimChance(value.getSwimChance()); + return this.swimChance(value.swimChance()); } @Override diff --git a/src/main/java/org/spongepowered/common/entity/ai/goal/builtin/creature/SpongeAttackLivingGoalBuilder.java b/src/main/java/org/spongepowered/common/entity/ai/goal/builtin/creature/SpongeAttackLivingGoalBuilder.java index cf9ae80153f..5b3d6ddc315 100644 --- a/src/main/java/org/spongepowered/common/entity/ai/goal/builtin/creature/SpongeAttackLivingGoalBuilder.java +++ b/src/main/java/org/spongepowered/common/entity/ai/goal/builtin/creature/SpongeAttackLivingGoalBuilder.java @@ -53,7 +53,7 @@ public AttackLivingGoal.Builder longMemory() { @Override public AttackLivingGoal.Builder from(AttackLivingGoal value) { - return this.speed(value.getSpeed()) + return this.speed(value.speed()) .longMemory(); } diff --git a/src/main/java/org/spongepowered/common/entity/ai/goal/builtin/creature/SpongeAvoidLivingGoalBuilder.java b/src/main/java/org/spongepowered/common/entity/ai/goal/builtin/creature/SpongeAvoidLivingGoalBuilder.java index 6ecf92c30a3..dc6315c1161 100644 --- a/src/main/java/org/spongepowered/common/entity/ai/goal/builtin/creature/SpongeAvoidLivingGoalBuilder.java +++ b/src/main/java/org/spongepowered/common/entity/ai/goal/builtin/creature/SpongeAvoidLivingGoalBuilder.java @@ -69,10 +69,10 @@ public AvoidLivingGoal.Builder farRangeSpeed(double speed) { @Override public AvoidLivingGoal.Builder from(AvoidLivingGoal value) { - return this.targetSelector(value.getTargetSelector()) - .searchDistance(value.getSearchDistance()) - .closeRangeSpeed(value.getCloseRangeSpeed()) - .farRangeSpeed(value.getFarRangeSpeed()); + return this.targetSelector(value.targetSelector()) + .searchDistance(value.searchDistance()) + .closeRangeSpeed(value.closeRangeSpeed()) + .farRangeSpeed(value.farRangeSpeed()); } @Override diff --git a/src/main/java/org/spongepowered/common/entity/ai/goal/builtin/creature/SpongeRandomWalkingGoalBuilder.java b/src/main/java/org/spongepowered/common/entity/ai/goal/builtin/creature/SpongeRandomWalkingGoalBuilder.java index 8035ac9c0be..e425c4c2e69 100644 --- a/src/main/java/org/spongepowered/common/entity/ai/goal/builtin/creature/SpongeRandomWalkingGoalBuilder.java +++ b/src/main/java/org/spongepowered/common/entity/ai/goal/builtin/creature/SpongeRandomWalkingGoalBuilder.java @@ -52,8 +52,8 @@ public RandomWalkingGoal.Builder executionChance(int executionChance) { @Override public RandomWalkingGoal.Builder from(RandomWalkingGoal value) { - return this.speed(value.getSpeed()) - .executionChance(value.getExecutionChance()); + return this.speed(value.speed()) + .executionChance(value.executionChance()); } @Override diff --git a/src/main/java/org/spongepowered/common/entity/ai/goal/builtin/creature/SpongeRangedAttackAgainstAgentGoalBuilder.java b/src/main/java/org/spongepowered/common/entity/ai/goal/builtin/creature/SpongeRangedAttackAgainstAgentGoalBuilder.java index f230e09fa05..a9e4968bd1c 100644 --- a/src/main/java/org/spongepowered/common/entity/ai/goal/builtin/creature/SpongeRangedAttackAgainstAgentGoalBuilder.java +++ b/src/main/java/org/spongepowered/common/entity/ai/goal/builtin/creature/SpongeRangedAttackAgainstAgentGoalBuilder.java @@ -63,9 +63,9 @@ public RangedAttackAgainstAgentGoal.Builder attackRadius(float radius) { @Override public RangedAttackAgainstAgentGoal.Builder from(RangedAttackAgainstAgentGoal value) { checkNotNull(value); - this.maxSpeed = value.getMoveSpeed(); - this.delayBetweenAttacks = value.getDelayBetweenAttacks(); - this.attackRadius = value.getAttackRadius(); + this.maxSpeed = value.moveSpeed(); + this.delayBetweenAttacks = value.delayBetweenAttacks(); + this.attackRadius = value.attackRadius(); return this; } diff --git a/src/main/java/org/spongepowered/common/entity/ai/goal/builtin/creature/horse/SpongeRunAroundLikeCrazyAIBuilder.java b/src/main/java/org/spongepowered/common/entity/ai/goal/builtin/creature/horse/SpongeRunAroundLikeCrazyAIBuilder.java index 6fcb8600a1a..cfd8e8a6de6 100644 --- a/src/main/java/org/spongepowered/common/entity/ai/goal/builtin/creature/horse/SpongeRunAroundLikeCrazyAIBuilder.java +++ b/src/main/java/org/spongepowered/common/entity/ai/goal/builtin/creature/horse/SpongeRunAroundLikeCrazyAIBuilder.java @@ -48,7 +48,7 @@ public RunAroundLikeCrazyGoal.Builder speed(double speed) { public RunAroundLikeCrazyGoal.Builder from(RunAroundLikeCrazyGoal value) { checkNotNull(value); - return this.speed(value.getSpeed()); + return this.speed(value.speed()); } @Override diff --git a/src/main/java/org/spongepowered/common/entity/ai/goal/builtin/creature/target/SpongeFindNearestAttackableTargetGoalBuilder.java b/src/main/java/org/spongepowered/common/entity/ai/goal/builtin/creature/target/SpongeFindNearestAttackableTargetGoalBuilder.java index b06d1bf2f38..655de7b5eae 100644 --- a/src/main/java/org/spongepowered/common/entity/ai/goal/builtin/creature/target/SpongeFindNearestAttackableTargetGoalBuilder.java +++ b/src/main/java/org/spongepowered/common/entity/ai/goal/builtin/creature/target/SpongeFindNearestAttackableTargetGoalBuilder.java @@ -72,11 +72,11 @@ public FindNearestAttackableTargetGoal.Builder filter(Predicate) (Predicate) value.getFilter(); + this.chance = value.chance(); + this.predicate = (Predicate) (Predicate) value.filter(); return this; } diff --git a/src/main/java/org/spongepowered/common/entity/living/human/HumanEntity.java b/src/main/java/org/spongepowered/common/entity/living/human/HumanEntity.java index 2231feb0995..ea145aef3a9 100644 --- a/src/main/java/org/spongepowered/common/entity/living/human/HumanEntity.java +++ b/src/main/java/org/spongepowered/common/entity/living/human/HumanEntity.java @@ -35,7 +35,6 @@ import net.minecraft.network.protocol.Packet; import net.minecraft.network.protocol.game.ClientboundAddPlayerPacket; import net.minecraft.network.protocol.game.ClientboundPlayerInfoPacket; -import net.minecraft.network.protocol.game.ClientboundPlayerInfoPacket.PlayerUpdate; import net.minecraft.network.protocol.game.ClientboundRemoveEntitiesPacket; import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; @@ -161,7 +160,7 @@ public boolean isNoAi() { } @Override - public Component getTeamRepresentation() { + public Component teamRepresentation() { return Component.text(this.fakeProfile.getName()); } @@ -385,7 +384,7 @@ public void removeFromTabListDelayed(@Nullable final ServerPlayer player, final if (delay == 0) { removeTask.run(); } else { - Sponge.getServer().getScheduler().submit(Task.builder() + Sponge.server().scheduler().submit(Task.builder() .execute(removeTask) .delay(new SpongeTicks(delay)) .plugin(Launch.getInstance().getCommonPlugin()) diff --git a/src/main/java/org/spongepowered/common/entity/player/SpongeUser.java b/src/main/java/org/spongepowered/common/entity/player/SpongeUser.java index f59187d0762..056396ddaca 100644 --- a/src/main/java/org/spongepowered/common/entity/player/SpongeUser.java +++ b/src/main/java/org/spongepowered/common/entity/player/SpongeUser.java @@ -145,7 +145,7 @@ public boolean isInitialized() { public DataHolder.Mutable getDataHolder(final boolean markDirty) { if (this.isOnline()) { - return this.getPlayer().get(); + return this.player().get(); } if (!this.isInitialized()) { this.initialize(); @@ -179,7 +179,7 @@ public void initialize() { return; } - final LevelStorageSource.LevelStorageAccess storageSource = ((MinecraftServerAccessor) Sponge.getServer()).accessor$storageSource(); + final LevelStorageSource.LevelStorageAccess storageSource = ((MinecraftServerAccessor) Sponge.server()).accessor$storageSource(); final File file = storageSource.getLevelPath(LevelResource.PLAYER_DATA_DIR).resolve(this.profile.getId().toString() + ".dat").toFile(); if (!file.exists()) { return; @@ -243,7 +243,7 @@ public void readCompound(final CompoundTag compound) { public void writeCompound(final CompoundTag compound) { - compound.putString(Constants.Sponge.World.WORLD_KEY, this.worldKey.getFormatted()); + compound.putString(Constants.Sponge.World.WORLD_KEY, this.worldKey.formatted()); this.loadInventory(); this.loadEnderInventory(); @@ -259,17 +259,17 @@ public void writeCompound(final CompoundTag compound) { } @Override - public UUID getUniqueId() { + public UUID uniqueId() { return this.profile.getId(); } @Override - public String getName() { + public String name() { return this.profile.getName(); } @Override - public int getContentVersion() { + public int contentVersion() { return 1; } @@ -277,7 +277,7 @@ public int getContentVersion() { public DataContainer toContainer() { // TODO More data return DataContainer.createNew() - .set(Queries.CONTENT_VERSION, this.getContentVersion()) + .set(Queries.CONTENT_VERSION, this.contentVersion()) .set(Constants.Entity.Player.UUID, this.profile.getId()) .set(Constants.Entity.Player.NAME, this.profile.getName()) .set(Constants.Entity.Player.SPAWNS, this.spawnLocations); @@ -294,8 +294,8 @@ public boolean canEquip(final EquipmentType type, @Nullable final ItemStack equi } @Override - public Optional getEquipped(final EquipmentType type) { - throw new MissingImplementationException("SpongeUser", "getEquipped"); + public Optional equipped(final EquipmentType type) { + throw new MissingImplementationException("SpongeUser", "equipped"); } @Override @@ -309,28 +309,28 @@ public boolean equip(final EquipmentType type, @Nullable final ItemStack equipme } @Override - public UserInventory getInventory() { + public UserInventory inventory() { return this.loadInventory(); } @Override - public EquipmentInventory getEquipment() { - return this.getInventory().getEquipment(); + public EquipmentInventory equipment() { + return this.inventory().equipment(); } @Override - public ItemStack getItemInHand(final HandType handType) { + public ItemStack itemInHand(final HandType handType) { if (handType == HandTypes.MAIN_HAND.get()) { - this.getEquipped(EquipmentTypes.MAIN_HAND).orElseThrow(IllegalStateException::new); + this.equipped(EquipmentTypes.MAIN_HAND).orElseThrow(IllegalStateException::new); } else if (handType == HandTypes.OFF_HAND.get()) { - this.getEquipped(EquipmentTypes.OFF_HAND).orElseThrow(IllegalStateException::new); + this.equipped(EquipmentTypes.OFF_HAND).orElseThrow(IllegalStateException::new); } throw new IllegalArgumentException("Invalid hand " + handType); } @Override - public ItemStack getHead() { - return this.getEquipped(EquipmentTypes.HEAD).orElseThrow(IllegalStateException::new); + public ItemStack head() { + return this.equipped(EquipmentTypes.HEAD).orElseThrow(IllegalStateException::new); } @Override @@ -339,8 +339,8 @@ public void setHead(final ItemStack helmet) { } @Override - public ItemStack getChest() { - return this.getEquipped(EquipmentTypes.CHEST).orElseThrow(IllegalStateException::new); + public ItemStack chest() { + return this.equipped(EquipmentTypes.CHEST).orElseThrow(IllegalStateException::new); } @Override @@ -349,8 +349,8 @@ public void setChest(final ItemStack chestplate) { } @Override - public ItemStack getLegs() { - return this.getEquipped(EquipmentTypes.LEGS).orElseThrow(IllegalStateException::new); + public ItemStack legs() { + return this.equipped(EquipmentTypes.LEGS).orElseThrow(IllegalStateException::new); } @Override @@ -359,8 +359,8 @@ public void setLegs(final ItemStack leggings) { } @Override - public ItemStack getFeet() { - return this.getEquipped(EquipmentTypes.FEET).orElseThrow(IllegalStateException::new); + public ItemStack feet() { + return this.equipped(EquipmentTypes.FEET).orElseThrow(IllegalStateException::new); } @Override @@ -381,7 +381,7 @@ public void setItemInHand(final HandType handType, @Nullable final ItemStack ite @Override public Map bridge$getBedlocations() { - final Optional player = this.getPlayer(); + final Optional player = this.player(); return player .map(value -> ((BedLocationHolderBridge) value).bridge$getBedlocations()) .orElse(this.spawnLocations); @@ -389,7 +389,7 @@ public void setItemInHand(final HandType handType, @Nullable final ItemStack ite @Override public boolean bridge$setBedLocations(final Map value) { - final Optional player = this.getPlayer(); + final Optional player = this.player(); if (player.isPresent()) { return ((BedLocationHolderBridge) player.get()).bridge$setBedLocations(value); } @@ -406,7 +406,7 @@ public void setItemInHand(final HandType handType, @Nullable final ItemStack ite @Override public ImmutableMap bridge$removeAllBeds() { - final Optional player = this.getPlayer(); + final Optional player = this.player(); if (player.isPresent()) { return ((BedLocationHolderBridge) player.get()).bridge$removeAllBeds(); } @@ -433,8 +433,8 @@ public void markDirty() { public void save() { Preconditions.checkState(this.isInitialized(), "User {} is not initialized", this.profile.getId()); - final LevelStorageSource.LevelStorageAccess storageSource = ((MinecraftServerAccessor) Sponge.getServer()).accessor$storageSource(); - final File file = storageSource.getLevelPath(LevelResource.PLAYER_DATA_DIR).resolve(this.getUniqueId() + ".dat").toFile(); + final LevelStorageSource.LevelStorageAccess storageSource = ((MinecraftServerAccessor) Sponge.server()).accessor$storageSource(); + final File file = storageSource.getLevelPath(LevelResource.PLAYER_DATA_DIR).resolve(this.uniqueId() + ".dat").toFile(); CompoundTag compound; try { compound = NbtIo.readCompressed(new FileInputStream(file)); @@ -487,31 +487,31 @@ private void setItemStackToSlot(final EquipmentSlot slotIn, final net.minecraft. } @Override - public org.spongepowered.api.profile.GameProfile getProfile() { + public org.spongepowered.api.profile.GameProfile profile() { return SpongeGameProfile.of(this.profile); } @Override public boolean isOnline() { - return this.getPlayer().isPresent(); + return this.player().isPresent(); } @Override - public Optional getPlayer() { + public Optional player() { return Optional.ofNullable((ServerPlayer) SpongeCommon.getServer().getPlayerList().getPlayer(this.profile.getId())); } @Override - public Vector3d getPosition() { - return this.getPlayer() - .map(Player::getPosition) + public Vector3d position() { + return this.player() + .map(Player::position) .orElseGet(() -> new Vector3d(this.x, this.y, this.z)); } @Override - public ResourceKey getWorldKey() { - final Optional player = this.getPlayer(); - return player.map(serverPlayer -> serverPlayer.getWorld().getKey()).orElseGet(() -> this.worldKey); + public ResourceKey worldKey() { + final Optional player = this.player(); + return player.map(serverPlayer -> serverPlayer.world().key()).orElseGet(() -> this.worldKey); } @@ -520,9 +520,9 @@ public boolean setLocation(final ResourceKey key, final Vector3d position) { Preconditions.checkNotNull(key); Preconditions.checkNotNull(position); - final Optional player = this.getPlayer(); + final Optional player = this.player(); if (player.isPresent()) { - final Optional world = Sponge.getServer().getWorldManager().world(key); + final Optional world = Sponge.server().worldManager().world(key); return world.filter(serverWorld -> player.get().setLocation(ServerLocation.of(serverWorld, position))).isPresent(); } @@ -535,16 +535,16 @@ public boolean setLocation(final ResourceKey key, final Vector3d position) { } @Override - public Vector3d getRotation() { - return this.getPlayer() - .map(Entity::getRotation) + public Vector3d rotation() { + return this.player() + .map(Entity::rotation) .orElseGet(() -> new Vector3d(this.pitch, this.yaw, 0)); } @Override public void setRotation(final Vector3d rotation) { Preconditions.checkNotNull(rotation, "Rotation was null!"); - final Optional playerOpt = this.getPlayer(); + final Optional playerOpt = this.player(); if (playerOpt.isPresent()) { playerOpt.get().setRotation(rotation); return; @@ -555,15 +555,15 @@ public void setRotation(final Vector3d rotation) { } @Override - public String getIdentifier() { + public String identifier() { return this.profile.getId().toString(); } @Override - public Inventory getEnderChestInventory() { - final Optional playerOpt = this.getPlayer(); + public Inventory enderChestInventory() { + final Optional playerOpt = this.player(); if (playerOpt.isPresent()) { - return playerOpt.get().getEnderChestInventory(); + return playerOpt.get().enderChestInventory(); } this.loadEnderInventory(); return ((Inventory) this.enderChest); @@ -605,7 +605,7 @@ public Inventory getEnderChestInventory() { @Override public void bridge$setVanished(final boolean vanished) { - final Optional playerOpt = this.getPlayer(); + final Optional playerOpt = this.player(); if (playerOpt.isPresent()) { ((VanishableBridge) playerOpt.get()).bridge$setVanished(vanished); return; @@ -623,17 +623,17 @@ public Inventory getEnderChestInventory() { @Override public boolean bridge$isVanished() { - return this.getPlayer().map(player -> ((VanishableBridge) player).bridge$isVanished()).orElseGet(() -> this.isVanished); + return this.player().map(player -> ((VanishableBridge) player).bridge$isVanished()).orElseGet(() -> this.isVanished); } @Override public boolean bridge$isInvisible() { - return this.getPlayer().map(player -> ((VanishableBridge) player).bridge$isInvisible()).orElseGet(() -> this.isInvisible); + return this.player().map(player -> ((VanishableBridge) player).bridge$isInvisible()).orElseGet(() -> this.isInvisible); } @Override public void bridge$setInvisible(final boolean invisible) { - final Optional player = this.getPlayer(); + final Optional player = this.player(); if (player.isPresent()) { ((VanishableBridge) player.get()).bridge$setInvisible(invisible); return; @@ -648,12 +648,12 @@ public Inventory getEnderChestInventory() { @Override public boolean bridge$isVanishIgnoresCollision() { - return this.getPlayer().map(player -> ((VanishableBridge) player).bridge$isVanishIgnoresCollision()).orElseGet(() -> this.vanishIgnoresCollision); + return this.player().map(player -> ((VanishableBridge) player).bridge$isVanishIgnoresCollision()).orElseGet(() -> this.vanishIgnoresCollision); } @Override public void bridge$setVanishIgnoresCollision(final boolean vanishIgnoresCollision) { - final Optional player = this.getPlayer(); + final Optional player = this.player(); if (player.isPresent()) { ((VanishableBridge) player.get()).bridge$setVanishIgnoresCollision(vanishIgnoresCollision); return; @@ -668,12 +668,12 @@ public Inventory getEnderChestInventory() { @Override public boolean bridge$isVanishPreventsTargeting() { - return this.getPlayer().map(player -> ((VanishableBridge) player).bridge$isVanishPreventsTargeting()).orElseGet(() -> this.vanishPreventsTargeting); + return this.player().map(player -> ((VanishableBridge) player).bridge$isVanishPreventsTargeting()).orElseGet(() -> this.vanishPreventsTargeting); } @Override public void bridge$setVanishPreventsTargeting(final boolean vanishPreventsTargeting) { - final Optional player = this.getPlayer(); + final Optional player = this.player(); if (player.isPresent()) { ((VanishableBridge) player.get()).bridge$setVanishPreventsTargeting(vanishPreventsTargeting); return; @@ -722,7 +722,7 @@ public int hashCode() { public String toString() { return MoreObjects.toStringHelper(this) .add("isOnline", this.isOnline()) - .add("profile", this.getProfile()) + .add("profile", this.profile()) .toString(); } @@ -732,11 +732,11 @@ public String toString() { } public Boolean isInvulnerable() { - return this.getPlayer().map(player -> ((net.minecraft.world.entity.Entity) player).isInvulnerable()).orElse(this.invulnerable); + return this.player().map(player -> ((net.minecraft.world.entity.Entity) player).isInvulnerable()).orElse(this.invulnerable); } public void setInvulnerable(boolean invulnerable) { - final Optional playerOpt = this.getPlayer(); + final Optional playerOpt = this.player(); if (playerOpt.isPresent()) { ((net.minecraft.world.entity.Entity) playerOpt.get()).setInvulnerable(invulnerable); return; diff --git a/src/main/java/org/spongepowered/common/entity/player/tab/SpongeTabList.java b/src/main/java/org/spongepowered/common/entity/player/tab/SpongeTabList.java index 70ca8d8cc5a..2e18bc186dc 100644 --- a/src/main/java/org/spongepowered/common/entity/player/tab/SpongeTabList.java +++ b/src/main/java/org/spongepowered/common/entity/player/tab/SpongeTabList.java @@ -33,7 +33,6 @@ import net.kyori.adventure.text.Component; import net.minecraft.network.chat.TextComponent; import net.minecraft.network.protocol.game.ClientboundPlayerInfoPacket; -import net.minecraft.network.protocol.game.ClientboundPlayerInfoPacket.PlayerUpdate; import net.minecraft.network.protocol.game.ClientboundTabListPacket; import net.minecraft.world.level.GameType; import org.checkerframework.checker.nullness.qual.Nullable; @@ -65,12 +64,12 @@ public SpongeTabList(final net.minecraft.server.level.ServerPlayer player) { } @Override - public ServerPlayer getPlayer() { + public ServerPlayer player() { return (ServerPlayer) this.player; } @Override - public Optional getHeader() { + public Optional header() { return Optional.ofNullable(this.header); } @@ -84,7 +83,7 @@ public TabList setHeader(final @Nullable Component header) { } @Override - public Optional getFooter() { + public Optional footer() { return Optional.ofNullable(this.footer); } @@ -118,12 +117,12 @@ private void refreshClientHeaderFooter() { } @Override - public Collection getEntries() { + public Collection entries() { return Collections.unmodifiableCollection(this.entries.values()); } @Override - public Optional getEntry(final UUID uniqueId) { + public Optional entry(final UUID uniqueId) { checkNotNull(uniqueId, "unique id"); return Optional.ofNullable(this.entries.get(uniqueId)); } @@ -131,7 +130,7 @@ public Optional getEntry(final UUID uniqueId) { @Override public TabList addEntry(final TabListEntry entry) throws IllegalArgumentException { checkNotNull(entry, "builder"); - checkState(entry.getList().equals(this), "the provided tab list entry was not created for this tab list"); + checkState(entry.list().equals(this), "the provided tab list entry was not created for this tab list"); this.addEntry(entry, true); @@ -151,7 +150,7 @@ private void addEntry(final ClientboundPlayerInfoPacket.PlayerUpdate entry) { } private void addEntry(final TabListEntry entry, final boolean exceptionOnDuplicate) { - final UUID uniqueId = entry.getProfile().getUniqueId(); + final UUID uniqueId = entry.profile().uniqueId(); if (exceptionOnDuplicate) { checkArgument(!this.entries.containsKey(uniqueId), "cannot add duplicate entry"); @@ -161,7 +160,7 @@ private void addEntry(final TabListEntry entry, final boolean exceptionOnDuplica this.entries.put(uniqueId, entry); this.sendUpdate(entry, ClientboundPlayerInfoPacket.Action.ADD_PLAYER); - entry.getDisplayName().ifPresent(text -> this.sendUpdate(entry, ClientboundPlayerInfoPacket.Action.UPDATE_DISPLAY_NAME)); + entry.displayName().ifPresent(text -> this.sendUpdate(entry, ClientboundPlayerInfoPacket.Action.UPDATE_DISPLAY_NAME)); this.sendUpdate(entry, ClientboundPlayerInfoPacket.Action.UPDATE_LATENCY); this.sendUpdate(entry, ClientboundPlayerInfoPacket.Action.UPDATE_GAME_MODE); } @@ -189,9 +188,9 @@ public Optional removeEntry(final UUID uniqueId) { void sendUpdate(final TabListEntry entry, final ClientboundPlayerInfoPacket.Action action) { final ClientboundPlayerInfoPacket packet = new ClientboundPlayerInfoPacket(); ((ClientboundPlayerInfoPacketAccessor) packet).accessor$action(action); - final ClientboundPlayerInfoPacket.PlayerUpdate data = packet.new PlayerUpdate(SpongeGameProfile.toMcProfile(entry.getProfile()), - entry.getLatency(), (GameType) (Object) entry.getGameMode(), - entry.getDisplayName().isPresent() ? SpongeAdventure.asVanilla(entry.getDisplayName().get()) : null); + final ClientboundPlayerInfoPacket.PlayerUpdate data = packet.new PlayerUpdate(SpongeGameProfile.toMcProfile(entry.profile()), + entry.latency(), (GameType) (Object) entry.gameMode(), + entry.displayName().isPresent() ? SpongeAdventure.asVanilla(entry.displayName().get()) : null); ((ClientboundPlayerInfoPacketAccessor) packet).accessor$entries().add(data); this.player.connection.send(packet); } @@ -214,7 +213,7 @@ public void updateEntriesOnSend(final ClientboundPlayerInfoPacket packet) { } else if (action == ClientboundPlayerInfoPacket.Action.REMOVE_PLAYER) { this.removeEntry(data.getProfile().getId()); } else { - this.getEntry(data.getProfile().getId()).ifPresent(entry -> { + this.entry(data.getProfile().getId()).ifPresent(entry -> { if (action == ClientboundPlayerInfoPacket.Action.UPDATE_DISPLAY_NAME) { ((SpongeTabListEntry) entry).updateWithoutSend(); entry.setDisplayName(data.getDisplayName() == null ? null : SpongeAdventure.asAdventure(data.getDisplayName())); diff --git a/src/main/java/org/spongepowered/common/entity/player/tab/SpongeTabListEntry.java b/src/main/java/org/spongepowered/common/entity/player/tab/SpongeTabListEntry.java index 25318fb5e59..2920eb9e0a2 100644 --- a/src/main/java/org/spongepowered/common/entity/player/tab/SpongeTabListEntry.java +++ b/src/main/java/org/spongepowered/common/entity/player/tab/SpongeTabListEntry.java @@ -62,17 +62,17 @@ public SpongeTabListEntry(TabList list, GameProfile profile, @Nullable Component } @Override - public TabList getList() { + public TabList list() { return this.list; } @Override - public GameProfile getProfile() { + public GameProfile profile() { return this.profile; } @Override - public Optional getDisplayName() { + public Optional displayName() { return Optional.ofNullable(this.displayName); } @@ -84,7 +84,7 @@ public TabListEntry setDisplayName(@Nullable Component displayName) { } @Override - public int getLatency() { + public int latency() { return this.latency; } @@ -96,7 +96,7 @@ public TabListEntry setLatency(int latency) { } @Override - public GameMode getGameMode() { + public GameMode gameMode() { return this.gameMode; } @@ -136,7 +136,7 @@ public boolean equals(@Nullable Object other) { } TabListEntry that = (TabListEntry) other; - return Objects.equal(this.profile.getUniqueId(), that.getProfile().getUniqueId()); + return Objects.equal(this.profile.uniqueId(), that.profile().uniqueId()); } @Override diff --git a/src/main/java/org/spongepowered/common/entity/player/tab/TabListEntryBuilder.java b/src/main/java/org/spongepowered/common/entity/player/tab/TabListEntryBuilder.java index ef1810c6f93..1ffbd0b23ef 100644 --- a/src/main/java/org/spongepowered/common/entity/player/tab/TabListEntryBuilder.java +++ b/src/main/java/org/spongepowered/common/entity/player/tab/TabListEntryBuilder.java @@ -84,11 +84,11 @@ public TabListEntry build() { @Override public TabListEntry.Builder from(TabListEntry value) { - this.list = checkNotNull(value.getList(), "list"); - this.profile = checkNotNull(value.getProfile(), "profile"); - this.displayName = value.getDisplayName().orElse(null); - this.latency = value.getLatency(); - this.gameMode = checkNotNull(value.getGameMode(), "game mode"); + this.list = checkNotNull(value.list(), "list"); + this.profile = checkNotNull(value.profile(), "profile"); + this.displayName = value.displayName().orElse(null); + this.latency = value.latency(); + this.gameMode = checkNotNull(value.gameMode(), "game mode"); return this; } diff --git a/src/main/java/org/spongepowered/common/entity/projectile/DispenserSourceLogic.java b/src/main/java/org/spongepowered/common/entity/projectile/DispenserSourceLogic.java index 956a7a20805..e8e2550bd0c 100644 --- a/src/main/java/org/spongepowered/common/entity/projectile/DispenserSourceLogic.java +++ b/src/main/java/org/spongepowered/common/entity/projectile/DispenserSourceLogic.java @@ -53,7 +53,7 @@ public

Optional

launch(final ProjectileLogic

logic, if (args.length == 1 && args[0] instanceof Item) { return this.launch((DispenserBlockEntity) source, projectileType, (Item) args[0]); } - final Optional

projectile = logic.createProjectile(source, projectileType, source.getLocation()); + final Optional

projectile = logic.createProjectile(source, projectileType, source.location()); if (projectile.isPresent()) { final Direction enumfacing = DispenserSourceLogic.getFacing((DispenserBlockEntity) source); final net.minecraft.world.entity.Entity projectileEntity = (net.minecraft.world.entity.Entity) projectile.get(); diff --git a/src/main/java/org/spongepowered/common/entity/projectile/ProjectileUtil.java b/src/main/java/org/spongepowered/common/entity/projectile/ProjectileUtil.java index c8e19668518..5403375732f 100644 --- a/src/main/java/org/spongepowered/common/entity/projectile/ProjectileUtil.java +++ b/src/main/java/org/spongepowered/common/entity/projectile/ProjectileUtil.java @@ -154,11 +154,11 @@ private static ProjectileLogic getLogic(final EntityTy @SuppressWarnings("unchecked") static

Optional

defaultLaunch(final ProjectileSource source, final EntityType

projectileType, final ServerLocation loc) { - final Entity projectile = loc.getWorld().createEntity(projectileType, loc.getPosition()); + final Entity projectile = loc.world().createEntity(projectileType, loc.position()); if (projectile instanceof ThrowableProjectile) { ProjectileUtil.configureThrowable((ThrowableProjectile) projectile); } - return ProjectileUtil.doLaunch(loc.getWorld(), (P) projectile); + return ProjectileUtil.doLaunch(loc.world(), (P) projectile); } static

Optional

doLaunch(final World extent, final P projectile) { @@ -179,7 +179,7 @@ static

Optional

doLaunch(final World extent, final P p protected Optional createProjectile(final LivingEntity source, final ServerLocation loc) { final net.minecraft.world.entity.projectile.Arrow arrow = new net.minecraft.world.entity.projectile.Arrow(source.level, source); arrow.shoot(source.xRot, source.yRot, 0.0F, 3.0F, 0); - return ProjectileUtil.doLaunch(loc.getWorld(), (Arrow) arrow); + return ProjectileUtil.doLaunch(loc.world(), (Arrow) arrow); } }); ProjectileUtil.registerProjectileLogic(EntityTypes.SPECTRAL_ARROW, new SimpleItemLaunchLogic( @@ -189,7 +189,7 @@ protected Optional createProjectile(final LivingEntity source, final Serv protected Optional createProjectile(final LivingEntity source, final ServerLocation loc) { final net.minecraft.world.entity.projectile.SpectralArrow arrow = new net.minecraft.world.entity.projectile.SpectralArrow(source.level, source); arrow.shoot(source.xRot, source.yRot, 0.0F, 3.0F, 0); - return ProjectileUtil.doLaunch(loc.getWorld(), (SpectralArrow) arrow); + return ProjectileUtil.doLaunch(loc.world(), (SpectralArrow) arrow); } }); ProjectileUtil.registerProjectileLogic(EntityTypes.EGG, new SimpleItemLaunchLogic(EntityTypes.EGG, Items.EGG) { @@ -198,7 +198,7 @@ protected Optional createProjectile(final LivingEntity source, fi protected Optional createProjectile(final LivingEntity source, final ServerLocation loc) { final ThrownEgg egg = new ThrownEgg(source.level, source); egg.shoot(source.xRot, source.yRot, 0.0F, 1.5F, 0); - return ProjectileUtil.doLaunch(loc.getWorld(), (Egg) egg); + return ProjectileUtil.doLaunch(loc.world(), (Egg) egg); } }); ProjectileUtil.registerProjectileLogic(EntityTypes.SMALL_FIREBALL, new SimpleItemLaunchLogic( @@ -210,7 +210,7 @@ protected Optional createProjectile(final LivingEntity source, fi final net.minecraft.world.entity.projectile.SmallFireball fireball = new net.minecraft.world.entity.projectile.SmallFireball(source.level, source, lookVec.x * 4, lookVec.y * 4, lookVec.z * 4); fireball.setPos(fireball.getX(), fireball.getY() + source.getEyeHeight(), fireball.getZ()); - return ProjectileUtil.doLaunch(loc.getWorld(), (SmallFireball) fireball); + return ProjectileUtil.doLaunch(loc.world(), (SmallFireball) fireball); } }); ProjectileUtil.registerProjectileLogic(EntityTypes.FIREWORK_ROCKET, new SimpleItemLaunchLogic( @@ -218,8 +218,8 @@ protected Optional createProjectile(final LivingEntity source, fi @Override protected Optional createProjectile(final LivingEntity source, final ServerLocation loc) { - final FireworkRocketEntity firework = new FireworkRocketEntity(source.level, loc.getX(), loc.getY(), loc.getZ(), ItemStack.EMPTY); - return ProjectileUtil.doLaunch(loc.getWorld(), (FireworkRocket) firework); + final FireworkRocketEntity firework = new FireworkRocketEntity(source.level, loc.x(), loc.y(), loc.z(), ItemStack.EMPTY); + return ProjectileUtil.doLaunch(loc.world(), (FireworkRocket) firework); } }); ProjectileUtil.registerProjectileLogic(EntityTypes.SNOWBALL, new SimpleItemLaunchLogic(EntityTypes.SNOWBALL, Items.SNOWBALL) { @@ -228,7 +228,7 @@ protected Optional createProjectile(final LivingEntity source, f protected Optional createProjectile(final LivingEntity source, final ServerLocation loc) { final net.minecraft.world.entity.projectile.Snowball snowball = new net.minecraft.world.entity.projectile.Snowball(source.level, source); snowball.shoot(source.xRot, source.yRot, 0.0F, 1.5F, 0); - return ProjectileUtil.doLaunch(loc.getWorld(), (Snowball) snowball); + return ProjectileUtil.doLaunch(loc.world(), (Snowball) snowball); } }); ProjectileUtil.registerProjectileLogic(EntityTypes.EXPERIENCE_BOTTLE, new SimpleItemLaunchLogic( @@ -238,7 +238,7 @@ protected Optional createProjectile(final LivingEntity source, final S protected Optional createProjectile(final LivingEntity source, final ServerLocation loc) { final ThrownExperienceBottle expBottle = new ThrownExperienceBottle(source.level, source); expBottle.shoot(source.xRot, source.yRot, -20.0F, 0.7F, 0); - return ProjectileUtil.doLaunch(loc.getWorld(), (ExperienceBottle) expBottle); + return ProjectileUtil.doLaunch(loc.world(), (ExperienceBottle) expBottle); } }); @@ -249,7 +249,7 @@ protected Optional createProjectile(final LivingEntity source, protected Optional createProjectile(final LivingEntity source, final ServerLocation loc) { final ThrownEnderpearl pearl = new ThrownEnderpearl(source.level, source); pearl.shoot(source.xRot, source.yRot, 0.0F, 1.5F, 0); - return ProjectileUtil.doLaunch(loc.getWorld(), (EnderPearl) pearl); + return ProjectileUtil.doLaunch(loc.world(), (EnderPearl) pearl); } }); ProjectileUtil.registerProjectileLogic(EntityTypes.FIREBALL, new SimpleDispenserLaunchLogic(EntityTypes.FIREBALL) { @@ -260,7 +260,7 @@ protected Optional createProjectile(final LivingEntity source final LargeFireball fireball = new LargeFireball(source.level, source, lookVec.x * 4, lookVec.y * 4, lookVec.z * 4); fireball.setPos(fireball.getX(), fireball.getY() + source.getEyeHeight(), fireball.getZ()); - return ProjectileUtil.doLaunch(loc.getWorld(), (ExplosiveFireball) fireball); + return ProjectileUtil.doLaunch(loc.world(), (ExplosiveFireball) fireball); } @Override @@ -271,15 +271,15 @@ public Optional createProjectile(final ProjectileSource sourc } final DispenserBlockEntity dispenser = (DispenserBlockEntity) source; final Direction enumfacing = DispenserSourceLogic.getFacing(dispenser); - final LivingEntity thrower = new ArmorStand(dispenser.getLevel(), loc.getX() + enumfacing.getStepX(), - loc.getY() + enumfacing.getStepY(), loc.getZ() + enumfacing.getStepZ()); + final LivingEntity thrower = new ArmorStand(dispenser.getLevel(), loc.x() + enumfacing.getStepX(), + loc.y() + enumfacing.getStepY(), loc.z() + enumfacing.getStepZ()); final LargeFireball fireball = new LargeFireball(dispenser.getLevel(), thrower, 0, 0, 0); // Acceleration is set separately because the constructor applies a random value to it // As for 0.1; it is a reasonable default value fireball.xPower = enumfacing.getStepX() * 0.1; fireball.yPower = enumfacing.getStepY() * 0.1; fireball.zPower = enumfacing.getStepZ() * 0.1; - return ProjectileUtil.doLaunch(loc.getWorld(), (ExplosiveFireball) fireball); + return ProjectileUtil.doLaunch(loc.world(), (ExplosiveFireball) fireball); } }); ProjectileUtil.registerProjectileLogic(EntityTypes.WITHER_SKULL, new SimpleDispenserLaunchLogic(EntityTypes.WITHER_SKULL) { @@ -290,7 +290,7 @@ protected Optional createProjectile(final LivingEntity source, fina final net.minecraft.world.entity.projectile.WitherSkull skull = new net.minecraft.world.entity.projectile.WitherSkull(source.level, source, lookVec.x * 4, lookVec.y * 4, lookVec.z * 4); skull.setPos(skull.getX(), skull.getY() + source.getEyeHeight(), skull.getZ()); - return ProjectileUtil.doLaunch(loc.getWorld(), (WitherSkull) skull); + return ProjectileUtil.doLaunch(loc.world(), (WitherSkull) skull); } }); ProjectileUtil.registerProjectileLogic(EntityTypes.EYE_OF_ENDER, new SimpleDispenserLaunchLogic<>(EntityTypes.EYE_OF_ENDER)); @@ -300,8 +300,8 @@ protected Optional createProjectile(final LivingEntity source, fina @Override protected Optional createProjectile(final LivingEntity source, final ServerLocation loc) { if (source instanceof Player) { - final FishingHook hook = new FishingHook(source.level, (Player) source, loc.getX(), loc.getY(), loc.getZ()); - return ProjectileUtil.doLaunch(loc.getWorld(), (FishingBobber) hook); + final FishingHook hook = new FishingHook(source.level, (Player) source, loc.x(), loc.y(), loc.z()); + return ProjectileUtil.doLaunch(loc.world(), (FishingBobber) hook); } return super.createProjectile(source, loc); } @@ -313,7 +313,7 @@ protected Optional createProjectile(final LivingEntity source, final Ser final ThrownPotion potion = new ThrownPotion(source.level, source); potion.setItem(new ItemStack(Items.SPLASH_POTION, 1)); potion.shoot(source.xRot, source.yRot, -20.0F, 0.5F, 0); - return ProjectileUtil.doLaunch(loc.getWorld(), (Potion) potion); + return ProjectileUtil.doLaunch(loc.world(), (Potion) potion); } }); ProjectileUtil.registerProjectileLogic(EntityTypes.LLAMA_SPIT, new SimpleEntityLaunchLogic(EntityTypes.LLAMA_SPIT) { @@ -333,7 +333,7 @@ public Optional createProjectile(final ProjectileSource source, final net.minecraft.world.entity.projectile.LlamaSpit llamaSpit = new net.minecraft.world.entity.projectile.LlamaSpit(llama.level, (Llama) source); final net.minecraft.world.phys.Vec3 lookVec = llama.getViewVector(1); llamaSpit.shoot(lookVec.x, lookVec.y, lookVec.z, 1.5F, 0); - return ProjectileUtil.doLaunch(loc.getWorld(), (LlamaSpit) llamaSpit); + return ProjectileUtil.doLaunch(loc.world(), (LlamaSpit) llamaSpit); } }); ProjectileUtil.registerProjectileLogic(EntityTypes.DRAGON_FIREBALL, new SimpleDispenserLaunchLogic( @@ -345,7 +345,7 @@ protected Optional createProjectile(final LivingEntity source, f final net.minecraft.world.entity.projectile.DragonFireball fireball = new net.minecraft.world.entity.projectile.DragonFireball(source.level, source, lookVec.x * 4, lookVec.y * 4, lookVec.z * 4); fireball.setPos(fireball.getX(), fireball.getY() + source.getEyeHeight(), fireball.getZ()); - return ProjectileUtil.doLaunch(loc.getWorld(), (DragonFireball) fireball); + return ProjectileUtil.doLaunch(loc.world(), (DragonFireball) fireball); } }); ProjectileUtil.registerProjectileLogic(EntityTypes.SHULKER_BULLET, new SimpleEntityLaunchLogic<>(EntityTypes.SHULKER_BULLET)); diff --git a/src/main/java/org/spongepowered/common/entity/projectile/SimpleEntityLaunchLogic.java b/src/main/java/org/spongepowered/common/entity/projectile/SimpleEntityLaunchLogic.java index 1a7a60309eb..f3f325f5322 100644 --- a/src/main/java/org/spongepowered/common/entity/projectile/SimpleEntityLaunchLogic.java +++ b/src/main/java/org/spongepowered/common/entity/projectile/SimpleEntityLaunchLogic.java @@ -47,7 +47,7 @@ public Optional

launch(final ProjectileSource source) { if (!(source instanceof Entity)) { return Optional.empty(); } - final ServerLocation loc = ((Entity) source).getServerLocation().add(0, ((net.minecraft.world.entity.Entity) source).getBbHeight() / 2, 0); + final ServerLocation loc = ((Entity) source).serverLocation().add(0, ((net.minecraft.world.entity.Entity) source).getBbHeight() / 2, 0); if (source instanceof LivingEntity) { return this.createProjectile((LivingEntity) source, loc); } else { diff --git a/src/main/java/org/spongepowered/common/event/SpongeCommonEventFactory.java b/src/main/java/org/spongepowered/common/event/SpongeCommonEventFactory.java index 03d8d12da86..dda174b7ae7 100644 --- a/src/main/java/org/spongepowered/common/event/SpongeCommonEventFactory.java +++ b/src/main/java/org/spongepowered/common/event/SpongeCommonEventFactory.java @@ -51,7 +51,6 @@ import net.minecraft.world.level.block.DirectionalBlock; import net.minecraft.world.level.block.entity.JukeboxBlockEntity; import net.minecraft.world.level.block.piston.PistonStructureResolver; -import net.minecraft.world.level.dimension.DimensionType; import net.minecraft.world.level.saveddata.maps.MapIndex; import net.minecraft.world.level.saveddata.maps.MapItemSavedData; import net.minecraft.world.phys.BlockHitResult; @@ -114,7 +113,6 @@ import org.spongepowered.api.world.server.ServerLocation; import org.spongepowered.api.world.World; import org.spongepowered.api.world.explosion.Explosion; -import org.spongepowered.api.world.server.ServerWorld; import org.spongepowered.api.world.storage.WorldProperties; import org.spongepowered.common.SpongeCommon; import org.spongepowered.common.adventure.SpongeAdventure; @@ -183,7 +181,7 @@ public static void callDropItemDispense(final List items, final Phas entities.add((Entity) item); } final DropItemEvent.Dispense dispense = - SpongeEventFactory.createDropItemEventDispense(frame.getCurrentCause(), entities); + SpongeEventFactory.createDropItemEventDispense(frame.currentCause(), entities); SpongeCommon.postEvent(dispense); if (!dispense.isCancelled()) { EntityUtil.processEntitySpawnsFromEvent(context, dispense); @@ -202,7 +200,7 @@ public static void callDropItemDrop(final net.minecraft.server.level.ServerPlaye // Creative doesn't inform server of cursor status so there is no way of knowing final Transaction cursorTransaction = new Transaction<>(ItemStackSnapshot.empty(), ItemStackSnapshot.empty()); final DropItemEvent.Dispense dispense = - SpongeEventFactory.createClickContainerEventDropOutsideCreative(frame.getCurrentCause(), + SpongeEventFactory.createClickContainerEventDropOutsideCreative(frame.currentCause(), ((org.spongepowered.api.item.inventory.Container) player.containerMenu), cursorTransaction, entities, Optional.empty(), Collections.emptyList()); SpongeCommon.postEvent(dispense); @@ -216,7 +214,7 @@ public static void callDropItemCustom(final List items, final PhaseConte try (final CauseStackManager.StackFrame frame = PhaseTracker.getCauseStackManager().pushCauseFrame()) { frame.addContext(EventContextKeys.SPAWN_TYPE, SpawnTypes.DROPPED_ITEM); final DropItemEvent.Custom event = - SpongeEventFactory.createDropItemEventCustom(frame.getCurrentCause(), items); + SpongeEventFactory.createDropItemEventCustom(frame.currentCause(), items); SpongeCommon.postEvent(event); if (!event.isCancelled()) { EntityUtil.processEntitySpawnsFromEvent(context, event); @@ -226,8 +224,8 @@ public static void callDropItemCustom(final List items, final PhaseConte public static void callDropItemCustom(final List items, final PhaseContext context, final Supplier> supplier) { try (final CauseStackManager.StackFrame frame = PhaseTracker.getCauseStackManager().pushCauseFrame()) { - frame.getCurrentContext().require(EventContextKeys.SPAWN_TYPE); - final DropItemEvent.Custom event = SpongeEventFactory.createDropItemEventCustom(frame.getCurrentCause(), items); + frame.currentContext().require(EventContextKeys.SPAWN_TYPE); + final DropItemEvent.Custom event = SpongeEventFactory.createDropItemEventCustom(frame.currentCause(), items); SpongeCommon.postEvent(event); if (!event.isCancelled()) { EntityUtil.processEntitySpawnsFromEvent(event, supplier); @@ -237,8 +235,8 @@ public static void callDropItemCustom(final List items, final PhaseConte public static void callDropItemClose(final List items, final PhaseContext context, final Supplier> supplier) { try (final CauseStackManager.StackFrame frame = PhaseTracker.getCauseStackManager().pushCauseFrame()) { - frame.getCurrentContext().require(EventContextKeys.SPAWN_TYPE); - final DropItemEvent.Close event = SpongeEventFactory.createDropItemEventClose(frame.getCurrentCause(), items); + frame.currentContext().require(EventContextKeys.SPAWN_TYPE); + final DropItemEvent.Close event = SpongeEventFactory.createDropItemEventClose(frame.currentCause(), items); SpongeCommon.postEvent(event); if (!event.isCancelled()) { EntityUtil.processEntitySpawnsFromEvent(event, supplier); @@ -250,9 +248,9 @@ public static boolean callSpawnEntitySpawner(final List entities, final try (final CauseStackManager.StackFrame frame = PhaseTracker.getCauseStackManager().pushCauseFrame()) { frame.addContext(EventContextKeys.SPAWN_TYPE, SpawnTypes.WORLD_SPAWNER); - final SpawnEntityEvent event = SpongeEventFactory.createSpawnEntityEvent(frame.getCurrentCause(), entities); + final SpawnEntityEvent event = SpongeEventFactory.createSpawnEntityEvent(frame.currentCause(), entities); SpongeCommon.postEvent(event); - if (!event.isCancelled() && event.getEntities().size() > 0) { + if (!event.isCancelled() && event.entities().size() > 0) { return EntityUtil.processEntitySpawnsFromEvent(context, event); } return false; @@ -260,7 +258,7 @@ public static boolean callSpawnEntitySpawner(final List entities, final } public static void callDropItemDestruct(final List entities, final PhaseContext context) { - final DropItemEvent.Destruct destruct = SpongeEventFactory.createDropItemEventDestruct(PhaseTracker.getCauseStackManager().getCurrentCause(), entities); + final DropItemEvent.Destruct destruct = SpongeEventFactory.createDropItemEventDestruct(PhaseTracker.getCauseStackManager().currentCause(), entities); SpongeCommon.postEvent(destruct); if (!destruct.isCancelled()) { EntityUtil.processEntitySpawnsFromEvent(context, destruct); @@ -268,9 +266,9 @@ public static void callDropItemDestruct(final List entities, final Phase } public static boolean callSpawnEntity(final List entities, final PhaseContext context) { - PhaseTracker.getCauseStackManager().getCurrentContext().require(EventContextKeys.SPAWN_TYPE); + PhaseTracker.getCauseStackManager().currentContext().require(EventContextKeys.SPAWN_TYPE); try { - final SpawnEntityEvent event = SpongeEventFactory.createSpawnEntityEvent(PhaseTracker.getCauseStackManager().getCurrentCause(), entities); + final SpawnEntityEvent event = SpongeEventFactory.createSpawnEntityEvent(PhaseTracker.getCauseStackManager().currentCause(), entities); SpongeCommon.postEvent(event); return !event.isCancelled() && EntityUtil.processEntitySpawnsFromEvent(context, event); } catch (final Exception e) { @@ -297,7 +295,7 @@ public static boolean callSpawnEntity(final List entities, final PhaseCo } public static boolean callSpawnEntityCustom(final List entities, final PhaseContext context) { - final SpawnEntityEvent.Custom event = SpongeEventFactory.createSpawnEntityEventCustom(PhaseTracker.getCauseStackManager().getCurrentCause(), entities); + final SpawnEntityEvent.Custom event = SpongeEventFactory.createSpawnEntityEventCustom(PhaseTracker.getCauseStackManager().currentCause(), entities); SpongeCommon.postEvent(event); return event.isCancelled() && EntityUtil.processEntitySpawnsFromEvent(context, event); } @@ -331,7 +329,7 @@ public static CollideEntityEvent c final List spEntities = (List) (List) entities; final CollideEntityEvent event = - SpongeEventFactory.createCollideEntityEvent(PhaseTracker.getCauseStackManager().getCurrentCause(), spEntities); + SpongeEventFactory.createCollideEntityEvent(PhaseTracker.getCauseStackManager().currentCause(), spEntities); SpongeCommon.postEvent(event); return event; } @@ -442,7 +440,7 @@ private static ChangeBlockEvent.Pre callChangeBlockEventPre(final ServerLevelBri phaseContext.applyNotifierIfAvailable(notifier -> frame.addContext(EventContextKeys.NOTIFIER, notifier)); final ChangeBlockEvent.Pre event = - SpongeEventFactory.createChangeBlockEventPre(frame.getCurrentCause(), locations, + SpongeEventFactory.createChangeBlockEventPre(frame.currentCause(), locations, (org.spongepowered.api.world.server.ServerWorld) worldIn ); SpongeCommon.postEvent(event); @@ -467,11 +465,11 @@ public static ChangeBlockEvent callChangeBlockEventModifyLiquidMix( } frame.addContext(EventContextKeys.LIQUID_MIX, (org.spongepowered.api.world.server.ServerWorld) worldIn); - final WorldProperties world = ((org.spongepowered.api.world.server.ServerWorld) worldIn).getProperties(); + final WorldProperties world = ((org.spongepowered.api.world.server.ServerWorld) worldIn).properties(); final Vector3i position = new Vector3i(pos.getX(), pos.getY(), pos.getZ()); final ServerLocation location = ServerLocation.of((org.spongepowered.api.world.server.ServerWorld) worldIn, position); - final ChangeBlockEvent event = SpongeEventFactory.createChangeBlockEventPre(frame.getCurrentCause(), + final ChangeBlockEvent event = SpongeEventFactory.createChangeBlockEventPre(frame.currentCause(), Collections.singletonList(location), ((org.spongepowered.api.world.server.ServerWorld) worldIn)); SpongeCommon.postEvent(event); @@ -495,13 +493,13 @@ public static ChangeBlockEvent callChangeBlockEventModifyLiquidBreak( frame.pushCause(source); frame.addContext(EventContextKeys.LIQUID_BREAK, (org.spongepowered.api.world.server.ServerWorld) worldIn); - final WorldProperties world = ((org.spongepowered.api.world.server.ServerWorld) worldIn).getProperties(); + final WorldProperties world = ((org.spongepowered.api.world.server.ServerWorld) worldIn).properties(); final Vector3i position = new Vector3i(pos.getX(), pos.getY(), pos.getZ()); final SpongeBlockSnapshot from = SpongeBlockSnapshotBuilder.pooled().blockState(fromState).world((ServerLevel) worldIn).position(position).build(); final SpongeBlockSnapshot to = SpongeBlockSnapshotBuilder.pooled().blockState(toState).world((ServerLevel) worldIn).position(position).build(); final BlockTransaction transaction = new BlockTransaction(from, to, Operations.LIQUID_SPREAD.get()); - final ChangeBlockEvent event = SpongeEventFactory.createChangeBlockEventAll(frame.getCurrentCause(), + final ChangeBlockEvent event = SpongeEventFactory.createChangeBlockEventAll(frame.currentCause(), Collections.singletonList(transaction), ((org.spongepowered.api.world.server.ServerWorld) worldIn)); SpongeCommon.postEvent(event); @@ -542,7 +540,7 @@ public static NotifyNeighborBlockEvent callNotifyNeighborEvent(final World world } final NotifyNeighborBlockEvent event = - SpongeEventFactory.createNotifyNeighborBlockEvent(PhaseTracker.getCauseStackManager().getCurrentCause(), neighbors, neighbors); + SpongeEventFactory.createNotifyNeighborBlockEvent(PhaseTracker.getCauseStackManager().currentCause(), neighbors, neighbors); SpongeCommon.postEvent(event); return event; } @@ -551,8 +549,8 @@ public static NotifyNeighborBlockEvent callNotifyNeighborEvent(final World world public static InteractEntityEvent.Primary callInteractEntityEventPrimary(final net.minecraft.server.level.ServerPlayer player, final ItemStack stack, final net.minecraft.world.entity.Entity entity, final InteractionHand hand) { try (final CauseStackManager.StackFrame frame = PhaseTracker.getCauseStackManager().pushCauseFrame()) { SpongeCommonEventFactory.applyCommonInteractContext(player, stack, hand, null, entity, frame); - final InteractEntityEvent.Primary event = SpongeEventFactory.createInteractEntityEventPrimary(frame.getCurrentCause(), (Entity) entity); - if (entity instanceof Player && !((org.spongepowered.api.world.server.ServerWorld) player.getLevel()).getProperties().pvp()) { + final InteractEntityEvent.Primary event = SpongeEventFactory.createInteractEntityEventPrimary(frame.currentCause(), (Entity) entity); + if (entity instanceof Player && !((org.spongepowered.api.world.server.ServerWorld) player.getLevel()).properties().pvp()) { event.setCancelled(true); // if PvP is disabled for world, cancel } SpongeCommon.postEvent(event); @@ -565,8 +563,8 @@ public static InteractEntityEvent.Secondary callInteractEntityEventSecondary(fin try (final CauseStackManager.StackFrame frame = PhaseTracker.getCauseStackManager().pushCauseFrame()) { SpongeCommonEventFactory.applyCommonInteractContext(player, stack, hand, null, entity, frame); final InteractEntityEvent.Secondary event = hitVec == null ? - SpongeEventFactory.createInteractEntityEventSecondaryOn(frame.getCurrentCause(), (Entity) entity) : - SpongeEventFactory.createInteractEntityEventSecondaryAt(frame.getCurrentCause(), (Entity) entity, hitVec); + SpongeEventFactory.createInteractEntityEventSecondaryOn(frame.currentCause(), (Entity) entity) : + SpongeEventFactory.createInteractEntityEventSecondaryAt(frame.currentCause(), (Entity) entity, hitVec); SpongeCommon.postEvent(event); return event; } @@ -575,7 +573,7 @@ public static InteractEntityEvent.Secondary callInteractEntityEventSecondary(fin public static InteractItemEvent.Primary callInteractItemEventPrimary(final net.minecraft.world.entity.player.Player player, final ItemStack stack, final InteractionHand hand) { try (final CauseStackManager.StackFrame frame = PhaseTracker.getCauseStackManager().pushCauseFrame()) { SpongeCommonEventFactory.applyCommonInteractContext(player, stack, hand, null, null, frame); - final InteractItemEvent.Primary event = SpongeEventFactory.createInteractItemEventPrimary(frame.getCurrentCause(), ItemStackUtil.snapshotOf(stack)); + final InteractItemEvent.Primary event = SpongeEventFactory.createInteractItemEventPrimary(frame.currentCause(), ItemStackUtil.snapshotOf(stack)); SpongeCommon.postEvent(event); return event; } @@ -584,7 +582,7 @@ public static InteractItemEvent.Primary callInteractItemEventPrimary(final net.m public static InteractItemEvent.Secondary callInteractItemEventSecondary(final net.minecraft.world.entity.player.Player player, final ItemStack stack, final InteractionHand hand) { try (final CauseStackManager.StackFrame frame = PhaseTracker.getCauseStackManager().pushCauseFrame()) { SpongeCommonEventFactory.applyCommonInteractContext(player, stack, hand, null, null, frame); - final InteractItemEvent.Secondary event = SpongeEventFactory.createInteractItemEventSecondary(frame.getCurrentCause(), ItemStackUtil.snapshotOf(stack)); + final InteractItemEvent.Secondary event = SpongeEventFactory.createInteractItemEventSecondary(frame.currentCause(), ItemStackUtil.snapshotOf(stack)); SpongeCommon.postEvent(event); return event; } @@ -606,13 +604,13 @@ public static InteractBlockEvent.Primary callInteractBlockEventPrimary(Serverbou final InteractBlockEvent.Primary event; switch (action) { case START_DESTROY_BLOCK: - event = SpongeEventFactory.createInteractBlockEventPrimaryStart(frame.getCurrentCause(), blockSnapshot, direction); + event = SpongeEventFactory.createInteractBlockEventPrimaryStart(frame.currentCause(), blockSnapshot, direction); break; case ABORT_DESTROY_BLOCK: - event = SpongeEventFactory.createInteractBlockEventPrimaryStop(frame.getCurrentCause(), blockSnapshot, direction); + event = SpongeEventFactory.createInteractBlockEventPrimaryStop(frame.currentCause(), blockSnapshot, direction); break; case STOP_DESTROY_BLOCK: - event = SpongeEventFactory.createInteractBlockEventPrimaryFinish(frame.getCurrentCause(), blockSnapshot, direction); + event = SpongeEventFactory.createInteractBlockEventPrimaryFinish(frame.currentCause(), blockSnapshot, direction); break; default: throw new IllegalStateException("unreachable code"); @@ -626,7 +624,7 @@ public static InteractBlockEvent.Primary callInteractBlockEventPrimary(Serverbou public static InteractBlockEvent.Secondary callInteractBlockEventSecondary(final net.minecraft.world.entity.player.Player player, final ItemStack heldItem, final Vector3d hitVec, final BlockSnapshot targetBlock, final Direction targetSide, final InteractionHand hand) { try (final CauseStackManager.StackFrame frame = PhaseTracker.getCauseStackManager().pushCauseFrame()) { SpongeCommonEventFactory.applyCommonInteractContext(player, heldItem, hand, targetBlock, null, frame); - final InteractBlockEvent.Secondary event = SpongeEventFactory.createInteractBlockEventSecondary(frame.getCurrentCause(), + final InteractBlockEvent.Secondary event = SpongeEventFactory.createInteractBlockEventSecondary(frame.currentCause(), Tristate.UNDEFINED, Tristate.UNDEFINED, Tristate.UNDEFINED, Tristate.UNDEFINED, targetBlock, hitVec, targetSide); SpongeCommon.postEvent(event); @@ -678,14 +676,14 @@ public static void callNaturalMoveEntityEvent(final net.minecraft.world.entity.E frame.pushCause(entity); frame.addContext(EventContextKeys.MOVEMENT_TYPE, MovementTypes.NATURAL); - final MoveEntityEvent event = SpongeEventFactory.createMoveEntityEvent(frame.getCurrentCause(), (Entity) entity, + final MoveEntityEvent event = SpongeEventFactory.createMoveEntityEvent(frame.currentCause(), (Entity) entity, new Vector3d(entity.xOld, entity.yOld, entity.zOld), new Vector3d(entity.getX(), entity.getY(), entity.getZ()), new Vector3d(entity.getX(), entity.getY(), entity.getZ())); if (SpongeCommon.postEvent(event)) { entity.setPos(entity.xOld, entity.yOld, entity.zOld); } else { - entity.setPos(event.getDestinationPosition().getX(), event.getDestinationPosition().getY(), event.getDestinationPosition().getZ()); + entity.setPos(event.destinationPosition().getX(), event.destinationPosition().getY(), event.destinationPosition().getZ()); } } } @@ -703,15 +701,15 @@ public static void callNaturalRotateEntityEvent(final net.minecraft.world.entity try (final CauseStackManager.StackFrame frame = PhaseTracker.getCauseStackManager().pushCauseFrame()) { frame.pushCause(entity); - final RotateEntityEvent event = SpongeEventFactory.createRotateEntityEvent(frame.getCurrentCause(), (Entity) entity, + final RotateEntityEvent event = SpongeEventFactory.createRotateEntityEvent(frame.currentCause(), (Entity) entity, new Vector3d(entity.xRotO, entity.yRotO, 0), new Vector3d(entity.xRot, entity.yRot, 0)); if (SpongeCommon.postEvent(event)) { entity.xRot = entity.xRotO; entity.yRot = entity.yRotO; } else { - entity.xRot = (float) event.getToRotation().getX(); - entity.yRot = (float) event.getToRotation().getY(); + entity.xRot = (float) event.toRotation().getX(); + entity.yRot = (float) event.toRotation().getY(); } } } @@ -745,7 +743,7 @@ public static DestructEntityEvent.Death callDestructEntityEventDeath(final Livin sourceCreator.ifPresent(user -> frame.addContext(EventContextKeys.CREATOR, user)); - final DestructEntityEvent.Death event = SpongeEventFactory.createDestructEntityEventDeath(frame.getCurrentCause(), + final DestructEntityEvent.Death event = SpongeEventFactory.createDestructEntityEventDeath(frame.currentCause(), originalChannel, Optional.of(originalChannel), originalMessage, originalMessage, (Living) entity, entity.level.getGameRules().getBoolean(GameRules.RULE_KEEPINVENTORY), messageCancelled); SpongeCommon.postEvent(event); @@ -768,7 +766,7 @@ public static boolean handleCollideBlockEvent(final Block block, final net.minec } // TODO: Add target side support - final CollideBlockEvent event = SpongeEventFactory.createCollideBlockEvent(frame.getCurrentCause(), (BlockState) state, + final CollideBlockEvent event = SpongeEventFactory.createCollideBlockEvent(frame.currentCause(), (BlockState) state, ServerLocation.of((org.spongepowered.api.world.server.ServerWorld) world, VecHelper.toVector3d(pos)), direction); final boolean cancelled = SpongeCommon.postEvent(event); if (!cancelled) { @@ -813,21 +811,21 @@ public static boolean handleCollideImpactEvent(final net.minecraft.world.entity. final BlockSnapshot targetBlock = ((org.spongepowered.api.world.server.ServerWorld) projectile.level).createSnapshot(blockPos.getX(), blockPos.getY(), blockPos.getZ()); final Direction side = DirectionFacingProvider.INSTANCE.getKey(blockMovingObjectPosition.getDirection()).get(); - final CollideBlockEvent.Impact event = SpongeEventFactory.createCollideBlockEventImpact(frame.getCurrentCause(), - impactPoint, targetBlock.getState(), - targetBlock.getLocation().get(), side); + final CollideBlockEvent.Impact event = SpongeEventFactory.createCollideBlockEventImpact(frame.currentCause(), + impactPoint, targetBlock.state(), + targetBlock.location().get(), side); cancelled = SpongeCommon.postEvent(event); // Track impact block if event is not cancelled if (!cancelled && creator.isPresent()) { - final BlockPos targetPos = VecHelper.toBlockPos(impactPoint.getBlockPosition()); + final BlockPos targetPos = VecHelper.toBlockPos(impactPoint.blockPosition()); final LevelChunkBridge spongeChunk = (LevelChunkBridge) projectile.level.getChunkAt(targetPos); - spongeChunk.bridge$addTrackedBlockPosition((Block) targetBlock.getState().getType(), targetPos, creator.get(), PlayerTracker.Type.NOTIFIER); + spongeChunk.bridge$addTrackedBlockPosition((Block) targetBlock.state().type(), targetPos, creator.get(), PlayerTracker.Type.NOTIFIER); } } else if (movingObjectType == HitResult.Type.ENTITY) { // entity final EntityHitResult entityMovingObjectPosition = (EntityHitResult) movingObjectPosition; final ArrayList entityList = new ArrayList<>(); entityList.add((Entity) entityMovingObjectPosition.getEntity()); - final CollideEntityEvent.Impact event = SpongeEventFactory.createCollideEntityEventImpact(frame.getCurrentCause(), entityList, impactPoint); + final CollideEntityEvent.Impact event = SpongeEventFactory.createCollideEntityEventImpact(frame.currentCause(), entityList, impactPoint); cancelled = SpongeCommon.postEvent(event); } @@ -839,7 +837,7 @@ public static InteractContainerEvent.Close callInteractInventoryCloseEvent(final final ItemStackSnapshot lastCursor, final ItemStackSnapshot newCursor, final boolean clientSource) { final Transaction cursorTransaction = new Transaction<>(lastCursor, newCursor); final InteractContainerEvent.Close event = - SpongeEventFactory.createInteractContainerEventClose(PhaseTracker.getCauseStackManager().getCurrentCause(), ContainerUtil.fromNative(container), cursorTransaction); + SpongeEventFactory.createInteractContainerEventClose(PhaseTracker.getCauseStackManager().currentCause(), ContainerUtil.fromNative(container), cursorTransaction); SpongeCommon.postEvent(event); if (event.isCancelled()) { if (clientSource && container.getSlot(0) != null) { @@ -869,18 +867,18 @@ public static InteractContainerEvent.Close callInteractInventoryCloseEvent(final } } // Handle cursor - if (!event.getCursorTransaction().isValid()) { - handleCustomCursor(player, event.getCursorTransaction().getOriginal()); + if (!event.cursorTransaction().isValid()) { + handleCustomCursor(player, event.cursorTransaction().original()); } } else { final TrackedInventoryBridge mixinContainer = (TrackedInventoryBridge) player.containerMenu; mixinContainer.bridge$getCapturedSlotTransactions().clear(); mixinContainer.bridge$setCaptureInventory(false); // Handle cursor - if (!event.getCursorTransaction().isValid()) { - handleCustomCursor(player, event.getCursorTransaction().getOriginal()); - } else if (event.getCursorTransaction().getCustom().isPresent()) { - handleCustomCursor(player, event.getCursorTransaction().getFinal()); + if (!event.cursorTransaction().isValid()) { + handleCustomCursor(player, event.cursorTransaction().original()); + } else if (event.cursorTransaction().custom().isPresent()) { + handleCustomCursor(player, event.cursorTransaction().finalReplacement()); } if (!clientSource && player.containerMenu != null && player.connection != null) { player.closeContainer(); @@ -891,19 +889,19 @@ public static InteractContainerEvent.Close callInteractInventoryCloseEvent(final } public static SetAITargetEvent callSetAttackTargetEvent(@Nullable final Entity target, final Agent agent) { - final SetAITargetEvent event = SpongeEventFactory.createSetAITargetEvent(PhaseTracker.getCauseStackManager().getCurrentCause(), agent, Optional.ofNullable(target)); + final SetAITargetEvent event = SpongeEventFactory.createSetAITargetEvent(PhaseTracker.getCauseStackManager().currentCause(), agent, Optional.ofNullable(target)); SpongeCommon.postEvent(event); return event; } public static Optional detonateExplosive(final ExplosiveBridge explosiveBridge, final Explosion.Builder builder) { final DetonateExplosiveEvent event = SpongeEventFactory.createDetonateExplosiveEvent( - PhaseTracker.getCauseStackManager().getCurrentCause(), builder, (Explosive) explosiveBridge, builder.build() + PhaseTracker.getCauseStackManager().currentCause(), builder, (Explosive) explosiveBridge, builder.build() ); - if (!Sponge.getEventManager().post(event)) { - final Explosion explosion = event.getExplosionBuilder().build(); - if (explosion.getRadius() > 0) { - ((TrackedWorldBridge) ((Explosive) explosiveBridge).getWorld()) + if (!Sponge.eventManager().post(event)) { + final Explosion explosion = event.explosionBuilder().build(); + if (explosion.radius() > 0) { + ((TrackedWorldBridge) ((Explosive) explosiveBridge).world()) .tracker$triggerInternalExplosion( explosion, e -> GeneralPhase.State.EXPLOSION.createPhaseContext(PhaseTracker.SERVER).explosion(e) @@ -948,7 +946,7 @@ public static ItemStack throwDropItemAndConstructEvent(final net.minecraft.world frame.pushCause(entity); // FIRST we want to throw the DropItemEvent.PRE - final DropItemEvent.Pre dropEvent = SpongeEventFactory.createDropItemEventPre(frame.getCurrentCause(), + final DropItemEvent.Pre dropEvent = SpongeEventFactory.createDropItemEventPre(frame.currentCause(), ImmutableList.of(snapshot), original); SpongeCommon.postEvent(dropEvent); if (dropEvent.isCancelled()) { @@ -957,13 +955,13 @@ public static ItemStack throwDropItemAndConstructEvent(final net.minecraft.world } return null; } - if (dropEvent.getDroppedItems().isEmpty()) { + if (dropEvent.droppedItems().isEmpty()) { return null; } // SECOND throw the ConstructEntityEvent frame.addContext(EventContextKeys.SPAWN_TYPE, SpawnTypes.DROPPED_ITEM); - final ConstructEntityEvent.Pre event = SpongeEventFactory.createConstructEntityEventPre(frame.getCurrentCause(), ServerLocation.of((org.spongepowered.api.world.server.ServerWorld) entity.level, posX, posY, posZ), new Vector3d(0, 0, 0), EntityTypes.ITEM.get()); + final ConstructEntityEvent.Pre event = SpongeEventFactory.createConstructEntityEventPre(frame.currentCause(), ServerLocation.of((org.spongepowered.api.world.server.ServerWorld) entity.level, posX, posY, posZ), new Vector3d(0, 0, 0), EntityTypes.ITEM.get()); frame.removeContext(EventContextKeys.SPAWN_TYPE); SpongeCommon.postEvent(event); if (event.isCancelled()) { @@ -974,7 +972,7 @@ public static ItemStack throwDropItemAndConstructEvent(final net.minecraft.world return null; } - item = event.isCancelled() ? null : ItemStackUtil.fromSnapshotToNative(dropEvent.getDroppedItems().get(0)); + item = event.isCancelled() ? null : ItemStackUtil.fromSnapshotToNative(dropEvent.droppedItems().get(0)); if (item == null) { // Make sure the player is restoring inventories if (mixinPlayer != null) { @@ -1003,7 +1001,7 @@ public static PlaySoundEvent.Broadcast callPlaySoundBroadcastEvent(final CauseSt return null; } final ServerLocation location = ServerLocation.of((org.spongepowered.api.world.server.ServerWorld) bridge, pos.getX(), pos.getY(), pos.getZ()); - final PlaySoundEvent.Broadcast event = SpongeEventFactory.createPlaySoundEventBroadcast(frame.getCurrentCause(), location, + final PlaySoundEvent.Broadcast event = SpongeEventFactory.createPlaySoundEventBroadcast(frame.currentCause(), location, Sound.Source.HOSTILE, soundType.get(), 1.0F, volume); SpongeCommon.postEvent(event); return event; @@ -1012,13 +1010,13 @@ public static PlaySoundEvent.Broadcast callPlaySoundBroadcastEvent(final CauseSt public static PlaySoundEvent.Record callPlaySoundRecordEvent(final Cause cause, final JukeboxBlockEntity jukebox, final MusicDisc recordType, final int data) { final Jukebox apiJuke = (Jukebox) jukebox; - final ServerLocation location = (ServerLocation) apiJuke.getLocation(); + final ServerLocation location = (ServerLocation) apiJuke.location(); final PlaySoundEvent.Record event = data == 0 ? SpongeEventFactory - .createPlaySoundEventRecordStart(cause, apiJuke, location, recordType, Sound.Source.RECORD, recordType.getSound(), 1.0F, 4.0F) + .createPlaySoundEventRecordStart(cause, apiJuke, location, recordType, Sound.Source.RECORD, recordType.sound(), 1.0F, 4.0F) : SpongeEventFactory - .createPlaySoundEventRecordStop(cause, apiJuke, location, recordType, Sound.Source.RECORD, recordType.getSound(), 1.0F, 4.0F); + .createPlaySoundEventRecordStop(cause, apiJuke, location, recordType, Sound.Source.RECORD, recordType.sound(), 1.0F, 4.0F); SpongeCommon.postEvent(event); return event; } @@ -1052,7 +1050,7 @@ public static Optional fireCreateMapEvent(final Cause cause) { public static Optional fireCreateMapEvent(final Cause cause, Set> values) { - final ServerLevel defaultWorld = (ServerLevel) Sponge.getServer().getWorldManager().defaultWorld(); + final ServerLevel defaultWorld = (ServerLevel) Sponge.server().worldManager().defaultWorld(); final MapIdTrackerBridge mapIdTrackerBridge = (MapIdTrackerBridge) defaultWorld.getDataStorage().computeIfAbsent(MapIndex::new, Constants.Map.MAP_INDEX_DATA_NAME); final int id = mapIdTrackerBridge.bridge$getHighestMapId() @@ -1088,7 +1086,7 @@ public static Optional fireCreateMapEvent(final Cause cause, Set implements EventContextKey { } @Override - public ResourceKey getKey() { + public ResourceKey key() { return this.key; } @Override - public Type getAllowedType() { + public Type allowedType() { return this.allowed; } diff --git a/src/main/java/org/spongepowered/common/event/SpongeEventManager.java b/src/main/java/org/spongepowered/common/event/SpongeEventManager.java index ba77ff47f91..e76b88966c1 100644 --- a/src/main/java/org/spongepowered/common/event/SpongeEventManager.java +++ b/src/main/java/org/spongepowered/common/event/SpongeEventManager.java @@ -383,7 +383,7 @@ protected RegisteredListener.Cache getHandlerCache(final Event event) { final Class eventClass = event.getClass(); final EventType eventType; if (event instanceof GenericEvent) { - eventType = new EventType(eventClass, checkNotNull(((GenericEvent) event).getParamType().getType())); + eventType = new EventType(eventClass, checkNotNull(((GenericEvent) event).paramType().getType())); } else { eventType = new EventType(eventClass, null); } @@ -455,7 +455,7 @@ private EventListenerPhaseContext createPluginContext(final RegisteredListener key(final ResourceKey location) { - return RegistryKey.of(SpongeRegistryTypes.SPAWN_TYPE, location).asDefaultedReference(() -> Sponge.getGame().registries()); + return RegistryKey.of(SpongeRegistryTypes.SPAWN_TYPE, location).asDefaultedReference(() -> Sponge.game().registries()); } } diff --git a/src/main/java/org/spongepowered/common/event/cause/entity/damage/DamageEventHandler.java b/src/main/java/org/spongepowered/common/event/cause/entity/damage/DamageEventHandler.java index 4ca2f81eee6..b6d53848734 100644 --- a/src/main/java/org/spongepowered/common/event/cause/entity/damage/DamageEventHandler.java +++ b/src/main/java/org/spongepowered/common/event/cause/entity/damage/DamageEventHandler.java @@ -125,10 +125,10 @@ public static Optional createArmorModifiers(final LivingEntity e final EventContext.Builder contextBuilder = EventContext.builder(); if (entityLivingBase instanceof ArmorEquipable) { // TODO - Add the event context keys for these armor pieces - final ItemStackSnapshot helmet = ((ArmorEquipable) entityLivingBase).getHead().createSnapshot(); - final ItemStackSnapshot chest = ((ArmorEquipable) entityLivingBase).getChest().createSnapshot(); - final ItemStackSnapshot legs = ((ArmorEquipable) entityLivingBase).getLegs().createSnapshot(); - final ItemStackSnapshot feet = ((ArmorEquipable) entityLivingBase).getFeet().createSnapshot(); + final ItemStackSnapshot helmet = ((ArmorEquipable) entityLivingBase).head().createSnapshot(); + final ItemStackSnapshot chest = ((ArmorEquipable) entityLivingBase).chest().createSnapshot(); + final ItemStackSnapshot legs = ((ArmorEquipable) entityLivingBase).legs().createSnapshot(); + final ItemStackSnapshot feet = ((ArmorEquipable) entityLivingBase).feet().createSnapshot(); } final DamageFunction armorModifier = DamageFunction.of(DamageModifier.builder() .cause(Cause.of(EventContext.empty(), attribute, entityLivingBase)) @@ -145,7 +145,7 @@ public static Optional createResistanceModifier(final LivingEnti return Optional.of(new DamageFunction(DamageModifier.builder() .cause(Cause.of(EventContext.empty(), effect)) .type(DamageModifierTypes.DEFENSIVE_POTION_EFFECT) - .build(), DamageEventHandler.createResistanceFunction(effect.getAmplifier()))); + .build(), DamageEventHandler.createResistanceFunction(effect.amplifier()))); } return Optional.empty(); } @@ -284,7 +284,7 @@ public static ServerLocation findFirstMatchingBlock(final Entity entity, final A } // Entity is source of fire - return ((org.spongepowered.api.entity.Entity) entity).getServerLocation(); + return ((org.spongepowered.api.entity.Entity) entity).serverLocation(); } /** @@ -311,9 +311,9 @@ public static void generateCauseFor(final DamageSource damageSource, final Cause creatorBridge.tracked$getNotifierReference().ifPresent(notifier -> frame.addContext(EventContextKeys.NOTIFIER, notifier)); } } else if (damageSource instanceof BlockDamageSource) { - final ServerLocation location = ((BlockDamageSource) damageSource).getLocation(); + final ServerLocation location = ((BlockDamageSource) damageSource).location(); final BlockPos blockPos = VecHelper.toBlockPos(location); - final LevelChunkBridge mixinChunk = (LevelChunkBridge) ((net.minecraft.world.level.Level) location.getWorld()).getChunkAt(blockPos); + final LevelChunkBridge mixinChunk = (LevelChunkBridge) ((net.minecraft.world.level.Level) location.world()).getChunkAt(blockPos); mixinChunk.bridge$getBlockCreator(blockPos).ifPresent(creator -> frame.addContext(EventContextKeys.CREATOR, creator)); mixinChunk.bridge$getBlockNotifier(blockPos).ifPresent(notifier -> frame.addContext(EventContextKeys.NOTIFIER, notifier)); } diff --git a/src/main/java/org/spongepowered/common/event/cause/entity/damage/SpongeBlockDamageSourceBuilder.java b/src/main/java/org/spongepowered/common/event/cause/entity/damage/SpongeBlockDamageSourceBuilder.java index 973ffb9367f..d11840cd60e 100644 --- a/src/main/java/org/spongepowered/common/event/cause/entity/damage/SpongeBlockDamageSourceBuilder.java +++ b/src/main/java/org/spongepowered/common/event/cause/entity/damage/SpongeBlockDamageSourceBuilder.java @@ -57,7 +57,7 @@ public BlockDamageSource build() throws IllegalStateException { checkState(this.location != null); checkState(this.blockSnapshot != null); checkState(this.damageType != null); - final MinecraftBlockDamageSource damageSource = new MinecraftBlockDamageSource(this.damageType.getName(), this.location); + final MinecraftBlockDamageSource damageSource = new MinecraftBlockDamageSource(this.damageType.name(), this.location); final DamageSourceAccessor accessor = (DamageSourceAccessor) (Object) damageSource; if (this.absolute) { accessor.invoker$bypassMagic(); diff --git a/src/main/java/org/spongepowered/common/event/cause/entity/damage/SpongeCommonDamageSource.java b/src/main/java/org/spongepowered/common/event/cause/entity/damage/SpongeCommonDamageSource.java index 3210bb4b14d..206f7ec77be 100644 --- a/src/main/java/org/spongepowered/common/event/cause/entity/damage/SpongeCommonDamageSource.java +++ b/src/main/java/org/spongepowered/common/event/cause/entity/damage/SpongeCommonDamageSource.java @@ -81,7 +81,7 @@ public boolean scalesWithDifficulty() { @Override public float getFoodExhaustion() { - return (float) this.getExhaustion(); + return (float) this.exhaustion(); } diff --git a/src/main/java/org/spongepowered/common/event/cause/entity/damage/SpongeCommonEntityDamageSource.java b/src/main/java/org/spongepowered/common/event/cause/entity/damage/SpongeCommonEntityDamageSource.java index 4239b23ed7d..1843fb3051c 100644 --- a/src/main/java/org/spongepowered/common/event/cause/entity/damage/SpongeCommonEntityDamageSource.java +++ b/src/main/java/org/spongepowered/common/event/cause/entity/damage/SpongeCommonEntityDamageSource.java @@ -69,7 +69,7 @@ public void setEntitySource(final Entity entitySource) { @Override public Entity getEntity() { - return (Entity) this.getSource(); + return (Entity) this.source(); } @Override @@ -99,7 +99,7 @@ public boolean scalesWithDifficulty() { @Override public float getFoodExhaustion() { - return (float) this.getExhaustion(); + return (float) this.exhaustion(); } } diff --git a/src/main/java/org/spongepowered/common/event/cause/entity/damage/SpongeCommonIndirectEntityDamageSource.java b/src/main/java/org/spongepowered/common/event/cause/entity/damage/SpongeCommonIndirectEntityDamageSource.java index fd4b8222456..f6a62bab492 100644 --- a/src/main/java/org/spongepowered/common/event/cause/entity/damage/SpongeCommonIndirectEntityDamageSource.java +++ b/src/main/java/org/spongepowered/common/event/cause/entity/damage/SpongeCommonIndirectEntityDamageSource.java @@ -76,7 +76,7 @@ public void setIndirectSource(final Entity entity) { @Override public Entity getEntity() { - return (Entity) this.getSource(); + return (Entity) this.source(); } @Override @@ -106,7 +106,7 @@ public boolean scalesWithDifficulty() { @Override public float getFoodExhaustion() { - return (float) this.getExhaustion(); + return (float) this.exhaustion(); } } diff --git a/src/main/java/org/spongepowered/common/event/cause/entity/damage/SpongeDamageType.java b/src/main/java/org/spongepowered/common/event/cause/entity/damage/SpongeDamageType.java index fd7a3291da3..c6ae93063b6 100644 --- a/src/main/java/org/spongepowered/common/event/cause/entity/damage/SpongeDamageType.java +++ b/src/main/java/org/spongepowered/common/event/cause/entity/damage/SpongeDamageType.java @@ -35,7 +35,7 @@ public SpongeDamageType(final String languageKey) { } @Override - public String getName() { + public String name() { return this.languageKey; } } diff --git a/src/main/java/org/spongepowered/common/event/cause/entity/damage/SpongeEntityDamageSourceBuilder.java b/src/main/java/org/spongepowered/common/event/cause/entity/damage/SpongeEntityDamageSourceBuilder.java index 9090772b02c..a432c1da0b2 100644 --- a/src/main/java/org/spongepowered/common/event/cause/entity/damage/SpongeEntityDamageSourceBuilder.java +++ b/src/main/java/org/spongepowered/common/event/cause/entity/damage/SpongeEntityDamageSourceBuilder.java @@ -48,7 +48,7 @@ public SpongeEntityDamageSourceBuilder entity(final Entity entity) { public EntityDamageSource build() throws IllegalStateException { checkState(this.damageType != null, "Damage type cannot be null!"); checkState(this.reference.get() != null); - final net.minecraft.world.damagesource.EntityDamageSource damageSource = new net.minecraft.world.damagesource.EntityDamageSource(this.damageType.getName(), + final net.minecraft.world.damagesource.EntityDamageSource damageSource = new net.minecraft.world.damagesource.EntityDamageSource(this.damageType.name(), (net.minecraft.world.entity.Entity) this.reference.get()); final DamageSourceAccessor accessor = (DamageSourceAccessor) damageSource; if (this.creative) { @@ -78,7 +78,7 @@ public EntityDamageSource build() throws IllegalStateException { @Override public EntityDamageSource.Builder from(final EntityDamageSource value) { super.from(value); - this.reference = new WeakReference<>(value.getSource()); + this.reference = new WeakReference<>(value.source()); return this; } diff --git a/src/main/java/org/spongepowered/common/event/cause/entity/damage/SpongeFallingBlockDamgeSourceBuilder.java b/src/main/java/org/spongepowered/common/event/cause/entity/damage/SpongeFallingBlockDamgeSourceBuilder.java index da0561d90a1..402fce11d31 100644 --- a/src/main/java/org/spongepowered/common/event/cause/entity/damage/SpongeFallingBlockDamgeSourceBuilder.java +++ b/src/main/java/org/spongepowered/common/event/cause/entity/damage/SpongeFallingBlockDamgeSourceBuilder.java @@ -59,7 +59,7 @@ public FallingBlockDamageSource build() throws IllegalStateException { checkState(this.reference.get() != null); checkState(this.damageType != null); final MinecraftFallingBlockDamageSource damageSource = - new MinecraftFallingBlockDamageSource(this.damageType.getName(), (FallingBlockEntity) this.reference.get()); + new MinecraftFallingBlockDamageSource(this.damageType.name(), (FallingBlockEntity) this.reference.get()); final DamageSourceAccessor accessor = (DamageSourceAccessor) (Object) damageSource; if (this.creative) { accessor.invoker$bypassInvul(); @@ -88,7 +88,7 @@ public FallingBlockDamageSource build() throws IllegalStateException { @Override public FallingBlockDamageSource.Builder from(final FallingBlockDamageSource value) { super.from(value); - this.reference = new WeakReference<>(value.getSource()); + this.reference = new WeakReference<>(value.source()); return this; } diff --git a/src/main/java/org/spongepowered/common/event/cause/entity/damage/SpongeIndirectEntityDamageSourceBuilder.java b/src/main/java/org/spongepowered/common/event/cause/entity/damage/SpongeIndirectEntityDamageSourceBuilder.java index 54838ecd7d8..c026abe2e40 100644 --- a/src/main/java/org/spongepowered/common/event/cause/entity/damage/SpongeIndirectEntityDamageSourceBuilder.java +++ b/src/main/java/org/spongepowered/common/event/cause/entity/damage/SpongeIndirectEntityDamageSourceBuilder.java @@ -56,7 +56,7 @@ public IndirectEntityDamageSource build() throws IllegalStateException { checkState(this.damageType != null); final net.minecraft.world.damagesource.IndirectEntityDamageSource damageSource = - new net.minecraft.world.damagesource.IndirectEntityDamageSource(this.damageType.getName(), + new net.minecraft.world.damagesource.IndirectEntityDamageSource(this.damageType.name(), (net.minecraft.world.entity.Entity) this.reference.get(), (net.minecraft.world.entity.Entity) this.proxy.get()); final DamageSourceAccessor accessor = (DamageSourceAccessor) damageSource; @@ -87,8 +87,8 @@ public IndirectEntityDamageSource build() throws IllegalStateException { @Override public IndirectEntityDamageSource.Builder from(final IndirectEntityDamageSource value) { super.from(value); - this.reference = new WeakReference<>(value.getSource()); - this.proxy = new WeakReference<>(value.getIndirectSource()); + this.reference = new WeakReference<>(value.source()); + this.proxy = new WeakReference<>(value.indirectSource()); return this; } diff --git a/src/main/java/org/spongepowered/common/event/filter/FilterGenerator.java b/src/main/java/org/spongepowered/common/event/filter/FilterGenerator.java index db9c60da980..e2dda537c85 100644 --- a/src/main/java/org/spongepowered/common/event/filter/FilterGenerator.java +++ b/src/main/java/org/spongepowered/common/event/filter/FilterGenerator.java @@ -187,8 +187,8 @@ public byte[] generateClass(String name, Method method) { "Cannot have additional parameters filters without an array source (for " + param.getName() + ")"); } Tuple localState = source.write(cw, mv, method, param, local); - local = localState.getFirst(); - plocals[i - 1] = localState.getSecond(); + local = localState.first(); + plocals[i - 1] = localState.second(); for (ParameterFilterDelegate paramFilter : paramFilters) { paramFilter.write(cw, mv, method, param, plocals[i - 1]); diff --git a/src/main/java/org/spongepowered/common/event/filter/delegate/CauseFilterSourceDelegate.java b/src/main/java/org/spongepowered/common/event/filter/delegate/CauseFilterSourceDelegate.java index e7696f04666..00fb2d2c044 100644 --- a/src/main/java/org/spongepowered/common/event/filter/delegate/CauseFilterSourceDelegate.java +++ b/src/main/java/org/spongepowered/common/event/filter/delegate/CauseFilterSourceDelegate.java @@ -44,7 +44,7 @@ public abstract class CauseFilterSourceDelegate implements ParameterFilterSource public Tuple write(ClassWriter cw, MethodVisitor mv, Method method, Parameter param, int local) { // Get the cause mv.visitVarInsn(ALOAD, 1); - mv.visitMethodInsn(INVOKEINTERFACE, Type.getInternalName(Event.class), "getCause", + mv.visitMethodInsn(INVOKEINTERFACE, Type.getInternalName(Event.class), "cause", "()" + Type.getDescriptor(Cause.class), true); Class targetType = param.getType(); diff --git a/src/main/java/org/spongepowered/common/event/inventory/InventoryEventFactory.java b/src/main/java/org/spongepowered/common/event/inventory/InventoryEventFactory.java index 223863a6cb1..3115519537c 100644 --- a/src/main/java/org/spongepowered/common/event/inventory/InventoryEventFactory.java +++ b/src/main/java/org/spongepowered/common/event/inventory/InventoryEventFactory.java @@ -101,15 +101,15 @@ public static boolean callPlayerChangeInventoryPickupPreEvent(final Player playe final ItemStackSnapshot snapshot = ItemStackUtil.snapshotOf(stack); final ChangeInventoryEvent.Pickup.Pre event = SpongeEventFactory.createChangeInventoryEventPickupPre( - causeStackManager.getCurrentCause(), + causeStackManager.currentCause(), Optional.empty(), Collections.singletonList(snapshot), ((Inventory) player.inventory), (Item) itemToPickup, snapshot); SpongeCommon.postEvent(event); causeStackManager.popCause(); if (event.isCancelled()) { return false; } - if (event.getCustom().isPresent()) { - final List list = event.getCustom().get(); + if (event.custom().isPresent()) { + final List list = event.custom().get(); if (list.isEmpty()) { itemToPickup.getItem().setCount(0); return false; @@ -130,7 +130,7 @@ public static boolean callPlayerChangeInventoryPickupPreEvent(final Player playe capture.bridge$setCaptureInventory(false); if (!fullTransfer) { for (final SlotTransaction trans : capture.bridge$getCapturedSlotTransactions()) { - trans.getSlot().set(trans.getOriginal().createStack()); + trans.slot().set(trans.original().createStack()); } return false; } @@ -148,7 +148,7 @@ public static boolean callPlayerChangeInventoryPickupEvent(final Player player, return true; } PhaseTracker.getCauseStackManager().pushCause(player); - final ChangeInventoryEvent.Pickup event = SpongeEventFactory.createChangeInventoryEventPickup(PhaseTracker.getCauseStackManager().getCurrentCause(), (Inventory) player.containerMenu, + final ChangeInventoryEvent.Pickup event = SpongeEventFactory.createChangeInventoryEventPickup(PhaseTracker.getCauseStackManager().currentCause(), (Inventory) player.containerMenu, inventory.bridge$getCapturedSlotTransactions()); SpongeCommon.postEvent(event); PhaseTracker.getCauseStackManager().popCause(); @@ -164,7 +164,7 @@ public static ItemStack callInventoryPickupEvent(final Container inventory, fina final ItemStackSnapshot snapshot = ItemStackUtil.snapshotOf(stack); final ChangeInventoryEvent.Pickup.Pre event = - SpongeEventFactory.createChangeInventoryEventPickupPre(frame.getCurrentCause(), + SpongeEventFactory.createChangeInventoryEventPickupPre(frame.currentCause(), Optional.empty(), Collections.singletonList(snapshot), (Inventory) inventory, (Item) item, snapshot); SpongeCommon.postEvent(event); if (event.isCancelled()) { @@ -177,13 +177,13 @@ public static ItemStack callInventoryPickupEvent(final Container inventory, fina prevInventory[i] = inventory.getItem(i); } - if (event.getCustom().isPresent()) { - if (event.getCustom().get().isEmpty()) { + if (event.custom().isPresent()) { + if (event.custom().get().isEmpty()) { return ItemStack.EMPTY; } boolean fullTransfer = true; - for (final ItemStackSnapshot snap : event.getCustom().get()) { + for (final ItemStackSnapshot snap : event.custom().get()) { final ItemStack stackToAdd = ItemStackUtil.fromSnapshotToNative(snap); final ItemStack remaining = HopperBlockEntity.addItem(null, inventory, stackToAdd, null); if (!remaining.isEmpty()) { @@ -218,7 +218,7 @@ private static boolean callInventoryPickupEvent(final Container inventory, final if (trans.isEmpty()) { return true; } - final ChangeInventoryEvent.Pickup event = SpongeEventFactory.createChangeInventoryEventPickup(PhaseTracker.getCauseStackManager().getCurrentCause(), spongeInventory, trans); + final ChangeInventoryEvent.Pickup event = SpongeEventFactory.createChangeInventoryEventPickup(PhaseTracker.getCauseStackManager().currentCause(), spongeInventory, trans); SpongeCommon.postEvent(event); InventoryEventFactory.applyTransactions(event); return !event.isCancelled(); @@ -245,16 +245,16 @@ private static List generateTransactions(@Nullable final Invent private static void applyTransactions(final ChangeInventoryEvent.Pickup event) { if (event.isCancelled()) { - for (final SlotTransaction trans : event.getTransactions()) { - trans.getSlot().set(trans.getOriginal().createStack()); + for (final SlotTransaction trans : event.transactions()) { + trans.slot().set(trans.original().createStack()); } return; } - for (final SlotTransaction trans : event.getTransactions()) { + for (final SlotTransaction trans : event.transactions()) { if (!trans.isValid()) { - trans.getSlot().set(trans.getOriginal().createStack()); - } else if (trans.getCustom().isPresent()) { - trans.getSlot().set(trans.getFinal().createStack()); + trans.slot().set(trans.original().createStack()); + } else if (trans.custom().isPresent()) { + trans.slot().set(trans.finalReplacement().createStack()); } } } @@ -278,7 +278,7 @@ public static ClickContainerEvent.Creative callCreativeClickContainerEvent(final } } final ClickContainerEvent.Creative event = - SpongeEventFactory.createClickContainerEventCreative(frame.getCurrentCause(), (org.spongepowered.api.item.inventory.Container) player.containerMenu, cursorTransaction, + SpongeEventFactory.createClickContainerEventCreative(frame.currentCause(), (org.spongepowered.api.item.inventory.Container) player.containerMenu, cursorTransaction, Optional.ofNullable(slot), new ArrayList<>(captures)); captures.clear(); @@ -293,7 +293,7 @@ public static boolean callInteractContainerOpenEvent(final ServerPlayer player) final ItemStackSnapshot newCursor = ItemStackUtil.snapshotOf(player.inventory.getCarried()); final Transaction cursorTransaction = new Transaction<>(ItemStackSnapshot.empty(), newCursor); final InteractContainerEvent.Open event = - SpongeEventFactory.createInteractContainerEventOpen(PhaseTracker.getCauseStackManager().getCurrentCause(), + SpongeEventFactory.createInteractContainerEventOpen(PhaseTracker.getCauseStackManager().currentCause(), (org.spongepowered.api.item.inventory.Container) player.containerMenu, cursorTransaction); SpongeCommon.postEvent(event); if (event.isCancelled()) { @@ -303,8 +303,8 @@ public static boolean callInteractContainerOpenEvent(final ServerPlayer player) // TODO - determine if/how we want to fire inventory events outside of click packet handlers //((ContainerBridge) player.openContainer).bridge$setCaptureInventory(true); // Custom cursor - if (event.getCursorTransaction().getCustom().isPresent()) { - handleCustomCursor(player, event.getCursorTransaction().getFinal()); + if (event.cursorTransaction().custom().isPresent()) { + handleCustomCursor(player, event.cursorTransaction().finalReplacement()); } return true; } @@ -323,7 +323,7 @@ public static AbstractContainerMenu displayContainer(final ServerPlayer player, } player.openMenu(namedContainerProvider); } else if (viewable.get() instanceof CarriedInventory) { - Optional carrier = ((CarriedInventory) viewable.get()).getCarrier(); + Optional carrier = ((CarriedInventory) viewable.get()).carrier(); if (carrier.get() instanceof AbstractHorse) { player.openHorseInventory(((AbstractHorse) carrier.get()), ((Container) viewable.get())); } @@ -377,7 +377,7 @@ public static AbstractContainerMenu displayContainer(final ServerPlayer player, public static TransferInventoryEvent.Pre callTransferPre(final Inventory source, final Inventory destination) { PhaseTracker.getCauseStackManager().pushCause(source); final TransferInventoryEvent.Pre event = SpongeEventFactory.createTransferInventoryEventPre( - PhaseTracker.getCauseStackManager().getCurrentCause(), source, destination); + PhaseTracker.getCauseStackManager().currentCause(), source, destination); SpongeCommon.postEvent(event); PhaseTracker.getCauseStackManager().popCause(); return event; @@ -396,18 +396,18 @@ public static void callTransferPost(@Nullable final TrackedInventoryBridge captu sourceStack.setCount(1); ItemStackSnapshot transferredStack = ItemStackUtil.snapshotOf(sourceStack); - Slot sourceSlot = sourceSlotTransaction.getSlot(); + Slot sourceSlot = sourceSlotTransaction.slot(); Slot targetSlot = null; // There should only be 2 transactions - the other is the transaction on the target slot for (SlotTransaction transaction : slotTransactions) { if (transaction != sourceSlotTransaction) { - targetSlot = transaction.getSlot(); + targetSlot = transaction.slot(); break; } } final TransferInventoryEvent.Post event = - SpongeEventFactory.createTransferInventoryEventPost(PhaseTracker.getCauseStackManager().getCurrentCause(), + SpongeEventFactory.createTransferInventoryEventPost(PhaseTracker.getCauseStackManager().currentCause(), source, sourceSlot, destination, targetSlot, transferredStack); SpongeCommon.postEvent(event); slotTransactions.clear(); @@ -429,7 +429,7 @@ public static SlotTransaction captureTransaction(@Nullable final TrackedInventor return null; } - Optional slot = inv.getSlot(index); + Optional slot = inv.slot(index); if (slot.isPresent()) { SlotTransaction trans = new SlotTransaction(slot.get(), ItemStackUtil.snapshotOf(originalStack), @@ -459,7 +459,7 @@ public static ItemStack captureTransaction(@Nullable final TrackedInventoryBridg return transaction.get(); } - Optional slot = inv.getSlot(index); + Optional slot = inv.slot(index); if (!slot.isPresent()) { SpongeCommon.getLogger().warn("Unable to capture transaction from " + inv.getClass() + " at index " + index); return transaction.get(); @@ -476,14 +476,14 @@ public static ItemStack captureTransaction(@Nullable final TrackedInventoryBridg public static CraftItemEvent.Preview callCraftEventPre(final Player player, final CraftingInventory inventory, final SlotTransaction previewTransaction, @Nullable final CraftingRecipe recipe, final AbstractContainerMenu container, final List transactions) { final CraftItemEvent.Preview event = SpongeEventFactory - .createCraftItemEventPreview(PhaseTracker.getCauseStackManager().getCurrentCause(), inventory, (Inventory) container, previewTransaction, Optional.ofNullable(recipe), transactions); + .createCraftItemEventPreview(PhaseTracker.getCauseStackManager().currentCause(), inventory, (Inventory) container, previewTransaction, Optional.ofNullable(recipe), transactions); SpongeCommon.postEvent(event); PacketPhaseUtil.handleSlotRestore(player, container, new ArrayList<>(transactions), event.isCancelled()); if (player instanceof ServerPlayer) { - if (event.getPreview().getCustom().isPresent() || event.isCancelled() || !event.getPreview().isValid()) { - ItemStackSnapshot stack = event.getPreview().getFinal(); - if (event.isCancelled() || !event.getPreview().isValid()) { - stack = event.getPreview().getOriginal(); + if (event.preview().custom().isPresent() || event.isCancelled() || !event.preview().isValid()) { + ItemStackSnapshot stack = event.preview().finalReplacement(); + if (event.isCancelled() || !event.preview().isValid()) { + stack = event.preview().original(); } // Resend modified output ((ServerPlayer) player).connection.send(new ClientboundContainerSetSlotPacket(0, 0, ItemStackUtil.fromSnapshotToNative(stack))); @@ -502,8 +502,8 @@ public static CraftItemEvent.Craft callCraftEventPost(final Player player, final previousCursor = player.inventory.getCarried(); // or get the current one } final Transaction cursorTransaction = new Transaction<>(ItemStackUtil.snapshotOf(previousCursor), ItemStackUtil.snapshotOf(player.inventory.getCarried())); - final org.spongepowered.api.item.inventory.Slot slot = inventory.getResult(); - final CraftItemEvent.Craft event = SpongeEventFactory.createCraftItemEventCraft(PhaseTracker.getCauseStackManager().getCurrentCause(), + final org.spongepowered.api.item.inventory.Slot slot = inventory.result(); + final CraftItemEvent.Craft event = SpongeEventFactory.createCraftItemEventCraft(PhaseTracker.getCauseStackManager().currentCause(), ContainerUtil.fromNative(container), result, inventory, cursorTransaction, Optional.ofNullable(recipe), Optional.of(slot), transactions); SpongeCommon.postEvent(event); @@ -511,9 +511,9 @@ public static CraftItemEvent.Craft callCraftEventPost(final Player player, final ((TrackedInventoryBridge) container).bridge$setCaptureInventory(false); // handle slot-transactions PacketPhaseUtil.handleSlotRestore(player, container, new ArrayList<>(transactions), event.isCancelled()); - if (event.isCancelled() || !event.getCursorTransaction().isValid() || event.getCursorTransaction().getCustom().isPresent()) { + if (event.isCancelled() || !event.cursorTransaction().isValid() || event.cursorTransaction().custom().isPresent()) { // handle cursor-transaction - final ItemStackSnapshot newCursor = event.isCancelled() || event.getCursorTransaction().isValid() ? event.getCursorTransaction().getOriginal() : event.getCursorTransaction().getFinal(); + final ItemStackSnapshot newCursor = event.isCancelled() || event.cursorTransaction().isValid() ? event.cursorTransaction().original() : event.cursorTransaction().finalReplacement(); player.inventory.setCarried(ItemStackUtil.fromSnapshotToNative(newCursor)); if (player instanceof ServerPlayer) { ((ServerPlayer) player).connection.send(new ClientboundContainerSetSlotPacket(-1, -1, player.inventory.getCarried())); @@ -528,7 +528,7 @@ public static CraftItemEvent.Craft callCraftEventPost(final Player player, final public static UpdateAnvilEvent callUpdateAnvilEvent(final AnvilMenu anvil, final ItemStack slot1, final ItemStack slot2, final ItemStack result, final String name, final int levelCost, final int materialCost) { final Transaction transaction = new Transaction<>(ItemStackSnapshot.empty(), ItemStackUtil.snapshotOf(result)); final UpdateAnvilEventCost costs = new UpdateAnvilEventCost(levelCost, materialCost); - final UpdateAnvilEvent event = SpongeEventFactory.createUpdateAnvilEvent(PhaseTracker.getCauseStackManager().getCurrentCause(), + final UpdateAnvilEvent event = SpongeEventFactory.createUpdateAnvilEvent(PhaseTracker.getCauseStackManager().currentCause(), new Transaction<>(costs, costs), (Inventory)anvil, name, ItemStackUtil.snapshotOf(slot1), transaction, ItemStackUtil.snapshotOf(slot2)); SpongeCommon.postEvent(event); return event; @@ -542,9 +542,9 @@ public static ChangeEntityEquipmentEvent callChangeEntityEquipmentEvent( frame.pushCause(entity); final Transaction transaction = new Transaction<>(before, after); if (after.isEmpty()) { - event = SpongeEventFactory.createChangeEntityEquipmentEventBreak(frame.getCurrentCause(), (Entity) entity, slot, transaction); + event = SpongeEventFactory.createChangeEntityEquipmentEventBreak(frame.currentCause(), (Entity) entity, slot, transaction); } else { - event = SpongeEventFactory.createChangeEntityEquipmentEvent(frame.getCurrentCause(), (Entity) entity, slot, transaction); + event = SpongeEventFactory.createChangeEntityEquipmentEvent(frame.currentCause(), (Entity) entity, slot, transaction); } SpongeCommon.postEvent(event); return event; @@ -555,17 +555,17 @@ public static ChangeEntityEquipmentEvent callChangeEntityEquipmentEvent( public static int callEnchantEventLevelRequirement(EnchantmentMenu container, int seed, int option, int power, ItemStack itemStack, int levelRequirement) { org.spongepowered.api.item.inventory.Container enchantContainer = ContainerUtil.fromNative(container); - Player viewer = (Player) enchantContainer.getViewer(); + Player viewer = (Player) enchantContainer.viewer(); ItemStackSnapshot cursor = ItemStackUtil.snapshotOf(viewer.inventory.getCarried()); Transaction cursorTrans = new Transaction<>(cursor, cursor); EnchantItemEvent.CalculateLevelRequirement event = - SpongeEventFactory.createEnchantItemEventCalculateLevelRequirement(PhaseTracker.getCauseStackManager().getCurrentCause(), + SpongeEventFactory.createEnchantItemEventCalculateLevelRequirement(PhaseTracker.getCauseStackManager().currentCause(), levelRequirement, levelRequirement, enchantContainer, cursorTrans, ItemStackUtil.snapshotOf(itemStack), option, power, seed); SpongeCommon.postEvent(event); - return event.getLevelRequirement(); + return event.levelRequirement(); } public static List callEnchantEventEnchantmentList(EnchantmentMenu container, @@ -575,18 +575,18 @@ public static List callEnchantEventEnchantmentList(Enchantm org.spongepowered.api.item.inventory.Container enchantContainer = ContainerUtil.fromNative(container); - Player viewer = (Player) enchantContainer.getViewer(); + Player viewer = (Player) enchantContainer.viewer(); ItemStackSnapshot cursor = ItemStackUtil.snapshotOf(viewer.inventory.getCarried()); Transaction cursorTrans = new Transaction<>(cursor, cursor); EnchantItemEvent.CalculateEnchantment event = - SpongeEventFactory.createEnchantItemEventCalculateEnchantment(PhaseTracker.getCauseStackManager().getCurrentCause(), + SpongeEventFactory.createEnchantItemEventCalculateEnchantment(PhaseTracker.getCauseStackManager().currentCause(), enchList, enchList, enchantContainer, cursorTrans, ItemStackUtil.snapshotOf(itemStack), level, option, seed); SpongeCommon.postEvent(event); - if (event.getEnchantments() != event.getOriginalEnchantments()) { - return SpongeRandomEnchantmentListBuilder.toNative(event.getEnchantments()); + if (event.enchantments() != event.originalEnchantments()) { + return SpongeRandomEnchantmentListBuilder.toNative(event.enchantments()); } return list; } @@ -604,16 +604,16 @@ public static EnchantItemEvent.Post callEnchantEventEnchantPost(Player playerIn, slotTrans.add(enchantedItem); EnchantItemEvent.Post event = - SpongeEventFactory.createEnchantItemEventPost(PhaseTracker.getCauseStackManager().getCurrentCause(), enchantContainer, - cursorTrans, enchantedItem.getSlot(), Optional.empty(),slotTrans, option, seed); + SpongeEventFactory.createEnchantItemEventPost(PhaseTracker.getCauseStackManager().currentCause(), enchantContainer, + cursorTrans, enchantedItem.slot(), Optional.empty(),slotTrans, option, seed); SpongeCommon.postEvent(event); - PacketPhaseUtil.handleSlotRestore(playerIn, container, event.getTransactions(), event.isCancelled()); - if (event.isCancelled() || !event.getCursorTransaction().isValid()) { - PacketPhaseUtil.handleCustomCursor(playerIn, event.getCursorTransaction().getOriginal()); - } else if (event.getCursorTransaction().getCustom().isPresent()) { - PacketPhaseUtil.handleCustomCursor(playerIn, event.getCursorTransaction().getFinal()); + PacketPhaseUtil.handleSlotRestore(playerIn, container, event.transactions(), event.isCancelled()); + if (event.isCancelled() || !event.cursorTransaction().isValid()) { + PacketPhaseUtil.handleCustomCursor(playerIn, event.cursorTransaction().original()); + } else if (event.cursorTransaction().custom().isPresent()) { + PacketPhaseUtil.handleCustomCursor(playerIn, event.cursorTransaction().finalReplacement()); } return event; diff --git a/src/main/java/org/spongepowered/common/event/inventory/UpdateAnvilEventCost.java b/src/main/java/org/spongepowered/common/event/inventory/UpdateAnvilEventCost.java index 1bb5842190f..2d8562060b0 100644 --- a/src/main/java/org/spongepowered/common/event/inventory/UpdateAnvilEventCost.java +++ b/src/main/java/org/spongepowered/common/event/inventory/UpdateAnvilEventCost.java @@ -39,11 +39,11 @@ public UpdateAnvilEventCost(int levelCost, int materialCost) { this.materialCost = materialCost; } - public int getLevelCost() { + public int levelCost() { return this.levelCost; } - public int getMaterialCost() { + public int materialCost() { return this.materialCost; } @@ -56,14 +56,14 @@ public AnvilCost withMaterialCost(int materialCost) { } @Override - public int getContentVersion() { + public int contentVersion() { return 1; } @Override public DataContainer toContainer() { - return DataContainer.createNew().set(Queries.CONTENT_VERSION, this.getContentVersion()) - .set(Constants.TileEntity.Anvils.MATERIALCOST, this.getMaterialCost()) - .set(Constants.TileEntity.Anvils.LEVELCOST, this.getLevelCost()); + return DataContainer.createNew().set(Queries.CONTENT_VERSION, this.contentVersion()) + .set(Constants.TileEntity.Anvils.MATERIALCOST, this.materialCost()) + .set(Constants.TileEntity.Anvils.LEVELCOST, this.levelCost()); } } diff --git a/src/main/java/org/spongepowered/common/event/lifecycle/AbstractLifecycleEvent.java b/src/main/java/org/spongepowered/common/event/lifecycle/AbstractLifecycleEvent.java index 555de16c88f..438fdb94273 100644 --- a/src/main/java/org/spongepowered/common/event/lifecycle/AbstractLifecycleEvent.java +++ b/src/main/java/org/spongepowered/common/event/lifecycle/AbstractLifecycleEvent.java @@ -41,12 +41,12 @@ public AbstractLifecycleEvent(final Cause cause, final Game game) { } @Override - public final Cause getCause() { + public final Cause cause() { return this.cause; } @Override - public final Game getGame() { + public final Game game() { return this.game; } @@ -60,7 +60,7 @@ public GenericImpl(final Cause cause, final Game game, final TypeToken token) } @Override - public final TypeToken getParamType() { + public final TypeToken paramType() { return this.token; } } diff --git a/src/main/java/org/spongepowered/common/event/lifecycle/AbstractProvideServiceEventImpl.java b/src/main/java/org/spongepowered/common/event/lifecycle/AbstractProvideServiceEventImpl.java index cde42593da6..7383079bda0 100644 --- a/src/main/java/org/spongepowered/common/event/lifecycle/AbstractProvideServiceEventImpl.java +++ b/src/main/java/org/spongepowered/common/event/lifecycle/AbstractProvideServiceEventImpl.java @@ -84,7 +84,7 @@ public EngineScopedImpl(final Cause cause, final Game game, final TypeToken t } @Override - public Engine getEngine() { + public Engine engine() { return this.engine; } diff --git a/src/main/java/org/spongepowered/common/event/lifecycle/AbstractRegisterRegistryEvent.java b/src/main/java/org/spongepowered/common/event/lifecycle/AbstractRegisterRegistryEvent.java index cc26c593296..adb7504f164 100644 --- a/src/main/java/org/spongepowered/common/event/lifecycle/AbstractRegisterRegistryEvent.java +++ b/src/main/java/org/spongepowered/common/event/lifecycle/AbstractRegisterRegistryEvent.java @@ -95,7 +95,7 @@ public EngineScopedImpl(final Cause cause, final Game game, final E engine) { } @Override - public TypeToken getParamType() { + public TypeToken paramType() { return this.token; } @@ -115,13 +115,13 @@ public WorldScopedImpl(final Cause cause, final Game game, final ResourceKey wor } @Override - public ResourceKey getWorldKey() { + public ResourceKey worldKey() { return this.worldKey; } @Override protected SpongeRegistryHolder getHolder() { - return (SpongeRegistryHolder) this.game.getServer().getWorldManager().world(this.worldKey).get().registries(); + return (SpongeRegistryHolder) this.game.server().worldManager().world(this.worldKey).get().registries(); } } } diff --git a/src/main/java/org/spongepowered/common/event/lifecycle/AbstractRegisterRegistryValueEvent.java b/src/main/java/org/spongepowered/common/event/lifecycle/AbstractRegisterRegistryValueEvent.java index cc0f18e4a51..119a01ddf13 100644 --- a/src/main/java/org/spongepowered/common/event/lifecycle/AbstractRegisterRegistryValueEvent.java +++ b/src/main/java/org/spongepowered/common/event/lifecycle/AbstractRegisterRegistryValueEvent.java @@ -97,7 +97,7 @@ public EngineScopedImpl(final Cause cause, final Game game, final E engine) { } @Override - public TypeToken getParamType() { + public TypeToken paramType() { return this.token; } @@ -117,13 +117,13 @@ public WorldScopedImpl(final Cause cause, final Game game, final ResourceKey wor } @Override - public ResourceKey getWorldKey() { + public ResourceKey worldKey() { return this.worldKey; } @Override protected RegistryHolder getHolder() { - return Sponge.getServer().getWorldManager().world(this.worldKey).orElse(null).registries(); + return Sponge.server().worldManager().world(this.worldKey).orElse(null).registries(); } } } diff --git a/src/main/java/org/spongepowered/common/event/lifecycle/RegisterBuilderEventImpl.java b/src/main/java/org/spongepowered/common/event/lifecycle/RegisterBuilderEventImpl.java index 02b328480ab..54d6abe38a8 100644 --- a/src/main/java/org/spongepowered/common/event/lifecycle/RegisterBuilderEventImpl.java +++ b/src/main/java/org/spongepowered/common/event/lifecycle/RegisterBuilderEventImpl.java @@ -44,7 +44,7 @@ public RegisterBuilderEventImpl(final Cause cause, final Game game) { @Override public > void register(Class builderClass, Supplier supplier) throws DuplicateRegistrationException { - ((SpongeBuilderProvider) Sponge.getGame().getBuilderProvider()).register(builderClass, Objects.requireNonNull((Supplier < T >) supplier, + ((SpongeBuilderProvider) Sponge.game().builderProvider()).register(builderClass, Objects.requireNonNull((Supplier < T >) supplier, "supplier")); } diff --git a/src/main/java/org/spongepowered/common/event/lifecycle/RegisterFactoryEventImpl.java b/src/main/java/org/spongepowered/common/event/lifecycle/RegisterFactoryEventImpl.java index d9b7622aa30..1414cdb52a7 100644 --- a/src/main/java/org/spongepowered/common/event/lifecycle/RegisterFactoryEventImpl.java +++ b/src/main/java/org/spongepowered/common/event/lifecycle/RegisterFactoryEventImpl.java @@ -42,7 +42,7 @@ public RegisterFactoryEventImpl(final Cause cause, final Game game) { @SuppressWarnings("unchecked") @Override public T register(final Class factoryClass, final T factory) throws DuplicateRegistrationException { - return (T) ((SpongeFactoryProvider) Sponge.getGame().getFactoryProvider()).registerFactory(factoryClass, Objects.requireNonNull(factory, + return (T) ((SpongeFactoryProvider) Sponge.game().factoryProvider()).registerFactory(factoryClass, Objects.requireNonNull(factory, "factory")); } diff --git a/src/main/java/org/spongepowered/common/event/tracking/IPhaseState.java b/src/main/java/org/spongepowered/common/event/tracking/IPhaseState.java index d7909e2716e..6d27a292dc9 100644 --- a/src/main/java/org/spongepowered/common/event/tracking/IPhaseState.java +++ b/src/main/java/org/spongepowered/common/event/tracking/IPhaseState.java @@ -502,7 +502,7 @@ default BlockChange associateBlockChangeWithSnapshot(final C phaseContext, final * {@link CauseStackManager}. In certain cases, there are states that can have * excessive modifiers being pushed and popped with and without causes that may cause * performance degredation due to the excessive amounts of how many recyclings occur - * with {@link CauseStackManager#getCurrentCause()} lacking a cached context + * with {@link CauseStackManager#currentCause()} lacking a cached context * and therefor needing to re-create the context each and every time. * * @param phaseContext The appropriate phase context @@ -557,7 +557,7 @@ default SpawnEntityEvent createSpawnEvent(final C context, ) { return SpongeEventFactory.createSpawnEntityEvent(currentCause, collect.stream() - .map(t -> (org.spongepowered.api.entity.Entity) t.getFirst()) + .map(t -> (org.spongepowered.api.entity.Entity) t.first()) .collect(Collectors.toList()) ); } diff --git a/src/main/java/org/spongepowered/common/event/tracking/PhasePrinter.java b/src/main/java/org/spongepowered/common/event/tracking/PhasePrinter.java index 259cc4ef8a2..81e42db2f76 100644 --- a/src/main/java/org/spongepowered/common/event/tracking/PhasePrinter.java +++ b/src/main/java/org/spongepowered/common/event/tracking/PhasePrinter.java @@ -100,7 +100,7 @@ static void printNullSourceForBlock(final ServerLevel worldServer, final BlockPo + "issue tracker on GitHub. Please provide the following information: ") .add() .add(" %s : %s", "Source position", pos) - .add(" %s : %s", "World", ((org.spongepowered.api.world.server.ServerWorld) worldServer).getKey()) + .add(" %s : %s", "World", ((org.spongepowered.api.world.server.ServerWorld) worldServer).key()) .add(" %s : %s", "Source Block Recovered", blockIn) .add(" %s : %s", "Notified Position", otherPos).add(); @@ -351,8 +351,8 @@ static void generateVersionInfo(final PrettyPrinter printer) { static void printIncorrectPhaseCompletion(final PhaseStack stack, final IPhaseState<@NonNull ?> prevState, final IPhaseState<@NonNull ?> state) { if (!SpongeConfigs.getCommon().get().phaseTracker.verbose && !PhasePrinter.completedIncorrectStates.isEmpty()) { for (final Tuple, IPhaseState<@NonNull ?>> tuple : PhasePrinter.completedIncorrectStates) { - if ((tuple.getFirst().equals(prevState) - && tuple.getSecond().equals(state))) { + if ((tuple.first().equals(prevState) + && tuple.second().equals(state))) { // we've already printed once about the previous state and the current state // being completed incorrectly. only print it once. return; diff --git a/src/main/java/org/spongepowered/common/event/tracking/PhaseStateProxy.java b/src/main/java/org/spongepowered/common/event/tracking/PhaseStateProxy.java index 8e4f7072423..a949ac24e49 100644 --- a/src/main/java/org/spongepowered/common/event/tracking/PhaseStateProxy.java +++ b/src/main/java/org/spongepowered/common/event/tracking/PhaseStateProxy.java @@ -426,7 +426,7 @@ default BlockChange associateBlockChangeWithSnapshot(final BlockState newState, * {@link CauseStackManager}. In certain cases, there are states that can have * excessive modifiers being pushed and popped with and without causes that may cause * performance degredation due to the excessive amounts of how many recyclings occur - * with {@link CauseStackManager#getCurrentCause()} lacking a cached context + * with {@link CauseStackManager#currentCause()} lacking a cached context * and therefor needing to re-create the context each and every time. * * @return True if the modifiers should be pushed to the manager diff --git a/src/main/java/org/spongepowered/common/event/tracking/PhaseTracker.java b/src/main/java/org/spongepowered/common/event/tracking/PhaseTracker.java index d5aeef2bb51..c796287171d 100644 --- a/src/main/java/org/spongepowered/common/event/tracking/PhaseTracker.java +++ b/src/main/java/org/spongepowered/common/event/tracking/PhaseTracker.java @@ -487,20 +487,20 @@ public String toString() { } @Override - public Cause getCurrentCause() { + public Cause currentCause() { this.enforceMainThread(); if (this.cached_cause == null || this.cached_ctx == null) { if (this.cause.isEmpty()) { - this.cached_cause = Cause.of(this.getCurrentContext(), SpongeCommon.getGame()); + this.cached_cause = Cause.of(this.currentContext(), SpongeCommon.getGame()); } else { - this.cached_cause = Cause.of(this.getCurrentContext(), this.cause); + this.cached_cause = Cause.of(this.currentContext(), this.cause); } } return this.cached_cause; } @Override - public EventContext getCurrentContext() { + public EventContext currentContext() { this.enforceMainThread(); if (this.cached_ctx == null) { this.cached_ctx = EventContext.of(this.ctx); @@ -720,7 +720,7 @@ public CauseStackManager addContext(final EventContextKey key, final T va } @Override - public Optional getContext(final EventContextKey key) { + public Optional context(final EventContextKey key) { checkNotNull(key, "key"); this.enforceMainThread(); return Optional.ofNullable((T) this.ctx.get(key)); diff --git a/src/main/java/org/spongepowered/common/event/tracking/SpongeCauseStackFrame.java b/src/main/java/org/spongepowered/common/event/tracking/SpongeCauseStackFrame.java index 5801edbbf71..cd0f5015f39 100644 --- a/src/main/java/org/spongepowered/common/event/tracking/SpongeCauseStackFrame.java +++ b/src/main/java/org/spongepowered/common/event/tracking/SpongeCauseStackFrame.java @@ -97,13 +97,13 @@ Map, Object> getOriginalContextDelta() { } @Override - public Cause getCurrentCause() { - return this.tracker.getCurrentCause(); + public Cause currentCause() { + return this.tracker.currentCause(); } @Override - public EventContext getCurrentContext() { - return this.tracker.getCurrentContext(); + public EventContext currentContext() { + return this.tracker.currentContext(); } @Override diff --git a/src/main/java/org/spongepowered/common/event/tracking/TrackingUtil.java b/src/main/java/org/spongepowered/common/event/tracking/TrackingUtil.java index ba9495c2235..55de240f9e0 100644 --- a/src/main/java/org/spongepowered/common/event/tracking/TrackingUtil.java +++ b/src/main/java/org/spongepowered/common/event/tracking/TrackingUtil.java @@ -229,7 +229,7 @@ public static void updateTickBlock( if (ShouldFire.TICK_BLOCK_EVENT) { final BlockSnapshot snapshot = mixinWorld.bridge$createSnapshot(block, pos, BlockChangeFlags.NONE); - final TickBlockEvent event = SpongeEventFactory.createTickBlockEventScheduled(PhaseTracker.getCauseStackManager().getCurrentCause(), snapshot); + final TickBlockEvent event = SpongeEventFactory.createTickBlockEventScheduled(PhaseTracker.getCauseStackManager().currentCause(), snapshot); SpongeCommon.postEvent(event); if (event.isCancelled()) { return; @@ -265,7 +265,7 @@ public static void updateTickFluid( final net.minecraft.world.level.block.state.BlockState blockState = fluidState.createLegacyBlock(); if (ShouldFire.TICK_BLOCK_EVENT) { final BlockSnapshot snapshot = mixinWorld.bridge$createSnapshot(blockState, pos, BlockChangeFlags.NONE); - final TickBlockEvent event = SpongeEventFactory.createTickBlockEventScheduled(PhaseTracker.getCauseStackManager().getCurrentCause(), snapshot); + final TickBlockEvent event = SpongeEventFactory.createTickBlockEventScheduled(PhaseTracker.getCauseStackManager().currentCause(), snapshot); SpongeCommon.postEvent(event); if (event.isCancelled()) { return; @@ -304,7 +304,7 @@ public static void randomTickBlock(final TrackedWorldBridge mixinWorld, final BlockSnapshot currentTickBlock = mixinWorld.bridge$createSnapshot(state, pos, BlockChangeFlags.NONE); final TickBlockEvent event = - SpongeEventFactory.createTickBlockEventRandom(PhaseTracker.getCauseStackManager().getCurrentCause(), currentTickBlock); + SpongeEventFactory.createTickBlockEventRandom(PhaseTracker.getCauseStackManager().currentCause(), currentTickBlock); SpongeCommon.postEvent(event); if (event.isCancelled()) { return; @@ -340,7 +340,7 @@ public static void randomTickFluid(final TrackedWorldBridge mixinWorld, final BlockSnapshot currentTickBlock = mixinWorld.bridge$createSnapshot(state.createLegacyBlock(), pos, BlockChangeFlags.NONE); final TickBlockEvent event = - SpongeEventFactory.createTickBlockEventRandom(PhaseTracker.getCauseStackManager().getCurrentCause(), currentTickBlock); + SpongeEventFactory.createTickBlockEventRandom(PhaseTracker.getCauseStackManager().currentCause(), currentTickBlock); SpongeCommon.postEvent(event); if (event.isCancelled()) { return; @@ -457,10 +457,10 @@ public static boolean processBlockCaptures(final PhaseContext context) { } public static void associateTrackerToTarget(final BlockChange blockChange, final Transaction transaction, final User user) { - final BlockSnapshot finalSnapshot = transaction.getFinal(); + final BlockSnapshot finalSnapshot = transaction.finalReplacement(); final SpongeBlockSnapshot spongeSnapshot = (SpongeBlockSnapshot) finalSnapshot; final BlockPos pos = spongeSnapshot.getBlockPos(); - final Block block = ((net.minecraft.world.level.block.state.BlockState) spongeSnapshot.getState()).getBlock(); + final Block block = ((net.minecraft.world.level.block.state.BlockState) spongeSnapshot.state()).getBlock(); spongeSnapshot.getServerWorld() .map(world -> world.getChunkAt(pos)) .map(chunk -> (LevelChunkBridge) chunk) diff --git a/src/main/java/org/spongepowered/common/event/tracking/context/transaction/AddBlockEventTransaction.java b/src/main/java/org/spongepowered/common/event/tracking/context/transaction/AddBlockEventTransaction.java index 003973fb2fa..435826ef411 100644 --- a/src/main/java/org/spongepowered/common/event/tracking/context/transaction/AddBlockEventTransaction.java +++ b/src/main/java/org/spongepowered/common/event/tracking/context/transaction/AddBlockEventTransaction.java @@ -45,7 +45,7 @@ public class AddBlockEventTransaction extends BlockEventBasedTransaction { AddBlockEventTransaction(final SpongeBlockSnapshot original, final TrackerBlockEventDataBridge blockEvent) { - super(original.getBlockPos(), (BlockState) original.getState(), original.getWorld()); + super(original.getBlockPos(), (BlockState) original.state(), original.world()); this.blockEvent = (BlockEventData) blockEvent; this.original = original; } diff --git a/src/main/java/org/spongepowered/common/event/tracking/context/transaction/AddTileEntity.java b/src/main/java/org/spongepowered/common/event/tracking/context/transaction/AddTileEntity.java index d984d4a2126..f48fcd6033a 100644 --- a/src/main/java/org/spongepowered/common/event/tracking/context/transaction/AddTileEntity.java +++ b/src/main/java/org/spongepowered/common/event/tracking/context/transaction/AddTileEntity.java @@ -51,7 +51,7 @@ public final class AddTileEntity extends BlockEventBasedTransaction { final SpongeBlockSnapshot attachedSnapshot, final SpongeBlockSnapshot existing ) { - super(existing.getBlockPos(), (BlockState) existing.getState(), ((ServerWorld) added.getLevel()).getKey()); + super(existing.getBlockPos(), (BlockState) existing.state(), ((ServerWorld) added.getLevel()).key()); this.added = added; this.addedSnapshot = attachedSnapshot; this.oldSnapshot = existing; diff --git a/src/main/java/org/spongepowered/common/event/tracking/context/transaction/BlockEventBasedTransaction.java b/src/main/java/org/spongepowered/common/event/tracking/context/transaction/BlockEventBasedTransaction.java index cbd3348ee7b..a971ebd158d 100644 --- a/src/main/java/org/spongepowered/common/event/tracking/context/transaction/BlockEventBasedTransaction.java +++ b/src/main/java/org/spongepowered/common/event/tracking/context/transaction/BlockEventBasedTransaction.java @@ -72,7 +72,7 @@ public final Optional generateEvent(final PhaseContext<@No final Cause currentCause, final ImmutableMultimap.Builder transactionPostEventBuilder ) { - final Optional o = ((SpongeServer) SpongeCommon.getServer()).getWorldManager().world(this.worldKey); + final Optional o = ((SpongeServer) SpongeCommon.getServer()).worldManager().world(this.worldKey); if (!o.isPresent()) { return Optional.empty(); } @@ -133,12 +133,12 @@ public final boolean markCancelledTransactions(final ChangeBlockEvent.All event, final ImmutableList> blockTransactions ) { boolean cancelledAny = false; - for (final Transaction transaction : event.getTransactions()) { + for (final Transaction transaction : event.transactions()) { if (!transaction.isValid()) { cancelledAny = true; for (final GameTransaction gameTransaction : blockTransactions) { final BlockEventBasedTransaction blockTransaction = (BlockEventBasedTransaction) gameTransaction; - final Vector3i position = transaction.getOriginal().getPosition(); + final Vector3i position = transaction.original().position(); final BlockPos affectedPosition = blockTransaction.affectedPosition; if (position.getX() == affectedPosition.getX() && position.getY() == affectedPosition.getY() diff --git a/src/main/java/org/spongepowered/common/event/tracking/context/transaction/ChangeBlock.java b/src/main/java/org/spongepowered/common/event/tracking/context/transaction/ChangeBlock.java index a9df723c7d5..e5910c0b84e 100644 --- a/src/main/java/org/spongepowered/common/event/tracking/context/transaction/ChangeBlock.java +++ b/src/main/java/org/spongepowered/common/event/tracking/context/transaction/ChangeBlock.java @@ -64,7 +64,7 @@ public final class ChangeBlock extends BlockEventBasedTransaction { ChangeBlock(final SpongeBlockSnapshot attachedSnapshot, final BlockState newState, final SpongeBlockChangeFlag blockChange ) { - super(attachedSnapshot.getBlockPos(), (BlockState) attachedSnapshot.getState(), attachedSnapshot.getWorld()); + super(attachedSnapshot.getBlockPos(), (BlockState) attachedSnapshot.state(), attachedSnapshot.world()); this.original = attachedSnapshot; this.newState = newState; this.blockChangeFlag = blockChange; @@ -152,12 +152,12 @@ public void addToPrinter(final PrettyPrinter printer) { @Override protected SpongeBlockSnapshot getResultingSnapshot() { final SpongeBlockSnapshotBuilder builder = SpongeBlockSnapshotBuilder.pooled() - .position(this.original.getPosition()) + .position(this.original.position()) .blockState((org.spongepowered.api.block.BlockState) this.newState); if (this.original.getServerWorld().isPresent()) { builder.world(this.original.getServerWorld().get()); } else { - builder.world(this.original.getWorld()); + builder.world(this.original.world()); } return builder.build(); } diff --git a/src/main/java/org/spongepowered/common/event/tracking/context/transaction/EntityPerformingDropsTransaction.java b/src/main/java/org/spongepowered/common/event/tracking/context/transaction/EntityPerformingDropsTransaction.java index b8773bca4f2..a1da3554df1 100644 --- a/src/main/java/org/spongepowered/common/event/tracking/context/transaction/EntityPerformingDropsTransaction.java +++ b/src/main/java/org/spongepowered/common/event/tracking/context/transaction/EntityPerformingDropsTransaction.java @@ -60,7 +60,7 @@ public final class EntityPerformingDropsTransaction extends GameTransaction> lastAttacker ) { - super(TransactionTypes.ENTITY_DEATH_DROPS.get(), ((org.spongepowered.api.world.server.ServerWorld) worldSupplier.get()).getKey()); + super(TransactionTypes.ENTITY_DEATH_DROPS.get(), ((org.spongepowered.api.world.server.ServerWorld) worldSupplier.get()).key()); this.worldSupplier = worldSupplier; this.destroyingEntity = destroyingEntity; this.entityTag = entityTag; diff --git a/src/main/java/org/spongepowered/common/event/tracking/context/transaction/NeighborNotification.java b/src/main/java/org/spongepowered/common/event/tracking/context/transaction/NeighborNotification.java index a2f6cdc114c..57355841b59 100644 --- a/src/main/java/org/spongepowered/common/event/tracking/context/transaction/NeighborNotification.java +++ b/src/main/java/org/spongepowered/common/event/tracking/context/transaction/NeighborNotification.java @@ -42,7 +42,6 @@ import org.spongepowered.common.util.PrettyPrinter; import org.spongepowered.common.world.server.SpongeLocatableBlockBuilder; -import java.util.Collections; import java.util.EnumMap; import java.util.Map; import java.util.Optional; @@ -69,7 +68,7 @@ final class NeighborNotification extends GameTransaction worldSupplier, final Entity entityToSpawn, final Supplier deducedSpawnType ) { - super(TransactionTypes.SPAWN_ENTITY.get(), ((org.spongepowered.api.world.server.ServerWorld) worldSupplier.get()).getKey()); + super(TransactionTypes.SPAWN_ENTITY.get(), ((org.spongepowered.api.world.server.ServerWorld) worldSupplier.get()).key()); this.worldSupplier = worldSupplier; this.entityToSpawn = entityToSpawn; this.entityTag = entityToSpawn.saveWithoutId(new CompoundTag()); diff --git a/src/main/java/org/spongepowered/common/event/tracking/context/transaction/TransactionalCaptureSupplier.java b/src/main/java/org/spongepowered/common/event/tracking/context/transaction/TransactionalCaptureSupplier.java index fd36ebe5981..295a1524d92 100644 --- a/src/main/java/org/spongepowered/common/event/tracking/context/transaction/TransactionalCaptureSupplier.java +++ b/src/main/java/org/spongepowered/common/event/tracking/context/transaction/TransactionalCaptureSupplier.java @@ -389,7 +389,7 @@ public boolean processTransactions(final PhaseContext<@NonNull ?> context) { eventWithTransactions.markCancelled(); continue; } - Sponge.getEventManager().post(event); + Sponge.eventManager().post(event); if (event instanceof Cancellable && ((Cancellable) event).isCancelled()) { eventWithTransactions.markCancelled(); cancelledAny = true; @@ -498,7 +498,7 @@ private static void generateEventForTransaction( }) .orElse(null) ) { - final Optional event = pointer.generateEvent(context, parent, transactions, instance.getCurrentCause(), transactionPostEventBuilder); + final Optional event = pointer.generateEvent(context, parent, transactions, instance.currentCause(), transactionPostEventBuilder); if (!event.isPresent()) { transactions.forEach(GameTransaction::markCancelled); return; diff --git a/src/main/java/org/spongepowered/common/event/tracking/context/transaction/type/BlockTransactionType.java b/src/main/java/org/spongepowered/common/event/tracking/context/transaction/type/BlockTransactionType.java index 93cdf550f70..70349e5f1df 100644 --- a/src/main/java/org/spongepowered/common/event/tracking/context/transaction/type/BlockTransactionType.java +++ b/src/main/java/org/spongepowered/common/event/tracking/context/transaction/type/BlockTransactionType.java @@ -60,10 +60,10 @@ public BlockTransactionType() { protected void consumeEventsAndMarker(final Collection changeBlockEvents, final Marker marker) { final Multimap eventsByWorld = LinkedListMultimap.create(); - changeBlockEvents.forEach(event -> eventsByWorld.put(event.getWorld().getKey(), event)); + changeBlockEvents.forEach(event -> eventsByWorld.put(event.world().key(), event)); eventsByWorld.asMap().forEach((key, events) -> { - final Optional serverWorld = ((SpongeServer) SpongeCommon.getServer()).getWorldManager().world(key); + final Optional serverWorld = ((SpongeServer) SpongeCommon.getServer()).worldManager().world(key); if (!serverWorld.isPresent()) { return; } @@ -71,15 +71,15 @@ protected void consumeEventsAndMarker(final Collection !event.isCancelled()) - .flatMap(event -> event.getTransactions().stream()) + .flatMap(event -> event.transactions().stream()) .filter(BlockTransaction::isValid) .forEach(transactions -> { // Then "put" the most recent transactions such that we have a complete rebuild of // each position according to what originally existed and then // the ultimate final block on that position - final SpongeBlockSnapshot original = (SpongeBlockSnapshot) transactions.getOriginal(); + final SpongeBlockSnapshot original = (SpongeBlockSnapshot) transactions.original(); positions.put(original.getBlockPos(), original); - positions.put(original.getBlockPos(), (SpongeBlockSnapshot) transactions.getFinal()); + positions.put(original.getBlockPos(), (SpongeBlockSnapshot) transactions.finalReplacement()); }); final PhaseContext<@NonNull ?> context = PhaseTracker.getInstance().getPhaseContext(); @@ -102,7 +102,7 @@ protected void consumeEventsAndMarker(final Collection DefaultedRegistryReference> key(final ResourceKey location) { - return RegistryKey.of(SpongeRegistryTypes.TRANSACTION_TYPE, location).asDefaultedReference(() -> Sponge.getGame().registries()); + return RegistryKey.of(SpongeRegistryTypes.TRANSACTION_TYPE, location).asDefaultedReference(() -> Sponge.game().registries()); } } \ No newline at end of file diff --git a/src/main/java/org/spongepowered/common/event/tracking/phase/block/GrowablePhaseContext.java b/src/main/java/org/spongepowered/common/event/tracking/phase/block/GrowablePhaseContext.java index 140ce74f318..92ac9b43c07 100644 --- a/src/main/java/org/spongepowered/common/event/tracking/phase/block/GrowablePhaseContext.java +++ b/src/main/java/org/spongepowered/common/event/tracking/phase/block/GrowablePhaseContext.java @@ -87,8 +87,8 @@ public GrowablePhaseContext buildAndSwitch() { .position(VecHelper.toVector3i(this.pos)) .blockState(this.blockState) .flag(BlockChangeFlags.PHYSICS_OBSERVER); - this.priorContext.applyOwnerIfAvailable((owner) -> builder.creator(owner.getUniqueId())); - this.priorContext.applyNotifierIfAvailable((notifier) -> builder.notifier(notifier.getUniqueId())); + this.priorContext.applyOwnerIfAvailable((owner) -> builder.creator(owner.uniqueId())); + this.priorContext.applyNotifierIfAvailable((notifier) -> builder.notifier(notifier.uniqueId())); this.snapshot = builder.build(); return super.buildAndSwitch(); } diff --git a/src/main/java/org/spongepowered/common/event/tracking/phase/general/CommandState.java b/src/main/java/org/spongepowered/common/event/tracking/phase/general/CommandState.java index ffbe0d605f6..d8788b935da 100644 --- a/src/main/java/org/spongepowered/common/event/tracking/phase/general/CommandState.java +++ b/src/main/java/org/spongepowered/common/event/tracking/phase/general/CommandState.java @@ -78,7 +78,7 @@ public void postBlockTransactionApplication(final BlockChange blockChange, final // We have to check if there is a player, because command blocks can be triggered // without player interaction. // Fixes https://github.com/SpongePowered/SpongeForge/issues/2442 - PhaseTracker.getCauseStackManager().getCurrentCause().first(User.class).ifPresent(user -> { + PhaseTracker.getCauseStackManager().currentCause().first(User.class).ifPresent(user -> { TrackingUtil.associateTrackerToTarget(blockChange, transaction, user); }); } @@ -88,7 +88,7 @@ public void associateNeighborStateNotifier(final CommandPhaseContext context, @N final BlockPos notifyPos, final ServerLevel minecraftWorld, final PlayerTracker.Type notifier) { context.getSource(Player.class) .ifPresent(player -> ((LevelChunkBridge) minecraftWorld.getChunkAt(notifyPos)) - .bridge$addTrackedBlockPosition(block, notifyPos, ((ServerPlayer) player).getUser(), PlayerTracker.Type.NOTIFIER)); + .bridge$addTrackedBlockPosition(block, notifyPos, ((ServerPlayer) player).user(), PlayerTracker.Type.NOTIFIER)); } @Override @@ -100,7 +100,7 @@ public void unwind(final CommandPhaseContext phaseContext) { ((TrackedInventoryBridge) playerSource.get().inventory).bridge$setCaptureInventory(false); final List list = ((TrackedInventoryBridge) playerSource.get().inventory).bridge$getCapturedSlotTransactions(); if (!list.isEmpty()) { - final ChangeInventoryEvent event = SpongeEventFactory.createChangeInventoryEvent(csm.getCurrentCause(), + final ChangeInventoryEvent event = SpongeEventFactory.createChangeInventoryEvent(csm.currentCause(), ((Inventory) playerSource.get().inventory), list); SpongeCommon.postEvent(event); PacketPhaseUtil.handleSlotRestore(playerSource.get(), null, list, event.isCancelled()); diff --git a/src/main/java/org/spongepowered/common/event/tracking/phase/general/ExplosionState.java b/src/main/java/org/spongepowered/common/event/tracking/phase/general/ExplosionState.java index b52317d85b1..d0c9e44968e 100644 --- a/src/main/java/org/spongepowered/common/event/tracking/phase/general/ExplosionState.java +++ b/src/main/java/org/spongepowered/common/event/tracking/phase/general/ExplosionState.java @@ -116,7 +116,7 @@ public SpawnEntityEvent createSpawnEvent( if (parent instanceof ChangeBlock) { return SpongeEventFactory.createDropItemEventDestruct(currentCause, collect.stream() - .map(t -> (org.spongepowered.api.entity.Entity) t.getFirst()) + .map(t -> (org.spongepowered.api.entity.Entity) t.first()) .collect(Collectors.toList())); } return super.createSpawnEvent(context, parent, collect, currentCause); diff --git a/src/main/java/org/spongepowered/common/event/tracking/phase/packet/PacketPhaseUtil.java b/src/main/java/org/spongepowered/common/event/tracking/phase/packet/PacketPhaseUtil.java index 0071ad1797a..ddb508b91aa 100644 --- a/src/main/java/org/spongepowered/common/event/tracking/phase/packet/PacketPhaseUtil.java +++ b/src/main/java/org/spongepowered/common/event/tracking/phase/packet/PacketPhaseUtil.java @@ -80,12 +80,12 @@ public static boolean handleSlotRestore(final Player player, @Nullable final Abs boolean restoredAny = false; for (final SlotTransaction slotTransaction : slotTransactions) { - if ((!slotTransaction.getCustom().isPresent() && slotTransaction.isValid()) && !eventCancelled) { + if ((!slotTransaction.custom().isPresent() && slotTransaction.isValid()) && !eventCancelled) { continue; } restoredAny = true; - final SlotAdapter slot = (SlotAdapter) slotTransaction.getSlot(); - final ItemStackSnapshot snapshot = eventCancelled || !slotTransaction.isValid() ? slotTransaction.getOriginal() : slotTransaction.getCustom().get(); + final SlotAdapter slot = (SlotAdapter) slotTransaction.slot(); + final ItemStackSnapshot snapshot = eventCancelled || !slotTransaction.isValid() ? slotTransaction.original() : slotTransaction.custom().get(); if (containerMenu == null) { slot.set(snapshot.createStack()); } else { @@ -214,8 +214,8 @@ public static void onProcessPacket(final Packet packetIn, final PacketListener n .cursor(cursor); PacketPhase.getInstance().populateContext(packetIn, packetPlayer, packetState, context); - context.creator(((ServerPlayer) packetPlayer).getUser()); - context.notifier(((ServerPlayer) packetPlayer).getUser()); + context.creator(((ServerPlayer) packetPlayer).user()); + context.notifier(((ServerPlayer) packetPlayer).user()); } try (final PhaseContext packetContext = context) { packetContext.buildAndSwitch(); diff --git a/src/main/java/org/spongepowered/common/event/tracking/phase/packet/PacketState.java b/src/main/java/org/spongepowered/common/event/tracking/phase/packet/PacketState.java index cca3afcd80d..81f2888d542 100644 --- a/src/main/java/org/spongepowered/common/event/tracking/phase/packet/PacketState.java +++ b/src/main/java/org/spongepowered/common/event/tracking/phase/packet/PacketState.java @@ -69,13 +69,13 @@ protected PacketState() { protected static void processSpawnedEntities(final net.minecraft.server.level.ServerPlayer player, final SpawnEntityEvent event) { - final List entities = event.getEntities(); + final List entities = event.entities(); PacketState.processEntities(player, entities); } protected static void processEntities(final net.minecraft.server.level.ServerPlayer player, final Collection entities) { for (final Entity entity : entities) { - EntityUtil.processEntitySpawn(entity, () -> Optional.of(((ServerPlayer)player).getUser())); + EntityUtil.processEntitySpawn(entity, () -> Optional.of(((ServerPlayer)player).user())); } } @@ -101,7 +101,7 @@ public void associateNeighborStateNotifier( final PlayerTracker.Type notifier) { final Player player = unwindingContext.getSpongePlayer(); final LevelChunk chunk = minecraftWorld.getChunkAt(notifyPos); - ((LevelChunkBridge) chunk).bridge$setBlockNotifier(notifyPos, player.getUniqueId()); + ((LevelChunkBridge) chunk).bridge$setBlockNotifier(notifyPos, player.uniqueId()); } @Override @@ -143,8 +143,8 @@ public boolean spawnEntity(final P context, final Entity entity) { try (final CauseStackManager.StackFrame frame = PhaseTracker.getCauseStackManager().pushCauseFrame()) { frame.pushCause(player); frame.addContext(EventContextKeys.SPAWN_TYPE, this.getEntitySpawnType(context)); - frame.addContext(EventContextKeys.CREATOR, ((ServerPlayer)player).getUser()); - frame.addContext(EventContextKeys.NOTIFIER, ((ServerPlayer)player).getUser()); + frame.addContext(EventContextKeys.CREATOR, ((ServerPlayer)player).user()); + frame.addContext(EventContextKeys.NOTIFIER, ((ServerPlayer)player).user()); return SpongeCommonEventFactory.callSpawnEntity(entities, context); } } diff --git a/src/main/java/org/spongepowered/common/event/tracking/phase/packet/drag/MiddleDragInventoryStopState.java b/src/main/java/org/spongepowered/common/event/tracking/phase/packet/drag/MiddleDragInventoryStopState.java index 6b739268c76..f90ed7d7a7f 100644 --- a/src/main/java/org/spongepowered/common/event/tracking/phase/packet/drag/MiddleDragInventoryStopState.java +++ b/src/main/java/org/spongepowered/common/event/tracking/phase/packet/drag/MiddleDragInventoryStopState.java @@ -52,7 +52,7 @@ public ClickContainerEvent createInventoryEvent(final ServerPlayer playerMP, fin final List slotTransactions, final List capturedEntities, final int usedButton, @Nullable final Slot slot) { return SpongeEventFactory.createClickContainerEventDragMiddle( - PhaseTracker.getCauseStackManager().getCurrentCause(), + PhaseTracker.getCauseStackManager().currentCause(), openContainer, transaction, Optional.ofNullable(slot), slotTransactions); } diff --git a/src/main/java/org/spongepowered/common/event/tracking/phase/packet/drag/PrimaryDragInventoryStopState.java b/src/main/java/org/spongepowered/common/event/tracking/phase/packet/drag/PrimaryDragInventoryStopState.java index d1ef6d6c468..5e04b7653bc 100644 --- a/src/main/java/org/spongepowered/common/event/tracking/phase/packet/drag/PrimaryDragInventoryStopState.java +++ b/src/main/java/org/spongepowered/common/event/tracking/phase/packet/drag/PrimaryDragInventoryStopState.java @@ -50,7 +50,7 @@ public PrimaryDragInventoryStopState() { public ClickContainerEvent createInventoryEvent(ServerPlayer playerMP, Container openContainer, Transaction transaction, List slotTransactions, List capturedEntities, int usedButton, @Nullable Slot slot) { return SpongeEventFactory.createClickContainerEventDragPrimary( - PhaseTracker.getCauseStackManager().getCurrentCause(), openContainer, transaction, + PhaseTracker.getCauseStackManager().currentCause(), openContainer, transaction, Optional.ofNullable(slot), slotTransactions); } diff --git a/src/main/java/org/spongepowered/common/event/tracking/phase/packet/drag/SecondaryDragInventoryStopState.java b/src/main/java/org/spongepowered/common/event/tracking/phase/packet/drag/SecondaryDragInventoryStopState.java index b11ff008024..81f127aa2b6 100644 --- a/src/main/java/org/spongepowered/common/event/tracking/phase/packet/drag/SecondaryDragInventoryStopState.java +++ b/src/main/java/org/spongepowered/common/event/tracking/phase/packet/drag/SecondaryDragInventoryStopState.java @@ -52,7 +52,7 @@ public ClickContainerEvent createInventoryEvent(final ServerPlayer playerMP, fin final List slotTransactions, final List capturedEntities, final int usedButton, @Nullable final Slot slot) { return SpongeEventFactory.createClickContainerEventDragSecondary( - PhaseTracker.getCauseStackManager().getCurrentCause(), openContainer, transaction, + PhaseTracker.getCauseStackManager().currentCause(), openContainer, transaction, Optional.ofNullable(slot), slotTransactions); } diff --git a/src/main/java/org/spongepowered/common/event/tracking/phase/packet/inventory/BasicInventoryPacketState.java b/src/main/java/org/spongepowered/common/event/tracking/phase/packet/inventory/BasicInventoryPacketState.java index e4a0ced7db1..e28b822c5c1 100644 --- a/src/main/java/org/spongepowered/common/event/tracking/phase/packet/inventory/BasicInventoryPacketState.java +++ b/src/main/java/org/spongepowered/common/event/tracking/phase/packet/inventory/BasicInventoryPacketState.java @@ -175,7 +175,7 @@ public void unwind(final InventoryPacketContext context) { if (ShouldFire.SPAWN_ENTITY_EVENT && !capturedItems.isEmpty()) { for (final Entity entiy: capturedItems) { if (entiy instanceof CreatorTrackedBridge) { - ((CreatorTrackedBridge) entiy).tracked$setCreatorReference(((ServerPlayer) player).getUser()); + ((CreatorTrackedBridge) entiy).tracked$setCreatorReference(((ServerPlayer) player).user()); } else { entiy.offer(Keys.CREATOR, player.getUUID()); } @@ -235,20 +235,20 @@ public void unwind(final InventoryPacketContext context) { // Therefore, we never add any 'fake' transactions, as the final // packet has everything we want. if (!(inventoryEvent instanceof ClickContainerEvent.Drag)) { - PacketPhaseUtil.validateCapturedTransactions(packetIn.getSlotNum(), openContainer, inventoryEvent.getTransactions()); + PacketPhaseUtil.validateCapturedTransactions(packetIn.getSlotNum(), openContainer, inventoryEvent.transactions()); } SpongeCommon.postEvent(inventoryEvent); // Handle cursor - if (inventoryEvent.isCancelled() || !inventoryEvent.getCursorTransaction().isValid()) { - PacketPhaseUtil.handleCustomCursor(player, inventoryEvent.getCursorTransaction().getOriginal()); - } else if (inventoryEvent.getCursorTransaction().getCustom().isPresent()){ - PacketPhaseUtil.handleCustomCursor(player, inventoryEvent.getCursorTransaction().getFinal()); + if (inventoryEvent.isCancelled() || !inventoryEvent.cursorTransaction().isValid()) { + PacketPhaseUtil.handleCustomCursor(player, inventoryEvent.cursorTransaction().original()); + } else if (inventoryEvent.cursorTransaction().custom().isPresent()){ + PacketPhaseUtil.handleCustomCursor(player, inventoryEvent.cursorTransaction().finalReplacement()); } // Handle slots - PacketPhaseUtil.handleSlotRestore(player, openContainer, inventoryEvent.getTransactions(), inventoryEvent.isCancelled()); + PacketPhaseUtil.handleSlotRestore(player, openContainer, inventoryEvent.transactions(), inventoryEvent.isCancelled()); if (!inventoryEvent.isCancelled()) { if (inventoryEvent instanceof SpawnEntityEvent) { diff --git a/src/main/java/org/spongepowered/common/event/tracking/phase/packet/inventory/CloseWindowState.java b/src/main/java/org/spongepowered/common/event/tracking/phase/packet/inventory/CloseWindowState.java index 822f483617f..af04b9533ca 100644 --- a/src/main/java/org/spongepowered/common/event/tracking/phase/packet/inventory/CloseWindowState.java +++ b/src/main/java/org/spongepowered/common/event/tracking/phase/packet/inventory/CloseWindowState.java @@ -78,7 +78,7 @@ public void unwind(BasicPacketContext context) { // .map(entity -> (Entity) entity) // .collect(Collectors.toList()); // if (!entities.isEmpty()) { -// SpongeCommonEventFactory.callDropItemClose(entities, context, () -> Optional.of(((ServerPlayer) player).getUser())); +// SpongeCommonEventFactory.callDropItemClose(entities, context, () -> Optional.of(((ServerPlayer) player).user())); // } // }); } diff --git a/src/main/java/org/spongepowered/common/event/tracking/phase/packet/inventory/DoubleClickInventoryState.java b/src/main/java/org/spongepowered/common/event/tracking/phase/packet/inventory/DoubleClickInventoryState.java index 224fbde50e5..6e12ce77a60 100644 --- a/src/main/java/org/spongepowered/common/event/tracking/phase/packet/inventory/DoubleClickInventoryState.java +++ b/src/main/java/org/spongepowered/common/event/tracking/phase/packet/inventory/DoubleClickInventoryState.java @@ -62,7 +62,7 @@ public ClickContainerEvent createInventoryEvent(final ServerPlayer playerMP, fin final Transaction transaction, final List slotTransactions, final List capturedEntities, final int usedButton, @Nullable final Slot slot) { - return SpongeEventFactory.createClickContainerEventDouble(PhaseTracker.getCauseStackManager().getCurrentCause(), + return SpongeEventFactory.createClickContainerEventDouble(PhaseTracker.getCauseStackManager().currentCause(), openContainer, transaction, Optional.ofNullable(slot), slotTransactions); } diff --git a/src/main/java/org/spongepowered/common/event/tracking/phase/packet/inventory/DropItemOutsideWindowState.java b/src/main/java/org/spongepowered/common/event/tracking/phase/packet/inventory/DropItemOutsideWindowState.java index d6c015c2a24..37e8c0e31d6 100644 --- a/src/main/java/org/spongepowered/common/event/tracking/phase/packet/inventory/DropItemOutsideWindowState.java +++ b/src/main/java/org/spongepowered/common/event/tracking/phase/packet/inventory/DropItemOutsideWindowState.java @@ -68,17 +68,17 @@ public ClickContainerEvent createInventoryEvent(final net.minecraft.server.level for (final Entity currentEntity : capturedEntities) { if (currentEntity instanceof CreatorTrackedBridge) { - ((CreatorTrackedBridge) currentEntity).tracked$setCreatorReference(((ServerPlayer) playerMP).getUser()); + ((CreatorTrackedBridge) currentEntity).tracked$setCreatorReference(((ServerPlayer) playerMP).user()); } else { currentEntity.offer(Keys.CREATOR, playerMP.getUUID()); } } if (usedButton == Constants.Networking.PACKET_BUTTON_PRIMARY_ID) { - return SpongeEventFactory.createClickContainerEventDropOutsidePrimary(frame.getCurrentCause(), + return SpongeEventFactory.createClickContainerEventDropOutsidePrimary(frame.currentCause(), openContainer, transaction, capturedEntities, Optional.ofNullable(slot), slotTransactions); } else { - return SpongeEventFactory.createClickContainerEventDropOutsideSecondary(frame.getCurrentCause(), + return SpongeEventFactory.createClickContainerEventDropOutsideSecondary(frame.currentCause(), openContainer, transaction, capturedEntities, Optional.ofNullable(slot), slotTransactions); } diff --git a/src/main/java/org/spongepowered/common/event/tracking/phase/packet/inventory/DropItemWithHotkeyState.java b/src/main/java/org/spongepowered/common/event/tracking/phase/packet/inventory/DropItemWithHotkeyState.java index 1db62700ad3..7c193db6c0e 100644 --- a/src/main/java/org/spongepowered/common/event/tracking/phase/packet/inventory/DropItemWithHotkeyState.java +++ b/src/main/java/org/spongepowered/common/event/tracking/phase/packet/inventory/DropItemWithHotkeyState.java @@ -96,7 +96,7 @@ public void unwind(final InventoryPacketContext context) { usedButton = packetIn.getAction() == ServerboundPlayerActionPacket.Action.DROP_ITEM ? Constants.Networking.PACKET_BUTTON_PRIMARY_ID : 1; - slot = ((PlayerInventory) player.inventory).getEquipment().getSlot( + slot = ((PlayerInventory) player.inventory).equipment().slot( EquipmentTypes.MAIN_HAND).orElse(null); } else { final ServerboundContainerClickPacket packetIn = context.getPacket(); @@ -115,9 +115,9 @@ public void unwind(final InventoryPacketContext context) { SpongeCommon.postEvent(dropItemEvent); if (dropItemEvent.isCancelled() || PacketPhaseUtil.allTransactionsInvalid( - dropItemEvent.getTransactions())) { + dropItemEvent.transactions())) { ((ServerPlayerBridge) player).bridge$restorePacketItem(InteractionHand.MAIN_HAND); - PacketPhaseUtil.handleSlotRestore(player, player.containerMenu, dropItemEvent.getTransactions(), + PacketPhaseUtil.handleSlotRestore(player, player.containerMenu, dropItemEvent.transactions(), true); } else { PacketState.processSpawnedEntities(player, dropItemEvent); @@ -146,7 +146,7 @@ public ClickContainerEvent.Drop createInventoryEvent(final net.minecraft.server. frame.addContext(EventContextKeys.SPAWN_TYPE, SpawnTypes.DROPPED_ITEM); for (final Entity currentEntity : capturedEntities) { if (currentEntity instanceof CreatorTrackedBridge) { - ((CreatorTrackedBridge) currentEntity).tracked$setCreatorReference(((ServerPlayer) serverPlayer).getUser()); + ((CreatorTrackedBridge) currentEntity).tracked$setCreatorReference(((ServerPlayer) serverPlayer).user()); } else { currentEntity.offer(Keys.CREATOR, serverPlayer.getUUID()); } @@ -156,11 +156,11 @@ public ClickContainerEvent.Drop createInventoryEvent(final net.minecraft.server. final ClickContainerEvent.Drop event; if (usedButton == Constants.Networking.PACKET_BUTTON_PRIMARY_ID) { event = SpongeEventFactory.createClickContainerEventDropSingle( - frame.getCurrentCause(), + frame.currentCause(), openContainer, transaction, capturedEntities, Optional.ofNullable(slot), slotTransactions); } else { event = SpongeEventFactory.createClickContainerEventDropFull( - frame.getCurrentCause(), + frame.currentCause(), openContainer, transaction, capturedEntities, Optional.ofNullable(slot), slotTransactions); } // TODO the nature of how this event is handled prevents the cause information being preserved through diff --git a/src/main/java/org/spongepowered/common/event/tracking/phase/packet/inventory/EnchantItemPacketState.java b/src/main/java/org/spongepowered/common/event/tracking/phase/packet/inventory/EnchantItemPacketState.java index af340307e3c..aaec05aa873 100644 --- a/src/main/java/org/spongepowered/common/event/tracking/phase/packet/inventory/EnchantItemPacketState.java +++ b/src/main/java/org/spongepowered/common/event/tracking/phase/packet/inventory/EnchantItemPacketState.java @@ -100,7 +100,7 @@ public void unwind(InventoryPacketContext context) { return; }if (inventoryEvent != null) { // Don't fire inventory drop events when there are no entities - if (inventoryEvent instanceof AffectEntityEvent && ((AffectEntityEvent) inventoryEvent).getEntities().isEmpty()) { + if (inventoryEvent instanceof AffectEntityEvent && ((AffectEntityEvent) inventoryEvent).entities().isEmpty()) { slotTransactions.clear(); trackedInventory.bridge$setCaptureInventory(false); return; @@ -112,28 +112,28 @@ public void unwind(InventoryPacketContext context) { // Therefore, we never add any 'fake' transactions, as the final // packet has everything we want. if (!(inventoryEvent instanceof ClickContainerEvent.Drag)) { - PacketPhaseUtil.validateCapturedTransactions(packetIn.getContainerId(), openContainer, inventoryEvent.getTransactions()); + PacketPhaseUtil.validateCapturedTransactions(packetIn.getContainerId(), openContainer, inventoryEvent.transactions()); } SpongeCommon.postEvent(inventoryEvent); - if (inventoryEvent.isCancelled() || PacketPhaseUtil.allTransactionsInvalid(inventoryEvent.getTransactions())) { + if (inventoryEvent.isCancelled() || PacketPhaseUtil.allTransactionsInvalid(inventoryEvent.transactions())) { if (inventoryEvent instanceof ClickContainerEvent.Drop) { capturedItems.clear(); } // Restore cursor - PacketPhaseUtil.handleCustomCursor(player, inventoryEvent.getCursorTransaction().getOriginal()); + PacketPhaseUtil.handleCustomCursor(player, inventoryEvent.cursorTransaction().original()); // Restore target slots - PacketPhaseUtil.handleSlotRestore(player, openContainer, inventoryEvent.getTransactions(), true); + PacketPhaseUtil.handleSlotRestore(player, openContainer, inventoryEvent.transactions(), true); } else { - PacketPhaseUtil.handleSlotRestore(player, openContainer, inventoryEvent.getTransactions(), false); + PacketPhaseUtil.handleSlotRestore(player, openContainer, inventoryEvent.transactions(), false); // Handle cursor - if (!inventoryEvent.getCursorTransaction().isValid()) { - PacketPhaseUtil.handleCustomCursor(player, inventoryEvent.getCursorTransaction().getOriginal()); - } else if (inventoryEvent.getCursorTransaction().getCustom().isPresent()) { - PacketPhaseUtil.handleCustomCursor(player, inventoryEvent.getCursorTransaction().getFinal()); + if (!inventoryEvent.cursorTransaction().isValid()) { + PacketPhaseUtil.handleCustomCursor(player, inventoryEvent.cursorTransaction().original()); + } else if (inventoryEvent.cursorTransaction().custom().isPresent()) { + PacketPhaseUtil.handleCustomCursor(player, inventoryEvent.cursorTransaction().finalReplacement()); } if (inventoryEvent instanceof SpawnEntityEvent) { PacketState.processSpawnedEntities(player, (SpawnEntityEvent) inventoryEvent); diff --git a/src/main/java/org/spongepowered/common/event/tracking/phase/packet/inventory/MiddleInventoryClickState.java b/src/main/java/org/spongepowered/common/event/tracking/phase/packet/inventory/MiddleInventoryClickState.java index 9ae2fed9b4e..706be6fe8cf 100644 --- a/src/main/java/org/spongepowered/common/event/tracking/phase/packet/inventory/MiddleInventoryClickState.java +++ b/src/main/java/org/spongepowered/common/event/tracking/phase/packet/inventory/MiddleInventoryClickState.java @@ -57,7 +57,7 @@ public ClickContainerEvent createInventoryEvent(final ServerPlayer playerMP, fin final List slotTransactions, final List capturedEntities, final int usedButton, @Nullable final Slot slot) { return SpongeEventFactory.createClickContainerEventMiddle( - PhaseTracker.getCauseStackManager().getCurrentCause(), + PhaseTracker.getCauseStackManager().currentCause(), openContainer, transaction, Optional.ofNullable(slot), slotTransactions); } diff --git a/src/main/java/org/spongepowered/common/event/tracking/phase/packet/inventory/OpenInventoryState.java b/src/main/java/org/spongepowered/common/event/tracking/phase/packet/inventory/OpenInventoryState.java index cf0471c302c..0bab0bb11ac 100644 --- a/src/main/java/org/spongepowered/common/event/tracking/phase/packet/inventory/OpenInventoryState.java +++ b/src/main/java/org/spongepowered/common/event/tracking/phase/packet/inventory/OpenInventoryState.java @@ -47,18 +47,18 @@ public void unwind(InventoryPacketContext context) { try (CauseStackManager.StackFrame frame = PhaseTracker.getCauseStackManager().pushCauseFrame()) { frame.pushCause(player); final InteractContainerEvent.Open event = - SpongeEventFactory.createInteractContainerEventOpen(frame.getCurrentCause(), ContainerUtil.fromNative(player.containerMenu), + SpongeEventFactory.createInteractContainerEventOpen(frame.currentCause(), ContainerUtil.fromNative(player.containerMenu), cursorTransaction); SpongeCommon.postEvent(event); if (event.isCancelled()) { player.closeContainer(); } else { // Custom cursor - final Transaction transaction = event.getCursorTransaction(); + final Transaction transaction = event.cursorTransaction(); if (!transaction.isValid()) { - PacketPhaseUtil.handleCustomCursor(player, transaction.getOriginal()); - } else if (transaction.getCustom().isPresent()) { - PacketPhaseUtil.handleCustomCursor(player, transaction.getFinal()); + PacketPhaseUtil.handleCustomCursor(player, transaction.original()); + } else if (transaction.custom().isPresent()) { + PacketPhaseUtil.handleCustomCursor(player, transaction.finalReplacement()); } } } diff --git a/src/main/java/org/spongepowered/common/event/tracking/phase/packet/inventory/PlaceRecipePacketState.java b/src/main/java/org/spongepowered/common/event/tracking/phase/packet/inventory/PlaceRecipePacketState.java index 92562ada858..1fe0fddae67 100644 --- a/src/main/java/org/spongepowered/common/event/tracking/phase/packet/inventory/PlaceRecipePacketState.java +++ b/src/main/java/org/spongepowered/common/event/tracking/phase/packet/inventory/PlaceRecipePacketState.java @@ -81,7 +81,7 @@ public void unwind(final InventoryPacketContext context) { final List previewTransactions = ((TrackedContainerBridge) player.containerMenu).bridge$getPreviewTransactions(); if (previewTransactions.isEmpty()) { - final CraftingOutput slot = ((CraftingInventory) craftInv).getResult(); + final CraftingOutput slot = ((CraftingInventory) craftInv).result(); final SlotTransaction st = new SlotTransaction(slot, ItemStackSnapshot.empty(), slot.peek().createSnapshot()); previewTransactions.add(st); } @@ -100,20 +100,20 @@ public void unwind(final InventoryPacketContext context) { final ClickContainerEvent event; if (shift) { - event = SpongeEventFactory.createClickContainerEventRecipeAll(frame.getCurrentCause(),((Container) player.containerMenu), + event = SpongeEventFactory.createClickContainerEventRecipeAll(frame.currentCause(),((Container) player.containerMenu), cursorTransaction, (Recipe) recipe, Optional.empty(), transactions); } else { - event = SpongeEventFactory.createClickContainerEventRecipeSingle(frame.getCurrentCause(), ((Container) player.containerMenu), + event = SpongeEventFactory.createClickContainerEventRecipeSingle(frame.currentCause(), ((Container) player.containerMenu), cursorTransaction, (Recipe) recipe, Optional.empty(), transactions); } SpongeCommon.postEvent(event); - if (event.isCancelled() || !event.getCursorTransaction().isValid()) { - PacketPhaseUtil.handleCustomCursor(player, event.getCursorTransaction().getOriginal()); + if (event.isCancelled() || !event.cursorTransaction().isValid()) { + PacketPhaseUtil.handleCustomCursor(player, event.cursorTransaction().original()); } else { - PacketPhaseUtil.handleCustomCursor(player, event.getCursorTransaction().getFinal()); + PacketPhaseUtil.handleCustomCursor(player, event.cursorTransaction().finalReplacement()); } - PacketPhaseUtil.handleSlotRestore(player, player.containerMenu, event.getTransactions(), event.isCancelled()); - event.getTransactions().clear(); + PacketPhaseUtil.handleSlotRestore(player, player.containerMenu, event.transactions(), event.isCancelled()); + event.transactions().clear(); } } } diff --git a/src/main/java/org/spongepowered/common/event/tracking/phase/packet/inventory/PrimaryInventoryClickState.java b/src/main/java/org/spongepowered/common/event/tracking/phase/packet/inventory/PrimaryInventoryClickState.java index abc44809767..bb1f56c9aed 100644 --- a/src/main/java/org/spongepowered/common/event/tracking/phase/packet/inventory/PrimaryInventoryClickState.java +++ b/src/main/java/org/spongepowered/common/event/tracking/phase/packet/inventory/PrimaryInventoryClickState.java @@ -57,10 +57,10 @@ public ClickContainerEvent createInventoryEvent(final ServerPlayer playerMP, fin if (!capturedEntities.isEmpty()) { PhaseTracker.getCauseStackManager().addContext(EventContextKeys.SPAWN_TYPE, SpawnTypes.DISPENSE); return SpongeEventFactory.createClickContainerEventDropOutsidePrimary( - PhaseTracker.getCauseStackManager().getCurrentCause(), + PhaseTracker.getCauseStackManager().currentCause(), openContainer, transaction, capturedEntities, Optional.ofNullable(slot), slotTransactions); } - return SpongeEventFactory.createClickContainerEventPrimary(PhaseTracker.getCauseStackManager().getCurrentCause(), + return SpongeEventFactory.createClickContainerEventPrimary(PhaseTracker.getCauseStackManager().currentCause(), openContainer, transaction, Optional.ofNullable(slot), slotTransactions); } diff --git a/src/main/java/org/spongepowered/common/event/tracking/phase/packet/inventory/PrimaryInventoryShiftClick.java b/src/main/java/org/spongepowered/common/event/tracking/phase/packet/inventory/PrimaryInventoryShiftClick.java index e6aec0b5592..071e31426ea 100644 --- a/src/main/java/org/spongepowered/common/event/tracking/phase/packet/inventory/PrimaryInventoryShiftClick.java +++ b/src/main/java/org/spongepowered/common/event/tracking/phase/packet/inventory/PrimaryInventoryShiftClick.java @@ -53,7 +53,7 @@ public ClickContainerEvent createInventoryEvent(final ServerPlayer playerMP, fin final List slotTransactions, final List capturedEntities, final int usedButton, @Nullable final Slot slot) { return SpongeEventFactory.createClickContainerEventShiftPrimary( - PhaseTracker.getCauseStackManager().getCurrentCause(), + PhaseTracker.getCauseStackManager().currentCause(), openContainer, transaction, Optional.ofNullable(slot), slotTransactions); } diff --git a/src/main/java/org/spongepowered/common/event/tracking/phase/packet/inventory/SecondaryInventoryClickState.java b/src/main/java/org/spongepowered/common/event/tracking/phase/packet/inventory/SecondaryInventoryClickState.java index 38a4cba849a..fcb4cf7bc86 100644 --- a/src/main/java/org/spongepowered/common/event/tracking/phase/packet/inventory/SecondaryInventoryClickState.java +++ b/src/main/java/org/spongepowered/common/event/tracking/phase/packet/inventory/SecondaryInventoryClickState.java @@ -53,7 +53,7 @@ public ClickContainerEvent createInventoryEvent(final ServerPlayer playerMP, fin final List slotTransactions, final List capturedEntities, final int usedButton, @Nullable final Slot slot) { return SpongeEventFactory.createClickContainerEventSecondary( - PhaseTracker.getCauseStackManager().getCurrentCause(), + PhaseTracker.getCauseStackManager().currentCause(), openContainer, transaction, Optional.ofNullable(slot), slotTransactions); } diff --git a/src/main/java/org/spongepowered/common/event/tracking/phase/packet/inventory/SecondaryInventoryShiftClickState.java b/src/main/java/org/spongepowered/common/event/tracking/phase/packet/inventory/SecondaryInventoryShiftClickState.java index 7421995a043..7a51184959c 100644 --- a/src/main/java/org/spongepowered/common/event/tracking/phase/packet/inventory/SecondaryInventoryShiftClickState.java +++ b/src/main/java/org/spongepowered/common/event/tracking/phase/packet/inventory/SecondaryInventoryShiftClickState.java @@ -53,7 +53,7 @@ public ClickContainerEvent createInventoryEvent(final ServerPlayer playerMP, fin final List slotTransactions, final List capturedEntities, final int usedButton, @Nullable final Slot slot) { return SpongeEventFactory.createClickContainerEventShiftSecondary( - PhaseTracker.getCauseStackManager().getCurrentCause(), + PhaseTracker.getCauseStackManager().currentCause(), openContainer, transaction, Optional.ofNullable(slot), slotTransactions); } diff --git a/src/main/java/org/spongepowered/common/event/tracking/phase/packet/inventory/SwapHandItemsState.java b/src/main/java/org/spongepowered/common/event/tracking/phase/packet/inventory/SwapHandItemsState.java index 30247d5604e..bad67faf534 100644 --- a/src/main/java/org/spongepowered/common/event/tracking/phase/packet/inventory/SwapHandItemsState.java +++ b/src/main/java/org/spongepowered/common/event/tracking/phase/packet/inventory/SwapHandItemsState.java @@ -42,7 +42,7 @@ public final class SwapHandItemsState extends BasicInventoryPacketState { public ChangeInventoryEvent.SwapHand createInventoryEvent(final Inventory inventory, final List slotTransactions) { - return SpongeEventFactory.createChangeInventoryEventSwapHand(PhaseTracker.getCauseStackManager().getCurrentCause(), inventory, slotTransactions); + return SpongeEventFactory.createChangeInventoryEventSwapHand(PhaseTracker.getCauseStackManager().currentCause(), inventory, slotTransactions); } @Override @@ -60,7 +60,7 @@ public void unwind(final InventoryPacketContext context) { final List trans = mixinInventory.bridge$getCapturedSlotTransactions(); final ChangeInventoryEvent.SwapHand swapItemEvent = this.createInventoryEvent(((Inventory) player.inventory), trans); SpongeCommon.postEvent(swapItemEvent); - PacketPhaseUtil.handleSlotRestore(player, null, swapItemEvent.getTransactions(), swapItemEvent.isCancelled()); + PacketPhaseUtil.handleSlotRestore(player, null, swapItemEvent.transactions(), swapItemEvent.isCancelled()); mixinInventory.bridge$setCaptureInventory(false); mixinInventory.bridge$getCapturedSlotTransactions().clear(); } diff --git a/src/main/java/org/spongepowered/common/event/tracking/phase/packet/inventory/SwitchHotbarNumberPressState.java b/src/main/java/org/spongepowered/common/event/tracking/phase/packet/inventory/SwitchHotbarNumberPressState.java index fac8406c879..72352e16725 100644 --- a/src/main/java/org/spongepowered/common/event/tracking/phase/packet/inventory/SwitchHotbarNumberPressState.java +++ b/src/main/java/org/spongepowered/common/event/tracking/phase/packet/inventory/SwitchHotbarNumberPressState.java @@ -52,7 +52,7 @@ public ClickContainerEvent createInventoryEvent(final ServerPlayer playerMP, fin final List slotTransactions, final List capturedEntities, final int usedButton, @Nullable final Slot slot) { return SpongeEventFactory.createClickContainerEventNumberPress( - PhaseTracker.getCauseStackManager().getCurrentCause(), + PhaseTracker.getCauseStackManager().currentCause(), openContainer, transaction, Optional.ofNullable(slot), slotTransactions, usedButton); } diff --git a/src/main/java/org/spongepowered/common/event/tracking/phase/packet/inventory/SwitchHotbarScrollState.java b/src/main/java/org/spongepowered/common/event/tracking/phase/packet/inventory/SwitchHotbarScrollState.java index 137fc8a5163..9b70a238988 100644 --- a/src/main/java/org/spongepowered/common/event/tracking/phase/packet/inventory/SwitchHotbarScrollState.java +++ b/src/main/java/org/spongepowered/common/event/tracking/phase/packet/inventory/SwitchHotbarScrollState.java @@ -65,7 +65,7 @@ public ClickContainerEvent createInventoryEvent(final ServerPlayer playerMP, fin final List capturedEntities, final int usedButton, @Nullable final org.spongepowered.api.item.inventory.Slot slot) { return SpongeEventFactory.createClickContainerEventNumberPress( - PhaseTracker.getCauseStackManager().getCurrentCause(), + PhaseTracker.getCauseStackManager().currentCause(), openContainer, transaction, Optional.ofNullable(slot), slotTransactions, usedButton); } @@ -93,16 +93,16 @@ public void unwind(final InventoryPacketContext context) { final ImmutableList transactions = new ImmutableList.Builder().add(sourceTransaction).add(targetTransaction).build(); final ChangeInventoryEvent.Held changeInventoryEventHeld = SpongeEventFactory - .createChangeInventoryEventHeld(frame.getCurrentCause(), slotNew, (Inventory) inventoryContainer, + .createChangeInventoryEventHeld(frame.currentCause(), slotNew, (Inventory) inventoryContainer, slotPrev, transactions); final net.minecraft.world.inventory.AbstractContainerMenu openContainer = player.containerMenu; SpongeCommon.postEvent(changeInventoryEventHeld); if (changeInventoryEventHeld.isCancelled() || PacketPhaseUtil.allTransactionsInvalid( - changeInventoryEventHeld.getTransactions())) { + changeInventoryEventHeld.transactions())) { player.connection.send(new ClientboundSetCarriedItemPacket(previousSlot)); inventory.selected = previousSlot; } else { - PacketPhaseUtil.handleSlotRestore(player, openContainer, changeInventoryEventHeld.getTransactions(), + PacketPhaseUtil.handleSlotRestore(player, openContainer, changeInventoryEventHeld.transactions(), false); inventory.selected = itemChange.getSlot(); player.resetLastActionTime(); diff --git a/src/main/java/org/spongepowered/common/event/tracking/phase/packet/player/ChatPacketState.java b/src/main/java/org/spongepowered/common/event/tracking/phase/packet/player/ChatPacketState.java index 1bb3df385ae..807103ea7d0 100644 --- a/src/main/java/org/spongepowered/common/event/tracking/phase/packet/player/ChatPacketState.java +++ b/src/main/java/org/spongepowered/common/event/tracking/phase/packet/player/ChatPacketState.java @@ -35,7 +35,7 @@ public final class ChatPacketState extends BasicPacketState { public void populateContext(ServerPlayer playerMP, Packet packet, BasicPacketContext context) { // CPacketChatMessage chatMessage = (CPacketChatMessage) packet; // unused, to be removed and re-located when phase context is cleaned up -// if (chatMessage.getMessage().contains("kill")) { +// if (chatMessage.message().contains("kill")) { // context.add(NamedCause.of(InternalNamedCauses.General.DESTRUCT_ITEM_DROPS, true)); // } } diff --git a/src/main/java/org/spongepowered/common/event/tracking/phase/packet/player/PacketCommandState.java b/src/main/java/org/spongepowered/common/event/tracking/phase/packet/player/PacketCommandState.java index 0eb0dd103ad..ec84c85ca9c 100644 --- a/src/main/java/org/spongepowered/common/event/tracking/phase/packet/player/PacketCommandState.java +++ b/src/main/java/org/spongepowered/common/event/tracking/phase/packet/player/PacketCommandState.java @@ -78,7 +78,7 @@ public void postBlockTransactionApplication(final BlockChange blockChange, final // We have to check if there is a player, because command blocks can be triggered // without player interaction. // Fixes https://github.com/SpongePowered/SpongeForge/issues/2442 - PhaseTracker.getCauseStackManager().getCurrentCause().first(User.class).ifPresent(user -> { + PhaseTracker.getCauseStackManager().currentCause().first(User.class).ifPresent(user -> { TrackingUtil.associateTrackerToTarget(blockChange, transaction, user); }); } @@ -89,13 +89,13 @@ public SpawnEntityEvent createSpawnEvent( final ImmutableList> collect, final Cause currentCause ) { final Cause newCauseWithSpawnType = Cause.builder().from(currentCause).build( - EventContext.builder().from(currentCause.getContext()).add( + EventContext.builder().from(currentCause.context()).add( EventContextKeys.SPAWN_TYPE, SpawnTypes.PLACEMENT.get() ).build()); return SpongeEventFactory.createSpawnEntityEvent(newCauseWithSpawnType, collect.stream() - .map(t -> (org.spongepowered.api.entity.Entity) t.getFirst()) + .map(t -> (org.spongepowered.api.entity.Entity) t.first()) .collect(Collectors.toList()) ); } diff --git a/src/main/java/org/spongepowered/common/event/tracking/phase/packet/player/PlaceBlockPacketState.java b/src/main/java/org/spongepowered/common/event/tracking/phase/packet/player/PlaceBlockPacketState.java index acef4ca9bd1..1a285a3fbd3 100644 --- a/src/main/java/org/spongepowered/common/event/tracking/phase/packet/player/PlaceBlockPacketState.java +++ b/src/main/java/org/spongepowered/common/event/tracking/phase/packet/player/PlaceBlockPacketState.java @@ -64,7 +64,7 @@ public final class PlaceBlockPacketState extends BasicPacketState { private BiConsumer BASIC_PACKET_MODIFIER = ((BiConsumer) IPhaseState.DEFAULT_OWNER_NOTIFIER) .andThen((frame, ctx) -> { - frame.addContext(EventContextKeys.PLAYER_PLACE, ctx.getSpongePlayer().getWorld()); + frame.addContext(EventContextKeys.PLAYER_PLACE, ctx.getSpongePlayer().world()); frame.addContext(EventContextKeys.USED_HAND, ctx.getHandUsed()); frame.addContext(EventContextKeys.USED_ITEM, ctx.getItemUsedSnapshot()); frame.pushCause(ctx.getSpongePlayer()); @@ -93,20 +93,20 @@ public void populateContext(final net.minecraft.server.level.ServerPlayer player @Override public void postBlockTransactionApplication(final BlockChange blockChange, final Transaction transaction, final BasicPacketContext context) { - TrackingUtil.associateTrackerToTarget(blockChange, transaction, ((ServerPlayer) context.getPacketPlayer()).getUser()); + TrackingUtil.associateTrackerToTarget(blockChange, transaction, ((ServerPlayer) context.getPacketPlayer()).user()); } @Override public void appendNotifierToBlockEvent(final BasicPacketContext context, final TrackedWorldBridge mixinWorldServer, final BlockPos pos, final TrackerBlockEventDataBridge blockEvent ) { - final Player player = PhaseTracker.getCauseStackManager().getCurrentCause().first(Player.class).get(); - final BlockState state = ((ServerWorld) mixinWorldServer).getBlock(pos.getX(), pos.getY(), pos.getZ()); + final Player player = PhaseTracker.getCauseStackManager().currentCause().first(Player.class).get(); + final BlockState state = ((ServerWorld) mixinWorldServer).block(pos.getX(), pos.getY(), pos.getZ()); final LocatableBlock locatable = new SpongeLocatableBlockBuilder().world((ServerWorld) mixinWorldServer).position(pos.getX(), pos.getY(), pos.getZ()).state(state).build(); blockEvent.bridge$setTickingLocatable(locatable); - blockEvent.bridge$setSourceUser(((ServerPlayer)player).getUser()); + blockEvent.bridge$setSourceUser(((ServerPlayer)player).user()); } @SuppressWarnings("ConstantConditions") @@ -140,7 +140,7 @@ public void unwind(final BasicPacketContext context) { @Override public SpawnType getEntitySpawnType(final BasicPacketContext context) { - if (context.getItemUsed().getType() instanceof SpawnEggItem) { + if (context.getItemUsed().type() instanceof SpawnEggItem) { return SpawnTypes.SPAWN_EGG.get(); } // Some other items directly cause entities to be spawned, such as diff --git a/src/main/java/org/spongepowered/common/event/tracking/phase/packet/player/ResourcePackState.java b/src/main/java/org/spongepowered/common/event/tracking/phase/packet/player/ResourcePackState.java index 60aa1f4d4ff..76804bc296d 100644 --- a/src/main/java/org/spongepowered/common/event/tracking/phase/packet/player/ResourcePackState.java +++ b/src/main/java/org/spongepowered/common/event/tracking/phase/packet/player/ResourcePackState.java @@ -71,6 +71,6 @@ public void unwind(BasicPacketContext phaseContext) { return; } SpongeCommon.postEvent( - SpongeEventFactory.createResourcePackStatusEvent(PhaseTracker.getCauseStackManager().getCurrentCause(), pack, (ServerPlayer) player, status)); + SpongeEventFactory.createResourcePackStatusEvent(PhaseTracker.getCauseStackManager().currentCause(), pack, (ServerPlayer) player, status)); } } diff --git a/src/main/java/org/spongepowered/common/event/tracking/phase/packet/player/UseItemPacketState.java b/src/main/java/org/spongepowered/common/event/tracking/phase/packet/player/UseItemPacketState.java index 6674810edc4..16fcc659fea 100644 --- a/src/main/java/org/spongepowered/common/event/tracking/phase/packet/player/UseItemPacketState.java +++ b/src/main/java/org/spongepowered/common/event/tracking/phase/packet/player/UseItemPacketState.java @@ -60,12 +60,12 @@ public final class UseItemPacketState extends BasicPacketState { private BiConsumer BASIC_PACKET_MODIFIER = ((BiConsumer) IPhaseState.DEFAULT_OWNER_NOTIFIER) .andThen((frame, ctx) -> { - frame.addContext(EventContextKeys.PLAYER_PLACE, ctx.getSpongePlayer().getWorld()); + frame.addContext(EventContextKeys.PLAYER_PLACE, ctx.getSpongePlayer().world()); frame.addContext(EventContextKeys.USED_HAND, ctx.getHandUsed()); frame.addContext(EventContextKeys.USED_ITEM, ctx.getItemUsedSnapshot()); final ItemStack itemStack = ctx.getItemUsed(); frame.addContext(EventContextKeys.SPAWN_TYPE, - itemStack.getType() instanceof SpawnEggItem ? SpawnTypes.SPAWN_EGG : SpawnTypes.PLACEMENT); + itemStack.type() instanceof SpawnEggItem ? SpawnTypes.SPAWN_EGG : SpawnTypes.PLACEMENT); frame.pushCause(ctx.getSpongePlayer()); }); @@ -93,13 +93,13 @@ public void populateContext(net.minecraft.server.level.ServerPlayer playerMP, Pa public void postBlockTransactionApplication(BlockChange blockChange, Transaction transaction, BasicPacketContext context) { ServerPlayer player = context.getSpongePlayer(); - BlockPos pos = VecHelper.toBlockPos(transaction.getFinal().getLocation().get()); - LevelChunkBridge spongeChunk = (LevelChunkBridge) ((ServerLevel) player.getWorld()).getChunkAt(pos); + BlockPos pos = VecHelper.toBlockPos(transaction.finalReplacement().location().get()); + LevelChunkBridge spongeChunk = (LevelChunkBridge) ((ServerLevel) player.world()).getChunkAt(pos); if (blockChange == BlockChange.PLACE) { - spongeChunk.bridge$addTrackedBlockPosition((Block) transaction.getFinal().getState().getType(), pos, player.getUser(), PlayerTracker.Type.CREATOR); + spongeChunk.bridge$addTrackedBlockPosition((Block) transaction.finalReplacement().state().type(), pos, player.user(), PlayerTracker.Type.CREATOR); } - spongeChunk.bridge$addTrackedBlockPosition((Block) transaction.getFinal().getState().getType(), pos, player.getUser(), PlayerTracker.Type.NOTIFIER); + spongeChunk.bridge$addTrackedBlockPosition((Block) transaction.finalReplacement().state().type(), pos, player.user(), PlayerTracker.Type.NOTIFIER); } @SuppressWarnings("ConstantConditions") @@ -111,7 +111,7 @@ public void unwind(BasicPacketContext context) { final HandType hand = context.getHandUsed(); try (CauseStackManager.StackFrame frame = PhaseTracker.getCauseStackManager().pushCauseFrame()) { frame.addContext(EventContextKeys.SPAWN_TYPE, - itemStack.getType() instanceof SpawnEggItem ? SpawnTypes.SPAWN_EGG : SpawnTypes.PLACEMENT); + itemStack.type() instanceof SpawnEggItem ? SpawnTypes.SPAWN_EGG : SpawnTypes.PLACEMENT); // context.getCapturedEntitySupplier() // .acceptAndClearIfNotEmpty(entities -> { // SpongeCommonEventFactory.callSpawnEntity(entities, context); diff --git a/src/main/java/org/spongepowered/common/event/tracking/phase/plugin/ListenerPhaseState.java b/src/main/java/org/spongepowered/common/event/tracking/phase/plugin/ListenerPhaseState.java index 047a73aa48a..f4d1b2ab8b1 100644 --- a/src/main/java/org/spongepowered/common/event/tracking/phase/plugin/ListenerPhaseState.java +++ b/src/main/java/org/spongepowered/common/event/tracking/phase/plugin/ListenerPhaseState.java @@ -60,7 +60,7 @@ public void associateNeighborStateNotifier(final L unwindingContext, @Nullable f final ServerLevel minecraftWorld, final PlayerTracker.Type notifier) { unwindingContext.getCapturedPlayer().ifPresent(player -> ((LevelChunkBridge) minecraftWorld.getChunkAt(notifyPos)) - .bridge$addTrackedBlockPosition(block, notifyPos, ((ServerPlayer) player).getUser(), PlayerTracker.Type.NOTIFIER) + .bridge$addTrackedBlockPosition(block, notifyPos, ((ServerPlayer) player).user(), PlayerTracker.Type.NOTIFIER) ); } diff --git a/src/main/java/org/spongepowered/common/event/tracking/phase/plugin/WorldTickListenerContext.java b/src/main/java/org/spongepowered/common/event/tracking/phase/plugin/WorldTickListenerContext.java index a244b21da15..9b3b8e0c744 100644 --- a/src/main/java/org/spongepowered/common/event/tracking/phase/plugin/WorldTickListenerContext.java +++ b/src/main/java/org/spongepowered/common/event/tracking/phase/plugin/WorldTickListenerContext.java @@ -57,7 +57,7 @@ public PrettyPrinter printCustom(final PrettyPrinter printer, final int indent) final String s = String.format("%1$" + indent + "s", ""); super.printCustom(printer, indent); if (!((WorldBridge) this.getWorld()).bridge$isFake()) { - printer.add(s + "- %s: %s", "TickingWorld", ((ServerWorld) this.getWorld()).getKey()); + printer.add(s + "- %s: %s", "TickingWorld", ((ServerWorld) this.getWorld()).key()); } else { printer.add(s + "- %s: %s", "Ticking World", "Pseudo Fake World?" + this.tickingWorld); } diff --git a/src/main/java/org/spongepowered/common/event/tracking/phase/plugin/WorldTickListenerState.java b/src/main/java/org/spongepowered/common/event/tracking/phase/plugin/WorldTickListenerState.java index f759aa3878f..4f2285b22ba 100644 --- a/src/main/java/org/spongepowered/common/event/tracking/phase/plugin/WorldTickListenerState.java +++ b/src/main/java/org/spongepowered/common/event/tracking/phase/plugin/WorldTickListenerState.java @@ -52,7 +52,7 @@ public void unwind(final WorldTickListenerContext phaseContext) { // frame.addContext(EventContextKeys.SPAWN_TYPE, SpawnTypes.DROPPED_ITEM); // final LocatableBlock // block = -// new SpongeLocatableBlockBuilder().world((ServerWorld) phaseContext.getWorld()).position(key.getX(), key.getY(), +// new SpongeLocatableBlockBuilder().world((ServerWorld) phaseContext.world()).position(key.getX(), key.getY(), // key.getZ()).build(); // frame.pushCause(container); // frame.pushCause(block); diff --git a/src/main/java/org/spongepowered/common/event/tracking/phase/tick/BlockEventTickPhaseState.java b/src/main/java/org/spongepowered/common/event/tracking/phase/tick/BlockEventTickPhaseState.java index 9fd437a2261..7ff77ece64b 100644 --- a/src/main/java/org/spongepowered/common/event/tracking/phase/tick/BlockEventTickPhaseState.java +++ b/src/main/java/org/spongepowered/common/event/tracking/phase/tick/BlockEventTickPhaseState.java @@ -85,8 +85,8 @@ public void associateNeighborStateNotifier( @Override public void postBlockTransactionApplication(final BlockChange blockChange, final Transaction snapshotTransaction, final BlockEventTickContext context) { - final Block block = (Block) snapshotTransaction.getOriginal().getState().getType(); - final SpongeBlockSnapshot original = (SpongeBlockSnapshot) snapshotTransaction.getOriginal(); + final Block block = (Block) snapshotTransaction.original().state().type(); + final SpongeBlockSnapshot original = (SpongeBlockSnapshot) snapshotTransaction.original(); final BlockPos changedBlockPos = original.getBlockPos(); original.getServerWorld().ifPresent(worldServer -> { final LevelChunkBridge changedMixinChunk = (LevelChunkBridge) worldServer.getChunkAt(changedBlockPos); diff --git a/src/main/java/org/spongepowered/common/event/tracking/phase/tick/BlockTickContext.java b/src/main/java/org/spongepowered/common/event/tracking/phase/tick/BlockTickContext.java index 1586f016e1f..c7340120991 100644 --- a/src/main/java/org/spongepowered/common/event/tracking/phase/tick/BlockTickContext.java +++ b/src/main/java/org/spongepowered/common/event/tracking/phase/tick/BlockTickContext.java @@ -49,10 +49,10 @@ public BlockTickContext source(final Object owner) { super.source(owner); if (owner instanceof LocatableBlock) { final LocatableBlock locatableBlock = (LocatableBlock) owner; - final Block block = ((BlockState) locatableBlock.getBlockState()).getBlock(); + final Block block = ((BlockState) locatableBlock.blockState()).getBlock(); this.tickingBlock = (BlockBridge) block; this.providesModifier = !(block instanceof LiquidBlock); - this.world = locatableBlock.getWorld(); + this.world = locatableBlock.world(); if (block instanceof TrackableBridge) { final TrackableBridge trackable = (TrackableBridge) block; this.setBlockEvents(trackable.bridge$allowsBlockEventCreation()) diff --git a/src/main/java/org/spongepowered/common/event/tracking/phase/tick/EntityTickPhaseState.java b/src/main/java/org/spongepowered/common/event/tracking/phase/tick/EntityTickPhaseState.java index 45c072c5768..028b1a02118 100644 --- a/src/main/java/org/spongepowered/common/event/tracking/phase/tick/EntityTickPhaseState.java +++ b/src/main/java/org/spongepowered/common/event/tracking/phase/tick/EntityTickPhaseState.java @@ -172,8 +172,8 @@ public void postBlockTransactionApplication(final BlockChange blockChange, final final EntityTickContext context) { if (blockChange == BlockChange.BREAK) { final Entity tickingEntity = context.getSource(Entity.class).get(); - final BlockPos blockPos = VecHelper.toBlockPos(transaction.getOriginal().getPosition()); - final List hangingEntities = ((ServerLevel) tickingEntity.getWorld()) + final BlockPos blockPos = VecHelper.toBlockPos(transaction.original().position()); + final List hangingEntities = ((ServerLevel) tickingEntity.world()) .getEntitiesOfClass(HangingEntity.class, new AABB(blockPos, blockPos).inflate(1.1D, 1.1D, 1.1D), entityIn -> { if (entityIn == null) { diff --git a/src/main/java/org/spongepowered/common/event/tracking/phase/tick/FluidTickContext.java b/src/main/java/org/spongepowered/common/event/tracking/phase/tick/FluidTickContext.java index 20e8056e166..1dfe23f74a7 100644 --- a/src/main/java/org/spongepowered/common/event/tracking/phase/tick/FluidTickContext.java +++ b/src/main/java/org/spongepowered/common/event/tracking/phase/tick/FluidTickContext.java @@ -49,9 +49,9 @@ public FluidTickContext source(final Object owner) { super.source(owner); if (owner instanceof LocatableBlock) { final LocatableBlock locatableBlock = (LocatableBlock) owner; - final Block block = ((BlockState) locatableBlock.getBlockState()).getBlock(); + final Block block = ((BlockState) locatableBlock.blockState()).getBlock(); this.providesModifier = !(block instanceof LiquidBlock); - this.world = locatableBlock.getWorld(); + this.world = locatableBlock.world(); if (block instanceof TrackableBridge) { final TrackableBridge trackable = (TrackableBridge) block; this.setBlockEvents(trackable.bridge$allowsBlockEventCreation()) diff --git a/src/main/java/org/spongepowered/common/event/tracking/phase/tick/FluidTickPhaseState.java b/src/main/java/org/spongepowered/common/event/tracking/phase/tick/FluidTickPhaseState.java index 49079777627..43c0884aa5c 100644 --- a/src/main/java/org/spongepowered/common/event/tracking/phase/tick/FluidTickPhaseState.java +++ b/src/main/java/org/spongepowered/common/event/tracking/phase/tick/FluidTickPhaseState.java @@ -151,7 +151,7 @@ public BlockChange associateBlockChangeWithSnapshot( @Override public Operation getBlockOperation(final SpongeBlockSnapshot original, final BlockChange blockChange ) { - final FluidState fluidState = original.getState().getFluidState(); + final FluidState fluidState = original.state().fluidState(); if (!fluidState.isEmpty() && blockChange == BlockChange.DECAY) { return Operations.LIQUID_DECAY.get(); } diff --git a/src/main/java/org/spongepowered/common/event/tracking/phase/tick/LocationBasedTickPhaseState.java b/src/main/java/org/spongepowered/common/event/tracking/phase/tick/LocationBasedTickPhaseState.java index 49d139c7d53..a1472937d76 100644 --- a/src/main/java/org/spongepowered/common/event/tracking/phase/tick/LocationBasedTickPhaseState.java +++ b/src/main/java/org/spongepowered/common/event/tracking/phase/tick/LocationBasedTickPhaseState.java @@ -71,8 +71,8 @@ public void postBlockTransactionApplication(final BlockChange blockChange, final Transaction snapshotTransaction, final T context) { // If we do not have a notifier at this point then there is no need to attempt to retrieve one from the chunk context.applyNotifierIfAvailable(user -> { - final SpongeBlockSnapshot original = (SpongeBlockSnapshot) snapshotTransaction.getOriginal(); - final Block block = (Block) original.getState().getType(); + final SpongeBlockSnapshot original = (SpongeBlockSnapshot) snapshotTransaction.original(); + final Block block = (Block) original.state().type(); final BlockPos changedBlockPos = original.getBlockPos(); original.getServerWorld().ifPresent(worldServer -> { final LevelChunkBridge changedMixinChunk = (LevelChunkBridge) worldServer.getChunkAt(changedBlockPos); diff --git a/src/main/java/org/spongepowered/common/event/tracking/phase/tick/PlayerTickPhaseState.java b/src/main/java/org/spongepowered/common/event/tracking/phase/tick/PlayerTickPhaseState.java index 928b2ca7dcc..69fa3b38bac 100644 --- a/src/main/java/org/spongepowered/common/event/tracking/phase/tick/PlayerTickPhaseState.java +++ b/src/main/java/org/spongepowered/common/event/tracking/phase/tick/PlayerTickPhaseState.java @@ -75,8 +75,8 @@ public void unwind(final PlayerTickContext context) { public void appendContextPreExplosion(final ExplosionContext explosionContext, final PlayerTickContext context) { final Player player = context.getSource(Player.class) .orElseThrow(TrackingUtil.throwWithContext("Expected to be processing over a ticking TileEntity!", context)); - explosionContext.creator(((ServerPlayer) player).getUser()); - explosionContext.notifier(((ServerPlayer) player).getUser()); + explosionContext.creator(((ServerPlayer) player).user()); + explosionContext.notifier(((ServerPlayer) player).user()); explosionContext.source(player); } diff --git a/src/main/java/org/spongepowered/common/event/tracking/phase/tick/TileEntityTickPhaseState.java b/src/main/java/org/spongepowered/common/event/tracking/phase/tick/TileEntityTickPhaseState.java index c52d13dc10d..5b31ef2c35f 100644 --- a/src/main/java/org/spongepowered/common/event/tracking/phase/tick/TileEntityTickPhaseState.java +++ b/src/main/java/org/spongepowered/common/event/tracking/phase/tick/TileEntityTickPhaseState.java @@ -64,7 +64,7 @@ public BiConsumer getFrameM LocatableBlock getLocatableBlockSourceFromContext(final PhaseContext context) { return context.getSource(BlockEntity.class) .orElseThrow(TrackingUtil.throwWithContext("Expected to be ticking over a TileEntity!", context)) - .getLocatableBlock(); + .locatableBlock(); } @SuppressWarnings("unchecked") @@ -73,7 +73,7 @@ public void unwind(final TileEntityTickContext context) { final BlockEntity tickingTile = context.getSource(BlockEntity.class) .orElseThrow(TrackingUtil.throwWithContext("Not ticking on a TileEntity!", context)); try (final CauseStackManager.StackFrame frame = PhaseTracker.getCauseStackManager().pushCauseFrame()) { - frame.pushCause(tickingTile.getLocatableBlock()); + frame.pushCause(tickingTile.locatableBlock()); TrackingUtil.processBlockCaptures(context); frame.addContext(EventContextKeys.SPAWN_TYPE, SpawnTypes.BLOCK_SPAWNING); } @@ -86,7 +86,7 @@ public void appendNotifierToBlockEvent(final TileEntityTickContext context, fina final BlockEntity tickingTile = context.getSource(BlockEntity.class) .orElseThrow(TrackingUtil.throwWithContext("Not ticking on a TileEntity!", context)); - blockEvent.bridge$setTickingLocatable(tickingTile.getLocatableBlock()); + blockEvent.bridge$setTickingLocatable(tickingTile.locatableBlock()); blockEvent.bridge$setTileEntity(tickingTile); } diff --git a/src/main/java/org/spongepowered/common/fluid/SpongeFluidStack.java b/src/main/java/org/spongepowered/common/fluid/SpongeFluidStack.java index 89fa6f75bd7..e68c6c3b0f6 100644 --- a/src/main/java/org/spongepowered/common/fluid/SpongeFluidStack.java +++ b/src/main/java/org/spongepowered/common/fluid/SpongeFluidStack.java @@ -67,12 +67,12 @@ private SpongeFluidStack(final FluidType fluidType, final int volume, @Nullable @Override @NonNull - public FluidType getFluid() { + public FluidType fluid() { return this.fluidType; } @Override - public int getVolume() { + public int volume() { return this.volume; } @@ -101,12 +101,12 @@ public boolean validateRawData(final DataView container) { public void setRawData(@NonNull final DataView container) throws InvalidDataException { try { final int contentVersion = container.getInt(Queries.CONTENT_VERSION).get(); - if (contentVersion != this.getContentVersion()) { + if (contentVersion != this.contentVersion()) { throw new InvalidDataException("Older content found! Cannot set raw data of older content!"); } final String rawFluid = container.getString(Constants.Fluids.FLUID_TYPE).get(); final int volume = container.getInt(Constants.Fluids.FLUID_VOLUME).get(); - final Optional fluidType = Sponge.getGame().registries().registry(RegistryTypes.FLUID_TYPE).findValue(ResourceKey.resolve(rawFluid)); + final Optional fluidType = Sponge.game().registries().registry(RegistryTypes.FLUID_TYPE).findValue(ResourceKey.resolve(rawFluid)); if (!fluidType.isPresent()) { throw new InvalidDataException("Unknown FluidType found! Requested: " + rawFluid + "but got none."); } @@ -121,16 +121,16 @@ public void setRawData(@NonNull final DataView container) throws InvalidDataExce } @Override - public int getContentVersion() { + public int contentVersion() { return 1; } @Override @NonNull public DataContainer toContainer() { - final ResourceKey resourceKey = Sponge.getGame().registries().registry(RegistryTypes.FLUID_TYPE).valueKey(this.fluidType); + final ResourceKey resourceKey = Sponge.game().registries().registry(RegistryTypes.FLUID_TYPE).valueKey(this.fluidType); final DataContainer container = DataContainer.createNew() - .set(Queries.CONTENT_VERSION, this.getContentVersion()) + .set(Queries.CONTENT_VERSION, this.contentVersion()) .set(Constants.Fluids.FLUID_TYPE, resourceKey) .set(Constants.Fluids.FLUID_VOLUME, this.volume); if (this.extraData != null) { diff --git a/src/main/java/org/spongepowered/common/fluid/SpongeFluidStackBuilder.java b/src/main/java/org/spongepowered/common/fluid/SpongeFluidStackBuilder.java index aa77a778969..0aa468c9828 100644 --- a/src/main/java/org/spongepowered/common/fluid/SpongeFluidStackBuilder.java +++ b/src/main/java/org/spongepowered/common/fluid/SpongeFluidStackBuilder.java @@ -88,8 +88,8 @@ public FluidStack build() { @Override public FluidStack.@NonNull Builder from(final FluidStack value) { - this.fluidType = value.getFluid(); - this.volume = value.getVolume(); + this.fluidType = value.fluid(); + this.volume = value.volume(); final DataContainer container = value.toContainer(); if (container.contains(Constants.Sponge.UNSAFE_NBT)) { this.extra = container.getView(Constants.Sponge.UNSAFE_NBT).get().copy(); @@ -106,7 +106,7 @@ protected Optional buildContent(final DataView container) throws Inv this.reset(); final String rawFluid = container.getString(Constants.Fluids.FLUID_TYPE).get(); - final Optional fluidType = Sponge.getGame().registries().registry(RegistryTypes.FLUID_TYPE).findValue(ResourceKey.resolve(rawFluid)); + final Optional fluidType = Sponge.game().registries().registry(RegistryTypes.FLUID_TYPE).findValue(ResourceKey.resolve(rawFluid)); if (!fluidType.isPresent()) { throw new InvalidDataException("Invalid fluid id found: " + rawFluid); } diff --git a/src/main/java/org/spongepowered/common/fluid/SpongeFluidStackSnapshot.java b/src/main/java/org/spongepowered/common/fluid/SpongeFluidStackSnapshot.java index 7671e2bcf05..91542274799 100644 --- a/src/main/java/org/spongepowered/common/fluid/SpongeFluidStackSnapshot.java +++ b/src/main/java/org/spongepowered/common/fluid/SpongeFluidStackSnapshot.java @@ -66,12 +66,12 @@ private SpongeFluidStackSnapshot(final FluidType fluidType, final int volume, @N @Override @NonNull - public FluidType getFluid() { + public FluidType fluid() { return this.fluidType; } @Override - public int getVolume() { + public int volume() { return this.volume; } @@ -82,16 +82,16 @@ public FluidStack createStack() { } @Override - public int getContentVersion() { + public int contentVersion() { return 1; } @Override @NonNull public DataContainer toContainer() { - final ResourceKey resourceKey = Sponge.getGame().registries().registry(RegistryTypes.FLUID_TYPE).valueKey(this.fluidType); + final ResourceKey resourceKey = Sponge.game().registries().registry(RegistryTypes.FLUID_TYPE).valueKey(this.fluidType); final DataContainer container = DataContainer.createNew() - .set(Queries.CONTENT_VERSION, this.getContentVersion()) + .set(Queries.CONTENT_VERSION, this.contentVersion()) .set(Constants.Fluids.FLUID_TYPE, resourceKey) .set(Constants.Fluids.FLUID_VOLUME, this.volume); if (this.extraData != null) { diff --git a/src/main/java/org/spongepowered/common/fluid/SpongeFluidStackSnapshotBuilder.java b/src/main/java/org/spongepowered/common/fluid/SpongeFluidStackSnapshotBuilder.java index b74465542cf..b3c50b12274 100644 --- a/src/main/java/org/spongepowered/common/fluid/SpongeFluidStackSnapshotBuilder.java +++ b/src/main/java/org/spongepowered/common/fluid/SpongeFluidStackSnapshotBuilder.java @@ -72,8 +72,8 @@ public SpongeFluidStackSnapshotBuilder() { @Override public FluidStackSnapshot.@NonNull Builder from(@NonNull final FluidStack fluidStack) { - this.fluidType = fluidStack.getFluid(); - this.volume = fluidStack.getVolume(); + this.fluidType = fluidStack.fluid(); + this.volume = fluidStack.volume(); final DataContainer datacontainer = fluidStack.toContainer(); this.container = null; if (datacontainer.contains(Constants.Sponge.UNSAFE_NBT)) { @@ -88,7 +88,7 @@ public SpongeFluidStackSnapshotBuilder() { if (!(holder instanceof SpongeFluidStackSnapshot)) { throw new IllegalArgumentException("Must be a SpongeFluidStackSnapshot"); } - this.fluidType = Objects.requireNonNull(holder.getFluid(), "Invalid FluidStackSnapshot! FluidType cannot be null!"); + this.fluidType = Objects.requireNonNull(holder.fluid(), "Invalid FluidStackSnapshot! FluidType cannot be null!"); this.container = holder.toContainer(); this.keyValues = new LinkedHashMap<>(((SpongeFluidStackSnapshot) holder).impl$getMappedValues()); return this; @@ -118,7 +118,7 @@ protected Optional buildContent(@NonNull final DataView cont try { if (container.contains(Constants.Fluids.FLUID_TYPE, Constants.Fluids.FLUID_VOLUME)) { final String rawFluid = container.getString(Constants.Fluids.FLUID_TYPE).get(); - final Optional type = Sponge.getGame().registries().registry(RegistryTypes.FLUID_TYPE).findValue(ResourceKey.resolve(rawFluid)); + final Optional type = Sponge.game().registries().registry(RegistryTypes.FLUID_TYPE).findValue(ResourceKey.resolve(rawFluid)); if (!type.isPresent()) { throw new InvalidDataException("Unknown fluid id found: " + rawFluid); } diff --git a/src/main/java/org/spongepowered/common/fluid/SpongeFluidStateBuilder.java b/src/main/java/org/spongepowered/common/fluid/SpongeFluidStateBuilder.java index dceb02971bb..fe683ba58a6 100644 --- a/src/main/java/org/spongepowered/common/fluid/SpongeFluidStateBuilder.java +++ b/src/main/java/org/spongepowered/common/fluid/SpongeFluidStateBuilder.java @@ -50,11 +50,11 @@ public final class SpongeFluidStateBuilder implements org.spongepowered.api.fluid.FluidState.Builder { - private org.spongepowered.api.fluid.FluidState state = FluidTypes.EMPTY.get().getDefaultState(); + private org.spongepowered.api.fluid.FluidState state = FluidTypes.EMPTY.get().defaultState(); @Override public org.spongepowered.api.fluid.FluidState.@NonNull Builder fluid(@NonNull final FluidType fluidType) { - this.state = Objects.requireNonNull(fluidType).getDefaultState(); + this.state = Objects.requireNonNull(fluidType).defaultState(); return this; } diff --git a/src/main/java/org/spongepowered/common/hooks/DimensionHooks.java b/src/main/java/org/spongepowered/common/hooks/DimensionHooks.java index 512c835f09b..2f6fc912705 100644 --- a/src/main/java/org/spongepowered/common/hooks/DimensionHooks.java +++ b/src/main/java/org/spongepowered/common/hooks/DimensionHooks.java @@ -47,6 +47,6 @@ public interface DimensionHooks { * @return True to generate spawn on load as a default */ default boolean doesGenerateSpawnOnLoad(final DimensionType dimensionType) { - return WorldTypes.OVERWORLD.get(Sponge.getServer().registries()) == dimensionType; + return WorldTypes.OVERWORLD.get(Sponge.server().registries()) == dimensionType; } } diff --git a/src/main/java/org/spongepowered/common/hooks/EventHooks.java b/src/main/java/org/spongepowered/common/hooks/EventHooks.java index 26e920bd685..28e717cfb6b 100644 --- a/src/main/java/org/spongepowered/common/hooks/EventHooks.java +++ b/src/main/java/org/spongepowered/common/hooks/EventHooks.java @@ -38,7 +38,7 @@ public interface EventHooks { default ChangeEntityWorldEvent.Pre callChangeEntityWorldEventPre(final Entity entity, final ServerLevel toWorld) { - final ChangeEntityWorldEvent.Pre event = SpongeEventFactory.createChangeEntityWorldEventPre(PhaseTracker.getCauseStackManager().getCurrentCause(), + final ChangeEntityWorldEvent.Pre event = SpongeEventFactory.createChangeEntityWorldEventPre(PhaseTracker.getCauseStackManager().currentCause(), (org.spongepowered.api.entity.Entity) entity, (org.spongepowered.api.world.server.ServerWorld) entity.getCommandSenderWorld(), (org.spongepowered.api.world.server.ServerWorld) toWorld, (org.spongepowered.api.world.server.ServerWorld) toWorld); SpongeCommon.postEvent(event); @@ -47,7 +47,7 @@ default ChangeEntityWorldEvent.Pre callChangeEntityWorldEventPre(final Entity en default void callChangeEntityWorldEventPost(final Entity entity, final net.minecraft.server.level.ServerLevel fromWorld, final ServerLevel originalDestinationWorld) { - final ChangeEntityWorldEvent.Post event = SpongeEventFactory.createChangeEntityWorldEventPost(PhaseTracker.getCauseStackManager().getCurrentCause(), + final ChangeEntityWorldEvent.Post event = SpongeEventFactory.createChangeEntityWorldEventPost(PhaseTracker.getCauseStackManager().currentCause(), (org.spongepowered.api.entity.Entity) entity, (org.spongepowered.api.world.server.ServerWorld) fromWorld, (org.spongepowered.api.world.server.ServerWorld) entity.getCommandSenderWorld(), (org.spongepowered.api.world.server.ServerWorld) originalDestinationWorld); diff --git a/src/main/java/org/spongepowered/common/hooks/GeneralHooks.java b/src/main/java/org/spongepowered/common/hooks/GeneralHooks.java index 554c7be6e89..81043ca7662 100644 --- a/src/main/java/org/spongepowered/common/hooks/GeneralHooks.java +++ b/src/main/java/org/spongepowered/common/hooks/GeneralHooks.java @@ -43,6 +43,6 @@ default boolean onServerThread() { // Return true when the server isn't yet initialized, this means on a client // that the game is still being loaded. This is needed to support initialization // events with cause tracking. - return !Sponge.isServerAvailable() || Sponge.getServer().onMainThread(); + return !Sponge.isServerAvailable() || Sponge.server().onMainThread(); } } diff --git a/src/main/java/org/spongepowered/common/inject/provider/PluginAssetProvider.java b/src/main/java/org/spongepowered/common/inject/provider/PluginAssetProvider.java index a50f324de94..2461bd1ba2b 100644 --- a/src/main/java/org/spongepowered/common/inject/provider/PluginAssetProvider.java +++ b/src/main/java/org/spongepowered/common/inject/provider/PluginAssetProvider.java @@ -43,7 +43,7 @@ public class PluginAssetProvider implements Provider { @Override public Asset get() { String name = this.point.getAnnotation(AssetId.class).value(); - return this.assetManager.getAsset(this.container, name) + return this.assetManager.asset(this.container, name) .orElseThrow(() -> new NoSuchElementException("Cannot find asset " + name)); } diff --git a/src/main/java/org/spongepowered/common/inject/provider/PluginConfigurationModule.java b/src/main/java/org/spongepowered/common/inject/provider/PluginConfigurationModule.java index 356cd05acc0..8e90fc2e609 100644 --- a/src/main/java/org/spongepowered/common/inject/provider/PluginConfigurationModule.java +++ b/src/main/java/org/spongepowered/common/inject/provider/PluginConfigurationModule.java @@ -34,17 +34,6 @@ import org.checkerframework.checker.nullness.qual.Nullable; import org.spongepowered.api.config.ConfigRoot; import org.spongepowered.common.config.PluginConfigManager; -import org.spongepowered.common.inject.provider.PluginConfigurationModule.CommentedConfigurationNodeProvider; -import org.spongepowered.common.inject.provider.PluginConfigurationModule.CommentedConfigurationNodeReferenceProvider; -import org.spongepowered.common.inject.provider.PluginConfigurationModule.IHateGuiceInjectorProvider; -import org.spongepowered.common.inject.provider.PluginConfigurationModule.NonSharedDirAsPath; -import org.spongepowered.common.inject.provider.PluginConfigurationModule.NonSharedPathAsPath; -import org.spongepowered.common.inject.provider.PluginConfigurationModule.PrivateCommentedConfigurationNode; -import org.spongepowered.common.inject.provider.PluginConfigurationModule.PrivateCommentedConfigurationNodeReference; -import org.spongepowered.common.inject.provider.PluginConfigurationModule.SharedCommentedConfigurationNode; -import org.spongepowered.common.inject.provider.PluginConfigurationModule.SharedCommentedConfigurationNodeReference; -import org.spongepowered.common.inject.provider.PluginConfigurationModule.SharedDirAsPath; -import org.spongepowered.common.inject.provider.PluginConfigurationModule.TypeSerializers; import org.spongepowered.configurate.CommentedConfigurationNode; import org.spongepowered.configurate.ConfigurateException; import org.spongepowered.configurate.ConfigurationNode; @@ -154,7 +143,7 @@ static final class NonSharedDirAsPath implements Provider { @Override public Path get() { - return this.mgr.getPluginConfig(this.container).getDirectory(); + return this.mgr.pluginConfig(this.container).directory(); } } @@ -177,7 +166,7 @@ static final class NonSharedPathAsPath implements Provider { @Override public Path get() { - return this.mgr.getPluginConfig(this.container).getConfigPath(); + return this.mgr.pluginConfig(this.container).configPath(); } } @@ -200,7 +189,7 @@ static final class SharedDirAsPath implements Provider { @Override public Path get() { - return this.mgr.getSharedConfig(this.container).getConfigPath(); + return this.mgr.sharedConfig(this.container).configPath(); } } @@ -231,7 +220,7 @@ static final class SharedCommentedConfigurationNode extends CommentedConfigurati @Override public ConfigurationLoader get() { - return this.mgr.getSharedConfig(this.container).getConfig(PluginConfigManager.getOptions(this.serializers.get())); + return this.mgr.sharedConfig(this.container).config(PluginConfigManager.getOptions(this.serializers.get())); } } @@ -246,7 +235,7 @@ static final class PrivateCommentedConfigurationNode extends CommentedConfigurat @Override public ConfigurationLoader get() { - return this.mgr.getPluginConfig(this.container).getConfig(PluginConfigManager.getOptions(this.serializers.get())); + return this.mgr.pluginConfig(this.container).config(PluginConfigManager.getOptions(this.serializers.get())); } } @@ -296,10 +285,10 @@ static final class SharedCommentedConfigurationNodeReference extends CommentedCo @Override public ConfigurationReference get() { - final ConfigRoot shared = this.mgr.getSharedConfig(this.container); + final ConfigRoot shared = this.mgr.sharedConfig(this.container); try { - return this.configureLogging(shared.getConfigPath(), this.mgr.getWatchServiceListener() - .listenToConfiguration(path -> shared.getConfig(PluginConfigManager.getOptions(this.serializers.get())), shared.getConfigPath())); + return this.configureLogging(shared.configPath(), this.mgr.watchServiceListener() + .listenToConfiguration(path -> shared.config(PluginConfigManager.getOptions(this.serializers.get())), shared.configPath())); } catch (final ConfigurateException ex) { throw new ProvisionException("Unable to load configuration reference", ex); } @@ -317,11 +306,11 @@ static final class PrivateCommentedConfigurationNodeReference extends CommentedC @Override public ConfigurationReference get() { - final ConfigRoot privateRoot = this.mgr.getPluginConfig(this.container); + final ConfigRoot privateRoot = this.mgr.pluginConfig(this.container); try { - return this.configureLogging(privateRoot.getConfigPath(), this.mgr.getWatchServiceListener() - .listenToConfiguration(path -> privateRoot.getConfig(PluginConfigManager.getOptions(this.serializers.get())), - privateRoot.getConfigPath())); + return this.configureLogging(privateRoot.configPath(), this.mgr.watchServiceListener() + .listenToConfiguration(path -> privateRoot.config(PluginConfigManager.getOptions(this.serializers.get())), + privateRoot.configPath())); } catch (final ConfigurateException ex) { throw new ProvisionException("Unable to load configuration reference", ex); } @@ -344,9 +333,9 @@ static final class TypeSerializers implements Provider public TypeSerializerCollection get() { final @Nullable Injector injector = IHateGuiceInjectorProvider.get(this.container); if (injector == null) { - return this.mgr.getSerializers(); + return this.mgr.serializers(); } else { - return this.mgr.getSerializers().childBuilder() + return this.mgr.serializers().childBuilder() .registerAnnotatedObjects(ObjectMapper.factoryBuilder() .addDiscoverer(GuiceObjectMapperProvider.injectedObjectDiscoverer(injector)) .build()) diff --git a/src/main/java/org/spongepowered/common/inventory/DefaultSingleBlockCarrier.java b/src/main/java/org/spongepowered/common/inventory/DefaultSingleBlockCarrier.java index 2a4d98a02d9..1eb9e33612f 100644 --- a/src/main/java/org/spongepowered/common/inventory/DefaultSingleBlockCarrier.java +++ b/src/main/java/org/spongepowered/common/inventory/DefaultSingleBlockCarrier.java @@ -42,37 +42,36 @@ public interface DefaultSingleBlockCarrier extends SingleBlockCarrier { @Override - default Inventory getInventory(Direction from) { - return DefaultSingleBlockCarrier.getInventory(from, this); + default Inventory inventory(final Direction from) { + return DefaultSingleBlockCarrier.inventory(from, this); } @SuppressWarnings({"rawtypes", "unchecked"}) @Override - default CarriedInventory getInventory() { + default CarriedInventory inventory() { if (this instanceof CarriedInventory) { return (CarriedInventory) this; } // override for non CarriedInventory - throw new MissingImplementationException("SingleBlockCarrier", "getInventory"); + throw new MissingImplementationException("SingleBlockCarrier", "inventory"); } - @SuppressWarnings("deprecation") - static Inventory getInventory(Direction from, BlockCarrier thisThing) { + static Inventory inventory(final Direction from, final BlockCarrier thisThing) { if (thisThing instanceof WorldlyContainer) { - net.minecraft.core.Direction facing = DirectionFacingProvider.INSTANCE.get(from).get(); - int[] slots = ((WorldlyContainer) thisThing).getSlotsForFace(facing); + final net.minecraft.core.Direction facing = DirectionFacingProvider.INSTANCE.get(from).get(); + final int[] slots = ((WorldlyContainer) thisThing).getSlotsForFace(facing); if (slots.length == 0) { - return new EmptyInventoryImpl(thisThing.getInventory()); + return new EmptyInventoryImpl(thisThing.inventory()); } // build query for each slot - Query.Builder builder = Query.builder(); + final Query.Builder builder = Query.builder(); Arrays.stream(slots).mapToObj(slot -> QueryTypes.KEY_VALUE.get().of(SlotMatchers.index(slot))) .forEach(builder::and); - Query query = builder.build(); + final Query query = builder.build(); - return thisThing.getInventory().query(query); + return thisThing.inventory().query(query); } - return thisThing.getInventory(); + return thisThing.inventory(); } } diff --git a/src/main/java/org/spongepowered/common/inventory/EmptyInventoryImpl.java b/src/main/java/org/spongepowered/common/inventory/EmptyInventoryImpl.java index 0092862885f..b1910581998 100644 --- a/src/main/java/org/spongepowered/common/inventory/EmptyInventoryImpl.java +++ b/src/main/java/org/spongepowered/common/inventory/EmptyInventoryImpl.java @@ -222,7 +222,7 @@ public boolean canFit(ItemStack stack) { return false; } - public Optional getSlot(int index) { + public Optional slot(int index) { return Optional.empty(); } diff --git a/src/main/java/org/spongepowered/common/inventory/InventoryTransactionResultImpl.java b/src/main/java/org/spongepowered/common/inventory/InventoryTransactionResultImpl.java index ac8fd24289b..95b726a8ef4 100644 --- a/src/main/java/org/spongepowered/common/inventory/InventoryTransactionResultImpl.java +++ b/src/main/java/org/spongepowered/common/inventory/InventoryTransactionResultImpl.java @@ -59,15 +59,15 @@ public class InventoryTransactionResultImpl implements InventoryTransactionResul @Override public InventoryTransactionResult and(InventoryTransactionResult other) { Type resultType = Type.SUCCESS; - if (this.type == Type.ERROR || other.getType() == Type.ERROR) { + if (this.type == Type.ERROR || other.type() == Type.ERROR) { resultType = Type.ERROR; } - if (this.type == Type.FAILURE || other.getType() == Type.FAILURE) { + if (this.type == Type.FAILURE || other.type() == Type.FAILURE) { resultType = Type.FAILURE; } InventoryTransactionResult.Builder builder = - InventoryTransactionResult.builder().type(resultType).reject(this.rejected).reject(other.getRejectedItems()) - .transaction(this.slotTransactions).transaction(other.getSlotTransactions()); + InventoryTransactionResult.builder().type(resultType).reject(this.rejected).reject(other.rejectedItems()) + .transaction(this.slotTransactions).transaction(other.slotTransactions()); this.polled.forEach(builder::poll); return builder.build(); } @@ -75,7 +75,7 @@ public InventoryTransactionResult and(InventoryTransactionResult other) { @Override public void revert() { for (SlotTransaction transaction : Lists.reverse(this.slotTransactions)) { - transaction.getSlot().set(transaction.getOriginal().createStack()); + transaction.slot().set(transaction.original().createStack()); } } @@ -89,27 +89,27 @@ public boolean revertOnFailure() { } @Override - public Type getType() { + public Type type() { return this.type; } @Override - public List getRejectedItems() { + public List rejectedItems() { return this.rejected; } @Override - public List getSlotTransactions() { + public List slotTransactions() { return this.slotTransactions; } @Override - public List getPolledItems() { + public List polledItems() { return this.polled; } @Override - public ItemStackSnapshot getPolledItem() { + public ItemStackSnapshot polledItem() { return this.polled.get(0); } @@ -186,9 +186,9 @@ public InventoryTransactionResult.Poll build() { @Override public InventoryTransactionResult.Builder from(InventoryTransactionResult value) { checkNotNull(value, "InventoryTransactionResult cannot be null!"); - this.resultType = checkNotNull(value.getType(), "ResultType cannot be null!"); - this.slotTransactions = new ArrayList<>(value.getSlotTransactions()); - this.rejected = new ArrayList<>(value.getRejectedItems()); + this.resultType = checkNotNull(value.type(), "ResultType cannot be null!"); + this.slotTransactions = new ArrayList<>(value.slotTransactions()); + this.rejected = new ArrayList<>(value.rejectedItems()); return this; } diff --git a/src/main/java/org/spongepowered/common/inventory/SpongeBlockEntityCarrier.java b/src/main/java/org/spongepowered/common/inventory/SpongeBlockEntityCarrier.java index 5ced83528aa..cda0266e703 100644 --- a/src/main/java/org/spongepowered/common/inventory/SpongeBlockEntityCarrier.java +++ b/src/main/java/org/spongepowered/common/inventory/SpongeBlockEntityCarrier.java @@ -44,19 +44,19 @@ public SpongeBlockEntityCarrier(final BlockEntity inventory, final Container con } @Override - public World getWorld() { + public World world() { return (World) this.inventory.getLevel(); } @Override - public ServerLocation getLocation() { + public ServerLocation location() { final BlockPos pos = this.inventory.getBlockPos(); return ServerLocation.of(((ServerWorld) this.inventory.getLevel()), pos.getX(), pos.getY(), pos.getZ()); } @Override @SuppressWarnings("unchecked") - public CarriedInventory getInventory() { + public CarriedInventory inventory() { return (CarriedInventory) this.container; } } diff --git a/src/main/java/org/spongepowered/common/inventory/SpongeLocationCarrier.java b/src/main/java/org/spongepowered/common/inventory/SpongeLocationCarrier.java index 403ff0d22c8..46b7e5ea61f 100644 --- a/src/main/java/org/spongepowered/common/inventory/SpongeLocationCarrier.java +++ b/src/main/java/org/spongepowered/common/inventory/SpongeLocationCarrier.java @@ -41,17 +41,17 @@ public SpongeLocationCarrier(final ServerLocation location, final Container cont } @Override - public World getWorld() { - return this.location.getWorld(); + public World world() { + return this.location.world(); } @Override - public ServerLocation getLocation() { + public ServerLocation location() { return this.location; } @Override - public CarriedInventory getInventory() { + public CarriedInventory inventory() { return (CarriedInventory) this.container; } } diff --git a/src/main/java/org/spongepowered/common/inventory/adapter/impl/AdapterLogic.java b/src/main/java/org/spongepowered/common/inventory/adapter/impl/AdapterLogic.java index 8717e3c0cdd..6ff9d62fdec 100644 --- a/src/main/java/org/spongepowered/common/inventory/adapter/impl/AdapterLogic.java +++ b/src/main/java/org/spongepowered/common/inventory/adapter/impl/AdapterLogic.java @@ -161,7 +161,7 @@ private static InventoryTransactionResult insertStack(Fabric fabric, Lens lens, } int maxStackSize = Math.min(lens.getMaxStackSize(fabric), nativeStack.getMaxStackSize()); - int remaining = stack.getQuantity(); + int remaining = stack.quantity(); for (int ord = 0; ord < lens.slotCount() && remaining > 0; ord++) { final net.minecraft.world.item.ItemStack old = lens.getStack(fabric, ord); @@ -193,7 +193,7 @@ public static InventoryTransactionResult appendSequential(Fabric fabric, @Nullab net.minecraft.world.item.ItemStack nativeStack = ItemStackUtil.toNative(stack); int maxStackSize = Math.min(lens.getMaxStackSize(fabric), nativeStack.getMaxStackSize()); - int remaining = stack.getQuantity(); + int remaining = stack.quantity(); for (int ord = 0; ord < lens.slotCount() && remaining > 0; ord++) { net.minecraft.world.item.ItemStack old = lens.getStack(fabric, ord); @@ -214,7 +214,7 @@ public static InventoryTransactionResult appendSequential(Fabric fabric, @Nullab } - if (remaining == stack.getQuantity()) { + if (remaining == stack.quantity()) { // No items were consumed result.type(Type.FAILURE).reject(ItemStackUtil.cloneDefensive(nativeStack)); } else { @@ -245,7 +245,7 @@ public static int getCapacity(Fabric fabric, Lens lens) { } public static boolean contains(InventoryAdapter adapter, ItemStack stack) { - return AdapterLogic.contains(adapter.inventoryAdapter$getFabric(), adapter.inventoryAdapter$getRootLens(), stack, stack.getQuantity()); + return AdapterLogic.contains(adapter.inventoryAdapter$getFabric(), adapter.inventoryAdapter$getRootLens(), stack, stack.quantity()); } public static boolean contains(InventoryAdapter adapter, ItemStack stack, int quantity) { @@ -309,7 +309,7 @@ public static boolean canFit(Fabric fabric, Lens lens, ItemStack stack) { net.minecraft.world.item.ItemStack nativeStack = ItemStackUtil.toNative(stack); int maxStackSize = Math.min(lens.getMaxStackSize(fabric), nativeStack.getMaxStackSize()); - int remaining = stack.getQuantity(); + int remaining = stack.quantity(); for (int ord = 0; ord < lens.slotCount() && remaining > 0; ord++) { net.minecraft.world.item.ItemStack old = lens.getStack(fabric, ord); diff --git a/src/main/java/org/spongepowered/common/inventory/adapter/impl/DefaultImplementedAdapterInventory.java b/src/main/java/org/spongepowered/common/inventory/adapter/impl/DefaultImplementedAdapterInventory.java index 569a0fd2430..b173dd8b3b7 100644 --- a/src/main/java/org/spongepowered/common/inventory/adapter/impl/DefaultImplementedAdapterInventory.java +++ b/src/main/java/org/spongepowered/common/inventory/adapter/impl/DefaultImplementedAdapterInventory.java @@ -188,7 +188,7 @@ default boolean containsChild(Inventory child) { } @Override - default Optional getSlot(int index) { + default Optional slot(int index) { return ((InventoryBridge) this).bridge$getAdapter().inventoryAdapter$getSlot(index); } diff --git a/src/main/java/org/spongepowered/common/inventory/adapter/impl/comp/CraftingInventoryAdapter.java b/src/main/java/org/spongepowered/common/inventory/adapter/impl/comp/CraftingInventoryAdapter.java index a659db54391..1422341771c 100644 --- a/src/main/java/org/spongepowered/common/inventory/adapter/impl/comp/CraftingInventoryAdapter.java +++ b/src/main/java/org/spongepowered/common/inventory/adapter/impl/comp/CraftingInventoryAdapter.java @@ -45,7 +45,7 @@ public CraftingInventoryAdapter(Fabric fabric, CraftingInventoryLens root, Inven } @Override - public CraftingGridInventory getCraftingGrid() { + public CraftingGridInventory craftingGrid() { if (this.craftingGrid == null) { this.craftingGrid = (CraftingGridInventory) this.craftingLens.getCraftingGrid().getAdapter(this.inventoryAdapter$getFabric(), this); } @@ -53,7 +53,7 @@ public CraftingGridInventory getCraftingGrid() { } @Override - public CraftingOutput getResult() { + public CraftingOutput result() { if (this.result == null) { this.result = (CraftingOutput) this.craftingLens.getOutputSlot().getAdapter(this.inventoryAdapter$getFabric(), this); } diff --git a/src/main/java/org/spongepowered/common/inventory/adapter/impl/comp/EquipmentInventoryAdapter.java b/src/main/java/org/spongepowered/common/inventory/adapter/impl/comp/EquipmentInventoryAdapter.java index 10f7a991e40..90f1d32060c 100644 --- a/src/main/java/org/spongepowered/common/inventory/adapter/impl/comp/EquipmentInventoryAdapter.java +++ b/src/main/java/org/spongepowered/common/inventory/adapter/impl/comp/EquipmentInventoryAdapter.java @@ -55,7 +55,7 @@ public EquipmentInventoryAdapter(Equipable carrier, Fabric fabric, ArmorInventor } @Override - public Optional getCarrier() { + public Optional carrier() { return Optional.ofNullable(this.carrier); } @@ -88,7 +88,7 @@ public InventoryTransactionResult set(EquipmentType equipmentType, ItemStack sta } @Override - public Optional getSlot(EquipmentType equipmentType) { + public Optional slot(EquipmentType equipmentType) { Inventory slot = this.queryForType(equipmentType); if (slot instanceof Slot) { return Optional.of((Slot) slot); diff --git a/src/main/java/org/spongepowered/common/inventory/adapter/impl/comp/GridInventoryAdapter.java b/src/main/java/org/spongepowered/common/inventory/adapter/impl/comp/GridInventoryAdapter.java index 490a347a993..7b6d6605df1 100644 --- a/src/main/java/org/spongepowered/common/inventory/adapter/impl/comp/GridInventoryAdapter.java +++ b/src/main/java/org/spongepowered/common/inventory/adapter/impl/comp/GridInventoryAdapter.java @@ -55,27 +55,27 @@ public GridInventoryAdapter(Fabric fabric, GridInventoryLens root, Inventory par } @Override - public int getColumns() { + public int columns() { return this.lens2d.getWidth(); } @Override - public int getRows() { + public int rows() { return this.lens2d.getHeight(); } @Override - public Vector2i getDimensions() { - return new Vector2i(this.getColumns(), this.getRows()); + public Vector2i dimensions() { + return new Vector2i(this.columns(), this.rows()); } @Override - public Optional getSlot(int x, int y) { + public Optional slot(int x, int y) { return BasicInventoryAdapter.forSlot(this.inventoryAdapter$getFabric(), this.getSlotLens(x, y), this); } @Override - public Optional getRow(int y) { + public Optional row(int y) { try { InventoryRowLens rowLens = this.gridLens.getRow(y); return Optional.ofNullable((InventoryRow) rowLens.getAdapter(this.inventoryAdapter$getFabric(), this)); @@ -85,7 +85,7 @@ public Optional getRow(int y) { } @Override - public Optional getColumn(int x) { + public Optional column(int x) { try { InventoryColumnLens columnLens = this.gridLens.getColumn(x); return Optional.ofNullable((InventoryColumn) columnLens.getAdapter(this.inventoryAdapter$getFabric(), this)); diff --git a/src/main/java/org/spongepowered/common/inventory/adapter/impl/comp/HotbarAdapter.java b/src/main/java/org/spongepowered/common/inventory/adapter/impl/comp/HotbarAdapter.java index 08d4bb0d939..3d704ae73ac 100644 --- a/src/main/java/org/spongepowered/common/inventory/adapter/impl/comp/HotbarAdapter.java +++ b/src/main/java/org/spongepowered/common/inventory/adapter/impl/comp/HotbarAdapter.java @@ -39,7 +39,7 @@ public HotbarAdapter(Fabric fabric, HotbarLens root, Inventory parent) { } @Override - public int getSelectedSlotIndex() { + public int selectedSlotIndex() { return this.hotbarLens.getSelectedSlotIndex(this.inventoryAdapter$getFabric()); } diff --git a/src/main/java/org/spongepowered/common/inventory/adapter/impl/comp/Inventory2DAdapter.java b/src/main/java/org/spongepowered/common/inventory/adapter/impl/comp/Inventory2DAdapter.java index 88d5fbd3d91..1b380a3cd62 100644 --- a/src/main/java/org/spongepowered/common/inventory/adapter/impl/comp/Inventory2DAdapter.java +++ b/src/main/java/org/spongepowered/common/inventory/adapter/impl/comp/Inventory2DAdapter.java @@ -59,7 +59,7 @@ protected SlotLens getSlotLens(Vector2i pos) { } } - public Optional getSlot(Vector2i pos) { + public Optional slot(Vector2i pos) { return BasicInventoryAdapter.forSlot(this.inventoryAdapter$getFabric(), this.getSlotLens(pos), this); } diff --git a/src/main/java/org/spongepowered/common/inventory/adapter/impl/comp/PrimaryPlayerInventoryAdapter.java b/src/main/java/org/spongepowered/common/inventory/adapter/impl/comp/PrimaryPlayerInventoryAdapter.java index 95017261ecf..d8c6d786b31 100644 --- a/src/main/java/org/spongepowered/common/inventory/adapter/impl/comp/PrimaryPlayerInventoryAdapter.java +++ b/src/main/java/org/spongepowered/common/inventory/adapter/impl/comp/PrimaryPlayerInventoryAdapter.java @@ -42,7 +42,7 @@ public PrimaryPlayerInventoryAdapter(Fabric fabric, PrimaryPlayerInventoryLens l } @Override - public Hotbar getHotbar() { + public Hotbar hotbar() { return ((Hotbar) this.root.getHotbar().getAdapter(this.inventoryAdapter$getFabric(), this)); } @@ -52,7 +52,7 @@ public GridInventory asGrid() { } @Override - public GridInventory getStorage() { + public GridInventory storage() { return ((GridInventory) this.root.getGrid().getAdapter(this.inventoryAdapter$getFabric(), this)); } diff --git a/src/main/java/org/spongepowered/common/inventory/adapter/impl/slots/SlotAdapter.java b/src/main/java/org/spongepowered/common/inventory/adapter/impl/slots/SlotAdapter.java index 334ca62a3dc..077218dd3f6 100644 --- a/src/main/java/org/spongepowered/common/inventory/adapter/impl/slots/SlotAdapter.java +++ b/src/main/java/org/spongepowered/common/inventory/adapter/impl/slots/SlotAdapter.java @@ -96,7 +96,7 @@ public InventoryTransactionResult offer(final ItemStack... stacks) { final net.minecraft.world.item.ItemStack nativeStack = ItemStackUtil.toNative(stack); final int maxStackSize = this.slot.getMaxStackSize(this.inventoryAdapter$getFabric()); - int remaining = stack.getQuantity(); + int remaining = stack.quantity(); final net.minecraft.world.item.ItemStack old = this.slot.getStack(this.inventoryAdapter$getFabric()); ItemStackSnapshot oldStack = ItemStackUtil.snapshotOf(old); @@ -114,7 +114,7 @@ public InventoryTransactionResult offer(final ItemStack... stacks) { } result.transaction(new SlotTransaction(this, oldStack, newStack)); - if (remaining == stack.getQuantity()) { + if (remaining == stack.quantity()) { // No items were consumed result.reject(ItemStackUtil.cloneDefensive(nativeStack)); result.type(InventoryTransactionResult.Type.FAILURE); @@ -132,9 +132,9 @@ public boolean canFit(final ItemStack stack) { int maxStackSize = this.inventoryAdapter$getFabric().fabric$getMaxStackSize(); final net.minecraft.world.item.ItemStack old = this.slot.getStack(this.inventoryAdapter$getFabric()); if (old.isEmpty()) { - return maxStackSize >= stack.getQuantity(); + return maxStackSize >= stack.quantity(); } - return ItemStackUtil.compareIgnoreQuantity(old, stack) && maxStackSize - old.getCount() >= stack.getQuantity(); + return ItemStackUtil.compareIgnoreQuantity(old, stack) && maxStackSize - old.getCount() >= stack.quantity(); } @Override @@ -149,7 +149,7 @@ public InventoryTransactionResult set(final ItemStack stack) { SlotTransaction trans = new SlotTransaction(this, oldSnap, ItemStackSnapshot.empty()); return result.transaction(trans).build(); } - int remaining = stack.getQuantity(); + int remaining = stack.quantity(); final int push = Math.min(remaining, this.slot.getMaxStackSize(this.inventoryAdapter$getFabric())); net.minecraft.world.item.ItemStack newStack = ItemStackUtil.cloneDefensiveNative(nativeStack, push); if (this.slot.setStack(this.inventoryAdapter$getFabric(), newStack)) { @@ -193,7 +193,7 @@ public boolean hasChildren() { public boolean contains(final ItemStack stack) { final net.minecraft.world.item.ItemStack slotStack = this.slot.getStack(this.inventoryAdapter$getFabric()); return slotStack.isEmpty() ? ItemStackUtil.toNative(stack).isEmpty() : - ItemStackUtil.compareIgnoreQuantity(slotStack, stack) && slotStack.getCount() >= stack.getQuantity(); + ItemStackUtil.compareIgnoreQuantity(slotStack, stack) && slotStack.getCount() >= stack.quantity(); } @Override diff --git a/src/main/java/org/spongepowered/common/inventory/custom/CustomInventory.java b/src/main/java/org/spongepowered/common/inventory/custom/CustomInventory.java index 319231c8c8f..d5e3ff7db42 100644 --- a/src/main/java/org/spongepowered/common/inventory/custom/CustomInventory.java +++ b/src/main/java/org/spongepowered/common/inventory/custom/CustomInventory.java @@ -108,7 +108,7 @@ public ItemStack getItem(final int index) { for (Inventory inv : this.inventories) { if (inv.capacity() > index - offset) { // This MUST not use Sponge API level because Minecraft relies on returning ItemStack references - return inv.getSlot(index - offset).map(InventoryAdapter.class::cast) + return inv.slot(index - offset).map(InventoryAdapter.class::cast) .map(slot -> slot.inventoryAdapter$getRootLens().getStack(slot.inventoryAdapter$getFabric(), 0)) .orElse(ItemStack.EMPTY); } @@ -126,7 +126,7 @@ public ItemStack removeItem(final int index, final int count) { continue; } InventoryTransactionResult.Poll result = inv.pollFrom(index - offset, count); - return ItemStackUtil.fromSnapshotToNative(result.getPolledItem()); + return ItemStackUtil.fromSnapshotToNative(result.polledItem()); } return ItemStack.EMPTY; } @@ -137,7 +137,7 @@ public ItemStack removeItemNoUpdate(final int index) { for (Inventory inv : this.inventories) { if (inv.capacity() > index - offset) { InventoryTransactionResult.Poll result = inv.pollFrom(index - offset); - return ItemStackUtil.fromSnapshotToNative(result.getPolledItem()); + return ItemStackUtil.fromSnapshotToNative(result.polledItem()); } offset += inv.capacity(); } diff --git a/src/main/java/org/spongepowered/common/inventory/custom/SpongeInventoryMenu.java b/src/main/java/org/spongepowered/common/inventory/custom/SpongeInventoryMenu.java index 7d563cc48c3..3c7023f1bd8 100644 --- a/src/main/java/org/spongepowered/common/inventory/custom/SpongeInventoryMenu.java +++ b/src/main/java/org/spongepowered/common/inventory/custom/SpongeInventoryMenu.java @@ -76,7 +76,7 @@ public SpongeInventoryMenu(ViewableInventory inventory) { } @Override - public ViewableInventory getInventory() { + public ViewableInventory inventory() { return this.inventory; } @@ -197,7 +197,7 @@ public void onClose(Player player, Container container) { if (this.closeHandler != null) { try (CauseStackManager.StackFrame frame = PhaseTracker.getCauseStackManager().pushCauseFrame()) { frame.pushCause(player); - Cause cause = frame.getCurrentCause(); + Cause cause = frame.currentCause(); this.closeHandler.handle(cause, container); } } @@ -207,17 +207,17 @@ public void onClose(Player player, Container container) { public boolean onClick(int slotId, int dragType, ClickType clickTypeIn, Player player, Container container) { try (CauseStackManager.StackFrame frame = PhaseTracker.getCauseStackManager().pushCauseFrame()) { frame.pushCause(player); - Cause cause = frame.getCurrentCause(); + Cause cause = frame.currentCause(); if (clickTypeIn == ClickType.QUICK_CRAFT) { return this.onClickDrag(cause, slotId, dragType, container); } - Optional slot = container.getSlot(slotId); + Optional slot = container.slot(slotId); if (slot.isPresent()) { switch (clickTypeIn) { case SWAP: if (dragType >= 0 && dragType < 9) { - Optional slot2 = container.getSlot(dragType); + Optional slot2 = container.slot(dragType); if (slot2.isPresent() && this.keySwapHandler != null) { return this.keySwapHandler.handle(cause, container, slot.get(), slotId, ClickTypes.KEY_SWAP.get(), slot2.get()); } @@ -287,7 +287,7 @@ private boolean onClickDrag(Cause cause, int slotId, int dragType, Container con } break; case 1: // add drag - Optional slot = container.getSlot(slotId); + Optional slot = container.slot(slotId); if (slot.isPresent() && this.slotClickHandler != null) { switch (dragMode) { case 0: @@ -345,7 +345,7 @@ public boolean onChange(ItemStack newStack, ItemStack oldStack, Container contai } if (this.changeHandler != null) { - Cause cause = PhaseTracker.getCauseStackManager().getCurrentCause(); + Cause cause = PhaseTracker.getCauseStackManager().currentCause(); return this.changeHandler.handle(cause, container, ((org.spongepowered.api.item.inventory.Slot) slot), slotIndex, ItemStackUtil.snapshotOf(oldStack), ItemStackUtil.snapshotOf(newStack)); } diff --git a/src/main/java/org/spongepowered/common/inventory/custom/SpongeViewableInventoryBuilder.java b/src/main/java/org/spongepowered/common/inventory/custom/SpongeViewableInventoryBuilder.java index f5a222f9259..b0d879ba681 100644 --- a/src/main/java/org/spongepowered/common/inventory/custom/SpongeViewableInventoryBuilder.java +++ b/src/main/java/org/spongepowered/common/inventory/custom/SpongeViewableInventoryBuilder.java @@ -128,7 +128,7 @@ private Vector2i indexToPos(int offset) { private Slot newDummySlot() { Container dummyInv = new net.minecraft.world.SimpleContainer(1); - return ((Inventory) dummyInv).getSlot(0).get(); + return ((Inventory) dummyInv).slot(0).get(); } // Slot definition Impl: @@ -384,9 +384,9 @@ public SlotLens getSlotLens(int index) { // create the internal MerchantInventory (3 slots) // create the MerchantResultSlot // used to check if player is customer - // trigger sound (casted to Entity when !getWorld().isClientSide) !!! + // trigger sound (casted to Entity when !world().isClientSide) !!! // reset customer on close - // when closing and !getWorld().isClientSide drop items back into world !!! + // when closing and !world().isClientSide drop items back into world !!! // getOffers Merchant merchant = null; ContainerTypeInfo.of(0, 0, diff --git a/src/main/java/org/spongepowered/common/inventory/lens/impl/comp/ArmorInventoryLens.java b/src/main/java/org/spongepowered/common/inventory/lens/impl/comp/ArmorInventoryLens.java index 52184e31c4a..bfa46c47c58 100644 --- a/src/main/java/org/spongepowered/common/inventory/lens/impl/comp/ArmorInventoryLens.java +++ b/src/main/java/org/spongepowered/common/inventory/lens/impl/comp/ArmorInventoryLens.java @@ -76,7 +76,7 @@ private void initContainer(SlotLensProvider slots) { public Inventory getAdapter(Fabric fabric, Inventory parent) { ArmorEquipable carrier = null; if (parent instanceof CarriedInventory) { - Optional opt = ((CarriedInventory) parent).getCarrier(); + Optional opt = ((CarriedInventory) parent).carrier(); if (opt.isPresent() && opt.get() instanceof ArmorEquipable) { carrier = ((ArmorEquipable) opt.get()); } diff --git a/src/main/java/org/spongepowered/common/inventory/lens/impl/comp/EquipmentInventoryLens.java b/src/main/java/org/spongepowered/common/inventory/lens/impl/comp/EquipmentInventoryLens.java index df1f816a714..89acf207b10 100644 --- a/src/main/java/org/spongepowered/common/inventory/lens/impl/comp/EquipmentInventoryLens.java +++ b/src/main/java/org/spongepowered/common/inventory/lens/impl/comp/EquipmentInventoryLens.java @@ -57,7 +57,7 @@ private void init(Map lenses) { public Inventory getAdapter(Fabric fabric, Inventory parent) { Equipable carrier = null; if (parent instanceof CarriedInventory) { - Optional opt = ((CarriedInventory) parent).getCarrier(); + Optional opt = ((CarriedInventory) parent).carrier(); if (opt.isPresent() && opt.get() instanceof Equipable) { carrier = ((Equipable) opt.get()); } diff --git a/src/main/java/org/spongepowered/common/inventory/lens/impl/minecraft/LargeChestInventoryLens.java b/src/main/java/org/spongepowered/common/inventory/lens/impl/minecraft/LargeChestInventoryLens.java index cb763c40137..d4f58d8810c 100644 --- a/src/main/java/org/spongepowered/common/inventory/lens/impl/minecraft/LargeChestInventoryLens.java +++ b/src/main/java/org/spongepowered/common/inventory/lens/impl/minecraft/LargeChestInventoryLens.java @@ -32,7 +32,7 @@ /** * This class is only used as an adapter when explicitly requested from the API, trough - * {@link Chest#getDoubleChestInventory()} + * {@link Chest#doubleChestInventory()} */ public class LargeChestInventoryLens extends RealLens { diff --git a/src/main/java/org/spongepowered/common/inventory/lens/impl/minecraft/PlayerInventoryLens.java b/src/main/java/org/spongepowered/common/inventory/lens/impl/minecraft/PlayerInventoryLens.java index 480fc0fad64..ac5e0a93180 100644 --- a/src/main/java/org/spongepowered/common/inventory/lens/impl/minecraft/PlayerInventoryLens.java +++ b/src/main/java/org/spongepowered/common/inventory/lens/impl/minecraft/PlayerInventoryLens.java @@ -134,9 +134,9 @@ public Inventory getAdapter(Fabric fabric, Inventory parent) { if (this.isContainer && fabric instanceof AbstractContainerMenu) { // If Lens is for Container extract the PlayerInventory AbstractContainerMenu container = (AbstractContainerMenu) fabric; - Optional carrier = ((CarriedInventory) container).getCarrier(); + Optional carrier = ((CarriedInventory) container).carrier(); if (carrier.isPresent() && carrier.get() instanceof Player) { - return ((Player) carrier.get()).getInventory(); + return ((Player) carrier.get()).inventory(); } } return (Inventory) fabric.fabric$get(this.base).bridge$getAdapter(); diff --git a/src/main/java/org/spongepowered/common/inventory/lens/impl/slot/SlotLensCollection.java b/src/main/java/org/spongepowered/common/inventory/lens/impl/slot/SlotLensCollection.java index d831fb72095..9f9d3b54f19 100644 --- a/src/main/java/org/spongepowered/common/inventory/lens/impl/slot/SlotLensCollection.java +++ b/src/main/java/org/spongepowered/common/inventory/lens/impl/slot/SlotLensCollection.java @@ -39,7 +39,7 @@ public class SlotLensCollection implements SlotLensProvider { public static class Builder { private List, SlotLensProvider>> slotTypes = new ArrayList<>(); - private final SlotLensProvider defaultProvider = (i) -> new BasicSlotLens(i, this.slotTypes.get(i).getFirst()); + private final SlotLensProvider defaultProvider = (i) -> new BasicSlotLens(i, this.slotTypes.get(i).first()); public SlotLensCollection.Builder add() { return this.add(SlotAdapter.class); @@ -75,7 +75,7 @@ public SlotLensCollection build() { final List lenses = new ArrayList<>(); for (int i = 0; i < this.slotTypes.size(); i++) { - lenses.add(this.slotTypes.get(i).getSecond().getSlotLens(i)); + lenses.add(this.slotTypes.get(i).second().getSlotLens(i)); } return new SlotLensCollection(lenses); diff --git a/src/main/java/org/spongepowered/common/inventory/query/SpongeQueryTypes.java b/src/main/java/org/spongepowered/common/inventory/query/SpongeQueryTypes.java index b119eaa426d..67c249830d5 100644 --- a/src/main/java/org/spongepowered/common/inventory/query/SpongeQueryTypes.java +++ b/src/main/java/org/spongepowered/common/inventory/query/SpongeQueryTypes.java @@ -59,14 +59,14 @@ private SpongeQueryTypes() { } private static DefaultedRegistryReference noParamKey(final ResourceKey location) { - return RegistryKey.of(RegistryTypes.QUERY_TYPE, location).asDefaultedReference(() -> Sponge.getGame().registries()); + return RegistryKey.of(RegistryTypes.QUERY_TYPE, location).asDefaultedReference(() -> Sponge.game().registries()); } private static DefaultedRegistryReference> oneParamKey(final ResourceKey location) { - return RegistryKey.of(RegistryTypes.QUERY_TYPE, location).asDefaultedReference(() -> Sponge.getGame().registries()); + return RegistryKey.of(RegistryTypes.QUERY_TYPE, location).asDefaultedReference(() -> Sponge.game().registries()); } private static DefaultedRegistryReference> twoParamKey(final ResourceKey location) { - return RegistryKey.of(RegistryTypes.QUERY_TYPE, location).asDefaultedReference(() -> Sponge.getGame().registries()); + return RegistryKey.of(RegistryTypes.QUERY_TYPE, location).asDefaultedReference(() -> Sponge.game().registries()); } } diff --git a/src/main/java/org/spongepowered/common/inventory/query/type/GridQuery.java b/src/main/java/org/spongepowered/common/inventory/query/type/GridQuery.java index 4148ecac3d5..ddf2ca73523 100644 --- a/src/main/java/org/spongepowered/common/inventory/query/type/GridQuery.java +++ b/src/main/java/org/spongepowered/common/inventory/query/type/GridQuery.java @@ -52,7 +52,7 @@ public Inventory execute(Inventory inventory, InventoryAdapter adapter) { GridInventoryAdapter gridAdapter = (GridInventoryAdapter) adapter; - Vector2i max = gridAdapter.getDimensions(); + Vector2i max = gridAdapter.dimensions(); if (max.getX() < this.offset.getX() + this.size.getX() && max.getY() < this.offset.getY() + this.size.getY()) { // queried grid does not fit inventory return new EmptyInventoryImpl(inventory); diff --git a/src/main/java/org/spongepowered/common/inventory/query/type/ItemTypeQuery.java b/src/main/java/org/spongepowered/common/inventory/query/type/ItemTypeQuery.java index 63df983c10b..9aa0ad2f7ab 100644 --- a/src/main/java/org/spongepowered/common/inventory/query/type/ItemTypeQuery.java +++ b/src/main/java/org/spongepowered/common/inventory/query/type/ItemTypeQuery.java @@ -35,7 +35,7 @@ public ItemTypeQuery(ItemType type) { @Override protected boolean matches(ItemStack itemStack, ItemType arg) { - return itemStack.getType().equals(arg); + return itemStack.type().equals(arg); } } diff --git a/src/main/java/org/spongepowered/common/inventory/query/type/KeyValueMatcherQuery.java b/src/main/java/org/spongepowered/common/inventory/query/type/KeyValueMatcherQuery.java index 1cd22582af0..542c2bc2269 100644 --- a/src/main/java/org/spongepowered/common/inventory/query/type/KeyValueMatcherQuery.java +++ b/src/main/java/org/spongepowered/common/inventory/query/type/KeyValueMatcherQuery.java @@ -129,7 +129,7 @@ private void delegateOffset(final Lens lens, final Map matches) { } public boolean matches(final Lens lens, final Lens parent, final Inventory inventory) { - final Key> key = this.matcher.getKey(); + final Key> key = this.matcher.key(); if (this.matcher.matches(inventory.get(key).orElse(null))) { return true; } diff --git a/src/main/java/org/spongepowered/common/inventory/util/ContainerUtil.java b/src/main/java/org/spongepowered/common/inventory/util/ContainerUtil.java index a4350c002e5..9276695bfce 100644 --- a/src/main/java/org/spongepowered/common/inventory/util/ContainerUtil.java +++ b/src/main/java/org/spongepowered/common/inventory/util/ContainerUtil.java @@ -329,7 +329,7 @@ private static Carrier carrierOrNull(final net.minecraft.world.Container invento return (Carrier) inventory; } if (inventory instanceof CarriedInventory) { - final Optional carrier = ((CarriedInventory) inventory).getCarrier(); + final Optional carrier = ((CarriedInventory) inventory).carrier(); return carrier.orElse(null); } return null; diff --git a/src/main/java/org/spongepowered/common/inventory/util/InventoryUtil.java b/src/main/java/org/spongepowered/common/inventory/util/InventoryUtil.java index 5e500aa6c31..89d64b94c87 100644 --- a/src/main/java/org/spongepowered/common/inventory/util/InventoryUtil.java +++ b/src/main/java/org/spongepowered/common/inventory/util/InventoryUtil.java @@ -81,7 +81,7 @@ public static C toNativeInventory(fina } public static Optional getDoubleChestInventory(final ChestBlockEntity chest) { - final Optional connectedChestOptional = ((Chest) chest).getConnectedChest(); + final Optional connectedChestOptional = ((Chest) chest).connectedChest(); if (!connectedChestOptional.isPresent()) { return Optional.empty(); } @@ -139,7 +139,7 @@ public static PluginContainer getPluginContainer(Object inventory) { } if (inventory instanceof CarriedInventory) { - final Optional carrier = ((CarriedInventory) inventory).getCarrier(); + final Optional carrier = ((CarriedInventory) inventory).carrier(); if (carrier.isPresent()) { inventory = carrier.get(); } @@ -148,21 +148,21 @@ public static PluginContainer getPluginContainer(Object inventory) { final Object base = inventory; if (base instanceof BlockEntity) { - final ResourceKey key = Sponge.getGame().registries().registry(RegistryTypes.BLOCK_ENTITY_TYPE).valueKey(((BlockEntity) base).getType()); - final String pluginId = key.getNamespace(); - container = Sponge.getPluginManager().getPlugin(pluginId) - .orElseThrow(() -> new AssertionError("Missing plugin " + pluginId + " for block " + key.getNamespace() + ":" + key.getValue())); + final ResourceKey key = Sponge.game().registries().registry(RegistryTypes.BLOCK_ENTITY_TYPE).valueKey(((BlockEntity) base).type()); + final String pluginId = key.namespace(); + container = Sponge.pluginManager().plugin(pluginId) + .orElseThrow(() -> new AssertionError("Missing plugin " + pluginId + " for block " + key.namespace() + ":" + key.value())); } else if (base instanceof Entity) { - final ResourceKey key = (ResourceKey) (Object) EntityType.getKey((EntityType) ((Entity) base).getType()); - final String pluginId = key.getNamespace(); - container = Sponge.getPluginManager().getPlugin(pluginId).orElseGet(() -> { + final ResourceKey key = (ResourceKey) (Object) EntityType.getKey((EntityType) ((Entity) base).type()); + final String pluginId = key.namespace(); + container = Sponge.pluginManager().plugin(pluginId).orElseGet(() -> { SpongeCommon.getLogger().debug("Unknown plugin for [{}]", base); return Launch.getInstance().getMinecraftPlugin(); }); } else if (base instanceof SpongeUser) { container = Launch.getInstance().getMinecraftPlugin(); } else { - container = Sponge.getPluginManager().getPlugin(PlatformHooks.INSTANCE + container = Sponge.pluginManager().plugin(PlatformHooks.INSTANCE .getInventoryHooks() .getModIdFromInventory(base.getClass())) .orElseGet(() -> { diff --git a/src/main/java/org/spongepowered/common/ipforward/velocity/VelocityForwardingInfo.java b/src/main/java/org/spongepowered/common/ipforward/velocity/VelocityForwardingInfo.java index 75760de07d7..b3164bf11e9 100644 --- a/src/main/java/org/spongepowered/common/ipforward/velocity/VelocityForwardingInfo.java +++ b/src/main/java/org/spongepowered/common/ipforward/velocity/VelocityForwardingInfo.java @@ -65,7 +65,7 @@ private static class VelocityChannel { private static final RawHandshakeDataChannel CHANNEL; static { - final RawDataChannel rawData = Sponge.getChannelRegistry().getOfType(VelocityChannel.PLAYER_INFO_CHANNEL, RawDataChannel.class); + final RawDataChannel rawData = Sponge.channelRegistry().ofType(VelocityChannel.PLAYER_INFO_CHANNEL, RawDataChannel.class); rawData.setExceptionHandler(ChannelExceptionHandler.logEverything().suppressIfFutureIsPresent(NoResponseException.class)); CHANNEL = rawData.handshake(); } diff --git a/src/main/java/org/spongepowered/common/item/ItemStackSnapshotDuplicateManipulatorUpdater.java b/src/main/java/org/spongepowered/common/item/ItemStackSnapshotDuplicateManipulatorUpdater.java index 193692b9bce..e30116eb15f 100644 --- a/src/main/java/org/spongepowered/common/item/ItemStackSnapshotDuplicateManipulatorUpdater.java +++ b/src/main/java/org/spongepowered/common/item/ItemStackSnapshotDuplicateManipulatorUpdater.java @@ -34,12 +34,12 @@ public final class ItemStackSnapshotDuplicateManipulatorUpdater implements DataContentUpdater { @Override - public int getInputVersion() { + public int inputVersion() { return Constants.Sponge.ItemStackSnapshot.DUPLICATE_MANIPULATOR_DATA_VERSION; } @Override - public int getOutputVersion() { + public int outputVersion() { return Constants.Sponge.ItemStackSnapshot.REMOVED_DUPLICATE_DATA; } @@ -59,7 +59,7 @@ public DataView update(DataView content) { content.set(Constants.Sponge.UNSAFE_NBT, NBTTranslator.INSTANCE.translate(compound)); } } - content.set(Queries.CONTENT_VERSION, this.getOutputVersion()); + content.set(Queries.CONTENT_VERSION, this.outputVersion()); return content; } } diff --git a/src/main/java/org/spongepowered/common/item/SpongeFireworkEffect.java b/src/main/java/org/spongepowered/common/item/SpongeFireworkEffect.java index 4c520eb8cca..37b961a5d79 100644 --- a/src/main/java/org/spongepowered/common/item/SpongeFireworkEffect.java +++ b/src/main/java/org/spongepowered/common/item/SpongeFireworkEffect.java @@ -88,31 +88,31 @@ public boolean hasTrail() { } @Override - public List getColors() { + public List colors() { return this.colors; } @Override - public List getFadeColors() { + public List fadeColors() { return this.fades; } @Override - public FireworkShape getShape() { + public FireworkShape shape() { return this.shape; } @Override - public int getContentVersion() { + public int contentVersion() { return 1; } @Override public DataContainer toContainer() { - final ResourceKey resourceKey = Sponge.getGame().registries().registry(RegistryTypes.FIREWORK_SHAPE).valueKey(this.shape); + final ResourceKey resourceKey = Sponge.game().registries().registry(RegistryTypes.FIREWORK_SHAPE).valueKey(this.shape); return DataContainer.createNew() - .set(Queries.CONTENT_VERSION, this.getContentVersion()) + .set(Queries.CONTENT_VERSION, this.contentVersion()) .set(Constants.Item.Fireworks.FIREWORK_SHAPE, resourceKey) .set(Constants.Item.Fireworks.FIREWORK_COLORS, this.colors) .set(Constants.Item.Fireworks.FIREWORK_FADE_COLORS, this.fades) diff --git a/src/main/java/org/spongepowered/common/item/SpongeFireworkEffectBuilder.java b/src/main/java/org/spongepowered/common/item/SpongeFireworkEffectBuilder.java index 00b0e2f827a..e99791ba08e 100644 --- a/src/main/java/org/spongepowered/common/item/SpongeFireworkEffectBuilder.java +++ b/src/main/java/org/spongepowered/common/item/SpongeFireworkEffectBuilder.java @@ -117,9 +117,9 @@ public FireworkEffect build() { @Override public FireworkEffect.Builder from(final FireworkEffect value) { return this.trail(value.hasTrail()) - .colors(value.getColors()) - .fades(value.getFadeColors()) - .shape(value.getShape()) + .colors(value.colors()) + .fades(value.fadeColors()) + .shape(value.shape()) .flicker(value.flickers()); } diff --git a/src/main/java/org/spongepowered/common/item/SpongeItemStackBuilder.java b/src/main/java/org/spongepowered/common/item/SpongeItemStackBuilder.java index 0ba6698a79b..a3eb3c9c8b6 100644 --- a/src/main/java/org/spongepowered/common/item/SpongeItemStackBuilder.java +++ b/src/main/java/org/spongepowered/common/item/SpongeItemStackBuilder.java @@ -86,8 +86,8 @@ public ItemStack.Builder itemType(final ItemType itemType) { } @Override - public ItemType getCurrentItem() { - return this.type == null ? BlockTypes.AIR.get().getItem().get() : this.type; + public ItemType currentItem() { + return this.type == null ? BlockTypes.AIR.get().item().get() : this.type; } @Override @@ -110,8 +110,8 @@ public ItemStack.Builder add(final Key> key, final V valu public ItemStack.Builder fromItemStack(final ItemStack itemStack) { checkNotNull(itemStack, "Item stack cannot be null"); // Assumes the item stack's values don't need to be validated - this.type = itemStack.getType(); - this.quantity = itemStack.getQuantity(); + this.type = itemStack.type(); + this.quantity = itemStack.quantity(); if ((Object) itemStack instanceof net.minecraft.world.item.ItemStack) { final CompoundTag itemCompound = ((net.minecraft.world.item.ItemStack) (Object) itemStack).getTag(); if (itemCompound != null && !itemCompound.isEmpty()) { @@ -209,8 +209,8 @@ public ItemStack.Builder fromContainer(final DataView container) { @Override public ItemStack.Builder fromSnapshot(final ItemStackSnapshot snapshot) { checkNotNull(snapshot, "The snapshot was null!"); - this.itemType(snapshot.getType()); - this.quantity(snapshot.getQuantity()); + this.itemType(snapshot.type()); + this.quantity(snapshot.quantity()); for (Value.Immutable value : snapshot.getValues()) { this.add(value); @@ -227,9 +227,9 @@ public ItemStack.Builder fromSnapshot(final ItemStackSnapshot snapshot) { public ItemStack.Builder fromBlockSnapshot(final BlockSnapshot blockSnapshot) { checkNotNull(blockSnapshot, "The snapshot was null!"); this.reset(); - final BlockType blockType = blockSnapshot.getState().getType(); + final BlockType blockType = blockSnapshot.state().type(); final ResourceLocation blockTypeKey = Registry.BLOCK.getKey((Block) blockType); - final Optional itemType = blockType.getItem(); + final Optional itemType = blockType.item(); this.itemType(itemType.orElseThrow(() -> new IllegalArgumentException("ItemType not found for block type: " + blockTypeKey))); this.quantity(1); if (blockSnapshot instanceof SpongeBlockSnapshot) { @@ -255,9 +255,9 @@ public ItemStack.Builder fromBlockSnapshot(final BlockSnapshot blockSnapshot) { @Override public ItemStack.Builder fromBlockState(final BlockState blockState) { Objects.requireNonNull(blockState, "blockState"); - final BlockType blockType = blockState.getType(); + final BlockType blockType = blockState.type(); final ResourceLocation blockTypeKey = Registry.BLOCK.getKey((Block) blockType); - this.itemType(blockType.getItem().orElseThrow(() -> new IllegalArgumentException("Missing valid ItemType for BlockType: " + blockTypeKey))); + this.itemType(blockType.item().orElseThrow(() -> new IllegalArgumentException("Missing valid ItemType for BlockType: " + blockTypeKey))); blockState.getValues().forEach(this::add); return this; } diff --git a/src/main/java/org/spongepowered/common/item/SpongeItemStackSnapshot.java b/src/main/java/org/spongepowered/common/item/SpongeItemStackSnapshot.java index 926a5fcbfee..1fdc7b567c8 100644 --- a/src/main/java/org/spongepowered/common/item/SpongeItemStackSnapshot.java +++ b/src/main/java/org/spongepowered/common/item/SpongeItemStackSnapshot.java @@ -81,7 +81,7 @@ public class SpongeItemStackSnapshot implements ItemStackSnapshot { public SpongeItemStackSnapshot(final ItemStack itemStack) { checkNotNull(itemStack); if (ItemStackUtil.toNative(itemStack) == net.minecraft.world.item.ItemStack.EMPTY) { - this.itemType = itemStack.getType(); + this.itemType = itemStack.type(); this.quantity = 0; this.damageValue = 0; this.manipulators = ImmutableList.of(); @@ -91,8 +91,8 @@ public SpongeItemStackSnapshot(final ItemStack itemStack) { this.compound = null; return; } - this.itemType = itemStack.getType(); - this.quantity = itemStack.getQuantity(); + this.itemType = itemStack.type(); + this.quantity = itemStack.quantity(); final ImmutableList.Builder builder = ImmutableList.builder(); final ImmutableSet.Builder> keyBuilder = ImmutableSet.builder(); final ImmutableSet.Builder> valueBuilder = ImmutableSet.builder(); @@ -150,12 +150,12 @@ public SpongeItemStackSnapshot(final ItemType itemType, } @Override - public ItemType getType() { + public ItemType type() { return this.itemType == null ? (ItemType) net.minecraft.world.item.ItemStack.EMPTY.getItem() : this.itemType; } @Override - public int getQuantity() { + public int quantity() { return this.quantity; } @@ -181,15 +181,15 @@ public ItemStack createStack() { } @Override - public int getContentVersion() { + public int contentVersion() { return Constants.Sponge.ItemStackSnapshot.CURRENT_VERSION; } @Override public DataContainer toContainer() { - final ResourceKey resourceKey = Sponge.getGame().registries().registry(RegistryTypes.ITEM_TYPE).valueKey(this.itemType); + final ResourceKey resourceKey = Sponge.game().registries().registry(RegistryTypes.ITEM_TYPE).valueKey(this.itemType); final DataContainer container = DataContainer.createNew() - .set(Queries.CONTENT_VERSION, this.getContentVersion()) + .set(Queries.CONTENT_VERSION, this.contentVersion()) .set(Constants.ItemStack.TYPE, resourceKey) .set(Constants.ItemStack.COUNT, this.quantity) .set(Constants.ItemStack.DAMAGE_VALUE, this.damageValue); @@ -206,7 +206,7 @@ public DataContainer toContainer() { public Optional transform(final Key> key, final Function function) { final ItemStack copy = this.privateStack.copy(); final DataTransactionResult result = copy.transform(key, function); - if (result.getType() != DataTransactionResult.Type.SUCCESS) { + if (result.type() != DataTransactionResult.Type.SUCCESS) { return Optional.empty(); } return Optional.of(copy.createSnapshot()); @@ -216,7 +216,7 @@ public Optional transform(final Key> k public Optional with(final Key> key, final E value) { final ItemStack copy = this.privateStack.copy(); final DataTransactionResult result = copy.offer(key, value); - if (result.getType() != DataTransactionResult.Type.SUCCESS) { + if (result.type() != DataTransactionResult.Type.SUCCESS) { return Optional.empty(); } return Optional.of(copy.createSnapshot()); @@ -224,7 +224,7 @@ public Optional with(final Key> key, f @Override public Optional with(final Value value) { - return this.with((Key>) value.getKey(), (Object) value.get()); + return this.with((Key>) value.key(), (Object) value.get()); } @@ -260,7 +260,7 @@ public Set> getValues() { @Override public String toString() { - final ResourceKey resourceKey = Sponge.getGame().registries().registry(RegistryTypes.ITEM_TYPE).valueKey(this.itemType); + final ResourceKey resourceKey = Sponge.game().registries().registry(RegistryTypes.ITEM_TYPE).valueKey(this.itemType); return MoreObjects.toStringHelper(this) .add("itemType", resourceKey) @@ -301,7 +301,7 @@ public ItemStackSnapshot withRawData(DataView container) throws InvalidDataExcep public Optional without(Key key) { final ItemStack copy = this.privateStack.copy(); final DataTransactionResult result = copy.remove(key); - if (result.getType() != DataTransactionResult.Type.SUCCESS) { + if (result.type() != DataTransactionResult.Type.SUCCESS) { return Optional.empty(); } return Optional.of(copy.createSnapshot()); @@ -343,8 +343,8 @@ public int hashCode() { @Override public HoverEvent asHoverEvent(final UnaryOperator op) { - final ResourceKey resourceKey = Sponge.getGame().registries().registry(RegistryTypes.ITEM_TYPE).valueKey(this.itemType); + final ResourceKey resourceKey = Sponge.game().registries().registry(RegistryTypes.ITEM_TYPE).valueKey(this.itemType); final CompoundTag tag = this.getCompound().orElse(null); - return HoverEvent.showItem(op.apply(HoverEvent.ShowItem.of(resourceKey, this.getQuantity(), SpongeAdventure.asBinaryTagHolder(tag)))); + return HoverEvent.showItem(op.apply(HoverEvent.ShowItem.of(resourceKey, this.quantity(), SpongeAdventure.asBinaryTagHolder(tag)))); } } diff --git a/src/main/java/org/spongepowered/common/item/enchantment/SpongeEnchantment.java b/src/main/java/org/spongepowered/common/item/enchantment/SpongeEnchantment.java index 0bd6cac6ab4..73ab222dc92 100644 --- a/src/main/java/org/spongepowered/common/item/enchantment/SpongeEnchantment.java +++ b/src/main/java/org/spongepowered/common/item/enchantment/SpongeEnchantment.java @@ -44,26 +44,26 @@ public SpongeEnchantment(final EnchantmentType enchantmentType, final int level) } @Override - public EnchantmentType getType() { + public EnchantmentType type() { return this.enchantmentType; } @Override - public int getLevel() { + public int level() { return this.level; } @Override - public int getContentVersion() { + public int contentVersion() { return 1; } @Override public DataContainer toContainer() { - final ResourceKey resourceKey = Sponge.getGame().registries().registry(RegistryTypes.ENCHANTMENT_TYPE).valueKey(this.enchantmentType); + final ResourceKey resourceKey = Sponge.game().registries().registry(RegistryTypes.ENCHANTMENT_TYPE).valueKey(this.enchantmentType); return DataContainer.createNew() - .set(Queries.CONTENT_VERSION, this.getContentVersion()) + .set(Queries.CONTENT_VERSION, this.contentVersion()) .set(Queries.ENCHANTMENT_ID, resourceKey) .set(Queries.LEVEL, this.level); } diff --git a/src/main/java/org/spongepowered/common/item/enchantment/SpongeEnchantmentBuilder.java b/src/main/java/org/spongepowered/common/item/enchantment/SpongeEnchantmentBuilder.java index 4b50d79975b..a2e7158ab1c 100644 --- a/src/main/java/org/spongepowered/common/item/enchantment/SpongeEnchantmentBuilder.java +++ b/src/main/java/org/spongepowered/common/item/enchantment/SpongeEnchantmentBuilder.java @@ -52,8 +52,8 @@ public SpongeEnchantmentBuilder() { @Override public Enchantment.Builder from(final Enchantment value) { checkNotNull(value, "The enchantment to create a builder from cannot be null!"); - this.enchantmentType = value.getType(); - this.level = value.getLevel(); + this.enchantmentType = value.type(); + this.level = value.level(); return this; } diff --git a/src/main/java/org/spongepowered/common/item/enchantment/SpongeRandomEnchantmentListBuilder.java b/src/main/java/org/spongepowered/common/item/enchantment/SpongeRandomEnchantmentListBuilder.java index 8dc8f003c47..fd3a52de70a 100644 --- a/src/main/java/org/spongepowered/common/item/enchantment/SpongeRandomEnchantmentListBuilder.java +++ b/src/main/java/org/spongepowered/common/item/enchantment/SpongeRandomEnchantmentListBuilder.java @@ -141,7 +141,7 @@ public static List fromNative(List list) { public static List toNative(List list) { return list.stream().map(ench -> - new EnchantmentInstance(((net.minecraft.world.item.enchantment.Enchantment) ench.getType()), ench.getLevel()) + new EnchantmentInstance(((net.minecraft.world.item.enchantment.Enchantment) ench.type()), ench.level()) ).collect(Collectors.toList()); } diff --git a/src/main/java/org/spongepowered/common/item/merchant/SpongeTradeOfferBuilder.java b/src/main/java/org/spongepowered/common/item/merchant/SpongeTradeOfferBuilder.java index fba04e5885a..18928d75ed8 100644 --- a/src/main/java/org/spongepowered/common/item/merchant/SpongeTradeOfferBuilder.java +++ b/src/main/java/org/spongepowered/common/item/merchant/SpongeTradeOfferBuilder.java @@ -138,15 +138,15 @@ public TradeOffer build() throws IllegalStateException { public TradeOffer.Builder from(final TradeOffer offer) { checkNotNull(offer, "Trade offer cannot be null"); // Assumes the offer's values don't need to be validated - this.firstItem = offer.getFirstBuyingItem(); - this.secondItem = offer.getSecondBuyingItem().orElse(null); - this.sellingItem = offer.getSellingItem(); - this.useCount = offer.getUses(); - this.maxUses = offer.getMaxUses(); + this.firstItem = offer.firstBuyingItem(); + this.secondItem = offer.secondBuyingItem().orElse(null); + this.sellingItem = offer.sellingItem(); + this.useCount = offer.uses(); + this.maxUses = offer.maxUses(); this.allowsExperience = offer.doesGrantExperience(); - this.merchantExperienceGranted = offer.getExperienceGrantedToMerchant(); - this.priceGrowthMultiplier = offer.getPriceGrowthMultiplier(); - this.demandBonus = offer.getDemandBonus(); + this.merchantExperienceGranted = offer.experienceGrantedToMerchant(); + this.priceGrowthMultiplier = offer.priceGrowthMultiplier(); + this.demandBonus = offer.demandBonus(); return this; } diff --git a/src/main/java/org/spongepowered/common/item/merchant/SpongeTradeOfferGenerator.java b/src/main/java/org/spongepowered/common/item/merchant/SpongeTradeOfferGenerator.java index fe57a7c4105..7d39ca14c90 100644 --- a/src/main/java/org/spongepowered/common/item/merchant/SpongeTradeOfferGenerator.java +++ b/src/main/java/org/spongepowered/common/item/merchant/SpongeTradeOfferGenerator.java @@ -71,11 +71,11 @@ public TradeOffer apply(final Entity merchant, final Random random) { } builder.sellingItem(this.sellingItemGenerator.apply(random)); if (random.nextDouble() < this.experience) { - builder.merchantExperienceGranted(this.grantedExperience.getFlooredAmount(random)); + builder.merchantExperienceGranted(this.grantedExperience.flooredAmount(random)); } - builder.uses(this.baseUses.getFlooredAmount(random)); - builder.maxUses(this.maxUses.getFlooredAmount(random)); + builder.uses(this.baseUses.flooredAmount(random)); + builder.maxUses(this.maxUses.flooredAmount(random)); return builder.build(); } diff --git a/src/main/java/org/spongepowered/common/item/recipe/SpongeRecipeRegistration.java b/src/main/java/org/spongepowered/common/item/recipe/SpongeRecipeRegistration.java index a4216bba05b..99600e508ac 100644 --- a/src/main/java/org/spongepowered/common/item/recipe/SpongeRecipeRegistration.java +++ b/src/main/java/org/spongepowered/common/item/recipe/SpongeRecipeRegistration.java @@ -106,7 +106,7 @@ public ResourceLocation getId() { } @Override - public ResourceKey getKey() { + public ResourceKey key() { return (ResourceKey) (Object) this.key; } @@ -141,7 +141,7 @@ public ResourceLocation getAdvancementId() { } @Override - public int getContentVersion() { + public int contentVersion() { return 1; } diff --git a/src/main/java/org/spongepowered/common/item/recipe/crafting/custom/SpongeSpecialRecipe.java b/src/main/java/org/spongepowered/common/item/recipe/crafting/custom/SpongeSpecialRecipe.java index e8c688bf256..a368994d08d 100644 --- a/src/main/java/org/spongepowered/common/item/recipe/crafting/custom/SpongeSpecialRecipe.java +++ b/src/main/java/org/spongepowered/common/item/recipe/crafting/custom/SpongeSpecialRecipe.java @@ -91,7 +91,7 @@ public NonNullList getRemainingItems(CraftingContainer inv) { public RecipeSerializer getSerializer() { // Fake special crafting serializer // because of Unknown recipe serializer when using our serializer with a vanilla client - // return Registry.RECIPE_SERIALIZER.getOrDefault(this.getId()); + // return Registry.RECIPE_SERIALIZER.getOrDefault(this.id()); return RecipeSerializer.BANNER_DUPLICATE; } } diff --git a/src/main/java/org/spongepowered/common/item/util/SpongeItemStackComparatorFactory.java b/src/main/java/org/spongepowered/common/item/util/SpongeItemStackComparatorFactory.java index 34b37024e44..854672052c2 100644 --- a/src/main/java/org/spongepowered/common/item/util/SpongeItemStackComparatorFactory.java +++ b/src/main/java/org/spongepowered/common/item/util/SpongeItemStackComparatorFactory.java @@ -48,7 +48,7 @@ public SpongeItemStackComparatorFactory(Comparator comparator) { @Override public ItemStackComparators.Factory byType() { - final Comparator comparator = Comparator.comparing(i -> i.getType().key(RegistryTypes.ITEM_TYPE)); + final Comparator comparator = Comparator.comparing(i -> i.type().key(RegistryTypes.ITEM_TYPE)); return new SpongeItemStackComparatorFactory(this.comparator == null ? comparator : this.comparator.thenComparing(comparator)); } @@ -67,7 +67,7 @@ public ItemStackComparators.Factory byDurability() { @Override public ItemStackComparators.Factory bySize() { - final Comparator comparator = Comparator.comparing(ItemStack::getQuantity); + final Comparator comparator = Comparator.comparing(ItemStack::quantity); return new SpongeItemStackComparatorFactory(this.comparator == null ? comparator : this.comparator.thenComparing(this.comparator)); } @@ -105,8 +105,8 @@ public int compare(ItemStack o1, ItemStack o2) { private boolean isIgnored(Set> list, Value.Immutable toCheck) { for (Key> ignore : this.ignored) { - if (toCheck.getKey().equals(ignore)) { - list.removeIf(val -> ignore.equals(val.getKey())); + if (toCheck.key().equals(ignore)) { + list.removeIf(val -> ignore.equals(val.key())); return true; } } diff --git a/src/main/java/org/spongepowered/common/map/SpongeMapStorage.java b/src/main/java/org/spongepowered/common/map/SpongeMapStorage.java index 0f4e39dfd52..fa512db89b2 100644 --- a/src/main/java/org/spongepowered/common/map/SpongeMapStorage.java +++ b/src/main/java/org/spongepowered/common/map/SpongeMapStorage.java @@ -59,10 +59,10 @@ public final class SpongeMapStorage implements MapStorage { @Nullable private BiMap mapIdUUIDIndex = null; @Override - public Collection getAllMapInfos() { + public Collection allMapInfos() { final Set mapInfos = new HashSet<>(); - final ServerWorld spongeWorld = Sponge.getServer().getWorldManager().defaultWorld(); + final ServerWorld spongeWorld = Sponge.server().worldManager().defaultWorld(); final ServerLevel defaultWorld = (ServerLevel) spongeWorld; final int highestId = ((MapIdTrackerBridge)defaultWorld.getDataStorage() @@ -80,7 +80,7 @@ public Collection getAllMapInfos() { } @Override - public Optional getMapInfo(final UUID uuid) { + public Optional mapInfo(final UUID uuid) { MapInfo mapInfo = this.loadedMapUUIDs.get(uuid); if (mapInfo != null) { return Optional.of(mapInfo); @@ -89,7 +89,7 @@ public Optional getMapInfo(final UUID uuid) { if (mapId == null) { return Optional.empty(); } - final ServerWorld spongeWorld = Sponge.getServer().getWorldManager().defaultWorld(); + final ServerWorld spongeWorld = Sponge.server().worldManager().defaultWorld(); final ServerLevel defaultWorld = (ServerLevel) spongeWorld; final MapInfo loadedMapInfo = (MapInfo) defaultWorld.getMapData(Constants.Map.MAP_PREFIX + mapId); return Optional.ofNullable(loadedMapInfo); @@ -97,7 +97,7 @@ public Optional getMapInfo(final UUID uuid) { @Override public Optional createNewMapInfo() { - return SpongeCommonEventFactory.fireCreateMapEvent(PhaseTracker.getCauseStackManager().getCurrentCause()); + return SpongeCommonEventFactory.fireCreateMapEvent(PhaseTracker.getCauseStackManager().currentCause()); } /** @@ -107,7 +107,7 @@ public Optional createNewMapInfo() { * @return UUID of the map. */ public UUID requestUUID(final int id) { - ensureHasMapUUIDIndex(); + this.ensureHasMapUUIDIndex(); UUID uuid = this.mapIdUUIDIndex.get(id); if (uuid == null) { uuid = UUID.randomUUID(); @@ -117,12 +117,12 @@ public UUID requestUUID(final int id) { } public void addMapInfo(final MapInfo mapInfo) { - this.loadedMapUUIDs.put(mapInfo.getUniqueId(), mapInfo); + this.loadedMapUUIDs.put(mapInfo.uniqueId(), mapInfo); } private void ensureHasMapUUIDIndex() { if (this.mapIdUUIDIndex == null) { - this.mapIdUUIDIndex = ((PrimaryLevelDataBridge) Sponge.getServer().getWorldManager().defaultWorld().getProperties()).bridge$getMapUUIDIndex(); + this.mapIdUUIDIndex = ((PrimaryLevelDataBridge) Sponge.server().worldManager().defaultWorld().properties()).bridge$getMapUUIDIndex(); } } } diff --git a/src/main/java/org/spongepowered/common/map/canvas/SpongeEmptyCanvas.java b/src/main/java/org/spongepowered/common/map/canvas/SpongeEmptyCanvas.java index a074c2df65f..a65c0e88aa1 100644 --- a/src/main/java/org/spongepowered/common/map/canvas/SpongeEmptyCanvas.java +++ b/src/main/java/org/spongepowered/common/map/canvas/SpongeEmptyCanvas.java @@ -46,7 +46,7 @@ private SpongeEmptyCanvas() {} public static final SpongeEmptyCanvas INSTANCE = new SpongeEmptyCanvas(); @Override - public MapColor getColor(final int x, final int y) { + public MapColor color(final int x, final int y) { return MapColor.of(MapColorTypes.NONE.get()); } @@ -70,7 +70,7 @@ public Builder toBuilder() { } @Override - public int getContentVersion() { + public int contentVersion() { return 1; } diff --git a/src/main/java/org/spongepowered/common/map/canvas/SpongeMapByteCanvas.java b/src/main/java/org/spongepowered/common/map/canvas/SpongeMapByteCanvas.java index 38a508376bb..c03753bf82e 100644 --- a/src/main/java/org/spongepowered/common/map/canvas/SpongeMapByteCanvas.java +++ b/src/main/java/org/spongepowered/common/map/canvas/SpongeMapByteCanvas.java @@ -52,7 +52,7 @@ public void applyToMapData(final MapItemSavedData mapData) { } @Override - public int getContentVersion() { + public int contentVersion() { return 1; } @@ -62,7 +62,7 @@ public DataContainer toContainer() { } @Override - public MapColor getColor(final int x, final int y) { + public MapColor color(final int x, final int y) { if (!MapUtil.isInCanvasBounds(x)) { throw new IllegalStateException("x (" + x + ") is out of bounds"); } @@ -83,7 +83,7 @@ public Image toImage() { int pos = 0; for (int y = 0; y < Constants.Map.MAP_PIXELS; y++, pos += Constants.Map.MAP_PIXELS) { for (int x = 0; x < Constants.Map.MAP_PIXELS; x++, pos++) { - image.setRGB(x, y, this.getColor(x,y).getColor().getRgb()); + image.setRGB(x, y, this.color(x,y).color().rgb()); } } return image; @@ -95,9 +95,9 @@ public Image toImage(final Color color) { int pos = 0; for (int y = 0; y < Constants.Map.MAP_PIXELS; y++, pos += Constants.Map.MAP_PIXELS) { for (int x = 0; x < Constants.Map.MAP_PIXELS; x++, pos++) { - final MapColor foundColor = this.getColor(x,y); - final Color paintColor = foundColor.getType() == MapColorTypes.NONE.get() ? color - : foundColor.getColor().asJavaColor(); + final MapColor foundColor = this.color(x,y); + final Color paintColor = foundColor.type() == MapColorTypes.NONE.get() ? color + : foundColor.color().asJavaColor(); image.setRGB(x, y, paintColor.getRGB()); } } diff --git a/src/main/java/org/spongepowered/common/map/canvas/SpongeMapCanvasBuilder.java b/src/main/java/org/spongepowered/common/map/canvas/SpongeMapCanvasBuilder.java index 8b281f658a2..2d2f2c56c93 100644 --- a/src/main/java/org/spongepowered/common/map/canvas/SpongeMapCanvasBuilder.java +++ b/src/main/java/org/spongepowered/common/map/canvas/SpongeMapCanvasBuilder.java @@ -28,8 +28,6 @@ import org.spongepowered.api.data.persistence.DataView; import org.spongepowered.api.map.MapCanvas; import org.spongepowered.api.map.color.MapColor; -import org.spongepowered.api.map.color.MapColorType; -import org.spongepowered.api.map.color.MapShade; import org.spongepowered.api.registry.RegistryTypes; import org.spongepowered.common.util.MapUtil; import org.spongepowered.common.map.color.SpongeMapColor; @@ -126,10 +124,10 @@ public MapCanvas.Builder fromImage(final Image image) { final int[] pixels = ((DataBufferInt) bufferedImage.getRaster().getDataBuffer()).getData(); // Get the color palette we are working with final Map palette = new HashMap<>(); - Sponge.getGame().registries().registry(RegistryTypes.MAP_COLOR_TYPE).stream().forEach(color -> { - Sponge.getGame().registries().registry(RegistryTypes.MAP_SHADE).stream().forEach(shade -> { + Sponge.game().registries().registry(RegistryTypes.MAP_COLOR_TYPE).stream().forEach(color -> { + Sponge.game().registries().registry(RegistryTypes.MAP_SHADE).stream().forEach(shade -> { SpongeMapColor spongeMapColor = new SpongeMapColor(color, shade); - palette.put(spongeMapColor.getColor().getRgb(), spongeMapColor); + palette.put(spongeMapColor.color().rgb(), spongeMapColor); }); }); final byte[] canvas = getCanvas(); diff --git a/src/main/java/org/spongepowered/common/map/color/SpongeMapColor.java b/src/main/java/org/spongepowered/common/map/color/SpongeMapColor.java index 061f8a694ed..331d4cdcc1d 100644 --- a/src/main/java/org/spongepowered/common/map/color/SpongeMapColor.java +++ b/src/main/java/org/spongepowered/common/map/color/SpongeMapColor.java @@ -49,19 +49,19 @@ public byte getMCColor() { } @Override - public MapShade getShade() { + public MapShade shade() { return this.shade; } @Override - public MapColorType getType() {return this.type;} + public MapColorType type() {return this.type;} @Override - public Color getColor() { - Color color = getType().getColor(); - int r = addShade(color.getRed()); - int g = addShade(color.getGreen()); - int b = addShade(color.getBlue()); + public Color color() { + Color color = type().color(); + int r = addShade(color.red()); + int g = addShade(color.green()); + int b = addShade(color.blue()); return Color.ofRgb(r,g,b); } @@ -70,7 +70,7 @@ private int addShade(int color) { } @Override - public int getContentVersion() { + public int contentVersion() { return 1; } diff --git a/src/main/java/org/spongepowered/common/map/color/SpongeMapColorBuilder.java b/src/main/java/org/spongepowered/common/map/color/SpongeMapColorBuilder.java index e5e0c1c311e..29722da7375 100644 --- a/src/main/java/org/spongepowered/common/map/color/SpongeMapColorBuilder.java +++ b/src/main/java/org/spongepowered/common/map/color/SpongeMapColorBuilder.java @@ -25,14 +25,12 @@ package org.spongepowered.common.map.color; import com.google.common.base.Preconditions; -import net.minecraft.core.MappedRegistry; import org.spongepowered.api.data.persistence.DataView; import org.spongepowered.api.data.persistence.InvalidDataException; import org.spongepowered.api.map.color.MapColor; import org.spongepowered.api.map.color.MapColorType; import org.spongepowered.api.map.color.MapShade; import org.spongepowered.api.map.color.MapShades; -import org.spongepowered.api.registry.RegistryTypes; import org.spongepowered.common.util.Constants; import org.spongepowered.common.util.MapUtil; @@ -99,8 +97,8 @@ public MapColor build() throws IllegalStateException { @Override public MapColor.Builder from(MapColor value) { SpongeMapColor mapColorBridge = (SpongeMapColor)value; - this.color = mapColorBridge.getType(); - this.shade = mapColorBridge.getShade(); + this.color = mapColorBridge.type(); + this.shade = mapColorBridge.shade(); return this; } diff --git a/src/main/java/org/spongepowered/common/map/color/SpongeMapColorType.java b/src/main/java/org/spongepowered/common/map/color/SpongeMapColorType.java index 524aa38ee22..5978882eb47 100644 --- a/src/main/java/org/spongepowered/common/map/color/SpongeMapColorType.java +++ b/src/main/java/org/spongepowered/common/map/color/SpongeMapColorType.java @@ -43,7 +43,7 @@ public int getColorIndex() { } @Override - public Color getColor() { + public Color color() { return Color.of(new java.awt.Color(this.materialColor.col)); } } diff --git a/src/main/java/org/spongepowered/common/map/decoration/SpongeMapDecorationBuilder.java b/src/main/java/org/spongepowered/common/map/decoration/SpongeMapDecorationBuilder.java index f4145058600..44684650075 100644 --- a/src/main/java/org/spongepowered/common/map/decoration/SpongeMapDecorationBuilder.java +++ b/src/main/java/org/spongepowered/common/map/decoration/SpongeMapDecorationBuilder.java @@ -71,10 +71,10 @@ public MapDecoration.Builder reset() { @Override public MapDecoration.Builder from(MapDecoration value) { Preconditions.checkNotNull(value, "MapDecoration cannot be null"); - this.type = value.getType(); - this.x = value.getPosition().getX(); - this.y = value.getPosition().getY(); - this.rot = value.getRotation(); + this.type = value.type(); + this.x = value.position().getX(); + this.y = value.position().getY(); + this.rot = value.rotation(); return this; } diff --git a/src/main/java/org/spongepowered/common/network/channel/PacketSender.java b/src/main/java/org/spongepowered/common/network/channel/PacketSender.java index 51059f525d8..94b20279121 100644 --- a/src/main/java/org/spongepowered/common/network/channel/PacketSender.java +++ b/src/main/java/org/spongepowered/common/network/channel/PacketSender.java @@ -50,14 +50,14 @@ public static void sendTo(final EngineConnection connection, final Packet pac final Connection networkManager = ((ConnectionHolderBridge) connection).bridge$getConnection(); GenericFutureListener> asyncListener = null; if (listener != null) { - final EngineConnectionSide side = connection.getSide(); + final EngineConnectionSide side = connection.side(); // Complete the netty callback on the sync thread asyncListener = future -> { final BlockableEventLoop executor; if (side == EngineConnectionSide.CLIENT) { - executor = (BlockableEventLoop) Sponge.getClient(); + executor = (BlockableEventLoop) Sponge.client(); } else { - executor = (BlockableEventLoop) Sponge.getServer(); + executor = (BlockableEventLoop) Sponge.server(); } executor.execute(() -> listener.accept(future)); }; diff --git a/src/main/java/org/spongepowered/common/network/channel/SpongeChannel.java b/src/main/java/org/spongepowered/common/network/channel/SpongeChannel.java index e685f15d3a4..093744ae7dc 100644 --- a/src/main/java/org/spongepowered/common/network/channel/SpongeChannel.java +++ b/src/main/java/org/spongepowered/common/network/channel/SpongeChannel.java @@ -65,7 +65,7 @@ public SpongeChannel(final int type, final ResourceKey key, final SpongeChannelR this.type = type; this.key = key; this.registry = registry; - this.logger = LogManager.getLogger("channel/" + key.getFormatted()); + this.logger = LogManager.getLogger("channel/" + key.formatted()); } public int getType() { @@ -77,12 +77,12 @@ public Logger getLogger() { } @Override - public SpongeChannelRegistry getRegistry() { + public SpongeChannelRegistry registry() { return this.registry; } @Override - public ResourceKey getKey() { + public ResourceKey key() { return this.key; } @@ -100,8 +100,8 @@ public String toString() { } public boolean checkSupported(final EngineConnection connection, final CompletableFuture future) { - if (!ConnectionUtil.getRegisteredChannels(connection).contains(this.getKey())) { - this.handleException(connection, new ChannelNotSupportedException("The channel \"" + this.getKey() + "\" isn't supported."), future); + if (!ConnectionUtil.getRegisteredChannels(connection).contains(this.key())) { + this.handleException(connection, new ChannelNotSupportedException("The channel \"" + this.key() + "\" isn't supported."), future); return false; } return true; @@ -137,7 +137,7 @@ public void handleException(final EngineConnection connection, final Throwable c try { this.exceptionHandler.handle(connection, this, ChannelExceptionUtil.of(cause), future); } catch (final Throwable ex) { - SpongeCommon.getLogger().error("The exception handler of the channel " + this.getKey() + " failed to handle an exception.", ex); + SpongeCommon.getLogger().error("The exception handler of the channel " + this.key() + " failed to handle an exception.", ex); } } diff --git a/src/main/java/org/spongepowered/common/network/channel/SpongeChannelExceptionHandlerFactory.java b/src/main/java/org/spongepowered/common/network/channel/SpongeChannelExceptionHandlerFactory.java index c7002d1409a..cbf708f712c 100644 --- a/src/main/java/org/spongepowered/common/network/channel/SpongeChannelExceptionHandlerFactory.java +++ b/src/main/java/org/spongepowered/common/network/channel/SpongeChannelExceptionHandlerFactory.java @@ -33,7 +33,7 @@ public final class SpongeChannelExceptionHandlerFactory implements ChannelExcept public SpongeChannelExceptionHandlerFactory() { this.logEverything = (connection, channel, exception, future) -> { - ((SpongeChannel) channel).getLogger().error("An error occurred on the {} channel.", channel.getKey(), exception); + ((SpongeChannel) channel).getLogger().error("An error occurred on the {} channel.", channel.key(), exception); if (future != null) { future.completeExceptionally(exception); } diff --git a/src/main/java/org/spongepowered/common/network/channel/SpongeChannelRegistry.java b/src/main/java/org/spongepowered/common/network/channel/SpongeChannelRegistry.java index 495065e4845..f36349030ee 100644 --- a/src/main/java/org/spongepowered/common/network/channel/SpongeChannelRegistry.java +++ b/src/main/java/org/spongepowered/common/network/channel/SpongeChannelRegistry.java @@ -111,7 +111,7 @@ public C createChannel(final ResourceKey channelKey, final C if (tuple == null) { throw new IllegalArgumentException("Unsupported channel type: " + channelType); } - final SpongeChannel channel = tuple.getSecond().create(tuple.getFirst(), channelKey, this); + final SpongeChannel channel = tuple.second().create(tuple.first(), channelKey, this); this.channels.put(channelKey, channel); return (C) channel; } @@ -123,7 +123,7 @@ public Optional get(final ResourceKey channelKey) { } @Override - public C getOfType(final ResourceKey channelKey, final Class channelType) { + public C ofType(final ResourceKey channelKey, final Class channelType) { Objects.requireNonNull(channelKey, "channelKey"); Objects.requireNonNull(channelType, "channelType"); final Channel binding = this.channels.get(channelKey); @@ -138,7 +138,7 @@ public C getOfType(final ResourceKey channelKey, final Class } @Override - public Collection getChannels() { + public Collection channels() { return ImmutableList.copyOf(this.channels.values()); } @@ -170,16 +170,16 @@ public C register(ResourceKey channelKey, Class channelTy } @Override - public Game getGame() { + public Game game() { return SpongeCommon.getGame(); } @Override - public Cause getCause() { + public Cause cause() { return cause; } }; - Sponge.getEventManager().post(event); + Sponge.eventManager().post(event); } public CompletableFuture requestClientType(final EngineConnection connection) { @@ -238,7 +238,7 @@ public CompletableFuture sendLoginChannelRegistry(final EngineConnection c public void sendChannelRegistrations(final EngineConnection connection) { final ChannelBuf payload = RegisterChannelUtil.encodePayload(this.channels.keySet()); - final Packet mcPacket = PacketUtil.createPlayPayload(Constants.Channels.REGISTER_KEY, payload, connection.getSide()); + final Packet mcPacket = PacketUtil.createPlayPayload(Constants.Channels.REGISTER_KEY, payload, connection.side()); PacketSender.sendTo(connection, mcPacket); } @@ -255,7 +255,7 @@ private ChannelBuf encodeChannelRegistry() { final ChannelBuf buf = this.bufferAllocator.buffer(); buf.writeVarInt(channels.size()); for (final SpongeChannel channel : channels) { - buf.writeString(channel.getKey().getFormatted()); + buf.writeString(channel.key().formatted()); // The type is included to provide extra information for e.g. proxies // who want to improve sponge support // Not used by sponge itself @@ -352,7 +352,7 @@ public boolean handleLoginRequestPayload(final EngineConnection connection, fina private boolean handleLoginRequestPayload(final EngineConnection connection, final ResourceKey channelKey, final int transactionId, final ChannelBuf payload) { if (channelKey.equals(Constants.Channels.SPONGE_CLIENT_TYPE)) { - final ClientType clientType = ((MinecraftBridge) Sponge.getClient()).bridge$getClientType(); + final ClientType clientType = ((MinecraftBridge) Sponge.client()).bridge$getClientType(); final ChannelBuf responsePayload = this.bufferAllocator.buffer(); responsePayload.writeString(clientType.getName()); final Packet mcPacket = PacketUtil.createLoginPayloadResponse(responsePayload, transactionId); diff --git a/src/main/java/org/spongepowered/common/network/channel/packet/AbstractPacketChannel.java b/src/main/java/org/spongepowered/common/network/channel/packet/AbstractPacketChannel.java index 6d3592523e8..6344c68fa86 100644 --- a/src/main/java/org/spongepowered/common/network/channel/packet/AbstractPacketChannel.java +++ b/src/main/java/org/spongepowered/common/network/channel/packet/AbstractPacketChannel.java @@ -63,7 +63,7 @@ public AbstractPacketChannel(final int type, final ResourceKey key, final Sponge } @Override - public Collection> getBindings() { + public Collection> bindings() { return ImmutableList.copyOf(this.byOpcode.values()); } @@ -85,7 +85,7 @@ static final class TransactionData

, R extends Packet> } protected void encodePayload(final ChannelBuf payload, final Packet packet) { - final ChannelBuf packetContent = this.getRegistry().getBufferAllocator().buffer(); + final ChannelBuf packetContent = this.registry().getBufferAllocator().buffer(); try { this.encodePayloadUnsafe(packetContent, packet); ChannelBuffers.write(payload, packetContent); @@ -120,7 +120,7 @@ protected

P decodePayload(final Supplier

packetSupplier, f protected SpongePacketBinding requireBinding(final int opcode) { final SpongePacketBinding binding = (SpongePacketBinding) this.byOpcode.get(opcode); if (binding == null) { - throw new ChannelException("Unknown opcode " + opcode + " for channel " + this.getKey()); + throw new ChannelException("Unknown opcode " + opcode + " for channel " + this.key()); } return binding; } @@ -128,7 +128,7 @@ protected SpongePacketBinding requireBinding(final int opcode) { protected SpongePacketBinding requireBinding(final Class packet) { final SpongePacketBinding binding = (SpongePacketBinding) this.byType.get(packet); if (binding == null) { - throw new ChannelException("Unknown packet type " + packet + " for channel " + this.getKey()); + throw new ChannelException("Unknown packet type " + packet + " for channel " + this.key()); } return binding; } @@ -193,20 +193,20 @@ private void checkPossibleRegistration(final Class packetClass, final int opc } @Override - public

, R extends Packet> Optional> getTransactionalBinding( + public

, R extends Packet> Optional> transactionalBinding( final Class

requestPacketType) { Objects.requireNonNull(requestPacketType, "requestPacketType"); return Optional.ofNullable((TransactionalPacketBinding) this.byType.get(requestPacketType)); } @Override - public Optional> getBinding(final Class packetClass) { + public Optional> binding(final Class packetClass) { Objects.requireNonNull(packetClass, "packetClass"); return Optional.ofNullable((PacketBinding) this.byType.get(packetClass)); } @Override - public Optional> getBinding(final int opcode) { + public Optional> binding(final int opcode) { return Optional.ofNullable(this.byOpcode.get(opcode)); } diff --git a/src/main/java/org/spongepowered/common/network/channel/packet/SpongeBasicPacketChannel.java b/src/main/java/org/spongepowered/common/network/channel/packet/SpongeBasicPacketChannel.java index 8baf1ab3e2b..b9546ef9255 100644 --- a/src/main/java/org/spongepowered/common/network/channel/packet/SpongeBasicPacketChannel.java +++ b/src/main/java/org/spongepowered/common/network/channel/packet/SpongeBasicPacketChannel.java @@ -76,7 +76,7 @@ private

, R extends Packet> void sendRequestTo(final final ChannelBuf payload; try { - payload = SpongeBasicPacketChannel.this.encodeLoginPayload(binding.getOpcode(), request); + payload = SpongeBasicPacketChannel.this.encodeLoginPayload(binding.opcode(), request); } catch (final Throwable ex) { SpongeBasicPacketChannel.this.handleException(connection, ex, future); return; @@ -106,7 +106,7 @@ private CompletableFuture sendNormalTo(final EngineConnection connection, final ChannelBuf payload; try { - payload = SpongeBasicPacketChannel.this.encodePayload(binding.getOpcode(), packet); + payload = SpongeBasicPacketChannel.this.encodePayload(binding.opcode(), packet); } catch (final Throwable ex) { SpongeBasicPacketChannel.this.handleException(connection, ChannelExceptionUtil.of(ex), future); return future; @@ -115,7 +115,7 @@ private CompletableFuture sendNormalTo(final EngineConnection connection, final TransactionStore transactionStore = ConnectionUtil.getTransactionStore(connection); final int transactionId = transactionStore.nextId(); - final net.minecraft.network.protocol.Packet mcPacket = PacketUtil.createLoginPayloadRequest(SpongeBasicPacketChannel.this.getKey(), payload, transactionId); + final net.minecraft.network.protocol.Packet mcPacket = PacketUtil.createLoginPayloadRequest(SpongeBasicPacketChannel.this.key(), payload, transactionId); PacketSender.sendTo(connection, mcPacket, future); return future; } @@ -154,7 +154,7 @@ public CompletableFuture sendToServer(final Packet packet) { @Override public boolean isSupportedBy(final EngineConnection connection) { - return ConnectionUtil.getRegisteredChannels(connection).contains(SpongeBasicPacketChannel.this.getKey()); + return ConnectionUtil.getRegisteredChannels(connection).contains(SpongeBasicPacketChannel.this.key()); } @Override @@ -170,13 +170,13 @@ public CompletableFuture sendTo(final EngineConnection connection, final P final ChannelBuf payload; try { - payload = SpongeBasicPacketChannel.this.encodePayload(binding.getOpcode(), packet); + payload = SpongeBasicPacketChannel.this.encodePayload(binding.opcode(), packet); } catch (final Throwable ex) { SpongeBasicPacketChannel.this.handleException(connection, ex, future); return future; } - final net.minecraft.network.protocol.Packet mcPacket = PacketUtil.createPlayPayload(SpongeBasicPacketChannel.this.getKey(), payload, connection.getSide()); + final net.minecraft.network.protocol.Packet mcPacket = PacketUtil.createPlayPayload(SpongeBasicPacketChannel.this.key(), payload, connection.side()); PacketSender.sendTo(connection, mcPacket, future); return future; } @@ -197,7 +197,7 @@ public PacketDispatcher play() { } private ChannelBuf encodePayload(final int opcode, final Packet packet) { - final ChannelBuf payload = this.getRegistry().getBufferAllocator().buffer(); + final ChannelBuf payload = this.registry().getBufferAllocator().buffer(); payload.writeByte((byte) opcode); this.encodePayload(payload, packet); return payload; @@ -205,11 +205,11 @@ private ChannelBuf encodePayload(final int opcode, final Packet packet) { // This only exists for forge compatibility private ChannelBuf encodeLoginPayload(final int opcode, final Packet packet) { - final ChannelBuf loginPayload = this.getRegistry().getBufferAllocator().buffer(); - final ChannelBuf payload = this.getRegistry().getBufferAllocator().buffer(); + final ChannelBuf loginPayload = this.registry().getBufferAllocator().buffer(); + final ChannelBuf payload = this.registry().getBufferAllocator().buffer(); try { this.encodePayloadUnsafe(payload, packet); - loginPayload.writeString(this.getKey().getFormatted()); + loginPayload.writeString(this.key().formatted()); loginPayload.writeVarInt(payload.available() + 1); loginPayload.writeByte((byte) opcode); ChannelBuffers.write(loginPayload, payload); @@ -268,7 +268,7 @@ protected void fail0(final ChannelException exception) { @Override protected void success0(final Packet response) { try { - final ChannelBuf responsePayload = SpongeBasicPacketChannel.this.encodeLoginPayload(transactionalBinding.getOpcode(), response); + final ChannelBuf responsePayload = SpongeBasicPacketChannel.this.encodeLoginPayload(transactionalBinding.opcode(), response); final net.minecraft.network.protocol.Packet mcPacket = PacketUtil.createLoginPayloadResponse(responsePayload, transactionId); PacketSender.sendTo(connection, mcPacket); } catch (final Throwable ex) { diff --git a/src/main/java/org/spongepowered/common/network/channel/packet/SpongeFixedTransactionalPacketBinding.java b/src/main/java/org/spongepowered/common/network/channel/packet/SpongeFixedTransactionalPacketBinding.java index 785c08e35ab..fdf6c9a7058 100644 --- a/src/main/java/org/spongepowered/common/network/channel/packet/SpongeFixedTransactionalPacketBinding.java +++ b/src/main/java/org/spongepowered/common/network/channel/packet/SpongeFixedTransactionalPacketBinding.java @@ -45,7 +45,7 @@ public SpongeFixedTransactionalPacketBinding(final int opcode, final Class

re } @Override - public Class getResponsePacketType() { + public Class responsePacketType() { return this.responsePacketType; } @@ -56,8 +56,8 @@ public Supplier getResponsePacketConstructor() { @Override public String toString() { return MoreObjects.toStringHelper(this) - .add("opcode", this.getOpcode()) - .add("requestPacketType", this.getPacketType()) + .add("opcode", this.opcode()) + .add("requestPacketType", this.packetType()) .add("responsePacketType", this.responsePacketType) .toString(); } diff --git a/src/main/java/org/spongepowered/common/network/channel/packet/SpongePacketBinding.java b/src/main/java/org/spongepowered/common/network/channel/packet/SpongePacketBinding.java index aa61081c5b5..e4eebb92a38 100644 --- a/src/main/java/org/spongepowered/common/network/channel/packet/SpongePacketBinding.java +++ b/src/main/java/org/spongepowered/common/network/channel/packet/SpongePacketBinding.java @@ -44,12 +44,12 @@ public SpongePacketBinding(final int opcode, final Class

packetType) { } @Override - public int getOpcode() { + public int opcode() { return this.opcode; } @Override - public Class

getPacketType() { + public Class

packetType() { return this.packetType; } diff --git a/src/main/java/org/spongepowered/common/network/channel/packet/SpongePacketChannel.java b/src/main/java/org/spongepowered/common/network/channel/packet/SpongePacketChannel.java index a5b0f5e236f..37a93d6e012 100644 --- a/src/main/java/org/spongepowered/common/network/channel/packet/SpongePacketChannel.java +++ b/src/main/java/org/spongepowered/common/network/channel/packet/SpongePacketChannel.java @@ -101,25 +101,25 @@ private

, R extends Packet> void sendRequestPacketTo( final int transactionId = transactionStore.nextId(); final boolean isLoginPhase = ConnectionUtil.isLoginPhase(connection); - final EngineConnectionSide side = connection.getSide(); + final EngineConnectionSide side = connection.side(); - final ChannelBuf payload = this.getRegistry().getBufferAllocator().buffer(); + final ChannelBuf payload = this.registry().getBufferAllocator().buffer(); final Supplier> mcPacketSupplier; if (isLoginPhase) { if (side == EngineConnectionSide.CLIENT) { - payload.writeString(this.getKey().getFormatted()); + payload.writeString(this.key().formatted()); payload.writeVarLong(SpongePacketChannel.packTypeAndValue(SpongePacketChannel.TYPE_REQUEST, transactionId)); - payload.writeVarInt(binding.getOpcode()); + payload.writeVarInt(binding.opcode()); mcPacketSupplier = () -> PacketUtil.createLoginPayloadResponse(payload, Constants.Channels.LOGIN_PAYLOAD_TRANSACTION_ID); } else { - payload.writeVarLong(SpongePacketChannel.packTypeAndValue(SpongePacketChannel.TYPE_REQUEST, binding.getOpcode())); - mcPacketSupplier = () -> PacketUtil.createLoginPayloadRequest(this.getKey(), payload, transactionId); + payload.writeVarLong(SpongePacketChannel.packTypeAndValue(SpongePacketChannel.TYPE_REQUEST, binding.opcode())); + mcPacketSupplier = () -> PacketUtil.createLoginPayloadRequest(this.key(), payload, transactionId); } } else { payload.writeVarLong(SpongePacketChannel.packTypeAndValue(SpongePacketChannel.TYPE_REQUEST, transactionId)); - payload.writeVarInt(binding.getOpcode()); - mcPacketSupplier = () -> PacketUtil.createPlayPayload(this.getKey(), payload, side); + payload.writeVarInt(binding.opcode()); + mcPacketSupplier = () -> PacketUtil.createPlayPayload(this.key(), payload, side); } try { @@ -152,9 +152,9 @@ private

, R extends Packet> void sendRequestPacketTo( private

, R extends Packet> void sendResponsePacketTo(final EngineConnection connection, final @Nullable SpongeTransactionalPacketBinding requestBinding, final @Nullable R packet, final int transactionId) { final boolean isLoginPhase = ConnectionUtil.isLoginPhase(connection); - final EngineConnectionSide side = connection.getSide(); + final EngineConnectionSide side = connection.side(); - final ChannelBuf payload = this.getRegistry().getBufferAllocator().buffer(); + final ChannelBuf payload = this.registry().getBufferAllocator().buffer(); final Supplier> mcPacketSupplier; if (packet == null || requestBinding instanceof SpongeFixedTransactionalPacketBinding) { @@ -166,15 +166,15 @@ private

, R extends Packet> void sendResponsePacketTo } else { payload.writeVarLong(SpongePacketChannel.packTypeAndValue(type, transactionId)); mcPacketSupplier = () -> PacketUtil.createLoginPayloadRequest( - this.getKey(), payload, Constants.Channels.LOGIN_PAYLOAD_TRANSACTION_ID); + this.key(), payload, Constants.Channels.LOGIN_PAYLOAD_TRANSACTION_ID); } } else { payload.writeVarLong(SpongePacketChannel.packTypeAndValue(type, transactionId)); - mcPacketSupplier = () -> PacketUtil.createPlayPayload(this.getKey(), payload, side); + mcPacketSupplier = () -> PacketUtil.createPlayPayload(this.key(), payload, side); } } else { // Dynamic opcode - final int opcode = this.requireBinding(packet.getClass()).getOpcode(); + final int opcode = this.requireBinding(packet.getClass()).opcode(); if (isLoginPhase) { if (side == EngineConnectionSide.CLIENT) { payload.writeVarLong(SpongePacketChannel.packTypeAndValue(SpongePacketChannel.TYPE_DYNAMIC_RESPONSE, opcode)); @@ -183,12 +183,12 @@ private

, R extends Packet> void sendResponsePacketTo payload.writeVarLong(SpongePacketChannel.packTypeAndValue(SpongePacketChannel.TYPE_DYNAMIC_RESPONSE, transactionId)); payload.writeVarInt(opcode); mcPacketSupplier = () -> PacketUtil.createLoginPayloadRequest( - this.getKey(), payload, Constants.Channels.LOGIN_PAYLOAD_TRANSACTION_ID); + this.key(), payload, Constants.Channels.LOGIN_PAYLOAD_TRANSACTION_ID); } } else { payload.writeVarLong(SpongePacketChannel.packTypeAndValue(SpongePacketChannel.TYPE_DYNAMIC_RESPONSE, transactionId)); payload.writeVarInt(opcode); - mcPacketSupplier = () -> PacketUtil.createPlayPayload(this.getKey(), payload, side); + mcPacketSupplier = () -> PacketUtil.createPlayPayload(this.key(), payload, side); } } @@ -208,24 +208,24 @@ private

void sendNormalPacketTo(final EngineConnection connec (SpongePacketBinding) this.requireBinding(packet.getClass()); final boolean isLoginPhase = ConnectionUtil.isLoginPhase(connection); - final EngineConnectionSide side = connection.getSide(); + final EngineConnectionSide side = connection.side(); - final ChannelBuf payload = this.getRegistry().getBufferAllocator().buffer(); + final ChannelBuf payload = this.registry().getBufferAllocator().buffer(); final Supplier> mcPacketSupplier; if (isLoginPhase) { if (side == EngineConnectionSide.CLIENT) { - payload.writeString(this.getKey().getFormatted()); - payload.writeVarLong(SpongePacketChannel.packTypeAndValue(SpongePacketChannel.TYPE_NORMAL, binding.getOpcode())); + payload.writeString(this.key().formatted()); + payload.writeVarLong(SpongePacketChannel.packTypeAndValue(SpongePacketChannel.TYPE_NORMAL, binding.opcode())); mcPacketSupplier = () -> PacketUtil.createLoginPayloadResponse(payload, Constants.Channels.LOGIN_PAYLOAD_TRANSACTION_ID); } else { - payload.writeVarLong(SpongePacketChannel.packTypeAndValue(SpongePacketChannel.TYPE_NORMAL, binding.getOpcode())); + payload.writeVarLong(SpongePacketChannel.packTypeAndValue(SpongePacketChannel.TYPE_NORMAL, binding.opcode())); final int transactionId = ConnectionUtil.getTransactionStore(connection).nextId(); - mcPacketSupplier = () -> PacketUtil.createLoginPayloadRequest(this.getKey(), payload, transactionId); + mcPacketSupplier = () -> PacketUtil.createLoginPayloadRequest(this.key(), payload, transactionId); } } else { - payload.writeVarLong(SpongePacketChannel.packTypeAndValue(SpongePacketChannel.TYPE_NORMAL, binding.getOpcode())); - mcPacketSupplier = () -> PacketUtil.createPlayPayload(this.getKey(), payload, side); + payload.writeVarLong(SpongePacketChannel.packTypeAndValue(SpongePacketChannel.TYPE_NORMAL, binding.opcode())); + mcPacketSupplier = () -> PacketUtil.createPlayPayload(this.key(), payload, side); } try { @@ -252,7 +252,7 @@ public CompletableFuture sendTo(final EngineConnection con @Override public boolean isSupportedBy(final EngineConnection connection) { Objects.requireNonNull(connection, "connection"); - return ConnectionUtil.getRegisteredChannels(connection).contains(this.getKey()); + return ConnectionUtil.getRegisteredChannels(connection).contains(this.key()); } @Override diff --git a/src/main/java/org/spongepowered/common/network/channel/packet/SpongeTransactionalPacketBinding.java b/src/main/java/org/spongepowered/common/network/channel/packet/SpongeTransactionalPacketBinding.java index 167250bdd6b..5cffeee5b0d 100644 --- a/src/main/java/org/spongepowered/common/network/channel/packet/SpongeTransactionalPacketBinding.java +++ b/src/main/java/org/spongepowered/common/network/channel/packet/SpongeTransactionalPacketBinding.java @@ -129,8 +129,8 @@ public TransactionalPacketBinding addResponseHandler(final ResponsePacketH @Override public String toString() { return MoreObjects.toStringHelper(this) - .add("opcode", this.getOpcode()) - .add("requestPacketType", this.getPacketType()) + .add("opcode", this.opcode()) + .add("requestPacketType", this.packetType()) .toString(); } } diff --git a/src/main/java/org/spongepowered/common/network/channel/raw/SpongeRawDataChannel.java b/src/main/java/org/spongepowered/common/network/channel/raw/SpongeRawDataChannel.java index 1c176563912..b49e336b488 100644 --- a/src/main/java/org/spongepowered/common/network/channel/raw/SpongeRawDataChannel.java +++ b/src/main/java/org/spongepowered/common/network/channel/raw/SpongeRawDataChannel.java @@ -71,7 +71,7 @@ protected void handleTransactionResponse(EngineConnection connection, Object sto } ChannelBuf encodePayload(final Consumer payload) { - final ChannelBuf buf = this.getRegistry().getBufferAllocator().buffer(); + final ChannelBuf buf = this.registry().getBufferAllocator().buffer(); payload.accept(buf); return buf; } diff --git a/src/main/java/org/spongepowered/common/network/channel/raw/SpongeRawLoginDataChannel.java b/src/main/java/org/spongepowered/common/network/channel/raw/SpongeRawLoginDataChannel.java index daf9707cd71..3aa8114a856 100644 --- a/src/main/java/org/spongepowered/common/network/channel/raw/SpongeRawLoginDataChannel.java +++ b/src/main/java/org/spongepowered/common/network/channel/raw/SpongeRawLoginDataChannel.java @@ -165,7 +165,7 @@ public CompletableFuture sendTo(final EngineConnection connection, f } }; - final Packet mcPacket = PacketUtil.createLoginPayloadRequest(this.parent.getKey(), buf, transactionId); + final Packet mcPacket = PacketUtil.createLoginPayloadRequest(this.parent.key(), buf, transactionId); PacketSender.sendTo(connection, mcPacket, sendFuture -> { if (sendFuture.isSuccess()) { transactionStore.put(transactionId, this.parent, resultConsumer); diff --git a/src/main/java/org/spongepowered/common/network/channel/raw/SpongeRawPlayDataChannel.java b/src/main/java/org/spongepowered/common/network/channel/raw/SpongeRawPlayDataChannel.java index 563f3d0917d..bb48fcfff6b 100644 --- a/src/main/java/org/spongepowered/common/network/channel/raw/SpongeRawPlayDataChannel.java +++ b/src/main/java/org/spongepowered/common/network/channel/raw/SpongeRawPlayDataChannel.java @@ -59,7 +59,7 @@ public SpongeRawDataChannel parent() { @Override public boolean isSupportedBy(final EngineConnection connection) { Objects.requireNonNull(connection, "connection"); - return ConnectionUtil.getRegisteredChannels(connection).contains(this.parent.getKey()); + return ConnectionUtil.getRegisteredChannels(connection).contains(this.parent.key()); } @Override @@ -116,7 +116,7 @@ public CompletableFuture sendTo(final EngineConnection connection, final C return future; } - final Packet mcPacket = PacketUtil.createPlayPayload(this.parent.getKey(), payload, connection.getSide()); + final Packet mcPacket = PacketUtil.createPlayPayload(this.parent.key(), payload, connection.side()); PacketSender.sendTo(connection, mcPacket, future); return future; } diff --git a/src/main/java/org/spongepowered/common/network/packet/SpongePacketHandler.java b/src/main/java/org/spongepowered/common/network/packet/SpongePacketHandler.java index ad6d60a56ce..26f20ecc613 100644 --- a/src/main/java/org/spongepowered/common/network/packet/SpongePacketHandler.java +++ b/src/main/java/org/spongepowered/common/network/packet/SpongePacketHandler.java @@ -53,7 +53,7 @@ public static void init(final SpongeChannelRegistry registry) { SpongePacketHandler.channel = registry.createChannel(ResourceKey.sponge("default"), PacketChannel.class); SpongePacketHandler.channel.registerTransactional(RequestBlockTrackerDataPacket.class, TrackerDataResponsePacket.class, 0) .setRequestHandler(EngineConnectionTypes.SERVER_PLAYER, (requestPacket, connection, response) -> { - final ServerPlayer player = connection.getPlayer(); + final ServerPlayer player = connection.player(); if (!player.hasPermission("sponge.debug.block-tracking")) { return; } @@ -72,7 +72,7 @@ public static void init(final SpongeChannelRegistry registry) { }); SpongePacketHandler.channel.registerTransactional(RequestEntityTrackerDataPacket.class, TrackerDataResponsePacket.class, 1) .setRequestHandler(EngineConnectionTypes.SERVER_PLAYER, (requestPacket, connection, response) -> { - final ServerPlayer player = connection.getPlayer(); + final ServerPlayer player = connection.player(); if (!player.hasPermission("sponge.debug.entity-tracking")) { return; } @@ -106,8 +106,8 @@ private static TrackerDataResponsePacket createTrackerDataResponse( final Optional owner, final Optional notifier ) { - final String ownerName = owner.map(User::getName).orElse(""); - final String notifierName = notifier.map(User::getName).orElse(""); + final String ownerName = owner.map(User::name).orElse(""); + final String notifierName = notifier.map(User::name).orElse(""); return new TrackerDataResponsePacket(ownerName, notifierName); } diff --git a/src/main/java/org/spongepowered/common/network/status/SpongeFavicon.java b/src/main/java/org/spongepowered/common/network/status/SpongeFavicon.java index 7436c32c638..f41a66094c4 100644 --- a/src/main/java/org/spongepowered/common/network/status/SpongeFavicon.java +++ b/src/main/java/org/spongepowered/common/network/status/SpongeFavicon.java @@ -66,7 +66,7 @@ public String getEncoded() { } @Override - public BufferedImage getImage() { + public BufferedImage image() { return this.decoded; } diff --git a/src/main/java/org/spongepowered/common/network/status/SpongeLegacyMinecraftVersion.java b/src/main/java/org/spongepowered/common/network/status/SpongeLegacyMinecraftVersion.java index 16158c7637a..8e9567e377c 100644 --- a/src/main/java/org/spongepowered/common/network/status/SpongeLegacyMinecraftVersion.java +++ b/src/main/java/org/spongepowered/common/network/status/SpongeLegacyMinecraftVersion.java @@ -48,7 +48,7 @@ public SpongeLegacyMinecraftVersion(SpongeLegacyMinecraftVersion base, int versi } @Override - public String getName() { + public String name() { return this.name; } @@ -58,7 +58,7 @@ public boolean isLegacy() { } @Override - public OptionalInt getDataVersion() { + public OptionalInt dataVersion() { return OptionalInt.empty(); } diff --git a/src/main/java/org/spongepowered/common/network/status/SpongeLegacyStatusClient.java b/src/main/java/org/spongepowered/common/network/status/SpongeLegacyStatusClient.java index b50ee5bdbd7..fa8604cdc59 100644 --- a/src/main/java/org/spongepowered/common/network/status/SpongeLegacyStatusClient.java +++ b/src/main/java/org/spongepowered/common/network/status/SpongeLegacyStatusClient.java @@ -45,17 +45,17 @@ public SpongeLegacyStatusClient(InetSocketAddress address, MinecraftVersion vers } @Override - public InetSocketAddress getAddress() { + public InetSocketAddress address() { return this.address; } @Override - public MinecraftVersion getVersion() { + public MinecraftVersion version() { return this.version; } @Override - public Optional getVirtualHost() { + public Optional virtualHost() { return this.virtualHost; } diff --git a/src/main/java/org/spongepowered/common/network/status/SpongeStatusClient.java b/src/main/java/org/spongepowered/common/network/status/SpongeStatusClient.java index c6dbbaf10a2..5d498792499 100644 --- a/src/main/java/org/spongepowered/common/network/status/SpongeStatusClient.java +++ b/src/main/java/org/spongepowered/common/network/status/SpongeStatusClient.java @@ -43,17 +43,17 @@ public SpongeStatusClient(Connection networkManager) { } @Override - public InetSocketAddress getAddress() { + public InetSocketAddress address() { return this.connection.bridge$getAddress(); } @Override - public MinecraftVersion getVersion() { + public MinecraftVersion version() { return this.connection.bridge$getVersion(); } @Override - public Optional getVirtualHost() { + public Optional virtualHost() { return Optional.ofNullable(this.connection.bridge$getVirtualHost()); } diff --git a/src/main/java/org/spongepowered/common/network/status/SpongeStatusResponse.java b/src/main/java/org/spongepowered/common/network/status/SpongeStatusResponse.java index dbdacb629df..9dd9b490356 100644 --- a/src/main/java/org/spongepowered/common/network/status/SpongeStatusResponse.java +++ b/src/main/java/org/spongepowered/common/network/status/SpongeStatusResponse.java @@ -47,13 +47,13 @@ private SpongeStatusResponse() { } @Nullable - public static ServerStatus post(MinecraftServer server, StatusClient client) { + public static ServerStatus post(final MinecraftServer server, final StatusClient client) { return SpongeStatusResponse.call(SpongeStatusResponse.create(server), client); } @Nullable - public static ServerStatus postLegacy(MinecraftServer server, InetSocketAddress address, MinecraftVersion version, - InetSocketAddress virtualHost) { + public static ServerStatus postLegacy(final MinecraftServer server, final InetSocketAddress address, final MinecraftVersion version, + final InetSocketAddress virtualHost) { ServerStatus response = SpongeStatusResponse.create(server); response.setVersion(new ServerStatus.Version(response.getVersion().getName(), Byte.MAX_VALUE)); response = SpongeStatusResponse.call(response, new SpongeLegacyStatusClient(address, version, virtualHost)); @@ -64,23 +64,23 @@ public static ServerStatus postLegacy(MinecraftServer server, InetSocketAddress } @Nullable - private static ServerStatus call(ServerStatus response, StatusClient client) { - if (!SpongeCommon.postEvent(SpongeEventFactory.createClientPingServerEvent(Cause.of(EventContext.empty(), Sponge.getServer()), client, + private static ServerStatus call(final ServerStatus response, final StatusClient client) { + if (!SpongeCommon.postEvent(SpongeEventFactory.createClientPingServerEvent(Cause.of(EventContext.empty(), Sponge.server()), client, (ClientPingServerEvent.Response) response))) { return response; } return null; } - public static ServerStatus create(MinecraftServer server) { + public static ServerStatus create(final MinecraftServer server) { return SpongeStatusResponse.clone(server.getStatus()); } - private static ServerStatus clone(ServerStatus original) { - ServerStatus clone = new ServerStatus(); + private static ServerStatus clone(final ServerStatus original) { + final ServerStatus clone = new ServerStatus(); clone.setDescription(original.getDescription()); if (original.getFavicon() != null) { - ((ClientPingServerEvent.Response) clone).setFavicon(((StatusResponse) original).getFavicon().get()); + ((ClientPingServerEvent.Response) clone).setFavicon(((StatusResponse) original).favicon().get()); } clone.setPlayers(SpongeStatusResponse.clone(original.getPlayers())); @@ -89,9 +89,9 @@ private static ServerStatus clone(ServerStatus original) { } @Nullable - private static ServerStatus.Players clone(@Nullable ServerStatus.Players original) { + private static ServerStatus.Players clone(@Nullable final ServerStatus.Players original) { if (original != null) { - ServerStatus.Players clone = new ServerStatus.Players(original.getMaxPlayers(), + final ServerStatus.Players clone = new ServerStatus.Players(original.getMaxPlayers(), original.getNumPlayers()); clone.setSample(original.getSample()); return clone; @@ -100,19 +100,19 @@ private static ServerStatus.Players clone(@Nullable ServerStatus.Players origina } @Nullable - private static ServerStatus.Version clone(@Nullable ServerStatus.Version original) { + private static ServerStatus.Version clone(@Nullable final ServerStatus.Version original) { return original != null ? new ServerStatus.Version(original.getName(), original.getProtocol()) : null; } - public static String getMotd(ServerStatus response) { + public static String getMotd(final ServerStatus response) { return SpongeStatusResponse.getFirstLine(SpongeAdventure.legacySection(SpongeAdventure.asAdventure(response.getDescription()))); } - public static String getUnformattedMotd(ServerStatus response) { + public static String getUnformattedMotd(final ServerStatus response) { return SpongeStatusResponse.getFirstLine(SpongeAdventure.plain(SpongeAdventure.asAdventure(response.getDescription()))); } - private static String getFirstLine(String s) { + private static String getFirstLine(final String s) { return NetworkUtil.substringBefore(s, '\n'); } diff --git a/src/main/java/org/spongepowered/common/placeholder/SpongePlaceholderComponent.java b/src/main/java/org/spongepowered/common/placeholder/SpongePlaceholderComponent.java index 41e5e6c5f11..45857c02ed2 100644 --- a/src/main/java/org/spongepowered/common/placeholder/SpongePlaceholderComponent.java +++ b/src/main/java/org/spongepowered/common/placeholder/SpongePlaceholderComponent.java @@ -40,12 +40,12 @@ public SpongePlaceholderComponent(final PlaceholderParser parser, final Placehol } @Override - public PlaceholderContext getContext() { + public PlaceholderContext context() { return this.context; } @Override - public PlaceholderParser getParser() { + public PlaceholderParser parser() { return this.parser; } diff --git a/src/main/java/org/spongepowered/common/placeholder/SpongePlaceholderComponentBuilder.java b/src/main/java/org/spongepowered/common/placeholder/SpongePlaceholderComponentBuilder.java index dab0310082a..b57c17793ab 100644 --- a/src/main/java/org/spongepowered/common/placeholder/SpongePlaceholderComponentBuilder.java +++ b/src/main/java/org/spongepowered/common/placeholder/SpongePlaceholderComponentBuilder.java @@ -37,13 +37,13 @@ public class SpongePlaceholderComponentBuilder implements PlaceholderComponent.B @Nullable private PlaceholderContext context; @Override - public PlaceholderComponent.Builder setParser(final PlaceholderParser parser) { + public PlaceholderComponent.Builder parser(final PlaceholderParser parser) { this.parser = Preconditions.checkNotNull(parser, "parser cannot be null"); return this; } @Override - public PlaceholderComponent.Builder setContext(final PlaceholderContext context) { + public PlaceholderComponent.Builder context(final PlaceholderContext context) { this.context = Preconditions.checkNotNull(context, "context cannot be null"); return this; } diff --git a/src/main/java/org/spongepowered/common/placeholder/SpongePlaceholderContext.java b/src/main/java/org/spongepowered/common/placeholder/SpongePlaceholderContext.java index 9034487d78e..fc8996df14c 100644 --- a/src/main/java/org/spongepowered/common/placeholder/SpongePlaceholderContext.java +++ b/src/main/java/org/spongepowered/common/placeholder/SpongePlaceholderContext.java @@ -42,7 +42,7 @@ public SpongePlaceholderContext(@Nullable final Supplier associatedObjec } @Override - public Optional getAssociatedObject() { + public Optional associatedObject() { if (this.associatedObjectSupplier == null) { return Optional.empty(); } @@ -50,7 +50,7 @@ public Optional getAssociatedObject() { } @Override - public Optional getArgumentString() { + public Optional argumentString() { return Optional.ofNullable(this.argument); } diff --git a/src/main/java/org/spongepowered/common/placeholder/SpongePlaceholderContextBuilder.java b/src/main/java/org/spongepowered/common/placeholder/SpongePlaceholderContextBuilder.java index e4ac73e4d4c..ed96a47cb88 100644 --- a/src/main/java/org/spongepowered/common/placeholder/SpongePlaceholderContextBuilder.java +++ b/src/main/java/org/spongepowered/common/placeholder/SpongePlaceholderContextBuilder.java @@ -47,26 +47,26 @@ public class SpongePlaceholderContextBuilder implements PlaceholderContext.Build @Override @SuppressWarnings("unchecked") - public PlaceholderContext.Builder setAssociatedObject(@Nullable final Object associatedObject) { + public PlaceholderContext.Builder associatedObject(@Nullable final Object associatedObject) { if (associatedObject == null) { this.associatedObjectSupplier = null; } else if (associatedObject instanceof Supplier) { - return this.setAssociatedObject((Supplier) associatedObject); + return this.associatedObject((Supplier) associatedObject); } else if (associatedObject instanceof SystemSubject) { - this.associatedObjectSupplier = Sponge::getSystemSubject; + this.associatedObjectSupplier = Sponge::systemSubject; } else if (associatedObject instanceof Server) { - this.associatedObjectSupplier = Sponge::getServer; + this.associatedObjectSupplier = Sponge::server; } else if (associatedObject instanceof Player) { - return this.setAssociatedObject((Player) associatedObject); + return this.associatedObject((Player) associatedObject); } else if (associatedObject instanceof ServerWorld) { - final ResourceKey key = ((ServerWorld) associatedObject).getKey(); - this.associatedObjectSupplier = () -> SpongeCommon.getGame().getServer().getWorldManager().world(key).orElse(null); + final ResourceKey key = ((ServerWorld) associatedObject).key(); + this.associatedObjectSupplier = () -> SpongeCommon.getGame().server().worldManager().world(key).orElse(null); } else if (associatedObject instanceof Entity) { final Entity entity = ((Entity) associatedObject); - final ResourceKey key = entity.getServerLocation().getWorld().getKey(); - final UUID entityUuid = ((Entity) associatedObject).getUniqueId(); + final ResourceKey key = entity.serverLocation().world().key(); + final UUID entityUuid = ((Entity) associatedObject).uniqueId(); this.associatedObjectSupplier = - () -> SpongeCommon.getGame().getServer().getWorldManager().world(key).flatMap(x -> x.getEntity(entityUuid)).orElse(null); + () -> SpongeCommon.getGame().server().worldManager().world(key).flatMap(x -> x.entity(entityUuid)).orElse(null); } else { // We create a weak reference here so we don't hold on to game objects. final WeakReference objectWeakReference = new WeakReference<>(associatedObject); @@ -76,13 +76,13 @@ public PlaceholderContext.Builder setAssociatedObject(@Nullable final Object ass } @Override - public PlaceholderContext.Builder setAssociatedObject(@Nullable final Supplier associatedObjectSupplier) { + public PlaceholderContext.Builder associatedObject(@Nullable final Supplier associatedObjectSupplier) { this.associatedObjectSupplier = associatedObjectSupplier; return this; } @Override - public PlaceholderContext.Builder setArgumentString(@Nullable final String argument) { + public PlaceholderContext.Builder argumentString(@Nullable final String argument) { this.argument = argument == null || argument.isEmpty() ? null : argument; return this; } diff --git a/src/main/java/org/spongepowered/common/profile/SpongeGameProfile.java b/src/main/java/org/spongepowered/common/profile/SpongeGameProfile.java index d4f3ae77569..5dc459becb1 100644 --- a/src/main/java/org/spongepowered/common/profile/SpongeGameProfile.java +++ b/src/main/java/org/spongepowered/common/profile/SpongeGameProfile.java @@ -72,11 +72,11 @@ public static com.mojang.authlib.GameProfile toMcProfile(final GameProfile profi } public static GameProfile unsignedOf(final GameProfile profile) { - if (profile.getProperties().isEmpty()) { + if (profile.properties().isEmpty()) { return profile; } - return new SpongeGameProfile(profile.getUniqueId(), profile.getName().orElse(null), - profile.getProperties().stream().map(SpongeGameProfile::withoutSignature).collect(ImmutableList.toImmutableList())); + return new SpongeGameProfile(profile.uniqueId(), profile.name().orElse(null), + profile.properties().stream().map(SpongeGameProfile::withoutSignature).collect(ImmutableList.toImmutableList())); } private static String decodeBase64(final String value) { @@ -91,7 +91,7 @@ private static ProfileProperty withoutSignature(final ProfileProperty property) if (!property.hasSignature()) { return property; } - final String decoded = SpongeGameProfile.decodeBase64(property.getValue()); + final String decoded = SpongeGameProfile.decodeBase64(property.value()); final JsonObject json; try { json = SpongeGameProfile.GSON.fromJson(decoded, JsonObject.class); @@ -104,7 +104,7 @@ private static ProfileProperty withoutSignature(final ProfileProperty property) } json.remove("signatureRequired"); final String encoded = SpongeGameProfile.encodeBase64(SpongeGameProfile.GSON.toJson(json)); - return ProfileProperty.of(property.getName(), encoded); + return ProfileProperty.of(property.name(), encoded); } private final UUID uniqueId; @@ -131,18 +131,18 @@ public com.mojang.authlib.GameProfile toMcProfile() { final String name = this.name; final com.mojang.authlib.GameProfile mcProfile = new com.mojang.authlib.GameProfile(uniqueId, name); for (final ProfileProperty property : this.properties) { - mcProfile.getProperties().put(property.getName(), (Property) property); + mcProfile.getProperties().put(property.name(), (Property) property); } return mcProfile; } @Override - public UUID getUniqueId() { + public UUID uniqueId() { return this.uniqueId; } @Override - public Optional getName() { + public Optional name() { return Optional.ofNullable(this.name); } @@ -152,7 +152,7 @@ public GameProfile withName(final @Nullable String name) { } @Override - public List getProperties() { + public List properties() { return this.properties; } @@ -197,15 +197,15 @@ public GameProfile withoutProperties(final Predicate filter) { } @Override - public int getContentVersion() { + public int contentVersion() { return 1; } @Override public DataContainer toContainer() { final DataContainer container = DataContainer.createNew() - .set(Queries.CONTENT_VERSION, this.getContentVersion()) - .set(Constants.Profile.UUID, this.getUniqueId().toString()); + .set(Queries.CONTENT_VERSION, this.contentVersion()) + .set(Constants.Profile.UUID, this.uniqueId().toString()); if (this.name != null) { container.set(Constants.Profile.NAME, this.name); } @@ -213,9 +213,9 @@ public DataContainer toContainer() { final List entries = new ArrayList<>(this.properties.size()); for (final ProfileProperty property : this.properties) { final DataContainer entry = DataContainer.createNew() - .set(Constants.Profile.NAME, property.getName()) - .set(Constants.Profile.VALUE, property.getValue()); - property.getSignature().ifPresent(signature -> entry.set(Constants.Profile.SIGNATURE, signature)); + .set(Constants.Profile.NAME, property.name()) + .set(Constants.Profile.VALUE, property.value()); + property.signature().ifPresent(signature -> entry.set(Constants.Profile.SIGNATURE, signature)); entries.add(entry); } container.set(Constants.Profile.PROPERTIES, entries); diff --git a/src/main/java/org/spongepowered/common/profile/SpongeGameProfileManager.java b/src/main/java/org/spongepowered/common/profile/SpongeGameProfileManager.java index 805452d2522..10b269eb867 100644 --- a/src/main/java/org/spongepowered/common/profile/SpongeGameProfileManager.java +++ b/src/main/java/org/spongepowered/common/profile/SpongeGameProfileManager.java @@ -66,7 +66,7 @@ public SpongeGameProfileManager(final Server server) { } @Override - public GameProfileCache getCache() { + public GameProfileCache cache() { return this.cache; } @@ -76,7 +76,7 @@ public GameProfileProvider uncached() { } @Override - public CompletableFuture getBasicProfile(final UUID uniqueId) { + public CompletableFuture basicProfile(final UUID uniqueId) { Objects.requireNonNull(uniqueId, "uniqueId"); final Optional entry = this.cache.bridge$getEntry(uniqueId); if (entry.isPresent()) { @@ -88,22 +88,22 @@ public CompletableFuture getBasicProfile(final UUID uniqueId) { this.cache.bridge$addBasic(profile); return CompletableFuture.completedFuture(profile); } - return this.uncached().getBasicProfile(uniqueId).thenApply(profile -> { + return this.uncached().basicProfile(uniqueId).thenApply(profile -> { this.cache.bridge$addBasic(profile); return profile; }); } @Override - public CompletableFuture getBasicProfile(final String name, final @Nullable Instant time) { + public CompletableFuture basicProfile(final String name, final @Nullable Instant time) { Objects.requireNonNull(name, "name"); if (time != null) { - return this.uncached().getBasicProfile(name, time); + return this.uncached().basicProfile(name, time); } return this.cache.bridge$getEntry(name) .flatMap(entry -> Optional.ofNullable(entry.bridge$getBasic())) .map(CompletableFuture::completedFuture) - .orElseGet(() -> this.uncached().getBasicProfile(name) + .orElseGet(() -> this.uncached().basicProfile(name) .thenApply(profile -> { this.cache.bridge$addBasic(profile); return profile; @@ -111,10 +111,10 @@ public CompletableFuture getBasicProfile(final String name, final @ } @Override - public CompletableFuture> getBasicProfiles(final Iterable names, final @Nullable Instant time) { + public CompletableFuture> basicProfiles(final Iterable names, final @Nullable Instant time) { Objects.requireNonNull(names, "names"); if (time != null) { - return this.uncached().getBasicProfiles(names, time); + return this.uncached().basicProfiles(names, time); } final Map result = new HashMap<>(); final List toLookup = new ArrayList<>(); @@ -130,7 +130,7 @@ public CompletableFuture> getBasicProfiles(final Iterab if (toLookup.isEmpty()) { return CompletableFuture.completedFuture(result); } - return this.uncached().getBasicProfiles(toLookup).thenApply(lookedUp -> { + return this.uncached().basicProfiles(toLookup).thenApply(lookedUp -> { for (final GameProfile profile : lookedUp.values()) { this.cache.bridge$addBasic(profile); } @@ -140,24 +140,24 @@ public CompletableFuture> getBasicProfiles(final Iterab } @Override - public CompletableFuture getProfile(final String name, final boolean signed) { + public CompletableFuture profile(final String name, final boolean signed) { Objects.requireNonNull(name, "name"); return this.cache.bridge$getEntry(name) .flatMap(entry -> Optional.ofNullable(entry.bridge$getFull(signed))) .map(CompletableFuture::completedFuture) - .orElseGet(() -> this.uncached().getProfile(name, signed).thenApply(profile -> { + .orElseGet(() -> this.uncached().profile(name, signed).thenApply(profile -> { this.cache.bridge$add(profile, true, signed); return profile; })); } @Override - public CompletableFuture getProfile(final UUID uniqueId, final boolean signed) { + public CompletableFuture profile(final UUID uniqueId, final boolean signed) { Objects.requireNonNull(uniqueId, "uniqueId"); return this.cache.bridge$getEntry(uniqueId) .flatMap(entry -> Optional.ofNullable(entry.bridge$getFull(signed))) .map(CompletableFuture::completedFuture) - .orElseGet(() -> this.uncached().getProfile(uniqueId, signed).thenApply(profile -> { + .orElseGet(() -> this.uncached().profile(uniqueId, signed).thenApply(profile -> { this.cache.bridge$add(profile, true, signed); return profile; })); @@ -167,7 +167,7 @@ public void lookupUserAsync(final UUID uniqueId) { Objects.requireNonNull(uniqueId, "uniqueId"); this.gameLookupExecutorService.execute(() -> { try { - this.getBasicProfile(uniqueId).get(); + this.basicProfile(uniqueId).get(); } catch (final InterruptedException | ExecutionException e) { e.printStackTrace(); } diff --git a/src/main/java/org/spongepowered/common/profile/UncachedGameProfileProvider.java b/src/main/java/org/spongepowered/common/profile/UncachedGameProfileProvider.java index 02a4e13d173..3c4c025b8dd 100644 --- a/src/main/java/org/spongepowered/common/profile/UncachedGameProfileProvider.java +++ b/src/main/java/org/spongepowered/common/profile/UncachedGameProfileProvider.java @@ -101,7 +101,7 @@ private void submit(final Runnable runnable) { } @Override - public CompletableFuture getProfile(final UUID uniqueId, final boolean signed) { + public CompletableFuture profile(final UUID uniqueId, final boolean signed) { Objects.requireNonNull(uniqueId, "uniqueId"); return Objects.requireNonNull(this.profileCache.get(uniqueId)).thenApply(profile -> { if (profile == null) { @@ -112,13 +112,13 @@ public CompletableFuture getProfile(final UUID uniqueId, final bool } @Override - public CompletableFuture getProfile(final String name, final boolean signed) { + public CompletableFuture profile(final String name, final boolean signed) { Objects.requireNonNull(name, "name"); final CachedProfile cachedProfile = this.profileByNameCache.getIfPresent(name.toLowerCase(Locale.ROOT)); if (cachedProfile != null) { return CompletableFuture.completedFuture(signed ? cachedProfile.getSigned() : cachedProfile.getUnsigned()); } - return this.getBasicProfile(name).thenCompose(basicProfile -> this.getProfile(basicProfile.getUniqueId(), signed)); + return this.basicProfile(name).thenCompose(basicProfile -> this.profile(basicProfile.uniqueId(), signed)); } private static final class CachedProfile { @@ -146,7 +146,7 @@ public GameProfile getUnsigned() { } @Override - public CompletableFuture getBasicProfile(final UUID uniqueId) { + public CompletableFuture basicProfile(final UUID uniqueId) { Objects.requireNonNull(uniqueId, "uniqueId"); return Objects.requireNonNull(this.profileCache.get(uniqueId)).thenApply(profile -> { if (profile == null) { @@ -157,7 +157,7 @@ public CompletableFuture getBasicProfile(final UUID uniqueId) { } @Override - public CompletableFuture getBasicProfile(final String name, final @Nullable Instant time) { + public CompletableFuture basicProfile(final String name, final @Nullable Instant time) { Objects.requireNonNull(name, "name"); if (time != null) { return this.submit(() -> { @@ -181,7 +181,7 @@ public CompletableFuture getBasicProfile(final String name, final @ } @Override - public CompletableFuture> getBasicProfiles(final Iterable names, final @Nullable Instant time) { + public CompletableFuture> basicProfiles(final Iterable names, final @Nullable Instant time) { Objects.requireNonNull(names, "names"); final CompletableFuture> result = new CompletableFuture<>(); if (time != null) { diff --git a/src/main/java/org/spongepowered/common/raid/SpongeRaidWave.java b/src/main/java/org/spongepowered/common/raid/SpongeRaidWave.java index 967d5eb1821..5c23b88109e 100644 --- a/src/main/java/org/spongepowered/common/raid/SpongeRaidWave.java +++ b/src/main/java/org/spongepowered/common/raid/SpongeRaidWave.java @@ -44,7 +44,7 @@ public SpongeRaidWave(final net.minecraft.world.entity.raid.Raid raid, final int } @Override - public Raid getRaid() { + public Raid raid() { return (Raid) this.raid; } @@ -70,7 +70,7 @@ public boolean isFinal() { } @Override - public Optional getLeader() { + public Optional leader() { return Optional.ofNullable((Raider) this.raid.getLeader(this.waveId)); } diff --git a/src/main/java/org/spongepowered/common/registry/SpongeGameRegistry.java b/src/main/java/org/spongepowered/common/registry/SpongeGameRegistry.java index 37f405fc57d..4898299c483 100644 --- a/src/main/java/org/spongepowered/common/registry/SpongeGameRegistry.java +++ b/src/main/java/org/spongepowered/common/registry/SpongeGameRegistry.java @@ -36,12 +36,12 @@ public final class SpongeGameRegistry implements GameRegistry { @Override - public AdventureRegistry getAdventureRegistry() { + public AdventureRegistry adventureRegistry() { return AdventureRegistryImpl.INSTANCE; } @Override - public RecipeRegistry getRecipeRegistry() { - return ((RecipeRegistry) ((MinecraftServer) Sponge.getServer()).getRecipeManager()); + public RecipeRegistry recipeRegistry() { + return ((RecipeRegistry) ((MinecraftServer) Sponge.server()).getRecipeManager()); } } diff --git a/src/main/java/org/spongepowered/common/registry/SpongeRegistryLoaders.java b/src/main/java/org/spongepowered/common/registry/SpongeRegistryLoaders.java index 16ac5a3ed89..d98b3b5ef45 100644 --- a/src/main/java/org/spongepowered/common/registry/SpongeRegistryLoaders.java +++ b/src/main/java/org/spongepowered/common/registry/SpongeRegistryLoaders.java @@ -293,9 +293,9 @@ public static RegistryLoader banType() { public static RegistryLoader> blockTransactionTypes() { return RegistryLoader.of(l -> { l.add(TransactionTypes.BLOCK, k -> new BlockTransactionType()); - l.add(TransactionTypes.ENTITY_DEATH_DROPS, k -> new NoOpTransactionType<>(false, k.getValue().toUpperCase(Locale.ROOT))); - l.add(TransactionTypes.NEIGHBOR_NOTIFICATION, k -> new NoOpTransactionType<>(false, k.getValue().toUpperCase(Locale.ROOT))); - l.add(TransactionTypes.SPAWN_ENTITY, k -> new NoOpTransactionType<>(false, k.getValue().toUpperCase(Locale.ROOT))); + l.add(TransactionTypes.ENTITY_DEATH_DROPS, k -> new NoOpTransactionType<>(false, k.value().toUpperCase(Locale.ROOT))); + l.add(TransactionTypes.NEIGHBOR_NOTIFICATION, k -> new NoOpTransactionType<>(false, k.value().toUpperCase(Locale.ROOT))); + l.add(TransactionTypes.SPAWN_ENTITY, k -> new NoOpTransactionType<>(false, k.value().toUpperCase(Locale.ROOT))); }); } @@ -376,7 +376,7 @@ public static RegistryLoader> valueParameter() { l.add(ResourceKeyedValueParameters.VECTOR3D, k -> StandardCatalogedArgumentParser.createConverter(k, Vec3Argument.vec3(), (reader, cause, result) -> VecHelper.toVector3d(result.getPosition(cause.getSource())))); l.add(ResourceKeyedValueParameters.WORLD, k -> StandardCatalogedArgumentParser.createConverter(k, DimensionArgument.dimension(), - (reader, cause, result) -> Sponge.getServer().getWorldManager().world((ResourceKey) (Object) result) + (reader, cause, result) -> Sponge.server().worldManager().world((ResourceKey) (Object) result) .orElseThrow(() -> DimensionArgumentAccessor.accessor$ERROR_INVALID_VALUE().createWithContext(reader, result)) )); }); @@ -725,14 +725,14 @@ public static RegistryLoader> particleOption() { public static RegistryLoader placeholderParser() { return RegistryLoader.of(l -> { l.add(PlaceholderParsers.CURRENT_WORLD, k -> new SpongePlaceholderParserBuilder() - .parser(placeholderText -> Component.text(placeholderText.getAssociatedObject().filter(x -> x instanceof Locatable) - .map(x -> ((Locatable) x).getServerLocation().getWorldKey()) - .orElseGet(() -> Sponge.getServer().getWorldManager().defaultWorld().getKey()).toString())) + .parser(placeholderText -> Component.text(placeholderText.associatedObject().filter(x -> x instanceof Locatable) + .map(x -> ((Locatable) x).serverLocation().worldKey()) + .orElseGet(() -> Sponge.server().worldManager().defaultWorld().key()).toString())) .build()); l.add(PlaceholderParsers.NAME, k -> new SpongePlaceholderParserBuilder() - .parser(placeholderText -> placeholderText.getAssociatedObject() + .parser(placeholderText -> placeholderText.associatedObject() .filter(x -> x instanceof Nameable) - .map(x -> Component.text(((Nameable) x).getName())) + .map(x -> Component.text(((Nameable) x).name())) .orElse(Component.empty())) .build()); }); diff --git a/src/main/java/org/spongepowered/common/registry/VanillaRegistryLoader.java b/src/main/java/org/spongepowered/common/registry/VanillaRegistryLoader.java index 06857fb657d..54efbaedab7 100644 --- a/src/main/java/org/spongepowered/common/registry/VanillaRegistryLoader.java +++ b/src/main/java/org/spongepowered/common/registry/VanillaRegistryLoader.java @@ -276,10 +276,10 @@ private static RegistryLoader> trigger() { l.add(Triggers.USED_TOTEM, k -> (Trigger) CriteriaTriggers.USED_TOTEM); l.add(Triggers.VILLAGER_TRADE, k -> (Trigger) CriteriaTriggers.TRADE); final DefaultedRegistryReference> dummyKey = - RegistryKey.of(RegistryTypes.TRIGGER, ResourceKey.sponge("dummy")).asDefaultedReference(() -> Sponge.getGame().registries()); + RegistryKey.of(RegistryTypes.TRIGGER, ResourceKey.sponge("dummy")).asDefaultedReference(() -> Sponge.game().registries()); l.add(dummyKey, k -> (Trigger) (Object) SpongeDummyTrigger.DUMMY_TRIGGER); final DefaultedRegistryReference> scoreKey = - RegistryKey.of(RegistryTypes.TRIGGER, ResourceKey.sponge("score")).asDefaultedReference(() -> Sponge.getGame().registries()); + RegistryKey.of(RegistryTypes.TRIGGER, ResourceKey.sponge("score")).asDefaultedReference(() -> Sponge.game().registries()); l.add(scoreKey, k -> (Trigger) (Object) SpongeScoreTrigger.SCORE_TRIGGER); }); } diff --git a/src/main/java/org/spongepowered/common/relocate/co/aikar/timings/SpongeTimings.java b/src/main/java/org/spongepowered/common/relocate/co/aikar/timings/SpongeTimings.java index a405f9c2030..63c2467ebaf 100644 --- a/src/main/java/org/spongepowered/common/relocate/co/aikar/timings/SpongeTimings.java +++ b/src/main/java/org/spongepowered/common/relocate/co/aikar/timings/SpongeTimings.java @@ -32,7 +32,6 @@ import org.spongepowered.api.block.entity.BlockEntity; import org.spongepowered.api.registry.RegistryTypes; import org.spongepowered.api.scheduler.ScheduledTask; -import org.spongepowered.common.bridge.ResourceKeyBridge; import org.spongepowered.common.scheduler.AsyncScheduler; import org.spongepowered.common.scheduler.SpongeScheduledTask; import org.spongepowered.plugin.PluginContainer; @@ -86,9 +85,9 @@ public static Timing getPluginTaskTimings(ScheduledTask task, long period) { if (((SpongeScheduledTask) task).getScheduler() instanceof AsyncScheduler) { return null; } - PluginContainer plugin = task.getOwner(); + PluginContainer plugin = task.owner(); - String name = "Task: " + task.getName(); + String name = "Task: " + task.name(); if (period > 0) { name += " (interval:" + period + ")"; } else { @@ -106,12 +105,12 @@ public static Timing getPluginTaskTimings(ScheduledTask task, long period) { * @return The timing */ public static Timing getEntityTiming(EntityType entity) { - final ResourceKey resourceKey = Sponge.getGame().registries().registry(RegistryTypes.ENTITY_TYPE).valueKey((org.spongepowered.api.entity.EntityType) entity); + final ResourceKey resourceKey = Sponge.game().registries().registry(RegistryTypes.ENTITY_TYPE).valueKey((org.spongepowered.api.entity.EntityType) entity); return SpongeTimingsFactory.ofSafe("Minecraft", "## entity - " + resourceKey); } public static Timing getTileEntityTiming(final BlockEntity entity) { - final ResourceKey resourceKey = Sponge.getGame().registries().registry(RegistryTypes.BLOCK_ENTITY_TYPE).valueKey(entity.getType()); + final ResourceKey resourceKey = Sponge.game().registries().registry(RegistryTypes.BLOCK_ENTITY_TYPE).valueKey(entity.type()); return SpongeTimingsFactory.ofSafe("Minecraft", "## tickBlockEntity - " + resourceKey); } @@ -140,7 +139,7 @@ public static void stopServer() { } public static Timing getBlockTiming(BlockType block) { - final ResourceKey resourceKey = Sponge.getGame().registries().registry(RegistryTypes.BLOCK_TYPE).valueKey(block); + final ResourceKey resourceKey = Sponge.game().registries().registry(RegistryTypes.BLOCK_TYPE).valueKey(block); return SpongeTimingsFactory.ofSafe("## Scheduled Block: " + resourceKey); } } diff --git a/src/main/java/org/spongepowered/common/relocate/co/aikar/timings/TimingHistory.java b/src/main/java/org/spongepowered/common/relocate/co/aikar/timings/TimingHistory.java index 209db4c4670..72cac150d85 100644 --- a/src/main/java/org/spongepowered/common/relocate/co/aikar/timings/TimingHistory.java +++ b/src/main/java/org/spongepowered/common/relocate/co/aikar/timings/TimingHistory.java @@ -32,12 +32,6 @@ import org.spongepowered.api.entity.EntityType; import org.spongepowered.api.entity.living.player.server.ServerPlayer; import org.spongepowered.common.SpongeCommon; -import org.spongepowered.common.relocate.co.aikar.timings.TimingHistory.Counter; -import org.spongepowered.common.relocate.co.aikar.timings.TimingHistory.MinuteReport; -import org.spongepowered.common.relocate.co.aikar.timings.TimingHistory.PingRecord; -import org.spongepowered.common.relocate.co.aikar.timings.TimingHistory.RegionData; -import org.spongepowered.common.relocate.co.aikar.timings.TimingHistory.RegionData.RegionId; -import org.spongepowered.common.relocate.co.aikar.timings.TimingHistory.TicksRecord; import org.spongepowered.common.relocate.co.aikar.util.JSONUtil; import org.spongepowered.common.relocate.co.aikar.util.LoadingMap; import org.spongepowered.common.relocate.co.aikar.util.MRUMapCache; @@ -93,12 +87,12 @@ public class TimingHistory { } // Information about all loaded chunks/entities -// this.worlds = JSONUtil.mapArrayToObject(SpongeImpl.getGame().getServer().getWorldManager().getWorlds(), (world) -> { +// this.worlds = JSONUtil.mapArrayToObject(SpongeImpl.game().getServer().worldManager().getWorlds(), (world) -> { // Map regions = LoadingMap.newHashMap(RegionData.LOADER); -// return JSONUtil.singleObjectPair(String.valueOf(worldMap.get(world.getProperties().getDirectoryName())), JSONUtil.mapArray(world.getLoadedChunks(), (chunk) -> { -// RegionData data = regions.get(new RegionId(chunk.getChunkPosition().getX(), chunk.getChunkPosition().getZ())); +// return JSONUtil.singleObjectPair(String.valueOf(worldMap.get(world.getProperties().getDirectoryName())), JSONUtil.mapArray(world.loadedChunks(), (chunk) -> { +// RegionData data = regions.get(new RegionId(chunk.chunkPosition().getX(), chunk.chunkPosition().getZ())); // -// for (Entity entity : chunk.getEntities()) { +// for (Entity entity : chunk.entities()) { // if (entity.getType() == null) { // continue; // } @@ -116,8 +110,8 @@ public class TimingHistory { // return null; // } // return JSONUtil.arrayOf( -// chunk.getChunkPosition().getX(), -// chunk.getChunkPosition().getZ(), +// chunk.chunkPosition().getX(), +// chunk.chunkPosition().getZ(), // JSONUtil.mapArrayToObject(data.entityCounts.entrySet(), (entry) -> { // this.entityTypeSet.add(entry.getKey()); // return JSONUtil.singleObjectPair(TimingsPls.getEntityId(entry.getKey()), entry.getValue().count()); @@ -268,10 +262,10 @@ static class PingRecord { final double avg; PingRecord() { - final Collection onlinePlayers = SpongeCommon.getGame().getServer().getOnlinePlayers(); + final Collection onlinePlayers = SpongeCommon.getGame().server().onlinePlayers(); int totalPing = 0; for (ServerPlayer player : onlinePlayers) { - totalPing += player.getConnection().getLatency(); + totalPing += player.connection().latency(); } this.avg = onlinePlayers.isEmpty() ? 0 : totalPing / onlinePlayers.size(); } diff --git a/src/main/java/org/spongepowered/common/relocate/co/aikar/timings/TimingsExport.java b/src/main/java/org/spongepowered/common/relocate/co/aikar/timings/TimingsExport.java index ae86e575003..2d8a18150f3 100644 --- a/src/main/java/org/spongepowered/common/relocate/co/aikar/timings/TimingsExport.java +++ b/src/main/java/org/spongepowered/common/relocate/co/aikar/timings/TimingsExport.java @@ -114,18 +114,18 @@ static void reportTimings() { listeners.send(Component.text("Preparing Timings Report...", NamedTextColor.GREEN)); TimingsExport.lastReport = now; - Platform platform = SpongeCommon.getGame().getPlatform(); + Platform platform = SpongeCommon.getGame().platform(); JsonObjectBuilder builder = JSONUtil.objectBuilder() // Get some basic system details about the server - .add("version", platform.getContainer(IMPLEMENTATION).getMetadata().getVersion()) - .add("maxplayers", SpongeCommon.getGame().getServer().getMaxPlayers()) + .add("version", platform.container(IMPLEMENTATION).getMetadata().getVersion()) + .add("maxplayers", SpongeCommon.getGame().server().maxPlayers()) .add("start", TimingsManager.timingStart / 1000) .add("end", System.currentTimeMillis() / 1000) .add("sampletime", (System.currentTimeMillis() - TimingsManager.timingStart) / 1000); if (!TimingsManager.privacy) { builder.add("server", TimingsExport.getServerName()) - .add("motd", SpongeAdventure.plain(Sponge.getServer().getMOTD())) - .add("online-mode", Sponge.getServer().isOnlineModeEnabled()) + .add("motd", SpongeAdventure.plain(Sponge.server().motd())) + .add("online-mode", Sponge.server().isOnlineModeEnabled()) .add("icon", SpongeCommon.getServer().getStatus().getFavicon()); } @@ -182,7 +182,7 @@ static void reportTimings() { .add("blockentity", JSONUtil.mapArrayToObject(blockEntityTypeSet, (blockEntityType) -> { final ResourceKey resourceKey = - Sponge.getGame().registries().registry(RegistryTypes.BLOCK_ENTITY_TYPE).valueKey(blockEntityType); + Sponge.game().registries().registry(RegistryTypes.BLOCK_ENTITY_TYPE).valueKey(blockEntityType); return JSONUtil.singleObjectPair(TimingsPls.getBlockEntityId(blockEntityType), resourceKey); }) ) @@ -196,7 +196,7 @@ static void reportTimings() { // Information about loaded plugins - builder.add("plugins", JSONUtil.mapArrayToObject(SpongeCommon.getGame().getPluginManager().getPlugins(), (plugin) -> { + builder.add("plugins", JSONUtil.mapArrayToObject(SpongeCommon.getGame().pluginManager().plugins(), (plugin) -> { return JSONUtil.objectBuilder().add(plugin.getMetadata().getId(), JSONUtil.objectBuilder() .add("version", plugin.getMetadata().getVersion()) .add("description", plugin.getMetadata().getDescription().orElse("")) diff --git a/src/main/java/org/spongepowered/common/relocate/co/aikar/timings/TimingsManager.java b/src/main/java/org/spongepowered/common/relocate/co/aikar/timings/TimingsManager.java index 2c4767ae149..94a29a45658 100644 --- a/src/main/java/org/spongepowered/common/relocate/co/aikar/timings/TimingsManager.java +++ b/src/main/java/org/spongepowered/common/relocate/co/aikar/timings/TimingsManager.java @@ -89,7 +89,7 @@ static void tick() { handler.processTick(violated); } - TimingHistory.playerTicks += SpongeCommon.getGame().getServer().getOnlinePlayers().size(); + TimingHistory.playerTicks += SpongeCommon.getGame().server().onlinePlayers().size(); TimingHistory.timedTicks++; // Generate TPS/Ping/Tick reports every minute } @@ -150,13 +150,13 @@ public static Timing getCommandTiming(String pluginName, CommandMapping command) if (!("minecraft".equals(pluginName) || "bukkit".equals(pluginName) || "Spigot".equals(pluginName))) { - plugin = SpongeCommon.getGame().getPluginManager().getPlugin(pluginName); + plugin = SpongeCommon.getGame().pluginManager().plugin(pluginName); } if (!plugin.isPresent()) { - return SpongeTimingsFactory.ofSafe("Command: " + pluginName + ":" + command.getPrimaryAlias()); + return SpongeTimingsFactory.ofSafe("Command: " + pluginName + ":" + command.primaryAlias()); } - return SpongeTimingsFactory.ofSafe(plugin.get(), "Command: " + pluginName + ":" + command.getPrimaryAlias()); + return SpongeTimingsFactory.ofSafe(plugin.get(), "Command: " + pluginName + ":" + command.primaryAlias()); } } diff --git a/src/main/java/org/spongepowered/common/relocate/co/aikar/timings/WorldTimingsHandler.java b/src/main/java/org/spongepowered/common/relocate/co/aikar/timings/WorldTimingsHandler.java index e5652dcb07a..b37edf9cd12 100644 --- a/src/main/java/org/spongepowered/common/relocate/co/aikar/timings/WorldTimingsHandler.java +++ b/src/main/java/org/spongepowered/common/relocate/co/aikar/timings/WorldTimingsHandler.java @@ -78,7 +78,7 @@ public class WorldTimingsHandler { public final Timing chunkPopulate; public WorldTimingsHandler(Level world) { - String name = ((ServerWorld) world).getKey() + " - "; + String name = ((ServerWorld) world).key() + " - "; this.mobSpawn = SpongeTimingsFactory.ofSafe(name + "mobSpawn"); this.doChunkUnload = SpongeTimingsFactory.ofSafe(name + "doChunkUnload"); diff --git a/src/main/java/org/spongepowered/common/resourcepack/SpongeResourcePack.java b/src/main/java/org/spongepowered/common/resourcepack/SpongeResourcePack.java index a2739dbc89b..6debafbd371 100644 --- a/src/main/java/org/spongepowered/common/resourcepack/SpongeResourcePack.java +++ b/src/main/java/org/spongepowered/common/resourcepack/SpongeResourcePack.java @@ -55,18 +55,18 @@ public SpongeResourcePack(@Nullable String hash) { public abstract String getUrlString(); @Override - public String getId() { + public String id() { return this.id; } @Override - public Optional getHash() { + public Optional hash() { return Optional.of(this.hash); } @Override public String toString() { - return MoreObjects.toStringHelper(this).add("id", this.getId()).add("uri", this.getUri()).toString(); + return MoreObjects.toStringHelper(this).add("id", this.id()).add("uri", this.uri()).toString(); } public static SpongeResourcePack create(String uri, String hash) throws URISyntaxException { diff --git a/src/main/java/org/spongepowered/common/resourcepack/SpongeURIResourcePack.java b/src/main/java/org/spongepowered/common/resourcepack/SpongeURIResourcePack.java index 88081164b8a..2107577a810 100644 --- a/src/main/java/org/spongepowered/common/resourcepack/SpongeURIResourcePack.java +++ b/src/main/java/org/spongepowered/common/resourcepack/SpongeURIResourcePack.java @@ -56,12 +56,12 @@ public String getUrlString() { } @Override - public String getName() { + public String name() { return this.name; } @Override - public URI getUri() { + public URI uri() { return this.uri; } diff --git a/src/main/java/org/spongepowered/common/resourcepack/SpongeWorldResourcePack.java b/src/main/java/org/spongepowered/common/resourcepack/SpongeWorldResourcePack.java index d03228615b4..bf8ece4c771 100644 --- a/src/main/java/org/spongepowered/common/resourcepack/SpongeWorldResourcePack.java +++ b/src/main/java/org/spongepowered/common/resourcepack/SpongeWorldResourcePack.java @@ -58,7 +58,7 @@ public SpongeWorldResourcePack(final URI levelUri, @Nullable final String hash) } @Override - public String getName() { + public String name() { return "resourceszip"; } @@ -68,7 +68,7 @@ public String getUrlString() { } @Override - public URI getUri() { + public URI uri() { return this.uri; } diff --git a/src/main/java/org/spongepowered/common/scheduler/AsyncScheduler.java b/src/main/java/org/spongepowered/common/scheduler/AsyncScheduler.java index 991e229504f..b749cc844f8 100644 --- a/src/main/java/org/spongepowered/common/scheduler/AsyncScheduler.java +++ b/src/main/java/org/spongepowered/common/scheduler/AsyncScheduler.java @@ -78,7 +78,7 @@ private void mainLoop() { private void recalibrateMinimumTimeout() { this.lock.lock(); try { - final Set tasks = this.getTasks(); + final Set tasks = this.tasks(); this.minimumTimeout = Long.MAX_VALUE; final long now = System.nanoTime(); for (final ScheduledTask tmpTask : tasks) { @@ -182,7 +182,7 @@ public CompletableFuture submit(Callable callable) { public void close() { this.running = false; // Cancel all tasks - final Set tasks = this.getTasks(); + final Set tasks = this.tasks(); tasks.forEach(ScheduledTask::cancel); // Shut down the executor diff --git a/src/main/java/org/spongepowered/common/scheduler/ServerScheduler.java b/src/main/java/org/spongepowered/common/scheduler/ServerScheduler.java index b5b82c0d198..d6b2d805748 100644 --- a/src/main/java/org/spongepowered/common/scheduler/ServerScheduler.java +++ b/src/main/java/org/spongepowered/common/scheduler/ServerScheduler.java @@ -43,7 +43,7 @@ public ServerScheduler() { public void tick() { super.tick(); - for (final Player player : Sponge.getServer().getOnlinePlayers()) { + for (final Player player : Sponge.server().onlinePlayers()) { if (player instanceof net.minecraft.world.entity.player.Player) { // Detect Changes on PlayerInventories marked as dirty. ((InventoryBridge) ((net.minecraft.world.entity.player.Player) player).inventory).bridge$cleanupDirty(); diff --git a/src/main/java/org/spongepowered/common/scheduler/SpongeScheduledTask.java b/src/main/java/org/spongepowered/common/scheduler/SpongeScheduledTask.java index d883ceb62ff..bb7394a2f08 100644 --- a/src/main/java/org/spongepowered/common/scheduler/SpongeScheduledTask.java +++ b/src/main/java/org/spongepowered/common/scheduler/SpongeScheduledTask.java @@ -53,17 +53,17 @@ public final class SpongeScheduledTask implements ScheduledTask { } @Override - public UUID getUniqueId() { + public UUID uniqueId() { return this.id; } @Override - public String getName() { + public String name() { return this.name; } @Override - public Task getTask() { + public Task task() { return this.task; } diff --git a/src/main/java/org/spongepowered/common/scheduler/SpongeScheduler.java b/src/main/java/org/spongepowered/common/scheduler/SpongeScheduler.java index 16b9057ef53..4bd26bc63a0 100644 --- a/src/main/java/org/spongepowered/common/scheduler/SpongeScheduler.java +++ b/src/main/java/org/spongepowered/common/scheduler/SpongeScheduler.java @@ -88,7 +88,7 @@ protected long getTimestamp(SpongeScheduledTask task) { */ protected void addTask(final SpongeScheduledTask task) { task.setTimestamp(this.getTimestamp(task)); - this.taskMap.put(task.getUniqueId(), task); + this.taskMap.put(task.uniqueId(), task); } /** @@ -97,11 +97,11 @@ protected void addTask(final SpongeScheduledTask task) { * @param task The task to remove */ private void removeTask(final SpongeScheduledTask task) { - this.taskMap.remove(task.getUniqueId()); + this.taskMap.remove(task.uniqueId()); } @Override - public Optional getTaskById(UUID id) { + public Optional taskById(UUID id) { checkNotNull(id, "id"); synchronized (this.taskMap) { return Optional.ofNullable(this.taskMap.get(id)); @@ -109,14 +109,14 @@ public Optional getTaskById(UUID id) { } @Override - public Set getTasksByName(String pattern) { + public Set tasksByName(String pattern) { checkNotNull(pattern, "pattern"); final Pattern searchPattern = Pattern.compile(pattern); - final Set matchingTasks = this.getTasks(); + final Set matchingTasks = this.tasks(); final Iterator it = matchingTasks.iterator(); while (it.hasNext()) { - final Matcher matcher = searchPattern.matcher(it.next().getName()); + final Matcher matcher = searchPattern.matcher(it.next().name()); if (!matcher.matches()) { it.remove(); } @@ -126,22 +126,22 @@ public Set getTasksByName(String pattern) { } @Override - public Set getTasks() { + public Set tasks() { synchronized (this.taskMap) { return Sets.newHashSet(this.taskMap.values()); } } @Override - public Set getTasksByPlugin(PluginContainer plugin) { + public Set tasksByPlugin(PluginContainer plugin) { checkNotNull(plugin, "plugin"); final String testOwnerId = plugin.getMetadata().getId(); - final Set allTasks = this.getTasks(); + final Set allTasks = this.tasks(); final Iterator it = allTasks.iterator(); while (it.hasNext()) { - final String taskOwnerId = it.next().getOwner().getMetadata().getId(); + final String taskOwnerId = it.next().owner().getMetadata().getId(); if (!testOwnerId.equals(taskOwnerId)) { it.remove(); } @@ -160,7 +160,7 @@ public SpongeTaskExecutorService createExecutor(PluginContainer plugin) { public SpongeScheduledTask submit(Task task) { checkNotNull(task, "task"); final SpongeScheduledTask scheduledTask = new SpongeScheduledTask(this, (SpongeTask) task, - task.getName() + "-" + this.tag + "-#" + this.sequenceNumber++); + task.name() + "-" + this.tag + "-#" + this.sequenceNumber++); this.addTask(scheduledTask); return scheduledTask; } @@ -250,18 +250,18 @@ private void processTask(final SpongeScheduledTask task) { private void startTask(final SpongeScheduledTask task) { this.executeTaskRunnable(task, () -> { task.setState(SpongeScheduledTask.ScheduledTaskState.EXECUTING); - try (@Nullable final PhaseContext context = this.createContext(task, task.getOwner()); + try (@Nullable final PhaseContext context = this.createContext(task, task.owner()); final Timing timings = task.task.getTimingsHandler()) { timings.startTimingIfSync(); if (context != null) { context.buildAndSwitch(); } try { - SpongeCommon.setActivePlugin(task.getOwner()); - task.task.getConsumer().accept(task); + SpongeCommon.setActivePlugin(task.owner()); + task.task.consumer().accept(task); } catch (Throwable t) { SpongeCommon.getLogger().error("The Scheduler tried to run the task '{}' owned by '{}' but an error occurred.", - task.getName(), task.getOwner().getMetadata().getId(), t); + task.name(), task.owner().getMetadata().getId(), t); } } finally { if (!task.isCancelled()) { diff --git a/src/main/java/org/spongepowered/common/scheduler/SpongeTask.java b/src/main/java/org/spongepowered/common/scheduler/SpongeTask.java index ccf9a844cec..85e50f60ec0 100644 --- a/src/main/java/org/spongepowered/common/scheduler/SpongeTask.java +++ b/src/main/java/org/spongepowered/common/scheduler/SpongeTask.java @@ -64,27 +64,27 @@ public final class SpongeTask implements Task { } @Override - public String getName() { + public String name() { return this.name; } @Override - public PluginContainer getOwner() { + public PluginContainer owner() { return this.owner; } @Override - public Duration getDelay() { + public Duration delay() { return Duration.ofNanos(this.delay); } @Override - public Duration getInterval() { + public Duration interval() { return Duration.ofNanos(this.interval); } @Override - public Consumer getConsumer() { + public Consumer consumer() { return this.consumer; } @@ -149,10 +149,10 @@ public Task.Builder delay(final long delay, final TimeUnit unit) { @Override public Task.Builder delay(final Ticks delay) { Objects.requireNonNull(delay); - if (delay.getTicks() < 0) { + if (delay.ticks() < 0) { throw new IllegalArgumentException("Delay must be equal to or greater than zero!"); } - this.delay = delay.getTicks() * SpongeScheduler.TICK_DURATION_NS; + this.delay = delay.ticks() * SpongeScheduler.TICK_DURATION_NS; this.tickBasedDelay = true; return this; } @@ -194,10 +194,10 @@ public Task.Builder interval(final long interval, final TimeUnit unit) { @Override public Task.Builder interval(final Ticks interval) { Objects.requireNonNull(interval); - if (interval.getTicks() < 0) { + if (interval.ticks() < 0) { throw new IllegalArgumentException("Interval must be equal to or greater than zero!"); } - this.interval = interval.getTicks() * SpongeScheduler.TICK_DURATION_NS; + this.interval = interval.ticks() * SpongeScheduler.TICK_DURATION_NS; this.tickBasedInterval = true; return this; } @@ -222,8 +222,8 @@ public Task.Builder from(final Task value) { Objects.requireNonNull(value); final SpongeTask task = (SpongeTask) value; - this.consumer = value.getConsumer(); - this.plugin = task.getOwner(); + this.consumer = value.consumer(); + this.plugin = task.owner(); this.interval = task.interval; this.delay = task.delay; this.tickBasedDelay = task.tickBased; diff --git a/src/main/java/org/spongepowered/common/scheduler/SpongeTaskBuilder.java b/src/main/java/org/spongepowered/common/scheduler/SpongeTaskBuilder.java index af4306e75d0..8ba027db2af 100644 --- a/src/main/java/org/spongepowered/common/scheduler/SpongeTaskBuilder.java +++ b/src/main/java/org/spongepowered/common/scheduler/SpongeTaskBuilder.java @@ -77,8 +77,8 @@ public Task.Builder delay(final long delay, final TimeUnit unit) { @Override public Task.Builder delay(final Ticks delay) { - Preconditions.checkArgument(delay.getTicks() >= 0, "Delay cannot be negative"); - this.delay = delay.getTicks() * SpongeScheduler.TICK_DURATION_NS; + Preconditions.checkArgument(delay.ticks() >= 0, "Delay cannot be negative"); + this.delay = delay.ticks() * SpongeScheduler.TICK_DURATION_NS; this.tickBasedDelay = true; return this; } @@ -115,8 +115,8 @@ public Task.Builder interval(final long interval, final TimeUnit unit) { @Override public Task.Builder interval(final Ticks interval) { - Preconditions.checkArgument(interval.getTicks() >= 0, "Interval cannot be negative"); - this.interval = interval.getTicks() * SpongeScheduler.TICK_DURATION_NS; + Preconditions.checkArgument(interval.ticks() >= 0, "Interval cannot be negative"); + this.interval = interval.ticks() * SpongeScheduler.TICK_DURATION_NS; this.tickBasedInterval = true; return this; } @@ -152,8 +152,8 @@ public Task build() { @Override public Task.Builder from(final Task value) { final SpongeTask task = (SpongeTask) value; - this.consumer = value.getConsumer(); - this.plugin = task.getOwner(); + this.consumer = value.consumer(); + this.plugin = task.owner(); this.interval = task.interval; this.delay = task.delay; this.tickBasedDelay = task.tickBased; diff --git a/src/main/java/org/spongepowered/common/scheduler/SpongeTaskExecutorService.java b/src/main/java/org/spongepowered/common/scheduler/SpongeTaskExecutorService.java index 892f823dbe1..3efb8ecb0c4 100644 --- a/src/main/java/org/spongepowered/common/scheduler/SpongeTaskExecutorService.java +++ b/src/main/java/org/spongepowered/common/scheduler/SpongeTaskExecutorService.java @@ -208,13 +208,13 @@ private static class LanternScheduledFuture implements org.spongepowered.api. } @Override - public ScheduledTask getTask() { + public ScheduledTask task() { return this.task; } @Override public boolean isPeriodic() { - final Duration interval = this.task.task.getInterval(); + final Duration interval = this.task.task.interval(); return interval.toMillis() > 0; } @@ -229,7 +229,7 @@ public long getDelay(TimeUnit unit) { @SuppressWarnings("rawtypes") @Override public int compareTo(Delayed other) { - // Since getDelay may return different values for each call, + // Since delay may return different values for each call, // this check is required to correctly implement Comparable if (other == this) { return 0; @@ -241,7 +241,7 @@ public int compareTo(Delayed other) { final SpongeScheduledTask otherTask = ((LanternScheduledFuture) other).task; return ComparisonChain.start() .compare(this.task.nextExecutionTimestamp(), otherTask.nextExecutionTimestamp()) - .compare(this.task.getUniqueId(), otherTask.getUniqueId()) + .compare(this.task.uniqueId(), otherTask.uniqueId()) .result(); } diff --git a/src/main/java/org/spongepowered/common/scoreboard/SpongeDisplaySlot.java b/src/main/java/org/spongepowered/common/scoreboard/SpongeDisplaySlot.java index 07a42c543e5..ba72b85372b 100644 --- a/src/main/java/org/spongepowered/common/scoreboard/SpongeDisplaySlot.java +++ b/src/main/java/org/spongepowered/common/scoreboard/SpongeDisplaySlot.java @@ -60,7 +60,7 @@ public DisplaySlot withTeamColor(@Nullable final NamedTextColor color) { } @Override - public Optional getTeamColor() { + public Optional teamColor() { if (this.color == null) { this.color = SpongeAdventure.asAdventureNamed(this.formatting); } diff --git a/src/main/java/org/spongepowered/common/scoreboard/SpongeObjective.java b/src/main/java/org/spongepowered/common/scoreboard/SpongeObjective.java index f6535912dc8..d7ef674b51c 100644 --- a/src/main/java/org/spongepowered/common/scoreboard/SpongeObjective.java +++ b/src/main/java/org/spongepowered/common/scoreboard/SpongeObjective.java @@ -70,12 +70,12 @@ public SpongeObjective(final String name, final Criterion criterion) { } @Override - public String getName() { + public String name() { return this.name; } @Override - public Component getDisplayName() { + public Component displayName() { return this.displayName; } @@ -86,12 +86,12 @@ public void setDisplayName(final Component displayName) throws IllegalArgumentEx } @Override - public Criterion getCriterion() { + public Criterion criterion() { return this.criterion; } @Override - public ObjectiveDisplayMode getDisplayMode() { + public ObjectiveDisplayMode displayMode() { return this.displayMode; } @@ -103,7 +103,7 @@ public void setDisplayMode(final ObjectiveDisplayMode displayMode) { } @Override - public Map getScores() { + public Map scores() { return new HashMap<>(this.scores); } @@ -114,11 +114,11 @@ public boolean hasScore(final Component name) { @Override public void addScore(final Score score) throws IllegalArgumentException { - if (this.scores.containsKey(score.getName())) { + if (this.scores.containsKey(score.name())) { throw new IllegalArgumentException(String.format("A score with the name %s already exists!", - SpongeAdventure.legacySection(score.getName()))); + SpongeAdventure.legacySection(score.name()))); } - this.scores.put(score.getName(), score); + this.scores.put(score.name(), score); final SpongeScore spongeScore = (SpongeScore) score; for (final net.minecraft.world.scores.Objective objective: this.objectives.values()) { @@ -127,12 +127,12 @@ public void addScore(final Score score) throws IllegalArgumentException { } @Override - public Optional getScore(final Component name) { + public Optional score(final Component name) { return Optional.ofNullable(this.scores.get(name)); } @Override - public Score getOrCreateScore(final Component name) { + public Score orCreateScore(final Component name) { if (this.scores.containsKey(name)) { return this.scores.get(name); } @@ -146,7 +146,7 @@ public Score getOrCreateScore(final Component name) { public boolean removeScore(final Score spongeScore) { final String name = ((SpongeScore) spongeScore).legacyName; - if (!this.scores.containsKey(spongeScore.getName())) { + if (!this.scores.containsKey(spongeScore.name())) { return false; } @@ -173,18 +173,18 @@ public boolean removeScore(final Score spongeScore) { ((SpongeScore) spongeScore).removeScoreFor(objective); } - this.scores.remove(spongeScore.getName()); + this.scores.remove(spongeScore.name()); return true; } @Override public boolean removeScore(final Component name) { - final Optional score = this.getScore(name); + final Optional score = this.score(name); return score.filter(this::removeScore).isPresent(); } @Override - public Set getScoreboards() { + public Set scoreboards() { return (Set) (Set) new HashSet<>(this.objectives.keySet()); } @@ -203,7 +203,7 @@ private void updateDisplayName() { public void updateScores(final net.minecraft.world.scores.Scoreboard scoreboard) { final net.minecraft.world.scores.Objective objective = this.getObjectiveFor(scoreboard); - for (final Score score: this.getScores().values()) { + for (final Score score: this.scores().values()) { final SpongeScore spongeScore = (SpongeScore) score; this.addScoreToScoreboard(scoreboard, spongeScore.getScoreFor(objective)); } @@ -283,10 +283,10 @@ public Objective.Builder objectiveDisplayMode(final ObjectiveDisplayMode objecti public Objective.Builder from(final Objective value) { Objects.requireNonNull(value); - this.name = value.getName(); - this.displayName = value.getDisplayName(); - this.criterion = value.getCriterion(); - this.objectiveDisplayMode = value.getDisplayMode(); + this.name = value.name(); + this.displayName = value.displayName(); + this.criterion = value.criterion(); + this.objectiveDisplayMode = value.displayMode(); return this; } diff --git a/src/main/java/org/spongepowered/common/scoreboard/SpongeScore.java b/src/main/java/org/spongepowered/common/scoreboard/SpongeScore.java index b652f60e236..61ed1d28e0f 100644 --- a/src/main/java/org/spongepowered/common/scoreboard/SpongeScore.java +++ b/src/main/java/org/spongepowered/common/scoreboard/SpongeScore.java @@ -57,12 +57,12 @@ public SpongeScore(final Component name) { } @Override - public Component getName() { + public Component name() { return this.name; } @Override - public int getScore() { + public int score() { return this.score; } @@ -96,7 +96,7 @@ private void updateScore() { } @Override - public Set getObjectives() { + public Set objectives() { final Set objectives = new HashSet<>(); for (final net.minecraft.world.scores.Objective objective: this.scores.keySet()) { objectives.add(((ObjectiveBridge) objective).bridge$getSpongeObjective()); diff --git a/src/main/java/org/spongepowered/common/scoreboard/builder/SpongeScoreboardBuilder.java b/src/main/java/org/spongepowered/common/scoreboard/builder/SpongeScoreboardBuilder.java index 85d507ea474..453bab99097 100644 --- a/src/main/java/org/spongepowered/common/scoreboard/builder/SpongeScoreboardBuilder.java +++ b/src/main/java/org/spongepowered/common/scoreboard/builder/SpongeScoreboardBuilder.java @@ -54,8 +54,8 @@ public Scoreboard.Builder teams(List teams) { @Override public Scoreboard.Builder from(Scoreboard value) { - this.objectives = new ArrayList<>(value.getObjectives()); - this.teams = new ArrayList<>(value.getTeams()); + this.objectives = new ArrayList<>(value.objectives()); + this.teams = new ArrayList<>(value.teams()); return this; } diff --git a/src/main/java/org/spongepowered/common/scoreboard/builder/SpongeTeamBuilder.java b/src/main/java/org/spongepowered/common/scoreboard/builder/SpongeTeamBuilder.java index bd4044e2f87..13cf1b41109 100644 --- a/src/main/java/org/spongepowered/common/scoreboard/builder/SpongeTeamBuilder.java +++ b/src/main/java/org/spongepowered/common/scoreboard/builder/SpongeTeamBuilder.java @@ -139,17 +139,17 @@ public Team.Builder members(final Set members) { @Override public Team.Builder from(final Team value) { - this.name(value.getName()) - .displayName(value.getDisplayName()) - .prefix(value.getPrefix()) - .color(value.getColor()) + this.name(value.name()) + .displayName(value.displayName()) + .prefix(value.prefix()) + .color(value.color()) .allowFriendlyFire(value.allowFriendlyFire()) .canSeeFriendlyInvisibles(value.canSeeFriendlyInvisibles()) - .suffix(value.getSuffix()) - .nameTagVisibility(value.getNameTagVisibility()) - .deathTextVisibility(value.getDeathMessageVisibility()) - .collisionRule(value.getCollisionRule()) - .members(value.getMembers()); + .suffix(value.suffix()) + .nameTagVisibility(value.nameTagVisibility()) + .deathTextVisibility(value.deathMessageVisibility()) + .collisionRule(value.collisionRule()) + .members(value.members()); return this; } diff --git a/src/main/java/org/spongepowered/common/server/BootstrapProperties.java b/src/main/java/org/spongepowered/common/server/BootstrapProperties.java index 8f0d73cc544..bcf045dfea0 100644 --- a/src/main/java/org/spongepowered/common/server/BootstrapProperties.java +++ b/src/main/java/org/spongepowered/common/server/BootstrapProperties.java @@ -54,8 +54,8 @@ public final class BootstrapProperties { public static void init(final WorldGenSettings dimensionGeneratorSettings, final GameType gameType, final net.minecraft.world.Difficulty difficulty, final boolean pvp, final boolean hardcore, final boolean commands, final int viewDistance, final RegistryAccess registries) { BootstrapProperties.dimensionGeneratorSettings = dimensionGeneratorSettings; - BootstrapProperties.gameMode = RegistryKey.of(RegistryTypes.GAME_MODE, ResourceKey.sponge(gameType.getName())).asDefaultedReference(() -> Sponge.getGame().registries()); - BootstrapProperties.difficulty = RegistryKey.of(RegistryTypes.DIFFICULTY, ResourceKey.sponge(difficulty.getKey())).asDefaultedReference(() -> Sponge.getGame().registries()); + BootstrapProperties.gameMode = RegistryKey.of(RegistryTypes.GAME_MODE, ResourceKey.sponge(gameType.getName())).asDefaultedReference(() -> Sponge.game().registries()); + BootstrapProperties.difficulty = RegistryKey.of(RegistryTypes.DIFFICULTY, ResourceKey.sponge(difficulty.getKey())).asDefaultedReference(() -> Sponge.game().registries()); BootstrapProperties.pvp = pvp; BootstrapProperties.hardcore = hardcore; BootstrapProperties.commands = commands; diff --git a/src/main/java/org/spongepowered/common/server/ServerConsoleSystemSubject.java b/src/main/java/org/spongepowered/common/server/ServerConsoleSystemSubject.java index e13e6c94dae..16bbea25a14 100644 --- a/src/main/java/org/spongepowered/common/server/ServerConsoleSystemSubject.java +++ b/src/main/java/org/spongepowered/common/server/ServerConsoleSystemSubject.java @@ -45,7 +45,7 @@ public final class ServerConsoleSystemSubject extends SpongeSystemSubject implements CommandSourceProviderBridge, CommandSource, CommandSourceBridge { @Override - public String getIdentifier() { + public String identifier() { return "console"; } diff --git a/src/main/java/org/spongepowered/common/service/SpongeServiceProvider.java b/src/main/java/org/spongepowered/common/service/SpongeServiceProvider.java index 81eeaf8ef25..803bacf5207 100644 --- a/src/main/java/org/spongepowered/common/service/SpongeServiceProvider.java +++ b/src/main/java/org/spongepowered/common/service/SpongeServiceProvider.java @@ -40,7 +40,6 @@ import org.spongepowered.common.event.SpongeEventManager; import org.spongepowered.common.event.lifecycle.AbstractProvideServiceEventImpl; import org.spongepowered.common.launch.Launch; -import org.spongepowered.common.service.SpongeServiceProvider.Registration; import org.spongepowered.common.util.PrettyPrinter; import org.spongepowered.plugin.PluginContainer; @@ -84,7 +83,7 @@ public final Optional provide(@NonNull final Class serviceClass) { @Override @NonNull @SuppressWarnings("unchecked") - public final Optional> getRegistration(@NonNull final Class serviceClass) { + public final Optional> registration(@NonNull final Class serviceClass) { return Optional.ofNullable((ServiceRegistration) this.services.get(serviceClass)); } @@ -126,7 +125,7 @@ public final void init() { Registration registration = null; if (isSpecific) { final Optional specificPluginContainer = - Launch.getInstance().getPluginManager().getPlugin(pluginId); + Launch.getInstance().getPluginManager().plugin(pluginId); if (specificPluginContainer.isPresent()) { registration = this.getSpecificRegistration(specificPluginContainer.get(), candidate); if (registration == null) { @@ -173,7 +172,7 @@ public final void init() { prettyPrinter.log(SpongeCommon.getLogger(), Level.ERROR); } } else { - final Collection toQuery = Launch.getInstance().getPluginManager().getPlugins(); + final Collection toQuery = Launch.getInstance().getPluginManager().plugins(); registration = this.attemptRegistration(toQuery, candidate); } @@ -216,7 +215,7 @@ private Registration getSpecificRegistration(final PluginContainer contai // This is the actual query - a generic event. final AbstractProvideServiceEventImpl event = this.createEvent(container, service); try { - ((SpongeEventManager) this.getGame().getEventManager()).post(event, container); + ((SpongeEventManager) this.getGame().eventManager()).post(event, container); } catch (final Exception ex) { ex.printStackTrace(); } diff --git a/src/main/java/org/spongepowered/common/service/game/pagination/SpongePaginationBuilder.java b/src/main/java/org/spongepowered/common/service/game/pagination/SpongePaginationBuilder.java index 5329166f955..2dadf88c971 100644 --- a/src/main/java/org/spongepowered/common/service/game/pagination/SpongePaginationBuilder.java +++ b/src/main/java/org/spongepowered/common/service/game/pagination/SpongePaginationBuilder.java @@ -122,11 +122,11 @@ public PaginationList build() { @Override public PaginationList.Builder from(final PaginationList list) { this.reset(); - this.contents = list.getContents(); - this.title = list.getTitle().orElse(null); - this.header = list.getHeader().orElse(null); - this.footer = list.getFooter().orElse(null); - this.paginationSpacer = list.getPadding(); + this.contents = list.contents(); + this.title = list.title().orElse(null); + this.header = list.header().orElse(null); + this.footer = list.footer().orElse(null); + this.paginationSpacer = list.padding(); this.paginationList = null; return this; diff --git a/src/main/java/org/spongepowered/common/service/game/pagination/SpongePaginationList.java b/src/main/java/org/spongepowered/common/service/game/pagination/SpongePaginationList.java index 800f5c42809..6bb97e6f0bb 100644 --- a/src/main/java/org/spongepowered/common/service/game/pagination/SpongePaginationList.java +++ b/src/main/java/org/spongepowered/common/service/game/pagination/SpongePaginationList.java @@ -72,32 +72,32 @@ public SpongePaginationList( } @Override - public Iterable getContents() { + public Iterable contents() { return this.contents; } @Override - public Optional getTitle() { + public Optional title() { return Optional.ofNullable(this.title); } @Override - public Optional getHeader() { + public Optional header() { return Optional.ofNullable(this.header); } @Override - public Optional getFooter() { + public Optional footer() { return Optional.ofNullable(this.footer); } @Override - public Component getPadding() { + public Component padding() { return this.paginationSpacer; } @Override - public int getLinesPerPage() { + public int linesPerPage() { return this.linesPerPage; } @@ -120,8 +120,8 @@ public void sendTo(final Audience receiver, final int page) { // Thus, we use a supplier to supply the player from the server, if required. final Supplier> audienceSupplier; if (receiver instanceof Player) { - final UUID playerUuid = ((Player) receiver).getUniqueId(); - audienceSupplier = () -> Sponge.getServer().getPlayer(playerUuid); + final UUID playerUuid = ((Player) receiver).uniqueId(); + audienceSupplier = () -> Sponge.server().player(playerUuid); } else { final WeakReference srcReference = new WeakReference<>(receiver); audienceSupplier = () -> Optional.ofNullable(srcReference.get()); diff --git a/src/main/java/org/spongepowered/common/service/game/pagination/SpongePaginationService.java b/src/main/java/org/spongepowered/common/service/game/pagination/SpongePaginationService.java index 7c4779cca07..371722f5b72 100644 --- a/src/main/java/org/spongepowered/common/service/game/pagination/SpongePaginationService.java +++ b/src/main/java/org/spongepowered/common/service/game/pagination/SpongePaginationService.java @@ -124,30 +124,30 @@ private SourcePaginations getPaginationStateForNonPlayer(final Audience source, @Nullable private SourcePaginations getPaginationStateForPlayer(final Player source, final boolean create) { - return this.playerActivePaginations.get(source.getUniqueId(), k -> create ? new SourcePaginations() : null); + return this.playerActivePaginations.get(source.uniqueId(), k -> create ? new SourcePaginations() : null); } public Command.Parameterized createPaginationCommand() { final Parameter.Value paginationIdParameter = Parameter.builder(ActivePagination.class) - .parser(new ActivePaginationParameter()) - .setKey("pagination-id") + .addParser(new ActivePaginationParameter()) + .key("pagination-id") .build(); final Command.Parameterized next = Command.builder() - .setShortDescription(Component.text("Go to the next page")) - .setExecutor((context) -> { + .shortDescription(Component.text("Go to the next page")) + .executor((context) -> { context.requireOne(paginationIdParameter).nextPage(); return CommandResult.success(); }).build(); final Command.Parameterized prev = Command.builder() - .setShortDescription(Component.text("Go to the previous page")) - .setExecutor((context) -> { + .shortDescription(Component.text("Go to the previous page")) + .executor((context) -> { context.requireOne(paginationIdParameter).previousPage(); return CommandResult.success(); }).build(); - final Parameter.Value pageParameter = Parameter.integerNumber().setKey("page").build(); + final Parameter.Value pageParameter = Parameter.integerNumber().key("page").build(); final CommandExecutor pageExecutor = (context) -> { context.requireOne(paginationIdParameter).specificPage(context.requireOne(pageParameter)); @@ -155,38 +155,38 @@ public Command.Parameterized createPaginationCommand() { }; final Command.Parameterized page = Command.builder() - .setShortDescription(Component.text("Go to a specific page")) - .parameter(pageParameter) - .setExecutor(pageExecutor) + .shortDescription(Component.text("Go to a specific page")) + .addParameter(pageParameter) + .executor(pageExecutor) .build(); return Command.builder() - .parameters(paginationIdParameter, Parameter.firstOf(pageParameter, + .addParameters(paginationIdParameter, Parameter.firstOf(pageParameter, Parameter.subcommand(next, "next", "n"), Parameter.subcommand(prev, "prev", "p", "previous"), Parameter.subcommand(page, "page"))) - .child(page, "page") - .setShortDescription(Component.text("Helper command for paginations occurring")) - .setExecutor(pageExecutor) + .addChild(page, "page") + .shortDescription(Component.text("Helper command for paginations occurring")) + .executor(pageExecutor) .build(); } private final class ActivePaginationParameter implements ValueParameter, ValueCompleter { @Override - public Optional getValue(final Parameter.Key parameterKey, + public Optional parseValue(final Parameter.Key parameterKey, final ArgumentReader.Mutable reader, final CommandContext.Builder context) throws ArgumentParseException { - final Audience source = context.getCause().getAudience(); + final Audience source = context.cause().audience(); final SourcePaginations paginations = SpongePaginationService.this.getPaginationState(source, false); if (paginations == null) { - final String name = source instanceof Nameable ? ((Nameable) source).getName() : source.toString(); + final String name = source instanceof Nameable ? ((Nameable) source).name() : source.toString(); throw reader.createException(Component.text(String.format("Source %s has no paginations!", name))); } final UUID id; - final ArgumentReader.Immutable state = reader.getImmutable(); + final ArgumentReader.Immutable state = reader.immutable(); try { id = UUID.fromString(reader.parseString()); } catch (final IllegalArgumentException ex) { @@ -205,7 +205,7 @@ public Optional getValue(final Parameter.Key complete(final CommandContext context, final String input) { - final Audience audience = context.getCause().getAudience(); + final Audience audience = context.cause().audience(); final SourcePaginations paginations = SpongePaginationService.this.getPaginationState(audience, false); if (paginations != null) { return paginations.keys().stream().map(Object::toString).filter(x -> x.startsWith(input)).collect(Collectors.toList()); diff --git a/src/main/java/org/spongepowered/common/service/server/ban/SpongeBanService.java b/src/main/java/org/spongepowered/common/service/server/ban/SpongeBanService.java index 923ef9e63ff..21ea76ee82e 100644 --- a/src/main/java/org/spongepowered/common/service/server/ban/SpongeBanService.java +++ b/src/main/java/org/spongepowered/common/service/server/ban/SpongeBanService.java @@ -67,9 +67,9 @@ public final class SpongeBanService implements BanService { @Override - public CompletableFuture> getBans() { - final Collection bans = this.getProfileBans().join(); - final Collection ipBans = this.getIpBans().join(); + public CompletableFuture> bans() { + final Collection bans = this.profileBans().join(); + final Collection ipBans = this.ipBans().join(); final Collection list = new ArrayList<>(bans.size() + ipBans.size()); list.addAll(bans); list.addAll(ipBans); @@ -78,7 +78,7 @@ public CompletableFuture> getBans() { @SuppressWarnings("unchecked") @Override - public CompletableFuture> getProfileBans() { + public CompletableFuture> profileBans() { final StoredUserListAccessor accessor = (StoredUserListAccessor) this.getUserBanList(); accessor.invoker$removeExpired(); @@ -87,7 +87,7 @@ public CompletableFuture> getProfileBans() { @SuppressWarnings("unchecked") @Override - public CompletableFuture> getIpBans() { + public CompletableFuture> ipBans() { final StoredUserListAccessor accessor = ((StoredUserListAccessor) this.getIPBanList()); accessor.invoker$removeExpired(); return CompletableFuture.completedFuture(Collections.unmodifiableCollection(new ArrayList<>((Collection) (Object) accessor.accessor$map().values()))); @@ -95,7 +95,7 @@ public CompletableFuture> getIpBans() { @SuppressWarnings("unchecked") @Override - public CompletableFuture> getBanFor(final GameProfile profile) { + public CompletableFuture> banFor(final GameProfile profile) { final StoredUserListAccessor accessor = (StoredUserListAccessor) this.getUserBanList(); accessor.invoker$removeExpired(); @@ -104,7 +104,7 @@ public CompletableFuture> getBanFor(final GameProfile prof @SuppressWarnings("unchecked") @Override - public CompletableFuture> getBanFor(final InetAddress address) { + public CompletableFuture> banFor(final InetAddress address) { final StoredUserListAccessor accessor = ((StoredUserListAccessor) this.getIPBanList()); accessor.invoker$removeExpired(); @@ -133,7 +133,7 @@ public CompletableFuture isBanned(final InetAddress address) { @SuppressWarnings("unchecked") @Override public CompletableFuture pardon(final GameProfile profile) { - final CompletableFuture> ban = this.getBanFor(profile); + final CompletableFuture> ban = this.banFor(profile); final StoredUserListAccessor accessor = (StoredUserListAccessor) this.getUserBanList(); accessor.invoker$removeExpired(); @@ -143,7 +143,7 @@ public CompletableFuture pardon(final GameProfile profile) { @SuppressWarnings("unchecked") @Override public CompletableFuture pardon(final InetAddress address) { - final CompletableFuture> ban = this.getBanFor(address); + final CompletableFuture> ban = this.banFor(address); final StoredUserListAccessor accessor = ((StoredUserListAccessor) this.getIPBanList()); accessor.invoker$removeExpired(); return CompletableFuture.completedFuture(ban.join().isPresent() && this.removeBan(ban.join().get()).join()); @@ -154,51 +154,51 @@ public CompletableFuture removeBan(final Ban ban) { if (!this.hasBan(ban).join()) { return CompletableFuture.completedFuture(false); } - if (ban.getType().equals(BanTypes.PROFILE.get())) { - final User user = Sponge.getServer().getUserManager().getOrCreate(((Ban.Profile) ban).getProfile()); - Sponge.getEventManager().post(SpongeEventFactory.createPardonUserEvent(PhaseTracker.getCauseStackManager().getCurrentCause(), (Ban.Profile) ban, user)); + if (ban.type().equals(BanTypes.PROFILE.get())) { + final User user = Sponge.server().userManager().findOrCreate(((Ban.Profile) ban).profile()); + Sponge.eventManager().post(SpongeEventFactory.createPardonUserEvent(PhaseTracker.getCauseStackManager().currentCause(), (Ban.Profile) ban, user)); - UserListUtil.removeEntry(this.getUserBanList(), SpongeGameProfile.toMcProfile(((Ban.Profile) ban).getProfile())); + UserListUtil.removeEntry(this.getUserBanList(), SpongeGameProfile.toMcProfile(((Ban.Profile) ban).profile())); return CompletableFuture.completedFuture(true); - } else if (ban.getType().equals(BanTypes.IP.get())) { - Sponge.getEventManager().post(SpongeEventFactory.createPardonIpEvent(PhaseTracker.getCauseStackManager().getCurrentCause(), (Ban.IP) ban)); + } else if (ban.type().equals(BanTypes.IP.get())) { + Sponge.eventManager().post(SpongeEventFactory.createPardonIpEvent(PhaseTracker.getCauseStackManager().currentCause(), (Ban.IP) ban)); - final InetSocketAddress inetSocketAddress = new InetSocketAddress(((Ban.IP) ban).getAddress(), 0); + final InetSocketAddress inetSocketAddress = new InetSocketAddress(((Ban.IP) ban).address(), 0); UserListUtil.removeEntry(this.getIPBanList(), ((IpBanListAccessor) this.getIPBanList()).invoker$getIpFromAddress(inetSocketAddress)); return CompletableFuture.completedFuture(true); } - throw new IllegalArgumentException(String.format("Ban %s had unrecognized BanType %s!", ban, ban.getType())); + throw new IllegalArgumentException(String.format("Ban %s had unrecognized BanType %s!", ban, ban.type())); } @Override public CompletableFuture> addBan(final Ban ban) { final Ban prevBan; - if (ban.getType().equals(BanTypes.PROFILE.get())) { + if (ban.type().equals(BanTypes.PROFILE.get())) { - final User user = Sponge.getServer().getUserManager().getOrCreate(((Ban.Profile) ban).getProfile()); - Sponge.getEventManager().post(SpongeEventFactory.createBanUserEvent(PhaseTracker.getCauseStackManager().getCurrentCause(), (Ban.Profile) ban, user)); + final User user = Sponge.server().userManager().findOrCreate(((Ban.Profile) ban).profile()); + Sponge.eventManager().post(SpongeEventFactory.createBanUserEvent(PhaseTracker.getCauseStackManager().currentCause(), (Ban.Profile) ban, user)); prevBan = (Ban) UserListUtil.addEntry(this.getUserBanList(), (StoredUserEntry) ban); - } else if (ban.getType().equals(BanTypes.IP.get())) { + } else if (ban.type().equals(BanTypes.IP.get())) { - Sponge.getEventManager().post(SpongeEventFactory.createBanIpEvent(PhaseTracker.getCauseStackManager().getCurrentCause(), (Ban.IP) ban)); + Sponge.eventManager().post(SpongeEventFactory.createBanIpEvent(PhaseTracker.getCauseStackManager().currentCause(), (Ban.IP) ban)); prevBan = (Ban) UserListUtil.addEntry(this.getIPBanList(), (StoredUserEntry) ban); } else { - throw new IllegalArgumentException(String.format("Ban %s had unrecognized BanType %s!", ban, ban.getType())); + throw new IllegalArgumentException(String.format("Ban %s had unrecognized BanType %s!", ban, ban.type())); } return CompletableFuture.completedFuture(Optional.ofNullable(prevBan)); } @Override public CompletableFuture hasBan(final Ban ban) { - if (ban.getType().equals(BanTypes.PROFILE.get())) { - return this.isBanned(((Ban.Profile) ban).getProfile()); - } else if (ban.getType().equals(BanTypes.IP.get())) { - return this.isBanned(((Ban.IP) ban).getAddress()); + if (ban.type().equals(BanTypes.PROFILE.get())) { + return this.isBanned(((Ban.Profile) ban).profile()); + } else if (ban.type().equals(BanTypes.IP.get())) { + return this.isBanned(((Ban.IP) ban).address()); } - throw new IllegalArgumentException(String.format("Ban %s had unrecognized BanType %s!", ban, ban.getType())); + throw new IllegalArgumentException(String.format("Ban %s had unrecognized BanType %s!", ban, ban.type())); } private UserBanList getUserBanList() { diff --git a/src/main/java/org/spongepowered/common/service/server/ban/SpongeIPBanList.java b/src/main/java/org/spongepowered/common/service/server/ban/SpongeIPBanList.java index 297df7bce64..e781b11bdbb 100644 --- a/src/main/java/org/spongepowered/common/service/server/ban/SpongeIPBanList.java +++ b/src/main/java/org/spongepowered/common/service/server/ban/SpongeIPBanList.java @@ -59,7 +59,7 @@ protected boolean contains(final String entry) { } try { - return Sponge.getServer().getServiceProvider().banService().isBanned(InetAddress.getByName(entry)).join(); + return Sponge.server().serviceProvider().banService().isBanned(InetAddress.getByName(entry)).join(); } catch (final UnknownHostException e) { throw new IllegalArgumentException("Error parsing Ban IP address!", e); } @@ -72,7 +72,7 @@ protected boolean contains(final String entry) { } try { - return (IpBanListEntry) Sponge.getServer().getServiceProvider().banService().getBanFor(InetAddress.getByName(obj)).join().orElse(null); + return (IpBanListEntry) Sponge.server().serviceProvider().banService().banFor(InetAddress.getByName(obj)).join().orElse(null); } catch (final UnknownHostException e) { throw new IllegalArgumentException("Error parsing Ban IP address!", e); } @@ -85,7 +85,7 @@ public void remove(final String entry) { } try { - Sponge.getServer().getServiceProvider().banService().pardon(InetAddress.getByName(entry)); + Sponge.server().serviceProvider().banService().pardon(InetAddress.getByName(entry)); } catch (final UnknownHostException e) { throw new IllegalArgumentException("Error parsing Ban IP address!", e); } @@ -94,20 +94,20 @@ public void remove(final String entry) { @Override public String[] getUserList() { final List ips = new ArrayList<>(); - for (final Ban.IP ban : Sponge.getServer().getServiceProvider().banService().getIpBans().join()) { - ips.add(this.getIpFromAddress(new InetSocketAddress(ban.getAddress(), 0))); + for (final Ban.IP ban : Sponge.server().serviceProvider().banService().ipBans().join()) { + ips.add(this.getIpFromAddress(new InetSocketAddress(ban.address(), 0))); } return ips.toArray(new String[0]); } @Override public void add(final IpBanListEntry entry) { - Sponge.getServer().getServiceProvider().banService().addBan((Ban) entry); + Sponge.server().serviceProvider().banService().addBan((Ban) entry); } @Override public boolean isEmpty() { - return Sponge.getServer().getServiceProvider().banService().getIpBans().join().isEmpty(); + return Sponge.server().serviceProvider().banService().ipBans().join().isEmpty(); } /** diff --git a/src/main/java/org/spongepowered/common/service/server/ban/SpongeUserBanList.java b/src/main/java/org/spongepowered/common/service/server/ban/SpongeUserBanList.java index 3b5cf2c38a6..800834f58a8 100644 --- a/src/main/java/org/spongepowered/common/service/server/ban/SpongeUserBanList.java +++ b/src/main/java/org/spongepowered/common/service/server/ban/SpongeUserBanList.java @@ -33,7 +33,6 @@ import java.util.ArrayList; import java.util.List; -import javax.annotation.Nullable; import net.minecraft.server.players.UserBanList; import net.minecraft.server.players.UserBanListEntry; @@ -48,37 +47,37 @@ public SpongeUserBanList(final File file) { @Override protected boolean contains(final com.mojang.authlib.GameProfile profile) { - return Sponge.getServer().getServiceProvider().banService().isBanned(SpongeGameProfile.of(profile)).join(); + return Sponge.server().serviceProvider().banService().isBanned(SpongeGameProfile.of(profile)).join(); } @Override public UserBanListEntry get(final com.mojang.authlib.GameProfile profile) { - return (UserBanListEntry) Sponge.getServer().getServiceProvider().banService().getBanFor(SpongeGameProfile.of(profile)).join().orElse(null); + return (UserBanListEntry) Sponge.server().serviceProvider().banService().banFor(SpongeGameProfile.of(profile)).join().orElse(null); } @Override public String[] getUserList() { final List names = new ArrayList<>(); - for (final Ban.Profile ban : Sponge.getServer().getServiceProvider().banService().getProfileBans().join()) { - ban.getProfile().getName().ifPresent(names::add); + for (final Ban.Profile ban : Sponge.server().serviceProvider().banService().profileBans().join()) { + ban.profile().name().ifPresent(names::add); } return names.toArray(new String[names.size()]); } @Override public void add(final UserBanListEntry entry) { - Sponge.getServer().getServiceProvider().banService().addBan((Ban) entry); + Sponge.server().serviceProvider().banService().addBan((Ban) entry); } @Override public boolean isEmpty() { - return Sponge.getServer().getServiceProvider().banService().getProfileBans().join().isEmpty(); + return Sponge.server().serviceProvider().banService().profileBans().join().isEmpty(); } @Override public void remove(final com.mojang.authlib.GameProfile entry) { - Sponge.getServer().getServiceProvider().banService().pardon(SpongeGameProfile.of(entry)); + Sponge.server().serviceProvider().banService().pardon(SpongeGameProfile.of(entry)); } } diff --git a/src/main/java/org/spongepowered/common/service/server/permission/BridgeSubject.java b/src/main/java/org/spongepowered/common/service/server/permission/BridgeSubject.java index a9d177eece6..38e5ff7e36f 100644 --- a/src/main/java/org/spongepowered/common/service/server/permission/BridgeSubject.java +++ b/src/main/java/org/spongepowered/common/service/server/permission/BridgeSubject.java @@ -57,37 +57,37 @@ default boolean isSubjectDataPersisted() { } @Override - default Set getActiveContexts() { + default Set activeContexts() { return ((SubjectBridge) this).bridge$resolveOptional() - .map(Subject::getActiveContexts) + .map(Subject::activeContexts) .orElseGet(Collections::emptySet); } @Override - default Optional getFriendlyIdentifier() { + default Optional friendlyIdentifier() { return ((SubjectBridge) this).bridge$resolveOptional() - .flatMap(Contextual::getFriendlyIdentifier); + .flatMap(Contextual::friendlyIdentifier); } @Override - default SubjectCollection getContainingCollection() { - return ((SubjectBridge) this).bridge$resolve().getContainingCollection(); + default SubjectCollection containingCollection() { + return ((SubjectBridge) this).bridge$resolve().containingCollection(); } @Override - default SubjectData getSubjectData() { - return ((SubjectBridge) this).bridge$resolve().getSubjectData(); + default SubjectData subjectData() { + return ((SubjectBridge) this).bridge$resolve().subjectData(); } @Override - default SubjectData getTransientSubjectData() { - return ((SubjectBridge) this).bridge$resolve().getTransientSubjectData(); + default SubjectData transientSubjectData() { + return ((SubjectBridge) this).bridge$resolve().transientSubjectData(); } @Override - default Tristate getPermissionValue(final Set contexts, final String permission) { + default Tristate permissionValue(final Set contexts, final String permission) { return ((SubjectBridge) this).bridge$resolveOptional() - .map(subject -> subject.getPermissionValue(contexts, permission)) + .map(subject -> subject.permissionValue(contexts, permission)) .orElseGet(() -> ((SubjectBridge) this).bridge$permDefault(permission)); } @@ -95,7 +95,7 @@ default Tristate getPermissionValue(final Set contexts, final String pe default boolean hasPermission(final Set contexts, final String permission) { return ((SubjectBridge) this).bridge$resolveOptional() .map(subject -> { - final Tristate ret = subject.getPermissionValue(contexts, permission); + final Tristate ret = subject.permissionValue(contexts, permission); if (ret == Tristate.UNDEFINED) { return ((SubjectBridge) this).bridge$permDefault(permission).asBoolean(); } @@ -108,7 +108,7 @@ default boolean hasPermission(final Set contexts, final String permissi default boolean hasPermission(final String permission) { // forwarded to the implementation in this class, and not the default // in the Subject interface so permission defaults can be applied - return this.hasPermission(this.getActiveContexts(), permission); + return this.hasPermission(this.activeContexts(), permission); } @Override @@ -122,22 +122,22 @@ default boolean isChildOf(final SubjectReference parent) { } @Override - default List getParents(final Set contexts) { - return ((SubjectBridge) this).bridge$resolve().getParents(contexts); + default List parents(final Set contexts) { + return ((SubjectBridge) this).bridge$resolve().parents(contexts); } @Override - default List getParents() { - return ((SubjectBridge) this).bridge$resolve().getParents(); + default List parents() { + return ((SubjectBridge) this).bridge$resolve().parents(); } @Override - default Optional getOption(final Set contexts, final String key) { - return ((SubjectBridge) this).bridge$resolve().getOption(contexts, key); + default Optional option(final Set contexts, final String key) { + return ((SubjectBridge) this).bridge$resolve().option(contexts, key); } @Override - default Optional getOption(final String key) { - return ((SubjectBridge) this).bridge$resolve().getOption(key); + default Optional option(final String key) { + return ((SubjectBridge) this).bridge$resolve().option(key); } } diff --git a/src/main/java/org/spongepowered/common/service/server/permission/DataFactoryCollection.java b/src/main/java/org/spongepowered/common/service/server/permission/DataFactoryCollection.java index 334427e968f..462e1f704e3 100644 --- a/src/main/java/org/spongepowered/common/service/server/permission/DataFactoryCollection.java +++ b/src/main/java/org/spongepowered/common/service/server/permission/DataFactoryCollection.java @@ -67,7 +67,7 @@ public boolean isRegistered(String identifier) { @Override @SuppressWarnings({"unchecked", "rawtypes"}) - public Collection getLoadedSubjects() { + public Collection loadedSubjects() { return (Collection) this.subjects.values(); } @@ -81,18 +81,18 @@ protected DataFactorySubject(String identifier, Function getFriendlyIdentifier() { + public Optional friendlyIdentifier() { // TODO provide friendly identifier if possible return Optional.empty(); } @Override - public SubjectCollection getContainingCollection() { + public SubjectCollection containingCollection() { return DataFactoryCollection.this; } @@ -102,32 +102,32 @@ public PermissionService getService() { } @Override - public MemorySubjectData getSubjectData() { + public MemorySubjectData subjectData() { return this.data; } @Override - public Tristate getPermissionValue(Set contexts, String permission) { - Tristate ret = super.getPermissionValue(contexts, permission); + public Tristate permissionValue(Set contexts, String permission) { + Tristate ret = super.permissionValue(contexts, permission); if (ret == Tristate.UNDEFINED) { - ret = this.getDataPermissionValue(DataFactoryCollection.this.getDefaults().getTransientSubjectData(), permission); + ret = this.getDataPermissionValue(DataFactoryCollection.this.defaults().transientSubjectData(), permission); } if (ret == Tristate.UNDEFINED) { - ret = this.getDataPermissionValue(DataFactoryCollection.this.service.getDefaults().getTransientSubjectData(), permission); + ret = this.getDataPermissionValue(DataFactoryCollection.this.service.defaults().transientSubjectData(), permission); } return ret; } @Override - public Optional getOption(Set contexts, String option) { - Optional ret = super.getOption(contexts, option); + public Optional option(Set contexts, String option) { + Optional ret = super.option(contexts, option); if (!ret.isPresent()) { - ret = this.getDataOptionValue(DataFactoryCollection.this.getDefaults().getSubjectData(), option); + ret = this.getDataOptionValue(DataFactoryCollection.this.defaults().subjectData(), option); } if (!ret.isPresent()) { - ret = this.getDataOptionValue(DataFactoryCollection.this.service.getDefaults().getSubjectData(), option); + ret = this.getDataOptionValue(DataFactoryCollection.this.service.defaults().subjectData(), option); } return ret; } diff --git a/src/main/java/org/spongepowered/common/service/server/permission/FixedParentMemorySubjectData.java b/src/main/java/org/spongepowered/common/service/server/permission/FixedParentMemorySubjectData.java index 875125fed1e..07f839d06b2 100644 --- a/src/main/java/org/spongepowered/common/service/server/permission/FixedParentMemorySubjectData.java +++ b/src/main/java/org/spongepowered/common/service/server/permission/FixedParentMemorySubjectData.java @@ -49,8 +49,8 @@ public FixedParentMemorySubjectData(Subject subject, SubjectReference parent) { } @Override - public List getParents(Set contexts) { - return ImmutableList.builder().add(this.forcedParent).addAll(super.getParents(contexts)).build(); + public List parents(Set contexts) { + return ImmutableList.builder().add(this.forcedParent).addAll(super.parents(contexts)).build(); } @Override diff --git a/src/main/java/org/spongepowered/common/service/server/permission/GlobalMemorySubjectData.java b/src/main/java/org/spongepowered/common/service/server/permission/GlobalMemorySubjectData.java index 6b0bc2e3543..d91e3660a3c 100644 --- a/src/main/java/org/spongepowered/common/service/server/permission/GlobalMemorySubjectData.java +++ b/src/main/java/org/spongepowered/common/service/server/permission/GlobalMemorySubjectData.java @@ -47,8 +47,8 @@ public GlobalMemorySubjectData(Subject subject) { } @Override - public Map, List> getAllParents() { - return ImmutableMap.of(SubjectData.GLOBAL_CONTEXT, this.getParents(SubjectData.GLOBAL_CONTEXT)); + public Map, List> allParents() { + return ImmutableMap.of(SubjectData.GLOBAL_CONTEXT, this.parents(SubjectData.GLOBAL_CONTEXT)); } @Override diff --git a/src/main/java/org/spongepowered/common/service/server/permission/OpLevelCollection.java b/src/main/java/org/spongepowered/common/service/server/permission/OpLevelCollection.java index 13d4ecc6009..a49f59d23ef 100644 --- a/src/main/java/org/spongepowered/common/service/server/permission/OpLevelCollection.java +++ b/src/main/java/org/spongepowered/common/service/server/permission/OpLevelCollection.java @@ -68,7 +68,7 @@ public boolean isRegistered(final String identifier) { @Override @SuppressWarnings({"unchecked", "rawtypes"}) - public Collection getLoadedSubjects() { + public Collection loadedSubjects() { return (Collection) this.levels.values(); } @@ -84,14 +84,14 @@ public OpLevelSubject(final SpongePermissionService service, final int level) { this.data = new GlobalMemorySubjectData(this) { @Override - public List getParents(final Set contexts) { + public List parents(final Set contexts) { if (!contexts.isEmpty()) { return Collections.emptyList(); } if (level == 0) { - return super.getParents(contexts); + return super.parents(contexts); } else { - return ImmutableList.builder().add(service.getGroupForOpLevel(level - 1).asSubjectReference()).addAll(super.getParents(contexts)).build(); + return ImmutableList.builder().add(service.getGroupForOpLevel(level - 1).asSubjectReference()).addAll(super.parents(contexts)).build(); } } }; @@ -103,13 +103,13 @@ public int getOpLevel() { } @Override - public String getIdentifier() { + public String identifier() { return "op_" + this.level; } @Override - public SubjectCollection getContainingCollection() { - return this.service.getGroupSubjects(); + public SubjectCollection containingCollection() { + return this.service.groupSubjects(); } @Override @@ -118,7 +118,7 @@ public PermissionService getService() { } @Override - public MemorySubjectData getSubjectData() { + public MemorySubjectData subjectData() { return this.data; } } diff --git a/src/main/java/org/spongepowered/common/service/server/permission/SingleParentMemorySubjectData.java b/src/main/java/org/spongepowered/common/service/server/permission/SingleParentMemorySubjectData.java index 10fc0c0f422..702f5e23422 100644 --- a/src/main/java/org/spongepowered/common/service/server/permission/SingleParentMemorySubjectData.java +++ b/src/main/java/org/spongepowered/common/service/server/permission/SingleParentMemorySubjectData.java @@ -47,7 +47,7 @@ public SingleParentMemorySubjectData(Subject subject) { } @Override - public List getParents(Set contexts) { + public List parents(Set contexts) { final SubjectReference parent = this.getParent(); return contexts.isEmpty() && parent != null ? Collections.singletonList(parent) : Collections.emptyList(); } diff --git a/src/main/java/org/spongepowered/common/service/server/permission/SpongeBaseSubject.java b/src/main/java/org/spongepowered/common/service/server/permission/SpongeBaseSubject.java index bdc22a3775f..941a07bf7ee 100644 --- a/src/main/java/org/spongepowered/common/service/server/permission/SpongeBaseSubject.java +++ b/src/main/java/org/spongepowered/common/service/server/permission/SpongeBaseSubject.java @@ -41,7 +41,7 @@ public abstract class SpongeBaseSubject implements Subject { public abstract PermissionService getService(); @Override - public abstract MemorySubjectData getTransientSubjectData(); + public abstract MemorySubjectData transientSubjectData(); @Override public boolean isSubjectDataPersisted() { @@ -50,25 +50,25 @@ public boolean isSubjectDataPersisted() { @Override public SubjectReference asSubjectReference() { - return this.getService().newSubjectReference(this.getContainingCollection().getIdentifier(), this.getIdentifier()); + return this.getService().newSubjectReference(this.containingCollection().identifier(), this.identifier()); } @Override public boolean hasPermission(Set contexts, String permission) { - return this.getPermissionValue(contexts, permission) == Tristate.TRUE; + return this.permissionValue(contexts, permission) == Tristate.TRUE; } @Override - public Tristate getPermissionValue(Set contexts, String permission) { - return this.getDataPermissionValue(this.getTransientSubjectData(), permission); + public Tristate permissionValue(Set contexts, String permission) { + return this.getDataPermissionValue(this.transientSubjectData(), permission); } protected Tristate getDataPermissionValue(MemorySubjectData subject, String permission) { - Tristate res = subject.getNodeTree(SubjectData.GLOBAL_CONTEXT).get(permission); + Tristate res = subject.nodeTree(SubjectData.GLOBAL_CONTEXT).get(permission); if (res == Tristate.UNDEFINED) { - for (SubjectReference parent : subject.getParents(SubjectData.GLOBAL_CONTEXT)) { - res = parent.resolve().join().getPermissionValue(SubjectData.GLOBAL_CONTEXT, permission); + for (SubjectReference parent : subject.parents(SubjectData.GLOBAL_CONTEXT)) { + res = parent.resolve().join().permissionValue(SubjectData.GLOBAL_CONTEXT, permission); if (res != Tristate.UNDEFINED) { return res; } @@ -80,20 +80,20 @@ protected Tristate getDataPermissionValue(MemorySubjectData subject, String perm @Override public boolean isChildOf(Set contexts, SubjectReference parent) { - return this.getSubjectData().getParents(contexts).contains(parent); + return this.subjectData().parents(contexts).contains(parent); } @Override - public List getParents(Set contexts) { - return this.getSubjectData().getParents(contexts); + public List parents(Set contexts) { + return this.subjectData().parents(contexts); } protected Optional getDataOptionValue(MemorySubjectData subject, String option) { - Optional res = Optional.ofNullable(subject.getOptions(SubjectData.GLOBAL_CONTEXT).get(option)); + Optional res = Optional.ofNullable(subject.options(SubjectData.GLOBAL_CONTEXT).get(option)); if (!res.isPresent()) { - for (SubjectReference parent : subject.getParents(SubjectData.GLOBAL_CONTEXT)) { - res = parent.resolve().join().getOption(SubjectData.GLOBAL_CONTEXT, option); + for (SubjectReference parent : subject.parents(SubjectData.GLOBAL_CONTEXT)) { + res = parent.resolve().join().option(SubjectData.GLOBAL_CONTEXT, option); if (res.isPresent()) { return res; } @@ -104,12 +104,12 @@ protected Optional getDataOptionValue(MemorySubjectData subject, String } @Override - public Optional getOption(Set contexts, String key) { - return this.getDataOptionValue(this.getTransientSubjectData(), key); + public Optional option(Set contexts, String key) { + return this.getDataOptionValue(this.transientSubjectData(), key); } @Override - public Set getActiveContexts() { + public Set activeContexts() { return SubjectData.GLOBAL_CONTEXT; } } diff --git a/src/main/java/org/spongepowered/common/service/server/permission/SpongePermissionDescription.java b/src/main/java/org/spongepowered/common/service/server/permission/SpongePermissionDescription.java index dffb420aad5..34960893a1d 100644 --- a/src/main/java/org/spongepowered/common/service/server/permission/SpongePermissionDescription.java +++ b/src/main/java/org/spongepowered/common/service/server/permission/SpongePermissionDescription.java @@ -66,29 +66,29 @@ class SpongePermissionDescription implements PermissionDescription { } @Override - public String getId() { + public String id() { return this.id; } @Override - public Optional getDescription() { + public Optional description() { return Optional.ofNullable(this.description); } @Override - public Map getAssignedSubjects(String identifier) { + public Map assignedSubjects(String identifier) { SubjectCollection subjects = this.permissionService.get(identifier); - return subjects.getLoadedWithPermission(this.id); + return subjects.loadedWithPermission(this.id); } @Override public CompletableFuture> findAssignedSubjects(String type) { SubjectCollection subjects = this.permissionService.get(type); - return subjects.getAllWithPermission(this.id); + return subjects.allWithPermission(this.id); } @Override - public Optional getOwner() { + public Optional owner() { return Optional.of(this.owner); } @@ -164,7 +164,7 @@ public SpongePermissionDescription register() throws IllegalStateException { SpongeSubjectCollection subjects = this.permissionService.get(PermissionService.SUBJECTS_ROLE_TEMPLATE); for (Entry assignment : this.roleAssignments.entrySet()) { Subject subject = subjects.get(assignment.getKey()); - subject.getTransientSubjectData().setPermission(SubjectData.GLOBAL_CONTEXT, this.id, assignment.getValue()); + subject.transientSubjectData().setPermission(SubjectData.GLOBAL_CONTEXT, this.id, assignment.getValue()); } return description; } diff --git a/src/main/java/org/spongepowered/common/service/server/permission/SpongePermissionService.java b/src/main/java/org/spongepowered/common/service/server/permission/SpongePermissionService.java index 365baf048c7..2babc21b5df 100644 --- a/src/main/java/org/spongepowered/common/service/server/permission/SpongePermissionService.java +++ b/src/main/java/org/spongepowered/common/service/server/permission/SpongePermissionService.java @@ -86,7 +86,7 @@ public SpongePermissionService(final Game game) { // , // s -> { // if (s.equals("Server")) { -// return SpongeImpl.getGame().getServer().getConsole(); +// return SpongeImpl.game().getServer().getConsole(); // } /*else if (s.equals("RCON")) { // TODO: Implement RCON API? // }*/ @@ -106,16 +106,16 @@ static int getServerOpLevel() { } public Subject getGroupForOpLevel(final int level) { - return this.getGroupSubjects().get("op_" + level); + return this.groupSubjects().get("op_" + level); } @Override - public SpongeSubjectCollection getUserSubjects() { + public SpongeSubjectCollection userSubjects() { return this.get(PermissionService.SUBJECTS_USER); } @Override - public SpongeSubjectCollection getGroupSubjects() { + public SpongeSubjectCollection groupSubjects() { return this.get(PermissionService.SUBJECTS_GROUP); } @@ -135,12 +135,12 @@ public SpongeSubjectCollection get(final String identifier) { } @Override - public SpongeSubject getDefaults() { + public SpongeSubject defaults() { return this.defaultData; } @Override - public Predicate getIdentifierValidityPredicate() { + public Predicate identifierValidityPredicate() { return s -> true; } @@ -157,7 +157,7 @@ public CompletableFuture loadCollection(final String identifi } @Override - public Optional getCollection(final String identifier) { + public Optional collection(final String identifier) { return Optional.of(this.get(identifier)); } @@ -167,13 +167,13 @@ public CompletableFuture hasCollection(final String identifier) { } @Override - public Map getLoadedCollections() { + public Map loadedCollections() { return ImmutableMap.copyOf(this.subjects); } @Override - public CompletableFuture> getAllIdentifiers() { - return CompletableFuture.completedFuture(this.getLoadedCollections().keySet()); + public CompletableFuture> allIdentifiers() { + return CompletableFuture.completedFuture(this.loadedCollections().keySet()); } @Override @@ -188,18 +188,18 @@ public Builder newDescriptionBuilder(final PluginContainer container) { public void addDescription(final PermissionDescription permissionDescription) { checkNotNull(permissionDescription, "permissionDescription"); - checkNotNull(permissionDescription.getId(), "permissionId"); - this.descriptionMap.put(permissionDescription.getId().toLowerCase(), permissionDescription); + checkNotNull(permissionDescription.id(), "permissionId"); + this.descriptionMap.put(permissionDescription.id().toLowerCase(), permissionDescription); this.descriptions = null; } @Override - public Optional getDescription(final String permissionId) { + public Optional description(final String permissionId) { return Optional.ofNullable(this.descriptionMap.get(checkNotNull(permissionId, "permissionId").toLowerCase())); } @Override - public Collection getDescriptions() { + public Collection descriptions() { Collection descriptions = this.descriptions; if (descriptions == null) { descriptions = ImmutableList.copyOf(this.descriptionMap.values()); diff --git a/src/main/java/org/spongepowered/common/service/server/permission/SpongePermissions.java b/src/main/java/org/spongepowered/common/service/server/permission/SpongePermissions.java index 98105acc70b..2ae631ee52e 100644 --- a/src/main/java/org/spongepowered/common/service/server/permission/SpongePermissions.java +++ b/src/main/java/org/spongepowered/common/service/server/permission/SpongePermissions.java @@ -59,15 +59,15 @@ public static void populateNonCommandPermissions(final SubjectData data, final B public static void registerPermission(final String permissionNode, final int opLevel) { if (SpongePermissions.REGISTERED_PERMISSIONS.add(permissionNode)) { - final PermissionService service = Sponge.getServer().getServiceProvider().permissionService(); + final PermissionService service = Sponge.server().serviceProvider().permissionService(); if (opLevel == 0) { // register as a default permission - service.getDefaults() - .getTransientSubjectData() + service.defaults() + .transientSubjectData() .setPermission(SubjectData.GLOBAL_CONTEXT, permissionNode, Tristate.TRUE); } if (service instanceof SpongePermissionService) { - ((SpongePermissionService) service).getGroupForOpLevel(opLevel).getTransientSubjectData() + ((SpongePermissionService) service).getGroupForOpLevel(opLevel).transientSubjectData() .setPermission(SubjectData.GLOBAL_CONTEXT, permissionNode, Tristate.TRUE); } } diff --git a/src/main/java/org/spongepowered/common/service/server/permission/SpongeSubject.java b/src/main/java/org/spongepowered/common/service/server/permission/SpongeSubject.java index ab8f6cbb97e..d5736128818 100644 --- a/src/main/java/org/spongepowered/common/service/server/permission/SpongeSubject.java +++ b/src/main/java/org/spongepowered/common/service/server/permission/SpongeSubject.java @@ -29,11 +29,11 @@ public abstract class SpongeSubject extends SpongeBaseSubject { @Override - public MemorySubjectData getTransientSubjectData() { - return this.getSubjectData(); + public MemorySubjectData transientSubjectData() { + return this.subjectData(); } @Override - public abstract MemorySubjectData getSubjectData(); + public abstract MemorySubjectData subjectData(); } diff --git a/src/main/java/org/spongepowered/common/service/server/permission/SpongeSubjectCollection.java b/src/main/java/org/spongepowered/common/service/server/permission/SpongeSubjectCollection.java index eb64738529a..735c8749ccf 100644 --- a/src/main/java/org/spongepowered/common/service/server/permission/SpongeSubjectCollection.java +++ b/src/main/java/org/spongepowered/common/service/server/permission/SpongeSubjectCollection.java @@ -51,18 +51,18 @@ protected SpongeSubjectCollection(String identifier, SpongePermissionService ser } @Override - public String getIdentifier() { + public String identifier() { return this.identifier; } @Override - public Predicate getIdentifierValidityPredicate() { + public Predicate identifierValidityPredicate() { return s -> true; } @Override public SubjectReference newSubjectReference(String subjectIdentifier) { - return this.service.newSubjectReference(this.getIdentifier(), subjectIdentifier); + return this.service.newSubjectReference(this.identifier(), subjectIdentifier); } public abstract SpongeSubject get(String identifier); @@ -75,7 +75,7 @@ public CompletableFuture loadSubject(String identifier) { } @Override - public Optional getSubject(String identifier) { + public Optional subject(String identifier) { return Optional.of(this.get(identifier)); } @@ -94,10 +94,10 @@ public CompletableFuture> loadSubjects(Set identifi } @Override - public Map getLoadedWithPermission(String permission) { + public Map loadedWithPermission(String permission) { final Map ret = new HashMap<>(); - for (Subject subj : this.getLoadedSubjects()) { - Tristate state = subj.getPermissionValue(subj.getActiveContexts(), permission); + for (Subject subj : this.loadedSubjects()) { + Tristate state = subj.permissionValue(subj.activeContexts(), permission); if (state != Tristate.UNDEFINED) { ret.put(subj, state.asBoolean()); } @@ -106,10 +106,10 @@ public Map getLoadedWithPermission(String permission) { } @Override - public Map getLoadedWithPermission(Set contexts, String permission) { + public Map loadedWithPermission(Set contexts, String permission) { final Map ret = new HashMap<>(); - for (Subject subj : this.getLoadedSubjects()) { - Tristate state = subj.getPermissionValue(contexts, permission); + for (Subject subj : this.loadedSubjects()) { + Tristate state = subj.permissionValue(contexts, permission); if (state != Tristate.UNDEFINED) { ret.put(subj, state.asBoolean()); } @@ -118,8 +118,8 @@ public Map getLoadedWithPermission(Set contexts, Stri } @Override - public CompletableFuture> getAllWithPermission(String permission) { - return CompletableFuture.completedFuture(this.getLoadedWithPermission(permission).entrySet().stream() + public CompletableFuture> allWithPermission(String permission) { + return CompletableFuture.completedFuture(this.loadedWithPermission(permission).entrySet().stream() .collect(Collectors.toMap( e -> e.getKey().asSubjectReference(), Map.Entry::getValue) @@ -128,8 +128,8 @@ public CompletableFuture> getAllWithPermission(St } @Override - public CompletableFuture> getAllWithPermission(Set contexts, String permission) { - return CompletableFuture.completedFuture(this.getLoadedWithPermission(contexts, permission).entrySet().stream() + public CompletableFuture> allWithPermission(Set contexts, String permission) { + return CompletableFuture.completedFuture(this.loadedWithPermission(contexts, permission).entrySet().stream() .collect(Collectors.toMap( e -> e.getKey().asSubjectReference(), Map.Entry::getValue) @@ -138,16 +138,16 @@ public CompletableFuture> getAllWithPermission(Se } @Override - public CompletableFuture> getAllIdentifiers() { - return CompletableFuture.completedFuture(this.getLoadedSubjects().stream() - .map(Subject::getIdentifier) + public CompletableFuture> allIdentifiers() { + return CompletableFuture.completedFuture(this.loadedSubjects().stream() + .map(Subject::identifier) .collect(ImmutableSet.toImmutableSet()) ); } @Override - public SpongeSubject getDefaults() { - return this.service.getDefaultCollection().get(this.getIdentifier()); + public SpongeSubject defaults() { + return this.service.getDefaultCollection().get(this.identifier()); } @Override diff --git a/src/main/java/org/spongepowered/common/service/server/permission/SpongeSubjectReference.java b/src/main/java/org/spongepowered/common/service/server/permission/SpongeSubjectReference.java index 0ba93d018e2..84a290e3a29 100644 --- a/src/main/java/org/spongepowered/common/service/server/permission/SpongeSubjectReference.java +++ b/src/main/java/org/spongepowered/common/service/server/permission/SpongeSubjectReference.java @@ -46,12 +46,12 @@ public SpongeSubjectReference(SpongePermissionService service, String collection } @Override - public String getCollectionIdentifier() { + public String collectionIdentifier() { return this.collectionId; } @Override - public String getSubjectIdentifier() { + public String subjectIdentifier() { return this.subjectId; } diff --git a/src/main/java/org/spongepowered/common/service/server/permission/SpongeSystemSubject.java b/src/main/java/org/spongepowered/common/service/server/permission/SpongeSystemSubject.java index da02842545a..a406631e3bd 100644 --- a/src/main/java/org/spongepowered/common/service/server/permission/SpongeSystemSubject.java +++ b/src/main/java/org/spongepowered/common/service/server/permission/SpongeSystemSubject.java @@ -75,7 +75,7 @@ public abstract class SpongeSystemSubject implements Subject, SystemSubject, Bri @Override public String toString() { return MoreObjects.toStringHelper(this) - .add("identifier", this.getIdentifier()) + .add("identifier", this.identifier()) .add("reference", this.bridge$resolveOptional()) .toString(); } diff --git a/src/main/java/org/spongepowered/common/service/server/permission/SubjectHelper.java b/src/main/java/org/spongepowered/common/service/server/permission/SubjectHelper.java index e91543a472c..fa7e15af8e6 100644 --- a/src/main/java/org/spongepowered/common/service/server/permission/SubjectHelper.java +++ b/src/main/java/org/spongepowered/common/service/server/permission/SubjectHelper.java @@ -26,15 +26,11 @@ import com.google.common.base.Preconditions; import org.spongepowered.api.Sponge; -import org.spongepowered.api.entity.living.player.User; -import org.spongepowered.api.profile.GameProfile; import org.spongepowered.api.service.permission.PermissionService; import org.spongepowered.api.service.permission.Subject; import org.spongepowered.api.service.permission.SubjectReference; -import org.spongepowered.common.SpongeCommon; import org.spongepowered.common.bridge.authlib.GameProfileHolderBridge; import org.spongepowered.common.bridge.permissions.SubjectBridge; -import org.spongepowered.common.profile.SpongeGameProfile; /** * {@link SubjectBridge} helper class to apply the appropriate subject to the @@ -47,7 +43,7 @@ private SubjectHelper() { public static void applySubject(final SubjectBridge ref) { Preconditions.checkNotNull(ref); - final PermissionService service = Sponge.getServer().getServiceProvider().permissionService(); + final PermissionService service = Sponge.server().serviceProvider().permissionService(); final SubjectReference subject; // check if we're using the native Sponge impl @@ -60,12 +56,12 @@ public static void applySubject(final SubjectBridge ref) { // GameProfile is already resolved, use it directly subject = ((UserCollection) collection).get(((GameProfileHolderBridge) ref).bridge$getGameProfile()).asSubjectReference(); } else { - subject = collection.get(((Subject) ref).getIdentifier()).asSubjectReference(); + subject = collection.get(((Subject) ref).identifier()).asSubjectReference(); } } else { // build a new subject reference using the permission service // this doesn't actually load the subject, so it will be lazily init'd when needed. - subject = service.newSubjectReference(ref.bridge$getSubjectCollectionIdentifier(), ((Subject) ref).getIdentifier()); + subject = service.newSubjectReference(ref.bridge$getSubjectCollectionIdentifier(), ((Subject) ref).identifier()); } ref.bridge$setSubject(subject); diff --git a/src/main/java/org/spongepowered/common/service/server/permission/UserCollection.java b/src/main/java/org/spongepowered/common/service/server/permission/UserCollection.java index 1fee931831c..ed1cdbf7542 100644 --- a/src/main/java/org/spongepowered/common/service/server/permission/UserCollection.java +++ b/src/main/java/org/spongepowered/common/service/server/permission/UserCollection.java @@ -29,7 +29,6 @@ import org.spongepowered.api.service.permission.PermissionService; import org.spongepowered.api.service.permission.Subject; import org.spongepowered.common.SpongeCommon; -import org.spongepowered.common.SpongeGame; import org.spongepowered.common.profile.SpongeGameProfile; import java.util.Collection; @@ -59,7 +58,7 @@ protected SpongeSubject get(final GameProfile profile) { private GameProfile uuidToGameProfile(final UUID uuid) { try { - return SpongeGameProfile.toMcProfile(Sponge.getServer().getGameProfileManager().getBasicProfile(uuid).get()); + return SpongeGameProfile.toMcProfile(Sponge.server().gameProfileManager().basicProfile(uuid).get()); } catch (final Exception e) { SpongeCommon.getLogger().warn("Failed to lookup game profile for {}", uuid, e); // TODO: I'm sure this is null for a reason, but it breaks subjects. @@ -89,8 +88,8 @@ private UUID identityToUuid(final String identifier) { @Override @SuppressWarnings({"unchecked", "rawtypes"}) - public Collection getLoadedSubjects() { - return (Collection) SpongeCommon.getGame().getServer().getOnlinePlayers(); + public Collection loadedSubjects() { + return (Collection) SpongeCommon.getGame().server().onlinePlayers(); /*return ImmutableSet.copyOf(Iterables.concat( Iterables.transform(SpongePermissionService.getOps().getValues().values(), new Function() { @@ -101,7 +100,7 @@ public Subject apply(Object input) { return get(profile); } // WARNING: This gives dupes - }), Sponge.getGame().getServer().getOnlinePlayers()));*/ + }), Sponge.game().getServer().getOnlinePlayers()));*/ } public SpongePermissionService getService() { diff --git a/src/main/java/org/spongepowered/common/service/server/permission/UserSubject.java b/src/main/java/org/spongepowered/common/service/server/permission/UserSubject.java index e58d4ed2e9c..0eab9ab2bbb 100644 --- a/src/main/java/org/spongepowered/common/service/server/permission/UserSubject.java +++ b/src/main/java/org/spongepowered/common/service/server/permission/UserSubject.java @@ -78,12 +78,12 @@ public void setParent(final SubjectReference parent) { } @Override - public String getIdentifier() { + public String identifier() { return this.player.getId().toString(); } @Override - public Optional getFriendlyIdentifier() { + public Optional friendlyIdentifier() { return Optional.of(this.player.getName()); } @@ -101,12 +101,12 @@ int getOpLevel() { } @Override - public SubjectCollection getContainingCollection() { + public SubjectCollection containingCollection() { return this.collection; } @Override - public MemorySubjectData getSubjectData() { + public MemorySubjectData subjectData() { return this.data; } @@ -116,13 +116,13 @@ public PermissionService getService() { } @Override - public Tristate getPermissionValue(final Set contexts, final String permission) { - Tristate ret = super.getPermissionValue(contexts, permission); + public Tristate permissionValue(final Set contexts, final String permission) { + Tristate ret = super.permissionValue(contexts, permission); if (ret == Tristate.UNDEFINED) { - ret = this.getDataPermissionValue(this.collection.getDefaults().getSubjectData(), permission); + ret = this.getDataPermissionValue(this.collection.defaults().subjectData(), permission); } if (ret == Tristate.UNDEFINED) { - ret = this.getDataPermissionValue(this.collection.getService().getDefaults().getSubjectData(), permission); + ret = this.getDataPermissionValue(this.collection.getService().defaults().subjectData(), permission); } if (ret == Tristate.UNDEFINED && this.getOpLevel() >= SpongePermissionService.getServerOpLevel()) { ret = Tristate.TRUE; @@ -131,13 +131,13 @@ public Tristate getPermissionValue(final Set contexts, final String per } @Override - public Optional getOption(final Set contexts, final String option) { - Optional ret = super.getOption(contexts, option); + public Optional option(final Set contexts, final String option) { + Optional ret = super.option(contexts, option); if (!ret.isPresent()) { - ret = this.getDataOptionValue(this.collection.getDefaults().getSubjectData(), option); + ret = this.getDataOptionValue(this.collection.defaults().subjectData(), option); } if (!ret.isPresent()) { - ret = this.getDataOptionValue(this.collection.getService().getDefaults().getSubjectData(), option); + ret = this.getDataOptionValue(this.collection.getService().defaults().subjectData(), option); } return ret; } diff --git a/src/main/java/org/spongepowered/common/service/server/rcon/MinecraftRconService.java b/src/main/java/org/spongepowered/common/service/server/rcon/MinecraftRconService.java index 7a557c75466..a782e2b73f9 100644 --- a/src/main/java/org/spongepowered/common/service/server/rcon/MinecraftRconService.java +++ b/src/main/java/org/spongepowered/common/service/server/rcon/MinecraftRconService.java @@ -41,7 +41,7 @@ public boolean isRconEnabled() { } @Override - public String getRconPassword() { + public String rconPassword() { return this.server.getProperties().rconPassword; } } diff --git a/src/main/java/org/spongepowered/common/service/server/whitelist/SpongeUserWhiteList.java b/src/main/java/org/spongepowered/common/service/server/whitelist/SpongeUserWhiteList.java index e7aed46e599..68f474002db 100644 --- a/src/main/java/org/spongepowered/common/service/server/whitelist/SpongeUserWhiteList.java +++ b/src/main/java/org/spongepowered/common/service/server/whitelist/SpongeUserWhiteList.java @@ -48,14 +48,14 @@ public SpongeUserWhiteList(final File file) { @Override protected boolean contains(final com.mojang.authlib.GameProfile entry) { - return Sponge.getServer().getServiceProvider().whitelistService().isWhitelisted(SpongeGameProfile.of(entry)).join(); + return Sponge.server().serviceProvider().whitelistService().isWhitelisted(SpongeGameProfile.of(entry)).join(); } @Override public String[] getUserList() { final List names = new ArrayList<>(); - for (final GameProfile profile : Sponge.getServer().getServiceProvider().whitelistService().getWhitelistedProfiles().join()) { - profile.getName().ifPresent(names::add); + for (final GameProfile profile : Sponge.server().serviceProvider().whitelistService().whitelistedProfiles().join()) { + profile.name().ifPresent(names::add); } return names.toArray(new String[names.size()]); } @@ -63,17 +63,17 @@ public String[] getUserList() { @SuppressWarnings("unchecked") @Override public void add(final UserWhiteListEntry entry) { - Sponge.getServer().getServiceProvider().whitelistService().addProfile(SpongeGameProfile.of(((StoredUserEntryAccessor) entry).accessor$user())); + Sponge.server().serviceProvider().whitelistService().addProfile(SpongeGameProfile.of(((StoredUserEntryAccessor) entry).accessor$user())); } @Override public void remove(final com.mojang.authlib.GameProfile entry) { - Sponge.getServer().getServiceProvider().whitelistService().removeProfile(SpongeGameProfile.of(entry)); + Sponge.server().serviceProvider().whitelistService().removeProfile(SpongeGameProfile.of(entry)); } @Override public boolean isEmpty() { - return Sponge.getServer().getServiceProvider().whitelistService().getWhitelistedProfiles().join().isEmpty(); + return Sponge.server().serviceProvider().whitelistService().whitelistedProfiles().join().isEmpty(); } } diff --git a/src/main/java/org/spongepowered/common/service/server/whitelist/SpongeWhitelistService.java b/src/main/java/org/spongepowered/common/service/server/whitelist/SpongeWhitelistService.java index c687a7ad670..91e3f8153ae 100644 --- a/src/main/java/org/spongepowered/common/service/server/whitelist/SpongeWhitelistService.java +++ b/src/main/java/org/spongepowered/common/service/server/whitelist/SpongeWhitelistService.java @@ -46,7 +46,7 @@ public final class SpongeWhitelistService implements WhitelistService { @SuppressWarnings("unchecked") @Override - public CompletableFuture> getWhitelistedProfiles() { + public CompletableFuture> whitelistedProfiles() { final List profiles = new ArrayList<>(); final UserWhiteList list = SpongeCommon.getServer().getPlayerList().getWhiteList(); diff --git a/src/main/java/org/spongepowered/common/sql/SpongeSqlManager.java b/src/main/java/org/spongepowered/common/sql/SpongeSqlManager.java index a76b4d0521a..f2b71fe7551 100644 --- a/src/main/java/org/spongepowered/common/sql/SpongeSqlManager.java +++ b/src/main/java/org/spongepowered/common/sql/SpongeSqlManager.java @@ -99,7 +99,7 @@ public final class SpongeSqlManager implements SqlManager, Closeable { return origPath.toString(); } - return Sponge.getConfigManager().getPluginConfig(plugin).getDirectory().resolve(orig).toAbsolutePath().toString(); + return Sponge.configManager().pluginConfig(plugin).directory().resolve(orig).toAbsolutePath().toString(); }); } @@ -134,15 +134,15 @@ public void buildConnectionCache() { }); } @Override - public DataSource getDataSource(final String jdbcConnection) throws SQLException { - return this.getDataSource(null, jdbcConnection); + public DataSource dataSource(final String jdbcConnection) throws SQLException { + return this.dataSource(null, jdbcConnection); } @Override - public DataSource getDataSource(final PluginContainer plugin, final String jdbcConnection) throws SQLException { + public DataSource dataSource(final PluginContainer plugin, final String jdbcConnection) throws SQLException { checkNotNull(this.connectionCache); - final String jdbcConnectionString = this.getConnectionUrlFromAlias(jdbcConnection).orElse(jdbcConnection); + final String jdbcConnectionString = this.connectionUrlFromAlias(jdbcConnection).orElse(jdbcConnection); final ConnectionInfo info = ConnectionInfo.fromUrl(plugin, jdbcConnectionString); try { return this.connectionCache.get(info); @@ -268,7 +268,7 @@ private static String urlDecode(final String str) { } @Override - public Optional getConnectionUrlFromAlias(final String alias) { + public Optional connectionUrlFromAlias(final String alias) { return Optional.ofNullable(SpongeConfigs.getCommon().get().sql.aliases.get(alias)); } diff --git a/src/main/java/org/spongepowered/common/state/AbstractSpongeStateMatcher.java b/src/main/java/org/spongepowered/common/state/AbstractSpongeStateMatcher.java index fde95e358aa..29d5aba7884 100644 --- a/src/main/java/org/spongepowered/common/state/AbstractSpongeStateMatcher.java +++ b/src/main/java/org/spongepowered/common/state/AbstractSpongeStateMatcher.java @@ -83,7 +83,7 @@ protected final boolean isValid(final StateHolder stateHolder) { } private boolean matches(final DataHolder holder, final KeyValueMatcher keyValueMatcher) { - return holder.get(keyValueMatcher.getKey()).map(keyValueMatcher::matches).orElse(false); + return holder.get(keyValueMatcher.key()).map(keyValueMatcher::matches).orElse(false); } } diff --git a/src/main/java/org/spongepowered/common/state/SpongeBlockStateMatcher.java b/src/main/java/org/spongepowered/common/state/SpongeBlockStateMatcher.java index a1bc4cd6bfc..065869416b1 100644 --- a/src/main/java/org/spongepowered/common/state/SpongeBlockStateMatcher.java +++ b/src/main/java/org/spongepowered/common/state/SpongeBlockStateMatcher.java @@ -52,7 +52,7 @@ public boolean matches(@NonNull final BlockState state) { @Override @NonNull - public List getCompatibleStates() { + public List compatibleStates() { if (this.compatibleStates == null) { final Block blockType = (Block) this.type; this.compatibleStates = blockType.getStateDefinition().getPossibleStates() diff --git a/src/main/java/org/spongepowered/common/state/SpongeFluidStateMatcher.java b/src/main/java/org/spongepowered/common/state/SpongeFluidStateMatcher.java index d283e6dd739..94aa99dc614 100644 --- a/src/main/java/org/spongepowered/common/state/SpongeFluidStateMatcher.java +++ b/src/main/java/org/spongepowered/common/state/SpongeFluidStateMatcher.java @@ -53,7 +53,7 @@ public boolean matches(@NonNull final FluidState state) { @Override @NonNull - public List getCompatibleStates() { + public List compatibleStates() { if (this.compatibleStates == null) { final Block blockType = (Block) this.type; this.compatibleStates = blockType.getStateDefinition().getPossibleStates() diff --git a/src/main/java/org/spongepowered/common/user/ServerUserProvider.java b/src/main/java/org/spongepowered/common/user/ServerUserProvider.java index cc783ec3c78..f4a0098f2da 100644 --- a/src/main/java/org/spongepowered/common/user/ServerUserProvider.java +++ b/src/main/java/org/spongepowered/common/user/ServerUserProvider.java @@ -163,7 +163,7 @@ Optional getUser(final UUID uuid) { Optional getUser(@Nullable final GameProfile profile) { this.pollFilesystemWatcher(); - if (profile != null && this.knownUUIDs.contains(profile.getUniqueId())) { + if (profile != null && this.knownUUIDs.contains(profile.uniqueId())) { // This is okay, the file exists. return Optional.of(this.getOrCreateUser(profile, false)); } @@ -173,7 +173,7 @@ Optional getUser(@Nullable final GameProfile profile) { User getOrCreateUser(final GameProfile profile, final boolean force) { final com.mojang.authlib.GameProfile resolvedProfile; if (!force) { - final UUID userID = profile.getUniqueId(); + final UUID userID = profile.uniqueId(); final User currentUser = this.userCache.getIfPresent(userID); if (currentUser != null) { return currentUser; @@ -183,7 +183,7 @@ User getOrCreateUser(final GameProfile profile, final boolean force) { resolvedProfile = p == null ? SpongeGameProfile.toMcProfile(profile) : p; } else { resolvedProfile = SpongeGameProfile.toMcProfile(profile); - final User currentUser = this.userCache.getIfPresent(profile.getUniqueId()); + final User currentUser = this.userCache.getIfPresent(profile.uniqueId()); if (currentUser != null) { if (SpongeUser.dirtyUsers.contains(currentUser)) { ((SpongeUser) currentUser).save(); @@ -194,8 +194,8 @@ User getOrCreateUser(final GameProfile profile, final boolean force) { this.pollFilesystemWatcher(); final User user = new SpongeUser(resolvedProfile); - this.userCache.put(profile.getUniqueId(), user); - this.knownUUIDs.add(profile.getUniqueId()); + this.userCache.put(profile.uniqueId(), user); + this.knownUUIDs.add(profile.uniqueId()); return user; } @@ -209,13 +209,13 @@ boolean deleteUser(final UUID uuid) { } Stream matchKnownProfiles(final String lowercaseName) { - return ((Server) this.server).getGameProfileManager().getCache().streamOfMatches(lowercaseName) - .filter(gameProfile -> this.knownUUIDs.contains(gameProfile.getUniqueId())); + return ((Server) this.server).gameProfileManager().cache().streamOfMatches(lowercaseName) + .filter(gameProfile -> this.knownUUIDs.contains(gameProfile.uniqueId())); } Stream streamAll() { - final GameProfileCache cache = ((Server) this.server).getGameProfileManager().getCache(); - return this.knownUUIDs.stream().map(x -> cache.getById(x).orElseGet(() -> GameProfile.of(x))); + final GameProfileCache cache = ((Server) this.server).gameProfileManager().cache(); + return this.knownUUIDs.stream().map(x -> cache.byId(x).orElseGet(() -> GameProfile.of(x))); } private Path getPlayerDataFile(final UUID uniqueId) { diff --git a/src/main/java/org/spongepowered/common/user/SpongeUserManager.java b/src/main/java/org/spongepowered/common/user/SpongeUserManager.java index 19884529469..1ceaf26f59e 100644 --- a/src/main/java/org/spongepowered/common/user/SpongeUserManager.java +++ b/src/main/java/org/spongepowered/common/user/SpongeUserManager.java @@ -57,24 +57,24 @@ public void init() { } @Override - public Optional get(final UUID uniqueId) { + public Optional find(final UUID uniqueId) { return this.serverUserProvider.getUser(uniqueId); } @Override - public Optional get(final String lastKnownName) { + public Optional find(final String lastKnownName) { checkNotNull(lastKnownName, "lastKnownName"); checkArgument(!lastKnownName.isEmpty() && lastKnownName.length() <= 16, "Invalid username %s", lastKnownName); return this.serverUserProvider.getUser(lastKnownName); } @Override - public Optional get(final GameProfile profile) { + public Optional find(final GameProfile profile) { return this.serverUserProvider.getUser(profile); } @Override - public User getOrCreate(final GameProfile profile) { + public User findOrCreate(final GameProfile profile) { return this.serverUserProvider.getOrCreateUser(this.ensureNonEmptyUUID(profile), false); } @@ -83,7 +83,7 @@ public User forceRecreateUser(final GameProfile profile) { } @Override - public Collection getAll() { + public Collection all() { return this.streamAll().collect(Collectors.toList()); } @@ -94,12 +94,12 @@ public Stream streamAll() { @Override public boolean delete(final GameProfile profile) { - return this.serverUserProvider.deleteUser(checkNotNull(profile, "profile").getUniqueId()); + return this.serverUserProvider.deleteUser(checkNotNull(profile, "profile").uniqueId()); } @Override public boolean delete(final User user) { - return this.delete(user.getProfile()); + return this.delete(user.profile()); } @Override @@ -108,8 +108,8 @@ public Stream streamOfMatches(final String lastKnownName) { } private GameProfile ensureNonEmptyUUID(final GameProfile profile) { - if (profile.getUniqueId().equals(SpongeGameProfile.EMPTY_UUID)) { - final String name = profile.getName().orElse(null); + if (profile.uniqueId().equals(SpongeGameProfile.EMPTY_UUID)) { + final String name = profile.name().orElse(null); // Use Forge's FakePlayer UUID return new SpongeGameProfile(SpongeUserManager.FAKEPLAYER_UUID, name); } diff --git a/src/main/java/org/spongepowered/common/util/BookUtil.java b/src/main/java/org/spongepowered/common/util/BookUtil.java index 83340a8f4f7..f6f0e335dcd 100644 --- a/src/main/java/org/spongepowered/common/util/BookUtil.java +++ b/src/main/java/org/spongepowered/common/util/BookUtil.java @@ -57,8 +57,8 @@ public static void fakeBookView(final Book book, final Collection DATA_CONTENT_UPDATER_COMPARATOR = (o1, o2) -> ComparisonChain.start() - .compare(o2.getInputVersion(), o1.getInputVersion()) - .compare(o2.getOutputVersion(), o1.getOutputVersion()) + .compare(o2.inputVersion(), o1.inputVersion()) + .compare(o2.outputVersion(), o1.outputVersion()) .result(); public static Comparator intComparator() { diff --git a/src/main/java/org/spongepowered/common/util/DataUtil.java b/src/main/java/org/spongepowered/common/util/DataUtil.java index 4a48444e66e..8b9955b692c 100644 --- a/src/main/java/org/spongepowered/common/util/DataUtil.java +++ b/src/main/java/org/spongepowered/common/util/DataUtil.java @@ -75,9 +75,9 @@ public static ServerLocation getLocation(final DataView view, final boolean cast final ResourceKey world = view.getResourceKey(Queries.WORLD_KEY).orElseThrow(DataUtil.dataNotFound()); final Vector3d pos = DataUtil.getPosition3d(view, null); if (castToInt) { - return ServerLocation.of(SpongeCommon.getGame().getServer().getWorldManager().world(world).orElseThrow(DataUtil.dataNotFound()), pos.toInt()); + return ServerLocation.of(SpongeCommon.getGame().server().worldManager().world(world).orElseThrow(DataUtil.dataNotFound()), pos.toInt()); } - return ServerLocation.of(SpongeCommon.getGame().getServer().getWorldManager().world(world).orElseThrow(DataUtil.dataNotFound()), pos); + return ServerLocation.of(SpongeCommon.getGame().server().worldManager().world(world).orElseThrow(DataUtil.dataNotFound()), pos); } public static Vector3i getPosition3i(final DataView view) { @@ -120,7 +120,7 @@ public static WeightedTable ensureMutable(WeightedTable table) { if (type == WeightedTable.class) { return table; } - final WeightedTable copy = new WeightedTable<>(table.getRolls()); + final WeightedTable copy = new WeightedTable<>(table.rolls()); copy.addAll(table); return copy; } diff --git a/src/main/java/org/spongepowered/common/util/EngineUtil.java b/src/main/java/org/spongepowered/common/util/EngineUtil.java index 9da287c9e6f..53767f6ac9e 100644 --- a/src/main/java/org/spongepowered/common/util/EngineUtil.java +++ b/src/main/java/org/spongepowered/common/util/EngineUtil.java @@ -33,14 +33,14 @@ public final class EngineUtil { @Nullable public static Engine determineEngine() { if (Sponge.isServerAvailable()) { - if (Sponge.getServer().onMainThread()) { - return Sponge.getServer(); + if (Sponge.server().onMainThread()) { + return Sponge.server(); } } if (Sponge.isClientAvailable()) { - if (Sponge.getClient().onMainThread()) { - return Sponge.getClient(); + if (Sponge.client().onMainThread()) { + return Sponge.client(); } } diff --git a/src/main/java/org/spongepowered/common/util/FireworkUtil.java b/src/main/java/org/spongepowered/common/util/FireworkUtil.java index 34339d034c1..8731e1f6501 100644 --- a/src/main/java/org/spongepowered/common/util/FireworkUtil.java +++ b/src/main/java/org/spongepowered/common/util/FireworkUtil.java @@ -69,7 +69,7 @@ public static FireworkEffect fromCompound(final CompoundTag compound) { } if (compound.contains(Constants.Item.Fireworks.SHAPE_TYPE)) { final byte type = compound.getByte(Constants.Item.Fireworks.SHAPE_TYPE); - final MappedRegistry registry = (MappedRegistry) (Object) Sponge.getGame().registries().registry(RegistryTypes.FIREWORK_SHAPE); + final MappedRegistry registry = (MappedRegistry) (Object) Sponge.game().registries().registry(RegistryTypes.FIREWORK_SHAPE); @Nullable final FireworkShape shape = registry.byId(type); if (shape != null) { builder.shape(shape); @@ -96,18 +96,18 @@ public static FireworkEffect fromCompound(final CompoundTag compound) { } public static CompoundTag toCompound(final FireworkEffect effect) { - final MappedRegistry registry = (MappedRegistry) (Object) Sponge.getGame().registries().registry(RegistryTypes.FIREWORK_SHAPE); + final MappedRegistry registry = (MappedRegistry) (Object) Sponge.game().registries().registry(RegistryTypes.FIREWORK_SHAPE); final CompoundTag tag = new CompoundTag(); tag.putBoolean(Constants.Item.Fireworks.FLICKER, effect.flickers()); tag.putBoolean(Constants.Item.Fireworks.TRAIL, effect.hasTrail()); - tag.putByte(Constants.Item.Fireworks.SHAPE_TYPE, (byte) registry.getId(effect.getShape())); - final int[] colorsArray = effect.getColors().stream() - .mapToInt(Color::getRgb) + tag.putByte(Constants.Item.Fireworks.SHAPE_TYPE, (byte) registry.getId(effect.shape())); + final int[] colorsArray = effect.colors().stream() + .mapToInt(Color::rgb) .toArray(); tag.putIntArray(Constants.Item.Fireworks.COLORS, colorsArray); - final int[] fadeArray = effect.getFadeColors().stream() - .mapToInt(Color::getRgb) + final int[] fadeArray = effect.fadeColors().stream() + .mapToInt(Color::rgb) .toArray(); tag.putIntArray(Constants.Item.Fireworks.FADE_COLORS, fadeArray); return tag; diff --git a/src/main/java/org/spongepowered/common/util/ParticleOptionUtil.java b/src/main/java/org/spongepowered/common/util/ParticleOptionUtil.java index 36594d70195..7e38d9e6978 100644 --- a/src/main/java/org/spongepowered/common/util/ParticleOptionUtil.java +++ b/src/main/java/org/spongepowered/common/util/ParticleOptionUtil.java @@ -51,7 +51,7 @@ public static ImmutableMap, Object> generateDefaultsForNamed(P options.put(ParticleOptions.QUANTITY.get(), 1); if (type.getDeserializer() == BlockParticleOption.DESERIALIZER) { - options.put(ParticleOptions.BLOCK_STATE.get(), BlockTypes.AIR.get().getDefaultState()); + options.put(ParticleOptions.BLOCK_STATE.get(), BlockTypes.AIR.get().defaultState()); } else if (type.getDeserializer() == ItemParticleOption.DESERIALIZER) { options.put(ParticleOptions.ITEM_STACK_SNAPSHOT.get(), ItemStackSnapshot.empty()); } else if (type.getDeserializer() == DustParticleOptions.DESERIALIZER) { diff --git a/src/main/java/org/spongepowered/common/util/SpongeAABB.java b/src/main/java/org/spongepowered/common/util/SpongeAABB.java index aee16520493..b7aee5c180c 100644 --- a/src/main/java/org/spongepowered/common/util/SpongeAABB.java +++ b/src/main/java/org/spongepowered/common/util/SpongeAABB.java @@ -52,25 +52,25 @@ public SpongeAABB(final Vector3d v1, final Vector3d v2) { } @Override - public Vector3d getMin() { + public Vector3d min() { return this.min; } @Override - public Vector3d getMax() { + public Vector3d max() { return this.max; } @Override - public Vector3d getCenter() { + public Vector3d center() { if (this.center == null) { - this.center = this.min.add(this.getSize().div(2)); + this.center = this.min.add(this.size().div(2)); } return this.center; } @Override - public Vector3d getSize() { + public Vector3d size() { if (this.size == null) { this.size = this.max.sub(this.min); } @@ -91,8 +91,8 @@ public boolean intersects(final AABB other) { Objects.requireNonNull(other, "other"); final Vector3d mins = this.min; final Vector3d maxs = this.max; - final Vector3d mino = other.getMin(); - final Vector3d maxo = other.getMax(); + final Vector3d mino = other.min(); + final Vector3d maxo = other.max(); return maxs.getX() >= mino.getX() && maxo.getX() >= mins.getX() && maxs.getY() >= mino.getY() && maxo.getY() >= mins.getY() && maxs.getZ() >= mino.getZ() && maxo.getZ() >= mins.getZ(); diff --git a/src/main/java/org/spongepowered/common/util/SpongeCriterionUtil.java b/src/main/java/org/spongepowered/common/util/SpongeCriterionUtil.java index 08fc5fced09..a92091fe379 100644 --- a/src/main/java/org/spongepowered/common/util/SpongeCriterionUtil.java +++ b/src/main/java/org/spongepowered/common/util/SpongeCriterionUtil.java @@ -67,7 +67,7 @@ private static void build(final Class type, final A } checkNotNull(criterion, "criterion"); if (type.isInstance(criterion)) { - criteria.addAll(((OperatorCriterion) criterion).getCriteria()); + criteria.addAll(((OperatorCriterion) criterion).criteria()); } else { criteria.add(criterion); } @@ -92,10 +92,10 @@ private static List> collectCriteria(final AdvancementCriterion cri List> requirements = new ArrayList<>(); if (criterion instanceof SpongeAndCriterion) { - ((SpongeOperatorCriterion) criterion).getCriteria().forEach(c -> requirements.addAll(SpongeCriterionUtil.collectCriteria(c, criteria))); + ((SpongeOperatorCriterion) criterion).criteria().forEach(c -> requirements.addAll(SpongeCriterionUtil.collectCriteria(c, criteria))); } else if (criterion instanceof SpongeOrCriterion) { // OR List of AND Criteria of OR Criteria - final List>> andRequirementsList = ((SpongeOperatorCriterion) criterion).getCriteria().stream().map(c -> SpongeCriterionUtil + final List>> andRequirementsList = ((SpongeOperatorCriterion) criterion).criteria().stream().map(c -> SpongeCriterionUtil .collectCriteria(c, criteria)).collect(Collectors.toList()); List> finalList = new ArrayList<>(); // For every AND Criteria @@ -122,14 +122,14 @@ private static List> collectCriteria(final AdvancementCriterion cri requirements.addAll(finalList); } else if (criterion instanceof SpongeScoreCriterion) { final SpongeScoreCriterion scoreCriterion = (SpongeScoreCriterion) criterion; - for (int i = 0; i < scoreCriterion.getGoal(); i++) { + for (int i = 0; i < scoreCriterion.goal(); i++) { final DefaultedAdvancementCriterion internalCriterion = scoreCriterion.internalCriteria.get(i); - criteria.put(internalCriterion.getName(), ((Criterion) internalCriterion)); - requirements.add(Collections.singletonList(internalCriterion.getName())); + criteria.put(internalCriterion.name(), ((Criterion) internalCriterion)); + requirements.add(Collections.singletonList(internalCriterion.name())); } } else { - criteria.put(criterion.getName(), (Criterion) criterion); - requirements.add(Collections.singletonList(criterion.getName())); + criteria.put(criterion.name(), (Criterion) criterion); + requirements.add(Collections.singletonList(criterion.name())); } return requirements; diff --git a/src/main/java/org/spongepowered/common/util/SpongeMinecraftDayTime.java b/src/main/java/org/spongepowered/common/util/SpongeMinecraftDayTime.java index 7dd421914b7..b10e0ced4d7 100644 --- a/src/main/java/org/spongepowered/common/util/SpongeMinecraftDayTime.java +++ b/src/main/java/org/spongepowered/common/util/SpongeMinecraftDayTime.java @@ -70,7 +70,7 @@ public int minute() { public MinecraftDayTime add(final Ticks ticks) { Objects.requireNonNull(ticks); - return new SpongeMinecraftDayTime(this.internalTime + ticks.getTicks()); + return new SpongeMinecraftDayTime(this.internalTime + ticks.ticks()); } @Override @@ -89,11 +89,11 @@ public MinecraftDayTime add(final int days, final int hours, final int minutes) @Override public MinecraftDayTime subtract(final Ticks ticks) { - final long time = this.internalTime - ticks.getTicks(); + final long time = this.internalTime - ticks.ticks(); if (time <= 0) { throw new IllegalArgumentException("ticks is larger than this day time object"); } - return new SpongeMinecraftDayTime(this.internalTime - ticks.getTicks()); + return new SpongeMinecraftDayTime(this.internalTime - ticks.ticks()); } @Override @@ -178,7 +178,7 @@ public MinecraftDayTime of(final Engine engine, final Ticks ticks) { Objects.requireNonNull(engine); Objects.requireNonNull(ticks); - return new SpongeMinecraftDayTime(ticks.getTicks()); + return new SpongeMinecraftDayTime(ticks.ticks()); } } } diff --git a/src/main/java/org/spongepowered/common/util/SpongeOrientation.java b/src/main/java/org/spongepowered/common/util/SpongeOrientation.java index d95f5bd03c3..e6108e3f469 100644 --- a/src/main/java/org/spongepowered/common/util/SpongeOrientation.java +++ b/src/main/java/org/spongepowered/common/util/SpongeOrientation.java @@ -35,7 +35,7 @@ public SpongeOrientation(final int angle) { } @Override - public int getAngle() { + public int angle() { return this.angle; } } diff --git a/src/main/java/org/spongepowered/common/util/SpongeRange.java b/src/main/java/org/spongepowered/common/util/SpongeRange.java index b3e7c3cc70f..9e2a202d7e9 100644 --- a/src/main/java/org/spongepowered/common/util/SpongeRange.java +++ b/src/main/java/org/spongepowered/common/util/SpongeRange.java @@ -43,13 +43,13 @@ public SpongeRange(@Nullable final T min, @Nullable final T max) { @Override @Nullable - public T getMin() { + public T min() { return this.min; } @Override @Nullable - public T getMax() { + public T max() { return this.max; } diff --git a/src/main/java/org/spongepowered/common/util/SpongeTicks.java b/src/main/java/org/spongepowered/common/util/SpongeTicks.java index 9594515b0fb..8e860c4ad28 100644 --- a/src/main/java/org/spongepowered/common/util/SpongeTicks.java +++ b/src/main/java/org/spongepowered/common/util/SpongeTicks.java @@ -44,7 +44,7 @@ public SpongeTicks(final long ticks) { } @Override - public long getMinecraftSeconds(@NonNull final Engine engine) { + public long minecraftSeconds(@NonNull final Engine engine) { // We do this to try to ensure we get the most accurate number of seconds we can. // We know the hour rate is 1000 ticks, we can get an accurate hour count. This reduces the potential // for error. @@ -56,18 +56,18 @@ public long getMinecraftSeconds(@NonNull final Engine engine) { @Override @NonNull - public Duration getMinecraftDayTimeDuration(@NonNull final Engine engine) { - return Duration.of(this.getMinecraftSeconds(engine), ChronoUnit.SECONDS); + public Duration minecraftDayTimeDuration(@NonNull final Engine engine) { + return Duration.of(this.minecraftSeconds(engine), ChronoUnit.SECONDS); } @Override @NonNull - public Duration getExpectedDuration(@NonNull final Engine engine) { + public Duration expectedDuration(@NonNull final Engine engine) { return this.effectiveMinimumDuration; } @Override - public long getTicks() { + public long ticks() { return this.ticks; } diff --git a/src/main/java/org/spongepowered/common/util/SpongeTransform.java b/src/main/java/org/spongepowered/common/util/SpongeTransform.java index fb9da2f30b8..795a6d92abd 100644 --- a/src/main/java/org/spongepowered/common/util/SpongeTransform.java +++ b/src/main/java/org/spongepowered/common/util/SpongeTransform.java @@ -47,7 +47,7 @@ public SpongeTransform(final Vector3d position, final Vector3d rotation, final V } @Override - public Vector3d getPosition() { + public Vector3d position() { return this.position; } @@ -59,7 +59,7 @@ public Transform withPosition(final Vector3d position) { } @Override - public Vector3d getRotation() { + public Vector3d rotation() { return this.rotation; } @@ -78,7 +78,7 @@ public Transform withRotation(final Quaterniond rotation) { } @Override - public Quaterniond getRotationAsQuaternion() { + public Quaterniond rotationAsQuaternion() { if (this.rotationQuaternion == null) { this.rotationQuaternion = SpongeTransform.fromAxesAngles(this.rotation); } @@ -86,22 +86,22 @@ public Quaterniond getRotationAsQuaternion() { } @Override - public double getPitch() { + public double pitch() { return this.rotation.getX(); } @Override - public double getYaw() { + public double yaw() { return this.rotation.getY(); } @Override - public double getRoll() { + public double roll() { return this.rotation.getZ(); } @Override - public Vector3d getScale() { + public Vector3d scale() { return this.scale; } @@ -117,9 +117,9 @@ public Transform add(final Transform other) { Objects.requireNonNull(other); return new SpongeTransform( - this.position.add(other.getPosition()), - SpongeTransform.toAxesAngles(this.getRotationAsQuaternion().mul(other.getRotationAsQuaternion())), - this.scale.add(other.getScale()) + this.position.add(other.position()), + SpongeTransform.toAxesAngles(this.rotationAsQuaternion().mul(other.rotationAsQuaternion())), + this.scale.add(other.scale()) ); } @@ -147,7 +147,7 @@ public Transform rotate(final Quaterniond rotation) { return new SpongeTransform( this.position, - SpongeTransform.toAxesAngles(this.getRotationAsQuaternion().mul(rotation)), + SpongeTransform.toAxesAngles(this.rotationAsQuaternion().mul(rotation)), this.scale ); } @@ -166,7 +166,7 @@ public Transform scale(final Vector3d scale) { @Override public Matrix4d toMatrix() { return Matrix4d.createScaling(this.scale.toVector4(1)) - .rotate(this.getRotationAsQuaternion()) + .rotate(this.rotationAsQuaternion()) .translate(this.position); } diff --git a/src/main/java/org/spongepowered/common/util/UsernameCache.java b/src/main/java/org/spongepowered/common/util/UsernameCache.java index 593c42c0ea1..8e9e12de11d 100644 --- a/src/main/java/org/spongepowered/common/util/UsernameCache.java +++ b/src/main/java/org/spongepowered/common/util/UsernameCache.java @@ -57,7 +57,7 @@ public final class UsernameCache { public UsernameCache(final Server server) { this.usernameByUniqueId = new ConcurrentHashMap<>(); this.gson = new GsonBuilder().setPrettyPrinting().create(); - this.cacheFile = server.getGame().getGameDirectory().resolve("usernamecache.json"); + this.cacheFile = server.game().gameDirectory().resolve("usernamecache.json"); } public void setUsername(final UUID uniqueId, final String username) { diff --git a/src/main/java/org/spongepowered/common/util/VecHelper.java b/src/main/java/org/spongepowered/common/util/VecHelper.java index ee7fcd17340..21645044556 100644 --- a/src/main/java/org/spongepowered/common/util/VecHelper.java +++ b/src/main/java/org/spongepowered/common/util/VecHelper.java @@ -195,8 +195,8 @@ public static net.minecraft.world.phys.AABB toMinecraftAABB(final AABB box) { if (box == null) { return null; } - final org.spongepowered.math.vector.Vector3d min = box.getMin(); - final org.spongepowered.math.vector.Vector3d max = box.getMax(); + final org.spongepowered.math.vector.Vector3d min = box.min(); + final org.spongepowered.math.vector.Vector3d max = box.max(); return new net.minecraft.world.phys.AABB( min.getX(), min.getY(), min.getZ(), max.getX(), max.getY(), max.getZ() diff --git a/src/main/java/org/spongepowered/common/util/metric/SpongeMetricsConfigManager.java b/src/main/java/org/spongepowered/common/util/metric/SpongeMetricsConfigManager.java index 37c0d2568e3..d0cf183a004 100644 --- a/src/main/java/org/spongepowered/common/util/metric/SpongeMetricsConfigManager.java +++ b/src/main/java/org/spongepowered/common/util/metric/SpongeMetricsConfigManager.java @@ -55,12 +55,12 @@ public CompletableFuture savePluginsInConfig(final M } @Override - public Tristate getGlobalCollectionState() { + public Tristate globalCollectionState() { return this.metrics.get().globalState; } @Override - public Tristate getCollectionState(final PluginContainer container) { + public Tristate collectionState(final PluginContainer container) { return this.metrics.get().getCollectionState(container); } } diff --git a/src/main/java/org/spongepowered/common/util/raytrace/AbstractSpongeRayTrace.java b/src/main/java/org/spongepowered/common/util/raytrace/AbstractSpongeRayTrace.java index fafc09a5455..4de83afd8da 100644 --- a/src/main/java/org/spongepowered/common/util/raytrace/AbstractSpongeRayTrace.java +++ b/src/main/java/org/spongepowered/common/util/raytrace/AbstractSpongeRayTrace.java @@ -38,7 +38,6 @@ import org.spongepowered.api.world.server.ServerLocation; import org.spongepowered.api.world.server.ServerWorld; import org.spongepowered.common.util.VecHelper; -import org.spongepowered.common.util.raytrace.AbstractSpongeRayTrace.TData; import org.spongepowered.math.vector.Vector3d; import org.spongepowered.math.vector.Vector3i; @@ -71,7 +70,7 @@ public abstract class AbstractSpongeRayTrace implements Ray @Override @NonNull public final RayTrace<@NonNull T> world(@NonNull final ServerWorld serverWorld) { - this.world = serverWorld.getKey(); + this.world = serverWorld.key(); return this; } @@ -80,7 +79,7 @@ public abstract class AbstractSpongeRayTrace implements Ray public RayTrace<@NonNull T> sourceEyePosition(@NonNull final Living entity) { this.sourcePosition(entity.get(Keys.EYE_POSITION) .orElseThrow(() -> new IllegalArgumentException("Entity does not have an eye position key"))); - return this.world(entity.getServerLocation().getWorld()); + return this.world(entity.serverLocation().world()); } @Override @@ -170,8 +169,8 @@ public abstract class AbstractSpongeRayTrace implements Ray throw new IllegalStateException("The start and end must be two different vectors"); } - final ServerWorld serverWorld = Sponge.getServer().getWorldManager().world(this.world) - .orElseThrow(() -> new IllegalStateException("World with key " + this.world.getFormatted() + " is not loaded!")); + final ServerWorld serverWorld = Sponge.server().worldManager().world(this.world) + .orElseThrow(() -> new IllegalStateException("World with key " + this.world.formatted() + " is not loaded!")); Vector3i currentBlock = this.initialBlock(direction); final Vector3i steps = this.createSteps(direction); @@ -223,7 +222,7 @@ public abstract class AbstractSpongeRayTrace implements Ray if (requiresEntityTracking && this.continueWhileEntity != null) { final double resultDistance; if (result.isPresent()) { - resultDistance = result.get().getHitPosition().distanceSquared(currentLocation); + resultDistance = result.get().hitPosition().distanceSquared(currentLocation); } else { resultDistance = Double.MAX_VALUE; } @@ -312,7 +311,7 @@ final LocatableBlock getBlock(final ServerWorld world, final net.minecraft.world Math.min(in.y, out.y), Math.min(in.z, out.z) ); - return world.getLocatableBlock(coord); + return world.locatableBlock(coord); } private boolean shouldAdvanceThroughBlock(final ServerWorld serverWorld, diff --git a/src/main/java/org/spongepowered/common/util/raytrace/SpongeBlockRayTrace.java b/src/main/java/org/spongepowered/common/util/raytrace/SpongeBlockRayTrace.java index 9625952a77e..e1a3d74b0ba 100644 --- a/src/main/java/org/spongepowered/common/util/raytrace/SpongeBlockRayTrace.java +++ b/src/main/java/org/spongepowered/common/util/raytrace/SpongeBlockRayTrace.java @@ -39,7 +39,7 @@ public final class SpongeBlockRayTrace extends AbstractSpongeRayTrace<@NonNull LocatableBlock> { private static final Predicate DEFAULT_FILTER = block -> { - final BlockType type = block.getBlockState().getType(); + final BlockType type = block.blockState().type(); return type != BlockTypes.CAVE_AIR.get() && type != BlockTypes.VOID_AIR.get() && type != BlockTypes.AIR.get(); }; diff --git a/src/main/java/org/spongepowered/common/util/raytrace/SpongeEntityRayTrace.java b/src/main/java/org/spongepowered/common/util/raytrace/SpongeEntityRayTrace.java index 9c7ca25a448..33798316c38 100644 --- a/src/main/java/org/spongepowered/common/util/raytrace/SpongeEntityRayTrace.java +++ b/src/main/java/org/spongepowered/common/util/raytrace/SpongeEntityRayTrace.java @@ -61,7 +61,7 @@ List selectEntities(final ServerWorld serverW double currentSqDist = Double.MAX_VALUE; RayTraceResult<@NonNull Entity> returnedEntity = null; final LocatableBlock locatableBlock = this.getBlock(serverWorld, vec3din, vec3dend); - for (final net.minecraft.world.entity.Entity entity : this.selectEntities(serverWorld, this.getBlockAABB(locatableBlock.getBlockPosition()))) { + for (final net.minecraft.world.entity.Entity entity : this.selectEntities(serverWorld, this.getBlockAABB(locatableBlock.blockPosition()))) { final Optional vec3d = entity.getBoundingBox().clip(vec3din, vec3dend); if (vec3d.isPresent()) { final Vec3 hitPosition = vec3d.get(); diff --git a/src/main/java/org/spongepowered/common/util/raytrace/SpongeRayTraceFactory.java b/src/main/java/org/spongepowered/common/util/raytrace/SpongeRayTraceFactory.java index 8510d99f242..ed59d8f13d4 100644 --- a/src/main/java/org/spongepowered/common/util/raytrace/SpongeRayTraceFactory.java +++ b/src/main/java/org/spongepowered/common/util/raytrace/SpongeRayTraceFactory.java @@ -39,7 +39,7 @@ public final class SpongeRayTraceFactory implements RayTrace.Factory { public SpongeRayTraceFactory() { this.onlyAir = locatableBlock -> { - final BlockType type = locatableBlock.getBlockState().getType(); + final BlockType type = locatableBlock.blockState().type(); return type == BlockTypes.AIR.get() || type == BlockTypes.CAVE_AIR.get() || type == BlockTypes.VOID_AIR.get(); diff --git a/src/main/java/org/spongepowered/common/util/raytrace/SpongeRayTraceResult.java b/src/main/java/org/spongepowered/common/util/raytrace/SpongeRayTraceResult.java index ab1d4437f25..55bde316eac 100644 --- a/src/main/java/org/spongepowered/common/util/raytrace/SpongeRayTraceResult.java +++ b/src/main/java/org/spongepowered/common/util/raytrace/SpongeRayTraceResult.java @@ -40,12 +40,12 @@ public SpongeRayTraceResult(final T selectedObject, final Vector3d hitPosition) } @Override - public T getSelectedObject() { + public T selectedObject() { return this.selectedObject; } @Override - public Vector3d getHitPosition() { + public Vector3d hitPosition() { return this.hitPosition; } diff --git a/src/main/java/org/spongepowered/common/world/SpongeExplosionBuilder.java b/src/main/java/org/spongepowered/common/world/SpongeExplosionBuilder.java index d7ff7f122dc..a626c0aa9f0 100644 --- a/src/main/java/org/spongepowered/common/world/SpongeExplosionBuilder.java +++ b/src/main/java/org/spongepowered/common/world/SpongeExplosionBuilder.java @@ -113,16 +113,16 @@ public Explosion.Builder knockback(double knockback) { @Override public Explosion.Builder from(Explosion value) { - this.location = value.getServerLocation(); - this.sourceExplosive = value.getSourceExplosive().orElse(null); - this.radius = value.getRadius(); + this.location = value.serverLocation(); + this.sourceExplosive = value.sourceExplosive().orElse(null); + this.radius = value.radius(); this.canCauseFire = value.canCauseFire(); this.shouldBreakBlocks = value.shouldBreakBlocks(); this.shouldSmoke = value.shouldPlaySmoke(); this.shouldDamageEntities = value.shouldDamageEntities(); - this.resolution = value.getResolution(); - this.randomness = value.getRandomness(); - this.knockback = value.getKnockback(); + this.resolution = value.resolution(); + this.randomness = value.randomness(); + this.knockback = value.knockback(); return this; } @@ -146,8 +146,8 @@ public Explosion build() throws IllegalStateException { // TODO Check coordinates and if world is loaded here. Preconditions.checkState(this.location != null, "Location is null!"); - final World world = this.location.getWorld(); - final Vector3d origin = this.location.getPosition(); + final World world = this.location.world(); + final Vector3d origin = this.location.position(); final net.minecraft.world.level.Explosion explosion = new net.minecraft.world.level.Explosion((net.minecraft.world.level.Level) world, (Entity) this.sourceExplosive, null, null, origin.getX(), origin.getY(), origin.getZ(), this.radius, this.canCauseFire, this.shouldSmoke ? net.minecraft.world.level.Explosion.BlockInteraction.DESTROY : net.minecraft.world.level.Explosion.BlockInteraction.NONE); diff --git a/src/main/java/org/spongepowered/common/world/SpongeLocation.java b/src/main/java/org/spongepowered/common/world/SpongeLocation.java index b89c841089f..cf7adeb23a6 100644 --- a/src/main/java/org/spongepowered/common/world/SpongeLocation.java +++ b/src/main/java/org/spongepowered/common/world/SpongeLocation.java @@ -75,7 +75,7 @@ protected SpongeLocation(final W worldRef, final Vector3d position, final Vector } @Override - public W getWorld() { + public W world() { final W world = this.worldRef.get(); if (world == null) { throw new IllegalStateException("World Reference is no longer valid!"); @@ -84,7 +84,7 @@ public W getWorld() { } @Override - public Optional getWorldIfAvailable() { + public Optional worldIfAvailable() { return Optional.ofNullable(this.worldRef.get()); } @@ -99,52 +99,52 @@ public boolean isValid() { } @Override - public Vector3d getPosition() { + public Vector3d position() { return this.position; } @Override - public Vector3i getBlockPosition() { + public Vector3i blockPosition() { return this.blockPosition; } @Override - public Vector3i getChunkPosition() { + public Vector3i chunkPosition() { return this.chunkPosition; } @Override - public Vector3i getBiomePosition() { + public Vector3i biomePosition() { return this.biomePosition; } @Override - public double getX() { + public double x() { return this.position.getX(); } @Override - public double getY() { + public double y() { return this.position.getY(); } @Override - public double getZ() { - return this.getPosition().getZ(); + public double z() { + return this.position().getZ(); } @Override - public int getBlockX() { + public int blockX() { return this.blockPosition.getX(); } @Override - public int getBlockY() { + public int blockY() { return this.blockPosition.getY(); } @Override - public int getBlockZ() { + public int blockZ() { return this.blockPosition.getZ(); } @@ -167,7 +167,7 @@ public L withPosition(final Vector3d position) { throw new IllegalStateException("World Reference is null!"); } // TODO - for now, we make the assumption we always have a server object if we're creating locations - final ChunkLayout chunkLayout = Sponge.getServer().getChunkLayout(); + final ChunkLayout chunkLayout = Sponge.server().chunkLayout(); return (L) new SpongeLocation<>(world, chunkLayout, position); } @@ -179,7 +179,7 @@ public L withBlockPosition(final Vector3i position) { throw new IllegalStateException("World Reference is null!"); } // TODO - for now, we make the assumption we always have a server object if we're creating locations - final ChunkLayout chunkLayout = Sponge.getServer().getChunkLayout(); + final ChunkLayout chunkLayout = Sponge.server().chunkLayout(); return (L) new SpongeLocation<>(world, chunkLayout, position.toDouble()); } @@ -224,53 +224,53 @@ public L relativeToBlock(final Direction direction) { } @Override - public Biome getBiome() { - return this.getWorld().getBiome(this.blockPosition); + public Biome biome() { + return this.world().biome(this.blockPosition); } @Override public boolean hasBlock() { - return this.isValid() && this.getWorld().hasBlockState(this.blockPosition); + return this.isValid() && this.world().hasBlockState(this.blockPosition); } @Override - public BlockState getBlock() { - return this.getWorld().getBlock(this.blockPosition); + public BlockState block() { + return this.world().block(this.blockPosition); } @Override - public FluidState getFluid() { - return this.getWorld().getFluid(this.blockPosition); + public FluidState fluid() { + return this.world().fluid(this.blockPosition); } @Override public boolean hasBlockEntity() { - return this.isValid() && this.getWorld().getBlockEntity(this.blockPosition).isPresent(); + return this.isValid() && this.world().blockEntity(this.blockPosition).isPresent(); } @Override - public Optional getBlockEntity() { - return this.getWorld().getBlockEntity(this.blockPosition); + public Optional blockEntity() { + return this.world().blockEntity(this.blockPosition); } @Override public boolean setBlock(final BlockState state) { - return this.getWorld().setBlock(this.blockPosition, state); + return this.world().setBlock(this.blockPosition, state); } @Override public boolean setBlock(final BlockState state, final BlockChangeFlag flag) { - return this.getWorld().setBlock(this.blockPosition, state, flag); + return this.world().setBlock(this.blockPosition, state, flag); } @Override public boolean setBlockType(final BlockType type) { - return this.getWorld().setBlock(this.blockPosition, type.getDefaultState()); + return this.world().setBlock(this.blockPosition, type.defaultState()); } @Override public boolean setBlockType(final BlockType type, final BlockChangeFlag flag) { - return this.getWorld().setBlock(this.blockPosition, type.getDefaultState(), flag); + return this.world().setBlock(this.blockPosition, type.defaultState(), flag); } public BlockPos asBlockPos() { diff --git a/src/main/java/org/spongepowered/common/world/biome/SpongeBiomeProviderFactory.java b/src/main/java/org/spongepowered/common/world/biome/SpongeBiomeProviderFactory.java index 34cad6aa124..acab406dd67 100644 --- a/src/main/java/org/spongepowered/common/world/biome/SpongeBiomeProviderFactory.java +++ b/src/main/java/org/spongepowered/common/world/biome/SpongeBiomeProviderFactory.java @@ -126,6 +126,6 @@ public ConfigurableBiomeProvider checkerb public BiomeProvider fixed(final RegistryReference biome) { Objects.requireNonNull(biome, "biome"); - return (BiomeProvider) new FixedBiomeSource(() -> (net.minecraft.world.level.biome.Biome) (Object) biome.get(Sponge.getServer().registries())); + return (BiomeProvider) new FixedBiomeSource(() -> (net.minecraft.world.level.biome.Biome) (Object) biome.get(Sponge.server().registries())); } } diff --git a/src/main/java/org/spongepowered/common/world/border/PlayerOwnBorderListener.java b/src/main/java/org/spongepowered/common/world/border/PlayerOwnBorderListener.java index 4eb30bc5222..b3e812d0249 100644 --- a/src/main/java/org/spongepowered/common/world/border/PlayerOwnBorderListener.java +++ b/src/main/java/org/spongepowered/common/world/border/PlayerOwnBorderListener.java @@ -76,7 +76,7 @@ public void onBorderSetDamageSafeZOne(final WorldBorder border, final double new * This method is for cleaning up the player reference once they disconnect. */ public void onPlayerDisconnect() { - ((ServerPlayer) this.player).getWorldBorder().ifPresent(border -> ((WorldBorderAccessor) border).accessor$listeners().remove(this)); + ((ServerPlayer) this.player).worldBorder().ifPresent(border -> ((WorldBorderAccessor) border).accessor$listeners().remove(this)); } private void sendBorderPacket(final Packet packet) { diff --git a/src/main/java/org/spongepowered/common/world/border/SpongeWorldBorderBuilder.java b/src/main/java/org/spongepowered/common/world/border/SpongeWorldBorderBuilder.java index d5a0e625ca4..4d3def23b75 100644 --- a/src/main/java/org/spongepowered/common/world/border/SpongeWorldBorderBuilder.java +++ b/src/main/java/org/spongepowered/common/world/border/SpongeWorldBorderBuilder.java @@ -40,12 +40,12 @@ public class SpongeWorldBorderBuilder implements WorldBorder.Builder { @Override public WorldBorder.Builder from(final WorldBorder border) { - this.diameter = border.getDiameter(); - this.center = border.getCenter(); - this.warningTime = border.getWarningTime(); - this.warningDistance = border.getWarningDistance(); - this.damageThreshold = border.getDamageThreshold(); - this.damageAmount = border.getDamageAmount(); + this.diameter = border.diameter(); + this.center = border.center(); + this.warningTime = border.warningTime(); + this.warningDistance = border.warningDistance(); + this.damageThreshold = border.damageThreshold(); + this.damageAmount = border.damageAmount(); return this; } diff --git a/src/main/java/org/spongepowered/common/world/generation/config/SpongeFlatGeneratorConfigBuilder.java b/src/main/java/org/spongepowered/common/world/generation/config/SpongeFlatGeneratorConfigBuilder.java index bb1c80bae8d..016d72234b1 100644 --- a/src/main/java/org/spongepowered/common/world/generation/config/SpongeFlatGeneratorConfigBuilder.java +++ b/src/main/java/org/spongepowered/common/world/generation/config/SpongeFlatGeneratorConfigBuilder.java @@ -106,9 +106,9 @@ public FlatGeneratorConfig.Builder reset() { this.structureConfig = (StructureGenerationConfig) new StructureSettings(Optional.of(StructureSettings.DEFAULT_STRONGHOLD), Maps.newHashMap(ImmutableMap.of(StructureFeature.VILLAGE, StructureSettings.DEFAULTS.get(StructureFeature.VILLAGE)))); this.layers.clear(); - this.layers.add(LayerConfig.of(1, BlockTypes.BEDROCK.get().getDefaultState())); - this.layers.add(LayerConfig.of(2, BlockTypes.DIRT.get().getDefaultState())); - this.layers.add(LayerConfig.of(1, BlockTypes.GRASS_BLOCK.get().getDefaultState())); + this.layers.add(LayerConfig.of(1, BlockTypes.BEDROCK.get().defaultState())); + this.layers.add(LayerConfig.of(2, BlockTypes.DIRT.get().defaultState())); + this.layers.add(LayerConfig.of(1, BlockTypes.GRASS_BLOCK.get().defaultState())); this.biome = Biomes.PLAINS; this.performDecoration = true; this.populateLakes = true; diff --git a/src/main/java/org/spongepowered/common/world/generation/config/SpongeNoiseGeneratorConfig.java b/src/main/java/org/spongepowered/common/world/generation/config/SpongeNoiseGeneratorConfig.java index 0fba3b93921..95bc54ba5db 100644 --- a/src/main/java/org/spongepowered/common/world/generation/config/SpongeNoiseGeneratorConfig.java +++ b/src/main/java/org/spongepowered/common/world/generation/config/SpongeNoiseGeneratorConfig.java @@ -90,8 +90,8 @@ public NoiseGeneratorConfig.Builder seaLevel(final int y) { public NoiseGeneratorConfig.Builder reset() { this.structureConfig = (StructureGenerationConfig) new StructureSettings(true); this.noiseConfig = NoiseConfig.overworld(); - this.defaultBlock = BlockTypes.STONE.get().getDefaultState(); - this.defaultFluid = BlockTypes.WATER.get().getDefaultState(); + this.defaultBlock = BlockTypes.STONE.get().defaultState(); + this.defaultFluid = BlockTypes.WATER.get().defaultState(); this.bedrockRoofY = -10; this.bedrockFloorY = 0; this.seaLevel = 63; diff --git a/src/main/java/org/spongepowered/common/world/generation/config/flat/SpongeLayerConfigFactory.java b/src/main/java/org/spongepowered/common/world/generation/config/flat/SpongeLayerConfigFactory.java index 5cddd8779f2..3ad79f325bd 100644 --- a/src/main/java/org/spongepowered/common/world/generation/config/flat/SpongeLayerConfigFactory.java +++ b/src/main/java/org/spongepowered/common/world/generation/config/flat/SpongeLayerConfigFactory.java @@ -34,7 +34,7 @@ public final class SpongeLayerConfigFactory implements LayerConfig.Factory { @Override public LayerConfig of(final int height, final BlockState block) { - final FlatLayerInfo layer = new FlatLayerInfo(height, (Block) block.getType()); + final FlatLayerInfo layer = new FlatLayerInfo(height, (Block) block.type()); ((FlatLayerInfoAccessor) layer).accessor$blockState((net.minecraft.world.level.block.state.BlockState) block); return (LayerConfig) layer; } diff --git a/src/main/java/org/spongepowered/common/world/portal/EndPortalType.java b/src/main/java/org/spongepowered/common/world/portal/EndPortalType.java index 96574b218aa..920c064e09f 100644 --- a/src/main/java/org/spongepowered/common/world/portal/EndPortalType.java +++ b/src/main/java/org/spongepowered/common/world/portal/EndPortalType.java @@ -38,7 +38,7 @@ public final class EndPortalType extends VanillaPortalType { @Override public void generatePortal(final ServerLocation location, final Axis axis) { Objects.requireNonNull(location); - PortalHelper.generateEndPortal((ServerLevel) location.getWorld(), location.getBlockX(), location.getBlockY(), location.getBlockZ(), true); + PortalHelper.generateEndPortal((ServerLevel) location.world(), location.blockX(), location.blockY(), location.blockZ(), true); } @Override diff --git a/src/main/java/org/spongepowered/common/world/portal/NetherPortalType.java b/src/main/java/org/spongepowered/common/world/portal/NetherPortalType.java index 0f301efc631..fc413aadaa0 100644 --- a/src/main/java/org/spongepowered/common/world/portal/NetherPortalType.java +++ b/src/main/java/org/spongepowered/common/world/portal/NetherPortalType.java @@ -55,8 +55,8 @@ public final class NetherPortalType extends VanillaPortalType { static Optional findPortalInternal(final ServerLocation location) { - final ServerLevel serverWorld = (ServerLevel) location.getWorld(); - final BlockPos position = VecHelper.toBlockPos(location.getBlockPosition()); + final ServerLevel serverWorld = (ServerLevel) location.world(); + final BlockPos position = VecHelper.toBlockPos(location.blockPosition()); return serverWorld.getPortalForcer() .findPortalAround(position, serverWorld.dimension() == Level.NETHER); } @@ -68,7 +68,7 @@ public void generatePortal(final ServerLocation location, final Axis axis) { if (mcAxis == Direction.Axis.Y) { mcAxis = Direction.Axis.X; } - PortalHelper.generateNetherPortal((ServerLevel) location.getWorld(), location.getBlockX(), location.getBlockY(), location.getBlockZ(), mcAxis, true); + PortalHelper.generateNetherPortal((ServerLevel) location.world(), location.blockX(), location.blockY(), location.blockZ(), mcAxis, true); } @Override @@ -91,8 +91,8 @@ public boolean teleport(final Entity entity, final ServerLocation destination, f final PlatformTeleporter teleporter = new Teleporter(destination, generateDestinationPortal, this); - ((EntityAccessor) entity).accessor$portalEntrancePos(VecHelper.toBlockPos(entity.getBlockPosition())); - return ((EntityBridge) entity).bridge$changeDimension((ServerLevel) destination.getWorld(), teleporter) != null; + ((EntityAccessor) entity).accessor$portalEntrancePos(VecHelper.toBlockPos(entity.blockPosition())); + return ((EntityBridge) entity).bridge$changeDimension((ServerLevel) destination.world(), teleporter) != null; } @@ -117,15 +117,15 @@ public PortalInfo getPortalInfo(final net.minecraft.world.entity.Entity entity, Optional portal = NetherPortalType.findPortalInternal(this.originalDestination) .map(x -> this.createNetherPortalInfo(entity, targetWorld, x.minCorner, x)); - final Vector3d originalDestination = portal.map(x -> VecHelper.toVector3d(x.pos)).orElseGet(this.originalDestination::getPosition); + final Vector3d originalDestination = portal.map(x -> VecHelper.toVector3d(x.pos)).orElseGet(this.originalDestination::position); final ChangeEntityWorldEvent.Reposition reposition = ((EntityBridge) entity).bridge$fireRepositionEvent( - this.originalDestination.getWorld(), + this.originalDestination.world(), (org.spongepowered.api.world.server.ServerWorld) targetWorld, originalDestination ); - if (!reposition.isCancelled() && reposition.getDestinationPosition() != originalDestination) { + if (!reposition.isCancelled() && reposition.destinationPosition() != originalDestination) { // find another portal - portal = NetherPortalType.findPortalInternal(this.originalDestination.withPosition(reposition.getDestinationPosition())) + portal = NetherPortalType.findPortalInternal(this.originalDestination.withPosition(reposition.destinationPosition())) .map(x -> this.createNetherPortalInfo(entity, targetWorld, x.minCorner, x)); } diff --git a/src/main/java/org/spongepowered/common/world/portal/VanillaPortal.java b/src/main/java/org/spongepowered/common/world/portal/VanillaPortal.java index 3752d92260d..cb9510e5597 100644 --- a/src/main/java/org/spongepowered/common/world/portal/VanillaPortal.java +++ b/src/main/java/org/spongepowered/common/world/portal/VanillaPortal.java @@ -44,18 +44,18 @@ public VanillaPortal(final PortalType type, final ServerLocation origin, @Nullab } @Override - public PortalType getType() { + public PortalType type() { return this.type; } @Override - public ServerLocation getOrigin() { + public ServerLocation origin() { return this.origin; } // Vanilla has no knowledge of where portals go to until you try, best we can do... @Override - public Optional getDestination() { + public Optional destination() { return Optional.ofNullable(this.destination); } } diff --git a/src/main/java/org/spongepowered/common/world/schematic/ImmutableBimapPalette.java b/src/main/java/org/spongepowered/common/world/schematic/ImmutableBimapPalette.java index c766dca5256..cdc80ede1ea 100644 --- a/src/main/java/org/spongepowered/common/world/schematic/ImmutableBimapPalette.java +++ b/src/main/java/org/spongepowered/common/world/schematic/ImmutableBimapPalette.java @@ -73,12 +73,12 @@ public ImmutableBimapPalette( } @Override - public PaletteType getType() { + public PaletteType type() { return this.paletteType; } @Override - public int getHighestId() { + public int highestId() { return this.maxId; } @@ -100,7 +100,7 @@ public Optional> get(final int id) { @Override public Stream stream() { return this.idsr.keySet().stream() - .map(ref -> this.paletteType.getResolver().apply(ref.value(), this.registry)) + .map(ref -> this.paletteType.resolver().apply(ref.value(), this.registry)) .filter(Optional::isPresent) .map(Optional::get); } @@ -109,7 +109,7 @@ public Stream stream() { public Stream> streamWithIds() { return this.ids.entrySet().stream() .map(entry -> { - final Optional apply = this.paletteType.getResolver().apply(entry.getValue() + final Optional apply = this.paletteType.resolver().apply(entry.getValue() .value(), this.registry); return apply.map(value -> new AbstractMap.SimpleEntry<>(value, entry.getKey())); }) diff --git a/src/main/java/org/spongepowered/common/world/schematic/MutableBimapPalette.java b/src/main/java/org/spongepowered/common/world/schematic/MutableBimapPalette.java index 4bf7599ca38..9f88894f5f9 100644 --- a/src/main/java/org/spongepowered/common/world/schematic/MutableBimapPalette.java +++ b/src/main/java/org/spongepowered/common/world/schematic/MutableBimapPalette.java @@ -84,12 +84,12 @@ public MutableBimapPalette(final PaletteType paletteType, final Registry getType() { + public PaletteType type() { return this.paletteType; } @Override - public int getHighestId() { + public int highestId() { return this.maxId; } @@ -122,7 +122,7 @@ private int getOrAssignInternal(final PaletteReference ref) { } @Override - public int getOrAssign(final T state) { + public int orAssign(final T state) { final PaletteReference ref = MutableBimapPalette.createPaletteReference( state, this.paletteType, @@ -140,11 +140,11 @@ public Optional> get(final int id) { public Optional get(final int id, final RegistryHolder holder) { return this.get(id) .flatMap(ref -> { - final Optional byRegistry = this.paletteType.getResolver().apply(ref.value(), this.registry); + final Optional byRegistry = this.paletteType.resolver().apply(ref.value(), this.registry); if (!byRegistry.isPresent()) { return Objects.requireNonNull(holder,"RegistryHolder cannot be null") .findRegistry(ref.registry()) - .flatMap(reg -> this.getType().getResolver().apply(ref.value(), reg)); + .flatMap(reg -> this.type().resolver().apply(ref.value(), reg)); } return byRegistry; }); @@ -170,7 +170,7 @@ static PaletteReference createPaletteReference( final PaletteType paletteType, final Registry registry ) { - final String string = paletteType.getStringifier().apply(registry, state); + final String string = paletteType.stringifier().apply(registry, state); return PaletteReference.byString(registry.type(), string); } @@ -192,7 +192,7 @@ public boolean remove(final T state) { public Stream stream() { final HashBiMap, Integer> copy = HashBiMap.create(this.idsr); return copy.keySet().stream() - .map(ref -> this.paletteType.getResolver().apply(ref.value(), this.registry)) + .map(ref -> this.paletteType.resolver().apply(ref.value(), this.registry)) .filter(Optional::isPresent) .map(Optional::get); } @@ -202,7 +202,7 @@ public Stream> streamWithIds() { final HashBiMap> copy = HashBiMap.create(this.ids); return copy.entrySet().stream() .map(entry -> { - final Optional apply = this.paletteType.getResolver().apply(entry.getValue() + final Optional apply = this.paletteType.resolver().apply(entry.getValue() .value(), this.registry); return apply.map(value -> new AbstractMap.SimpleEntry<>(value, entry.getKey())); }) diff --git a/src/main/java/org/spongepowered/common/world/schematic/SpongePaletteType.java b/src/main/java/org/spongepowered/common/world/schematic/SpongePaletteType.java index ed79e55e800..a3a8ae42b7f 100644 --- a/src/main/java/org/spongepowered/common/world/schematic/SpongePaletteType.java +++ b/src/main/java/org/spongepowered/common/world/schematic/SpongePaletteType.java @@ -52,12 +52,12 @@ public Palette create(final RegistryHolder holder, final RegistryType r } @Override - public BiFunction, Optional> getResolver() { + public BiFunction, Optional> resolver() { return this.resolver; } @Override - public BiFunction, T, String> getStringifier() { + public BiFunction, T, String> stringifier() { return this.stringifier; } diff --git a/src/main/java/org/spongepowered/common/world/schematic/SpongeSchematic.java b/src/main/java/org/spongepowered/common/world/schematic/SpongeSchematic.java index f8b2c928f4d..602337a015d 100644 --- a/src/main/java/org/spongepowered/common/world/schematic/SpongeSchematic.java +++ b/src/main/java/org/spongepowered/common/world/schematic/SpongeSchematic.java @@ -73,17 +73,17 @@ public SpongeSchematic(final Vector3i start, final Vector3i size, } @Override - public Palette getBlockPalette() { + public Palette blockPalette() { return this.volume.getBlockPalette(); } @Override - public Palette getBiomePalette() { + public Palette biomePalette() { return this.volume.getBiomePalette(); } @Override - public DataView getMetadata() { + public DataView metadata() { return this.metadata; } @@ -98,42 +98,42 @@ public void removeBlockEntity(final int x, final int y, final int z) { } @Override - public Optional getBlockEntityArchetype(final int x, final int y, final int z) { - return this.volume.getBlockEntityArchetype(x, y, z); + public Optional blockEntityArchetype(final int x, final int y, final int z) { + return this.volume.blockEntityArchetype(x, y, z); } @Override - public Map getBlockEntityArchetypes() { - return this.volume.getBlockEntityArchetypes(); + public Map blockEntityArchetypes() { + return this.volume.blockEntityArchetypes(); } @Override - public VolumeStream getBlockEntityArchetypeStream(final Vector3i min, final Vector3i max, + public VolumeStream blockEntityArchetypeStream(final Vector3i min, final Vector3i max, final StreamOptions options ) { - return this.volume.getBlockEntityArchetypeStream(min, max, options); + return this.volume.blockEntityArchetypeStream(min, max, options); } @Override - public Collection getEntityArchetypes() { - return this.volume.getEntityArchetypes(); + public Collection entityArchetypes() { + return this.volume.entityArchetypes(); } @Override - public Collection getEntityArchetypes(final Predicate filter) { - return this.volume.getEntityArchetypes(filter); + public Collection entityArchetypes(final Predicate filter) { + return this.volume.entityArchetypes(filter); } @Override - public VolumeStream getEntityArchetypeStream( + public VolumeStream entityArchetypeStream( final Vector3i min, final Vector3i max, final StreamOptions options ) { - return this.volume.getEntityArchetypeStream(min, max, options); + return this.volume.entityArchetypeStream(min, max, options); } @Override - public Stream getEntitiesByPosition() { - return this.volume.getEntitiesByPosition(); + public Stream entitiesByPosition() { + return this.volume.entitiesByPosition(); } @Override @@ -147,32 +147,32 @@ public boolean removeBlock(final int x, final int y, final int z) { } @Override - public BlockState getBlock(final int x, final int y, final int z) { - return this.volume.getBlock(x, y, z); + public BlockState block(final int x, final int y, final int z) { + return this.volume.block(x, y, z); } @Override - public FluidState getFluid(final int x, final int y, final int z) { - return this.volume.getFluid(x, y, z); + public FluidState fluid(final int x, final int y, final int z) { + return this.volume.fluid(x, y, z); } @Override - public int getHighestYAt(final int x, final int z) { - return this.volume.getHighestYAt(x, z); + public int highestYAt(final int x, final int z) { + return this.volume.highestYAt(x, z); } @Override - public VolumeStream getBlockStateStream(final Vector3i min, final Vector3i max, final StreamOptions options + public VolumeStream blockStateStream(final Vector3i min, final Vector3i max, final StreamOptions options ) { - return this.volume.getBlockStateStream(min, max, options); + return this.volume.blockStateStream(min, max, options); } @Override public Optional get(final int x, final int y, final int z, final Key> key) { final Stream>> dataRetrievalStream = Stream.of( - () -> this.getBlock(x, y, z).get(key), - () -> this.getFluid(x, y, z).get(key), - () -> this.getBlockEntityArchetype(x, y, z).flatMap(archetype -> archetype.get(key)) + () -> this.block(x, y, z).get(key), + () -> this.fluid(x, y, z).get(key), + () -> this.blockEntityArchetype(x, y, z).flatMap(archetype -> archetype.get(key)) ); return dataRetrievalStream.map(Supplier::get) .filter(Optional::isPresent) @@ -183,9 +183,9 @@ public Optional get(final int x, final int y, final int z, final Key> Optional getValue(final int x, final int y, final int z, final Key key) { final Stream>> dataRetrievalStream = Stream.of( - () -> this.getBlock(x, y, z).getValue(key), - () -> this.getFluid(x, y, z).getValue(key), - () -> this.getBlockEntityArchetype(x, y, z).flatMap(archetype -> archetype.getValue(key)) + () -> this.block(x, y, z).getValue(key), + () -> this.fluid(x, y, z).getValue(key), + () -> this.blockEntityArchetype(x, y, z).flatMap(archetype -> archetype.getValue(key)) ); return dataRetrievalStream.map(Supplier::get) .filter(Optional::isPresent) @@ -196,9 +196,9 @@ public > Optional getValue(final int x, final int y, fi @Override public boolean supports(final int x, final int y, final int z, final Key key) { final Stream> dataRetrievalStream = Stream.of( - () -> this.getBlock(x, y, z).supports(key), - () -> this.getFluid(x, y, z).supports(key), - () -> this.getBlockEntityArchetype(x, y, z).map(archetype -> archetype.supports(key)).orElse(false) + () -> this.block(x, y, z).supports(key), + () -> this.fluid(x, y, z).supports(key), + () -> this.blockEntityArchetype(x, y, z).map(archetype -> archetype.supports(key)).orElse(false) ); return dataRetrievalStream.map(Supplier::get) .filter(Boolean::booleanValue) @@ -207,11 +207,11 @@ public boolean supports(final int x, final int y, final int z, final Key key) } @Override - public Set> getKeys(final int x, final int y, final int z) { + public Set> keys(final int x, final int y, final int z) { final Stream>>> dataRetrievalStream = Stream.of( - () -> this.getBlock(x, y, z).getKeys(), - () -> this.getFluid(x, y, z).getKeys(), - () -> this.getBlockEntityArchetype(x, y, z).map(ValueContainer::getKeys).orElseGet(Collections::emptySet) + () -> this.block(x, y, z).getKeys(), + () -> this.fluid(x, y, z).getKeys(), + () -> this.blockEntityArchetype(x, y, z).map(ValueContainer::getKeys).orElseGet(Collections::emptySet) ); return dataRetrievalStream.map(Supplier::get) .flatMap(Set::stream) @@ -221,9 +221,9 @@ public boolean supports(final int x, final int y, final int z, final Key key) @Override public Set> getValues(final int x, final int y, final int z) { final Stream>>> dataRetrievalStream = Stream.of( - () -> this.getBlock(x, y, z).getValues(), - () -> this.getFluid(x, y, z).getValues(), - () -> this.getBlockEntityArchetype(x, y, z).map(ValueContainer::getValues).orElseGet(Collections::emptySet) + () -> this.block(x, y, z).getValues(), + () -> this.fluid(x, y, z).getValues(), + () -> this.blockEntityArchetype(x, y, z).map(ValueContainer::getValues).orElseGet(Collections::emptySet) ); return dataRetrievalStream.map(Supplier::get) .flatMap(Set::stream) @@ -233,19 +233,19 @@ public Set> getValues(final int x, final int y, final int z) @Override public DataTransactionResult offer(final int x, final int y, final int z, final Key> key, final E value) { final Stream> dataRetrievalStream = Stream.of( - () -> this.getBlock(x, y, z).with(key, value) + () -> this.block(x, y, z).with(key, value) .map(newState -> { final Value newValue = newState.requireValue(key); this.setBlock(x, y, z, newState); return DataTransactionResult.successResult(newValue.asImmutable()); }).orElseGet(DataTransactionResult::failNoData), - () -> this.getFluid(x, y, z).with(key, value) + () -> this.fluid(x, y, z).with(key, value) .map(newState -> { final Value newValue = newState.requireValue(key); - this.setBlock(x, y, z, newState.getBlock()); + this.setBlock(x, y, z, newState.block()); return DataTransactionResult.successResult(newValue.asImmutable()); }).orElseGet(DataTransactionResult::failNoData), - () -> this.getBlockEntityArchetype(x, y, z).map(archetype -> archetype.offer(key, value)).orElseGet(DataTransactionResult::failNoData) + () -> this.blockEntityArchetype(x, y, z).map(archetype -> archetype.offer(key, value)).orElseGet(DataTransactionResult::failNoData) ); return dataRetrievalStream.map(Supplier::get) .filter(DataTransactionResult::isSuccessful) @@ -257,19 +257,19 @@ public DataTransactionResult offer(final int x, final int y, final int z, fi @Override public DataTransactionResult remove(final int x, final int y, final int z, final Key<@NonNull ?> key) { final Stream> dataRetrievalStream = Stream.of( - () -> this.getBlock(x, y, z).without(key) + () -> this.block(x, y, z).without(key) .map(newState -> { - final Value.Immutable newValue = this.getBlock(x, y, z).requireValue((Key) key).asImmutable(); + final Value.Immutable newValue = this.block(x, y, z).requireValue((Key) key).asImmutable(); this.setBlock(x, y, z, newState); return DataTransactionResult.successResult(newValue); }).orElseGet(DataTransactionResult::failNoData), - () -> this.getFluid(x, y, z).without(key) + () -> this.fluid(x, y, z).without(key) .map(newState -> { - final Value.Immutable newValue = this.getFluid(x, y, z).requireValue((Key) key).asImmutable(); - this.setBlock(x, y, z, newState.getBlock()); + final Value.Immutable newValue = this.fluid(x, y, z).requireValue((Key) key).asImmutable(); + this.setBlock(x, y, z, newState.block()); return DataTransactionResult.successResult(newValue); }).orElseGet(DataTransactionResult::failNoData), - () -> this.getBlockEntityArchetype(x, y, z).map(archetype -> archetype.remove(key)).orElseGet(DataTransactionResult::failNoData) + () -> this.blockEntityArchetype(x, y, z).map(archetype -> archetype.remove(key)).orElseGet(DataTransactionResult::failNoData) ); return dataRetrievalStream.map(Supplier::get) .filter(DataTransactionResult::isSuccessful) @@ -279,7 +279,7 @@ public DataTransactionResult remove(final int x, final int y, final int z, final @Override public DataTransactionResult undo(final int x, final int y, final int z, final DataTransactionResult result) { - return result.getReplacedData().stream() + return result.replacedData().stream() .map(successful -> this.offer(x, y, z, successful)) .collect(DataTransactionResult.toTransaction()); } @@ -297,7 +297,7 @@ public DataTransactionResult copyFrom(final int xTo, final int yTo, final int zT ) { return from.getValues().stream() .map(value -> { - final Value merged = this.get(xTo, yTo, zTo, value.getKey()) + final Value merged = this.get(xTo, yTo, zTo, value.key()) .map(existing -> function.merge((Value) existing, value).asImmutable()) .orElse(value); @@ -312,7 +312,7 @@ public DataTransactionResult copyFrom(final int xTo, final int yTo, final int zT ) { return this.getValues(xFrom, yFrom, zFrom).stream() .map(value -> { - final Value merged = this.get(xTo, yTo, zTo, value.getKey()) + final Value merged = this.get(xTo, yTo, zTo, value.key()) .map(existing -> function.merge((Value) existing, value).asImmutable()) .orElse(value.asImmutable()); @@ -323,14 +323,14 @@ public DataTransactionResult copyFrom(final int xTo, final int yTo, final int zT @Override public boolean validateRawData(final int x, final int y, final int z, final DataView container) { - return this.getBlockEntityArchetype(x, y, z) + return this.blockEntityArchetype(x, y, z) .map(archetype -> archetype.validateRawData(container)) .orElse(false); } @Override public void setRawData(final int x, final int y, final int z, final DataView container) throws InvalidDataException { - this.getBlockEntityArchetype(x, y, z) + this.blockEntityArchetype(x, y, z) .ifPresent(archetype -> archetype.setRawData(container)); } @@ -340,14 +340,14 @@ public void addEntity(final EntityArchetypeEntry entry) { } @Override - public Biome getBiome(final int x, final int y, final int z) { - return this.getBiome(x, y, z); + public Biome biome(final int x, final int y, final int z) { + return this.biome(x, y, z); } @Override - public VolumeStream getBiomeStream(final Vector3i min, final Vector3i max, final StreamOptions options + public VolumeStream biomeStream(final Vector3i min, final Vector3i max, final StreamOptions options ) { - return this.volume.getBiomeStream(min, max, options); + return this.volume.biomeStream(min, max, options); } @Override diff --git a/src/main/java/org/spongepowered/common/world/server/SpongeLocatableBlock.java b/src/main/java/org/spongepowered/common/world/server/SpongeLocatableBlock.java index 4ba4005d880..0fc69a01e00 100644 --- a/src/main/java/org/spongepowered/common/world/server/SpongeLocatableBlock.java +++ b/src/main/java/org/spongepowered/common/world/server/SpongeLocatableBlock.java @@ -66,24 +66,24 @@ public final class SpongeLocatableBlock implements LocatableBlock { } SpongeLocatableBlock(final ServerWorld world, final int x, final int y, final int z) { - this.world = world.getKey(); + this.world = world.key(); this.worldRef = new WeakReference<>(world); this.position = new Vector3i(x, y, z); - this.blockState = world.getBlock(x, y, z); + this.blockState = world.block(x, y, z); } @Override - public BlockState getBlockState() { + public BlockState blockState() { return this.blockState; } @Override - public World getWorld() { + public World world() { return Objects.requireNonNull(this.worldRef.get(), "World was de-referenced!"); } @Override - public ServerLocation getLocation() { + public ServerLocation location() { if (this.location == null) { this.location = ServerLocation.of(Objects.requireNonNull(this.worldRef.get(), "World was de-referenced!"), this.position); } @@ -91,7 +91,7 @@ public ServerLocation getLocation() { } @Override - public int getContentVersion() { + public int contentVersion() { return 1; } @@ -163,7 +163,7 @@ public LocatableBlock withRawData(final DataView container) throws InvalidDataEx @Override public LocatableBlock mergeWith(final LocatableBlock that, final MergeFunction function) { - return LocatableBlock.builder().from(this).state(this.blockState.mergeWith(that.getBlockState(), function)).build(); + return LocatableBlock.builder().from(this).state(this.blockState.mergeWith(that.blockState(), function)).build(); } @Override diff --git a/src/main/java/org/spongepowered/common/world/server/SpongeLocatableBlockBuilder.java b/src/main/java/org/spongepowered/common/world/server/SpongeLocatableBlockBuilder.java index 618f402ddff..983748e036d 100644 --- a/src/main/java/org/spongepowered/common/world/server/SpongeLocatableBlockBuilder.java +++ b/src/main/java/org/spongepowered/common/world/server/SpongeLocatableBlockBuilder.java @@ -63,10 +63,10 @@ public SpongeLocatableBlockBuilder state(final BlockState blockState) { @Override public SpongeLocatableBlockBuilder location(final ServerLocation location) { Objects.requireNonNull(location, "LocationBridge cannot be null!"); - this.blockState = location::getBlock; - this.position = location::getBlockPosition; - this.world = () -> location.getWorld().getKey(); - final WeakReference worldRef = new WeakReference<>(location.getWorld()); + this.blockState = location::block; + this.position = location::blockPosition; + this.world = () -> location.world().key(); + final WeakReference worldRef = new WeakReference<>(location.world()); this.worldReference = () -> Objects.requireNonNull(worldRef.get(), "ServerWorld refrence dereferenced"); return this; } @@ -90,7 +90,7 @@ public SpongeLocatableBlockBuilder world(final Supplier) (Supplier) worldSupplier; - this.world = () -> ((ServerWorld) worldSupplier.get()).getKey(); + this.world = () -> ((ServerWorld) worldSupplier.get()).key(); return this; } @@ -99,16 +99,16 @@ public SpongeLocatableBlockBuilder world(final ServerWorld world) { Objects.requireNonNull(world, "World cannot be null!"); final WeakReference reference = new WeakReference<>(world); this.worldReference = () -> Objects.requireNonNull(reference.get(), "ServerWorld refrence dereferenced"); - this.world = () -> this.worldReference.get().getKey(); + this.world = () -> this.worldReference.get().key(); return this; } @Override public SpongeLocatableBlockBuilder from(final LocatableBlock value) { Objects.requireNonNull(value, "LocatableBlock cannot be null!"); - this.position = value::getBlockPosition; - this.world = () -> value.getServerLocation().getWorld().getKey(); - final WeakReference worldRef = new WeakReference<>(value.getServerLocation().getWorld()); + this.position = value::blockPosition; + this.world = () -> value.serverLocation().world().key(); + final WeakReference worldRef = new WeakReference<>(value.serverLocation().world()); this.worldReference = () -> Objects.requireNonNull(worldRef.get(), "ServerWorld refrence dereferenced"); return this; } @@ -142,7 +142,7 @@ protected Optional buildContent(final DataView container) throws .orElseThrow(() -> new InvalidDataException("Could not locate an \"z\" coordinate in the container!")); final BlockState blockState = container.getSerializable(Constants.Block.BLOCK_STATE, BlockState.class) .orElseThrow(() -> new InvalidDataException("Could not locate a BlockState")); - return Sponge.getServer().getWorldManager().world(worldKey) + return Sponge.server().worldManager().world(worldKey) .map(world -> new SpongeLocatableBlockBuilder() .position(x, y, z) .world(world) diff --git a/src/main/java/org/spongepowered/common/world/server/SpongeServerLocation.java b/src/main/java/org/spongepowered/common/world/server/SpongeServerLocation.java index 8256e47b18a..f9c4bbe7373 100644 --- a/src/main/java/org/spongepowered/common/world/server/SpongeServerLocation.java +++ b/src/main/java/org/spongepowered/common/world/server/SpongeServerLocation.java @@ -31,13 +31,8 @@ import org.spongepowered.api.block.BlockSnapshot; import org.spongepowered.api.block.BlockType; import org.spongepowered.api.data.DataHolder; -import org.spongepowered.api.data.DataTransactionResult; import org.spongepowered.api.data.Key; -import org.spongepowered.api.data.value.CollectionValue; -import org.spongepowered.api.data.value.MapValue; -import org.spongepowered.api.data.value.MergeFunction; import org.spongepowered.api.data.value.Value; -import org.spongepowered.api.data.value.ValueContainer; import org.spongepowered.api.entity.Entity; import org.spongepowered.api.entity.EntityType; import org.spongepowered.api.fluid.FluidType; @@ -60,13 +55,10 @@ import java.util.Arrays; import java.util.Collection; import java.util.List; -import java.util.Map; import java.util.Objects; import java.util.Optional; -import java.util.Set; import java.util.StringJoiner; import java.util.function.BiFunction; -import java.util.function.Function; @DefaultQualifier(NonNull.class) public final class SpongeServerLocation extends SpongeLocation implements ServerLocation, SpongeMutableDataHolder { @@ -81,49 +73,49 @@ public final class SpongeServerLocation extends SpongeLocation E createEntity(final EntityType type) { - return this.getWorld().createEntity(type, this.getPosition()); + return this.world().createEntity(type, this.position()); } @Override public boolean spawnEntity(final Entity entity) { - return this.getWorld().spawnEntity(entity); + return this.world().spawnEntity(entity); } @Override public Collection spawnEntities(final Iterable entities) { - return this.getWorld().spawnEntities(entities); + return this.world().spawnEntities(entities); } @Override public ServerLocation asHighestLocation() { - return this.withBlockPosition(this.getWorld().getHighestPositionAt(this.getBlockPosition())); + return this.withBlockPosition(this.world().highestPositionAt(this.blockPosition())); } @Override public BlockSnapshot createSnapshot() { - return this.getWorld().createSnapshot(this.getBlockPosition()); + return this.world().createSnapshot(this.blockPosition()); } @Override - public Collection> getScheduledBlockUpdates() { - return this.getWorld().getScheduledBlockUpdates().getScheduledAt(this.getBlockPosition()); + public Collection> scheduledBlockUpdates() { + return this.world().scheduledBlockUpdates().scheduledAt(this.blockPosition()); } @Override @@ -229,8 +221,8 @@ public ScheduledUpdate scheduleBlockUpdate(final Duration delay, fina } @Override - public Collection> getScheduledFluidUpdates() { - return this.getWorld().getScheduledFluidUpdates().getScheduledAt(this.getBlockPosition()); + public Collection> scheduledFluidUpdates() { + return this.world().scheduledFluidUpdates().scheduledAt(this.blockPosition()); } @Override @@ -262,7 +254,7 @@ public Optional get(final Direction direction, final Key impl$delegateDataHolder() { - return Arrays.asList(this, this.getBlock()); + return Arrays.asList(this, this.block()); } @Override @@ -275,20 +267,20 @@ public boolean equals(final Object o) { } final SpongeServerLocation that = (SpongeServerLocation) o; return this.worldRef.get().equals(that.worldRef.get()) && - this.getPosition().equals(that.getPosition()) && - this.getBlockPosition().equals(that.getBlockPosition()); + this.position().equals(that.position()) && + this.blockPosition().equals(that.blockPosition()); } @Override public int hashCode() { - return Objects.hash(this.worldRef.get(), this.getPosition(), this.getBlockPosition()); + return Objects.hash(this.worldRef.get(), this.position(), this.blockPosition()); } @Override public String toString() { return new StringJoiner(", ", SpongeServerLocation.class.getSimpleName() + "[", "]") - .add("worldRef=" + this.getWorldKey()) - .add("position=" + this.getPosition()) + .add("worldRef=" + this.worldKey()) + .add("position=" + this.position()) .toString(); } @@ -299,7 +291,7 @@ public ServerLocation create(final ServerWorld world, final Vector3d position) { Objects.requireNonNull(world); Objects.requireNonNull(position); - return new SpongeServerLocation(world, world.getEngine().getChunkLayout(), position); + return new SpongeServerLocation(world, world.engine().chunkLayout(), position); } @Override @@ -307,7 +299,7 @@ public ServerLocation create(final ServerWorld world, final Vector3i blockPositi Objects.requireNonNull(world); Objects.requireNonNull(blockPosition); - final ChunkLayout chunkLayout = world.getEngine().getChunkLayout(); + final ChunkLayout chunkLayout = world.engine().chunkLayout(); final Vector3d position = blockPosition.toDouble(); return new SpongeServerLocation(world, chunkLayout, position); } @@ -317,11 +309,11 @@ public ServerLocation create(final ResourceKey worldKey, final Vector3d position Objects.requireNonNull(worldKey); Objects.requireNonNull(position); - final Optional world = Sponge.getServer().getWorldManager().world(worldKey); + final Optional world = Sponge.server().worldManager().world(worldKey); if (!world.isPresent()) { throw new IllegalStateException("Unknown world for key: " + worldKey.toString()); } - return new SpongeServerLocation(world.get(), world.get().getEngine().getChunkLayout(), position); + return new SpongeServerLocation(world.get(), world.get().engine().chunkLayout(), position); } @Override @@ -329,11 +321,11 @@ public ServerLocation create(final ResourceKey worldKey, final Vector3i blockPos Objects.requireNonNull(worldKey); Objects.requireNonNull(blockPosition); - final Optional world = Sponge.getServer().getWorldManager().world(worldKey); + final Optional world = Sponge.server().worldManager().world(worldKey); if (!world.isPresent()) { throw new IllegalStateException("Unknown world for key: " + worldKey.toString()); } - return new SpongeServerLocation(world.get(), world.get().getEngine().getChunkLayout(), blockPosition.toDouble()); + return new SpongeServerLocation(world.get(), world.get().engine().chunkLayout(), blockPosition.toDouble()); } } } diff --git a/src/main/java/org/spongepowered/common/world/server/SpongeWorldManager.java b/src/main/java/org/spongepowered/common/world/server/SpongeWorldManager.java index 6f6a019803f..a92a4f19856 100644 --- a/src/main/java/org/spongepowered/common/world/server/SpongeWorldManager.java +++ b/src/main/java/org/spongepowered/common/world/server/SpongeWorldManager.java @@ -27,17 +27,12 @@ import net.minecraft.core.Registry; import net.minecraft.resources.ResourceLocation; import net.minecraft.server.level.ServerLevel; -import net.minecraft.world.Difficulty; import net.minecraft.world.level.Level; -import org.checkerframework.checker.nullness.qual.Nullable; import org.spongepowered.api.ResourceKey; -import org.spongepowered.api.world.server.WorldTemplate; import org.spongepowered.api.world.server.WorldManager; -import org.spongepowered.common.SpongeCommon; import java.io.IOException; import java.nio.file.Path; -import java.util.Objects; public interface SpongeWorldManager extends WorldManager { @@ -64,7 +59,7 @@ default String getDirectoryName(final ResourceKey key) { if (Level.END.equals(registryKey)) { return "DIM1"; } - return key.getValue(); + return key.value(); } default boolean isVanillaWorld(final ResourceKey key) { @@ -82,6 +77,6 @@ default boolean isDefaultWorld(final ResourceKey key) { } default Path getDataPackFile(final ResourceKey key) { - return this.getDimensionDataPackDirectory().resolve(key.getNamespace()).resolve("dimension").resolve(key.getValue() + ".json"); + return this.getDimensionDataPackDirectory().resolve(key.namespace()).resolve("dimension").resolve(key.value() + ".json"); } } diff --git a/src/main/java/org/spongepowered/common/world/server/SpongeWorldTemplate.java b/src/main/java/org/spongepowered/common/world/server/SpongeWorldTemplate.java index e3e9e3530ba..576d99aad29 100644 --- a/src/main/java/org/spongepowered/common/world/server/SpongeWorldTemplate.java +++ b/src/main/java/org/spongepowered/common/world/server/SpongeWorldTemplate.java @@ -267,7 +267,7 @@ public Optional spawnPosition() { } @Override - public int getContentVersion() { + public int contentVersion() { return 0; } @@ -440,7 +440,7 @@ public Builder reset() { @Override public Builder from(final WorldTemplate template) { - this.key = Objects.requireNonNull(template, "template").getKey(); + this.key = Objects.requireNonNull(template, "template").key(); this.displayName = template.displayName().orElse(null); this.worldType = template.worldType(); this.generator = template.generator(); diff --git a/src/main/java/org/spongepowered/common/world/server/SpongeWorldTypeTemplate.java b/src/main/java/org/spongepowered/common/world/server/SpongeWorldTypeTemplate.java index 7d2e2b72e31..83e69e0bd64 100644 --- a/src/main/java/org/spongepowered/common/world/server/SpongeWorldTypeTemplate.java +++ b/src/main/java/org/spongepowered/common/world/server/SpongeWorldTypeTemplate.java @@ -102,7 +102,7 @@ public final class SpongeWorldTypeTemplate extends AbstractResourceKeyed impleme Codec.BOOL.fieldOf("has_raids").forGetter(DimensionType::hasRaids), Codec.intRange(0, 256).fieldOf("logical_height").forGetter(DimensionType::logicalHeight), ResourceLocation.CODEC.fieldOf("infiniburn").forGetter(v -> ((Tag.Named)v.infiniburn()).getName()), - ResourceLocation.CODEC.fieldOf("effects").orElse((ResourceLocation) (Object) WorldTypeEffects.OVERWORLD.getKey()).forGetter(v -> ((DimensionTypeAccessor) v).accessor$effectsLocation()), + ResourceLocation.CODEC.fieldOf("effects").orElse((ResourceLocation) (Object) WorldTypeEffects.OVERWORLD.key()).forGetter(v -> ((DimensionTypeAccessor) v).accessor$effectsLocation()), Codec.FLOAT.fieldOf("ambient_light").forGetter(v -> ((DimensionTypeAccessor) v).accessor$ambientLight()), SpongeWorldTypeTemplate.SPONGE_CODEC.optionalFieldOf("#sponge").forGetter(v -> Optional.of(new SpongeDataSection((ResourceLocation) (Object) BiomeSamplerProvider.INSTANCE.get((BiomeSampler) v.getBiomeZoomer()), v.createDragonFight()))) ) @@ -169,7 +169,7 @@ public DataPackType type() { } @Override - public int getContentVersion() { + public int contentVersion() { return 0; } diff --git a/src/main/java/org/spongepowered/common/world/server/WorldMigrator.java b/src/main/java/org/spongepowered/common/world/server/WorldMigrator.java index c97d8687c50..a069a94c8fc 100644 --- a/src/main/java/org/spongepowered/common/world/server/WorldMigrator.java +++ b/src/main/java/org/spongepowered/common/world/server/WorldMigrator.java @@ -127,7 +127,7 @@ public static void migrateWorldsTo(Path worldContainer) { // Previous to 1/10/2018, Sponge accidentally used the wrong save folder for client saves (put them on the root instead of saves/my_save). // This fixes this issue by moving over the folders and deleting them on the root - if (Sponge.getPlatform().getType().isClient()) { + if (Sponge.platform().type().isClient()) { try { Files.newDirectoryStream(worldContainer.getParent()).forEach((saveFolder) -> { final boolean isWorld = Files.exists(saveFolder.resolve("level.dat")); diff --git a/src/main/java/org/spongepowered/common/world/storage/SpongeChunkLayout.java b/src/main/java/org/spongepowered/common/world/storage/SpongeChunkLayout.java index f70ecdb1b8e..bc03f79d57c 100644 --- a/src/main/java/org/spongepowered/common/world/storage/SpongeChunkLayout.java +++ b/src/main/java/org/spongepowered/common/world/storage/SpongeChunkLayout.java @@ -41,27 +41,27 @@ private SpongeChunkLayout() { } @Override - public Vector3i getChunkSize() { + public Vector3i chunkSize() { return SpongeChunkLayout.CHUNK_SIZE; } @Override - public Vector3i getSpaceMax() { + public Vector3i spaceMax() { return SpongeChunkLayout.SPACE_MAX; } @Override - public Vector3i getSpaceMin() { + public Vector3i spaceMin() { return SpongeChunkLayout.SPACE_MIN; } @Override - public Vector3i getSpaceSize() { + public Vector3i spaceSize() { return SpongeChunkLayout.SPACE_SIZE; } @Override - public Vector3i getSpaceOrigin() { + public Vector3i spaceOrigin() { return Vector3i.ZERO; } diff --git a/src/main/java/org/spongepowered/common/world/storage/SpongePlayerData.java b/src/main/java/org/spongepowered/common/world/storage/SpongePlayerData.java index 4b9cd2ff0cc..b5f376c9b78 100644 --- a/src/main/java/org/spongepowered/common/world/storage/SpongePlayerData.java +++ b/src/main/java/org/spongepowered/common/world/storage/SpongePlayerData.java @@ -66,14 +66,14 @@ public void setLastJoined(final long lastJoined) { } @Override - public int getContentVersion() { + public int contentVersion() { return 1; } @Override public DataContainer toContainer() { return DataContainer.createNew() - .set(Queries.CONTENT_VERSION, this.getContentVersion()) + .set(Queries.CONTENT_VERSION, this.contentVersion()) .set(Constants.Entity.Player.UUID, this.uniqueId.toString()) .set(Constants.Sponge.PlayerData.PLAYER_DATA_JOIN, this.firstJoined) .set(Constants.Sponge.PlayerData.PLAYER_DATA_LAST, this.lastJoined); diff --git a/src/main/java/org/spongepowered/common/world/storage/SpongePlayerDataManager.java b/src/main/java/org/spongepowered/common/world/storage/SpongePlayerDataManager.java index ace115c5a44..9a35aab81ef 100644 --- a/src/main/java/org/spongepowered/common/world/storage/SpongePlayerDataManager.java +++ b/src/main/java/org/spongepowered/common/world/storage/SpongePlayerDataManager.java @@ -67,7 +67,7 @@ public SpongePlayerDataManager(final Server server) { public void load() { try { - this.playersDirectory = ((SpongeWorldManager) this.server.getWorldManager()).getDefaultWorldDirectory().resolve("data").resolve( + this.playersDirectory = ((SpongeWorldManager) this.server.worldManager()).getDefaultWorldDirectory().resolve("data").resolve( SpongePlayerDataManager.SPONGE_DATA); Files.createDirectories(this.playersDirectory); diff --git a/src/main/java/org/spongepowered/common/world/teleport/ConfigTeleportHelperFilter.java b/src/main/java/org/spongepowered/common/world/teleport/ConfigTeleportHelperFilter.java index 98c3b92d311..1653ec1c875 100644 --- a/src/main/java/org/spongepowered/common/world/teleport/ConfigTeleportHelperFilter.java +++ b/src/main/java/org/spongepowered/common/world/teleport/ConfigTeleportHelperFilter.java @@ -70,7 +70,7 @@ private static void updateCacheIfNecessary() { ConfigTeleportHelperFilter.floorBlockStates = teleportHelperCat.unsafeFloorBlocks.stream() .map(x -> ResourceKey.resolve(x.toLowerCase(Locale.ENGLISH))) .map(x -> Registry.BLOCK.getOptional((ResourceLocation) (Object) x).map(b -> (BlockType) b) - .map(StateContainer::getDefaultState).orElse(null)) + .map(StateContainer::defaultState).orElse(null)) .filter(Objects::nonNull) .collect(Collectors.toList()); @@ -83,7 +83,7 @@ private static void updateCacheIfNecessary() { ConfigTeleportHelperFilter.bodyBlockStates = teleportHelperCat.unsafeBlockBlocks.stream() .map(x -> ResourceKey.resolve(x.toLowerCase(Locale.ENGLISH))) .map(x -> Registry.BLOCK.getOptional((ResourceLocation) (Object) x).map(b -> (BlockType) b) - .map(StateContainer::getDefaultState).orElse(null)) + .map(StateContainer::defaultState).orElse(null)) .filter(Objects::nonNull) .collect(Collectors.toList()); } @@ -92,12 +92,12 @@ private static void updateCacheIfNecessary() { @Override public boolean isSafeFloorMaterial(@NonNull final BlockState blockState) { ConfigTeleportHelperFilter.updateCacheIfNecessary(); - return !ConfigTeleportHelperFilter.floorBlockStates.contains(blockState) && !ConfigTeleportHelperFilter.floorBlockTypes.contains(blockState.getType()); + return !ConfigTeleportHelperFilter.floorBlockStates.contains(blockState) && !ConfigTeleportHelperFilter.floorBlockTypes.contains(blockState.type()); } @Override public boolean isSafeBodyMaterial(@NonNull final BlockState blockState) { ConfigTeleportHelperFilter.updateCacheIfNecessary(); - return !ConfigTeleportHelperFilter.bodyBlockStates.contains(blockState) && !ConfigTeleportHelperFilter.bodyBlockTypes.contains(blockState.getType()); + return !ConfigTeleportHelperFilter.bodyBlockStates.contains(blockState) && !ConfigTeleportHelperFilter.bodyBlockTypes.contains(blockState.type()); } } diff --git a/src/main/java/org/spongepowered/common/world/teleport/SpongeTeleportHelper.java b/src/main/java/org/spongepowered/common/world/teleport/SpongeTeleportHelper.java index 5500c0817fb..fd508a6c2f8 100644 --- a/src/main/java/org/spongepowered/common/world/teleport/SpongeTeleportHelper.java +++ b/src/main/java/org/spongepowered/common/world/teleport/SpongeTeleportHelper.java @@ -53,9 +53,9 @@ public final class SpongeTeleportHelper implements TeleportHelper { @Override - public Optional getSafeLocation(ServerLocation location, int height, int width, int distanceToDrop, + public Optional findSafeLocation(ServerLocation location, int height, int width, int distanceToDrop, TeleportHelperFilter filter, TeleportHelperFilter... additionalFilters) { - final ServerWorld world = location.getWorld(); + final ServerWorld world = location.world(); final Set filters = Sets.newHashSet(additionalFilters); filters.add(filter); @@ -73,16 +73,16 @@ public Optional getSafeLocation(ServerLocation location, int hei private Stream getBlockLocations(ServerLocation worldLocation, int height, int width) { // We don't want to warp outside of the world border, so we want to check that we're within it. - final WorldBorder worldBorder = (WorldBorder) worldLocation.getWorld().getProperties().worldBorder(); + final WorldBorder worldBorder = (WorldBorder) worldLocation.world().properties().worldBorder(); int worldBorderMinX = GenericMath.floor(worldBorder.getMinX()); int worldBorderMinZ = GenericMath.floor(worldBorder.getMinZ()); int worldBorderMaxX = GenericMath.floor(worldBorder.getMaxX()); int worldBorderMaxZ = GenericMath.floor(worldBorder.getMaxZ()); // Get the World and get the maximum Y value. - int worldMaxY = worldLocation.getWorld().getBlockMax().getY(); + int worldMaxY = worldLocation.world().blockMax().getY(); - Vector3i vectorLocation = worldLocation.getBlockPosition(); + Vector3i vectorLocation = worldLocation.blockPosition(); // We use clamp to remain within the world confines, so we don't waste time checking blocks outside of the // world border and the world height. @@ -190,7 +190,7 @@ private BlockData getBlockData(Vector3i vector3i, World world, Map= position.getY()) { + if (world.highestYAt(position.getX(), position.getZ()) >= position.getY()) { // We're below the highest y co-ordinate, so we're not interested in it. return Tristate.FALSE; } diff --git a/src/main/java/org/spongepowered/common/world/volume/SpongeVolumeStream.java b/src/main/java/org/spongepowered/common/world/volume/SpongeVolumeStream.java index 1cd8ffcc18f..c99f617e339 100644 --- a/src/main/java/org/spongepowered/common/world/volume/SpongeVolumeStream.java +++ b/src/main/java/org/spongepowered/common/world/volume/SpongeVolumeStream.java @@ -59,7 +59,7 @@ public SpongeVolumeStream(final Stream> elementStream, } @Override - public V getVolume() { + public V volume() { return this.volumeSupplier.get(); } @@ -69,10 +69,10 @@ public VolumeStream filter(final VolumePredicate predicate) { .filter(element -> predicate.test( this.volumeSupplier.get(), - element::getType, - element.getPosition().getX(), - element.getPosition().getY(), - element.getPosition().getZ() + element::type, + element.position().getX(), + element.position().getY(), + element.position().getZ() ) ), this.volumeSupplier); } @@ -87,11 +87,11 @@ public VolumeStream map(final VolumeMapper mapper) { return new SpongeVolumeStream<>(this.stream.map(element -> VolumeElement.of(this.volumeSupplier.get(), mapper.map( this.volumeSupplier.get(), - element::getType, - element.getPosition().getX(), - element.getPosition().getY(), - element.getPosition().getZ() - ), element.getPosition()) + element::type, + element.position().getX(), + element.position().getY(), + element.position().getZ() + ), element.position()) ), this.volumeSupplier); } @@ -103,12 +103,12 @@ public VolumeStream> flatMap(final VolumeFlatMapper> flatMap(final VolumeFlatMapper VolumeStream map(final Function, ? extends Out> mapper) { return new SpongeVolumeStream<>(this.stream.map(element -> VolumeElement.of( - this.getVolume(), + this.volume(), mapper.apply(element), - element.getPosition() + element.position() )), this.volumeSupplier); } @@ -133,11 +133,11 @@ public long count() { public boolean allMatch(final VolumePredicate predicate) { return this.stream .allMatch(element -> predicate.test( - this.getVolume(), - element::getType, - element.getPosition().getX(), - element.getPosition().getY(), - element.getPosition().getZ() + this.volume(), + element::type, + element.position().getX(), + element.position().getY(), + element.position().getZ() )); } @@ -149,11 +149,11 @@ public boolean allMatch(final Predicate> predicate) @Override public boolean noneMatch(final VolumePredicate predicate) { return this.stream.noneMatch(element -> predicate.test( - this.getVolume(), - element::getType, - element.getPosition().getX(), - element.getPosition().getY(), - element.getPosition().getZ() + this.volume(), + element::type, + element.position().getX(), + element.position().getY(), + element.position().getZ() )); } @@ -165,11 +165,11 @@ public boolean noneMatch(final Predicate> predicate) @Override public boolean anyMatch(final VolumePredicate predicate) { return this.stream.anyMatch(element -> predicate.test( - this.getVolume(), - element::getType, - element.getPosition().getX(), - element.getPosition().getY(), - element.getPosition().getZ() + this.volume(), + element::type, + element.position().getX(), + element.position().getY(), + element.position().getZ() )); } @@ -201,8 +201,8 @@ public void apply(final VolumeCollector colle final W targetVolume = collector.target().get(); final VolumeElement transformed = collector.positionTransform().apply(VolumeElement.of( collector.target(), - element::getType, - element.getPosition() + element::type, + element.position() )); collector.applicator() .apply(targetVolume, transformed); @@ -218,8 +218,8 @@ public void applyUntil(final VolumeCollector element = iterator.next(); final VolumeElement transformed = collector.positionTransform().apply(VolumeElement.of( collector.target(), - element::getType, - element.getPosition() + element::type, + element.position() )); final R apply = collector.applicator() .apply(targetVolume, transformed); @@ -230,11 +230,11 @@ public void applyUntil(final VolumeCollector visitor) { this.stream.forEach(element -> visitor.consume( - element.getVolume(), - element.getType(), - element.getPosition().getX(), - element.getPosition().getY(), - element.getPosition().getZ() + element.volume(), + element.type(), + element.position().getX(), + element.position().getY(), + element.position().getZ() )); } diff --git a/src/main/java/org/spongepowered/common/world/volume/VolumeStreamUtils.java b/src/main/java/org/spongepowered/common/world/volume/VolumeStreamUtils.java index c465a6c326b..0ec166c9a8d 100644 --- a/src/main/java/org/spongepowered/common/world/volume/VolumeStreamUtils.java +++ b/src/main/java/org/spongepowered/common/world/volume/VolumeStreamUtils.java @@ -98,7 +98,7 @@ public static Supplier createWeaklyReferencedSupplier(final T object, fin } public static Predicate> entityArchetypePositionFilter(final Vector3i min, final Vector3i max) { - return VolumeStreamUtils.filterPositions(tuple -> tuple.getFirst().toInt(), min, max); + return VolumeStreamUtils.filterPositions(tuple -> tuple.first().toInt(), min, max); } public static Predicate> blockEntityArchetypePositionFilter(final Vector3i min, final Vector3i max) { diff --git a/src/main/java/org/spongepowered/common/world/volume/archetype/entity/SpongeEntityArchetypeEntry.java b/src/main/java/org/spongepowered/common/world/volume/archetype/entity/SpongeEntityArchetypeEntry.java index 58a13358b16..d6d7c2942e5 100644 --- a/src/main/java/org/spongepowered/common/world/volume/archetype/entity/SpongeEntityArchetypeEntry.java +++ b/src/main/java/org/spongepowered/common/world/volume/archetype/entity/SpongeEntityArchetypeEntry.java @@ -41,12 +41,12 @@ public SpongeEntityArchetypeEntry(final EntityArchetype archetype, final Vector3 } @Override - public EntityArchetype getArchetype() { + public EntityArchetype archetype() { return this.archetype; } @Override - public Vector3d getPosition() { + public Vector3d position() { return this.position; } diff --git a/src/main/java/org/spongepowered/common/world/volume/block/SpongeBlockVolumeFactory.java b/src/main/java/org/spongepowered/common/world/volume/block/SpongeBlockVolumeFactory.java index 0b1b15e549f..7a938b6e2b6 100644 --- a/src/main/java/org/spongepowered/common/world/volume/block/SpongeBlockVolumeFactory.java +++ b/src/main/java/org/spongepowered/common/world/volume/block/SpongeBlockVolumeFactory.java @@ -57,7 +57,7 @@ public class SpongeBlockVolumeFactory implements BlockVolumeFactory { final BlockVolume.Streamable<@NonNull ?> existing, final Vector3i newMin, final Vector3i newMax ) { final ArrayMutableBlockBuffer buffer = new ArrayMutableBlockBuffer(newMin, newMax.sub(newMin)); - existing.getBlockStateStream(newMin, newMax, StreamOptions.lazily()) + existing.blockStateStream(newMin, newMax, StreamOptions.lazily()) .apply(VolumeCollectors.of(buffer, VolumePositionTranslators.identity(), VolumeApplicators.applyBlocks())); return buffer; } @@ -65,8 +65,8 @@ public class SpongeBlockVolumeFactory implements BlockVolumeFactory { @Override public BlockVolume.Mutable<@NonNull ?> copy(final BlockVolume.Streamable<@NonNull ?> existing ) { - final ArrayMutableBlockBuffer buffer = new ArrayMutableBlockBuffer(existing.getBlockMin(), existing.getBlockSize()); - existing.getBlockStateStream(existing.getBlockMin(), existing.getBlockMax(), StreamOptions.lazily()) + final ArrayMutableBlockBuffer buffer = new ArrayMutableBlockBuffer(existing.blockMin(), existing.blockSize()); + existing.blockStateStream(existing.blockMin(), existing.blockMax(), StreamOptions.lazily()) .apply(VolumeCollectors.of(buffer, VolumePositionTranslators.identity(), VolumeApplicators.applyBlocks())); return buffer; } @@ -78,10 +78,10 @@ public BlockVolume.Immutable immutableOf(final BlockVolume.Streamable<@NonNull ? return this.createImmutableFromBufferData((ArrayMutableBlockBuffer) existing); } final ArrayMutableBlockBuffer buffer = new ArrayMutableBlockBuffer( - existing.getBlockMin(), - existing.getBlockSize() + existing.blockMin(), + existing.blockSize() ); - existing.getBlockStateStream(existing.getBlockMin(), existing.getBlockMax(), StreamOptions.lazily()) + existing.blockStateStream(existing.blockMin(), existing.blockMax(), StreamOptions.lazily()) .apply(VolumeCollectors.of(buffer, VolumePositionTranslators.identity(), VolumeApplicators.applyBlocks())); return this.createImmutableFromBufferData(buffer); } @@ -89,14 +89,14 @@ public BlockVolume.Immutable immutableOf(final BlockVolume.Streamable<@NonNull ? private ArrayImmutableBlockBuffer createImmutableFromBufferData(final ArrayMutableBlockBuffer arrayBuffer) { final BlockBackingData data = arrayBuffer.getCopiedBackingData(); final Palette.Immutable immutablePalette = arrayBuffer.getPalette().asImmutable(); - return new ArrayImmutableBlockBuffer(immutablePalette, arrayBuffer.getBlockMin(), arrayBuffer.getBlockSize(), data); + return new ArrayImmutableBlockBuffer(immutablePalette, arrayBuffer.blockMin(), arrayBuffer.blockSize(), data); } @Override public BlockVolume.Immutable immutableOf(final BlockVolume.Streamable<@NonNull ?> existing, final Vector3i newMin, final Vector3i newMax ) { final ArrayMutableBlockBuffer buffer = new ArrayMutableBlockBuffer(newMin, newMax.sub(newMin)); - existing.getBlockStateStream(newMin, newMax, StreamOptions.lazily()) + existing.blockStateStream(newMin, newMax, StreamOptions.lazily()) .apply(VolumeCollectors.of(buffer, VolumePositionTranslators.identity(), VolumeApplicators.applyBlocks())); return this.createImmutableFromBufferData(buffer); } diff --git a/src/main/java/org/spongepowered/common/world/volume/buffer/AbstractVolumeBuffer.java b/src/main/java/org/spongepowered/common/world/volume/buffer/AbstractVolumeBuffer.java index 4d2f7422bf7..07a56a5690b 100644 --- a/src/main/java/org/spongepowered/common/world/volume/buffer/AbstractVolumeBuffer.java +++ b/src/main/java/org/spongepowered/common/world/volume/buffer/AbstractVolumeBuffer.java @@ -61,17 +61,17 @@ protected int getIndex(final int x, final int y, final int z) { } @Override - public Vector3i getBlockMax() { + public Vector3i blockMax() { return this.end; } @Override - public Vector3i getBlockMin() { + public Vector3i blockMin() { return this.start; } @Override - public Vector3i getBlockSize() { + public Vector3i blockSize() { return this.size; } diff --git a/src/main/java/org/spongepowered/common/world/volume/buffer/archetype/SpongeArchetypeVolume.java b/src/main/java/org/spongepowered/common/world/volume/buffer/archetype/SpongeArchetypeVolume.java index a693c8837f5..858cf4133d4 100644 --- a/src/main/java/org/spongepowered/common/world/volume/buffer/archetype/SpongeArchetypeVolume.java +++ b/src/main/java/org/spongepowered/common/world/volume/buffer/archetype/SpongeArchetypeVolume.java @@ -79,54 +79,54 @@ public SpongeArchetypeVolume(final Vector3i start, final Vector3i size, final Re } @Override - public Optional getBlockEntityArchetype(final int x, final int y, final int z) { + public Optional blockEntityArchetype(final int x, final int y, final int z) { return Optional.empty(); } @Override - public Map getBlockEntityArchetypes() { - return this.blockEntities.getBlockEntityArchetypes(); + public Map blockEntityArchetypes() { + return this.blockEntities.blockEntityArchetypes(); } @Override - public VolumeStream getBlockEntityArchetypeStream(final Vector3i min, final Vector3i max, + public VolumeStream blockEntityArchetypeStream(final Vector3i min, final Vector3i max, final StreamOptions options ) { - final Vector3i blockMin = this.getBlockMin(); - final Vector3i blockMax = this.getBlockMax(); + final Vector3i blockMin = this.blockMin(); + final Vector3i blockMax = this.blockMax(); VolumeStreamUtils.validateStreamArgs(min, max, blockMin, blockMax, options); - final Stream> stateStream = this.blockEntities.getBlockEntityArchetypeStream(min, max, options) + final Stream> stateStream = this.blockEntities.blockEntityArchetypeStream(min, max, options) .toStream() - .map(element -> VolumeElement.of(this, element::getType, element.getPosition())); + .map(element -> VolumeElement.of(this, element::type, element.position())); return new SpongeVolumeStream<>(stateStream, () -> this); } @Override - public Collection getEntityArchetypes() { - return this.entities.getEntityArchetypes(); + public Collection entityArchetypes() { + return this.entities.entityArchetypes(); } @Override - public Collection getEntityArchetypes(final Predicate filter) { - return this.entities.getEntityArchetypes(filter); + public Collection entityArchetypes(final Predicate filter) { + return this.entities.entityArchetypes(filter); } @Override - public VolumeStream getEntityArchetypeStream( + public VolumeStream entityArchetypeStream( final Vector3i min, final Vector3i max, final StreamOptions options ) { - final Vector3i blockMin = this.getBlockMin(); - final Vector3i blockMax = this.getBlockMax(); + final Vector3i blockMin = this.blockMin(); + final Vector3i blockMax = this.blockMax(); VolumeStreamUtils.validateStreamArgs(min, max, blockMin, blockMax, options); - final Stream> stateStream = this.entities.getEntityArchetypeStream(min, max, options).toStream() - .map(element -> VolumeElement.of(this, element::getType, element.getPosition())); + final Stream> stateStream = this.entities.entityArchetypeStream(min, max, options).toStream() + .map(element -> VolumeElement.of(this, element::type, element.position())); return new SpongeVolumeStream<>(stateStream, () -> this); } @Override - public Stream getEntitiesByPosition() { - return this.entities.getEntitiesByPosition(); + public Stream entitiesByPosition() { + return this.entities.entitiesByPosition(); } @Override @@ -140,25 +140,25 @@ public boolean removeBlock(final int x, final int y, final int z) { } @Override - public BlockState getBlock(final int x, final int y, final int z) { - return this.blocks.getBlock(x, y, z); + public BlockState block(final int x, final int y, final int z) { + return this.blocks.block(x, y, z); } @Override - public FluidState getFluid(final int x, final int y, final int z) { - return this.blocks.getFluid(x, y, z); + public FluidState fluid(final int x, final int y, final int z) { + return this.blocks.fluid(x, y, z); } @Override - public int getHighestYAt(final int x, final int z) { - return this.blocks.getHighestYAt(x, z); + public int highestYAt(final int x, final int z) { + return this.blocks.highestYAt(x, z); } @Override - public VolumeStream getBlockStateStream(final Vector3i min, final Vector3i max, final StreamOptions options + public VolumeStream blockStateStream(final Vector3i min, final Vector3i max, final StreamOptions options ) { - final Vector3i blockMin = this.getBlockMin(); - final Vector3i blockMax = this.getBlockMax(); + final Vector3i blockMin = this.blockMin(); + final Vector3i blockMax = this.blockMax(); VolumeStreamUtils.validateStreamArgs(min, max, blockMin, blockMax, options); final ArrayMutableBlockBuffer buffer; if (options.carbonCopy()) { @@ -169,7 +169,7 @@ public VolumeStream getBlockStateStream(final Vecto final Stream> stateStream = IntStream.range(blockMin.getX(), blockMax.getX() + 1) .mapToObj(x -> IntStream.range(blockMin.getZ(), blockMax.getZ() + 1) .mapToObj(z -> IntStream.range(blockMin.getY(), blockMax.getY() + 1) - .mapToObj(y -> VolumeElement.of((ArchetypeVolume) this, () -> buffer.getBlock(x, y, z), new Vector3i(x, y, z))) + .mapToObj(y -> VolumeElement.of((ArchetypeVolume) this, () -> buffer.block(x, y, z), new Vector3i(x, y, z))) ).flatMap(Function.identity()) ).flatMap(Function.identity()); return new SpongeVolumeStream<>(stateStream, () -> this); @@ -199,22 +199,22 @@ public void addEntity(final EntityArchetypeEntry entry) { } @Override - public Biome getBiome(final int x, final int y, final int z) { - return this.biomes.getBiome(x, y, z); + public Biome biome(final int x, final int y, final int z) { + return this.biomes.biome(x, y, z); } @Override - public VolumeStream getBiomeStream( + public VolumeStream biomeStream( final Vector3i min, final Vector3i max, final StreamOptions options ) { - final Vector3i blockMin = this.getBlockMin(); - final Vector3i blockMax = this.getBlockMax(); + final Vector3i blockMin = this.blockMin(); + final Vector3i blockMax = this.blockMax(); VolumeStreamUtils.validateStreamArgs(min, max, blockMin, blockMax, options); - final Stream> stateStream = this.biomes.getBiomeStream(min, max, options) + final Stream> stateStream = this.biomes.biomeStream(min, max, options) .toStream() - .map(element -> VolumeElement.of(this, element::getType, element.getPosition())); + .map(element -> VolumeElement.of(this, element::type, element.position())); return new SpongeVolumeStream<>(stateStream, () -> this); } diff --git a/src/main/java/org/spongepowered/common/world/volume/buffer/archetype/blockentity/AbstractMutableBlockEntityArchetypeBuffer.java b/src/main/java/org/spongepowered/common/world/volume/buffer/archetype/blockentity/AbstractMutableBlockEntityArchetypeBuffer.java index 166a1d41e92..470b175d123 100644 --- a/src/main/java/org/spongepowered/common/world/volume/buffer/archetype/blockentity/AbstractMutableBlockEntityArchetypeBuffer.java +++ b/src/main/java/org/spongepowered/common/world/volume/buffer/archetype/blockentity/AbstractMutableBlockEntityArchetypeBuffer.java @@ -54,7 +54,7 @@ protected AbstractMutableBlockEntityArchetypeBuffer(final Vector3i start, final } protected AbstractMutableBlockEntityArchetypeBuffer(final ArrayMutableBlockBuffer buffer) { - super(buffer.getBlockMin(), buffer.getBlockSize()); + super(buffer.blockMin(), buffer.blockSize()); this.blockBuffer = buffer; } @@ -83,26 +83,26 @@ public Palette getPalette() { } @Override - public BlockState getBlock(final int x, final int y, final int z) { - return this.blockBuffer.getBlock(x, y, z); + public BlockState block(final int x, final int y, final int z) { + return this.blockBuffer.block(x, y, z); } @Override - public FluidState getFluid(final int x, final int y, final int z) { - return this.blockBuffer.getFluid(x, y, z); + public FluidState fluid(final int x, final int y, final int z) { + return this.blockBuffer.fluid(x, y, z); } @Override - public int getHighestYAt(final int x, final int z) { - return this.blockBuffer.getHighestYAt(x, z); + public int highestYAt(final int x, final int z) { + return this.blockBuffer.highestYAt(x, z); } @SuppressWarnings("unchecked") @Override - public VolumeStream getBlockStateStream(final Vector3i min, final Vector3i max, + public VolumeStream blockStateStream(final Vector3i min, final Vector3i max, final StreamOptions options) { - final Vector3i blockMin = this.getBlockMin(); - final Vector3i blockMax = this.getBlockMax(); + final Vector3i blockMin = this.blockMin(); + final Vector3i blockMax = this.blockMax(); VolumeStreamUtils.validateStreamArgs(min, max, blockMin, blockMax, options); final ArrayMutableBlockBuffer buffer; if (options.carbonCopy()) { @@ -113,7 +113,7 @@ public VolumeStream getBlockStateStream(final Vector3i min, final final Stream> stateStream = IntStream.range(blockMin.getX(), blockMax.getX() + 1) .mapToObj(x -> IntStream.range(blockMin.getZ(), blockMax.getZ() + 1) .mapToObj(z -> IntStream.range(blockMin.getY(), blockMax.getY() + 1) - .mapToObj(y -> VolumeElement.of((M) this, () -> buffer.getBlock(x, y, z), new Vector3i(x, y, z))) + .mapToObj(y -> VolumeElement.of((M) this, () -> buffer.block(x, y, z), new Vector3i(x, y, z))) ).flatMap(Function.identity()) ).flatMap(Function.identity()); return new SpongeVolumeStream<>(stateStream, () -> (M) this); diff --git a/src/main/java/org/spongepowered/common/world/volume/buffer/archetype/blockentity/MutableArrayBasedBlockEntityArchetypeBuffer.java b/src/main/java/org/spongepowered/common/world/volume/buffer/archetype/blockentity/MutableArrayBasedBlockEntityArchetypeBuffer.java index 3a3b98335e8..e66c4c1b40c 100644 --- a/src/main/java/org/spongepowered/common/world/volume/buffer/archetype/blockentity/MutableArrayBasedBlockEntityArchetypeBuffer.java +++ b/src/main/java/org/spongepowered/common/world/volume/buffer/archetype/blockentity/MutableArrayBasedBlockEntityArchetypeBuffer.java @@ -56,17 +56,17 @@ public void removeBlockEntity(int x, int y, int z) { } @Override - public Optional getBlockEntityArchetype(int x, int y, int z) { + public Optional blockEntityArchetype(int x, int y, int z) { return Optional.empty(); } @Override - public Map getBlockEntityArchetypes() { + public Map blockEntityArchetypes() { return null; } @Override - public VolumeStream getBlockEntityArchetypeStream(Vector3i min, + public VolumeStream blockEntityArchetypeStream(Vector3i min, Vector3i max, StreamOptions options ) { return null; diff --git a/src/main/java/org/spongepowered/common/world/volume/buffer/archetype/blockentity/MutableMapBlockEntityArchetypeBuffer.java b/src/main/java/org/spongepowered/common/world/volume/buffer/archetype/blockentity/MutableMapBlockEntityArchetypeBuffer.java index ca23fdd2c8b..6f85e3d56a1 100644 --- a/src/main/java/org/spongepowered/common/world/volume/buffer/archetype/blockentity/MutableMapBlockEntityArchetypeBuffer.java +++ b/src/main/java/org/spongepowered/common/world/volume/buffer/archetype/blockentity/MutableMapBlockEntityArchetypeBuffer.java @@ -85,20 +85,20 @@ public void removeBlockEntity(final int x, final int y, final int z) { } @Override - public Optional getBlockEntityArchetype(final int x, final int y, final int z) { + public Optional blockEntityArchetype(final int x, final int y, final int z) { return Optional.ofNullable(this.blockEntities.get(new Vector3i(x, y, z))); } @Override - public Map getBlockEntityArchetypes() { + public Map blockEntityArchetypes() { return this.blockEntities; } @Override - public VolumeStream getBlockEntityArchetypeStream(final Vector3i min, + public VolumeStream blockEntityArchetypeStream(final Vector3i min, final Vector3i max, final StreamOptions options ) { - VolumeStreamUtils.validateStreamArgs(min, max, this.getBlockMin(), this.getBlockMax(), options); + VolumeStreamUtils.validateStreamArgs(min, max, this.blockMin(), this.blockMax(), options); final Stream> entryStream; if (options.carbonCopy()) { final Map copy = new HashMap<>(); diff --git a/src/main/java/org/spongepowered/common/world/volume/buffer/archetype/entity/ObjectArrayMutableEntityArchetypeBuffer.java b/src/main/java/org/spongepowered/common/world/volume/buffer/archetype/entity/ObjectArrayMutableEntityArchetypeBuffer.java index 567b5008089..e05572b8c9f 100644 --- a/src/main/java/org/spongepowered/common/world/volume/buffer/archetype/entity/ObjectArrayMutableEntityArchetypeBuffer.java +++ b/src/main/java/org/spongepowered/common/world/volume/buffer/archetype/entity/ObjectArrayMutableEntityArchetypeBuffer.java @@ -54,25 +54,25 @@ public ObjectArrayMutableEntityArchetypeBuffer(final Vector3i start, final Vecto } @Override - public Collection getEntityArchetypes() { + public Collection entityArchetypes() { return this.entities.stream() - .map(Tuple::getSecond) + .map(Tuple::second) .collect(Collectors.toList()); } @Override - public Collection getEntityArchetypes(final Predicate filter) { + public Collection entityArchetypes(final Predicate filter) { return this.entities.stream() - .map(Tuple::getSecond) + .map(Tuple::second) .filter(filter) .collect(Collectors.toList()); } @Override - public VolumeStream getEntityArchetypeStream(final Vector3i min, final Vector3i max, + public VolumeStream entityArchetypeStream(final Vector3i min, final Vector3i max, final StreamOptions options ) { - VolumeStreamUtils.validateStreamArgs(min, max, this.getBlockMin(), this.getBlockMax(), options); + VolumeStreamUtils.validateStreamArgs(min, max, this.blockMin(), this.blockMax(), options); final Stream> entryStream; if (options.carbonCopy()) { entryStream = new ArrayList<>(this.entities).stream(); @@ -81,27 +81,27 @@ public VolumeStream ge } final Stream> archetypeStream = entryStream .filter(VolumeStreamUtils.entityArchetypePositionFilter(min, max)) - .map(tuple -> VolumeElement.of(this, tuple.getSecond(), tuple.getFirst().toInt())); + .map(tuple -> VolumeElement.of(this, tuple.second(), tuple.first().toInt())); return new SpongeVolumeStream<>(archetypeStream, () -> this); } @Override - public Stream getEntitiesByPosition() { + public Stream entitiesByPosition() { return this.entities.stream() - .map(tuple -> EntityArchetypeEntry.of(tuple.getSecond(), tuple.getFirst())); + .map(tuple -> EntityArchetypeEntry.of(tuple.second(), tuple.first())); } @Override public void addEntity(final EntityArchetypeEntry entry) { - if (!this.containsBlock(Objects.requireNonNull(entry, "EntityArchetype cannot be null").getPosition().toInt())) { + if (!this.containsBlock(Objects.requireNonNull(entry, "EntityArchetype cannot be null").position().toInt())) { final String message = String.format( "EntityArchetype position is out of bounds: Found %s but is outside bounds (%s, %s)", - entry.getPosition(), - this.getBlockMin(), - this.getBlockMax() + entry.position(), + this.blockMin(), + this.blockMax() ); throw new IllegalArgumentException(message); } - this.entities.add(Tuple.of(entry.getPosition(), entry.getArchetype())); + this.entities.add(Tuple.of(entry.position(), entry.archetype())); } } diff --git a/src/main/java/org/spongepowered/common/world/volume/buffer/biome/ByteArrayImmutableBiomeBuffer.java b/src/main/java/org/spongepowered/common/world/volume/buffer/biome/ByteArrayImmutableBiomeBuffer.java index 1bb66d58297..ff64438d84f 100644 --- a/src/main/java/org/spongepowered/common/world/volume/buffer/biome/ByteArrayImmutableBiomeBuffer.java +++ b/src/main/java/org/spongepowered/common/world/volume/buffer/biome/ByteArrayImmutableBiomeBuffer.java @@ -66,10 +66,10 @@ private ByteArrayImmutableBiomeBuffer(final Palette palette, final } @Override - public Biome getBiome(final int x, final int y, final int z) { + public Biome biome(final int x, final int y, final int z) { this.checkRange(x, y, z); - return this.palette.get(this.biomes[this.getIndex(x, y, z)], Sponge.getServer().registries()) - .orElseGet(Sponge.getServer().registries() + return this.palette.get(this.biomes[this.getIndex(x, y, z)], Sponge.server().registries()) + .orElseGet(Sponge.server().registries() .registry(RegistryTypes.BIOME) .value(Biomes.OCEAN) ); @@ -112,10 +112,10 @@ public int hashCode() { } @Override - public VolumeStream getBiomeStream(final Vector3i min, final Vector3i max, final StreamOptions options + public VolumeStream biomeStream(final Vector3i min, final Vector3i max, final StreamOptions options ) { - final Vector3i blockMin = this.getBlockMin(); - final Vector3i blockMax = this.getBlockMax(); + final Vector3i blockMin = this.blockMin(); + final Vector3i blockMax = this.blockMax(); VolumeStreamUtils.validateStreamArgs(min, max, blockMin, blockMax, options); final Stream> stateStream = IntStream.range(blockMin.getX(), blockMax.getX() + 1) @@ -123,8 +123,8 @@ public VolumeStream getBiomeStream(final Vector3i min, final V .mapToObj(z -> IntStream.range(blockMin.getY(), blockMax.getY() + 1) .mapToObj(y -> VolumeElement.of(this, () -> { final byte biomeId = this.biomes[this.getIndex(x, y, z)]; - return this.palette.get(biomeId & 255, Sponge.getServer().registries()) - .orElseGet(Sponge.getServer().registries() + return this.palette.get(biomeId & 255, Sponge.server().registries()) + .orElseGet(Sponge.server().registries() .registry(RegistryTypes.BIOME) .value(Biomes.OCEAN) ); diff --git a/src/main/java/org/spongepowered/common/world/volume/buffer/biome/ByteArrayMutableBiomeBuffer.java b/src/main/java/org/spongepowered/common/world/volume/buffer/biome/ByteArrayMutableBiomeBuffer.java index 21f1fb5e594..309770e080e 100644 --- a/src/main/java/org/spongepowered/common/world/volume/buffer/biome/ByteArrayMutableBiomeBuffer.java +++ b/src/main/java/org/spongepowered/common/world/volume/buffer/biome/ByteArrayMutableBiomeBuffer.java @@ -59,24 +59,24 @@ public ByteArrayMutableBiomeBuffer(final Palette palette, final Ve public ByteArrayMutableBiomeBuffer(final Palette palette, final byte[] biomes, final Vector3i start, final Vector3i size) { super(start, size); this.biomes = biomes; - this.palette = palette.asMutable(Sponge.getGame().registries()); + this.palette = palette.asMutable(Sponge.game().registries()); } @Override public boolean setBiome(final int x, final int y, final int z, final Biome biome) { this.checkRange(x, y, z); - this.biomes[this.getIndex(x, y, z)] = (byte) this.palette.getOrAssign(biome); + this.biomes[this.getIndex(x, y, z)] = (byte) this.palette.orAssign(biome); return true; } @Override - public Biome getBiome(final int x, final int y, final int z) { + public Biome biome(final int x, final int y, final int z) { this.checkRange(x, y, z); final byte biomeId = this.biomes[this.getIndex(x, y, z)]; - return this.palette.get(biomeId & 255, Sponge.getServer().registries()) - .orElseGet(Sponge.getServer().registries() + return this.palette.get(biomeId & 255, Sponge.server().registries()) + .orElseGet(Sponge.server().registries() .registry(RegistryTypes.BIOME) .value(Biomes.OCEAN) ); @@ -106,13 +106,13 @@ public int hashCode() { } @Override - public VolumeStream getBiomeStream( + public VolumeStream biomeStream( final Vector3i min, final Vector3i max, final StreamOptions options ) { - final Vector3i blockMin = this.getBlockMin(); - final Vector3i blockMax = this.getBlockMax(); + final Vector3i blockMin = this.blockMin(); + final Vector3i blockMax = this.blockMax(); VolumeStreamUtils.validateStreamArgs(min, max, blockMin, blockMax, options); final byte[] biomes; if (options.carbonCopy()) { @@ -125,8 +125,8 @@ public VolumeStream getBiomeStream( .mapToObj(z -> IntStream.range(blockMin.getY(), blockMax.getY() + 1) .mapToObj(y -> VolumeElement.of(this, () -> { final byte biomeId = biomes[this.getIndex(x, y, z)]; - return this.palette.get(biomeId & 255, Sponge.getServer().registries()) - .orElseGet(() -> Sponge.getServer().registries() + return this.palette.get(biomeId & 255, Sponge.server().registries()) + .orElseGet(() -> Sponge.server().registries() .registry(RegistryTypes.BIOME) .value(Biomes.OCEAN) ); diff --git a/src/main/java/org/spongepowered/common/world/volume/buffer/biome/ObjectArrayImmutableBiomeBuffer.java b/src/main/java/org/spongepowered/common/world/volume/buffer/biome/ObjectArrayImmutableBiomeBuffer.java index 056d46806b2..dee384ce710 100644 --- a/src/main/java/org/spongepowered/common/world/volume/buffer/biome/ObjectArrayImmutableBiomeBuffer.java +++ b/src/main/java/org/spongepowered/common/world/volume/buffer/biome/ObjectArrayImmutableBiomeBuffer.java @@ -65,7 +65,7 @@ public ObjectArrayImmutableBiomeBuffer(final Biome[] biomes, final Vector3i star } @Override - public Biome getBiome(final int x, final int y, final int z) { + public Biome biome(final int x, final int y, final int z) { this.checkRange(x, y, z); return this.biomes[this.getIndex(x, y, z)]; } @@ -109,12 +109,12 @@ public int hashCode() { } @Override - public VolumeStream getBiomeStream(final Vector3i min, final Vector3i max, final StreamOptions options + public VolumeStream biomeStream(final Vector3i min, final Vector3i max, final StreamOptions options ) { VolumeStreamUtils.validateStreamArgs(min, max, options); - final Stream> stateStream = IntStream.range(this.getBlockMin().getX(), this.getBlockMax().getX() + 1) - .mapToObj(x -> IntStream.range(this.getBlockMin().getZ(), this.getBlockMax().getZ() + 1) - .mapToObj(z -> IntStream.range(this.getBlockMin().getY(), this.getBlockMax().getY() + 1) + final Stream> stateStream = IntStream.range(this.blockMin().getX(), this.blockMax().getX() + 1) + .mapToObj(x -> IntStream.range(this.blockMin().getZ(), this.blockMax().getZ() + 1) + .mapToObj(z -> IntStream.range(this.blockMin().getY(), this.blockMax().getY() + 1) .mapToObj(y -> VolumeElement.of(this, () -> this.biomes[this.getIndex(x, y, z)], new Vector3i(x, y, z))) ).flatMap(Function.identity()) ).flatMap(Function.identity()); diff --git a/src/main/java/org/spongepowered/common/world/volume/buffer/biome/ObjectArrayMutableBiomeBuffer.java b/src/main/java/org/spongepowered/common/world/volume/buffer/biome/ObjectArrayMutableBiomeBuffer.java index 8b044d5a07f..9c8bc31bd70 100644 --- a/src/main/java/org/spongepowered/common/world/volume/buffer/biome/ObjectArrayMutableBiomeBuffer.java +++ b/src/main/java/org/spongepowered/common/world/volume/buffer/biome/ObjectArrayMutableBiomeBuffer.java @@ -75,7 +75,7 @@ public ObjectArrayMutableBiomeBuffer(final Biome[] biomes, final Vector3i start, } @Override - public Biome getBiome(final int x, final int y, final int z) { + public Biome biome(final int x, final int y, final int z) { this.checkRange(x, y, z); return this.biomes[this.getIndex(x, y, z)]; } @@ -136,13 +136,13 @@ public int hashCode() { } @Override - public VolumeStream getBiomeStream( + public VolumeStream biomeStream( final Vector3i min, final Vector3i max, final StreamOptions options ) { - final Vector3i blockMin = this.getBlockMin(); - final Vector3i blockMax = this.getBlockMax(); + final Vector3i blockMin = this.blockMin(); + final Vector3i blockMax = this.blockMax(); VolumeStreamUtils.validateStreamArgs(min, max, blockMin, blockMax, options); final Biome[] buffer; if (options.carbonCopy()) { diff --git a/src/main/java/org/spongepowered/common/world/volume/buffer/block/ArrayImmutableBlockBuffer.java b/src/main/java/org/spongepowered/common/world/volume/buffer/block/ArrayImmutableBlockBuffer.java index 63f2e3d8b62..6c93de03d78 100644 --- a/src/main/java/org/spongepowered/common/world/volume/buffer/block/ArrayImmutableBlockBuffer.java +++ b/src/main/java/org/spongepowered/common/world/volume/buffer/block/ArrayImmutableBlockBuffer.java @@ -46,7 +46,7 @@ public class ArrayImmutableBlockBuffer extends AbstractBlockBuffer implements BlockVolume.Immutable { - private static final BlockState AIR = BlockTypes.AIR.get().getDefaultState(); + private static final BlockState AIR = BlockTypes.AIR.get().defaultState(); private final Palette palette; private final BlockBackingData data; @@ -83,18 +83,18 @@ public Palette getPalette() { } @Override - public BlockState getBlock(final int x, final int y, final int z) { + public BlockState block(final int x, final int y, final int z) { this.checkRange(x, y, z); - return this.palette.get(this.data.get(this.getIndex(x, y, z)), Sponge.getGame().registries()).orElse(ArrayImmutableBlockBuffer.AIR); + return this.palette.get(this.data.get(this.getIndex(x, y, z)), Sponge.game().registries()).orElse(ArrayImmutableBlockBuffer.AIR); } @Override - public FluidState getFluid(final int x, final int y, final int z) { - return this.getBlock(x, y, z).getFluidState(); + public FluidState fluid(final int x, final int y, final int z) { + return this.block(x, y, z).fluidState(); } @Override - public int getHighestYAt(final int x, final int z) { + public int highestYAt(final int x, final int z) { return 0; } @@ -133,14 +133,14 @@ public int hashCode() { } @Override - public VolumeStream getBlockStateStream(final Vector3i min, final Vector3i max, final StreamOptions options + public VolumeStream blockStateStream(final Vector3i min, final Vector3i max, final StreamOptions options ) { - VolumeStreamUtils.validateStreamArgs(min, max, this.getBlockMin(), this.getBlockMax(), options); + VolumeStreamUtils.validateStreamArgs(min, max, this.blockMin(), this.blockMax(), options); // We don't need to copy since this is immutable. - final Stream> stateStream = IntStream.range(this.getBlockMin().getX(), this.getBlockMax().getX() + 1) - .mapToObj(x -> IntStream.range(this.getBlockMin().getZ(), this.getBlockMax().getZ() + 1) - .mapToObj(z -> IntStream.range(this.getBlockMin().getY(), this.getBlockMax().getY() + 1) - .mapToObj(y -> VolumeElement.of(this, () -> this.getBlock(x, y, z), new Vector3i(x, y, z))) + final Stream> stateStream = IntStream.range(this.blockMin().getX(), this.blockMax().getX() + 1) + .mapToObj(x -> IntStream.range(this.blockMin().getZ(), this.blockMax().getZ() + 1) + .mapToObj(z -> IntStream.range(this.blockMin().getY(), this.blockMax().getY() + 1) + .mapToObj(y -> VolumeElement.of(this, () -> this.block(x, y, z), new Vector3i(x, y, z))) ).flatMap(Function.identity()) ).flatMap(Function.identity()); return new SpongeVolumeStream<>(stateStream, () -> this); diff --git a/src/main/java/org/spongepowered/common/world/volume/buffer/block/ArrayMutableBlockBuffer.java b/src/main/java/org/spongepowered/common/world/volume/buffer/block/ArrayMutableBlockBuffer.java index c95f1ebaaa4..dca3aa6b641 100644 --- a/src/main/java/org/spongepowered/common/world/volume/buffer/block/ArrayMutableBlockBuffer.java +++ b/src/main/java/org/spongepowered/common/world/volume/buffer/block/ArrayMutableBlockBuffer.java @@ -52,7 +52,7 @@ public class ArrayMutableBlockBuffer extends AbstractBlockBuffer implements BlockVolume.Mutable { - private static final BlockState AIR = BlockTypes.AIR.get().getDefaultState(); + private static final BlockState AIR = BlockTypes.AIR.get().defaultState(); private final Palette.Mutable palette; private final RegistryReference defaultState; @@ -62,7 +62,7 @@ public ArrayMutableBlockBuffer(final Vector3i start, final Vector3i size) { this( new MutableBimapPalette<>( PaletteTypes.BLOCK_STATE_PALETTE.get(), - Sponge.getGame().registries().registry(RegistryTypes.BLOCK_TYPE), + Sponge.game().registries().registry(RegistryTypes.BLOCK_TYPE), RegistryTypes.BLOCK_TYPE ), BlockTypes.AIR, @@ -75,13 +75,13 @@ public ArrayMutableBlockBuffer(final Palette palette, fin final Vector3i start, final Vector3i size ) { super(start, size); - final Palette.Mutable mutablePalette = palette.asMutable(Sponge.getGame().registries()); + final Palette.Mutable mutablePalette = palette.asMutable(Sponge.game().registries()); this.palette = mutablePalette; - final int airId = mutablePalette.getOrAssign(ArrayMutableBlockBuffer.AIR); + final int airId = mutablePalette.orAssign(ArrayMutableBlockBuffer.AIR); final int dataSize = this.area(); this.defaultState = defaultState; - this.data = new BlockBackingData.PackedBackingData(dataSize, palette.getHighestId()); + this.data = new BlockBackingData.PackedBackingData(dataSize, palette.highestId()); // all blocks default to air if (airId != 0) { @@ -93,7 +93,7 @@ public ArrayMutableBlockBuffer(final Palette palette, fin public ArrayMutableBlockBuffer(final Palette palette, final Vector3i start, final Vector3i size, final char[] blocks) { super(start, size); - this.palette = palette.asMutable(Sponge.getGame().registries()); + this.palette = palette.asMutable(Sponge.game().registries()); this.data = new BlockBackingData.CharBackingData(blocks); this.defaultState = BlockTypes.AIR; } @@ -108,7 +108,7 @@ public ArrayMutableBlockBuffer(final Palette palette, fin */ ArrayMutableBlockBuffer(final Palette palette, final BlockBackingData blocks, final Vector3i start, final Vector3i size) { super(start, size); - this.palette = palette.asMutable(Sponge.getGame().registries()); + this.palette = palette.asMutable(Sponge.game().registries()); this.data = blocks; this.defaultState = BlockTypes.AIR; } @@ -121,10 +121,10 @@ public Palette getPalette() { @Override public boolean setBlock(final int x, final int y, final int z, final BlockState block) { this.checkRange(x, y, z); - final int id = this.palette.getOrAssign(block); + final int id = this.palette.orAssign(block); if (id > this.data.getMax()) { - final int highId = this.palette.getHighestId(); + final int highId = this.palette.highestId(); final int dataSize = this.area(); final BlockBackingData newdata = new BlockBackingData.PackedBackingData(dataSize, highId); for (int i = 0; i < dataSize; i++) { @@ -139,24 +139,24 @@ public boolean setBlock(final int x, final int y, final int z, final BlockState @Override public boolean removeBlock(final int x, final int y, final int z) { this.checkRange(x, y, z); - return this.setBlock(x, y, z, BlockTypes.AIR.get().getDefaultState()); + return this.setBlock(x, y, z, BlockTypes.AIR.get().defaultState()); } @Override - public BlockState getBlock(final int x, final int y, final int z) { + public BlockState block(final int x, final int y, final int z) { this.checkRange(x, y, z); - final RegistryHolder registries = Sponge.getGame().registries(); + final RegistryHolder registries = Sponge.game().registries(); return this.palette.get(this.data.get(this.getIndex(x, y, z)), registries) - .orElseGet(() -> this.defaultState.get(registries).getDefaultState()); + .orElseGet(() -> this.defaultState.get(registries).defaultState()); } @Override - public FluidState getFluid(final int x, final int y, final int z) { - return this.getBlock(x, y, z).getFluidState(); + public FluidState fluid(final int x, final int y, final int z) { + return this.block(x, y, z).fluidState(); } @Override - public int getHighestYAt(final int x, final int z) { + public int highestYAt(final int x, final int z) { return 0; } @@ -186,9 +186,9 @@ public int hashCode() { } @Override - public VolumeStream getBlockStateStream(final Vector3i min, final Vector3i max, final StreamOptions options) { - final Vector3i blockMin = this.getBlockMin(); - final Vector3i blockMax = this.getBlockMax(); + public VolumeStream blockStateStream(final Vector3i min, final Vector3i max, final StreamOptions options) { + final Vector3i blockMin = this.blockMin(); + final Vector3i blockMax = this.blockMax(); VolumeStreamUtils.validateStreamArgs(min, max, blockMin, blockMax, options); final ArrayMutableBlockBuffer buffer; if (options.carbonCopy()) { @@ -199,7 +199,7 @@ public VolumeStream getBlockStateStream(fin final Stream> stateStream = IntStream.range(blockMin.getX(), blockMax.getX() + 1) .mapToObj(x -> IntStream.range(blockMin.getZ(), blockMax.getZ() + 1) .mapToObj(z -> IntStream.range(blockMin.getY(), blockMax.getY() + 1) - .mapToObj(y -> VolumeElement.of(this, () -> buffer.getBlock(x, y, z), new Vector3i(x, y, z))) + .mapToObj(y -> VolumeElement.of(this, () -> buffer.block(x, y, z), new Vector3i(x, y, z))) ).flatMap(Function.identity()) ).flatMap(Function.identity()); return new SpongeVolumeStream<>(stateStream, () -> this); @@ -210,7 +210,7 @@ public void setBlock(final BlockPos pos, final net.minecraft.world.level.block.s } public net.minecraft.world.level.block.state.BlockState getBlock(final BlockPos blockPos) { - return (net.minecraft.world.level.block.state.BlockState) this.getBlock(blockPos.getX(), blockPos.getY(), blockPos.getZ()); + return (net.minecraft.world.level.block.state.BlockState) this.block(blockPos.getX(), blockPos.getY(), blockPos.getZ()); } public ArrayMutableBlockBuffer copy() { diff --git a/src/main/java/org/spongepowered/common/world/volume/buffer/blockentity/AbstractMutableBlockEntityBuffer.java b/src/main/java/org/spongepowered/common/world/volume/buffer/blockentity/AbstractMutableBlockEntityBuffer.java index f35733ccf6f..1c2aaf854fe 100644 --- a/src/main/java/org/spongepowered/common/world/volume/buffer/blockentity/AbstractMutableBlockEntityBuffer.java +++ b/src/main/java/org/spongepowered/common/world/volume/buffer/blockentity/AbstractMutableBlockEntityBuffer.java @@ -78,26 +78,26 @@ public Palette getPalette() { } @Override - public BlockState getBlock(final int x, final int y, final int z) { - return this.blockBuffer.getBlock(x, y, z); + public BlockState block(final int x, final int y, final int z) { + return this.blockBuffer.block(x, y, z); } @Override - public FluidState getFluid(final int x, final int y, final int z) { - return this.blockBuffer.getFluid(x, y, z); + public FluidState fluid(final int x, final int y, final int z) { + return this.blockBuffer.fluid(x, y, z); } @Override - public int getHighestYAt(final int x, final int z) { - return this.blockBuffer.getHighestYAt(x, z); + public int highestYAt(final int x, final int z) { + return this.blockBuffer.highestYAt(x, z); } @SuppressWarnings("unchecked") @Override - public VolumeStream getBlockStateStream(final Vector3i min, final Vector3i max, + public VolumeStream blockStateStream(final Vector3i min, final Vector3i max, final StreamOptions options) { - final Vector3i blockMin = this.getBlockMin(); - final Vector3i blockMax = this.getBlockMax(); + final Vector3i blockMin = this.blockMin(); + final Vector3i blockMax = this.blockMax(); VolumeStreamUtils.validateStreamArgs(min, max, blockMin, blockMax, options); final ArrayMutableBlockBuffer buffer; if (options.carbonCopy()) { @@ -108,7 +108,7 @@ public VolumeStream getBlockStateStream(final Vector3i min, final final Stream> stateStream = IntStream.range(blockMin.getX(), blockMax.getX() + 1) .mapToObj(x -> IntStream.range(blockMin.getZ(), blockMax.getZ() + 1) .mapToObj(z -> IntStream.range(blockMin.getY(), blockMax.getY() + 1) - .mapToObj(y -> VolumeElement.of((M) this, () -> buffer.getBlock(x, y, z), new Vector3i(x, y, z))) + .mapToObj(y -> VolumeElement.of((M) this, () -> buffer.block(x, y, z), new Vector3i(x, y, z))) ).flatMap(Function.identity()) ).flatMap(Function.identity()); return new SpongeVolumeStream<>(stateStream, () -> (M) this); diff --git a/src/main/java/org/spongepowered/common/world/volume/buffer/blockentity/ObjectArrayMutableBlockEntityBuffer.java b/src/main/java/org/spongepowered/common/world/volume/buffer/blockentity/ObjectArrayMutableBlockEntityBuffer.java index 4aacfbe347b..c2b6854455b 100644 --- a/src/main/java/org/spongepowered/common/world/volume/buffer/blockentity/ObjectArrayMutableBlockEntityBuffer.java +++ b/src/main/java/org/spongepowered/common/world/volume/buffer/blockentity/ObjectArrayMutableBlockEntityBuffer.java @@ -57,36 +57,36 @@ public void addBlockEntity(final int x, final int y, final int z, final BlockEnt @Override public void removeBlockEntity(final int x, final int y, final int z) { this.blockEntities.removeIf(be -> { - final Vector3i pos = be.getBlockPosition(); + final Vector3i pos = be.blockPosition(); return pos.getX() == x && pos.getZ() == z && pos.getY() == y; }); } @Override - public VolumeStream getBlockEntityStream(final Vector3i min, final Vector3i max, + public VolumeStream blockEntityStream(final Vector3i min, final Vector3i max, final StreamOptions options) { - VolumeStreamUtils.validateStreamArgs(min, max, this.getBlockMin(), this.getBlockMax(), options); + VolumeStreamUtils.validateStreamArgs(min, max, this.blockMin(), this.blockMax(), options); final Stream> blockEntityStream = this.blockEntities.stream() - .map(be -> VolumeElement.of(this, be, be.getBlockPosition())); + .map(be -> VolumeElement.of(this, be, be.blockPosition())); return new SpongeVolumeStream<>(blockEntityStream, () -> this); } @Override - public Collection getBlockEntities() { + public Collection blockEntities() { return this.blockEntities; } @Override - public Optional getBlockEntity(final int x, final int y, final int z) { + public Optional blockEntity(final int x, final int y, final int z) { return this.blockEntities.stream().filter(be -> { - final Vector3i pos = be.getBlockPosition(); + final Vector3i pos = be.blockPosition(); return pos.getX() == x && pos.getY() == y && pos.getZ() == z; }).findFirst(); } public net.minecraft.world.level.block.entity.@Nullable BlockEntity getTileEntity(final BlockPos blockPos) { - return (net.minecraft.world.level.block.entity.BlockEntity) this.getBlockEntity(blockPos.getX(), blockPos.getY(), blockPos.getZ()).orElse(null); + return (net.minecraft.world.level.block.entity.BlockEntity) this.blockEntity(blockPos.getX(), blockPos.getY(), blockPos.getZ()).orElse(null); } } diff --git a/src/main/java/org/spongepowered/common/world/volume/buffer/entity/ObjectArrayMutableEntityBuffer.java b/src/main/java/org/spongepowered/common/world/volume/buffer/entity/ObjectArrayMutableEntityBuffer.java index 1fa9870be62..72fac512fc8 100644 --- a/src/main/java/org/spongepowered/common/world/volume/buffer/entity/ObjectArrayMutableEntityBuffer.java +++ b/src/main/java/org/spongepowered/common/world/volume/buffer/entity/ObjectArrayMutableEntityBuffer.java @@ -83,33 +83,33 @@ public Palette getPalette() { } @Override - public BlockState getBlock(final int x, final int y, final int z) { - return this.blockBuffer.getBlock(x, y, z); + public BlockState block(final int x, final int y, final int z) { + return this.blockBuffer.block(x, y, z); } @Override - public FluidState getFluid(final int x, final int y, final int z) { - return this.blockBuffer.getFluid(x, y, z); + public FluidState fluid(final int x, final int y, final int z) { + return this.blockBuffer.fluid(x, y, z); } @Override - public int getHighestYAt(final int x, final int z) { - return this.blockBuffer.getHighestYAt(x, z); + public int highestYAt(final int x, final int z) { + return this.blockBuffer.highestYAt(x, z); } @Override - public VolumeStream getBlockStateStream(final Vector3i min, final Vector3i max, + public VolumeStream blockStateStream(final Vector3i min, final Vector3i max, final StreamOptions options ) { final Stream> stateStream = IntStream.range( - this.getBlockMin().getX(), - this.getBlockMax().getX() + 1 + this.blockMin().getX(), + this.blockMax().getX() + 1 ) - .mapToObj(x -> IntStream.range(this.getBlockMin().getZ(), this.getBlockMax().getZ() + 1) - .mapToObj(z -> IntStream.range(this.getBlockMin().getY(), this.getBlockMax().getY() + 1) + .mapToObj(x -> IntStream.range(this.blockMin().getZ(), this.blockMax().getZ() + 1) + .mapToObj(z -> IntStream.range(this.blockMin().getY(), this.blockMax().getY() + 1) .mapToObj(y -> VolumeElement.of( this, - () -> this.blockBuffer.getBlock(x, y, z), + () -> this.blockBuffer.block(x, y, z), new Vector3i(x, y, z) )) ).flatMap(Function.identity()) @@ -153,8 +153,8 @@ public boolean spawnEntity(final Entity entity) { if (entity == null) { throw new IllegalArgumentException("Entity cannot be null!"); } - if (!this.containsBlock(entity.getPosition().toInt())) { - throw new IllegalArgumentException(String.format("Entity is out of bounds! {min: %s, max: %s} does not contain %s", this.getBlockMin(), this.getBlockMax(), entity.getPosition())); + if (!this.containsBlock(entity.position().toInt())) { + throw new IllegalArgumentException(String.format("Entity is out of bounds! {min: %s, max: %s} does not contain %s", this.blockMin(), this.blockMax(), entity.position())); } return this.entities.add(entity); } @@ -167,7 +167,7 @@ public Collection spawnEntities(final Iterable entitie } @Override - public Collection getPlayers() { + public Collection players() { return this.entities.stream() .filter(entity -> entity instanceof Player) .map(entity -> (Player) entity) @@ -175,31 +175,31 @@ public Collection getPlayers() { } @Override - public Optional getEntity(final UUID uuid) { + public Optional entity(final UUID uuid) { if (uuid == null) { throw new IllegalArgumentException("UUID cannot be null!"); } return this.entities.stream() - .filter(entity -> uuid.equals(entity.getUniqueId())) + .filter(entity -> uuid.equals(entity.uniqueId())) .findFirst(); } @Override - public Collection getEntities(final Class entityClass, final AABB box, + public Collection entities(final Class entityClass, final AABB box, @Nullable final Predicate predicate ) { Objects.requireNonNull(entityClass); Objects.requireNonNull(box); - if (!this.containsBlock(box.getMin().toInt())) { + if (!this.containsBlock(box.min().toInt())) { throw new IllegalArgumentException("Box is larger than volume allowed"); } - if (!this.containsBlock(box.getMax().toInt())) { + if (!this.containsBlock(box.max().toInt())) { throw new IllegalArgumentException("Box is larger than volume allowed!"); } Stream tStream = this.entities.stream() .filter(entityClass::isInstance) .map(entity -> (T) entity) - .filter(entity -> box.contains(entity.getPosition())); + .filter(entity -> box.contains(entity.position())); if (predicate != null) { tStream = tStream.filter(predicate); } @@ -209,28 +209,28 @@ public Collection getEntities(final Class getEntities(final AABB box, final Predicate filter) { + public Collection entities(final AABB box, final Predicate filter) { Objects.requireNonNull(filter, "Filter cannot be null"); Objects.requireNonNull(box, "Bounding box cannot be null"); - if (!this.containsBlock(box.getMin().toInt())) { + if (!this.containsBlock(box.min().toInt())) { throw new IllegalArgumentException("Box is larger than volume allowed"); } - if (!this.containsBlock(box.getMax().toInt())) { + if (!this.containsBlock(box.max().toInt())) { throw new IllegalArgumentException("Box is larger than volume allowed!"); } return this.entities.stream() - .filter(entity -> box.contains(entity.getPosition())) + .filter(entity -> box.contains(entity.position())) .filter(filter) .collect(Collectors.toList()); } @Override - public VolumeStream getEntityStream(final Vector3i min, final Vector3i max, final StreamOptions options + public VolumeStream entityStream(final Vector3i min, final Vector3i max, final StreamOptions options ) { - VolumeStreamUtils.validateStreamArgs(min, max, this.getBlockMin(), this.getBlockMax(), options); + VolumeStreamUtils.validateStreamArgs(min, max, this.blockMin(), this.blockMax(), options); // Normally, we'd be able to shadow-copy, but we can't copy entities, and we're only using a list, so we can iterate only on the list. final Stream> backingStream = this.entities.stream() - .map(entity -> VolumeElement.of(this, entity, entity.getBlockPosition())); + .map(entity -> VolumeElement.of(this, entity, entity.blockPosition())); return new SpongeVolumeStream<>(backingStream, () -> this); } diff --git a/src/main/java/org/spongepowered/common/world/weather/SpongeWeather.java b/src/main/java/org/spongepowered/common/world/weather/SpongeWeather.java index a80df30fe94..b707aa4bfd7 100644 --- a/src/main/java/org/spongepowered/common/world/weather/SpongeWeather.java +++ b/src/main/java/org/spongepowered/common/world/weather/SpongeWeather.java @@ -59,16 +59,16 @@ public Ticks runningDuration() { } @Override - public int getContentVersion() { + public int contentVersion() { return 0; } @Override public DataContainer toContainer() { return DataContainer.createNew() - .set(Queries.CONTENT_VERSION, this.getContentVersion()) + .set(Queries.CONTENT_VERSION, this.contentVersion()) .set(Constants.Universe.Weather.TYPE, this.type.key(RegistryTypes.WEATHER_TYPE)) - .set(Constants.Universe.Weather.REMAINING_DURATION, this.remainingDuration.getTicks()) - .set(Constants.Universe.Weather.RUNNING_DURATION, this.runningDuration.getTicks()); + .set(Constants.Universe.Weather.REMAINING_DURATION, this.remainingDuration.ticks()) + .set(Constants.Universe.Weather.RUNNING_DURATION, this.runningDuration.ticks()); } } diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/common/entity/living/HumanEntityMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/common/entity/living/HumanEntityMixin_API.java index 43da58cfcdd..fa6efcfe5c5 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/common/entity/living/HumanEntityMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/common/entity/living/HumanEntityMixin_API.java @@ -39,7 +39,7 @@ public abstract class HumanEntityMixin_API extends PathfinderMobMixin_API implem @Shadow private GameProfile fakeProfile; @Override - public String getName() { + public String name() { return this.fakeProfile.getName(); } diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/common/util/MinecraftBlockDamageSourceMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/common/util/MinecraftBlockDamageSourceMixin_API.java index db750677ce9..62f35344c17 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/common/util/MinecraftBlockDamageSourceMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/common/util/MinecraftBlockDamageSourceMixin_API.java @@ -45,22 +45,22 @@ public abstract class MinecraftBlockDamageSourceMixin_API extends DamageSourceMi @Shadow(remap = false) @Final private ServerLocation location; @Override - public ServerLocation getLocation() { + public ServerLocation location() { return this.location; } @Override - public BlockSnapshot getBlockSnapshot() { + public BlockSnapshot blockSnapshot() { return this.blockSnapshot; } @Override public String toString() { - final ResourceKey resourceKey = Sponge.getGame().registries().registry(RegistryTypes.DAMAGE_TYPE).valueKey(this.getType()); + final ResourceKey resourceKey = Sponge.game().registries().registry(RegistryTypes.DAMAGE_TYPE).valueKey(this.type()); return MoreObjects.toStringHelper("BlockDamageSource") .add("Name", this.shadow$getMsgId()) .add("Key", resourceKey) - .add("BlockSnapshot", this.getBlockSnapshot()) + .add("BlockSnapshot", this.blockSnapshot()) .add("Location", this.location) .toString(); } diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/common/util/MinecraftFallingBlockDamageSourceMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/common/util/MinecraftFallingBlockDamageSourceMixin_API.java index 5523e9eaf94..f8799182832 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/common/util/MinecraftFallingBlockDamageSourceMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/common/util/MinecraftFallingBlockDamageSourceMixin_API.java @@ -38,18 +38,18 @@ public abstract class MinecraftFallingBlockDamageSourceMixin_API extends EntityDamageSourceMixin_API implements FallingBlockDamageSource { @Override - public FallingBlock getSource() { - return (FallingBlock) super.getSource(); + public FallingBlock source() { + return (FallingBlock) super.source(); } @Override public String toString() { - final ResourceKey resourceKey = Sponge.getGame().registries().registry(RegistryTypes.DAMAGE_TYPE).valueKey(this.getType()); + final ResourceKey resourceKey = Sponge.game().registries().registry(RegistryTypes.DAMAGE_TYPE).valueKey(this.type()); return MoreObjects.toStringHelper(this) .add("Name", this.shadow$getMsgId()) .add("Key", resourceKey) - .add("FallingBlock", this.getSource().toString()) + .add("FallingBlock", this.source().toString()) .toString(); } } diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/entity/ai/goal/AbstractGoalMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/entity/ai/goal/AbstractGoalMixin_API.java index 01e1777ec3d..bd4bb1c7f8e 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/entity/ai/goal/AbstractGoalMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/entity/ai/goal/AbstractGoalMixin_API.java @@ -43,7 +43,7 @@ public abstract class AbstractGoalMixin_API implements Goal */ @Override @Overwrite - public final Optional> getExecutor() { + public final Optional> executor() { return (Optional>) (Optional) ((GoalBridge) this).bridge$getGoalExecutor(); } diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/event/cause/entity/damage/source/common/AbstractDamageSourceMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/event/cause/entity/damage/source/common/AbstractDamageSourceMixin_API.java index 26561c27847..7595d145441 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/event/cause/entity/damage/source/common/AbstractDamageSourceMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/event/cause/entity/damage/source/common/AbstractDamageSourceMixin_API.java @@ -48,7 +48,7 @@ public abstract class AbstractDamageSourceMixin_API implements DamageSource { @Inject(method = "", at = @At("RETURN")) private void api$setUpBridges(final CallbackInfo callbackInfo) { final SpongeCommonDamageSource commonSource = (SpongeCommonDamageSource) (Object) this; - commonSource.setDamageType(this.getType().getName()); + commonSource.setDamageType(this.type().name()); if (this.isAbsolute()) { commonSource.bridge$setDamageIsAbsolute(); } @@ -69,7 +69,7 @@ public abstract class AbstractDamageSourceMixin_API implements DamageSource { } // Sets exhaustion last as to allow control if the builder specified a custom exhaustion value - commonSource.bridge$setHungerDamage((float) this.getExhaustion()); + commonSource.bridge$setHungerDamage((float) this.exhaustion()); } } diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/event/cause/entity/damage/source/common/AbstractEntityDamageSourceMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/event/cause/entity/damage/source/common/AbstractEntityDamageSourceMixin_API.java index fabd75d56f9..3ef669f1988 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/event/cause/entity/damage/source/common/AbstractEntityDamageSourceMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/event/cause/entity/damage/source/common/AbstractEntityDamageSourceMixin_API.java @@ -25,11 +25,9 @@ package org.spongepowered.common.mixin.api.event.cause.entity.damage.source.common; import net.minecraft.world.entity.Entity; -import org.spongepowered.api.event.cause.entity.damage.DamageType; import org.spongepowered.api.event.cause.entity.damage.source.EntityDamageSource; import org.spongepowered.api.event.cause.entity.damage.source.common.AbstractEntityDamageSource; import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @@ -51,8 +49,8 @@ public abstract class AbstractEntityDamageSourceMixin_API implements EntityDamag @Inject(method = "", at = @At("RETURN")) private void impl$bridgeApiToImplConstruction(final CallbackInfo callbackInfo) { final SpongeCommonEntityDamageSource commonSource = (SpongeCommonEntityDamageSource) (Object) this; - commonSource.setDamageType(this.getType().getName()); - commonSource.setEntitySource((Entity) this.getSource()); + commonSource.setDamageType(this.type().name()); + commonSource.setEntitySource((Entity) this.source()); if (this.isAbsolute()) { commonSource.bridge$setDamageIsAbsolute(); } diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/event/cause/entity/damage/source/common/AbstractIndirectEntityDamageSourceMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/event/cause/entity/damage/source/common/AbstractIndirectEntityDamageSourceMixin_API.java index 37adc58f1dd..7def82035a8 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/event/cause/entity/damage/source/common/AbstractIndirectEntityDamageSourceMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/event/cause/entity/damage/source/common/AbstractIndirectEntityDamageSourceMixin_API.java @@ -49,9 +49,9 @@ public abstract class AbstractIndirectEntityDamageSourceMixin_API implements Ind @Inject(method = "", at = @At("RETURN")) private void api$setUpBridges(final CallbackInfo callbackInfo) { final SpongeCommonIndirectEntityDamageSource commonIndirect = (SpongeCommonIndirectEntityDamageSource) (Object) this; - commonIndirect.setDamageType(this.getType().getName()); - commonIndirect.setEntitySource((Entity) this.getSource()); - commonIndirect.setIndirectSource((Entity) this.getIndirectSource()); + commonIndirect.setDamageType(this.type().name()); + commonIndirect.setEntitySource((Entity) this.source()); + commonIndirect.setIndirectSource((Entity) this.indirectSource()); if (this.isAbsolute()) { commonIndirect.bridge$setDamageIsAbsolute(); } diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/item/merchant/MerchantMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/item/merchant/MerchantMixin_API.java index 80c782c1815..e3cd89f005a 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/item/merchant/MerchantMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/item/merchant/MerchantMixin_API.java @@ -50,7 +50,7 @@ public interface MerchantMixin_API extends Merchant { @Nullable default Player imerchant$getTradingPlayer() { - return (Player) this.getCustomer() + return (Player) this.customer() .filter(humanoid -> humanoid instanceof Player) .orElse(null); } @@ -73,6 +73,6 @@ public interface MerchantMixin_API extends Merchant { } default Level imerchant$getLevel() { - return ((Level) this.getLocation().getWorld()); + return ((Level) this.location().world()); } } diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/advancements/AdvancementMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/advancements/AdvancementMixin_API.java index cdabac11f39..376ea79a218 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/advancements/AdvancementMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/advancements/AdvancementMixin_API.java @@ -57,32 +57,32 @@ public abstract class AdvancementMixin_API implements org.spongepowered.api.adva @Shadow @Final private Advancement parent; @Override - public Optional getTree() { + public Optional tree() { if (this.parent == null) { return Optional.of(this); } - return ((org.spongepowered.api.advancement.Advancement) this.parent).getTree(); + return ((org.spongepowered.api.advancement.Advancement) this.parent).tree(); } @SuppressWarnings({"unchecked", "rawtypes"}) @Override - public Collection getChildren() { + public Collection children() { return ImmutableList.copyOf((Collection) this.children); } @Override - public AdvancementCriterion getCriterion() { + public AdvancementCriterion criterion() { return ((AdvancementBridge) this).bridge$getCriterion(); } @SuppressWarnings("unchecked") @Override - public Optional getParent() { + public Optional parent() { return (Optional) (Optional) ((AdvancementBridge) this).bridge$getParent(); } @Override - public Optional getDisplayInfo() { + public Optional displayInfo() { return Optional.ofNullable((org.spongepowered.api.advancement.DisplayInfo) this.display); } @@ -92,7 +92,7 @@ public List toToastText() { } @Override - public ResourceKey getKey() { + public ResourceKey key() { return (ResourceKey) (Object) this.id; } @@ -102,12 +102,12 @@ public Component asComponent() { } @Override - public org.spongepowered.api.advancement.Advancement getRootAdvancement() { + public org.spongepowered.api.advancement.Advancement rootAdvancement() { return this; } @Override - public Optional getBackgroundPath() { + public Optional backgroundPath() { return Optional.ofNullable((ResourceKey) (Object) this.display.getBackground()); } diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/advancements/AdvancementProgressMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/advancements/AdvancementProgressMixin_API.java index 616cfde29e4..750a3074df8 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/advancements/AdvancementProgressMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/advancements/AdvancementProgressMixin_API.java @@ -45,21 +45,21 @@ public abstract class AdvancementProgressMixin_API implements org.spongepowered. @Override public Optional get() { - return this.get(this.getAdvancement().getCriterion()).get().get(); + return this.get(this.advancement().criterion()).get().get(); } @Override public Instant grant() { - return this.get(this.getAdvancement().getCriterion()).get().grant(); + return this.get(this.advancement().criterion()).get().grant(); } @Override public Optional revoke() { - return this.get(this.getAdvancement().getCriterion()).get().revoke(); + return this.get(this.advancement().criterion()).get().revoke(); } @Override - public Advancement getAdvancement() { + public Advancement advancement() { return ((AdvancementProgressBridge) this).bridge$getAdvancement(); } @@ -68,7 +68,7 @@ public Optional get(AdvancementCriterion criterion) { Preconditions.checkNotNull(criterion, "criterion"); final Map map = ((AdvancementProgressBridge) this).bridge$getProgressMap(); Preconditions.checkState(map != null, "progressMap isn't initialized"); - return Optional.ofNullable((CriterionProgress) map.get(criterion.getName())); + return Optional.ofNullable((CriterionProgress) map.get(criterion.name())); } @Override @@ -76,22 +76,22 @@ public Optional get(ScoreAdvancementCriterion criterion) Preconditions.checkNotNull(criterion); final Map map = ((AdvancementProgressBridge) this).bridge$getProgressMap(); Preconditions.checkState(map != null, "progressMap isn't initialized"); - return Optional.ofNullable((ScoreCriterionProgress) map.get(criterion.getName())); + return Optional.ofNullable((ScoreCriterionProgress) map.get(criterion.name())); } @Override public CriterionProgress require(final AdvancementCriterion criterion) { Objects.requireNonNull(criterion, "criterion"); - return this.get(criterion).orElseThrow(() -> new IllegalStateException("The criterion " + criterion.getName() - + " isn't present on the advancement '" + this.getAdvancement() + "'.")); + return this.get(criterion).orElseThrow(() -> new IllegalStateException("The criterion " + criterion.name() + + " isn't present on the advancement '" + this.advancement() + "'.")); } @Override public ScoreCriterionProgress require(final ScoreAdvancementCriterion criterion) { Objects.requireNonNull(criterion, "criterion"); - return this.get(criterion).orElseThrow(() -> new IllegalStateException("The score criterion " + criterion.getName() - + " isn't present on the advancement '" + this.getAdvancement().getKey().toString() + "'.")); + return this.get(criterion).orElseThrow(() -> new IllegalStateException("The score criterion " + criterion.name() + + " isn't present on the advancement '" + this.advancement().key().toString() + "'.")); } } diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/advancements/CriterionMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/advancements/CriterionMixin_API.java index ef4515dd475..00b1b33b662 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/advancements/CriterionMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/advancements/CriterionMixin_API.java @@ -41,12 +41,12 @@ public abstract class CriterionMixin_API implements DefaultedAdvancementCriterio @Shadow @Final private CriterionTriggerInstance trigger; @Override - public String getName() { + public String name() { return ((CriterionBridge) this).bridge$getName(); } @Override - public Optional> getTrigger() { + public Optional> trigger() { return Optional.ofNullable((FilteredTrigger) this.trigger); } } diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/advancements/CriterionProgressMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/advancements/CriterionProgressMixin_API.java index b140fe7902a..71dc0c8341a 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/advancements/CriterionProgressMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/advancements/CriterionProgressMixin_API.java @@ -45,7 +45,7 @@ public abstract class CriterionProgressMixin_API implements org.spongepowered.ap @Shadow @Nullable private Date obtained; @Override - public AdvancementCriterion getCriterion() { + public AdvancementCriterion criterion() { return ((CriterionProgressBridge) this).bridge$getCriterion(); } @@ -65,8 +65,8 @@ public Instant grant() { return this.obtained.toInstant(); } final AdvancementProgress advancementProgress = ((CriterionProgressBridge) this).bridge$getAdvancementProgress(); - final org.spongepowered.api.advancement.Advancement advancement = advancementProgress.getAdvancement(); - ((AdvancementProgressBridge) advancementProgress).bridge$getPlayerAdvancements().award((Advancement) advancement, this.getCriterion().getName()); + final org.spongepowered.api.advancement.Advancement advancement = advancementProgress.advancement(); + ((AdvancementProgressBridge) advancementProgress).bridge$getPlayerAdvancements().award((Advancement) advancement, this.criterion().name()); return this.obtained.toInstant(); } @@ -77,8 +77,8 @@ public Optional revoke() { } final Instant instant = this.obtained.toInstant(); final AdvancementProgress advancementProgress = ((CriterionProgressBridge) this).bridge$getAdvancementProgress(); - final org.spongepowered.api.advancement.Advancement advancement = advancementProgress.getAdvancement(); - ((AdvancementProgressBridge) advancementProgress).bridge$getPlayerAdvancements().revoke((Advancement) advancement, this.getCriterion().getName()); + final org.spongepowered.api.advancement.Advancement advancement = advancementProgress.advancement(); + ((AdvancementProgressBridge) advancementProgress).bridge$getPlayerAdvancements().revoke((Advancement) advancement, this.criterion().name()); return Optional.of(instant); } diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/advancements/CriterionTriggerInstanceMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/advancements/CriterionTriggerInstanceMixin_API.java index 5e47414d93f..4b4c533ae8c 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/advancements/CriterionTriggerInstanceMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/advancements/CriterionTriggerInstanceMixin_API.java @@ -43,14 +43,14 @@ public interface CriterionTriggerInstanceMixin_API extends FilteredTrigger { @Shadow ResourceLocation shadow$getCriterion(); @Override - default Trigger getType() { + default Trigger type() { final CriterionTrigger triggerType = CriteriaTriggers.getCriterion(this.shadow$getCriterion()); Preconditions.checkNotNull(triggerType, "triggerType"); return (Trigger) triggerType; } @Override - default FilteredTriggerConfiguration getConfiguration() { + default FilteredTriggerConfiguration configuration() { return UnknownFilteredTriggerConfiguration.INSTANCE; } } diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/advancements/CriterionTriggerMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/advancements/CriterionTriggerMixin_API.java index b5f924afa1f..52a97fec365 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/advancements/CriterionTriggerMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/advancements/CriterionTriggerMixin_API.java @@ -42,13 +42,13 @@ public interface CriterionTriggerMixin_API getItem() { + public Optional item() { final Item item = this.shadow$asItem(); if (item == Items.AIR) { return Optional.empty(); @@ -73,12 +73,12 @@ public Component asComponent() { @SuppressWarnings("unchecked") @Override - public Collection> getStateProperties() { + public Collection> stateProperties() { return (Collection>) (Object) this.stateDefinition.getProperties(); } @Override - public Optional> getStatePropertyByName(final String name) { + public Optional> statePropertyByName(final String name) { return Optional.ofNullable((StateProperty) this.stateDefinition.getProperty(name)); } diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/client/MinecraftMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/client/MinecraftMixin_API.java index 32123df0907..ff671b2840a 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/client/MinecraftMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/client/MinecraftMixin_API.java @@ -67,12 +67,12 @@ public MinecraftMixin_API(String name) { } @Override - public Optional getPlayer() { + public Optional player() { return Optional.ofNullable((LocalPlayer) this.player); } @Override - public Optional getServer() { + public Optional server() { final MinecraftBridge minecraftBridge = (MinecraftBridge) (this); final IntegratedServer integratedServer = minecraftBridge.bridge$getTemporaryIntegratedServer(); @@ -84,12 +84,12 @@ public Optional getServer() { } @Override - public Optional getWorld() { + public Optional world() { return Optional.ofNullable((ClientWorld) this.level); } @Override - public Optional getConnection() { + public Optional connection() { if (this.pendingConnection == null) { return Optional.empty(); } @@ -97,17 +97,17 @@ public Optional getConnection() { } @Override - public Game getGame() { - return Sponge.getGame(); + public Game game() { + return Sponge.game(); } @Override - public CauseStackManager getCauseStackManager() { + public CauseStackManager causeStackManager() { return PhaseTracker.getCauseStackManager(); } @Override - public ClientScheduler getScheduler() { + public ClientScheduler scheduler() { return this.api$scheduler; } diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/client/multiplayer/ClientPacketListenerMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/client/multiplayer/ClientPacketListenerMixin_API.java index f6265446252..32a9951e640 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/client/multiplayer/ClientPacketListenerMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/client/multiplayer/ClientPacketListenerMixin_API.java @@ -39,7 +39,7 @@ public abstract class ClientPacketListenerMixin_API implements LocalPlayerConnec // @formatter:on @Override - public LocalPlayer getPlayer() { + public LocalPlayer player() { return (LocalPlayer) this.minecraft.player; } } diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/client/network/ClientNetHandlerMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/client/network/ClientNetHandlerMixin_API.java index 290fd5af2b6..a3a0e688301 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/client/network/ClientNetHandlerMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/client/network/ClientNetHandlerMixin_API.java @@ -51,12 +51,12 @@ public void close(final Component reason) { } @Override - public InetSocketAddress getAddress() { + public InetSocketAddress address() { return ((ConnectionBridge) ((ConnectionHolderBridge) this).bridge$getConnection()).bridge$getAddress(); } @Override - public InetSocketAddress getVirtualHost() { + public InetSocketAddress virtualHost() { return ((ConnectionBridge) ((ConnectionHolderBridge) this).bridge$getConnection()).bridge$getVirtualHost(); } } diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/client/server/IntegratedServerMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/client/server/IntegratedServerMixin_API.java index 56e35cb1892..95c4c3546de 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/client/server/IntegratedServerMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/client/server/IntegratedServerMixin_API.java @@ -40,7 +40,7 @@ public abstract class IntegratedServerMixin_API implements LocalServer { // @formatter:on @Override - public Client getClient() { + public Client client() { return (Client) this.minecraft; } } diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/commands/CommandSourceStackMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/commands/CommandSourceStackMixin_API.java index 57b46361501..19dc95216cf 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/commands/CommandSourceStackMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/commands/CommandSourceStackMixin_API.java @@ -50,65 +50,65 @@ public abstract class CommandSourceStackMixin_API implements CommandCause { @Override - public Cause getCause() { + public Cause cause() { return ((CommandSourceStackBridge) this).bridge$getCause(); } @Override - public Subject getSubject() { - return this.getCause().getContext() + public Subject subject() { + return this.cause().context() .get(EventContextKeys.SUBJECT) - .orElseGet(() -> this.getCause().first(Subject.class).orElseGet(Sponge::getSystemSubject)); + .orElseGet(() -> this.cause().first(Subject.class).orElseGet(Sponge::systemSubject)); } @Override - public Audience getAudience() { - return this.getCause().getContext() + public Audience audience() { + return this.cause().context() .get(EventContextKeys.AUDIENCE) - .orElseGet(() -> this.getCause().first(Audience.class).orElseGet(Sponge::getSystemSubject)); + .orElseGet(() -> this.cause().first(Audience.class).orElseGet(Sponge::systemSubject)); } @Override - public Optional getLocation() { - final Cause cause = this.getCause(); - final EventContext eventContext = cause.getContext(); + public Optional location() { + final Cause cause = this.cause(); + final EventContext eventContext = cause.context(); if (eventContext.containsKey(EventContextKeys.LOCATION)) { return eventContext.get(EventContextKeys.LOCATION); } - final Optional optionalLocation = this.getTargetBlock().flatMap(BlockSnapshot::getLocation); + final Optional optionalLocation = this.targetBlock().flatMap(BlockSnapshot::location); if (optionalLocation.isPresent()) { return optionalLocation; } - return cause.first(Locatable.class).map(Locatable::getServerLocation); + return cause.first(Locatable.class).map(Locatable::serverLocation); } @Override - public Optional getRotation() { - final Cause cause = this.getCause(); - final EventContext eventContext = cause.getContext(); + public Optional rotation() { + final Cause cause = this.cause(); + final EventContext eventContext = cause.context(); if (eventContext.containsKey(EventContextKeys.ROTATION)) { return eventContext.get(EventContextKeys.ROTATION); } - return cause.first(Entity.class).map(Entity::getRotation); + return cause.first(Entity.class).map(Entity::rotation); } @Override - public Optional getTargetBlock() { - return Optional.ofNullable(this.getCause().getContext().get(EventContextKeys.BLOCK_TARGET) - .orElseGet(() -> this.getCause().first(BlockSnapshot.class).orElse(null))); + public Optional targetBlock() { + return Optional.ofNullable(this.cause().context().get(EventContextKeys.BLOCK_TARGET) + .orElseGet(() -> this.cause().first(BlockSnapshot.class).orElse(null))); } @Override public void sendMessage(@NonNull final Identified identity, @NonNull final Component message) { - this.getAudience().sendMessage(identity, message); + this.audience().sendMessage(identity, message); } @Override public void sendMessage(@NonNull final Identity identity, @NonNull final Component message) { - this.getAudience().sendMessage(identity, message); + this.audience().sendMessage(identity, message); } } diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/commands/arguments/selector/EntitySelectorMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/commands/arguments/selector/EntitySelectorMixin_API.java index 5ef55d772fd..0aa1e16dd16 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/commands/arguments/selector/EntitySelectorMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/commands/arguments/selector/EntitySelectorMixin_API.java @@ -52,9 +52,9 @@ public abstract class EntitySelectorMixin_API implements Selector { @Override @NonNull public Collection select(@NonNull final ServerLocation location) throws IllegalStateException { - return this.api$select(((MinecraftServer) Sponge.getServer()).createCommandSourceStack() - .withLevel((net.minecraft.server.level.ServerLevel) location.getWorld()) - .withPosition(VecHelper.toVanillaVector3d(location.getPosition()))); + return this.api$select(((MinecraftServer) Sponge.server()).createCommandSourceStack() + .withLevel((net.minecraft.server.level.ServerLevel) location.world()) + .withPosition(VecHelper.toVanillaVector3d(location.position()))); } @Override diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/commands/arguments/selector/EntitySelectorParserMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/commands/arguments/selector/EntitySelectorParserMixin_API.java index 77b8c120eed..96d9897684f 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/commands/arguments/selector/EntitySelectorParserMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/commands/arguments/selector/EntitySelectorParserMixin_API.java @@ -157,24 +157,24 @@ public abstract class EntitySelectorParserMixin_API implements Selector.Builder } @Override - public Selector.@NonNull Builder setLimit(final int limit) { + public Selector.@NonNull Builder limit(final int limit) { this.maxResults = limit; this.shadow$setLimited(limit != Integer.MAX_VALUE); return this; } @Override - public Selector.@NonNull Builder setDistance(@NonNull final Range<@NonNull Double> range) { - Preconditions.checkArgument(range.getMin() == null || range.getMin() >= 0, "min must be non-negative"); - Preconditions.checkArgument(range.getMax() == null || range.getMax() >= 0, "max must be non-negative"); + public Selector.@NonNull Builder distance(@NonNull final Range<@NonNull Double> range) { + Preconditions.checkArgument(range.min() == null || range.min() >= 0, "min must be non-negative"); + Preconditions.checkArgument(range.max() == null || range.max() >= 0, "max must be non-negative"); this.distance = MinMaxBounds_FloatsAccessor.invoker$new( - this.api$floatFromDouble(range.getMin(), Function.identity()), - this.api$floatFromDouble(range.getMax(), Function.identity())); + this.api$floatFromDouble(range.min(), Function.identity()), + this.api$floatFromDouble(range.max(), Function.identity())); return this; } @Override - public Selector.@NonNull Builder setVolume(final org.spongepowered.math.vector.@NonNull Vector3d corner1, + public Selector.@NonNull Builder volume(final org.spongepowered.math.vector.@NonNull Vector3d corner1, final org.spongepowered.math.vector.@NonNull Vector3d corner2) { final org.spongepowered.math.vector.Vector3d minPoint = corner1.min(corner2); final org.spongepowered.math.vector.Vector3d distance = corner1.max(corner2).sub(minPoint); @@ -188,12 +188,12 @@ public abstract class EntitySelectorParserMixin_API implements Selector.Builder } @Override - public Selector.@NonNull Builder setSortAlgorithm(@NonNull final Supplier algorithm) { - return this.setSortAlgorithm(algorithm.get()); + public Selector.@NonNull Builder sortAlgorithm(@NonNull final Supplier algorithm) { + return this.sortAlgorithm(algorithm.get()); } @Override - public Selector.@NonNull Builder setSortAlgorithm(@NonNull final SelectorSortAlgorithm algorithm) { + public Selector.@NonNull Builder sortAlgorithm(@NonNull final SelectorSortAlgorithm algorithm) { Preconditions.checkArgument(algorithm instanceof SpongeSelectorSortAlgorithm, "Must be a SpongeSelectorSortAlgorithm"); this.shadow$setSorted(true); this.order = ((SpongeSelectorSortAlgorithm) algorithm).getSortAlgorithm(); @@ -201,27 +201,27 @@ public abstract class EntitySelectorParserMixin_API implements Selector.Builder } @Override - public Selector.@NonNull Builder advancement(@NonNull final Advancement advancement) { + public Selector.@NonNull Builder addAdvancement(@NonNull final Advancement advancement) { return this.api$advancement(advancement, false); } @Override - public Selector.@NonNull Builder notAdvancement(@NonNull final Advancement advancement) { + public Selector.@NonNull Builder addNotAdvancement(@NonNull final Advancement advancement) { return this.api$advancement(advancement, true); } @Override - public Selector.@NonNull Builder advancementCriterion(@NonNull final Advancement advancement, @NonNull final AdvancementCriterion criterion) { + public Selector.@NonNull Builder addAdvancementCriterion(@NonNull final Advancement advancement, @NonNull final AdvancementCriterion criterion) { return this.api$advancementCriterion(advancement, criterion, false); } @Override - public Selector.@NonNull Builder notAdvancementCriterion(@NonNull final Advancement advancement, @NonNull final AdvancementCriterion criterion) { + public Selector.@NonNull Builder addNotAdvancementCriterion(@NonNull final Advancement advancement, @NonNull final AdvancementCriterion criterion) { return this.api$advancementCriterion(advancement, criterion, true); } @Override - public Selector.@NonNull Builder setDataView(@NonNull final DataView view) { + public Selector.@NonNull Builder dataView(@NonNull final DataView view) { try { // TODO: ensure this works as expected final String json = DataFormats.JSON.get().write(view); @@ -233,59 +233,59 @@ public abstract class EntitySelectorParserMixin_API implements Selector.Builder } @Override - public Selector.@NonNull Builder notEntityType(@NonNull final Supplier<@NonNull EntityType<@NonNull ?>> type) { - return this.notEntityType(type.get()); + public Selector.@NonNull Builder addNotEntityType(@NonNull final Supplier<@NonNull EntityType<@NonNull ?>> type) { + return this.addNotEntityType(type.get()); } @Override - public Selector.@NonNull Builder notEntityType(@NonNull final EntityType<@NonNull ?> type) { + public Selector.@NonNull Builder addNotEntityType(@NonNull final EntityType<@NonNull ?> type) { final ResourceKey key = (ResourceKey) (Object) Registry.ENTITY_TYPE.getKey((net.minecraft.world.entity.EntityType) type); this.api$handle("type", "!" + key.asString()); return this; } @Override - public Selector.@NonNull Builder entityType(@NonNull final Supplier<@NonNull EntityType<@NonNull ?>> type, final boolean inherit) { - return this.entityType(type.get(), inherit); + public Selector.@NonNull Builder addEntityType(@NonNull final Supplier<@NonNull EntityType<@NonNull ?>> type, final boolean inherit) { + return this.addEntityType(type.get(), inherit); } @Override - public Selector.@NonNull Builder entityType(@NonNull final EntityType<@NonNull ?> type, final boolean inherit) { + public Selector.@NonNull Builder addEntityType(@NonNull final EntityType<@NonNull ?> type, final boolean inherit) { final ResourceKey key = (ResourceKey) (Object) Registry.ENTITY_TYPE.getKey((net.minecraft.world.entity.EntityType) type); this.api$handle("type", String.format("%s%s", inherit ? "#" : "", key.asString())); return this; } @Override - public Selector.@NonNull Builder setExperienceLevel(@NonNull final Range<@NonNull Integer> range) { - Preconditions.checkArgument(range.getMin() == null || range.getMin() >= 0, "min must be non-negative"); - Preconditions.checkArgument(range.getMax() == null || range.getMax() >= 0, "max must be non-negative"); - this.level = MinMaxBounds_IntsAccessor.invoker$new(range.getMin(), range.getMax()); + public Selector.@NonNull Builder experienceLevel(@NonNull final Range<@NonNull Integer> range) { + Preconditions.checkArgument(range.min() == null || range.min() >= 0, "min must be non-negative"); + Preconditions.checkArgument(range.max() == null || range.max() >= 0, "max must be non-negative"); + this.level = MinMaxBounds_IntsAccessor.invoker$new(range.min(), range.max()); this.shadow$setIncludesEntities(false); return this; } @Override - public Selector.@NonNull Builder gameMode(@NonNull final Supplier mode) { - return this.gameMode(mode.get()); + public Selector.@NonNull Builder addGameMode(@NonNull final Supplier mode) { + return this.addGameMode(mode.get()); } @Override - public Selector.@NonNull Builder gameMode(@NonNull final GameMode mode) { - final ResourceKey key = Sponge.getGame().registries().registry(RegistryTypes.GAME_MODE).valueKey(mode); - this.api$handle("gamemode", key.getValue(), Tristate.FALSE); + public Selector.@NonNull Builder addGameMode(@NonNull final GameMode mode) { + final ResourceKey key = Sponge.game().registries().registry(RegistryTypes.GAME_MODE).valueKey(mode); + this.api$handle("gamemode", key.value(), Tristate.FALSE); return this; } @Override - public Selector.@NonNull Builder notGameMode(@NonNull final Supplier mode) { - return this.notGameMode(mode.get()); + public Selector.@NonNull Builder addNotGameMode(@NonNull final Supplier mode) { + return this.addNotGameMode(mode.get()); } @Override - public Selector.@NonNull Builder notGameMode(@NonNull final GameMode mode) { - final ResourceKey key = Sponge.getGame().registries().registry(RegistryTypes.GAME_MODE).valueKey(mode); - this.api$handle("gamemode", key.getValue(), Tristate.TRUE); + public Selector.@NonNull Builder addNotGameMode(@NonNull final GameMode mode) { + final ResourceKey key = Sponge.game().registries().registry(RegistryTypes.GAME_MODE).valueKey(mode); + this.api$handle("gamemode", key.value(), Tristate.TRUE); return this; } @@ -302,65 +302,65 @@ public abstract class EntitySelectorParserMixin_API implements Selector.Builder } @Override - public Selector.@NonNull Builder team(@NonNull final Team team) { - this.api$handle("team", team.getName(), Tristate.FALSE); + public Selector.@NonNull Builder addTeam(@NonNull final Team team) { + this.api$handle("team", team.name(), Tristate.FALSE); return this; } @Override - public Selector.@NonNull Builder notTeam(@NonNull final Team team) { - this.api$handle("team", team.getName(), Tristate.TRUE); + public Selector.@NonNull Builder addNotTeam(@NonNull final Team team) { + this.api$handle("team", team.name(), Tristate.TRUE); return this; } @Override - public Selector.@NonNull Builder name(@NonNull final String name) { + public Selector.@NonNull Builder addName(@NonNull final String name) { this.api$handle("name", name, Tristate.FALSE); return this; } @Override - public Selector.@NonNull Builder notName(@NonNull final String name) { + public Selector.@NonNull Builder addNotName(@NonNull final String name) { this.api$handle("name", name, Tristate.TRUE); return this; } @Override - public Selector.@NonNull Builder score(@NonNull final Score score, @NonNull final Range<@NonNull Integer> range) { + public Selector.@NonNull Builder addScore(@NonNull final Score score, @NonNull final Range<@NonNull Integer> range) { if (this.api$scores == null) { this.api$scores = new HashMap<>(); } // TODO: Check this is right. - this.api$scores.put(score.getName().toString(), range); + this.api$scores.put(score.name().toString(), range); return this; } @Override - public Selector.@NonNull Builder tag(@NonNull final String tag) { + public Selector.@NonNull Builder addTag(@NonNull final String tag) { this.api$handle("tag", tag, Tristate.FALSE); return this; } @Override - public Selector.@NonNull Builder notTag(@NonNull final String tag) { + public Selector.@NonNull Builder addNotTag(@NonNull final String tag) { this.api$handle("tag", tag, Tristate.TRUE); return this; } @Override - public Selector.@NonNull Builder setPitch(@NonNull final Range<@NonNull Double> range) { + public Selector.@NonNull Builder pitch(@NonNull final Range<@NonNull Double> range) { this.rotX = this.api$getWrappedBounds(range); return this; } @Override - public Selector.@NonNull Builder setYaw(@NonNull final Range<@NonNull Double> range) { + public Selector.@NonNull Builder yaw(@NonNull final Range<@NonNull Double> range) { this.rotY = this.api$getWrappedBounds(range); return this; } @Override - public Selector.@NonNull Builder filter(@NonNull final Predicate filter) { + public Selector.@NonNull Builder addFilter(@NonNull final Predicate filter) { this.shadow$addPredicate((Predicate) (Object) filter); return this; } @@ -440,7 +440,7 @@ public Selector build() throws IllegalStateException { if (this.api$advancement == null) { this.api$advancement = new Object2BooleanOpenHashMap<>(); } - this.api$advancement.put(advancement.getKey().asString(), inverted); + this.api$advancement.put(advancement.key().asString(), inverted); return this; } @@ -449,7 +449,7 @@ public Selector build() throws IllegalStateException { if (this.api$criterion == null) { this.api$criterion = new HashMap<>(); } - this.api$criterion.computeIfAbsent(advancement.getKey().toString(), k -> new Object2BooleanOpenHashMap<>()).put(criterion.getName(), inverted); + this.api$criterion.computeIfAbsent(advancement.key().toString(), k -> new Object2BooleanOpenHashMap<>()).put(criterion.name(), inverted); return this; } @@ -475,8 +475,8 @@ public Selector build() throws IllegalStateException { private WrappedMinMaxBounds api$getWrappedBounds(final Range<@NonNull Double> range) { - final Float a = this.api$floatFromDouble(range.getMin(), Mth::wrapDegrees); - final Float b = this.api$floatFromDouble(range.getMax(), Mth::wrapDegrees); + final Float a = this.api$floatFromDouble(range.min(), Mth::wrapDegrees); + final Float b = this.api$floatFromDouble(range.max(), Mth::wrapDegrees); if (a == null) { return new WrappedMinMaxBounds(null, b); } @@ -490,13 +490,13 @@ public Selector build() throws IllegalStateException { } private String api$intRangeToStringRepresentation(@NonNull final Range<@NonNull Integer> range) { - if (range.getMin() != null && range.getMax() != null && range.getMin().intValue() == range.getMax().intValue()) { - return String.valueOf(range.getMax().intValue()); + if (range.min() != null && range.max() != null && range.min().intValue() == range.max().intValue()) { + return String.valueOf(range.max().intValue()); } return String.format("%s..%s", - range.getMin() == null ? "" : String.valueOf(range.getMin().intValue()), - range.getMax() == null ? "" : String.valueOf(range.getMax().intValue())); + range.min() == null ? "" : String.valueOf(range.min().intValue()), + range.max() == null ? "" : String.valueOf(range.max().intValue())); } } diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/core/particles/ParticleTypeMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/core/particles/ParticleTypeMixin_API.java index 1ec3ee39c6d..a0fa45f5202 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/core/particles/ParticleTypeMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/core/particles/ParticleTypeMixin_API.java @@ -40,7 +40,7 @@ public abstract class ParticleTypeMixin_API implements org.spongepowered.api.eff @SuppressWarnings("unchecked") @Override - public Optional getDefaultOption(ParticleOption option) { + public Optional defaultOption(ParticleOption option) { if (this.api$defaultOptions == null) { this.api$defaultOptions = ParticleOptionUtil.generateDefaultsForNamed((ParticleType) (Object) this); } @@ -48,7 +48,7 @@ public Optional getDefaultOption(ParticleOption option) { } @Override - public Map, Object> getDefaultOptions() { + public Map, Object> defaultOptions() { if (this.api$defaultOptions == null) { this.api$defaultOptions = ParticleOptionUtil.generateDefaultsForNamed((ParticleType) (Object) this); } diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/map/MapDecorationMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/map/MapDecorationMixin_API.java index e60c2adf623..d46667f21f6 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/map/MapDecorationMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/map/MapDecorationMixin_API.java @@ -55,13 +55,13 @@ public abstract class MapDecorationMixin_API implements org.spongepowered.api.ma // @formatter:on @Override - public MapDecorationType getType() { + public MapDecorationType type() { return SpongeMapDecorationType.toSpongeType(this.type) .orElseThrow(() -> new IllegalStateException("Tried to get MapDecoration type but it didn't exist in Sponge's registries! Have MC Decoration types been missed?")); } @Override - public Vector2i getPosition() { + public Vector2i position() { return new Vector2i(this.x, this.y); } @@ -81,7 +81,7 @@ public void setRotation(MapDecorationOrientation dir) { } @Override - public MapDecorationOrientation getRotation() { + public MapDecorationOrientation rotation() { int rot = MapUtil.normalizeDecorationOrientation(this.rot); return MapUtil.getMapRotById(rot); } @@ -92,7 +92,7 @@ public boolean isPersistent() { } @Override - public int getContentVersion() { + public int contentVersion() { return 1; } diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/map/MapInfoMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/map/MapInfoMixin_API.java index aea18afe5aa..752cf303b1c 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/map/MapInfoMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/map/MapInfoMixin_API.java @@ -60,27 +60,27 @@ public MapInfoMixin_API(String name) { @Override public boolean isLinked(final ItemStack itemStack) { - return itemStack.getType() == ItemTypes.FILLED_MAP.get() + return itemStack.type() == ItemTypes.FILLED_MAP.get() && itemStack.get(Keys.MAP_INFO).isPresent() && itemStack.get(Keys.MAP_INFO).get() == this; } @Override public void addBannerDecoration(final ServerLocation bannerLocation) throws IllegalArgumentException { - final BlockType bannerType = bannerLocation.getBlock().getType(); + final BlockType bannerType = bannerLocation.block().type(); Preconditions.checkArgument(bannerType instanceof BannerBlock, "Location must have a banner!"); - this.toggleBanner((LevelAccessor) bannerLocation.getWorld(), new BlockPos(bannerLocation.getBlockX(), bannerLocation.getBlockY(), bannerLocation.getBlockZ())); + this.toggleBanner((LevelAccessor) bannerLocation.world(), new BlockPos(bannerLocation.blockX(), bannerLocation.blockY(), bannerLocation.blockZ())); this.setDirty(); } @Override - public UUID getUniqueId() { + public UUID uniqueId() { return ((MapItemSavedDataBridge) this).bridge$getUniqueId(); } @Override - public int getContentVersion() { + public int contentVersion() { return 1; } diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/network/protocol/status/ServerStatusMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/network/protocol/status/ServerStatusMixin_API.java index 722efccc376..6a589ff33d6 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/network/protocol/status/ServerStatusMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/network/protocol/status/ServerStatusMixin_API.java @@ -51,7 +51,7 @@ public abstract class ServerStatusMixin_API implements ClientPingServerEvent.Res @Override - public Component getDescription() { + public Component description() { return ((ServerStatusBridge) this).bridge$getDescription(); } @@ -62,7 +62,7 @@ public void setDescription(final Component description) { } @Override - public Optional getPlayers() { + public Optional players() { return Optional.ofNullable((org.spongepowered.api.event.server.ClientPingServerEvent.Response.Players) this.players); } @@ -80,12 +80,12 @@ public void setHidePlayers(final boolean hide) { } @Override - public MinecraftVersion getVersion() { + public MinecraftVersion version() { return (MinecraftVersion) this.version; } @Override - public Optional getFavicon() { + public Optional favicon() { return Optional.ofNullable(((ServerStatusBridge) this).bridge$getFavicon()); } diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/network/protocol/status/ServerStatus_PlayersMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/network/protocol/status/ServerStatus_PlayersMixin_API.java index e0c9e2ac523..f253c179a38 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/network/protocol/status/ServerStatus_PlayersMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/network/protocol/status/ServerStatus_PlayersMixin_API.java @@ -50,7 +50,7 @@ public abstract class ServerStatus_PlayersMixin_API implements ClientPingServerE @Nullable private List profiles; @Override - public int getOnline() { + public int online() { return this.numPlayers; } @@ -60,7 +60,7 @@ public void setOnline(final int online) { } @Override - public int getMax() { + public int max() { return this.maxPlayers; } @@ -70,7 +70,7 @@ public void setMax(final int max) { } @Override - public List getProfiles() { + public List profiles() { if (this.profiles == null) { this.profiles = new ArrayList<>(); } diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/network/protocol/status/ServerStatus_VersionMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/network/protocol/status/ServerStatus_VersionMixin_API.java index 4c690600270..4b705a600cd 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/network/protocol/status/ServerStatus_VersionMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/network/protocol/status/ServerStatus_VersionMixin_API.java @@ -43,7 +43,7 @@ public abstract class ServerStatus_VersionMixin_API implements MinecraftVersion, // @formatter:on @Override - public String getName() { + public String name() { return this.name; } @@ -53,7 +53,7 @@ public boolean isLegacy() { } @Override - public OptionalInt getDataVersion() { + public OptionalInt dataVersion() { return OptionalInt.empty(); } diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/server/MinecraftServerMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/server/MinecraftServerMixin_API.java index b4237d3b1ae..7d8f2ea3e29 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/server/MinecraftServerMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/server/MinecraftServerMixin_API.java @@ -161,18 +161,18 @@ public MinecraftServerMixin_API(final String name) { @Override public @NonNull Iterable audiences() { if (this.audiences == null) { - this.audiences = Iterables.concat((List) this.shadow$getPlayerList().getPlayers(), Collections.singleton(Sponge.getGame().getSystemSubject())); + this.audiences = Iterables.concat((List) this.shadow$getPlayerList().getPlayers(), Collections.singleton(Sponge.game().systemSubject())); } return this.audiences; } @Override - public ChunkLayout getChunkLayout() { + public ChunkLayout chunkLayout() { return SpongeChunkLayout.INSTANCE; } @Override - public Audience getBroadcastAudience() { + public Audience broadcastAudience() { if (this.api$broadcastAudience == null) { this.api$broadcastAudience = this; } @@ -186,7 +186,7 @@ public void setBroadcastAudience(final Audience channel) { } @Override - public Optional getBoundAddress() { + public Optional boundAddress() { return Optional.empty(); } @@ -211,12 +211,12 @@ public boolean isHardcoreModeEnabled() { } @Override - public Difficulty getDifficulty() { + public Difficulty difficulty() { return (Difficulty) (Object) this.worldData.getDifficulty(); } @Override - public GameMode getGameMode() { + public GameMode gameMode() { return (GameMode) (Object) this.worldData.getGameType(); } @@ -251,17 +251,17 @@ public boolean isMultiWorldEnabled() { } @Override - public UserManager getUserManager() { + public UserManager userManager() { return this.api$userManager; } - @Override public TeleportHelper getTeleportHelper() { + @Override public TeleportHelper teleportHelper() { return this.api$teleportHelper; } @Override @SuppressWarnings({"unchecked", "rawtypes"}) - public Collection getOnlinePlayers() { + public Collection onlinePlayers() { if (this.shadow$getPlayerList() == null || this.shadow$getPlayerList().getPlayers() == null) { return ImmutableList.of(); } @@ -269,7 +269,7 @@ public Collection getOnlinePlayers() { } @Override - public Optional getPlayer(final UUID uniqueId) { + public Optional player(final UUID uniqueId) { Preconditions.checkNotNull(uniqueId); if (this.shadow$getPlayerList() == null) { return Optional.empty(); @@ -278,7 +278,7 @@ public Optional getPlayer(final UUID uniqueId) { } @Override - public Optional getPlayer(final String name) { + public Optional player(final String name) { if (this.shadow$getPlayerList() == null) { return Optional.empty(); } @@ -286,12 +286,12 @@ public Optional getPlayer(final String name) { } @Override - public Component getMOTD() { + public Component motd() { return SpongeAdventure.legacySection(this.shadow$getMotd()); } @Override - public int getMaxPlayers() { + public int maxPlayers() { if (this.shadow$getPlayerList() == null) { return 0; } @@ -299,23 +299,23 @@ public int getMaxPlayers() { } @Override - public int getRunningTimeTicks() { + public int runningTimeTicks() { return this.shadow$getTickCount(); } @Override - public double getTicksPerSecond() { + public double ticksPerSecond() { // Cap at 20 TPS - return 1000 / Math.max(50, this.getAverageTickTime()); + return 1000 / Math.max(50, this.averageTickTime()); } @Override - public double getAverageTickTime() { + public double averageTickTime() { return Mth.average(this.tickTimes) / 1000000; } @Override - public int getTargetTicksPerSecond() { + public int targetTicksPerSecond() { return 20; } @@ -327,7 +327,7 @@ public void shutdown() { @Override public void shutdown(final Component kickMessage) { Preconditions.checkNotNull(kickMessage); - for (final ServerPlayer player : this.getOnlinePlayers()) { + for (final ServerPlayer player : this.onlinePlayers()) { player.kick(kickMessage); } @@ -335,7 +335,7 @@ public void shutdown(final Component kickMessage) { } @Override - public GameProfileManager getGameProfileManager() { + public GameProfileManager gameProfileManager() { if (this.api$profileManager == null) { this.api$profileManager = new SpongeGameProfileManager(this); } @@ -344,16 +344,16 @@ public GameProfileManager getGameProfileManager() { } @Override - public SpongeCommandManager getCommandManager() { + public SpongeCommandManager commandManager() { return ((CommandsBridge) this.shadow$getCommands()).bridge$commandManager(); } - public Optional server$getResourcePack() { + public Optional server$resourcePack() { return Optional.ofNullable(((MinecraftServerBridge) this).bridge$getResourcePack()); } @Override - public Optional getServerScoreboard() { + public Optional serverScoreboard() { if (this.api$scoreboard == null) { final ServerLevel world = SpongeCommon.getServer().overworld(); if (world == null) { @@ -366,7 +366,7 @@ public Optional getServerScoreboard() { } @Intrinsic - public int server$getPlayerIdleTimeout() { + public int server$playerIdleTimeout() { return this.shadow$getPlayerIdleTimeout(); } @@ -376,17 +376,17 @@ public Optional getServerScoreboard() { } @Override - public Game getGame() { - return Sponge.getGame(); + public Game game() { + return Sponge.game(); } @Override - public CauseStackManager getCauseStackManager() { + public CauseStackManager causeStackManager() { return PhaseTracker.getCauseStackManager(); } @Override - public ServerScheduler getScheduler() { + public ServerScheduler scheduler() { return this.api$scheduler; } @@ -420,7 +420,7 @@ public void sendMessage(final Identity identity, final Component message, final } @Override - public ServiceProvider.ServerScoped getServiceProvider() { + public ServiceProvider.ServerScoped serviceProvider() { return ((MinecraftServerBridge) this).bridge$getServiceProvider(); } @@ -434,7 +434,7 @@ public RegistryHolder registries() { return this.api$registryHolder; } @Override - public MapStorage getMapStorage() { + public MapStorage mapStorage() { return this.api$mapStorage; } } diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/server/ServerScoreboardMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/server/ServerScoreboardMixin_API.java index 46b73a396b8..454866a8e0a 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/server/ServerScoreboardMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/server/ServerScoreboardMixin_API.java @@ -53,11 +53,10 @@ import java.util.stream.Collectors; @Mixin(ServerScoreboard.class) -@Implements(@Interface(iface = Scoreboard.class, prefix = "scoreboard$")) public abstract class ServerScoreboardMixin_API implements Scoreboard { - @Intrinsic - public Optional scoreboard$getObjective(final String name) { + @Override + public Optional objective(final String name) { Objects.requireNonNull(name); final net.minecraft.world.scores.Objective objective = ((ScoreboardAccessor) this).accessor$objectivesByName().get(name); @@ -65,8 +64,8 @@ public abstract class ServerScoreboardMixin_API implements Scoreboard { } @Override - public Optional getObjective(final DisplaySlot slot) { - final MappedRegistry registry = (MappedRegistry) (Object) Sponge.getGame().registries().registry(RegistryTypes.DISPLAY_SLOT); + public Optional objective(final DisplaySlot slot) { + final MappedRegistry registry = (MappedRegistry) (Object) Sponge.game().registries().registry(RegistryTypes.DISPLAY_SLOT); final net.minecraft.world.scores.Objective objective = ((ScoreboardAccessor) this).accessor$displayObjectives()[registry.getId(slot)]; if (objective != null) { return Optional.of(((ObjectiveBridge) objective).bridge$getSpongeObjective()); @@ -75,7 +74,7 @@ public Optional getObjective(final DisplaySlot slot) { } @Override - public Set getObjectivesByCriterion(final Criterion criterion) { + public Set objectivesByCriterion(final Criterion criterion) { if (((ScoreboardAccessor) this).accessor$objectivesByCriteria().containsKey(criterion)) { return ((ScoreboardAccessor) this).accessor$objectivesByCriteria().get(criterion).stream() .map(objective -> ((ObjectiveBridge) objective).bridge$getSpongeObjective()).collect(Collectors.toSet()); @@ -98,7 +97,7 @@ public void updateDisplaySlot(@Nullable final Objective objective, final Display } @Override - public Set getObjectives() { + public Set objectives() { return ((ScoreboardAccessor) this).accessor$objectivesByName().values().stream() .map(objective -> ((ObjectiveBridge) objective).bridge$getSpongeObjective()) .collect(Collectors.toSet()); @@ -112,21 +111,21 @@ public void removeObjective(final Objective objective) { } @Override - public Set getScores() { + public Set scores() { final Set scores = new HashSet<>(); for (final net.minecraft.world.scores.Objective objective: ((ScoreboardAccessor) this).accessor$objectivesByName().values()) { - scores.addAll(((ObjectiveBridge) objective).bridge$getSpongeObjective().getScores().values()); + scores.addAll(((ObjectiveBridge) objective).bridge$getSpongeObjective().scores().values()); } return scores; } @Override - public Set getScores(final Component name) { + public Set scores(final Component name) { Objects.requireNonNull(name); final Set scores = new HashSet<>(); for (final net.minecraft.world.scores.Objective objective: ((ScoreboardAccessor) this).accessor$objectivesByName().values()) { - ((ObjectiveBridge) objective).bridge$getSpongeObjective().getScore(name).ifPresent(scores::add); + ((ObjectiveBridge) objective).bridge$getSpongeObjective().score(name).ifPresent(scores::add); } return scores; } @@ -137,12 +136,12 @@ public void removeScores(final Component name) { for (final net.minecraft.world.scores.Objective objective: ((ScoreboardAccessor) this).accessor$objectivesByName().values()) { final SpongeObjective spongeObjective = ((ObjectiveBridge) objective).bridge$getSpongeObjective(); - spongeObjective.getScore(name).ifPresent(spongeObjective::removeScore); + spongeObjective.score(name).ifPresent(spongeObjective::removeScore); } } @Intrinsic - public Optional scoreboard$getTeam(final String name) { + public Optional team(final String name) { Objects.requireNonNull(name); return Optional.ofNullable((Team) ((ScoreboardAccessor) this).accessor$teamsByName().get(name)); @@ -155,13 +154,13 @@ public void registerTeam(final Team team) throws IllegalArgumentException { ((ServerScoreboardBridge) this).bridge$registerTeam(team); } - @Intrinsic - public Set scoreboard$getTeams() { + @Override + public Set teams() { return new HashSet<>((Collection) (Object) ((ScoreboardAccessor) this).accessor$teamsByName().values()); } @Override - public Optional getMemberTeam(final Component member) { + public Optional memberTeam(final Component member) { Objects.requireNonNull(member); return Optional.ofNullable((Team) ((ScoreboardAccessor) this).accessor$teamsByPlayer().get(SpongeAdventure.legacySection(member))); diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/server/dedicated/DedicatedServerMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/server/dedicated/DedicatedServerMixin_API.java index 1b622c9a7b5..b8dabfc2edf 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/server/dedicated/DedicatedServerMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/server/dedicated/DedicatedServerMixin_API.java @@ -50,7 +50,7 @@ public DedicatedServerMixin_API(final String name) { } @Override - public Optional getBoundAddress() { + public Optional boundAddress() { if (this.shadow$getServerIp() == null) { return Optional.empty(); } diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/server/level/ServerLevelMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/server/level/ServerLevelMixin_API.java index b21934f6057..c1dda397519 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/server/level/ServerLevelMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/server/level/ServerLevelMixin_API.java @@ -43,16 +43,10 @@ import net.minecraft.world.level.chunk.LevelChunk; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.storage.LevelResource; -import org.jetbrains.annotations.NotNull; import org.spongepowered.api.ResourceKey; import org.spongepowered.api.Server; import org.spongepowered.api.block.BlockSnapshot; import org.spongepowered.api.block.BlockType; -import org.spongepowered.api.data.DataHolder; -import org.spongepowered.api.data.DataProvider; -import org.spongepowered.api.data.DataTransactionResult; -import org.spongepowered.api.data.Key; -import org.spongepowered.api.data.value.Value; import org.spongepowered.api.entity.living.player.server.ServerPlayer; import org.spongepowered.api.fluid.FluidType; import org.spongepowered.api.registry.RegistryHolder; @@ -76,7 +70,6 @@ import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.common.accessor.world.entity.raid.RaidsAccessor; import org.spongepowered.common.bridge.server.level.ServerLevelBridge; -import org.spongepowered.common.data.SpongeDataManager; import org.spongepowered.common.data.holder.SpongeLocationBaseDataHolder; import org.spongepowered.common.mixin.api.mcp.world.level.LevelMixin_API; import org.spongepowered.common.util.MissingImplementationException; @@ -87,22 +80,18 @@ import java.io.IOException; import java.nio.file.Path; -import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.Objects; import java.util.Optional; import java.util.UUID; -import java.util.function.Supplier; -import java.util.stream.Stream; import javax.annotation.Nonnull; import javax.annotation.Nullable; @SuppressWarnings({"unchecked", "rawtypes"}) @Mixin(ServerLevel.class) -@Implements(@Interface(iface = org.spongepowered.api.world.server.ServerWorld.class, prefix = "serverWorld$")) public abstract class ServerLevelMixin_API extends LevelMixin_API implements org.spongepowered.api.world.server.ServerWorld, SpongeLocationBaseDataHolder { // @formatter:off @@ -122,8 +111,8 @@ public abstract class ServerLevelMixin_API extends LevelMixin_API getPlayers() { + public Collection players() { return Collections.unmodifiableCollection((Collection) (Collection) ImmutableList.copyOf(this.shadow$players())); } @Override - public Collection getEntities() { + public Collection entities() { return (Collection< org.spongepowered.api.entity.Entity>) (Object) Collections.unmodifiableCollection(this.entitiesById.values()); } @Override - public Collection getRaids() { + public Collection raids() { return (Collection) (Collection) ((RaidsAccessor) this.shadow$getRaids()).accessor$raidMap().values(); } @Override - public Optional getRaidAt(final Vector3i blockPosition) { + public Optional raidAt(final Vector3i blockPosition) { return Optional.ofNullable((org.spongepowered.api.raid.Raid) this.shadow$getRaidAt(VecHelper.toBlockPos(Objects.requireNonNull(blockPosition, "blockPosition")))); } @@ -251,7 +240,7 @@ public boolean containsBlock(final int x, final int y, final int z) { // EntityVolume @Override - public Optional getEntity(final UUID uniqueId) { + public Optional entity(final UUID uniqueId) { return Optional.ofNullable((org.spongepowered.api.entity.Entity) this.shadow$getEntity(Objects.requireNonNull(uniqueId, "uniqueId"))); } @@ -265,12 +254,12 @@ public void removeBlockEntity(final int x, final int y, final int z) { // UpdateableVolume @Override - public ScheduledUpdateList getScheduledBlockUpdates() { + public ScheduledUpdateList scheduledBlockUpdates() { return (ScheduledUpdateList) this.blockTicks; } @Override - public ScheduledUpdateList getScheduledFluidUpdates() { + public ScheduledUpdateList scheduledFluidUpdates() { return (ScheduledUpdateList) this.liquidTicks; } diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/server/level/ServerPlayerMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/server/level/ServerPlayerMixin_API.java index 9e94ea0ec6c..a5f1e41db23 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/server/level/ServerPlayerMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/server/level/ServerPlayerMixin_API.java @@ -122,7 +122,7 @@ public abstract class ServerPlayerMixin_API extends PlayerMixin_API implements S @Nullable private WorldBorder api$worldBorder; @Override - public ServerWorld getWorld() { + public ServerWorld world() { return (ServerWorld) this.shadow$getLevel(); } @@ -148,7 +148,7 @@ public void spawnParticles(final ParticleEffect particleEffect, final Vector3d p } @Override - public User getUser() { + public User user() { return ((ServerPlayerBridge) this).bridge$getUser(); } @@ -161,8 +161,8 @@ public boolean isOnline() { } @Override - public GameProfile getProfile() { - return ((ServerPlayerBridge) this).bridge$getUser().getProfile(); + public GameProfile profile() { + return ((ServerPlayerBridge) this).bridge$getUser().profile(); } @Override @@ -183,7 +183,7 @@ public void spawnParticles(final ParticleEffect particleEffect, final Vector3d p } @Override - public ServerPlayerConnection getConnection() { + public ServerPlayerConnection connection() { return (ServerPlayerConnection) this.connection; } @@ -198,8 +198,8 @@ public String getIpAddress() { } @Override - public String getIdentifier() { - return ((ServerPlayerBridge) this).bridge$getUser().getIdentifier(); + public String identifier() { + return ((ServerPlayerBridge) this).bridge$getUser().identifier(); } @Override @@ -212,12 +212,12 @@ public void setScoreboard(final Scoreboard scoreboard) { } @Override - public Component getTeamRepresentation() { + public Component teamRepresentation() { return SpongeAdventure.asAdventure(this.shadow$getName()); } @Override - public Scoreboard getScoreboard() { + public Scoreboard scoreboard() { return ((ServerPlayerBridge) this).bridge$getScoreboard(); } @@ -243,17 +243,17 @@ public void stopMusicDisc(final Vector3i position) { @Override public void sendResourcePack(final ResourcePack pack) { - this.connection.send(new ClientboundResourcePackPacket(((SpongeResourcePack) Objects.requireNonNull(pack, "pack")).getUrlString(), pack.getHash().orElse(""))); + this.connection.send(new ClientboundResourcePackPacket(((SpongeResourcePack) Objects.requireNonNull(pack, "pack")).getUrlString(), pack.hash().orElse(""))); } @Override - public TabList getTabList() { + public TabList tabList() { return this.api$tabList; } @Override public boolean hasPlayedBefore() { - final Instant instant = ((SpongeServer) this.shadow$getServer()).getPlayerDataManager().getFirstJoined(this.getUniqueId()).get(); + final Instant instant = ((SpongeServer) this.shadow$getServer()).getPlayerDataManager().getFirstJoined(this.uniqueId()).get(); final Instant toTheMinute = instant.truncatedTo(ChronoUnit.MINUTES); final Instant now = Instant.now().truncatedTo(ChronoUnit.MINUTES); final Duration timeSinceFirstJoined = Duration.of(now.minusMillis(toTheMinute.toEpochMilli()).toEpochMilli(), ChronoUnit.MINUTES); @@ -283,7 +283,7 @@ public boolean respawn() { } @Override - public PlayerChatRouter getChatRouter() { + public PlayerChatRouter chatRouter() { if (this.api$chatRouter == null) { this.api$chatRouter = (player, message) -> ((Server) this.server).sendMessage(player, Component.translatable("chat.type.text", SpongeAdventure.asAdventure(this.shadow$getDisplayName()), message)); @@ -301,31 +301,31 @@ public PlayerChatEvent simulateChat(final Component message, final Cause cause) Objects.requireNonNull(message, "message"); Objects.requireNonNull(cause, "cause"); - final PlayerChatRouter originalRouter = this.getChatRouter(); + final PlayerChatRouter originalRouter = this.chatRouter(); final PlayerChatEvent event = SpongeEventFactory.createPlayerChatEvent(cause, originalRouter, Optional.of(originalRouter), message, message); if (!SpongeCommon.postEvent(event)) { - event.getChatRouter().ifPresent(channel -> channel.chat(this, event.getMessage())); + event.chatRouter().ifPresent(channel -> channel.chat(this, event.message())); } return event; } @Override - public Optional getWorldBorder() { + public Optional worldBorder() { return Optional.ofNullable(this.api$worldBorder); } @Override - public CooldownTracker getCooldownTracker() { + public CooldownTracker cooldownTracker() { return (CooldownTracker) this.shadow$getCooldowns(); } @Override - public AdvancementProgress getProgress(final Advancement advancement) { + public AdvancementProgress progress(final Advancement advancement) { return (AdvancementProgress) this.advancements.getOrStartProgress((net.minecraft.advancements.Advancement) Objects.requireNonNull(advancement, "advancement")); } @Override - public Collection getUnlockedAdvancementTrees() { + public Collection unlockedAdvancementTrees() { if (this.impl$isFake) { return Collections.emptyList(); } @@ -340,7 +340,7 @@ public void setWorldBorder(final @Nullable WorldBorder border) { if (this.api$worldBorder == border) { return; //do not fire an event since nothing would have changed } - if (!SpongeCommon.postEvent(SpongeEventFactory.createChangeWorldBorderEventTargetPlayer(PhaseTracker.getCauseStackManager().getCurrentCause(), + if (!SpongeCommon.postEvent(SpongeEventFactory.createChangeWorldBorderEventTargetPlayer(PhaseTracker.getCauseStackManager().currentCause(), Optional.ofNullable(this.api$worldBorder), this, Optional.ofNullable(border)))) { if (this.api$worldBorder != null) { //is the world border about to be unset? ((WorldBorderAccessor) this.api$worldBorder).accessor$listeners().remove( @@ -501,7 +501,7 @@ public void openBook(@NonNull final Book book) { } @Override - public @NonNull Locale getLocale() { + public @NonNull Locale locale() { return ((ServerPlayerBridge) this).bridge$getLanguage(); } diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/server/network/ServerGamePacketListenerImplMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/server/network/ServerGamePacketListenerImplMixin_API.java index 4c03e73c2d9..970e3f5bae0 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/server/network/ServerGamePacketListenerImplMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/server/network/ServerGamePacketListenerImplMixin_API.java @@ -52,7 +52,7 @@ public abstract class ServerGamePacketListenerImplMixin_API implements ServerPla // @formatter:on @Override - public GameProfile getProfile() { + public GameProfile profile() { return SpongeGameProfile.of(this.player.getGameProfile()); } @@ -68,22 +68,22 @@ public void close(final Component reason) { } @Override - public ServerPlayer getPlayer() { + public ServerPlayer player() { return (ServerPlayer) this.player; } @Override - public InetSocketAddress getAddress() { + public InetSocketAddress address() { return ((ConnectionBridge) this.connection).bridge$getAddress(); } @Override - public InetSocketAddress getVirtualHost() { + public InetSocketAddress virtualHost() { return ((ConnectionBridge) this.connection).bridge$getVirtualHost(); } @Override - public int getLatency() { + public int latency() { return this.player.latency; } } diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/server/network/ServerLoginPacketListenerImplMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/server/network/ServerLoginPacketListenerImplMixin_API.java index 262a61ed560..dbac9be4c9e 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/server/network/ServerLoginPacketListenerImplMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/server/network/ServerLoginPacketListenerImplMixin_API.java @@ -51,7 +51,7 @@ public abstract class ServerLoginPacketListenerImplMixin_API implements ServerSi // @formatter:on @Override - public GameProfile getProfile() { + public GameProfile profile() { return SpongeGameProfile.of(this.gameProfile); } @@ -67,12 +67,12 @@ public void close(final Component reason) { } @Override - public InetSocketAddress getAddress() { + public InetSocketAddress address() { return ((ConnectionBridge) this.connection).bridge$getAddress(); } @Override - public InetSocketAddress getVirtualHost() { + public InetSocketAddress virtualHost() { return ((ConnectionBridge) this.connection).bridge$getVirtualHost(); } } diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/server/players/BanListEntryMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/server/players/BanListEntryMixin_API.java index 4472ae4e594..107e0560fcd 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/server/players/BanListEntryMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/server/players/BanListEntryMixin_API.java @@ -45,22 +45,22 @@ public abstract class BanListEntryMixin_API extends StoredUserEntryMixin_API< // @formatter:on @Override - public Optional getReason() { + public Optional reason() { return ((BanListEntryBridge) this).bridge$getReason(); } @Override - public Instant getCreationDate() { + public Instant creationDate() { return this.created.toInstant(); } @Override - public Optional getBanSource() { + public Optional banSource() { return ((BanListEntryBridge) this).bridge$getSource(); } @Override - public Optional getExpirationDate() { + public Optional expirationDate() { return Optional.ofNullable(this.expires == null ? null : this.expires.toInstant()); } } diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/server/players/GameProfileCacheMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/server/players/GameProfileCacheMixin_API.java index d7c8e0219ab..78888f3c30e 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/server/players/GameProfileCacheMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/server/players/GameProfileCacheMixin_API.java @@ -65,11 +65,11 @@ public abstract class GameProfileCacheMixin_API implements GameProfileCache { @Override public boolean remove(final GameProfile profile) { Objects.requireNonNull(profile, "profile"); - final UUID uniqueId = profile.getUniqueId(); + final UUID uniqueId = profile.uniqueId(); final GameProfileCache_GameProfileInfoAccessor entry = this.profilesByUUID.remove(uniqueId); if (entry != null) { - if (profile.getName().isPresent()) { - this.profilesByName.remove(profile.getName().get().toLowerCase(Locale.ROOT)); + if (profile.name().isPresent()) { + this.profilesByName.remove(profile.name().get().toLowerCase(Locale.ROOT)); } // Only return true if the entry wasn't expired return entry.invoker$getExpirationDate().getTime() >= System.currentTimeMillis(); @@ -100,7 +100,7 @@ public Collection removeIf(final Predicate filter) { final boolean isExpired = entry.invoker$getExpirationDate().getTime() < System.currentTimeMillis(); if (isExpired || filter.test(profile)) { it.remove(); - profile.getName().ifPresent(name -> this.profilesByName.remove(name, entry)); + profile.name().ifPresent(name -> this.profilesByName.remove(name, entry)); if (!isExpired) { result.add(profile); } @@ -116,13 +116,13 @@ public void clear() { } @Override - public Optional getById(final UUID uniqueId) { + public Optional byId(final UUID uniqueId) { Objects.requireNonNull(uniqueId, "uniqueId"); return Optional.ofNullable(this.shadow$get(uniqueId)).map(SpongeGameProfile::of); } @Override - public Map> getByIds(final Iterable uniqueIds) { + public Map> byIds(final Iterable uniqueIds) { Objects.requireNonNull(uniqueIds, "uniqueIds"); final Map> result = new HashMap<>(); for (final UUID uniqueId : uniqueIds) { @@ -132,7 +132,7 @@ public Map> getByIds(final Iterable uniqueIds) } @Override - public Optional getByName(final String name) { + public Optional byName(final String name) { Objects.requireNonNull(name, "name"); @Nullable GameProfileCache_GameProfileInfoAccessor entry = this.profilesByName.get(name.toLowerCase(Locale.ROOT)); @@ -147,11 +147,11 @@ public Optional getByName(final String name) { } @Override - public Map> getByNames(final Iterable names) { + public Map> byNames(final Iterable names) { Objects.requireNonNull(names, "names"); final Map> result = Maps.newHashMap(); for (final String name : names) { - result.put(name, this.getByName(name)); + result.put(name, this.byName(name)); } return ImmutableMap.copyOf(result); } diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/server/players/IpBanListEntryMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/server/players/IpBanListEntryMixin_API.java index 0ecc627b99d..527c40d8032 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/server/players/IpBanListEntryMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/server/players/IpBanListEntryMixin_API.java @@ -37,12 +37,12 @@ public abstract class IpBanListEntryMixin_API extends BanListEntryMixin_API implements Ban.IP { @Override - public BanType getType() { + public BanType type() { return BanTypes.IP.get(); } @Override - public InetAddress getAddress() { + public InetAddress address() { return ((IpBanListEntryBridge) this).bridge$getAddress(); } } diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/server/players/UserBanListEntryMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/server/players/UserBanListEntryMixin_API.java index c557c91762c..8c9725a21f7 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/server/players/UserBanListEntryMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/server/players/UserBanListEntryMixin_API.java @@ -36,12 +36,12 @@ public abstract class UserBanListEntryMixin_API extends BanListEntryMixin_API implements Ban.Profile { @Override - public BanType getType() { + public BanType type() { return BanTypes.PROFILE.get(); } @Override - public GameProfile getProfile() { + public GameProfile profile() { return SpongeGameProfile.of(this.shadow$getUser()); } } diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/server/rcon/RconConsoleSourceMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/server/rcon/RconConsoleSourceMixin_API.java index 159658bc91c..b5ba46816b8 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/server/rcon/RconConsoleSourceMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/server/rcon/RconConsoleSourceMixin_API.java @@ -32,7 +32,7 @@ public abstract class RconConsoleSourceMixin_API implements Subject { @Override - public String getIdentifier() { + public String identifier() { // RCon no longer has an identifier on the class, but it passes this to its CommandSource return "Recon"; } diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/server/rcon/thread/RconClientMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/server/rcon/thread/RconClientMixin_API.java index 3615b921639..ade9bcf79fa 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/server/rcon/thread/RconClientMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/server/rcon/thread/RconClientMixin_API.java @@ -48,12 +48,12 @@ protected RconClientMixin_API(final String threadName) { } @Override - public InetSocketAddress getAddress() { + public InetSocketAddress address() { return (InetSocketAddress) this.client.getRemoteSocketAddress(); } @Override - public InetSocketAddress getVirtualHost() { + public InetSocketAddress virtualHost() { return (InetSocketAddress) this.client.getLocalSocketAddress(); } diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/sounds/SoundEventMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/sounds/SoundEventMixin_API.java index bf3c8bf464a..1e540517031 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/sounds/SoundEventMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/sounds/SoundEventMixin_API.java @@ -44,9 +44,4 @@ public ResourceKey key() { return (ResourceKey) (Object) this.location; } - @Override - public ResourceKey getKey() { - return (ResourceKey) (Object) this.location; - } - } diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/state/PropertyMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/state/PropertyMixin_API.java index b5a32a41bcf..27356cd1b64 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/state/PropertyMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/state/PropertyMixin_API.java @@ -39,12 +39,11 @@ /** * This is retained solely for simplification not having to perform any - * lookups to the {@link BlockPropertyIdProvider#getIdFor(IProperty)}. + * lookups to the {@link BlockPropertyIdProvider#idFor(IProperty)}. * * @param The type of comparable */ @Mixin(value = Property.class) -@Implements(@Interface(iface = StateProperty.class, prefix = "stateProperty$")) public abstract class PropertyMixin_API> implements StateProperty { // @formatter:off @@ -53,24 +52,24 @@ public abstract class PropertyMixin_API> implements Stat @Shadow public abstract String shadow$getName(); // @formatter:on - @Intrinsic - public String stateProperty$getName() { + @Override + public String name() { return this.shadow$getName(); } - @Intrinsic - public Collection stateProperty$getPossibleValues() { + @Override + public Collection possibleValues() { return this.shadow$getPossibleValues(); } - @Intrinsic - public Class stateProperty$getValueClass() { + @Override + public Class valueClass() { return this.shadow$getValueClass(); } @Override - public Predicate getPredicate() { - return Functional.predicateIn(this.getPossibleValues()); + public Predicate predicate() { + return Functional.predicateIn(this.possibleValues()); } @SuppressWarnings("unchecked") diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/stats/StatMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/stats/StatMixin_API.java index a0470c46f38..e0521d502e0 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/stats/StatMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/stats/StatMixin_API.java @@ -44,12 +44,12 @@ public abstract class StatMixin_API implements Statistic { // @formatter:on @Override - public Optional getCriterion() { + public Optional criterion() { return Optional.empty(); } @Override - public NumberFormat getFormat() { + public NumberFormat format() { return ((StatFormatterBridge) this.formatter).bridge$getFormat(); } } diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/stats/StatTypeMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/stats/StatTypeMixin_API.java index 59364c663a2..324e392c08f 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/stats/StatTypeMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/stats/StatTypeMixin_API.java @@ -45,7 +45,7 @@ public abstract class StatTypeMixin_API implements StatisticCategory { @Override @SuppressWarnings({"unchecked"}) - public Collection getStatistics() { + public Collection statistics() { return Collections.unmodifiableCollection((Collection) (Object) this.map.values()); } } diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/util/DamageSourceMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/util/DamageSourceMixin_API.java index ed467434cc1..012100ebd7a 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/util/DamageSourceMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/util/DamageSourceMixin_API.java @@ -79,12 +79,12 @@ public boolean isScaledByDifficulty() { } @Override - public double getExhaustion() { + public double exhaustion() { return this.shadow$getFoodExhaustion(); } @Override - public DamageType getType() { + public DamageType type() { return ((DamageSourceBridge) this).bridge$getDamageType(); } diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/util/EntityDamageSourceMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/util/EntityDamageSourceMixin_API.java index f5534486406..40fc6399899 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/util/EntityDamageSourceMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/util/EntityDamageSourceMixin_API.java @@ -40,7 +40,7 @@ public abstract class EntityDamageSourceMixin_API extends DamageSourceMixin_API // @formatter:on @Override - public Entity getSource() { + public Entity source() { return ((Entity) this.entity); } diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/util/IndirectEntityDamageSourceMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/util/IndirectEntityDamageSourceMixin_API.java index f03ccf9bea4..8356188d6a8 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/util/IndirectEntityDamageSourceMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/util/IndirectEntityDamageSourceMixin_API.java @@ -40,7 +40,7 @@ public abstract class IndirectEntityDamageSourceMixin_API extends EntityDamageSo // @formatter:on @Override - public org.spongepowered.api.entity.Entity getIndirectSource() { + public org.spongepowered.api.entity.Entity indirectSource() { return (org.spongepowered.api.entity.Entity) this.owner; } diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/IWorldGenerationBaseReaderMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/IWorldGenerationBaseReaderMixin_API.java index b1e4f0a4070..39ac0cc394e 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/IWorldGenerationBaseReaderMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/IWorldGenerationBaseReaderMixin_API.java @@ -48,9 +48,9 @@ default boolean hasBlockState(final int x, final int y, final int z, final Predi return this.shadow$isStateAtPosition(new BlockPos(x, y, z), state -> predicate.test((BlockState) state)); } -// TODO this conflicts with IWorldReaderMixin_API#getHeight +// TODO this conflicts with IWorldReaderMixin_API#height // @Override -// default int getHeight(final HeightType type, final int x, final int z) { +// default int height(final HeightType type, final int x, final int z) { // return this.shadow$getHeightmapPos((Heightmap.Type) (Object) type, new BlockPos(x, 0, z)).getY(); // } } diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/effect/MobEffectInstanceMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/effect/MobEffectInstanceMixin_API.java index 35b1b5642e3..b4dacd16c9a 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/effect/MobEffectInstanceMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/effect/MobEffectInstanceMixin_API.java @@ -40,7 +40,6 @@ import org.spongepowered.common.util.Constants; @Mixin(net.minecraft.world.effect.MobEffectInstance.class) -@Implements(@Interface(iface = PotionEffect.class, prefix = "potionEffect$")) public abstract class MobEffectInstanceMixin_API implements PotionEffect { // @formatter:off @@ -52,17 +51,17 @@ public abstract class MobEffectInstanceMixin_API implements PotionEffect { // @formatter:on @Override - public PotionEffectType getType() { + public PotionEffectType type() { return (PotionEffectType) this.effect; } - @Intrinsic - public int potionEffect$getDuration() { + @Override + public int duration() { return this.duration; } - @Intrinsic - public int potionEffect$getAmplifier() { + @Override + public int amplifier() { return this.amplifier; } @@ -77,16 +76,16 @@ public boolean showsParticles() { } @Override - public int getContentVersion() { + public int contentVersion() { return Constants.Sponge.Potion.CURRENT_VERSION; } @Override public DataContainer toContainer() { - final ResourceKey key = (ResourceKey) (Object) Registry.MOB_EFFECT.getKey((MobEffect) this.getType()); + final ResourceKey key = (ResourceKey) (Object) Registry.MOB_EFFECT.getKey((MobEffect) this.type()); return DataContainer.createNew() - .set(Queries.CONTENT_VERSION, this.getContentVersion()) + .set(Queries.CONTENT_VERSION, this.contentVersion()) .set(Constants.Item.Potions.POTION_TYPE, key) .set(Constants.Item.Potions.POTION_DURATION, this.duration) .set(Constants.Item.Potions.POTION_AMPLIFIER, this.amplifier) diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/EntityMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/EntityMixin_API.java index 7c0509eafbd..90b44f0825b 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/EntityMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/EntityMixin_API.java @@ -111,23 +111,23 @@ public abstract class EntityMixin_API implements org.spongepowered.api.entity.En // @formatter:on @Override - public Random getRandom() { + public Random random() { return this.random; } @Override - public Vector3d getPosition() { + public Vector3d position() { return new Vector3d(this.shadow$getX(), this.shadow$getY(), this.shadow$getZ()); } @Override - public World getWorld() { + public World world() { return (World) this.level; } @Override - public ServerLocation getLocation() { - return ServerLocation.of((org.spongepowered.api.world.server.ServerWorld) this.shadow$getCommandSenderWorld(), this.getPosition()); + public ServerLocation location() { + return ServerLocation.of((org.spongepowered.api.world.server.ServerWorld) this.shadow$getCommandSenderWorld(), this.position()); } @Override @@ -146,7 +146,7 @@ public boolean setLocationAndRotation(ServerLocation location, Vector3d rotation } @Override - public Vector3d getScale() { + public Vector3d scale() { return Vector3d.ONE; } @@ -156,8 +156,8 @@ public void setScale(final Vector3d scale) { } @Override - public Transform getTransform() { - return Transform.of(this.getPosition(), this.getRotation(), this.getScale()); + public Transform transform() { + return Transform.of(this.position(), this.rotation(), this.scale()); } @Override @@ -166,10 +166,10 @@ public boolean setTransform(final Transform transform) { return false; } Preconditions.checkNotNull(transform, "The transform cannot be null!"); - final Vector3d position = transform.getPosition(); + final Vector3d position = transform.position(); this.shadow$setPos(position.getX(), position.getY(), position.getZ()); - this.setRotation(transform.getRotation()); - this.setScale(transform.getScale()); + this.setRotation(transform.rotation()); + this.setScale(transform.scale()); if (!((WorldBridge) this.shadow$getCommandSenderWorld()).bridge$isFake()) { ((ServerLevel) this.shadow$getCommandSenderWorld()).updateChunkPos((Entity) (Object) this); } @@ -185,7 +185,7 @@ public boolean transferToWorld(final org.spongepowered.api.world.server.ServerWo } @Override - public Vector3d getRotation() { + public Vector3d rotation() { return new Vector3d(this.xRot, this.yRot, 0); } @@ -198,11 +198,11 @@ public void setRotation(final Vector3d rotation) { } if (((Entity) (Object) this) instanceof ServerPlayer && ((ServerPlayer) (Entity) (Object) this).connection != null) { // Force an update, this also set the rotation in this entity - ((ServerPlayer) (Entity) (Object) this).connection.teleport(this.getPosition().getX(), this.getPosition().getY(), - this.getPosition().getZ(), (float) rotation.getY(), (float) rotation.getX(), EnumSet.noneOf(ClientboundPlayerPositionPacket.RelativeArgument.class)); + ((ServerPlayer) (Entity) (Object) this).connection.teleport(this.position().getX(), this.position().getY(), + this.position().getZ(), (float) rotation.getY(), (float) rotation.getX(), EnumSet.noneOf(ClientboundPlayerPositionPacket.RelativeArgument.class)); } else { if (!this.shadow$getCommandSenderWorld().isClientSide) { // We can't set the rotation update on client worlds. - ((ServerLevelBridge) this.getWorld()).bridge$addEntityRotationUpdate((Entity) (Object) this, rotation); + ((ServerLevelBridge) this.world()).bridge$addEntityRotationUpdate((Entity) (Object) this, rotation); } // Let the entity tracker do its job, this just updates the variables @@ -211,7 +211,7 @@ public void setRotation(final Vector3d rotation) { } @Override - public Optional getBoundingBox() { + public Optional boundingBox() { final net.minecraft.world.phys.AABB boundingBox = this.shadow$getBoundingBox(); if (boundingBox == null) { return Optional.empty(); @@ -250,47 +250,46 @@ public boolean damage(final double damage, final org.spongepowered.api.event.cau return this.shadow$hurt((DamageSource) damageSource, (float) damage); } - @Override - public EntityType getType() { + public EntityType type() { return (EntityType) this.type; } @Override - public UUID getUniqueId() { + public UUID uniqueId() { return this.uuid; } @Override - public int getContentVersion() { + public int contentVersion() { return 1; } @Override public DataContainer toContainer() { - final Transform transform = this.getTransform(); + final Transform transform = this.transform(); final CompoundTag compound = new CompoundTag(); this.shadow$saveAsPassenger(compound); final DataContainer unsafeNbt = NBTTranslator.INSTANCE.translateFrom(compound); final DataContainer container = DataContainer.createNew() - .set(Queries.CONTENT_VERSION, this.getContentVersion()) + .set(Queries.CONTENT_VERSION, this.contentVersion()) .set(Constants.Entity.CLASS, this.getClass().getName()) - .set(Queries.WORLD_KEY, ((org.spongepowered.api.world.server.ServerWorld) this.getWorld()).getKey().getFormatted()) + .set(Queries.WORLD_KEY, ((org.spongepowered.api.world.server.ServerWorld) this.world()).key().formatted()) .createView(Constants.Sponge.SNAPSHOT_WORLD_POSITION) - .set(Queries.POSITION_X, transform.getPosition().getX()) - .set(Queries.POSITION_Y, transform.getPosition().getY()) - .set(Queries.POSITION_Z, transform.getPosition().getZ()) - .getContainer() + .set(Queries.POSITION_X, transform.position().getX()) + .set(Queries.POSITION_Y, transform.position().getY()) + .set(Queries.POSITION_Z, transform.position().getZ()) + .container() .createView(Constants.Entity.ROTATION) - .set(Queries.POSITION_X, transform.getRotation().getX()) - .set(Queries.POSITION_Y, transform.getRotation().getY()) - .set(Queries.POSITION_Z, transform.getRotation().getZ()) - .getContainer() + .set(Queries.POSITION_X, transform.rotation().getX()) + .set(Queries.POSITION_Y, transform.rotation().getY()) + .set(Queries.POSITION_Z, transform.rotation().getZ()) + .container() .createView(Constants.Entity.SCALE) - .set(Queries.POSITION_X, transform.getScale().getX()) - .set(Queries.POSITION_Y, transform.getScale().getY()) - .set(Queries.POSITION_Z, transform.getScale().getZ()) - .getContainer() - .set(Constants.Entity.TYPE, Registry.ENTITY_TYPE.getKey((net.minecraft.world.entity.EntityType) this.getType())) + .set(Queries.POSITION_X, transform.scale().getX()) + .set(Queries.POSITION_Y, transform.scale().getY()) + .set(Queries.POSITION_Z, transform.scale().getZ()) + .container() + .set(Constants.Entity.TYPE, Registry.ENTITY_TYPE.getKey((net.minecraft.world.entity.EntityType) this.type())) .set(Constants.Sponge.UNSAFE_NBT, unsafeNbt); return container; } @@ -339,8 +338,8 @@ public EntityArchetype createArchetype() { @Override public HoverEvent asHoverEvent(final UnaryOperator op) { - final ResourceLocation entityTypeKey = Registry.ENTITY_TYPE.getKey((net.minecraft.world.entity.EntityType) this.getType()); - return HoverEvent.showEntity(op.apply(HoverEvent.ShowEntity.of((Key) (Object) entityTypeKey, this.getUniqueId(), this.displayName().get()))); + final ResourceLocation entityTypeKey = Registry.ENTITY_TYPE.getKey((net.minecraft.world.entity.EntityType) this.type()); + return HoverEvent.showEntity(op.apply(HoverEvent.ShowEntity.of((Key) (Object) entityTypeKey, this.uniqueId(), this.displayName().get()))); } protected Set> api$getVanillaValues() { diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/LivingEntityMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/LivingEntityMixin_API.java index f548a21e605..bd8d623fab2 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/LivingEntityMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/LivingEntityMixin_API.java @@ -57,12 +57,12 @@ public abstract class LivingEntityMixin_API extends EntityMixin_API implements L @Shadow public abstract boolean addEffect(MobEffectInstance p_195064_1_); @Override - public Component getTeamRepresentation() { + public Component teamRepresentation() { return Component.text(this.shadow$getUUID().toString()); } @Override - public Optional getAttribute(final AttributeType type) { + public Optional attribute(final AttributeType type) { Preconditions.checkNotNull(type, "AttributeType cannot be null"); return Optional.ofNullable((Attribute) this.shadow$getAttribute((net.minecraft.world.entity.ai.attributes.Attribute) type)); } diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/MobMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/MobMixin_API.java index 6a36a25ef84..ab8f7e8296b 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/MobMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/MobMixin_API.java @@ -48,7 +48,7 @@ public abstract class MobMixin_API extends LivingEntityMixin_API implements Agen // @formatter:on @Override - public Optional> getGoal(GoalExecutorType type) { + public Optional> goal(GoalExecutorType type) { if (GoalExecutorTypes.NORMAL.get().equals(type)) { return Optional.of((GoalExecutor) this.goalSelector); } else if (GoalExecutorTypes.TARGET.get().equals(type)) { diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/ai/attributes/AttributeInstanceMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/ai/attributes/AttributeInstanceMixin_API.java index 3f41b787207..55c9d676d68 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/ai/attributes/AttributeInstanceMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/ai/attributes/AttributeInstanceMixin_API.java @@ -60,17 +60,17 @@ public abstract class AttributeInstanceMixin_API implements Attribute { // @formatter:on @Override - public AttributeType getType() { + public AttributeType type() { return (AttributeType) this.shadow$getAttribute(); } - @Intrinsic - public double attribute$getBaseValue() { + @Override + public double baseValue() { return this.shadow$getBaseValue(); } - @Intrinsic - public double attribute$getValue() { + @Override + public double value() { return this.shadow$getValue(); } @@ -80,12 +80,12 @@ public AttributeType getType() { } @Override - public Collection getModifiers() { + public Collection modifiers() { return (Collection) this.shadow$getModifiers(); } @Override - public Collection getModifiers(final AttributeOperation operation) { + public Collection modifiers(final AttributeOperation operation) { return (Collection) this.shadow$getModifiers((net.minecraft.world.entity.ai.attributes.AttributeModifier.Operation) (Object) Objects.requireNonNull(operation, "operation")); } @@ -95,7 +95,7 @@ public boolean hasModifier(final AttributeModifier modifier) { } @Override - public Optional getModifier(final UUID uniqueId) { + public Optional modifier(final UUID uniqueId) { return Optional.ofNullable((AttributeModifier) this.shadow$getModifier(Objects.requireNonNull(uniqueId, "uniqueId"))); } diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/ai/attributes/AttributeMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/ai/attributes/AttributeMixin_API.java index a708dadd4d5..ecff6eee129 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/ai/attributes/AttributeMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/ai/attributes/AttributeMixin_API.java @@ -33,7 +33,6 @@ import org.spongepowered.asm.mixin.Shadow; @Mixin(Attribute.class) -@Implements(@Interface(iface = AttributeType.class, prefix = "attributeType$")) public abstract class AttributeMixin_API implements AttributeType { // @formatter:off @@ -41,8 +40,8 @@ public abstract class AttributeMixin_API implements AttributeType { @Shadow public abstract double shadow$sanitizeValue(double value); // @formatter:on - @Intrinsic - public double attributeType$getDefaultValue() { + @Override + public double defaultValue() { return this.shadow$getDefaultValue(); } diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/ai/attributes/AttributeModifierMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/ai/attributes/AttributeModifierMixin_API.java index b75d7fcc612..09d7cbcbad5 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/ai/attributes/AttributeModifierMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/ai/attributes/AttributeModifierMixin_API.java @@ -35,7 +35,6 @@ import java.util.UUID; @Mixin(net.minecraft.world.entity.ai.attributes.AttributeModifier.class) -@Implements(@Interface(iface = AttributeModifier.class, prefix = "attributeModifier$")) public abstract class AttributeModifierMixin_API implements AttributeModifier { // @formatter:off @@ -45,23 +44,23 @@ public abstract class AttributeModifierMixin_API implements AttributeModifier { @Shadow public abstract UUID shadow$getId(); // @formatter:on - @Intrinsic - public String attributeModifier$getName() { + @Override + public String name() { return this.shadow$getName(); } @Override - public AttributeOperation getOperation() { + public AttributeOperation operation() { return (AttributeOperation) (Object) this.shadow$getOperation(); } - @Intrinsic - public double attributeModifier$getAmount() { + @Override + public double amount() { return this.shadow$getAmount(); } @Override - public UUID getUniqueId() { + public UUID uniqueId() { return this.shadow$getId(); } diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/ai/attributes/RangedAttributeMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/ai/attributes/RangedAttributeMixin_API.java index dc36d508bd8..367d45e754f 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/ai/attributes/RangedAttributeMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/ai/attributes/RangedAttributeMixin_API.java @@ -39,12 +39,12 @@ public abstract class RangedAttributeMixin_API implements RangedAttributeType { // @formatter:on @Override - public double getMinimumValue() { + public double minimumValue() { return this.minValue; } @Override - public double getMaximumValue() { + public double maximumValue() { return this.maxValue; } } diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/ai/goal/AvoidEntityGoalMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/ai/goal/AvoidEntityGoalMixin_API.java index 76b4d0902ba..3aed8f07c02 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/ai/goal/AvoidEntityGoalMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/ai/goal/AvoidEntityGoalMixin_API.java @@ -50,7 +50,7 @@ public abstract class AvoidEntityGoalMixin_API extends GoalMixin_API i // @formatter:on @Override - public Predicate getTargetSelector() { + public Predicate targetSelector() { final Predicate predicate = ((TargetingConditionsAccessor) this.avoidEntityTargeting).accessor$selector(); return (Predicate) (Object) (predicate == null ? AvoidEntityGoalMixin_API.ALWAYS_TRUE : predicate); } @@ -62,7 +62,7 @@ public AvoidLivingGoal setTargetSelector(Predicate predicate) { } @Override - public float getSearchDistance() { + public float searchDistance() { return this.maxDist; } @@ -73,7 +73,7 @@ public AvoidLivingGoal setSearchDistance(float distance) { } @Override - public double getCloseRangeSpeed() { + public double closeRangeSpeed() { return this.sprintSpeedModifier; } @@ -84,7 +84,7 @@ public AvoidLivingGoal setCloseRangeSpeed(double speed) { } @Override - public double getFarRangeSpeed() { + public double farRangeSpeed() { return this.walkSpeedModifier; } diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/ai/goal/FloatGoalMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/ai/goal/FloatGoalMixin_API.java index d0a118dcad2..dd1b897cfc6 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/ai/goal/FloatGoalMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/ai/goal/FloatGoalMixin_API.java @@ -40,7 +40,7 @@ public abstract class FloatGoalMixin_API implements SwimGoal { } @Override - public float getSwimChance() { + public float swimChance() { return this.api$swimChance; } diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/ai/goal/GoalMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/ai/goal/GoalMixin_API.java index 5d1e8e5c98a..09f97dcbe39 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/ai/goal/GoalMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/ai/goal/GoalMixin_API.java @@ -45,12 +45,12 @@ public abstract class GoalMixin_API implements org.spongepowere // @formatter:on @Override - public GoalType getType() { + public GoalType type() { return ((GoalBridge) this).bridge$getType(); } @Override - public Optional> getExecutor() { + public Optional> executor() { return (Optional>) (Optional) ((GoalBridge) this).bridge$getGoalExecutor(); } diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/ai/goal/GoalSelectorMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/ai/goal/GoalSelectorMixin_API.java index b8fa239401e..7d3acdd7add 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/ai/goal/GoalSelectorMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/ai/goal/GoalSelectorMixin_API.java @@ -53,12 +53,12 @@ public abstract class GoalSelectorMixin_API implements GoalExec @SuppressWarnings("unchecked") @Override - public O getOwner() { + public O owner() { return (O) ((GoalSelectorBridge) this).bridge$getOwner(); } @Override - public GoalExecutorType getType() { + public GoalExecutorType type() { return ((GoalSelectorBridge) this).bridge$getType(); } @@ -81,16 +81,16 @@ public GoalExecutor removeGoals(final GoalType type) { } @Override - public List> getTasksByType(final GoalType type) { + public List> tasksByType(final GoalType type) { final ImmutableList.Builder> tasks = ImmutableList.builder(); this.availableGoals.stream().map(WrappedGoal::getGoal).map(Goal.class::cast) - .filter(goal -> goal.getType() == type) + .filter(goal -> goal.type() == type) .forEach(tasks::add); return tasks.build(); } @Override - public List> getTasks() { + public List> tasks() { final ImmutableList.Builder> tasks = ImmutableList.builder(); this.availableGoals.stream().map(WrappedGoal::getGoal).map(Goal.class::cast).forEach(tasks::add); return tasks.build(); diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/ai/goal/LookAtPlayerGoalMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/ai/goal/LookAtPlayerGoalMixin_API.java index f9d1306d75b..5f48e7da1f5 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/ai/goal/LookAtPlayerGoalMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/ai/goal/LookAtPlayerGoalMixin_API.java @@ -44,7 +44,7 @@ public abstract class LookAtPlayerGoalMixin_API extends Goal implements LookAtGo // @formatter:on @Override - public Class getWatchedClass() { + public Class watchedClass() { return (Class) this.lookAtType; } @@ -55,7 +55,7 @@ public LookAtGoal setWatchedClass(Class watchedClass) { } @Override - public float getMaxDistance() { + public float maxDistance() { return this.lookDistance; } @@ -66,7 +66,7 @@ public LookAtGoal setMaxDistance(float maxDistance) { } @Override - public float getChance() { + public float chance() { return this.probability; } diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/ai/goal/MeleeAttackGoalMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/ai/goal/MeleeAttackGoalMixin_API.java index 163110abb01..891f3bcb9c9 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/ai/goal/MeleeAttackGoalMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/ai/goal/MeleeAttackGoalMixin_API.java @@ -40,7 +40,7 @@ public abstract class MeleeAttackGoalMixin_API implements AttackLivingGoal { // @formatter:on @Override - public double getSpeed() { + public double speed() { return this.speedModifier; } diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/ai/goal/RandomStrollGoalMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/ai/goal/RandomStrollGoalMixin_API.java index 01b94cf9747..0dc5b5c54c3 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/ai/goal/RandomStrollGoalMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/ai/goal/RandomStrollGoalMixin_API.java @@ -40,7 +40,7 @@ public abstract class RandomStrollGoalMixin_API extends GoalMixin_API // @formatter:on @Override - public double getSpeed() { + public double speed() { return this.speedModifier; } @@ -51,7 +51,7 @@ public RandomWalkingGoal setSpeed(double speed) { } @Override - public int getExecutionChance() { + public int executionChance() { return this.interval; } diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/ai/goal/RangedAttackGoalMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/ai/goal/RangedAttackGoalMixin_API.java index 635dc69b184..efe2ec632a2 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/ai/goal/RangedAttackGoalMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/ai/goal/RangedAttackGoalMixin_API.java @@ -42,7 +42,7 @@ public abstract class RangedAttackGoalMixin_API implements RangedAttackAgainstAg // @formatter:on @Override - public double getMoveSpeed() { + public double moveSpeed() { return this.speedModifier; } @@ -53,7 +53,7 @@ public RangedAttackAgainstAgentGoal setMoveSpeed(final double speed) { } @Override - public int getDelayBetweenAttacks() { + public int delayBetweenAttacks() { return this.attackIntervalMax; } @@ -64,7 +64,7 @@ public RangedAttackAgainstAgentGoal setDelayBetweenAttacks(final int delay) { } @Override - public float getAttackRadius() { + public float attackRadius() { return this.attackRadius; } diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/ai/goal/RunAroundLikeCrazyGoalMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/ai/goal/RunAroundLikeCrazyGoalMixin_API.java index a5a81438020..f8d98ecf0b3 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/ai/goal/RunAroundLikeCrazyGoalMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/ai/goal/RunAroundLikeCrazyGoalMixin_API.java @@ -39,7 +39,7 @@ public abstract class RunAroundLikeCrazyGoalMixin_API extends Goal implements Ru // @formatter:on @Override - public double getSpeed() { + public double speed() { return this.speedModifier; } diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/ai/goal/target/NearestAttackableTargetGoalMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/ai/goal/target/NearestAttackableTargetGoalMixin_API.java index 2e99e8bd463..00a2e690460 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/ai/goal/target/NearestAttackableTargetGoalMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/ai/goal/target/NearestAttackableTargetGoalMixin_API.java @@ -50,7 +50,7 @@ public abstract class NearestAttackableTargetGoalMixin_API extends TargetGoalMix // @formatter:on @Override - public Class getTargetClass() { + public Class targetClass() { return (Class) this.targetType; } @@ -61,7 +61,7 @@ public FindNearestAttackableTargetGoal setTargetClass(Class ta } @Override - public int getChance() { + public int chance() { return this.randomInterval; } @@ -78,7 +78,7 @@ public FindNearestAttackableTargetGoal filter(Predicate predicate) { } @Override - public Predicate getFilter() { + public Predicate filter() { final Predicate predicate = ((TargetingConditionsAccessor) this.targetConditions).accessor$selector(); return (Predicate) (Object) (predicate == null ? NearestAttackableTargetGoalMixin_API.ALWAYS_TRUE : predicate); } diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/animal/AnimalMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/animal/AnimalMixin_API.java index 06262d60185..44b41089f01 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/animal/AnimalMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/animal/AnimalMixin_API.java @@ -24,15 +24,24 @@ */ package org.spongepowered.common.mixin.api.mcp.world.entity.animal; +import net.minecraft.server.level.ServerLevel; import org.spongepowered.api.data.value.Value; import org.spongepowered.api.entity.living.animal.Animal; +import org.spongepowered.api.item.inventory.ItemStack; import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.common.mixin.api.mcp.world.entity.AgableMobMixin_API; import java.util.Set; @Mixin(net.minecraft.world.entity.animal.Animal.class) public abstract class AnimalMixin_API extends AgableMobMixin_API implements Animal { + // @formatter: off + @Shadow public abstract boolean shadow$isFood(net.minecraft.world.item.ItemStack var1); + @Shadow public abstract boolean shadow$canMate(net.minecraft.world.entity.animal.Animal var1); + @Shadow public abstract void shadow$spawnChildFromBreeding(ServerLevel var1, net.minecraft.world.entity.animal.Animal var2); + // @formatter: on + @Override protected Set> api$getVanillaValues() { final Set> values = super.api$getVanillaValues(); @@ -44,4 +53,20 @@ public abstract class AnimalMixin_API extends AgableMobMixin_API implements Anim return values; } + + @Override + public boolean isFood(final ItemStack stack) { + return this.shadow$isFood((net.minecraft.world.item.ItemStack) (Object) stack); + } + + @Override + public boolean canBreedWith(final Animal other) { + return this.shadow$canMate((net.minecraft.world.entity.animal.Animal) other); + } + + @Override + public void breedWith(final Animal animal) { + this.shadow$spawnChildFromBreeding((ServerLevel) this.world(), (net.minecraft.world.entity.animal.Animal) animal); + } + } diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/animal/CatMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/animal/CatMixin_API.java index 8074c9d2413..503313e499b 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/animal/CatMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/animal/CatMixin_API.java @@ -41,7 +41,7 @@ public abstract class CatMixin_API extends TamableAnimalMixin_API implements Cat values.add(this.sitting().asImmutable()); // Meow - values.add(this.type().asImmutable()); + values.add(this.catType().asImmutable()); values.add(this.lyingDown().asImmutable()); values.add(this.relaxed().asImmutable()); values.add(this.collarColor().asImmutable()); diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/animal/FoxMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/animal/FoxMixin_API.java index 77bc7e89d21..3c58d07b9c6 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/animal/FoxMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/animal/FoxMixin_API.java @@ -26,7 +26,6 @@ import org.spongepowered.api.data.value.Value; import org.spongepowered.api.entity.living.animal.Fox; -import org.spongepowered.api.entity.living.monster.Patroller; import org.spongepowered.asm.mixin.Implements; import org.spongepowered.asm.mixin.Interface; import org.spongepowered.asm.mixin.Intrinsic; @@ -53,7 +52,7 @@ public abstract class FoxMixin_API extends AnimalMixin_API implements Fox { protected Set> api$getVanillaValues() { final Set> values = super.api$getVanillaValues(); - values.add(this.type().asImmutable()); + values.add(this.foxType().asImmutable()); values.add(this.sitting().asImmutable()); values.add(this.faceplanted().asImmutable()); values.add(this.defending().asImmutable()); diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/animal/MushroomCowMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/animal/MushroomCowMixin_API.java index 88faad5d7a0..507568fc059 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/animal/MushroomCowMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/animal/MushroomCowMixin_API.java @@ -38,7 +38,7 @@ public abstract class MushroomCowMixin_API extends AnimalMixin_API implements Mo protected Set> api$getVanillaValues() { final Set> values = super.api$getVanillaValues(); - values.add(this.type().asImmutable()); + values.add(this.mooshroomType().asImmutable()); return values; } diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/animal/ParrotMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/animal/ParrotMixin_API.java index 73c343652e4..34b27ce9e47 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/animal/ParrotMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/animal/ParrotMixin_API.java @@ -40,7 +40,7 @@ public abstract class ParrotMixin_API extends TamableAnimalMixin_API implements // Sittable values.add(this.sitting().asImmutable()); - values.add(this.type().asImmutable()); + values.add(this.parrotType().asImmutable()); return values; } diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/animal/RabbitMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/animal/RabbitMixin_API.java index 30886af734c..5bb120737fe 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/animal/RabbitMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/animal/RabbitMixin_API.java @@ -37,7 +37,7 @@ public abstract class RabbitMixin_API extends AnimalMixin_API implements Rabbit protected Set> api$getVanillaValues() { final Set> values = super.api$getVanillaValues(); - values.add(this.type().asImmutable()); + values.add(this.rabbitType().asImmutable()); return values; } diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/animal/horse/LlamaMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/animal/horse/LlamaMixin_API.java index 99f6b89ee46..cb916774e86 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/animal/horse/LlamaMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/animal/horse/LlamaMixin_API.java @@ -37,7 +37,7 @@ public abstract class LlamaMixin_API extends AbstractChestedHorseMixin_API imple protected Set> api$getVanillaValues() { final Set> values = super.api$getVanillaValues(); - values.add(this.type().asImmutable()); + values.add(this.llamaType().asImmutable()); values.add(this.strength().asImmutable()); this.tamer().map(Value::asImmutable).ifPresent(values::add); diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/boss/EnderDragonPartMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/boss/EnderDragonPartMixin_API.java index a0760d41b5e..e16e2d574e9 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/boss/EnderDragonPartMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/boss/EnderDragonPartMixin_API.java @@ -39,7 +39,7 @@ public abstract class EnderDragonPartMixin_API extends EntityMixin_API implement // @formatter:on @Override - public EnderDragon getParent() { + public EnderDragon parent() { return (EnderDragon) this.parentMob; } diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/boss/enderdragon/EnderDragonMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/boss/enderdragon/EnderDragonMixin_API.java index b97637ed0e3..4e4ccfb5e82 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/boss/enderdragon/EnderDragonMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/boss/enderdragon/EnderDragonMixin_API.java @@ -46,7 +46,7 @@ public abstract class EnderDragonMixin_API extends MobMixin_API implements Ender // @formatter:on @Override - public Set getParts() { + public Set parts() { Builder builder = ImmutableSet.builder(); for (net.minecraft.world.entity.boss.EnderDragonPart part : this.subEntities) { @@ -57,7 +57,7 @@ public Set getParts() { } @Override - public DragonPhaseManager getPhaseManager() { + public DragonPhaseManager phaseManager() { return (DragonPhaseManager) this.phaseManager; } diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/boss/enderdragon/phases/DragonPhaseInstanceMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/boss/enderdragon/phases/DragonPhaseInstanceMixin_API.java index 5e1f1b74d7a..478d024eaba 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/boss/enderdragon/phases/DragonPhaseInstanceMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/boss/enderdragon/phases/DragonPhaseInstanceMixin_API.java @@ -43,12 +43,12 @@ public interface DragonPhaseInstanceMixin_API extends DragonPhase { // @formatter:on @Override - default DragonPhaseType getType() { + default DragonPhaseType type() { return (DragonPhaseType) this.shadow$getPhase(); } @Override - default Optional getTargetPosition() { + default Optional targetPosition() { final net.minecraft.world.phys.Vec3 vec = this.shadow$getFlyTargetLocation(); return vec == null ? Optional.empty() : Optional.of(VecHelper.toVector3d(vec)); } diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/boss/enderdragon/phases/EnderDragonPhaseManagerMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/boss/enderdragon/phases/EnderDragonPhaseManagerMixin_API.java index bf8149bf26c..928fe3fa3d6 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/boss/enderdragon/phases/EnderDragonPhaseManagerMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/boss/enderdragon/phases/EnderDragonPhaseManagerMixin_API.java @@ -42,7 +42,7 @@ public abstract class EnderDragonPhaseManagerMixin_API implements DragonPhaseMan // @formatter:on @Override - public DragonPhase getPhase() { + public DragonPhase phase() { return (DragonPhase) this.currentPhase; } diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/decoration/HangingEntityMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/decoration/HangingEntityMixin_API.java index f84250a04df..39406453960 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/decoration/HangingEntityMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/decoration/HangingEntityMixin_API.java @@ -44,7 +44,7 @@ public abstract class HangingEntityMixin_API extends EntityMixin_API implements protected Set> api$getVanillaValues() { final Set> values = super.api$getVanillaValues(); - values.add(this.direction().asImmutable()); + values.add(this.hangingDirection().asImmutable()); return values; } diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/decoration/MotiveMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/decoration/MotiveMixin_API.java index 037e7b1c28e..60f6379e6a1 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/decoration/MotiveMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/decoration/MotiveMixin_API.java @@ -32,7 +32,6 @@ import org.spongepowered.asm.mixin.Shadow; @Mixin(net.minecraft.world.entity.decoration.Motive.class) -@Implements(value = @Interface(iface = ArtType.class, prefix = "artType$")) public abstract class MotiveMixin_API implements ArtType { // @formatter:off @@ -40,13 +39,13 @@ public abstract class MotiveMixin_API implements ArtType { @Shadow public abstract int shadow$getHeight(); // @formatter:on - @Intrinsic - public int artType$getWidth() { + @Override + public int width() { return this.shadow$getWidth(); } - @Intrinsic - public int artType$getHeight() { + @Override + public int height() { return this.shadow$getHeight(); } } diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/monster/ShulkerMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/monster/ShulkerMixin_API.java index 1df4ec627ba..2a3695bb44f 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/monster/ShulkerMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/monster/ShulkerMixin_API.java @@ -45,7 +45,7 @@ public abstract class ShulkerMixin_API extends AbstractGolemMixin_API implements final Set> values = super.api$getVanillaValues(); values.add(this.color().asImmutable()); - values.add(this.direction().asImmutable()); + values.add(this.hangingDirection().asImmutable()); return values; } diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/monster/ZombieVillagerMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/monster/ZombieVillagerMixin_API.java index 55848cabfb9..0e8396d85b0 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/monster/ZombieVillagerMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/monster/ZombieVillagerMixin_API.java @@ -27,7 +27,6 @@ import org.spongepowered.api.data.value.Value; import org.spongepowered.api.entity.living.monster.zombie.ZombieVillager; import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; import java.util.Set; @@ -38,7 +37,7 @@ public abstract class ZombieVillagerMixin_API extends ZombieMixin_API implements protected Set> api$getVanillaValues() { final Set> values = super.api$getVanillaValues(); - values.add(this.type().asImmutable()); + values.add(this.villagerType().asImmutable()); values.add(this.profession().asImmutable()); return values; diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/npc/AbstractVillagerMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/npc/AbstractVillagerMixin_API.java index 22e79d75def..936597a0184 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/npc/AbstractVillagerMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/npc/AbstractVillagerMixin_API.java @@ -45,7 +45,7 @@ public abstract class AbstractVillagerMixin_API extends AgableMobMixin_API imple // @formatter:on @Override - public Optional getCustomer() { + public Optional customer() { return Optional.ofNullable((Humanoid) this.shadow$getTradingPlayer()); } diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/npc/VillagerMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/npc/VillagerMixin_API.java index 7877538fc99..50361b0ae7d 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/npc/VillagerMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/npc/VillagerMixin_API.java @@ -36,7 +36,7 @@ public abstract class VillagerMixin_API extends AbstractVillagerMixin_API implem protected Set> api$getVanillaValues() { final Set> values = super.api$getVanillaValues(); - values.add(this.type().asImmutable()); + values.add(this.villagerType().asImmutable()); values.add(this.profession().asImmutable()); values.add(this.professionLevel().asImmutable()); diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/player/PlayerMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/player/PlayerMixin_API.java index 9924961ba20..37c674325ec 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/player/PlayerMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/player/PlayerMixin_API.java @@ -40,8 +40,7 @@ import org.spongepowered.common.mixin.api.mcp.world.entity.LivingEntityMixin_API; @Mixin(net.minecraft.world.entity.player.Player.class) -@Implements(@Interface(iface = Player.class, prefix = "player$")) -public abstract class PlayerMixin_API extends LivingEntityMixin_API { +public abstract class PlayerMixin_API extends LivingEntityMixin_API implements Player { // @formatter:off @Shadow public AbstractContainerMenu containerMenu; @@ -55,8 +54,8 @@ public abstract class PlayerMixin_API extends LivingEntityMixin_API { public final boolean impl$isFake = ((PlatformEntityBridge) (net.minecraft.world.entity.player.Player) (Object) this).bridge$isFakePlayer(); - @Intrinsic - public String player$getName() { + @Override + public String name() { return this.shadow$getName().getString(); } diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/projectile/ShulkerBulletMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/projectile/ShulkerBulletMixin_API.java index e6eee9a7513..dc6f4518f40 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/projectile/ShulkerBulletMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/projectile/ShulkerBulletMixin_API.java @@ -43,7 +43,7 @@ public abstract class ShulkerBulletMixin_API extends EntityMixin_API implements // EntityTargettingProjectile this.targetEntity().map(Value::asImmutable).ifPresent(values::add); - values.add(this.direction().asImmutable()); + values.add(this.hangingDirection().asImmutable()); return values; } diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/raid/RaidMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/raid/RaidMixin_API.java index 47a77c15aa4..2a225f156c4 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/raid/RaidMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/raid/RaidMixin_API.java @@ -61,12 +61,12 @@ public abstract class RaidMixin_API implements org.spongepowered.api.raid.Raid { //@formatter:on @Override - public ServerWorld getWorld() { + public ServerWorld world() { return (ServerWorld) this.shadow$getLevel(); } @Override - public BossBar getBossBar() { + public BossBar bossBar() { return SpongeAdventure.asAdventure(this.raidEvent); } @@ -77,27 +77,27 @@ public void setBossBar(final BossBar bossBar) { } @Override - public RaidStatus getStatus() { + public RaidStatus status() { return (RaidStatus) (Object) this.status; } @Override - public Optional getCurrentWave() { + public Optional currentWave() { return Optional.ofNullable(((RaidBridge) this).bridge$getWaves().get(this.shadow$getGroupsSpawned())); } @Override - public List getWaves() { + public List waves() { return new ArrayList<>(((RaidBridge) this).bridge$getWaves().values()); } @Override - public int getTotalWaveAmount() { + public int totalWaveAmount() { return this.groupRaiderMap.size(); } @Override - public double getHealth() { + public double health() { return this.shadow$getHealthOfLivingRaiders(); } } diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/vehicle/BoatMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/vehicle/BoatMixin_API.java index 26d58eae985..b2687cecf05 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/vehicle/BoatMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/vehicle/BoatMixin_API.java @@ -40,7 +40,7 @@ public abstract class BoatMixin_API extends EntityMixin_API implements Boat { protected Set> api$getVanillaValues() { final Set> values = super.api$getVanillaValues(); - values.add(this.type().asImmutable()); + values.add(this.boatType().asImmutable()); values.add(this.inWater().asImmutable()); values.add(this.moveOnLand().asImmutable()); values.add(this.maxSpeed().asImmutable()); diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/vehicle/Boat_TypeMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/vehicle/Boat_TypeMixin_API.java index b25bbf6f160..d0bbd464b96 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/vehicle/Boat_TypeMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/vehicle/Boat_TypeMixin_API.java @@ -40,7 +40,7 @@ public abstract class Boat_TypeMixin_API implements BoatType { // @formatter:on @Override - public BlockType getRepresentedBlock() { + public BlockType representedBlock() { return (BlockType) this.planks; } } diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/vehicle/MinecartCommandBlockMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/vehicle/MinecartCommandBlockMixin_API.java index 1f76d2b6cc1..d4bdfab2657 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/vehicle/MinecartCommandBlockMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/entity/vehicle/MinecartCommandBlockMixin_API.java @@ -41,7 +41,7 @@ public abstract class MinecartCommandBlockMixin_API extends AbstractMinecartMixi // @formatter:on @Override - public String getIdentifier() { + public String identifier() { return this.getCommandBlock().getName().getString(); } diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/item/ArmorMaterialsMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/item/ArmorMaterialsMixin_API.java index abce4284702..ac4e9456749 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/item/ArmorMaterialsMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/item/ArmorMaterialsMixin_API.java @@ -42,7 +42,7 @@ public abstract class ArmorMaterialsMixin_API implements ArmorMaterial { // @formatter:on @Override - public Optional getRepairIngredient() { + public Optional repairIngredient() { final net.minecraft.world.item.crafting.Ingredient repairMaterial = this.shadow$getRepairIngredient(); return Optional.ofNullable(((Ingredient) (Object) repairMaterial)); } diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/item/DyeColorMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/item/DyeColorMixin_API.java index 400a0c51cee..a9c24409d54 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/item/DyeColorMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/item/DyeColorMixin_API.java @@ -38,7 +38,7 @@ public abstract class DyeColorMixin_API implements DyeColor { // @formatter:on @Override - public Color getColor() { + public Color color() { float[] components = this.shadow$getTextureDiffuseColors(); int r = GenericMath.floor(components[0] * 255); int g = GenericMath.floor(components[1] * 255); diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/item/ItemCooldownsMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/item/ItemCooldownsMixin_API.java index b722bfa5d35..1a95ee3847e 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/item/ItemCooldownsMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/item/ItemCooldownsMixin_API.java @@ -57,7 +57,7 @@ public boolean hasCooldown(final ItemType type) { } @Override - public OptionalInt getCooldown(final ItemType type) { + public OptionalInt cooldown(final ItemType type) { checkNotNull(type, "Item type cannot be null!"); final ItemCooldowns_CooldownInstanceAccessor cooldown = (ItemCooldowns_CooldownInstanceAccessor) this.cooldowns.get((Item) type); @@ -85,7 +85,7 @@ public boolean resetCooldown(final ItemType type) { } @Override - public OptionalDouble getFractionRemaining(final ItemType type) { + public OptionalDouble fractionRemaining(final ItemType type) { checkNotNull(type, "Item type cannot be null!"); final float cooldown = this.shadow$getCooldownPercent((Item) type, 0); diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/item/ItemMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/item/ItemMixin_API.java index f0a22433d83..d22d1a9742f 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/item/ItemMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/item/ItemMixin_API.java @@ -53,12 +53,12 @@ public Component asComponent() { } @Override - public int getMaxStackQuantity() { + public int maxStackQuantity() { return this.shadow$getMaxStackSize(); } @Override - public Optional getBlock() { + public Optional block() { return Optional.ofNullable(this.api$blockType); } diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/item/ItemStackMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/item/ItemStackMixin_API.java index 34e1252924a..2568c90b6f5 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/item/ItemStackMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/item/ItemStackMixin_API.java @@ -77,11 +77,11 @@ public abstract class ItemStackMixin_API implements SerializableDataHolder.Mutab @Shadow public abstract void shadow$addAttributeModifier(Attribute attribute, net.minecraft.world.entity.ai.attributes.AttributeModifier modifier, @Nullable EquipmentSlot equipmentSlot); // @formatter:on - public int itemStack$getQuantity() { + public int itemStack$quantity() { return this.shadow$getCount(); } - public ItemType itemStack$getType() { + public ItemType itemStack$type() { return (ItemType) this.shadow$getItem(); } @@ -89,7 +89,7 @@ public abstract class ItemStackMixin_API implements SerializableDataHolder.Mutab this.shadow$setCount(quantity); } - public int itemStack$getMaxStackQuantity() { + public int itemStack$maxStackQuantity() { return this.shadow$getMaxStackSize(); } @@ -129,7 +129,7 @@ public SerializableDataHolder.Mutable copy() { return (ItemStack) (Object) this.shadow$copy(); } - public Collection itemStack$getAttributeModifiers(final AttributeType attributeType, final EquipmentType equipmentType) { + public Collection itemStack$attributeModifiers(final AttributeType attributeType, final EquipmentType equipmentType) { Preconditions.checkNotNull(attributeType, "Attribute type cannot be null"); Preconditions.checkNotNull(equipmentType, "Equipment type cannot be null"); @@ -161,17 +161,17 @@ public SerializableDataHolder.Mutable copy() { } @Override - public int getContentVersion() { + public int contentVersion() { return 1; } @Override public DataContainer toContainer() { - final ResourceKey key = (ResourceKey) (Object) Registry.ITEM.getKey((Item) this.itemStack$getType()); + final ResourceKey key = (ResourceKey) (Object) Registry.ITEM.getKey((Item) this.itemStack$type()); final DataContainer container = DataContainer.createNew() - .set(Queries.CONTENT_VERSION, this.getContentVersion()) + .set(Queries.CONTENT_VERSION, this.contentVersion()) .set(Constants.ItemStack.TYPE, key) - .set(Constants.ItemStack.COUNT, this.itemStack$getQuantity()) + .set(Constants.ItemStack.COUNT, this.itemStack$quantity()) .set(Constants.ItemStack.DAMAGE_VALUE, this.shadow$getDamageValue()); if (this.shadow$hasTag()) { // no tag? no data, simple as that. final CompoundTag compound = this.shadow$getTag().copy(); diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/item/TiersMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/item/TiersMixin_API.java index 36dc8add69e..4caee4805cf 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/item/TiersMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/item/TiersMixin_API.java @@ -37,7 +37,7 @@ public abstract class TiersMixin_API implements ItemTier { // @formatter:on @Override - public org.spongepowered.api.item.recipe.crafting.Ingredient getRepairIngredient() { + public org.spongepowered.api.item.recipe.crafting.Ingredient repairIngredient() { return (org.spongepowered.api.item.recipe.crafting.Ingredient) (Object) this.shadow$getRepairIngredient(); } } diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/item/alchemy/PotionMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/item/alchemy/PotionMixin_API.java index 5a30dd657a3..8a662db5c91 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/item/alchemy/PotionMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/item/alchemy/PotionMixin_API.java @@ -42,7 +42,7 @@ public abstract class PotionMixin_API implements PotionType { @Override @SuppressWarnings(value = {"unchecked", "rawtypes"}) - public List getEffects() { + public List effects() { return ((List) this.effects); // PotionEffect is mixed into } diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/item/crafting/AbstractCookingRecipeMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/item/crafting/AbstractCookingRecipeMixin_API.java index 74363d515ab..47773fc08f1 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/item/crafting/AbstractCookingRecipeMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/item/crafting/AbstractCookingRecipeMixin_API.java @@ -43,7 +43,6 @@ import net.minecraft.world.item.crafting.Ingredient; @Mixin(AbstractCookingRecipe.class) -@Implements(@Interface(iface = CookingRecipe.class, prefix = "cookingRecipe$")) public abstract class AbstractCookingRecipeMixin_API implements CookingRecipe { // @formatter:off @@ -55,12 +54,12 @@ public abstract class AbstractCookingRecipeMixin_API implements CookingRecipe { @Override - public ResourceKey getKey() { + public ResourceKey key() { return (ResourceKey) (Object) this.id; } @Override - public org.spongepowered.api.item.recipe.crafting.Ingredient getIngredient() { + public org.spongepowered.api.item.recipe.crafting.Ingredient ingredient() { return IngredientUtil.fromNative(this.ingredient); } @@ -70,20 +69,20 @@ public boolean isValid(ItemStackSnapshot ingredient) { } @Override - public Optional getResult(ItemStackSnapshot ingredient) { + public Optional result(ItemStackSnapshot ingredient) { if (this.isValid(ingredient)) { - return Optional.of(new CookingResult(this.getExemplaryResult(), this.shadow$getExperience())); + return Optional.of(new CookingResult(this.exemplaryResult(), this.shadow$getExperience())); } return Optional.empty(); } - @Intrinsic - public int cookingRecipe$getCookingTime() { + @Override + public int cookingTime() { return this.shadow$getCookingTime(); } - @Intrinsic - public float cookingRecipe$getExperience() { + @Override + public float experience() { return this.shadow$getExperience(); } } diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/item/crafting/CraftingRecipeMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/item/crafting/CraftingRecipeMixin_API.java index 0c4930c6045..c7a0df03287 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/item/crafting/CraftingRecipeMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/item/crafting/CraftingRecipeMixin_API.java @@ -37,18 +37,17 @@ import net.minecraft.world.item.crafting.ShapelessRecipe; @Mixin(net.minecraft.world.item.crafting.CraftingRecipe.class) -@Implements(@Interface(iface = CraftingRecipe.class, prefix = "craftingRecipe$")) -public interface CraftingRecipeMixin_API { +public interface CraftingRecipeMixin_API extends CraftingRecipe { // @formatter:off @Shadow net.minecraft.world.item.crafting.RecipeType shadow$getType(); // @formatter:on - default RecipeType craftingRecipe$getType() { + default RecipeType type() { return (RecipeType) this.shadow$getType(); } - default Optional craftingRecipe$getGroup() { + default Optional group() { String group = ""; if (this instanceof ShapedRecipe) { group = ((ShapedRecipeAccessor) this).accessor$group(); diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/item/crafting/CustomRecipeMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/item/crafting/CustomRecipeMixin_API.java index 68b4004d201..4cbffb99509 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/item/crafting/CustomRecipeMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/item/crafting/CustomRecipeMixin_API.java @@ -38,7 +38,7 @@ public abstract class CustomRecipeMixin_API implements SpecialCraftingRecipe { @Shadow @Final private ResourceLocation id; @Override - public ResourceKey getKey() { + public ResourceKey key() { return (ResourceKey) (Object) this.id; } } diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/item/crafting/RecipeManagerMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/item/crafting/RecipeManagerMixin_API.java index 2a8b3c8602b..14e593d5e60 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/item/crafting/RecipeManagerMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/item/crafting/RecipeManagerMixin_API.java @@ -71,20 +71,20 @@ public abstract class RecipeManagerMixin_API implements RecipeRegistry { // @formatter:on @Override - public Optional getByKey(ResourceKey key) { + public Optional byKey(ResourceKey key) { Preconditions.checkNotNull(key); return this.shadow$byKey((ResourceLocation) (Object) key).map(Recipe.class::cast); } @Override @SuppressWarnings(value = {"unchecked", "rawtypes"}) - public Collection getAll() { + public Collection all() { return (Collection) this.shadow$getRecipes(); } @Override @SuppressWarnings(value = {"unchecked", "rawtypes"}) - public Collection getAllOfType(RecipeType type) { + public Collection allOfType(RecipeType type) { Preconditions.checkNotNull(type); return this.shadow$byType((net.minecraft.world.item.crafting.RecipeType)type).values(); } @@ -93,8 +93,8 @@ public Collection getAllOfType(RecipeType type) { public Collection findByResult(RecipeType type, ItemStackSnapshot result) { Preconditions.checkNotNull(type); Preconditions.checkNotNull(result); - return this.getAllOfType(type).stream() - .filter(r -> r.getExemplaryResult().equals(result)) + return this.allOfType(type).stream() + .filter(r -> r.exemplaryResult().equals(result)) .collect(Collectors.toList()); } diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/item/crafting/RecipeMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/item/crafting/RecipeMixin_API.java index 75ebffdd5d6..47496e33e6f 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/item/crafting/RecipeMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/item/crafting/RecipeMixin_API.java @@ -50,8 +50,7 @@ import net.minecraft.world.item.ItemStack; @Mixin(net.minecraft.world.item.crafting.Recipe.class) -@Implements(@Interface(iface = Recipe.class, prefix = "recipe$")) -public interface RecipeMixin_API { +public interface RecipeMixin_API extends Recipe { // @formatter:off @Shadow ItemStack shadow$assemble(C inv); @@ -65,37 +64,42 @@ public interface RecipeMixin_API { // @formatter:on @Nonnull - default ItemStackSnapshot recipe$getExemplaryResult() { + @Override + default ItemStackSnapshot exemplaryResult() { return ItemStackUtil.snapshotOf(this.shadow$getResultItem()); } - default boolean recipe$isValid(@Nonnull Inventory inv, @Nonnull ServerWorld world) { + @Override + default boolean isValid(@Nonnull final Inventory inv, @Nonnull final ServerWorld world) { return this.shadow$matches(toNativeInventory(inv), (net.minecraft.world.level.Level) world); } @Nonnull - default ItemStackSnapshot recipe$getResult(@Nonnull Inventory inv) { + @Override + default ItemStackSnapshot result(@Nonnull final Inventory inv) { return ItemStackUtil.snapshotOf(this.shadow$assemble(toNativeInventory(inv))); } @Nonnull - default List recipe$getRemainingItems(@Nonnull Inventory inv) { + @Override + default List remainingItems(@Nonnull final Inventory inv) { return this.shadow$getRemainingItems(toNativeInventory(inv)).stream() .map(ItemStackUtil::snapshotOf) .collect(Collectors.toList()); } - @Intrinsic - default List recipe$getIngredients() { + @Override + default List ingredients() { return this.shadow$getIngredients().stream().map(IngredientUtil::fromNative).collect(Collectors.toList()); } - @Intrinsic - default boolean recipe$isDynamic() { + @Override + default boolean isDynamic() { return this.shadow$isSpecial(); } - default RecipeType recipe$getType() { + @Override + default RecipeType type() { return (RecipeType) this.shadow$getType(); } } diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/item/crafting/ShapedRecipeMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/item/crafting/ShapedRecipeMixin_API.java index 5e08283f6dd..426b34b91be 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/item/crafting/ShapedRecipeMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/item/crafting/ShapedRecipeMixin_API.java @@ -45,13 +45,13 @@ public abstract class ShapedRecipeMixin_API implements ShapedCraftingRecipe { // @formatter:on @Override - public ResourceKey getKey() { + public ResourceKey key() { return (ResourceKey) (Object) this.id; } @SuppressWarnings("ConstantConditions") @Override - public org.spongepowered.api.item.recipe.crafting.Ingredient getIngredient(final int x, final int y) { + public org.spongepowered.api.item.recipe.crafting.Ingredient ingredient(final int x, final int y) { if (x < 0 || x >= this.width || y < 0 || y >= this.height) { throw new IndexOutOfBoundsException("Invalid ingredient predicate location"); } @@ -61,12 +61,12 @@ public org.spongepowered.api.item.recipe.crafting.Ingredient getIngredient(final } @Override - public int getWidth() { + public int width() { return this.width; } @Override - public int getHeight() { + public int height() { return this.height; } diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/item/crafting/ShapelessRecipeMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/item/crafting/ShapelessRecipeMixin_API.java index 9f8bf9dd494..3882776afba 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/item/crafting/ShapelessRecipeMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/item/crafting/ShapelessRecipeMixin_API.java @@ -40,7 +40,7 @@ public abstract class ShapelessRecipeMixin_API implements ShapelessCraftingRecip // @formatter:on @Override - public ResourceKey getKey() { + public ResourceKey key() { return (ResourceKey) (Object) this.id; } } diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/item/crafting/StonecutterRecipeMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/item/crafting/StonecutterRecipeMixin_API.java index 36a740b99ec..2b4befcddfc 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/item/crafting/StonecutterRecipeMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/item/crafting/StonecutterRecipeMixin_API.java @@ -33,7 +33,7 @@ public abstract class StonecutterRecipeMixin_API extends SingleItemRecipeMixin_API implements StoneCutterRecipe { @Override - public ResourceKey getKey() { + public ResourceKey key() { return (ResourceKey) (Object) this.id; } } diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/item/enchantment/EnchantmentMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/item/enchantment/EnchantmentMixin_API.java index 2133e48aa74..2385911f2bb 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/item/enchantment/EnchantmentMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/item/enchantment/EnchantmentMixin_API.java @@ -55,27 +55,27 @@ public abstract class EnchantmentMixin_API implements EnchantmentType { // @formatter:on @Override - public int getWeight() { + public int weight() { return this.rarity.getWeight(); } @Override - public int getMinimumLevel() { + public int minimumLevel() { return this.shadow$getMinLevel(); } @Override - public int getMaximumLevel() { + public int maximumLevel() { return this.shadow$getMaxLevel(); } @Override - public int getMinimumEnchantabilityForLevel(final int level) { + public int minimumEnchantabilityForLevel(final int level) { return this.shadow$getMinCost(level); } @Override - public int getMaximumEnchantabilityForLevel(final int level) { + public int maximumEnchantabilityForLevel(final int level) { return this.shadow$getMaxCost(level); } diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/item/trading/MerchantOfferMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/item/trading/MerchantOfferMixin_API.java index 71fba1d9bd8..5ca4a3a340d 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/item/trading/MerchantOfferMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/item/trading/MerchantOfferMixin_API.java @@ -42,7 +42,6 @@ import net.minecraft.world.item.trading.MerchantOffer; @Mixin(MerchantOffer.class) -@Implements(@Interface(iface = TradeOffer.class, prefix = "tradeOffer$")) public abstract class MerchantOfferMixin_API implements TradeOffer { // @formatter:off @@ -59,7 +58,7 @@ public abstract class MerchantOfferMixin_API implements TradeOffer { // @formatter:on @Override - public ItemStackSnapshot getFirstBuyingItem() { + public ItemStackSnapshot firstBuyingItem() { return ((ItemStack) (Object) this.shadow$getCostA()).createSnapshot(); } @@ -69,7 +68,7 @@ public boolean hasSecondItem() { } @Override - public Optional getSecondBuyingItem() { + public Optional secondBuyingItem() { if (this.shadow$getCostB() == null) { return Optional.empty(); } @@ -77,17 +76,17 @@ public Optional getSecondBuyingItem() { } @Override - public ItemStackSnapshot getSellingItem() { + public ItemStackSnapshot sellingItem() { return ((ItemStack) (Object) this.shadow$getResult()).createSnapshot(); } - @Intrinsic - public int tradeOffer$getUses() { + @Override + public int uses() { return this.shadow$getUses(); } - @Intrinsic - public int tradeOffer$getMaxUses() { + @Override + public int maxUses() { return this.shadow$getMaxUses(); } @@ -102,35 +101,35 @@ public boolean doesGrantExperience() { } @Override - public int getExperienceGrantedToMerchant() { + public int experienceGrantedToMerchant() { return this.shadow$getXp(); } @Override - public double getPriceGrowthMultiplier() { + public double priceGrowthMultiplier() { return this.shadow$getPriceMultiplier(); } @Override - public int getDemandBonus() { + public int demandBonus() { return this.shadow$getDemand(); } @Override - public int getContentVersion() { + public int contentVersion() { return 1; } @Override public DataContainer toContainer() { return DataContainer.createNew() - .set(Queries.CONTENT_VERSION, this.getContentVersion()) - .set(Constants.Item.TradeOffer.FIRST_QUERY, this.getFirstBuyingItem()) - .set(Constants.Item.TradeOffer.SECOND_QUERY, this.hasSecondItem() ? this.getSecondBuyingItem().get() : "none") + .set(Queries.CONTENT_VERSION, this.contentVersion()) + .set(Constants.Item.TradeOffer.FIRST_QUERY, this.firstBuyingItem()) + .set(Constants.Item.TradeOffer.SECOND_QUERY, this.hasSecondItem() ? this.secondBuyingItem().get() : "none") .set(Constants.Item.TradeOffer.BUYING_QUERY, this.shadow$getCostA()) .set(Constants.Item.TradeOffer.EXPERIENCE_QUERY, this.doesGrantExperience()) .set(Constants.Item.TradeOffer.MAX_QUERY, this.shadow$getMaxUses()) - .set(Constants.Item.TradeOffer.USES_QUERY, this.getUses()) + .set(Constants.Item.TradeOffer.USES_QUERY, this.uses()) .set(Constants.Item.TradeOffer.EXPERIENCE_GRANTED_TO_MERCHANT_QUERY, this.shadow$getXp()) .set(Constants.Item.TradeOffer.PRICE_GROWTH_MULTIPLIER_QUERY, this.shadow$getPriceMultiplier()) .set(Constants.Item.TradeOffer.DEMAND_BONUS_QUERY, this.shadow$getDemand()); diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/level/BlockGetterMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/level/BlockGetterMixin_API.java index ee87d2de3b7..e3296191fff 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/level/BlockGetterMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/level/BlockGetterMixin_API.java @@ -43,7 +43,6 @@ import java.util.Optional; @Mixin(BlockGetter.class) -@Implements(@Interface(iface = PrimitiveGameVolume.class, prefix = "primitive$")) public interface BlockGetterMixin_API extends PrimitiveGameVolume { //@formatter:off @@ -56,62 +55,62 @@ public interface BlockGetterMixin_API extends PrimitiveGameVolume { //@formatter:on @Override - default int getMaximumLight() { + default int maximumLight() { return this.shadow$getMaxLightLevel(); } @Override - default int getEmittedLight(final Vector3i position) { + default int emittedLight(final Vector3i position) { return this.shadow$getLightEmission(new BlockPos(position.getX(), position.getY(), position.getZ())); } @Override - default int getEmittedLight(final int x, final int y, final int z) { + default int emittedLight(final int x, final int y, final int z) { return this.shadow$getLightEmission(new BlockPos(x, y, z)); } - @Intrinsic - default int primitive$getHeight() { + @Override + default int height() { return this.shadow$getMaxBuildHeight(); } @Override - default Collection getBlockEntities() { + default Collection blockEntities() { return Collections.emptyList(); } @Override - default Optional getBlockEntity(final int x, final int y, final int z) { + default Optional blockEntity(final int x, final int y, final int z) { return Optional.ofNullable((BlockEntity) this.shadow$getBlockEntity(new BlockPos(x, y, z))); } @Override - default org.spongepowered.api.block.BlockState getBlock(final int x, final int y, final int z) { + default org.spongepowered.api.block.BlockState block(final int x, final int y, final int z) { return (org.spongepowered.api.block.BlockState) this.shadow$getBlockState(new BlockPos(x, y, z)); } @Override - default FluidState getFluid(final int x, final int y, final int z) { + default FluidState fluid(final int x, final int y, final int z) { return (FluidState) (Object) this.shadow$getFluidState(new BlockPos(x, y, z)); } @Override - default int getHighestYAt(final int x, final int z) { + default int highestYAt(final int x, final int z) { throw new UnsupportedOperationException("Unfortunately, you've found an extended class of IBlockReader that isn't part of Sponge API"); } @Override - default Vector3i getBlockMin() { + default Vector3i blockMin() { throw new UnsupportedOperationException("Unfortunately, you've found an extended class of IBlockReader that isn't part of Sponge API"); } @Override - default Vector3i getBlockMax() { + default Vector3i blockMax() { throw new UnsupportedOperationException("Unfortunately, you've found an extended class of IBlockReader that isn't part of Sponge API"); } @Override - default Vector3i getBlockSize() { + default Vector3i blockSize() { throw new UnsupportedOperationException("Unfortunately, you've found an extended class of IBlockReader that isn't part of Sponge API"); } diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/level/EntityGetterMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/level/EntityGetterMixin_API.java index d7e3d18d6b8..7cf65cc165f 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/level/EntityGetterMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/level/EntityGetterMixin_API.java @@ -53,17 +53,17 @@ public interface EntityGetterMixin_API extends EntityVolume { //@formatter:on @Override - default Vector3i getBlockMin() { + default Vector3i blockMin() { throw new UnsupportedOperationException("Unfortunately, you've found an extended class of IEntityReader that isn't part of Sponge API"); } @Override - default Vector3i getBlockMax() { + default Vector3i blockMax() { throw new UnsupportedOperationException("Unfortunately, you've found an extended class of IEntityReader that isn't part of Sponge API"); } @Override - default Vector3i getBlockSize() { + default Vector3i blockSize() { throw new UnsupportedOperationException("Unfortunately, you've found an extended class of IEntityReader that isn't part of Sponge API"); } @@ -78,25 +78,25 @@ default boolean isAreaAvailable(final int x, final int y, final int z) { } @Override - default Optional getEntity(final UUID uuid) { + default Optional entity(final UUID uuid) { return Optional.empty(); } @SuppressWarnings("unchecked") @Override - default Collection getPlayers() { + default Collection players() { return Collections.unmodifiableCollection((List) (List) this.shadow$players()); } @SuppressWarnings(value = {"unchecked", "rawtypes"}) @Override - default Collection getEntities(final AABB box, final Predicate filter) { + default Collection entities(final AABB box, final Predicate filter) { return (Collection) this.shadow$getEntities(null, VecHelper.toMinecraftAABB(box), VolumeStreamUtils.apiToImplPredicate(filter)); } @SuppressWarnings(value = {"unchecked", "rawtypes"}) @Override - default Collection getEntities(final Class entityClass, final AABB box, @Nullable + default Collection entities(final Class entityClass, final AABB box, @Nullable final Predicate predicate) { final Predicate filter = entity -> predicate == null || (entityClass.isInstance(entity) && predicate.test((E) entity)); final List ts = this.shadow$getEntitiesOfClass((Class) (Class) entityClass, diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/level/ExplosionMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/level/ExplosionMixin_API.java index dd3ef8aeafc..dbd48b10d47 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/level/ExplosionMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/level/ExplosionMixin_API.java @@ -54,7 +54,7 @@ public abstract class ExplosionMixin_API implements Explosion { @Nullable private ServerLocation api$location; @Override - public ServerLocation getLocation() { + public ServerLocation location() { if (this.api$location == null) { this.api$location = ServerLocation.of((ServerWorld) this.level, this.x, this.y, this.z); } @@ -62,7 +62,7 @@ public ServerLocation getLocation() { } @Override - public Optional getSourceExplosive() { + public Optional sourceExplosive() { if (this.source instanceof Explosive) { return Optional.of((Explosive) this.source); } @@ -71,7 +71,7 @@ public Optional getSourceExplosive() { } @Override - public float getRadius() { + public float radius() { return this.radius; } @@ -96,17 +96,17 @@ public boolean shouldDamageEntities() { } @Override - public int getResolution() { + public int resolution() { return ((ExplosionBridge) this).bridge$getResolution(); } @Override - public float getRandomness() { + public float randomness() { return ((ExplosionBridge) this).bridge$getRandomness(); } @Override - public double getKnockback() { + public double knockback() { return ((ExplosionBridge) this).bridge$getKnockback(); } diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/level/GameRules_KeyMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/level/GameRules_KeyMixin_API.java index fbd4988ebb5..e8628904c23 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/level/GameRules_KeyMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/level/GameRules_KeyMixin_API.java @@ -39,18 +39,18 @@ public class GameRules_KeyMixin_API implements GameRule { @Shadow @Final private String id; @Override - public String getName() { + public String name() { return this.id; } @Override - public Type getValueType() { + public Type valueType() { throw new UnsupportedOperationException("Not implemented yet"); } @Override @SuppressWarnings("unchecked") - public T getDefaultValue() { + public T defaultValue() { final GameRules.Type type = GameRulesAccessor.accessor$GAME_RULE_TYPES().get(this); final GameRules.Value value = type.createRule(); if (value instanceof GameRules.BooleanValue) { diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/level/LevelAccessorMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/level/LevelAccessorMixin_API.java index 4f2cb331af9..1811c43c8c0 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/level/LevelAccessorMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/level/LevelAccessorMixin_API.java @@ -108,15 +108,15 @@ public interface LevelAccessorMixin_API { // Volume - default Vector3i protoWorld$getBlockMin() { + default Vector3i protoWorld$blockMin() { throw new UnsupportedOperationException("Unfortunately, you've found an extended class of IWorld that isn't part of Sponge API: " + this.getClass()); } - default Vector3i protoWorld$getBlockMax() { + default Vector3i protoWorld$blockMax() { throw new UnsupportedOperationException("Unfortunately, you've found an extended class of IWorld that isn't part of Sponge API: " + this.getClass()); } - default Vector3i protoWorld$getBlockSize() { + default Vector3i protoWorld$blockSize() { throw new UnsupportedOperationException("Unfortunately, you've found an extended class of IWorld that isn't part of Sponge API: " + this.getClass()); } @@ -130,20 +130,20 @@ public interface LevelAccessorMixin_API { // EntityVolume - default Optional protoWorld$getEntity(final UUID uuid) { + default Optional protoWorld$entity(final UUID uuid) { throw new UnsupportedOperationException("Unfortunately, you've found an extended class of IWorld that isn't part of Sponge API: " + this.getClass()); } // RandomProvider @Intrinsic - default Random protoWorld$getRandom() { + default Random protoWorld$random() { return this.shadow$getRandom(); } // ProtoWorld - default Difficulty protoWorld$getDifficulty() { + default Difficulty protoWorld$difficulty() { return (Difficulty) (Object) this.shadow$getLevelData().getDifficulty(); } @@ -152,14 +152,14 @@ public interface LevelAccessorMixin_API { final List entitiesToSpawn = new ArrayList<>(); entities.forEach(entitiesToSpawn::add); - final SpawnEntityEvent.Custom event = SpongeEventFactory.createSpawnEntityEventCustom(PhaseTracker.getCauseStackManager().getCurrentCause(), entitiesToSpawn); - if (Sponge.getEventManager().post(event)) { + final SpawnEntityEvent.Custom event = SpongeEventFactory.createSpawnEntityEventCustom(PhaseTracker.getCauseStackManager().currentCause(), entitiesToSpawn); + if (Sponge.eventManager().post(event)) { return Collections.emptyList(); } - for (final Entity entity : event.getEntities()) { + for (final Entity entity : event.entities()) { EntityUtil.processEntitySpawn(entity, Optional::empty); } - return Collections.unmodifiableCollection(new ArrayList<>(event.getEntities())); + return Collections.unmodifiableCollection(new ArrayList<>(event.entities())); } default boolean protoWorld$spawnEntity(final Entity entity) { diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/level/LevelMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/level/LevelMixin_API.java index e93d6651ca7..9304667e5d2 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/level/LevelMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/level/LevelMixin_API.java @@ -116,12 +116,12 @@ public abstract class LevelMixin_API, L extends Location getClosestPlayer(final int x, final int y, final int z, final double distance, final Predicate predicate) { + public Optional closestPlayer(final int x, final int y, final int z, final double distance, final Predicate predicate) { return Optional.ofNullable((Player) ((net.minecraft.world.level.Level) (Object) this).getNearestPlayer(x, y, z, distance, (Predicate) Objects.requireNonNull(predicate, "predicate"))); } @Override - public Chunk getChunk(final int cx, final int cy, final int cz) { + public Chunk chunk(final int cx, final int cy, final int cz) { return (Chunk) ((net.minecraft.world.level.Level) (Object) this).getChunk(cx >> 4, cz >> 4, ChunkStatus.EMPTY, true); } @@ -141,7 +141,7 @@ public Optional loadChunk(final int cx, final int cy, final int cz, final } @Override - public Iterable getLoadedChunks() { + public Iterable loadedChunks() { final ChunkSource chunkProvider = ((LevelAccessor) this).getChunkSource(); if (chunkProvider instanceof ServerChunkCache) { final ChunkMapAccessor chunkManager = (ChunkMapAccessor) ((ServerChunkCache) chunkProvider).chunkMap; @@ -160,31 +160,31 @@ public Iterable getLoadedChunks() { // BlockVolume @Override - public int getHighestYAt(final int x, final int z) { - return this.getHeight(HeightTypes.WORLD_SURFACE.get(), x, z); + public int highestYAt(final int x, final int z) { + return this.height(HeightTypes.WORLD_SURFACE.get(), x, z); } // Volume @Override - public Vector3i getBlockMin() { + public Vector3i blockMin() { return Constants.World.BLOCK_MIN; } @Override - public Vector3i getBlockMax() { + public Vector3i blockMax() { return Constants.World.BIOME_MAX; } @Override - public Vector3i getBlockSize() { + public Vector3i blockSize() { return Constants.World.BLOCK_SIZE; } // ContextSource @Override - public Context getContext() { + public Context context() { if (this.impl$context == null) { this.impl$context = new Context(Context.WORLD_KEY, this.shadow$dimension().location().toString()); } @@ -259,7 +259,7 @@ public void playSound(final Sound sound, final double x, final double y, final d } @Override - public Collection getBlockEntities() { + public Collection blockEntities() { return (Collection) Collections.unmodifiableCollection(this.blockEntityList); } @@ -297,14 +297,14 @@ public ArchetypeVolume createArchetypeVolume(final Vector3i min, final Vector3i final Vector3i volMax = max.max(min); final SpongeArchetypeVolume volume = new SpongeArchetypeVolume(adjustedVolMin, volMax.sub(rawVolMin).add(1, 1, 1), this.registries()); - this.getBlockStateStream(min, max, StreamOptions.lazily()) + this.blockStateStream(min, max, StreamOptions.lazily()) .apply(VolumeCollectors.of( volume, VolumePositionTranslators.offset(origin), VolumeApplicators.applyBlocks() )); - this.getBlockEntityStream(min, max, StreamOptions.lazily()) + this.blockEntityStream(min, max, StreamOptions.lazily()) .map((world, blockEntity, x, y, z) -> blockEntity.get().createArchetype()) .apply(VolumeCollectors.of( volume, @@ -312,14 +312,14 @@ public ArchetypeVolume createArchetypeVolume(final Vector3i min, final Vector3i VolumeApplicators.applyBlockEntityArchetypes() )); - this.getBiomeStream(min, max, StreamOptions.lazily()) + this.biomeStream(min, max, StreamOptions.lazily()) .apply(VolumeCollectors.of( volume, VolumePositionTranslators.offset(origin), VolumeApplicators.applyBiomes() )); - this.getEntityStream(min, max, StreamOptions.lazily()) + this.entityStream(min, max, StreamOptions.lazily()) .map((world, entity, x, y, z) -> entity.get().createArchetype()) .apply(VolumeCollectors.of( volume, @@ -336,18 +336,18 @@ public ArchetypeVolume createArchetypeVolume(final Vector3i min, final Vector3i // EntityVolume @Override - public Optional getEntity(final UUID uuid) { + public Optional entity(final UUID uuid) { throw new UnsupportedOperationException("Unfortunately, you've found an extended class of Level that isn't part of Sponge API"); } @Override - public Collection getPlayers() { + public Collection players() { throw new UnsupportedOperationException("Unfortunately, you've found an extended class of Level that isn't part of Sponge API"); } @SuppressWarnings("unchecked") @Override - public VolumeStream getEntityStream(final Vector3i min, final Vector3i max, final StreamOptions options) { + public VolumeStream entityStream(final Vector3i min, final Vector3i max, final StreamOptions options) { VolumeStreamUtils.validateStreamArgs(Objects.requireNonNull(min, "min"), Objects.requireNonNull(max, "max"), Objects.requireNonNull(options, "options")); @@ -379,8 +379,8 @@ public VolumeStream getEntityStream(final Vector3i min, final Vector3 // Filtered Position Entity Accessor (entityUuid, world) -> { final net.minecraft.world.entity.@Nullable Entity entity = shouldCarbonCopy - ? (net.minecraft.world.entity.Entity) backingVolume.getEntity(entityUuid).orElse(null) - : (net.minecraft.world.entity.Entity) ((ProtoWorld) world).getEntity(entityUuid).orElse(null); + ? (net.minecraft.world.entity.Entity) backingVolume.entity(entityUuid).orElse(null) + : (net.minecraft.world.entity.Entity) ((ProtoWorld) world).entity(entityUuid).orElse(null); if (entity == null) { return null; } diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/level/LevelReaderMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/level/LevelReaderMixin_API.java index 5ebdd5da310..828fd8dae10 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/level/LevelReaderMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/level/LevelReaderMixin_API.java @@ -67,7 +67,6 @@ @SuppressWarnings({"RedundantTypeArguments", "unchecked", "RedundantCast"}) @Mixin(LevelReader.class) -@Implements(@Interface(iface = Region.class, prefix = "region$")) public interface LevelReaderMixin_API> extends Region { // @formatter:off @@ -86,12 +85,12 @@ public interface LevelReaderMixin_API> extends Region { // Region @Override - default WorldType getWorldType() { + default WorldType worldType() { return (WorldType) this.shadow$dimensionType(); } @Override - default WorldBorder getBorder() { + default WorldBorder border() { return (WorldBorder) ((CollisionGetter) this).getWorldBorder(); } @@ -112,18 +111,18 @@ default boolean hasLiquid(final int x, final int y, final int z) { @Override default boolean containsAnyLiquids(final AABB aabb) { - final Vector3d max = Objects.requireNonNull(aabb, "aabb").getMax(); - final Vector3d min = aabb.getMin(); + final Vector3d max = Objects.requireNonNull(aabb, "aabb").max(); + final Vector3d min = aabb.min(); return this.shadow$containsAnyLiquid(new net.minecraft.world.phys.AABB(min.getX(), min.getY(), min.getZ(), max.getX(), max.getY(), max.getZ())); } @Override - default int getSkylightSubtracted() { + default int skylightSubtracted() { return this.shadow$getSkyDarken(); } - @Intrinsic - default int region$getSeaLevel() { + @Override + default int seaLevel() { return this.shadow$getSeaLevel(); } @@ -136,7 +135,7 @@ default boolean isAreaLoaded(final int xStart, final int yStart, final int zStar // RandomProvider @Override - default Random getRandom() { + default Random random() { return new Random(); } @@ -146,7 +145,7 @@ default Random getRandom() { @SuppressWarnings("ConstantConditions") @Override - default ProtoChunk<@NonNull ?> getChunk(final int x, final int y, final int z) { + default ProtoChunk<@NonNull ?> chunk(final int x, final int y, final int z) { return (ProtoChunk<@NonNull ?>) this.shadow$getChunk(x >> 4, z >> 4, ChunkStatus.EMPTY, true); } @@ -169,17 +168,17 @@ default boolean hasChunk(final Vector3i position) { // HeightAwareVolume @Override - default int getHeight(final HeightType type, final int x, final int z) { + default int height(final HeightType type, final int x, final int z) { return this.shadow$getHeight((Heightmap.Types) (Object) Objects.requireNonNull(type, "type"), x, z); } @Override - default Biome getBiome(final int x, final int y, final int z) { + default Biome biome(final int x, final int y, final int z) { return (Biome) (Object) this.shadow$getBiome(new BlockPos(x, y, z)); } @Override - default VolumeStream getBiomeStream(final Vector3i min, final Vector3i max, final StreamOptions options) { + default VolumeStream biomeStream(final Vector3i min, final Vector3i max, final StreamOptions options) { VolumeStreamUtils.validateStreamArgs(Objects.requireNonNull(min, "min"), Objects.requireNonNull(max, "max"), Objects.requireNonNull(options, "options")); @@ -221,7 +220,7 @@ default VolumeStream getBiomeStream(final Vector3i min, final Vector3i } @Override - default VolumeStream getBlockStateStream(final Vector3i min, final Vector3i max, final StreamOptions options) { + default VolumeStream blockStateStream(final Vector3i min, final Vector3i max, final StreamOptions options) { VolumeStreamUtils.validateStreamArgs(Objects.requireNonNull(min, "min"), Objects.requireNonNull(max, "max"), Objects.requireNonNull(options, "options")); @@ -262,7 +261,7 @@ default VolumeStream getBlockStateStream(final Vector3i min, fina } @Override - default VolumeStream getBlockEntityStream(final Vector3i min, final Vector3i max, final StreamOptions options) { + default VolumeStream blockEntityStream(final Vector3i min, final Vector3i max, final StreamOptions options) { VolumeStreamUtils.validateStreamArgs(Objects.requireNonNull(min, "min"), Objects.requireNonNull(max, "max"), Objects.requireNonNull(options, "options")); diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/level/biome/BiomeMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/level/biome/BiomeMixin_API.java index 756aaa586c2..d46f79cdfac 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/level/biome/BiomeMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/level/biome/BiomeMixin_API.java @@ -37,12 +37,12 @@ public abstract class BiomeMixin_API implements Biome { //@formatter:on @Override - public double getTemperature() { + public double temperature() { return this.shadow$getBaseTemperature(); } @Override - public double getHumidity() { + public double humidity() { return this.shadow$getDownfall(); } } diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/level/block/RotationMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/level/block/RotationMixin_API.java index 26925d35204..1d398c10730 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/level/block/RotationMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/level/block/RotationMixin_API.java @@ -43,7 +43,7 @@ public org.spongepowered.api.util.rotation.Rotation and(final org.spongepowered. @SuppressWarnings({"ConstantConditions", "RedundantCast"}) @Override - public int getAngle() { + public int angle() { if ((Rotation) (Object) this == Rotation.NONE) { return 0; } else if ((Rotation) (Object) this == Rotation.CLOCKWISE_90) { diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/level/block/entity/BeaconBlockEntityMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/level/block/entity/BeaconBlockEntityMixin_API.java index 65bd6644b4e..fc4c2a2caa8 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/level/block/entity/BeaconBlockEntityMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/level/block/entity/BeaconBlockEntityMixin_API.java @@ -47,7 +47,7 @@ public abstract class BeaconBlockEntityMixin_API extends BlockEntityMixin_API im // @formatter:on @Override - public int getCompletedLevels() { + public int completedLevels() { return this.levels < 0 ? 0 : this.levels; } diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/level/block/entity/BlockEntityMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/level/block/entity/BlockEntityMixin_API.java index a9e653bd974..36ab5784a23 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/level/block/entity/BlockEntityMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/level/block/entity/BlockEntityMixin_API.java @@ -69,13 +69,12 @@ public abstract class BlockEntityMixin_API implements BlockEntity { @Nullable private LocatableBlock api$LocatableBlock; - @Override - public ServerLocation getLocation() { + public ServerLocation location() { return ServerLocation.of((ServerWorld) this.level, VecHelper.toVector3i(this.shadow$getBlockPos())); } @Override - public ServerLocation getServerLocation() { + public ServerLocation serverLocation() { if (this.level == null) { throw new RuntimeException("The TileEntity has not been spawned in a world yet!"); } @@ -89,17 +88,17 @@ public ServerLocation getServerLocation() { } @Override - public World getWorld() { + public World world() { return (World) this.level; } @Override - public Vector3i getBlockPosition() { + public Vector3i blockPosition() { return VecHelper.toVector3i(this.shadow$getBlockPos()); } @Override - public int getContentVersion() { + public int contentVersion() { return 1; } @@ -108,8 +107,8 @@ public DataContainer toContainer() { final ResourceKey key = (ResourceKey) (Object) Registry.BLOCK_ENTITY_TYPE.getKey(this.type); final DataContainer container = DataContainer.createNew() - .set(Queries.CONTENT_VERSION, this.getContentVersion()) - .set(Queries.WORLD_KEY, ((ServerWorld) this.level).getKey()) + .set(Queries.CONTENT_VERSION, this.contentVersion()) + .set(Queries.WORLD_KEY, ((ServerWorld) this.level).key()) .set(Queries.POSITION_X, this.shadow$getBlockPos().getX()) .set(Queries.POSITION_Y, this.shadow$getBlockPos().getY()) .set(Queries.POSITION_Z, this.shadow$getBlockPos().getZ()) @@ -146,12 +145,12 @@ public void setValid(final boolean valid) { } @Override - public final BlockEntityType getType() { + public final BlockEntityType type() { return (BlockEntityType) this.type; } @Override - public BlockState getBlock() { + public BlockState block() { return (BlockState) this.level.getBlockState(this.shadow$getBlockPos()); } @@ -164,9 +163,9 @@ public BlockEntityArchetype createArchetype() { } @Override - public LocatableBlock getLocatableBlock() { + public LocatableBlock locatableBlock() { if (this.api$LocatableBlock == null) { - final BlockState blockState = this.getBlock(); + final BlockState blockState = this.block(); this.api$LocatableBlock = new SpongeLocatableBlockBuilder() .world((ServerWorld) this.level) .position(this.shadow$getBlockPos().getX(), this.shadow$getBlockPos().getY(), this.shadow$getBlockPos().getZ()) diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/level/block/entity/BlockEntityTypeMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/level/block/entity/BlockEntityTypeMixin_API.java index bb38027d54a..7b89baa0caa 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/level/block/entity/BlockEntityTypeMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/level/block/entity/BlockEntityTypeMixin_API.java @@ -39,6 +39,6 @@ public abstract class BlockEntityTypeMixin_API implements BlockEntityType { @Override public boolean isValidBlock(final BlockState block) { - return this.shadow$isValid((Block) block.getType()); + return this.shadow$isValid((Block) block.type()); } } diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/level/block/entity/ChestBlockEntityMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/level/block/entity/ChestBlockEntityMixin_API.java index 1aea04818d3..78cbe8992ca 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/level/block/entity/ChestBlockEntityMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/level/block/entity/ChestBlockEntityMixin_API.java @@ -42,7 +42,7 @@ public abstract class ChestBlockEntityMixin_API extends RandomizableContainerBlockEntityMixin_API implements Chest { @Override - public Optional getConnectedChest() { + public Optional connectedChest() { // Based off of the logic in ChestBlock.getChestInventory but without a blocked check and returning the TE instead of the inventory. ChestBlockEntity chestTileEntity = (ChestBlockEntity) (Object) this; BlockState chestState = chestTileEntity.getBlockState(); diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/level/block/entity/CommandBlockEntityMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/level/block/entity/CommandBlockEntityMixin_API.java index 71361a5c818..9df1714149e 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/level/block/entity/CommandBlockEntityMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/level/block/entity/CommandBlockEntityMixin_API.java @@ -48,7 +48,7 @@ public void execute() { } @Override - public String getName() { + public String name() { return this.shadow$getCommandBlock().getName().getString(); } @@ -79,7 +79,7 @@ public DataContainer toContainer() { } @Override - public String getIdentifier() { + public String identifier() { return this.shadow$getCommandBlock().getName().getString(); } } diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/level/block/state/BlockBehaviour_BlockStateBaseMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/level/block/state/BlockBehaviour_BlockStateBaseMixin_API.java index d771e17b5f2..1ccf24608ba 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/level/block/state/BlockBehaviour_BlockStateBaseMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/level/block/state/BlockBehaviour_BlockStateBaseMixin_API.java @@ -46,12 +46,12 @@ public abstract class BlockBehaviour_BlockStateBaseMixin_API extends StateHolder // @formatter:on @Override - public BlockType getType() { + public BlockType type() { return (BlockType) this.shadow$getBlock(); } @Override - public org.spongepowered.api.fluid.FluidState getFluidState() { + public org.spongepowered.api.fluid.FluidState fluidState() { return (org.spongepowered.api.fluid.FluidState) (Object) this.shadow$getFluidState(); } diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/level/block/state/BlockStateMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/level/block/state/BlockStateMixin_API.java index 6d4def4b30e..5984cd092bc 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/level/block/state/BlockStateMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/level/block/state/BlockStateMixin_API.java @@ -54,14 +54,14 @@ public abstract class BlockStateMixin_API extends BlockBehaviour_BlockStateBaseM private String api$serializedState; @Override - public int getContentVersion() { + public int contentVersion() { return Constants.Sponge.BlockState.STATE_AS_CATALOG_ID; } @Override public DataContainer toContainer() { return DataContainer.createNew() - .set(Queries.CONTENT_VERSION, this.getContentVersion()) + .set(Queries.CONTENT_VERSION, this.contentVersion()) .set(Constants.Block.BLOCK_STATE, this.impl$getSerializedString()); } @@ -69,10 +69,10 @@ public DataContainer toContainer() { public BlockSnapshot snapshotFor(final ServerLocation location) { final SpongeBlockSnapshotBuilder builder = SpongeBlockSnapshotBuilder.pooled() .blockState((net.minecraft.world.level.block.state.BlockState) (Object) this) - .position(location.getBlockPosition()) - .world((ServerLevel) location.getWorld()); - if (this.shadow$getBlock().isEntityBlock() && location.getBlock().getType().equals(this.shadow$getBlock())) { - final BlockEntity tileEntity = location.getBlockEntity() + .position(location.blockPosition()) + .world((ServerLevel) location.world()); + if (this.shadow$getBlock().isEntityBlock() && location.block().type().equals(this.shadow$getBlock())) { + final BlockEntity tileEntity = location.blockEntity() .orElseThrow(() -> new IllegalStateException("Unable to retrieve a TileEntity for location: " + location)); builder.add(((SpongeDataHolderBridge) tileEntity).bridge$getManipulator()); final CompoundTag compound = new CompoundTag(); @@ -111,6 +111,6 @@ public BlockState copy() { @Override public List impl$delegateDataHolder() { - return Arrays.asList(this, this.getType()); + return Arrays.asList(this, this.type()); } } diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/level/block/state/StateHolderMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/level/block/state/StateHolderMixin_API.java index c118540c988..8e7dde07c70 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/level/block/state/StateHolderMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/level/block/state/StateHolderMixin_API.java @@ -52,7 +52,7 @@ public abstract class StateHolderMixin_API, C> implements Sta // @formatter:on @Override - public > Optional getStateProperty(StateProperty stateProperty) { + public > Optional stateProperty(StateProperty stateProperty) { if (!this.shadow$hasProperty((Property) stateProperty)) { return Optional.empty(); } @@ -61,8 +61,8 @@ public > Optional getStateProperty(StateProperty s } @Override - public Optional> getStatePropertyByName(String name) { - return this.getStateProperties().stream().filter(p -> p.getName().equals(name)).findFirst(); + public Optional> statePropertyByName(String name) { + return this.stateProperties().stream().filter(p -> p.name().equals(name)).findFirst(); } @Override @@ -96,17 +96,17 @@ public > Optional cycleValue(Key> k } @Override - public Collection> getStateProperties() { + public Collection> stateProperties() { return (Collection) this.shadow$getValues().keySet(); } @Override - public Collection getStatePropertyValues() { + public Collection statePropertyValues() { return this.shadow$getValues().values(); } @Override - public Map, ?> getStatePropertyMap() { + public Map, ?> statePropertyMap() { return (Map) this.shadow$getValues(); } } diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/level/block/state/properties/NoteBlockInstrumentMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/level/block/state/properties/NoteBlockInstrumentMixin_API.java index 2f2aab62dee..a3e4b50ca5f 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/level/block/state/properties/NoteBlockInstrumentMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/level/block/state/properties/NoteBlockInstrumentMixin_API.java @@ -39,7 +39,7 @@ public abstract class NoteBlockInstrumentMixin_API implements InstrumentType { // @formatter:on @Override - public SoundType getSound() { + public SoundType sound() { return (SoundType) this.shadow$getSoundEvent(); } } diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/level/border/WorldBorderMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/level/border/WorldBorderMixin_API.java index 3f82fa31424..075912769e3 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/level/border/WorldBorderMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/level/border/WorldBorderMixin_API.java @@ -58,8 +58,8 @@ public abstract class WorldBorderMixin_API implements WorldBorder { @Shadow public abstract double shadow$getSize(); //@formatter:on - @Intrinsic - public Duration worldBorder$getWarningTime() { + @Override + public Duration warningTime() { return Duration.of(this.shadow$getWarningTime(), ChronoUnit.MILLIS); } @@ -69,7 +69,7 @@ public abstract class WorldBorderMixin_API implements WorldBorder { } @Override - public double getWarningDistance() { + public double warningDistance() { return this.shadow$getWarningBlocks(); } @@ -79,12 +79,12 @@ public void setWarningDistance(final double distance) { } @Override - public double getNewDiameter() { + public double newDiameter() { return this.shadow$getLerpTarget(); } @Override - public double getDiameter() { + public double diameter() { return this.shadow$getSize(); } @@ -95,7 +95,7 @@ public void setDiameter(final double diameter) { @Override public void setDiameter(final double diameter, final Duration time) { - this.shadow$lerpSizeBetween(this.getDiameter(), diameter, time.toMillis()); + this.shadow$lerpSizeBetween(this.diameter(), diameter, time.toMillis()); } @Override @@ -104,12 +104,12 @@ public void setDiameter(final double startDiameter, final double endDiameter, fi } @Override - public Duration getTimeRemaining() { + public Duration timeRemaining() { return Duration.of(this.shadow$getLerpRemainingTime(), ChronoUnit.MILLIS); } @Override - public Vector3d getCenter() { + public Vector3d center() { return new Vector3d(this.getCenterX(), 0, this.getCenterZ()); } @@ -119,7 +119,7 @@ public Vector3d getCenter() { } @Override - public double getDamageThreshold() { + public double damageThreshold() { return this.shadow$getDamageSafeZone(); } @@ -129,7 +129,7 @@ public void setDamageThreshold(final double distance) { } @Override - public double getDamageAmount() { + public double damageAmount() { return this.shadow$getDamagePerBlock(); } diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/level/chunk/LevelChunkMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/level/chunk/LevelChunkMixin_API.java index 54f10f2a15c..89d8ed56480 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/level/chunk/LevelChunkMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/level/chunk/LevelChunkMixin_API.java @@ -98,29 +98,34 @@ public boolean setBiome(final int x, final int y, final int z, final Biome biome } @Override - public Vector3i getChunkPosition() { + public long inhabitedTime() { + return this.inhabitedTime; + } + + @Override + public Vector3i chunkPosition() { return new Vector3i(this.chunkPos.x, 0, this.chunkPos.z); } @Override - public double getRegionalDifficultyFactor() { + public double regionalDifficultyFactor() { return new DifficultyInstance(this.level.getDifficulty(), this.level.getDayTime(), - this.getInhabitedTime(), this.level.getMoonBrightness()).getEffectiveDifficulty(); + this.inhabitedTime(), this.level.getMoonBrightness()).getEffectiveDifficulty(); } @Override - public double getRegionalDifficultyPercentage() { + public double regionalDifficultyPercentage() { return new DifficultyInstance(this.level.getDifficulty(), this.level.getDayTime(), - this.getInhabitedTime(), this.level.getMoonBrightness()).getSpecialMultiplier(); + this.inhabitedTime(), this.level.getMoonBrightness()).getSpecialMultiplier(); } @Override - public org.spongepowered.api.world.World getWorld() { + public org.spongepowered.api.world.World world() { return ((org.spongepowered.api.world.World) this.level); } @Override - public VolumeStream getEntityStream( + public VolumeStream entityStream( Vector3i min, Vector3i max, StreamOptions options ) { VolumeStreamUtils.validateStreamArgs( @@ -148,8 +153,8 @@ public VolumeStream getEntityStream( // Filtered Position Entity Accessor (entityUuid, chunk) -> { final net.minecraft.world.entity.@Nullable Entity entity = shouldCarbonCopy - ? (net.minecraft.world.entity.Entity) backingVolume.getEntity(entityUuid).orElse(null) - : (net.minecraft.world.entity.Entity) chunk.getWorld().getEntity(entityUuid).orElse(null); + ? (net.minecraft.world.entity.Entity) backingVolume.entity(entityUuid).orElse(null) + : (net.minecraft.world.entity.Entity) chunk.world().entity(entityUuid).orElse(null); if (entity == null) { return null; } @@ -159,7 +164,7 @@ public VolumeStream getEntityStream( } @Override - public VolumeStream getBlockStateStream( + public VolumeStream blockStateStream( Vector3i min, Vector3i max, StreamOptions options ) { VolumeStreamUtils.validateStreamArgs(Objects.requireNonNull(min, "min"), Objects.requireNonNull(max, "max"), @@ -200,7 +205,7 @@ public VolumeStream getBlockStateStream( } @Override - public VolumeStream getBlockEntityStream( + public VolumeStream blockEntityStream( Vector3i min, Vector3i max, StreamOptions options ) { VolumeStreamUtils.validateStreamArgs(Objects.requireNonNull(min, "min"), Objects.requireNonNull(max, "max"), @@ -229,7 +234,7 @@ public VolumeStream getBlockEntityStream( // Filtered Position Entity Accessor (blockPos, world) -> { final net.minecraft.world.level.block.entity.@Nullable BlockEntity tileEntity = shouldCarbonCopy - ? (net.minecraft.world.level.block.entity.BlockEntity) backingVolume.getBlockEntity(blockPos.getX(), blockPos.getY(), blockPos.getZ()) + ? (net.minecraft.world.level.block.entity.BlockEntity) backingVolume.blockEntity(blockPos.getX(), blockPos.getY(), blockPos.getZ()) .orElse(null) : ((LevelReader) world).getBlockEntity(blockPos); return new Tuple<>(blockPos, tileEntity); @@ -242,7 +247,7 @@ public VolumeStream getBlockEntityStream( } @Override - public VolumeStream getBiomeStream( + public VolumeStream biomeStream( Vector3i min, Vector3i max, StreamOptions options ) { VolumeStreamUtils.validateStreamArgs(Objects.requireNonNull(min, "min"), Objects.requireNonNull(max, "max"), @@ -274,7 +279,7 @@ public VolumeStream getBiomeStream( (blockPos, world) -> { final net.minecraft.world.level.biome.Biome biome = shouldCarbonCopy ? backingVolume.getNativeBiome(blockPos.getX(), blockPos.getY(), blockPos.getZ()) - : ((LevelReader) world.getWorld()).getBiome(blockPos); + : ((LevelReader) world.world()).getBiome(blockPos); return new Tuple<>(blockPos, biome); } ); diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/level/dimension/DimensionTypeMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/level/dimension/DimensionTypeMixin_API.java index f5146cfbf98..d34c1536123 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/level/dimension/DimensionTypeMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/level/dimension/DimensionTypeMixin_API.java @@ -75,7 +75,7 @@ public abstract class DimensionTypeMixin_API implements WorldType { @Nullable private Context api$context; @Override - public Context getContext() { + public Context context() { if (this.api$context == null) { final ResourceLocation key = SpongeCommon.getServer().registryAccess().dimensionTypes().getKey((DimensionType) (Object) this); this.api$context = new Context(Context.DIMENSION_KEY, key.getPath()); diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/level/material/FluidMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/level/material/FluidMixin_API.java index 0c6906d7354..5baae4334df 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/level/material/FluidMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/level/material/FluidMixin_API.java @@ -44,22 +44,22 @@ public abstract class FluidMixin_API implements FluidType { // @formatter:on @Override - public ImmutableList getValidStates() { + public ImmutableList validStates() { return (ImmutableList) this.shadow$getStateDefinition().getPossibleStates(); } @Override - public FluidState getDefaultState() { + public FluidState defaultState() { return (FluidState) (Object) this.shadow$defaultFluidState(); } @Override - public Collection> getStateProperties() { + public Collection> stateProperties() { return (Collection) this.shadow$getStateDefinition().getProperties(); } @Override - public Optional> getStatePropertyByName(final String name) { + public Optional> statePropertyByName(final String name) { return Optional.ofNullable((StateProperty) this.shadow$getStateDefinition().getProperty(name)); } } diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/level/material/FluidStateMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/level/material/FluidStateMixin_API.java index d5ea2d1426d..10f4b9cde8b 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/level/material/FluidStateMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/level/material/FluidStateMixin_API.java @@ -45,12 +45,12 @@ public abstract class FluidStateMixin_API implements FluidState { // @formatter:on @Override - public BlockState getBlock() { + public BlockState block() { return (BlockState) this.shadow$createLegacyBlock(); } - @Intrinsic - public FluidType fluidState$getType() { + @Override + public FluidType type() { return (FluidType) this.shadow$getType(); } diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/level/storage/LevelDataMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/level/storage/LevelDataMixin_API.java index c6284085d10..b036a19d8a2 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/level/storage/LevelDataMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/level/storage/LevelDataMixin_API.java @@ -86,7 +86,7 @@ default Vector3i spawnPosition() { } @Override - default V getGameRule(final GameRule gameRule) { + default V gameRule(final GameRule gameRule) { final GameRules.Value value = this.shadow$getGameRules().getRule((GameRules.Key) (Object) Objects.requireNonNull(gameRule, "gameRule")); if (value instanceof GameRules.BooleanValue) { @@ -106,8 +106,8 @@ default void setGameRule(final GameRule gameRule, final V value) { ((GameRules_ValueAccessor) mValue).invoker$deserialize(value.toString()); } - @Intrinsic - default Map, ?> worldProperties$getGameRules() { + @Override + default Map, ?> gameRules() { final Map, GameRules.Value> rules = ((GameRulesAccessor) this.shadow$getGameRules()).accessor$rules(); diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/level/storage/PrimaryLevelDataMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/level/storage/PrimaryLevelDataMixin_API.java index 9c2832164d7..e7e77c2b47a 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/level/storage/PrimaryLevelDataMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/level/storage/PrimaryLevelDataMixin_API.java @@ -65,7 +65,7 @@ public abstract class PrimaryLevelDataMixin_API implements ServerWorldProperties // @formatter:on @Override - public ResourceKey getKey() { + public ResourceKey key() { return ((ResourceKeyBridge) this).bridge$getKey(); } @@ -120,7 +120,7 @@ public void setPvp(final boolean pvp) { } @Override - public UUID getUniqueId() { + public UUID uniqueId() { return ((PrimaryLevelDataBridge) this).bridge$uniqueId(); } diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/level/storage/ServerLevelDataMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/level/storage/ServerLevelDataMixin_API.java index e859a9d1274..4cd8dab3a53 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/level/storage/ServerLevelDataMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/level/storage/ServerLevelDataMixin_API.java @@ -24,20 +24,14 @@ */ package org.spongepowered.common.mixin.api.mcp.world.level.storage; -import net.kyori.adventure.text.Component; import net.minecraft.world.level.GameType; import net.minecraft.world.level.storage.ServerLevelData; import org.checkerframework.checker.nullness.qual.Nullable; -import org.spongepowered.api.ResourceKey; import org.spongepowered.api.entity.living.player.gamemode.GameMode; import org.spongepowered.api.entity.living.trader.WanderingTrader; import org.spongepowered.api.util.MinecraftDayTime; import org.spongepowered.api.util.Ticks; -import org.spongepowered.api.world.SerializationBehavior; import org.spongepowered.api.world.WorldBorder; -import org.spongepowered.api.world.WorldType; -import org.spongepowered.api.world.generation.config.WorldGenerationConfig; -import org.spongepowered.api.world.server.ServerWorld; import org.spongepowered.api.world.server.storage.ServerWorldProperties; import org.spongepowered.api.world.weather.Weather; import org.spongepowered.api.world.weather.WeatherType; @@ -53,7 +47,6 @@ import org.spongepowered.common.world.weather.SpongeWeatherType; import java.util.Objects; -import java.util.Optional; import java.util.UUID; @SuppressWarnings("ConstantConditions") @@ -84,7 +77,7 @@ public interface ServerLevelDataMixin_API extends ServerWorldProperties { @Override default void setDayTime(final MinecraftDayTime dayTime) { - this.shadow$setDayTime(dayTime.asTicks().getTicks()); + this.shadow$setDayTime(dayTime.asTicks().ticks()); } @Override @@ -129,7 +122,7 @@ default void setWanderingTraderSpawnChance(final int chance) { @Override default void setWanderingTrader(@Nullable final WanderingTrader trader) { - this.shadow$setWanderingTraderId(trader == null ? null : trader.getUniqueId()); + this.shadow$setWanderingTraderId(trader == null ? null : trader.uniqueId()); } @Override @@ -150,7 +143,7 @@ default void setWeather(final WeatherType type) { @Override default void setWeather(final WeatherType type, final Ticks ticks) { Objects.requireNonNull(type, "type"); - final long time = Objects.requireNonNull(ticks, "ticks").getTicks(); + final long time = Objects.requireNonNull(ticks, "ticks").ticks(); if (type == WeatherTypes.CLEAR.get()) { this.shadow$setClearWeatherTime((int) time); diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/scores/PlayerTeamMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/scores/PlayerTeamMixin_API.java index 87817ce5bcf..421cd318f48 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/scores/PlayerTeamMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/scores/PlayerTeamMixin_API.java @@ -70,13 +70,13 @@ public abstract class PlayerTeamMixin_API implements Team { @Shadow public abstract Collection shadow$getPlayers(); // @formatter:on - @Intrinsic - public String team$getName() { + @Override + public String name() { return this.name; } @Override - public Component getDisplayName() { + public Component displayName() { return ((PlayerTeamBridge) this).bridge$getDisplayName(); } @@ -86,7 +86,7 @@ public void setDisplayName(final Component text) { } @Override - public NamedTextColor getColor() { + public NamedTextColor color() { return ((PlayerTeamBridge) this).bridge$getColor(); } @@ -96,7 +96,7 @@ public void setColor(final NamedTextColor color) { } @Override - public Component getPrefix() { + public Component prefix() { return ((PlayerTeamBridge) this).bridge$getPrefix(); } @@ -106,7 +106,7 @@ public void setPrefix(final Component prefix) { } @Override - public Component getSuffix() { + public Component suffix() { return ((PlayerTeamBridge) this).bridge$getSuffix(); } @@ -137,7 +137,7 @@ public void setCanSeeFriendlyInvisibles(final boolean enabled) { @SuppressWarnings("ConstantConditions") @Override - public Visibility getNameTagVisibility() { + public Visibility nameTagVisibility() { return (Visibility) (Object) this.shadow$getNameTagVisibility(); } @@ -149,7 +149,7 @@ public void setNameTagVisibility(final Visibility visibility) { @SuppressWarnings("ConstantConditions") @Override - public Visibility getDeathMessageVisibility() { + public Visibility deathMessageVisibility() { return (Visibility) (Object) this.shadow$getDeathMessageVisibility(); } @@ -161,7 +161,7 @@ public void setDeathMessageVisibility(final Visibility visibility) { @SuppressWarnings("ConstantConditions") @Override - public org.spongepowered.api.scoreboard.CollisionRule getCollisionRule() { + public org.spongepowered.api.scoreboard.CollisionRule collisionRule() { return (org.spongepowered.api.scoreboard.CollisionRule) (Object) this.shadow$getCollisionRule(); } @@ -172,7 +172,7 @@ public void setCollisionRule(final org.spongepowered.api.scoreboard.CollisionRul } @Override - public Set getMembers() { + public Set members() { return this.shadow$getPlayers().stream().map(SpongeAdventure::legacySection).collect(Collectors.toSet()); } @@ -206,7 +206,7 @@ public boolean removeMember(final Component member) { } @Override - public Optional getScoreboard() { + public Optional scoreboard() { return Optional.ofNullable((org.spongepowered.api.scoreboard.Scoreboard) this.scoreboard); } diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/scores/criteria/ObjectiveCriteriaMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/scores/criteria/ObjectiveCriteriaMixin_API.java index cb75926904d..1089add5b6e 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/scores/criteria/ObjectiveCriteriaMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/scores/criteria/ObjectiveCriteriaMixin_API.java @@ -38,7 +38,7 @@ public abstract class ObjectiveCriteriaMixin_API implements Criterion { // @formatter:on @Override - public ObjectiveDisplayMode getDisplayMode() { + public ObjectiveDisplayMode displayMode() { return (ObjectiveDisplayMode) (Object) this.shadow$getDefaultRenderType(); } } diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/storage/MapItemSavedDataMixin.java b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/storage/MapItemSavedDataMixin.java index 8a3766e3b95..106511994fe 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/storage/MapItemSavedDataMixin.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mcp/world/storage/MapItemSavedDataMixin.java @@ -141,7 +141,7 @@ public MapItemSavedDataMixin(final String name) { } catch (final NumberFormatException e) { SpongeCommon.getLogger().error("Map id could not be got from map name, (" + mapname + ")", e); } - final SpongeMapStorage mapStorage = (SpongeMapStorage) Sponge.getServer().getMapStorage(); + final SpongeMapStorage mapStorage = (SpongeMapStorage) Sponge.server().mapStorage(); mapStorage.addMapInfo((MapInfo) this); this.impl$uuid = mapStorage.requestUUID(this.impl$mapId); } diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/mojang/authlib/properties/PropertyMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/mojang/authlib/properties/PropertyMixin_API.java index 8aa4a955138..2609eee92ee 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/mojang/authlib/properties/PropertyMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/mojang/authlib/properties/PropertyMixin_API.java @@ -43,7 +43,17 @@ public abstract class PropertyMixin_API implements ProfileProperty { @Shadow @Final private @Nullable String signature; @Override - public Optional getSignature() { // We don't need to make this @Implements because the signature difference + public String name() { + return this.name; + } + + @Override + public String value() { + return this.value; + } + + @Override + public Optional signature() { // We don't need to make this @Implements because the signature difference return Optional.ofNullable(this.signature); } @@ -58,9 +68,9 @@ public boolean equals(final Object obj) { return false; } final ProfileProperty other = (ProfileProperty) obj; - return other.getName().equals(this.name) && - other.getValue().equals(this.value) && - Objects.equals(other.getSignature().orElse(null), this.signature); + return other.name().equals(this.name) && + other.value().equals(this.value) && + Objects.equals(other.signature().orElse(null), this.signature); } @Override diff --git a/src/mixins/java/org/spongepowered/common/mixin/api/world/gen/Heightmap_TypeMixin_API.java b/src/mixins/java/org/spongepowered/common/mixin/api/world/gen/Heightmap_TypeMixin_API.java index 2123f1c2023..a38e600ad98 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/api/world/gen/Heightmap_TypeMixin_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/api/world/gen/Heightmap_TypeMixin_API.java @@ -42,7 +42,7 @@ public abstract class Heightmap_TypeMixin_API implements HeightType { // @formatter:on @Override - public BlockReaderAwareMatcher getMatcher() { + public BlockReaderAwareMatcher matcher() { return (state, volume, position) -> this.isOpaque.test((net.minecraft.world.level.block.state.BlockState) state); } } diff --git a/src/mixins/java/org/spongepowered/common/mixin/concurrentcheck/util/ClassInstanceMultiMapMixin_ConcurrentCheck.java b/src/mixins/java/org/spongepowered/common/mixin/concurrentcheck/util/ClassInstanceMultiMapMixin_ConcurrentCheck.java index 25374fbcb74..c2e601c1921 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/concurrentcheck/util/ClassInstanceMultiMapMixin_ConcurrentCheck.java +++ b/src/mixins/java/org/spongepowered/common/mixin/concurrentcheck/util/ClassInstanceMultiMapMixin_ConcurrentCheck.java @@ -39,7 +39,7 @@ public abstract class ClassInstanceMultiMapMixin_ConcurrentCheck { @Inject(method = "add", at = @At("HEAD"), cancellable = true) private void concurrentCheck$checkThreadOnAdd(final Object entity, final CallbackInfoReturnable cir) { // This class gets used on the client, but we only care about the server - if (SpongeCommon.getGame().getPlatform().getExecutionType() != Platform.Type.CLIENT && !PlatformHooks.INSTANCE + if (SpongeCommon.getGame().platform().executionType() != Platform.Type.CLIENT && !PlatformHooks.INSTANCE .getGeneralHooks() .onServerThread()) { Thread.dumpStack(); @@ -52,7 +52,7 @@ public abstract class ClassInstanceMultiMapMixin_ConcurrentCheck { @Inject(method = "remove", at = @At("HEAD"), cancellable = true) private void concurrentCheck$checkServerThreadSide(final Object entity, final CallbackInfoReturnable cir) { - if (SpongeCommon.getGame().getPlatform().getExecutionType() != Platform.Type.CLIENT && !PlatformHooks.INSTANCE + if (SpongeCommon.getGame().platform().executionType() != Platform.Type.CLIENT && !PlatformHooks.INSTANCE .getGeneralHooks() .onServerThread()) { Thread.dumpStack(); diff --git a/src/mixins/java/org/spongepowered/common/mixin/core/advancements/AdvancementMixin.java b/src/mixins/java/org/spongepowered/common/mixin/core/advancements/AdvancementMixin.java index bd82ebf3b76..d94ff53fed6 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/core/advancements/AdvancementMixin.java +++ b/src/mixins/java/org/spongepowered/common/mixin/core/advancements/AdvancementMixin.java @@ -108,7 +108,7 @@ public abstract class AdvancementMixin implements AdvancementBridge { } for (Map.Entry> groupEntry : scoreCriteria.entrySet()) { criteriaMap.put(groupEntry.getKey(), new SpongeScoreCriterion(groupEntry.getKey(), groupEntry.getValue())); - groupEntry.getValue().forEach(c -> criteriaMap.remove(c.getName())); + groupEntry.getValue().forEach(c -> criteriaMap.remove(c.name())); } final Set andCriteria = new HashSet<>(); diff --git a/src/mixins/java/org/spongepowered/common/mixin/core/advancements/AdvancementProgressMixin.java b/src/mixins/java/org/spongepowered/common/mixin/core/advancements/AdvancementProgressMixin.java index 94f43b45a33..8ffabcdf643 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/core/advancements/AdvancementProgressMixin.java +++ b/src/mixins/java/org/spongepowered/common/mixin/core/advancements/AdvancementProgressMixin.java @@ -131,7 +131,7 @@ public abstract class AdvancementProgressMixin implements AdvancementProgressBri final Optional advancement = this.getOptionalAdvancement(); if (advancement.isPresent()) { this.impl$progressMap = new LinkedHashMap<>(); - this.impl$processProgressMap(advancement.get().getCriterion(), this.impl$progressMap); + this.impl$processProgressMap(advancement.get().criterion(), this.impl$progressMap); } else { this.impl$progressMap = null; } @@ -171,26 +171,26 @@ public abstract class AdvancementProgressMixin implements AdvancementProgressBri private void impl$processProgressMap(AdvancementCriterion criterion, Map progressMap) { if (criterion instanceof OperatorCriterion) { - ((OperatorCriterion) criterion).getCriteria().forEach(child -> this.impl$processProgressMap(child, progressMap)); + ((OperatorCriterion) criterion).criteria().forEach(child -> this.impl$processProgressMap(child, progressMap)); if (criterion instanceof AndCriterion) { - progressMap.put(criterion.getName(), new SpongeAndCriterionProgress((org.spongepowered.api.advancement.AdvancementProgress) this, (SpongeAndCriterion) criterion)); + progressMap.put(criterion.name(), new SpongeAndCriterionProgress((org.spongepowered.api.advancement.AdvancementProgress) this, (SpongeAndCriterion) criterion)); } else if (criterion instanceof OrCriterion) { - progressMap.put(criterion.getName(), new SpongeOrCriterionProgress((org.spongepowered.api.advancement.AdvancementProgress) this, (SpongeOrCriterion) criterion)); + progressMap.put(criterion.name(), new SpongeOrCriterionProgress((org.spongepowered.api.advancement.AdvancementProgress) this, (SpongeOrCriterion) criterion)); } } else if (criterion instanceof SpongeScoreCriterion) { final SpongeScoreCriterion scoreCriterion = (SpongeScoreCriterion) criterion; for (final AdvancementCriterion internalCriterion : scoreCriterion.internalCriteria) { - final CriterionProgressBridge progress = (CriterionProgressBridge) this.criteria.get(internalCriterion.getName()); + final CriterionProgressBridge progress = (CriterionProgressBridge) this.criteria.get(internalCriterion.name()); progress.bridge$setCriterion(internalCriterion); progress.bridge$setAdvancementProgress((org.spongepowered.api.advancement.AdvancementProgress) this); - progressMap.put(internalCriterion.getName(), (ImplementationBackedCriterionProgress) progress); + progressMap.put(internalCriterion.name(), (ImplementationBackedCriterionProgress) progress); } - progressMap.put(scoreCriterion.getName(), new SpongeScoreCriterionProgress((org.spongepowered.api.advancement.AdvancementProgress) this, scoreCriterion)); + progressMap.put(scoreCriterion.name(), new SpongeScoreCriterionProgress((org.spongepowered.api.advancement.AdvancementProgress) this, scoreCriterion)); } else if (!(criterion instanceof SpongeEmptyCriterion)) { - final CriterionProgressBridge progress = (CriterionProgressBridge) this.criteria.get(criterion.getName()); + final CriterionProgressBridge progress = (CriterionProgressBridge) this.criteria.get(criterion.name()); progress.bridge$setCriterion(criterion); progress.bridge$setAdvancementProgress((org.spongepowered.api.advancement.AdvancementProgress) this); - progressMap.put(criterion.getName(), (ImplementationBackedCriterionProgress) progress); + progressMap.put(criterion.name(), (ImplementationBackedCriterionProgress) progress); } } @@ -206,7 +206,7 @@ public abstract class AdvancementProgressMixin implements AdvancementProgressBri final Advancement advancement = this.getOptionalAdvancement().orElse(null); if (advancement != null) { - final ImplementationBackedCriterionProgress bridge = this.impl$progressMap.get(advancement.getCriterion().getName()); + final ImplementationBackedCriterionProgress bridge = this.impl$progressMap.get(advancement.criterion().name()); ci.setReturnValue(bridge != null && ((CriterionProgress) bridge).achieved()); } } @@ -233,22 +233,22 @@ public abstract class AdvancementProgressMixin implements AdvancementProgressBri criterionProgress.grant(); return true; } - final Cause cause = PhaseTracker.getCauseStackManager().getCurrentCause(); + final Cause cause = PhaseTracker.getCauseStackManager().currentCause(); final ServerPlayer player = ((PlayerAdvancementsBridge) this.impl$playerAdvancements).bridge$getPlayer(); final CriterionProgress progress = (CriterionProgress) criterionProgress; - final AdvancementCriterion criterion = progress.getCriterion(); + final AdvancementCriterion criterion = progress.criterion(); final CriterionBridge criterionBridge = (CriterionBridge) criterion; // The score criterion needs special care final SpongeScoreCriterion scoreCriterion = criterionBridge.bridge$getScoreCriterion(); final CriterionEvent event; if (scoreCriterion != null) { - final SpongeScoreCriterionProgress scoreProgress = (SpongeScoreCriterionProgress) this.impl$progressMap.get(scoreCriterion.getName()); - final int lastScore = scoreProgress.getScore(); + final SpongeScoreCriterionProgress scoreProgress = (SpongeScoreCriterionProgress) this.impl$progressMap.get(scoreCriterion.name()); + final int lastScore = scoreProgress.score(); final int score = lastScore + 1; - if (lastScore == scoreCriterion.getGoal()) { + if (lastScore == scoreCriterion.goal()) { event = SpongeEventFactory.createCriterionEventScoreRevoke( cause, this.bridge$getAdvancement(), scoreCriterion, player, lastScore, score); - } else if (score == scoreCriterion.getGoal()) { + } else if (score == scoreCriterion.goal()) { event = SpongeEventFactory.createCriterionEventScoreGrant( cause, this.bridge$getAdvancement(), scoreCriterion, player, Instant.now(), lastScore, score); } else { @@ -288,24 +288,24 @@ public abstract class AdvancementProgressMixin implements AdvancementProgressBri criterionProgress.revoke(); return true; } - final Cause cause = PhaseTracker.getCauseStackManager().getCurrentCause(); + final Cause cause = PhaseTracker.getCauseStackManager().currentCause(); final ServerPlayer player = ((PlayerAdvancementsBridge) this.impl$playerAdvancements).bridge$getPlayer(); final CriterionProgress progress = (CriterionProgress) criterionProgress; - final AdvancementCriterion criterion = progress.getCriterion(); + final AdvancementCriterion criterion = progress.criterion(); final CriterionBridge criterionBridge = (CriterionBridge) criterion; // The score criterion needs special care final SpongeScoreCriterion scoreCriterion = criterionBridge.bridge$getScoreCriterion(); final CriterionEvent event; - final Advancement advancement = ((org.spongepowered.api.advancement.AdvancementProgress) this).getAdvancement(); + final Advancement advancement = ((org.spongepowered.api.advancement.AdvancementProgress) this).advancement(); if (scoreCriterion != null) { - final SpongeScoreCriterionProgress scoreProgress = (SpongeScoreCriterionProgress) this.impl$progressMap.get(scoreCriterion.getName()); - final int lastScore = scoreProgress.getScore(); + final SpongeScoreCriterionProgress scoreProgress = (SpongeScoreCriterionProgress) this.impl$progressMap.get(scoreCriterion.name()); + final int lastScore = scoreProgress.score(); final int score = lastScore + 1; - if (lastScore == scoreCriterion.getGoal()) { + if (lastScore == scoreCriterion.goal()) { event = SpongeEventFactory.createCriterionEventScoreRevoke( cause, advancement, scoreCriterion, player, lastScore, score); - } else if (score == scoreCriterion.getGoal()) { + } else if (score == scoreCriterion.goal()) { event = SpongeEventFactory.createCriterionEventScoreGrant( cause, advancement, scoreCriterion, player, Instant.now(), lastScore, score); diff --git a/src/mixins/java/org/spongepowered/common/mixin/core/advancements/CriterionMixin.java b/src/mixins/java/org/spongepowered/common/mixin/core/advancements/CriterionMixin.java index 5fd25fc7959..dfad3664e44 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/core/advancements/CriterionMixin.java +++ b/src/mixins/java/org/spongepowered/common/mixin/core/advancements/CriterionMixin.java @@ -71,7 +71,7 @@ public abstract class CriterionMixin implements CriterionBridge { cir.getReturnValue().addProperty("trigger_times", ((SpongeScoreTrigger.Instance) this.trigger).getTriggerTimes()); } if (this.impl$scoreCriterion != null) { - cir.getReturnValue().addProperty("criterion", this.impl$scoreCriterion.getName()); + cir.getReturnValue().addProperty("criterion", this.impl$scoreCriterion.name()); } } diff --git a/src/mixins/java/org/spongepowered/common/mixin/core/advancements/CriterionTrigger_ListenerMixin.java b/src/mixins/java/org/spongepowered/common/mixin/core/advancements/CriterionTrigger_ListenerMixin.java index c5e427d2da4..3a7416f9d6c 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/core/advancements/CriterionTrigger_ListenerMixin.java +++ b/src/mixins/java/org/spongepowered/common/mixin/core/advancements/CriterionTrigger_ListenerMixin.java @@ -77,14 +77,14 @@ public abstract class CriterionTrigger_ListenerMixin { // Sponge filters are always handled in the trigger method if (!(this.trigger instanceof SpongeFilteredTrigger)) { final FilteredTrigger filteredTrigger = (FilteredTrigger) this.trigger; - if (filteredTrigger.getType() instanceof SpongeCriterionTrigger) { - final Cause cause = PhaseTracker.getCauseStackManager().getCurrentCause(); + if (filteredTrigger.type() instanceof SpongeCriterionTrigger) { + final Cause cause = PhaseTracker.getCauseStackManager().currentCause(); final ServerPlayer player = ((PlayerAdvancementsBridge) playerAdvancements).bridge$getPlayer(); - final TypeToken typeToken = TypeToken.get(filteredTrigger.getType().getConfigurationType()); + final TypeToken typeToken = TypeToken.get(filteredTrigger.type().configurationType()); final CriterionEvent.Trigger event = SpongeEventFactory.createCriterionEventTrigger(cause, advancement, advancementCriterion, typeToken, player, filteredTrigger, true); SpongeCommon.postEvent(event); - if (!event.getResult()) { + if (!event.result()) { ci.cancel(); return; } @@ -94,7 +94,7 @@ public abstract class CriterionTrigger_ListenerMixin { // Handle the score criteria ourselves, with each trigger will // the score be increased by one. if (advancementCriterion instanceof ScoreAdvancementCriterion) { - ((PlayerAdvancementsBridge) playerAdvancements).bridge$getPlayer().getProgress(advancement) + ((PlayerAdvancementsBridge) playerAdvancements).bridge$getPlayer().progress(advancement) .get((ScoreAdvancementCriterion) advancementCriterion).get().add(1); ci.cancel(); PhaseTracker.getCauseStackManager().popCause(); diff --git a/src/mixins/java/org/spongepowered/common/mixin/core/advancements/TreeNodePositionMixin.java b/src/mixins/java/org/spongepowered/common/mixin/core/advancements/TreeNodePositionMixin.java index 05189554aae..5ba8a003627 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/core/advancements/TreeNodePositionMixin.java +++ b/src/mixins/java/org/spongepowered/common/mixin/core/advancements/TreeNodePositionMixin.java @@ -44,9 +44,9 @@ public abstract class TreeNodePositionMixin { @Inject(method = "run", at = @At("RETURN")) private static void impl$onLayout(Advancement root, CallbackInfo ci) { - final AdvancementTree advancementTree = ((org.spongepowered.api.advancement.Advancement) root).getTree().get(); + final AdvancementTree advancementTree = ((org.spongepowered.api.advancement.Advancement) root).tree().get(); final TreeLayout layout = new SpongeTreeLayout(advancementTree); - final Cause cause = PhaseTracker.getCauseStackManager().getCurrentCause(); + final Cause cause = PhaseTracker.getCauseStackManager().currentCause(); final AdvancementTreeEvent.GenerateLayout event = SpongeEventFactory.createAdvancementTreeEventGenerateLayout(cause, layout, advancementTree); SpongeCommon.postEvent(event); } diff --git a/src/mixins/java/org/spongepowered/common/mixin/core/authlib/properties/PropertyMixin.java b/src/mixins/java/org/spongepowered/common/mixin/core/authlib/properties/PropertyMixin.java index cb4cf137607..b4ae82bd378 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/core/authlib/properties/PropertyMixin.java +++ b/src/mixins/java/org/spongepowered/common/mixin/core/authlib/properties/PropertyMixin.java @@ -53,8 +53,8 @@ public boolean equals(@Nullable final Object other) { } final ProfileProperty that = (ProfileProperty) other; - return Objects.equal(this.getName(), that.getName()) - && Objects.equal(this.getValue(), that.getValue()) + return Objects.equal(this.getName(), that.name()) + && Objects.equal(this.getValue(), that.value()) && Objects.equal(this.getSignature(), ((Property) that).getSignature()); } diff --git a/src/mixins/java/org/spongepowered/common/mixin/core/client/MinecraftMixin.java b/src/mixins/java/org/spongepowered/common/mixin/core/client/MinecraftMixin.java index 3601da292cc..0c98cde34c6 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/core/client/MinecraftMixin.java +++ b/src/mixins/java/org/spongepowered/common/mixin/core/client/MinecraftMixin.java @@ -24,9 +24,7 @@ */ package org.spongepowered.common.mixin.core.client; -import com.mojang.datafixers.util.Function4; import com.mojang.serialization.DynamicOps; -import io.netty.util.internal.shaded.org.jctools.queues.atomic.LinkedQueueAtomicNode; import net.minecraft.client.Minecraft; import net.minecraft.client.main.GameConfig; import net.minecraft.client.server.IntegratedServer; @@ -40,8 +38,6 @@ import net.minecraft.world.level.storage.LevelResource; import net.minecraft.world.level.storage.LevelStorageSource; import net.minecraft.world.level.storage.WorldData; -import org.checkerframework.checker.units.qual.Area; -import org.checkerframework.common.value.qual.IntRangeFromGTENegativeOne; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; @@ -57,8 +53,6 @@ import org.spongepowered.common.server.BootstrapProperties; import java.nio.file.Path; -import java.util.concurrent.ExecutionException; -import java.util.function.Function; @Mixin(Minecraft.class) public abstract class MinecraftMixin implements MinecraftBridge, SpongeClient { @@ -85,7 +79,7 @@ public abstract class MinecraftMixin implements MinecraftBridge, SpongeClient { @Inject(method = "runTick", at = @At("TAIL")) private void impl$tickClientScheduler(final boolean renderWorldIn, final CallbackInfo ci) { - this.getScheduler().tick(); + this.scheduler().tick(); } @Override @@ -105,7 +99,7 @@ public abstract class MinecraftMixin implements MinecraftBridge, SpongeClient { @Inject(method = "close", at = @At(value = "INVOKE", target = "Lnet/minecraft/Util;shutdownExecutors()V")) private void impl$shutdownAsyncScheduler(final CallbackInfo ci) { - SpongeCommon.getGame().getAsyncScheduler().close(); + SpongeCommon.getGame().asyncScheduler().close(); } @Redirect(method = "loadWorldData", at = @At(value = "INVOKE", target = "Lnet/minecraft/resources/RegistryReadOps;create(Lcom/mojang/serialization/DynamicOps;Lnet/minecraft/server/packs/resources/ResourceManager;Lnet/minecraft/core/RegistryAccess$RegistryHolder;)Lnet/minecraft/resources/RegistryReadOps;")) diff --git a/src/mixins/java/org/spongepowered/common/mixin/core/commands/CommandSourceStackMixin.java b/src/mixins/java/org/spongepowered/common/mixin/core/commands/CommandSourceStackMixin.java index 7a9418fcb93..e51f26bee6d 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/core/commands/CommandSourceStackMixin.java +++ b/src/mixins/java/org/spongepowered/common/mixin/core/commands/CommandSourceStackMixin.java @@ -102,12 +102,12 @@ public abstract class CommandSourceStackMixin implements CommandSourceStackBridg final EntityAnchorArgument.Anchor p_i49553_12_, final CallbackInfo ci ) { - this.impl$cause = PhaseTracker.getCauseStackManager().getCurrentCause(); - final EventContext context = this.impl$cause.getContext(); + this.impl$cause = PhaseTracker.getCauseStackManager().currentCause(); + final EventContext context = this.impl$cause.context(); context.get(EventContextKeys.LOCATION).ifPresent(x ->{ - this.worldPosition = VecHelper.toVanillaVector3d(x.getPosition()); - this.level = (ServerLevel) x.getWorld(); + this.worldPosition = VecHelper.toVanillaVector3d(x.position()); + this.level = (ServerLevel) x.world(); }); context.get(EventContextKeys.ROTATION).ifPresent(x -> this.rotation = new Vec2((float) x.getX(), (float) x.getY())); @@ -164,8 +164,8 @@ public abstract class CommandSourceStackMixin implements CommandSourceStackBridg @Inject(method = "withLevel", at = @At("RETURN")) private void impl$updateCauseOnWithWorld(final ServerLevel serverWorld, final CallbackInfoReturnable cir) { if (cir.getReturnValue() != (Object) this) { - final ServerLocation location = this.impl$cause.getContext().get(EventContextKeys.LOCATION) - .map(x -> ServerLocation.of((org.spongepowered.api.world.server.ServerWorld) serverWorld, x.getPosition())) + final ServerLocation location = this.impl$cause.context().get(EventContextKeys.LOCATION) + .map(x -> ServerLocation.of((org.spongepowered.api.world.server.ServerWorld) serverWorld, x.position())) .orElseGet(() -> ServerLocation.of((org.spongepowered.api.world.server.ServerWorld) serverWorld, VecHelper.toVector3d(cir.getReturnValue().getPosition()))); ((CommandSourceStackBridge) cir.getReturnValue()).bridge$setCause(this.impl$applyToCause(EventContextKeys.LOCATION, location)); @@ -176,8 +176,8 @@ public abstract class CommandSourceStackMixin implements CommandSourceStackBridg private void impl$updateCauseOnWithPosition(final Vec3 pos, final CallbackInfoReturnable cir) { if (cir.getReturnValue() != (Object) this) { final org.spongepowered.math.vector.Vector3d position = VecHelper.toVector3d(pos); - final ServerLocation location = this.impl$cause.getContext().get(EventContextKeys.LOCATION) - .map(x -> ServerLocation.of(x.getWorld(), position)) + final ServerLocation location = this.impl$cause.context().get(EventContextKeys.LOCATION) + .map(x -> ServerLocation.of(x.world(), position)) .orElseGet(() -> ServerLocation.of((org.spongepowered.api.world.server.ServerWorld) cir.getReturnValue().getLevel(), position)); ((CommandSourceStackBridge) cir.getReturnValue()).bridge$setCause(this.impl$applyToCause(EventContextKeys.LOCATION, location)); } @@ -233,7 +233,7 @@ public abstract class CommandSourceStackMixin implements CommandSourceStackBridg } private Cause impl$applyToCause(final EventContextKey key, final T value) { - final EventContext.Builder builder = EventContext.builder().from(this.impl$cause.getContext()); + final EventContext.Builder builder = EventContext.builder().from(this.impl$cause.context()); builder.add(key, value); return Cause.builder().from(this.impl$cause).build(builder.build()); } diff --git a/src/mixins/java/org/spongepowered/common/mixin/core/data/SpongeDataHolderMixin.java b/src/mixins/java/org/spongepowered/common/mixin/core/data/SpongeDataHolderMixin.java index f241e4016e2..3223aefe3be 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/core/data/SpongeDataHolderMixin.java +++ b/src/mixins/java/org/spongepowered/common/mixin/core/data/SpongeDataHolderMixin.java @@ -77,7 +77,7 @@ public abstract class SpongeDataHolderMixin implements SpongeDataHolderBridge { if (this instanceof DataHolder.Mutable && !(this instanceof org.spongepowered.api.item.inventory.ItemStack)) { // Does not work when adding ItemStacks to inventory because the Item may be empty (see Inventory#addResource) for (final Value.Immutable value : manipulator.getValues()) { - final DataProvider provider = SpongeDataManager.getProviderRegistry().getProvider(value.getKey(), this.getClass()); + final DataProvider provider = SpongeDataManager.getProviderRegistry().getProvider(value.key(), this.getClass()); provider.offerValue((DataHolder.Mutable) this, value); } } else { diff --git a/src/mixins/java/org/spongepowered/common/mixin/core/item/ItemEmptyMapMixin.java b/src/mixins/java/org/spongepowered/common/mixin/core/item/ItemEmptyMapMixin.java index ba52bc7e8f7..63f35ed3ed3 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/core/item/ItemEmptyMapMixin.java +++ b/src/mixins/java/org/spongepowered/common/mixin/core/item/ItemEmptyMapMixin.java @@ -69,11 +69,11 @@ public abstract class ItemEmptyMapMixin { frame.addContext(EventContextKeys.PLAYER, player); final HandType handType = (HandType) (Object) usedHand; frame.addContext(EventContextKeys.USED_HAND, handType); - frame.addContext(EventContextKeys.USED_ITEM, player.getItemInHand(handType).createSnapshot()); + frame.addContext(EventContextKeys.USED_ITEM, player.itemInHand(handType).createSnapshot()); final Set> mapValues = Sets.newHashSet( Value.immutableOf(Keys.MAP_LOCATION, Vector2i.from((int)playerIn.getX(), (int)playerIn.getZ())), - Value.immutableOf(Keys.MAP_WORLD, ((ServerWorld)level).getKey()), + Value.immutableOf(Keys.MAP_WORLD, ((ServerWorld)level).key()), Value.immutableOf(Keys.MAP_TRACKS_PLAYERS, trackingPosition), Value.immutableOf(Keys.MAP_UNLIMITED_TRACKING, unlimitedTracking), Value.immutableOf(Keys.MAP_SCALE, (int)scale) @@ -83,7 +83,7 @@ public abstract class ItemEmptyMapMixin { //Value.immutableOf(Keys.MAP_DECORATIONS, Sets.newHashSet()) ); - final Optional optMapInfo = SpongeCommonEventFactory.fireCreateMapEvent(frame.getCurrentCause(), mapValues); + final Optional optMapInfo = SpongeCommonEventFactory.fireCreateMapEvent(frame.currentCause(), mapValues); if (!optMapInfo.isPresent()) { return ItemStack.EMPTY; } diff --git a/src/mixins/java/org/spongepowered/common/mixin/core/network/protocol/game/ClientboundResourcePackPacketMixin.java b/src/mixins/java/org/spongepowered/common/mixin/core/network/protocol/game/ClientboundResourcePackPacketMixin.java index d8879722b34..1e4cd50ffa3 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/core/network/protocol/game/ClientboundResourcePackPacketMixin.java +++ b/src/mixins/java/org/spongepowered/common/mixin/core/network/protocol/game/ClientboundResourcePackPacketMixin.java @@ -57,7 +57,7 @@ public abstract class ClientboundResourcePackPacketMixin implements ClientboundR public void bridge$setSpongePack(final ResourcePack pack) { this.impl$pack = pack; this.url = ((SpongeResourcePack) pack).getUrlString(); - this.hash = pack.getHash().orElse(""); + this.hash = pack.hash().orElse(""); } @Override diff --git a/src/mixins/java/org/spongepowered/common/mixin/core/network/syncher/SynchedEntityDataMixin.java b/src/mixins/java/org/spongepowered/common/mixin/core/network/syncher/SynchedEntityDataMixin.java index 59ad16e1fd0..89f99d40345 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/core/network/syncher/SynchedEntityDataMixin.java +++ b/src/mixins/java/org/spongepowered/common/mixin/core/network/syncher/SynchedEntityDataMixin.java @@ -94,15 +94,15 @@ public void set(final EntityDataAccessor key, T value) { final DataTransactionResult transaction = optional.get(); final ChangeDataHolderEvent.ValueChange event = - SpongeEventFactory.createChangeDataHolderEventValueChange(PhaseTracker.getCauseStackManager().getCurrentCause(), transaction, + SpongeEventFactory.createChangeDataHolderEventValueChange(PhaseTracker.getCauseStackManager().currentCause(), transaction, (DataHolder.Mutable) this.entity); - Sponge.getEventManager().post(event); + Sponge.eventManager().post(event); if (event.isCancelled()) { //If the event is cancelled, well, don't change the underlying value. return; } try { - value = converter.get().getValueFromEvent(currentValue, event.getEndResult().getSuccessfulData()); + value = converter.get().getValueFromEvent(currentValue, event.endResult().successfulData()); } catch (final Exception e) { // Worst case scenario, we don't want to cause an issue, so we just set the value value = incomingValue; diff --git a/src/mixins/java/org/spongepowered/common/mixin/core/server/MinecraftServerMixin.java b/src/mixins/java/org/spongepowered/common/mixin/core/server/MinecraftServerMixin.java index d49d6a7a3d3..e1829b95a20 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/core/server/MinecraftServerMixin.java +++ b/src/mixins/java/org/spongepowered/common/mixin/core/server/MinecraftServerMixin.java @@ -110,8 +110,8 @@ public abstract class MinecraftServerMixin implements SpongeServer, MinecraftSer @Nullable private ResourcePack impl$resourcePack; @Override - public Subject getSubject() { - return SpongeCommon.getGame().getSystemSubject(); + public Subject subject() { + return SpongeCommon.getGame().systemSubject(); } @Inject(method = "spin", at = @At("TAIL"), locals = LocalCapture.CAPTURE_FAILEXCEPTION) @@ -149,7 +149,7 @@ public Subject getSubject() { @Inject(method = "tickServer", at = @At("TAIL")) private void impl$tickServerScheduler(final BooleanSupplier hasTimeLeft, final CallbackInfo ci) { - this.getScheduler().tick(); + this.scheduler().tick(); } @Override @@ -163,7 +163,7 @@ public Subject getSubject() { // system subject @Override public void bridge$addToCauseStack(final CauseStackManager.StackFrame frame) { - frame.pushCause(Sponge.getSystemSubject()); + frame.pushCause(Sponge.systemSubject()); } // We want to save the username cache json, as we normally bypass it. @@ -282,15 +282,15 @@ public boolean saveAllChunks(final boolean suppressLog, final boolean flush, fin if (log) { if (this.bridge$performAutosaveChecks()) { - MinecraftServerMixin.LOGGER.info("Auto-saving data for world '{}'", ((org.spongepowered.api.world.server.ServerWorld) world).getKey()); + MinecraftServerMixin.LOGGER.info("Auto-saving data for world '{}'", ((org.spongepowered.api.world.server.ServerWorld) world).key()); } else { - MinecraftServerMixin.LOGGER.info("Saving data for world '{}'", ((org.spongepowered.api.world.server.ServerWorld) world).getKey()); + MinecraftServerMixin.LOGGER.info("Saving data for world '{}'", ((org.spongepowered.api.world.server.ServerWorld) world).key()); } } // Forced happens during command } else { if (log) { - MinecraftServerMixin.LOGGER.info("Manually saving data for world '{}'", ((org.spongepowered.api.world.server.ServerWorld) world).getKey()); + MinecraftServerMixin.LOGGER.info("Manually saving data for world '{}'", ((org.spongepowered.api.world.server.ServerWorld) world).key()); } ((PrimaryLevelDataBridge) world.getLevelData()).bridge$configAdapter().save(); diff --git a/src/mixins/java/org/spongepowered/common/mixin/core/server/PlayerAdvancementsMixin.java b/src/mixins/java/org/spongepowered/common/mixin/core/server/PlayerAdvancementsMixin.java index 9b43c7eb199..5219f177dc4 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/core/server/PlayerAdvancementsMixin.java +++ b/src/mixins/java/org/spongepowered/common/mixin/core/server/PlayerAdvancementsMixin.java @@ -92,7 +92,7 @@ public abstract class PlayerAdvancementsMixin implements PlayerAdvancementsBridg return progress.isDone(); } - final AdvancementCriterion criterion = ((org.spongepowered.api.advancement.criteria.CriterionProgress) progress).getCriterion(); + final AdvancementCriterion criterion = ((org.spongepowered.api.advancement.criteria.CriterionProgress) progress).criterion(); final CriterionBridge mixinCriterion = (CriterionBridge) criterion; // Only remove the trigger once the goal is reached if (mixinCriterion.bridge$getScoreCriterion() != null) { @@ -116,7 +116,7 @@ public abstract class PlayerAdvancementsMixin implements PlayerAdvancementsBridg } final org.spongepowered.api.advancement.Advancement advancement = - ((org.spongepowered.api.advancement.AdvancementProgress) advancementProgress).getAdvancement(); + ((org.spongepowered.api.advancement.AdvancementProgress) advancementProgress).advancement(); final AdvancementCriterion advancementCriterion = (AdvancementCriterion) ((Advancement) advancement).getCriteria().get(criterion); final CriterionBridge criterionBridge = (CriterionBridge) advancementCriterion; // Only remove the trigger once the goal is reached @@ -132,8 +132,8 @@ public abstract class PlayerAdvancementsMixin implements PlayerAdvancementsBridg final ImmutableSet.Builder builder = ImmutableSet.builder(); for (final Map.Entry entry : this.advancements.entrySet()) { final org.spongepowered.api.advancement.Advancement advancement = (org.spongepowered.api.advancement.Advancement) entry.getKey(); - if (!advancement.getParent().isPresent()) { - advancement.getTree().ifPresent(builder::add); + if (!advancement.parent().isPresent()) { + advancement.tree().ifPresent(builder::add); } } return builder.build(); @@ -181,13 +181,13 @@ public abstract class PlayerAdvancementsMixin implements PlayerAdvancementsBridg final Audience channel; if (this.impl$message != null) { - channel = Sponge.getServer().getBroadcastAudience(); + channel = Sponge.server().broadcastAudience(); } else { channel = Audience.empty(); } final AdvancementEvent.Grant event = SpongeEventFactory.createAdvancementEventGrant( - Sponge.getServer().getCauseStackManager().getCurrentCause(), + Sponge.server().causeStackManager().currentCause(), channel, Optional.of(channel), this.impl$message == null ? Component.empty() : this.impl$message, @@ -198,7 +198,7 @@ public abstract class PlayerAdvancementsMixin implements PlayerAdvancementsBridg ); SpongeCommon.postEvent(event); if (!event.isMessageCancelled()) { - event.getAudience().ifPresent(eventChannel -> eventChannel.sendMessage(Identity.nil(), event.getMessage())); + event.audience().ifPresent(eventChannel -> eventChannel.sendMessage(Identity.nil(), event.message())); } this.impl$message = null; diff --git a/src/mixins/java/org/spongepowered/common/mixin/core/server/ServerScoreboardMixin.java b/src/mixins/java/org/spongepowered/common/mixin/core/server/ServerScoreboardMixin.java index 60292e81e20..a9613b6737f 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/core/server/ServerScoreboardMixin.java +++ b/src/mixins/java/org/spongepowered/common/mixin/core/server/ServerScoreboardMixin.java @@ -88,10 +88,10 @@ public abstract class ServerScoreboardMixin extends Scoreboard implements Server @Override public void bridge$updateDisplaySlot(@Nullable final Objective objective, final DisplaySlot displaySlot) throws IllegalStateException { - if (objective != null && !objective.getScoreboards().contains(this)) { + if (objective != null && !objective.scoreboards().contains(this)) { throw new IllegalStateException("Attempting to set an objective's display slot that does not exist on this scoreboard!"); } - final MappedRegistry registry = (MappedRegistry) (Object) Sponge.getGame().registries().registry(RegistryTypes.DISPLAY_SLOT); + final MappedRegistry registry = (MappedRegistry) (Object) Sponge.game().registries().registry(RegistryTypes.DISPLAY_SLOT); final int index = registry.getId(displaySlot); ((ScoreboardAccessor) this).accessor$displayObjectives()[index] = objective == null ? null: ((SpongeObjective) objective).getObjectiveFor(this); ((ServerScoreboardBridge) this).bridge$sendToPlayers(new ClientboundSetDisplayObjectivePacket(index, ((ScoreboardAccessor) this).accessor$displayObjectives()[index])); @@ -101,20 +101,20 @@ public abstract class ServerScoreboardMixin extends Scoreboard implements Server @Override public void bridge$addObjective(final Objective objective) { - final net.minecraft.world.scores.Objective nmsObjective = this.getObjective(objective.getName()); + final net.minecraft.world.scores.Objective nmsObjective = this.getObjective(objective.name()); if (nmsObjective != null) { - throw new IllegalArgumentException(String.format("An objective with the name '%s' already exists!", objective.getName())); + throw new IllegalArgumentException(String.format("An objective with the name '%s' already exists!", objective.name())); } final net.minecraft.world.scores.Objective scoreObjective = ((SpongeObjective) objective).getObjectiveFor(this); - List objectives = ((ScoreboardAccessor) this).accessor$objectivesByCriteria().get(objective.getCriterion()); + List objectives = ((ScoreboardAccessor) this).accessor$objectivesByCriteria().get(objective.criterion()); if (objectives == null) { objectives = new ArrayList<>(); - ((ScoreboardAccessor) this).accessor$objectivesByCriteria().put((ObjectiveCriteria) objective.getCriterion(), objectives); + ((ScoreboardAccessor) this).accessor$objectivesByCriteria().put((ObjectiveCriteria) objective.criterion(), objectives); } objectives.add(scoreObjective); - ((ScoreboardAccessor) this).accessor$objectivesByName().put(objective.getName(), scoreObjective); + ((ScoreboardAccessor) this).accessor$objectivesByName().put(objective.name(), scoreObjective); this.onObjectiveAdded(scoreObjective); ((SpongeObjective) objective).updateScores(this); @@ -128,7 +128,7 @@ public abstract class ServerScoreboardMixin extends Scoreboard implements Server @Override public Optional bridge$getObjective(final DisplaySlot slot) { - final MappedRegistry registry = (MappedRegistry) (Object) Sponge.getGame().registries().registry(RegistryTypes.DISPLAY_SLOT); + final MappedRegistry registry = (MappedRegistry) (Object) Sponge.game().registries().registry(RegistryTypes.DISPLAY_SLOT); final net.minecraft.world.scores.Objective objective = ((ScoreboardAccessor) this).accessor$displayObjectives()[registry.getId(slot)]; if (objective != null) { return Optional.of(((ObjectiveBridge) objective).bridge$getSpongeObjective()); @@ -182,8 +182,8 @@ public abstract class ServerScoreboardMixin extends Scoreboard implements Server @Override public void bridge$registerTeam(final Team spongeTeam) { final PlayerTeam team = (PlayerTeam) spongeTeam; - if (this.getPlayerTeam(spongeTeam.getName()) != null) { - throw new IllegalArgumentException(String.format("A team with the name '%s' already exists!", spongeTeam.getName())); + if (this.getPlayerTeam(spongeTeam.name()) != null) { + throw new IllegalArgumentException(String.format("A team with the name '%s' already exists!", spongeTeam.name())); } if (((PlayerTeamAccessor) team).accessor$scoreboard() != null) { @@ -264,7 +264,7 @@ public void removePlayerTeam(final PlayerTeam team) { @Override public Score getOrCreatePlayerScore(final String name, final net.minecraft.world.scores.Objective objective) { - return ((SpongeScore) ((ObjectiveBridge) objective).bridge$getSpongeObjective().getOrCreateScore(SpongeAdventure.legacySection(name))) + return ((SpongeScore) ((ObjectiveBridge) objective).bridge$getSpongeObjective().orCreateScore(SpongeAdventure.legacySection(name))) .getScoreFor(objective); } @@ -272,7 +272,7 @@ public Score getOrCreatePlayerScore(final String name, final net.minecraft.world public void resetPlayerScore(final String name, final net.minecraft.world.scores.Objective objective) { if (objective != null) { final SpongeObjective spongeObjective = ((ObjectiveBridge) objective).bridge$getSpongeObjective(); - final Optional score = spongeObjective.getScore(SpongeAdventure.legacySection(name)); + final Optional score = spongeObjective.score(SpongeAdventure.legacySection(name)); if (score.isPresent()) { spongeObjective.removeScore(score.get()); } else { @@ -330,7 +330,7 @@ private boolean onUpdateScoreValue(final Set set, final Object object) { @Overwrite public void setDisplayObjective(final int slot, @Nullable final net.minecraft.world.scores.Objective objective) { final Objective apiObjective = objective == null ? null : ((ObjectiveBridge) objective).bridge$getSpongeObjective(); - final DisplaySlot displaySlot = (DisplaySlot) ((Registry) Sponge.getGame().registries().registry(RegistryTypes.DISPLAY_SLOT)).byId(slot); + final DisplaySlot displaySlot = (DisplaySlot) ((Registry) Sponge.game().registries().registry(RegistryTypes.DISPLAY_SLOT)).byId(slot); this.bridge$updateDisplaySlot(apiObjective, displaySlot); } diff --git a/src/mixins/java/org/spongepowered/common/mixin/core/server/commands/TeleportCommandMixin.java b/src/mixins/java/org/spongepowered/common/mixin/core/server/commands/TeleportCommandMixin.java index 447d8a226ff..876099f9ab6 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/core/server/commands/TeleportCommandMixin.java +++ b/src/mixins/java/org/spongepowered/common/mixin/core/server/commands/TeleportCommandMixin.java @@ -86,7 +86,7 @@ private static void performTeleport(CommandSourceStack source, Entity entityIn, // TODO Should honor the relative list before the event.. if (ShouldFire.MOVE_ENTITY_EVENT) { - final MoveEntityEvent posEvent = SpongeEventFactory.createMoveEntityEvent(frame.getCurrentCause(), + final MoveEntityEvent posEvent = SpongeEventFactory.createMoveEntityEvent(frame.currentCause(), (org.spongepowered.api.entity.Entity) entityIn, VecHelper.toVector3d(entityIn.position()), new Vector3d(x, y, z), new Vector3d(x, y, z)); @@ -94,19 +94,19 @@ private static void performTeleport(CommandSourceStack source, Entity entityIn, return; } - actualX = posEvent.getDestinationPosition().getX(); - actualY = posEvent.getDestinationPosition().getY(); - actualZ = posEvent.getDestinationPosition().getZ(); + actualX = posEvent.destinationPosition().getX(); + actualY = posEvent.destinationPosition().getY(); + actualZ = posEvent.destinationPosition().getZ(); } if (ShouldFire.ROTATE_ENTITY_EVENT) { - final RotateEntityEvent rotateEvent = SpongeEventFactory.createRotateEntityEvent(frame.getCurrentCause(), + final RotateEntityEvent rotateEvent = SpongeEventFactory.createRotateEntityEvent(frame.currentCause(), (org.spongepowered.api.entity.Entity) entityIn, new Vector3d(actualPitch, actualYaw, 0), new Vector3d(pitch, yaw, 0)); SpongeCommon.postEvent(rotateEvent); - actualYaw = rotateEvent.isCancelled() ? entityIn.yRot : rotateEvent.getToRotation().getY(); - actualPitch = rotateEvent.isCancelled() ? entityIn.xRot : rotateEvent.getToRotation().getX(); + actualYaw = rotateEvent.isCancelled() ? entityIn.yRot : rotateEvent.toRotation().getY(); + actualPitch = rotateEvent.isCancelled() ? entityIn.xRot : rotateEvent.toRotation().getX(); } if (entityIn instanceof ServerPlayer) { @@ -148,11 +148,11 @@ private static void performTeleport(CommandSourceStack source, Entity entityIn, } final ChangeEntityWorldEvent.Reposition posEvent = - SpongeEventFactory.createChangeEntityWorldEventReposition(frame.getCurrentCause(), + SpongeEventFactory.createChangeEntityWorldEventReposition(frame.currentCause(), (org.spongepowered.api.entity.Entity) entityIn, (org.spongepowered.api.world.server.ServerWorld) entityIn.getCommandSenderWorld(), - VecHelper.toVector3d(entityIn.position()), new Vector3d(x, y, z), preEvent.getOriginalDestinationWorld(), - new Vector3d(x, y, z), preEvent.getDestinationWorld()); + VecHelper.toVector3d(entityIn.position()), new Vector3d(x, y, z), preEvent.originalDestinationWorld(), + new Vector3d(x, y, z), preEvent.destinationWorld()); if (SpongeCommon.postEvent(posEvent)) { return; @@ -165,13 +165,13 @@ private static void performTeleport(CommandSourceStack source, Entity entityIn, } if (ShouldFire.ROTATE_ENTITY_EVENT) { - final RotateEntityEvent rotateEvent = SpongeEventFactory.createRotateEntityEvent(frame.getCurrentCause(), + final RotateEntityEvent rotateEvent = SpongeEventFactory.createRotateEntityEvent(frame.currentCause(), (org.spongepowered.api.entity.Entity) entityIn, new Vector3d(entityIn.xRot, entityIn.yRot, 0), new Vector3d(actualPitch, actualYaw, 0)); if (!SpongeCommon.postEvent(rotateEvent)) { - actualYaw = Mth.wrapDegrees(rotateEvent.getToRotation().getY()); - actualPitch = Mth.wrapDegrees(rotateEvent.getToRotation().getX()); + actualYaw = Mth.wrapDegrees(rotateEvent.toRotation().getY()); + actualPitch = Mth.wrapDegrees(rotateEvent.toRotation().getX()); actualPitch = Mth.clamp(actualPitch, -90.0F, 90.0F); } else { actualYaw = entityIn.yRot; @@ -180,14 +180,14 @@ private static void performTeleport(CommandSourceStack source, Entity entityIn, } result.restoreFrom(entityIn); - result.moveTo(posEvent.getDestinationPosition().getX(), posEvent.getDestinationPosition().getY(), - posEvent.getDestinationPosition().getZ(), (float) actualYaw, (float) actualPitch); + result.moveTo(posEvent.destinationPosition().getX(), posEvent.destinationPosition().getY(), + posEvent.destinationPosition().getZ(), (float) actualYaw, (float) actualPitch); result.setYHeadRot((float) actualYaw); worldIn.addFromAnotherDimension(result); entityIn.removed = true; PlatformHooks.INSTANCE.getEventHooks().callChangeEntityWorldEventPost(result, fromWorld, - (ServerLevel) preEvent.getOriginalDestinationWorld()); + (ServerLevel) preEvent.originalDestinationWorld()); } } } diff --git a/src/mixins/java/org/spongepowered/common/mixin/core/server/dedicated/DedicatedPlayerListMixin.java b/src/mixins/java/org/spongepowered/common/mixin/core/server/dedicated/DedicatedPlayerListMixin.java index dec7176d2fd..4f2b56d50c1 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/core/server/dedicated/DedicatedPlayerListMixin.java +++ b/src/mixins/java/org/spongepowered/common/mixin/core/server/dedicated/DedicatedPlayerListMixin.java @@ -56,18 +56,18 @@ public DedicatedPlayerListMixin(final MinecraftServer server, final RegistryAcce ci.setReturnValue(true); return; } - final PermissionService permissionService = Sponge.getServer().getServiceProvider().permissionService(); - final Subject subject = permissionService.getUserSubjects() - .getSubject(profile.getId().toString()).orElse(permissionService.getDefaults()); + final PermissionService permissionService = Sponge.server().serviceProvider().permissionService(); + final Subject subject = permissionService.userSubjects() + .subject(profile.getId().toString()).orElse(permissionService.defaults()); ci.setReturnValue(subject.hasPermission(LoginPermissions.BYPASS_WHITELIST_PERMISSION)); } @Inject(method = "canBypassPlayerLimit", at = @At("HEAD"), cancellable = true) private void impl$checkForPlayerLimitBypassPermission(final GameProfile profile, final CallbackInfoReturnable ci) { - final PermissionService permissionService = Sponge.getServer().getServiceProvider().permissionService(); - final Subject subject = permissionService.getUserSubjects() - .getSubject(profile.getId().toString()).orElse(permissionService.getDefaults()); - final Tristate tristate = subject.getPermissionValue(SubjectData.GLOBAL_CONTEXT, LoginPermissions.BYPASS_PLAYER_LIMIT_PERMISSION); + final PermissionService permissionService = Sponge.server().serviceProvider().permissionService(); + final Subject subject = permissionService.userSubjects() + .subject(profile.getId().toString()).orElse(permissionService.defaults()); + final Tristate tristate = subject.permissionValue(SubjectData.GLOBAL_CONTEXT, LoginPermissions.BYPASS_PLAYER_LIMIT_PERMISSION); // Use the op list if the permission isn't overridden for the subject and // if we are still using the default permission service if (tristate == Tristate.UNDEFINED && permissionService instanceof SpongePermissionService) { diff --git a/src/mixins/java/org/spongepowered/common/mixin/core/server/dedicated/DedicatedServerMixin.java b/src/mixins/java/org/spongepowered/common/mixin/core/server/dedicated/DedicatedServerMixin.java index 5dd4d04d9d6..e14ab68581e 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/core/server/dedicated/DedicatedServerMixin.java +++ b/src/mixins/java/org/spongepowered/common/mixin/core/server/dedicated/DedicatedServerMixin.java @@ -67,7 +67,7 @@ private void onSave(final GameProfileCache cache) { @Inject(method = "stopServer", at = @At("TAIL")) private void impl$shutdownAsyncScheduler(final CallbackInfo ci) { - SpongeCommon.getGame().getAsyncScheduler().close(); + SpongeCommon.getGame().asyncScheduler().close(); } @Override diff --git a/src/mixins/java/org/spongepowered/common/mixin/core/server/level/ChunkMapMixin.java b/src/mixins/java/org/spongepowered/common/mixin/core/server/level/ChunkMapMixin.java index 241d2855b53..afdf362454e 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/core/server/level/ChunkMapMixin.java +++ b/src/mixins/java/org/spongepowered/common/mixin/core/server/level/ChunkMapMixin.java @@ -95,14 +95,14 @@ public abstract class ChunkMapMixin { private void impl$onSetUnloaded(final ServerLevel level, final LevelChunk chunk) { level.unload(chunk); final Vector3i chunkPos = new Vector3i(chunk.getPos().x, 0, chunk.getPos().z); - final ChunkEvent.Unload event = SpongeEventFactory.createChunkEventUnload(PhaseTracker.getInstance().getCurrentCause(), chunkPos, (ResourceKey) (Object) this.level.dimension().location()); + final ChunkEvent.Unload event = SpongeEventFactory.createChunkEventUnload(PhaseTracker.getInstance().currentCause(), chunkPos, (ResourceKey) (Object) this.level.dimension().location()); SpongeCommon.postEvent(event); } @Inject(method = "save", at = @At(value = "RETURN")) private void impl$onSaved(final ChunkAccess var1, final CallbackInfoReturnable cir) { final Vector3i chunkPos = new Vector3i(var1.getPos().x, 0, var1.getPos().z); - final ChunkEvent.Save.Post postSave = SpongeEventFactory.createChunkEventSavePost(PhaseTracker.getInstance().getCurrentCause(), chunkPos, + final ChunkEvent.Save.Post postSave = SpongeEventFactory.createChunkEventSavePost(PhaseTracker.getInstance().currentCause(), chunkPos, (ResourceKey) (Object) this.level.dimension().location()); SpongeCommon.postEvent(postSave); } @@ -111,7 +111,7 @@ public abstract class ChunkMapMixin { private void impl$onSave(final ChunkAccess var1, final CallbackInfoReturnable cir) { if (var1 instanceof Chunk) { final Vector3i chunkPos = new Vector3i(var1.getPos().x, 0, var1.getPos().z); - final ChunkEvent.Save.Pre postSave = SpongeEventFactory.createChunkEventSavePre(PhaseTracker.getInstance().getCurrentCause(), + final ChunkEvent.Save.Pre postSave = SpongeEventFactory.createChunkEventSavePre(PhaseTracker.getInstance().currentCause(), chunkPos, (ResourceKey) (Object) this.level.dimension().location(), ((Chunk) var1)); SpongeCommon.postEvent(postSave); if (postSave.isCancelled()) { @@ -130,7 +130,7 @@ public abstract class ChunkMapMixin { private void impl$onLoad(final LevelChunk levelChunk, final boolean loaded) { levelChunk.setLoaded(true); final Vector3i chunkPos = new Vector3i(levelChunk.getPos().x, 0, levelChunk.getPos().z); - final ChunkEvent.Load loadEvent = SpongeEventFactory.createChunkEventLoad(PhaseTracker.getInstance().getCurrentCause(), + final ChunkEvent.Load loadEvent = SpongeEventFactory.createChunkEventLoad(PhaseTracker.getInstance().currentCause(), chunkPos, (ResourceKey) (Object) this.level.dimension().location(), ((Chunk) levelChunk)); SpongeCommon.postEvent(loadEvent); } diff --git a/src/mixins/java/org/spongepowered/common/mixin/core/server/level/ServerLevelMixin.java b/src/mixins/java/org/spongepowered/common/mixin/core/server/level/ServerLevelMixin.java index c825a9925ef..8e39fc23c4a 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/core/server/level/ServerLevelMixin.java +++ b/src/mixins/java/org/spongepowered/common/mixin/core/server/level/ServerLevelMixin.java @@ -198,19 +198,19 @@ public abstract class ServerLevelMixin extends LevelMixin implements ServerLevel if (ShouldFire.EXPLOSION_EVENT_PRE) { final ExplosionEvent.Pre event = - SpongeEventFactory.createExplosionEventPre(PhaseTracker.getCauseStackManager().getCurrentCause(), + SpongeEventFactory.createExplosionEventPre(PhaseTracker.getCauseStackManager().currentCause(), explosion, (org.spongepowered.api.world.server.ServerWorld) this); if (SpongeCommon.postEvent(event)) { return; } - explosion = event.getExplosion(); + explosion = event.explosion(); } final net.minecraft.world.level.Explosion mcExplosion = (net.minecraft.world.level.Explosion) explosion; try (final PhaseContext ignored = GeneralPhase.State.EXPLOSION.createPhaseContext(PhaseTracker.SERVER) .explosion((net.minecraft.world.level.Explosion) explosion) - .source(explosion.getSourceExplosive().isPresent() ? explosion.getSourceExplosive() : this)) { + .source(explosion.sourceExplosive().isPresent() ? explosion.sourceExplosive() : this)) { ignored.buildAndSwitch(); final boolean shouldBreakBlocks = explosion.shouldBreakBlocks(); // Sponge End diff --git a/src/mixins/java/org/spongepowered/common/mixin/core/server/level/ServerPlayerMixin.java b/src/mixins/java/org/spongepowered/common/mixin/core/server/level/ServerPlayerMixin.java index 11a59ca40ea..05f1ad6b406 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/core/server/level/ServerPlayerMixin.java +++ b/src/mixins/java/org/spongepowered/common/mixin/core/server/level/ServerPlayerMixin.java @@ -167,7 +167,7 @@ public abstract class ServerPlayerMixin extends PlayerMixin implements SubjectBr private final User impl$user = this.impl$getUserObjectOnConstruction(); private net.minecraft.network.chat.@Nullable Component impl$connectionMessage; private Locale impl$language = Locales.EN_US; - private Scoreboard impl$scoreboard = Sponge.getGame().getServer().getServerScoreboard().get(); + private Scoreboard impl$scoreboard = Sponge.game().server().serverScoreboard().get(); @Nullable private Boolean impl$keepInventory = null; // Used to restore original item received in a packet after canceling an event private ItemStack impl$packetItem = ItemStack.EMPTY; @@ -229,41 +229,41 @@ public abstract class ServerPlayerMixin extends PlayerMixin implements SubjectBr frame.pushCause(SpongeCommon.getActivePlugin()); frame.addContext(EventContextKeys.MOVEMENT_TYPE, MovementTypes.PLUGIN); - ServerLevel destinationWorld = (net.minecraft.server.level.ServerLevel) location.getWorld(); + ServerLevel destinationWorld = (net.minecraft.server.level.ServerLevel) location.world(); - Vector3d toPosition = location.getPosition(); + Vector3d toPosition = location.position(); if (this.shadow$getLevel() != destinationWorld) { - final ChangeEntityWorldEvent.Pre event = SpongeEventFactory.createChangeEntityWorldEventPre(frame.getCurrentCause(), + final ChangeEntityWorldEvent.Pre event = SpongeEventFactory.createChangeEntityWorldEventPre(frame.currentCause(), (org.spongepowered.api.entity.Entity) this, (org.spongepowered.api.world.server.ServerWorld) this.shadow$getLevel(), - location.getWorld(), location.getWorld()); + location.world(), location.world()); if (SpongeCommon.postEvent(event)) { return false; } final ChangeEntityWorldEvent.Reposition repositionEvent = - SpongeEventFactory.createChangeEntityWorldEventReposition(frame.getCurrentCause(), + SpongeEventFactory.createChangeEntityWorldEventReposition(frame.currentCause(), (org.spongepowered.api.entity.Entity) this, (org.spongepowered.api.world.server.ServerWorld) this.shadow$getLevel(), - VecHelper.toVector3d(this.shadow$position()), location.getPosition(), event.getOriginalDestinationWorld(), - location.getPosition(), event.getDestinationWorld()); + VecHelper.toVector3d(this.shadow$position()), location.position(), event.originalDestinationWorld(), + location.position(), event.destinationWorld()); if (SpongeCommon.postEvent(repositionEvent)) { return false; } - destinationWorld = (net.minecraft.server.level.ServerLevel) event.getDestinationWorld(); + destinationWorld = (net.minecraft.server.level.ServerLevel) event.destinationWorld(); - toPosition = repositionEvent.getDestinationPosition(); + toPosition = repositionEvent.destinationPosition(); } else { if (ShouldFire.MOVE_ENTITY_EVENT) { - final MoveEntityEvent event = SpongeEventFactory.createMoveEntityEvent(frame.getCurrentCause(), + final MoveEntityEvent event = SpongeEventFactory.createMoveEntityEvent(frame.currentCause(), (org.spongepowered.api.entity.Entity) this, VecHelper.toVector3d(this.shadow$position()), - location.getPosition(), location.getPosition()); + location.position(), location.position()); if (SpongeCommon.postEvent(event)) { return false; } - toPosition = event.getDestinationPosition(); + toPosition = event.destinationPosition(); } } @@ -280,7 +280,7 @@ public abstract class ServerPlayerMixin extends PlayerMixin implements SubjectBr this.shadow$absMoveTo(toPosition.getX(), toPosition.getY(), toPosition.getZ(), this.yRot, this.xRot); EntityUtil.performPostChangePlayerWorldLogic((net.minecraft.server.level.ServerPlayer) (Object) this, this.shadow$getLevel(), - (net.minecraft.server.level.ServerLevel) location.getWorld(), destinationWorld, false); + (net.minecraft.server.level.ServerLevel) location.world(), destinationWorld, false); } else { this.connection.teleport(toPosition.getX(), toPosition.getY(), toPosition.getZ(), this.yRot, this.xRot, new HashSet<>()); @@ -300,15 +300,15 @@ public abstract class ServerPlayerMixin extends PlayerMixin implements SubjectBr public boolean bridge$kick(final Component message) { final Component messageToSend; if (ShouldFire.KICK_PLAYER_EVENT) { - final KickPlayerEvent kickEvent = SpongeEventFactory.createKickPlayerEvent(PhaseTracker.getCauseStackManager().getCurrentCause(), + final KickPlayerEvent kickEvent = SpongeEventFactory.createKickPlayerEvent(PhaseTracker.getCauseStackManager().currentCause(), message, message, (ServerPlayer) this ); - if (Sponge.getEventManager().post(kickEvent)) { + if (Sponge.eventManager().post(kickEvent)) { return false; } - messageToSend = kickEvent.getMessage(); + messageToSend = kickEvent.message(); } else { messageToSend = message; } @@ -344,13 +344,13 @@ public abstract class ServerPlayerMixin extends PlayerMixin implements SubjectBr @Override public void bridge$removeScoreboardOnRespawn() { - ((ServerScoreboardBridge) ((ServerPlayer) this).getScoreboard()).bridge$removePlayer((net.minecraft.server.level.ServerPlayer) (Object) this, false); + ((ServerScoreboardBridge) ((ServerPlayer) this).scoreboard()).bridge$removePlayer((net.minecraft.server.level.ServerPlayer) (Object) this, false); } @Override public void bridge$setScoreboardOnRespawn(final Scoreboard scoreboard) { this.impl$scoreboard = scoreboard; - ((ServerScoreboardBridge) ((ServerPlayer) this).getScoreboard()).bridge$addPlayer((net.minecraft.server.level.ServerPlayer) (Object) this, false); + ((ServerScoreboardBridge) ((ServerPlayer) this).scoreboard()).bridge$addPlayer((net.minecraft.server.level.ServerPlayer) (Object) this, false); } @Override @@ -361,7 +361,7 @@ public abstract class ServerPlayerMixin extends PlayerMixin implements SubjectBr @Override public void bridge$replaceScoreboard(@org.checkerframework.checker.nullness.qual.Nullable Scoreboard scoreboard) { if (scoreboard == null) { - scoreboard = Sponge.getGame().getServer().getServerScoreboard() + scoreboard = Sponge.game().server().serverScoreboard() .orElseThrow(() -> new IllegalStateException("Server does not have a valid scoreboard")); } this.impl$scoreboard = scoreboard; @@ -393,7 +393,7 @@ public abstract class ServerPlayerMixin extends PlayerMixin implements SubjectBr public Set bridge$getSkinParts() { final int mask = this.shadow$getEntityData().get(DATA_PLAYER_MODE_CUSTOMISATION); if (this.impl$skinPartMask != mask) { - this.impl$skinParts = Sponge.getGame().registries().registry(RegistryTypes.SKIN_PART).stream() + this.impl$skinParts = Sponge.game().registries().registry(RegistryTypes.SKIN_PART).stream() .map(part -> (SpongeSkinPart) part) .filter(part -> part.test(mask)) .collect(ImmutableSet.toImmutableSet()); @@ -436,7 +436,7 @@ public void teleportTo( double actualYaw = yaw; double actualPitch = pitch; - final boolean hasMovementContext = PhaseTracker.getCauseStackManager().getCurrentContext().containsKey(EventContextKeys.MOVEMENT_TYPE); + final boolean hasMovementContext = PhaseTracker.getCauseStackManager().currentContext().containsKey(EventContextKeys.MOVEMENT_TYPE); try (final CauseStackManager.StackFrame frame = PhaseTracker.getCauseStackManager().pushCauseFrame()) { if (!hasMovementContext) { @@ -446,7 +446,7 @@ public void teleportTo( if (world == player.level) { if (ShouldFire.MOVE_ENTITY_EVENT) { - final MoveEntityEvent posEvent = SpongeEventFactory.createMoveEntityEvent(frame.getCurrentCause(), + final MoveEntityEvent posEvent = SpongeEventFactory.createMoveEntityEvent(frame.currentCause(), (org.spongepowered.api.entity.Entity) player, VecHelper.toVector3d(player.position()), new Vector3d(x, y, z), new Vector3d(x, y, z)); @@ -454,20 +454,20 @@ public void teleportTo( return; } - actualX = posEvent.getDestinationPosition().getX(); - actualY = posEvent.getDestinationPosition().getY(); - actualZ = posEvent.getDestinationPosition().getZ(); + actualX = posEvent.destinationPosition().getX(); + actualY = posEvent.destinationPosition().getY(); + actualZ = posEvent.destinationPosition().getZ(); } if (ShouldFire.ROTATE_ENTITY_EVENT) { - final RotateEntityEvent rotateEvent = SpongeEventFactory.createRotateEntityEvent(frame.getCurrentCause(), + final RotateEntityEvent rotateEvent = SpongeEventFactory.createRotateEntityEvent(frame.currentCause(), (org.spongepowered.api.entity.Entity) player, new Vector3d(actualPitch, actualYaw, 0), new Vector3d(pitch, yaw, 0)); SpongeCommon.postEvent(rotateEvent); - actualYaw = rotateEvent.isCancelled() ? player.yRot : rotateEvent.getToRotation().getY(); - actualPitch = rotateEvent.isCancelled() ? player.xRot : rotateEvent.getToRotation().getX(); + actualYaw = rotateEvent.isCancelled() ? player.yRot : rotateEvent.toRotation().getY(); + actualPitch = rotateEvent.isCancelled() ? player.xRot : rotateEvent.toRotation().getX(); } this.shadow$setCamera(player); @@ -490,36 +490,36 @@ public void teleportTo( } if (ShouldFire.MOVE_ENTITY_EVENT) { - final MoveEntityEvent posEvent = SpongeEventFactory.createChangeEntityWorldEventReposition(frame.getCurrentCause(), - (org.spongepowered.api.entity.Entity) player, preEvent.getOriginalWorld(), VecHelper.toVector3d(player.position()), - new Vector3d(x, y, z), preEvent.getOriginalDestinationWorld(), new Vector3d(x, y, z), preEvent.getDestinationWorld()); + final MoveEntityEvent posEvent = SpongeEventFactory.createChangeEntityWorldEventReposition(frame.currentCause(), + (org.spongepowered.api.entity.Entity) player, preEvent.originalWorld(), VecHelper.toVector3d(player.position()), + new Vector3d(x, y, z), preEvent.originalDestinationWorld(), new Vector3d(x, y, z), preEvent.destinationWorld()); if (SpongeCommon.postEvent(posEvent)) { return; } - actualX = posEvent.getDestinationPosition().getX(); - actualY = posEvent.getDestinationPosition().getY(); - actualZ = posEvent.getDestinationPosition().getZ(); + actualX = posEvent.destinationPosition().getX(); + actualY = posEvent.destinationPosition().getY(); + actualZ = posEvent.destinationPosition().getZ(); } this.shadow$setPos(actualX, actualY, actualZ); if (ShouldFire.ROTATE_ENTITY_EVENT) { - final RotateEntityEvent rotateEvent = SpongeEventFactory.createRotateEntityEvent(frame.getCurrentCause(), + final RotateEntityEvent rotateEvent = SpongeEventFactory.createRotateEntityEvent(frame.currentCause(), (org.spongepowered.api.entity.Entity) player, new Vector3d(actualYaw, actualPitch, 0), new Vector3d(yaw, pitch, 0)); if (!SpongeCommon.postEvent(rotateEvent)) { - actualYaw = (float) rotateEvent.getToRotation().getX(); - actualPitch = (float) rotateEvent.getToRotation().getY(); + actualYaw = (float) rotateEvent.toRotation().getX(); + actualPitch = (float) rotateEvent.toRotation().getY(); } } this.yRot = (float) actualYaw; this.xRot = (float) actualPitch; - EntityUtil.performPostChangePlayerWorldLogic(player, (net.minecraft.server.level.ServerLevel) preEvent.getOriginalWorld(), - (net.minecraft.server.level.ServerLevel) preEvent.getOriginalDestinationWorld(), - (net.minecraft.server.level.ServerLevel) preEvent.getDestinationWorld(), false); + EntityUtil.performPostChangePlayerWorldLogic(player, (net.minecraft.server.level.ServerLevel) preEvent.originalWorld(), + (net.minecraft.server.level.ServerLevel) preEvent.originalDestinationWorld(), + (net.minecraft.server.level.ServerLevel) preEvent.destinationWorld(), false); } } } @@ -697,10 +697,10 @@ public void die(final DamageSource cause) { (net.minecraft.server.level.ServerPlayer) (Object) this, itextcomponent); } } else { - final Component message = event.getMessage(); + final Component message = event.message(); // Sponge start - use the event audience if (message != Component.empty()) { - event.getAudience().ifPresent(eventChannel -> eventChannel.sendMessage(Identity.nil(), message)); + event.audience().ifPresent(eventChannel -> eventChannel.sendMessage(Identity.nil(), message)); } // Sponge end // this.server.getPlayerList().sendMessage(itextcomponent); @@ -717,7 +717,7 @@ public void die(final DamageSource cause) { // Sponge Start - update the keep inventory flag for dropping inventory // during the death update ticks - this.impl$keepInventory = event.getKeepInventory(); + this.impl$keepInventory = event.keepInventory(); if (!this.shadow$isSpectator()) { this.shadow$dropAllDeathLoot(cause); @@ -758,9 +758,9 @@ public void die(final DamageSource cause) { } private User impl$getUserObjectOnConstruction() { - final SpongeUserManager manager = (SpongeUserManager) SpongeCommon.getGame().getServer().getUserManager(); + final SpongeUserManager manager = (SpongeUserManager) SpongeCommon.getGame().server().userManager(); if (this.impl$isFake) { - return manager.getOrCreate(SpongeUserManager.FAKEPLAYER_PROFILE); + return manager.findOrCreate(SpongeUserManager.FAKEPLAYER_PROFILE); } // Ensure that the game profile is up to date. return manager.forceRecreateUser(SpongeGameProfile.of(this.shadow$getGameProfile())); @@ -791,7 +791,7 @@ public void die(final DamageSource cause) { final ServerboundClientInformationPacketAccessor $packet = (ServerboundClientInformationPacketAccessor) packet; final Locale newLocale = LocaleCache.getLocale($packet.accessor$language()); - final ImmutableSet skinParts = Sponge.getGame().registries().registry(RegistryTypes.SKIN_PART).stream() + final ImmutableSet skinParts = Sponge.game().registries().registry(RegistryTypes.SKIN_PART).stream() .map(part -> (SpongeSkinPart) part) .filter(part -> part.test(packet.getModelCustomisation())) .collect(ImmutableSet.toImmutableSet()); @@ -801,7 +801,7 @@ public void die(final DamageSource cause) { try (final CauseStackManager.StackFrame frame = PhaseTracker.getCauseStackManager().pushCauseFrame()) { final ChatVisibility visibility = (ChatVisibility) (Object) packet.getChatVisibility(); final PlayerChangeClientSettingsEvent event = SpongeEventFactory.createPlayerChangeClientSettingsEvent( - frame.getCurrentCause(), + frame.currentCause(), visibility, skinParts, newLocale, diff --git a/src/mixins/java/org/spongepowered/common/mixin/core/server/network/ServerGamePacketListenerImplMixin.java b/src/mixins/java/org/spongepowered/common/mixin/core/server/network/ServerGamePacketListenerImplMixin.java index a4695be9b1a..25710ef5361 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/core/server/network/ServerGamePacketListenerImplMixin.java +++ b/src/mixins/java/org/spongepowered/common/mixin/core/server/network/ServerGamePacketListenerImplMixin.java @@ -174,14 +174,14 @@ public abstract class ServerGamePacketListenerImplMixin implements ConnectionHol ci.cancel(); } else { final Optional mappingOptional = - manager.getCommandMapping(command[0].toLowerCase(Locale.ROOT)) - .filter(x -> !(x.getRegistrar() instanceof BrigadierBasedRegistrar)); + manager.commandMapping(command[0].toLowerCase(Locale.ROOT)) + .filter(x -> !(x.registrar() instanceof BrigadierBasedRegistrar)); if (mappingOptional.isPresent()) { final CommandMapping mapping = mappingOptional.get(); - if (mapping.getRegistrar().canExecute(cause, mapping)) { + if (mapping.registrar().canExecute(cause, mapping)) { try { final SuggestionsBuilder builder = new SuggestionsBuilder(rawCommand, rawCommand.lastIndexOf(" ") + 1); - mapping.getRegistrar().suggestions(cause, mapping, command[0], command[1]).forEach(builder::suggest); + mapping.registrar().suggestions(cause, mapping, command[0], command[1]).forEach(builder::suggest); this.connection.send(new ClientboundCommandSuggestionsPacket(packet.getId(), builder.build())); } catch (final CommandException e) { cause.sendMessage(Identity.nil(), Component.text("Unable to create suggestions for your tab completion")); @@ -224,7 +224,7 @@ public abstract class ServerGamePacketListenerImplMixin implements ConnectionHol * if (isMovePlayerPacketInvalid(packetIn)) { * this.disconnect(new TranslationTextComponent("multiplayer.disconnect.invalid_player_movement")); * } else { - * ServerWorld serverworld = this.server.getWorld(this.player.dimension); + * ServerWorld serverworld = this.server.world(this.player.dimension); * if (!this.player.queuedEndExit) { // <---- Here is where we're injecting * if (this.networkTickCount == 0) { * this.captureCurrentPosition(); @@ -278,7 +278,7 @@ public abstract class ServerGamePacketListenerImplMixin implements ConnectionHol // Use the position of the last movement with an event or the current player position if never called // We need this because we ignore very small position changes as to not spam as many move events. - final org.spongepowered.math.vector.Vector3d fromPosition = player.getPosition(); + final org.spongepowered.math.vector.Vector3d fromPosition = player.position(); org.spongepowered.math.vector.Vector3d toPosition = new org.spongepowered.math.vector.Vector3d(packetIn.getX(this.player.getX()), packetIn.getY(this.player.getY()), packetIn.getZ(this.player.getZ())); @@ -292,22 +292,22 @@ public abstract class ServerGamePacketListenerImplMixin implements ConnectionHol boolean cancelRotation = false; // Call move & rotate event as needed... if (fireMoveEvent) { - final MoveEntityEvent event = SpongeEventFactory.createMoveEntityEvent(PhaseTracker.getCauseStackManager().getCurrentCause(), (ServerPlayer) this.player, fromPosition, + final MoveEntityEvent event = SpongeEventFactory.createMoveEntityEvent(PhaseTracker.getCauseStackManager().currentCause(), (ServerPlayer) this.player, fromPosition, toPosition, toPosition); if (SpongeCommon.postEvent(event)) { cancelMovement = true; } else { - toPosition = event.getDestinationPosition(); + toPosition = event.destinationPosition(); } } if (significantRotation && fireRotationEvent) { - final RotateEntityEvent event = SpongeEventFactory.createRotateEntityEvent(PhaseTracker.getCauseStackManager().getCurrentCause(), (ServerPlayer) this.player, fromRotation, + final RotateEntityEvent event = SpongeEventFactory.createRotateEntityEvent(PhaseTracker.getCauseStackManager().currentCause(), (ServerPlayer) this.player, fromRotation, toRotation); if (SpongeCommon.postEvent(event)) { cancelRotation = true; } else { - toRotation = event.getToRotation(); + toRotation = event.toRotation(); } } @@ -429,7 +429,7 @@ public abstract class ServerGamePacketListenerImplMixin implements ConnectionHol frame.addContext(EventContextKeys.USED_ITEM, ItemStackUtil.snapshotOf(heldItem)); frame.addContext(EventContextKeys.USED_HAND, handType); final AnimateHandEvent event = - SpongeEventFactory.createAnimateHandEvent(frame.getCurrentCause(), handType, (Humanoid) this.player); + SpongeEventFactory.createAnimateHandEvent(frame.currentCause(), handType, (Humanoid) this.player); if (SpongeCommon.postEvent(event)) { ci.cancel(); } @@ -485,14 +485,14 @@ public abstract class ServerGamePacketListenerImplMixin implements ConnectionHol } final ServerLevel destination = destinationWorld == null ? overworld : destinationWorld; final RespawnPlayerEvent.SelectWorld event = - SpongeEventFactory.createRespawnPlayerEventSelectWorld(PhaseTracker.getCauseStackManager().getCurrentCause(), + SpongeEventFactory.createRespawnPlayerEventSelectWorld(PhaseTracker.getCauseStackManager().currentCause(), (org.spongepowered.api.world.server.ServerWorld) destination, (org.spongepowered.api.world.server.ServerWorld) player.getLevel(), (org.spongepowered.api.world.server.ServerWorld) overworld, (ServerPlayer) player); SpongeCommon.postEvent(event); - ((PlayerListBridge) this.server.getPlayerList()).bridge$setOriginalDestinationDimension(((ServerLevel) event.getOriginalDestinationWorld()).dimension()); - ((PlayerListBridge) this.server.getPlayerList()).bridge$setNewDestinationDimension(((ServerLevel) event.getDestinationWorld()).dimension()); + ((PlayerListBridge) this.server.getPlayerList()).bridge$setOriginalDestinationDimension(((ServerLevel) event.originalDestinationWorld()).dimension()); + ((PlayerListBridge) this.server.getPlayerList()).bridge$setNewDestinationDimension(((ServerLevel) event.destinationWorld()).dimension()); // The key is reset to null in the overwrite return playerList.respawn(player, keepAllPlayerData); } @@ -511,12 +511,12 @@ public abstract class ServerGamePacketListenerImplMixin implements ConnectionHol try (final CauseStackManager.StackFrame frame = PhaseTracker.getCauseStackManager().pushCauseFrame()) { frame.pushCause(this.player); final Component message = SpongeAdventure.asAdventure(component); - Audience audience = Sponge.getServer().getBroadcastAudience(); + Audience audience = Sponge.server().broadcastAudience(); final ServerSideConnectionEvent.Disconnect event = SpongeEventFactory.createServerSideConnectionEventDisconnect( - PhaseTracker.getCauseStackManager().getCurrentCause(), audience, Optional.of(audience), message, message, - spongePlayer.getConnection(), spongePlayer); + PhaseTracker.getCauseStackManager().currentCause(), audience, Optional.of(audience), message, message, + spongePlayer.connection(), spongePlayer); SpongeCommon.postEvent(event); - event.getAudience().ifPresent(a -> a.sendMessage(spongePlayer, event.getMessage())); + event.audience().ifPresent(a -> a.sendMessage(spongePlayer, event.message())); } ((ServerPlayerBridge) this.player).bridge$getWorldBorderListener().onPlayerDisconnect(); @@ -549,7 +549,7 @@ public abstract class ServerGamePacketListenerImplMixin implements ConnectionHol try (final CauseStackManager.StackFrame frame = PhaseTracker.getCauseStackManager().pushCauseFrame()) { frame.pushCause(this.player); final ListValue.Mutable newLinesValue = ListValue.mutableOf(Keys.SIGN_LINES, newLines); - final ChangeSignEvent event = SpongeEventFactory.createChangeSignEvent(PhaseTracker.getCauseStackManager().getCurrentCause(), + final ChangeSignEvent event = SpongeEventFactory.createChangeSignEvent(PhaseTracker.getCauseStackManager().currentCause(), originalLinesValue.asImmutable(), newLinesValue, (Sign) blockEntity); final ListValue toApply = SpongeCommon.postEvent(event) ? originalLinesValue : newLinesValue; diff --git a/src/mixins/java/org/spongepowered/common/mixin/core/server/network/ServerLoginPacketListenerImplMixin.java b/src/mixins/java/org/spongepowered/common/mixin/core/server/network/ServerLoginPacketListenerImplMixin.java index 22741f49a0e..050918589a8 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/core/server/network/ServerLoginPacketListenerImplMixin.java +++ b/src/mixins/java/org/spongepowered/common/mixin/core/server/network/ServerLoginPacketListenerImplMixin.java @@ -96,7 +96,7 @@ public abstract class ServerLoginPacketListenerImplMixin implements ServerLoginP cause, disconnectMessage, disconnectMessage, (ServerSideConnection) this); SpongeCommon.postEvent(event); if (event.isCancelled()) { - this.impl$disconnectClient(event.getMessage()); + this.impl$disconnectClient(event.message()); } return event.isCancelled(); } diff --git a/src/mixins/java/org/spongepowered/common/mixin/core/server/players/BanListEntryMixin.java b/src/mixins/java/org/spongepowered/common/mixin/core/server/players/BanListEntryMixin.java index 436ab8c53cb..480b11a08ec 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/core/server/players/BanListEntryMixin.java +++ b/src/mixins/java/org/spongepowered/common/mixin/core/server/players/BanListEntryMixin.java @@ -57,8 +57,8 @@ public abstract class BanListEntryMixin extends StoredUserEntryMixin imple // final Optional user; // if ("Server".equals(this.source)) { // There could be a user called Server, but of course Mojang doesn't care... -// this.bridge$commandSrc = SpongeCommon.getGame().getServer().getConsole(); -// } else if ((user = Sponge.getGame().getServer().getPlayer(this.bannedBy)).isPresent()) { +// this.bridge$commandSrc = SpongeCommon.game().getServer().getConsole(); +// } else if ((user = Sponge.game().getServer().player(this.bannedBy)).isPresent()) { // this.bridge$commandSrc = user.get(); // } } diff --git a/src/mixins/java/org/spongepowered/common/mixin/core/server/players/GameProfileCacheMixin.java b/src/mixins/java/org/spongepowered/common/mixin/core/server/players/GameProfileCacheMixin.java index ed3d362edcb..94c6faa24e5 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/core/server/players/GameProfileCacheMixin.java +++ b/src/mixins/java/org/spongepowered/common/mixin/core/server/players/GameProfileCacheMixin.java @@ -125,7 +125,7 @@ public abstract class GameProfileCacheMixin implements GameProfileCacheBridge { public void bridge$add(final GameProfile profile, final boolean full, final boolean signed) { Objects.requireNonNull(profile, "profile"); - GameProfileCache_GameProfileInfoAccessor accessor = this.profilesByUUID.get(profile.getUniqueId()); + GameProfileCache_GameProfileInfoAccessor accessor = this.profilesByUUID.get(profile.uniqueId()); final com.mojang.authlib.GameProfile current = accessor == null ? null : accessor.invoker$getProfile(); final com.mojang.authlib.GameProfile mcProfile = SpongeGameProfile.toMcProfile(profile); // Don't allow basic game profiles to overwrite the contents if already @@ -136,7 +136,7 @@ public abstract class GameProfileCacheMixin implements GameProfileCacheBridge { } this.shadow$add(mcProfile); - accessor = this.profilesByUUID.get(profile.getUniqueId()); + accessor = this.profilesByUUID.get(profile.uniqueId()); if (accessor == null || accessor.invoker$getProfile() != mcProfile) { return; } @@ -155,7 +155,7 @@ public abstract class GameProfileCacheMixin implements GameProfileCacheBridge { @Inject(method = "add", at = @At(value = "RETURN")) private void impl$UpdateCacheUsername(final com.mojang.authlib.GameProfile profile, final CallbackInfo ci) { - ((SpongeServer) Sponge.getServer()).getUsernameCache().setUsername(profile.getId(), profile.getName()); + ((SpongeServer) Sponge.server()).getUsernameCache().setUsername(profile.getId(), profile.getName()); } @Redirect(method = "lookupGameProfile", @@ -167,8 +167,8 @@ public abstract class GameProfileCacheMixin implements GameProfileCacheBridge { ) private static void impl$LookUpViaSponge(final GameProfileRepository repository, final String[] names, final Agent agent, final ProfileLookupCallback callback) { - final GameProfileManager profileManager = Sponge.getServer().getGameProfileManager(); - profileManager.getBasicProfile(names[0]) + final GameProfileManager profileManager = Sponge.server().gameProfileManager(); + profileManager.basicProfile(names[0]) .whenComplete((profile, ex) -> { if (ex != null) { callback.onProfileLookupFailed(new com.mojang.authlib.GameProfile(null, names[0]), diff --git a/src/mixins/java/org/spongepowered/common/mixin/core/server/players/PlayerListMixin.java b/src/mixins/java/org/spongepowered/common/mixin/core/server/players/PlayerListMixin.java index 6b6b3e863c4..4d956c35b4b 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/core/server/players/PlayerListMixin.java +++ b/src/mixins/java/org/spongepowered/common/mixin/core/server/players/PlayerListMixin.java @@ -186,11 +186,11 @@ public abstract class PlayerListMixin implements PlayerListBridge { mcPlayer.setLevel(mcWorld); final ServerPlayer player = (ServerPlayer) mcPlayer; - final ServerLocation location = player.getServerLocation(); - final Vector3d rotation = player.getRotation(); - // player.getConnection() cannot be used here, because it's still be null at this point + final ServerLocation location = player.serverLocation(); + final Vector3d rotation = player.rotation(); + // player.connection() cannot be used here, because it's still be null at this point final ServerSideConnection connection = (ServerSideConnection) networkManager.getPacketListener(); - final User user = player.getUser(); + final User user = player.user(); final Cause cause = Cause.of(EventContext.empty(), connection, user); final ServerSideConnectionEvent.Login event = SpongeEventFactory.createServerSideConnectionEventLogin(cause, disconnectMessage, @@ -199,15 +199,15 @@ public abstract class PlayerListMixin implements PlayerListBridge { event.setCancelled(true); } if (SpongeCommon.postEvent(event)) { - this.impl$disconnectClient(networkManager, event.getMessage(), player.getProfile()); + this.impl$disconnectClient(networkManager, event.message(), player.profile()); return null; } - final ServerLocation toLocation = event.getToLocation(); - final Vector3d toRotation = event.getToRotation(); - mcPlayer.absMoveTo(toLocation.getX(), toLocation.getY(), toLocation.getZ(), + final ServerLocation toLocation = event.toLocation(); + final Vector3d toRotation = event.toRotation(); + mcPlayer.absMoveTo(toLocation.x(), toLocation.y(), toLocation.z(), (float) toRotation.getY(), (float) toRotation.getX()); - return (net.minecraft.server.level.ServerLevel) toLocation.getWorld(); + return (net.minecraft.server.level.ServerLevel) toLocation.world(); } @Inject(method = "placeNewPlayer", @@ -233,7 +233,7 @@ public abstract class PlayerListMixin implements PlayerListBridge { private void impl$onInitPlayer_printPlayerWorldInJoinFeedback( final Logger logger, final String message, final Object p0, final Object p1, final Object p2, final Object p3, final Object p4, final Object p5, final Connection manager, final net.minecraft.server.level.ServerPlayer entity) { - logger.info("{}[{}] logged in to world '{}' with entity id {} at ({}, {}, {})", p0, p1, ((org.spongepowered.api.world.server.ServerWorld) entity.getLevel()).getKey(), p2, p3, p4, p5); + logger.info("{}[{}] logged in to world '{}' with entity id {} at ({}, {}, {})", p0, p1, ((org.spongepowered.api.world.server.ServerWorld) entity.getLevel()).key(), p2, p3, p4, p5); } @Redirect(method = "placeNewPlayer", @@ -303,7 +303,7 @@ public abstract class PlayerListMixin implements PlayerListBridge { @Inject(method = "placeNewPlayer", at = @At(value = "RETURN")) private void impl$onInitPlayer_join(final Connection networkManager, final net.minecraft.server.level.ServerPlayer mcPlayer, final CallbackInfo ci) { final ServerPlayer player = (ServerPlayer) mcPlayer; - final ServerSideConnection connection = player.getConnection(); + final ServerSideConnection connection = player.connection(); final Cause cause = Cause.of(EventContext.empty(), connection, player); final Audience audience = Audiences.onlinePlayers(); final Component joinComponent = SpongeAdventure.asAdventure(((ServerPlayerBridge) mcPlayer).bridge$getConnectionMessageToSend()); @@ -312,7 +312,7 @@ public abstract class PlayerListMixin implements PlayerListBridge { Optional.of(audience), joinComponent, joinComponent, connection, player, false); SpongeCommon.postEvent(event); if (!event.isMessageCancelled()) { - event.getAudience().ifPresent(audience1 -> audience1.sendMessage(Identity.nil(), event.getMessage())); + event.audience().ifPresent(audience1 -> audience1.sendMessage(Identity.nil(), event.message())); } ((ServerPlayerBridge) mcPlayer).bridge$setConnectionMessageToSend(null); @@ -325,7 +325,7 @@ public abstract class PlayerListMixin implements PlayerListBridge { @Inject(method = "remove", at = @At("HEAD")) private void impl$RemovePlayerReferenceFromScoreboard(final net.minecraft.server.level.ServerPlayer player, final CallbackInfo ci) { - ((ServerScoreboardBridge) ((ServerPlayer) player).getScoreboard()).bridge$removePlayer(player, false); + ((ServerScoreboardBridge) ((ServerPlayer) player).scoreboard()).bridge$removePlayer(player, false); } @Redirect(method = "setLevel", @@ -385,14 +385,14 @@ public abstract class PlayerListMixin implements PlayerListBridge { final org.spongepowered.api.world.server.ServerWorld originalDestinationWorld = (org.spongepowered.api.world.server.ServerWorld) this.server.getLevel(this.impl$originalDestination == null ? Level.OVERWORLD : this.impl$originalDestination); final org.spongepowered.api.world.server.ServerWorld destinationWorld = (org.spongepowered.api.world.server.ServerWorld) this.server.getLevel(this.impl$newDestination == null ? Level.OVERWORLD : this.impl$newDestination); - final RespawnPlayerEvent.Recreate event = SpongeEventFactory.createRespawnPlayerEventRecreate(PhaseTracker.getCauseStackManager().getCurrentCause(), destinationPosition, originalWorld, originalPosition, destinationWorld, originalDestinationWorld, destinationPosition, (ServerPlayer) originalPlayer, (ServerPlayer) recreatedPlayer, this.impl$isGameMechanicRespawn, !keepAllPlayerData); + final RespawnPlayerEvent.Recreate event = SpongeEventFactory.createRespawnPlayerEventRecreate(PhaseTracker.getCauseStackManager().currentCause(), destinationPosition, originalWorld, originalPosition, destinationWorld, originalDestinationWorld, destinationPosition, (ServerPlayer) originalPlayer, (ServerPlayer) recreatedPlayer, this.impl$isGameMechanicRespawn, !keepAllPlayerData); SpongeCommon.postEvent(event); - recreatedPlayer.setPos(event.getDestinationPosition().getX(), event.getDestinationPosition().getY(), event.getDestinationPosition().getZ()); + recreatedPlayer.setPos(event.destinationPosition().getX(), event.destinationPosition().getY(), event.destinationPosition().getZ()); this.impl$isGameMechanicRespawn = false; this.impl$originalDestination = null; this.impl$newDestination = null; - final ServerLevel targetWorld = (ServerLevel) event.getDestinationWorld(); + final ServerLevel targetWorld = (ServerLevel) event.destinationWorld(); ((ServerPlayerBridge) recreatedPlayer).bridge$sendChangeDimension( targetWorld.dimensionType(), ((ClientboundRespawnPacketAccessor) packetIn).accessor$dimension(), diff --git a/src/mixins/java/org/spongepowered/common/mixin/core/server/rcon/thread/RconClientMixin.java b/src/mixins/java/org/spongepowered/common/mixin/core/server/rcon/thread/RconClientMixin.java index b3be44408b4..c11ad4a41ba 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/core/server/rcon/thread/RconClientMixin.java +++ b/src/mixins/java/org/spongepowered/common/mixin/core/server/rcon/thread/RconClientMixin.java @@ -81,7 +81,7 @@ protected RconClientMixin(final String p_i45300_2_) { causeStackManager.pushCause(this); causeStackManager.pushCause(this.impl$source); final RconConnectionEvent.Disconnect event = SpongeEventFactory.createRconConnectionEventDisconnect( - causeStackManager.getCurrentCause(), (RconConnection) this.impl$source); + causeStackManager.currentCause(), (RconConnection) this.impl$source); SpongeCommon.postEvent(event); causeStackManager.popCauses(2); return event; @@ -110,7 +110,7 @@ public void run() { causeStackManager.pushCause(this); causeStackManager.pushCause(this.impl$source); final RconConnectionEvent.Connect event = SpongeEventFactory.createRconConnectionEventConnect( - causeStackManager.getCurrentCause(), (RconConnection) this.impl$source); + causeStackManager.currentCause(), (RconConnection) this.impl$source); SpongeCommon.postEvent(event); causeStackManager.popCauses(2); return event; @@ -192,7 +192,7 @@ public void run() { causeStackManager.pushCause(this); causeStackManager.pushCause(this.impl$source); final RconConnectionEvent.Auth event1 = SpongeEventFactory.createRconConnectionEventAuth( - causeStackManager.getCurrentCause(), (RconConnection) this.impl$source); + causeStackManager.currentCause(), (RconConnection) this.impl$source); SpongeCommon.postEvent(event1); causeStackManager.popCauses(2); return event1; diff --git a/src/mixins/java/org/spongepowered/common/mixin/core/world/damagesource/DamageSourceMixin.java b/src/mixins/java/org/spongepowered/common/mixin/core/world/damagesource/DamageSourceMixin.java index 14bf759230e..d9e27ac9042 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/core/world/damagesource/DamageSourceMixin.java +++ b/src/mixins/java/org/spongepowered/common/mixin/core/world/damagesource/DamageSourceMixin.java @@ -123,7 +123,7 @@ private static void onSetExplosionSource(@Nullable final Explosion explosion, if (!this.msgId.contains(":")) { this.impl$damageType = MemoizedSupplier.memoize(() -> DamageSourceToTypeProvider.INSTANCE.getOrCustom(this.msgId).get()); } else { - this.impl$damageType = MemoizedSupplier.memoize(() -> Sponge.getGame().registries().registry(RegistryTypes.DAMAGE_TYPE).findValue(ResourceKey.resolve(this.msgId)).orElseGet(DamageTypes.CUSTOM)); + this.impl$damageType = MemoizedSupplier.memoize(() -> Sponge.game().registries().registry(RegistryTypes.DAMAGE_TYPE).findValue(ResourceKey.resolve(this.msgId)).orElseGet(DamageTypes.CUSTOM)); } } @@ -164,7 +164,7 @@ private static void onSetExplosionSource(@Nullable final Explosion explosion, @Override public String toString() { - final ResourceKey resourceKey = Sponge.getGame().registries().registry(RegistryTypes.DAMAGE_TYPE).valueKey(this.impl$damageType.get()); + final ResourceKey resourceKey = Sponge.game().registries().registry(RegistryTypes.DAMAGE_TYPE).valueKey(this.impl$damageType.get()); return MoreObjects.toStringHelper("DamageSource") .add("Name", this.msgId) .add("Key", resourceKey) diff --git a/src/mixins/java/org/spongepowered/common/mixin/core/world/damagesource/EntityDamageSourceMixin.java b/src/mixins/java/org/spongepowered/common/mixin/core/world/damagesource/EntityDamageSourceMixin.java index 473d33ca63c..cedc161d258 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/core/world/damagesource/EntityDamageSourceMixin.java +++ b/src/mixins/java/org/spongepowered/common/mixin/core/world/damagesource/EntityDamageSourceMixin.java @@ -42,7 +42,7 @@ public abstract class EntityDamageSourceMixin extends DamageSourceMixin { @Override public String toString() { - final ResourceKey resourceKey = Sponge.getGame().registries().registry(RegistryTypes.DAMAGE_TYPE).valueKey(this.impl$damageType.get()); + final ResourceKey resourceKey = Sponge.game().registries().registry(RegistryTypes.DAMAGE_TYPE).valueKey(this.impl$damageType.get()); return MoreObjects.toStringHelper("EntityDamageSource") .add("Name", this.msgId) diff --git a/src/mixins/java/org/spongepowered/common/mixin/core/world/damagesource/IndirectEntityDamageSourceMixin.java b/src/mixins/java/org/spongepowered/common/mixin/core/world/damagesource/IndirectEntityDamageSourceMixin.java index 33dc27c3910..b9338dc4f16 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/core/world/damagesource/IndirectEntityDamageSourceMixin.java +++ b/src/mixins/java/org/spongepowered/common/mixin/core/world/damagesource/IndirectEntityDamageSourceMixin.java @@ -64,7 +64,7 @@ private void onConstruct(final CallbackInfo callbackInfo) { @Override public String toString() { - final ResourceKey resourceKey = Sponge.getGame().registries().registry(RegistryTypes.DAMAGE_TYPE).valueKey(this.impl$damageType.get()); + final ResourceKey resourceKey = Sponge.game().registries().registry(RegistryTypes.DAMAGE_TYPE).valueKey(this.impl$damageType.get()); final MoreObjects.ToStringHelper helper = MoreObjects.toStringHelper("IndirectEntityDamageSource") .add("Name", this.msgId) .add("Type", resourceKey) diff --git a/src/mixins/java/org/spongepowered/common/mixin/core/world/entity/AgableMobMixin.java b/src/mixins/java/org/spongepowered/common/mixin/core/world/entity/AgableMobMixin.java index 8d90d1309a4..5a0cc78a759 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/core/world/entity/AgableMobMixin.java +++ b/src/mixins/java/org/spongepowered/common/mixin/core/world/entity/AgableMobMixin.java @@ -43,7 +43,7 @@ public abstract class AgableMobMixin extends MobMixin { private void impl$callReadyToMateOnAgeUp(final int age, final CallbackInfo ci) { if (age == 0 && ShouldFire.BREEDING_EVENT_READY_TO_MATE) { if (((AgableMob) (Object) this) instanceof net.minecraft.world.entity.animal.Animal) { - final BreedingEvent.ReadyToMate event = SpongeEventFactory.createBreedingEventReadyToMate(PhaseTracker.getCauseStackManager().getCurrentCause(), (Animal) this); + final BreedingEvent.ReadyToMate event = SpongeEventFactory.createBreedingEventReadyToMate(PhaseTracker.getCauseStackManager().currentCause(), (Animal) this); SpongeCommon.postEvent(event); } } diff --git a/src/mixins/java/org/spongepowered/common/mixin/core/world/entity/EntityMixin.java b/src/mixins/java/org/spongepowered/common/mixin/core/world/entity/EntityMixin.java index 258bc5c096f..68cdde4ae53 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/core/world/entity/EntityMixin.java +++ b/src/mixins/java/org/spongepowered/common/mixin/core/world/entity/EntityMixin.java @@ -220,7 +220,7 @@ public abstract class EntityMixin implements EntityBridge, PlatformEntityBridge, @Override public boolean bridge$setLocation(final ServerLocation location) { - if (this.removed || ((WorldBridge) location.getWorld()).bridge$isFake()) { + if (this.removed || ((WorldBridge) location.world()).bridge$isFake()) { return false; } @@ -230,42 +230,42 @@ public abstract class EntityMixin implements EntityBridge, PlatformEntityBridge, final net.minecraft.world.phys.Vec3 originalPosition = this.shadow$position(); - net.minecraft.server.level.ServerLevel destinationWorld = (net.minecraft.server.level.ServerLevel) location.getWorld(); + net.minecraft.server.level.ServerLevel destinationWorld = (net.minecraft.server.level.ServerLevel) location.world(); if (this.shadow$getCommandSenderWorld() != destinationWorld) { - final ChangeEntityWorldEvent.Pre event = SpongeEventFactory.createChangeEntityWorldEventPre(frame.getCurrentCause(), - (org.spongepowered.api.entity.Entity) this, (ServerWorld) this.shadow$getCommandSenderWorld(), location.getWorld(), - location.getWorld()); - if (SpongeCommon.postEvent(event) && ((WorldBridge) event.getDestinationWorld()).bridge$isFake()) { + final ChangeEntityWorldEvent.Pre event = SpongeEventFactory.createChangeEntityWorldEventPre(frame.currentCause(), + (org.spongepowered.api.entity.Entity) this, (ServerWorld) this.shadow$getCommandSenderWorld(), location.world(), + location.world()); + if (SpongeCommon.postEvent(event) && ((WorldBridge) event.destinationWorld()).bridge$isFake()) { return false; } final ChangeEntityWorldEvent.Reposition repositionEvent = - SpongeEventFactory.createChangeEntityWorldEventReposition(frame.getCurrentCause(), + SpongeEventFactory.createChangeEntityWorldEventReposition(frame.currentCause(), (org.spongepowered.api.entity.Entity) this, (ServerWorld) this.shadow$getCommandSenderWorld(), - VecHelper.toVector3d(this.shadow$position()), location.getPosition(), event.getOriginalDestinationWorld(), - location.getPosition(), event.getDestinationWorld()); + VecHelper.toVector3d(this.shadow$position()), location.position(), event.originalDestinationWorld(), + location.position(), event.destinationWorld()); if (SpongeCommon.postEvent(repositionEvent)) { return false; } - destinationWorld = (net.minecraft.server.level.ServerLevel) event.getDestinationWorld(); + destinationWorld = (net.minecraft.server.level.ServerLevel) event.destinationWorld(); - this.shadow$setPos(repositionEvent.getDestinationPosition().getX(), - repositionEvent.getDestinationPosition().getY(), repositionEvent.getDestinationPosition().getZ()); + this.shadow$setPos(repositionEvent.destinationPosition().getX(), + repositionEvent.destinationPosition().getY(), repositionEvent.destinationPosition().getZ()); } else { final Vector3d destination; if (ShouldFire.MOVE_ENTITY_EVENT) { - final MoveEntityEvent event = SpongeEventFactory.createMoveEntityEvent(frame.getCurrentCause(), + final MoveEntityEvent event = SpongeEventFactory.createMoveEntityEvent(frame.currentCause(), (org.spongepowered.api.entity.Entity) this, VecHelper.toVector3d(this.shadow$position()), - location.getPosition(), location.getPosition()); + location.position(), location.position()); if (SpongeCommon.postEvent(event)) { return false; } - destination = event.getDestinationPosition(); + destination = event.destinationPosition(); } else { - destination = location.getPosition(); + destination = location.position(); } this.shadow$setPos(destination.getX(), destination.getY(), destination.getZ()); } @@ -301,7 +301,7 @@ public abstract class EntityMixin implements EntityBridge, PlatformEntityBridge, frame.pushCause(this); frame.addContext(EventContextKeys.DISMOUNT_TYPE, type); if (SpongeCommon.postEvent(SpongeEventFactory. - createRideEntityEventDismount(frame.getCurrentCause(), (org.spongepowered.api.entity.Entity) this.shadow$getVehicle()))) { + createRideEntityEventDismount(frame.currentCause(), (org.spongepowered.api.entity.Entity) this.shadow$getVehicle()))) { return false; } } @@ -411,8 +411,8 @@ public abstract class EntityMixin implements EntityBridge, PlatformEntityBridge, @Override public void bridge$setTransform(final Transform transform) { - this.shadow$setPos(transform.getPosition().getX(), transform.getPosition().getY(), transform.getPosition().getZ()); - this.shadow$setRot((float) transform.getYaw(), (float) transform.getPitch()); + this.shadow$setPos(transform.position().getX(), transform.position().getY(), transform.position().getZ()); + this.shadow$setRot((float) transform.yaw(), (float) transform.pitch()); } @Redirect(method = "findDimensionEntryPoint", at = @At(value = "INVOKE", @@ -497,7 +497,7 @@ public abstract class EntityMixin implements EntityBridge, PlatformEntityBridge, if (preChangeEvent.isCancelled()) { return null; } - final net.minecraft.server.level.ServerLevel targetWorld = (net.minecraft.server.level.ServerLevel) preChangeEvent.getDestinationWorld(); + final net.minecraft.server.level.ServerLevel targetWorld = (net.minecraft.server.level.ServerLevel) preChangeEvent.destinationWorld(); final Vector3d currentPosition = VecHelper.toVector3d(this.shadow$position()); // If a player, set the fact they are changing dimensions @@ -536,7 +536,7 @@ public abstract class EntityMixin implements EntityBridge, PlatformEntityBridge, if (transportedEntity != null && this.impl$shouldFireRepositionEvent) { final Vector3d destination = VecHelper.toVector3d(this.shadow$position()); final ChangeEntityWorldEvent.Reposition reposition = SpongeEventFactory.createChangeEntityWorldEventReposition( - PhaseTracker.getCauseStackManager().getCurrentCause(), + PhaseTracker.getCauseStackManager().currentCause(), (org.spongepowered.api.entity.Entity) transportedEntity, (org.spongepowered.api.world.server.ServerWorld) serverworld, currentPosition, @@ -549,8 +549,8 @@ public abstract class EntityMixin implements EntityBridge, PlatformEntityBridge, if (reposition.isCancelled()) { // send them back to the original destination finalPosition = originalDestination; - } else if (reposition.getDestinationPosition() != destination) { - finalPosition = reposition.getDestinationPosition(); + } else if (reposition.destinationPosition() != destination) { + finalPosition = reposition.destinationPosition(); } else { finalPosition = null; } @@ -635,12 +635,12 @@ public abstract class EntityMixin implements EntityBridge, PlatformEntityBridge, (ServerWorld) targetWorld, destinationPosition ); - if (!reposition.isCancelled() && reposition.getDestinationPosition() != destinationPosition) { + if (!reposition.isCancelled() && reposition.destinationPosition() != destinationPosition) { this.impl$dontCreateExitPortal = true; // Something changed so we want to re-rerun this loop. // TODO: There is an open question here about whether we want to force the creation of a portal in this // scenario, or whether we're happy if the repositioning will put someone in a nearby portal. - cir.setReturnValue(this.shadow$getExitPortal(targetWorld, VecHelper.toBlockPos(reposition.getDestinationPosition()), targetIsNether)); + cir.setReturnValue(this.shadow$getExitPortal(targetWorld, VecHelper.toBlockPos(reposition.destinationPosition()), targetIsNether)); } } } @@ -652,7 +652,7 @@ public abstract class EntityMixin implements EntityBridge, PlatformEntityBridge, this.impl$shouldFireRepositionEvent = false; final ChangeEntityWorldEvent.Reposition reposition = SpongeEventFactory.createChangeEntityWorldEventReposition( - PhaseTracker.getCauseStackManager().getCurrentCause(), + PhaseTracker.getCauseStackManager().currentCause(), (org.spongepowered.api.entity.Entity) this, (ServerWorld) this.level, VecHelper.toVector3d(this.position), @@ -694,13 +694,13 @@ public final void teleportToWithTicket(final double x, final double y, final dou final Vector3d destinationPosition; boolean hasMovementContext = true; if (ShouldFire.MOVE_ENTITY_EVENT) { - if (!server.getCurrentContext().containsKey(EventContextKeys.MOVEMENT_TYPE)) { + if (!server.currentContext().containsKey(EventContextKeys.MOVEMENT_TYPE)) { hasMovementContext = false; server.pushCause(SpongeCommon.getActivePlugin()); server.addContext(EventContextKeys.MOVEMENT_TYPE, MovementTypes.PLUGIN); } - final MoveEntityEvent event = SpongeEventFactory.createMoveEntityEvent(server.getCurrentCause(), + final MoveEntityEvent event = SpongeEventFactory.createMoveEntityEvent(server.currentCause(), (org.spongepowered.api.entity.Entity) this, VecHelper.toVector3d(this.shadow$position()), new Vector3d(x, y, z), new Vector3d(x, y, z)); @@ -713,7 +713,7 @@ public final void teleportToWithTicket(final double x, final double y, final dou return; } - destinationPosition = event.getDestinationPosition(); + destinationPosition = event.destinationPosition(); } else { destinationPosition = new Vector3d(x, y, z); } @@ -738,7 +738,7 @@ public final void teleportToWithTicket(final double x, final double y, final dou final CallbackInfoReturnable ci) { if (!this.level.isClientSide && ShouldFire.RIDE_ENTITY_EVENT_MOUNT) { PhaseTracker.getCauseStackManager().pushCause(this); - if (SpongeCommon.postEvent(SpongeEventFactory.createRideEntityEventMount(PhaseTracker.getCauseStackManager().getCurrentCause(), (org.spongepowered.api.entity.Entity) vehicle))) { + if (SpongeCommon.postEvent(SpongeEventFactory.createRideEntityEventMount(PhaseTracker.getCauseStackManager().currentCause(), (org.spongepowered.api.entity.Entity) vehicle))) { ci.cancel(); } PhaseTracker.getCauseStackManager().popCause(); @@ -826,7 +826,7 @@ public void stopRiding() { } else { this.impl$visibilityTicks = 1; this.impl$pendingVisibilityUpdate = false; - for (final ServerPlayerEntity entityPlayerMP : SpongeCommon.getServer().getPlayerList().getPlayers()) { + for (final ServerPlayerEntity entityPlayerMP : SpongeCommon.getServer().getPlayerList().players()) { if ((Entity) (Object) this == entityPlayerMP) { continue; } @@ -1025,7 +1025,7 @@ public ItemEntity entityDropItem(final ItemStack stack, final float offsetY) { if (this.fire < 1 && !this.impl$isImmuneToFireForIgniteEvent()) { try (final CauseStackManager.StackFrame frame = PhaseTracker.getCauseStackManager().pushCauseFrame()) { - frame.pushCause(((org.spongepowered.api.entity.Entity) this).getLocation().getWorld()); + frame.pushCause(((org.spongepowered.api.entity.Entity) this).location().world()); final IgniteEntityEvent event = SpongeEventFactory. createIgniteEntityEvent(frame.getCurrentCause(), ticks, ticks, (org.spongepowered.api.entity.Entity) this); @@ -1033,7 +1033,7 @@ public ItemEntity entityDropItem(final ItemStack stack, final float offsetY) { this.fire = 0; return; // set fire ticks to 0 } - this.fire = event.getFireTicks(); + this.fire = event.fireTicks(); } } } diff --git a/src/mixins/java/org/spongepowered/common/mixin/core/world/entity/LightningBoltMixin.java b/src/mixins/java/org/spongepowered/common/mixin/core/world/entity/LightningBoltMixin.java index 36284c07ea5..4b5ce4b9620 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/core/world/entity/LightningBoltMixin.java +++ b/src/mixins/java/org/spongepowered/common/mixin/core/world/entity/LightningBoltMixin.java @@ -105,14 +105,14 @@ public abstract class LightningBoltMixin extends EntityMixin { return; } try (final CauseStackManager.StackFrame frame = PhaseTracker.getCauseStackManager().pushCauseFrame()) { - final LightningEvent.Strike strike = SpongeEventFactory.createLightningEventStrike(frame.getCurrentCause(), this.impl$struckEntities); - Sponge.getEventManager().post(strike); + final LightningEvent.Strike strike = SpongeEventFactory.createLightningEventStrike(frame.currentCause(), this.impl$struckEntities); + Sponge.eventManager().post(strike); if (!strike.isCancelled()) { - for (final Entity e : strike.getEntities()) { + for (final Entity e : strike.entities()) { ((net.minecraft.world.entity.Entity) e).thunderHit((ServerLevel) this.level, (LightningBolt) (Object) this); } - SpongeCommon.postEvent(SpongeEventFactory.createLightningEventPost(frame.getCurrentCause())); + SpongeCommon.postEvent(SpongeEventFactory.createLightningEventPost(frame.currentCause())); } } } diff --git a/src/mixins/java/org/spongepowered/common/mixin/core/world/entity/LivingEntityMixin.java b/src/mixins/java/org/spongepowered/common/mixin/core/world/entity/LivingEntityMixin.java index 42a2dca75dd..7c1c00099ef 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/core/world/entity/LivingEntityMixin.java +++ b/src/mixins/java/org/spongepowered/common/mixin/core/world/entity/LivingEntityMixin.java @@ -244,7 +244,7 @@ public abstract class LivingEntityMixin extends EntityMixin implements LivingEnt DamageEventHandler.generateCauseFor(damageSource, frame); final DamageEntityEvent event = SpongeEventFactory - .createDamageEntityEvent(frame.getCurrentCause(), (org.spongepowered.api.entity.Entity) this, originalFunctions, + .createDamageEntityEvent(frame.currentCause(), (org.spongepowered.api.entity.Entity) this, originalFunctions, originalDamage); if (damageSource != SpongeDamageSources.IGNORED) { // Basically, don't throw an event if it's our own damage source @@ -254,7 +254,7 @@ public abstract class LivingEntityMixin extends EntityMixin implements LivingEnt return false; } - damage = (float) event.getFinalDamage(); + damage = (float) event.finalDamage(); // Sponge Start - Allow the platform to adjust damage before applying armor/etc damage = this.bridge$applyModDamageBeforeFunctions((LivingEntity) (Object) this, damageSource, damage); @@ -266,7 +266,7 @@ public abstract class LivingEntityMixin extends EntityMixin implements LivingEnt // without using our mixin redirects in EntityFallingBlockMixin. if ((damageSource instanceof FallingBlockDamageSource) || damageSource == DamageSource.ANVIL || damageSource == DamageSource.FALLING_BLOCK && !helmet.isEmpty()) { - helmet.hurtAndBreak((int) (event.getBaseDamage() * 4.0F + this.random.nextFloat() * event.getBaseDamage() * 2.0F), + helmet.hurtAndBreak((int) (event.baseDamage() * 4.0F + this.random.nextFloat() * event.baseDamage() * 2.0F), (LivingEntity) (Object) this, (entity) -> { entity.broadcastBreakEvent(EquipmentSlot.HEAD); }); @@ -274,7 +274,7 @@ public abstract class LivingEntityMixin extends EntityMixin implements LivingEnt // Shield if (shieldFunction.isPresent()) { - this.shadow$hurtCurrentlyUsedShield((float) event.getBaseDamage()); + this.shadow$hurtCurrentlyUsedShield((float) event.baseDamage()); if (!damageSource.isProjectile()) { final Entity entity = damageSource.getDirectEntity(); @@ -286,11 +286,11 @@ public abstract class LivingEntityMixin extends EntityMixin implements LivingEnt // Armor if (!damageSource.isBypassArmor() && armorFunction.isPresent()) { - this.shadow$hurtArmor(damageSource, (float) event.getBaseDamage()); + this.shadow$hurtArmor(damageSource, (float) event.baseDamage()); } // Resistance modifier post calculation if (resistanceFunction.isPresent()) { - final float f2 = (float) event.getDamage(resistanceFunction.get().getModifier()) - damage; + final float f2 = (float) event.damage(resistanceFunction.get().modifier()) - damage; if (f2 > 0.0F && f2 < 3.4028235E37F) { if (((LivingEntity) (Object) this) instanceof net.minecraft.server.level.ServerPlayer) { ((net.minecraft.server.level.ServerPlayer) ((LivingEntity) (Object) this)).awardStat(Stats.DAMAGE_RESISTED, Math.round(f2 * 10.0F)); @@ -301,13 +301,13 @@ public abstract class LivingEntityMixin extends EntityMixin implements LivingEnt } - double absorptionModifier = absorptionFunction.map(function -> event.getDamage(function.getModifier())).orElse(0d); + double absorptionModifier = absorptionFunction.map(function -> event.damage(function.modifier())).orElse(0d); if (absorptionFunction.isPresent()) { - absorptionModifier = event.getDamage(absorptionFunction.get().getModifier()); + absorptionModifier = event.damage(absorptionFunction.get().modifier()); } - final float f = (float) event.getFinalDamage() - (float) absorptionModifier; + final float f = (float) event.finalDamage() - (float) absorptionModifier; this.shadow$setAbsorptionAmount(Math.max(this.shadow$getAbsorptionAmount() + (float) absorptionModifier, 0.0F)); if (f > 0.0F && f < 3.4028235E37F && damageSource.getEntity() instanceof net.minecraft.server.level.ServerPlayer) { ((net.minecraft.server.level.ServerPlayer) damageSource.getEntity()).awardStat(Stats.DAMAGE_DEALT_ABSORBED, Math.round(f * 10.0F)); @@ -363,7 +363,7 @@ protected void actuallyHurt(final DamageSource damageSource, final float damage) @Inject(method = "die", at = @At("HEAD"), cancellable = true) private void impl$throwDestructEntityDeath(DamageSource cause, CallbackInfo ci) { - final boolean throwEvent = !((WorldBridge) this.level).bridge$isFake() && Sponge.isServerAvailable() && Sponge.getServer().onMainThread(); + final boolean throwEvent = !((WorldBridge) this.level).bridge$isFake() && Sponge.isServerAvailable() && Sponge.server().onMainThread(); if (!this.dead) { // isDead should be set later on in this method so we aren't re-throwing the events. if (throwEvent && this.impl$deathEventsPosted <= Constants.Sponge.MAX_DEATH_EVENTS_BEFORE_GIVING_UP) { // ignore because some moron is not resetting the entity. @@ -657,11 +657,11 @@ public boolean hurt(final DamageSource source, final float amount) { frame.pushCause(this); // ENTITY_TELEPORT is our fallback context - if (!frame.getCurrentContext().containsKey(EventContextKeys.MOVEMENT_TYPE)) { + if (!frame.currentContext().containsKey(EventContextKeys.MOVEMENT_TYPE)) { frame.addContext(EventContextKeys.MOVEMENT_TYPE, MovementTypes.ENTITY_TELEPORT); } - final MoveEntityEvent event = SpongeEventFactory.createMoveEntityEvent(frame.getCurrentCause(), + final MoveEntityEvent event = SpongeEventFactory.createMoveEntityEvent(frame.currentCause(), (org.spongepowered.api.entity.Entity) this, this.impl$preTeleportPosition, new Vector3d(this.shadow$getX(), this.shadow$getY(), this.shadow$getZ()), new Vector3d(x, y, z)); @@ -673,8 +673,8 @@ public boolean hurt(final DamageSource source, final float amount) { return; } - this.shadow$teleportTo(event.getDestinationPosition().getX(), event.getDestinationPosition().getY(), - event.getDestinationPosition().getZ()); + this.shadow$teleportTo(event.destinationPosition().getX(), event.destinationPosition().getY(), + event.destinationPosition().getZ()); } } @@ -729,14 +729,14 @@ public boolean canBeCollidedWith() { final ItemStackSnapshot snapshot = ItemStackUtil.snapshotOf(stack); final HandType handType = (HandType) (Object) hand; this.impl$addSelfToFrame(frame, snapshot, handType); - event = SpongeEventFactory.createUseItemStackEventStart(PhaseTracker.getCauseStackManager().getCurrentCause(), + event = SpongeEventFactory.createUseItemStackEventStart(PhaseTracker.getCauseStackManager().currentCause(), stack.getUseDuration(), stack.getUseDuration(), snapshot); } if (SpongeCommon.postEvent(event)) { ci.cancel(); } else { - this.useItemRemaining = event.getRemainingDuration(); + this.useItemRemaining = event.remainingDuration(); } } @@ -763,8 +763,8 @@ public boolean canBeCollidedWith() { frame.pushCause(this); frame.addContext(EventContextKeys.USED_ITEM, snapshot); if (this instanceof ServerPlayer) { - frame.addContext(EventContextKeys.CREATOR, ((ServerPlayer) this).getUser()); - frame.addContext(EventContextKeys.NOTIFIER, ((ServerPlayer) this).getUser()); + frame.addContext(EventContextKeys.CREATOR, ((ServerPlayer) this).user()); + frame.addContext(EventContextKeys.NOTIFIER, ((ServerPlayer) this).user()); } } @@ -782,12 +782,12 @@ public boolean canBeCollidedWith() { final ItemStackSnapshot snapshot = ItemStackUtil.snapshotOf(this.useItem); final HandType handType = (HandType) (Object) this.shadow$getUsedItemHand(); this.impl$addSelfToFrame(frame, snapshot, handType); - event = SpongeEventFactory.createUseItemStackEventTick(PhaseTracker.getCauseStackManager().getCurrentCause(), + event = SpongeEventFactory.createUseItemStackEventTick(PhaseTracker.getCauseStackManager().currentCause(), this.useItemRemaining, this.useItemRemaining, snapshot); SpongeCommon.postEvent(event); } // Because the item usage will only finish if useItemRemaining == 0 and decrements it first, it should be >= 1 - this.useItemRemaining = Math.max(event.getRemainingDuration(), 1); + this.useItemRemaining = Math.max(event.remainingDuration(), 1); if (event.isCancelled()) { // Get prepared for some cool hacks: We're within the condition for updateItemUse @@ -815,12 +815,12 @@ public boolean canBeCollidedWith() { final ItemStackSnapshot snapshot = ItemStackUtil.snapshotOf(this.useItem); final HandType handType = (HandType) (Object) this.shadow$getUsedItemHand(); this.impl$addSelfToFrame(frame, snapshot, handType); - event = SpongeEventFactory.createUseItemStackEventFinish(PhaseTracker.getCauseStackManager().getCurrentCause(), + event = SpongeEventFactory.createUseItemStackEventFinish(PhaseTracker.getCauseStackManager().currentCause(), this.useItemRemaining, this.useItemRemaining, snapshot); } SpongeCommon.postEvent(event); - if (event.getRemainingDuration() > 0) { - this.useItemRemaining = event.getRemainingDuration(); + if (event.remainingDuration() > 0) { + this.useItemRemaining = event.remainingDuration(); ci.cancel(); } else if (event.isCancelled()) { this.shadow$stopUsingItem(); @@ -854,7 +854,7 @@ public boolean canBeCollidedWith() { final ItemStackSnapshot snapshot = ItemStackUtil.snapshotOf(stack == null ? ItemStack.EMPTY : stack); final HandType handType = (HandType) (Object) hand; this.impl$addSelfToFrame(frame, activeItemStackSnapshot, handType); - event = SpongeEventFactory.createUseItemStackEventReplace(PhaseTracker.getCauseStackManager().getCurrentCause(), + event = SpongeEventFactory.createUseItemStackEventReplace(PhaseTracker.getCauseStackManager().currentCause(), this.useItemRemaining, this.useItemRemaining, activeItemStackSnapshot, new Transaction<>(ItemStackUtil.snapshotOf(this.impl$activeItemStackCopy), snapshot)); } @@ -864,12 +864,12 @@ public boolean canBeCollidedWith() { return; } - if (!event.getItemStackResult().isValid()) { + if (!event.itemStackResult().isValid()) { this.shadow$setItemInHand(hand, this.impl$activeItemStackCopy.copy()); return; } - this.shadow$setItemInHand(hand, ItemStackUtil.fromSnapshotToNative(event.getItemStackResult().getFinal())); + this.shadow$setItemInHand(hand, ItemStackUtil.fromSnapshotToNative(event.itemStackResult().finalReplacement())); } @SuppressWarnings("ConstantConditions") @@ -886,7 +886,7 @@ public boolean canBeCollidedWith() { final ItemStackSnapshot snapshot = ItemStackUtil.snapshotOf(stack); final HandType handType = (HandType) (Object) this.shadow$getUsedItemHand(); this.impl$addSelfToFrame(frame, snapshot, handType); - if (!SpongeCommon.postEvent(SpongeEventFactory.createUseItemStackEventStop(PhaseTracker.getCauseStackManager().getCurrentCause(), + if (!SpongeCommon.postEvent(SpongeEventFactory.createUseItemStackEventStop(PhaseTracker.getCauseStackManager().currentCause(), duration, duration, snapshot))) { stack.releaseUsing(world, self, duration); } @@ -906,7 +906,7 @@ public boolean canBeCollidedWith() { try (final CauseStackManager.StackFrame frame = PhaseTracker.getCauseStackManager().pushCauseFrame()) { this.impl$addSelfToFrame(frame, snapshot); - SpongeCommon.postEvent(SpongeEventFactory.createUseItemStackEventReset(PhaseTracker.getCauseStackManager().getCurrentCause(), + SpongeCommon.postEvent(SpongeEventFactory.createUseItemStackEventReset(PhaseTracker.getCauseStackManager().currentCause(), this.useItemRemaining, this.useItemRemaining, snapshot)); } this.impl$activeItemStackCopy = null; diff --git a/src/mixins/java/org/spongepowered/common/mixin/core/world/entity/MobMixin.java b/src/mixins/java/org/spongepowered/common/mixin/core/world/entity/MobMixin.java index fed03915af2..8a4cb435f90 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/core/world/entity/MobMixin.java +++ b/src/mixins/java/org/spongepowered/common/mixin/core/world/entity/MobMixin.java @@ -119,7 +119,7 @@ public abstract class MobMixin extends LivingEntityMixin { } else { csm.pushCause(entity); } - final UnleashEntityEvent event = SpongeEventFactory.createUnleashEntityEvent(csm.getCurrentCause(), (Living) this); + final UnleashEntityEvent event = SpongeEventFactory.createUnleashEntityEvent(csm.currentCause(), (Living) this); SpongeCommon.postEvent(event); csm.popCause(); if (event.isCancelled()) { @@ -151,7 +151,7 @@ private void onSetAttackTarget(@Nullable final LivingEntity entitylivingbaseIn, if (event.isCancelled()) { ci.cancel(); } else { - this.target = ((LivingEntity) event.getTarget().orElse(null)); + this.target = ((LivingEntity) event.target().orElse(null)); } } } @@ -223,16 +223,16 @@ public boolean doHurtTarget(final net.minecraft.world.entity.Entity targetEntity // Sponge Start - Throw our event and handle appropriately final DamageSource damageSource = DamageSource.mobAttack((Mob) (Object) this); PhaseTracker.getCauseStackManager().pushCause(damageSource); - final AttackEntityEvent event = SpongeEventFactory.createAttackEntityEvent(PhaseTracker.getCauseStackManager().getCurrentCause(), (org.spongepowered.api.entity.Entity) targetEntity, + final AttackEntityEvent event = SpongeEventFactory.createAttackEntityEvent(PhaseTracker.getCauseStackManager().currentCause(), (org.spongepowered.api.entity.Entity) targetEntity, originalFunctions, knockbackModifier, originalBaseDamage); SpongeCommon.postEvent(event); PhaseTracker.getCauseStackManager().popCause(); if (event.isCancelled()) { return false; } - knockbackModifier = event.getKnockbackModifier(); + knockbackModifier = event.knockbackModifier(); // boolean attackSucceeded = targetEntity.attackEntityFrom(DamageSource.causeMobDamage(this), baseDamage); - final boolean attackSucceeded = targetEntity.hurt(damageSource, (float) event.getFinalOutputDamage()); + final boolean attackSucceeded = targetEntity.hurt(damageSource, (float) event.finalOutputDamage()); // Sponge End if (attackSucceeded) { if (knockbackModifier > 0 && targetEntity instanceof LivingEntity) { diff --git a/src/mixins/java/org/spongepowered/common/mixin/core/world/entity/ai/goal/BreedGoalMixin.java b/src/mixins/java/org/spongepowered/common/mixin/core/world/entity/ai/goal/BreedGoalMixin.java index 73343c54b12..a2870ac486d 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/core/world/entity/ai/goal/BreedGoalMixin.java +++ b/src/mixins/java/org/spongepowered/common/mixin/core/world/entity/ai/goal/BreedGoalMixin.java @@ -68,9 +68,9 @@ public abstract class BreedGoalMixin { try (final CauseStackManager.StackFrame frame = PhaseTracker.getCauseStackManager().pushCauseFrame()) { frame.pushCause(this.animal); final org.spongepowered.api.event.entity.BreedingEvent.FindMate event = - SpongeEventFactory.createBreedingEventFindMate(frame.getCurrentCause(), TristateResult.Result.DEFAULT, + SpongeEventFactory.createBreedingEventFindMate(frame.currentCause(), TristateResult.Result.DEFAULT, TristateResult.Result.DEFAULT, (Animal) nearbyMate, true); - if (SpongeCommon.postEvent(event) || event.getResult() == TristateResult.Result.DENY) { + if (SpongeCommon.postEvent(event) || event.result() == TristateResult.Result.DENY) { nearbyMate = null; } } diff --git a/src/mixins/java/org/spongepowered/common/mixin/core/world/entity/ai/goal/GoalSelectorMixin.java b/src/mixins/java/org/spongepowered/common/mixin/core/world/entity/ai/goal/GoalSelectorMixin.java index 23e6a73be94..b3f785abb00 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/core/world/entity/ai/goal/GoalSelectorMixin.java +++ b/src/mixins/java/org/spongepowered/common/mixin/core/world/entity/ai/goal/GoalSelectorMixin.java @@ -75,14 +75,14 @@ private boolean onAddEntityTask(final Set goals, final Object task, // Event is fired in bridge$fireConstructors return goals.add(new WrappedGoal(priority, base)); } - final GoalEvent.Add event = SpongeEventFactory.createGoalEventAdd(PhaseTracker.getCauseStackManager().getCurrentCause(), priority, priority, + final GoalEvent.Add event = SpongeEventFactory.createGoalEventAdd(PhaseTracker.getCauseStackManager().currentCause(), priority, priority, (Agent) this.owner, (GoalExecutor) this, (org.spongepowered.api.entity.ai.goal.Goal) base); SpongeCommon.postEvent(event); if (event.isCancelled()) { ((GoalBridge) base).bridge$setGoalExecutor(null); return false; } - return goals.add(new WrappedGoal(event.getPriority(), base)); + return goals.add(new WrappedGoal(event.priority(), base)); } @Override @@ -119,7 +119,7 @@ public void removeGoal(final Goal task) { this.availableGoals.removeIf(prioritizedGoal -> { if (prioritizedGoal.getGoal() == task) { if (ShouldFire.GOAL_EVENT_REMOVE && this.owner != null && !((EntityBridge) this.owner).bridge$isConstructing()) { - GoalEvent.Remove event = SpongeEventFactory.createGoalEventRemove(PhaseTracker.getCauseStackManager().getCurrentCause(), + GoalEvent.Remove event = SpongeEventFactory.createGoalEventRemove(PhaseTracker.getCauseStackManager().currentCause(), (Agent) this.owner, (GoalExecutor) this, (org.spongepowered.api.entity.ai.goal.Goal) task, prioritizedGoal.getPriority()); SpongeCommon.postEvent(event); if (event.isCancelled()) { diff --git a/src/mixins/java/org/spongepowered/common/mixin/core/world/entity/ai/goal/RunAroundLikeCrazyGoalMixin.java b/src/mixins/java/org/spongepowered/common/mixin/core/world/entity/ai/goal/RunAroundLikeCrazyGoalMixin.java index 986ae7bc9ee..aa990bbfced 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/core/world/entity/ai/goal/RunAroundLikeCrazyGoalMixin.java +++ b/src/mixins/java/org/spongepowered/common/mixin/core/world/entity/ai/goal/RunAroundLikeCrazyGoalMixin.java @@ -71,7 +71,7 @@ public void tick() { // Sponge start - Fire Tame Entity event try (CauseStackManager.StackFrame frame = PhaseTracker.getCauseStackManager().pushCauseFrame()) { frame.pushCause(entity); - if (SpongeCommon.postEvent(SpongeEventFactory.createTameEntityEvent(frame.getCurrentCause(), (HorseLike) this.horse))) { + if (SpongeCommon.postEvent(SpongeEventFactory.createTameEntityEvent(frame.currentCause(), (HorseLike) this.horse))) { return; } } diff --git a/src/mixins/java/org/spongepowered/common/mixin/core/world/entity/animal/AnimalMixin.java b/src/mixins/java/org/spongepowered/common/mixin/core/world/entity/animal/AnimalMixin.java index 0eecc468639..fab182ca821 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/core/world/entity/animal/AnimalMixin.java +++ b/src/mixins/java/org/spongepowered/common/mixin/core/world/entity/animal/AnimalMixin.java @@ -55,7 +55,7 @@ public abstract class AnimalMixin extends AgableMobMixin { frame.pushCause(this); frame.pushCause(partner); final org.spongepowered.api.event.entity.BreedingEvent.Breed event = - SpongeEventFactory.createBreedingEventBreed(PhaseTracker.getCauseStackManager().getCurrentCause(), (Ageable) offspring); + SpongeEventFactory.createBreedingEventBreed(PhaseTracker.getCauseStackManager().currentCause(), (Ageable) offspring); if (!(!SpongeCommon.postEvent(event) && level.addFreshEntity(offspring))) { ci.cancel(); diff --git a/src/mixins/java/org/spongepowered/common/mixin/core/world/entity/animal/OcelotMixin.java b/src/mixins/java/org/spongepowered/common/mixin/core/world/entity/animal/OcelotMixin.java index bcfbd7ae9bb..26bb5fae5e5 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/core/world/entity/animal/OcelotMixin.java +++ b/src/mixins/java/org/spongepowered/common/mixin/core/world/entity/animal/OcelotMixin.java @@ -49,7 +49,7 @@ public abstract class OcelotMixin extends AgableMobMixin { stack.setCount(stack.getCount() + 1); try (CauseStackManager.StackFrame frame = PhaseTracker.getCauseStackManager().pushCauseFrame()) { frame.pushCause(player); - if (!SpongeCommon.postEvent(SpongeEventFactory.createTameEntityEvent(frame.getCurrentCause(), (Ocelot) this))) { + if (!SpongeCommon.postEvent(SpongeEventFactory.createTameEntityEvent(frame.currentCause(), (Ocelot) this))) { stack.setCount(stack.getCount() - 1); return random; } diff --git a/src/mixins/java/org/spongepowered/common/mixin/core/world/entity/animal/ParrotMixin.java b/src/mixins/java/org/spongepowered/common/mixin/core/world/entity/animal/ParrotMixin.java index 4108b6b5878..d3e27971d1e 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/core/world/entity/animal/ParrotMixin.java +++ b/src/mixins/java/org/spongepowered/common/mixin/core/world/entity/animal/ParrotMixin.java @@ -51,7 +51,7 @@ public abstract class ParrotMixin extends AgableMobMixin { stack.setCount(stack.getCount() + 1); try (CauseStackManager.StackFrame frame = PhaseTracker.getCauseStackManager().pushCauseFrame()) { frame.pushCause(player); - if (!SpongeCommon.postEvent(SpongeEventFactory.createTameEntityEvent(frame.getCurrentCause(), (Parrot) this))) { + if (!SpongeCommon.postEvent(SpongeEventFactory.createTameEntityEvent(frame.currentCause(), (Parrot) this))) { stack.setCount(stack.getCount() - 1); return random; } diff --git a/src/mixins/java/org/spongepowered/common/mixin/core/world/entity/animal/WolfMixin.java b/src/mixins/java/org/spongepowered/common/mixin/core/world/entity/animal/WolfMixin.java index 24f518a8308..39d5dbb53c5 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/core/world/entity/animal/WolfMixin.java +++ b/src/mixins/java/org/spongepowered/common/mixin/core/world/entity/animal/WolfMixin.java @@ -68,7 +68,7 @@ public abstract class WolfMixin extends AgableMobMixin implements AggressiveEnti try { PhaseTracker.getCauseStackManager().pushCause(ItemStackUtil.fromNative(stack).createSnapshot()); PhaseTracker.getCauseStackManager().pushCause(player); - if (!SpongeCommon.postEvent(SpongeEventFactory.createTameEntityEvent(PhaseTracker.getCauseStackManager().getCurrentCause(), (Wolf) this))) { + if (!SpongeCommon.postEvent(SpongeEventFactory.createTameEntityEvent(PhaseTracker.getCauseStackManager().currentCause(), (Wolf) this))) { stack.grow(1); return random; } diff --git a/src/mixins/java/org/spongepowered/common/mixin/core/world/entity/animal/horse/LlamaMixin.java b/src/mixins/java/org/spongepowered/common/mixin/core/world/entity/animal/horse/LlamaMixin.java index 453da8de1e9..18fc19cc05f 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/core/world/entity/animal/horse/LlamaMixin.java +++ b/src/mixins/java/org/spongepowered/common/mixin/core/world/entity/animal/horse/LlamaMixin.java @@ -43,13 +43,13 @@ public abstract class LlamaMixin implements LlamaBridge { @Override public LlamaType bridge$getLlamaType() { - final MappedRegistry registry = (MappedRegistry) (Object) Sponge.getGame().registries().registry(RegistryTypes.LLAMA_TYPE); + final MappedRegistry registry = (MappedRegistry) (Object) Sponge.game().registries().registry(RegistryTypes.LLAMA_TYPE); return registry.byId(this.shadow$getVariant()); } @Override public void bridge$setLlamaType(final LlamaType type) { - final MappedRegistry registry = (MappedRegistry) (Object) Sponge.getGame().registries().registry(RegistryTypes.LLAMA_TYPE); + final MappedRegistry registry = (MappedRegistry) (Object) Sponge.game().registries().registry(RegistryTypes.LLAMA_TYPE); this.shadow$setVariant(registry.getId(type)); } } diff --git a/src/mixins/java/org/spongepowered/common/mixin/core/world/entity/decoration/ArmorStandMixin.java b/src/mixins/java/org/spongepowered/common/mixin/core/world/entity/decoration/ArmorStandMixin.java index 10abd26577d..1351d8082e2 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/core/world/entity/decoration/ArmorStandMixin.java +++ b/src/mixins/java/org/spongepowered/common/mixin/core/world/entity/decoration/ArmorStandMixin.java @@ -59,13 +59,13 @@ public abstract class ArmorStandMixin extends LivingEntityMixin { private void fireDestroyDamageEvent(final DamageSource source, final CallbackInfoReturnable cir) { try (final CauseStackManager.StackFrame frame = PhaseTracker.getCauseStackManager().pushCauseFrame()) { DamageEventHandler.generateCauseFor(source, frame); - final DamageEntityEvent event = SpongeEventFactory.createDamageEntityEvent(frame.getCurrentCause(), + final DamageEntityEvent event = SpongeEventFactory.createDamageEntityEvent(frame.currentCause(), (Entity) this, new ArrayList<>(), Math.max(1000, this.shadow$getHealth())); if (SpongeCommon.postEvent(event)) { cir.setReturnValue(false); } - if (event.getFinalDamage() < this.shadow$getHealth()) { - this.shadow$causeDamage(source, (float) event.getFinalDamage()); + if (event.finalDamage() < this.shadow$getHealth()) { + this.shadow$causeDamage(source, (float) event.finalDamage()); cir.setReturnValue(false); } } @@ -94,10 +94,10 @@ private void fireDamageEventOutOfWorld(final DamageSource source, final float am private void impl$fireDamageEventDamage(final ArmorStand self, final DamageSource source, final float amount) { try (final CauseStackManager.StackFrame frame = PhaseTracker.getCauseStackManager().pushCauseFrame()) { DamageEventHandler.generateCauseFor(source, frame); - final DamageEntityEvent event = SpongeEventFactory.createDamageEntityEvent(frame.getCurrentCause(), + final DamageEntityEvent event = SpongeEventFactory.createDamageEntityEvent(frame.currentCause(), (Entity) this, new ArrayList<>(), amount); if (!SpongeCommon.postEvent(event)) { - this.shadow$causeDamage(source, (float) event.getFinalDamage()); + this.shadow$causeDamage(source, (float) event.finalDamage()); } } } @@ -118,7 +118,7 @@ private void fireDamageEventFirstPunch(final DamageSource source, final float am // like damage in other respects, so fire an event. try (final CauseStackManager.StackFrame frame = PhaseTracker.getCauseStackManager().pushCauseFrame()) { DamageEventHandler.generateCauseFor(source, frame); - final DamageEntityEvent event = SpongeEventFactory.createDamageEntityEvent(frame.getCurrentCause(), + final DamageEntityEvent event = SpongeEventFactory.createDamageEntityEvent(frame.currentCause(), (Entity) this, new ArrayList<>(), 0); if (SpongeCommon.postEvent(event)) { cir.setReturnValue(false); diff --git a/src/mixins/java/org/spongepowered/common/mixin/core/world/entity/decoration/HangingEntityMixin.java b/src/mixins/java/org/spongepowered/common/mixin/core/world/entity/decoration/HangingEntityMixin.java index 5347ce8556f..f4668445294 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/core/world/entity/decoration/HangingEntityMixin.java +++ b/src/mixins/java/org/spongepowered/common/mixin/core/world/entity/decoration/HangingEntityMixin.java @@ -70,7 +70,7 @@ public abstract class HangingEntityMixin extends EntityMixin { final CallbackInfoReturnable cir) { try (final CauseStackManager.StackFrame frame = PhaseTracker.getCauseStackManager().pushCauseFrame()) { frame.pushCause(source); - final AttackEntityEvent event = SpongeEventFactory.createAttackEntityEvent(frame.getCurrentCause(), + final AttackEntityEvent event = SpongeEventFactory.createAttackEntityEvent(frame.currentCause(), (Entity) this, new ArrayList<>(), 0, amount); SpongeCommon.postEvent(event); if (event.isCancelled()) { diff --git a/src/mixins/java/org/spongepowered/common/mixin/core/world/entity/decoration/ItemFrameMixin.java b/src/mixins/java/org/spongepowered/common/mixin/core/world/entity/decoration/ItemFrameMixin.java index 13bfb2177e5..8e2179378f6 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/core/world/entity/decoration/ItemFrameMixin.java +++ b/src/mixins/java/org/spongepowered/common/mixin/core/world/entity/decoration/ItemFrameMixin.java @@ -55,7 +55,7 @@ private void onAttackEntityFrom(final DamageSource source, final float amount, final CallbackInfoReturnable cir) { try (final CauseStackManager.StackFrame frame = PhaseTracker.getCauseStackManager().pushCauseFrame()) { frame.pushCause(source); - final AttackEntityEvent event = SpongeEventFactory.createAttackEntityEvent(frame.getCurrentCause(), (ItemFrame) this, new ArrayList<>(), 0, amount); + final AttackEntityEvent event = SpongeEventFactory.createAttackEntityEvent(frame.currentCause(), (ItemFrame) this, new ArrayList<>(), 0, amount); SpongeCommon.postEvent(event); if (event.isCancelled()) { cir.setReturnValue(true); diff --git a/src/mixins/java/org/spongepowered/common/mixin/core/world/entity/item/ItemEntityMixin.java b/src/mixins/java/org/spongepowered/common/mixin/core/world/entity/item/ItemEntityMixin.java index a9fb1520a61..ff1323cf29b 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/core/world/entity/item/ItemEntityMixin.java +++ b/src/mixins/java/org/spongepowered/common/mixin/core/world/entity/item/ItemEntityMixin.java @@ -171,7 +171,7 @@ public abstract class ItemEntityMixin extends EntityMixin implements ItemEntityB } try (final CauseStackManager.StackFrame frame = PhaseTracker.getCauseStackManager().pushCauseFrame()) { frame.pushCause(this); - final ExpireEntityEvent event = SpongeEventFactory.createExpireEntityEvent(frame.getCurrentCause(), (Item) this); + final ExpireEntityEvent event = SpongeEventFactory.createExpireEntityEvent(frame.currentCause(), (Item) this); SpongeCommon.postEvent(event); } } diff --git a/src/mixins/java/org/spongepowered/common/mixin/core/world/entity/monster/EnderMan_EndermanLeaveBlockGoalMixin.java b/src/mixins/java/org/spongepowered/common/mixin/core/world/entity/monster/EnderMan_EndermanLeaveBlockGoalMixin.java index 7a11fc906bd..b591e1c47f4 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/core/world/entity/monster/EnderMan_EndermanLeaveBlockGoalMixin.java +++ b/src/mixins/java/org/spongepowered/common/mixin/core/world/entity/monster/EnderMan_EndermanLeaveBlockGoalMixin.java @@ -94,7 +94,7 @@ public abstract class EnderMan_EndermanLeaveBlockGoalMixin extends Goal { final ServerLocation location = ServerLocation.of((ServerWorld) blockReaderIn, blockPosIn.getX(), blockPosIn.getY(), blockPosIn.getZ()); final List list = new ArrayList<>(1); list.add(location); - final Cause cause = PhaseTracker.getCauseStackManager().getCurrentCause(); + final Cause cause = PhaseTracker.getCauseStackManager().currentCause(); final ChangeBlockEvent.Pre event = SpongeEventFactory.createChangeBlockEventPre(cause, list, ((ServerWorld) this.enderman.level)); return !SpongeCommon.postEvent(event); diff --git a/src/mixins/java/org/spongepowered/common/mixin/core/world/entity/player/PlayerMixin.java b/src/mixins/java/org/spongepowered/common/mixin/core/world/entity/player/PlayerMixin.java index 1a1ddfa1b74..a56069e79d2 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/core/world/entity/player/PlayerMixin.java +++ b/src/mixins/java/org/spongepowered/common/mixin/core/world/entity/player/PlayerMixin.java @@ -205,7 +205,7 @@ public abstract class PlayerMixin extends LivingEntityMixin implements PlayerBri csm.pushCause(this); final BlockPos bedLocation = this.shadow$getSleepingPos().get(); final BlockSnapshot snapshot = ((ServerWorld) this.level).createSnapshot(bedLocation.getX(), bedLocation.getY(), bedLocation.getZ()); - SpongeCommon.postEvent(SpongeEventFactory.createSleepingEventTick(csm.getCurrentCause(), snapshot, (Humanoid) this)); + SpongeCommon.postEvent(SpongeEventFactory.createSleepingEventTick(csm.currentCause(), snapshot, (Humanoid) this)); csm.popCause(); } return true; @@ -383,11 +383,11 @@ public void attack(final Entity targetEntity) { final List enchantmentModifierFunctions = DamageEventHandler.createAttackEnchantmentFunction(this.shadow$getMainHandItem(), creatureAttribute, attackStrength); // This is kept for the post-damage event handling final List enchantmentModifiers = enchantmentModifierFunctions.stream() - .map(ModifierFunction::getModifier) + .map(ModifierFunction::modifier) .collect(Collectors.toList()); enchantmentDamage = (float) enchantmentModifierFunctions.stream() - .map(ModifierFunction::getFunction) + .map(ModifierFunction::function) .mapToDouble(function -> function.applyAsDouble(originalBaseDamage)) .sum(); originalFunctions.addAll(enchantmentModifierFunctions); @@ -441,7 +441,7 @@ public void attack(final Entity targetEntity) { if (isMainthread) { PhaseTracker.getInstance().pushCause(damageSource); } - final Cause currentCause = isMainthread ? PhaseTracker.getInstance().getCurrentCause() : Cause.of(EventContext.empty(), damageSource); + final Cause currentCause = isMainthread ? PhaseTracker.getInstance().currentCause() : Cause.of(EventContext.empty(), damageSource); final AttackEntityEvent event = SpongeEventFactory.createAttackEntityEvent(currentCause, (org.spongepowered.api.entity.Entity) targetEntity, originalFunctions, knockbackModifier, originalBaseDamage); SpongeCommon.postEvent(event); @@ -452,14 +452,14 @@ public void attack(final Entity targetEntity) { return; } - damage = (float) event.getFinalOutputDamage(); + damage = (float) event.finalOutputDamage(); // Sponge End // Sponge Start - need final for later events final double attackDamage = damage; - knockbackModifier = (int) event.getKnockbackModifier(); + knockbackModifier = (int) event.knockbackModifier(); enchantmentDamage = (float) enchantmentModifiers.stream() - .mapToDouble(event::getOutputDamage) + .mapToDouble(event::outputDamage) .sum(); // Sponge End @@ -525,12 +525,12 @@ public void attack(final Entity targetEntity) { sweapingFunctions, 1, 1.0D); SpongeCommon.postEvent(sweepingAttackEvent); if (!sweepingAttackEvent.isCancelled()) { - livingEntity.knockback(sweepingAttackEvent.getKnockbackModifier() * 0.4F, + livingEntity.knockback(sweepingAttackEvent.knockbackModifier() * 0.4F, (double) Mth.sin(this.yRot * ((float)Math.PI / 180F)), (double) -Mth.cos(this.yRot * ((float)Math.PI / 180F))); livingEntity.hurt(DamageSource.playerAttack((net.minecraft.world.entity.player.Player) (Object) this), - (float) sweepingAttackEvent.getFinalOutputDamage()); + (float) sweepingAttackEvent.finalOutputDamage()); } } // Sponge End diff --git a/src/mixins/java/org/spongepowered/common/mixin/core/world/entity/projectile/FireworkRocketEntityMixin.java b/src/mixins/java/org/spongepowered/common/mixin/core/world/entity/projectile/FireworkRocketEntityMixin.java index 4fd847b7504..21a3fad5778 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/core/world/entity/projectile/FireworkRocketEntityMixin.java +++ b/src/mixins/java/org/spongepowered/common/mixin/core/world/entity/projectile/FireworkRocketEntityMixin.java @@ -108,7 +108,7 @@ public abstract class FireworkRocketEntityMixin extends EntityMixin implements F frame.addContext(EventContextKeys.PROJECTILE_SOURCE, this.impl$projectileSource); SpongeCommonEventFactory.detonateExplosive(this, Explosion.builder() .sourceExplosive(((FireworkRocket) this)) - .location(((FireworkRocket) this).getServerLocation()) + .location(((FireworkRocket) this).serverLocation()) .radius(this.impl$explosionRadius)) .ifPresent(explosion -> world.broadcastEntityEvent(self, state)); } diff --git a/src/mixins/java/org/spongepowered/common/mixin/core/world/entity/projectile/FishingHookMixin.java b/src/mixins/java/org/spongepowered/common/mixin/core/world/entity/projectile/FishingHookMixin.java index deb7d11cf66..c292dbbc0ae 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/core/world/entity/projectile/FishingHookMixin.java +++ b/src/mixins/java/org/spongepowered/common/mixin/core/world/entity/projectile/FishingHookMixin.java @@ -90,7 +90,7 @@ public abstract class FishingHookMixin extends EntityMixin { @Inject(method = "setHookedEntity", at = @At("HEAD"), cancellable = true) private void onSetHookedEntity(CallbackInfo ci) { if (SpongeCommon - .postEvent(SpongeEventFactory.createFishingEventHookEntity(PhaseTracker.getCauseStackManager().getCurrentCause(), (Entity) this.hookedIn, (FishingBobber) this))) { + .postEvent(SpongeEventFactory.createFishingEventHookEntity(PhaseTracker.getCauseStackManager().currentCause(), (Entity) this.hookedIn, (FishingBobber) this))) { this.hookedIn = null; ci.cancel(); } @@ -130,7 +130,7 @@ public int retrieve(ItemStack stack) { } PhaseTracker.getCauseStackManager().pushCause(playerEntity); - if (SpongeCommon.postEvent(SpongeEventFactory.createFishingEventStop(PhaseTracker.getCauseStackManager().getCurrentCause(), ((FishingBobber) this), transactions))) { + if (SpongeCommon.postEvent(SpongeEventFactory.createFishingEventStop(PhaseTracker.getCauseStackManager().currentCause(), ((FishingBobber) this), transactions))) { // Event is cancelled return 0; } @@ -153,7 +153,7 @@ public int retrieve(ItemStack stack) { if (!transaction.isValid()) { continue; } - ItemStack itemstack = (ItemStack) (Object) transaction.getFinal().createStack(); + ItemStack itemstack = (ItemStack) (Object) transaction.finalReplacement().createStack(); // Sponge end ItemEntity entityitem = new ItemEntity(this.level, this.shadow$getX(), this.shadow$getY(), this.shadow$getZ(), itemstack); diff --git a/src/mixins/java/org/spongepowered/common/mixin/core/world/entity/projectile/ThrownEnderpearlMixin.java b/src/mixins/java/org/spongepowered/common/mixin/core/world/entity/projectile/ThrownEnderpearlMixin.java index f8fee546495..1b8276c3c01 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/core/world/entity/projectile/ThrownEnderpearlMixin.java +++ b/src/mixins/java/org/spongepowered/common/mixin/core/world/entity/projectile/ThrownEnderpearlMixin.java @@ -34,17 +34,15 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.ModifyArg; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.spongepowered.asm.mixin.injection.callback.LocalCapture; import org.spongepowered.common.SpongeCommon; import org.spongepowered.common.event.ShouldFire; import org.spongepowered.common.event.tracking.PhaseTracker; -import org.spongepowered.common.util.Constants; import org.spongepowered.common.util.VecHelper; import org.spongepowered.common.world.portal.PlatformTeleporter; import org.spongepowered.math.vector.Vector3d; import javax.annotation.Nullable; -import net.minecraft.nbt.CompoundTag; + import net.minecraft.server.level.ServerLevel; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.projectile.ThrownEnderpearl; @@ -79,7 +77,7 @@ public abstract class ThrownEnderpearlMixin extends ThrowableProjectileMixin { frame.pushCause(this); frame.addContext(EventContextKeys.MOVEMENT_TYPE, MovementTypes.ENDER_PEARL); - final MoveEntityEvent event = SpongeEventFactory.createMoveEntityEvent(frame.getCurrentCause(), + final MoveEntityEvent event = SpongeEventFactory.createMoveEntityEvent(frame.currentCause(), (org.spongepowered.api.entity.Entity) entity, VecHelper.toVector3d(entity.position()), VecHelper.toVector3d(this.shadow$position()), VecHelper.toVector3d(this.shadow$position())); if (SpongeCommon.postEvent(event)) { @@ -89,7 +87,7 @@ public abstract class ThrownEnderpearlMixin extends ThrowableProjectileMixin { } // This seems odd but we move the pearl so that the pearl's logic will move the living entity later in the impact method - final Vector3d destinationPosition = event.getDestinationPosition(); + final Vector3d destinationPosition = event.destinationPosition(); this.shadow$setPos(destinationPosition.getX(), destinationPosition.getY(), destinationPosition.getZ()); } } diff --git a/src/mixins/java/org/spongepowered/common/mixin/core/world/entity/vehicle/AbstractMinecartMixin.java b/src/mixins/java/org/spongepowered/common/mixin/core/world/entity/vehicle/AbstractMinecartMixin.java index 6451ca256f9..a2455bb16a7 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/core/world/entity/vehicle/AbstractMinecartMixin.java +++ b/src/mixins/java/org/spongepowered/common/mixin/core/world/entity/vehicle/AbstractMinecartMixin.java @@ -118,7 +118,7 @@ protected double getMaxSpeed() { try (final CauseStackManager.StackFrame frame = PhaseTracker.getCauseStackManager().pushCauseFrame()) { frame.pushCause(this); frame.pushCause(source); - final AttackEntityEvent event = SpongeEventFactory.createAttackEntityEvent(frame.getCurrentCause(), (MinecartLike) this, new ArrayList<>(), 0, amount); + final AttackEntityEvent event = SpongeEventFactory.createAttackEntityEvent(frame.currentCause(), (MinecartLike) this, new ArrayList<>(), 0, amount); SpongeCommon.postEvent(event); if (event.isCancelled()) { cir.setReturnValue(true); diff --git a/src/mixins/java/org/spongepowered/common/mixin/core/world/entity/vehicle/MinecartTNTMixin.java b/src/mixins/java/org/spongepowered/common/mixin/core/world/entity/vehicle/MinecartTNTMixin.java index 6cda652c8c7..b23cfd4fd2d 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/core/world/entity/vehicle/MinecartTNTMixin.java +++ b/src/mixins/java/org/spongepowered/common/mixin/core/world/entity/vehicle/MinecartTNTMixin.java @@ -175,7 +175,7 @@ public abstract class MinecartTNTMixin extends AbstractMinecartMixin implements private void impl$postOnAttackEntityFrom(final DamageSource source, final float amount, final CallbackInfoReturnable cir) { try (final CauseStackManager.StackFrame frame = PhaseTracker.getCauseStackManager().pushCauseFrame()) { frame.pushCause(source); - final AttackEntityEvent event = SpongeEventFactory.createAttackEntityEvent(frame.getCurrentCause(), + final AttackEntityEvent event = SpongeEventFactory.createAttackEntityEvent(frame.currentCause(), (TNTMinecart) this, new ArrayList<>(), 0, amount); SpongeCommon.postEvent(event); if (event.isCancelled()) { diff --git a/src/mixins/java/org/spongepowered/common/mixin/core/world/item/EnderEyeItemMixin.java b/src/mixins/java/org/spongepowered/common/mixin/core/world/item/EnderEyeItemMixin.java index fe57b118047..91a715bb472 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/core/world/item/EnderEyeItemMixin.java +++ b/src/mixins/java/org/spongepowered/common/mixin/core/world/item/EnderEyeItemMixin.java @@ -93,7 +93,7 @@ public abstract class EnderEyeItemMixin extends ItemMixin { final CallbackInfoReturnable> cir, final ItemStack used, final HitResult rayTraceResult, @Nullable final BlockPos targetPos) { if (targetPos != null && !((WorldBridge) worldIn).bridge$isFake() && ShouldFire.CONSTRUCT_ENTITY_EVENT_PRE) { final ConstructEntityEvent.Pre event = - SpongeEventFactory.createConstructEntityEventPre(PhaseTracker.getCauseStackManager().getCurrentCause(), + SpongeEventFactory.createConstructEntityEventPre(PhaseTracker.getCauseStackManager().currentCause(), ServerLocation.of((ServerWorld) worldIn, playerIn.getX(), playerIn.getY() + (double) (playerIn.getDimensions(playerIn .getPose()).height / 2.0F), playerIn.getZ()), new Vector3d(0, 0, 0), EntityTypes.EYE_OF_ENDER.get()); if (SpongeCommon.postEvent(event)) { @@ -111,7 +111,7 @@ public abstract class EnderEyeItemMixin extends ItemMixin { final CallbackInfoReturnable> cir, final ItemStack used, @Nullable final BlockPos targetPos) { if (targetPos != null && !((WorldBridge) worldIn).bridge$isFake() && ShouldFire.CONSTRUCT_ENTITY_EVENT_PRE) { final ConstructEntityEvent.Pre event = - SpongeEventFactory.createConstructEntityEventPre(PhaseTracker.getCauseStackManager().getCurrentCause(), + SpongeEventFactory.createConstructEntityEventPre(PhaseTracker.getCauseStackManager().currentCause(), ServerLocation.of((ServerWorld) worldIn, playerIn.getX(), playerIn.getY() + (double) (playerIn.getDimensions(playerIn .getPose()).height / 2.0F), playerIn.getZ()), new Vector3d(0, 0, 0), EntityTypes.EYE_OF_ENDER.get()); if (SpongeCommon.postEvent(event)) { diff --git a/src/mixins/java/org/spongepowered/common/mixin/core/world/item/FireworkRocketItemMixin.java b/src/mixins/java/org/spongepowered/common/mixin/core/world/item/FireworkRocketItemMixin.java index 4b7eb17393b..d09c735b8ef 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/core/world/item/FireworkRocketItemMixin.java +++ b/src/mixins/java/org/spongepowered/common/mixin/core/world/item/FireworkRocketItemMixin.java @@ -132,7 +132,7 @@ public abstract class FireworkRocketItemMixin { frame.addContext(EventContextKeys.USED_ITEM, ItemStackUtil.snapshotOf(usedItem)); frame.addContext(EventContextKeys.PROJECTILE_SOURCE, (ProjectileSource) player); frame.pushCause(player); - final ConstructEntityEvent.Pre event = SpongeEventFactory.createConstructEntityEventPre(frame.getCurrentCause(), + final ConstructEntityEvent.Pre event = SpongeEventFactory.createConstructEntityEventPre(frame.currentCause(), ServerLocation.of((ServerWorld) world, player.getX(), player.getY(), player.getZ()), new Vector3d(0, 0, 0), EntityTypes.FIREWORK_ROCKET.get()); return SpongeCommon.postEvent(event); diff --git a/src/mixins/java/org/spongepowered/common/mixin/core/world/item/FishingRodItemMixin.java b/src/mixins/java/org/spongepowered/common/mixin/core/world/item/FishingRodItemMixin.java index f95491dce5e..bb60c790866 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/core/world/item/FishingRodItemMixin.java +++ b/src/mixins/java/org/spongepowered/common/mixin/core/world/item/FishingRodItemMixin.java @@ -72,7 +72,7 @@ private void onThrowEvent(Level world, Player player, InteractionHand hand, Call int j = EnchantmentHelper.getFishingLuckBonus(itemstack); FishingHook fishHook = new FishingHook(player, world, j, k); PhaseTracker.getCauseStackManager().pushCause(player); - if (SpongeCommon.postEvent(SpongeEventFactory.createFishingEventStart(PhaseTracker.getCauseStackManager().getCurrentCause(), (FishingBobber) fishHook))) { + if (SpongeCommon.postEvent(SpongeEventFactory.createFishingEventStart(PhaseTracker.getCauseStackManager().currentCause(), (FishingBobber) fishHook))) { fishHook.remove(); // Bye cir.setReturnValue(new InteractionResultHolder<>(InteractionResult.SUCCESS, player.getItemInHand(hand))); } else { diff --git a/src/mixins/java/org/spongepowered/common/mixin/core/world/item/ServerItemCooldownsMixin.java b/src/mixins/java/org/spongepowered/common/mixin/core/world/item/ServerItemCooldownsMixin.java index 9092b9579a3..08ae6098733 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/core/world/item/ServerItemCooldownsMixin.java +++ b/src/mixins/java/org/spongepowered/common/mixin/core/world/item/ServerItemCooldownsMixin.java @@ -26,7 +26,6 @@ import org.spongepowered.api.Sponge; import org.spongepowered.api.entity.living.player.CooldownTracker; -import org.spongepowered.api.entity.living.player.Player; import org.spongepowered.api.entity.living.player.server.ServerPlayer; import org.spongepowered.api.event.SpongeEventFactory; import org.spongepowered.api.event.entity.living.player.CooldownEvent; @@ -52,23 +51,23 @@ public abstract class ServerItemCooldownsMixin extends ItemCooldownsMixin { if (ticks == 0) { return 0; } - final OptionalInt beforeCooldown = ((CooldownTracker) this).getCooldown(type); - final CooldownEvent.Set event = SpongeEventFactory.createCooldownEventSet(PhaseTracker.getCauseStackManager().getCurrentCause(), + final OptionalInt beforeCooldown = ((CooldownTracker) this).cooldown(type); + final CooldownEvent.Set event = SpongeEventFactory.createCooldownEventSet(PhaseTracker.getCauseStackManager().currentCause(), ticks, ticks, type, (ServerPlayer) this.player, beforeCooldown); - if (Sponge.getEventManager().post(event)) { + if (Sponge.eventManager().post(event)) { this.onCooldownStarted((Item) type, beforeCooldown.orElse(0)); return -1; } else { - return event.getNewCooldown(); + return event.newCooldown(); } } @Override protected void impl$throwEndCooldownEvent(final ItemType type) { - final CooldownEvent.End event = SpongeEventFactory.createCooldownEventEnd(PhaseTracker.getCauseStackManager().getCurrentCause(), + final CooldownEvent.End event = SpongeEventFactory.createCooldownEventEnd(PhaseTracker.getCauseStackManager().currentCause(), type, (ServerPlayer) this.player); - Sponge.getEventManager().post(event); + Sponge.eventManager().post(event); } } diff --git a/src/mixins/java/org/spongepowered/common/mixin/core/world/level/ExplosionMixin.java b/src/mixins/java/org/spongepowered/common/mixin/core/world/level/ExplosionMixin.java index 8f66b91cbe4..b8e905ef614 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/core/world/level/ExplosionMixin.java +++ b/src/mixins/java/org/spongepowered/common/mixin/core/world/level/ExplosionMixin.java @@ -204,7 +204,7 @@ public void explode() { entities.add((org.spongepowered.api.entity.Entity) entity); } } - final Cause cause = PhaseTracker.getCauseStackManager().getCurrentCause(); + final Cause cause = PhaseTracker.getCauseStackManager().currentCause(); final ExplosionEvent.Detonate detonate = SpongeEventFactory.createExplosionEventDetonate(cause, blockPositions, entities, (Explosion) this, (org.spongepowered.api.world.server.ServerWorld) this.level); SpongeCommon.postEvent(detonate); @@ -214,14 +214,14 @@ public void explode() { return; } if (this.impl$shouldBreakBlocks) { - for (final ServerLocation worldLocation : detonate.getAffectedLocations()) { + for (final ServerLocation worldLocation : detonate.affectedLocations()) { this.toBlow.add(VecHelper.toBlockPos(worldLocation)); } } // Clear the list of entities so they can be pulled from the event. list.clear(); if (this.impl$shouldDamageEntities) { - for (final org.spongepowered.api.entity.Entity entity : detonate.getEntities()) { + for (final org.spongepowered.api.entity.Entity entity : detonate.entities()) { try { list.add((Entity) entity); } catch (final Exception e) { diff --git a/src/mixins/java/org/spongepowered/common/mixin/core/world/level/block/CommandBlockMixin.java b/src/mixins/java/org/spongepowered/common/mixin/core/world/level/block/CommandBlockMixin.java index 70757d0438a..0c1038ca986 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/core/world/level/block/CommandBlockMixin.java +++ b/src/mixins/java/org/spongepowered/common/mixin/core/world/level/block/CommandBlockMixin.java @@ -50,7 +50,7 @@ public abstract class CommandBlockMixin { // However, when a plugin provides a permission service, we have to force the op level to 0 on the client, since // the server can't tell the client to open it. // If the server-side permission check fails, we need to forcibly close it, since it will already have opened on the client. - if (!world.isClientSide() && !(Sponge.getServer().getServiceProvider().permissionService() instanceof SpongePermissionService)) { + if (!world.isClientSide() && !(Sponge.server().serviceProvider().permissionService() instanceof SpongePermissionService)) { // CommandBlock GUI opens solely on the client, we need to force it close on cancellation ((ServerPlayer) player).connection.send(new ClientboundContainerClosePacket(0)); } diff --git a/src/mixins/java/org/spongepowered/common/mixin/core/world/level/block/FallingBlockMixin.java b/src/mixins/java/org/spongepowered/common/mixin/core/world/level/block/FallingBlockMixin.java index 6bc6c18da3a..28e7f819668 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/core/world/level/block/FallingBlockMixin.java +++ b/src/mixins/java/org/spongepowered/common/mixin/core/world/level/block/FallingBlockMixin.java @@ -72,7 +72,7 @@ public abstract class FallingBlockMixin { try (final CauseStackManager.StackFrame frame = PhaseTracker.getCauseStackManager().pushCauseFrame()) { frame.pushCause(snapshot); frame.addContext(EventContextKeys.SPAWN_TYPE, SpawnTypes.FALLING_BLOCK); - final ConstructEntityEvent.Pre event = SpongeEventFactory.createConstructEntityEventPre(frame.getCurrentCause(), + final ConstructEntityEvent.Pre event = SpongeEventFactory.createConstructEntityEventPre(frame.currentCause(), ServerLocation.of( (org.spongepowered.api.world.server.ServerWorld) world, pos.getX() + 0.5D, pos.getY(), pos.getZ() + 0.5D), new Vector3d(0, 0, 0), diff --git a/src/mixins/java/org/spongepowered/common/mixin/core/world/level/block/NoteBlockMixin.java b/src/mixins/java/org/spongepowered/common/mixin/core/world/level/block/NoteBlockMixin.java index 9ea416959d0..5f418921737 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/core/world/level/block/NoteBlockMixin.java +++ b/src/mixins/java/org/spongepowered/common/mixin/core/world/level/block/NoteBlockMixin.java @@ -65,7 +65,7 @@ public abstract class NoteBlockMixin extends BlockMixin { } //InstrumentProperty doesn't return what we wan't for the noteblock directly, so we have to check the block under it. - InstrumentType instrumentType = ((ServerWorld) worldIn).getBlock(pos.getX(), pos.getY() - 1, pos.getZ()).get(Keys.REPRESENTED_INSTRUMENT).orElse(null); + InstrumentType instrumentType = ((ServerWorld) worldIn).block(pos.getX(), pos.getY() - 1, pos.getZ()).get(Keys.REPRESENTED_INSTRUMENT).orElse(null); if (instrumentType == null) { return; } @@ -73,9 +73,9 @@ public abstract class NoteBlockMixin extends BlockMixin { float pitch = (float) Math.pow(2.0D, (double) (param - 12) / 12.0D); final MappedRegistry registry = - (MappedRegistry) (Object) Sponge.getGame().registries().registry(RegistryTypes.NOTE_PITCH); + (MappedRegistry) (Object) Sponge.game().registries().registry(RegistryTypes.NOTE_PITCH); final PlaySoundEvent.NoteBlock event = SpongeCommonEventFactory.callPlaySoundNoteBlockEvent( - PhaseTracker.getCauseStackManager().getCurrentCause(), (ServerWorld) worldIn, pos, + PhaseTracker.getCauseStackManager().currentCause(), (ServerWorld) worldIn, pos, NoteBlockInstrument.byState(state).getSoundEvent(), instrumentType, registry.byId(param), pitch); if (event.isCancelled()) { callbackInfo.setReturnValue(true); diff --git a/src/mixins/java/org/spongepowered/common/mixin/core/world/level/block/entity/AbstractFurnaceBlockEntityMixin.java b/src/mixins/java/org/spongepowered/common/mixin/core/world/level/block/entity/AbstractFurnaceBlockEntityMixin.java index 40c16d56417..f931b583089 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/core/world/level/block/entity/AbstractFurnaceBlockEntityMixin.java +++ b/src/mixins/java/org/spongepowered/common/mixin/core/world/level/block/entity/AbstractFurnaceBlockEntityMixin.java @@ -70,7 +70,7 @@ public abstract class AbstractFurnaceBlockEntityMixin extends BaseContainerBlock // Shrink Fuel @Redirect(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/item/ItemStack;shrink(I)V")) private void impl$throwFuelEventIfOrShrink(final ItemStack itemStack, final int quantity) { - final Cause cause = PhaseTracker.getCauseStackManager().getCurrentCause(); + final Cause cause = PhaseTracker.getCauseStackManager().currentCause(); final ItemStackSnapshot fuel = ItemStackUtil.snapshotOf(itemStack); final ItemStackSnapshot shrinkedFuel = ItemStackUtil.snapshotOf(ItemStackUtil.cloneDefensive(itemStack, itemStack.getCount() - 1)); @@ -89,8 +89,8 @@ public abstract class AbstractFurnaceBlockEntityMixin extends BaseContainerBlock return; } - if (transaction.getCustom().isPresent()) { - this.items.set(1, ItemStackUtil.fromSnapshotToNative(transaction.getFinal())); + if (transaction.custom().isPresent()) { + this.items.set(1, ItemStackUtil.fromSnapshotToNative(transaction.finalReplacement())); } else { // vanilla itemStack.shrink(quantity); } @@ -110,7 +110,7 @@ public abstract class AbstractFurnaceBlockEntityMixin extends BaseContainerBlock final ItemStackSnapshot fuel = ItemStackUtil.snapshotOf(this.items.get(1)); - final Cause cause = PhaseTracker.getCauseStackManager().getCurrentCause(); + final Cause cause = PhaseTracker.getCauseStackManager().currentCause(); if (this.cookingProgress == 0) { // Start final CookingEvent.Start event = SpongeEventFactory.createCookingEventStart(cause, (FurnaceBlockEntity) this, Optional.of(fuel), Optional.of((CookingRecipe) recipe), Collections.emptyList()); @@ -130,7 +130,7 @@ public abstract class AbstractFurnaceBlockEntityMixin extends BaseContainerBlock private int impl$resetCookTimeIfCancelled(final int newCookTime, final int zero, final int totalCookTime) { final int clampedCookTime = Mth.clamp(newCookTime, zero, totalCookTime); final ItemStackSnapshot fuel = ItemStackUtil.snapshotOf(this.items.get(1)); - final Cause cause = PhaseTracker.getCauseStackManager().getCurrentCause(); + final Cause cause = PhaseTracker.getCauseStackManager().currentCause(); final AbstractCookingRecipe recipe = this.impl$getCurrentRecipe(); final CookingEvent.Tick event = SpongeEventFactory.createCookingEventTick(cause, (FurnaceBlockEntity) this, Optional.of(fuel), Optional.of((CookingRecipe) recipe), Collections.emptyList()); @@ -180,7 +180,7 @@ public abstract class AbstractFurnaceBlockEntityMixin extends BaseContainerBlock private void impl$callInteruptSmeltEvent() { if (this.cookingProgress > 0) { final ItemStackSnapshot fuel = ItemStackUtil.snapshotOf(this.items.get(1)); - final Cause cause = PhaseTracker.getCauseStackManager().getCurrentCause(); + final Cause cause = PhaseTracker.getCauseStackManager().currentCause(); final AbstractCookingRecipe recipe = this.impl$getCurrentRecipe(); final CookingEvent.Interrupt event = SpongeEventFactory.createCookingEventInterrupt(cause, (FurnaceBlockEntity) this, Optional.of(fuel), Optional.ofNullable((CookingRecipe) recipe)); @@ -195,7 +195,7 @@ public abstract class AbstractFurnaceBlockEntityMixin extends BaseContainerBlock at = @At(value = "INVOKE", target = "Lnet/minecraft/world/item/ItemStack;shrink(I)V")) private void impl$afterSmeltItem(final Recipe recipe, final CallbackInfo ci) { final ItemStackSnapshot fuel = ItemStackUtil.snapshotOf(this.items.get(1)); - final Cause cause = PhaseTracker.getCauseStackManager().getCurrentCause(); + final Cause cause = PhaseTracker.getCauseStackManager().currentCause(); final ItemStackSnapshot snapshot = ItemStackUtil.snapshotOf(recipe.getResultItem()); final CookingEvent.Finish event = SpongeEventFactory.createCookingEventFinish(cause, (FurnaceBlockEntity) this, Collections.singletonList(snapshot), Optional.of(fuel), Optional.ofNullable((CookingRecipe) recipe)); diff --git a/src/mixins/java/org/spongepowered/common/mixin/core/world/level/block/entity/BlockEntityMixin.java b/src/mixins/java/org/spongepowered/common/mixin/core/world/level/block/entity/BlockEntityMixin.java index e322fda67f9..5839e52aa7f 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/core/world/level/block/entity/BlockEntityMixin.java +++ b/src/mixins/java/org/spongepowered/common/mixin/core/world/level/block/entity/BlockEntityMixin.java @@ -126,7 +126,7 @@ protected MoreObjects.ToStringHelper getPrettyPrinterStringHelper() { return MoreObjects.toStringHelper(this) .add("type", key) - .add("world", ((ServerWorld) this.level).getKey()) + .add("world", ((ServerWorld) this.level).key()) .add("pos", this.worldPosition); } diff --git a/src/mixins/java/org/spongepowered/common/mixin/core/world/level/block/entity/CampfireBlockEntityMixin.java b/src/mixins/java/org/spongepowered/common/mixin/core/world/level/block/entity/CampfireBlockEntityMixin.java index 856b354e535..5c682ebf8de 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/core/world/level/block/entity/CampfireBlockEntityMixin.java +++ b/src/mixins/java/org/spongepowered/common/mixin/core/world/level/block/entity/CampfireBlockEntityMixin.java @@ -69,7 +69,7 @@ public abstract class CampfireBlockEntityMixin implements CampfireBlockEntityBri private void impl$canCook(final CallbackInfo ci, final int i, final ItemStack itemStack) { final boolean isEmpty = itemStack.isEmpty(); if (!isEmpty) { - final Cause cause = PhaseTracker.getCauseStackManager().getCurrentCause(); + final Cause cause = PhaseTracker.getCauseStackManager().currentCause(); final ItemStackSnapshot stack = ItemStackUtil.snapshotOf(this.items.get(i)); final CookingEvent.Tick event = SpongeEventFactory.createCookingEventTick(cause, (Campfire) this, Optional.empty(), Optional.ofNullable((CookingRecipe) impl$cookingRecipe[i]), Collections.singletonList(new Transaction<>(stack, stack))); @@ -91,7 +91,7 @@ public abstract class CampfireBlockEntityMixin implements CampfireBlockEntityBri @Surrogate private void impl$assembleCampfireResult(final CallbackInfo ci, final int i, final ItemStack itemStack, final Container iInventory, final ItemStack itemStack1, final BlockPos blockPos) { - final Cause cause = PhaseTracker.getCauseStackManager().getCurrentCause(); + final Cause cause = PhaseTracker.getCauseStackManager().currentCause(); final ItemStackSnapshot snapshot = ItemStackUtil.snapshotOf(itemStack1); final CookingEvent.Finish event = SpongeEventFactory.createCookingEventFinish(cause, (Campfire) this, Collections.singletonList(snapshot), Optional.empty(), Optional.ofNullable((CookingRecipe) this.impl$cookingRecipe[i])); diff --git a/src/mixins/java/org/spongepowered/common/mixin/core/world/level/block/entity/SkullBlockEntityMixin.java b/src/mixins/java/org/spongepowered/common/mixin/core/world/level/block/entity/SkullBlockEntityMixin.java index b2e704f2db0..3db1387aab3 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/core/world/level/block/entity/SkullBlockEntityMixin.java +++ b/src/mixins/java/org/spongepowered/common/mixin/core/world/level/block/entity/SkullBlockEntityMixin.java @@ -81,12 +81,12 @@ private GameProfile onUpdateProfile(final GameProfile input) { if (input.isComplete() && input.getProperties().containsKey("textures")) { return input; } - final GameProfileManager manager = Sponge.getServer().getGameProfileManager(); + final GameProfileManager manager = Sponge.server().gameProfileManager(); CompletableFuture future = null; if (input.getId() != null) { - future = manager.getProfile(input.getId()); + future = manager.profile(input.getId()); } else if (!StringUtil.isNullOrEmpty(input.getName())) { - future = manager.getProfile(input.getName()); + future = manager.profile(input.getName()); } if (future == null) { return input; diff --git a/src/mixins/java/org/spongepowered/common/mixin/core/world/level/block/entity/TheEndGatewayBlockEntityMixin.java b/src/mixins/java/org/spongepowered/common/mixin/core/world/level/block/entity/TheEndGatewayBlockEntityMixin.java index 445c920b2b0..6146c1109c3 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/core/world/level/block/entity/TheEndGatewayBlockEntityMixin.java +++ b/src/mixins/java/org/spongepowered/common/mixin/core/world/level/block/entity/TheEndGatewayBlockEntityMixin.java @@ -43,7 +43,7 @@ public abstract class TheEndGatewayBlockEntityMixin extends TheEndPortalBlockEnt try (final CauseStackManager.StackFrame frame = PhaseTracker.getCauseStackManager().pushCauseFrame()) { // We'll already have the entity in the cause if they are a player and threw their pearl into it. We do not // want to re-arrange the cause - if (!frame.getCurrentCause().containsType(entity.getClass())) { + if (!frame.currentCause().containsType(entity.getClass())) { frame.pushCause(entity); } frame.pushCause(this); diff --git a/src/mixins/java/org/spongepowered/common/mixin/core/world/level/dimension/LevelStemMixin.java b/src/mixins/java/org/spongepowered/common/mixin/core/world/level/dimension/LevelStemMixin.java index 932f1ff91b2..5eac44e2614 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/core/world/level/dimension/LevelStemMixin.java +++ b/src/mixins/java/org/spongepowered/common/mixin/core/world/level/dimension/LevelStemMixin.java @@ -153,7 +153,7 @@ public abstract class LevelStemMixin implements LevelStemBridge, ResourceKeyBrid @Override public void bridge$populateFromTemplate(final SpongeWorldTemplate s) { - this.impl$key = s.getKey(); + this.impl$key = s.key(); this.impl$gameMode = s.gameMode == null ? null : (ResourceLocation) (Object) s.gameMode.location(); this.impl$difficulty = s.difficulty == null ? null : (ResourceLocation) (Object) s.difficulty.location(); this.impl$serializationBehavior = s.serializationBehavior; diff --git a/src/mixins/java/org/spongepowered/common/mixin/core/world/level/storage/PlayerDataStorageMixin.java b/src/mixins/java/org/spongepowered/common/mixin/core/world/level/storage/PlayerDataStorageMixin.java index d2ece1b3537..12e34e55e5c 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/core/world/level/storage/PlayerDataStorageMixin.java +++ b/src/mixins/java/org/spongepowered/common/mixin/core/world/level/storage/PlayerDataStorageMixin.java @@ -70,7 +70,7 @@ public abstract class PlayerDataStorageMixin { target = "Lnet/minecraft/nbt/NbtIo;writeCompressed(Lnet/minecraft/nbt/CompoundTag;Ljava/io/File;)V", shift = At.Shift.AFTER)) private void impl$saveSpongePlayerData(final Player player, final CallbackInfo callbackInfo) { - ((SpongeServer) Sponge.getServer()).getPlayerDataManager().saveSpongePlayerData(player.getUUID()); + ((SpongeServer) Sponge.server()).getPlayerDataManager().saveSpongePlayerData(player.getUUID()); } @Inject( diff --git a/src/mixins/java/org/spongepowered/common/mixin/core/world/level/storage/PrimaryLevelDataMixin.java b/src/mixins/java/org/spongepowered/common/mixin/core/world/level/storage/PrimaryLevelDataMixin.java index d215ff62234..c8ec9422129 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/core/world/level/storage/PrimaryLevelDataMixin.java +++ b/src/mixins/java/org/spongepowered/common/mixin/core/world/level/storage/PrimaryLevelDataMixin.java @@ -317,7 +317,7 @@ public ServerLevelData overworldData() { dimensionGeneratorSettings = ((WorldGenSettingsBridge) input).bridge$copy(); final MappedRegistry registry = new MappedRegistry<>(Registry.LEVEL_STEM_REGISTRY, Lifecycle.stable()); ((org.spongepowered.api.registry.Registry) (Object) dimensionGeneratorSettings.dimensions()).streamEntries().forEach(entry -> { - if (Constants.MINECRAFT.equals(entry.key().getNamespace())) { + if (Constants.MINECRAFT.equals(entry.key().namespace())) { ((org.spongepowered.api.registry.Registry) (Object) registry).register(entry.key(), entry.value()); } }); diff --git a/src/mixins/java/org/spongepowered/common/mixin/core/world/scores/PlayerTeamMixin.java b/src/mixins/java/org/spongepowered/common/mixin/core/world/scores/PlayerTeamMixin.java index 694aff183d3..2de3e9d8c1a 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/core/world/scores/PlayerTeamMixin.java +++ b/src/mixins/java/org/spongepowered/common/mixin/core/world/scores/PlayerTeamMixin.java @@ -194,7 +194,7 @@ public abstract class PlayerTeamMixin implements PlayerTeamBridge { @Override public Audience bridge$getTeamChannel(final ServerPlayer player) { return Audience.audience(this.getPlayers().stream() - .map(name -> Sponge.getGame().getServer().getPlayer(name)) + .map(name -> Sponge.game().server().player(name)) .filter(Optional::isPresent) .map(Optional::get) .filter(member -> member != player) @@ -203,7 +203,7 @@ public abstract class PlayerTeamMixin implements PlayerTeamBridge { @Override public Audience bridge$getNonTeamChannel() { - return Audience.audience(Sponge.getGame().getServer().getOnlinePlayers().stream() + return Audience.audience(Sponge.game().server().onlinePlayers().stream() .filter(player -> ((ServerPlayer) player).getTeam() != (Object) this) .collect(Collectors.toSet())); } diff --git a/src/mixins/java/org/spongepowered/common/mixin/entitycollision/entity/EntityMixin_EntityCollision.java b/src/mixins/java/org/spongepowered/common/mixin/entitycollision/entity/EntityMixin_EntityCollision.java index 49311f14a3e..2d9883a3b00 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/entitycollision/entity/EntityMixin_EntityCollision.java +++ b/src/mixins/java/org/spongepowered/common/mixin/entitycollision/entity/EntityMixin_EntityCollision.java @@ -62,10 +62,10 @@ public abstract class EntityMixin_EntityCollision implements CollisionCapability final ItemStack itemstack = item.getItem(); if (!itemstack.isEmpty()) { this.entityCollision$key = - Sponge.getGame().registries().registry(RegistryTypes.ITEM_TYPE).valueKey(((org.spongepowered.api.item.inventory.ItemStack) (Object) itemstack).getType()); + Sponge.game().registries().registry(RegistryTypes.ITEM_TYPE).valueKey(((org.spongepowered.api.item.inventory.ItemStack) (Object) itemstack).type()); } } else { - this.entityCollision$key = Sponge.getGame().registries().registry(RegistryTypes.ENTITY_TYPE).valueKey(((Entity) this).getType()); + this.entityCollision$key = Sponge.game().registries().registry(RegistryTypes.ENTITY_TYPE).valueKey(((Entity) this).type()); } if (!this.shadow$getCommandSenderWorld().isClientSide()) { this.collision$initializeCollisionState(this.shadow$getCommandSenderWorld()); @@ -93,12 +93,12 @@ public abstract class EntityMixin_EntityCollision implements CollisionCapability final InheritableConfigHandle worldConfigAdapter = ((PrimaryLevelDataBridge) world.getLevelData()).bridge$configAdapter(); final ConfigHandle globalConfigAdapter = SpongeConfigs.getCommon(); final EntityCollisionCategory.ModSubCategory worldCollMod = - worldConfigAdapter.getOrCreateValue(s -> s.entityCollision.mods.get(this.entityCollision$key.getNamespace()), + worldConfigAdapter.getOrCreateValue(s -> s.entityCollision.mods.get(this.entityCollision$key.namespace()), c -> { // TODO: save after populating? - final EntityCollisionCategory.ModSubCategory globalCollision = new EntityCollisionCategory.ModSubCategory(this.entityCollision$key.getNamespace()); - c.entityCollision.mods.put(this.entityCollision$key.getNamespace(), globalCollision); - globalCollision.entities.put(this.entityCollision$key.getNamespace(), this.collision$getMaxCollisions()); + final EntityCollisionCategory.ModSubCategory globalCollision = new EntityCollisionCategory.ModSubCategory(this.entityCollision$key.namespace()); + c.entityCollision.mods.put(this.entityCollision$key.namespace(), globalCollision); + globalCollision.entities.put(this.entityCollision$key.namespace(), this.collision$getMaxCollisions()); }, worldConfigAdapter.get().entityCollision.autoPopulate); final EntityCollisionCategory worldCollCat = worldConfigAdapter.get().entityCollision; @@ -119,11 +119,11 @@ public abstract class EntityMixin_EntityCollision implements CollisionCapability Integer entityMaxCollision = null; if ((net.minecraft.world.entity.Entity) (Object) this instanceof ItemEntity) { // check if all items are overridden - entityMaxCollision = worldCollMod.entities.get(this.entityCollision$key.getValue()); + entityMaxCollision = worldCollMod.entities.get(this.entityCollision$key.value()); } if (entityMaxCollision == null) { - entityMaxCollision = worldCollMod.entities.get(this.entityCollision$key.getValue()); + entityMaxCollision = worldCollMod.entities.get(this.entityCollision$key.value()); } // entity overrides diff --git a/src/mixins/java/org/spongepowered/common/mixin/entitycollision/world/level/block/BlockMixin_EntityCollision.java b/src/mixins/java/org/spongepowered/common/mixin/entitycollision/world/level/block/BlockMixin_EntityCollision.java index 95a72c9ed94..23acb8326fc 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/entitycollision/world/level/block/BlockMixin_EntityCollision.java +++ b/src/mixins/java/org/spongepowered/common/mixin/entitycollision/world/level/block/BlockMixin_EntityCollision.java @@ -47,7 +47,7 @@ public abstract class BlockMixin_EntityCollision implements CollisionCapabilityB @Override public ResourceKey collision$getKey() { - return Sponge.getGame().registries().registry(RegistryTypes.BLOCK_TYPE).valueKey((BlockType) this); + return Sponge.game().registries().registry(RegistryTypes.BLOCK_TYPE).valueKey((BlockType) this); } @Override @@ -79,9 +79,9 @@ public abstract class BlockMixin_EntityCollision implements CollisionCapabilityB this.collision$setMaxCollisions(worldCollCat.maxEntitiesWithinAABB); boolean requiresSave = false; - Sponge.getGame().registries().registry(RegistryTypes.BLOCK_TYPE).valueKey((BlockType) this); + Sponge.game().registries().registry(RegistryTypes.BLOCK_TYPE).valueKey((BlockType) this); - String[] ids = Sponge.getGame().registries().registry(RegistryTypes.BLOCK_TYPE).valueKey((BlockType) this).toString().split(":"); + String[] ids = Sponge.game().registries().registry(RegistryTypes.BLOCK_TYPE).valueKey((BlockType) this).toString().split(":"); String modId = ids[0]; String name = ids[1]; diff --git a/src/mixins/java/org/spongepowered/common/mixin/entitycollision/world/level/chunk/LevelChunkMixin_EntityCollision.java b/src/mixins/java/org/spongepowered/common/mixin/entitycollision/world/level/chunk/LevelChunkMixin_EntityCollision.java index 4dab365455b..f92d627d4ad 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/entitycollision/world/level/chunk/LevelChunkMixin_EntityCollision.java +++ b/src/mixins/java/org/spongepowered/common/mixin/entitycollision/world/level/chunk/LevelChunkMixin_EntityCollision.java @@ -108,7 +108,7 @@ public abstract class LevelChunkMixin_EntityCollision { if (source instanceof LocatableBlock) { final LocatableBlock locatable = (LocatableBlock) source; - final BlockType blockType = locatable.getLocation().getBlock().getType(); + final BlockType blockType = locatable.location().block().type(); collisionBridge = (CollisionCapabilityBridge) blockType; } else if (source instanceof CollisionCapabilityBridge) { collisionBridge = (CollisionCapabilityBridge) source; diff --git a/src/mixins/java/org/spongepowered/common/mixin/inventory/api/TraitMixin_ArmorEquipable_Inventory_API.java b/src/mixins/java/org/spongepowered/common/mixin/inventory/api/TraitMixin_ArmorEquipable_Inventory_API.java index d0317473e5f..73ccf854932 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/inventory/api/TraitMixin_ArmorEquipable_Inventory_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/inventory/api/TraitMixin_ArmorEquipable_Inventory_API.java @@ -67,7 +67,7 @@ public boolean canEquip(final EquipmentType type, @Nullable final ItemStack equi } @Override - public Optional getEquipped(final EquipmentType type) { + public Optional equipped(final EquipmentType type) { final InventoryAdapter inv = ((InventoryBridge) this).bridge$getAdapter(); final EquipmentInventoryLens lens = this.impl$equipmentInventory(inv); return Optional.of(ItemStackUtil.fromNative(lens.getStack(inv.inventoryAdapter$getFabric(), ((EquipmentSlot) (Object) type).getIndex()))); @@ -81,7 +81,7 @@ public boolean equip(final EquipmentType type, @Nullable final ItemStack equipme } @Override - public ItemStack getItemInHand(HandType handType) { + public ItemStack itemInHand(HandType handType) { Preconditions.checkNotNull(handType); final net.minecraft.world.item.ItemStack nmsItem = ((LivingEntity) (Object)this).getItemInHand((InteractionHand) (Object) handType); return ItemStackUtil.fromNative(nmsItem); @@ -94,8 +94,8 @@ public void setItemInHand(HandType handType, @Nullable ItemStack itemInHand) { } @Override - public ItemStack getHead() { - return this.getEquipped(EquipmentTypes.HEAD).get(); + public ItemStack head() { + return this.equipped(EquipmentTypes.HEAD).get(); } @Override @@ -104,8 +104,8 @@ public void setHead(ItemStack head) { } @Override - public ItemStack getChest() { - return this.getEquipped(EquipmentTypes.CHEST).get(); + public ItemStack chest() { + return this.equipped(EquipmentTypes.CHEST).get(); } @Override @@ -114,8 +114,8 @@ public void setChest(ItemStack chest) { } @Override - public ItemStack getLegs() { - return this.getEquipped(EquipmentTypes.LEGS).get(); + public ItemStack legs() { + return this.equipped(EquipmentTypes.LEGS).get(); } @Override @@ -124,8 +124,8 @@ public void setLegs(ItemStack legs) { } @Override - public ItemStack getFeet() { - return this.getEquipped(EquipmentTypes.FEET).get(); + public ItemStack feet() { + return this.equipped(EquipmentTypes.FEET).get(); } @Override diff --git a/src/mixins/java/org/spongepowered/common/mixin/inventory/api/TraitMixin_Carried_Inventory_API.java b/src/mixins/java/org/spongepowered/common/mixin/inventory/api/TraitMixin_Carried_Inventory_API.java index 107f687b670..28c2cd10683 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/inventory/api/TraitMixin_Carried_Inventory_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/inventory/api/TraitMixin_Carried_Inventory_API.java @@ -45,7 +45,7 @@ public abstract class TraitMixin_Carried_Inventory_API implements CarriedInventory { @Override - public Optional getCarrier() { + public Optional carrier() { if (this instanceof CarriedBridge) { return ((CarriedBridge) this).bridge$getCarrier(); } diff --git a/src/mixins/java/org/spongepowered/common/mixin/inventory/api/TraitMixin_Equipable_Inventory_API.java b/src/mixins/java/org/spongepowered/common/mixin/inventory/api/TraitMixin_Equipable_Inventory_API.java index 9fcbe8b4744..3572b68f556 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/inventory/api/TraitMixin_Equipable_Inventory_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/inventory/api/TraitMixin_Equipable_Inventory_API.java @@ -39,7 +39,7 @@ public abstract class TraitMixin_Equipable_Inventory_API implements Equipable { private EquipmentInventory impl$equipmentInventory = null; @Override - public EquipmentInventory getEquipment() { + public EquipmentInventory equipment() { if (this.impl$equipmentInventory == null) { final InventoryAdapter inv = ((InventoryBridge) this).bridge$getAdapter(); final EquipmentInventoryLens lens = (EquipmentInventoryLens) inv.inventoryAdapter$getRootLens(); diff --git a/src/mixins/java/org/spongepowered/common/mixin/inventory/api/TraitMixin_Viewable_Inventory_API.java b/src/mixins/java/org/spongepowered/common/mixin/inventory/api/TraitMixin_Viewable_Inventory_API.java index 069f1a92fff..df6e3844341 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/inventory/api/TraitMixin_Viewable_Inventory_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/inventory/api/TraitMixin_Viewable_Inventory_API.java @@ -61,7 +61,7 @@ public abstract class TraitMixin_Viewable_Inventory_API implements ViewableInventory { @Override - public Set getViewers() { + public Set viewers() { if (this instanceof ViewableInventoryBridge) { return ((ViewableInventoryBridge) this).viewableBridge$getViewers(); } diff --git a/src/mixins/java/org/spongepowered/common/mixin/inventory/api/common/entity/player/SpongeUserInventoryMixin_Inventory_API.java b/src/mixins/java/org/spongepowered/common/mixin/inventory/api/common/entity/player/SpongeUserInventoryMixin_Inventory_API.java index 6435ddcad08..f2e696d324f 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/inventory/api/common/entity/player/SpongeUserInventoryMixin_Inventory_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/inventory/api/common/entity/player/SpongeUserInventoryMixin_Inventory_API.java @@ -53,12 +53,12 @@ public abstract class SpongeUserInventoryMixin_Inventory_API implements UserInve @Nullable private SlotAdapter impl$offhand; @Override - public Optional getCarrier() { + public Optional carrier() { return Optional.ofNullable(this.user); } @Override - public PrimaryPlayerInventory getPrimary() { + public PrimaryPlayerInventory primary() { if (this.impl$grid == null) { this.impl$grid = (PrimaryPlayerInventoryAdapter) ((PlayerInventoryLens) this.inventoryAdapter$getRootLens()).getPrimaryInventoryLens().getAdapter(this.inventoryAdapter$getFabric(), this); } @@ -66,7 +66,7 @@ public PrimaryPlayerInventory getPrimary() { } @Override - public EquipmentInventory getArmor() { + public EquipmentInventory armor() { if (this.impl$armor == null) { this.impl$armor = (EquipmentInventoryAdapter) ((PlayerInventoryLens) this.inventoryAdapter$getRootLens()).getArmorLens().getAdapter(this.inventoryAdapter$getFabric(), this); } @@ -74,7 +74,7 @@ public EquipmentInventory getArmor() { } @Override - public EquipmentInventory getEquipment() { + public EquipmentInventory equipment() { if (this.impl$equipment == null) { this.impl$equipment = (EquipmentInventoryAdapter) ((PlayerInventoryLens) this.inventoryAdapter$getRootLens()).getEquipmentLens().getAdapter(this.inventoryAdapter$getFabric(), this); } @@ -82,7 +82,7 @@ public EquipmentInventory getEquipment() { } @Override - public Slot getOffhand() { + public Slot offhand() { if (this.impl$offhand == null) { this.impl$offhand = (SlotAdapter) ((PlayerInventoryLens) this.inventoryAdapter$getRootLens()).getOffhandLens().getAdapter(this.inventoryAdapter$getFabric(), this); } diff --git a/src/mixins/java/org/spongepowered/common/mixin/inventory/api/inventory/container/ContainerMixin_Inventory_API.java b/src/mixins/java/org/spongepowered/common/mixin/inventory/api/inventory/container/ContainerMixin_Inventory_API.java index d438b0575ad..045e3f95031 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/inventory/api/inventory/container/ContainerMixin_Inventory_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/inventory/api/inventory/container/ContainerMixin_Inventory_API.java @@ -77,7 +77,7 @@ public boolean isViewedSlot(final org.spongepowered.api.item.inventory.Slot slot } @Override - public List getViewed() { + public List viewed() { List list = new ArrayList<>(); for (Container inv : ((ContainerBridge) this).bridge$getInventories().keySet()) { Inventory inventory = InventoryUtil.toInventory(inv, null); @@ -98,14 +98,14 @@ public boolean setCursor(org.spongepowered.api.item.inventory.ItemStack item) { } @Override - public Optional getCursor() { + public Optional cursor() { return this.listeners().stream().findFirst() .map(p -> p.inventory.getCarried()) .map(ItemStackUtil::fromNative); } @Override - public ServerPlayer getViewer() { + public ServerPlayer viewer() { return this.listeners().stream() .filter(ServerPlayer.class::isInstance) .map(ServerPlayer.class::cast) @@ -116,12 +116,12 @@ public ServerPlayer getViewer() { @Override public boolean isOpen() { org.spongepowered.api.item.inventory.Container thisContainer = this; - throw new MissingImplementationException("Viewer", "getOpenInventory"); -// return this.getViewer().getOpenInventory().map(c -> c == thisContainer).orElse(false); + throw new MissingImplementationException("Viewer", "openInventory"); +// return this.viewer().openInventory().map(c -> c == thisContainer).orElse(false); } @Override - public ContainerType getType() { + public ContainerType type() { return ((ContainerType) this.menuType); } diff --git a/src/mixins/java/org/spongepowered/common/mixin/inventory/api/server/level/ServerPlayerMixin_Carrier_Inventory_API.java b/src/mixins/java/org/spongepowered/common/mixin/inventory/api/server/level/ServerPlayerMixin_Carrier_Inventory_API.java index 7c8370c4c14..07849f76b10 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/inventory/api/server/level/ServerPlayerMixin_Carrier_Inventory_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/inventory/api/server/level/ServerPlayerMixin_Carrier_Inventory_API.java @@ -34,7 +34,7 @@ public abstract class ServerPlayerMixin_Carrier_Inventory_API implements Carrier { @Override - public CarriedInventory getInventory() { + public CarriedInventory inventory() { return (CarriedInventory) ((Player) (Object)this).inventory; } diff --git a/src/mixins/java/org/spongepowered/common/mixin/inventory/api/server/level/ServerPlayerMixin_Inventory_API.java b/src/mixins/java/org/spongepowered/common/mixin/inventory/api/server/level/ServerPlayerMixin_Inventory_API.java index 85344589696..ff76f882ca1 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/inventory/api/server/level/ServerPlayerMixin_Inventory_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/inventory/api/server/level/ServerPlayerMixin_Inventory_API.java @@ -51,7 +51,7 @@ public abstract class ServerPlayerMixin_Inventory_API extends PlayerMixin_Inventory_API implements ServerPlayer { @Override - public Optional getOpenInventory() { + public Optional openInventory() { return Optional.ofNullable((Container) this.containerMenu); } @@ -65,17 +65,17 @@ public Optional openInventory(final Inventory inventory) throws Illeg public Optional openInventory(final Inventory inventory, final Component displayName) { final ContainerBridge openContainer = (ContainerBridge) this.containerMenu; if (openContainer.bridge$isInUse()) { - final Cause cause = PhaseTracker.getCauseStackManager().getCurrentCause(); + final Cause cause = PhaseTracker.getCauseStackManager().currentCause(); SpongeCommon.getLogger().warn("This player is currently modifying an open container. This action will be delayed."); Task.builder().delay(Ticks.zero()).execute(() -> { try (final CauseStackManager.StackFrame frame = PhaseTracker.getCauseStackManager().pushCauseFrame()) { cause.all().forEach(frame::pushCause); - cause.getContext().asMap().forEach((key, value) -> frame.addContext(((EventContextKey) key), value)); + cause.context().asMap().forEach((key, value) -> frame.addContext(((EventContextKey) key), value)); this.closeInventory(); // Cause close event first. So cursor item is not lost. this.openInventory(inventory); // Then open the inventory } }).plugin(Launch.getInstance().getCommonPlugin()).build(); - return this.getOpenInventory(); + return this.openInventory(); } return Optional.ofNullable((Container) InventoryEventFactory.displayContainer((net.minecraft.server.level.ServerPlayer) (Object) this, inventory, displayName)); } @@ -85,12 +85,12 @@ public Optional openInventory(final Inventory inventory, final Compon public boolean closeInventory() throws IllegalArgumentException { final net.minecraft.world.inventory.AbstractContainerMenu openContainer = this.containerMenu; if (((ContainerBridge) openContainer).bridge$isInUse()) { - final Cause cause = PhaseTracker.getCauseStackManager().getCurrentCause(); + final Cause cause = PhaseTracker.getCauseStackManager().currentCause(); SpongeCommon.getLogger().warn("This player is currently modifying an open container. This action will be delayed."); Task.builder().delay(Ticks.zero()).execute(() -> { try (final CauseStackManager.StackFrame frame = PhaseTracker.getCauseStackManager().pushCauseFrame()) { cause.all().forEach(frame::pushCause); - cause.getContext().asMap().forEach((key, value) -> frame.addContext(((EventContextKey) key), value)); + cause.context().asMap().forEach((key, value) -> frame.addContext(((EventContextKey) key), value)); this.closeInventory(); } }).plugin(Launch.getInstance().getCommonPlugin()).build(); diff --git a/src/mixins/java/org/spongepowered/common/mixin/inventory/api/world/CompoundContainerMixin_Carried_Inventory_API.java b/src/mixins/java/org/spongepowered/common/mixin/inventory/api/world/CompoundContainerMixin_Carried_Inventory_API.java index f60da53a406..da5f63970ce 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/inventory/api/world/CompoundContainerMixin_Carried_Inventory_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/inventory/api/world/CompoundContainerMixin_Carried_Inventory_API.java @@ -35,7 +35,7 @@ public abstract class CompoundContainerMixin_Carried_Inventory_API implements CarriedInventory { @Override - public Optional getCarrier() { + public Optional carrier() { return Optional.of((MultiBlockCarrier) this); } diff --git a/src/mixins/java/org/spongepowered/common/mixin/inventory/api/world/CompoundContainerMixin_Carrier_Inventory_API.java b/src/mixins/java/org/spongepowered/common/mixin/inventory/api/world/CompoundContainerMixin_Carrier_Inventory_API.java index d1b11f42ace..aa9d6a2d702 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/inventory/api/world/CompoundContainerMixin_Carrier_Inventory_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/inventory/api/world/CompoundContainerMixin_Carrier_Inventory_API.java @@ -51,42 +51,42 @@ public abstract class CompoundContainerMixin_Carrier_Inventory_API implements Mu @Shadow @Final private Container container2; @Override - public List getLocations() { + public List locations() { final List list = new ArrayList<>(); if (this.container1 instanceof BlockEntity) { - list.add(((BlockEntity) this.container1).getServerLocation()); + list.add(((BlockEntity) this.container1).serverLocation()); } if (this.container2 instanceof BlockEntity) { - list.add(((BlockEntity) this.container2).getServerLocation()); + list.add(((BlockEntity) this.container2).serverLocation()); } return Collections.unmodifiableList(list); } @Override - public CarriedInventory getInventory() { + public CarriedInventory inventory() { return (CarriedInventory) this; } @Override - public ServerLocation getLocation() { - return this.getLocations().get(0); + public ServerLocation location() { + return this.locations().get(0); } @Override - public Optional getInventory(final ServerLocation at) { - if (this.getLocations().contains(at)) { - return Optional.of(this.getInventory()); + public Optional inventory(final ServerLocation at) { + if (this.locations().contains(at)) { + return Optional.of(this.inventory()); } return Optional.empty(); } @Override - public Optional getInventory(final ServerLocation at, final Direction from) { - return this.getInventory(at); + public Optional inventory(final ServerLocation at, final Direction from) { + return this.inventory(at); } @Override - public Inventory getInventory(final Direction from) { - return DefaultSingleBlockCarrier.getInventory(from, this); + public Inventory inventory(final Direction from) { + return DefaultSingleBlockCarrier.inventory(from, this); } } diff --git a/src/mixins/java/org/spongepowered/common/mixin/inventory/api/world/entity/EquipmentSlotMixin_Inventory_API.java b/src/mixins/java/org/spongepowered/common/mixin/inventory/api/world/entity/EquipmentSlotMixin_Inventory_API.java index e74c70e5bd0..f9ad70efbd4 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/inventory/api/world/entity/EquipmentSlotMixin_Inventory_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/inventory/api/world/entity/EquipmentSlotMixin_Inventory_API.java @@ -37,7 +37,7 @@ public abstract class EquipmentSlotMixin_Inventory_API implements EquipmentType @Shadow @Final private EquipmentSlot.Type type; @Override - public EquipmentGroup getGroup() { + public EquipmentGroup group() { return (EquipmentGroup) (Object) this.type; } } diff --git a/src/mixins/java/org/spongepowered/common/mixin/inventory/api/world/entity/animal/horse/AbstractHorseMixin_Carrier_Inventory_API.java b/src/mixins/java/org/spongepowered/common/mixin/inventory/api/world/entity/animal/horse/AbstractHorseMixin_Carrier_Inventory_API.java index 77da4c25532..3e0ab03763a 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/inventory/api/world/entity/animal/horse/AbstractHorseMixin_Carrier_Inventory_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/inventory/api/world/entity/animal/horse/AbstractHorseMixin_Carrier_Inventory_API.java @@ -38,7 +38,7 @@ public abstract class AbstractHorseMixin_Carrier_Inventory_API implements Carrie @Shadow protected SimpleContainer inventory; @Override - public CarriedInventory getInventory() { + public CarriedInventory inventory() { return InventoryUtil.carriedWrapperInventory(this.inventory, this); } diff --git a/src/mixins/java/org/spongepowered/common/mixin/inventory/api/world/entity/monster/PillagerMixin_Carrier_Inventory_API.java b/src/mixins/java/org/spongepowered/common/mixin/inventory/api/world/entity/monster/PillagerMixin_Carrier_Inventory_API.java index 5f0ccd06881..7b3da8a4f4c 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/inventory/api/world/entity/monster/PillagerMixin_Carrier_Inventory_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/inventory/api/world/entity/monster/PillagerMixin_Carrier_Inventory_API.java @@ -39,7 +39,7 @@ public abstract class PillagerMixin_Carrier_Inventory_API implements Carrier { @Shadow @Final private SimpleContainer inventory; @Override - public CarriedInventory getInventory() { + public CarriedInventory inventory() { return InventoryUtil.carriedWrapperInventory(this.inventory, this); } diff --git a/src/mixins/java/org/spongepowered/common/mixin/inventory/api/world/entity/npc/AbstractVillagerMixin_Carrier_Inventory_API.java b/src/mixins/java/org/spongepowered/common/mixin/inventory/api/world/entity/npc/AbstractVillagerMixin_Carrier_Inventory_API.java index 0765636a8c8..31ebb802dae 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/inventory/api/world/entity/npc/AbstractVillagerMixin_Carrier_Inventory_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/inventory/api/world/entity/npc/AbstractVillagerMixin_Carrier_Inventory_API.java @@ -39,7 +39,7 @@ public abstract class AbstractVillagerMixin_Carrier_Inventory_API implements Car @Shadow @Final private SimpleContainer inventory; @Override - public CarriedInventory getInventory() { + public CarriedInventory inventory() { return InventoryUtil.carriedWrapperInventory(this.inventory, this); } diff --git a/src/mixins/java/org/spongepowered/common/mixin/inventory/api/world/entity/player/InventoryMixin_Carried_Inventory_API.java b/src/mixins/java/org/spongepowered/common/mixin/inventory/api/world/entity/player/InventoryMixin_Carried_Inventory_API.java index 9a71f800bfb..827d5666b87 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/inventory/api/world/entity/player/InventoryMixin_Carried_Inventory_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/inventory/api/world/entity/player/InventoryMixin_Carried_Inventory_API.java @@ -38,7 +38,7 @@ public abstract class InventoryMixin_Carried_Inventory_API implements CarriedInv @Final @Shadow public net.minecraft.world.entity.player.Player player; @Override - public Optional getCarrier() { + public Optional carrier() { return Optional.ofNullable((Player) this.player); } diff --git a/src/mixins/java/org/spongepowered/common/mixin/inventory/api/world/entity/player/InventoryMixin_Inventory_API.java b/src/mixins/java/org/spongepowered/common/mixin/inventory/api/world/entity/player/InventoryMixin_Inventory_API.java index 40ac8487784..5214de086fc 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/inventory/api/world/entity/player/InventoryMixin_Inventory_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/inventory/api/world/entity/player/InventoryMixin_Inventory_API.java @@ -48,7 +48,7 @@ public abstract class InventoryMixin_Inventory_API implements PlayerInventory { @Nullable private SlotAdapter api$offhand; @Override - public PrimaryPlayerInventory getPrimary() { + public PrimaryPlayerInventory primary() { if (this.api$primary == null && ((InventoryAdapter) this).inventoryAdapter$getRootLens() instanceof PlayerInventoryLens) { final Lens lens = ((InventoryAdapter) this).inventoryAdapter$getRootLens(); final Fabric fabric = ((InventoryAdapter) this).inventoryAdapter$getFabric(); @@ -58,7 +58,7 @@ public PrimaryPlayerInventory getPrimary() { } @Override - public EquipmentInventory getArmor() { + public EquipmentInventory armor() { if (this.api$armor == null && ((InventoryAdapter) this).inventoryAdapter$getRootLens() instanceof PlayerInventoryLens) { final Lens lens = ((InventoryAdapter) this).inventoryAdapter$getRootLens(); final Fabric fabric = ((InventoryAdapter) this).inventoryAdapter$getFabric(); @@ -68,7 +68,7 @@ public EquipmentInventory getArmor() { } @Override - public EquipmentInventory getEquipment() { + public EquipmentInventory equipment() { if (this.api$equipment == null && ((InventoryAdapter) this).inventoryAdapter$getRootLens() instanceof PlayerInventoryLens) { final Lens lens = ((InventoryAdapter) this).inventoryAdapter$getRootLens(); final Fabric fabric = ((InventoryAdapter) this).inventoryAdapter$getFabric(); @@ -78,7 +78,7 @@ public EquipmentInventory getEquipment() { } @Override - public Slot getOffhand() { + public Slot offhand() { if (this.api$offhand == null && ((InventoryAdapter) this).inventoryAdapter$getRootLens() instanceof PlayerInventoryLens) { final Lens lens = ((InventoryAdapter) this).inventoryAdapter$getRootLens(); final Fabric fabric = ((InventoryAdapter) this).inventoryAdapter$getFabric(); diff --git a/src/mixins/java/org/spongepowered/common/mixin/inventory/api/world/entity/player/PlayerMixin_Inventory_API.java b/src/mixins/java/org/spongepowered/common/mixin/inventory/api/world/entity/player/PlayerMixin_Inventory_API.java index 99da8e9da2c..36e279cc344 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/inventory/api/world/entity/player/PlayerMixin_Inventory_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/inventory/api/world/entity/player/PlayerMixin_Inventory_API.java @@ -44,17 +44,17 @@ public abstract class PlayerMixin_Inventory_API implements Player, InventoryBrid @Shadow public abstract PlayerEnderChestContainer shadow$getEnderChestInventory(); @Override - public org.spongepowered.api.item.inventory.entity.PlayerInventory getInventory() { + public org.spongepowered.api.item.inventory.entity.PlayerInventory inventory() { return (org.spongepowered.api.item.inventory.entity.PlayerInventory) this.inventory; } @Override - public EquipmentInventory getEquipment() { - return this.getInventory().getEquipment(); + public EquipmentInventory equipment() { + return this.inventory().equipment(); } @Override - public Inventory getEnderChestInventory() { + public Inventory enderChestInventory() { return (Inventory) this.shadow$getEnderChestInventory(); } diff --git a/src/mixins/java/org/spongepowered/common/mixin/inventory/api/world/entity/vehicle/AbstractMinecartContainerMixin_Carried_Inventory_API.java b/src/mixins/java/org/spongepowered/common/mixin/inventory/api/world/entity/vehicle/AbstractMinecartContainerMixin_Carried_Inventory_API.java index aeff25b7bbd..68e75b4004f 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/inventory/api/world/entity/vehicle/AbstractMinecartContainerMixin_Carried_Inventory_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/inventory/api/world/entity/vehicle/AbstractMinecartContainerMixin_Carried_Inventory_API.java @@ -36,7 +36,7 @@ public abstract class AbstractMinecartContainerMixin_Carried_Inventory_API getCarrier() { + public Optional carrier() { return Optional.of((M) this); } } diff --git a/src/mixins/java/org/spongepowered/common/mixin/inventory/api/world/entity/vehicle/AbstractMinecartContainerMixin_Carrier_Inventory_API.java b/src/mixins/java/org/spongepowered/common/mixin/inventory/api/world/entity/vehicle/AbstractMinecartContainerMixin_Carrier_Inventory_API.java index cc7db994808..c770d7e904c 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/inventory/api/world/entity/vehicle/AbstractMinecartContainerMixin_Carrier_Inventory_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/inventory/api/world/entity/vehicle/AbstractMinecartContainerMixin_Carrier_Inventory_API.java @@ -34,7 +34,7 @@ public abstract class AbstractMinecartContainerMixin_Carrier_Inventory_API> implements Carrier { @Override - public CarriedInventory getInventory() { + public CarriedInventory inventory() { return (CarriedInventory) this; } } diff --git a/src/mixins/java/org/spongepowered/common/mixin/inventory/api/world/inventory/AnvilMenuMixin_BlockCarrier_Inventory_API.java b/src/mixins/java/org/spongepowered/common/mixin/inventory/api/world/inventory/AnvilMenuMixin_BlockCarrier_Inventory_API.java index 9cb31220872..ae24b3a6c93 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/inventory/api/world/inventory/AnvilMenuMixin_BlockCarrier_Inventory_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/inventory/api/world/inventory/AnvilMenuMixin_BlockCarrier_Inventory_API.java @@ -37,14 +37,14 @@ public abstract class AnvilMenuMixin_BlockCarrier_Inventory_API implements DefaultSingleBlockCarrier { @Override - public ServerLocation getLocation() { + public ServerLocation location() { return ((ItemCombinerMenuAccessor) this).accessor$access().evaluate((world, pos) -> ServerLocation.of(((ServerWorld) world), new Vector3i(pos.getX(), pos.getY(), pos.getZ())) ).orElse(null); } @Override - public World getWorld() { + public World world() { return ((ItemCombinerMenuAccessor) this).accessor$access().evaluate((world, pos) -> (World) world).orElse(null); } diff --git a/src/mixins/java/org/spongepowered/common/mixin/inventory/api/world/inventory/CraftingContainerMixin_Inventory_API.java b/src/mixins/java/org/spongepowered/common/mixin/inventory/api/world/inventory/CraftingContainerMixin_Inventory_API.java index b3f80370ba3..7123e32bdb6 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/inventory/api/world/inventory/CraftingContainerMixin_Inventory_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/inventory/api/world/inventory/CraftingContainerMixin_Inventory_API.java @@ -53,8 +53,8 @@ public abstract class CraftingContainerMixin_Inventory_API implements CraftingGr private GridInventory gridAdapter; @Override - public Optional getRecipe(ServerWorld world) { - return Sponge.getRegistry().getRecipeRegistry().findMatchingRecipe((Inventory) this.menu, checkNotNull(world, "world")).map(CraftingRecipe.class::cast); + public Optional recipe(ServerWorld world) { + return Sponge.registry().recipeRegistry().findMatchingRecipe((Inventory) this.menu, checkNotNull(world, "world")).map(CraftingRecipe.class::cast); } @Override diff --git a/src/mixins/java/org/spongepowered/common/mixin/inventory/api/world/inventory/CraftingMenuMixin_BlockCarrier_Inventory_API.java b/src/mixins/java/org/spongepowered/common/mixin/inventory/api/world/inventory/CraftingMenuMixin_BlockCarrier_Inventory_API.java index 912e401e49e..c11a87165b4 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/inventory/api/world/inventory/CraftingMenuMixin_BlockCarrier_Inventory_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/inventory/api/world/inventory/CraftingMenuMixin_BlockCarrier_Inventory_API.java @@ -40,12 +40,12 @@ public abstract class CraftingMenuMixin_BlockCarrier_Inventory_API implements De @Shadow @Final private ContainerLevelAccess access; @Override - public ServerLocation getLocation() { + public ServerLocation location() { return this.access.evaluate((world, pos) -> ServerLocation.of(((ServerWorld) world), pos.getX(), pos.getY(), pos.getZ())).orElse(null); } @Override - public World getWorld() { + public World world() { return this.access.evaluate((world, pos) -> (World) world).orElse(null); } diff --git a/src/mixins/java/org/spongepowered/common/mixin/inventory/api/world/inventory/EnchantmentMenuMixin_BlockCarrier_Inventory_API.java b/src/mixins/java/org/spongepowered/common/mixin/inventory/api/world/inventory/EnchantmentMenuMixin_BlockCarrier_Inventory_API.java index 6f7a1be1e88..940772d7bfb 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/inventory/api/world/inventory/EnchantmentMenuMixin_BlockCarrier_Inventory_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/inventory/api/world/inventory/EnchantmentMenuMixin_BlockCarrier_Inventory_API.java @@ -38,7 +38,7 @@ import org.spongepowered.math.vector.Vector3i; /** - * Specifically to implement the {@link #getInventory()} and {@link #getLocation()} + * Specifically to implement the {@link #inventory()} and {@link #location()} * aspects of {@link SingleBlockCarrier} since the remainder of * {@link Inventory} implementation is defaulted in {@link SingleBlockCarrier} */ @@ -48,14 +48,14 @@ public abstract class EnchantmentMenuMixin_BlockCarrier_Inventory_API implements @Shadow @Final private ContainerLevelAccess access; @Override - public ServerLocation getLocation() { + public ServerLocation location() { return this.access.evaluate((world, pos) -> ServerLocation.of(((ServerWorld) world), new Vector3i(pos.getX(), pos.getY(), pos.getZ())) ).orElse(null); } @Override - public World getWorld() { + public World world() { return this.access.evaluate((world, pos) -> (World) world).orElse(null); } diff --git a/src/mixins/java/org/spongepowered/common/mixin/inventory/api/world/inventory/LecternMenuMixin_BlockCarrier_Inventory_API.java b/src/mixins/java/org/spongepowered/common/mixin/inventory/api/world/inventory/LecternMenuMixin_BlockCarrier_Inventory_API.java index 73130aa91b3..fe967ea3a88 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/inventory/api/world/inventory/LecternMenuMixin_BlockCarrier_Inventory_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/inventory/api/world/inventory/LecternMenuMixin_BlockCarrier_Inventory_API.java @@ -43,16 +43,16 @@ public abstract class LecternMenuMixin_BlockCarrier_Inventory_API implements Def private LecternBlockEntity impl$lectern; @Override - public ServerLocation getLocation() { + public ServerLocation location() { if (this.impl$lectern == null) { this.impl$lectern = ((LecternBlockEntity_Accessor) this.lectern).accessor$this$0(); } - return ((BlockEntity) this.impl$lectern).getServerLocation(); + return ((BlockEntity) this.impl$lectern).serverLocation(); } @Override - public World getWorld() { - return ((BlockEntity) this.lectern).getWorld(); + public World world() { + return ((BlockEntity) this.lectern).world(); } } diff --git a/src/mixins/java/org/spongepowered/common/mixin/inventory/api/world/inventory/LoomMenuMixin_BlockCarrier_Inventory_API.java b/src/mixins/java/org/spongepowered/common/mixin/inventory/api/world/inventory/LoomMenuMixin_BlockCarrier_Inventory_API.java index 98e9d3913c3..cf309bb2af3 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/inventory/api/world/inventory/LoomMenuMixin_BlockCarrier_Inventory_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/inventory/api/world/inventory/LoomMenuMixin_BlockCarrier_Inventory_API.java @@ -41,14 +41,14 @@ public abstract class LoomMenuMixin_BlockCarrier_Inventory_API implements Defaul @Final @Shadow private ContainerLevelAccess access; @Override - public ServerLocation getLocation() { + public ServerLocation location() { return this.access.evaluate((world, pos) -> ServerLocation.of(((ServerWorld) world), new Vector3i(pos.getX(), pos.getY(), pos.getZ())) ).orElse(null); } @Override - public World getWorld() { + public World world() { return this.access.evaluate((world, pos) -> (World) world).orElse(null); } } diff --git a/src/mixins/java/org/spongepowered/common/mixin/inventory/api/world/inventory/StonecutterMenuMixin_BlockCarrier_Inventory_API.java b/src/mixins/java/org/spongepowered/common/mixin/inventory/api/world/inventory/StonecutterMenuMixin_BlockCarrier_Inventory_API.java index 0380a6d7976..5c318089aa6 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/inventory/api/world/inventory/StonecutterMenuMixin_BlockCarrier_Inventory_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/inventory/api/world/inventory/StonecutterMenuMixin_BlockCarrier_Inventory_API.java @@ -41,14 +41,14 @@ public abstract class StonecutterMenuMixin_BlockCarrier_Inventory_API implements @Final @Shadow private ContainerLevelAccess access; @Override - public ServerLocation getLocation() { + public ServerLocation location() { return this.access.evaluate((world, pos) -> ServerLocation.of(((ServerWorld) world), new Vector3i(pos.getX(), pos.getY(), pos.getZ())) ).orElse(null); } @Override - public World getWorld() { + public World world() { return this.access.evaluate((world, pos) -> (World) world).orElse(null); } } diff --git a/src/mixins/java/org/spongepowered/common/mixin/inventory/api/world/level/block/entity/BaseContainerBlockEntityMixin_Carried_Inventory_API.java b/src/mixins/java/org/spongepowered/common/mixin/inventory/api/world/level/block/entity/BaseContainerBlockEntityMixin_Carried_Inventory_API.java index 50d18c1b6c4..9bfd846c2bc 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/inventory/api/world/level/block/entity/BaseContainerBlockEntityMixin_Carried_Inventory_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/inventory/api/world/level/block/entity/BaseContainerBlockEntityMixin_Carried_Inventory_API.java @@ -37,13 +37,13 @@ public abstract class BaseContainerBlockEntityMixin_Carried_Inventory_API getCarrier() { + public Optional carrier() { return Optional.of((T) this); } @Override @SuppressWarnings("unchecked") - public Optional getBlockEntity() { + public Optional blockEntity() { return Optional.of((T) this); } diff --git a/src/mixins/java/org/spongepowered/common/mixin/inventory/api/world/level/block/entity/BaseContainerBlockEntityMixin_Carrier_Inventory_API.java b/src/mixins/java/org/spongepowered/common/mixin/inventory/api/world/level/block/entity/BaseContainerBlockEntityMixin_Carrier_Inventory_API.java index 00e3230e08b..fb076cb498e 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/inventory/api/world/level/block/entity/BaseContainerBlockEntityMixin_Carrier_Inventory_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/inventory/api/world/level/block/entity/BaseContainerBlockEntityMixin_Carrier_Inventory_API.java @@ -37,13 +37,13 @@ public abstract class BaseContainerBlockEntityMixin_Carrier_Inventory_API implem @SuppressWarnings("unchecked") @Override - public BlockEntityInventory getInventory() { + public BlockEntityInventory inventory() { return (BlockEntityInventory) this; } @Override - public Inventory getInventory(final Direction from) { - return DefaultSingleBlockCarrier.getInventory(from, this); + public Inventory inventory(final Direction from) { + return DefaultSingleBlockCarrier.inventory(from, this); } } diff --git a/src/mixins/java/org/spongepowered/common/mixin/inventory/api/world/level/block/entity/CampfireBlockEntityMixin_Carried_Inventory_API.java b/src/mixins/java/org/spongepowered/common/mixin/inventory/api/world/level/block/entity/CampfireBlockEntityMixin_Carried_Inventory_API.java index 8f0423e878f..4073a3c57c5 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/inventory/api/world/level/block/entity/CampfireBlockEntityMixin_Carried_Inventory_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/inventory/api/world/level/block/entity/CampfireBlockEntityMixin_Carried_Inventory_API.java @@ -37,13 +37,13 @@ public abstract class CampfireBlockEntityMixin_Carried_Inventory_API getCarrier() { + public Optional carrier() { return Optional.of((T) this); } @Override @SuppressWarnings("unchecked") - public Optional getBlockEntity() { + public Optional blockEntity() { return Optional.of((T) this); } diff --git a/src/mixins/java/org/spongepowered/common/mixin/inventory/api/world/level/block/entity/CampfireBlockEntityMixin_Carrier_Inventory_API.java b/src/mixins/java/org/spongepowered/common/mixin/inventory/api/world/level/block/entity/CampfireBlockEntityMixin_Carrier_Inventory_API.java index e5522ec6a76..18eddf53bf9 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/inventory/api/world/level/block/entity/CampfireBlockEntityMixin_Carrier_Inventory_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/inventory/api/world/level/block/entity/CampfireBlockEntityMixin_Carrier_Inventory_API.java @@ -37,13 +37,13 @@ public abstract class CampfireBlockEntityMixin_Carrier_Inventory_API implements @SuppressWarnings("unchecked") @Override - public BlockEntityInventory getInventory() { + public BlockEntityInventory inventory() { return (BlockEntityInventory) this; } @Override - public Inventory getInventory(final Direction from) { - return DefaultSingleBlockCarrier.getInventory(from, this); + public Inventory inventory(final Direction from) { + return DefaultSingleBlockCarrier.inventory(from, this); } } diff --git a/src/mixins/java/org/spongepowered/common/mixin/inventory/api/world/level/block/entity/ChestBlockEntityMixin_Inventory_API.java b/src/mixins/java/org/spongepowered/common/mixin/inventory/api/world/level/block/entity/ChestBlockEntityMixin_Inventory_API.java index f5e300d91d3..2a1a7a891a3 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/inventory/api/world/level/block/entity/ChestBlockEntityMixin_Inventory_API.java +++ b/src/mixins/java/org/spongepowered/common/mixin/inventory/api/world/level/block/entity/ChestBlockEntityMixin_Inventory_API.java @@ -36,7 +36,7 @@ public abstract class ChestBlockEntityMixin_Inventory_API implements Chest { @Override - public Optional getDoubleChestInventory() { + public Optional doubleChestInventory() { return InventoryUtil.getDoubleChestInventory(((ChestBlockEntity)(Object) this)); } diff --git a/src/mixins/java/org/spongepowered/common/mixin/inventory/event/entity/LivingEntityMixin_Inventory.java b/src/mixins/java/org/spongepowered/common/mixin/inventory/event/entity/LivingEntityMixin_Inventory.java index 761f163a1a5..f9d51a69ad5 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/inventory/event/entity/LivingEntityMixin_Inventory.java +++ b/src/mixins/java/org/spongepowered/common/mixin/inventory/event/entity/LivingEntityMixin_Inventory.java @@ -111,12 +111,12 @@ public abstract class LivingEntityMixin_Inventory { this.shadow$setItemSlot(equipmentslottype, oldStack); return true; } - final Transaction transaction = event.getTransaction(); + final Transaction transaction = event.transaction(); if (!transaction.isValid()) { this.shadow$setItemSlot(equipmentslottype, oldStack); return true; } - final Optional optional = transaction.getCustom(); + final Optional optional = transaction.custom(); if (optional.isPresent()) { final ItemStack custom = ItemStackUtil.fromSnapshotToNative(optional.get()); this.shadow$setItemSlot(equipmentslottype, custom); diff --git a/src/mixins/java/org/spongepowered/common/mixin/inventory/event/entity/player/PlayerEntityMixin_Inventory.java b/src/mixins/java/org/spongepowered/common/mixin/inventory/event/entity/player/PlayerEntityMixin_Inventory.java index 0b05df80472..7aebdc1bcb5 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/inventory/event/entity/player/PlayerEntityMixin_Inventory.java +++ b/src/mixins/java/org/spongepowered/common/mixin/inventory/event/entity/player/PlayerEntityMixin_Inventory.java @@ -63,15 +63,15 @@ private void onSetItemStackToSlot(final EquipmentSlot slotIn, final ItemStack st List slotTransactions = ((TrackedInventoryBridge) this.inventory).bridge$getCapturedSlotTransactions(); if (slotIn == EquipmentSlot.MAINHAND) { final ItemStack orig = this.inventory.items.get(this.inventory.selected); - final Slot slot = ((PlayerInventory) this.inventory).getPrimary().getHotbar().getSlot(this.inventory.selected).get(); + final Slot slot = ((PlayerInventory) this.inventory).primary().hotbar().slot(this.inventory.selected).get(); slotTransactions.add(new SlotTransaction(slot, ItemStackUtil.snapshotOf(orig), ItemStackUtil.snapshotOf(stack))); } else if (slotIn == EquipmentSlot.OFFHAND) { final ItemStack orig = this.inventory.offhand.get(0); - final Slot slot = ((PlayerInventory) this.inventory).getOffhand(); + final Slot slot = ((PlayerInventory) this.inventory).offhand(); slotTransactions.add(new SlotTransaction(slot, ItemStackUtil.snapshotOf(orig), ItemStackUtil.snapshotOf(stack))); } else if (slotIn.getType() == EquipmentSlot.Type.ARMOR) { final ItemStack orig = this.inventory.armor.get(slotIn.getIndex()); - final Slot slot = ((PlayerInventory) this.inventory).getEquipment().getSlot(slotIn.getIndex()).get(); + final Slot slot = ((PlayerInventory) this.inventory).equipment().slot(slotIn.getIndex()).get(); slotTransactions.add(new SlotTransaction(slot, ItemStackUtil.snapshotOf(orig), ItemStackUtil.snapshotOf(stack))); } } diff --git a/src/mixins/java/org/spongepowered/common/mixin/inventory/event/server/network/ServerGamePacketListenerImplMixin_Inventory.java b/src/mixins/java/org/spongepowered/common/mixin/inventory/event/server/network/ServerGamePacketListenerImplMixin_Inventory.java index 0cbc4f2a169..a9ce512d7e5 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/inventory/event/server/network/ServerGamePacketListenerImplMixin_Inventory.java +++ b/src/mixins/java/org/spongepowered/common/mixin/inventory/event/server/network/ServerGamePacketListenerImplMixin_Inventory.java @@ -66,16 +66,16 @@ private void onProcessCreativeInventoryAction(ServerboundSetCreativeModeSlotPack } ci.cancel(); } else { - if (PacketPhaseUtil.handleSlotRestore(this.player, this.player.containerMenu, clickEvent.getTransactions(), false)) { + if (PacketPhaseUtil.handleSlotRestore(this.player, this.player.containerMenu, clickEvent.transactions(), false)) { ci.cancel(); } - final Transaction cursorTransaction = clickEvent.getCursorTransaction(); + final Transaction cursorTransaction = clickEvent.cursorTransaction(); if (!cursorTransaction.isValid()) { // TODO original cursor is currently always empty - PacketPhaseUtil.handleCustomCursor(this.player, cursorTransaction.getOriginal()); + PacketPhaseUtil.handleCustomCursor(this.player, cursorTransaction.original()); } - else if (cursorTransaction.getCustom().isPresent()) { - PacketPhaseUtil.handleCustomCursor(this.player, cursorTransaction.getFinal()); + else if (cursorTransaction.custom().isPresent()) { + PacketPhaseUtil.handleCustomCursor(this.player, cursorTransaction.finalReplacement()); } } } diff --git a/src/mixins/java/org/spongepowered/common/mixin/inventory/event/world/inventory/AbstractContainerMenuMixin_Inventory.java b/src/mixins/java/org/spongepowered/common/mixin/inventory/event/world/inventory/AbstractContainerMenuMixin_Inventory.java index 0978c037c21..ca31508e0d0 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/inventory/event/world/inventory/AbstractContainerMenuMixin_Inventory.java +++ b/src/mixins/java/org/spongepowered/common/mixin/inventory/event/world/inventory/AbstractContainerMenuMixin_Inventory.java @@ -149,7 +149,7 @@ public abstract class AbstractContainerMenuMixin_Inventory implements TrackedCon @Override public void bridge$trackViewable(Object inventory) { if (inventory instanceof Carrier) { - inventory = ((Carrier) inventory).getInventory(); + inventory = ((Carrier) inventory).inventory(); } if (inventory instanceof Inventory) { ((Inventory) inventory).asViewable().ifPresent(i -> ((ViewableInventoryBridge) i).viewableBridge$addContainer((AbstractContainerMenu) (Object) this)); @@ -167,7 +167,7 @@ public abstract class AbstractContainerMenuMixin_Inventory implements TrackedCon private void impl$unTrackViewable(@Nullable Object inventory) { if (inventory instanceof Carrier) { - inventory = ((Carrier) inventory).getInventory(); + inventory = ((Carrier) inventory).inventory(); } if (inventory instanceof Inventory) { ((Inventory) inventory).asViewable().ifPresent(i -> ((ViewableInventoryBridge) i).viewableBridge$removeContainer(((AbstractContainerMenu) (Object) this))); diff --git a/src/mixins/java/org/spongepowered/common/mixin/inventory/event/world/inventory/AnvilMenuMixin_Inventory.java b/src/mixins/java/org/spongepowered/common/mixin/inventory/event/world/inventory/AnvilMenuMixin_Inventory.java index 63a77c11ca2..2d5f4c7aa4e 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/inventory/event/world/inventory/AnvilMenuMixin_Inventory.java +++ b/src/mixins/java/org/spongepowered/common/mixin/inventory/event/world/inventory/AnvilMenuMixin_Inventory.java @@ -60,7 +60,7 @@ public abstract class AnvilMenuMixin_Inventory extends ItemCombinerMenuMixin_Inv (AnvilMenu) (Object) this, itemstack, itemstack2, result, this.itemName == null ? "" : this.itemName, this.cost.get(), this.repairItemCountCost); - final ItemStackSnapshot finalItem = event.getResult().getFinal(); + final ItemStackSnapshot finalItem = event.result().finalReplacement(); if (event.isCancelled() || finalItem.isEmpty()) { this.resultSlots.setItem(0, ItemStack.EMPTY); this.cost.set(0); @@ -69,9 +69,9 @@ public abstract class AnvilMenuMixin_Inventory extends ItemCombinerMenuMixin_Inv return; } - this.resultSlots.setItem(0, ItemStackUtil.fromSnapshotToNative(event.getResult().getFinal())); - this.cost.set(event.getCosts().getFinal().getLevelCost()); - this.repairItemCountCost = event.getCosts().getFinal().getMaterialCost(); + this.resultSlots.setItem(0, ItemStackUtil.fromSnapshotToNative(event.result().finalReplacement())); + this.cost.set(event.costs().finalReplacement().levelCost()); + this.repairItemCountCost = event.costs().finalReplacement().materialCost(); ((AnvilMenu)(Object) this).broadcastChanges(); } diff --git a/src/mixins/java/org/spongepowered/common/mixin/inventory/event/world/inventory/ResultSlotMixin_Inventory.java b/src/mixins/java/org/spongepowered/common/mixin/inventory/event/world/inventory/ResultSlotMixin_Inventory.java index 5b7f3ead818..ee2ac21458b 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/inventory/event/world/inventory/ResultSlotMixin_Inventory.java +++ b/src/mixins/java/org/spongepowered/common/mixin/inventory/event/world/inventory/ResultSlotMixin_Inventory.java @@ -148,7 +148,7 @@ private void afterTake(final Player thePlayer, final ItemStack stack, final Call final List capturedTransactions = ((TrackedInventoryBridge) container).bridge$getCapturedSlotTransactions(); for (final Iterator iterator = capturedTransactions.iterator(); iterator.hasNext(); ) { final SlotTransaction trans = iterator.next(); - Optional slotIndex = trans.getSlot().get(Keys.SLOT_INDEX); + Optional slotIndex = trans.slot().get(Keys.SLOT_INDEX); if (slotIndex.isPresent() && slotIndex.get() == 0) { iterator.remove(); if (first == null) { @@ -161,7 +161,7 @@ private void afterTake(final Player thePlayer, final ItemStack stack, final Call // if we got a transaction on the crafting-slot use this if (first != null) { capturedTransactions.add(first); - craftedItem = first.getOriginal().copy(); + craftedItem = first.original().copy(); } else { craftedItem = ItemStackUtil.snapshotOf(this.impl$craftedStack); } @@ -182,7 +182,7 @@ private void afterTake(final Player thePlayer, final ItemStack stack, final Call final SlotTransaction last; if (previewTransactions.isEmpty()) { - last = new SlotTransaction(craftingInventory.getResult(), ItemStackSnapshot.empty(), ItemStackUtil.snapshotOf(this.getItem())); + last = new SlotTransaction(craftingInventory.result(), ItemStackSnapshot.empty(), ItemStackUtil.snapshotOf(this.getItem())); previewTransactions.add(last); } else { last = previewTransactions.get(0); diff --git a/src/mixins/java/org/spongepowered/common/mixin/inventory/impl/world/inventory/AbstractContainerMenuMixin_Menu_Inventory.java b/src/mixins/java/org/spongepowered/common/mixin/inventory/impl/world/inventory/AbstractContainerMenuMixin_Menu_Inventory.java index 91216dfabc6..54bc4bf8163 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/inventory/impl/world/inventory/AbstractContainerMenuMixin_Menu_Inventory.java +++ b/src/mixins/java/org/spongepowered/common/mixin/inventory/impl/world/inventory/AbstractContainerMenuMixin_Menu_Inventory.java @@ -133,7 +133,7 @@ public abstract class AbstractContainerMenuMixin_Menu_Inventory implements MenuB @Override public boolean bridge$isReadonlyMenu(Slot slot) { - return this.impl$menu != null && this.impl$menu.isReadOnly() && slot.container == this.impl$menu.getInventory(); + return this.impl$menu != null && this.impl$menu.isReadOnly() && slot.container == this.impl$menu.inventory(); } @Override diff --git a/src/mixins/java/org/spongepowered/common/mixin/tracker/CreatorTrackedMixin_Tracker.java b/src/mixins/java/org/spongepowered/common/mixin/tracker/CreatorTrackedMixin_Tracker.java index 30b95e4e122..8edba80e392 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/tracker/CreatorTrackedMixin_Tracker.java +++ b/src/mixins/java/org/spongepowered/common/mixin/tracker/CreatorTrackedMixin_Tracker.java @@ -66,7 +66,7 @@ public abstract class CreatorTrackedMixin_Tracker implements CreatorTrackedBridg @Override public void tracked$setCreatorReference(@Nullable final User creator) { this.tracker$creatorUser = new WeakReference<>(creator); - this.tracked$setTrackedUUID(PlayerTracker.Type.CREATOR, creator == null ? null : creator.getUniqueId()); + this.tracked$setTrackedUUID(PlayerTracker.Type.CREATOR, creator == null ? null : creator.uniqueId()); } @Override @@ -85,7 +85,7 @@ public abstract class CreatorTrackedMixin_Tracker implements CreatorTrackedBridg @Override public void tracked$setNotifier(@Nullable final User notifier) { this.tracker$notifierUser = new WeakReference<>(notifier); - this.tracked$setTrackedUUID(PlayerTracker.Type.NOTIFIER, notifier == null ? null : notifier.getUniqueId()); + this.tracked$setTrackedUUID(PlayerTracker.Type.NOTIFIER, notifier == null ? null : notifier.uniqueId()); } @Override @@ -109,26 +109,26 @@ public abstract class CreatorTrackedMixin_Tracker implements CreatorTrackedBridg return Optional.empty(); } // get player if online - final ServerPlayer player = Sponge.getServer().getPlayer(uuid).orElse(null); - final User user = player == null ? null : player.getUser(); + final ServerPlayer player = Sponge.server().player(uuid).orElse(null); + final User user = player == null ? null : player.user(); if (user != null) { return Optional.of(user); } // check username cache - final String username = ((SpongeServer) Sponge.getServer()).getUsernameCache().getLastKnownUsername(uuid); + final String username = ((SpongeServer) Sponge.server()).getUsernameCache().getLastKnownUsername(uuid); if (username != null) { - return Sponge.getServer().getUserManager().get(GameProfile.of(uuid, username)); + return Sponge.server().userManager().find(GameProfile.of(uuid, username)); } // check mojang cache - final GameProfile profile = Sponge.getServer().getGameProfileManager().getCache().getById(uuid).orElse(null); + final GameProfile profile = Sponge.server().gameProfileManager().cache().byId(uuid).orElse(null); if (profile != null) { - return Sponge.getServer().getUserManager().get(profile); + return Sponge.server().userManager().find(profile); } // If we reach this point, queue UUID for async lookup and return empty - ((SpongeGameProfileManager) Sponge.getServer().getGameProfileManager()).lookupUserAsync(uuid); + ((SpongeGameProfileManager) Sponge.server().gameProfileManager()).lookupUserAsync(uuid); return Optional.empty(); } diff --git a/src/mixins/java/org/spongepowered/common/mixin/tracker/server/level/ChunkMapMixin_Tracker.java b/src/mixins/java/org/spongepowered/common/mixin/tracker/server/level/ChunkMapMixin_Tracker.java index c77e7d1cc23..c874b120c66 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/tracker/server/level/ChunkMapMixin_Tracker.java +++ b/src/mixins/java/org/spongepowered/common/mixin/tracker/server/level/ChunkMapMixin_Tracker.java @@ -56,7 +56,7 @@ public abstract class ChunkMapMixin_Tracker { at = @At(value = "NEW", args = "class=java/lang/IllegalStateException", remap = false)) private IllegalStateException tracker$reportEntityAlreadyTrackedWithWorld(final String string, final Entity entityIn) { final IllegalStateException exception = new IllegalStateException(String.format("Entity %s is already tracked for world: %s", entityIn, - ((org.spongepowered.api.world.server.ServerWorld) this.level).getKey())); + ((org.spongepowered.api.world.server.ServerWorld) this.level).key())); if (SpongeConfigs.getCommon().get().phaseTracker.verboseErrors) { PhasePrinter.printMessageWithCaughtException(PhaseTracker.getInstance(), "Exception tracking entity", "An entity that was already tracked was added to the tracker!", exception); } diff --git a/src/mixins/java/org/spongepowered/common/mixin/tracker/server/level/ServerLevelMixin_Tracker.java b/src/mixins/java/org/spongepowered/common/mixin/tracker/server/level/ServerLevelMixin_Tracker.java index f4c501f9d2a..d52e9d50596 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/tracker/server/level/ServerLevelMixin_Tracker.java +++ b/src/mixins/java/org/spongepowered/common/mixin/tracker/server/level/ServerLevelMixin_Tracker.java @@ -370,12 +370,12 @@ public abstract class ServerLevelMixin_Tracker extends LevelMixin_Tracker implem final ExplosionEvent.Pre event = SpongeEventFactory.createExplosionEventPre( - PhaseTracker.SERVER.getCurrentCause(), + PhaseTracker.SERVER.currentCause(), explosion, ((org.spongepowered.api.world.server.ServerWorld) this)); if (SpongeCommon.postEvent(event)) { return (Explosion) explosion; } - explosion = event.getExplosion(); + explosion = event.explosion(); } final Explosion mcExplosion; try { @@ -391,7 +391,7 @@ public abstract class ServerLevelMixin_Tracker extends LevelMixin_Tracker implem } try (final PhaseContext<@NonNull ?> ignored = contextCreator.apply(mcExplosion) - .source(((Optional) explosion.getSourceExplosive()).orElse(this))) { + .source(((Optional) explosion.sourceExplosive()).orElse(this))) { ignored.buildAndSwitch(); final boolean damagesTerrain = explosion.shouldBreakBlocks(); // Sponge End @@ -808,13 +808,13 @@ public boolean destroyBlock(final BlockPos pos, final boolean doDrops, @Nullable return; } - final Cause currentCause = tracker.getCurrentCause(); + final Cause currentCause = tracker.currentCause(); final SpawnEntityEvent.Pre pre = SpongeEventFactory.createSpawnEntityEventPre( currentCause, Collections.singletonList((org.spongepowered.api.entity.Entity) entityIn) ); - Sponge.getEventManager().post(pre); + Sponge.eventManager().post(pre); if (pre.isCancelled()) { cir.setReturnValue(false); } diff --git a/src/mixins/java/org/spongepowered/common/mixin/tracker/server/level/ServerPlayerGameModeMixin_Tracker.java b/src/mixins/java/org/spongepowered/common/mixin/tracker/server/level/ServerPlayerGameModeMixin_Tracker.java index 7029806381e..1fb759264e3 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/tracker/server/level/ServerPlayerGameModeMixin_Tracker.java +++ b/src/mixins/java/org/spongepowered/common/mixin/tracker/server/level/ServerPlayerGameModeMixin_Tracker.java @@ -99,8 +99,8 @@ public InteractionResult useItemOn(final ServerPlayer playerIn, final Level worl if (event.isCancelled()) { return InteractionResult.FAIL; } - final Tristate useItem = event.getUseItemResult(); - final Tristate useBlock = event.getUseBlockResult(); + final Tristate useItem = event.useItemResult(); + final Tristate useBlock = event.useBlockResult(); // Sponge end if (this.gameModeForPlayer == GameType.SPECTATOR) { final MenuProvider inamedcontainerprovider = blockstate.getMenuProvider(worldIn, blockpos); diff --git a/src/mixins/java/org/spongepowered/common/mixin/tracker/world/entity/player/InventoryMixin_Tracker.java b/src/mixins/java/org/spongepowered/common/mixin/tracker/world/entity/player/InventoryMixin_Tracker.java index 580c0b22c65..624d7eebed5 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/tracker/world/entity/player/InventoryMixin_Tracker.java +++ b/src/mixins/java/org/spongepowered/common/mixin/tracker/world/entity/player/InventoryMixin_Tracker.java @@ -48,10 +48,10 @@ public abstract class InventoryMixin_Tracker implements TrackedInventoryBridge { private Slot impl$getSpongeSlotByIndex(int index) { final int hotbarSize = net.minecraft.world.entity.player.Inventory.getSelectionSize(); if (index < hotbarSize) { - return ((PlayerInventory) this).getPrimary().getHotbar().getSlot(index).get(); + return ((PlayerInventory) this).primary().hotbar().slot(index).get(); } index -= hotbarSize; - return ((PlayerInventory) this).getPrimary().getStorage().getSlot(index).get(); + return ((PlayerInventory) this).primary().storage().slot(index).get(); } @Inject(method = "add(ILnet/minecraft/world/item/ItemStack;)Z", at = @At(value = "INVOKE", target = "Lnet/minecraft/core/NonNullList;set(ILjava/lang/Object;)Ljava/lang/Object;", ordinal = 0)) @@ -68,7 +68,7 @@ public abstract class InventoryMixin_Tracker implements TrackedInventoryBridge { private int impl$ifCaptureDoTransactions(final net.minecraft.world.entity.player.Inventory inv, final int index, final ItemStack stack) { if (this.bridge$capturingInventory()) { // Capture items getting picked up - final Slot slot = index == 40 ? ((PlayerInventory) this).getOffhand() : this.impl$getSpongeSlotByIndex(index); + final Slot slot = index == 40 ? ((PlayerInventory) this).offhand() : this.impl$getSpongeSlotByIndex(index); final ItemStackSnapshot original = ItemStackUtil.snapshotOf(this.shadow$getItem(index)); final int result = this.shadow$addResource(index, stack); final ItemStackSnapshot replacement = ItemStackUtil.snapshotOf(this.shadow$getItem(index)); diff --git a/src/mixins/java/org/spongepowered/common/mixin/tracker/world/level/ExplosionMixin_Tracker.java b/src/mixins/java/org/spongepowered/common/mixin/tracker/world/level/ExplosionMixin_Tracker.java index 941eb236ed2..08a0df91b41 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/tracker/world/level/ExplosionMixin_Tracker.java +++ b/src/mixins/java/org/spongepowered/common/mixin/tracker/world/level/ExplosionMixin_Tracker.java @@ -139,7 +139,7 @@ public void finalizeExplosion(final boolean spawnParticles) { // }); // } - //this.world.setBlock(blockpos, Blocks.AIR.getDefaultState(), 3); + //this.world.setBlock(blockpos, Blocks.AIR.defaultState(), 3); //block.onExplosionDestroy(this.world, blockpos, this); final PhaseContext<@NonNull ?> context = PhaseTracker.getInstance().getPhaseContext(); @@ -162,7 +162,7 @@ public void finalizeExplosion(final boolean spawnParticles) { } // Sponge Start - This is built into the SpawnDestructBlocksEffect // for(Pair pair : objectarraylist) { - // Block.spawnAsEntity(this.world, pair.getSecond(), pair.getFirst()); + // Block.spawnAsEntity(this.world, pair.second(), pair.first()); // } // Sponge End } diff --git a/src/mixins/java/org/spongepowered/common/mixin/tracker/world/level/block/DispenserBlockMixin_Tracker.java b/src/mixins/java/org/spongepowered/common/mixin/tracker/world/level/block/DispenserBlockMixin_Tracker.java index 12b3971fa39..11fc453b1a1 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/tracker/world/level/block/DispenserBlockMixin_Tracker.java +++ b/src/mixins/java/org/spongepowered/common/mixin/tracker/world/level/block/DispenserBlockMixin_Tracker.java @@ -114,7 +114,7 @@ public class DispenserBlockMixin_Tracker { original.add(snapshot); try (final CauseStackManager.StackFrame frame = PhaseTracker.getCauseStackManager().pushCauseFrame()) { frame.pushCause(dispenserTileEntity); - final DropItemEvent.Pre dropEvent = SpongeEventFactory.createDropItemEventPre(frame.getCurrentCause(), ImmutableList.of(snapshot), original); + final DropItemEvent.Pre dropEvent = SpongeEventFactory.createDropItemEventPre(frame.currentCause(), ImmutableList.of(snapshot), original); SpongeCommon.postEvent(dropEvent); if (dropEvent.isCancelled()) { dispenserTileEntity.setItem(index, this.tracker$originalItem); diff --git a/src/mixins/java/org/spongepowered/common/mixin/tracker/world/level/chunk/LevelChunkMixin_Tracker.java b/src/mixins/java/org/spongepowered/common/mixin/tracker/world/level/chunk/LevelChunkMixin_Tracker.java index 1df5512dd14..686cf473128 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/tracker/world/level/chunk/LevelChunkMixin_Tracker.java +++ b/src/mixins/java/org/spongepowered/common/mixin/tracker/world/level/chunk/LevelChunkMixin_Tracker.java @@ -161,7 +161,7 @@ public abstract class LevelChunkMixin_Tracker implements TrackedLevelChunkBridge snapshot, currentBlock ); - if (((BlockStateBridge) snapshot.getState()).bridge$hasTileEntity() + if (((BlockStateBridge) snapshot.state()).bridge$hasTileEntity() && (snapshot.blockChange == BlockChange.BREAK || snapshot.blockChange == BlockChange.MODIFY)) { transaction.queuedRemoval = existing; } diff --git a/src/test/java/org/spongepowered/common/data/persistence/SimpleData.java b/src/test/java/org/spongepowered/common/data/persistence/SimpleData.java index 892ba285fa6..bf78656822b 100644 --- a/src/test/java/org/spongepowered/common/data/persistence/SimpleData.java +++ b/src/test/java/org/spongepowered/common/data/persistence/SimpleData.java @@ -64,7 +64,7 @@ public List getTestList() { } @Override - public int getContentVersion() { + public int contentVersion() { return 1; } diff --git a/src/test/java/org/spongepowered/common/util/ReflectionTest.java b/src/test/java/org/spongepowered/common/util/ReflectionTest.java index 54f54cafe7d..d91a564b611 100644 --- a/src/test/java/org/spongepowered/common/util/ReflectionTest.java +++ b/src/test/java/org/spongepowered/common/util/ReflectionTest.java @@ -108,7 +108,7 @@ public void testImmutableValueCache() { }; @Override - public String getId() { + public String id() { return "test"; } @@ -118,12 +118,12 @@ public String getName() { } @Override - public Type getValueType() { + public Type valueType() { return this.token; } @Override - public Type getElementType() { + public Type elementType() { return Double.class; } diff --git a/src/test/java/org/spongepowered/common/util/SpongeAABBTest.java b/src/test/java/org/spongepowered/common/util/SpongeAABBTest.java index e2e029b47e0..3b09d5db286 100644 --- a/src/test/java/org/spongepowered/common/util/SpongeAABBTest.java +++ b/src/test/java/org/spongepowered/common/util/SpongeAABBTest.java @@ -38,12 +38,12 @@ final class SpongeAABBTest { @Test void testConstructor() { final AABB aabb1 = new SpongeAABB(new Vector3d(1, 2, 3), new Vector3d(7, 10, 13)); - Assertions.assertEquals(new Vector3d(1, 2, 3), aabb1.getMin()); - Assertions.assertEquals(new Vector3d(7, 10, 13), aabb1.getMax()); + Assertions.assertEquals(new Vector3d(1, 2, 3), aabb1.min()); + Assertions.assertEquals(new Vector3d(7, 10, 13), aabb1.max()); final AABB aabb2 = new SpongeAABB(new Vector3d(11, 2, 3), new Vector3d(7, -10, 13)); - Assertions.assertEquals(new Vector3d(7, -10, 3), aabb2.getMin()); - Assertions.assertEquals(new Vector3d(11, 2, 13), aabb2.getMax()); + Assertions.assertEquals(new Vector3d(7, -10, 3), aabb2.min()); + Assertions.assertEquals(new Vector3d(11, 2, 13), aabb2.max()); try { new SpongeAABB(new Vector3d(1, 2, 3), new Vector3d(1, 10, 13)); @@ -70,13 +70,13 @@ void testConstructor() { @Test void testSize() { final AABB aabb = new SpongeAABB(new Vector3d(1, 2, 3), new Vector3d(7, 10, 13)); - Assertions.assertEquals(new Vector3d(6, 8, 10), aabb.getSize()); + Assertions.assertEquals(new Vector3d(6, 8, 10), aabb.size()); } @Test void testCenter() { final AABB aabb = new SpongeAABB(new Vector3d(1, 2, 3), new Vector3d(7, 10, 13)); - Assertions.assertEquals(new Vector3d(4, 6, 8), aabb.getCenter()); + Assertions.assertEquals(new Vector3d(4, 6, 8), aabb.center()); } @Test @@ -114,7 +114,7 @@ void testIntersectsAABB() { for (int i = 0; i < 1000; i++) { final AABB aabb1 = newAABB(); final AABB aabb2 = newIntersectingAABB(aabb1); - final AABB aabb3 = aabb2.offset(aabb1.getSize().add(aabb2.getSize())); + final AABB aabb3 = aabb2.offset(aabb1.size().add(aabb2.size())); Assertions.assertTrue(aabb1.intersects(aabb2)); Assertions.assertTrue(aabb2.intersects(aabb1)); Assertions.assertFalse(aabb1.intersects(aabb3)); @@ -198,8 +198,8 @@ private static AABB newAABB() { } private static AABB newIntersectingAABB(AABB with) { - final Vector3d wMin = with.getMin(); - final Vector3d wSize = with.getSize(); + final Vector3d wMin = with.min(); + final Vector3d wSize = with.size(); final double iSizeX = RANDOM.nextDouble() * wSize.getX(); final double iSizeY = RANDOM.nextDouble() * wSize.getY(); final double iSizeZ = RANDOM.nextDouble() * wSize.getZ(); diff --git a/testplugins/src/main/java/org/spongepowered/test/LoadableModule.java b/testplugins/src/main/java/org/spongepowered/test/LoadableModule.java index 8bdccdb16dd..e7db32bf5b3 100644 --- a/testplugins/src/main/java/org/spongepowered/test/LoadableModule.java +++ b/testplugins/src/main/java/org/spongepowered/test/LoadableModule.java @@ -30,7 +30,7 @@ public interface LoadableModule { default void disable(final CommandContext ctx) { - Sponge.getEventManager().unregisterPluginListeners(Sponge.getPluginManager().fromInstance(this).get()); + Sponge.eventManager().unregisterPluginListeners(Sponge.pluginManager().fromInstance(this).get()); } void enable(CommandContext ctx); diff --git a/testplugins/src/main/java/org/spongepowered/test/TestPlugin.java b/testplugins/src/main/java/org/spongepowered/test/TestPlugin.java index 91dba53d0c1..5877bda46a3 100644 --- a/testplugins/src/main/java/org/spongepowered/test/TestPlugin.java +++ b/testplugins/src/main/java/org/spongepowered/test/TestPlugin.java @@ -53,13 +53,13 @@ public TestPlugin(final PluginContainer plugin) { @Listener public void onRegisterCommand(final RegisterCommandEvent event) { - final Parameter.Value pluginKey = Parameter.plugin().setKey("plugin").setSuggestions( - (context, currentInput) -> Sponge.getPluginManager().getPlugins().stream() + final Parameter.Value pluginKey = Parameter.plugin().key("plugin").suggestions( + (context, currentInput) -> Sponge.pluginManager().plugins().stream() .filter(pc -> pc.getInstance() instanceof LoadableModule) .filter(x -> x.getMetadata().getId().startsWith(currentInput)) .map(x -> x.getMetadata().getId()).collect(Collectors.toList())).build(); - final Command.Parameterized enableCommand = Command.builder().parameter(pluginKey) - .setExecutor(context -> { + final Command.Parameterized enableCommand = Command.builder().addParameter(pluginKey) + .executor(context -> { final PluginContainer pc = context.requireOne(pluginKey); if (pc.getInstance() instanceof LoadableModule) { if (this.enabledPlugins.add(pc.getMetadata().getId())) { @@ -71,8 +71,8 @@ public void onRegisterCommand(final RegisterCommandEvent } return CommandResult.success(); }).build(); - final Command.Parameterized disableCommand = Command.builder().parameter(pluginKey) - .setExecutor(context -> { + final Command.Parameterized disableCommand = Command.builder().addParameter(pluginKey) + .executor(context -> { final PluginContainer pc = context.requireOne(pluginKey); if (pc.getInstance() instanceof LoadableModule) { if (this.enabledPlugins.remove(pc.getMetadata().getId())) { @@ -84,8 +84,8 @@ public void onRegisterCommand(final RegisterCommandEvent } return CommandResult.success(); }).build(); - final Command.Parameterized toggleCommand = Command.builder().parameter(pluginKey) - .setExecutor(context -> { + final Command.Parameterized toggleCommand = Command.builder().addParameter(pluginKey) + .executor(context -> { final PluginContainer pc = context.requireOne(pluginKey); if (pc.getInstance() instanceof LoadableModule) { if (this.enabledPlugins.contains(pc.getMetadata().getId())) { @@ -102,11 +102,11 @@ public void onRegisterCommand(final RegisterCommandEvent }).build(); final Command.Parameterized testPluginCommand = Command.builder() - .child(enableCommand, "enable") - .child(disableCommand, "disable") - .child(toggleCommand, "toggle") - .parameter(pluginKey) - .setExecutor(toggleCommand.getExecutor().get()) + .addChild(enableCommand, "enable") + .addChild(disableCommand, "disable") + .addChild(toggleCommand, "toggle") + .addParameter(pluginKey) + .executor(toggleCommand.executor().get()) .build(); event.register(this.plugin, testPluginCommand, "testplugins"); } diff --git a/testplugins/src/main/java/org/spongepowered/test/advancement/AdvancementTest.java b/testplugins/src/main/java/org/spongepowered/test/advancement/AdvancementTest.java index b92d88c56f4..16d22e228ac 100644 --- a/testplugins/src/main/java/org/spongepowered/test/advancement/AdvancementTest.java +++ b/testplugins/src/main/java/org/spongepowered/test/advancement/AdvancementTest.java @@ -59,7 +59,6 @@ import org.spongepowered.api.event.item.inventory.ChangeInventoryEvent; import org.spongepowered.api.event.item.inventory.container.InteractContainerEvent; import org.spongepowered.api.event.lifecycle.RegisterDataPackValueEvent; -import org.spongepowered.api.event.lifecycle.RegisterRegistryEvent; import org.spongepowered.api.event.lifecycle.RegisterRegistryValueEvent; import org.spongepowered.api.item.ItemTypes; import org.spongepowered.api.item.inventory.BlockCarrier; @@ -91,21 +90,21 @@ public final class AdvancementTest implements LoadableModule { @Override public void enable(final CommandContext ctx) { this.enabled = true; - Sponge.getEventManager().registerListeners(this.plugin, this.listeners); + Sponge.eventManager().registerListeners(this.plugin, this.listeners); try { - Sponge.getServer().getCommandManager().process("reload"); + Sponge.server().commandManager().process("reload"); } catch (final CommandException e) { e.printStackTrace(); } - ctx.getCause().first(ServerPlayer.class).map(player -> player.getProgress(this.rootAdvancement).grant()); + ctx.cause().first(ServerPlayer.class).map(player -> player.progress(this.rootAdvancement).grant()); } @Override public void disable(final CommandContext ctx) { this.enabled = false; - Sponge.getEventManager().unregisterListeners(this.listeners); + Sponge.eventManager().unregisterListeners(this.listeners); try { - Sponge.getServer().getCommandManager().process("reload"); + Sponge.server().commandManager().process("reload"); } catch (final CommandException e) { e.printStackTrace(); } @@ -113,39 +112,39 @@ public void disable(final CommandContext ctx) { @Listener public void onTreeAdjust(final AdvancementTreeEvent.GenerateLayout event) { - final AdvancementTree tree = event.getTree(); + final AdvancementTree tree = event.tree(); if (tree.equals(this.rootAdvancement)) { - final TreeLayoutElement layoutElement1 = event.getLayout().getElement(this.counterAdvancement1).get(); - final TreeLayoutElement layoutElement2 = event.getLayout().getElement(this.counterAdvancement2).get(); - layoutElement1.setPosition(layoutElement2.getPosition()); - layoutElement2.setPosition(layoutElement2.getPosition().add(-1,2)); + final TreeLayoutElement layoutElement1 = event.layout().element(this.counterAdvancement1).get(); + final TreeLayoutElement layoutElement2 = event.layout().element(this.counterAdvancement2).get(); + layoutElement1.setPosition(layoutElement2.position()); + layoutElement2.setPosition(layoutElement2.position().add(-1,2)); } } @Listener public void onGranted(final AdvancementEvent.Grant event) { - this.logger.info("{} was granted", event.getAdvancement().getKey()); + this.logger.info("{} was granted", event.advancement().key()); } @Listener public void onGranted(final AdvancementEvent.Revoke event) { - this.logger.info("{} was revoked", event.getAdvancement().getKey()); + this.logger.info("{} was revoked", event.advancement().key()); } @Listener public void onTrigger(final CriterionEvent.Trigger event) { - this.logger.info("{} for {} was triggered", event.getTrigger().getType().getKey(), event.getAdvancement().getKey()); + this.logger.info("{} for {} was triggered", event.trigger().type().key(), event.advancement().key()); } @Listener public void onTriggerRegistry(final RegisterRegistryValueEvent.GameScoped event) { - Sponge.getDataManager().registerBuilder(InventoryChangeTriggerConfig.class, new InventoryChangeTriggerConfig.Builder()); + Sponge.dataManager().registerBuilder(InventoryChangeTriggerConfig.class, new InventoryChangeTriggerConfig.Builder()); this.inventoryChangeTrigger = Trigger.builder() .dataSerializableConfig(InventoryChangeTriggerConfig.class) .listener(triggerEvent -> { - final ItemStack stack = triggerEvent.getTrigger().getConfiguration().stack; - final int found = triggerEvent.getPlayer().getInventory().query(QueryTypes.ITEM_STACK_IGNORE_QUANTITY, stack).totalQuantity(); - triggerEvent.setResult(stack.getQuantity() <= found); + final ItemStack stack = triggerEvent.trigger().configuration().stack; + final int found = triggerEvent.player().inventory().query(QueryTypes.ITEM_STACK_IGNORE_QUANTITY, stack).totalQuantity(); + triggerEvent.setResult(stack.quantity() <= found); }) .key(ResourceKey.of(this.plugin, "my_inventory_trigger")) .name("my_inventory_trigger") @@ -289,16 +288,16 @@ public void onContainerEvent(final ChangeInventoryEvent event, @First final Serv @Listener public void onConainterEvent(final InteractContainerEvent.Open event, @First final ServerPlayer player) { - final AdvancementProgress progress1 = player.getProgress(AdvancementTest.this.counterAdvancement1); + final AdvancementProgress progress1 = player.progress(AdvancementTest.this.counterAdvancement1); if (progress1.achieved()) { - final AdvancementProgress progress2 = player.getProgress(AdvancementTest.this.counterAdvancement2); + final AdvancementProgress progress2 = player.progress(AdvancementTest.this.counterAdvancement2); progress2.require(AdvancementTest.this.counter2).add(1); } else { progress1.require(AdvancementTest.this.counter1).add(1); - final Object carrier = ((CarriedInventory) event.getContainer()).getCarrier().orElse(null); + final Object carrier = ((CarriedInventory) event.container()).carrier().orElse(null); if (carrier instanceof BlockCarrier) { - if (((BlockCarrier) carrier).getLocation().getBlockType().isAnyOf(BlockTypes.TRAPPED_CHEST)) { + if (((BlockCarrier) carrier).location().blockType().isAnyOf(BlockTypes.TRAPPED_CHEST)) { progress1.require(AdvancementTest.this.counter1Bypass).grant(); } } @@ -319,7 +318,7 @@ public InventoryChangeTriggerConfig(final DataView stack) { } @Override - public int getContentVersion() { + public int contentVersion() { return 1; } diff --git a/testplugins/src/main/java/org/spongepowered/test/archetype/ArchetypeTest.java b/testplugins/src/main/java/org/spongepowered/test/archetype/ArchetypeTest.java index 128242075cf..62061060f2f 100644 --- a/testplugins/src/main/java/org/spongepowered/test/archetype/ArchetypeTest.java +++ b/testplugins/src/main/java/org/spongepowered/test/archetype/ArchetypeTest.java @@ -58,13 +58,13 @@ public ArchetypeTest(final PluginContainer plugin) { @Listener public void registerCommands(final RegisterCommandEvent event) { event.register(this.plugin, Command.builder() - .child(Command.builder().setExecutor(this::testEntityArchetype).build(), "entity") + .addChild(Command.builder().executor(this::testEntityArchetype).build(), "entity") .build(), "testarchetypes"); } private CommandResult testEntityArchetype(CommandContext context) { - context.getCause().first(ServerPlayer.class).ifPresent(p -> { - final Sheep entity = p.getWorld().createEntity(EntityTypes.SHEEP, p.getPosition()); + context.cause().first(ServerPlayer.class).ifPresent(p -> { + final Sheep entity = p.world().createEntity(EntityTypes.SHEEP, p.position()); this.testEntityArchetype(entity); }); return CommandResult.success(); @@ -72,7 +72,7 @@ private CommandResult testEntityArchetype(CommandContext context) { @Override public void enable(CommandContext ctx) { - Sponge.getEventManager().registerListeners(this.plugin, new ArchetypeTestListener()); + Sponge.eventManager().registerListeners(this.plugin, new ArchetypeTestListener()); } @@ -80,23 +80,23 @@ public class ArchetypeTestListener { // TODO we're missing InteractEntityEvent implementation so we cannot test with this yet @Listener public void onRightClickEntity(InteractEntityEvent.Secondary event) { - final Entity entity = event.getEntity(); + final Entity entity = event.entity(); ArchetypeTest.this.testEntityArchetype(entity); } } public void testEntityArchetype(Entity entity) { - Sponge.getServer().getCauseStackManager().addContext(EventContextKeys.SPAWN_TYPE, SpawnTypes.PLUGIN); // Need that for restoring + Sponge.server().causeStackManager().addContext(EventContextKeys.SPAWN_TYPE, SpawnTypes.PLUGIN); // Need that for restoring final EntityArchetype archetype = entity.createArchetype(); // Restore same entity from archetype - archetype.apply(entity.getServerLocation()); + archetype.apply(entity.serverLocation()); // Test restoring from serialized archetype final EntityArchetype rebuiltArchetype = EntityArchetype.builder().build(archetype.toContainer()).get(); - rebuiltArchetype.apply(entity.getServerLocation()); + rebuiltArchetype.apply(entity.serverLocation()); - final EntitySnapshot rebuiltSnapshot = rebuiltArchetype.toSnapshot(entity.getServerLocation()); + final EntitySnapshot rebuiltSnapshot = rebuiltArchetype.toSnapshot(entity.serverLocation()); rebuiltSnapshot.restore(); } } diff --git a/testplugins/src/main/java/org/spongepowered/test/changeblock/ChangeBlockTest.java b/testplugins/src/main/java/org/spongepowered/test/changeblock/ChangeBlockTest.java index cced0b5f77f..ea331277b0c 100644 --- a/testplugins/src/main/java/org/spongepowered/test/changeblock/ChangeBlockTest.java +++ b/testplugins/src/main/java/org/spongepowered/test/changeblock/ChangeBlockTest.java @@ -71,16 +71,16 @@ public ChangeBlockTest(final PluginContainer plugin) { @Override public void enable(final CommandContext ctx) { - Sponge.getEventManager().registerListeners(this.plugin, new ChangeBlockListener()); - Sponge.getEventManager().registerListeners(this.plugin, new HarvestEntityListener()); - Sponge.getEventManager().registerListeners(this.plugin, new SpawnEntityListener()); - Sponge.getEventManager().registerListeners(this.plugin, new EntityDeathPrinter()); + Sponge.eventManager().registerListeners(this.plugin, new ChangeBlockListener()); + Sponge.eventManager().registerListeners(this.plugin, new HarvestEntityListener()); + Sponge.eventManager().registerListeners(this.plugin, new SpawnEntityListener()); + Sponge.eventManager().registerListeners(this.plugin, new EntityDeathPrinter()); } @Listener public void registerCommands(final RegisterCommandEvent event) { event.register(this.plugin, Command.builder() - .setExecutor(context -> { + .executor(context -> { this.cancelAll = !this.cancelAll; final Component newState = Component.text(this.cancelAll ? "OFF" : "ON", this.cancelAll ? NamedTextColor.GREEN : NamedTextColor.RED); context.sendMessage(Identity.nil(), Component.text("Turning Block Changes: ").append(newState)); @@ -89,7 +89,7 @@ public void registerCommands(final RegisterCommandEvent e .build(), "toggleBlockChanges" ); event.register(this.plugin, Command.builder() - .setExecutor(context -> { + .executor(context -> { this.waterProofRedstone = !this.waterProofRedstone; final Component newState = Component.text(this.waterProofRedstone ? "ON" : "OFF", this.waterProofRedstone ? NamedTextColor.GREEN : NamedTextColor.RED); context.sendMessage(Identity.nil(), Component.text("Waterproof Redstone : ").append(newState)); @@ -98,7 +98,7 @@ public void registerCommands(final RegisterCommandEvent e .build(), "toggleRedstoneWaterProofing" ); event.register(this.plugin, Command.builder() - .setExecutor(context -> { + .executor(context -> { this.printEntityHarvests = !this.printEntityHarvests; final Component newState = Component.text(this.printEntityHarvests ? "ON" : "OFF", this.printEntityHarvests ? NamedTextColor.GREEN : NamedTextColor.RED); context.sendMessage(Identity.nil(), Component.text("Logging Entity Harvests : ").append(newState)); @@ -107,7 +107,7 @@ public void registerCommands(final RegisterCommandEvent e .build(), "toggleEntityHarvestPrinting" ); event.register(this.plugin, Command.builder() - .setExecutor(context -> { + .executor(context -> { this.printEntityDeaths = !this.printEntityDeaths; final Component newState = Component.text(this.printEntityDeaths ? "ON" : "OFF", this.printEntityDeaths ? NamedTextColor.GREEN : NamedTextColor.RED); context.sendMessage(Identity.nil(), Component.text("Logging Entity Harvests : ").append(newState)); @@ -116,7 +116,7 @@ public void registerCommands(final RegisterCommandEvent e .build(), "toggleEntityDeathPrinting" ); event.register(this.plugin, Command.builder() - .setExecutor(context -> { + .executor(context -> { this.printEntitySpawns = !this.printEntitySpawns; final Component newState = Component.text(this.printEntitySpawns ? "ON" : "OFF", this.printEntitySpawns ? NamedTextColor.GREEN : NamedTextColor.RED); context.sendMessage(Identity.nil(), Component.text("Logging Entity Spawns : ").append(newState)); @@ -138,7 +138,7 @@ public void onEntityHarvest(final HarvestEntityEvent event) { pluginLogger.log(Level.INFO, ChangeBlockTest.marker, "/* HarvestEntityEvent"); pluginLogger.log(Level.INFO, ChangeBlockTest.marker, "/"); pluginLogger.log(Level.INFO, ChangeBlockTest.marker, "/ Cause:"); - for (final Object o : event.getCause()) { + for (final Object o : event.cause()) { pluginLogger.log(Level.INFO, ChangeBlockTest.marker, "/ - " + o); } pluginLogger.log(Level.INFO, ChangeBlockTest.marker, "/"); @@ -156,7 +156,7 @@ public void onEntitySpawn(final SpawnEntityEvent event) { pluginLogger.log(Level.INFO, ChangeBlockTest.marker, "/* SpawnEntityEvent"); pluginLogger.log(Level.INFO, ChangeBlockTest.marker, "/"); pluginLogger.log(Level.INFO, ChangeBlockTest.marker, "/ Cause:"); - for (final Object o : event.getCause()) { + for (final Object o : event.cause()) { pluginLogger.log(Level.INFO, ChangeBlockTest.marker, "/ - " + o); } pluginLogger.log(Level.INFO, ChangeBlockTest.marker, "/"); @@ -174,7 +174,7 @@ public void onEntitySpawn(final DestructEntityEvent.Death event) { pluginLogger.log(Level.INFO, ChangeBlockTest.marker, "/* DestructEntityEvent.Death"); pluginLogger.log(Level.INFO, ChangeBlockTest.marker, "/"); pluginLogger.log(Level.INFO, ChangeBlockTest.marker, "/ Cause:"); - for (final Object o : event.getCause()) { + for (final Object o : event.cause()) { pluginLogger.log(Level.INFO, ChangeBlockTest.marker, "/ - " + o); } pluginLogger.log(Level.INFO, ChangeBlockTest.marker, "/"); @@ -189,13 +189,13 @@ public void onChangeBlock(final ChangeBlockEvent.All post) { pluginLogger.log(Level.INFO, ChangeBlockTest.marker, "/* ChangeBlockEvent"); pluginLogger.log(Level.INFO, ChangeBlockTest.marker, "/"); pluginLogger.log(Level.INFO, ChangeBlockTest.marker, "/ Cause:"); - for (final Object o : post.getCause()) { + for (final Object o : post.cause()) { pluginLogger.log(Level.INFO, ChangeBlockTest.marker, "/ - " + o); } pluginLogger.log(Level.INFO, ChangeBlockTest.marker, "/"); - if (post.getCause().root() instanceof LocatableBlock) { + if (post.cause().root() instanceof LocatableBlock) { // Leaves are the bane of all existence... they just spam so many events.... - final BlockType type = ((LocatableBlock) post.getCause().root()).getBlockState().getType(); + final BlockType type = ((LocatableBlock) post.cause().root()).blockState().type(); if (type == BlockTypes.ACACIA_LEAVES.get() || type == BlockTypes.BIRCH_LEAVES.get() || type == BlockTypes.OAK_LEAVES.get() @@ -209,9 +209,9 @@ public void onChangeBlock(final ChangeBlockEvent.All post) { post.setCancelled(true); } if (ChangeBlockTest.this.waterProofRedstone) { - for (final BlockTransaction transaction : post.getTransactions()) { - final boolean wasRedstone = transaction.getOriginal().getState().getType() == BlockTypes.REDSTONE_WIRE.get(); - final boolean becomesLiquid = transaction.getFinal().getState().get(Keys.MATTER_TYPE).get() == MatterTypes.LIQUID.get(); + for (final BlockTransaction transaction : post.transactions()) { + final boolean wasRedstone = transaction.original().state().type() == BlockTypes.REDSTONE_WIRE.get(); + final boolean becomesLiquid = transaction.finalReplacement().state().get(Keys.MATTER_TYPE).get() == MatterTypes.LIQUID.get(); if (wasRedstone && becomesLiquid) { post.setCancelled(true); return; diff --git a/testplugins/src/main/java/org/spongepowered/test/channel/ChannelTest.java b/testplugins/src/main/java/org/spongepowered/test/channel/ChannelTest.java index 9b62b2bbd80..e6033672f24 100644 --- a/testplugins/src/main/java/org/spongepowered/test/channel/ChannelTest.java +++ b/testplugins/src/main/java/org/spongepowered/test/channel/ChannelTest.java @@ -99,7 +99,7 @@ public void onRegisterChannel(final RegisterChannelEvent event) { public void onConnectionHandshake(final ServerSideConnectionEvent.Handshake event) { this.plugin.getLogger().info("Starting handshake phase."); final PingPacket pingPacket1 = new PingPacket(123); - final ServerSideConnection connection = event.getConnection(); + final ServerSideConnection connection = event.connection(); this.channel.sendTo(connection, pingPacket1) .thenAccept(response1 -> { this.logReceived(this.channel, response1, connection); @@ -165,14 +165,14 @@ public void onConnectionHandshake(final ServerSideConnectionEvent.Handshake even @Listener public void onConnectionLogin(final ServerSideConnectionEvent.Login event) { - this.plugin.getLogger().info("Player \"" + event.getProfile().getName().orElse("unknown") + "\" is logging in."); + this.plugin.getLogger().info("Player \"" + event.profile().name().orElse("unknown") + "\" is logging in."); } @Listener public void onConnectionJoin(final ServerSideConnectionEvent.Join event) { - this.plugin.getLogger().info("Player \"" + event.getPlayer().getName() + "\" joined."); + this.plugin.getLogger().info("Player \"" + event.player().name() + "\" joined."); - final ServerSideConnection connection = event.getConnection(); + final ServerSideConnection connection = event.connection(); final PingPacket pingPacket1 = new PingPacket(789); this.channel.sendTo(connection, pingPacket1) .thenAccept(response1 -> this.logReceived(this.channel, response1, connection)) @@ -193,6 +193,6 @@ private static String getName(final EngineConnectionSide side) { } private void logReceived(final Channel channel, final Object packet, final EngineConnection connection) { - this.plugin.getLogger().info("Received {} through {} on the {} side.", packet, channel.getKey(), ChannelTest.getName(connection.getSide())); + this.plugin.getLogger().info("Received {} through {} on the {} side.", packet, channel.key(), ChannelTest.getName(connection.side())); } } diff --git a/testplugins/src/main/java/org/spongepowered/test/chat/ChatTest.java b/testplugins/src/main/java/org/spongepowered/test/chat/ChatTest.java index 21ede19d9c6..a2337e5ee12 100644 --- a/testplugins/src/main/java/org/spongepowered/test/chat/ChatTest.java +++ b/testplugins/src/main/java/org/spongepowered/test/chat/ChatTest.java @@ -93,19 +93,19 @@ public void constructed(final ConstructPluginEvent event) { @Override public void enable(final CommandContext ctx) { - this.game.getEventManager().registerListeners(this.container, new Listeners()); + this.game.eventManager().registerListeners(this.container, new Listeners()); } @Listener public void registerCommands(final RegisterCommandEvent event) { // /togglebossbar event.register(this.container, Command.builder() - .setPermission("chattest.togglebossbar") - .setExecutor(ctx -> { + .permission("chattest.togglebossbar") + .executor(ctx -> { if (this.barVisible) { - this.game.getServer().hideBossBar(ChatTest.INFO_BAR); + this.game.server().hideBossBar(ChatTest.INFO_BAR); } else { - this.game.getServer().showBossBar(ChatTest.INFO_BAR); + this.game.server().showBossBar(ChatTest.INFO_BAR); } this.barVisible = !this.barVisible; return CommandResult.success(); @@ -113,9 +113,9 @@ public void registerCommands(final RegisterCommandEvent e .build(), "togglebossbar"); event.register(this.container, Command.builder() - .setPermission("chattest.sendbook") - .setExecutor(ctx -> { - ctx.getCause().getAudience().openBook(Book.builder() + .permission("chattest.sendbook") + .executor(ctx -> { + ctx.cause().audience().openBook(Book.builder() .title(Component.text("A story")) .author(Component.text("You")) .pages(Component.translatable("chattest.book.1"), @@ -123,17 +123,17 @@ public void registerCommands(final RegisterCommandEvent e return CommandResult.success(); }).build(), "sendbook"); - final Parameter.Value targetArg = Parameter.player().setKey("target").build(); - final Parameter.Value messageArg = Parameter.jsonText().setKey("message").build(); + final Parameter.Value targetArg = Parameter.player().key("target").build(); + final Parameter.Value messageArg = Parameter.jsonText().key("message").build(); event.register(this.container, Command.builder() - .setPermission("chatttest.tell-resolve") - .parameters(targetArg, messageArg) - .setExecutor(ctx -> { + .permission("chatttest.tell-resolve") + .addParameters(targetArg, messageArg) + .executor(ctx -> { final ServerPlayer target = ctx.requireOne(targetArg); final Component message = ctx.requireOne(messageArg); - final Component resolvedMessage = SpongeComponents.resolve(message, ctx.getCause(), target, ResolveOperations.CONTEXTUAL_COMPONENTS); - target.sendMessage(ctx.getCause().first(Identified.class).map(Identified::identity).orElse(Identity.nil()), resolvedMessage); + final Component resolvedMessage = SpongeComponents.resolve(message, ctx.cause(), target, ResolveOperations.CONTEXTUAL_COMPONENTS); + target.sendMessage(ctx.cause().first(Identified.class).map(Identified::identity).orElse(Identity.nil()), resolvedMessage); return CommandResult.success(); }) .build(), "tellresolve"); @@ -143,13 +143,13 @@ public static class Listeners { @Listener public void onLogin(final ServerSideConnectionEvent.Join event) { - event.getPlayer().sendMessage(Component.translatable("chattest.response")); + event.player().sendMessage(Component.translatable("chattest.response")); } @Listener(order = Order.LAST) public void onChat(final PlayerChatEvent event, final @Root ServerPlayer player) { ChatTest.LOGGER.info(Component.translatable("chattest.response.chat", - event.getMessage(), + event.message(), player.require(Keys.DISPLAY_NAME) .decorate(TextDecoration.BOLD) .colorIfAbsent(NamedTextColor.AQUA)) diff --git a/testplugins/src/main/java/org/spongepowered/test/chunk/ChunkEventTest.java b/testplugins/src/main/java/org/spongepowered/test/chunk/ChunkEventTest.java index e4e482ea712..e8dd2ceac12 100644 --- a/testplugins/src/main/java/org/spongepowered/test/chunk/ChunkEventTest.java +++ b/testplugins/src/main/java/org/spongepowered/test/chunk/ChunkEventTest.java @@ -25,17 +25,11 @@ package org.spongepowered.test.chunk; import com.google.inject.Inject; -import net.kyori.adventure.identity.Identity; import net.kyori.adventure.text.Component; import org.spongepowered.api.Sponge; import org.spongepowered.api.command.parameter.CommandContext; -import org.spongepowered.api.event.EventContextKeys; import org.spongepowered.api.event.Listener; -import org.spongepowered.api.event.block.InteractBlockEvent; -import org.spongepowered.api.event.entity.InteractEntityEvent; -import org.spongepowered.api.event.item.inventory.InteractItemEvent; import org.spongepowered.api.event.world.chunk.ChunkEvent; -import org.spongepowered.api.registry.RegistryTypes; import org.spongepowered.plugin.PluginContainer; import org.spongepowered.plugin.jvm.Plugin; import org.spongepowered.test.LoadableModule; @@ -52,30 +46,30 @@ public ChunkEventTest(final PluginContainer plugin) { @Override public void enable(final CommandContext ctx) { - Sponge.getEventManager().registerListeners(this.plugin, new ChunkListener()); + Sponge.eventManager().registerListeners(this.plugin, new ChunkListener()); } public static class ChunkListener { @Listener public void onChunkLoad(ChunkEvent.Load event) { - Sponge.getGame().getSystemSubject().sendMessage(Component.text("Load Chunk " + event.getTargetChunk().getChunkPosition() + " in " + event.getChunkWorld().asString())); + Sponge.game().systemSubject().sendMessage(Component.text("Load Chunk " + event.targetChunk().chunkPosition() + " in " + event.chunkWorld().asString())); } @Listener public void onChunkSave(ChunkEvent.Save.Pre event) { event.setCancelled(true); - Sponge.getGame().getSystemSubject().sendMessage(Component.text("Pre Save Chunk " + event.getChunkPosition() + " in " + event.getChunkWorld().asString())); + Sponge.game().systemSubject().sendMessage(Component.text("Pre Save Chunk " + event.chunkPosition() + " in " + event.chunkWorld().asString())); } @Listener public void onChunkSave(ChunkEvent.Save.Post event) { - Sponge.getGame().getSystemSubject().sendMessage(Component.text("Post Save Chunk " + event.getChunkPosition() + " in " + event.getChunkWorld().asString())); + Sponge.game().systemSubject().sendMessage(Component.text("Post Save Chunk " + event.chunkPosition() + " in " + event.chunkWorld().asString())); } @Listener public void onChunkUnload(ChunkEvent.Unload event) { - Sponge.getGame().getSystemSubject().sendMessage(Component.text("Unload Chunk " + event.getChunkPosition() + " in " + event.getChunkWorld().asString())); + Sponge.game().systemSubject().sendMessage(Component.text("Unload Chunk " + event.chunkPosition() + " in " + event.chunkWorld().asString())); } } } diff --git a/testplugins/src/main/java/org/spongepowered/test/command/CommandTest.java b/testplugins/src/main/java/org/spongepowered/test/command/CommandTest.java index 9ab430d6e3d..696c72e6bbb 100644 --- a/testplugins/src/main/java/org/spongepowered/test/command/CommandTest.java +++ b/testplugins/src/main/java/org/spongepowered/test/command/CommandTest.java @@ -82,42 +82,42 @@ public CommandTest(final PluginContainer plugin, final Logger logger) { @Listener public void onRegisterSpongeCommand(final RegisterCommandEvent event) { - final Parameter.Value playerKey = Parameter.player().setKey("player") - .setUsage(key -> "[any player]") + final Parameter.Value playerKey = Parameter.player().key("player") + .usage(key -> "[any player]") .build(); event.register( this.plugin, Command.builder() - .parameter(playerKey) - .setExecutor(context -> { - final ServerPlayer player = context.getOne(playerKey) - .orElse(context.getCause().root() instanceof ServerPlayer ? ((ServerPlayer) context.getCause().root()) : null); - this.logger.info(player.getName()); + .addParameter(playerKey) + .executor(context -> { + final ServerPlayer player = context.one(playerKey) + .orElse(context.cause().root() instanceof ServerPlayer ? ((ServerPlayer) context.cause().root()) : null); + this.logger.info(player.name()); return CommandResult.success(); }) .build(), "getplayer"); - final Parameter.Value playerParameterKey = Parameter.string().setKey("name").optional().build(); + final Parameter.Value playerParameterKey = Parameter.string().key("name").optional().build(); event.register( this.plugin, Command.builder() - .parameter(playerParameterKey) - .setExecutor(context -> { - final Optional result = context.getOne(playerParameterKey); + .addParameter(playerParameterKey) + .executor(context -> { + final Optional result = context.one(playerParameterKey); final Collection collection; if (result.isPresent()) { // check to see if the string matches - collection = Sponge.getGame().getServer().getUserManager() + collection = Sponge.game().server().userManager() .streamOfMatches(result.get().toLowerCase(Locale.ROOT)) .collect(Collectors.toList()); } else { - collection = Sponge.getGame().getServer().getUserManager() + collection = Sponge.game().server().userManager() .streamAll() .collect(Collectors.toList()); } collection.forEach(x -> this.logger.info( - "GameProfile - UUID: {}, Name - {}", x.getUniqueId().toString(), x.getName().orElse("---"))); + "GameProfile - UUID: {}, Name - {}", x.uniqueId().toString(), x.name().orElse("---"))); return CommandResult.success(); }) .build(), @@ -129,13 +129,13 @@ public void onRegisterSpongeCommand(final RegisterCommandEvent { - context.sendMessage(Identity.nil(), Component.text(context.getFlagInvocationCount("flag"))); - context.sendMessage(Identity.nil(), Component.text(context.getFlagInvocationCount("t"))); - context.getAll(testKey).forEach(x -> context.sendMessage(Identity.nil(), Component.text(x))); + .addFlag(Flag.builder().alias("f").alias("flag").build()) + .addFlag(Flag.builder().alias("t").alias("text").setParameter(Parameter.string().key(testKey).build()).build()) + .addParameter(Parameter.formattingCodeText().key(requiredKey).build()) + .executor(context -> { + context.sendMessage(Identity.nil(), Component.text(context.flagInvocationCount("flag"))); + context.sendMessage(Identity.nil(), Component.text(context.flagInvocationCount("t"))); + context.all(testKey).forEach(x -> context.sendMessage(Identity.nil(), Component.text(x))); context.sendMessage(Identity.nil(), context.requireOne(requiredKey)); return CommandResult.success(); }) @@ -146,12 +146,12 @@ public void onRegisterSpongeCommand(final RegisterCommandEvent { + .addFlag(Flag.builder().alias("t").alias("text").setParameter(Parameter.string().key(testKey).build()).build()) + .addParameter(Parameter.formattingCodeText().key(requiredKey).build()) + .executor(context -> { context.sendMessage(Identity.nil(), Component.text("optional_test")); - context.sendMessage(Identity.nil(), Component.text(context.getFlagInvocationCount("t"))); - context.getAll(testKey).forEach(x -> context.sendMessage(Identity.nil(), Component.text(x))); + context.sendMessage(Identity.nil(), Component.text(context.flagInvocationCount("t"))); + context.all(testKey).forEach(x -> context.sendMessage(Identity.nil(), Component.text(x))); context.sendMessage(Identity.nil(), context.requireOne(requiredKey)); return CommandResult.success(); }) @@ -162,7 +162,7 @@ public void onRegisterSpongeCommand(final RegisterCommandEvent { + .executor(x -> { x.sendMessage(Identity.nil(), Component.text().content("Click Me") .clickEvent(SpongeComponents.executeCallback(ctx -> ctx.sendMessage(Identity.nil(), Component.text("Hello")))) .build() @@ -175,15 +175,15 @@ public void onRegisterSpongeCommand(final RegisterCommandEvent { + .executor(x -> { final Collection collection = Selector.builder() .applySelectorType(SelectorTypes.ALL_ENTITIES.get()) - .entityType(EntityTypes.PLAYER.get(), false) - .gameMode(GameModes.CREATIVE.get()) - .setLimit(1) + .addEntityType(EntityTypes.PLAYER.get(), false) + .addGameMode(GameModes.CREATIVE.get()) + .limit(1) .includeSelf() .build() - .select(x.getCause()); + .select(x.cause()); for (final Entity entity : collection) { x.sendMessage(Identity.nil(), Component.text(entity.toString())); } @@ -194,12 +194,12 @@ public void onRegisterSpongeCommand(final RegisterCommandEvent serverLocationKey = Parameter.key("serverLocation", ServerLocation.class); - final Parameter.Value serverLocationParameter = Parameter.location().setKey(serverLocationKey).build(); + final Parameter.Value serverLocationParameter = Parameter.location().key(serverLocationKey).build(); event.register( this.plugin, Command.builder() - .parameter(serverLocationParameter) - .setExecutor(x -> { + .addParameter(serverLocationParameter) + .executor(x -> { x.sendMessage(Identity.nil(), Component.text(x.requireOne(serverLocationKey).toString())); return CommandResult.success(); }) @@ -213,15 +213,15 @@ public void onRegisterSpongeCommand(final RegisterCommandEvent Sponge.getGame().registries(), + commandContext -> Sponge.game().registries(), RegistryTypes.REGISTRY_KEYED_VALUE_PARAMETER, "sponge" - ).setKey(commandParameterKey).build()) - .setExecutor(x -> { + ).key(commandParameterKey).build()) + .executor(x -> { x.sendMessage(Identity.nil(), Component.text(x.requireOne(serverLocationKey).toString())); x.sendMessage(Identity.nil(), Component.text(x.requireOne(commandParameterKey).toString())); return CommandResult.success(); @@ -235,10 +235,10 @@ public void onRegisterSpongeCommand(final RegisterCommandEvent ImmutableList.of("bacon", "eggs", "spam")).build()) - .setExecutor(x -> { - x.sendMessage(Identity.nil(), Component.text(x.getOne(enumParameterKey).orElse(TestEnum.ONE).name())); + .addParameter(Parameter.enumValue(TestEnum.class).key(enumParameterKey).build()) + .addParameter(Parameter.string().key(stringKey).suggestions((context, currentInput) -> ImmutableList.of("bacon", "eggs", "spam")).build()) + .executor(x -> { + x.sendMessage(Identity.nil(), Component.text(x.one(enumParameterKey).orElse(TestEnum.ONE).name())); return CommandResult.success(); }) .build(), @@ -250,9 +250,9 @@ public void onRegisterSpongeCommand(final RegisterCommandEvent { - x.sendMessage(Identity.nil(), Component.text(x.requireOne(resourceKeyKey).getFormatted())); + .addParameter(Parameter.resourceKey().key(resourceKeyKey).build()) + .executor(x -> { + x.sendMessage(Identity.nil(), Component.text(x.requireOne(resourceKeyKey).formatted())); return CommandResult.success(); }) .build(), @@ -263,9 +263,9 @@ public void onRegisterSpongeCommand(final RegisterCommandEvent { - context.sendMessage(Identity.nil(), Component.text(context.requireOne(userKey).getName())); + .addParameter(Parameter.user().key(userKey).build()) + .executor(context -> { + context.sendMessage(Identity.nil(), Component.text(context.requireOne(userKey).name())); return CommandResult.success(); }) .build(), @@ -276,40 +276,40 @@ public void onRegisterSpongeCommand(final RegisterCommandEvent { - context.sendMessage(Identity.nil(), Component.text("Collected literals: " + String.join(", ", context.getAll(stringLiteralKey)))); + .executor(context -> { + context.sendMessage(Identity.nil(), Component.text("Collected literals: " + String.join(", ", context.all(stringLiteralKey)))); return CommandResult.success(); }) - .setTerminal(true) - .parameter( - Parameter.firstOfBuilder(Parameter.literal(String.class, "1", "1").setKey(stringLiteralKey).build()) - .or(Parameter.literal(String.class, "2", "2").setKey(stringLiteralKey).build()) + .terminal(true) + .addParameter( + Parameter.firstOfBuilder(Parameter.literal(String.class, "1", "1").key(stringLiteralKey).build()) + .or(Parameter.literal(String.class, "2", "2").key(stringLiteralKey).build()) .terminal() .build() ) - .parameter(Parameter.seqBuilder(Parameter.literal(String.class, "3", "3").setKey(stringLiteralKey).build()) - .then(Parameter.literal(String.class, "4", "4").setKey(stringLiteralKey).build()) + .addParameter(Parameter.seqBuilder(Parameter.literal(String.class, "3", "3").key(stringLiteralKey).build()) + .then(Parameter.literal(String.class, "4", "4").key(stringLiteralKey).build()) .terminal() .build()) - .parameter(Parameter.literal(String.class, "5", "5").optional().setKey(stringLiteralKey).build()) - .parameter(Parameter.literal(String.class, "6", "6").setKey(stringLiteralKey).build()) + .addParameter(Parameter.literal(String.class, "5", "5").optional().key(stringLiteralKey).build()) + .addParameter(Parameter.literal(String.class, "6", "6").key(stringLiteralKey).build()) .build(), "testnesting"); final Parameter.Value systemSubjectValue = Parameter.builder(SystemSubject.class) - .setKey("systemsubject") - .parser(VariableValueParameters.literalBuilder(SystemSubject.class).setLiteral(Collections.singleton("-")) - .setReturnValue(Sponge::getSystemSubject).build()) + .key("systemsubject") + .addParser(VariableValueParameters.literalBuilder(SystemSubject.class).literal(Collections.singleton("-")) + .returnValue(Sponge::systemSubject).build()) .build(); event.register( this.plugin, Command.builder() - .parameter(Parameter.firstOf( + .addParameter(Parameter.firstOf( systemSubjectValue, CommonParameters.PLAYER )) - .parameter(Parameter.remainingJoinedStrings().setKey(stringKey).build()) - .setExecutor(context -> { + .addParameter(Parameter.remainingJoinedStrings().key(stringKey).build()) + .executor(context -> { final Audience audience; final String name; if (context.hasAny(systemSubjectValue)) { @@ -317,12 +317,12 @@ public void onRegisterSpongeCommand(final RegisterCommandEvent " + message)); - final Object root = context.getCause().root(); + final Object root = context.cause().root(); final Identity identity = root instanceof ServerPlayer ? ((ServerPlayer) root).identity() : Identity.nil(); audience.sendMessage(identity, Component.text("From " + name + "> " + message)); return CommandResult.success(); @@ -336,15 +336,15 @@ public void onRegisterSpongeCommand(final RegisterCommandEvent s.isEmpty() ? Collections.singletonList("x") : Arrays.asList(s, s + "bar", "foo_" + s); // final ValueCompleter stringValueCompleter = null; - final Parameter.Value r_opt = Parameter.remainingJoinedStrings().setKey("r_def").optional().build(); - final Parameter.Value r_req = Parameter.remainingJoinedStrings().setKey("r_req").setSuggestions(stringValueCompleter).build(); - final Parameter.Value opt1 = Parameter.string().optional().setKey("opt1").build(); - final Parameter.Value opt2 = Parameter.string().optional().setKey("opt2").build(); - final Parameter.Value topt = Parameter.string().optional().setKey("topt").terminal().build(); - final Parameter.Value req1 = Parameter.string().setKey("req1").setSuggestions(stringValueCompleter).build(); - final Parameter.Value req2 = Parameter.string().setKey("req2").build(); - final Parameter.Value lit1 = Parameter.literal(Boolean.class, true, "lit1").setKey("lit1").build(); - final Parameter.Value lit2 = Parameter.literal(Boolean.class, true, "lit2").setKey("lit2").build(); + final Parameter.Value r_opt = Parameter.remainingJoinedStrings().key("r_def").optional().build(); + final Parameter.Value r_req = Parameter.remainingJoinedStrings().key("r_req").suggestions(stringValueCompleter).build(); + final Parameter.Value opt1 = Parameter.string().optional().key("opt1").build(); + final Parameter.Value opt2 = Parameter.string().optional().key("opt2").build(); + final Parameter.Value topt = Parameter.string().optional().key("topt").terminal().build(); + final Parameter.Value req1 = Parameter.string().key("req1").suggestions(stringValueCompleter).build(); + final Parameter.Value req2 = Parameter.string().key("req2").build(); + final Parameter.Value lit1 = Parameter.literal(Boolean.class, true, "lit1").key("lit1").build(); + final Parameter.Value lit2 = Parameter.literal(Boolean.class, true, "lit2").key("lit2").build(); final Parameter optSeq_lit_req1 = Parameter.seqBuilder(lit1).then(req1).optional().build(); final Parameter optSeq_lit_req2 = Parameter.seqBuilder(lit2).then(req2).optional().build(); final Parameter seq_req_2 = Parameter.seqBuilder(req1).then(req2).build(); @@ -352,13 +352,13 @@ public void onRegisterSpongeCommand(final RegisterCommandEvent - builder.child(Command.builder().setExecutor(context -> CommandTest.printParameters(context, req1)) - .parameter(req1).build(),"required"); + builder.addChild(Command.builder().executor(context -> CommandTest.printParameters(context, req1)) + .addParameter(req1).build(),"required"); // subcommand| - builder.child(Command.builder().setExecutor(context -> CommandTest.printParameters(context, r_opt)) - .parameter(r_opt) - .child(Command.builder().setExecutor(c -> CommandTest.printParameters(c, r_opt)).build(), "subcommand") + builder.addChild(Command.builder().executor(context -> CommandTest.printParameters(context, r_opt)) + .addParameter(r_opt) + .addChild(Command.builder().executor(c -> CommandTest.printParameters(c, r_opt)).build(), "subcommand") .build(), "optional_or_subcmd"); @@ -367,82 +367,82 @@ public void onRegisterSpongeCommand(final RegisterCommandEvent // TODO missing executed command when only providing a single value - builder.child(Command.builder().setExecutor(context -> CommandTest.printParameters(context, opt1, r_req)) - .parameters(opt1, r_req).build(), "optional_r_required"); + builder.addChild(Command.builder().executor(context -> CommandTest.printParameters(context, opt1, r_req)) + .addParameters(opt1, r_req).build(), "optional_r_required"); // [opt1] [opt2] // TODO missing executed command when only providing a single value - builder.child(Command.builder().setExecutor(context -> CommandTest.printParameters(context, opt1, opt2, r_req)) - .parameters(opt1, opt2, r_req).build(), "optional_optional_required"); + builder.addChild(Command.builder().executor(context -> CommandTest.printParameters(context, opt1, opt2, r_req)) + .addParameters(opt1, opt2, r_req).build(), "optional_optional_required"); // [opt1] [opt2] // TODO some redundancy in generated nodes because opt1 node can terminate early - builder.child(Command.builder().setExecutor(context -> CommandTest.printParameters(context, opt1, opt2)) - .parameters(opt1, opt2).build(), "optional_optional"); + builder.addChild(Command.builder().executor(context -> CommandTest.printParameters(context, opt1, opt2)) + .addParameters(opt1, opt2).build(), "optional_optional"); // [opt1] [literal ] // TODO completion does not include req1 when opt1/literal is ambigous - builder.child(Command.builder().setExecutor(c -> CommandTest.printParameters(c, opt1, lit1, req1)) - .parameters(opt1, optSeq_lit_req1).build(), "optional_optsequence_literal_required"); + builder.addChild(Command.builder().executor(c -> CommandTest.printParameters(c, opt1, lit1, req1)) + .addParameters(opt1, optSeq_lit_req1).build(), "optional_optsequence_literal_required"); // [literal ] [literal2 ] // TODO sequences are not optional - builder.child(Command.builder().setExecutor(c -> CommandTest.printParameters(c, lit1, req1, lit2, req2)) - .parameters(optSeq_lit_req1, optSeq_lit_req2).build(), "opt_sequence_2_literal_required"); + builder.addChild(Command.builder().executor(c -> CommandTest.printParameters(c, lit1, req1, lit2, req2)) + .addParameters(optSeq_lit_req1, optSeq_lit_req2).build(), "opt_sequence_2_literal_required"); // < > - builder.child(Command.builder().setExecutor(c -> CommandTest.printParameters(c, req1, req2)) - .parameters(seq_req_2).build(), "seq_required_required"); + builder.addChild(Command.builder().executor(c -> CommandTest.printParameters(c, req1, req2)) + .addParameters(seq_req_2).build(), "seq_required_required"); // <[opt1] [opt2]> // TODO some redundancy in generated nodes because opt1 node can terminate early - builder.child(Command.builder().setExecutor(c -> CommandTest.printParameters(c, opt1, opt2)) - .parameters(seq_opt_2).build(), "seq_optional_optional"); + builder.addChild(Command.builder().executor(c -> CommandTest.printParameters(c, opt1, opt2)) + .addParameters(seq_opt_2).build(), "seq_optional_optional"); // <[opt1] [opt2] > - builder.child(Command.builder().setExecutor(c -> CommandTest.printParameters(c, opt1, opt2, req1)) - .parameters(seq_opt_2_req).build(), "seq_optional_optional_required"); + builder.addChild(Command.builder().executor(c -> CommandTest.printParameters(c, opt1, opt2, req1)) + .addParameters(seq_opt_2_req).build(), "seq_optional_optional_required"); // [opt1] [opt2] // TODO some redundancy in generated nodes because req1 node can terminate early - builder.child(Command.builder().setExecutor(c -> CommandTest.printParameters(c, opt1, req1, opt2)) - .parameters(opt1, req1, opt2).build(), "optional_required_optional"); + builder.addChild(Command.builder().executor(c -> CommandTest.printParameters(c, opt1, req1, opt2)) + .addParameters(opt1, req1, opt2).build(), "optional_required_optional"); // [opt1] [topt] !terminal // or // [opt1] [topt] - builder.child(Command.builder().setExecutor(c -> CommandTest.printParameters(c, opt1, topt, req1)) - .parameters(opt1, topt, req1).build(), "optional_toptional_optional"); + builder.addChild(Command.builder().executor(c -> CommandTest.printParameters(c, opt1, topt, req1)) + .addParameters(opt1, topt, req1).build(), "optional_toptional_optional"); event.register(this.plugin, builder.build(), "testcommand", "testcmd"); // Adapted from https://github.com/SpongePowered/Sponge/issues/3238#issuecomment-750456173 final Command.Parameterized firstSub = Command.builder() - .parameter(CommonParameters.BOOLEAN) - .setExecutor(c -> { + .addParameter(CommonParameters.BOOLEAN) + .executor(c -> { c.sendMessage(Identity.nil(), Component.text("first")); return CommandResult.success(); }) .build(); final Command.Parameterized secondSub = Command.builder() - .parameter(CommonParameters.BOOLEAN) - .setExecutor(c -> { + .addParameter(CommonParameters.BOOLEAN) + .executor(c -> { c.sendMessage(Identity.nil(), Component.text("second")); return CommandResult.success(); }) .build(); final Command.Parameterized parent = Command.builder() - .setExecutor(c -> { + .executor(c -> { c.sendMessage(Identity.nil(), Component.text("parent")); return CommandResult.success(); }) - .parameters(CommonParameters.WORLD) - .parameters(Parameter.firstOf( + .addParameters(CommonParameters.WORLD) + .addParameters(Parameter.firstOf( Parameter.subcommand(firstSub, "first"), Parameter.subcommand(secondSub, "second") )) - .setTerminal(true) + .terminal(true) .build(); event.register(this.plugin, parent, "testterminal"); @@ -450,14 +450,14 @@ public void onRegisterSpongeCommand(final RegisterCommandEvent { + .shortDescription(Component.text("test throwing execptions")) + .addChild(Command.builder() + .executor(ctx -> { throw new CommandException(Component.text("Exit via exception")); }) .build(), "exception") - .child(Command.builder() - .setExecutor(ctx -> { + .addChild(Command.builder() + .executor(ctx -> { return CommandResult.error(Component.text("Exit via failed result")); }).build(), "failedresult") .build(), "testfailure"); @@ -471,12 +471,12 @@ public void onRegisterRawSpongeCommand(final RegisterCommandEvent e private static CommandResult printParameters(final CommandContext context, final Parameter.Value... params) { for (final Parameter.Value param : params) { - final Object paramValue = context.getOne(param).map(Object::toString).orElse("missing"); - final String paramUsage = param.getUsage(context.getCause()); + final Object paramValue = context.one(param).map(Object::toString).orElse("missing"); + final String paramUsage = param.usage(context.cause()); context.sendMessage(Identity.nil(), Component.text(paramUsage + ": " + paramValue)); } // TODO usage starts with "command" - comes from SpogneParameterizedCommand#getCachedDispatcher - context.getExecutedCommand().ifPresent(cmd -> context.sendMessage(Identity.nil(), cmd.getUsage(context.getCause()).color(NamedTextColor.GRAY))); + context.executedCommand().ifPresent(cmd -> context.sendMessage(Identity.nil(), cmd.usage(context.cause()).color(NamedTextColor.GRAY))); return CommandResult.success(); } diff --git a/testplugins/src/main/java/org/spongepowered/test/command/RawCommandTest.java b/testplugins/src/main/java/org/spongepowered/test/command/RawCommandTest.java index 2c8b19d5ca0..3965159286b 100644 --- a/testplugins/src/main/java/org/spongepowered/test/command/RawCommandTest.java +++ b/testplugins/src/main/java/org/spongepowered/test/command/RawCommandTest.java @@ -51,14 +51,14 @@ public CommandResult process(final @NonNull CommandCause cause, final ArgumentRe if (!arguments.canRead()) { cause.sendMessage(Identity.nil(), Component.text("No arguments")); } - cause.sendMessage(Identity.nil(), Component.text(arguments.getRemaining())); + cause.sendMessage(Identity.nil(), Component.text(arguments.remaining())); return CommandResult.success(); } @Override @NonNull - public List getSuggestions(final @NonNull CommandCause cause, final ArgumentReader.@NonNull Mutable arguments) throws CommandException { - if (arguments.getRemaining().endsWith(" ")) { + public List suggestions(final @NonNull CommandCause cause, final ArgumentReader.@NonNull Mutable arguments) throws CommandException { + if (arguments.remaining().endsWith(" ")) { return this.suggestions; } @@ -78,19 +78,19 @@ public boolean canExecute(@NonNull final CommandCause cause) { @Override @NonNull - public Optional getShortDescription(@NonNull final CommandCause cause) { + public Optional shortDescription(@NonNull final CommandCause cause) { return Optional.empty(); } @Override @NonNull - public Optional getExtendedDescription(@NonNull final CommandCause cause) { + public Optional extendedDescription(@NonNull final CommandCause cause) { return Optional.empty(); } @Override @NonNull - public Component getUsage(@NonNull final CommandCause cause) { + public Component usage(@NonNull final CommandCause cause) { return Component.text("[string] [string]"); } diff --git a/testplugins/src/main/java/org/spongepowered/test/config/ConfigTest.java b/testplugins/src/main/java/org/spongepowered/test/config/ConfigTest.java index 16ccf34fbce..3a8eeaed4b3 100644 --- a/testplugins/src/main/java/org/spongepowered/test/config/ConfigTest.java +++ b/testplugins/src/main/java/org/spongepowered/test/config/ConfigTest.java @@ -70,7 +70,7 @@ public void clientConnected(final ServerSideConnectionEvent.Join event) { return; } - event.getPlayer().sendMessage(Identity.nil(), motd); + event.player().sendMessage(Identity.nil(), motd); } diff --git a/testplugins/src/main/java/org/spongepowered/test/customdata/CustomDataTest.java b/testplugins/src/main/java/org/spongepowered/test/customdata/CustomDataTest.java index f455c549602..6c5b3d97586 100644 --- a/testplugins/src/main/java/org/spongepowered/test/customdata/CustomDataTest.java +++ b/testplugins/src/main/java/org/spongepowered/test/customdata/CustomDataTest.java @@ -94,38 +94,38 @@ private enum Type { @Listener public void onRegisterSpongeCommand(final RegisterCommandEvent event) { - final Parameter.Value numberKey = Parameter.integerNumber().setKey("number").optional().build(); - final Parameter.Value type = Parameter.enumValue(Type.class).setKey("type").optional().build(); + final Parameter.Value numberKey = Parameter.integerNumber().key("number").optional().build(); + final Parameter.Value type = Parameter.enumValue(Type.class).key("type").optional().build(); final Command.Parameterized myCommand = Command.builder() - .parameter(type) - .parameter(numberKey) - .setExecutor(context -> { - final Integer number = context.getOne(numberKey).orElse(1); - final ServerPlayer player = context.getCause().first(ServerPlayer.class).get(); - switch (context.getOne(type).orElse(Type.ITEMSTACK)) { + .addParameter(type) + .addParameter(numberKey) + .executor(context -> { + final Integer number = context.one(numberKey).orElse(1); + final ServerPlayer player = context.cause().first(ServerPlayer.class).get(); + switch (context.one(type).orElse(Type.ITEMSTACK)) { case ITEMSTACK: final ItemStack stack = ItemStack.of(ItemTypes.PAPER); stack.offer(this.myDataKey, number); stack.offer(this.mySimpleDataKey, "It works! " + number); stack.offer(this.myItemTypeKey, ItemTypes.PAPER.get()); - player.getInventory().offer(stack); - final List slots = player.getInventory().query(QueryTypes.ITEM_STACK_CUSTOM.get().of(s -> s.get(this.myDataKey).isPresent())).slots(); + player.inventory().offer(stack); + final List slots = player.inventory().query(QueryTypes.ITEM_STACK_CUSTOM.get().of(s -> s.get(this.myDataKey).isPresent())).slots(); final int itemSum = slots.stream().map(Slot::peek).mapToInt(item -> item.get(this.myDataKey).get()).sum(); player.sendActionBar(Component.text(itemSum)); slots.stream().map(Slot::peek).map(s -> s.get(this.mySimpleDataKey)).forEach(data -> data.ifPresent(value -> player.sendMessage(Identity.nil(), Component.text(value)))); break; case ENTITY: - final Entity entity = player.getWorld().createEntity(EntityTypes.MINECART.get(), player.getPosition().add(0, 3, 0)); + final Entity entity = player.world().createEntity(EntityTypes.MINECART.get(), player.position().add(0, 3, 0)); entity.offer(this.myDataKey, number); - player.getWorld().spawnEntity(entity); - final int entitySum = player.getNearbyEntities(5).stream().filter(e -> e.get(this.myDataKey).isPresent()).mapToInt(e -> e.get(this.myDataKey).get()).sum(); + player.world().spawnEntity(entity); + final int entitySum = player.nearbyEntities(5).stream().filter(e -> e.get(this.myDataKey).isPresent()).mapToInt(e -> e.get(this.myDataKey).get()).sum(); player.sendActionBar(Component.text(entitySum)); break; case BLOCKENTITY: - player.getWorld().setBlock(player.getBlockPosition(), BlockTypes.DISPENSER.get().getDefaultState()); - final BlockEntity blockEntity = player.getWorld().getBlockEntity(player.getBlockPosition()).get(); + player.world().setBlock(player.blockPosition(), BlockTypes.DISPENSER.get().defaultState()); + final BlockEntity blockEntity = player.world().blockEntity(player.blockPosition()).get(); blockEntity.offer(this.myDataKey, number); - final int blockEntitySum = player.getWorld().getBlockEntities().stream().filter(e -> e.get(this.myDataKey).isPresent()) + final int blockEntitySum = player.world().blockEntities().stream().filter(e -> e.get(this.myDataKey).isPresent()) .mapToInt(e -> e.get(this.myDataKey).get()).sum(); player.sendActionBar(Component.text(blockEntitySum)); break; @@ -136,17 +136,17 @@ public void onRegisterSpongeCommand(final RegisterCommandEvent this.customUserData(player.getUniqueId(), number)).plugin(this.plugin).build()); - scheduler.submit(Task.builder().delay(Ticks.of(2)).execute(() -> this.customUserData(player.getUniqueId(), number)).plugin(this.plugin).build()); + final Scheduler scheduler = Sponge.server().scheduler(); + scheduler.submit(Task.builder().delay(Ticks.single()).execute(() -> this.customUserData(player.uniqueId(), number)).plugin(this.plugin).build()); + scheduler.submit(Task.builder().delay(Ticks.of(2)).execute(() -> this.customUserData(player.uniqueId(), number)).plugin(this.plugin).build()); break; case BLOCK: // try out custom data-stores - final Integer oldNumber = player.getWorld().get(player.getBlockPosition(), this.myDataKey).orElse(0); + final Integer oldNumber = player.world().get(player.blockPosition(), this.myDataKey).orElse(0); player.sendActionBar(Component.text(oldNumber)); - player.getWorld().offer(player.getBlockPosition(), this.myDataKey, oldNumber + number); + player.world().offer(player.blockPosition(), this.myDataKey, oldNumber + number); } return CommandResult.success(); }) @@ -187,7 +187,7 @@ public void onRegisterData(final RegisterDataEvent event) { private Map> myCustomData = new HashMap<>(); private DataTransactionResult removeData(ServerLocation serverLocation) { - final Integer removed = this.myCustomData.getOrDefault(serverLocation.getWorldKey(), Collections.emptyMap()).remove(serverLocation.getBlockPosition()); + final Integer removed = this.myCustomData.getOrDefault(serverLocation.worldKey(), Collections.emptyMap()).remove(serverLocation.blockPosition()); if (removed == null) { return DataTransactionResult.failNoData(); } @@ -195,26 +195,26 @@ private DataTransactionResult removeData(ServerLocation serverLocation) { } private DataTransactionResult setData(ServerLocation serverLocation, Integer value) { - final Map worldData = this.myCustomData.computeIfAbsent(serverLocation.getWorldKey(), k -> new HashMap<>()); - worldData.put(serverLocation.getBlockPosition(), value); + final Map worldData = this.myCustomData.computeIfAbsent(serverLocation.worldKey(), k -> new HashMap<>()); + worldData.put(serverLocation.blockPosition(), value); return DataTransactionResult.successResult(Value.immutableOf(this.myDataKey, value)); } private Integer getData(ServerLocation serverLocation) { - return this.myCustomData.getOrDefault(serverLocation.getWorldKey(), Collections.emptyMap()).get(serverLocation.getBlockPosition()); + return this.myCustomData.getOrDefault(serverLocation.worldKey(), Collections.emptyMap()).get(serverLocation.blockPosition()); } @Listener public void onJoin(final ServerSideConnectionEvent.Join event) { - final Optional myValue = event.getPlayer().get(this.myDataKey); + final Optional myValue = event.player().get(this.myDataKey); myValue.ifPresent(integer -> this.plugin.getLogger().info("CustomData: {}", integer)); } private void customUserData(final UUID playerUUID, final int number) { - final Optional user = Sponge.getServer().getUserManager().get(playerUUID); + final Optional user = Sponge.server().userManager().find(playerUUID); if (user.isPresent()) { final Integer integer = user.get().get(this.myDataKey).orElse(0); - this.plugin.getLogger().info("Custom data on user {}: {}", user.get().getName(), integer); + this.plugin.getLogger().info("Custom data on user {}: {}", user.get().name(), integer); user.get().offer(this.myDataKey, number); } } diff --git a/testplugins/src/main/java/org/spongepowered/test/data/DataTest.java b/testplugins/src/main/java/org/spongepowered/test/data/DataTest.java index 289faebc333..894edc0ddce 100644 --- a/testplugins/src/main/java/org/spongepowered/test/data/DataTest.java +++ b/testplugins/src/main/java/org/spongepowered/test/data/DataTest.java @@ -145,9 +145,9 @@ public DataTest(final PluginContainer plugin) { @Listener public void onRegisterCommand(final RegisterCommandEvent event) { event.register(this.plugin, Command.builder() - .setExecutionRequirements(cc -> cc.first(ServerPlayer.class).isPresent()) - .setExecutor(context -> { - this.testData(context.getCause().first(ServerPlayer.class).get()); + .executionRequirements(cc -> cc.first(ServerPlayer.class).isPresent()) + .executor(context -> { + this.testData(context.cause().first(ServerPlayer.class).get()); return CommandResult.success(); }) .build() @@ -156,12 +156,12 @@ public void onRegisterCommand(final RegisterCommandEvent public void testData(final ServerPlayer player) { - final ServerWorld world = player.getWorld(); - final Vector3d position = player.getPosition(); + final ServerWorld world = player.world(); + final Vector3d position = player.position(); final Vector3i blockPos = position.toInt(); - final ServerLocation location = world.getLocation(blockPos); + final ServerLocation location = world.location(blockPos); - final BlockState oldState = world.getBlock(blockPos); + final BlockState oldState = world.block(blockPos); world.setWeather(WeatherTypes.CLEAR.get()); @@ -169,7 +169,7 @@ public void testData(final ServerPlayer player) { this.checkOfferData(player, Keys.ABSORPTION, 10.0); this.checkOfferData(player, Keys.ABSORPTION, 20.0); // TODO launchProjectile is abstract -// final Optional arrow = player.launchProjectile(Arrow.class, player.getHeadDirection()); +// final Optional arrow = player.launchProjectile(Arrow.class, player.headDirection()); // this.checkOfferData(arrow.get(), Keys.ACCELERATION, Vector3d.UP); // TODO Keys.ACTIVE_ITEM is only when actually using itemsd // Test: get during event + setting empty & remove @@ -206,7 +206,7 @@ public void testData(final ServerPlayer player) { final Entity painting = world.createEntity(EntityTypes.PAINTING.get(), position); this.checkGetData(painting, Keys.ART_TYPE, ArtTypes.KEBAB.get()); // TODO test offer (only works on valid painting) - final BlockState leverState = BlockTypes.LEVER.get().getDefaultState(); + final BlockState leverState = BlockTypes.LEVER.get().defaultState(); this.checkWithData(leverState, Keys.ATTACHMENT_SURFACE, AttachmentSurfaces.WALL.get()); this.checkWithData(leverState, Keys.ATTACHMENT_SURFACE, AttachmentSurfaces.FLOOR.get()); @@ -219,11 +219,11 @@ public void testData(final ServerPlayer player) { final ItemStack writtenBookStack = ItemStack.of(ItemTypes.WRITTEN_BOOK); this.checkOfferData(writtenBookStack, Keys.AUTHOR, Component.text("You")); - final BlockState logState = BlockTypes.OAK_LOG.get().getDefaultState(); + final BlockState logState = BlockTypes.OAK_LOG.get().defaultState(); this.checkWithData(logState, Keys.AXIS, Axis.Y); this.checkWithData(logState, Keys.AXIS, Axis.X); - this.checkOfferData(sheep, Keys.BABY_TICKS, Ticks.ofWallClockSeconds(Sponge.getServer(), 1)); + this.checkOfferData(sheep, Keys.BABY_TICKS, Ticks.ofWallClockSeconds(Sponge.server(), 1)); this.checkOfferData(sheep, Keys.BABY_TICKS, Ticks.zero()); final List pattern = Arrays.asList(BannerPatternLayer.of(BannerPatternShapes.BASE, DyeColors.BLACK), BannerPatternLayer.of(BannerPatternShapes.RHOMBUS, DyeColors.ORANGE)); @@ -236,8 +236,8 @@ public void testData(final ServerPlayer player) { this.checkGetListData(bannerStack, Keys.BANNER_PATTERN_LAYERS, Collections.emptyList()); this.checkOfferListData(bannerStack, Keys.BANNER_PATTERN_LAYERS, pattern); - world.setBlock(blockPos, BlockTypes.RED_BANNER.get().getDefaultState()); - final BlockEntity bannerEntity = world.getBlockEntity(blockPos).get(); + world.setBlock(blockPos, BlockTypes.RED_BANNER.get().defaultState()); + final BlockEntity bannerEntity = world.blockEntity(blockPos).get(); this.checkOfferListData(bannerEntity, Keys.BANNER_PATTERN_LAYERS, pattern); // Keys.BASE_COLOR @@ -258,19 +258,19 @@ public void testData(final ServerPlayer player) { this.checkOfferData(guardian, Keys.BEAM_TARGET_ENTITY, player); // TODO LocationBasedDataHolder get(int,int,int,key) is abstract -// this.checkGetData(location, Keys.BIOME_TEMPERATURE, world.getBiome(blockPos).getTemperature()); +// this.checkGetData(location, Keys.BIOME_TEMPERATURE, world.biome(blockPos).getTemperature()); - final BlockState obisidanState = BlockTypes.OBSIDIAN.get().getDefaultState(); + final BlockState obisidanState = BlockTypes.OBSIDIAN.get().defaultState(); this.checkGetData(obisidanState, Keys.BLAST_RESISTANCE, 1200.0); - final BlockState dirtState = BlockTypes.DIRT.get().getDefaultState(); + final BlockState dirtState = BlockTypes.DIRT.get().defaultState(); this.checkGetData(dirtState, Keys.BLAST_RESISTANCE, 0.5); - final BlockState bricksState = BlockTypes.BRICKS.get().getDefaultState(); + final BlockState bricksState = BlockTypes.BRICKS.get().defaultState(); this.checkGetData(bricksState, Keys.BLAST_RESISTANCE, 6.0); // TODO Keys.BLOCK_LIGHT final Entity fallingBlock = world.createEntity(EntityTypes.FALLING_BLOCK.get(), position.add(0,5,0)); - final BlockState sandState = BlockTypes.SAND.get().getDefaultState(); + final BlockState sandState = BlockTypes.SAND.get().defaultState(); this.checkOfferData(fallingBlock, Keys.BLOCK_STATE, sandState); this.checkOfferData(minecartEntity, Keys.BLOCK_STATE, dirtState); @@ -293,7 +293,7 @@ public void testData(final ServerPlayer player) { this.checkOfferSetData(jungleAxe, Keys.BREAKABLE_BLOCK_TYPES, new HashSet<>(Arrays.asList(BlockTypes.COCOA.get(), BlockTypes.JUNGLE_LEAVES.get()))); this.checkGetData(sheep, Keys.BREEDER, null); - this.checkOfferData(sheep, Keys.BREEDER, player.getUniqueId()); + this.checkOfferData(sheep, Keys.BREEDER, player.uniqueId()); this.checkGetData(sheep, Keys.BREEDING_COOLDOWN, Ticks.zero()); this.checkOfferData(sheep, Keys.BREEDING_COOLDOWN, Ticks.of(100)); @@ -323,7 +323,7 @@ public void testData(final ServerPlayer player) { // TODO maybe only when actually falling // final Entity fallingAnvil = world.createEntity(EntityTypes.FALLING_BLOCK.get(), position); -// fallingAnvil.offer(Keys.BLOCK_STATE, BlockTypes.ANVIL.get().getDefaultState()); +// fallingAnvil.offer(Keys.BLOCK_STATE, BlockTypes.ANVIL.get().defaultState()); // this.checkGetData(fallingAnvil, Keys.CAN_HURT_ENTITIES, true); @@ -345,9 +345,9 @@ public void testData(final ServerPlayer player) { this.checkOfferData(cat, Keys.CAT_TYPE, CatTypes.WHITE.get()); // TODO -// world.setBlock(blockPos, BlockTypes.CHEST.get().getDefaultState()); +// world.setBlock(blockPos, BlockTypes.CHEST.get().defaultState()); // final Optional chestAttachmentType = world.get(blockPos, Keys.CHEST_ATTACHMENT_TYPE); -// world.setBlock(blockPos.add(0, 0, 1), BlockTypes.CHEST.get().getDefaultState()); +// world.setBlock(blockPos.add(0, 0, 1), BlockTypes.CHEST.get().defaultState()); this.checkOfferData(armorStand, Keys.CHEST_ROTATION, Vector3d.from(0, 90, 0)); @@ -361,7 +361,7 @@ public void testData(final ServerPlayer player) { // TODO COMMAND // TODO NPE in event? -// world.setBlock(blockPos, BlockTypes.COMPARATOR.get().getDefaultState()); +// world.setBlock(blockPos, BlockTypes.COMPARATOR.get().defaultState()); // BlockState comparator = world.getBlock(blockPos); // this.checkGetData(comparator, Keys.COMPARATOR_MODE, ComparatorModes.COMPARE.get()); // comparator = comparator.with(Keys.COMPARATOR_MODE, ComparatorModes.SUBTRACT.get()).get(); @@ -372,12 +372,12 @@ public void testData(final ServerPlayer player) { final ItemStack waterBucket = ItemStack.of(ItemTypes.WATER_BUCKET); this.checkGetData(waterBucket, Keys.CONTAINER_ITEM, ItemTypes.BUCKET.get()); - world.setBlock(blockPos, BlockTypes.HOPPER.get().getDefaultState()); - this.checkGetData(world.getBlockEntity(blockPos).get(), Keys.COOLDOWN, Ticks.zero()); - this.checkOfferData(world.getBlockEntity(blockPos).get(), Keys.COOLDOWN, Ticks.of(10)); - world.setBlock(blockPos, BlockTypes.END_GATEWAY.get().getDefaultState()); - this.checkGetData(world.getBlockEntity(blockPos).get(), Keys.COOLDOWN, Ticks.zero()); - this.checkOfferData(world.getBlockEntity(blockPos).get(), Keys.COOLDOWN, Ticks.of(15)); + world.setBlock(blockPos, BlockTypes.HOPPER.get().defaultState()); + this.checkGetData(world.blockEntity(blockPos).get(), Keys.COOLDOWN, Ticks.zero()); + this.checkOfferData(world.blockEntity(blockPos).get(), Keys.COOLDOWN, Ticks.of(10)); + world.setBlock(blockPos, BlockTypes.END_GATEWAY.get().defaultState()); + this.checkGetData(world.blockEntity(blockPos).get(), Keys.COOLDOWN, Ticks.zero()); + this.checkOfferData(world.blockEntity(blockPos).get(), Keys.COOLDOWN, Ticks.of(15)); // TODO Keys.CREATOR @@ -395,7 +395,7 @@ public void testData(final ServerPlayer player) { checkOfferData(redFlard, Keys.CUSTOM_MODEL_DATA, 123456); redFlard.offer(Keys.CUSTOM_NAME, Component.text("Red FLARD", NamedTextColor.DARK_RED)); redFlard.offer(Keys.LORE, Arrays.asList(Component.text("May ignite holder! Handle with care", NamedTextColor.GOLD))); - player.getInventory().offer(redFlard); + player.inventory().offer(redFlard); // TODO Keys.CUSTOM_ATTACK_DAMAGE @@ -405,7 +405,7 @@ public void testData(final ServerPlayer player) { this.checkGetData(fallingBlock, Keys.DAMAGE_PER_BLOCK, 2.0); this.checkOfferData(fallingBlock, Keys.DAMAGE_PER_BLOCK, 5.0); - final BlockState leavesState = BlockTypes.ACACIA_LEAVES.get().getDefaultState(); + final BlockState leavesState = BlockTypes.ACACIA_LEAVES.get().defaultState(); this.checkGetData(leavesState, Keys.DECAY_DISTANCE, 7); this.checkWithData(leavesState, Keys.DECAY_DISTANCE, 2); @@ -433,7 +433,7 @@ public void testData(final ServerPlayer player) { this.checkOfferData(shulkerBullet, Keys.DIRECTION, Direction.NORTH); this.checkOfferData(shulkerBullet, Keys.DIRECTION, Direction.UP); - final BlockState acaciaStairs = BlockTypes.ACACIA_STAIRS.get().getDefaultState(); + final BlockState acaciaStairs = BlockTypes.ACACIA_STAIRS.get().defaultState(); this.checkGetData(acaciaStairs, Keys.DIRECTION, Direction.NORTH); this.checkWithData(acaciaStairs, Keys.DIRECTION, Direction.WEST); @@ -443,12 +443,12 @@ public void testData(final ServerPlayer player) { Component.translatable("chat.square_brackets").args(Component.empty().append(Component.text("Jungle Axe")).decorate(TextDecoration.ITALIC)) .color(NamedTextColor.WHITE).hoverEvent(jungleAxe.createSnapshot().asHoverEvent())); this.checkGetData(shulkerBullet, Keys.DISPLAY_NAME, Component.text("Angry Shulker Bullet") - .hoverEvent(HoverEvent.showEntity(ResourceKey.minecraft("shulker_bullet"), shulkerBullet.getUniqueId(), Component.text("Angry Shulker Bullet"))) - .insertion(shulkerBullet.getUniqueId().toString())); + .hoverEvent(HoverEvent.showEntity(ResourceKey.minecraft("shulker_bullet"), shulkerBullet.uniqueId(), Component.text("Angry Shulker Bullet"))) + .insertion(shulkerBullet.uniqueId().toString())); this.checkGetData(sheep, Keys.DISPLAY_NAME, Component.text("A sheep") - .hoverEvent(HoverEvent.showEntity(ResourceKey.minecraft("sheep"), sheep.getUniqueId(), Component.text("A sheep"))) - .insertion(sheep.getUniqueId().toString())); // Set with CUSTOM_NAME - world.setBlock(blockPos, BlockTypes.CHEST.get().getDefaultState()); + .hoverEvent(HoverEvent.showEntity(ResourceKey.minecraft("sheep"), sheep.uniqueId(), Component.text("A sheep"))) + .insertion(sheep.uniqueId().toString())); // Set with CUSTOM_NAME + world.setBlock(blockPos, BlockTypes.CHEST.get().defaultState()); this.checkGetData(location, Keys.CUSTOM_NAME, null); this.checkGetData(location, Keys.DISPLAY_NAME, Component.translatable("container.chest")); this.checkOfferData(location, Keys.CUSTOM_NAME, Component.text("Just a Chest")); @@ -467,15 +467,15 @@ public void testData(final ServerPlayer player) { this.checkOfferData(cat, Keys.DYE_COLOR, DyeColors.LIME.get()); this.checkGetData(ItemStack.of(ItemTypes.RED_WOOL), Keys.DYE_COLOR, DyeColors.RED.get()); this.checkGetData(bannerStack, Keys.DYE_COLOR, DyeColors.RED.get()); - this.checkGetData(BlockTypes.RED_BED.get().getDefaultState(), Keys.DYE_COLOR, DyeColors.RED.get()); - this.checkGetData(BlockTypes.BLUE_CONCRETE.get().getDefaultState(), Keys.DYE_COLOR, DyeColors.BLUE.get()); - this.checkGetData(BlockTypes.BLUE_CONCRETE_POWDER.get().getDefaultState(), Keys.DYE_COLOR, DyeColors.BLUE.get()); - this.checkGetData(BlockTypes.BLUE_TERRACOTTA.get().getDefaultState(), Keys.DYE_COLOR, DyeColors.BLUE.get()); - this.checkGetData(BlockTypes.BLUE_GLAZED_TERRACOTTA.get().getDefaultState(), Keys.DYE_COLOR, DyeColors.BLUE.get()); - this.checkGetData(BlockTypes.BLUE_STAINED_GLASS.get().getDefaultState(), Keys.DYE_COLOR, DyeColors.BLUE.get()); - this.checkGetData(BlockTypes.BLUE_STAINED_GLASS_PANE.get().getDefaultState(), Keys.DYE_COLOR, DyeColors.BLUE.get()); - this.checkGetData(BlockTypes.BLUE_BANNER.get().getDefaultState(), Keys.DYE_COLOR, DyeColors.BLUE.get()); - this.checkGetData(BlockTypes.BLUE_WALL_BANNER.get().getDefaultState(), Keys.DYE_COLOR, DyeColors.BLUE.get()); + this.checkGetData(BlockTypes.RED_BED.get().defaultState(), Keys.DYE_COLOR, DyeColors.RED.get()); + this.checkGetData(BlockTypes.BLUE_CONCRETE.get().defaultState(), Keys.DYE_COLOR, DyeColors.BLUE.get()); + this.checkGetData(BlockTypes.BLUE_CONCRETE_POWDER.get().defaultState(), Keys.DYE_COLOR, DyeColors.BLUE.get()); + this.checkGetData(BlockTypes.BLUE_TERRACOTTA.get().defaultState(), Keys.DYE_COLOR, DyeColors.BLUE.get()); + this.checkGetData(BlockTypes.BLUE_GLAZED_TERRACOTTA.get().defaultState(), Keys.DYE_COLOR, DyeColors.BLUE.get()); + this.checkGetData(BlockTypes.BLUE_STAINED_GLASS.get().defaultState(), Keys.DYE_COLOR, DyeColors.BLUE.get()); + this.checkGetData(BlockTypes.BLUE_STAINED_GLASS_PANE.get().defaultState(), Keys.DYE_COLOR, DyeColors.BLUE.get()); + this.checkGetData(BlockTypes.BLUE_BANNER.get().defaultState(), Keys.DYE_COLOR, DyeColors.BLUE.get()); + this.checkGetData(BlockTypes.BLUE_WALL_BANNER.get().defaultState(), Keys.DYE_COLOR, DyeColors.BLUE.get()); this.checkOfferData(bannerEntity, Keys.DYE_COLOR, DyeColors.PINK.get()); final Entity tropicalFish = world.createEntity(EntityTypes.TROPICAL_FISH.get(), position); @@ -490,9 +490,9 @@ public void testData(final ServerPlayer player) { this.checkOfferData(chicken, Keys.EGG_TIME, Ticks.of(0)); this.checkOfferData(chicken, Keys.EGG_TIME, Ticks.of(5000)); - world.setBlock(blockPos, BlockTypes.END_GATEWAY.get().getDefaultState()); - this.checkGetData(world.getBlockEntity(blockPos).get(), Keys.END_GATEWAY_AGE, Ticks.of(0L)); - this.checkOfferData(world.getBlockEntity(blockPos).get(), Keys.END_GATEWAY_AGE, Ticks.of(100L)); + world.setBlock(blockPos, BlockTypes.END_GATEWAY.get().defaultState()); + this.checkGetData(world.blockEntity(blockPos).get(), Keys.END_GATEWAY_AGE, Ticks.of(0L)); + this.checkOfferData(world.blockEntity(blockPos).get(), Keys.END_GATEWAY_AGE, Ticks.of(100L)); // Keys.EQUIPMENT_TYPE is for inventories this.checkOfferData(player, Keys.EXHAUSTION, 1.0); @@ -539,12 +539,12 @@ public void testData(final ServerPlayer player) { this.checkOfferData(player, Keys.FIRST_DATE_JOINED, Instant.now().minus(1, ChronoUnit.DAYS)); final Entity fox = world.createEntity(EntityTypes.FOX.get(), position); - this.checkOfferData(fox, Keys.FIRST_TRUSTED, player.getUniqueId()); + this.checkOfferData(fox, Keys.FIRST_TRUSTED, player.uniqueId()); // TODO missing dataprovider // this.checkGetData(waterBucket, Keys.FLUID_ITEM_STACK, FluidStackSnapshot.builder().fluid(FluidTypes.WATER).build()); - final BlockState waterBlockState = BlockTypes.WATER.get().getDefaultState(); + final BlockState waterBlockState = BlockTypes.WATER.get().defaultState(); this.checkGetData(waterBlockState, Keys.FLUID_LEVEL, 8); // TODO Keys.FLUID_TANK_CONTENTS @@ -570,14 +570,14 @@ public void testData(final ServerPlayer player) { player.offer(Keys.GAME_MODE, gameMode); final ItemStack playerHeadStack = ItemStack.of(ItemTypes.PLAYER_HEAD); - this.checkOfferData(playerHeadStack, Keys.GAME_PROFILE, player.getProfile()); + this.checkOfferData(playerHeadStack, Keys.GAME_PROFILE, player.profile()); // TODO Block Keys.GAME_PROFILE this.checkGetData(writtenBookStack, Keys.GENERATION, 0); this.checkOfferData(writtenBookStack, Keys.GENERATION, 2); - final BlockState melonStemState = BlockTypes.MELON_STEM.get().getDefaultState(); - final BlockState cactusState = BlockTypes.CACTUS.get().getDefaultState(); + final BlockState melonStemState = BlockTypes.MELON_STEM.get().defaultState(); + final BlockState cactusState = BlockTypes.CACTUS.get().defaultState(); this.checkGetData(melonStemState, Keys.GROWTH_STAGE, 0); this.checkWithData(melonStemState, Keys.GROWTH_STAGE, 4); this.checkGetData(cactusState, Keys.GROWTH_STAGE, 0); @@ -606,7 +606,7 @@ public void testData(final ServerPlayer player) { this.checkOfferData(armorStand, Keys.HAS_MARKER, true); this.checkOfferData(armorStand, Keys.HAS_MARKER, false); - final BlockState mushroomBlockState = BlockTypes.BROWN_MUSHROOM_BLOCK.get().getDefaultState(); + final BlockState mushroomBlockState = BlockTypes.BROWN_MUSHROOM_BLOCK.get().defaultState(); this.checkGetData(mushroomBlockState, Keys.HAS_PORES_DOWN, true); this.checkGetData(mushroomBlockState, Keys.HAS_PORES_EAST, true); this.checkGetData(mushroomBlockState, Keys.HAS_PORES_NORTH, true); @@ -662,11 +662,11 @@ public void testData(final ServerPlayer player) { this.checkOfferData(itemEntity, Keys.INFINITE_PICKUP_DELAY, true); world.spawnEntity(itemEntity); - final BlockState noteBlockState = BlockTypes.NOTE_BLOCK.get().getDefaultState(); + final BlockState noteBlockState = BlockTypes.NOTE_BLOCK.get().defaultState(); this.checkGetData(noteBlockState, Keys.INSTRUMENT_TYPE, InstrumentTypes.HARP.get()); this.checkWithData(noteBlockState, Keys.INSTRUMENT_TYPE, InstrumentTypes.COW_BELL.get()); - final BlockState daylightDetectorState = BlockTypes.DAYLIGHT_DETECTOR.get().getDefaultState(); + final BlockState daylightDetectorState = BlockTypes.DAYLIGHT_DETECTOR.get().defaultState(); this.checkGetData(daylightDetectorState, Keys.INVERTED, false); this.checkWithData(daylightDetectorState, Keys.INVERTED, true); @@ -675,7 +675,7 @@ public void testData(final ServerPlayer player) { this.checkOfferData(sheep, Keys.INVULNERABLE, true); this.checkOfferData(sheep, Keys.INVULNERABLE, false); - final BlockState fenceGateState = BlockTypes.ACACIA_FENCE_GATE.get().getDefaultState(); + final BlockState fenceGateState = BlockTypes.ACACIA_FENCE_GATE.get().defaultState(); this.checkGetData(fenceGateState, Keys.IN_WALL, false); this.checkWithData(fenceGateState, Keys.IN_WALL, true); @@ -695,7 +695,7 @@ public void testData(final ServerPlayer player) { // this.checkOfferData(zombiePigman, Keys.IS_ANGRY, true); // this.checkOfferData(zombiePigman, Keys.IS_ANGRY, false); - final BlockState torchState = BlockTypes.TORCH.get().getDefaultState(); + final BlockState torchState = BlockTypes.TORCH.get().defaultState(); this.checkGetData(torchState, Keys.IS_ATTACHED, false); this.checkGetData(dirtState, Keys.IS_ATTACHED, null); @@ -717,21 +717,21 @@ public void testData(final ServerPlayer player) { final Entity spider = world.createEntity(EntityTypes.SPIDER.get(), position); this.checkOfferData(spider, Keys.IS_CLIMBING, true); - final BlockState fenceState = BlockTypes.ACACIA_FENCE.get().getDefaultState(); + final BlockState fenceState = BlockTypes.ACACIA_FENCE.get().defaultState(); this.checkWithData(fenceState, Keys.IS_CONNECTED_EAST, true); this.checkWithData(fenceState, Keys.IS_CONNECTED_NORTH, false); this.checkWithData(fenceState, Keys.IS_CONNECTED_SOUTH, true); this.checkWithData(fenceState, Keys.IS_CONNECTED_WEST, false); - final BlockState wallState = BlockTypes.ANDESITE_WALL.get().getDefaultState(); + final BlockState wallState = BlockTypes.ANDESITE_WALL.get().defaultState(); this.checkWithData(wallState, Keys.IS_CONNECTED_EAST, true); this.checkWithData(wallState, Keys.IS_CONNECTED_NORTH, false); this.checkWithData(wallState, Keys.IS_CONNECTED_SOUTH, true); this.checkWithData(wallState, Keys.IS_CONNECTED_WEST, false); this.checkWithData(wallState, Keys.IS_CONNECTED_UP, true); - final BlockState vineState = BlockTypes.VINE.get().getDefaultState(); + final BlockState vineState = BlockTypes.VINE.get().defaultState(); this.checkWithData(vineState, Keys.IS_CONNECTED_UP, false); this.checkWithData(vineState, Keys.IS_CONNECTED_UP, true); @@ -743,7 +743,7 @@ public void testData(final ServerPlayer player) { this.checkOfferData(fox, Keys.IS_DEFENDING, true); - final BlockState tripWireState = BlockTypes.TRIPWIRE.get().getDefaultState(); + final BlockState tripWireState = BlockTypes.TRIPWIRE.get().defaultState(); this.checkWithData(tripWireState, Keys.IS_DISARMED, true); this.checkOfferData(panda, Keys.IS_EATING, true); @@ -753,13 +753,13 @@ public void testData(final ServerPlayer player) { this.checkOfferData(player, Keys.IS_ELYTRA_FLYING, true); this.checkOfferData(player, Keys.IS_ELYTRA_FLYING, false); - final BlockState pistonState = BlockTypes.PISTON.get().getDefaultState(); + final BlockState pistonState = BlockTypes.PISTON.get().defaultState(); this.checkWithData(pistonState, Keys.IS_EXTENDED, true); this.checkOfferData(fox, Keys.IS_FACEPLANTED, false); this.checkOfferData(fox, Keys.IS_FACEPLANTED, true); - final BlockState portalFrameState = BlockTypes.END_PORTAL_FRAME.get().getDefaultState(); + final BlockState portalFrameState = BlockTypes.END_PORTAL_FRAME.get().defaultState(); this.checkWithData(portalFrameState, Keys.IS_FILLED, true); this.checkWithData(portalFrameState, Keys.IS_FILLED, false); @@ -801,9 +801,9 @@ public void testData(final ServerPlayer player) { this.checkOfferData(vindicator, Keys.IS_LEADER, true); - final BlockState furnaceState = BlockTypes.FURNACE.get().getDefaultState(); - final BlockState campfireState = BlockTypes.CAMPFIRE.get().getDefaultState(); - final BlockState redstoneTorchState = BlockTypes.REDSTONE_TORCH.get().getDefaultState(); + final BlockState furnaceState = BlockTypes.FURNACE.get().defaultState(); + final BlockState campfireState = BlockTypes.CAMPFIRE.get().defaultState(); + final BlockState redstoneTorchState = BlockTypes.REDSTONE_TORCH.get().defaultState(); this.checkWithData(furnaceState, Keys.IS_LIT, false); this.checkWithData(furnaceState, Keys.IS_LIT, true); this.checkWithData(campfireState, Keys.IS_LIT, false); @@ -813,7 +813,7 @@ public void testData(final ServerPlayer player) { this.checkOfferData(cat, Keys.IS_LYING_DOWN, true); - final BlockState bedState = BlockTypes.BLACK_BED.get().getDefaultState(); + final BlockState bedState = BlockTypes.BLACK_BED.get().defaultState(); this.checkWithData(bedState, Keys.IS_OCCUPIED, true); this.checkWithData(bedState, Keys.IS_OCCUPIED, false); @@ -909,7 +909,7 @@ public void testData(final ServerPlayer player) { this.checkOfferData(jungleAxe, Keys.IS_UNBREAKABLE, true); this.checkGetData(obisidanState, Keys.IS_UNBREAKABLE, false); - final BlockState bedrockState = BlockTypes.BEDROCK.get().getDefaultState(); + final BlockState bedrockState = BlockTypes.BEDROCK.get().defaultState(); this.checkGetData(bedrockState, Keys.IS_UNBREAKABLE, true); // this.checkOfferData(panda, Keys.IS_UNHAPPY, true); @@ -940,12 +940,12 @@ public void testData(final ServerPlayer player) { // this.checkOfferData(player, Keys.LAST_DATE_JOINED, Instant.now().minus(1, TemporalUnits.DAYS)); // this.checkOfferData(player, Keys.LAST_DATE_PLAYED, Instant.now().minus(1, TemporalUnits.DAYS)); - final User user = Sponge.getServer().getUserManager().get(player.getUniqueId()).get(); + final User user = Sponge.server().userManager().find(player.uniqueId()).get(); // this.checkOfferData(user, Keys.LAST_DATE_JOINED, Instant.now().minus(1, TemporalUnits.DAYS)); // this.checkOfferData(user, Keys.LAST_DATE_PLAYED, Instant.now().minus(1, TemporalUnits.DAYS)); - final BlockState snowState = BlockTypes.SNOW.get().getDefaultState(); - final BlockState cakeState = BlockTypes.CAKE.get().getDefaultState(); + final BlockState snowState = BlockTypes.SNOW.get().defaultState(); + final BlockState cakeState = BlockTypes.CAKE.get().defaultState(); this.checkWithData(snowState, Keys.LAYER, 4); this.checkWithData(cakeState, Keys.LAYER, 4); @@ -958,7 +958,7 @@ public void testData(final ServerPlayer player) { this.checkOfferData(vex, Keys.LIFE_TICKS, Ticks.of(10)); this.checkGetData(dirtState, Keys.LIGHT_EMISSION, 0); - final BlockState glowstoneState = BlockTypes.GLOWSTONE.get().getDefaultState(); + final BlockState glowstoneState = BlockTypes.GLOWSTONE.get().defaultState(); this.checkGetData(glowstoneState, Keys.LIGHT_EMISSION, 15); final Entity llama = world.createEntity(EntityTypes.LLAMA.get(), position); @@ -970,7 +970,7 @@ public void testData(final ServerPlayer player) { this.checkGetData(dirtState, Keys.MATTER_TYPE, MatterTypes.SOLID.get()); this.checkGetData(waterBlockState, Keys.MATTER_TYPE, MatterTypes.LIQUID.get()); - this.checkGetData(BlockTypes.AIR.get().getDefaultState(), Keys.MATTER_TYPE, MatterTypes.GAS.get()); + this.checkGetData(BlockTypes.AIR.get().defaultState(), Keys.MATTER_TYPE, MatterTypes.GAS.get()); // this.checkOfferData(player, Keys.MAX_AIR, 20); @@ -997,7 +997,7 @@ public void testData(final ServerPlayer player) { // TODO Keys.MIN_SPAWN_DELAY - final BlockState farmlandState = BlockTypes.FARMLAND.get().getDefaultState(); + final BlockState farmlandState = BlockTypes.FARMLAND.get().defaultState(); this.checkWithData(farmlandState, Keys.MOISTURE, 1); final Entity mooshroom = world.createEntity(EntityTypes.MOOSHROOM.get(), position); @@ -1012,7 +1012,7 @@ public void testData(final ServerPlayer player) { // TODO missing supplier // this.checkWithData(noteBlockState, Keys.NOTE_PITCH, NotePitches.E1.get()); -// this.checkOfferData(sheep, Keys.NOTIFIER, player.getUniqueId()); +// this.checkOfferData(sheep, Keys.NOTIFIER, player.uniqueId()); this.checkOfferData(boat, Keys.OCCUPIED_DECELERATION, 2.0); @@ -1056,7 +1056,7 @@ public void testData(final ServerPlayer player) { this.checkWithData(bedState, Keys.PORTION_TYPE, PortionTypes.BOTTOM.get()); this.checkWithData(bedState, Keys.PORTION_TYPE, PortionTypes.TOP.get()); - final BlockState doorState = BlockTypes.ACACIA_DOOR.get().getDefaultState(); + final BlockState doorState = BlockTypes.ACACIA_DOOR.get().defaultState(); this.checkWithData(doorState, Keys.PORTION_TYPE, PortionTypes.TOP.get()); this.checkOfferData(minecartEntity, Keys.POTENTIAL_MAX_SPEED, 20.0); @@ -1070,7 +1070,7 @@ public void testData(final ServerPlayer player) { // this.checkOfferData(potion, Keys.POTION_TYPE, PotionTypes.AWKWARD.get()); // this.checkOfferData(splashPotion, Keys.POTION_TYPE, PotionTypes.MUNDANE.get()); - final BlockState redstoneWireState = BlockTypes.REDSTONE_WIRE.get().getDefaultState(); + final BlockState redstoneWireState = BlockTypes.REDSTONE_WIRE.get().defaultState(); this.checkWithData(redstoneWireState, Keys.POWER, 10); // TODO Keys.PRIMARY_POTION_EFFECT_TYPE @@ -1091,12 +1091,12 @@ public void testData(final ServerPlayer player) { // TODO this.checkOfferData(ravager, Keys.RAID_WAVE, ); - final BlockState railState = BlockTypes.RAIL.get().getDefaultState(); + final BlockState railState = BlockTypes.RAIL.get().defaultState(); this.checkWithData(railState, Keys.RAIL_DIRECTION, RailDirections.ASCENDING_EAST.get()); this.checkOfferData(areaEffectCloud, Keys.REAPPLICATION_DELAY, Ticks.single()); - final BlockState repeaterState = BlockTypes.REPEATER.get().getDefaultState(); + final BlockState repeaterState = BlockTypes.REPEATER.get().defaultState(); this.checkWithData(repeaterState, Keys.REDSTONE_DELAY, 2); this.checkOfferData(sheep, Keys.REMAINING_AIR, 1); @@ -1129,14 +1129,14 @@ public void testData(final ServerPlayer player) { // Keys.SECONDARY_POTION_EFFECT_TYPE - this.checkOfferData(fox, Keys.SECOND_TRUSTED, player.getUniqueId()); + this.checkOfferData(fox, Keys.SECOND_TRUSTED, player.uniqueId()); // Keys.SHOOTER final Entity endCrystal = world.createEntity(EntityTypes.END_CRYSTAL.get(), position); this.checkOfferData(endCrystal, Keys.SHOW_BOTTOM, true); - final BlockState signState = BlockTypes.SPRUCE_SIGN.get().getDefaultState(); + final BlockState signState = BlockTypes.SPRUCE_SIGN.get().defaultState(); world.setBlock(blockPos, signState); final Component emptyText = Component.empty().style(Style.empty()); // TODO signlines component contain font @@ -1154,7 +1154,7 @@ public void testData(final ServerPlayer player) { // Keys.SKY_LIGHT - final BlockState slabState = BlockTypes.BIRCH_SLAB.get().getDefaultState(); + final BlockState slabState = BlockTypes.BIRCH_SLAB.get().defaultState(); this.checkWithData(slabState, Keys.SLAB_PORTION, SlabPortions.BOTTOM.get()); this.checkWithData(slabState, Keys.SLAB_PORTION, SlabPortions.DOUBLE.get()); this.checkWithData(slabState, Keys.SLAB_PORTION, SlabPortions.TOP.get()); @@ -1210,9 +1210,9 @@ public void testData(final ServerPlayer player) { this.checkOfferData(minecartEntity, Keys.VELOCITY, Vector3d.FORWARD); this.checkOfferData(minecartEntity, Keys.SWIFTNESS, 2.0); - this.checkOfferData(horse, Keys.TAMER, player.getUniqueId()); - this.checkOfferData(wolf, Keys.TAMER, player.getUniqueId()); - this.checkOfferData(parrot, Keys.TAMER, player.getUniqueId()); + this.checkOfferData(horse, Keys.TAMER, player.uniqueId()); + this.checkOfferData(wolf, Keys.TAMER, player.uniqueId()); + this.checkOfferData(parrot, Keys.TAMER, player.uniqueId()); this.checkOfferData(parrot, Keys.TAMER, null); this.checkOfferData(zombifiedPiglin, Keys.TARGET_ENTITY, player); @@ -1253,7 +1253,7 @@ public void testData(final ServerPlayer player) { this.checkOfferData(boat, Keys.UNOCCUPIED_DECELERATION, 2.0); - final BlockState tntState = BlockTypes.TNT.get().getDefaultState(); + final BlockState tntState = BlockTypes.TNT.get().defaultState(); this.checkWithData(tntState, Keys.UNSTABLE, true); // Keys.UPDATE_GAME_PROFILE @@ -1303,7 +1303,7 @@ public void testData(final ServerPlayer player) { // Check data holder delegation // serverworld -> serverlocation -> blockstate -> blocktype // blocksnapshot -> blockstate -> blocktype - final BlockState dioriteState = BlockTypes.DIORITE.get().getDefaultState(); + final BlockState dioriteState = BlockTypes.DIORITE.get().defaultState(); world.setBlock(blockPos, dioriteState); final Double destroySpeed = world.get(blockPos, Keys.DESTROY_SPEED).get(); this.checkGetData(location, Keys.DESTROY_SPEED, destroySpeed); @@ -1344,7 +1344,7 @@ private void checkOfferData(final DataHolder.Mutable holder, final Key> boolean checkResult(final DataHolder.Mutable holder, final Key key, final Object value, final DataTransactionResult result) { if (!result.isSuccessful()) { - this.plugin.getLogger().error("Failed offer on {} for {} with {}.", DataTest.getHolderName(holder), key.getKey() + this.plugin.getLogger().error("Failed offer on {} for {} with {}.", DataTest.getHolderName(holder), key.key() .asString(), value); return true; } @@ -1357,28 +1357,28 @@ private void checkGetWeightedData(final DataHolder holder, final Key actual = gotValue.get().get(new Random()); if (!Objects.deepEquals(actual.toArray(), expected.toArray())) { this.plugin.getLogger().error("Value differs om {} for {}.\nExpected: {}\nActual: {}", DataTest.getHolderName(holder), - key.getKey().asString(), expected, actual); + key.key().asString(), expected, actual); } } else { this.plugin.getLogger().error("Value is missing on {} for {}.\nExpected: {}", DataTest.getHolderName(holder), - key.getKey().asString(), expected); + key.key().asString(), expected); } } private void checkGetListData(final DataHolder holder, final Key> key, final List expected) { - this.checkData(holder, key.getKey().asString(), expected, holder.get(key).orElse(null)); + this.checkData(holder, key.key().asString(), expected, holder.get(key).orElse(null)); } private void checkGetSetData(final DataHolder holder, final Key> key, final Set expected) { - this.checkData(holder, key.getKey().asString(), expected, holder.get(key).orElse(null)); + this.checkData(holder, key.key().asString(), expected, holder.get(key).orElse(null)); } private void checkGetMapData(final DataHolder holder, final Key> key, final Map expected) { - this.checkData(holder, key.getKey().asString(), expected, holder.get(key).orElse(null)); + this.checkData(holder, key.key().asString(), expected, holder.get(key).orElse(null)); } private void checkGetData(final DataHolder holder, final Key> key, final T expected) { - this.checkData(holder, key.getKey().asString(), expected, holder.get(key).orElse(null)); + this.checkData(holder, key.key().asString(), expected, holder.get(key).orElse(null)); } private void checkData(final DataHolder holder, final String key, final T expectedValue, @Nullable final T actualValue) { @@ -1395,9 +1395,9 @@ private void checkData(final DataHolder holder, final String key, final T ex private static String getHolderName(final DataHolder holder) { String value = ""; if (holder instanceof BlockState) { - value = RegistryTypes.BLOCK_TYPE.keyFor(Sponge.getGame().registries(), ((BlockState) holder).getType()).getValue(); + value = RegistryTypes.BLOCK_TYPE.keyFor(Sponge.game().registries(), ((BlockState) holder).type()).value(); } else if (holder instanceof ItemStack) { - value = RegistryTypes.ITEM_TYPE.keyFor(Sponge.getGame().registries(), ((ItemStack) holder).getType()).getValue(); + value = RegistryTypes.ITEM_TYPE.keyFor(Sponge.game().registries(), ((ItemStack) holder).type()).value(); } return String.format("%s[%s]", holder.getClass().getSimpleName(), value); } diff --git a/testplugins/src/main/java/org/spongepowered/test/human/HumanTest.java b/testplugins/src/main/java/org/spongepowered/test/human/HumanTest.java index 575fd006ad1..c5124196531 100644 --- a/testplugins/src/main/java/org/spongepowered/test/human/HumanTest.java +++ b/testplugins/src/main/java/org/spongepowered/test/human/HumanTest.java @@ -65,19 +65,19 @@ public HumanTest(final PluginContainer plugin) { @Listener public void onRegisterCommand(final RegisterCommandEvent event) { - final Parameter.Value nameParameter = Parameter.string().setKey("name").optional().build(); - final Parameter.Value mimicParameter = Parameter.string().setKey("mimic_username").optional().build(); + final Parameter.Value nameParameter = Parameter.string().key("name").optional().build(); + final Parameter.Value mimicParameter = Parameter.string().key("mimic_username").optional().build(); event.register(this.plugin, Command .builder() - .parameter(nameParameter) - .parameter(mimicParameter) - .setPermission(this.plugin.getMetadata().getId() + ".command.human.create") - .setExecutor(context -> { - final ServerPlayer player = context.getCause().first(ServerPlayer.class).get(); - final Optional optName = context.getOne(nameParameter); - final String mimicUsername = context.getOne(mimicParameter).orElse(optName.orElse(player.getName())); - final boolean result = this.spawnHuman(player.getServerLocation(), optName.orElse("Human " + player.getName()), mimicUsername); + .addParameter(nameParameter) + .addParameter(mimicParameter) + .permission(this.plugin.getMetadata().getId() + ".command.human.create") + .executor(context -> { + final ServerPlayer player = context.cause().first(ServerPlayer.class).get(); + final Optional optName = context.one(nameParameter); + final String mimicUsername = context.one(mimicParameter).orElse(optName.orElse(player.name())); + final boolean result = this.spawnHuman(player.serverLocation(), optName.orElse("Human " + player.name()), mimicUsername); return result ? CommandResult.success() : CommandResult.error(Component.text("Failed to spawn the human!")); }) .build() @@ -86,10 +86,10 @@ public void onRegisterCommand(final RegisterCommandEvent } public boolean spawnHuman(ServerLocation at, String name, String mimicUsername) { - final Human human = at.getWorld().createEntity(EntityTypes.HUMAN.get(), at.getPosition()); + final Human human = at.world().createEntity(EntityTypes.HUMAN.get(), at.position()); human.offer(Keys.CUSTOM_NAME, Component.text(name)); human.useSkinFor(mimicUsername); - final boolean result = at.getWorld().spawnEntity(human); + final boolean result = at.world().spawnEntity(human); this.initHumanEquipment(human); this.initHumanGoals(human); @@ -98,12 +98,12 @@ public boolean spawnHuman(ServerLocation at, String name, String mimicUsername) } public void initHumanGoals(Human human) { - final GoalExecutor targetGoal = human.getGoal(GoalExecutorTypes.TARGET.get()).orElse(null); + final GoalExecutor targetGoal = human.goal(GoalExecutorTypes.TARGET.get()).orElse(null); // targetGoal.addGoal(0, FindNearestAttackableTargetGoal.builder().chance(1).target(ServerPlayer.class).build(human)); // targetGoal.addGoal(0, FindNearestAttackableTargetGoal.builder().chance(1).target(Monster.class).build(human)); targetGoal.addGoal(1, FindNearestAttackableTargetGoal.builder().chance(1).target(Human.class).build(human)); - final GoalExecutor normalGoal = human.getGoal(GoalExecutorTypes.NORMAL.get()).orElse(null); + final GoalExecutor normalGoal = human.goal(GoalExecutorTypes.NORMAL.get()).orElse(null); normalGoal.addGoal(0, SwimGoal.builder().swimChance(0.8f).build(human)); // normalGoal.addGoal(0, AvoidLivingGoal.builder().targetSelector(l -> l instanceof Creeper).searchDistance(5).closeRangeSpeed(7).farRangeSpeed(2).build(human)); normalGoal.addGoal(1, AttackLivingGoal.builder().longMemory().speed(4).build(human)); diff --git a/testplugins/src/main/java/org/spongepowered/test/interact/InteractTest.java b/testplugins/src/main/java/org/spongepowered/test/interact/InteractTest.java index f379f5e15fe..ba1dba3bbc2 100644 --- a/testplugins/src/main/java/org/spongepowered/test/interact/InteractTest.java +++ b/testplugins/src/main/java/org/spongepowered/test/interact/InteractTest.java @@ -51,45 +51,45 @@ public InteractTest(final PluginContainer plugin) { @Override public void enable(final CommandContext ctx) { - Sponge.getEventManager().registerListeners(this.plugin, new InteractListener()); + Sponge.eventManager().registerListeners(this.plugin, new InteractListener()); } public static class InteractListener { @Listener public void onInteractBlock(final InteractBlockEvent event) { - Sponge.getServer().getBroadcastAudience().sendMessage(Identity.nil(), Component.text("/*************")); - Sponge.getServer().getBroadcastAudience().sendMessage(Identity.nil(), Component.text().append(Component.text("/* Event: ")).append(Component.text(event.getClass().getSimpleName())).build()); - Sponge.getServer().getBroadcastAudience().sendMessage(Identity.nil(), + Sponge.server().broadcastAudience().sendMessage(Identity.nil(), Component.text("/*************")); + Sponge.server().broadcastAudience().sendMessage(Identity.nil(), Component.text().append(Component.text("/* Event: ")).append(Component.text(event.getClass().getSimpleName())).build()); + Sponge.server().broadcastAudience().sendMessage(Identity.nil(), Component.text().append(Component.text("/* Hand: ")) - .append(Component.text(event.getContext().get(EventContextKeys.USED_HAND).map(h -> RegistryTypes.HAND_TYPE.keyFor(Sponge.getGame().registries(), h).getFormatted()).orElse("UNKNOWN"))) + .append(Component.text(event.context().get(EventContextKeys.USED_HAND).map(h -> RegistryTypes.HAND_TYPE.keyFor(Sponge.game().registries(), h).formatted()).orElse("UNKNOWN"))) .build() ); - Sponge.getGame().getSystemSubject().sendMessage(Identity.nil(), Component.text().append(Component.text("/ Cause: ")).append(Component.text(event.getCause().all().toString())).build()); - Sponge.getGame().getSystemSubject().sendMessage(Identity.nil(), Component.text().append(Component.text("/ Context: ")).append(Component.text(event.getContext().toString())).build()); + Sponge.game().systemSubject().sendMessage(Identity.nil(), Component.text().append(Component.text("/ Cause: ")).append(Component.text(event.cause().all().toString())).build()); + Sponge.game().systemSubject().sendMessage(Identity.nil(), Component.text().append(Component.text("/ Context: ")).append(Component.text(event.context().toString())).build()); } @Listener public void onInteractItem(final InteractItemEvent event) { - Sponge.getServer().getBroadcastAudience().sendMessage(Identity.nil(), Component.text("/*************")); - Sponge.getServer().getBroadcastAudience().sendMessage(Identity.nil(), Component.text().append(Component.text("/* Event: ")).append(Component.text(event.getClass().getSimpleName())).build()); - Sponge.getServer().getBroadcastAudience().sendMessage(Identity.nil(), + Sponge.server().broadcastAudience().sendMessage(Identity.nil(), Component.text("/*************")); + Sponge.server().broadcastAudience().sendMessage(Identity.nil(), Component.text().append(Component.text("/* Event: ")).append(Component.text(event.getClass().getSimpleName())).build()); + Sponge.server().broadcastAudience().sendMessage(Identity.nil(), Component.text().append(Component.text("/* Hand: ")) - .append(Component.text(event.getContext().get(EventContextKeys.USED_HAND).map(h -> RegistryTypes.HAND_TYPE.keyFor(Sponge.getGame().registries(), h).getFormatted()).orElse("UNKNOWN"))) + .append(Component.text(event.context().get(EventContextKeys.USED_HAND).map(h -> RegistryTypes.HAND_TYPE.keyFor(Sponge.game().registries(), h).formatted()).orElse("UNKNOWN"))) .build() ); - Sponge.getGame().getSystemSubject().sendMessage(Identity.nil(), Component.text().append(Component.text("/ Cause: ")).append(Component.text(event.getCause().all().toString())).build()); - Sponge.getGame().getSystemSubject().sendMessage(Identity.nil(), Component.text().append(Component.text("/ Context: ")).append(Component.text(event.getContext().toString())).build()); + Sponge.game().systemSubject().sendMessage(Identity.nil(), Component.text().append(Component.text("/ Cause: ")).append(Component.text(event.cause().all().toString())).build()); + Sponge.game().systemSubject().sendMessage(Identity.nil(), Component.text().append(Component.text("/ Context: ")).append(Component.text(event.context().toString())).build()); } @Listener public void onInteractEntity(final InteractEntityEvent event) { - Sponge.getServer().getBroadcastAudience().sendMessage(Identity.nil(), Component.text("/*************")); - Sponge.getServer().getBroadcastAudience().sendMessage(Identity.nil(), Component.text().append(Component.text("/* Event: ")).append(Component.text(event.getClass().getSimpleName())).build()); - Sponge.getServer().getBroadcastAudience().sendMessage(Identity.nil(), + Sponge.server().broadcastAudience().sendMessage(Identity.nil(), Component.text("/*************")); + Sponge.server().broadcastAudience().sendMessage(Identity.nil(), Component.text().append(Component.text("/* Event: ")).append(Component.text(event.getClass().getSimpleName())).build()); + Sponge.server().broadcastAudience().sendMessage(Identity.nil(), Component.text().append(Component.text("/* Hand: ")) - .append(Component.text(event.getContext().get(EventContextKeys.USED_HAND).map(h -> RegistryTypes.HAND_TYPE.keyFor(Sponge.getGame().registries(), h).getFormatted()).orElse("UNKNOWN"))) + .append(Component.text(event.context().get(EventContextKeys.USED_HAND).map(h -> RegistryTypes.HAND_TYPE.keyFor(Sponge.game().registries(), h).formatted()).orElse("UNKNOWN"))) .build() ); - Sponge.getGame().getSystemSubject().sendMessage(Identity.nil(), Component.text().append(Component.text("/ Cause: ")).append(Component.text(event.getCause().all().toString())).build()); - Sponge.getGame().getSystemSubject().sendMessage(Identity.nil(), Component.text().append(Component.text("/ Context: ")).append(Component.text(event.getContext().toString())).build()); + Sponge.game().systemSubject().sendMessage(Identity.nil(), Component.text().append(Component.text("/ Cause: ")).append(Component.text(event.cause().all().toString())).build()); + Sponge.game().systemSubject().sendMessage(Identity.nil(), Component.text().append(Component.text("/ Context: ")).append(Component.text(event.context().toString())).build()); } } } diff --git a/testplugins/src/main/java/org/spongepowered/test/inventory/InventoryTest.java b/testplugins/src/main/java/org/spongepowered/test/inventory/InventoryTest.java index 62ca45a1477..370ecd79f3c 100644 --- a/testplugins/src/main/java/org/spongepowered/test/inventory/InventoryTest.java +++ b/testplugins/src/main/java/org/spongepowered/test/inventory/InventoryTest.java @@ -85,7 +85,7 @@ public InventoryTestListener(final PluginContainer plugin) { @Listener public void onInteractContainerOpen(final InteractContainerEvent.Open event) { - final Container container = event.getContainer(); + final Container container = event.container(); final Hotbar hotbarFromContain = container.query(Hotbar.class).orElse(null); final Hotbar hotbarFromPrimary = container.query(PrimaryPlayerInventory.class).get().query(Hotbar.class).orElse(null); final Inventory stoneFromContain = hotbarFromContain.query(QueryTypes.ITEM_TYPE, ItemTypes.STONE.get()); @@ -114,13 +114,13 @@ public void onInteractContainerOpen(final InteractContainerEvent.Open event) { @Listener public void onInteractContainer(final InteractContainerEvent event) { if (event instanceof EnchantItemEvent) { - this.plugin.getLogger().info("{} [{}] S:{}", event.getClass().getSimpleName(), ((EnchantItemEvent) event).getOption(), - ((EnchantItemEvent) event).getSeed()); + this.plugin.getLogger().info("{} [{}] S:{}", event.getClass().getSimpleName(), ((EnchantItemEvent) event).option(), + ((EnchantItemEvent) event).seed()); } - final Optional component = event.getContainer().get(Keys.DISPLAY_NAME); + final Optional component = event.container().get(Keys.DISPLAY_NAME); final String title = component.map(c -> PlainComponentSerializer.plain().serialize(c)).orElse("No Title"); if (title.equals("Foobar")) { - InventoryTest.doFancyStuff(event.getCause().first(Player.class).get()); + InventoryTest.doFancyStuff(event.cause().first(Player.class).get()); } } @@ -128,29 +128,29 @@ public void onInteractContainer(final InteractContainerEvent event) { public void onInteract(final ChangeInventoryEvent event) { if (event instanceof ClickContainerEvent) { - this.plugin.getLogger().info("{} {}", event.getClass().getSimpleName(), ((ClickContainerEvent) event).getContainer().getClass().getSimpleName()); - final Transaction cursor = ((ClickContainerEvent) event).getCursorTransaction(); - this.plugin.getLogger().info(" Cursor: {}x{}->{}x{}", cursor.getOriginal().getType(), cursor.getOriginal().getQuantity(), - cursor.getFinal().getType(), cursor.getFinal().getQuantity()); + this.plugin.getLogger().info("{} {}", event.getClass().getSimpleName(), ((ClickContainerEvent) event).container().getClass().getSimpleName()); + final Transaction cursor = ((ClickContainerEvent) event).cursorTransaction(); + this.plugin.getLogger().info(" Cursor: {}x{}->{}x{}", cursor.original().type(), cursor.original().quantity(), + cursor.finalReplacement().type(), cursor.finalReplacement().quantity()); } else { - this.plugin.getLogger().info("{} {}", event.getClass().getSimpleName(), event.getInventory().getClass().getSimpleName()); + this.plugin.getLogger().info("{} {}", event.getClass().getSimpleName(), event.inventory().getClass().getSimpleName()); } - for (final SlotTransaction slotTrans : event.getTransactions()) { - final Optional integer = slotTrans.getSlot().get(Keys.SLOT_INDEX); - this.plugin.getLogger().info(" SlotTr: {}x{}->{}x{}[{}]", slotTrans.getOriginal().getType(), slotTrans.getOriginal().getQuantity(), - slotTrans.getFinal().getType(), slotTrans.getFinal().getQuantity(), integer.get()); + for (final SlotTransaction slotTrans : event.transactions()) { + final Optional integer = slotTrans.slot().get(Keys.SLOT_INDEX); + this.plugin.getLogger().info(" SlotTr: {}x{}->{}x{}[{}]", slotTrans.original().type(), slotTrans.original().quantity(), + slotTrans.finalReplacement().type(), slotTrans.finalReplacement().quantity(), integer.get()); } } @Listener public void onTransfer(final TransferInventoryEvent event) { if (event instanceof TransferInventoryEvent.Post) { - this.plugin.getLogger().info("{} {}=>{}", event.getClass().getSimpleName(), event.getSourceInventory().getClass().getSimpleName(), event.getTargetInventory() + this.plugin.getLogger().info("{} {}=>{}", event.getClass().getSimpleName(), event.sourceInventory().getClass().getSimpleName(), event.targetInventory() .getClass().getSimpleName()); - final Integer sourceIdx = ((TransferInventoryEvent.Post) event).getSourceSlot().get(Keys.SLOT_INDEX).get(); - final Integer targetIdx = ((TransferInventoryEvent.Post) event).getTargetSlot().get(Keys.SLOT_INDEX).get(); - final ItemStackSnapshot item = ((TransferInventoryEvent.Post) event).getTransferredItem(); - this.plugin.getLogger().info("[{}] -> [{}] {}x{}", sourceIdx, targetIdx, item.getType(), item.getQuantity()); + final Integer sourceIdx = ((TransferInventoryEvent.Post) event).sourceSlot().get(Keys.SLOT_INDEX).get(); + final Integer targetIdx = ((TransferInventoryEvent.Post) event).targetSlot().get(Keys.SLOT_INDEX).get(); + final ItemStackSnapshot item = ((TransferInventoryEvent.Post) event).transferredItem(); + this.plugin.getLogger().info("[{}] -> [{}] {}x{}", sourceIdx, targetIdx, item.type(), item.quantity()); } } @@ -158,19 +158,19 @@ public void onTransfer(final TransferInventoryEvent event) { public void onCraft(CraftItemEvent event) { // this.plugin.getLogger().info("{} size: {} recipe: {} ", // event.getClass().getSimpleName(), -// event.getCraftingInventory().capacity(), -// event.getRecipe().map(Recipe::getKey).map(ResourceKey::asString).orElse("no recipe")); +// event.craftingInventory().capacity(), +// event.recipe().map(Recipe::getKey).map(ResourceKey::asString).orElse("no recipe")); } } @Override public void enable(final CommandContext ctx) { - Sponge.getEventManager().registerListeners(this.plugin, new InventoryTestListener(this.plugin)); + Sponge.eventManager().registerListeners(this.plugin, new InventoryTestListener(this.plugin)); } private static void doFancyStuff(final Player player) { - final GridInventory inv27Grid = player.getInventory().query(PrimaryPlayerInventory.class).get().getStorage(); + final GridInventory inv27Grid = player.inventory().query(PrimaryPlayerInventory.class).get().storage(); final Inventory inv27Slots = Inventory.builder().slots(27).completeStructure().build(); final Inventory inv27Slots2 = Inventory.builder().slots(27).completeStructure().build(); final ViewableInventory doubleMyInventory = ViewableInventory.builder().type(ContainerTypes.GENERIC_9X6.get()) @@ -267,7 +267,7 @@ public boolean handle(final Cause cause, final Container container, final Slot s // Inventory mixedComposite = Inventory.builder().inventory(grids).slots(1).inventory(container).completeStructure().build(); // } // if (container instanceof DispenserContainer) { - // final GridInventory inv27Grid = ((PlayerInventory)player.inventory).query(PrimaryPlayerInventory.class).get().getStorage(); + // final GridInventory inv27Grid = ((PlayerInventory)player.inventory).query(PrimaryPlayerInventory.class).get().storage(); // final Inventory inv27Slots = Inventory.builder().slots(27).completeStructure().build(); // final Inventory inv27Slots2 = Inventory.builder().slots(27).completeStructure().build(); // final ViewableInventory doubleMyInventory = ViewableInventory.builder().type(ContainerTypes.GENERIC_9x6.get()) diff --git a/testplugins/src/main/java/org/spongepowered/test/map/MapTest.java b/testplugins/src/main/java/org/spongepowered/test/map/MapTest.java index 4157ec8dc00..f0a7b9f36c1 100644 --- a/testplugins/src/main/java/org/spongepowered/test/map/MapTest.java +++ b/testplugins/src/main/java/org/spongepowered/test/map/MapTest.java @@ -112,100 +112,100 @@ public MapTest(final Logger logger) { @Listener public void onGameInit(final RegisterCommandEvent event) { final Command.Builder builder = Command.builder(); - builder.child(Command.builder().setExecutor((this::printMapData)).build(), "printMapData"); - builder.child(Command.builder().setExecutor((this::setMapNether)).build(), "setmapnether"); - builder.child(Command.builder().setExecutor((this::setColorAndLocked)).build(), "setColorAndLocked"); - builder.child(Command.builder().setExecutor((this::saveToFile)).build(), "saveMapToFile"); - builder.child(Command.builder().setExecutor((this::savePallete)).build(), "savePalleteToFile"); - builder.child(Command.builder().setExecutor((this::loadMapFromFile)).build(), "loadMapFromFile"); - builder.child(Command.builder().setExecutor((this::listMaps)).build(), "listMaps"); - builder.child(Command.builder().setExecutor((this::randomDecorations)).build(), "randomDecorations"); - builder.child(Command.builder().setExecutor((this::orientDecorationsDown)).build(), "orientDecorationsDown"); - builder.child(Command.builder().setExecutor((this::getMapUUID)).build(), "getmapuuid"); - builder.child(Command.builder().setExecutor((this::testMapSerialization)).build(), "testmapserialization"); - builder.child(Command.builder().setExecutor((this::create)).build(), "create"); - final Parameter.Value uuidParameter = Parameter.uuid().setKey("uuid").build(); - builder.child(Command.builder().parameter(Parameter.uuid().setKey("uuid").build()).setExecutor(ctx -> { + builder.addChild(Command.builder().executor((this::printMapData)).build(), "printMapData"); + builder.addChild(Command.builder().executor((this::setMapNether)).build(), "setmapnether"); + builder.addChild(Command.builder().executor((this::setColorAndLocked)).build(), "setColorAndLocked"); + builder.addChild(Command.builder().executor((this::saveToFile)).build(), "saveMapToFile"); + builder.addChild(Command.builder().executor((this::savePallete)).build(), "savePalleteToFile"); + builder.addChild(Command.builder().executor((this::loadMapFromFile)).build(), "loadMapFromFile"); + builder.addChild(Command.builder().executor((this::listMaps)).build(), "listMaps"); + builder.addChild(Command.builder().executor((this::randomDecorations)).build(), "randomDecorations"); + builder.addChild(Command.builder().executor((this::orientDecorationsDown)).build(), "orientDecorationsDown"); + builder.addChild(Command.builder().executor((this::getMapUUID)).build(), "getmapuuid"); + builder.addChild(Command.builder().executor((this::testMapSerialization)).build(), "testmapserialization"); + builder.addChild(Command.builder().executor((this::create)).build(), "create"); + final Parameter.Value uuidParameter = Parameter.uuid().key("uuid").build(); + builder.addChild(Command.builder().addParameter(Parameter.uuid().key("uuid").build()).executor(ctx -> { return this.getMapFromUUID(uuidParameter, ctx); }).build(), "getmapfromuuid"); - builder.child(Command.builder().setExecutor((this::testMapShades)).build(), "testmapshades"); - builder.child(Command.builder().setExecutor((this::enableUnlimitedTracking)).build(), "enableunlimitedtracking"); - builder.child(Command.builder().setExecutor((this::addNamedDecoration)).build(), "addnameddecoration"); - builder.child(Command.builder().setExecutor((this::addWorldBanner)).build(), "addworldbanner"); - builder.child(Command.builder().setExecutor((this::recenterMap)).build(), "recentermap"); - builder.child(Command.builder().setExecutor((this::setMapWorld)).build(), "setmapworld"); + builder.addChild(Command.builder().executor((this::testMapShades)).build(), "testmapshades"); + builder.addChild(Command.builder().executor((this::enableUnlimitedTracking)).build(), "enableunlimitedtracking"); + builder.addChild(Command.builder().executor((this::addNamedDecoration)).build(), "addnameddecoration"); + builder.addChild(Command.builder().executor((this::addWorldBanner)).build(), "addworldbanner"); + builder.addChild(Command.builder().executor((this::recenterMap)).build(), "recentermap"); + builder.addChild(Command.builder().executor((this::setMapWorld)).build(), "setmapworld"); event.register(this.container, builder.build(), "maptest"); } - private CommandResult getMapFromUUID(Parameter.Value uuidParameter, CommandContext ctx) throws CommandException { + private CommandResult getMapFromUUID(final Parameter.Value uuidParameter, final CommandContext ctx) throws CommandException { final Player player = this.requirePlayer(ctx); - final UUID uuid = ctx.getOne(uuidParameter).get(); + final UUID uuid = ctx.one(uuidParameter).get(); final ItemStack itemStack = ItemStack.of(ItemTypes.FILLED_MAP, 1); - final MapInfo mapInfo = Sponge.getServer().getMapStorage().getMapInfo(uuid) + final MapInfo mapInfo = Sponge.server().mapStorage().mapInfo(uuid) .orElseThrow(() -> new CommandException(Component.text("UUID " + uuid + " was not a valid map uuid!"))); itemStack.offer(Keys.MAP_INFO, mapInfo); - player.getInventory().offer(itemStack); + player.inventory().offer(itemStack); return CommandResult.success(); } - private CommandResult setMapWorld(CommandContext ctx) throws CommandException { + private CommandResult setMapWorld(final CommandContext ctx) throws CommandException { final Player player = this.requirePlayer(ctx); - final ItemStack heldMap = player.getItemInHand(HandTypes.MAIN_HAND); - if (heldMap.getType() != ItemTypes.FILLED_MAP.get()) { + final ItemStack heldMap = player.itemInHand(HandTypes.MAIN_HAND); + if (heldMap.type() != ItemTypes.FILLED_MAP.get()) { throw new CommandException(Component.text("You must hold a map in your hand")); } - MapInfo mapInfo = heldMap.require(Keys.MAP_INFO); - ServerWorld serverWorld = (ServerWorld) player.getLocation().getWorld(); - mapInfo.offer(Keys.MAP_WORLD, serverWorld.getKey()); + final MapInfo mapInfo = heldMap.require(Keys.MAP_INFO); + final ServerWorld serverWorld = (ServerWorld) player.location().world(); + mapInfo.offer(Keys.MAP_WORLD, serverWorld.key()); player.sendMessage(Component.text("New map world: " + mapInfo.require(Keys.MAP_WORLD))); return CommandResult.success(); } - private CommandResult recenterMap(CommandContext ctx) throws CommandException { + private CommandResult recenterMap(final CommandContext ctx) throws CommandException { final Player player = this.requirePlayer(ctx); - final ItemStack heldMap = player.getItemInHand(HandTypes.MAIN_HAND); - if (heldMap.getType() != ItemTypes.FILLED_MAP.get()) { + final ItemStack heldMap = player.itemInHand(HandTypes.MAIN_HAND); + if (heldMap.type() != ItemTypes.FILLED_MAP.get()) { throw new CommandException(Component.text("You must hold a map in your hand")); } - MapInfo mapInfo = heldMap.require(Keys.MAP_INFO); - mapInfo.offer(Keys.MAP_LOCATION, player.getLocation().getBlockPosition().toVector2(true)); + final MapInfo mapInfo = heldMap.require(Keys.MAP_INFO); + mapInfo.offer(Keys.MAP_LOCATION, player.location().blockPosition().toVector2(true)); player.sendMessage(Component.text("New center " + mapInfo.require(Keys.MAP_LOCATION))); return CommandResult.success(); } - private CommandResult addWorldBanner(CommandContext ctx) throws CommandException { + private CommandResult addWorldBanner(final CommandContext ctx) throws CommandException { final Player player = this.requirePlayer(ctx); - final ItemStack heldMap = player.getItemInHand(HandTypes.MAIN_HAND); - if (heldMap.getType() != ItemTypes.FILLED_MAP.get()) { + final ItemStack heldMap = player.itemInHand(HandTypes.MAIN_HAND); + if (heldMap.type() != ItemTypes.FILLED_MAP.get()) { throw new CommandException(Component.text("You must hold a map in your hand")); } - MapInfo mapInfo = heldMap.require(Keys.MAP_INFO); - RayTraceResult hit = RayTrace.block() + final MapInfo mapInfo = heldMap.require(Keys.MAP_INFO); + final RayTraceResult hit = RayTrace.block() .sourcePosition(player) .direction(player) - .world(player.getServerLocation().getWorld()) + .world(player.serverLocation().world()) .continueWhileBlock(RayTrace.onlyAir()) .limit(100) - .select(a -> a.getLocation().getBlockEntity().filter(entity -> entity instanceof Banner).isPresent()) + .select(a -> a.location().blockEntity().filter(entity -> entity instanceof Banner).isPresent()) .execute() .orElseThrow(() -> new CommandException(Component.text("You must look at a banner"))); - mapInfo.addBannerDecoration(hit.getSelectedObject().getServerLocation()); + mapInfo.addBannerDecoration(hit.selectedObject().serverLocation()); return CommandResult.success(); } - private CommandResult addNamedDecoration(CommandContext ctx) throws CommandException { + private CommandResult addNamedDecoration(final CommandContext ctx) throws CommandException { final Player player = this.requirePlayer(ctx); - final ItemStack heldMap = player.getItemInHand(HandTypes.MAIN_HAND); - if (heldMap.getType() != ItemTypes.FILLED_MAP.get()) { + final ItemStack heldMap = player.itemInHand(HandTypes.MAIN_HAND); + if (heldMap.type() != ItemTypes.FILLED_MAP.get()) { throw new CommandException(Component.text("You must hold a map in your hand")); } - MapDecoration decoration = MapDecoration.builder() + final MapDecoration decoration = MapDecoration.builder() .type(MapDecorationTypes.BANNER_BLUE) .customName(Component.text("I AM A ").color(NamedTextColor.BLUE).append(BlockTypes.BLUE_BANNER.get())) .rotation(MapDecorationOrientations.NORTH) @@ -214,39 +214,39 @@ private CommandResult addNamedDecoration(CommandContext ctx) throws CommandExcep return CommandResult.success(); } - private CommandResult enableUnlimitedTracking(CommandContext ctx) throws CommandException { + private CommandResult enableUnlimitedTracking(final CommandContext ctx) throws CommandException { final Player player = this.requirePlayer(ctx); - final ItemStack heldMap = player.getItemInHand(HandTypes.MAIN_HAND); + final ItemStack heldMap = player.itemInHand(HandTypes.MAIN_HAND); - if (heldMap.getType() != ItemTypes.FILLED_MAP.get()) { + if (heldMap.type() != ItemTypes.FILLED_MAP.get()) { throw new CommandException(Component.text("You must hold a map in your hand")); } heldMap.require(Keys.MAP_INFO).offer(Keys.MAP_UNLIMITED_TRACKING, true); return CommandResult.success(); } - private CommandResult testMapShades(CommandContext ctx) throws CommandException { + private CommandResult testMapShades(final CommandContext ctx) throws CommandException { final Player player = this.requirePlayer(ctx); - for (RegistryEntry entry : Sponge.getGame().registries().registry(RegistryTypes.MAP_SHADE)) { + for (final RegistryEntry entry : Sponge.game().registries().registry(RegistryTypes.MAP_SHADE)) { final MapColor mapColor = MapColor.of(MapColorTypes.COLOR_GREEN.get(), entry.value()); final MapCanvas mapCanvas = MapCanvas.builder().paintAll(mapColor).build(); - final MapInfo mapInfo = Sponge.getServer().getMapStorage() + final MapInfo mapInfo = Sponge.server().mapStorage() .createNewMapInfo() .orElseThrow(() -> new CommandException(Component.text("Unable to create new map!"))); mapInfo.offer(Keys.MAP_LOCKED, true); mapInfo.offer(Keys.MAP_CANVAS, mapCanvas); - ItemStack itemStack = ItemStack.of(ItemTypes.FILLED_MAP); + final ItemStack itemStack = ItemStack.of(ItemTypes.FILLED_MAP); itemStack.offer(Keys.MAP_INFO, mapInfo); - itemStack.offer(Keys.DISPLAY_NAME, Component.text(entry.key().getFormatted())); + itemStack.offer(Keys.DISPLAY_NAME, Component.text(entry.key().formatted())); - player.getInventory().getPrimary().offer(itemStack); + player.inventory().primary().offer(itemStack); } return CommandResult.success(); } - private CommandResult create(CommandContext ctx) throws CommandException { + private CommandResult create(final CommandContext ctx) throws CommandException { final Player player = this.requirePlayer(ctx); - final MapInfo mapInfo = Sponge.getServer().getMapStorage() + final MapInfo mapInfo = Sponge.server().mapStorage() .createNewMapInfo() .orElseThrow(() -> new CommandException(Component.text("Map creation was cancelled!"))); final ItemStack itemStack = ItemStack.of(ItemTypes.FILLED_MAP, 1); @@ -255,23 +255,23 @@ private CommandResult create(CommandContext ctx) throws CommandException { .build(); mapInfo.offer(Keys.MAP_CANVAS, canvas); mapInfo.offer(Keys.MAP_LOCKED, true); - mapInfo.offer(Keys.MAP_LOCATION, player.getPosition().toInt().toVector2(true)); + mapInfo.offer(Keys.MAP_LOCATION, player.position().toInt().toVector2(true)); itemStack.offer(Keys.MAP_INFO, mapInfo); - player.getInventory().offer(itemStack); + player.inventory().offer(itemStack); return CommandResult.success(); } - private CommandResult testMapSerialization(CommandContext ctx) { + private CommandResult testMapSerialization(final CommandContext ctx) { MapInfo mapInfo = null; - Audience audience = ctx.getCause().getAudience(); + final Audience audience = ctx.cause().audience(); if (audience instanceof Player) { final Player player = (Player) audience; - mapInfo = player.getItemInHand(HandTypes.MAIN_HAND).get(Keys.MAP_INFO) + mapInfo = player.itemInHand(HandTypes.MAIN_HAND).get(Keys.MAP_INFO) .orElse(null); } - final MapStorage mapStorage = Sponge.getServer().getMapStorage(); + final MapStorage mapStorage = Sponge.server().mapStorage(); if (mapInfo == null) { - mapInfo = mapStorage.getAllMapInfos() + mapInfo = mapStorage.allMapInfos() .stream().findAny() .orElse(mapStorage.createNewMapInfo().get()); } @@ -309,32 +309,32 @@ private CommandResult testMapSerialization(CommandContext ctx) { return CommandResult.success(); } - private CommandResult getMapUUID(CommandContext ctx) throws CommandException { + private CommandResult getMapUUID(final CommandContext ctx) throws CommandException { final Player player = this.requirePlayer(ctx); - final ItemStack map = player.getItemInHand(HandTypes.MAIN_HAND); - if (map.getType() != ItemTypes.FILLED_MAP.get()) { + final ItemStack map = player.itemInHand(HandTypes.MAIN_HAND); + if (map.type() != ItemTypes.FILLED_MAP.get()) { throw new CommandException(Component.text("You must hold a map in your hand!")); } - final Component uuid = Component.text(map.require(Keys.MAP_INFO).getUniqueId().toString()); + final Component uuid = Component.text(map.require(Keys.MAP_INFO).uniqueId().toString()); player.sendMessage(uuid); this.logger.info("map uuid: " + uuid); return CommandResult.success(); } - private CommandResult orientDecorationsDown(CommandContext ctx) throws CommandException { + private CommandResult orientDecorationsDown(final CommandContext ctx) throws CommandException { final Player player = this.requirePlayer(ctx); - final ItemStack heldMap = player.getItemInHand(HandTypes.MAIN_HAND); - if (heldMap.getType() != ItemTypes.FILLED_MAP.get()) { + final ItemStack heldMap = player.itemInHand(HandTypes.MAIN_HAND); + if (heldMap.type() != ItemTypes.FILLED_MAP.get()) { throw new CommandException(Component.text("You must hold a map in your hand")); } heldMap.require(Keys.MAP_INFO).require(Keys.MAP_DECORATIONS).forEach(decoration -> decoration.setRotation(MapDecorationOrientations.SOUTH)); return CommandResult.success(); } - private CommandResult randomDecorations(CommandContext ctx) throws CommandException { + private CommandResult randomDecorations(final CommandContext ctx) throws CommandException { final Player player = this.requirePlayer(ctx); - final ItemStack heldMap = player.getItemInHand(HandTypes.MAIN_HAND); - if (heldMap.getType() != ItemTypes.FILLED_MAP.get()) { + final ItemStack heldMap = player.itemInHand(HandTypes.MAIN_HAND); + if (heldMap.type() != ItemTypes.FILLED_MAP.get()) { throw new CommandException(Component.text("You must hold a map in your hand")); } player.sendMessage(Component.text("Getting mapInfo")); @@ -345,17 +345,17 @@ private CommandResult randomDecorations(CommandContext ctx) throws CommandExcept int y = Byte.MIN_VALUE; final List types = RegistryTypes.MAP_DECORATION_TYPE.get().stream().collect(Collectors.toList()); - Collection orientations = Sponge.getGame().registries().registry(RegistryTypes.MAP_DECORATION_ORIENTATION).stream().collect(Collectors.toList()); + final Collection orientations = Sponge.game().registries().registry(RegistryTypes.MAP_DECORATION_ORIENTATION).stream().collect(Collectors.toList()); player.sendMessage(Component.text("Number of orientations: " + orientations.size())); player.sendMessage(Component.text("EAST: " + MapDecorationOrientations.EAST.get().key(RegistryTypes.MAP_DECORATION_ORIENTATION).toString())); for (final MapDecorationOrientation dir : orientations) { decorations.add( MapDecoration.builder() - .type(types.get(player.getRandom().nextInt(types.size()))) + .type(types.get(player.random().nextInt(types.size()))) .rotation(dir) .position(Vector2i.from(x, y)) .build()); - player.sendMessage(Component.text(dir.key(RegistryTypes.MAP_DECORATION_ORIENTATION).getValue()).append(Component.text("x: " + x)).append(Component.text("y: " + y))); + player.sendMessage(Component.text(dir.key(RegistryTypes.MAP_DECORATION_ORIENTATION).value()).append(Component.text("x: " + x)).append(Component.text("y: " + y))); x += 16; if (x > Byte.MAX_VALUE) { y += 16; @@ -371,8 +371,8 @@ private CommandResult randomDecorations(CommandContext ctx) throws CommandExcept return CommandResult.success(); } - private CommandResult listMaps(CommandContext ctx) { - final Collection mapInfos = Sponge.getServer().getMapStorage().getAllMapInfos(); + private CommandResult listMaps(final CommandContext ctx) { + final Collection mapInfos = Sponge.server().mapStorage().allMapInfos(); ctx.sendMessage(Identity.nil(), Component.text(mapInfos.size())); final List list = new ArrayList<>(mapInfos); list.sort(Comparator.comparingInt(info -> info.toContainer().getInt(DataQuery.of("UnsafeMapId")).get())); @@ -382,10 +382,10 @@ private CommandResult listMaps(CommandContext ctx) { return CommandResult.success(); } - private CommandResult loadMapFromFile(CommandContext ctx) throws CommandException { + private CommandResult loadMapFromFile(final CommandContext ctx) throws CommandException { final Player player = this.requirePlayer(ctx); - final ItemStack map = player.getItemInHand(HandTypes.MAIN_HAND); - if (map.getType() != ItemTypes.FILLED_MAP.get()) { + final ItemStack map = player.itemInHand(HandTypes.MAIN_HAND); + if (map.type() != ItemTypes.FILLED_MAP.get()) { throw new CommandException(Component.text("You must hold a map in your hand")); } final File file = new File("map.png"); @@ -415,7 +415,7 @@ private CommandResult loadMapFromFile(CommandContext ctx) throws CommandExceptio return CommandResult.success(); } - private CommandResult savePallete(CommandContext ctx) { + private CommandResult savePallete(final CommandContext ctx) { final File file = new File("pallete.png"); try { if (!file.isFile()) { @@ -424,7 +424,7 @@ private CommandResult savePallete(CommandContext ctx) { final MapCanvas.Builder builder = MapCanvas.builder(); final List mapColors = new ArrayList<>(); - for (MapColorType mapColorType : Sponge.getGame().registries().registry(RegistryTypes.MAP_COLOR_TYPE).stream().collect(Collectors.toList())) { + for (final MapColorType mapColorType : Sponge.game().registries().registry(RegistryTypes.MAP_COLOR_TYPE).stream().collect(Collectors.toList())) { final MapColor[] colors = new MapColor[] { MapColor.of(mapColorType), MapColor.builder().baseColor(mapColorType).darkest().build(), @@ -449,15 +449,15 @@ private CommandResult savePallete(CommandContext ctx) { final Color color = new Color(0,0,0,0); ImageIO.write((BufferedImage) canvas.toImage(color),"png", file); } catch (final IOException e) { - Sponge.getServer().sendMessage(Component.text("IOException")); + Sponge.server().sendMessage(Component.text("IOException")); } return CommandResult.success(); } - private CommandResult saveToFile(CommandContext ctx) throws CommandException { + private CommandResult saveToFile(final CommandContext ctx) throws CommandException { final Player player = this.requirePlayer(ctx); - final ItemStack map = player.getItemInHand(HandTypes.MAIN_HAND); - if (map.getType() != ItemTypes.FILLED_MAP.get()) { + final ItemStack map = player.itemInHand(HandTypes.MAIN_HAND); + if (map.type() != ItemTypes.FILLED_MAP.get()) { throw new CommandException(Component.text("You must hold a map in your hand")); } final Image image = map.require(Keys.MAP_INFO).require(Keys.MAP_CANVAS).toImage(); @@ -479,10 +479,10 @@ private CommandResult saveToFile(CommandContext ctx) throws CommandException { return CommandResult.success(); } - private CommandResult setColorAndLocked(CommandContext ctx) throws CommandException { + private CommandResult setColorAndLocked(final CommandContext ctx) throws CommandException { final Player player = this.requirePlayer(ctx); - final ItemStack map = player.getItemInHand(HandTypes.MAIN_HAND); - if (map.getType() != ItemTypes.FILLED_MAP.get()) { + final ItemStack map = player.itemInHand(HandTypes.MAIN_HAND); + if (map.type() != ItemTypes.FILLED_MAP.get()) { throw new CommandException(Component.text("You must hold a map in your hand")); } //map.offer(Keys.MAP_LOCATION, new Vector2i(10000,10000)); @@ -490,21 +490,21 @@ private CommandResult setColorAndLocked(CommandContext ctx) throws CommandExcept final MapInfo mapInfo = map.require(Keys.MAP_INFO); mapInfo.offer(Keys.MAP_LOCKED, true); mapInfo.offer(Keys.MAP_CANVAS, MapCanvas.builder().paintAll(color).build()); - player.sendMessage(Component.text(mapInfo.require(Keys.MAP_CANVAS).getColor(0,0).toContainer().toString())); + player.sendMessage(Component.text(mapInfo.require(Keys.MAP_CANVAS).color(0,0).toContainer().toString())); return CommandResult.success(); } - private CommandResult setMapNether(CommandContext ctx) throws CommandException { - Audience audience = ctx.getCause().getAudience(); + private CommandResult setMapNether(final CommandContext ctx) throws CommandException { + final Audience audience = ctx.cause().audience(); final Player player = this.requirePlayer(ctx); - final ItemStack map = player.getItemInHand(HandTypes.MAIN_HAND); - if (map.getType() != ItemTypes.FILLED_MAP.get()) { + final ItemStack map = player.itemInHand(HandTypes.MAIN_HAND); + if (map.type() != ItemTypes.FILLED_MAP.get()) { throw new CommandException(Component.text("You must hold a map in your hand")); } final ResourceKey netherKey = ResourceKey.minecraft("the_nether"); - Optional nether = Sponge.getServer().getWorldManager().world(netherKey); + final Optional nether = Sponge.server().worldManager().world(netherKey); if (!nether.isPresent()) { - final CompletableFuture loadedNether = Sponge.getServer().getWorldManager().loadWorld(netherKey); + final CompletableFuture loadedNether = Sponge.server().worldManager().loadWorld(netherKey); loadedNether.whenComplete((v, e) -> { if (e != null) { audience.sendMessage(Component.text("Failed to load nether world!", NamedTextColor.GREEN)); @@ -517,18 +517,18 @@ private CommandResult setMapNether(CommandContext ctx) throws CommandException { }); throw new CommandException(Component.text("No nether loaded, trying to load now, please wait")); } - map.require(Keys.MAP_INFO).offer(Keys.MAP_WORLD, nether.get().getKey()); + map.require(Keys.MAP_INFO).offer(Keys.MAP_WORLD, nether.get().key()); return CommandResult.success(); } - private CommandResult printMapData(CommandContext ctx) throws CommandException { + private CommandResult printMapData(final CommandContext ctx) throws CommandException { final Player player = this.requirePlayer(ctx); - final ItemStack itemStack = player.getItemInHand(HandTypes.MAIN_HAND); - if (itemStack.getType() != ItemTypes.FILLED_MAP.get()) { + final ItemStack itemStack = player.itemInHand(HandTypes.MAIN_HAND); + if (itemStack.type() != ItemTypes.FILLED_MAP.get()) { throw new CommandException(Component.text("You must hold a map in your hand")); } final MapInfo mapInfo = itemStack.require(Keys.MAP_INFO); - final Audience console = Sponge.getSystemSubject(); + final Audience console = Sponge.systemSubject(); console.sendMessage(Component.text("the mapdata contains: " + mapInfo.toContainer())); console.sendMessage(Component.text("the map contains nbt: " + itemStack.toContainer())); @@ -536,10 +536,10 @@ private CommandResult printMapData(CommandContext ctx) throws CommandException { return CommandResult.success(); } - private void checkSerialization(CommandContext ctx, String testName, String expected, String after) { - final Audience audience = ctx.getCause().getAudience(); - boolean success = expected.equals(after); - Component text = Component.text("Test of ").append(Component.text(testName, NamedTextColor.BLUE)) + private void checkSerialization(final CommandContext ctx, final String testName, final String expected, final String after) { + final Audience audience = ctx.cause().audience(); + final boolean success = expected.equals(after); + final Component text = Component.text("Test of ").append(Component.text(testName, NamedTextColor.BLUE)) .append(success ? Component.text(" SUCCEEDED", NamedTextColor.GREEN) : Component.text(" FAILED", NamedTextColor.RED)); audience.sendMessage(text); if (!success) { @@ -559,9 +559,9 @@ private DataView blankMapDecorationIds(final DataView dataView) { /*@Listener public void onGameStart(GameStartedServerEvent e) { - Sponge.getScheduler() + Sponge.scheduler() .createSyncExecutor(this) - .scheduleAtFixedRate(() -> Sponge.getServer().getPlayer("tyhdefu").ifPresent(player -> player.getItemInHand(HandTypes.MAIN_HAND).filter(itemStack -> itemStack.getType() == ItemTypes.FILLED_MAP) + .scheduleAtFixedRate(() -> Sponge.getServer().player("tyhdefu").ifPresent(player -> player.getItemInHand(HandTypes.MAIN_HAND).filter(itemStack -> itemStack.getType() == ItemTypes.FILLED_MAP) .map(itemStack -> itemStack.require(Keys.MAP_INFO)) .map(mapInfo -> mapInfo.require(Keys.MAP_DECORATIONS)) .ifPresent(mapDecorations -> mapDecorations.forEach(dec -> player.sendMessage(Text.of(dec.toContainer())))) @@ -569,27 +569,27 @@ public void onGameStart(GameStartedServerEvent e) { }*/ private Player requirePlayer(final CommandContext source) throws CommandException { - Audience audience = source.getCause().getAudience(); + final Audience audience = source.cause().audience(); if (audience instanceof Player) { return (Player) audience; } throw new CommandException(Component.text("Must be called from player!")); } - private void createDefaultCommand(final String name, final CommandExecutor executor, RegisterCommandEvent event) { + private void createDefaultCommand(final String name, final CommandExecutor executor, final RegisterCommandEvent event) { final Command.Parameterized command = Command.builder() - .setExecutor(executor) + .executor(executor) .build(); event.register(this.container, command, name); } @Override - public void enable(CommandContext ctx) { - Audience audience = ctx.getCause().getAudience(); + public void enable(final CommandContext ctx) { + final Audience audience = ctx.cause().audience(); if (!this.isEnabled) { this.isEnabled = true; - Sponge.getEventManager().registerListeners(this.container, this.listeners); + Sponge.eventManager().registerListeners(this.container, this.listeners); audience.sendMessage(Component.text("Map listeners are enabled. Created maps will now start blue.", NamedTextColor.GREEN)); } else { audience.sendMessage(Component.text("Map listeners are already enabled.", NamedTextColor.YELLOW)); @@ -600,14 +600,14 @@ public static class Listeners { private final Logger logger; - public Listeners(Logger logger) { + public Listeners(final Logger logger) { this.logger = logger; } @Listener public void onMapCreate(final CreateMapEvent event) { logger.info("ON MAP CREATE EVENT"); - final MapInfo mapInfo = event.getMapInfo(); + final MapInfo mapInfo = event.mapInfo(); mapInfo.offer(Keys.MAP_CANVAS, MapCanvas.builder() .paintAll(MapColor.of(MapColorTypes.COLOR_BLUE)) .build()); diff --git a/testplugins/src/main/java/org/spongepowered/test/movement/MovementTest.java b/testplugins/src/main/java/org/spongepowered/test/movement/MovementTest.java index 55f322e64ed..71ae81dd359 100644 --- a/testplugins/src/main/java/org/spongepowered/test/movement/MovementTest.java +++ b/testplugins/src/main/java/org/spongepowered/test/movement/MovementTest.java @@ -68,10 +68,10 @@ public MovementTest(final PluginContainer plugin) { @Override public void enable(final CommandContext ctx) { - Sponge.getEventManager().registerListeners(this.plugin, new MoveEntityListener()); - Sponge.getEventManager().registerListeners(this.plugin, new RotationEventListener()); - Sponge.getEventManager().registerListeners(this.plugin, new MoveEntityTeleportListener()); - Sponge.getEventManager().registerListeners(this.plugin, new MoveEntityCancellation()); + Sponge.eventManager().registerListeners(this.plugin, new MoveEntityListener()); + Sponge.eventManager().registerListeners(this.plugin, new RotationEventListener()); + Sponge.eventManager().registerListeners(this.plugin, new MoveEntityTeleportListener()); + Sponge.eventManager().registerListeners(this.plugin, new MoveEntityCancellation()); } @Listener @@ -79,7 +79,7 @@ public void registerCommands(final RegisterCommandEvent e event.register(this.plugin, Command.builder() - .setExecutor(context -> { + .executor(context -> { this.cancelMovement = !this.cancelMovement; final Component newState = Component.text(this.cancelMovement ? "OFF" : "ON", this.cancelMovement ? NamedTextColor.RED : NamedTextColor.GREEN); context.sendMessage(Identity.nil(), Component.text("Cancel Entity Movement : ").append(newState)); @@ -88,7 +88,7 @@ public void registerCommands(final RegisterCommandEvent e .build(), "toggleMovement" ); event.register(this.plugin, Command.builder() - .setExecutor(context -> { + .executor(context -> { this.teleportOnMove = !this.teleportOnMove; final Component newState = Component.text(this.teleportOnMove ? "ON" : "OFF", this.teleportOnMove ? NamedTextColor.GREEN : NamedTextColor.RED); context.sendMessage(Identity.nil(), Component.text("Teleport Entity on Movement : ").append(newState)); @@ -109,7 +109,7 @@ public void onEntitySpawn(final RotateEntityEvent event) { pluginLogger.log(Level.INFO, MovementTest.marker, "/* RotateEntityEvent"); pluginLogger.log(Level.INFO, MovementTest.marker, "/"); pluginLogger.log(Level.INFO, MovementTest.marker, "/ Cause:"); - for (final Object o : event.getCause()) { + for (final Object o : event.cause()) { pluginLogger.log(Level.INFO, MovementTest.marker, "/ - " + o); } pluginLogger.log(Level.INFO, MovementTest.marker, "/"); @@ -127,13 +127,13 @@ public void onEntitySpawn(final MoveEntityEvent event, final @Root Player player pluginLogger.log(Level.INFO, MovementTest.marker, "/* MoveEntityEvent testing with teleport"); pluginLogger.log(Level.INFO, MovementTest.marker, "/"); pluginLogger.log(Level.INFO, MovementTest.marker, "/ Cause:"); - for (final Object o : event.getCause()) { + for (final Object o : event.cause()) { pluginLogger.log(Level.INFO, MovementTest.marker, "/ - " + o); } pluginLogger.log(Level.INFO, MovementTest.marker, "/"); - final Vector3d sub = event.getOriginalDestinationPosition().sub(event.getOriginalPosition()); + final Vector3d sub = event.originalDestinationPosition().sub(event.originalPosition()); final Vector3d mul = sub.mul(5); - event.setDestinationPosition(event.getOriginalDestinationPosition().add(mul)); + event.setDestinationPosition(event.originalDestinationPosition().add(mul)); MovementTest.this.teleportOnMove = false; } } @@ -159,11 +159,11 @@ public void onChangeBlock(final MoveEntityEvent post) { pluginLogger.log(Level.INFO, MovementTest.marker, "/* MoveEntityEvent"); pluginLogger.log(Level.INFO, MovementTest.marker, "/"); pluginLogger.log(Level.INFO, MovementTest.marker, "/ Cause:"); - for (final Object o : post.getCause()) { + for (final Object o : post.cause()) { pluginLogger.log(Level.INFO, MovementTest.marker, "/ - " + o); } pluginLogger.log(Level.INFO, MovementTest.marker, "/"); - if (MovementTest.this.cancelAll && post.getCause().containsType(BlockSnapshot.class)) { + if (MovementTest.this.cancelAll && post.cause().containsType(BlockSnapshot.class)) { post.setCancelled(true); } if (MovementTest.this.waterProofRedstone) { diff --git a/testplugins/src/main/java/org/spongepowered/test/notifyneighbor/NotifyNeighborTest.java b/testplugins/src/main/java/org/spongepowered/test/notifyneighbor/NotifyNeighborTest.java index 233453c3ff6..60f0041a7e2 100644 --- a/testplugins/src/main/java/org/spongepowered/test/notifyneighbor/NotifyNeighborTest.java +++ b/testplugins/src/main/java/org/spongepowered/test/notifyneighbor/NotifyNeighborTest.java @@ -51,16 +51,16 @@ public NotifyNeighborTest(final PluginContainer plugin) { @Override public void enable(final CommandContext ctx) { - Sponge.getEventManager().registerListeners(this.plugin, new NotifyNeighborListener()); + Sponge.eventManager().registerListeners(this.plugin, new NotifyNeighborListener()); } public static class NotifyNeighborListener { @Listener public void onChangeBlock(final NotifyNeighborBlockEvent event) { - final LocatableBlock causeBlock = event.getCause().first(LocatableBlock.class).get(); - for (Map.Entry entry : event.getNeighbors().entrySet()) { - Sponge.getGame().getSystemSubject().sendMessage( - Component.text(causeBlock.getBlockPosition() + " " + causeBlock.getBlockState() + " notified " + entry.getValue() + " in direction " + entry.getKey())); + final LocatableBlock causeBlock = event.cause().first(LocatableBlock.class).get(); + for (Map.Entry entry : event.neighbors().entrySet()) { + Sponge.game().systemSubject().sendMessage( + Component.text(causeBlock.blockPosition() + " " + causeBlock.blockState() + " notified " + entry.getValue() + " in direction " + entry.getKey())); } } } diff --git a/testplugins/src/main/java/org/spongepowered/test/particle/ParticleTest.java b/testplugins/src/main/java/org/spongepowered/test/particle/ParticleTest.java index 77b549509dd..b7c0deb37b0 100644 --- a/testplugins/src/main/java/org/spongepowered/test/particle/ParticleTest.java +++ b/testplugins/src/main/java/org/spongepowered/test/particle/ParticleTest.java @@ -61,15 +61,15 @@ public ParticleTest(final PluginContainer plugin) { public void onRegisterSpongeCommand(final RegisterCommandEvent event) { final Parameter.Value particleType = Parameter.registryElement(TypeToken.get(ParticleType.class), - (ctx) -> Sponge.getGame().registries(), + (ctx) -> Sponge.game().registries(), RegistryTypes.PARTICLE_TYPE, "minecraft", "sponge") - .setKey("particletype").build(); + .key("particletype").build(); final Command.Parameterized myCommand = Command.builder() - .parameter(particleType) - .setExecutor(context -> { - this.spawnParticles(context.getCause().first(ServerPlayer.class).get(), context.requireOne(particleType)); + .addParameter(particleType) + .executor(context -> { + this.spawnParticles(context.cause().first(ServerPlayer.class).get(), context.requireOne(particleType)); return CommandResult.success(); }) .build(); @@ -80,7 +80,7 @@ private void spawnParticles(ServerPlayer serverPlayer, ParticleType type) { // TODO NOTE color is determined by velocity? final ParticleEffect effect = ParticleEffect.builder() .type(type) - .option(ParticleOptions.BLOCK_STATE, BlockTypes.DIAMOND_BLOCK.get().getDefaultState()) + .option(ParticleOptions.BLOCK_STATE, BlockTypes.DIAMOND_BLOCK.get().defaultState()) .option(ParticleOptions.COLOR, Color.LIME) .option(ParticleOptions.ITEM_STACK_SNAPSHOT, ItemStack.of(ItemTypes.GOLDEN_APPLE.get()).createSnapshot()) .option(ParticleOptions.DIRECTION, Direction.EAST) @@ -89,6 +89,6 @@ private void spawnParticles(ServerPlayer serverPlayer, ParticleType type) { .velocity(Vector3d.RIGHT.mul(0.5)) .quantity(20) .build(); - serverPlayer.spawnParticles(effect, serverPlayer.getPosition().add(-2, 1, -2)); + serverPlayer.spawnParticles(effect, serverPlayer.position().add(-2, 1, -2)); } } diff --git a/testplugins/src/main/java/org/spongepowered/test/projectile/ProjectileTest.java b/testplugins/src/main/java/org/spongepowered/test/projectile/ProjectileTest.java index bd355f3d4d7..aded055f1bc 100644 --- a/testplugins/src/main/java/org/spongepowered/test/projectile/ProjectileTest.java +++ b/testplugins/src/main/java/org/spongepowered/test/projectile/ProjectileTest.java @@ -72,7 +72,7 @@ public class ProjectileTest implements LoadableModule { @Override public void enable(final CommandContext ctx) { this.listeners = new ProjectileTestListener(); - Sponge.getEventManager().registerListeners(this.plugin, this.listeners); + Sponge.eventManager().registerListeners(this.plugin, this.listeners); } @Listener @@ -80,22 +80,22 @@ public void registerCommand(final RegisterCommandEvent ev final Parameter.Value> entityTypeParameter = Parameter.registryElement( TypeTokens.ENTITY_TYPE_TOKEN, - (ctx) -> Sponge.getGame().registries(), + (ctx) -> Sponge.game().registries(), RegistryTypes.ENTITY_TYPE, "minecraft", "sponge") - .setKey("type") + .key("type") .build(); - final Parameter.Value targetParameter = Parameter.bool().setKey("target").optional().build(); + final Parameter.Value targetParameter = Parameter.bool().key("target").optional().build(); final Command.Parameterized launchCommand = Command.builder() - .parameters(entityTypeParameter, targetParameter) - .setExecutor(context -> { - final Player player = context.getCause().first(Player.class) + .addParameters(entityTypeParameter, targetParameter) + .executor(context -> { + final Player player = context.cause().first(Player.class) .orElseThrow(() -> new CommandException(Component.text("Only a player can execute this command"))); final EntityType entityType = context.requireOne(entityTypeParameter); final Optional launched; - if (context.getOne(targetParameter).orElse(false)) { - final Collection nearbyEntities = player.getNearbyEntities(10, + if (context.one(targetParameter).orElse(false)) { + final Collection nearbyEntities = player.nearbyEntities(10, entity -> entity instanceof Living && entity != player); if (nearbyEntities.isEmpty()) { return CommandResult.error(Component.text("No entity to target nearby")); @@ -103,7 +103,7 @@ public void registerCommand(final RegisterCommandEvent ev final Entity target = nearbyEntities.iterator().next(); launched = player.launchProjectileTo((EntityType) entityType, target); if (launched.isPresent()) { - player.sendMessage(Identity.nil(), Component.text("Launched projectile to " + RegistryTypes.ENTITY_TYPE.keyFor(Sponge.getGame().registries(), target.getType()).asString())); + player.sendMessage(Identity.nil(), Component.text("Launched projectile to " + RegistryTypes.ENTITY_TYPE.keyFor(Sponge.game().registries(), target.type()).asString())); return CommandResult.success(); } } else { @@ -120,12 +120,12 @@ public void registerCommand(final RegisterCommandEvent ev event.register(this.plugin, launchCommand, "launch"); final Command.Parameterized launchToMeCommand = Command.builder() - .parameter(entityTypeParameter) - .setExecutor(context -> { - final Player player = context.getCause().first(Player.class) + .addParameter(entityTypeParameter) + .executor(context -> { + final Player player = context.cause().first(Player.class) .orElseThrow(() -> new CommandException(Component.text("Only a player can execute this command"))); final Collection nearbyProjectileSources = - (Collection) player.getNearbyEntities(10, entity -> entity instanceof ProjectileSource); + (Collection) player.nearbyEntities(10, entity -> entity instanceof ProjectileSource); if (nearbyProjectileSources.isEmpty()) { return CommandResult.error(Component.text("No projectile source nearby")); } @@ -133,34 +133,34 @@ public void registerCommand(final RegisterCommandEvent ev final ProjectileSource projectileSource = nearbyProjectileSources.iterator().next(); final EntityType entityType = context.requireOne(entityTypeParameter); final Optional launched = projectileSource.launchProjectileTo((EntityType) entityType, player); - final EntityType type = ((Entity) projectileSource).getType(); + final EntityType type = ((Entity) projectileSource).type(); if (launched.isPresent()) { - final EntityType launchedType = launched.get().getType(); + final EntityType launchedType = launched.get().type(); player.sendMessage(Identity.nil(), Component.text() - .append(Component.text("You made a ")).append(Component.text(RegistryTypes.ENTITY_TYPE.keyFor(Sponge.getGame().registries(), type).asString())) - .append(Component.text(" shoot a ")).append(Component.text(RegistryTypes.ENTITY_TYPE.keyFor(Sponge.getGame().registries(), launchedType).asString())) + .append(Component.text("You made a ")).append(Component.text(RegistryTypes.ENTITY_TYPE.keyFor(Sponge.game().registries(), type).asString())) + .append(Component.text(" shoot a ")).append(Component.text(RegistryTypes.ENTITY_TYPE.keyFor(Sponge.game().registries(), launchedType).asString())) .append(Component.text(" at you")).build() ); return CommandResult.success(); } throw new CommandException(Component.text() - .append(Component.text("Could not launch a ")).append(Component.text(RegistryTypes.ENTITY_TYPE.keyFor(Sponge.getGame().registries(), type).asString())) - .append(Component.text(" from a ")).append(Component.text(RegistryTypes.ENTITY_TYPE.keyFor(Sponge.getGame().registries(), entityType).asString())) + .append(Component.text("Could not launch a ")).append(Component.text(RegistryTypes.ENTITY_TYPE.keyFor(Sponge.game().registries(), type).asString())) + .append(Component.text(" from a ")).append(Component.text(RegistryTypes.ENTITY_TYPE.keyFor(Sponge.game().registries(), entityType).asString())) .append(Component.text(" at you")).build()); }) .build(); event.register(this.plugin, launchToMeCommand, "launchtome"); final Parameter.Value dispenserParameter = Parameter.location() - .setKey("dispenser") + .key("dispenser") .build(); final Command.Parameterized triggerDispenserCommand = Command.builder() - .parameters(dispenserParameter, entityTypeParameter) - .setExecutor(context -> { - final Player player = context.getCause().first(Player.class) + .addParameters(dispenserParameter, entityTypeParameter) + .executor(context -> { + final Player player = context.cause().first(Player.class) .orElseThrow(() -> new CommandException(Component.text("Only a player can execute this command"))); - final BlockEntity dispenser = context.requireOne(dispenserParameter).getBlockEntity().orElse(null); + final BlockEntity dispenser = context.requireOne(dispenserParameter).blockEntity().orElse(null); if (dispenser == null) { return CommandResult.error(Component.text("Could not find dispenser")); } @@ -169,14 +169,14 @@ public void registerCommand(final RegisterCommandEvent ev if (launched.isPresent()) { launched.get().offer(Keys.SHOOTER, player); player.sendMessage(Identity.nil(), Component.text() - .append(Component.text("The dispenser launched a ")).append(Component.text(RegistryTypes.ENTITY_TYPE.keyFor(Sponge.getGame().registries(), launched.get().getType()).asString())) + .append(Component.text("The dispenser launched a ")).append(Component.text(RegistryTypes.ENTITY_TYPE.keyFor(Sponge.game().registries(), launched.get().type()).asString())) .build() ); return CommandResult.success(); } return CommandResult.error(Component.text() - .append(Component.text("Could not make the dispenser launch a ")).append(Component.text(RegistryTypes.ENTITY_TYPE.keyFor(Sponge.getGame().registries(), entityType).asString())) + .append(Component.text("Could not make the dispenser launch a ")).append(Component.text(RegistryTypes.ENTITY_TYPE.keyFor(Sponge.game().registries(), entityType).asString())) .build()); }) .build(); @@ -209,18 +209,18 @@ public ProjectileTestListener() { @Listener public void onClickBlock(final InteractBlockEvent.Secondary event, @First final ServerPlayer player) { - final Vector3d interactionPoint = event.getInteractionPoint(); - final ServerWorld world = player.getWorld(); + final Vector3d interactionPoint = event.interactionPoint(); + final ServerWorld world = player.world(); final EntityType nextType = this.projectileTypes.poll(); this.projectileTypes.offer(nextType); - final Optional blockEntity = world.getBlockEntity(interactionPoint.toInt()); + final Optional blockEntity = world.blockEntity(interactionPoint.toInt()); if (blockEntity.isPresent() && blockEntity.get() instanceof Dispenser) { ((Dispenser) blockEntity.get()).launchProjectile(nextType); } else { player.launchProjectile(nextType); } event.setCancelled(true); - player.sendMessage(Identity.nil(), Component.text(RegistryTypes.ENTITY_TYPE.keyFor(Sponge.getGame().registries(), nextType).toString())); + player.sendMessage(Identity.nil(), Component.text(RegistryTypes.ENTITY_TYPE.keyFor(Sponge.game().registries(), nextType).toString())); } } diff --git a/testplugins/src/main/java/org/spongepowered/test/raytrace/RayTraceTest.java b/testplugins/src/main/java/org/spongepowered/test/raytrace/RayTraceTest.java index aa9506d5187..4d69dbed63f 100644 --- a/testplugins/src/main/java/org/spongepowered/test/raytrace/RayTraceTest.java +++ b/testplugins/src/main/java/org/spongepowered/test/raytrace/RayTraceTest.java @@ -52,22 +52,22 @@ public RayTraceTest(final PluginContainer pluginContainer) { @Listener public void registerCommands(final RegisterCommandEvent event) { final Parameter.Value serverLocationParameter = Parameter.builder(ServerLocation.class) - .setKey("target_location") - .parser(ResourceKeyedValueParameters.TARGET_BLOCK) + .key("target_location") + .addParser(ResourceKeyedValueParameters.TARGET_BLOCK) .build(); final Parameter.Value entityParameter = Parameter.builder(Entity.class) - .setKey("target_entity") - .parser(ResourceKeyedValueParameters.TARGET_ENTITY) + .key("target_entity") + .addParser(ResourceKeyedValueParameters.TARGET_ENTITY) .build(); event.register( this.pluginContainer, Command.builder() - .parameter(serverLocationParameter) - .setExecutor(context -> { + .addParameter(serverLocationParameter) + .executor(context -> { final ServerLocation serverLocation = context.requireOne(serverLocationParameter); context.sendMessage(Identity.nil(), Component.text("Location: " + serverLocation.toString())); - context.sendMessage(Identity.nil(), Component.text("Block: " + serverLocation.getBlock().toString())); + context.sendMessage(Identity.nil(), Component.text("Block: " + serverLocation.block().toString())); return CommandResult.success(); }) .build(), @@ -76,11 +76,11 @@ public void registerCommands(final RegisterCommandEvent e event.register( this.pluginContainer, Command.builder() - .parameter(entityParameter) - .setExecutor(context -> { + .addParameter(entityParameter) + .executor(context -> { final Entity entity = context.requireOne(entityParameter); - context.sendMessage(Identity.nil(), Component.text("Location: " + entity.getLocation().toString())); - context.sendMessage(Identity.nil(), Component.text("Entity Type: " + RegistryTypes.ENTITY_TYPE.keyFor(entity.getWorld().registries(), entity.getType()).asString())); + context.sendMessage(Identity.nil(), Component.text("Location: " + entity.location().toString())); + context.sendMessage(Identity.nil(), Component.text("Entity Type: " + RegistryTypes.ENTITY_TYPE.keyFor(entity.world().registries(), entity.type()).asString())); return CommandResult.success(); }) .build(), diff --git a/testplugins/src/main/java/org/spongepowered/test/recipe/RecipeTest.java b/testplugins/src/main/java/org/spongepowered/test/recipe/RecipeTest.java index d6b141bbe67..a9bc7ef1e19 100644 --- a/testplugins/src/main/java/org/spongepowered/test/recipe/RecipeTest.java +++ b/testplugins/src/main/java/org/spongepowered/test/recipe/RecipeTest.java @@ -81,7 +81,7 @@ public RecipeTest(final PluginContainer plugin) { public void enable(CommandContext ctx) { this.enabled = true; try { - Sponge.getServer().getCommandManager().process("reload"); + Sponge.server().commandManager().process("reload"); } catch (CommandException e) { e.printStackTrace(); } @@ -91,7 +91,7 @@ public void enable(CommandContext ctx) { public void disable(CommandContext ctx) { this.enabled = false; try { - Sponge.getServer().getCommandManager().process("reload"); + Sponge.server().commandManager().process("reload"); } catch (CommandException e) { e.printStackTrace(); } @@ -253,7 +253,7 @@ public void onRecipeRegistry(RegisterDataPackValueEvent even // Predicate Ingredients - final Predicate hardnessPredicate = stack -> stack.getType().getBlock().map(b -> b.getDefaultState().get(Keys.DESTROY_SPEED).orElse(0d) > 20).orElse(false); // e.g. obsidian + final Predicate hardnessPredicate = stack -> stack.type().block().map(b -> b.defaultState().get(Keys.DESTROY_SPEED).orElse(0d) > 20).orElse(false); // e.g. obsidian final Ingredient hardBlock = Ingredient.of(ResourceKey.of(this.plugin, "hardblock"), hardnessPredicate, ItemStack.of(ItemTypes.BEDROCK)); final RecipeRegistration hardblockToWool = ShapelessCraftingRecipe.builder().addIngredients(hardBlock).result(ItemStack.of(ItemTypes.WHITE_WOOL)) @@ -270,8 +270,8 @@ public void onRecipeRegistry(RegisterDataPackValueEvent even .where('v', Ingredient.of(ItemTypes.BOOK)) .where('e', Ingredient.of(ItemTypes.EMERALD_BLOCK)) .result(grid -> { - final Optional player = Sponge.getServer().getCauseStackManager().getCurrentCause().first(ServerPlayer.class); - final String name = player.map(ServerPlayer::getName).orElse("Steve"); + final Optional player = Sponge.server().causeStackManager().currentCause().first(ServerPlayer.class); + final String name = player.map(ServerPlayer::name).orElse("Steve"); villagerEgg.offer(Keys.CUSTOM_NAME, Component.text(name)); return villagerEgg.copy(); }, villagerEgg.copy()) @@ -288,16 +288,16 @@ public void onRecipeRegistry(RegisterDataPackValueEvent even .where('d', Ingredient.of(ItemTypes.DAYLIGHT_DETECTOR)) .where('b', Ingredient.of(ItemTypes.BOOK)) .result(grid -> { - final Optional player = Sponge.getServer().getCauseStackManager().getCurrentCause().first(ServerPlayer.class); - final Optional biome = player.map(p -> p.getWorld().getBiome(p.getBlockPosition())); - final String name = biome.map(present -> RegistryTypes.BIOME.keyFor(player.get().getWorld().registries(), present)).map(ResourceKey::toString).orElse("Unknown"); - final Integer biomeTemperature = biome.map(Biome::getTemperature).map(d -> (int) (d*10)).orElse(0); - final Integer biomeHumidity = biome.map(Biome::getHumidity).map(d -> (int) (d*10)).orElse(0); + final Optional player = Sponge.server().causeStackManager().currentCause().first(ServerPlayer.class); + final Optional biome = player.map(p -> p.world().biome(p.blockPosition())); + final String name = biome.map(present -> RegistryTypes.BIOME.keyFor(player.get().world().registries(), present)).map(ResourceKey::toString).orElse("Unknown"); + final Integer biomeTemperature = biome.map(Biome::temperature).map(d -> (int) (d*10)).orElse(0); + final Integer biomeHumidity = biome.map(Biome::humidity).map(d -> (int) (d*10)).orElse(0); final TextComponent temperature = Component.text("Temperature: ").append(Component.text(biomeTemperature)); final TextComponent humidity = Component.text("Humidity: ").append(Component.text(biomeHumidity)); writtenBook.offer(Keys.DISPLAY_NAME, Component.text("Biome Data: " + name)); writtenBook.offer(Keys.PAGES, Arrays.asList(temperature, humidity)); - writtenBook.offer(Keys.AUTHOR, Component.text(player.map(ServerPlayer::getName).orElse("Herobrine"))); + writtenBook.offer(Keys.AUTHOR, Component.text(player.map(ServerPlayer::name).orElse("Herobrine"))); return writtenBook.copy(); }, writtenBook.copy()) .key(ResourceKey.of(this.plugin, "biome_detector")) @@ -346,20 +346,20 @@ public void onRecipeRegistry(RegisterDataPackValueEvent even if (inv.capacity() != 9) { return false; } - final ItemType stick = inv.asGrid().peek(2,1).get().getType(); + final ItemType stick = inv.asGrid().peek(2,1).get().type(); if (!stick.isAnyOf(ItemTypes.STICK)) { return false; } final ItemStack middleItem = inv.peekAt(1).get(); - final ItemType type00 = inv.asGrid().peek(0,0).get().getType(); - final ItemType type10 = inv.asGrid().peek(0,1).get().getType(); - final ItemType type20 = inv.asGrid().peek(0,2).get().getType(); + final ItemType type00 = inv.asGrid().peek(0,0).get().type(); + final ItemType type10 = inv.asGrid().peek(0,1).get().type(); + final ItemType type20 = inv.asGrid().peek(0,2).get().type(); - final ItemType type01 = inv.asGrid().peek(1,0).get().getType(); - final ItemType type11 = inv.asGrid().peek(1,1).get().getType(); - final ItemType type21 = inv.asGrid().peek(1,2).get().getType(); + final ItemType type01 = inv.asGrid().peek(1,0).get().type(); + final ItemType type11 = inv.asGrid().peek(1,1).get().type(); + final ItemType type21 = inv.asGrid().peek(1,2).get().type(); if (type00 == type01 && type01 == type20 && type20 == type21 && type10 == type11) { if (type00.isAnyOf(ItemTypes.WHITE_WOOL)) { @@ -385,7 +385,7 @@ public void onRecipeRegistry(RegisterDataPackValueEvent even final RecipeRegistration squeezeSpongeRecipe = ShapelessCraftingRecipe.builder() .addIngredients(ItemTypes.WET_SPONGE, ItemTypes.BUCKET) .remainingItems(inv -> inv.slots().stream().map(Slot::peek) - .map(item -> (item.getType().isAnyOf(ItemTypes.WET_SPONGE) ? ItemTypes.SPONGE : ItemTypes.AIR).get()) + .map(item -> (item.type().isAnyOf(ItemTypes.WET_SPONGE) ? ItemTypes.SPONGE : ItemTypes.AIR).get()) .map(ItemStack::of) .collect(Collectors.toList())) .result(ItemStack.of(ItemTypes.WATER_BUCKET)) diff --git a/testplugins/src/main/java/org/spongepowered/test/scaledhealth/ScaledHealthTest.java b/testplugins/src/main/java/org/spongepowered/test/scaledhealth/ScaledHealthTest.java index d50f718ce6a..45ebef463bd 100644 --- a/testplugins/src/main/java/org/spongepowered/test/scaledhealth/ScaledHealthTest.java +++ b/testplugins/src/main/java/org/spongepowered/test/scaledhealth/ScaledHealthTest.java @@ -54,25 +54,25 @@ public ScaledHealthTest(final PluginContainer pluginContainer) { public void registerCommands(final RegisterCommandEvent event) { event.register(this.pluginContainer, Command.builder() - .child(this.getShowHealth(), "show") - .child(this.getSetHealthScale(), "scale", "setScale") - .child(this.getReSetHealthScale(), "resetScale") - .child(this.setHealthCommand(), "setHealth", "set") - .child(this.getSetMaxHealth(), "setMax", "max") - .setExecutor(this::showHealthInfo) + .addChild(this.getShowHealth(), "show") + .addChild(this.getSetHealthScale(), "scale", "setScale") + .addChild(this.getReSetHealthScale(), "resetScale") + .addChild(this.setHealthCommand(), "setHealth", "set") + .addChild(this.getSetMaxHealth(), "setMax", "max") + .executor(this::showHealthInfo) .build(), "health"); } private Command.Parameterized getSetMaxHealth() { - final Parameter.Value health = Parameter.doubleNumber().setKey("health").build(); + final Parameter.Value health = Parameter.doubleNumber().key("health").build(); return Command.builder() - .parameter(health) - .setShortDescription(Component.text("Sets your maximum health", NamedTextColor.AQUA)) - .setExecutionRequirements(c -> c.getSubject() instanceof ServerPlayer) - .setExecutor(ctx -> { + .addParameter(health) + .shortDescription(Component.text("Sets your maximum health", NamedTextColor.AQUA)) + .executionRequirements(c -> c.subject() instanceof ServerPlayer) + .executor(ctx -> { final Double newHealth = ctx.requireOne(health); - ((ServerPlayer) ctx.getSubject()).offer(Keys.MAX_HEALTH, newHealth); + ((ServerPlayer) ctx.subject()).offer(Keys.MAX_HEALTH, newHealth); ctx.sendMessage(Identity.nil(), Component.text("Max Health set to: ", NamedTextColor.DARK_AQUA).append(Component.text(newHealth, NamedTextColor.RED))); return CommandResult.success(); }) @@ -81,14 +81,14 @@ private Command.Parameterized getSetMaxHealth() { } private Command.Parameterized setHealthCommand() { - final Parameter.Value health = Parameter.doubleNumber().setKey("health").build(); + final Parameter.Value health = Parameter.doubleNumber().key("health").build(); return Command.builder() - .parameter(health) - .setShortDescription(Component.text("Sets your health", NamedTextColor.AQUA)) - .setExecutionRequirements(c -> c.getSubject() instanceof ServerPlayer) - .setExecutor(ctx -> { + .addParameter(health) + .shortDescription(Component.text("Sets your health", NamedTextColor.AQUA)) + .executionRequirements(c -> c.subject() instanceof ServerPlayer) + .executor(ctx -> { final Double newHealth = ctx.requireOne(health); - ((ServerPlayer) ctx.getSubject()).offer(Keys.HEALTH, newHealth); + ((ServerPlayer) ctx.subject()).offer(Keys.HEALTH, newHealth); ctx.sendMessage(Identity.nil(), Component.text("Health set to: ", NamedTextColor.DARK_AQUA).append(Component.text(newHealth, NamedTextColor.RED))); return CommandResult.success(); }) @@ -96,14 +96,14 @@ private Command.Parameterized setHealthCommand() { } private Command.Parameterized getSetHealthScale() { - final Parameter.Value health = Parameter.doubleNumber().setKey("health").build(); + final Parameter.Value health = Parameter.doubleNumber().key("health").build(); return Command.builder() - .parameter(health) - .setShortDescription(Component.text("Sets your health scale", NamedTextColor.AQUA)) - .setExecutionRequirements(c -> c.getSubject() instanceof ServerPlayer) - .setExecutor(ctx -> { + .addParameter(health) + .shortDescription(Component.text("Sets your health scale", NamedTextColor.AQUA)) + .executionRequirements(c -> c.subject() instanceof ServerPlayer) + .executor(ctx -> { final Double newHealth = ctx.requireOne(health); - if (((ServerPlayer) ctx.getSubject()).offer(Keys.HEALTH_SCALE, newHealth).isSuccessful()) { + if (((ServerPlayer) ctx.subject()).offer(Keys.HEALTH_SCALE, newHealth).isSuccessful()) { ctx.sendMessage(Identity.nil(), Component.text("Health scaled to: ", NamedTextColor.DARK_AQUA).append(Component.text(newHealth, NamedTextColor.RED))); } return CommandResult.success(); @@ -113,10 +113,10 @@ private Command.Parameterized getSetHealthScale() { private Command.Parameterized getReSetHealthScale() { return Command.builder() - .setShortDescription(Component.text("Sets your health scale", NamedTextColor.AQUA)) - .setExecutionRequirements(c -> c.getSubject() instanceof ServerPlayer) - .setExecutor(ctx -> { - ((ServerPlayer) ctx.getSubject()).remove(Keys.HEALTH_SCALE); + .shortDescription(Component.text("Sets your health scale", NamedTextColor.AQUA)) + .executionRequirements(c -> c.subject() instanceof ServerPlayer) + .executor(ctx -> { + ((ServerPlayer) ctx.subject()).remove(Keys.HEALTH_SCALE); ctx.sendMessage(Identity.nil(), Component.text("Health not scaled", NamedTextColor.DARK_AQUA)); return CommandResult.success(); }) @@ -125,16 +125,16 @@ private Command.Parameterized getReSetHealthScale() { private Command.Parameterized getShowHealth() { return Command.builder() - .setShortDescription(Component.text("Shows your health", NamedTextColor.AQUA)) - .setExecutionRequirements(c -> c.getSubject() instanceof ServerPlayer) - .setExecutor(this::showHealthInfo) + .shortDescription(Component.text("Shows your health", NamedTextColor.AQUA)) + .executionRequirements(c -> c.subject() instanceof ServerPlayer) + .executor(this::showHealthInfo) .build(); } private CommandResult showHealthInfo(org.spongepowered.api.command.parameter.CommandContext ctx) { - final double health = ((ServerPlayer) ctx.getSubject()).get(Keys.HEALTH).orElse(0D); - final double maxHealth = ((ServerPlayer) ctx.getSubject()).get(Keys.MAX_HEALTH).orElse(0D); - final Optional scaling = ((ServerPlayer) ctx.getSubject()).get(Keys.HEALTH_SCALE); + final double health = ((ServerPlayer) ctx.subject()).get(Keys.HEALTH).orElse(0D); + final double maxHealth = ((ServerPlayer) ctx.subject()).get(Keys.MAX_HEALTH).orElse(0D); + final Optional scaling = ((ServerPlayer) ctx.subject()).get(Keys.HEALTH_SCALE); ctx.sendMessage(Identity.nil(), Component.text("Health: ", NamedTextColor.DARK_AQUA) .append(Component.text(health, NamedTextColor.RED)) .append(Component.text("/")) diff --git a/testplugins/src/main/java/org/spongepowered/test/trades/TradeTest.java b/testplugins/src/main/java/org/spongepowered/test/trades/TradeTest.java index 8fcc7658836..b5cb6dd1dfe 100644 --- a/testplugins/src/main/java/org/spongepowered/test/trades/TradeTest.java +++ b/testplugins/src/main/java/org/spongepowered/test/trades/TradeTest.java @@ -99,7 +99,7 @@ private static Component buildComponentWithStuff(final NamedTextColor color, fin @Override public void enable(final CommandContext ctx) { - Sponge.getEventManager().registerListeners(this.pluginContainer, new SpawnListener()); + Sponge.eventManager().registerListeners(this.pluginContainer, new SpawnListener()); } public static final class SpawnListener { @@ -153,18 +153,18 @@ public void onSpawn(final SpawnEntityEvent event) { // Sponge takes inspiration from Entity systems, where any object can have any data. // The data we're setting here is then represented as the key. // Once we have our data we then offer the data to the entity using the specified key. - event.getEntities().stream() - .filter(entity1 -> entity1.getType().equals(EntityTypes.VILLAGER.get()) && Math.random() > 0.7) + event.entities().stream() + .filter(entity1 -> entity1.type().equals(EntityTypes.VILLAGER.get()) && Math.random() > 0.7) .forEach(villager -> { final DataManipulator.Mutable container = DataManipulator.mutableOf() - .set(Keys.PROFESSION_TYPE, ProfessionTypes.CLERIC.get(villager.getWorld().registries())) + .set(Keys.PROFESSION_TYPE, ProfessionTypes.CLERIC.get(villager.world().registries())) .set(Keys.CUSTOM_NAME, TradeTest.FLARDIAN) .set(Keys.INVULNERABILITY_TICKS, Ticks.of(10000)) // We have to specify the experience and level because otherwise the villager's brains reset // the job.... because they have a mind of their own... .set(Keys.EXPERIENCE, 1) .set(Keys.EXPERIENCE_LEVEL, 1) - .set(Keys.TRADE_OFFERS, ImmutableList.of(SpawnListener.generateTradeOffer().apply(villager, villager.getRandom()))); + .set(Keys.TRADE_OFFERS, ImmutableList.of(SpawnListener.generateTradeOffer().apply(villager, villager.random()))); villager.copyFrom(container); }); } diff --git a/testplugins/src/main/java/org/spongepowered/test/volumestream/VolumeStreamTest.java b/testplugins/src/main/java/org/spongepowered/test/volumestream/VolumeStreamTest.java index a87627d900d..5bdd85103e6 100644 --- a/testplugins/src/main/java/org/spongepowered/test/volumestream/VolumeStreamTest.java +++ b/testplugins/src/main/java/org/spongepowered/test/volumestream/VolumeStreamTest.java @@ -71,16 +71,16 @@ public final class VolumeStreamTest implements LoadableModule { private static final Map player_data = new HashMap<>(); private static PlayerData get(final Player pl) { - PlayerData data = VolumeStreamTest.player_data.get(pl.getUniqueId()); + PlayerData data = VolumeStreamTest.player_data.get(pl.uniqueId()); if (data == null) { - data = new PlayerData(pl.getUniqueId()); - VolumeStreamTest.player_data.put(pl.getUniqueId(), data); + data = new PlayerData(pl.uniqueId()); + VolumeStreamTest.player_data.put(pl.uniqueId(), data); } return data; } @Override public void enable(final CommandContext ctx) { - Sponge.getEventManager().registerListeners(this.plugin, this.listener); + Sponge.eventManager().registerListeners(this.plugin, this.listener); } @Listener @@ -89,14 +89,14 @@ public void onGamePreInitialization(final RegisterCommandEvent { - if (!(src.getCause().root() instanceof Player)) { + .shortDescription(Component.text("Copies a region of the world to your clipboard")) + .permission(this.plugin.getMetadata().getId() + ".command.copy") + .executor(src -> { + if (!(src.cause().root() instanceof Player)) { src.sendMessage(Identity.nil(), Component.text("Player only.", NamedTextColor.RED)); return CommandResult.success(); } - final Player player = (Player) src.getCause().root(); + final Player player = (Player) src.cause().root(); final PlayerData data = VolumeStreamTest.get(player); if (data.getPos1() == null || data.getPos2() == null) { player.sendMessage(Identity.nil(), Component.text("You must set both positions before copying", NamedTextColor.RED)); @@ -104,8 +104,8 @@ public void onGamePreInitialization(final RegisterCommandEvent { - if (!(src.getCause().root() instanceof ServerPlayer)) { + .shortDescription(Component.text("Pastes your clipboard to where you are standing")) + .permission(this.plugin.getMetadata().getId() + ".command.paste") + .executor(src -> { + if (!(src.cause().root() instanceof ServerPlayer)) { src.sendMessage(Identity.nil(), Component.text("Player only.", NamedTextColor.RED)); return CommandResult.success(); } - final ServerPlayer player = (ServerPlayer) src.getCause().root(); + final ServerPlayer player = (ServerPlayer) src.cause().root(); final PlayerData data = VolumeStreamTest.get(player); final ArchetypeVolume volume = data.getClipboard(); if (volume == null) { player.sendMessage(Identity.nil(), Component.text("You must copy something before pasting", NamedTextColor.RED)); return CommandResult.success(); } - try (CauseStackManager.StackFrame frame = Sponge.getServer().getCauseStackManager().pushCauseFrame()) { + try (CauseStackManager.StackFrame frame = Sponge.server().causeStackManager().pushCauseFrame()) { frame.pushCause(this.plugin); - volume.getBlockStateStream(volume.getBlockMin(), volume.getBlockMax(), StreamOptions.lazily()) + volume.blockStateStream(volume.blockMin(), volume.blockMax(), StreamOptions.lazily()) .apply(VolumeCollectors.of( - player.getWorld(), - VolumePositionTranslators.relativeTo(player.getBlockPosition()), + player.world(), + VolumePositionTranslators.relativeTo(player.blockPosition()), VolumeApplicators.applyBlocks(BlockChangeFlags.ALL) )); - volume.getBiomeStream(volume.getBlockMin(), volume.getBlockMax(), StreamOptions.lazily()) + volume.biomeStream(volume.blockMin(), volume.blockMax(), StreamOptions.lazily()) .apply(VolumeCollectors.of( - player.getWorld(), - VolumePositionTranslators.relativeTo(player.getBlockPosition()), + player.world(), + VolumePositionTranslators.relativeTo(player.blockPosition()), VolumeApplicators.applyBiomes() )); - volume.getBlockEntityArchetypeStream(volume.getBlockMin(), volume.getBlockMax(), StreamOptions.lazily()) + volume.blockEntityArchetypeStream(volume.blockMin(), volume.blockMax(), StreamOptions.lazily()) .apply(VolumeCollectors.of( - player.getWorld(), - VolumePositionTranslators.relativeTo(player.getBlockPosition()), + player.world(), + VolumePositionTranslators.relativeTo(player.blockPosition()), VolumeApplicators.applyBlockEntityArchetype() )); frame.addContext(EventContextKeys.SPAWN_TYPE, SpawnTypes.PLACEMENT.get()); - volume.getEntityArchetypeStream(volume.getBlockMin(), volume.getBlockMax(), StreamOptions.lazily()) + volume.entityArchetypeStream(volume.blockMin(), volume.blockMax(), StreamOptions.lazily()) .apply(VolumeCollectors.of( - player.getWorld(), - VolumePositionTranslators.relativeTo(player.getBlockPosition()), + player.world(), + VolumePositionTranslators.relativeTo(player.blockPosition()), VolumeApplicators.applyEntityArchetype() )); } @@ -168,16 +168,16 @@ public static class CopyPastaListener { @Listener public void onInteract(final InteractBlockEvent.Secondary event, @Root final Player player) { - final HandType handUsed = event.getContext().require(EventContextKeys.USED_HAND); - event.getContext().get(EventContextKeys.USED_ITEM).ifPresent(snapshot -> { - final BlockSnapshot block = event.getBlock(); - if (snapshot.getType().equals(ItemTypes.WOODEN_AXE.get()) && block != BlockSnapshot.empty()) { + final HandType handUsed = event.context().require(EventContextKeys.USED_HAND); + event.context().get(EventContextKeys.USED_ITEM).ifPresent(snapshot -> { + final BlockSnapshot block = event.block(); + if (snapshot.type().equals(ItemTypes.WOODEN_AXE.get()) && block != BlockSnapshot.empty()) { if (HandTypes.MAIN_HAND.get().equals(handUsed)) { - VolumeStreamTest.get(player).setPos1(block.getPosition()); - player.sendMessage(Component.text("Position 1 set to " + block.getPosition(), NamedTextColor.LIGHT_PURPLE)); + VolumeStreamTest.get(player).setPos1(block.position()); + player.sendMessage(Component.text("Position 1 set to " + block.position(), NamedTextColor.LIGHT_PURPLE)); } else if (HandTypes.OFF_HAND.get().equals(handUsed)) { - VolumeStreamTest.get(player).setPos2(block.getPosition()); - player.sendMessage(Component.text("Position 2 set to " + block.getPosition(), NamedTextColor.LIGHT_PURPLE)); + VolumeStreamTest.get(player).setPos2(block.position()); + player.sendMessage(Component.text("Position 2 set to " + block.position(), NamedTextColor.LIGHT_PURPLE)); } event.setCancelled(true); } diff --git a/testplugins/src/main/java/org/spongepowered/test/world/WorldTest.java b/testplugins/src/main/java/org/spongepowered/test/world/WorldTest.java index 7983953aa1a..ccf54d1d72b 100644 --- a/testplugins/src/main/java/org/spongepowered/test/world/WorldTest.java +++ b/testplugins/src/main/java/org/spongepowered/test/world/WorldTest.java @@ -50,7 +50,6 @@ import org.spongepowered.api.world.WorldTypes; import org.spongepowered.api.world.biome.provider.BiomeProvider; import org.spongepowered.api.world.biome.provider.CheckerboardBiomeConfig; -import org.spongepowered.api.world.biome.provider.LayeredBiomeConfig; import org.spongepowered.api.world.generation.ChunkGenerator; import org.spongepowered.api.world.generation.structure.Structure; import org.spongepowered.api.world.generation.config.NoiseGeneratorConfig; @@ -89,21 +88,21 @@ public WorldTest(final PluginContainer plugin, final Game game) { @Listener public void onRegisterCommand(final RegisterCommandEvent event) { - final Parameter.Value optPlayerParameter = Parameter.player().optional().setKey("player").build(); - final Parameter.Value worldKeyParameter = Parameter.resourceKey().setKey("world").build(); - final Parameter.Value optWorldParameter = Parameter.world().optional().setKey("world").build(); - final Parameter.Value optPositionParameter = Parameter.vector3d().optional().setKey("position").build(); - final Parameter.Value portalTypeParameter = Parameter.registryElement(TypeToken.get(PortalType.class), RegistryTypes.PORTAL_TYPE, "minecraft", "sponge").setKey("portal_type").build(); - final Parameter.Value worldTypeParameter = Parameter.registryElement(TypeToken.get(WorldType.class), RegistryTypes.WORLD_TYPE, "minecraft", "sponge").setKey("world_type").build(); - final Parameter.Value copyWorldKeyParameter = Parameter.resourceKey().setKey("copy_world").build(); - final Parameter.Value moveWorldKeyParameter = Parameter.resourceKey().setKey("move_world").build(); + final Parameter.Value optPlayerParameter = Parameter.player().optional().key("player").build(); + final Parameter.Value worldKeyParameter = Parameter.resourceKey().key("world").build(); + final Parameter.Value optWorldParameter = Parameter.world().optional().key("world").build(); + final Parameter.Value optPositionParameter = Parameter.vector3d().optional().key("position").build(); + final Parameter.Value portalTypeParameter = Parameter.registryElement(TypeToken.get(PortalType.class), RegistryTypes.PORTAL_TYPE, "minecraft", "sponge").key("portal_type").build(); + final Parameter.Value worldTypeParameter = Parameter.registryElement(TypeToken.get(WorldType.class), RegistryTypes.WORLD_TYPE, "minecraft", "sponge").key("world_type").build(); + final Parameter.Value copyWorldKeyParameter = Parameter.resourceKey().key("copy_world").build(); + final Parameter.Value moveWorldKeyParameter = Parameter.resourceKey().key("move_world").build(); event .register(this.plugin, Command .builder() - .parameters(CommonParameters.LOCATION_ONLINE_ONLY, portalTypeParameter) - .setPermission(this.plugin.getMetadata().getId() + ".command.portal.create") - .setExecutor(context -> { + .addParameters(CommonParameters.LOCATION_ONLINE_ONLY, portalTypeParameter) + .permission(this.plugin.getMetadata().getId() + ".command.portal.create") + .executor(context -> { final ServerLocation location = context.requireOne(CommonParameters.LOCATION_ONLINE_ONLY); final PortalType portalType = context.requireOne(portalTypeParameter); portalType.generatePortal(location, Axis.X); @@ -113,10 +112,10 @@ public void onRegisterCommand(final RegisterCommandEvent , "cp", "createportal") .register(this.plugin, Command .builder() - .parameters(optPlayerParameter, CommonParameters.LOCATION_ONLINE_ONLY, portalTypeParameter) - .setPermission(this.plugin.getMetadata().getId() + ".command.portal.use") - .setExecutor(context -> { - final ServerPlayer player = context.getOne(optPlayerParameter).orElse(this.getSourcePlayer(context)); + .addParameters(optPlayerParameter, CommonParameters.LOCATION_ONLINE_ONLY, portalTypeParameter) + .permission(this.plugin.getMetadata().getId() + ".command.portal.use") + .executor(context -> { + final ServerPlayer player = context.one(optPlayerParameter).orElse(this.getSourcePlayer(context)); final ServerLocation location = context.requireOne(CommonParameters.LOCATION_ONLINE_ONLY); final PortalType portalType = context.requireOne(portalTypeParameter); return portalType.teleport(player, location, true) ? CommandResult.success() : CommandResult.error(Component.text("Could not teleport!")); @@ -125,10 +124,10 @@ public void onRegisterCommand(final RegisterCommandEvent , "up", "useportal") .register(this.plugin, Command .builder() - .parameters(optPlayerParameter, worldTypeParameter) - .setPermission(this.plugin.getMetadata().getId() + ".command.environment.change") - .setExecutor(context -> { - final ServerPlayer player = context.getOne(optPlayerParameter).orElse(this.getSourcePlayer(context)); + .addParameters(optPlayerParameter, worldTypeParameter) + .permission(this.plugin.getMetadata().getId() + ".command.environment.change") + .executor(context -> { + final ServerPlayer player = context.one(optPlayerParameter).orElse(this.getSourcePlayer(context)); final WorldType worldType = context.requireOne(worldTypeParameter); player.sendWorldType(worldType); return CommandResult.success(); @@ -137,43 +136,43 @@ public void onRegisterCommand(final RegisterCommandEvent , "ce", "changeenvironment") .register(this.plugin, Command .builder() - .parameters(CommonParameters.WORLD, worldTypeParameter) - .setPermission(this.plugin.getMetadata().getId() + ".command.worldtype.change") - .setExecutor(context -> { + .addParameters(CommonParameters.WORLD, worldTypeParameter) + .permission(this.plugin.getMetadata().getId() + ".command.worldtype.change") + .executor(context -> { final ServerWorld world = context.requireOne(CommonParameters.WORLD); final WorldType worldType = context.requireOne(worldTypeParameter); - world.getProperties().setWorldType(worldType); + world.properties().setWorldType(worldType); return CommandResult.success(); }) .build() , "cwt", "changeworldtype") .register(this.plugin, Command .builder() - .parameters(optPlayerParameter, optWorldParameter, optPositionParameter) - .setPermission(this.plugin.getMetadata().getId() + ".command.location.change") - .setExecutor(context -> { - final ServerPlayer player = context.getOne(optPlayerParameter).orElse(this.getSourcePlayer(context)); - final ServerWorld world = context.getOne(optWorldParameter).orElse(player.getWorld()); - final Vector3d position = context.getOne(optPositionParameter).orElse(world.getProperties().spawnPosition().toDouble()); + .addParameters(optPlayerParameter, optWorldParameter, optPositionParameter) + .permission(this.plugin.getMetadata().getId() + ".command.location.change") + .executor(context -> { + final ServerPlayer player = context.one(optPlayerParameter).orElse(this.getSourcePlayer(context)); + final ServerWorld world = context.one(optWorldParameter).orElse(player.world()); + final Vector3d position = context.one(optPositionParameter).orElse(world.properties().spawnPosition().toDouble()); return player.setLocation(ServerLocation.of(world, position)) ? CommandResult.success() : CommandResult.error(Component.text("Could not teleport!")); }) .build() , "cl", "changelocation") .register(this.plugin, Command .builder() - .parameter(worldKeyParameter) - .setPermission(this.plugin.getMetadata().getId() + ".command.world.load") - .setExecutor(context -> { + .addParameter(worldKeyParameter) + .permission(this.plugin.getMetadata().getId() + ".command.world.load") + .executor(context -> { final ResourceKey key = context.requireOne(worldKeyParameter); - this.game.getServer().getWorldManager().loadWorld(key).whenComplete((r, t) -> { + this.game.server().worldManager().loadWorld(key).whenComplete((r, t) -> { if (t != null) { - context.getCause().getAudience().sendMessage(Identity.nil(), Component.text(t.getMessage())); + context.cause().audience().sendMessage(Identity.nil(), Component.text(t.getMessage())); } else { if (r != null) { - context.getCause().getAudience().sendMessage(Identity.nil(), Component.text("World loaded successfully!")); + context.cause().audience().sendMessage(Identity.nil(), Component.text("World loaded successfully!")); } else { - context.getCause().getAudience().sendMessage(Identity.nil(), Component.text("World failed to load!")); + context.cause().audience().sendMessage(Identity.nil(), Component.text("World failed to load!")); } } }); @@ -184,9 +183,9 @@ public void onRegisterCommand(final RegisterCommandEvent , "lw", "loadworld") .register(this.plugin, Command .builder() - .parameters(worldKeyParameter, worldTypeParameter) - .setPermission(this.plugin.getMetadata().getId() + ".command.world.create") - .setExecutor(context -> { + .addParameters(worldKeyParameter, worldTypeParameter) + .permission(this.plugin.getMetadata().getId() + ".command.world.create") + .executor(context -> { final ResourceKey key = context.requireOne(worldKeyParameter); final ResourceKey worldType = RegistryTypes.WORLD_TYPE.get().valueKey(context.requireOne(worldTypeParameter)); final WorldTemplate template = WorldTemplate.builder() @@ -196,14 +195,14 @@ public void onRegisterCommand(final RegisterCommandEvent .performsSpawnLogic(true) .build(); - this.game.getServer().getWorldManager().loadWorld(template).whenComplete((r, t) -> { + this.game.server().worldManager().loadWorld(template).whenComplete((r, t) -> { if (t != null) { - context.getCause().getAudience().sendMessage(Identity.nil(), Component.text(t.getMessage())); + context.cause().audience().sendMessage(Identity.nil(), Component.text(t.getMessage())); } else { if (r != null) { - context.getCause().getAudience().sendMessage(Identity.nil(), Component.text("World created successfully!")); + context.cause().audience().sendMessage(Identity.nil(), Component.text("World created successfully!")); } else { - context.getCause().getAudience().sendMessage(Identity.nil(), Component.text("World failed to create!")); + context.cause().audience().sendMessage(Identity.nil(), Component.text("World failed to create!")); } } }); @@ -214,18 +213,18 @@ public void onRegisterCommand(final RegisterCommandEvent , "cw", "createworld") .register(this.plugin, Command .builder() - .parameter(CommonParameters.WORLD) - .setExecutor(context -> { + .addParameter(CommonParameters.WORLD) + .executor(context -> { final ServerWorld world = context.requireOne(CommonParameters.WORLD); - this.game.getServer().getWorldManager().unloadWorld(world).whenComplete((r, t) -> { + this.game.server().worldManager().unloadWorld(world).whenComplete((r, t) -> { if (t != null) { - context.getCause().getAudience().sendMessage(Identity.nil(), Component.text(t.getMessage())); + context.cause().audience().sendMessage(Identity.nil(), Component.text(t.getMessage())); } else { if (r) { - context.getCause().getAudience().sendMessage(Identity.nil(), Component.text("World unloaded successfully!")); + context.cause().audience().sendMessage(Identity.nil(), Component.text("World unloaded successfully!")); } else { - context.getCause().getAudience().sendMessage(Identity.nil(), Component.text("World failed to unload!")); + context.cause().audience().sendMessage(Identity.nil(), Component.text("World failed to unload!")); } } }); @@ -236,19 +235,19 @@ public void onRegisterCommand(final RegisterCommandEvent , "uw", "unloadworld") .register(this.plugin, Command .builder() - .parameters(worldKeyParameter, copyWorldKeyParameter) - .setExecutor(context -> { + .addParameters(worldKeyParameter, copyWorldKeyParameter) + .executor(context -> { final ResourceKey key = context.requireOne(worldKeyParameter); final ResourceKey copyWorldKey = context.requireOne(copyWorldKeyParameter); - this.game.getServer().getWorldManager().copyWorld(key, copyWorldKey).whenComplete((r, t) -> { + this.game.server().worldManager().copyWorld(key, copyWorldKey).whenComplete((r, t) -> { if (t != null) { - context.getCause().getAudience().sendMessage(Identity.nil(), Component.text(t.getMessage())); + context.cause().audience().sendMessage(Identity.nil(), Component.text(t.getMessage())); } else { if (r) { - context.getCause().getAudience().sendMessage(Identity.nil(), Component.text("World copied successfully!")); + context.cause().audience().sendMessage(Identity.nil(), Component.text("World copied successfully!")); } else { - context.getCause().getAudience().sendMessage(Identity.nil(), Component.text("World failed to copy!")); + context.cause().audience().sendMessage(Identity.nil(), Component.text("World failed to copy!")); } } }); @@ -259,19 +258,19 @@ public void onRegisterCommand(final RegisterCommandEvent , "cpw", "copyworld") .register(this.plugin, Command .builder() - .parameters(worldKeyParameter, moveWorldKeyParameter) - .setExecutor(context -> { + .addParameters(worldKeyParameter, moveWorldKeyParameter) + .executor(context -> { final ResourceKey key = context.requireOne(worldKeyParameter); final ResourceKey moveWorldKey = context.requireOne(moveWorldKeyParameter); - this.game.getServer().getWorldManager().moveWorld(key, moveWorldKey).whenComplete((r, t) -> { + this.game.server().worldManager().moveWorld(key, moveWorldKey).whenComplete((r, t) -> { if (t != null) { - context.getCause().getAudience().sendMessage(Identity.nil(), Component.text(t.getMessage())); + context.cause().audience().sendMessage(Identity.nil(), Component.text(t.getMessage())); } else { if (r) { - context.getCause().getAudience().sendMessage(Identity.nil(), Component.text("World moved successfully!")); + context.cause().audience().sendMessage(Identity.nil(), Component.text("World moved successfully!")); } else { - context.getCause().getAudience().sendMessage(Identity.nil(), Component.text("World failed to move!")); + context.cause().audience().sendMessage(Identity.nil(), Component.text("World failed to move!")); } } }); @@ -282,18 +281,18 @@ public void onRegisterCommand(final RegisterCommandEvent , "mw", "moveworld") .register(this.plugin, Command .builder() - .parameters(worldKeyParameter) - .setExecutor(context -> { + .addParameters(worldKeyParameter) + .executor(context -> { final ResourceKey key = context.requireOne(worldKeyParameter); - this.game.getServer().getWorldManager().deleteWorld(key).whenComplete((r, t) -> { + this.game.server().worldManager().deleteWorld(key).whenComplete((r, t) -> { if (t != null) { - context.getCause().getAudience().sendMessage(Identity.nil(), Component.text(t.getMessage())); + context.cause().audience().sendMessage(Identity.nil(), Component.text(t.getMessage())); } else { if (r) { - context.getCause().getAudience().sendMessage(Identity.nil(), Component.text("World deleted successfully!")); + context.cause().audience().sendMessage(Identity.nil(), Component.text("World deleted successfully!")); } else { - context.getCause().getAudience().sendMessage(Identity.nil(), Component.text("World failed to delete!")); + context.cause().audience().sendMessage(Identity.nil(), Component.text("World failed to delete!")); } } }); @@ -304,34 +303,34 @@ public void onRegisterCommand(final RegisterCommandEvent , "dw", "deleteworld") .register(this.plugin, Command .builder() - .parameter(optPlayerParameter) - .setExecutor(context -> { - final ServerPlayer player = context.getOne(optPlayerParameter).orElse(this.getSourcePlayer(context)); + .addParameter(optPlayerParameter) + .executor(context -> { + final ServerPlayer player = context.one(optPlayerParameter).orElse(this.getSourcePlayer(context)); player.sendMessage(Identity.nil(), - Component.text("You are in World ").append(player.getWorld().getProperties().displayName().orElseGet(() -> Component.text(player.getWorld().getKey().toString(), + Component.text("You are in World ").append(player.world().properties().displayName().orElseGet(() -> Component.text(player.world().key().toString(), NamedTextColor.AQUA))) - .append(Component.text(" at (" + player.getPosition().getFloorX() + ", " + player.getPosition().getFloorY() + - ", " + player.getPosition().getFloorZ() + ")"))); + .append(Component.text(" at (" + player.position().getFloorX() + ", " + player.position().getFloorY() + + ", " + player.position().getFloorZ() + ")"))); return CommandResult.success(); }) .build() , "wai", "whereami") .register(this.plugin, Command .builder() - .setExecutor(this::createRandomCheckerboardWorld) + .executor(this::createRandomCheckerboardWorld) .build() , "createrandomworld", "crw" ); } private CommandResult createRandomCheckerboardWorld(final CommandContext context) { - final WorldManager wm = Sponge.getServer().getWorldManager(); - final ServerPlayer player = (ServerPlayer) context.getCause().root(); - final String owner = player.getName(); - final Random random = player.getWorld().getRandom(); + final WorldManager wm = Sponge.server().worldManager(); + final ServerPlayer player = (ServerPlayer) context.cause().root(); + final String owner = player.name(); + final Random random = player.world().random(); - final List> allBiomes = Sponge.getServer().registries().registry(RegistryTypes.BIOME) + final List> allBiomes = Sponge.server().registries().registry(RegistryTypes.BIOME) .streamEntries() .map(RegistryEntry::asReference) .collect(Collectors.toList()); @@ -376,8 +375,8 @@ private CommandResult createRandomCheckerboardWorld(final CommandContext context noiseGenConfig)) .build(); - if (player.getWorld().getKey().equals(worldKey)) { - player.setLocation(ServerLocation.of(wm.defaultWorld(), wm.defaultWorld().getProperties().spawnPosition())); + if (player.world().key().equals(worldKey)) { + player.setLocation(ServerLocation.of(wm.defaultWorld(), wm.defaultWorld().properties().spawnPosition())); } context.sendMessage(Identity.nil(), Component.text("Generating your world...")); wm.deleteWorld(worldKey).thenCompose(b -> wm.loadWorld(customTemplate)).thenAccept(w -> this.transportToWorld(player, w)).exceptionally(e -> { @@ -392,14 +391,14 @@ private CommandResult createRandomCheckerboardWorld(final CommandContext context private void transportToWorld(final ServerPlayer player, final ServerWorld world) { player.sendMessage(Identity.nil(), Component.text("Teleporting...")); - final ServerLocation spawn = world.getLocation(world.getProperties().spawnPosition()); - player.setLocation(Sponge.getServer().getTeleportHelper().getSafeLocation(spawn).orElse(spawn)); - player.showTitle(Title.title(Component.text("Welcome to your world"), Component.text(player.getName()))); + final ServerLocation spawn = world.location(world.properties().spawnPosition()); + player.setLocation(Sponge.server().teleportHelper().findSafeLocation(spawn).orElse(spawn)); + player.showTitle(Title.title(Component.text("Welcome to your world"), Component.text(player.name()))); } private ServerPlayer getSourcePlayer(final CommandContext context) { - if (context.getCause().root() instanceof ServerPlayer) { - return (ServerPlayer) context.getCause().root(); + if (context.cause().root() instanceof ServerPlayer) { + return (ServerPlayer) context.cause().root(); } throw new NoSuchElementException("Source is not a player"); } diff --git a/vanilla/src/launch/java/org/spongepowered/vanilla/launch/IntegrationTestLaunch.java b/vanilla/src/launch/java/org/spongepowered/vanilla/launch/IntegrationTestLaunch.java index 946e2157f31..17dc331b88c 100644 --- a/vanilla/src/launch/java/org/spongepowered/vanilla/launch/IntegrationTestLaunch.java +++ b/vanilla/src/launch/java/org/spongepowered/vanilla/launch/IntegrationTestLaunch.java @@ -73,7 +73,7 @@ private void performIntegrationTests(final String... args) { Launch.getInstance().auditMixins(); this.getLogger().info("Testing complete, goodbye!"); - SpongeCommon.getGame().getAsyncScheduler().close(); + SpongeCommon.getGame().asyncScheduler().close(); System.exit(0); } } diff --git a/vanilla/src/launch/java/org/spongepowered/vanilla/launch/VanillaLaunch.java b/vanilla/src/launch/java/org/spongepowered/vanilla/launch/VanillaLaunch.java index bfed0f6f3b6..0dd2e8d98f9 100644 --- a/vanilla/src/launch/java/org/spongepowered/vanilla/launch/VanillaLaunch.java +++ b/vanilla/src/launch/java/org/spongepowered/vanilla/launch/VanillaLaunch.java @@ -37,7 +37,6 @@ import org.spongepowered.vanilla.launch.plugin.VanillaPluginManager; import java.io.IOException; -import java.net.URI; import java.net.URISyntaxException; import java.net.URL; import java.nio.file.Path; @@ -73,7 +72,7 @@ public final void loadPlugins() { @Override public final PluginContainer getPlatformPlugin() { if (this.vanillaPlugin == null) { - this.vanillaPlugin = this.getPluginManager().getPlugin("spongevanilla").orElse(null); + this.vanillaPlugin = this.getPluginManager().plugin("spongevanilla").orElse(null); if (this.vanillaPlugin == null) { throw new RuntimeException("Could not find the plugin representing SpongeVanilla, this is a serious issue!"); diff --git a/vanilla/src/launch/java/org/spongepowered/vanilla/launch/plugin/VanillaPluginManager.java b/vanilla/src/launch/java/org/spongepowered/vanilla/launch/plugin/VanillaPluginManager.java index 79924454db5..2fc59a48604 100644 --- a/vanilla/src/launch/java/org/spongepowered/vanilla/launch/plugin/VanillaPluginManager.java +++ b/vanilla/src/launch/java/org/spongepowered/vanilla/launch/plugin/VanillaPluginManager.java @@ -68,14 +68,14 @@ public Optional fromInstance(final Object instance) { } @Override - public Optional getPlugin(final String id) { + public Optional plugin(final String id) { Objects.requireNonNull(id); return Optional.ofNullable(this.plugins.get(id)); } @Override - public Collection getPlugins() { + public Collection plugins() { return Collections.unmodifiableCollection(this.sortedPlugins); } diff --git a/vanilla/src/main/java/org/spongepowered/vanilla/VanillaServer.java b/vanilla/src/main/java/org/spongepowered/vanilla/VanillaServer.java index fc91f1e9283..731b2f4e1a4 100644 --- a/vanilla/src/main/java/org/spongepowered/vanilla/VanillaServer.java +++ b/vanilla/src/main/java/org/spongepowered/vanilla/VanillaServer.java @@ -30,5 +30,5 @@ public interface VanillaServer extends VanillaEngine, SpongeServer { @Override - VanillaWorldManager getWorldManager(); + VanillaWorldManager worldManager(); } diff --git a/vanilla/src/main/java/org/spongepowered/vanilla/client/gui/screen/PluginScreen.java b/vanilla/src/main/java/org/spongepowered/vanilla/client/gui/screen/PluginScreen.java index de108636d7b..cdd4891568e 100644 --- a/vanilla/src/main/java/org/spongepowered/vanilla/client/gui/screen/PluginScreen.java +++ b/vanilla/src/main/java/org/spongepowered/vanilla/client/gui/screen/PluginScreen.java @@ -57,7 +57,7 @@ public PluginScreen(final Screen previousScreen) { super(new TextComponent("Plugins")); this.previousScreen = previousScreen; this.metadata = new ObjectArrayList<>(); - final Collection plugins = Launch.getInstance().getPluginManager().getPlugins(); + final Collection plugins = Launch.getInstance().getPluginManager().plugins(); this.metadata.addAll(plugins.stream().map(PluginContainer::getMetadata).collect(Collectors.toList())); } @@ -73,7 +73,7 @@ protected void init() { // Add plugin list this.selectionList.setSelectConsumer(e -> this.contentPanel.setMetadata(e == null ? null : e.metadata)); this.generateEntries( - Launch.getInstance().getPluginManager().getPlugins().stream().map(PluginContainer::getMetadata).collect(Collectors.toList())); + Launch.getInstance().getPluginManager().plugins().stream().map(PluginContainer::getMetadata).collect(Collectors.toList())); // Add search text field this.searchField = new EditBox(this.font, this.width / 2 - 100, 22, 200, 20, new TranslatableComponent(I18n.get("itemGroup.search"))); diff --git a/vanilla/src/main/java/org/spongepowered/vanilla/world/VanillaWorldManager.java b/vanilla/src/main/java/org/spongepowered/vanilla/world/VanillaWorldManager.java index 4a31dc0bf55..48d3d389e8a 100644 --- a/vanilla/src/main/java/org/spongepowered/vanilla/world/VanillaWorldManager.java +++ b/vanilla/src/main/java/org/spongepowered/vanilla/world/VanillaWorldManager.java @@ -242,7 +242,7 @@ public boolean worldExists(final ResourceKey key) { final boolean isVanillaSubLevel = Level.NETHER.equals(registryKey) || Level.END.equals(registryKey); final Path levelDirectory = isVanillaSubLevel ? this.defaultWorldDirectory.resolve(this.getDirectoryName(key)) : - this.customWorldsDirectory.resolve(key.getNamespace()).resolve(key.getValue()); + this.customWorldsDirectory.resolve(key.namespace()).resolve(key.value()); return Files.exists(levelDirectory); } @@ -252,15 +252,15 @@ public Optional worldKey(final UUID uniqueId) { return this.worlds .values() .stream() - .filter(w -> ((org.spongepowered.api.world.server.ServerWorld) w).getUniqueId().equals(uniqueId)) + .filter(w -> ((org.spongepowered.api.world.server.ServerWorld) w).uniqueId().equals(uniqueId)) .map(w -> (org.spongepowered.api.world.server.ServerWorld) w) - .map(org.spongepowered.api.world.server.ServerWorld::getKey) + .map(org.spongepowered.api.world.server.ServerWorld::key) .findAny(); } @Override public CompletableFuture loadWorld(final WorldTemplate template) { - final ResourceKey key = Objects.requireNonNull(template, "template").getKey(); + final ResourceKey key = Objects.requireNonNull(template, "template").key(); final net.minecraft.resources.ResourceKey registryKey = SpongeWorldManager.createRegistryKey(key); if (Level.OVERWORLD.equals(registryKey)) { FutureUtil.completedWithException(new IllegalArgumentException("The default world cannot be told to load!")); @@ -328,7 +328,7 @@ private CompletableFuture loadWo if (isVanillaSubLevel) { storageSource = LevelStorageSource.createDefault(this.defaultWorldDirectory).createAccess(directoryName); } else { - storageSource = LevelStorageSource.createDefault(this.customWorldsDirectory).createAccess(worldKey.getNamespace() + File.separator + worldKey.getValue()); + storageSource = LevelStorageSource.createDefault(this.customWorldsDirectory).createAccess(worldKey.namespace() + File.separator + worldKey.value()); } } catch (final IOException e) { e.printStackTrace(); @@ -346,9 +346,9 @@ private CompletableFuture loadWo levelSettings = MinecraftServer.DEMO_SETTINGS; generationSettings = WorldGenSettings.demoSettings(BootstrapProperties.registries); } else { - levelSettings = new LevelSettings(directoryName, (GameType) (Object) BootstrapProperties.gameMode.get(Sponge.getGame().registries()), + levelSettings = new LevelSettings(directoryName, (GameType) (Object) BootstrapProperties.gameMode.get(Sponge.game().registries()), templateBridge.bridge$hardcore().orElse(BootstrapProperties.hardcore), (Difficulty) (Object) BootstrapProperties.difficulty - .get(Sponge.getGame().registries()), templateBridge.bridge$commands().orElse(BootstrapProperties.commands), new GameRules(), + .get(Sponge.game().registries()), templateBridge.bridge$commands().orElse(BootstrapProperties.commands), new GameRules(), defaultLevelData.getDataPackConfig()); generationSettings = generatorSettings; } @@ -396,7 +396,7 @@ public CompletableFuture unloadWorld(final ResourceKey key) { @Override public CompletableFuture unloadWorld(final org.spongepowered.api.world.server.ServerWorld world) { - final net.minecraft.resources.ResourceKey registryKey = SpongeWorldManager.createRegistryKey(Objects.requireNonNull(world, "world").getKey()); + final net.minecraft.resources.ResourceKey registryKey = SpongeWorldManager.createRegistryKey(Objects.requireNonNull(world, "world").key()); if (Level.OVERWORLD.equals(registryKey)) { return CompletableFuture.completedFuture(false); @@ -441,7 +441,7 @@ public CompletableFuture saveTemplate(final WorldTemplate template) { final LevelStem scratch = ((SpongeWorldTemplate) Objects.requireNonNull(template, "template")).asDimension(); try { final JsonElement element = SpongeWorldTemplate.DIRECT_CODEC.encodeStart(RegistryWriteOps.create(JsonOps.INSTANCE, BootstrapProperties.registries), scratch).getOrThrow(true, s -> { }); - final Path dataPackFile = this.getDataPackFile(template.getKey()); + final Path dataPackFile = this.getDataPackFile(template.key()); Files.createDirectories(dataPackFile.getParent()); DataPackSerializer.writeFile(dataPackFile, element); DataPackSerializer.writePackMetadata("World", this.dimensionsDataPackDirectory.getParent()); @@ -471,8 +471,8 @@ public CompletableFuture> loadProperties(final R if (isVanillaWorld) { storageSource = LevelStorageSource.createDefault(this.defaultWorldDirectory).createAccess(directoryName); } else { - storageSource = LevelStorageSource.createDefault(this.customWorldsDirectory).createAccess(key.getNamespace() + File.separator + - key.getValue()); + storageSource = LevelStorageSource.createDefault(this.customWorldsDirectory).createAccess(key.namespace() + File.separator + + key.value()); } } catch (final IOException e) { return FutureUtil.completedWithException(e); @@ -500,13 +500,13 @@ public CompletableFuture> loadProperties(final R @Override public CompletableFuture saveProperties(final ServerWorldProperties properties) { - final net.minecraft.resources.ResourceKey registryKey = SpongeWorldManager.createRegistryKey(Objects.requireNonNull(properties, "properties").getKey()); + final net.minecraft.resources.ResourceKey registryKey = SpongeWorldManager.createRegistryKey(Objects.requireNonNull(properties, "properties").key()); if (this.worlds.get(registryKey) != null) { return CompletableFuture.completedFuture(false); } - final ResourceKey key = properties.getKey(); + final ResourceKey key = properties.key(); final boolean isVanillaWorld = this.isVanillaWorld(key); final String directoryName = this.getDirectoryName(key); @@ -516,8 +516,8 @@ public CompletableFuture saveProperties(final ServerWorldProperties pro if (isVanillaWorld) { storageSource = LevelStorageSource.createDefault(this.defaultWorldDirectory).createAccess(directoryName); } else { - storageSource = LevelStorageSource.createDefault(this.customWorldsDirectory).createAccess(key.getNamespace() + File.separator + - key.getValue()); + storageSource = LevelStorageSource.createDefault(this.customWorldsDirectory).createAccess(key.namespace() + File.separator + + key.value()); } } catch (final IOException e) { return FutureUtil.completedWithException(e); @@ -574,13 +574,13 @@ public CompletableFuture copyWorld(final ResourceKey key, final Resourc final String directoryName = this.getDirectoryName(key); final Path originalDirectory = isDefaultWorld ? this.defaultWorldDirectory : isVanillaWorld ? this.defaultWorldDirectory - .resolve(directoryName) : this.customWorldsDirectory.resolve(key.getNamespace()).resolve(key.getValue()); + .resolve(directoryName) : this.customWorldsDirectory.resolve(key.namespace()).resolve(key.value()); final boolean isVanillaCopyWorld = this.isVanillaWorld(copyKey); final String copyDirectoryName = this.getDirectoryName(copyKey); final Path copyDirectory = isVanillaCopyWorld ? this.defaultWorldDirectory - .resolve(copyDirectoryName) : this.customWorldsDirectory.resolve(key.getNamespace()).resolve(key.getValue()); + .resolve(copyDirectoryName) : this.customWorldsDirectory.resolve(key.namespace()).resolve(key.value()); try { Files.walkFileTree(originalDirectory, new SimpleFileVisitor() { @@ -696,13 +696,13 @@ public CompletableFuture moveWorld(final ResourceKey key, final Resourc final String directoryName = this.getDirectoryName(key); final Path originalDirectory = isVanillaWorld ? this.defaultWorldDirectory - .resolve(directoryName) : this.customWorldsDirectory.resolve(key.getNamespace()).resolve(key.getValue()); + .resolve(directoryName) : this.customWorldsDirectory.resolve(key.namespace()).resolve(key.value()); final boolean isVanillaMoveWorld = this.isVanillaWorld(movedKey); final String moveDirectoryName = this.getDirectoryName(movedKey); final Path moveDirectory = isVanillaMoveWorld ? this.defaultWorldDirectory - .resolve(moveDirectoryName) : this.customWorldsDirectory.resolve(key.getNamespace()).resolve(key.getValue()); + .resolve(moveDirectoryName) : this.customWorldsDirectory.resolve(key.namespace()).resolve(key.value()); try { Files.createDirectories(moveDirectory); @@ -712,10 +712,10 @@ public CompletableFuture moveWorld(final ResourceKey key, final Resourc } final Path configFile = SpongeCommon.getSpongeConfigDirectory().resolve(SpongeCommon.ECOSYSTEM_ID).resolve("worlds").resolve(key - .getNamespace()).resolve(key.getValue() + ".conf"); + .namespace()).resolve(key.value() + ".conf"); final Path copiedConfigFile = SpongeCommon.getSpongeConfigDirectory().resolve(SpongeCommon.ECOSYSTEM_ID).resolve("worlds") - .resolve(movedKey.getNamespace()).resolve(movedKey.getValue() + ".conf"); + .resolve(movedKey.namespace()).resolve(movedKey.value() + ".conf"); try { Files.createDirectories(copiedConfigFile.getParent()); @@ -764,7 +764,7 @@ public CompletableFuture deleteWorld(final ResourceKey key) { final boolean isVanillaWorld = this.isVanillaWorld(key); final String directoryName = this.getDirectoryName(key); - final Path directory = isVanillaWorld ? this.defaultWorldDirectory.resolve(directoryName) : this.customWorldsDirectory.resolve(key.getNamespace()).resolve(key.getValue()); + final Path directory = isVanillaWorld ? this.defaultWorldDirectory.resolve(directoryName) : this.customWorldsDirectory.resolve(key.namespace()).resolve(key.value()); if (Files.exists(directory)) { try { @@ -776,7 +776,7 @@ public CompletableFuture deleteWorld(final ResourceKey key) { } } - final Path configFile = SpongeCommon.getSpongeConfigDirectory().resolve(SpongeCommon.ECOSYSTEM_ID).resolve("worlds").resolve(key.getNamespace()).resolve(key.getValue() + ".conf"); + final Path configFile = SpongeCommon.getSpongeConfigDirectory().resolve(SpongeCommon.ECOSYSTEM_ID).resolve("worlds").resolve(key.namespace()).resolve(key.value() + ".conf"); try { Files.deleteIfExists(configFile); @@ -821,7 +821,7 @@ public void unloadWorld0(final ServerLevel world) throws IOException { this.worlds.remove(registryKey); - SpongeCommon.postEvent(SpongeEventFactory.createUnloadWorldEvent(PhaseTracker.getCauseStackManager().getCurrentCause(), (org.spongepowered.api.world.server.ServerWorld) world)); + SpongeCommon.postEvent(SpongeEventFactory.createUnloadWorldEvent(PhaseTracker.getCauseStackManager().currentCause(), (org.spongepowered.api.world.server.ServerWorld) world)); } @Override @@ -869,7 +869,7 @@ public void loadLevel() { if (isVanillaSubLevel) { storageSource = LevelStorageSource.createDefault(this.defaultWorldDirectory).createAccess(directoryName); } else { - storageSource = LevelStorageSource.createDefault(this.customWorldsDirectory).createAccess(worldKey.getNamespace() + File.separator + worldKey.getValue()); + storageSource = LevelStorageSource.createDefault(this.customWorldsDirectory).createAccess(worldKey.namespace() + File.separator + worldKey.value()); } } catch (final IOException e) { throw new RuntimeException(String.format("Failed to create level data for world '%s'!", worldKey), e); @@ -894,9 +894,9 @@ public void loadLevel() { generationSettings = WorldGenSettings.demoSettings(BootstrapProperties.registries); } else { levelSettings = new LevelSettings(directoryName, - (GameType) (Object) BootstrapProperties.gameMode.get(Sponge.getGame().registries()), + (GameType) (Object) BootstrapProperties.gameMode.get(Sponge.game().registries()), templateBridge.bridge$hardcore().orElse(BootstrapProperties.hardcore), - (Difficulty) (Object) BootstrapProperties.difficulty.get(Sponge.getGame().registries()), + (Difficulty) (Object) BootstrapProperties.difficulty.get(Sponge.game().registries()), templateBridge.bridge$commands().orElse(BootstrapProperties.commands), new GameRules(), defaultLevelData.getDataPackConfig()); generationSettings = ((WorldGenSettingsBridge) defaultLevelData.worldGenSettings()).bridge$copy(); } @@ -946,7 +946,7 @@ public void loadLevel() { } } - ((SpongeUserManager) Sponge.getServer().getUserManager()).init(); + ((SpongeUserManager) Sponge.server().userManager()).init(); ((SpongeServer) SpongeCommon.getServer()).getPlayerDataManager().load(); } @@ -963,7 +963,7 @@ private ServerLevel prepareWorld(final ServerLevel world, final boolean isDebugG final boolean isInitialized = levelData.isInitialized(); - SpongeCommon.postEvent(SpongeEventFactory.createLoadWorldEvent(PhaseTracker.getCauseStackManager().getCurrentCause(), + SpongeCommon.postEvent(SpongeEventFactory.createLoadWorldEvent(PhaseTracker.getCauseStackManager().currentCause(), (org.spongepowered.api.world.server.ServerWorld) world, isInitialized)); // Set the view distance back on it's self to trigger the logic @@ -1041,11 +1041,11 @@ private CompletableFuture loadSpawnChunksAsync(final ServerLevel wo serverChunkProvider.addRegionTicket(VanillaWorldManager.SPAWN_CHUNKS, chunkPos, borderRadius, world.dimension().location()); final CompletableFuture generationFuture = new CompletableFuture<>(); - Sponge.getAsyncScheduler().submit( + Sponge.asyncScheduler().submit( Task.builder().plugin(Launch.getInstance().getPlatformPlugin()) .execute(task -> { if (serverChunkProvider.getTickingGenerated() >= spawnChunks) { - Sponge.getServer().getScheduler().submit(Task.builder().plugin(Launch.getInstance().getPlatformPlugin()).execute(() -> generationFuture.complete(world)).build()); + Sponge.server().scheduler().submit(Task.builder().plugin(Launch.getInstance().getPlatformPlugin()).execute(() -> generationFuture.complete(world)).build()); // Notify the future that we are done task.cancel(); // And cancel this task MinecraftServerAccessor.accessor$LOGGER().info("Done preparing start region for world '{}' ({})", world diff --git a/vanilla/src/mixins/java/org/spongepowered/vanilla/mixin/api/mcp/server/MinecraftServerMixin_Vanilla_API.java b/vanilla/src/mixins/java/org/spongepowered/vanilla/mixin/api/mcp/server/MinecraftServerMixin_Vanilla_API.java index 16276fd9896..f09c0534b2d 100644 --- a/vanilla/src/mixins/java/org/spongepowered/vanilla/mixin/api/mcp/server/MinecraftServerMixin_Vanilla_API.java +++ b/vanilla/src/mixins/java/org/spongepowered/vanilla/mixin/api/mcp/server/MinecraftServerMixin_Vanilla_API.java @@ -61,7 +61,7 @@ public abstract class MinecraftServerMixin_Vanilla_API implements VanillaServer } @Override - public VanillaWorldManager getWorldManager() { + public VanillaWorldManager worldManager() { return this.vanilla_api$worldManager; } } diff --git a/vanilla/src/mixins/java/org/spongepowered/vanilla/mixin/core/CrashReportMixin_Vanilla.java b/vanilla/src/mixins/java/org/spongepowered/vanilla/mixin/core/CrashReportMixin_Vanilla.java index 9a9b0652c17..4887a976977 100644 --- a/vanilla/src/mixins/java/org/spongepowered/vanilla/mixin/core/CrashReportMixin_Vanilla.java +++ b/vanilla/src/mixins/java/org/spongepowered/vanilla/mixin/core/CrashReportMixin_Vanilla.java @@ -45,7 +45,7 @@ public abstract class CrashReportMixin_Vanilla { private void vanilla$addPluginsToEnvironment(final CallbackInfo ci) { this.systemDetails.setDetail("Plugins", () -> { final StringBuilder result = new StringBuilder(64); - for (final PluginContainer container : Sponge.getPluginManager().getPlugins()) { + for (final PluginContainer container : Sponge.pluginManager().plugins()) { final PluginMetadata metadata = container.getMetadata(); final String name = metadata.getName().orElse(metadata.getId()); diff --git a/vanilla/src/mixins/java/org/spongepowered/vanilla/mixin/core/client/multiplayer/ClientHandshakePacketListenerImplMixin_Vanilla.java b/vanilla/src/mixins/java/org/spongepowered/vanilla/mixin/core/client/multiplayer/ClientHandshakePacketListenerImplMixin_Vanilla.java index f9b18c718ad..b88e5324a81 100644 --- a/vanilla/src/mixins/java/org/spongepowered/vanilla/mixin/core/client/multiplayer/ClientHandshakePacketListenerImplMixin_Vanilla.java +++ b/vanilla/src/mixins/java/org/spongepowered/vanilla/mixin/core/client/multiplayer/ClientHandshakePacketListenerImplMixin_Vanilla.java @@ -50,7 +50,7 @@ public abstract class ClientHandshakePacketListenerImplMixin_Vanilla implements private void vanilla$handleRequestPayload(final ClientboundCustomQueryPacket packet, final CallbackInfo ci) { ci.cancel(); - final SpongeChannelRegistry channelRegistry = (SpongeChannelRegistry) Sponge.getChannelRegistry(); + final SpongeChannelRegistry channelRegistry = (SpongeChannelRegistry) Sponge.channelRegistry(); this.minecraft.execute(() -> { final EngineConnection connection = (EngineConnection) this; if (!channelRegistry.handleLoginRequestPayload(connection, packet)) { diff --git a/vanilla/src/mixins/java/org/spongepowered/vanilla/mixin/core/client/multiplayer/ClientPacketListenerMixin_Vanilla.java b/vanilla/src/mixins/java/org/spongepowered/vanilla/mixin/core/client/multiplayer/ClientPacketListenerMixin_Vanilla.java index a99493a67fc..8d8a2fe9e30 100644 --- a/vanilla/src/mixins/java/org/spongepowered/vanilla/mixin/core/client/multiplayer/ClientPacketListenerMixin_Vanilla.java +++ b/vanilla/src/mixins/java/org/spongepowered/vanilla/mixin/core/client/multiplayer/ClientPacketListenerMixin_Vanilla.java @@ -41,7 +41,7 @@ public abstract class ClientPacketListenerMixin_Vanilla implements ClientGamePac @Inject(method = "handleCustomPayload", cancellable = true, at = @At(value = "INVOKE", target = "Lnet/minecraft/network/protocol/game/ClientboundCustomPayloadPacket;getIdentifier()Lnet/minecraft/resources/ResourceLocation;")) private void vanilla$handleCustomPayload(final ClientboundCustomPayloadPacket packet, final CallbackInfo ci) { - final SpongeChannelRegistry channelRegistry = (SpongeChannelRegistry) Sponge.getChannelRegistry(); + final SpongeChannelRegistry channelRegistry = (SpongeChannelRegistry) Sponge.channelRegistry(); if (channelRegistry.handlePlayPayload((EngineConnection) this, packet)) { ci.cancel(); } diff --git a/vanilla/src/mixins/java/org/spongepowered/vanilla/mixin/core/client/server/IntegratedServerMixin_Vanilla.java b/vanilla/src/mixins/java/org/spongepowered/vanilla/mixin/core/client/server/IntegratedServerMixin_Vanilla.java index 8a7fef96f7b..213f3ec6a5d 100644 --- a/vanilla/src/mixins/java/org/spongepowered/vanilla/mixin/core/client/server/IntegratedServerMixin_Vanilla.java +++ b/vanilla/src/mixins/java/org/spongepowered/vanilla/mixin/core/client/server/IntegratedServerMixin_Vanilla.java @@ -83,7 +83,7 @@ public abstract class IntegratedServerMixin_Vanilla extends MinecraftServerMixin @Override public void loadLevel() { this.shadow$detectBundledResources(); - this.getWorldManager().loadLevel(); + this.worldManager().loadLevel(); } @Override diff --git a/vanilla/src/mixins/java/org/spongepowered/vanilla/mixin/core/server/dedicated/DedicatedServerMixin_Vanilla.java b/vanilla/src/mixins/java/org/spongepowered/vanilla/mixin/core/server/dedicated/DedicatedServerMixin_Vanilla.java index 69efc93edb9..cdc51f2b6cc 100644 --- a/vanilla/src/mixins/java/org/spongepowered/vanilla/mixin/core/server/dedicated/DedicatedServerMixin_Vanilla.java +++ b/vanilla/src/mixins/java/org/spongepowered/vanilla/mixin/core/server/dedicated/DedicatedServerMixin_Vanilla.java @@ -68,6 +68,6 @@ public abstract class DedicatedServerMixin_Vanilla extends MinecraftServerMixin_ @Override protected void loadLevel() { this.shadow$detectBundledResources(); - this.getWorldManager().loadLevel(); + this.worldManager().loadLevel(); } } diff --git a/vanilla/src/mixins/java/org/spongepowered/vanilla/mixin/core/server/network/ServerGamePacketListenerImplMixin_Vanilla.java b/vanilla/src/mixins/java/org/spongepowered/vanilla/mixin/core/server/network/ServerGamePacketListenerImplMixin_Vanilla.java index 607bb5ca231..5b66ce89e84 100644 --- a/vanilla/src/mixins/java/org/spongepowered/vanilla/mixin/core/server/network/ServerGamePacketListenerImplMixin_Vanilla.java +++ b/vanilla/src/mixins/java/org/spongepowered/vanilla/mixin/core/server/network/ServerGamePacketListenerImplMixin_Vanilla.java @@ -69,7 +69,7 @@ private void onHandleCustomPayload(final ServerboundCustomPayloadPacket packet, // method of its class, only applicable to this packet, so just retain here. ((ServerboundCustomPayloadPacketAccessor) packet).accessor$data().retain(); - final SpongeChannelRegistry channelRegistry = (SpongeChannelRegistry) Sponge.getChannelRegistry(); + final SpongeChannelRegistry channelRegistry = (SpongeChannelRegistry) Sponge.channelRegistry(); this.server.execute(() -> channelRegistry.handlePlayPayload((EngineConnection) this, packet)); } @@ -81,18 +81,18 @@ private void onHandleCustomPayload(final ServerboundCustomPayloadPacket packet, locals = LocalCapture.CAPTURE_FAILHARD) private void vanilla$onProcessChatMessage(String p_244548_1_, CallbackInfo ci, net.minecraft.network.chat.Component component) { ChatFormatter.formatChatComponent((net.minecraft.network.chat.TranslatableComponent) component); - final PlayerChatRouter chatRouter = ((ServerPlayer) this.player).getChatRouter(); + final PlayerChatRouter chatRouter = ((ServerPlayer) this.player).chatRouter(); Component adventure = SpongeAdventure.asAdventure(component); adventure = ((TranslatableComponent) adventure).args().get(1); try (CauseStackManager.StackFrame frame = PhaseTracker.SERVER.pushCauseFrame()) { frame.pushCause(this.player); final PlayerChatEvent event = SpongeEventFactory - .createPlayerChatEvent(PhaseTracker.SERVER.getCurrentCause(), chatRouter, Optional.of(chatRouter), adventure, adventure); + .createPlayerChatEvent(PhaseTracker.SERVER.currentCause(), chatRouter, Optional.of(chatRouter), adventure, adventure); if (SpongeCommon.postEvent(event)) { ci.cancel(); } else { - event.getChatRouter().ifPresent(router -> router.chat((ServerPlayer) this.player, event.getMessage())); + event.chatRouter().ifPresent(router -> router.chat((ServerPlayer) this.player, event.message())); } } } diff --git a/vanilla/src/mixins/java/org/spongepowered/vanilla/mixin/core/server/network/ServerLoginPacketListenerImplMixin_Vanilla.java b/vanilla/src/mixins/java/org/spongepowered/vanilla/mixin/core/server/network/ServerLoginPacketListenerImplMixin_Vanilla.java index 97a0d6e8721..11b6b8ecc8c 100644 --- a/vanilla/src/mixins/java/org/spongepowered/vanilla/mixin/core/server/network/ServerLoginPacketListenerImplMixin_Vanilla.java +++ b/vanilla/src/mixins/java/org/spongepowered/vanilla/mixin/core/server/network/ServerLoginPacketListenerImplMixin_Vanilla.java @@ -69,7 +69,7 @@ public abstract class ServerLoginPacketListenerImplMixin_Vanilla implements Serv private void onResponsePayload(final ServerboundCustomQueryPacket packet, final CallbackInfo ci) { ci.cancel(); - final SpongeChannelRegistry channelRegistry = (SpongeChannelRegistry) Sponge.getChannelRegistry(); + final SpongeChannelRegistry channelRegistry = (SpongeChannelRegistry) Sponge.channelRegistry(); this.server.execute(() -> channelRegistry.handleLoginResponsePayload((EngineConnection) this, packet)); } @@ -80,12 +80,12 @@ private void onResponsePayload(final ServerboundCustomQueryPacket packet, final if (this.impl$handshakeState == ServerLoginPacketListenerImplMixin_Vanilla.HANDSHAKE_NOT_STARTED) { this.impl$handshakeState = ServerLoginPacketListenerImplMixin_Vanilla.HANDSHAKE_CLIENT_TYPE; - ((SpongeChannelRegistry) Sponge.getChannelRegistry()).requestClientType(connection).thenAccept(result -> { + ((SpongeChannelRegistry) Sponge.channelRegistry()).requestClientType(connection).thenAccept(result -> { this.impl$handshakeState = ServerLoginPacketListenerImplMixin_Vanilla.HANDSHAKE_SYNC_CHANNEL_REGISTRATIONS; }); } else if (this.impl$handshakeState == ServerLoginPacketListenerImplMixin_Vanilla.HANDSHAKE_SYNC_CHANNEL_REGISTRATIONS) { - ((SpongeChannelRegistry) Sponge.getChannelRegistry()).sendLoginChannelRegistry(connection).thenAccept(result -> { + ((SpongeChannelRegistry) Sponge.channelRegistry()).sendLoginChannelRegistry(connection).thenAccept(result -> { final Cause cause = Cause.of(EventContext.empty(), this); final ServerSideConnectionEvent.Handshake event = SpongeEventFactory.createServerSideConnectionEventHandshake(cause, connection); @@ -106,7 +106,7 @@ private void onResponsePayload(final ServerboundCustomQueryPacket packet, final private void impl$onTryAcceptPlayer_beforeInitPlayer(final CallbackInfo ci) { final ServerSideConnection connection = (ServerSideConnection) this; // Also send the channel registrations using the minecraft channel, for compatibility - ((SpongeChannelRegistry) Sponge.getChannelRegistry()).sendChannelRegistrations(connection); + ((SpongeChannelRegistry) Sponge.channelRegistry()).sendChannelRegistrations(connection); } @Inject(method = "handleHello", at = @At("RETURN"))