feat: 更新添加VBossAuth支持

Signed-off-by: 502647092 <admin@yumc.pw>
This commit is contained in:
2016-12-24 17:54:36 +08:00
parent a95ff7fa8b
commit 40e2294984
7 changed files with 189 additions and 156 deletions

243
pom.xml
View File

@@ -1,121 +1,126 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <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"> 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> <modelVersion>4.0.0</modelVersion>
<groupId>pw.yumc</groupId> <groupId>pw.yumc</groupId>
<artifactId>MiaoLobby</artifactId> <artifactId>MiaoLobby</artifactId>
<version>1.2</version> <version>1.2</version>
<build> <build>
<finalName>${project.name}</finalName> <finalName>${project.name}</finalName>
<resources> <resources>
<resource> <resource>
<directory>src/main/resources</directory> <directory>src/main/resources</directory>
<filtering>true</filtering> <filtering>true</filtering>
</resource> </resource>
</resources> </resources>
<plugins> <plugins>
<plugin> <plugin>
<artifactId>maven-compiler-plugin</artifactId> <artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version> <version>3.3</version>
<configuration> <configuration>
<source>1.7</source> <source>1.7</source>
<target>1.7</target> <target>1.7</target>
</configuration> </configuration>
</plugin> </plugin>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId> <artifactId>maven-shade-plugin</artifactId>
<version>2.3</version> <version>2.3</version>
<configuration> <configuration>
<createDependencyReducedPom>false</createDependencyReducedPom> <createDependencyReducedPom>false</createDependencyReducedPom>
<minimizeJar>true</minimizeJar> <minimizeJar>true</minimizeJar>
<artifactSet> <artifactSet>
<includes> <includes>
<include>pw.yumc:YumCore</include> <include>pw.yumc:YumCore</include>
</includes> </includes>
</artifactSet> </artifactSet>
<relocations> <relocations>
<relocation> <relocation>
<pattern>pw.yumc.YumCore</pattern> <pattern>pw.yumc.YumCore</pattern>
<shadedPattern>${project.groupId}.${project.artifactId}</shadedPattern> <shadedPattern>${project.groupId}.${project.artifactId}</shadedPattern>
</relocation> </relocation>
</relocations> </relocations>
</configuration> </configuration>
<executions> <executions>
<execution> <execution>
<phase>package</phase> <phase>package</phase>
<goals> <goals>
<goal>shade</goal> <goal>shade</goal>
</goals> </goals>
</execution> </execution>
</executions> </executions>
</plugin> </plugin>
<plugin> <plugin>
<groupId>com.github.wvengen</groupId> <groupId>com.github.wvengen</groupId>
<artifactId>proguard-maven-plugin</artifactId> <artifactId>proguard-maven-plugin</artifactId>
<executions> <executions>
<execution> <execution>
<phase>package</phase> <phase>package</phase>
<goals> <goals>
<goal>proguard</goal> <goal>proguard</goal>
</goals> </goals>
<configuration> <configuration>
<options> <options>
<option>-keep class ${project.groupId}.${project.artifactId}.${project.artifactId}</option> <option>-keep class ${project.groupId}.${project.artifactId}.${project.artifactId}</option>
</options> </options>
<libs> <libs>
<lib>${java.home}/lib/rt.jar</lib> <lib>${java.home}/lib/rt.jar</lib>
</libs> </libs>
</configuration> </configuration>
</execution> </execution>
</executions> </executions>
</plugin> </plugin>
</plugins> </plugins>
</build> </build>
<ciManagement> <ciManagement>
<system>Jenkins</system> <system>Jenkins</system>
<url>http://ci.yumc.pw/job/${project.artifactId}/</url> <url>http://ci.yumc.pw/job/${project.artifactId}/</url>
</ciManagement> </ciManagement>
<properties> <properties>
<update.description></update.description> <update.description></update.description>
<update.changes></update.changes> <update.changes></update.changes>
<env.GIT_COMMIT>DEBUG</env.GIT_COMMIT> <env.GIT_COMMIT>DEBUG</env.GIT_COMMIT>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties> </properties>
<repositories> <repositories>
<repository> <repository>
<id>spigot-repo</id> <id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url> <url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
</repository> </repository>
<repository> <repository>
<id>yumc-repo</id> <id>yumc-repo</id>
<url>http://repo.yumc.pw/content/groups/public/</url> <url>http://repo.yumc.pw/content/groups/public/</url>
</repository> </repository>
</repositories> </repositories>
<distributionManagement> <distributionManagement>
<repository> <repository>
<id>jtb</id> <id>jtb</id>
<name>YUMC</name> <name>YUMC</name>
<url>http://repo.yumc.pw/content/repositories/yumcenter/</url> <url>http://repo.yumc.pw/content/repositories/yumcenter/</url>
</repository> </repository>
</distributionManagement> </distributionManagement>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.spigotmc</groupId> <groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId> <artifactId>spigot-api</artifactId>
<type>jar</type> <type>jar</type>
<version>1.10.2-R0.1-SNAPSHOT</version> <version>1.10.2-R0.1-SNAPSHOT</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>pw.yumc</groupId> <groupId>pw.yumc</groupId>
<artifactId>YumCore</artifactId> <artifactId>YumCore</artifactId>
<type>jar</type> <type>jar</type>
<version>1.0</version> <version>1.0</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>cn.citycraft</groupId> <groupId>cn.citycraft</groupId>
<artifactId>AuthMe</artifactId> <artifactId>AuthMe</artifactId>
<type>jar</type> <type>jar</type>
<version>6.1</version> <version>6.1</version>
</dependency> </dependency>
</dependencies> <dependency>
<groupId>cn.citycraft</groupId>
<artifactId>VBossAuth</artifactId>
<version>1.5.2</version>
</dependency>
</dependencies>
</project> </project>

