Skip to content

Commit

Permalink
Merge pull request #13 from Fusezion/dev/2.8.1
Browse files Browse the repository at this point in the history
Prepare release of 2.8.1
  • Loading branch information
Fusezion authored Dec 14, 2024
2 parents 0ac28dd + c0752dd commit 9351d6a
Show file tree
Hide file tree
Showing 21 changed files with 200 additions and 151 deletions.
25 changes: 18 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ plugins {
}

group = "lol.aabss"
version = "2.8"
version = "2.8.1"

repositories {
mavenCentral()
Expand All @@ -18,26 +18,37 @@ repositories {
}

dependencies {
compileOnly "io.papermc.paper:paper-api:1.21.1-R0.1-SNAPSHOT"
compileOnly "io.papermc.paper:paper-api:1.21.4-R0.1-SNAPSHOT"
implementation "net.kyori:adventure-text-minimessage:4.15.0"
compileOnly ("com.github.SkriptLang:Skript:2.7.0") {
compileOnly ("com.github.SkriptLang:Skript:2.9.5") {
transitive = false
}
compileOnly "com.github.decentsoftware-eu:decentholograms:2.8.8"
compileOnly files("libs/VulcanAPI.jar")
implementation "com.github.SkriptLang:skript-reflect:2.4-dev1"
implementation "org.mineskin:java-client:2.1.1-SNAPSHOT"
implementation "org.mineskin:java-client-java11:2.1.1-SNAPSHOT"
implementation "org.mineskin:java-client:3.0.1-SNAPSHOT"
implementation "org.mineskin:java-client-java11:3.0.1-SNAPSHOT"
}

java {
toolchain.languageVersion.set(JavaLanguageVersion.of(21))
}

build {
dependsOn(shadowJar)
tasks.withType(JavaCompile).tap {
configureEach {
options.compilerArgs.add("-Xlint:unchecked")
options.compilerArgs.add("-Xlint:deprecation")
}
}
}

shadowJar {
archiveFileName = project.name + "-" + project.version + ".jar"
dependencies {
include(dependency("org.mineskin:java-client:2.1.1-SNAPSHOT"))
include(dependency("org.mineskin:java-client-java11:2.1.1-SNAPSHOT"))
include(dependency("org.mineskin:java-client:3.0.1-SNAPSHOT"))
include(dependency("org.mineskin:java-client-java11:3.0.1-SNAPSHOT"))
}
}

Expand Down
12 changes: 11 additions & 1 deletion src/main/java/lol/aabss/skuishy/Skuishy.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import ch.njol.skript.SkriptAddon;
import ch.njol.skript.bstats.bukkit.Metrics;
import ch.njol.skript.bstats.charts.SimplePie;
import ch.njol.skript.util.Version;
import com.mojang.brigadier.arguments.StringArgumentType;
import io.papermc.paper.command.brigadier.Commands;
import io.papermc.paper.plugin.lifecycle.event.LifecycleEventManager;
Expand All @@ -29,7 +30,11 @@
import java.util.HashMap;

import static lol.aabss.skuishy.other.GetVersion.latestVersion;
import static lol.aabss.skuishy.other.SubCommands.*;
import static lol.aabss.skuishy.other.SubCommands.cmdDependencies;
import static lol.aabss.skuishy.other.SubCommands.cmdInfo;
import static lol.aabss.skuishy.other.SubCommands.cmdReload;
import static lol.aabss.skuishy.other.SubCommands.cmdUpdate;
import static lol.aabss.skuishy.other.SubCommands.cmdVersion;
import static net.kyori.adventure.text.minimessage.MiniMessage.miniMessage;

@SuppressWarnings("deprecation")
Expand All @@ -42,6 +47,8 @@ public class Skuishy extends JavaPlugin {
public static Permission last_permission;
public static Blueprint last_blueprint;
public static String latest_version;
public static Version latest_version_object;
public static Version plugin_version;
public static String data_path;
public static HashMap<String, Boolean> element_map = new HashMap<>();
public static final String prefix = ChatColor.of("#00ff00") + "[Skuishy] " + ChatColor.RESET;
Expand All @@ -51,6 +58,7 @@ public class Skuishy extends JavaPlugin {
@SuppressWarnings("UnstableApiUsage")
public void onEnable() {
instance = this;
plugin_version = new Version(getPluginMeta().getVersion());
saveDefaultConfig();
Blueprint.loadJson();
getServer().getPluginManager().registerEvents(new UpdateChecker(), this);
Expand All @@ -75,6 +83,8 @@ public void onEnable() {
Logger.success("Skuishy has been enabled!");
Bukkit.getScheduler().scheduleAsyncRepeatingTask(this, () -> {
latest_version = latestVersion();
assert latest_version != null;
latest_version_object = new Version(latest_version);
if (getConfig().getBoolean("version-check-msg")) Logger.warn("Got latest version."); // not a warn just want yellow
}, 0L, 144000L);
data_path = this.getDataFolder().getAbsolutePath();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"if {_shearable} is ready to be sheared:",
"\tshear {_shearable}"
})
@Since("2.9")
@Since("2.8.1")
public class CondIsShearableReadyToBeSheared extends EntityCondition<Shearable> {

static {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"if {_wolf} is tamed:",
"\tset tamed state of {_wolf} to false"
})
@Since("2.9")
@Since("2.8.1")
public class CondIsTameableTamed extends EntityCondition<Tameable> {

static {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
@Examples({
"set collar color of {_cat} to purple"
})
@Since("2.9")
@Since("2.8.1")
public class ExprCollarColorableCollar extends EntityExpression<CollarColorable, Color> {

static {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
@Examples({
"set {_parent} to complex parent of {_child::1}"
})
@Since("2.9")
@Since("2.8.1")
public class ExprComplexEntityPartParent extends EntityExpression<ComplexEntityPart, LivingEntity> {

static {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
@Examples({
"set {_child::*} to complex parts of {_parent}"
})
@Since("2.9")
@Since("2.8.1")
public class ExprComplexLivingEntityParts extends PropertyExpression<Entity, Entity> {

static {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
@Examples({
"send school leader of {_fish}"
})
@Since("2.9")
@Since("2.8.1")
public class ExprSchoolableFishLeader extends EntityExpression<SchoolableFish, Entity> {

static {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
@Examples({
"send max school size of {_fish}"
})
@Since("2.9")
@Since("2.8.1")
public class ExprSchoolableFishSize extends EntityExpression<SchoolableFish, Integer> {

static {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
@Examples({
"set tamed state of {_cat} to true"
})
@Since("2.9")
@Since("2.8.1")
public class ExprTameableTamed extends EntityExpression<Tameable, Boolean> {

static {
Expand Down
39 changes: 21 additions & 18 deletions src/main/java/lol/aabss/skuishy/elements/general/Functions.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package lol.aabss.skuishy.elements.general;

import ch.njol.skript.classes.ClassInfo;
import ch.njol.skript.lang.function.Parameter;
import ch.njol.skript.lang.function.SimpleJavaFunction;
import ch.njol.skript.registrations.Classes;
Expand All @@ -9,39 +10,41 @@

import static ch.njol.skript.lang.function.Functions.registerFunction;

@SuppressWarnings("NullableProblems")
public class Functions {

static {
Parameter<?>[] numbersParam = new Parameter[]{new Parameter<>("ns", DefaultClasses.NUMBER, false, null)};
Parameter<?>[] numbersParam = new Parameter[]{new Parameter<>("numbers", DefaultClasses.NUMBER, false, null)};
registerFunction(new SimpleJavaFunction<>("mean", numbersParam, DefaultClasses.NUMBER, true) {
@Override
public Number @NotNull [] executeSimple(Object[][] params) {
Object[] ns = params[0];
double sum = 0.0;
for (Object num : ns) {
sum += ((Number) num).doubleValue();
for (Number num : (Number[]) params[0]) {
sum += num.doubleValue();
}
double mean = sum / ns.length;
double mean = sum / params[0].length;
return new Number[]{mean};
}
}
.description("Calculates the mean of a list of numbers.")
.examples()
.since("1.7"));

registerFunction(new SimpleJavaFunction<>("eulerangle", new Parameter[]{
new Parameter<>("x", DefaultClasses.NUMBER, true, null),
new Parameter<>("y", DefaultClasses.NUMBER, true, null),
new Parameter<>("z", DefaultClasses.NUMBER, true, null)
}, Classes.getExactClassInfo(EulerAngle.class), true) {
@Override
public EulerAngle[] executeSimple(Object[][] params) {
if (params.length < 3) {
return null;
ClassInfo<EulerAngle> eulerAngleClassInfo = Classes.getExactClassInfo(EulerAngle.class);
if (eulerAngleClassInfo != null) {
registerFunction(new SimpleJavaFunction<>("eulerangle", new Parameter[]{
new Parameter<>("x", DefaultClasses.NUMBER, true, null),
new Parameter<>("y", DefaultClasses.NUMBER, true, null),
new Parameter<>("z", DefaultClasses.NUMBER, true, null)
}, eulerAngleClassInfo, true) {
@Override
public EulerAngle[] executeSimple(Object[][] params) {
if (params.length < 3) {
return null;
}
return new EulerAngle[]{new EulerAngle((Double) params[0][0], (Double) params[1][0], (Double) params[2][0])};
}
return new EulerAngle[]{new EulerAngle((Double) params[0][0], (Double) params[1][0], (Double) params[2][0])};
}
});
});
}

}
}
33 changes: 27 additions & 6 deletions src/main/java/lol/aabss/skuishy/elements/general/Types.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
import ch.njol.skript.lang.ParseContext;
import ch.njol.skript.registrations.Classes;
import io.papermc.paper.datapack.Datapack;
import io.papermc.paper.registry.RegistryAccess;
import io.papermc.paper.registry.RegistryKey;
import lol.aabss.skuishy.Skuishy;
import lol.aabss.skuishy.other.EnumWrapper;
import lol.aabss.skuishy.other.RegistryClassInfo;
import org.bukkit.Art;
import org.bukkit.Rotation;
import org.bukkit.Statistic;
Expand Down Expand Up @@ -77,12 +81,29 @@ public boolean canParse(@NotNull ParseContext context) {
}

if (Skript.classExists("org.bukkit.Art") && Classes.getExactClassInfo(Art.class) == null) {
Classes.registerClass(new EnumWrapper<>(Art.class).getClassInfo("art")
.user("arts?")
.name("Art")
.description("Represents a piece of art.")
.since("2.8")
);
ClassInfo<?> art_class_info = null;
if (Skript.classExists("io.papermc.paper.registry.RegistryKey") && Skript.fieldExists(RegistryKey.class, "PAINTING_VARIANT")) {
RegistryAccess registryAccess = RegistryAccess.registryAccess();
art_class_info = RegistryClassInfo.create(registryAccess.getRegistry(RegistryKey.PAINTING_VARIANT), Art.class, "art");
} else if (Art.class.isEnum()) {
try {
Class<?> art_class = Class.forName("org.bukkit.Art");
// noinspection unchecked,rawtypes
Class<? extends Enum> art_class_enum = (Class<? extends Enum>) art_class;
// noinspection unchecked,rawtypes
art_class_info = new EnumWrapper<>(art_class_enum).getClassInfo("art");
} catch (ClassNotFoundException exception) {
Skuishy.Logger.exception(exception);
}
}
if (art_class_info != null) {
Classes.registerClass(art_class_info
.user("arts?")
.name("Art")
.description("Represents a piece of art.")
.since("2.8")
);
}
}

if (Skript.classExists("org.bukkit.Rotation") && Classes.getExactClassInfo(Rotation.class) == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,15 @@
import ch.njol.skript.lang.Expression;
import ch.njol.skript.lang.ExpressionType;
import ch.njol.skript.lang.SkriptParser;
import ch.njol.skript.lang.UnparsedLiteral;
import ch.njol.skript.lang.util.SimpleExpression;
import ch.njol.skript.registrations.Classes;
import ch.njol.skript.util.LiteralUtils;
import ch.njol.util.Kleenean;
import lol.aabss.skuishy.other.Text;
import org.bukkit.event.Event;
import org.jetbrains.annotations.NotNull;

import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

@Name("Other - Tiny Text")
Expand All @@ -29,28 +27,37 @@
@Since("2.7")
public class ExprTinyText extends SimpleExpression<String> {

private static final List<String> normal_char_set = Arrays.stream("abcdefghijklmnopqrstuvwxyz".split("")).toList();
private static final List<String> tiny_char_set = Arrays.stream("ᴀʙᴄᴅᴇғɢʜɪᴊᴋʟᴍɴᴏᴘǫʀsᴛᴜᴠᴡxʏᴢ".split("")).toList();
private static final List<String> super_tiny_char_set = Arrays.stream("ᵃᵇᶜᵈᵉᶠᵍʰᶦʲᵏˡᵐⁿᵒᵖᵠʳˢᵗᵘᵛʷˣʸᶻ".split("")).toList();

static {
Skript.registerExpression(ExprTinyText.class, String.class, ExpressionType.COMBINED,
"[:super] tiny [(text|caps)] %objects%",
"%objects% in [:super] tiny (text|caps)"
"%objects% (in|as) [:super] tiny (text|caps)"
);
}

private Expression<Object> text;
private boolean superTiny;
private Expression<Object> objects;
private boolean isSuperTiny;

@Override
public boolean init(Expression<?>[] exprs, int i, @NotNull Kleenean kleenean, SkriptParser.ParseResult parseResult) {
objects = LiteralUtils.defendExpression(exprs[0]);
this.isSuperTiny = parseResult.hasTag("super");
return LiteralUtils.canInitSafely(objects);
}

@Override
protected String @NotNull [] get(@NotNull Event event) {
List<String> string = new ArrayList<>();
for (Object s : text.getArray(event)){
string.add(Text.tinyText(Classes.toString(s), superTiny));
}
return string.toArray(String[]::new);
return objects.stream(event)
.map(Classes::toString)
.map(this::tinyText).toArray(String[]::new);
}

@Override
public boolean isSingle() {
return text.isSingle();
return objects.isSingle();
}

@Override
Expand All @@ -59,17 +66,23 @@ public boolean isSingle() {
}

@Override
public @NotNull String toString(@Nullable Event event, boolean b) {
return "tiny text";
public @NotNull String toString(@Nullable Event event, boolean debug) {
return this.objects.toString(event, debug) + " as " + (isSuperTiny ? "super " : "") + "tiny text";
}

@Override
public boolean init(Expression<?>[] exprs, int i, @NotNull Kleenean kleenean, SkriptParser.ParseResult parseResult) {
text = (Expression<Object>) exprs[0];
if (text instanceof UnparsedLiteral) {
text = LiteralUtils.defendExpression(text);
public String tinyText(String string){
StringBuilder tinyText = new StringBuilder();
List<String> char_set = isSuperTiny ? super_tiny_char_set : tiny_char_set;
boolean isColorCode = false; // Preset the isColorCode to false
for (String str : string.split("")) {
int index = normal_char_set.indexOf(str);
if (!isColorCode && index != -1) { // Checks if string is not a color code and index was founds
str = char_set.get(index);
}
isColorCode = str.equals("§"); // Ensures the next loop uses a normal character
tinyText.append(str);
}
superTiny = parseResult.hasTag("super");
return LiteralUtils.canInitSafely(text);
return tinyText.toString();
}

}
Loading

0 comments on commit 9351d6a

Please sign in to comment.