Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version 1.5 #28

Merged
merged 69 commits into from
Mar 23, 2023
Merged
Show file tree
Hide file tree
Changes from 44 commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
7896084
bump 1.5-SNAPSHOT
TureBentzin Feb 28, 2023
940674a
Delete identifier.sqlite
TureBentzin Feb 28, 2023
4852430
Update FallBackMessage.java
TureBentzin Mar 3, 2023
7e2c7c0
Delete ApiIntegrityTest.java
TureBentzin Mar 3, 2023
d9d58a5
remove debugs
TureBentzin Mar 3, 2023
ad4d14b
add setIfAbsent
TureBentzin Mar 3, 2023
07d1e3a
Update Configuration.java
TureBentzin Mar 3, 2023
6c01f9a
fix naming
TureBentzin Mar 3, 2023
09482d7
Create ObjectHashtableToStringHashtableMapper.java
TureBentzin Mar 3, 2023
8a45e7e
add OfflineConfiguration to API
TureBentzin Mar 3, 2023
f1f9424
Update CoreCacheApi.java
TureBentzin Mar 3, 2023
1413ec8
deprecate doWithData
TureBentzin Mar 3, 2023
1e17791
add core check to API.get()
TureBentzin Mar 3, 2023
8af9f4e
add autostart to minigames
TureBentzin Mar 4, 2023
e5e1eb9
fix #27
TureBentzin Mar 4, 2023
f4615d4
fix StackWalker bug
TureBentzin Mar 4, 2023
4fc161f
fixed isses with the APIProvider
TureBentzin Mar 5, 2023
5a7b8cd
add errorprone
TureBentzin Mar 5, 2023
e16f498
add PreDefinedInsertionProcedure
TureBentzin Mar 6, 2023
5c80025
start fixing the SwitchingInsertionProcedure
TureBentzin Mar 6, 2023
f9e1b68
add javadoc
TureBentzin Mar 6, 2023
c68b65b
add createSectionClone and new Interpreters
TureBentzin Mar 6, 2023
c564eae
add Environment and Property Interpreter
TureBentzin Mar 7, 2023
776bf38
upgrade environment interpreter
TureBentzin Mar 7, 2023
d05c4d1
move dir
TureBentzin Mar 7, 2023
7ccf4db
Create HazelFeedMapInterpreter.java
TureBentzin Mar 7, 2023
f740ff2
add customPropertyInterpreter
TureBentzin Mar 7, 2023
6571958
Break "load" method of MiniGames
TureBentzin Mar 9, 2023
ed9c003
Create GenericHashtableToStringHashtableMapper.java
TureBentzin Mar 11, 2023
e1db6f9
reformat code and javadoc
TureBentzin Mar 11, 2023
e79bed1
Create DictionaryFeedInterpreter.java
TureBentzin Mar 11, 2023
1f2f814
remove PlayerLocaleReference
TureBentzin Mar 11, 2023
542de76
fix some bugs
TureBentzin Mar 11, 2023
212f6ee
add debugNotifications flag for automatic notification printing
TureBentzin Mar 11, 2023
112e07e
Update CoreNotificationApi.java
TureBentzin Mar 11, 2023
a22e856
bump 1.5
TureBentzin Mar 14, 2023
a88edb0
Merge branch 'main' into development
TureBentzin Mar 14, 2023
e29ddd7
bump Core and Adventure to 1.5
TureBentzin Mar 14, 2023
c30223e
boolean exists(String name);
TureBentzin Mar 15, 2023
f401644
Merge branch 'development' of https://github.com/JuliGames/JuliGamesC…
TureBentzin Mar 15, 2023
8a520da
Update LegacyToAnsiConverter.java
TureBentzin Mar 15, 2023
9d4cd58
bump DevTools
TureBentzin Mar 15, 2023
34efad4
add some interpretation
TureBentzin Mar 15, 2023
1aee57c
some bugfixes
TureBentzin Mar 15, 2023
30b7f72
add DurationFormat
TureBentzin Mar 15, 2023
c56135d
Update DurationFormatUtils.java
TureBentzin Mar 15, 2023
a21c937
Update API/src/main/java/net/juligames/core/api/minigame/BasicMiniGam…
TureBentzin Mar 18, 2023
6054931
Update Core/src/main/java/net/juligames/core/config/CoreConfiguration…
TureBentzin Mar 18, 2023
8cb34c9
Update MiniGameAPI/src/main/java/net/juligames/core/minigame/api/Mini…
TureBentzin Mar 18, 2023
0fa586e
Update API/src/main/java/net/juligames/core/api/config/BuildInInterpr…
TureBentzin Mar 18, 2023
caf4d1c
Update API/src/main/java/net/juligames/core/api/config/ConfigurationA…
TureBentzin Mar 18, 2023
ccb7980
Update API/src/main/java/net/juligames/core/api/config/mapbacked/Dict…
TureBentzin Mar 18, 2023
d2d32d3
fix #30
TureBentzin Mar 22, 2023
4f375be
fixed compiler issue
TureBentzin Mar 22, 2023
acb4f0b
fixed second compiler issue
TureBentzin Mar 22, 2023
c13c820
Update SwitchingInsertionProcedure.java
TureBentzin Mar 22, 2023
1a9993c
Merge branch 'development' of https://github.com/JuliGames/JuliGamesC…
TureBentzin Mar 22, 2023
dbdaa04
some reformat
TureBentzin Mar 22, 2023
fcee9d8
removed cachingConfiguration
TureBentzin Mar 22, 2023
b33ae1d
Add EntryInterpretation
TureBentzin Mar 22, 2023
85474c9
fix exception handeling with entry interpretation
TureBentzin Mar 22, 2023
8dfef5f
Update DurationFormatUtils.java
TureBentzin Mar 22, 2023
ccfc2be
integrate the Factories more
TureBentzin Mar 22, 2023
634ef92
Update EnvironmentVariable.java
TureBentzin Mar 22, 2023
60c01e9
Delete Transaction.java
TureBentzin Mar 22, 2023
2e6aa0b
removed Experimental Status
TureBentzin Mar 22, 2023
18a32ee
Merge pull request #32 from JuliGames/duration-format
TureBentzin Mar 22, 2023
10af82a
fixed some bugs
TureBentzin Mar 23, 2023
8e2a353
Merge branch 'development' of https://github.com/JuliGames/JuliGamesC…
TureBentzin Mar 23, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions API/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<artifactId>JuliGamesCore</artifactId>
<groupId>net.juligames.core</groupId>
<version>1.4</version>
<version>1.5</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down Expand Up @@ -58,7 +58,7 @@
<dependency>
<groupId>de.bentzin.tools</groupId>
<artifactId>DevTools</artifactId>
<version>2.2</version>
<version>2.3</version>
<scope>compile</scope>
</dependency>

