Fixed double server status manager in MK

Fixed tps of 0.
Fixed couple bugs in Shop/Conf page.
This commit is contained in:
Jonathan Williams 2013-09-26 21:18:31 -07:00
parent f0e6a7294e
commit b71ff09fb5
8 changed files with 44 additions and 24 deletions

Binary file not shown.

View File

@ -10,6 +10,16 @@
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.ui.externaltools.ExternalToolBuilder</name>
<triggers>auto,full,incremental,</triggers>
<arguments>
<dictionary>
<key>LaunchConfigHandle</key>
<value>&lt;project&gt;/.externalToolBuilders/Core.launch</value>
</dictionary>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>

View File

@ -78,7 +78,6 @@ public class LagMeter extends MiniPlugin
if (_count % 30 == 0)
{
_ticksPerSecondAverage = 30000D / (now - _lastAverage) * 20D;
_ticksPerSecond = 0;
_lastAverage = now;
}

View File

@ -235,7 +235,7 @@ public class ConfirmationPage<PluginType extends MiniPlugin, ShopType extends Sh
Bukkit.getScheduler().cancelTask(_taskId);
if (_returnPage != null)
if (_returnPage != null && Shop != null)
Shop.SetCurrentPageForPlayer(Player, _returnPage);
}
@ -264,11 +264,11 @@ public class ConfirmationPage<PluginType extends MiniPlugin, ShopType extends Sh
{
Bukkit.getScheduler().cancelTask(_taskId);
if (_returnPage != null)
if (_returnPage != null && Shop != null)
{
Shop.OpenPageForPlayer(Player, _returnPage);
}
else
else if (Player != null)
{
Player.closeInventory();
}

View File

@ -143,5 +143,7 @@ public abstract class ShopPageBase<PluginType extends MiniPlugin, ShopType exten
{
Player = null;
Client = null;
Shop = null;
Plugin = null;
}
}

View File

@ -38,7 +38,7 @@ public class ServerStatusManager extends MiniPlugin
GetPluginManager().callEvent(event);
loadServerTrackerValues();
setupConfigValues();
String address = "localhost";
@ -57,7 +57,7 @@ public class ServerStatusManager extends MiniPlugin
for (NetworkInterface netint : Collections.list(nets))
{
if (netint.getDisplayName().equalsIgnoreCase("eth1"))
if (netint.getDisplayName().equalsIgnoreCase("eth0"))
{
Enumeration<InetAddress> inetAddresses = netint.getInetAddresses();
for (InetAddress inetAddress : Collections.list(inetAddresses))
@ -80,7 +80,14 @@ public class ServerStatusManager extends MiniPlugin
try
{
_repository = new ServerStatusRepository(plugin.getConfig().getString("serverstatus.name"), plugin.getConfig().getString("serverstatus.group"), address + ":" + _plugin.getServer().getPort(), event.getMaxPlayers());
_repository = new ServerStatusRepository(
plugin.getConfig().getString("serverstatus.connectionurl"),
plugin.getConfig().getString("serverstatus.username"),
plugin.getConfig().getString("serverstatus.password"),
plugin.getConfig().getString("serverstatus.name"),
plugin.getConfig().getString("serverstatus.group"),
address + ":" + _plugin.getServer().getPort(), event.getMaxPlayers()
);
_repository.initialize();
}
catch (Exception ex)
@ -89,22 +96,23 @@ public class ServerStatusManager extends MiniPlugin
}
}
private void loadServerTrackerValues()
private void setupConfigValues()
{
FileConfiguration yamlConfig = new YamlConfiguration();
File serverTrackerConfig = new File("plugins/ServerTracker/config.yml");
if (!serverTrackerConfig.exists())
return;
try
{
yamlConfig.load(serverTrackerConfig);
GetPlugin().getConfig().addDefault("serverstatus.name", yamlConfig.get("servertracker.informations.name"));
GetPlugin().getConfig().addDefault("serverstatus.connectionurl", "jdbc:mysql://sql.mineplex.com:3306/ServerStatus");
GetPlugin().getConfig().set("serverstatus.connectionurl", GetPlugin().getConfig().getString("serverstatus.connectionurl"));
GetPlugin().getConfig().addDefault("serverstatus.username", "root");
GetPlugin().getConfig().set("serverstatus.username", GetPlugin().getConfig().getString("serverstatus.username"));
GetPlugin().getConfig().addDefault("serverstatus.password", "tAbechAk3wR7tuTh");
GetPlugin().getConfig().set("serverstatus.password", GetPlugin().getConfig().getString("serverstatus.password"));
GetPlugin().getConfig().addDefault("serverstatus.name", "TEST-1");
GetPlugin().getConfig().set("serverstatus.name", GetPlugin().getConfig().getString("serverstatus.name"));
GetPlugin().getConfig().addDefault("serverstatus.group", yamlConfig.get("servertracker.informations.group"));
GetPlugin().getConfig().addDefault("serverstatus.group", "Testing");
GetPlugin().getConfig().set("serverstatus.group", GetPlugin().getConfig().getString("serverstatus.group"));
GetPlugin().saveConfig();

View File

@ -11,9 +11,9 @@ import java.util.List;
public class ServerStatusRepository
{
private String _connectionString = "jdbc:mysql://sql.mineplex.com:3306/ServerStatus";
private String _userName = "root";
private String _password = "tAbechAk3wR7tuTh";
private String _connectionString;
private String _userName;
private String _password;
private static String CREATE_TABLE = "CREATE TABLE IF NOT EXISTS ServerStatus (id INT NOT NULL AUTO_INCREMENT, serverName VARCHAR(256), serverGroup VARCHAR(256), address VARCHAR(256), updated LONG, motd VARCHAR(256), players INT, maxPlayers INT, tps INT, ram INT, maxRam INT, PRIMARY KEY (id));";
private static String INSERT_PLAYER_COUNT = "INSERT INTO ServerStatus values(default, ?, ?, ?, now(), 'Configuring server.', ?, ?, 0, ?, ?);";
@ -27,8 +27,11 @@ public class ServerStatusRepository
private String _address;
private int _maxPlayers = 0;
public ServerStatusRepository(String serverName, String serverGroup, String address, int maxPlayers)
public ServerStatusRepository(String connectionUrl, String username, String password, String serverName, String serverGroup, String address, int maxPlayers)
{
_connectionString = connectionUrl;
_userName = username;
_password = password;
_serverName = serverName;
_serverGroup = serverGroup;
_address = address;

View File

@ -145,8 +145,6 @@ public class MineKart extends JavaPlugin implements INautilusPlugin, Listener
new MemoryFix(this);
new ServerStatusManager(this, new LagMeter(this, _clientManager));
getServer().getPluginManager().registerEvents(this, this);
CreateFakeKarts();