-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
247b9c3
commit 15966d8
Showing
27 changed files
with
140 additions
and
200 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
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
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
38 changes: 9 additions & 29 deletions
38
src/main/java/io/github/apickledwalrus/skriptgui/elements/conditions/CondHasGUI.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 |
---|---|---|
@@ -1,57 +1,37 @@ | ||
package io.github.apickledwalrus.skriptgui.elements.conditions; | ||
|
||
import ch.njol.skript.conditions.base.PropertyCondition; | ||
import org.bukkit.entity.Player; | ||
import org.bukkit.event.Event; | ||
|
||
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 io.github.apickledwalrus.skriptgui.SkriptGUI; | ||
import org.eclipse.jdt.annotation.Nullable; | ||
|
||
@Name("Has GUI") | ||
@Description("Checks whether the given player(s) has/have a GUI open.") | ||
@Description("Checks whether a player has a GUI open.") | ||
@Examples({ | ||
"command /guiviewers: # Returns a list of all players with a GUI open.", | ||
"command /guiviewers: # Prints a list of all players with a GUI open.", | ||
"\tset {_viewers::*} to all players where [input has a gui]", | ||
"\tsend \"GUI Viewers: %{_viewers::*}%\" to player" | ||
}) | ||
@Since("1.0.0") | ||
public class CondHasGUI extends Condition { | ||
public class CondHasGUI extends PropertyCondition<Player> { | ||
|
||
static { | ||
Skript.registerCondition(CondHasGUI.class, | ||
"%players% (has|have) a gui [open]", | ||
"%players% (doesn't|does not|do not|don't) have a gui [open]" | ||
); | ||
} | ||
|
||
@SuppressWarnings("NotNullFieldNotInitialized") | ||
private Expression<Player> players; | ||
|
||
@Override | ||
@SuppressWarnings("unchecked") | ||
public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean kleenean, ParseResult parseResult) { | ||
players = (Expression<Player>) exprs[0]; | ||
setNegated(matchedPattern == 1); | ||
return true; | ||
register(CondHasGUI.class, PropertyType.HAVE, "a gui [open]", "players"); | ||
} | ||
|
||
@Override | ||
public boolean check(Event e) { | ||
return players.check(e, p -> SkriptGUI.getGUIManager().hasGUI(p), isNegated()); | ||
public boolean check(Player player) { | ||
return SkriptGUI.getGUIManager().hasGUI(player); | ||
} | ||
|
||
@Override | ||
public String toString(@Nullable Event e, boolean debug) { | ||
return players.toString(e, debug) + (!isNegated() ? " has/have " : " do not/don't have ") + " a gui open"; | ||
protected String getPropertyName() { | ||
return "a gui open"; | ||
} | ||
|
||
} |
5 changes: 0 additions & 5 deletions
5
src/main/java/io/github/apickledwalrus/skriptgui/elements/conditions/package-info.java
This file was deleted.
Oops, something went wrong.
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
5 changes: 0 additions & 5 deletions
5
src/main/java/io/github/apickledwalrus/skriptgui/elements/effects/package-info.java
This file was deleted.
Oops, something went wrong.
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
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
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
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
Oops, something went wrong.