1
0
mirror of https://github.com/Zrips/Jobs.git synced 2025-01-02 14:29:07 +01:00

Option to set specific message toggle state

This commit is contained in:
Zrips 2024-09-29 14:54:40 +03:00
parent 9ed7956d62
commit 224bb6e150
3 changed files with 29 additions and 17 deletions

View File

@ -26,26 +26,38 @@ public class toggle implements Cmd {
return null;
}
Player player = (Player) sender;
UUID playerUUID = player.getUniqueId();
UUID playerUUID = ((Player) sender).getUniqueId();
MessageToggleType type = null;
MessageToggleState state = null;
if (args.length == 1) {
for (String one : args) {
if (type == null) {
type = MessageToggleType.getByName(one);
if (type != null)
continue;
}
switch (args[0].toLowerCase()) {
case "actionbar":
toggleState(sender, playerUUID, MessageToggleType.ActionBar);
if (state == null) {
state = MessageToggleState.getByName(one);
if (state != null)
continue;
}
}
if (type != null) {
switch (type) {
case ChatText:
case ActionBar:
toggleState(sender, playerUUID, type, state);
return true;
case "bossbar":
toggleState(sender, playerUUID, MessageToggleType.BossBar);
if (ToggleBarHandling.getState(playerUUID, MessageToggleType.BossBar).equals(MessageToggleState.Off)) {
case BossBar:
toggleState(sender, playerUUID, type, state);
if (ToggleBarHandling.getState(playerUUID, type).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;
}
}
@ -57,8 +69,8 @@ public class toggle implements Cmd {
return true;
}
private static void toggleState(CommandSender sender, UUID uuid, MessageToggleType type) {
MessageToggleState state = ToggleBarHandling.getState(uuid, type).getNext();
private static void toggleState(CommandSender sender, UUID uuid, MessageToggleType type, MessageToggleState state) {
state = state != null ? state : ToggleBarHandling.getState(uuid, type).getNext();
if (type.equals(MessageToggleType.ChatText) && state.equals(MessageToggleState.Rapid))
state = state.getNext();

View File

@ -995,7 +995,7 @@ public class GeneralConfigManager {
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()));
ChatTextMessageDefault = MessageToggleState.getByName(c.get("ChatText.Messages.DefaultState", MessageToggleState.Off.toString()));
c.addComment("ActionBars.Enabled", "Enables ActionBar messages");
ActionBarEnabled = c.get("ActionBars.Enabled", true);
@ -1013,7 +1013,7 @@ public class GeneralConfigManager {
BossBarEnabled = c.get("BossBar.Enabled", true);
c.addComment("BossBar.Messages.DefaultState", "When this set to true player will see Bossbar messages by default");
BossBarsMessageDefault = MessageToggleState.getByName(c.get("BossBar.Messages.DefaultState", MessageToggleState.Rapid.toString()));
BossBarsMessageDefault = MessageToggleState.getByName(c.get("BossBar.Messages.DefaultState", MessageToggleState.Batched.toString()));
c.addComment("BossBar.SegmentCount", "Defines in how many parts bossbar will be split visually", "Valid options: 1, 6, 10, 12, 20");
SegmentCount = c.get("BossBar.SegmentCount", 1);

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%%chattext"));
Jobs.getGCManager().getCommandArgs().put("toggle", Arrays.asList("actionbar%%bossbar%%chattext", "off%%rapid%%batched"));
c.get("command.toggle.output.turnedoff", "&4This feature is turned off!");
c.get("command.toggle.output.paid.main", "&aYou got:");