Updated ServerConfiguration to support resourcepack and Arcade settings.
This commit is contained in:
parent
6f2a6a6ebd
commit
f931bd26e6
3
.gitignore
vendored
3
.gitignore
vendored
@ -26,3 +26,6 @@ Servers
|
||||
Debug
|
||||
*.gitignore
|
||||
/Maps/GRASER UHC
|
||||
/MutualNDA (1)-signed.pdf
|
||||
/MutualNDA - signed-signed.pdf
|
||||
/MutualNDA - signed.pdf
|
||||
|
@ -1,8 +1,6 @@
|
||||
package mineplex.core.serverConfig;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import net.minecraft.server.v1_7_R4.PlayerList;
|
||||
|
||||
@ -27,8 +25,6 @@ public class ServerConfiguration extends MiniPlugin
|
||||
|
||||
for (ServerGroup serverGroup : ServerManager.getServerRepository(region).getServerGroups())
|
||||
{
|
||||
System.out.println(serverGroup.getName());
|
||||
|
||||
if (serverGroup.getName().equalsIgnoreCase(plugin.getConfig().getString("serverstatus.group")))
|
||||
{
|
||||
_serverGroup = serverGroup;
|
||||
@ -39,9 +35,6 @@ public class ServerConfiguration extends MiniPlugin
|
||||
if (_serverGroup == null)
|
||||
return;
|
||||
|
||||
if (_serverGroup.getWhitelist())
|
||||
_plugin.getServer().setWhitelist(true);
|
||||
|
||||
try
|
||||
{
|
||||
_playerListMaxPlayers = PlayerList.class.getDeclaredField("maxPlayers");
|
||||
@ -53,7 +46,9 @@ public class ServerConfiguration extends MiniPlugin
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
_plugin.getServer().setWhitelist(_serverGroup.getWhitelist());
|
||||
((CraftServer)_plugin.getServer()).getServer().setPvP(_serverGroup.getPvp());
|
||||
((CraftServer)_plugin.getServer()).getServer().setTexturePack(_serverGroup.getResourcePack());
|
||||
}
|
||||
|
||||
public ServerGroup getServerGroup()
|
||||
|
@ -80,7 +80,7 @@ public class Hub extends JavaPlugin implements IRelation
|
||||
|
||||
DonationManager donationManager = new DonationManager(this, webServerAddress);
|
||||
|
||||
ServerConfiguration configuration = new ServerConfiguration(this);
|
||||
new ServerConfiguration(this);
|
||||
|
||||
//Other Modules
|
||||
PreferencesManager preferenceManager = new PreferencesManager(this, clientManager, donationManager);
|
||||
|
@ -68,6 +68,9 @@ public class ServerGroup
|
||||
private boolean _tournament;
|
||||
public boolean getTournament() { return _tournament; }
|
||||
|
||||
private boolean _tournamentPoints;
|
||||
public boolean getTournamentPoints() { return _tournamentPoints; }
|
||||
|
||||
private boolean _teamRejoin;
|
||||
public boolean getTeamRejoin() { return _teamRejoin; }
|
||||
|
||||
@ -122,6 +125,8 @@ public class ServerGroup
|
||||
private boolean _staffOnly;
|
||||
public boolean getStaffOnly() { return _staffOnly; }
|
||||
|
||||
private String _resourcePack;
|
||||
public String getResourcePack() { return _resourcePack; }
|
||||
// The set of active MinecraftServers that belong to this server group
|
||||
private Set<MinecraftServer> _servers;
|
||||
public Set<MinecraftServer> getServers() { return _servers; }
|
||||
@ -150,6 +155,7 @@ public class ServerGroup
|
||||
_maxPlayers = Integer.valueOf(data.get("maxPlayers"));
|
||||
_pvp = Boolean.valueOf(data.get("pvp"));
|
||||
_tournament = Boolean.valueOf(data.get("tournament"));
|
||||
_tournamentPoints = Boolean.valueOf(data.get("tournamentPoints"));
|
||||
_generateFreeVersions = Boolean.valueOf(data.get("generateFreeVersions"));
|
||||
_games = data.get("games");
|
||||
_serverType = data.get("serverType");
|
||||
@ -168,6 +174,7 @@ public class ServerGroup
|
||||
_playerKickIdle = Boolean.valueOf(data.get("playerKickIdle"));
|
||||
_staffOnly = Boolean.valueOf(data.get("staffOnly"));
|
||||
_whitelist = Boolean.valueOf(data.get("whitelist"));
|
||||
_resourcePack = data.get("resourcePack");
|
||||
|
||||
fetchServers(region);
|
||||
}
|
||||
|
@ -416,12 +416,12 @@ public class ServerMonitor
|
||||
|
||||
private static void startServer(final DedicatedServer serverSpace, final ServerGroup serverGroup, final int serverNum, final boolean free)
|
||||
{
|
||||
String cmd = "/home/mineplex/easyRemoteStartServer.sh";
|
||||
String cmd = "/home/mineplex/easyRemoteStartServerCustom.sh";
|
||||
final String groupPrefix = serverGroup.getPrefix();
|
||||
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, serverGroup.getMinPlayers() + "", serverGroup.getMaxPlayers() + "", serverGroup.getPvp() + "", serverGroup.getTournament() + "", free + "", serverSpace.isUsRegion() ? "true" : "false", serverGroup.getArcadeGroup() + "", serverGroup.getGames(), serverGroup.getServerType(), serverGroup.getAddNoCheat() + "", serverGroup.getTeamAutoJoin() + "", serverGroup.getTeamForceBalance() + "", serverGroup.getTeamRejoin() + "", serverGroup.getGameAutoStart() + "", serverGroup.getGameTimeout() + "", serverGroup.getHotbarHubClock() + "", serverGroup.getHotbarInventory() + "", serverGroup.getPlayerKickIdle() + "", serverGroup.getRewardGems() + "", serverGroup.getRewardItems() + "", serverGroup.getRewardAchievements() + "", serverGroup.getRewardStats() + ""});
|
||||
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() + "" });
|
||||
pr.start(new GenericRunnable<Boolean>()
|
||||
{
|
||||
public void run(Boolean error)
|
||||
|
@ -1,12 +1,6 @@
|
||||
package nautilus.game.arcade;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileWriter;
|
||||
import java.io.InputStreamReader;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
@ -42,6 +36,7 @@ import mineplex.core.preferences.PreferencesManager;
|
||||
import mineplex.core.projectile.ProjectileManager;
|
||||
import mineplex.core.punish.Punish;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import mineplex.core.serverConfig.ServerConfiguration;
|
||||
import mineplex.core.spawn.Spawn;
|
||||
import mineplex.core.status.ServerStatusManager;
|
||||
import mineplex.core.teleport.Teleport;
|
||||
@ -62,6 +57,8 @@ public class Arcade extends JavaPlugin
|
||||
|
||||
private ArcadeManager _gameManager;
|
||||
|
||||
private ServerConfiguration _serverConfiguration;
|
||||
|
||||
@Override
|
||||
public void onEnable()
|
||||
{
|
||||
@ -87,6 +84,8 @@ public class Arcade extends JavaPlugin
|
||||
|
||||
_donationManager = new DonationManager(this, webServerAddress);
|
||||
|
||||
_serverConfiguration = new ServerConfiguration(this);
|
||||
|
||||
PreferencesManager preferenceManager = new PreferencesManager(this, _clientManager, _donationManager);
|
||||
new MessageManager(this, _clientManager, preferenceManager);
|
||||
|
||||
@ -133,7 +132,6 @@ public class Arcade extends JavaPlugin
|
||||
MinecraftServer.getServer().getPropertyManager().setProperty("debug", true);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onDisable()
|
||||
{
|
||||
@ -149,103 +147,29 @@ public class Arcade extends JavaPlugin
|
||||
{
|
||||
GameServerConfig config = new GameServerConfig();
|
||||
|
||||
//Load Track Data
|
||||
String line = null;
|
||||
config.ServerType = _serverConfiguration.getServerGroup().getServerType();
|
||||
config.MinPlayers = _serverConfiguration.getServerGroup().getMinPlayers();
|
||||
config.MaxPlayers = _serverConfiguration.getServerGroup().getMaxPlayers();
|
||||
config.Tournament = _serverConfiguration.getServerGroup().getTournament();
|
||||
config.TournamentPoints = _serverConfiguration.getServerGroup().getTournamentPoints();
|
||||
config.TeamRejoin = _serverConfiguration.getServerGroup().getTeamRejoin();
|
||||
config.TeamAutoJoin = _serverConfiguration.getServerGroup().getTeamAutoJoin();
|
||||
config.TeamForceBalance = _serverConfiguration.getServerGroup().getTeamForceBalance();
|
||||
config.GameAutoStart = _serverConfiguration.getServerGroup().getGameAutoStart();
|
||||
config.GameTimeout = _serverConfiguration.getServerGroup().getGameTimeout();
|
||||
config.RewardGems = _serverConfiguration.getServerGroup().getRewardGems();
|
||||
config.RewardItems = _serverConfiguration.getServerGroup().getRewardItems();
|
||||
config.RewardStats = _serverConfiguration.getServerGroup().getRewardStats();
|
||||
config.RewardAchievements = _serverConfiguration.getServerGroup().getRewardAchievements();
|
||||
config.HotbarInventory = _serverConfiguration.getServerGroup().getHotbarInventory();
|
||||
config.HotbarHubClock = _serverConfiguration.getServerGroup().getHotbarHubClock();
|
||||
config.PlayerKickIdle = _serverConfiguration.getServerGroup().getPlayerKickIdle();
|
||||
|
||||
try
|
||||
{
|
||||
File file = new File("ArcadeSettings.config");
|
||||
if (!file.exists())
|
||||
WriteServerConfig(GetDefaultConfig());
|
||||
|
||||
FileInputStream fstream = new FileInputStream("ArcadeSettings.config");
|
||||
DataInputStream in = new DataInputStream(fstream);
|
||||
BufferedReader br = new BufferedReader(new InputStreamReader(in));
|
||||
|
||||
while ((line = br.readLine()) != null)
|
||||
{
|
||||
String[] tokens = line.split("=");
|
||||
|
||||
if (tokens.length < 2)
|
||||
continue;
|
||||
|
||||
if (tokens[0].equals("SERVER_TYPE"))
|
||||
{
|
||||
config.ServerType = tokens[1];
|
||||
}
|
||||
else if (tokens[0].equals("PLAYERS_MIN"))
|
||||
{
|
||||
config.MinPlayers = Integer.parseInt(tokens[1]);
|
||||
}
|
||||
else if (tokens[0].equals("PLAYERS_MAX"))
|
||||
{
|
||||
config.MaxPlayers = Integer.parseInt(tokens[1]);
|
||||
}
|
||||
else if (tokens[0].equals("TOURNAMENT"))
|
||||
{
|
||||
config.Tournament = Boolean.parseBoolean(tokens[1]);
|
||||
}
|
||||
else if (tokens[0].equals("TOURNAMENT_POINTS"))
|
||||
{
|
||||
config.TournamentPoints = Boolean.parseBoolean(tokens[1]);
|
||||
}
|
||||
else if (tokens[0].equals("TEAM_REJOIN"))
|
||||
{
|
||||
config.TeamRejoin = Boolean.parseBoolean(tokens[1]);
|
||||
}
|
||||
else if (tokens[0].equals("TEAM_AUTO_JOIN"))
|
||||
{
|
||||
config.TeamAutoJoin = Boolean.parseBoolean(tokens[1]);
|
||||
}
|
||||
else if (tokens[0].equals("TEAM_FORCE_BALANCE"))
|
||||
{
|
||||
config.TeamForceBalance = Boolean.parseBoolean(tokens[1]);
|
||||
}
|
||||
else if (tokens[0].equals("GAME_AUTO_START"))
|
||||
{
|
||||
config.GameAutoStart = Boolean.parseBoolean(tokens[1]);
|
||||
}
|
||||
else if (tokens[0].equals("GAME_TIMEOUT"))
|
||||
{
|
||||
config.GameTimeout = Boolean.parseBoolean(tokens[1]);
|
||||
}
|
||||
else if (tokens[0].equals("REWARD_GEMS"))
|
||||
{
|
||||
config.RewardGems = Boolean.parseBoolean(tokens[1]);
|
||||
}
|
||||
else if (tokens[0].equals("REWARD_ITEMS"))
|
||||
{
|
||||
config.RewardItems = Boolean.parseBoolean(tokens[1]);
|
||||
}
|
||||
else if (tokens[0].equals("REWARD_STATS"))
|
||||
{
|
||||
config.RewardStats = Boolean.parseBoolean(tokens[1]);
|
||||
}
|
||||
else if (tokens[0].equals("REWARD_ACHIEVEMENTS"))
|
||||
{
|
||||
config.RewardAchievements = Boolean.parseBoolean(tokens[1]);
|
||||
}
|
||||
else if (tokens[0].equals("HOTBAR_INVENTORY"))
|
||||
{
|
||||
config.HotbarInventory = Boolean.parseBoolean(tokens[1]);
|
||||
}
|
||||
else if (tokens[0].equals("HOTBAR_HUB_CLOCK"))
|
||||
{
|
||||
config.HotbarHubClock = Boolean.parseBoolean(tokens[1]);
|
||||
}
|
||||
else if (tokens[0].equals("PLAYER_KICK_IDLE"))
|
||||
{
|
||||
config.PlayerKickIdle = Boolean.parseBoolean(tokens[1]);
|
||||
}
|
||||
//Games
|
||||
else
|
||||
for (String gameName : _serverConfiguration.getServerGroup().getGames().split(","))
|
||||
{
|
||||
try
|
||||
{
|
||||
GameType type = GameType.valueOf(tokens[0]);
|
||||
boolean enabled = Boolean.valueOf(tokens[1]);
|
||||
|
||||
if (enabled)
|
||||
GameType type = GameType.valueOf(gameName);
|
||||
config.GameList.add(type);
|
||||
}
|
||||
catch (Exception e)
|
||||
@ -254,19 +178,9 @@ public class Arcade extends JavaPlugin
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
in.close();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
if (!config.IsValid())
|
||||
config = GetDefaultConfig();
|
||||
|
||||
WriteServerConfig(config);
|
||||
return config;
|
||||
}
|
||||
|
||||
@ -282,53 +196,6 @@ public class Arcade extends JavaPlugin
|
||||
return config;
|
||||
}
|
||||
|
||||
public void WriteServerConfig(GameServerConfig config)
|
||||
{
|
||||
try
|
||||
{
|
||||
FileWriter fstream = new FileWriter("ArcadeSettings.config");
|
||||
BufferedWriter out = new BufferedWriter(fstream);
|
||||
|
||||
out.write("SERVER_TYPE=" + config.ServerType + "\n");
|
||||
out.write("PLAYERS_MIN=" + config.MinPlayers + "\n");
|
||||
out.write("PLAYERS_MAX=" + config.MaxPlayers + "\n");
|
||||
|
||||
out.write("\nTOURNAMENT=" + config.Tournament + "\n");
|
||||
|
||||
out.write("\nTOURNAMENT_POINTS=" + config.TournamentPoints + "\n");
|
||||
|
||||
out.write("\nTEAM_REJOIN=" + config.TeamRejoin + "\n");
|
||||
out.write("TEAM_AUTO_JOIN=" + config.TeamAutoJoin + "\n");
|
||||
out.write("TEAM_FORCE_BALANCE=" + config.TeamForceBalance + "\n");
|
||||
|
||||
out.write("\nGAME_AUTO_START=" + config.GameAutoStart + "\n");
|
||||
out.write("GAME_TIMEOUT=" + config.GameTimeout + "\n");
|
||||
|
||||
out.write("\nREWARD_GEMS=" + config.RewardGems + "\n");
|
||||
out.write("REWARD_ITEMS=" + config.RewardItems + "\n");
|
||||
out.write("REWARD_STATS=" + config.RewardStats + "\n");
|
||||
out.write("REWARD_ACHIEVEMENTS=" + config.RewardAchievements + "\n");
|
||||
|
||||
out.write("\nHOTBAR_INVENTORY=" + config.HotbarInventory + "\n");
|
||||
out.write("HOTBAR_HUB_CLOCK=" + config.HotbarHubClock + "\n");
|
||||
|
||||
out.write("\nPLAYER_KICK_IDLE=" + config.PlayerKickIdle + "\n");
|
||||
|
||||
out.write("\n\nGames List;\n");
|
||||
|
||||
for (GameType type : GameType.values())
|
||||
{
|
||||
out.write(type.toString() + "=" + config.GameList.contains(type) + "\n");
|
||||
}
|
||||
|
||||
out.close();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void DeleteFolders()
|
||||
{
|
||||
File curDir = new File(".");
|
||||
|
Loading…
Reference in New Issue
Block a user