From 5bc4bd4bb228f218f6125b71b38b17116a5a1533 Mon Sep 17 00:00:00 2001 From: j502647092 Date: Tue, 28 Jul 2015 21:16:19 +0800 Subject: [PATCH] add PlayerLoginQueue and add JoinListen... Signed-off-by: j502647092 --- .../CTZLoginServer/CTZLoginQueue.java | 25 +++++++++++++++++++ .../CTZLoginServer/listen/PlayerListen.java | 25 +++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 src/cn/citycraft/CTZLoginServer/CTZLoginQueue.java create mode 100644 src/cn/citycraft/CTZLoginServer/listen/PlayerListen.java diff --git a/src/cn/citycraft/CTZLoginServer/CTZLoginQueue.java b/src/cn/citycraft/CTZLoginServer/CTZLoginQueue.java new file mode 100644 index 0000000..550110c --- /dev/null +++ b/src/cn/citycraft/CTZLoginServer/CTZLoginQueue.java @@ -0,0 +1,25 @@ +/** + * + */ +package cn.citycraft.CTZLoginServer; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author 蒋天蓓 + * 2015年7月28日下午9:08:23 + * TODO + */ +public class CTZLoginQueue { + protected static List list = new ArrayList(); + + public static boolean Login(String player) { + return list.remove(player); + } + + public static void add(String player) { + list.add(player); + } + +} diff --git a/src/cn/citycraft/CTZLoginServer/listen/PlayerListen.java b/src/cn/citycraft/CTZLoginServer/listen/PlayerListen.java new file mode 100644 index 0000000..3773516 --- /dev/null +++ b/src/cn/citycraft/CTZLoginServer/listen/PlayerListen.java @@ -0,0 +1,25 @@ +/** + * + */ +package cn.citycraft.CTZLoginServer.listen; + +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerJoinEvent; + +import cn.citycraft.CTZLoginServer.CTZLoginQueue; + +/** + * @author 蒋天蓓 + * 2015年7月28日下午9:05:20 + * TODO + */ +public class PlayerListen implements Listener { + + @EventHandler + public void PlayerLogin(PlayerJoinEvent e) { + if (!CTZLoginQueue.Login(e.getPlayer().getName())) { + e.getPlayer().kickPlayer("&c请从服务器专用启动器进入游戏!"); + } + } +}