Skip to content

Commit

Permalink
feat: infrastructure
Browse files Browse the repository at this point in the history
  • Loading branch information
ybw0014 committed Dec 22, 2023
1 parent 3324ff4 commit 768e2f4
Show file tree
Hide file tree
Showing 37 changed files with 881 additions and 76 deletions.
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/bug-report-cn.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ body:
required: false
- label: 你没有对下载的文件内容进行任何更改
required: true
- label: 你已经寻找过[已知问题列表](https://github.com/ybw0014/GuizhanSlimefunAddon/issues),且没有找到相同的问题
- label: 你已经寻找过[已知问题列表](https://github.com/ybw0014/SlimefunTranslation/issues),且没有找到相同的问题
required: true

- type: textarea
Expand Down Expand Up @@ -126,4 +126,4 @@ body:
只需填写Build后面的数字版本即可
(`Build 7 zh-CN(ybw0014) (git 9ef7fee)`只需填写`7`即可)
validations:
required: true
required: true
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug-report-en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ body:
attributes:
value: |
## Welcome to Bug Tracker
Please take a look at [How to report bugs](https://github.com/Slimefun/Slimefun4/wiki/How-to-report-bugs) and [existing Issues](https://github.com/ybw0014/GuizhanSlimefunAddon/issues).
Please take a look at [How to report bugs](https://github.com/Slimefun/Slimefun4/wiki/How-to-report-bugs) and [existing Issues](https://github.com/ybw0014/SlimefunTranslation/issues).
<strong><i>Fields marked with an asterisk (*) are required.</i></strong>
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ jobs:
if: startsWith(github.event.head_commit.message, '[CI skip]') == false
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3.5.3
- uses: actions/checkout@v4
- name: Set up JDK 16
uses: actions/setup-java@v3.11.0
uses: actions/setup-java@v4
with:
java-version: 16
java-version: 17
distribution: temurin
- name: Build with Maven
run: mvn package --file pom.xml
4 changes: 2 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,7 @@ Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:

GuizhanSlimefunAddon Copyright (C) 2022 ybw0014
SlimefunTranslation Copyright (C) 2023 ybw0014
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
Expand All @@ -671,4 +671,4 @@ into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<https://www.gnu.org/licenses/why-not-lgpl.html>.
<https://www.gnu.org/licenses/why-not-lgpl.html>.
26 changes: 26 additions & 0 deletions README.md
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/).
17 changes: 17 additions & 0 deletions README.zh-CN.md
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/).
4 changes: 4 additions & 0 deletions crowdin.yml
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%

6 changes: 6 additions & 0 deletions jitpack.yml
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
25 changes: 18 additions & 7 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>

<groupId>net.guizhanss</groupId>
<artifactId>GuizhanSlimefunAddon</artifactId>
<artifactId>SlimefunTranslation</artifactId>
<version>UNOFFICIAL</version>
<packaging>jar</packaging>

Expand Down Expand Up @@ -45,7 +45,7 @@
<relocations>
<relocation>
<pattern>org.bstats</pattern>
<shadedPattern>net.guizhanss.guizhanslimefunaddon.bstats</shadedPattern>
<shadedPattern>net.guizhanss.slimefuntranslation.bstats</shadedPattern>
</relocation>
</relocations>
</configuration>
Expand Down Expand Up @@ -77,6 +77,10 @@
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
<repository>
<id>dmulloy2-repo</id>
<url>https://repo.dmulloy2.net/repository/public/</url>
</repository>
</repositories>

<dependencies>
Expand All @@ -88,9 +92,9 @@
</dependency>

<dependency>
<groupId>io.github.Slimefun</groupId>
<groupId>com.github.Slimefun</groupId>
<artifactId>Slimefun4</artifactId>
<version>RC-34</version>
<version>bbfb9734b9</version>
<scope>provided</scope>
<exclusions>
<exclusion>
Expand All @@ -103,7 +107,7 @@
<dependency>
<groupId>org.bstats</groupId>
<artifactId>bstats-bukkit</artifactId>
<version>3.0.0</version>
<version>3.0.1</version>
<scope>compile</scope>
</dependency>

Expand All @@ -116,8 +120,15 @@

<dependency>
<groupId>net.guizhanss</groupId>
<artifactId>GuizhanLibPlugin</artifactId>
<version>1.3.1</version>
<artifactId>GuizhanLib-api</artifactId>
<version>1.7.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>

<dependency>
<groupId>com.comphenix.protocol</groupId>
<artifactId>ProtocolLib</artifactId>
<version>4.7.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
Expand Down
7 changes: 7 additions & 0 deletions renovate.json
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"
]
}

This file was deleted.

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();
}
}
}
}
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<>();
}
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);
}
Loading

0 comments on commit 768e2f4

Please sign in to comment.