From e7e4e5dad40786b1630a9568187b5a7b41c0c392 Mon Sep 17 00:00:00 2001 From: Sky Date: Thu, 12 Aug 2021 19:17:45 +0200 Subject: [PATCH] :ambulance: Hotfixed the variable usage in most syntaxes --- .idea/modules/Skimage.test.iml | 2 -- build.gradle | 4 +-- .../SkImage/skript/effects/EffDrawLine.java | 2 +- .../SkImage/skript/effects/EffDrawRect.java | 2 +- .../SkImage/skript/effects/EffDrawText.java | 28 +++++++++++-------- .../skript/expressions/ExprColorFromRGB.java | 2 +- .../skript/expressions/ExprDarkerImage.java | 2 +- .../skript/expressions/ExprImageBlurred.java | 2 +- .../skript/expressions/ExprLighterImage.java | 2 +- .../skript/expressions/ExprNewImage.java | 4 +-- .../skript/expressions/ExprNewTextFormat.java | 4 +-- .../skript/expressions/ExprResizedImage.java | 2 +- src/main/resources/plugin.yml | 2 +- 13 files changed, 31 insertions(+), 27 deletions(-) diff --git a/.idea/modules/Skimage.test.iml b/.idea/modules/Skimage.test.iml index 58d3fe9..0fd33be 100644 --- a/.idea/modules/Skimage.test.iml +++ b/.idea/modules/Skimage.test.iml @@ -4,8 +4,6 @@ - SPIGOT - BUKKIT PAPER diff --git a/build.gradle b/build.gradle index e94107d..a91df64 100644 --- a/build.gradle +++ b/build.gradle @@ -7,7 +7,7 @@ plugins { group 'info.itsthesky' version '1.3' -def version = '1.3' +def version = '1.7' repositories { mavenCentral() @@ -35,7 +35,7 @@ jar { } dependencies { - implementation 'com.github.SkriptLang:Skript:2.5' + implementation 'com.github.SkriptLang:Skript:2.5.3' implementation 'org.spigotmc:spigot-api:1.16.4-R0.1-SNAPSHOT' implementation 'org.jetbrains:annotations:20.1.0' implementation 'com.sk89q.worldguard:worldguard-bukkit:7.0.4' diff --git a/src/main/java/info/itsthesky/SkImage/skript/effects/EffDrawLine.java b/src/main/java/info/itsthesky/SkImage/skript/effects/EffDrawLine.java index 67d9855..acfdf0c 100644 --- a/src/main/java/info/itsthesky/SkImage/skript/effects/EffDrawLine.java +++ b/src/main/java/info/itsthesky/SkImage/skript/effects/EffDrawLine.java @@ -22,7 +22,7 @@ public class EffDrawLine extends Effect { static { Skript.registerEffect(EffDrawLine.class, - "[skimage] draw line with [the] (size|width) %integer% from %integer%[ ][,][ ]%integer% to %integer%[ ][,][ ]%integer% with [(color|colored)] %imagecolor% on [the] [image] %image%"); + "[skimage] draw line with [the] (size|width) %number% from %number%[ ][,][ ]%number% to %number%[ ][,][ ]%number% with [(color|colored)] %imagecolor% on [the] [image] %image%"); } private Expression exprSize; diff --git a/src/main/java/info/itsthesky/SkImage/skript/effects/EffDrawRect.java b/src/main/java/info/itsthesky/SkImage/skript/effects/EffDrawRect.java index c55e624..d7df889 100644 --- a/src/main/java/info/itsthesky/SkImage/skript/effects/EffDrawRect.java +++ b/src/main/java/info/itsthesky/SkImage/skript/effects/EffDrawRect.java @@ -22,7 +22,7 @@ public class EffDrawRect extends Effect { static { Skript.registerEffect(EffDrawRect.class, - "[skimage] draw rect[angle] [with anti[-]aliases] at [the [pixel] location] %integer%[ ][,][ ]%integer% with [the] size %integer%[ ][,][ ]%integer% with [(color|colored)] %imagecolor% [[with] [rotation] %-number% degree[s] [angle] [using origin location %-number%,[ ]%-number%]] on [the] [image] %image%"); + "[skimage] draw rect[angle] [with anti[-]aliases] at [the [pixel] location] %number%[ ][,][ ]%number% with [the] size %number%[ ][,][ ]%number% with [(color|colored)] %imagecolor% [[with] [rotation] %-number% degree[s] [angle] [using origin location %-number%,[ ]%-number%]] on [the] [image] %image%"); } private Expression exprX, exprY; diff --git a/src/main/java/info/itsthesky/SkImage/skript/effects/EffDrawText.java b/src/main/java/info/itsthesky/SkImage/skript/effects/EffDrawText.java index f96c6bb..c6df2fc 100644 --- a/src/main/java/info/itsthesky/SkImage/skript/effects/EffDrawText.java +++ b/src/main/java/info/itsthesky/SkImage/skript/effects/EffDrawText.java @@ -9,6 +9,7 @@ import ch.njol.skript.lang.Expression; import ch.njol.skript.lang.SkriptParser; import ch.njol.util.Kleenean; +import info.itsthesky.SkImage.SkImage; import org.bukkit.event.Event; import java.awt.*; @@ -23,8 +24,8 @@ public class EffDrawText extends Effect { static { Skript.registerEffect(EffDrawText.class, - "[skimage] draw [text] %string% [with anti[-]aliases] with [the] font [style] %font% at [x] %integer%[ ](,|and)[ ][y] %integer% with [color] %imagecolor% on [the] [image] %image%", - "[skimage] draw [text] %string% [with anti[-]aliases] with [the] font [style] %font% at [x] %integer%[ ](,|and)[ ][y] %integer% with [color] %imagecolor% on [the] [image] %image% with align center"); + "[skimage] draw [text] %string% [with anti[-]aliases] with [the] font [style] %font% at [x] %number%[ ](,|and)[ ][y] %number% with [color] %imagecolor% on [the] [image] %image%", + "[skimage] draw [text] %string% [with anti[-]aliases] with [the] font [style] %font% at [x] %number%[ ](,|and)[ ][y] %number% with [color] %imagecolor% on [the] [image] %image% with align center"); } private Expression exprText; @@ -66,15 +67,20 @@ protected void execute(Event e) { } g2d.setFont(font); g2d.setColor(color); - if (isCenter == 0) { - g2d.drawString(text, x, y); - } else { - TextLayout textLayout = new TextLayout(text, g2d.getFont(), - g2d.getFontRenderContext()); - double textHeight = textLayout.getBounds().getHeight(); - double textWidth = textLayout.getBounds().getWidth(); - g2d.drawString(text, (x / 2 - (int) textWidth / 2), - (y / 2 + (int) textHeight / 2)); + try { + if (isCenter == 0) { + g2d.drawString(text, x, y); + } else { + TextLayout textLayout = new TextLayout(text, g2d.getFont(), + g2d.getFontRenderContext()); + double textHeight = textLayout.getBounds().getHeight(); + double textWidth = textLayout.getBounds().getWidth(); + g2d.drawString(text, (x / 2 - (int) textWidth / 2), + (y / 2 + (int) textHeight / 2)); + } + } catch (Exception exception) { + SkImage.getInstance().getLogger().warning("Cannot draw text on the image because of an internal exception:"); + SkImage.getInstance().getLogger().warning(exception.getMessage()); } g2d.dispose(); } diff --git a/src/main/java/info/itsthesky/SkImage/skript/expressions/ExprColorFromRGB.java b/src/main/java/info/itsthesky/SkImage/skript/expressions/ExprColorFromRGB.java index 55b1fcb..371444b 100644 --- a/src/main/java/info/itsthesky/SkImage/skript/expressions/ExprColorFromRGB.java +++ b/src/main/java/info/itsthesky/SkImage/skript/expressions/ExprColorFromRGB.java @@ -23,7 +23,7 @@ public class ExprColorFromRGB extends SimpleExpression { static { Skript.registerExpression(ExprColorFromRGB.class, Color.class, ExpressionType.SIMPLE, - "[skimage] color from (rgb|redgreenblue) %integer%[ ][,][ ]%integer%[ ][,][ ]%integer%"); + "[skimage] color from (rgb|redgreenblue) %number%[ ][,][ ]%number%[ ][,][ ]%number%"); } private Expression exprRed, exprGreen, exprBlue; diff --git a/src/main/java/info/itsthesky/SkImage/skript/expressions/ExprDarkerImage.java b/src/main/java/info/itsthesky/SkImage/skript/expressions/ExprDarkerImage.java index dd15d33..78ea8a9 100644 --- a/src/main/java/info/itsthesky/SkImage/skript/expressions/ExprDarkerImage.java +++ b/src/main/java/info/itsthesky/SkImage/skript/expressions/ExprDarkerImage.java @@ -23,7 +23,7 @@ public class ExprDarkerImage extends SimpleExpression { static { Skript.registerExpression(ExprDarkerImage.class, BufferedImage.class, ExpressionType.SIMPLE, - "[skimage] darker [image] %image% with [the] force %integer%"); + "[skimage] darker [image] %image% with [the] force %number%"); } private Expression exprImage; diff --git a/src/main/java/info/itsthesky/SkImage/skript/expressions/ExprImageBlurred.java b/src/main/java/info/itsthesky/SkImage/skript/expressions/ExprImageBlurred.java index 2fbe85d..6c76aaa 100644 --- a/src/main/java/info/itsthesky/SkImage/skript/expressions/ExprImageBlurred.java +++ b/src/main/java/info/itsthesky/SkImage/skript/expressions/ExprImageBlurred.java @@ -23,7 +23,7 @@ public class ExprImageBlurred extends SimpleExpression { static { Skript.registerExpression(ExprImageBlurred.class, BufferedImage.class, ExpressionType.SIMPLE, - "[skimage] blur[red] [image] %image% with [the] (force|power) %integer%"); + "[skimage] blur[red] [image] %image% with [the] (force|power) %number%"); } private Expression exprImage; diff --git a/src/main/java/info/itsthesky/SkImage/skript/expressions/ExprLighterImage.java b/src/main/java/info/itsthesky/SkImage/skript/expressions/ExprLighterImage.java index b2e7378..0502fb8 100644 --- a/src/main/java/info/itsthesky/SkImage/skript/expressions/ExprLighterImage.java +++ b/src/main/java/info/itsthesky/SkImage/skript/expressions/ExprLighterImage.java @@ -23,7 +23,7 @@ public class ExprLighterImage extends SimpleExpression { static { Skript.registerExpression(ExprLighterImage.class, BufferedImage.class, ExpressionType.SIMPLE, - "[skimage] lighter [image] %image% with [the] force %integer%"); + "[skimage] lighter [image] %image% with [the] force %number%"); } private Expression exprImage; diff --git a/src/main/java/info/itsthesky/SkImage/skript/expressions/ExprNewImage.java b/src/main/java/info/itsthesky/SkImage/skript/expressions/ExprNewImage.java index 3d421a7..c906f55 100644 --- a/src/main/java/info/itsthesky/SkImage/skript/expressions/ExprNewImage.java +++ b/src/main/java/info/itsthesky/SkImage/skript/expressions/ExprNewImage.java @@ -23,8 +23,8 @@ public class ExprNewImage extends SimpleExpression { static { Skript.registerExpression(ExprNewImage.class, BufferedImage.class, ExpressionType.SIMPLE, - "[skimage] new image with [width] %integer% and [with] [height] %integer%", - "[skimage] new image with size %integer%[ ][,][ ]%integer%"); + "[skimage] new image with [width] %number% and [with] [height] %number%", + "[skimage] new image with size %number%[ ][,][ ]%number%"); } private Expression exprWidth; diff --git a/src/main/java/info/itsthesky/SkImage/skript/expressions/ExprNewTextFormat.java b/src/main/java/info/itsthesky/SkImage/skript/expressions/ExprNewTextFormat.java index b42b34c..7d94ce5 100644 --- a/src/main/java/info/itsthesky/SkImage/skript/expressions/ExprNewTextFormat.java +++ b/src/main/java/info/itsthesky/SkImage/skript/expressions/ExprNewTextFormat.java @@ -26,7 +26,7 @@ public class ExprNewTextFormat extends SimpleExpression { static { Skript.registerExpression(ExprNewTextFormat.class, Font.class, ExpressionType.SIMPLE, - "[skimage] new font[ ](format|style) with [the] [font] [name] %string% [[and] with [the] [style] %-string%] and with [the] [font] size %integer%"); + "[skimage] new font[ ](format|style) with [the] [font] [name] %string% [[and] with [the] [style] %-string%] and with [the] [font] size %number%"); } private Expression exprFont; @@ -47,7 +47,7 @@ protected Font[] get(@NotNull Event e) { String font = exprFont.getSingle(e); Number size = exprSize.getSingle(e); String style = exprStyle == null ? "plain" : (exprStyle.getSingle(e) == null ? "plain" : exprStyle.getSingle(e)); - if (font == null || size == null) return new Font[0]; + if (font == null || size == null || style == null) return new Font[0]; if (!Arrays.asList(GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames()).contains(font)) { SkImage.getInstance().getLogger().severe("The font named " + font + " doesn't exist or is not loaded in the JVM!"); return new Font[0]; diff --git a/src/main/java/info/itsthesky/SkImage/skript/expressions/ExprResizedImage.java b/src/main/java/info/itsthesky/SkImage/skript/expressions/ExprResizedImage.java index 30b89d3..ee6f79b 100644 --- a/src/main/java/info/itsthesky/SkImage/skript/expressions/ExprResizedImage.java +++ b/src/main/java/info/itsthesky/SkImage/skript/expressions/ExprResizedImage.java @@ -24,7 +24,7 @@ public class ExprResizedImage extends SimpleExpression { static { Skript.registerExpression(ExprResizedImage.class, BufferedImage.class, ExpressionType.SIMPLE, - "[skimage] resized [the] [image] %image% (with|to) [the] [size] %integer%[ ][,][ ]%integer% [with algo[rithm] %integer%]"); + "[skimage] resized [the] [image] %image% (with|to) [the] [size] %number%[ ][,][ ]%number% [with algo[rithm] %number%]"); } private Expression exprImage1; diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index e2f6567..cf0dd8d 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,6 +1,6 @@ name: SkImage author: ItsTheSky -version: 1.6 +version: 1.7 description: Simple addon which let you create, manage and customize image. main: info.itsthesky.SkImage.SkImage depend: