1
0
mirror of https://github.com/Zrips/Jobs.git synced 2024-11-29 05:55:27 +01:00

Saving message options into database

option to toggle bossbar, actionbar and chattext modes
showing message states when using clean toggle command
better handling of toggle command
This commit is contained in:
Zrips 2024-09-29 11:54:45 +03:00
parent 00a50da871
commit 9ed7956d62
11 changed files with 261 additions and 198 deletions

View File

@ -897,7 +897,7 @@ public final class Jobs extends JavaPlugin {
getInstance().getBlockOwnerShip(CMIMaterial.SMOKER).ifPresent(BlockOwnerShip::load);
}
ToggleBarHandling.load();
ToggleBarHandling.init();
usedSlots.clear();
for (Job job : jobs) {
usedSlots.put(job, dao.getSlotsTaken(job));
@ -937,7 +937,6 @@ public final class Jobs extends JavaPlugin {
dao.saveExplore();
blockOwnerShipsMaterial.values().forEach(BlockOwnerShip::save);
ToggleBarHandling.save();
if (saveTask != null)
saveTask.shutdown();

View File

@ -62,6 +62,7 @@ import com.gamingmesh.jobs.dao.JobsDAOData;
import com.gamingmesh.jobs.economy.PaymentData;
import com.gamingmesh.jobs.hooks.HookManager;
import com.gamingmesh.jobs.i18n.Language;
import com.gamingmesh.jobs.stuff.ToggleBarHandling;
import com.gamingmesh.jobs.stuff.Util;
import net.Zrips.CMILib.ActionBar.CMIActionBar;
@ -286,6 +287,8 @@ public class PlayerManager {
if (info != null) {
jPlayer.setDoneQuests(info.getQuestsDone());
jPlayer.setQuestProgressionFromString(info.getQuestProgression());
ToggleBarHandling.recordPlayerOptionsFromInt(jPlayer.getUniqueId(), info.getMessageOptions());
}
Jobs.getJobsDAO().loadLog(jPlayer);
@ -444,6 +447,9 @@ public class PlayerManager {
jPlayer.setUserId(info.getID());
jPlayer.setDoneQuests(info.getQuestsDone());
jPlayer.setQuestProgressionFromString(info.getQuestProgression());
ToggleBarHandling.recordPlayerOptionsFromInt(jPlayer.getUniqueId(), info.getMessageOptions());
jPlayer.setSeen(info.getSeen());
if (jobs != null) {

View File

@ -10,6 +10,7 @@ import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.commands.Cmd;
import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.container.MessageToggleState;
import com.gamingmesh.jobs.container.MessageToggleType;
import com.gamingmesh.jobs.i18n.Language;
import com.gamingmesh.jobs.stuff.ToggleBarHandling;
@ -25,34 +26,44 @@ public class toggle implements Cmd {
return null;
}
boolean isBossbar = false, isActionbar = false;
if (args.length != 1 || (!(isBossbar = args[0].equalsIgnoreCase("bossbar")) && !(isActionbar = args[0].equalsIgnoreCase("actionbar")))) {
return false;
}
Player player = (Player) sender;
UUID playerUUID = player.getUniqueId();
if (isActionbar) {
MessageToggleState ex = ToggleBarHandling.getActionBarToggle().getOrDefault(playerUUID, Jobs.getGCManager().ActionBarsMessageDefault).getNext();
Language.sendMessage(sender, "command.toggle.output." + ex.toString());
ToggleBarHandling.getActionBarToggle().put(playerUUID, ex);
if (args.length == 1) {
switch (args[0].toLowerCase()) {
case "actionbar":
toggleState(sender, playerUUID, MessageToggleType.ActionBar);
return true;
case "bossbar":
toggleState(sender, playerUUID, MessageToggleType.BossBar);
if (ToggleBarHandling.getState(playerUUID, MessageToggleType.BossBar).equals(MessageToggleState.Off)) {
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(playerUUID);
if (jPlayer != null)
jPlayer.hideBossBars();
}
return true;
case "chattext":
toggleState(sender, playerUUID, MessageToggleType.ChatText);
return true;
}
}
if (isBossbar) {
MessageToggleState ex = ToggleBarHandling.getBossBarToggle().getOrDefault(playerUUID, Jobs.getGCManager().BossBarsMessageDefault).getNext();
Language.sendMessage(sender, "command.toggle.output." + ex.toString());
if (ex.equals(MessageToggleState.Off)) {
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player.getUniqueId());
if (jPlayer != null)
jPlayer.hideBossBars();
}
ToggleBarHandling.getBossBarToggle().put(playerUUID, ex);
LC.info_Spliter.sendMessage(sender);
for (MessageToggleType one : MessageToggleType.values()) {
Language.sendMessage(sender, "command.toggle.output." + ToggleBarHandling.getState(playerUUID, one).toString(), "[type]", one.toString());
}
return true;
}
private static void toggleState(CommandSender sender, UUID uuid, MessageToggleType type) {
MessageToggleState state = ToggleBarHandling.getState(uuid, type).getNext();
if (type.equals(MessageToggleType.ChatText) && state.equals(MessageToggleState.Rapid))
state = state.getNext();
ToggleBarHandling.modify(uuid, type, state);
Language.sendMessage(sender, "command.toggle.output." + state.toString(), "[type]", type.toString());
}
}

View File

@ -40,7 +40,7 @@ public class BossBarManager {
if (Version.getCurrent().isLower(Version.v1_9_R1) || Jobs.getGCManager().BossBarsMessageDefault.equals(MessageToggleState.Off))
return;
if (ToggleBarHandling.getBossBarToggle().getOrDefault(player.getUniqueId(), MessageToggleState.Rapid).equals(MessageToggleState.Off))
if (ToggleBarHandling.getBossBarState(player.getUniqueId()).equals(MessageToggleState.Off))
return;
showJobProgressionInTask(player, jobProg, expGain);

View File

@ -116,6 +116,7 @@ public class GeneralConfigManager {
payForEachVTradeItem, allowEnchantingBoostedItems, preventShopItemEnchanting;
public MessageToggleState BossBarsMessageDefault = MessageToggleState.Rapid;
public MessageToggleState ActionBarsMessageDefault = MessageToggleState.Rapid;
public MessageToggleState ChatTextMessageDefault = MessageToggleState.Batched;
public int ActionBarsMessageKeepFor;
@ -991,7 +992,11 @@ public class GeneralConfigManager {
"Percentage to loose when leaving job at max level",
"Only works when fix-at-max-level is set to false");
levelLossPercentageFromMax = c.get("old-job.level-loss-from-max-level", levelLossPercentage);
c.addComment("ChatText.Messages.DefaultState", "States of chat text messages when payment is issued", "Valid options: Off, Batched",
"This will be used if player disables action bar payment messages");
ChatTextMessageDefault = MessageToggleState.getByName(c.get("ChatText.Messages.DefaultState", MessageToggleState.Batched.toString()));
c.addComment("ActionBars.Enabled", "Enables ActionBar messages");
ActionBarEnabled = c.get("ActionBars.Enabled", true);

View File

@ -646,7 +646,7 @@ public class LanguageManager {
c.get("command.toggle.help.info", "Toggles payment output on action bar or bossbar.");
c.get("command.toggle.help.args", "actionbar/bossbar");
Jobs.getGCManager().getCommandArgs().put("toggle", Arrays.asList("actionbar%%bossbar"));
Jobs.getGCManager().getCommandArgs().put("toggle", Arrays.asList("actionbar%%bossbar%%chattext"));
c.get("command.toggle.output.turnedoff", "&4This feature is turned off!");
c.get("command.toggle.output.paid.main", "&aYou got:");
@ -658,9 +658,9 @@ public class LanguageManager {
c.get("command.toggle.output.paid.ACexp", "&7+[exp]XP ");
c.get("command.toggle.output.paid.ACpoints", "&6+[points]pts ");
c.get("command.toggle.output.Rapid", "&aToggled: &7Rapid");
c.get("command.toggle.output.Batched", "&aToggled: &fBatched");
c.get("command.toggle.output.Off", "&aToggled: &6Off");
c.get("command.toggle.output.Rapid", "&7[type]&a: &7Rapid");
c.get("command.toggle.output.Batched", "&7[type]&a: &fBatched");
c.get("command.toggle.output.Off", "&7[type]&a: &6Off");
c.get("command.howmuch.help.info", "Check potential payment by target entity or block");
c.get("command.howmuch.help.args", "");

View File

@ -0,0 +1,37 @@
package com.gamingmesh.jobs.container;
import net.Zrips.CMILib.Container.CMINumber;
import net.Zrips.CMILib.Locale.LC;
public enum MessageToggleType {
ActionBar, BossBar, ChatText;
public static MessageToggleType getByName(String name) {
for (MessageToggleType state : MessageToggleType.values()) {
if (state.name().equalsIgnoreCase(name))
return state;
}
return null;
}
public static MessageToggleType getFromID(int id) {
return MessageToggleType.values()[CMINumber.clamp(id, 0, MessageToggleType.values().length - 1)];
}
public static String toCommaSeparatedString() {
StringBuilder str = new StringBuilder();
for (MessageToggleType state : MessageToggleType.values()) {
if (!str.toString().isEmpty())
str.append(LC.info_ListSpliter.getLocale());
str.append(state.name());
}
return str.toString();
}
public MessageToggleType getNext() {
int index = this.ordinal();
index++;
index = index >= MessageToggleType.values().length ? 0 : index;
return MessageToggleType.values()[index];
}
}

View File

@ -13,70 +13,78 @@ public class PlayerInfo {
private String questProgression;
private UUID uuid;
private JobsPlayer player;
private Integer messageOptions;
public PlayerInfo(String name, int id, UUID uuid, Long seen, Integer questsDone, String questProgression) {
this.name = name == null ? "Unknown" : name;
this.id = id;
this.uuid = uuid;
this.seen = seen;
this.questsDone = questsDone;
this.questProgression = questProgression;
player = Jobs.getPlayerManager().getJobsPlayer(uuid);
if (player != null)
player.setUserId(id);
public PlayerInfo(String name, int id, UUID uuid, Long seen, Integer questsDone, String questProgression, Integer messageOptions) {
this.name = name == null ? "Unknown" : name;
this.id = id;
this.uuid = uuid;
this.seen = seen;
this.questsDone = questsDone;
this.questProgression = questProgression;
player = Jobs.getPlayerManager().getJobsPlayer(uuid);
if (player != null)
player.setUserId(id);
this.messageOptions = messageOptions;
}
public PlayerInfo(String name, int id, UUID uuid, Long seen, Integer questsDone) {
this(name, id, uuid, seen, questsDone, null);
this(name, id, uuid, seen, questsDone, null, null);
}
public String getName() {
if (player == null)
player = Jobs.getPlayerManager().getJobsPlayer(uuid);
return player != null ? player.getName() : name;
if (player == null)
player = Jobs.getPlayerManager().getJobsPlayer(uuid);
return player != null ? player.getName() : name;
}
public int getID() {
return id;
return id;
}
public Long getSeen() {
return seen;
return seen;
}
public UUID getUuid() {
return uuid;
return uuid;
}
public JobsPlayer getJobsPlayer() {
if (player == null)
player = Jobs.getPlayerManager().getJobsPlayer(uuid);
return player;
if (player == null)
player = Jobs.getPlayerManager().getJobsPlayer(uuid);
return player;
}
public String getDisplayName() {
if (player == null)
player = Jobs.getPlayerManager().getJobsPlayer(uuid);
if (player == null)
return getName();
return player.getDisplayName();
if (player == null)
player = Jobs.getPlayerManager().getJobsPlayer(uuid);
if (player == null)
return getName();
return player.getDisplayName();
}
public Integer getQuestsDone() {
return questsDone;
return questsDone;
}
@Deprecated
public void setQuestsDone(Integer questsDone) {
this.questsDone = questsDone;
this.questsDone = questsDone;
}
public String getQuestProgression() {
return questProgression;
return questProgression;
}
@Deprecated
public void setQuestProgression(String questProgression) {
this.questProgression = questProgression;
this.questProgression = questProgression;
}
public Integer getMessageOptions() {
return messageOptions;
}
}

View File

@ -41,6 +41,7 @@ import com.gamingmesh.jobs.container.PlayerPoints;
import com.gamingmesh.jobs.container.TopList;
import com.gamingmesh.jobs.dao.JobsManager.DataBaseType;
import com.gamingmesh.jobs.economy.PaymentData;
import com.gamingmesh.jobs.stuff.ToggleBarHandling;
import com.gamingmesh.jobs.stuff.Util;
import net.Zrips.CMILib.Logs.CMIDebug;
@ -130,7 +131,8 @@ public abstract class JobsDAO {
username("text"),
seen("bigint"),
donequests("int"),
quests("text");
quests("text"),
messageOptions("int");
private String type;
@ -1904,7 +1906,8 @@ public abstract class JobsDAO {
res.getInt("id"), uuid,
res.getLong(UserTableFields.seen.getCollumn()),
res.getInt(UserTableFields.donequests.getCollumn()),
res.getString(UserTableFields.quests.getCollumn()));
res.getString(UserTableFields.quests.getCollumn()),
res.getInt(UserTableFields.messageOptions.getCollumn()));
Jobs.getPlayerManager().addPlayerToMap(pInfo);
}
} catch (SQLException e) {
@ -1945,7 +1948,8 @@ public abstract class JobsDAO {
UUID.fromString(uuid),
seen,
res.getInt(UserTableFields.donequests.getCollumn()),
res.getString(UserTableFields.quests.getCollumn())));
res.getString(UserTableFields.quests.getCollumn()),
res.getInt(UserTableFields.messageOptions.getCollumn())));
} catch (IllegalArgumentException e) {
}
}
@ -2063,16 +2067,30 @@ public abstract class JobsDAO {
PreparedStatement prest = null;
try {
prest = conn.prepareStatement("UPDATE `" + DBTables.UsersTable.getTableName() + "` SET `" + UserTableFields.seen.getCollumn()
Integer options = ToggleBarHandling.getPlayerOptionsAsInt(player.getUniqueId());
StringBuilder querry = new StringBuilder();
querry.append("UPDATE `" + DBTables.UsersTable.getTableName() + "` SET `" + UserTableFields.seen.getCollumn()
+ "` = ?, `" + UserTableFields.username.getCollumn()
+ "` = ?, `" + UserTableFields.donequests.getCollumn()
+ "` = ?, `" + UserTableFields.quests.getCollumn()
+ "` = ? WHERE `id` = ?;");
+ "` = ?, `" + UserTableFields.quests.getCollumn());
if (options != null)
querry.append("` = ?, `" + UserTableFields.messageOptions.getCollumn());
querry.append("` = ? WHERE `id` = ?;");
prest = conn.prepareStatement(querry.toString());
prest.setLong(1, System.currentTimeMillis());
prest.setString(2, player.getName());
prest.setInt(3, player.getDoneQuests());
prest.setString(4, player.getQuestProgressionString());
prest.setInt(5, player.getUserId());
// Only recording options if its not null
if (options != null)
prest.setInt(5, options);
// Shifting the index based on previous options on what we are saving
prest.setInt(options != null ? 6 : 5, player.getUserId());
prest.execute();
} catch (SQLException e) {
e.printStackTrace();
@ -2734,7 +2752,7 @@ public abstract class JobsDAO {
if (Jobs.getGCManager().useNewExploration)
return false;
JobsConnection conn = getConnection();
if (conn == null)
return false;

View File

@ -34,11 +34,9 @@ import com.gamingmesh.jobs.api.JobsInstancePaymentEvent;
import com.gamingmesh.jobs.api.JobsPaymentEvent;
import com.gamingmesh.jobs.container.CurrencyType;
import com.gamingmesh.jobs.container.MessageToggleState;
import com.gamingmesh.jobs.economy.BufferedPayment;
import com.gamingmesh.jobs.stuff.ToggleBarHandling;
import net.Zrips.CMILib.ActionBar.CMIActionBar;
import net.Zrips.CMILib.Logs.CMIDebug;
import net.Zrips.CMILib.Version.Version;
public class JobsPaymentVisualizationListener implements Listener {
@ -106,34 +104,37 @@ public class JobsPaymentVisualizationListener implements Listener {
if (event.getPlayer() == null || !event.getPlayer().isOnline() || event.getPayment().isEmpty())
return;
MessageToggleState state = ToggleBarHandling.getActionBarState(event.getPlayer().getUniqueId());
if (state.equals(MessageToggleState.Rapid))
return;
UUID playerUUID = event.getPlayer().getUniqueId();
Player abp = Bukkit.getPlayer(playerUUID);
if (abp == null)
Player player = Bukkit.getPlayer(playerUUID);
if (player == null)
return;
if (!Jobs.getGeneralConfigManager().ActionBarEnabled) {
String message = generateDelayedMessage(event.getPayment());
if (!message.isEmpty())
abp.sendMessage(message);
showChatMessage(player, event.getPayment());
return;
}
if (state.equals(MessageToggleState.Batched)) {
String message = generateDelayedMessage(event.getPayment());
if (!message.isEmpty())
CMIActionBar.send(abp, message);
MessageToggleState state = ToggleBarHandling.getActionBarState(event.getPlayer().getUniqueId());
if (!state.equals(MessageToggleState.Batched)) {
showChatMessage(player, event.getPayment());
return;
}
String message = generateDelayedMessage(event.getPayment());
if (!message.isEmpty())
CMIActionBar.send(player, message);
return;
}
private static void showChatMessage(Player player, Map<CurrencyType, Double> payment) {
MessageToggleState chatState = ToggleBarHandling.getChatTextState(player.getUniqueId());
if (chatState.equals(MessageToggleState.Off))
return;
String message = generateDelayedMessage(payment);
if (!message.isEmpty())
abp.sendMessage(message);
player.sendMessage(message);
}
private static String generateDelayedMessage(Map<CurrencyType, Double> payment) {
@ -176,7 +177,7 @@ public class JobsPaymentVisualizationListener implements Listener {
public void onJobsPaymentEventBossBar(JobsPaymentEvent event) {
if (event.isCancelled())
return;
if (event.getPlayer() == null || !event.getPlayer().isOnline())
return;

View File

@ -2,142 +2,120 @@ package com.gamingmesh.jobs.stuff;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.UUID;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.FileConfiguration;
import javax.annotation.Nullable;
import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.config.YmlMaker;
import com.gamingmesh.jobs.container.MessageToggleState;
import net.Zrips.CMILib.Container.CMINumber;
import com.gamingmesh.jobs.container.MessageToggleType;
public class ToggleBarHandling {
static Map<UUID, MessageToggleState> actionBarToggle = new HashMap<>();
static Map<UUID, MessageToggleState> bossBarToggle = new HashMap<>();
static Map<MessageToggleType, Map<UUID, MessageToggleState>> toggleMap = new HashMap<>();
public static void load() {
YmlMaker f = new YmlMaker(Jobs.getFolder(), "actionBarBossbar.yml");
if (!f.exists())
return;
private static int defaultStatesAsInt = 1000;
FileConfiguration config = f.getConfig();
if (Jobs.getGCManager().BossBarEnabled) {
ConfigurationSection section = config.getConfigurationSection("bossBar");
if (section != null) {
for (String one : section.getKeys(false)) {
MessageToggleState state = MessageToggleState.Rapid;
if (section.isBoolean(one)) {
if (!section.getBoolean(one))
state = MessageToggleState.Off;
} else if (section.isInt(one)) {
int id = section.getInt(one);
state = MessageToggleState.getFromID(id);
}
try {
bossBarToggle.put(UUID.fromString(one), state);
} catch (Throwable e) {
}
}
}
}
if (Jobs.getGCManager().ActionBarEnabled) {
ConfigurationSection section = config.getConfigurationSection("actionBar");
if (section != null) {
for (String one : section.getKeys(false)) {
MessageToggleState state = MessageToggleState.Rapid;
if (section.isBoolean(one)) {
if (!section.getBoolean(one))
state = MessageToggleState.Off;
} else if (section.isInt(one)) {
int id = section.getInt(one);
state = MessageToggleState.getFromID(id);
}
try {
actionBarToggle.put(UUID.fromString(one), state);
} catch (Throwable e) {
}
}
}
public static void init() {
StringBuilder result = new StringBuilder();
// Starts with 1 in case remaining are 0's to produce actual full digit number
result.append("1");
for (MessageToggleType one : MessageToggleType.values()) {
result.append(getDefaultState(one).ordinal());
}
defaultStatesAsInt = Integer.parseInt(result.toString());
}
public static void save() {
YmlMaker f = new YmlMaker(Jobs.getFolder(), "actionBarBossbar.yml");
if (bossBarToggle.isEmpty() && actionBarToggle.isEmpty()) {
if (f.exists() && f.getConfigFile().length() == 0L) {
f.getConfigFile().delete();
}
return;
}
if (!f.exists())
f.createNewFile();
f.saveDefaultConfig();
FileConfiguration config = f.getConfig();
if (Jobs.getGCManager().BossBarEnabled) {
config.set("bossBar", null);
if (!bossBarToggle.isEmpty()) {
for (Entry<UUID, MessageToggleState> one : bossBarToggle.entrySet()) {
if (!one.getValue().equals(Jobs.getGeneralConfigManager().BossBarsMessageDefault)) {
config.set("bossBar." + one.getKey().toString(), one.getValue());
}
}
}
}
config.set("actionBar", null);
if (!actionBarToggle.isEmpty()) {
for (Entry<UUID, MessageToggleState> one : actionBarToggle.entrySet()) {
if (!one.getValue().equals(Jobs.getGeneralConfigManager().ActionBarsMessageDefault)) {
config.set("actionBar." + one.getKey().toString(), one.getValue());
}
}
}
bossBarToggle.clear();
actionBarToggle.clear();
f.saveConfig();
}
@Deprecated
public static Map<UUID, MessageToggleState> getActionBarToggle() {
return actionBarToggle;
return toggleMap.getOrDefault(MessageToggleType.ActionBar, new HashMap<>());
}
@Deprecated
public static Map<UUID, MessageToggleState> getBossBarToggle() {
return bossBarToggle;
return toggleMap.getOrDefault(MessageToggleType.BossBar, new HashMap<>());
}
public static MessageToggleState modify(UUID uuid, MessageToggleType type, MessageToggleState state) {
synchronized (toggleMap) {
return toggleMap.computeIfAbsent(type, k -> new HashMap<>()).put(uuid, state);
}
}
public static MessageToggleState getActionBarState(UUID uuid) {
synchronized (actionBarToggle) {
return actionBarToggle.getOrDefault(uuid, Jobs.getGCManager().ActionBarsMessageDefault);
synchronized (toggleMap) {
return getState(uuid, MessageToggleType.ActionBar);
}
}
public static MessageToggleState getBossBarState(UUID uuid) {
synchronized (bossBarToggle) {
return bossBarToggle.getOrDefault(uuid, Jobs.getGCManager().BossBarsMessageDefault);
synchronized (toggleMap) {
return getState(uuid, MessageToggleType.BossBar);
}
}
public static MessageToggleState getChatTextState(UUID uuid) {
synchronized (toggleMap) {
return getState(uuid, MessageToggleType.ChatText);
}
}
public static MessageToggleState getState(UUID uuid, MessageToggleType type) {
synchronized (toggleMap) {
return toggleMap.getOrDefault(type, new HashMap<>()).getOrDefault(uuid, getDefaultState(type));
}
}
private static MessageToggleState getDefaultState(MessageToggleType type) {
switch (type) {
default:
case ActionBar:
return Jobs.getGCManager().ActionBarsMessageDefault;
case BossBar:
return Jobs.getGCManager().BossBarsMessageDefault;
case ChatText:
return Jobs.getGCManager().ChatTextMessageDefault;
}
}
public static @Nullable Integer getPlayerOptionsAsInt(UUID uuid) {
StringBuilder result = new StringBuilder();
// Starts with 1 in case remaining are 0's to produce actual full digit number
result.append("1");
for (MessageToggleType one : MessageToggleType.values()) {
result.append(getState(uuid, one).ordinal());
}
int options = Integer.parseInt(result.toString());
if (options == defaultStatesAsInt)
return null;
return options;
}
public static void recordPlayerOptionsFromInt(UUID uuid, @Nullable Integer options) {
// Value should be over 10 where first number isint part of options value
if (options == null || options < 10)
return;
int[] values = Integer
.toString(options)
// removing first number which should be 1 as a filler
.substring(1)
.chars()
.map(c -> c - '0')
.toArray();
for (MessageToggleType type : MessageToggleType.values()) {
if (type.ordinal() >= values.length)
break;
MessageToggleState state = MessageToggleState.getFromID(values[type.ordinal()]);
// Only recording if values isint default one
if (state != null && !getDefaultState(type).equals(state))
toggleMap.computeIfAbsent(type, k -> new HashMap<>()).put(uuid, state);
}
}
}