From 61d5b46fc85d951638dfac59133e1e8bea63f5a8 Mon Sep 17 00:00:00 2001 From: Dan Mulloy Date: Sun, 1 Jul 2018 15:25:02 -0400 Subject: [PATCH] Add /com colead --- .../core/communities/CommunityManager.java | 2 + .../commands/CommunityCoLeadCommand.java | 67 +++++++++++++++++++ .../commands/CommunityCommand.java | 2 + 3 files changed, 71 insertions(+) create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/communities/commands/CommunityCoLeadCommand.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/communities/CommunityManager.java b/Plugins/Mineplex.Core/src/mineplex/core/communities/CommunityManager.java index 286b07471..7eec9be4b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/communities/CommunityManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/communities/CommunityManager.java @@ -97,6 +97,7 @@ public class CommunityManager extends MiniDbClientPlugin { OWN_COMMUNITY, COMMUNITY_CHAT_COMMAND, + COMMUNITY_COLEAD_COMMAND, COMMUNITY_COMMAND, COMMUNITY_DESCRIPTION_COMMAND, COMMUNITY_DESCRIPTION_STAFF_COMMAND, @@ -302,6 +303,7 @@ public class CommunityManager extends MiniDbClientPlugin PermissionGroup.ETERNAL.setPermission(Perm.OWN_COMMUNITY, true, true); PermissionGroup.PLAYER.setPermission(Perm.COMMUNITY_CHAT_COMMAND, true, true); PermissionGroup.PLAYER.setPermission(Perm.COMMUNITY_COMMAND, true, true); + PermissionGroup.PLAYER.setPermission(Perm.COMMUNITY_COLEAD_COMMAND, true, true); PermissionGroup.PLAYER.setPermission(Perm.COMMUNITY_DESCRIPTION_COMMAND, true, true); PermissionGroup.ADMIN.setPermission(Perm.COMMUNITY_DESCRIPTION_STAFF_COMMAND, true, true); PermissionGroup.ETERNAL.setPermission(Perm.COMMUNITY_DISBAND_COMMAND, true, true); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/communities/commands/CommunityCoLeadCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/communities/commands/CommunityCoLeadCommand.java new file mode 100644 index 000000000..fd6add001 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/communities/commands/CommunityCoLeadCommand.java @@ -0,0 +1,67 @@ +package mineplex.core.communities.commands; + +import org.bukkit.entity.Player; + +import mineplex.core.command.CommandBase; +import mineplex.core.common.util.F; +import mineplex.core.communities.CommunityManager; +import mineplex.core.communities.data.Community; +import mineplex.core.communities.data.CommunityMemberData; +import mineplex.core.communities.data.CommunityMemberInfo; +import mineplex.core.communities.data.CommunityRole; + +public class CommunityCoLeadCommand extends CommandBase +{ + public CommunityCoLeadCommand(CommunityManager plugin) + { + super(plugin, CommunityManager.Perm.COMMUNITY_COLEAD_COMMAND, "colead"); + } + + @Override + public void Execute(Player caller, String[] args) + { + if (args.length < 2) + { + reply(caller, "Invalid arguments. Try /colead "); + return; + } + + Community community = Plugin.getLoadedCommunity(args[0]); + if (community == null) + { + reply(caller, "Unknown community: " + args[0]); + return; + } + + CommunityMemberInfo member = community.getMembers().get(caller.getUniqueId()); + if (member == null) + { + reply(caller, "You are not a member of " + community.getName()); + return; + } + + if (member.Role != CommunityRole.LEADER) + { + reply(caller, "You are not the leader of " + community.getName()); + return; + } + + for (CommunityMemberInfo info : community.getMembers().values()) + { + if (info.Name.equalsIgnoreCase(args[1]) || info.UUID.toString().equals(args[1])) + { + if (info.Role == CommunityRole.COLEADER) + { + reply(caller, info.Name + " is alredy a Co-Leader"); + return; + } + + Plugin.handleRoleUpdate(caller, community, info, CommunityRole.COLEADER); + reply(caller, "You have updated " + info.Name + "\'s role to Co-Leader"); + return; + } + } + + reply(caller, "Unknown player: " + args[1]); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/communities/commands/CommunityCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/communities/commands/CommunityCommand.java index 0acac3449..b8e88998e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/communities/commands/CommunityCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/communities/commands/CommunityCommand.java @@ -28,6 +28,7 @@ public class CommunityCommand extends MultiCommandBase //AddCommand(new CommunityMenuCommand(plugin)); AddCommand(new CommunityRenameCommand(plugin)); AddCommand(new CommunityUnInviteCommand(plugin)); + AddCommand(new CommunityCoLeadCommand(plugin)); } @Override @@ -48,6 +49,7 @@ public class CommunityCommand extends MultiCommandBase UtilPlayer.message(caller, F.help("/com mcs ", "Opens the Mineplex Community Server of a community you manage", ChatColor.DARK_AQUA)); UtilPlayer.message(caller, F.help("/com description ", "Sets the description of a community you manage", ChatColor.DARK_AQUA)); UtilPlayer.message(caller, F.help("/com disband ", "Disbands a community you own", ChatColor.DARK_AQUA)); + UtilPlayer.message(caller, F.help("/com colead ", "Promotes a player to Co-Leader", ChatColor.DARK_AQUA)); return; }