Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 23 additions & 15 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,32 @@
name: Java CI
# Modified from https://blob.build/docs/upload/github-action/
name: Publish build

on:
push:
branches:
- master
pull_request:
branches:
- master
- master

jobs:
build:

publish:
name: Upload build
runs-on: ubuntu-latest
if: contains(github.event.head_commit.message, '[ci skip]') == false

steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3.4.1
with:
java-version: '17'
distribution: 'adopt'
- name: Build with Maven
run: mvn clean package
- uses: actions/checkout@v3

- name: Set up JDK 17
uses: actions/setup-java@v3.4.1
with:
java-version: "17"
distribution: "adopt"

- name: Build with Maven
run: mvn clean package

- name: Upload to Blob Builds
uses: WalshyDev/blob-builds/gh-action@main
with:
project: SlimeHUD
apiToken: ${{ secrets.BLOB_BUILDS_API_TOKEN }}
releaseNotes: ${{ github.event.head_commit.message }}
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,26 @@

Adds a WAILA (What Am I Looking At) HUD for Slimefun items. Can be set to display in the bossbar or above the hotbar in `config.yml`. Additional energy/cargo information can also be toggled on or off in `config.yml`. Individual players can also toggle their WAILA HUD with `/slimehud toggle`.

The HUD lets you see what Slimefun item a block is without breaking or opening its menu. It also displays additional information depending on the block, such as network size, cargo channel, and energy generation. See the [wiki](https://github.com/SchnTgaiSpock/SlimeHUD/wiki) for more details.
The HUD lets you see what Slimefun item a block is without breaking or opening its menu. It also displays additional information depending on the block, such as network size, cargo channel, and energy generation. See the [wiki](https://schn.pages.dev/slimehud) for more details.

## Preview

<https://user-images.githubusercontent.com/101147426/182007545-474a6596-b4e2-4a92-bdab-c18ed2286a94.mp4>

## PlaceholderAPI

- `%slimehud_toggle%` Returns the current player's toggle state. Possible values are `true` or `false`.
- `%slimehud_hud%` Standard hud, including block display name and additional information.
- `%slimehud_hud_block%` Only block display names.
- `%slimehud_hud_block_info%` Only additional information.

## Limitations

- Minecraft only has 7 colors for the bossbar, compared to 16 for regular items.

## API

API documentation can be found [here](https://github.com/SchnTgaiSpock/SlimeHUD/wiki/API-Usage) on the wiki.
API documentation can be found [here](https://schn.pages.dev/slimehud/api-usage) on the wiki.

## Requirements

Expand Down
47 changes: 36 additions & 11 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>io.github.schntgaispock.slimehud</groupId>
<artifactId>SlimeHUD</artifactId>
<version>1.2.7</version>
<version>1.3.1</version>

<properties>
<maven.compiler.source>17</maven.compiler.source>
Expand All @@ -26,6 +26,11 @@
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>

<repository>
<id>placeholderapi</id>
<url>https://repo.extendedclip.com/content/repositories/placeholderapi/</url>
</repository>
</repositories>

<build>
Expand All @@ -44,10 +49,22 @@
</resources>

<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.12.1</version>

<configuration>
<excludes>
<exclude>**/package-info.java</exclude>
</excludes>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.3.0</version>
<version>3.5.1</version>
<configuration>
<minimizeJar>true</minimizeJar>
<relocations>
Expand Down Expand Up @@ -92,7 +109,7 @@
<dependency>
<groupId>com.github.Slimefun</groupId>
<artifactId>Slimefun4</artifactId>
<version>RC-33</version>
<version>RC-37</version>
<scope>provided</scope>
<exclusions>
<exclusion>
Expand All @@ -110,16 +127,17 @@
</dependency>

<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.26</version>
<groupId>me.clip</groupId>
<artifactId>placeholderapi</artifactId>
<version>2.11.6</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
<version>1.3.2</version>
<scope>compile</scope>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.30</version>
<scope>provided</scope>
</dependency>

<dependency>
Expand All @@ -131,8 +149,15 @@
<dependency>
<groupId>org.bstats</groupId>
<artifactId>bstats-bukkit</artifactId>
<version>3.0.0</version>
<version>3.0.2</version>
<scope>compile</scope>
</dependency>

<dependency>
<groupId>net.guizhanss</groupId>
<artifactId>SlimefunTranslation</artifactId>
<version>81b930d5ad</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
22 changes: 21 additions & 1 deletion src/main/java/io/github/schntgaispock/slimehud/SlimeHUD.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

import javax.annotation.Nonnull;

import io.github.schntgaispock.slimehud.placeholder.PlaceholderManager;
import io.github.schntgaispock.slimehud.translation.TranslationManager;
import io.github.schntgaispock.slimehud.waila.HudController;
import org.bstats.bukkit.Metrics;
import org.bstats.charts.SimplePie;
Expand All @@ -12,18 +14,21 @@
import io.github.mooy1.infinitylib.core.AddonConfig;
import io.github.schntgaispock.slimehud.command.CommandManager;
import io.github.schntgaispock.slimehud.waila.WAILAManager;
import io.github.thebusybiscuit.slimefun4.libraries.dough.updater.BlobBuildUpdater;
import lombok.Getter;

public class SlimeHUD extends AbstractAddon {

@Getter AddonConfig playerData;
static @Getter SlimeHUD instance;
private HudController hudController;
private TranslationManager translationManager;

public SlimeHUD() {
super("SchnTgaiSpock", "SlimeHUD", "master", "options.auto-update");
}


@Override
public void enable() {
instance = this;
Expand All @@ -32,7 +37,16 @@ public void enable() {
getLogger().info("# SlimeHUD by SchnTgaiSpock #");
getLogger().info("#=================================#");

Metrics metrics = new Metrics(this, 15883);
if (getConfig().getBoolean("options.auto-update")) {
if (getDescription().getVersion().startsWith("Dev - ")) {
new BlobBuildUpdater(this, getFile(), "SlimeHUD", "Dev").start();
} else {
getLogger().info("This is an unofficial build of SlimeHUD, so auto updates are disabled!");
getLogger().info("You can download the official build here: https://blob.build/project/SlimeHUD");
}
}

final Metrics metrics = new Metrics(this, 15883);
metrics.addCustomChart(
new SimplePie("disabled", () -> {
return "" + getConfig().getBoolean("waila.disabled");
Expand All @@ -48,7 +62,9 @@ public void enable() {

WAILAManager.setup();
CommandManager.setup();
PlaceholderManager.setup();
hudController = new HudController();
translationManager = new TranslationManager();
}

@Override
Expand All @@ -61,6 +77,10 @@ public static HudController getHudController() {
return instance.hudController;
}

public static TranslationManager getTranslationManager() {
return instance.translationManager;
}

public static NamespacedKey newNamespacedKey(@Nonnull String name) {
return new NamespacedKey(SlimeHUD.getInstance(), name);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ private void sendInfo(Player player) {
"",
"§a§lSlimeHUD §7- §2Version " + SlimeHUD.getInstance().getPluginVersion(),
"§7------",
"§a§lWiki §7- §2https://github.com/SchnTgaiSpock/SlimeHUD/wiki",
"§a§lWiki §7- §2https://schn.pages.dev/slimehud",
"§a§lIssues §7- §2https://github.com/SchnTgaiSpock/SlimeHUD/issues",
""
);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package io.github.schntgaispock.slimehud.placeholder;

import io.github.schntgaispock.slimehud.SlimeHUD;
import io.github.schntgaispock.slimehud.waila.PlayerWAILA;
import io.github.schntgaispock.slimehud.waila.WAILAManager;
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
import org.bukkit.entity.Player;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;

public class PlaceholderHook extends PlaceholderExpansion {
private final WAILAManager wailaManager = WAILAManager.getInstance();

@Override
public @Nonnull String getIdentifier() {
return "slimehud";
}

@Override
public @Nonnull String getAuthor() {
return "TheLittle_Yang";
}

@Override
public @Nonnull String getVersion() {
return "1.0.0";
}

@Override
public boolean persist() {
return true;
}

@Override
public @Nullable String onPlaceholderRequest(Player player, @Nonnull String params) {
if (params.equalsIgnoreCase("toggle")) {
return SlimeHUD.getInstance().getPlayerData().getString(player.getUniqueId() + ".waila", "true");
} else if (params.startsWith("hud")) {
String[] split = params.split("_");
PlayerWAILA playerWAILA = wailaManager.getWailas().get(player.getUniqueId());
switch (split.length) {
case 1 -> {
return playerWAILA.getFacing();
}
case 2 -> {
return playerWAILA.getFacingBlock();
}
case 3 -> {
return playerWAILA.getFacingBlockInfo();
}
}
}

return null;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package io.github.schntgaispock.slimehud.placeholder;

import io.github.schntgaispock.slimehud.SlimeHUD;
import org.bukkit.Bukkit;

public class PlaceholderManager {
public static void setup() {
if (SlimeHUD.getInstance().getConfig().getBoolean("options.placeholder-api-support", true)) {
if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
new PlaceholderHook().register();
} else {
SlimeHUD.getInstance().getLogger().info("PlaceholderAPI is not installed and has been ignored.");
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package io.github.schntgaispock.slimehud.translation;

import io.github.schntgaispock.slimehud.SlimeHUD;
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
import net.guizhanss.slimefuntranslation.api.SlimefunTranslationAPI;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;

import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;

public class TranslationManager {
private boolean translationEnabled;

public TranslationManager() {
if (SlimeHUD.getInstance().getConfig().getBoolean("options.slimefun-translation-support", true)) {
if (Bukkit.getPluginManager().getPlugin("SlimefunTranslation") != null) {
translationEnabled = true;
} else {
SlimeHUD.getInstance().getLogger().info("SlimefunTranslation is not installed and has been ignored.");
translationEnabled = false;
}
}
}

@Nonnull
@ParametersAreNonnullByDefault
public String getItemName(Player p, SlimefunItem sfItem) {
if (!translationEnabled) {
return sfItem.getItemName();
}

try {
return SlimefunTranslationAPI.getItemName(SlimefunTranslationAPI.getUser(p), sfItem);
} catch (NoClassDefFoundError e) {
SlimeHUD.getInstance().getLogger().info("Could not get item translation! Please update SlimefunTranslation");
translationEnabled = false;
return sfItem.getItemName();
}
}
}
Loading