Skip to content

Commit

Permalink
Merge pull request #23 from JuliGames/development
Browse files Browse the repository at this point in the history
- new identifications
- better support for cloud systems
- the core plugins are now disabled by default (can be enabled with -DcorePlugins=true)
- ApiCore was renamed to ApiProvider (should not affect any third party, because this class is internal, but still exposed to the API)
- add "doWithData" method to all configurations (currently experimental to allow "putIfAbsent" calls)
- add Converter between bukkits YMLConfigurations and cores Configurations
- add inbuilt CommandSystem (experimental)
- better annotations in the API Module
- the "CustomTopicManager" was removed as announced
- experimental integration of the PaperCore to bstats
- planes for the "playerLocaleReference" to be removed
- a lot of bug fixes
- support for legacy message format with `AdventureAPI 1.4`
  • Loading branch information
TureBentzin authored Feb 28, 2023
2 parents d96743a + 8d85ccf commit dec9378
Show file tree
Hide file tree
Showing 112 changed files with 2,621 additions and 821 deletions.
10 changes: 0 additions & 10 deletions .mvn/old-maven.config

This file was deleted.

1 change: 1 addition & 0 deletions API/dependency-reduced-pom.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--suppress HttpUrlsUsage -->
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
Expand Down
3 changes: 2 additions & 1 deletion API/pom.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--suppress VulnerableLibrariesLocal -->
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>JuliGamesCore</artifactId>
<groupId>net.juligames.core</groupId>
<version>1.3</version>
<version>1.4</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
42 changes: 21 additions & 21 deletions API/src/main/java/net/juligames/core/api/API.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ public interface API {
* This is the primary way for getting your API Instance. With this Instance you have access to all build in features in the core
* that are explicitly exposed to the API. If the API should not be provided by a core then this will throw a {@link APIException}
* to indicate that a Core is necessary to get this Instance. For further Information on how to use the {@link API} please check out
* the GitHub Wiki. For further information on this method check out {@link ApiCore}
* the GitHub Wiki. For further information on this method check out {@link ApiProvider}
*
* @return your API Instance
* @throws APIException if no API is present
*/
static @NotNull API get() throws APIException {
@MaybePresent Optional<API> api = ApiCore.optionalApi();
@MaybePresent Optional<API> api = ApiProvider.optionalApi();
if (api.isEmpty()) {
throw new APIException();
}
Expand All @@ -54,80 +54,80 @@ public interface API {
* @return an NonNull Optional that contains the first result for your query. The Optional might be empty
*/
@MaybePresent
@NotNull Optional<? extends MessageRecipient> findRecipient(Predicate<MessageRecipient> searchQuery);
@NotNull Optional<? extends MessageRecipient> findRecipient(@NotNull Predicate<MessageRecipient> searchQuery);

@MaybePresent
@NotNull Optional<? extends MessageRecipient> findRecipientByName(String name);
@NotNull Optional<? extends MessageRecipient> findRecipientByName(@NotNull String name);

/**
* @return the {@link HazelDataApi}
*/
HazelDataApi getHazelDataApi();
@NotNull HazelDataApi getHazelDataApi();

/**
* @return The {@link NotificationApi} for this core
*/
NotificationApi getNotificationApi();
@NotNull NotificationApi getNotificationApi();

/**
* @return The {@link ClusterApi} for this core
*/
ClusterApi getClusterApi();
@NotNull ClusterApi getClusterApi();

/**
* @return de.bentzin.tools.logging.Logger for use when accessing via API
*/
Logger getAPILogger();
@NotNull Logger getAPILogger();

/**
* @return net.juligames.core.api.jdbi.SQLManager to get {@link org.jdbi.v3.core.Jdbi}
*/
SQLManager getSQLManager();
@NotNull SQLManager getSQLManager();

/**
* @return The {@link MessageApi} used to send Messages via core to players
*/
MessageApi getMessageApi();
@NotNull MessageApi getMessageApi();

/**
* @return the {@link ConfigurationAPI}
*/
ConfigurationAPI getConfigurationApi();
@NotNull ConfigurationAPI getConfigurationApi();

/**
* @return the {@link CommandApi}
*/
CommandApi getCommandApi();
@NotNull CommandApi getCommandApi();

/**
* @return a possible local running {@link BasicMiniGame}
*/
SubscribableType<BasicMiniGame> getLocalMiniGame();
@NotNull SubscribableType<BasicMiniGame> getLocalMiniGame();

/**
* @return CacheAPI for use with Caffeine
*/
CacheApi getCacheAPI();
@NotNull CacheApi getCacheAPI();

/**
* @return The Name this core is assigned to
*/
String getName();
@NotNull String getName();

String getVersion();
@NotNull String getVersion();

String getBuildVersion();
@NotNull String getBuildVersion();

Map<String, String> getJavaEnvironment();
@NotNull Map<String, String> getJavaEnvironment();

Runtime getJavaRuntime();
@NotNull Runtime getJavaRuntime();

@ApiStatus.Internal
void collectGarbage();

Supplier<Collection<? extends MessageRecipient>> getOnlineRecipientProvider();
@NotNull Supplier<Collection<? extends MessageRecipient>> getOnlineRecipientProvider();

Collection<? extends MessageRecipient> supplyOnlineRecipients();
@NotNull Collection<? extends MessageRecipient> supplyOnlineRecipients();

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

import de.bentzin.tools.misc.SubscribableType;
import org.checkerframework.checker.optional.qual.MaybePresent;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.Optional;
Expand All @@ -13,17 +15,20 @@
* 16.11.2022
* @apiNote This is for distribution of the API. If you want to get the API then please use {@link API#get()}
*/
public class ApiCore {
@ApiStatus.Internal
public class ApiProvider {

public static API CURRENT_API;
private static CompletableFuture<API> completableFuture = new CompletableFuture<>();
private static final @NotNull SubscribableType<API> subscribableType = new SubscribableType<>();
public static @Nullable API CURRENT_API;
private static @NotNull CompletableFuture<API> completableFuture = new CompletableFuture<>();

@ApiStatus.Internal
public static void insert(API api) {
public static void insert(@Nullable API api) {
//1. set CURRENT_API
CURRENT_API = api;
//2. complete Future
completableFuture.complete(api);
updateType();
}

@ApiStatus.Internal
Expand All @@ -32,6 +37,11 @@ public static void drop() {
CURRENT_API = null;
//2. uncompleted completableFuture...
completableFuture = new CompletableFuture<>();
updateType();
}

protected static void updateType() {
subscribableType.set(CURRENT_API);
}

@Nullable
Expand All @@ -40,11 +50,17 @@ public static API getAPI() {
}

@MaybePresent
public static Optional<API> optionalApi() {
public static @NotNull Optional<API> optionalApi() {
return Optional.ofNullable(CURRENT_API);
}

public static Future<API> futureApi() {
public static @NotNull Future<API> futureApi() {
return completableFuture;
}

@ApiStatus.Experimental
@ApiStatus.Internal
protected @NotNull SubscribableType<API> typeApi() {
return subscribableType;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,13 @@ public interface ClusterApi {
*/
Optional<String> getLocalName();

/**
* This will return an {@link Optional} containing the identification of the local Hazelcast Instance if present. Otherwise,
* the Optional will be empty. An Identification could be "Lobby-1" or "MissileWars-2-1"
*/
@ApiStatus.AvailableSince("1.4-SNAPSHOT")
Optional<String> getLocalIdentification();

Map<UUID, InstanceType> getAllUUIDS();

enum InstanceType {CLIENT, MEMBER}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,10 @@
*/
@SuppressWarnings("unused")
@Deprecated
public class CollectionInterpreter<T> implements IterableInterpreter<T, Collection<T>> {

private final Interpreter<T> tInterpreter;

public CollectionInterpreter(Interpreter<T> tInterpreter) {
this.tInterpreter = tInterpreter;
}
public record CollectionInterpreter<T>(Interpreter<T> tInterpreter) implements IterableInterpreter<T, Collection<T>> {

@Override
public Collection<T> interpret(final @NotNull String input) throws Exception {
public @NotNull Collection<T> interpret(final @NotNull String input) throws Exception {
if (!input.startsWith("{") || !input.endsWith("}")) {
throw new IllegalArgumentException("Input has to start with { and end with }");
}
Expand Down Expand Up @@ -75,7 +69,7 @@ private void checkLength(@NotNull String input) {


@Override
public String reverse(@NotNull Collection<T> ts) {
public @NotNull String reverse(@NotNull Collection<T> ts) {
StringBuilder builder = new StringBuilder();

for (T value : ts) {
Expand All @@ -91,8 +85,4 @@ public String reverse(@NotNull Collection<T> ts) {
appender.append("[").append(tInterpreter.reverse(object)).append("]");
return appender;
}

public Interpreter<T> tInterpreter() {
return tInterpreter;
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package net.juligames.core.api.config;

import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;

/**
* @author Ture Bentzin
Expand All @@ -14,5 +15,5 @@ public interface ConfigWriter {
* @param configuration the configuration
* @param keyspace the keyspace to write data to
*/
void write(Configuration configuration, String keyspace);
void write(@NotNull Configuration configuration, @NotNull String keyspace);
}
Loading

0 comments on commit dec9378

Please sign in to comment.