guildinfo

This commit is contained in:
speedxx 2020-06-22 13:51:32 -04:00
parent 592dafb83f
commit 7a91293988
5 changed files with 61 additions and 4 deletions

View file

@ -6,7 +6,7 @@
<groupId>me.totalfreedom</groupId>
<artifactId>TFGuilds</artifactId>
<version>0.1.1</version>
<version>0.1.2</version>
<packaging>jar</packaging>
<name>TFGuilds</name>

View file

@ -46,6 +46,7 @@ public final class TFGuilds extends JavaPlugin
this.getCommand("inviteguild").setExecutor(new InviteGuildCommand());
this.getCommand("leaveguild").setExecutor(new LeaveGuildCommand());
this.getCommand("guildkick").setExecutor(new GuildKickCommand());
this.getCommand("guildinfo").setExecutor(new GuildInfoCommand());
}
private void enableListeners()

View file

@ -0,0 +1,42 @@
package me.totalfreedom.tfguilds.command;
import me.totalfreedom.tfguilds.util.GBase;
import me.totalfreedom.tfguilds.util.GUtil;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import java.util.List;
public class GuildInfoCommand extends GBase implements CommandExecutor
{
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args)
{
Player player = (Player) sender;
String guild = GUtil.getGuild(player);
if (guild == null)
{
sender.sendMessage(ChatColor.RED + "You aren't in a guild!");
return true;
}
String owner = GUtil.getOwner(guild);
String tag = GUtil.getTag(guild);
String creation = GUtil.getTimeCreated(guild);
List<String> members = GUtil.getMember(guild);
player.sendMessage(GUtil.color("&2-=-=-=- &aGuild Information &2-=-=-=-"));
player.sendMessage(GUtil.color("&2Guild Name: &a" + guild));
player.sendMessage(GUtil.color("&2Guild Owner: &a" + owner));
player.sendMessage(GUtil.color("&2Guild Tag: &a" + tag));
player.sendMessage(GUtil.color("&2Guild Creation Date: &a" + creation));
player.sendMessage(GUtil.color("&2Member Count: &a" + members.size()));
player.sendMessage(GUtil.color("&2Members: &a" + members));
player.sendMessage(GUtil.color("&2-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-="));
return true;
}
}

View file

@ -9,7 +9,10 @@ import org.bukkit.entity.Player;
import me.totalfreedom.tfguilds.TFGuilds;
import org.bukkit.scheduler.BukkitRunnable;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
@ -31,6 +34,11 @@ public class GUtil
List<String> players = plugin.guilds.getStringList("guilds." + guildName + ".members");
players.add(owner.getName());
plugin.guilds.set("guilds." + guildName + ".members", players);
plugin.guilds.set("guilds." + guildName + ".tag", GUtil.color("&8[&7" + guildName + "&8]&r "));
DateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
Date date = new Date();
plugin.guilds.set("guilds." + guildName + ".created", dateFormat.format(date));
plugin.guilds.save();
GLog.info(owner.getName() + " has created a new guild: " + guildName);
@ -40,8 +48,6 @@ public class GUtil
{
GLog.info("Removing guilds.yml data for " + getGuild((Player) owner));
plugin.guilds.set("guilds." + getGuild((Player) owner), null);
plugin.guilds.set("guilds." + getGuild((Player) owner) + ".owner", null);
plugin.guilds.set("guilds." + getGuild((Player) owner) + ".members", null);
plugin.guilds.save();
}
@ -74,6 +80,11 @@ public class GUtil
return plugin.guilds.getString("guilds." + guildName + ".tag");
}
public static String getTimeCreated(String guildName)
{
return plugin.guilds.getString("guilds." + guildName + ".created");
}
public static boolean hasTag(String guildName)
{
return plugin.guilds.contains("guilds." + guildName + ".tag");

View file

@ -40,4 +40,7 @@ commands:
aliases: [guildleave]
guildkick:
description: Kicks a player from the guild
usage: /<command> <player>
usage: /<command> <player>
guildinfo:
description: Gives you information about any guild
usage: /<command>