Common Development Pitfalls

Aug 11, 2015
Common Development Pitfalls
  • Common BungeeCord Development Pitfalls

    Common mistakes made while developing BungeeCord plugins and how to work around them

    Creating new threads(top)

    Creating new threads (for example, creating Threads, Timers, or Executors) is an behaviour that has been discouraged since build #948 and above, and in a future build it will be disabled.

    The recommended solution is to use the BungeeCord scheduler:
    Code (Java):
      getProxy().getScheduler().runAsync(this, new Runnable() {
        public void run() {

    If you require a Future, wrap the callable/runnable in a FutureTask.

    In cases where you are not able to specify a way to run an asynchronous task using the BungeeCord scheduler, you have two options:
    1. If the (external) API offers the ability to provide an Executor or ExecutorService, provide it your Plugin.getExecutorService().
    2. Create the object in an asynchronous task.

    Blocking the I/O threads(top)

    In BungeeCord, most events and/or commands are run on the network I/O threads. Due to the nature of BungeeCord (where all threads are multiplexed for high efficiency), performing blocking operations (such as I/O, fetching remote URLs, querying a database, ...) will hurt proxy performance.

    In general:
    1. Always run blocking tasks asynchronously. If you are not sure what operations are blocking, in most cases accessing external resources (like the disk, or a database server) is blocking.
    2. Never delay an event or command for longer than required. If you need to delay an event and it extends AsyncEvent, use its registerIntent() (to begin the task in the event handler) and completeIntent() (to end it, to call in the async task) methods. You should still run the blocking task asynchronously, but this will allow the event to be delayed and eventually continued when all asynchronous operations have completed.

    Attempting to mix Bukkit and BungeeCord APIs(top)

    BungeeCord does not include the Bukkit API and even if it had included it, it would be useless at best as it could not talk to your backend Bukkit server. Additionally, this works the other way: Spigot does not include the BungeeCord API and it would be useless to include it as it will not be able to talk to your BungeeCord instance.

    Note that BungeeCord's chat component API is included in Spigot, however this API is decoupled from BungeeCord.
  • Loading...
  • Loading...