Skip to content

Commit

Permalink
Added Some Beacon Elements, fixed Lusk not working on Purpur
Browse files Browse the repository at this point in the history
  • Loading branch information
JakeGBLP committed Apr 20, 2023
1 parent c5b909b commit cc05443
Show file tree
Hide file tree
Showing 6 changed files with 393 additions and 285 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jar.enabled = false


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

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

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

import ch.njol.skript.Skript;
import ch.njol.skript.doc.Description;
import ch.njol.skript.doc.Examples;
import ch.njol.skript.doc.Name;
import ch.njol.skript.doc.Since;
import ch.njol.skript.lang.Condition;
import ch.njol.skript.lang.Expression;
import ch.njol.skript.lang.SkriptParser.ParseResult;
import ch.njol.util.Kleenean;
import com.destroystokyo.paper.event.block.BeaconEffectEvent;
import org.bukkit.event.Event;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

@Name("Beacon - Applied Effect is Primary Effect")
@Description("Checks if the applied effect in the Beacon Effect Applied Event is the primary effect.")
@Examples({"on beacon effect apply:\n\tif the applied effect is the primary effect:\n\t\tbroadcast \"the primary effect has been applied!\""})
@Since("1.0.3")
public class CondBeaconAppliedEffectPrimary extends Condition {
static {
Skript.registerCondition(CondBeaconAppliedEffectPrimary.class, "[the] applied [beacon] effect is [the] primary [beacon] effect",
"[the] applied [beacon] effect is(n't| not) [the] primary [beacon] effect",
"[the] applied [beacon] effect is [the] secondary [beacon] effect",
"[the] applied [beacon] effect is(n't| not) [the] secondary [beacon] effect");
}

@Override
public boolean init(Expression<?> @NotNull [] expressions, int matchedPattern, @NotNull Kleenean isDelayed, @NotNull ParseResult parser) {
if (!getParser().isCurrentEvent(BeaconEffectEvent.class)) {
Skript.error("This condition can only be used in Beacon Effect Applied Event.");
return false;
}
setNegated(matchedPattern == 1 || matchedPattern == 2);
return true;
}

@Override
public @NotNull String toString(@Nullable Event event, boolean debug) {
return "the applied beacon effect is" + (isNegated() ? " not" : "") + " the primary beacon effect";
}

@Override
public boolean check(@NotNull Event event) {
if (event instanceof BeaconEffectEvent beaconEffectEvent) {
return isNegated() ^ beaconEffectEvent.isPrimary();
}
return false;
}
}

0 comments on commit cc05443

Please sign in to comment.