mirror of
https://github.com/CarmJos/EasyPlugin.git
synced 2026-06-05 09:01:47 +08:00
Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4dbcdfb02c | |||
| 9448c21810 | |||
| e30f7ce795 | |||
| 1a9024ca40 | |||
| 0005ce13b4 | |||
| c7190274d7 | |||
| be798a981a | |||
| bbdfe313d5 | |||
| 2acc81185a | |||
| 5886f162af |
@@ -0,0 +1,27 @@
|
|||||||
|
# EasyPlugin Repository
|
||||||
|
|
||||||
|
采用github的repo分支进行依赖,随项目发布而自动更新。
|
||||||
|
|
||||||
|
其他依赖方式见主页介绍。
|
||||||
|
|
||||||
|
## 依赖方式
|
||||||
|
|
||||||
|
### Maven
|
||||||
|
|
||||||
|
```xml
|
||||||
|
<repositories>
|
||||||
|
<repository>
|
||||||
|
<id>EasyPlugin</id>
|
||||||
|
<name>GitHub Branch Repository</name>
|
||||||
|
<url>https://github.com/CarmJos/EasyPlugin/blob/repo/</url>
|
||||||
|
</repository>
|
||||||
|
</repositories>
|
||||||
|
```
|
||||||
|
|
||||||
|
### Gradle
|
||||||
|
|
||||||
|
```groovy
|
||||||
|
repositories {
|
||||||
|
maven { url 'https://github.com/CarmJos/EasyPlugin/blob/repo/' }
|
||||||
|
}
|
||||||
|
```
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
|
# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
|
||||||
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
|
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
|
||||||
|
|
||||||
name: Project Deployment
|
name: Deploy & Publish
|
||||||
|
|
||||||
on:
|
on:
|
||||||
# 支持手动触发构建
|
# 支持手动触发构建
|
||||||
@@ -11,10 +11,8 @@ on:
|
|||||||
types: [ published ]
|
types: [ published ]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
maven-deploy:
|
packages-deploy:
|
||||||
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- name: "Set up JDK"
|
- name: "Set up JDK"
|
||||||
@@ -28,16 +26,14 @@ jobs:
|
|||||||
server-password: MAVEN_TOKEN
|
server-password: MAVEN_TOKEN
|
||||||
|
|
||||||
- name: "Maven Deploy"
|
- name: "Maven Deploy"
|
||||||
run: mvn -B deploy --file pom.xml -DskipTests
|
run: mvn -B -Pgithub deploy --file pom.xml -DskipTests
|
||||||
env:
|
env:
|
||||||
MAVEN_USERNAME: ${{ github.repository_owner }}
|
MAVEN_USERNAME: ${{ github.repository_owner }}
|
||||||
MAVEN_TOKEN: ${{secrets.GITHUB_TOKEN}}
|
MAVEN_TOKEN: ${{secrets.GITHUB_TOKEN}}
|
||||||
|
|
||||||
|
|
||||||
javadoc-deploy:
|
github-deploy:
|
||||||
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- name: "Set up JDK"
|
- name: "Set up JDK"
|
||||||
@@ -47,6 +43,16 @@ jobs:
|
|||||||
distribution: 'adopt'
|
distribution: 'adopt'
|
||||||
cache: maven
|
cache: maven
|
||||||
|
|
||||||
|
- name: "Maven Deploy"
|
||||||
|
run: mvn -B -Plocal deploy --file pom.xml -DskipTests
|
||||||
|
|
||||||
|
- name: "Copy artifacts"
|
||||||
|
run: |
|
||||||
|
rm -rf deploy
|
||||||
|
mkdir -vp deploy
|
||||||
|
cp -vrf $HOME/local-deploy/* deploy/
|
||||||
|
cp -vrf .documentation/repository/REPO-README.md deploy/README.md
|
||||||
|
|
||||||
- name: "Generate Javadoc"
|
- name: "Generate Javadoc"
|
||||||
run: mvn -B javadoc:aggregate --file pom.xml -DskipTests
|
run: mvn -B javadoc:aggregate --file pom.xml -DskipTests
|
||||||
|
|
||||||
@@ -57,21 +63,21 @@ jobs:
|
|||||||
cp -vrf target/site/apidocs/* docs/
|
cp -vrf target/site/apidocs/* docs/
|
||||||
cp -vrf .documentation/javadoc/JAVADOC-README.md docs/README.md
|
cp -vrf .documentation/javadoc/JAVADOC-README.md docs/README.md
|
||||||
|
|
||||||
- name: "Generate Sitemap"
|
- name: "Generate Javadoc sitemap"
|
||||||
id: sitemap
|
id: sitemap
|
||||||
uses: cicirello/generate-sitemap@v1
|
uses: cicirello/generate-sitemap@v1
|
||||||
with:
|
with:
|
||||||
base-url-path: https://carmjos.github.io/EasyPlugin
|
base-url-path: https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}
|
||||||
path-to-root: docs
|
path-to-root: docs
|
||||||
|
|
||||||
- name: Output stats
|
- name: "Output Javadoc stats"
|
||||||
run: |
|
run: |
|
||||||
echo "sitemap-path = ${{ steps.sitemap.outputs.sitemap-path }}"
|
echo "sitemap-path = ${{ steps.sitemap.outputs.sitemap-path }}"
|
||||||
echo "url-count = ${{ steps.sitemap.outputs.url-count }}"
|
echo "url-count = ${{ steps.sitemap.outputs.url-count }}"
|
||||||
echo "excluded-count = ${{ steps.sitemap.outputs.excluded-count }}"
|
echo "excluded-count = ${{ steps.sitemap.outputs.excluded-count }}"
|
||||||
ls -l docs
|
ls -l docs
|
||||||
|
|
||||||
- name: Configure Git
|
- name: "Configure Git"
|
||||||
env:
|
env:
|
||||||
DEPLOY_PRI: ${{secrets.DEPLOY_PRI}}
|
DEPLOY_PRI: ${{secrets.DEPLOY_PRI}}
|
||||||
run: |
|
run: |
|
||||||
@@ -80,19 +86,25 @@ jobs:
|
|||||||
echo "$DEPLOY_PRI" > ~/.ssh/id_rsa
|
echo "$DEPLOY_PRI" > ~/.ssh/id_rsa
|
||||||
chmod 600 ~/.ssh/id_rsa
|
chmod 600 ~/.ssh/id_rsa
|
||||||
ssh-keyscan github.com >> ~/.ssh/known_hosts
|
ssh-keyscan github.com >> ~/.ssh/known_hosts
|
||||||
git config --global user.name 'CarmJos'
|
git config --global user.name '${{ github.repository_owner }}'
|
||||||
git config --global user.email 'carm@carm.cc'
|
git config --global user.email '${{ github.repository_owner }}@users.noreply.github.com'
|
||||||
|
|
||||||
- name: Commit documentation changes
|
- name: "Commit&Push repository files"
|
||||||
|
run: |
|
||||||
|
cd deploy
|
||||||
|
git init
|
||||||
|
git remote add origin git@github.com:${{ github.repository_owner }}/${{ github.event.repository.name }}.git
|
||||||
|
git checkout -b repo
|
||||||
|
git add -A
|
||||||
|
git commit -m "Maven project deployment."
|
||||||
|
git push origin HEAD:repo --force
|
||||||
|
|
||||||
|
- name: "Commit&Push API documentation"
|
||||||
run: |
|
run: |
|
||||||
cd docs
|
cd docs
|
||||||
git init
|
git init
|
||||||
git remote add origin git@github.com:CarmJos/EasyPlugin.git
|
git remote add origin git@github.com:${{ github.repository_owner }}/${{ github.event.repository.name }}.git
|
||||||
git checkout -b gh-pages
|
git checkout -b gh-pages
|
||||||
git add -A
|
git add -A
|
||||||
git commit -m "API Document generated."
|
git commit -m "API Document generated."
|
||||||
|
|
||||||
- name: Javadoc Website Push
|
|
||||||
run: |
|
|
||||||
cd docs
|
|
||||||
git push origin HEAD:gh-pages --force
|
git push origin HEAD:gh-pages --force
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
|
# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
|
||||||
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
|
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
|
||||||
|
|
||||||
name: Project Build & Tests
|
name: Build & Tests
|
||||||
|
|
||||||
on:
|
on:
|
||||||
# 支持手动触发构建
|
# 支持手动触发构建
|
||||||
@@ -19,7 +19,7 @@ jobs:
|
|||||||
uses: actions/setup-java@v2
|
uses: actions/setup-java@v2
|
||||||
with:
|
with:
|
||||||
cache: maven
|
cache: maven
|
||||||
java-version: '11'
|
java-version: '8'
|
||||||
distribution: 'adopt'
|
distribution: 'adopt'
|
||||||
server-id: github
|
server-id: github
|
||||||
server-username: MAVEN_USERNAME
|
server-username: MAVEN_USERNAME
|
||||||
|
|||||||
@@ -67,10 +67,10 @@
|
|||||||
<repositories>
|
<repositories>
|
||||||
|
|
||||||
<repository>
|
<repository>
|
||||||
<!--采用github依赖库,安全稳定,但需要配置 (推荐)-->
|
<!--采用github-repo依赖库(推荐)-->
|
||||||
<id>EasyPlugin</id>
|
<id>EasyPlugin</id>
|
||||||
<name>GitHub Packages</name>
|
<name>GitHub Packages</name>
|
||||||
<url>https://maven.pkg.github.com/CarmJos/EasyPlugin</url>
|
<url>https://raw.githubusercontent.com/CarmJos/EasyPlugin/repo/</url>
|
||||||
</repository>
|
</repository>
|
||||||
|
|
||||||
<repository>
|
<repository>
|
||||||
@@ -121,7 +121,7 @@
|
|||||||
```groovy
|
```groovy
|
||||||
repositories {
|
repositories {
|
||||||
// 采用github依赖库,安全稳定,但需要配置 (推荐)
|
// 采用github依赖库,安全稳定,但需要配置 (推荐)
|
||||||
maven { url 'https://maven.pkg.github.com/CarmJos/EasyPlugin' }
|
maven { url 'https://raw.githubusercontent.com/CarmJos/EasyPlugin/repo/' }
|
||||||
|
|
||||||
// 采用我的私人依赖库,简单方便,但可能因为变故而无法使用
|
// 采用我的私人依赖库,简单方便,但可能因为变故而无法使用
|
||||||
maven { url 'https://repo.carm.cc/repository/maven-public/' }
|
maven { url 'https://repo.carm.cc/repository/maven-public/' }
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>easyplugin-parent</artifactId>
|
<artifactId>easyplugin-parent</artifactId>
|
||||||
<groupId>cc.carm.lib</groupId>
|
<groupId>cc.carm.lib</groupId>
|
||||||
<version>1.4.1</version>
|
<version>1.4.5</version>
|
||||||
<relativePath>../../pom.xml</relativePath>
|
<relativePath>../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import org.bukkit.command.TabExecutor;
|
|||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
import org.bukkit.util.StringUtil;
|
import org.bukkit.util.StringUtil;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@@ -15,17 +16,25 @@ public abstract class CommandHandler implements TabExecutor, NamedExecutor {
|
|||||||
|
|
||||||
protected final @NotNull JavaPlugin plugin;
|
protected final @NotNull JavaPlugin plugin;
|
||||||
protected final @NotNull String cmd;
|
protected final @NotNull String cmd;
|
||||||
|
protected final @NotNull List<String> aliases;
|
||||||
|
|
||||||
protected final @NotNull Map<String, SubCommand> registeredCommands = new HashMap<>();
|
protected final @NotNull Map<String, SubCommand> registeredCommands = new HashMap<>();
|
||||||
protected final @NotNull Map<String, CommandHandler> registeredHandlers = new HashMap<>();
|
protected final @NotNull Map<String, CommandHandler> registeredHandlers = new HashMap<>();
|
||||||
|
|
||||||
|
protected final @NotNull Map<String, String> aliasesMap = new HashMap<>();
|
||||||
|
|
||||||
public CommandHandler(@NotNull JavaPlugin plugin) {
|
public CommandHandler(@NotNull JavaPlugin plugin) {
|
||||||
this(plugin, plugin.getName());
|
this(plugin, plugin.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
public CommandHandler(@NotNull JavaPlugin plugin, @NotNull String cmd) {
|
public CommandHandler(@NotNull JavaPlugin plugin, @NotNull String cmd) {
|
||||||
|
this(plugin, cmd, new String[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CommandHandler(@NotNull JavaPlugin plugin, @NotNull String cmd, @NotNull String... aliases) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.cmd = cmd;
|
this.cmd = cmd;
|
||||||
|
this.aliases = Arrays.asList(aliases);
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract void noArgs(CommandSender sender);
|
public abstract void noArgs(CommandSender sender);
|
||||||
@@ -34,27 +43,26 @@ public abstract class CommandHandler implements TabExecutor, NamedExecutor {
|
|||||||
|
|
||||||
public abstract void noPermission(CommandSender sender);
|
public abstract void noPermission(CommandSender sender);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull List<String> getAliases() {
|
||||||
|
return aliases;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return this.cmd;
|
return this.cmd;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void registerSubCommand(SubCommand command) {
|
public void registerSubCommand(SubCommand command) {
|
||||||
for (String alias : command.getAliases()) {
|
String name = command.getName().toLowerCase();
|
||||||
if (this.registeredCommands.containsKey(alias)) {
|
this.registeredCommands.put(name, command);
|
||||||
this.plugin.getLogger().warning("Conflicting command aliases '" + alias + "' for '" + command.getName() + "', overwriting.");
|
command.getAliases().forEach(alias -> this.aliasesMap.put(alias.toLowerCase(), name));
|
||||||
}
|
|
||||||
this.registeredCommands.put(alias, command);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void registerHandler(CommandHandler handler) {
|
public void registerHandler(CommandHandler handler) {
|
||||||
for (String alias : handler.getAliases()) {
|
String name = handler.getName().toLowerCase();
|
||||||
if (this.registeredCommands.containsKey(alias)) {
|
this.registeredHandlers.put(name, handler);
|
||||||
this.plugin.getLogger().warning("Conflicting command aliases '" + alias + "' for '" + handler.getName() + "', overwriting.");
|
handler.getAliases().forEach(alias -> this.aliasesMap.put(alias.toLowerCase(), name));
|
||||||
}
|
|
||||||
this.registeredHandlers.put(alias, handler);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -62,16 +70,18 @@ public abstract class CommandHandler implements TabExecutor, NamedExecutor {
|
|||||||
if (args.length == 0) {
|
if (args.length == 0) {
|
||||||
this.noArgs(sender);
|
this.noArgs(sender);
|
||||||
} else {
|
} else {
|
||||||
String sub = args[0].toLowerCase();
|
String input = args[0].toLowerCase();
|
||||||
CommandHandler handler = this.registeredHandlers.get(sub);
|
|
||||||
|
CommandHandler handler = getHandler(input);
|
||||||
if (handler != null) {
|
if (handler != null) {
|
||||||
if (!handler.hasPermission(sender)) {
|
if (!handler.hasPermission(sender)) {
|
||||||
this.noPermission(sender);
|
this.noPermission(sender);
|
||||||
} else {
|
} else {
|
||||||
handler.onCommand(sender, command, label, this.shortenArgs(args));
|
handler.onCommand(sender, command, label, this.shortenArgs(args));
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
SubCommand subCommand = this.registeredCommands.get(sub);
|
|
||||||
|
SubCommand subCommand = getSubCommand(input);
|
||||||
if (subCommand == null) {
|
if (subCommand == null) {
|
||||||
this.unknownCommand(sender, args);
|
this.unknownCommand(sender, args);
|
||||||
} else if (!subCommand.hasPermission(sender)) {
|
} else if (!subCommand.hasPermission(sender)) {
|
||||||
@@ -83,7 +93,7 @@ public abstract class CommandHandler implements TabExecutor, NamedExecutor {
|
|||||||
this.unknownCommand(sender, args);
|
this.unknownCommand(sender, args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -101,12 +111,12 @@ public abstract class CommandHandler implements TabExecutor, NamedExecutor {
|
|||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
CommandHandler handler = this.registeredHandlers.get(input);
|
CommandHandler handler = getHandler(input);
|
||||||
if (handler != null && handler.hasPermission(sender)) {
|
if (handler != null && handler.hasPermission(sender)) {
|
||||||
return handler.onTabComplete(sender, command, alias, this.shortenArgs(args));
|
return handler.onTabComplete(sender, command, alias, this.shortenArgs(args));
|
||||||
}
|
}
|
||||||
|
|
||||||
SubCommand subCommand = this.registeredCommands.get(input);
|
SubCommand subCommand = getSubCommand(input);
|
||||||
if (subCommand != null && subCommand.hasPermission(sender)) {
|
if (subCommand != null && subCommand.hasPermission(sender)) {
|
||||||
return subCommand.tabComplete(this.plugin, sender, this.shortenArgs(args));
|
return subCommand.tabComplete(this.plugin, sender, this.shortenArgs(args));
|
||||||
}
|
}
|
||||||
@@ -124,6 +134,24 @@ public abstract class CommandHandler implements TabExecutor, NamedExecutor {
|
|||||||
return sortedExecutors;
|
return sortedExecutors;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected @Nullable CommandHandler getHandler(@NotNull String name) {
|
||||||
|
CommandHandler fromName = this.registeredHandlers.get(name);
|
||||||
|
if (fromName != null) return fromName;
|
||||||
|
|
||||||
|
String nameFromAlias = this.aliasesMap.get(name);
|
||||||
|
if (nameFromAlias == null) return null;
|
||||||
|
else return this.registeredHandlers.get(nameFromAlias);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected @Nullable SubCommand getSubCommand(@NotNull String name) {
|
||||||
|
SubCommand fromName = this.registeredCommands.get(name);
|
||||||
|
if (fromName != null) return fromName;
|
||||||
|
|
||||||
|
String nameFromAlias = this.aliasesMap.get(name);
|
||||||
|
if (nameFromAlias == null) return null;
|
||||||
|
else return this.registeredCommands.get(nameFromAlias);
|
||||||
|
}
|
||||||
|
|
||||||
protected String[] shortenArgs(String[] args) {
|
protected String[] shortenArgs(String[] args) {
|
||||||
if (args.length == 0) {
|
if (args.length == 0) {
|
||||||
return args;
|
return args;
|
||||||
|
|||||||
@@ -2,16 +2,13 @@ package cc.carm.lib.easyplugin.command;
|
|||||||
|
|
||||||
import org.bukkit.permissions.Permissible;
|
import org.bukkit.permissions.Permissible;
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public interface NamedExecutor {
|
public interface NamedExecutor {
|
||||||
|
|
||||||
String getName();
|
String getName();
|
||||||
|
|
||||||
default List<String> getAliases() {
|
List<String> getAliases();
|
||||||
return Collections.singletonList(getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
default boolean hasPermission(Permissible permissible) {
|
default boolean hasPermission(Permissible permissible) {
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import java.util.Arrays;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
public class SimpleCompleter {
|
public class SimpleCompleter {
|
||||||
|
|
||||||
@@ -21,9 +22,13 @@ public class SimpleCompleter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static @NotNull List<String> objects(@NotNull String input, int limit, List<?> objects) {
|
public static @NotNull List<String> objects(@NotNull String input, int limit, List<?> objects) {
|
||||||
return objects.stream().filter(Objects::nonNull).map(Object::toString)
|
return objects(input, limit, objects.stream());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static @NotNull List<String> objects(@NotNull String input, int limit, Stream<?> stream) {
|
||||||
|
return stream.filter(Objects::nonNull).map(Object::toString)
|
||||||
.filter(s -> StringUtil.startsWithIgnoreCase(s, input))
|
.filter(s -> StringUtil.startsWithIgnoreCase(s, input))
|
||||||
.limit(Math.min(0, limit)).collect(Collectors.toList());
|
.limit(Math.max(0, limit)).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static @NotNull List<String> text(@NotNull String input, String... texts) {
|
public static @NotNull List<String> text(@NotNull String input, String... texts) {
|
||||||
@@ -47,7 +52,7 @@ public class SimpleCompleter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static @NotNull List<String> onlinePlayers(@NotNull String input, int limit) {
|
public static @NotNull List<String> onlinePlayers(@NotNull String input, int limit) {
|
||||||
return text(input, limit, Bukkit.getOnlinePlayers().stream().map(HumanEntity::getName).collect(Collectors.toList()));
|
return objects(input, limit, Bukkit.getOnlinePlayers().stream().map(HumanEntity::getName));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static @NotNull List<String> allPlayers(@NotNull String input) {
|
public static @NotNull List<String> allPlayers(@NotNull String input) {
|
||||||
@@ -55,7 +60,7 @@ public class SimpleCompleter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static @NotNull List<String> allPlayers(@NotNull String input, int limit) {
|
public static @NotNull List<String> allPlayers(@NotNull String input, int limit) {
|
||||||
return text(input, limit, Arrays.stream(Bukkit.getOfflinePlayers()).map(OfflinePlayer::getName).collect(Collectors.toList()));
|
return objects(input, limit, Arrays.stream(Bukkit.getOfflinePlayers()).map(OfflinePlayer::getName));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static @NotNull List<String> worlds(@NotNull String input) {
|
public static @NotNull List<String> worlds(@NotNull String input) {
|
||||||
@@ -63,7 +68,7 @@ public class SimpleCompleter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static @NotNull List<String> worlds(@NotNull String input, int limit) {
|
public static @NotNull List<String> worlds(@NotNull String input, int limit) {
|
||||||
return text(input, limit, Bukkit.getWorlds().stream().map(World::getName).collect(Collectors.toList()));
|
return objects(input, limit, Bukkit.getWorlds().stream().map(World::getName));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static @NotNull List<String> materials(@NotNull String input) {
|
public static @NotNull List<String> materials(@NotNull String input) {
|
||||||
@@ -71,7 +76,7 @@ public class SimpleCompleter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static @NotNull List<String> materials(@NotNull String input, int limit) {
|
public static @NotNull List<String> materials(@NotNull String input, int limit) {
|
||||||
return text(input, limit, Arrays.stream(Material.values()).map(Enum::name).collect(Collectors.toList()));
|
return objects(input, limit, Arrays.stream(Material.values()).map(Enum::name));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static @NotNull List<String> effects(@NotNull String input) {
|
public static @NotNull List<String> effects(@NotNull String input) {
|
||||||
@@ -79,7 +84,7 @@ public class SimpleCompleter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static @NotNull List<String> effects(@NotNull String input, int limit) {
|
public static @NotNull List<String> effects(@NotNull String input, int limit) {
|
||||||
return text(input, limit, Arrays.stream(PotionEffectType.values()).map(PotionEffectType::getName).collect(Collectors.toList()));
|
return objects(input, limit, Arrays.stream(PotionEffectType.values()).map(PotionEffectType::getName));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,15 +3,34 @@ package cc.carm.lib.easyplugin.command;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@SuppressWarnings("UnusedReturnValue")
|
@SuppressWarnings("UnusedReturnValue")
|
||||||
public abstract class SubCommand implements NamedExecutor {
|
public abstract class SubCommand implements NamedExecutor {
|
||||||
|
|
||||||
private final String name;
|
private final String name;
|
||||||
|
private final List<String> aliases;
|
||||||
|
|
||||||
public SubCommand(String name) {
|
public SubCommand(String name) {
|
||||||
|
this(name, new String[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public SubCommand(String name, String... aliases) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
this.aliases = Arrays.asList(aliases);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return this.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> getAliases() {
|
||||||
|
return this.aliases;
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract Void execute(JavaPlugin plugin, CommandSender sender, String[] args);
|
public abstract Void execute(JavaPlugin plugin, CommandSender sender, String[] args);
|
||||||
@@ -20,9 +39,5 @@ public abstract class SubCommand implements NamedExecutor {
|
|||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getName() {
|
|
||||||
return this.name;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>easyplugin-parent</artifactId>
|
<artifactId>easyplugin-parent</artifactId>
|
||||||
<groupId>cc.carm.lib</groupId>
|
<groupId>cc.carm.lib</groupId>
|
||||||
<version>1.4.1</version>
|
<version>1.4.5</version>
|
||||||
<relativePath>../../pom.xml</relativePath>
|
<relativePath>../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|||||||
+1
-1
@@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>easyplugin-parent</artifactId>
|
<artifactId>easyplugin-parent</artifactId>
|
||||||
<groupId>cc.carm.lib</groupId>
|
<groupId>cc.carm.lib</groupId>
|
||||||
<version>1.4.1</version>
|
<version>1.4.5</version>
|
||||||
<relativePath>../../pom.xml</relativePath>
|
<relativePath>../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>easyplugin-parent</artifactId>
|
<artifactId>easyplugin-parent</artifactId>
|
||||||
<groupId>cc.carm.lib</groupId>
|
<groupId>cc.carm.lib</groupId>
|
||||||
<version>1.4.1</version>
|
<version>1.4.5</version>
|
||||||
<relativePath>../../pom.xml</relativePath>
|
<relativePath>../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|||||||
+7
-50
@@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>easyplugin-parent</artifactId>
|
<artifactId>easyplugin-parent</artifactId>
|
||||||
<groupId>cc.carm.lib</groupId>
|
<groupId>cc.carm.lib</groupId>
|
||||||
<version>1.4.1</version>
|
<version>1.4.5</version>
|
||||||
<relativePath>../../pom.xml</relativePath>
|
<relativePath>../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
@@ -50,39 +50,6 @@
|
|||||||
<url>https://github.com/CarmJos/EasyPlugin/actions/workflows/maven.yml</url>
|
<url>https://github.com/CarmJos/EasyPlugin/actions/workflows/maven.yml</url>
|
||||||
</ciManagement>
|
</ciManagement>
|
||||||
|
|
||||||
<distributionManagement>
|
|
||||||
<downloadUrl>https://github.com/CarmJos/EasyPlugin/releases</downloadUrl>
|
|
||||||
<repository>
|
|
||||||
<id>github</id>
|
|
||||||
<name>GitHub Packages</name>
|
|
||||||
<url>https://maven.pkg.github.com/CarmJos/EasyPlugin</url>
|
|
||||||
</repository>
|
|
||||||
</distributionManagement>
|
|
||||||
|
|
||||||
<repositories>
|
|
||||||
|
|
||||||
<repository>
|
|
||||||
<id>carm-repo</id>
|
|
||||||
<name>Carm's Repo</name>
|
|
||||||
<url>https://repo.carm.cc/repository/maven-public/</url>
|
|
||||||
</repository>
|
|
||||||
|
|
||||||
<repository>
|
|
||||||
<id>central</id>
|
|
||||||
<url>https://repo1.maven.org/maven2/</url>
|
|
||||||
</repository>
|
|
||||||
|
|
||||||
<repository>
|
|
||||||
<id>github</id>
|
|
||||||
<name>GitHub Packages</name>
|
|
||||||
<url>https://maven.pkg.github.com/CarmJos/*</url>
|
|
||||||
<snapshots>
|
|
||||||
<enabled>true</enabled>
|
|
||||||
</snapshots>
|
|
||||||
</repository>
|
|
||||||
|
|
||||||
</repositories>
|
|
||||||
|
|
||||||
<dependencyManagement>
|
<dependencyManagement>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
@@ -90,21 +57,11 @@
|
|||||||
<artifactId>easyplugin-main</artifactId>
|
<artifactId>easyplugin-main</artifactId>
|
||||||
<version>${project.parent.version}</version>
|
<version>${project.parent.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>${project.parent.groupId}</groupId>
|
|
||||||
<artifactId>easyplugin-configuration</artifactId>
|
|
||||||
<version>${project.parent.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>${project.parent.groupId}</groupId>
|
<groupId>${project.parent.groupId}</groupId>
|
||||||
<artifactId>easyplugin-command</artifactId>
|
<artifactId>easyplugin-command</artifactId>
|
||||||
<version>${project.parent.version}</version>
|
<version>${project.parent.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>${project.parent.groupId}</groupId>
|
|
||||||
<artifactId>easyplugin-database</artifactId>
|
|
||||||
<version>${project.parent.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>${project.parent.groupId}</groupId>
|
<groupId>${project.parent.groupId}</groupId>
|
||||||
<artifactId>easyplugin-gui</artifactId>
|
<artifactId>easyplugin-gui</artifactId>
|
||||||
@@ -112,7 +69,7 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>${project.parent.groupId}</groupId>
|
<groupId>${project.parent.groupId}</groupId>
|
||||||
<artifactId>easyplugin-placeholderapi</artifactId>
|
<artifactId>easyplugin-papi</artifactId>
|
||||||
<version>${project.parent.version}</version>
|
<version>${project.parent.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
@@ -120,11 +77,6 @@
|
|||||||
<artifactId>easyplugin-vault</artifactId>
|
<artifactId>easyplugin-vault</artifactId>
|
||||||
<version>${project.parent.version}</version>
|
<version>${project.parent.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>${project.parent.groupId}</groupId>
|
|
||||||
<artifactId>easyplugin-lp</artifactId>
|
|
||||||
<version>${project.parent.version}</version>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</dependencyManagement>
|
</dependencyManagement>
|
||||||
|
|
||||||
@@ -139,6 +91,11 @@
|
|||||||
<artifactId>easyplugin-gui</artifactId>
|
<artifactId>easyplugin-gui</artifactId>
|
||||||
<version>${project.parent.version}</version>
|
<version>${project.parent.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>${project.parent.groupId}</groupId>
|
||||||
|
<artifactId>easyplugin-command</artifactId>
|
||||||
|
<version>${project.parent.version}</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>${project.parent.groupId}</groupId>
|
<groupId>${project.parent.groupId}</groupId>
|
||||||
<artifactId>easyplugin-placeholderapi</artifactId>
|
<artifactId>easyplugin-placeholderapi</artifactId>
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>easyplugin-parent</artifactId>
|
<artifactId>easyplugin-parent</artifactId>
|
||||||
<groupId>cc.carm.lib</groupId>
|
<groupId>cc.carm.lib</groupId>
|
||||||
<version>1.4.1</version>
|
<version>1.4.5</version>
|
||||||
<relativePath>../../pom.xml</relativePath>
|
<relativePath>../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
@@ -60,18 +60,10 @@
|
|||||||
<type>pom</type>
|
<type>pom</type>
|
||||||
|
|
||||||
<exclusions>
|
<exclusions>
|
||||||
<exclusion>
|
|
||||||
<groupId>cc.carm.lib</groupId>
|
|
||||||
<artifactId>easyplugin-github</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
<exclusion>
|
<exclusion>
|
||||||
<groupId>cc.carm.lib</groupId>
|
<groupId>cc.carm.lib</groupId>
|
||||||
<artifactId>easyplugin-placeholderapi</artifactId>
|
<artifactId>easyplugin-placeholderapi</artifactId>
|
||||||
</exclusion>
|
</exclusion>
|
||||||
<exclusion>
|
|
||||||
<groupId>cc.carm.lib</groupId>
|
|
||||||
<artifactId>easyplugin-lp</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
<exclusion>
|
<exclusion>
|
||||||
<groupId>cc.carm.lib</groupId>
|
<groupId>cc.carm.lib</groupId>
|
||||||
<artifactId>easyplugin-vault</artifactId>
|
<artifactId>easyplugin-vault</artifactId>
|
||||||
|
|||||||
+12
-1
@@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>easyplugin-parent</artifactId>
|
<artifactId>easyplugin-parent</artifactId>
|
||||||
<groupId>cc.carm.lib</groupId>
|
<groupId>cc.carm.lib</groupId>
|
||||||
<version>1.4.1</version>
|
<version>1.4.5</version>
|
||||||
<relativePath>../../pom.xml</relativePath>
|
<relativePath>../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
@@ -22,4 +22,15 @@
|
|||||||
|
|
||||||
<name>EasyPlugin-PlaceholderAPI</name>
|
<name>EasyPlugin-PlaceholderAPI</name>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>me.clip</groupId>
|
||||||
|
<artifactId>placeholderapi</artifactId>
|
||||||
|
<version>2.10.9</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>easyplugin-parent</artifactId>
|
<artifactId>easyplugin-parent</artifactId>
|
||||||
<groupId>cc.carm.lib</groupId>
|
<groupId>cc.carm.lib</groupId>
|
||||||
<version>1.4.1</version>
|
<version>1.4.5</version>
|
||||||
<relativePath>../../pom.xml</relativePath>
|
<relativePath>../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|||||||
@@ -15,10 +15,11 @@
|
|||||||
<groupId>cc.carm.lib</groupId>
|
<groupId>cc.carm.lib</groupId>
|
||||||
<artifactId>easyplugin-parent</artifactId>
|
<artifactId>easyplugin-parent</artifactId>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
<version>1.4.1</version>
|
<version>1.4.5</version>
|
||||||
<modules>
|
<modules>
|
||||||
|
|
||||||
<module>base/main</module>
|
<module>base/main</module>
|
||||||
|
<module>base/command</module>
|
||||||
<module>base/gui</module>
|
<module>base/gui</module>
|
||||||
|
|
||||||
<module>extension/papi</module>
|
<module>extension/papi</module>
|
||||||
@@ -27,7 +28,6 @@
|
|||||||
<module>collection/all</module>
|
<module>collection/all</module>
|
||||||
<module>collection/bom</module>
|
<module>collection/bom</module>
|
||||||
<module>collection/common</module>
|
<module>collection/common</module>
|
||||||
<module>base/command</module>
|
|
||||||
|
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
@@ -35,6 +35,13 @@
|
|||||||
<description>轻松插件类库,简单快捷的通用Spigot插件基础类库。</description>
|
<description>轻松插件类库,简单快捷的通用Spigot插件基础类库。</description>
|
||||||
<url>https://github.com/CarmJos/EasyPlugin</url>
|
<url>https://github.com/CarmJos/EasyPlugin</url>
|
||||||
|
|
||||||
|
<scm>
|
||||||
|
<connection>scm:git:git@github.com:CarmJos/EasyPlugin.git</connection>
|
||||||
|
<developerConnection>scm:git:git@github.com:CarmJos/EasyPlugin.git</developerConnection>
|
||||||
|
<url>https://github.com/CarmJos/EasyPlugin</url>
|
||||||
|
<tag>HEAD</tag>
|
||||||
|
</scm>
|
||||||
|
|
||||||
<developers>
|
<developers>
|
||||||
<developer>
|
<developer>
|
||||||
<id>CarmJos</id>
|
<id>CarmJos</id>
|
||||||
@@ -63,11 +70,6 @@
|
|||||||
|
|
||||||
<distributionManagement>
|
<distributionManagement>
|
||||||
<downloadUrl>https://github.com/CarmJos/EasyPlugin/releases</downloadUrl>
|
<downloadUrl>https://github.com/CarmJos/EasyPlugin/releases</downloadUrl>
|
||||||
<repository>
|
|
||||||
<id>github</id>
|
|
||||||
<name>GitHub Packages</name>
|
|
||||||
<url>https://maven.pkg.github.com/CarmJos/EasyPlugin</url>
|
|
||||||
</repository>
|
|
||||||
</distributionManagement>
|
</distributionManagement>
|
||||||
|
|
||||||
<repositories>
|
<repositories>
|
||||||
@@ -221,4 +223,47 @@
|
|||||||
</build>
|
</build>
|
||||||
|
|
||||||
|
|
||||||
|
<profiles>
|
||||||
|
|
||||||
|
<profile>
|
||||||
|
<id>ossrh</id>
|
||||||
|
<distributionManagement>
|
||||||
|
<snapshotRepository>
|
||||||
|
<id>ossrh</id>
|
||||||
|
<url>https://s01.oss.sonatype.org/content/repositories/snapshots</url>
|
||||||
|
</snapshotRepository>
|
||||||
|
<repository>
|
||||||
|
<id>ossrh</id>
|
||||||
|
<url>https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/</url>
|
||||||
|
</repository>
|
||||||
|
</distributionManagement>
|
||||||
|
</profile>
|
||||||
|
|
||||||
|
<profile>
|
||||||
|
<id>github</id>
|
||||||
|
<distributionManagement>
|
||||||
|
<repository>
|
||||||
|
<id>github</id>
|
||||||
|
<name>GitHub Packages</name>
|
||||||
|
<url>https://maven.pkg.github.com/CarmJos/EasyPlugin</url>
|
||||||
|
</repository>
|
||||||
|
</distributionManagement>
|
||||||
|
</profile>
|
||||||
|
|
||||||
|
<profile>
|
||||||
|
<id>local</id>
|
||||||
|
<distributionManagement>
|
||||||
|
<snapshotRepository>
|
||||||
|
<id>localRepository</id>
|
||||||
|
<url>file:${user.home}/local-deploy/</url>
|
||||||
|
</snapshotRepository>
|
||||||
|
<repository>
|
||||||
|
<id>localRepository</id>
|
||||||
|
<url>file:${user.home}/local-deploy/</url>
|
||||||
|
</repository>
|
||||||
|
</distributionManagement>
|
||||||
|
</profile>
|
||||||
|
|
||||||
|
</profiles>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
Reference in New Issue
Block a user