-
-
Notifications
You must be signed in to change notification settings - Fork 112
Trial Spawner and Vaults 1.21 additions #2790
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
MC-Samuel
wants to merge
4
commits into
DenizenScript:dev
Choose a base branch
from
MC-Samuel:trial-spawners-and-vaults
base: dev
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
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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
74 changes: 74 additions & 0 deletions
74
paper/src/main/java/com/denizenscript/denizen/paper/events/VaultChangeStateScriptEvent.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,74 @@ | ||
| package com.denizenscript.denizen.paper.events; | ||
|
|
||
| import com.denizenscript.denizen.events.BukkitScriptEvent; | ||
| import com.denizenscript.denizen.objects.LocationTag; | ||
| import com.denizenscript.denizen.utilities.implementation.BukkitScriptEntryData; | ||
| import com.denizenscript.denizencore.objects.ObjectTag; | ||
| import com.denizenscript.denizencore.objects.core.ElementTag; | ||
| import com.denizenscript.denizencore.scripts.ScriptEntryData; | ||
| import io.papermc.paper.event.block.VaultChangeStateEvent; | ||
| import org.bukkit.event.EventHandler; | ||
| import org.bukkit.event.Listener; | ||
|
|
||
| public class VaultChangeStateScriptEvent extends BukkitScriptEvent implements Listener { | ||
|
|
||
| // <--[event] | ||
| // @Events | ||
| // vault changes state | ||
| // | ||
| // @Plugin Paper | ||
| // | ||
| // @Group Block | ||
| // | ||
| // @Cancellable true | ||
| // | ||
| // @Location true | ||
| // | ||
| // @Triggers when a vault block's state changes. A list of states can be found at <@link url https://hub.spigotmc.org/javadocs/spigot/org/bukkit/block/data/type/TrialSpawner.State.html>. | ||
| // | ||
| // @Context | ||
| // <context.location> returns the LocationTag of the vault block. | ||
| // <context.old_state> returns the vault state before the change. | ||
| // <context.new_state> returns the vault state after the change. | ||
| // | ||
| // @Player when the entity who triggered the change is a player. | ||
| // | ||
| // --> | ||
|
|
||
| public VaultChangeStateScriptEvent() { | ||
| registerCouldMatcher("vault changes state"); | ||
| } | ||
|
|
||
| public LocationTag location; | ||
| public VaultChangeStateEvent event; | ||
|
|
||
| @Override | ||
| public boolean matches(ScriptPath path) { | ||
| if (!runInCheck(path, location)) { | ||
| return false; | ||
| } | ||
| return super.matches(path); | ||
| } | ||
|
|
||
| @Override | ||
| public ScriptEntryData getScriptEntryData() { | ||
| return new BukkitScriptEntryData(event.getPlayer()); | ||
| } | ||
|
|
||
| @Override | ||
| public ObjectTag getContext(String name) { | ||
| return switch (name) { | ||
| case "old_state" -> new ElementTag(event.getCurrentState()); | ||
| case "new_state" -> new ElementTag(event.getNewState()); | ||
| case "location" -> location; | ||
| default -> super.getContext(name); | ||
| }; | ||
| } | ||
|
|
||
| @EventHandler | ||
| public void onVaultChangeStateEvent(VaultChangeStateEvent event) { | ||
| location = new LocationTag(event.getBlock().getLocation()); | ||
| this.event = event; | ||
| fire(event); | ||
| } | ||
| } | ||
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
...in/src/main/java/com/denizenscript/denizen/events/block/BlockDispenseLootScriptEvent.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 com.denizenscript.denizen.events.block; | ||
|
|
||
| import com.denizenscript.denizen.events.BukkitScriptEvent; | ||
| import com.denizenscript.denizen.objects.*; | ||
| import com.denizenscript.denizen.utilities.implementation.BukkitScriptEntryData; | ||
| import com.denizenscript.denizencore.objects.ObjectTag; | ||
| import com.denizenscript.denizencore.objects.core.ListTag; | ||
| import com.denizenscript.denizencore.scripts.ScriptEntryData; | ||
| import org.bukkit.event.EventHandler; | ||
| import org.bukkit.event.Listener; | ||
| import org.bukkit.event.block.BlockDispenseLootEvent; | ||
| import org.bukkit.inventory.ItemStack; | ||
|
|
||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
|
|
||
| public class BlockDispenseLootScriptEvent extends BukkitScriptEvent implements Listener { | ||
|
|
||
| // <--[event] | ||
| // @Events | ||
| // loot dispenses from <block> | ||
| // | ||
| // @Group Block | ||
| // | ||
| // @Location true | ||
| // | ||
| // @Cancellable true | ||
| // | ||
| // @Player Always. | ||
| // | ||
| // @Triggers when a block dispenses loot containing multiple items. | ||
| // | ||
| // @Context | ||
| // <context.loot> returns a ListTag(ItemTag) of outcome items. | ||
| // <context.location> returns a LocationTag of the block that is dispensing the items. | ||
| // | ||
| // @Determine | ||
| // "LOOT:<ListTag(ItemTag)>" to determine the new items that are outputted. | ||
| // | ||
| // --> | ||
|
|
||
| public BlockDispenseLootScriptEvent() { | ||
| registerCouldMatcher("loot dispenses from <block>"); | ||
| this.<BlockDispenseLootScriptEvent, ListTag>registerDetermination("loot", ListTag.class, (evt, context, input) -> { | ||
| List<ItemStack> items = new ArrayList<>(input.size()); | ||
| for (ItemTag item : input.filter(ItemTag.class, context)) { | ||
| items.add(item.getItemStack()); | ||
| } | ||
| evt.event.setDispensedLoot(items); | ||
| }); | ||
| } | ||
|
|
||
| public MaterialTag block; | ||
| public LocationTag location; | ||
| public BlockDispenseLootEvent event; | ||
|
|
||
| @Override | ||
| public boolean matches(ScriptPath path) { | ||
| if (!path.tryArgObject(3, block)) { | ||
| return false; | ||
| } | ||
| if (!runInCheck(path, location)) { | ||
| return false; | ||
| } | ||
| return super.matches(path); | ||
| } | ||
|
|
||
| @Override | ||
| public ScriptEntryData getScriptEntryData() { | ||
| return new BukkitScriptEntryData(new PlayerTag(event.getPlayer()), null); | ||
| } | ||
|
|
||
| @Override | ||
| public ObjectTag getContext(String name) { | ||
| return switch (name) { | ||
| case "loot" -> new ListTag(event.getDispensedLoot(), ItemTag::new); | ||
| case "location" -> location; | ||
| default -> super.getContext(name); | ||
| }; | ||
| } | ||
|
|
||
| @EventHandler | ||
| public void onBlockLootDispense(BlockDispenseLootEvent event) { | ||
| block = new MaterialTag(event.getBlock().getType()); | ||
| location = new LocationTag(event.getBlock().getLocation()); | ||
| this.event = event; | ||
| fire(event); | ||
| } | ||
| } |
70 changes: 70 additions & 0 deletions
70
plugin/src/main/java/com/denizenscript/denizen/events/block/VaultDisplayItemScriptEvent.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,70 @@ | ||
| package com.denizenscript.denizen.events.block; | ||
|
|
||
| import com.denizenscript.denizen.events.BukkitScriptEvent; | ||
| import com.denizenscript.denizen.objects.ItemTag; | ||
| import com.denizenscript.denizen.objects.LocationTag; | ||
| import com.denizenscript.denizencore.objects.ObjectTag; | ||
| import org.bukkit.event.EventHandler; | ||
| import org.bukkit.event.Listener; | ||
| import org.bukkit.event.block.VaultDisplayItemEvent; | ||
|
|
||
| public class VaultDisplayItemScriptEvent extends BukkitScriptEvent implements Listener { | ||
|
|
||
| // <--[event] | ||
| // @Events | ||
| // vault displays <item> | ||
| // | ||
| // @Group Block | ||
| // | ||
| // @Location true | ||
| // | ||
| // @Cancellable true | ||
| // | ||
| // @Triggers when a vault block displays an item. | ||
| // | ||
| // @Context | ||
| // <context.location> returns the LocationTag of the vault block. | ||
| // <context.item> returns the ItemTag being displayed. | ||
| // | ||
| // @Determine | ||
| // ItemTag to set the item being displayed. | ||
| // | ||
| // --> | ||
|
|
||
| public VaultDisplayItemScriptEvent() { | ||
| registerCouldMatcher("vault displays <item>"); | ||
| this.<VaultDisplayItemScriptEvent, ItemTag>registerDetermination(null, ItemTag.class, (evt, context, input) -> { | ||
| evt.event.setDisplayItem(input.getItemStack()); | ||
| }); | ||
| } | ||
|
|
||
| public LocationTag location; | ||
| public VaultDisplayItemEvent event; | ||
|
|
||
| @Override | ||
| public boolean matches(ScriptPath path) { | ||
| if (!runInCheck(path, location)) { | ||
| return false; | ||
| } | ||
| if (!path.tryArgObject(2, new ItemTag(event.getDisplayItem()))) { | ||
| return false; | ||
| } | ||
| return super.matches(path); | ||
| } | ||
|
|
||
| @Override | ||
| public ObjectTag getContext(String name) { | ||
| return switch (name) { | ||
| case "item" -> new ItemTag(event.getDisplayItem()); | ||
| case "location" -> location; | ||
| default -> super.getContext(name); | ||
| }; | ||
| } | ||
|
|
||
| @EventHandler | ||
| public void onVaultDisplayItemEvent(VaultDisplayItemEvent event) { | ||
| location = new LocationTag(event.getBlock().getLocation()); | ||
| this.event = event; | ||
| fire(event); | ||
| } | ||
| } |
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.
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.
Needs some reference/link as to what the states are, maybe just one link in
Triggers(but can also be here if you prefer)