CloudNet Development Wiki

Mar 4, 2019
CloudNet Development Wiki
  • Hey Guys using CloudNet,

    I'm not the author of this plugin. All Credits goes to @Dytanic

    i really like CN (CloudNet) and on the Support Discord are very very very much questions about how to use this or that so i decided to make a Wiki Page for those who need it :D

    When something is not correct please contact me i'll change that.

    1. Diffrent classes and their methods

    There a are a few ways to access the API or to "use" it.

    The CloudNetAPI.class

    Here you can do following:

    • writeCNPCommand(String command)
    • writeCNSCommand(CNSInfo cnsInfo, String command)
    • reloadPermissions()
    • reload()
    • reload(CNSInfo cnsInfo)
    • getOnlinePlayers()
    • getOnlinePlayersByUUID()
    • getOnlinePlayersByName()
    • getProxys()
    • getProxysByName()
    • getGroups()
    • getServers()
    • getPermissionPool()
    • getServers(String group)
    • getServerInfos()
    • getServerInfos(String group)
    • getCloudNetServer(String serverId)
    • getOnlineCloudNetServers()
    • getProxyInfo(String proxy)
    • getOnlineCountByGroup(String group)
    • createPermissionGroup(PermissionGroup permissionGroup)
    • deletePermissionGroup(PermissionGroup permissionGroup)
    • updatePermissionGroup(PermissionGroup permissionGroup)
    • addPermission(UUID user, String permission, boolean value)
    • removePermission(UUID user, String permission)
    • createServerGroup(CNSInfo cnsInfo, ServerGroup serverGroup)
    • deleteServerGroup(CNSInfo cnsInfo, ServerGroup serverGroup)
    • updateServerGroup(CNSInfo cnsInfo, ServerGroup serverGroup)
    • getPermissionsGroups()
    • updatePlayer(PlayerWhereAmI playerWhereAmI)
    • setRank(PlayerWhereAmI playerWhereAmI, PermissionGroup permissionGroup, long timeout)
    • setRank(PlayerWhereAmI playerWhereAmI, String permissionGroup, long timeout)
    • setRank(PlayerWhereAmI playerWhereAmI, PermissionGroup permissionGroup, int days)
    • setRank(PlayerWhereAmI playerWhereAmI, PermissionGroup permissionGroup)
    • setRank(PlayerWhereAmI playerWhereAmI, String permissionGroup)
    • setRank(String name, String permissionGroup, long timeout)
    • startServer(SimpleServerGroup group, Document properties, boolean priorityStop)
    • boolean priorityStop, int maxplayers, int memory, boolean hide)
    • startCustomServer(SimpleServerGroup group, String serverId, Document properties,
    • startServer(String group, Document properties, boolean priorityStop)
    • startHidedServer(SimpleServerGroup group, Document properties, boolean priorityStop)
    • setPlayerToGroup(String name, PermissionGroup permissionGroup, long timeout)
    • sendServerCommand(ServerInfo serverInfo, String command)
    • getOnlineCount()
    • stopServer(String serverId)
    • startStaticServer(SimpleServerGroup group, String serverId, Document properties,
    • boolean priorityStop, int memory)
    • restartServer(String serverId, Document properties, boolean priorityStop)
    • restartStaticServer(String serverId, Document properties, boolean priorityStop, int memory)
    • sendCustomMessage(ServerType serviceType, String message, Document document)
    • query(String qry, Document metaData, Callback<Document> resultHandler)
    • getOfflinePlayer(String name, Callback<PlayerWhereAmI> callback)
    • getUUID(String name, Callback<UUID> uuidCallback)
    • getServerGroup(String name, Callback<ServerGroup> result)
    • getOnlinePlayer(String name)
    • getGroupData(String groupName)
    • getPermissionGroup(String name)
    • getOnlinePlayer(UUID uuid)
    • getServerInfo(String serverId)
    • getCnpConnector()
    • getCloudNetwork()
    • getMetaData()
    • getScheduler()
    • getCloudId()
    • getServerId()
    • getScheduledThread()
    • getUniqueId()
    • setCloudNetwork(CloudNetwork cloudNetwork)
    • getInstance()

    Then there is the CloudServer.class

    If you write in your code:

    Code (Text):
    CloudServer cloudServer = CloudServer.getInstance();
    You get the "instance" of the server the API is currently running on!

    • getInstance()
    • getServerGroup()
    • update()
    • sendCustomProxyMessage(String message, Document dataCatcher)
    • changeToIngame(boolean newServer)
    • updateNameTags(Player player)
    • setProperties(Document properties)
    • setServerState(ServerState serverState)
    • setMotd(String motd)
    • setMaxPlayers(int maxPlayers)
    • setExtra(String extra)
    • getMemory()
    • getProperties()
    • getMaxPlayers()
    • getPlugin()
    • getStartUp()
    • getServerGroupMode()
    • getMap()
    • getServerState()
    • getExtra()
    • getGroup()
    • getMotd()
    • isBetaServer()
    • getProfile()
    • setMap(ServerMap map)
    • setProfile(ServerGroupProfile profile)
    • getOwner()
    • isAutoStartServerByFull()
    • setAutoStartServerByFull(boolean autoStartServerByFull)
    • isHide()

    Also there is the CloudProxy.class

    • sendCustomProxyMessage(String message, Document metaData)
    • kickPlayer(String name, String resaon)
    • kickPlayer(UUID uuid, String reason)
    • sendPlayer(UUID uuid, ServerInfo serverInfo)
    • broadcast(String message)
    • updateProxyLayout(ProxyLayout proxyLayout)
    • update()
    • getProxyLayout()
    • getHostName()
    • getPort()
    • getMemory()
    • getFallback()
    • getInstance()
    • setProxyLayout(ProxyLayout proxyLayout)

    2. A few examples

    To start a new hidden server for the server maker (commandexecutor)
    Code (Text):
    UUID uuid; //UUID of the player
    CloudNetAPI.getInstance().startHidedServer(CloudNetAPI.getInstance().getGroupData(serverGroup), (new Document()).append("createdServerUUID", uuid.toString()), true);

    To send a command to any server in the CN available:
    Here the first one sends a command to the BungeeCord server to execute
    The second executes a command on lobby-1
    Code (Text):
    CloudNetAPI.getInstance().writeCNSCommand(CloudNetAPI.getInstance().getCloudNetServer("CNS-1"), "command -p Proxy-1 alert Nice Server");
    CloudNetAPI.getInstance().writeCNSCommand(CloudNetAPI.getInstance().getCloudNetServer("CNS-1"), "command -s lobby-1 gamemode 1 zM4xi");

    To send a player to any server in the CN:
    Code (Text):
    UUID uuid; //UUID of a player
    String serverName; //name/id of a server
    CloudProxy.getInstance().sendPlayer(uuid, CloudNetAPI.getInstance().getServerInfo(serverName));

    For more or specific examples please contact me i'll add them!

    3. Setup the CN (Step by Step)

    1.Folder Setup
    1.1 Recommended Folder paths
    1.2 Server Requirements
    2. First Start-Up and Configuration
    2.1 Follow the instructions
    2.2 Configure the CNP
    2.3 Configure the CNS

    1. Folder Setup
    1.1 Recommended Folder paths

    I recommend making a new folder named something clearly pointing out that here is the network stored, something like "network" or cloudsystem".
    Im gonna use following for this example:

    1.2 Server Requirements

    You can use the CN with any server you want to, but however i recommend a server a minimum of 8 GB of RAM and an average to very good CPU.

    The RAM is the most important because of the multiroot support of CN you can easily relive the CPU of a server.

    For this example im using following:

    Server 1:
    AMD Opteron(tm) Processor 3365
    32 GB RAM

    Server 2:
    Intel(R) Xeon(R) CPU E5-1650 v2 @ 3.50GHz
    12 GB RAM

    CNP: running on Server 1
    CNS-1: running on Server 1 (only lobbys)
    CNS-2: running on Server 2 (gameserver etc.)

    For optimized workload i recommend spreading it as far as possible.

    2. First Start-Up and Configuration
    2.1 Follow the instructions

    Navigate in the folder /server/network/ (example).
    Download the latest version of CN on linux with following command:

    Unpack the .zip and you will get 3 new folder

    On the first startup the console will guide you through a few questions that are self explanatory.

    How To Start? Navigate to /server/network/CloudNet-Proxy (example) and there you find a .jar and to start files on linux run the CNP by using following command:

    on Windows just execute the .bat file
    On Linux make sure the file has permission to execute to be sure all works navigate in the folder above /server/ (example)
    Here enter following command:

    This will give the files in the folder the needed permissions.

    For the CNS? Navigate to /server/network/CloudNet-Server/ (example)
    and make the same liek before execute the "start" files.

    2.2 Configure the CNP

    After the first setup i would recommend stop both instances by typing "stop" and hitting ENTER and then go in the filebrowser to configure both.

    File: config.yml

    edit the motd, maintenance motd and the messages and some options

    File: signsLayouts.json

    edit your layouts how you want them


    Edit the permissions, prefix and more

    2.3 Configure the CNS


    edit the maxmemory of the complete CNS, the ports, the CNS Name (for multiple roots/CNS), and you can turn records/logs on.

    File: groups.json

    edit all servergroups, their diffrent settings like dynamic ram and mor, the proxy setttings
  • Loading...
  • Loading...