From eaa49306c56444f7eab7dab04954bb4563267da9 Mon Sep 17 00:00:00 2001 From: Taylor Becker Date: Sun, 13 Mar 2016 22:59:21 -0400 Subject: [PATCH] Added support for sets of messages Added messages config option for a list of message strings Added random-order config option to toggle sequential vs random Added example config for message set and improved auto generated config Refactored loading messages from config Removed RepeatingMessage class since its only purpose was to hold a variable that was only used once Incremented version number to 1.9.1 --- .../simpleannounce/SimpleAnnounce.java | 202 ++++++++++++------ .../simpleannounce/message/Message.java | 6 +- .../simpleannounce/message/MessageGroup.java | 64 ++++++ .../message/RepeatingMessage.java | 35 --- .../message/sender/BossBarSender.java | 22 +- src/main/resources/plugin.yml | 2 +- 6 files changed, 215 insertions(+), 116 deletions(-) create mode 100755 src/main/java/org/simplemc/simpleannounce/message/MessageGroup.java delete mode 100755 src/main/java/org/simplemc/simpleannounce/message/RepeatingMessage.java diff --git a/src/main/java/org/simplemc/simpleannounce/SimpleAnnounce.java b/src/main/java/org/simplemc/simpleannounce/SimpleAnnounce.java index da737ef..db716f5 100755 --- a/src/main/java/org/simplemc/simpleannounce/SimpleAnnounce.java +++ b/src/main/java/org/simplemc/simpleannounce/SimpleAnnounce.java @@ -1,5 +1,6 @@ package org.simplemc.simpleannounce; +import java.util.Arrays; import java.util.LinkedList; import java.util.List; import java.util.Set; @@ -14,7 +15,7 @@ import org.bukkit.plugin.java.JavaPlugin; import org.simplemc.simpleannounce.message.Message; -import org.simplemc.simpleannounce.message.RepeatingMessage; +import org.simplemc.simpleannounce.message.MessageGroup; import org.simplemc.simpleannounce.message.sender.BossBarSender; import org.simplemc.simpleannounce.message.sender.ChatMessageSender; import org.simplemc.simpleannounce.message.sender.MessageSender; @@ -108,17 +109,33 @@ private void validateConfig() // messages if (!getConfig().contains("messages")) { - getConfig().set("messages.default1.message", "This is an automatically generated repeating message!"); - getConfig().set("messages.default1.delay", 15); - getConfig().set("messages.default1.repeat", 60); - getConfig().set("messages.default2.message", "This is another automatically generated repeating message for people with build permission!"); - getConfig().set("messages.default2.delay", 30); - getConfig().set("messages.default2.repeat", 60); - List df2Includes = new LinkedList<>(); - df2Includes.add("permissions.build"); - getConfig().set("messages.default2.includesperms", df2Includes); - getConfig().set("messages.default3.message", "This is an automatically generated one-time message!"); - getConfig().set("messages.default3.delay", 45); + // example repeating message + getConfig().set("messages.repeating-example.message", "This is an automatically generated repeating message!"); + getConfig().set("messages.repeating-example.delay", 15); + getConfig().set("messages.repeating-example.repeat", 60); + + // example repeating message with perms + getConfig().set("messages.permissions-example.message", "This is another automatically generated repeating message for people with build permission!"); + getConfig().set("messages.permissions-example.delay", 30); + getConfig().set("messages.permissions-example.repeat", 60); + getConfig().set("messages.permissions-example.includesperms", Arrays.asList(new String[]{"permissions.build"})); + + // example one time message + getConfig().set("messages.one-time-example.message", "This is an automatically generated one-time message!"); + getConfig().set("messages.one-time-example.delay", 45); + + // example message group with boss bar sender + getConfig().set("messages.message-group-example.messages", + Arrays.asList(new String[] + { + "This is an automatically generated sequential message group (1 of 3)!", + "This is an automatically generated sequential message group (2 of 3)!", + "This is an automatically generated sequential message group (3 of 3)!" + })); + getConfig().set("messages.message-group-example.delay", 30); + getConfig().set("messages.message-group-example.repeat", 30); + getConfig().set("messages.message-group-example.sender", "bossbar"); + getConfig().set("messages.message-group-example.random-order", false); updated = true; } @@ -138,7 +155,8 @@ private void validateConfig() "-------------------------\n" + "\n" + "(String, must be unique):\n" + - " message(String, required): \n" + + " message(String, required) OR messages(String list, see sample config): \n" + + " random-order(boolean, optional): \n" + " sender(String, optional): \n" + " bar(section, optional):\n" + " hold(int, optional):