Fix error with Shulkerbox filter on MC 1.14

This commit is contained in:
GeorgH93 2019-06-21 21:26:27 +02:00
parent c730c18b05
commit 4b41901c38
No known key found for this signature in database
GPG Key ID: D1630D37F9E4B3C8
3 changed files with 13 additions and 20 deletions

View File

@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>at.pcgamingfreaks</groupId> <groupId>at.pcgamingfreaks</groupId>
<artifactId>Minepacks</artifactId> <artifactId>Minepacks</artifactId>
<version>2.0.5</version> <version>2.0.6</version>
<scm> <scm>
<connection>scm:git:git@github.com:GeorgH93/Minepacks.git</connection> <connection>scm:git:git@github.com:GeorgH93/Minepacks.git</connection>
@ -21,6 +21,7 @@
<name>Minepacks</name> <name>Minepacks</name>
<description>Minepacks is a backpack plugin with different backpack sizes, multi language support and SQLite and MySQL storage support.</description> <description>Minepacks is a backpack plugin with different backpack sizes, multi language support and SQLite and MySQL storage support.</description>
<url>https://www.spigotmc.org/resources/19286/</url>
<inceptionYear>2014</inceptionYear> <inceptionYear>2014</inceptionYear>
<licenses> <licenses>
<license> <license>
@ -31,7 +32,6 @@
</licenses> </licenses>
<properties> <properties>
<author>GeorgH93</author> <author>GeorgH93</author>
<website>https://www.spigotmc.org/resources/19286/</website>
<version>${project.version}</version> <version>${project.version}</version>
<dependencies>depend: [ PCGF_PluginLib ]</dependencies> <dependencies>depend: [ PCGF_PluginLib ]</dependencies>
<mainClass>${project.groupId}.${project.artifactId}.Bukkit.${project.artifactId}</mainClass> <mainClass>${project.groupId}.${project.artifactId}.Bukkit.${project.artifactId}</mainClass>
@ -235,7 +235,6 @@
<artifact>at.pcgamingfreaks:PluginLib</artifact> <artifact>at.pcgamingfreaks:PluginLib</artifact>
<excludes> <excludes>
<exclude>*.yml</exclude> <exclude>*.yml</exclude>
<exclude>META-INF/*.txt</exclude>
</excludes> </excludes>
</filter> </filter>
</filters> </filters>

View File

@ -1,6 +1,6 @@
name: "${project.name}" name: "${project.name}"
author: "${author}" author: "${author}"
website: "${website}" website: "${project.url}"
main: "${mainClass}" main: "${mainClass}"
description: "${project.description}" description: "${project.description}"
version: "${version}" version: "${version}"

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2016-2018 GeorgH93 * Copyright (C) 2019 GeorgH93
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -102,13 +102,11 @@ public void onInventoryClick(InventoryClickEvent event)
@EventHandler(ignoreCancelled = true) @EventHandler(ignoreCancelled = true)
public void onInventoryOpen(InventoryOpenEvent event) public void onInventoryOpen(InventoryOpenEvent event)
{ {
if(event.getInventory() != null && event.getInventory().getHolder() != null && event.getInventory().getHolder().getClass().getName().toLowerCase().contains("shulker")) if(event.getInventory().getHolder() != null && event.getInventory().getHolder().getClass().getName().toLowerCase().contains("shulker"))
{ {
if(removeExisting) if(removeExisting)
{ {
Block shulkerBlock = ((ShulkerBox) event.getInventory().getHolder()).getBlock(); Block shulkerBlock = ((ShulkerBox) event.getInventory().getHolder()).getBlock();
if(shulkerBlock != null)
{
if(dropExistingContent) if(dropExistingContent)
{ {
Utils.dropInventory(event.getInventory(), shulkerBlock.getLocation()); Utils.dropInventory(event.getInventory(), shulkerBlock.getLocation());
@ -116,7 +114,6 @@ public void onInventoryOpen(InventoryOpenEvent event)
event.getInventory().clear(); event.getInventory().clear();
shulkerBlock.setType(Material.AIR); shulkerBlock.setType(Material.AIR);
} }
}
event.setCancelled(true); event.setCancelled(true);
} }
} }
@ -200,13 +197,10 @@ private boolean handleShulkerBlock(Block block)
if(removeExisting) if(removeExisting)
{ {
ShulkerBox shulkerBox = (ShulkerBox) block.getState(); ShulkerBox shulkerBox = (ShulkerBox) block.getState();
if(shulkerBox != null)
{
if(dropExistingContent) Utils.dropInventory(shulkerBox.getInventory(), shulkerBox.getLocation()); if(dropExistingContent) Utils.dropInventory(shulkerBox.getInventory(), shulkerBox.getLocation());
shulkerBox.getInventory().clear(); shulkerBox.getInventory().clear();
block.setType(Material.AIR); block.setType(Material.AIR);
} }
}
return true; return true;
} }
return false; return false;
@ -242,6 +236,7 @@ public void onBlockDispense(BlockDispenseEvent event)
@EventHandler(ignoreCancelled = true) @EventHandler(ignoreCancelled = true)
public void onPrepareItemCraftEvent(PrepareItemCraftEvent event) public void onPrepareItemCraftEvent(PrepareItemCraftEvent event)
{ {
if(event.getRecipe() == null) return;
Material itemType = event.getRecipe().getResult().getType(); Material itemType = event.getRecipe().getResult().getType();
if(itemType == Material.SHULKER_SHELL || SHULKER_BOX_MATERIALS.contains(itemType)) if(itemType == Material.SHULKER_SHELL || SHULKER_BOX_MATERIALS.contains(itemType))
{ {
@ -253,7 +248,6 @@ public void onPrepareItemCraftEvent(PrepareItemCraftEvent event)
@EventHandler(ignoreCancelled = true) @EventHandler(ignoreCancelled = true)
public void onDrop(PlayerDropItemEvent event) public void onDrop(PlayerDropItemEvent event)
{ {
//TODO null checks
Material itemType = event.getItemDrop().getItemStack().getType(); Material itemType = event.getItemDrop().getItemStack().getType();
if(itemType == Material.SHULKER_SHELL || SHULKER_BOX_MATERIALS.contains(itemType)) if(itemType == Material.SHULKER_SHELL || SHULKER_BOX_MATERIALS.contains(itemType))
{ {