Skip to content

Commit

Permalink
1.3.4 release, closes #20
Browse files Browse the repository at this point in the history
  • Loading branch information
detox-dev committed Nov 29, 2021
1 parent 9672a3a commit caadc9c
Show file tree
Hide file tree
Showing 4 changed files with 144 additions and 143 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.ankoki</groupId>
<artifactId>SkJade</artifactId>
<version>1.4.0-beta</version>
<version>1.3.4</version>

<properties>
<maven.compiler.source>1.8</maven.compiler.source>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class ExprNearestStructure extends SimpleExpression<Location> {
static {
if (Utils.getServerMajorVersion() > 12) {
Skript.registerExpression(ExprNearestStructure.class, Location.class, ExpressionType.SIMPLE,
"[the] (nearest|closest) (1¦(not |un)(explored|discovered)|) [structure [of]] %structuretype% (in|within) [a] radius [of] %number% (around|at|from|of) %location%");
"[the] (nearest|closest) (1¦(not |un)(explored|discovered)|) [structure [of]] %skjstructuretype% (in|within) [a] radius [of] %number% (around|at|from|of) %location%");
}
}

Expand Down
279 changes: 140 additions & 139 deletions src/main/java/com/ankoki/skjade/hooks/holograms/HoloClassInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,150 +24,151 @@
public class HoloClassInfo {

static {
Classes.registerClass(new ClassInfo<>(Hologram.class, "hologram")
.user("holo(gram)?s?")
.name("Hologram")
.description("A Hologram created with Holographic displays.")
.since("1.0.0")
.changer(new Changer<Hologram>() {
@Nullable
@Override
public Class<?>[] acceptChange(ChangeMode mode) {
if (mode == ChangeMode.DELETE || mode == ChangeMode.RESET || mode == ChangeMode.ADD) {
return CollectionUtils.array(String.class, ItemStack.class);
}
return null;
}
try {
Classes.registerClass(new ClassInfo<>(Hologram.class, "hologram")
.user("holo(gram)?s?")
.name("Hologram")
.description("A Hologram created with Holographic displays.")
.since("1.0.0")
.changer(new Changer<Hologram>() {
@Nullable
@Override
public Class<?>[] acceptChange(ChangeMode mode) {
if (mode == ChangeMode.DELETE || mode == ChangeMode.RESET || mode == ChangeMode.ADD) {
return CollectionUtils.array(String.class, ItemStack.class);
}
return null;
}

@Override
public void change(Hologram[] holograms, @Nullable Object[] delta, ChangeMode mode) {
if (mode == ChangeMode.DELETE) {
HologramManager.deleteHologram(holograms);
}
else if (mode == ChangeMode.ADD) {
if (delta == null || delta[0] == null) return;
if (delta[0] instanceof String) {
for (Hologram hologram : holograms) {
HologramManager.addTextLine(hologram, (String) delta[0]);
@Override
public void change(Hologram[] holograms, @Nullable Object[] delta, ChangeMode mode) {
if (mode == ChangeMode.DELETE) {
HologramManager.deleteHologram(holograms);
} else if (mode == ChangeMode.ADD) {
if (delta == null || delta[0] == null) return;
if (delta[0] instanceof String) {
for (Hologram hologram : holograms) {
HologramManager.addTextLine(hologram, (String) delta[0]);
}
} else if (delta[0] instanceof ItemStack) {
for (Hologram hologram : holograms) {
HologramManager.addItemLine(hologram, (ItemStack) delta[0]);
}
}
} else {
for (Hologram hologram : holograms) {
if (!hologram.isDeleted()) {
hologram.clearLines();
}
}
}
}
} else if (delta[0] instanceof ItemStack) {
for (Hologram hologram : holograms) {
HologramManager.addItemLine(hologram, (ItemStack) delta[0]);
})
.parser(new Parser<Hologram>() {
@Override
public boolean canParse(ParseContext context) {
return false;
}
}
}
else {
for (Hologram hologram : holograms) {
if (!hologram.isDeleted()) {
hologram.clearLines();

@Override
public String toString(Hologram hologram, int i) {
return "hologram";
}

@Override
public String toVariableNameString(Hologram hologram) {
return "hologram:" + hologram.getCreationTimestamp();
}

@Override
public String getVariableNamePattern() {
return "hologram:\\d+";
}
})
.serializer(new Serializer<Hologram>() {
@Override
public Fields serialize(Hologram hologram) throws NotSerializableException {
Fields fields = new Fields();
fields.putObject("id", HologramManager.getIDFromHolo(hologram));
fields.putObject("location", HologramManager.getHoloLocation(hologram));
fields.putObject("lines", HologramManager.getLines(hologram));

return fields;
}

@Override
public void deserialize(Hologram hologram, Fields fields) throws StreamCorruptedException, NotSerializableException {
if (!hologram.isDeleted()) hologram.delete();
HologramManager.createHologram((String) fields.getObject("id"),
(Location) fields.getObject("location"), true, true);
}

@Override
public boolean mustSyncDeserialization() {
return true;
}

@Override
protected boolean canBeInstantiated() {
return false;
}
}));

Converters.registerConverter(Hologram.class, Location.class, Hologram::getLocation);

Classes.registerClass(new ClassInfo<>(HologramLine.class, "hologramline")
.user("holo(gram)?( |-)?lines?")
.name("Hologram Line")
.description("A line of a Hologram.")
.since("1.0.0")
.changer(new Changer<HologramLine>() {
@Nullable
@Override
public Class<?>[] acceptChange(ChangeMode mode) {
if (mode == ChangeMode.DELETE || mode == ChangeMode.RESET) {
return CollectionUtils.array();
}
return null;
}
}
}
}
})
.parser(new Parser<Hologram>() {
@Override
public boolean canParse(ParseContext context) {
return false;
}
@Override
public String toString(Hologram hologram, int i) {
return "hologram";
}

@Override
public String toVariableNameString(Hologram hologram) {
return "hologram:" + hologram.getCreationTimestamp();
}

@Override
public String getVariableNamePattern() {
return "hologram:\\d+";
}
})
.serializer(new Serializer<Hologram>() {
@Override
public Fields serialize(Hologram hologram) throws NotSerializableException {
Fields fields = new Fields();
fields.putObject("id", HologramManager.getIDFromHolo(hologram));
fields.putObject("location", HologramManager.getHoloLocation(hologram));
fields.putObject("lines", HologramManager.getLines(hologram));

return fields;
}

@Override
public void deserialize(Hologram hologram, Fields fields) throws StreamCorruptedException, NotSerializableException {
if (!hologram.isDeleted()) hologram.delete();
HologramManager.createHologram((String) fields.getObject("id"),
(Location) fields.getObject("location"), true, true);
}

@Override
public boolean mustSyncDeserialization() {
return true;
}

@Override
protected boolean canBeInstantiated() {
return false;
}
}));

Converters.registerConverter(Hologram.class, Location.class, Hologram::getLocation);

Classes.registerClass(new ClassInfo<>(HologramLine.class, "hologramline")
.user("holo(gram)?( |-)?lines?")
.name("Hologram Line")
.description("A line of a Hologram.")
.since("1.0.0")
.changer(new Changer<HologramLine>() {
@Nullable
@Override
public Class<?>[] acceptChange(ChangeMode mode) {
if (mode == ChangeMode.DELETE || mode == ChangeMode.RESET) {
return CollectionUtils.array();
}
return null;
}

@Override
public void change(HologramLine[] hologramLines, @Nullable Object[] objects, ChangeMode mode) {
for (HologramLine line : hologramLines) {
line.removeLine();
@Override
public void change(HologramLine[] hologramLines, @Nullable Object[] objects, ChangeMode mode) {
for (HologramLine line : hologramLines) {
line.removeLine();
}
}
})
.parser(new Parser<HologramLine>() {
@Override
public boolean canParse(ParseContext context) {
return false;
}

@Override
public String toString(HologramLine hologramLine, int i) {
return hologramLine instanceof ItemLine ? "hologram item line" : "hologram text line";
}

@Override
public String toVariableNameString(HologramLine hologramLine) {
return hologramLine instanceof ItemLine ? "hologram item line" : "hologram text line";
}

@Override
public String getVariableNamePattern() {
return "\\S+";
}
}));

Converters.registerConverter(TextLine.class, String.class, TextLine::getText);
Converters.registerConverter(ItemLine.class, ItemType.class, line -> new ItemType(line.getItemStack()));
Converters.registerConverter(HologramLine.class, Number.class, line -> {
Hologram parent = line.getParent();
for (int i = 0; i < parent.size(); i++) {
if (parent.getLine(i).equals(line)) return i++;
}
}
})
.parser(new Parser<HologramLine>() {
@Override
public boolean canParse(ParseContext context) {
return false;
}

@Override
public String toString(HologramLine hologramLine, int i) {
return hologramLine instanceof ItemLine ? "hologram item line" : "hologram text line";
}

@Override
public String toVariableNameString(HologramLine hologramLine) {
return hologramLine instanceof ItemLine ? "hologram item line" : "hologram text line";
}

@Override
public String getVariableNamePattern() {
return "\\S+";
}
}));

Converters.registerConverter(TextLine.class, String.class, TextLine::getText);
Converters.registerConverter(ItemLine.class, ItemType.class, line -> new ItemType(line.getItemStack()));
Converters.registerConverter(HologramLine.class, Number.class, line -> {
Hologram parent = line.getParent();
for (int i = 0; i < parent.size(); i++) {
if (parent.getLine(i).equals(line)) return i++;
}
return null;
});
return null;
});
} catch(IllegalArgumentException ignored) {}
}
}
4 changes: 2 additions & 2 deletions src/main/java/com/ankoki/skjade/utils/NonLegacyClassInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ public class NonLegacyClassInfo {

public NonLegacyClassInfo() {
//StructureType ClassInfo
Classes.registerClass(new ClassInfo<>(StructureType.class, "structuretype")
.user("structuretype?s?")
Classes.registerClass(new ClassInfo<>(StructureType.class, "skjstructuretype")
.user("skjstructuretype?s?")
.name("Structure Type")
.description("A specified structure type.")
.since("1.3.0")
Expand Down

0 comments on commit caadc9c

Please sign in to comment.