Skip to content

Commit

Permalink
Merge pull request #47 from Nookure/dev
Browse files Browse the repository at this point in the history
Fix chest oppening
  • Loading branch information
Angelillo15 authored Sep 10, 2023
2 parents 747aa6c + e49d3d2 commit 6acb06b
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 57 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/Javadoc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ name: JavaDoc Generator
on:
push:
branches: [ 2.x ]
pull_request:
branches: [ 2.x ]
jobs:

build-on-ubuntu:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- name: Seting up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 11
java-version: 17

- name: Setup Gradle
uses: gradle/gradle-build-action@v2
Expand Down
28 changes: 0 additions & 28 deletions .github/workflows/publish-api.yml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,39 +14,38 @@
import org.bukkit.inventory.Inventory;

public class OnOpenChest implements Listener {
@Inject
private StaffManager staffManager;
@Inject
private StaffManager staffManager;

@EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerInteract(PlayerInteractEvent event) {
Player player = event.getPlayer();
@EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerInteract(PlayerInteractEvent event) {
Player player = event.getPlayer();

if (!staffManager.isStaffPlayer(player)) {
return;
}

IStaffPlayer staffPlayer = staffManager.getStaffPlayer(player);

if (!staffPlayer.isStaffMode()) {
return;
}
if (!staffManager.isStaffPlayer(player)) {
return;
}

if (event.getClickedBlock() == null) {
return;
}
IStaffPlayer staffPlayer = staffManager.getStaffPlayer(player);

if (!event.getClickedBlock().getType().name().contains("CHEST")) {
return;
}
if (!staffPlayer.isStaffMode()) {
return;
}

Container container = (Container) event.getClickedBlock().getState();
if (event.getClickedBlock() == null) {
return;
}

if (container instanceof Chest chest) {
Inventory cInv = Bukkit.createInventory(null, chest.getInventory().getSize(), chest.getInventory().getType().name());
if (!event.getClickedBlock().getType().name().contains("CHEST")) {
return;
}

player.openInventory(cInv);
Container container = (Container) event.getClickedBlock().getState();

event.setCancelled(true);
}
if (container instanceof Chest chest) {
Inventory cInv = Bukkit.createInventory(null, chest.getInventory().getSize(), chest.getInventory().getType().name());
cInv.setContents(chest.getInventory().getContents());
player.openInventory(cInv);
event.setCancelled(true);
}
}
}

0 comments on commit 6acb06b

Please sign in to comment.