Skip to content
This repository has been archived by the owner on Mar 4, 2023. It is now read-only.

Commit

Permalink
Update 1.1
Browse files Browse the repository at this point in the history
The addon is called "CPU Info" now
New more accurate icon
Added new GUI-Editor tab "CPU Info"
You now can also show your core amount
-> If your CPU is hyperthreading you have to activate "Is your CPU hyperthreading?" in the addon settings or else your cores will not be shown correctly.
  • Loading branch information
RappyTV committed Jun 29, 2022
1 parent 6d77780 commit fd12f1f
Show file tree
Hide file tree
Showing 13 changed files with 146 additions and 41 deletions.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
# **CPU Usage Display**
> With this plugin you can add a new module to your screen which displays your current CPU usage.
> With this plugin you can add two new modules to your screen which display your current CPU usage in percent and your amount of cores.
### Installation
1. Press `Win` + `R`
2. Paste this into the window that popped up: `%appdata%/.minecraft/LabyMod/addons-1.12` and press enter
3. It should open your Labymod addon directory; Paste the [CPU-Usage-Display.jar](https://github.com/RappyTV/CPU-Usage-Display/releases/download/1.0.0/CPU-Usage-Display.jar) in there.
4. Launch your Labymod client.

### Config
- "Is your CPU hyperthreading?" - You have to activate this if your CPU is hyperthreading or else the cores will not be shown correctly
<br>

[How to find out if my CPU is hyper-threading](https://www.techwalla.com/articles/how-to-tell-if-my-cpu-is-hyper-threading)

If you have any problems with the addon/have update ideas, feel free to
- Open an Issue [here](https://github.com/RappyTV/CPU-Usage-Display/issues/new/choose)
or
Expand Down
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ apply plugin: 'net.minecraftforge.gradle.forge'
//Only edit below this line, the above code adds and enables the necessary things for Forge to be setup.


version = "1.0.1"
group = "com.rappytv.cpudisplay" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "cpudisplay"
version = "2"
group = "com.rappytv.cpuinfo" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "cpuinfo"

sourceCompatibility = targetCompatibility = '1.8' // Need this here so eclipse task generates correctly.
compileJava {
Expand Down
21 changes: 0 additions & 21 deletions src/main/java/com/rappytv/cpudisplay/main/Main.java

This file was deleted.

49 changes: 49 additions & 0 deletions src/main/java/com/rappytv/cpuinfo/main/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package com.rappytv.cpuinfo.main;

import com.rappytv.cpuinfo.modules.Category;
import com.rappytv.cpuinfo.modules.cpu.CoreModule;
import com.rappytv.cpuinfo.modules.cpu.PercentUsageModule;
import com.sun.management.OperatingSystemMXBean;
import net.labymod.api.LabyModAddon;
import net.labymod.ingamegui.ModuleCategoryRegistry;
import net.labymod.settings.elements.BooleanElement;
import net.labymod.settings.elements.ControlElement;
import net.labymod.settings.elements.SettingsElement;
import net.labymod.utils.Consumer;
import net.minecraft.util.ResourceLocation;

import java.lang.management.ManagementFactory;
import java.util.List;

public class Main extends LabyModAddon {

public static final OperatingSystemMXBean os = (OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean();
public static boolean hyper = false;

@Override
public void onEnable() {
ModuleCategoryRegistry.loadCategory(new Category());
getApi().registerModule(new PercentUsageModule());
getApi().registerModule(new CoreModule());
}

@Override
public void loadConfig() {
hyper = getConfig().has("hyperthreading") ? getConfig().get("hyperthreading").getAsBoolean() : hyper;
}

@Override
protected void fillSettings(List<SettingsElement> list) {
BooleanElement hyperbool = new BooleanElement("Is your CPU hyperthreading?", new ControlElement.IconData(new ResourceLocation("cpuinfo/textures/settings/portal.png")), new Consumer<Boolean>() {
@Override
public void accept(Boolean accepted) {
hyper = accepted;

getConfig().addProperty("hyperthreading", hyper);
saveConfig();
}
}, hyper);

list.add(hyperbool);
}
}
13 changes: 13 additions & 0 deletions src/main/java/com/rappytv/cpuinfo/modules/Category.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.rappytv.cpuinfo.modules;

import net.labymod.ingamegui.ModuleCategory;
import net.labymod.settings.elements.ControlElement;
import net.minecraft.util.ResourceLocation;

public class Category extends ModuleCategory {


public Category() {
super("CPU Info", true, new ControlElement.IconData(new ResourceLocation("cpuinfo/textures/icon.png")));
}
}
61 changes: 61 additions & 0 deletions src/main/java/com/rappytv/cpuinfo/modules/cpu/CoreModule.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package com.rappytv.cpuinfo.modules.cpu;

import com.rappytv.cpuinfo.main.Main;
import com.rappytv.cpuinfo.modules.Category;
import net.labymod.ingamegui.ModuleCategory;
import net.labymod.ingamegui.moduletypes.SimpleModule;
import net.labymod.settings.elements.ControlElement;
import net.minecraft.util.ResourceLocation;

public class CoreModule extends SimpleModule {

@Override
public String getDisplayName() {
return "Cores";
}

@Override
public String getDisplayValue() {
int cores = Runtime.getRuntime().availableProcessors();
if(Main.hyper) cores /= 2;
return String.valueOf(cores);
}

@Override
public String getDefaultValue() {
return "4";
}

@Override
public ControlElement.IconData getIconData() {
return new ControlElement.IconData(new ResourceLocation("cpuinfo/textures/modules/cores.png"));
}

@Override
public void loadSettings() {}

@Override
public String getSettingName() {
return "cpu_cores";
}

@Override
public String getControlName() {
return "CPU Cores";
}

@Override
public String getDescription() {
return "Displays the quantity of cores your CPU has.";
}

@Override
public int getSortingId() {
return 7;
}

@Override
public ModuleCategory getCategory() {
return new Category();
}
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
package com.rappytv.cpudisplay.modules;
package com.rappytv.cpuinfo.modules.cpu;

import com.rappytv.cpuinfo.main.Main;
import com.rappytv.cpuinfo.modules.Category;
import net.labymod.ingamegui.ModuleCategory;
import net.labymod.ingamegui.ModuleCategoryRegistry;
import net.labymod.ingamegui.moduletypes.SimpleModule;
import net.labymod.settings.elements.ControlElement;

import com.sun.management.OperatingSystemMXBean;
import net.minecraft.util.ResourceLocation;

import java.lang.management.ManagementFactory;

public class CPUModule extends SimpleModule {

private final OperatingSystemMXBean os = (OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean();
public class PercentUsageModule extends SimpleModule {

@Override
public String getDisplayName() {
Expand All @@ -21,17 +18,17 @@ public String getDisplayName() {

@Override
public String getDisplayValue() {
return ((int) (os.getSystemCpuLoad() * 100)) + "%";
return ((int) (Main.os.getSystemCpuLoad() * 100)) + "%";
}

@Override
public String getDefaultValue() {
return String.valueOf(0);
return "9%";
}

@Override
public ControlElement.IconData getIconData() {
return new ControlElement.IconData(new ResourceLocation("cpu_usage/textures/icon.png"));
return new ControlElement.IconData(new ResourceLocation("cpuinfo/textures/modules/percentage.png"));
}

@Override
Expand All @@ -49,7 +46,7 @@ public String getControlName() {

@Override
public String getDescription() {
return "Displays the current CPU Usage on your screen.";
return "Displays the current CPU Usage.";
}

@Override
Expand All @@ -59,6 +56,6 @@ public int getSortingId() {

@Override
public ModuleCategory getCategory() {
return ModuleCategoryRegistry.CATEGORY_INFO;
return new Category();
}
}
8 changes: 4 additions & 4 deletions src/main/resources/addon.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"uuid": "%uuid%",
"name": "CPU Usage Display",
"mainClass": "com.rappytv.cpudisplay.main.Main",
"name": "CPU Info",
"mainClass": "com.rappytv.cpuinfo.main.Main",
"description": "This addon lets you add a new module called \"CPU Usage\" to your screen which displays your current CPU Usage in %",
"version": 1,
"version": 2,
"author": "RappyTV#6969",
"category": 1,
"icon": "https://cdn.discordapp.com/attachments/962708390805655593/974966193544904754/icon.png"
"icon": "https://cdn.discordapp.com/attachments/938944740920016916/991304102699081858/icon.png"
}
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit fd12f1f

Please sign in to comment.