forked from regelneef/necessities
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCommandMemInfo.java
More file actions
51 lines (36 loc) · 1.63 KB
/
CommandMemInfo.java
File metadata and controls
51 lines (36 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package kdx7214.necessities;
import java.util.List;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.server.MinecraftServer;
import net.minecraft.src.ModLoader;
import net.minecraft.command.* ;
import net.minecraft.entity.player.EntityPlayer;
public class CommandMemInfo extends CommandBaseNecessities {
public CommandMemInfo() {
}
public String getCommandName()
{
return "meminfo";
}
public String getCommandUsage(ICommandSender par1ICommandSender)
{
return "/" + getCommandName() ;
}
public void processCommand(ICommandSender sender, String[] par2ArrayOfStr)
{
MinecraftServer server = ModLoader.getMinecraftServerInstance() ;
EntityPlayer player = getCommandSenderAsPlayer(sender) ;
long maxmem = Runtime.getRuntime().maxMemory() / 1024L / 1024L ;
long usedmem = (Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) / 1024L / 1024L ;
long percent = Runtime.getRuntime().freeMemory() * 100L / Runtime.getRuntime().maxMemory() ;
int loadedChunks = NecessitiesMain.instance.necessities_data.getInteger("[Chunks]") ;
String msg = "Memory: " + usedmem + "MB used out of " + maxmem + "MB (" + percent + "% free)" ;
player.addChatMessage(msg) ;
msg = "Loaded Chunks: " + loadedChunks ;
player.addChatMessage(msg) ;
} // public void processCommand(...)
@Override
public boolean canCommandSenderUseCommand(ICommandSender sender) {
return hasPermission(sender, "necessities.meminfo", false, false) ;
} // public boolean canCommandSenderUseCommand(...)
} // public class CommandMemInfo