本文整理汇总了Java中cn.nukkit.utils.ServerKiller.start方法的典型用法代码示例。如果您正苦于以下问题:Java ServerKiller.start方法的具体用法?Java ServerKiller.start怎么用?Java ServerKiller.start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cn.nukkit.utils.ServerKiller
的用法示例。
在下文中一共展示了ServerKiller.start方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: shutdown
import cn.nukkit.utils.ServerKiller; //导入方法依赖的package包/类
/**
* サーバーを終了させます。
* @return void
*/
public void shutdown() {
if (this.isRunning) {
ServerKiller killer = new ServerKiller(90);
killer.start();
}
this.isRunning = false;
}
示例2: main
import cn.nukkit.utils.ServerKiller; //导入方法依赖的package包/类
public static void main(String[] args) {
if(!(JAVA_VERSION.startsWith("1.8"))){
System.out.println("[CRITICAL] This program runs on JRE(JRE) 1.8");
System.out.println("[CRITICAL] You must use JRE(JDK) 1.8.");
System.out.println("[CRITICAL] Java version: " + JAVA_VERSION);
System.exit(0);
}
//Shorter title for windows 8/2012
String osName = System.getProperty("os.name").toLowerCase();
if (osName.contains("windows")) {
if (osName.contains("windows 8") || osName.contains("2012")) {
shortTitle = true;
}
}
//启动参数
for (String arg : args) {
switch (arg) {
case "disable-ansi":
ANSI = false;
break;
}
}
MainLogger logger = new MainLogger(DATA_PATH + "server.log");
System.out.println("Minecraft用 Jupiterサーバーを開始しています。");
jobs.add(new Callable<Server>(){
@Override
public Server call() throws Exception {
return new Server(logger, PATH, DATA_PATH, PLUGIN_PATH);
}
});
try {
threadpool.invokeAll(jobs);
threadpool.shutdown();
if(threadpool.awaitTermination(1L,TimeUnit.MINUTES)){// 1 minutes
System.out.println("サーバーを停止しています...");
logger.info("スレッドが停止しました。");
for (Thread thread : java.lang.Thread.getAllStackTraces().keySet()) {
if (!(thread instanceof InterruptibleThread)) {
continue;
}
logger.debug("Stopping " + thread.getClass().getSimpleName() + " thread");
if (thread.isAlive()) {
thread.interrupt();
}
}
ServerKiller killer = new ServerKiller(8);
killer.start();
logger.shutdown();
logger.interrupt();
CommandReader.getInstance().removePromptLine();
System.out.println("サーバーが停止しました。");
System.exit(0);
}else{
System.out.println("サーバーの停止に失敗しました。");
}
} catch (InterruptedException e) {
e.printStackTrace();
threadpool.shutdown();
}
}
示例3: main
import cn.nukkit.utils.ServerKiller; //导入方法依赖的package包/类
public static void main(String[] args) {
//Shorter title for windows 8/2012
String osName = System.getProperty("os.name").toLowerCase();
if (osName.contains("windows")) {
if (osName.contains("windows 8") || osName.contains("2012")) {
shortTitle = true;
}
}
//启动参数
for (String arg : args) {
switch (arg) {
case "disable-ansi":
ANSI = false;
break;
}
}
MainLogger logger = new MainLogger(DATA_PATH + "server.log");
try {
if (ANSI) {
System.out.print((char) 0x1b + "]0;Starting Nukkit Server For Minecraft: PE" + (char) 0x07);
}
new Server(logger, PATH, DATA_PATH, PLUGIN_PATH);
} catch (Exception e) {
logger.logException(e);
}
if (ANSI) {
System.out.print((char) 0x1b + "]0;Stopping Server..." + (char) 0x07);
}
logger.info("Stopping other threads");
for (Thread thread : java.lang.Thread.getAllStackTraces().keySet()) {
if (!(thread instanceof InterruptibleThread)) {
continue;
}
logger.debug("Stopping " + thread.getClass().getSimpleName() + " thread");
if (thread.isAlive()) {
thread.interrupt();
}
}
ServerKiller killer = new ServerKiller(8);
killer.start();
logger.shutdown();
logger.interrupt();
CommandReader.getInstance().removePromptLine();
if (ANSI) {
System.out.print((char) 0x1b + "]0;Server Stopped" + (char) 0x07);
}
System.exit(0);
}
示例4: main
import cn.nukkit.utils.ServerKiller; //导入方法依赖的package包/类
public static void main(String[] args) {
//Shorter title for windows 8/2012
String osName = System.getProperty("os.name").toLowerCase();
if (osName.contains("windows")) {
if (osName.contains("windows 8") || osName.contains("2012")) {
shortTitle = true;
}
}
//启动参数
for (String arg : args) {
switch (arg) {
case "disable-ansi":
ANSI = false;
break;
}
}
MainLogger logger = new MainLogger(DATA_PATH + "server.log");
try {
if (ANSI) {
System.out.print((char) 0x1b + "]0;Starting CoreX Server For Minecraft: PE" + (char) 0x07);
}
new Server(logger, PATH, DATA_PATH, PLUGIN_PATH);
} catch (Exception e) {
logger.logException(e);
}
if (ANSI) {
System.out.print((char) 0x1b + "]0;Stopping Server..." + (char) 0x07);
}
logger.info("Stopping other threads");
for (Thread thread : java.lang.Thread.getAllStackTraces().keySet()) {
if (!(thread instanceof InterruptibleThread)) {
continue;
}
logger.debug("Stopping " + thread.getClass().getSimpleName() + " thread");
if (thread.isAlive()) {
thread.interrupt();
}
}
ServerKiller killer = new ServerKiller(8);
killer.start();
logger.shutdown();
logger.interrupt();
CommandReader.getInstance().removePromptLine();
if (ANSI) {
System.out.print((char) 0x1b + "]0;Server Stopped" + (char) 0x07);
}
System.exit(0);
}
示例5: main
import cn.nukkit.utils.ServerKiller; //导入方法依赖的package包/类
public static void main(String[] args) {
//Shorter title for windows 8/2012
String osName = System.getProperty("os.name").toLowerCase();
if (osName.contains("windows")) {
if (osName.contains("windows 8") || osName.contains("2012")) {
shortTitle = true;
}
}
//启动参数
for (String arg : args) {
switch (arg) {
case "disable-ansi":
ANSI = false;
break;
}
}
MainLogger logger = new MainLogger(DATA_PATH + "server.log");
try {
if (ANSI) {
System.out.print((char) 0x1b + "]0;Starting Nukkit Server For Minecraft: PE" + (char) 0x07);
}
Server server = new Server(logger, PATH, DATA_PATH, PLUGIN_PATH);
} catch (Exception e) {
logger.logException(e);
}
if (ANSI) {
System.out.print((char) 0x1b + "]0;Stopping Server..." + (char) 0x07);
}
logger.info("Stopping other threads");
for (Thread thread : java.lang.Thread.getAllStackTraces().keySet()) {
if (!(thread instanceof InterruptibleThread)) {
continue;
}
logger.debug("Stopping " + thread.getClass().getSimpleName() + " thread");
if (thread.isAlive()) {
thread.interrupt();
}
}
ServerKiller killer = new ServerKiller(8);
killer.start();
logger.shutdown();
logger.interrupt();
CommandReader.getInstance().removePromptLine();
if (ANSI) {
System.out.print((char) 0x1b + "]0;Server Stopped" + (char) 0x07);
}
System.exit(0);
}
示例6: main
import cn.nukkit.utils.ServerKiller; //导入方法依赖的package包/类
public static void main(String[] args) {
//Shorter title for windows 8/2012
String osName = System.getProperty("os.name").toLowerCase();
if (osName.contains("windows")) {
if (osName.contains("windows 8") || osName.contains("2012")) {
shortTitle = true;
}
}
//启动参数
for (String arg : args) {
switch (arg) {
case "disable-ansi":
ANSI = false;
break;
}
}
MainLogger logger = new MainLogger(DATA_PATH + "server.log");
try {
if (ANSI) {
System.out.print((char) 0x1b + "]0;Starting Apollo Server For Minecraft: PE" + (char) 0x07);
}
new Server(logger, PATH, DATA_PATH, PLUGIN_PATH);
} catch (Exception e) {
logger.logException(e);
}
if (ANSI) {
System.out.print((char) 0x1b + "]0;Stopping Server..." + (char) 0x07);
}
logger.info("Stopping other threads");
for (Thread thread : java.lang.Thread.getAllStackTraces().keySet()) {
if (!(thread instanceof InterruptibleThread)) {
continue;
}
logger.debug("Stopping " + thread.getClass().getSimpleName() + " thread");
if (thread.isAlive()) {
thread.interrupt();
}
}
ServerKiller killer = new ServerKiller(8);
killer.start();
logger.shutdown();
logger.interrupt();
CommandReader.getInstance().removePromptLine();
if (ANSI) {
System.out.print((char) 0x1b + "]0;Server Stopped" + (char) 0x07);
}
System.exit(0);
}