Skip to content

Commit

Permalink
1.0.0 初始版本完成
Browse files Browse the repository at this point in the history
  • Loading branch information
CarmJos committed Dec 3, 2021
0 parents commit 4f9df8f
Show file tree
Hide file tree
Showing 11 changed files with 550 additions and 0 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# 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

name: Deploy

on:
# 支持手动触发构建
workflow_dispatch:
release:
# 创建release的时候触发
types: [ published ]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: "Set up JDK"
uses: actions/setup-java@v2
with:
java-version: '11'
distribution: 'adopt'
cache: maven
server-id: github
server-username: MAVEN_USERNAME
server-password: MAVEN_TOKEN
- name: "Deploy"
run: mvn -B deploy --file pom.xml -DskipTests
env:
MAVEN_USERNAME: ${{ github.repository_owner }}
MAVEN_TOKEN: ${{secrets.GITHUB_TOKEN}}
38 changes: 38 additions & 0 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# 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

name: Build

on:
# 支持手动触发构建
workflow_dispatch:
push:

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: "Set up JDK"
uses: actions/setup-java@v2
with:
java-version: '11'
distribution: 'adopt'
cache: maven
server-id: github
server-username: MAVEN_USERNAME
server-password: MAVEN_TOKEN
- name: "Package"
run: mvn -B package --file pom.xml
env:
MAVEN_USERNAME: ${{ github.repository_owner }}
MAVEN_TOKEN: ${{secrets.GITHUB_TOKEN}}
- name: "Target Stage"
run: mkdir staging && cp target/*.jar staging
- name: "Upload artifact"
uses: actions/upload-artifact@v2
with:
name: Artifact
path: staging
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/.idea/
/target/
./*.iml
*.iml
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
```text
___ _ _ ___ _
( _`\ ( )_ (_ ) ( _`\ ( )
| |_) ) _ _ __ | ,_) _ _ | | | ( (_) _ ___ ___ ___ ___ _ _ ___ _| | ___
| ,__/'/'_`\ ( '__)| | /'_` ) | | | | _ /'_`\ /' _ ` _ `\/' _ ` _ `\ /'_` )/' _ `\ /'_` |/',__)
| | ( (_) )| | | |_ ( (_| | | | | (_( )( (_) )| ( ) ( ) || ( ) ( ) |( (_| || ( ) |( (_| |\__, \
(_) `\___/'(_) `\__)`\__,_)(___) (____/'`\___/'(_) (_) (_)(_) (_) (_)`\__,_)(_) (_)`\__,_)(____/
```

# PortalCommands

当玩家进入传送门时执行对应指令。
~~~~
## 依赖
- **[必须]** 插件本体基于 [Spigot-API](https://hub.spigotmc.org/stash/projects/SPIGOT) 、[BukkitAPI](http://bukkit.org/) 实现。~~~~
- **[推荐]** 变量部分基于 [PlaceholderAPI](https://www.spigotmc.org/resources/6245/) 实现。

详细依赖列表可见 [Dependencies](https://github.com/CarmJos/PortalCommands/network/dependencies)

## 支持与捐赠

若您觉得本插件做的不错,您可以捐赠支持我!

感谢您成为开源项目的支持者!

<img height=25% width=25% src="https://raw.githubusercontent.com/CarmJos/CarmJos/main/img/donate-code.jpg" alt=""/>
195 changes: 195 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,195 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>cc.carm.plugom</groupId>
<artifactId>portalcommands</artifactId>
<version>1.0.0</version>

<name>PortalCommands</name>
<description>当玩家进入传送门时执行对应指令。</description>
<url>https://github.com/CarmJos/PortalCommands</url>

<issueManagement>
<system>GitHub Issues</system>
<url>${project.url}/issues</url>
</issueManagement>

<ciManagement>
<system>GitHub Actions</system>
<url>${project.url}/actions/workflows/maven.yml</url>
</ciManagement>
<developers>
<developer>
<id>CarmJos</id>
<name>Carm Jos</name>
<email>[email protected]</email>
<url>https://work.carm.cc</url>
<roles>
<role>Main Developer</role>
</roles>
</developer>
</developers>

<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.encoding>UTF-8</maven.compiler.encoding>
</properties>

<repositories>

<repository>
<id>carm-repo</id>
<name>Carm's Repo</name>
<url>https://repo.carm.cc/repository/maven-public/</url>
</repository>

<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>

<repository>
<id>placeholder-api-repo</id>
<url>https://repo.extendedclip.com/content/repositories/placeholderapi/</url>
</repository>

<repository>
<id>oss-repo</id>
<url>https://oss.sonatype.org/content/groups/public/</url>
</repository>

<repository>
<id>nexus</id>
<url>https://mvn.lumine.io/repository/maven-public/</url>
</repository>

<repository>
<id>maven-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/${project.name}</url>
</repository>
</repositories>

<distributionManagement>
<downloadUrl>${project.url}/releases</downloadUrl>
</distributionManagement>

<dependencies>

<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.17-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>me.clip</groupId>
<artifactId>placeholderapi</artifactId>
<version>2.10.9</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>22.0.0</version>
<scope>provided</scope>
</dependency>

</dependencies>


<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
<compilerArgument>-parameters</compilerArgument>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.2.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.2.0</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
</configuration>
</execution>
</executions>
<configuration>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/MANIFEST.MF</exclude>
<exclude>META-INF/*.txt</exclude>
</excludes>
</filter>
</filters>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
<configuration>
<useSystemClassLoader>false</useSystemClassLoader>
</configuration>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>

</project>
90 changes: 90 additions & 0 deletions src/main/java/cc/carm/plugin/protalcommands/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
package cc.carm.plugin.protalcommands;

import cc.carm.plugin.protalcommands.listener.UserListener;
import cc.carm.plugin.protalcommands.util.ColorParser;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.PluginCommand;
import org.bukkit.command.TabCompleter;
import org.bukkit.event.Listener;
import org.bukkit.plugin.java.JavaPlugin;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.List;

public class Main extends JavaPlugin {

private static Main instance;
public static boolean debugMode = true;

@Override
public void onEnable() {
instance = this;
log(getName() + " " + getDescription().getVersion() + " &7开始加载...");
long startTime = System.currentTimeMillis();

log("加载配置文件...");
saveDefaultConfig();
reloadConfig();

log("注册监听器...");
regListener(new UserListener());

log("加载完成 ,共耗时 " + (System.currentTimeMillis() - startTime) + " ms 。");

}

@Override
public void onDisable() {
log(getName() + " " + getDescription().getVersion() + " 开始卸载...");
long startTime = System.currentTimeMillis();

log("卸载监听器...");
Bukkit.getServicesManager().unregisterAll(this);

log("卸载完成 ,共耗时 " + (System.currentTimeMillis() - startTime) + " ms 。");
}

/**
* 注册监听器
*
* @param listener 监听器
*/
public static void regListener(Listener listener) {
Bukkit.getPluginManager().registerEvents(listener, getInstance());
}

public static void log(String message) {
Bukkit.getConsoleSender().sendMessage(ColorParser.parse("[" + getInstance().getName() + "] " + message));
}

public static void debug(String message) {
if (debugMode) {
log("[DEBUG] " + message);
}
}

public static Main getInstance() {
return instance;
}

public static void registerCommand(String commandName,
@NotNull CommandExecutor executor) {
registerCommand(commandName, executor, null);
}

public static void registerCommand(String commandName,
@NotNull CommandExecutor executor,
@Nullable TabCompleter tabCompleter) {
PluginCommand command = Bukkit.getPluginCommand(commandName);
if (command == null) return;
command.setExecutor(executor);
if (tabCompleter != null) command.setTabCompleter(tabCompleter);
}

public static List<String> getCommands() {
return getInstance().getConfig().getStringList("commands");
}

}
Loading

0 comments on commit 4f9df8f

Please sign in to comment.