mirror of
https://github.com/TotalFreedomMC/TFGuilds.git
synced 2024-12-22 16:05:00 +00:00
the usage is still absolutely awful
This commit is contained in:
parent
3a3f402812
commit
121d569721
14 changed files with 541 additions and 11 deletions
|
@ -6,6 +6,7 @@ import me.totalfreedom.tfguilds.command.GuildCommand;
|
|||
import me.totalfreedom.tfguilds.command.TFGuildsCommand;
|
||||
import me.totalfreedom.tfguilds.config.Config;
|
||||
import me.totalfreedom.tfguilds.listener.ChatListener;
|
||||
import me.totalfreedom.tfguilds.listener.JoinListener;
|
||||
import me.totalfreedom.tfguilds.util.GLog;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
@ -54,5 +55,6 @@ public final class TFGuilds extends JavaPlugin
|
|||
{
|
||||
PluginManager manager = this.getServer().getPluginManager();
|
||||
manager.registerEvents(new ChatListener(), this);
|
||||
manager.registerEvents(new JoinListener(), this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
package me.totalfreedom.tfguilds.command;
|
||||
|
||||
import me.totalfreedom.tfguilds.Common;
|
||||
import me.totalfreedom.tfguilds.guild.Guild;
|
||||
import me.totalfreedom.tfguilds.util.GUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class CreateRankSubcommand extends Common implements CommandExecutor
|
||||
{
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args)
|
||||
{
|
||||
if (sender instanceof ConsoleCommandSender)
|
||||
{
|
||||
sender.sendMessage(NO_PERMS);
|
||||
return true;
|
||||
}
|
||||
Player player = (Player) sender;
|
||||
Guild guild = Guild.getGuild(player);
|
||||
if (guild == null)
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "You aren't in a guild!");
|
||||
return true;
|
||||
}
|
||||
if (!guild.getOwner().equals(player.getName()))
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "You can't change the name of your guild!");
|
||||
return true;
|
||||
}
|
||||
String rank = StringUtils.join(args, " ", 1, args.length);
|
||||
if (guild.hasRank(rank))
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "A rank of that name already exists in the guild!");
|
||||
return true;
|
||||
}
|
||||
guild.addRank(rank);
|
||||
sender.sendMessage(tl(PREFIX + "Created a new rank named %s%" + rank + "%p% for your guild."));
|
||||
guild.save();
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
package me.totalfreedom.tfguilds.command;
|
||||
|
||||
import me.totalfreedom.tfguilds.Common;
|
||||
import me.totalfreedom.tfguilds.guild.Guild;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class DeleteRankSubcommand extends Common implements CommandExecutor
|
||||
{
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args)
|
||||
{
|
||||
if (sender instanceof ConsoleCommandSender)
|
||||
{
|
||||
sender.sendMessage(NO_PERMS);
|
||||
return true;
|
||||
}
|
||||
Player player = (Player) sender;
|
||||
Guild guild = Guild.getGuild(player);
|
||||
if (guild == null)
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "You aren't in a guild!");
|
||||
return true;
|
||||
}
|
||||
if (!guild.getOwner().equals(player.getName()))
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "You can't change the name of your guild!");
|
||||
return true;
|
||||
}
|
||||
String rank = StringUtils.join(args, " ", 1, args.length);
|
||||
if (!guild.hasRank(rank))
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "A rank of that name does not exist in the guild!");
|
||||
return true;
|
||||
}
|
||||
guild.removeRank(rank);
|
||||
sender.sendMessage(tl(PREFIX + "Deleted the rank named %s%" + rank + "%p% in your guild."));
|
||||
guild.save();
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -31,6 +31,12 @@ public class GuildCommand extends Common implements CommandExecutor
|
|||
case "chat": return new ChatSubcommand().onCommand(sender, command, label, args);
|
||||
case "saveconfig": return new SaveConfigSubcommand().onCommand(sender, command, label, args);
|
||||
case "join": return new JoinSubcommand().onCommand(sender, command, label, args);
|
||||
case "rename": return new RenameSubcommand().onCommand(sender, command, label, args);
|
||||
case "createrank": return new CreateRankSubcommand().onCommand(sender, command, label, args);
|
||||
case "deleterank": return new DeleteRankSubcommand().onCommand(sender, command, label, args);
|
||||
case "setrank": return new SetRankSubcommand().onCommand(sender, command, label, args);
|
||||
case "motd": return new MOTDSubcommand().onCommand(sender, command, label, args);
|
||||
case "home": return new HomeSubcommand().onCommand(sender, command, label, args);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -24,6 +24,13 @@ public class HelpSubcommand extends Common implements CommandExecutor
|
|||
sender.sendMessage(tl("%s% - %p%tp <player>"));
|
||||
sender.sendMessage(tl("%s% - %p%info [guild]"));
|
||||
sender.sendMessage(tl("%s% - %p%tag <set <tag> | clear>"));
|
||||
sender.sendMessage(tl("%s% - %p%rename <name>"));
|
||||
sender.sendMessage(tl("%s% - %p%createrank <name>"));
|
||||
sender.sendMessage(tl("%s% - %p%deleterank <rank>"));
|
||||
sender.sendMessage(tl("%s% - %p%setrank <player> <rank | none>"));
|
||||
sender.sendMessage(tl("%s% - %p%motd <set <motd> | clear>"));
|
||||
sender.sendMessage(tl("%s% - %p%home [set]"));
|
||||
sender.sendMessage(tl("%s% - %p%chat [message]"));
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
package me.totalfreedom.tfguilds.command;
|
||||
|
||||
import me.totalfreedom.tfguilds.Common;
|
||||
import me.totalfreedom.tfguilds.guild.Guild;
|
||||
import me.totalfreedom.tfguilds.util.GUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class HomeSubcommand extends Common implements CommandExecutor
|
||||
{
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args)
|
||||
{
|
||||
if (sender instanceof ConsoleCommandSender)
|
||||
{
|
||||
sender.sendMessage(NO_PERMS);
|
||||
return true;
|
||||
}
|
||||
Player player = (Player) sender;
|
||||
Guild guild = Guild.getGuild(player);
|
||||
if (guild == null)
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "You aren't in a guild!");
|
||||
return true;
|
||||
}
|
||||
if (args.length == 2)
|
||||
{
|
||||
if (args[1].equalsIgnoreCase("set"))
|
||||
{
|
||||
if (!guild.hasModerator(player.getName()))
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "You can't modify your guild's home!");
|
||||
return true;
|
||||
}
|
||||
guild.setHome(player.getLocation());
|
||||
guild.save();
|
||||
sender.sendMessage(tl(PREFIX + "Set your current location as the new home of your guild%p%."));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (!guild.hasHome())
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "Your guild doesn't have a home!");
|
||||
return true;
|
||||
}
|
||||
player.teleport(guild.getHome());
|
||||
sender.sendMessage(tl("%p%Teleported you to your guild's home!"));
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
package me.totalfreedom.tfguilds.command;
|
||||
|
||||
import me.totalfreedom.tfguilds.Common;
|
||||
import me.totalfreedom.tfguilds.guild.Guild;
|
||||
import me.totalfreedom.tfguilds.guild.GuildRank;
|
||||
import me.totalfreedom.tfguilds.util.GUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class MOTDSubcommand extends Common implements CommandExecutor
|
||||
{
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args)
|
||||
{
|
||||
if (sender instanceof ConsoleCommandSender)
|
||||
{
|
||||
sender.sendMessage(NO_PERMS);
|
||||
return true;
|
||||
}
|
||||
Player player = (Player) sender;
|
||||
Guild guild = Guild.getGuild(player);
|
||||
if (guild == null)
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "You aren't in a guild!");
|
||||
return true;
|
||||
}
|
||||
if (!guild.hasModerator(player.getName()))
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "You can't modify your guild's MOTD!");
|
||||
return true;
|
||||
}
|
||||
if (args.length >= 3)
|
||||
{
|
||||
if (args[1].equalsIgnoreCase("set"))
|
||||
{
|
||||
String motd = StringUtils.join(args, " ", 2, args.length);
|
||||
guild.setMotd(motd);
|
||||
guild.save();
|
||||
sender.sendMessage(tl(PREFIX + "Set %s%" + GUtil.colorize(motd) + "%p% as the new MOTD of your guild%p%."));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (!args[1].equalsIgnoreCase("clear"))
|
||||
return false;
|
||||
guild.setMotd(null);
|
||||
guild.save();
|
||||
sender.sendMessage(tl(PREFIX + "Cleared your guild's MOTD."));
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
package me.totalfreedom.tfguilds.command;
|
||||
|
||||
import me.totalfreedom.tfguilds.Common;
|
||||
import me.totalfreedom.tfguilds.guild.Guild;
|
||||
import me.totalfreedom.tfguilds.util.GUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class RenameSubcommand extends Common implements CommandExecutor
|
||||
{
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args)
|
||||
{
|
||||
if (sender instanceof ConsoleCommandSender)
|
||||
{
|
||||
sender.sendMessage(NO_PERMS);
|
||||
return true;
|
||||
}
|
||||
Player player = (Player) sender;
|
||||
Guild guild = Guild.getGuild(player);
|
||||
if (guild == null)
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "You aren't in a guild!");
|
||||
return true;
|
||||
}
|
||||
if (!guild.getOwner().equals(player.getName()))
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "You can't change the name of your guild!");
|
||||
return true;
|
||||
}
|
||||
String newName = StringUtils.join(args, " ", 1, args.length);
|
||||
guild.disband();
|
||||
guild.setIdentifier(GUtil.flatten(newName));
|
||||
guild.setName(newName);
|
||||
sender.sendMessage(tl(PREFIX + "Set %s%" + GUtil.colorize(newName) + "%p% as the new name of your guild%p%."));
|
||||
guild.broadcast(tl("%p%Your guild has been renamed to " + GUtil.colorize(newName) + "%p%."));
|
||||
guild.save();
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,74 @@
|
|||
package me.totalfreedom.tfguilds.command;
|
||||
|
||||
import me.totalfreedom.tfguilds.Common;
|
||||
import me.totalfreedom.tfguilds.guild.Guild;
|
||||
import me.totalfreedom.tfguilds.guild.GuildRank;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class SetRankSubcommand extends Common implements CommandExecutor
|
||||
{
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args)
|
||||
{
|
||||
if (sender instanceof ConsoleCommandSender)
|
||||
{
|
||||
sender.sendMessage(NO_PERMS);
|
||||
return true;
|
||||
}
|
||||
Player player = (Player) sender;
|
||||
Guild guild = Guild.getGuild(player);
|
||||
if (guild == null)
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "You aren't in a guild!");
|
||||
return true;
|
||||
}
|
||||
if (!guild.hasModerator(player.getName()))
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "You can't change the ranks of your guild members!");
|
||||
return true;
|
||||
}
|
||||
Player r = Bukkit.getPlayer(args[1]);
|
||||
if (r == null)
|
||||
{
|
||||
sender.sendMessage(PNF);
|
||||
return true;
|
||||
}
|
||||
if (!guild.hasMember(r.getName()))
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "This player is not in your guild!");
|
||||
return true;
|
||||
}
|
||||
String name = StringUtils.join(args, " ", 2, args.length);
|
||||
if (name.toLowerCase().equals("members") ||
|
||||
name.toLowerCase().equals("member") ||
|
||||
name.toLowerCase().equals("none"))
|
||||
{
|
||||
for (GuildRank gr : guild.getRanks())
|
||||
gr.getMembers().remove(r.getName());
|
||||
sender.sendMessage(tl(PREFIX + "Removed the rank of %s%" + r.getName() + "%p% in your guild."));
|
||||
r.sendMessage(tl("%p%Your rank in your guild has been removed."));
|
||||
guild.save();
|
||||
return true;
|
||||
}
|
||||
GuildRank rank = guild.getRank(name);
|
||||
if (rank == null)
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "A rank of that name does not exist in the guild!");
|
||||
return true;
|
||||
}
|
||||
for (GuildRank gr : guild.getRanks())
|
||||
gr.getMembers().remove(r.getName());
|
||||
rank.getMembers().add(r.getName());
|
||||
sender.sendMessage(tl(PREFIX + "Set the rank of %s%" + r.getName() + "%p% in your guild to %s%" + rank.getName() + "%p%."));
|
||||
r.sendMessage(tl("%p%Your rank in your guild has been set to %s%" + rank.getName() + "%p%."));
|
||||
guild.save();
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -8,7 +8,8 @@ import me.totalfreedom.tfguilds.util.GUtil;
|
|||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -20,10 +21,12 @@ public class Guild
|
|||
private static TFGuilds plugin = TFGuilds.getPlugin();
|
||||
|
||||
@Getter
|
||||
private final String identifier;
|
||||
@Setter
|
||||
private String identifier;
|
||||
|
||||
@Getter
|
||||
private final String name;
|
||||
@Setter
|
||||
private String name;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
|
@ -43,10 +46,31 @@ public class Guild
|
|||
@Setter
|
||||
private GuildState state;
|
||||
|
||||
@Getter
|
||||
private List<GuildRank> ranks;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private String motd;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private Location home;
|
||||
|
||||
@Getter
|
||||
private final long creation;
|
||||
|
||||
public Guild(String identifier, String name, String owner, List<String> members, List<String> moderators, String tag, GuildState state, long creation)
|
||||
public Guild(String identifier,
|
||||
String name,
|
||||
String owner,
|
||||
List<String> members,
|
||||
List<String> moderators,
|
||||
String tag,
|
||||
GuildState state,
|
||||
List<GuildRank> ranks,
|
||||
String motd,
|
||||
Location home,
|
||||
long creation)
|
||||
{
|
||||
this.identifier = identifier;
|
||||
this.name = name;
|
||||
|
@ -55,6 +79,9 @@ public class Guild
|
|||
this.moderators = moderators;
|
||||
this.tag = tag;
|
||||
this.state = state;
|
||||
this.ranks = ranks;
|
||||
this.motd = motd;
|
||||
this.home = home;
|
||||
this.creation = creation;
|
||||
}
|
||||
|
||||
|
@ -66,6 +93,10 @@ public class Guild
|
|||
plugin.guilds.set(identifier + ".moderators", moderators);
|
||||
plugin.guilds.set(identifier + ".tag", tag);
|
||||
plugin.guilds.set(identifier + ".state", state.name());
|
||||
for (GuildRank rank : ranks)
|
||||
rank.set();
|
||||
plugin.guilds.set(identifier + ".motd", motd);
|
||||
plugin.guilds.set(identifier + ".home", home);
|
||||
plugin.guilds.set(identifier + ".creation", creation);
|
||||
plugin.guilds.save();
|
||||
}
|
||||
|
@ -106,11 +137,60 @@ public class Guild
|
|||
return moderators.contains(name);
|
||||
}
|
||||
|
||||
public void addRank(String name)
|
||||
{
|
||||
ranks.add(new GuildRank(identifier, GUtil.flatten(name), name, new ArrayList<>()));
|
||||
}
|
||||
|
||||
public void removeRank(String name)
|
||||
{
|
||||
GuildRank remove = null;
|
||||
for (GuildRank rank : ranks)
|
||||
{
|
||||
if (GUtil.flatten(name).equals(rank.getIdentifier()))
|
||||
remove = rank;
|
||||
}
|
||||
if (remove == null)
|
||||
return;
|
||||
remove.delete();
|
||||
ranks.remove(remove);
|
||||
}
|
||||
|
||||
public boolean hasRank(String name)
|
||||
{
|
||||
for (GuildRank rank : ranks)
|
||||
{
|
||||
if (GUtil.flatten(name).equals(rank.getIdentifier()))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public GuildRank getRank(String name)
|
||||
{
|
||||
for (GuildRank rank : ranks)
|
||||
{
|
||||
if (GUtil.flatten(name).equals(rank.getIdentifier()))
|
||||
return rank;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean hasTag()
|
||||
{
|
||||
return tag != null;
|
||||
}
|
||||
|
||||
public boolean hasMOTD()
|
||||
{
|
||||
return motd != null;
|
||||
}
|
||||
|
||||
public boolean hasHome()
|
||||
{
|
||||
return home != null;
|
||||
}
|
||||
|
||||
public void broadcast(String message)
|
||||
{
|
||||
for (Player player : Bukkit.getOnlinePlayers())
|
||||
|
@ -134,12 +214,27 @@ public class Guild
|
|||
return only;
|
||||
}
|
||||
|
||||
public List<String> getRankNames()
|
||||
{
|
||||
List<String> names = new ArrayList<>();
|
||||
for (GuildRank rank : ranks)
|
||||
names.add(rank.getName());
|
||||
return names;
|
||||
}
|
||||
|
||||
public String getList()
|
||||
{
|
||||
return Common.tl(Common.PREFIX + "Guild Roster\n" +
|
||||
String list = Common.PREFIX + "Guild Roster\n" +
|
||||
"%s%Owner%p% - " + owner + "\n" +
|
||||
"%s%Moderators%p% - " + StringUtils.join(moderators, ", ") + "\n" +
|
||||
"%s%Members%p% - " + StringUtils.join(getOnlyMembers(), ", ") + "\n");
|
||||
"%s%Moderators%p% - " + StringUtils.join(moderators, ", ") + "\n";
|
||||
|
||||
for (GuildRank rank : ranks)
|
||||
{
|
||||
list += "%s%" + rank.getName() + "%p% - " + StringUtils.join(rank.getMembers(), ", ") + "\n";
|
||||
}
|
||||
|
||||
return Common.tl(list +
|
||||
"%s%Members%p% - " + StringUtils.join(getOnlyMembers(), ", "));
|
||||
}
|
||||
|
||||
public String getInformation()
|
||||
|
@ -151,8 +246,9 @@ public class Guild
|
|||
"%s%Members%p%: " + StringUtils.join(getOnlyMembers(), ", ") + "\n" +
|
||||
"%s%Tag%p%: " + (tag == null ? "None" : GUtil.colorize(tag)) + "\n" +
|
||||
"%s%State%p%: " + state.getDisplay() + "\n" +
|
||||
"%s%Ranks%p%: " + StringUtils.join(getRankNames(), ", ") + "\n" +
|
||||
"%s%Creation%p%: " + GUtil.format(creation) + "\n" +
|
||||
"%s%Identifier (Technical)%p%: " + identifier + "\n");
|
||||
"%s%Identifier (Technical)%p%: " + identifier);
|
||||
}
|
||||
|
||||
public void chat(String as, String msg)
|
||||
|
@ -177,7 +273,17 @@ public class Guild
|
|||
{
|
||||
if (plugin.guilds.contains(identifier))
|
||||
return getGuild(identifier);
|
||||
Guild guild = new Guild(identifier, name, owner.getName(), Collections.singletonList(owner.getName()), new ArrayList<>(), null, GuildState.INVITE_ONLY, System.currentTimeMillis());
|
||||
Guild guild = new Guild(identifier,
|
||||
name,
|
||||
owner.getName(),
|
||||
Collections.singletonList(owner.getName()),
|
||||
new ArrayList<>(),
|
||||
null,
|
||||
GuildState.INVITE_ONLY,
|
||||
new ArrayList<>(),
|
||||
null,
|
||||
null,
|
||||
System.currentTimeMillis());
|
||||
guild.save();
|
||||
return guild;
|
||||
}
|
||||
|
@ -186,6 +292,16 @@ public class Guild
|
|||
{
|
||||
if (!plugin.guilds.contains(identifier))
|
||||
return null;
|
||||
List<GuildRank> ranks = new ArrayList<>();
|
||||
ConfigurationSection rankcs = plugin.guilds.getConfigurationSection(identifier + ".ranks");
|
||||
if (rankcs != null)
|
||||
{
|
||||
for (String key : rankcs.getKeys(false))
|
||||
{
|
||||
ranks.add(new GuildRank(identifier, key, plugin.guilds.getString(identifier + ".ranks." + key + ".name"),
|
||||
plugin.guilds.getStringList(identifier + ".ranks." + key + ".members")));
|
||||
}
|
||||
}
|
||||
return new Guild(identifier,
|
||||
plugin.guilds.getString(identifier + ".name"),
|
||||
plugin.guilds.getString(identifier + ".owner"),
|
||||
|
@ -193,6 +309,9 @@ public class Guild
|
|||
plugin.guilds.getStringList(identifier + ".moderators"),
|
||||
plugin.guilds.getString(identifier + ".tag"),
|
||||
GuildState.valueOf(plugin.guilds.getString(identifier + ".state")),
|
||||
ranks,
|
||||
plugin.guilds.getString(identifier + ".motd"),
|
||||
plugin.guilds.getLocation(identifier + ".home"),
|
||||
plugin.guilds.getLong(identifier + ".creation"));
|
||||
}
|
||||
|
||||
|
|
47
src/main/java/me/totalfreedom/tfguilds/guild/GuildRank.java
Normal file
47
src/main/java/me/totalfreedom/tfguilds/guild/GuildRank.java
Normal file
|
@ -0,0 +1,47 @@
|
|||
package me.totalfreedom.tfguilds.guild;
|
||||
|
||||
import lombok.Getter;
|
||||
import me.totalfreedom.tfguilds.TFGuilds;
|
||||
import me.totalfreedom.tfguilds.util.GLog;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class GuildRank
|
||||
{
|
||||
private static TFGuilds plugin = TFGuilds.getPlugin();
|
||||
|
||||
// owning guild's identifier
|
||||
private String iguild;
|
||||
|
||||
// identifier
|
||||
@Getter
|
||||
private String identifier;
|
||||
|
||||
// name
|
||||
@Getter
|
||||
private String name;
|
||||
|
||||
// members of this rank
|
||||
@Getter
|
||||
private List<String> members;
|
||||
|
||||
public GuildRank(String iguild, String identifier, String name, List<String> members)
|
||||
{
|
||||
this.identifier = identifier;
|
||||
this.iguild = iguild;
|
||||
this.name = name;
|
||||
this.members = members;
|
||||
}
|
||||
|
||||
public void set()
|
||||
{
|
||||
plugin.guilds.set(iguild + ".ranks." + identifier + ".name", name);
|
||||
plugin.guilds.set(iguild + ".ranks." + identifier + ".members", members);
|
||||
}
|
||||
|
||||
public void delete()
|
||||
{
|
||||
GLog.info("called on: " + iguild + ", rank: " + name + ", identifier: " + identifier);
|
||||
plugin.guilds.set(iguild + ".ranks." + identifier, null);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package me.totalfreedom.tfguilds.listener;
|
||||
|
||||
import me.totalfreedom.tfguilds.guild.Guild;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
|
||||
public class JoinListener implements Listener
|
||||
{
|
||||
@EventHandler
|
||||
public void onPlayerJoin(PlayerJoinEvent e)
|
||||
{
|
||||
Player player = e.getPlayer();
|
||||
Guild guild = Guild.getGuild(player);
|
||||
if (guild == null)
|
||||
return;
|
||||
if (guild.hasMOTD())
|
||||
{
|
||||
player.sendMessage(guild.getMotd());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -10,7 +10,7 @@ import java.util.regex.Pattern;
|
|||
|
||||
public class GUtil
|
||||
{
|
||||
private static final SimpleDateFormat STANDARD = new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss Z");
|
||||
private static final SimpleDateFormat STANDARD = new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss");
|
||||
|
||||
public static String flatten(String s)
|
||||
{
|
||||
|
|
|
@ -8,7 +8,7 @@ description: A guilds plugin for the TotalFreedom server.
|
|||
commands:
|
||||
guild:
|
||||
description: The main command of TFGuilds.
|
||||
usage: /<command> [list [guild] | help | create <name> | disband [name] | invite <player> | addmod <guild <player> | player> | removemod <guild <name> | name> | createrole <name> | setowner <guild <player> | player> | kick <guild <player> | player> | leave | setstate <guild <state> | state> | tp <player> | info [guild] | tag <set <tag> | clear> | join <guild> | chat [message] | saveconfig]
|
||||
usage: /<command> [list [guild] | help | create <name> | disband [name] | invite <player> | addmod <guild <player> | player> | removemod <guild <name> | name> | createrole <name> | setowner <guild <player> | player> | kick <guild <player> | player> | leave | setstate <guild <state> | state> | tp <player> | info [guild] | tag <set <tag> | clear> | join <guild> | chat [message] | saveconfig | rename <name> | createrank <name> | deleterank <rank> | setrank <player> <rank | none> motd <set <motd> | clear> | home [set] | chat [message]]
|
||||
aliases: [g]
|
||||
guildchat:
|
||||
description: Talk in chat with your guild.
|
||||
|
|
Loading…
Reference in a new issue