Made Unidentified Items unusable

This commit is contained in:
Aria 2019-10-14 12:41:47 +02:00
parent 1be8e8ca79
commit 31ca777678
2 changed files with 10 additions and 1 deletions

View File

@ -3,6 +3,7 @@ package net.Indyuce.mmoitems.api.player;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Sound;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.MMOItems;
@ -54,7 +55,14 @@ public abstract class RPGPlayer {
} }
public boolean canUse(NBTItem item, boolean message) { public boolean canUse(NBTItem item, boolean message) {
if (item.hasTag("MMOITEMS_UNIDENTIFIED_ITEM")) {
if (message) {
Message.UNIDENTIFIED_ITEM.format(ChatColor.RED).send(player.getPlayer(), "cant-use-item");
player.getPlayer().playSound(player.getPlayer().getLocation(), Sound.ENTITY_VILLAGER_NO, 1, 1.5f);
}
return false;
}
for (Conditional condition : MMOItems.plugin.getStats().getConditionals()) for (Conditional condition : MMOItems.plugin.getStats().getConditionals())
if (!condition.canUse(this, item, message)) if (!condition.canUse(this, item, message))
return false; return false;

View File

@ -27,6 +27,7 @@ public enum Message {
WRONG_CLASS("You don't have the right class!"), WRONG_CLASS("You don't have the right class!"),
NOT_ENOUGH_MANA("You don't have enough mana!"), NOT_ENOUGH_MANA("You don't have enough mana!"),
NOT_ENOUGH_STAMINA("You don't have enough stamina!"), NOT_ENOUGH_STAMINA("You don't have enough stamina!"),
UNIDENTIFIED_ITEM("You can't use an unidentified item!"),
// custom durability // custom durability
ITEM_BROKE("Your #item#&c broke."), ITEM_BROKE("Your #item#&c broke."),