diff --git a/pom.xml b/pom.xml
index 59ac0e7..8bbed37 100644
--- a/pom.xml
+++ b/pom.xml
@@ -153,7 +153,7 @@
org.spigotmc
spigot-api
- 1.13.1-R0.1-SNAPSHOT
+ 1.14.4-R0.1-SNAPSHOT
provided
diff --git a/src/main/java/com/drtshock/playervaults/PlayerVaults.java b/src/main/java/com/drtshock/playervaults/PlayerVaults.java
index 0a55aa8..6db3d85 100644
--- a/src/main/java/com/drtshock/playervaults/PlayerVaults.java
+++ b/src/main/java/com/drtshock/playervaults/PlayerVaults.java
@@ -50,6 +50,7 @@ import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
+import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitRunnable;
@@ -94,6 +95,8 @@ public class PlayerVaults extends JavaPlugin {
// VaultViewInfo - Inventory
private final HashMap openInventories = new HashMap<>();
private final Set blockedMats = new HashSet<>();
+ private boolean blockWithModelData = false;
+ private boolean blockWithoutModelData = false;
private boolean useVault;
private YamlConfiguration signs;
private File signsFile;
@@ -393,8 +396,16 @@ public class PlayerVaults extends JavaPlugin {
// Clear just in case this is a reload.
blockedMats.clear();
+ this.blockWithModelData = false;
+ this.blockWithoutModelData = false;
if (getConf().getItemBlocking().isEnabled()) {
for (String s : getConf().getItemBlocking().getList()) {
+ if (s.equalsIgnoreCase("BLOCK_ALL_WITH_CUSTOM_MODEL_DATA")) {
+ this.blockWithModelData = true;
+ }
+ if (s.equalsIgnoreCase("BLOCK_ALL_WITHOUT_CUSTOM_MODEL_DATA")) {
+ this.blockWithoutModelData = true;
+ }
Material mat = Material.matchMaterial(s);
if (mat != null) {
blockedMats.add(mat);
@@ -402,6 +413,12 @@ public class PlayerVaults extends JavaPlugin {
}
}
}
+ try {
+ ItemMeta.class.getMethod("hasCustomModelData");
+ } catch (NoSuchMethodException e) {
+ this.blockWithModelData = false;
+ this.blockWithoutModelData = false;
+ }
File lang = new File(this.getDataFolder(), "lang");
if (lang.exists()) {
@@ -560,6 +577,14 @@ public class PlayerVaults extends JavaPlugin {
return blockedMats.contains(mat);
}
+ public boolean isBlockWithModelData() {
+ return this.blockWithModelData;
+ }
+
+ public boolean isBlockWithoutModelData() {
+ return this.blockWithoutModelData;
+ }
+
/**
* Tries to grab the server version as a string.
*
diff --git a/src/main/java/com/drtshock/playervaults/config/file/Config.java b/src/main/java/com/drtshock/playervaults/config/file/Config.java
index 71d8f23..ac957f4 100644
--- a/src/main/java/com/drtshock/playervaults/config/file/Config.java
+++ b/src/main/java/com/drtshock/playervaults/config/file/Config.java
@@ -30,7 +30,10 @@ public class Config {
public class Block {
private boolean enabled = true;
@Comment("Material list for blocked items (does not support ID's), only effective if the feature is enabled.\n" +
- " If you don't know material names: https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Material.html")
+ " If you don't know material names: https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Material.html\n" +
+ "\n" +
+ "Also, if you add \"BLOCK_ALL_WITH_CUSTOM_MODEL_DATA\" or \"BLOCK_ALL_WITHOUT_CUSTOM_MODEL_DATA\"\n" +
+ " then either all items with custom model data will be blocked, or all items without custom model data will be blocked.")
private List list = new ArrayList() {
{
this.add("PUMPKIN");
diff --git a/src/main/java/com/drtshock/playervaults/config/file/Translation.java b/src/main/java/com/drtshock/playervaults/config/file/Translation.java
index 34b6736..bcb2474 100644
--- a/src/main/java/com/drtshock/playervaults/config/file/Translation.java
+++ b/src/main/java/com/drtshock/playervaults/config/file/Translation.java
@@ -174,6 +174,8 @@ public class Translation {
private TL locked = TL.of("Vaults are currently locked while conversion occurs. Please try again in a moment!");
private TL help = TL.of("/pv ");
private TL blockedItem = TL.of(" is blocked from vaults.");
+ private TL blockedItemWithModelData = TL.of("This item is blocked from vaults.");
+ private TL blockedItemWithoutModelData = TL.of("This item is blocked from vaults.");
private TL signsDisabled = TL.of("Vault signs are currently disabled.");
private TL blockedBadItem = TL.of("This item is not allowed in a vault.");
}
@@ -306,6 +308,14 @@ public class Translation {
return this.translations.blockedItem;
}
+ public @NonNull TL blockedItemWithModelData() {
+ return this.translations.blockedItemWithModelData;
+ }
+
+ public @NonNull TL blockedItemWithoutModelData() {
+ return this.translations.blockedItemWithoutModelData;
+ }
+
public @NonNull TL signsDisabled() {
return this.translations.signsDisabled;
}
diff --git a/src/main/java/com/drtshock/playervaults/listeners/Listeners.java b/src/main/java/com/drtshock/playervaults/listeners/Listeners.java
index 61b6ccb..50afc41 100644
--- a/src/main/java/com/drtshock/playervaults/listeners/Listeners.java
+++ b/src/main/java/com/drtshock/playervaults/listeners/Listeners.java
@@ -135,10 +135,22 @@ public class Listeners implements Listener {
if (item == null) {
continue;
}
- if (!player.hasPermission("playervaults.bypassblockeditems") && PlayerVaults.getInstance().isBlockedMaterial(item.getType())) {
- event.setCancelled(true);
- this.plugin.getTL().blockedItem().title().with("item", item.getType().name()).send(player);
- return;
+ if (!player.hasPermission("playervaults.bypassblockeditems")) {
+ if (PlayerVaults.getInstance().isBlockWithModelData() && item.hasItemMeta() && item.getItemMeta().hasCustomModelData()) {
+ event.setCancelled(true);
+ this.plugin.getTL().blockedItemWithModelData().title().send(player);
+ return;
+ }
+ if (PlayerVaults.getInstance().isBlockWithoutModelData() && (!item.hasItemMeta() || !item.getItemMeta().hasCustomModelData())) {
+ event.setCancelled(true);
+ this.plugin.getTL().blockedItemWithoutModelData().title().send(player);
+ return;
+ }
+ if (PlayerVaults.getInstance().isBlockedMaterial(item.getType())) {
+ event.setCancelled(true);
+ this.plugin.getTL().blockedItem().title().with("item", item.getType().name()).send(player);
+ return;
+ }
}
}
}