mirror of
https://gitlab.com/phoenix-dvpmt/mmoitems.git
synced 2025-02-23 14:51:21 +01:00
Hopefully fixed empty chat messages
This commit is contained in:
parent
852e62057b
commit
1178709a78
@ -6,7 +6,6 @@ import net.Indyuce.mmoitems.api.item.mmoitem.VolatileMMOItem;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerData;
|
||||
import net.Indyuce.mmoitems.stat.type.PlayerConsumable;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@ -16,7 +15,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
*
|
||||
* @author Gunging
|
||||
*/
|
||||
public class ConsumableConsumedEvent extends PlayerDataEvent implements Cancellable {
|
||||
public class ConsumableConsumedEvent extends PlayerDataEvent {
|
||||
@NotNull
|
||||
private final VolatileMMOItem mmoitem;
|
||||
@NotNull
|
||||
|
@ -31,7 +31,7 @@ public class Weapon extends UseItem {
|
||||
@Override
|
||||
public boolean checkItemRequirements() {
|
||||
if (playerData.areHandsFull()) {
|
||||
Message.HANDS_TOO_CHARGED.format(ChatColor.RED).send(getPlayer(), "two-handed");
|
||||
Message.HANDS_TOO_CHARGED.format(ChatColor.RED).send(getPlayer());
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -68,13 +68,13 @@ public class Weapon extends UseItem {
|
||||
|
||||
double manaCost = getNBTItem().getStat("MANA_COST");
|
||||
if (manaCost > 0 && playerData.getRPG().getMana() < manaCost) {
|
||||
Message.NOT_ENOUGH_MANA.format(ChatColor.RED).send(getPlayer(), "not-enough-mana");
|
||||
Message.NOT_ENOUGH_MANA.format(ChatColor.RED).send(getPlayer());
|
||||
return false;
|
||||
}
|
||||
|
||||
double staminaCost = getNBTItem().getStat("STAMINA_COST");
|
||||
if (staminaCost > 0 && playerData.getRPG().getStamina() < staminaCost) {
|
||||
Message.NOT_ENOUGH_STAMINA.format(ChatColor.RED).send(getPlayer(), "not-enough-stamina");
|
||||
Message.NOT_ENOUGH_STAMINA.format(ChatColor.RED).send(getPlayer());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -110,7 +110,7 @@ public abstract class RPGPlayer {
|
||||
public boolean canUse(NBTItem item, boolean message, boolean allowDynamic) {
|
||||
if (item.hasTag("MMOITEMS_UNIDENTIFIED_ITEM")) {
|
||||
if (message) {
|
||||
Message.UNIDENTIFIED_ITEM.format(ChatColor.RED).send(player.getPlayer(), "cant-use-item");
|
||||
Message.UNIDENTIFIED_ITEM.format(ChatColor.RED).send(player.getPlayer());
|
||||
player.getPlayer().playSound(player.getPlayer().getLocation(), Sound.ENTITY_VILLAGER_NO, 1, 1.5f);
|
||||
}
|
||||
return false;
|
||||
@ -146,7 +146,7 @@ public abstract class RPGPlayer {
|
||||
for (int j = 0; j < 10; j++)
|
||||
progressBar.append(progress >= j ? ChatColor.GREEN : ChatColor.WHITE).append(barChar);
|
||||
Message.SPELL_ON_COOLDOWN.format(ChatColor.RED, "#left#", "" + new DecimalFormat("0.#").format(info.getRemaining()), "#progress#",
|
||||
progressBar.toString(), "#s#", (info.getRemaining() >= 2 ? "s" : "")).send(player, "ability-cooldown");
|
||||
progressBar.toString(), "#s#", (info.getRemaining() >= 2 ? "s" : "")).send(player);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -158,12 +158,12 @@ public abstract class RPGPlayer {
|
||||
return false;
|
||||
|
||||
if (data.hasModifier("mana") && getMana() < data.getModifier("mana")) {
|
||||
Message.NOT_ENOUGH_MANA.format(ChatColor.RED).send(player, "not-enough-mana");
|
||||
Message.NOT_ENOUGH_MANA.format(ChatColor.RED).send(player);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (data.hasModifier("stamina") && getStamina() < data.getModifier("stamina")) {
|
||||
Message.NOT_ENOUGH_STAMINA.format(ChatColor.RED).send(player, "not-enough-stamina");
|
||||
Message.NOT_ENOUGH_STAMINA.format(ChatColor.RED).send(player);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1,9 +0,0 @@
|
||||
package net.Indyuce.mmoitems.api.util.message;
|
||||
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
|
||||
public class AddonMessage extends PlayerMessage {
|
||||
public AddonMessage(String path) {
|
||||
super(MMOItems.plugin.getLanguage().getMessage(path));
|
||||
}
|
||||
}
|
@ -1,40 +1,39 @@
|
||||
package net.Indyuce.mmoitems.api.util.message;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
public enum Message {
|
||||
|
||||
RECEIVED_ITEM("You received &6#item#&e#amount#."),
|
||||
|
||||
// general restrictions
|
||||
HANDS_TOO_CHARGED("You can't do anything, your hands are too charged."),
|
||||
SPELL_ON_COOLDOWN("#progress# &eYou must wait #left# second#s# before casting this spell."),
|
||||
ITEM_ON_COOLDOWN("This item is on cooldown! Please wait #left#s."),
|
||||
// General restrictions
|
||||
HANDS_TOO_CHARGED("You can't do anything, your hands are too charged.", "two-handed"),
|
||||
SPELL_ON_COOLDOWN("#progress# &eYou must wait #left# second#s# before casting this spell.", "ability-cooldown"),
|
||||
ITEM_ON_COOLDOWN("This item is on cooldown! Please wait #left#s.", "item-cooldown"),
|
||||
NOT_ENOUGH_PERMS_COMMAND("You don't have enough permissions."),
|
||||
|
||||
// mitigation
|
||||
ATTACK_BLOCKED("You just blocked #percent#% of the attack damage!"),
|
||||
ATTACK_DODGED("You just dodged an attack!"),
|
||||
ATTACK_PARRIED("You just parried an attack!"),
|
||||
// Damage Mitigation
|
||||
ATTACK_BLOCKED("You just blocked #percent#% of the attack damage!", "mitigation"),
|
||||
ATTACK_DODGED("You just dodged an attack!", "mitigation"),
|
||||
ATTACK_PARRIED("You just parried an attack!", "mitigation"),
|
||||
|
||||
// item restrictions
|
||||
NOT_ENOUGH_LEVELS("You don't have enough levels to use this item!"),
|
||||
SOULBOUND_RESTRICTION("This item is linked to another player, you can't use it!"),
|
||||
NOT_ENOUGH_PERMS("You don't have enough permissions to use this."),
|
||||
WRONG_CLASS("You don't have the right class!"),
|
||||
NOT_ENOUGH_MANA("You don't have enough mana!"),
|
||||
NOT_ENOUGH_STAMINA("You don't have enough stamina!"),
|
||||
NOT_ENOUGH_ATTRIBUTE("You don't have enough #attribute#!"),
|
||||
NOT_ENOUGH_PROFESSION("You aren't high enough #profession# level!"),
|
||||
UNIDENTIFIED_ITEM("You can't use an unidentified item!"),
|
||||
// Item restrictions
|
||||
NOT_ENOUGH_LEVELS("You don't have enough levels to use this item!", "cant-use-item"),
|
||||
SOULBOUND_RESTRICTION("This item is linked to another player, you can't use it!", "cant-use-item"),
|
||||
NOT_ENOUGH_PERMS("You don't have enough permissions to use this.", "cant-use-item"),
|
||||
WRONG_CLASS("You don't have the right class!", "cant-use-item"),
|
||||
NOT_ENOUGH_MANA("You don't have enough mana!", "not-enough-mana"),
|
||||
NOT_ENOUGH_STAMINA("You don't have enough stamina!", "not-enough-stamina"),
|
||||
NOT_ENOUGH_ATTRIBUTE("You don't have enough #attribute#!", "cant-use-item"),
|
||||
NOT_ENOUGH_PROFESSION("You don't have enough levels in #profession#!", "cant-use-item"),
|
||||
UNIDENTIFIED_ITEM("You can't use an unidentified item!", "cant-use-item"),
|
||||
|
||||
// custom durability
|
||||
// Sustom durability
|
||||
// ITEM_BROKE("Your #item#&c broke."),
|
||||
ZERO_DURABILITY("This item is broken, you first need to repair it."),
|
||||
ZERO_DURABILITY("This item is broken, you first need to repair it.", "item-break"),
|
||||
|
||||
// consumables & gem stones
|
||||
// Consumables & Gem stones
|
||||
CANNOT_IDENTIFY_STACKED_ITEMS("You may only identify one item at a time."),
|
||||
SUCCESSFULLY_IDENTIFIED("You successfully identified &6#item#&e."),
|
||||
SUCCESSFULLY_DECONSTRUCTED("You successfully deconstructed &6#item#&e."),
|
||||
@ -49,7 +48,7 @@ public enum Message {
|
||||
RANDOM_UNSOCKET_GEM_TOO_OLD("The gems have bonded strongly with your item. Cannot remove."),
|
||||
RANDOM_UNSOCKET_SUCCESS("&aYou removed &3#gem# &afrom your &6#item#&a!"),
|
||||
|
||||
// soulbound
|
||||
// Soulbound
|
||||
CANT_BIND_ITEM("This item is currently linked to #player# by a Lvl #level# soulbound. You will have to break this soulbound first."),
|
||||
NO_SOULBOUND("This item is not bound to anyone."),
|
||||
CANT_BIND_STACKED("You can't bind stacked items."),
|
||||
@ -60,7 +59,7 @@ public enum Message {
|
||||
SUCCESSFULLY_BREAK_BIND("You successfully broke the Lvl &6#level# &eitem soulbound!"),
|
||||
SOULBOUND_ITEM_LORE("&4Linked to #player#//&4Lvl #level# Soulbound"),
|
||||
|
||||
// upgrade
|
||||
// Upgrade
|
||||
CANT_UPGRADED_STACK("You can't upgrade stacked items."),
|
||||
MAX_UPGRADES_HIT("This item cannot be upgraded anymore."),
|
||||
UPGRADE_FAIL("Your upgrade failed and you lost your consumable."),
|
||||
@ -70,7 +69,7 @@ public enum Message {
|
||||
NOT_HAVE_ITEM_UPGRADE("You don't have the item to upgrade!"),
|
||||
UPGRADE_REQUIREMENT_SAFE_CHECK("You would not meet the upgraded item requirements."),
|
||||
|
||||
// crafting messages
|
||||
// Crafting stations
|
||||
NOT_ENOUGH_MATERIALS("You do not have enough materials to craft this item."),
|
||||
CONDITIONS_NOT_MET("You cannot craft this item."),
|
||||
CRAFTING_CANCELED("You cancelled a crafting recipe."),
|
||||
@ -84,11 +83,16 @@ public enum Message {
|
||||
UNABLE_TO_REPAIR("This item can't be repaired by this consumable!"),
|
||||
;
|
||||
|
||||
private final String defaultMessage, path;
|
||||
private final String defaultMessage, path, actionBarConfigPath;
|
||||
|
||||
Message(String defaultMessage) {
|
||||
private Message(String defaultMessage, String actionBarConfigPath) {
|
||||
this.defaultMessage = defaultMessage;
|
||||
this.path = name().toLowerCase().replace("_", "-");
|
||||
this.actionBarConfigPath = actionBarConfigPath;
|
||||
}
|
||||
|
||||
private Message(String defaultMessage) {
|
||||
this(defaultMessage, null);
|
||||
}
|
||||
|
||||
public String getDefault() {
|
||||
@ -99,12 +103,19 @@ public enum Message {
|
||||
return MMOItems.plugin.getLanguage().getMessage(path);
|
||||
}
|
||||
|
||||
// toReplace length must be even
|
||||
public boolean isActionBarMessage() {
|
||||
return actionBarConfigPath != null;
|
||||
}
|
||||
|
||||
public String getActionBarConfigPath() {
|
||||
return actionBarConfigPath;
|
||||
}
|
||||
|
||||
public String formatRaw(ChatColor prefix, String... toReplace) {
|
||||
return format(prefix, toReplace).toString();
|
||||
}
|
||||
|
||||
public PlayerMessage format(ChatColor prefix, String... toReplace) {
|
||||
return new PlayerMessage(getUpdated()).format(prefix, toReplace);
|
||||
return new PlayerMessage(this).format(prefix, toReplace);
|
||||
}
|
||||
}
|
@ -1,23 +1,39 @@
|
||||
package net.Indyuce.mmoitems.api.util.message;
|
||||
|
||||
import io.lumine.mythic.lib.MythicLib;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import io.lumine.mythic.lib.MythicLib;
|
||||
|
||||
public class PlayerMessage {
|
||||
private final boolean actionBar;
|
||||
|
||||
private String message;
|
||||
|
||||
/*
|
||||
* this class allows the plugin to block empty messages from sending to
|
||||
* player chat
|
||||
/**
|
||||
* Used to block empty messages from spamming the chat. Also used to apply
|
||||
* a default color code to the message and be able to select which
|
||||
* messages are displayed on the action bar and which go to chat.
|
||||
*
|
||||
* @param message Unformatted message
|
||||
*/
|
||||
public PlayerMessage(String message) {
|
||||
public PlayerMessage(Message message) {
|
||||
this.message = message.getUpdated();
|
||||
this.actionBar = MMOItems.plugin.getConfig().getBoolean("action-bar-display." + message.getActionBarConfigPath());
|
||||
}
|
||||
|
||||
/**
|
||||
* Can be used by external plugins. This can be useful to
|
||||
* apply that 60 tick action bar timeout when using MMOCore
|
||||
*
|
||||
* @param message Messages with color codes applied.
|
||||
* @param actionBar Should the message be displayed on the action bar
|
||||
*/
|
||||
public PlayerMessage(String message, boolean actionBar) {
|
||||
this.message = message;
|
||||
this.actionBar = actionBar;
|
||||
}
|
||||
|
||||
public PlayerMessage format(ChatColor prefix, String... toReplace) {
|
||||
@ -27,17 +43,16 @@ public class PlayerMessage {
|
||||
return this;
|
||||
}
|
||||
|
||||
public void send(CommandSender player) {
|
||||
if (!ChatColor.stripColor(message).equals(""))
|
||||
player.sendMessage(message);
|
||||
}
|
||||
|
||||
// send on action bar or chat
|
||||
public void send(Player player, String actionBarBooleanPath) {
|
||||
if (ChatColor.stripColor(message).equals(""))
|
||||
/**
|
||||
* Either sends to action bar or to chat if it's not empty
|
||||
*
|
||||
* @param player Player to send message to
|
||||
*/
|
||||
public void send(Player player) {
|
||||
if (ChatColor.stripColor(message).isEmpty())
|
||||
return;
|
||||
|
||||
if (MMOItems.plugin.getConfig().getBoolean("action-bar-display." + actionBarBooleanPath)) {
|
||||
if (actionBar) {
|
||||
if (Bukkit.getPluginManager().isPluginEnabled("MMOCore"))
|
||||
PlayerData.get(player).setActionBarTimeOut(60);
|
||||
|
||||
|
@ -1,14 +1,14 @@
|
||||
package net.Indyuce.mmoitems.comp.mmocore.stat;
|
||||
|
||||
import io.lumine.mythic.lib.api.item.NBTItem;
|
||||
import io.lumine.mythic.lib.version.VersionMaterial;
|
||||
import net.Indyuce.mmocore.api.player.attribute.PlayerAttribute;
|
||||
import net.Indyuce.mmoitems.api.player.RPGPlayer;
|
||||
import net.Indyuce.mmoitems.api.util.message.AddonMessage;
|
||||
import net.Indyuce.mmoitems.api.util.message.Message;
|
||||
import net.Indyuce.mmoitems.comp.mmocore.MMOCoreHook.MMOCoreRPGPlayer;
|
||||
import net.Indyuce.mmoitems.stat.type.DoubleStat;
|
||||
import net.Indyuce.mmoitems.stat.type.GemStoneStat;
|
||||
import net.Indyuce.mmoitems.stat.type.ItemRestriction;
|
||||
import io.lumine.mythic.lib.api.item.NBTItem;
|
||||
import io.lumine.mythic.lib.version.VersionMaterial;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Sound;
|
||||
|
||||
@ -26,7 +26,7 @@ public class Required_Attribute extends DoubleStat implements ItemRestriction, G
|
||||
MMOCoreRPGPlayer mmocore = (MMOCoreRPGPlayer) player;
|
||||
if (mmocore.getData().getAttributes().getAttribute(attribute) < item.getStat(getId())) {
|
||||
if (message) {
|
||||
new AddonMessage("not-enough-attribute").format(ChatColor.RED, "#attribute#", attribute.getName()).send(player.getPlayer(), "cant-use-item");
|
||||
Message.NOT_ENOUGH_ATTRIBUTE.format(ChatColor.RED, "#attribute#", attribute.getName()).send(player.getPlayer());
|
||||
player.getPlayer().playSound(player.getPlayer().getLocation(), Sound.ENTITY_VILLAGER_NO, 1, 1.5f);
|
||||
}
|
||||
return false;
|
||||
|
@ -1,17 +1,16 @@
|
||||
package net.Indyuce.mmoitems.comp.mmocore.stat;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
|
||||
import io.lumine.mythic.lib.api.item.NBTItem;
|
||||
import net.Indyuce.mmocore.api.experience.Profession;
|
||||
import net.Indyuce.mmoitems.api.player.RPGPlayer;
|
||||
import net.Indyuce.mmoitems.api.util.message.AddonMessage;
|
||||
import net.Indyuce.mmoitems.api.util.message.Message;
|
||||
import net.Indyuce.mmoitems.comp.mmocore.MMOCoreHook;
|
||||
import net.Indyuce.mmoitems.stat.type.DoubleStat;
|
||||
import net.Indyuce.mmoitems.stat.type.GemStoneStat;
|
||||
import net.Indyuce.mmoitems.stat.type.ItemRestriction;
|
||||
import io.lumine.mythic.lib.api.item.NBTItem;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
|
||||
public class Required_Profession extends DoubleStat implements ItemRestriction, GemStoneStat {
|
||||
private final Profession profession;
|
||||
@ -26,7 +25,7 @@ public class Required_Profession extends DoubleStat implements ItemRestriction,
|
||||
MMOCoreHook.MMOCoreRPGPlayer mmocore = (MMOCoreHook.MMOCoreRPGPlayer) player;
|
||||
if (mmocore.getData().getCollectionSkills().getLevel(this.profession) < item.getStat(getId())) {
|
||||
if (message) {
|
||||
new AddonMessage("not-enough-profession").format(ChatColor.RED, "#profession#", profession.getName()).send(player.getPlayer(), "cant-use-item");
|
||||
Message.NOT_ENOUGH_PROFESSION.format(ChatColor.RED, "#profession#", profession.getName()).send(player.getPlayer());
|
||||
player.getPlayer().playSound(player.getPlayer().getLocation(), Sound.ENTITY_VILLAGER_NO, 1, 1.5f);
|
||||
}
|
||||
return false;
|
||||
|
@ -74,7 +74,7 @@ public class ItemUse implements Listener {
|
||||
if (!useItem.getPlayerData().isOnCooldown(useItem.getMMOItem().getId())) {
|
||||
Message.ITEM_ON_COOLDOWN
|
||||
.format(ChatColor.RED, "#left#", DIGIT.format(useItem.getPlayerData().getItemCooldown(useItem.getMMOItem().getId())))
|
||||
.send(player, "item-cooldown");
|
||||
.send(player);
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
@ -314,7 +314,7 @@ public class ItemUse implements Listener {
|
||||
if (!useItem.getPlayerData().isOnCooldown(useItem.getMMOItem().getId())) {
|
||||
Message.ITEM_ON_COOLDOWN
|
||||
.format(ChatColor.RED, "#left#", DIGIT.format(useItem.getPlayerData().getItemCooldown(useItem.getMMOItem().getId())))
|
||||
.send(player, "item-cooldown");
|
||||
.send(player);
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
@ -91,7 +91,7 @@ public class MaximumDurability extends DoubleStat implements ItemRestriction, Ge
|
||||
|
||||
if (item.getDouble(ItemStats.CUSTOM_DURABILITY.getNBTPath()) <= 0) {
|
||||
if (message) {
|
||||
Message.ZERO_DURABILITY.format(ChatColor.RED).send(player.getPlayer(), "cant-use-item");
|
||||
Message.ZERO_DURABILITY.format(ChatColor.RED).send(player.getPlayer());
|
||||
player.getPlayer().playSound(player.getPlayer().getLocation(), Sound.ENTITY_VILLAGER_NO, 1, 1.5f);
|
||||
}
|
||||
return false;
|
||||
|
@ -155,7 +155,7 @@ public class Permission extends StringListStat implements ItemRestriction {
|
||||
for (String s : split)
|
||||
if (!player.getPlayer().hasPermission(s)) {
|
||||
if (message) {
|
||||
Message.NOT_ENOUGH_PERMS.format(ChatColor.RED).send(player.getPlayer(), "cant-use-item");
|
||||
Message.NOT_ENOUGH_PERMS.format(ChatColor.RED).send(player.getPlayer());
|
||||
player.getPlayer().playSound(player.getPlayer().getLocation(), Sound.ENTITY_VILLAGER_NO, 1, 1.5f);
|
||||
}
|
||||
return false;
|
||||
|
@ -154,7 +154,7 @@ public class RequiredClass extends StringListStat implements ItemRestriction, Ge
|
||||
String requiredClass = item.getString(ItemStats.REQUIRED_CLASS.getNBTPath());
|
||||
if (!requiredClass.equals("") && !hasRightClass(player, requiredClass) && !player.getPlayer().hasPermission("mmoitems.bypass.class")) {
|
||||
if (message) {
|
||||
Message.WRONG_CLASS.format(ChatColor.RED).send(player.getPlayer(), "cant-use-item");
|
||||
Message.WRONG_CLASS.format(ChatColor.RED).send(player.getPlayer());
|
||||
player.getPlayer().playSound(player.getPlayer().getLocation(), Sound.ENTITY_VILLAGER_NO, 1, 1.5f);
|
||||
}
|
||||
return false;
|
||||
|
@ -134,7 +134,7 @@ public class RequiredLevel extends DoubleStat implements ItemRestriction {
|
||||
int level = item.getInteger(ItemStats.REQUIRED_LEVEL.getNBTPath());
|
||||
if (player.getLevel() < level && !player.getPlayer().hasPermission("mmoitems.bypass.level")) {
|
||||
if (message) {
|
||||
Message.NOT_ENOUGH_LEVELS.format(ChatColor.RED).send(player.getPlayer(), "cant-use-item");
|
||||
Message.NOT_ENOUGH_LEVELS.format(ChatColor.RED).send(player.getPlayer());
|
||||
player.getPlayer().playSound(player.getPlayer().getLocation(), Sound.ENTITY_VILLAGER_NO, 1, 1.5f);
|
||||
}
|
||||
return false;
|
||||
|
@ -1,13 +1,7 @@
|
||||
package net.Indyuce.mmoitems.stat;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
|
||||
import io.lumine.mythic.lib.api.item.NBTItem;
|
||||
import io.lumine.mythic.lib.version.VersionMaterial;
|
||||
import net.Indyuce.mmoitems.ItemStats;
|
||||
import net.Indyuce.mmoitems.MMOUtils;
|
||||
import net.Indyuce.mmoitems.api.Type;
|
||||
@ -21,10 +15,15 @@ import net.Indyuce.mmoitems.api.util.message.Message;
|
||||
import net.Indyuce.mmoitems.stat.data.SoulboundData;
|
||||
import net.Indyuce.mmoitems.stat.type.ConsumableItemInteraction;
|
||||
import net.Indyuce.mmoitems.stat.type.DoubleStat;
|
||||
import io.lumine.mythic.lib.api.item.NBTItem;
|
||||
import io.lumine.mythic.lib.version.VersionMaterial;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class SoulbindingBreakChance extends DoubleStat implements ConsumableItemInteraction {
|
||||
private static final Random random = new Random();
|
||||
|
||||
@ -45,7 +44,7 @@ public class SoulbindingBreakChance extends DoubleStat implements ConsumableItem
|
||||
|
||||
MMOItem targetMMO = new VolatileMMOItem(target);
|
||||
if (!targetMMO.hasData(ItemStats.SOULBOUND)) {
|
||||
Message.NO_SOULBOUND.format(ChatColor.RED).send(player, "soulbound");
|
||||
Message.NO_SOULBOUND.format(ChatColor.RED).send(player);
|
||||
player.playSound(player.getLocation(), Sound.ENTITY_VILLAGER_NO, 1, 1);
|
||||
return false;
|
||||
}
|
||||
@ -53,7 +52,7 @@ public class SoulbindingBreakChance extends DoubleStat implements ConsumableItem
|
||||
// check for soulbound level
|
||||
SoulboundData soulbound = (SoulboundData) targetMMO.getData(ItemStats.SOULBOUND);
|
||||
if (Math.max(1, consumable.getNBTItem().getStat(ItemStats.SOULBOUND_LEVEL.getId())) < soulbound.getLevel()) {
|
||||
Message.LOW_SOULBOUND_LEVEL.format(ChatColor.RED, "#level#", MMOUtils.intToRoman(soulbound.getLevel())).send(player, "soulbound");
|
||||
Message.LOW_SOULBOUND_LEVEL.format(ChatColor.RED, "#level#", MMOUtils.intToRoman(soulbound.getLevel())).send(player);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -65,11 +64,11 @@ public class SoulbindingBreakChance extends DoubleStat implements ConsumableItem
|
||||
|
||||
(targetMMO = new LiveMMOItem(target)).removeData(ItemStats.SOULBOUND);
|
||||
target.getItem().setItemMeta(targetMMO.newBuilder().build().getItemMeta());
|
||||
Message.SUCCESSFULLY_BREAK_BIND.format(ChatColor.YELLOW, "#level#", MMOUtils.intToRoman(soulbound.getLevel())).send(player, "soulbound");
|
||||
Message.SUCCESSFULLY_BREAK_BIND.format(ChatColor.YELLOW, "#level#", MMOUtils.intToRoman(soulbound.getLevel())).send(player);
|
||||
player.playSound(player.getLocation(), Sound.BLOCK_ANVIL_LAND, 1, 2);
|
||||
|
||||
} else {
|
||||
Message.UNSUCCESSFUL_SOULBOUND_BREAK.format(ChatColor.RED).send(player, "soulbound");
|
||||
Message.UNSUCCESSFUL_SOULBOUND_BREAK.format(ChatColor.RED).send(player);
|
||||
player.playSound(player.getLocation(), Sound.ENTITY_ITEM_BREAK, 1, 0);
|
||||
}
|
||||
|
||||
|
@ -1,13 +1,7 @@
|
||||
package net.Indyuce.mmoitems.stat;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
|
||||
import io.lumine.mythic.lib.api.item.NBTItem;
|
||||
import io.lumine.mythic.lib.version.VersionMaterial;
|
||||
import net.Indyuce.mmoitems.ItemStats;
|
||||
import net.Indyuce.mmoitems.MMOUtils;
|
||||
import net.Indyuce.mmoitems.api.Type;
|
||||
@ -21,10 +15,15 @@ import net.Indyuce.mmoitems.api.util.message.Message;
|
||||
import net.Indyuce.mmoitems.stat.data.SoulboundData;
|
||||
import net.Indyuce.mmoitems.stat.type.ConsumableItemInteraction;
|
||||
import net.Indyuce.mmoitems.stat.type.DoubleStat;
|
||||
import io.lumine.mythic.lib.api.item.NBTItem;
|
||||
import io.lumine.mythic.lib.version.VersionMaterial;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class SoulbindingChance extends DoubleStat implements ConsumableItemInteraction {
|
||||
private static final Random random = new Random();
|
||||
|
||||
@ -43,15 +42,14 @@ public class SoulbindingChance extends DoubleStat implements ConsumableItemInter
|
||||
return false;
|
||||
|
||||
if (target.getItem().getAmount() > 1) {
|
||||
Message.CANT_BIND_STACKED.format(ChatColor.RED).send(player, "soulbound");
|
||||
Message.CANT_BIND_STACKED.format(ChatColor.RED).send(player);
|
||||
return false;
|
||||
}
|
||||
|
||||
MMOItem targetMMO = new VolatileMMOItem(target);
|
||||
if (targetMMO.hasData(ItemStats.SOULBOUND)) {
|
||||
SoulboundData data = (SoulboundData) targetMMO.getData(ItemStats.SOULBOUND);
|
||||
Message.CANT_BIND_ITEM.format(ChatColor.RED, "#player#", data.getName(), "#level#", MMOUtils.intToRoman(data.getLevel())).send(player,
|
||||
"soulbound");
|
||||
Message.CANT_BIND_ITEM.format(ChatColor.RED, "#player#", data.getName(), "#level#", MMOUtils.intToRoman(data.getLevel())).send(player);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -67,12 +65,12 @@ public class SoulbindingChance extends DoubleStat implements ConsumableItemInter
|
||||
target.getItem().setItemMeta(targetMMO.newBuilder().build().getItemMeta());
|
||||
Message.SUCCESSFULLY_BIND_ITEM
|
||||
.format(ChatColor.YELLOW, "#item#", MMOUtils.getDisplayName(target.getItem()), "#level#", MMOUtils.intToRoman(soulboundLevel))
|
||||
.send(player, "soulbound");
|
||||
.send(player);
|
||||
player.playSound(player.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 1, 2);
|
||||
return true;
|
||||
}
|
||||
|
||||
Message.UNSUCCESSFUL_SOULBOUND.format(ChatColor.RED).send(player, "soulbound");
|
||||
Message.UNSUCCESSFUL_SOULBOUND.format(ChatColor.RED).send(player);
|
||||
player.playSound(player.getLocation(), Sound.ENTITY_VILLAGER_NO, 1, 1);
|
||||
return true;
|
||||
}
|
||||
|
@ -116,7 +116,7 @@ public class Soulbound extends ItemStat implements InternalStat, ItemRestriction
|
||||
if (item.hasTag(ItemStats.SOULBOUND.getNBTPath()) && !item.getString(ItemStats.SOULBOUND.getNBTPath()).contains(player.getPlayer().getUniqueId().toString()) && !player.getPlayer().hasPermission("mmoitems.bypass.soulbound")) {
|
||||
if (message) {
|
||||
int level = new JsonParser().parse(item.getString(ItemStats.SOULBOUND.getNBTPath())).getAsJsonObject().get("Level").getAsInt();
|
||||
Message.SOULBOUND_RESTRICTION.format(ChatColor.RED).send(player.getPlayer(), "cant-use-item");
|
||||
Message.SOULBOUND_RESTRICTION.format(ChatColor.RED).send(player.getPlayer());
|
||||
player.getPlayer().playSound(player.getPlayer().getLocation(), Sound.ENTITY_VILLAGER_NO, 1, 1.5f);
|
||||
player.getPlayer()
|
||||
.damage(MMOItems.plugin.getLanguage().soulboundBaseDamage + level * MMOItems.plugin.getLanguage().soulboundPerLvlDamage);
|
||||
|
Loading…
Reference in New Issue
Block a user