-
Notifications
You must be signed in to change notification settings - Fork 2
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
23 changed files
with
838 additions
and
292 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
name: TpaForm 自动构建 | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
build: | ||
|
||
if: contains(github.event.head_commit.message, '[构建跳过]') == false | ||
runs-on: ubuntu-latest | ||
|
||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: '17' | ||
distribution: 'temurin' | ||
server-id: github # Value of the distributionManagement/repository/id field of the pom.xml | ||
settings-path: ${{ github.workspace }} # location for the settings.xml file | ||
|
||
- name: Build with Maven | ||
run: mvn package --file pom.xml | ||
- name: Archive artifacts | ||
uses: actions/upload-artifact@v3 | ||
if: success() | ||
with: | ||
name: TpaForm | ||
path: target/TpaForm.jar | ||
- name: Automatic Releases | ||
uses: marvinpinto/[email protected] | ||
if: success() | ||
with: | ||
repo_token: "${{ secrets.GITHUB_TOKEN }}" | ||
automatic_release_tag: "dev" | ||
prerelease: false | ||
title: "TpaForm 自动构建版本" | ||
files: | | ||
target/TpaForm.jar | ||
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 |
---|---|---|
@@ -1,2 +1,4 @@ | ||
# Tpa | ||
TPA命令BE Form支持 | ||
## TpaForm Tpa Form支持 | ||
为Tpa相关命令添加Form菜单,基于命令监听实现 | ||
## 前置 | ||
* Floodgate (2.2.0版本以上) - 用于基岩版菜单 |
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,55 @@ | ||
package ltd.rymc.form.tpa; | ||
|
||
import co.aikar.commands.PaperCommandManager; | ||
import ltd.rymc.form.tpa.commands.TpaFormCommand; | ||
import ltd.rymc.form.tpa.config.ConfigManager; | ||
import ltd.rymc.form.tpa.configs.LangConfig; | ||
import ltd.rymc.form.tpa.configs.TpaConfig; | ||
import ltd.rymc.form.tpa.listener.TpaCommandListener; | ||
import ltd.rymc.form.tpa.metrics.Metrics; | ||
import org.bukkit.Bukkit; | ||
import org.bukkit.plugin.java.JavaPlugin; | ||
|
||
public final class TpaForm extends JavaPlugin { | ||
|
||
private static TpaForm instance; | ||
private static ConfigManager<TpaConfig> tpaConfigManager; | ||
private static ConfigManager<LangConfig> langConfigManager; | ||
private static PaperCommandManager commandManager; | ||
|
||
@Override | ||
public void onEnable() { | ||
instance = this; | ||
tpaConfigManager = ConfigManager.create(TpaForm.getInstance().getDataFolder().toPath(),"config.yml", TpaConfig.class); | ||
langConfigManager = ConfigManager.create(TpaForm.getInstance().getDataFolder().toPath(), "lang.yml", LangConfig.class); | ||
reload(); | ||
|
||
commandManager = new PaperCommandManager(this); | ||
commandManager.registerCommand(new TpaFormCommand()); | ||
|
||
Bukkit.getPluginManager().registerEvents(new TpaCommandListener(), this); | ||
|
||
if (config().metrics()){ | ||
new Metrics(this, 16561); | ||
} | ||
|
||
} | ||
|
||
public static void reload(){ | ||
tpaConfigManager.reloadConfig(); | ||
langConfigManager.reloadConfig(); | ||
} | ||
|
||
public static TpaConfig config(){ | ||
return tpaConfigManager.getConfigData(); | ||
} | ||
|
||
public static LangConfig lang(){ | ||
return langConfigManager.getConfigData(); | ||
} | ||
|
||
public static TpaForm getInstance() { | ||
return instance; | ||
} | ||
|
||
} |
33 changes: 33 additions & 0 deletions
33
src/main/java/ltd/rymc/form/tpa/commands/TpaFormCommand.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,33 @@ | ||
package ltd.rymc.form.tpa.commands; | ||
|
||
import co.aikar.commands.BaseCommand; | ||
import co.aikar.commands.annotation.CommandAlias; | ||
import co.aikar.commands.annotation.CommandPermission; | ||
import co.aikar.commands.annotation.Default; | ||
import co.aikar.commands.annotation.Description; | ||
import co.aikar.commands.annotation.Subcommand; | ||
import ltd.rymc.form.tpa.TpaForm; | ||
import ltd.rymc.form.tpa.forms.TpaSendForm; | ||
import org.bukkit.command.CommandSender; | ||
import org.bukkit.entity.Player; | ||
|
||
@SuppressWarnings("unused") | ||
@CommandAlias("tpaui|tform") | ||
@Description("TpaForm Form菜单") | ||
public class TpaFormCommand extends BaseCommand { | ||
|
||
@Default | ||
public void main(CommandSender sender){ | ||
if (!(sender instanceof Player)) return; | ||
|
||
Player player = ((Player) sender); | ||
new TpaSendForm(player,null).send(); | ||
} | ||
|
||
@Subcommand("reload") | ||
@CommandPermission("tpaform.reload") | ||
public void reload(CommandSender sender){ | ||
TpaForm.reload(); | ||
sender.sendMessage((sender instanceof Player ? TpaForm.lang().prefix() : "") + TpaForm.lang().reload()); | ||
} | ||
} |
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,67 @@ | ||
package ltd.rymc.form.tpa.config; | ||
|
||
import ltd.rymc.form.tpa.TpaForm; | ||
import space.arim.dazzleconf.ConfigurationFactory; | ||
import space.arim.dazzleconf.ConfigurationOptions; | ||
import space.arim.dazzleconf.error.ConfigFormatSyntaxException; | ||
import space.arim.dazzleconf.error.InvalidConfigException; | ||
import space.arim.dazzleconf.ext.snakeyaml.CommentMode; | ||
import space.arim.dazzleconf.ext.snakeyaml.SnakeYamlConfigurationFactory; | ||
import space.arim.dazzleconf.ext.snakeyaml.SnakeYamlOptions; | ||
import space.arim.dazzleconf.helper.ConfigurationHelper; | ||
import space.arim.dazzleconf.sorter.AnnotationBasedSorter; | ||
|
||
import java.io.IOException; | ||
import java.io.UncheckedIOException; | ||
import java.nio.file.Path; | ||
|
||
public final class ConfigManager<C> { | ||
|
||
private final ConfigurationHelper<C> configHelper; | ||
private volatile C configData; | ||
|
||
private ConfigManager(ConfigurationHelper<C> configHelper) { | ||
this.configHelper = configHelper; | ||
} | ||
|
||
public static <C> ConfigManager<C> create(Path configFolder, String fileName, Class<C> configClass) { | ||
// SnakeYaml example | ||
SnakeYamlOptions yamlOptions = new SnakeYamlOptions.Builder() | ||
.commentMode(CommentMode.alternativeWriter("%s")) | ||
.build(); | ||
ConfigurationFactory<C> configFactory = SnakeYamlConfigurationFactory.create( | ||
configClass, | ||
new ConfigurationOptions.Builder().sorter(new AnnotationBasedSorter()).build(), | ||
yamlOptions); | ||
return new ConfigManager<>(new ConfigurationHelper<>(configFolder, fileName, configFactory)) ; | ||
} | ||
|
||
public void reloadConfig() { | ||
try { | ||
configData = configHelper.reloadConfigData(); | ||
} catch (IOException ex) { | ||
throw new UncheckedIOException(ex); | ||
|
||
} catch (ConfigFormatSyntaxException ex) { | ||
configData = configHelper.getFactory().loadDefaults(); | ||
TpaForm.getInstance().getLogger().severe("The yaml syntax in your configuration is invalid. " | ||
+ "Check your YAML syntax with a tool such as https://yaml-online-parser.appspot.com/"); | ||
ex.printStackTrace(); | ||
|
||
} catch (InvalidConfigException ex) { | ||
configData = configHelper.getFactory().loadDefaults(); | ||
TpaForm.getInstance().getLogger().severe("One of the values in your configuration is not valid. " | ||
+ "Check to make sure you have specified the right data types."); | ||
ex.printStackTrace(); | ||
} | ||
} | ||
|
||
public C getConfigData() { | ||
C configData = this.configData; | ||
if (configData == null) { | ||
throw new IllegalStateException("Configuration has not been loaded yet"); | ||
} | ||
return configData; | ||
} | ||
|
||
} |
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,74 @@ | ||
package ltd.rymc.form.tpa.configs; | ||
|
||
import space.arim.dazzleconf.annote.ConfComments; | ||
import space.arim.dazzleconf.annote.ConfDefault; | ||
import space.arim.dazzleconf.annote.ConfHeader; | ||
import space.arim.dazzleconf.annote.ConfKey; | ||
import space.arim.dazzleconf.sorter.AnnotationBasedSorter; | ||
|
||
@SuppressWarnings("unused") | ||
@ConfHeader("# 语言文件 TpaForm Lang zh_cn ver 2.0.0 by RENaa_FD") | ||
public interface LangConfig { | ||
@ConfDefault.DefaultString("§f[§6服务器§f] ") | ||
@ConfKey("prefix") | ||
@ConfComments("\n# 重载插件部分") | ||
@AnnotationBasedSorter.Order(10) | ||
String prefix(); | ||
|
||
@ConfDefault.DefaultString("插件已重载!") | ||
@ConfKey("reload") | ||
@AnnotationBasedSorter.Order(20) | ||
String reload(); | ||
|
||
@ConfDefault.DefaultString("传送菜单") | ||
@ConfKey("title") | ||
@ConfComments("\n# 菜单标题") | ||
@AnnotationBasedSorter.Order(30) | ||
String title(); | ||
|
||
@ConfDefault.DefaultString("请选择玩家") | ||
@ConfKey("select-players") | ||
@ConfComments("\n# 传送选择菜单") | ||
@AnnotationBasedSorter.Order(40) | ||
String selectPlayers(); | ||
@ConfDefault.DefaultString("玩家列表") | ||
@ConfKey("player-list") | ||
@AnnotationBasedSorter.Order(50) | ||
String playerList(); | ||
|
||
@ConfDefault.DefaultString("如果上方找起来过于麻烦可以使用这个输入框") | ||
@ConfKey("input-tips") | ||
@AnnotationBasedSorter.Order(60) | ||
String inputTips(); | ||
|
||
@ConfDefault.DefaultString("无需输入完整玩家名") | ||
@ConfKey("input-tips1") | ||
@AnnotationBasedSorter.Order(70) | ||
String inputTips1(); | ||
|
||
@ConfDefault.DefaultString("模式(开为传送到你这,关为传送到你选择的玩家)") | ||
@ConfKey("tpa-mode") | ||
@AnnotationBasedSorter.Order(80) | ||
String tpaMode(); | ||
|
||
@ConfDefault.DefaultString("%s 想要传送到你这") | ||
@ConfKey("tpa") | ||
@ConfComments("\n# 传送接受菜单") | ||
@AnnotationBasedSorter.Order(90) | ||
String tpa(); | ||
|
||
@ConfDefault.DefaultString("%s 想要让你传送到他那") | ||
@ConfKey("tpa-here") | ||
@AnnotationBasedSorter.Order(100) | ||
String tpaHere(); | ||
|
||
@ConfDefault.DefaultString("同意传送") | ||
@ConfKey("accept") | ||
@AnnotationBasedSorter.Order(110) | ||
String accept(); | ||
|
||
@ConfDefault.DefaultString("拒绝传送") | ||
@ConfKey("deny") | ||
@AnnotationBasedSorter.Order(120) | ||
String deny(); | ||
} |
Oops, something went wrong.