Skip to content
This repository has been archived by the owner on Feb 18, 2021. It is now read-only.

[WIP] Fix everything #14

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
14 changes: 7 additions & 7 deletions OrionAPI/build.gradle
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
dependencies {
// Instrumetnation tools will be bundled
compile group: 'eu.mikroskeem', name: 'shuriken.instrumentation', version: shuriken_version

// Dependencies what are present on runtime
compile group: 'org.apache.logging.log4j', name: 'log4j-api', version: log4j2_version
compile group: 'org.ow2.asm', name: 'asm', version: asm_version

// Dependencies which will be downloaded
downloadDep group: 'javax.inject', name: 'javax.inject', version: '1'
downloadDep(group: 'eu.mikroskeem', name: 'legacylauncher', version: legacylauncher_version) {
compile group: 'javax.inject', name: 'javax.inject', version: '1'
compile(group: 'cpw.mods', name: 'modlauncher', version: modLauncherVersion) {
exclude module: '*'
}
downloadDep(group: 'ninja.leaping.configurate', name: 'configurate-hocon', version: hocon_version) {
compile(group: 'org.spongepowered', name: 'configurate-hocon', version: hocon_version) {
exclude module: 'guava'
}

// TODO: way to disable Mixin AP
downloadDep(group: 'org.spongepowered', name: 'mixin', version: mixin_version) {
compile(group: 'org.spongepowered', name: 'mixin', version: mixin_version) {
exclude module: 'commons-io'
exclude module: 'guava'
exclude module: 'launchwrapper'
exclude module: 'log4j-core'
exclude module: 'gson'
}

compile group: 'org.checkerframework', name: 'checker-qual', version: checker_qual_version

// Required to get Mixin AP working
compile group: 'com.google.code.gson', name: 'gson', version: gson_version
compile group: 'com.google.guava', name: 'guava', version: guava_version
Expand Down
80 changes: 0 additions & 80 deletions OrionAPI/src/main/java/eu/mikroskeem/orion/api/CBVersion.java

This file was deleted.

58 changes: 38 additions & 20 deletions OrionAPI/src/main/java/eu/mikroskeem/orion/api/Orion.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@
import eu.mikroskeem.orion.api.asset.AssetManager;
import eu.mikroskeem.orion.api.bytecode.OrionTransformer;
import eu.mikroskeem.orion.api.mod.ModInfo;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;

import java.net.URL;
import java.util.Collections;
import java.util.List;
import java.util.Set;

Expand All @@ -47,8 +47,12 @@ public interface Orion {
* Registers access transformer to be applied on server start.
*
* @param atUrl Resource {@link URL} of access transformer file (in other words {@link Class#getResource(String)})
* @deprecated Deprecated without replacement
*/
void registerAT(@NotNull URL atUrl);
@Deprecated
default void registerAT(@NonNull URL atUrl) {
throw new UnsupportedOperationException();
}

/**
* Registers mixin config.
Expand All @@ -57,46 +61,61 @@ public interface Orion {
*
* @param mixinConfigName Mixin configuration name in format: <pre>mixins.MOD_ID.WHATEVER.json</pre>
*/
void registerMixinConfig(@NotNull String mixinConfigName);
void registerMixinConfig(@NonNull String mixinConfigName);

/**
* Gets list of registered Maven repositories
*
* @return {@link List} of Maven repository {@link URL}s
* @deprecated Deprecated without replacement
*/
@NotNull
List<URL> getRegisteredMavenRepositories();
@NonNull
@Deprecated
default List<URL> getRegisteredMavenRepositories() {
return Collections.emptyList();
}

/**
* Registers Maven repository where libraries can be downloaded
*
* @param url Maven repository url
* @see Orion#registerLibrary(String)
* @deprecated Deprecated without replacement
*/
void registerMavenRepository(@NotNull URL url);
@Deprecated
default void registerMavenRepository(@NonNull URL url) {
throw new UnsupportedOperationException();
}

/**
* Gets list of registered mod libraries
*
* @return {@link List} of mod libraries
* @see Orion#registerLibrary(String)
* @deprecated Deprecated without replacement
*/
@NotNull
List<String> getRegisteredLibraries();
@NonNull
@Deprecated
default List<String> getRegisteredLibraries() {
return Collections.emptyList();
}

/**
* Add new library for downloading from Maven repository.
*
* @param dependencyString Dependency string, like <pre>groupId:artifactId:version</pre>
* @deprecated Deprecated without replacement
*/
void registerLibrary(@NotNull String dependencyString);
default void registerLibrary(@NonNull String dependencyString) {
throw new UnsupportedOperationException();
}

/**
* Gets unmodifiable list of loaded mods
*
* @return Unmodifiable list of loaded mods
*/
@NotNull
@NonNull
List<ModInfo> getMods();

/**
Expand All @@ -107,14 +126,14 @@ public interface Orion {
* @return Instance of {@link ModInfo} or null, if mod wasn't found
*/
@Nullable
ModInfo getMod(@NotNull String modId);
ModInfo getMod(@NonNull String modId);

/**
* Gets unmodifiable list of registered Mixin configurations
*
* @return Unmodifiable list of registered Mixin configurations
*/
@NotNull
@NonNull
List<String> getMixinConfigurations();

/**
Expand All @@ -123,31 +142,30 @@ public interface Orion {
* @since 0.0.3-SNAPSHOT
* @param transformer New transformer
*/
void registerTransformer(@NotNull Class<? extends OrionTransformer> transformer);
void registerTransformer(@NonNull Class<? extends OrionTransformer> transformer);

/**
* Unregisters registered {@link OrionTransformer} class
*
* @since 0.0.3-SNAPSHOT
* @param transformer Registered transformer. Check if transformer is registered with {@link #getRegisteredTransformers()}
*/
void unregisterTransformer(@NotNull Class<? extends OrionTransformer> transformer);
void unregisterTransformer(@NonNull Class<? extends OrionTransformer> transformer);

/**
* Gets list of registered Orion bytecode transformers
*
* @since 0.0.3-SNAPSHOT
* @return {@link List} of registered {@link OrionTransformer}s
*/
@NotNull
Set<Class<? extends OrionTransformer>> getRegisteredTransformers();
@NonNull
Set<@NonNull Class<? extends OrionTransformer>> getRegisteredTransformers();

/**
* Gets mod asset manager
*
* @since 0.0.4-SNAPSHOT
* @return Mod asset manager
*/
@NotNull
AssetManager.ForMod getAssetManager();
AssetManager.@NonNull ForMod getAssetManager();
}
9 changes: 3 additions & 6 deletions OrionAPI/src/main/java/eu/mikroskeem/orion/api/OrionAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@

package eu.mikroskeem.orion.api;

import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import org.checkerframework.checker.nullness.qual.NonNull;

import java.util.Objects;

Expand All @@ -45,8 +44,7 @@ public final class OrionAPI {
*
* @return {@link Orion} instance
*/
@NotNull
@Contract(pure = true)
@NonNull
public static Orion getInstance() {
return instance;
}
Expand All @@ -56,8 +54,7 @@ public static Orion getInstance() {
*
* @param instance {@link Orion}
*/
@Contract("null -> fail")
public static void setInstance(@NotNull Orion instance) {
public static void setInstance(@NonNull Orion instance) {
Objects.requireNonNull(instance, "Can not set Orion instance to null!");
if(OrionAPI.instance != null) throw new IllegalStateException("Orion instance is already set!");
OrionAPI.instance = instance;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
package eu.mikroskeem.orion.api.asset;

import eu.mikroskeem.orion.api.mod.ModInfo;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;

import java.io.InputStream;
import java.io.UncheckedIOException;
Expand All @@ -46,7 +46,7 @@ public interface AssetManager {
* @return Instance of {@link InputStream} streaming asset contents or null, if asset couldn't be found
*/
@Nullable
InputStream getAsset(@NotNull String assetPath);
InputStream getAsset(@NonNull String assetPath);

/**
* Copies asset from mod jar to path
Expand All @@ -57,7 +57,7 @@ public interface AssetManager {
* @param assetPath Asset path
* @throws UncheckedIOException If asset copying fails either because of filesystem or resource finding error
*/
void copyAsset(@NotNull Path destination, @NotNull String assetPath) throws UncheckedIOException;
void copyAsset(@NonNull Path destination, @NonNull String assetPath) throws UncheckedIOException;

/**
* Copies asset from mod jar to path
Expand All @@ -67,7 +67,7 @@ public interface AssetManager {
* @param overwriteExisting Whether to overwrite destination file if present
* @throws UncheckedIOException If asset copying fails either because of filesystem or resource finding error
*/
void copyAsset(@NotNull Path destination, @NotNull String assetPath, boolean overwriteExisting) throws UncheckedIOException;
void copyAsset(@NonNull Path destination, @NonNull String assetPath, boolean overwriteExisting) throws UncheckedIOException;

/**
* Mod specific asset manager picker
Expand All @@ -79,8 +79,8 @@ interface ForMod {
* @param modInfo Instance of {@link ModInfo}
* @return Mod specific {@link AssetManager}
*/
@NotNull
AssetManager forMod(@NotNull ModInfo modInfo);
@NonNull
AssetManager forMod(@NonNull ModInfo modInfo);

/**
* Gets asset manager for mod specified with {@code modInfo}
Expand All @@ -89,6 +89,6 @@ interface ForMod {
* @return Mod specific {@link AssetManager} or null, if no such mod exists
*/
@Nullable
AssetManager forMod(@NotNull String modId);
AssetManager forMod(@NonNull String modId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@

package eu.mikroskeem.orion.api.bytecode;


import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;

/**
* Orion bytecode transformer interface
Expand All @@ -45,5 +44,5 @@ public interface OrionTransformer {
* @return Transformed class or null
*/
@Nullable
byte[] transformClass(@Nullable byte[] source, @NotNull String className, @NotNull String remappedClassName);
byte[] transformClass(@Nullable byte[] source, @NonNull String className, @NonNull String remappedClassName);
}
Loading