-
-
Notifications
You must be signed in to change notification settings - Fork 399
EntityData Overhaul #7985
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
Open
Absolutionism
wants to merge
26
commits into
SkriptLang:dev/feature
Choose a base branch
from
Absolutionism:dev/EntityDataMultiLinedPatterns
base: dev/feature
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
EntityData Overhaul #7985
Changes from 20 commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
e63d99b
Initial Commit
Absolutionism 389dc5a
Additional Cleanup
Absolutionism 7145797
Update default.lang
Absolutionism 7439f0e
Initial Commit
Absolutionism b4e91d5
Merge branch 'dev/EntityDataParseTags' into dev/EntityDataMultiLinedP…
Absolutionism 5a43b48
Follow Up Commit
Absolutionism ad87cc1
Language Map Update
Absolutionism 123bf4d
EntityDataInfo and EnitityData Update
Absolutionism 001746f
Merge remote-tracking branch 'upstream/dev/feature' into dev/EntityDa…
Absolutionism 9be006a
Merge remote-tracking branch 'upstream/dev/feature' into dev/EntityDa…
Absolutionism 4a256d9
Overhaul
Absolutionism 3e9879e
Enum->Interface Fixes
Absolutionism 40e1d0c
Added states and test
Absolutionism 5af956a
Merge remote-tracking branch 'upstream/dev/feature' into dev/EntityDa…
Absolutionism 68f0144
Update EntityData.java
Absolutionism dc262e9
Update EntityData.sk
Absolutionism 8c2566d
Fix test
Absolutionism 0a947fc
Kleenean Changes
Absolutionism 3d4279e
Update EntityData.sk
Absolutionism c4a045a
Efy's Requested Changes
Absolutionism d6526c4
Efy's Requested Changes -2
Absolutionism 45721aa
Sovdes Requested Changes
Absolutionism 22e7165
FieldHandler
Absolutionism 0ea837c
Massive Fixes/Changes
Absolutionism 57e503d
Update EntityData.sk
Absolutionism 313c005
Merge remote-tracking branch 'upstream/dev/feature' into dev/EntityDa…
Absolutionism File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
89 changes: 89 additions & 0 deletions
89
src/main/java/ch/njol/skript/conditions/CondIsSpawnable.java
This file contains hidden or 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,89 @@ | ||
package ch.njol.skript.conditions; | ||
|
||
import ch.njol.skript.Skript; | ||
import ch.njol.skript.doc.Description; | ||
import ch.njol.skript.doc.Example; | ||
import ch.njol.skript.doc.Name; | ||
import ch.njol.skript.doc.Since; | ||
import ch.njol.skript.entity.EntityData; | ||
import ch.njol.skript.entity.EntityType; | ||
import ch.njol.skript.lang.Condition; | ||
import ch.njol.skript.lang.Expression; | ||
import ch.njol.skript.lang.SkriptParser.ParseResult; | ||
import ch.njol.skript.lang.SyntaxStringBuilder; | ||
import ch.njol.skript.lang.util.SimpleExpression; | ||
import ch.njol.util.Kleenean; | ||
import org.bukkit.Bukkit; | ||
import org.bukkit.World; | ||
import org.bukkit.event.Event; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
@Name("Is Spawnable") | ||
@Description(""" | ||
Whether an entity type can be spawned in a world. If no world is provided, will default to the first world. | ||
Any general types such as 'monster, mob, entity, living entity' etc. will never be spawnable. | ||
""") | ||
@Example(""" | ||
if a pig is spawnable: # true | ||
if a monster can be spawned: # false | ||
""") | ||
@Since("INSERT VERSION") | ||
public class CondIsSpawnable extends Condition { | ||
|
||
static { | ||
Skript.registerCondition(CondIsSpawnable.class, ConditionType.COMBINED, | ||
"%entitytypes% is spawnable [in [the [world]] %-world%]", | ||
"%entitytypes% can be spawned [in [the [world]] %-world%]", | ||
"%entitytypes% (isn't|is not) spawnable [in [the [world]] %-world%]", | ||
"%entitytypes% (can't|can not) be spawned [in [the [world]] %-world%]"); | ||
} | ||
|
||
private Expression<?> types; | ||
private @Nullable Expression<World> world = null; | ||
|
||
@Override | ||
public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed, ParseResult parseResult) { | ||
types = exprs[0]; | ||
if (exprs[1] != null) { | ||
//noinspection unchecked | ||
world = (Expression<World>) exprs[1]; | ||
} | ||
setNegated(matchedPattern >= 2); | ||
return true; | ||
} | ||
|
||
@Override | ||
public boolean check(Event event) { | ||
World world = null; | ||
if (this.world != null) { | ||
world = this.world.getSingle(event); | ||
} | ||
if (world == null) | ||
world = Bukkit.getWorlds().get(0); | ||
|
||
World finalWorld = world; | ||
return SimpleExpression.check(types.getArray(event), object -> { | ||
if (object instanceof EntityData<?> entityData) { | ||
return entityData.canSpawn(finalWorld); | ||
} else if (object instanceof EntityType entityType) { | ||
EntityData<?> entityData = entityType.data; | ||
if (entityData != null) | ||
return entityData.canSpawn(finalWorld); | ||
} | ||
return false; | ||
}, isNegated(), types.getAnd()); | ||
} | ||
|
||
@Override | ||
public String toString(@Nullable Event event, boolean debug) { | ||
SyntaxStringBuilder builder = new SyntaxStringBuilder(event, debug); | ||
builder.append(types, "is"); | ||
if (isNegated()) | ||
builder.append("not"); | ||
builder.append("spawnable"); | ||
if (world != null) | ||
builder.append("in", world); | ||
return builder.toString(); | ||
} | ||
|
||
} |
This file contains hidden or 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 hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.