-
-
Notifications
You must be signed in to change notification settings - Fork 368
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
Add breeding #7110
Open
Efnilite
wants to merge
62
commits into
SkriptLang:dev/feature
Choose a base branch
from
Efnilite:breeding
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
Add breeding #7110
Changes from all commits
Commits
Show all changes
62 commits
Select commit
Hold shift + click to select a range
a437ca9
Update aliases I guess?
Fusezion 296a944
Revert "Update aliases I guess?"
Fusezion 2cdf76d
Adding Events
Fusezion 9b3afd9
Breeding Event Expressions
Fusezion 27e1392
More Breeding Related Syntax
Fusezion 07ced16
Pattern Fixes & Class Exist checks
Fusezion 6ab1dba
Test, Test, Test
Fusezion 0423ea7
Merge branch 'master' into enhancement/Breedable
Fusezion c6acbe9
:purple_heart: Formatting
Fusezion 243d402
Added Adult Syntax
Fusezion 8bcbffb
Apply suggestions from code review
Fusezion 50748f5
ExprLoveTime -> ExprLoveTicks
Fusezion 93059ae
Update ExprBreedingFamily.java
Fusezion 912a300
Update ExprExperience.java
Fusezion 09d1999
Added comment to CondIsAdult and EffMakeAdult
Fusezion daeb7bf
Merge branch 'master' into enhancement/Breedable
Fusezion c543ef2
Merge branch 'master' into enhancement/Breedable
TheLimeGlass 34d5453
Syntax description notes
Fusezion 0b894cc
Update ExprLoveTicks and SimpleEvents
Fusezion 0b10f7d
Fix ExprLoveTicks & Update Test
Fusezion 14b7962
LoveTicks -> LoveTime
Fusezion 4ab107e
Merge branch 'master' into enhancement/Breedable
Fusezion 442602a
Apply suggestions from code review
Fusezion babb7b1
Change CondIsAdult condition checks
Fusezion 60a0500
Apply requested code review changes
Fusezion a8deec7
Apply more requested changes
Fusezion f46a502
Merge branch 'enhancement/Breedable' of https://github.com/Fusezion/S…
Fusezion fcbe57a
Merge branch 'master' into enhancement/Breedable
Fusezion a5f894d
Merge branch 'master' into enhancement/Breedable
Fusezion 2556e3b
Merge branch 'SkriptLang:master' into enhancement/Breedable
Fusezion 47301ca
Merge branch 'dev/feature' into enhancement/Breedable
Fusezion abe6540
Merge branch 'dev/feature' into enhancement/Breedable
sovdeeth f6e2954
Merge branch 'dev/feature' into enhancement/Breedable
Fusezion 04d4e3a
Merge branch 'dev/feature' into enhancement/Breedable
Fusezion f14bc73
Merge branch 'dev/feature' into enhancement/Breedable
sovdeeth 485ac5f
Merge branch 'dev/feature' into enhancement/Breedable
sovdeeth 9d98120
update conds
Efnilite 29847db
update exprs
Efnilite 803c718
update effs
Efnilite fe00590
update event values
Efnilite 668dad6
Merge branch 'fork/Fusezion/enhancement/Breedable' into breeding
Efnilite 91b9ee1
update annot
Efnilite 5018770
update annotations
Efnilite 28c1ac3
update CondIsInLove
Efnilite f0a12da
renames
Efnilite 987ff80
updates
Efnilite 11dbd44
update tests
Efnilite 7715a65
oops
Efnilite 24e3c2b
fix
Efnilite 05e7627
grr
Efnilite 8b7106f
gahr
Efnilite d4be4e9
add breeding trigger event
Efnilite 06dd041
more
Efnilite 9ab4f4a
MORE
Efnilite 555c053
MORE!!!!
Efnilite fb105b4
MORE!!!!!!
Efnilite fd0baef
Merge branch 'dev/feature' into breeding
Efnilite d74ddc9
stupid copilot
Efnilite 4f4b5aa
Merge remote-tracking branch 'origin/breeding' into breeding
Efnilite d43733a
g
Efnilite eff120d
fixes
Efnilite 43d3769
agag
Efnilite 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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package ch.njol.skript.conditions; | ||
|
||
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; | ||
import org.bukkit.entity.Breedable; | ||
import org.bukkit.entity.LivingEntity; | ||
|
||
@Name("Can Age") | ||
@Description("Checks whether or not an entity will be able to age/grow up.") | ||
@Examples({ | ||
"on breeding:", | ||
"\tentity can't age", | ||
"\tbroadcast \"An immortal has been born!\" to player" | ||
}) | ||
@Since("INSERT VERSION") | ||
public class CondCanAge extends PropertyCondition<LivingEntity> { | ||
|
||
static { | ||
register(CondCanAge.class, PropertyType.CAN, "(age|grow (up|old[er]))", "livingentities"); | ||
} | ||
|
||
@Override | ||
public boolean check(LivingEntity entity) { | ||
return entity instanceof Breedable breedable && !breedable.getAgeLock(); | ||
} | ||
|
||
@Override | ||
protected String getPropertyName() { | ||
return "age"; | ||
} | ||
|
||
} |
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,36 @@ | ||
package ch.njol.skript.conditions; | ||
|
||
import ch.njol.skript.Skript; | ||
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; | ||
import org.bukkit.entity.Breedable; | ||
import org.bukkit.entity.LivingEntity; | ||
|
||
@Name("Can Breed") | ||
@Description("Checks whether or not a living entity can be bred.") | ||
@Examples({ | ||
"on right click on living entity:", | ||
"\tevent-entity can't breed", | ||
"\tsend \"Turns out %event-entity% is not breedable. Must be a Skript user!\" to player" | ||
}) | ||
@Since("INSERT VERSION") | ||
public class CondCanBreed extends PropertyCondition<LivingEntity> { | ||
|
||
static { | ||
register(CondCanBreed.class, PropertyType.CAN, "(breed|be bred)", "livingentities"); | ||
} | ||
|
||
@Override | ||
public boolean check(LivingEntity entity) { | ||
return entity instanceof Breedable breedable && breedable.canBreed(); | ||
} | ||
|
||
@Override | ||
protected String getPropertyName() { | ||
return "breed"; | ||
} | ||
|
||
} |
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,35 @@ | ||
package ch.njol.skript.conditions; | ||
|
||
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; | ||
import org.bukkit.entity.Ageable; | ||
import org.bukkit.entity.LivingEntity; | ||
|
||
@Name("Is Adult") | ||
@Description("Checks whether or not a living entity is an adult.") | ||
@Examples({ | ||
"on drink:", | ||
"\tevent-entity is not an adult", | ||
"\tkill event-entity" | ||
}) | ||
@Since("INSERT VERSION") | ||
public class CondIsAdult extends PropertyCondition<LivingEntity> { | ||
|
||
static { | ||
register(CondIsAdult.class, "[an] adult", "livingentities"); | ||
} | ||
|
||
@Override | ||
public boolean check(LivingEntity entity) { | ||
return entity instanceof Ageable ageable && ageable.isAdult(); | ||
} | ||
|
||
@Override | ||
protected String getPropertyName() { | ||
return "an adult"; | ||
} | ||
|
||
} |
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,36 @@ | ||
package ch.njol.skript.conditions; | ||
|
||
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; | ||
import org.bukkit.entity.Ageable; | ||
import org.bukkit.entity.LivingEntity; | ||
|
||
@Name("Is Baby") | ||
@Description("Checks whether or not a living entity is a baby.") | ||
@Examples({ | ||
"on drink:", | ||
"\tevent-entity is a baby", | ||
"\tkill event-entity" | ||
}) | ||
@Since("INSERT VERSION") | ||
public class CondIsBaby extends PropertyCondition<LivingEntity> { | ||
|
||
static { | ||
register(CondIsBaby.class, "a (child|baby)", "livingentities"); | ||
} | ||
|
||
@Override | ||
public boolean check(LivingEntity entity) { | ||
return entity instanceof Ageable ageable && !ageable.isAdult(); | ||
|
||
} | ||
|
||
@Override | ||
protected String getPropertyName() { | ||
return "a baby"; | ||
} | ||
|
||
} |
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,38 @@ | ||
package ch.njol.skript.conditions; | ||
|
||
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; | ||
import org.bukkit.entity.Animals; | ||
import org.bukkit.entity.LivingEntity; | ||
|
||
@Name("Is In Love") | ||
@Description("Checks whether or not a living entity is in love.") | ||
@Examples({ | ||
"on spawn of living entity:", | ||
"\tif entity is in love:", | ||
"broadcast \"That was quick!\"" | ||
}) | ||
@Since("INSERT VERSION") | ||
public class CondIsInLove extends PropertyCondition<LivingEntity> { | ||
|
||
static { | ||
register(CondIsInLove.class, "in lov(e|ing) [state|mode]", "livingentities"); | ||
} | ||
|
||
@Override | ||
public boolean check(LivingEntity entity) { | ||
if (entity instanceof Animals animals) | ||
return animals.isLoveMode(); | ||
|
||
return false; | ||
} | ||
|
||
@Override | ||
protected String getPropertyName() { | ||
return "in love"; | ||
} | ||
|
||
} |
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,63 @@ | ||
package ch.njol.skript.effects; | ||
|
||
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.Effect; | ||
import ch.njol.skript.lang.Expression; | ||
import ch.njol.skript.lang.SkriptParser.ParseResult; | ||
import ch.njol.util.Kleenean; | ||
import org.bukkit.entity.Breedable; | ||
import org.bukkit.entity.LivingEntity; | ||
import org.bukkit.event.Event; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
@Name("Allow Aging") | ||
@Description("Sets whether or not living entities will be able to age.") | ||
@Examples({ | ||
"on spawn of animal:", | ||
"\tallow aging of entity" | ||
}) | ||
@Since("INSERT VERSION") | ||
public class EffAllowAging extends Effect { | ||
|
||
static { | ||
Skript.registerEffect(EffAllowAging.class, | ||
"lock age of %livingentities%", | ||
"prevent aging of %livingentities%", | ||
"prevent %livingentities% from aging", | ||
"unlock age of %livingentities%", | ||
"allow aging of %livingentities%", | ||
"allow %livingentities% to age"); | ||
} | ||
|
||
private boolean unlock; | ||
private Expression<LivingEntity> entities; | ||
|
||
@Override | ||
public boolean init(Expression<?>[] expressions, int matchedPattern, | ||
Kleenean isDelayed, ParseResult parseResult) { | ||
//noinspection unchecked | ||
entities = (Expression<LivingEntity>) expressions[0]; | ||
unlock = matchedPattern > 2; | ||
return true; | ||
} | ||
|
||
@Override | ||
protected void execute(Event event) { | ||
for (LivingEntity livingEntity : entities.getArray(event)) { | ||
if (!(livingEntity instanceof Breedable breedable)) | ||
continue; | ||
|
||
breedable.setAgeLock(!unlock); | ||
} | ||
} | ||
|
||
@Override | ||
public String toString(@Nullable Event event, boolean debug) { | ||
return (unlock ? "allow" : "prevent") + " aging of " + entities.toString(event,debug); | ||
} | ||
|
||
} |
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,61 @@ | ||
package ch.njol.skript.effects; | ||
|
||
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.Effect; | ||
import ch.njol.skript.lang.Expression; | ||
import ch.njol.skript.lang.SkriptParser.ParseResult; | ||
import ch.njol.util.Kleenean; | ||
import org.bukkit.entity.Breedable; | ||
import org.bukkit.entity.LivingEntity; | ||
import org.bukkit.event.Event; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
@Name("Make Breedable") | ||
@Description("Sets whether or not entities will be able to breed. Only works on animals.") | ||
@Examples({ | ||
"on spawn of animal:", | ||
"\tmake entity unbreedable" | ||
}) | ||
@Since("INSERT VERSION") | ||
public class EffBreedable extends Effect { | ||
|
||
static { | ||
Skript.registerEffect(EffBreedable.class, | ||
"make %livingentities% breedable", | ||
"unsterilize %livingentities%", | ||
"make %livingentities% (not |non(-| )|un)breedable", | ||
"sterilize %livingentities%"); | ||
} | ||
|
||
private boolean sterilize; | ||
private Expression<LivingEntity> entities; | ||
|
||
@Override | ||
public boolean init(Expression<?>[] expressions, int matchedPattern, | ||
Kleenean isDelayed, ParseResult parseResult) { | ||
sterilize = matchedPattern > 1; | ||
//noinspection unchecked | ||
entities = (Expression<LivingEntity>) expressions[0]; | ||
return true; | ||
} | ||
|
||
@Override | ||
protected void execute(Event event) { | ||
for (LivingEntity entity : entities.getArray(event)) { | ||
if (!(entity instanceof Breedable breedable)) | ||
continue; | ||
|
||
breedable.setBreed(!sterilize); | ||
} | ||
} | ||
|
||
@Override | ||
public String toString(@Nullable Event event, boolean debug) { | ||
return "make " + entities.toString(event, debug) + (sterilize ? " non-" : " ") + "breedable"; | ||
} | ||
|
||
} |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💀