Skip to content

Commit 4f9df8f

Browse files
committed
1.0.0 初始版本完成
0 parents  commit 4f9df8f

File tree

11 files changed

+550
-0
lines changed

11 files changed

+550
-0
lines changed

.github/workflows/deploy.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
3+
4+
name: Deploy
5+
6+
on:
7+
# 支持手动触发构建
8+
workflow_dispatch:
9+
release:
10+
# 创建release的时候触发
11+
types: [ published ]
12+
13+
jobs:
14+
build:
15+
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- uses: actions/checkout@v2
20+
- name: "Set up JDK"
21+
uses: actions/setup-java@v2
22+
with:
23+
java-version: '11'
24+
distribution: 'adopt'
25+
cache: maven
26+
server-id: github
27+
server-username: MAVEN_USERNAME
28+
server-password: MAVEN_TOKEN
29+
- name: "Deploy"
30+
run: mvn -B deploy --file pom.xml -DskipTests
31+
env:
32+
MAVEN_USERNAME: ${{ github.repository_owner }}
33+
MAVEN_TOKEN: ${{secrets.GITHUB_TOKEN}}

.github/workflows/maven.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
3+
4+
name: Build
5+
6+
on:
7+
# 支持手动触发构建
8+
workflow_dispatch:
9+
push:
10+
11+
jobs:
12+
build:
13+
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- uses: actions/checkout@v2
18+
- name: "Set up JDK"
19+
uses: actions/setup-java@v2
20+
with:
21+
java-version: '11'
22+
distribution: 'adopt'
23+
cache: maven
24+
server-id: github
25+
server-username: MAVEN_USERNAME
26+
server-password: MAVEN_TOKEN
27+
- name: "Package"
28+
run: mvn -B package --file pom.xml
29+
env:
30+
MAVEN_USERNAME: ${{ github.repository_owner }}
31+
MAVEN_TOKEN: ${{secrets.GITHUB_TOKEN}}
32+
- name: "Target Stage"
33+
run: mkdir staging && cp target/*.jar staging
34+
- name: "Upload artifact"
35+
uses: actions/upload-artifact@v2
36+
with:
37+
name: Artifact
38+
path: staging

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/.idea/
2+
/target/
3+
./*.iml
4+
*.iml

README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
```text
2+
___ _ _ ___ _
3+
( _`\ ( )_ (_ ) ( _`\ ( )
4+
| |_) ) _ _ __ | ,_) _ _ | | | ( (_) _ ___ ___ ___ ___ _ _ ___ _| | ___
5+
| ,__/'/'_`\ ( '__)| | /'_` ) | | | | _ /'_`\ /' _ ` _ `\/' _ ` _ `\ /'_` )/' _ `\ /'_` |/',__)
6+
| | ( (_) )| | | |_ ( (_| | | | | (_( )( (_) )| ( ) ( ) || ( ) ( ) |( (_| || ( ) |( (_| |\__, \
7+
(_) `\___/'(_) `\__)`\__,_)(___) (____/'`\___/'(_) (_) (_)(_) (_) (_)`\__,_)(_) (_)`\__,_)(____/
8+
```
9+
10+
# PortalCommands
11+
12+
当玩家进入传送门时执行对应指令。
13+
~~~~
14+
## 依赖
15+
16+
- **[必须]** 插件本体基于 [Spigot-API](https://hub.spigotmc.org/stash/projects/SPIGOT) 、[BukkitAPI](http://bukkit.org/) 实现。~~~~
17+
- **[推荐]** 变量部分基于 [PlaceholderAPI](https://www.spigotmc.org/resources/6245/) 实现。
18+
19+
详细依赖列表可见 [Dependencies](https://github.com/CarmJos/PortalCommands/network/dependencies) 。
20+
21+
## 支持与捐赠
22+
23+
若您觉得本插件做的不错,您可以捐赠支持我!
24+
25+
感谢您成为开源项目的支持者!
26+
27+
<img height=25% width=25% src="https://raw.githubusercontent.com/CarmJos/CarmJos/main/img/donate-code.jpg" alt=""/>

pom.xml

Lines changed: 195 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,195 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<groupId>cc.carm.plugom</groupId>
8+
<artifactId>portalcommands</artifactId>
9+
<version>1.0.0</version>
10+
11+
<name>PortalCommands</name>
12+
<description>当玩家进入传送门时执行对应指令。</description>
13+
<url>https://github.com/CarmJos/PortalCommands</url>
14+
15+
<issueManagement>
16+
<system>GitHub Issues</system>
17+
<url>${project.url}/issues</url>
18+
</issueManagement>
19+
20+
<ciManagement>
21+
<system>GitHub Actions</system>
22+
<url>${project.url}/actions/workflows/maven.yml</url>
23+
</ciManagement>
24+
<developers>
25+
<developer>
26+
<id>CarmJos</id>
27+
<name>Carm Jos</name>
28+
<email>[email protected]</email>
29+
<url>https://work.carm.cc</url>
30+
<roles>
31+
<role>Main Developer</role>
32+
</roles>
33+
</developer>
34+
</developers>
35+
36+
<properties>
37+
<maven.compiler.source>8</maven.compiler.source>
38+
<maven.compiler.target>8</maven.compiler.target>
39+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
40+
<maven.compiler.encoding>UTF-8</maven.compiler.encoding>
41+
</properties>
42+
43+
<repositories>
44+
45+
<repository>
46+
<id>carm-repo</id>
47+
<name>Carm's Repo</name>
48+
<url>https://repo.carm.cc/repository/maven-public/</url>
49+
</repository>
50+
51+
<repository>
52+
<id>spigot-repo</id>
53+
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
54+
</repository>
55+
56+
<repository>
57+
<id>placeholder-api-repo</id>
58+
<url>https://repo.extendedclip.com/content/repositories/placeholderapi/</url>
59+
</repository>
60+
61+
<repository>
62+
<id>oss-repo</id>
63+
<url>https://oss.sonatype.org/content/groups/public/</url>
64+
</repository>
65+
66+
<repository>
67+
<id>nexus</id>
68+
<url>https://mvn.lumine.io/repository/maven-public/</url>
69+
</repository>
70+
71+
<repository>
72+
<id>maven-central</id>
73+
<url>https://repo1.maven.org/maven2/</url>
74+
</repository>
75+
76+
<repository>
77+
<id>github</id>
78+
<name>GitHub Packages</name>
79+
<url>https://maven.pkg.github.com/CarmJos/${project.name}</url>
80+
</repository>
81+
</repositories>
82+
83+
<distributionManagement>
84+
<downloadUrl>${project.url}/releases</downloadUrl>
85+
</distributionManagement>
86+
87+
<dependencies>
88+
89+
<dependency>
90+
<groupId>org.spigotmc</groupId>
91+
<artifactId>spigot-api</artifactId>
92+
<version>1.17-R0.1-SNAPSHOT</version>
93+
<scope>provided</scope>
94+
</dependency>
95+
96+
<dependency>
97+
<groupId>me.clip</groupId>
98+
<artifactId>placeholderapi</artifactId>
99+
<version>2.10.9</version>
100+
<scope>provided</scope>
101+
</dependency>
102+
103+
<dependency>
104+
<groupId>junit</groupId>
105+
<artifactId>junit</artifactId>
106+
<version>4.13.2</version>
107+
<scope>test</scope>
108+
</dependency>
109+
110+
<dependency>
111+
<groupId>org.jetbrains</groupId>
112+
<artifactId>annotations</artifactId>
113+
<version>22.0.0</version>
114+
<scope>provided</scope>
115+
</dependency>
116+
117+
</dependencies>
118+
119+
120+
<build>
121+
<plugins>
122+
<plugin>
123+
<groupId>org.apache.maven.plugins</groupId>
124+
<artifactId>maven-compiler-plugin</artifactId>
125+
<version>3.8.1</version>
126+
<configuration>
127+
<source>1.8</source>
128+
<target>1.8</target>
129+
<encoding>UTF-8</encoding>
130+
<compilerArgument>-parameters</compilerArgument>
131+
</configuration>
132+
</plugin>
133+
<plugin>
134+
<groupId>org.apache.maven.plugins</groupId>
135+
<artifactId>maven-jar-plugin</artifactId>
136+
<version>3.2.0</version>
137+
</plugin>
138+
<plugin>
139+
<groupId>org.apache.maven.plugins</groupId>
140+
<artifactId>maven-source-plugin</artifactId>
141+
<version>3.2.0</version>
142+
<executions>
143+
<execution>
144+
<phase>package</phase>
145+
<goals>
146+
<goal>jar-no-fork</goal>
147+
</goals>
148+
</execution>
149+
</executions>
150+
</plugin>
151+
<plugin>
152+
<groupId>org.apache.maven.plugins</groupId>
153+
<artifactId>maven-shade-plugin</artifactId>
154+
<version>3.2.3</version>
155+
<executions>
156+
<execution>
157+
<phase>package</phase>
158+
<goals>
159+
<goal>shade</goal>
160+
</goals>
161+
<configuration>
162+
<createDependencyReducedPom>false</createDependencyReducedPom>
163+
</configuration>
164+
</execution>
165+
</executions>
166+
<configuration>
167+
<filters>
168+
<filter>
169+
<artifact>*:*</artifact>
170+
<excludes>
171+
<exclude>META-INF/MANIFEST.MF</exclude>
172+
<exclude>META-INF/*.txt</exclude>
173+
</excludes>
174+
</filter>
175+
</filters>
176+
</configuration>
177+
</plugin>
178+
<plugin>
179+
<groupId>org.apache.maven.plugins</groupId>
180+
<artifactId>maven-surefire-plugin</artifactId>
181+
<version>2.22.1</version>
182+
<configuration>
183+
<useSystemClassLoader>false</useSystemClassLoader>
184+
</configuration>
185+
</plugin>
186+
</plugins>
187+
<resources>
188+
<resource>
189+
<directory>src/main/resources</directory>
190+
<filtering>true</filtering>
191+
</resource>
192+
</resources>
193+
</build>
194+
195+
</project>
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
package cc.carm.plugin.protalcommands;
2+
3+
import cc.carm.plugin.protalcommands.listener.UserListener;
4+
import cc.carm.plugin.protalcommands.util.ColorParser;
5+
import org.bukkit.Bukkit;
6+
import org.bukkit.command.CommandExecutor;
7+
import org.bukkit.command.PluginCommand;
8+
import org.bukkit.command.TabCompleter;
9+
import org.bukkit.event.Listener;
10+
import org.bukkit.plugin.java.JavaPlugin;
11+
import org.jetbrains.annotations.NotNull;
12+
import org.jetbrains.annotations.Nullable;
13+
14+
import java.util.List;
15+
16+
public class Main extends JavaPlugin {
17+
18+
private static Main instance;
19+
public static boolean debugMode = true;
20+
21+
@Override
22+
public void onEnable() {
23+
instance = this;
24+
log(getName() + " " + getDescription().getVersion() + " &7开始加载...");
25+
long startTime = System.currentTimeMillis();
26+
27+
log("加载配置文件...");
28+
saveDefaultConfig();
29+
reloadConfig();
30+
31+
log("注册监听器...");
32+
regListener(new UserListener());
33+
34+
log("加载完成 ,共耗时 " + (System.currentTimeMillis() - startTime) + " ms 。");
35+
36+
}
37+
38+
@Override
39+
public void onDisable() {
40+
log(getName() + " " + getDescription().getVersion() + " 开始卸载...");
41+
long startTime = System.currentTimeMillis();
42+
43+
log("卸载监听器...");
44+
Bukkit.getServicesManager().unregisterAll(this);
45+
46+
log("卸载完成 ,共耗时 " + (System.currentTimeMillis() - startTime) + " ms 。");
47+
}
48+
49+
/**
50+
* 注册监听器
51+
*
52+
* @param listener 监听器
53+
*/
54+
public static void regListener(Listener listener) {
55+
Bukkit.getPluginManager().registerEvents(listener, getInstance());
56+
}
57+
58+
public static void log(String message) {
59+
Bukkit.getConsoleSender().sendMessage(ColorParser.parse("[" + getInstance().getName() + "] " + message));
60+
}
61+
62+
public static void debug(String message) {
63+
if (debugMode) {
64+
log("[DEBUG] " + message);
65+
}
66+
}
67+
68+
public static Main getInstance() {
69+
return instance;
70+
}
71+
72+
public static void registerCommand(String commandName,
73+
@NotNull CommandExecutor executor) {
74+
registerCommand(commandName, executor, null);
75+
}
76+
77+
public static void registerCommand(String commandName,
78+
@NotNull CommandExecutor executor,
79+
@Nullable TabCompleter tabCompleter) {
80+
PluginCommand command = Bukkit.getPluginCommand(commandName);
81+
if (command == null) return;
82+
command.setExecutor(executor);
83+
if (tabCompleter != null) command.setTabCompleter(tabCompleter);
84+
}
85+
86+
public static List<String> getCommands() {
87+
return getInstance().getConfig().getStringList("commands");
88+
}
89+
90+
}

0 commit comments

Comments
 (0)