mirror of
https://e.coding.net/circlecloud/CTZLoginServer.git
synced 2024-12-11 05:18:48 +00:00
updata...
This commit is contained in:
parent
1aede8f0e3
commit
0e22831512
@ -3,6 +3,7 @@ package cn.citycraft.CTZLoginServer;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
import cn.citycraft.CTZLoginServer.Socket.CTZLoginServerSocket;
|
||||
import cn.citycraft.CTZLoginServer.config.Config;
|
||||
@ -10,10 +11,12 @@ import cn.citycraft.CTZLoginServer.listen.PlayerListen;
|
||||
|
||||
public class CTZLoginServer extends JavaPlugin {
|
||||
public String version;
|
||||
public BukkitTask loginserver;
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
getLogger().info("已卸载!");
|
||||
loginserver.cancel();
|
||||
getLogger().info("CTZLoginServer已卸载!");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -28,12 +31,22 @@ public class CTZLoginServer extends JavaPlugin {
|
||||
pm.disablePlugin(this);
|
||||
return;
|
||||
}
|
||||
this.getServer()
|
||||
onLoadLoginServer();
|
||||
pm.registerEvents(new PlayerListen(), this);
|
||||
getLogger().info("CTZLoginServer已加载!");
|
||||
}
|
||||
|
||||
public void onLoadLoginServer() {
|
||||
if (loginserver != null) {
|
||||
loginserver.cancel();
|
||||
getLogger().info("CTZL登录服务器已关闭!");
|
||||
}
|
||||
loginserver = this
|
||||
.getServer()
|
||||
.getScheduler()
|
||||
.runTaskAsynchronously(this,
|
||||
new CTZLoginServerSocket(this, Config.getInstance().getInt("server.port")));
|
||||
pm.registerEvents(new PlayerListen(), this);
|
||||
getLogger().info("已加载!");
|
||||
getLogger().info("CTZL登录服务器已开启!");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -17,7 +17,7 @@ import fr.xephi.authme.api.API;
|
||||
|
||||
public class CTZLoginServerSocket implements Runnable {
|
||||
|
||||
public int port = 8080;
|
||||
public int port = 25580;
|
||||
public CTZLoginServer plugin;
|
||||
|
||||
/**
|
||||
@ -32,7 +32,6 @@ public class CTZLoginServerSocket implements Runnable {
|
||||
public void run() {
|
||||
ServerSocket s = null;
|
||||
Socket socket = null;
|
||||
|
||||
try {
|
||||
// 设定服务端的端口号
|
||||
s = new ServerSocket(port);
|
||||
@ -45,7 +44,7 @@ public class CTZLoginServerSocket implements Runnable {
|
||||
} catch (Exception e) {
|
||||
System.out.println("CTZL服务器崩溃...");
|
||||
} finally {
|
||||
System.out.println("关闭连接");
|
||||
System.out.println("CTZL服务器已关闭...");
|
||||
try {
|
||||
socket.close();
|
||||
s.close();
|
||||
@ -90,8 +89,6 @@ public class CTZLoginServerSocket implements Runnable {
|
||||
}
|
||||
if (API.isRegistered(username)) {
|
||||
res.setHtml("true");
|
||||
Bukkit.getConsoleSender().sendMessage(
|
||||
"§6玩家: §a" + username + " §d注册成功 IP: " + ip);
|
||||
} else
|
||||
res.setHtml("false");
|
||||
break;
|
||||
@ -102,9 +99,11 @@ public class CTZLoginServerSocket implements Runnable {
|
||||
res.setState(HttpStates.Bad_Request);
|
||||
break;
|
||||
}
|
||||
if (API.registerPlayer(username, password))
|
||||
if (API.registerPlayer(username, password)) {
|
||||
res.setHtml("true");
|
||||
else
|
||||
Bukkit.getConsoleSender().sendMessage(
|
||||
"§6玩家: §a" + username + " §d注册成功 IP: " + ip);
|
||||
} else
|
||||
res.setHtml("false");
|
||||
break;
|
||||
case "login":
|
||||
|
@ -13,6 +13,7 @@ import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
import cn.citycraft.CTZLoginServer.CTZLoginQueue;
|
||||
import cn.citycraft.CTZLoginServer.config.Config;
|
||||
import fr.xephi.authme.api.API;
|
||||
|
||||
/**
|
||||
* @author 蒋天蓓
|
||||
@ -26,20 +27,25 @@ public class PlayerListen implements Listener {
|
||||
public void PlayerLogin(PlayerLoginEvent e) {
|
||||
String name = e.getPlayer().getName().toLowerCase();
|
||||
long lasttime = lastquittime.get(name) == null ? 0 : lastquittime.get(name);
|
||||
e.setKickMessage("§6[§bCTZLS§6] §c禁止入服 请使用服务器专用启动器进入游戏!");
|
||||
if (getNowTime() - lasttime < Config.getInstance().getInt("server.timeout")) {
|
||||
return;
|
||||
}
|
||||
if (CTZLoginQueue.isCheckIP()) {
|
||||
if (CTZLoginQueue.Login(name, e.getAddress().getHostAddress())) {
|
||||
return;
|
||||
if (CTZLoginQueue.Login(name)) {
|
||||
if (CTZLoginQueue.Login(name, e.getAddress().getHostAddress())) {
|
||||
API.forceLogin(e.getPlayer());
|
||||
return;
|
||||
}
|
||||
e.setKickMessage("§6[§bCTZLS§6] §c禁止入服 申请登录的IP与客户端IP不同!");
|
||||
}
|
||||
} else {
|
||||
if (CTZLoginQueue.Login(name)) {
|
||||
API.forceLogin(e.getPlayer());
|
||||
return;
|
||||
}
|
||||
}
|
||||
e.setResult(Result.KICK_WHITELIST);
|
||||
e.setKickMessage("§6[§bCTZLS§6] §c禁止入服 请使用服务器专用启动器进入游戏!");
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
Loading…
Reference in New Issue
Block a user