feat: 更新添加VBossAuth支持

Signed-off-by: 502647092 <admin@yumc.pw>
vbauth
502647092 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"
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>pw.yumc</groupId>
<artifactId>MiaoLobby</artifactId>
<version>1.2</version>
<build>
<finalName>${project.name}</finalName>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.3</version>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
<minimizeJar>true</minimizeJar>
<artifactSet>
<includes>
<include>pw.yumc:YumCore</include>
</includes>
</artifactSet>
<relocations>
<relocation>
<pattern>pw.yumc.YumCore</pattern>
<shadedPattern>${project.groupId}.${project.artifactId}</shadedPattern>
</relocation>
</relocations>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.github.wvengen</groupId>
<artifactId>proguard-maven-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>proguard</goal>
</goals>
<configuration>
<options>
<option>-keep class ${project.groupId}.${project.artifactId}.${project.artifactId}</option>
</options>
<libs>
<lib>${java.home}/lib/rt.jar</lib>
</libs>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<ciManagement>
<system>Jenkins</system>
<url>http://ci.yumc.pw/job/${project.artifactId}/</url>
</ciManagement>
<properties>
<update.description></update.description>
<update.changes></update.changes>
<env.GIT_COMMIT>DEBUG</env.GIT_COMMIT>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<repositories>
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
</repository>
<repository>
<id>yumc-repo</id>
<url>http://repo.yumc.pw/content/groups/public/</url>
</repository>
</repositories>
<distributionManagement>
<repository>
<id>jtb</id>
<name>YUMC</name>
<url>http://repo.yumc.pw/content/repositories/yumcenter/</url>
</repository>
</distributionManagement>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<type>jar</type>
<version>1.10.2-R0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>pw.yumc</groupId>
<artifactId>YumCore</artifactId>
<type>jar</type>
<version>1.0</version>
</dependency>
<dependency>
<groupId>cn.citycraft</groupId>
<artifactId>AuthMe</artifactId>
<type>jar</type>
<version>6.1</version>
</dependency>
</dependencies>
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>pw.yumc</groupId>
<artifactId>MiaoLobby</artifactId>
<version>1.2</version>
<build>
<finalName>${project.name}</finalName>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.3</version>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
<minimizeJar>true</minimizeJar>
<artifactSet>
<includes>
<include>pw.yumc:YumCore</include>
</includes>
</artifactSet>
<relocations>
<relocation>
<pattern>pw.yumc.YumCore</pattern>
<shadedPattern>${project.groupId}.${project.artifactId}</shadedPattern>
</relocation>
</relocations>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.github.wvengen</groupId>
<artifactId>proguard-maven-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>proguard</goal>
</goals>
<configuration>
<options>
<option>-keep class ${project.groupId}.${project.artifactId}.${project.artifactId}</option>
</options>
<libs>
<lib>${java.home}/lib/rt.jar</lib>
</libs>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<ciManagement>
<system>Jenkins</system>
<url>http://ci.yumc.pw/job/${project.artifactId}/</url>
</ciManagement>
<properties>
<update.description></update.description>
<update.changes></update.changes>
<env.GIT_COMMIT>DEBUG</env.GIT_COMMIT>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<repositories>
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
</repository>
<repository>
<id>yumc-repo</id>
<url>http://repo.yumc.pw/content/groups/public/</url>
</repository>
</repositories>
<distributionManagement>
<repository>
<id>jtb</id>
<name>YUMC</name>
<url>http://repo.yumc.pw/content/repositories/yumcenter/</url>
</repository>
</distributionManagement>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<type>jar</type>
<version>1.10.2-R0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>pw.yumc</groupId>
<artifactId>YumCore</artifactId>
<type>jar</type>
<version>1.0</version>
</dependency>
<dependency>
<groupId>cn.citycraft</groupId>
<artifactId>AuthMe</artifactId>
<type>jar</type>
<version>6.1</version>
</dependency>
<dependency>
<groupId>cn.citycraft</groupId>
<artifactId>VBossAuth</artifactId>
<version>1.5.2</version>
</dependency>
</dependencies>
</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;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.scheduler.BukkitRunnable;
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
public void onLogin(final LoginEvent e) {
new BukkitRunnable() {
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);
delayTp(e.getPlayer());
}
}

View File

@ -17,7 +17,7 @@ public class Config extends InjectConfig {
public String TimeOut;
public String TPDelay;
public String Unavailable;
public Boolean AuthMeAutoTP;
public Boolean LoginAutoTP;
public Integer AutoTPDelay;
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.Executor;
import pw.yumc.YumCore.commands.annotation.Help;
import pw.yumc.YumCore.update.SubscribeTask;
import pw.yumc.YumCore.statistic.Statistics;
import pw.yumc.YumCore.update.SubscribeTask;
public class MiaoLobby extends JavaPlugin implements CommandExecutor {
public Config config;
@ -54,8 +54,13 @@ public class MiaoLobby extends JavaPlugin implements CommandExecutor {
public void onEnable() {
new CommandManager("MiaoLobby", this);
Bukkit.getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
if (config.AuthMeAutoTP && Bukkit.getPluginManager().isPluginEnabled("AuthMe")) {
new AuthMeHook();
if (config.LoginAutoTP) {
if (Bukkit.getPluginManager().isPluginEnabled("AuthMe")) {
new AuthMeHook();
}
if (Bukkit.getPluginManager().isPluginEnabled("VBossAuth")) {
new VBossAuthHook();
}
}
new Statistics();
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:
@ -7,8 +7,8 @@ Servers:
- lobby2
#传送超时时间(单位: Tick)
WaitTime: 35
#AuthMe自动传送
AuthMeAutoTP: true
#登录自动传送(暂时支持AuthMe和VBossAuth)
LoginAutoTP: true
#自动登录延时(单位: 秒)
AutoTPDelay: 10
#尝试完毕后是否继续重试