Skip to content

Instantly share code, notes, and snippets.

@sabinM1
Created June 16, 2021 07:45
Show Gist options
  • Save sabinM1/6d41867acefc9a88483d057483c23dbc to your computer and use it in GitHub Desktop.
Save sabinM1/6d41867acefc9a88483d057483c23dbc to your computer and use it in GitHub Desktop.
ActualRAM decompiled

As described by the author, ActualRAM is a small plugin that helps you find out how much RAM your server really needs.

I do not own this plugin, it was posted on Reddit (archived link) with only a jar file.

Some people were interested in the source code, so I decompiled it using Java Decompiler.

4df96ccf72becd2f1bc68b1360e5a62be3cd9fc6e6efed1e8bf1bb85cd178a1e
/* */ package com.dusti;
/* */
/* */ import com.dusti.commands.ActualRAMCommands;
/* */ import org.bukkit.command.CommandExecutor;
/* */ import org.bukkit.plugin.java.JavaPlugin;
/* */
/* */ public class ActualRAM extends JavaPlugin {
/* */ public void onEnable() {
/* 10 */ ActualRAMCommands commands = new ActualRAMCommands();
/* 11 */ getCommand("showram").setExecutor((CommandExecutor)commands);
/* 12 */ System.out.println("ActualRAM enabled");
/* */ }
/* */
/* */ public void onDisable() {
/* 17 */ System.out.println("ActualRAM disabled");
/* */ }
/* */ }
/* Location: /home/sabin/Downloads/ActualRAM.jar!/com/dusti/ActualRAM.class
* Java compiler version: 8 (52.0)
* JD-Core Version: 1.1.3
*/
/* */ package com.dusti.commands;
/* */
/* */ import org.bukkit.ChatColor;
/* */ import org.bukkit.command.Command;
/* */ import org.bukkit.command.CommandExecutor;
/* */ import org.bukkit.command.CommandSender;
/* */
/* */ public class ActualRAMCommands implements CommandExecutor {
/* */ public boolean onCommand(CommandSender commandSender, Command command, String s, String[] args) {
/* 11 */ if (command.getName().equalsIgnoreCase("showram"))
/* */ try {
/* 13 */ Runtime r = Runtime.getRuntime();
/* 14 */ float usedMemory = (float)(r.totalMemory() - r.freeMemory()) / 1048576.0F;
/* 15 */ int usedMemoryPercentage = (int)(100.0F * usedMemory / (float)(r.maxMemory() / 1048576L));
/* 16 */ commandSender.sendMessage(ChatColor.DARK_GREEN + "[ActualRAM] §aCurrent RAM Usage: §f" + (int)usedMemory + "§a/§f" + (r.totalMemory() / 1048576L) + "§a/§f" + (r.maxMemory() / 1048576L) + "§aMB (§f" + usedMemoryPercentage + "§a%)");
/* 17 */ } catch (IllegalArgumentException e) {
/* 18 */ commandSender.sendMessage(ChatColor.RED + "[ActualRAM] §cAn error occurred while executing this command.");
/* */ }
/* 21 */ return true;
/* */ }
/* */ }
/* Location: /home/sabin/Downloads/ActualRAM.jar!/com/dusti/commands/ActualRAMCommands.class
* Java compiler version: 8 (52.0)
* JD-Core Version: 1.1.3
*/
main: com.dusti.ActualRAM
name: ActualRAM
version: 1
author: Dusti
commands:
showram:
description: Shows current memory usage
aliases: actualram
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment