Skip to content

Commit a96c666

Browse files
committed
* Completely removed old task scheduling utility for newly optimized 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
1 parent b7a05b9 commit a96c666

File tree

9 files changed

+191
-181
lines changed

9 files changed

+191
-181
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package com.github.sanctum.labyrinth.annotation;
2+
3+
import java.lang.annotation.Documented;
4+
import java.lang.annotation.ElementType;
5+
import java.lang.annotation.Retention;
6+
import java.lang.annotation.RetentionPolicy;
7+
import java.lang.annotation.Target;
8+
9+
/**
10+
* <p>A simple annotation for marking elements that are completely optional</p>
11+
*/
12+
@Documented
13+
@Retention(RetentionPolicy.RUNTIME)
14+
@Target(value = {ElementType.TYPE, ElementType.METHOD, ElementType.PARAMETER, ElementType.FIELD, ElementType.CONSTRUCTOR, ElementType.ANNOTATION_TYPE, ElementType.TYPE_USE})
15+
public @interface Voluntary {
16+
17+
/**
18+
* @return The developer comment for this example.
19+
*/
20+
String value() default "no comment";
21+
22+
}

labyrinth-common/src/main/java/com/github/sanctum/labyrinth/data/WideFunction.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package com.github.sanctum.labyrinth.data;
22

33
/**
4+
* A Bi-Function like interface for converting 2 objects into one result.
5+
*
46
* @see java.util.function.Function
57
*/
68
@FunctionalInterface

labyrinth-common/src/main/java/com/github/sanctum/labyrinth/library/Deployable.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ public Deployable<T> queue(Consumer<? super T> consumer, Date date) {
176176

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

182182
@Override

labyrinth-common/src/main/java/com/github/sanctum/labyrinth/library/DeployableMapping.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,25 @@
11
package com.github.sanctum.labyrinth.library;
22

33
import com.github.sanctum.labyrinth.LabyrinthProvider;
4+
import com.github.sanctum.labyrinth.annotation.Comment;
45
import com.github.sanctum.labyrinth.api.Service;
56
import com.github.sanctum.labyrinth.api.TaskService;
67
import java.util.Date;
78
import java.util.concurrent.CompletableFuture;
89
import java.util.function.Consumer;
910
import java.util.function.Function;
11+
import java.util.function.Supplier;
1012

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

1316
private final Function<? super Object, ? extends R> function;
1417
private final Object parent;
1518
private R value;
1619

17-
DeployableMapping(Object o, Function<? super Object, ? extends R> function) {
20+
DeployableMapping(Supplier<Object> o, Function<? super Object, ? extends R> function) {
1821
this.function = function;
19-
this.parent = o;
22+
this.parent = o.get();
2023
}
2124

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

7578
@Override
7679
public <O> DeployableMapping<O> map(Function<? super R, ? extends O> mapper) {
77-
return new DeployableMapping<>(submit().join(), (Function<? super Object, ? extends O>) mapper);
80+
return new DeployableMapping<>(() -> submit().join(), (Function<? super Object, ? extends O>) mapper);
7881
}
7982

8083
@Override

labyrinth-common/src/main/java/com/github/sanctum/labyrinth/library/Mailer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ public Deployable<Mailer> queue(Consumer<? super Mailer> consumer, Date date) {
486486

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

492492
@Override

labyrinth-gui/src/main/java/com/github/sanctum/labyrinth/gui/unity/construct/Menu.java

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -757,6 +757,21 @@ default Inventory getInventory() {
757757
return () -> menu;
758758
}
759759

760+
static @NotNull Instance of(@NotNull Menu menu, Player player) {
761+
return new Instance() {
762+
763+
@Override
764+
public @NotNull Inventory getInventory() {
765+
return player != null ? menu.getInventory().getViewer(player).getInventory().getElement() : menu.getInventory().getElement();
766+
}
767+
768+
@Override
769+
public @NotNull Menu getMenu() {
770+
return menu;
771+
}
772+
};
773+
}
774+
760775
}
761776

762777
/**
@@ -854,9 +869,6 @@ public void onOpen(InventoryOpenEvent e) {
854869
}
855870

856871
}
857-
858-
859-
p.updateInventory();
860872
}
861873
}
862874

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

14601472
if (element.isCancelled()) {
1461-
element.getElement().closeInventory();
1473+
menu.close((Player) e.getPlayer());
14621474
}
14631475

14641476
}

labyrinth-gui/src/main/java/com/github/sanctum/labyrinth/gui/unity/impl/MenuViewer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public Inventory getElement() {
4949
if (getInventory().isPaginated()) {
5050
total = ((InventoryElement.Paginated)getInventory()).getTotalPages();
5151
}
52-
this.inventory = Bukkit.createInventory(Menu.Instance.of(element.menu), getInventory().getParent().getSize().getSize(), StringUtils.use(MessageFormat.format(getInventory().title, getPage().toNumber(), total)).translate());
52+
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());
5353
}
5454
if (getInventory().getParent().getProperties().contains(Menu.Property.REFILLABLE)) {
5555
if (!UniformedComponents.accept(Arrays.asList(inventory.getContents())).filter(Objects::nonNull).findAny().isPresent()) {

0 commit comments

Comments
 (0)