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

The following examples show how to use org.bukkit.Bukkit#shutdown() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CommandListener.java    From Carbon with GNU Lesser General Public License v3.0 8 votes vote down vote up
@EventHandler
public void onServerCommand(ServerCommandEvent event) {
  FileConfiguration spigot = YamlConfiguration.loadConfiguration(new File(Bukkit.getServer().getWorldContainer(), "spigot.yml"));

  if (event.getCommand().equalsIgnoreCase("reload")) {
    // Restarts server if server is set up for it.
    if (spigot.getBoolean("settings.restart-on-crash")) {
      Bukkit.getLogger().severe("Restarting server due to reload command!");
      event.setCommand("restart");
    } else {
      // Call to server shutdown on disable.
      // Won't hurt if server already disables itself, but will prevent plugin unload/reload.
      Bukkit.getLogger().severe("Stopping server due to reload command!");
      Bukkit.shutdown();
    }
  }
}
 
Example 2
Source File: TrMenuLoader.java    From TrMenu with MIT License 6 votes vote down vote up
private boolean installDepend() {
    Plugin plugin = Bukkit.getPluginManager().getPlugin("PlaceholderAPI");
    File jarFile = new File("plugins/PlaceholderAPI.jar");
    String url = "https://api.spiget.org/v2/resources/6245/download";

    if (plugin == null) {
        jarFile.delete();
        TLocale.sendToConsole("PLUGIN.DEPEND.DOWNLOAD", "PlaceholderAPI");
        if (Files.downloadFile(url, jarFile)) {
            TLocale.sendToConsole("PLUGIN.DEPEND.INSTALL", "PlaceholderAPI");
        } else {
            TLocale.sendToConsole("PLUGIN.DEPEND.INSTALL-FAILED", "PlaceholderAPI");
        }
        Bukkit.shutdown();
        return true;
    }
    return false;
}
 
Example 3
Source File: CommandListener.java    From Carbon with GNU Lesser General Public License v3.0 6 votes vote down vote up
@EventHandler
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
  FileConfiguration spigot = YamlConfiguration.loadConfiguration(new File(Bukkit.getServer().getWorldContainer(), "spigot.yml"));
  if (event.getMessage().equalsIgnoreCase("/reload") && event.getPlayer().hasPermission("bukkit.command.reload")) {
    // Restarts server if server is set up for it.
    if (spigot.getBoolean("settings.restart-on-crash")) {
      Bukkit.getLogger().severe("[Carbon] Restarting server due to reload command!");
      Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "restart");
    } else {
      // Call to server shutdown on disable.
      // Won't hurt if server already disables itself, but will prevent plugin unload/reload.
      Bukkit.getLogger().severe("[Carbon] Stopping server due to reload command!");
      Bukkit.shutdown();
    }
  }
  }
 
Example 4
Source File: Updater.java    From TrMenu with MIT License 5 votes vote down vote up
public static void init(Plugin plugin) {
    url = "https://api.github.com/repos/Arasple/" + plugin.getName() + "/releases/latest";
    version = TrMenu.getTrVersion();
    newVersion = version;
    setAutoUpdate();

    if (!String.valueOf(version).equalsIgnoreCase(plugin.getDescription().getVersion().split("-")[0])) {
        TLocale.sendToConsole("ERROR.VERSION");
        Bukkit.shutdown();
    }
    Bukkit.getPluginManager().registerEvents(new Updater(), plugin);
}
 
Example 5
Source File: ListenerTabooLibUpdateCommand.java    From TrMenu with MIT License 5 votes vote down vote up
private void update(CommandSender sender) {
    sender.sendMessage("§8[§fTabooLib§8] §7Downloading TabooLib file...");
    Files.downloadFile(Plugin.URL[0][1], new File("libs/TabooLib.jar"));
    sender.sendMessage("§8[§fTabooLib§8] §2Download completed, the server will restart in 3 secs");
    try {
        Thread.sleep(3000L);
    } catch (InterruptedException e1) {
        e1.printStackTrace();
    }
    Bukkit.shutdown();
}
 
