Skip to content

Commit

Permalink
* Completely removed old task scheduling utility for newly optimized …
Browse files Browse the repository at this point in the history
…alternative.

* Optimized task execution handling.
* Added new isModded check to LegacyCheckService
* Added new toBlockFace method to DirectivePoint
* Optimized internal Unity task executions.
* Finalized OrdinalProcedure service.
* Completely removed old PaginatedList.java utility.
* Finalized sub-command injection handling.
* Optimized and fixed remaining issues with Message.java abstraction in tandem with ComponentUtil.
* Optimized labyrinth provided placeholder system.
* Added version support for 1.18+ (1.19 & future versions)
* Added new AbstractClassLoader for alternative class loading from external jars than AddonLoader
* Added class unloading to AddonLoader
* Added new multi-object isNull checking method to Check.java
* Finalized SubCommandList.java and made its internal referencing to depend on localization.
* Added new docket interfacing to unity gui library. Purposed to create ultimate fluidity in menu creation through configuration.
* Added new FormattedString.java class to help act as more of a modular StringUtils utility class.
* Added json string to json object conversion method to JsonIntermediate.java
* Optimized unity menu interaction, fixed resulting item inventory duplication bug in modded environments.
* Fixed TablistInstance.java player list name default.
* Fixed reflection problems 1.18+ with Task.java
* Added simple UnknownGeneric.java interface.
* Fixed WebResponse.java
  • Loading branch information
Hempfest committed Jun 17, 2022
1 parent b7a05b9 commit a96c666
Show file tree
Hide file tree
Showing 9 changed files with 191 additions and 181 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.github.sanctum.labyrinth.annotation;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
* <p>A simple annotation for marking elements that are completely optional</p>
*/
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target(value = {ElementType.TYPE, ElementType.METHOD, ElementType.PARAMETER, ElementType.FIELD, ElementType.CONSTRUCTOR, ElementType.ANNOTATION_TYPE, ElementType.TYPE_USE})
public @interface Voluntary {

/**
* @return The developer comment for this example.
*/
String value() default "no comment";

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.github.sanctum.labyrinth.data;

/**
* A Bi-Function like interface for converting 2 objects into one result.
*
* @see java.util.function.Function
*/
@FunctionalInterface
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ public Deployable<T> queue(Consumer<? super T> consumer, Date date) {

@Override
public <O> DeployableMapping<O> map(Function<? super T, ? extends O> mapper) {
return new DeployableMapping<>(submit().join(), (Function<? super Object, ? extends O>) mapper);
return new DeployableMapping<>(() -> submit().join(), (Function<? super Object, ? extends O>) mapper);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
package com.github.sanctum.labyrinth.library;

import com.github.sanctum.labyrinth.LabyrinthProvider;
import com.github.sanctum.labyrinth.annotation.Comment;
import com.github.sanctum.labyrinth.api.Service;
import com.github.sanctum.labyrinth.api.TaskService;
import java.util.Date;
import java.util.concurrent.CompletableFuture;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Supplier;

@Comment("A delegate to deployable interfacing, conforming one object type into another.")
public final class DeployableMapping<R> implements Deployable<R> {

private final Function<? super Object, ? extends R> function;
private final Object parent;
private R value;

DeployableMapping(Object o, Function<? super Object, ? extends R> function) {
DeployableMapping(Supplier<Object> o, Function<? super Object, ? extends R> function) {
this.function = function;
this.parent = o;
this.parent = o.get();
}

@Override
Expand Down Expand Up @@ -74,7 +77,7 @@ public DeployableMapping<R> queue(Consumer<? super R> consumer, Date date) {

@Override
public <O> DeployableMapping<O> map(Function<? super R, ? extends O> mapper) {
return new DeployableMapping<>(submit().join(), (Function<? super Object, ? extends O>) mapper);
return new DeployableMapping<>(() -> submit().join(), (Function<? super Object, ? extends O>) mapper);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ public Deployable<Mailer> queue(Consumer<? super Mailer> consumer, Date date) {

@Override
public <O> DeployableMapping<O> map(Function<? super Mailer, ? extends O> mapper) {
return new DeployableMapping<>(Mailer.this, (Function<? super Object, ? extends O>) mapper);
return new DeployableMapping<>(() -> Mailer.this, (Function<? super Object, ? extends O>) mapper);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -757,6 +757,21 @@ default Inventory getInventory() {
return () -> menu;
}

static @NotNull Instance of(@NotNull Menu menu, Player player) {
return new Instance() {

@Override
public @NotNull Inventory getInventory() {
return player != null ? menu.getInventory().getViewer(player).getInventory().getElement() : menu.getInventory().getElement();
}

@Override
public @NotNull Menu getMenu() {
return menu;
}
};
}

}

/**
Expand Down Expand Up @@ -854,9 +869,6 @@ public void onOpen(InventoryOpenEvent e) {
}

}


p.updateInventory();
}
}

Expand Down Expand Up @@ -1458,7 +1470,7 @@ public void onOpen(InventoryOpenEvent e) {
menu.open.apply(element);

if (element.isCancelled()) {
element.getElement().closeInventory();
menu.close((Player) e.getPlayer());
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public Inventory getElement() {
if (getInventory().isPaginated()) {
total = ((InventoryElement.Paginated)getInventory()).getTotalPages();
}
this.inventory = Bukkit.createInventory(Menu.Instance.of(element.menu), getInventory().getParent().getSize().getSize(), StringUtils.use(MessageFormat.format(getInventory().title, getPage().toNumber(), total)).translate());
this.inventory = Bukkit.createInventory(Menu.Instance.of(element.menu, getPlayer().getPlayer()), getInventory().getParent().getSize().getSize(), StringUtils.use(MessageFormat.format(getInventory().title, getPage().toNumber(), total)).translate());
}
if (getInventory().getParent().getProperties().contains(Menu.Property.REFILLABLE)) {
if (!UniformedComponents.accept(Arrays.asList(inventory.getContents())).filter(Objects::nonNull).findAny().isPresent()) {
Expand Down

0 comments on commit a96c666

Please sign in to comment.