Skip to content

Commit

Permalink
1.3.0 release:D
Browse files Browse the repository at this point in the history
Took 40 minutes
  • Loading branch information
Ankoki committed May 13, 2021
1 parent 0a4a3df commit 10b9306
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 15 deletions.
2 changes: 1 addition & 1 deletion plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<packaging>jar</packaging>
<artifactId>SkJade</artifactId>
<version>1.3.0-beta</version>
<version>1.3.0</version>

<parent>
<artifactId>SkJade-parent</artifactId>
Expand Down
1 change: 0 additions & 1 deletion plugin/src/main/java/com/ankoki/skjade/SkJade.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import ch.njol.skript.SkriptAddon;
import ch.njol.skript.classes.Changer;
import ch.njol.skript.classes.ClassInfo;
import ch.njol.skript.classes.EnumSerializer;
import ch.njol.skript.classes.Parser;
import ch.njol.skript.lang.ParseContext;
import ch.njol.skript.registrations.Classes;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,15 @@ public class EffHideEntity extends Effect {

static {
Skript.registerEffect(EffHideEntity.class,
"hide [the] [entity] %entities% (1¦from %-players%|)");
"[skjade] (hide|destory|send [a] destroy packet for) [the] [entity] %entities% (1¦(from|for) %-players%|)");
}

private Expression<Entity> entity;
private Expression<Player> player;

@Override
protected void execute(Event e) {
System.out.println("execute");
if (entity == null) return;
Entity[] entities = entity.getArray(e);
if (player == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class ExprUnary extends SimpleExpression<Number> {

static {
Skript.registerExpression(ExprUnary.class, Number.class, ExpressionType.SIMPLE,
"(-|unary [value of ])%number%");
"(-|unary [value of ])%~number%");
}

private Expression<Number> numberExpr;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,25 @@

import ch.njol.skript.Skript;
import ch.njol.skript.doc.*;
import ch.njol.skript.effects.Delay;
import ch.njol.skript.lang.Expression;
import ch.njol.skript.lang.ExpressionType;
import ch.njol.skript.lang.SkriptParser.ParseResult;
import ch.njol.skript.lang.util.SimpleExpression;
import ch.njol.util.Kleenean;
import com.ankoki.skjade.SkJade;
import io.netty.util.concurrent.CompleteFuture;
import org.bukkit.event.Event;
import org.jetbrains.annotations.Nullable;

import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.InputStream;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.net.URL;
import java.util.concurrent.CompletableFuture;

@Name("Image Lines")
@Description("Returns all the lines to make up an image. Max width is 150 and the image should be in the SkJade plugin folder.")
Expand All @@ -26,11 +31,13 @@ public class ExprImageLines extends SimpleExpression<String> {

static {
Skript.registerExpression(ExprImageLines.class, String.class, ExpressionType.SIMPLE,
"[hologram] lines of [the] image %string% with [(a|the)] width [of] %number%");
"[hologram] lines of [the] image %string% with [(a|the)] width [of] %number%",
"[hologram] lines of [the] image from [the] url %string% with [(a|the)] width [of] %number%");
}

Expression<String> imageName;
Expression<Number> widthExpr;
private boolean fromUrl;
private Expression<String> imageName;
private Expression<Number> widthExpr;

@Nullable
@Override
Expand All @@ -44,9 +51,25 @@ protected String[] get(Event e) {
Class clazz = Class.forName("com.gmail.filoghost.holographicdisplays.image.ImageMessage");
Constructor<?> constructor = clazz.getDeclaredConstructor(BufferedImage.class, int.class);
constructor.setAccessible(true);
File file = new File(SkJade.getInstance().getDataFolder() + File.separator + name);
if (!file.exists() || file.isDirectory()) return new String[0];
Object object = constructor.newInstance(ImageIO.read(file), width);
BufferedImage bufferedImage;
if (fromUrl) {
Delay.addDelayedEvent(e);
CompletableFuture<BufferedImage> future = CompletableFuture.supplyAsync(() -> {
try {
URL url = new URL(name);
return ImageIO.read(url);
} catch (Exception ignored) {}
return null;
});
while (!future.isDone()) {}
bufferedImage = future.get();
} else {
File file = new File(SkJade.getInstance().getDataFolder() + File.separator + name);
if (!file.exists() || file.isDirectory()) return new String[0];
bufferedImage = ImageIO.read(file);
}
if (bufferedImage == null) return new String[0];
Object object = constructor.newInstance(bufferedImage, width);
Method method = clazz.getDeclaredMethod("getLines");
method.setAccessible(true);
return (String[]) method.invoke(object);
Expand Down Expand Up @@ -75,6 +98,7 @@ public String toString(@Nullable Event e, boolean debug) {
public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed, ParseResult parseResult) {
imageName = (Expression<String>) exprs[0];
widthExpr = (Expression<Number>) exprs[1];
fromUrl = matchedPattern == 1;
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@
import java.lang.reflect.InvocationTargetException;
import java.nio.charset.StandardCharsets;

@Name("Server Brand")
@Description("Sends a server brand to players.")
@Examples("send brand \"washing machine heart by mitski\" to all players")
@Since("1.3.0")
//@Name("Server Brand")
//@Description("Sends a server brand to players.")
//@Examples("send brand \"washing machine heart by mitski\" to all players")
//@Since("INSERT VERSION")
public class EffShowBrand extends Effect {
private static final MinecraftKey BRAND_KEY = new MinecraftKey("brand");
private static final PacketContainer PAYLOAD_PACKET = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.CUSTOM_PAYLOAD);
Expand Down
2 changes: 1 addition & 1 deletion plugin/src/main/java/com/ankoki/skjade/utils/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,6 @@ private void loadFile() {
HOLOGRAPHIC_DISPLAYS_ENABLED = config.getBoolean("holographic-displays-enabled");
ELEMENTALS_ENABLED = config.getBoolean("elementals-enabled");
VERSION_ALERTS = config.getBoolean("new-version-alerts");
LASERS_ENABLED = config.getBoolean("lasers-enabled");
//LASERS_ENABLED = config.getBoolean("lasers-enabled");
}
}

0 comments on commit 10b9306

Please sign in to comment.