Example 6
Source File: ListenerCommand.java    From TabooLib with MIT License 5 votes vote down vote up
@EventHandler(priority = EventPriority.LOWEST)
public void cmd(ServerCommandEvent e) {
    if (e.getCommand().equalsIgnoreCase("saveFiles")) {
        Local.saveFiles();
        LocalPlayer.saveFiles();
        TLogger.getGlobalLogger().info("Successfully.");
    } else if (e.getCommand().equalsIgnoreCase("tDebug")) {
        if (TabooLibAPI.isDebug()) {
            TabooLibAPI.debug(false);
            TLogger.getGlobalLogger().info("&cDisabled.");
        } else {
            TabooLibAPI.debug(true);
            TLogger.getGlobalLogger().info("&aEnabled.");
        }
    } else if (e.getCommand().equalsIgnoreCase("libUpdate")) {
        e.setCancelled(true);
        e.getSender().sendMessage("§8[§fTabooLib§8] §cWARNING §7| §4Update TabooLib will force to restart your server. Please confirm this action by type §c/libupdateconfirm");
    } else if (e.getCommand().equalsIgnoreCase("libUpdateConfirm") || e.getCommand().equalsIgnoreCase("libUpdate confirm")) {
        e.getSender().sendMessage("§8[§fTabooLib§8] §7Downloading TabooLib file...");
        Files.downloadFile("https://skymc.oss-cn-shanghai.aliyuncs.com/plugins/TabooLib.jar", new File("libs/TabooLib.jar"));
        e.getSender().sendMessage("§8[§fTabooLib§8] §2Download completed, the server will restart in 3 secs");
        try {
            Thread.sleep(3000L);
        } catch (InterruptedException e1) {
            e1.printStackTrace();
        }
        Bukkit.shutdown();
    }
}
 
Example 7
Source File: Carbon.java    From Carbon-2 with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void onLoad() {
    log = this.getLogger(); //Automatically appends [Carbon] to prefix
    // call to server shutdown if worlds are already loaded, prevents various errors when loading plugin on the fly
    if (!Bukkit.getWorlds().isEmpty()) {
        log.log(Level.SEVERE, "World loaded before{0} {1}! (Was {2} loaded on the fly?)", new Object[]{pluginDescriptionFile.getName(), pluginDescriptionFile.getVersion(), pluginDescriptionFile.getName()});
        if (spigotConfig.getBoolean("settings.restart-on-crash")) {
            getServer().dispatchCommand(Bukkit.getConsoleSender(), "restart");
        }

        Bukkit.shutdown();
        return;
    }

    // Inject 1.9 features. Stop server if something fails
    try {
        injector.registerAll();
        injector.registerRecipes();
    } catch (Throwable e) {
        e.printStackTrace(System.out);
        log.warning("1.9 injection failed! Something went wrong, server cannot start properly, shutting down...");
        Bukkit.shutdown();
        return;
    }

    log.info("Carbon has finished injecting all 1.9 functionalities.");
}
 
Example 8
Source File: Carbon.java    From Carbon-2 with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void onLoad() {
    log = this.getLogger(); //Automatically appends [Carbon] to prefix
    // call to server shutdown if worlds are already loaded, prevents various errors when loading plugin on the fly
    if (!Bukkit.getWorlds().isEmpty()) {
        log.log(Level.SEVERE, "World loaded before{0} {1}! (Was {2} loaded on the fly?)", new Object[]{pluginDescriptionFile.getName(), pluginDescriptionFile.getVersion(), pluginDescriptionFile.getName()});
        if (spigotConfig.getBoolean("settings.restart-on-crash")) {
            getServer().dispatchCommand(Bukkit.getConsoleSender(), "restart");
        }

        Bukkit.shutdown();
        return;
    }

    // Inject 1.9 features. Stop server if something fails
    try {
        injector.registerAll();
        injector.registerRecipes();
    } catch (Throwable e) {
        e.printStackTrace(System.out);
        log.warning("1.9 injection failed! Something went wrong, server cannot start properly, shutting down...");
        Bukkit.shutdown();
        return;
    }

    log.info("Carbon has finished injecting all 1.9 functionalities.");
}
 
