1
0
mirror of https://e.coding.net/circlecloud/CTZServer.git synced 2024-12-26 17:18:45 +00:00

init project...

Signed-off-by: 502647092 <jtb1@163.com>
This commit is contained in:
502647092 2015-09-07 20:51:38 +08:00
commit 51f5b8431d
17 changed files with 1094 additions and 0 deletions

32
.classpath Normal file
View File

@ -0,0 +1,32 @@
<?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" path="/PluginHelper"/>
<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>

38
.gitignore vendored Normal file
View File

@ -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

23
.project Normal file
View File

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>CTZServer</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>

75
pom.xml Normal file
View File

@ -0,0 +1,75 @@
<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>CTZServer</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<name>CTZServer</name>
<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>
<createDependencyReducedPom>false</createDependencyReducedPom>
<minimizeJar>false</minimizeJar>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>cn.citycraft.CTZServer.Main</mainClass>
</transformer>
</transformers>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>citycraft-repo</id>
<url>http://ci.citycraft.cn:8800/jenkins/plugin/repository/everything/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>cn.citycraft</groupId>
<artifactId>PluginHelper</artifactId>
<type>jar</type>
<version>1.0</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.14</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
</dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>

10
resources/plugin.yml Normal file
View File

@ -0,0 +1,10 @@
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:
yum:
description: MC插件仓库
usage: §6使用§a/yum help§6查看帮助!

View File

@ -0,0 +1,252 @@
package cn.citycraft.CTZServer;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import org.bukkit.configuration.ConfigurationSection;
import com.google.gson.Gson;
public class CTZServer {
protected static Logger log = new Logger();
static ServerInfo sl = new ServerInfo();
static Gson gson = new Gson();
/**
* 把中文转成Unicode码
*
* @param str
* - 待转换的字符串
* @return 转换后的字符串
*/
public static String chinaToUnicode(String str) {
String result = "";
for (int i = 0; i < str.length(); i++) {
int chr1 = str.charAt(i);
if (chr1 >= 19968 && chr1 <= 171941)
result += "\\u" + Integer.toHexString(chr1);
else
result += str.charAt(i);
}
return result;
}
/**
* 获得json字符串
*
* @return
*/
public static String getJson() {
return chinaToUnicode(gson.toJson(sl));
}
public static Logger getLogger() {
return log;
}
/**
* 初始化服务器序列化类
*
* @param 配置类
*/
public static void Init(ConfigurationSection cs) {
Set<String> arealist = cs.getKeys(false);
for (String a : arealist) {
Area area = new Area();
area.setName(cs.getString(a + ".name"));
Set<String> serverlist = cs.getConfigurationSection(a + ".servers").getKeys(false);
for (String s : serverlist) {
Server server = new Server();
server.name = cs.getString(a + ".servers." + s + ".name");
server.address = cs.getString(a + ".servers." + s + ".address");
server.port = cs.getInt(a + ".servers." + s + ".port");
server.version = cs.getString(a + ".servers." + s + ".version");
server.info = cs.getString(a + ".servers." + s + ".info");
server.url = cs.getString(a + ".servers." + s + ".url");
server.depend = cs.getString(a + ".servers." + s + ".depend");
area.servers.add(server);
}
sl.areas.add(area);
}
}
/**
* 初始化服务器序列化类
*
* @param json
* - json字符串
*/
public static boolean Init(String json) {
try {
sl = gson.fromJson(json, ServerInfo.class);
return true;
} catch (Exception e) {
return false;
}
}
/**
* 判断是否为中文字符
*
* @param c
* @return
*/
public boolean isChinese(char c) {
Character.UnicodeBlock ub = Character.UnicodeBlock.of(c);
if (ub == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS || ub == Character.UnicodeBlock.CJK_COMPATIBILITY_IDEOGRAPHS || ub == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A
|| ub == Character.UnicodeBlock.GENERAL_PUNCTUATION || ub == Character.UnicodeBlock.CJK_SYMBOLS_AND_PUNCTUATION || ub == Character.UnicodeBlock.HALFWIDTH_AND_FULLWIDTH_FORMS)
return true;
return false;
}
}
class Area {
/**
* 大区名称
*/
String name;
/**
* 服务器信息
*/
List<Server> servers = new ArrayList<Server>();
public String getName() {
return name;
}
public List<Server> getServers() {
return servers;
}
public void setName(String name) {
this.name = name;
}
public void setServers(List<Server> servers) {
this.servers = servers;
}
}
/**
* 服务器数据序列化类
*
* @author 蒋天蓓
* 2015年8月14日下午4:36:12
*
*/
class Server {
/**
* 服务器名称
*/
public String name;
/**
* 服务器地址
*/
public String address;
/**
* 服务器端口
*/
public int port;
/**
* 服务器描述
*/
public String info;
/**
* 服务器版本
*/
public String version;
/**
* 版本下载地址
*/
public String url;
/**
* 依赖版本
*/
public String depend;
public String getAddress() {
return address;
}
public String getDepend() {
return depend;
}
public String getInfo() {
return info;
}
public String getName() {
return name;
}
public int getPort() {
return port;
}
public String getUrl() {
return url;
}
public String getVersion() {
return version;
}
public void setAddress(String address) {
this.address = address;
}
public void setDepend(String depend) {
this.depend = depend;
}
public void setInfo(String info) {
this.info = info;
}
public void setName(String name) {
this.name = name;
}
public void setPort(int port) {
this.port = port;
}
public void setUrl(String url) {
this.url = url;
}
public void setVersion(String version) {
this.version = version;
}
@Override
public String toString() {
return String.format("{0}:{1}", address, port);
}
}
class ServerInfo {
/**
* 服务器分区信息
*/
List<Area> areas = new ArrayList<Area>();
public List<Area> getAreas() {
return areas;
}
public void setAreas(List<Area> aareas) {
areas = aareas;
}
}

