mirror of
https://github.com/GeorgH93/Minepacks.git
synced 2024-11-14 10:45:23 +01:00
Update API
This commit is contained in:
parent
16a658e739
commit
c4af733660
4
pom.xml
4
pom.xml
@ -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>
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user