Skip to content

Commit

Permalink
Removed Decimal Round, Added Raised Hand Time Expressions, replaced V…
Browse files Browse the repository at this point in the history
…ersion.java with a library, Removed useless comments.

General Cleanup.

Preparing for 1.0.3
  • Loading branch information
JakeGBLP committed Apr 21, 2023
1 parent 7a6ce7c commit 9e745ec
Show file tree
Hide file tree
Showing 39 changed files with 355 additions and 433 deletions.
6 changes: 4 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ build.dependsOn(shadowJar)
jar.enabled = false


group = 'Lusk'
version = '1.0.3-beta1'
group = "Lusk"
version = "1.0.3"

compileJava {options.encoding = "UTF-8"}

Expand All @@ -35,6 +35,8 @@ dependencies {
compileOnly 'io.papermc.paper:paper-api:1.19.4-R0.1-SNAPSHOT'
compileOnly 'com.github.SkriptLang:Skript:2.6.3'
implementation 'org.bstats:bstats-bukkit:3.0.1'
implementation "com.vdurmont:semver4j:3.1.0"


}
shadowJar {
Expand Down
117 changes: 0 additions & 117 deletions src/main/java/me/jake/lusk/classes/Version.java

This file was deleted.

14 changes: 4 additions & 10 deletions src/main/java/me/jake/lusk/elements/classes/AddonComparators.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,16 @@

import ch.njol.skript.classes.Comparator;
import ch.njol.skript.registrations.Comparators;
import me.jake.lusk.classes.Version;
import com.vdurmont.semver4j.Semver;
import org.jetbrains.annotations.NotNull;

public class AddonComparators {
public AddonComparators() {}

static {
// 1.0.0

// Custom

// Version
Comparators.registerComparator(Version.class, Version.class, new Comparator<>() {
Comparators.registerComparator(Semver.class, Semver.class, new Comparator<>() {
@Override
public @NotNull Relation compare(Version v1, Version v2) {
return v1.isNewerThan(v2) ? Relation.GREATER : v2.isNewerThan(v1) ? Relation.SMALLER : Relation.EQUAL;
public @NotNull Relation compare(Semver v1, Semver v2) {
return v1.isGreaterThan(v2) ? Relation.GREATER : v2.isGreaterThan(v1) ? Relation.SMALLER : Relation.EQUAL;
}

@Override
Expand Down
24 changes: 9 additions & 15 deletions src/main/java/me/jake/lusk/elements/classes/Types.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import ch.njol.skript.lang.ParseContext;
import ch.njol.skript.registrations.Classes;
import com.destroystokyo.paper.event.entity.EndermanEscapeEvent.Reason;
import me.jake.lusk.classes.Version;
import com.vdurmont.semver4j.Semver;
import org.bukkit.block.banner.PatternType;
import org.bukkit.entity.EnderDragon;
import org.bukkit.entity.Pose;
Expand All @@ -22,8 +22,6 @@

public class Types {
static {

// 1.0.0
Classes.registerClass(new ClassInfo<>(EquipmentSlot.class, "equipmentslot")
.user("equipment ?slots?")
.name("Equipment Slot")
Expand Down Expand Up @@ -80,7 +78,6 @@ public PatternType parse(final @NotNull String s, final @NotNull ParseContext co
}
})
.serializer(new EnumSerializer<>(PatternType.class)));
// Paper
if (Skript.classExists("com.destroystokyo.paper.event.entity.EndermanEscapeEvent.Reason")) {
Classes.registerClass(new ClassInfo<>(Reason.class, "endermanescapereason")
.user("ender ?man ?escape ?reasons?")
Expand Down Expand Up @@ -111,42 +108,39 @@ public Reason parse(final @NotNull String s, final @NotNull ParseContext context
})
.serializer(new EnumSerializer<>(Reason.class)));
}
// Custom
Classes.registerClass(new ClassInfo<>(Version.class, "version")
Classes.registerClass(new ClassInfo<>(Semver.class, "version")
.user("versions?")
.name("Version")
.description("A Minecraft Version")
.usage("")
.examples("")
.since("1.0.0")
.parser(new Parser<Version>() {
.parser(new Parser<Semver>() {
@Override
@Nullable
public Version parse(final @NotNull String s, final @NotNull ParseContext context) {
return Version.parse(s);
public @NotNull Semver parse(final @NotNull String s, final @NotNull ParseContext context) {
return new Semver(s, Semver.SemverType.LOOSE);
}

@Override
public boolean canParse(final @NotNull ParseContext context) {
return true;
return false;
}

@Override
public @NotNull String toString(final Version v, final int flags) {
public @NotNull String toString(final Semver v, final int flags) {
return v.toString();
}

@Override
public @NotNull String toVariableNameString(final Version v) {
public @NotNull String toVariableNameString(final Semver v) {
return v.toString();
}

@Override
public @NotNull String getDebugMessage(final Version v) {
public @NotNull String getDebugMessage(final Semver v) {
return toString(v, 0) + " version (" + v + ")";
}
}));
// 1.0.2
Classes.registerClass(new ClassInfo<>(Pose.class, "pose")
.user("poses?")
.name("Pose")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ public boolean init(Expression<?> @NotNull [] expressions, int matchedPattern, @

@Override
public @NotNull String toString(@Nullable Event event, boolean debug) {
assert event != null;
return entityExpression.getSingle(event) + " can" + (isNegated() ? "'t" : "") + " be duplicated";
return (event != null ? entityExpression.getSingle(event) : "") + " can" + (isNegated() ? "'t" : "") + " be duplicated";
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,44 @@
import ch.njol.skript.lang.Expression;
import ch.njol.skript.lang.SkriptParser.ParseResult;
import ch.njol.util.Kleenean;
import me.jake.lusk.utils.Utils;
import org.bukkit.Bukkit;
import org.bukkit.event.Event;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

@Name("Sever allows Nether/End")
@Name("Nether/End - is Allowed")
@Description("Checks if the server allows the Nether or the End")
@Examples({"if the server does not allow the end:\n\tbroadcast \"No End here!\""})
@Since("1.0.0")
@Since("1.0.0, 1.0.3 (is Allowed)")
public class CondAllowsDimension extends Condition {
static {
Skript.registerCondition(CondAllowsDimension.class, "[the] server allows [the] (:nether|end)", "[the] server does(n'| no)t allow [the] (:nether|end)");
Skript.registerCondition(CondAllowsDimension.class,
"[the] server allows [the] end",
"[the] server allows [the] nether",
"[the] server does(n'| no)t allow [the] end",
"[the] server does(n'| no)t allow [the] nether",
"[the] end is allowed",
"[the] nether is allowed",
"[the] end is(n't| not) allowed",
"[the] nether is(n't| not) allowed");
}

private boolean nether;

@Override
public boolean init(Expression<?> @NotNull [] expressions, int matchedPattern, @NotNull Kleenean isDelayed, @NotNull ParseResult parser) {
nether = parser.hasTag("nether");
setNegated(matchedPattern == 1);
nether = !Utils.isEven(matchedPattern);
setNegated(switch (matchedPattern) {
case 2,3,6,7 -> true;
default -> false;
});
return true;
}

@Override
public @NotNull String toString(@Nullable Event event, boolean debug) {
return "the server " + (isNegated() ? "does not allow" : "allows") + " the " + (nether ? "nether" : "end");
return "the " + (nether ? "nether" : "end") + " is" + (isNegated() ? " not" : "") + " allowed";
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package me.jake.lusk.elements.conditions;

import ch.njol.skript.Skript;
import ch.njol.skript.conditions.base.PropertyCondition;
import ch.njol.skript.doc.Description;
import ch.njol.skript.doc.Examples;
Expand All @@ -26,8 +25,6 @@ public boolean check(LivingEntity entity) {
return fox.isInterested();
} else if (entity instanceof Wolf wolf) {
return wolf.isInterested();
} else {
Skript.error("You can only use this condition with Foxes and Wolves!");
}
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,7 @@ public class CondAnimalSat extends PropertyCondition<LivingEntity> {

@Override
public boolean check(LivingEntity entity) {
if (entity != null) {
if (entity instanceof Sittable sittable) {
return sittable.isSitting();
}
}
if (entity instanceof Sittable sittable) return sittable.isSitting();
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import org.bukkit.entity.LivingEntity;
import org.jetbrains.annotations.NotNull;

@Name("Living Entity - is Awake")
@Name("Entity - is Awake")
@Description("Checks the current waking state of a living entity.")
@Examples({"on damage of bat:\n\tcancel event if victim is not awake"})
@Since("1.0.0")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import ch.njol.skript.lang.SkriptParser.ParseResult;
import ch.njol.util.Kleenean;
import com.destroystokyo.paper.event.player.PlayerPostRespawnEvent;
import me.jake.lusk.classes.Version;
import com.vdurmont.semver4j.Semver;
import me.jake.lusk.utils.Utils;
import org.bukkit.event.Event;
import org.jetbrains.annotations.NotNull;
Expand All @@ -29,7 +29,7 @@
public class CondBedRespawn extends Condition {

static {
if (!Utils.getSkriptVersion().isNewerThan(new Version(2, 6, 4))) {
if (Utils.getSkriptVersion().isLowerThanOrEqualTo(new Semver("2.6.4"))) {
if (Skript.classExists("com.destroystokyo.paper.event.player.PlayerPostRespawnEvent")) {
Skript.registerCondition(CondBedRespawn.class, "[the] player will respawn at [their] bed",
"[the] player w(on't|ill not) respawn at [their] bed");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,13 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.Objects;

@Name("Boolean")
@Description("Returns if the given object is true or false.")
@Examples({"if {isJailed::%uuid of player%}:\n\tbroadcast \"%player% is Jailed!\""})
@Since("1.0.0")
@Since("1.0.0, 1.0.3 (not)")
public class CondBoolean extends Condition {
static {
Skript.registerCondition(CondBoolean.class, "%boolean%", "!%boolean%");
Skript.registerCondition(CondBoolean.class, "%boolean%", "(!|not )%boolean%");
}

private Expression<Boolean> bool;
Expand All @@ -36,8 +34,7 @@ public boolean init(Expression<?> @NotNull [] expressions, int matchedPattern, @

@Override
public @NotNull String toString(@Nullable Event event, boolean debug) {
assert event != null;
return (isNegated() ? "!" : "") + Objects.requireNonNull(bool.getSingle(event));
return (isNegated() ? "!" : "") + (event == null ? "" : bool.getSingle(event));
}

@Override
Expand Down

0 comments on commit 9e745ec

Please sign in to comment.