generated from ybw0014/GuizhanSlimefunAddon
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
37 changed files
with
881 additions
and
76 deletions.
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
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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# SlimefunTranslation | ||
|
||
[English](./README.md) | [简体中文](./README.zh-CN.md) | ||
|
||
A [Slimefun4](https://github.com/Slimefun/Slimefun4) addon that translates Slimefun items (also supports addons). It does not modify the actual item, instead modifying the packets. The display language will be based on player's Slimefun language setting. | ||
|
||
## Download | ||
|
||
### Dependencies | ||
|
||
- [ProtocolLib](https://www.spigotmc.org/resources/protocollib.1997/) is required dependency. You may need to download the development version if you are on 1.20+. | ||
- [PlaceholderAPI](https://www.spigotmc.org/resources/placeholderapi.6245/) is optional dependency. It is required if you want to use placeholders in the translation. | ||
|
||
### Blob Builds | ||
|
||
Blob Builds (official builds page for Slimefun and addons): [Click to go](https://blob.build/project/SlimefunTranslation/Dev) | ||
|
||
### Guizhan Builds | ||
|
||
Guizhan Builds (my own builds page, all my addons are also available there): | ||
|
||
[![Build Status](https://builds.guizhanss.com/api/badge/ybw0014/SlimefunTranslation/master/latest)](https://builds.guizhanss.com/ybw0014/SlimefunTranslation/master) | ||
|
||
## Wiki | ||
|
||
For usage and more information, please visit our [Wiki](https://docs.ybw0014.dev/slimefuntranslation/). |
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,17 @@ | ||
# SlimefunTranslation 粘液翻译 | ||
|
||
[English](./README.md) | [简体中文](./README.zh-CN.md) | ||
|
||
A [Slimefun4](https://github.com/Slimefun/Slimefun4) addon that translates Slimefun items (also supports addons). It does not modify the actual item, instead modifying the packets. The display language will be based on player's Slimefun language setting. | ||
|
||
## Download | ||
|
||
[ProtocolLib](https://www.spigotmc.org/resources/protocollib.1997/) is required dependency. You may need to download the development version if you are on 1.20+. | ||
|
||
Click the image below to download SlimefunTranslation: | ||
|
||
[![Build Status](https://builds.guizhanss.com/api/badge/ybw0014/SlimefunTranslation/master/latest)](https://builds.guizhanss.com/ybw0014/SlimefunTranslation/master) | ||
|
||
## Wiki | ||
|
||
For usage and more information, please visit our [Wiki](https://docs.ybw0014.dev/slimefuntranslation/). |
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,4 @@ | ||
files: | ||
- source: /src/main/resources/languages/en/*.yml | ||
translation: /src/main/resources/languages/%osx_locale%/%original_file_name% | ||
|
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,6 @@ | ||
before_install: | ||
- sdk install java 17.0.1-open | ||
- sdk use java 17.0.1-open | ||
|
||
jdk: | ||
- openjdk17 |
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"$schema": "https://docs.renovatebot.com/renovate-schema.json", | ||
"extends": [ | ||
"config:base", | ||
":disableDependencyDashboard" | ||
] | ||
} |
55 changes: 0 additions & 55 deletions
55
src/main/java/net/guizhanss/guizhanslimefunaddon/GuizhanSlimefunAddon.java
This file was deleted.
Oops, something went wrong.
93 changes: 93 additions & 0 deletions
93
src/main/java/net/guizhanss/slimefuntranslation/SlimefunTranslation.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,93 @@ | ||
package net.guizhanss.slimefuntranslation; | ||
|
||
import java.io.File; | ||
import java.lang.reflect.Method; | ||
import java.util.logging.Level; | ||
|
||
import org.bukkit.plugin.Plugin; | ||
|
||
import io.github.thebusybiscuit.slimefun4.libraries.dough.updater.BlobBuildUpdater; | ||
|
||
import net.guizhanss.guizhanlib.slimefun.addon.AbstractAddon; | ||
import net.guizhanss.guizhanlib.updater.GuizhanBuildsUpdater; | ||
import net.guizhanss.slimefuntranslation.core.Registry; | ||
import net.guizhanss.slimefuntranslation.implementation.managers.CommandManager; | ||
import net.guizhanss.slimefuntranslation.implementation.managers.ListenerManager; | ||
import net.guizhanss.slimefuntranslation.implementation.managers.PacketListenerManager; | ||
import net.guizhanss.slimefuntranslation.implementation.managers.TranslationManager; | ||
import net.guizhanss.slimefuntranslation.implementation.managers.UserManager; | ||
|
||
import org.bstats.bukkit.Metrics; | ||
|
||
public final class SlimefunTranslation extends AbstractAddon { | ||
|
||
private Registry registry; | ||
private UserManager userManager; | ||
private TranslationManager translationManager; | ||
|
||
public SlimefunTranslation() { | ||
super("ybw0014", "SlimefunTranslation", "master", "auto-update"); | ||
} | ||
|
||
private static SlimefunTranslation inst() { | ||
return getInstance(); | ||
} | ||
|
||
public static Registry getRegistry() { | ||
return inst().registry; | ||
} | ||
|
||
public static UserManager getUserManager() { | ||
return inst().userManager; | ||
} | ||
|
||
public static TranslationManager getTranslationManager() { | ||
return inst().translationManager; | ||
} | ||
|
||
@Override | ||
public void enable() { | ||
log(Level.INFO, "===================="); | ||
log(Level.INFO, "Slimefun Translation"); | ||
log(Level.INFO, " by ybw0014 "); | ||
log(Level.INFO, "===================="); | ||
|
||
registry = new Registry(); | ||
userManager = new UserManager(); | ||
translationManager = new TranslationManager(this); | ||
new CommandManager(this); | ||
new ListenerManager(this); | ||
new PacketListenerManager(); | ||
|
||
setupMetrics(); | ||
|
||
getScheduler().runAsync(() -> { | ||
translationManager.loadTranslations(); | ||
}); | ||
} | ||
|
||
@Override | ||
public void disable() { | ||
} | ||
|
||
private void setupMetrics() { | ||
new Metrics(this, 20496); | ||
} | ||
|
||
@Override | ||
protected void autoUpdate() { | ||
if (getPluginVersion().startsWith("Dev")) { | ||
new BlobBuildUpdater(this, getFile(), getGithubRepo()).start(); | ||
} else if (getPluginVersion().startsWith("Build")) { | ||
try { | ||
// use updater in lib plugin | ||
Class<?> clazz = Class.forName("net.guizhanss.guizhanlibplugin.updater.GuizhanUpdater"); | ||
Method updaterStart = clazz.getDeclaredMethod("start", Plugin.class, File.class, String.class, String.class, String.class); | ||
updaterStart.invoke(null, this, getFile(), getGithubUser(), getGithubRepo(), getGithubBranch()); | ||
} catch (Exception ignored) { | ||
// use updater in lib | ||
new GuizhanBuildsUpdater(this, getFile(), getGithubUser(), getGithubRepo(), getGithubBranch()).start(); | ||
} | ||
} | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
src/main/java/net/guizhanss/slimefuntranslation/api/TranslationConfiguration.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,25 @@ | ||
package net.guizhanss.slimefuntranslation.api; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import net.guizhanss.slimefuntranslation.api.interfaces.Translation; | ||
|
||
import lombok.Getter; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
/** | ||
* This class holds the information provided from a valid translations file, or from other addons. | ||
* | ||
* @author ybw0014 | ||
*/ | ||
@RequiredArgsConstructor | ||
@Getter | ||
public class TranslationConfiguration { | ||
private final String name; | ||
private final String author; | ||
private final boolean enabled; | ||
private final String lang; | ||
|
||
private final Map<String, Translation> translations = new HashMap<>(); | ||
} |
19 changes: 19 additions & 0 deletions
19
src/main/java/net/guizhanss/slimefuntranslation/api/interfaces/Translatable.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,19 @@ | ||
package net.guizhanss.slimefuntranslation.api.interfaces; | ||
|
||
import java.util.List; | ||
|
||
import javax.annotation.Nonnull; | ||
|
||
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; | ||
|
||
/** | ||
* This interface should be implemented by a {@link SlimefunItem}. | ||
* It means the {@link SlimefunItem} can be translated from code. | ||
*/ | ||
public interface Translatable { | ||
@Nonnull | ||
String getTranslatedDisplayName(String original); | ||
|
||
@Nonnull | ||
List<String> getTranslatedLore(List<String> original); | ||
} |
Oops, something went wrong.