View File

@@ -0,0 +1,39 @@
package pw.yumc.MiaoLobby;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
import org.bukkit.scheduler.BukkitRunnable;
import pw.yumc.YumCore.bukkit.P;
import pw.yumc.YumCore.bukkit.compatible.C;
/**
* Created by 蒋天蓓 on 2016/12/24 0024.
*/
public class AuthHook implements Listener {
MiaoLobby plugin = P.getPlugin();
public AuthHook() {
Bukkit.getPluginManager().registerEvents(this, P.instance);
}
protected void delayTp(final Player player) {
new BukkitRunnable() {
int delay = plugin.config.AutoTPDelay;
@Override
public void run() {
if (player.isOnline()) {
if (delay > 0) {
C.ActionBar.send(player, String.format(plugin.config.TPDelay, delay));
delay--;
return;
}
plugin.random(player);
}
cancel();
}
}.runTaskTimerAsynchronously(plugin, 0, 20);
}
}

View File

@@ -1,40 +1,12 @@
package pw.yumc.MiaoLobby; package pw.yumc.MiaoLobby;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.scheduler.BukkitRunnable;
import fr.xephi.authme.events.LoginEvent; import fr.xephi.authme.events.LoginEvent;
import pw.yumc.YumCore.bukkit.P;
import pw.yumc.YumCore.bukkit.compatible.C;
public class AuthMeHook implements Listener {
MiaoLobby plugin = P.getPlugin();
public AuthMeHook() {
Bukkit.getPluginManager().registerEvents(this, P.instance);
}
public class AuthMeHook extends AuthHook {
@EventHandler @EventHandler
public void onLogin(final LoginEvent e) { public void onLogin(final LoginEvent e) {
new BukkitRunnable() { delayTp(e.getPlayer());
Player player = e.getPlayer();
int delay = plugin.config.AutoTPDelay;
@Override
public void run() {
if (player.isOnline()) {
if (delay > 0) {
C.ActionBar.send(player, String.format(plugin.config.TPDelay, delay));
delay--;
return;
}
plugin.random(player);
}
cancel();
}
}.runTaskTimerAsynchronously(plugin, 0, 20);
} }
} }

View File

@@ -17,7 +17,7 @@ public class Config extends InjectConfig {
public String TimeOut; public String TimeOut;
public String TPDelay; public String TPDelay;
public String Unavailable; public String Unavailable;
public Boolean AuthMeAutoTP; public Boolean LoginAutoTP;
public Integer AutoTPDelay; public Integer AutoTPDelay;
public Boolean ReTry; public Boolean ReTry;
} }

View File

@@ -21,8 +21,8 @@ import pw.yumc.YumCore.commands.CommandManager;
import pw.yumc.YumCore.commands.annotation.Cmd; import pw.yumc.YumCore.commands.annotation.Cmd;
import pw.yumc.YumCore.commands.annotation.Cmd.Executor; import pw.yumc.YumCore.commands.annotation.Cmd.Executor;
import pw.yumc.YumCore.commands.annotation.Help; import pw.yumc.YumCore.commands.annotation.Help;
import pw.yumc.YumCore.update.SubscribeTask;
import pw.yumc.YumCore.statistic.Statistics; import pw.yumc.YumCore.statistic.Statistics;
import pw.yumc.YumCore.update.SubscribeTask;
public class MiaoLobby extends JavaPlugin implements CommandExecutor { public class MiaoLobby extends JavaPlugin implements CommandExecutor {
public Config config; public Config config;
@@ -54,8 +54,13 @@ public class MiaoLobby extends JavaPlugin implements CommandExecutor {
public void onEnable() { public void onEnable() {
new CommandManager("MiaoLobby", this); new CommandManager("MiaoLobby", this);
Bukkit.getMessenger().registerOutgoingPluginChannel(this, "BungeeCord"); Bukkit.getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
if (config.AuthMeAutoTP && Bukkit.getPluginManager().isPluginEnabled("AuthMe")) { if (config.LoginAutoTP) {
new AuthMeHook(); if (Bukkit.getPluginManager().isPluginEnabled("AuthMe")) {
new AuthMeHook();
}
if (Bukkit.getPluginManager().isPluginEnabled("VBossAuth")) {
new VBossAuthHook();
}
} }
new Statistics(); new Statistics();
new SubscribeTask(); new SubscribeTask();

View File

@@ -0,0 +1,12 @@
package pw.yumc.MiaoLobby;
import org.bukkit.event.EventHandler;
import cn.citycraft.VBossAuth.event.LoginEvent;
public class VBossAuthHook extends AuthHook {
@EventHandler
public void onLogin(final LoginEvent e) {
delayTp(e.getPlayer());
}
}

View File

@@ -1,5 +1,5 @@
#配置文件版本 请勿修改 #配置文件版本 请勿修改
Version: 1.2 Version: 1.3
#数据库信息 #数据库信息
Servers: Servers:
@@ -7,8 +7,8 @@ Servers:
- lobby2 - lobby2
#传送超时时间(单位: Tick) #传送超时时间(单位: Tick)
WaitTime: 35 WaitTime: 35
#AuthMe自动传送 #登录自动传送(暂时支持AuthMe和VBossAuth)
AuthMeAutoTP: true LoginAutoTP: true
#自动登录延时(单位: 秒) #自动登录延时(单位: 秒)
AutoTPDelay: 10 AutoTPDelay: 10
#尝试完毕后是否继续重试 #尝试完毕后是否继续重试