Update API

This commit is contained in:
GeorgH93 2020-02-15 03:41:14 +01:00
parent 16a658e739
commit c4af733660
No known key found for this signature in database
GPG Key ID: D1630D37F9E4B3C8
2 changed files with 13 additions and 9 deletions

View File

@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>at.pcgamingfreaks</groupId>
<artifactId>Minepacks</artifactId>
<version>2.2-ALPHA2</version>
<version>2.2-BETA</version>
<scm>
<connection>scm:git:git@github.com:GeorgH93/Minepacks.git</connection>
@ -55,7 +55,7 @@
<dependency>
<groupId>at.pcgamingfreaks</groupId>
<artifactId>Minepacks-API</artifactId>
<version>2.0.11</version>
<version>2.2-SNAPSHOT</version>
<exclusions>
<exclusion>
<groupId>org.bukkit</groupId>

View File

@ -33,6 +33,7 @@
import org.bukkit.event.inventory.InventoryMoveItemEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Collection;
@ -112,6 +113,12 @@ public boolean isItemBlocked(final @Nullable ItemStack item)
return whitelistMode;
}
@Override
public void sendNotAllowedMessage(@NotNull Player player, @NotNull ItemStack itemStack)
{
messageNotAllowedInBackpack.send(player, itemNameResolver.getName(itemStack));
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onItemMove(InventoryMoveItemEvent event)
{
@ -119,7 +126,7 @@ public void onItemMove(InventoryMoveItemEvent event)
{
if(event.getSource().getHolder() instanceof Player)
{
messageNotAllowedInBackpack.send((Player) event.getSource().getHolder(), itemNameResolver.getName(event.getItem()));
sendNotAllowedMessage((Player) event.getSource().getHolder(), event.getItem());
}
event.setCancelled(true);
}
@ -132,23 +139,20 @@ public void onItemClick(InventoryClickEvent event)
if(event.getInventory().getHolder() instanceof Backpack)
{
Player player = (Player) event.getWhoClicked();
if(event.getAction() == InventoryAction.MOVE_TO_OTHER_INVENTORY && isItemBlocked(event.getCurrentItem()))
if(event.getAction() == InventoryAction.MOVE_TO_OTHER_INVENTORY && checkIsBlockedAndShowMessage(player, event.getCurrentItem()))
{
event.setCancelled(true);
messageNotAllowedInBackpack.send(event.getView().getPlayer(), itemNameResolver.getName(event.getCurrentItem()));
}
else if((event.getAction() == InventoryAction.HOTBAR_MOVE_AND_READD || event.getAction() == InventoryAction.HOTBAR_SWAP) && event.getHotbarButton() != -1)
{
ItemStack item = event.getWhoClicked().getInventory().getItem(event.getHotbarButton());
if(item != null && isItemBlocked(item))
if(checkIsBlockedAndShowMessage(player, item))
{
event.setCancelled(true);
messageNotAllowedInBackpack.send(event.getView().getPlayer(), itemNameResolver.getName(item));
}
}
else if(!player.getInventory().equals(event.getClickedInventory()) && isItemBlocked(event.getCursor()))
else if(!player.getInventory().equals(event.getClickedInventory()) && checkIsBlockedAndShowMessage(player, event.getCursor()))
{
messageNotAllowedInBackpack.send(event.getView().getPlayer(), itemNameResolver.getName(event.getCursor()));
event.setCancelled(true);
}
}