Skip to content

Commit

Permalink
🚑 Hotfixed the variable usage in most syntaxes
Browse files Browse the repository at this point in the history
  • Loading branch information
ItsTheSky committed Aug 12, 2021
1 parent 33e72b4 commit e7e4e5d
Show file tree
Hide file tree
Showing 13 changed files with 31 additions and 27 deletions.
2 changes: 0 additions & 2 deletions .idea/modules/Skimage.test.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ plugins {
group 'info.itsthesky'
version '1.3'

def version = '1.3'
def version = '1.7'

repositories {
mavenCentral()
Expand Down Expand Up @@ -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'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Integer> exprSize;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Number> exprX, exprY;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.*;
Expand All @@ -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<String> exprText;
Expand Down Expand Up @@ -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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class ExprColorFromRGB extends SimpleExpression<Color> {

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<Integer> exprRed, exprGreen, exprBlue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class ExprDarkerImage extends SimpleExpression<BufferedImage> {

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<BufferedImage> exprImage;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class ExprImageBlurred extends SimpleExpression<BufferedImage> {

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<BufferedImage> exprImage;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class ExprLighterImage extends SimpleExpression<BufferedImage> {

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<BufferedImage> exprImage;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ public class ExprNewImage extends SimpleExpression<BufferedImage> {

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<Integer> exprWidth;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class ExprNewTextFormat extends SimpleExpression<Font> {

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<String> exprFont;
Expand All @@ -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];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class ExprResizedImage extends SimpleExpression<BufferedImage> {

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<BufferedImage> exprImage1;
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down

0 comments on commit e7e4e5d

Please sign in to comment.