diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 92be39cf..4c439b3a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -107,20 +107,14 @@ jobs: pl3xmap | suggests | * luckperms | suggests | * plan-player-analytics | suggests | * - files-primary: target/HuskHomes-Fabric-1.20.1-*.jar - files-secondary: target/HuskHomes-Fabric-(1.19.4|1.19.2)-*.jar + files-primary: target/HuskHomes-Fabric-*.jar name: HuskHomes (Fabric) v${{ env.version_name }} version: ${{ env.version_name }} version-type: alpha - changelog: | - > ⚠ Remember to download the correct JAR file for your version of Minecraft! - - ${{ github.event.head_commit.message }} + changelog: ${{ github.event.head_commit.message }} loaders: | fabric game-versions: | - 1.19.2 - 1.19.4 1.20.1 java: 17 - name: 'Upload GitHub Artifacts 📦' diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9e2ef964..a625efe6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -95,20 +95,14 @@ jobs: pl3xmap | suggests | * luckperms | suggests | * plan-player-analytics | suggests | * - files-primary: target/HuskHomes-Fabric-1.20.1-*.jar - files-secondary: target/HuskHomes-Fabric-(1.19.4|1.19.2)-*.jar + files-primary: target/HuskHomes-Fabric-*.jar name: HuskHomes (Fabric) v${{ github.event.release.tag_name }} version: ${{ github.event.release.tag_name }} version-type: release - changelog: | - > ⚠ Remember to download the correct JAR file for your version of Minecraft! - - ${{ github.event.release.body }} + changelog: ${{ github.event.release.body }} loaders: | fabric game-versions: | - 1.19.2 - 1.19.4 1.20.1 java: 17 - name: 'Upload GitHub Artifacts 📦' diff --git a/fabric/fabric-1.19.2/build.gradle b/fabric/fabric-1.19.2/build.gradle deleted file mode 100644 index 033739b7..00000000 --- a/fabric/fabric-1.19.2/build.gradle +++ /dev/null @@ -1,84 +0,0 @@ -import org.apache.tools.ant.filters.ReplaceTokens - -plugins { - id 'fabric-loom' version "$fabric_loom_version" -} - -apply plugin: 'fabric-loom' -loom.serverOnlyMinecraftJar() - -// Get properties from local gradle.properties file -def properties = new Properties() -file("gradle.properties").withInputStream { properties.load(it) } - - -dependencies { - minecraft "com.mojang:minecraft:${fabric_minecraft_version}" - mappings "net.fabricmc:yarn:${fabric_yarn_mappings}:v2" - modImplementation "net.fabricmc:fabric-loader:${fabric_loader_version}" - - // Fabric API modules - Set fabricApiModules = [ - 'fabric-api-base', - 'fabric-lifecycle-events-v1', - 'fabric-entity-events-v1', - 'fabric-command-api-v2', - 'fabric-networking-api-v1' - ] - fabricApiModules.forEach { - modImplementation(fabricApi.module(it, fabric_api_version)) - } - modImplementation include("net.kyori:adventure-platform-fabric:${adventure_platform_fabric_version}") - modImplementation include("me.lucko:fabric-permissions-api:${fabric_permissions_api_version}") - - implementation include("redis.clients:jedis:$jedis_version") - implementation include("org.apache.commons:commons-pool2:$commons_pool_version") - implementation include("com.mysql:mysql-connector-j:$mysql_driver_version") - implementation include("org.xerial:sqlite-jdbc:$sqlite_driver_version") - - compileOnly 'org.jetbrains:annotations:24.0.1' - - shadow project(path: ":common") -} - -shadowJar { - configurations = [project.configurations.shadow] - destinationDirectory.set(file("$projectDir/build/libs")) - - exclude('net.fabricmc:.*') - exclude('net.kyori:.*') - exclude '/mappings/*' - - relocate 'org.apache.commons.io', 'net.william278.huskhomes.libraries.commons.io' - relocate 'org.apache.commons.text', 'net.william278.huskhomes.libraries.commons.text' - relocate 'org.apache.commons.lang3', 'net.william278.huskhomes.libraries.commons.lang3' - relocate 'de.themoep', 'net.william278.huskhomes.libraries' - relocate 'org.jetbrains', 'net.william278.huskhomes.libraries' - relocate 'org.intellij', 'net.william278.huskhomes.libraries' - relocate 'com.zaxxer', 'net.william278.huskhomes.libraries' - relocate 'net.william278.annotaml', 'net.william278.huskhomes.libraries.annotaml' - relocate 'net.william278.paginedown', 'net.william278.huskhomes.libraries.paginedown' - relocate 'net.william278.desertwell', 'net.william278.huskhomes.libraries.desertwell' - relocate 'dev.dejvokep.boostedyaml', 'net.william278.huskhomes.libraries.boostedyaml' - relocate 'org.yaml.snakeyaml', 'net.william278.huskhomes.libraries.snakeyaml' - relocate 'com.google.gson', 'net.william278.huskhomes.libraries.gson' -} - -processResources { - filesMatching(['**/*.json', '**/*.yml']) { - filter ReplaceTokens as Class, beginToken: '${', endToken: '}', - tokens: properties - } -} - -remapJar { - dependsOn tasks.shadowJar - mustRunAfter tasks.shadowJar - inputFile = shadowJar.archiveFile.get() - addNestedDependencies = true - - destinationDirectory.set(file("$rootDir/target/")) - archiveClassifier.set('') -} - -shadowJar.finalizedBy(remapJar) \ No newline at end of file diff --git a/fabric/fabric-1.19.2/gradle.properties b/fabric/fabric-1.19.2/gradle.properties deleted file mode 100644 index 3eb8e059..00000000 --- a/fabric/fabric-1.19.2/gradle.properties +++ /dev/null @@ -1,6 +0,0 @@ -fabric_minecraft_version=1.19.2 -fabric_loader_version=0.14.17 -fabric_yarn_mappings=1.19.2+build.28 -fabric_api_version=0.76.0+1.19.2 - -adventure_platform_fabric_version=5.5.2 \ No newline at end of file diff --git a/fabric/fabric-1.19.2/src/main/java/net/william278/huskhomes/FabricHuskHomes.java b/fabric/fabric-1.19.2/src/main/java/net/william278/huskhomes/FabricHuskHomes.java deleted file mode 100644 index 3aca2d0f..00000000 --- a/fabric/fabric-1.19.2/src/main/java/net/william278/huskhomes/FabricHuskHomes.java +++ /dev/null @@ -1,489 +0,0 @@ -/* - * This file is part of HuskHomes, licensed under the Apache License 2.0. - * - * Copyright (c) William278 - * Copyright (c) contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.william278.huskhomes; - -import io.netty.buffer.ByteBufUtil; -import net.fabricmc.api.DedicatedServerModInitializer; -import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback; -import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents; -import net.fabricmc.fabric.api.networking.v1.PacketSender; -import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking; -import net.fabricmc.loader.api.FabricLoader; -import net.fabricmc.loader.api.ModContainer; -import net.kyori.adventure.platform.fabric.FabricServerAudiences; -import net.minecraft.network.PacketByteBuf; -import net.minecraft.server.MinecraftServer; -import net.minecraft.server.network.ServerPlayNetworkHandler; -import net.minecraft.server.network.ServerPlayerEntity; -import net.minecraft.util.Identifier; -import net.minecraft.util.math.BlockPos; -import net.william278.annotaml.Annotaml; -import net.william278.desertwell.util.Version; -import net.william278.huskhomes.command.Command; -import net.william278.huskhomes.command.FabricCommand; -import net.william278.huskhomes.config.Locales; -import net.william278.huskhomes.config.Server; -import net.william278.huskhomes.config.Settings; -import net.william278.huskhomes.config.Spawn; -import net.william278.huskhomes.database.Database; -import net.william278.huskhomes.database.MySqlDatabase; -import net.william278.huskhomes.database.SqLiteDatabase; -import net.william278.huskhomes.event.FabricEventDispatcher; -import net.william278.huskhomes.hook.Hook; -import net.william278.huskhomes.listener.EventListener; -import net.william278.huskhomes.listener.FabricEventListener; -import net.william278.huskhomes.manager.Manager; -import net.william278.huskhomes.network.Broker; -import net.william278.huskhomes.network.PluginMessageBroker; -import net.william278.huskhomes.network.RedisBroker; -import net.william278.huskhomes.position.Location; -import net.william278.huskhomes.position.World; -import net.william278.huskhomes.random.NormalDistributionEngine; -import net.william278.huskhomes.random.RandomTeleportEngine; -import net.william278.huskhomes.user.ConsoleUser; -import net.william278.huskhomes.user.FabricUser; -import net.william278.huskhomes.user.OnlineUser; -import net.william278.huskhomes.user.SavedUser; -import net.william278.huskhomes.util.FabricSafetyResolver; -import net.william278.huskhomes.util.FabricTask; -import net.william278.huskhomes.util.UnsafeBlocks; -import net.william278.huskhomes.util.Validator; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.lang.reflect.InvocationTargetException; -import java.nio.file.Files; -import java.util.*; -import java.util.concurrent.ConcurrentHashMap; -import java.util.logging.Level; -import java.util.stream.Collectors; - -public class FabricHuskHomes implements DedicatedServerModInitializer, HuskHomes, FabricTask.Supplier, - FabricEventDispatcher, FabricSafetyResolver, ServerPlayNetworking.PlayChannelHandler { - - public static final Logger LOGGER = LoggerFactory.getLogger("HuskHomes"); - private final ModContainer modContainer = FabricLoader.getInstance().getModContainer("huskhomes") - .orElseThrow(() -> new RuntimeException("Failed to get Mod Container")); - - private MinecraftServer minecraftServer; - private Map permissions; - private Set savedUsers; - private Settings settings; - private Locales locales; - private Database database; - private Validator validator; - private Manager manager; - private EventListener eventListener; - private RandomTeleportEngine randomTeleportEngine; - private Spawn serverSpawn; - private UnsafeBlocks unsafeBlocks; - private List hooks; - private List commands; - private ConcurrentHashMap> globalPlayerList; - private Set currentlyOnWarmup; - private Server server; - @Nullable - private Broker broker; - private FabricServerAudiences audiences; - - @Override - public void onInitializeServer() { - // Get plugin version from mod container - this.permissions = new HashMap<>(); - this.savedUsers = new HashSet<>(); - this.globalPlayerList = new ConcurrentHashMap<>(); - this.currentlyOnWarmup = new HashSet<>(); - this.validator = new Validator(this); - - // Load settings and locales - initialize("plugin config & locale files", (plugin) -> { - if (!loadConfigs()) { - throw new IllegalStateException("Failed to load config files. Please check the console for errors"); - } - }); - - // Pre-register commands - initialize("commands", (plugin) -> this.commands = registerCommands()); - - ServerLifecycleEvents.SERVER_STARTING.register(server -> { - this.minecraftServer = server; - this.onEnable(); - }); - ServerLifecycleEvents.SERVER_STOPPING.register(server -> this.onDisable()); - } - - private void onEnable() { - // Create adventure audience - this.audiences = FabricServerAudiences.of(minecraftServer); - - // Initialize the database - initialize(getSettings().getDatabaseType().getDisplayName() + " database connection", (plugin) -> { - this.database = switch (getSettings().getDatabaseType()) { - case MYSQL, MARIADB -> new MySqlDatabase(this); - case SQLITE -> new SqLiteDatabase(this); - }; - - database.initialize(); - }); - - // Initialize the manager - this.manager = new Manager(this); - - // Initialize the network messenger if proxy mode is enabled - if (getSettings().doCrossServer()) { - initialize(settings.getBrokerType().getDisplayName() + " message broker", (plugin) -> { - broker = switch (settings.getBrokerType()) { - case PLUGIN_MESSAGE -> new PluginMessageBroker(this); - case REDIS -> new RedisBroker(this); - }; - broker.initialize(); - }); - } - - setRandomTeleportEngine(new NormalDistributionEngine(this)); - - // Register plugin hooks (Economy, Maps, Plan) - initialize("hooks", (plugin) -> { - this.registerHooks(); - - if (hooks.size() > 0) { - hooks.forEach(hook -> { - try { - hook.initialize(); - } catch (Throwable e) { - log(Level.WARNING, "Failed to initialize " + hook.getName() + " hook", e); - } - }); - log(Level.INFO, "Registered " + hooks.size() + " mod hooks: " + hooks.stream() - .map(Hook::getName) - .collect(Collectors.joining(", "))); - } - }); - - // Register events - initialize("events", (plugin) -> this.eventListener = new FabricEventListener(this)); - - this.checkForUpdates(); - } - - private void onDisable() { - if (this.eventListener != null) { - this.eventListener.handlePluginDisable(); - } - if (database != null) { - database.terminate(); - } - if (broker != null) { - broker.close(); - } - if (audiences != null) { - audiences.close(); - audiences = null; - } - cancelTasks(); - } - - @Override - @NotNull - public ConsoleUser getConsole() { - return new ConsoleUser(audiences.console()); - } - - @Override - @NotNull - public List getOnlineUsers() { - return minecraftServer.getPlayerManager().getPlayerList() - .stream().map(user -> (OnlineUser) FabricUser.adapt(user, this)) - .toList(); - } - - @Override - @NotNull - public Set getSavedUsers() { - return savedUsers; - } - - @Override - @NotNull - public Settings getSettings() { - return settings; - } - - @Override - public void setSettings(@NotNull Settings settings) { - this.settings = settings; - } - - @Override - @NotNull - public Locales getLocales() { - return locales; - } - - @Override - public void setLocales(@NotNull Locales locales) { - this.locales = locales; - } - - @Override - public Optional getServerSpawn() { - return Optional.ofNullable(serverSpawn); - } - - @Override - public void setServerSpawn(@NotNull Spawn spawn) { - this.serverSpawn = spawn; - } - - @Override - public void setServerSpawn(@NotNull Location location) { - try { - // Create or update the spawn.yml file - final File spawnFile = new File(getDataFolder(), "spawn.yml"); - if (spawnFile.exists() && !spawnFile.delete()) { - log(Level.WARNING, "Failed to delete the existing spawn.yml file"); - } - this.serverSpawn = Annotaml.create(spawnFile, new Spawn(location)).get(); - - // Update the world spawn location, too - minecraftServer.getWorlds().forEach(world -> { - if (world.getRegistryKey().getValue().asString().equals(location.getWorld().getName())) { - world.setSpawnPos(new BlockPos(location.getX(), location.getY(), location.getZ()), 0); - } - }); - } catch (IOException | InvocationTargetException | InstantiationException | IllegalAccessException e) { - log(Level.WARNING, "Failed to save the server spawn.yml file", e); - } - } - - @Override - @NotNull - public String getServerName() { - return server.getName(); - } - - @Override - public void setServer(@NotNull Server server) { - this.server = server; - } - - @Override - public void setUnsafeBlocks(@NotNull UnsafeBlocks unsafeBlocks) { - this.unsafeBlocks = unsafeBlocks; - } - - @NotNull - @Override - public UnsafeBlocks getUnsafeBlocks() { - return unsafeBlocks; - } - - @Override - @NotNull - public Database getDatabase() { - return database; - } - - @Override - @NotNull - public Validator getValidator() { - return validator; - } - - @Override - @NotNull - public Manager getManager() { - return manager; - } - - @Override - @NotNull - public Broker getMessenger() { - if (broker == null) { - throw new IllegalStateException("Attempted to access message broker when it was not initialized"); - } - return broker; - } - - @Override - @NotNull - public RandomTeleportEngine getRandomTeleportEngine() { - return randomTeleportEngine; - } - - @Override - public void setRandomTeleportEngine(@NotNull RandomTeleportEngine randomTeleportEngine) { - this.randomTeleportEngine = randomTeleportEngine; - } - - @Override - @NotNull - public List getHooks() { - return hooks; - } - - @Override - public void setHooks(@NotNull List hooks) { - this.hooks = hooks; - } - - @Override - @Nullable - public InputStream getResource(@NotNull String name) { - return this.modContainer.findPath(name) - .map(path -> { - try { - return Files.newInputStream(path); - } catch (IOException e) { - log(Level.WARNING, "Failed to load resource: " + name, e); - } - return null; - }) - .orElse(this.getClass().getClassLoader().getResourceAsStream(name)); - } - - @Override - @NotNull - public File getDataFolder() { - return FabricLoader.getInstance().getConfigDir().resolve("huskhomes").toFile(); - } - - @Override - @NotNull - public List getWorlds() { - final List worlds = new ArrayList<>(); - minecraftServer.getWorlds().forEach(world -> worlds.add(World.from( - world.getRegistryKey().getValue().asString(), - UUID.nameUUIDFromBytes(world.getRegistryKey().getValue().asString().getBytes()) - ))); - return worlds; - } - - @Override - @NotNull - public Version getVersion() { - return Version.fromString(modContainer.getMetadata().getVersion().getFriendlyString(), "-"); - } - - @Override - @NotNull - public List getCommands() { - return commands; - } - - @NotNull - public List registerCommands() { - final List commands = FabricCommand.Type.getCommands(getPlugin()); - CommandRegistrationCallback.EVENT.register((dispatcher, ignored, ignored2) -> - commands.forEach(command -> new FabricCommand(command, this).register(dispatcher))); - return commands; - } - - @Override - public boolean isDependencyLoaded(@NotNull String name) { - return FabricLoader.getInstance().isModLoaded(name); - } - - @Override - @NotNull - public Map> getGlobalPlayerList() { - return globalPlayerList; - } - - @Override - @NotNull - public Set getCurrentlyOnWarmup() { - return currentlyOnWarmup; - } - - @Override - public void registerMetrics(int metricsId) { - // No metrics for Fabric - } - - @Override - public void initializePluginChannels() { - ServerPlayNetworking.registerGlobalReceiver(new Identifier("bungeecord", "main"), this); - } - - // When the server receives a plugin message - @Override - public void receive(@NotNull MinecraftServer server, @NotNull ServerPlayerEntity player, - @NotNull ServerPlayNetworkHandler handler, @NotNull PacketByteBuf buf, - @NotNull PacketSender responseSender) { - if (broker instanceof PluginMessageBroker messenger - && getSettings().getBrokerType() == Broker.Type.PLUGIN_MESSAGE) { - messenger.onReceive( - PluginMessageBroker.BUNGEE_CHANNEL_ID, - FabricUser.adapt(player, this), - ByteBufUtil.getBytes(buf) - ); - } - } - - @Override - public void log(@NotNull Level level, @NotNull String message, @NotNull Throwable... exceptions) { - switch (level.getName()) { - case "WARNING" -> { - if (exceptions.length >= 1) { - LOGGER.warn(message, exceptions[0]); - } else { - LOGGER.warn(message); - } - } - case "SEVERE" -> { - if (exceptions.length >= 1) { - LOGGER.error(message, exceptions[0]); - } else { - LOGGER.error(message); - } - } - default -> { - if (exceptions.length >= 1) { - LOGGER.info(message, exceptions[0]); - } else { - LOGGER.info(message); - } - } - } - } - - @NotNull - public Map getPermissions() { - return permissions; - } - - @NotNull - public MinecraftServer getMinecraftServer() { - return minecraftServer; - } - - @Override - @NotNull - public FabricHuskHomes getPlugin() { - return this; - } - -} diff --git a/fabric/fabric-1.19.2/src/main/java/net/william278/huskhomes/event/FabricEventDispatcher.java b/fabric/fabric-1.19.2/src/main/java/net/william278/huskhomes/event/FabricEventDispatcher.java deleted file mode 100644 index 25b48705..00000000 --- a/fabric/fabric-1.19.2/src/main/java/net/william278/huskhomes/event/FabricEventDispatcher.java +++ /dev/null @@ -1,146 +0,0 @@ -/* - * This file is part of HuskHomes, licensed under the Apache License 2.0. - * - * Copyright (c) William278 - * Copyright (c) contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.william278.huskhomes.event; - -import net.minecraft.util.ActionResult; -import net.william278.huskhomes.FabricHuskHomes; -import net.william278.huskhomes.position.Home; -import net.william278.huskhomes.position.Position; -import net.william278.huskhomes.position.Warp; -import net.william278.huskhomes.teleport.Teleport; -import net.william278.huskhomes.teleport.TeleportRequest; -import net.william278.huskhomes.teleport.TimedTeleport; -import net.william278.huskhomes.user.CommandUser; -import net.william278.huskhomes.user.OnlineUser; -import net.william278.huskhomes.user.User; -import org.jetbrains.annotations.NotNull; - -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.util.List; -import java.util.logging.Level; - -public interface FabricEventDispatcher extends EventDispatcher { - - @SuppressWarnings("unchecked") - @Override - default boolean fireIsCancelled(@NotNull T event) { - try { - final Method field = event.getClass().getDeclaredMethod("getEvent"); - field.setAccessible(true); - - net.fabricmc.fabric.api.event.Event fabricEvent = - (net.fabricmc.fabric.api.event.Event) field.invoke(event); - - final FabricEventCallback invoker = (FabricEventCallback) fabricEvent.invoker(); - return invoker.invoke(event) == ActionResult.FAIL; - } catch (InvocationTargetException | NoSuchMethodException | IllegalAccessException e) { - getPlugin().log(Level.WARNING, "Failed to fire event (" + event.getClass().getName() + ")", e); - return false; - } - } - - @Override - @NotNull - default ITeleportEvent getTeleportEvent(@NotNull Teleport teleport) { - return TeleportCallback.SUPPLIER.apply(teleport); - } - - @Override - default @NotNull ITeleportWarmupEvent getTeleportWarmupEvent(@NotNull TimedTeleport teleport, int duration) { - return TeleportWarmupCallback.SUPPLIER.apply(teleport, duration); - } - - @Override - default @NotNull ISendTeleportRequestEvent getSendTeleportRequestEvent(@NotNull OnlineUser sender, - @NotNull TeleportRequest request) { - return SendTeleportRequestCallback.SUPPLIER.apply(sender, request); - } - - @Override - default @NotNull IReceiveTeleportRequestEvent getReceiveTeleportRequestEvent(@NotNull OnlineUser recipient, - @NotNull TeleportRequest request) { - return ReceiveTeleportRequestCallback.SUPPLIER.apply(recipient, request); - } - - @Override - default @NotNull IReplyTeleportRequestEvent getReplyTeleportRequestEvent(@NotNull OnlineUser recipient, - @NotNull TeleportRequest request) { - return ReplyTeleportRequestCallback.SUPPLIER.apply(recipient, request); - } - - @Override - default @NotNull IHomeCreateEvent getHomeCreateEvent(@NotNull User owner, @NotNull String name, - @NotNull Position position, @NotNull CommandUser creator) { - return HomeCreateCallback.SUPPLIER.apply(owner, name, position, creator); - } - - @Override - default @NotNull IHomeEditEvent getHomeEditEvent(@NotNull Home home, @NotNull CommandUser editor) { - return HomeEditCallback.SUPPLIER.apply(home, editor); - } - - @Override - default @NotNull IHomeDeleteEvent getHomeDeleteEvent(@NotNull Home home, @NotNull CommandUser deleter) { - return HomeDeleteCallback.SUPPLIER.apply(home, deleter); - } - - @Override - default @NotNull IWarpCreateEvent getWarpCreateEvent(@NotNull String name, @NotNull Position position, - @NotNull CommandUser creator) { - return WarpCreateCallback.SUPPLIER.apply(name, position, creator); - } - - @Override - default @NotNull IWarpEditEvent getWarpEditEvent(@NotNull Warp warp, @NotNull CommandUser editor) { - return WarpEditCallback.SUPPLIER.apply(warp, editor); - } - - @Override - default @NotNull IWarpDeleteEvent getWarpDeleteEvent(@NotNull Warp warp, @NotNull CommandUser deleter) { - return WarpDeleteCallback.SUPPLIER.apply(warp, deleter); - } - - @Override - default @NotNull IHomeListEvent getViewHomeListEvent(@NotNull List homes, @NotNull CommandUser listViewer, - boolean publicHomeList) { - return HomeListCallback.SUPPLIER.apply(homes, listViewer, publicHomeList); - } - - @Override - default @NotNull IWarpListEvent getViewWarpListEvent(@NotNull List homes, @NotNull CommandUser listViewer) { - return WarpListCallback.SUPPLIER.apply(homes, listViewer); - } - - @Override - default @NotNull IDeleteAllHomesEvent getDeleteAllHomesEvent(@NotNull User user, @NotNull CommandUser deleter) { - return DeleteAllHomesCallback.SUPPLIER.apply(user, deleter); - } - - @Override - default @NotNull IDeleteAllWarpsEvent getDeleteAllWarpsEvent(@NotNull CommandUser deleter) { - return DeleteAllWarpsCallback.SUPPLIER.apply(deleter); - } - - @Override - @NotNull - FabricHuskHomes getPlugin(); - -} diff --git a/fabric/fabric-1.19.2/src/main/java/net/william278/huskhomes/user/FabricUser.java b/fabric/fabric-1.19.2/src/main/java/net/william278/huskhomes/user/FabricUser.java deleted file mode 100644 index 08984144..00000000 --- a/fabric/fabric-1.19.2/src/main/java/net/william278/huskhomes/user/FabricUser.java +++ /dev/null @@ -1,166 +0,0 @@ -/* - * This file is part of HuskHomes, licensed under the Apache License 2.0. - * - * Copyright (c) William278 - * Copyright (c) contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.william278.huskhomes.user; - -import me.lucko.fabric.api.permissions.v0.Permissions; -import net.fabricmc.fabric.api.networking.v1.PacketByteBufs; -import net.kyori.adventure.audience.Audience; -import net.minecraft.network.PacketByteBuf; -import net.minecraft.network.packet.s2c.play.CustomPayloadS2CPacket; -import net.minecraft.server.MinecraftServer; -import net.minecraft.server.network.ServerPlayerEntity; -import net.minecraft.util.Identifier; -import net.minecraft.util.math.BlockPos; -import net.william278.huskhomes.FabricHuskHomes; -import net.william278.huskhomes.position.Location; -import net.william278.huskhomes.position.Position; -import net.william278.huskhomes.position.World; -import net.william278.huskhomes.teleport.TeleportationException; -import org.jetbrains.annotations.NotNull; - -import java.util.*; - -public class FabricUser extends OnlineUser { - - private final FabricHuskHomes plugin; - private final ServerPlayerEntity player; - - private FabricUser(@NotNull ServerPlayerEntity player, @NotNull FabricHuskHomes plugin) { - super(player.getUuid(), player.getEntityName()); - this.player = player; - this.plugin = plugin; - } - - @NotNull - public static FabricUser adapt(@NotNull ServerPlayerEntity player, @NotNull FabricHuskHomes plugin) { - return new FabricUser(player, plugin); - } - - @Override - public Position getPosition() { - return Position.at( - player.getX(), player.getY(), player.getZ(), - player.getYaw(), player.getPitch(), - World.from( - player.getWorld().getRegistryKey().getValue().asString(), - UUID.nameUUIDFromBytes(player.getWorld().getRegistryKey().getValue().asString().getBytes()) - ), - plugin.getServerName() - ); - } - - @Override - public Optional getBedSpawnPosition() { - final BlockPos spawn = player.getSpawnPointPosition(); - if (spawn == null) { - return Optional.empty(); - } - - return Optional.of(Position.at( - spawn.getX(), spawn.getY(), spawn.getZ(), - player.getSpawnAngle(), 0, - World.from( - player.getSpawnPointDimension().getValue().asString(), - UUID.nameUUIDFromBytes(player.getSpawnPointDimension().getValue().asString().getBytes()) - ), - plugin.getServerName() - )); - } - - @Override - public double getHealth() { - return player.getHealth(); - } - - @Override - public boolean hasPermission(@NotNull String node) { - final boolean requiresOp = Boolean.TRUE.equals(plugin.getPermissions().getOrDefault(node, true)); - return Permissions.check(player, node, !requiresOp || player.hasPermissionLevel(3)); - } - - @Override - @NotNull - public Map getPermissions() { - return plugin.getPermissions().entrySet().stream() - .filter(entry -> Permissions.check(player, entry.getKey(), entry.getValue())) - .collect(HashMap::new, (map, entry) -> map.put(entry.getKey(), entry.getValue()), HashMap::putAll); - } - - @Override - @NotNull - protected List getNumericalPermissions(@NotNull String nodePrefix) { - final List permissions = new ArrayList<>(); - for (int i = 0; i < 100; i++) { - if (hasPermission(nodePrefix + i)) { - permissions.add(i); - } - } - return permissions.stream().sorted(Collections.reverseOrder()).toList(); - } - - @Override - @NotNull - public Audience getAudience() { - return player; - } - - @Override - public void teleportLocally(@NotNull Location location, boolean async) throws TeleportationException { - final MinecraftServer server = player.getServer(); - assert server != null : "Server is null"; - final Identifier worldId = Identifier.tryParse(location.getWorld().getName()); - player.teleport( - server.getWorld(server.getWorldRegistryKeys().stream() - .filter(key -> key.getValue().equals(worldId)).findFirst().orElseThrow( - () -> new TeleportationException(TeleportationException.Type.WORLD_NOT_FOUND, plugin)) - ), - location.getX(), location.getY(), location.getZ(), - location.getYaw(), location.getPitch() - ); - } - - @Override - public void sendPluginMessage(@NotNull String channel, byte[] message) { - final PacketByteBuf buf = PacketByteBufs.create(); - buf.writeBytes(message); - final CustomPayloadS2CPacket packet = new CustomPayloadS2CPacket(parseIdentifier(channel), buf); - player.networkHandler.sendPacket(packet); - } - - @Override - public boolean isMoving() { - return player.isTouchingWater() || player.isFallFlying() || player.isSprinting() || player.isSneaking(); - } - - @Override - public boolean isVanished() { - return false; - } - - @NotNull - private static Identifier parseIdentifier(@NotNull String channel) { - if (channel.equals("BungeeCord")) { - return new Identifier("bungeecord", "main"); - } - return Optional.ofNullable(Identifier.tryParse(channel)) - .orElseThrow(() -> new IllegalArgumentException("Invalid channel name: " + channel)); - } - -} diff --git a/fabric/fabric-1.19.2/src/main/java/net/william278/huskhomes/util/FabricSafetyResolver.java b/fabric/fabric-1.19.2/src/main/java/net/william278/huskhomes/util/FabricSafetyResolver.java deleted file mode 100644 index 4d3b2d29..00000000 --- a/fabric/fabric-1.19.2/src/main/java/net/william278/huskhomes/util/FabricSafetyResolver.java +++ /dev/null @@ -1,129 +0,0 @@ -/* - * This file is part of HuskHomes, licensed under the Apache License 2.0. - * - * Copyright (c) William278 - * Copyright (c) contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.william278.huskhomes.util; - -import net.minecraft.block.Block; -import net.minecraft.block.FireBlock; -import net.minecraft.block.FluidBlock; -import net.minecraft.server.MinecraftServer; -import net.minecraft.server.world.ServerWorld; -import net.minecraft.util.Identifier; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; -import net.minecraft.util.registry.Registry; -import net.minecraft.world.BlockView; -import net.william278.huskhomes.FabricHuskHomes; -import net.william278.huskhomes.position.Location; -import org.jetbrains.annotations.NotNull; - -import java.util.Optional; -import java.util.concurrent.CompletableFuture; - -public interface FabricSafetyResolver extends SafetyResolver { - - @Override - default CompletableFuture> findSafeGroundLocation(@NotNull Location location) { - final MinecraftServer server = ((FabricHuskHomes) getPlugin()).getMinecraftServer(); - final Identifier worldId = Identifier.tryParse(location.getWorld().getName()); - - // Ensure the location is on a valid world - final Optional locationWorld = server.getWorldRegistryKeys().stream() - .filter(key -> key.getValue().equals(worldId)).findFirst() - .map(server::getWorld); - if (locationWorld.isEmpty()) { - return CompletableFuture.completedFuture(Optional.empty()); - } - - // Ensure the location is within the world border - final ServerWorld world = locationWorld.get(); - if (!world.getWorldBorder().contains(location.getX(), location.getZ())) { - return CompletableFuture.completedFuture(Optional.empty()); - } - - return CompletableFuture.completedFuture(findSafeLocationNear(location, world)); - } - - /** - * Search for a safe ground location near the given location. - * - * @param location The location to search around - * @return An optional safe location, within 4 blocks of the given location - */ - private Optional findSafeLocationNear(@NotNull Location location, @NotNull ServerWorld world) { - final BlockPos.Mutable blockPos = new BlockPos.Mutable(location.getX(), location.getY(), location.getZ()); - for (int x = -SEARCH_RADIUS; x <= SEARCH_RADIUS; x++) { - for (int z = -SEARCH_RADIUS; z <= SEARCH_RADIUS; z++) { - blockPos.set(location.getX() + x, location.getY(), location.getZ() + z); - final int highestY = getHighestYAt(world, blockPos.getX(), blockPos.getY(), blockPos.getZ()) + 1; - - final Block block = world.getBlockState(blockPos.withY(highestY - 1)).getBlock(); - final Identifier id = Registry.BLOCK.getId(block); - - final Block bodyBlockType = world.getBlockState(blockPos.withY(highestY)).getBlock(); - final Identifier bodyBlockId = Registry.BLOCK.getId(bodyBlockType); - - final Block headBlockType = world.getBlockState(blockPos.withY(highestY + 1)).getBlock(); - final Identifier headBlockId = Registry.BLOCK.getId(headBlockType); - - if (!(block instanceof FluidBlock) && !(block instanceof FireBlock) - && isBlockSafeForStanding(id.toString()) && isBlockSafeForOccupation(bodyBlockId.toString()) - && isBlockSafeForOccupation(headBlockId.toString())) { - double locx = blockPos.getX(); - if (locx < 0) { - locx += 1.5d; - } else { - locx = locx + 0.5d; - } - double locz = blockPos.getZ(); - if (locz < 0) { - locz += 1.5d; - } else { - locz = locz + 0.5d; - } - return Optional.of(Location.at( - locx, - highestY, - locz, - location.getWorld() - )); - } - } - } - return Optional.empty(); - } - - /** - * Get the highest Y value at the given X and Z coordinates. - * - * @param blockView The block view to search - * @param x The X coordinate - * @param y The Y coordinate - * @param z The Z coordinate - * @return The highest Y value at the given X and Z coordinates - */ - private int getHighestYAt(@NotNull BlockView blockView, int x, int y, int z) { - final BlockPos.Mutable cursor = new BlockPos.Mutable(x, y, z); - while (blockView.getBlockState(cursor).isAir() && cursor.getY() > blockView.getBottomY()) { - cursor.move(Direction.DOWN); - } - return cursor.getY(); - } - -} diff --git a/fabric/fabric-1.19.2/src/main/java/net/william278/huskhomes/util/FabricTask.java b/fabric/fabric-1.19.2/src/main/java/net/william278/huskhomes/util/FabricTask.java deleted file mode 100644 index fdf8a1fc..00000000 --- a/fabric/fabric-1.19.2/src/main/java/net/william278/huskhomes/util/FabricTask.java +++ /dev/null @@ -1,132 +0,0 @@ -/* - * This file is part of HuskHomes, licensed under the Apache License 2.0. - * - * Copyright (c) William278 - * Copyright (c) contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.william278.huskhomes.util; - -import net.william278.huskhomes.FabricHuskHomes; -import net.william278.huskhomes.HuskHomes; -import org.jetbrains.annotations.NotNull; - -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.Executors; -import java.util.concurrent.ScheduledFuture; -import java.util.concurrent.TimeUnit; - -public interface FabricTask extends Task { - - class Sync extends Task.Sync implements FabricTask { - - protected Sync(@NotNull HuskHomes plugin, @NotNull Runnable runnable, long delayTicks) { - super(plugin, runnable, delayTicks); - } - - @Override - public void cancel() { - super.cancel(); - } - - @Override - public void run() { - if (!cancelled) { - Executors.newSingleThreadScheduledExecutor().schedule( - () -> ((FabricHuskHomes) getPlugin()).getMinecraftServer().executeSync(runnable), - delayTicks * 50, - TimeUnit.MILLISECONDS - ); - } - } - } - - class Async extends Task.Async implements FabricTask { - private CompletableFuture task; - - protected Async(@NotNull HuskHomes plugin, @NotNull Runnable runnable) { - super(plugin, runnable); - } - - @Override - public void cancel() { - if (task != null && !cancelled) { - task.cancel(true); - } - super.cancel(); - } - - @Override - public void run() { - if (!cancelled) { - this.task = CompletableFuture.runAsync(runnable, ((FabricHuskHomes) getPlugin()).getMinecraftServer()); - } - } - } - - class Repeating extends Task.Repeating implements FabricTask { - - private ScheduledFuture task; - - protected Repeating(@NotNull HuskHomes plugin, @NotNull Runnable runnable, long repeatingTicks) { - super(plugin, runnable, repeatingTicks); - } - - @Override - public void cancel() { - if (task != null && !cancelled) { - task.cancel(true); - } - super.cancel(); - } - - @Override - public void run() { - if (!cancelled) { - this.task = Executors.newSingleThreadScheduledExecutor().scheduleAtFixedRate( - runnable, 0, repeatingTicks * 50, TimeUnit.MILLISECONDS - ); - } - } - } - - interface Supplier extends Task.Supplier { - - @NotNull - @Override - default Task.Sync getSyncTask(@NotNull Runnable runnable, long delayTicks) { - return new Sync(getPlugin(), runnable, delayTicks); - } - - @NotNull - @Override - default Task.Async getAsyncTask(@NotNull Runnable runnable) { - return new Async(getPlugin(), runnable); - } - - @NotNull - @Override - default Task.Repeating getRepeatingTask(@NotNull Runnable runnable, long repeatingTicks) { - return new Repeating(getPlugin(), runnable, repeatingTicks); - } - - @Override - default void cancelTasks() { - // Do nothing - } - - } - -} diff --git a/fabric/fabric-1.19.4/gradle.properties b/fabric/fabric-1.19.4/gradle.properties deleted file mode 100644 index fb8648a1..00000000 --- a/fabric/fabric-1.19.4/gradle.properties +++ /dev/null @@ -1,6 +0,0 @@ -fabric_minecraft_version=1.20.1 -fabric_loader_version=0.14.21 -fabric_yarn_mappings=1.19.4+build.2 -fabric_api_version=0.84.0+1.19.4 - -adventure_platform_fabric_version=5.8.0 \ No newline at end of file diff --git a/fabric/fabric-1.19.4/src/main/java/net/william278/huskhomes/FabricHuskHomes.java b/fabric/fabric-1.19.4/src/main/java/net/william278/huskhomes/FabricHuskHomes.java deleted file mode 100644 index 13fd5bbd..00000000 --- a/fabric/fabric-1.19.4/src/main/java/net/william278/huskhomes/FabricHuskHomes.java +++ /dev/null @@ -1,478 +0,0 @@ -/* - * This file is part of HuskHomes, licensed under the Apache License 2.0. - * - * Copyright (c) William278 - * Copyright (c) contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.william278.huskhomes; - -import io.netty.buffer.ByteBufUtil; -import net.fabricmc.api.DedicatedServerModInitializer; -import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback; -import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents; -import net.fabricmc.fabric.api.networking.v1.PacketSender; -import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking; -import net.fabricmc.loader.api.FabricLoader; -import net.fabricmc.loader.api.ModContainer; -import net.kyori.adventure.platform.fabric.FabricServerAudiences; -import net.minecraft.network.PacketByteBuf; -import net.minecraft.server.MinecraftServer; -import net.minecraft.server.network.ServerPlayNetworkHandler; -import net.minecraft.server.network.ServerPlayerEntity; -import net.minecraft.util.Identifier; -import net.minecraft.util.math.BlockPos; -import net.william278.annotaml.Annotaml; -import net.william278.desertwell.util.Version; -import net.william278.huskhomes.command.Command; -import net.william278.huskhomes.command.FabricCommand; -import net.william278.huskhomes.config.Locales; -import net.william278.huskhomes.config.Server; -import net.william278.huskhomes.config.Settings; -import net.william278.huskhomes.config.Spawn; -import net.william278.huskhomes.database.Database; -import net.william278.huskhomes.database.MySqlDatabase; -import net.william278.huskhomes.database.SqLiteDatabase; -import net.william278.huskhomes.event.FabricEventDispatcher; -import net.william278.huskhomes.hook.Hook; -import net.william278.huskhomes.listener.EventListener; -import net.william278.huskhomes.listener.FabricEventListener; -import net.william278.huskhomes.manager.Manager; -import net.william278.huskhomes.network.Broker; -import net.william278.huskhomes.network.PluginMessageBroker; -import net.william278.huskhomes.network.RedisBroker; -import net.william278.huskhomes.position.Location; -import net.william278.huskhomes.position.World; -import net.william278.huskhomes.random.NormalDistributionEngine; -import net.william278.huskhomes.random.RandomTeleportEngine; -import net.william278.huskhomes.user.ConsoleUser; -import net.william278.huskhomes.user.FabricUser; -import net.william278.huskhomes.user.OnlineUser; -import net.william278.huskhomes.user.SavedUser; -import net.william278.huskhomes.util.FabricSafetyResolver; -import net.william278.huskhomes.util.FabricTask; -import net.william278.huskhomes.util.UnsafeBlocks; -import net.william278.huskhomes.util.Validator; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.slf4j.spi.LoggingEventBuilder; - -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.lang.reflect.InvocationTargetException; -import java.nio.file.Files; -import java.util.*; -import java.util.concurrent.ConcurrentHashMap; -import java.util.logging.Level; -import java.util.stream.Collectors; - -public class FabricHuskHomes implements DedicatedServerModInitializer, HuskHomes, FabricTask.Supplier, - FabricEventDispatcher, FabricSafetyResolver, ServerPlayNetworking.PlayChannelHandler { - - public static final Logger LOGGER = LoggerFactory.getLogger("HuskHomes"); - private final ModContainer modContainer = FabricLoader.getInstance().getModContainer("huskhomes") - .orElseThrow(() -> new RuntimeException("Failed to get Mod Container")); - - private MinecraftServer minecraftServer; - private Map permissions; - private Set savedUsers; - private Settings settings; - private Locales locales; - private Database database; - private Validator validator; - private Manager manager; - private EventListener eventListener; - private RandomTeleportEngine randomTeleportEngine; - private Spawn serverSpawn; - private UnsafeBlocks unsafeBlocks; - private List hooks; - private List commands; - private ConcurrentHashMap> globalPlayerList; - private Set currentlyOnWarmup; - private Server server; - @Nullable - private Broker broker; - private FabricServerAudiences audiences; - - @Override - public void onInitializeServer() { - // Get plugin version from mod container - this.permissions = new HashMap<>(); - this.savedUsers = new HashSet<>(); - this.globalPlayerList = new ConcurrentHashMap<>(); - this.currentlyOnWarmup = new HashSet<>(); - this.validator = new Validator(this); - - // Load settings and locales - initialize("plugin config & locale files", (plugin) -> { - if (!loadConfigs()) { - throw new IllegalStateException("Failed to load config files. Please check the console for errors"); - } - }); - - // Pre-register commands - initialize("commands", (plugin) -> this.commands = registerCommands()); - - ServerLifecycleEvents.SERVER_STARTING.register(server -> { - this.minecraftServer = server; - this.onEnable(); - }); - ServerLifecycleEvents.SERVER_STOPPING.register(server -> this.onDisable()); - } - - private void onEnable() { - // Create adventure audience - this.audiences = FabricServerAudiences.of(minecraftServer); - - // Initialize the database - initialize(getSettings().getDatabaseType().getDisplayName() + " database connection", (plugin) -> { - this.database = switch (getSettings().getDatabaseType()) { - case MYSQL, MARIADB -> new MySqlDatabase(this); - case SQLITE -> new SqLiteDatabase(this); - }; - - database.initialize(); - }); - - // Initialize the manager - this.manager = new Manager(this); - - // Initialize the network messenger if proxy mode is enabled - if (getSettings().doCrossServer()) { - initialize(settings.getBrokerType().getDisplayName() + " message broker", (plugin) -> { - broker = switch (settings.getBrokerType()) { - case PLUGIN_MESSAGE -> new PluginMessageBroker(this); - case REDIS -> new RedisBroker(this); - }; - broker.initialize(); - }); - } - - setRandomTeleportEngine(new NormalDistributionEngine(this)); - - // Register plugin hooks (Economy, Maps, Plan) - initialize("hooks", (plugin) -> { - this.registerHooks(); - - if (hooks.size() > 0) { - hooks.forEach(hook -> { - try { - hook.initialize(); - } catch (Throwable e) { - log(Level.WARNING, "Failed to initialize " + hook.getName() + " hook", e); - } - }); - log(Level.INFO, "Registered " + hooks.size() + " mod hooks: " + hooks.stream() - .map(Hook::getName) - .collect(Collectors.joining(", "))); - } - }); - - // Register events - initialize("events", (plugin) -> this.eventListener = new FabricEventListener(this)); - - this.checkForUpdates(); - } - - private void onDisable() { - if (this.eventListener != null) { - this.eventListener.handlePluginDisable(); - } - if (database != null) { - database.terminate(); - } - if (broker != null) { - broker.close(); - } - if (audiences != null) { - audiences.close(); - audiences = null; - } - cancelTasks(); - } - - @Override - @NotNull - public ConsoleUser getConsole() { - return new ConsoleUser(audiences.console()); - } - - @Override - @NotNull - public List getOnlineUsers() { - return minecraftServer.getPlayerManager().getPlayerList() - .stream().map(user -> (OnlineUser) FabricUser.adapt(user, this)) - .toList(); - } - - @Override - @NotNull - public Set getSavedUsers() { - return savedUsers; - } - - @Override - @NotNull - public Settings getSettings() { - return settings; - } - - @Override - public void setSettings(@NotNull Settings settings) { - this.settings = settings; - } - - @Override - @NotNull - public Locales getLocales() { - return locales; - } - - @Override - public void setLocales(@NotNull Locales locales) { - this.locales = locales; - } - - @Override - public Optional getServerSpawn() { - return Optional.ofNullable(serverSpawn); - } - - @Override - public void setServerSpawn(@NotNull Spawn spawn) { - this.serverSpawn = spawn; - } - - @Override - public void setServerSpawn(@NotNull Location location) { - try { - // Create or update the spawn.yml file - final File spawnFile = new File(getDataFolder(), "spawn.yml"); - if (spawnFile.exists() && !spawnFile.delete()) { - log(Level.WARNING, "Failed to delete the existing spawn.yml file"); - } - this.serverSpawn = Annotaml.create(spawnFile, new Spawn(location)).get(); - - // Update the world spawn location, too - minecraftServer.getWorlds().forEach(world -> { - if (world.getRegistryKey().getValue().asString().equals(location.getWorld().getName())) { - world.setSpawnPos(BlockPos.ofFloored(location.getX(), location.getY(), location.getZ()), 0); - } - }); - } catch (IOException | InvocationTargetException | InstantiationException | IllegalAccessException e) { - log(Level.WARNING, "Failed to save the server spawn.yml file", e); - } - } - - @Override - @NotNull - public String getServerName() { - return server.getName(); - } - - @Override - public void setServer(@NotNull Server server) { - this.server = server; - } - - @Override - public void setUnsafeBlocks(@NotNull UnsafeBlocks unsafeBlocks) { - this.unsafeBlocks = unsafeBlocks; - } - - @NotNull - @Override - public UnsafeBlocks getUnsafeBlocks() { - return unsafeBlocks; - } - - @Override - @NotNull - public Database getDatabase() { - return database; - } - - @Override - @NotNull - public Validator getValidator() { - return validator; - } - - @Override - @NotNull - public Manager getManager() { - return manager; - } - - @Override - @NotNull - public Broker getMessenger() { - if (broker == null) { - throw new IllegalStateException("Attempted to access message broker when it was not initialized"); - } - return broker; - } - - @Override - @NotNull - public RandomTeleportEngine getRandomTeleportEngine() { - return randomTeleportEngine; - } - - @Override - public void setRandomTeleportEngine(@NotNull RandomTeleportEngine randomTeleportEngine) { - this.randomTeleportEngine = randomTeleportEngine; - } - - @Override - @NotNull - public List getHooks() { - return hooks; - } - - @Override - public void setHooks(@NotNull List hooks) { - this.hooks = hooks; - } - - @Override - @Nullable - public InputStream getResource(@NotNull String name) { - return this.modContainer.findPath(name) - .map(path -> { - try { - return Files.newInputStream(path); - } catch (IOException e) { - log(Level.WARNING, "Failed to load resource: " + name, e); - } - return null; - }) - .orElse(this.getClass().getClassLoader().getResourceAsStream(name)); - } - - @Override - @NotNull - public File getDataFolder() { - return FabricLoader.getInstance().getConfigDir().resolve("huskhomes").toFile(); - } - - @Override - @NotNull - public List getWorlds() { - final List worlds = new ArrayList<>(); - minecraftServer.getWorlds().forEach(world -> worlds.add(World.from( - world.getRegistryKey().getValue().asString(), - UUID.nameUUIDFromBytes(world.getRegistryKey().getValue().asString().getBytes()) - ))); - return worlds; - } - - @Override - @NotNull - public Version getVersion() { - return Version.fromString(modContainer.getMetadata().getVersion().getFriendlyString(), "-"); - } - - @Override - @NotNull - public List getCommands() { - return commands; - } - - @NotNull - public List registerCommands() { - final List commands = FabricCommand.Type.getCommands(getPlugin()); - CommandRegistrationCallback.EVENT.register((dispatcher, ignored, ignored2) -> - commands.forEach(command -> new FabricCommand(command, this).register(dispatcher))); - return commands; - } - - @Override - public boolean isDependencyLoaded(@NotNull String name) { - return FabricLoader.getInstance().isModLoaded(name); - } - - @Override - @NotNull - public Map> getGlobalPlayerList() { - return globalPlayerList; - } - - @Override - @NotNull - public Set getCurrentlyOnWarmup() { - return currentlyOnWarmup; - } - - @Override - public void registerMetrics(int metricsId) { - // No metrics for Fabric - } - - @Override - public void initializePluginChannels() { - ServerPlayNetworking.registerGlobalReceiver(new Identifier("bungeecord", "main"), this); - } - - // When the server receives a plugin message - @Override - public void receive(@NotNull MinecraftServer server, @NotNull ServerPlayerEntity player, - @NotNull ServerPlayNetworkHandler handler, @NotNull PacketByteBuf buf, - @NotNull PacketSender responseSender) { - if (broker instanceof PluginMessageBroker messenger - && getSettings().getBrokerType() == Broker.Type.PLUGIN_MESSAGE) { - messenger.onReceive( - PluginMessageBroker.BUNGEE_CHANNEL_ID, - FabricUser.adapt(player, this), - ByteBufUtil.getBytes(buf) - ); - } - } - - @Override - public void log(@NotNull Level level, @NotNull String message, @NotNull Throwable... exceptions) { - LoggingEventBuilder logEvent = LOGGER.makeLoggingEventBuilder( - switch (level.getName()) { - case "WARNING" -> org.slf4j.event.Level.WARN; - case "SEVERE" -> org.slf4j.event.Level.ERROR; - default -> org.slf4j.event.Level.INFO; - } - ); - if (exceptions.length >= 1) { - logEvent = logEvent.setCause(exceptions[0]); - } - logEvent.log(message); - } - - @NotNull - public Map getPermissions() { - return permissions; - } - - @NotNull - public MinecraftServer getMinecraftServer() { - return minecraftServer; - } - - @Override - @NotNull - public FabricHuskHomes getPlugin() { - return this; - } - -} diff --git a/fabric/fabric-1.19.4/src/main/java/net/william278/huskhomes/command/FabricCommand.java b/fabric/fabric-1.19.4/src/main/java/net/william278/huskhomes/command/FabricCommand.java deleted file mode 100644 index cb34e143..00000000 --- a/fabric/fabric-1.19.4/src/main/java/net/william278/huskhomes/command/FabricCommand.java +++ /dev/null @@ -1,181 +0,0 @@ -/* - * This file is part of HuskHomes, licensed under the Apache License 2.0. - * - * Copyright (c) William278 - * Copyright (c) contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.william278.huskhomes.command; - -import com.mojang.brigadier.CommandDispatcher; -import com.mojang.brigadier.builder.LiteralArgumentBuilder; -import com.mojang.brigadier.tree.LiteralCommandNode; -import me.lucko.fabric.api.permissions.v0.PermissionCheckEvent; -import me.lucko.fabric.api.permissions.v0.Permissions; -import net.fabricmc.fabric.api.util.TriState; -import net.minecraft.server.command.ServerCommandSource; -import net.minecraft.server.network.ServerPlayerEntity; -import net.william278.huskhomes.FabricHuskHomes; -import net.william278.huskhomes.HuskHomes; -import net.william278.huskhomes.teleport.TeleportRequest; -import net.william278.huskhomes.user.CommandUser; -import net.william278.huskhomes.user.FabricUser; -import org.jetbrains.annotations.NotNull; - -import java.util.Arrays; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.function.Function; -import java.util.function.Predicate; - -import static com.mojang.brigadier.arguments.StringArgumentType.greedyString; -import static net.minecraft.server.command.CommandManager.argument; -import static net.minecraft.server.command.CommandManager.literal; - -public class FabricCommand { - - private final FabricHuskHomes plugin; - private final Command command; - - public FabricCommand(@NotNull Command command, @NotNull FabricHuskHomes plugin) { - this.command = command; - this.plugin = plugin; - } - - public void register(@NotNull CommandDispatcher dispatcher) { - // Register brigadier command - final Predicate predicate = Permissions - .require(command.getPermission(), command.isOperatorCommand() ? 3 : 0); - final LiteralArgumentBuilder builder = literal(command.getName()) - .requires(predicate).executes(getBrigadierExecutor()); - plugin.getPermissions().put(command.getPermission(), command.isOperatorCommand()); - if (!command.getRawUsage().isBlank()) { - builder.then(argument(command.getRawUsage().replaceAll("[<>\\[\\]]", ""), greedyString()) - .executes(getBrigadierExecutor()) - .suggests(getBrigadierSuggester())); - } - - // Register additional permissions - final Map permissions = command.getAdditionalPermissions(); - permissions.forEach((permission, isOp) -> plugin.getPermissions().put(permission, isOp)); - PermissionCheckEvent.EVENT.register((player, node) -> { - if (permissions.containsKey(node) && permissions.get(node) && player.hasPermissionLevel(3)) { - return TriState.TRUE; - } - return TriState.DEFAULT; - }); - - // Register aliases - final LiteralCommandNode node = dispatcher.register(builder); - dispatcher.register(literal("huskhomes:" + command.getName()) - .requires(predicate).executes(getBrigadierExecutor()).redirect(node)); - command.getAliases().forEach(alias -> dispatcher.register(literal(alias) - .requires(predicate).executes(getBrigadierExecutor()).redirect(node))); - } - - private com.mojang.brigadier.Command getBrigadierExecutor() { - return (context) -> { - command.onExecuted( - resolveExecutor(context.getSource()), - command.removeFirstArg(context.getInput().split(" ")) - ); - return 1; - }; - } - - private com.mojang.brigadier.suggestion.SuggestionProvider getBrigadierSuggester() { - if (!(command instanceof TabProvider provider)) { - return (context, builder) -> com.mojang.brigadier.suggestion.Suggestions.empty(); - } - return (context, builder) -> { - final String[] args = command.removeFirstArg(context.getInput().split(" ")); - provider.getSuggestions(resolveExecutor(context.getSource()), args).stream() - .map(suggestion -> { - final String completedArgs = String.join(" ", args); - int lastIndex = completedArgs.lastIndexOf(" "); - if (lastIndex == -1) { - return suggestion; - } - return completedArgs.substring(0, lastIndex + 1) + suggestion; - }) - .forEach(builder::suggest); - return builder.buildFuture(); - }; - } - - private CommandUser resolveExecutor(@NotNull ServerCommandSource source) { - if (source.getEntity() instanceof ServerPlayerEntity player) { - return FabricUser.adapt(player, plugin); - } - return plugin.getConsole(); - } - - - /** - * Commands available on the Fabric HuskHomes implementation. - */ - public enum Type { - HOME_COMMAND(PrivateHomeCommand::new), - SET_HOME_COMMAND(SetHomeCommand::new), - HOME_LIST_COMMAND(PrivateHomeListCommand::new), - DEL_HOME_COMMAND(DelHomeCommand::new), - EDIT_HOME_COMMAND(EditHomeCommand::new), - PUBLIC_HOME_COMMAND(PublicHomeCommand::new), - PUBLIC_HOME_LIST_COMMAND(PublicHomeListCommand::new), - WARP_COMMAND(WarpCommand::new), - SET_WARP_COMMAND(SetWarpCommand::new), - WARP_LIST_COMMAND(WarpListCommand::new), - DEL_WARP_COMMAND(DelWarpCommand::new), - EDIT_WARP_COMMAND(EditWarpCommand::new), - TP_COMMAND(TpCommand::new), - TP_HERE_COMMAND(TpHereCommand::new), - TPA_COMMAND((plugin) -> new TeleportRequestCommand(plugin, TeleportRequest.Type.TPA)), - TPA_HERE_COMMAND((plugin) -> new TeleportRequestCommand(plugin, TeleportRequest.Type.TPA_HERE)), - TPACCEPT_COMMAND((plugin) -> new TpRespondCommand(plugin, true)), - TPDECLINE_COMMAND((plugin) -> new TpRespondCommand(plugin, false)), - RTP_COMMAND(RtpCommand::new), - TP_IGNORE_COMMAND(TpIgnoreCommand::new), - TP_OFFLINE_COMMAND(TpOfflineCommand::new), - TP_ALL_COMMAND(TpAllCommand::new), - TPA_ALL_COMMAND(TpaAllCommand::new), - SPAWN_COMMAND(SpawnCommand::new), - SET_SPAWN_COMMAND(SetSpawnCommand::new), - BACK_COMMAND(BackCommand::new), - HUSKHOMES_COMMAND(HuskHomesCommand::new); - - private final Function supplier; - - Type(@NotNull Function supplier) { - this.supplier = supplier; - } - - @NotNull - public Command createCommand(@NotNull HuskHomes plugin) { - return supplier.apply(plugin); - } - - @NotNull - public static List getCommands(@NotNull FabricHuskHomes plugin) { - return Arrays.stream(values()) - .map(type -> type.createCommand(plugin)) - .map(command -> plugin.getSettings().isCommandDisabled(command) ? null : command) - .filter(Objects::nonNull) - .toList(); - } - - } - -} diff --git a/fabric/fabric-1.19.4/src/main/java/net/william278/huskhomes/event/DeleteAllHomesCallback.java b/fabric/fabric-1.19.4/src/main/java/net/william278/huskhomes/event/DeleteAllHomesCallback.java deleted file mode 100644 index f84f238d..00000000 --- a/fabric/fabric-1.19.4/src/main/java/net/william278/huskhomes/event/DeleteAllHomesCallback.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * This file is part of HuskHomes, licensed under the Apache License 2.0. - * - * Copyright (c) William278 - * Copyright (c) contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.william278.huskhomes.event; - -import net.fabricmc.fabric.api.event.Event; -import net.fabricmc.fabric.api.event.EventFactory; -import net.minecraft.util.ActionResult; -import net.william278.huskhomes.user.CommandUser; -import net.william278.huskhomes.user.User; -import org.jetbrains.annotations.NotNull; - -import java.util.function.BiFunction; - -public interface DeleteAllHomesCallback extends FabricEventCallback { - - @NotNull - Event EVENT = EventFactory.createArrayBacked(DeleteAllHomesCallback.class, - (listeners) -> (event) -> { - for (DeleteAllHomesCallback listener : listeners) { - final ActionResult result = listener.invoke(event); - if (event.isCancelled()) { - return ActionResult.CONSUME; - } else if (result != ActionResult.PASS) { - event.setCancelled(true); - return result; - } - } - - return ActionResult.PASS; - }); - - @NotNull - BiFunction SUPPLIER = (owner, deleter) -> - new IDeleteAllHomesEvent() { - private boolean cancelled = false; - - @Override - @NotNull - public User getHomeOwner() { - return owner; - } - - @Override - @NotNull - public CommandUser getDeleter() { - return deleter; - } - - @Override - public void setCancelled(boolean cancelled) { - this.cancelled = cancelled; - } - - @Override - public boolean isCancelled() { - return cancelled; - } - - @NotNull - public Event getEvent() { - return EVENT; - } - }; - -} diff --git a/fabric/fabric-1.19.4/src/main/java/net/william278/huskhomes/event/DeleteAllWarpsCallback.java b/fabric/fabric-1.19.4/src/main/java/net/william278/huskhomes/event/DeleteAllWarpsCallback.java deleted file mode 100644 index 78945be9..00000000 --- a/fabric/fabric-1.19.4/src/main/java/net/william278/huskhomes/event/DeleteAllWarpsCallback.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * This file is part of HuskHomes, licensed under the Apache License 2.0. - * - * Copyright (c) William278 - * Copyright (c) contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.william278.huskhomes.event; - -import net.fabricmc.fabric.api.event.Event; -import net.fabricmc.fabric.api.event.EventFactory; -import net.minecraft.util.ActionResult; -import net.william278.huskhomes.user.CommandUser; -import org.jetbrains.annotations.NotNull; - -import java.util.function.Function; - -public interface DeleteAllWarpsCallback extends FabricEventCallback { - - @NotNull - Event EVENT = EventFactory.createArrayBacked(DeleteAllWarpsCallback.class, - (listeners) -> (event) -> { - for (DeleteAllWarpsCallback listener : listeners) { - final ActionResult result = listener.invoke(event); - if (event.isCancelled()) { - return ActionResult.CONSUME; - } else if (result != ActionResult.PASS) { - event.setCancelled(true); - return result; - } - } - - return ActionResult.PASS; - }); - - @NotNull - Function SUPPLIER = (deleter) -> - new IDeleteAllWarpsEvent() { - private boolean cancelled = false; - - @Override - @NotNull - public CommandUser getDeleter() { - return deleter; - } - - @Override - public void setCancelled(boolean cancelled) { - this.cancelled = cancelled; - } - - @Override - public boolean isCancelled() { - return cancelled; - } - - @NotNull - public Event getEvent() { - return EVENT; - } - }; - -} diff --git a/fabric/fabric-1.19.4/src/main/java/net/william278/huskhomes/event/FabricEventCallback.java b/fabric/fabric-1.19.4/src/main/java/net/william278/huskhomes/event/FabricEventCallback.java deleted file mode 100644 index ef0c3a7f..00000000 --- a/fabric/fabric-1.19.4/src/main/java/net/william278/huskhomes/event/FabricEventCallback.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * This file is part of HuskHomes, licensed under the Apache License 2.0. - * - * Copyright (c) William278 - * Copyright (c) contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.william278.huskhomes.event; - -import net.minecraft.util.ActionResult; -import org.jetbrains.annotations.NotNull; - -public interface FabricEventCallback { - - @NotNull - ActionResult invoke(@NotNull E event); - - -} diff --git a/fabric/fabric-1.19.4/src/main/java/net/william278/huskhomes/event/FabricEventDispatcher.java b/fabric/fabric-1.19.4/src/main/java/net/william278/huskhomes/event/FabricEventDispatcher.java deleted file mode 100644 index 25b48705..00000000 --- a/fabric/fabric-1.19.4/src/main/java/net/william278/huskhomes/event/FabricEventDispatcher.java +++ /dev/null @@ -1,146 +0,0 @@ -/* - * This file is part of HuskHomes, licensed under the Apache License 2.0. - * - * Copyright (c) William278 - * Copyright (c) contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.william278.huskhomes.event; - -import net.minecraft.util.ActionResult; -import net.william278.huskhomes.FabricHuskHomes; -import net.william278.huskhomes.position.Home; -import net.william278.huskhomes.position.Position; -import net.william278.huskhomes.position.Warp; -import net.william278.huskhomes.teleport.Teleport; -import net.william278.huskhomes.teleport.TeleportRequest; -import net.william278.huskhomes.teleport.TimedTeleport; -import net.william278.huskhomes.user.CommandUser; -import net.william278.huskhomes.user.OnlineUser; -import net.william278.huskhomes.user.User; -import org.jetbrains.annotations.NotNull; - -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.util.List; -import java.util.logging.Level; - -public interface FabricEventDispatcher extends EventDispatcher { - - @SuppressWarnings("unchecked") - @Override - default boolean fireIsCancelled(@NotNull T event) { - try { - final Method field = event.getClass().getDeclaredMethod("getEvent"); - field.setAccessible(true); - - net.fabricmc.fabric.api.event.Event fabricEvent = - (net.fabricmc.fabric.api.event.Event) field.invoke(event); - - final FabricEventCallback invoker = (FabricEventCallback) fabricEvent.invoker(); - return invoker.invoke(event) == ActionResult.FAIL; - } catch (InvocationTargetException | NoSuchMethodException | IllegalAccessException e) { - getPlugin().log(Level.WARNING, "Failed to fire event (" + event.getClass().getName() + ")", e); - return false; - } - } - - @Override - @NotNull - default ITeleportEvent getTeleportEvent(@NotNull Teleport teleport) { - return TeleportCallback.SUPPLIER.apply(teleport); - } - - @Override - default @NotNull ITeleportWarmupEvent getTeleportWarmupEvent(@NotNull TimedTeleport teleport, int duration) { - return TeleportWarmupCallback.SUPPLIER.apply(teleport, duration); - } - - @Override - default @NotNull ISendTeleportRequestEvent getSendTeleportRequestEvent(@NotNull OnlineUser sender, - @NotNull TeleportRequest request) { - return SendTeleportRequestCallback.SUPPLIER.apply(sender, request); - } - - @Override - default @NotNull IReceiveTeleportRequestEvent getReceiveTeleportRequestEvent(@NotNull OnlineUser recipient, - @NotNull TeleportRequest request) { - return ReceiveTeleportRequestCallback.SUPPLIER.apply(recipient, request); - } - - @Override - default @NotNull IReplyTeleportRequestEvent getReplyTeleportRequestEvent(@NotNull OnlineUser recipient, - @NotNull TeleportRequest request) { - return ReplyTeleportRequestCallback.SUPPLIER.apply(recipient, request); - } - - @Override - default @NotNull IHomeCreateEvent getHomeCreateEvent(@NotNull User owner, @NotNull String name, - @NotNull Position position, @NotNull CommandUser creator) { - return HomeCreateCallback.SUPPLIER.apply(owner, name, position, creator); - } - - @Override - default @NotNull IHomeEditEvent getHomeEditEvent(@NotNull Home home, @NotNull CommandUser editor) { - return HomeEditCallback.SUPPLIER.apply(home, editor); - } - - @Override - default @NotNull IHomeDeleteEvent getHomeDeleteEvent(@NotNull Home home, @NotNull CommandUser deleter) { - return HomeDeleteCallback.SUPPLIER.apply(home, deleter); - } - - @Override - default @NotNull IWarpCreateEvent getWarpCreateEvent(@NotNull String name, @NotNull Position position, - @NotNull CommandUser creator) { - return WarpCreateCallback.SUPPLIER.apply(name, position, creator); - } - - @Override - default @NotNull IWarpEditEvent getWarpEditEvent(@NotNull Warp warp, @NotNull CommandUser editor) { - return WarpEditCallback.SUPPLIER.apply(warp, editor); - } - - @Override - default @NotNull IWarpDeleteEvent getWarpDeleteEvent(@NotNull Warp warp, @NotNull CommandUser deleter) { - return WarpDeleteCallback.SUPPLIER.apply(warp, deleter); - } - - @Override - default @NotNull IHomeListEvent getViewHomeListEvent(@NotNull List homes, @NotNull CommandUser listViewer, - boolean publicHomeList) { - return HomeListCallback.SUPPLIER.apply(homes, listViewer, publicHomeList); - } - - @Override - default @NotNull IWarpListEvent getViewWarpListEvent(@NotNull List homes, @NotNull CommandUser listViewer) { - return WarpListCallback.SUPPLIER.apply(homes, listViewer); - } - - @Override - default @NotNull IDeleteAllHomesEvent getDeleteAllHomesEvent(@NotNull User user, @NotNull CommandUser deleter) { - return DeleteAllHomesCallback.SUPPLIER.apply(user, deleter); - } - - @Override - default @NotNull IDeleteAllWarpsEvent getDeleteAllWarpsEvent(@NotNull CommandUser deleter) { - return DeleteAllWarpsCallback.SUPPLIER.apply(deleter); - } - - @Override - @NotNull - FabricHuskHomes getPlugin(); - -} diff --git a/fabric/fabric-1.19.4/src/main/java/net/william278/huskhomes/event/HomeCreateCallback.java b/fabric/fabric-1.19.4/src/main/java/net/william278/huskhomes/event/HomeCreateCallback.java deleted file mode 100644 index 026ad4b3..00000000 --- a/fabric/fabric-1.19.4/src/main/java/net/william278/huskhomes/event/HomeCreateCallback.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * This file is part of HuskHomes, licensed under the Apache License 2.0. - * - * Copyright (c) William278 - * Copyright (c) contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.william278.huskhomes.event; - -import net.fabricmc.fabric.api.event.Event; -import net.fabricmc.fabric.api.event.EventFactory; -import net.minecraft.data.client.BlockStateVariantMap.QuadFunction; -import net.minecraft.util.ActionResult; -import net.william278.huskhomes.position.Position; -import net.william278.huskhomes.user.CommandUser; -import net.william278.huskhomes.user.User; -import org.jetbrains.annotations.NotNull; - -public interface HomeCreateCallback extends FabricEventCallback { - - @NotNull - Event EVENT = EventFactory.createArrayBacked(HomeCreateCallback.class, - (listeners) -> (event) -> { - for (HomeCreateCallback listener : listeners) { - final ActionResult result = listener.invoke(event); - if (event.isCancelled()) { - return ActionResult.CONSUME; - } else if (result != ActionResult.PASS) { - event.setCancelled(true); - return result; - } - } - - return ActionResult.PASS; - }); - - @NotNull - QuadFunction SUPPLIER = (user, name, position, creator) -> - new IHomeCreateEvent() { - private boolean cancelled = false; - private String homeName = name; - - @Override - @NotNull - public User getOwner() { - return user; - } - - @Override - @NotNull - public String getName() { - return homeName; - } - - @Override - public void setName(@NotNull String name) { - this.homeName = name; - } - - @Override - @NotNull - public Position getPosition() { - return position; - } - - @Override - public void setPosition(@NotNull Position position) { - } - - @Override - public @NotNull CommandUser getCreator() { - return creator; - } - - @Override - public void setCancelled(boolean cancelled) { - this.cancelled = cancelled; - } - - @Override - public boolean isCancelled() { - return cancelled; - } - - @NotNull - public Event getEvent() { - return EVENT; - } - }; - -} diff --git a/fabric/fabric-1.19.4/src/main/java/net/william278/huskhomes/event/HomeDeleteCallback.java b/fabric/fabric-1.19.4/src/main/java/net/william278/huskhomes/event/HomeDeleteCallback.java deleted file mode 100644 index 0f479589..00000000 --- a/fabric/fabric-1.19.4/src/main/java/net/william278/huskhomes/event/HomeDeleteCallback.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * This file is part of HuskHomes, licensed under the Apache License 2.0. - * - * Copyright (c) William278 - * Copyright (c) contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.william278.huskhomes.event; - -import net.fabricmc.fabric.api.event.Event; -import net.fabricmc.fabric.api.event.EventFactory; -import net.minecraft.util.ActionResult; -import net.william278.huskhomes.position.Home; -import net.william278.huskhomes.user.CommandUser; -import org.jetbrains.annotations.NotNull; - -import java.util.function.BiFunction; - -public interface HomeDeleteCallback extends FabricEventCallback { - - @NotNull - Event EVENT = EventFactory.createArrayBacked(HomeDeleteCallback.class, - (listeners) -> (event) -> { - for (HomeDeleteCallback listener : listeners) { - final ActionResult result = listener.invoke(event); - if (event.isCancelled()) { - return ActionResult.CONSUME; - } else if (result != ActionResult.PASS) { - event.setCancelled(true); - return result; - } - } - - return ActionResult.PASS; - }); - - @NotNull - BiFunction SUPPLIER = (home, deleter) -> - new IHomeDeleteEvent() { - private boolean cancelled = false; - - @Override - @NotNull - public Home getHome() { - return home; - } - - @Override - @NotNull - public CommandUser getDeleter() { - return deleter; - } - - @Override - public void setCancelled(boolean cancelled) { - this.cancelled = cancelled; - } - - @Override - public boolean isCancelled() { - return cancelled; - } - - @NotNull - public Event getEvent() { - return EVENT; - } - - }; - -} diff --git a/fabric/fabric-1.19.4/src/main/java/net/william278/huskhomes/event/HomeEditCallback.java b/fabric/fabric-1.19.4/src/main/java/net/william278/huskhomes/event/HomeEditCallback.java deleted file mode 100644 index 3b28f749..00000000 --- a/fabric/fabric-1.19.4/src/main/java/net/william278/huskhomes/event/HomeEditCallback.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * This file is part of HuskHomes, licensed under the Apache License 2.0. - * - * Copyright (c) William278 - * Copyright (c) contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.william278.huskhomes.event; - -import net.fabricmc.fabric.api.event.Event; -import net.fabricmc.fabric.api.event.EventFactory; -import net.minecraft.util.ActionResult; -import net.william278.huskhomes.position.Home; -import net.william278.huskhomes.user.CommandUser; -import org.jetbrains.annotations.NotNull; - -import java.util.function.BiFunction; - -public interface HomeEditCallback extends FabricEventCallback { - - @NotNull - Event EVENT = EventFactory.createArrayBacked(HomeEditCallback.class, - (listeners) -> (event) -> { - for (HomeEditCallback listener : listeners) { - final ActionResult result = listener.invoke(event); - if (event.isCancelled()) { - return ActionResult.CONSUME; - } else if (result != ActionResult.PASS) { - event.setCancelled(true); - return result; - } - } - - return ActionResult.PASS; - }); - - @NotNull - BiFunction SUPPLIER = (home, editor) -> - new IHomeEditEvent() { - private boolean cancelled = false; - - @Override - @NotNull - public Home getHome() { - return home; - } - - @Override - @NotNull - public CommandUser getEditor() { - return editor; - } - - @Override - public void setCancelled(boolean cancelled) { - this.cancelled = cancelled; - } - - @Override - public boolean isCancelled() { - return cancelled; - } - - @NotNull - public Event getEvent() { - return EVENT; - } - - }; - -} diff --git a/fabric/fabric-1.19.4/src/main/java/net/william278/huskhomes/event/HomeListCallback.java b/fabric/fabric-1.19.4/src/main/java/net/william278/huskhomes/event/HomeListCallback.java deleted file mode 100644 index e89d5cb6..00000000 --- a/fabric/fabric-1.19.4/src/main/java/net/william278/huskhomes/event/HomeListCallback.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * This file is part of HuskHomes, licensed under the Apache License 2.0. - * - * Copyright (c) William278 - * Copyright (c) contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.william278.huskhomes.event; - -import net.fabricmc.fabric.api.event.Event; -import net.fabricmc.fabric.api.event.EventFactory; -import net.minecraft.util.ActionResult; -import net.william278.huskhomes.position.Home; -import net.william278.huskhomes.user.CommandUser; -import org.apache.commons.lang3.function.TriFunction; -import org.jetbrains.annotations.NotNull; - -import java.util.List; - -public interface HomeListCallback extends FabricEventCallback { - - @NotNull - Event EVENT = EventFactory.createArrayBacked(HomeListCallback.class, - (listeners) -> (event) -> { - for (HomeListCallback listener : listeners) { - final ActionResult result = listener.invoke(event); - if (event.isCancelled()) { - return ActionResult.CONSUME; - } else if (result != ActionResult.PASS) { - event.setCancelled(true); - return result; - } - } - - return ActionResult.PASS; - }); - - @NotNull - TriFunction, CommandUser, Boolean, IHomeListEvent> SUPPLIER = (homes, viewer, publicHomes) -> - new IHomeListEvent() { - private boolean cancelled = false; - private List listHomes = homes; - - @Override - @NotNull - public List getHomes() { - return listHomes; - } - - @Override - public void setHomes(@NotNull List homes) { - this.listHomes = homes; - } - - @Override - @NotNull - public CommandUser getListViewer() { - return viewer; - } - - @Override - public boolean getIsPublicHomeList() { - return publicHomes; - } - - @Override - public void setCancelled(boolean cancelled) { - this.cancelled = cancelled; - } - - @Override - public boolean isCancelled() { - return cancelled; - } - - @NotNull - public Event getEvent() { - return EVENT; - } - - }; - -} diff --git a/fabric/fabric-1.19.4/src/main/java/net/william278/huskhomes/event/ReceiveTeleportRequestCallback.java b/fabric/fabric-1.19.4/src/main/java/net/william278/huskhomes/event/ReceiveTeleportRequestCallback.java deleted file mode 100644 index a0b4da5a..00000000 --- a/fabric/fabric-1.19.4/src/main/java/net/william278/huskhomes/event/ReceiveTeleportRequestCallback.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * This file is part of HuskHomes, licensed under the Apache License 2.0. - * - * Copyright (c) William278 - * Copyright (c) contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.william278.huskhomes.event; - -import net.fabricmc.fabric.api.event.Event; -import net.fabricmc.fabric.api.event.EventFactory; -import net.minecraft.util.ActionResult; -import net.william278.huskhomes.teleport.TeleportRequest; -import net.william278.huskhomes.user.OnlineUser; -import org.jetbrains.annotations.NotNull; - -import java.util.function.BiFunction; - -public interface ReceiveTeleportRequestCallback extends FabricEventCallback { - - @NotNull - Event EVENT = EventFactory.createArrayBacked(ReceiveTeleportRequestCallback.class, - (listeners) -> (event) -> { - for (ReceiveTeleportRequestCallback listener : listeners) { - final ActionResult result = listener.invoke(event); - if (event.isCancelled()) { - return ActionResult.CONSUME; - } else if (result != ActionResult.PASS) { - event.setCancelled(true); - return result; - } - } - - return ActionResult.PASS; - }); - - @NotNull - BiFunction SUPPLIER = (recipient, request) -> - new IReceiveTeleportRequestEvent() { - private boolean cancelled = false; - - @Override - @NotNull - public OnlineUser getRecipient() { - return recipient; - } - - @Override - @NotNull - public TeleportRequest getRequest() { - return request; - } - - @Override - public void setCancelled(boolean cancelled) { - this.cancelled = cancelled; - } - - @Override - public boolean isCancelled() { - return cancelled; - } - - @NotNull - public Event getEvent() { - return EVENT; - } - - }; - -} diff --git a/fabric/fabric-1.19.4/src/main/java/net/william278/huskhomes/event/ReplyTeleportRequestCallback.java b/fabric/fabric-1.19.4/src/main/java/net/william278/huskhomes/event/ReplyTeleportRequestCallback.java deleted file mode 100644 index 85dcddb8..00000000 --- a/fabric/fabric-1.19.4/src/main/java/net/william278/huskhomes/event/ReplyTeleportRequestCallback.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * This file is part of HuskHomes, licensed under the Apache License 2.0. - * - * Copyright (c) William278 - * Copyright (c) contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.william278.huskhomes.event; - -import net.fabricmc.fabric.api.event.Event; -import net.fabricmc.fabric.api.event.EventFactory; -import net.minecraft.util.ActionResult; -import net.william278.huskhomes.teleport.TeleportRequest; -import net.william278.huskhomes.user.OnlineUser; -import org.jetbrains.annotations.NotNull; - -import java.util.function.BiFunction; - -public interface ReplyTeleportRequestCallback extends FabricEventCallback { - - @NotNull - Event EVENT = EventFactory.createArrayBacked(ReplyTeleportRequestCallback.class, - (listeners) -> (event) -> { - for (ReplyTeleportRequestCallback listener : listeners) { - final ActionResult result = listener.invoke(event); - if (event.isCancelled()) { - return ActionResult.CONSUME; - } else if (result != ActionResult.PASS) { - event.setCancelled(true); - return result; - } - } - - return ActionResult.PASS; - }); - - @NotNull - BiFunction SUPPLIER = (recipient, request) -> - new IReplyTeleportRequestEvent() { - private boolean cancelled = false; - - @Override - @NotNull - public OnlineUser getRecipient() { - return recipient; - } - - @Override - @NotNull - public TeleportRequest getRequest() { - return request; - } - - @Override - public void setCancelled(boolean cancelled) { - this.cancelled = cancelled; - } - - @Override - public boolean isCancelled() { - return cancelled; - } - - @NotNull - public Event getEvent() { - return EVENT; - } - - }; - -} diff --git a/fabric/fabric-1.19.4/src/main/java/net/william278/huskhomes/event/SendTeleportRequestCallback.java b/fabric/fabric-1.19.4/src/main/java/net/william278/huskhomes/event/SendTeleportRequestCallback.java deleted file mode 100644 index d7fd6505..00000000 --- a/fabric/fabric-1.19.4/src/main/java/net/william278/huskhomes/event/SendTeleportRequestCallback.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * This file is part of HuskHomes, licensed under the Apache License 2.0. - * - * Copyright (c) William278 - * Copyright (c) contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.william278.huskhomes.event; - -import net.fabricmc.fabric.api.event.Event; -import net.fabricmc.fabric.api.event.EventFactory; -import net.minecraft.util.ActionResult; -import net.william278.huskhomes.teleport.TeleportRequest; -import net.william278.huskhomes.user.OnlineUser; -import org.jetbrains.annotations.NotNull; - -import java.util.function.BiFunction; - -public interface SendTeleportRequestCallback extends FabricEventCallback { - - @NotNull - Event EVENT = EventFactory.createArrayBacked(SendTeleportRequestCallback.class, - (listeners) -> (event) -> { - for (SendTeleportRequestCallback listener : listeners) { - final ActionResult result = listener.invoke(event); - if (event.isCancelled()) { - return ActionResult.CONSUME; - } else if (result != ActionResult.PASS) { - event.setCancelled(true); - return result; - } - } - - return ActionResult.PASS; - }); - - @NotNull - BiFunction SUPPLIER = (sender, request) -> - new ISendTeleportRequestEvent() { - private boolean cancelled = false; - - @Override - @NotNull - public OnlineUser getSender() { - return sender; - } - - @Override - @NotNull - public TeleportRequest getRequest() { - return request; - } - - @Override - public void setCancelled(boolean cancelled) { - this.cancelled = cancelled; - } - - @Override - public boolean isCancelled() { - return cancelled; - } - - @NotNull - public Event getEvent() { - return EVENT; - } - - }; - -} diff --git a/fabric/fabric-1.19.4/src/main/java/net/william278/huskhomes/event/TeleportBackCallback.java b/fabric/fabric-1.19.4/src/main/java/net/william278/huskhomes/event/TeleportBackCallback.java deleted file mode 100644 index 90a153c6..00000000 --- a/fabric/fabric-1.19.4/src/main/java/net/william278/huskhomes/event/TeleportBackCallback.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * This file is part of HuskHomes, licensed under the Apache License 2.0. - * - * Copyright (c) William278 - * Copyright (c) contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.william278.huskhomes.event; - -import net.fabricmc.fabric.api.event.Event; -import net.fabricmc.fabric.api.event.EventFactory; -import net.minecraft.util.ActionResult; -import net.william278.huskhomes.position.Position; -import net.william278.huskhomes.teleport.Teleport; -import org.jetbrains.annotations.NotNull; - -import java.util.function.Function; - -public interface TeleportBackCallback extends FabricEventCallback { - - @NotNull - Event EVENT = EventFactory.createArrayBacked(TeleportBackCallback.class, - (listeners) -> (event) -> { - for (TeleportBackCallback listener : listeners) { - final ActionResult result = listener.invoke(event); - if (event.isCancelled()) { - return ActionResult.FAIL; - } else if (result == ActionResult.FAIL) { - event.setCancelled(true); - return result; - } - } - - return ActionResult.PASS; - }); - - @NotNull - Function SUPPLIER = (teleport) -> - new ITeleportBackEvent() { - private boolean cancelled = false; - - @Override - @NotNull - public Position getLastPosition() { - return (Position) getTeleport().getTarget(); - } - - @Override - @NotNull - public Teleport getTeleport() { - return teleport; - } - - @Override - public void setCancelled(boolean cancelled) { - this.cancelled = cancelled; - } - - @Override - public boolean isCancelled() { - return cancelled; - } - - @NotNull - public Event getEvent() { - return EVENT; - } - - }; - -} diff --git a/fabric/fabric-1.19.4/src/main/java/net/william278/huskhomes/event/TeleportCallback.java b/fabric/fabric-1.19.4/src/main/java/net/william278/huskhomes/event/TeleportCallback.java deleted file mode 100644 index 99a7cc6b..00000000 --- a/fabric/fabric-1.19.4/src/main/java/net/william278/huskhomes/event/TeleportCallback.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * This file is part of HuskHomes, licensed under the Apache License 2.0. - * - * Copyright (c) William278 - * Copyright (c) contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.william278.huskhomes.event; - -import net.fabricmc.fabric.api.event.Event; -import net.fabricmc.fabric.api.event.EventFactory; -import net.minecraft.util.ActionResult; -import net.william278.huskhomes.teleport.Teleport; -import org.jetbrains.annotations.NotNull; - -import java.util.function.Function; - -public interface TeleportCallback extends FabricEventCallback { - - @NotNull - Event EVENT = EventFactory.createArrayBacked(TeleportCallback.class, - (listeners) -> (event) -> { - for (TeleportCallback listener : listeners) { - final ActionResult result = listener.invoke(event); - if (event.isCancelled()) { - return ActionResult.FAIL; - } else if (result == ActionResult.FAIL) { - event.setCancelled(true); - return result; - } - } - - return ActionResult.PASS; - }); - - @NotNull - Function SUPPLIER = (teleport) -> - new ITeleportEvent() { - private boolean cancelled = false; - - @Override - @NotNull - public Teleport getTeleport() { - return teleport; - } - - @Override - public void setCancelled(boolean cancelled) { - this.cancelled = cancelled; - } - - @Override - public boolean isCancelled() { - return cancelled; - } - - @NotNull - public Event getEvent() { - return EVENT; - } - - }; - -} diff --git a/fabric/fabric-1.19.4/src/main/java/net/william278/huskhomes/event/TeleportWarmupCallback.java b/fabric/fabric-1.19.4/src/main/java/net/william278/huskhomes/event/TeleportWarmupCallback.java deleted file mode 100644 index c9d6961c..00000000 --- a/fabric/fabric-1.19.4/src/main/java/net/william278/huskhomes/event/TeleportWarmupCallback.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * This file is part of HuskHomes, licensed under the Apache License 2.0. - * - * Copyright (c) William278 - * Copyright (c) contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.william278.huskhomes.event; - -import net.fabricmc.fabric.api.event.Event; -import net.fabricmc.fabric.api.event.EventFactory; -import net.minecraft.util.ActionResult; -import net.william278.huskhomes.teleport.TimedTeleport; -import org.jetbrains.annotations.NotNull; - -import java.util.function.BiFunction; - -public interface TeleportWarmupCallback extends FabricEventCallback { - @NotNull - Event EVENT = EventFactory.createArrayBacked(TeleportWarmupCallback.class, - (listeners) -> (event) -> { - for (TeleportWarmupCallback listener : listeners) { - final ActionResult result = listener.invoke(event); - if (event.isCancelled()) { - return ActionResult.FAIL; - } else if (result == ActionResult.FAIL) { - event.setCancelled(true); - return result; - } - } - - return ActionResult.PASS; - }); - - @NotNull - BiFunction SUPPLIER = (timedTeleport, duration) -> - new ITeleportWarmupEvent() { - private boolean cancelled = false; - - @Override - @NotNull - public TimedTeleport getTimedTeleport() { - return timedTeleport; - } - - @Override - public int getWarmupDuration() { - return duration; - } - - @Override - public void setCancelled(boolean cancelled) { - this.cancelled = cancelled; - } - - @Override - public boolean isCancelled() { - return cancelled; - } - - @NotNull - public Event getEvent() { - return EVENT; - } - - }; -} diff --git a/fabric/fabric-1.19.4/src/main/java/net/william278/huskhomes/event/WarpCreateCallback.java b/fabric/fabric-1.19.4/src/main/java/net/william278/huskhomes/event/WarpCreateCallback.java deleted file mode 100644 index 78b69dc9..00000000 --- a/fabric/fabric-1.19.4/src/main/java/net/william278/huskhomes/event/WarpCreateCallback.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * This file is part of HuskHomes, licensed under the Apache License 2.0. - * - * Copyright (c) William278 - * Copyright (c) contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.william278.huskhomes.event; - -import net.fabricmc.fabric.api.event.Event; -import net.fabricmc.fabric.api.event.EventFactory; -import net.minecraft.util.ActionResult; -import net.william278.huskhomes.position.Position; -import net.william278.huskhomes.user.CommandUser; -import org.apache.commons.lang3.function.TriFunction; -import org.jetbrains.annotations.NotNull; - -public interface WarpCreateCallback extends FabricEventCallback { - - @NotNull - Event EVENT = EventFactory.createArrayBacked(WarpCreateCallback.class, - (listeners) -> (event) -> { - for (WarpCreateCallback listener : listeners) { - final ActionResult result = listener.invoke(event); - if (event.isCancelled()) { - return ActionResult.CONSUME; - } else if (result != ActionResult.PASS) { - event.setCancelled(true); - return result; - } - } - - return ActionResult.PASS; - }); - - @NotNull - TriFunction SUPPLIER = (name, position, creator) -> - new IWarpCreateEvent() { - private boolean cancelled = false; - private String homeName = name; - - @Override - @NotNull - public String getName() { - return homeName; - } - - @Override - public void setName(@NotNull String name) { - this.homeName = name; - } - - @Override - @NotNull - public Position getPosition() { - return position; - } - - @Override - public void setPosition(@NotNull Position position) { - } - - @Override - @NotNull - public CommandUser getCreator() { - return creator; - } - - @Override - public void setCancelled(boolean cancelled) { - this.cancelled = cancelled; - } - - @Override - public boolean isCancelled() { - return cancelled; - } - - @NotNull - public Event getEvent() { - return EVENT; - } - - }; - -} diff --git a/fabric/fabric-1.19.4/src/main/java/net/william278/huskhomes/event/WarpDeleteCallback.java b/fabric/fabric-1.19.4/src/main/java/net/william278/huskhomes/event/WarpDeleteCallback.java deleted file mode 100644 index cbba72ea..00000000 --- a/fabric/fabric-1.19.4/src/main/java/net/william278/huskhomes/event/WarpDeleteCallback.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * This file is part of HuskHomes, licensed under the Apache License 2.0. - * - * Copyright (c) William278 - * Copyright (c) contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.william278.huskhomes.event; - -import net.fabricmc.fabric.api.event.Event; -import net.fabricmc.fabric.api.event.EventFactory; -import net.minecraft.util.ActionResult; -import net.william278.huskhomes.position.Warp; -import net.william278.huskhomes.user.CommandUser; -import org.jetbrains.annotations.NotNull; - -import java.util.function.BiFunction; - -public interface WarpDeleteCallback extends FabricEventCallback { - - @NotNull - Event EVENT = EventFactory.createArrayBacked(WarpDeleteCallback.class, - (listeners) -> (event) -> { - for (WarpDeleteCallback listener : listeners) { - final ActionResult result = listener.invoke(event); - if (event.isCancelled()) { - return ActionResult.CONSUME; - } else if (result != ActionResult.PASS) { - event.setCancelled(true); - return result; - } - } - - return ActionResult.PASS; - }); - - @NotNull - BiFunction SUPPLIER = (warp, deleter) -> - new IWarpDeleteEvent() { - private boolean cancelled = false; - - @Override - @NotNull - public Warp getWarp() { - return warp; - } - - @Override - @NotNull - public CommandUser getDeleter() { - return deleter; - } - - @Override - public void setCancelled(boolean cancelled) { - this.cancelled = cancelled; - } - - @Override - public boolean isCancelled() { - return cancelled; - } - - @NotNull - public Event getEvent() { - return EVENT; - } - - }; - -} diff --git a/fabric/fabric-1.19.4/src/main/java/net/william278/huskhomes/event/WarpEditCallback.java b/fabric/fabric-1.19.4/src/main/java/net/william278/huskhomes/event/WarpEditCallback.java deleted file mode 100644 index d3291d91..00000000 --- a/fabric/fabric-1.19.4/src/main/java/net/william278/huskhomes/event/WarpEditCallback.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * This file is part of HuskHomes, licensed under the Apache License 2.0. - * - * Copyright (c) William278 - * Copyright (c) contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.william278.huskhomes.event; - -import net.fabricmc.fabric.api.event.Event; -import net.fabricmc.fabric.api.event.EventFactory; -import net.minecraft.util.ActionResult; -import net.william278.huskhomes.position.Warp; -import net.william278.huskhomes.user.CommandUser; -import org.jetbrains.annotations.NotNull; - -import java.util.function.BiFunction; - -public interface WarpEditCallback extends FabricEventCallback { - - @NotNull - Event EVENT = EventFactory.createArrayBacked(WarpEditCallback.class, - (listeners) -> (event) -> { - for (WarpEditCallback listener : listeners) { - final ActionResult result = listener.invoke(event); - if (event.isCancelled()) { - return ActionResult.CONSUME; - } else if (result != ActionResult.PASS) { - event.setCancelled(true); - return result; - } - } - - return ActionResult.PASS; - }); - - @NotNull - BiFunction SUPPLIER = (warp, editor) -> - new IWarpEditEvent() { - private boolean cancelled = false; - - @Override - @NotNull - public Warp getWarp() { - return warp; - } - - @Override - @NotNull - public CommandUser getEditor() { - return editor; - } - - @Override - public void setCancelled(boolean cancelled) { - this.cancelled = cancelled; - } - - @Override - public boolean isCancelled() { - return cancelled; - } - - @NotNull - public Event getEvent() { - return EVENT; - } - - }; - -} diff --git a/fabric/fabric-1.19.4/src/main/java/net/william278/huskhomes/event/WarpListCallback.java b/fabric/fabric-1.19.4/src/main/java/net/william278/huskhomes/event/WarpListCallback.java deleted file mode 100644 index 21f2a55f..00000000 --- a/fabric/fabric-1.19.4/src/main/java/net/william278/huskhomes/event/WarpListCallback.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * This file is part of HuskHomes, licensed under the Apache License 2.0. - * - * Copyright (c) William278 - * Copyright (c) contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.william278.huskhomes.event; - -import net.fabricmc.fabric.api.event.Event; -import net.fabricmc.fabric.api.event.EventFactory; -import net.minecraft.util.ActionResult; -import net.william278.huskhomes.position.Warp; -import net.william278.huskhomes.user.CommandUser; -import org.jetbrains.annotations.NotNull; - -import java.util.List; -import java.util.function.BiFunction; - -public interface WarpListCallback extends FabricEventCallback { - - @NotNull - Event EVENT = EventFactory.createArrayBacked(WarpListCallback.class, - (listeners) -> (event) -> { - for (WarpListCallback listener : listeners) { - final ActionResult result = listener.invoke(event); - if (event.isCancelled()) { - return ActionResult.CONSUME; - } else if (result != ActionResult.PASS) { - event.setCancelled(true); - return result; - } - } - - return ActionResult.PASS; - }); - - @NotNull - BiFunction, CommandUser, IWarpListEvent> SUPPLIER = (warps, viewer) -> - new IWarpListEvent() { - private boolean cancelled = false; - private List listWarps = warps; - - @Override - @NotNull - public List getWarps() { - return listWarps; - } - - @Override - public void setWarps(@NotNull List homes) { - this.listWarps = homes; - } - - @Override - @NotNull - public CommandUser getListViewer() { - return viewer; - } - - @Override - public void setCancelled(boolean cancelled) { - this.cancelled = cancelled; - } - - @Override - public boolean isCancelled() { - return cancelled; - } - - @NotNull - public Event getEvent() { - return EVENT; - } - - }; - -} diff --git a/fabric/fabric-1.19.4/src/main/java/net/william278/huskhomes/listener/FabricEventListener.java b/fabric/fabric-1.19.4/src/main/java/net/william278/huskhomes/listener/FabricEventListener.java deleted file mode 100644 index ba97ce55..00000000 --- a/fabric/fabric-1.19.4/src/main/java/net/william278/huskhomes/listener/FabricEventListener.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * This file is part of HuskHomes, licensed under the Apache License 2.0. - * - * Copyright (c) William278 - * Copyright (c) contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.william278.huskhomes.listener; - -import net.fabricmc.fabric.api.entity.event.v1.ServerLivingEntityEvents; -import net.fabricmc.fabric.api.entity.event.v1.ServerPlayerEvents; -import net.fabricmc.fabric.api.networking.v1.ServerPlayConnectionEvents; -import net.minecraft.server.network.ServerPlayerEntity; -import net.william278.huskhomes.FabricHuskHomes; -import net.william278.huskhomes.user.FabricUser; -import org.jetbrains.annotations.NotNull; - -// Note that the teleport event and update player respawn position events are not handled on Fabric. -// The "update last position on teleport event" and "global respawn" features are not supported on Fabric. -public class FabricEventListener extends EventListener { - - public FabricEventListener(@NotNull FabricHuskHomes plugin) { - super(plugin); - this.registerEvents(plugin); - } - - // Register fabric event callback listeners to internal handlers - private void registerEvents(@NotNull FabricHuskHomes plugin) { - // Join event - ServerPlayConnectionEvents.JOIN.register((handler, sender, server) -> handlePlayerJoin( - FabricUser.adapt(handler.player, plugin) - )); - - // Quit event - ServerPlayConnectionEvents.DISCONNECT.register((handler, server) -> handlePlayerLeave( - FabricUser.adapt(handler.player, plugin) - )); - - // Death event - ServerLivingEntityEvents.AFTER_DEATH.register((entity, source) -> { - if (entity instanceof ServerPlayerEntity player) { - handlePlayerDeath(FabricUser.adapt(player, plugin)); - } - }); - - // Respawn event - ServerPlayerEvents.AFTER_RESPAWN.register((oldPlayer, newPlayer, alive) -> handlePlayerRespawn( - FabricUser.adapt(newPlayer, plugin) - )); - } - -} diff --git a/fabric/fabric-1.19.4/src/main/java/net/william278/huskhomes/user/FabricUser.java b/fabric/fabric-1.19.4/src/main/java/net/william278/huskhomes/user/FabricUser.java deleted file mode 100644 index 08984144..00000000 --- a/fabric/fabric-1.19.4/src/main/java/net/william278/huskhomes/user/FabricUser.java +++ /dev/null @@ -1,166 +0,0 @@ -/* - * This file is part of HuskHomes, licensed under the Apache License 2.0. - * - * Copyright (c) William278 - * Copyright (c) contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.william278.huskhomes.user; - -import me.lucko.fabric.api.permissions.v0.Permissions; -import net.fabricmc.fabric.api.networking.v1.PacketByteBufs; -import net.kyori.adventure.audience.Audience; -import net.minecraft.network.PacketByteBuf; -import net.minecraft.network.packet.s2c.play.CustomPayloadS2CPacket; -import net.minecraft.server.MinecraftServer; -import net.minecraft.server.network.ServerPlayerEntity; -import net.minecraft.util.Identifier; -import net.minecraft.util.math.BlockPos; -import net.william278.huskhomes.FabricHuskHomes; -import net.william278.huskhomes.position.Location; -import net.william278.huskhomes.position.Position; -import net.william278.huskhomes.position.World; -import net.william278.huskhomes.teleport.TeleportationException; -import org.jetbrains.annotations.NotNull; - -import java.util.*; - -public class FabricUser extends OnlineUser { - - private final FabricHuskHomes plugin; - private final ServerPlayerEntity player; - - private FabricUser(@NotNull ServerPlayerEntity player, @NotNull FabricHuskHomes plugin) { - super(player.getUuid(), player.getEntityName()); - this.player = player; - this.plugin = plugin; - } - - @NotNull - public static FabricUser adapt(@NotNull ServerPlayerEntity player, @NotNull FabricHuskHomes plugin) { - return new FabricUser(player, plugin); - } - - @Override - public Position getPosition() { - return Position.at( - player.getX(), player.getY(), player.getZ(), - player.getYaw(), player.getPitch(), - World.from( - player.getWorld().getRegistryKey().getValue().asString(), - UUID.nameUUIDFromBytes(player.getWorld().getRegistryKey().getValue().asString().getBytes()) - ), - plugin.getServerName() - ); - } - - @Override - public Optional getBedSpawnPosition() { - final BlockPos spawn = player.getSpawnPointPosition(); - if (spawn == null) { - return Optional.empty(); - } - - return Optional.of(Position.at( - spawn.getX(), spawn.getY(), spawn.getZ(), - player.getSpawnAngle(), 0, - World.from( - player.getSpawnPointDimension().getValue().asString(), - UUID.nameUUIDFromBytes(player.getSpawnPointDimension().getValue().asString().getBytes()) - ), - plugin.getServerName() - )); - } - - @Override - public double getHealth() { - return player.getHealth(); - } - - @Override - public boolean hasPermission(@NotNull String node) { - final boolean requiresOp = Boolean.TRUE.equals(plugin.getPermissions().getOrDefault(node, true)); - return Permissions.check(player, node, !requiresOp || player.hasPermissionLevel(3)); - } - - @Override - @NotNull - public Map getPermissions() { - return plugin.getPermissions().entrySet().stream() - .filter(entry -> Permissions.check(player, entry.getKey(), entry.getValue())) - .collect(HashMap::new, (map, entry) -> map.put(entry.getKey(), entry.getValue()), HashMap::putAll); - } - - @Override - @NotNull - protected List getNumericalPermissions(@NotNull String nodePrefix) { - final List permissions = new ArrayList<>(); - for (int i = 0; i < 100; i++) { - if (hasPermission(nodePrefix + i)) { - permissions.add(i); - } - } - return permissions.stream().sorted(Collections.reverseOrder()).toList(); - } - - @Override - @NotNull - public Audience getAudience() { - return player; - } - - @Override - public void teleportLocally(@NotNull Location location, boolean async) throws TeleportationException { - final MinecraftServer server = player.getServer(); - assert server != null : "Server is null"; - final Identifier worldId = Identifier.tryParse(location.getWorld().getName()); - player.teleport( - server.getWorld(server.getWorldRegistryKeys().stream() - .filter(key -> key.getValue().equals(worldId)).findFirst().orElseThrow( - () -> new TeleportationException(TeleportationException.Type.WORLD_NOT_FOUND, plugin)) - ), - location.getX(), location.getY(), location.getZ(), - location.getYaw(), location.getPitch() - ); - } - - @Override - public void sendPluginMessage(@NotNull String channel, byte[] message) { - final PacketByteBuf buf = PacketByteBufs.create(); - buf.writeBytes(message); - final CustomPayloadS2CPacket packet = new CustomPayloadS2CPacket(parseIdentifier(channel), buf); - player.networkHandler.sendPacket(packet); - } - - @Override - public boolean isMoving() { - return player.isTouchingWater() || player.isFallFlying() || player.isSprinting() || player.isSneaking(); - } - - @Override - public boolean isVanished() { - return false; - } - - @NotNull - private static Identifier parseIdentifier(@NotNull String channel) { - if (channel.equals("BungeeCord")) { - return new Identifier("bungeecord", "main"); - } - return Optional.ofNullable(Identifier.tryParse(channel)) - .orElseThrow(() -> new IllegalArgumentException("Invalid channel name: " + channel)); - } - -} diff --git a/fabric/fabric-1.19.4/src/main/java/net/william278/huskhomes/util/FabricTask.java b/fabric/fabric-1.19.4/src/main/java/net/william278/huskhomes/util/FabricTask.java deleted file mode 100644 index fdf8a1fc..00000000 --- a/fabric/fabric-1.19.4/src/main/java/net/william278/huskhomes/util/FabricTask.java +++ /dev/null @@ -1,132 +0,0 @@ -/* - * This file is part of HuskHomes, licensed under the Apache License 2.0. - * - * Copyright (c) William278 - * Copyright (c) contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.william278.huskhomes.util; - -import net.william278.huskhomes.FabricHuskHomes; -import net.william278.huskhomes.HuskHomes; -import org.jetbrains.annotations.NotNull; - -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.Executors; -import java.util.concurrent.ScheduledFuture; -import java.util.concurrent.TimeUnit; - -public interface FabricTask extends Task { - - class Sync extends Task.Sync implements FabricTask { - - protected Sync(@NotNull HuskHomes plugin, @NotNull Runnable runnable, long delayTicks) { - super(plugin, runnable, delayTicks); - } - - @Override - public void cancel() { - super.cancel(); - } - - @Override - public void run() { - if (!cancelled) { - Executors.newSingleThreadScheduledExecutor().schedule( - () -> ((FabricHuskHomes) getPlugin()).getMinecraftServer().executeSync(runnable), - delayTicks * 50, - TimeUnit.MILLISECONDS - ); - } - } - } - - class Async extends Task.Async implements FabricTask { - private CompletableFuture task; - - protected Async(@NotNull HuskHomes plugin, @NotNull Runnable runnable) { - super(plugin, runnable); - } - - @Override - public void cancel() { - if (task != null && !cancelled) { - task.cancel(true); - } - super.cancel(); - } - - @Override - public void run() { - if (!cancelled) { - this.task = CompletableFuture.runAsync(runnable, ((FabricHuskHomes) getPlugin()).getMinecraftServer()); - } - } - } - - class Repeating extends Task.Repeating implements FabricTask { - - private ScheduledFuture task; - - protected Repeating(@NotNull HuskHomes plugin, @NotNull Runnable runnable, long repeatingTicks) { - super(plugin, runnable, repeatingTicks); - } - - @Override - public void cancel() { - if (task != null && !cancelled) { - task.cancel(true); - } - super.cancel(); - } - - @Override - public void run() { - if (!cancelled) { - this.task = Executors.newSingleThreadScheduledExecutor().scheduleAtFixedRate( - runnable, 0, repeatingTicks * 50, TimeUnit.MILLISECONDS - ); - } - } - } - - interface Supplier extends Task.Supplier { - - @NotNull - @Override - default Task.Sync getSyncTask(@NotNull Runnable runnable, long delayTicks) { - return new Sync(getPlugin(), runnable, delayTicks); - } - - @NotNull - @Override - default Task.Async getAsyncTask(@NotNull Runnable runnable) { - return new Async(getPlugin(), runnable); - } - - @NotNull - @Override - default Task.Repeating getRepeatingTask(@NotNull Runnable runnable, long repeatingTicks) { - return new Repeating(getPlugin(), runnable, repeatingTicks); - } - - @Override - default void cancelTasks() { - // Do nothing - } - - } - -} diff --git a/fabric/fabric-1.19.4/src/main/resources/assets/huskhomes/icon.png b/fabric/fabric-1.19.4/src/main/resources/assets/huskhomes/icon.png deleted file mode 100644 index 7c79c219..00000000 Binary files a/fabric/fabric-1.19.4/src/main/resources/assets/huskhomes/icon.png and /dev/null differ diff --git a/fabric/fabric-1.19.4/src/main/resources/fabric.mod.json b/fabric/fabric-1.19.4/src/main/resources/fabric.mod.json deleted file mode 100644 index 5c57dfef..00000000 --- a/fabric/fabric-1.19.4/src/main/resources/fabric.mod.json +++ /dev/null @@ -1,37 +0,0 @@ -{ - "schemaVersion": 1, - "id": "huskhomes", - "version": "${version}", - "name": "HuskHomes", - "icon": "assets/huskhomes/icon.png", - "description": "${description}", - "authors": [ - { - "name": "William278", - "contact": { - "sources": "https://github.com/WiIIiam278/", - "homepage": "https://william278.net/" - } - } - ], - "license": "Apache-2.0", - "contact": { - "homepage": "https://william278.net/project/huskhomes/", - "repo": "https://github.com/WiIIiam278/HuskHomes", - "issues": "https://github.com/WiIIiam278/HuskHomes/issues" - }, - "environment": "server", - "entrypoints": { - "server": [ - "net.william278.huskhomes.FabricHuskHomes" - ] - }, - "depends": { - "fabricloader": ">=${fabric_loader_version}", - "minecraft": ">=${fabric_minecraft_version}", - "fabric-api": "*" - }, - "custom": { - "modmenu:api": true - } -} \ No newline at end of file diff --git a/fabric/fabric-1.20.1/gradle.properties b/fabric/fabric-1.20.1/gradle.properties deleted file mode 100644 index 32f6e0ce..00000000 --- a/fabric/fabric-1.20.1/gradle.properties +++ /dev/null @@ -1,6 +0,0 @@ -fabric_minecraft_version=1.20.1 -fabric_loader_version=0.14.21 -fabric_yarn_mappings=1.20.1+build.2 -fabric_api_version=0.83.1+1.20.1 - -adventure_platform_fabric_version=5.9.0-SNAPSHOT \ No newline at end of file diff --git a/fabric/fabric-1.20.1/src/main/java/net/william278/huskhomes/command/FabricCommand.java b/fabric/fabric-1.20.1/src/main/java/net/william278/huskhomes/command/FabricCommand.java deleted file mode 100644 index cb34e143..00000000 --- a/fabric/fabric-1.20.1/src/main/java/net/william278/huskhomes/command/FabricCommand.java +++ /dev/null @@ -1,181 +0,0 @@ -/* - * This file is part of HuskHomes, licensed under the Apache License 2.0. - * - * Copyright (c) William278 - * Copyright (c) contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.william278.huskhomes.command; - -import com.mojang.brigadier.CommandDispatcher; -import com.mojang.brigadier.builder.LiteralArgumentBuilder; -import com.mojang.brigadier.tree.LiteralCommandNode; -import me.lucko.fabric.api.permissions.v0.PermissionCheckEvent; -import me.lucko.fabric.api.permissions.v0.Permissions; -import net.fabricmc.fabric.api.util.TriState; -import net.minecraft.server.command.ServerCommandSource; -import net.minecraft.server.network.ServerPlayerEntity; -import net.william278.huskhomes.FabricHuskHomes; -import net.william278.huskhomes.HuskHomes; -import net.william278.huskhomes.teleport.TeleportRequest; -import net.william278.huskhomes.user.CommandUser; -import net.william278.huskhomes.user.FabricUser; -import org.jetbrains.annotations.NotNull; - -import java.util.Arrays; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.function.Function; -import java.util.function.Predicate; - -import static com.mojang.brigadier.arguments.StringArgumentType.greedyString; -import static net.minecraft.server.command.CommandManager.argument; -import static net.minecraft.server.command.CommandManager.literal; - -public class FabricCommand { - - private final FabricHuskHomes plugin; - private final Command command; - - public FabricCommand(@NotNull Command command, @NotNull FabricHuskHomes plugin) { - this.command = command; - this.plugin = plugin; - } - - public void register(@NotNull CommandDispatcher dispatcher) { - // Register brigadier command - final Predicate predicate = Permissions - .require(command.getPermission(), command.isOperatorCommand() ? 3 : 0); - final LiteralArgumentBuilder builder = literal(command.getName()) - .requires(predicate).executes(getBrigadierExecutor()); - plugin.getPermissions().put(command.getPermission(), command.isOperatorCommand()); - if (!command.getRawUsage().isBlank()) { - builder.then(argument(command.getRawUsage().replaceAll("[<>\\[\\]]", ""), greedyString()) - .executes(getBrigadierExecutor()) - .suggests(getBrigadierSuggester())); - } - - // Register additional permissions - final Map permissions = command.getAdditionalPermissions(); - permissions.forEach((permission, isOp) -> plugin.getPermissions().put(permission, isOp)); - PermissionCheckEvent.EVENT.register((player, node) -> { - if (permissions.containsKey(node) && permissions.get(node) && player.hasPermissionLevel(3)) { - return TriState.TRUE; - } - return TriState.DEFAULT; - }); - - // Register aliases - final LiteralCommandNode node = dispatcher.register(builder); - dispatcher.register(literal("huskhomes:" + command.getName()) - .requires(predicate).executes(getBrigadierExecutor()).redirect(node)); - command.getAliases().forEach(alias -> dispatcher.register(literal(alias) - .requires(predicate).executes(getBrigadierExecutor()).redirect(node))); - } - - private com.mojang.brigadier.Command getBrigadierExecutor() { - return (context) -> { - command.onExecuted( - resolveExecutor(context.getSource()), - command.removeFirstArg(context.getInput().split(" ")) - ); - return 1; - }; - } - - private com.mojang.brigadier.suggestion.SuggestionProvider getBrigadierSuggester() { - if (!(command instanceof TabProvider provider)) { - return (context, builder) -> com.mojang.brigadier.suggestion.Suggestions.empty(); - } - return (context, builder) -> { - final String[] args = command.removeFirstArg(context.getInput().split(" ")); - provider.getSuggestions(resolveExecutor(context.getSource()), args).stream() - .map(suggestion -> { - final String completedArgs = String.join(" ", args); - int lastIndex = completedArgs.lastIndexOf(" "); - if (lastIndex == -1) { - return suggestion; - } - return completedArgs.substring(0, lastIndex + 1) + suggestion; - }) - .forEach(builder::suggest); - return builder.buildFuture(); - }; - } - - private CommandUser resolveExecutor(@NotNull ServerCommandSource source) { - if (source.getEntity() instanceof ServerPlayerEntity player) { - return FabricUser.adapt(player, plugin); - } - return plugin.getConsole(); - } - - - /** - * Commands available on the Fabric HuskHomes implementation. - */ - public enum Type { - HOME_COMMAND(PrivateHomeCommand::new), - SET_HOME_COMMAND(SetHomeCommand::new), - HOME_LIST_COMMAND(PrivateHomeListCommand::new), - DEL_HOME_COMMAND(DelHomeCommand::new), - EDIT_HOME_COMMAND(EditHomeCommand::new), - PUBLIC_HOME_COMMAND(PublicHomeCommand::new), - PUBLIC_HOME_LIST_COMMAND(PublicHomeListCommand::new), - WARP_COMMAND(WarpCommand::new), - SET_WARP_COMMAND(SetWarpCommand::new), - WARP_LIST_COMMAND(WarpListCommand::new), - DEL_WARP_COMMAND(DelWarpCommand::new), - EDIT_WARP_COMMAND(EditWarpCommand::new), - TP_COMMAND(TpCommand::new), - TP_HERE_COMMAND(TpHereCommand::new), - TPA_COMMAND((plugin) -> new TeleportRequestCommand(plugin, TeleportRequest.Type.TPA)), - TPA_HERE_COMMAND((plugin) -> new TeleportRequestCommand(plugin, TeleportRequest.Type.TPA_HERE)), - TPACCEPT_COMMAND((plugin) -> new TpRespondCommand(plugin, true)), - TPDECLINE_COMMAND((plugin) -> new TpRespondCommand(plugin, false)), - RTP_COMMAND(RtpCommand::new), - TP_IGNORE_COMMAND(TpIgnoreCommand::new), - TP_OFFLINE_COMMAND(TpOfflineCommand::new), - TP_ALL_COMMAND(TpAllCommand::new), - TPA_ALL_COMMAND(TpaAllCommand::new), - SPAWN_COMMAND(SpawnCommand::new), - SET_SPAWN_COMMAND(SetSpawnCommand::new), - BACK_COMMAND(BackCommand::new), - HUSKHOMES_COMMAND(HuskHomesCommand::new); - - private final Function supplier; - - Type(@NotNull Function supplier) { - this.supplier = supplier; - } - - @NotNull - public Command createCommand(@NotNull HuskHomes plugin) { - return supplier.apply(plugin); - } - - @NotNull - public static List getCommands(@NotNull FabricHuskHomes plugin) { - return Arrays.stream(values()) - .map(type -> type.createCommand(plugin)) - .map(command -> plugin.getSettings().isCommandDisabled(command) ? null : command) - .filter(Objects::nonNull) - .toList(); - } - - } - -} diff --git a/fabric/fabric-1.20.1/src/main/java/net/william278/huskhomes/event/DeleteAllHomesCallback.java b/fabric/fabric-1.20.1/src/main/java/net/william278/huskhomes/event/DeleteAllHomesCallback.java deleted file mode 100644 index f84f238d..00000000 --- a/fabric/fabric-1.20.1/src/main/java/net/william278/huskhomes/event/DeleteAllHomesCallback.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * This file is part of HuskHomes, licensed under the Apache License 2.0. - * - * Copyright (c) William278 - * Copyright (c) contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.william278.huskhomes.event; - -import net.fabricmc.fabric.api.event.Event; -import net.fabricmc.fabric.api.event.EventFactory; -import net.minecraft.util.ActionResult; -import net.william278.huskhomes.user.CommandUser; -import net.william278.huskhomes.user.User; -import org.jetbrains.annotations.NotNull; - -import java.util.function.BiFunction; - -public interface DeleteAllHomesCallback extends FabricEventCallback { - - @NotNull - Event EVENT = EventFactory.createArrayBacked(DeleteAllHomesCallback.class, - (listeners) -> (event) -> { - for (DeleteAllHomesCallback listener : listeners) { - final ActionResult result = listener.invoke(event); - if (event.isCancelled()) { - return ActionResult.CONSUME; - } else if (result != ActionResult.PASS) { - event.setCancelled(true); - return result; - } - } - - return ActionResult.PASS; - }); - - @NotNull - BiFunction SUPPLIER = (owner, deleter) -> - new IDeleteAllHomesEvent() { - private boolean cancelled = false; - - @Override - @NotNull - public User getHomeOwner() { - return owner; - } - - @Override - @NotNull - public CommandUser getDeleter() { - return deleter; - } - - @Override - public void setCancelled(boolean cancelled) { - this.cancelled = cancelled; - } - - @Override - public boolean isCancelled() { - return cancelled; - } - - @NotNull - public Event getEvent() { - return EVENT; - } - }; - -} diff --git a/fabric/fabric-1.20.1/src/main/java/net/william278/huskhomes/event/DeleteAllWarpsCallback.java b/fabric/fabric-1.20.1/src/main/java/net/william278/huskhomes/event/DeleteAllWarpsCallback.java deleted file mode 100644 index 78945be9..00000000 --- a/fabric/fabric-1.20.1/src/main/java/net/william278/huskhomes/event/DeleteAllWarpsCallback.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * This file is part of HuskHomes, licensed under the Apache License 2.0. - * - * Copyright (c) William278 - * Copyright (c) contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.william278.huskhomes.event; - -import net.fabricmc.fabric.api.event.Event; -import net.fabricmc.fabric.api.event.EventFactory; -import net.minecraft.util.ActionResult; -import net.william278.huskhomes.user.CommandUser; -import org.jetbrains.annotations.NotNull; - -import java.util.function.Function; - -public interface DeleteAllWarpsCallback extends FabricEventCallback { - - @NotNull - Event EVENT = EventFactory.createArrayBacked(DeleteAllWarpsCallback.class, - (listeners) -> (event) -> { - for (DeleteAllWarpsCallback listener : listeners) { - final ActionResult result = listener.invoke(event); - if (event.isCancelled()) { - return ActionResult.CONSUME; - } else if (result != ActionResult.PASS) { - event.setCancelled(true); - return result; - } - } - - return ActionResult.PASS; - }); - - @NotNull - Function SUPPLIER = (deleter) -> - new IDeleteAllWarpsEvent() { - private boolean cancelled = false; - - @Override - @NotNull - public CommandUser getDeleter() { - return deleter; - } - - @Override - public void setCancelled(boolean cancelled) { - this.cancelled = cancelled; - } - - @Override - public boolean isCancelled() { - return cancelled; - } - - @NotNull - public Event getEvent() { - return EVENT; - } - }; - -} diff --git a/fabric/fabric-1.20.1/src/main/java/net/william278/huskhomes/event/FabricEventCallback.java b/fabric/fabric-1.20.1/src/main/java/net/william278/huskhomes/event/FabricEventCallback.java deleted file mode 100644 index ef0c3a7f..00000000 --- a/fabric/fabric-1.20.1/src/main/java/net/william278/huskhomes/event/FabricEventCallback.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * This file is part of HuskHomes, licensed under the Apache License 2.0. - * - * Copyright (c) William278 - * Copyright (c) contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.william278.huskhomes.event; - -import net.minecraft.util.ActionResult; -import org.jetbrains.annotations.NotNull; - -public interface FabricEventCallback { - - @NotNull - ActionResult invoke(@NotNull E event); - - -} diff --git a/fabric/fabric-1.20.1/src/main/java/net/william278/huskhomes/event/HomeCreateCallback.java b/fabric/fabric-1.20.1/src/main/java/net/william278/huskhomes/event/HomeCreateCallback.java deleted file mode 100644 index 026ad4b3..00000000 --- a/fabric/fabric-1.20.1/src/main/java/net/william278/huskhomes/event/HomeCreateCallback.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * This file is part of HuskHomes, licensed under the Apache License 2.0. - * - * Copyright (c) William278 - * Copyright (c) contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.william278.huskhomes.event; - -import net.fabricmc.fabric.api.event.Event; -import net.fabricmc.fabric.api.event.EventFactory; -import net.minecraft.data.client.BlockStateVariantMap.QuadFunction; -import net.minecraft.util.ActionResult; -import net.william278.huskhomes.position.Position; -import net.william278.huskhomes.user.CommandUser; -import net.william278.huskhomes.user.User; -import org.jetbrains.annotations.NotNull; - -public interface HomeCreateCallback extends FabricEventCallback { - - @NotNull - Event EVENT = EventFactory.createArrayBacked(HomeCreateCallback.class, - (listeners) -> (event) -> { - for (HomeCreateCallback listener : listeners) { - final ActionResult result = listener.invoke(event); - if (event.isCancelled()) { - return ActionResult.CONSUME; - } else if (result != ActionResult.PASS) { - event.setCancelled(true); - return result; - } - } - - return ActionResult.PASS; - }); - - @NotNull - QuadFunction SUPPLIER = (user, name, position, creator) -> - new IHomeCreateEvent() { - private boolean cancelled = false; - private String homeName = name; - - @Override - @NotNull - public User getOwner() { - return user; - } - - @Override - @NotNull - public String getName() { - return homeName; - } - - @Override - public void setName(@NotNull String name) { - this.homeName = name; - } - - @Override - @NotNull - public Position getPosition() { - return position; - } - - @Override - public void setPosition(@NotNull Position position) { - } - - @Override - public @NotNull CommandUser getCreator() { - return creator; - } - - @Override - public void setCancelled(boolean cancelled) { - this.cancelled = cancelled; - } - - @Override - public boolean isCancelled() { - return cancelled; - } - - @NotNull - public Event getEvent() { - return EVENT; - } - }; - -} diff --git a/fabric/fabric-1.20.1/src/main/java/net/william278/huskhomes/event/HomeDeleteCallback.java b/fabric/fabric-1.20.1/src/main/java/net/william278/huskhomes/event/HomeDeleteCallback.java deleted file mode 100644 index 0f479589..00000000 --- a/fabric/fabric-1.20.1/src/main/java/net/william278/huskhomes/event/HomeDeleteCallback.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * This file is part of HuskHomes, licensed under the Apache License 2.0. - * - * Copyright (c) William278 - * Copyright (c) contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.william278.huskhomes.event; - -import net.fabricmc.fabric.api.event.Event; -import net.fabricmc.fabric.api.event.EventFactory; -import net.minecraft.util.ActionResult; -import net.william278.huskhomes.position.Home; -import net.william278.huskhomes.user.CommandUser; -import org.jetbrains.annotations.NotNull; - -import java.util.function.BiFunction; - -public interface HomeDeleteCallback extends FabricEventCallback { - - @NotNull - Event EVENT = EventFactory.createArrayBacked(HomeDeleteCallback.class, - (listeners) -> (event) -> { - for (HomeDeleteCallback listener : listeners) { - final ActionResult result = listener.invoke(event); - if (event.isCancelled()) { - return ActionResult.CONSUME; - } else if (result != ActionResult.PASS) { - event.setCancelled(true); - return result; - } - } - - return ActionResult.PASS; - }); - - @NotNull - BiFunction SUPPLIER = (home, deleter) -> - new IHomeDeleteEvent() { - private boolean cancelled = false; - - @Override - @NotNull - public Home getHome() { - return home; - } - - @Override - @NotNull - public CommandUser getDeleter() { - return deleter; - } - - @Override - public void setCancelled(boolean cancelled) { - this.cancelled = cancelled; - } - - @Override - public boolean isCancelled() { - return cancelled; - } - - @NotNull - public Event getEvent() { - return EVENT; - } - - }; - -} diff --git a/fabric/fabric-1.20.1/src/main/java/net/william278/huskhomes/event/HomeEditCallback.java b/fabric/fabric-1.20.1/src/main/java/net/william278/huskhomes/event/HomeEditCallback.java deleted file mode 100644 index 3b28f749..00000000 --- a/fabric/fabric-1.20.1/src/main/java/net/william278/huskhomes/event/HomeEditCallback.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * This file is part of HuskHomes, licensed under the Apache License 2.0. - * - * Copyright (c) William278 - * Copyright (c) contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.william278.huskhomes.event; - -import net.fabricmc.fabric.api.event.Event; -import net.fabricmc.fabric.api.event.EventFactory; -import net.minecraft.util.ActionResult; -import net.william278.huskhomes.position.Home; -import net.william278.huskhomes.user.CommandUser; -import org.jetbrains.annotations.NotNull; - -import java.util.function.BiFunction; - -public interface HomeEditCallback extends FabricEventCallback { - - @NotNull - Event EVENT = EventFactory.createArrayBacked(HomeEditCallback.class, - (listeners) -> (event) -> { - for (HomeEditCallback listener : listeners) { - final ActionResult result = listener.invoke(event); - if (event.isCancelled()) { - return ActionResult.CONSUME; - } else if (result != ActionResult.PASS) { - event.setCancelled(true); - return result; - } - } - - return ActionResult.PASS; - }); - - @NotNull - BiFunction SUPPLIER = (home, editor) -> - new IHomeEditEvent() { - private boolean cancelled = false; - - @Override - @NotNull - public Home getHome() { - return home; - } - - @Override - @NotNull - public CommandUser getEditor() { - return editor; - } - - @Override - public void setCancelled(boolean cancelled) { - this.cancelled = cancelled; - } - - @Override - public boolean isCancelled() { - return cancelled; - } - - @NotNull - public Event getEvent() { - return EVENT; - } - - }; - -} diff --git a/fabric/fabric-1.20.1/src/main/java/net/william278/huskhomes/event/HomeListCallback.java b/fabric/fabric-1.20.1/src/main/java/net/william278/huskhomes/event/HomeListCallback.java deleted file mode 100644 index e89d5cb6..00000000 --- a/fabric/fabric-1.20.1/src/main/java/net/william278/huskhomes/event/HomeListCallback.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * This file is part of HuskHomes, licensed under the Apache License 2.0. - * - * Copyright (c) William278 - * Copyright (c) contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.william278.huskhomes.event; - -import net.fabricmc.fabric.api.event.Event; -import net.fabricmc.fabric.api.event.EventFactory; -import net.minecraft.util.ActionResult; -import net.william278.huskhomes.position.Home; -import net.william278.huskhomes.user.CommandUser; -import org.apache.commons.lang3.function.TriFunction; -import org.jetbrains.annotations.NotNull; - -import java.util.List; - -public interface HomeListCallback extends FabricEventCallback { - - @NotNull - Event EVENT = EventFactory.createArrayBacked(HomeListCallback.class, - (listeners) -> (event) -> { - for (HomeListCallback listener : listeners) { - final ActionResult result = listener.invoke(event); - if (event.isCancelled()) { - return ActionResult.CONSUME; - } else if (result != ActionResult.PASS) { - event.setCancelled(true); - return result; - } - } - - return ActionResult.PASS; - }); - - @NotNull - TriFunction, CommandUser, Boolean, IHomeListEvent> SUPPLIER = (homes, viewer, publicHomes) -> - new IHomeListEvent() { - private boolean cancelled = false; - private List listHomes = homes; - - @Override - @NotNull - public List getHomes() { - return listHomes; - } - - @Override - public void setHomes(@NotNull List homes) { - this.listHomes = homes; - } - - @Override - @NotNull - public CommandUser getListViewer() { - return viewer; - } - - @Override - public boolean getIsPublicHomeList() { - return publicHomes; - } - - @Override - public void setCancelled(boolean cancelled) { - this.cancelled = cancelled; - } - - @Override - public boolean isCancelled() { - return cancelled; - } - - @NotNull - public Event getEvent() { - return EVENT; - } - - }; - -} diff --git a/fabric/fabric-1.20.1/src/main/java/net/william278/huskhomes/event/ReceiveTeleportRequestCallback.java b/fabric/fabric-1.20.1/src/main/java/net/william278/huskhomes/event/ReceiveTeleportRequestCallback.java deleted file mode 100644 index a0b4da5a..00000000 --- a/fabric/fabric-1.20.1/src/main/java/net/william278/huskhomes/event/ReceiveTeleportRequestCallback.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * This file is part of HuskHomes, licensed under the Apache License 2.0. - * - * Copyright (c) William278 - * Copyright (c) contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.william278.huskhomes.event; - -import net.fabricmc.fabric.api.event.Event; -import net.fabricmc.fabric.api.event.EventFactory; -import net.minecraft.util.ActionResult; -import net.william278.huskhomes.teleport.TeleportRequest; -import net.william278.huskhomes.user.OnlineUser; -import org.jetbrains.annotations.NotNull; - -import java.util.function.BiFunction; - -public interface ReceiveTeleportRequestCallback extends FabricEventCallback { - - @NotNull - Event EVENT = EventFactory.createArrayBacked(ReceiveTeleportRequestCallback.class, - (listeners) -> (event) -> { - for (ReceiveTeleportRequestCallback listener : listeners) { - final ActionResult result = listener.invoke(event); - if (event.isCancelled()) { - return ActionResult.CONSUME; - } else if (result != ActionResult.PASS) { - event.setCancelled(true); - return result; - } - } - - return ActionResult.PASS; - }); - - @NotNull - BiFunction SUPPLIER = (recipient, request) -> - new IReceiveTeleportRequestEvent() { - private boolean cancelled = false; - - @Override - @NotNull - public OnlineUser getRecipient() { - return recipient; - } - - @Override - @NotNull - public TeleportRequest getRequest() { - return request; - } - - @Override - public void setCancelled(boolean cancelled) { - this.cancelled = cancelled; - } - - @Override - public boolean isCancelled() { - return cancelled; - } - - @NotNull - public Event getEvent() { - return EVENT; - } - - }; - -} diff --git a/fabric/fabric-1.20.1/src/main/java/net/william278/huskhomes/event/ReplyTeleportRequestCallback.java b/fabric/fabric-1.20.1/src/main/java/net/william278/huskhomes/event/ReplyTeleportRequestCallback.java deleted file mode 100644 index 85dcddb8..00000000 --- a/fabric/fabric-1.20.1/src/main/java/net/william278/huskhomes/event/ReplyTeleportRequestCallback.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * This file is part of HuskHomes, licensed under the Apache License 2.0. - * - * Copyright (c) William278 - * Copyright (c) contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.william278.huskhomes.event; - -import net.fabricmc.fabric.api.event.Event; -import net.fabricmc.fabric.api.event.EventFactory; -import net.minecraft.util.ActionResult; -import net.william278.huskhomes.teleport.TeleportRequest; -import net.william278.huskhomes.user.OnlineUser; -import org.jetbrains.annotations.NotNull; - -import java.util.function.BiFunction; - -public interface ReplyTeleportRequestCallback extends FabricEventCallback { - - @NotNull - Event EVENT = EventFactory.createArrayBacked(ReplyTeleportRequestCallback.class, - (listeners) -> (event) -> { - for (ReplyTeleportRequestCallback listener : listeners) { - final ActionResult result = listener.invoke(event); - if (event.isCancelled()) { - return ActionResult.CONSUME; - } else if (result != ActionResult.PASS) { - event.setCancelled(true); - return result; - } - } - - return ActionResult.PASS; - }); - - @NotNull - BiFunction SUPPLIER = (recipient, request) -> - new IReplyTeleportRequestEvent() { - private boolean cancelled = false; - - @Override - @NotNull - public OnlineUser getRecipient() { - return recipient; - } - - @Override - @NotNull - public TeleportRequest getRequest() { - return request; - } - - @Override - public void setCancelled(boolean cancelled) { - this.cancelled = cancelled; - } - - @Override - public boolean isCancelled() { - return cancelled; - } - - @NotNull - public Event getEvent() { - return EVENT; - } - - }; - -} diff --git a/fabric/fabric-1.20.1/src/main/java/net/william278/huskhomes/event/SendTeleportRequestCallback.java b/fabric/fabric-1.20.1/src/main/java/net/william278/huskhomes/event/SendTeleportRequestCallback.java deleted file mode 100644 index d7fd6505..00000000 --- a/fabric/fabric-1.20.1/src/main/java/net/william278/huskhomes/event/SendTeleportRequestCallback.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * This file is part of HuskHomes, licensed under the Apache License 2.0. - * - * Copyright (c) William278 - * Copyright (c) contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.william278.huskhomes.event; - -import net.fabricmc.fabric.api.event.Event; -import net.fabricmc.fabric.api.event.EventFactory; -import net.minecraft.util.ActionResult; -import net.william278.huskhomes.teleport.TeleportRequest; -import net.william278.huskhomes.user.OnlineUser; -import org.jetbrains.annotations.NotNull; - -import java.util.function.BiFunction; - -public interface SendTeleportRequestCallback extends FabricEventCallback { - - @NotNull - Event EVENT = EventFactory.createArrayBacked(SendTeleportRequestCallback.class, - (listeners) -> (event) -> { - for (SendTeleportRequestCallback listener : listeners) { - final ActionResult result = listener.invoke(event); - if (event.isCancelled()) { - return ActionResult.CONSUME; - } else if (result != ActionResult.PASS) { - event.setCancelled(true); - return result; - } - } - - return ActionResult.PASS; - }); - - @NotNull - BiFunction SUPPLIER = (sender, request) -> - new ISendTeleportRequestEvent() { - private boolean cancelled = false; - - @Override - @NotNull - public OnlineUser getSender() { - return sender; - } - - @Override - @NotNull - public TeleportRequest getRequest() { - return request; - } - - @Override - public void setCancelled(boolean cancelled) { - this.cancelled = cancelled; - } - - @Override - public boolean isCancelled() { - return cancelled; - } - - @NotNull - public Event getEvent() { - return EVENT; - } - - }; - -} diff --git a/fabric/fabric-1.20.1/src/main/java/net/william278/huskhomes/event/TeleportBackCallback.java b/fabric/fabric-1.20.1/src/main/java/net/william278/huskhomes/event/TeleportBackCallback.java deleted file mode 100644 index 90a153c6..00000000 --- a/fabric/fabric-1.20.1/src/main/java/net/william278/huskhomes/event/TeleportBackCallback.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * This file is part of HuskHomes, licensed under the Apache License 2.0. - * - * Copyright (c) William278 - * Copyright (c) contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.william278.huskhomes.event; - -import net.fabricmc.fabric.api.event.Event; -import net.fabricmc.fabric.api.event.EventFactory; -import net.minecraft.util.ActionResult; -import net.william278.huskhomes.position.Position; -import net.william278.huskhomes.teleport.Teleport; -import org.jetbrains.annotations.NotNull; - -import java.util.function.Function; - -public interface TeleportBackCallback extends FabricEventCallback { - - @NotNull - Event EVENT = EventFactory.createArrayBacked(TeleportBackCallback.class, - (listeners) -> (event) -> { - for (TeleportBackCallback listener : listeners) { - final ActionResult result = listener.invoke(event); - if (event.isCancelled()) { - return ActionResult.FAIL; - } else if (result == ActionResult.FAIL) { - event.setCancelled(true); - return result; - } - } - - return ActionResult.PASS; - }); - - @NotNull - Function SUPPLIER = (teleport) -> - new ITeleportBackEvent() { - private boolean cancelled = false; - - @Override - @NotNull - public Position getLastPosition() { - return (Position) getTeleport().getTarget(); - } - - @Override - @NotNull - public Teleport getTeleport() { - return teleport; - } - - @Override - public void setCancelled(boolean cancelled) { - this.cancelled = cancelled; - } - - @Override - public boolean isCancelled() { - return cancelled; - } - - @NotNull - public Event getEvent() { - return EVENT; - } - - }; - -} diff --git a/fabric/fabric-1.20.1/src/main/java/net/william278/huskhomes/event/TeleportCallback.java b/fabric/fabric-1.20.1/src/main/java/net/william278/huskhomes/event/TeleportCallback.java deleted file mode 100644 index 99a7cc6b..00000000 --- a/fabric/fabric-1.20.1/src/main/java/net/william278/huskhomes/event/TeleportCallback.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * This file is part of HuskHomes, licensed under the Apache License 2.0. - * - * Copyright (c) William278 - * Copyright (c) contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.william278.huskhomes.event; - -import net.fabricmc.fabric.api.event.Event; -import net.fabricmc.fabric.api.event.EventFactory; -import net.minecraft.util.ActionResult; -import net.william278.huskhomes.teleport.Teleport; -import org.jetbrains.annotations.NotNull; - -import java.util.function.Function; - -public interface TeleportCallback extends FabricEventCallback { - - @NotNull - Event EVENT = EventFactory.createArrayBacked(TeleportCallback.class, - (listeners) -> (event) -> { - for (TeleportCallback listener : listeners) { - final ActionResult result = listener.invoke(event); - if (event.isCancelled()) { - return ActionResult.FAIL; - } else if (result == ActionResult.FAIL) { - event.setCancelled(true); - return result; - } - } - - return ActionResult.PASS; - }); - - @NotNull - Function SUPPLIER = (teleport) -> - new ITeleportEvent() { - private boolean cancelled = false; - - @Override - @NotNull - public Teleport getTeleport() { - return teleport; - } - - @Override - public void setCancelled(boolean cancelled) { - this.cancelled = cancelled; - } - - @Override - public boolean isCancelled() { - return cancelled; - } - - @NotNull - public Event getEvent() { - return EVENT; - } - - }; - -} diff --git a/fabric/fabric-1.20.1/src/main/java/net/william278/huskhomes/event/TeleportWarmupCallback.java b/fabric/fabric-1.20.1/src/main/java/net/william278/huskhomes/event/TeleportWarmupCallback.java deleted file mode 100644 index c9d6961c..00000000 --- a/fabric/fabric-1.20.1/src/main/java/net/william278/huskhomes/event/TeleportWarmupCallback.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * This file is part of HuskHomes, licensed under the Apache License 2.0. - * - * Copyright (c) William278 - * Copyright (c) contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.william278.huskhomes.event; - -import net.fabricmc.fabric.api.event.Event; -import net.fabricmc.fabric.api.event.EventFactory; -import net.minecraft.util.ActionResult; -import net.william278.huskhomes.teleport.TimedTeleport; -import org.jetbrains.annotations.NotNull; - -import java.util.function.BiFunction; - -public interface TeleportWarmupCallback extends FabricEventCallback { - @NotNull - Event EVENT = EventFactory.createArrayBacked(TeleportWarmupCallback.class, - (listeners) -> (event) -> { - for (TeleportWarmupCallback listener : listeners) { - final ActionResult result = listener.invoke(event); - if (event.isCancelled()) { - return ActionResult.FAIL; - } else if (result == ActionResult.FAIL) { - event.setCancelled(true); - return result; - } - } - - return ActionResult.PASS; - }); - - @NotNull - BiFunction SUPPLIER = (timedTeleport, duration) -> - new ITeleportWarmupEvent() { - private boolean cancelled = false; - - @Override - @NotNull - public TimedTeleport getTimedTeleport() { - return timedTeleport; - } - - @Override - public int getWarmupDuration() { - return duration; - } - - @Override - public void setCancelled(boolean cancelled) { - this.cancelled = cancelled; - } - - @Override - public boolean isCancelled() { - return cancelled; - } - - @NotNull - public Event getEvent() { - return EVENT; - } - - }; -} diff --git a/fabric/fabric-1.20.1/src/main/java/net/william278/huskhomes/event/WarpCreateCallback.java b/fabric/fabric-1.20.1/src/main/java/net/william278/huskhomes/event/WarpCreateCallback.java deleted file mode 100644 index 78b69dc9..00000000 --- a/fabric/fabric-1.20.1/src/main/java/net/william278/huskhomes/event/WarpCreateCallback.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * This file is part of HuskHomes, licensed under the Apache License 2.0. - * - * Copyright (c) William278 - * Copyright (c) contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.william278.huskhomes.event; - -import net.fabricmc.fabric.api.event.Event; -import net.fabricmc.fabric.api.event.EventFactory; -import net.minecraft.util.ActionResult; -import net.william278.huskhomes.position.Position; -import net.william278.huskhomes.user.CommandUser; -import org.apache.commons.lang3.function.TriFunction; -import org.jetbrains.annotations.NotNull; - -public interface WarpCreateCallback extends FabricEventCallback { - - @NotNull - Event EVENT = EventFactory.createArrayBacked(WarpCreateCallback.class, - (listeners) -> (event) -> { - for (WarpCreateCallback listener : listeners) { - final ActionResult result = listener.invoke(event); - if (event.isCancelled()) { - return ActionResult.CONSUME; - } else if (result != ActionResult.PASS) { - event.setCancelled(true); - return result; - } - } - - return ActionResult.PASS; - }); - - @NotNull - TriFunction SUPPLIER = (name, position, creator) -> - new IWarpCreateEvent() { - private boolean cancelled = false; - private String homeName = name; - - @Override - @NotNull - public String getName() { - return homeName; - } - - @Override - public void setName(@NotNull String name) { - this.homeName = name; - } - - @Override - @NotNull - public Position getPosition() { - return position; - } - - @Override - public void setPosition(@NotNull Position position) { - } - - @Override - @NotNull - public CommandUser getCreator() { - return creator; - } - - @Override - public void setCancelled(boolean cancelled) { - this.cancelled = cancelled; - } - - @Override - public boolean isCancelled() { - return cancelled; - } - - @NotNull - public Event getEvent() { - return EVENT; - } - - }; - -} diff --git a/fabric/fabric-1.20.1/src/main/java/net/william278/huskhomes/event/WarpDeleteCallback.java b/fabric/fabric-1.20.1/src/main/java/net/william278/huskhomes/event/WarpDeleteCallback.java deleted file mode 100644 index cbba72ea..00000000 --- a/fabric/fabric-1.20.1/src/main/java/net/william278/huskhomes/event/WarpDeleteCallback.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * This file is part of HuskHomes, licensed under the Apache License 2.0. - * - * Copyright (c) William278 - * Copyright (c) contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.william278.huskhomes.event; - -import net.fabricmc.fabric.api.event.Event; -import net.fabricmc.fabric.api.event.EventFactory; -import net.minecraft.util.ActionResult; -import net.william278.huskhomes.position.Warp; -import net.william278.huskhomes.user.CommandUser; -import org.jetbrains.annotations.NotNull; - -import java.util.function.BiFunction; - -public interface WarpDeleteCallback extends FabricEventCallback { - - @NotNull - Event EVENT = EventFactory.createArrayBacked(WarpDeleteCallback.class, - (listeners) -> (event) -> { - for (WarpDeleteCallback listener : listeners) { - final ActionResult result = listener.invoke(event); - if (event.isCancelled()) { - return ActionResult.CONSUME; - } else if (result != ActionResult.PASS) { - event.setCancelled(true); - return result; - } - } - - return ActionResult.PASS; - }); - - @NotNull - BiFunction SUPPLIER = (warp, deleter) -> - new IWarpDeleteEvent() { - private boolean cancelled = false; - - @Override - @NotNull - public Warp getWarp() { - return warp; - } - - @Override - @NotNull - public CommandUser getDeleter() { - return deleter; - } - - @Override - public void setCancelled(boolean cancelled) { - this.cancelled = cancelled; - } - - @Override - public boolean isCancelled() { - return cancelled; - } - - @NotNull - public Event getEvent() { - return EVENT; - } - - }; - -} diff --git a/fabric/fabric-1.20.1/src/main/java/net/william278/huskhomes/event/WarpEditCallback.java b/fabric/fabric-1.20.1/src/main/java/net/william278/huskhomes/event/WarpEditCallback.java deleted file mode 100644 index d3291d91..00000000 --- a/fabric/fabric-1.20.1/src/main/java/net/william278/huskhomes/event/WarpEditCallback.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * This file is part of HuskHomes, licensed under the Apache License 2.0. - * - * Copyright (c) William278 - * Copyright (c) contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.william278.huskhomes.event; - -import net.fabricmc.fabric.api.event.Event; -import net.fabricmc.fabric.api.event.EventFactory; -import net.minecraft.util.ActionResult; -import net.william278.huskhomes.position.Warp; -import net.william278.huskhomes.user.CommandUser; -import org.jetbrains.annotations.NotNull; - -import java.util.function.BiFunction; - -public interface WarpEditCallback extends FabricEventCallback { - - @NotNull - Event EVENT = EventFactory.createArrayBacked(WarpEditCallback.class, - (listeners) -> (event) -> { - for (WarpEditCallback listener : listeners) { - final ActionResult result = listener.invoke(event); - if (event.isCancelled()) { - return ActionResult.CONSUME; - } else if (result != ActionResult.PASS) { - event.setCancelled(true); - return result; - } - } - - return ActionResult.PASS; - }); - - @NotNull - BiFunction SUPPLIER = (warp, editor) -> - new IWarpEditEvent() { - private boolean cancelled = false; - - @Override - @NotNull - public Warp getWarp() { - return warp; - } - - @Override - @NotNull - public CommandUser getEditor() { - return editor; - } - - @Override - public void setCancelled(boolean cancelled) { - this.cancelled = cancelled; - } - - @Override - public boolean isCancelled() { - return cancelled; - } - - @NotNull - public Event getEvent() { - return EVENT; - } - - }; - -} diff --git a/fabric/fabric-1.20.1/src/main/java/net/william278/huskhomes/event/WarpListCallback.java b/fabric/fabric-1.20.1/src/main/java/net/william278/huskhomes/event/WarpListCallback.java deleted file mode 100644 index 21f2a55f..00000000 --- a/fabric/fabric-1.20.1/src/main/java/net/william278/huskhomes/event/WarpListCallback.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * This file is part of HuskHomes, licensed under the Apache License 2.0. - * - * Copyright (c) William278 - * Copyright (c) contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.william278.huskhomes.event; - -import net.fabricmc.fabric.api.event.Event; -import net.fabricmc.fabric.api.event.EventFactory; -import net.minecraft.util.ActionResult; -import net.william278.huskhomes.position.Warp; -import net.william278.huskhomes.user.CommandUser; -import org.jetbrains.annotations.NotNull; - -import java.util.List; -import java.util.function.BiFunction; - -public interface WarpListCallback extends FabricEventCallback { - - @NotNull - Event EVENT = EventFactory.createArrayBacked(WarpListCallback.class, - (listeners) -> (event) -> { - for (WarpListCallback listener : listeners) { - final ActionResult result = listener.invoke(event); - if (event.isCancelled()) { - return ActionResult.CONSUME; - } else if (result != ActionResult.PASS) { - event.setCancelled(true); - return result; - } - } - - return ActionResult.PASS; - }); - - @NotNull - BiFunction, CommandUser, IWarpListEvent> SUPPLIER = (warps, viewer) -> - new IWarpListEvent() { - private boolean cancelled = false; - private List listWarps = warps; - - @Override - @NotNull - public List getWarps() { - return listWarps; - } - - @Override - public void setWarps(@NotNull List homes) { - this.listWarps = homes; - } - - @Override - @NotNull - public CommandUser getListViewer() { - return viewer; - } - - @Override - public void setCancelled(boolean cancelled) { - this.cancelled = cancelled; - } - - @Override - public boolean isCancelled() { - return cancelled; - } - - @NotNull - public Event getEvent() { - return EVENT; - } - - }; - -} diff --git a/fabric/fabric-1.20.1/src/main/java/net/william278/huskhomes/listener/FabricEventListener.java b/fabric/fabric-1.20.1/src/main/java/net/william278/huskhomes/listener/FabricEventListener.java deleted file mode 100644 index ba97ce55..00000000 --- a/fabric/fabric-1.20.1/src/main/java/net/william278/huskhomes/listener/FabricEventListener.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * This file is part of HuskHomes, licensed under the Apache License 2.0. - * - * Copyright (c) William278 - * Copyright (c) contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.william278.huskhomes.listener; - -import net.fabricmc.fabric.api.entity.event.v1.ServerLivingEntityEvents; -import net.fabricmc.fabric.api.entity.event.v1.ServerPlayerEvents; -import net.fabricmc.fabric.api.networking.v1.ServerPlayConnectionEvents; -import net.minecraft.server.network.ServerPlayerEntity; -import net.william278.huskhomes.FabricHuskHomes; -import net.william278.huskhomes.user.FabricUser; -import org.jetbrains.annotations.NotNull; - -// Note that the teleport event and update player respawn position events are not handled on Fabric. -// The "update last position on teleport event" and "global respawn" features are not supported on Fabric. -public class FabricEventListener extends EventListener { - - public FabricEventListener(@NotNull FabricHuskHomes plugin) { - super(plugin); - this.registerEvents(plugin); - } - - // Register fabric event callback listeners to internal handlers - private void registerEvents(@NotNull FabricHuskHomes plugin) { - // Join event - ServerPlayConnectionEvents.JOIN.register((handler, sender, server) -> handlePlayerJoin( - FabricUser.adapt(handler.player, plugin) - )); - - // Quit event - ServerPlayConnectionEvents.DISCONNECT.register((handler, server) -> handlePlayerLeave( - FabricUser.adapt(handler.player, plugin) - )); - - // Death event - ServerLivingEntityEvents.AFTER_DEATH.register((entity, source) -> { - if (entity instanceof ServerPlayerEntity player) { - handlePlayerDeath(FabricUser.adapt(player, plugin)); - } - }); - - // Respawn event - ServerPlayerEvents.AFTER_RESPAWN.register((oldPlayer, newPlayer, alive) -> handlePlayerRespawn( - FabricUser.adapt(newPlayer, plugin) - )); - } - -} diff --git a/fabric/fabric-1.20.1/src/main/java/net/william278/huskhomes/util/FabricSafetyResolver.java b/fabric/fabric-1.20.1/src/main/java/net/william278/huskhomes/util/FabricSafetyResolver.java deleted file mode 100644 index 15eb62ef..00000000 --- a/fabric/fabric-1.20.1/src/main/java/net/william278/huskhomes/util/FabricSafetyResolver.java +++ /dev/null @@ -1,129 +0,0 @@ -/* - * This file is part of HuskHomes, licensed under the Apache License 2.0. - * - * Copyright (c) William278 - * Copyright (c) contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.william278.huskhomes.util; - -import net.minecraft.block.Block; -import net.minecraft.block.FireBlock; -import net.minecraft.block.FluidBlock; -import net.minecraft.registry.Registries; -import net.minecraft.server.MinecraftServer; -import net.minecraft.server.world.ServerWorld; -import net.minecraft.util.Identifier; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; -import net.minecraft.world.BlockView; -import net.william278.huskhomes.FabricHuskHomes; -import net.william278.huskhomes.position.Location; -import org.jetbrains.annotations.NotNull; - -import java.util.Optional; -import java.util.concurrent.CompletableFuture; - -public interface FabricSafetyResolver extends SafetyResolver { - - @Override - default CompletableFuture> findSafeGroundLocation(@NotNull Location location) { - final MinecraftServer server = ((FabricHuskHomes) getPlugin()).getMinecraftServer(); - final Identifier worldId = Identifier.tryParse(location.getWorld().getName()); - - // Ensure the location is on a valid world - final Optional locationWorld = server.getWorldRegistryKeys().stream() - .filter(key -> key.getValue().equals(worldId)).findFirst() - .map(server::getWorld); - if (locationWorld.isEmpty()) { - return CompletableFuture.completedFuture(Optional.empty()); - } - - // Ensure the location is within the world border - final ServerWorld world = locationWorld.get(); - if (!world.getWorldBorder().contains(location.getX(), location.getZ())) { - return CompletableFuture.completedFuture(Optional.empty()); - } - - return CompletableFuture.completedFuture(findSafeLocationNear(location, world)); - } - - /** - * Search for a safe ground location near the given location. - * - * @param location The location to search around - * @return An optional safe location, within 4 blocks of the given location - */ - private Optional findSafeLocationNear(@NotNull Location location, @NotNull ServerWorld world) { - final BlockPos.Mutable blockPos = new BlockPos.Mutable(location.getX(), location.getY(), location.getZ()); - for (int x = -SEARCH_RADIUS; x <= SEARCH_RADIUS; x++) { - for (int z = -SEARCH_RADIUS; z <= SEARCH_RADIUS; z++) { - blockPos.set(location.getX() + x, location.getY(), location.getZ() + z); - final int highestY = getHighestYAt(world, blockPos.getX(), blockPos.getY(), blockPos.getZ()) + 1; - - final Block block = world.getBlockState(blockPos.withY(highestY - 1)).getBlock(); - final Identifier id = Registries.BLOCK.getId(block); - - final Block bodyBlockType = world.getBlockState(blockPos.withY(highestY)).getBlock(); - final Identifier bodyBlockId = Registries.BLOCK.getId(bodyBlockType); - - final Block headBlockType = world.getBlockState(blockPos.withY(highestY + 1)).getBlock(); - final Identifier headBlockId = Registries.BLOCK.getId(headBlockType); - - if (!(block instanceof FluidBlock) && !(block instanceof FireBlock) - && isBlockSafeForStanding(id.toString()) && isBlockSafeForOccupation(bodyBlockId.toString()) - && isBlockSafeForOccupation(headBlockId.toString())) { - double locx = blockPos.getX(); - if (locx < 0) { - locx += 1.5d; - } else { - locx = locx + 0.5d; - } - double locz = blockPos.getZ(); - if (locz < 0) { - locz += 1.5d; - } else { - locz = locz + 0.5d; - } - return Optional.of(Location.at( - locx, - highestY, - locz, - location.getWorld() - )); - } - } - } - return Optional.empty(); - } - - /** - * Get the highest Y value at the given X and Z coordinates. - * - * @param blockView The block view to search - * @param x The X coordinate - * @param y The Y coordinate - * @param z The Z coordinate - * @return The highest Y value at the given X and Z coordinates - */ - private int getHighestYAt(@NotNull BlockView blockView, int x, int y, int z) { - final BlockPos.Mutable cursor = new BlockPos.Mutable(x, y, z); - while (blockView.getBlockState(cursor).isAir() && cursor.getY() > blockView.getBottomY()) { - cursor.move(Direction.DOWN); - } - return cursor.getY(); - } - -} diff --git a/fabric/fabric-1.20.1/src/main/resources/assets/huskhomes/icon.png b/fabric/fabric-1.20.1/src/main/resources/assets/huskhomes/icon.png deleted file mode 100644 index 7c79c219..00000000 Binary files a/fabric/fabric-1.20.1/src/main/resources/assets/huskhomes/icon.png and /dev/null differ diff --git a/fabric/fabric-1.20.1/src/main/resources/fabric.mod.json b/fabric/fabric-1.20.1/src/main/resources/fabric.mod.json deleted file mode 100644 index 5c57dfef..00000000 --- a/fabric/fabric-1.20.1/src/main/resources/fabric.mod.json +++ /dev/null @@ -1,37 +0,0 @@ -{ - "schemaVersion": 1, - "id": "huskhomes", - "version": "${version}", - "name": "HuskHomes", - "icon": "assets/huskhomes/icon.png", - "description": "${description}", - "authors": [ - { - "name": "William278", - "contact": { - "sources": "https://github.com/WiIIiam278/", - "homepage": "https://william278.net/" - } - } - ], - "license": "Apache-2.0", - "contact": { - "homepage": "https://william278.net/project/huskhomes/", - "repo": "https://github.com/WiIIiam278/HuskHomes", - "issues": "https://github.com/WiIIiam278/HuskHomes/issues" - }, - "environment": "server", - "entrypoints": { - "server": [ - "net.william278.huskhomes.FabricHuskHomes" - ] - }, - "depends": { - "fabricloader": ">=${fabric_loader_version}", - "minecraft": ">=${fabric_minecraft_version}", - "fabric-api": "*" - }, - "custom": { - "modmenu:api": true - } -} \ No newline at end of file diff --git a/fabric/fabric-1.20.1/src/main/java/net/william278/huskhomes/FabricHuskHomes.java b/fabric/src/main/java/net/william278/huskhomes/FabricHuskHomes.java similarity index 100% rename from fabric/fabric-1.20.1/src/main/java/net/william278/huskhomes/FabricHuskHomes.java rename to fabric/src/main/java/net/william278/huskhomes/FabricHuskHomes.java diff --git a/fabric/fabric-1.19.2/src/main/java/net/william278/huskhomes/command/FabricCommand.java b/fabric/src/main/java/net/william278/huskhomes/command/FabricCommand.java similarity index 100% rename from fabric/fabric-1.19.2/src/main/java/net/william278/huskhomes/command/FabricCommand.java rename to fabric/src/main/java/net/william278/huskhomes/command/FabricCommand.java diff --git a/fabric/fabric-1.19.2/src/main/java/net/william278/huskhomes/event/DeleteAllHomesCallback.java b/fabric/src/main/java/net/william278/huskhomes/event/DeleteAllHomesCallback.java similarity index 100% rename from fabric/fabric-1.19.2/src/main/java/net/william278/huskhomes/event/DeleteAllHomesCallback.java rename to fabric/src/main/java/net/william278/huskhomes/event/DeleteAllHomesCallback.java diff --git a/fabric/fabric-1.19.2/src/main/java/net/william278/huskhomes/event/DeleteAllWarpsCallback.java b/fabric/src/main/java/net/william278/huskhomes/event/DeleteAllWarpsCallback.java similarity index 100% rename from fabric/fabric-1.19.2/src/main/java/net/william278/huskhomes/event/DeleteAllWarpsCallback.java rename to fabric/src/main/java/net/william278/huskhomes/event/DeleteAllWarpsCallback.java diff --git a/fabric/fabric-1.19.2/src/main/java/net/william278/huskhomes/event/FabricEventCallback.java b/fabric/src/main/java/net/william278/huskhomes/event/FabricEventCallback.java similarity index 100% rename from fabric/fabric-1.19.2/src/main/java/net/william278/huskhomes/event/FabricEventCallback.java rename to fabric/src/main/java/net/william278/huskhomes/event/FabricEventCallback.java diff --git a/fabric/fabric-1.20.1/src/main/java/net/william278/huskhomes/event/FabricEventDispatcher.java b/fabric/src/main/java/net/william278/huskhomes/event/FabricEventDispatcher.java similarity index 100% rename from fabric/fabric-1.20.1/src/main/java/net/william278/huskhomes/event/FabricEventDispatcher.java rename to fabric/src/main/java/net/william278/huskhomes/event/FabricEventDispatcher.java diff --git a/fabric/fabric-1.19.2/src/main/java/net/william278/huskhomes/event/HomeCreateCallback.java b/fabric/src/main/java/net/william278/huskhomes/event/HomeCreateCallback.java similarity index 100% rename from fabric/fabric-1.19.2/src/main/java/net/william278/huskhomes/event/HomeCreateCallback.java rename to fabric/src/main/java/net/william278/huskhomes/event/HomeCreateCallback.java diff --git a/fabric/fabric-1.19.2/src/main/java/net/william278/huskhomes/event/HomeDeleteCallback.java b/fabric/src/main/java/net/william278/huskhomes/event/HomeDeleteCallback.java similarity index 100% rename from fabric/fabric-1.19.2/src/main/java/net/william278/huskhomes/event/HomeDeleteCallback.java rename to fabric/src/main/java/net/william278/huskhomes/event/HomeDeleteCallback.java diff --git a/fabric/fabric-1.19.2/src/main/java/net/william278/huskhomes/event/HomeEditCallback.java b/fabric/src/main/java/net/william278/huskhomes/event/HomeEditCallback.java similarity index 100% rename from fabric/fabric-1.19.2/src/main/java/net/william278/huskhomes/event/HomeEditCallback.java rename to fabric/src/main/java/net/william278/huskhomes/event/HomeEditCallback.java diff --git a/fabric/fabric-1.19.2/src/main/java/net/william278/huskhomes/event/HomeListCallback.java b/fabric/src/main/java/net/william278/huskhomes/event/HomeListCallback.java similarity index 100% rename from fabric/fabric-1.19.2/src/main/java/net/william278/huskhomes/event/HomeListCallback.java rename to fabric/src/main/java/net/william278/huskhomes/event/HomeListCallback.java diff --git a/fabric/fabric-1.19.2/src/main/java/net/william278/huskhomes/event/ReceiveTeleportRequestCallback.java b/fabric/src/main/java/net/william278/huskhomes/event/ReceiveTeleportRequestCallback.java similarity index 100% rename from fabric/fabric-1.19.2/src/main/java/net/william278/huskhomes/event/ReceiveTeleportRequestCallback.java rename to fabric/src/main/java/net/william278/huskhomes/event/ReceiveTeleportRequestCallback.java diff --git a/fabric/fabric-1.19.2/src/main/java/net/william278/huskhomes/event/ReplyTeleportRequestCallback.java b/fabric/src/main/java/net/william278/huskhomes/event/ReplyTeleportRequestCallback.java similarity index 100% rename from fabric/fabric-1.19.2/src/main/java/net/william278/huskhomes/event/ReplyTeleportRequestCallback.java rename to fabric/src/main/java/net/william278/huskhomes/event/ReplyTeleportRequestCallback.java diff --git a/fabric/fabric-1.19.2/src/main/java/net/william278/huskhomes/event/SendTeleportRequestCallback.java b/fabric/src/main/java/net/william278/huskhomes/event/SendTeleportRequestCallback.java similarity index 100% rename from fabric/fabric-1.19.2/src/main/java/net/william278/huskhomes/event/SendTeleportRequestCallback.java rename to fabric/src/main/java/net/william278/huskhomes/event/SendTeleportRequestCallback.java diff --git a/fabric/fabric-1.19.2/src/main/java/net/william278/huskhomes/event/TeleportBackCallback.java b/fabric/src/main/java/net/william278/huskhomes/event/TeleportBackCallback.java similarity index 100% rename from fabric/fabric-1.19.2/src/main/java/net/william278/huskhomes/event/TeleportBackCallback.java rename to fabric/src/main/java/net/william278/huskhomes/event/TeleportBackCallback.java diff --git a/fabric/fabric-1.19.2/src/main/java/net/william278/huskhomes/event/TeleportCallback.java b/fabric/src/main/java/net/william278/huskhomes/event/TeleportCallback.java similarity index 100% rename from fabric/fabric-1.19.2/src/main/java/net/william278/huskhomes/event/TeleportCallback.java rename to fabric/src/main/java/net/william278/huskhomes/event/TeleportCallback.java diff --git a/fabric/fabric-1.19.2/src/main/java/net/william278/huskhomes/event/TeleportWarmupCallback.java b/fabric/src/main/java/net/william278/huskhomes/event/TeleportWarmupCallback.java similarity index 100% rename from fabric/fabric-1.19.2/src/main/java/net/william278/huskhomes/event/TeleportWarmupCallback.java rename to fabric/src/main/java/net/william278/huskhomes/event/TeleportWarmupCallback.java diff --git a/fabric/fabric-1.19.2/src/main/java/net/william278/huskhomes/event/WarpCreateCallback.java b/fabric/src/main/java/net/william278/huskhomes/event/WarpCreateCallback.java similarity index 100% rename from fabric/fabric-1.19.2/src/main/java/net/william278/huskhomes/event/WarpCreateCallback.java rename to fabric/src/main/java/net/william278/huskhomes/event/WarpCreateCallback.java diff --git a/fabric/fabric-1.19.2/src/main/java/net/william278/huskhomes/event/WarpDeleteCallback.java b/fabric/src/main/java/net/william278/huskhomes/event/WarpDeleteCallback.java similarity index 100% rename from fabric/fabric-1.19.2/src/main/java/net/william278/huskhomes/event/WarpDeleteCallback.java rename to fabric/src/main/java/net/william278/huskhomes/event/WarpDeleteCallback.java diff --git a/fabric/fabric-1.19.2/src/main/java/net/william278/huskhomes/event/WarpListCallback.java b/fabric/src/main/java/net/william278/huskhomes/event/WarpListCallback.java similarity index 100% rename from fabric/fabric-1.19.2/src/main/java/net/william278/huskhomes/event/WarpListCallback.java rename to fabric/src/main/java/net/william278/huskhomes/event/WarpListCallback.java diff --git a/fabric/fabric-1.19.2/src/main/java/net/william278/huskhomes/listener/FabricEventListener.java b/fabric/src/main/java/net/william278/huskhomes/listener/FabricEventListener.java similarity index 100% rename from fabric/fabric-1.19.2/src/main/java/net/william278/huskhomes/listener/FabricEventListener.java rename to fabric/src/main/java/net/william278/huskhomes/listener/FabricEventListener.java diff --git a/fabric/fabric-1.20.1/src/main/java/net/william278/huskhomes/user/FabricUser.java b/fabric/src/main/java/net/william278/huskhomes/user/FabricUser.java similarity index 100% rename from fabric/fabric-1.20.1/src/main/java/net/william278/huskhomes/user/FabricUser.java rename to fabric/src/main/java/net/william278/huskhomes/user/FabricUser.java diff --git a/fabric/fabric-1.19.4/src/main/java/net/william278/huskhomes/util/FabricSafetyResolver.java b/fabric/src/main/java/net/william278/huskhomes/util/FabricSafetyResolver.java similarity index 100% rename from fabric/fabric-1.19.4/src/main/java/net/william278/huskhomes/util/FabricSafetyResolver.java rename to fabric/src/main/java/net/william278/huskhomes/util/FabricSafetyResolver.java diff --git a/fabric/fabric-1.20.1/src/main/java/net/william278/huskhomes/util/FabricTask.java b/fabric/src/main/java/net/william278/huskhomes/util/FabricTask.java similarity index 100% rename from fabric/fabric-1.20.1/src/main/java/net/william278/huskhomes/util/FabricTask.java rename to fabric/src/main/java/net/william278/huskhomes/util/FabricTask.java diff --git a/fabric/fabric-1.19.2/src/main/resources/assets/huskhomes/icon.png b/fabric/src/main/resources/assets/huskhomes/icon.png similarity index 100% rename from fabric/fabric-1.19.2/src/main/resources/assets/huskhomes/icon.png rename to fabric/src/main/resources/assets/huskhomes/icon.png diff --git a/fabric/fabric-1.19.2/src/main/resources/fabric.mod.json b/fabric/src/main/resources/fabric.mod.json similarity index 100% rename from fabric/fabric-1.19.2/src/main/resources/fabric.mod.json rename to fabric/src/main/resources/fabric.mod.json diff --git a/gradle.properties b/gradle.properties index 4a589c56..046a87c4 100644 --- a/gradle.properties +++ b/gradle.properties @@ -7,10 +7,19 @@ plugin_version=4.4.2 plugin_archive=huskhomes plugin_description=The powerful and intuitive homes, warps, and teleports plugin/mod +# General settings jedis_version=4.4.2 commons_pool_version=2.11.1 sqlite_driver_version=3.42.0.0 mysql_driver_version=8.0.33 +# Fabric settings fabric_loom_version=1.3-SNAPSHOT -fabric_permissions_api_version=0.2-SNAPSHOT \ No newline at end of file + +fabric_minecraft_version=1.20.1 +fabric_loader_version=0.14.21 +fabric_yarn_mappings=1.20.1+build.2 +fabric_api_version=0.83.1+1.20.1 + +fabric_permissions_api_version=0.2-SNAPSHOT +adventure_platform_fabric_version=5.9.0-SNAPSHOT \ No newline at end of file diff --git a/settings.gradle b/settings.gradle index 10dcd02c..12a72041 100644 --- a/settings.gradle +++ b/settings.gradle @@ -15,9 +15,7 @@ include( 'plugin', // Fabric - 'fabric:fabric-1.19.2', - 'fabric:fabric-1.19.4', - 'fabric:fabric-1.20.1', + 'fabric', // Sponge 'sponge'