init project...
commit
7a98072a8d
|
@ -0,0 +1,31 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<classpath>
|
||||||
|
<classpathentry kind="src" output="target/classes" path="src/main/java">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="optional" value="true"/>
|
||||||
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
|
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
|
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
|
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="optional" value="true"/>
|
||||||
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
|
<classpathentry kind="output" path="target/classes"/>
|
||||||
|
</classpath>
|
|
@ -0,0 +1,38 @@
|
||||||
|
# Eclipse stuff
|
||||||
|
/.settings
|
||||||
|
|
||||||
|
# netbeans
|
||||||
|
/nbproject
|
||||||
|
|
||||||
|
# we use maven!
|
||||||
|
/build.xml
|
||||||
|
|
||||||
|
# maven
|
||||||
|
/target
|
||||||
|
/repo
|
||||||
|
|
||||||
|
# vim
|
||||||
|
.*.sw[a-p]
|
||||||
|
|
||||||
|
# various other potential build files
|
||||||
|
/build
|
||||||
|
/bin
|
||||||
|
/dist
|
||||||
|
/manifest.mf
|
||||||
|
|
||||||
|
/world
|
||||||
|
|
||||||
|
# Mac filesystem dust
|
||||||
|
*.DS_Store
|
||||||
|
|
||||||
|
# intellij
|
||||||
|
*.iml
|
||||||
|
*.ipr
|
||||||
|
*.iws
|
||||||
|
.idea/
|
||||||
|
|
||||||
|
# Project Stuff
|
||||||
|
/src/main/resources/Soulbound
|
||||||
|
|
||||||
|
# Atlassian Stuff
|
||||||
|
/atlassian-ide-plugin.xml
|
|
@ -0,0 +1,23 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<projectDescription>
|
||||||
|
<name>CTZServerBridge</name>
|
||||||
|
<comment></comment>
|
||||||
|
<projects>
|
||||||
|
</projects>
|
||||||
|
<buildSpec>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
</buildSpec>
|
||||||
|
<natures>
|
||||||
|
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||||
|
<nature>org.eclipse.m2e.core.maven2Nature</nature>
|
||||||
|
</natures>
|
||||||
|
</projectDescription>
|
|
@ -0,0 +1,80 @@
|
||||||
|
<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>cn.citycraft</groupId>
|
||||||
|
<artifactId>CTZServerBridge</artifactId>
|
||||||
|
<version>1.0</version>
|
||||||
|
<name>CTZServerBridge</name>
|
||||||
|
<description>服务器桥接插件...</description>
|
||||||
|
<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.1</version>
|
||||||
|
<configuration>
|
||||||
|
<source>1.8</source>
|
||||||
|
<target>1.8</target>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-shade-plugin</artifactId>
|
||||||
|
<version>2.3</version>
|
||||||
|
<configuration>
|
||||||
|
<minimizeJar>true</minimizeJar>
|
||||||
|
<artifactSet>
|
||||||
|
<includes>
|
||||||
|
<include>cn.citycraft:PluginHelper</include>
|
||||||
|
</includes>
|
||||||
|
</artifactSet>
|
||||||
|
<relocation>
|
||||||
|
<pattern>cn.citycraft.PluginHelper</pattern>
|
||||||
|
<shadedPattern>${project.groupId}.${project.artifactId}</shadedPattern>
|
||||||
|
</relocation>
|
||||||
|
</configuration>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<phase>package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>shade</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
<repositories>
|
||||||
|
<repository>
|
||||||
|
<id>spigot-repo</id>
|
||||||
|
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
|
||||||
|
</repository>
|
||||||
|
<repository>
|
||||||
|
<id>citycraft-repo</id>
|
||||||
|
<url>http://ci.citycraft.cn:8800/jenkins/plugin/repository/everything/</url>
|
||||||
|
</repository>
|
||||||
|
</repositories>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.spigotmc</groupId>
|
||||||
|
<artifactId>spigot-api</artifactId>
|
||||||
|
<type>jar</type>
|
||||||
|
<version>1.8.3-R0.1-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.citycraft</groupId>
|
||||||
|
<artifactId>PluginHelper</artifactId>
|
||||||
|
<type>jar</type>
|
||||||
|
<version>1.0</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
<properties>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
</properties>
|
||||||
|
</project>
|
|
@ -0,0 +1,70 @@
|
||||||
|
package cn.citycraft.CTZServerBridge;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.command.ConsoleCommandSender;
|
||||||
|
import org.bukkit.plugin.PluginManager;
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
|
import cn.citycraft.CTZServerBridge.listen.PlayerListen;
|
||||||
|
import cn.citycraft.PluginHelper.sql.KeyValue;
|
||||||
|
import cn.citycraft.PluginHelper.sql.MySQLHelper;
|
||||||
|
import cn.citycraft.PluginHelper.sql.SQLHelper;
|
||||||
|
|
||||||
|
public class CTZServerBridge extends JavaPlugin {
|
||||||
|
|
||||||
|
ConsoleCommandSender ccs;
|
||||||
|
SQLHelper sql;
|
||||||
|
|
||||||
|
public SQLHelper getSql() {
|
||||||
|
return sql;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDisable() {
|
||||||
|
super.onDisable();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onEnable() {
|
||||||
|
this.initDatabase();
|
||||||
|
this.initListener();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initListener() {
|
||||||
|
PluginManager pm = Bukkit.getPluginManager();
|
||||||
|
pm.registerEvents(new PlayerListen(this), this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化数据库
|
||||||
|
*/
|
||||||
|
void initDatabase() {
|
||||||
|
String dbtable = "ctzserver";
|
||||||
|
ccs.sendMessage(ChatColor.GREEN + "初始化数据库连接...");
|
||||||
|
sql = new MySQLHelper("127.0.0.1", 3306, "minecraft", "root", "325325");
|
||||||
|
if (!sql.dbConnection()) {
|
||||||
|
ccs.sendMessage(ChatColor.RED + "数据库连接失败...");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ccs.sendMessage(ChatColor.GREEN + "数据库连接成功,检查数据表是否存在...");
|
||||||
|
if (!sql.isTableExists(dbtable)) {
|
||||||
|
ccs.sendMessage(ChatColor.RED + "数据表不存在,新建表" + dbtable + "...");
|
||||||
|
KeyValue kv = new KeyValue("player", "VARCHAR(16) NOT NULL")
|
||||||
|
.add("password", "VARCHAR(50) NOT NULL")
|
||||||
|
.add("ip", "VARCHAR(40) NOT NULL DEFAULT '127.0.0.1'")
|
||||||
|
.add("lastloginout", "BIGINT(20) NOT NULL DEFAULT 0")
|
||||||
|
.add("x", "DOUBLE NOT NULL DEFAULT 0")
|
||||||
|
.add("y", "DOUBLE NOT NULL DEFAULT 0")
|
||||||
|
.add("z", "DOUBLE NOT NULL DEFAULT 0")
|
||||||
|
.add("email", "VARCHAR(50) NOT NULL DEFAULT 'mc@mc.com'")
|
||||||
|
.add("world", "VARCHAR(20) DEFAULT 'world'")
|
||||||
|
.add("islogged", "SMALLINT(6) NOT NULL DEFAULT 0");
|
||||||
|
String Conditions = "UNIQUE (`player`)";
|
||||||
|
if (!sql.createTables(dbtable, kv, Conditions))
|
||||||
|
ccs.sendMessage(ChatColor.RED + "数据表 " + dbtable + " 创建失败,请尝试手动创建并重启服务器...");
|
||||||
|
else
|
||||||
|
ccs.sendMessage(ChatColor.GREEN + "数据表 " + dbtable + " 创建成功...");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,73 @@
|
||||||
|
package cn.citycraft.CTZServerBridge.listen;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.player.PlayerLoginEvent;
|
||||||
|
import org.bukkit.event.player.PlayerLoginEvent.Result;
|
||||||
|
|
||||||
|
import cn.citycraft.CTZServerBridge.CTZServerBridge;
|
||||||
|
import cn.citycraft.PluginHelper.sql.KeyValue;
|
||||||
|
|
||||||
|
public class PlayerListen implements Listener {
|
||||||
|
static final String TableName = "ctzserver";
|
||||||
|
static final String UserField = "player";
|
||||||
|
static final String PWDField = "password";
|
||||||
|
CTZServerBridge plugin;
|
||||||
|
|
||||||
|
public PlayerListen(CTZServerBridge ctzServerBridge) {
|
||||||
|
plugin = ctzServerBridge;
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void Join(PlayerLoginEvent e) {
|
||||||
|
Player p = e.getPlayer();
|
||||||
|
String result = plugin.getSql().dbSelectFirst(TableName, "islogged", new KeyValue(UserField, p.getName()));
|
||||||
|
if (result == null && !result.equalsIgnoreCase("1")) {
|
||||||
|
e.setKickMessage("§6[§bCTZLS§6] §c禁止入服 请使用服务器专用启动器进入游戏!");
|
||||||
|
e.setResult(Result.KICK_WHITELIST);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// private long getNowTime() {
|
||||||
|
// return System.currentTimeMillis() / 1000;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @EventHandler
|
||||||
|
// 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.canLogin(name, e.getAddress().getHostAddress())) {
|
||||||
|
// return;
|
||||||
|
// } else {
|
||||||
|
// if (CTZLoginQueue.canLogin(name))
|
||||||
|
// if (CTZLoginQueue.isCheckIP())
|
||||||
|
// e.setKickMessage("§6[§bCTZLS§6] §c禁止入服 申请登录的IP与客户端IP不同!");
|
||||||
|
// else
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
// if (!Config.getInstance().getBoolean("config.forceclient"))
|
||||||
|
// return;
|
||||||
|
// e.setResult(Result.KICK_WHITELIST);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @EventHandler(priority = EventPriority.LOWEST)
|
||||||
|
// public void PlayerJoin(PlayerJoinEvent e) {
|
||||||
|
// String name = e.getPlayer().getName().toLowerCase();
|
||||||
|
// if (lastquittime.containsKey(name)) {
|
||||||
|
// API.forceLogin(e.getPlayer());
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
// if (CTZLoginQueue.Login(name)) {
|
||||||
|
// API.forceLogin(e.getPlayer());
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @EventHandler
|
||||||
|
// public void PlayerQuit(PlayerQuitEvent e) {
|
||||||
|
// lastquittime.put(e.getPlayer().getName().toLowerCase(), getNowTime());
|
||||||
|
// }
|
|
@ -0,0 +1,14 @@
|
||||||
|
name: ${project.artifactId}
|
||||||
|
description: ${project.description}
|
||||||
|
main: ${project.groupId}.${project.artifactId}.${project.artifactId}
|
||||||
|
version: ${project.version}
|
||||||
|
auther: 喵♂呜
|
||||||
|
website: http://ci.citycraft.cn:8800/jenkins/job/${project.artifactId}/
|
||||||
|
commands:
|
||||||
|
ctzs:
|
||||||
|
description: CTZ服务器桥接插件
|
||||||
|
usage: §b使用/ctzs help 查看帮助!
|
||||||
|
permissions:
|
||||||
|
ctzs.reload:
|
||||||
|
description: 重新载入插件!
|
||||||
|
default: op
|
Loading…
Reference in New Issue