diff --git a/core/src/main/java/net/labymod/serverapi/core/AbstractLabyModPlayer.java b/core/src/main/java/net/labymod/serverapi/core/AbstractLabyModPlayer.java index f35d0df..b88b29e 100644 --- a/core/src/main/java/net/labymod/serverapi/core/AbstractLabyModPlayer.java +++ b/core/src/main/java/net/labymod/serverapi/core/AbstractLabyModPlayer.java @@ -60,6 +60,7 @@ import org.jetbrains.annotations.Nullable; import java.util.ArrayList; +import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -221,6 +222,15 @@ public void disableAddons(List addonsToDisable) { this.sendPacket(AddonDisablePacket.disable(addonsToDisable)); } + /** + * Forcefully disables the provided addons. + * + * @param addonsToDisable the addons to disable + */ + public void disableAddons(String... addonsToDisable) { + this.disableAddons(Arrays.asList(addonsToDisable)); + } + /** * Reverts the forced disable state for the provided addons * @@ -234,6 +244,15 @@ public void revertDisabledAddons(List addonsToRevert) { this.sendPacket(AddonDisablePacket.revert(addonsToRevert)); } + /** + * Reverts the forced disable state for the provided addons + * + * @param addonsToRevert the addons to revert + */ + public void revertDisabledAddons(String... addonsToRevert) { + this.revertDisabledAddons(Arrays.asList(addonsToRevert)); + } + /** * Reverts the forced disable state for all addons disabled via {@link #disableAddons(List)} */ @@ -524,6 +543,29 @@ public void sendAddonRecommendations(@NotNull List addons) { this.sendLabyModPacket(new AddonRecommendationPacket(addons)); } + /** + * Sends the provided recommended addons to the player + * + * @param addons The recommended addons + */ + public void sendAddonRecommendations(@NotNull RecommendedAddon... addons) { + this.sendLabyModPacket(new AddonRecommendationPacket(addons)); + } + + /** + * Sends the provided recommended addons to the player and handle the response via the provided + * consumer + * + * @param responseConsumer The consumer for the response + * @param addons The recommended addons + */ + public void sendAddonRecommendations( + @NotNull Consumer responseConsumer, + @NotNull RecommendedAddon... addons + ) { + this.sendAddonRecommendations(Arrays.asList(addons), responseConsumer); + } + /** * Sends the provided recommended addons to the player and handle the response via the provided * consumer diff --git a/server/common/src/main/java/net/labymod/serverapi/server/common/model/player/AbstractServerLabyModPlayer.java b/server/common/src/main/java/net/labymod/serverapi/server/common/model/player/AbstractServerLabyModPlayer.java index a403539..7acb42f 100644 --- a/server/common/src/main/java/net/labymod/serverapi/server/common/model/player/AbstractServerLabyModPlayer.java +++ b/server/common/src/main/java/net/labymod/serverapi/server/common/model/player/AbstractServerLabyModPlayer.java @@ -32,6 +32,7 @@ import org.jetbrains.annotations.NotNull; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import java.util.UUID; import java.util.function.Consumer; @@ -60,22 +61,67 @@ public T getPlayer() { return this.serverPlayer; } + /** + * @return the installed addons of the user. The object is empty until one of the request + * methods is called. + */ public @NotNull InstalledAddonsResponse installedAddons() { return this.installedAddonsResponse; } + /** + * Requests ALL installed addons from the user. + */ public void requestInstalledAddons() { this.requestInstalledAddons(new ArrayList<>(), null); } + /** + * Requests ALL installed addons from the user. + * + * @param response the response consumer. Called when the response is received. + */ public void requestInstalledAddons(Consumer response) { this.requestInstalledAddons(new ArrayList<>(), response); } + /** + * Requests the installed state of the provided addons. + * + * @param addonsToRequest The addons to request the installed state of. + */ + public void requestInstalledAddons(String... addonsToRequest) { + this.requestInstalledAddons(Arrays.asList(addonsToRequest), null); + } + + /** + * Requests the installed state of the provided addons. + * + * @param addonsToRequest The addons to request the installed state of. + */ public void requestInstalledAddons(@NotNull List addonsToRequest) { this.requestInstalledAddons(addonsToRequest, null); } + /** + * Requests the installed state of the provided addons. + * + * @param response the response consumer. Called when the response is received. + * @param addonsToRequest The addons to request the installed state of. + */ + public void requestInstalledAddons( + Consumer response, + String... addonsToRequest + ) { + this.requestInstalledAddons(Arrays.asList(addonsToRequest), response); + } + + /** + * Requests the installed state of the provided addons. + * + * @param addonsToRequest The addons to request the installed state of. + * @param response the response consumer. Called when the response is received. + */ public void requestInstalledAddons( @NotNull List addonsToRequest, Consumer response