mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-03 14:38:53 +00:00
feat: target Minecraft 1.21 on Fabric, add API
Also adjusts how the HuskHomes API on Fabric is versioned. Now has the pattern: `net.william278.huskhomes:huskhomes-fabric:<version>+<mc_version>` Closes #640
This commit is contained in:
11 files changed
+258
-75
No files matched your search
+18
-15
@@ -3,6 +3,7 @@ import org.apache.tools.ant.filters.ReplaceTokens
|
|||||||
plugins {
|
plugins {
|
||||||
id 'io.github.goooler.shadow' version '8.1.7'
|
id 'io.github.goooler.shadow' version '8.1.7'
|
||||||
id 'org.cadixdev.licenser' version '0.6.1' apply false
|
id 'org.cadixdev.licenser' version '0.6.1' apply false
|
||||||
|
id 'fabric-loom' version "$fabric_loom_version" apply false
|
||||||
id 'org.ajoberstar.grgit' version '5.2.2'
|
id 'org.ajoberstar.grgit' version '5.2.2'
|
||||||
id 'checkstyle'
|
id 'checkstyle'
|
||||||
id 'maven-publish'
|
id 'maven-publish'
|
||||||
@@ -70,10 +71,6 @@ allprojects {
|
|||||||
repositories {
|
repositories {
|
||||||
mavenLocal()
|
mavenLocal()
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
maven {
|
|
||||||
url 'https://s01.oss.sonatype.org/content/repositories/snapshots/'
|
|
||||||
mavenContent { snapshotsOnly() }
|
|
||||||
}
|
|
||||||
maven { url 'https://repo.william278.net/releases/' }
|
maven { url 'https://repo.william278.net/releases/' }
|
||||||
maven { url 'https://maven.fabricmc.net/' }
|
maven { url 'https://maven.fabricmc.net/' }
|
||||||
maven { url 'https://libraries.minecraft.net/' }
|
maven { url 'https://libraries.minecraft.net/' }
|
||||||
@@ -87,6 +84,7 @@ allprojects {
|
|||||||
maven { url 'https://repo.alessiodp.com/releases/' }
|
maven { url 'https://repo.alessiodp.com/releases/' }
|
||||||
maven { url 'https://repo.essentialsx.net/releases/' }
|
maven { url 'https://repo.essentialsx.net/releases/' }
|
||||||
maven { url 'https://repo.mikeprimm.com/' }
|
maven { url 'https://repo.mikeprimm.com/' }
|
||||||
|
maven { url 'https://maven.impactdev.net/repository/development' }
|
||||||
maven { url 'https://jitpack.io' }
|
maven { url 'https://jitpack.io' }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -121,6 +119,11 @@ allprojects {
|
|||||||
}
|
}
|
||||||
|
|
||||||
subprojects {
|
subprojects {
|
||||||
|
if (['fabric'].contains(project.name)) {
|
||||||
|
apply plugin: 'fabric-loom'
|
||||||
|
compileJava.options.release.set 21
|
||||||
|
}
|
||||||
|
|
||||||
version rootProject.version
|
version rootProject.version
|
||||||
archivesBaseName = "${rootProject.name}-${project.name.capitalize()}"
|
archivesBaseName = "${rootProject.name}-${project.name.capitalize()}"
|
||||||
|
|
||||||
@@ -133,10 +136,6 @@ subprojects {
|
|||||||
archiveClassifier.set('')
|
archiveClassifier.set('')
|
||||||
}
|
}
|
||||||
|
|
||||||
if (['fabric'].contains(project.name)) {
|
|
||||||
compileJava.options.release.set 21
|
|
||||||
}
|
|
||||||
|
|
||||||
// API publishing
|
// API publishing
|
||||||
if (['common', 'bukkit', 'fabric', 'sponge'].contains(project.name)) {
|
if (['common', 'bukkit', 'fabric', 'sponge'].contains(project.name)) {
|
||||||
java {
|
java {
|
||||||
@@ -183,8 +182,8 @@ subprojects {
|
|||||||
mavenJavaFabric(MavenPublication) {
|
mavenJavaFabric(MavenPublication) {
|
||||||
groupId = 'net.william278.huskhomes'
|
groupId = 'net.william278.huskhomes'
|
||||||
artifactId = 'huskhomes-fabric'
|
artifactId = 'huskhomes-fabric'
|
||||||
version = "$rootProject.version"
|
version = "$rootProject.version+${fabric_minecraft_version}"
|
||||||
artifact shadowJar
|
artifact remapJar
|
||||||
artifact sourcesJar
|
artifact sourcesJar
|
||||||
artifact javadocJar
|
artifact javadocJar
|
||||||
}
|
}
|
||||||
@@ -214,16 +213,20 @@ logger.lifecycle("Building HuskHomes ${version} by William278")
|
|||||||
|
|
||||||
@SuppressWarnings('GrMethodMayBeStatic')
|
@SuppressWarnings('GrMethodMayBeStatic')
|
||||||
def versionMetadata() {
|
def versionMetadata() {
|
||||||
|
// Require grgit
|
||||||
if (grgit == null) {
|
if (grgit == null) {
|
||||||
return '-' + System.getenv("GITHUB_RUN_NUMBER") ? 'build.' + System.getenv("GITHUB_RUN_NUMBER") : 'unknown'
|
return '-unknown'
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get if there is a tag for this commit
|
// If unclean, return the last commit hash with -indev
|
||||||
|
if (!grgit.status().clean) {
|
||||||
|
return '-' + grgit.head().abbreviatedId + '-indev'
|
||||||
|
}
|
||||||
|
|
||||||
|
// Otherwise if this matches a tag, return nothing
|
||||||
def tag = grgit.tag.list().find { it.commit.id == grgit.head().id }
|
def tag = grgit.tag.list().find { it.commit.id == grgit.head().id }
|
||||||
if (tag != null) {
|
if (tag != null) {
|
||||||
return ''
|
return ''
|
||||||
}
|
}
|
||||||
|
return '-' + grgit.head().abbreviatedId
|
||||||
// Otherwise, get the last commit hash and if it's a clean head
|
|
||||||
return '-' + grgit.head().abbreviatedId + (grgit.status().clean ? '' : '-indev')
|
|
||||||
}
|
}
|
||||||
@@ -38,6 +38,8 @@ import java.util.Objects;
|
|||||||
* and process teleports
|
* and process teleports
|
||||||
*
|
*
|
||||||
* <p>Retrieve an instance of the API class via {@link #getInstance()}.
|
* <p>Retrieve an instance of the API class via {@link #getInstance()}.
|
||||||
|
*
|
||||||
|
* @since 3.0
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public class HuskHomesAPI extends BaseHuskHomesAPI {
|
public class HuskHomesAPI extends BaseHuskHomesAPI {
|
||||||
@@ -72,10 +74,10 @@ public class HuskHomesAPI extends BaseHuskHomesAPI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an {@link OnlineUser} instance for the given bukkit {@link Player}.
|
* Returns an {@link OnlineUser} instance for the given Bukkit {@link Player}.
|
||||||
*
|
*
|
||||||
* @param player the bukkit player to get the {@link User} instance for
|
* @param player the Bukkit player to get the {@link User} instance for
|
||||||
* @return the {@link OnlineUser} instance for the given bukkit {@link Player}
|
* @return the {@link OnlineUser} instance for the given Bukkit {@link Player}
|
||||||
* @since 3.0
|
* @since 3.0
|
||||||
*/
|
*/
|
||||||
@NotNull
|
@NotNull
|
||||||
@@ -84,10 +86,10 @@ public class HuskHomesAPI extends BaseHuskHomesAPI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the bukkit {@link Player} being represented by the given {@link OnlineUser}.
|
* Returns the Bukkit {@link Player} being represented by the given {@link OnlineUser}.
|
||||||
*
|
*
|
||||||
* @param user {@link OnlineUser} to get the bukkit player from
|
* @param user {@link OnlineUser} to get the Bukkit player from
|
||||||
* @return the bukkit {@link Player} being represented by the given {@link OnlineUser}
|
* @return the Bukkit {@link Player} being represented by the given {@link OnlineUser}
|
||||||
* @since 3.0
|
* @since 3.0
|
||||||
*/
|
*/
|
||||||
@NotNull
|
@NotNull
|
||||||
@@ -96,10 +98,10 @@ public class HuskHomesAPI extends BaseHuskHomesAPI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the bukkit {@link Location} being represented by the given {@link Position}.
|
* Returns the Bukkit {@link Location} being represented by the given {@link Position}.
|
||||||
*
|
*
|
||||||
* @param position the {@link Position} to get the bukkit location from
|
* @param position the {@link Position} to get the Bukkit location from
|
||||||
* @return the bukkit {@link Location} being represented by the given {@link Position}
|
* @return the Bukkit {@link Location} being represented by the given {@link Position}
|
||||||
* @since 3.0
|
* @since 3.0
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
@@ -108,10 +110,10 @@ public class HuskHomesAPI extends BaseHuskHomesAPI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a {@link Location} instance for the given bukkit {@link Location} on the server.
|
* Returns a {@link Location} instance for the given Bukkit {@link Location} on the server.
|
||||||
*
|
*
|
||||||
* @param location the bukkit location to get the {@link Location} instance for
|
* @param location the Bukkit location to get the {@link Location} instance for
|
||||||
* @return the {@link Location} instance for the given bukkit {@link Location}
|
* @return the {@link Location} instance for the given Bukkit {@link Location}
|
||||||
* @since 3.0
|
* @since 3.0
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
@@ -120,11 +122,11 @@ public class HuskHomesAPI extends BaseHuskHomesAPI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a {@link Position} instance for the given bukkit {@link Location} on the server.
|
* Returns a {@link Position} instance for the given Bukkit {@link Location} on the server.
|
||||||
*
|
*
|
||||||
* @param location the bukkit location to get the {@link Position} instance for
|
* @param location the Bukkit location to get the {@link Position} instance for
|
||||||
* @param server the {@link Server} the position is on
|
* @param server the {@link Server} the position is on
|
||||||
* @return the {@link Position} instance for the given bukkit {@link Location} on the given {@link Server}
|
* @return the {@link Position} instance for the given Bukkit {@link Location} on the given {@link Server}
|
||||||
* @see Position#getServer() to get the server the position is on
|
* @see Position#getServer() to get the server the position is on
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
*/
|
*/
|
||||||
@@ -134,9 +136,9 @@ public class HuskHomesAPI extends BaseHuskHomesAPI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a {@link Position} instance for the given bukkit {@link Location} on the server.
|
* Returns a {@link Position} instance for the given Bukkit {@link Location} on the server.
|
||||||
*
|
*
|
||||||
* @param location the bukkit location to get the {@link Position} instance for
|
* @param location the Bukkit location to get the {@link Position} instance for
|
||||||
* @return the {@link Position} instance for the given {@link Location} on the server
|
* @return the {@link Position} instance for the given {@link Location} on the server
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
*/
|
*/
|
||||||
@@ -145,15 +147,4 @@ public class HuskHomesAPI extends BaseHuskHomesAPI {
|
|||||||
return Position.at(Objects.requireNonNull(adaptLocation(location)), getServer());
|
return Position.at(Objects.requireNonNull(adaptLocation(location)), getServer());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the name of this server.
|
|
||||||
*
|
|
||||||
* @return the server name
|
|
||||||
* @since 4.0
|
|
||||||
*/
|
|
||||||
@NotNull
|
|
||||||
public String getServer() {
|
|
||||||
return plugin.getServerName();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -71,6 +71,17 @@ public class BaseHuskHomesAPI {
|
|||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the name of this server.
|
||||||
|
*
|
||||||
|
* @return the server name
|
||||||
|
* @since 4.6.4
|
||||||
|
*/
|
||||||
|
@NotNull
|
||||||
|
public String getServer() {
|
||||||
|
return plugin.getServerName();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns saved {@link SavedUser} for the given player's account {@link UUID}, if they exist.
|
* Returns saved {@link SavedUser} for the given player's account {@link UUID}, if they exist.
|
||||||
*
|
*
|
||||||
|
|||||||
+2
-13
@@ -15,22 +15,11 @@ dependencies {
|
|||||||
mappings "net.fabricmc:yarn:${fabric_yarn_mappings}:v2"
|
mappings "net.fabricmc:yarn:${fabric_yarn_mappings}:v2"
|
||||||
modImplementation "net.fabricmc:fabric-loader:${fabric_loader_version}"
|
modImplementation "net.fabricmc:fabric-loader:${fabric_loader_version}"
|
||||||
|
|
||||||
// Fabric API modules
|
|
||||||
Set<String> fabricApiModules = [
|
|
||||||
'fabric-api-base',
|
|
||||||
'fabric-lifecycle-events-v1',
|
|
||||||
'fabric-entity-events-v1',
|
|
||||||
'fabric-command-api-v2',
|
|
||||||
'fabric-networking-api-v1',
|
|
||||||
'fabric-dimensions-v1',
|
|
||||||
]
|
|
||||||
fabricApiModules.forEach {
|
|
||||||
modCompileOnly(fabricApi.module(it, fabric_api_version))
|
|
||||||
}
|
|
||||||
modImplementation include("net.kyori:adventure-platform-fabric:${adventure_platform_fabric_version}")
|
modImplementation include("net.kyori:adventure-platform-fabric:${adventure_platform_fabric_version}")
|
||||||
modImplementation include("me.lucko:fabric-permissions-api:${fabric_permissions_api_version}")
|
modImplementation include("me.lucko:fabric-permissions-api:${fabric_permissions_api_version}")
|
||||||
modImplementation include("eu.pb4:placeholder-api:${fabric_placeholder_api_version}")
|
modImplementation include("eu.pb4:placeholder-api:${fabric_placeholder_api_version}")
|
||||||
modImplementation("net.impactdev.impactor.api:economy:${fabric_impactor_api_version}")
|
modImplementation include("net.impactdev.impactor.api:economy:${fabric_impactor_api_version}")
|
||||||
|
modCompileOnly "net.fabricmc.fabric-api:fabric-api:${fabric_api_version}"
|
||||||
|
|
||||||
implementation include("redis.clients:jedis:$jedis_version")
|
implementation include("redis.clients:jedis:$jedis_version")
|
||||||
implementation include("org.apache.commons:commons-pool2:$commons_pool_version")
|
implementation include("org.apache.commons:commons-pool2:$commons_pool_version")
|
||||||
|
|||||||
@@ -34,6 +34,8 @@ import net.fabricmc.loader.api.FabricLoader;
|
|||||||
import net.fabricmc.loader.api.ModContainer;
|
import net.fabricmc.loader.api.ModContainer;
|
||||||
import net.kyori.adventure.audience.Audience;
|
import net.kyori.adventure.audience.Audience;
|
||||||
import net.kyori.adventure.platform.fabric.FabricServerAudiences;
|
import net.kyori.adventure.platform.fabric.FabricServerAudiences;
|
||||||
|
import net.minecraft.registry.RegistryKey;
|
||||||
|
import net.minecraft.registry.RegistryKeys;
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
import net.minecraft.server.world.ServerWorld;
|
import net.minecraft.server.world.ServerWorld;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
@@ -41,6 +43,7 @@ import net.minecraft.util.math.BlockPos;
|
|||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
import net.minecraft.world.TeleportTarget;
|
import net.minecraft.world.TeleportTarget;
|
||||||
import net.william278.desertwell.util.Version;
|
import net.william278.desertwell.util.Version;
|
||||||
|
import net.william278.huskhomes.api.FabricHuskHomesAPI;
|
||||||
import net.william278.huskhomes.command.Command;
|
import net.william278.huskhomes.command.Command;
|
||||||
import net.william278.huskhomes.command.FabricCommand;
|
import net.william278.huskhomes.command.FabricCommand;
|
||||||
import net.william278.huskhomes.config.Locales;
|
import net.william278.huskhomes.config.Locales;
|
||||||
@@ -192,6 +195,9 @@ public class FabricHuskHomes implements DedicatedServerModInitializer, HuskHomes
|
|||||||
// Register events
|
// Register events
|
||||||
initialize("events", (plugin) -> this.eventListener = new FabricEventListener(this));
|
initialize("events", (plugin) -> this.eventListener = new FabricEventListener(this));
|
||||||
|
|
||||||
|
// Initialize the API
|
||||||
|
initialize("API", (plugin) -> FabricHuskHomesAPI.register(this));
|
||||||
|
|
||||||
this.checkForUpdates();
|
this.checkForUpdates();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -250,7 +256,10 @@ public class FabricHuskHomes implements DedicatedServerModInitializer, HuskHomes
|
|||||||
public void setWorldSpawn(@NotNull Position position) {
|
public void setWorldSpawn(@NotNull Position position) {
|
||||||
final ServerWorld world = Adapter.adapt(position, minecraftServer);
|
final ServerWorld world = Adapter.adapt(position, minecraftServer);
|
||||||
if (world != null) {
|
if (world != null) {
|
||||||
world.setSpawnPos(BlockPos.ofFloored(Adapter.adapt(position).position), position.getYaw());
|
world.setSpawnPos(
|
||||||
|
BlockPos.ofFloored(position.getX(), position.getY(), position.getZ()),
|
||||||
|
position.getYaw()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -403,25 +412,28 @@ public class FabricHuskHomes implements DedicatedServerModInitializer, HuskHomes
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public static TeleportTarget adapt(@NotNull Location location) {
|
public static TeleportTarget adapt(@NotNull Location location, @NotNull MinecraftServer server) {
|
||||||
return new TeleportTarget(
|
return new TeleportTarget(
|
||||||
|
adapt(location.getWorld(), server),
|
||||||
new Vec3d(location.getX(), location.getY(), location.getZ()),
|
new Vec3d(location.getX(), location.getY(), location.getZ()),
|
||||||
Vec3d.ZERO,
|
Vec3d.ZERO,
|
||||||
location.getYaw(),
|
location.getYaw(),
|
||||||
location.getPitch()
|
location.getPitch(),
|
||||||
|
entity -> entity.refreshPositionAndAngles(
|
||||||
|
location.getX(), location.getY(), location.getZ(),
|
||||||
|
location.getYaw(), location.getPitch()
|
||||||
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public static ServerWorld adapt(@NotNull World world, @NotNull MinecraftServer server) {
|
public static ServerWorld adapt(@NotNull World world, @NotNull MinecraftServer server) {
|
||||||
return server.getWorld(server.getWorldRegistryKeys().stream()
|
return server.getWorld(RegistryKey.of(RegistryKeys.WORLD, Identifier.tryParse(world.getName())));
|
||||||
.filter(key -> key.getValue().equals(Identifier.tryParse(world.getName())))
|
|
||||||
.findFirst().orElse(null));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public static ServerWorld adapt(@NotNull Location location, @NotNull MinecraftServer server) {
|
public static ServerWorld adapt(@NotNull Position position, @NotNull MinecraftServer server) {
|
||||||
return adapt(location.getWorld(), server);
|
return adapt(position.getWorld(), server);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
|
|||||||
@@ -0,0 +1,173 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of HuskHomes, licensed under the Apache License 2.0.
|
||||||
|
*
|
||||||
|
* Copyright (c) William278 <[email protected]>
|
||||||
|
* 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.api;
|
||||||
|
|
||||||
|
import net.minecraft.server.network.ServerPlayerEntity;
|
||||||
|
import net.minecraft.server.world.ServerWorld;
|
||||||
|
import net.minecraft.util.math.Vec3d;
|
||||||
|
import net.minecraft.world.TeleportTarget;
|
||||||
|
import net.william278.huskhomes.FabricHuskHomes;
|
||||||
|
import net.william278.huskhomes.config.Server;
|
||||||
|
import net.william278.huskhomes.position.Location;
|
||||||
|
import net.william278.huskhomes.position.Position;
|
||||||
|
import net.william278.huskhomes.position.World;
|
||||||
|
import net.william278.huskhomes.user.FabricUser;
|
||||||
|
import net.william278.huskhomes.user.OnlineUser;
|
||||||
|
import net.william278.huskhomes.user.User;
|
||||||
|
import org.jetbrains.annotations.ApiStatus;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The HuskHomes API implementation for the Fabric platform, providing methods to access ServerPlayerEntity data,
|
||||||
|
* homes, warps and process teleports
|
||||||
|
*
|
||||||
|
* <p>Retrieve an instance of the API class via {@link #getInstance()}.
|
||||||
|
*
|
||||||
|
* @since 4.7
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
public class FabricHuskHomesAPI extends BaseHuskHomesAPI {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>(Internal use only)</b> - Constructor, instantiating the API.
|
||||||
|
*/
|
||||||
|
@ApiStatus.Internal
|
||||||
|
private FabricHuskHomesAPI(@NotNull FabricHuskHomes plugin) {
|
||||||
|
super(plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get an instance of the HuskHomes API.
|
||||||
|
*
|
||||||
|
* @return instance of the HuskHomes API
|
||||||
|
* @throws NotRegisteredException if the API has not yet been registered.
|
||||||
|
*/
|
||||||
|
@NotNull
|
||||||
|
public static FabricHuskHomesAPI getInstance() throws NotRegisteredException {
|
||||||
|
return (FabricHuskHomesAPI) BaseHuskHomesAPI.getInstance();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>(Internal use only)</b> - Register the API for this platform.
|
||||||
|
*
|
||||||
|
* @param plugin the plugin instance
|
||||||
|
*/
|
||||||
|
@ApiStatus.Internal
|
||||||
|
public static void register(@NotNull FabricHuskHomes plugin) {
|
||||||
|
instance = new FabricHuskHomesAPI(plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns an {@link OnlineUser} instance for the given Fabric {@link ServerPlayerEntity}.
|
||||||
|
*
|
||||||
|
* @param player the Fabric ServerPlayerEntity to get the {@link User} instance for
|
||||||
|
* @return the {@link OnlineUser} instance for the given Fabric {@link ServerPlayerEntity}
|
||||||
|
* @since 4.7
|
||||||
|
*/
|
||||||
|
@NotNull
|
||||||
|
public OnlineUser adaptUser(@NotNull ServerPlayerEntity player) {
|
||||||
|
return FabricUser.adapt(player, (FabricHuskHomes) plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the Fabric {@link ServerPlayerEntity} being represented by the given {@link OnlineUser}.
|
||||||
|
*
|
||||||
|
* @param user {@link OnlineUser} to get the Fabric ServerPlayerEntity from
|
||||||
|
* @return the Fabric {@link ServerPlayerEntity} being represented by the given {@link OnlineUser}
|
||||||
|
* @since 4.7
|
||||||
|
*/
|
||||||
|
@NotNull
|
||||||
|
public ServerPlayerEntity getServerPlayerEntity(@NotNull OnlineUser user) {
|
||||||
|
return ((FabricUser) user).getPlayer();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the Fabric {@link Location} being represented by the given {@link Position}.
|
||||||
|
*
|
||||||
|
* @param position the {@link Position} to get the Fabric location from
|
||||||
|
* @return the fabric {@link ServerWorld} being represented by the given {@link Position}
|
||||||
|
* @since 4.7
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public ServerWorld getServerWorld(@NotNull World position) {
|
||||||
|
return FabricHuskHomes.Adapter.adapt(position, ((FabricHuskHomes) plugin).getMinecraftServer());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the Fabric {@link TeleportTarget} being represented by the given {@link Location}.
|
||||||
|
*
|
||||||
|
* @param location the {@link Location} to get the {@link TeleportTarget} from
|
||||||
|
* @return the {@link TeleportTarget} being represented by the given {@link Location}
|
||||||
|
* @since 4.7
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public TeleportTarget getTeleportTarget(@NotNull Location location) {
|
||||||
|
return FabricHuskHomes.Adapter.adapt(location, ((FabricHuskHomes) plugin).getMinecraftServer());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a {@link Location} instance for the given Fabric {@link Location} on the server.
|
||||||
|
*
|
||||||
|
* @return the {@link Location} instance for the given Fabric {@link Location}
|
||||||
|
* @since 4.7
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public Location adaptLocation(@NotNull Vec3d pos, @NotNull net.minecraft.world.World world,
|
||||||
|
float yaw, float pitch) {
|
||||||
|
return FabricHuskHomes.Adapter.adapt(pos, world, yaw, pitch);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a {@link Position} instance for the given Fabric {@link Location} on the server.
|
||||||
|
*
|
||||||
|
* @param pos the {@link Vec3d} position to get the {@link Position} instance for
|
||||||
|
* @param world the world the position is on
|
||||||
|
* @param yaw the yaw of the position
|
||||||
|
* @param pitch the pitch of the position
|
||||||
|
* @param server the {@link Server} the position is on
|
||||||
|
* @return the {@link Position} instance for the given Fabric {@link Location} on the given {@link Server}
|
||||||
|
* @see Position#getServer() to get the server the position is on
|
||||||
|
* @since 4.7
|
||||||
|
*/
|
||||||
|
@NotNull
|
||||||
|
public Position adaptPosition(@NotNull Vec3d pos, @NotNull net.minecraft.world.World world,
|
||||||
|
float yaw, float pitch, @NotNull String server) {
|
||||||
|
return FabricHuskHomes.Adapter.adapt(pos, world, yaw, pitch, server);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a {@link Position} instance for the given Fabric {@link Location} on the server.
|
||||||
|
*
|
||||||
|
* @param pos the {@link Vec3d} position to get the {@link Position} instance for
|
||||||
|
* @param world the world the position is on
|
||||||
|
* @param yaw the yaw of the position
|
||||||
|
* @param pitch the pitch of the position
|
||||||
|
* @return the {@link Position} instance for the given Fabric {@link Location} on the given {@link Server}
|
||||||
|
* @see Position#getServer() to get the server the position is on
|
||||||
|
* @since 4.7
|
||||||
|
*/
|
||||||
|
@NotNull
|
||||||
|
public Position adaptPosition(@NotNull Vec3d pos, @NotNull net.minecraft.world.World world,
|
||||||
|
float yaw, float pitch) {
|
||||||
|
return FabricHuskHomes.Adapter.adapt(pos, world, yaw, pitch, getServer());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -39,7 +39,7 @@ public class FabricPlaceholderAPIHook extends Hook {
|
|||||||
@SuppressWarnings("SameParameterValue")
|
@SuppressWarnings("SameParameterValue")
|
||||||
@NotNull
|
@NotNull
|
||||||
private Identifier createIdentifier(@NotNull String name) {
|
private Identifier createIdentifier(@NotNull String name) {
|
||||||
return new Identifier("huskhomes", name);
|
return Identifier.of("huskhomes", name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -20,7 +20,6 @@
|
|||||||
package net.william278.huskhomes.user;
|
package net.william278.huskhomes.user;
|
||||||
|
|
||||||
import me.lucko.fabric.api.permissions.v0.Permissions;
|
import me.lucko.fabric.api.permissions.v0.Permissions;
|
||||||
import net.fabricmc.fabric.api.dimension.v1.FabricDimensions;
|
|
||||||
import net.kyori.adventure.audience.Audience;
|
import net.kyori.adventure.audience.Audience;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.network.packet.s2c.common.CustomPayloadS2CPacket;
|
import net.minecraft.network.packet.s2c.common.CustomPayloadS2CPacket;
|
||||||
@@ -145,7 +144,7 @@ public class FabricUser extends OnlineUser {
|
|||||||
if (world == null) {
|
if (world == null) {
|
||||||
throw new TeleportationException(TeleportationException.Type.WORLD_NOT_FOUND, plugin);
|
throw new TeleportationException(TeleportationException.Type.WORLD_NOT_FOUND, plugin);
|
||||||
}
|
}
|
||||||
FabricDimensions.teleport(player, world, FabricHuskHomes.Adapter.adapt(location));
|
player.teleportTo(FabricHuskHomes.Adapter.adapt(location, server));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -178,4 +177,9 @@ public class FabricUser extends OnlineUser {
|
|||||||
plugin.runSyncDelayed(() -> player.setInvulnerable(false), this, invulnerabilityTimeInTicks);
|
plugin.runSyncDelayed(() -> player.setInvulnerable(false), this, invulnerabilityTimeInTicks);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public ServerPlayerEntity getPlayer() {
|
||||||
|
return player;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
+7
-7
@@ -18,12 +18,12 @@ postgresql_driver_version=42.7.3
|
|||||||
commons_pool_version=2.12.0
|
commons_pool_version=2.12.0
|
||||||
|
|
||||||
# Fabric settings
|
# Fabric settings
|
||||||
fabric_loom_version=1.6-SNAPSHOT
|
fabric_loom_version=1.7-SNAPSHOT
|
||||||
fabric_minecraft_version=1.20.6
|
fabric_minecraft_version=1.21
|
||||||
fabric_loader_version=0.15.11
|
fabric_loader_version=0.15.11
|
||||||
fabric_yarn_mappings=1.20.6+build.3
|
fabric_yarn_mappings=1.21+build.2
|
||||||
fabric_api_version=0.99.0+1.20.6
|
fabric_api_version=0.100.3+1.21
|
||||||
fabric_permissions_api_version=0.3.1
|
fabric_permissions_api_version=0.3.1
|
||||||
adventure_platform_fabric_version=5.13.0
|
adventure_platform_fabric_version=5.14.0
|
||||||
fabric_impactor_api_version=5.2.4
|
fabric_impactor_api_version=5.2.4-SNAPSHOT
|
||||||
fabric_placeholder_api_version=2.4.0-pre.1+1.20.5
|
fabric_placeholder_api_version=2.4.0+1.21
|
||||||
Vendored
BIN
Binary file not shown.
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
|
||||||
networkTimeout=10000
|
networkTimeout=10000
|
||||||
validateDistributionUrl=true
|
validateDistributionUrl=true
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
|
|||||||
Reference in new issue
Block a user