-
Notifications
You must be signed in to change notification settings - Fork 569
Walshy/mc 1.21 bundles #4299
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
Intybyte
wants to merge
15
commits into
Slimefun:experimental
Choose a base branch
from
Intybyte:walshy/mc-1.21-bundles
base: experimental
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
Walshy/mc 1.21 bundles #4299
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
c84e876
Update to 1.21
WalshyDev b508e45
Add a temporary InventoryViewWrapper in tests. Refactor TestBackpackL…
md5sha256 00da02c
Wrap the inventory view after the backpack has been opened
md5sha256 6f02cae
Updates usages of CustomItemStack (#4253)
md5sha256 47092df
Remove EnumMap and EnumSet usages (#4258)
md5sha256 78992ff
bundles.json file
Intybyte f4e3c9c
Add Bundle tag to enum
Intybyte d74b812
Add backpack check
Intybyte 2409268
idk
Intybyte 68e1bf0
Merge branch 'refs/heads/experimental' into walshy/mc-1.21-bundles
Intybyte 42655d1
Fix BundlingListener
Intybyte f280478
Fix merge error
Intybyte d9e2194
Fix indentation
Intybyte 170af72
javadoc
Intybyte 3eb37e4
InventoryClickEvent bundling
Intybyte 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
64 changes: 64 additions & 0 deletions
64
...in/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BundlingListener.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,64 @@ | ||
package io.github.thebusybiscuit.slimefun4.implementation.listeners; | ||
|
||
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; | ||
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; | ||
import io.github.thebusybiscuit.slimefun4.implementation.items.backpacks.SlimefunBackpack; | ||
import io.github.thebusybiscuit.slimefun4.utils.tags.SlimefunTag; | ||
import org.bukkit.Material; | ||
import org.bukkit.event.EventHandler; | ||
import org.bukkit.event.Listener; | ||
import org.bukkit.event.inventory.InventoryClickEvent; | ||
import org.bukkit.inventory.ItemStack; | ||
|
||
import javax.annotation.Nonnull; | ||
|
||
public class BundlingListener implements Listener { | ||
public BundlingListener(@Nonnull Slimefun plugin) { | ||
plugin.getServer().getPluginManager().registerEvents(this, plugin); | ||
} | ||
|
||
@EventHandler(ignoreCancelled = true) | ||
public void onBundling(InventoryClickEvent event) { | ||
ItemStack cursor = event.getCursor(); | ||
ItemStack slot = event.getCurrentItem(); | ||
|
||
if (slot == null || cursor.isEmpty()) { | ||
return; | ||
} | ||
|
||
if (isBundle(cursor) && isBackpack(slot) || isBundle(slot) && isBackpack(cursor)) { | ||
event.setCancelled(true); | ||
} | ||
} | ||
|
||
@EventHandler(ignoreCancelled = true) | ||
public void onCreativeBundle(InventoryClickEvent event) { | ||
ItemStack cursor = event.getCursor(); | ||
ItemStack slot = event.getCurrentItem(); | ||
|
||
if (slot == null || cursor.isEmpty()) { | ||
return; | ||
} | ||
|
||
if (isBundle(cursor) && isBackpack(slot) || isBundle(slot) && isBackpack(cursor)) { | ||
event.setCancelled(true); | ||
} | ||
} | ||
|
||
private boolean isBundle(ItemStack stack) { | ||
return SlimefunTag.BUNDLES.isTagged(stack.getType()); | ||
} | ||
|
||
private boolean isBackpack(ItemStack stack) { | ||
if (stack.getType() != Material.PLAYER_HEAD) { | ||
return false; | ||
} | ||
|
||
SlimefunItem backpack = SlimefunItem.getByItem(stack); | ||
if (backpack == null) { | ||
return false; | ||
} | ||
|
||
return backpack instanceof SlimefunBackpack; | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
{ | ||
"values": [ | ||
{ | ||
"id": "minecraft:bundle", | ||
"required": false | ||
}, | ||
{ | ||
"id": "minecraft:white_bundle", | ||
"required": false | ||
}, | ||
{ | ||
"id": "minecraft:orange_bundle", | ||
"required": false | ||
}, | ||
{ | ||
"id": "minecraft:magenta_bundle", | ||
"required": false | ||
}, | ||
{ | ||
"id": "minecraft:light_blue_bundle", | ||
"required": false | ||
}, | ||
{ | ||
"id": "minecraft:yellow_bundle", | ||
"required": false | ||
}, | ||
{ | ||
"id": "minecraft:lime_bundle", | ||
"required": false | ||
}, | ||
{ | ||
"id": "minecraft:pink_bundle", | ||
"required": false | ||
}, | ||
{ | ||
"id": "minecraft:gray_bundle", | ||
"required": false | ||
}, | ||
{ | ||
"id": "minecraft:light_gray_bundle", | ||
"required": false | ||
}, | ||
{ | ||
"id": "minecraft:cyan_bundle", | ||
"required": false | ||
}, | ||
{ | ||
"id": "minecraft:purple_bundle", | ||
"required": false | ||
}, | ||
{ | ||
"id": "minecraft:blue_bundle", | ||
"required": false | ||
}, | ||
{ | ||
"id": "minecraft:brown_bundle", | ||
"required": false | ||
}, | ||
{ | ||
"id": "minecraft:green_bundle", | ||
"required": false | ||
}, | ||
{ | ||
"id": "minecraft:red_bundle", | ||
"required": false | ||
}, | ||
{ | ||
"id": "minecraft:black_bundle", | ||
"required": false | ||
} | ||
] | ||
} |
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.