-
-
Notifications
You must be signed in to change notification settings - Fork 454
Misc events #8801
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
AnOwlBe
wants to merge
15
commits into
SkriptLang:dev/feature
Choose a base branch
from
AnOwlBe:MiscEvents
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
Misc events #8801
Changes from 6 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
6343a4c
ScriptEvent
AnOwlBe d30e923
Attempt at fixing gradlew.bat
AnOwlBe d2e17db
skript related events
AnOwlBe 850f693
more events
AnOwlBe f1c78a8
Enchantment events + anvil event
AnOwlBe 6311cfb
some bugs found during testing
AnOwlBe cb6abb0
requested changes
AnOwlBe bbaf8dc
Update src/main/java/org/skriptlang/skript/bukkit/misc/elements/event…
AnOwlBe d5336c7
Update src/main/java/org/skriptlang/skript/bukkit/misc/elements/event…
AnOwlBe df4286d
some requested changes
AnOwlBe b421ad9
in worlds
AnOwlBe d96cfbc
Update src/main/java/org/skriptlang/skript/bukkit/misc/elements/event…
AnOwlBe 15743ea
Merge branch 'dev/feature' into MiscEvents
AnOwlBe e8cb24d
requested changes
AnOwlBe ee75889
forgot MiscEvents.java
AnOwlBe 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
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 was deleted.
Oops, something went wrong.
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
82 changes: 82 additions & 0 deletions
82
src/main/java/org/skriptlang/skript/bukkit/enchantments/elements/EnchantmentEvents.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,82 @@ | ||
| package org.skriptlang.skript.bukkit.enchantments.elements; | ||
|
|
||
| import ch.njol.skript.lang.util.SimpleEvent; | ||
| import ch.njol.skript.util.EnchantmentType; | ||
| import org.bukkit.block.Block; | ||
| import org.bukkit.entity.Player; | ||
| import org.bukkit.event.enchantment.EnchantItemEvent; | ||
| import org.bukkit.event.enchantment.PrepareItemEnchantEvent; | ||
| import org.bukkit.inventory.ItemStack; | ||
| import org.skriptlang.skript.bukkit.lang.eventvalue.EventValue; | ||
| import org.skriptlang.skript.bukkit.lang.eventvalue.EventValueRegistry; | ||
| import org.skriptlang.skript.bukkit.registration.BukkitSyntaxInfos; | ||
| import org.skriptlang.skript.registration.SyntaxRegistry; | ||
|
|
||
| public class EnchantmentEvents { | ||
|
|
||
| public static void register(SyntaxRegistry syntaxRegistry, EventValueRegistry eventValueRegistry) { | ||
| syntaxRegistry.register(BukkitSyntaxInfos.Event.KEY, BukkitSyntaxInfos.Event.builder(SimpleEvent.class, "Enchant Prepare") | ||
| .addEvent(PrepareItemEnchantEvent.class) | ||
| .addPatterns("[item] enchant prepare") | ||
| .addDescription(""" | ||
| Called when a player puts an item into enchantment table. | ||
| This event may be called multiple times. | ||
| See <a href='#ExprEnchantEventsEnchantItem'>enchant item expression</a> for how to get the enchant item. | ||
| """) | ||
| .addExample(""" | ||
| on item enchant prepare: | ||
| set enchant offer 1 to sharpness 1 | ||
| set the cost of enchantment offer 1 to 10 levels | ||
| """) | ||
| .addSince("2.5") | ||
| .supplier(() -> new SimpleEvent("item enchant prepare")) | ||
| .build()); | ||
|
|
||
| eventValueRegistry.register(EventValue.builder(PrepareItemEnchantEvent.class, Player.class) | ||
| .getter(PrepareItemEnchantEvent::getEnchanter) | ||
| .build()); | ||
|
|
||
| eventValueRegistry.register(EventValue.builder(PrepareItemEnchantEvent.class, ItemStack.class) | ||
| .getter(PrepareItemEnchantEvent::getItem) | ||
| .build()); | ||
|
|
||
| eventValueRegistry.register(EventValue.builder(PrepareItemEnchantEvent.class, Block.class) | ||
| .getter(PrepareItemEnchantEvent::getEnchantBlock) | ||
| .build()); | ||
|
AnOwlBe marked this conversation as resolved.
|
||
|
|
||
| syntaxRegistry.register(BukkitSyntaxInfos.Event.KEY, BukkitSyntaxInfos.Event.builder(SimpleEvent.class, "Item Enchant") | ||
| .addEvent(EnchantItemEvent.class) | ||
| .addPatterns("[item] enchant") | ||
| .addDescription(""" | ||
| Called when a player successfully enchants an item. | ||
| See <a href='#ExprEnchantEventsEnchantItem'>enchant item expression</a> for how to get the enchanted item. | ||
|
AnOwlBe marked this conversation as resolved.
Outdated
|
||
| """) | ||
| .addExample(""" | ||
| on enchant: | ||
| if the clicked button is 1: | ||
| set the applied enchantments to (sharpness 10 and unbreaking 10) | ||
| """) | ||
| .addSince("2.5") | ||
| .supplier(() -> new SimpleEvent("item enchant")) | ||
| .build()); | ||
|
|
||
| eventValueRegistry.register(EventValue.builder(EnchantItemEvent.class, Player.class) | ||
| .getter(EnchantItemEvent::getEnchanter) | ||
| .build()); | ||
|
|
||
| eventValueRegistry.register(EventValue.builder(EnchantItemEvent.class, ItemStack.class) | ||
| .getter(EnchantItemEvent::getItem) | ||
| .build()); | ||
|
|
||
| eventValueRegistry.register(EventValue.builder(EnchantItemEvent.class, EnchantmentType[].class) | ||
| .getter(event -> event.getEnchantsToAdd().entrySet().stream() | ||
| .map(entry -> new EnchantmentType(entry.getKey(), entry.getValue())) | ||
| .toArray(EnchantmentType[]::new)) | ||
| .build()); | ||
|
|
||
| eventValueRegistry.register(EventValue.builder(EnchantItemEvent.class, Block.class) | ||
| .getter(EnchantItemEvent::getEnchantBlock) | ||
| .build()); | ||
| } | ||
|
|
||
| } | ||
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.
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.