Skip to content

Commit ed41931

Browse files
committed
add javadocs for some methods, add methods with array instead of list
1 parent 40516ca commit ed41931

File tree

2 files changed

+88
-0
lines changed

2 files changed

+88
-0
lines changed

core/src/main/java/net/labymod/serverapi/core/AbstractLabyModPlayer.java

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
import org.jetbrains.annotations.Nullable;
6161

6262
import java.util.ArrayList;
63+
import java.util.Arrays;
6364
import java.util.HashMap;
6465
import java.util.List;
6566
import java.util.Map;
@@ -221,6 +222,15 @@ public void disableAddons(List<String> addonsToDisable) {
221222
this.sendPacket(AddonDisablePacket.disable(addonsToDisable));
222223
}
223224

225+
/**
226+
* Forcefully disables the provided addons.
227+
*
228+
* @param addonsToDisable the addons to disable
229+
*/
230+
public void disableAddons(String... addonsToDisable) {
231+
this.disableAddons(Arrays.asList(addonsToDisable));
232+
}
233+
224234
/**
225235
* Reverts the forced disable state for the provided addons
226236
*
@@ -234,6 +244,15 @@ public void revertDisabledAddons(List<String> addonsToRevert) {
234244
this.sendPacket(AddonDisablePacket.revert(addonsToRevert));
235245
}
236246

247+
/**
248+
* Reverts the forced disable state for the provided addons
249+
*
250+
* @param addonsToRevert the addons to revert
251+
*/
252+
public void revertDisabledAddons(String... addonsToRevert) {
253+
this.revertDisabledAddons(Arrays.asList(addonsToRevert));
254+
}
255+
237256
/**
238257
* Reverts the forced disable state for all addons disabled via {@link #disableAddons(List)}
239258
*/
@@ -524,6 +543,29 @@ public void sendAddonRecommendations(@NotNull List<RecommendedAddon> addons) {
524543
this.sendLabyModPacket(new AddonRecommendationPacket(addons));
525544
}
526545

546+
/**
547+
* Sends the provided recommended addons to the player
548+
*
549+
* @param addons The recommended addons
550+
*/
551+
public void sendAddonRecommendations(@NotNull RecommendedAddon... addons) {
552+
this.sendLabyModPacket(new AddonRecommendationPacket(addons));
553+
}
554+
555+
/**
556+
* Sends the provided recommended addons to the player and handle the response via the provided
557+
* consumer
558+
*
559+
* @param responseConsumer The consumer for the response
560+
* @param addons The recommended addons
561+
*/
562+
public void sendAddonRecommendations(
563+
@NotNull Consumer<AddonRecommendationResponsePacket> responseConsumer,
564+
@NotNull RecommendedAddon... addons
565+
) {
566+
this.sendAddonRecommendations(Arrays.asList(addons), responseConsumer);
567+
}
568+
527569
/**
528570
* Sends the provided recommended addons to the player and handle the response via the provided
529571
* consumer

server/common/src/main/java/net/labymod/serverapi/server/common/model/player/AbstractServerLabyModPlayer.java

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import org.jetbrains.annotations.NotNull;
3333

3434
import java.util.ArrayList;
35+
import java.util.Arrays;
3536
import java.util.List;
3637
import java.util.UUID;
3738
import java.util.function.Consumer;
@@ -60,22 +61,67 @@ public T getPlayer() {
6061
return this.serverPlayer;
6162
}
6263

64+
/**
65+
* @return the installed addons of the user. The object is empty until one of the request
66+
* methods is called.
67+
*/
6368
public @NotNull InstalledAddonsResponse installedAddons() {
6469
return this.installedAddonsResponse;
6570
}
6671

72+
/**
73+
* Requests ALL installed addons from the user.
74+
*/
6775
public void requestInstalledAddons() {
6876
this.requestInstalledAddons(new ArrayList<>(), null);
6977
}
7078

79+
/**
80+
* Requests ALL installed addons from the user.
81+
*
82+
* @param response the response consumer. Called when the response is received.
83+
*/
7184
public void requestInstalledAddons(Consumer<InstalledAddonsResponse> response) {
7285
this.requestInstalledAddons(new ArrayList<>(), response);
7386
}
7487

88+
/**
89+
* Requests the installed state of the provided addons.
90+
*
91+
* @param addonsToRequest The addons to request the installed state of.
92+
*/
93+
public void requestInstalledAddons(String... addonsToRequest) {
94+
this.requestInstalledAddons(Arrays.asList(addonsToRequest), null);
95+
}
96+
97+
/**
98+
* Requests the installed state of the provided addons.
99+
*
100+
* @param addonsToRequest The addons to request the installed state of.
101+
*/
75102
public void requestInstalledAddons(@NotNull List<String> addonsToRequest) {
76103
this.requestInstalledAddons(addonsToRequest, null);
77104
}
78105

106+
/**
107+
* Requests the installed state of the provided addons.
108+
*
109+
* @param response the response consumer. Called when the response is received.
110+
* @param addonsToRequest The addons to request the installed state of.
111+
*/
112+
public void requestInstalledAddons(
113+
Consumer<InstalledAddonsResponse> response,
114+
String... addonsToRequest
115+
) {
116+
this.requestInstalledAddons(Arrays.asList(addonsToRequest), response);
117+
}
118+
119+
/**
120+
* Requests the installed state of the provided addons.
121+
*
122+
* @param addonsToRequest The addons to request the installed state of.
123+
* @param response the response consumer. Called when the response is received.
124+
*/
79125
public void requestInstalledAddons(
80126
@NotNull List<String> addonsToRequest,
81127
Consumer<InstalledAddonsResponse> response

0 commit comments

Comments
 (0)