Example 9
Source File: ProtocolSupport.java    From ProtocolSupport with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public void onDisable() {
	Bukkit.shutdown();
	if (!loaded) {
		return;
	}
	ServerPlatform.get().getInjector().onDisable();
}
 
Example 10
Source File: BukkitBootstrap.java    From CloudNet with Apache License 2.0 4 votes vote down vote up
@Deprecated
@Override
public void run() {
    getServer().getPluginManager().disablePlugin(this);
    Bukkit.shutdown();
}
 
Example 11
Source File: PacketInExReset.java    From SubServers-2 with Apache License 2.0 4 votes vote down vote up
@Override
public void receive(SubDataSender client, ObjectMap<Integer> data) {
    if (data != null && data.contains(0x0000)) Bukkit.getLogger().warning("SubData > Received shutdown signal: " + data.getString(0x0000));
    else Bukkit.getLogger().warning("SubData > Received shutdown signal");
    Bukkit.shutdown();
}
 
Example 12
Source File: Carbon.java    From Carbon with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public void onLoad() {
  if(!Utilities.getMinecraftVersion(Bukkit.getVersion()).equals(supportedVersion)) {
    log.log(Level.WARNING, "[Carbon] It appears you are using version {0}! Sorry, but Carbon doesn''t support any other version than Spigot 1.7.10! Please remove this plugin from your server.", Bukkit.getVersion());
    Bukkit.shutdown();
    return;
  } else {
    log.log(Level.INFO, "[Carbon] Server version {0} detected! Carbon is loading...", Bukkit.getVersion());
  }
  //call to server shutdown if worlds are already loaded, prevents various errors when loading plugin on the fly
  if (!Bukkit.getWorlds().isEmpty()) {
    log.log(Level.SEVERE, "World loaded before{0} {1}! (Was {2} loaded on the fly?)", new Object[]{pluginDescriptionFile.getName(), pluginDescriptionFile.getVersion(), pluginDescriptionFile.getName()});
    if (spigotConfig.getBoolean("settings.restart-on-crash")) {
      getServer().dispatchCommand(Bukkit.getConsoleSender(), "restart");
    }

    Bukkit.shutdown();
    return;
  }
  
  
  saveResource("libraries/natives/32/linux/libattach.so", true);
  saveResource("libraries/natives/32/solaris/libattach.so", true);
  saveResource("libraries/natives/32/windows/attach.dll", true);
  saveResource("libraries/natives/64/linux/libattach.so", true);
  saveResource("libraries/natives/64/mac/libattach.dylib", true);
  saveResource("libraries/natives/64/solaris/libattach.so", true);
  saveResource("libraries/natives/64/windows/attach.dll", true);
  
  //Inject 1.8 features. Stop server if something fails
  try {
    Utilities.instantiate(this);
    instrumentator = new Instrumentator(this, new File(getDataFolder(), "libraries/natives/").getPath());
    instrumentator.instrumentate();
    injector = new Injector(this);
    injector.registerAll();
    injector.registerRecipes();
    entityGenerator.injectNewCreatures();
    if (getConfig().getBoolean("optimizations.usercache", false)) {
      OptimizedUserCacheInjector.injectUserCache();
      if (getConfig().getBoolean("debug.verbose", false)) {
        Carbon.log.log(Level.INFO, "[Carbon] Optimized UserCache was injected into Minecraft");
      }
    }
  } catch (Throwable e) {
    e.printStackTrace(System.out);
    log.warning("[Carbon] 1.8 injection failed! Something went wrong, server cannot start properly, shutting down...");
    Bukkit.shutdown();
    return;
  }

  log.info("Carbon has finished injecting all 1.8 functionalities.");
}