View File

@ -0,0 +1,41 @@
package cn.citycraft.CTZServer;
import java.text.SimpleDateFormat;
import java.util.Date;
import org.bukkit.ChatColor;
public class Logger {
public void error(String string) {
log(LEVEL.ERROR, string);
}
public void info(String string) {
log(LEVEL.INFO, string);
}
public void log(LEVEL lvl, String string) {
String time = new SimpleDateFormat("HH:mm:ss").format(new Date(System.currentTimeMillis()));
System.out.println(String.format("[%1$s %2$s] %3$s", time, lvl, ChatColor.stripColor(string)));
}
public void warning(String string) {
log(LEVEL.WARN, string);
}
enum LEVEL {
INFO("信息"),
WARN("警告"),
ERROR("错误");
String prefix;
LEVEL(String prefix) {
this.prefix = prefix;
}
@Override
public String toString() {
return prefix;
}
}
}

View File

@ -0,0 +1,7 @@
package cn.citycraft.CTZServer;
public class Main {
public static void main(String[] arg) throws InterruptedException {
new Thread(new ServerThread()).start();
}
}

View File

@ -0,0 +1,96 @@
package cn.citycraft.CTZServer;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import org.bukkit.ChatColor;
import cn.citycraft.CTZServer.commands.HandlerCommand;
import cn.citycraft.CTZServer.socket.CTZLoginServerSocket;
import cn.citycraft.sql.MySQLHelper;
import cn.citycraft.sql.SQLHelper;
import cn.citycraft.utils.FileUtil;
public class ServerThread implements Runnable {
protected CTZLoginServerSocket server;
protected SQLHelper sql;
HandlerCommand handlercmd;
public CTZLoginServerSocket getServer() {
return server;
}
@Override
public void run() {
CTZServer.getLogger().info(ChatColor.GREEN + "服务器开始启动...");
initCommand();
initDatabase();
initServerInfo();
server = new CTZLoginServerSocket();
server.start();
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
while (true) {
String cmdline;
try {
cmdline = br.readLine();
if (cmdline == null || cmdline.isEmpty())
continue;
String[] cmdargs = cmdline.split(" ");
String cmd = cmdargs[0];
handlercmd.execute(cmd, cmdargs);
} catch (IOException e) {
}
}
}
/**
* 初始化命令
*/
void initCommand() {
CTZServer.getLogger().info(ChatColor.GREEN + "初始化基础命令...");
handlercmd = new HandlerCommand(this);
}
/**
* 初始化数据库
*/
void initDatabase() {
String dbtable = "ctzserver";
CTZServer.getLogger().info(ChatColor.GREEN + "初始化数据库连接...");
sql = new MySQLHelper("127.0.0.1", 3306, "minecraft", "root", "");
if (!sql.dbConnection()) {
CTZServer.getLogger().warning(ChatColor.RED + "数据库连接失败...");
return;
}
CTZServer.getLogger().info("数据库连接成功,检查数据表是否存在...");
if (!sql.isTableExists(dbtable)) {
CTZServer.getLogger().info("数据表不存在,新建表" + dbtable + "...");
HashMap<String, String> fields = new HashMap<String, String>();
fields.put("player", "VARCHAR(16) NOT NULL");
fields.put("prefix", "VARCHAR(600) NOT NULL");
String Conditions = "UNIQUE (`player`)";
if (!sql.createTables(dbtable, fields, Conditions))
CTZServer.getLogger().warning("数据表" + dbtable + "创建失败,请尝试手动创建并重启服务器...");
}
}
/**
* 初始化服务器信息
*/
void initServerInfo() {
CTZServer.getLogger().info(ChatColor.GREEN + "加载服务器信息...");
FileUtil.saveResource(this, "/servers.json", false);
String json = FileUtil.readFile(new File("servers.json"));
if (CTZServer.Init(json))
CTZServer.getLogger().info(ChatColor.GREEN + "服务器信息加载成功...");
else
CTZServer.getLogger().warning(ChatColor.RED + "服务器信息加载失败...");
}
}

