Java Code Examples for org.bukkit.Bukkit.shutdown()

The following are Jave code examples for showing how to use shutdown() of the org.bukkit.Bukkit class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: EscapeLag   File: NetWorker.java   View Source Code Vote up 6 votes
public static void CheckAndDownloadPlugin() {
    if (ConfigMain.AutoUpdate == true) {
        try {
            // 整体获取
            File NetworkerFile = new File(EscapeLag.MainThis.getDataFolder(), "networkerlog");
            DowloadFile("http://www.relatev.com/files/EscapeLag/NetWorker.yml", NetworkerFile);
            YamlConfiguration URLLog = YamlConfiguration.loadConfiguration(NetworkerFile);
            // 检查插件并下载新版本
            EscapeLag.MainThis.getLogger().info("正在检查新版本插件,请稍等...");
            int NewVersion = URLLog.getInt("UpdateVersion");
            int NowVersion = Integer.valueOf("%BUILD_NUMBER%");
            if (NewVersion > NowVersion) {
                EscapeLag.MainThis.getLogger().info("插件检测到新版本 " + NewVersion + ",正在自动下载新版本插件...");
                DowloadFile("https://www.relatev.com/files/EscapeLag/EscapeLag.jar", EscapeLag.getPluginsFile());
                EscapeLag.MainThis.getLogger().info("插件更新版本下载完成!正在重启服务器!");
                Bukkit.shutdown();
            } else {
                EscapeLag.MainThis.getLogger().info("EscapeLag插件工作良好,暂无新版本检测更新。");
            }
            // 完成提示
            EscapeLag.MainThis.getLogger().info("全部网络工作都读取完毕了...");
        } catch (IOException ex) {
        }
    }
}
 
Example 2
Project: AgarMC   File: AgarGame.java   View Source Code Vote up 6 votes
public AgarGame(GameType type) {
    super("agarmc", AgarMC.NAME, type.getDisplayName(), CPlayer.class);
    gameType = type;
    try
    {
        IGameProperties config = SamaGamesAPI.get().getGameManager().getGameProperties();
        origin = Utils.getLocation(config.getOption("origin", null));
        dimensions = config.getOption("dimensions", null).getAsInt();
        maxstatic = dimensions * dimensions / 24;
        maxvirus = dimensions * dimensions / 1000;
        maxcells = 16;
        Bukkit.getLogger().info("Arena : Origin = " + origin.toString() + ", Dimensions = " + dimensions);
    }
    catch(Exception e)
    {
        Bukkit.getLogger().severe("Error in game.json ! Stopping server !");
        e.printStackTrace();
        Bukkit.shutdown();
    }
}
 
Example 3
Project: SamaGamesCore   File: DatabaseConnector.java   View Source Code Vote up 6 votes
private void connect()
{
    JedisPoolConfig config = new JedisPoolConfig();
    config.setMaxTotal(-1);
    config.setJmxEnabled(false);

    try
    {
        this.cachePool = new JedisPool(config, this.bungee.getIp(), this.bungee.getPort(), 0, this.bungee.getPassword());
        this.cachePool.getResource().close();

        this.plugin.log(Level.INFO, "Connected to database.");
    }
    catch (Exception e)
    {
        plugin.getLogger().log(Level.SEVERE, "Can't connect to the database!", e);
        Bukkit.shutdown();
    }
}
 
Example 4
Project: CentauriCloud   File: NetworkHandler.java   View Source Code Vote up 5 votes
@Override
protected void channelRead0(ChannelHandlerContext ctx, Packet packet) throws Exception {
	if (packet instanceof PacketPing) {
		ctx.channel().writeAndFlush(packet);
	} else if (packet instanceof PacketKillServer) {
		Bukkit.shutdown();
	} else if (packet instanceof PacketToServerDispatchCommand) {
		Bukkit.dispatchCommand(Bukkit.getConsoleSender(), ((PacketToServerDispatchCommand) packet).getCommand());
	}

	SpigotConnectorPlugin.getInstance().getPacketHandlers().forEach(handler -> handler.channelRead(ctx, packet));
}
 
Example 5
Project: CloudNet   File: BukkitBootstrap.java   View Source Code Vote up 5 votes
@Deprecated
@Override
public void run()
{
    getServer().getPluginManager().disablePlugin(this);
    Bukkit.shutdown();
}
 
Example 6
Project: EscapeLag   File: AzureAPI.java   View Source Code Vote up 5 votes
public static void RestartServer(String message){
AzureAPI.log("开始以理由 " + message +"重启服务器...");
List<Player> players = AzurePlayerList.players();
int ps = players.size();
for(int i=0;i<ps;i++){
	Player player = players.get(i);
	player.kickPlayer(loggerPrefix + message);
}
      Bukkit.shutdown();
  }
 
