-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Some Beacon Elements, fixed Lusk not working on Purpur
- Loading branch information
Showing
6 changed files
with
393 additions
and
285 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
src/main/java/me/jake/lusk/elements/conditions/CondBeaconAppliedEffectPrimary.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
Oops, something went wrong.