forked from Upstream/mmocore
Fixed empty messages sent to chat/action bar
This commit is contained in:
parent
c211c05a67
commit
36b5be13be
@ -22,10 +22,14 @@ public class ConfigMessage {
|
|||||||
private ConfigMessage(@NotNull String key) {
|
private ConfigMessage(@NotNull String key) {
|
||||||
this.key = key;
|
this.key = key;
|
||||||
|
|
||||||
|
// Initialize message list
|
||||||
final Object obj = MMOCore.plugin.configManager.getMessageObject(key);
|
final Object obj = MMOCore.plugin.configManager.getMessageObject(key);
|
||||||
if (obj == null) lines.add("<message_not_found:'" + key + "'>");
|
if (obj == null) lines.add("<message_not_found:'" + key + "'>");
|
||||||
else if (obj instanceof List<?>) lines.addAll((List<String>) obj);
|
else if (obj instanceof List<?>) lines.addAll((List<String>) obj);
|
||||||
else lines.add(obj.toString());
|
else {
|
||||||
|
final String tostr = obj.toString();
|
||||||
|
if (!tostr.isEmpty()) lines.add(tostr);
|
||||||
|
}
|
||||||
|
|
||||||
// Does message include placeholders
|
// Does message include placeholders
|
||||||
boolean hasPlaceholders = false;
|
boolean hasPlaceholders = false;
|
||||||
@ -106,7 +110,7 @@ public class ConfigMessage {
|
|||||||
final String rawMessage = format(player, messageFormat);
|
final String rawMessage = format(player, messageFormat);
|
||||||
final PlayerData playerData = PlayerData.has(player) ? PlayerData.get(player) : null;
|
final PlayerData playerData = PlayerData.has(player) ? PlayerData.get(player) : null;
|
||||||
|
|
||||||
// Handle special case with player data+action bar
|
// Handle special case with player data + action bar
|
||||||
if (playerData != null && playerData.isOnline() && actionbar) {
|
if (playerData != null && playerData.isOnline() && actionbar) {
|
||||||
playerData.displayActionBar(rawMessage, raw);
|
playerData.displayActionBar(rawMessage, raw);
|
||||||
return;
|
return;
|
||||||
|
@ -24,6 +24,7 @@ public class SoundObject {
|
|||||||
private final float volume;
|
private final float volume;
|
||||||
private final float pitch;
|
private final float pitch;
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public SoundObject(String input) {
|
public SoundObject(String input) {
|
||||||
String[] split = input.split(",");
|
String[] split = input.split(",");
|
||||||
|
|
||||||
@ -43,6 +44,7 @@ public class SoundObject {
|
|||||||
pitch = split.length > 2 ? Float.parseFloat(split[2]) : 1;
|
pitch = split.length > 2 ? Float.parseFloat(split[2]) : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public SoundObject(ConfigurationSection config) {
|
public SoundObject(ConfigurationSection config) {
|
||||||
String input = config.getString("sound");
|
String input = config.getString("sound");
|
||||||
|
|
||||||
@ -65,32 +67,39 @@ public class SoundObject {
|
|||||||
* @return If this object is custom a custom sound, potentially
|
* @return If this object is custom a custom sound, potentially
|
||||||
* from a resource pack
|
* from a resource pack
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public boolean isCustom() {
|
public boolean isCustom() {
|
||||||
return sound == null;
|
return sound == null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
@Deprecated
|
||||||
public Sound getSound() {
|
public Sound getSound() {
|
||||||
return sound;
|
return sound;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
@Deprecated
|
||||||
public String getKey() {
|
public String getKey() {
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public float getVolume() {
|
public float getVolume() {
|
||||||
return volume;
|
return volume;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public float getPitch() {
|
public float getPitch() {
|
||||||
return pitch;
|
return pitch;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public void playTo(Player player) {
|
public void playTo(Player player) {
|
||||||
playTo(player, volume, pitch);
|
playTo(player, volume, pitch);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public void playTo(Player player, float volume, float pitch) {
|
public void playTo(Player player, float volume, float pitch) {
|
||||||
if (isCustom())
|
if (isCustom())
|
||||||
player.playSound(player.getLocation(), key, volume, pitch);
|
player.playSound(player.getLocation(), key, volume, pitch);
|
||||||
@ -98,10 +107,12 @@ public class SoundObject {
|
|||||||
player.playSound(player.getLocation(), sound, volume, pitch);
|
player.playSound(player.getLocation(), sound, volume, pitch);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public void playAt(Location loc) {
|
public void playAt(Location loc) {
|
||||||
playAt(loc, volume, pitch);
|
playAt(loc, volume, pitch);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public void playAt(Location loc, float volume, float pitch) {
|
public void playAt(Location loc, float volume, float pitch) {
|
||||||
if (isCustom())
|
if (isCustom())
|
||||||
loc.getWorld().playSound(loc, key, volume, pitch);
|
loc.getWorld().playSound(loc, key, volume, pitch);
|
||||||
|
@ -153,7 +153,7 @@ public class ConfigManager {
|
|||||||
skillTreeScrollStepY = config.getInt("skill-tree-scroll-step-y", 1);
|
skillTreeScrollStepY = config.getInt("skill-tree-scroll-step-y", 1);
|
||||||
// Resources
|
// Resources
|
||||||
staminaFull = getColorOrDefault("stamina-whole", ChatColor.GREEN);
|
staminaFull = getColorOrDefault("stamina-whole", ChatColor.GREEN);
|
||||||
staminaHalf = getColorOrDefault("stamina-half", ChatColor.DARK_GREEN);
|
staminaHalf = getColorOrDefault("stamina-half", ChatColor.DARK_GRAY);
|
||||||
staminaEmpty = getColorOrDefault("stamina-empty", ChatColor.WHITE);
|
staminaEmpty = getColorOrDefault("stamina-empty", ChatColor.WHITE);
|
||||||
|
|
||||||
passiveSkillNeedBound = MMOCore.plugin.getConfig().getBoolean("passive-skill-need-bound");
|
passiveSkillNeedBound = MMOCore.plugin.getConfig().getBoolean("passive-skill-need-bound");
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
package net.Indyuce.mmocore.manager;
|
package net.Indyuce.mmocore.manager;
|
||||||
|
|
||||||
|
import io.lumine.mythic.lib.util.SoundObject;
|
||||||
import net.Indyuce.mmocore.MMOCore;
|
import net.Indyuce.mmocore.MMOCore;
|
||||||
import net.Indyuce.mmocore.api.ConfigFile;
|
import net.Indyuce.mmocore.api.ConfigFile;
|
||||||
import net.Indyuce.mmocore.api.SoundEvent;
|
import net.Indyuce.mmocore.api.SoundEvent;
|
||||||
import net.Indyuce.mmocore.api.SoundObject;
|
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
@ -6,8 +6,8 @@ import io.lumine.mythic.lib.api.player.EquipmentSlot;
|
|||||||
import io.lumine.mythic.lib.player.PlayerMetadata;
|
import io.lumine.mythic.lib.player.PlayerMetadata;
|
||||||
import io.lumine.mythic.lib.skill.trigger.TriggerMetadata;
|
import io.lumine.mythic.lib.skill.trigger.TriggerMetadata;
|
||||||
import io.lumine.mythic.lib.skill.trigger.TriggerType;
|
import io.lumine.mythic.lib.skill.trigger.TriggerType;
|
||||||
|
import io.lumine.mythic.lib.util.SoundObject;
|
||||||
import net.Indyuce.mmocore.MMOCore;
|
import net.Indyuce.mmocore.MMOCore;
|
||||||
import net.Indyuce.mmocore.api.SoundObject;
|
|
||||||
import net.Indyuce.mmocore.api.event.PlayerKeyPressEvent;
|
import net.Indyuce.mmocore.api.event.PlayerKeyPressEvent;
|
||||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||||
import net.Indyuce.mmocore.gui.api.item.Placeholders;
|
import net.Indyuce.mmocore.gui.api.item.Placeholders;
|
||||||
|
@ -5,8 +5,8 @@ import io.lumine.mythic.lib.UtilityMethods;
|
|||||||
import io.lumine.mythic.lib.api.player.EquipmentSlot;
|
import io.lumine.mythic.lib.api.player.EquipmentSlot;
|
||||||
import io.lumine.mythic.lib.player.PlayerMetadata;
|
import io.lumine.mythic.lib.player.PlayerMetadata;
|
||||||
import io.lumine.mythic.lib.skill.trigger.TriggerMetadata;
|
import io.lumine.mythic.lib.skill.trigger.TriggerMetadata;
|
||||||
|
import io.lumine.mythic.lib.util.SoundObject;
|
||||||
import net.Indyuce.mmocore.MMOCore;
|
import net.Indyuce.mmocore.MMOCore;
|
||||||
import net.Indyuce.mmocore.api.SoundObject;
|
|
||||||
import net.Indyuce.mmocore.api.event.PlayerKeyPressEvent;
|
import net.Indyuce.mmocore.api.event.PlayerKeyPressEvent;
|
||||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||||
import net.Indyuce.mmocore.skill.ClassSkill;
|
import net.Indyuce.mmocore.skill.ClassSkill;
|
||||||
|
Loading…
Reference in New Issue
Block a user