seperate commands

This commit is contained in:
speedxx 2020-06-15 22:50:29 -04:00
parent 82cf99c03c
commit 6edd6241b4
7 changed files with 83 additions and 45 deletions

View file

@ -6,7 +6,7 @@
<groupId>me.tf</groupId>
<artifactId>TFGuilds</artifactId>
<version>0.0.1</version>
<version>0.0.3</version>
<packaging>jar</packaging>
<name>TFGuilds</name>

View file

@ -1,7 +1,8 @@
package totalfreedom.tfguilds;
import org.bukkit.plugin.java.JavaPlugin;
import totalfreedom.tfguilds.command.GuildCommand;
import totalfreedom.tfguilds.command.CreateGuildCommand;
import totalfreedom.tfguilds.command.TfGuildsCommand;
import totalfreedom.tfguilds.config.Config;
import totalfreedom.tfguilds.util.GLog;
@ -31,6 +32,7 @@ public final class TFGuilds extends JavaPlugin
private void enableCommands()
{
this.getCommand("guild").setExecutor(new GuildCommand());
this.getCommand("tfguilds").setExecutor(new TfGuildsCommand());
this.getCommand("createguild").setExecutor(new CreateGuildCommand());
}
}

View file

@ -0,0 +1,45 @@
package totalfreedom.tfguilds.command;
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 totalfreedom.tfguilds.util.GBase;
import totalfreedom.tfguilds.util.GUtil;
public class CreateGuildCommand extends GBase implements CommandExecutor
{
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args)
{
if (args.length == 0)
{
return false;
}
Player player = (Player) sender;
if (GUtil.isConsole(player))
{
sender.sendMessage(ChatColor.RED + "You are not allowed to run this command.");
return true;
}
// this stupid shit
/* List<String> members = plugin.guilds.getStringList("guilds." + args[1] + ".members");
for (String players : members)
{
if (players.contains(player.getName()))
{
player.sendMessage(ChatColor.RED + "You are already in a guild.");
return true;
}
} */
GUtil.createGuild(sender, args[1]);
sender.sendMessage(ChatColor.GREEN + "Successfully created a guild named " + args[1]);
return true;
}
}

View file

@ -1,34 +0,0 @@
package totalfreedom.tfguilds.command;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import totalfreedom.tfguilds.util.GBase;
import totalfreedom.tfguilds.util.GUtil;
public class GuildCommand extends GBase implements CommandExecutor
{
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args)
{
if (args.length != 2)
{
return false;
}
if (args[0].toLowerCase().equals("create"))
{
if (GUtil.isConsole(sender))
{
sender.sendMessage(ChatColor.RED + "You are not allowed to run this command.");
return true;
}
GUtil.createGuild(sender, args[1]);
sender.sendMessage(ChatColor.GREEN + "Successfully created a guild named " + args[1]);
return true;
}
return false;
}
}

View file

@ -0,0 +1,19 @@
package totalfreedom.tfguilds.command;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import totalfreedom.tfguilds.util.GBase;
import totalfreedom.tfguilds.util.GUtil;
public class TfGuildsCommand extends GBase implements CommandExecutor
{
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args)
{
sender.sendMessage(GUtil.color("&aTFGuilds &2is a plugin which allows for players to make their own guilds, providing guild chat and guild teleportation."));
sender.sendMessage(String.format(GUtil.color("&2Version &av%s"), plugin.getDescription().getVersion()));
sender.sendMessage(GUtil.color("&2Developed by &aspeednt & supernt"));
return true;
}
}

View file

@ -1,6 +1,6 @@
package totalfreedom.tfguilds.util;
import lombok.Getter;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.ConsoleCommandSender;
import totalfreedom.tfguilds.TFGuilds;
@ -11,9 +11,6 @@ public class GUtil
{
public static TFGuilds plugin = TFGuilds.plugin;
@Getter
public static String[] guildName;
public static boolean isConsole(CommandSender sender)
{
return sender instanceof ConsoleCommandSender;
@ -32,4 +29,9 @@ public class GUtil
plugin.guilds.save();
GLog.info(owner.getName() + " has created a new guild: " + guildName);
}
public static String color(String s)
{
return ChatColor.translateAlternateColorCodes('&', s);
}
}

View file

@ -5,7 +5,11 @@ api-version: 1.13
authors: [speednt]
description: Plugin which allows for players to make their own guilds on the server
commands:
guild:
description: Main command for TFGuilds, allows for creating your own guild
usage: /<command> <create> <name>
aliases: [g]
tfguilds:
description: Plugin info
usage: /<command>
aliases: [guilds, tfguildsinfo, tfginfo, guildsinfo]
createguild:
description: Creates a guild
usage: /<command> <name>
aliases: [guildcreate]