Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added gamemode to CondIsInvulnerable.java #6741

Open
wants to merge 22 commits into
base: dev/feature
Choose a base branch
from
Open
Changes from 9 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
381f603
Added gamemode to CondIsInvulnerable.java
JakeGBLP May 28, 2024
af88166
Update src/main/java/ch/njol/skript/conditions/CondIsInvulnerable.java
JakeGBLP May 28, 2024
bf180a9
Update src/main/java/ch/njol/skript/conditions/CondIsInvulnerable.java
JakeGBLP May 28, 2024
fb7734a
Update src/main/java/ch/njol/skript/conditions/CondIsInvulnerable.java
JakeGBLP May 28, 2024
aebbe7f
Update src/main/java/ch/njol/skript/conditions/CondIsInvulnerable.java
JakeGBLP May 28, 2024
f0e5263
Added methodExists check
JakeGBLP May 28, 2024
b022a6e
checks if the method for gamemodes exists when registering the condit…
JakeGBLP May 28, 2024
70c11c0
Merge branch 'dev/feature' into vulnerable
sovdeeth May 28, 2024
70ff527
all gamemodes over variable in example
JakeGBLP Jun 2, 2024
826f0d6
tests
JakeGBLP Jun 8, 2024
57210b3
Merge remote-tracking branch 'origin/vulnerable' into vulnerable
JakeGBLP Jun 8, 2024
5d9bb0b
Refactor + space
JakeGBLP Jun 8, 2024
96bee73
Update src/test/skript/tests/syntaxes/conditions/CondIsInvulnerable.sk
JakeGBLP Jun 9, 2024
02dbc1e
updated test
JakeGBLP Jun 9, 2024
ad8dfdd
Merge remote-tracking branch 'origin/vulnerable' into vulnerable
JakeGBLP Jun 9, 2024
dc9ed34
updated test
JakeGBLP Jun 9, 2024
9b47ba9
Update src/test/skript/tests/syntaxes/conditions/CondIsInvulnerable.sk
JakeGBLP Aug 15, 2024
befa150
Update src/test/skript/tests/syntaxes/conditions/CondIsInvulnerable.sk
JakeGBLP Aug 17, 2024
13a77b1
Merge branch 'dev/feature' into vulnerable
sovdeeth Sep 22, 2024
3d9554e
Update CondIsInvulnerable.sk
JakeGBLP Sep 22, 2024
8f4b834
Update CondIsInvulnerable.sk
JakeGBLP Sep 27, 2024
672579a
Merge branch 'dev/feature' into vulnerable
UnderscoreTud Sep 27, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 24 additions & 11 deletions src/main/java/ch/njol/skript/conditions/CondIsInvulnerable.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,40 @@
*/
package ch.njol.skript.conditions;

import ch.njol.skript.Skript;
import ch.njol.skript.doc.*;
import org.bukkit.GameEvent;
import org.bukkit.GameMode;
import org.bukkit.entity.Entity;

import ch.njol.skript.conditions.base.PropertyCondition;
import ch.njol.skript.doc.Description;
import ch.njol.skript.doc.Examples;
import ch.njol.skript.doc.Name;
import ch.njol.skript.doc.Since;

@Name("Is Invulnerable")
@Description("Checks whether an entity is invulnerable.")
@Examples("target entity is invulnerable")
@Since("2.5")
public class CondIsInvulnerable extends PropertyCondition<Entity> {
@Description("Checks whether an entity or a gamemode is invulnerable.\nFor gamemodes, Paper and Minecraft 1.20.6 are required")
@Examples({
"target entity is invulnerable",
"",
"loop all gamemodes:",
"\tif loop-value is not invulnerable:",
"\t\tbroadcast \"the gamemode %loop-value% is vulnerable!\""
})
@Since("2.5, INSERT VERSION (gamemode)")
@RequiredPlugins("Paper 1.20.6+ (gamemodes)")
public class CondIsInvulnerable extends PropertyCondition<Object> {
private static final boolean GAMEMODE = Skript.methodExists(GameMode.class,"isInvulnerable");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing a space after the comma

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we also name this SUPPORTS_GAMEMODE or something besides just gamemode


static {
register(CondIsInvulnerable.class, PropertyType.BE, "(invulnerable|invincible)", "entities");
register(CondIsInvulnerable.class, PropertyType.BE, "(invulnerable|invincible)", "entities" + (GAMEMODE ? "/gamemodes" : ""));
}

@Override
public boolean check(Entity entity) {
return entity.isInvulnerable();
public boolean check(Object object) {
if (object instanceof Entity) {
return ((Entity) object).isInvulnerable();
} else if (GAMEMODE && object instanceof GameMode) {
return ((GameMode) object).isInvulnerable();
}
return false;
}

@Override
Expand Down