View File

@ -0,0 +1,88 @@
package cn.citycraft.CTZServer.commands;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public abstract class BaseCommand {
private String name;
private String[] aliases;
public BaseCommand(String name) {
this(name, new String[0]);
}
public BaseCommand(String name, String... aliases) {
this.name = name;
this.aliases = aliases;
}
/**
* 执行命令参数
*
* @param label
* - 命令
* @param args
* - 命令附加参数
*/
public abstract void execute(String label, String[] args);
/**
* 获得命令列表
*
* @return 命令列表
*/
public List<String> getCommandList() {
List<String> cmds = new ArrayList<String>();
cmds.add(name);
cmds.addAll(Arrays.asList(aliases));
return cmds;
}
/**
* 获得命令说明
*
* @return
*/
public abstract String getDescription();
/**
* 获得最小参数个数
*
* @return 最小参数个数
*/
public abstract int getMinimumArguments();
/**
* 获取命令名称
*
* @return 命令名称
*/
public String getName() {
return name;
}
/**
* 获得可能的参数
*
* @return
*/
public abstract String getPossibleArguments();
/**
* 命令匹配检测
*
* @param name
* - 命令
* @return 是否匹配
*/
public final boolean isValidTrigger(String name) {
if (this.name.equalsIgnoreCase(name))
return true;
if (aliases != null)
for (String alias : aliases)
if (alias.equalsIgnoreCase(name))
return true;
return false;
}
}

View File

@ -0,0 +1,37 @@
package cn.citycraft.CTZServer.commands;
import org.bukkit.ChatColor;
import cn.citycraft.CTZServer.CTZServer;
import cn.citycraft.CTZServer.ServerThread;
public class CommandStop extends BaseCommand {
ServerThread serverThread;
public CommandStop(ServerThread serverThread) {
super("stop");
this.serverThread = serverThread;
}
@Override
public void execute(String label, String[] args) {
CTZServer.getLogger().info(ChatColor.RED + "开始关闭服务器...");
serverThread.getServer().ShutDown();
}
@Override
public String getDescription() {
return ChatColor.RED + "关闭服务器";
}
@Override
public int getMinimumArguments() {
return 0;
}
@Override
public String getPossibleArguments() {
return null;
}
}

View File

@ -0,0 +1,53 @@
package cn.citycraft.CTZServer.commands;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.ChatColor;
import cn.citycraft.CTZServer.CTZServer;
import cn.citycraft.CTZServer.ServerThread;
import cn.citycraft.CTZServer.utils.StringUtil;
public class HandlerCommand {
ServerThread serverThread;
/**
* 已注册命令列表(包括别名)
*/
List<String> RegisterCommandList = new ArrayList<String>();
/**
* 命令监听类列表
*/
private List<BaseCommand> commandlist = new ArrayList<BaseCommand>();
public HandlerCommand(ServerThread serverThread) {
this.serverThread = serverThread;
registerCommand(new CommandStop(serverThread));
}
public boolean execute(String cmd, String[] args) {
String subcmd = args[0];
String[] subargs = StringUtil.moveStrings(args, 1);
for (BaseCommand command : commandlist)
if (command.isValidTrigger(subcmd))
if (subargs.length >= command.getMinimumArguments()) {
command.execute(subcmd, subargs);
return true;
} else
CTZServer.getLogger().info(ChatColor.RED + "错误的参数 " + ChatColor.YELLOW + "使用方法 /yum " + command.getName() + command.getPossibleArguments());
CTZServer.getLogger().info("未知命令 请使用help查看帮助...");
return false;
}
/**
* 注册命令
*
* @param command
* - 被注册的命令类
*/
public void registerCommand(BaseCommand command) {
if (command != null)
commandlist.add(command);
}
}

