mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-27 01:05:38 +00:00
Formatting cleanup.
Added ignore for unchecked cast warning.
This commit is contained in:
parent
bcd9658b3d
commit
d4dfe06ec0
@ -21,7 +21,6 @@ public class Command_health extends TFM_Command
|
||||
|
||||
new BukkitRunnable()
|
||||
{
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
@ -40,7 +39,8 @@ public class Command_health extends TFM_Command
|
||||
new BukkitRunnable()
|
||||
{
|
||||
@Override
|
||||
public void run() {
|
||||
public void run()
|
||||
{
|
||||
playerMsg("Reserved Memory: " + runtime.totalMemory() / mb + "mb");
|
||||
playerMsg("Used Memory: " + new DecimalFormat("#").format(usedMem / mb) + "mb (" + new DecimalFormat("#").format((usedMem / runtime.totalMemory()) * 100) + "%)");
|
||||
playerMsg("Max Memory: " + runtime.maxMemory() / mb + "mb");
|
||||
@ -54,7 +54,6 @@ public class Command_health extends TFM_Command
|
||||
TFM_Log.warning(ExceptionUtils.getStackTrace(iex));
|
||||
}
|
||||
}
|
||||
|
||||
}.runTaskAsynchronously(TotalFreedomMod.plugin);
|
||||
|
||||
return true;
|
||||
|
@ -9,10 +9,11 @@ import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.ALL, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Shows the status of all Mojang services", usage = "/<command>")
|
||||
public class Command_services extends TFM_Command {
|
||||
|
||||
public class Command_services extends TFM_Command
|
||||
{
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) {
|
||||
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
playerMsg("Mojang Services" + ChatColor.WHITE + ":", ChatColor.BLUE);
|
||||
|
||||
for (TFM_ServiceChecker_ServiceStatus service : TFM_ServiceChecker.getInstance().getAllStatuses())
|
||||
@ -24,5 +25,4 @@ public class Command_services extends TFM_Command {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,25 +1,12 @@
|
||||
package me.StevenLawson.TotalFreedomMod.Commands;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_Log;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
import org.json.simple.JSONValue;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.ALL, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Show misc. server info.", usage = "/<command>")
|
||||
@ -50,68 +37,6 @@ public class Command_status extends TFM_Command
|
||||
playerMsg(String.format("World %d: %s - %d players.", i++, world.getName(), world.getPlayers().size()), ChatColor.BLUE);
|
||||
}
|
||||
|
||||
/* Moved to TFM_ServiceChecker and Command_services
|
||||
new BukkitRunnable()
|
||||
{
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
try
|
||||
{
|
||||
URL mojang_status = new URL("http://status.mojang.com/check");
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(mojang_status.openStream()));
|
||||
JSONArray status_json = (JSONArray) JSONValue.parse(in.readLine());
|
||||
in.close();
|
||||
|
||||
Map<String, Boolean> service_status = new HashMap<String, Boolean>();
|
||||
|
||||
Iterator status_it = status_json.iterator();
|
||||
while (status_it.hasNext())
|
||||
{
|
||||
JSONObject service = (JSONObject) status_it.next();
|
||||
Iterator service_it = service.entrySet().iterator();
|
||||
while (service_it.hasNext())
|
||||
{
|
||||
Entry<String, String> pair = (Entry<String, String>) service_it.next();
|
||||
service_status.put(pair.getKey(), (pair.getValue().equals("green") ? Boolean.TRUE : Boolean.FALSE));
|
||||
}
|
||||
}
|
||||
|
||||
final List<String> status_output = new ArrayList<String>();
|
||||
|
||||
Iterator<Entry<String, Boolean>> output_it = service_status.entrySet().iterator();
|
||||
while (output_it.hasNext())
|
||||
{
|
||||
Entry<String, Boolean> pair = output_it.next();
|
||||
String service_name = pair.getKey();
|
||||
boolean service_online = pair.getValue().booleanValue();
|
||||
|
||||
if (SERVICE_MAP.containsKey(service_name))
|
||||
{
|
||||
service_name = SERVICE_MAP.get(service_name);
|
||||
}
|
||||
|
||||
status_output.add(String.format("%s is %s", service_name, (service_online ? ChatColor.GREEN + "ONLINE" + ChatColor.GRAY : ChatColor.RED + "OFFLINE" + ChatColor.GRAY)));
|
||||
}
|
||||
|
||||
new BukkitRunnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
playerMsg(String.format("Mojang Service Status: %s.", StringUtils.join(status_output, ", ")), ChatColor.GRAY);
|
||||
}
|
||||
}.runTask(plugin);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TFM_Log.severe(ex);
|
||||
}
|
||||
}
|
||||
}.runTaskAsynchronously(plugin);
|
||||
*/
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -20,5 +20,4 @@ public class Command_tfm extends TFM_Command
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -32,12 +32,11 @@ public class TFM_ServiceChecker
|
||||
services.put("session.minecraft.net", new TFM_ServiceChecker_ServiceStatus("Minecraft Sessions (Legacy)"));
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public BukkitRunnable getUpdateRunnable()
|
||||
{
|
||||
return new BukkitRunnable()
|
||||
{
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
@ -166,7 +165,7 @@ public class TFM_ServiceChecker
|
||||
|
||||
if (!TFM_ServiceChecker.getInstance().version.contains("Mojang"))
|
||||
{
|
||||
status += " (" + getUptimeColor() + getUptime() + ChatColor.WHITE + "%)";
|
||||
status += " (" + getUptimeColor() + getUptime() + ChatColor.WHITE + "%)";
|
||||
}
|
||||
|
||||
return status;
|
||||
@ -202,7 +201,5 @@ public class TFM_ServiceChecker
|
||||
{
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user