Skip to content

Commit

Permalink
fixes #55
Browse files Browse the repository at this point in the history
  • Loading branch information
lMartin3 committed Apr 2, 2023
1 parent d7d0d81 commit 5d019fa
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ plugins {
}

group 'dev.martinl'
version '4.1.0'
version '4.1.1'

tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@
import dev.martinl.bsbrewritten.manager.ShulkerOpenData;
import dev.martinl.bsbrewritten.util.MaterialUtil;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.inventory.*;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerTeleportEvent;
import org.bukkit.inventory.Inventory;
Expand Down Expand Up @@ -168,14 +170,25 @@ public void onClick(InventoryClickEvent e) {
* */
@EventHandler
public void onBlockPlace(BlockPlaceEvent e){
Player player = e.getPlayer();
cancelIfPlayerHasShulkerOpen(e.getPlayer(), e);
}


/*
* This should prevent players from
* */
@EventHandler
public void onItemFrameInteract(PlayerInteractEntityEvent e){
cancelIfPlayerHasShulkerOpen(e.getPlayer(), e);
}


private void cancelIfPlayerHasShulkerOpen(Player player, Cancellable cancellable) {
if (player.getOpenInventory().getType() != InventoryType.SHULKER_BOX)
return; //check if the open inventory is one from a shulker box
if (player.getOpenInventory().getTopInventory().getLocation() != null) return; //check if the shulker is a block
if (!instance.getShulkerManager().doesPlayerHaveShulkerOpen(player.getUniqueId()))
return; //check if the inventory belongs to BSB
e.setCancelled(true);
cancellable.setCancelled(true);
}

}
2 changes: 1 addition & 1 deletion src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: 'BetterShulkerBoxes'
version: 4.1.0
version: 4.1.1
main: dev.martinl.bsbrewritten.BSBRewritten
author: 'Rektb (lMartin3#1975)'
api-version: '1.13'
Expand Down

0 comments on commit 5d019fa

Please sign in to comment.