View File

@ -0,0 +1,177 @@
package cn.citycraft.CTZServer.socket;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.net.ServerSocket;
import java.net.Socket;
import org.bukkit.ChatColor;
import cn.citycraft.CTZServer.CTZServer;
import cn.citycraft.CTZServer.socket.Response.HttpStates;
public class CTZLoginServerSocket extends Thread {
ServerSocket s = null;
Socket socket = null;
int port = 25580;
/**
* 初始化服务端口
*/
public CTZLoginServerSocket() {
}
/**
* 初始化服务端口
*/
public CTZLoginServerSocket(int port) {
this.port = port;
}
@Override
public void run() {
try {
// 设定服务端的端口号
s = new ServerSocket(port);
CTZServer.getLogger().info(ChatColor.BLUE + "CTZ服务器开始监听 端口:" + s.getLocalPort());
// 等待请求,此方法会一直阻塞,直到获得请求才往下走
while (true) {
socket = s.accept();
new ClientThread(socket).start();
}
} catch (Exception e) {
CTZServer.getLogger().warning(ChatColor.RED + "CTZ服务器崩溃: " + e.getMessage());
} finally {
ShutDown();
}
}
/**
* 关闭服务器
*/
public void ShutDown() {
try {
socket.close();
s.close();
} catch (Exception e) {
}
CTZServer.getLogger().info(ChatColor.RED + "CTZ服务器已关闭...");
System.exit(0);
}
class ClientThread extends Thread {
Socket client = null;
BufferedReader br = null;
PrintWriter pw = null;
String ip = null;
public ClientThread(Socket client) {
this.client = client;
}
@Override
public void run() {
try {
// 用于接收客户端发来的请求
br = new BufferedReader(new InputStreamReader(client.getInputStream()));
// 用于发送返回信息,可以不需要装饰这么多io流使用缓冲流时发送数据要注意调用.flush()方法
pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(client.getOutputStream())), true);
ip = client.getInetAddress().getHostAddress();
while (true) {
String str = br.readLine();
if (str != null) {
Request req = new Request(str);
Response res = new Response();
String username = "";
String password = "";
if (req.isSuccess) {
switch (req.getPrefix().substring(1)) {
case "isregistered":
username = req.Query("username");
if (username == null) {
res.setState(HttpStates.Bad_Request);
break;
}
// if (API.isRegistered(username))
// res.setHtml("true");
// else
// res.setHtml("false");
break;
case "register":
username = req.Query("username");
password = req.Query("password");
if (username == null || password == null) {
res.setState(HttpStates.Bad_Request);
break;
}
// if (API.registerPlayer(username, password)) {
// res.setHtml("true");
// Bukkit.getConsoleSender().sendMessage("§6玩家: §a" + username + " §d注册成功 IP: " + ip);
// } else
// res.setHtml("false");
break;
case "login":
username = req.Query("username");
password = req.Query("password");
if (username == null || password == null) {
res.setState(HttpStates.Bad_Request);
break;
}
// if (API.checkPassword(username, password)) {
// res.setHtml("true");
// if (CTZLoginQueue.isCheckIP())
// CTZLoginQueue.add(username, ip);
// else
// CTZLoginQueue.add(username);
// Bukkit.getConsoleSender().sendMessage("§6玩家: §a" + username + " §3登录成功 IP: " + ip);
// } else
// res.setHtml("false");
break;
case "islogin":
username = req.Query("username");
if (username == null) {
res.setState(HttpStates.Bad_Request);
break;
}
// if (Bukkit.getPlayer(username) != null)
// res.setHtml("true");
// else
// res.setHtml("false");
// break;
case "changepassword":
username = req.Query("username");
password = req.Query("password");
if (username == null || password == null) {
res.setState(HttpStates.Bad_Request);
break;
}
// if (API.checkPassword(username, password))
// res.setHtml("true");
// // TODO 处理玩家密码修改事件
// else
// res.setHtml("false");
break;
case "serverlist":
res.setState(HttpStates.OK);
res.setHtml(CTZServer.getJson());
break;
default:
res.setState(HttpStates.Bad_Request);
}
pw.write(res.toString());
pw.flush();
}
break;
}
}
br.close();
pw.close();
client.close();
} catch (Exception e) {
}
}
}
}

