mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-06-19 07:11:14 +00:00
Lazy#of -> Lazy#lazy
This commit is contained in:
+1
-1
@@ -9,7 +9,7 @@ import java.util.Collection;
|
|||||||
public interface EnumProperty<T extends Enum<T>> extends Property<T> {
|
public interface EnumProperty<T extends Enum<T>> extends Property<T> {
|
||||||
static <T extends Enum<T>> EnumProperty<T> of(String name, Class<T> clazz) {
|
static <T extends Enum<T>> EnumProperty<T> of(String name, Class<T> clazz) {
|
||||||
return new EnumProperty<T>() {
|
return new EnumProperty<T>() {
|
||||||
private final Lazy<Collection<T>> constants = Lazy.of(() -> Arrays.asList(clazz.getEnumConstants()));
|
private final Lazy<Collection<T>> constants = Lazy.lazy(() -> Arrays.asList(clazz.getEnumConstants()));
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Class<T> getType() {
|
public Class<T> getType() {
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ public final class Lazy<T> {
|
|||||||
this.valueSupplier = valueSupplier;
|
this.valueSupplier = valueSupplier;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T> Lazy<T> of(Supplier<T> valueSupplier) {
|
public static <T> Lazy<T> lazy(Supplier<T> valueSupplier) {
|
||||||
return new Lazy<>(valueSupplier);
|
return new Lazy<>(valueSupplier);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,13 +9,11 @@ import com.dfsek.terra.api.command.exception.MalformedCommandException;
|
|||||||
import com.dfsek.terra.api.config.ConfigPack;
|
import com.dfsek.terra.api.config.ConfigPack;
|
||||||
import com.dfsek.terra.api.config.PluginConfig;
|
import com.dfsek.terra.api.config.PluginConfig;
|
||||||
import com.dfsek.terra.api.event.EventManager;
|
import com.dfsek.terra.api.event.EventManager;
|
||||||
import com.dfsek.terra.api.event.events.platform.PlatformInitializationEvent;
|
|
||||||
import com.dfsek.terra.api.event.functional.FunctionalEventHandler;
|
import com.dfsek.terra.api.event.functional.FunctionalEventHandler;
|
||||||
import com.dfsek.terra.api.lang.Language;
|
import com.dfsek.terra.api.lang.Language;
|
||||||
import com.dfsek.terra.api.profiler.Profiler;
|
import com.dfsek.terra.api.profiler.Profiler;
|
||||||
import com.dfsek.terra.api.registry.CheckedRegistry;
|
import com.dfsek.terra.api.registry.CheckedRegistry;
|
||||||
import com.dfsek.terra.api.registry.Registry;
|
import com.dfsek.terra.api.registry.Registry;
|
||||||
import com.dfsek.terra.api.util.generic.Construct;
|
|
||||||
import com.dfsek.terra.api.util.generic.Lazy;
|
import com.dfsek.terra.api.util.generic.Lazy;
|
||||||
import com.dfsek.terra.commands.CommandUtil;
|
import com.dfsek.terra.commands.CommandUtil;
|
||||||
import com.dfsek.terra.commands.TerraCommandManager;
|
import com.dfsek.terra.commands.TerraCommandManager;
|
||||||
@@ -39,7 +37,7 @@ import java.util.Optional;
|
|||||||
* Skeleton implementation of {@link TerraPlugin}
|
* Skeleton implementation of {@link TerraPlugin}
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractTerraPlugin implements TerraPlugin {
|
public abstract class AbstractTerraPlugin implements TerraPlugin {
|
||||||
private final Lazy<DebugLogger> debugLogger = Lazy.of(() -> new DebugLogger(logger()));
|
private final Lazy<DebugLogger> debugLogger = Lazy.lazy(() -> new DebugLogger(logger()));
|
||||||
private final EventManager eventManager = new EventManagerImpl(this);
|
private final EventManager eventManager = new EventManagerImpl(this);
|
||||||
|
|
||||||
private final ConfigRegistry configRegistry = new ConfigRegistry();
|
private final ConfigRegistry configRegistry = new ConfigRegistry();
|
||||||
|
|||||||
+1
-2
@@ -8,7 +8,6 @@ import com.dfsek.terra.api.registry.meta.RegistryFactory;
|
|||||||
import com.dfsek.terra.api.util.generic.Lazy;
|
import com.dfsek.terra.api.util.generic.Lazy;
|
||||||
|
|
||||||
import java.lang.reflect.AnnotatedType;
|
import java.lang.reflect.AnnotatedType;
|
||||||
import java.lang.reflect.Type;
|
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
||||||
public class RegistryFactoryImpl implements RegistryFactory {
|
public class RegistryFactoryImpl implements RegistryFactory {
|
||||||
@@ -20,7 +19,7 @@ public class RegistryFactoryImpl implements RegistryFactory {
|
|||||||
@Override
|
@Override
|
||||||
public <T> OpenRegistry<T> create(Function<OpenRegistry<T>, TypeLoader<T>> loader) {
|
public <T> OpenRegistry<T> create(Function<OpenRegistry<T>, TypeLoader<T>> loader) {
|
||||||
return new OpenRegistryImpl<>() {
|
return new OpenRegistryImpl<>() {
|
||||||
private final Lazy<TypeLoader<T>> loaderCache = Lazy.of(() -> loader.apply(this));
|
private final Lazy<TypeLoader<T>> loaderCache = Lazy.lazy(() -> loader.apply(this));
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public T load(AnnotatedType type, Object o, ConfigLoader configLoader) throws LoadException {
|
public T load(AnnotatedType type, Object o, ConfigLoader configLoader) throws LoadException {
|
||||||
|
|||||||
@@ -5,10 +5,8 @@ import com.dfsek.tectonic.loading.TypeRegistry;
|
|||||||
import com.dfsek.terra.AbstractTerraPlugin;
|
import com.dfsek.terra.AbstractTerraPlugin;
|
||||||
import com.dfsek.terra.api.Logger;
|
import com.dfsek.terra.api.Logger;
|
||||||
import com.dfsek.terra.api.addon.TerraAddon;
|
import com.dfsek.terra.api.addon.TerraAddon;
|
||||||
import com.dfsek.terra.api.block.state.BlockState;
|
|
||||||
import com.dfsek.terra.api.handle.ItemHandle;
|
import com.dfsek.terra.api.handle.ItemHandle;
|
||||||
import com.dfsek.terra.api.handle.WorldHandle;
|
import com.dfsek.terra.api.handle.WorldHandle;
|
||||||
import com.dfsek.terra.api.lang.Language;
|
|
||||||
import com.dfsek.terra.api.util.generic.Lazy;
|
import com.dfsek.terra.api.util.generic.Lazy;
|
||||||
import com.dfsek.terra.config.lang.LangUtil;
|
import com.dfsek.terra.config.lang.LangUtil;
|
||||||
import com.dfsek.terra.fabric.handle.FabricItemHandle;
|
import com.dfsek.terra.fabric.handle.FabricItemHandle;
|
||||||
@@ -44,7 +42,7 @@ public class TerraPluginImpl extends AbstractTerraPlugin {
|
|||||||
|
|
||||||
private final ItemHandle itemHandle = new FabricItemHandle();
|
private final ItemHandle itemHandle = new FabricItemHandle();
|
||||||
private final WorldHandle worldHandle = new FabricWorldHandle();
|
private final WorldHandle worldHandle = new FabricWorldHandle();
|
||||||
private final Lazy<File> dataFolder = Lazy.of(() -> new File(FabricLoader.getInstance().getConfigDir().toFile(), "Terra"));
|
private final Lazy<File> dataFolder = Lazy.lazy(() -> new File(FabricLoader.getInstance().getConfigDir().toFile(), "Terra"));
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public WorldHandle getWorldHandle() {
|
public WorldHandle getWorldHandle() {
|
||||||
|
|||||||
Reference in New Issue
Block a user