-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Un-deprecated and re-purposed Applicable#apply
* Added silent array processing. * Added new Comment annotation. * Added new Counter object for cross-thread atomic usage. * Optimized skull cache. * Added new scoreboard utility mimicking the tablist utility. * Added new WebResponse interface, static method available for downloading resources.
- Loading branch information
Showing
41 changed files
with
910 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
labyrinth-common/src/main/java/com/github/sanctum/labyrinth/annotation/Comment.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.github.sanctum.labyrinth.annotation; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
/** | ||
* <p>A developer comment.</p> | ||
*/ | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target(value = {ElementType.TYPE, ElementType.METHOD, ElementType.PARAMETER, ElementType.FIELD, ElementType.CONSTRUCTOR, ElementType.ANNOTATION_TYPE, ElementType.TYPE_USE}) | ||
public @interface Comment { | ||
|
||
/** | ||
* @return The developer comment for this example. | ||
*/ | ||
String value() default "no comment"; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 87 additions & 0 deletions
87
labyrinth-common/src/main/java/com/github/sanctum/labyrinth/data/service/Counter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
package com.github.sanctum.labyrinth.data.service; | ||
|
||
import com.github.sanctum.labyrinth.api.Service; | ||
import com.github.sanctum.labyrinth.library.TypeFlag; | ||
|
||
public interface Counter<N extends Number> extends Service { | ||
|
||
void add(); | ||
|
||
void subtract(); | ||
|
||
N get(); | ||
|
||
static <N extends Number> Counter<N> newInstance() { | ||
return new Counter<N>() { | ||
|
||
Number i; | ||
boolean integer = false; | ||
|
||
{ | ||
TypeFlag<N> flag = TypeFlag.get(); | ||
Class<N> type = flag.getType(); | ||
if (type == Integer.class) { | ||
i = 0L; | ||
integer = true; | ||
} else i = 0.0D; | ||
} | ||
|
||
@Override | ||
public void add() { | ||
if (integer) { | ||
i = (i.longValue() + 1L); | ||
} else i = (i.doubleValue() + 1D); | ||
} | ||
|
||
@Override | ||
public void subtract() { | ||
if (integer) { | ||
i = (i.longValue() - 1L); | ||
} else i = (i.doubleValue() - 1D); | ||
} | ||
|
||
@Override | ||
public N get() { | ||
return (N) i; | ||
} | ||
}; | ||
} | ||
|
||
static <N extends Number> Counter<N> newInstance(N influence) { | ||
return new Counter<N>() { | ||
|
||
Number i; | ||
final Number inf = influence; | ||
boolean integer = false; | ||
|
||
{ | ||
TypeFlag<N> flag = TypeFlag.get(); | ||
Class<N> type = flag.getType(); | ||
if (type == Integer.class) { | ||
i = 0L; | ||
integer = true; | ||
} else i = 0.0D; | ||
} | ||
|
||
@Override | ||
public void add() { | ||
if (integer) { | ||
i = (i.longValue() + inf.longValue()); | ||
} else i = (i.doubleValue() + inf.doubleValue()); | ||
} | ||
|
||
@Override | ||
public void subtract() { | ||
if (integer) { | ||
i = (i.longValue() - inf.longValue()); | ||
} else i = (i.doubleValue() - inf.doubleValue()); | ||
} | ||
|
||
@Override | ||
public N get() { | ||
return (N) i; | ||
} | ||
}; | ||
} | ||
|
||
} |
7 changes: 5 additions & 2 deletions
7
labyrinth-common/src/main/java/com/github/sanctum/labyrinth/data/service/DummyReducer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,14 @@ | ||
package com.github.sanctum.labyrinth.data.service; | ||
|
||
import com.github.sanctum.labyrinth.annotation.Json; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
public class DummyReducer implements Json.Reducer { | ||
public final class DummyReducer implements Json.Reducer { | ||
@Override | ||
public Map<String, Object> reduce(Object o) { | ||
return null; | ||
Map<String, Object> map = new HashMap<>(); | ||
map.put("element", o.toString()); | ||
return map; | ||
} | ||
} |
Oops, something went wrong.