View File

@ -0,0 +1,77 @@
/**
*
*/
package cn.citycraft.CTZServer.socket;
import java.util.Date;
import java.util.HashMap;
import java.util.Map.Entry;
/**
* @author 蒋天蓓 2015年7月28日下午7:19:28 HTTP客户端响应类
*/
public class Response {
public enum HttpStates {
OK(200), // 客户端请求成功
Bad_Request(400), // 客户端请求有语法错误不能被服务器所理解
Unauthorized(401), // 请求未经授权这个状态代码必须和WWW-Authenticate报头域一起使用
Forbidden(403), // 服务器收到请求但是拒绝提供服务
Not_Found(404), // 请求资源不存在eg输入了错误的URL
Internal_Server_Error(500), // 服务器发生不可预期的错误
Server_Unavailable(503); // 服务器当前不能处理客户端的请求一段时间后可能恢复正常
private int num = 0;
HttpStates(int num) {
this.num = num;
}
/**
* @return 返回状态所表示的代码
*/
public int getNum() {
return num;
}
@Override
public String toString() {
return super.toString().replace("_", " ");
}
}
protected HttpStates state = HttpStates.OK;
protected String version = "HTTP/1.1";
protected HashMap<String, String> header = new HashMap<String, String>();
protected String html = "";
public Response() {
header.put("Date", new Date().toString() + " GMT");
header.put("Server", "Minecraft-CTZLoginServer");
}
public void setHeader(String key, String value) {
header.put(key, value);
}
public void setHtml(String html) {
this.html = html;
}
public void setState(HttpStates state) {
this.state = state;
}
@Override
public String toString() {
StringBuffer sb = new StringBuffer();
sb.append(version + " " + state.getNum() + " " + state.toString() + "\r\n");
for (Entry<String, String> entry : header.entrySet()) {
sb.append(entry.getKey() + ": " + entry.getValue() + "\r\n");
}
sb.append("\r\n");
sb.append(this.html);
return sb.toString();
}
}

View File

@ -0,0 +1,56 @@
package cn.citycraft.CTZServer.utils;
import java.util.Collection;
/**
* 字符串工具
*
* @author 蒋天蓓
* 2015年8月22日下午12:41:59
*/
public class StringUtil {
/**
* 转移数组后获取字符串
*
* @param args
* - 原数组
* @param start
* - 数组开始位置
* @return 转移后的数组字符串
*/
public static String consolidateStrings(String[] args, int start) {
String ret = args[start];
if (args.length > start + 1)
for (int i = start + 1; i < args.length; i++)
ret = ret + " " + args[i];
return ret;
}
/**
* 转移数组
*
* @param args
* - 原数组
* @param start
* - 数组开始位置
* @return 转移后的数组字符串
*/
public static String[] moveStrings(String[] args, int start) {
String[] ret = new String[args.length - start];
System.arraycopy(args, start, ret, 0, ret.length);
return ret;
}
/**
* 给玩家或控制台发送消息组
*
* @param sender
* - 接收消息的玩家
* @param msg
* - 消息组
*/
public static void sendStringArray(Collection<String> msg) {
for (String string : msg)
System.out.println(string);
}
}

View File

@ -0,0 +1,32 @@
{
"areas":[
{
"name":"纯净大区",
"servers":[
{
"name":"InfinityZone",
"address":"four.mengcraft.com",
"port":11133,
"info":"InfinityZone \u000d 稳定 声誉 生存 地皮 小游戏",
"version":"1.8-Forge",
"url":"four.mengcraft.com",
"depend":"1.8"
}
]
},
{
"name":"模组大区",
"servers":[
{
"name":"光坂小镇",
"address":"three.mengcraft.com",
"port":11333,
"info":"MOD服务器: 豆腐 家具",
"version":"1.7.10-Forge",
"url":"three.mengcraft.com",
"depend":"1.7"
}
]
}
]
}