mirror of
https://github.com/TotalFreedomMC/TFGuilds.git
synced 2024-12-22 07:55:03 +00:00
tab completion, fix more
This commit is contained in:
parent
232b2788c5
commit
cd61afd3c8
11 changed files with 106 additions and 8 deletions
2
pom.xml
2
pom.xml
|
@ -6,7 +6,7 @@
|
|||
|
||||
<groupId>me.totalfreedom</groupId>
|
||||
<artifactId>TFGuilds</artifactId>
|
||||
<version>0.2.6</version>
|
||||
<version>0.2.7</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>TFGuilds</name>
|
||||
|
|
|
@ -2,7 +2,7 @@ package me.totalfreedom.tfguilds.command;
|
|||
|
||||
import me.totalfreedom.tfguilds.Common;
|
||||
import me.totalfreedom.tfguilds.guild.Guild;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
|
|
|
@ -2,7 +2,7 @@ package me.totalfreedom.tfguilds.command;
|
|||
|
||||
import me.totalfreedom.tfguilds.Common;
|
||||
import me.totalfreedom.tfguilds.guild.Guild;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
|
|
|
@ -1,11 +1,17 @@
|
|||
package me.totalfreedom.tfguilds.command;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import me.totalfreedom.tfguilds.Common;
|
||||
import me.totalfreedom.tfguilds.guild.Guild;
|
||||
import me.totalfreedom.tfguilds.util.GUtil;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
|
||||
public class GuildCommand extends Common implements CommandExecutor
|
||||
public class GuildCommand extends Common implements CommandExecutor, TabCompleter
|
||||
{
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args)
|
||||
|
@ -65,4 +71,45 @@ public class GuildCommand extends Common implements CommandExecutor
|
|||
}
|
||||
return new HelpSubcommand().onCommand(sender, command, label, args);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args)
|
||||
{
|
||||
Guild guild = Guild.getGuild(sender);
|
||||
if (args.length == 1)
|
||||
{
|
||||
return Arrays.asList("addmod", "chat", "createrank", "create",
|
||||
"deleterank", "disband", "help", "home", "info", "invite",
|
||||
"join", "kick", "leave", "list", "motd", "removemod", "rename",
|
||||
"roster", "setowner", "setrank", "setstate", "tag", "tp");
|
||||
}
|
||||
else if (args.length == 2)
|
||||
{
|
||||
switch (args[0])
|
||||
{
|
||||
case "home":
|
||||
return Arrays.asList("set");
|
||||
case "info":
|
||||
case "join":
|
||||
case "roster":
|
||||
return Guild.getGuildList();
|
||||
case "motd":
|
||||
case "tag":
|
||||
return Arrays.asList("set", "clear");
|
||||
case "setstate":
|
||||
return Arrays.asList("OPEN", "INVITE", "CLOSED");
|
||||
case "invite":
|
||||
return GUtil.getPlayerList();
|
||||
case "deleterank":
|
||||
return guild.getRankNames();
|
||||
case "tp":
|
||||
case "removemod":
|
||||
case "addmod":
|
||||
case "setowner":
|
||||
case "kick":
|
||||
return guild.getMembers();
|
||||
}
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
|
@ -2,8 +2,6 @@ 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;
|
||||
|
|
|
@ -3,7 +3,7 @@ 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.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
|
|
|
@ -43,6 +43,12 @@ public class RemoveModSubcommand extends Common implements CommandExecutor
|
|||
return true;
|
||||
}
|
||||
|
||||
if (guild.getModerators().contains(sender.getName()))
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "You may not demote yourself.");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!guild.hasMember(player.getName()))
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "This player is not in the specified guild!");
|
||||
|
@ -89,6 +95,12 @@ public class RemoveModSubcommand extends Common implements CommandExecutor
|
|||
return true;
|
||||
}
|
||||
|
||||
if (n == player)
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "You may not demote yourself.");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!guild.hasMember(n.getName()))
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "This player is not in your guild!");
|
||||
|
|
|
@ -43,6 +43,12 @@ public class SetOwnerSubcommand extends Common implements CommandExecutor
|
|||
return true;
|
||||
}
|
||||
|
||||
if (guild.getOwner().contains(player.getName()))
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "This player is already the owner of that guild!");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!guild.hasMember(player.getName()))
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "This player is not in the specified guild!");
|
||||
|
@ -84,6 +90,12 @@ public class SetOwnerSubcommand extends Common implements CommandExecutor
|
|||
return true;
|
||||
}
|
||||
|
||||
if (n == player)
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "You are already the owner of your guild.");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!guild.hasMember(n.getName()))
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "This player is not in your guild!");
|
||||
|
|
|
@ -3,7 +3,7 @@ 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.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
|
|
|
@ -11,6 +11,7 @@ import org.apache.commons.lang.StringUtils;
|
|||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
@ -398,6 +399,20 @@ public class Guild
|
|||
return guild;
|
||||
}
|
||||
|
||||
public static Guild getGuild(CommandSender sender)
|
||||
{
|
||||
Guild guild = null;
|
||||
for (String key : plugin.guilds.getKeys(false))
|
||||
{
|
||||
Guild kg = getGuild(key);
|
||||
if (kg.getMembers().contains(sender.getName()))
|
||||
{
|
||||
guild = kg;
|
||||
}
|
||||
}
|
||||
return guild;
|
||||
}
|
||||
|
||||
public static boolean guildExists(String identifier)
|
||||
{
|
||||
return plugin.guilds.contains(identifier);
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package me.totalfreedom.tfguilds.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
|
@ -9,6 +11,7 @@ import java.util.Date;
|
|||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class GUtil
|
||||
{
|
||||
|
@ -45,4 +48,15 @@ public class GUtil
|
|||
|
||||
public static List<String> BLACKLISTED_NAMES_AND_TAGS = Arrays.asList(
|
||||
"admin", "owner", "moderator", "developer", "console", "dev", "staff", "mod", "sra", "sta", "sa", "super admin", "telnet admin", "senior admin");
|
||||
|
||||
public static List<String> getPlayerList()
|
||||
{
|
||||
List<String> players = new ArrayList<>();
|
||||
for (Player player : Bukkit.getOnlinePlayers())
|
||||
{
|
||||
players.add(player.getName());
|
||||
}
|
||||
return players;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue