2018-06-01 17:35:48 +00:00
|
|
|
package me.totalfreedom.totalfreedommod.command;
|
|
|
|
|
2018-07-31 07:01:29 +00:00
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Map;
|
2018-06-05 10:36:20 +00:00
|
|
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
2018-06-01 17:35:48 +00:00
|
|
|
import org.bukkit.ChatColor;
|
|
|
|
import org.bukkit.command.Command;
|
|
|
|
import org.bukkit.command.CommandSender;
|
|
|
|
import org.bukkit.configuration.ConfigurationSection;
|
2018-06-29 19:15:36 +00:00
|
|
|
import org.bukkit.configuration.file.YamlConfiguration;
|
2018-06-01 17:35:48 +00:00
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
|
2018-06-02 21:15:18 +00:00
|
|
|
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH)
|
2020-03-30 23:43:57 +00:00
|
|
|
@CommandParameters(description = "See TotalFreedom's social media links.", usage = "/<command>", aliases = "link")
|
2018-06-02 21:09:58 +00:00
|
|
|
public class Command_links extends FreedomCommand
|
|
|
|
{
|
2018-06-01 17:35:48 +00:00
|
|
|
@Override
|
2020-07-01 01:51:06 +00:00
|
|
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
2018-06-02 21:09:58 +00:00
|
|
|
{
|
2018-06-29 19:15:36 +00:00
|
|
|
YamlConfiguration config = plugin.config.configuration;
|
|
|
|
ConfigurationSection section = config.getConfigurationSection("social_links");
|
2018-06-08 08:21:10 +00:00
|
|
|
if (section != null)
|
|
|
|
{
|
|
|
|
Map<String, Object> values = section.getValues(false);
|
2018-06-01 17:35:48 +00:00
|
|
|
|
2018-06-08 08:21:10 +00:00
|
|
|
List<String> lines = new ArrayList<>();
|
2018-06-01 17:35:48 +00:00
|
|
|
|
2018-06-08 08:21:10 +00:00
|
|
|
for (String key : values.keySet())
|
2018-06-02 21:09:58 +00:00
|
|
|
{
|
2018-06-08 08:21:10 +00:00
|
|
|
if (!(values.get(key) instanceof String))
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
2018-07-31 07:01:29 +00:00
|
|
|
String link = (String)values.get(key);
|
2018-06-08 08:21:10 +00:00
|
|
|
lines.add(ChatColor.GOLD + "- " + key + ": " + ChatColor.AQUA + link);
|
2018-06-01 17:35:48 +00:00
|
|
|
}
|
|
|
|
|
2018-06-08 13:34:10 +00:00
|
|
|
msg("Social Media Links:", ChatColor.AQUA);
|
2018-06-19 09:01:51 +00:00
|
|
|
sender.sendMessage(lines.toArray(new String[0]));
|
2018-06-08 08:21:10 +00:00
|
|
|
return true;
|
2018-06-01 17:35:48 +00:00
|
|
|
}
|
2018-06-08 08:21:10 +00:00
|
|
|
else
|
2018-06-02 21:09:58 +00:00
|
|
|
{
|
2018-06-08 13:34:10 +00:00
|
|
|
msg("There are no links added in the configuration file.", ChatColor.RED);
|
2018-06-01 17:35:48 +00:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|