Added support for creating Event servers.
This commit is contained in:
parent
8a027872aa
commit
2dade32499
@ -0,0 +1,24 @@
|
||||
package mineplex.core.personalServer;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
|
||||
public class HostEventServerCommand extends CommandBase<PersonalServerManager>
|
||||
{
|
||||
public HostEventServerCommand(PersonalServerManager plugin)
|
||||
{
|
||||
super(plugin, Rank.ADMIN, "hostevent");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
if (!Recharge.Instance.use(caller, "Host Event", 30000, false, false))
|
||||
return;
|
||||
|
||||
Plugin.hostServer(caller, caller.getName(), true);
|
||||
}
|
||||
}
|
@ -19,6 +19,6 @@ public class HostServerCommand extends CommandBase<PersonalServerManager>
|
||||
if (!Recharge.Instance.use(caller, "Host Server", 30000, false, false))
|
||||
return;
|
||||
|
||||
Plugin.hostServer(caller, caller.getName());
|
||||
Plugin.hostServer(caller, caller.getName(), false);
|
||||
}
|
||||
}
|
||||
|
@ -100,6 +100,7 @@ public class PersonalServerManager extends MiniPlugin
|
||||
public void addCommands()
|
||||
{
|
||||
addCommand(new HostServerCommand(this));
|
||||
addCommand(new HostEventServerCommand(this));
|
||||
}
|
||||
|
||||
private void setupConfigValues()
|
||||
@ -117,23 +118,26 @@ public class PersonalServerManager extends MiniPlugin
|
||||
}
|
||||
}
|
||||
|
||||
public void hostServer(Player player, String serverName)
|
||||
public void hostServer(Player player, String serverName, boolean eventServer)
|
||||
{
|
||||
int ram = 1024;
|
||||
int cpu = 1;
|
||||
|
||||
Rank rank = _clientManager.Get(player).GetRank();
|
||||
|
||||
if (rank.Has(Rank.SNR_MODERATOR) || rank == Rank.YOUTUBE)
|
||||
if (eventServer || rank.Has(Rank.SNR_MODERATOR) || rank == Rank.YOUTUBE)
|
||||
{
|
||||
ram = 2048;
|
||||
cpu = 3;
|
||||
cpu = 4;
|
||||
}
|
||||
|
||||
createGroup(player, serverName, ram, cpu, 12, 24, "Smash");
|
||||
if (eventServer)
|
||||
createGroup(player, "EVENT", ram, cpu, 40, 80, "Event", eventServer);
|
||||
else
|
||||
createGroup(player, serverName, ram, cpu, 40, 80, "Smash", eventServer);
|
||||
}
|
||||
|
||||
private void createGroup(final Player host, final String serverName, final int ram, final int cpu, final int minPlayers, final int maxPlayers, final String games)
|
||||
private void createGroup(final Player host, final String serverName, final int ram, final int cpu, final int minPlayers, final int maxPlayers, final String games, final boolean event)
|
||||
{
|
||||
getPlugin().getServer().getScheduler().runTaskAsynchronously(getPlugin(), new Runnable()
|
||||
{
|
||||
@ -144,7 +148,7 @@ public class PersonalServerManager extends MiniPlugin
|
||||
if (existingServerGroup.getPrefix().equalsIgnoreCase(serverName) || existingServerGroup.getName().equalsIgnoreCase(serverName))
|
||||
{
|
||||
if (host.getName().equalsIgnoreCase(existingServerGroup.getHost()))
|
||||
host.sendMessage(F.main(getName(), "Your server is still being created. If you haven't been connected in 20 seconds, type /server " + serverName + "-1."));
|
||||
host.sendMessage(F.main(getName(), "Your server is still being created or already exists. If you haven't been connected in 20 seconds, type /server " + serverName + "-1."));
|
||||
else
|
||||
host.sendMessage(C.cRed + "Sorry, but you're not allowed to create a MPS server because you have chosen a name to glitch the system :)");
|
||||
|
||||
@ -153,7 +157,7 @@ public class PersonalServerManager extends MiniPlugin
|
||||
}
|
||||
|
||||
final ServerGroup serverGroup = new ServerGroup(serverName, serverName, host.getName(), ram, cpu, 1, 0, UtilMath.random.nextInt(250) + 19999, true, "arcade.zip", "Arcade.jar", "plugins/Arcade/", minPlayers, maxPlayers,
|
||||
true, false, false, games, "Player", true, false, true, false, true, true, false, false, false, false, true, true, true, false, false, "", _us ? Region.US : Region.EU);
|
||||
true, false, false, games, "Player", true, event, false, true, false, true, true, false, false, false, false, true, true, true, false, false, "", _us ? Region.US : Region.EU);
|
||||
|
||||
getPlugin().getServer().getScheduler().runTaskAsynchronously(getPlugin(), new Runnable()
|
||||
{
|
||||
|
@ -52,6 +52,7 @@ public class ServerGroup
|
||||
private String _games;
|
||||
private String _serverType;
|
||||
private boolean _addNoCheat;
|
||||
private boolean _addWorldEdit;
|
||||
private boolean _whitelist;
|
||||
private boolean _staffOnly;
|
||||
private String _resourcePack = "";
|
||||
@ -82,6 +83,7 @@ public class ServerGroup
|
||||
_games = data.get("games");
|
||||
_serverType = data.get("serverType");
|
||||
_addNoCheat = Boolean.valueOf(data.get("addNoCheat"));
|
||||
_addWorldEdit = Boolean.valueOf(data.get("addWorldEdit"));
|
||||
_teamRejoin = Boolean.valueOf(data.get("teamRejoin"));
|
||||
_teamAutoJoin = Boolean.valueOf(data.get("teamAutoJoin"));
|
||||
_teamForceBalance = Boolean.valueOf(data.get("teamForceBalance"));
|
||||
@ -105,7 +107,7 @@ public class ServerGroup
|
||||
}
|
||||
|
||||
public ServerGroup(String name, String prefix, String host, int ram, int cpu, int totalServers, int joinable, int portSection, boolean arcade, String worldZip, String plugin, String configPath
|
||||
, int minPlayers, int maxPlayers, boolean pvp, boolean tournament, boolean tournamentPoints, String games, String serverType, boolean noCheat, boolean teamRejoin
|
||||
, int minPlayers, int maxPlayers, boolean pvp, boolean tournament, boolean tournamentPoints, String games, String serverType, boolean noCheat, boolean worldEdit, boolean teamRejoin
|
||||
, boolean teamAutoJoin, boolean teamForceBalance, boolean gameAutoStart, boolean gameTimeout, boolean rewardGems, boolean rewardItems, boolean rewardStats
|
||||
, boolean rewardAchievements, boolean hotbarInventory, boolean hotbarHubClock, boolean playerKickIdle, boolean staffOnly, boolean whitelist, String resourcePack, Region region)
|
||||
{
|
||||
@ -129,6 +131,7 @@ public class ServerGroup
|
||||
_games = games;
|
||||
_serverType = serverType;
|
||||
_addNoCheat = noCheat;
|
||||
_addWorldEdit = worldEdit;
|
||||
_teamRejoin = teamRejoin;
|
||||
_teamAutoJoin = teamAutoJoin;
|
||||
_teamForceBalance = teamForceBalance;
|
||||
@ -187,6 +190,7 @@ public class ServerGroup
|
||||
public String getGames() { return _games; }
|
||||
public String getServerType() { return _serverType; }
|
||||
public boolean getAddNoCheat() { return _addNoCheat; }
|
||||
public boolean getAddWorldEdit() { return _addWorldEdit; }
|
||||
public boolean getWhitelist() { return _whitelist; }
|
||||
public boolean getStaffOnly() { return _staffOnly; }
|
||||
public String getResourcePack() { return _resourcePack; }
|
||||
|
@ -641,7 +641,7 @@ public class ServerMonitor
|
||||
final String serverName = serverSpace.getName();
|
||||
final String serverAddress = serverSpace.getPublicAddress();
|
||||
|
||||
ProcessRunner pr = new ProcessRunner(new String[] {"/bin/sh", cmd, serverAddress, serverSpace.getPrivateAddress(), (serverGroup.getPortSection() + serverNum) + "", serverGroup.getRequiredRam() + "", serverGroup.getWorldZip(), serverGroup.getPlugin(), serverGroup.getConfigPath(), serverGroup.getName(), serverGroup.getPrefix() + "-" + serverNum, serverSpace.isUsRegion() ? "true" : "false", serverGroup.getAddNoCheat() + "" });
|
||||
ProcessRunner pr = new ProcessRunner(new String[] {"/bin/sh", cmd, serverAddress, serverSpace.getPrivateAddress(), (serverGroup.getPortSection() + serverNum) + "", serverGroup.getRequiredRam() + "", serverGroup.getWorldZip(), serverGroup.getPlugin(), serverGroup.getConfigPath(), serverGroup.getName(), serverGroup.getPrefix() + "-" + serverNum, serverSpace.isUsRegion() ? "true" : "false", serverGroup.getAddNoCheat() + "", serverGroup.getAddWorldEdit() + "" });
|
||||
pr.start(new GenericRunnable<Boolean>()
|
||||
{
|
||||
public void run(Boolean error)
|
||||
|
Loading…
Reference in New Issue
Block a user