Skip to content

Commit

Permalink
final face lift of 1.6
Browse files Browse the repository at this point in the history
  • Loading branch information
TureBentzin committed Jun 18, 2023
1 parent 6407a47 commit 140993d
Show file tree
Hide file tree
Showing 41 changed files with 267 additions and 251 deletions.
32 changes: 17 additions & 15 deletions .run/CoreMaster.run.xml
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="CoreMaster" type="Application" factoryName="Application" nameIsGenerated="true">
<option name="MAIN_CLASS_NAME" value="net.juligames.core.master.CoreMaster" />
<module name="Master" />
<option name="PROGRAM_PARAMETERS" value="--add-modules java.se --add-exports java.base/jdk.internal.ref=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/sun.nio.ch=ALL-UNNAMED --add-opens java.management/sun.management=ALL-UNNAMED --add-opens jdk.management/com.sun.management.internal=ALL-UNNAMED" />
<option name="VM_PARAMETERS" value="-Dhazelcast.diagnostics.enabled=true -DcoreDebug=true " />
<extension name="coverage">
<pattern>
<option name="PATTERN" value="net.juligames.core.master.*" />
<option name="ENABLED" value="true" />
</pattern>
</extension>
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
<configuration default="false" name="CoreMaster" type="Application" factoryName="Application"
nameIsGenerated="true">
<option name="MAIN_CLASS_NAME" value="net.juligames.core.master.CoreMaster"/>
<module name="Master"/>
<option name="PROGRAM_PARAMETERS"
value="--add-modules java.se --add-exports java.base/jdk.internal.ref=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/sun.nio.ch=ALL-UNNAMED --add-opens java.management/sun.management=ALL-UNNAMED --add-opens jdk.management/com.sun.management.internal=ALL-UNNAMED"/>
<option name="VM_PARAMETERS" value="-Dhazelcast.diagnostics.enabled=true -DcoreDebug=true "/>
<extension name="coverage">
<pattern>
<option name="PATTERN" value="net.juligames.core.master.*"/>
<option name="ENABLED" value="true"/>
</pattern>
</extension>
<method v="2">
<option name="Make" enabled="true"/>
</method>
</configuration>
</component>
1 change: 1 addition & 0 deletions API/src/main/java/net/juligames/core/api/API.java
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ public interface API extends Logging {

/**
* When using a {@link LogManager} you should use {@link API#getJavaLogManager()} to get hold of it
*
* @return an {@link LogManager} instance that is or acts like {@link LogManager#getLogManager()}
* @apiNote This is not associated with the {@link de.bentzin.tools.logging} package and environment
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
* }
* }
* </pre>
*
* @author Ture Bentzin
* 15.03.2023
*/
@ApiStatus.AvailableSince("1.5")
@ApiStatus.Experimental
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* This is an example implementation for interpreting Integers
* <pre>
* {@code
*
* public final class IntegerInterpreter implements Interpreter<Integer> {
*
* @Override
Expand Down Expand Up @@ -93,7 +93,7 @@ default <R> void reverseAndThenComplete(@NotNull T t, @NotNull CompletableFuture
* CompletableFuture with the result of the interpretation. This process is known as "interpreting the input as an
* instance of Type T". If the interpretation fails, an Exception will be thrown.
*
* @param input the input to be interpreted
* @param input the input to be interpreted
* @param completableFuture the CompletableFuture that should be completed with the result of the interpretation
* @throws Exception will be thrown if the input cant be interpreted according to this implementation
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,18 @@

/**
* This might be used later outside of this package
*
* @author Ture Bentzin
* 12.04.2023
*/
@ApiStatus.Internal
@ApiStatus.AvailableSince("1.6")
public sealed interface PrimitiveInterpreter<T> permits Interpreter{
public sealed interface PrimitiveInterpreter<T> permits Interpreter {

/**
* Converts the given input according to this implementation to a given Object of the provided Type.
* This process is known as "interpreting the input as an instance of Type T"
*
* @param input the input to be interpreted
* @return the instance of T that results the interpretation
* @throws Exception will be thrown if the input cant be interpreted according to this implementation
Expand Down
13 changes: 9 additions & 4 deletions API/src/main/java/net/juligames/core/api/config/Reverser.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ public sealed interface Reverser<T> permits Interpreter, Reverser.PrivateReverse

/**
* The function#apply should never return null
*
* @param function the function
* @param <T> Type
* @return a reverser based on the function
* @param <T> Type
*/
@Contract(pure = true)
static <T> @NotNull Reverser<T> ofFunctional(@NotNull Function<T, String> function) {
Expand All @@ -30,9 +31,10 @@ public sealed interface Reverser<T> permits Interpreter, Reverser.PrivateReverse
/**
* This will return a new {@link Reverser} that will execute the {@link #reverse(Object)} method from the given
* tReverser. This only benefits of you want to prevent casting this {@link Reverser} to a {@link Interpreter}!
*
* @param tReverser the reverser
* @param <T> T
* @return a new reverser
* @param <T> T
*/
@ApiStatus.Experimental
@Contract(pure = true)
Expand All @@ -44,8 +46,9 @@ public sealed interface Reverser<T> permits Interpreter, Reverser.PrivateReverse
* This {@link Reverser} will reverse the given object ONLY based on its toString!
* Should only be used with EXTREME caution!
* This does not respect {@link CustomInterpretable}
* @return a new reverser
*
* @param <T> T
* @return a new reverser
*/
@ApiStatus.Experimental
@Contract(pure = true)
Expand All @@ -57,8 +60,9 @@ public sealed interface Reverser<T> permits Interpreter, Reverser.PrivateReverse
* This {@link Reverser} will reverse the given object ONLY based on its {@link String#valueOf(Object)}!
* Should only be used with EXTREME caution!
* This does not respect {@link CustomInterpretable}
* @return a new reverser
*
* @param <T> T
* @return a new reverser
*/
@ApiStatus.Experimental
@Contract(pure = true)
Expand All @@ -81,6 +85,7 @@ public sealed interface Reverser<T> permits Interpreter, Reverser.PrivateReverse

/**
* Meant ONLY for use with {@link #ofFunctional(Function)}
*
* @param <T> the type
*/
@ApiStatus.Internal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public DictionaryFeedInterpreter(@NotNull Supplier<Dictionary<String, E>> dictio
/**
* Constructs a new {@link DictionaryFeedInterpreter} instance with the given dictionary supplier and map part factory.
*
* @param dictionarySupplier the supplier to use to provide the backing dictionary
* @param dictionarySupplier the supplier to use to provide the backing dictionary
* @param dictionaryPartFactory the function to use to create map parts based on the dictionary and the key
*/
public DictionaryFeedInterpreter(@NotNull Supplier<Dictionary<String, E>> dictionarySupplier,
Expand Down Expand Up @@ -64,7 +64,7 @@ public DictionaryFeedInterpreter(@NotNull Supplier<Dictionary<String, E>> dictio
/**
* Creates a new map part with the given key and dictionary supplier using the factory function.
*
* @param key the key of the new map part
* @param key the key of the new map part
* @param dictionarySupplier the dictionary supplier to use for the new map part
* @return the newly created map part
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ public MapFeedInterpreter(@NotNull Supplier<Map<String, E>> mapSupplier,
}

public @NotNull MapPart<E> fabricate(@NotNull String key, @NotNull Supplier<Map<String, E>> mapSupplier) {
return mapPartFactory.apply(key,mapSupplier);
return mapPartFactory.apply(key, mapSupplier);
}

protected @NotNull MapPart<E> fabricate(@NotNull String key) {
return mapPartFactory.apply(key,mapSupplier);
return mapPartFactory.apply(key, mapSupplier);
}

private record MapPartImpl<E>(String key, Supplier<Map<String, E>> mapSupplier) implements MapPart<E> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* be used as the "key" for getting the property. If you {@link #reverse(Object)} then {@link String#valueOf(Object)}
* will be used
* <p>
* This is an example on how to use the {@link PropertyInterpreter} specifically the {@link PropertyInterpreter#stringPropertyInterpreter()}
* This is an example on how to use the {@link PropertyInterpreter} specifically the {@link PropertyInterpreter#stringPropertyInterpreter()}
* </p>
* <pre>
* {@code
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
* 17.04.2023
*/
@ApiStatus.AvailableSince("1.6")
public abstract class Interpretation<T> implements Representation<T>{
public abstract class Interpretation<T> implements Representation<T> {

public final @NotNull PrimitiveInterpreter<T> interpreter;

public Interpretation(@NotNull PrimitiveInterpreter<T> interpreter) {
this.interpreter = interpreter;
}

public final @NotNull PrimitiveInterpreter<T> interpreter;

@Override
public final @NotNull T represent() {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ public final class AdventureWebuiEditorAPI {
public AdventureWebuiEditorAPI(final @NotNull URI root) {
this(root, HttpClient.newHttpClient());
}

/**
* Creates a new instance of the editor API with the default JuliGames api
*/
Expand Down Expand Up @@ -200,7 +201,7 @@ public AdventureWebuiEditorAPI(final @NotNull HttpClient client) {

/**
* @param command command with {token}
* @param app app
* @param app app
* @return the link
*/
@Contract(pure = true)
Expand All @@ -215,7 +216,7 @@ public AdventureWebuiEditorAPI(final @NotNull HttpClient client) {
/**
* @param message the initial message
* @param command command with {token}
* @param app app
* @param app app
* @return the link
*/
@Contract(pure = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public interface MessageRecipient {
* specified.
*
* @return the default locale that is distributed by the master, or the locale of this MessageRecipient if
* specified
* specified
*/
default @Nullable String supplyLocaleOrDefault() {
if (supplyLocale() != null) {
Expand All @@ -49,11 +49,10 @@ public interface MessageRecipient {
}

/**
* @param miniMessage the miniMessage string to deliver
* @deprecated Use {@link #deliver(Message)} instead.
*
* <p>Delivers a miniMessage string to the recipient.</p>
*
* @param miniMessage the miniMessage string to deliver
*/
@Deprecated
@ApiStatus.Internal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
/**
* This interface provides methods for serializing a MiniMessage to plain text or legacy format.
* It also provides methods for translating legacy format messages to MiniMessage format.
*
* @author Ture Bentzin
* 25.12.2022
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public enum PatternType {
* Converts a pattern string to a tag string.
*
* @param target the target string to convert
* @param index the integer index to use in the tag
* @param index the integer index to use in the tag
* @return the converted tag string
*/
public @NotNull String convertPatternToTag(@NotNull String target, int index) {
Expand Down
3 changes: 2 additions & 1 deletion API/src/main/java/net/juligames/core/api/misc/APIUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,8 @@ public static <R> Optional<R> executeAndReturnFirstSuccess(Supplier<R> @NotNull
for (Supplier<R> supplier : suppliers) {
try {
return Optional.of(supplier.get());
}catch (Exception ignore) {}
} catch (Exception ignore) {
}
}
return Optional.empty();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,26 @@ public class DurationFormatUtils {
static final @NotNull Object S = "S";
public static @NotNull String INTERNAL_MESSAGE_PREFIX = "internal.api.misc.format.";

static {
API.get().getAPILogger().info(DurationFormatUtils.class.getName() + " was loaded! Trying to register default messages:");
long s1 = System.currentTimeMillis();
try {
registerMessages();
//BIT
final long between = s1 - System.currentTimeMillis();
Duration duration = Duration.ofMillis(between);
String formatDurationWords = formatDurationWords(duration, false, false, null,
API.get().getMessageApi().defaultUtilLocale());
API.get().getAPILogger().info("finished registration of default messages! (took: " + formatDurationWords + ")");
} catch (Exception e) {
API.get().getAPILogger().warning("failed to register default messages: " + e);
ThrowableDebug.debug(e);
}

}

//-----------------------------------------------------------------------

/**
* <p>DurationFormatUtils instances should NOT be constructed in standard programming.</p>
*
Expand All @@ -87,8 +107,6 @@ public DurationFormatUtils() {
super();
}

//-----------------------------------------------------------------------

/**
* <p>Formats the time gap as a string.</p>
*
Expand Down Expand Up @@ -244,24 +262,6 @@ public DurationFormatUtils() {
suppressTrailingZeroElements, getLocalisationFromMessageSystem(locale, s));
}

static {
API.get().getAPILogger().info(DurationFormatUtils.class.getName() + " was loaded! Trying to register default messages:");
long s1 = System.currentTimeMillis();
try {
registerMessages();
//BIT
final long between = s1 - System.currentTimeMillis();
Duration duration = Duration.ofMillis(between);
String formatDurationWords = formatDurationWords(duration, false, false, null,
API.get().getMessageApi().defaultUtilLocale());
API.get().getAPILogger().info("finished registration of default messages! (took: " + formatDurationWords + ")");
}catch (Exception e){
API.get().getAPILogger().warning("failed to register default messages: " + e);
ThrowableDebug.debug(e);
}

}

public static void registerMessages() {
registerDefaultMessage("days");
registerDefaultMessage("hours");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,11 @@ private EntryInterpretationUtil() {
}).collect(Collectors.toUnmodifiableSet());
}

public static <K,V> @Unmodifiable @NotNull Map<K,V> interpretMap(@NotNull Map<String,String> map, @NotNull Interpreter<K> kInterpreter, @NotNull Interpreter<V> vInterpreter) {
public static <K, V> @Unmodifiable @NotNull Map<K, V> interpretMap(@NotNull Map<String, String> map, @NotNull Interpreter<K> kInterpreter, @NotNull Interpreter<V> vInterpreter) {
return Map.ofEntries(interpretEntries(map.entrySet(), kInterpreter, vInterpreter).toArray((IntFunction<Map.Entry<K, V>[]>) value -> new Map.Entry[0]));
}

public static <K,V> @Unmodifiable @NotNull Map<String, String> reverseMap(@NotNull Map<K, V> map, @NotNull Interpreter<K> kInterpreter, @NotNull Interpreter<V> vInterpreter) {
public static <K, V> @Unmodifiable @NotNull Map<String, String> reverseMap(@NotNull Map<K, V> map, @NotNull Interpreter<K> kInterpreter, @NotNull Interpreter<V> vInterpreter) {
return Map.ofEntries(reverseEntries(map.entrySet(), kInterpreter, vInterpreter).toArray((IntFunction<Map.Entry<String, String>[]>) value -> new Map.Entry[0]));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@

/**
* This class provides predicates
* @implNote might use {@link APIUtils#executedWithoutExceptionL(Runnable)} later
*
* @author Ture Bentzin
* 19.05.2023
* @implNote might use {@link APIUtils#executedWithoutExceptionL(Runnable)} later
*/
public class Predicates {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package net.juligames.core.api.misc;

import net.juligames.core.api.API;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;

import java.io.PrintWriter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

/**
* Like a normal {@link Runnable} but it accepts Exceptions
*
* @author Ture Bentzin
* 10.04.2023
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public interface AdventureTagManager extends MiniMessageSerializer {

/**
* This method creates a new {@link TagResolver} that combines {@link #getResolver()} and append
*
* @param append additional resolvers
* @return a new {@link TagResolver}
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import net.juligames.core.api.message.MessageRecipient;
import net.kyori.adventure.audience.Audience;
import net.kyori.adventure.identity.Identity;
import net.kyori.adventure.pointer.Pointered;
import net.kyori.adventure.text.Component;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
Expand Down
Loading

0 comments on commit 140993d

Please sign in to comment.