-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from SlimefunGuguProject/upstream/feat/slimefun…
…-translation feat: SlimefunTranslation integration
- Loading branch information
Showing
6 changed files
with
56 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
src/main/java/io/github/schntgaispock/slimehud/translation/TranslationManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package io.github.schntgaispock.slimehud.translation; | ||
|
||
import io.github.schntgaispock.slimehud.SlimeHUD; | ||
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; | ||
import net.guizhanss.slimefuntranslation.SlimefunTranslation; | ||
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(); | ||
} | ||
return SlimefunTranslation.getTranslationService().getTranslatedItemName( | ||
SlimefunTranslation.getUserService().getUser(p), | ||
sfItem | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ depend: | |
|
||
softdepend: | ||
- PlaceholderAPI | ||
- SlimefunTranslation | ||
|
||
commands: | ||
slimehud: | ||
|