From 713ec7c8d9ea033b7603aaef7d3de2f923cb0c43 Mon Sep 17 00:00:00 2001 From: Mafrans Date: Fri, 1 Jun 2018 19:35:48 +0200 Subject: [PATCH] Add a command that shows social media links. Resolves #67 --- .../command/Command_links.java | 39 +++++++++++++++++++ src/main/resources/config.yml | 7 ++++ 2 files changed, 46 insertions(+) create mode 100644 src/main/java/me/totalfreedom/totalfreedommod/command/Command_links.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_links.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_links.java new file mode 100644 index 00000000..f378cc67 --- /dev/null +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_links.java @@ -0,0 +1,39 @@ +package me.totalfreedom.totalfreedommod.command; + +import org.bukkit.ChatColor; +import org.bukkit.command.Command; +import org.bukkit.command.CommandSender; +import org.bukkit.configuration.ConfigurationSection; +import org.bukkit.entity.Player; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +public class Command_links extends FreedomCommand { + @Override + protected boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) { + ConfigurationSection section = plugin.getConfig().getConfigurationSection("social_links"); + Map values = section.getValues(false); + + List lines = new ArrayList<>(); + + for(String key : values.keySet()) { + if(!(values.get(key) instanceof String)) { + continue; + } + + String link = (String) values.get(key); + + lines.add(ChatColor.GOLD + "- " + key + ": " + ChatColor.AQUA + link); + } + if(lines.size() == 0) { + lines.add(ChatColor.GOLD + "- There are no links currently added in the config"); + } + + lines.add(ChatColor.AQUA + "TotalFreedom Social Media Links:"); + sender.sendMessage(lines.toArray(new String[0])); + + return true; + } +} diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 70457fd4..7215193c 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -61,6 +61,13 @@ forceip: # The kick message sent to players when logging in with the wrong hostname kickmsg: You have been kicked from the server - Please connect using %address% +# TotalFreedom Social Media Links, casing will be preserved +social_links: + Forum: 'https://totalfreedom.boards.net/' + Website: 'https://totalfreedom.me/' + Discord: 'https://discordapp.com/invite/XXjmAmV/' + + # Blocking certain events allow: fire_place: false