Implement all communities commands
This commit is contained in:
parent
d44a3774db
commit
9ba38ffd3b
@ -0,0 +1,41 @@
|
||||
package mineplex.core.communities.commands;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.communities.Community;
|
||||
import mineplex.core.communities.CommunityManager;
|
||||
|
||||
public class CommunityChatCommand extends CommandBase<CommunityManager>
|
||||
{
|
||||
public CommunityChatCommand(CommunityManager plugin)
|
||||
{
|
||||
super(plugin, Rank.ALL, "chat");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
UtilPlayer.message(caller, F.help("/com chat <community>", "Selects which community you chat to", Rank.ALL));
|
||||
return;
|
||||
}
|
||||
Community c = Plugin.getLoadedCommunity(args[0]);
|
||||
if (c == null)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.getName(), "That community was not found!"));
|
||||
return;
|
||||
}
|
||||
if (!c.getMembers().containsKey(caller.getUniqueId()))
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.getName(), "You are not in " + F.name(c.getName()) + "!"));
|
||||
return;
|
||||
}
|
||||
UtilPlayer.message(caller, F.main(Plugin.getName(), "You are now chatting to " + F.name(c.getName()) + "!"));
|
||||
Plugin.Get(caller).setCommunityChattingTo(c);
|
||||
}
|
||||
}
|
@ -4,18 +4,53 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.command.MultiCommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.communities.Community;
|
||||
import mineplex.core.communities.CommunityManager;
|
||||
import mineplex.core.communities.gui.community.CommunityMembersPage;
|
||||
|
||||
public class CommunityCommand extends MultiCommandBase<CommunityManager>
|
||||
{
|
||||
public CommunityCommand(CommunityManager plugin)
|
||||
{
|
||||
super(plugin, Rank.TITAN, "com");
|
||||
super(plugin, Rank.ALL, "community", "communities", "com");
|
||||
|
||||
AddCommand(new CommunityChatCommand(plugin));
|
||||
AddCommand(new CommunityCreateCommand(plugin));
|
||||
AddCommand(new CommunityDescriptionCommand(plugin));
|
||||
AddCommand(new CommunityDisbandCommand(plugin));
|
||||
AddCommand(new CommunityInviteCommand(plugin));
|
||||
AddCommand(new CommunityMenuCommand(plugin));
|
||||
AddCommand(new CommunityRenameCommand(plugin));
|
||||
AddCommand(new CommunityUnInviteCommand(plugin));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void Help(Player caller, String[] args)
|
||||
{
|
||||
|
||||
if (args.length > 0)
|
||||
{
|
||||
Community community = Plugin.getLoadedCommunity(args[0]);
|
||||
if (community == null)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.getName(), "Could not find community " + F.name(args[0]) + "!"));
|
||||
}
|
||||
else
|
||||
{
|
||||
new CommunityMembersPage(caller, community);
|
||||
}
|
||||
return;
|
||||
}
|
||||
UtilPlayer.message(caller, F.main(Plugin.getName(), "Community Commands:"));
|
||||
UtilPlayer.message(caller, F.help("/com <community>", "Opens a community's menu", Rank.ALL));
|
||||
UtilPlayer.message(caller, F.help("/com menu", "Opens your community menu", Rank.ALL));
|
||||
UtilPlayer.message(caller, F.help("/com invite <player> <community>", "Invites a player to a community you manage", Rank.ALL));
|
||||
UtilPlayer.message(caller, F.help("/com uninvite <player> <community>", "Revokes a player's invitation to a community you manage", Rank.ALL));
|
||||
UtilPlayer.message(caller, F.help("/com chat <community>", "Selects which community you chat to", Rank.ALL));
|
||||
UtilPlayer.message(caller, F.help("/com create <name>", "Creates a new community", Rank.ETERNAL));
|
||||
UtilPlayer.message(caller, F.help("/com rename <community> <name>", "Changes the name of a community you own", Rank.ETERNAL));
|
||||
UtilPlayer.message(caller, F.help("/com description <community> <description>", "Sets the description of a community you manage", Rank.ALL));
|
||||
UtilPlayer.message(caller, F.help("/com disband <community>", "Disbands a community you own", Rank.ETERNAL));
|
||||
}
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
package mineplex.core.communities.commands;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.communities.Community;
|
||||
import mineplex.core.communities.CommunityManager;
|
||||
|
||||
public class CommunityCreateCommand extends CommandBase<CommunityManager>
|
||||
{
|
||||
public CommunityCreateCommand(CommunityManager plugin)
|
||||
{
|
||||
super(plugin, Rank.ETERNAL, "create");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
UtilPlayer.message(caller, F.help("/com create <name>", "Creates a new community", Rank.ETERNAL));
|
||||
return;
|
||||
}
|
||||
Community c = Plugin.getLoadedCommunity(args[0]);
|
||||
if (c != null)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.getName(), "A community already exists with that name!"));
|
||||
return;
|
||||
}
|
||||
if (Plugin.Get(caller).ownsCommunity())
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.getName(), "You already own a community!"));
|
||||
return;
|
||||
}
|
||||
if (args[0].length() > 15 || !StringUtils.isAlphanumeric(args[0]))
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.getName(), "A community name cannot be longer than 15 characters and must be alphanumeric!"));
|
||||
return;
|
||||
}
|
||||
Plugin.handleCreate(caller, args[0]);
|
||||
}
|
||||
}
|
@ -0,0 +1,59 @@
|
||||
package mineplex.core.communities.commands;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.Managers;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.communities.Community;
|
||||
import mineplex.core.communities.CommunityManager;
|
||||
import mineplex.core.communities.CommunityMemberInfo;
|
||||
import mineplex.core.communities.CommunityRole;
|
||||
import mineplex.core.communities.CommunitySetting;
|
||||
|
||||
public class CommunityDescriptionCommand extends CommandBase<CommunityManager>
|
||||
{
|
||||
public CommunityDescriptionCommand(CommunityManager plugin)
|
||||
{
|
||||
super(plugin, Rank.ALL, "description");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
if (args.length < 2)
|
||||
{
|
||||
UtilPlayer.message(caller, F.help("/com description <community> <description>", "Sets the description of a community you manage", Rank.ALL));
|
||||
return;
|
||||
}
|
||||
Community c = Plugin.getLoadedCommunity(args[0]);
|
||||
String desc = args[1];
|
||||
for (int i = 2; i < args.length; i++)
|
||||
{
|
||||
desc += (" " + args[i]);
|
||||
}
|
||||
if (c == null)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.getName(), "That community was not found!"));
|
||||
return;
|
||||
}
|
||||
if (c.getMembers().getOrDefault(caller, new CommunityMemberInfo(caller.getName(), caller.getUniqueId(), -1, CommunityRole.MEMBER, -1L)).Role.ordinal() > CommunityRole.COLEADER.ordinal())
|
||||
{
|
||||
if (!Managers.get(CoreClientManager.class).Get(caller).GetRank().has(Rank.ADMIN))
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.getName(), "You are not a co-leader of " + F.name(c.getName()) + "!"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (desc.length() > 30)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.getName(), "A community description cannot be longer than 30 characters!"));
|
||||
return;
|
||||
}
|
||||
UtilPlayer.message(caller, F.main(Plugin.getName(), "You have changed the description of " + F.name(c.getName()) + " to " + desc + "!"));
|
||||
Plugin.handleSettingUpdate(caller, c, CommunitySetting.DESCRIPTION, desc);
|
||||
}
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
package mineplex.core.communities.commands;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.Managers;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.communities.Community;
|
||||
import mineplex.core.communities.CommunityManager;
|
||||
import mineplex.core.communities.CommunityMemberInfo;
|
||||
import mineplex.core.communities.CommunityRole;
|
||||
|
||||
public class CommunityDisbandCommand extends CommandBase<CommunityManager>
|
||||
{
|
||||
public CommunityDisbandCommand(CommunityManager plugin)
|
||||
{
|
||||
super(plugin, Rank.ETERNAL, "disband");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
UtilPlayer.message(caller, F.help("/com disband <community>", "Disbands a community you own", Rank.ETERNAL));
|
||||
return;
|
||||
}
|
||||
Community c = Plugin.getLoadedCommunity(args[0]);
|
||||
if (c == null)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.getName(), "That community was not found!"));
|
||||
return;
|
||||
}
|
||||
if (c.getMembers().getOrDefault(caller, new CommunityMemberInfo(caller.getName(), caller.getUniqueId(), -1, CommunityRole.MEMBER, -1L)).Role != CommunityRole.LEADER)
|
||||
{
|
||||
if (!Managers.get(CoreClientManager.class).Get(caller).GetRank().has(Rank.ADMIN))
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.getName(), "You are not the leader of " + F.name(c.getName()) + "!"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
UtilPlayer.message(caller, F.main(Plugin.getName(), "You have disbanded community " + F.name(c.getName()) + "!"));
|
||||
Plugin.handleDisband(caller, c);
|
||||
}
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
package mineplex.core.communities.commands;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.Managers;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.communities.Community;
|
||||
import mineplex.core.communities.CommunityManager;
|
||||
import mineplex.core.communities.CommunityMemberInfo;
|
||||
import mineplex.core.communities.CommunityRole;
|
||||
|
||||
public class CommunityInviteCommand extends CommandBase<CommunityManager>
|
||||
{
|
||||
public CommunityInviteCommand(CommunityManager plugin)
|
||||
{
|
||||
super(plugin, Rank.ALL, "invite");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
if (args.length < 2)
|
||||
{
|
||||
UtilPlayer.message(caller, F.help("/com invite <player> <community>", "Invites a player to a community you manage", Rank.ALL));
|
||||
return;
|
||||
}
|
||||
String player = args[0];
|
||||
Community c = Plugin.getLoadedCommunity(args[1]);
|
||||
if (c == null)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.getName(), "That community was not found!"));
|
||||
return;
|
||||
}
|
||||
if (c.getMembers().getOrDefault(caller, new CommunityMemberInfo(caller.getName(), caller.getUniqueId(), -1, CommunityRole.MEMBER, -1L)).Role.ordinal() > CommunityRole.COLEADER.ordinal())
|
||||
{
|
||||
if (!Managers.get(CoreClientManager.class).Get(caller).GetRank().has(Rank.ADMIN))
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.getName(), "You are not a co-leader of " + F.name(c.getName()) + "!"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
Plugin.handleInvite(caller, c, player);
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package mineplex.core.communities.commands;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.communities.CommunityManager;
|
||||
import mineplex.core.communities.gui.overview.CommunityOverviewPage;
|
||||
|
||||
public class CommunityMenuCommand extends CommandBase<CommunityManager>
|
||||
{
|
||||
public CommunityMenuCommand(CommunityManager plugin)
|
||||
{
|
||||
super(plugin, Rank.ALL, "menu");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
new CommunityOverviewPage(caller);
|
||||
}
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
package mineplex.core.communities.commands;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.Managers;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.communities.Community;
|
||||
import mineplex.core.communities.CommunityManager;
|
||||
import mineplex.core.communities.CommunityMemberInfo;
|
||||
import mineplex.core.communities.CommunityRole;
|
||||
|
||||
public class CommunityRenameCommand extends CommandBase<CommunityManager>
|
||||
{
|
||||
public CommunityRenameCommand(CommunityManager plugin)
|
||||
{
|
||||
super(plugin, Rank.ETERNAL, "rename");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
if (args.length < 2)
|
||||
{
|
||||
UtilPlayer.message(caller, F.help("/com rename <community> <name>", "Changes the name of a community you own", Rank.ETERNAL));
|
||||
return;
|
||||
}
|
||||
Community c = Plugin.getLoadedCommunity(args[0]);
|
||||
String newName = args[1];
|
||||
if (c == null)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.getName(), "That community was not found!"));
|
||||
return;
|
||||
}
|
||||
if (c.getMembers().getOrDefault(caller, new CommunityMemberInfo(caller.getName(), caller.getUniqueId(), -1, CommunityRole.MEMBER, -1L)).Role != CommunityRole.LEADER)
|
||||
{
|
||||
if (!Managers.get(CoreClientManager.class).Get(caller).GetRank().has(Rank.ADMIN))
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.getName(), "You are not the leader of " + F.name(c.getName()) + "!"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (Plugin.getLoadedCommunity(newName) != null)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.getName(), "A community already exists with that name!"));
|
||||
return;
|
||||
}
|
||||
UtilPlayer.message(caller, F.main(Plugin.getName(), "You have changed the name of " + F.name(c.getName()) + " to " + F.name(newName) + "!"));
|
||||
Plugin.handleNameUpdate(caller, c, newName);
|
||||
}
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
package mineplex.core.communities.commands;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.Managers;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.communities.Community;
|
||||
import mineplex.core.communities.CommunityManager;
|
||||
import mineplex.core.communities.CommunityMemberInfo;
|
||||
import mineplex.core.communities.CommunityRole;
|
||||
|
||||
public class CommunityUnInviteCommand extends CommandBase<CommunityManager>
|
||||
{
|
||||
public CommunityUnInviteCommand(CommunityManager plugin)
|
||||
{
|
||||
super(plugin, Rank.ALL, "uninvite");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
if (args.length < 2)
|
||||
{
|
||||
UtilPlayer.message(caller, F.help("/com uninvite <player> <community>", "Revokes a player's invitation to a community you manage", Rank.ALL));
|
||||
return;
|
||||
}
|
||||
String player = args[0];
|
||||
Community c = Plugin.getLoadedCommunity(args[1]);
|
||||
if (c == null)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.getName(), "That community was not found!"));
|
||||
return;
|
||||
}
|
||||
if (c.getMembers().getOrDefault(caller, new CommunityMemberInfo(caller.getName(), caller.getUniqueId(), -1, CommunityRole.MEMBER, -1L)).Role.ordinal() > CommunityRole.COLEADER.ordinal())
|
||||
{
|
||||
if (!Managers.get(CoreClientManager.class).Get(caller).GetRank().has(Rank.ADMIN))
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.getName(), "You are not a co-leader of " + F.name(c.getName()) + "!"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
Plugin.handleUninvite(caller, c, player);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user