javaminecraftsensorsoshi

Why is this happening when retrieving info from sensors via OSHI API?


I'm using the OSHI API in a Maven Project which I've implemented into my plugin, which works correctly with 0 errors. Although i don't get any errors some of the OSHI API are returning strange values which I'm not able to understand what do they mean and why they're not showing up correctly.

I've tried to check if my code had any errors but it doesn't look like it's my fault.

private oshi.SystemInfo si = new SystemInfo();
private HardwareAbstractionLayer hw = si.getHardware();
private Sensors sensor = hw.getSensors();

// Here sending the Fans RPM:
sender.sendMessage(Utils.chat("&7Fans: &e " + sensor.getFanSpeeds() + "&e RPM"));

I did not expect the output RPM to be like this:

Fans: [I@2f86d3c9 RPM

I have tested the code on a server with Linux Manjaro and Fans with 1700RPM (looked through ASUS Drivers) and the Fan are working correctly.


Solution

  • Welcome to StackOverflow.

    The fan speeds return value is an int[] array, so you can't just concatenate it in a string, or you'll get the object reference of the array.

    Use Arrays.toString(sensor.getFanSpeeds()) and you should get more useful output.