mirror of
https://github.com/GTNewHorizons/JustEnoughCalculation.git
synced 2026-11-19 11:49:06 +00:00
Clean up
This commit is contained in:
1 parent
45a1bb1761
commit
b627439835
8 files changed
-187
No files matched your search
@@ -1,15 +0,0 @@
|
||||
package me.towdium.jecalculation;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import org.apache.commons.lang3.StringEscapeUtils;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class JecaTranslator {
|
||||
public static String format(String translateKey, Object... parameters){
|
||||
String buffer = I18n.format(translateKey, parameters);
|
||||
buffer = StringEscapeUtils.unescapeJava(buffer);
|
||||
return buffer.replace("\t", " ");
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
package me.towdium.jecalculation.polyfill;
|
||||
|
||||
public class ClickType {
|
||||
public static final int PICKUP = 0;
|
||||
public static final int QUICK_MOVE = 1;
|
||||
public static final int SWAP = 2;
|
||||
public static final int CLONE = 3;
|
||||
public static final int THROW = 4;
|
||||
public static final int QUICK_CRAFT = 5;
|
||||
public static final int PICKUP_ALL = 6;
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
package me.towdium.jecalculation.polyfill;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.TYPE)
|
||||
@Deprecated
|
||||
public @interface Event {
|
||||
|
||||
/**
|
||||
* A class which will be subscribed to {@link net.minecraftforge.common.MinecraftForge.EVENT_BUS} at mod construction time.
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.TYPE)
|
||||
@Deprecated
|
||||
@interface EventBusSubscriber {
|
||||
Side[] value() default {Side.CLIENT, Side.SERVER};
|
||||
|
||||
/**
|
||||
* Optional value, only nessasary if tis annotation is not on the same class that has a @Mod annotation.
|
||||
* Needed to prevent early classloading of classes not owned by your mod.
|
||||
*
|
||||
* @return mod id
|
||||
*/
|
||||
String modid() default "";
|
||||
}
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
package me.towdium.jecalculation.polyfill;
|
||||
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.EventBus;
|
||||
import me.towdium.jecalculation.JustEnoughCalculation;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import org.reflections.Reflections;
|
||||
import org.reflections.scanners.ResourcesScanner;
|
||||
import org.reflections.scanners.SubTypesScanner;
|
||||
import org.reflections.util.ClasspathHelper;
|
||||
import org.reflections.util.ConfigurationBuilder;
|
||||
import org.reflections.util.FilterBuilder;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Deprecated
|
||||
public class Loader {
|
||||
|
||||
public static void subscribeToEventBus() {
|
||||
Set<Class<?>> classes = getAllClasses("me.towdium.jecalculation");
|
||||
classes.stream().filter((cls) -> cls.isAnnotationPresent(Event.EventBusSubscriber.class)).forEach((cls) -> {
|
||||
JustEnoughCalculation.logger.info("loading class" + cls.getName());
|
||||
try {
|
||||
MinecraftForge.EVENT_BUS.register(cls.newInstance());
|
||||
} catch (InstantiationException | IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static Set<Class<?>> getAllClasses(String packageName) {
|
||||
List<ClassLoader> classLoadersList = new LinkedList<ClassLoader>();
|
||||
classLoadersList.add(ClasspathHelper.contextClassLoader());
|
||||
classLoadersList.add(ClasspathHelper.staticClassLoader());
|
||||
|
||||
Reflections reflections = new Reflections(new ConfigurationBuilder().setScanners(
|
||||
new SubTypesScanner(false /* don't exclude Object.class */), new ResourcesScanner()).setUrls(
|
||||
ClasspathHelper.forClassLoader(classLoadersList.toArray(new ClassLoader[0]))).filterInputsBy(
|
||||
new FilterBuilder().include(FilterBuilder.prefix(packageName))));
|
||||
return reflections.getSubTypesOf(Object.class);
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
package me.towdium.jecalculation.utils;
|
||||
|
||||
/**
|
||||
* Author: towdium
|
||||
* Date: 8/10/17.
|
||||
*/
|
||||
public class IllegalPositionException extends RuntimeException {
|
||||
public IllegalPositionException() {
|
||||
super();
|
||||
}
|
||||
|
||||
public IllegalPositionException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
package me.towdium.jecalculation.utils;
|
||||
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
|
||||
@ParametersAreNonnullByDefault
|
||||
final public class OptionalEither<L, R> {
|
||||
public static <L, R> OptionalEither<L, R> left(L value) {
|
||||
return new OptionalEither<>(Optional.of(value), Optional.empty());
|
||||
}
|
||||
|
||||
public static <L, R> OptionalEither<L, R> right(R value) {
|
||||
return new OptionalEither<>(Optional.empty(), Optional.of(value));
|
||||
}
|
||||
|
||||
public static <L, R> OptionalEither<L, R> empty() {
|
||||
return new OptionalEither<>(Optional.empty(), Optional.empty());
|
||||
}
|
||||
|
||||
@SuppressWarnings("OptionalUsedAsFieldOrParameterType")
|
||||
private final Optional<L> left;
|
||||
@SuppressWarnings("OptionalUsedAsFieldOrParameterType")
|
||||
private final Optional<R> right;
|
||||
|
||||
@SuppressWarnings("OptionalUsedAsFieldOrParameterType")
|
||||
private OptionalEither(Optional<L> l, Optional<R> r) {
|
||||
left = l;
|
||||
right = r;
|
||||
}
|
||||
|
||||
public <T> Optional<T> map(Function<? super L, ? extends T> lFunc, Function<? super R, ? extends T> rFunc) {
|
||||
if(left.isPresent()){
|
||||
return left.map(lFunc);
|
||||
} else if(right.isPresent()){
|
||||
return right.map(rFunc);
|
||||
} else {
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
|
||||
public <T> OptionalEither<T, R> mapLeft(Function<? super L, ? extends T> lFunc) {
|
||||
return new OptionalEither<>(left.map(lFunc), right);
|
||||
}
|
||||
|
||||
public <T> OptionalEither<L, T> mapRight(Function<? super R, ? extends T> rFunc) {
|
||||
return new OptionalEither<>(left, right.map(rFunc));
|
||||
}
|
||||
|
||||
public void apply(Consumer<? super L> lFunc, Consumer<? super R> rFunc) {
|
||||
left.ifPresent(lFunc);
|
||||
right.ifPresent(rFunc);
|
||||
}
|
||||
|
||||
public boolean isPresent() {
|
||||
return left.isPresent() || right.isPresent();
|
||||
}
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
package me.towdium.jecalculation.utils.function;
|
||||
|
||||
public interface TriConsumer<T, U, V> {
|
||||
void accept(T t, U u, V v);
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
package me.towdium.jecalculation.utils.function;
|
||||
|
||||
public interface TriFunction <T, U, V, R> {
|
||||
R apply(T t, U u, V v);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user