Merge pull request #13 from dazoe/broadcast-messages

Broadcast messages
This commit is contained in:
tastybento 2018-09-02 08:09:41 +08:00 committed by GitHub
commit 516fe3f8d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 0 deletions

View File

@ -6,6 +6,7 @@ import bentobox.addon.challenges.commands.ChallengesCommand;
import bentobox.addon.challenges.commands.admin.Challenges; import bentobox.addon.challenges.commands.admin.Challenges;
import world.bentobox.bentobox.api.addons.Addon; import world.bentobox.bentobox.api.addons.Addon;
import world.bentobox.bentobox.api.commands.CompositeCommand; import world.bentobox.bentobox.api.commands.CompositeCommand;
import world.bentobox.bentobox.api.configuration.Config;
/** /**
* Add-on to BSkyBlock that enables challenges * Add-on to BSkyBlock that enables challenges
@ -18,6 +19,12 @@ public class ChallengesAddon extends Addon {
private String permissionPrefix = "addon"; private String permissionPrefix = "addon";
private FreshSqueezedChallenges importManager; private FreshSqueezedChallenges importManager;
@Override
public void onLoad() {
// Save default config.yml
saveDefaultConfig();
}
@Override @Override
public void onEnable() { public void onEnable() {
// Check if it is enabled - it might be loaded, but not enabled. // Check if it is enabled - it might be loaded, but not enabled.

View File

@ -11,6 +11,7 @@ import java.util.Map;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
@ -71,6 +72,12 @@ public class TryToComplete {
// Run commands // Run commands
runCommands(challenge.getRewardCommands()); runCommands(challenge.getRewardCommands());
user.sendMessage("challenges.you-completed", "[challenge]", challenge.getFriendlyName()); 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 { } else {
// Give rewards // Give rewards
for (ItemStack reward : challenge.getRepeatItemReward()) { for (ItemStack reward : challenge.getRepeatItemReward()) {