Example 7
Project: mczone   File: PVPTask.java   View Source Code Vote up 5 votes
@Override
public void run() {
	TIME += 1;

       Bukkit.getScheduler().scheduleSyncDelayedTask(Walls.instance, new Runnable() {
           @Override
           public void run() {
               Walls.checkWinner();
           }
       });
	
	int limit = 2700;
	if (TIME == limit - 300) {
	    Chat.server("&cGame ending in 5 minutes!");
	    return;
	}
	if (TIME == limit - 120) {
	    Chat.server("&cGame ending in 2 minutes!");
	    return;
	}
	if (TIME == limit - 60) {
	    Chat.server("&cGame ending in 1 minute!");
	    return;
	}
	if (TIME >= limit - 10) {
		Chat.server("&cGame ending in " + Chat.time(2700 - TIME) + "!");
	}
	if (TIME == limit || Bukkit.getOnlinePlayers().length == 0) {
		Bukkit.shutdown();
	}
	
}
 
Example 8
Project: SamaGamesCore   File: GameProperties.java   View Source Code Vote up 5 votes
public void reload()
{
    try
    {
        File file = new File(APIPlugin.getInstance().getDataFolder().getAbsoluteFile().getParentFile().getParentFile(), "game.json");

        if (!file.exists())
        {
            APIPlugin.log(Level.WARNING, "No game properties file found! If this serveur isn't a game server, don't worry about this message!");
            return;
        }

        JsonObject rootJson = new JsonParser().parse(new InputStreamReader(new FileInputStream(file), Charset.forName("UTF-8"))).getAsJsonObject();
        this.templateID = rootJson.get("template-id").getAsString();
        this.mapName = rootJson.get("map-name").getAsString();
        this.minSlots = rootJson.get("min-slots").getAsInt();
        this.maxSlots = rootJson.get("max-slots").getAsInt();
        this.options = rootJson.get("options").getAsJsonObject();

        File worldFolder = new File(APIPlugin.getInstance().getDataFolder().getAbsoluteFile().getParentFile().getParentFile(), "world");
        File arenaFile = new File(worldFolder, "arena.json");

        if (!arenaFile.exists())
        {
            this.mapProperties = new JsonObject();
            APIPlugin.log(Level.WARNING, "No arena properties file found! If this serveur isn't a game server, don't worry about this message!");
            return;
        }

        this.mapProperties = new JsonParser().parse(new InputStreamReader(new FileInputStream(arenaFile), Charset.forName("UTF-8"))).getAsJsonObject();
    }
    catch (FileNotFoundException e)
    {
        e.printStackTrace();
        APIPlugin.log(Level.SEVERE, "Can't open the game properties file. Abort start!");
        APIPlugin.getInstance().disable();
        Bukkit.shutdown();
    }
}
 
Example 9
Project: mczone   File: PreTask.java   View Source Code Vote up 4 votes
@Override
public void run() {
	if (TIME % 20 == 0) {
        Kit.load();
	}
	
	TOTAL_TIME += 1;
	if (Bukkit.getOnlinePlayers().length > 1)
	    TIME -= 1;
	
	if (TOTAL_TIME > 900 && Bukkit.getOnlinePlayers().length <= 3) {
	    Bukkit.shutdown();
	}
	
	if (Bukkit.getOnlinePlayers().length==Bukkit.getMaxPlayers() && TIME >= 15) {
		TIME = 10;
	}
	
	if (TIME==0) {
		boolean start = true;
		for (Team team : Team.list) {
			if (team.getMembers().size() <= 2) {
				start = false;
				break;
			}
		}
		if (start) {
		    Bukkit.getScheduler().scheduleSyncDelayedTask(Walls.instance, new Runnable() {
                   @Override
                   public void run() {
                       Walls.prep();
                   }
		    });
		}
		else {
			Chat.server("&cWe need 2 players per team in order to start the game!");
			TIME = Config.getInt("pre-time");
			return;
		}
		return;
	}
	
	if (TIME % 20 == 0 || TIME <= 10)
		Chat.server("&eGame beginning in &4" + Chat.time(TIME) + "&e!");	
}
 
Example 10
Project: SurvivalAPI   File: SurvivalGenerator.java   View Source Code Vote up 4 votes
public void finishGeneration(World world, long time)
{
    this.getLogger().info("Ready in " + time + "ms");
    Bukkit.shutdown();
}
 
Example 11
Project: Recreator   File: AzureAPI.java   View Source Code Vote up 4 votes
public static void fatal(final String prefix, final String context) {
    Bukkit.getLogger().severe(prefix + context);
    Bukkit.shutdown();
}