mirror of
https://github.com/TotalFreedomMC/TFGuilds.git
synced 2024-12-22 16:05:00 +00:00
default guild ranks
it works!!!!!!!!!!!!!!
This commit is contained in:
parent
b8a07c0281
commit
50de5817e9
6 changed files with 102 additions and 5 deletions
|
@ -48,6 +48,13 @@ public class DeleteRankSubcommand extends Common implements CommandExecutor
|
||||||
}
|
}
|
||||||
|
|
||||||
guild.removeRank(rank);
|
guild.removeRank(rank);
|
||||||
|
|
||||||
|
if (guild.hasDefaultRank() && rank.equals(guild.getDefaultRank()))
|
||||||
|
{
|
||||||
|
guild.setDefaultRank(null);
|
||||||
|
guild.save();
|
||||||
|
}
|
||||||
|
|
||||||
sender.sendMessage(tl(PREFIX + "Deleted the rank named %s%" + rank + "%p% in your guild."));
|
sender.sendMessage(tl(PREFIX + "Deleted the rank named %s%" + rank + "%p% in your guild."));
|
||||||
guild.save();
|
guild.save();
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -66,6 +66,8 @@ public class GuildCommand extends Common implements CommandExecutor, TabComplete
|
||||||
return new HomeSubcommand().onCommand(sender, command, label, args);
|
return new HomeSubcommand().onCommand(sender, command, label, args);
|
||||||
case "roster":
|
case "roster":
|
||||||
return new RosterSubcommand().onCommand(sender, command, label, args);
|
return new RosterSubcommand().onCommand(sender, command, label, args);
|
||||||
|
case "setdefaultrank":
|
||||||
|
return new SetDefaultRankSubcommand().onCommand(sender, command, label, args);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -81,7 +83,7 @@ public class GuildCommand extends Common implements CommandExecutor, TabComplete
|
||||||
return Arrays.asList("addmod", "chat", "createrank", "create",
|
return Arrays.asList("addmod", "chat", "createrank", "create",
|
||||||
"deleterank", "disband", "help", "home", "info", "invite",
|
"deleterank", "disband", "help", "home", "info", "invite",
|
||||||
"join", "kick", "leave", "list", "motd", "removemod", "rename",
|
"join", "kick", "leave", "list", "motd", "removemod", "rename",
|
||||||
"roster", "setowner", "setrank", "setstate", "tag", "tp");
|
"roster", "setowner", "setrank", "setstate", "tag", "tp", "setdefaultrank");
|
||||||
}
|
}
|
||||||
else if (args.length == 2)
|
else if (args.length == 2)
|
||||||
{
|
{
|
||||||
|
@ -116,6 +118,7 @@ public class GuildCommand extends Common implements CommandExecutor, TabComplete
|
||||||
}
|
}
|
||||||
|
|
||||||
case "deleterank":
|
case "deleterank":
|
||||||
|
case "setdefaultrank":
|
||||||
{
|
{
|
||||||
if (guild.getOwner().equals(sender.getName()))
|
if (guild.getOwner().equals(sender.getName()))
|
||||||
{
|
{
|
||||||
|
|
|
@ -33,6 +33,7 @@ public class HelpSubcommand extends Common implements CommandExecutor
|
||||||
sender.sendMessage(tl("%s% - %p%chat [message]"));
|
sender.sendMessage(tl("%s% - %p%chat [message]"));
|
||||||
sender.sendMessage(tl("%s% - %p%roster [guild | player]"));
|
sender.sendMessage(tl("%s% - %p%roster [guild | player]"));
|
||||||
sender.sendMessage(tl("%s% - %p%setstate <open | invite | closed>"));
|
sender.sendMessage(tl("%s% - %p%setstate <open | invite | closed>"));
|
||||||
|
sender.sendMessage(tl("%s% - %p%setdefaultrank <rank | none>"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,63 @@
|
||||||
|
package me.totalfreedom.tfguilds.command;
|
||||||
|
|
||||||
|
import me.totalfreedom.tfguilds.Common;
|
||||||
|
import me.totalfreedom.tfguilds.guild.Guild;
|
||||||
|
import org.apache.commons.lang.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 SetDefaultRankSubcommand 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args.length == 0)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
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 do not have permissions to manage ranks in your guild!");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
String rank = StringUtils.join(args, " ", 1, args.length);
|
||||||
|
if (rank.equalsIgnoreCase("members") || rank.equalsIgnoreCase("member") || rank.equalsIgnoreCase("none"))
|
||||||
|
{
|
||||||
|
guild.setDefaultRank(null);
|
||||||
|
guild.save();
|
||||||
|
sender.sendMessage(tl(PREFIX + "Removed the default guild rank."));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!guild.hasRank(rank))
|
||||||
|
{
|
||||||
|
sender.sendMessage(ChatColor.RED + "A rank of that name does not exist in the guild!");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
guild.setDefaultRank(rank);
|
||||||
|
guild.save();
|
||||||
|
sender.sendMessage(tl(PREFIX + "Set " + rank + " as the default rank for your guild."));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
|
@ -59,6 +59,10 @@ public class Guild
|
||||||
@Setter
|
@Setter
|
||||||
private Location home;
|
private Location home;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
private String defaultRank;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private final long creation;
|
private final long creation;
|
||||||
|
|
||||||
|
@ -72,7 +76,8 @@ public class Guild
|
||||||
List<GuildRank> ranks,
|
List<GuildRank> ranks,
|
||||||
String motd,
|
String motd,
|
||||||
Location home,
|
Location home,
|
||||||
long creation)
|
long creation,
|
||||||
|
String defaultrank)
|
||||||
{
|
{
|
||||||
this.identifier = identifier;
|
this.identifier = identifier;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
@ -85,6 +90,7 @@ public class Guild
|
||||||
this.motd = motd;
|
this.motd = motd;
|
||||||
this.home = home;
|
this.home = home;
|
||||||
this.creation = creation;
|
this.creation = creation;
|
||||||
|
this.defaultRank = defaultrank;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void save()
|
public void save()
|
||||||
|
@ -102,11 +108,17 @@ public class Guild
|
||||||
plugin.guilds.set(identifier + ".motd", motd);
|
plugin.guilds.set(identifier + ".motd", motd);
|
||||||
plugin.guilds.set(identifier + ".home", home);
|
plugin.guilds.set(identifier + ".home", home);
|
||||||
plugin.guilds.set(identifier + ".creation", creation);
|
plugin.guilds.set(identifier + ".creation", creation);
|
||||||
|
plugin.guilds.set(identifier + ".defaultrank", defaultRank);
|
||||||
plugin.guilds.save();
|
plugin.guilds.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addMember(String name)
|
public void addMember(String name)
|
||||||
{
|
{
|
||||||
|
if (hasDefaultRank())
|
||||||
|
{
|
||||||
|
getRank(defaultRank).getMembers().add(name);
|
||||||
|
}
|
||||||
|
|
||||||
members.add(name);
|
members.add(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,6 +131,10 @@ public class Guild
|
||||||
}
|
}
|
||||||
|
|
||||||
members.remove(name);
|
members.remove(name);
|
||||||
|
for (GuildRank gr : getRanks())
|
||||||
|
{
|
||||||
|
getRank(gr.getName()).getMembers().remove(name);
|
||||||
|
}
|
||||||
moderators.remove(name);
|
moderators.remove(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -211,6 +227,11 @@ public class Guild
|
||||||
return home != null;
|
return home != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean hasDefaultRank()
|
||||||
|
{
|
||||||
|
return defaultRank != null;
|
||||||
|
}
|
||||||
|
|
||||||
public void broadcast(String message)
|
public void broadcast(String message)
|
||||||
{
|
{
|
||||||
for (Player player : Bukkit.getOnlinePlayers())
|
for (Player player : Bukkit.getOnlinePlayers())
|
||||||
|
@ -359,7 +380,8 @@ public class Guild
|
||||||
new ArrayList<>(),
|
new ArrayList<>(),
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
System.currentTimeMillis());
|
System.currentTimeMillis(),
|
||||||
|
null);
|
||||||
guild.save();
|
guild.save();
|
||||||
GLog.info(owner.getName() + " has created guild " + name);
|
GLog.info(owner.getName() + " has created guild " + name);
|
||||||
return guild;
|
return guild;
|
||||||
|
@ -393,7 +415,8 @@ public class Guild
|
||||||
ranks,
|
ranks,
|
||||||
plugin.guilds.getString(identifier + ".motd"),
|
plugin.guilds.getString(identifier + ".motd"),
|
||||||
plugin.guilds.getLocation(identifier + ".home"),
|
plugin.guilds.getLocation(identifier + ".home"),
|
||||||
plugin.guilds.getLong(identifier + ".creation"));
|
plugin.guilds.getLong(identifier + ".creation"),
|
||||||
|
plugin.guilds.getString(identifier + ".defaultrank"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Guild getGuild(Player player)
|
public static Guild getGuild(Player player)
|
||||||
|
|
Loading…
Reference in a new issue