diff --git a/.github/workflows/publish-curseforge.yml b/.github/workflows/publish-curseforge.yml index 676cb27..1f02295 100644 --- a/.github/workflows/publish-curseforge.yml +++ b/.github/workflows/publish-curseforge.yml @@ -20,25 +20,23 @@ jobs: - name: Build artifacts run: ./gradlew build - name: publish artifacts - uses: Kir-Antipov/mc-publish@v3.2 + uses: Kir-Antipov/mc-publish@v3.3 with: curseforge-id: 688057 curseforge-token: ${{ secrets.CURSEFORGE_TOKEN }} - files-primary: build/libs/!(*-@(dev|sources)).jar - files-secondary: build/libs/*-@(dev|sources).jar + files: build/libs/*.jar version-type: beta loaders: | fabric quilt - game-versions: | - 1.19.4 - dependencies: | - fabric-api | depends | * + + game-version-filter: releases java: | 17 retry-attempts: 2 retry-delay: 10000 + fail-mode: fail diff --git a/.github/workflows/publish-modrinth.yml b/.github/workflows/publish-modrinth.yml index 2276400..d132ffb 100644 --- a/.github/workflows/publish-modrinth.yml +++ b/.github/workflows/publish-modrinth.yml @@ -20,25 +20,23 @@ jobs: - name: Build artifacts run: ./gradlew build - name: publish artifacts - uses: Kir-Antipov/mc-publish@v3.2 + uses: Kir-Antipov/mc-publish@v3.3 with: modrinth-id: wbrBu6hJ modrinth-token: ${{ secrets.MODRINTH_TOKEN }} - files-primary: build/libs/!(*-@(dev|sources)).jar - files-secondary: build/libs/*-@(dev|sources).jar + files: build/libs/*.jar version-type: beta loaders: | fabric quilt - game-versions: | - 1.19.4 - dependencies: | - fabric-api | depends | * + + game-version-filter: releases java: | 17 retry-attempts: 2 retry-delay: 10000 + fail-mode: fail diff --git a/build.gradle b/build.gradle index ad6e81c..8c2a69d 100644 --- a/build.gradle +++ b/build.gradle @@ -1,9 +1,9 @@ plugins { - id "fabric-loom" version "1.1-SNAPSHOT" - id "io.github.juuxel.loom-quiltflower" version "1.8.0" + id "fabric-loom" version "1.2-SNAPSHOT" + id "io.github.juuxel.loom-quiltflower" version "1.10.0" } -version = project.mod_version + "+" + project.minecraft_version +version = project.mod_version group = project.maven_group repositories { @@ -14,7 +14,6 @@ repositories { maven { url "https://maven.nucleoid.xyz" } maven { url "https://oss.sonatype.org/content/repositories/snapshots" } maven { url "https://ladysnake.jfrog.io/artifactory/mods" } - maven { url "https://jitpack.io" } } dependencies { @@ -23,20 +22,15 @@ dependencies { modImplementation "net.fabricmc:fabric-loader:${project.fabric_loader}" modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_api}" - modImplementation "dev.onyxstudios.cardinal-components-api:cardinal-components-api:${project.cca}" - include "dev.onyxstudios.cardinal-components-api:cardinal-components-base:${project.cca}" - include "dev.onyxstudios.cardinal-components-api:cardinal-components-world:${project.cca}" - include "dev.onyxstudios.cardinal-components-api:cardinal-components-entity:${project.cca}" - modImplementation include("com.github.tyap-lyap:fantasy:${project.fantasy}") -// modImplementation include("xyz.nucleoid:fantasy:${project.fantasy}") + modImplementation include("dev.onyxstudios.cardinal-components-api:cardinal-components-base:${project.cca}") + modImplementation include("dev.onyxstudios.cardinal-components-api:cardinal-components-world:${project.cca}") + modImplementation include("dev.onyxstudios.cardinal-components-api:cardinal-components-entity:${project.cca}") + + modImplementation include("xyz.nucleoid:fantasy:${project.fantasy}") modImplementation include("eu.pb4:placeholder-api:${project.placeholder_api}") modImplementation include("xyz.nucleoid:server-translations-api:${project.server_translations_api}") modImplementation include("me.lucko:fabric-permissions-api:0.2-SNAPSHOT") - - modLocalRuntime "maven.modrinth:dcwa:4.0" - modLocalRuntime "maven.modrinth:starlight:1.1.1+1.19" - modLocalRuntime "maven.modrinth:lithium:mc1.19.4-0.11.1" } loom { diff --git a/gradle.properties b/gradle.properties index 2482842..c326ac2 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,19 +5,19 @@ org.gradle.parallel = true # Mod Properties maven_group = ru.pinkgoosik archives_base_name = skylands -mod_version = 0.3.8 +mod_version = 0.3.9+1.20 # Dependencies | Check these on https://fabricmc.net/develop -minecraft_version = 1.19.4 -yarn_mappings = 1.19.4+build.1 -fabric_loader = 0.14.17 -fabric_api = 0.76.0+1.19.4 +minecraft_version = 1.20 +yarn_mappings = 1.20+build.1 +fabric_loader = 0.14.21 +fabric_api = 0.83.0+1.20 # https://github.com/OnyxStudios/Cardinal-Components-API/releases -cca = 5.1.0 +cca = 5.2.0 # https://github.com/NucleoidMC/fantasy/releases -fantasy = 15b00d289f +fantasy = 0.4.11+1.20-rc1 # https://github.com/Patbox/TextPlaceholderAPI/releases -placeholder_api = 2.0.0-rc.1+1.19.3 +placeholder_api = 2.1.1+1.20 # https://github.com/NucleoidMC/Server-Translations/releases server_translations_api = 2.0.0-beta.2+1.19.4-pre2 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index ef89f5a..c898b7a 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip networkTimeout=10000 zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists \ No newline at end of file diff --git a/src/main/java/skylands/command/AcceptCommand.java b/src/main/java/skylands/command/AcceptCommand.java index b4ce720..34d7804 100644 --- a/src/main/java/skylands/command/AcceptCommand.java +++ b/src/main/java/skylands/command/AcceptCommand.java @@ -7,8 +7,7 @@ import net.minecraft.server.network.ServerPlayerEntity; import skylands.data.SkylandsComponents; import skylands.logic.Skylands; -import skylands.util.Players; -import skylands.util.Texts; +import skylands.util.SkylandsTexts; import static com.mojang.brigadier.arguments.StringArgumentType.word; import static net.minecraft.server.command.CommandManager.argument; @@ -29,28 +28,28 @@ static void init(CommandDispatcher dispatcher) { } static void run(ServerPlayerEntity player, String ownerName) { - var inviter = Players.get(ownerName); - if(inviter.isPresent()) { - var island = Skylands.instance.islands.get(inviter.get()); + if(player.getServer() != null) { + var inviter = player.getServer().getPlayerManager().getPlayer(ownerName); + var island = Skylands.getIslands().get(inviter); if(island.isPresent()) { var invite = Skylands.instance.invites.get(island.get(), player); if(invite.isPresent()) { if(!invite.get().accepted) { invite.get().accept(player); - player.sendMessage(Texts.prefixed("message.skylands.accept.success", map -> map.put("%owner%", ownerName))); + player.sendMessage(SkylandsTexts.prefixed("message.skylands.accept.success", map -> map.put("%owner%", ownerName))); SkylandsComponents.PLAYER_DATA.get(player).addIsland(ownerName); } } else { - player.sendMessage(Texts.prefixed("message.skylands.accept.fail")); + player.sendMessage(SkylandsTexts.prefixed("message.skylands.accept.fail")); } } else { - player.sendMessage(Texts.prefixed("message.skylands.accept.no_island")); + player.sendMessage(SkylandsTexts.prefixed("message.skylands.accept.no_island")); } } else { - player.sendMessage(Texts.prefixed("message.skylands.accept.no_player")); + player.sendMessage(SkylandsTexts.prefixed("message.skylands.accept.no_player")); } } } diff --git a/src/main/java/skylands/command/BanCommands.java b/src/main/java/skylands/command/BanCommands.java index e9b3b52..f41b128 100644 --- a/src/main/java/skylands/command/BanCommands.java +++ b/src/main/java/skylands/command/BanCommands.java @@ -8,8 +8,8 @@ import net.minecraft.server.network.ServerPlayerEntity; import skylands.logic.Member; import skylands.logic.Skylands; -import skylands.util.Texts; -import skylands.util.Worlds; +import skylands.util.SkylandsTexts; +import skylands.util.SkylandsWorlds; import static com.mojang.brigadier.arguments.StringArgumentType.word; import static net.minecraft.command.argument.EntityArgumentType.player; @@ -61,42 +61,42 @@ static void init(CommandDispatcher dispatcher) { static void ban(ServerPlayerEntity player, ServerPlayerEntity banned) { Skylands.instance.islands.get(player).ifPresentOrElse(island -> { if(player.getName().getString().equals(banned.getName().getString())) { - player.sendMessage(Texts.prefixed("message.skylands.ban_player.yourself")); + player.sendMessage(SkylandsTexts.prefixed("message.skylands.ban_player.yourself")); } else { if(island.isMember(banned)) { - player.sendMessage(Texts.prefixed("message.skylands.ban_player.member")); + player.sendMessage(SkylandsTexts.prefixed("message.skylands.ban_player.member")); } else { if(island.isBanned(banned)) { - player.sendMessage(Texts.prefixed("message.skylands.ban_player.fail")); + player.sendMessage(SkylandsTexts.prefixed("message.skylands.ban_player.fail")); } else { island.bans.add(new Member(banned)); - player.sendMessage(Texts.prefixed("message.skylands.ban_player.success", map -> map.put("%player%", banned.getName().getString()))); - banned.sendMessage(Texts.prefixed("message.skylands.ban_player.ban", map -> map.put("%owner%", island.owner.name))); + player.sendMessage(SkylandsTexts.prefixed("message.skylands.ban_player.success", map -> map.put("%player%", banned.getName().getString()))); + banned.sendMessage(SkylandsTexts.prefixed("message.skylands.ban_player.ban", map -> map.put("%owner%", island.owner.name))); - Worlds.getIsland(banned.getWorld()).ifPresent(isl -> { + SkylandsWorlds.getIsland(banned.getWorld()).ifPresent(isl -> { if(isl.owner.uuid.equals(island.owner.uuid)) { - banned.sendMessage(Texts.prefixed("message.skylands.hub_visit")); + banned.sendMessage(SkylandsTexts.prefixed("message.skylands.hub_visit")); Skylands.instance.hub.visit(player); } }); } } } - }, () -> player.sendMessage(Texts.prefixed("message.skylands.ban_player.no_island"))); + }, () -> player.sendMessage(SkylandsTexts.prefixed("message.skylands.ban_player.no_island"))); } static void unban(ServerPlayerEntity player, String unbanned) { Skylands.instance.islands.get(player).ifPresentOrElse(island -> { if(!island.isBanned(unbanned)) { - player.sendMessage(Texts.prefixed("message.skylands.unban_player.fail")); + player.sendMessage(SkylandsTexts.prefixed("message.skylands.unban_player.fail")); } else { island.bans.removeIf(member -> member.name.equals(unbanned)); - player.sendMessage(Texts.prefixed("message.skylands.unban_player.success", map -> map.put("%player%", unbanned))); + player.sendMessage(SkylandsTexts.prefixed("message.skylands.unban_player.success", map -> map.put("%player%", unbanned))); } - }, () -> player.sendMessage(Texts.prefixed("message.skylands.unban_player.no_island"))); + }, () -> player.sendMessage(SkylandsTexts.prefixed("message.skylands.unban_player.no_island"))); } } diff --git a/src/main/java/skylands/command/CreateCommand.java b/src/main/java/skylands/command/CreateCommand.java index c1fcbe9..aad3b72 100644 --- a/src/main/java/skylands/command/CreateCommand.java +++ b/src/main/java/skylands/command/CreateCommand.java @@ -7,7 +7,7 @@ import skylands.logic.Island; import skylands.logic.IslandStuck; import skylands.logic.Skylands; -import skylands.util.Texts; +import skylands.util.SkylandsTexts; import static net.minecraft.server.command.CommandManager.literal; @@ -28,14 +28,14 @@ static void run(ServerPlayerEntity player) { IslandStuck islands = Skylands.instance.islands; if(islands.get(player).isPresent()) { - player.sendMessage(Texts.prefixed("message.skylands.island_create.fail")); + player.sendMessage(SkylandsTexts.prefixed("message.skylands.island_create.fail")); } else { Island island = islands.create(player); if(Skylands.config.teleportAfterIslandCreation) { island.visitAsMember(player); } - player.sendMessage(Texts.prefixed("message.skylands.island_create.success")); + player.sendMessage(SkylandsTexts.prefixed("message.skylands.island_create.success")); } } } diff --git a/src/main/java/skylands/command/DeleteCommand.java b/src/main/java/skylands/command/DeleteCommand.java index cb8f745..078925c 100644 --- a/src/main/java/skylands/command/DeleteCommand.java +++ b/src/main/java/skylands/command/DeleteCommand.java @@ -7,7 +7,7 @@ import net.minecraft.server.network.ServerPlayerEntity; import skylands.logic.IslandStuck; import skylands.logic.Skylands; -import skylands.util.Texts; +import skylands.util.SkylandsTexts; import java.time.Instant; import java.time.temporal.ChronoUnit; @@ -43,18 +43,18 @@ static void run(ServerPlayerEntity player, String confirmWord) { if(seconds >= Skylands.config.islandDeletionCooldown) { islands.delete(player); - player.sendMessage(Texts.prefixed("message.skylands.island_delete.success")); + player.sendMessage(SkylandsTexts.prefixed("message.skylands.island_delete.success")); } else { - player.sendMessage(Texts.prefixed("message.skylands.island_delete.too_often")); + player.sendMessage(SkylandsTexts.prefixed("message.skylands.island_delete.too_often")); } }, () -> { - player.sendMessage(Texts.prefixed("message.skylands.island_delete.fail")); + player.sendMessage(SkylandsTexts.prefixed("message.skylands.island_delete.fail")); }); } else { - player.sendMessage(Texts.prefixed("message.skylands.island_delete.warning")); + player.sendMessage(SkylandsTexts.prefixed("message.skylands.island_delete.warning")); } } @@ -67,14 +67,14 @@ static void warn(ServerPlayerEntity player) { var hours = ChronoUnit.HOURS.between(created, now); if(hours >= 24) { - player.sendMessage(Texts.prefixed("message.skylands.island_delete.warning")); + player.sendMessage(SkylandsTexts.prefixed("message.skylands.island_delete.warning")); } else { - player.sendMessage(Texts.prefixed("message.skylands.island_delete.too_often")); + player.sendMessage(SkylandsTexts.prefixed("message.skylands.island_delete.too_often")); } }, () -> { - player.sendMessage(Texts.prefixed("message.skylands.island_delete.fail")); + player.sendMessage(SkylandsTexts.prefixed("message.skylands.island_delete.fail")); }); } } diff --git a/src/main/java/skylands/command/HomeCommand.java b/src/main/java/skylands/command/HomeCommand.java index 0a865fa..1c4e02a 100644 --- a/src/main/java/skylands/command/HomeCommand.java +++ b/src/main/java/skylands/command/HomeCommand.java @@ -8,7 +8,7 @@ import skylands.SkylandsMod; import skylands.data.SkylandsComponents; import skylands.logic.Skylands; -import skylands.util.Texts; +import skylands.util.SkylandsTexts; import static com.mojang.brigadier.arguments.StringArgumentType.word; import static net.minecraft.server.command.CommandManager.argument; @@ -53,33 +53,33 @@ static void init(CommandDispatcher dispatcher) { public static void run(ServerPlayerEntity player) { Skylands.instance.islands.get(player).ifPresentOrElse(island -> { if(player.getWorld().getRegistryKey().getValue().equals(SkylandsMod.id(player.getUuid().toString()))) { - player.sendMessage(Texts.prefixed("message.skylands.home.fail")); + player.sendMessage(SkylandsTexts.prefixed("message.skylands.home.fail")); } else { - player.sendMessage(Texts.prefixed("message.skylands.home.success")); + player.sendMessage(SkylandsTexts.prefixed("message.skylands.home.success")); island.visitAsMember(player); } - }, () -> player.sendMessage(Texts.prefixed("message.skylands.home.no_island"))); + }, () -> player.sendMessage(SkylandsTexts.prefixed("message.skylands.home.no_island"))); } public static void run(ServerPlayerEntity visitor, String islandOwner) { Skylands.instance.islands.get(islandOwner).ifPresentOrElse(island -> { if(visitor.getWorld().getRegistryKey().getValue().equals(SkylandsMod.id(island.owner.uuid.toString()))) { - visitor.sendMessage(Texts.prefixed("message.skylands.visit_home.fail", map -> map.put("%owner%", islandOwner))); + visitor.sendMessage(SkylandsTexts.prefixed("message.skylands.visit_home.fail", map -> map.put("%owner%", islandOwner))); } else { if(island.isMember(visitor)) { - visitor.sendMessage(Texts.prefixed("message.skylands.visit_home.success", map -> map.put("%owner%", islandOwner))); + visitor.sendMessage(SkylandsTexts.prefixed("message.skylands.visit_home.success", map -> map.put("%owner%", islandOwner))); island.visitAsMember(visitor); SkylandsComponents.PLAYER_DATA.get(visitor).addIsland(islandOwner); } else { - visitor.sendMessage(Texts.prefixed("message.skylands.visit_home.not_member")); + visitor.sendMessage(SkylandsTexts.prefixed("message.skylands.visit_home.not_member")); SkylandsComponents.PLAYER_DATA.get(visitor).removeIsland(islandOwner); } } }, () -> { - visitor.sendMessage(Texts.prefixed("message.skylands.visit_home.no_island")); + visitor.sendMessage(SkylandsTexts.prefixed("message.skylands.visit_home.no_island")); SkylandsComponents.PLAYER_DATA.get(visitor).removeIsland(islandOwner); }); } diff --git a/src/main/java/skylands/command/HubCommands.java b/src/main/java/skylands/command/HubCommands.java index 8af354a..8378b08 100644 --- a/src/main/java/skylands/command/HubCommands.java +++ b/src/main/java/skylands/command/HubCommands.java @@ -8,7 +8,7 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; import skylands.logic.Skylands; -import skylands.util.Texts; +import skylands.util.SkylandsTexts; import static net.minecraft.command.argument.BlockPosArgumentType.blockPos; import static net.minecraft.server.command.CommandManager.argument; @@ -39,25 +39,25 @@ static void init(CommandDispatcher dispatcher) { } public static void visit(ServerPlayerEntity player) { - player.sendMessage(Texts.prefixed("message.skylands.hub_visit")); + player.sendMessage(SkylandsTexts.prefixed("message.skylands.hub_visit")); Skylands.getHub().visit(player); } static void setPos(BlockPos pos, ServerCommandSource source) { Skylands.getHub().pos = new Vec3d(pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5); String posText = pos.getX() + " " + pos.getY() + " " + pos.getZ(); - source.sendFeedback(Texts.prefixed("message.skylands.hub_pos_change", map -> map.put("%pos%", posText)), true); + source.sendFeedback(() -> SkylandsTexts.prefixed("message.skylands.hub_pos_change", map -> map.put("%pos%", posText)), true); } static void toggleProtection(ServerCommandSource source) { var hub = Skylands.getHub(); if(hub.hasProtection) { hub.hasProtection = false; - source.sendFeedback(Texts.prefixed("message.skylands.hub_protection.disable"), true); + source.sendFeedback(() -> SkylandsTexts.prefixed("message.skylands.hub_protection.disable"), true); } else { hub.hasProtection = true; - source.sendFeedback(Texts.prefixed("message.skylands.hub_protection.enable"), true); + source.sendFeedback(() -> SkylandsTexts.prefixed("message.skylands.hub_protection.enable"), true); } } } diff --git a/src/main/java/skylands/command/KickCommand.java b/src/main/java/skylands/command/KickCommand.java index ee51d3c..42e402f 100644 --- a/src/main/java/skylands/command/KickCommand.java +++ b/src/main/java/skylands/command/KickCommand.java @@ -6,8 +6,8 @@ import net.minecraft.server.command.ServerCommandSource; import net.minecraft.server.network.ServerPlayerEntity; import skylands.logic.Skylands; -import skylands.util.Texts; -import skylands.util.Worlds; +import skylands.util.SkylandsTexts; +import skylands.util.SkylandsWorlds; import static net.minecraft.command.argument.EntityArgumentType.player; import static net.minecraft.server.command.CommandManager.argument; @@ -29,27 +29,27 @@ static void init(CommandDispatcher dispatcher) { static void run(ServerPlayerEntity player, ServerPlayerEntity kicked) { Skylands.instance.islands.get(player).ifPresentOrElse(island -> { if(player.getName().getString().equals(kicked.getName().getString())) { - player.sendMessage(Texts.prefixed("message.skylands.kick_visitor.yourself")); + player.sendMessage(SkylandsTexts.prefixed("message.skylands.kick_visitor.yourself")); } else { if(island.isMember(kicked)) { - player.sendMessage(Texts.prefixed("message.skylands.kick_visitor.member")); + player.sendMessage(SkylandsTexts.prefixed("message.skylands.kick_visitor.member")); } else { - Worlds.getIsland(kicked.getWorld()).ifPresent(isl -> { + SkylandsWorlds.getIsland(kicked.getWorld()).ifPresent(isl -> { if(isl.owner.uuid.equals(island.owner.uuid)) { - player.sendMessage(Texts.prefixed("message.skylands.kick_visitor.success", map -> map.put("%player%", kicked.getName().getString()))); + player.sendMessage(SkylandsTexts.prefixed("message.skylands.kick_visitor.success", map -> map.put("%player%", kicked.getName().getString()))); - kicked.sendMessage(Texts.prefixed("message.skylands.kick_visitor.kick", map -> map.put("%owner%", player.getName().getString()))); - kicked.sendMessage(Texts.prefixed("message.skylands.hub_visit")); + kicked.sendMessage(SkylandsTexts.prefixed("message.skylands.kick_visitor.kick", map -> map.put("%owner%", player.getName().getString()))); + kicked.sendMessage(SkylandsTexts.prefixed("message.skylands.hub_visit")); Skylands.instance.hub.visit(kicked); } else { - player.sendMessage(Texts.prefixed("message.skylands.kick_visitor.fail", map -> map.put("%player%", kicked.getName().getString()))); + player.sendMessage(SkylandsTexts.prefixed("message.skylands.kick_visitor.fail", map -> map.put("%player%", kicked.getName().getString()))); } }); } } - }, () -> player.sendMessage(Texts.prefixed("message.skylands.kick_visitor.no_island"))); + }, () -> player.sendMessage(SkylandsTexts.prefixed("message.skylands.kick_visitor.no_island"))); } } diff --git a/src/main/java/skylands/command/MemberCommands.java b/src/main/java/skylands/command/MemberCommands.java index 89b1ea1..d9587bd 100644 --- a/src/main/java/skylands/command/MemberCommands.java +++ b/src/main/java/skylands/command/MemberCommands.java @@ -7,7 +7,7 @@ import net.minecraft.server.command.ServerCommandSource; import net.minecraft.server.network.ServerPlayerEntity; import skylands.logic.Skylands; -import skylands.util.Texts; +import skylands.util.SkylandsTexts; import static com.mojang.brigadier.arguments.StringArgumentType.word; import static net.minecraft.command.argument.EntityArgumentType.player; @@ -54,38 +54,38 @@ static void init(CommandDispatcher dispatcher) { static void invite(ServerPlayerEntity inviter, ServerPlayerEntity newcomer) { Skylands.instance.islands.get(inviter).ifPresentOrElse(island -> { if(island.isMember(newcomer)) { - inviter.sendMessage(Texts.prefixed("message.skylands.invite_member.already_member")); + inviter.sendMessage(SkylandsTexts.prefixed("message.skylands.invite_member.already_member")); } else { if(Skylands.instance.invites.hasInvite(island, newcomer)) { - inviter.sendMessage(Texts.prefixed("message.skylands.invite_member.already_invited")); + inviter.sendMessage(SkylandsTexts.prefixed("message.skylands.invite_member.already_invited")); } else { - inviter.sendMessage(Texts.prefixed("message.skylands.invite_member.success", (map) -> map.put("%newcomer%", newcomer.getName().getString()))); + inviter.sendMessage(SkylandsTexts.prefixed("message.skylands.invite_member.success", (map) -> map.put("%newcomer%", newcomer.getName().getString()))); - newcomer.sendMessage(Texts.prefixed("message.skylands.invite_member.invite.0", (map) -> map.put("%inviter%", inviter.getName().getString()))); - newcomer.sendMessage(Texts.prefixed("message.skylands.invite_member.invite.1", (map) -> map.put("%inviter%", inviter.getName().getString()))); + newcomer.sendMessage(SkylandsTexts.prefixed("message.skylands.invite_member.invite.0", (map) -> map.put("%inviter%", inviter.getName().getString()))); + newcomer.sendMessage(SkylandsTexts.prefixed("message.skylands.invite_member.invite.1", (map) -> map.put("%inviter%", inviter.getName().getString()))); Skylands.instance.invites.create(island, newcomer); } } - }, () -> inviter.sendMessage(Texts.prefixed("message.skylands.invite_member.no_island"))); + }, () -> inviter.sendMessage(SkylandsTexts.prefixed("message.skylands.invite_member.no_island"))); } static void remove(ServerPlayerEntity player, String removed) { Skylands.instance.islands.get(player).ifPresentOrElse(island -> { if(player.getName().getString().equals(removed)) { - player.sendMessage(Texts.prefixed("message.skylands.remove_member.yourself")); + player.sendMessage(SkylandsTexts.prefixed("message.skylands.remove_member.yourself")); } else { if(island.isMember(removed)) { island.members.removeIf(member -> member.name.equals(removed)); - player.sendMessage(Texts.prefixed("message.skylands.remove_member.success", (map) -> map.put("%member%", removed))); + player.sendMessage(SkylandsTexts.prefixed("message.skylands.remove_member.success", (map) -> map.put("%member%", removed))); } else { - player.sendMessage(Texts.prefixed("message.skylands.remove_member.not_member")); + player.sendMessage(SkylandsTexts.prefixed("message.skylands.remove_member.not_member")); } } - }, () -> player.sendMessage(Texts.prefixed("message.skylands.remove_member.no_island"))); + }, () -> player.sendMessage(SkylandsTexts.prefixed("message.skylands.remove_member.no_island"))); } } diff --git a/src/main/java/skylands/command/SettingCommands.java b/src/main/java/skylands/command/SettingCommands.java index 5e1ddf7..64c3b50 100644 --- a/src/main/java/skylands/command/SettingCommands.java +++ b/src/main/java/skylands/command/SettingCommands.java @@ -8,7 +8,7 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; import skylands.logic.Skylands; -import skylands.util.Texts; +import skylands.util.SkylandsTexts; import static net.minecraft.command.argument.BlockPosArgumentType.blockPos; import static net.minecraft.server.command.CommandManager.argument; @@ -43,32 +43,32 @@ static void init(CommandDispatcher dispatcher) { static void toggleVisits(ServerPlayerEntity player) { Skylands.instance.islands.get(player).ifPresentOrElse(island -> { if(island.locked) { - player.sendMessage(Texts.prefixed("message.skylands.settings.unlock")); + player.sendMessage(SkylandsTexts.prefixed("message.skylands.settings.unlock")); island.locked = false; } else { - player.sendMessage(Texts.prefixed("message.skylands.settings.lock")); + player.sendMessage(SkylandsTexts.prefixed("message.skylands.settings.lock")); island.locked = true; } - }, () -> player.sendMessage(Texts.prefixed("message.skylands.settings.no_island"))); + }, () -> player.sendMessage(SkylandsTexts.prefixed("message.skylands.settings.no_island"))); } static void setSpawnPos(ServerPlayerEntity player, BlockPos pos) { Skylands.instance.islands.get(player).ifPresentOrElse(island -> { island.spawnPos = new Vec3d(pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5); String posText = pos.getX() + " " + pos.getY() + " " + pos.getZ(); - player.sendMessage(Texts.prefixed("message.skylands.settings.spawn_pos_change", map -> map.put("%pos%", posText))); + player.sendMessage(SkylandsTexts.prefixed("message.skylands.settings.spawn_pos_change", map -> map.put("%pos%", posText))); - }, () -> player.sendMessage(Texts.prefixed("message.skylands.settings.no_island"))); + }, () -> player.sendMessage(SkylandsTexts.prefixed("message.skylands.settings.no_island"))); } static void setVisitsPos(ServerPlayerEntity player, BlockPos pos) { Skylands.instance.islands.get(player).ifPresentOrElse(island -> { island.visitsPos = new Vec3d(pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5); String posText = pos.getX() + " " + pos.getY() + " " + pos.getZ(); - player.sendMessage(Texts.prefixed("message.skylands.settings.visits_pos_change", map -> map.put("%pos%", posText))); + player.sendMessage(SkylandsTexts.prefixed("message.skylands.settings.visits_pos_change", map -> map.put("%pos%", posText))); - }, () -> player.sendMessage(Texts.prefixed("message.skylands.settings.no_island"))); + }, () -> player.sendMessage(SkylandsTexts.prefixed("message.skylands.settings.no_island"))); } } diff --git a/src/main/java/skylands/command/SkylandsCommands.java b/src/main/java/skylands/command/SkylandsCommands.java index 399362e..454dabd 100644 --- a/src/main/java/skylands/command/SkylandsCommands.java +++ b/src/main/java/skylands/command/SkylandsCommands.java @@ -8,7 +8,7 @@ import net.minecraft.server.command.ServerCommandSource; import skylands.config.SkylandsConfigCommands; import skylands.logic.Skylands; -import skylands.util.Texts; +import skylands.util.SkylandsTexts; import static net.minecraft.server.command.CommandManager.literal; import static net.minecraft.server.command.CommandManager.argument; @@ -49,9 +49,9 @@ private static void register(CommandDispatcher dispatcher) Skylands.getIslands().get(playerName).ifPresentOrElse(island -> { Skylands.instance.islands.delete(playerName); - Texts.prefixed(context, "message.skylands.force.delete.success", map -> map.put("%player%", playerName)); + SkylandsTexts.prefixed(context, "message.skylands.force.delete.success", map -> map.put("%player%", playerName)); }, () -> { - Texts.prefixed(context, "message.skylands.force.delete.fail", map -> map.put("%player%", playerName)); + SkylandsTexts.prefixed(context, "message.skylands.force.delete.fail", map -> map.put("%player%", playerName)); }); return 1; @@ -63,9 +63,9 @@ private static void register(CommandDispatcher dispatcher) if(admin != null) { Skylands.getIslands().get(playerName).ifPresentOrElse(island -> { island.visitAsMember(admin); - Texts.prefixed(context, "message.skylands.force.visit.success", map -> map.put("%player%", playerName)); + SkylandsTexts.prefixed(context, "message.skylands.force.visit.success", map -> map.put("%player%", playerName)); }, () -> { - Texts.prefixed(context, "message.skylands.force.visit.fail", map -> map.put("%player%", playerName)); + SkylandsTexts.prefixed(context, "message.skylands.force.visit.fail", map -> map.put("%player%", playerName)); }); } return 1; diff --git a/src/main/java/skylands/command/VisitCommand.java b/src/main/java/skylands/command/VisitCommand.java index 1bb52a7..2bf61a2 100644 --- a/src/main/java/skylands/command/VisitCommand.java +++ b/src/main/java/skylands/command/VisitCommand.java @@ -7,7 +7,7 @@ import net.minecraft.server.network.ServerPlayerEntity; import skylands.SkylandsMod; import skylands.logic.Skylands; -import skylands.util.Texts; +import skylands.util.SkylandsTexts; import static net.minecraft.command.argument.EntityArgumentType.player; import static net.minecraft.server.command.CommandManager.argument; @@ -31,23 +31,23 @@ public static void run(ServerPlayerEntity visitor, ServerPlayerEntity owner) { Skylands.instance.islands.get(owner).ifPresentOrElse(island -> { if(!island.isMember(visitor) && island.isBanned(visitor)) { - visitor.sendMessage(Texts.prefixed("message.skylands.island_visit.ban", map -> map.put("%owner%", ownerName))); + visitor.sendMessage(SkylandsTexts.prefixed("message.skylands.island_visit.ban", map -> map.put("%owner%", ownerName))); } else { if(!island.locked) { if(visitor.getWorld().getRegistryKey().getValue().equals(SkylandsMod.id(island.owner.uuid.toString()))) { - visitor.sendMessage(Texts.prefixed("message.skylands.island_visit.fail", map -> map.put("%owner%", ownerName))); + visitor.sendMessage(SkylandsTexts.prefixed("message.skylands.island_visit.fail", map -> map.put("%owner%", ownerName))); } else { - visitor.sendMessage(Texts.prefixed("message.skylands.island_visit.success", map -> map.put("%owner%", ownerName))); + visitor.sendMessage(SkylandsTexts.prefixed("message.skylands.island_visit.success", map -> map.put("%owner%", ownerName))); island.visitAsVisitor(visitor); } } else { - visitor.sendMessage(Texts.prefixed("message.skylands.island_visit.no_visits", map -> map.put("%owner%", ownerName))); + visitor.sendMessage(SkylandsTexts.prefixed("message.skylands.island_visit.no_visits", map -> map.put("%owner%", ownerName))); } } - }, () -> visitor.sendMessage(Texts.prefixed("message.skylands.island_visit.no_island", map -> map.put("%owner%", ownerName)))); + }, () -> visitor.sendMessage(SkylandsTexts.prefixed("message.skylands.island_visit.no_island", map -> map.put("%owner%", ownerName)))); } } diff --git a/src/main/java/skylands/config/SkylandsConfigCommands.java b/src/main/java/skylands/config/SkylandsConfigCommands.java index b64ec69..d194e81 100644 --- a/src/main/java/skylands/config/SkylandsConfigCommands.java +++ b/src/main/java/skylands/config/SkylandsConfigCommands.java @@ -23,7 +23,7 @@ public static void init(CommandDispatcher dispatcher) { Skylands.config.defaultSpawnPos = new PlayerPosition(pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5); Skylands.config.save(); String posText = pos.getX() + " " + pos.getY() + " " + pos.getZ(); - context.getSource().sendFeedback(Text.of("config.defaultSpawnPos has changed to: " + posText), true); + context.getSource().sendFeedback(() -> Text.of("config.defaultSpawnPos has changed to: " + posText), true); return 1; }))).then(literal("default-visits-pos").then(argument("position", blockPos()).executes(context -> { @@ -31,7 +31,7 @@ public static void init(CommandDispatcher dispatcher) { Skylands.config.defaultVisitsPos = new PlayerPosition(pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5); Skylands.config.save(); String posText = pos.getX() + " " + pos.getY() + " " + pos.getZ(); - context.getSource().sendFeedback(Text.of("config.defaultVisitsPos has changed to: " + posText), true); + context.getSource().sendFeedback(() -> Text.of("config.defaultVisitsPos has changed to: " + posText), true); return 1; }))).then(literal("default-hub-pos").then(argument("position", blockPos()).executes(context -> { @@ -39,53 +39,53 @@ public static void init(CommandDispatcher dispatcher) { Skylands.config.defaultHubPos = new PlayerPosition(pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5); Skylands.config.save(); String posText = pos.getX() + " " + pos.getY() + " " + pos.getZ(); - context.getSource().sendFeedback(Text.of("config.defaultHubPos has changed to: " + posText), true); + context.getSource().sendFeedback(() -> Text.of("config.defaultHubPos has changed to: " + posText), true); return 1; }))).then(literal("island-deletion-cooldown").then(argument("cooldown", integer()).executes(context -> { var cooldown = IntegerArgumentType.getInteger(context, "cooldown"); Skylands.config.islandDeletionCooldown = cooldown; Skylands.config.save(); - context.getSource().sendFeedback(Text.of("config.islandDeletionCooldown has changed to: " + cooldown), true); + context.getSource().sendFeedback(() -> Text.of("config.islandDeletionCooldown has changed to: " + cooldown), true); return 1; }))).then(literal("teleport-after-island-creation").executes(context -> { var config = Skylands.config; config.teleportAfterIslandCreation = !config.teleportAfterIslandCreation; config.save(); - context.getSource().sendFeedback(Text.of("config.teleportAfterIslandCreation has changed to: " + config.teleportAfterIslandCreation), true); + context.getSource().sendFeedback(() -> Text.of("config.teleportAfterIslandCreation has changed to: " + config.teleportAfterIslandCreation), true); return 1; })).then(literal("hub-protected-by-default").executes(context -> { var config = Skylands.config; config.hubProtectedByDefault = !config.hubProtectedByDefault; config.save(); - context.getSource().sendFeedback(Text.of("config.hubProtectedByDefault has changed to: " + config.hubProtectedByDefault), true); + context.getSource().sendFeedback(() -> Text.of("config.hubProtectedByDefault has changed to: " + config.hubProtectedByDefault), true); return 1; })).then(literal("create-island-on-player-join").executes(context -> { var config = Skylands.config; config.createIslandOnPlayerJoin = !config.createIslandOnPlayerJoin; config.save(); - context.getSource().sendFeedback(Text.of("config.createIslandOnPlayerJoin has changed to: " + config.createIslandOnPlayerJoin), true); + context.getSource().sendFeedback(() -> Text.of("config.createIslandOnPlayerJoin has changed to: " + config.createIslandOnPlayerJoin), true); return 1; })).then(literal("toggle-update-checker").executes(context -> { var config = Skylands.config; config.updateCheckerEnabled = !config.updateCheckerEnabled; config.save(); - context.getSource().sendFeedback(Text.of("config.updateCheckerEnabled has changed to: " + config.updateCheckerEnabled), true); + context.getSource().sendFeedback(() -> Text.of("config.updateCheckerEnabled has changed to: " + config.updateCheckerEnabled), true); return 1; })).then(literal("toggle-right-click-harvest").executes(context -> { var config = Skylands.config; config.rightClickHarvestEnabled = !config.rightClickHarvestEnabled; config.save(); - context.getSource().sendFeedback(Text.of("config.rightClickHarvestEnabled has changed to: " + config.rightClickHarvestEnabled), true); + context.getSource().sendFeedback(() -> Text.of("config.rightClickHarvestEnabled has changed to: " + config.rightClickHarvestEnabled), true); return 1; })).then(literal("reload").executes(context -> { Skylands.config = SkylandsConfig.read(); - context.getSource().sendFeedback(Text.of("Config successfully reloaded!"), true); + context.getSource().sendFeedback(() -> Text.of("Config successfully reloaded!"), true); return 1; })))); diff --git a/src/main/java/skylands/data/PlayerComponent.java b/src/main/java/skylands/data/PlayerComponent.java index 0e1daf5..fdaf058 100644 --- a/src/main/java/skylands/data/PlayerComponent.java +++ b/src/main/java/skylands/data/PlayerComponent.java @@ -4,7 +4,7 @@ import net.minecraft.entity.player.PlayerEntity; import net.minecraft.nbt.NbtCompound; import skylands.logic.Skylands; -import skylands.util.Worlds; +import skylands.util.SkylandsWorlds; import java.util.ArrayList; import java.util.UUID; @@ -64,7 +64,7 @@ public void writeToNbt(NbtCompound tag) { } tag.put("islands", islandsNbt); - Worlds.getIsland(player.getWorld()).ifPresent(island -> { + SkylandsWorlds.getIsland(player.getWorld()).ifPresent(island -> { tag.putString("lastIsland", island.owner.uuid.toString()); }); } diff --git a/src/main/java/skylands/event/BlockBreakEvent.java b/src/main/java/skylands/event/BlockBreakEvent.java index 9947983..a173c11 100644 --- a/src/main/java/skylands/event/BlockBreakEvent.java +++ b/src/main/java/skylands/event/BlockBreakEvent.java @@ -6,7 +6,7 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import skylands.logic.Skylands; -import skylands.util.Texts; +import skylands.util.SkylandsTexts; import skylands.util.WorldProtection; @SuppressWarnings("unused") @@ -14,12 +14,12 @@ public class BlockBreakEvent { public static boolean onBreak(World world, PlayerEntity player, BlockPos pos, BlockState state) { if(!WorldProtection.canModify(world, player)) { - player.sendMessage(Texts.prefixed("message.skylands.world_protection.block_break"), true); + player.sendMessage(SkylandsTexts.prefixed("message.skylands.world_protection.block_break"), true); return false; } if(Skylands.config.rightClickHarvestEnabled && state.getBlock() instanceof CropBlock crop && crop.isMature(state)) { - player.sendMessage(Texts.prefixed("message.skylands.right_click_harvest.tip"), true); + player.sendMessage(SkylandsTexts.prefixed("message.skylands.right_click_harvest.tip"), true); } return true; diff --git a/src/main/java/skylands/event/PlayerConnectEvent.java b/src/main/java/skylands/event/PlayerConnectEvent.java index 48cd80b..d37511a 100644 --- a/src/main/java/skylands/event/PlayerConnectEvent.java +++ b/src/main/java/skylands/event/PlayerConnectEvent.java @@ -5,9 +5,9 @@ import net.minecraft.world.World; import skylands.logic.Member; import skylands.logic.Skylands; -import skylands.util.Texts; +import skylands.util.SkylandsTexts; import skylands.util.UpdateChecker; -import skylands.util.Worlds; +import skylands.util.SkylandsWorlds; import java.util.Set; @@ -40,10 +40,10 @@ public static void onJoin(MinecraftServer server, ServerPlayerEntity player) { } }); - Worlds.getIsland(player.getWorld()).ifPresent(island -> { + SkylandsWorlds.getIsland(player.getWorld()).ifPresent(island -> { if(!island.isMember(player) && island.isBanned(player)) { - player.sendMessage(Texts.prefixed("message.skylands.ban_player.ban", map -> map.put("%owner%", island.owner.name))); - player.sendMessage(Texts.prefixed("message.skylands.hub_visit")); + player.sendMessage(SkylandsTexts.prefixed("message.skylands.ban_player.ban", map -> map.put("%owner%", island.owner.name))); + player.sendMessage(SkylandsTexts.prefixed("message.skylands.hub_visit")); var pos = Skylands.instance.hub.pos; player.teleport(server.getOverworld(), pos.getX(), pos.getY(), pos.getZ(), Set.of(), 0, 0); } diff --git a/src/main/java/skylands/event/UseBlockEvent.java b/src/main/java/skylands/event/UseBlockEvent.java index c62d7c0..e390650 100644 --- a/src/main/java/skylands/event/UseBlockEvent.java +++ b/src/main/java/skylands/event/UseBlockEvent.java @@ -13,7 +13,7 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import skylands.logic.Skylands; -import skylands.util.Texts; +import skylands.util.SkylandsTexts; import skylands.util.WorldProtection; public class UseBlockEvent { @@ -45,7 +45,7 @@ public static ActionResult onBlockUse(PlayerEntity player, World world, Hand han return ActionResult.SUCCESS; } else { - player.sendMessage(Texts.prefixed("message.skylands.world_protection.harvest"), true); + player.sendMessage(SkylandsTexts.prefixed("message.skylands.world_protection.harvest"), true); return ActionResult.PASS; } diff --git a/src/main/java/skylands/logic/Invites.java b/src/main/java/skylands/logic/Invites.java index 4eef808..a8021fe 100644 --- a/src/main/java/skylands/logic/Invites.java +++ b/src/main/java/skylands/logic/Invites.java @@ -2,7 +2,7 @@ import net.minecraft.entity.player.PlayerEntity; import net.minecraft.server.MinecraftServer; -import skylands.util.Texts; +import skylands.util.SkylandsTexts; import java.util.ArrayList; import java.util.Optional; @@ -58,7 +58,7 @@ public void accept(PlayerEntity player) { island.members.add(new Member(player)); } else { - player.sendMessage(Texts.prefixed("message.skylands.accept.no_island")); + player.sendMessage(SkylandsTexts.prefixed("message.skylands.accept.no_island")); } } } diff --git a/src/main/java/skylands/logic/Island.java b/src/main/java/skylands/logic/Island.java index ade3ceb..0b26f6b 100644 --- a/src/main/java/skylands/logic/Island.java +++ b/src/main/java/skylands/logic/Island.java @@ -24,7 +24,7 @@ import org.apache.commons.io.FileUtils; import skylands.SkylandsMod; import skylands.api.SkylandsAPI; -import skylands.util.Texts; +import skylands.util.SkylandsTexts; import xyz.nucleoid.fantasy.Fantasy; import xyz.nucleoid.fantasy.RuntimeWorldConfig; import xyz.nucleoid.fantasy.RuntimeWorldHandle; @@ -232,6 +232,11 @@ public RuntimeWorldHandle getNetherHandler() { return this.fantasy.getOrOpenPersistentWorld(new Identifier("nether", this.owner.uuid.toString()), this.netherConfig); } + public void unload() { + getHandler().unload(); + if(hasNether) getNetherHandler().unload(); + } + void copyNetherTemplate() { try { File netherTemplate = server.getFile("nether_template"); @@ -289,7 +294,7 @@ public void visit(PlayerEntity visitor, Vec3d pos, float yaw, float pitch) { if(!isMember(visitor)) { this.getOwner().ifPresent(owner -> { if(!visitor.getUuid().equals(owner.getUuid())) { - owner.sendMessage(Texts.prefixed("message.skylands.island_visit.visit", map -> map.put("%visitor%", visitor.getName().getString()))); + owner.sendMessage(SkylandsTexts.prefixed("message.skylands.island_visit.visit", map -> map.put("%visitor%", visitor.getName().getString()))); } }); } diff --git a/src/main/java/skylands/mixin/block/EndPortalBlockMixin.java b/src/main/java/skylands/mixin/block/EndPortalBlockMixin.java index 6369945..df1812c 100644 --- a/src/main/java/skylands/mixin/block/EndPortalBlockMixin.java +++ b/src/main/java/skylands/mixin/block/EndPortalBlockMixin.java @@ -12,7 +12,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.LocalCapture; import skylands.logic.Island; -import skylands.util.Worlds; +import skylands.util.SkylandsWorlds; import java.util.Optional; @@ -22,11 +22,11 @@ public class EndPortalBlockMixin { @Inject(method = "onEntityCollision", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;moveToWorld(Lnet/minecraft/server/world/ServerWorld;)Lnet/minecraft/entity/Entity;"), locals = LocalCapture.CAPTURE_FAILHARD, cancellable = true) public void resourceKey(BlockState state, World world, BlockPos pos, Entity entity, CallbackInfo ci) { - if (Worlds.isIsland(world)) { - Optional island = Worlds.getIsland(world); + if (SkylandsWorlds.isIsland(world)) { + Optional island = SkylandsWorlds.getIsland(world); if (island.isPresent()) { ServerWorld targetWorld; - if (Worlds.isEnd(world.getRegistryKey())) { + if (SkylandsWorlds.isEnd(world.getRegistryKey())) { targetWorld = island.get().getWorld(); } else { targetWorld = island.get().getEnd(); diff --git a/src/main/java/skylands/mixin/block/entity/EndGatewayBlockEntityMixin.java b/src/main/java/skylands/mixin/block/entity/EndGatewayBlockEntityMixin.java index a912473..13b2c2f 100644 --- a/src/main/java/skylands/mixin/block/entity/EndGatewayBlockEntityMixin.java +++ b/src/main/java/skylands/mixin/block/entity/EndGatewayBlockEntityMixin.java @@ -6,14 +6,14 @@ import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; -import skylands.util.Worlds; +import skylands.util.SkylandsWorlds; @Mixin(EndGatewayBlockEntity.class) public class EndGatewayBlockEntityMixin { @Redirect(method = "tryTeleportingEntity", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;getRegistryKey()Lnet/minecraft/registry/RegistryKey;")) private static RegistryKey tryTeleportingEntity_redirectRegistryKey(World instance) { - return Worlds.redirect(instance.getRegistryKey()); + return SkylandsWorlds.redirect(instance.getRegistryKey()); } } diff --git a/src/main/java/skylands/mixin/entity/EntityMixin.java b/src/main/java/skylands/mixin/entity/EntityMixin.java index aabcc56..e9520dd 100644 --- a/src/main/java/skylands/mixin/entity/EntityMixin.java +++ b/src/main/java/skylands/mixin/entity/EntityMixin.java @@ -10,7 +10,7 @@ import org.spongepowered.asm.mixin.injection.ModifyVariable; import org.spongepowered.asm.mixin.injection.Redirect; import skylands.logic.Island; -import skylands.util.Worlds; +import skylands.util.SkylandsWorlds; import java.util.Optional; @@ -18,18 +18,18 @@ public abstract class EntityMixin { @Shadow - public World world; + private World world; @ModifyVariable(method = "tickPortal", at = @At("STORE"), ordinal = 0) public RegistryKey tickPortal_modifyRegistryKey(RegistryKey instance) { - if (Worlds.isIsland(world) && Worlds.isOverworld(world.getRegistryKey())) { - Optional island = Worlds.getIsland(world); + if (SkylandsWorlds.isIsland(world) && SkylandsWorlds.isOverworld(world.getRegistryKey())) { + Optional island = SkylandsWorlds.getIsland(world); if (island.isPresent()) { return island.get().getNether().getRegistryKey(); } } - if (Worlds.isIsland(world) && Worlds.isNether(world.getRegistryKey())) { - Optional island = Worlds.getIsland(world); + if (SkylandsWorlds.isIsland(world) && SkylandsWorlds.isNether(world.getRegistryKey())) { + Optional island = SkylandsWorlds.getIsland(world); if (island.isPresent()) { return island.get().getWorld().getRegistryKey(); } @@ -39,18 +39,18 @@ public RegistryKey tickPortal_modifyRegistryKey(RegistryKey instan @Redirect(method = "getTeleportTarget", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/world/ServerWorld;getRegistryKey()Lnet/minecraft/registry/RegistryKey;")) public RegistryKey getTeleportTarget_redirectRegistryKey0(ServerWorld instance) { - return Worlds.redirect(instance.getRegistryKey()); + return SkylandsWorlds.redirect(instance.getRegistryKey()); } @Redirect(method = "getTeleportTarget", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;getRegistryKey()Lnet/minecraft/registry/RegistryKey;")) public RegistryKey getTeleportTarget_redirectRegistryKey(World instance) { - return Worlds.redirect(instance.getRegistryKey()); + return SkylandsWorlds.redirect(instance.getRegistryKey()); } @Redirect(method = "moveToWorld", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/world/ServerWorld;getRegistryKey()Lnet/minecraft/registry/RegistryKey;", ordinal = 0)) public RegistryKey moveToWorld_redirectRegistryKey(ServerWorld instance) { - return Worlds.redirect(instance.getRegistryKey()); + return SkylandsWorlds.redirect(instance.getRegistryKey()); } } diff --git a/src/main/java/skylands/mixin/entity/ServerPlayerEntityMixin.java b/src/main/java/skylands/mixin/entity/ServerPlayerEntityMixin.java index 0e5425d..5cd6077 100644 --- a/src/main/java/skylands/mixin/entity/ServerPlayerEntityMixin.java +++ b/src/main/java/skylands/mixin/entity/ServerPlayerEntityMixin.java @@ -8,19 +8,23 @@ import net.minecraft.util.math.BlockPos; 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.Redirect; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import skylands.logic.Skylands; import skylands.util.WorldProtection; -import skylands.util.Worlds; +import skylands.util.SkylandsWorlds; import java.util.Set; @Mixin(ServerPlayerEntity.class) public abstract class ServerPlayerEntityMixin extends PlayerEntity { + @Shadow + public abstract ServerWorld getServerWorld(); + public ServerPlayerEntityMixin(World world, BlockPos pos, float yaw, GameProfile gameProfile) { super(world, pos, yaw, gameProfile); } @@ -28,10 +32,11 @@ public ServerPlayerEntityMixin(World world, BlockPos pos, float yaw, GameProfile @Inject(method = "tick", at = @At("TAIL")) void tick(CallbackInfo ci) { ServerPlayerEntity player = ServerPlayerEntity.class.cast(this); + ServerWorld world = getServerWorld(); if(!WorldProtection.canModify(world, player)) { if(player.getPos().getY() < world.getDimension().minY() - 10) { - Worlds.getIsland(world).ifPresentOrElse(island -> { + SkylandsWorlds.getIsland(world).ifPresentOrElse(island -> { var pos = island.spawnPos; player.teleport(island.getWorld(), pos.getX(), pos.getY(), pos.getZ(), Set.of(), 0, 0); }, () -> { @@ -43,17 +48,17 @@ void tick(CallbackInfo ci) { @Redirect(method = "moveToWorld", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/world/ServerWorld;getRegistryKey()Lnet/minecraft/registry/RegistryKey;")) public RegistryKey moveToWorld_redirectRegistryKey(ServerWorld instance) { - return Worlds.redirect(instance.getRegistryKey()); + return SkylandsWorlds.redirect(instance.getRegistryKey()); } @Redirect(method = "getTeleportTarget", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/world/ServerWorld;getRegistryKey()Lnet/minecraft/registry/RegistryKey;")) public RegistryKey getTeleportTarget_redirectRegistryKey(ServerWorld instance) { - return Worlds.redirect(instance.getRegistryKey()); + return SkylandsWorlds.redirect(instance.getRegistryKey()); } @Redirect(method = "worldChanged", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/world/ServerWorld;getRegistryKey()Lnet/minecraft/registry/RegistryKey;")) public RegistryKey worldChanged_redirectRegistryKey(ServerWorld instance) { - return Worlds.redirect(instance.getRegistryKey()); + return SkylandsWorlds.redirect(instance.getRegistryKey()); } } diff --git a/src/main/java/skylands/mixin/server/PlayerManagerMixin.java b/src/main/java/skylands/mixin/server/PlayerManagerMixin.java index 8538bd8..0ff6efb 100644 --- a/src/main/java/skylands/mixin/server/PlayerManagerMixin.java +++ b/src/main/java/skylands/mixin/server/PlayerManagerMixin.java @@ -10,7 +10,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import skylands.logic.Island; import skylands.logic.Skylands; -import skylands.util.Texts; +import skylands.util.SkylandsTexts; @Mixin(PlayerManager.class) public class PlayerManagerMixin { @@ -23,7 +23,7 @@ void onPlayerConnect(ClientConnection connection, ServerPlayerEntity player, Cal if(Skylands.config.teleportAfterIslandCreation) { island.visitAsMember(player); } - player.sendMessage(Texts.prefixed("message.skylands.island_create.success")); + player.sendMessage(SkylandsTexts.prefixed("message.skylands.island_create.success")); } } } diff --git a/src/main/java/skylands/mixin/world/ServerWorldMixin.java b/src/main/java/skylands/mixin/world/ServerWorldMixin.java index 45fb06c..97e1f50 100644 --- a/src/main/java/skylands/mixin/world/ServerWorldMixin.java +++ b/src/main/java/skylands/mixin/world/ServerWorldMixin.java @@ -12,6 +12,7 @@ import net.minecraft.server.world.ServerChunkManager; import net.minecraft.server.world.ServerEntityManager; import net.minecraft.server.world.ServerWorld; +import net.minecraft.util.math.random.RandomSequencesState; import net.minecraft.util.profiler.Profiler; import net.minecraft.village.ZombieSiegeManager; import net.minecraft.world.MutableWorldProperties; @@ -55,7 +56,7 @@ protected ServerWorldMixin(MutableWorldProperties properties, RegistryKey } @Inject(method = "", at = @At("TAIL")) - void init(MinecraftServer server, Executor workerExecutor, LevelStorage.Session session, ServerWorldProperties properties, RegistryKey worldKey, DimensionOptions dimensionOptions, WorldGenerationProgressListener worldGenerationProgressListener, boolean debugWorld, long seed, List spawners, boolean shouldTickTime, CallbackInfo ci) { + void init(MinecraftServer server, Executor workerExecutor, LevelStorage.Session session, ServerWorldProperties properties, RegistryKey worldKey, DimensionOptions dimensionOptions, WorldGenerationProgressListener worldGenerationProgressListener, boolean debugWorld, long seed, List spawners, boolean shouldTickTime, RandomSequencesState randomSequencesState, CallbackInfo ci) { if(worldKey.getValue().getNamespace().equals(SkylandsMod.MOD_ID)) { this.spawners = ImmutableList.of(new PhantomSpawner(), new PatrolSpawner(), new CatSpawner(), new ZombieSiegeManager(), new WanderingTraderManager(properties)); diff --git a/src/main/java/skylands/mixin/world/protection/ArmorStandMixin.java b/src/main/java/skylands/mixin/world/protection/ArmorStandMixin.java index d3d20d1..458eb44 100644 --- a/src/main/java/skylands/mixin/world/protection/ArmorStandMixin.java +++ b/src/main/java/skylands/mixin/world/protection/ArmorStandMixin.java @@ -13,7 +13,7 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import skylands.util.Texts; +import skylands.util.SkylandsTexts; import skylands.util.WorldProtection; @Mixin(ArmorStandEntity.class) @@ -25,9 +25,10 @@ protected ArmorStandMixin(EntityType entityType, World w @Inject(method = "damage", at = @At("HEAD"), cancellable = true) void damage(DamageSource source, float amount, CallbackInfoReturnable cir) { + World world = getWorld(); if(!world.isClient && source.getAttacker() instanceof PlayerEntity attacker) { if(!WorldProtection.canModify(world, attacker)) { - attacker.sendMessage(Texts.prefixed("message.skylands.world_protection.entity_hurt"), true); + attacker.sendMessage(SkylandsTexts.prefixed("message.skylands.world_protection.entity_hurt"), true); cir.setReturnValue(false); } } @@ -35,9 +36,9 @@ void damage(DamageSource source, float amount, CallbackInfoReturnable c @Inject(method = "interactAt", at = @At("HEAD"), cancellable = true) void interactAt(PlayerEntity player, Vec3d hitPos, Hand hand, CallbackInfoReturnable cir) { - if(!player.world.isClient) { - if(!WorldProtection.canModify(player.world, player)) { - player.sendMessage(Texts.prefixed("message.skylands.world_protection.armor_stand_use"), true); + if(!player.getWorld().isClient) { + if(!WorldProtection.canModify(player.getWorld(), player)) { + player.sendMessage(SkylandsTexts.prefixed("message.skylands.world_protection.armor_stand_use"), true); cir.setReturnValue(ActionResult.FAIL); } } diff --git a/src/main/java/skylands/mixin/world/protection/AxeItemMixin.java b/src/main/java/skylands/mixin/world/protection/AxeItemMixin.java index b5b3c68..bb8aa99 100644 --- a/src/main/java/skylands/mixin/world/protection/AxeItemMixin.java +++ b/src/main/java/skylands/mixin/world/protection/AxeItemMixin.java @@ -9,7 +9,7 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import skylands.util.Texts; +import skylands.util.SkylandsTexts; import skylands.util.WorldProtection; @Mixin(AxeItem.class) @@ -21,7 +21,7 @@ void useOnBlock(ItemUsageContext context, CallbackInfoReturnable c PlayerEntity player = context.getPlayer(); if(!world.isClient && player != null) { if(!WorldProtection.canModify(world, player)) { - player.sendMessage(Texts.prefixed("message.skylands.world_protection.axe_use"), true); + player.sendMessage(SkylandsTexts.prefixed("message.skylands.world_protection.axe_use"), true); cir.setReturnValue(ActionResult.FAIL); } } diff --git a/src/main/java/skylands/mixin/world/protection/BarrelBlockMixin.java b/src/main/java/skylands/mixin/world/protection/BarrelBlockMixin.java index cc817b9..cf643f7 100644 --- a/src/main/java/skylands/mixin/world/protection/BarrelBlockMixin.java +++ b/src/main/java/skylands/mixin/world/protection/BarrelBlockMixin.java @@ -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.CallbackInfoReturnable; -import skylands.util.Texts; +import skylands.util.SkylandsTexts; import skylands.util.WorldProtection; @Mixin(BarrelBlock.class) @@ -22,7 +22,7 @@ public abstract class BarrelBlockMixin { void onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit, CallbackInfoReturnable cir) { if(!world.isClient) { if(!WorldProtection.canModify(world, player)) { - player.sendMessage(Texts.prefixed("message.skylands.world_protection.barrel_open"), true); + player.sendMessage(SkylandsTexts.prefixed("message.skylands.world_protection.barrel_open"), true); cir.setReturnValue(ActionResult.FAIL); } } diff --git a/src/main/java/skylands/mixin/world/protection/BlockItemMixin.java b/src/main/java/skylands/mixin/world/protection/BlockItemMixin.java index 2e51875..9c4b034 100644 --- a/src/main/java/skylands/mixin/world/protection/BlockItemMixin.java +++ b/src/main/java/skylands/mixin/world/protection/BlockItemMixin.java @@ -10,7 +10,7 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import skylands.util.Texts; +import skylands.util.SkylandsTexts; import skylands.util.WorldProtection; @Mixin(BlockItem.class) @@ -26,7 +26,7 @@ void useOnBlock(ItemUsageContext context, CallbackInfoReturnable c PlayerEntity player = context.getPlayer(); if(!world.isClient && player != null) { if(!WorldProtection.canModify(world, player)) { - player.sendMessage(Texts.prefixed("message.skylands.world_protection.block_place"), true); + player.sendMessage(SkylandsTexts.prefixed("message.skylands.world_protection.block_place"), true); cir.setReturnValue(ActionResult.FAIL); } } diff --git a/src/main/java/skylands/mixin/world/protection/BoatMixin.java b/src/main/java/skylands/mixin/world/protection/BoatMixin.java index c14a0cd..ec6d29f 100644 --- a/src/main/java/skylands/mixin/world/protection/BoatMixin.java +++ b/src/main/java/skylands/mixin/world/protection/BoatMixin.java @@ -10,7 +10,7 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import skylands.util.Texts; +import skylands.util.SkylandsTexts; import skylands.util.WorldProtection; @Mixin(BoatEntity.class) @@ -22,9 +22,10 @@ public BoatMixin(EntityType type, World world) { @Inject(method = "damage", at = @At("HEAD"), cancellable = true) void damage(DamageSource source, float amount, CallbackInfoReturnable cir) { + World world = getWorld(); if(!world.isClient && source.getAttacker() instanceof PlayerEntity attacker) { if(!WorldProtection.canModify(world, attacker)) { - attacker.sendMessage(Texts.prefixed("message.skylands.world_protection.entity_hurt"), true); + attacker.sendMessage(SkylandsTexts.prefixed("message.skylands.world_protection.entity_hurt"), true); cir.setReturnValue(false); } } diff --git a/src/main/java/skylands/mixin/world/protection/BoneMealItemMixin.java b/src/main/java/skylands/mixin/world/protection/BoneMealItemMixin.java index 97f353e..19f99d3 100644 --- a/src/main/java/skylands/mixin/world/protection/BoneMealItemMixin.java +++ b/src/main/java/skylands/mixin/world/protection/BoneMealItemMixin.java @@ -9,7 +9,7 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import skylands.util.Texts; +import skylands.util.SkylandsTexts; import skylands.util.WorldProtection; @Mixin(BoneMealItem.class) @@ -21,7 +21,7 @@ void useOnBlock(ItemUsageContext context, CallbackInfoReturnable c PlayerEntity player = context.getPlayer(); if(!world.isClient && player != null) { if(!WorldProtection.canModify(world, player)) { - player.sendMessage(Texts.prefixed("message.skylands.world_protection.bone_meal_use"), true); + player.sendMessage(SkylandsTexts.prefixed("message.skylands.world_protection.bone_meal_use"), true); cir.setReturnValue(ActionResult.FAIL); } } diff --git a/src/main/java/skylands/mixin/world/protection/BucketItemMixin.java b/src/main/java/skylands/mixin/world/protection/BucketItemMixin.java index 24a1393..11ed23c 100644 --- a/src/main/java/skylands/mixin/world/protection/BucketItemMixin.java +++ b/src/main/java/skylands/mixin/world/protection/BucketItemMixin.java @@ -10,7 +10,7 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import skylands.util.Texts; +import skylands.util.SkylandsTexts; import skylands.util.WorldProtection; @Mixin(BucketItem.class) @@ -20,7 +20,7 @@ public abstract class BucketItemMixin { void use(World world, PlayerEntity user, Hand hand, CallbackInfoReturnable> cir) { if(!world.isClient) { if(!WorldProtection.canModify(world, user)) { - user.sendMessage(Texts.prefixed("message.skylands.world_protection.bucket_use"), true); + user.sendMessage(SkylandsTexts.prefixed("message.skylands.world_protection.bucket_use"), true); cir.setReturnValue(TypedActionResult.fail(user.getStackInHand(hand))); } } diff --git a/src/main/java/skylands/mixin/world/protection/ButtonMixin.java b/src/main/java/skylands/mixin/world/protection/ButtonMixin.java index b03369e..8a71a70 100644 --- a/src/main/java/skylands/mixin/world/protection/ButtonMixin.java +++ b/src/main/java/skylands/mixin/world/protection/ButtonMixin.java @@ -13,7 +13,7 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import skylands.util.Texts; +import skylands.util.SkylandsTexts; import skylands.util.WorldProtection; @Mixin(ButtonBlock.class) @@ -27,7 +27,7 @@ public ButtonMixin(Settings settings) { void onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit, CallbackInfoReturnable cir) { if(!world.isClient) { if(!WorldProtection.canModify(world, player)) { - player.sendMessage(Texts.prefixed("message.skylands.world_protection.redstone"), true); + player.sendMessage(SkylandsTexts.prefixed("message.skylands.world_protection.redstone"), true); cir.setReturnValue(ActionResult.FAIL); } } diff --git a/src/main/java/skylands/mixin/world/protection/ChestBlockMixin.java b/src/main/java/skylands/mixin/world/protection/ChestBlockMixin.java index 90669df..8438c65 100644 --- a/src/main/java/skylands/mixin/world/protection/ChestBlockMixin.java +++ b/src/main/java/skylands/mixin/world/protection/ChestBlockMixin.java @@ -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.CallbackInfoReturnable; -import skylands.util.Texts; +import skylands.util.SkylandsTexts; import skylands.util.WorldProtection; @Mixin(ChestBlock.class) @@ -22,7 +22,7 @@ public abstract class ChestBlockMixin { void onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit, CallbackInfoReturnable cir) { if(!world.isClient) { if(!WorldProtection.canModify(world, player)) { - player.sendMessage(Texts.prefixed("message.skylands.world_protection.chest_open"), true); + player.sendMessage(SkylandsTexts.prefixed("message.skylands.world_protection.chest_open"), true); cir.setReturnValue(ActionResult.FAIL); } } diff --git a/src/main/java/skylands/mixin/world/protection/ChestBoatMixin.java b/src/main/java/skylands/mixin/world/protection/ChestBoatMixin.java index ba5727b..28308bf 100644 --- a/src/main/java/skylands/mixin/world/protection/ChestBoatMixin.java +++ b/src/main/java/skylands/mixin/world/protection/ChestBoatMixin.java @@ -11,7 +11,7 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import skylands.util.Texts; +import skylands.util.SkylandsTexts; import skylands.util.WorldProtection; @Mixin(ChestBoatEntity.class) @@ -23,9 +23,9 @@ public ChestBoatMixin(EntityType entityType, World world) @Inject(method = "interact", at = @At("HEAD"), cancellable = true) void interact(PlayerEntity player, Hand hand, CallbackInfoReturnable cir) { - if(!player.world.isClient) { - if(!WorldProtection.canModify(player.world, player)) { - player.sendMessage(Texts.prefixed("message.skylands.world_protection.boat_open"), true); + if(!player.getWorld().isClient) { + if(!WorldProtection.canModify(player.getWorld(), player)) { + player.sendMessage(SkylandsTexts.prefixed("message.skylands.world_protection.boat_open"), true); cir.setReturnValue(ActionResult.FAIL); } } diff --git a/src/main/java/skylands/mixin/world/protection/ComparatorMixin.java b/src/main/java/skylands/mixin/world/protection/ComparatorMixin.java index 09e9b96..7048916 100644 --- a/src/main/java/skylands/mixin/world/protection/ComparatorMixin.java +++ b/src/main/java/skylands/mixin/world/protection/ComparatorMixin.java @@ -13,7 +13,7 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import skylands.util.Texts; +import skylands.util.SkylandsTexts; import skylands.util.WorldProtection; @Mixin(ComparatorBlock.class) @@ -27,7 +27,7 @@ protected ComparatorMixin(Settings settings) { void onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit, CallbackInfoReturnable cir) { if(!world.isClient) { if(!WorldProtection.canModify(world, player)) { - player.sendMessage(Texts.prefixed("message.skylands.world_protection.redstone"), true); + player.sendMessage(SkylandsTexts.prefixed("message.skylands.world_protection.redstone"), true); cir.setReturnValue(ActionResult.FAIL); } } diff --git a/src/main/java/skylands/mixin/world/protection/DecorationEntityMixin.java b/src/main/java/skylands/mixin/world/protection/DecorationEntityMixin.java index 358bd0f..7c77bb7 100644 --- a/src/main/java/skylands/mixin/world/protection/DecorationEntityMixin.java +++ b/src/main/java/skylands/mixin/world/protection/DecorationEntityMixin.java @@ -10,7 +10,7 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import skylands.util.Texts; +import skylands.util.SkylandsTexts; import skylands.util.WorldProtection; @Mixin(AbstractDecorationEntity.class) @@ -22,9 +22,10 @@ public DecorationEntityMixin(EntityType type, World world) { @Inject(method = "damage", at = @At("HEAD"), cancellable = true) void damage(DamageSource source, float amount, CallbackInfoReturnable cir) { + World world = getWorld(); if(!world.isClient && source.getAttacker() instanceof PlayerEntity attacker) { if(!WorldProtection.canModify(world, attacker)) { - attacker.sendMessage(Texts.prefixed("message.skylands.world_protection.entity_hurt"), true); + attacker.sendMessage(SkylandsTexts.prefixed("message.skylands.world_protection.entity_hurt"), true); cir.setReturnValue(false); } } diff --git a/src/main/java/skylands/mixin/world/protection/DecorationItemMixin.java b/src/main/java/skylands/mixin/world/protection/DecorationItemMixin.java index 5141236..bebcaf3 100644 --- a/src/main/java/skylands/mixin/world/protection/DecorationItemMixin.java +++ b/src/main/java/skylands/mixin/world/protection/DecorationItemMixin.java @@ -10,7 +10,7 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import skylands.util.Texts; +import skylands.util.SkylandsTexts; import skylands.util.WorldProtection; @Mixin(DecorationItem.class) @@ -26,7 +26,7 @@ void useOnBlock(ItemUsageContext context, CallbackInfoReturnable c PlayerEntity player = context.getPlayer(); if(!world.isClient && player != null) { if(!WorldProtection.canModify(world, player)) { - player.sendMessage(Texts.prefixed("message.skylands.world_protection.item_place"), true); + player.sendMessage(SkylandsTexts.prefixed("message.skylands.world_protection.item_place"), true); cir.setReturnValue(ActionResult.FAIL); } } diff --git a/src/main/java/skylands/mixin/world/protection/DoorBlockMixin.java b/src/main/java/skylands/mixin/world/protection/DoorBlockMixin.java index 55ee3cc..a16b19a 100644 --- a/src/main/java/skylands/mixin/world/protection/DoorBlockMixin.java +++ b/src/main/java/skylands/mixin/world/protection/DoorBlockMixin.java @@ -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.CallbackInfoReturnable; -import skylands.util.Texts; +import skylands.util.SkylandsTexts; import skylands.util.WorldProtection; @Mixin(DoorBlock.class) @@ -22,7 +22,7 @@ public abstract class DoorBlockMixin { void onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit, CallbackInfoReturnable cir) { if(!world.isClient) { if(!WorldProtection.canModify(world, player)) { - player.sendMessage(Texts.prefixed("message.skylands.world_protection.door_open"), true); + player.sendMessage(SkylandsTexts.prefixed("message.skylands.world_protection.door_open"), true); cir.setReturnValue(ActionResult.FAIL); } } diff --git a/src/main/java/skylands/mixin/world/protection/FarmlandBlockMixin.java b/src/main/java/skylands/mixin/world/protection/FarmlandBlockMixin.java index 44ad6db..7993b68 100644 --- a/src/main/java/skylands/mixin/world/protection/FarmlandBlockMixin.java +++ b/src/main/java/skylands/mixin/world/protection/FarmlandBlockMixin.java @@ -10,7 +10,7 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import skylands.util.Texts; +import skylands.util.SkylandsTexts; import skylands.util.WorldProtection; @Mixin(FarmlandBlock.class) @@ -20,7 +20,7 @@ public abstract class FarmlandBlockMixin { void onLandedUpon(World world, BlockState state, BlockPos pos, Entity entity, float fallDistance, CallbackInfo ci) { if(!world.isClient && entity instanceof PlayerEntity player) { if(!WorldProtection.canModify(world, player)) { - player.sendMessage(Texts.prefixed("message.skylands.world_protection.farmland_spoil"), true); + player.sendMessage(SkylandsTexts.prefixed("message.skylands.world_protection.farmland_spoil"), true); ci.cancel(); } } diff --git a/src/main/java/skylands/mixin/world/protection/FenceGateBlockMixin.java b/src/main/java/skylands/mixin/world/protection/FenceGateBlockMixin.java index a266845..a57d97d 100644 --- a/src/main/java/skylands/mixin/world/protection/FenceGateBlockMixin.java +++ b/src/main/java/skylands/mixin/world/protection/FenceGateBlockMixin.java @@ -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.CallbackInfoReturnable; -import skylands.util.Texts; +import skylands.util.SkylandsTexts; import skylands.util.WorldProtection; @Mixin(FenceGateBlock.class) @@ -22,7 +22,7 @@ public abstract class FenceGateBlockMixin { void onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit, CallbackInfoReturnable cir) { if(!world.isClient) { if(!WorldProtection.canModify(world, player)) { - player.sendMessage(Texts.prefixed("message.skylands.world_protection.fence_gate_open"), true); + player.sendMessage(SkylandsTexts.prefixed("message.skylands.world_protection.fence_gate_open"), true); cir.setReturnValue(ActionResult.FAIL); } } diff --git a/src/main/java/skylands/mixin/world/protection/FlintAndSteelMixin.java b/src/main/java/skylands/mixin/world/protection/FlintAndSteelMixin.java index 4e9d665..a58b908 100644 --- a/src/main/java/skylands/mixin/world/protection/FlintAndSteelMixin.java +++ b/src/main/java/skylands/mixin/world/protection/FlintAndSteelMixin.java @@ -9,7 +9,7 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import skylands.util.Texts; +import skylands.util.SkylandsTexts; import skylands.util.WorldProtection; @Mixin(FlintAndSteelItem.class) @@ -21,7 +21,7 @@ void useOnBlock(ItemUsageContext context, CallbackInfoReturnable c PlayerEntity player = context.getPlayer(); if(!world.isClient && player != null) { if(!WorldProtection.canModify(world, player)) { - player.sendMessage(Texts.prefixed("message.skylands.world_protection.flint_and_steel_use"), true); + player.sendMessage(SkylandsTexts.prefixed("message.skylands.world_protection.flint_and_steel_use"), true); cir.setReturnValue(ActionResult.FAIL); } } diff --git a/src/main/java/skylands/mixin/world/protection/FlowerPotBlockMixin.java b/src/main/java/skylands/mixin/world/protection/FlowerPotBlockMixin.java index 162c2a0..cc420eb 100644 --- a/src/main/java/skylands/mixin/world/protection/FlowerPotBlockMixin.java +++ b/src/main/java/skylands/mixin/world/protection/FlowerPotBlockMixin.java @@ -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.CallbackInfoReturnable; -import skylands.util.Texts; +import skylands.util.SkylandsTexts; import skylands.util.WorldProtection; @Mixin(FlowerPotBlock.class) @@ -22,7 +22,7 @@ public abstract class FlowerPotBlockMixin { void onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit, CallbackInfoReturnable cir) { if(!world.isClient) { if(!WorldProtection.canModify(world, player)) { - player.sendMessage(Texts.prefixed("message.skylands.world_protection.flower_pot_use"), true); + player.sendMessage(SkylandsTexts.prefixed("message.skylands.world_protection.flower_pot_use"), true); cir.setReturnValue(ActionResult.FAIL); } } diff --git a/src/main/java/skylands/mixin/world/protection/FurnaceBlockMixin.java b/src/main/java/skylands/mixin/world/protection/FurnaceBlockMixin.java index a8ac460..770b042 100644 --- a/src/main/java/skylands/mixin/world/protection/FurnaceBlockMixin.java +++ b/src/main/java/skylands/mixin/world/protection/FurnaceBlockMixin.java @@ -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.CallbackInfoReturnable; -import skylands.util.Texts; +import skylands.util.SkylandsTexts; import skylands.util.WorldProtection; @Mixin(AbstractFurnaceBlock.class) @@ -22,7 +22,7 @@ public abstract class FurnaceBlockMixin { void onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit, CallbackInfoReturnable cir) { if(!world.isClient) { if(!WorldProtection.canModify(world, player)) { - player.sendMessage(Texts.prefixed("message.skylands.world_protection.furnace_open"), true); + player.sendMessage(SkylandsTexts.prefixed("message.skylands.world_protection.furnace_open"), true); cir.setReturnValue(ActionResult.FAIL); } } diff --git a/src/main/java/skylands/mixin/world/protection/HoeItemMixin.java b/src/main/java/skylands/mixin/world/protection/HoeItemMixin.java index 68f4813..6cb1205 100644 --- a/src/main/java/skylands/mixin/world/protection/HoeItemMixin.java +++ b/src/main/java/skylands/mixin/world/protection/HoeItemMixin.java @@ -9,7 +9,7 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import skylands.util.Texts; +import skylands.util.SkylandsTexts; import skylands.util.WorldProtection; @Mixin(HoeItem.class) @@ -21,7 +21,7 @@ void useOnBlock(ItemUsageContext context, CallbackInfoReturnable c PlayerEntity player = context.getPlayer(); if(!world.isClient && player != null) { if(!WorldProtection.canModify(world, player)) { - player.sendMessage(Texts.prefixed("message.skylands.world_protection.hoe_use"), true); + player.sendMessage(SkylandsTexts.prefixed("message.skylands.world_protection.hoe_use"), true); cir.setReturnValue(ActionResult.FAIL); } } diff --git a/src/main/java/skylands/mixin/world/protection/HopperBlockMixin.java b/src/main/java/skylands/mixin/world/protection/HopperBlockMixin.java index 6280fdd..ee568ef 100644 --- a/src/main/java/skylands/mixin/world/protection/HopperBlockMixin.java +++ b/src/main/java/skylands/mixin/world/protection/HopperBlockMixin.java @@ -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.CallbackInfoReturnable; -import skylands.util.Texts; +import skylands.util.SkylandsTexts; import skylands.util.WorldProtection; @Mixin(HopperBlock.class) @@ -22,7 +22,7 @@ public abstract class HopperBlockMixin { void onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit, CallbackInfoReturnable cir) { if(!world.isClient) { if(!WorldProtection.canModify(world, player)) { - player.sendMessage(Texts.prefixed("message.skylands.world_protection.hopper_open"), true); + player.sendMessage(SkylandsTexts.prefixed("message.skylands.world_protection.hopper_open"), true); cir.setReturnValue(ActionResult.FAIL); } } diff --git a/src/main/java/skylands/mixin/world/protection/ItemFrameEntityMixin.java b/src/main/java/skylands/mixin/world/protection/ItemFrameEntityMixin.java index fbf113d..266073b 100644 --- a/src/main/java/skylands/mixin/world/protection/ItemFrameEntityMixin.java +++ b/src/main/java/skylands/mixin/world/protection/ItemFrameEntityMixin.java @@ -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.CallbackInfoReturnable; -import skylands.util.Texts; +import skylands.util.SkylandsTexts; import skylands.util.WorldProtection; @Mixin(ItemFrameEntity.class) @@ -24,9 +24,10 @@ protected ItemFrameEntityMixin(EntityType en @Inject(method = "damage", at = @At("HEAD"), cancellable = true) void damage(DamageSource source, float amount, CallbackInfoReturnable cir) { + World world = getWorld(); if(!world.isClient && source.getAttacker() instanceof PlayerEntity attacker) { if(!WorldProtection.canModify(world, attacker)) { - attacker.sendMessage(Texts.prefixed("message.skylands.world_protection.entity_hurt"), true); + attacker.sendMessage(SkylandsTexts.prefixed("message.skylands.world_protection.entity_hurt"), true); cir.setReturnValue(false); } } @@ -34,9 +35,9 @@ void damage(DamageSource source, float amount, CallbackInfoReturnable c @Inject(method = "interact", at = @At("HEAD"), cancellable = true) void interact(PlayerEntity player, Hand hand, CallbackInfoReturnable cir) { - if(!player.world.isClient) { - if(!WorldProtection.canModify(world, player)) { - player.sendMessage(Texts.prefixed("message.skylands.world_protection.item_frame_use"), true); + if(!player.getWorld().isClient) { + if(!WorldProtection.canModify(player)) { + player.sendMessage(SkylandsTexts.prefixed("message.skylands.world_protection.item_frame_use"), true); cir.setReturnValue(ActionResult.FAIL); } } diff --git a/src/main/java/skylands/mixin/world/protection/LeverMixin.java b/src/main/java/skylands/mixin/world/protection/LeverMixin.java index ed58ec5..66fa5fc 100644 --- a/src/main/java/skylands/mixin/world/protection/LeverMixin.java +++ b/src/main/java/skylands/mixin/world/protection/LeverMixin.java @@ -13,7 +13,7 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import skylands.util.Texts; +import skylands.util.SkylandsTexts; import skylands.util.WorldProtection; @Mixin(LeverBlock.class) @@ -27,7 +27,7 @@ public LeverMixin(Settings settings) { void onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit, CallbackInfoReturnable cir) { if(!world.isClient) { if(!WorldProtection.canModify(world, player)) { - player.sendMessage(Texts.prefixed("message.skylands.world_protection.redstone"), true); + player.sendMessage(SkylandsTexts.prefixed("message.skylands.world_protection.redstone"), true); cir.setReturnValue(ActionResult.FAIL); } } diff --git a/src/main/java/skylands/mixin/world/protection/LivingEntityMixin.java b/src/main/java/skylands/mixin/world/protection/LivingEntityMixin.java index 5dbefe9..149595b 100644 --- a/src/main/java/skylands/mixin/world/protection/LivingEntityMixin.java +++ b/src/main/java/skylands/mixin/world/protection/LivingEntityMixin.java @@ -10,7 +10,7 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import skylands.util.Texts; +import skylands.util.SkylandsTexts; import skylands.util.WorldProtection; @Mixin(LivingEntity.class) @@ -23,17 +23,18 @@ public LivingEntityMixin(EntityType type, World world) { @Inject(method = "damage", at = @At("HEAD"), cancellable = true) void damage(DamageSource source, float amount, CallbackInfoReturnable cir) { LivingEntity self = LivingEntity.class.cast(this); + World world = getWorld(); if(!world.isClient && world.getServer() != null) { if(self instanceof PlayerEntity player) { if(!WorldProtection.canModify(world, player)) { - player.sendMessage(Texts.prefixed("message.skylands.world_protection.damage_take"), true); + player.sendMessage(SkylandsTexts.prefixed("message.skylands.world_protection.damage_take"), true); cir.setReturnValue(false); } } if(source.getAttacker() instanceof PlayerEntity attacker) { if(!WorldProtection.canModify(world, attacker)) { - attacker.sendMessage(Texts.prefixed("message.skylands.world_protection.entity_hurt"), true); + attacker.sendMessage(SkylandsTexts.prefixed("message.skylands.world_protection.entity_hurt"), true); cir.setReturnValue(false); } } diff --git a/src/main/java/skylands/mixin/world/protection/MinecartMixin.java b/src/main/java/skylands/mixin/world/protection/MinecartMixin.java index a96d2ff..477301e 100644 --- a/src/main/java/skylands/mixin/world/protection/MinecartMixin.java +++ b/src/main/java/skylands/mixin/world/protection/MinecartMixin.java @@ -10,7 +10,7 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import skylands.util.Texts; +import skylands.util.SkylandsTexts; import skylands.util.WorldProtection; @Mixin(AbstractMinecartEntity.class) @@ -22,9 +22,10 @@ public MinecartMixin(EntityType type, World world) { @Inject(method = "damage", at = @At("HEAD"), cancellable = true) void damage(DamageSource source, float amount, CallbackInfoReturnable cir) { + World world = getWorld(); if(!world.isClient && source.getAttacker() instanceof PlayerEntity attacker) { if(!WorldProtection.canModify(world, attacker)) { - attacker.sendMessage(Texts.prefixed("message.skylands.world_protection.entity_hurt"), true); + attacker.sendMessage(SkylandsTexts.prefixed("message.skylands.world_protection.entity_hurt"), true); cir.setReturnValue(false); } } diff --git a/src/main/java/skylands/mixin/world/protection/RedstoneWireMixin.java b/src/main/java/skylands/mixin/world/protection/RedstoneWireMixin.java index b4e0bc0..2af57bd 100644 --- a/src/main/java/skylands/mixin/world/protection/RedstoneWireMixin.java +++ b/src/main/java/skylands/mixin/world/protection/RedstoneWireMixin.java @@ -13,7 +13,7 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import skylands.util.Texts; +import skylands.util.SkylandsTexts; import skylands.util.WorldProtection; @Mixin(RedstoneWireBlock.class) @@ -27,7 +27,7 @@ public RedstoneWireMixin(Settings settings) { void onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit, CallbackInfoReturnable cir) { if(!world.isClient) { if(!WorldProtection.canModify(world, player)) { - player.sendMessage(Texts.prefixed("message.skylands.world_protection.redstone"), true); + player.sendMessage(SkylandsTexts.prefixed("message.skylands.world_protection.redstone"), true); cir.setReturnValue(ActionResult.FAIL); } } diff --git a/src/main/java/skylands/mixin/world/protection/RepeaterMixin.java b/src/main/java/skylands/mixin/world/protection/RepeaterMixin.java index 56c9196..c4811d3 100644 --- a/src/main/java/skylands/mixin/world/protection/RepeaterMixin.java +++ b/src/main/java/skylands/mixin/world/protection/RepeaterMixin.java @@ -13,7 +13,7 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import skylands.util.Texts; +import skylands.util.SkylandsTexts; import skylands.util.WorldProtection; @Mixin(RepeaterBlock.class) @@ -27,7 +27,7 @@ protected RepeaterMixin(Settings settings) { void onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit, CallbackInfoReturnable cir) { if(!world.isClient) { if(!WorldProtection.canModify(world, player)) { - player.sendMessage(Texts.prefixed("message.skylands.world_protection.redstone"), true); + player.sendMessage(SkylandsTexts.prefixed("message.skylands.world_protection.redstone"), true); cir.setReturnValue(ActionResult.FAIL); } } diff --git a/src/main/java/skylands/mixin/world/protection/ShovelItemMixin.java b/src/main/java/skylands/mixin/world/protection/ShovelItemMixin.java index bf12371..4938ec3 100644 --- a/src/main/java/skylands/mixin/world/protection/ShovelItemMixin.java +++ b/src/main/java/skylands/mixin/world/protection/ShovelItemMixin.java @@ -9,7 +9,7 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import skylands.util.Texts; +import skylands.util.SkylandsTexts; import skylands.util.WorldProtection; @Mixin(ShovelItem.class) @@ -21,7 +21,7 @@ void useOnBlock(ItemUsageContext context, CallbackInfoReturnable c PlayerEntity player = context.getPlayer(); if(!world.isClient && player != null) { if(!WorldProtection.canModify(world, player)) { - player.sendMessage(Texts.prefixed("message.skylands.world_protection.shovel_use"), true); + player.sendMessage(SkylandsTexts.prefixed("message.skylands.world_protection.shovel_use"), true); cir.setReturnValue(ActionResult.FAIL); } } diff --git a/src/main/java/skylands/mixin/world/protection/ShulkerBoxBlockMixin.java b/src/main/java/skylands/mixin/world/protection/ShulkerBoxBlockMixin.java index 4d560e5..da2455b 100644 --- a/src/main/java/skylands/mixin/world/protection/ShulkerBoxBlockMixin.java +++ b/src/main/java/skylands/mixin/world/protection/ShulkerBoxBlockMixin.java @@ -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.CallbackInfoReturnable; -import skylands.util.Texts; +import skylands.util.SkylandsTexts; import skylands.util.WorldProtection; @Mixin(ShulkerBoxBlock.class) @@ -22,7 +22,7 @@ public abstract class ShulkerBoxBlockMixin { void onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit, CallbackInfoReturnable cir) { if(!world.isClient) { if(!WorldProtection.canModify(world, player)) { - player.sendMessage(Texts.prefixed("message.skylands.world_protection.shulker_box_open"), true); + player.sendMessage(SkylandsTexts.prefixed("message.skylands.world_protection.shulker_box_open"), true); cir.setReturnValue(ActionResult.FAIL); } } diff --git a/src/main/java/skylands/mixin/world/protection/StorageMinecartMixin.java b/src/main/java/skylands/mixin/world/protection/StorageMinecartMixin.java index 58e798a..15ad890 100644 --- a/src/main/java/skylands/mixin/world/protection/StorageMinecartMixin.java +++ b/src/main/java/skylands/mixin/world/protection/StorageMinecartMixin.java @@ -8,7 +8,7 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import skylands.util.Texts; +import skylands.util.SkylandsTexts; import skylands.util.WorldProtection; @Mixin(StorageMinecartEntity.class) @@ -16,9 +16,9 @@ public abstract class StorageMinecartMixin { @Inject(method = "interact", at = @At("HEAD"), cancellable = true) void interact(PlayerEntity player, Hand hand, CallbackInfoReturnable cir) { - if(!player.world.isClient) { - if(!WorldProtection.canModify(player.world, player)) { - player.sendMessage(Texts.prefixed("message.skylands.world_protection.minecart_open"), true); + if(!player.getWorld().isClient) { + if(!WorldProtection.canModify(player)) { + player.sendMessage(SkylandsTexts.prefixed("message.skylands.world_protection.minecart_open"), true); cir.setReturnValue(ActionResult.FAIL); } } diff --git a/src/main/java/skylands/mixin/world/protection/VillagerEntityMixin.java b/src/main/java/skylands/mixin/world/protection/VillagerEntityMixin.java index c06eefc..6daaadb 100644 --- a/src/main/java/skylands/mixin/world/protection/VillagerEntityMixin.java +++ b/src/main/java/skylands/mixin/world/protection/VillagerEntityMixin.java @@ -8,7 +8,7 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import skylands.util.Texts; +import skylands.util.SkylandsTexts; import skylands.util.WorldProtection; @Mixin(VillagerEntity.class) @@ -16,9 +16,9 @@ public abstract class VillagerEntityMixin { @Inject(method = "interactMob", at = @At("HEAD"), cancellable = true) void interact(PlayerEntity player, Hand hand, CallbackInfoReturnable cir) { - if(!player.world.isClient) { - if(!WorldProtection.canModify(player.world, player)) { - player.sendMessage(Texts.prefixed("message.skylands.world_protection.villager_use"), true); + if(!player.getWorld().isClient) { + if(!WorldProtection.canModify(player)) { + player.sendMessage(SkylandsTexts.prefixed("message.skylands.world_protection.villager_use"), true); cir.setReturnValue(ActionResult.FAIL); } } diff --git a/src/main/java/skylands/util/Players.java b/src/main/java/skylands/util/Players.java deleted file mode 100644 index 79be1b2..0000000 --- a/src/main/java/skylands/util/Players.java +++ /dev/null @@ -1,18 +0,0 @@ -package skylands.util; - -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.server.MinecraftServer; -import skylands.logic.Skylands; - -import java.util.Optional; - -public class Players { - static MinecraftServer server = Skylands.instance.server; - - public static Optional get(String name) { - for(var player : server.getPlayerManager().getPlayerList()) { - if(player.getName().getString().equals(name)) return Optional.of(player); - } - return Optional.empty(); - } -} diff --git a/src/main/java/skylands/util/Texts.java b/src/main/java/skylands/util/SkylandsTexts.java similarity index 91% rename from src/main/java/skylands/util/Texts.java rename to src/main/java/skylands/util/SkylandsTexts.java index 3ec7d21..b362bf0 100644 --- a/src/main/java/skylands/util/Texts.java +++ b/src/main/java/skylands/util/SkylandsTexts.java @@ -11,15 +11,15 @@ import java.util.Map; import java.util.function.Consumer; -public class Texts { +public class SkylandsTexts { public static String prefixTranslationKey = "message.skylands.prefix"; public static void prefixed(CommandContext context, String key, Consumer> builder) { - context.getSource().sendFeedback(Texts.prefixed(key, builder), false); + context.getSource().sendFeedback(() -> SkylandsTexts.prefixed(key, builder), false); } public static void prefixed(PlayerEntity player, String key, Consumer> builder) { - player.sendMessage(Texts.prefixed(key, builder)); + player.sendMessage(SkylandsTexts.prefixed(key, builder)); } public static Text prefixed(String key, Consumer> builder) { diff --git a/src/main/java/skylands/util/Worlds.java b/src/main/java/skylands/util/SkylandsWorlds.java similarity index 98% rename from src/main/java/skylands/util/Worlds.java rename to src/main/java/skylands/util/SkylandsWorlds.java index a8bdca0..e842e91 100644 --- a/src/main/java/skylands/util/Worlds.java +++ b/src/main/java/skylands/util/SkylandsWorlds.java @@ -9,7 +9,7 @@ import java.util.Optional; import java.util.UUID; -public class Worlds { +public class SkylandsWorlds { public static boolean isIsland(World world) { return isIsland(world.getRegistryKey()); diff --git a/src/main/java/skylands/util/UpdateChecker.java b/src/main/java/skylands/util/UpdateChecker.java index e9ed4df..fa6d95d 100644 --- a/src/main/java/skylands/util/UpdateChecker.java +++ b/src/main/java/skylands/util/UpdateChecker.java @@ -48,7 +48,7 @@ static void check(ServerPlayerEntity player) { var remoteNum = Integer.parseInt(remote.replaceAll("\\.", "")); if(remoteNum > localNum) { - var text = Texts.prefixed("message.skylands.new_update", map -> { + var text = SkylandsTexts.prefixed("message.skylands.new_update", map -> { map.put("%local_version%", local); map.put("%remote_version%", remote); map.put("%changes%", getChanges(localNum)); diff --git a/src/main/java/skylands/util/WorldProtection.java b/src/main/java/skylands/util/WorldProtection.java index 61022e9..8ba2db2 100644 --- a/src/main/java/skylands/util/WorldProtection.java +++ b/src/main/java/skylands/util/WorldProtection.java @@ -8,7 +8,7 @@ public class WorldProtection { public static boolean canModify(World world, PlayerEntity player) { - var island = Worlds.getIsland(world); + var island = SkylandsWorlds.getIsland(world); if(Permissions.check(player, "skylands.world.protection.bypass", false)) { return true; @@ -23,4 +23,8 @@ public static boolean canModify(World world, PlayerEntity player) { } return true; } + + public static boolean canModify(PlayerEntity player) { + return canModify(player.getWorld(), player); + } } diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 35d86b5..b94e385 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -39,7 +39,7 @@ "depends": { "fabricloader": "*", "fabric": "*", - "minecraft": ">=1.19.4", + "minecraft": ">=1.20-rc.1 <1.21", "java": ">=17" } }