From a8d1737e53dfa926cf429ab9f43c7d370fb66451 Mon Sep 17 00:00:00 2001 From: Flemmli97 Date: Fri, 3 Dec 2021 22:37:35 +0100 Subject: [PATCH] port to 1.18 --- build.gradle | 17 +- common/build.gradle | 6 +- .../flemmli97/flan/CrossPlatformStuff.java | 14 +- .../flemmli97/flan/SimpleRegistryWrapper.java | 6 +- .../flemmli97/flan/api/ClaimHandler.java | 10 +- .../flan/api/data/IPermissionContainer.java | 8 +- .../flan/api/data/IPermissionStorage.java | 2 +- .../flan/api/permission/ClaimPermission.java | 8 +- .../api/permission/ObjectToPermissionMap.java | 72 +- .../api/permission/PermissionRegistry.java | 28 +- .../io/github/flemmli97/flan/claim/Claim.java | 201 +++--- .../flan/claim/ClaimPermissionCheck.java | 10 +- .../flemmli97/flan/claim/ClaimStorage.java | 150 ++--- .../flemmli97/flan/claim/GlobalClaim.java | 16 +- .../flan/claim/ParticleIndicators.java | 19 +- .../flemmli97/flan/claim/PermHelper.java | 32 +- .../flemmli97/flan/commands/CommandClaim.java | 616 +++++++++--------- .../flemmli97/flan/commands/CommandHelp.java | 52 +- .../flan/commands/CommandHelpers.java | 46 +- .../github/flemmli97/flan/config/Config.java | 24 +- .../flemmli97/flan/config/ConfigHandler.java | 16 +- .../flan/event/BlockInteractEvents.java | 180 ++--- .../flan/event/EntityInteractEvents.java | 356 +++++----- .../flan/event/ItemInteractEvents.java | 215 +++--- .../flemmli97/flan/event/PlayerEvents.java | 20 +- .../flemmli97/flan/event/WorldEvents.java | 74 +-- .../flan/gui/ClaimMenuScreenHandler.java | 118 ++-- .../flemmli97/flan/gui/ClaimTextHandler.java | 90 +-- .../flan/gui/ConfirmScreenHandler.java | 40 +- .../flan/gui/GroupPlayerScreenHandler.java | 84 ++- .../flan/gui/GroupScreenHandler.java | 74 +-- .../flan/gui/LockedLecternScreenHandler.java | 42 +- .../flan/gui/PermissionScreenHandler.java | 76 +-- .../flan/gui/PersonalGroupScreenHandler.java | 76 +-- .../gui/PersonalPermissionScreenHandler.java | 84 +-- .../flan/gui/PotionEditScreenHandler.java | 100 +-- .../flan/gui/ServerOnlyScreenHandler.java | 100 ++- .../flan/gui/ServerScreenHelper.java | 80 +-- .../flan/gui/StringResultScreenHandler.java | 117 ++-- .../flemmli97/flan/gui/inv/SeparateInv.java | 2 +- .../flan/gui/inv/SeparateInvImpl.java | 32 +- .../flemmli97/flan/gui/inv/SlotDelegate.java | 18 +- .../integration/currency/CommandCurrency.java | 8 +- .../permissions/PermissionNodeHandler.java | 14 +- .../flan/mixin/AbstractBlockStateMixin.java | 36 +- .../flan/mixin/AbstractContainerAccessor.java | 20 + .../flan/mixin/BannedEntryAccessor.java | 6 +- .../flan/mixin/EndermanPickupMixin.java | 12 +- .../flan/mixin/EndermanPlaceMixin.java | 16 +- .../flemmli97/flan/mixin/EntityMixin.java | 8 +- .../flemmli97/flan/mixin/FireBlockMixin.java | 26 +- .../flemmli97/flan/mixin/FluidMixin.java | 20 +- .../flan/mixin/FrostWalkerMixin.java | 20 +- .../flemmli97/flan/mixin/IHungerAccessor.java | 6 +- .../flemmli97/flan/mixin/IItemAccessor.java | 14 +- .../flan/mixin/ILecternBlockValues.java | 14 +- .../flan/mixin/IPersistentProjectileVars.java | 18 +- .../flemmli97/flan/mixin/ItemEntityMixin.java | 20 +- .../flemmli97/flan/mixin/ItemStackMixin.java | 14 +- .../flan/mixin/LightningFireEntityMixin.java | 6 +- .../flan/mixin/PlayerClaimMixin.java | 10 +- .../flemmli97/flan/mixin/PlayerMixin.java | 16 +- .../flan/mixin/RaidManagerMixin.java | 12 +- .../flan/mixin/ServerWorldMixin.java | 12 +- .../flemmli97/flan/mixin/TurtleEggMixin.java | 13 +- .../flemmli97/flan/player/ClaimDisplay.java | 57 +- .../flemmli97/flan/player/IOwnedItem.java | 4 +- .../flan/player/OfflinePlayerData.java | 12 +- .../flan/player/PlayerClaimData.java | 137 ++-- .../flan/player/PlayerDataHandler.java | 6 +- .../flemmli97/flan/player/TeleportUtils.java | 63 +- .../flan/scoreboard/ClaimCriterias.java | 14 +- common/src/main/resources/flan.mixins.json | 3 +- fabric/build.gradle | 41 +- .../gradle/wrapper/gradle-wrapper.properties | 5 + .../flemmli97/flan/FabricRegistryWrapper.java | 10 +- .../flan/api/fabric/PermissionCheckEvent.java | 14 +- .../fabric/ClaimPermissionCheckImpl.java | 8 +- .../flan/fabric/CrossPlatformStuffImpl.java | 32 +- .../flan/fabric/mixin/EntityDamageMixin.java | 24 +- .../flan/fabric/mixin/FabricFireMixin.java | 17 +- .../flan/fabric/mixin/LightningHitMixin.java | 6 +- .../flan/fabric/mixin/PistonMixin.java | 16 +- .../flan/fabric/mixin/PlayerDropMixin.java | 12 +- .../mixin/PlayerInteractEntityMixin.java | 30 + .../flan/fabric/mixin/PlayerManagerMixin.java | 10 +- .../flan/fabric/mixin/ProjectileMixin.java | 20 +- .../mixin/ServerPlayNetworkHandlerMixin.java | 36 - .../flan/fabric/mixin/ServerWorldMixin.java | 18 +- .../flan/fabric/mixin/SnowGolemMixin.java | 8 +- .../flan/fabric/mixin/SpawnHelperMixin.java | 12 +- .../flan/fabric/mixin/WitherMixin.java | 12 +- .../fabric/mixin/WorldSaveHandlerMixin.java | 14 +- .../flan/fabric/mixin/XpEntityMixin.java | 10 +- .../currency/fabric/CommandCurrencyImpl.java | 43 +- .../fabric/PermissionNodeHandlerImpl.java | 37 +- .../playerability/PlayerAbilityEvents.java | 25 +- .../main/resources/flan.fabric.mixins.json | 4 +- forge/build.gradle | 43 +- .../flemmli97/flan/ForgeRegistryWrapper.java | 7 +- .../flan/api/forge/PermissionCheckEvent.java | 16 +- .../claim/forge/ClaimPermissionCheckImpl.java | 8 +- .../flan/forge/CrossPlatformStuffImpl.java | 20 +- .../flemmli97/flan/{ => forge}/FlanForge.java | 4 +- .../flan/forge/mixin/ForgeFireMixin.java | 17 +- .../forgeevent/BlockInteractEventsForge.java | 14 +- .../forgeevent/EntityInteractEventsForge.java | 34 +- .../forgeevent/ItemInteractEventsForge.java | 10 +- .../flan/forgeevent/ServerEvents.java | 12 +- .../flan/forgeevent/WorldEventsForge.java | 18 +- .../currency/forge/CommandCurrencyImpl.java | 46 +- .../forge/PermissionNodeHandlerImpl.java | 25 +- forge/src/main/resources/META-INF/mods.toml | 4 +- .../src/main/resources/flan.forge.mixins.json | 2 +- forge/src/main/resources/pack.mcmeta | 2 +- gradle.properties | 21 +- gradle/wrapper/gradle-wrapper.jar | Bin 58694 -> 59536 bytes gradle/wrapper/gradle-wrapper.properties | 2 +- settings.gradle | 7 +- 119 files changed, 2362 insertions(+), 2382 deletions(-) create mode 100644 common/src/main/java/io/github/flemmli97/flan/mixin/AbstractContainerAccessor.java create mode 100644 fabric/gradle/wrapper/gradle-wrapper.properties create mode 100644 fabric/src/main/java/io/github/flemmli97/flan/fabric/mixin/PlayerInteractEntityMixin.java delete mode 100644 fabric/src/main/java/io/github/flemmli97/flan/fabric/mixin/ServerPlayNetworkHandlerMixin.java rename forge/src/main/java/io/github/flemmli97/flan/{ => forge}/FlanForge.java (93%) diff --git a/build.gradle b/build.gradle index 8dbd99e..166f320 100644 --- a/build.gradle +++ b/build.gradle @@ -5,8 +5,8 @@ buildscript { } plugins { - id "architectury-plugin" version "3.1-SNAPSHOT" - id "dev.architectury.loom" version "0.7.2-SNAPSHOT" apply false + id "architectury-plugin" version "3.4-SNAPSHOT" + id "dev.architectury.loom" version "0.10.0-SNAPSHOT" apply false id 'com.matthewprenger.cursegradle' version '1.4.0' } @@ -27,7 +27,7 @@ subprojects { dependencies { minecraft "com.mojang:minecraft:${rootProject.minecraft_version}" - mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2" + mappings loom.officialMojangMappings() } } @@ -42,10 +42,7 @@ allprojects { tasks.withType(JavaCompile) { options.encoding = "UTF-8" - def targetVersion = 8 - if (JavaVersion.current().isJava9Compatible()) { - options.release = targetVersion - } + options.release = 17 } java { @@ -119,7 +116,7 @@ curseforge { addGameVersion "Fabric" mainArtifact(project(":fabric").tasks.getByName('remapJar')) { def txt = changelog(1).replace("\n-", "\n\n- ") - txt = txt + "\n\n" + "For past versions see: https://github.com/Flemmli97/Flan/blob/1.16/Changelog.md" + txt = txt + "\n\n" + "For past versions see: ${project.full_changelog}" changelog = txt changelogType = "markdown" releaseType = 'release' @@ -138,7 +135,7 @@ curseforge { addGameVersion "Forge" mainArtifact(project(":forge").tasks.getByName('remapJar')) { def txt = changelog(1).replace("\n-", "\n\n- ") - txt = txt + "\n\n" + "For past versions see: https://github.com/Flemmli97/Flan/blob/1.16/Changelog.md" + txt = txt + "\n\n" + "For past versions see: ${project.full_changelog}" changelog = txt changelogType = "markdown" releaseType = 'release' @@ -161,7 +158,7 @@ tasks.getByName("curseforge").doLast { def message = new Message() def version = project.curse_versions.split(', ')[0] message.setUsername("Curseforge Release") - message.setContent("<@&852113509243682817> ${project.project_name} ${project.mod_version} for Minecraft ${version} has been released!") + message.setContent("${project.discord_role} ${project.project_name} ${project.mod_version} for Minecraft ${version} has been released!") message.setAvatarUrl("https://cdn.discordapp.com/avatars/680540027255652407/e4b7a058b24843ae13389a9a3cc3ae8c.png?size=128") def embed = new Embed() diff --git a/common/build.gradle b/common/build.gradle index d2fd2f8..592e0ca 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -1,5 +1,5 @@ plugins { - id "com.github.johnrengelman.shadow" version "5.0.0" + id "com.github.johnrengelman.shadow" version "7.1.0" } configurations { @@ -34,10 +34,6 @@ transformProductionForge { input.set shadowJar.archiveFile } -java { - withSourcesJar() -} - publishing { publications { mavenCommon(MavenPublication) { diff --git a/common/src/main/java/io/github/flemmli97/flan/CrossPlatformStuff.java b/common/src/main/java/io/github/flemmli97/flan/CrossPlatformStuff.java index a469bbb..1ebab77 100644 --- a/common/src/main/java/io/github/flemmli97/flan/CrossPlatformStuff.java +++ b/common/src/main/java/io/github/flemmli97/flan/CrossPlatformStuff.java @@ -1,12 +1,12 @@ package io.github.flemmli97.flan; -import me.shedaniel.architectury.annotations.ExpectPlatform; -import net.minecraft.block.Block; -import net.minecraft.block.entity.BlockEntity; -import net.minecraft.entity.EntityType; -import net.minecraft.entity.effect.StatusEffect; -import net.minecraft.item.Item; +import dev.architectury.injectables.annotations.ExpectPlatform; import net.minecraft.nbt.CompoundTag; +import net.minecraft.world.effect.MobEffect; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.item.Item; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.entity.BlockEntity; import java.nio.file.Path; @@ -18,7 +18,7 @@ public class CrossPlatformStuff { } @ExpectPlatform - public static SimpleRegistryWrapper registryStatusEffects() { + public static SimpleRegistryWrapper registryStatusEffects() { throw new AssertionError(); } diff --git a/common/src/main/java/io/github/flemmli97/flan/SimpleRegistryWrapper.java b/common/src/main/java/io/github/flemmli97/flan/SimpleRegistryWrapper.java index b27e97c..b23afe3 100644 --- a/common/src/main/java/io/github/flemmli97/flan/SimpleRegistryWrapper.java +++ b/common/src/main/java/io/github/flemmli97/flan/SimpleRegistryWrapper.java @@ -1,15 +1,15 @@ package io.github.flemmli97.flan; -import net.minecraft.util.Identifier; +import net.minecraft.resources.ResourceLocation; /** * Simple structure to get stuff from registries */ public interface SimpleRegistryWrapper { - T getFromId(Identifier id); + T getFromId(ResourceLocation id); - Identifier getIDFrom(T entry); + ResourceLocation getIDFrom(T entry); Iterable getIterator(); } diff --git a/common/src/main/java/io/github/flemmli97/flan/api/ClaimHandler.java b/common/src/main/java/io/github/flemmli97/flan/api/ClaimHandler.java index 5796c76..38d3fc0 100644 --- a/common/src/main/java/io/github/flemmli97/flan/api/ClaimHandler.java +++ b/common/src/main/java/io/github/flemmli97/flan/api/ClaimHandler.java @@ -7,8 +7,8 @@ import io.github.flemmli97.flan.claim.ClaimStorage; import io.github.flemmli97.flan.player.OfflinePlayerData; import io.github.flemmli97.flan.player.PlayerClaimData; import net.minecraft.server.MinecraftServer; -import net.minecraft.server.network.ServerPlayerEntity; -import net.minecraft.server.world.ServerWorld; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.server.level.ServerPlayer; import java.util.UUID; @@ -19,14 +19,14 @@ public class ClaimHandler { * You can then use IPermissionContainer#getForPermissionCheck * to return an {@link IPermissionContainer} for which you can then check permissions against */ - public static IPermissionStorage getPermissionStorage(ServerWorld world) { + public static IPermissionStorage getPermissionStorage(ServerLevel world) { return ClaimStorage.get(world); } /** * Gets the claim data for the given player */ - public static IPlayerData getPlayerData(ServerPlayerEntity player) { + public static IPlayerData getPlayerData(ServerPlayer player) { return PlayerClaimData.get(player); } @@ -34,7 +34,7 @@ public class ClaimHandler { * Same as the above but with an uuid. Use this if the player is not online. */ public static IPlayerData getPlayerData(MinecraftServer server, UUID uuid) { - ServerPlayerEntity player = server.getPlayerManager().getPlayer(uuid); + ServerPlayer player = server.getPlayerList().getPlayer(uuid); if (player != null) return getPlayerData(player); return new OfflinePlayerData(server, uuid); diff --git a/common/src/main/java/io/github/flemmli97/flan/api/data/IPermissionContainer.java b/common/src/main/java/io/github/flemmli97/flan/api/data/IPermissionContainer.java index a5138b2..acd5360 100644 --- a/common/src/main/java/io/github/flemmli97/flan/api/data/IPermissionContainer.java +++ b/common/src/main/java/io/github/flemmli97/flan/api/data/IPermissionContainer.java @@ -1,12 +1,12 @@ package io.github.flemmli97.flan.api.data; import io.github.flemmli97.flan.api.permission.ClaimPermission; -import net.minecraft.server.network.ServerPlayerEntity; -import net.minecraft.util.math.BlockPos; +import net.minecraft.core.BlockPos; +import net.minecraft.server.level.ServerPlayer; public interface IPermissionContainer { - default boolean canInteract(ServerPlayerEntity player, ClaimPermission perm, BlockPos pos) { + default boolean canInteract(ServerPlayer player, ClaimPermission perm, BlockPos pos) { return this.canInteract(player, perm, pos, false); } @@ -15,6 +15,6 @@ public interface IPermissionContainer { * * @param player The player doing the action. Can be null */ - boolean canInteract(ServerPlayerEntity player, ClaimPermission perm, BlockPos pos, boolean message); + boolean canInteract(ServerPlayer player, ClaimPermission perm, BlockPos pos, boolean message); } diff --git a/common/src/main/java/io/github/flemmli97/flan/api/data/IPermissionStorage.java b/common/src/main/java/io/github/flemmli97/flan/api/data/IPermissionStorage.java index ebc63bf..d8c7389 100644 --- a/common/src/main/java/io/github/flemmli97/flan/api/data/IPermissionStorage.java +++ b/common/src/main/java/io/github/flemmli97/flan/api/data/IPermissionStorage.java @@ -1,6 +1,6 @@ package io.github.flemmli97.flan.api.data; -import net.minecraft.util.math.BlockPos; +import net.minecraft.core.BlockPos; public interface IPermissionStorage { diff --git a/common/src/main/java/io/github/flemmli97/flan/api/permission/ClaimPermission.java b/common/src/main/java/io/github/flemmli97/flan/api/permission/ClaimPermission.java index 107c2e9..dc7f20d 100644 --- a/common/src/main/java/io/github/flemmli97/flan/api/permission/ClaimPermission.java +++ b/common/src/main/java/io/github/flemmli97/flan/api/permission/ClaimPermission.java @@ -1,9 +1,9 @@ package io.github.flemmli97.flan.api.permission; import io.github.flemmli97.flan.claim.Claim; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.util.math.BlockPos; +import net.minecraft.core.BlockPos; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; import java.util.function.Supplier; @@ -56,7 +56,7 @@ public class ClaimPermission { } public interface ClaimTest { - PermissionFlag test(Claim claim, PlayerEntity player, BlockPos pos); + PermissionFlag test(Claim claim, Player player, BlockPos pos); } private static final ClaimTest pass = (claim, player, pos) -> PermissionFlag.PASS; diff --git a/common/src/main/java/io/github/flemmli97/flan/api/permission/ObjectToPermissionMap.java b/common/src/main/java/io/github/flemmli97/flan/api/permission/ObjectToPermissionMap.java index 14e1656..630cf3d 100644 --- a/common/src/main/java/io/github/flemmli97/flan/api/permission/ObjectToPermissionMap.java +++ b/common/src/main/java/io/github/flemmli97/flan/api/permission/ObjectToPermissionMap.java @@ -1,36 +1,36 @@ package io.github.flemmli97.flan.api.permission; import io.github.flemmli97.flan.CrossPlatformStuff; -import net.minecraft.block.AbstractButtonBlock; -import net.minecraft.block.AbstractPressurePlateBlock; -import net.minecraft.block.AbstractRedstoneGateBlock; -import net.minecraft.block.AnvilBlock; -import net.minecraft.block.BeaconBlock; -import net.minecraft.block.BedBlock; -import net.minecraft.block.BellBlock; -import net.minecraft.block.Block; -import net.minecraft.block.CampfireBlock; -import net.minecraft.block.ChorusFlowerBlock; -import net.minecraft.block.DaylightDetectorBlock; -import net.minecraft.block.DoorBlock; -import net.minecraft.block.EnchantingTableBlock; -import net.minecraft.block.EnderChestBlock; -import net.minecraft.block.FarmlandBlock; -import net.minecraft.block.FenceGateBlock; -import net.minecraft.block.JukeboxBlock; -import net.minecraft.block.LeverBlock; -import net.minecraft.block.NetherPortalBlock; -import net.minecraft.block.NoteBlock; -import net.minecraft.block.RedstoneWireBlock; -import net.minecraft.block.TargetBlock; -import net.minecraft.block.TntBlock; -import net.minecraft.block.TrapdoorBlock; -import net.minecraft.block.TurtleEggBlock; -import net.minecraft.item.BucketItem; -import net.minecraft.item.EnderPearlItem; -import net.minecraft.item.Item; -import net.minecraft.item.Items; import net.minecraft.server.MinecraftServer; +import net.minecraft.world.item.BucketItem; +import net.minecraft.world.item.EnderpearlItem; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.Items; +import net.minecraft.world.level.block.AnvilBlock; +import net.minecraft.world.level.block.BasePressurePlateBlock; +import net.minecraft.world.level.block.BeaconBlock; +import net.minecraft.world.level.block.BedBlock; +import net.minecraft.world.level.block.BellBlock; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.ButtonBlock; +import net.minecraft.world.level.block.CampfireBlock; +import net.minecraft.world.level.block.ChorusFlowerBlock; +import net.minecraft.world.level.block.DaylightDetectorBlock; +import net.minecraft.world.level.block.DiodeBlock; +import net.minecraft.world.level.block.DoorBlock; +import net.minecraft.world.level.block.EnchantmentTableBlock; +import net.minecraft.world.level.block.EnderChestBlock; +import net.minecraft.world.level.block.FarmBlock; +import net.minecraft.world.level.block.FenceGateBlock; +import net.minecraft.world.level.block.JukeboxBlock; +import net.minecraft.world.level.block.LeverBlock; +import net.minecraft.world.level.block.NetherPortalBlock; +import net.minecraft.world.level.block.NoteBlock; +import net.minecraft.world.level.block.RedStoneWireBlock; +import net.minecraft.world.level.block.TargetBlock; +import net.minecraft.world.level.block.TntBlock; +import net.minecraft.world.level.block.TrapDoorBlock; +import net.minecraft.world.level.block.TurtleEggBlock; import java.util.HashMap; import java.util.Map; @@ -95,21 +95,21 @@ public class ObjectToPermissionMap { registerBlockPredicateMap((block) -> block instanceof BeaconBlock, () -> PermissionRegistry.BEACON); registerBlockPredicateMap((block) -> block instanceof DoorBlock, () -> PermissionRegistry.DOOR); registerBlockPredicateMap((block) -> block instanceof FenceGateBlock, () -> PermissionRegistry.FENCEGATE); - registerBlockPredicateMap((block) -> block instanceof TrapdoorBlock, () -> PermissionRegistry.TRAPDOOR); - registerBlockPredicateMap((block) -> block instanceof LeverBlock || block instanceof AbstractButtonBlock, () -> PermissionRegistry.BUTTONLEVER); + registerBlockPredicateMap((block) -> block instanceof TrapDoorBlock, () -> PermissionRegistry.TRAPDOOR); + registerBlockPredicateMap((block) -> block instanceof LeverBlock || block instanceof ButtonBlock, () -> PermissionRegistry.BUTTONLEVER); registerBlockPredicateMap((block) -> block instanceof NoteBlock, () -> PermissionRegistry.NOTEBLOCK); - registerBlockPredicateMap((block) -> block instanceof AbstractRedstoneGateBlock || block instanceof RedstoneWireBlock || block instanceof DaylightDetectorBlock, () -> PermissionRegistry.REDSTONE); + registerBlockPredicateMap((block) -> block instanceof DiodeBlock || block instanceof RedStoneWireBlock || block instanceof DaylightDetectorBlock, () -> PermissionRegistry.REDSTONE); registerBlockPredicateMap((block) -> block instanceof JukeboxBlock, () -> PermissionRegistry.JUKEBOX); - registerBlockPredicateMap((block) -> block instanceof AbstractPressurePlateBlock, () -> PermissionRegistry.PRESSUREPLATE); + registerBlockPredicateMap((block) -> block instanceof BasePressurePlateBlock, () -> PermissionRegistry.PRESSUREPLATE); registerBlockPredicateMap((block) -> block instanceof NetherPortalBlock, () -> PermissionRegistry.PORTAL); - registerBlockPredicateMap((block) -> block instanceof TurtleEggBlock || block instanceof FarmlandBlock, () -> PermissionRegistry.TRAMPLE); + registerBlockPredicateMap((block) -> block instanceof TurtleEggBlock || block instanceof FarmBlock, () -> PermissionRegistry.TRAMPLE); registerBlockPredicateMap((block) -> block instanceof TargetBlock, () -> PermissionRegistry.TARGETBLOCK); registerBlockPredicateMap((block) -> block instanceof BellBlock || block instanceof CampfireBlock || block instanceof TntBlock || block instanceof ChorusFlowerBlock, () -> PermissionRegistry.PROJECTILES); registerBlockPredicateMap((block) -> block instanceof EnderChestBlock, () -> PermissionRegistry.ENDERCHEST); - registerBlockPredicateMap((block) -> block instanceof EnchantingTableBlock, () -> PermissionRegistry.ENCHANTMENTTABLE); + registerBlockPredicateMap((block) -> block instanceof EnchantmentTableBlock, () -> PermissionRegistry.ENCHANTMENTTABLE); - registerItemPredicateMap(item -> item instanceof EnderPearlItem, () -> PermissionRegistry.ENDERPEARL); + registerItemPredicateMap(item -> item instanceof EnderpearlItem, () -> PermissionRegistry.ENDERPEARL); registerItemPredicateMap(item -> item instanceof BucketItem, () -> PermissionRegistry.BUCKET); registerItemPredicateMap(item -> item == Items.END_CRYSTAL, () -> PermissionRegistry.ENDCRYSTALPLACE); registerItemPredicateMap(item -> item == Items.CHORUS_FRUIT, () -> PermissionRegistry.CHORUSFRUIT); diff --git a/common/src/main/java/io/github/flemmli97/flan/api/permission/PermissionRegistry.java b/common/src/main/java/io/github/flemmli97/flan/api/permission/PermissionRegistry.java index 7df869a..9ffcb6e 100644 --- a/common/src/main/java/io/github/flemmli97/flan/api/permission/PermissionRegistry.java +++ b/common/src/main/java/io/github/flemmli97/flan/api/permission/PermissionRegistry.java @@ -1,10 +1,10 @@ package io.github.flemmli97.flan.api.permission; import io.github.flemmli97.flan.config.ConfigHandler; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.util.Identifier; -import net.minecraft.village.raid.Raid; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.entity.raid.Raid; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; import java.util.ArrayList; import java.util.Collection; @@ -21,9 +21,9 @@ public class PermissionRegistry { private static final Map permissions = new LinkedHashMap<>(); private static final Map globalPermissions = new LinkedHashMap<>(); - private static final Map interactBlocks = new HashMap<>(); - private static final Map breakBlocks = new HashMap<>(); - private static final Map items = new HashMap<>(); + private static final Map interactBlocks = new HashMap<>(); + private static final Map breakBlocks = new HashMap<>(); + private static final Map items = new HashMap<>(); private static boolean locked; @@ -55,7 +55,7 @@ public class PermissionRegistry { public static ClaimPermission TRAMPLE = register(new ClaimPermission("TRAMPLE", () -> new ItemStack(Items.FARMLAND), "Permission to enable block trampling", "(farmland, turtle eggs)")); public static ClaimPermission FROSTWALKER = register(new ClaimPermission("FROSTWALKER", () -> new ItemStack(Items.LEATHER_BOOTS), "Permission for frostwalker to activate")); public static ClaimPermission PORTAL = register(new ClaimPermission("PORTAL", () -> new ItemStack(Items.OBSIDIAN), true, "Permission to use nether portals")); - public static ClaimPermission RAID = register(new ClaimPermission("RAID", Raid::getOminousBanner, "Permission to trigger raids in claim.", "Wont prevent raids (just) outside")); + public static ClaimPermission RAID = register(new ClaimPermission("RAID", Raid::getLeaderBannerInstance, "Permission to trigger raids in claim.", "Wont prevent raids (just) outside")); public static ClaimPermission BOAT = register(new ClaimPermission("BOAT", () -> new ItemStack(Items.OAK_BOAT), "Permission to sit in boats")); public static ClaimPermission MINECART = register(new ClaimPermission("MINECART", () -> new ItemStack(Items.MINECART), "Permission to sit in minecarts")); public static ClaimPermission BUCKET = register(new ClaimPermission("BUCKET", () -> new ItemStack(Items.BUCKET), "Permission to take liquids with buckets")); @@ -121,23 +121,23 @@ public class PermissionRegistry { return globalPermissions.values(); } - public static ClaimPermission registerBreakPerm(ClaimPermission perm, Identifier... affectedBlocks) { + public static ClaimPermission registerBreakPerm(ClaimPermission perm, ResourceLocation... affectedBlocks) { ClaimPermission reg = register(perm); - for (Identifier blocks : affectedBlocks) + for (ResourceLocation blocks : affectedBlocks) breakBlocks.put(blocks, perm); return reg; } - public static ClaimPermission registerBlockInteract(ClaimPermission perm, Identifier... affectedBlocks) { + public static ClaimPermission registerBlockInteract(ClaimPermission perm, ResourceLocation... affectedBlocks) { ClaimPermission reg = register(perm); - for (Identifier blocks : affectedBlocks) + for (ResourceLocation blocks : affectedBlocks) interactBlocks.put(blocks, perm); return reg; } - public static ClaimPermission registerItemUse(ClaimPermission perm, Identifier... affectedBlocks) { + public static ClaimPermission registerItemUse(ClaimPermission perm, ResourceLocation... affectedBlocks) { ClaimPermission reg = register(perm); - for (Identifier blocks : affectedBlocks) + for (ResourceLocation blocks : affectedBlocks) items.put(blocks, perm); return reg; } diff --git a/common/src/main/java/io/github/flemmli97/flan/claim/Claim.java b/common/src/main/java/io/github/flemmli97/flan/claim/Claim.java index 50af0d2..3c69814 100644 --- a/common/src/main/java/io/github/flemmli97/flan/claim/Claim.java +++ b/common/src/main/java/io/github/flemmli97/flan/claim/Claim.java @@ -5,7 +5,6 @@ import com.google.common.collect.Lists; import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; -import com.mojang.authlib.GameProfile; import io.github.flemmli97.flan.CrossPlatformStuff; import io.github.flemmli97.flan.Flan; import io.github.flemmli97.flan.api.data.IPermissionContainer; @@ -15,20 +14,21 @@ import io.github.flemmli97.flan.config.Config; import io.github.flemmli97.flan.config.ConfigHandler; import io.github.flemmli97.flan.player.LogoutTracker; import io.github.flemmli97.flan.player.PlayerClaimData; -import net.minecraft.entity.effect.StatusEffect; -import net.minecraft.entity.effect.StatusEffectInstance; -import net.minecraft.network.packet.s2c.play.TitleS2CPacket; +import net.minecraft.ChatFormatting; +import net.minecraft.core.BlockPos; +import net.minecraft.network.chat.Component; +import net.minecraft.network.protocol.game.ClientboundSetSubtitleTextPacket; +import net.minecraft.network.protocol.game.ClientboundSetTitleTextPacket; +import net.minecraft.resources.ResourceLocation; import net.minecraft.server.MinecraftServer; -import net.minecraft.server.network.ServerPlayerEntity; -import net.minecraft.server.world.ServerWorld; -import net.minecraft.text.Text; -import net.minecraft.util.ActionResult; -import net.minecraft.util.Formatting; -import net.minecraft.util.Identifier; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Box; -import net.minecraft.world.Heightmap; -import net.minecraft.world.chunk.ChunkStatus; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.effect.MobEffect; +import net.minecraft.world.effect.MobEffectInstance; +import net.minecraft.world.level.chunk.ChunkStatus; +import net.minecraft.world.level.levelgen.Heightmap; +import net.minecraft.world.phys.AABB; import java.util.ArrayList; import java.util.Arrays; @@ -65,30 +65,30 @@ public class Claim implements IPermissionContainer { */ private boolean removed; - private final ServerWorld world; + private final ServerLevel world; - private final Map potions = new HashMap<>(); + private final Map potions = new HashMap<>(); - public Text enterTitle, enterSubtitle, leaveTitle, leaveSubtitle; + public Component enterTitle, enterSubtitle, leaveTitle, leaveSubtitle; - private Claim(ServerWorld world) { + private Claim(ServerLevel world) { this.world = world; } - public Claim(BlockPos pos1, BlockPos pos2, ServerPlayerEntity creator) { - this(pos1.getX(), pos2.getX(), pos1.getZ(), pos2.getZ(), Math.min(pos1.getY(), pos2.getY()), creator.getUuid(), creator.getServerWorld(), PlayerClaimData.get(creator).playerDefaultGroups().isEmpty()); + public Claim(BlockPos pos1, BlockPos pos2, ServerPlayer creator) { + this(pos1.getX(), pos2.getX(), pos1.getZ(), pos2.getZ(), Math.min(pos1.getY(), pos2.getY()), creator.getUUID(), creator.getLevel(), PlayerClaimData.get(creator).playerDefaultGroups().isEmpty()); PlayerClaimData.get(creator).playerDefaultGroups().forEach((s, m) -> m.forEach((perm, bool) -> this.editPerms(null, s, perm, bool ? 1 : 0, true))); } - public Claim(BlockPos pos1, BlockPos pos2, UUID creator, ServerWorld world) { + public Claim(BlockPos pos1, BlockPos pos2, UUID creator, ServerLevel world) { this(pos1.getX(), pos2.getX(), pos1.getZ(), pos2.getZ(), Math.min(pos1.getY(), pos2.getY()), creator, world); } - public Claim(int x1, int x2, int z1, int z2, int minY, UUID creator, ServerWorld world) { + public Claim(int x1, int x2, int z1, int z2, int minY, UUID creator, ServerLevel world) { this(x1, x2, z1, z2, minY, creator, world, true); } - public Claim(int x1, int x2, int z1, int z2, int minY, UUID creator, ServerWorld world, boolean setDefaultGroups) { + public Claim(int x1, int x2, int z1, int z2, int minY, UUID creator, ServerLevel world, boolean setDefaultGroups) { this.minX = Math.min(x1, x2); this.minZ = Math.min(z1, z2); this.maxX = Math.max(x1, x2); @@ -103,7 +103,7 @@ public class Claim implements IPermissionContainer { ConfigHandler.config.defaultGroups.forEach((s, m) -> m.forEach((perm, bool) -> this.editPerms(null, s, perm, bool ? 1 : 0, true))); } - public static Claim fromJson(JsonObject obj, UUID owner, ServerWorld world) { + public static Claim fromJson(JsonObject obj, UUID owner, ServerLevel world) { Claim claim = new Claim(world); claim.readJson(obj, owner); ClaimUpdater.updateClaim(claim); @@ -112,7 +112,7 @@ public class Claim implements IPermissionContainer { private BlockPos getInitCenterPos() { BlockPos center = new BlockPos(this.minX + (this.maxX - this.minX) * 0.5, 0, this.minZ + (this.maxZ - this.minZ) * 0.5); - int y = this.world.getChunk(center.getX() >> 4, center.getZ() >> 4, ChunkStatus.HEIGHTMAPS).sampleHeightmap(Heightmap.Type.MOTION_BLOCKING, center.getX() & 15, center.getZ() & 15); + int y = this.world.getChunk(center.getX() >> 4, center.getZ() >> 4, ChunkStatus.HEIGHTMAPS).getHeight(Heightmap.Types.MOTION_BLOCKING, center.getX() & 15, center.getZ() & 15); return new BlockPos(center.getX(), y + 1, center.getZ()); } @@ -148,13 +148,13 @@ public class Claim implements IPermissionContainer { return this.owner; } - public Optional getOwnerPlayer() { + public Optional getOwnerPlayer() { if (this.getOwner() != null) - return Optional.ofNullable(this.world.getServer().getPlayerManager().getPlayer(this.getOwner())); + return Optional.ofNullable(this.world.getServer().getPlayerList().getPlayer(this.getOwner())); return Optional.empty(); } - public ServerWorld getWorld() { + public ServerLevel getWorld() { return this.world; } @@ -178,9 +178,9 @@ public class Claim implements IPermissionContainer { this.setDirty(true); } - public void toggleAdminClaim(ServerPlayerEntity player, boolean flag) { + public void toggleAdminClaim(ServerPlayer player, boolean flag) { if (!flag) - this.transferOwner(player.getUuid()); + this.transferOwner(player.getUUID()); else { this.owner = null; this.subClaims.forEach(claim -> claim.owner = null); @@ -217,7 +217,7 @@ public class Claim implements IPermissionContainer { return this.minX <= other.maxX && this.maxX >= other.minX && this.minZ <= other.maxZ && this.maxZ >= other.minZ; } - public boolean intersects(Box box) { + public boolean intersects(AABB box) { return this.minX < box.maxX && this.maxX + 1 > box.minX && this.minZ < box.maxZ && this.maxZ + 1 > box.minZ && box.maxY >= this.minY; } @@ -235,16 +235,16 @@ public class Claim implements IPermissionContainer { } @Override - public boolean canInteract(ServerPlayerEntity player, ClaimPermission perm, BlockPos pos, boolean message) { - ActionResult res = ClaimPermissionCheck.check(player, perm, pos); - if (res != ActionResult.PASS) - return res != ActionResult.FAIL; + public boolean canInteract(ServerPlayer player, ClaimPermission perm, BlockPos pos, boolean message) { + InteractionResult res = ClaimPermissionCheck.check(player, perm, pos); + if (res != InteractionResult.PASS) + return res != InteractionResult.FAIL; if (perm != null) { ClaimPermission.PermissionFlag flag = perm.test.test(this, player, pos); if (flag != ClaimPermission.PermissionFlag.PASS) { if (flag == ClaimPermission.PermissionFlag.NO) { if (message) - player.sendMessage(PermHelper.simpleColoredText(ConfigHandler.lang.noPermissionSimple, Formatting.DARK_RED), true); + player.displayClientMessage(PermHelper.simpleColoredText(ConfigHandler.lang.noPermissionSimple, ChatFormatting.DARK_RED), true); return false; } return true; @@ -256,7 +256,7 @@ public class Claim implements IPermissionContainer { if (global.getValue() || (player != null && this.isAdminIgnore(player))) return true; if (message) - player.sendMessage(PermHelper.simpleColoredText(ConfigHandler.lang.noPermissionSimple, Formatting.DARK_RED), true); + player.displayClientMessage(PermHelper.simpleColoredText(ConfigHandler.lang.noPermissionSimple, ChatFormatting.DARK_RED), true); return false; } if (ConfigHandler.config.offlineProtectActivation != -1 && (LogoutTracker.getInstance(this.world.getServer()).justLoggedOut(this.getOwner()) || this.getOwnerPlayer().isPresent())) { @@ -272,10 +272,10 @@ public class Claim implements IPermissionContainer { if (this.hasPerm(perm)) return true; if (message) - player.sendMessage(PermHelper.simpleColoredText(ConfigHandler.lang.noPermissionSimple, Formatting.DARK_RED), true); + player.displayClientMessage(PermHelper.simpleColoredText(ConfigHandler.lang.noPermissionSimple, ChatFormatting.DARK_RED), true); return false; } - if (this.isAdminIgnore(player) || player.getUuid().equals(this.owner)) + if (this.isAdminIgnore(player) || player.getUUID().equals(this.owner)) return true; if (perm != PermissionRegistry.EDITCLAIM && perm != PermissionRegistry.EDITPERMS) for (Claim claim : this.subClaims) { @@ -283,25 +283,25 @@ public class Claim implements IPermissionContainer { return claim.canInteract(player, perm, pos, message); } } - if (this.playersGroups.containsKey(player.getUuid())) { - Map map = this.permissions.get(this.playersGroups.get(player.getUuid())); + if (this.playersGroups.containsKey(player.getUUID())) { + Map map = this.permissions.get(this.playersGroups.get(player.getUUID())); if (map != null && map.containsKey(perm)) { if (map.get(perm)) return true; if (message) - player.sendMessage(PermHelper.simpleColoredText(ConfigHandler.lang.noPermissionSimple, Formatting.DARK_RED), true); + player.displayClientMessage(PermHelper.simpleColoredText(ConfigHandler.lang.noPermissionSimple, ChatFormatting.DARK_RED), true); return false; } } if (this.hasPerm(perm)) return true; if (message) - player.sendMessage(PermHelper.simpleColoredText(ConfigHandler.lang.noPermissionSimple, Formatting.DARK_RED), true); + player.displayClientMessage(PermHelper.simpleColoredText(ConfigHandler.lang.noPermissionSimple, ChatFormatting.DARK_RED), true); return false; } - private boolean isAdminIgnore(ServerPlayerEntity player) { - return player == null || ((this.isAdminClaim() && player.hasPermissionLevel(2)) || PlayerClaimData.get(player).isAdminIgnoreClaim()); + private boolean isAdminIgnore(ServerPlayer player) { + return player == null || ((this.isAdminClaim() && player.hasPermissions(2)) || PlayerClaimData.get(player).isAdminIgnoreClaim()); } /** @@ -408,17 +408,13 @@ public class Claim implements IPermissionContainer { l.add(uuid); }); List names = new ArrayList<>(); - l.forEach(uuid -> { - GameProfile prof = server.getUserCache().getByUuid(uuid); - if (prof != null) - names.add(prof.getName()); - }); + l.forEach(uuid -> server.getProfileCache().get(uuid).ifPresent(prof -> names.add(prof.getName()))); names.sort(null); return names; } - public boolean editGlobalPerms(ServerPlayerEntity player, ClaimPermission toggle, int mode) { - if ((player != null && !this.canInteract(player, PermissionRegistry.EDITPERMS, player.getBlockPos())) || (!this.isAdminClaim() && ConfigHandler.config.globallyDefined(this.world, toggle))) + public boolean editGlobalPerms(ServerPlayer player, ClaimPermission toggle, int mode) { + if ((player != null && !this.canInteract(player, PermissionRegistry.EDITPERMS, player.blockPosition())) || (!this.isAdminClaim() && ConfigHandler.config.globallyDefined(this.world, toggle))) return false; if (mode > 1) mode = -1; @@ -430,7 +426,7 @@ public class Claim implements IPermissionContainer { return true; } - public boolean editPerms(ServerPlayerEntity player, String group, ClaimPermission perm, int mode) { + public boolean editPerms(ServerPlayer player, String group, ClaimPermission perm, int mode) { return this.editPerms(player, group, perm, mode, false); } @@ -440,10 +436,10 @@ public class Claim implements IPermissionContainer { * @param mode -1 = makes it resort to the global perm, 0 = deny perm, 1 = allow perm * @return If editing was successful or not */ - public boolean editPerms(ServerPlayerEntity player, String group, ClaimPermission perm, int mode, boolean alwaysCan) { + public boolean editPerms(ServerPlayer player, String group, ClaimPermission perm, int mode, boolean alwaysCan) { if (PermissionRegistry.globalPerms().contains(perm) || (!this.isAdminClaim() && ConfigHandler.config.globallyDefined(this.world, perm))) return false; - if (alwaysCan || this.canInteract(player, PermissionRegistry.EDITPERMS, player.getBlockPos())) { + if (alwaysCan || this.canInteract(player, PermissionRegistry.EDITPERMS, player.blockPosition())) { if (mode > 1) mode = -1; boolean has = this.permissions.containsKey(group); @@ -460,8 +456,8 @@ public class Claim implements IPermissionContainer { return false; } - public boolean removePermGroup(ServerPlayerEntity player, String group) { - if (this.canInteract(player, PermissionRegistry.EDITPERMS, player.getBlockPos())) { + public boolean removePermGroup(ServerPlayer player, String group) { + if (this.canInteract(player, PermissionRegistry.EDITPERMS, player.blockPosition())) { this.permissions.remove(group); List toRemove = new ArrayList<>(); this.playersGroups.forEach((uuid, g) -> { @@ -496,54 +492,54 @@ public class Claim implements IPermissionContainer { return false; } - public void addPotion(StatusEffect effect, int amplifier) { + public void addPotion(MobEffect effect, int amplifier) { this.potions.put(effect, amplifier); this.setDirty(true); } - public void removePotion(StatusEffect effect) { + public void removePotion(MobEffect effect) { this.potions.remove(effect); this.setDirty(true); } - public Map getPotions() { + public Map getPotions() { return this.potions; } - public void applyEffects(ServerPlayerEntity player) { - if (player.world.getTime() % 80 == 0) - this.potions.forEach((effect, amp) -> player.applyStatusEffect(new StatusEffectInstance(effect, 200, amp - 1, true, false))); + public void applyEffects(ServerPlayer player) { + if (player.level.getGameTime() % 80 == 0) + this.potions.forEach((effect, amp) -> player.forceAddEffect(new MobEffectInstance(effect, 200, amp - 1, true, false), null)); } public BlockPos getHomePos() { return this.homePos; } - public void setEnterTitle(Text title, Text sub) { + public void setEnterTitle(Component title, Component sub) { this.enterTitle = title; this.enterSubtitle = sub; this.setDirty(true); } - public void setLeaveTitle(Text title, Text sub) { + public void setLeaveTitle(Component title, Component sub) { this.leaveTitle = title; this.leaveSubtitle = sub; this.setDirty(true); } - public void displayEnterTitle(ServerPlayerEntity player) { + public void displayEnterTitle(ServerPlayer player) { if (this.enterTitle != null) { - player.networkHandler.sendPacket(new TitleS2CPacket(TitleS2CPacket.Action.TITLE, this.enterTitle)); + player.connection.send(new ClientboundSetTitleTextPacket(this.enterTitle)); if (this.enterSubtitle != null) - player.networkHandler.sendPacket(new TitleS2CPacket(TitleS2CPacket.Action.SUBTITLE, this.enterSubtitle)); + player.connection.send(new ClientboundSetSubtitleTextPacket(this.enterSubtitle)); } } - public void displayLeaveTitle(ServerPlayerEntity player) { + public void displayLeaveTitle(ServerPlayer player) { if (this.leaveTitle != null) { - player.networkHandler.sendPacket(new TitleS2CPacket(TitleS2CPacket.Action.TITLE, this.leaveTitle)); + player.connection.send(new ClientboundSetTitleTextPacket(this.leaveTitle)); if (this.leaveSubtitle != null) - player.networkHandler.sendPacket(new TitleS2CPacket(TitleS2CPacket.Action.SUBTITLE, this.leaveSubtitle)); + player.connection.send(new ClientboundSetSubtitleTextPacket(this.leaveSubtitle)); } } @@ -579,18 +575,18 @@ public class Claim implements IPermissionContainer { } String message = ConfigHandler.fromJson(obj, "EnterTitle", ""); if (!message.isEmpty()) - this.enterTitle = Text.Serializer.fromJson(message); + this.enterTitle = Component.Serializer.fromJson(message); message = ConfigHandler.fromJson(obj, "EnterSubtitle", ""); if (!message.isEmpty()) - this.enterSubtitle = Text.Serializer.fromJson(message); + this.enterSubtitle = Component.Serializer.fromJson(message); message = ConfigHandler.fromJson(obj, "LeaveTitle", ""); if (!message.isEmpty()) - this.leaveTitle = Text.Serializer.fromJson(message); + this.leaveTitle = Component.Serializer.fromJson(message); message = ConfigHandler.fromJson(obj, "LeaveSubtitle", ""); if (!message.isEmpty()) - this.leaveSubtitle = Text.Serializer.fromJson(message); + this.leaveSubtitle = Component.Serializer.fromJson(message); JsonObject potion = ConfigHandler.fromJson(obj, "Potions"); - potion.entrySet().forEach(e -> this.potions.put(CrossPlatformStuff.registryStatusEffects().getFromId(new Identifier(e.getKey())), e.getValue().getAsInt())); + potion.entrySet().forEach(e -> this.potions.put(CrossPlatformStuff.registryStatusEffects().getFromId(new ResourceLocation(e.getKey())), e.getValue().getAsInt())); if (ConfigHandler.fromJson(obj, "AdminClaim", false)) this.owner = null; else @@ -655,10 +651,10 @@ public class Claim implements IPermissionContainer { home.add(this.homePos.getY()); home.add(this.homePos.getZ()); obj.add("Home", home); - obj.addProperty("EnterTitle", this.enterTitle == null ? "" : Text.Serializer.toJson(this.enterTitle)); - obj.addProperty("EnterSubtitle", this.enterSubtitle == null ? "" : Text.Serializer.toJson(this.enterSubtitle)); - obj.addProperty("LeaveTitle", this.leaveTitle == null ? "" : Text.Serializer.toJson(this.leaveTitle)); - obj.addProperty("LeaveSubtitle", this.leaveSubtitle == null ? "" : Text.Serializer.toJson(this.leaveSubtitle)); + obj.addProperty("EnterTitle", this.enterTitle == null ? "" : Component.Serializer.toJson(this.enterTitle)); + obj.addProperty("EnterSubtitle", this.enterSubtitle == null ? "" : Component.Serializer.toJson(this.enterSubtitle)); + obj.addProperty("LeaveTitle", this.leaveTitle == null ? "" : Component.Serializer.toJson(this.leaveTitle)); + obj.addProperty("LeaveSubtitle", this.leaveSubtitle == null ? "" : Component.Serializer.toJson(this.leaveSubtitle)); JsonObject potions = new JsonObject(); this.potions.forEach((effect, amp) -> potions.addProperty(CrossPlatformStuff.registryStatusEffects().getIDFrom(effect).toString(), amp)); obj.add("Potions", potions); @@ -730,46 +726,45 @@ public class Claim implements IPermissionContainer { return String.format("%s:[x=%d,z=%d] - [x=%d,z=%d]", this.claimName, this.minX, this.minZ, this.maxX, this.maxZ); } - public List infoString(ServerPlayerEntity player, InfoType infoType) { - boolean perms = this.canInteract(player, PermissionRegistry.EDITPERMS, player.getBlockPos()); - List l = new ArrayList<>(); - l.add(PermHelper.simpleColoredText("=============================================", Formatting.GREEN)); - GameProfile prof = this.owner != null ? player.getServer().getUserCache().getByUuid(this.owner) : null; - String ownerName = this.isAdminClaim() ? "Admin" : prof != null ? prof.getName() : ""; + public List infoString(ServerPlayer player, InfoType infoType) { + boolean perms = this.canInteract(player, PermissionRegistry.EDITPERMS, player.blockPosition()); + List l = new ArrayList<>(); + l.add(PermHelper.simpleColoredText("=============================================", ChatFormatting.GREEN)); + String ownerName = this.isAdminClaim() ? "Admin" : player.getServer().getProfileCache().get(this.owner).map(prof -> prof.getName()).orElse(""); if (this.parent == null) { if (this.claimName.isEmpty()) - l.add(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.claimBasicInfo, ownerName, this.minX, this.minZ, this.maxX, this.maxZ, this.subClaims.size()), Formatting.GOLD)); + l.add(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.claimBasicInfo, ownerName, this.minX, this.minZ, this.maxX, this.maxZ, this.subClaims.size()), ChatFormatting.GOLD)); else - l.add(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.claimBasicInfoNamed, ownerName, this.minX, this.minZ, this.maxX, this.maxZ, this.subClaims.size(), this.claimName), Formatting.GOLD)); + l.add(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.claimBasicInfoNamed, ownerName, this.minX, this.minZ, this.maxX, this.maxZ, this.subClaims.size(), this.claimName), ChatFormatting.GOLD)); } else { if (this.claimName.isEmpty()) - l.add(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.claimBasicInfoSub, ownerName, this.minX, this.minZ, this.maxX, this.maxZ), Formatting.GOLD)); + l.add(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.claimBasicInfoSub, ownerName, this.minX, this.minZ, this.maxX, this.maxZ), ChatFormatting.GOLD)); else - l.add(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.claimBasicInfoSubNamed, ownerName, this.minX, this.minZ, this.maxX, this.maxZ, this.claimName), Formatting.GOLD)); + l.add(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.claimBasicInfoSubNamed, ownerName, this.minX, this.minZ, this.maxX, this.maxZ, this.claimName), ChatFormatting.GOLD)); } if (perms) { if (infoType == InfoType.ALL || infoType == InfoType.GLOBAL) - l.add(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.claimInfoPerms, this.globalPerm), Formatting.RED)); + l.add(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.claimInfoPerms, this.globalPerm), ChatFormatting.RED)); if (infoType == InfoType.ALL || infoType == InfoType.GROUP) { - l.add(PermHelper.simpleColoredText(ConfigHandler.lang.claimGroupInfoHeader, Formatting.RED)); + l.add(PermHelper.simpleColoredText(ConfigHandler.lang.claimGroupInfoHeader, ChatFormatting.RED)); Map> nameToGroup = new HashMap<>(); for (Map.Entry e : this.playersGroups.entrySet()) { - GameProfile pgroup = player.getServer().getUserCache().getByUuid(e.getKey()); - if (prof != null) { - nameToGroup.merge(e.getValue(), Lists.newArrayList(pgroup.getName()), (old, val) -> { - old.add(pgroup.getName()); - return old; - }); - } + player.getServer().getProfileCache().get(e.getKey()).ifPresent(pgroup -> + + nameToGroup.merge(e.getValue(), Lists.newArrayList(pgroup.getName()), (old, val) -> { + old.add(pgroup.getName()); + return old; + }) + ); } for (Map.Entry> e : this.permissions.entrySet()) { - l.add(PermHelper.simpleColoredText(String.format(" %s:", e.getKey()), Formatting.DARK_RED)); - l.add(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.claimGroupPerms, e.getValue()), Formatting.RED)); - l.add(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.claimGroupPlayers, nameToGroup.getOrDefault(e.getKey(), new ArrayList<>())), Formatting.RED)); + l.add(PermHelper.simpleColoredText(String.format(" %s:", e.getKey()), ChatFormatting.DARK_RED)); + l.add(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.claimGroupPerms, e.getValue()), ChatFormatting.RED)); + l.add(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.claimGroupPlayers, nameToGroup.getOrDefault(e.getKey(), new ArrayList<>())), ChatFormatting.RED)); } } } - l.add(PermHelper.simpleColoredText("=============================================", Formatting.GREEN)); + l.add(PermHelper.simpleColoredText("=============================================", ChatFormatting.GREEN)); return l; } diff --git a/common/src/main/java/io/github/flemmli97/flan/claim/ClaimPermissionCheck.java b/common/src/main/java/io/github/flemmli97/flan/claim/ClaimPermissionCheck.java index 48ad36c..0233bd9 100644 --- a/common/src/main/java/io/github/flemmli97/flan/claim/ClaimPermissionCheck.java +++ b/common/src/main/java/io/github/flemmli97/flan/claim/ClaimPermissionCheck.java @@ -1,15 +1,15 @@ package io.github.flemmli97.flan.claim; +import dev.architectury.injectables.annotations.ExpectPlatform; import io.github.flemmli97.flan.api.permission.ClaimPermission; -import me.shedaniel.architectury.annotations.ExpectPlatform; -import net.minecraft.server.network.ServerPlayerEntity; -import net.minecraft.util.ActionResult; -import net.minecraft.util.math.BlockPos; +import net.minecraft.core.BlockPos; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.InteractionResult; public class ClaimPermissionCheck { @ExpectPlatform - public static ActionResult check(ServerPlayerEntity player, ClaimPermission permission, BlockPos pos) { + public static InteractionResult check(ServerPlayer player, ClaimPermission permission, BlockPos pos) { throw new AssertionError(); } } diff --git a/common/src/main/java/io/github/flemmli97/flan/claim/ClaimStorage.java b/common/src/main/java/io/github/flemmli97/flan/claim/ClaimStorage.java index efa54b7..96b6ea9 100644 --- a/common/src/main/java/io/github/flemmli97/flan/claim/ClaimStorage.java +++ b/common/src/main/java/io/github/flemmli97/flan/claim/ClaimStorage.java @@ -22,21 +22,21 @@ import io.github.flemmli97.flan.player.PlayerClaimData; import io.github.flemmli97.flan.player.PlayerDataHandler; import it.unimi.dsi.fastutil.longs.Long2ObjectMap; import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap; +import net.minecraft.ChatFormatting; +import net.minecraft.commands.CommandSourceStack; +import net.minecraft.core.BlockPos; +import net.minecraft.network.chat.ClickEvent; +import net.minecraft.network.chat.HoverEvent; +import net.minecraft.network.chat.MutableComponent; +import net.minecraft.network.chat.TranslatableComponent; +import net.minecraft.resources.ResourceKey; import net.minecraft.server.MinecraftServer; -import net.minecraft.server.command.ServerCommandSource; -import net.minecraft.server.network.ServerPlayerEntity; -import net.minecraft.server.world.ServerWorld; -import net.minecraft.text.ClickEvent; -import net.minecraft.text.HoverEvent; -import net.minecraft.text.MutableText; -import net.minecraft.text.TranslatableText; -import net.minecraft.util.Formatting; -import net.minecraft.util.Pair; -import net.minecraft.util.WorldSavePath; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.ChunkPos; -import net.minecraft.util.registry.RegistryKey; -import net.minecraft.world.World; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.util.Tuple; +import net.minecraft.world.level.ChunkPos; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.storage.LevelResource; import org.yaml.snakeyaml.Yaml; import java.io.File; @@ -64,11 +64,11 @@ public class ClaimStorage implements IPermissionStorage { private final Set dirty = new HashSet<>(); private final GlobalClaim globalClaim; - public static ClaimStorage get(ServerWorld world) { + public static ClaimStorage get(ServerLevel world) { return ((IClaimStorage) world).get(); } - public ClaimStorage(MinecraftServer server, ServerWorld world) { + public ClaimStorage(MinecraftServer server, ServerLevel world) { this.globalClaim = new GlobalClaim(world); this.read(server, world); PlayerDataHandler.deleteUnusedClaims(server, this, world); @@ -81,36 +81,36 @@ public class ClaimStorage implements IPermissionStorage { return uuid; } - public boolean createClaim(BlockPos pos1, BlockPos pos2, ServerPlayerEntity player) { - Claim claim = new Claim(pos1.down(ConfigHandler.config.defaultClaimDepth), pos2.down(ConfigHandler.config.defaultClaimDepth), player); + public boolean createClaim(BlockPos pos1, BlockPos pos2, ServerPlayer player) { + Claim claim = new Claim(pos1.below(ConfigHandler.config.defaultClaimDepth), pos2.below(ConfigHandler.config.defaultClaimDepth), player); Set conflicts = this.conflicts(claim, null); if (conflicts.isEmpty()) { PlayerClaimData data = PlayerClaimData.get(player); if (claim.getPlane() < ConfigHandler.config.minClaimsize) { - player.sendMessage(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.minClaimSize, ConfigHandler.config.minClaimsize), Formatting.RED), false); + player.displayClientMessage(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.minClaimSize, ConfigHandler.config.minClaimsize), ChatFormatting.RED), false); return false; } - if (!data.isAdminIgnoreClaim() && ConfigHandler.config.maxClaims != -1 && !PermissionNodeHandler.permBelowEqVal(player, PermissionNodeHandler.permMaxClaims, this.playerClaimMap.getOrDefault(player.getUuid(), Sets.newHashSet()).size() + 1, ConfigHandler.config.maxClaims)) { - player.sendMessage(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.maxClaims), Formatting.RED), false); + if (!data.isAdminIgnoreClaim() && ConfigHandler.config.maxClaims != -1 && !PermissionNodeHandler.permBelowEqVal(player, PermissionNodeHandler.permMaxClaims, this.playerClaimMap.getOrDefault(player.getUUID(), Sets.newHashSet()).size() + 1, ConfigHandler.config.maxClaims)) { + player.displayClientMessage(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.maxClaims), ChatFormatting.RED), false); return false; } if (!data.isAdminIgnoreClaim() && !data.canUseClaimBlocks(claim.getPlane())) { - player.sendMessage(PermHelper.simpleColoredText(ConfigHandler.lang.notEnoughBlocks, Formatting.RED), false); + player.displayClientMessage(PermHelper.simpleColoredText(ConfigHandler.lang.notEnoughBlocks, ChatFormatting.RED), false); return false; } claim.setClaimID(this.generateUUID()); Flan.log("Creating new claim {}", claim); this.addClaim(claim); - data.addDisplayClaim(claim, EnumDisplayType.MAIN, player.getBlockPos().getY()); + data.addDisplayClaim(claim, EnumDisplayType.MAIN, player.blockPosition().getY()); data.updateScoreboard(); - player.sendMessage(PermHelper.simpleColoredText(ConfigHandler.lang.claimCreateSuccess, Formatting.GOLD), false); - player.sendMessage(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.claimBlocksFormat, - data.getClaimBlocks(), data.getAdditionalClaims(), data.usedClaimBlocks()), Formatting.GOLD), false); + player.displayClientMessage(PermHelper.simpleColoredText(ConfigHandler.lang.claimCreateSuccess, ChatFormatting.GOLD), false); + player.displayClientMessage(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.claimBlocksFormat, + data.getClaimBlocks(), data.getAdditionalClaims(), data.usedClaimBlocks()), ChatFormatting.GOLD), false); return true; } PlayerClaimData data = PlayerClaimData.get(player); - conflicts.forEach(conf -> data.addDisplayClaim(conf, EnumDisplayType.CONFLICT, player.getBlockPos().getY())); - player.sendMessage(PermHelper.simpleColoredText(ConfigHandler.lang.conflictOther, Formatting.RED), false); + conflicts.forEach(conf -> data.addDisplayClaim(conf, EnumDisplayType.CONFLICT, player.blockPosition().getY())); + player.displayClientMessage(PermHelper.simpleColoredText(ConfigHandler.lang.conflictOther, ChatFormatting.RED), false); return false; } @@ -119,7 +119,7 @@ public class ClaimStorage implements IPermissionStorage { int[] chunks = getChunkPos(claim); for (int x = chunks[0]; x <= chunks[1]; x++) for (int z = chunks[2]; z <= chunks[3]; z++) { - List claims = this.claims.get(ChunkPos.toLong(x, z)); + List claims = this.claims.get(ChunkPos.asLong(x, z)); if (claims != null) for (Claim other : claims) { if (claim.intersects(other) && !other.equals(except)) { @@ -130,7 +130,7 @@ public class ClaimStorage implements IPermissionStorage { return conflicted; } - public boolean deleteClaim(Claim claim, boolean updateClaim, EnumEditMode mode, ServerWorld world) { + public boolean deleteClaim(Claim claim, boolean updateClaim, EnumEditMode mode, ServerLevel world) { if (mode == EnumEditMode.SUBCLAIM) { if (claim.parentClaim() != null) return claim.parentClaim().deleteSubClaim(claim); @@ -140,7 +140,7 @@ public class ClaimStorage implements IPermissionStorage { int[] pos = getChunkPos(claim); for (int x = pos[0]; x <= pos[1]; x++) for (int z = pos[2]; z <= pos[3]; z++) { - this.claims.compute(ChunkPos.toLong(x, z), (key, val) -> { + this.claims.compute(ChunkPos.asLong(x, z), (key, val) -> { if (val == null) return null; val.remove(claim); @@ -156,9 +156,9 @@ public class ClaimStorage implements IPermissionStorage { return this.claimUUIDMap.remove(claim.getClaimID()) != null; } - public void toggleAdminClaim(ServerPlayerEntity player, Claim claim, boolean toggle) { + public void toggleAdminClaim(ServerPlayer player, Claim claim, boolean toggle) { Flan.log("Set claim {} to an admin claim", claim); - this.deleteClaim(claim, false, EnumEditMode.DEFAULT, player.getServerWorld()); + this.deleteClaim(claim, false, EnumEditMode.DEFAULT, player.getLevel()); if (toggle) claim.getOwnerPlayer().ifPresent(o -> PlayerClaimData.get(o).updateScoreboard()); claim.toggleAdminClaim(player, toggle); @@ -167,18 +167,18 @@ public class ClaimStorage implements IPermissionStorage { this.addClaim(claim); } - public boolean resizeClaim(Claim claim, BlockPos from, BlockPos to, ServerPlayerEntity player) { + public boolean resizeClaim(Claim claim, BlockPos from, BlockPos to, ServerPlayer player) { int[] dims = claim.getDimensions(); BlockPos opposite = new BlockPos(dims[0] == from.getX() ? dims[1] : dims[0], dims[4], dims[2] == from.getZ() ? dims[3] : dims[2]); - Claim newClaim = new Claim(opposite, to, player.getUuid(), player.getServerWorld()); + Claim newClaim = new Claim(opposite, to, player.getUUID(), player.getLevel()); if (newClaim.getPlane() < ConfigHandler.config.minClaimsize) { - player.sendMessage(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.minClaimSize, ConfigHandler.config.minClaimsize), Formatting.RED), false); + player.displayClientMessage(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.minClaimSize, ConfigHandler.config.minClaimsize), ChatFormatting.RED), false); return false; } Set conflicts = this.conflicts(newClaim, claim); if (!conflicts.isEmpty()) { - conflicts.forEach(conf -> PlayerClaimData.get(player).addDisplayClaim(conf, EnumDisplayType.CONFLICT, player.getBlockPos().getY())); - player.sendMessage(PermHelper.simpleColoredText(ConfigHandler.lang.conflictOther, Formatting.RED), false); + conflicts.forEach(conf -> PlayerClaimData.get(player).addDisplayClaim(conf, EnumDisplayType.CONFLICT, player.blockPosition().getY())); + player.displayClientMessage(PermHelper.simpleColoredText(ConfigHandler.lang.conflictOther, ChatFormatting.RED), false); return false; } int diff = newClaim.getPlane() - claim.getPlane(); @@ -191,23 +191,23 @@ public class ClaimStorage implements IPermissionStorage { boolean enoughBlocks = claim.isAdminClaim() || data.isAdminIgnoreClaim() || newData.canUseClaimBlocks(diff); if (enoughBlocks) { Flan.log("Resizing claim {}", claim); - this.deleteClaim(claim, false, EnumEditMode.DEFAULT, player.getServerWorld()); + this.deleteClaim(claim, false, EnumEditMode.DEFAULT, player.getLevel()); claim.copySizes(newClaim); this.addClaim(claim); - data.addDisplayClaim(claim, EnumDisplayType.MAIN, player.getBlockPos().getY()); + data.addDisplayClaim(claim, EnumDisplayType.MAIN, player.blockPosition().getY()); if (newData instanceof PlayerClaimData) ((PlayerClaimData) newData).updateScoreboard(); - player.sendMessage(PermHelper.simpleColoredText(ConfigHandler.lang.resizeSuccess, Formatting.GOLD), false); - player.sendMessage(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.claimBlocksFormat, - newData.getClaimBlocks(), newData.getAdditionalClaims(), newData.usedClaimBlocks()), Formatting.GOLD), false); + player.displayClientMessage(PermHelper.simpleColoredText(ConfigHandler.lang.resizeSuccess, ChatFormatting.GOLD), false); + player.displayClientMessage(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.claimBlocksFormat, + newData.getClaimBlocks(), newData.getAdditionalClaims(), newData.usedClaimBlocks()), ChatFormatting.GOLD), false); return true; } - player.sendMessage(PermHelper.simpleColoredText(ConfigHandler.lang.notEnoughBlocks, Formatting.RED), false); + player.displayClientMessage(PermHelper.simpleColoredText(ConfigHandler.lang.notEnoughBlocks, ChatFormatting.RED), false); return false; } public Claim getClaimAt(BlockPos pos) { - long chunk = ChunkPos.toLong(pos.getX() >> 4, pos.getZ() >> 4); + long chunk = ChunkPos.asLong(pos.getX() >> 4, pos.getZ() >> 4); List list = this.claims.get(chunk); if (list != null) for (Claim claim : list) { @@ -233,7 +233,7 @@ public class ClaimStorage implements IPermissionStorage { int[] pos = getChunkPos(claim); for (int x = pos[0]; x <= pos[1]; x++) for (int z = pos[2]; z <= pos[3]; z++) { - this.claims.merge(ChunkPos.toLong(x, z), Lists.newArrayList(claim), (old, val) -> { + this.claims.merge(ChunkPos.asLong(x, z), Lists.newArrayList(claim), (old, val) -> { old.add(claim); return old; }); @@ -245,8 +245,8 @@ public class ClaimStorage implements IPermissionStorage { }); } - public boolean transferOwner(Claim claim, ServerPlayerEntity player, UUID newOwner) { - if (!player.getUuid().equals(claim.getOwner())) + public boolean transferOwner(Claim claim, ServerPlayer player, UUID newOwner) { + if (!player.getUUID().equals(claim.getOwner())) return false; this.playerClaimMap.merge(claim.getOwner(), new HashSet<>(), (old, val) -> { old.remove(claim); @@ -281,9 +281,9 @@ public class ClaimStorage implements IPermissionStorage { return pos; } - public void read(MinecraftServer server, ServerWorld world) { - Flan.log("Loading claim data for world {}", world.getRegistryKey()); - Path dir = ConfigHandler.getClaimSavePath(server, world.getRegistryKey()); + public void read(MinecraftServer server, ServerLevel world) { + Flan.log("Loading claim data for world {}", world.dimension()); + Path dir = ConfigHandler.getClaimSavePath(server, world.dimension()); if (Files.exists(dir)) { try { for (Path file : Files.walk(dir).filter(Files::isRegularFile).collect(Collectors.toSet())) { @@ -310,7 +310,7 @@ public class ClaimStorage implements IPermissionStorage { } } - public void save(MinecraftServer server, RegistryKey reg) { + public void save(MinecraftServer server, ResourceKey reg) { Flan.log("Saving claims for world {}", reg); Path dir = ConfigHandler.getClaimSavePath(server, reg); try { @@ -354,11 +354,11 @@ public class ClaimStorage implements IPermissionStorage { } } - public static boolean readGriefPreventionData(MinecraftServer server, ServerCommandSource src) { + public static boolean readGriefPreventionData(MinecraftServer server, CommandSourceStack src) { Yaml yml = new Yaml(); - File griefPrevention = server.getSavePath(WorldSavePath.ROOT).resolve("plugins/GriefPreventionData/ClaimData").toFile(); + File griefPrevention = server.getWorldPath(LevelResource.ROOT).resolve("plugins/GriefPreventionData/ClaimData").toFile(); if (!griefPrevention.exists()) { - src.sendFeedback(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.cantFindData, griefPrevention.getAbsolutePath()), Formatting.DARK_RED), false); + src.sendSuccess(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.cantFindData, griefPrevention.getAbsolutePath()), ChatFormatting.DARK_RED), false); return false; } Map> subClaimMap = new HashMap<>(); @@ -392,7 +392,7 @@ public class ClaimStorage implements IPermissionStorage { try { intFileMap.put(Integer.valueOf(f.getName().replace(".yml", "")), f); } catch (NumberFormatException e) { - src.sendFeedback(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.errorFile, f.getName(), Formatting.RED)), false); + src.sendSuccess(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.errorFile, f.getName(), ChatFormatting.RED)), false); } } } @@ -413,28 +413,28 @@ public class ClaimStorage implements IPermissionStorage { } for (File parent : intFileMap.values()) { try { - Pair parentClaim = parseFromYaml(parent, yml, server, perms); + Tuple parentClaim = parseFromYaml(parent, yml, server, perms); List childs = subClaimMap.get(parent); if (childs != null && !childs.isEmpty()) { for (File childF : childs) - parentClaim.getRight().addSubClaimGriefprevention(parseFromYaml(childF, yml, server, perms).getRight()); + parentClaim.getB().addSubClaimGriefprevention(parseFromYaml(childF, yml, server, perms).getB()); } - ClaimStorage storage = ClaimStorage.get(parentClaim.getLeft()); - Set conflicts = storage.conflicts(parentClaim.getRight(), null); + ClaimStorage storage = ClaimStorage.get(parentClaim.getA()); + Set conflicts = storage.conflicts(parentClaim.getB(), null); if (conflicts.isEmpty()) { - parentClaim.getRight().setClaimID(storage.generateUUID()); - storage.addClaim(parentClaim.getRight()); + parentClaim.getB().setClaimID(storage.generateUUID()); + storage.addClaim(parentClaim.getB()); } else { - src.sendFeedback(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.readConflict, parent.getName(), conflicts), Formatting.DARK_RED), false); + src.sendSuccess(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.readConflict, parent.getName(), conflicts), ChatFormatting.DARK_RED), false); for (Claim claim : conflicts) { int[] dim = claim.getDimensions(); - MutableText text = PermHelper.simpleColoredText(String.format("@[x=%d;z=%d]", dim[0], dim[2]), Formatting.RED); - text.setStyle(text.getStyle().withClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/tp @s " + dim[0] + " ~ " + dim[2])).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TranslatableText("chat.coordinates.tooltip")))); - src.sendFeedback(text, false); + MutableComponent text = PermHelper.simpleColoredText(String.format("@[x=%d;z=%d]", dim[0], dim[2]), ChatFormatting.RED); + text.setStyle(text.getStyle().withClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/tp @s " + dim[0] + " ~ " + dim[2])).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TranslatableComponent("chat.coordinates.tooltip")))); + src.sendSuccess(text, false); } } } catch (Exception e) { - src.sendFeedback(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.errorFile, parent.getName(), Formatting.RED)), false); + src.sendSuccess(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.errorFile, parent.getName(), ChatFormatting.RED)), false); e.printStackTrace(); } } @@ -451,8 +451,8 @@ public class ClaimStorage implements IPermissionStorage { return set; } - private static Pair parseFromYaml(File file, Yaml yml, MinecraftServer server, - Map> perms) throws IOException { + private static Tuple parseFromYaml(File file, Yaml yml, MinecraftServer server, + Map> perms) throws IOException { FileReader reader = new FileReader(file); Map values = yml.load(reader); reader.close(); @@ -465,7 +465,7 @@ public class ClaimStorage implements IPermissionStorage { List accessors = readList(values, "Accessors"); String[] lesserCorner = values.get("Lesser Boundary Corner").toString().split(";"); String[] greaterCorner = values.get("Greater Boundary Corner").toString().split(";"); - ServerWorld world = server.getWorld(worldRegFromString(lesserCorner[0])); + ServerLevel world = server.getLevel(worldRegFromString(lesserCorner[0])); Claim claim = new Claim(Integer.parseInt(lesserCorner[1]), Integer.parseInt(greaterCorner[1]), Integer.parseInt(lesserCorner[3]), Integer.parseInt(greaterCorner[3]), ConfigHandler.config.defaultClaimDepth == 255 ? 0 : Integer.parseInt(lesserCorner[2]), owner, world); @@ -513,7 +513,7 @@ public class ClaimStorage implements IPermissionStorage { accessors.forEach(s -> claim.setPlayerGroup(UUID.fromString(s), "Accessors", true)); } } - return new Pair<>(world, claim); + return new Tuple<>(world, claim); } @SuppressWarnings("unchecked") @@ -524,11 +524,11 @@ public class ClaimStorage implements IPermissionStorage { return new ArrayList<>(); } - public static RegistryKey worldRegFromString(String spigot) { + public static ResourceKey worldRegFromString(String spigot) { if (spigot.equals("world_the_end")) - return World.END; + return Level.END; if (spigot.equals("world_nether")) - return World.NETHER; - return World.OVERWORLD; + return Level.NETHER; + return Level.OVERWORLD; } } diff --git a/common/src/main/java/io/github/flemmli97/flan/claim/GlobalClaim.java b/common/src/main/java/io/github/flemmli97/flan/claim/GlobalClaim.java index 527f091..8108db1 100644 --- a/common/src/main/java/io/github/flemmli97/flan/claim/GlobalClaim.java +++ b/common/src/main/java/io/github/flemmli97/flan/claim/GlobalClaim.java @@ -6,27 +6,27 @@ import io.github.flemmli97.flan.api.permission.PermissionRegistry; import io.github.flemmli97.flan.config.Config; import io.github.flemmli97.flan.config.ConfigHandler; import io.github.flemmli97.flan.player.PlayerClaimData; -import net.minecraft.server.network.ServerPlayerEntity; -import net.minecraft.server.world.ServerWorld; -import net.minecraft.util.Formatting; -import net.minecraft.util.math.BlockPos; +import net.minecraft.ChatFormatting; +import net.minecraft.core.BlockPos; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.server.level.ServerPlayer; public class GlobalClaim implements IPermissionContainer { - private final ServerWorld world; + private final ServerLevel world; - public GlobalClaim(ServerWorld world) { + public GlobalClaim(ServerLevel world) { this.world = world; } @Override - public boolean canInteract(ServerPlayerEntity player, ClaimPermission perm, BlockPos pos, boolean message) { + public boolean canInteract(ServerPlayer player, ClaimPermission perm, BlockPos pos, boolean message) { Config.GlobalType global = ConfigHandler.config.getGlobal(this.world, perm); if (global != Config.GlobalType.NONE && (player == null || !PlayerClaimData.get(player).isAdminIgnoreClaim())) { if (global.getValue()) return true; if (message) - player.sendMessage(PermHelper.simpleColoredText(ConfigHandler.lang.noPermissionSimple, Formatting.DARK_RED), true); + player.displayClientMessage(PermHelper.simpleColoredText(ConfigHandler.lang.noPermissionSimple, ChatFormatting.DARK_RED), true); return false; } return perm != PermissionRegistry.MOBSPAWN && perm != PermissionRegistry.ANIMALSPAWN; diff --git a/common/src/main/java/io/github/flemmli97/flan/claim/ParticleIndicators.java b/common/src/main/java/io/github/flemmli97/flan/claim/ParticleIndicators.java index a3e0aab..ef1f3f2 100644 --- a/common/src/main/java/io/github/flemmli97/flan/claim/ParticleIndicators.java +++ b/common/src/main/java/io/github/flemmli97/flan/claim/ParticleIndicators.java @@ -1,19 +1,20 @@ package io.github.flemmli97.flan.claim; -import net.minecraft.particle.DustParticleEffect; +import com.mojang.math.Vector3f; +import net.minecraft.core.particles.DustParticleOptions; public class ParticleIndicators { - public static final DustParticleEffect CLAIMCORNER = new DustParticleEffect(194 / 255f, 130 / 255f, 4 / 255f, 3); - public static final DustParticleEffect CLAIMMIDDLE = new DustParticleEffect(237 / 255f, 187 / 255f, 38 / 255f, 3); + public static final DustParticleOptions CLAIMCORNER = new DustParticleOptions(new Vector3f(194 / 255f, 130 / 255f, 4 / 255f), 3); + public static final DustParticleOptions CLAIMMIDDLE = new DustParticleOptions(new Vector3f(237 / 255f, 187 / 255f, 38 / 255f), 3); - public static final DustParticleEffect SUBCLAIMCORNER = new DustParticleEffect(125 / 255f, 125 / 255f, 125 / 255f, 3); - public static final DustParticleEffect SUBCLAIMMIDDLE = new DustParticleEffect(194 / 255f, 194 / 255f, 194 / 255f, 3); + public static final DustParticleOptions SUBCLAIMCORNER = new DustParticleOptions(new Vector3f(125 / 255f, 125 / 255f, 125 / 255f), 3); + public static final DustParticleOptions SUBCLAIMMIDDLE = new DustParticleOptions(new Vector3f(194 / 255f, 194 / 255f, 194 / 255f), 3); - public static final DustParticleEffect EDITCLAIMCORNER = new DustParticleEffect(12 / 255f, 110 / 255f, 103 / 255f, 3); - public static final DustParticleEffect EDITCLAIMMIDDLE = new DustParticleEffect(20 / 255f, 186 / 255f, 175 / 255f, 3); + public static final DustParticleOptions EDITCLAIMCORNER = new DustParticleOptions(new Vector3f(12 / 255f, 110 / 255f, 103 / 255f), 3); + public static final DustParticleOptions EDITCLAIMMIDDLE = new DustParticleOptions(new Vector3f(20 / 255f, 186 / 255f, 175 / 255f), 3); - public static final DustParticleEffect SETCORNER = new DustParticleEffect(18 / 255f, 38 / 255f, 150 / 255f, 3); + public static final DustParticleOptions SETCORNER = new DustParticleOptions(new Vector3f(18 / 255f, 38 / 255f, 150 / 255f), 3); - public static final DustParticleEffect OVERLAPCLAIM = new DustParticleEffect(255 / 255f, 0 / 255f, 0 / 255f, 3); + public static final DustParticleOptions OVERLAPCLAIM = new DustParticleOptions(new Vector3f(255 / 255f, 0 / 255f, 0 / 255f), 3); } diff --git a/common/src/main/java/io/github/flemmli97/flan/claim/PermHelper.java b/common/src/main/java/io/github/flemmli97/flan/claim/PermHelper.java index 89ae7d6..13abf9b 100644 --- a/common/src/main/java/io/github/flemmli97/flan/claim/PermHelper.java +++ b/common/src/main/java/io/github/flemmli97/flan/claim/PermHelper.java @@ -2,19 +2,19 @@ package io.github.flemmli97.flan.claim; import io.github.flemmli97.flan.api.permission.ClaimPermission; import io.github.flemmli97.flan.config.ConfigHandler; -import net.minecraft.server.network.ServerPlayerEntity; -import net.minecraft.text.LiteralText; -import net.minecraft.text.MutableText; -import net.minecraft.text.Style; -import net.minecraft.util.Formatting; -import net.minecraft.util.math.BlockPos; +import net.minecraft.ChatFormatting; +import net.minecraft.core.BlockPos; +import net.minecraft.network.chat.MutableComponent; +import net.minecraft.network.chat.Style; +import net.minecraft.network.chat.TextComponent; +import net.minecraft.server.level.ServerPlayer; import java.util.Optional; import java.util.function.Consumer; public class PermHelper { - public static boolean check(ServerPlayerEntity player, BlockPos pos, Claim claim, ClaimPermission perm, Consumer> cons) { + public static boolean check(ServerPlayer player, BlockPos pos, Claim claim, ClaimPermission perm, Consumer> cons) { if (claim == null) { cons.accept(Optional.empty()); return false; @@ -24,26 +24,26 @@ public class PermHelper { return hasPerm; } - public static Claim checkReturn(ServerPlayerEntity player, ClaimPermission perm, Consumer> cons) { - BlockPos pos = player.getBlockPos(); - Claim claim = ClaimStorage.get(player.getServerWorld()).getClaimAt(pos); + public static Claim checkReturn(ServerPlayer player, ClaimPermission perm, Consumer> cons) { + BlockPos pos = player.blockPosition(); + Claim claim = ClaimStorage.get(player.getLevel()).getClaimAt(pos); return check(player, pos, claim, perm, cons) ? claim : null; } - public static void noClaimMessage(ServerPlayerEntity player) { - player.sendMessage(new LiteralText(ConfigHandler.lang.noClaim).setStyle(Style.EMPTY.withFormatting(Formatting.DARK_RED)), false); + public static void noClaimMessage(ServerPlayer player) { + player.displayClientMessage(new TextComponent(ConfigHandler.lang.noClaim).setStyle(Style.EMPTY.applyFormat(ChatFormatting.DARK_RED)), false); } - public static Consumer> genericNoPermMessage(ServerPlayerEntity player) { + public static Consumer> genericNoPermMessage(ServerPlayer player) { return (b -> { if (!b.isPresent()) PermHelper.noClaimMessage(player); else if (!b.get()) - player.sendMessage(simpleColoredText(ConfigHandler.lang.noPermission, Formatting.DARK_RED), false); + player.displayClientMessage(simpleColoredText(ConfigHandler.lang.noPermission, ChatFormatting.DARK_RED), false); }); } - public static MutableText simpleColoredText(String text, Formatting... formatting) { - return new LiteralText(text).setStyle(formatting != null ? Style.EMPTY.withFormatting(formatting) : Style.EMPTY); + public static MutableComponent simpleColoredText(String text, ChatFormatting... formatting) { + return new TextComponent(text).setStyle(formatting != null ? Style.EMPTY.applyFormats(formatting) : Style.EMPTY); } } diff --git a/common/src/main/java/io/github/flemmli97/flan/commands/CommandClaim.java b/common/src/main/java/io/github/flemmli97/flan/commands/CommandClaim.java index e3a1ce6..1dcf7c1 100644 --- a/common/src/main/java/io/github/flemmli97/flan/commands/CommandClaim.java +++ b/common/src/main/java/io/github/flemmli97/flan/commands/CommandClaim.java @@ -24,22 +24,22 @@ import io.github.flemmli97.flan.player.EnumDisplayType; import io.github.flemmli97.flan.player.EnumEditMode; import io.github.flemmli97.flan.player.OfflinePlayerData; import io.github.flemmli97.flan.player.PlayerClaimData; -import net.minecraft.command.CommandSource; -import net.minecraft.command.argument.BlockPosArgumentType; -import net.minecraft.command.argument.GameProfileArgumentType; -import net.minecraft.command.argument.TextArgumentType; +import net.minecraft.ChatFormatting; +import net.minecraft.commands.CommandSourceStack; +import net.minecraft.commands.Commands; +import net.minecraft.commands.SharedSuggestionProvider; +import net.minecraft.commands.arguments.ComponentArgument; +import net.minecraft.commands.arguments.GameProfileArgument; +import net.minecraft.commands.arguments.coordinates.BlockPosArgument; +import net.minecraft.core.BlockPos; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.MutableComponent; +import net.minecraft.network.chat.Style; +import net.minecraft.network.chat.TextComponent; import net.minecraft.server.MinecraftServer; -import net.minecraft.server.command.CommandManager; -import net.minecraft.server.command.ServerCommandSource; -import net.minecraft.server.network.ServerPlayerEntity; -import net.minecraft.server.world.ServerWorld; -import net.minecraft.text.LiteralText; -import net.minecraft.text.MutableText; -import net.minecraft.text.Style; -import net.minecraft.text.Text; -import net.minecraft.util.Formatting; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.level.Level; import java.util.ArrayList; import java.util.Collection; @@ -50,175 +50,175 @@ import java.util.UUID; public class CommandClaim { - public static void register(CommandDispatcher dispatcher, boolean dedicated) { - LiteralArgumentBuilder builder = CommandManager.literal("flan") - .then(CommandManager.literal("reload").requires(src -> PermissionNodeHandler.perm(src, PermissionNodeHandler.cmdReload, true)).executes(CommandClaim::reloadConfig)) - .then(CommandManager.literal("addClaim").requires(src -> PermissionNodeHandler.perm(src, PermissionNodeHandler.claimCreate)) - .then(CommandManager.argument("from", BlockPosArgumentType.blockPos()).then(CommandManager.argument("to", BlockPosArgumentType.blockPos()).executes(CommandClaim::addClaim))) - .then(CommandManager.literal("all").executes(CommandClaim::addClaimAll)) - .then(CommandManager.literal("rect").then(CommandManager.argument("x", IntegerArgumentType.integer()).then(CommandManager.argument("z", IntegerArgumentType.integer()).executes(ctx -> CommandClaim.addClaimRect(ctx, IntegerArgumentType.getInteger(ctx, "x"), IntegerArgumentType.getInteger(ctx, "z"))))))) - .then(CommandManager.literal("menu").requires(src -> PermissionNodeHandler.perm(src, PermissionNodeHandler.cmdMenu)).executes(CommandClaim::openMenu)) - .then(CommandManager.literal("setHome").requires(src -> PermissionNodeHandler.perm(src, PermissionNodeHandler.cmdHome)).executes(CommandClaim::setClaimHome)) - .then(CommandManager.literal("trapped").requires(src -> PermissionNodeHandler.perm(src, PermissionNodeHandler.cmdTrapped)).executes(CommandClaim::trapped)) - .then(CommandManager.literal("name").requires(src -> PermissionNodeHandler.perm(src, PermissionNodeHandler.cmdName)).then(CommandManager.argument("name", StringArgumentType.string()).executes(CommandClaim::nameClaim))) - .then(CommandManager.literal("unlockDrops").executes(CommandClaim::unlockDrops) - .then(CommandManager.argument("players", GameProfileArgumentType.gameProfile()).requires(src -> PermissionNodeHandler.perm(src, PermissionNodeHandler.cmdUnlockAll, true)).executes(CommandClaim::unlockDropsPlayers))) - .then(CommandManager.literal("personalGroups").requires(src -> PermissionNodeHandler.perm(src, PermissionNodeHandler.cmdPGroup)).executes(CommandClaim::openPersonalGroups)) - .then(CommandManager.literal("claimInfo").requires(src -> PermissionNodeHandler.perm(src, PermissionNodeHandler.cmdInfo)).executes(ctx -> CommandClaim.claimInfo(ctx, Claim.InfoType.ALL)) - .then(CommandManager.argument("type", StringArgumentType.word()).suggests((src, b) -> CommandHelpers.enumSuggestion(Claim.InfoType.class, b)).executes(CommandClaim::claimInfo))) - .then(CommandManager.literal("transferClaim").requires(src -> PermissionNodeHandler.perm(src, PermissionNodeHandler.cmdTransfer)).then(CommandManager.argument("player", GameProfileArgumentType.gameProfile()).executes(CommandClaim::transferClaim))) - .then(CommandManager.literal("delete").requires(src -> PermissionNodeHandler.perm(src, PermissionNodeHandler.cmdTransfer)).executes(CommandClaim::deleteClaim)) - .then(CommandManager.literal("deleteAll").requires(src -> PermissionNodeHandler.perm(src, PermissionNodeHandler.cmdTransfer)).executes(CommandClaim::deleteAllClaim)) - .then(CommandManager.literal("deleteSubClaim").requires(src -> PermissionNodeHandler.perm(src, PermissionNodeHandler.cmdTransfer)).executes(CommandClaim::deleteSubClaim)) - .then(CommandManager.literal("deleteAllSubClaims").requires(src -> PermissionNodeHandler.perm(src, PermissionNodeHandler.cmdTransfer)).executes(CommandClaim::deleteAllSubClaim)) - .then(CommandManager.literal("list").requires(src -> PermissionNodeHandler.perm(src, PermissionNodeHandler.cmdList)).executes(CommandClaim::listClaims).then(CommandManager.argument("player", GameProfileArgumentType.gameProfile()).requires(src -> PermissionNodeHandler.perm(src, PermissionNodeHandler.cmdListAll, true)) - .executes(cmd -> listClaims(cmd, GameProfileArgumentType.getProfileArgument(cmd, "player"))))) - .then(CommandManager.literal("switchMode").requires(src -> PermissionNodeHandler.perm(src, PermissionNodeHandler.cmdClaimMode)).executes(CommandClaim::switchClaimMode)) - .then(CommandManager.literal("adminMode").requires(src -> PermissionNodeHandler.perm(src, PermissionNodeHandler.cmdAdminMode, true)).executes(CommandClaim::switchAdminMode)) - .then(CommandManager.literal("readGriefPrevention").requires(src -> PermissionNodeHandler.perm(src, PermissionNodeHandler.cmdGriefPrevention, true)).executes(CommandClaim::readGriefPreventionData)) - .then(CommandManager.literal("setAdminClaim").requires(src -> PermissionNodeHandler.perm(src, PermissionNodeHandler.cmdAdminSet, true)).then(CommandManager.argument("toggle", BoolArgumentType.bool()).executes(CommandClaim::toggleAdminClaim))) - .then(CommandManager.literal("listAdminClaims").requires(src -> PermissionNodeHandler.perm(src, PermissionNodeHandler.cmdAdminList, true)).executes(CommandClaim::listAdminClaims)) - .then(CommandManager.literal("adminDelete").requires(src -> PermissionNodeHandler.perm(src, PermissionNodeHandler.cmdAdminDelete, true)).executes(CommandClaim::adminDelete) - .then(CommandManager.literal("all").then(CommandManager.argument("players", GameProfileArgumentType.gameProfile()) + public static void register(CommandDispatcher dispatcher, boolean dedicated) { + LiteralArgumentBuilder builder = Commands.literal("flan") + .then(Commands.literal("reload").requires(src -> PermissionNodeHandler.perm(src, PermissionNodeHandler.cmdReload, true)).executes(CommandClaim::reloadConfig)) + .then(Commands.literal("addClaim").requires(src -> PermissionNodeHandler.perm(src, PermissionNodeHandler.claimCreate)) + .then(Commands.argument("from", BlockPosArgument.blockPos()).then(Commands.argument("to", BlockPosArgument.blockPos()).executes(CommandClaim::addClaim))) + .then(Commands.literal("all").executes(CommandClaim::addClaimAll)) + .then(Commands.literal("rect").then(Commands.argument("x", IntegerArgumentType.integer()).then(Commands.argument("z", IntegerArgumentType.integer()).executes(ctx -> CommandClaim.addClaimRect(ctx, IntegerArgumentType.getInteger(ctx, "x"), IntegerArgumentType.getInteger(ctx, "z"))))))) + .then(Commands.literal("menu").requires(src -> PermissionNodeHandler.perm(src, PermissionNodeHandler.cmdMenu)).executes(CommandClaim::openMenu)) + .then(Commands.literal("setHome").requires(src -> PermissionNodeHandler.perm(src, PermissionNodeHandler.cmdHome)).executes(CommandClaim::setClaimHome)) + .then(Commands.literal("trapped").requires(src -> PermissionNodeHandler.perm(src, PermissionNodeHandler.cmdTrapped)).executes(CommandClaim::trapped)) + .then(Commands.literal("name").requires(src -> PermissionNodeHandler.perm(src, PermissionNodeHandler.cmdName)).then(Commands.argument("name", StringArgumentType.string()).executes(CommandClaim::nameClaim))) + .then(Commands.literal("unlockDrops").executes(CommandClaim::unlockDrops) + .then(Commands.argument("players", GameProfileArgument.gameProfile()).requires(src -> PermissionNodeHandler.perm(src, PermissionNodeHandler.cmdUnlockAll, true)).executes(CommandClaim::unlockDropsPlayers))) + .then(Commands.literal("personalGroups").requires(src -> PermissionNodeHandler.perm(src, PermissionNodeHandler.cmdPGroup)).executes(CommandClaim::openPersonalGroups)) + .then(Commands.literal("claimInfo").requires(src -> PermissionNodeHandler.perm(src, PermissionNodeHandler.cmdInfo)).executes(ctx -> CommandClaim.claimInfo(ctx, Claim.InfoType.ALL)) + .then(Commands.argument("type", StringArgumentType.word()).suggests((src, b) -> CommandHelpers.enumSuggestion(Claim.InfoType.class, b)).executes(CommandClaim::claimInfo))) + .then(Commands.literal("transferClaim").requires(src -> PermissionNodeHandler.perm(src, PermissionNodeHandler.cmdTransfer)).then(Commands.argument("player", GameProfileArgument.gameProfile()).executes(CommandClaim::transferClaim))) + .then(Commands.literal("delete").requires(src -> PermissionNodeHandler.perm(src, PermissionNodeHandler.cmdTransfer)).executes(CommandClaim::deleteClaim)) + .then(Commands.literal("deleteAll").requires(src -> PermissionNodeHandler.perm(src, PermissionNodeHandler.cmdTransfer)).executes(CommandClaim::deleteAllClaim)) + .then(Commands.literal("deleteSubClaim").requires(src -> PermissionNodeHandler.perm(src, PermissionNodeHandler.cmdTransfer)).executes(CommandClaim::deleteSubClaim)) + .then(Commands.literal("deleteAllSubClaims").requires(src -> PermissionNodeHandler.perm(src, PermissionNodeHandler.cmdTransfer)).executes(CommandClaim::deleteAllSubClaim)) + .then(Commands.literal("list").requires(src -> PermissionNodeHandler.perm(src, PermissionNodeHandler.cmdList)).executes(CommandClaim::listClaims).then(Commands.argument("player", GameProfileArgument.gameProfile()).requires(src -> PermissionNodeHandler.perm(src, PermissionNodeHandler.cmdListAll, true)) + .executes(cmd -> listClaims(cmd, GameProfileArgument.getGameProfiles(cmd, "player"))))) + .then(Commands.literal("switchMode").requires(src -> PermissionNodeHandler.perm(src, PermissionNodeHandler.cmdClaimMode)).executes(CommandClaim::switchClaimMode)) + .then(Commands.literal("adminMode").requires(src -> PermissionNodeHandler.perm(src, PermissionNodeHandler.cmdAdminMode, true)).executes(CommandClaim::switchAdminMode)) + .then(Commands.literal("readGriefPrevention").requires(src -> PermissionNodeHandler.perm(src, PermissionNodeHandler.cmdGriefPrevention, true)).executes(CommandClaim::readGriefPreventionData)) + .then(Commands.literal("setAdminClaim").requires(src -> PermissionNodeHandler.perm(src, PermissionNodeHandler.cmdAdminSet, true)).then(Commands.argument("toggle", BoolArgumentType.bool()).executes(CommandClaim::toggleAdminClaim))) + .then(Commands.literal("listAdminClaims").requires(src -> PermissionNodeHandler.perm(src, PermissionNodeHandler.cmdAdminList, true)).executes(CommandClaim::listAdminClaims)) + .then(Commands.literal("adminDelete").requires(src -> PermissionNodeHandler.perm(src, PermissionNodeHandler.cmdAdminDelete, true)).executes(CommandClaim::adminDelete) + .then(Commands.literal("all").then(Commands.argument("players", GameProfileArgument.gameProfile()) .executes(CommandClaim::adminDeleteAll)))) - .then(CommandManager.literal("giveClaimBlocks").requires(src -> PermissionNodeHandler.perm(src, PermissionNodeHandler.cmdAdminGive, true)).then(CommandManager.argument("players", GameProfileArgumentType.gameProfile()) - .then(CommandManager.argument("amount", IntegerArgumentType.integer()).executes(CommandClaim::giveClaimBlocks)))) - .then(CommandManager.literal("buyBlocks").requires(src -> PermissionNodeHandler.perm(src, PermissionNodeHandler.cmdBuy, false)) - .then(CommandManager.argument("amount", IntegerArgumentType.integer()).executes(CommandCurrency::buyClaimBlocks))) - .then(CommandManager.literal("sellBlocks").requires(src -> PermissionNodeHandler.perm(src, PermissionNodeHandler.cmdSell, false)) - .then(CommandManager.argument("amount", IntegerArgumentType.integer()).executes(CommandCurrency::sellClaimBlocks))) - .then(CommandManager.literal("claimMessage").then(CommandManager.argument("type", StringArgumentType.word()).suggests((ctx, b) -> CommandSource.suggestMatching(new String[]{"enter", "leave"}, b)) - .then(CommandManager.argument("title", StringArgumentType.word()).suggests((ctx, b) -> CommandSource.suggestMatching(new String[]{"title", "subtitle"}, b)) - .then(CommandManager.literal("text").then(CommandManager.argument("component", TextArgumentType.text()).executes(ctx -> CommandClaim.editClaimMessages(ctx, TextArgumentType.getTextArgument(ctx, "component"))))) - .then(CommandManager.literal("string").then(CommandManager.argument("message", StringArgumentType.string()).executes(CommandClaim::editClaimMessages)))))) - .then(CommandManager.literal("group").requires(src -> PermissionNodeHandler.perm(src, PermissionNodeHandler.cmdGroup)) - .then(CommandManager.literal("add").then(CommandManager.argument("group", StringArgumentType.string()).executes(CommandClaim::addGroup))) - .then(CommandManager.literal("remove").then(CommandManager.argument("group", StringArgumentType.string()) + .then(Commands.literal("giveClaimBlocks").requires(src -> PermissionNodeHandler.perm(src, PermissionNodeHandler.cmdAdminGive, true)).then(Commands.argument("players", GameProfileArgument.gameProfile()) + .then(Commands.argument("amount", IntegerArgumentType.integer()).executes(CommandClaim::giveClaimBlocks)))) + .then(Commands.literal("buyBlocks").requires(src -> PermissionNodeHandler.perm(src, PermissionNodeHandler.cmdBuy, false)) + .then(Commands.argument("amount", IntegerArgumentType.integer()).executes(CommandCurrency::buyClaimBlocks))) + .then(Commands.literal("sellBlocks").requires(src -> PermissionNodeHandler.perm(src, PermissionNodeHandler.cmdSell, false)) + .then(Commands.argument("amount", IntegerArgumentType.integer()).executes(CommandCurrency::sellClaimBlocks))) + .then(Commands.literal("claimMessage").then(Commands.argument("type", StringArgumentType.word()).suggests((ctx, b) -> SharedSuggestionProvider.suggest(new String[]{"enter", "leave"}, b)) + .then(Commands.argument("title", StringArgumentType.word()).suggests((ctx, b) -> SharedSuggestionProvider.suggest(new String[]{"title", "subtitle"}, b)) + .then(Commands.literal("text").then(Commands.argument("component", ComponentArgument.textComponent()).executes(ctx -> CommandClaim.editClaimMessages(ctx, ComponentArgument.getComponent(ctx, "component"))))) + .then(Commands.literal("string").then(Commands.argument("message", StringArgumentType.string()).executes(CommandClaim::editClaimMessages)))))) + .then(Commands.literal("group").requires(src -> PermissionNodeHandler.perm(src, PermissionNodeHandler.cmdGroup)) + .then(Commands.literal("add").then(Commands.argument("group", StringArgumentType.string()).executes(CommandClaim::addGroup))) + .then(Commands.literal("remove").then(Commands.argument("group", StringArgumentType.string()) .suggests(CommandHelpers::groupSuggestion).executes(CommandClaim::removeGroup))) - .then(CommandManager.literal("players") - .then(CommandManager.literal("add").then(CommandManager.argument("group", StringArgumentType.word()).suggests(CommandHelpers::groupSuggestion) - .then(CommandManager.argument("players", GameProfileArgumentType.gameProfile()).executes(CommandClaim::addPlayer) - .then(CommandManager.literal("overwrite").executes(CommandClaim::forceAddPlayer))))) - .then(CommandManager.literal("remove").then(CommandManager.argument("group", StringArgumentType.word()).suggests(CommandHelpers::groupSuggestion) - .then(CommandManager.argument("players", GameProfileArgumentType.gameProfile()).suggests((context, build) -> { - ServerPlayerEntity player = context.getSource().getPlayer(); + .then(Commands.literal("players") + .then(Commands.literal("add").then(Commands.argument("group", StringArgumentType.word()).suggests(CommandHelpers::groupSuggestion) + .then(Commands.argument("players", GameProfileArgument.gameProfile()).executes(CommandClaim::addPlayer) + .then(Commands.literal("overwrite").executes(CommandClaim::forceAddPlayer))))) + .then(Commands.literal("remove").then(Commands.argument("group", StringArgumentType.word()).suggests(CommandHelpers::groupSuggestion) + .then(Commands.argument("players", GameProfileArgument.gameProfile()).suggests((context, build) -> { + ServerPlayer player = context.getSource().getPlayerOrException(); List list = new ArrayList<>(); - ServerCommandSource src = context.getSource(); - ClaimStorage storage = ClaimStorage.get(src.getWorld()); - Claim claim = storage.getClaimAt(src.getPlayer().getBlockPos()); - if (claim != null && claim.canInteract(src.getPlayer(), PermissionRegistry.EDITPERMS, src.getPlayer().getBlockPos())) { + CommandSourceStack src = context.getSource(); + ClaimStorage storage = ClaimStorage.get(src.getLevel()); + Claim claim = storage.getClaimAt(src.getPlayerOrException().blockPosition()); + if (claim != null && claim.canInteract(src.getPlayerOrException(), PermissionRegistry.EDITPERMS, src.getPlayerOrException().blockPosition())) { list = claim.playersFromGroup(player.getServer(), ""); } - return CommandSource.suggestMatching(list, build); + return SharedSuggestionProvider.suggest(list, build); }).executes(CommandClaim::removePlayer)))))) - .then(CommandManager.literal("teleport").requires(src -> PermissionNodeHandler.perm(src, PermissionNodeHandler.cmdTeleport)) - .then(CommandManager.literal("self").then(CommandManager.argument("claim", StringArgumentType.string()).suggests((ctx, b) -> CommandHelpers.claimSuggestions(ctx, b, ctx.getSource().getPlayer().getUuid())) + .then(Commands.literal("teleport").requires(src -> PermissionNodeHandler.perm(src, PermissionNodeHandler.cmdTeleport)) + .then(Commands.literal("self").then(Commands.argument("claim", StringArgumentType.string()).suggests((ctx, b) -> CommandHelpers.claimSuggestions(ctx, b, ctx.getSource().getPlayerOrException().getUUID())) .executes(CommandClaim::teleport))) - .then(CommandManager.literal("admin").then(CommandManager.argument("claim", StringArgumentType.string()).suggests((ctx, b) -> CommandHelpers.claimSuggestions(ctx, b, null)) + .then(Commands.literal("admin").then(Commands.argument("claim", StringArgumentType.string()).suggests((ctx, b) -> CommandHelpers.claimSuggestions(ctx, b, null)) .executes(CommandClaim::teleportAdminClaims))) - .then(CommandManager.literal("other").then(CommandManager.argument("player", GameProfileArgumentType.gameProfile()).then(CommandManager.argument("claim", StringArgumentType.string()).suggests((ctx, b) -> CommandHelpers.claimSuggestions(ctx, b, CommandHelpers.singleProfile(ctx, "player").getId())) + .then(Commands.literal("other").then(Commands.argument("player", GameProfileArgument.gameProfile()).then(Commands.argument("claim", StringArgumentType.string()).suggests((ctx, b) -> CommandHelpers.claimSuggestions(ctx, b, CommandHelpers.singleProfile(ctx, "player").getId())) .executes(src -> CommandClaim.teleport(src, CommandHelpers.singleProfile(src, "player").getId())))))) - .then(CommandManager.literal("permission").requires(src -> PermissionNodeHandler.perm(src, PermissionNodeHandler.cmdPermission)) - .then(CommandManager.literal("personal").then(CommandManager.argument("group", StringArgumentType.string()).suggests(CommandHelpers::personalGroupSuggestion) - .then(CommandManager.argument("permission", StringArgumentType.word()).suggests((ctx, b) -> CommandHelpers.permSuggestions(ctx, b, true)) - .then(CommandManager.argument("toggle", StringArgumentType.word()) - .suggests((ctx, b) -> CommandSource.suggestMatching(new String[]{"default", "true", "false"}, b)).executes(CommandClaim::editPersonalPerm))))) - .then(CommandManager.literal("global").then(CommandManager.argument("permission", StringArgumentType.word()).suggests((ctx, b) -> CommandHelpers.permSuggestions(ctx, b, false)) - .then(CommandManager.argument("toggle", StringArgumentType.word()).suggests((ctx, b) -> CommandSource.suggestMatching(new String[]{"default", "true", "false"}, b)).executes(CommandClaim::editGlobalPerm)))) - .then(CommandManager.literal("group").then(CommandManager.argument("group", StringArgumentType.string()).suggests(CommandHelpers::groupSuggestion) - .then(CommandManager.argument("permission", StringArgumentType.word()).suggests((ctx, b) -> CommandHelpers.permSuggestions(ctx, b, true)) - .then(CommandManager.argument("toggle", StringArgumentType.word()) - .suggests((ctx, b) -> CommandSource.suggestMatching(new String[]{"default", "true", "false"}, b)).executes(CommandClaim::editGroupPerm)))))); - builder.then(CommandManager.literal("help").executes(ctx -> CommandHelp.helpMessage(ctx, 0, builder.getArguments())) - .then(CommandManager.argument("page", IntegerArgumentType.integer()).executes(ctx -> CommandHelp.helpMessage(ctx, builder.getArguments()))) - .then(CommandManager.literal("cmd").then(CommandManager.argument("command", StringArgumentType.word()).suggests((ctx, sb) -> CommandSource.suggestMatching(CommandHelp.registeredCommands(ctx, builder.getArguments()), sb)).executes(CommandHelp::helpCmd)))); - builder.then(CommandManager.literal("?").executes(ctx -> CommandHelp.helpCmd(ctx, "help"))); + .then(Commands.literal("permission").requires(src -> PermissionNodeHandler.perm(src, PermissionNodeHandler.cmdPermission)) + .then(Commands.literal("personal").then(Commands.argument("group", StringArgumentType.string()).suggests(CommandHelpers::personalGroupSuggestion) + .then(Commands.argument("permission", StringArgumentType.word()).suggests((ctx, b) -> CommandHelpers.permSuggestions(ctx, b, true)) + .then(Commands.argument("toggle", StringArgumentType.word()) + .suggests((ctx, b) -> SharedSuggestionProvider.suggest(new String[]{"default", "true", "false"}, b)).executes(CommandClaim::editPersonalPerm))))) + .then(Commands.literal("global").then(Commands.argument("permission", StringArgumentType.word()).suggests((ctx, b) -> CommandHelpers.permSuggestions(ctx, b, false)) + .then(Commands.argument("toggle", StringArgumentType.word()).suggests((ctx, b) -> SharedSuggestionProvider.suggest(new String[]{"default", "true", "false"}, b)).executes(CommandClaim::editGlobalPerm)))) + .then(Commands.literal("group").then(Commands.argument("group", StringArgumentType.string()).suggests(CommandHelpers::groupSuggestion) + .then(Commands.argument("permission", StringArgumentType.word()).suggests((ctx, b) -> CommandHelpers.permSuggestions(ctx, b, true)) + .then(Commands.argument("toggle", StringArgumentType.word()) + .suggests((ctx, b) -> SharedSuggestionProvider.suggest(new String[]{"default", "true", "false"}, b)).executes(CommandClaim::editGroupPerm)))))); + builder.then(Commands.literal("help").executes(ctx -> CommandHelp.helpMessage(ctx, 0, builder.getArguments())) + .then(Commands.argument("page", IntegerArgumentType.integer()).executes(ctx -> CommandHelp.helpMessage(ctx, builder.getArguments()))) + .then(Commands.literal("cmd").then(Commands.argument("command", StringArgumentType.word()).suggests((ctx, sb) -> SharedSuggestionProvider.suggest(CommandHelp.registeredCommands(ctx, builder.getArguments()), sb)).executes(CommandHelp::helpCmd)))); + builder.then(Commands.literal("?").executes(ctx -> CommandHelp.helpCmd(ctx, "help"))); dispatcher.register(builder); } - private static int reloadConfig(CommandContext context) { + private static int reloadConfig(CommandContext context) { ConfigHandler.reloadConfigs(); - context.getSource().sendFeedback(PermHelper.simpleColoredText(ConfigHandler.lang.configReload), true); + context.getSource().sendSuccess(PermHelper.simpleColoredText(ConfigHandler.lang.configReload), true); return Command.SINGLE_SUCCESS; } - private static int addClaim(CommandContext context) throws CommandSyntaxException { - ServerPlayerEntity player = context.getSource().getPlayer(); - ClaimStorage storage = ClaimStorage.get(player.getServerWorld()); - BlockPos from = BlockPosArgumentType.getLoadedBlockPos(context, "from"); - BlockPos to = BlockPosArgumentType.getLoadedBlockPos(context, "to"); + private static int addClaim(CommandContext context) throws CommandSyntaxException { + ServerPlayer player = context.getSource().getPlayerOrException(); + ClaimStorage storage = ClaimStorage.get(player.getLevel()); + BlockPos from = BlockPosArgument.getLoadedBlockPos(context, "from"); + BlockPos to = BlockPosArgument.getLoadedBlockPos(context, "to"); storage.createClaim(from, to, player); return Command.SINGLE_SUCCESS; } - private static int addClaimAll(CommandContext context) throws CommandSyntaxException { - ServerPlayerEntity player = context.getSource().getPlayer(); + private static int addClaimAll(CommandContext context) throws CommandSyntaxException { + ServerPlayer player = context.getSource().getPlayerOrException(); PlayerClaimData data = PlayerClaimData.get(player); int usable = data.getClaimBlocks() + data.getAdditionalClaims() - data.usedClaimBlocks(); int size = (int) Math.floor(Math.sqrt(usable)); return addClaimRect(context, size, size); } - private static int addClaimRect(CommandContext context, int x, int z) throws CommandSyntaxException { - ServerPlayerEntity player = context.getSource().getPlayer(); - ClaimStorage storage = ClaimStorage.get(player.getServerWorld()); + private static int addClaimRect(CommandContext context, int x, int z) throws CommandSyntaxException { + ServerPlayer player = context.getSource().getPlayerOrException(); + ClaimStorage storage = ClaimStorage.get(player.getLevel()); boolean evenX = x % 2 == 0; boolean evenZ = z % 2 == 0; - BlockPos from = player.getBlockPos().add(evenX ? -(int) ((x - 1) * 0.5) : -(int) (x * 0.5), -5, evenZ ? -(int) ((z - 1) * 0.5) : -(int) (z * 0.5)); - BlockPos to = player.getBlockPos().add((int) (x * 0.5), -5, (int) (z * 0.5)); + BlockPos from = player.blockPosition().offset(evenX ? -(int) ((x - 1) * 0.5) : -(int) (x * 0.5), -5, evenZ ? -(int) ((z - 1) * 0.5) : -(int) (z * 0.5)); + BlockPos to = player.blockPosition().offset((int) (x * 0.5), -5, (int) (z * 0.5)); storage.createClaim(from, to, player); return Command.SINGLE_SUCCESS; } - private static int transferClaim(CommandContext context) throws CommandSyntaxException { - ServerPlayerEntity player = context.getSource().getPlayer(); - Collection profs = GameProfileArgumentType.getProfileArgument(context, "player"); + private static int transferClaim(CommandContext context) throws CommandSyntaxException { + ServerPlayer player = context.getSource().getPlayerOrException(); + Collection profs = GameProfileArgument.getGameProfiles(context, "player"); if (profs.size() != 1) { - context.getSource().sendFeedback(PermHelper.simpleColoredText(ConfigHandler.lang.onlyOnePlayer, Formatting.RED), false); + context.getSource().sendSuccess(PermHelper.simpleColoredText(ConfigHandler.lang.onlyOnePlayer, ChatFormatting.RED), false); return 0; } GameProfile prof = profs.iterator().next(); - ClaimStorage storage = ClaimStorage.get(player.getServerWorld()); - Claim claim = storage.getClaimAt(player.getBlockPos()); + ClaimStorage storage = ClaimStorage.get(player.getLevel()); + Claim claim = storage.getClaimAt(player.blockPosition()); if (claim == null) { - player.sendMessage(PermHelper.simpleColoredText(ConfigHandler.lang.noClaim, Formatting.RED), false); + player.displayClientMessage(PermHelper.simpleColoredText(ConfigHandler.lang.noClaim, ChatFormatting.RED), false); return 0; } PlayerClaimData data = PlayerClaimData.get(player); boolean enoughBlocks = true; if (!data.isAdminIgnoreClaim()) { - MinecraftServer server = context.getSource().getMinecraftServer(); - ServerPlayerEntity newOwner = server.getPlayerManager().getPlayer(prof.getId()); + MinecraftServer server = context.getSource().getServer(); + ServerPlayer newOwner = server.getPlayerList().getPlayer(prof.getId()); IPlayerData newData = newOwner != null ? PlayerClaimData.get(newOwner) : new OfflinePlayerData(server, prof.getId()); enoughBlocks = newData.canUseClaimBlocks(claim.getPlane()); } if (!enoughBlocks) { - player.sendMessage(PermHelper.simpleColoredText(ConfigHandler.lang.ownerTransferNoBlocks, Formatting.RED), false); + player.displayClientMessage(PermHelper.simpleColoredText(ConfigHandler.lang.ownerTransferNoBlocks, ChatFormatting.RED), false); if (PermissionNodeHandler.perm(context.getSource(), PermissionNodeHandler.cmdAdminMode, true)) - player.sendMessage(PermHelper.simpleColoredText(ConfigHandler.lang.ownerTransferNoBlocksAdmin, Formatting.RED), false); + player.displayClientMessage(PermHelper.simpleColoredText(ConfigHandler.lang.ownerTransferNoBlocksAdmin, ChatFormatting.RED), false); return 0; } if (!storage.transferOwner(claim, player, prof.getId())) { - player.sendMessage(PermHelper.simpleColoredText(ConfigHandler.lang.ownerTransferFail, Formatting.RED), false); + player.displayClientMessage(PermHelper.simpleColoredText(ConfigHandler.lang.ownerTransferFail, ChatFormatting.RED), false); return 0; } - player.sendMessage(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.ownerTransferSuccess, prof.getName()), Formatting.GOLD), false); + player.displayClientMessage(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.ownerTransferSuccess, prof.getName()), ChatFormatting.GOLD), false); return Command.SINGLE_SUCCESS; } - private static int openMenu(CommandContext context) throws CommandSyntaxException { - ServerPlayerEntity player = context.getSource().getPlayer(); + private static int openMenu(CommandContext context) throws CommandSyntaxException { + ServerPlayer player = context.getSource().getPlayerOrException(); PlayerClaimData data = PlayerClaimData.get(player); - Claim claim = ClaimStorage.get(player.getServerWorld()).getClaimAt(player.getBlockPos()); + Claim claim = ClaimStorage.get(player.getLevel()).getClaimAt(player.blockPosition()); if (claim == null) { PermHelper.noClaimMessage(player); return 0; } if (data.getEditMode() == EnumEditMode.DEFAULT) { ClaimMenuScreenHandler.openClaimMenu(player, claim); - data.addDisplayClaim(claim, EnumDisplayType.MAIN, player.getBlockPos().getY()); + data.addDisplayClaim(claim, EnumDisplayType.MAIN, player.blockPosition().getY()); } else { - Claim sub = claim.getSubClaim(player.getBlockPos()); + Claim sub = claim.getSubClaim(player.blockPosition()); if (sub != null) ClaimMenuScreenHandler.openClaimMenu(player, sub); else @@ -227,175 +227,175 @@ public class CommandClaim { return Command.SINGLE_SUCCESS; } - private static int trapped(CommandContext context) throws CommandSyntaxException { - ServerPlayerEntity player = context.getSource().getPlayer(); + private static int trapped(CommandContext context) throws CommandSyntaxException { + ServerPlayer player = context.getSource().getPlayerOrException(); PlayerClaimData data = PlayerClaimData.get(player); if (data.setTrappedRescue()) { - context.getSource().sendFeedback(PermHelper.simpleColoredText(ConfigHandler.lang.trappedRescue, Formatting.GOLD), false); + context.getSource().sendSuccess(PermHelper.simpleColoredText(ConfigHandler.lang.trappedRescue, ChatFormatting.GOLD), false); return Command.SINGLE_SUCCESS; } else { - context.getSource().sendFeedback(PermHelper.simpleColoredText(ConfigHandler.lang.trappedFail, Formatting.RED), false); + context.getSource().sendSuccess(PermHelper.simpleColoredText(ConfigHandler.lang.trappedFail, ChatFormatting.RED), false); } return 0; } - private static int nameClaim(CommandContext context) throws CommandSyntaxException { - ServerPlayerEntity player = context.getSource().getPlayer(); + private static int nameClaim(CommandContext context) throws CommandSyntaxException { + ServerPlayer player = context.getSource().getPlayerOrException(); PlayerClaimData data = PlayerClaimData.get(player); if (data.getEditMode() == EnumEditMode.DEFAULT) { Claim claim = PermHelper.checkReturn(player, PermissionRegistry.EDITPERMS, PermHelper.genericNoPermMessage(player)); if (claim == null) return 0; - boolean nameUsed = ClaimStorage.get(player.getServerWorld()).allClaimsFromPlayer(claim.getOwner()) + boolean nameUsed = ClaimStorage.get(player.getLevel()).allClaimsFromPlayer(claim.getOwner()) .stream().map(Claim::getClaimName).anyMatch(name -> name.equals(StringArgumentType.getString(context, "name"))); if (!nameUsed) { String name = StringArgumentType.getString(context, "name"); claim.setClaimName(name); - player.sendMessage(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.claimNameSet, name), Formatting.GOLD), false); + player.displayClientMessage(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.claimNameSet, name), ChatFormatting.GOLD), false); } else { - player.sendMessage(PermHelper.simpleColoredText(ConfigHandler.lang.claimNameUsed, Formatting.DARK_RED), false); + player.displayClientMessage(PermHelper.simpleColoredText(ConfigHandler.lang.claimNameUsed, ChatFormatting.DARK_RED), false); } } else { - Claim claim = ClaimStorage.get(player.getServerWorld()).getClaimAt(player.getBlockPos()); - Claim sub = claim.getSubClaim(player.getBlockPos()); - if (sub != null && (claim.canInteract(player, PermissionRegistry.EDITPERMS, player.getBlockPos()) || sub.canInteract(player, PermissionRegistry.EDITPERMS, player.getBlockPos()))) { + Claim claim = ClaimStorage.get(player.getLevel()).getClaimAt(player.blockPosition()); + Claim sub = claim.getSubClaim(player.blockPosition()); + if (sub != null && (claim.canInteract(player, PermissionRegistry.EDITPERMS, player.blockPosition()) || sub.canInteract(player, PermissionRegistry.EDITPERMS, player.blockPosition()))) { boolean nameUsed = claim.getAllSubclaims() .stream().map(Claim::getClaimName).anyMatch(name -> name.equals(StringArgumentType.getString(context, "name"))); if (!nameUsed) { String name = StringArgumentType.getString(context, "name"); sub.setClaimName(name); - player.sendMessage(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.claimNameSet, name), Formatting.GOLD), false); + player.displayClientMessage(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.claimNameSet, name), ChatFormatting.GOLD), false); } else { - player.sendMessage(PermHelper.simpleColoredText(ConfigHandler.lang.claimNameUsedSub, Formatting.DARK_RED), false); + player.displayClientMessage(PermHelper.simpleColoredText(ConfigHandler.lang.claimNameUsedSub, ChatFormatting.DARK_RED), false); } - } else if (claim.canInteract(player, PermissionRegistry.EDITPERMS, player.getBlockPos())) { - boolean nameUsed = ClaimStorage.get(player.getServerWorld()).allClaimsFromPlayer(claim.getOwner()) + } else if (claim.canInteract(player, PermissionRegistry.EDITPERMS, player.blockPosition())) { + boolean nameUsed = ClaimStorage.get(player.getLevel()).allClaimsFromPlayer(claim.getOwner()) .stream().map(Claim::getClaimName).anyMatch(name -> name.equals(StringArgumentType.getString(context, "name"))); if (!nameUsed) { String name = StringArgumentType.getString(context, "name"); claim.setClaimName(name); - player.sendMessage(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.claimNameSet, name), Formatting.GOLD), false); + player.displayClientMessage(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.claimNameSet, name), ChatFormatting.GOLD), false); } else { - player.sendMessage(PermHelper.simpleColoredText(ConfigHandler.lang.claimNameUsed, Formatting.DARK_RED), false); + player.displayClientMessage(PermHelper.simpleColoredText(ConfigHandler.lang.claimNameUsed, ChatFormatting.DARK_RED), false); } } else - player.sendMessage(PermHelper.simpleColoredText(ConfigHandler.lang.noPermission, Formatting.DARK_RED), false); + player.displayClientMessage(PermHelper.simpleColoredText(ConfigHandler.lang.noPermission, ChatFormatting.DARK_RED), false); } return Command.SINGLE_SUCCESS; } - private static int unlockDrops(CommandContext context) throws CommandSyntaxException { - ServerPlayerEntity player = context.getSource().getPlayer(); + private static int unlockDrops(CommandContext context) throws CommandSyntaxException { + ServerPlayer player = context.getSource().getPlayerOrException(); PlayerClaimData data = PlayerClaimData.get(player); data.unlockDeathItems(); - context.getSource().sendFeedback(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.unlockDrops, ConfigHandler.config.dropTicks), Formatting.GOLD), false); + context.getSource().sendSuccess(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.unlockDrops, ConfigHandler.config.dropTicks), ChatFormatting.GOLD), false); return Command.SINGLE_SUCCESS; } - private static int unlockDropsPlayers(CommandContext context) throws CommandSyntaxException { - Collection profs = GameProfileArgumentType.getProfileArgument(context, "players"); + private static int unlockDropsPlayers(CommandContext context) throws CommandSyntaxException { + Collection profs = GameProfileArgument.getGameProfiles(context, "players"); List success = new ArrayList<>(); for (GameProfile prof : profs) { - ServerPlayerEntity player = context.getSource().getMinecraftServer().getPlayerManager().getPlayer(prof.getId()); + ServerPlayer player = context.getSource().getServer().getPlayerList().getPlayer(prof.getId()); if (player != null) { PlayerClaimData data = PlayerClaimData.get(player); data.unlockDeathItems(); success.add(prof.getName()); } } - context.getSource().sendFeedback(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.unlockDropsMulti, success), Formatting.GOLD), false); + context.getSource().sendSuccess(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.unlockDropsMulti, success), ChatFormatting.GOLD), false); return Command.SINGLE_SUCCESS; } - private static int openPersonalGroups(CommandContext context) throws CommandSyntaxException { - ServerPlayerEntity player = context.getSource().getPlayer(); + private static int openPersonalGroups(CommandContext context) throws CommandSyntaxException { + ServerPlayer player = context.getSource().getPlayerOrException(); PersonalGroupScreenHandler.openGroupMenu(player); return Command.SINGLE_SUCCESS; } - private static int claimInfo(CommandContext context) throws CommandSyntaxException { + private static int claimInfo(CommandContext context) throws CommandSyntaxException { return claimInfo(context, CommandHelpers.parseEnum(Claim.InfoType.class, StringArgumentType.getString(context, "type"), Claim.InfoType.ALL)); } - private static int claimInfo(CommandContext context, Claim.InfoType infoType) throws CommandSyntaxException { - ServerPlayerEntity player = context.getSource().getPlayer(); - Claim claim = ClaimStorage.get(player.getServerWorld()).getClaimAt(player.getBlockPos()); + private static int claimInfo(CommandContext context, Claim.InfoType infoType) throws CommandSyntaxException { + ServerPlayer player = context.getSource().getPlayerOrException(); + Claim claim = ClaimStorage.get(player.getLevel()).getClaimAt(player.blockPosition()); PlayerClaimData data = PlayerClaimData.get(player); if (claim == null) { - player.sendMessage(PermHelper.simpleColoredText(ConfigHandler.lang.noClaim, Formatting.RED), false); + player.displayClientMessage(PermHelper.simpleColoredText(ConfigHandler.lang.noClaim, ChatFormatting.RED), false); return 0; } if (data.getEditMode() == EnumEditMode.SUBCLAIM) { - Claim sub = claim.getSubClaim(player.getBlockPos()); + Claim sub = claim.getSubClaim(player.blockPosition()); if (sub != null) { - List info = sub.infoString(player, infoType); - player.sendMessage(PermHelper.simpleColoredText(ConfigHandler.lang.claimSubHeader, Formatting.AQUA), false); - for (Text text : info) - player.sendMessage(text, false); + List info = sub.infoString(player, infoType); + player.displayClientMessage(PermHelper.simpleColoredText(ConfigHandler.lang.claimSubHeader, ChatFormatting.AQUA), false); + for (Component text : info) + player.displayClientMessage(text, false); return Command.SINGLE_SUCCESS; } } - List info = claim.infoString(player, infoType); - for (Text text : info) - player.sendMessage(text, false); + List info = claim.infoString(player, infoType); + for (Component text : info) + player.displayClientMessage(text, false); return Command.SINGLE_SUCCESS; } - private static int deleteClaim(CommandContext context) throws CommandSyntaxException { - ServerPlayerEntity player = context.getSource().getPlayer(); - ClaimStorage storage = ClaimStorage.get(player.getServerWorld()); - Claim claim = storage.getClaimAt(player.getBlockPos()); - boolean check = PermHelper.check(player, player.getBlockPos(), claim, PermissionRegistry.EDITCLAIM, b -> { + private static int deleteClaim(CommandContext context) throws CommandSyntaxException { + ServerPlayer player = context.getSource().getPlayerOrException(); + ClaimStorage storage = ClaimStorage.get(player.getLevel()); + Claim claim = storage.getClaimAt(player.blockPosition()); + boolean check = PermHelper.check(player, player.blockPosition(), claim, PermissionRegistry.EDITCLAIM, b -> { if (!b.isPresent()) PermHelper.noClaimMessage(player); else if (!b.get()) - player.sendMessage(PermHelper.simpleColoredText(ConfigHandler.lang.deleteClaimError, Formatting.DARK_RED), false); + player.displayClientMessage(PermHelper.simpleColoredText(ConfigHandler.lang.deleteClaimError, ChatFormatting.DARK_RED), false); else - player.sendMessage(PermHelper.simpleColoredText(ConfigHandler.lang.deleteClaim, Formatting.RED), false); + player.displayClientMessage(PermHelper.simpleColoredText(ConfigHandler.lang.deleteClaim, ChatFormatting.RED), false); }); if (!check) return 0; - storage.deleteClaim(claim, true, PlayerClaimData.get(player).getEditMode(), player.getServerWorld()); + storage.deleteClaim(claim, true, PlayerClaimData.get(player).getEditMode(), player.getLevel()); return Command.SINGLE_SUCCESS; } - private static int deleteAllClaim(CommandContext context) throws CommandSyntaxException { - ServerPlayerEntity player = context.getSource().getPlayer(); + private static int deleteAllClaim(CommandContext context) throws CommandSyntaxException { + ServerPlayer player = context.getSource().getPlayerOrException(); PlayerClaimData data = PlayerClaimData.get(player); if (data.confirmedDeleteAll()) { - for (ServerWorld world : player.getServer().getWorlds()) { + for (ServerLevel world : player.getServer().getAllLevels()) { ClaimStorage storage = ClaimStorage.get(world); - storage.allClaimsFromPlayer(player.getUuid()).forEach((claim) -> storage.deleteClaim(claim, true, PlayerClaimData.get(player).getEditMode(), player.getServerWorld())); + storage.allClaimsFromPlayer(player.getUUID()).forEach((claim) -> storage.deleteClaim(claim, true, PlayerClaimData.get(player).getEditMode(), player.getLevel())); } - player.sendMessage(PermHelper.simpleColoredText(ConfigHandler.lang.deleteAllClaim, Formatting.GOLD), false); + player.displayClientMessage(PermHelper.simpleColoredText(ConfigHandler.lang.deleteAllClaim, ChatFormatting.GOLD), false); data.setConfirmDeleteAll(false); } else { data.setConfirmDeleteAll(true); - player.sendMessage(PermHelper.simpleColoredText(ConfigHandler.lang.deleteAllClaimConfirm, Formatting.DARK_RED), false); + player.displayClientMessage(PermHelper.simpleColoredText(ConfigHandler.lang.deleteAllClaimConfirm, ChatFormatting.DARK_RED), false); } return Command.SINGLE_SUCCESS; } - private static int deleteSubClaim(CommandContext context) throws CommandSyntaxException { - ServerPlayerEntity player = context.getSource().getPlayer(); - ClaimStorage storage = ClaimStorage.get(player.getServerWorld()); - Claim claim = storage.getClaimAt(player.getBlockPos()); + private static int deleteSubClaim(CommandContext context) throws CommandSyntaxException { + ServerPlayer player = context.getSource().getPlayerOrException(); + ClaimStorage storage = ClaimStorage.get(player.getLevel()); + Claim claim = storage.getClaimAt(player.blockPosition()); if (claim == null) { - player.sendMessage(PermHelper.simpleColoredText(ConfigHandler.lang.noClaim, Formatting.RED), false); + player.displayClientMessage(PermHelper.simpleColoredText(ConfigHandler.lang.noClaim, ChatFormatting.RED), false); return 0; } - Claim sub = claim.getSubClaim(player.getBlockPos()); + Claim sub = claim.getSubClaim(player.blockPosition()); if (sub == null) { - player.sendMessage(PermHelper.simpleColoredText(ConfigHandler.lang.noClaim, Formatting.RED), false); + player.displayClientMessage(PermHelper.simpleColoredText(ConfigHandler.lang.noClaim, ChatFormatting.RED), false); return 0; } - boolean check = PermHelper.check(player, player.getBlockPos(), claim, PermissionRegistry.EDITCLAIM, b -> { + boolean check = PermHelper.check(player, player.blockPosition(), claim, PermissionRegistry.EDITCLAIM, b -> { if (!b.isPresent()) PermHelper.noClaimMessage(player); else if (!b.get()) - player.sendMessage(PermHelper.simpleColoredText(ConfigHandler.lang.deleteClaimError, Formatting.DARK_RED), false); + player.displayClientMessage(PermHelper.simpleColoredText(ConfigHandler.lang.deleteClaimError, ChatFormatting.DARK_RED), false); else - player.sendMessage(PermHelper.simpleColoredText(ConfigHandler.lang.deleteSubClaim, Formatting.DARK_RED), false); + player.displayClientMessage(PermHelper.simpleColoredText(ConfigHandler.lang.deleteSubClaim, ChatFormatting.DARK_RED), false); }); if (!check) return 0; @@ -403,24 +403,24 @@ public class CommandClaim { return Command.SINGLE_SUCCESS; } - private static int deleteAllSubClaim(CommandContext context) throws CommandSyntaxException { - ServerPlayerEntity player = context.getSource().getPlayer(); + private static int deleteAllSubClaim(CommandContext context) throws CommandSyntaxException { + ServerPlayer player = context.getSource().getPlayerOrException(); Claim claim = PermHelper.checkReturn(player, PermissionRegistry.EDITCLAIM, PermHelper.genericNoPermMessage(player)); if (claim == null) return 0; List subs = claim.getAllSubclaims(); subs.forEach(claim::deleteSubClaim); - player.sendMessage(PermHelper.simpleColoredText(ConfigHandler.lang.deleteSubClaimAll, Formatting.DARK_RED), false); + player.displayClientMessage(PermHelper.simpleColoredText(ConfigHandler.lang.deleteSubClaimAll, ChatFormatting.DARK_RED), false); return Command.SINGLE_SUCCESS; } - private static int listClaims(CommandContext context) throws CommandSyntaxException { + private static int listClaims(CommandContext context) throws CommandSyntaxException { return listClaimsFromUUID(context, null); } - private static int listClaims(CommandContext context, Collection profs) throws CommandSyntaxException { + private static int listClaims(CommandContext context, Collection profs) throws CommandSyntaxException { if (profs.size() != 1) { - context.getSource().sendFeedback(PermHelper.simpleColoredText(ConfigHandler.lang.onlyOnePlayer, Formatting.RED), false); + context.getSource().sendSuccess(PermHelper.simpleColoredText(ConfigHandler.lang.onlyOnePlayer, ChatFormatting.RED), false); return 0; } GameProfile prof = profs.iterator().next(); @@ -429,164 +429,164 @@ public class CommandClaim { return listClaimsFromUUID(context, prof.getId()); } - private static int listClaimsFromUUID(CommandContext context, UUID of) throws CommandSyntaxException { - MinecraftServer server = context.getSource().getMinecraftServer(); - ServerPlayerEntity player = of == null ? context.getSource().getPlayer() : server.getPlayerManager().getPlayer(of); - Map> claims = new HashMap<>(); - for (ServerWorld world : server.getWorlds()) { + private static int listClaimsFromUUID(CommandContext context, UUID of) throws CommandSyntaxException { + MinecraftServer server = context.getSource().getServer(); + ServerPlayer player = of == null ? context.getSource().getPlayerOrException() : server.getPlayerList().getPlayer(of); + Map> claims = new HashMap<>(); + for (ServerLevel world : server.getAllLevels()) { ClaimStorage storage = ClaimStorage.get(world); - claims.put(world, storage.allClaimsFromPlayer(player != null ? player.getUuid() : of)); + claims.put(world, storage.allClaimsFromPlayer(player != null ? player.getUUID() : of)); } if (ConfigHandler.config.maxClaimBlocks != -1) { if (player != null) { PlayerClaimData data = PlayerClaimData.get(player); - context.getSource().sendFeedback(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.claimBlocksFormat, - data.getClaimBlocks(), data.getAdditionalClaims(), data.usedClaimBlocks()), Formatting.GOLD), false); + context.getSource().sendSuccess(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.claimBlocksFormat, + data.getClaimBlocks(), data.getAdditionalClaims(), data.usedClaimBlocks()), ChatFormatting.GOLD), false); } else { OfflinePlayerData data = new OfflinePlayerData(server, of); - context.getSource().sendFeedback(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.claimBlocksFormat, - data.claimBlocks, data.getAdditionalClaims(), data.usedClaimBlocks()), Formatting.GOLD), false); + context.getSource().sendSuccess(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.claimBlocksFormat, + data.claimBlocks, data.getAdditionalClaims(), data.usedClaimBlocks()), ChatFormatting.GOLD), false); } } - context.getSource().sendFeedback(PermHelper.simpleColoredText(ConfigHandler.lang.listClaims, Formatting.GOLD), false); - for (Map.Entry> entry : claims.entrySet()) + context.getSource().sendSuccess(PermHelper.simpleColoredText(ConfigHandler.lang.listClaims, ChatFormatting.GOLD), false); + for (Map.Entry> entry : claims.entrySet()) for (Claim claim : entry.getValue()) - context.getSource().sendFeedback(PermHelper.simpleColoredText( - entry.getKey().getRegistryKey().getValue().toString() + " # " + claim.formattedClaim(), Formatting.YELLOW), false); + context.getSource().sendSuccess(PermHelper.simpleColoredText( + entry.getKey().dimension().location().toString() + " # " + claim.formattedClaim(), ChatFormatting.YELLOW), false); return Command.SINGLE_SUCCESS; } - private static int switchClaimMode(CommandContext context) throws CommandSyntaxException { - ServerPlayerEntity player = context.getSource().getPlayer(); + private static int switchClaimMode(CommandContext context) throws CommandSyntaxException { + ServerPlayer player = context.getSource().getPlayerOrException(); PlayerClaimData data = PlayerClaimData.get(player); data.setEditMode(data.getEditMode() == EnumEditMode.DEFAULT ? EnumEditMode.SUBCLAIM : EnumEditMode.DEFAULT); - player.sendMessage(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.editMode, data.getEditMode()), Formatting.GOLD), false); + player.displayClientMessage(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.editMode, data.getEditMode()), ChatFormatting.GOLD), false); return Command.SINGLE_SUCCESS; } - private static int switchAdminMode(CommandContext context) throws CommandSyntaxException { - ServerPlayerEntity player = context.getSource().getPlayer(); + private static int switchAdminMode(CommandContext context) throws CommandSyntaxException { + ServerPlayer player = context.getSource().getPlayerOrException(); PlayerClaimData data = PlayerClaimData.get(player); data.setAdminIgnoreClaim(!data.isAdminIgnoreClaim()); - player.sendMessage(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.adminMode, data.isAdminIgnoreClaim()), Formatting.GOLD), false); + player.displayClientMessage(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.adminMode, data.isAdminIgnoreClaim()), ChatFormatting.GOLD), false); return Command.SINGLE_SUCCESS; } - private static int adminDelete(CommandContext context) { - ServerCommandSource src = context.getSource(); - ClaimStorage storage = ClaimStorage.get(src.getWorld()); + private static int adminDelete(CommandContext context) { + CommandSourceStack src = context.getSource(); + ClaimStorage storage = ClaimStorage.get(src.getLevel()); Claim claim = storage.getClaimAt(new BlockPos(src.getPosition())); if (claim == null) { - src.sendFeedback(PermHelper.simpleColoredText(ConfigHandler.lang.noClaim, Formatting.RED), false); + src.sendSuccess(PermHelper.simpleColoredText(ConfigHandler.lang.noClaim, ChatFormatting.RED), false); return 0; } - storage.deleteClaim(claim, true, EnumEditMode.DEFAULT, src.getWorld()); - src.sendFeedback(PermHelper.simpleColoredText(ConfigHandler.lang.deleteClaim, Formatting.RED), true); + storage.deleteClaim(claim, true, EnumEditMode.DEFAULT, src.getLevel()); + src.sendSuccess(PermHelper.simpleColoredText(ConfigHandler.lang.deleteClaim, ChatFormatting.RED), true); return Command.SINGLE_SUCCESS; } - private static int adminDeleteAll(CommandContext context) throws CommandSyntaxException { - ServerCommandSource src = context.getSource(); - if (src.getEntity() instanceof ServerPlayerEntity) { - ServerPlayerEntity player = (ServerPlayerEntity) src.getEntity(); + private static int adminDeleteAll(CommandContext context) throws CommandSyntaxException { + CommandSourceStack src = context.getSource(); + if (src.getEntity() instanceof ServerPlayer) { + ServerPlayer player = (ServerPlayer) src.getEntity(); PlayerClaimData data = PlayerClaimData.get(player); if (!data.confirmedDeleteAll()) { data.setConfirmDeleteAll(true); - player.sendMessage(PermHelper.simpleColoredText(ConfigHandler.lang.deleteAllClaimConfirm, Formatting.DARK_RED), false); + player.displayClientMessage(PermHelper.simpleColoredText(ConfigHandler.lang.deleteAllClaimConfirm, ChatFormatting.DARK_RED), false); return Command.SINGLE_SUCCESS; } } List players = new ArrayList<>(); - for (GameProfile prof : GameProfileArgumentType.getProfileArgument(context, "players")) { - for (ServerWorld world : src.getWorld().getServer().getWorlds()) { + for (GameProfile prof : GameProfileArgument.getGameProfiles(context, "players")) { + for (ServerLevel world : src.getLevel().getServer().getAllLevels()) { ClaimStorage storage = ClaimStorage.get(world); storage.allClaimsFromPlayer(prof.getId()).forEach((claim) -> storage.deleteClaim(claim, true, EnumEditMode.DEFAULT, world)); } players.add(prof.getName()); } - src.sendFeedback(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.adminDeleteAll, players), Formatting.GOLD), true); + src.sendSuccess(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.adminDeleteAll, players), ChatFormatting.GOLD), true); return Command.SINGLE_SUCCESS; } - private static int toggleAdminClaim(CommandContext context) throws CommandSyntaxException { - ServerPlayerEntity player = context.getSource().getPlayer(); - ClaimStorage storage = ClaimStorage.get(player.getServerWorld()); - Claim claim = storage.getClaimAt(player.getBlockPos()); + private static int toggleAdminClaim(CommandContext context) throws CommandSyntaxException { + ServerPlayer player = context.getSource().getPlayerOrException(); + ClaimStorage storage = ClaimStorage.get(player.getLevel()); + Claim claim = storage.getClaimAt(player.blockPosition()); if (claim == null) { - context.getSource().sendFeedback(PermHelper.simpleColoredText(ConfigHandler.lang.noClaim, Formatting.RED), false); + context.getSource().sendSuccess(PermHelper.simpleColoredText(ConfigHandler.lang.noClaim, ChatFormatting.RED), false); return 0; } storage.toggleAdminClaim(player, claim, BoolArgumentType.getBool(context, "toggle")); - context.getSource().sendFeedback(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.setAdminClaim, claim.isAdminClaim()), Formatting.GOLD), true); + context.getSource().sendSuccess(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.setAdminClaim, claim.isAdminClaim()), ChatFormatting.GOLD), true); return Command.SINGLE_SUCCESS; } - private static int listAdminClaims(CommandContext context) { - ServerCommandSource src = context.getSource(); - Collection claims = ClaimStorage.get(src.getWorld()).getAdminClaims(); - src.sendFeedback(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.listAdminClaims, src.getWorld().getRegistryKey().getValue()), Formatting.GOLD), false); + private static int listAdminClaims(CommandContext context) { + CommandSourceStack src = context.getSource(); + Collection claims = ClaimStorage.get(src.getLevel()).getAdminClaims(); + src.sendSuccess(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.listAdminClaims, src.getLevel().dimension().location()), ChatFormatting.GOLD), false); for (Claim claim : claims) - src.sendFeedback(PermHelper.simpleColoredText(claim.formattedClaim(), Formatting.YELLOW), false); + src.sendSuccess(PermHelper.simpleColoredText(claim.formattedClaim(), ChatFormatting.YELLOW), false); return Command.SINGLE_SUCCESS; } - private static int readGriefPreventionData(CommandContext context) { - ServerCommandSource src = context.getSource(); - src.sendFeedback(PermHelper.simpleColoredText(ConfigHandler.lang.readGriefpreventionData, Formatting.GOLD), true); - if (ClaimStorage.readGriefPreventionData(src.getMinecraftServer(), src)) - src.sendFeedback(PermHelper.simpleColoredText(ConfigHandler.lang.readGriefpreventionClaimDataSuccess, Formatting.GOLD), true); - if (PlayerClaimData.readGriefPreventionPlayerData(src.getMinecraftServer(), src)) - src.sendFeedback(PermHelper.simpleColoredText(ConfigHandler.lang.readGriefpreventionPlayerDataSuccess, Formatting.GOLD), true); + private static int readGriefPreventionData(CommandContext context) { + CommandSourceStack src = context.getSource(); + src.sendSuccess(PermHelper.simpleColoredText(ConfigHandler.lang.readGriefpreventionData, ChatFormatting.GOLD), true); + if (ClaimStorage.readGriefPreventionData(src.getServer(), src)) + src.sendSuccess(PermHelper.simpleColoredText(ConfigHandler.lang.readGriefpreventionClaimDataSuccess, ChatFormatting.GOLD), true); + if (PlayerClaimData.readGriefPreventionPlayerData(src.getServer(), src)) + src.sendSuccess(PermHelper.simpleColoredText(ConfigHandler.lang.readGriefpreventionPlayerDataSuccess, ChatFormatting.GOLD), true); return Command.SINGLE_SUCCESS; } - private static int giveClaimBlocks(CommandContext context) throws CommandSyntaxException { - ServerCommandSource src = context.getSource(); + private static int giveClaimBlocks(CommandContext context) throws CommandSyntaxException { + CommandSourceStack src = context.getSource(); List players = new ArrayList<>(); int amount = IntegerArgumentType.getInteger(context, "amount"); - for (GameProfile prof : GameProfileArgumentType.getProfileArgument(context, "players")) { - ServerPlayerEntity player = src.getMinecraftServer().getPlayerManager().getPlayer(prof.getId()); + for (GameProfile prof : GameProfileArgument.getGameProfiles(context, "players")) { + ServerPlayer player = src.getServer().getPlayerList().getPlayer(prof.getId()); if (player != null) { PlayerClaimData data = PlayerClaimData.get(player); data.setAdditionalClaims(data.getAdditionalClaims() + amount); } else - PlayerClaimData.editForOfflinePlayer(src.getMinecraftServer(), prof.getId(), amount); + PlayerClaimData.editForOfflinePlayer(src.getServer(), prof.getId(), amount); players.add(prof.getName()); } - src.sendFeedback(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.giveClaimBlocks, players, amount), Formatting.GOLD), true); + src.sendSuccess(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.giveClaimBlocks, players, amount), ChatFormatting.GOLD), true); return Command.SINGLE_SUCCESS; } - private static int addGroup(CommandContext context) throws CommandSyntaxException { + private static int addGroup(CommandContext context) throws CommandSyntaxException { return modifyGroup(context, false); } - private static int removeGroup(CommandContext context) throws CommandSyntaxException { + private static int removeGroup(CommandContext context) throws CommandSyntaxException { return modifyGroup(context, true); } - private static int modifyGroup(CommandContext context, boolean remove) throws CommandSyntaxException { - ServerPlayerEntity player = context.getSource().getPlayer(); + private static int modifyGroup(CommandContext context, boolean remove) throws CommandSyntaxException { + ServerPlayer player = context.getSource().getPlayerOrException(); String group = StringArgumentType.getString(context, "group"); - ClaimStorage storage = ClaimStorage.get(player.getServerWorld()); - Claim claim = storage.getClaimAt(player.getBlockPos()); + ClaimStorage storage = ClaimStorage.get(player.getLevel()); + Claim claim = storage.getClaimAt(player.blockPosition()); if (claim == null) { PermHelper.noClaimMessage(player); return 0; } if (remove) { if (claim.removePermGroup(player, group)) - player.sendMessage(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.groupRemove, group), Formatting.GOLD), false); + player.displayClientMessage(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.groupRemove, group), ChatFormatting.GOLD), false); else { PermHelper.genericNoPermMessage(player); return 0; } } else { if (claim.groups().contains(group)) { - player.sendMessage(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.groupExist, group), Formatting.RED), false); + player.displayClientMessage(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.groupExist, group), ChatFormatting.RED), false); return 0; } else if (claim.editPerms(player, group, PermissionRegistry.EDITPERMS, -1)) - player.sendMessage(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.groupAdd, group), Formatting.GOLD), false); + player.displayClientMessage(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.groupAdd, group), ChatFormatting.GOLD), false); else { PermHelper.genericNoPermMessage(player); return 0; @@ -595,45 +595,45 @@ public class CommandClaim { return Command.SINGLE_SUCCESS; } - private static int forceAddPlayer(CommandContext context) throws CommandSyntaxException { + private static int forceAddPlayer(CommandContext context) throws CommandSyntaxException { String group = StringArgumentType.getString(context, "group"); return modifyPlayer(context, group, true); } - private static int addPlayer(CommandContext context) throws CommandSyntaxException { + private static int addPlayer(CommandContext context) throws CommandSyntaxException { String group = StringArgumentType.getString(context, "group"); return modifyPlayer(context, group, false); } - private static int removePlayer(CommandContext context) throws CommandSyntaxException { + private static int removePlayer(CommandContext context) throws CommandSyntaxException { return modifyPlayer(context, null, false); } - private static int modifyPlayer(CommandContext context, String group, boolean force) throws CommandSyntaxException { - ServerPlayerEntity player = context.getSource().getPlayer(); - ClaimStorage storage = ClaimStorage.get(player.getServerWorld()); - Claim claim = storage.getClaimAt(player.getBlockPos()); + private static int modifyPlayer(CommandContext context, String group, boolean force) throws CommandSyntaxException { + ServerPlayer player = context.getSource().getPlayerOrException(); + ClaimStorage storage = ClaimStorage.get(player.getLevel()); + Claim claim = storage.getClaimAt(player.blockPosition()); if (claim == null) { PermHelper.noClaimMessage(player); return 0; } - if (!claim.canInteract(player, PermissionRegistry.EDITPERMS, player.getBlockPos())) { + if (!claim.canInteract(player, PermissionRegistry.EDITPERMS, player.blockPosition())) { PermHelper.genericNoPermMessage(player); return 0; } List modified = new ArrayList<>(); - for (GameProfile prof : GameProfileArgumentType.getProfileArgument(context, "players")) { + for (GameProfile prof : GameProfileArgument.getGameProfiles(context, "players")) { if (claim.setPlayerGroup(prof.getId(), group, force)) modified.add(prof.getName()); } if (!modified.isEmpty()) - player.sendMessage(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.playerModify, group, modified), Formatting.GOLD), false); + player.displayClientMessage(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.playerModify, group, modified), ChatFormatting.GOLD), false); else - player.sendMessage(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.playerModifyNo, group, modified), Formatting.RED), false); + player.displayClientMessage(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.playerModifyNo, group, modified), ChatFormatting.RED), false); return Command.SINGLE_SUCCESS; } - private static int editGlobalPerm(CommandContext context) throws CommandSyntaxException { + private static int editGlobalPerm(CommandContext context) throws CommandSyntaxException { int mode = 0; switch (StringArgumentType.getString(context, "toggle")) { case "true": @@ -649,7 +649,7 @@ public class CommandClaim { return editPerms(context, null, mode); } - private static int editGroupPerm(CommandContext context) throws CommandSyntaxException { + private static int editGroupPerm(CommandContext context) throws CommandSyntaxException { int mode = 0; switch (StringArgumentType.getString(context, "toggle")) { case "true": @@ -665,12 +665,12 @@ public class CommandClaim { return editPerms(context, StringArgumentType.getString(context, "group"), mode); } - private static int editPerms(CommandContext context, String group, int mode) throws CommandSyntaxException { - ServerPlayerEntity player = context.getSource().getPlayer(); - Claim claim = ClaimStorage.get(player.getServerWorld()).getClaimAt(player.getBlockPos()); + private static int editPerms(CommandContext context, String group, int mode) throws CommandSyntaxException { + ServerPlayer player = context.getSource().getPlayerOrException(); + Claim claim = ClaimStorage.get(player.getLevel()).getClaimAt(player.blockPosition()); PlayerClaimData data = PlayerClaimData.get(player); if (data.getEditMode() == EnumEditMode.SUBCLAIM) { - Claim sub = claim.getSubClaim(player.getBlockPos()); + Claim sub = claim.getSubClaim(player.blockPosition()); if (sub != null) claim = sub; } @@ -678,8 +678,8 @@ public class CommandClaim { PermHelper.noClaimMessage(player); return 0; } - if (!claim.canInteract(player, PermissionRegistry.EDITPERMS, player.getBlockPos())) { - player.sendMessage(PermHelper.simpleColoredText(ConfigHandler.lang.noPermission, Formatting.DARK_RED), false); + if (!claim.canInteract(player, PermissionRegistry.EDITPERMS, player.blockPosition())) { + player.displayClientMessage(PermHelper.simpleColoredText(ConfigHandler.lang.noPermission, ChatFormatting.DARK_RED), false); return 0; } ClaimPermission perm; @@ -689,22 +689,22 @@ public class CommandClaim { if (group != null && PermissionRegistry.globalPerms().contains(perm)) throw new IllegalArgumentException(); } catch (NullPointerException e) { - player.sendMessage(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.noSuchPerm, p), Formatting.DARK_RED), false); + player.displayClientMessage(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.noSuchPerm, p), ChatFormatting.DARK_RED), false); return 0; } String setPerm = mode == 1 ? "true" : mode == 0 ? "false" : "default"; if (group == null) { claim.editGlobalPerms(player, perm, mode); - player.sendMessage(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.editPerm, perm, setPerm), Formatting.GOLD), false); + player.displayClientMessage(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.editPerm, perm, setPerm), ChatFormatting.GOLD), false); } else { claim.editPerms(player, group, perm, mode); - player.sendMessage(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.editPermGroup, perm, group, setPerm), Formatting.GOLD), false); + player.displayClientMessage(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.editPermGroup, perm, group, setPerm), ChatFormatting.GOLD), false); } return Command.SINGLE_SUCCESS; } - private static int editPersonalPerm(CommandContext context) throws CommandSyntaxException { - ServerPlayerEntity player = context.getSource().getPlayer(); + private static int editPersonalPerm(CommandContext context) throws CommandSyntaxException { + ServerPlayer player = context.getSource().getPlayerOrException(); String group = StringArgumentType.getString(context, "group"); int mode = 0; switch (StringArgumentType.getString(context, "toggle")) { @@ -725,37 +725,37 @@ public class CommandClaim { if (PermissionRegistry.globalPerms().contains(perm)) throw new IllegalArgumentException(); } catch (NullPointerException e) { - player.sendMessage(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.noSuchPerm, p), Formatting.DARK_RED), false); + player.displayClientMessage(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.noSuchPerm, p), ChatFormatting.DARK_RED), false); return 0; } String setPerm = mode == 1 ? "true" : mode == 0 ? "false" : "default"; if (PlayerClaimData.get(player).editDefaultPerms(group, perm, mode)) - player.sendMessage(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.editPersonalGroup, group, perm, setPerm), Formatting.GOLD), false); + player.displayClientMessage(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.editPersonalGroup, group, perm, setPerm), ChatFormatting.GOLD), false); return Command.SINGLE_SUCCESS; } - public static int setClaimHome(CommandContext context) throws CommandSyntaxException { - ServerPlayerEntity player = context.getSource().getPlayer(); + public static int setClaimHome(CommandContext context) throws CommandSyntaxException { + ServerPlayer player = context.getSource().getPlayerOrException(); Claim claim = PermHelper.checkReturn(player, PermissionRegistry.EDITCLAIM, PermHelper.genericNoPermMessage(player)); if (claim == null) return 0; - claim.setHomePos(player.getBlockPos()); - context.getSource().sendFeedback(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.setHome, player.getBlockPos().getX(), player.getBlockPos().getY(), player.getBlockPos().getZ()), Formatting.GOLD), false); + claim.setHomePos(player.blockPosition()); + context.getSource().sendSuccess(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.setHome, player.blockPosition().getX(), player.blockPosition().getY(), player.blockPosition().getZ()), ChatFormatting.GOLD), false); return Command.SINGLE_SUCCESS; } - public static int teleport(CommandContext context) throws CommandSyntaxException { - return teleport(context, context.getSource().getPlayer().getUuid()); + public static int teleport(CommandContext context) throws CommandSyntaxException { + return teleport(context, context.getSource().getPlayerOrException().getUUID()); } - public static int teleportAdminClaims(CommandContext context) throws CommandSyntaxException { + public static int teleportAdminClaims(CommandContext context) throws CommandSyntaxException { return teleport(context, null); } - public static int teleport(CommandContext context, UUID owner) throws CommandSyntaxException { - ServerPlayerEntity player = context.getSource().getPlayer(); + public static int teleport(CommandContext context, UUID owner) throws CommandSyntaxException { + ServerPlayer player = context.getSource().getPlayerOrException(); String name = StringArgumentType.getString(context, "claim"); - return ClaimStorage.get(player.getServerWorld()).allClaimsFromPlayer(owner) + return ClaimStorage.get(player.getLevel()).allClaimsFromPlayer(owner) .stream().filter(claim -> { if (claim.getClaimName().isEmpty()) return claim.getClaimID().toString().equals(name); @@ -765,30 +765,30 @@ public class CommandClaim { if (claim.canInteract(player, PermissionRegistry.TELEPORT, pos, false)) { PlayerClaimData data = PlayerClaimData.get(player); if (data.setTeleportTo(pos)) { - context.getSource().sendFeedback(PermHelper.simpleColoredText(ConfigHandler.lang.teleportHome, Formatting.GOLD), false); + context.getSource().sendSuccess(PermHelper.simpleColoredText(ConfigHandler.lang.teleportHome, ChatFormatting.GOLD), false); return Command.SINGLE_SUCCESS; } - context.getSource().sendFeedback(PermHelper.simpleColoredText(ConfigHandler.lang.teleportHomeFail, Formatting.RED), false); + context.getSource().sendSuccess(PermHelper.simpleColoredText(ConfigHandler.lang.teleportHomeFail, ChatFormatting.RED), false); } else - context.getSource().sendFeedback(PermHelper.simpleColoredText(ConfigHandler.lang.noPermissionSimple, Formatting.DARK_RED), false); + context.getSource().sendSuccess(PermHelper.simpleColoredText(ConfigHandler.lang.noPermissionSimple, ChatFormatting.DARK_RED), false); return 0; }).orElse(0); } - public static int editClaimMessages(CommandContext context) throws CommandSyntaxException { - return editClaimMessages(context, new LiteralText(StringArgumentType.getString(context, "message"))); + public static int editClaimMessages(CommandContext context) throws CommandSyntaxException { + return editClaimMessages(context, new TextComponent(StringArgumentType.getString(context, "message"))); } - public static int editClaimMessages(CommandContext context, Text text) throws CommandSyntaxException { - if (text instanceof MutableText) { + public static int editClaimMessages(CommandContext context, Component text) throws CommandSyntaxException { + if (text instanceof MutableComponent) { Style style = text.getStyle(); if (style.isEmpty()) - style = style.withFormatting(Formatting.WHITE); + style = style.applyFormat(ChatFormatting.WHITE); if (!style.isItalic()) style = style.withItalic(false); - ((MutableText) text).setStyle(style); + ((MutableComponent) text).setStyle(style); } - ServerPlayerEntity player = context.getSource().getPlayer(); + ServerPlayer player = context.getSource().getPlayerOrException(); Claim claim = PermHelper.checkReturn(player, PermissionRegistry.EDITPERMS, PermHelper.genericNoPermMessage(player)); if (claim == null) return 0; @@ -813,11 +813,11 @@ public class CommandClaim { } } String[] unf = feedback.split("%s", 2); - MutableText cmdFeed = new LiteralText(unf[0]).formatted(Formatting.GOLD) + MutableComponent cmdFeed = new TextComponent(unf[0]).withStyle(ChatFormatting.GOLD) .append(text); if (unf.length > 1) - cmdFeed.append(new LiteralText(unf[1])).formatted(Formatting.GOLD); - context.getSource().sendFeedback(cmdFeed, false); + cmdFeed.append(new TextComponent(unf[1])).withStyle(ChatFormatting.GOLD); + context.getSource().sendSuccess(cmdFeed, false); return Command.SINGLE_SUCCESS; } } diff --git a/common/src/main/java/io/github/flemmli97/flan/commands/CommandHelp.java b/common/src/main/java/io/github/flemmli97/flan/commands/CommandHelp.java index 92cd3f8..37c5faa 100644 --- a/common/src/main/java/io/github/flemmli97/flan/commands/CommandHelp.java +++ b/common/src/main/java/io/github/flemmli97/flan/commands/CommandHelp.java @@ -7,11 +7,11 @@ import com.mojang.brigadier.context.CommandContext; import com.mojang.brigadier.tree.CommandNode; import io.github.flemmli97.flan.claim.PermHelper; import io.github.flemmli97.flan.config.ConfigHandler; -import net.minecraft.server.command.ServerCommandSource; -import net.minecraft.text.ClickEvent; -import net.minecraft.text.MutableText; -import net.minecraft.text.Style; -import net.minecraft.util.Formatting; +import net.minecraft.ChatFormatting; +import net.minecraft.commands.CommandSourceStack; +import net.minecraft.network.chat.ClickEvent; +import net.minecraft.network.chat.MutableComponent; +import net.minecraft.network.chat.Style; import java.util.Collection; import java.util.List; @@ -19,64 +19,64 @@ import java.util.stream.Collectors; public class CommandHelp { - public static int helpMessage(CommandContext context, Collection> nodes) { + public static int helpMessage(CommandContext context, Collection> nodes) { int page = IntegerArgumentType.getInteger(context, "page"); return helpMessage(context, page, nodes); } - public static int helpMessage(CommandContext context, int page, Collection> nodes) { + public static int helpMessage(CommandContext context, int page, Collection> nodes) { List subCommands = registeredCommands(context, nodes); subCommands.remove("?"); int max = subCommands.size() / 8; if (page > max) page = max; - context.getSource().sendFeedback(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.helpHeader, page), Formatting.GOLD), false); + context.getSource().sendSuccess(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.helpHeader, page), ChatFormatting.GOLD), false); for (int i = 8 * page; i < 8 * (page + 1); i++) if (i < subCommands.size()) { - MutableText cmdText = PermHelper.simpleColoredText("- " + subCommands.get(i), Formatting.GRAY); - context.getSource().sendFeedback(cmdText.fillStyle(cmdText.getStyle().withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/flan help cmd " + subCommands.get(i)))), false); + MutableComponent cmdText = PermHelper.simpleColoredText("- " + subCommands.get(i), ChatFormatting.GRAY); + context.getSource().sendSuccess(cmdText.withStyle(cmdText.getStyle().withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/flan help cmd " + subCommands.get(i)))), false); } - MutableText pageText = PermHelper.simpleColoredText((page > 0 ? " " : "") + " ", Formatting.DARK_GREEN); + MutableComponent pageText = PermHelper.simpleColoredText((page > 0 ? " " : "") + " ", ChatFormatting.DARK_GREEN); if (page > 0) { - MutableText pageTextBack = PermHelper.simpleColoredText("<<", Formatting.DARK_GREEN); - pageTextBack.fillStyle(pageTextBack.getStyle().withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/flan help " + (page - 1)))); + MutableComponent pageTextBack = PermHelper.simpleColoredText("<<", ChatFormatting.DARK_GREEN); + pageTextBack.withStyle(pageTextBack.getStyle().withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/flan help " + (page - 1)))); pageText = pageTextBack.append(pageText); } if (page < max) { - MutableText pageTextNext = PermHelper.simpleColoredText(">>"); - pageTextNext.fillStyle(Style.EMPTY.withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/flan help " + (page + 1)))); + MutableComponent pageTextNext = PermHelper.simpleColoredText(">>"); + pageTextNext.withStyle(Style.EMPTY.withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/flan help " + (page + 1)))); pageText = pageText.append(pageTextNext); } - context.getSource().sendFeedback(pageText, false); + context.getSource().sendSuccess(pageText, false); return Command.SINGLE_SUCCESS; } - public static int helpCmd(CommandContext context) { + public static int helpCmd(CommandContext context) { String command = StringArgumentType.getString(context, "command"); return helpCmd(context, command); } - public static int helpCmd(CommandContext context, String command) { + public static int helpCmd(CommandContext context, String command) { String[] cmdHelp = ConfigHandler.lang.cmdLang.getCommandHelp(command); - context.getSource().sendFeedback(PermHelper.simpleColoredText(ConfigHandler.lang.helpCmdHeader, Formatting.DARK_GREEN), false); + context.getSource().sendSuccess(PermHelper.simpleColoredText(ConfigHandler.lang.helpCmdHeader, ChatFormatting.DARK_GREEN), false); for (int i = 0; i < cmdHelp.length; i++) { if (i == 0) { - context.getSource().sendFeedback(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.helpCmdSyntax, cmdHelp[i]), Formatting.GOLD), false); - context.getSource().sendFeedback(PermHelper.simpleColoredText(""), false); + context.getSource().sendSuccess(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.helpCmdSyntax, cmdHelp[i]), ChatFormatting.GOLD), false); + context.getSource().sendSuccess(PermHelper.simpleColoredText(""), false); } else { - context.getSource().sendFeedback(PermHelper.simpleColoredText(cmdHelp[i], Formatting.GOLD), false); + context.getSource().sendSuccess(PermHelper.simpleColoredText(cmdHelp[i], ChatFormatting.GOLD), false); } } if (command.equals("help")) { - context.getSource().sendFeedback(PermHelper.simpleColoredText(ConfigHandler.lang.wiki, Formatting.GOLD), false); - MutableText wiki = PermHelper.simpleColoredText("https://github.com/Flemmli97/Flan/wiki", Formatting.GREEN); + context.getSource().sendSuccess(PermHelper.simpleColoredText(ConfigHandler.lang.wiki, ChatFormatting.GOLD), false); + MutableComponent wiki = PermHelper.simpleColoredText("https://github.com/Flemmli97/Flan/wiki", ChatFormatting.GREEN); wiki.setStyle(wiki.getStyle().withClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "https://github.com/Flemmli97/Flan/wiki"))); - context.getSource().sendFeedback(wiki, false); + context.getSource().sendSuccess(wiki, false); } return Command.SINGLE_SUCCESS; } - public static List registeredCommands(CommandContext context, Collection> nodes) { + public static List registeredCommands(CommandContext context, Collection> nodes) { return nodes.stream().filter(node -> node.canUse(context.getSource())).map(CommandNode::getName).collect(Collectors.toList()); } } diff --git a/common/src/main/java/io/github/flemmli97/flan/commands/CommandHelpers.java b/common/src/main/java/io/github/flemmli97/flan/commands/CommandHelpers.java index 2a83f02..6ffbf54 100644 --- a/common/src/main/java/io/github/flemmli97/flan/commands/CommandHelpers.java +++ b/common/src/main/java/io/github/flemmli97/flan/commands/CommandHelpers.java @@ -12,12 +12,12 @@ import io.github.flemmli97.flan.claim.Claim; import io.github.flemmli97.flan.claim.ClaimStorage; import io.github.flemmli97.flan.config.ConfigHandler; import io.github.flemmli97.flan.player.PlayerClaimData; -import net.minecraft.command.CommandSource; -import net.minecraft.command.argument.GameProfileArgumentType; -import net.minecraft.server.command.ServerCommandSource; -import net.minecraft.server.network.ServerPlayerEntity; -import net.minecraft.server.world.ServerWorld; -import net.minecraft.util.math.BlockPos; +import net.minecraft.commands.CommandSourceStack; +import net.minecraft.commands.SharedSuggestionProvider; +import net.minecraft.commands.arguments.GameProfileArgument; +import net.minecraft.core.BlockPos; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.server.level.ServerPlayer; import java.util.ArrayList; import java.util.Collection; @@ -32,21 +32,21 @@ public class CommandHelpers { private static final Pattern allowed = Pattern.compile("[a-zA-Z0-9_+.-]+"); - public static CompletableFuture claimSuggestions(CommandContext context, SuggestionsBuilder build, UUID owner) { - return CommandSource.suggestMatching(ClaimStorage.get(context.getSource().getWorld()).allClaimsFromPlayer(owner) + public static CompletableFuture claimSuggestions(CommandContext context, SuggestionsBuilder build, UUID owner) { + return SharedSuggestionProvider.suggest(ClaimStorage.get(context.getSource().getLevel()).allClaimsFromPlayer(owner) .stream().map(claim -> claim.getClaimName().isEmpty() ? claim.getClaimID().toString() : claim.getClaimName()).collect(Collectors.toList()), build); } - public static GameProfile singleProfile(CommandContext context, String arg) throws CommandSyntaxException { - Collection profs = GameProfileArgumentType.getProfileArgument(context, arg); + public static GameProfile singleProfile(CommandContext context, String arg) throws CommandSyntaxException { + Collection profs = GameProfileArgument.getGameProfiles(context, arg); if (profs.size() != 1) { throw new SimpleCommandExceptionType(() -> ConfigHandler.lang.onlyOnePlayer).create(); } return profs.stream().findFirst().get(); } - public static CompletableFuture permSuggestions(CommandContext context, SuggestionsBuilder build, boolean group) { - ServerWorld world = context.getSource().getWorld(); + public static CompletableFuture permSuggestions(CommandContext context, SuggestionsBuilder build, boolean group) { + ServerLevel world = context.getSource().getLevel(); Claim claim = ClaimStorage.get(world).getClaimAt(new BlockPos(context.getSource().getPosition())); boolean admin = claim != null && claim.isAdminClaim(); List allowedPerms = new ArrayList<>(); @@ -57,15 +57,15 @@ public class CommandHelpers { if (!group || !PermissionRegistry.globalPerms().contains(perm)) allowedPerms.add(perm.id); } - return CommandSource.suggestMatching(allowedPerms, build); + return SharedSuggestionProvider.suggest(allowedPerms, build); } - public static CompletableFuture groupSuggestion(CommandContext context, SuggestionsBuilder build) throws CommandSyntaxException { - ServerPlayerEntity player = context.getSource().getPlayer(); + public static CompletableFuture groupSuggestion(CommandContext context, SuggestionsBuilder build) throws CommandSyntaxException { + ServerPlayer player = context.getSource().getPlayerOrException(); List list = new ArrayList<>(); - ClaimStorage storage = ClaimStorage.get(player.getServerWorld()); - Claim claim = storage.getClaimAt(player.getBlockPos()); - if (claim != null && claim.canInteract(player, PermissionRegistry.EDITPERMS, player.getBlockPos())) { + ClaimStorage storage = ClaimStorage.get(player.getLevel()); + Claim claim = storage.getClaimAt(player.blockPosition()); + if (claim != null && claim.canInteract(player, PermissionRegistry.EDITPERMS, player.blockPosition())) { list = claim.groups(); } for (int i = 0; i < list.size(); i++) { @@ -73,11 +73,11 @@ public class CommandHelpers { continue; list.set(i, '\"' + list.get(i) + '\"'); } - return CommandSource.suggestMatching(list, build); + return SharedSuggestionProvider.suggest(list, build); } - public static CompletableFuture personalGroupSuggestion(CommandContext context, SuggestionsBuilder build) throws CommandSyntaxException { - ServerPlayerEntity player = context.getSource().getPlayer(); + public static CompletableFuture personalGroupSuggestion(CommandContext context, SuggestionsBuilder build) throws CommandSyntaxException { + ServerPlayer player = context.getSource().getPlayerOrException(); List list = new ArrayList<>(PlayerClaimData.get(player).playerDefaultGroups().keySet()); list.sort(null); for (int i = 0; i < list.size(); i++) { @@ -85,7 +85,7 @@ public class CommandHelpers { continue; list.set(i, '\"' + list.get(i) + '\"'); } - return CommandSource.suggestMatching(list, build); + return SharedSuggestionProvider.suggest(list, build); } public static > T parseEnum(Class clss, String name, T fallback) { @@ -97,6 +97,6 @@ public class CommandHelpers { } public static > CompletableFuture enumSuggestion(Class clss, SuggestionsBuilder build) { - return CommandSource.suggestMatching(Stream.of(clss.getEnumConstants()).map(Object::toString), build); + return SharedSuggestionProvider.suggest(Stream.of(clss.getEnumConstants()).map(Object::toString), build); } } diff --git a/common/src/main/java/io/github/flemmli97/flan/config/Config.java b/common/src/main/java/io/github/flemmli97/flan/config/Config.java index 8f8e304..0d5dae4 100644 --- a/common/src/main/java/io/github/flemmli97/flan/config/Config.java +++ b/common/src/main/java/io/github/flemmli97/flan/config/Config.java @@ -7,11 +7,11 @@ import io.github.flemmli97.flan.CrossPlatformStuff; import io.github.flemmli97.flan.Flan; import io.github.flemmli97.flan.api.permission.ClaimPermission; import io.github.flemmli97.flan.api.permission.PermissionRegistry; -import net.minecraft.item.Item; -import net.minecraft.item.Items; +import net.minecraft.resources.ResourceLocation; import net.minecraft.server.MinecraftServer; -import net.minecraft.server.world.ServerWorld; -import net.minecraft.util.Identifier; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.Items; import java.io.File; import java.io.FileReader; @@ -144,9 +144,9 @@ public class Config { this.worldWhitelist = ConfigHandler.fromJson(obj, "worldWhitelist", this.worldWhitelist); if (obj.has("claimingItem")) - this.claimingItem = CrossPlatformStuff.registryItems().getFromId(new Identifier((obj.get("claimingItem").getAsString()))); + this.claimingItem = CrossPlatformStuff.registryItems().getFromId(new ResourceLocation((obj.get("claimingItem").getAsString()))); if (obj.has("inspectionItem")) - this.inspectionItem = CrossPlatformStuff.registryItems().getFromId(new Identifier((obj.get("inspectionItem").getAsString()))); + this.inspectionItem = CrossPlatformStuff.registryItems().getFromId(new ResourceLocation((obj.get("inspectionItem").getAsString()))); this.claimDisplayTime = ConfigHandler.fromJson(obj, "claimDisplayTime", this.claimDisplayTime); this.permissionLevel = ConfigHandler.fromJson(obj, "permissionLevel", this.permissionLevel); @@ -291,26 +291,26 @@ public class Config { } } - public boolean globallyDefined(ServerWorld world, ClaimPermission perm) { + public boolean globallyDefined(ServerLevel world, ClaimPermission perm) { return !this.getGlobal(world, perm).canModify(); } - public GlobalType getGlobal(ServerWorld world, ClaimPermission perm) { + public GlobalType getGlobal(ServerLevel world, ClaimPermission perm) { //Update permission map if not done already Map allMap = ConfigHandler.config.globalDefaultPerms.get("*"); if (allMap != null) { - world.getServer().getWorlds().forEach(w -> { - Map wMap = ConfigHandler.config.globalDefaultPerms.getOrDefault(w.getRegistryKey().getValue().toString(), new HashMap<>()); + world.getServer().getAllLevels().forEach(w -> { + Map wMap = ConfigHandler.config.globalDefaultPerms.getOrDefault(w.dimension().location().toString(), new HashMap<>()); allMap.forEach((key, value) -> { if (!wMap.containsKey(key)) wMap.put(key, value); }); - ConfigHandler.config.globalDefaultPerms.put(w.getRegistryKey().getValue().toString(), wMap); + ConfigHandler.config.globalDefaultPerms.put(w.dimension().location().toString(), wMap); }); ConfigHandler.config.globalDefaultPerms.remove("*"); } - Map permMap = ConfigHandler.config.globalDefaultPerms.get(world.getRegistryKey().getValue().toString()); + Map permMap = ConfigHandler.config.globalDefaultPerms.get(world.dimension().location().toString()); return permMap == null ? GlobalType.NONE : permMap.getOrDefault(perm, GlobalType.NONE); } diff --git a/common/src/main/java/io/github/flemmli97/flan/config/ConfigHandler.java b/common/src/main/java/io/github/flemmli97/flan/config/ConfigHandler.java index a8f6e66..e99a09b 100644 --- a/common/src/main/java/io/github/flemmli97/flan/config/ConfigHandler.java +++ b/common/src/main/java/io/github/flemmli97/flan/config/ConfigHandler.java @@ -4,11 +4,11 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.JsonArray; import com.google.gson.JsonObject; +import net.minecraft.resources.ResourceKey; import net.minecraft.server.MinecraftServer; -import net.minecraft.util.WorldSavePath; -import net.minecraft.util.registry.RegistryKey; -import net.minecraft.world.World; -import net.minecraft.world.dimension.DimensionType; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.dimension.DimensionType; +import net.minecraft.world.level.storage.LevelResource; import java.nio.file.Path; import java.util.HashMap; @@ -20,7 +20,7 @@ public class ConfigHandler { public static Config config; public static LangConfig lang; - private static Map, Path> claimSavePath = new HashMap<>(); + private static Map, Path> claimSavePath = new HashMap<>(); private static Path playerSavePath; public static void serverLoad(MinecraftServer server) { @@ -34,13 +34,13 @@ public class ConfigHandler { lang.load(); } - public static Path getClaimSavePath(MinecraftServer server, RegistryKey reg) { - return claimSavePath.computeIfAbsent(reg, r -> DimensionType.getSaveDirectory(r, server.getSavePath(WorldSavePath.ROOT).toFile()).toPath().resolve("data").resolve("claims")); + public static Path getClaimSavePath(MinecraftServer server, ResourceKey reg) { + return claimSavePath.computeIfAbsent(reg, r -> DimensionType.getStorageFolder(r, server.getWorldPath(LevelResource.ROOT)).resolve("data").resolve("claims")); } public static Path getPlayerSavePath(MinecraftServer server) { if (playerSavePath == null) - playerSavePath = server.getSavePath(WorldSavePath.PLAYERDATA).resolve("claimData"); + playerSavePath = server.getWorldPath(LevelResource.PLAYER_DATA_DIR).resolve("claimData"); return playerSavePath; } diff --git a/common/src/main/java/io/github/flemmli97/flan/event/BlockInteractEvents.java b/common/src/main/java/io/github/flemmli97/flan/event/BlockInteractEvents.java index c39ba1d..3dd6e67 100644 --- a/common/src/main/java/io/github/flemmli97/flan/event/BlockInteractEvents.java +++ b/common/src/main/java/io/github/flemmli97/flan/event/BlockInteractEvents.java @@ -10,49 +10,49 @@ import io.github.flemmli97.flan.config.ConfigHandler; import io.github.flemmli97.flan.gui.LockedLecternScreenHandler; import io.github.flemmli97.flan.player.EnumDisplayType; import io.github.flemmli97.flan.player.PlayerClaimData; -import net.minecraft.block.BlockState; -import net.minecraft.block.DoorBlock; -import net.minecraft.block.LecternBlock; -import net.minecraft.block.entity.BlockEntity; -import net.minecraft.block.entity.LecternBlockEntity; -import net.minecraft.block.enums.DoubleBlockHalf; -import net.minecraft.entity.Entity; -import net.minecraft.entity.ItemEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.entity.projectile.ProjectileEntity; -import net.minecraft.item.ItemStack; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; import net.minecraft.nbt.CompoundTag; -import net.minecraft.network.packet.s2c.play.BlockUpdateS2CPacket; -import net.minecraft.server.network.ServerPlayerEntity; -import net.minecraft.server.world.ServerWorld; -import net.minecraft.util.ActionResult; -import net.minecraft.util.Hand; -import net.minecraft.util.Identifier; -import net.minecraft.util.hit.BlockHitResult; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; -import net.minecraft.world.World; +import net.minecraft.network.protocol.game.ClientboundBlockUpdatePacket; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.entity.projectile.Projectile; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.DoorBlock; +import net.minecraft.world.level.block.LecternBlock; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.block.entity.LecternBlockEntity; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.DoubleBlockHalf; +import net.minecraft.world.phys.BlockHitResult; import java.util.List; public class BlockInteractEvents { - public static ActionResult startBreakBlocks(PlayerEntity player, World world, Hand hand, BlockPos pos, Direction direction) { - return breakBlocks(world, player, pos, world.getBlockState(pos), world.getBlockEntity(pos)) ? ActionResult.PASS : ActionResult.FAIL; + public static InteractionResult startBreakBlocks(Player player, Level world, InteractionHand hand, BlockPos pos, Direction direction) { + return breakBlocks(world, player, pos, world.getBlockState(pos), world.getBlockEntity(pos)) ? InteractionResult.PASS : InteractionResult.FAIL; } - public static boolean breakBlocks(World world, PlayerEntity p, BlockPos pos, BlockState state, BlockEntity tile) { - if (world.isClient || p.isSpectator()) + public static boolean breakBlocks(Level world, Player p, BlockPos pos, BlockState state, BlockEntity tile) { + if (world.isClientSide || p.isSpectator()) return true; - ServerPlayerEntity player = (ServerPlayerEntity) p; - ClaimStorage storage = ClaimStorage.get((ServerWorld) world); + ServerPlayer player = (ServerPlayer) p; + ClaimStorage storage = ClaimStorage.get((ServerLevel) world); IPermissionContainer claim = storage.getForPermissionCheck(pos); if (claim != null) { - Identifier id = CrossPlatformStuff.registryBlocks().getIDFrom(state.getBlock()); + ResourceLocation id = CrossPlatformStuff.registryBlocks().getIDFrom(state.getBlock()); if (contains(id, world.getBlockEntity(pos), ConfigHandler.config.breakBlockBlacklist, ConfigHandler.config.breakBETagBlacklist)) return true; if (!claim.canInteract(player, PermissionRegistry.BREAK, pos, true)) { - PlayerClaimData.get(player).addDisplayClaim(claim, EnumDisplayType.MAIN, player.getBlockPos().getY()); + PlayerClaimData.get(player).addDisplayClaim(claim, EnumDisplayType.MAIN, player.blockPosition().getY()); return false; } } @@ -60,92 +60,92 @@ public class BlockInteractEvents { } //Right click block - public static ActionResult useBlocks(PlayerEntity p, World world, Hand hand, BlockHitResult hitResult) { - if (world.isClient) - return ActionResult.PASS; - ServerPlayerEntity player = (ServerPlayerEntity) p; - ItemStack stack = player.getStackInHand(hand); + public static InteractionResult useBlocks(Player p, Level world, InteractionHand hand, BlockHitResult hitResult) { + if (world.isClientSide) + return InteractionResult.PASS; + ServerPlayer player = (ServerPlayer) p; + ItemStack stack = player.getItemInHand(hand); if (stack.getItem() == ConfigHandler.config.claimingItem) { ItemInteractEvents.claimLandHandling(player, hitResult.getBlockPos()); - return ActionResult.SUCCESS; + return InteractionResult.SUCCESS; } if (stack.getItem() == ConfigHandler.config.inspectionItem) { ItemInteractEvents.inspect(player, hitResult.getBlockPos()); - return ActionResult.SUCCESS; + return InteractionResult.SUCCESS; } - ClaimStorage storage = ClaimStorage.get((ServerWorld) world); + ClaimStorage storage = ClaimStorage.get((ServerLevel) world); IPermissionContainer claim = storage.getForPermissionCheck(hitResult.getBlockPos()); if (claim != null) { BlockState state = world.getBlockState(hitResult.getBlockPos()); - Identifier id = CrossPlatformStuff.registryBlocks().getIDFrom(state.getBlock()); + ResourceLocation id = CrossPlatformStuff.registryBlocks().getIDFrom(state.getBlock()); BlockEntity blockEntity = world.getBlockEntity(hitResult.getBlockPos()); if (contains(id, blockEntity, ConfigHandler.config.interactBlockBlacklist, ConfigHandler.config.interactBETagBlacklist)) - return ActionResult.PASS; + return InteractionResult.PASS; ClaimPermission perm = ObjectToPermissionMap.getFromBlock(state.getBlock()); if (perm == PermissionRegistry.PROJECTILES) perm = PermissionRegistry.OPENCONTAINER; //Pressureplate handled elsewhere if (perm != null && perm != PermissionRegistry.PRESSUREPLATE) { if (claim.canInteract(player, perm, hitResult.getBlockPos(), true)) - return ActionResult.PASS; + return InteractionResult.PASS; if (state.getBlock() instanceof DoorBlock) { - DoubleBlockHalf half = state.get(DoorBlock.HALF); + DoubleBlockHalf half = state.getValue(DoorBlock.HALF); if (half == DoubleBlockHalf.LOWER) { - BlockState other = world.getBlockState(hitResult.getBlockPos().up()); - player.networkHandler.sendPacket(new BlockUpdateS2CPacket(hitResult.getBlockPos().up(), other)); + BlockState other = world.getBlockState(hitResult.getBlockPos().above()); + player.connection.send(new ClientboundBlockUpdatePacket(hitResult.getBlockPos().above(), other)); } else { - BlockState other = world.getBlockState(hitResult.getBlockPos().down()); - player.networkHandler.sendPacket(new BlockUpdateS2CPacket(hitResult.getBlockPos().down(), other)); + BlockState other = world.getBlockState(hitResult.getBlockPos().below()); + player.connection.send(new ClientboundBlockUpdatePacket(hitResult.getBlockPos().below(), other)); } } - PlayerClaimData.get(player).addDisplayClaim(claim, EnumDisplayType.MAIN, player.getBlockPos().getY()); - return ActionResult.FAIL; + PlayerClaimData.get(player).addDisplayClaim(claim, EnumDisplayType.MAIN, player.blockPosition().getY()); + return InteractionResult.FAIL; } if (blockEntity != null) { if (blockEntity instanceof LecternBlockEntity) { if (claim.canInteract(player, PermissionRegistry.LECTERNTAKE, hitResult.getBlockPos(), false)) - return ActionResult.PASS; - if (state.get(LecternBlock.HAS_BOOK)) + return InteractionResult.PASS; + if (state.getValue(LecternBlock.HAS_BOOK)) LockedLecternScreenHandler.create(player, (LecternBlockEntity) blockEntity); - return ActionResult.FAIL; + return InteractionResult.FAIL; } if (!ConfigHandler.config.lenientBlockEntityCheck || CrossPlatformStuff.isInventoryTile(blockEntity)) { if (claim.canInteract(player, PermissionRegistry.OPENCONTAINER, hitResult.getBlockPos(), true)) - return ActionResult.PASS; - PlayerClaimData.get(player).addDisplayClaim(claim, EnumDisplayType.MAIN, player.getBlockPos().getY()); - return ActionResult.FAIL; + return InteractionResult.PASS; + PlayerClaimData.get(player).addDisplayClaim(claim, EnumDisplayType.MAIN, player.blockPosition().getY()); + return InteractionResult.FAIL; } } - return claim.canInteract(player, PermissionRegistry.INTERACTBLOCK, hitResult.getBlockPos(), false) ? ActionResult.PASS : ActionResult.FAIL; + return claim.canInteract(player, PermissionRegistry.INTERACTBLOCK, hitResult.getBlockPos(), false) ? InteractionResult.PASS : InteractionResult.FAIL; } - return ActionResult.PASS; + return InteractionResult.PASS; } - public static boolean contains(Identifier id, BlockEntity blockEntity, List idList, List tagList) { + public static boolean contains(ResourceLocation id, BlockEntity blockEntity, List idList, List tagList) { if (idList.contains(id.getNamespace()) || idList.contains(id.toString())) return true; if (blockEntity != null && !tagList.isEmpty()) { - CompoundTag nbt = blockEntity.toTag(new CompoundTag()); + CompoundTag nbt = blockEntity.saveWithoutMetadata(); return tagList.stream().anyMatch(tag -> CrossPlatformStuff.blockDataContains(nbt, tag)); } return false; } - public static boolean cancelEntityBlockCollision(BlockState state, World world, BlockPos pos, Entity entity) { - if (world.isClient) + public static boolean cancelEntityBlockCollision(BlockState state, Level world, BlockPos pos, Entity entity) { + if (world.isClientSide) return false; - ServerPlayerEntity player = null; - if (entity instanceof ServerPlayerEntity) - player = (ServerPlayerEntity) entity; - else if (entity instanceof ProjectileEntity) { - Entity owner = ((ProjectileEntity) entity).getOwner(); - if (owner instanceof ServerPlayerEntity) - player = (ServerPlayerEntity) owner; + ServerPlayer player = null; + if (entity instanceof ServerPlayer) + player = (ServerPlayer) entity; + else if (entity instanceof Projectile) { + Entity owner = ((Projectile) entity).getOwner(); + if (owner instanceof ServerPlayer) + player = (ServerPlayer) owner; } else if (entity instanceof ItemEntity) { - Entity owner = ((ServerWorld) world).getEntity(((ItemEntity) entity).getThrower()); - if (owner instanceof ServerPlayerEntity) - player = (ServerPlayerEntity) owner; + Entity owner = ((ServerLevel) world).getEntity(((ItemEntity) entity).getThrower()); + if (owner instanceof ServerPlayer) + player = (ServerPlayer) owner; } if (player == null) return false; @@ -154,7 +154,7 @@ public class BlockInteractEvents { return false; if (perm != PermissionRegistry.PRESSUREPLATE && perm != PermissionRegistry.PORTAL) return false; - ClaimStorage storage = ClaimStorage.get((ServerWorld) world); + ClaimStorage storage = ClaimStorage.get((ServerLevel) world); IPermissionContainer claim = storage.getForPermissionCheck(pos); if (claim != null) return !claim.canInteract(player, perm, pos, false); @@ -162,58 +162,58 @@ public class BlockInteractEvents { } public static boolean preventFallOn(Entity entity, double heightDifference, boolean onGround, BlockState landedState, BlockPos landedPosition) { - if (entity.world.isClient) + if (entity.level.isClientSide) return false; - if (entity instanceof ServerPlayerEntity) { + if (entity instanceof ServerPlayer) { ClaimPermission perm = ObjectToPermissionMap.getFromBlock(landedState.getBlock()); if (perm != PermissionRegistry.TRAMPLE) return false; - ClaimStorage storage = ClaimStorage.get((ServerWorld) entity.world); + ClaimStorage storage = ClaimStorage.get((ServerLevel) entity.level); IPermissionContainer claim = storage.getForPermissionCheck(landedPosition); if (claim == null) return false; - return !claim.canInteract((ServerPlayerEntity) entity, perm, landedPosition, true); - } else if (entity instanceof ProjectileEntity) { - Entity owner = ((ProjectileEntity) entity).getOwner(); - if (owner instanceof ServerPlayerEntity) { + return !claim.canInteract((ServerPlayer) entity, perm, landedPosition, true); + } else if (entity instanceof Projectile) { + Entity owner = ((Projectile) entity).getOwner(); + if (owner instanceof ServerPlayer) { ClaimPermission perm = ObjectToPermissionMap.getFromBlock(landedState.getBlock()); if (perm != PermissionRegistry.TRAMPLE) return false; - ClaimStorage storage = ClaimStorage.get((ServerWorld) entity.world); + ClaimStorage storage = ClaimStorage.get((ServerLevel) entity.level); IPermissionContainer claim = storage.getForPermissionCheck(landedPosition); - return !claim.canInteract((ServerPlayerEntity) owner, perm, landedPosition, true); + return !claim.canInteract((ServerPlayer) owner, perm, landedPosition, true); } } return false; } - public static boolean canBreakTurtleEgg(World world, BlockPos pos, Entity entity) { - if (world.isClient) + public static boolean canBreakTurtleEgg(Level world, BlockPos pos, Entity entity) { + if (world.isClientSide) return false; - ServerWorld serverWorld = (ServerWorld) world; - if (entity instanceof ServerPlayerEntity) { + ServerLevel serverWorld = (ServerLevel) world; + if (entity instanceof ServerPlayer) { ClaimStorage storage = ClaimStorage.get(serverWorld); IPermissionContainer claim = storage.getForPermissionCheck(pos); if (claim == null) return false; - return !claim.canInteract((ServerPlayerEntity) entity, PermissionRegistry.TRAMPLE, pos, true); - } else if (entity instanceof ProjectileEntity) { - Entity owner = ((ProjectileEntity) entity).getOwner(); - if (owner instanceof ServerPlayerEntity) { + return !claim.canInteract((ServerPlayer) entity, PermissionRegistry.TRAMPLE, pos, true); + } else if (entity instanceof Projectile) { + Entity owner = ((Projectile) entity).getOwner(); + if (owner instanceof ServerPlayer) { ClaimStorage storage = ClaimStorage.get(serverWorld); IPermissionContainer claim = storage.getForPermissionCheck(pos); if (claim == null) return false; - return !claim.canInteract((ServerPlayerEntity) owner, PermissionRegistry.TRAMPLE, pos, true); + return !claim.canInteract((ServerPlayer) owner, PermissionRegistry.TRAMPLE, pos, true); } } else if (entity instanceof ItemEntity) { Entity owner = serverWorld.getEntity(((ItemEntity) entity).getThrower()); - if (owner instanceof ServerPlayerEntity) { + if (owner instanceof ServerPlayer) { ClaimStorage storage = ClaimStorage.get(serverWorld); IPermissionContainer claim = storage.getForPermissionCheck(pos); if (claim == null) return false; - return !claim.canInteract((ServerPlayerEntity) owner, PermissionRegistry.TRAMPLE, pos, true); + return !claim.canInteract((ServerPlayer) owner, PermissionRegistry.TRAMPLE, pos, true); } } return false; diff --git a/common/src/main/java/io/github/flemmli97/flan/event/EntityInteractEvents.java b/common/src/main/java/io/github/flemmli97/flan/event/EntityInteractEvents.java index 9d0def1..1cc33b2 100644 --- a/common/src/main/java/io/github/flemmli97/flan/event/EntityInteractEvents.java +++ b/common/src/main/java/io/github/flemmli97/flan/event/EntityInteractEvents.java @@ -14,166 +14,166 @@ import io.github.flemmli97.flan.player.IOwnedItem; import io.github.flemmli97.flan.player.PlayerClaimData; import io.github.flemmli97.flan.player.TeleportUtils; import it.unimi.dsi.fastutil.ints.IntOpenHashSet; -import net.minecraft.block.BlockState; -import net.minecraft.entity.Entity; -import net.minecraft.entity.ItemEntity; -import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.boss.WitherEntity; -import net.minecraft.entity.damage.DamageSource; -import net.minecraft.entity.decoration.ArmorStandEntity; -import net.minecraft.entity.decoration.ItemFrameEntity; -import net.minecraft.entity.mob.EndermanEntity; -import net.minecraft.entity.mob.Monster; -import net.minecraft.entity.passive.SnowGolemEntity; -import net.minecraft.entity.passive.TameableEntity; -import net.minecraft.entity.passive.VillagerEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.entity.projectile.PersistentProjectileEntity; -import net.minecraft.entity.projectile.ProjectileEntity; -import net.minecraft.entity.projectile.thrown.EggEntity; -import net.minecraft.entity.projectile.thrown.EnderPearlEntity; -import net.minecraft.entity.projectile.thrown.PotionEntity; -import net.minecraft.entity.vehicle.AbstractMinecartEntity; -import net.minecraft.entity.vehicle.BoatEntity; -import net.minecraft.entity.vehicle.StorageMinecartEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.network.packet.s2c.play.InventoryS2CPacket; -import net.minecraft.network.packet.s2c.play.PlayerAbilitiesS2CPacket; -import net.minecraft.server.network.ServerPlayerEntity; -import net.minecraft.server.world.ServerWorld; -import net.minecraft.sound.SoundEvents; -import net.minecraft.util.ActionResult; -import net.minecraft.util.Hand; -import net.minecraft.util.Identifier; -import net.minecraft.util.collection.DefaultedList; -import net.minecraft.util.hit.BlockHitResult; -import net.minecraft.util.hit.EntityHitResult; -import net.minecraft.util.hit.HitResult; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.Vec3d; -import net.minecraft.world.World; +import net.minecraft.core.BlockPos; +import net.minecraft.core.NonNullList; +import net.minecraft.network.protocol.game.ClientboundContainerSetContentPacket; +import net.minecraft.network.protocol.game.ClientboundPlayerAbilitiesPacket; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.sounds.SoundEvents; +import net.minecraft.util.Mth; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.damagesource.DamageSource; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.TamableAnimal; +import net.minecraft.world.entity.animal.SnowGolem; +import net.minecraft.world.entity.boss.wither.WitherBoss; +import net.minecraft.world.entity.decoration.ArmorStand; +import net.minecraft.world.entity.decoration.ItemFrame; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.entity.monster.EnderMan; +import net.minecraft.world.entity.monster.Enemy; +import net.minecraft.world.entity.npc.Villager; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.entity.projectile.AbstractArrow; +import net.minecraft.world.entity.projectile.Projectile; +import net.minecraft.world.entity.projectile.ThrownEgg; +import net.minecraft.world.entity.projectile.ThrownEnderpearl; +import net.minecraft.world.entity.projectile.ThrownPotion; +import net.minecraft.world.entity.vehicle.AbstractMinecart; +import net.minecraft.world.entity.vehicle.AbstractMinecartContainer; +import net.minecraft.world.entity.vehicle.Boat; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.phys.EntityHitResult; +import net.minecraft.world.phys.HitResult; +import net.minecraft.world.phys.Vec3; import java.util.function.Consumer; public class EntityInteractEvents { - public static ActionResult attackEntity(PlayerEntity player, World world, Hand hand, Entity entity, EntityHitResult hitResult) { + public static InteractionResult attackEntity(Player player, Level world, InteractionHand hand, Entity entity, EntityHitResult hitResult) { return attackSimple(player, entity, true); } - public static ActionResult useAtEntity(PlayerEntity player, World world, Hand hand, Entity entity, /* Nullable */ EntityHitResult hitResult) { - if (player.world.isClient || player.isSpectator() || canInteract(entity)) - return ActionResult.PASS; - ClaimStorage storage = ClaimStorage.get((ServerWorld) world); - BlockPos pos = entity.getBlockPos(); + public static InteractionResult useAtEntity(Player player, Level world, InteractionHand hand, Entity entity, /* Nullable */ EntityHitResult hitResult) { + if (player.level.isClientSide || player.isSpectator() || canInteract(entity)) + return InteractionResult.PASS; + ClaimStorage storage = ClaimStorage.get((ServerLevel) world); + BlockPos pos = entity.blockPosition(); IPermissionContainer claim = storage.getForPermissionCheck(pos); if (claim != null) { - if (entity instanceof ArmorStandEntity) { - if (!claim.canInteract((ServerPlayerEntity) player, PermissionRegistry.ARMORSTAND, pos, true)) - return ActionResult.FAIL; + if (entity instanceof ArmorStand) { + if (!claim.canInteract((ServerPlayer) player, PermissionRegistry.ARMORSTAND, pos, true)) + return InteractionResult.FAIL; } } - return ActionResult.PASS; + return InteractionResult.PASS; } - public static ActionResult useEntity(PlayerEntity p, World world, Hand hand, Entity entity) { - if (p.world.isClient || p.isSpectator() || canInteract(entity)) - return ActionResult.PASS; - ServerPlayerEntity player = (ServerPlayerEntity) p; - ClaimStorage storage = ClaimStorage.get((ServerWorld) world); - BlockPos pos = entity.getBlockPos(); + public static InteractionResult useEntity(Player p, Level world, InteractionHand hand, Entity entity) { + if (p.level.isClientSide || p.isSpectator() || canInteract(entity)) + return InteractionResult.PASS; + ServerPlayer player = (ServerPlayer) p; + ClaimStorage storage = ClaimStorage.get((ServerLevel) world); + BlockPos pos = entity.blockPosition(); IPermissionContainer claim = storage.getForPermissionCheck(pos); if (claim != null) { - if (entity instanceof BoatEntity) - return claim.canInteract(player, PermissionRegistry.BOAT, pos, true) ? ActionResult.PASS : ActionResult.FAIL; - if (entity instanceof AbstractMinecartEntity) { - if (entity instanceof StorageMinecartEntity) - return claim.canInteract(player, PermissionRegistry.OPENCONTAINER, pos, true) ? ActionResult.PASS : ActionResult.FAIL; - return claim.canInteract(player, PermissionRegistry.MINECART, pos, true) ? ActionResult.PASS : ActionResult.FAIL; + if (entity instanceof Boat) + return claim.canInteract(player, PermissionRegistry.BOAT, pos, true) ? InteractionResult.PASS : InteractionResult.FAIL; + if (entity instanceof AbstractMinecart) { + if (entity instanceof AbstractMinecartContainer) + return claim.canInteract(player, PermissionRegistry.OPENCONTAINER, pos, true) ? InteractionResult.PASS : InteractionResult.FAIL; + return claim.canInteract(player, PermissionRegistry.MINECART, pos, true) ? InteractionResult.PASS : InteractionResult.FAIL; } - if (entity instanceof VillagerEntity) - return claim.canInteract(player, PermissionRegistry.TRADING, pos, true) ? ActionResult.PASS : ActionResult.FAIL; - if (entity instanceof ItemFrameEntity) - return claim.canInteract(player, PermissionRegistry.ITEMFRAMEROTATE, pos, true) ? ActionResult.PASS : ActionResult.FAIL; - if (entity instanceof TameableEntity) { - TameableEntity tame = (TameableEntity) entity; - if (tame.isOwner(player)) - return ActionResult.PASS; + if (entity instanceof Villager) + return claim.canInteract(player, PermissionRegistry.TRADING, pos, true) ? InteractionResult.PASS : InteractionResult.FAIL; + if (entity instanceof ItemFrame) + return claim.canInteract(player, PermissionRegistry.ITEMFRAMEROTATE, pos, true) ? InteractionResult.PASS : InteractionResult.FAIL; + if (entity instanceof TamableAnimal) { + TamableAnimal tame = (TamableAnimal) entity; + if (tame.isOwnedBy(player)) + return InteractionResult.PASS; } - return claim.canInteract(player, PermissionRegistry.ANIMALINTERACT, pos, true) ? ActionResult.PASS : ActionResult.FAIL; + return claim.canInteract(player, PermissionRegistry.ANIMALINTERACT, pos, true) ? InteractionResult.PASS : InteractionResult.FAIL; } - return ActionResult.PASS; + return InteractionResult.PASS; } public static boolean canInteract(Entity entity) { - Identifier id = CrossPlatformStuff.registryEntities().getIDFrom(entity.getType()); + ResourceLocation id = CrossPlatformStuff.registryEntities().getIDFrom(entity.getType()); return ConfigHandler.config.ignoredEntityTypes.contains(id.getNamespace()) || ConfigHandler.config.ignoredEntityTypes.contains(id.toString()) - || entity.getScoreboardTags().stream().anyMatch(ConfigHandler.config.entityTagIgnore::contains); + || entity.getTags().stream().anyMatch(ConfigHandler.config.entityTagIgnore::contains); } - public static boolean projectileHit(ProjectileEntity proj, HitResult res) { - if (proj.world.isClient) + public static boolean projectileHit(Projectile proj, HitResult res) { + if (proj.level.isClientSide) return false; Entity owner = proj.getOwner(); - if (owner instanceof ServerPlayerEntity) { - ServerPlayerEntity player = (ServerPlayerEntity) owner; + if (owner instanceof ServerPlayer) { + ServerPlayer player = (ServerPlayer) owner; if (res.getType() == HitResult.Type.BLOCK) { BlockHitResult blockRes = (BlockHitResult) res; BlockPos pos = blockRes.getBlockPos(); - BlockState state = proj.world.getBlockState(pos); + BlockState state = proj.level.getBlockState(pos); ClaimPermission perm; - if (proj instanceof EnderPearlEntity) + if (proj instanceof ThrownEnderpearl) perm = PermissionRegistry.ENDERPEARL; - else if (proj instanceof EggEntity || proj instanceof PotionEntity) + else if (proj instanceof ThrownEgg || proj instanceof ThrownPotion) perm = PermissionRegistry.PROJECTILES; else perm = ObjectToPermissionMap.getFromBlock(state.getBlock()); if (perm != PermissionRegistry.ENDERPEARL && perm != PermissionRegistry.TARGETBLOCK && perm != PermissionRegistry.PROJECTILES) return false; - ClaimStorage storage = ClaimStorage.get((ServerWorld) proj.world); + ClaimStorage storage = ClaimStorage.get((ServerLevel) proj.level); IPermissionContainer claim = storage.getForPermissionCheck(pos); if (claim == null) return false; boolean flag = !claim.canInteract(player, perm, pos, true); if (flag) { - if (proj instanceof PersistentProjectileEntity) { - PersistentProjectileEntity pers = (PersistentProjectileEntity) proj; - ((IPersistentProjectileVars) pers).setInBlockState(pers.world.getBlockState(pos)); - Vec3d vec3d = blockRes.getPos().subtract(pers.getX(), pers.getY(), pers.getZ()); - pers.setVelocity(vec3d); - Vec3d vec3d2 = vec3d.normalize().multiply(0.05000000074505806D); - pers.setPos(pers.getX() - vec3d2.x, pers.getY() - vec3d2.y, pers.getZ() - vec3d2.z); - pers.playSound(((IPersistentProjectileVars) pers).getSoundEvent(), 1.0F, 1.2F / (pers.world.random.nextFloat() * 0.2F + 0.9F)); + if (proj instanceof AbstractArrow) { + AbstractArrow pers = (AbstractArrow) proj; + ((IPersistentProjectileVars) pers).setInBlockState(pers.level.getBlockState(pos)); + Vec3 vec3d = blockRes.getLocation().subtract(pers.getX(), pers.getY(), pers.getZ()); + pers.setDeltaMovement(vec3d); + Vec3 vec3d2 = vec3d.normalize().scale(0.05000000074505806D); + pers.setPosRaw(pers.getX() - vec3d2.x, pers.getY() - vec3d2.y, pers.getZ() - vec3d2.z); + pers.playSound(((IPersistentProjectileVars) pers).getSoundEvent(), 1.0F, 1.2F / (pers.level.random.nextFloat() * 0.2F + 0.9F)); ((IPersistentProjectileVars) pers).setInGround(true); - pers.shake = 7; - pers.setCritical(false); + pers.shakeTime = 7; + pers.setCritArrow(false); pers.setPierceLevel((byte) 0); - pers.setSound(SoundEvents.ENTITY_ARROW_HIT); + pers.setSoundEvent(SoundEvents.ARROW_HIT); pers.setShotFromCrossbow(false); ((IPersistentProjectileVars) pers).resetPiercingStatus(); } - if (proj instanceof EnderPearlEntity) - proj.remove(); + if (proj instanceof ThrownEnderpearl) + proj.remove(Entity.RemovalReason.KILLED); //TODO: find a way to properly update chorus fruit break on hit //player.getServer().send(new ServerTask(player.getServer().getTicks()+2, ()->player.world.updateListeners(pos, state, state, 2))); } return flag; } else if (res.getType() == HitResult.Type.ENTITY) { - if (proj instanceof EnderPearlEntity) { - ClaimStorage storage = ClaimStorage.get((ServerWorld) proj.world); - IPermissionContainer claim = storage.getForPermissionCheck(proj.getBlockPos()); - return claim.canInteract(player, PermissionRegistry.ENDERPEARL, proj.getBlockPos(), true); + if (proj instanceof ThrownEnderpearl) { + ClaimStorage storage = ClaimStorage.get((ServerLevel) proj.level); + IPermissionContainer claim = storage.getForPermissionCheck(proj.blockPosition()); + return claim.canInteract(player, PermissionRegistry.ENDERPEARL, proj.blockPosition(), true); } Entity hit = ((EntityHitResult) res).getEntity(); - boolean fail = attackSimple(player, hit, true) != ActionResult.PASS; - if (fail && proj instanceof PersistentProjectileEntity && ((PersistentProjectileEntity) proj).getPierceLevel() > 0) { - PersistentProjectileEntity pers = (PersistentProjectileEntity) proj; + boolean fail = attackSimple(player, hit, true) != InteractionResult.PASS; + if (fail && proj instanceof AbstractArrow && ((AbstractArrow) proj).getPierceLevel() > 0) { + AbstractArrow pers = (AbstractArrow) proj; IntOpenHashSet pierced = ((IPersistentProjectileVars) pers).getPiercedEntities(); if (pierced == null) pierced = new IntOpenHashSet(5); - pierced.add(hit.getEntityId()); + pierced.add(hit.getId()); ((IPersistentProjectileVars) pers).setPiercedEntities(pierced); pers.setPierceLevel((byte) (pers.getPierceLevel() + 1)); } @@ -184,60 +184,60 @@ public class EntityInteractEvents { } public static boolean preventDamage(Entity entity, DamageSource source) { - if (source.getAttacker() instanceof ServerPlayerEntity) - return attackSimple((ServerPlayerEntity) source.getAttacker(), entity, true) != ActionResult.PASS; - else if (source.isExplosive() && !entity.world.isClient) { - IPermissionContainer claim = ClaimStorage.get((ServerWorld) entity.world).getForPermissionCheck(entity.getBlockPos()); - return claim != null && !claim.canInteract(null, PermissionRegistry.EXPLOSIONS, entity.getBlockPos()); + if (source.getEntity() instanceof ServerPlayer) + return attackSimple((ServerPlayer) source.getEntity(), entity, true) != InteractionResult.PASS; + else if (source.isExplosion() && !entity.level.isClientSide) { + IPermissionContainer claim = ClaimStorage.get((ServerLevel) entity.level).getForPermissionCheck(entity.blockPosition()); + return claim != null && !claim.canInteract(null, PermissionRegistry.EXPLOSIONS, entity.blockPosition()); } return false; } - public static ActionResult attackSimple(PlayerEntity p, Entity entity, boolean message) { - if (p.world.isClient || p.isSpectator() || canInteract(entity)) - return ActionResult.PASS; - if (entity instanceof Monster) - return ActionResult.PASS; - ServerPlayerEntity player = (ServerPlayerEntity) p; - ClaimStorage storage = ClaimStorage.get(player.getServerWorld()); - BlockPos pos = entity.getBlockPos(); + public static InteractionResult attackSimple(Player p, Entity entity, boolean message) { + if (p.level.isClientSide || p.isSpectator() || canInteract(entity)) + return InteractionResult.PASS; + if (entity instanceof Enemy) + return InteractionResult.PASS; + ServerPlayer player = (ServerPlayer) p; + ClaimStorage storage = ClaimStorage.get(player.getLevel()); + BlockPos pos = entity.blockPosition(); IPermissionContainer claim = storage.getForPermissionCheck(pos); if (claim != null) { if (!(entity instanceof LivingEntity)) - return claim.canInteract(player, PermissionRegistry.BREAKNONLIVING, pos, message) ? ActionResult.PASS : ActionResult.FAIL; - if (entity instanceof PlayerEntity) - return claim.canInteract(player, PermissionRegistry.HURTPLAYER, pos, message) ? ActionResult.PASS : ActionResult.FAIL; - return claim.canInteract(player, PermissionRegistry.HURTANIMAL, pos, message) ? ActionResult.PASS : ActionResult.FAIL; + return claim.canInteract(player, PermissionRegistry.BREAKNONLIVING, pos, message) ? InteractionResult.PASS : InteractionResult.FAIL; + if (entity instanceof Player) + return claim.canInteract(player, PermissionRegistry.HURTPLAYER, pos, message) ? InteractionResult.PASS : InteractionResult.FAIL; + return claim.canInteract(player, PermissionRegistry.HURTANIMAL, pos, message) ? InteractionResult.PASS : InteractionResult.FAIL; } - return ActionResult.PASS; + return InteractionResult.PASS; } - public static boolean xpAbsorb(PlayerEntity player) { - if (player instanceof ServerPlayerEntity) { - ClaimStorage storage = ClaimStorage.get((ServerWorld) player.world); - BlockPos pos = player.getBlockPos(); + public static boolean xpAbsorb(Player player) { + if (player instanceof ServerPlayer) { + ClaimStorage storage = ClaimStorage.get((ServerLevel) player.level); + BlockPos pos = player.blockPosition(); IPermissionContainer claim = storage.getForPermissionCheck(pos); if (claim != null) - return !claim.canInteract((ServerPlayerEntity) player, PermissionRegistry.XP, pos, false); + return !claim.canInteract((ServerPlayer) player, PermissionRegistry.XP, pos, false); } return false; } - public static boolean canCollideWith(PlayerEntity player, Entity entity) { - if (player instanceof ServerPlayerEntity) { - ServerPlayerEntity sPlayer = (ServerPlayerEntity) player; + public static boolean canCollideWith(Player player, Entity entity) { + if (player instanceof ServerPlayer) { + ServerPlayer sPlayer = (ServerPlayer) player; if (entity instanceof ItemEntity) { IOwnedItem ownedItem = (IOwnedItem) entity; if (ownedItem.getDeathPlayer() != null) { - ServerPlayerEntity other = sPlayer.getServer().getPlayerManager().getPlayer(ownedItem.getDeathPlayer()); + ServerPlayer other = sPlayer.getServer().getPlayerList().getPlayer(ownedItem.getDeathPlayer()); if (other == null) return false; - return ownedItem.getDeathPlayer().equals(player.getUuid()) || PlayerClaimData.get(other).deathItemsUnlocked(); + return ownedItem.getDeathPlayer().equals(player.getUUID()) || PlayerClaimData.get(other).deathItemsUnlocked(); } - if (sPlayer.getUuid().equals(ownedItem.getPlayerOrigin())) + if (sPlayer.getUUID().equals(ownedItem.getPlayerOrigin())) return true; - ClaimStorage storage = ClaimStorage.get(sPlayer.getServerWorld()); - BlockPos pos = sPlayer.getBlockPos(); + ClaimStorage storage = ClaimStorage.get(sPlayer.getLevel()); + BlockPos pos = sPlayer.blockPosition(); IPermissionContainer claim = storage.getForPermissionCheck(pos); if (claim != null) return claim.canInteract(sPlayer, PermissionRegistry.PICKUP, pos, false); @@ -246,36 +246,36 @@ public class EntityInteractEvents { return true; } - public static boolean canDropItem(PlayerEntity player, ItemStack stack) { - if (!player.isDead() && player instanceof ServerPlayerEntity) { - ClaimStorage storage = ClaimStorage.get((ServerWorld) player.world); - BlockPos pos = player.getBlockPos(); + public static boolean canDropItem(Player player, ItemStack stack) { + if (!player.isDeadOrDying() && player instanceof ServerPlayer) { + ClaimStorage storage = ClaimStorage.get((ServerLevel) player.level); + BlockPos pos = player.blockPosition(); IPermissionContainer claim = storage.getForPermissionCheck(pos); boolean allow = true; if (claim != null) - allow = claim.canInteract((ServerPlayerEntity) player, PermissionRegistry.DROP, pos, false); + allow = claim.canInteract((ServerPlayer) player, PermissionRegistry.DROP, pos, false); if (!allow) { - player.inventory.insertStack(stack); - DefaultedList stacks = DefaultedList.of(); - for (int j = 0; j < player.currentScreenHandler.slots.size(); ++j) { - ItemStack itemStack2 = player.currentScreenHandler.slots.get(j).getStack(); + player.getInventory().add(stack); + NonNullList stacks = NonNullList.create(); + for (int j = 0; j < player.containerMenu.slots.size(); ++j) { + ItemStack itemStack2 = player.containerMenu.slots.get(j).getItem(); stacks.add(itemStack2.isEmpty() ? ItemStack.EMPTY : itemStack2); } - ((ServerPlayerEntity) player).networkHandler.sendPacket(new InventoryS2CPacket(player.currentScreenHandler.syncId, stacks)); + ((ServerPlayer) player).connection.send(new ClientboundContainerSetContentPacket(player.containerMenu.containerId, 0, stacks, player.inventoryMenu.getCarried())); } return allow; } return true; } - public static boolean witherCanDestroy(WitherEntity wither) { - if (wither.world.isClient) + public static boolean witherCanDestroy(WitherBoss wither) { + if (wither.level.isClientSide) return true; - ClaimStorage storage = ClaimStorage.get((ServerWorld) wither.world); - BlockPos.Mutable pos = new BlockPos.Mutable(); + ClaimStorage storage = ClaimStorage.get((ServerLevel) wither.level); + BlockPos.MutableBlockPos pos = new BlockPos.MutableBlockPos(); for (int x = -1; x <= 1; x++) for (int z = -1; z <= 1; z++) { - pos.set(wither.getBlockPos(), x, 3, z); + pos.setWithOffset(wither.blockPosition(), x, 3, z); IPermissionContainer claim = storage.getForPermissionCheck(pos); if (!claim.canInteract(null, PermissionRegistry.WITHER, pos, false)) return false; @@ -283,38 +283,38 @@ public class EntityInteractEvents { return true; } - public static boolean canEndermanInteract(EndermanEntity enderman, BlockPos pos) { - if (enderman.world.isClient) + public static boolean canEndermanInteract(EnderMan enderman, BlockPos pos) { + if (enderman.level.isClientSide) return true; - ClaimStorage storage = ClaimStorage.get((ServerWorld) enderman.world); + ClaimStorage storage = ClaimStorage.get((ServerLevel) enderman.level); IPermissionContainer claim = storage.getForPermissionCheck(pos); return claim.canInteract(null, PermissionRegistry.ENDERMAN, pos, false); } - public static boolean canSnowGolemInteract(SnowGolemEntity snowgolem) { - if (snowgolem.world.isClient) + public static boolean canSnowGolemInteract(SnowGolem snowgolem) { + if (snowgolem.level.isClientSide) return true; int x, y, z; for (int l = 0; l < 4; ++l) { - x = MathHelper.floor(snowgolem.getX() + (l % 2 * 2 - 1) * 0.25F); - y = MathHelper.floor(snowgolem.getY()); - z = MathHelper.floor(snowgolem.getZ() + (l / 2 % 2 * 2 - 1) * 0.25F); + x = Mth.floor(snowgolem.getX() + (l % 2 * 2 - 1) * 0.25F); + y = Mth.floor(snowgolem.getY()); + z = Mth.floor(snowgolem.getZ() + (l / 2 % 2 * 2 - 1) * 0.25F); BlockPos pos = new BlockPos(x, y, z); - IPermissionContainer claim = ClaimStorage.get((ServerWorld) snowgolem.world).getForPermissionCheck(pos); + IPermissionContainer claim = ClaimStorage.get((ServerLevel) snowgolem.level).getForPermissionCheck(pos); if (!claim.canInteract(null, PermissionRegistry.SNOWGOLEM, pos, false)) return false; } return true; } - public static void updateDroppedItem(PlayerEntity player, ItemEntity entity) { + public static void updateDroppedItem(Player player, ItemEntity entity) { ((IOwnedItem) entity).setOriginPlayer((player)); } - public static void updateClaim(ServerPlayerEntity player, Claim currentClaim, Consumer cons) { - Vec3d pos = player.getPos(); - BlockPos rounded = TeleportUtils.roundedBlockPos(pos.add(0, player.getActiveEyeHeight(player.getPose(), player.getDimensions(player.getPose())), 0)); - ClaimStorage storage = ClaimStorage.get(player.getServerWorld()); + public static void updateClaim(ServerPlayer player, Claim currentClaim, Consumer cons) { + Vec3 pos = player.position(); + BlockPos rounded = TeleportUtils.roundedBlockPos(pos.add(0, player.getStandingEyeHeight(player.getPose(), player.getDimensions(player.getPose())), 0)); + ClaimStorage storage = ClaimStorage.get(player.getLevel()); if (currentClaim != null) { if (!currentClaim.intersects(player.getBoundingBox())) { Claim claim = storage.getClaimAt(rounded); @@ -325,22 +325,22 @@ public class EntityInteractEvents { claim.displayEnterTitle(player); } else { if (!player.isSpectator()) { - BlockPos.Mutable bPos = rounded.mutableCopy(); + BlockPos.MutableBlockPos bPos = rounded.mutable(); if (!currentClaim.canInteract(player, PermissionRegistry.CANSTAY, bPos, true)) { - Vec3d tp = TeleportUtils.getTeleportPos(player, pos, storage, currentClaim.getDimensions(), bPos, (claim, nPos) -> claim.canInteract(player, PermissionRegistry.CANSTAY, nPos, false)); - player.teleport(tp.getX(), tp.getY(), tp.getZ()); + Vec3 tp = TeleportUtils.getTeleportPos(player, pos, storage, currentClaim.getDimensions(), bPos, (claim, nPos) -> claim.canInteract(player, PermissionRegistry.CANSTAY, nPos, false)); + player.teleportToWithTicket(tp.x(), tp.y(), tp.z()); } - if (player.abilities.flying && !player.isCreative() && !currentClaim.canInteract(player, PermissionRegistry.FLIGHT, rounded, true)) { - player.abilities.flying = false; - player.networkHandler.sendPacket(new PlayerAbilitiesS2CPacket(player.abilities)); + if (player.getAbilities().flying && !player.isCreative() && !currentClaim.canInteract(player, PermissionRegistry.FLIGHT, rounded, true)) { + player.getAbilities().flying = false; + player.connection.send(new ClientboundPlayerAbilitiesPacket(player.getAbilities())); } - if (player.getHungerManager().getSaturationLevel() < 2 && currentClaim.canInteract(player, PermissionRegistry.NOHUNGER, bPos, false)) { - ((IHungerAccessor) player.getHungerManager()).setSaturation(2); + if (player.getFoodData().getSaturationLevel() < 2 && currentClaim.canInteract(player, PermissionRegistry.NOHUNGER, bPos, false)) { + ((IHungerAccessor) player.getFoodData()).setSaturation(2); } currentClaim.applyEffects(player); } } - } else if (player.age % 3 == 0) { + } else if (player.tickCount % 3 == 0) { Claim claim = storage.getClaimAt(rounded); cons.accept(claim); if (claim != null) @@ -348,19 +348,19 @@ public class EntityInteractEvents { } } - public static boolean canFrostwalkerFreeze(ServerWorld world, BlockPos pos, LivingEntity entity) { - if (entity instanceof ServerPlayerEntity) { + public static boolean canFrostwalkerFreeze(ServerLevel world, BlockPos pos, LivingEntity entity) { + if (entity instanceof ServerPlayer) { IPermissionContainer claim = ClaimStorage.get(world).getForPermissionCheck(pos); - return claim.canInteract((ServerPlayerEntity) entity, PermissionRegistry.FROSTWALKER, pos, false); + return claim.canInteract((ServerPlayer) entity, PermissionRegistry.FROSTWALKER, pos, false); } return true; } public static boolean preventLightningConvert(Entity entity) { - if (entity.world.isClient || entity instanceof Monster) + if (entity.level.isClientSide || entity instanceof Enemy) return false; - ClaimStorage storage = ClaimStorage.get((ServerWorld) entity.world); - IPermissionContainer claim = storage.getForPermissionCheck(entity.getBlockPos()); - return !claim.canInteract(null, PermissionRegistry.LIGHTNING, entity.getBlockPos(), false); + ClaimStorage storage = ClaimStorage.get((ServerLevel) entity.level); + IPermissionContainer claim = storage.getForPermissionCheck(entity.blockPosition()); + return !claim.canInteract(null, PermissionRegistry.LIGHTNING, entity.blockPosition(), false); } } diff --git a/common/src/main/java/io/github/flemmli97/flan/event/ItemInteractEvents.java b/common/src/main/java/io/github/flemmli97/flan/event/ItemInteractEvents.java index b3f867a..ebcbbf9 100644 --- a/common/src/main/java/io/github/flemmli97/flan/event/ItemInteractEvents.java +++ b/common/src/main/java/io/github/flemmli97/flan/event/ItemInteractEvents.java @@ -15,157 +15,157 @@ import io.github.flemmli97.flan.mixin.IItemAccessor; import io.github.flemmli97.flan.player.EnumDisplayType; import io.github.flemmli97.flan.player.EnumEditMode; import io.github.flemmli97.flan.player.PlayerClaimData; -import net.minecraft.block.BlockState; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.BlockItem; -import net.minecraft.item.Item; -import net.minecraft.item.ItemPlacementContext; -import net.minecraft.item.ItemStack; -import net.minecraft.item.ItemUsageContext; -import net.minecraft.item.Items; -import net.minecraft.network.packet.s2c.play.BlockUpdateS2CPacket; -import net.minecraft.network.packet.s2c.play.ScreenHandlerSlotUpdateS2CPacket; -import net.minecraft.server.network.ServerPlayerEntity; -import net.minecraft.server.world.ServerWorld; -import net.minecraft.text.Text; -import net.minecraft.util.ActionResult; -import net.minecraft.util.Formatting; -import net.minecraft.util.Hand; -import net.minecraft.util.TypedActionResult; -import net.minecraft.util.hit.BlockHitResult; -import net.minecraft.util.hit.HitResult; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.RaycastContext; -import net.minecraft.world.World; +import net.minecraft.ChatFormatting; +import net.minecraft.core.BlockPos; +import net.minecraft.network.chat.Component; +import net.minecraft.network.protocol.game.ClientboundBlockUpdatePacket; +import net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.InteractionResultHolder; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.BlockItem; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraft.world.item.context.BlockPlaceContext; +import net.minecraft.world.item.context.UseOnContext; +import net.minecraft.world.level.ClipContext; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.phys.HitResult; import java.util.Set; public class ItemInteractEvents { - public static TypedActionResult useItem(PlayerEntity p, World world, Hand hand) { - if (world.isClient || p.isSpectator()) - return TypedActionResult.pass(p.getStackInHand(hand)); - ServerPlayerEntity player = (ServerPlayerEntity) p; - ItemStack stack = player.getStackInHand(hand); + public static InteractionResultHolder useItem(Player p, Level world, InteractionHand hand) { + if (world.isClientSide || p.isSpectator()) + return InteractionResultHolder.pass(p.getItemInHand(hand)); + ServerPlayer player = (ServerPlayer) p; + ItemStack stack = player.getItemInHand(hand); if (stack.getItem() == ConfigHandler.config.claimingItem) { - HitResult ray = player.raycast(64, 0, false); + HitResult ray = player.pick(64, 0, false); if (ray != null && ray.getType() == HitResult.Type.BLOCK) { claimLandHandling(player, ((BlockHitResult) ray).getBlockPos()); - return TypedActionResult.success(stack); + return InteractionResultHolder.success(stack); } - return TypedActionResult.pass(stack); + return InteractionResultHolder.pass(stack); } if (stack.getItem() == ConfigHandler.config.inspectionItem) { - HitResult ray = player.raycast(32, 0, false); + HitResult ray = player.pick(32, 0, false); if (ray != null && ray.getType() == HitResult.Type.BLOCK) { inspect(player, ((BlockHitResult) ray).getBlockPos()); - return TypedActionResult.success(stack); + return InteractionResultHolder.success(stack); } - return TypedActionResult.pass(stack); + return InteractionResultHolder.pass(stack); } - ClaimStorage storage = ClaimStorage.get((ServerWorld) world); - BlockPos pos = player.getBlockPos(); - BlockHitResult hitResult = IItemAccessor.getRaycast(world, player, RaycastContext.FluidHandling.SOURCE_ONLY); + ClaimStorage storage = ClaimStorage.get((ServerLevel) world); + BlockPos pos = player.blockPosition(); + BlockHitResult hitResult = IItemAccessor.getRaycast(world, player, ClipContext.Fluid.SOURCE_ONLY); if (hitResult.getType() == HitResult.Type.BLOCK) { - pos = new ItemPlacementContext(player, hand, stack, hitResult).getBlockPos(); + pos = new BlockPlaceContext(player, hand, stack, hitResult).getClickedPos(); } IPermissionContainer claim = storage.getForPermissionCheck(pos); if (claim == null) - return TypedActionResult.pass(stack); + return InteractionResultHolder.pass(stack); ClaimPermission perm = ObjectToPermissionMap.getFromItem(stack.getItem()); if (perm != null) { boolean success = claim.canInteract(player, perm, pos, true); if (success) - return TypedActionResult.pass(stack); + return InteractionResultHolder.pass(stack); if (perm == PermissionRegistry.PLACE) { BlockPos update = pos; if (stack.getItem() == Items.LILY_PAD) { - BlockHitResult upResult = hitResult.withBlockPos(hitResult.getBlockPos().up()); - update = new ItemPlacementContext(new ItemUsageContext(player, hand, upResult)).getBlockPos(); + BlockHitResult upResult = hitResult.withPosition(hitResult.getBlockPos().above()); + update = new BlockPlaceContext(new UseOnContext(player, hand, upResult)).getClickedPos(); } - player.networkHandler.sendPacket(new BlockUpdateS2CPacket(update, world.getBlockState(update))); - PlayerClaimData.get(player).addDisplayClaim(claim, EnumDisplayType.MAIN, player.getBlockPos().getY()); + player.connection.send(new ClientboundBlockUpdatePacket(update, world.getBlockState(update))); + PlayerClaimData.get(player).addDisplayClaim(claim, EnumDisplayType.MAIN, player.blockPosition().getY()); updateHeldItem(player); } - return TypedActionResult.fail(stack); + return InteractionResultHolder.fail(stack); } - return TypedActionResult.pass(stack); + return InteractionResultHolder.pass(stack); } private static final Set blackListedItems = Sets.newHashSet(Items.COMPASS, Items.FILLED_MAP, Items.FIREWORK_ROCKET); - public static ActionResult onItemUseBlock(ItemUsageContext context) { + public static InteractionResult onItemUseBlock(UseOnContext context) { //Check for Fakeplayer. Since there is no api for that directly check the class - if (!(context.getPlayer() instanceof ServerPlayerEntity) || !context.getPlayer().getClass().equals(ServerPlayerEntity.class) || context.getStack().isEmpty()) - return ActionResult.PASS; - ClaimStorage storage = ClaimStorage.get((ServerWorld) context.getWorld()); - BlockPos placePos = new ItemPlacementContext(context).getBlockPos(); - IPermissionContainer claim = storage.getForPermissionCheck(placePos.add(0, 255, 0)); + if (!(context.getPlayer() instanceof ServerPlayer) || !context.getPlayer().getClass().equals(ServerPlayer.class) || context.getItemInHand().isEmpty()) + return InteractionResult.PASS; + ClaimStorage storage = ClaimStorage.get((ServerLevel) context.getLevel()); + BlockPos placePos = new BlockPlaceContext(context).getClickedPos(); + IPermissionContainer claim = storage.getForPermissionCheck(placePos.offset(0, 255, 0)); if (claim == null) - return ActionResult.PASS; - if (blackListedItems.contains(context.getStack().getItem())) - return ActionResult.PASS; + return InteractionResult.PASS; + if (blackListedItems.contains(context.getItemInHand().getItem())) + return InteractionResult.PASS; boolean actualInClaim = !(claim instanceof Claim) || placePos.getY() >= ((Claim) claim).getDimensions()[4]; - ServerPlayerEntity player = (ServerPlayerEntity) context.getPlayer(); - ClaimPermission perm = ObjectToPermissionMap.getFromItem(context.getStack().getItem()); + ServerPlayer player = (ServerPlayer) context.getPlayer(); + ClaimPermission perm = ObjectToPermissionMap.getFromItem(context.getItemInHand().getItem()); if (perm != null) { if (claim.canInteract(player, perm, placePos, false)) - return ActionResult.PASS; + return InteractionResult.PASS; else if (actualInClaim) { - player.sendMessage(PermHelper.simpleColoredText(ConfigHandler.lang.noPermissionSimple, Formatting.DARK_RED), true); - return ActionResult.FAIL; + player.displayClientMessage(PermHelper.simpleColoredText(ConfigHandler.lang.noPermissionSimple, ChatFormatting.DARK_RED), true); + return InteractionResult.FAIL; } } if (claim.canInteract(player, PermissionRegistry.PLACE, placePos, false)) { - if (!actualInClaim && context.getStack().getItem() instanceof BlockItem) { + if (!actualInClaim && context.getItemInHand().getItem() instanceof BlockItem) { ((Claim) claim).extendDownwards(placePos); } - return ActionResult.PASS; + return InteractionResult.PASS; } else if (actualInClaim) { - player.sendMessage(PermHelper.simpleColoredText(ConfigHandler.lang.noPermissionSimple, Formatting.DARK_RED), true); - BlockState other = context.getWorld().getBlockState(placePos.up()); - player.networkHandler.sendPacket(new BlockUpdateS2CPacket(placePos.up(), other)); - PlayerClaimData.get(player).addDisplayClaim(claim, EnumDisplayType.MAIN, player.getBlockPos().getY()); + player.displayClientMessage(PermHelper.simpleColoredText(ConfigHandler.lang.noPermissionSimple, ChatFormatting.DARK_RED), true); + BlockState other = context.getLevel().getBlockState(placePos.above()); + player.connection.send(new ClientboundBlockUpdatePacket(placePos.above(), other)); + PlayerClaimData.get(player).addDisplayClaim(claim, EnumDisplayType.MAIN, player.blockPosition().getY()); updateHeldItem(player); - return ActionResult.FAIL; + return InteractionResult.FAIL; } - return ActionResult.PASS; + return InteractionResult.PASS; } /** * -2 == Main inventory update */ - private static void updateHeldItem(ServerPlayerEntity player) { - player.networkHandler.sendPacket(new ScreenHandlerSlotUpdateS2CPacket(-2, player.inventory.selectedSlot, player.inventory.getMainHandStack())); - player.networkHandler.sendPacket(new ScreenHandlerSlotUpdateS2CPacket(-2, 40, player.inventory.getStack(40))); + private static void updateHeldItem(ServerPlayer player) { + player.connection.send(new ClientboundContainerSetSlotPacket(-2, 0, player.getInventory().selected, player.getInventory().getSelected())); + player.connection.send(new ClientboundContainerSetSlotPacket(-2, 0, 40, player.getInventory().getItem(40))); } - private static boolean cantClaimInWorld(ServerWorld world) { + private static boolean cantClaimInWorld(ServerLevel world) { for (String s : ConfigHandler.config.blacklistedWorlds) { - if (s.equals(world.getRegistryKey().getValue().toString())) { + if (s.equals(world.dimension().location().toString())) { return true; } } return false; } - public static void claimLandHandling(ServerPlayerEntity player, BlockPos target) { + public static void claimLandHandling(ServerPlayer player, BlockPos target) { if (!PermissionNodeHandler.perm(player, PermissionNodeHandler.claimCreate, false)) { - player.sendMessage(PermHelper.simpleColoredText(ConfigHandler.lang.noPermission, Formatting.DARK_RED), true); + player.displayClientMessage(PermHelper.simpleColoredText(ConfigHandler.lang.noPermission, ChatFormatting.DARK_RED), true); return; } if (ConfigHandler.config.worldWhitelist) { - if (!cantClaimInWorld(player.getServerWorld())) { - player.sendMessage(PermHelper.simpleColoredText(ConfigHandler.lang.landClaimDisabledWorld, Formatting.DARK_RED), false); + if (!cantClaimInWorld(player.getLevel())) { + player.displayClientMessage(PermHelper.simpleColoredText(ConfigHandler.lang.landClaimDisabledWorld, ChatFormatting.DARK_RED), false); return; } - } else if (cantClaimInWorld(player.getServerWorld())) { - player.sendMessage(PermHelper.simpleColoredText(ConfigHandler.lang.landClaimDisabledWorld, Formatting.DARK_RED), false); + } else if (cantClaimInWorld(player.getLevel())) { + player.displayClientMessage(PermHelper.simpleColoredText(ConfigHandler.lang.landClaimDisabledWorld, ChatFormatting.DARK_RED), false); return; } - ClaimStorage storage = ClaimStorage.get(player.getServerWorld()); - Claim claim = storage.getClaimAt(target.add(0, 255, 0)); + ClaimStorage storage = ClaimStorage.get(player.getLevel()); + Claim claim = storage.getClaimAt(target.offset(0, 255, 0)); PlayerClaimData data = PlayerClaimData.get(player); if (data.claimCooldown()) return; @@ -176,20 +176,20 @@ public class ItemInteractEvents { Claim subClaim = claim.getSubClaim(target); if (subClaim != null && data.currentEdit() == null) { if (subClaim.isCorner(target)) { - data.setEditClaim(subClaim, player.getBlockPos().getY()); + data.setEditClaim(subClaim, player.blockPosition().getY()); data.setEditingCorner(target); - player.sendMessage(PermHelper.simpleColoredText(ConfigHandler.lang.resizeClaim, Formatting.GOLD), false); + player.displayClientMessage(PermHelper.simpleColoredText(ConfigHandler.lang.resizeClaim, ChatFormatting.GOLD), false); } else { - player.sendMessage(PermHelper.simpleColoredText(ConfigHandler.lang.cantClaimHere, Formatting.RED), false); + player.displayClientMessage(PermHelper.simpleColoredText(ConfigHandler.lang.cantClaimHere, ChatFormatting.RED), false); } - data.addDisplayClaim(claim, EnumDisplayType.MAIN, player.getBlockPos().getY()); + data.addDisplayClaim(claim, EnumDisplayType.MAIN, player.blockPosition().getY()); } else { if (data.currentEdit() != null) { if (!data.editingCorner().equals(target)) { Set fl = claim.resizeSubclaim(data.currentEdit(), data.editingCorner(), target); if (!fl.isEmpty()) { - fl.forEach(confl -> data.addDisplayClaim(confl, EnumDisplayType.MAIN, player.getBlockPos().getY())); - player.sendMessage(PermHelper.simpleColoredText(ConfigHandler.lang.conflictOther, Formatting.RED), false); + fl.forEach(confl -> data.addDisplayClaim(confl, EnumDisplayType.MAIN, player.blockPosition().getY())); + player.displayClientMessage(PermHelper.simpleColoredText(ConfigHandler.lang.conflictOther, ChatFormatting.RED), false); } data.setEditClaim(null, 0); data.setEditingCorner(null); @@ -197,12 +197,12 @@ public class ItemInteractEvents { } else if (data.editingCorner() != null) { if (!data.editingCorner().equals(target)) { Set fl = claim.tryCreateSubClaim(data.editingCorner(), target); - data.addDisplayClaim(claim, EnumDisplayType.MAIN, player.getBlockPos().getY()); + data.addDisplayClaim(claim, EnumDisplayType.MAIN, player.blockPosition().getY()); if (!fl.isEmpty()) { - fl.forEach(confl -> data.addDisplayClaim(confl, EnumDisplayType.CONFLICT, player.getBlockPos().getY())); - player.sendMessage(PermHelper.simpleColoredText(ConfigHandler.lang.conflictOther, Formatting.RED), false); + fl.forEach(confl -> data.addDisplayClaim(confl, EnumDisplayType.CONFLICT, player.blockPosition().getY())); + player.displayClientMessage(PermHelper.simpleColoredText(ConfigHandler.lang.conflictOther, ChatFormatting.RED), false); } else { - player.sendMessage(PermHelper.simpleColoredText(ConfigHandler.lang.subClaimCreateSuccess, Formatting.GOLD), false); + player.displayClientMessage(PermHelper.simpleColoredText(ConfigHandler.lang.subClaimCreateSuccess, ChatFormatting.GOLD), false); } data.setEditingCorner(null); } @@ -211,24 +211,24 @@ public class ItemInteractEvents { } } else { if (claim.isCorner(target)) { - data.setEditClaim(claim, player.getBlockPos().getY()); + data.setEditClaim(claim, player.blockPosition().getY()); data.setEditingCorner(target); - player.sendMessage(PermHelper.simpleColoredText(ConfigHandler.lang.resizeClaim, Formatting.GOLD), false); + player.displayClientMessage(PermHelper.simpleColoredText(ConfigHandler.lang.resizeClaim, ChatFormatting.GOLD), false); } else if (data.currentEdit() != null) { storage.resizeClaim(data.currentEdit(), data.editingCorner(), target, player); data.setEditClaim(null, 0); data.setEditingCorner(null); } else { - data.addDisplayClaim(claim, EnumDisplayType.MAIN, player.getBlockPos().getY()); - player.sendMessage(PermHelper.simpleColoredText(ConfigHandler.lang.cantClaimHere, Formatting.RED), false); + data.addDisplayClaim(claim, EnumDisplayType.MAIN, player.blockPosition().getY()); + player.displayClientMessage(PermHelper.simpleColoredText(ConfigHandler.lang.cantClaimHere, ChatFormatting.RED), false); } } } else { - data.addDisplayClaim(claim, EnumDisplayType.MAIN, player.getBlockPos().getY()); - player.sendMessage(PermHelper.simpleColoredText(ConfigHandler.lang.cantClaimHere, Formatting.RED), false); + data.addDisplayClaim(claim, EnumDisplayType.MAIN, player.blockPosition().getY()); + player.displayClientMessage(PermHelper.simpleColoredText(ConfigHandler.lang.cantClaimHere, ChatFormatting.RED), false); } } else if (data.getEditMode() == EnumEditMode.SUBCLAIM) { - player.sendMessage(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.wrongMode, data.getEditMode()), Formatting.RED), false); + player.displayClientMessage(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.wrongMode, data.getEditMode()), ChatFormatting.RED), false); } else { if (data.currentEdit() != null) { storage.resizeClaim(data.currentEdit(), data.editingCorner(), target, player); @@ -242,25 +242,20 @@ public class ItemInteractEvents { } } - public static void inspect(ServerPlayerEntity player, BlockPos target) { - Claim claim = ClaimStorage.get(player.getServerWorld()).getClaimAt(target); + public static void inspect(ServerPlayer player, BlockPos target) { + Claim claim = ClaimStorage.get(player.getLevel()).getClaimAt(target); PlayerClaimData data = PlayerClaimData.get(player); if (data.claimCooldown()) return; data.setClaimActionCooldown(); if (claim != null) { - String owner = claim.isAdminClaim() ? "" : ""; - if (!claim.isAdminClaim()) { - GameProfile prof = player.getServer().getUserCache().getByUuid(claim.getOwner()); - if (prof != null && prof.getName() != null) - owner = prof.getName(); - } - Text text = PermHelper.simpleColoredText(String.format(ConfigHandler.lang.inspectBlockOwner, + String owner = claim.isAdminClaim() ? "" : player.getServer().getProfileCache().get(claim.getOwner()).map(GameProfile::getName).orElse(""); + Component text = PermHelper.simpleColoredText(String.format(ConfigHandler.lang.inspectBlockOwner, owner, - target.getX(), target.getY(), target.getZ()), Formatting.GREEN); - player.sendMessage(text, false); - data.addDisplayClaim(claim, EnumDisplayType.MAIN, player.getBlockPos().getY()); + target.getX(), target.getY(), target.getZ()), ChatFormatting.GREEN); + player.displayClientMessage(text, false); + data.addDisplayClaim(claim, EnumDisplayType.MAIN, player.blockPosition().getY()); } else - player.sendMessage(PermHelper.simpleColoredText(ConfigHandler.lang.inspectNoClaim, Formatting.RED), false); + player.displayClientMessage(PermHelper.simpleColoredText(ConfigHandler.lang.inspectNoClaim, ChatFormatting.RED), false); } } diff --git a/common/src/main/java/io/github/flemmli97/flan/event/PlayerEvents.java b/common/src/main/java/io/github/flemmli97/flan/event/PlayerEvents.java index 30fe989..0f77722 100644 --- a/common/src/main/java/io/github/flemmli97/flan/event/PlayerEvents.java +++ b/common/src/main/java/io/github/flemmli97/flan/event/PlayerEvents.java @@ -2,23 +2,23 @@ package io.github.flemmli97.flan.event; import io.github.flemmli97.flan.player.LogoutTracker; import io.github.flemmli97.flan.player.PlayerClaimData; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.server.network.ServerPlayerEntity; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.entity.player.Player; public class PlayerEvents { - public static void saveClaimData(PlayerEntity player) { - if (player instanceof ServerPlayerEntity) - PlayerClaimData.get((ServerPlayerEntity) player).save(player.getServer()); + public static void saveClaimData(Player player) { + if (player instanceof ServerPlayer) + PlayerClaimData.get((ServerPlayer) player).save(player.getServer()); } - public static void readClaimData(PlayerEntity player) { - if (player instanceof ServerPlayerEntity) - PlayerClaimData.get((ServerPlayerEntity) player).read(player.getServer()); + public static void readClaimData(Player player) { + if (player instanceof ServerPlayer) + PlayerClaimData.get((ServerPlayer) player).read(player.getServer()); } - public static void onLogout(PlayerEntity player) { + public static void onLogout(Player player) { if (player.getServer() != null) - LogoutTracker.getInstance(player.getServer()).track(player.getUuid()); + LogoutTracker.getInstance(player.getServer()).track(player.getUUID()); } } diff --git a/common/src/main/java/io/github/flemmli97/flan/event/WorldEvents.java b/common/src/main/java/io/github/flemmli97/flan/event/WorldEvents.java index 6ce2162..f064395 100644 --- a/common/src/main/java/io/github/flemmli97/flan/event/WorldEvents.java +++ b/common/src/main/java/io/github/flemmli97/flan/event/WorldEvents.java @@ -4,24 +4,24 @@ import io.github.flemmli97.flan.api.data.IPermissionContainer; import io.github.flemmli97.flan.api.permission.PermissionRegistry; import io.github.flemmli97.flan.claim.ClaimStorage; import io.github.flemmli97.flan.player.LogoutTracker; -import net.minecraft.block.BlockState; -import net.minecraft.entity.LightningEntity; -import net.minecraft.entity.SpawnGroup; -import net.minecraft.entity.mob.MobEntity; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; import net.minecraft.server.MinecraftServer; -import net.minecraft.server.network.ServerPlayerEntity; -import net.minecraft.server.world.ServerWorld; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; -import net.minecraft.world.BlockView; -import net.minecraft.world.World; -import net.minecraft.world.explosion.Explosion; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.entity.LightningBolt; +import net.minecraft.world.entity.Mob; +import net.minecraft.world.entity.MobCategory; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.Explosion; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.state.BlockState; public class WorldEvents { - public static void modifyExplosion(Explosion explosion, ServerWorld world) { + public static void modifyExplosion(Explosion explosion, ServerLevel world) { ClaimStorage storage = ClaimStorage.get(world); - explosion.getAffectedBlocks().removeIf(pos -> { + explosion.getToBlow().removeIf(pos -> { IPermissionContainer claim = storage.getForPermissionCheck(pos); if (claim != null) return !claim.canInteract(null, PermissionRegistry.EXPLOSIONS, pos); @@ -29,16 +29,16 @@ public class WorldEvents { }); } - public static boolean pistonCanPush(BlockState state, World world, BlockPos blockPos, Direction direction, Direction pistonDir) { - if (world.isClient || state.isAir()) + public static boolean pistonCanPush(BlockState state, Level world, BlockPos blockPos, Direction direction, Direction pistonDir) { + if (world.isClientSide || state.isAir()) return true; - BlockPos dirPos = blockPos.offset(direction); - ClaimStorage storage = ClaimStorage.get((ServerWorld) world); + BlockPos dirPos = blockPos.relative(direction); + ClaimStorage storage = ClaimStorage.get((ServerLevel) world); IPermissionContainer from = storage.getForPermissionCheck(blockPos); IPermissionContainer to = storage.getForPermissionCheck(dirPos); boolean flag = true; if (from.equals(to)) { - BlockPos oppPoos = blockPos.offset(direction.getOpposite()); + BlockPos oppPoos = blockPos.relative(direction.getOpposite()); IPermissionContainer opp = storage.getForPermissionCheck(oppPoos); if (!from.equals(opp)) flag = from.canInteract(null, PermissionRegistry.PISTONBORDER, oppPoos); @@ -47,44 +47,44 @@ public class WorldEvents { if (!flag) { //Idk enough about piston behaviour to update more blocks when slime is involved. //Ghost blocks appear when trying to push slime contraptions across border - world.updateListeners(blockPos, state, state, 20); + world.sendBlockUpdated(blockPos, state, state, 20); BlockState toState = world.getBlockState(dirPos); - world.updateListeners(dirPos, toState, toState, 20); + world.sendBlockUpdated(dirPos, toState, toState, 20); } return flag; } - public static boolean canFlow(BlockState fluidBlockState, BlockView world, BlockPos blockPos, Direction direction) { - if (!(world instanceof ServerWorld) || direction == Direction.UP || direction == Direction.DOWN) + public static boolean canFlow(BlockState fluidBlockState, BlockGetter world, BlockPos blockPos, Direction direction) { + if (!(world instanceof ServerLevel) || direction == Direction.UP || direction == Direction.DOWN) return true; - ClaimStorage storage = ClaimStorage.get((ServerWorld) world); + ClaimStorage storage = ClaimStorage.get((ServerLevel) world); IPermissionContainer from = storage.getForPermissionCheck(blockPos); - IPermissionContainer to = storage.getForPermissionCheck(blockPos.offset(direction)); + IPermissionContainer to = storage.getForPermissionCheck(blockPos.relative(direction)); return from.equals(to) || to.canInteract(null, PermissionRegistry.WATERBORDER, blockPos); } - public static boolean canStartRaid(ServerPlayerEntity player) { - IPermissionContainer claim = ClaimStorage.get(player.getServerWorld()).getForPermissionCheck(player.getBlockPos()); - return claim.canInteract(player, PermissionRegistry.RAID, player.getBlockPos()); + public static boolean canStartRaid(ServerPlayer player) { + IPermissionContainer claim = ClaimStorage.get(player.getLevel()).getForPermissionCheck(player.blockPosition()); + return claim.canInteract(player, PermissionRegistry.RAID, player.blockPosition()); } - public static boolean canFireSpread(ServerWorld world, BlockPos pos) { + public static boolean canFireSpread(ServerLevel world, BlockPos pos) { IPermissionContainer claim = ClaimStorage.get(world).getForPermissionCheck(pos); return claim.canInteract(null, PermissionRegistry.FIRESPREAD, pos); } - public static boolean preventMobSpawn(ServerWorld world, MobEntity entity) { - IPermissionContainer claim = ClaimStorage.get(world).getForPermissionCheck(entity.getBlockPos()); - if (entity.getType().getSpawnGroup() == SpawnGroup.MONSTER) - return claim.canInteract(null, PermissionRegistry.MOBSPAWN, entity.getBlockPos()); - return claim.canInteract(null, PermissionRegistry.ANIMALSPAWN, entity.getBlockPos()); + public static boolean preventMobSpawn(ServerLevel world, Mob entity) { + IPermissionContainer claim = ClaimStorage.get(world).getForPermissionCheck(entity.blockPosition()); + if (entity.getType().getCategory() == MobCategory.MONSTER) + return claim.canInteract(null, PermissionRegistry.MOBSPAWN, entity.blockPosition()); + return claim.canInteract(null, PermissionRegistry.ANIMALSPAWN, entity.blockPosition()); } - public static boolean lightningFire(LightningEntity lightning) { - if (!(lightning.world instanceof ServerWorld)) + public static boolean lightningFire(LightningBolt lightning) { + if (!(lightning.level instanceof ServerLevel)) return true; - BlockPos.Mutable mutable = lightning.getBlockPos().mutableCopy(); - ServerWorld world = (ServerWorld) lightning.world; + BlockPos.MutableBlockPos mutable = lightning.blockPosition().mutable(); + ServerLevel world = (ServerLevel) lightning.level; for (int x = -1; x <= 1; x++) for (int z = -1; z <= 1; z++) { mutable.set(mutable.getX() + x, mutable.getY(), mutable.getZ() + z); diff --git a/common/src/main/java/io/github/flemmli97/flan/gui/ClaimMenuScreenHandler.java b/common/src/main/java/io/github/flemmli97/flan/gui/ClaimMenuScreenHandler.java index 9f7566a..1847198 100644 --- a/common/src/main/java/io/github/flemmli97/flan/gui/ClaimMenuScreenHandler.java +++ b/common/src/main/java/io/github/flemmli97/flan/gui/ClaimMenuScreenHandler.java @@ -8,84 +8,84 @@ import io.github.flemmli97.flan.claim.PermHelper; import io.github.flemmli97.flan.config.ConfigHandler; import io.github.flemmli97.flan.gui.inv.SeparateInv; import io.github.flemmli97.flan.player.PlayerClaimData; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.screen.NamedScreenHandlerFactory; -import net.minecraft.screen.ScreenHandler; -import net.minecraft.screen.slot.Slot; -import net.minecraft.server.network.ServerPlayerEntity; -import net.minecraft.sound.SoundEvents; -import net.minecraft.text.Text; -import net.minecraft.util.Formatting; +import net.minecraft.ChatFormatting; +import net.minecraft.network.chat.Component; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.sounds.SoundEvents; +import net.minecraft.world.MenuProvider; +import net.minecraft.world.entity.player.Inventory; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.inventory.AbstractContainerMenu; +import net.minecraft.world.inventory.Slot; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; public class ClaimMenuScreenHandler extends ServerOnlyScreenHandler { private final Claim claim; - private ClaimMenuScreenHandler(int syncId, PlayerInventory playerInventory, Claim claim) { + private ClaimMenuScreenHandler(int syncId, Inventory playerInventory, Claim claim) { super(syncId, playerInventory, 1, claim); this.claim = claim; } - public static void openClaimMenu(ServerPlayerEntity player, Claim claim) { - NamedScreenHandlerFactory fac = new NamedScreenHandlerFactory() { + public static void openClaimMenu(ServerPlayer player, Claim claim) { + MenuProvider fac = new MenuProvider() { @Override - public ScreenHandler createMenu(int syncId, PlayerInventory inv, PlayerEntity player) { + public AbstractContainerMenu createMenu(int syncId, Inventory inv, Player player) { return new ClaimMenuScreenHandler(syncId, inv, claim); } @Override - public Text getDisplayName() { + public Component getDisplayName() { return PermHelper.simpleColoredText(claim.parentClaim() != null ? ConfigHandler.lang.screenMenuSub : ConfigHandler.lang.screenMenu); } }; - player.openHandledScreen(fac); + player.openMenu(fac); } @Override - protected void fillInventoryWith(PlayerEntity player, SeparateInv inv, Claim claim) { + protected void fillInventoryWith(Player player, SeparateInv inv, Claim claim) { for (int i = 0; i < 9; i++) { switch (i) { case 0: ItemStack close = new ItemStack(Items.TNT); - close.setCustomName(ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenClose, Formatting.DARK_RED)); + close.setHoverName(ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenClose, ChatFormatting.DARK_RED)); inv.updateStack(i, close); break; case 2: ItemStack perm = new ItemStack(Items.BEACON); - perm.setCustomName(ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenMenuGlobal, Formatting.GOLD)); - if (player instanceof ServerPlayerEntity && !this.hasEditPerm(claim, (ServerPlayerEntity) player)) - ServerScreenHelper.addLore(perm, ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenNoPerm, Formatting.DARK_RED)); + perm.setHoverName(ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenMenuGlobal, ChatFormatting.GOLD)); + if (player instanceof ServerPlayer && !this.hasEditPerm(claim, (ServerPlayer) player)) + ServerScreenHelper.addLore(perm, ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenNoPerm, ChatFormatting.DARK_RED)); inv.updateStack(i, perm); break; case 3: ItemStack group = new ItemStack(Items.WRITABLE_BOOK); - group.setCustomName(ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenMenuGroup, Formatting.GOLD)); - if (player instanceof ServerPlayerEntity && !this.hasEditPerm(claim, (ServerPlayerEntity) player)) - ServerScreenHelper.addLore(group, ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenNoPerm, Formatting.DARK_RED)); + group.setHoverName(ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenMenuGroup, ChatFormatting.GOLD)); + if (player instanceof ServerPlayer && !this.hasEditPerm(claim, (ServerPlayer) player)) + ServerScreenHelper.addLore(group, ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenNoPerm, ChatFormatting.DARK_RED)); inv.updateStack(i, group); break; case 4: ItemStack potions = new ItemStack(Items.POTION); - potions.setCustomName(ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenMenuPotion, Formatting.GOLD)); - if (player instanceof ServerPlayerEntity && !this.hasPerm(claim, (ServerPlayerEntity) player, PermissionRegistry.EDITPOTIONS)) - ServerScreenHelper.addLore(potions, ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenNoPerm, Formatting.DARK_RED)); + potions.setHoverName(ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenMenuPotion, ChatFormatting.GOLD)); + if (player instanceof ServerPlayer && !this.hasPerm(claim, (ServerPlayer) player, PermissionRegistry.EDITPOTIONS)) + ServerScreenHelper.addLore(potions, ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenNoPerm, ChatFormatting.DARK_RED)); inv.updateStack(i, potions); break; case 5: ItemStack sign = new ItemStack(Items.OAK_SIGN); - sign.setCustomName(ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenMenuClaimText, Formatting.GOLD)); - if (player instanceof ServerPlayerEntity && !this.hasPerm(claim, (ServerPlayerEntity) player, PermissionRegistry.EDITCLAIM)) - ServerScreenHelper.addLore(sign, ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenNoPerm, Formatting.DARK_RED)); + sign.setHoverName(ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenMenuClaimText, ChatFormatting.GOLD)); + if (player instanceof ServerPlayer && !this.hasPerm(claim, (ServerPlayer) player, PermissionRegistry.EDITCLAIM)) + ServerScreenHelper.addLore(sign, ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenNoPerm, ChatFormatting.DARK_RED)); inv.updateStack(i, sign); break; case 8: ItemStack delete = new ItemStack(Items.BARRIER); - delete.setCustomName(ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenMenuDelete, Formatting.RED)); - if (player instanceof ServerPlayerEntity && !this.hasPerm(claim, (ServerPlayerEntity) player, PermissionRegistry.EDITCLAIM)) - ServerScreenHelper.addLore(delete, ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenNoPerm, Formatting.DARK_RED)); + delete.setHoverName(ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenMenuDelete, ChatFormatting.RED)); + if (player instanceof ServerPlayer && !this.hasPerm(claim, (ServerPlayer) player, PermissionRegistry.EDITCLAIM)) + ServerScreenHelper.addLore(delete, ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenNoPerm, ChatFormatting.DARK_RED)); inv.updateStack(i, delete); break; default: @@ -100,75 +100,75 @@ public class ClaimMenuScreenHandler extends ServerOnlyScreenHandler { } @Override - protected boolean handleSlotClicked(ServerPlayerEntity player, int index, Slot slot, int clickType) { + protected boolean handleSlotClicked(ServerPlayer player, int index, Slot slot, int clickType) { switch (index) { case 0: - player.closeHandledScreen(); + player.closeContainer(); ServerScreenHelper.playSongToPlayer(player, SoundEvents.UI_BUTTON_CLICK, 1, 1f); break; case 2: if (this.hasEditPerm(this.claim, player)) { - player.closeHandledScreen(); + player.closeContainer(); player.getServer().execute(() -> PermissionScreenHandler.openClaimMenu(player, this.claim, null)); ServerScreenHelper.playSongToPlayer(player, SoundEvents.UI_BUTTON_CLICK, 1, 1f); } else - ServerScreenHelper.playSongToPlayer(player, SoundEvents.ENTITY_VILLAGER_NO, 1, 1f); + ServerScreenHelper.playSongToPlayer(player, SoundEvents.VILLAGER_NO, 1, 1f); break; case 3: if (this.hasEditPerm(this.claim, player)) { - player.closeHandledScreen(); + player.closeContainer(); player.getServer().execute(() -> GroupScreenHandler.openGroupMenu(player, this.claim)); ServerScreenHelper.playSongToPlayer(player, SoundEvents.UI_BUTTON_CLICK, 1, 1f); } else - ServerScreenHelper.playSongToPlayer(player, SoundEvents.ENTITY_VILLAGER_NO, 1, 1f); + ServerScreenHelper.playSongToPlayer(player, SoundEvents.VILLAGER_NO, 1, 1f); break; case 4: if (this.hasPerm(this.claim, player, PermissionRegistry.EDITPOTIONS)) { - player.closeHandledScreen(); + player.closeContainer(); player.getServer().execute(() -> PotionEditScreenHandler.openPotionMenu(player, this.claim)); ServerScreenHelper.playSongToPlayer(player, SoundEvents.UI_BUTTON_CLICK, 1, 1f); } else - ServerScreenHelper.playSongToPlayer(player, SoundEvents.ENTITY_VILLAGER_NO, 1, 1f); + ServerScreenHelper.playSongToPlayer(player, SoundEvents.VILLAGER_NO, 1, 1f); break; case 5: if (this.hasPerm(this.claim, player, PermissionRegistry.EDITCLAIM)) { - player.closeHandledScreen(); + player.closeContainer(); player.getServer().execute(() -> ClaimTextHandler.openClaimMenu(player, this.claim)); ServerScreenHelper.playSongToPlayer(player, SoundEvents.UI_BUTTON_CLICK, 1, 1f); } else - ServerScreenHelper.playSongToPlayer(player, SoundEvents.ENTITY_VILLAGER_NO, 1, 1f); + ServerScreenHelper.playSongToPlayer(player, SoundEvents.VILLAGER_NO, 1, 1f); break; case 8: if (this.hasPerm(this.claim, player, PermissionRegistry.EDITCLAIM)) { - player.closeHandledScreen(); + player.closeContainer(); player.getServer().execute(() -> ConfirmScreenHandler.openConfirmScreen(player, (bool) -> { if (bool) { - ClaimStorage storage = ClaimStorage.get(player.getServerWorld()); - storage.deleteClaim(this.claim, true, PlayerClaimData.get(player).getEditMode(), player.getServerWorld()); - player.closeHandledScreen(); - player.sendMessage(PermHelper.simpleColoredText(ConfigHandler.lang.deleteClaim, Formatting.RED), false); - ServerScreenHelper.playSongToPlayer(player, SoundEvents.BLOCK_ANVIL_PLACE, 1, 1f); + ClaimStorage storage = ClaimStorage.get(player.getLevel()); + storage.deleteClaim(this.claim, true, PlayerClaimData.get(player).getEditMode(), player.getLevel()); + player.closeContainer(); + player.displayClientMessage(PermHelper.simpleColoredText(ConfigHandler.lang.deleteClaim, ChatFormatting.RED), false); + ServerScreenHelper.playSongToPlayer(player, SoundEvents.ANVIL_PLACE, 1, 1f); } else { - player.closeHandledScreen(); + player.closeContainer(); player.getServer().execute(() -> ClaimMenuScreenHandler.openClaimMenu(player, this.claim)); - ServerScreenHelper.playSongToPlayer(player, SoundEvents.ENTITY_VILLAGER_NO, 1, 1f); + ServerScreenHelper.playSongToPlayer(player, SoundEvents.VILLAGER_NO, 1, 1f); } })); } else - ServerScreenHelper.playSongToPlayer(player, SoundEvents.ENTITY_VILLAGER_NO, 1, 1f); + ServerScreenHelper.playSongToPlayer(player, SoundEvents.VILLAGER_NO, 1, 1f); break; } return true; } - private boolean hasEditPerm(Claim claim, ServerPlayerEntity player) { - return ((claim.parentClaim() != null && claim.parentClaim().canInteract(player, PermissionRegistry.EDITPERMS, player.getBlockPos())) - || claim.canInteract(player, PermissionRegistry.EDITPERMS, player.getBlockPos())); + private boolean hasEditPerm(Claim claim, ServerPlayer player) { + return ((claim.parentClaim() != null && claim.parentClaim().canInteract(player, PermissionRegistry.EDITPERMS, player.blockPosition())) + || claim.canInteract(player, PermissionRegistry.EDITPERMS, player.blockPosition())); } - private boolean hasPerm(Claim claim, ServerPlayerEntity player, ClaimPermission perm) { + private boolean hasPerm(Claim claim, ServerPlayer player, ClaimPermission perm) { if (claim.parentClaim() != null) - return claim.parentClaim().canInteract(player, perm, player.getBlockPos()); - return claim.canInteract(player, perm, player.getBlockPos()); + return claim.parentClaim().canInteract(player, perm, player.blockPosition()); + return claim.canInteract(player, perm, player.blockPosition()); } } diff --git a/common/src/main/java/io/github/flemmli97/flan/gui/ClaimTextHandler.java b/common/src/main/java/io/github/flemmli97/flan/gui/ClaimTextHandler.java index a09c405..da806e5 100644 --- a/common/src/main/java/io/github/flemmli97/flan/gui/ClaimTextHandler.java +++ b/common/src/main/java/io/github/flemmli97/flan/gui/ClaimTextHandler.java @@ -6,20 +6,20 @@ import io.github.flemmli97.flan.claim.Claim; import io.github.flemmli97.flan.claim.PermHelper; import io.github.flemmli97.flan.config.ConfigHandler; import io.github.flemmli97.flan.gui.inv.SeparateInv; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.screen.NamedScreenHandlerFactory; -import net.minecraft.screen.ScreenHandler; -import net.minecraft.screen.slot.Slot; -import net.minecraft.server.network.ServerPlayerEntity; -import net.minecraft.sound.SoundEvents; -import net.minecraft.text.ClickEvent; -import net.minecraft.text.LiteralText; -import net.minecraft.text.Style; -import net.minecraft.text.Text; -import net.minecraft.util.Formatting; +import net.minecraft.ChatFormatting; +import net.minecraft.network.chat.ClickEvent; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.Style; +import net.minecraft.network.chat.TextComponent; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.sounds.SoundEvents; +import net.minecraft.world.MenuProvider; +import net.minecraft.world.entity.player.Inventory; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.inventory.AbstractContainerMenu; +import net.minecraft.world.inventory.Slot; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; import java.util.function.Consumer; @@ -27,59 +27,59 @@ public class ClaimTextHandler extends ServerOnlyScreenHandler { private final Claim claim; - private ClaimTextHandler(int syncId, PlayerInventory playerInventory, Claim claim) { + private ClaimTextHandler(int syncId, Inventory playerInventory, Claim claim) { super(syncId, playerInventory, 1, claim); this.claim = claim; } - public static void openClaimMenu(ServerPlayerEntity player, Claim claim) { - NamedScreenHandlerFactory fac = new NamedScreenHandlerFactory() { + public static void openClaimMenu(ServerPlayer player, Claim claim) { + MenuProvider fac = new MenuProvider() { @Override - public ScreenHandler createMenu(int syncId, PlayerInventory inv, PlayerEntity player) { + public AbstractContainerMenu createMenu(int syncId, Inventory inv, Player player) { return new ClaimTextHandler(syncId, inv, claim); } @Override - public Text getDisplayName() { + public Component getDisplayName() { return PermHelper.simpleColoredText(claim.parentClaim() != null ? ConfigHandler.lang.screenTitleEditorSub : ConfigHandler.lang.screenTitleEditor); } }; - player.openHandledScreen(fac); + player.openMenu(fac); } @Override - protected void fillInventoryWith(PlayerEntity player, SeparateInv inv, Claim claim) { + protected void fillInventoryWith(Player player, SeparateInv inv, Claim claim) { for (int i = 0; i < 9; i++) { switch (i) { case 0: ItemStack close = new ItemStack(Items.TNT); - close.setCustomName(ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenBack, Formatting.DARK_RED)); + close.setHoverName(ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenBack, ChatFormatting.DARK_RED)); inv.updateStack(i, close); break; case 2: ItemStack stack = new ItemStack(Items.OAK_SIGN); - stack.setCustomName(ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenEnterText, Formatting.GOLD)); + stack.setHoverName(ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenEnterText, ChatFormatting.GOLD)); if (claim.enterTitle != null) ServerScreenHelper.addLore(stack, claim.enterTitle); inv.updateStack(i, stack); break; case 3: ItemStack stack2 = new ItemStack(Items.OAK_SIGN); - stack2.setCustomName(ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenEnterSubText, Formatting.GOLD)); + stack2.setHoverName(ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenEnterSubText, ChatFormatting.GOLD)); if (claim.enterSubtitle != null) ServerScreenHelper.addLore(stack2, claim.enterSubtitle); inv.updateStack(i, stack2); break; case 4: ItemStack stack3 = new ItemStack(Items.OAK_SIGN); - stack3.setCustomName(ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenLeaveText, Formatting.GOLD)); + stack3.setHoverName(ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenLeaveText, ChatFormatting.GOLD)); if (claim.leaveTitle != null) ServerScreenHelper.addLore(stack3, claim.leaveTitle); inv.updateStack(i, stack3); break; case 5: ItemStack stack4 = new ItemStack(Items.OAK_SIGN); - stack4.setCustomName(ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenLeaveSubText, Formatting.GOLD)); + stack4.setHoverName(ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenLeaveSubText, ChatFormatting.GOLD)); if (claim.leaveSubtitle != null) ServerScreenHelper.addLore(stack4, claim.leaveSubtitle); inv.updateStack(i, stack4); @@ -96,13 +96,13 @@ public class ClaimTextHandler extends ServerOnlyScreenHandler { } @Override - protected boolean handleSlotClicked(ServerPlayerEntity player, int index, Slot slot, int clickType) { + protected boolean handleSlotClicked(ServerPlayer player, int index, Slot slot, int clickType) { if (index == 0) { - player.closeHandledScreen(); + player.closeContainer(); player.getServer().execute(() -> ClaimMenuScreenHandler.openClaimMenu(player, this.claim)); ServerScreenHelper.playSongToPlayer(player, SoundEvents.UI_BUTTON_CLICK, 1, 1f); } else { - Consumer cons = null; + Consumer cons = null; switch (index) { case 2: cons = text -> this.claim.setEnterTitle(text, this.claim.enterSubtitle); @@ -118,25 +118,25 @@ public class ClaimTextHandler extends ServerOnlyScreenHandler { break; } if (cons != null) { - player.closeHandledScreen(); - Consumer finalCons = cons; + player.closeContainer(); + Consumer finalCons = cons; if (clickType == 0) { player.getServer().execute(() -> StringResultScreenHandler.createNewStringResult(player, (s) -> { - player.closeHandledScreen(); - finalCons.accept(new LiteralText(s).fillStyle(Style.EMPTY.withItalic(false).withFormatting(Formatting.WHITE))); + player.closeContainer(); + finalCons.accept(new TextComponent(s).withStyle(Style.EMPTY.withItalic(false).applyFormat(ChatFormatting.WHITE))); player.getServer().execute(() -> ClaimTextHandler.openClaimMenu(player, this.claim)); - ServerScreenHelper.playSongToPlayer(player, SoundEvents.BLOCK_ANVIL_USE, 1, 1f); + ServerScreenHelper.playSongToPlayer(player, SoundEvents.ANVIL_USE, 1, 1f); }, () -> { - player.closeHandledScreen(); + player.closeContainer(); player.getServer().execute(() -> ClaimTextHandler.openClaimMenu(player, this.claim)); - ServerScreenHelper.playSongToPlayer(player, SoundEvents.ENTITY_VILLAGER_NO, 1, 1f); + ServerScreenHelper.playSongToPlayer(player, SoundEvents.VILLAGER_NO, 1, 1f); })); } else { - LiteralText text = new LiteralText(ConfigHandler.lang.chatClaimTextEdit); + TextComponent text = new TextComponent(ConfigHandler.lang.chatClaimTextEdit); String command = "/flan claimMessage" + (index == 2 || index == 3 ? " enter" : " leave") + (index == 2 || index == 4 ? " title" : " subtitle") + " text "; - text.fillStyle(Style.EMPTY.withClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, command))); - player.sendMessage(text, false); + text.withStyle(Style.EMPTY.withClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, command))); + player.displayClientMessage(text, false); } ServerScreenHelper.playSongToPlayer(player, SoundEvents.UI_BUTTON_CLICK, 1, 1f); } @@ -144,14 +144,14 @@ public class ClaimTextHandler extends ServerOnlyScreenHandler { return true; } - private boolean hasEditPerm(Claim claim, ServerPlayerEntity player) { - return ((claim.parentClaim() != null && claim.parentClaim().canInteract(player, PermissionRegistry.EDITPERMS, player.getBlockPos())) - || claim.canInteract(player, PermissionRegistry.EDITPERMS, player.getBlockPos())); + private boolean hasEditPerm(Claim claim, ServerPlayer player) { + return ((claim.parentClaim() != null && claim.parentClaim().canInteract(player, PermissionRegistry.EDITPERMS, player.blockPosition())) + || claim.canInteract(player, PermissionRegistry.EDITPERMS, player.blockPosition())); } - private boolean hasPerm(Claim claim, ServerPlayerEntity player, ClaimPermission perm) { + private boolean hasPerm(Claim claim, ServerPlayer player, ClaimPermission perm) { if (claim.parentClaim() != null) - return claim.parentClaim().canInteract(player, perm, player.getBlockPos()); - return claim.canInteract(player, perm, player.getBlockPos()); + return claim.parentClaim().canInteract(player, perm, player.blockPosition()); + return claim.canInteract(player, perm, player.blockPosition()); } } diff --git a/common/src/main/java/io/github/flemmli97/flan/gui/ConfirmScreenHandler.java b/common/src/main/java/io/github/flemmli97/flan/gui/ConfirmScreenHandler.java index 922423e..b450c14 100644 --- a/common/src/main/java/io/github/flemmli97/flan/gui/ConfirmScreenHandler.java +++ b/common/src/main/java/io/github/flemmli97/flan/gui/ConfirmScreenHandler.java @@ -3,16 +3,16 @@ package io.github.flemmli97.flan.gui; import io.github.flemmli97.flan.claim.PermHelper; import io.github.flemmli97.flan.config.ConfigHandler; import io.github.flemmli97.flan.gui.inv.SeparateInv; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.screen.NamedScreenHandlerFactory; -import net.minecraft.screen.ScreenHandler; -import net.minecraft.screen.slot.Slot; -import net.minecraft.server.network.ServerPlayerEntity; -import net.minecraft.text.Text; -import net.minecraft.util.Formatting; +import net.minecraft.ChatFormatting; +import net.minecraft.network.chat.Component; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.MenuProvider; +import net.minecraft.world.entity.player.Inventory; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.inventory.AbstractContainerMenu; +import net.minecraft.world.inventory.Slot; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; import java.util.function.Consumer; @@ -20,39 +20,39 @@ public class ConfirmScreenHandler extends ServerOnlyScreenHandler { private final Consumer cons; - private ConfirmScreenHandler(int syncId, PlayerInventory playerInventory, Consumer cons) { + private ConfirmScreenHandler(int syncId, Inventory playerInventory, Consumer cons) { super(syncId, playerInventory, 1, null); this.cons = cons; } - public static void openConfirmScreen(ServerPlayerEntity player, Consumer process) { - NamedScreenHandlerFactory fac = new NamedScreenHandlerFactory() { + public static void openConfirmScreen(ServerPlayer player, Consumer process) { + MenuProvider fac = new MenuProvider() { @Override - public ScreenHandler createMenu(int syncId, PlayerInventory inv, PlayerEntity player) { + public AbstractContainerMenu createMenu(int syncId, Inventory inv, Player player) { return new ConfirmScreenHandler(syncId, inv, process); } @Override - public Text getDisplayName() { + public Component getDisplayName() { return PermHelper.simpleColoredText(ConfigHandler.lang.screenConfirm); } }; - player.openHandledScreen(fac); + player.openMenu(fac); } @Override - protected void fillInventoryWith(PlayerEntity player, SeparateInv inv, Object additionalData) { + protected void fillInventoryWith(Player player, SeparateInv inv, Object additionalData) { for (int i = 0; i < 9; i++) { switch (i) { case 3: ItemStack yes = new ItemStack(Items.GREEN_WOOL); - yes.setCustomName(ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenYes, Formatting.GREEN)); + yes.setHoverName(ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenYes, ChatFormatting.GREEN)); inv.updateStack(i, yes); break; case 5: ItemStack no = new ItemStack(Items.RED_WOOL); - no.setCustomName(ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenNo, Formatting.RED)); + no.setHoverName(ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenNo, ChatFormatting.RED)); inv.updateStack(i, no); break; default: @@ -67,7 +67,7 @@ public class ConfirmScreenHandler extends ServerOnlyScreenHandler { } @Override - protected boolean handleSlotClicked(ServerPlayerEntity player, int index, Slot slot, int clickType) { + protected boolean handleSlotClicked(ServerPlayer player, int index, Slot slot, int clickType) { switch (index) { case 3: this.cons.accept(true); diff --git a/common/src/main/java/io/github/flemmli97/flan/gui/GroupPlayerScreenHandler.java b/common/src/main/java/io/github/flemmli97/flan/gui/GroupPlayerScreenHandler.java index a68e5b0..d64506e 100644 --- a/common/src/main/java/io/github/flemmli97/flan/gui/GroupPlayerScreenHandler.java +++ b/common/src/main/java/io/github/flemmli97/flan/gui/GroupPlayerScreenHandler.java @@ -5,20 +5,20 @@ import io.github.flemmli97.flan.claim.Claim; import io.github.flemmli97.flan.claim.PermHelper; import io.github.flemmli97.flan.config.ConfigHandler; import io.github.flemmli97.flan.gui.inv.SeparateInv; -import net.minecraft.block.entity.SkullBlockEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; +import net.minecraft.ChatFormatting; import net.minecraft.nbt.CompoundTag; -import net.minecraft.nbt.NbtHelper; -import net.minecraft.screen.NamedScreenHandlerFactory; -import net.minecraft.screen.ScreenHandler; -import net.minecraft.screen.slot.Slot; -import net.minecraft.server.network.ServerPlayerEntity; -import net.minecraft.sound.SoundEvents; -import net.minecraft.text.Text; -import net.minecraft.util.Formatting; +import net.minecraft.nbt.NbtUtils; +import net.minecraft.network.chat.Component; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.sounds.SoundEvents; +import net.minecraft.world.MenuProvider; +import net.minecraft.world.entity.player.Inventory; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.inventory.AbstractContainerMenu; +import net.minecraft.world.inventory.Slot; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraft.world.level.block.entity.SkullBlockEntity; import java.util.List; @@ -28,7 +28,7 @@ public class GroupPlayerScreenHandler extends ServerOnlyScreenHandler players = claim.playersFromGroup(player.getServer(), additionalData.getGroup()); for (int i = 0; i < 54; i++) { if (i == 0) { ItemStack close = new ItemStack(Items.TNT); - close.setCustomName(ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenBack, Formatting.DARK_RED)); + close.setHoverName(ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenBack, ChatFormatting.DARK_RED)); inv.updateStack(i, close); } else if (i == 3) { ItemStack stack = new ItemStack(Items.ANVIL); - stack.setCustomName(ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenAdd, Formatting.DARK_GREEN)); + stack.setHoverName(ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenAdd, ChatFormatting.DARK_GREEN)); inv.updateStack(i, stack); } else if (i == 4) { ItemStack stack = new ItemStack(Items.REDSTONE_BLOCK); - stack.setCustomName(ServerScreenHelper.coloredGuiText(String.format(ConfigHandler.lang.screenRemoveMode, this.removeMode ? ConfigHandler.lang.screenTrue : ConfigHandler.lang.screenFalse), Formatting.DARK_RED)); + stack.setHoverName(ServerScreenHelper.coloredGuiText(String.format(ConfigHandler.lang.screenRemoveMode, this.removeMode ? ConfigHandler.lang.screenTrue : ConfigHandler.lang.screenFalse), ChatFormatting.DARK_RED)); inv.updateStack(i, stack); } else if (i < 9 || i > 44 || i % 9 == 0 || i % 9 == 8) inv.updateStack(i, ServerScreenHelper.emptyFiller()); @@ -85,8 +85,7 @@ public class GroupPlayerScreenHandler extends ServerOnlyScreenHandler group.getOrCreateTag().put("SkullOwner", NbtUtils.writeGameProfile(new CompoundTag(), prof))); inv.updateStack(i, group); } } @@ -99,30 +98,29 @@ public class GroupPlayerScreenHandler extends ServerOnlyScreenHandler GroupScreenHandler.openGroupMenu(player, this.claim)); ServerScreenHelper.playSongToPlayer(player, SoundEvents.UI_BUTTON_CLICK, 1, 1f); return true; } if (index == 3) { - player.closeHandledScreen(); + player.closeContainer(); player.getServer().execute(() -> StringResultScreenHandler.createNewStringResult(player, (s) -> { - GameProfile prof = player.getServer().getUserCache().findByName(s); - boolean fl = prof == null || this.claim.setPlayerGroup(prof.getId(), this.group, false); - player.closeHandledScreen(); + boolean fl = player.getServer().getProfileCache().get(s).map(prof -> this.claim.setPlayerGroup(prof.getId(), this.group, false)).orElse(true); + player.closeContainer(); player.getServer().execute(() -> GroupPlayerScreenHandler.openPlayerGroupMenu(player, this.claim, this.group)); if (fl) - ServerScreenHelper.playSongToPlayer(player, SoundEvents.BLOCK_ANVIL_USE, 1, 1f); + ServerScreenHelper.playSongToPlayer(player, SoundEvents.ANVIL_USE, 1, 1f); else { - player.sendMessage(PermHelper.simpleColoredText(ConfigHandler.lang.playerGroupAddFail, Formatting.RED), false); - ServerScreenHelper.playSongToPlayer(player, SoundEvents.ENTITY_VILLAGER_NO, 1, 1f); + player.displayClientMessage(PermHelper.simpleColoredText(ConfigHandler.lang.playerGroupAddFail, ChatFormatting.RED), false); + ServerScreenHelper.playSongToPlayer(player, SoundEvents.VILLAGER_NO, 1, 1f); } }, () -> { - player.closeHandledScreen(); + player.closeContainer(); player.getServer().execute(() -> GroupPlayerScreenHandler.openPlayerGroupMenu(player, this.claim, this.group)); - ServerScreenHelper.playSongToPlayer(player, SoundEvents.ENTITY_VILLAGER_NO, 1, 1f); + ServerScreenHelper.playSongToPlayer(player, SoundEvents.VILLAGER_NO, 1, 1f); })); ServerScreenHelper.playSongToPlayer(player, SoundEvents.UI_BUTTON_CLICK, 1, 1f); return true; @@ -130,18 +128,18 @@ public class GroupPlayerScreenHandler extends ServerOnlyScreenHandler { private boolean removeMode; - private GroupScreenHandler(int syncId, PlayerInventory playerInventory, Claim claim) { + private GroupScreenHandler(int syncId, Inventory playerInventory, Claim claim) { super(syncId, playerInventory, 6, claim); this.claim = claim; } - public static void openGroupMenu(PlayerEntity player, Claim claim) { - NamedScreenHandlerFactory fac = new NamedScreenHandlerFactory() { + public static void openGroupMenu(Player player, Claim claim) { + MenuProvider fac = new MenuProvider() { @Override - public ScreenHandler createMenu(int syncId, PlayerInventory inv, PlayerEntity player) { + public AbstractContainerMenu createMenu(int syncId, Inventory inv, Player player) { return new GroupScreenHandler(syncId, inv, claim); } @Override - public Text getDisplayName() { + public Component getDisplayName() { return PermHelper.simpleColoredText(ConfigHandler.lang.screenGroups); } }; - player.openHandledScreen(fac); + player.openMenu(fac); } @Override - protected void fillInventoryWith(PlayerEntity player, SeparateInv inv, Claim claim) { + protected void fillInventoryWith(Player player, SeparateInv inv, Claim claim) { for (int i = 0; i < 54; i++) { if (i == 0) { ItemStack stack = new ItemStack(Items.TNT); - stack.setCustomName(ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenBack, Formatting.DARK_RED)); + stack.setHoverName(ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenBack, ChatFormatting.DARK_RED)); inv.updateStack(i, stack); } else if (i == 3) { ItemStack stack = new ItemStack(Items.ANVIL); - stack.setCustomName(ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenAdd, Formatting.DARK_GREEN)); + stack.setHoverName(ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenAdd, ChatFormatting.DARK_GREEN)); inv.updateStack(i, stack); } else if (i == 4) { ItemStack stack = new ItemStack(Items.REDSTONE_BLOCK); - stack.setCustomName(ServerScreenHelper.coloredGuiText(String.format(ConfigHandler.lang.screenRemoveMode, this.removeMode ? ConfigHandler.lang.screenTrue : ConfigHandler.lang.screenFalse), Formatting.DARK_RED)); + stack.setHoverName(ServerScreenHelper.coloredGuiText(String.format(ConfigHandler.lang.screenRemoveMode, this.removeMode ? ConfigHandler.lang.screenTrue : ConfigHandler.lang.screenFalse), ChatFormatting.DARK_RED)); inv.updateStack(i, stack); } else if (i < 9 || i > 44 || i % 9 == 0 || i % 9 == 8) inv.updateStack(i, ServerScreenHelper.emptyFiller()); @@ -68,7 +68,7 @@ public class GroupScreenHandler extends ServerOnlyScreenHandler { int id = (i % 9) + row * 7 - 1; if (id < groups.size()) { ItemStack group = new ItemStack(Items.PAPER); - group.setCustomName(ServerScreenHelper.coloredGuiText(groups.get(id), Formatting.DARK_BLUE)); + group.setHoverName(ServerScreenHelper.coloredGuiText(groups.get(id), ChatFormatting.DARK_BLUE)); inv.updateStack(i, group); } } @@ -81,24 +81,24 @@ public class GroupScreenHandler extends ServerOnlyScreenHandler { } @Override - protected boolean handleSlotClicked(ServerPlayerEntity player, int index, Slot slot, int clickType) { + protected boolean handleSlotClicked(ServerPlayer player, int index, Slot slot, int clickType) { if (index == 0) { - player.closeHandledScreen(); + player.closeContainer(); player.getServer().execute(() -> ClaimMenuScreenHandler.openClaimMenu(player, this.claim)); ServerScreenHelper.playSongToPlayer(player, SoundEvents.UI_BUTTON_CLICK, 1, 1f); return true; } if (index == 3) { - player.closeHandledScreen(); + player.closeContainer(); player.getServer().execute(() -> StringResultScreenHandler.createNewStringResult(player, (s) -> { this.claim.editPerms(player, s, PermissionRegistry.EDITPERMS, -1); - player.closeHandledScreen(); + player.closeContainer(); player.getServer().execute(() -> GroupScreenHandler.openGroupMenu(player, this.claim)); - ServerScreenHelper.playSongToPlayer(player, SoundEvents.BLOCK_ANVIL_USE, 1, 1f); + ServerScreenHelper.playSongToPlayer(player, SoundEvents.ANVIL_USE, 1, 1f); }, () -> { - player.closeHandledScreen(); + player.closeContainer(); player.getServer().execute(() -> GroupScreenHandler.openGroupMenu(player, this.claim)); - ServerScreenHelper.playSongToPlayer(player, SoundEvents.ENTITY_VILLAGER_NO, 1, 1f); + ServerScreenHelper.playSongToPlayer(player, SoundEvents.VILLAGER_NO, 1, 1f); })); ServerScreenHelper.playSongToPlayer(player, SoundEvents.UI_BUTTON_CLICK, 1, 1f); return true; @@ -106,24 +106,24 @@ public class GroupScreenHandler extends ServerOnlyScreenHandler { if (index == 4) { this.removeMode = !this.removeMode; ItemStack stack = new ItemStack(Items.REDSTONE_BLOCK); - stack.setCustomName(ServerScreenHelper.coloredGuiText(String.format(ConfigHandler.lang.screenRemoveMode, this.removeMode ? ConfigHandler.lang.screenTrue : ConfigHandler.lang.screenFalse), Formatting.DARK_RED)); - slot.setStack(stack); + stack.setHoverName(ServerScreenHelper.coloredGuiText(String.format(ConfigHandler.lang.screenRemoveMode, this.removeMode ? ConfigHandler.lang.screenTrue : ConfigHandler.lang.screenFalse), ChatFormatting.DARK_RED)); + slot.set(stack); ServerScreenHelper.playSongToPlayer(player, SoundEvents.UI_BUTTON_CLICK, 1, 1f); return true; } - ItemStack stack = slot.getStack(); + ItemStack stack = slot.getItem(); if (!stack.isEmpty()) { - String name = stack.getName().asString(); + String name = stack.getHoverName().getContents(); if (this.removeMode) { this.claim.removePermGroup(player, name); - slot.setStack(ItemStack.EMPTY); - ServerScreenHelper.playSongToPlayer(player, SoundEvents.ENTITY_BAT_DEATH, 1, 1f); + slot.set(ItemStack.EMPTY); + ServerScreenHelper.playSongToPlayer(player, SoundEvents.BAT_DEATH, 1, 1f); } else { if (clickType == 1) { - player.closeHandledScreen(); + player.closeContainer(); player.getServer().execute(() -> PermissionScreenHandler.openClaimMenu(player, this.claim, name)); } else { - player.closeHandledScreen(); + player.closeContainer(); player.getServer().execute(() -> GroupPlayerScreenHandler.openPlayerGroupMenu(player, this.claim, name)); } ServerScreenHelper.playSongToPlayer(player, SoundEvents.UI_BUTTON_CLICK, 1, 1f); diff --git a/common/src/main/java/io/github/flemmli97/flan/gui/LockedLecternScreenHandler.java b/common/src/main/java/io/github/flemmli97/flan/gui/LockedLecternScreenHandler.java index bf6eb23..3bb1e8a 100644 --- a/common/src/main/java/io/github/flemmli97/flan/gui/LockedLecternScreenHandler.java +++ b/common/src/main/java/io/github/flemmli97/flan/gui/LockedLecternScreenHandler.java @@ -3,45 +3,45 @@ package io.github.flemmli97.flan.gui; import io.github.flemmli97.flan.claim.PermHelper; import io.github.flemmli97.flan.config.ConfigHandler; import io.github.flemmli97.flan.mixin.ILecternBlockValues; -import net.minecraft.block.entity.LecternBlockEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.inventory.Inventory; -import net.minecraft.screen.LecternScreenHandler; -import net.minecraft.screen.NamedScreenHandlerFactory; -import net.minecraft.screen.PropertyDelegate; -import net.minecraft.screen.ScreenHandler; -import net.minecraft.server.network.ServerPlayerEntity; -import net.minecraft.text.Text; -import net.minecraft.util.Formatting; +import net.minecraft.ChatFormatting; +import net.minecraft.network.chat.Component; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.Container; +import net.minecraft.world.MenuProvider; +import net.minecraft.world.entity.player.Inventory; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.inventory.AbstractContainerMenu; +import net.minecraft.world.inventory.ContainerData; +import net.minecraft.world.inventory.LecternMenu; +import net.minecraft.world.level.block.entity.LecternBlockEntity; -public class LockedLecternScreenHandler extends LecternScreenHandler { +public class LockedLecternScreenHandler extends LecternMenu { - public LockedLecternScreenHandler(int syncId, Inventory inventory, PropertyDelegate propertyDelegate) { + public LockedLecternScreenHandler(int syncId, Container inventory, ContainerData propertyDelegate) { super(syncId, inventory, propertyDelegate); } - public static void create(ServerPlayerEntity player, LecternBlockEntity lectern) { - NamedScreenHandlerFactory fac = new NamedScreenHandlerFactory() { + public static void create(ServerPlayer player, LecternBlockEntity lectern) { + MenuProvider fac = new MenuProvider() { @Override - public ScreenHandler createMenu(int syncId, PlayerInventory inv, PlayerEntity player) { + public AbstractContainerMenu createMenu(int syncId, Inventory inv, Player player) { return new LockedLecternScreenHandler(syncId, ((ILecternBlockValues) lectern).getInv(), ((ILecternBlockValues) lectern).getProp()); } @Override - public Text getDisplayName() { + public Component getDisplayName() { return lectern.getDisplayName(); } }; - player.openHandledScreen(fac); + player.openMenu(fac); } @Override - public boolean onButtonClick(PlayerEntity player, int id) { + public boolean clickMenuButton(Player player, int id) { if (id == 3) { - player.sendMessage(PermHelper.simpleColoredText(ConfigHandler.lang.noPermissionSimple, Formatting.DARK_RED), false); + player.displayClientMessage(PermHelper.simpleColoredText(ConfigHandler.lang.noPermissionSimple, ChatFormatting.DARK_RED), false); return false; } - return super.onButtonClick(player, id); + return super.clickMenuButton(player, id); } } diff --git a/common/src/main/java/io/github/flemmli97/flan/gui/PermissionScreenHandler.java b/common/src/main/java/io/github/flemmli97/flan/gui/PermissionScreenHandler.java index 6afc4c7..60255e4 100644 --- a/common/src/main/java/io/github/flemmli97/flan/gui/PermissionScreenHandler.java +++ b/common/src/main/java/io/github/flemmli97/flan/gui/PermissionScreenHandler.java @@ -6,17 +6,17 @@ import io.github.flemmli97.flan.claim.Claim; import io.github.flemmli97.flan.claim.PermHelper; import io.github.flemmli97.flan.config.ConfigHandler; import io.github.flemmli97.flan.gui.inv.SeparateInv; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.screen.NamedScreenHandlerFactory; -import net.minecraft.screen.ScreenHandler; -import net.minecraft.screen.slot.Slot; -import net.minecraft.server.network.ServerPlayerEntity; -import net.minecraft.sound.SoundEvents; -import net.minecraft.text.Text; -import net.minecraft.util.Formatting; +import net.minecraft.ChatFormatting; +import net.minecraft.network.chat.Component; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.sounds.SoundEvents; +import net.minecraft.world.MenuProvider; +import net.minecraft.world.entity.player.Inventory; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.inventory.AbstractContainerMenu; +import net.minecraft.world.inventory.Slot; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; import java.util.ArrayList; import java.util.List; @@ -28,7 +28,7 @@ public class PermissionScreenHandler extends ServerOnlyScreenHandler private int page, maxPages; private List perms; - private PermissionScreenHandler(int syncId, PlayerInventory playerInventory, Claim claim, String group) { + private PermissionScreenHandler(int syncId, Inventory playerInventory, Claim claim, String group) { super(syncId, playerInventory, 6, new ClaimGroup() { @Override public Claim getClaim() { @@ -44,23 +44,23 @@ public class PermissionScreenHandler extends ServerOnlyScreenHandler this.group = group; } - public static void openClaimMenu(PlayerEntity player, Claim claim, String group) { - NamedScreenHandlerFactory fac = new NamedScreenHandlerFactory() { + public static void openClaimMenu(Player player, Claim claim, String group) { + MenuProvider fac = new MenuProvider() { @Override - public ScreenHandler createMenu(int syncId, PlayerInventory inv, PlayerEntity player) { + public AbstractContainerMenu createMenu(int syncId, Inventory inv, Player player) { return new PermissionScreenHandler(syncId, inv, claim, group); } @Override - public Text getDisplayName() { + public Component getDisplayName() { return PermHelper.simpleColoredText(group == null ? ConfigHandler.lang.screenGlobalPerms : String.format(ConfigHandler.lang.screenGroupPerms, group)); } }; - player.openHandledScreen(fac); + player.openMenu(fac); } @Override - protected void fillInventoryWith(PlayerEntity player, SeparateInv inv, ClaimGroup additionalData) { + protected void fillInventoryWith(Player player, SeparateInv inv, ClaimGroup additionalData) { this.perms = new ArrayList<>(PermissionRegistry.getPerms()); if (additionalData.getGroup() != null) this.perms.removeAll(PermissionRegistry.globalPerms()); @@ -68,11 +68,11 @@ public class PermissionScreenHandler extends ServerOnlyScreenHandler for (int i = 0; i < 54; i++) { if (i == 0) { ItemStack close = new ItemStack(Items.TNT); - close.setCustomName(ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenBack, Formatting.DARK_RED)); + close.setHoverName(ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenBack, ChatFormatting.DARK_RED)); inv.updateStack(i, close); } else if (i == 51) { ItemStack close = new ItemStack(Items.ARROW); - close.setCustomName(ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenNext, Formatting.WHITE)); + close.setHoverName(ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenNext, ChatFormatting.WHITE)); inv.updateStack(i, close); } else if (i < 9 || i > 44 || i % 9 == 0 || i % 9 == 8) inv.updateStack(i, ServerScreenHelper.emptyFiller()); @@ -89,44 +89,44 @@ public class PermissionScreenHandler extends ServerOnlyScreenHandler for (int i = 0; i < 54; i++) { if (i == 0) { ItemStack close = new ItemStack(Items.TNT); - close.setCustomName(ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenBack, Formatting.DARK_RED)); - this.slots.get(i).setStack(close); + close.setHoverName(ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenBack, ChatFormatting.DARK_RED)); + this.slots.get(i).set(close); } else if (i == 47) { ItemStack stack = ServerScreenHelper.emptyFiller(); if (this.page >= 1) { stack = new ItemStack(Items.ARROW); - stack.setCustomName(ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenPrevious, Formatting.WHITE)); + stack.setHoverName(ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenPrevious, ChatFormatting.WHITE)); } - this.slots.get(i).setStack(stack); + this.slots.get(i).set(stack); } else if (i == 51) { ItemStack stack = ServerScreenHelper.emptyFiller(); if (this.page < this.maxPages) { stack = new ItemStack(Items.ARROW); - stack.setCustomName(ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenNext, Formatting.WHITE)); + stack.setHoverName(ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenNext, ChatFormatting.WHITE)); } - this.slots.get(i).setStack(stack); + this.slots.get(i).set(stack); } else if (i < 9 || i > 44 || i % 9 == 0 || i % 9 == 8) - this.slots.get(i).setStack(ServerScreenHelper.emptyFiller()); + this.slots.get(i).set(ServerScreenHelper.emptyFiller()); else { int row = i / 9 - 1; int id = (i % 9) + row * 7 - 1 + this.page * 28; if (id < this.perms.size()) { - this.slots.get(i).setStack(ServerScreenHelper.fromPermission(this.claim, this.perms.get(id), this.group)); + this.slots.get(i).set(ServerScreenHelper.fromPermission(this.claim, this.perms.get(id), this.group)); } else - this.slots.get(i).setStack(ItemStack.EMPTY); + this.slots.get(i).set(ItemStack.EMPTY); } } - this.sendContentUpdates(); + this.broadcastChanges(); } @Override - protected boolean handleSlotClicked(ServerPlayerEntity player, int index, Slot slot, int clickType) { + protected boolean handleSlotClicked(ServerPlayer player, int index, Slot slot, int clickType) { if (index == 0) { if (this.group == null) { - player.closeHandledScreen(); + player.closeContainer(); player.getServer().execute(() -> ClaimMenuScreenHandler.openClaimMenu(player, this.claim)); } else { - player.closeHandledScreen(); + player.closeContainer(); player.getServer().execute(() -> GroupScreenHandler.openGroupMenu(player, this.claim)); } ServerScreenHelper.playSongToPlayer(player, SoundEvents.UI_BUTTON_CLICK, 1, 1f); @@ -142,8 +142,8 @@ public class PermissionScreenHandler extends ServerOnlyScreenHandler this.flipPage(); ServerScreenHelper.playSongToPlayer(player, SoundEvents.UI_BUTTON_CLICK, 1, 1f); } - ItemStack stack = slot.getStack(); - String name = stack.getName().asString(); + ItemStack stack = slot.getItem(); + String name = stack.getHoverName().getContents(); ClaimPermission perm; try { perm = PermissionRegistry.get(name); @@ -160,11 +160,11 @@ public class PermissionScreenHandler extends ServerOnlyScreenHandler success = this.claim.editGlobalPerms(player, perm, mode); } else success = this.claim.editPerms(player, this.group, perm, this.claim.groupHasPerm(this.group, perm) + 1); - slot.setStack(ServerScreenHelper.fromPermission(this.claim, perm, this.group)); + slot.set(ServerScreenHelper.fromPermission(this.claim, perm, this.group)); if (success) - ServerScreenHelper.playSongToPlayer(player, SoundEvents.BLOCK_NOTE_BLOCK_PLING, 1, 1.2f); + ServerScreenHelper.playSongToPlayer(player, SoundEvents.NOTE_BLOCK_PLING, 1, 1.2f); else - ServerScreenHelper.playSongToPlayer(player, SoundEvents.ENTITY_VILLAGER_NO, 1, 1f); + ServerScreenHelper.playSongToPlayer(player, SoundEvents.VILLAGER_NO, 1, 1f); return true; } diff --git a/common/src/main/java/io/github/flemmli97/flan/gui/PersonalGroupScreenHandler.java b/common/src/main/java/io/github/flemmli97/flan/gui/PersonalGroupScreenHandler.java index cc74646..3110b38 100644 --- a/common/src/main/java/io/github/flemmli97/flan/gui/PersonalGroupScreenHandler.java +++ b/common/src/main/java/io/github/flemmli97/flan/gui/PersonalGroupScreenHandler.java @@ -5,17 +5,17 @@ import io.github.flemmli97.flan.claim.PermHelper; import io.github.flemmli97.flan.config.ConfigHandler; import io.github.flemmli97.flan.gui.inv.SeparateInv; import io.github.flemmli97.flan.player.PlayerClaimData; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.screen.NamedScreenHandlerFactory; -import net.minecraft.screen.ScreenHandler; -import net.minecraft.screen.slot.Slot; -import net.minecraft.server.network.ServerPlayerEntity; -import net.minecraft.sound.SoundEvents; -import net.minecraft.text.Text; -import net.minecraft.util.Formatting; +import net.minecraft.ChatFormatting; +import net.minecraft.network.chat.Component; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.sounds.SoundEvents; +import net.minecraft.world.MenuProvider; +import net.minecraft.world.entity.player.Inventory; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.inventory.AbstractContainerMenu; +import net.minecraft.world.inventory.Slot; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; import java.util.ArrayList; import java.util.List; @@ -24,52 +24,52 @@ public class PersonalGroupScreenHandler extends ServerOnlyScreenHandler private boolean removeMode; - private PersonalGroupScreenHandler(int syncId, PlayerInventory playerInventory) { + private PersonalGroupScreenHandler(int syncId, Inventory playerInventory) { super(syncId, playerInventory, 6, null); } - public static void openGroupMenu(PlayerEntity player) { - NamedScreenHandlerFactory fac = new NamedScreenHandlerFactory() { + public static void openGroupMenu(Player player) { + MenuProvider fac = new MenuProvider() { @Override - public ScreenHandler createMenu(int syncId, PlayerInventory inv, PlayerEntity player) { + public AbstractContainerMenu createMenu(int syncId, Inventory inv, Player player) { return new PersonalGroupScreenHandler(syncId, inv); } @Override - public Text getDisplayName() { + public Component getDisplayName() { return PermHelper.simpleColoredText(ConfigHandler.lang.screenPersonalGroups); } }; - player.openHandledScreen(fac); + player.openMenu(fac); } @Override - protected void fillInventoryWith(PlayerEntity player, SeparateInv inv, Object additionalData) { - if (!(player instanceof ServerPlayerEntity)) + protected void fillInventoryWith(Player player, SeparateInv inv, Object additionalData) { + if (!(player instanceof ServerPlayer)) return; for (int i = 0; i < 54; i++) { if (i == 0) { ItemStack close = new ItemStack(Items.TNT); - close.setCustomName(ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenBack, Formatting.DARK_RED)); + close.setHoverName(ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenBack, ChatFormatting.DARK_RED)); inv.updateStack(i, close); } else if (i == 3) { ItemStack stack = new ItemStack(Items.ANVIL); - stack.setCustomName(ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenAdd, Formatting.DARK_GREEN)); + stack.setHoverName(ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenAdd, ChatFormatting.DARK_GREEN)); inv.updateStack(i, stack); } else if (i == 4) { ItemStack stack = new ItemStack(Items.REDSTONE_BLOCK); - stack.setCustomName(ServerScreenHelper.coloredGuiText(String.format(ConfigHandler.lang.screenRemoveMode, this.removeMode ? ConfigHandler.lang.screenTrue : ConfigHandler.lang.screenFalse), Formatting.DARK_RED)); + stack.setHoverName(ServerScreenHelper.coloredGuiText(String.format(ConfigHandler.lang.screenRemoveMode, this.removeMode ? ConfigHandler.lang.screenTrue : ConfigHandler.lang.screenFalse), ChatFormatting.DARK_RED)); inv.updateStack(i, stack); } else if (i < 9 || i > 44 || i % 9 == 0 || i % 9 == 8) inv.updateStack(i, ServerScreenHelper.emptyFiller()); else { - List groups = new ArrayList<>(PlayerClaimData.get((ServerPlayerEntity) player).playerDefaultGroups().keySet()); + List groups = new ArrayList<>(PlayerClaimData.get((ServerPlayer) player).playerDefaultGroups().keySet()); groups.sort(null); int row = i / 9 - 1; int id = (i % 9) + row * 7 - 1; if (id < groups.size()) { ItemStack group = new ItemStack(Items.PAPER); - group.setCustomName(ServerScreenHelper.coloredGuiText(groups.get(id), Formatting.DARK_BLUE)); + group.setHoverName(ServerScreenHelper.coloredGuiText(groups.get(id), ChatFormatting.DARK_BLUE)); inv.updateStack(i, group); } } @@ -82,23 +82,23 @@ public class PersonalGroupScreenHandler extends ServerOnlyScreenHandler } @Override - protected boolean handleSlotClicked(ServerPlayerEntity player, int index, Slot slot, int clickType) { + protected boolean handleSlotClicked(ServerPlayer player, int index, Slot slot, int clickType) { if (index == 0) { - player.closeHandledScreen(); + player.closeContainer(); ServerScreenHelper.playSongToPlayer(player, SoundEvents.UI_BUTTON_CLICK, 1, 1f); return true; } if (index == 3) { - player.closeHandledScreen(); + player.closeContainer(); player.getServer().execute(() -> StringResultScreenHandler.createNewStringResult(player, (s) -> { PlayerClaimData.get(player).editDefaultPerms(s, PermissionRegistry.EDITPERMS, -1); - player.closeHandledScreen(); + player.closeContainer(); player.getServer().execute(() -> PersonalGroupScreenHandler.openGroupMenu(player)); - ServerScreenHelper.playSongToPlayer(player, SoundEvents.BLOCK_ANVIL_USE, 1, 1f); + ServerScreenHelper.playSongToPlayer(player, SoundEvents.ANVIL_USE, 1, 1f); }, () -> { - player.closeHandledScreen(); + player.closeContainer(); player.getServer().execute(() -> PersonalGroupScreenHandler.openGroupMenu(player)); - ServerScreenHelper.playSongToPlayer(player, SoundEvents.ENTITY_VILLAGER_NO, 1, 1f); + ServerScreenHelper.playSongToPlayer(player, SoundEvents.VILLAGER_NO, 1, 1f); })); ServerScreenHelper.playSongToPlayer(player, SoundEvents.UI_BUTTON_CLICK, 1, 1f); return true; @@ -106,20 +106,20 @@ public class PersonalGroupScreenHandler extends ServerOnlyScreenHandler if (index == 4) { this.removeMode = !this.removeMode; ItemStack stack = new ItemStack(Items.REDSTONE_BLOCK); - stack.setCustomName(ServerScreenHelper.coloredGuiText(String.format(ConfigHandler.lang.screenRemoveMode, this.removeMode ? ConfigHandler.lang.screenTrue : ConfigHandler.lang.screenFalse), Formatting.DARK_RED)); - slot.setStack(stack); + stack.setHoverName(ServerScreenHelper.coloredGuiText(String.format(ConfigHandler.lang.screenRemoveMode, this.removeMode ? ConfigHandler.lang.screenTrue : ConfigHandler.lang.screenFalse), ChatFormatting.DARK_RED)); + slot.set(stack); ServerScreenHelper.playSongToPlayer(player, SoundEvents.UI_BUTTON_CLICK, 1, 1f); return true; } - ItemStack stack = slot.getStack(); + ItemStack stack = slot.getItem(); if (!stack.isEmpty()) { - String name = stack.getName().asString(); + String name = stack.getHoverName().getContents(); if (this.removeMode) { PlayerClaimData.get(player).playerDefaultGroups().remove(name); - slot.setStack(ItemStack.EMPTY); - ServerScreenHelper.playSongToPlayer(player, SoundEvents.ENTITY_BAT_DEATH, 1, 1f); + slot.set(ItemStack.EMPTY); + ServerScreenHelper.playSongToPlayer(player, SoundEvents.BAT_DEATH, 1, 1f); } else { - player.closeHandledScreen(); + player.closeContainer(); player.getServer().execute(() -> PersonalPermissionScreenHandler.openClaimMenu(player, name)); ServerScreenHelper.playSongToPlayer(player, SoundEvents.UI_BUTTON_CLICK, 1, 1f); } diff --git a/common/src/main/java/io/github/flemmli97/flan/gui/PersonalPermissionScreenHandler.java b/common/src/main/java/io/github/flemmli97/flan/gui/PersonalPermissionScreenHandler.java index 8bba8ee..519bda8 100644 --- a/common/src/main/java/io/github/flemmli97/flan/gui/PersonalPermissionScreenHandler.java +++ b/common/src/main/java/io/github/flemmli97/flan/gui/PersonalPermissionScreenHandler.java @@ -6,17 +6,17 @@ import io.github.flemmli97.flan.claim.PermHelper; import io.github.flemmli97.flan.config.ConfigHandler; import io.github.flemmli97.flan.gui.inv.SeparateInv; import io.github.flemmli97.flan.player.PlayerClaimData; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.screen.NamedScreenHandlerFactory; -import net.minecraft.screen.ScreenHandler; -import net.minecraft.screen.slot.Slot; -import net.minecraft.server.network.ServerPlayerEntity; -import net.minecraft.sound.SoundEvents; -import net.minecraft.text.Text; -import net.minecraft.util.Formatting; +import net.minecraft.ChatFormatting; +import net.minecraft.network.chat.Component; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.sounds.SoundEvents; +import net.minecraft.world.MenuProvider; +import net.minecraft.world.entity.player.Inventory; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.inventory.AbstractContainerMenu; +import net.minecraft.world.inventory.Slot; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; import java.util.ArrayList; import java.util.HashMap; @@ -27,32 +27,32 @@ public class PersonalPermissionScreenHandler extends ServerOnlyScreenHandler perms = new ArrayList<>(PermissionRegistry.getPerms()); if (this.group != null) @@ -61,15 +61,15 @@ public class PersonalPermissionScreenHandler extends ServerOnlyScreenHandler 44 || i % 9 == 0 || i % 9 == 8) inv.updateStack(i, ServerScreenHelper.emptyFiller()); @@ -77,13 +77,13 @@ public class PersonalPermissionScreenHandler extends ServerOnlyScreenHandler perms = new ArrayList<>(PermissionRegistry.getPerms()); if (this.group != null) @@ -92,40 +92,40 @@ public class PersonalPermissionScreenHandler extends ServerOnlyScreenHandler= 1) { stack = new ItemStack(Items.ARROW); - stack.setCustomName(ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenPrevious, Formatting.WHITE)); + stack.setHoverName(ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenPrevious, ChatFormatting.WHITE)); } - this.slots.get(i).setStack(stack); + this.slots.get(i).set(stack); } else if (i == 51) { ItemStack stack = ServerScreenHelper.emptyFiller(); if (this.page < maxPages) { stack = new ItemStack(Items.ARROW); - stack.setCustomName(ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenNext, Formatting.WHITE)); + stack.setHoverName(ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenNext, ChatFormatting.WHITE)); } - this.slots.get(i).setStack(stack); + this.slots.get(i).set(stack); } else if (i < 9 || i > 44 || i % 9 == 0 || i % 9 == 8) - this.slots.get(i).setStack(ServerScreenHelper.emptyFiller()); + this.slots.get(i).set(ServerScreenHelper.emptyFiller()); else { int row = i / 9 - 1; int id = (i % 9) + row * 7 - 1 + this.page * 28; if (id < perms.size()) { - this.slots.get(i).setStack(ServerScreenHelper.getFromPersonal((ServerPlayerEntity) this.player, perms.get(id), this.group)); + this.slots.get(i).set(ServerScreenHelper.getFromPersonal((ServerPlayer) this.player, perms.get(id), this.group)); } else - this.slots.get(i).setStack(ItemStack.EMPTY); + this.slots.get(i).set(ItemStack.EMPTY); } } - this.sendContentUpdates(); + this.broadcastChanges(); } @Override - protected boolean handleSlotClicked(ServerPlayerEntity player, int index, Slot slot, int clickType) { + protected boolean handleSlotClicked(ServerPlayer player, int index, Slot slot, int clickType) { if (index == 0) { - player.closeHandledScreen(); + player.closeContainer(); player.getServer().execute(() -> PersonalGroupScreenHandler.openGroupMenu(player)); ServerScreenHelper.playSongToPlayer(player, SoundEvents.UI_BUTTON_CLICK, 1, 1f); return true; @@ -140,8 +140,8 @@ public class PersonalPermissionScreenHandler extends ServerOnlyScreenHandler perms = data.playerDefaultGroups().getOrDefault(this.group, new HashMap<>()); boolean success = data.editDefaultPerms(this.group, perm, (perms.containsKey(perm) ? perms.get(perm) ? 1 : 0 : -1) + 1); - slot.setStack(ServerScreenHelper.getFromPersonal(player, perm, this.group)); + slot.set(ServerScreenHelper.getFromPersonal(player, perm, this.group)); if (success) - ServerScreenHelper.playSongToPlayer(player, SoundEvents.BLOCK_NOTE_BLOCK_PLING, 1, 1.2f); + ServerScreenHelper.playSongToPlayer(player, SoundEvents.NOTE_BLOCK_PLING, 1, 1.2f); else - ServerScreenHelper.playSongToPlayer(player, SoundEvents.ENTITY_VILLAGER_NO, 1, 1f); + ServerScreenHelper.playSongToPlayer(player, SoundEvents.VILLAGER_NO, 1, 1f); return true; } diff --git a/common/src/main/java/io/github/flemmli97/flan/gui/PotionEditScreenHandler.java b/common/src/main/java/io/github/flemmli97/flan/gui/PotionEditScreenHandler.java index d020af4..f0cffa3 100644 --- a/common/src/main/java/io/github/flemmli97/flan/gui/PotionEditScreenHandler.java +++ b/common/src/main/java/io/github/flemmli97/flan/gui/PotionEditScreenHandler.java @@ -6,23 +6,23 @@ import io.github.flemmli97.flan.claim.Claim; import io.github.flemmli97.flan.claim.PermHelper; import io.github.flemmli97.flan.config.ConfigHandler; import io.github.flemmli97.flan.gui.inv.SeparateInv; -import net.minecraft.entity.effect.StatusEffect; -import net.minecraft.entity.effect.StatusEffectInstance; -import net.minecraft.entity.effect.StatusEffects; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.potion.PotionUtil; -import net.minecraft.screen.NamedScreenHandlerFactory; -import net.minecraft.screen.ScreenHandler; -import net.minecraft.screen.slot.Slot; -import net.minecraft.server.network.ServerPlayerEntity; -import net.minecraft.sound.SoundEvents; -import net.minecraft.text.Text; -import net.minecraft.text.TranslatableText; -import net.minecraft.util.Formatting; -import net.minecraft.util.Identifier; +import net.minecraft.ChatFormatting; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.TranslatableComponent; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.sounds.SoundEvents; +import net.minecraft.world.MenuProvider; +import net.minecraft.world.effect.MobEffect; +import net.minecraft.world.effect.MobEffectInstance; +import net.minecraft.world.effect.MobEffects; +import net.minecraft.world.entity.player.Inventory; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.inventory.AbstractContainerMenu; +import net.minecraft.world.inventory.Slot; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraft.world.item.alchemy.PotionUtils; import java.util.Collection; import java.util.Collections; @@ -36,43 +36,43 @@ public class PotionEditScreenHandler extends ServerOnlyScreenHandler { private boolean removeMode; - protected PotionEditScreenHandler(int syncId, PlayerInventory playerInventory, Claim claim) { + protected PotionEditScreenHandler(int syncId, Inventory playerInventory, Claim claim) { super(syncId, playerInventory, 6, claim); this.claim = claim; } - public static void openPotionMenu(PlayerEntity player, Claim claim) { - NamedScreenHandlerFactory fac = new NamedScreenHandlerFactory() { + public static void openPotionMenu(Player player, Claim claim) { + MenuProvider fac = new MenuProvider() { @Override - public ScreenHandler createMenu(int syncId, PlayerInventory inv, PlayerEntity player) { + public AbstractContainerMenu createMenu(int syncId, Inventory inv, Player player) { return new PotionEditScreenHandler(syncId, inv, claim); } @Override - public Text getDisplayName() { + public Component getDisplayName() { return PermHelper.simpleColoredText(ConfigHandler.lang.screenPotions); } }; - player.openHandledScreen(fac); + player.openMenu(fac); } @Override - protected void fillInventoryWith(PlayerEntity player, SeparateInv inv, Claim claim) { - Map potions = claim.getPotions(); - List key = Lists.newArrayList(potions.keySet()); + protected void fillInventoryWith(Player player, SeparateInv inv, Claim claim) { + Map potions = claim.getPotions(); + List key = Lists.newArrayList(potions.keySet()); key.sort(Comparator.comparing(eff -> CrossPlatformStuff.registryStatusEffects().getIDFrom(eff).toString())); for (int i = 0; i < 54; i++) { if (i == 0) { ItemStack close = new ItemStack(Items.TNT); - close.setCustomName(ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenBack, Formatting.DARK_RED)); + close.setHoverName(ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenBack, ChatFormatting.DARK_RED)); inv.updateStack(i, close); } else if (i == 3) { ItemStack stack = new ItemStack(Items.ANVIL); - stack.setCustomName(ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenAdd, Formatting.DARK_GREEN)); + stack.setHoverName(ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenAdd, ChatFormatting.DARK_GREEN)); inv.updateStack(i, stack); } else if (i == 4) { ItemStack stack = new ItemStack(Items.REDSTONE_BLOCK); - stack.setCustomName(ServerScreenHelper.coloredGuiText(String.format(ConfigHandler.lang.screenRemoveMode, this.removeMode ? ConfigHandler.lang.screenTrue : ConfigHandler.lang.screenFalse), Formatting.DARK_RED)); + stack.setHoverName(ServerScreenHelper.coloredGuiText(String.format(ConfigHandler.lang.screenRemoveMode, this.removeMode ? ConfigHandler.lang.screenTrue : ConfigHandler.lang.screenFalse), ChatFormatting.DARK_RED)); inv.updateStack(i, stack); } else if (i < 9 || i > 44 || i % 9 == 0 || i % 9 == 8) inv.updateStack(i, ServerScreenHelper.emptyFiller()); @@ -80,13 +80,13 @@ public class PotionEditScreenHandler extends ServerOnlyScreenHandler { int row = i / 9 - 1; int id = (i % 9) + row * 7 - 1; if (id < potions.size()) { - StatusEffect effect = key.get(id); + MobEffect effect = key.get(id); ItemStack effectStack = new ItemStack(Items.POTION); - TranslatableText txt = new TranslatableText(effect.getTranslationKey()); - Collection inst = Collections.singleton(new StatusEffectInstance(effect, 0, potions.get(effect))); + TranslatableComponent txt = new TranslatableComponent(effect.getDescriptionId()); + Collection inst = Collections.singleton(new MobEffectInstance(effect, 0, potions.get(effect))); effectStack.getOrCreateTag().putString("FlanEffect", CrossPlatformStuff.registryStatusEffects().getIDFrom(effect).toString()); - effectStack.getTag().putInt("CustomPotionColor", PotionUtil.getColor(inst)); - effectStack.setCustomName(txt.setStyle(txt.getStyle().withItalic(false).withFormatting(Formatting.DARK_BLUE)).append(ServerScreenHelper.coloredGuiText("-" + potions.get(effect), Formatting.DARK_BLUE))); + effectStack.getTag().putInt("CustomPotionColor", PotionUtils.getColor(inst)); + effectStack.setHoverName(txt.setStyle(txt.getStyle().withItalic(false).applyFormat(ChatFormatting.DARK_BLUE)).append(ServerScreenHelper.coloredGuiText("-" + potions.get(effect), ChatFormatting.DARK_BLUE))); inv.updateStack(i, effectStack); } } @@ -99,21 +99,21 @@ public class PotionEditScreenHandler extends ServerOnlyScreenHandler { } @Override - protected boolean handleSlotClicked(ServerPlayerEntity player, int index, Slot slot, int clickType) { + protected boolean handleSlotClicked(ServerPlayer player, int index, Slot slot, int clickType) { if (index == 0) { - player.closeHandledScreen(); + player.closeContainer(); player.getServer().execute(() -> ClaimMenuScreenHandler.openClaimMenu(player, this.claim)); ServerScreenHelper.playSongToPlayer(player, SoundEvents.UI_BUTTON_CLICK, 1, 1f); return true; } if (index == 3) { - player.closeHandledScreen(); + player.closeContainer(); player.getServer().execute(() -> StringResultScreenHandler.createNewStringResult(player, (s) -> { String[] potion = s.split(";"); int amp = 1; - StatusEffect effect = CrossPlatformStuff.registryStatusEffects().getFromId(new Identifier(potion[0])); - if (effect == null || (effect == StatusEffects.LUCK && !potion[0].equals("minecraft:luck"))) { - ServerScreenHelper.playSongToPlayer(player, SoundEvents.ENTITY_VILLAGER_NO, 1, 1f); + MobEffect effect = CrossPlatformStuff.registryStatusEffects().getFromId(new ResourceLocation(potion[0])); + if (effect == null || (effect == MobEffects.LUCK && !potion[0].equals("minecraft:luck"))) { + ServerScreenHelper.playSongToPlayer(player, SoundEvents.VILLAGER_NO, 1, 1f); return; } if (potion.length > 1) { @@ -123,13 +123,13 @@ public class PotionEditScreenHandler extends ServerOnlyScreenHandler { } } this.claim.addPotion(effect, amp); - player.closeHandledScreen(); + player.closeContainer(); player.getServer().execute(() -> PotionEditScreenHandler.openPotionMenu(player, this.claim)); - ServerScreenHelper.playSongToPlayer(player, SoundEvents.BLOCK_ANVIL_USE, 1, 1f); + ServerScreenHelper.playSongToPlayer(player, SoundEvents.ANVIL_USE, 1, 1f); }, () -> { - player.closeHandledScreen(); + player.closeContainer(); player.getServer().execute(() -> PotionEditScreenHandler.openPotionMenu(player, this.claim)); - ServerScreenHelper.playSongToPlayer(player, SoundEvents.ENTITY_VILLAGER_NO, 1, 1f); + ServerScreenHelper.playSongToPlayer(player, SoundEvents.VILLAGER_NO, 1, 1f); })); ServerScreenHelper.playSongToPlayer(player, SoundEvents.UI_BUTTON_CLICK, 1, 1f); return true; @@ -137,17 +137,17 @@ public class PotionEditScreenHandler extends ServerOnlyScreenHandler { if (index == 4) { this.removeMode = !this.removeMode; ItemStack stack = new ItemStack(Items.REDSTONE_BLOCK); - stack.setCustomName(ServerScreenHelper.coloredGuiText(String.format(ConfigHandler.lang.screenRemoveMode, this.removeMode ? ConfigHandler.lang.screenTrue : ConfigHandler.lang.screenFalse), Formatting.DARK_RED)); - slot.setStack(stack); + stack.setHoverName(ServerScreenHelper.coloredGuiText(String.format(ConfigHandler.lang.screenRemoveMode, this.removeMode ? ConfigHandler.lang.screenTrue : ConfigHandler.lang.screenFalse), ChatFormatting.DARK_RED)); + slot.set(stack); ServerScreenHelper.playSongToPlayer(player, SoundEvents.UI_BUTTON_CLICK, 1, 1f); return true; } - ItemStack stack = slot.getStack(); + ItemStack stack = slot.getItem(); if (!stack.isEmpty() && this.removeMode) { String effect = stack.getOrCreateTag().getString("FlanEffect"); - this.claim.removePotion(CrossPlatformStuff.registryStatusEffects().getFromId(new Identifier(effect))); - slot.setStack(ItemStack.EMPTY); - ServerScreenHelper.playSongToPlayer(player, SoundEvents.ENTITY_BAT_DEATH, 1, 1f); + this.claim.removePotion(CrossPlatformStuff.registryStatusEffects().getFromId(new ResourceLocation(effect))); + slot.set(ItemStack.EMPTY); + ServerScreenHelper.playSongToPlayer(player, SoundEvents.BAT_DEATH, 1, 1f); } return false; } diff --git a/common/src/main/java/io/github/flemmli97/flan/gui/ServerOnlyScreenHandler.java b/common/src/main/java/io/github/flemmli97/flan/gui/ServerOnlyScreenHandler.java index 5665ed2..bf984a5 100644 --- a/common/src/main/java/io/github/flemmli97/flan/gui/ServerOnlyScreenHandler.java +++ b/common/src/main/java/io/github/flemmli97/flan/gui/ServerOnlyScreenHandler.java @@ -3,27 +3,24 @@ package io.github.flemmli97.flan.gui; import io.github.flemmli97.flan.gui.inv.SeparateInv; import io.github.flemmli97.flan.gui.inv.SeparateInvImpl; import io.github.flemmli97.flan.gui.inv.SlotDelegate; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.screen.GenericContainerScreenHandler; -import net.minecraft.screen.ScreenHandler; -import net.minecraft.screen.ScreenHandlerListener; -import net.minecraft.screen.ScreenHandlerType; -import net.minecraft.screen.slot.Slot; -import net.minecraft.screen.slot.SlotActionType; -import net.minecraft.server.network.ServerPlayerEntity; +import io.github.flemmli97.flan.mixin.AbstractContainerAccessor; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.entity.player.Inventory; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.inventory.AbstractContainerMenu; +import net.minecraft.world.inventory.ChestMenu; +import net.minecraft.world.inventory.ClickType; +import net.minecraft.world.inventory.ContainerListener; +import net.minecraft.world.inventory.MenuType; +import net.minecraft.world.inventory.Slot; +import net.minecraft.world.item.ItemStack; -import java.util.ArrayList; -import java.util.List; - -public abstract class ServerOnlyScreenHandler extends ScreenHandler { +public abstract class ServerOnlyScreenHandler extends AbstractContainerMenu { private final SeparateInvImpl inventory; - private final List listeners = new ArrayList<>(); private boolean update = true; - protected ServerOnlyScreenHandler(int syncId, PlayerInventory playerInventory, int rows, T additionalData) { + protected ServerOnlyScreenHandler(int syncId, Inventory playerInventory, int rows, T additionalData) { super(fromRows(rows), syncId); int i = (rows - 4) * 18; this.inventory = new SeparateInvImpl(rows * 9); @@ -40,12 +37,12 @@ public abstract class ServerOnlyScreenHandler extends ScreenHandler { for (m = 0; m < 9; ++m) { this.addSlot(new Slot(playerInventory, m + n * 9 + 9, 8 + m * 18, 103 + n * 18 + i) { @Override - public boolean canInsert(ItemStack stack) { + public boolean mayPlace(ItemStack stack) { return false; } @Override - public boolean canTakeItems(PlayerEntity playerEntity) { + public boolean mayPickup(Player playerEntity) { return false; } }); @@ -55,81 +52,82 @@ public abstract class ServerOnlyScreenHandler extends ScreenHandler { for (n = 0; n < 9; ++n) { this.addSlot(new Slot(playerInventory, n, 8 + n * 18, 161 + i) { @Override - public boolean canInsert(ItemStack stack) { + public boolean mayPlace(ItemStack stack) { return false; } @Override - public boolean canTakeItems(PlayerEntity playerEntity) { + public boolean mayPickup(Player playerEntity) { return false; } }); } } - private static ScreenHandlerType fromRows(int rows) { + private static MenuType fromRows(int rows) { switch (rows) { case 2: - return ScreenHandlerType.GENERIC_9X2; + return MenuType.GENERIC_9x2; case 3: - return ScreenHandlerType.GENERIC_9X3; + return MenuType.GENERIC_9x3; case 4: - return ScreenHandlerType.GENERIC_9X4; + return MenuType.GENERIC_9x4; case 5: - return ScreenHandlerType.GENERIC_9X5; + return MenuType.GENERIC_9x5; case 6: - return ScreenHandlerType.GENERIC_9X6; + return MenuType.GENERIC_9x6; } - return ScreenHandlerType.GENERIC_9X1; + return MenuType.GENERIC_9x1; } - protected abstract void fillInventoryWith(PlayerEntity player, SeparateInv inv, T additionalData); + protected abstract void fillInventoryWith(Player player, SeparateInv inv, T additionalData); @Override - public boolean canUse(PlayerEntity player) { + public boolean stillValid(Player player) { return true; } @Override - public ItemStack onSlotClick(int i, int j, SlotActionType actionType, PlayerEntity playerEntity) { + public void clicked(int i, int j, ClickType actionType, Player playerEntity) { if (i < 0) - return ItemStack.EMPTY; + return; Slot slot = this.slots.get(i); - if (this.isRightSlot(i)) - this.handleSlotClicked((ServerPlayerEntity) playerEntity, i, slot, j); - ItemStack stack = slot.getStack().copy(); - for (ScreenHandlerListener listener : this.listeners) - listener.onSlotUpdate(this, i, stack); - ((ServerPlayerEntity) playerEntity).updateCursorStack(); - return stack; + if (this.isRightSlot(i)) { + if (((AbstractContainerAccessor) this).containerSync() != null) + ((AbstractContainerAccessor) this).containerSync().sendCarriedChange(this, this.getCarried().copy()); + this.handleSlotClicked((ServerPlayer) playerEntity, i, slot, j); + } + ItemStack stack = slot.getItem().copy(); + for (ContainerListener listener : ((AbstractContainerAccessor) this).listeners()) + listener.slotChanged(this, i, stack); } @Override - public ItemStack transferSlot(PlayerEntity player, int index) { + public ItemStack quickMoveStack(Player player, int index) { if (index < 0) return ItemStack.EMPTY; Slot slot = this.slots.get(index); if (this.isRightSlot(index)) - this.handleSlotClicked((ServerPlayerEntity) player, index, slot, 0); - return slot.getStack().copy(); + this.handleSlotClicked((ServerPlayer) player, index, slot, 0); + return slot.getItem().copy(); } - @Override - public void addListener(ScreenHandlerListener listener) { + /*@Override + public void addSlotListener(ContainerListener listener) { this.update = false; - super.addListener(listener); + super.addSlotListener(listener); if (!this.listeners.contains(listener)) { this.listeners.add(listener); - listener.onHandlerRegistered(this, this.getStacks()); + listener.refreshContainer(this, this.getItems()); this.update = true; - this.sendContentUpdates(); + this.broadcastChanges(); } - } + }*/ @Override - public void sendContentUpdates() { - if (this.update) - super.sendContentUpdates(); + public void broadcastChanges() { + //if (this.update) + super.broadcastChanges(); } protected abstract boolean isRightSlot(int slot); @@ -137,5 +135,5 @@ public abstract class ServerOnlyScreenHandler extends ScreenHandler { /** * @param clickType 0 for left click, 1 for right click */ - protected abstract boolean handleSlotClicked(ServerPlayerEntity player, int index, Slot slot, int clickType); + protected abstract boolean handleSlotClicked(ServerPlayer player, int index, Slot slot, int clickType); } diff --git a/common/src/main/java/io/github/flemmli97/flan/gui/ServerScreenHelper.java b/common/src/main/java/io/github/flemmli97/flan/gui/ServerScreenHelper.java index 701d1ee..f5794ac 100644 --- a/common/src/main/java/io/github/flemmli97/flan/gui/ServerScreenHelper.java +++ b/common/src/main/java/io/github/flemmli97/flan/gui/ServerScreenHelper.java @@ -6,18 +6,18 @@ import io.github.flemmli97.flan.claim.PermHelper; import io.github.flemmli97.flan.config.Config; import io.github.flemmli97.flan.config.ConfigHandler; import io.github.flemmli97.flan.player.PlayerClaimData; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; +import net.minecraft.ChatFormatting; import net.minecraft.nbt.ListTag; import net.minecraft.nbt.StringTag; -import net.minecraft.network.packet.s2c.play.PlaySoundS2CPacket; -import net.minecraft.server.network.ServerPlayerEntity; -import net.minecraft.sound.SoundCategory; -import net.minecraft.sound.SoundEvent; -import net.minecraft.text.LiteralText; -import net.minecraft.text.Style; -import net.minecraft.text.Text; -import net.minecraft.util.Formatting; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.Style; +import net.minecraft.network.chat.TextComponent; +import net.minecraft.network.protocol.game.ClientboundSoundPacket; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.sounds.SoundEvent; +import net.minecraft.sounds.SoundSource; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; import java.util.ArrayList; import java.util.HashMap; @@ -28,24 +28,24 @@ public class ServerScreenHelper { public static ItemStack emptyFiller() { ItemStack stack = new ItemStack(Items.GRAY_STAINED_GLASS_PANE); - stack.setCustomName(PermHelper.simpleColoredText("")); + stack.setHoverName(PermHelper.simpleColoredText("")); return stack; } public static ItemStack fromPermission(Claim claim, ClaimPermission perm, String group) { ItemStack stack = perm.getItem(); - stack.setCustomName(ServerScreenHelper.coloredGuiText(perm.id, Formatting.GOLD)); - List lore = new ArrayList<>(); + stack.setHoverName(ServerScreenHelper.coloredGuiText(perm.id, ChatFormatting.GOLD)); + List lore = new ArrayList<>(); for (String pdesc : perm.desc) { - Text trans = ServerScreenHelper.coloredGuiText(pdesc, Formatting.YELLOW); + Component trans = ServerScreenHelper.coloredGuiText(pdesc, ChatFormatting.YELLOW); lore.add(trans); } Config.GlobalType global = ConfigHandler.config.getGlobal(claim.getWorld(), perm); if (!claim.isAdminClaim() && !global.canModify()) { - Text text = ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenUneditable, Formatting.DARK_RED); + Component text = ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenUneditable, ChatFormatting.DARK_RED); lore.add(text); String permFlag = global.getValue() ? ConfigHandler.lang.screenTrue : ConfigHandler.lang.screenFalse; - Text text2 = ServerScreenHelper.coloredGuiText(String.format(ConfigHandler.lang.screenEnableText, permFlag), permFlag.equals(ConfigHandler.lang.screenTrue) ? Formatting.GREEN : Formatting.RED); + Component text2 = ServerScreenHelper.coloredGuiText(String.format(ConfigHandler.lang.screenEnableText, permFlag), permFlag.equals(ConfigHandler.lang.screenTrue) ? ChatFormatting.GREEN : ChatFormatting.RED); lore.add(text2); } else { String permFlag; @@ -78,28 +78,28 @@ public class ServerScreenHelper { break; } } - Text text = ServerScreenHelper.coloredGuiText(String.format(ConfigHandler.lang.screenEnableText, permFlag), permFlag.equals(ConfigHandler.lang.screenTrue) ? Formatting.GREEN : Formatting.RED); + Component text = ServerScreenHelper.coloredGuiText(String.format(ConfigHandler.lang.screenEnableText, permFlag), permFlag.equals(ConfigHandler.lang.screenTrue) ? ChatFormatting.GREEN : ChatFormatting.RED); lore.add(text); } addLore(stack, lore); return stack; } - public static ItemStack getFromPersonal(ServerPlayerEntity player, ClaimPermission perm, String group) { + public static ItemStack getFromPersonal(ServerPlayer player, ClaimPermission perm, String group) { ItemStack stack = perm.getItem(); - stack.setCustomName(ServerScreenHelper.coloredGuiText(perm.id, Formatting.GOLD)); + stack.setHoverName(ServerScreenHelper.coloredGuiText(perm.id, ChatFormatting.GOLD)); ListTag lore = new ListTag(); for (String pdesc : perm.desc) { - Text trans = ServerScreenHelper.coloredGuiText(pdesc, Formatting.YELLOW); - lore.add(StringTag.of(Text.Serializer.toJson(trans))); + Component trans = ServerScreenHelper.coloredGuiText(pdesc, ChatFormatting.YELLOW); + lore.add(StringTag.valueOf(Component.Serializer.toJson(trans))); } - Config.GlobalType global = ConfigHandler.config.getGlobal(player.getServerWorld(), perm); + Config.GlobalType global = ConfigHandler.config.getGlobal(player.getLevel(), perm); if (!global.canModify()) { - Text text = ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenUneditable, Formatting.DARK_RED); - lore.add(StringTag.of(Text.Serializer.toJson(text))); + Component text = ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenUneditable, ChatFormatting.DARK_RED); + lore.add(StringTag.valueOf(Component.Serializer.toJson(text))); String permFlag = String.valueOf(global.getValue()); - Text text2 = ServerScreenHelper.coloredGuiText(String.format(ConfigHandler.lang.screenEnableText, permFlag), permFlag.equals(ConfigHandler.lang.screenTrue) ? Formatting.GREEN : Formatting.RED); - lore.add(StringTag.of(Text.Serializer.toJson(text2))); + Component text2 = ServerScreenHelper.coloredGuiText(String.format(ConfigHandler.lang.screenEnableText, permFlag), permFlag.equals(ConfigHandler.lang.screenTrue) ? ChatFormatting.GREEN : ChatFormatting.RED); + lore.add(StringTag.valueOf(Component.Serializer.toJson(text2))); } else { String permFlag; Map map = PlayerClaimData.get(player).playerDefaultGroups().getOrDefault(group, new HashMap<>()); @@ -107,31 +107,31 @@ public class ServerScreenHelper { permFlag = map.get(perm) ? ConfigHandler.lang.screenTrue : ConfigHandler.lang.screenFalse; else permFlag = ConfigHandler.lang.screenDefault; - Text text = ServerScreenHelper.coloredGuiText(String.format(ConfigHandler.lang.screenEnableText, permFlag), permFlag.equals(ConfigHandler.lang.screenTrue) ? Formatting.GREEN : Formatting.RED); - lore.add(StringTag.of(Text.Serializer.toJson(text))); + Component text = ServerScreenHelper.coloredGuiText(String.format(ConfigHandler.lang.screenEnableText, permFlag), permFlag.equals(ConfigHandler.lang.screenTrue) ? ChatFormatting.GREEN : ChatFormatting.RED); + lore.add(StringTag.valueOf(Component.Serializer.toJson(text))); } - stack.getOrCreateSubTag("display").put("Lore", lore); + stack.getOrCreateTagElement("display").put("Lore", lore); return stack; } - public static void playSongToPlayer(ServerPlayerEntity player, SoundEvent event, float vol, float pitch) { - player.networkHandler.sendPacket( - new PlaySoundS2CPacket(event, SoundCategory.PLAYERS, player.getPos().x, player.getPos().y, player.getPos().z, vol, pitch)); + public static void playSongToPlayer(ServerPlayer player, SoundEvent event, float vol, float pitch) { + player.connection.send( + new ClientboundSoundPacket(event, SoundSource.PLAYERS, player.position().x, player.position().y, player.position().z, vol, pitch)); } - public static Text coloredGuiText(String text, Formatting... formattings) { - return new LiteralText(text).setStyle(Style.EMPTY.withItalic(false).withFormatting(formattings)); + public static Component coloredGuiText(String text, ChatFormatting... formattings) { + return new TextComponent(text).setStyle(Style.EMPTY.withItalic(false).applyFormats(formattings)); } - public static void addLore(ItemStack stack, Text text) { + public static void addLore(ItemStack stack, Component text) { ListTag lore = new ListTag(); - lore.add(StringTag.of(Text.Serializer.toJson(text))); - stack.getOrCreateSubTag("display").put("Lore", lore); + lore.add(StringTag.valueOf(Component.Serializer.toJson(text))); + stack.getOrCreateTagElement("display").put("Lore", lore); } - public static void addLore(ItemStack stack, List texts) { + public static void addLore(ItemStack stack, List texts) { ListTag lore = new ListTag(); - texts.forEach(text -> lore.add(StringTag.of(Text.Serializer.toJson(text)))); - stack.getOrCreateSubTag("display").put("Lore", lore); + texts.forEach(text -> lore.add(StringTag.valueOf(Component.Serializer.toJson(text)))); + stack.getOrCreateTagElement("display").put("Lore", lore); } } diff --git a/common/src/main/java/io/github/flemmli97/flan/gui/StringResultScreenHandler.java b/common/src/main/java/io/github/flemmli97/flan/gui/StringResultScreenHandler.java index c5ab7a6..8bb44ec 100644 --- a/common/src/main/java/io/github/flemmli97/flan/gui/StringResultScreenHandler.java +++ b/common/src/main/java/io/github/flemmli97/flan/gui/StringResultScreenHandler.java @@ -2,28 +2,29 @@ package io.github.flemmli97.flan.gui; import io.github.flemmli97.flan.claim.PermHelper; import io.github.flemmli97.flan.config.ConfigHandler; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.network.packet.s2c.play.ExperienceBarUpdateS2CPacket; -import net.minecraft.screen.AnvilScreenHandler; -import net.minecraft.screen.NamedScreenHandlerFactory; -import net.minecraft.screen.ScreenHandler; -import net.minecraft.screen.ScreenHandlerListener; -import net.minecraft.screen.slot.Slot; -import net.minecraft.screen.slot.SlotActionType; -import net.minecraft.server.network.ServerPlayerEntity; -import net.minecraft.text.Text; +import io.github.flemmli97.flan.mixin.AbstractContainerAccessor; +import net.minecraft.network.chat.Component; +import net.minecraft.network.protocol.game.ClientboundSetExperiencePacket; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.MenuProvider; +import net.minecraft.world.entity.player.Inventory; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.inventory.AbstractContainerMenu; +import net.minecraft.world.inventory.AnvilMenu; +import net.minecraft.world.inventory.ClickType; +import net.minecraft.world.inventory.ContainerListener; +import net.minecraft.world.inventory.Slot; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; import org.apache.commons.lang3.StringUtils; import java.util.ArrayList; import java.util.List; import java.util.function.Consumer; -public class StringResultScreenHandler extends AnvilScreenHandler { +public class StringResultScreenHandler extends AnvilMenu { - private final List listeners = new ArrayList<>(); + private final List listeners = new ArrayList<>(); private final Consumer cons; private final Runnable ret; @@ -31,119 +32,119 @@ public class StringResultScreenHandler extends AnvilScreenHandler { private boolean init; private String name; - private StringResultScreenHandler(int syncId, PlayerInventory playerInventory, Consumer cons, Runnable ret) { + private StringResultScreenHandler(int syncId, Inventory playerInventory, Consumer cons, Runnable ret) { super(syncId, playerInventory); ItemStack stack = new ItemStack(Items.PAPER); - stack.setCustomName(PermHelper.simpleColoredText("")); - this.input.setStack(0, stack); + stack.setHoverName(PermHelper.simpleColoredText("")); + this.inputSlots.setItem(0, stack); ItemStack out = new ItemStack(Items.BOOK); - out.setCustomName(ServerScreenHelper.coloredGuiText(ConfigHandler.lang.stringScreenReturn)); - this.output.setStack(0, out); + out.setHoverName(ServerScreenHelper.coloredGuiText(ConfigHandler.lang.stringScreenReturn)); + this.resultSlots.setItem(0, out); this.cons = cons; this.ret = ret; } - public static void createNewStringResult(PlayerEntity player, Consumer cons, Runnable ret) { - NamedScreenHandlerFactory fac = new NamedScreenHandlerFactory() { + public static void createNewStringResult(Player player, Consumer cons, Runnable ret) { + MenuProvider fac = new MenuProvider() { @Override - public ScreenHandler createMenu(int syncId, PlayerInventory inv, PlayerEntity player) { + public AbstractContainerMenu createMenu(int syncId, Inventory inv, Player player) { return new StringResultScreenHandler(syncId, inv, cons, ret); } @Override - public Text getDisplayName() { + public Component getDisplayName() { return PermHelper.simpleColoredText(""); } }; - player.openHandledScreen(fac); + player.openMenu(fac); } @Override - public boolean canUse(PlayerEntity player) { + public boolean stillValid(Player player) { return true; } @Override - protected boolean canTakeOutput(PlayerEntity player, boolean present) { + protected boolean mayPickup(Player player, boolean present) { return true; } @Override - public ItemStack onSlotClick(int i, int j, SlotActionType actionType, PlayerEntity playerEntity) { - if (i < 0 || !(playerEntity instanceof ServerPlayerEntity)) - return ItemStack.EMPTY; - ServerPlayerEntity player = (ServerPlayerEntity) playerEntity; + public void clicked(int i, int j, ClickType actionType, Player playerEntity) { + if (i < 0 || !(playerEntity instanceof ServerPlayer)) + return; + ServerPlayer player = (ServerPlayer) playerEntity; Slot slot = this.slots.get(i); + if (((AbstractContainerAccessor) this).containerSync() != null) + ((AbstractContainerAccessor) this).containerSync().sendCarriedChange(this, this.getCarried().copy()); if (i == 0) this.ret.run(); else if (i == 2) { - String s = slot.getStack().hasCustomName() ? slot.getStack().getName().asString() : ""; + String s = slot.getItem().hasCustomHoverName() ? slot.getItem().getHoverName().getContents() : ""; if (!s.isEmpty() && !s.equals(ConfigHandler.lang.stringScreenReturn)) { this.cons.accept(s); } - player.networkHandler.sendPacket(new ExperienceBarUpdateS2CPacket(player.experienceProgress, player.totalExperience, player.experienceLevel)); + player.connection.send(new ClientboundSetExperiencePacket(player.experienceProgress, player.totalExperience, player.experienceLevel)); } - this.sendContentUpdates(); - player.updateCursorStack(); - return slot.getStack(); + this.broadcastChanges(); } @Override - public ItemStack transferSlot(PlayerEntity player, int index) { - if (!(player instanceof ServerPlayerEntity)) + public ItemStack quickMoveStack(Player player, int index) { + if (!(player instanceof ServerPlayer)) return ItemStack.EMPTY; if (index == 0) this.ret.run(); else if (index == 2) { Slot slot = this.slots.get(index); - String s = slot.getStack().hasCustomName() ? slot.getStack().getName().asString() : ""; + String s = slot.getItem().hasCustomHoverName() ? slot.getItem().getHoverName().getContents() : ""; if (!s.isEmpty() && !s.equals(ConfigHandler.lang.stringScreenReturn)) this.cons.accept(s); - ((ServerPlayerEntity) player).networkHandler.sendPacket(new ExperienceBarUpdateS2CPacket(player.experienceProgress, player.totalExperience, player.experienceLevel)); + ((ServerPlayer) player).connection.send(new ClientboundSetExperiencePacket(player.experienceProgress, player.totalExperience, player.experienceLevel)); } - this.sendContentUpdates(); + this.broadcastChanges(); return ItemStack.EMPTY; } - +/* @Override - public void addListener(ScreenHandlerListener listener) { + public void addSlotListener(ContainerListener listener) { if (!this.listeners.contains(listener)) { this.listeners.add(listener); - listener.onHandlerRegistered(this, this.getStacks()); - this.sendContentUpdates(); + listener.refreshContainer(this, this.getItems()); + this.broadcastChanges(); } - } + }*/ @Override - public void sendContentUpdates() { + public void broadcastChanges() { int j; for (j = 0; j < this.slots.size(); ++j) { - ItemStack itemStack = this.slots.get(j).getStack(); + ItemStack itemStack = this.slots.get(j).getItem(); - for (ScreenHandlerListener screenHandlerListener : this.listeners) { - screenHandlerListener.onSlotUpdate(this, j, itemStack.copy()); + for (ContainerListener screenHandlerListener : this.listeners) { + screenHandlerListener.slotChanged(this, j, itemStack.copy()); } } } @Override - public void updateResult() { + public void createResult() { if (!this.init) this.init = true; else { - ItemStack out = this.slots.get(2).getStack(); + ItemStack out = this.slots.get(2).getItem(); if (StringUtils.isBlank(this.name)) - out.removeCustomName(); - else if (!this.name.equals(out.getName().getString())) { - out.setCustomName(ServerScreenHelper.coloredGuiText(this.name)); + out.resetHoverName(); + else if (!this.name.equals(out.getHoverName().getString())) { + out.setHoverName(ServerScreenHelper.coloredGuiText(this.name)); } } - this.sendContentUpdates(); + this.broadcastChanges(); } @Override - public void setNewItemName(String string) { + public void setItemName(String string) { this.name = string; - this.updateResult(); + this.createResult(); } } diff --git a/common/src/main/java/io/github/flemmli97/flan/gui/inv/SeparateInv.java b/common/src/main/java/io/github/flemmli97/flan/gui/inv/SeparateInv.java index ba83405..264c39f 100644 --- a/common/src/main/java/io/github/flemmli97/flan/gui/inv/SeparateInv.java +++ b/common/src/main/java/io/github/flemmli97/flan/gui/inv/SeparateInv.java @@ -1,6 +1,6 @@ package io.github.flemmli97.flan.gui.inv; -import net.minecraft.item.ItemStack; +import net.minecraft.world.item.ItemStack; /** * This ensures that other mods will never be able to modify and get items from the inventory. diff --git a/common/src/main/java/io/github/flemmli97/flan/gui/inv/SeparateInvImpl.java b/common/src/main/java/io/github/flemmli97/flan/gui/inv/SeparateInvImpl.java index 2471b84..d159d38 100644 --- a/common/src/main/java/io/github/flemmli97/flan/gui/inv/SeparateInvImpl.java +++ b/common/src/main/java/io/github/flemmli97/flan/gui/inv/SeparateInvImpl.java @@ -1,71 +1,71 @@ package io.github.flemmli97.flan.gui.inv; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.inventory.SimpleInventory; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; +import net.minecraft.world.SimpleContainer; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; import java.util.ArrayList; import java.util.List; -public class SeparateInvImpl extends SimpleInventory implements SeparateInv { +public class SeparateInvImpl extends SimpleContainer implements SeparateInv { public SeparateInvImpl(int size) { super(size); } @Override - public ItemStack getStack(int slot) { + public ItemStack getItem(int slot) { return ItemStack.EMPTY; } @Override - public List clearToList() { + public List removeAllItems() { return new ArrayList<>(); } @Override - public ItemStack removeStack(int slot, int amount) { + public ItemStack removeItem(int slot, int amount) { return ItemStack.EMPTY; } @Override - public ItemStack removeItem(Item item, int count) { + public ItemStack removeItemType(Item item, int count) { return ItemStack.EMPTY; } @Override - public ItemStack addStack(ItemStack stack) { + public ItemStack addItem(ItemStack stack) { return stack; } @Override - public boolean canInsert(ItemStack stack) { + public boolean canAddItem(ItemStack stack) { return false; } @Override - public ItemStack removeStack(int slot) { + public ItemStack removeItemNoUpdate(int slot) { return ItemStack.EMPTY; } @Override - public void setStack(int slot, ItemStack stack) { + public void setItem(int slot, ItemStack stack) { } @Override - public boolean canPlayerUse(PlayerEntity player) { + public boolean stillValid(Player player) { return false; } @Override public void updateStack(int slot, ItemStack stack) { - super.setStack(slot, stack); + super.setItem(slot, stack); } @Override public ItemStack getActualStack(int slot) { - return super.getStack(slot); + return super.getItem(slot); } } diff --git a/common/src/main/java/io/github/flemmli97/flan/gui/inv/SlotDelegate.java b/common/src/main/java/io/github/flemmli97/flan/gui/inv/SlotDelegate.java index 14b958d..ff88f62 100644 --- a/common/src/main/java/io/github/flemmli97/flan/gui/inv/SlotDelegate.java +++ b/common/src/main/java/io/github/flemmli97/flan/gui/inv/SlotDelegate.java @@ -1,8 +1,8 @@ package io.github.flemmli97.flan.gui.inv; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.screen.slot.Slot; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.inventory.Slot; +import net.minecraft.world.item.ItemStack; public class SlotDelegate extends Slot { @@ -14,22 +14,22 @@ public class SlotDelegate extends Slot { } @Override - public void setStack(ItemStack stack) { - ((SeparateInvImpl) this.inventory).updateStack(this.index, stack); + public void set(ItemStack stack) { + ((SeparateInvImpl) this.container).updateStack(this.index, stack); } @Override - public ItemStack getStack() { - return ((SeparateInvImpl) this.inventory).getActualStack(this.index); + public ItemStack getItem() { + return ((SeparateInvImpl) this.container).getActualStack(this.index); } @Override - public boolean canInsert(ItemStack stack) { + public boolean mayPlace(ItemStack stack) { return false; } @Override - public boolean canTakeItems(PlayerEntity playerEntity) { + public boolean mayPickup(Player playerEntity) { return false; } } diff --git a/common/src/main/java/io/github/flemmli97/flan/integration/currency/CommandCurrency.java b/common/src/main/java/io/github/flemmli97/flan/integration/currency/CommandCurrency.java index 69a85ac..95df202 100644 --- a/common/src/main/java/io/github/flemmli97/flan/integration/currency/CommandCurrency.java +++ b/common/src/main/java/io/github/flemmli97/flan/integration/currency/CommandCurrency.java @@ -2,18 +2,18 @@ package io.github.flemmli97.flan.integration.currency; import com.mojang.brigadier.context.CommandContext; import com.mojang.brigadier.exceptions.CommandSyntaxException; -import me.shedaniel.architectury.annotations.ExpectPlatform; -import net.minecraft.server.command.ServerCommandSource; +import dev.architectury.injectables.annotations.ExpectPlatform; +import net.minecraft.commands.CommandSourceStack; public class CommandCurrency { @ExpectPlatform - public static int sellClaimBlocks(CommandContext context) throws CommandSyntaxException { + public static int sellClaimBlocks(CommandContext context) throws CommandSyntaxException { throw new AssertionError(); } @ExpectPlatform - public static int buyClaimBlocks(CommandContext context) throws CommandSyntaxException { + public static int buyClaimBlocks(CommandContext context) throws CommandSyntaxException { throw new AssertionError(); } } diff --git a/common/src/main/java/io/github/flemmli97/flan/integration/permissions/PermissionNodeHandler.java b/common/src/main/java/io/github/flemmli97/flan/integration/permissions/PermissionNodeHandler.java index 1d65d52..881994f 100644 --- a/common/src/main/java/io/github/flemmli97/flan/integration/permissions/PermissionNodeHandler.java +++ b/common/src/main/java/io/github/flemmli97/flan/integration/permissions/PermissionNodeHandler.java @@ -1,8 +1,8 @@ package io.github.flemmli97.flan.integration.permissions; -import me.shedaniel.architectury.annotations.ExpectPlatform; -import net.minecraft.server.command.ServerCommandSource; -import net.minecraft.server.network.ServerPlayerEntity; +import dev.architectury.injectables.annotations.ExpectPlatform; +import net.minecraft.commands.CommandSourceStack; +import net.minecraft.server.level.ServerPlayer; public class PermissionNodeHandler { @@ -47,22 +47,22 @@ public class PermissionNodeHandler { public static final String permClaimBlocks = "flan.claim.blocks.max"; public static final String permMaxClaims = "flan.claims.amount"; - public static boolean perm(ServerCommandSource src, String perm) { + public static boolean perm(CommandSourceStack src, String perm) { return perm(src, perm, false); } @ExpectPlatform - public static boolean perm(ServerCommandSource src, String perm, boolean adminCmd) { + public static boolean perm(CommandSourceStack src, String perm, boolean adminCmd) { throw new AssertionError(); } @ExpectPlatform - public static boolean perm(ServerPlayerEntity src, String perm, boolean adminCmd) { + public static boolean perm(ServerPlayer src, String perm, boolean adminCmd) { throw new AssertionError(); } @ExpectPlatform - public static boolean permBelowEqVal(ServerPlayerEntity src, String perm, int val, int fallback) { + public static boolean permBelowEqVal(ServerPlayer src, String perm, int val, int fallback) { throw new AssertionError(); } } \ No newline at end of file diff --git a/common/src/main/java/io/github/flemmli97/flan/mixin/AbstractBlockStateMixin.java b/common/src/main/java/io/github/flemmli97/flan/mixin/AbstractBlockStateMixin.java index c11dc39..bd117ec 100644 --- a/common/src/main/java/io/github/flemmli97/flan/mixin/AbstractBlockStateMixin.java +++ b/common/src/main/java/io/github/flemmli97/flan/mixin/AbstractBlockStateMixin.java @@ -1,15 +1,15 @@ package io.github.flemmli97.flan.mixin; import io.github.flemmli97.flan.event.BlockInteractEvents; -import net.minecraft.block.AbstractBlock; -import net.minecraft.block.BlockState; -import net.minecraft.entity.Entity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.util.ActionResult; -import net.minecraft.util.Hand; -import net.minecraft.util.hit.BlockHitResult; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; +import net.minecraft.core.BlockPos; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.state.BlockBehaviour; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.phys.BlockHitResult; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; @@ -17,12 +17,12 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -@Mixin(AbstractBlock.AbstractBlockState.class) +@Mixin(BlockBehaviour.BlockStateBase.class) public abstract class AbstractBlockStateMixin { - @Inject(method = "onEntityCollision", at = @At(value = "HEAD"), cancellable = true) - private void collision(World world, BlockPos pos, Entity entity, CallbackInfo info) { - if (BlockInteractEvents.cancelEntityBlockCollision(this.asBlockState(), world, pos, entity)) { + @Inject(method = "entityInside", at = @At(value = "HEAD"), cancellable = true) + private void collision(Level world, BlockPos pos, Entity entity, CallbackInfo info) { + if (BlockInteractEvents.cancelEntityBlockCollision(this.asState(), world, pos, entity)) { info.cancel(); } } @@ -31,15 +31,15 @@ public abstract class AbstractBlockStateMixin { * Can't use the hooks from both fabric or forge cause they are too generic. * Wouldn't be able to place blocks after cancelling them */ - @Inject(method = "onUse", at = @At(value = "HEAD"), cancellable = true) - private void useBlock(World world, PlayerEntity player, Hand hand, BlockHitResult result, CallbackInfoReturnable info) { - ActionResult res = BlockInteractEvents.useBlocks(player, world, hand, result); - if (res != ActionResult.PASS) { + @Inject(method = "use", at = @At(value = "HEAD"), cancellable = true) + private void useBlock(Level world, Player player, InteractionHand hand, BlockHitResult result, CallbackInfoReturnable info) { + InteractionResult res = BlockInteractEvents.useBlocks(player, world, hand, result); + if (res != InteractionResult.PASS) { info.setReturnValue(res); info.cancel(); } } @Shadow - protected abstract BlockState asBlockState(); + protected abstract BlockState asState(); } diff --git a/common/src/main/java/io/github/flemmli97/flan/mixin/AbstractContainerAccessor.java b/common/src/main/java/io/github/flemmli97/flan/mixin/AbstractContainerAccessor.java new file mode 100644 index 0000000..b172dd5 --- /dev/null +++ b/common/src/main/java/io/github/flemmli97/flan/mixin/AbstractContainerAccessor.java @@ -0,0 +1,20 @@ +package io.github.flemmli97.flan.mixin; + +import net.minecraft.world.inventory.AbstractContainerMenu; +import net.minecraft.world.inventory.ContainerListener; +import net.minecraft.world.inventory.ContainerSynchronizer; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + +import java.util.List; + +@Mixin(AbstractContainerMenu.class) +public interface AbstractContainerAccessor { + + @Accessor("containerListeners") + List listeners(); + + @Accessor("synchronizer") + ContainerSynchronizer containerSync(); + +} diff --git a/common/src/main/java/io/github/flemmli97/flan/mixin/BannedEntryAccessor.java b/common/src/main/java/io/github/flemmli97/flan/mixin/BannedEntryAccessor.java index 70ad0b1..9c0349a 100644 --- a/common/src/main/java/io/github/flemmli97/flan/mixin/BannedEntryAccessor.java +++ b/common/src/main/java/io/github/flemmli97/flan/mixin/BannedEntryAccessor.java @@ -1,14 +1,14 @@ package io.github.flemmli97.flan.mixin; -import net.minecraft.server.BanEntry; +import net.minecraft.server.players.BanListEntry; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; import java.util.Date; -@Mixin(BanEntry.class) +@Mixin(BanListEntry.class) public interface BannedEntryAccessor { - @Accessor("creationDate") + @Accessor("created") Date getCreationDate(); } diff --git a/common/src/main/java/io/github/flemmli97/flan/mixin/EndermanPickupMixin.java b/common/src/main/java/io/github/flemmli97/flan/mixin/EndermanPickupMixin.java index c921700..bc901b6 100644 --- a/common/src/main/java/io/github/flemmli97/flan/mixin/EndermanPickupMixin.java +++ b/common/src/main/java/io/github/flemmli97/flan/mixin/EndermanPickupMixin.java @@ -1,23 +1,23 @@ package io.github.flemmli97.flan.mixin; import io.github.flemmli97.flan.event.EntityInteractEvents; -import net.minecraft.entity.mob.EndermanEntity; -import net.minecraft.util.math.BlockPos; +import net.minecraft.core.BlockPos; +import net.minecraft.world.entity.monster.EnderMan; 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.ModifyVariable; -@Mixin(targets = "net/minecraft/entity/mob/EndermanEntity$PickUpBlockGoal") +@Mixin(targets = "net/minecraft/world/entity/monster/EnderMan$EndermanTakeBlockGoal") public abstract class EndermanPickupMixin { @Shadow - private EndermanEntity enderman; + private EnderMan enderman; - @ModifyVariable(method = "Lnet/minecraft/entity/mob/EndermanEntity$PickUpBlockGoal;tick()V", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;getBlockState(Lnet/minecraft/util/math/BlockPos;)Lnet/minecraft/block/BlockState;"), ordinal = 0) + @ModifyVariable(method = "Lnet/minecraft/world/entity/monster/EnderMan$EndermanTakeBlockGoal;tick()V", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/Level;getBlockState(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/block/state/BlockState;"), ordinal = 0) private BlockPos pickupCheck(BlockPos pos) { if (!EntityInteractEvents.canEndermanInteract(this.enderman, pos)) { - return BlockPos.ORIGIN; + return BlockPos.ZERO; } return pos; } diff --git a/common/src/main/java/io/github/flemmli97/flan/mixin/EndermanPlaceMixin.java b/common/src/main/java/io/github/flemmli97/flan/mixin/EndermanPlaceMixin.java index b6c2c77..66f1c64 100644 --- a/common/src/main/java/io/github/flemmli97/flan/mixin/EndermanPlaceMixin.java +++ b/common/src/main/java/io/github/flemmli97/flan/mixin/EndermanPlaceMixin.java @@ -1,24 +1,24 @@ package io.github.flemmli97.flan.mixin; import io.github.flemmli97.flan.event.EntityInteractEvents; -import net.minecraft.block.BlockState; -import net.minecraft.entity.mob.EndermanEntity; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; +import net.minecraft.core.BlockPos; +import net.minecraft.world.entity.monster.EnderMan; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.state.BlockState; 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.CallbackInfoReturnable; -@Mixin(targets = "net/minecraft/entity/mob/EndermanEntity$PlaceBlockGoal") +@Mixin(targets = "net/minecraft/world/entity/monster/EnderMan$EndermanLeaveBlockGoal") public abstract class EndermanPlaceMixin { @Shadow - private EndermanEntity enderman; + private EnderMan enderman; - @Inject(method = "Lnet/minecraft/entity/mob/EndermanEntity$PlaceBlockGoal;canPlaceOn(Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;Lnet/minecraft/block/BlockState;Lnet/minecraft/block/BlockState;Lnet/minecraft/util/math/BlockPos;)Z", at = @At(value = "HEAD"), cancellable = true) - private void placeCheck(World world, BlockPos posAbove, BlockState carriedState, BlockState stateAbove, BlockState state, BlockPos pos, CallbackInfoReturnable info) { + @Inject(method = "Lnet/minecraft/world/entity/monster/EnderMan$EndermanLeaveBlockGoal;canPlaceBlock(Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/core/BlockPos;)Z", at = @At(value = "HEAD"), cancellable = true) + private void placeCheck(Level world, BlockPos posAbove, BlockState carriedState, BlockState stateAbove, BlockState state, BlockPos pos, CallbackInfoReturnable info) { if (!EntityInteractEvents.canEndermanInteract(this.enderman, pos)) { info.setReturnValue(false); info.cancel(); diff --git a/common/src/main/java/io/github/flemmli97/flan/mixin/EntityMixin.java b/common/src/main/java/io/github/flemmli97/flan/mixin/EntityMixin.java index 850ef33..03676b4 100644 --- a/common/src/main/java/io/github/flemmli97/flan/mixin/EntityMixin.java +++ b/common/src/main/java/io/github/flemmli97/flan/mixin/EntityMixin.java @@ -1,9 +1,9 @@ package io.github.flemmli97.flan.mixin; import io.github.flemmli97.flan.event.BlockInteractEvents; -import net.minecraft.block.BlockState; -import net.minecraft.entity.Entity; -import net.minecraft.util.math.BlockPos; +import net.minecraft.core.BlockPos; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.level.block.state.BlockState; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -12,7 +12,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(Entity.class) public abstract class EntityMixin { - @Inject(method = "fall", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/Block;onLandedUpon(Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/entity/Entity;F)V"), cancellable = true) + @Inject(method = "checkFallDamage", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/block/Block;fallOn(Lnet/minecraft/world/level/Level;Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/entity/Entity;F)V"), cancellable = true) private void fallOnBlock(double heightDifference, boolean onGround, BlockState landedState, BlockPos landedPosition, CallbackInfo info) { if (BlockInteractEvents.preventFallOn((Entity) (Object) this, heightDifference, onGround, landedState, landedPosition)) info.cancel(); diff --git a/common/src/main/java/io/github/flemmli97/flan/mixin/FireBlockMixin.java b/common/src/main/java/io/github/flemmli97/flan/mixin/FireBlockMixin.java index baeef43..26e35e7 100644 --- a/common/src/main/java/io/github/flemmli97/flan/mixin/FireBlockMixin.java +++ b/common/src/main/java/io/github/flemmli97/flan/mixin/FireBlockMixin.java @@ -1,11 +1,11 @@ package io.github.flemmli97.flan.mixin; import io.github.flemmli97.flan.event.WorldEvents; -import net.minecraft.block.BlockState; -import net.minecraft.block.FireBlock; -import net.minecraft.server.world.ServerWorld; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.WorldView; +import net.minecraft.core.BlockPos; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.level.LevelReader; +import net.minecraft.world.level.block.FireBlock; +import net.minecraft.world.level.block.state.BlockState; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -17,16 +17,22 @@ import java.util.Random; @Mixin(FireBlock.class) public abstract class FireBlockMixin { - @Inject(method = "scheduledTick", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/world/ServerWorld;getGameRules()Lnet/minecraft/world/GameRules;"), cancellable = true) - private void tick(BlockState state, ServerWorld world, BlockPos pos, Random random, CallbackInfo info) { + /** + * Stop ticking overall if fire is in claim + */ + @Inject(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ServerLevel;getGameRules()Lnet/minecraft/world/level/GameRules;"), cancellable = true) + private void tick(BlockState state, ServerLevel world, BlockPos pos, Random random, CallbackInfo info) { if (!WorldEvents.canFireSpread(world, pos)) { info.cancel(); } } - @Inject(method = "getBurnChance(Lnet/minecraft/world/WorldView;Lnet/minecraft/util/math/BlockPos;)I", at = @At(value = "HEAD"), cancellable = true) - private void burn(WorldView worldView, BlockPos pos, CallbackInfoReturnable info) { - if (worldView instanceof ServerWorld && !WorldEvents.canFireSpread((ServerWorld) worldView, pos)) { + /** + * Check if fire can spread to this block + */ + @Inject(method = "getFireOdds", at = @At(value = "HEAD"), cancellable = true) + private void burn(LevelReader worldView, BlockPos pos, CallbackInfoReturnable info) { + if (worldView instanceof ServerLevel && !WorldEvents.canFireSpread((ServerLevel) worldView, pos)) { info.setReturnValue(0); info.cancel(); } diff --git a/common/src/main/java/io/github/flemmli97/flan/mixin/FluidMixin.java b/common/src/main/java/io/github/flemmli97/flan/mixin/FluidMixin.java index 5e91a19..e49dafb 100644 --- a/common/src/main/java/io/github/flemmli97/flan/mixin/FluidMixin.java +++ b/common/src/main/java/io/github/flemmli97/flan/mixin/FluidMixin.java @@ -1,23 +1,23 @@ package io.github.flemmli97.flan.mixin; import io.github.flemmli97.flan.event.WorldEvents; -import net.minecraft.block.BlockState; -import net.minecraft.fluid.FlowableFluid; -import net.minecraft.fluid.Fluid; -import net.minecraft.fluid.FluidState; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; -import net.minecraft.world.BlockView; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.material.FlowingFluid; +import net.minecraft.world.level.material.Fluid; +import net.minecraft.world.level.material.FluidState; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -@Mixin(FlowableFluid.class) +@Mixin(FlowingFluid.class) public abstract class FluidMixin { - @Inject(method = "canFlow", at = @At(value = "HEAD"), cancellable = true) - private void crossClaimFlow(BlockView world, BlockPos fluidPos, BlockState fluidBlockState, Direction flowDirection, BlockPos flowTo, + @Inject(method = "canSpreadTo", at = @At(value = "HEAD"), cancellable = true) + private void crossClaimFlow(BlockGetter world, BlockPos fluidPos, BlockState fluidBlockState, Direction flowDirection, BlockPos flowTo, BlockState flowToBlockState, FluidState fluidState, Fluid fluid, CallbackInfoReturnable info) { if (!WorldEvents.canFlow(fluidBlockState, world, fluidPos, flowDirection)) { info.setReturnValue(false); diff --git a/common/src/main/java/io/github/flemmli97/flan/mixin/FrostWalkerMixin.java b/common/src/main/java/io/github/flemmli97/flan/mixin/FrostWalkerMixin.java index 9667144..5aa27c2 100644 --- a/common/src/main/java/io/github/flemmli97/flan/mixin/FrostWalkerMixin.java +++ b/common/src/main/java/io/github/flemmli97/flan/mixin/FrostWalkerMixin.java @@ -1,12 +1,12 @@ package io.github.flemmli97.flan.mixin; import io.github.flemmli97.flan.event.EntityInteractEvents; -import net.minecraft.block.BlockState; -import net.minecraft.enchantment.FrostWalkerEnchantment; -import net.minecraft.entity.LivingEntity; -import net.minecraft.server.world.ServerWorld; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.WorldView; +import net.minecraft.core.BlockPos; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.item.enchantment.FrostWalkerEnchantment; +import net.minecraft.world.level.LevelReader; +import net.minecraft.world.level.block.state.BlockState; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; @@ -14,10 +14,10 @@ import org.spongepowered.asm.mixin.injection.Redirect; @Mixin(FrostWalkerEnchantment.class) public abstract class FrostWalkerMixin { - @Redirect(method = "freezeWater", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/BlockState;canPlaceAt(Lnet/minecraft/world/WorldView;Lnet/minecraft/util/math/BlockPos;)Z")) - private static boolean freeze(BlockState state, WorldView world, BlockPos pos, LivingEntity entity) { - if (world instanceof ServerWorld && !EntityInteractEvents.canFrostwalkerFreeze((ServerWorld) world, pos, entity)) + @Redirect(method = "onEntityMoved", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/block/state/BlockState;canSurvive(Lnet/minecraft/world/level/LevelReader;Lnet/minecraft/core/BlockPos;)Z")) + private static boolean freeze(BlockState state, LevelReader world, BlockPos pos, LivingEntity entity) { + if (world instanceof ServerLevel && !EntityInteractEvents.canFrostwalkerFreeze((ServerLevel) world, pos, entity)) return false; - return state.canPlaceAt(world, pos); + return state.canSurvive(world, pos); } } diff --git a/common/src/main/java/io/github/flemmli97/flan/mixin/IHungerAccessor.java b/common/src/main/java/io/github/flemmli97/flan/mixin/IHungerAccessor.java index e473ee6..58afd3f 100644 --- a/common/src/main/java/io/github/flemmli97/flan/mixin/IHungerAccessor.java +++ b/common/src/main/java/io/github/flemmli97/flan/mixin/IHungerAccessor.java @@ -1,12 +1,12 @@ package io.github.flemmli97.flan.mixin; -import net.minecraft.entity.player.HungerManager; +import net.minecraft.world.food.FoodData; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; -@Mixin(HungerManager.class) +@Mixin(FoodData.class) public interface IHungerAccessor { - @Accessor("foodSaturationLevel") + @Accessor("saturationLevel") void setSaturation(float saturation); } diff --git a/common/src/main/java/io/github/flemmli97/flan/mixin/IItemAccessor.java b/common/src/main/java/io/github/flemmli97/flan/mixin/IItemAccessor.java index 6fd742f..7efb584 100644 --- a/common/src/main/java/io/github/flemmli97/flan/mixin/IItemAccessor.java +++ b/common/src/main/java/io/github/flemmli97/flan/mixin/IItemAccessor.java @@ -1,18 +1,18 @@ package io.github.flemmli97.flan.mixin; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.Item; -import net.minecraft.util.hit.BlockHitResult; -import net.minecraft.world.RaycastContext; -import net.minecraft.world.World; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.Item; +import net.minecraft.world.level.ClipContext; +import net.minecraft.world.level.Level; +import net.minecraft.world.phys.BlockHitResult; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Invoker; @Mixin(Item.class) public interface IItemAccessor { - @Invoker("raycast") - static BlockHitResult getRaycast(World world, PlayerEntity player, RaycastContext.FluidHandling fluidHandling) { + @Invoker("getPlayerPOVHitResult") + static BlockHitResult getRaycast(Level world, Player player, ClipContext.Fluid fluidHandling) { throw new IllegalStateException(); } } diff --git a/common/src/main/java/io/github/flemmli97/flan/mixin/ILecternBlockValues.java b/common/src/main/java/io/github/flemmli97/flan/mixin/ILecternBlockValues.java index 53f0a5f..71d2144 100644 --- a/common/src/main/java/io/github/flemmli97/flan/mixin/ILecternBlockValues.java +++ b/common/src/main/java/io/github/flemmli97/flan/mixin/ILecternBlockValues.java @@ -1,17 +1,17 @@ package io.github.flemmli97.flan.mixin; -import net.minecraft.block.entity.LecternBlockEntity; -import net.minecraft.inventory.Inventory; -import net.minecraft.screen.PropertyDelegate; +import net.minecraft.world.Container; +import net.minecraft.world.inventory.ContainerData; +import net.minecraft.world.level.block.entity.LecternBlockEntity; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; @Mixin(LecternBlockEntity.class) public interface ILecternBlockValues { - @Accessor("inventory") - Inventory getInv(); + @Accessor("bookAccess") + Container getInv(); - @Accessor("propertyDelegate") - PropertyDelegate getProp(); + @Accessor("dataAccess") + ContainerData getProp(); } diff --git a/common/src/main/java/io/github/flemmli97/flan/mixin/IPersistentProjectileVars.java b/common/src/main/java/io/github/flemmli97/flan/mixin/IPersistentProjectileVars.java index a0acc4c..7574de4 100644 --- a/common/src/main/java/io/github/flemmli97/flan/mixin/IPersistentProjectileVars.java +++ b/common/src/main/java/io/github/flemmli97/flan/mixin/IPersistentProjectileVars.java @@ -1,31 +1,31 @@ package io.github.flemmli97.flan.mixin; import it.unimi.dsi.fastutil.ints.IntOpenHashSet; -import net.minecraft.block.BlockState; -import net.minecraft.entity.projectile.PersistentProjectileEntity; -import net.minecraft.sound.SoundEvent; +import net.minecraft.sounds.SoundEvent; +import net.minecraft.world.entity.projectile.AbstractArrow; +import net.minecraft.world.level.block.state.BlockState; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; import org.spongepowered.asm.mixin.gen.Invoker; -@Mixin(PersistentProjectileEntity.class) +@Mixin(AbstractArrow.class) public interface IPersistentProjectileVars { - @Accessor("inBlockState") + @Accessor("lastState") void setInBlockState(BlockState state); @Accessor("inGround") void setInGround(boolean flag); - @Invoker("getSound") + @Invoker("getHitGroundSoundEvent") SoundEvent getSoundEvent(); - @Invoker("clearPiercingStatus") + @Invoker("resetPiercedEntities") void resetPiercingStatus(); - @Accessor("piercedEntities") + @Accessor("piercingIgnoreEntityIds") IntOpenHashSet getPiercedEntities(); - @Accessor("piercedEntities") + @Accessor("piercingIgnoreEntityIds") void setPiercedEntities(IntOpenHashSet set); } diff --git a/common/src/main/java/io/github/flemmli97/flan/mixin/ItemEntityMixin.java b/common/src/main/java/io/github/flemmli97/flan/mixin/ItemEntityMixin.java index 5bfc4e3..e5a03b4 100644 --- a/common/src/main/java/io/github/flemmli97/flan/mixin/ItemEntityMixin.java +++ b/common/src/main/java/io/github/flemmli97/flan/mixin/ItemEntityMixin.java @@ -2,10 +2,10 @@ package io.github.flemmli97.flan.mixin; import io.github.flemmli97.flan.player.IOwnedItem; import io.github.flemmli97.flan.player.PlayerClaimData; -import net.minecraft.entity.ItemEntity; -import net.minecraft.entity.player.PlayerEntity; import net.minecraft.nbt.CompoundTag; -import net.minecraft.server.network.ServerPlayerEntity; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.entity.player.Player; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; @@ -22,22 +22,22 @@ public abstract class ItemEntityMixin implements IOwnedItem { @Unique private UUID flanDeathPlayerOrigin; - @Inject(method = "readCustomDataFromTag", at = @At("RETURN")) + @Inject(method = "readAdditionalSaveData", at = @At("RETURN")) private void readData(CompoundTag tag, CallbackInfo info) { if (tag.contains("Flan:PlayerOrigin")) - this.flanPlayerOrigin = tag.getUuid("Flan:PlayerOrigin"); + this.flanPlayerOrigin = tag.getUUID("Flan:PlayerOrigin"); } - @Inject(method = "writeCustomDataToTag", at = @At("RETURN")) + @Inject(method = "addAdditionalSaveData", at = @At("RETURN")) private void writeData(CompoundTag tag, CallbackInfo info) { if (this.flanPlayerOrigin != null) - tag.putUuid("Flan:PlayerOrigin", this.flanPlayerOrigin); + tag.putUUID("Flan:PlayerOrigin", this.flanPlayerOrigin); } @Override - public void setOriginPlayer(PlayerEntity player) { - this.flanPlayerOrigin = player.getUuid(); - if (player instanceof ServerPlayerEntity && PlayerClaimData.get((ServerPlayerEntity) player).setDeathItemOwner()) + public void setOriginPlayer(Player player) { + this.flanPlayerOrigin = player.getUUID(); + if (player instanceof ServerPlayer && PlayerClaimData.get((ServerPlayer) player).setDeathItemOwner()) this.flanDeathPlayerOrigin = this.flanPlayerOrigin; } diff --git a/common/src/main/java/io/github/flemmli97/flan/mixin/ItemStackMixin.java b/common/src/main/java/io/github/flemmli97/flan/mixin/ItemStackMixin.java index 75d4e63..60d1907 100644 --- a/common/src/main/java/io/github/flemmli97/flan/mixin/ItemStackMixin.java +++ b/common/src/main/java/io/github/flemmli97/flan/mixin/ItemStackMixin.java @@ -1,9 +1,9 @@ package io.github.flemmli97.flan.mixin; import io.github.flemmli97.flan.event.ItemInteractEvents; -import net.minecraft.item.ItemStack; -import net.minecraft.item.ItemUsageContext; -import net.minecraft.util.ActionResult; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.context.UseOnContext; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -12,10 +12,10 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(ItemStack.class) public abstract class ItemStackMixin { - @Inject(method = "useOnBlock", at = @At(value = "HEAD"), cancellable = true) - private void blockUse(ItemUsageContext context, CallbackInfoReturnable info) { - ActionResult result = ItemInteractEvents.onItemUseBlock(context); - if (result != ActionResult.PASS) { + @Inject(method = "useOn", at = @At(value = "HEAD"), cancellable = true) + private void blockUse(UseOnContext context, CallbackInfoReturnable info) { + InteractionResult result = ItemInteractEvents.onItemUseBlock(context); + if (result != InteractionResult.PASS) { info.setReturnValue(result); info.cancel(); } diff --git a/common/src/main/java/io/github/flemmli97/flan/mixin/LightningFireEntityMixin.java b/common/src/main/java/io/github/flemmli97/flan/mixin/LightningFireEntityMixin.java index 4ff1973..9b7313d 100644 --- a/common/src/main/java/io/github/flemmli97/flan/mixin/LightningFireEntityMixin.java +++ b/common/src/main/java/io/github/flemmli97/flan/mixin/LightningFireEntityMixin.java @@ -1,18 +1,18 @@ package io.github.flemmli97.flan.mixin; import io.github.flemmli97.flan.event.WorldEvents; -import net.minecraft.entity.LightningEntity; +import net.minecraft.world.entity.LightningBolt; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -@Mixin(LightningEntity.class) +@Mixin(LightningBolt.class) public abstract class LightningFireEntityMixin { @Inject(method = "spawnFire", at = @At(value = "HEAD"), cancellable = true) private void stopFire(int attempts, CallbackInfo info) { - if (!WorldEvents.lightningFire((LightningEntity) (Object) this)) + if (!WorldEvents.lightningFire((LightningBolt) (Object) this)) info.cancel(); } } diff --git a/common/src/main/java/io/github/flemmli97/flan/mixin/PlayerClaimMixin.java b/common/src/main/java/io/github/flemmli97/flan/mixin/PlayerClaimMixin.java index b540d7c..50bffed 100644 --- a/common/src/main/java/io/github/flemmli97/flan/mixin/PlayerClaimMixin.java +++ b/common/src/main/java/io/github/flemmli97/flan/mixin/PlayerClaimMixin.java @@ -4,7 +4,7 @@ import io.github.flemmli97.flan.claim.Claim; import io.github.flemmli97.flan.player.IPlayerClaimImpl; import io.github.flemmli97.flan.player.PlayerClaimData; import net.minecraft.server.MinecraftServer; -import net.minecraft.server.network.ServerPlayerEntity; +import net.minecraft.server.level.ServerPlayer; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Unique; @@ -12,7 +12,7 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -@Mixin(ServerPlayerEntity.class) +@Mixin(ServerPlayer.class) public abstract class PlayerClaimMixin implements IPlayerClaimImpl { @Unique @@ -26,7 +26,7 @@ public abstract class PlayerClaimMixin implements IPlayerClaimImpl { @Inject(method = "*", at = @At("RETURN")) private void initData(CallbackInfo info) { - this.flanClaimData = new PlayerClaimData((ServerPlayerEntity) (Object) this); + this.flanClaimData = new PlayerClaimData((ServerPlayer) (Object) this); } /*@Inject(method = "readCustomDataFromTag", at = @At("RETURN")) @@ -44,8 +44,8 @@ public abstract class PlayerClaimMixin implements IPlayerClaimImpl { this.flanClaimData.tick(this.flanCurrentClaim, claim -> this.flanCurrentClaim = claim); } - @Inject(method = "copyFrom", at = @At("RETURN")) - private void copyOld(ServerPlayerEntity oldPlayer, boolean alive, CallbackInfo info) { + @Inject(method = "restoreFrom", at = @At("RETURN")) + private void copyOld(ServerPlayer oldPlayer, boolean alive, CallbackInfo info) { this.flanClaimData.clone(PlayerClaimData.get(oldPlayer)); } diff --git a/common/src/main/java/io/github/flemmli97/flan/mixin/PlayerMixin.java b/common/src/main/java/io/github/flemmli97/flan/mixin/PlayerMixin.java index 33084ed..dc1cc31 100644 --- a/common/src/main/java/io/github/flemmli97/flan/mixin/PlayerMixin.java +++ b/common/src/main/java/io/github/flemmli97/flan/mixin/PlayerMixin.java @@ -1,27 +1,27 @@ package io.github.flemmli97.flan.mixin; import io.github.flemmli97.flan.event.EntityInteractEvents; -import net.minecraft.entity.Entity; -import net.minecraft.entity.ItemEntity; -import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.entity.player.Player; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.ModifyVariable; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -@Mixin(PlayerEntity.class) +@Mixin(Player.class) public abstract class PlayerMixin { - @ModifyVariable(method = "dropItem(Lnet/minecraft/item/ItemStack;ZZ)Lnet/minecraft/entity/ItemEntity;", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/ItemEntity;setPickupDelay(I)V")) + @ModifyVariable(method = "drop(Lnet/minecraft/world/item/ItemStack;ZZ)Lnet/minecraft/world/entity/item/ItemEntity;", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/item/ItemEntity;setPickUpDelay(I)V")) private ItemEntity ownerDrop(ItemEntity entity) { - EntityInteractEvents.updateDroppedItem((PlayerEntity) (Object) this, entity); + EntityInteractEvents.updateDroppedItem((Player) (Object) this, entity); return entity; } - @Inject(method = "collideWithEntity", at = @At(value = "HEAD"), cancellable = true) + @Inject(method = "touch", at = @At(value = "HEAD"), cancellable = true) private void entityCollide(Entity entity, CallbackInfo info) { - if (!EntityInteractEvents.canCollideWith((PlayerEntity) (Object) this, entity)) { + if (!EntityInteractEvents.canCollideWith((Player) (Object) this, entity)) { info.cancel(); } } diff --git a/common/src/main/java/io/github/flemmli97/flan/mixin/RaidManagerMixin.java b/common/src/main/java/io/github/flemmli97/flan/mixin/RaidManagerMixin.java index 4b8c342..0b7dbb0 100644 --- a/common/src/main/java/io/github/flemmli97/flan/mixin/RaidManagerMixin.java +++ b/common/src/main/java/io/github/flemmli97/flan/mixin/RaidManagerMixin.java @@ -1,19 +1,19 @@ package io.github.flemmli97.flan.mixin; import io.github.flemmli97.flan.event.WorldEvents; -import net.minecraft.server.network.ServerPlayerEntity; -import net.minecraft.village.raid.Raid; -import net.minecraft.village.raid.RaidManager; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.entity.raid.Raid; +import net.minecraft.world.entity.raid.Raids; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -@Mixin(RaidManager.class) +@Mixin(Raids.class) public abstract class RaidManagerMixin { - @Inject(method = "startRaid", at = @At(value = "HEAD"), cancellable = true) - private void checkRaid(ServerPlayerEntity player, CallbackInfoReturnable info) { + @Inject(method = "createOrExtendRaid", at = @At(value = "HEAD"), cancellable = true) + private void checkRaid(ServerPlayer player, CallbackInfoReturnable info) { if (!WorldEvents.canStartRaid(player)) { info.setReturnValue(null); info.cancel(); diff --git a/common/src/main/java/io/github/flemmli97/flan/mixin/ServerWorldMixin.java b/common/src/main/java/io/github/flemmli97/flan/mixin/ServerWorldMixin.java index e6705d3..6ce5d41 100644 --- a/common/src/main/java/io/github/flemmli97/flan/mixin/ServerWorldMixin.java +++ b/common/src/main/java/io/github/flemmli97/flan/mixin/ServerWorldMixin.java @@ -2,28 +2,28 @@ package io.github.flemmli97.flan.mixin; import io.github.flemmli97.flan.claim.ClaimStorage; import io.github.flemmli97.flan.claim.IClaimStorage; -import net.minecraft.server.world.ServerWorld; +import net.minecraft.server.level.ServerLevel; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -@Mixin(ServerWorld.class) +@Mixin(ServerLevel.class) public abstract class ServerWorldMixin implements IClaimStorage { @Unique private ClaimStorage flanClaimData; @Inject(method = "*", at = @At("RETURN")) private void initData(CallbackInfo info) { - ServerWorld world = ((ServerWorld) (Object) this); + ServerLevel world = ((ServerLevel) (Object) this); this.flanClaimData = new ClaimStorage(world.getServer(), world); } - @Inject(method = "saveLevel()V", at = @At("RETURN")) + @Inject(method = "saveLevelData", at = @At("RETURN")) private void saveClaimData(CallbackInfo info) { - ServerWorld world = ((ServerWorld) (Object) this); - this.flanClaimData.save(world.getServer(), world.getRegistryKey()); + ServerLevel world = ((ServerLevel) (Object) this); + this.flanClaimData.save(world.getServer(), world.dimension()); } @Override diff --git a/common/src/main/java/io/github/flemmli97/flan/mixin/TurtleEggMixin.java b/common/src/main/java/io/github/flemmli97/flan/mixin/TurtleEggMixin.java index 552510e..d9713f3 100644 --- a/common/src/main/java/io/github/flemmli97/flan/mixin/TurtleEggMixin.java +++ b/common/src/main/java/io/github/flemmli97/flan/mixin/TurtleEggMixin.java @@ -1,10 +1,11 @@ package io.github.flemmli97.flan.mixin; import io.github.flemmli97.flan.event.BlockInteractEvents; -import net.minecraft.block.TurtleEggBlock; -import net.minecraft.entity.Entity; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; +import net.minecraft.core.BlockPos; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.TurtleEggBlock; +import net.minecraft.world.level.block.state.BlockState; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -13,8 +14,8 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(TurtleEggBlock.class) public abstract class TurtleEggMixin { - @Inject(method = "onSteppedOn", at = @At(value = "HEAD"), cancellable = true) - private void collision(World world, BlockPos pos, Entity entity, CallbackInfo info) { + @Inject(method = "destroyEgg", at = @At(value = "HEAD"), cancellable = true) + private void collision(Level world, BlockState blockState, BlockPos pos, Entity entity, int chance, CallbackInfo info) { if (BlockInteractEvents.canBreakTurtleEgg(world, pos, entity)) { info.cancel(); } diff --git a/common/src/main/java/io/github/flemmli97/flan/player/ClaimDisplay.java b/common/src/main/java/io/github/flemmli97/flan/player/ClaimDisplay.java index 3376be8..653b21b 100644 --- a/common/src/main/java/io/github/flemmli97/flan/player/ClaimDisplay.java +++ b/common/src/main/java/io/github/flemmli97/flan/player/ClaimDisplay.java @@ -3,13 +3,12 @@ package io.github.flemmli97.flan.player; import io.github.flemmli97.flan.claim.Claim; import io.github.flemmli97.flan.claim.ParticleIndicators; import io.github.flemmli97.flan.config.ConfigHandler; -import net.minecraft.block.BlockState; -import net.minecraft.network.packet.s2c.play.ParticleS2CPacket; -import net.minecraft.particle.DustParticleEffect; -import net.minecraft.server.network.ServerPlayerEntity; -import net.minecraft.server.world.ServerWorld; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; +import net.minecraft.core.BlockPos; +import net.minecraft.core.particles.DustParticleOptions; +import net.minecraft.network.protocol.game.ClientboundLevelParticlesPacket; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.level.block.state.BlockState; import java.util.ArrayList; import java.util.HashSet; @@ -28,7 +27,7 @@ public class ClaimDisplay { private int[] prevDims; - private final DustParticleEffect corner, middle; + private final DustParticleOptions corner, middle; public ClaimDisplay(Claim claim, EnumDisplayType type, int y) { this.toDisplay = claim; @@ -56,29 +55,29 @@ public class ClaimDisplay { } } - public boolean display(ServerPlayerEntity player, boolean remove) { + public boolean display(ServerPlayer player, boolean remove) { if (--this.displayTime % 2 == 0) return this.toDisplay.isRemoved(); int[] dims = this.toDisplay.getDimensions(); if (this.poss == null || this.changed(dims)) { - this.middlePoss = calculateDisplayPos(player.getServerWorld(), dims, this.height); + this.middlePoss = calculateDisplayPos(player.getLevel(), dims, this.height); this.poss = new int[][]{ - getPosFrom(player.getServerWorld(), dims[0], dims[2], this.height), - getPosFrom(player.getServerWorld(), dims[1], dims[2], this.height), - getPosFrom(player.getServerWorld(), dims[0], dims[3], this.height), - getPosFrom(player.getServerWorld(), dims[1], dims[3], this.height), + getPosFrom(player.getLevel(), dims[0], dims[2], this.height), + getPosFrom(player.getLevel(), dims[1], dims[2], this.height), + getPosFrom(player.getLevel(), dims[0], dims[3], this.height), + getPosFrom(player.getLevel(), dims[1], dims[3], this.height), }; } for (int[] pos : this.poss) { if (pos[1] != pos[2]) - player.networkHandler.sendPacket(new ParticleS2CPacket(this.corner, true, pos[0] + 0.5, pos[2] + 0.25, pos[3] + 0.5, 0, 0.5f, 0, 0, 1)); - player.networkHandler.sendPacket(new ParticleS2CPacket(this.corner, true, pos[0] + 0.5, pos[1] + 0.25, pos[3] + 0.5, 0, 0.5f, 0, 0, 1)); + player.connection.send(new ClientboundLevelParticlesPacket(this.corner, true, pos[0] + 0.5, pos[2] + 0.25, pos[3] + 0.5, 0, 0.5f, 0, 0, 1)); + player.connection.send(new ClientboundLevelParticlesPacket(this.corner, true, pos[0] + 0.5, pos[1] + 0.25, pos[3] + 0.5, 0, 0.5f, 0, 0, 1)); } if (this.middlePoss != null) for (int[] pos : this.middlePoss) { if (pos[1] != pos[2]) - player.networkHandler.sendPacket(new ParticleS2CPacket(this.middle, true, pos[0] + 0.5, pos[2] + 0.25, pos[3] + 0.5, 0, 0.5f, 0, 0, 1)); - player.networkHandler.sendPacket(new ParticleS2CPacket(this.middle, true, pos[0] + 0.5, pos[1] + 0.25, pos[3] + 0.5, 0, 0.5f, 0, 0, 1)); + player.connection.send(new ClientboundLevelParticlesPacket(this.middle, true, pos[0] + 0.5, pos[2] + 0.25, pos[3] + 0.5, 0, 0.5f, 0, 0, 1)); + player.connection.send(new ClientboundLevelParticlesPacket(this.middle, true, pos[0] + 0.5, pos[1] + 0.25, pos[3] + 0.5, 0, 0.5f, 0, 0, 1)); } this.prevDims = dims; return this.toDisplay.isRemoved() || (remove && this.displayTime < 0); @@ -91,7 +90,7 @@ public class ClaimDisplay { return false; } - public static int[][] calculateDisplayPos(ServerWorld world, int[] from, int height) { + public static int[][] calculateDisplayPos(ServerLevel world, int[] from, int height) { List l = new ArrayList<>(); Set xs = new HashSet<>(); addEvenly(from[0], from[1], 10, xs); @@ -131,37 +130,37 @@ public class ClaimDisplay { * Returns an array of of form [x,y1,y2,z] where y1 = height of the lowest replaceable block and y2 = height of the * lowest air block above water (if possible) */ - public static int[] getPosFrom(ServerWorld world, int x, int z, int maxY) { + public static int[] getPosFrom(ServerLevel world, int x, int z, int maxY) { int[] y = nextAirAndWaterBlockFrom(world, x, maxY, z); return new int[]{x, y[0], y[1], z}; } - private static int[] nextAirAndWaterBlockFrom(ServerWorld world, int x, int y, int z) { + private static int[] nextAirAndWaterBlockFrom(ServerLevel world, int x, int y, int z) { BlockPos pos = new BlockPos(x, y, z); BlockState state = world.getBlockState(pos); if (state.getMaterial().isReplaceable()) { - pos = pos.down(); + pos = pos.below(); state = world.getBlockState(pos); - while (state.getMaterial().isReplaceable() && !World.isOutOfBuildLimitVertically(pos)) { - pos = pos.down(); + while (state.getMaterial().isReplaceable() && !world.isOutsideBuildHeight(pos)) { + pos = pos.below(); state = world.getBlockState(pos); } - pos = pos.up(); + pos = pos.above(); state = world.getBlockState(pos); } else { - pos = pos.up(); + pos = pos.above(); state = world.getBlockState(pos); while (!state.getMaterial().isReplaceable()) { - pos = pos.up(); + pos = pos.above(); state = world.getBlockState(pos); } } int[] yRet = {pos.getY(), pos.getY()}; if (state.getMaterial().isLiquid()) { - pos = pos.up(); + pos = pos.above(); state = world.getBlockState(pos); while (state.getMaterial().isLiquid()) { - pos = pos.up(); + pos = pos.above(); state = world.getBlockState(pos); } if (state.getMaterial().isReplaceable()) diff --git a/common/src/main/java/io/github/flemmli97/flan/player/IOwnedItem.java b/common/src/main/java/io/github/flemmli97/flan/player/IOwnedItem.java index 06d7893..6643643 100644 --- a/common/src/main/java/io/github/flemmli97/flan/player/IOwnedItem.java +++ b/common/src/main/java/io/github/flemmli97/flan/player/IOwnedItem.java @@ -1,12 +1,12 @@ package io.github.flemmli97.flan.player; -import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.world.entity.player.Player; import java.util.UUID; public interface IOwnedItem { - void setOriginPlayer(PlayerEntity player); + void setOriginPlayer(Player player); UUID getDeathPlayer(); diff --git a/common/src/main/java/io/github/flemmli97/flan/player/OfflinePlayerData.java b/common/src/main/java/io/github/flemmli97/flan/player/OfflinePlayerData.java index ff58141..903bf47 100644 --- a/common/src/main/java/io/github/flemmli97/flan/player/OfflinePlayerData.java +++ b/common/src/main/java/io/github/flemmli97/flan/player/OfflinePlayerData.java @@ -3,16 +3,15 @@ package io.github.flemmli97.flan.player; import com.google.gson.JsonObject; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import com.mojang.authlib.GameProfile; import io.github.flemmli97.flan.Flan; import io.github.flemmli97.flan.api.data.IPlayerData; import io.github.flemmli97.flan.claim.Claim; import io.github.flemmli97.flan.claim.ClaimStorage; import io.github.flemmli97.flan.config.ConfigHandler; import io.github.flemmli97.flan.mixin.BannedEntryAccessor; -import net.minecraft.server.BannedPlayerEntry; import net.minecraft.server.MinecraftServer; -import net.minecraft.server.world.ServerWorld; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.server.players.UserBanListEntry; import java.io.IOException; import java.nio.charset.StandardCharsets; @@ -76,7 +75,7 @@ public class OfflinePlayerData implements IPlayerData { @Override public int usedClaimBlocks() { int usedClaimsBlocks = 0; - for (ServerWorld world : this.server.getWorlds()) { + for (ServerLevel world : this.server.getAllLevels()) { Collection claims = ClaimStorage.get(world).allClaimsFromPlayer(this.owner); if (claims != null) usedClaimsBlocks += claims.stream().filter(claim -> !claim.isAdminClaim()).mapToInt(Claim::getPlane).sum(); @@ -113,9 +112,8 @@ public class OfflinePlayerData implements IPlayerData { } public boolean isExpired(LocalDateTime now) { - GameProfile prof = this.server.getUserCache().getByUuid(this.owner); - BannedPlayerEntry entry = prof != null ? this.server.getPlayerManager().getUserBanList().get(prof) : null; - boolean banned = entry != null && entry.getExpiryDate() == null; + UserBanListEntry entry = this.server.getProfileCache().get(this.owner).map(this.server.getPlayerList().getBans()::get).orElse(null); + boolean banned = entry != null && entry.getExpires() == null; if (banned) { LocalDateTime bannedTime = LocalDateTime.ofInstant(((BannedEntryAccessor) entry).getCreationDate().toInstant(), ZoneId.systemDefault()); return ConfigHandler.config.bannedDeletionTime != -1 && now.isAfter(bannedTime.plusDays(ConfigHandler.config.bannedDeletionTime)); diff --git a/common/src/main/java/io/github/flemmli97/flan/player/PlayerClaimData.java b/common/src/main/java/io/github/flemmli97/flan/player/PlayerClaimData.java index 3956dfc..24be2cd 100644 --- a/common/src/main/java/io/github/flemmli97/flan/player/PlayerClaimData.java +++ b/common/src/main/java/io/github/flemmli97/flan/player/PlayerClaimData.java @@ -16,21 +16,20 @@ import io.github.flemmli97.flan.config.ConfigHandler; import io.github.flemmli97.flan.event.EntityInteractEvents; import io.github.flemmli97.flan.integration.permissions.PermissionNodeHandler; import io.github.flemmli97.flan.scoreboard.ClaimCriterias; -import net.minecraft.block.BlockState; -import net.minecraft.network.packet.s2c.play.ParticleS2CPacket; -import net.minecraft.scoreboard.ScoreboardCriterion; +import net.minecraft.ChatFormatting; +import net.minecraft.commands.CommandSourceStack; +import net.minecraft.core.BlockPos; +import net.minecraft.network.protocol.game.ClientboundLevelParticlesPacket; import net.minecraft.server.MinecraftServer; -import net.minecraft.server.command.ServerCommandSource; -import net.minecraft.server.network.ServerPlayerEntity; -import net.minecraft.server.world.ServerWorld; -import net.minecraft.util.Formatting; -import net.minecraft.util.WorldSavePath; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Box; -import net.minecraft.util.math.Vec3d; -import net.minecraft.util.shape.VoxelShape; -import net.minecraft.world.Heightmap; -import net.minecraft.world.chunk.ChunkStatus; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.chunk.ChunkStatus; +import net.minecraft.world.level.levelgen.Heightmap; +import net.minecraft.world.level.storage.LevelResource; +import net.minecraft.world.phys.AABB; +import net.minecraft.world.phys.Vec3; +import net.minecraft.world.scores.criteria.ObjectiveCriteria; import java.io.BufferedReader; import java.io.File; @@ -57,7 +56,7 @@ public class PlayerClaimData implements IPlayerData { private int usedBlocks; private int lastBlockTick, trappedTick = -1, deathPickupTick; - private Vec3d trappedPos; + private Vec3 trappedPos; private BlockPos tpPos; private EnumEditMode mode = EnumEditMode.DEFAULT; private Claim editingClaim; @@ -69,7 +68,7 @@ public class PlayerClaimData implements IPlayerData { private final Set claimDisplayList = new HashSet<>(); private final Set displayToAdd = new HashSet<>(); - private final ServerPlayerEntity player; + private final ServerPlayer player; private boolean confirmDeleteAll, adminIgnoreClaim, claimBlockMessage; @@ -77,12 +76,12 @@ public class PlayerClaimData implements IPlayerData { private boolean shouldProtectDrop, calculateShouldDrop = true; - public PlayerClaimData(ServerPlayerEntity player) { + public PlayerClaimData(ServerPlayer player) { this.player = player; this.claimBlocks = ConfigHandler.config.startingBlocks; } - public static PlayerClaimData get(ServerPlayerEntity player) { + public static PlayerClaimData get(ServerPlayer player) { return ((IPlayerClaimImpl) player).get(); } @@ -185,12 +184,12 @@ public class PlayerClaimData implements IPlayerData { public void setEditingCorner(BlockPos pos) { if (pos != null) { - BlockState state = this.player.world.getBlockState(pos); + BlockState state = this.player.level.getBlockState(pos); while (state.isAir() || state.getMaterial().isReplaceable()) { - pos = pos.down(); - state = this.player.world.getBlockState(pos); + pos = pos.below(); + state = this.player.level.getBlockState(pos); } - this.cornerRenderPos = ClaimDisplay.getPosFrom(this.player.getServerWorld(), pos.getX(), pos.getZ(), pos.getY()); + this.cornerRenderPos = ClaimDisplay.getPosFrom(this.player.getLevel(), pos.getX(), pos.getZ(), pos.getY()); } else this.cornerRenderPos = null; this.firstCorner = pos; @@ -218,7 +217,7 @@ public class PlayerClaimData implements IPlayerData { } public boolean editDefaultPerms(String group, ClaimPermission perm, int mode) { - if (PermissionRegistry.globalPerms().contains(perm) || ConfigHandler.config.globallyDefined(this.player.getServerWorld(), perm)) + if (PermissionRegistry.globalPerms().contains(perm) || ConfigHandler.config.globallyDefined(this.player.getLevel(), perm)) return false; if (mode > 1) mode = -1; @@ -235,9 +234,9 @@ public class PlayerClaimData implements IPlayerData { public boolean setTrappedRescue() { Claim claim = ((IPlayerClaimImpl) this.player).getCurrentClaim(); - if (this.trappedTick < 0 && claim != null && !this.player.getUuid().equals(claim.getOwner())) { + if (this.trappedTick < 0 && claim != null && !this.player.getUUID().equals(claim.getOwner())) { this.trappedTick = 101; - this.trappedPos = this.player.getPos(); + this.trappedPos = this.player.position(); return true; } return false; @@ -246,7 +245,7 @@ public class PlayerClaimData implements IPlayerData { public boolean setTeleportTo(BlockPos tp) { if (this.trappedTick < 0) { this.trappedTick = 101; - this.trappedPos = this.player.getPos(); + this.trappedPos = this.player.position(); this.tpPos = tp; return true; } @@ -255,10 +254,10 @@ public class PlayerClaimData implements IPlayerData { public void tick(Claim currentClaim, Consumer cons) { EntityInteractEvents.updateClaim(this.player, currentClaim, cons); - boolean tool = this.player.getMainHandStack().getItem() == ConfigHandler.config.claimingItem - || this.player.getOffHandStack().getItem() == ConfigHandler.config.claimingItem; - boolean stick = this.player.getMainHandStack().getItem() == ConfigHandler.config.inspectionItem - || this.player.getOffHandStack().getItem() == ConfigHandler.config.inspectionItem; + boolean tool = this.player.getMainHandItem().getItem() == ConfigHandler.config.claimingItem + || this.player.getOffhandItem().getItem() == ConfigHandler.config.claimingItem; + boolean stick = this.player.getMainHandItem().getItem() == ConfigHandler.config.inspectionItem + || this.player.getOffhandItem().getItem() == ConfigHandler.config.inspectionItem; this.displayToAdd.forEach(add -> { if (!this.claimDisplayList.add(add)) { this.claimDisplayList.removeIf(c -> c.equals(add) && c.type != add.type); @@ -273,8 +272,8 @@ public class PlayerClaimData implements IPlayerData { } if (this.cornerRenderPos != null) { if (this.cornerRenderPos[1] != this.cornerRenderPos[2]) - this.player.networkHandler.sendPacket(new ParticleS2CPacket(ParticleIndicators.SETCORNER, true, this.cornerRenderPos[0] + 0.5, this.cornerRenderPos[2] + 0.25, this.cornerRenderPos[3] + 0.5, 0, 0.25f, 0, 0, 2)); - this.player.networkHandler.sendPacket(new ParticleS2CPacket(ParticleIndicators.SETCORNER, true, this.cornerRenderPos[0] + 0.5, this.cornerRenderPos[1] + 0.25, this.cornerRenderPos[3] + 0.5, 0, 0.25f, 0, 0, 2)); + this.player.connection.send(new ClientboundLevelParticlesPacket(ParticleIndicators.SETCORNER, true, this.cornerRenderPos[0] + 0.5, this.cornerRenderPos[2] + 0.25, this.cornerRenderPos[3] + 0.5, 0, 0.25f, 0, 0, 2)); + this.player.connection.send(new ClientboundLevelParticlesPacket(ParticleIndicators.SETCORNER, true, this.cornerRenderPos[0] + 0.5, this.cornerRenderPos[1] + 0.25, this.cornerRenderPos[3] + 0.5, 0, 0.25f, 0, 0, 2)); } if (--this.confirmTick < 0) this.confirmDeleteAll = false; @@ -286,43 +285,43 @@ public class PlayerClaimData implements IPlayerData { this.claimBlockMessage = false; } else if (!this.claimBlockMessage) { this.claimBlockMessage = true; - this.player.sendMessage(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.claimBlocksFormat, - this.getClaimBlocks(), this.getAdditionalClaims(), this.usedClaimBlocks()), Formatting.GOLD), false); + this.player.displayClientMessage(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.claimBlocksFormat, + this.getClaimBlocks(), this.getAdditionalClaims(), this.usedClaimBlocks()), ChatFormatting.GOLD), false); } this.actionCooldown--; if (--this.trappedTick >= 0) { if (this.trappedTick == 0) { if (this.tpPos != null) { - BlockPos.Mutable tpTo = this.tpPos.mutableCopy(); - Vec3d offset = new Vec3d(this.tpPos.getX() + 0.5, this.tpPos.getY() + 0.01, this.tpPos.getZ() + 0.5).subtract(this.player.getPos()); - int yHighest = this.player.world.getChunk(this.tpPos.getX() >> 4, this.tpPos.getZ() >> 4, ChunkStatus.HEIGHTMAPS).sampleHeightmap(Heightmap.Type.MOTION_BLOCKING, this.tpPos.getX() & 15, this.tpPos.getZ() & 15); - Box box = this.player.getBoundingBox().offset(offset); + BlockPos.MutableBlockPos tpTo = this.tpPos.mutable(); + Vec3 offset = new Vec3(this.tpPos.getX() + 0.5, this.tpPos.getY() + 0.01, this.tpPos.getZ() + 0.5).subtract(this.player.position()); + int yHighest = this.player.level.getChunk(this.tpPos.getX() >> 4, this.tpPos.getZ() >> 4, ChunkStatus.HEIGHTMAPS).getHeight(Heightmap.Types.MOTION_BLOCKING, this.tpPos.getX() & 15, this.tpPos.getZ() & 15); + AABB box = this.player.getBoundingBox().move(offset); if (tpTo.getY() < yHighest) { while (tpTo.getY() < yHighest) { - if (this.player.world.getBlockCollisions(this.player, box, (state, pos) -> true).allMatch(VoxelShape::isEmpty)) + if (this.player.level.noCollision(this.player, box)) break; tpTo.set(tpTo.getX(), tpTo.getY() + 1, tpTo.getZ()); - box = box.offset(0, 1, 0); + box = box.move(0, 1, 0); } tpTo.set(tpTo.getX(), tpTo.getY() + 1, tpTo.getZ()); } else tpTo.set(tpTo.getX(), yHighest, tpTo.getZ()); - this.player.teleport(tpTo.getX() + 0.5, tpTo.getY(), tpTo.getZ() + 0.5); + this.player.teleportToWithTicket(tpTo.getX() + 0.5, tpTo.getY(), tpTo.getZ() + 0.5); this.tpPos = null; } else { - Vec3d tp = TeleportUtils.getTeleportPos(this.player, this.player.getPos(), ClaimStorage.get(this.player.getServerWorld()), + Vec3 tp = TeleportUtils.getTeleportPos(this.player, this.player.position(), ClaimStorage.get(this.player.getLevel()), ((IPlayerClaimImpl) this.player).getCurrentClaim().getDimensions(), - TeleportUtils.roundedBlockPos(this.player.getPos()).mutableCopy(), (claim, nPos) -> false); - this.player.teleport(tp.getX(), tp.getY(), tp.getZ()); + TeleportUtils.roundedBlockPos(this.player.position()).mutable(), (claim, nPos) -> false); + this.player.teleportToWithTicket(tp.x(), tp.y(), tp.z()); } - } else if (this.player.getPos().squaredDistanceTo(this.trappedPos) > 0.15) { + } else if (this.player.position().distanceToSqr(this.trappedPos) > 0.15) { this.trappedTick = -1; this.trappedPos = null; - this.player.sendMessage(PermHelper.simpleColoredText(ConfigHandler.lang.trappedMove, Formatting.RED), false); + this.player.displayClientMessage(PermHelper.simpleColoredText(ConfigHandler.lang.trappedMove, ChatFormatting.RED), false); } } this.deathPickupTick--; - if (!this.player.isDead()) + if (!this.player.isDeadOrDying()) this.calculateShouldDrop = true; } @@ -340,7 +339,7 @@ public class PlayerClaimData implements IPlayerData { this.defaultGroups.clear(); this.defaultGroups.putAll(data.defaultGroups); if (data.setDeathItemOwner()) - this.player.sendMessage(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.unlockDropsCmd, "/flan unlockDrops"), Formatting.GOLD), false); + this.player.displayClientMessage(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.unlockDropsCmd, "/flan unlockDrops"), ChatFormatting.GOLD), false); } public void updateScoreboard() { @@ -353,8 +352,8 @@ public class PlayerClaimData implements IPlayerData { private int updateClaimScores() { int usedClaimsBlocks = 0; int claimsAmount = 0; - for (ServerWorld world : this.player.getServer().getWorlds()) { - Collection claims = ClaimStorage.get(world).allClaimsFromPlayer(this.player.getUuid()); + for (ServerLevel world : this.player.getServer().getAllLevels()) { + Collection claims = ClaimStorage.get(world).allClaimsFromPlayer(this.player.getUUID()); if (claims != null) { usedClaimsBlocks += claims.stream().filter(claim -> !claim.isAdminClaim()).mapToInt(Claim::getPlane).sum(); claimsAmount += claims.size(); @@ -366,8 +365,8 @@ public class PlayerClaimData implements IPlayerData { private int calculateUsedClaimBlocks() { int usedClaimsBlocks = 0; - for (ServerWorld world : this.player.getServer().getWorlds()) { - Collection claims = ClaimStorage.get(world).allClaimsFromPlayer(this.player.getUuid()); + for (ServerLevel world : this.player.getServer().getAllLevels()) { + Collection claims = ClaimStorage.get(world).allClaimsFromPlayer(this.player.getUUID()); if (claims != null) { usedClaimsBlocks += claims.stream().filter(claim -> !claim.isAdminClaim()).mapToInt(Claim::getPlane).sum(); } @@ -376,11 +375,11 @@ public class PlayerClaimData implements IPlayerData { } public boolean setDeathItemOwner() { - if (!this.player.isDead()) + if (!this.player.isDeadOrDying()) return false; if (this.calculateShouldDrop) { - BlockPos rounded = TeleportUtils.roundedBlockPos(this.player.getPos().add(0, this.player.getActiveEyeHeight(this.player.getPose(), this.player.getDimensions(this.player.getPose())), 0)); - this.shouldProtectDrop = ClaimStorage.get(this.player.getServerWorld()).getForPermissionCheck(rounded) + BlockPos rounded = TeleportUtils.roundedBlockPos(this.player.position().add(0, this.player.getStandingEyeHeight(this.player.getPose(), this.player.getDimensions(this.player.getPose())), 0)); + this.shouldProtectDrop = ClaimStorage.get(this.player.getLevel()).getForPermissionCheck(rounded) .canInteract(this.player, PermissionRegistry.LOCKITEMS, rounded); this.calculateShouldDrop = false; } @@ -388,11 +387,11 @@ public class PlayerClaimData implements IPlayerData { } public void save(MinecraftServer server) { - Flan.log("Saving player data for player {} with uuid {}", this.player.getName(), this.player.getUuid()); + Flan.log("Saving player data for player {} with uuid {}", this.player.getName(), this.player.getUUID()); Path dir = ConfigHandler.getPlayerSavePath(server); try { Files.createDirectories(dir); - Path file = dir.resolve(this.player.getUuid() + ".json"); + Path file = dir.resolve(this.player.getUUID() + ".json"); try { Files.createFile(file); } catch (FileAlreadyExistsException e) { @@ -418,11 +417,11 @@ public class PlayerClaimData implements IPlayerData { } public void read(MinecraftServer server) { - Flan.log("Reading player data for player {} with uuid {}", this.player.getName(), this.player.getUuid()); + Flan.log("Reading player data for player {} with uuid {}", this.player.getName(), this.player.getUUID()); try { - Path file = ConfigHandler.getPlayerSavePath(server).resolve(this.player.getUuid() + ".json"); + Path file = ConfigHandler.getPlayerSavePath(server).resolve(this.player.getUUID() + ".json"); if (!Files.exists(file)) { - Flan.log("No player data found for player {} with uuid {}", this.player.getName(), this.player.getUuid()); + Flan.log("No player data found for player {} with uuid {}", this.player.getName(), this.player.getUUID()); return; } JsonReader reader = ConfigHandler.GSON.newJsonReader(Files.newBufferedReader(file, StandardCharsets.UTF_8)); @@ -438,7 +437,7 @@ public class PlayerClaimData implements IPlayerData { try { this.editDefaultPerms(e.getKey(), PermissionRegistry.get(p.getKey()), p.getValue().getAsBoolean() ? 1 : 0); } catch (NullPointerException ex) { - Flan.logger.error("Error reading Permission {} for personal group {} for player {}. Permission doesnt exist", p.getKey(), e.getKey(), this.player.getName().asString()); + Flan.logger.error("Error reading Permission {} for personal group {} for player {}. Permission doesnt exist", p.getKey(), e.getKey(), this.player.getName().getContents()); } }); } @@ -450,8 +449,8 @@ public class PlayerClaimData implements IPlayerData { } } - public static void updateScoreFor(ServerPlayerEntity player, ScoreboardCriterion criterion, int val) { - player.getScoreboard().forEachScore(criterion, player.getEntityName(), (scoreboardPlayerScore) -> { + public static void updateScoreFor(ServerPlayer player, ObjectiveCriteria criterion, int val) { + player.getScoreboard().forAllObjectives(criterion, player.getScoreboardName(), (scoreboardPlayerScore) -> { scoreboardPlayerScore.setScore(val); }); } @@ -482,11 +481,11 @@ public class PlayerClaimData implements IPlayerData { } } - public static boolean readGriefPreventionPlayerData(MinecraftServer server, ServerCommandSource src) { + public static boolean readGriefPreventionPlayerData(MinecraftServer server, CommandSourceStack src) { Flan.log("Reading grief prevention data"); - File griefPrevention = server.getSavePath(WorldSavePath.ROOT).resolve("plugins/GriefPreventionData/PlayerData").toFile(); + File griefPrevention = server.getWorldPath(LevelResource.ROOT).resolve("plugins/GriefPreventionData/PlayerData").toFile(); if (!griefPrevention.exists()) { - src.sendFeedback(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.cantFindData, griefPrevention.getAbsolutePath()), Formatting.DARK_RED), false); + src.sendSuccess(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.cantFindData, griefPrevention.getAbsolutePath()), ChatFormatting.DARK_RED), false); return false; } for (File f : griefPrevention.listFiles()) { @@ -497,14 +496,14 @@ public class PlayerClaimData implements IPlayerData { } else { BufferedReader reader = new BufferedReader(new FileReader(f)); - ServerPlayerEntity player = server.getPlayerManager().getPlayer(UUID.fromString(f.getName())); + ServerPlayer player = server.getPlayerList().getPlayer(UUID.fromString(f.getName())); if (player != null) { PlayerClaimData data = PlayerClaimData.get(player); reader.readLine(); data.claimBlocks = Integer.parseInt(reader.readLine()); data.additionalClaimBlocks = Integer.parseInt(reader.readLine()); } else { - File dir = new File(server.getSavePath(WorldSavePath.PLAYERDATA).toFile(), "/claimData/"); + File dir = new File(server.getWorldPath(LevelResource.PLAYER_DATA_DIR).toFile(), "/claimData/"); if (!dir.exists()) dir.mkdir(); File file = new File(dir, f.getName() + ".json"); @@ -521,7 +520,7 @@ public class PlayerClaimData implements IPlayerData { reader.close(); } } catch (Exception e) { - src.sendFeedback(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.errorFile, f.getName(), Formatting.RED)), false); + src.sendSuccess(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.errorFile, f.getName(), ChatFormatting.RED)), false); } } return true; diff --git a/common/src/main/java/io/github/flemmli97/flan/player/PlayerDataHandler.java b/common/src/main/java/io/github/flemmli97/flan/player/PlayerDataHandler.java index 727af1d..d46db5d 100644 --- a/common/src/main/java/io/github/flemmli97/flan/player/PlayerDataHandler.java +++ b/common/src/main/java/io/github/flemmli97/flan/player/PlayerDataHandler.java @@ -4,7 +4,7 @@ import io.github.flemmli97.flan.Flan; import io.github.flemmli97.flan.claim.ClaimStorage; import io.github.flemmli97.flan.config.ConfigHandler; import net.minecraft.server.MinecraftServer; -import net.minecraft.server.world.ServerWorld; +import net.minecraft.server.level.ServerLevel; import java.nio.file.Files; import java.nio.file.Path; @@ -40,11 +40,11 @@ public class PlayerDataHandler { return playerDatas; } - public static void deleteUnusedClaims(MinecraftServer server, ClaimStorage storage, ServerWorld world) { + public static void deleteUnusedClaims(MinecraftServer server, ClaimStorage storage, ServerLevel world) { if (inActivePlayerData == null) initInactivePlayers(server); inActivePlayerData.forEach((uuid, data) -> { - Flan.log("{} Deleting all claims for inactive player {} last seen {}", world.getRegistryKey(), data.owner, data.lastOnline); + Flan.log("{} Deleting all claims for inactive player {} last seen {}", world.dimension(), data.owner, data.lastOnline); storage.allClaimsFromPlayer(data.owner) .forEach(claim -> storage.deleteClaim(claim, true, EnumEditMode.DEFAULT, world)); }); diff --git a/common/src/main/java/io/github/flemmli97/flan/player/TeleportUtils.java b/common/src/main/java/io/github/flemmli97/flan/player/TeleportUtils.java index 9cb411d..fda4503 100644 --- a/common/src/main/java/io/github/flemmli97/flan/player/TeleportUtils.java +++ b/common/src/main/java/io/github/flemmli97/flan/player/TeleportUtils.java @@ -2,39 +2,38 @@ package io.github.flemmli97.flan.player; import io.github.flemmli97.flan.claim.Claim; import io.github.flemmli97.flan.claim.ClaimStorage; -import net.minecraft.server.network.ServerPlayerEntity; -import net.minecraft.util.Pair; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; -import net.minecraft.util.math.Vec3d; -import net.minecraft.util.shape.VoxelShape; -import net.minecraft.world.Heightmap; -import net.minecraft.world.chunk.ChunkStatus; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.util.Tuple; +import net.minecraft.world.level.chunk.ChunkStatus; +import net.minecraft.world.level.levelgen.Heightmap; +import net.minecraft.world.phys.Vec3; import java.util.function.BiFunction; public class TeleportUtils { - public static BlockPos roundedBlockPos(Vec3d pos) { + public static BlockPos roundedBlockPos(Vec3 pos) { return new BlockPos(pos); } - public static Vec3d getTeleportPos(ServerPlayerEntity player, Vec3d playerPos, ClaimStorage storage, int[] dim, BlockPos.Mutable bPos, BiFunction check) { - Pair pos = nearestOutside(dim, playerPos); - bPos.set(pos.getRight().getX(), pos.getRight().getY(), pos.getRight().getZ()); + public static Vec3 getTeleportPos(ServerPlayer player, Vec3 playerPos, ClaimStorage storage, int[] dim, BlockPos.MutableBlockPos bPos, BiFunction check) { + Tuple pos = nearestOutside(dim, playerPos); + bPos.set(pos.getB().x(), pos.getB().y(), pos.getB().z()); Claim claim = storage.getClaimAt(bPos); if (claim == null || check.apply(claim, bPos)) { - Vec3d ret = pos.getRight(); + Vec3 ret = pos.getB(); BlockPos rounded = roundedBlockPos(ret); - int y = player.getServerWorld().getChunk(rounded.getX() >> 4, rounded.getZ() >> 4, ChunkStatus.HEIGHTMAPS) - .sampleHeightmap(Heightmap.Type.MOTION_BLOCKING, rounded.getX() & 15, rounded.getZ() & 15); - Vec3d dest = new Vec3d(ret.x, y + 1, ret.z); - if (player.world.getBlockCollisions(player, player.getBoundingBox().offset(dest.subtract(player.getPos())), (state, p) -> true).allMatch(VoxelShape::isEmpty)) + int y = player.getLevel().getChunk(rounded.getX() >> 4, rounded.getZ() >> 4, ChunkStatus.HEIGHTMAPS) + .getHeight(Heightmap.Types.MOTION_BLOCKING, rounded.getX() & 15, rounded.getZ() & 15); + Vec3 dest = new Vec3(ret.x, y + 1, ret.z); + if (player.level.noCollision(player, player.getBoundingBox().move(dest.subtract(player.position())))) return dest; - return new Vec3d(rounded.getX() + 0.5, y + 1, rounded.getZ() + 0.5); + return new Vec3(rounded.getX() + 0.5, y + 1, rounded.getZ() + 0.5); } int[] newDim = claim.getDimensions(); - switch (pos.getLeft()) { + switch (pos.getA()) { case NORTH: dim[2] = newDim[2]; break; @@ -51,28 +50,28 @@ public class TeleportUtils { return getTeleportPos(player, playerPos, storage, dim, bPos, check); } - private static Pair nearestOutside(int[] dim, Vec3d from) { - double northDist = Math.abs(from.getZ() - dim[2]); - double southDist = Math.abs(dim[3] - from.getZ()); - double westDist = Math.abs(from.getX() - dim[0]); - double eastDist = Math.abs(dim[1] - from.getX()); + private static Tuple nearestOutside(int[] dim, Vec3 from) { + double northDist = Math.abs(from.z() - dim[2]); + double southDist = Math.abs(dim[3] - from.z()); + double westDist = Math.abs(from.x() - dim[0]); + double eastDist = Math.abs(dim[1] - from.x()); if (northDist > southDist) { if (eastDist > westDist) { if (southDist > westDist) - return new Pair<>(Direction.WEST, new Vec3d(dim[0] - 1.5, from.getY(), from.getZ())); - return new Pair<>(Direction.SOUTH, new Vec3d(from.getX(), from.getY(), dim[3] + 1.5)); + return new Tuple<>(Direction.WEST, new Vec3(dim[0] - 1.5, from.y(), from.z())); + return new Tuple<>(Direction.SOUTH, new Vec3(from.x(), from.y(), dim[3] + 1.5)); } if (southDist > eastDist) - return new Pair<>(Direction.EAST, new Vec3d(dim[1] + 1.5, from.getY(), from.getZ())); - return new Pair<>(Direction.SOUTH, new Vec3d(from.getX(), from.getY(), dim[3] + 1.5)); + return new Tuple<>(Direction.EAST, new Vec3(dim[1] + 1.5, from.y(), from.z())); + return new Tuple<>(Direction.SOUTH, new Vec3(from.x(), from.y(), dim[3] + 1.5)); } if (eastDist > westDist) { if (northDist > westDist) - return new Pair<>(Direction.WEST, new Vec3d(dim[0] - 1.5, from.getY(), from.getZ())); - return new Pair<>(Direction.NORTH, new Vec3d(from.getX(), from.getY(), dim[2] - 1.5)); + return new Tuple<>(Direction.WEST, new Vec3(dim[0] - 1.5, from.y(), from.z())); + return new Tuple<>(Direction.NORTH, new Vec3(from.x(), from.y(), dim[2] - 1.5)); } if (northDist > eastDist) - return new Pair<>(Direction.EAST, new Vec3d(dim[1] + 1.5, from.getY(), from.getZ())); - return new Pair<>(Direction.NORTH, new Vec3d(from.getX(), from.getY(), dim[2] - 1.5)); + return new Tuple<>(Direction.EAST, new Vec3(dim[1] + 1.5, from.y(), from.z())); + return new Tuple<>(Direction.NORTH, new Vec3(from.x(), from.y(), dim[2] - 1.5)); } } diff --git a/common/src/main/java/io/github/flemmli97/flan/scoreboard/ClaimCriterias.java b/common/src/main/java/io/github/flemmli97/flan/scoreboard/ClaimCriterias.java index 1f8c76d..cf26736 100644 --- a/common/src/main/java/io/github/flemmli97/flan/scoreboard/ClaimCriterias.java +++ b/common/src/main/java/io/github/flemmli97/flan/scoreboard/ClaimCriterias.java @@ -1,16 +1,16 @@ package io.github.flemmli97.flan.scoreboard; -import net.minecraft.scoreboard.ScoreboardCriterion; +import net.minecraft.world.scores.criteria.ObjectiveCriteria; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; public class ClaimCriterias { - public static ScoreboardCriterion AMOUNT = create("flan:total_claimblocks", true, ScoreboardCriterion.RenderType.INTEGER); - public static ScoreboardCriterion USED = create("flan:used_claimblocks", true, ScoreboardCriterion.RenderType.INTEGER); - public static ScoreboardCriterion FREE = create("flan:free_claimblocks", true, ScoreboardCriterion.RenderType.INTEGER); - public static ScoreboardCriterion CLAIMS = create("flan:claim_number", true, ScoreboardCriterion.RenderType.INTEGER); + public static ObjectiveCriteria AMOUNT = create("flan:total_claimblocks", true, ObjectiveCriteria.RenderType.INTEGER); + public static ObjectiveCriteria USED = create("flan:used_claimblocks", true, ObjectiveCriteria.RenderType.INTEGER); + public static ObjectiveCriteria FREE = create("flan:free_claimblocks", true, ObjectiveCriteria.RenderType.INTEGER); + public static ObjectiveCriteria CLAIMS = create("flan:claim_number", true, ObjectiveCriteria.RenderType.INTEGER); public static void init() { @@ -19,9 +19,9 @@ public class ClaimCriterias { /** * Just reflection cause its only called once during init */ - private static ScoreboardCriterion create(String name, boolean readOnly, ScoreboardCriterion.RenderType renderType) { + private static ObjectiveCriteria create(String name, boolean readOnly, ObjectiveCriteria.RenderType renderType) { try { - Constructor cons = ScoreboardCriterion.class.getDeclaredConstructor(String.class, boolean.class, ScoreboardCriterion.RenderType.class); + Constructor cons = ObjectiveCriteria.class.getDeclaredConstructor(String.class, boolean.class, ObjectiveCriteria.RenderType.class); cons.setAccessible(true); return cons.newInstance(name, readOnly, renderType); } catch (NoSuchMethodException | InstantiationException | IllegalAccessException | InvocationTargetException e) { diff --git a/common/src/main/resources/flan.mixins.json b/common/src/main/resources/flan.mixins.json index 8215d09..e94c043 100644 --- a/common/src/main/resources/flan.mixins.json +++ b/common/src/main/resources/flan.mixins.json @@ -24,7 +24,8 @@ "FrostWalkerMixin", "LightningFireEntityMixin", "BannedEntryAccessor", - "MinecraftServerMixin" + "MinecraftServerMixin", + "AbstractContainerAccessor" ], "server": [ ], diff --git a/fabric/build.gradle b/fabric/build.gradle index 53fa1d7..5afddf9 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -1,9 +1,5 @@ plugins { - id "com.github.johnrengelman.shadow" version "5.0.0" -} - -configurations { - shadowCommon // Don't use shadow from the shadow plugin because we don't want IDEA to index this. + id "com.github.johnrengelman.shadow" version "7.1.0" } architectury { @@ -11,6 +7,14 @@ architectury { fabric() } +configurations { + common + shadowCommon // Don't use shadow from the shadow plugin because we don't want IDEA to index this. + compileClasspath.extendsFrom common + runtimeClasspath.extendsFrom common + developmentFabric.extendsFrom common +} + repositories { mavenCentral() maven { @@ -44,7 +48,10 @@ dependencies { // Fabric API. This is technically optional, but you probably want it anyway. modImplementation "net.fabricmc.fabric-api:fabric-api:${rootProject.fabric_version}" - + + common(project(path: ":common", configuration: "namedElements")) { transitive false } + shadowCommon(project(path: ":common", configuration: "transformProductionFabric")) { transitive false } +/* modImplementation "me.lucko:fabric-permissions-api:${rootProject.fabric_permissions_api}" modCompileOnly "io.github.gunpowder:gunpowder-api:${rootProject.gunpowder_version}" modRuntime "io.github.gunpowder:gunpowder-base:${rootProject.gunpowder_version}" @@ -52,17 +59,7 @@ dependencies { modImplementation "io.github.ladysnake:PlayerAbilityLib:${rootProject.player_ability_lib}" - implementation(project(path: ":common")) { - transitive = false - } - developmentFabric(project(path: ":common")) { - transitive = false - } - shadowCommon(project(path: ":common", configuration: "transformProductionFabric")) { - transitive = false - } - - modImplementation("dev.ftb.mods:ftb-ranks-fabric:1605.1.2-build.17") + modImplementation("dev.ftb.mods:ftb-ranks-fabric:1605.1.2-build.17")*/ } processResources { @@ -88,10 +85,6 @@ jar { classifier "dev" } -java { - withSourcesJar() -} - sourcesJar { def commonSources = project(":common").sourcesJar dependsOn commonSources @@ -99,6 +92,12 @@ sourcesJar { classifier "fabric-source" } +components.java { + withVariantsFromConfiguration(project.configurations.shadowRuntimeElements) { + skip() + } +} + task apiJar(type: Jar, dependsOn: classes) { archiveClassifier.set "fabric-api-source" from project(":common").sourceSets.main.output + sourceSets.main.output diff --git a/fabric/gradle/wrapper/gradle-wrapper.properties b/fabric/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..be52383 --- /dev/null +++ b/fabric/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-bin.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/fabric/src/main/java/io/github/flemmli97/flan/FabricRegistryWrapper.java b/fabric/src/main/java/io/github/flemmli97/flan/FabricRegistryWrapper.java index 6688c23..c6b9a5d 100644 --- a/fabric/src/main/java/io/github/flemmli97/flan/FabricRegistryWrapper.java +++ b/fabric/src/main/java/io/github/flemmli97/flan/FabricRegistryWrapper.java @@ -1,7 +1,7 @@ package io.github.flemmli97.flan; -import net.minecraft.util.Identifier; -import net.minecraft.util.registry.Registry; +import net.minecraft.core.Registry; +import net.minecraft.resources.ResourceLocation; public class FabricRegistryWrapper implements SimpleRegistryWrapper { @@ -12,13 +12,13 @@ public class FabricRegistryWrapper implements SimpleRegistryWrapper { } @Override - public T getFromId(Identifier id) { + public T getFromId(ResourceLocation id) { return this.delegate.get(id); } @Override - public Identifier getIDFrom(T entry) { - return this.delegate.getId(entry); + public ResourceLocation getIDFrom(T entry) { + return this.delegate.getKey(entry); } @Override diff --git a/fabric/src/main/java/io/github/flemmli97/flan/api/fabric/PermissionCheckEvent.java b/fabric/src/main/java/io/github/flemmli97/flan/api/fabric/PermissionCheckEvent.java index c79e9a8..387ccbd 100644 --- a/fabric/src/main/java/io/github/flemmli97/flan/api/fabric/PermissionCheckEvent.java +++ b/fabric/src/main/java/io/github/flemmli97/flan/api/fabric/PermissionCheckEvent.java @@ -3,9 +3,9 @@ package io.github.flemmli97.flan.api.fabric; import io.github.flemmli97.flan.api.permission.ClaimPermission; import net.fabricmc.fabric.api.event.Event; import net.fabricmc.fabric.api.event.EventFactory; -import net.minecraft.server.network.ServerPlayerEntity; -import net.minecraft.util.ActionResult; -import net.minecraft.util.math.BlockPos; +import net.minecraft.core.BlockPos; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.InteractionResult; public class PermissionCheckEvent { @@ -19,21 +19,21 @@ public class PermissionCheckEvent { * @param pos The block pos where the action is occuring * @return ActionResult#PASS to do nothing. ActionResult#FAIL to prevent the action. Else to allow the action */ - ActionResult check(ServerPlayerEntity player, ClaimPermission permission, BlockPos pos); + InteractionResult check(ServerPlayer player, ClaimPermission permission, BlockPos pos); } public static Event CHECK = EventFactory.createArrayBacked(PermissionCheck.class, (listeners) -> (player, permission, pos) -> { for (PermissionCheck event : listeners) { - ActionResult result = event.check(player, permission, pos); + InteractionResult result = event.check(player, permission, pos); - if (result != ActionResult.PASS) { + if (result != InteractionResult.PASS) { return result; } } - return ActionResult.PASS; + return InteractionResult.PASS; } ); } diff --git a/fabric/src/main/java/io/github/flemmli97/flan/claim/fabric/ClaimPermissionCheckImpl.java b/fabric/src/main/java/io/github/flemmli97/flan/claim/fabric/ClaimPermissionCheckImpl.java index 574a6b7..4653dd7 100644 --- a/fabric/src/main/java/io/github/flemmli97/flan/claim/fabric/ClaimPermissionCheckImpl.java +++ b/fabric/src/main/java/io/github/flemmli97/flan/claim/fabric/ClaimPermissionCheckImpl.java @@ -2,13 +2,13 @@ package io.github.flemmli97.flan.claim.fabric; import io.github.flemmli97.flan.api.fabric.PermissionCheckEvent; import io.github.flemmli97.flan.api.permission.ClaimPermission; -import net.minecraft.server.network.ServerPlayerEntity; -import net.minecraft.util.ActionResult; -import net.minecraft.util.math.BlockPos; +import net.minecraft.core.BlockPos; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.InteractionResult; public class ClaimPermissionCheckImpl { - public static ActionResult check(ServerPlayerEntity player, ClaimPermission permission, BlockPos pos) { + public static InteractionResult check(ServerPlayer player, ClaimPermission permission, BlockPos pos) { return PermissionCheckEvent.CHECK.invoker().check(player, permission, pos); } } diff --git a/fabric/src/main/java/io/github/flemmli97/flan/fabric/CrossPlatformStuffImpl.java b/fabric/src/main/java/io/github/flemmli97/flan/fabric/CrossPlatformStuffImpl.java index 8d70370..6c0cece 100644 --- a/fabric/src/main/java/io/github/flemmli97/flan/fabric/CrossPlatformStuffImpl.java +++ b/fabric/src/main/java/io/github/flemmli97/flan/fabric/CrossPlatformStuffImpl.java @@ -3,16 +3,16 @@ package io.github.flemmli97.flan.fabric; import io.github.flemmli97.flan.FabricRegistryWrapper; import io.github.flemmli97.flan.SimpleRegistryWrapper; import net.fabricmc.loader.api.FabricLoader; -import net.minecraft.block.Block; -import net.minecraft.block.InventoryProvider; -import net.minecraft.block.entity.BlockEntity; -import net.minecraft.entity.EntityType; -import net.minecraft.entity.effect.StatusEffect; -import net.minecraft.inventory.Inventory; -import net.minecraft.item.Item; +import net.minecraft.core.Registry; import net.minecraft.nbt.CompoundTag; -import net.minecraft.util.Identifier; -import net.minecraft.util.registry.Registry; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.Container; +import net.minecraft.world.WorldlyContainerHolder; +import net.minecraft.world.effect.MobEffect; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.item.Item; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.entity.BlockEntity; import java.nio.file.Path; @@ -22,16 +22,16 @@ public class CrossPlatformStuffImpl { return FabricLoader.getInstance().getConfigDir(); } - public static StatusEffect effectFromString(String s) { - return Registry.STATUS_EFFECT.get(new Identifier(s)); + public static MobEffect effectFromString(String s) { + return Registry.MOB_EFFECT.get(new ResourceLocation(s)); } - public static String stringFromEffect(StatusEffect s) { - return Registry.STATUS_EFFECT.getId(s).toString(); + public static String stringFromEffect(MobEffect s) { + return Registry.MOB_EFFECT.getKey(s).toString(); } - public static SimpleRegistryWrapper registryStatusEffects() { - return new FabricRegistryWrapper<>(Registry.STATUS_EFFECT); + public static SimpleRegistryWrapper registryStatusEffects() { + return new FabricRegistryWrapper<>(Registry.MOB_EFFECT); } public static SimpleRegistryWrapper registryBlocks() { @@ -47,7 +47,7 @@ public class CrossPlatformStuffImpl { } public static boolean isInventoryTile(BlockEntity blockEntity) { - return blockEntity instanceof Inventory || blockEntity instanceof InventoryProvider; + return blockEntity instanceof Container || blockEntity instanceof WorldlyContainerHolder; } public static boolean blockDataContains(CompoundTag nbt, String tag) { diff --git a/fabric/src/main/java/io/github/flemmli97/flan/fabric/mixin/EntityDamageMixin.java b/fabric/src/main/java/io/github/flemmli97/flan/fabric/mixin/EntityDamageMixin.java index 5db6423..e3f54bd 100644 --- a/fabric/src/main/java/io/github/flemmli97/flan/fabric/mixin/EntityDamageMixin.java +++ b/fabric/src/main/java/io/github/flemmli97/flan/fabric/mixin/EntityDamageMixin.java @@ -1,25 +1,25 @@ package io.github.flemmli97.flan.fabric.mixin; import io.github.flemmli97.flan.event.EntityInteractEvents; -import net.minecraft.entity.Entity; -import net.minecraft.entity.ItemEntity; -import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.damage.DamageSource; -import net.minecraft.entity.decoration.AbstractDecorationEntity; -import net.minecraft.entity.decoration.ArmorStandEntity; -import net.minecraft.entity.decoration.EndCrystalEntity; -import net.minecraft.entity.vehicle.AbstractMinecartEntity; -import net.minecraft.entity.vehicle.BoatEntity; +import net.minecraft.world.damagesource.DamageSource; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.boss.enderdragon.EndCrystal; +import net.minecraft.world.entity.decoration.ArmorStand; +import net.minecraft.world.entity.decoration.HangingEntity; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.entity.vehicle.AbstractMinecart; +import net.minecraft.world.entity.vehicle.Boat; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -@Mixin({LivingEntity.class, Entity.class, AbstractDecorationEntity.class, AbstractMinecartEntity.class, ArmorStandEntity.class, BoatEntity.class - , EndCrystalEntity.class, ItemEntity.class}) +@Mixin({LivingEntity.class, Entity.class, HangingEntity.class, AbstractMinecart.class, ArmorStand.class, Boat.class + , EndCrystal.class, ItemEntity.class}) public abstract class EntityDamageMixin { - @Inject(method = "damage", at = @At(value = "HEAD"), cancellable = true) + @Inject(method = "hurt", at = @At(value = "HEAD"), cancellable = true) private void onDamage(DamageSource source, float amount, CallbackInfoReturnable info) { if (EntityInteractEvents.preventDamage((Entity) (Object) this, source)) { info.setReturnValue(false); diff --git a/fabric/src/main/java/io/github/flemmli97/flan/fabric/mixin/FabricFireMixin.java b/fabric/src/main/java/io/github/flemmli97/flan/fabric/mixin/FabricFireMixin.java index efca142..015a34e 100644 --- a/fabric/src/main/java/io/github/flemmli97/flan/fabric/mixin/FabricFireMixin.java +++ b/fabric/src/main/java/io/github/flemmli97/flan/fabric/mixin/FabricFireMixin.java @@ -1,10 +1,10 @@ package io.github.flemmli97.flan.fabric.mixin; import io.github.flemmli97.flan.event.WorldEvents; -import net.minecraft.block.FireBlock; -import net.minecraft.server.world.ServerWorld; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; +import net.minecraft.core.BlockPos; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.FireBlock; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -15,9 +15,12 @@ import java.util.Random; @Mixin(FireBlock.class) public abstract class FabricFireMixin { - @Inject(method = "trySpreadingFire", at = @At(value = "HEAD"), cancellable = true) - private void spread(World world, BlockPos pos, int spreadFactor, Random rand, int currentAge, CallbackInfo info) { - if (!world.isClient && !WorldEvents.canFireSpread((ServerWorld) world, pos)) { + /** + * Check for blocks reacting to fire (e.g. tnt) + */ + @Inject(method = "checkBurnOut", at = @At(value = "HEAD"), cancellable = true) + private void spread(Level world, BlockPos pos, int spreadFactor, Random rand, int currentAge, CallbackInfo info) { + if (!world.isClientSide && !WorldEvents.canFireSpread((ServerLevel) world, pos)) { info.cancel(); } } diff --git a/fabric/src/main/java/io/github/flemmli97/flan/fabric/mixin/LightningHitMixin.java b/fabric/src/main/java/io/github/flemmli97/flan/fabric/mixin/LightningHitMixin.java index a28ca44..e85adad 100644 --- a/fabric/src/main/java/io/github/flemmli97/flan/fabric/mixin/LightningHitMixin.java +++ b/fabric/src/main/java/io/github/flemmli97/flan/fabric/mixin/LightningHitMixin.java @@ -1,15 +1,15 @@ package io.github.flemmli97.flan.fabric.mixin; import io.github.flemmli97.flan.event.EntityInteractEvents; -import net.minecraft.entity.Entity; -import net.minecraft.entity.LightningEntity; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.LightningBolt; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.ModifyVariable; import java.util.List; -@Mixin(LightningEntity.class) +@Mixin(LightningBolt.class) public abstract class LightningHitMixin { @ModifyVariable(method = "tick", at = @At(value = "INVOKE", target = "Ljava/util/List;iterator()Ljava/util/Iterator;"), require = 1) diff --git a/fabric/src/main/java/io/github/flemmli97/flan/fabric/mixin/PistonMixin.java b/fabric/src/main/java/io/github/flemmli97/flan/fabric/mixin/PistonMixin.java index 3b0130a..affcbe9 100644 --- a/fabric/src/main/java/io/github/flemmli97/flan/fabric/mixin/PistonMixin.java +++ b/fabric/src/main/java/io/github/flemmli97/flan/fabric/mixin/PistonMixin.java @@ -1,21 +1,21 @@ package io.github.flemmli97.flan.fabric.mixin; import io.github.flemmli97.flan.event.WorldEvents; -import net.minecraft.block.BlockState; -import net.minecraft.block.PistonBlock; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; -import net.minecraft.world.World; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.piston.PistonBaseBlock; +import net.minecraft.world.level.block.state.BlockState; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -@Mixin(PistonBlock.class) +@Mixin(PistonBaseBlock.class) public abstract class PistonMixin { - @Inject(method = "isMovable", at = @At(value = "HEAD"), cancellable = true) - private static void checkMovable(BlockState blockState, World world, BlockPos blockPos, Direction direction, boolean canBreak, Direction pistonDir, CallbackInfoReturnable info) { + @Inject(method = "isPushable", at = @At(value = "HEAD"), cancellable = true) + private static void checkMovable(BlockState blockState, Level world, BlockPos blockPos, Direction direction, boolean canBreak, Direction pistonDir, CallbackInfoReturnable info) { if (!WorldEvents.pistonCanPush(blockState, world, blockPos, direction, pistonDir)) { info.setReturnValue(false); info.cancel(); diff --git a/fabric/src/main/java/io/github/flemmli97/flan/fabric/mixin/PlayerDropMixin.java b/fabric/src/main/java/io/github/flemmli97/flan/fabric/mixin/PlayerDropMixin.java index 799eabf..98bba0b 100644 --- a/fabric/src/main/java/io/github/flemmli97/flan/fabric/mixin/PlayerDropMixin.java +++ b/fabric/src/main/java/io/github/flemmli97/flan/fabric/mixin/PlayerDropMixin.java @@ -1,20 +1,20 @@ package io.github.flemmli97.flan.fabric.mixin; import io.github.flemmli97.flan.event.EntityInteractEvents; -import net.minecraft.entity.ItemEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.ItemStack; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -@Mixin(PlayerEntity.class) +@Mixin(Player.class) public abstract class PlayerDropMixin { - @Inject(method = "dropItem(Lnet/minecraft/item/ItemStack;ZZ)Lnet/minecraft/entity/ItemEntity;", at = @At(value = "HEAD"), cancellable = true) + @Inject(method = "drop(Lnet/minecraft/world/item/ItemStack;ZZ)Lnet/minecraft/world/entity/item/ItemEntity;", at = @At(value = "HEAD"), cancellable = true) private void drop(ItemStack stack, boolean throwRandomly, boolean retainOwnership, CallbackInfoReturnable info) { - if (!EntityInteractEvents.canDropItem((PlayerEntity) (Object) this, stack)) { + if (!EntityInteractEvents.canDropItem((Player) (Object) this, stack)) { info.setReturnValue(null); info.cancel(); } diff --git a/fabric/src/main/java/io/github/flemmli97/flan/fabric/mixin/PlayerInteractEntityMixin.java b/fabric/src/main/java/io/github/flemmli97/flan/fabric/mixin/PlayerInteractEntityMixin.java new file mode 100644 index 0000000..5cc363f --- /dev/null +++ b/fabric/src/main/java/io/github/flemmli97/flan/fabric/mixin/PlayerInteractEntityMixin.java @@ -0,0 +1,30 @@ +package io.github.flemmli97.flan.fabric.mixin; + +import io.github.flemmli97.flan.event.EntityInteractEvents; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.player.Player; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +/** + * Fabric APIs UseEntityCallback is at Entity#interactAt and thats only used for armor stand. Why its only there idk... + */ +@Mixin(Player.class) +public abstract class PlayerInteractEntityMixin { + + @Inject(method = "interactOn", at = @At(value = "HEAD"), cancellable = true) + private void interactOnEntity(Entity entity, InteractionHand interactionHand, CallbackInfoReturnable info) { + if (entity == null || !(entity.level instanceof ServerLevel)) + return; + InteractionResult result = EntityInteractEvents.useEntity((Player) (Object) this, entity.level, interactionHand, entity); + if (result != InteractionResult.PASS) { + info.setReturnValue(InteractionResult.PASS); + info.cancel(); + } + } +} diff --git a/fabric/src/main/java/io/github/flemmli97/flan/fabric/mixin/PlayerManagerMixin.java b/fabric/src/main/java/io/github/flemmli97/flan/fabric/mixin/PlayerManagerMixin.java index 8182c9f..df64d86 100644 --- a/fabric/src/main/java/io/github/flemmli97/flan/fabric/mixin/PlayerManagerMixin.java +++ b/fabric/src/main/java/io/github/flemmli97/flan/fabric/mixin/PlayerManagerMixin.java @@ -2,18 +2,18 @@ package io.github.flemmli97.flan.fabric.mixin; import io.github.flemmli97.flan.event.PlayerEvents; import net.minecraft.nbt.CompoundTag; -import net.minecraft.server.PlayerManager; -import net.minecraft.server.network.ServerPlayerEntity; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.server.players.PlayerList; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -@Mixin(PlayerManager.class) +@Mixin(PlayerList.class) public abstract class PlayerManagerMixin { - @Inject(method = "loadPlayerData", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/network/ServerPlayerEntity;fromTag(Lnet/minecraft/nbt/CompoundTag;)V")) - private void singlePlayerRead(ServerPlayerEntity player, CallbackInfoReturnable info) { + @Inject(method = "load", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ServerPlayer;load(Lnet/minecraft/nbt/CompoundTag;)V")) + private void singlePlayerRead(ServerPlayer player, CallbackInfoReturnable info) { PlayerEvents.readClaimData(player); } } diff --git a/fabric/src/main/java/io/github/flemmli97/flan/fabric/mixin/ProjectileMixin.java b/fabric/src/main/java/io/github/flemmli97/flan/fabric/mixin/ProjectileMixin.java index b2efd24..f5251fa 100644 --- a/fabric/src/main/java/io/github/flemmli97/flan/fabric/mixin/ProjectileMixin.java +++ b/fabric/src/main/java/io/github/flemmli97/flan/fabric/mixin/ProjectileMixin.java @@ -1,24 +1,24 @@ package io.github.flemmli97.flan.fabric.mixin; import io.github.flemmli97.flan.event.EntityInteractEvents; -import net.minecraft.entity.projectile.DragonFireballEntity; -import net.minecraft.entity.projectile.ProjectileEntity; -import net.minecraft.entity.projectile.thrown.EggEntity; -import net.minecraft.entity.projectile.thrown.EnderPearlEntity; -import net.minecraft.entity.projectile.thrown.ExperienceBottleEntity; -import net.minecraft.entity.projectile.thrown.PotionEntity; -import net.minecraft.util.hit.HitResult; +import net.minecraft.world.entity.projectile.DragonFireball; +import net.minecraft.world.entity.projectile.Projectile; +import net.minecraft.world.entity.projectile.ThrownEgg; +import net.minecraft.world.entity.projectile.ThrownEnderpearl; +import net.minecraft.world.entity.projectile.ThrownExperienceBottle; +import net.minecraft.world.entity.projectile.ThrownPotion; +import net.minecraft.world.phys.HitResult; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -@Mixin(value = {ProjectileEntity.class, EggEntity.class, PotionEntity.class, ExperienceBottleEntity.class, DragonFireballEntity.class, EnderPearlEntity.class}) +@Mixin(value = {Projectile.class, ThrownEgg.class, ThrownPotion.class, ThrownExperienceBottle.class, DragonFireball.class, ThrownEnderpearl.class}) public abstract class ProjectileMixin { - @Inject(method = "onCollision", at = @At(value = "HEAD"), cancellable = true) + @Inject(method = "onHit", at = @At(value = "HEAD"), cancellable = true) private void collision(HitResult hitResult, CallbackInfo info) { - if (EntityInteractEvents.projectileHit((ProjectileEntity) (Object) this, hitResult)) { + if (EntityInteractEvents.projectileHit((Projectile) (Object) this, hitResult)) { info.cancel(); } } diff --git a/fabric/src/main/java/io/github/flemmli97/flan/fabric/mixin/ServerPlayNetworkHandlerMixin.java b/fabric/src/main/java/io/github/flemmli97/flan/fabric/mixin/ServerPlayNetworkHandlerMixin.java deleted file mode 100644 index a93be99..0000000 --- a/fabric/src/main/java/io/github/flemmli97/flan/fabric/mixin/ServerPlayNetworkHandlerMixin.java +++ /dev/null @@ -1,36 +0,0 @@ -package io.github.flemmli97.flan.fabric.mixin; - -import io.github.flemmli97.flan.event.EntityInteractEvents; -import net.minecraft.entity.Entity; -import net.minecraft.network.packet.c2s.play.PlayerInteractEntityC2SPacket; -import net.minecraft.server.network.ServerPlayNetworkHandler; -import net.minecraft.server.network.ServerPlayerEntity; -import net.minecraft.util.ActionResult; -import net.minecraft.world.World; -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; - -/** - * Fabric APIs UseEntityCallback is at Entity#interactAt and thats only used for armor stand. Why its only there idk... - */ -@Mixin(ServerPlayNetworkHandler.class) -public abstract class ServerPlayNetworkHandlerMixin { - - @Shadow - private ServerPlayerEntity player; - - @Inject(method = "onPlayerInteractEntity", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/network/ServerPlayerEntity;interact(Lnet/minecraft/entity/Entity;Lnet/minecraft/util/Hand;)Lnet/minecraft/util/ActionResult;"), cancellable = true) - private void onPlayerInteractEntity(PlayerInteractEntityC2SPacket packet, CallbackInfo info) { - World world = this.player.getEntityWorld(); - Entity entity = packet.getEntity(world); - if (entity != null) { - ActionResult result = EntityInteractEvents.useEntity(this.player, world, packet.getHand(), entity); - if (result != ActionResult.PASS) { - info.cancel(); - } - } - } -} diff --git a/fabric/src/main/java/io/github/flemmli97/flan/fabric/mixin/ServerWorldMixin.java b/fabric/src/main/java/io/github/flemmli97/flan/fabric/mixin/ServerWorldMixin.java index bd3d2f4..2bc28ba 100644 --- a/fabric/src/main/java/io/github/flemmli97/flan/fabric/mixin/ServerWorldMixin.java +++ b/fabric/src/main/java/io/github/flemmli97/flan/fabric/mixin/ServerWorldMixin.java @@ -1,22 +1,22 @@ package io.github.flemmli97.flan.fabric.mixin; import io.github.flemmli97.flan.event.WorldEvents; -import net.minecraft.entity.Entity; -import net.minecraft.entity.damage.DamageSource; -import net.minecraft.server.world.ServerWorld; -import net.minecraft.world.explosion.Explosion; -import net.minecraft.world.explosion.ExplosionBehavior; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.damagesource.DamageSource; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.level.Explosion; +import net.minecraft.world.level.ExplosionDamageCalculator; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import org.spongepowered.asm.mixin.injection.callback.LocalCapture; -@Mixin(ServerWorld.class) +@Mixin(ServerLevel.class) public abstract class ServerWorldMixin { - @Inject(method = "createExplosion", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/explosion/Explosion;collectBlocksAndDamageEntities()V", shift = At.Shift.AFTER), locals = LocalCapture.CAPTURE_FAILHARD) - private void explosionHook(Entity entity, DamageSource damageSource, ExplosionBehavior explosionBehavior, double d, double e, double f, float g, boolean bl, Explosion.DestructionType destructionType, CallbackInfoReturnable info, Explosion explosion) { - WorldEvents.modifyExplosion(explosion, (ServerWorld) (Object) this); + @Inject(method = "explode", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/Explosion;explode()V", shift = At.Shift.AFTER), locals = LocalCapture.CAPTURE_FAILHARD) + private void explosionHook(Entity entity, DamageSource damageSource, ExplosionDamageCalculator explosionBehavior, double d, double e, double f, float g, boolean bl, Explosion.BlockInteraction destructionType, CallbackInfoReturnable info, Explosion explosion) { + WorldEvents.modifyExplosion(explosion, (ServerLevel) (Object) this); } } diff --git a/fabric/src/main/java/io/github/flemmli97/flan/fabric/mixin/SnowGolemMixin.java b/fabric/src/main/java/io/github/flemmli97/flan/fabric/mixin/SnowGolemMixin.java index f9d953f..c3d3671 100644 --- a/fabric/src/main/java/io/github/flemmli97/flan/fabric/mixin/SnowGolemMixin.java +++ b/fabric/src/main/java/io/github/flemmli97/flan/fabric/mixin/SnowGolemMixin.java @@ -1,18 +1,18 @@ package io.github.flemmli97.flan.fabric.mixin; import io.github.flemmli97.flan.event.EntityInteractEvents; -import net.minecraft.entity.passive.SnowGolemEntity; +import net.minecraft.world.entity.animal.SnowGolem; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -@Mixin(SnowGolemEntity.class) +@Mixin(SnowGolem.class) public abstract class SnowGolemMixin { - @Inject(method = "tickMovement", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;getGameRules()Lnet/minecraft/world/GameRules;"), cancellable = true) + @Inject(method = "aiStep", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/Level;getGameRules()Lnet/minecraft/world/level/GameRules;"), cancellable = true) private void checkSnow(CallbackInfo info) { - if (!EntityInteractEvents.canSnowGolemInteract((SnowGolemEntity) (Object) this)) { + if (!EntityInteractEvents.canSnowGolemInteract((SnowGolem) (Object) this)) { info.cancel(); } } diff --git a/fabric/src/main/java/io/github/flemmli97/flan/fabric/mixin/SpawnHelperMixin.java b/fabric/src/main/java/io/github/flemmli97/flan/fabric/mixin/SpawnHelperMixin.java index 16087ec..5ee847e 100644 --- a/fabric/src/main/java/io/github/flemmli97/flan/fabric/mixin/SpawnHelperMixin.java +++ b/fabric/src/main/java/io/github/flemmli97/flan/fabric/mixin/SpawnHelperMixin.java @@ -1,19 +1,19 @@ package io.github.flemmli97.flan.fabric.mixin; import io.github.flemmli97.flan.event.WorldEvents; -import net.minecraft.entity.mob.MobEntity; -import net.minecraft.server.world.ServerWorld; -import net.minecraft.world.SpawnHelper; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.entity.Mob; +import net.minecraft.world.level.NaturalSpawner; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -@Mixin(SpawnHelper.class) +@Mixin(NaturalSpawner.class) public abstract class SpawnHelperMixin { - @Inject(method = "isValidSpawn", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/mob/MobEntity;canSpawn(Lnet/minecraft/world/WorldAccess;Lnet/minecraft/entity/SpawnReason;)Z"), cancellable = true) - private static void isValidSpawn(ServerWorld world, MobEntity entity, double squaredDistance, CallbackInfoReturnable info) { + @Inject(method = "isValidPositionForMob", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Mob;checkSpawnRules(Lnet/minecraft/world/level/LevelAccessor;Lnet/minecraft/world/entity/MobSpawnType;)Z"), cancellable = true) + private static void isValidSpawn(ServerLevel world, Mob entity, double squaredDistance, CallbackInfoReturnable info) { if (WorldEvents.preventMobSpawn(world, entity)) { info.setReturnValue(false); info.cancel(); diff --git a/fabric/src/main/java/io/github/flemmli97/flan/fabric/mixin/WitherMixin.java b/fabric/src/main/java/io/github/flemmli97/flan/fabric/mixin/WitherMixin.java index 2b9bb1f..2a20a23 100644 --- a/fabric/src/main/java/io/github/flemmli97/flan/fabric/mixin/WitherMixin.java +++ b/fabric/src/main/java/io/github/flemmli97/flan/fabric/mixin/WitherMixin.java @@ -1,22 +1,22 @@ package io.github.flemmli97.flan.fabric.mixin; import io.github.flemmli97.flan.event.EntityInteractEvents; -import net.minecraft.entity.boss.WitherEntity; +import net.minecraft.world.entity.boss.wither.WitherBoss; 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; -@Mixin(WitherEntity.class) +@Mixin(WitherBoss.class) public abstract class WitherMixin { @Shadow - private int field_7082; + private int destroyBlocksTick; - @Inject(method = "mobTick", at = @At(value = "HEAD")) + @Inject(method = "customServerAiStep", at = @At(value = "HEAD")) private void preventClaimDmg(CallbackInfo info) { - if (!EntityInteractEvents.witherCanDestroy((WitherEntity) (Object) this)) - this.field_7082 = -1; + if (!EntityInteractEvents.witherCanDestroy((WitherBoss) (Object) this)) + this.destroyBlocksTick = -1; } } diff --git a/fabric/src/main/java/io/github/flemmli97/flan/fabric/mixin/WorldSaveHandlerMixin.java b/fabric/src/main/java/io/github/flemmli97/flan/fabric/mixin/WorldSaveHandlerMixin.java index dc79590..9121ace 100644 --- a/fabric/src/main/java/io/github/flemmli97/flan/fabric/mixin/WorldSaveHandlerMixin.java +++ b/fabric/src/main/java/io/github/flemmli97/flan/fabric/mixin/WorldSaveHandlerMixin.java @@ -1,25 +1,25 @@ package io.github.flemmli97.flan.fabric.mixin; import io.github.flemmli97.flan.event.PlayerEvents; -import net.minecraft.entity.player.PlayerEntity; import net.minecraft.nbt.CompoundTag; -import net.minecraft.world.WorldSaveHandler; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.level.storage.PlayerDataStorage; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -@Mixin(WorldSaveHandler.class) +@Mixin(PlayerDataStorage.class) public abstract class WorldSaveHandlerMixin { - @Inject(method = "savePlayerData", at = @At(value = "RETURN")) - private void save(PlayerEntity player, CallbackInfo info) { + @Inject(method = "save", at = @At(value = "RETURN")) + private void save(Player player, CallbackInfo info) { PlayerEvents.saveClaimData(player); } - @Inject(method = "loadPlayerData", at = @At(value = "RETURN")) - private void load(PlayerEntity player, CallbackInfoReturnable info) { + @Inject(method = "load", at = @At(value = "RETURN")) + private void load(Player player, CallbackInfoReturnable info) { PlayerEvents.readClaimData(player); } } diff --git a/fabric/src/main/java/io/github/flemmli97/flan/fabric/mixin/XpEntityMixin.java b/fabric/src/main/java/io/github/flemmli97/flan/fabric/mixin/XpEntityMixin.java index 7a756f9..12c29dd 100644 --- a/fabric/src/main/java/io/github/flemmli97/flan/fabric/mixin/XpEntityMixin.java +++ b/fabric/src/main/java/io/github/flemmli97/flan/fabric/mixin/XpEntityMixin.java @@ -1,18 +1,18 @@ package io.github.flemmli97.flan.fabric.mixin; import io.github.flemmli97.flan.event.EntityInteractEvents; -import net.minecraft.entity.ExperienceOrbEntity; -import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.world.entity.ExperienceOrb; +import net.minecraft.world.entity.player.Player; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -@Mixin(ExperienceOrbEntity.class) +@Mixin(ExperienceOrb.class) public abstract class XpEntityMixin { - @Inject(method = "onPlayerCollision", at = @At(value = "HEAD"), cancellable = true) - private void collision(PlayerEntity player, CallbackInfo info) { + @Inject(method = "playerTouch", at = @At(value = "HEAD"), cancellable = true) + private void collision(Player player, CallbackInfo info) { if (EntityInteractEvents.xpAbsorb(player)) { info.cancel(); } diff --git a/fabric/src/main/java/io/github/flemmli97/flan/integration/currency/fabric/CommandCurrencyImpl.java b/fabric/src/main/java/io/github/flemmli97/flan/integration/currency/fabric/CommandCurrencyImpl.java index 9c519a8..7c6abaa 100644 --- a/fabric/src/main/java/io/github/flemmli97/flan/integration/currency/fabric/CommandCurrencyImpl.java +++ b/fabric/src/main/java/io/github/flemmli97/flan/integration/currency/fabric/CommandCurrencyImpl.java @@ -1,66 +1,59 @@ package io.github.flemmli97.flan.integration.currency.fabric; import com.mojang.brigadier.Command; -import com.mojang.brigadier.arguments.IntegerArgumentType; import com.mojang.brigadier.context.CommandContext; import com.mojang.brigadier.exceptions.CommandSyntaxException; import io.github.flemmli97.flan.Flan; import io.github.flemmli97.flan.claim.PermHelper; import io.github.flemmli97.flan.config.ConfigHandler; -import io.github.flemmli97.flan.player.PlayerClaimData; -import io.github.gunpowder.api.GunpowderMod; -import io.github.gunpowder.api.module.currency.dataholders.StoredBalance; -import io.github.gunpowder.api.module.currency.modelhandlers.BalanceHandler; -import net.minecraft.server.command.ServerCommandSource; -import net.minecraft.util.Formatting; - -import java.math.BigDecimal; +import net.minecraft.ChatFormatting; +import net.minecraft.commands.CommandSourceStack; public class CommandCurrencyImpl { - public static int sellClaimBlocks(CommandContext context) throws CommandSyntaxException { + public static int sellClaimBlocks(CommandContext context) throws CommandSyntaxException { if (!Flan.gunpowder) { - context.getSource().sendFeedback(PermHelper.simpleColoredText(ConfigHandler.lang.currencyMissing, Formatting.DARK_RED), false); + context.getSource().sendSuccess(PermHelper.simpleColoredText(ConfigHandler.lang.currencyMissing, ChatFormatting.DARK_RED), false); return 0; } - if (ConfigHandler.config.sellPrice == -1) { - context.getSource().sendFeedback(PermHelper.simpleColoredText(ConfigHandler.lang.sellDisabled, Formatting.DARK_RED), false); + /*if (ConfigHandler.config.sellPrice == -1) { + context.getSource().sendSuccess(PermHelper.simpleColoredText(ConfigHandler.lang.sellDisabled, ChatFormatting.DARK_RED), false); return 0; } int amount = Math.max(0, IntegerArgumentType.getInteger(context, "amount")); - PlayerClaimData data = PlayerClaimData.get(context.getSource().getPlayer()); + PlayerClaimData data = PlayerClaimData.get(context.getSource().getPlayerOrException()); if (data.getAdditionalClaims() - Math.max(0, data.usedClaimBlocks() - data.getClaimBlocks()) < amount) { - context.getSource().sendFeedback(PermHelper.simpleColoredText(ConfigHandler.lang.sellFail, Formatting.DARK_RED), false); + context.getSource().sendSuccess(PermHelper.simpleColoredText(ConfigHandler.lang.sellFail, ChatFormatting.DARK_RED), false); return 0; } - StoredBalance bal = GunpowderMod.getInstance().getRegistry().getModelHandler(BalanceHandler.class).getUser(context.getSource().getPlayer().getUuid()); + StoredBalance bal = GunpowderMod.getInstance().getRegistry().getModelHandler(BalanceHandler.class).getUser(context.getSource().getPlayerOrException().getUUID()); BigDecimal price = BigDecimal.valueOf(amount * ConfigHandler.config.sellPrice); bal.setBalance(bal.getBalance().add(price)); data.setAdditionalClaims(data.getAdditionalClaims() - amount); - context.getSource().sendFeedback(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.sellSuccess, amount, price), Formatting.GOLD), false); + context.getSource().sendSuccess(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.sellSuccess, amount, price), ChatFormatting.GOLD), false);*/ return Command.SINGLE_SUCCESS; } - public static int buyClaimBlocks(CommandContext context) throws CommandSyntaxException { + public static int buyClaimBlocks(CommandContext context) throws CommandSyntaxException { if (!Flan.gunpowder) { - context.getSource().sendFeedback(PermHelper.simpleColoredText(ConfigHandler.lang.currencyMissing, Formatting.DARK_RED), false); + context.getSource().sendSuccess(PermHelper.simpleColoredText(ConfigHandler.lang.currencyMissing, ChatFormatting.DARK_RED), false); return 0; } - if (ConfigHandler.config.buyPrice == -1) { - context.getSource().sendFeedback(PermHelper.simpleColoredText(ConfigHandler.lang.buyDisabled, Formatting.DARK_RED), false); + /*if (ConfigHandler.config.buyPrice == -1) { + context.getSource().sendSuccess(PermHelper.simpleColoredText(ConfigHandler.lang.buyDisabled, ChatFormatting.DARK_RED), false); return 0; } - StoredBalance bal = GunpowderMod.getInstance().getRegistry().getModelHandler(BalanceHandler.class).getUser(context.getSource().getPlayer().getUuid()); + StoredBalance bal = GunpowderMod.getInstance().getRegistry().getModelHandler(BalanceHandler.class).getUser(context.getSource().getPlayerOrException().getUUID()); int amount = Math.max(0, IntegerArgumentType.getInteger(context, "amount")); BigDecimal price = BigDecimal.valueOf(amount * ConfigHandler.config.buyPrice); if (bal.getBalance().compareTo(price) >= 0) { - PlayerClaimData data = PlayerClaimData.get(context.getSource().getPlayer()); + PlayerClaimData data = PlayerClaimData.get(context.getSource().getPlayerOrException()); data.setAdditionalClaims(data.getAdditionalClaims() + amount); bal.setBalance(bal.getBalance().subtract(price)); - context.getSource().sendFeedback(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.buySuccess, amount, price), Formatting.GOLD), false); + context.getSource().sendSuccess(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.buySuccess, amount, price), ChatFormatting.GOLD), false); return Command.SINGLE_SUCCESS; } - context.getSource().sendFeedback(PermHelper.simpleColoredText(ConfigHandler.lang.buyFail, Formatting.DARK_RED), false); + context.getSource().sendSuccess(PermHelper.simpleColoredText(ConfigHandler.lang.buyFail, ChatFormatting.DARK_RED), false);*/ return 0; } } diff --git a/fabric/src/main/java/io/github/flemmli97/flan/integration/permissions/fabric/PermissionNodeHandlerImpl.java b/fabric/src/main/java/io/github/flemmli97/flan/integration/permissions/fabric/PermissionNodeHandlerImpl.java index a7ea631..b9c0bc2 100644 --- a/fabric/src/main/java/io/github/flemmli97/flan/integration/permissions/fabric/PermissionNodeHandlerImpl.java +++ b/fabric/src/main/java/io/github/flemmli97/flan/integration/permissions/fabric/PermissionNodeHandlerImpl.java @@ -1,44 +1,41 @@ package io.github.flemmli97.flan.integration.permissions.fabric; -import dev.ftb.mods.ftbranks.api.FTBRanksAPI; -import io.github.flemmli97.flan.Flan; import io.github.flemmli97.flan.config.ConfigHandler; -import me.lucko.fabric.api.permissions.v0.Permissions; -import net.minecraft.server.command.ServerCommandSource; -import net.minecraft.server.network.ServerPlayerEntity; +import net.minecraft.commands.CommandSourceStack; +import net.minecraft.server.level.ServerPlayer; public class PermissionNodeHandlerImpl { - public static boolean perm(ServerCommandSource src, String perm, boolean adminCmd) { - if (Flan.permissionAPI) { + public static boolean perm(CommandSourceStack src, String perm, boolean adminCmd) { + /*if (Flan.permissionAPI) { if (adminCmd) return Permissions.check(src, perm, ConfigHandler.config.permissionLevel); return Permissions.check(src, perm, true); } - if (Flan.ftbRanks && src.getEntity() instanceof ServerPlayerEntity) { - ServerPlayerEntity player = (ServerPlayerEntity) src.getEntity(); - return FTBRanksAPI.getPermissionValue(player, perm).asBoolean().orElse(!adminCmd || player.hasPermissionLevel(ConfigHandler.config.permissionLevel)); - } - return !adminCmd || src.hasPermissionLevel(ConfigHandler.config.permissionLevel); + if (Flan.ftbRanks && src.getEntity() instanceof ServerPlayer) { + ServerPlayer player = (ServerPlayer) src.getEntity(); + return FTBRanksAPI.getPermissionValue(player, perm).asBoolean().orElse(!adminCmd || player.hasPermissions(ConfigHandler.config.permissionLevel)); + }*/ + return !adminCmd || src.hasPermission(ConfigHandler.config.permissionLevel); } - public static boolean perm(ServerPlayerEntity src, String perm, boolean adminCmd) { - if (Flan.permissionAPI) { + public static boolean perm(ServerPlayer src, String perm, boolean adminCmd) { + /*if (Flan.permissionAPI) { if (adminCmd) return Permissions.check(src, perm, ConfigHandler.config.permissionLevel); return Permissions.check(src, perm, true); } if (Flan.ftbRanks) { - return FTBRanksAPI.getPermissionValue(src, perm).asBoolean().orElse(!adminCmd || src.hasPermissionLevel(ConfigHandler.config.permissionLevel)); - } - return !adminCmd || src.hasPermissionLevel(ConfigHandler.config.permissionLevel); + return FTBRanksAPI.getPermissionValue(src, perm).asBoolean().orElse(!adminCmd || src.hasPermissions(ConfigHandler.config.permissionLevel)); + }*/ + return !adminCmd || src.hasPermissions(ConfigHandler.config.permissionLevel); } - public static boolean permBelowEqVal(ServerPlayerEntity src, String perm, int val, int fallback) { - if (Flan.ftbRanks) { + public static boolean permBelowEqVal(ServerPlayer src, String perm, int val, int fallback) { + /*if (Flan.ftbRanks) { int max = FTBRanksAPI.getPermissionValue(src, perm).asInteger().orElse(fallback); return val <= max; - } + }*/ return val <= fallback; } } diff --git a/fabric/src/main/java/io/github/flemmli97/flan/integration/playerability/PlayerAbilityEvents.java b/fabric/src/main/java/io/github/flemmli97/flan/integration/playerability/PlayerAbilityEvents.java index 32e58e3..618c486 100644 --- a/fabric/src/main/java/io/github/flemmli97/flan/integration/playerability/PlayerAbilityEvents.java +++ b/fabric/src/main/java/io/github/flemmli97/flan/integration/playerability/PlayerAbilityEvents.java @@ -1,28 +1,17 @@ package io.github.flemmli97.flan.integration.playerability; -import io.github.flemmli97.flan.api.data.IPermissionContainer; -import io.github.flemmli97.flan.api.permission.PermissionRegistry; -import io.github.flemmli97.flan.claim.ClaimStorage; -import io.github.ladysnake.pal.AbilitySource; -import io.github.ladysnake.pal.PlayerAbility; -import io.github.ladysnake.pal.PlayerAbilityEnableCallback; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.server.network.ServerPlayerEntity; -import net.minecraft.server.world.ServerWorld; -import net.minecraft.util.math.BlockPos; - public class PlayerAbilityEvents { public static void register() { - PlayerAbilityEnableCallback.EVENT.register(PlayerAbilityEvents::checkAbility); + //PlayerAbilityEnableCallback.EVENT.register(PlayerAbilityEvents::checkAbility); } - public static boolean checkAbility(PlayerEntity player, PlayerAbility ability, AbilitySource abilitySource) { - if (player.world.isClient) + /*public static boolean checkAbility(Player player, PlayerAbility ability, AbilitySource abilitySource) { + if (player.level.isClientSide) return true; - BlockPos pos = player.getBlockPos(); - ClaimStorage storage = ClaimStorage.get((ServerWorld) player.world); + BlockPos pos = player.blockPosition(); + ClaimStorage storage = ClaimStorage.get((ServerLevel) player.level); IPermissionContainer claim = storage.getForPermissionCheck(pos); - return claim.canInteract((ServerPlayerEntity) player, PermissionRegistry.FLIGHT, pos, true); - } + return claim.canInteract((ServerPlayer) player, PermissionRegistry.FLIGHT, pos, true); + }*/ } diff --git a/fabric/src/main/resources/flan.fabric.mixins.json b/fabric/src/main/resources/flan.fabric.mixins.json index e33a6e2..f153057 100644 --- a/fabric/src/main/resources/flan.fabric.mixins.json +++ b/fabric/src/main/resources/flan.fabric.mixins.json @@ -2,12 +2,12 @@ "required": true, "minVersion": "0.8", "package": "io.github.flemmli97.flan.fabric.mixin", - "compatibilityLevel": "JAVA_8", + "compatibilityLevel": "JAVA_16", "mixins": [ "ServerWorldMixin", "PistonMixin", "SpawnHelperMixin", - "ServerPlayNetworkHandlerMixin", + "PlayerInteractEntityMixin", "ProjectileMixin", "EntityDamageMixin", "XpEntityMixin", diff --git a/forge/build.gradle b/forge/build.gradle index 2ae9c5b..ffad1ab 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -1,9 +1,5 @@ plugins { - id "com.github.johnrengelman.shadow" version "5.0.0" -} - -configurations { - shadowCommon // Don't use shadow from the shadow plugin because we don't want IDEA to index this. + id "com.github.johnrengelman.shadow" version "7.1.0" } architectury { @@ -11,9 +7,18 @@ architectury { forge() } +configurations { + common + shadowCommon // Don't use shadow from the shadow plugin because we don't want IDEA to index this. + compileClasspath.extendsFrom common + runtimeClasspath.extendsFrom common + developmentForge.extendsFrom common +} + loom { - mixinConfigs = ["flan.mixins.json", "flan.forge.mixins.json"] - useFabricMixin = true + forge { + mixinConfigs = ["flan.mixins.json", "flan.forge.mixins.json"] + } } repositories { @@ -31,18 +36,11 @@ repositories { dependencies { forge "net.minecraftforge:forge:${rootProject.minecraft_version}-${rootProject.forge_version}" - implementation(project(path: ":common")) { - transitive = false - } - developmentForge(project(path: ":common")) { - transitive = false - } - shadowCommon(project(path: ":common", configuration: "transformProductionForge")) { - transitive = false - } + common(project(path: ":common", configuration: "namedElements")) { transitive false } + shadowCommon(project(path: ":common", configuration: "transformProductionForge")) { transitive = false } - modImplementation("dev.ftb.mods:ftb-ranks-forge:${ftb_ranks}") - modImplementation(dicemcmm) + //modImplementation("dev.ftb.mods:ftb-ranks-forge:${ftb_ranks}") + //modImplementation(dicemcmm) } processResources { @@ -70,10 +68,6 @@ jar { classifier "dev" } -java { - withSourcesJar() -} - sourcesJar { def commonSources = project(":common").sourcesJar dependsOn commonSources @@ -81,6 +75,11 @@ sourcesJar { classifier "forge-sources" } +components.java { + withVariantsFromConfiguration(project.configurations.shadowRuntimeElements) { + skip() + } +} task apiJar(type: Jar, dependsOn: classes) { archiveClassifier.set "forge-api-source" diff --git a/forge/src/main/java/io/github/flemmli97/flan/ForgeRegistryWrapper.java b/forge/src/main/java/io/github/flemmli97/flan/ForgeRegistryWrapper.java index eb6e330..9e221f7 100644 --- a/forge/src/main/java/io/github/flemmli97/flan/ForgeRegistryWrapper.java +++ b/forge/src/main/java/io/github/flemmli97/flan/ForgeRegistryWrapper.java @@ -1,6 +1,7 @@ package io.github.flemmli97.flan; -import net.minecraft.util.Identifier; +import io.github.flemmli97.flan.SimpleRegistryWrapper; +import net.minecraft.resources.ResourceLocation; import net.minecraftforge.registries.IForgeRegistry; import net.minecraftforge.registries.IForgeRegistryEntry; @@ -13,12 +14,12 @@ public class ForgeRegistryWrapper> implements S } @Override - public T getFromId(Identifier id) { + public T getFromId(ResourceLocation id) { return this.registry.getValue(id); } @Override - public Identifier getIDFrom(T entry) { + public ResourceLocation getIDFrom(T entry) { return entry.getRegistryName(); } diff --git a/forge/src/main/java/io/github/flemmli97/flan/api/forge/PermissionCheckEvent.java b/forge/src/main/java/io/github/flemmli97/flan/api/forge/PermissionCheckEvent.java index f41795d..651a49b 100644 --- a/forge/src/main/java/io/github/flemmli97/flan/api/forge/PermissionCheckEvent.java +++ b/forge/src/main/java/io/github/flemmli97/flan/api/forge/PermissionCheckEvent.java @@ -1,17 +1,17 @@ package io.github.flemmli97.flan.api.forge; import io.github.flemmli97.flan.api.permission.ClaimPermission; -import net.minecraft.server.network.ServerPlayerEntity; -import net.minecraft.util.ActionResult; -import net.minecraft.util.math.BlockPos; +import net.minecraft.core.BlockPos; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.InteractionResult; import net.minecraftforge.eventbus.api.Event; public class PermissionCheckEvent extends Event { - public final ServerPlayerEntity player; + public final ServerPlayer player; public final ClaimPermission permission; public final BlockPos pos; - private ActionResult result = ActionResult.PASS; + private InteractionResult result = InteractionResult.PASS; /** * Event for when permissions are checked @@ -20,7 +20,7 @@ public class PermissionCheckEvent extends Event { * @param permission The permission to check * @param pos The block pos where the action is occuring */ - public PermissionCheckEvent(ServerPlayerEntity player, ClaimPermission permission, BlockPos pos) { + public PermissionCheckEvent(ServerPlayer player, ClaimPermission permission, BlockPos pos) { this.player = player; this.permission = permission; this.pos = pos; @@ -29,11 +29,11 @@ public class PermissionCheckEvent extends Event { /** * @return ActionResult#PASS to do nothing. ActionResult#FAIL to prevent the action. Else to allow the action */ - public ActionResult getActionResult() { + public InteractionResult getActionResult() { return this.result; } - public void setResult(ActionResult result) { + public void setResult(InteractionResult result) { this.result = result; } } diff --git a/forge/src/main/java/io/github/flemmli97/flan/claim/forge/ClaimPermissionCheckImpl.java b/forge/src/main/java/io/github/flemmli97/flan/claim/forge/ClaimPermissionCheckImpl.java index ccfc445..b58005a 100644 --- a/forge/src/main/java/io/github/flemmli97/flan/claim/forge/ClaimPermissionCheckImpl.java +++ b/forge/src/main/java/io/github/flemmli97/flan/claim/forge/ClaimPermissionCheckImpl.java @@ -2,14 +2,14 @@ package io.github.flemmli97.flan.claim.forge; import io.github.flemmli97.flan.api.forge.PermissionCheckEvent; import io.github.flemmli97.flan.api.permission.ClaimPermission; -import net.minecraft.server.network.ServerPlayerEntity; -import net.minecraft.util.ActionResult; -import net.minecraft.util.math.BlockPos; +import net.minecraft.core.BlockPos; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.InteractionResult; import net.minecraftforge.common.MinecraftForge; public class ClaimPermissionCheckImpl { - public static ActionResult check(ServerPlayerEntity player, ClaimPermission permission, BlockPos pos) { + public static InteractionResult check(ServerPlayer player, ClaimPermission permission, BlockPos pos) { PermissionCheckEvent event = new PermissionCheckEvent(player, permission, pos); MinecraftForge.EVENT_BUS.post(event); return event.getActionResult(); diff --git a/forge/src/main/java/io/github/flemmli97/flan/forge/CrossPlatformStuffImpl.java b/forge/src/main/java/io/github/flemmli97/flan/forge/CrossPlatformStuffImpl.java index 86ae096..69fa1d2 100644 --- a/forge/src/main/java/io/github/flemmli97/flan/forge/CrossPlatformStuffImpl.java +++ b/forge/src/main/java/io/github/flemmli97/flan/forge/CrossPlatformStuffImpl.java @@ -2,14 +2,14 @@ package io.github.flemmli97.flan.forge; import io.github.flemmli97.flan.ForgeRegistryWrapper; import io.github.flemmli97.flan.SimpleRegistryWrapper; -import net.minecraft.block.Block; -import net.minecraft.block.InventoryProvider; -import net.minecraft.block.entity.BlockEntity; -import net.minecraft.entity.EntityType; -import net.minecraft.entity.effect.StatusEffect; -import net.minecraft.inventory.Inventory; -import net.minecraft.item.Item; import net.minecraft.nbt.CompoundTag; +import net.minecraft.world.Container; +import net.minecraft.world.WorldlyContainerHolder; +import net.minecraft.world.effect.MobEffect; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.item.Item; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraftforge.fml.loading.FMLPaths; import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.registries.ForgeRegistries; @@ -22,8 +22,8 @@ public class CrossPlatformStuffImpl { return FMLPaths.CONFIGDIR.get(); } - public static SimpleRegistryWrapper registryStatusEffects() { - return new ForgeRegistryWrapper<>(ForgeRegistries.POTIONS); + public static SimpleRegistryWrapper registryStatusEffects() { + return new ForgeRegistryWrapper<>(ForgeRegistries.MOB_EFFECTS); } public static SimpleRegistryWrapper registryBlocks() { @@ -39,7 +39,7 @@ public class CrossPlatformStuffImpl { } public static boolean isInventoryTile(BlockEntity blockEntity) { - return blockEntity instanceof Inventory || blockEntity instanceof InventoryProvider || blockEntity.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY).isPresent(); + return blockEntity instanceof Container || blockEntity instanceof WorldlyContainerHolder || blockEntity.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY).isPresent(); } public static boolean blockDataContains(CompoundTag nbt, String tag) { diff --git a/forge/src/main/java/io/github/flemmli97/flan/FlanForge.java b/forge/src/main/java/io/github/flemmli97/flan/forge/FlanForge.java similarity index 93% rename from forge/src/main/java/io/github/flemmli97/flan/FlanForge.java rename to forge/src/main/java/io/github/flemmli97/flan/forge/FlanForge.java index ab3b337..852c84c 100644 --- a/forge/src/main/java/io/github/flemmli97/flan/FlanForge.java +++ b/forge/src/main/java/io/github/flemmli97/flan/forge/FlanForge.java @@ -1,5 +1,6 @@ -package io.github.flemmli97.flan; +package io.github.flemmli97.flan.forge; +import io.github.flemmli97.flan.Flan; import io.github.flemmli97.flan.forgeevent.BlockInteractEventsForge; import io.github.flemmli97.flan.forgeevent.EntityInteractEventsForge; import io.github.flemmli97.flan.forgeevent.ItemInteractEventsForge; @@ -11,6 +12,7 @@ import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.fml.ModList; import net.minecraftforge.fml.common.Mod; +//Moved from io.github.flemmli97.flan to here since module thingy with forge @Mod(FlanForge.MODID) public class FlanForge { diff --git a/forge/src/main/java/io/github/flemmli97/flan/forge/mixin/ForgeFireMixin.java b/forge/src/main/java/io/github/flemmli97/flan/forge/mixin/ForgeFireMixin.java index 8704ecc..08503ee 100644 --- a/forge/src/main/java/io/github/flemmli97/flan/forge/mixin/ForgeFireMixin.java +++ b/forge/src/main/java/io/github/flemmli97/flan/forge/mixin/ForgeFireMixin.java @@ -1,11 +1,11 @@ package io.github.flemmli97.flan.forge.mixin; import io.github.flemmli97.flan.event.WorldEvents; -import net.minecraft.block.FireBlock; -import net.minecraft.server.world.ServerWorld; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; -import net.minecraft.world.World; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.FireBlock; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -16,9 +16,12 @@ import java.util.Random; @Mixin(FireBlock.class) public abstract class ForgeFireMixin { + /** + * Check for blocks reacting to fire (e.g. tnt) + */ @Inject(method = "tryCatchFire", at = @At(value = "HEAD"), cancellable = true) - private void spread(World world, BlockPos pos, int spreadFactor, Random rand, int currentAge, Direction dir, CallbackInfo info) { - if (!world.isClient && !WorldEvents.canFireSpread((ServerWorld) world, pos)) { + private void spread(Level world, BlockPos pos, int spreadFactor, Random rand, int currentAge, Direction dir, CallbackInfo info) { + if (!world.isClientSide && !WorldEvents.canFireSpread((ServerLevel) world, pos)) { info.cancel(); } } diff --git a/forge/src/main/java/io/github/flemmli97/flan/forgeevent/BlockInteractEventsForge.java b/forge/src/main/java/io/github/flemmli97/flan/forgeevent/BlockInteractEventsForge.java index 93ee831..63678b8 100644 --- a/forge/src/main/java/io/github/flemmli97/flan/forgeevent/BlockInteractEventsForge.java +++ b/forge/src/main/java/io/github/flemmli97/flan/forgeevent/BlockInteractEventsForge.java @@ -1,25 +1,25 @@ package io.github.flemmli97.flan.forgeevent; import io.github.flemmli97.flan.event.BlockInteractEvents; -import net.minecraft.server.world.ServerWorld; -import net.minecraft.util.ActionResult; -import net.minecraft.world.World; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.level.Level; import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.minecraftforge.event.world.BlockEvent; public class BlockInteractEventsForge { public static void startBreakBlocks(PlayerInteractEvent.LeftClickBlock event) { - if (!(event.getWorld() instanceof ServerWorld)) + if (!(event.getWorld() instanceof ServerLevel)) return; - if (BlockInteractEvents.startBreakBlocks(event.getPlayer(), event.getWorld(), event.getHand(), event.getPos(), event.getFace()) == ActionResult.FAIL) + if (BlockInteractEvents.startBreakBlocks(event.getPlayer(), event.getWorld(), event.getHand(), event.getPos(), event.getFace()) == InteractionResult.FAIL) event.setCanceled(true); } public static void breakBlocks(BlockEvent.BreakEvent event) { - if (!(event.getWorld() instanceof ServerWorld)) + if (!(event.getWorld() instanceof ServerLevel)) return; - if (!BlockInteractEvents.breakBlocks((World) event.getWorld(), event.getPlayer(), event.getPos(), event.getState(), event.getWorld().getBlockEntity(event.getPos()))) + if (!BlockInteractEvents.breakBlocks((Level) event.getWorld(), event.getPlayer(), event.getPos(), event.getState(), event.getWorld().getBlockEntity(event.getPos()))) event.setCanceled(true); } } diff --git a/forge/src/main/java/io/github/flemmli97/flan/forgeevent/EntityInteractEventsForge.java b/forge/src/main/java/io/github/flemmli97/flan/forgeevent/EntityInteractEventsForge.java index 64c6e5a..e9f53fb 100644 --- a/forge/src/main/java/io/github/flemmli97/flan/forgeevent/EntityInteractEventsForge.java +++ b/forge/src/main/java/io/github/flemmli97/flan/forgeevent/EntityInteractEventsForge.java @@ -1,12 +1,12 @@ package io.github.flemmli97.flan.forgeevent; import io.github.flemmli97.flan.event.EntityInteractEvents; -import net.minecraft.entity.Entity; -import net.minecraft.entity.boss.WitherEntity; -import net.minecraft.entity.passive.SnowGolemEntity; -import net.minecraft.entity.projectile.ProjectileEntity; -import net.minecraft.util.ActionResult; -import net.minecraft.util.hit.EntityHitResult; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.animal.SnowGolem; +import net.minecraft.world.entity.boss.wither.WitherBoss; +import net.minecraft.world.entity.projectile.Projectile; +import net.minecraft.world.phys.EntityHitResult; import net.minecraftforge.event.entity.EntityMobGriefingEvent; import net.minecraftforge.event.entity.EntityStruckByLightningEvent; import net.minecraftforge.event.entity.ProjectileImpactEvent; @@ -20,34 +20,34 @@ import net.minecraftforge.eventbus.api.Event; public class EntityInteractEventsForge { public static void attackEntity(AttackEntityEvent event) { - ActionResult result = EntityInteractEvents.attackSimple(event.getPlayer(), event.getTarget(), true); - if (result == ActionResult.FAIL) { + InteractionResult result = EntityInteractEvents.attackSimple(event.getPlayer(), event.getTarget(), true); + if (result == InteractionResult.FAIL) { event.setCanceled(true); } } public static void useAtEntity(PlayerInteractEvent.EntityInteractSpecific event) { Entity target = event.getTarget(); - ActionResult result = EntityInteractEvents.useAtEntity(event.getPlayer(), event.getWorld(), event.getHand(), target, + InteractionResult result = EntityInteractEvents.useAtEntity(event.getPlayer(), event.getWorld(), event.getHand(), target, new EntityHitResult(target, event.getLocalPos().add(target.getX(), target.getY(), target.getZ()))); - if (result != ActionResult.PASS) { + if (result != InteractionResult.PASS) { event.setCancellationResult(result); event.setCanceled(true); } } public static void useEntity(PlayerInteractEvent.EntityInteract event) { - ActionResult result = EntityInteractEvents.useEntity(event.getPlayer(), event.getWorld(), event.getHand(), event.getTarget()); - if (result != ActionResult.PASS) { + InteractionResult result = EntityInteractEvents.useEntity(event.getPlayer(), event.getWorld(), event.getHand(), event.getTarget()); + if (result != InteractionResult.PASS) { event.setCancellationResult(result); event.setCanceled(true); } } public static void projectileHit(ProjectileImpactEvent event) { - if (!(event.getEntity() instanceof ProjectileEntity)) + if (!(event.getEntity() instanceof Projectile)) return; - boolean stop = EntityInteractEvents.projectileHit((ProjectileEntity) event.getEntity(), event.getRayTraceResult()); + boolean stop = EntityInteractEvents.projectileHit((Projectile) event.getEntity(), event.getRayTraceResult()); if (stop) { event.setCanceled(true); } @@ -67,7 +67,7 @@ public class EntityInteractEventsForge { } public static void canDropItem(ItemTossEvent event) { - boolean canDrop = EntityInteractEvents.canDropItem(event.getPlayer(), event.getEntityItem().getStack()); + boolean canDrop = EntityInteractEvents.canDropItem(event.getPlayer(), event.getEntityItem().getItem()); if (!canDrop) { event.setCanceled(true); } @@ -78,10 +78,10 @@ public class EntityInteractEventsForge { * EntityInteractEvents.canSnowGolemInteract */ public static void mobGriefing(EntityMobGriefingEvent event) { - if (event.getEntity() instanceof WitherEntity && EntityInteractEvents.witherCanDestroy((WitherEntity) event.getEntity())) { + if (event.getEntity() instanceof WitherBoss && EntityInteractEvents.witherCanDestroy((WitherBoss) event.getEntity())) { event.setResult(Event.Result.DENY); } - if (event.getEntity() instanceof SnowGolemEntity && !EntityInteractEvents.canSnowGolemInteract((SnowGolemEntity) event.getEntity())) { + if (event.getEntity() instanceof SnowGolem && !EntityInteractEvents.canSnowGolemInteract((SnowGolem) event.getEntity())) { event.setResult(Event.Result.DENY); } } diff --git a/forge/src/main/java/io/github/flemmli97/flan/forgeevent/ItemInteractEventsForge.java b/forge/src/main/java/io/github/flemmli97/flan/forgeevent/ItemInteractEventsForge.java index c90ac5c..2ecb901 100644 --- a/forge/src/main/java/io/github/flemmli97/flan/forgeevent/ItemInteractEventsForge.java +++ b/forge/src/main/java/io/github/flemmli97/flan/forgeevent/ItemInteractEventsForge.java @@ -1,16 +1,16 @@ package io.github.flemmli97.flan.forgeevent; import io.github.flemmli97.flan.event.ItemInteractEvents; -import net.minecraft.item.ItemStack; -import net.minecraft.util.ActionResult; -import net.minecraft.util.TypedActionResult; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.InteractionResultHolder; +import net.minecraft.world.item.ItemStack; import net.minecraftforge.event.entity.player.PlayerInteractEvent; public class ItemInteractEventsForge { public static void useItem(PlayerInteractEvent.RightClickItem event) { - TypedActionResult result = ItemInteractEvents.useItem(event.getPlayer(), event.getWorld(), event.getHand()); - if (result.getResult() != ActionResult.PASS) { + InteractionResultHolder result = ItemInteractEvents.useItem(event.getPlayer(), event.getWorld(), event.getHand()); + if (result.getResult() != InteractionResult.PASS) { event.setCanceled(true); event.setCancellationResult(result.getResult()); } diff --git a/forge/src/main/java/io/github/flemmli97/flan/forgeevent/ServerEvents.java b/forge/src/main/java/io/github/flemmli97/flan/forgeevent/ServerEvents.java index d6134ae..7ff60ca 100644 --- a/forge/src/main/java/io/github/flemmli97/flan/forgeevent/ServerEvents.java +++ b/forge/src/main/java/io/github/flemmli97/flan/forgeevent/ServerEvents.java @@ -7,22 +7,22 @@ import io.github.flemmli97.flan.config.ConfigHandler; import io.github.flemmli97.flan.event.PlayerEvents; import io.github.flemmli97.flan.player.LogoutTracker; import io.github.flemmli97.flan.player.PlayerDataHandler; -import net.minecraft.world.World; +import net.minecraft.world.level.Level; import net.minecraftforge.event.RegisterCommandsEvent; import net.minecraftforge.event.TickEvent; import net.minecraftforge.event.entity.player.PlayerEvent; -import net.minecraftforge.fml.event.server.FMLServerAboutToStartEvent; -import net.minecraftforge.fml.event.server.FMLServerStartedEvent; +import net.minecraftforge.event.server.ServerAboutToStartEvent; +import net.minecraftforge.event.server.ServerStartedEvent; public class ServerEvents { - public static void serverStart(FMLServerAboutToStartEvent event) { + public static void serverStart(ServerAboutToStartEvent event) { ConfigHandler.serverLoad(event.getServer()); ObjectToPermissionMap.reload(event.getServer()); Flan.lockRegistry(event.getServer()); } - public static void serverFinishLoad(FMLServerStartedEvent event) { + public static void serverFinishLoad(ServerStartedEvent event) { PlayerDataHandler.deleteInactivePlayerData(event.getServer()); } @@ -43,7 +43,7 @@ public class ServerEvents { } public static void serverTick(TickEvent.WorldTickEvent event) { - if (event.phase == TickEvent.Phase.START && event.world.getServer() != null && event.world.getRegistryKey() == World.OVERWORLD) + if (event.phase == TickEvent.Phase.START && event.world.getServer() != null && event.world.dimension() == Level.OVERWORLD) LogoutTracker.getInstance(event.world.getServer()).tick(); } } diff --git a/forge/src/main/java/io/github/flemmli97/flan/forgeevent/WorldEventsForge.java b/forge/src/main/java/io/github/flemmli97/flan/forgeevent/WorldEventsForge.java index 0be8bbc..42917c7 100644 --- a/forge/src/main/java/io/github/flemmli97/flan/forgeevent/WorldEventsForge.java +++ b/forge/src/main/java/io/github/flemmli97/flan/forgeevent/WorldEventsForge.java @@ -1,9 +1,9 @@ package io.github.flemmli97.flan.forgeevent; import io.github.flemmli97.flan.event.WorldEvents; -import net.minecraft.entity.mob.MobEntity; -import net.minecraft.server.world.ServerWorld; -import net.minecraft.world.World; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.entity.Mob; +import net.minecraft.world.level.Level; import net.minecraftforge.event.entity.living.LivingSpawnEvent; import net.minecraftforge.event.world.ExplosionEvent; import net.minecraftforge.event.world.PistonEvent; @@ -12,21 +12,21 @@ import net.minecraftforge.eventbus.api.Event; public class WorldEventsForge { public static void modifyExplosion(ExplosionEvent.Detonate event) { - if (event.getWorld() instanceof ServerWorld) - WorldEvents.modifyExplosion(event.getExplosion(), (ServerWorld) event.getWorld()); + if (event.getWorld() instanceof ServerLevel) + WorldEvents.modifyExplosion(event.getExplosion(), (ServerLevel) event.getWorld()); } public static void pistonCanPush(PistonEvent.Pre event) { - if (!(event.getWorld() instanceof World)) + if (!(event.getWorld() instanceof Level)) return; - if (!WorldEvents.pistonCanPush(event.getState(), (World) event.getWorld(), event.getPos(), event.getDirection(), event.getDirection())) + if (!WorldEvents.pistonCanPush(event.getState(), (Level) event.getWorld(), event.getPos(), event.getDirection(), event.getDirection())) event.setCanceled(true); } public static void preventMobSpawn(LivingSpawnEvent.CheckSpawn event) { - if (!(event.getWorld() instanceof ServerWorld) || !(event.getEntityLiving() instanceof MobEntity)) + if (!(event.getWorld() instanceof ServerLevel) || !(event.getEntityLiving() instanceof Mob)) return; - if (WorldEvents.preventMobSpawn((ServerWorld) event.getWorld(), (MobEntity) event.getEntityLiving())) + if (WorldEvents.preventMobSpawn((ServerLevel) event.getWorld(), (Mob) event.getEntityLiving())) event.setResult(Event.Result.DENY); } } diff --git a/forge/src/main/java/io/github/flemmli97/flan/integration/currency/forge/CommandCurrencyImpl.java b/forge/src/main/java/io/github/flemmli97/flan/integration/currency/forge/CommandCurrencyImpl.java index e39922e..4f515f7 100644 --- a/forge/src/main/java/io/github/flemmli97/flan/integration/currency/forge/CommandCurrencyImpl.java +++ b/forge/src/main/java/io/github/flemmli97/flan/integration/currency/forge/CommandCurrencyImpl.java @@ -1,66 +1,56 @@ package io.github.flemmli97.flan.integration.currency.forge; import com.mojang.brigadier.Command; -import com.mojang.brigadier.arguments.IntegerArgumentType; import com.mojang.brigadier.context.CommandContext; import com.mojang.brigadier.exceptions.CommandSyntaxException; -import dicemc.money.MoneyMod; -import dicemc.money.storage.MoneyWSD; -import io.github.flemmli97.flan.Flan; -import io.github.flemmli97.flan.claim.PermHelper; -import io.github.flemmli97.flan.config.ConfigHandler; -import io.github.flemmli97.flan.player.PlayerClaimData; -import net.minecraft.server.command.ServerCommandSource; -import net.minecraft.util.Formatting; - -import java.util.UUID; +import net.minecraft.commands.CommandSourceStack; public class CommandCurrencyImpl { - public static int sellClaimBlocks(CommandContext context) throws CommandSyntaxException { - if (!Flan.diceMCMoneySign) { - context.getSource().sendFeedback(PermHelper.simpleColoredText(ConfigHandler.lang.currencyMissing, Formatting.DARK_RED), false); + public static int sellClaimBlocks(CommandContext context) throws CommandSyntaxException { + /*if (!Flan.diceMCMoneySign) { + context.getSource().sendSuccess(PermHelper.simpleColoredText(ConfigHandler.lang.currencyMissing, ChatFormatting.DARK_RED), false); return 0; } if (ConfigHandler.config.sellPrice == -1) { - context.getSource().sendFeedback(PermHelper.simpleColoredText(ConfigHandler.lang.sellDisabled, Formatting.DARK_RED), false); + context.getSource().sendSuccess(PermHelper.simpleColoredText(ConfigHandler.lang.sellDisabled, ChatFormatting.DARK_RED), false); return 0; } int amount = Math.max(0, IntegerArgumentType.getInteger(context, "amount")); - PlayerClaimData data = PlayerClaimData.get(context.getSource().getPlayer()); + PlayerClaimData data = PlayerClaimData.get(context.getSource().getPlayerOrException()); if (data.getAdditionalClaims() - Math.max(0, data.usedClaimBlocks() - data.getClaimBlocks()) < amount) { - context.getSource().sendFeedback(PermHelper.simpleColoredText(ConfigHandler.lang.sellFail, Formatting.DARK_RED), false); + context.getSource().sendSuccess(PermHelper.simpleColoredText(ConfigHandler.lang.sellFail, ChatFormatting.DARK_RED), false); return 0; } double price = amount * ConfigHandler.config.sellPrice; - MoneyWSD.get(context.getSource().getWorld()).changeBalance(MoneyMod.AcctTypes.PLAYER.key, context.getSource().getPlayer().getUuid(), price); + MoneyWSD.get(context.getSource().getLevel()).changeBalance(MoneyMod.AcctTypes.PLAYER.key, context.getSource().getPlayerOrException().getUUID(), price); data.setAdditionalClaims(data.getAdditionalClaims() - amount); - context.getSource().sendFeedback(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.sellSuccess, amount, price), Formatting.GOLD), false); + context.getSource().sendSuccess(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.sellSuccess, amount, price), ChatFormatting.GOLD), false);*/ return Command.SINGLE_SUCCESS; } - public static int buyClaimBlocks(CommandContext context) throws CommandSyntaxException { - if (!Flan.diceMCMoneySign) { - context.getSource().sendFeedback(PermHelper.simpleColoredText(ConfigHandler.lang.currencyMissing, Formatting.DARK_RED), false); + public static int buyClaimBlocks(CommandContext context) throws CommandSyntaxException { + /*if (!Flan.diceMCMoneySign) { + context.getSource().sendSuccess(PermHelper.simpleColoredText(ConfigHandler.lang.currencyMissing, ChatFormatting.DARK_RED), false); return 0; } if (ConfigHandler.config.buyPrice == -1) { - context.getSource().sendFeedback(PermHelper.simpleColoredText(ConfigHandler.lang.buyDisabled, Formatting.DARK_RED), false); + context.getSource().sendSuccess(PermHelper.simpleColoredText(ConfigHandler.lang.buyDisabled, ChatFormatting.DARK_RED), false); return 0; } - UUID uuid = context.getSource().getPlayer().getUuid(); - MoneyWSD manager = MoneyWSD.get(context.getSource().getWorld()); + UUID uuid = context.getSource().getPlayerOrException().getUUID(); + MoneyWSD manager = MoneyWSD.get(context.getSource().getLevel()); double bal = manager.getBalance(MoneyMod.AcctTypes.PLAYER.key, uuid); int amount = Math.max(0, IntegerArgumentType.getInteger(context, "amount")); double price = amount * ConfigHandler.config.buyPrice; if (bal >= price) { - PlayerClaimData data = PlayerClaimData.get(context.getSource().getPlayer()); + PlayerClaimData data = PlayerClaimData.get(context.getSource().getPlayerOrException()); data.setAdditionalClaims(data.getAdditionalClaims() + amount); manager.changeBalance(MoneyMod.AcctTypes.PLAYER.key, uuid, -price); - context.getSource().sendFeedback(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.buySuccess, amount, price), Formatting.GOLD), false); + context.getSource().sendSuccess(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.buySuccess, amount, price), ChatFormatting.GOLD), false); return Command.SINGLE_SUCCESS; } - context.getSource().sendFeedback(PermHelper.simpleColoredText(ConfigHandler.lang.buyFail, Formatting.DARK_RED), false); + context.getSource().sendSuccess(PermHelper.simpleColoredText(ConfigHandler.lang.buyFail, ChatFormatting.DARK_RED), false);*/ return 0; } } diff --git a/forge/src/main/java/io/github/flemmli97/flan/integration/permissions/forge/PermissionNodeHandlerImpl.java b/forge/src/main/java/io/github/flemmli97/flan/integration/permissions/forge/PermissionNodeHandlerImpl.java index 7b17d75..2a7679b 100644 --- a/forge/src/main/java/io/github/flemmli97/flan/integration/permissions/forge/PermissionNodeHandlerImpl.java +++ b/forge/src/main/java/io/github/flemmli97/flan/integration/permissions/forge/PermissionNodeHandlerImpl.java @@ -1,29 +1,28 @@ package io.github.flemmli97.flan.integration.permissions.forge; -import dev.ftb.mods.ftbranks.api.FTBRanksAPI; import io.github.flemmli97.flan.Flan; import io.github.flemmli97.flan.config.ConfigHandler; -import net.minecraft.server.command.ServerCommandSource; -import net.minecraft.server.network.ServerPlayerEntity; +import net.minecraft.commands.CommandSourceStack; +import net.minecraft.server.level.ServerPlayer; public class PermissionNodeHandlerImpl { - public static boolean perm(ServerCommandSource src, String perm, boolean adminCmd) { - if (!Flan.ftbRanks || !(src.getEntity() instanceof ServerPlayerEntity)) - return !adminCmd || src.hasPermissionLevel(ConfigHandler.config.permissionLevel); - ServerPlayerEntity player = (ServerPlayerEntity) src.getEntity(); - return FTBRanksAPI.getPermissionValue(player, perm).asBoolean().orElse(!adminCmd || player.hasPermissionLevel(ConfigHandler.config.permissionLevel)); + public static boolean perm(CommandSourceStack src, String perm, boolean adminCmd) { + if (!Flan.ftbRanks || !(src.getEntity() instanceof ServerPlayer)) + return !adminCmd || src.hasPermission(ConfigHandler.config.permissionLevel); + ServerPlayer player = (ServerPlayer) src.getEntity(); + return /*FTBRanksAPI.getPermissionValue(player, perm).asBoolean().orElse(!adminCmd || */player.hasPermissions(ConfigHandler.config.permissionLevel); } - public static boolean perm(ServerPlayerEntity src, String perm, boolean adminCmd) { + public static boolean perm(ServerPlayer src, String perm, boolean adminCmd) { if (!Flan.ftbRanks) - return !adminCmd || src.hasPermissionLevel(ConfigHandler.config.permissionLevel); - return FTBRanksAPI.getPermissionValue(src, perm).asBoolean().orElse(!adminCmd || src.hasPermissionLevel(ConfigHandler.config.permissionLevel)); + return !adminCmd || src.hasPermissions(ConfigHandler.config.permissionLevel); + return /*FTBRanksAPI.getPermissionValue(src, perm).asBoolean().orElse(!adminCmd || */src.hasPermissions(ConfigHandler.config.permissionLevel); } - public static boolean permBelowEqVal(ServerPlayerEntity src, String perm, int val, int fallback) { + public static boolean permBelowEqVal(ServerPlayer src, String perm, int val, int fallback) { if (Flan.ftbRanks) { - int max = FTBRanksAPI.getPermissionValue(src, perm).asInteger().orElse(fallback); + int max = fallback;//FTBRanksAPI.getPermissionValue(src, perm).asInteger().orElse(fallback); return val <= max; } return val <= fallback; diff --git a/forge/src/main/resources/META-INF/mods.toml b/forge/src/main/resources/META-INF/mods.toml index df243f8..a911b6a 100644 --- a/forge/src/main/resources/META-INF/mods.toml +++ b/forge/src/main/resources/META-INF/mods.toml @@ -1,5 +1,5 @@ modLoader="javafml" -loaderVersion="[35,)" +loaderVersion="[38,)" license="All rights reserved" issueTrackerURL="https://github.com/Flemmli97/Flan/issues" displayURL="https://github.com/Flemmli97/Flan" @@ -12,4 +12,4 @@ authors="Flemmli97" displayName="Flan" # updateJSONURL="" authors="Flemmli97" - description='''Flan (Forge version): A serverside claiming mod''' + description='''Flan (Forge version): A serverside claiming mod''' \ No newline at end of file diff --git a/forge/src/main/resources/flan.forge.mixins.json b/forge/src/main/resources/flan.forge.mixins.json index 6bbe6b3..142c33d 100644 --- a/forge/src/main/resources/flan.forge.mixins.json +++ b/forge/src/main/resources/flan.forge.mixins.json @@ -2,7 +2,7 @@ "required": true, "minVersion": "0.8", "package": "io.github.flemmli97.flan.forge.mixin", - "compatibilityLevel": "JAVA_8", + "compatibilityLevel": "JAVA_16", "mixins": [ "ForgeFireMixin" ], diff --git a/forge/src/main/resources/pack.mcmeta b/forge/src/main/resources/pack.mcmeta index e0d120b..971b731 100644 --- a/forge/src/main/resources/pack.mcmeta +++ b/forge/src/main/resources/pack.mcmeta @@ -1,6 +1,6 @@ { "pack": { "description": "Flan resources", - "pack_format": 6 + "pack_format": 7 } } \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 4797392..e379f0f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,32 +1,39 @@ -# Done to increase the memory available to gradle. org.gradle.jvmargs=-Xmx2G + +minecraft_version=1.18 + # Forge Properties -forge_version=36.1.31 +forge_version=38.0.8 + # Fabric Properties # check these on https://fabricmc.net/use -minecraft_version=1.16.5 -yarn_mappings=1.16.5+build.9 -loader_version=0.11.3 +loader_version=0.12.8 + # Mod Properties mod_version=1.6.3 maven_group=io.github.flemmli97 archives_base_name=flan + # Dependencies # currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api -fabric_version=0.34.2+1.16 +fabric_version=0.43.1+1.18 gunpowder_version=0.5.7+1.16.5 gunpowder_currency_version=1.0.2+gunpowder.0.3.7.mc.1.16.5 fabric_permissions_api=0.1-SNAPSHOT player_ability_lib=1.2.2 ftb_ranks=1605.1.2-build.17 dicemcmm=curse.maven:dicemcmoney-406972:3397211 + # Curse properties curse_page_fabric=https://www.curseforge.com/minecraft/mc-mods/flan -curse_versions=1.16.5, Java 8 +curse_versions=1.18, Java 17 curse_id_fabric=404578 curse_dep_fabric=fabric-api curse_page_forge=https://www.curseforge.com/minecraft/mc-mods/flan-forge curse_id_forge=493246 curse_dep_forge= + # Other project_name=Flan +full_changelog=https://github.com/Flemmli97/Flan/blob/1.16/Changelog.md +discord_role=<@&852113509243682817> diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 490fda8577df6c95960ba7077c43220e5bb2c0d9..7454180f2ae8848c63b8b4dea2cb829da983f2fa 100644 GIT binary patch delta 18415 zcmY(KV|$=Y8>BO_ZQHhO+qP}pv2EM7C$=$3CX-BTYhvv49{XkYH+1(^U3JzqJ`I+% z1lAM?gXq(yH^>eS0`eOQ1VjWR)n%0+_2(~2pj=}|4Nn98%aJoT+yYHini^eKcoP?t zLW2(0#!inI7gv@7UA%Ulq8nk8vA1hO_&Y-IwR5#c2mRtW#@5$v~DggL|9;ADj6bE%;FTogDj+0L1n96e)j+fr|b}2$>|X{%rCWEZHMxlo79tyoT*&}@6DO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^?O^AjRy4xyT-i}u64lAT} za?=cdSdz;pVVf9Js#-jwaA++OVH+LaE~?vi*5iCgLakL=Swb~+Pq!$1wO0?bRfo$F zNiLku@bJsb#yZCMu6Q|VYS3PUP5Azm$5Xj?Ud9UX-0K(M*2oU>4hlIDk!7(Atzj(3 z8}F^+H=htty|V*9cn_-9L{*^SWD(>`q`E?HvBp&y&XpliZgaI@I;xQ01HKAY>3ynv_oOKNljxzoi(IxN@6*9KuaI&{m`~^T)2vU(>(?65nN;Y_lrYDW z1Jry&$VAdX?{C7A8m3=<;dz}Jpr3cR+yryFpO&UEnm$ds2f~w2+o<*-m)+t^s0$`y zkGN^Z#|10po^aWYK%fC5DG7%&CfYY6TvM5YH2I9nHY{bjDEJoYTpJE$yD0sE%WXVd z2`{oH($6B8bx~vveT()&)EobwMx~#lse#W`lj>^BA{S;+DQRlWmnt9{Ygx6Nk1)o1 N`17riu>%}n>@TnYCZ_-Z diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 0f80bbf..e750102 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/settings.gradle b/settings.gradle index 837b0ed..37e4376 100644 --- a/settings.gradle +++ b/settings.gradle @@ -6,12 +6,7 @@ pluginManagement { } maven { url "https://maven.architectury.dev/" } maven { url "https://repo1.maven.org/maven2/" } - maven { - url = 'https://maven.minecraftforge.net/' - content { - excludeGroupByRegex "org.eclipse.*" - } - } + maven { url "https://maven.minecraftforge.net/" } gradlePluginPortal() } }