Expand Down
19 changes: 19 additions & 0 deletions API/src/main/java/net/juligames/core/api/API.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,30 @@ public interface API {
* @return your API Instance
* @throws APIException if no API is present
*/
@SuppressWarnings("SpellCheckingInspection")
static @NotNull API get() throws APIException {
@MaybePresent Optional<API> api = ApiProvider.optionalApi();
if (api.isEmpty()) {
throw new APIException();
}
if (!Boolean.getBoolean("acknowledgeMissingCoreClass")) {
//this block provides security over the used implementation of the API class!
try {
Class.forName("net.juligames.core.Core"); //check that the core is installed
} catch (ClassNotFoundException e) {
try {
api.ifPresent(api1 -> {
api1.getAPILogger().error("Error while providing this instance: " + e.getMessage() + "!");
api1.getAPILogger().error("It seems like you are operating an unsupported implementation of the Core! \n" +
"You can acknowledge this dangerous behavior by setting the \"-DacknowledgeMissingCoreClass=true\"!");
});
} catch (Exception ignored) {
//ok its fucked
throw new APIException(e);
}
throw new APIException(e);
}
}
return api.get();
}

Expand Down
1 change: 1 addition & 0 deletions API/src/main/java/net/juligames/core/api/TODO.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* @apiNote Methods annotated with this might throw a {@link net.juligames.core.api.err.dev.TODOException}
* @suppression may suppress convert to record and unused
*/
@SuppressWarnings("JavadocDeclaration")
public @interface TODO {
boolean doNotcall();
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
package net.juligames.core.api.config;

import net.juligames.core.api.API;
import net.juligames.core.api.jdbi.DBData;
import net.juligames.core.api.jdbi.DataDAO;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;

import java.io.File;
import java.net.URI;
import java.net.URL;
import java.text.DateFormat;
import java.time.DateTimeException;
import java.time.Duration;
import java.time.Instant;
import java.time.temporal.TemporalUnit;
import java.util.Date;
import java.util.NoSuchElementException;
import java.util.Objects;
import java.util.UUID;

/**
Expand Down Expand Up @@ -51,5 +60,75 @@ public interface BuildInInterpreters {
return s -> s;
}

@Contract(pure = true)
TureBentzin marked this conversation as resolved.
Show resolved Hide resolved
static @NotNull Interpreter<Class<?>> clazzInterpreter() {
return new Interpreter<>() {
@Override
public @NotNull Class<?> interpret(@NotNull String input) throws Exception {
return Class.forName(input);
}

@Override
public @NotNull String reverse(@NotNull Class<?> tClass) {
return tClass.getName();
}
};
}




@ApiStatus.AvailableSince("1.5")
@Contract(value = "_ -> new", pure = true)
static @NotNull Interpreter<Configuration> onlineConfigurationInterpreter(boolean createIfNotExists) {
return new Interpreter<>() {
@Override
public @NotNull Configuration interpret(@NotNull String input) throws Exception {
if (!createIfNotExists && !API.get().getConfigurationApi().exists(input)) {
throw new NoSuchElementException(input + " has no associated configuration!");
}
return API.get().getConfigurationApi().getOrCreate(input);
}

@Override
public @NotNull String reverse(@NotNull Configuration configuration) {
return configuration.getName();
}
};
}

@Contract(value = "_ -> new", pure = true)
@ApiStatus.AvailableSince("1.5")
static @NotNull Interpreter<Duration> durationInterpreter(TemporalUnit unit) {
return new Interpreter<>() {
@Override
public @NotNull Duration interpret(String input) throws DateTimeException, ArithmeticException, NumberFormatException {
return Duration.of(Long.parseLong(input), unit);
}

@Override
public @NotNull String reverse(Duration duration) {
return String.valueOf(duration.get(unit));
}
};
}

@Contract(value = " -> new", pure = true)
@ApiStatus.Experimental
@ApiStatus.AvailableSince("1.5")
static @NotNull Interpreter<DBData> dbDataInterpreter() {
return new Interpreter<>() {
@Override
public @NotNull DBData interpret(String input) throws Exception {
return Objects.requireNonNull(API.get().getSQLManager().withExtension(DataDAO.class, extension ->
extension.select(input)));
}

@Override
public @NotNull String reverse(DBData dbData) {
return dbData.getKey();
}
};
}

}
153 changes: 152 additions & 1 deletion API/src/main/java/net/juligames/core/api/config/Configuration.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package net.juligames.core.api.config;

import de.bentzin.tools.pair.BasicPair;
import de.bentzin.tools.pair.EntryPairAdapter;
import de.bentzin.tools.pair.Pair;
import net.juligames.core.api.misc.TriConsumer;
import org.checkerframework.checker.optional.qual.MaybePresent;
import org.jetbrains.annotations.ApiStatus;
Expand All @@ -11,6 +13,7 @@
import java.io.OutputStream;
import java.util.*;
import java.util.function.*;
import java.util.stream.Stream;

/**
* @author Ture Bentzin
Expand All @@ -20,7 +23,8 @@
* @see BuildInInterpreters
*/
@SuppressWarnings("unused")
public interface Configuration extends Comparable<Configuration> {
public interface Configuration extends Comparable<Configuration>, Iterable<Pair<String>> {


/**
* This keys can be requested but never should be overridden (it is possible to override them, but only consider doing this if you really
Expand Down Expand Up @@ -209,6 +213,73 @@ public interface Configuration extends Comparable<Configuration> {

void set(@NotNull BasicPair<String, String> basicPair);

//ifAbsent

@ApiStatus.AvailableSince("1.5")
void setStringIfAbsent(@NotNull String key, @NotNull String value);

@ApiStatus.AvailableSince("1.5")
void setStringIfAbsent(@NotNull String key, @NotNull Supplier<String> value);

@ApiStatus.AvailableSince("1.5")
void setIntegerIfAbsent(@NotNull String key, @NotNull Integer value);

@ApiStatus.AvailableSince("1.5")
void setIntegerIfAbsent(@NotNull String key, @NotNull Supplier<Integer> value);

@ApiStatus.AvailableSince("1.5")
void setDoubleIfAbsent(@NotNull String key, @NotNull Double value);

@ApiStatus.AvailableSince("1.5")
void setDoubleIfAbsent(@NotNull String key, @NotNull Supplier<Double> value);

@ApiStatus.AvailableSince("1.5")
void setLongIfAbsent(@NotNull String key, @NotNull Long value);

@ApiStatus.AvailableSince("1.5")
void setLongIfAbsent(@NotNull String key, @NotNull Supplier<Long> value);

@ApiStatus.AvailableSince("1.5")
void setShortIfAbsent(@NotNull String key, @NotNull Short value);

@ApiStatus.AvailableSince("1.5")
void setShortIfAbsent(@NotNull String key, @NotNull Supplier<Short> value);

@ApiStatus.AvailableSince("1.5")
void setByteIfAbsent(@NotNull String key, @NotNull Byte value);

@ApiStatus.AvailableSince("1.5")
void setByteIfAbsent(@NotNull String key, @NotNull Supplier<Byte> value);

@ApiStatus.AvailableSince("1.5")
void setBooleanIfAbsent(@NotNull String key, @NotNull Boolean value);

@ApiStatus.AvailableSince("1.5")
void setBooleanIfAbsent(@NotNull String key, @NotNull Supplier<Boolean> value);

@ApiStatus.AvailableSince("1.5")
void setFloatIfAbsent(@NotNull String key, @NotNull Float value);

@ApiStatus.AvailableSince("1.5")
void setFloatIfAbsent(@NotNull String key, @NotNull Supplier<Float> value);

@ApiStatus.AvailableSince("1.5")
<T> void setIfAbsent(@NotNull String key, @NotNull T value, @NotNull Interpreter<T> interpreter);

@ApiStatus.AvailableSince("1.5")
<T> void setIfAbsent(@NotNull String key, @NotNull Supplier<T> value, @NotNull Interpreter<T> interpreter);

@ApiStatus.AvailableSince("1.5")
<T> void setIfAbsent(@NotNull Supplier<String> key, @NotNull T value, @NotNull Interpreter<T> interpreter);

@ApiStatus.AvailableSince("1.5")
<T> void setIfAbsent(@NotNull Supplier<String> key, @NotNull Supplier<T> value, @NotNull Interpreter<T> interpreter);

@ApiStatus.AvailableSince("1.5")
void setIfAbsent(@NotNull BasicPair<String, String> basicPair);

//del

void del(@NotNull String key);

void del(@NotNull Supplier<String> keys);
Expand Down Expand Up @@ -261,12 +332,92 @@ public interface Configuration extends Comparable<Configuration> {
@ApiStatus.AvailableSince("1.4")
<R> R doWithData(@NotNull Function<Map<String, String>, R> function);

/**
* @deprecated this method can have serious effects on the integrity of the data managed by the configuration!
* Because of this thread the {@link #setStringIfAbsent(String, String)} methods where introduced. Removal of this method
* may be accomplished later. It is not unlikely that this method will be stripped of its manipulation capabilities and
* will serve only for query operations!
*/
@ApiStatus.Experimental
@ApiStatus.AvailableSince("1.4")
@Deprecated
void doWithData(@NotNull Consumer<Map<String, String>> action);

@Override
default int compareTo(@NotNull Configuration o) {
return o.size() - size();
}

@ApiStatus.AvailableSince("1.5")
@ApiStatus.Experimental
@NotNull
Stream<String> searchValue(@NotNull String value);

@ApiStatus.AvailableSince("1.5")
@NotNull String getName();

//from map

/**
* Performs the given action for each entry in this configuration until all entries
* have been processed or the action throws an exception. Unless
* otherwise specified by the implementing class, actions are performed in
* the order of entry set iteration (if an iteration order is specified.)
* Exceptions thrown by the action are relayed to the caller.
*
* @param action The action to be performed for each entry
* @throws NullPointerException if the specified action is null
* @throws ConcurrentModificationException if an entry is found to be
* removed during iteration
* @implSpec The default implementation is equivalent to, for this {@code configuration}:
* <pre> {@code
* for (Map.Entry<String, String> entry : configuration.entrySet())
Bommels05 marked this conversation as resolved.
Show resolved Hide resolved
* action.accept(entry.getKey(), entry.getValue());
* }</pre>
* <p>
* The default implementation makes no guarantees about synchronization
* or atomicity properties of this method. Any implementation providing
* atomicity guarantees must override this method and document its
* concurrency properties.
*/
@ApiStatus.AvailableSince("1.5")
default void forEach(BiConsumer<String, String> action) {
Objects.requireNonNull(action);
for (Map.Entry<String, String> entry : entrySet()) {
String k;
String v;
try {
k = entry.getKey();
v = entry.getValue();
} catch (IllegalStateException ise) {
// this usually means the entry is no longer in the map.
throw new ConcurrentModificationException(ise);
}
action.accept(k, v);
}
}


//Iterable

@NotNull
@Override
@ApiStatus.AvailableSince("1.5")
default Iterator<Pair<String>> iterator() {
return entrySet().stream().map(EntryPairAdapter::pairFromEntry).iterator();
}

@Override
@ApiStatus.AvailableSince("1.5")
default void forEach(Consumer<? super Pair<String>> action) {
forEach((s, s2) -> action.accept(new Pair<>(s, s2)));
}

@Override
@ApiStatus.AvailableSince("1.5")
default Spliterator<Pair<String>> spliterator() {
return entrySet().stream().map(EntryPairAdapter::pairFromEntry).spliterator();
}


}
Loading