From 22dc2721d7e02195776d1480f1b889ef02bc95da Mon Sep 17 00:00:00 2001 From: Dave Akers Date: Sat, 1 Sep 2018 17:52:47 -0500 Subject: [PATCH] Broadcast messages --- .../java/bentobox/addon/challenges/ChallengesAddon.java | 7 +++++++ .../bentobox/addon/challenges/panel/TryToComplete.java | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/src/main/java/bentobox/addon/challenges/ChallengesAddon.java b/src/main/java/bentobox/addon/challenges/ChallengesAddon.java index f25d260..4d13d78 100644 --- a/src/main/java/bentobox/addon/challenges/ChallengesAddon.java +++ b/src/main/java/bentobox/addon/challenges/ChallengesAddon.java @@ -6,6 +6,7 @@ import bentobox.addon.challenges.commands.ChallengesCommand; import bentobox.addon.challenges.commands.admin.Challenges; import world.bentobox.bentobox.api.addons.Addon; import world.bentobox.bentobox.api.commands.CompositeCommand; +import world.bentobox.bentobox.api.configuration.Config; /** * Add-on to BSkyBlock that enables challenges @@ -18,6 +19,12 @@ public class ChallengesAddon extends Addon { private String permissionPrefix = "addon"; private FreshSqueezedChallenges importManager; + @Override + public void onLoad() { + // Save default config.yml + saveDefaultConfig(); + } + @Override public void onEnable() { // Check if it is enabled - it might be loaded, but not enabled. diff --git a/src/main/java/bentobox/addon/challenges/panel/TryToComplete.java b/src/main/java/bentobox/addon/challenges/panel/TryToComplete.java index f108dd7..3872a1b 100644 --- a/src/main/java/bentobox/addon/challenges/panel/TryToComplete.java +++ b/src/main/java/bentobox/addon/challenges/panel/TryToComplete.java @@ -11,6 +11,7 @@ import java.util.Map; import org.bukkit.Material; import org.bukkit.World; import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import org.bukkit.util.Vector; @@ -71,6 +72,12 @@ public class TryToComplete { // Run commands runCommands(challenge.getRewardCommands()); user.sendMessage("challenges.you-completed", "[challenge]", challenge.getFriendlyName()); + if (addon.getConfig().getBoolean("broadcastmessages", false)) { + for (Player p : addon.getServer().getOnlinePlayers()) { + User.getInstance(p).sendMessage("challenges.name-has-completed", + "[name]", user.getName(), "[challenge]", challenge.getFriendlyName()); + } + } } else { // Give rewards for (ItemStack reward : challenge.getRepeatItemReward()) {