Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

name: build

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
cache: maven
- name: Build with Maven
run: mvn -B package --file pom.xml

- name: Upload a Build Artifact
uses: actions/upload-artifact@v4.6.0
with:
path: target/*.jar
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class PlayerDropItemListener implements Listener {
@EventHandler (ignoreCancelled = true)
public void onDrop(@NotNull PlayerDropItemEvent event) {
ItemStack it = event.getItemDrop().getItemStack();
if (!ShulkerUtils.isShulker(it)) return;
if (!ShulkerUtils.isShulker(it) || ShulkerUtils.getShulkerUUID(it) == null) return;

String name = ShulkerUtils.getShulkerName(it);
Shulkerbox shulkerbox = Shulkerboxes.getShulker(it, name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,6 @@

public class PlayerInteractListener implements Listener {

@EventHandler (ignoreCancelled = true)
public void onInteract(@NotNull PlayerInteractEvent event) {
if (event.getAction() == Action.PHYSICAL) return;
Shulkerbox shulkerbox;
if ((shulkerbox = ShulkerUtils.hasShulkerOpen(event.getPlayer())) == null) return;
shulkerbox.close();
}

@EventHandler (ignoreCancelled = true)
public void onInteractEntity(@NotNull PlayerInteractEntityEvent event) {
Shulkerbox shulkerbox;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,14 @@ public void onInteract(@NotNull PlayerInteractEvent event) {
event.getPlayer().closeInventory();
}

if (event.getAction() != Action.RIGHT_CLICK_AIR) return;
if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK) return;

final Player player = event.getPlayer();
if (openShulker(player, player.getInventory().getItemInMainHand())) event.setCancelled(true);

ItemStack potentialShulker = ShulkerUtils.getHeldShulker(player.getInventory());
if (ShulkerUtils.isShulker(potentialShulker))
if (openShulker(player, potentialShulker))
event.setCancelled(true);
}

@EventHandler (priority = EventPriority.LOW)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import org.bukkit.inventory.meta.BlockStateMeta;
import org.bukkit.inventory.meta.ItemMeta;
import org.jetbrains.annotations.NotNull;
Expand Down Expand Up @@ -69,6 +70,17 @@ public static boolean isShulker(@Nullable ItemStack it) {
return shulkers.contains(it.getType());
}

//returns shulker in main hand, if not found returns shulker in off hand
@Nullable
public static ItemStack getHeldShulker(PlayerInventory playerInventory) {
if (isShulker(playerInventory.getItemInMainHand()))
return playerInventory.getItemInMainHand();
else if (isShulker(playerInventory.getItemInOffHand()))
return playerInventory.getItemInOffHand();

return null;
}

public static boolean isAllowedInventoryType(@NotNull Inventory inventory) {
return inventories.contains(inventory.getType());
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

prefix: "&#CC00FF&lAxShulkers &7» "

# EXPERIEMENTAL (this option was well tested, however it is still less safe than the default system)
# EXPERIMENTAL (this option was well tested, however it is still less safe than the default system)
# this setting will remove the safety UUID from the shulkers after they are closed
# it relies on java WeakReference-s to protect you from dupes
# this also force disables 'enable-obfuscation'
Expand All @@ -27,7 +27,7 @@ enable-obfuscation: false
# note: this is not required for security, you can leave it on 0 to disable
open-cooldown-milliseconds: 0

# should the shulker open when it gets right clicked in the player's inventory?
# should the shulker open when it gets right-clicked in the player's inventory?
opening-from-inventory:
enabled: true
# should this also be possible in the player's ender chest?
Expand Down