feat: 添加AuthMe自动传送

Signed-off-by: 502647092 <admin@yumc.pw>
vbauth
502647092 2016-09-28 00:46:12 +08:00
parent 270291ff91
commit a8b14469ce
6 changed files with 58 additions and 19 deletions

View File

@ -111,5 +111,11 @@
<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>
</project>

View File

@ -0,0 +1,21 @@
package pw.yumc.MiaoLobby;
import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import fr.xephi.authme.events.LoginEvent;
import pw.yumc.YumCore.bukkit.P;
public class AuthMeHook implements Listener {
MiaoLobby plugin = P.getPlugin();
public AuthMeHook() {
Bukkit.getPluginManager().registerEvents(this, P.instance);
}
@EventHandler
public void onLogin(final LoginEvent e) {
plugin.random(e.getPlayer());
}
}

View File

@ -16,4 +16,5 @@ public class Config extends InjectConfig {
public String Message;
public String TimeOut;
public String Unavailable;
public Boolean AuthMeAutoTP;
}

View File

@ -19,6 +19,7 @@ import pw.yumc.YumCore.commands.CommandArgument;
import pw.yumc.YumCore.commands.CommandExecutor;
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;
public class MiaoLobby extends JavaPlugin implements CommandExecutor {
@ -35,10 +36,33 @@ public class MiaoLobby extends JavaPlugin implements CommandExecutor {
p.sendPluginMessage(this, "BungeeCord", out.toByteArray());
}
@Cmd(permission = "MiaoLobby.default")
@Cmd(permission = "MiaoLobby.default", executor = Executor.PLAYER)
@Help("进行随机服务器传送")
public boolean def(final CommandArgument e) {
final Player player = (Player) e.getSender();
random((Player) e.getSender());
return true;
}
@Override
public FileConfiguration getConfig() {
return config.getConfig();
}
@Override
public void onEnable() {
new CommandManager("MiaoLobby", this);
Bukkit.getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
if (config.AuthMeAutoTP && Bukkit.getPluginManager().isPluginEnabled("AuthMe")) {
new AuthMeHook();
}
}
@Override
public void onLoad() {
config = new Config();
}
public void random(final Player player) {
new BukkitRunnable() {
List<String> servers = new ArrayList<>(config.Servers);
int i = 0;
@ -58,23 +82,6 @@ public class MiaoLobby extends JavaPlugin implements CommandExecutor {
cancel();
}
}.runTaskTimerAsynchronously(this, 0, config.WaitTime);
return true;
}
@Override
public FileConfiguration getConfig() {
return config.getConfig();
}
@Override
public void onEnable() {
new CommandManager("MiaoLobby", this);
Bukkit.getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
}
@Override
public void onLoad() {
config = new Config();
}
@Cmd(permission = "MiaoLobby.reload")

View File

@ -7,6 +7,8 @@ Servers:
- lobby2
#传送超时时间(单位: Tick)
WaitTime: 20
#AuthMe自动传送
AuthMeAutoTP: true
#传送提示
Message: '&a请稍候 正在传送至服务器 %s ...'
TimeOut: '&c传送超时 正在切换到服务器 %s ...'

View File

@ -4,6 +4,8 @@ main: ${project.groupId}.${project.artifactId}.${project.artifactId}
version: ${project.version}-git-${env.GIT_COMMIT}
author: 喵♂呜
website: ${ciManagement.url}
softdepend:
- AuthMe
commands:
${project.artifactId}:
description: ${project.artifactId} - ${project.description}