mirror of
https://github.com/TotalFreedomMC/TFGuilds.git
synced 2024-12-22 07:55:03 +00:00
add guildchatspy
& add codestyle to project for proper code formatting
This commit is contained in:
parent
5ad6403f8f
commit
27859eddac
42 changed files with 438 additions and 68 deletions
5
.gitignore
vendored
5
.gitignore
vendored
|
@ -1,3 +1,6 @@
|
|||
.idea/
|
||||
/.idea/artifacts
|
||||
/.idea/libraries
|
||||
/.idea/workspace.xml
|
||||
/.idea/modules.xml
|
||||
target/
|
||||
out/
|
28
.idea/codeStyles/Project.xml
Normal file
28
.idea/codeStyles/Project.xml
Normal file
|
@ -0,0 +1,28 @@
|
|||
<component name="ProjectCodeStyleConfiguration">
|
||||
<code_scheme name="Project" version="173">
|
||||
<JavaCodeStyleSettings>
|
||||
<option name="CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND" value="20" />
|
||||
<option name="IMPORT_LAYOUT_TABLE">
|
||||
<value>
|
||||
<package name="" withSubpackages="true" static="false" />
|
||||
<package name="" withSubpackages="true" static="true" />
|
||||
</value>
|
||||
</option>
|
||||
</JavaCodeStyleSettings>
|
||||
<codeStyleSettings language="JAVA">
|
||||
<option name="BRACE_STYLE" value="2" />
|
||||
<option name="CLASS_BRACE_STYLE" value="2" />
|
||||
<option name="METHOD_BRACE_STYLE" value="2" />
|
||||
<option name="LAMBDA_BRACE_STYLE" value="2" />
|
||||
<option name="ELSE_ON_NEW_LINE" value="true" />
|
||||
<option name="WHILE_ON_NEW_LINE" value="true" />
|
||||
<option name="CATCH_ON_NEW_LINE" value="true" />
|
||||
<option name="FINALLY_ON_NEW_LINE" value="true" />
|
||||
<option name="SPACE_AFTER_TYPE_CAST" value="false" />
|
||||
<option name="IF_BRACE_FORCE" value="3" />
|
||||
<option name="DOWHILE_BRACE_FORCE" value="3" />
|
||||
<option name="WHILE_BRACE_FORCE" value="3" />
|
||||
<option name="FOR_BRACE_FORCE" value="3" />
|
||||
</codeStyleSettings>
|
||||
</code_scheme>
|
||||
</component>
|
5
.idea/codeStyles/codeStyleConfig.xml
Normal file
5
.idea/codeStyles/codeStyleConfig.xml
Normal file
|
@ -0,0 +1,5 @@
|
|||
<component name="ProjectCodeStyleConfiguration">
|
||||
<state>
|
||||
<option name="USE_PER_PROJECT_SETTINGS" value="true" />
|
||||
</state>
|
||||
</component>
|
16
.idea/compiler.xml
Normal file
16
.idea/compiler.xml
Normal file
|
@ -0,0 +1,16 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CompilerConfiguration">
|
||||
<annotationProcessing>
|
||||
<profile name="Maven default annotation processors profile" enabled="true">
|
||||
<sourceOutputDir name="target/generated-sources/annotations" />
|
||||
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
|
||||
<outputRelativeToContentRoot value="true" />
|
||||
<module name="TFGuilds" />
|
||||
</profile>
|
||||
</annotationProcessing>
|
||||
<bytecodeTargetLevel>
|
||||
<module name="TFGuilds" target="1.8" />
|
||||
</bytecodeTargetLevel>
|
||||
</component>
|
||||
</project>
|
7
.idea/encodings.xml
Normal file
7
.idea/encodings.xml
Normal file
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Encoding">
|
||||
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
|
||||
</component>
|
||||
</project>
|
16
.idea/misc.xml
Normal file
16
.idea/misc.xml
Normal file
|
@ -0,0 +1,16 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="EntryPointsManager">
|
||||
<list size="1">
|
||||
<item index="0" class="java.lang.String" itemvalue="org.bukkit.event.EventHandler" />
|
||||
</list>
|
||||
</component>
|
||||
<component name="MavenProjectsManager">
|
||||
<option name="originalFiles">
|
||||
<list>
|
||||
<option value="$PROJECT_DIR$/pom.xml" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" project-jdk-name="11" project-jdk-type="JavaSDK" />
|
||||
</project>
|
6
.idea/vcs.xml
Normal file
6
.idea/vcs.xml
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
|
@ -25,7 +25,7 @@
|
|||
<orderEntry type="library" scope="PROVIDED" name="Maven: commons-lang:commons-lang:2.6" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.google.guava:guava:21.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.google.code.gson:gson:2.8.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: net.md-5:bungeecord-chat:1.16-R0.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: net.md-5:bungeecord-chat:1.16-R0.3" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.yaml:snakeyaml:1.26" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.github.TFPatches:TotalFreedomMod:server-2ca57c9b39-1" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.projectlombok:lombok:1.18.10" level="project" />
|
||||
|
|
2
pom.xml
2
pom.xml
|
@ -6,7 +6,7 @@
|
|||
|
||||
<groupId>me.totalfreedom</groupId>
|
||||
<artifactId>TFGuilds</artifactId>
|
||||
<version>0.2.4</version>
|
||||
<version>0.2.6</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>TFGuilds</name>
|
||||
|
|
|
@ -22,6 +22,7 @@ public class Common
|
|||
|
||||
public static Map<Player, Guild> INVITES = new HashMap<>();
|
||||
public static List<Player> IN_GUILD_CHAT = new ArrayList<>();
|
||||
public static List<Player> CHAT_SPY = new ArrayList<>();
|
||||
|
||||
public static String tl(String in)
|
||||
{
|
||||
|
|
|
@ -2,6 +2,7 @@ package me.totalfreedom.tfguilds;
|
|||
|
||||
import me.totalfreedom.tfguilds.bridge.TFMBridge;
|
||||
import me.totalfreedom.tfguilds.command.GuildChatCommand;
|
||||
import me.totalfreedom.tfguilds.command.GuildChatSpyCommand;
|
||||
import me.totalfreedom.tfguilds.command.GuildCommand;
|
||||
import me.totalfreedom.tfguilds.command.TFGuildsCommand;
|
||||
import me.totalfreedom.tfguilds.config.Config;
|
||||
|
@ -49,6 +50,7 @@ public final class TFGuilds extends JavaPlugin
|
|||
this.getCommand("guild").setExecutor(new GuildCommand());
|
||||
this.getCommand("guildchat").setExecutor(new GuildChatCommand());
|
||||
this.getCommand("tfguilds").setExecutor(new TFGuildsCommand());
|
||||
this.getCommand("guildchatspy").setExecutor(new GuildChatSpyCommand());
|
||||
}
|
||||
|
||||
private void loadListeners()
|
||||
|
|
|
@ -26,7 +26,7 @@ public class TFMBridge
|
|||
final Plugin tfm = plugin.getServer().getPluginManager().getPlugin("TotalFreedomMod");
|
||||
if (tfm != null && tfm instanceof TotalFreedomMod)
|
||||
{
|
||||
tfmPlugin = (TotalFreedomMod) tfm;
|
||||
tfmPlugin = (TotalFreedomMod)tfm;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
|
|
@ -17,7 +17,10 @@ public class AddModSubcommand extends Common implements CommandExecutor
|
|||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args)
|
||||
{
|
||||
if (args.length == 1 || args.length > 3)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (args.length == 3)
|
||||
{
|
||||
if (!plugin.bridge.isAdmin(sender))
|
||||
|
@ -25,77 +28,91 @@ public class AddModSubcommand extends Common implements CommandExecutor
|
|||
sender.sendMessage(NO_PERMS);
|
||||
return true;
|
||||
}
|
||||
|
||||
Guild guild = Guild.getGuild(args[1]);
|
||||
if (guild == null)
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "That guild doesn't exist!");
|
||||
return true;
|
||||
}
|
||||
|
||||
Player player = Bukkit.getPlayer(args[2]);
|
||||
if (player == null)
|
||||
{
|
||||
sender.sendMessage(PNF);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!guild.hasMember(player.getName()))
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "This player is not in the specified guild!");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (guild.getOwner().equals(player.getName()))
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "No need to make the owner a moderator!");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (guild.hasModerator(player.getName()))
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "This member is already a moderator for this guild!");
|
||||
return true;
|
||||
}
|
||||
|
||||
guild.addModerator(player.getName());
|
||||
sender.sendMessage(tl(PREFIX + "Added %s%" + player.getName() + "%p% as a moderator for %s%" + GUtil.colorize(guild.getName()) + "%p%."));
|
||||
guild.broadcast(tl("%s%" + player.getName() + " %p%has been made a moderator of your guild."));
|
||||
guild.save();
|
||||
return true;
|
||||
}
|
||||
|
||||
if (sender instanceof ConsoleCommandSender)
|
||||
{
|
||||
sender.sendMessage(NO_PERMS);
|
||||
return true;
|
||||
}
|
||||
Player player = (Player) sender;
|
||||
|
||||
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 who is a moderator in your guild!");
|
||||
return true;
|
||||
}
|
||||
|
||||
Player n = Bukkit.getPlayer(args[1]);
|
||||
if (n == null)
|
||||
{
|
||||
sender.sendMessage(PNF);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (guild.getOwner().equals(n.getName()))
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "No need to make yourself a moderator!");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!guild.hasMember(n.getName()))
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "This player is not in your guild!");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (guild.hasModerator(n.getName()))
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "This member is already a moderator for your guild!");
|
||||
return true;
|
||||
}
|
||||
|
||||
guild.addModerator(n.getName());
|
||||
sender.sendMessage(tl(PREFIX + "Added %s%" + n.getName() + "%p% as a moderator for your guild."));
|
||||
guild.broadcast(tl("%s%" + n.getName() + " %p%has been made a moderator of your guild."));
|
||||
|
|
|
@ -20,25 +20,29 @@ public class ChatSubcommand extends Common implements CommandExecutor
|
|||
sender.sendMessage(NO_PERMS);
|
||||
return true;
|
||||
}
|
||||
Player player = (Player) sender;
|
||||
|
||||
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)
|
||||
{
|
||||
String message = StringUtils.join(args, " ", 1, args.length);
|
||||
guild.chat(player.getName(), message);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (IN_GUILD_CHAT.contains(player))
|
||||
{
|
||||
IN_GUILD_CHAT.remove(player);
|
||||
sender.sendMessage(tl("%p%Guild chat toggled off."));
|
||||
return true;
|
||||
}
|
||||
|
||||
IN_GUILD_CHAT.add(player);
|
||||
sender.sendMessage(tl("%p%Guild chat toggled on."));
|
||||
return true;
|
||||
|
|
|
@ -2,7 +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;
|
||||
|
@ -21,26 +20,33 @@ public class CreateRankSubcommand extends Common implements CommandExecutor
|
|||
sender.sendMessage(NO_PERMS);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args.length < 2)
|
||||
{
|
||||
return false;
|
||||
Player player = (Player) sender;
|
||||
}
|
||||
|
||||
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 create ranks for 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();
|
||||
|
|
|
@ -27,9 +27,11 @@ public class CreateSubcommand extends Common implements CommandExecutor
|
|||
}
|
||||
|
||||
if (args.length < 2)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Player player = (Player) sender;
|
||||
Player player = (Player)sender;
|
||||
String name = StringUtils.join(args, " ", 1, args.length);
|
||||
String identifier = GUtil.flatten(name);
|
||||
|
||||
|
@ -77,4 +79,4 @@ public class CreateSubcommand extends Common implements CommandExecutor
|
|||
Bukkit.broadcastMessage(GUtil.colorize(tl("%p%" + sender.getName() + " has created guild %p%&l" + name)));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -20,26 +20,33 @@ public class DeleteRankSubcommand extends Common implements CommandExecutor
|
|||
sender.sendMessage(NO_PERMS);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args.length < 2)
|
||||
{
|
||||
return false;
|
||||
Player player = (Player) sender;
|
||||
}
|
||||
|
||||
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 delete ranks from 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();
|
||||
|
|
|
@ -18,8 +18,10 @@ public class DisbandSubcommand extends Common implements CommandExecutor
|
|||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args)
|
||||
{
|
||||
if (args.length > 2)
|
||||
{
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
if (args.length == 2)
|
||||
{
|
||||
if (!plugin.bridge.isAdmin(sender))
|
||||
|
@ -49,7 +51,7 @@ public class DisbandSubcommand extends Common implements CommandExecutor
|
|||
return true;
|
||||
}
|
||||
|
||||
Player player = (Player) sender;
|
||||
Player player = (Player)sender;
|
||||
if (!Guild.isInGuild(player))
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "You aren't in a guild!");
|
||||
|
|
|
@ -20,25 +20,29 @@ public class GuildChatCommand extends Common implements CommandExecutor
|
|||
sender.sendMessage(NO_PERMS);
|
||||
return true;
|
||||
}
|
||||
Player player = (Player) sender;
|
||||
|
||||
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 >= 1)
|
||||
{
|
||||
String message = StringUtils.join(args, " ", 0, args.length);
|
||||
guild.chat(player.getName(), message);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (IN_GUILD_CHAT.contains(player))
|
||||
{
|
||||
IN_GUILD_CHAT.remove(player);
|
||||
sender.sendMessage(tl("%p%Guild chat toggled off."));
|
||||
return true;
|
||||
}
|
||||
|
||||
IN_GUILD_CHAT.add(player);
|
||||
sender.sendMessage(tl("%p%Guild chat toggled on."));
|
||||
return true;
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
package me.totalfreedom.tfguilds.command;
|
||||
|
||||
import me.totalfreedom.tfguilds.Common;
|
||||
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 GuildChatSpyCommand 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 (!plugin.bridge.isAdmin(sender))
|
||||
{
|
||||
sender.sendMessage(NO_PERMS);
|
||||
return true;
|
||||
}
|
||||
|
||||
Player player = (Player)sender;
|
||||
if (CHAT_SPY.contains(player))
|
||||
{
|
||||
CHAT_SPY.remove(player);
|
||||
sender.sendMessage(tl(PREFIX + "%p%Global guild chat spy disabled."));
|
||||
return true;
|
||||
}
|
||||
|
||||
CHAT_SPY.add(player);
|
||||
sender.sendMessage(tl(PREFIX + "%p%Global guild chat spy enabled."));
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -14,29 +14,52 @@ public class GuildCommand extends Common implements CommandExecutor
|
|||
{
|
||||
switch (args[0].toLowerCase())
|
||||
{
|
||||
case "list": return new ListSubcommand().onCommand(sender, command, label, args);
|
||||
case "help": return new HelpSubcommand().onCommand(sender, command, label, args);
|
||||
case "create": return new CreateSubcommand().onCommand(sender, command, label, args);
|
||||
case "disband": return new DisbandSubcommand().onCommand(sender, command, label, args);
|
||||
case "invite": return new InviteSubcommand().onCommand(sender, command, label, args);
|
||||
case "addmod": return new AddModSubcommand().onCommand(sender, command, label, args);
|
||||
case "removemod": return new RemoveModSubcommand().onCommand(sender, command, label, args);
|
||||
case "setowner": return new SetOwnerSubcommand().onCommand(sender, command, label, args);
|
||||
case "setstate": return new SetStateSubcommand().onCommand(sender, command, label, args);
|
||||
case "kick": return new KickSubcommand().onCommand(sender, command, label, args);
|
||||
case "leave": return new LeaveSubcommand().onCommand(sender, command, label, args);
|
||||
case "tp": return new TPSubcommand().onCommand(sender, command, label, args);
|
||||
case "info": return new InfoSubcommand().onCommand(sender, command, label, args);
|
||||
case "tag": return new TagSubcommand().onCommand(sender, command, label, args);
|
||||
case "chat": return new ChatSubcommand().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);
|
||||
case "roster": return new RosterSubcommand().onCommand(sender, command, label, args);
|
||||
case "list":
|
||||
return new ListSubcommand().onCommand(sender, command, label, args);
|
||||
case "help":
|
||||
return new HelpSubcommand().onCommand(sender, command, label, args);
|
||||
case "create":
|
||||
return new CreateSubcommand().onCommand(sender, command, label, args);
|
||||
case "disband":
|
||||
return new DisbandSubcommand().onCommand(sender, command, label, args);
|
||||
case "invite":
|
||||
return new InviteSubcommand().onCommand(sender, command, label, args);
|
||||
case "addmod":
|
||||
return new AddModSubcommand().onCommand(sender, command, label, args);
|
||||
case "removemod":
|
||||
return new RemoveModSubcommand().onCommand(sender, command, label, args);
|
||||
case "setowner":
|
||||
return new SetOwnerSubcommand().onCommand(sender, command, label, args);
|
||||
case "setstate":
|
||||
return new SetStateSubcommand().onCommand(sender, command, label, args);
|
||||
case "kick":
|
||||
return new KickSubcommand().onCommand(sender, command, label, args);
|
||||
case "leave":
|
||||
return new LeaveSubcommand().onCommand(sender, command, label, args);
|
||||
case "tp":
|
||||
return new TPSubcommand().onCommand(sender, command, label, args);
|
||||
case "info":
|
||||
return new InfoSubcommand().onCommand(sender, command, label, args);
|
||||
case "tag":
|
||||
return new TagSubcommand().onCommand(sender, command, label, args);
|
||||
case "chat":
|
||||
return new ChatSubcommand().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);
|
||||
case "roster":
|
||||
return new RosterSubcommand().onCommand(sender, command, label, args);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -17,19 +17,24 @@ public class HomeSubcommand extends Common implements CommandExecutor
|
|||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args)
|
||||
{
|
||||
if (args.length > 2)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (sender instanceof ConsoleCommandSender)
|
||||
{
|
||||
sender.sendMessage(NO_PERMS);
|
||||
return true;
|
||||
}
|
||||
Player player = (Player) sender;
|
||||
|
||||
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"))
|
||||
|
@ -39,6 +44,7 @@ public class HomeSubcommand extends Common implements CommandExecutor
|
|||
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%."));
|
||||
|
@ -46,11 +52,13 @@ public class HomeSubcommand extends Common implements CommandExecutor
|
|||
}
|
||||
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;
|
||||
|
|
|
@ -29,26 +29,31 @@ public class InfoSubcommand extends Common implements CommandExecutor
|
|||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Guild guild = Guild.getGuild(GUtil.flatten(StringUtils.join(args, " ", 1, args.length)));
|
||||
if (guild == null)
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "That guild doesn't exist!");
|
||||
return true;
|
||||
}
|
||||
|
||||
sender.sendMessage(guild.getInformation());
|
||||
return true;
|
||||
}
|
||||
|
||||
if (sender instanceof ConsoleCommandSender)
|
||||
{
|
||||
sender.sendMessage(NO_PERMS);
|
||||
return true;
|
||||
}
|
||||
Guild guild = Guild.getGuild((Player) sender);
|
||||
|
||||
Guild guild = Guild.getGuild((Player)sender);
|
||||
if (guild == null)
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "You aren't in a guild!");
|
||||
return true;
|
||||
}
|
||||
|
||||
sender.sendMessage(guild.getInformation());
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -23,11 +23,13 @@ public class InviteSubcommand extends Common implements CommandExecutor
|
|||
sender.sendMessage(NO_PERMS);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
if (args.length != 2)
|
||||
{
|
||||
return false;
|
||||
|
||||
Player player = (Player) sender;
|
||||
}
|
||||
|
||||
Player player = (Player)sender;
|
||||
Guild guild = Guild.getGuild(player);
|
||||
Player invitee = Bukkit.getPlayer(args[1]);
|
||||
if (invitee == null)
|
||||
|
@ -35,37 +37,37 @@ public class InviteSubcommand extends Common implements CommandExecutor
|
|||
sender.sendMessage(PNF);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
if (Guild.getGuild(invitee) != null)
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "This player is already in another guild!");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
if (guild == null)
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "You aren't in a guild!");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
if (guild.getState() == GuildState.CLOSED)
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "The guild is currently closed!");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
if (guild.getState() == GuildState.OPEN)
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "The guild is open! Tell your friend to join using \"/g join\"!");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
if (INVITES.containsKey(invitee))
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "They have already been invited to your guild!");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
INVITES.put(invitee, guild);
|
||||
invitee.sendMessage(tl("%p%You have been invited to join %s%" + GUtil.colorize(guild.getName()) + "%p% through %s%" + player.getName() + "%p%'s invite!"));
|
||||
invitee.sendMessage(tl("%p%Do %s%/g join " + ChatColor.stripColor(GUtil.colorize(guild.getName())) + "%p% to join!"));
|
||||
|
@ -76,7 +78,9 @@ public class InviteSubcommand extends Common implements CommandExecutor
|
|||
public void run()
|
||||
{
|
||||
if (!INVITES.containsKey(invitee))
|
||||
{
|
||||
return;
|
||||
}
|
||||
INVITES.remove(player);
|
||||
invitee.sendMessage(ChatColor.RED + "Invite expired.");
|
||||
sender.sendMessage(ChatColor.RED + "Invite expired.");
|
||||
|
@ -84,4 +88,4 @@ public class InviteSubcommand extends Common implements CommandExecutor
|
|||
}.runTaskLater(plugin, 20 * 90);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -22,25 +22,32 @@ public class JoinSubcommand extends Common implements CommandExecutor
|
|||
sender.sendMessage(NO_PERMS);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args.length < 2)
|
||||
{
|
||||
return false;
|
||||
Player player = (Player) sender;
|
||||
}
|
||||
|
||||
Player player = (Player)sender;
|
||||
if (Guild.getGuild(player) != null)
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "You are already in a guild!");
|
||||
return true;
|
||||
}
|
||||
|
||||
Guild guild = Guild.getGuild(GUtil.flatten(StringUtils.join(args, " ", 1, args.length)));
|
||||
if (guild == null)
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "That guild doesn't exist!");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (guild.getState() == GuildState.CLOSED)
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "That guild is currently closed!");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (guild.getState() == GuildState.INVITE_ONLY)
|
||||
{
|
||||
if (!INVITES.containsKey(player))
|
||||
|
@ -50,6 +57,7 @@ public class JoinSubcommand extends Common implements CommandExecutor
|
|||
}
|
||||
INVITES.remove(player);
|
||||
}
|
||||
|
||||
guild.addMember(player.getName());
|
||||
guild.broadcast(tl("%s%" + player.getName() + " %p%has joined your guild!"));
|
||||
guild.save();
|
||||
|
|
|
@ -17,7 +17,10 @@ public class KickSubcommand extends Common implements CommandExecutor
|
|||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args)
|
||||
{
|
||||
if (args.length > 3)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (args.length == 3)
|
||||
{
|
||||
if (!plugin.bridge.isAdmin(sender))
|
||||
|
@ -25,28 +28,33 @@ public class KickSubcommand extends Common implements CommandExecutor
|
|||
sender.sendMessage(NO_PERMS);
|
||||
return true;
|
||||
}
|
||||
|
||||
Guild guild = Guild.getGuild(args[1]);
|
||||
if (guild == null)
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "That guild doesn't exist!");
|
||||
return true;
|
||||
}
|
||||
|
||||
Player player = Bukkit.getPlayer(args[2]);
|
||||
if (player == null)
|
||||
{
|
||||
sender.sendMessage(PNF);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!guild.hasMember(player.getName()))
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "This player is not in the specified guild!");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (guild.getOwner().equals(player.getName()) || guild.hasModerator(player.getName()))
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "You cannot kick the owner/moderator(s) of a guild!");
|
||||
return true;
|
||||
}
|
||||
|
||||
guild.removeMember(player.getName());
|
||||
sender.sendMessage(tl(PREFIX + "Kicked %s%" + player.getName() + "%p% from %s%" + GUtil.colorize(guild.getName()) + "%p%."));
|
||||
player.sendMessage(tl("%s%You have been kicked from your guild."));
|
||||
|
@ -54,44 +62,52 @@ public class KickSubcommand extends Common implements CommandExecutor
|
|||
guild.save();
|
||||
return true;
|
||||
}
|
||||
|
||||
if (sender instanceof ConsoleCommandSender)
|
||||
{
|
||||
sender.sendMessage(NO_PERMS);
|
||||
return true;
|
||||
}
|
||||
Player player = (Player) sender;
|
||||
|
||||
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 kick people from your guild!");
|
||||
return true;
|
||||
}
|
||||
|
||||
Player n = Bukkit.getPlayer(args[1]);
|
||||
if (n == null)
|
||||
{
|
||||
sender.sendMessage(PNF);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (guild.getOwner().equals(n.getName()))
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "No need to make yourself a moderator!");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!guild.hasMember(n.getName()))
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "This player is not in your guild!");
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((guild.getOwner().equals(n.getName()) || guild.hasModerator(n.getName())) && !guild.getOwner().equals(player.getName()))
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "You cannot kick the owner/moderator(s) of a guild!");
|
||||
return true;
|
||||
}
|
||||
|
||||
guild.removeMember(n.getName());
|
||||
sender.sendMessage(tl(PREFIX + "Kicked %s%" + n.getName() + "%p% from your guild."));
|
||||
n.sendMessage(tl("%s%You have been kicked from your guild."));
|
||||
|
|
|
@ -15,24 +15,30 @@ public class LeaveSubcommand extends Common implements CommandExecutor
|
|||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args)
|
||||
{
|
||||
if (args.length > 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (sender instanceof ConsoleCommandSender)
|
||||
{
|
||||
sender.sendMessage(NO_PERMS);
|
||||
return true;
|
||||
}
|
||||
Player player = (Player) sender;
|
||||
|
||||
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 cannot leave as you are the owner!");
|
||||
return true;
|
||||
}
|
||||
|
||||
guild.removeModerator(player.getName());
|
||||
guild.removeMember(player.getName());
|
||||
guild.save();
|
||||
|
|
|
@ -2,10 +2,8 @@ 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;
|
||||
|
@ -19,24 +17,30 @@ public class MOTDSubcommand extends Common implements CommandExecutor
|
|||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args)
|
||||
{
|
||||
if (args.length == 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (sender instanceof ConsoleCommandSender)
|
||||
{
|
||||
sender.sendMessage(NO_PERMS);
|
||||
return true;
|
||||
}
|
||||
Player player = (Player) sender;
|
||||
|
||||
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"))
|
||||
|
@ -49,8 +53,12 @@ public class MOTDSubcommand extends Common implements CommandExecutor
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!args[1].equalsIgnoreCase("clear"))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
guild.setMotd(null);
|
||||
guild.save();
|
||||
sender.sendMessage(tl(PREFIX + "Cleared your guild's MOTD."));
|
||||
|
|
|
@ -17,7 +17,10 @@ public class RemoveModSubcommand extends Common implements CommandExecutor
|
|||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args)
|
||||
{
|
||||
if (args.length == 1 || args.length > 3)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (args.length == 3)
|
||||
{
|
||||
if (!plugin.bridge.isAdmin(sender))
|
||||
|
@ -25,67 +28,79 @@ public class RemoveModSubcommand extends Common implements CommandExecutor
|
|||
sender.sendMessage(NO_PERMS);
|
||||
return true;
|
||||
}
|
||||
|
||||
Guild guild = Guild.getGuild(args[1]);
|
||||
if (guild == null)
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "That guild doesn't exist!");
|
||||
return true;
|
||||
}
|
||||
|
||||
Player player = Bukkit.getPlayer(args[2]);
|
||||
if (player == null)
|
||||
{
|
||||
sender.sendMessage(PNF);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!guild.hasMember(player.getName()))
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "This player is not in the specified guild!");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!guild.hasModerator(player.getName()))
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "This member is not a moderator for this guild!");
|
||||
return true;
|
||||
}
|
||||
|
||||
guild.removeModerator(player.getName());
|
||||
sender.sendMessage(tl(PREFIX + "Removed %s%" + player.getName() + "%p% as a moderator for %s%" + GUtil.colorize(guild.getName()) + "%p%."));
|
||||
guild.broadcast(tl("%s%" + player.getName() + " %p%has been made a member of your guild."));
|
||||
guild.save();
|
||||
return true;
|
||||
}
|
||||
|
||||
if (sender instanceof ConsoleCommandSender)
|
||||
{
|
||||
sender.sendMessage(NO_PERMS);
|
||||
return true;
|
||||
}
|
||||
Player player = (Player) sender;
|
||||
|
||||
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 who is a moderator in your guild!");
|
||||
return true;
|
||||
}
|
||||
|
||||
Player n = Bukkit.getPlayer(args[1]);
|
||||
if (n == null)
|
||||
{
|
||||
sender.sendMessage(PNF);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!guild.hasMember(n.getName()))
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "This player is not in your guild!");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!guild.hasModerator(n.getName()))
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "This member is not a moderator for your guild!");
|
||||
return true;
|
||||
}
|
||||
|
||||
guild.removeModerator(n.getName());
|
||||
sender.sendMessage(tl(PREFIX + "Removed %s%" + n.getName() + "%p% as a moderator for your guild."));
|
||||
guild.broadcast(tl("%s%" + n.getName() + " %p%has been made a member of your guild."));
|
||||
|
|
|
@ -20,13 +20,17 @@ public class RenameSubcommand extends Common implements CommandExecutor
|
|||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args)
|
||||
{
|
||||
if (args.length < 2)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (sender instanceof ConsoleCommandSender)
|
||||
{
|
||||
sender.sendMessage(NO_PERMS);
|
||||
return true;
|
||||
}
|
||||
Player player = (Player) sender;
|
||||
|
||||
Player player = (Player)sender;
|
||||
Guild guild = Guild.getGuild(player);
|
||||
String newName = StringUtils.join(args, " ", 1, args.length);
|
||||
String identifier = GUtil.flatten(newName);
|
||||
|
@ -35,6 +39,7 @@ public class RenameSubcommand extends Common implements CommandExecutor
|
|||
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!");
|
||||
|
@ -67,6 +72,7 @@ public class RenameSubcommand extends Common implements CommandExecutor
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
guild.disband();
|
||||
guild.setIdentifier(GUtil.flatten(newName));
|
||||
guild.setName(newName);
|
||||
|
|
|
@ -47,7 +47,7 @@ public class RosterSubcommand extends Common implements CommandExecutor
|
|||
return true;
|
||||
}
|
||||
|
||||
Guild guild = Guild.getGuild((Player) sender);
|
||||
Guild guild = Guild.getGuild((Player)sender);
|
||||
if (guild == null)
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "You aren't in a guild!");
|
||||
|
|
|
@ -17,7 +17,10 @@ public class SetOwnerSubcommand extends Common implements CommandExecutor
|
|||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args)
|
||||
{
|
||||
if (args.length == 1 || args.length > 3)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (args.length == 3)
|
||||
{
|
||||
if (!plugin.bridge.isAdmin(sender))
|
||||
|
@ -25,23 +28,27 @@ public class SetOwnerSubcommand extends Common implements CommandExecutor
|
|||
sender.sendMessage(NO_PERMS);
|
||||
return true;
|
||||
}
|
||||
|
||||
Guild guild = Guild.getGuild(args[1]);
|
||||
if (guild == null)
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "That guild doesn't exist!");
|
||||
return true;
|
||||
}
|
||||
|
||||
Player player = Bukkit.getPlayer(args[2]);
|
||||
if (player == null)
|
||||
{
|
||||
sender.sendMessage(PNF);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!guild.hasMember(player.getName()))
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "This player is not in the specified guild!");
|
||||
return true;
|
||||
}
|
||||
|
||||
guild.removeModerator(player.getName());
|
||||
guild.setOwner(player.getName());
|
||||
sender.sendMessage(tl(PREFIX + "Ownership has been transferred to %s%" + player.getName() + "%p% in %s%" + GUtil.colorize(guild.getName()) + "%p%."));
|
||||
|
@ -49,34 +56,40 @@ public class SetOwnerSubcommand extends Common implements CommandExecutor
|
|||
guild.save();
|
||||
return true;
|
||||
}
|
||||
|
||||
if (sender instanceof ConsoleCommandSender)
|
||||
{
|
||||
sender.sendMessage(NO_PERMS);
|
||||
return true;
|
||||
}
|
||||
Player player = (Player) sender;
|
||||
|
||||
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 who is the owner of your guild!");
|
||||
return true;
|
||||
}
|
||||
|
||||
Player n = Bukkit.getPlayer(args[1]);
|
||||
if (n == null)
|
||||
{
|
||||
sender.sendMessage(PNF);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!guild.hasMember(n.getName()))
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "This player is not in your guild!");
|
||||
return true;
|
||||
}
|
||||
|
||||
guild.removeModerator(n.getName());
|
||||
guild.setOwner(n.getName());
|
||||
sender.sendMessage(tl(PREFIX + "Ownership has been transferred to %s%" + n.getName() + "%p% in your guild."));
|
||||
|
|
|
@ -18,55 +18,71 @@ public class SetRankSubcommand extends Common implements CommandExecutor
|
|||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args)
|
||||
{
|
||||
if (args.length == 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (sender instanceof ConsoleCommandSender)
|
||||
{
|
||||
sender.sendMessage(NO_PERMS);
|
||||
return true;
|
||||
}
|
||||
Player player = (Player) sender;
|
||||
|
||||
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%."));
|
||||
|
|
|
@ -23,47 +23,55 @@ public class SetStateSubcommand extends Common implements CommandExecutor
|
|||
sender.sendMessage(NO_PERMS);
|
||||
return true;
|
||||
}
|
||||
|
||||
Guild guild = Guild.getGuild(args[1]);
|
||||
if (guild == null)
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "That guild doesn't exist!");
|
||||
return true;
|
||||
}
|
||||
|
||||
GuildState state = GuildState.findState(args[2]);
|
||||
if (state == null)
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "That is not a valid state!");
|
||||
return true;
|
||||
}
|
||||
|
||||
guild.setState(state);
|
||||
sender.sendMessage(tl(PREFIX + "Set the guild state to %s%" + state.getDisplay().toLowerCase() + "%p% in %s%" + GUtil.colorize(guild.getName()) + "%p%."));
|
||||
guild.broadcast(tl("%p%The guild is now %s%" + state.getDisplay().toLowerCase() + "%p%."));
|
||||
guild.save();
|
||||
return true;
|
||||
}
|
||||
|
||||
if (sender instanceof ConsoleCommandSender)
|
||||
{
|
||||
sender.sendMessage(NO_PERMS);
|
||||
return true;
|
||||
}
|
||||
Player player = (Player) sender;
|
||||
|
||||
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 state of the guild!");
|
||||
return true;
|
||||
}
|
||||
|
||||
GuildState state = GuildState.findState(args[1]);
|
||||
if (state == null)
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "That is not a valid state!");
|
||||
return true;
|
||||
}
|
||||
|
||||
guild.setState(state);
|
||||
sender.sendMessage(tl(PREFIX + "Set the guild state to %s%" + state.getDisplay().toLowerCase() + "%p% in your guild."));
|
||||
guild.broadcast(tl("%p%The guild is now %s%" + state.getDisplay().toLowerCase() + "%p%."));
|
||||
|
|
|
@ -16,7 +16,10 @@ public class TFGuildsCommand extends Common implements CommandExecutor
|
|||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args)
|
||||
{
|
||||
if (args.length > 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (args.length == 1)
|
||||
{
|
||||
if (args[0].toLowerCase().equals("reload"))
|
||||
|
@ -26,6 +29,7 @@ public class TFGuildsCommand extends Common implements CommandExecutor
|
|||
sender.sendMessage(NO_PERMS);
|
||||
return true;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
plugin.config.load();
|
||||
|
@ -40,8 +44,8 @@ public class TFGuildsCommand extends Common implements CommandExecutor
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
sender.sendMessage(tl("%p%TFGuilds %s%is a plugin which allows for players to make their own guilds, providing guild chat, guild teleportation, and more."));
|
||||
sender.sendMessage(tl("%s%Version %p%v" + plugin.getDescription().getVersion()));
|
||||
OfflinePlayer sp = Bukkit.getOfflinePlayer(UUID.fromString("d018f2b8-ce60-4672-a45f-e580e0331299"));
|
||||
|
|
|
@ -20,26 +20,33 @@ public class TPSubcommand extends Common implements CommandExecutor
|
|||
sender.sendMessage(NO_PERMS);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args.length != 2)
|
||||
{
|
||||
return false;
|
||||
Player player = (Player) sender;
|
||||
}
|
||||
|
||||
Player player = (Player)sender;
|
||||
Guild guild = Guild.getGuild(player);
|
||||
if (guild == null)
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "You aren't in a guild!");
|
||||
return true;
|
||||
}
|
||||
|
||||
Player to = Bukkit.getPlayer(args[1]);
|
||||
if (to == null)
|
||||
{
|
||||
sender.sendMessage(PNF);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!guild.getMembers().contains(to.getName()))
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "That player is not in your guild.");
|
||||
return true;
|
||||
}
|
||||
|
||||
player.teleport(to.getLocation());
|
||||
sender.sendMessage(tl("%p%Teleported to %s%" + to.getName() + "%p%."));
|
||||
to.sendMessage(tl("%s%" + sender.getName() + " %p%has teleported to you."));
|
||||
|
|
|
@ -23,9 +23,11 @@ public class TagSubcommand extends Common implements CommandExecutor
|
|||
}
|
||||
|
||||
if (args.length < 2)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Player player = (Player) sender;
|
||||
Player player = (Player)sender;
|
||||
Guild guild = Guild.getGuild(player);
|
||||
if (guild == null)
|
||||
{
|
||||
|
|
|
@ -95,7 +95,9 @@ public class Guild
|
|||
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);
|
||||
|
@ -111,7 +113,10 @@ public class Guild
|
|||
{
|
||||
Player player = Bukkit.getPlayer(name);
|
||||
if (player != null)
|
||||
{
|
||||
Common.IN_GUILD_CHAT.remove(player);
|
||||
}
|
||||
|
||||
members.remove(name);
|
||||
moderators.remove(name);
|
||||
}
|
||||
|
@ -134,7 +139,10 @@ public class Guild
|
|||
public boolean hasModerator(String name)
|
||||
{
|
||||
if (owner.equals(name))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return moderators.contains(name);
|
||||
}
|
||||
|
||||
|
@ -149,10 +157,16 @@ public class Guild
|
|||
for (GuildRank rank : ranks)
|
||||
{
|
||||
if (GUtil.flatten(name).equals(rank.getIdentifier()))
|
||||
{
|
||||
remove = rank;
|
||||
}
|
||||
}
|
||||
|
||||
if (remove == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
remove.delete();
|
||||
ranks.remove(remove);
|
||||
}
|
||||
|
@ -162,7 +176,9 @@ public class Guild
|
|||
for (GuildRank rank : ranks)
|
||||
{
|
||||
if (GUtil.flatten(name).equals(rank.getIdentifier()))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -172,7 +188,9 @@ public class Guild
|
|||
for (GuildRank rank : ranks)
|
||||
{
|
||||
if (GUtil.flatten(name).equals(rank.getIdentifier()))
|
||||
{
|
||||
return rank;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -209,7 +227,9 @@ public class Guild
|
|||
for (String member : members)
|
||||
{
|
||||
if (member.equals(owner) || moderators.contains(member))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
only.add(member);
|
||||
}
|
||||
return only;
|
||||
|
@ -219,7 +239,9 @@ public class Guild
|
|||
{
|
||||
List<String> names = new ArrayList<>();
|
||||
for (GuildRank rank : ranks)
|
||||
{
|
||||
names.add(rank.getName());
|
||||
}
|
||||
return names;
|
||||
}
|
||||
|
||||
|
@ -267,6 +289,14 @@ public class Guild
|
|||
{
|
||||
broadcast(Common.tl("%s%[%p%Guild Chat %s%| %p%" + GUtil.colorize(name) + "%s%] %p%" + as + ChatColor.WHITE + ": %p%" + msg));
|
||||
GLog.info(Common.tl("%s%[%p%Guild Chat %s%| %p%" + GUtil.colorize(name) + "%s%] %p%" + as + ChatColor.WHITE + ": %p%" + msg));
|
||||
|
||||
for (Player player : Bukkit.getOnlinePlayers())
|
||||
{
|
||||
if (Common.CHAT_SPY.contains(player))
|
||||
{
|
||||
player.sendMessage(GUtil.colorize("&7[GUILD CHAT SPY | " + GUtil.colorize(name) + "] " + as + ": " + msg));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void disband()
|
||||
|
@ -275,7 +305,9 @@ public class Guild
|
|||
{
|
||||
Player player = Bukkit.getPlayer(member);
|
||||
if (player == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
Common.IN_GUILD_CHAT.remove(player);
|
||||
}
|
||||
plugin.guilds.set(identifier, null);
|
||||
|
@ -296,7 +328,10 @@ public class Guild
|
|||
public static Guild createGuild(String identifier, String name, Player owner)
|
||||
{
|
||||
if (plugin.guilds.contains(identifier))
|
||||
{
|
||||
return getGuild(identifier);
|
||||
}
|
||||
|
||||
Guild guild = new Guild(identifier,
|
||||
name,
|
||||
owner.getName(),
|
||||
|
@ -316,7 +351,10 @@ public class Guild
|
|||
public static Guild getGuild(String identifier)
|
||||
{
|
||||
if (!plugin.guilds.contains(identifier))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
List<GuildRank> ranks = new ArrayList<>();
|
||||
ConfigurationSection rankcs = plugin.guilds.getConfigurationSection(identifier + ".ranks");
|
||||
if (rankcs != null)
|
||||
|
@ -327,6 +365,7 @@ public class Guild
|
|||
plugin.guilds.getStringList(identifier + ".ranks." + key + ".members")));
|
||||
}
|
||||
}
|
||||
|
||||
return new Guild(identifier,
|
||||
plugin.guilds.getString(identifier + ".name"),
|
||||
plugin.guilds.getString(identifier + ".owner"),
|
||||
|
@ -347,7 +386,9 @@ public class Guild
|
|||
{
|
||||
Guild kg = getGuild(key);
|
||||
if (kg.getMembers().contains(player.getName()))
|
||||
{
|
||||
guild = kg;
|
||||
}
|
||||
}
|
||||
return guild;
|
||||
}
|
||||
|
@ -363,7 +404,9 @@ public class Guild
|
|||
{
|
||||
Guild guild = getGuild(key);
|
||||
if (guild.getMembers().contains(player.getName()))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -19,7 +19,10 @@ public enum GuildState
|
|||
public static GuildState findState(String string)
|
||||
{
|
||||
if (string == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
switch (string.toLowerCase())
|
||||
{
|
||||
case "open":
|
||||
|
|
|
@ -18,16 +18,20 @@ public class ChatListener implements Listener
|
|||
Player player = e.getPlayer();
|
||||
Guild guild = Guild.getGuild(player);
|
||||
if (guild == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (Common.IN_GUILD_CHAT.contains(player))
|
||||
{
|
||||
guild.chat(player.getName(), e.getMessage());
|
||||
e.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (guild.hasTag())
|
||||
{
|
||||
e.setFormat(GUtil.colorize(guild.getTag()) + ChatColor.RESET + " " + e.getFormat());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -15,10 +15,13 @@ public class JoinListener implements Listener
|
|||
Player player = e.getPlayer();
|
||||
Guild guild = Guild.getGuild(player);
|
||||
if (guild == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (guild.hasMOTD())
|
||||
{
|
||||
player.sendMessage(GUtil.colorize(guild.getMotd()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,7 +2,6 @@ name: TFGuilds
|
|||
version: ${project.version}
|
||||
main: me.totalfreedom.tfguilds.TFGuilds
|
||||
api-version: 1.16
|
||||
softdepend: [TotalFreedomMod]
|
||||
authors: [speed, super]
|
||||
description: A guilds plugin for the TotalFreedom server.
|
||||
commands:
|
||||
|
@ -17,4 +16,8 @@ commands:
|
|||
tfguilds:
|
||||
description: Information about the plugin.
|
||||
usage: /<command>
|
||||
aliases: [tfg]
|
||||
aliases: [tfg]
|
||||
guildchatspy:
|
||||
description: An admin only command which allows for spying on guild chat.
|
||||
usage: /<command>
|
||||
aliases: [gchatspy, gcs]
|
Loading…
Reference in a new issue