Skip to content

Instantly share code, notes, and snippets.

View maxov's full-sized avatar

Max Ovsiankin maxov

View GitHub Profile
project.getGradle().buildFinished { result ->
def failure = result.getFailure()
if (failure) {
def cause = failure.getCause().getCause().getCause()
throw new RuntimeException("no, this is what I want it to say!")
}
}
interface DataManipulator {
void clear();
void from(DataHolder holder);
}
interface DisplayNameData extends DataManipulator {
@maxov
maxov / turtles.md
Last active August 29, 2015 14:17
it's turtles all the way down
{ "Ticker": "IBM" } 
<json:object>
  <json:string name="Ticker">IBM</json:string>
</json:object>
@maxov
maxov / HList.java
Last active August 29, 2015 14:19
java heterogenous lists madness
public abstract class HList {
public abstract int length();
public static H0 of() {
return Nil;
}
public static <T1> H1<T1> of(T1 v1) {
return new H1<T1>(v1);
public static final Prop<Double, DamagingData> DAMAGE = null;
// TODO yes the capitals are bad style, but it makes sense for consistency
public static Prop<Double, DamagingData> DAMAGE_FOR_ENTITY(EntityType type) {
return null;
}
entity.get(Props.DAMAGE);
entity.get(Props.DAMAGE_FOR_ENTITY(EntityTypes.SKELETON);
// data api
Optional<DisplayNameData> wrappedDisplayName = entity.getData(DisplayNameData.class);
if (wrappedDisplayName.isPresent()) {
DisplayNameData displayname = wrappedDisplayName.get();
displayname.setDisplayName(Texts.of(displayName.get(), "hai!"));
entity.offer(displayname);
}
// equivalent POJO
if (entity.displayName != null) {
@maxov
maxov / value-api-question.java
Last active August 29, 2015 14:21
which is better?
// current data api
Optional<DisplayNameData> wrappedDisplayName = entity.getData(DisplayNameData.class);
if (wrappedDisplayName.isPresent()) {
DisplayNameData displayname = wrappedDisplayName.get();
displayname.setDisplayName(Texts.of(displayName.get(), "hai!"));
entity.offer(displayname);
}
// value api
if (entity.supports(Values.DISPLAY_NAME)) {
; the let macro
(set macros "let" (fn (tree)
(if (== (len tree) 0)
(err "let takes at least one arg")
(let
(expr (last tree))
(body (map (init tree) (fn (tree)
(cons (quote "def") tree))))
(form (push (cons (quote "do") body) expr))
(compileExpr form body)))))

Data Merging

Data merging is the process by which new data as set by a plugin is put back into someplace where it carries more meaning, like an entity or block.

The current method

The Sponge API has had DataPriority for a while. It essentially dictates how data from a copier and copiee (?) should be merged, applying specifically to the case of filling data in a mainpulator or offering it back to the containing holder.

@maxov
maxov / text-formatting.md
Last active August 29, 2015 14:22
A description of text formatting

Text Formatting

What are the goals?

  • A format that is easy for server admins to configure
  • A format that is familiar to people dealing with text/easy to learn
  • A format that is extensible and has the power to configure text objects in any way possible

Variables