From 10b93063e90a8a5914c1ca4782e702d99e1bac5a Mon Sep 17 00:00:00 2001 From: Ankoki <72931234+Ankoki-Dev@users.noreply.github.com> Date: Thu, 13 May 2021 20:04:24 +0100 Subject: [PATCH] 1.3.0 release:D Took 40 minutes --- plugin/pom.xml | 2 +- .../main/java/com/ankoki/skjade/SkJade.java | 1 - .../elements/effects/EffHideEntity.java | 3 +- .../elements/expressions/ExprUnary.java | 2 +- .../holograms/expressions/ExprImageLines.java | 36 +++++++++++++++---- .../protocollib/effects/EffShowBrand.java | 8 ++--- .../java/com/ankoki/skjade/utils/Config.java | 2 +- 7 files changed, 39 insertions(+), 15 deletions(-) diff --git a/plugin/pom.xml b/plugin/pom.xml index 32309d0..424bbb0 100644 --- a/plugin/pom.xml +++ b/plugin/pom.xml @@ -6,7 +6,7 @@ jar SkJade - 1.3.0-beta + 1.3.0 SkJade-parent diff --git a/plugin/src/main/java/com/ankoki/skjade/SkJade.java b/plugin/src/main/java/com/ankoki/skjade/SkJade.java index 79bbb8c..9fb172d 100644 --- a/plugin/src/main/java/com/ankoki/skjade/SkJade.java +++ b/plugin/src/main/java/com/ankoki/skjade/SkJade.java @@ -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; diff --git a/plugin/src/main/java/com/ankoki/skjade/elements/effects/EffHideEntity.java b/plugin/src/main/java/com/ankoki/skjade/elements/effects/EffHideEntity.java index 594680d..65aa8b1 100644 --- a/plugin/src/main/java/com/ankoki/skjade/elements/effects/EffHideEntity.java +++ b/plugin/src/main/java/com/ankoki/skjade/elements/effects/EffHideEntity.java @@ -24,7 +24,7 @@ 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; @@ -32,6 +32,7 @@ public class EffHideEntity extends Effect { @Override protected void execute(Event e) { + System.out.println("execute"); if (entity == null) return; Entity[] entities = entity.getArray(e); if (player == null) { diff --git a/plugin/src/main/java/com/ankoki/skjade/elements/expressions/ExprUnary.java b/plugin/src/main/java/com/ankoki/skjade/elements/expressions/ExprUnary.java index 5673338..2efdba2 100644 --- a/plugin/src/main/java/com/ankoki/skjade/elements/expressions/ExprUnary.java +++ b/plugin/src/main/java/com/ankoki/skjade/elements/expressions/ExprUnary.java @@ -21,7 +21,7 @@ public class ExprUnary extends SimpleExpression { static { Skript.registerExpression(ExprUnary.class, Number.class, ExpressionType.SIMPLE, - "(-|unary [value of ])%number%"); + "(-|unary [value of ])%~number%"); } private Expression numberExpr; diff --git a/plugin/src/main/java/com/ankoki/skjade/hooks/holograms/expressions/ExprImageLines.java b/plugin/src/main/java/com/ankoki/skjade/hooks/holograms/expressions/ExprImageLines.java index ec0f709..83ebebe 100644 --- a/plugin/src/main/java/com/ankoki/skjade/hooks/holograms/expressions/ExprImageLines.java +++ b/plugin/src/main/java/com/ankoki/skjade/hooks/holograms/expressions/ExprImageLines.java @@ -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.") @@ -26,11 +31,13 @@ public class ExprImageLines extends SimpleExpression { 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 imageName; - Expression widthExpr; + private boolean fromUrl; + private Expression imageName; + private Expression widthExpr; @Nullable @Override @@ -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 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); @@ -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) exprs[0]; widthExpr = (Expression) exprs[1]; + fromUrl = matchedPattern == 1; return true; } } diff --git a/plugin/src/main/java/com/ankoki/skjade/hooks/protocollib/effects/EffShowBrand.java b/plugin/src/main/java/com/ankoki/skjade/hooks/protocollib/effects/EffShowBrand.java index 7c21413..97e0760 100644 --- a/plugin/src/main/java/com/ankoki/skjade/hooks/protocollib/effects/EffShowBrand.java +++ b/plugin/src/main/java/com/ankoki/skjade/hooks/protocollib/effects/EffShowBrand.java @@ -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); diff --git a/plugin/src/main/java/com/ankoki/skjade/utils/Config.java b/plugin/src/main/java/com/ankoki/skjade/utils/Config.java index b026b76..ed4f5c2 100644 --- a/plugin/src/main/java/com/ankoki/skjade/utils/Config.java +++ b/plugin/src/main/java/com/ankoki/skjade/utils/Config.java @@ -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"); } }