Convert to MCS system for community servers and add a command to open them
This commit is contained in:
parent
0668e31710
commit
bd4fa1f2d4
|
@ -49,6 +49,7 @@ import mineplex.serverdata.data.DataRepository;
|
||||||
import mineplex.serverdata.data.PlayerStatus;
|
import mineplex.serverdata.data.PlayerStatus;
|
||||||
import mineplex.serverdata.redis.RedisDataRepository;
|
import mineplex.serverdata.redis.RedisDataRepository;
|
||||||
import mineplex.serverdata.servers.ServerManager;
|
import mineplex.serverdata.servers.ServerManager;
|
||||||
|
import mineplex.serverdata.servers.ServerRepository;
|
||||||
|
|
||||||
public class CommunityManager extends MiniDbClientPlugin<CommunityMemberData>
|
public class CommunityManager extends MiniDbClientPlugin<CommunityMemberData>
|
||||||
{
|
{
|
||||||
|
@ -59,6 +60,9 @@ public class CommunityManager extends MiniDbClientPlugin<CommunityMemberData>
|
||||||
|
|
||||||
public final DataRepository<PlayerStatus> StatusRepository;
|
public final DataRepository<PlayerStatus> StatusRepository;
|
||||||
|
|
||||||
|
private ServerRepository _serverRepo;
|
||||||
|
private boolean _us;
|
||||||
|
|
||||||
private boolean _cycling = false;
|
private boolean _cycling = false;
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
|
@ -69,6 +73,11 @@ public class CommunityManager extends MiniDbClientPlugin<CommunityMemberData>
|
||||||
StatusRepository = new RedisDataRepository<PlayerStatus>(ServerManager.getMasterConnection(), ServerManager.getSlaveConnection(),
|
StatusRepository = new RedisDataRepository<PlayerStatus>(ServerManager.getMasterConnection(), ServerManager.getSlaveConnection(),
|
||||||
Region.currentRegion(), PlayerStatus.class, "playerStatus");
|
Region.currentRegion(), PlayerStatus.class, "playerStatus");
|
||||||
|
|
||||||
|
_us = plugin.getConfig().getBoolean("serverstatus.us");
|
||||||
|
|
||||||
|
Region region = _us ? Region.US : Region.EU;
|
||||||
|
_serverRepo = ServerManager.getServerRepository(region);
|
||||||
|
|
||||||
_repo = new CommunityRepository(plugin, StatusRepository);
|
_repo = new CommunityRepository(plugin, StatusRepository);
|
||||||
|
|
||||||
_loadedCommunities = new HashMap<>();
|
_loadedCommunities = new HashMap<>();
|
||||||
|
|
|
@ -21,6 +21,7 @@ public class CommunityCommand extends MultiCommandBase<CommunityManager>
|
||||||
AddCommand(new CommunityDescriptionCommand(plugin));
|
AddCommand(new CommunityDescriptionCommand(plugin));
|
||||||
AddCommand(new CommunityDisbandCommand(plugin));
|
AddCommand(new CommunityDisbandCommand(plugin));
|
||||||
AddCommand(new CommunityInviteCommand(plugin));
|
AddCommand(new CommunityInviteCommand(plugin));
|
||||||
|
AddCommand(new CommunityMCSCommand(plugin));
|
||||||
AddCommand(new CommunityMenuCommand(plugin));
|
AddCommand(new CommunityMenuCommand(plugin));
|
||||||
AddCommand(new CommunityRenameCommand(plugin));
|
AddCommand(new CommunityRenameCommand(plugin));
|
||||||
AddCommand(new CommunityUnInviteCommand(plugin));
|
AddCommand(new CommunityUnInviteCommand(plugin));
|
||||||
|
@ -50,6 +51,7 @@ public class CommunityCommand extends MultiCommandBase<CommunityManager>
|
||||||
UtilPlayer.message(caller, F.help("/com chat <community>", "Selects which community you chat to", 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 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 rename <community> <name>", "Changes the name of a community you own", Rank.ETERNAL));
|
||||||
|
UtilPlayer.message(caller, F.help("/com mcs <community>", "Opens the Mineplex Community Server of a community you manage", Rank.ALL));
|
||||||
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 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));
|
UtilPlayer.message(caller, F.help("/com disband <community>", "Disbands a community you own", Rank.ETERNAL));
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,49 @@
|
||||||
|
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.personalServer.PersonalServerManager;
|
||||||
|
|
||||||
|
public class CommunityMCSCommand extends CommandBase<CommunityManager>
|
||||||
|
{
|
||||||
|
public CommunityMCSCommand(CommunityManager plugin)
|
||||||
|
{
|
||||||
|
super(plugin, Rank.ALL, "mcs");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void Execute(Player caller, String[] args)
|
||||||
|
{
|
||||||
|
if (args.length < 1)
|
||||||
|
{
|
||||||
|
UtilPlayer.message(caller, F.help("/com mcs <community>", "Opens the Mineplex Community Server of a community you manage", 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().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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Managers.get(PersonalServerManager.class).hostCommunityServer(caller, c);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,50 @@
|
||||||
|
package mineplex.core.communities.mps;
|
||||||
|
|
||||||
|
import org.bukkit.Material;
|
||||||
|
|
||||||
|
import mineplex.core.common.util.C;
|
||||||
|
|
||||||
|
public enum MCSTheme
|
||||||
|
{
|
||||||
|
CANDYLAND(1, C.cPurple + "Candyland", Material.COOKIE, 1000, "Lobby_MPS_Candyland.zip")
|
||||||
|
;
|
||||||
|
|
||||||
|
private final int _id;
|
||||||
|
private final String _displayName, _file;
|
||||||
|
private final Material _displayType;
|
||||||
|
private final int _cost;
|
||||||
|
|
||||||
|
private MCSTheme(int id, String displayName, Material displayType, int cost, String file)
|
||||||
|
{
|
||||||
|
_id = id;
|
||||||
|
_displayName = displayName;
|
||||||
|
_displayType = displayType;
|
||||||
|
_cost = cost;
|
||||||
|
_file = file;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getId()
|
||||||
|
{
|
||||||
|
return _id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDisplayName()
|
||||||
|
{
|
||||||
|
return _displayName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Material getDisplayType()
|
||||||
|
{
|
||||||
|
return _displayType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCost()
|
||||||
|
{
|
||||||
|
return _cost;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFile()
|
||||||
|
{
|
||||||
|
return _file;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue