Skip to content

Commit

Permalink
chore: more javadocs
Browse files Browse the repository at this point in the history
  • Loading branch information
Jamalam360 committed Jan 4, 2023
1 parent c963da3 commit 07976fc
Show file tree
Hide file tree
Showing 12 changed files with 34 additions and 113 deletions.
4 changes: 4 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ java {
withJavadocJar()
}

tasks.withType(Javadoc::class.java) {
exclude("**/mixin/**")
}

sourceSets {
val main = this.getByName("main")

Expand Down
4 changes: 0 additions & 4 deletions src/main/java/io/github/jamalam360/jamlib/JamLib.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,8 @@
import static net.minecraft.server.command.CommandManager.literal;

import io.github.jamalam360.jamlib.log.JamLibLogger;
import io.github.jamalam360.jamlib.tick.TickScheduling;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.text.Text;
import org.jetbrains.annotations.ApiStatus.Internal;
Expand All @@ -43,8 +41,6 @@ public class JamLib implements ModInitializer {

@Override
public void onInitialize() {
ServerTickEvents.END_WORLD_TICK.register(TickScheduling::onEndTickServer);

//noinspection CodeBlock2Expr
CommandRegistrationCallback.EVENT.register((dispatcher, registryAccess, env) -> {
dispatcher.register(
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/io/github/jamalam360/jamlib/JamLibClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
package io.github.jamalam360.jamlib;

import io.github.jamalam360.jamlib.keybind.JamLibKeybinds;
import io.github.jamalam360.jamlib.tick.TickScheduling;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import org.jetbrains.annotations.ApiStatus.Internal;
Expand All @@ -35,7 +34,6 @@ public class JamLibClient implements ClientModInitializer {

@Override
public void onInitializeClient() {
ClientTickEvents.END_WORLD_TICK.register(TickScheduling::onEndTickClient);
ClientTickEvents.END_CLIENT_TICK.register(JamLibKeybinds::onEndTick);
}
}
10 changes: 8 additions & 2 deletions src/main/java/io/github/jamalam360/jamlib/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public class Util {
/**
* @param value The nullable value.
* @param consumer The consumer to run if {@code value} is not null.
* @param <T> The return type.
*/
public static <T> void ifNotNull(@Nullable T value, Consumer<T> consumer) {
if (value != null) {
Expand All @@ -48,6 +49,7 @@ public static <T> void ifNotNull(@Nullable T value, Consumer<T> consumer) {
* @param value The nullable value.
* @param consumer The consumer to run if {@code value} is not null.
* @param elseCallback The callback to run if {@code value} is null.
* @param <T> The return type.
*/
public static <T> void ifNotNull(@Nullable T value, Consumer<T> consumer, Runnable elseCallback) {
if (value != null) {
Expand All @@ -62,7 +64,9 @@ public static <T> void ifNotNull(@Nullable T value, Consumer<T> consumer, Runnab
* @param function The function to run to calculate the return value if {@code value} is not null.
* @param elseValue The value to return if {@code value} is null.
* @param <T> The value type.
* @param <R> The result type.
* @param <R> The return type.
*
* @return The value computed by the {@code function} if {@code value} is not null, or else the {@code elseValue}.
*/
public static <T, R> R ifNotNull(@Nullable T value, Function<T, R> function, R elseValue) {
if (value != null) {
Expand All @@ -77,7 +81,9 @@ public static <T, R> R ifNotNull(@Nullable T value, Function<T, R> function, R e
* @param function The function to run to calculate the return value if {@code value} is not null.
* @param elseFunction The function to run to calculate the return value if {@code value} is null.
* @param <T> The value type.
* @param <R> The result type.
* @param <R> The return type.
*
* @return The value computed by the {@code function} if {@code value} is not null, or else the value computed by the {@code elseFunction}.
*/
public static <T, R> R ifNotNull(@Nullable T value, Function<T, R> function, Supplier<R> elseFunction) {
if (value != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
* <p>Helper class to initialize 'compatibility modules' for a mod. A compatibility module is
* an entrypoint (that implements {@link ModInitializer}) that is only loaded when another specific mod is loaded.</p>
*
* <p>To define compatibility modules, create a {@code jamlib:compatibility_modules}</p> map
* <p>To define compatibility modules, create a {@code jamlib:compatibility_modules} map
* in your {@code fabric.mod.json}'s {@code custom} field (or the equivalent for the Quilt toolchain). The keys of this map should be mod ID's, and the values should be
* the fully qualified name of your compatibility module</p>
*
Expand All @@ -56,7 +56,7 @@ public class JamLibCompatibilityModuleHandler {
/**
* Search for, and initialize if required, all compatibility modules under the specified {@code modId}.
*
* @param modId <bold>Your mod's</bold> ID. Used to lookup the {@code jamlib:compatibility_modules}
* @param modId <b>Your mod's</b> ID. Used to lookup the {@code jamlib:compatibility_modules}
* map from the {@code fabric.mod.json} or {@code quilt.mod.json}.
*/
public static void initialize(String modId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
import net.minecraft.util.Formatting;

/**
* <p>MidnightConfig v2.1.0 by TeamMidnightDust & Motschen (adapted from Minenash/TinyConfig),
* <p>MidnightConfig v2.1.0 by TeamMidnightDust and Motschen (adapted from Minenash/TinyConfig),
* adapted by Jamalam for use in JamLib</p>
*
* <p>Used to register config classes that are reflectively updated. Provides a ModMenu-based GUI.</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,16 @@

/**
* <p>This event is called on the client-side when the user scrolls their
* mouse wheel, <bold>if</bold> they <bold>don't</bold> have a screen open.</p>
* mouse wheel, <b>if</b> they <b>don't</b> have a screen open.</p>
*
* <p>Use custom packets if this event is required on the server-side.</p>
*/
@Environment(EnvType.CLIENT)
public interface MouseScrollCallback {

/**
* The {@link Event}.
*/
Event<MouseScrollCallback> EVENT = EventFactory.createArrayBacked(MouseScrollCallback.class, (listeners) -> (mouseX, mouseY, amount) -> {
boolean consumed = false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
*/
public class JamLibClientNetworking {

/**
* An {@link Map} that maps mod ID's to a list of registered channels under that mod ID.
*/
protected static final Map<String, List<JamLibNetworkChannel<?>>> CLIENT_CHANNELS = new HashMap<>();

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,16 @@ public JamLibNetworkChannel(Identifier identifier) {
this.identifier = identifier;
}

/**
* @return The identifier of this channel.
*/
protected Identifier getIdentifier() {
return identifier;
}

/**
* @return The handler that responds to packets on this channel.
*/
protected T getHandler() {
return handler;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ public JamLibS2CNetworkChannel(Identifier identifier) {

/**
* Shorthand method for sending an empty packet to the client.
*
* @param player The player of the client the packet is to be sent to.
*/
public void send(ServerPlayerEntity player) {
PacketByteBuf buf = PacketByteBufs.empty();
Expand All @@ -59,6 +61,7 @@ public void send(ServerPlayerEntity player) {
/**
* Send a packet to the client.
*
* @param player The player of the client the packet is to be sent to.
* @param dataWriter A consumer of a {@link PacketByteBuf} which is used to write the data.
*/
public void send(ServerPlayerEntity player, Consumer<PacketByteBuf> dataWriter) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
*/
public class JamLibServerNetworking {

/**
* An {@link Map} that maps mod ID's to a list of registered channels under that mod ID.
*/
protected static final Map<String, List<JamLibNetworkChannel<?>>> SERVER_CHANNELS = new HashMap<>();

/**
Expand Down
101 changes: 0 additions & 101 deletions src/main/java/io/github/jamalam360/jamlib/tick/TickScheduling.java

This file was deleted.

0 comments on commit 07976fc

Please sign in to comment.