The DPDDspace Server Wrapper

    Alendon

    Programmer
    Joined
    Apr 13, 2016
    Messages
    32
    Reaction score
    19
    Hello Guys
    here i want to present you the DPDDs StarMade Wrapper. It is be a multifunctional server management and extension tool. The Wrapper is written in C# in the .Net Version 4.6.1 (How to use on Linux, look below).

    • Server/Wrapper:
      • The Server restarts automatically and have a built in daily restarter
      • Updates automatically the Server when a new StarMade Version was released
      • Built in Plugin System
      • a !help method for a general information about all plugin commands
      • !help 'plugin_command' for detailed information
      • !usage 'plugin_command' for the usage
      • DONT NEED any Modifications on the Client Side
      • Have Multiple StarMade Servers running if you want
      • Wrapper Commands like: start, stop, pause, resume, restart, update, various plugin commands
      • Run every StarMade Command from the Console if you want
      • Logging System (not all Important things write logs yet)
    • Plugin System:
      • Very easy installation of new Plugins
      • Files with multiple Plugins inside are fully supported
      • Choose Easily which Plugin you want to activate or not, also you can load unload them later
      • A ! based Command System
      • Multiple Events are supported like: PlayerKilled, SectorChange or FactionJoin
      • All important Commands with a return Value are supported, for example FactionMembers or PlayerInfo
      • And still if not directly implemented you can use any StarMade Command which has Console
        compatibility
      • A Build in Custom Event System(The Wrapper triggers and a random event method from a plugin get called)
      • The Logging System Is accesable from the Plugins for an uniform logging
      • Support for Voting Based Rewards
      • Property/Config Support for Plugins
    • Server/Wrapper:
      • Use the Chat in the Wrapper(not that difficult just not implemented yet)
      • Pretty Up the whole Wrapper, maybe a GUI Version -> Create a Remote Tool for the Wrapper
      • Support for Timebased Plugin Actions (Next Update)
      • Add Database Support
      • Create a Server Mod for bridging StarMade and The Wrapper and general Distort Support
      • Expand the AutoUpdater for Extended File Support(BlockType.Properties for example)
      • Automatic Backups
      • Custom Wrapper Commands (for Plugins)
    • Plugin System:
      • A Questing System?
    • On Windows:
      • Make Sure you have a compatible .NET Version installed
    • On Linux or macOS:
      • Goto Download - Stable | Mono
      • Choose your Distribution
      • Follow the installation Guide and install the mono complete Package to make sure everything runs right
    • Extract the Content of the Wrapper to an empty Folder
    • Open The wrapper.properties and adjust your preffered Settings
    Code:
    HourToRestart at which Hour the wrapper should restart, example 3 is at 3 o'clock
    DailyAutoRestart if true the Server will daily restart at given time
    SMAutoUpdate if set true it will automatically check if there is an StarMade update available and install it
    PathToStarNet The Path where you have StarNet saved, i put it in the zip so dont change this
    PathToSm The relative StarMade Path if you dont know how to use, just put your StarMade Folder(where the starmade.jar is inside) in the folder where the wrapper is, and eventually rename, OR you dont make anything and the Wrapper will automatically install StarMade
    DefaultLoadPlugins if true all plugins which are inside the Plugin Path will be loaded
    PluginPath The Path  where the Wrapper searches the Plugins
    Pass Your SuperAdminPassword
    Port The Port where the Server will run, leave it at 4242 unless you want to run multiple Servers
    RamMin The Minimum Ram for StarMade
    RamMax The Maximum Ram for StarMade
    StopCountdown The Countdown for stopping the Server
    PlayerPerCustomEvent The needed Players for Triggering one more Custom Event
    EventLogInConsole The SM-Events will be logged in Console if true(for example PlayerKilled PlayerJoin)
    LogPath The Path where the Wrapper/Plugin Logs will be saved
    PluginDataSavePath The Path for Custom Data saved by Plugins
    CustomEventSleep The time how often a Custom event can Occur in millisecond
    Debug Only Logs actually, if true Debug Informations will be logged
    VoteLink The Link of your Server on starmade-servers.com
    VoteApiKey your Server Api Key of starmade-servers.com
    UseVoteSystem set this true, if you have a Plugin which uses the Vote System
    If you dont have an StarMade Installation linked in the Prroperties(default is ./StarMade) the Wrapper will automatically download the latest if you have set SMAutoUpdate to true, otherwise you get asked on Wrapper Start
    • Run The Wrapper Executeable, on Linux Server use the mono command to start the Wrapper
    • PLS Dont use older StarMade Version or only with caution, they are not supported
    • On Wrapper Start it checks if the StarMade.jar exists to check the game availability and the version, the wrapper can update or install StarMade, Check the properties file
    • At Runtime you can use various commands by just typing it into the console, also you can use StarMade Commands like ingame with "/status" for example, run the help command to see a list of all available commands
    • IMPORTANT: ALWAYS CLOSE THE WRAPPER WITH THE STOP COMMAND, OTHERWISE ITS POSSIBLE THAT THE STARMADE SERVER KEEPS RUNNING, ALSO THE PLUGINS GET A STOPPED METHOD CALLED, SO THEY HAVE A CHANCE TO SAVE DATA OR ELSE
    • Put the Plugin.dll inside your Plugins Folder
    • Check your wrapper.properties and set DefaultLoadPlugins=true, or create a file named pluginload.properties and put there the PluginID inside =true
    • You can use different wrapper commands to manage the Plugins, also See a List of all available Plugins with the "plugins_available" command, run help to see all
    But The most Important:
    • Cooming soon xD
    • No i give you a short instruction now but a more detailed one and a few examples are following
    • In Visual Studio:
    • Create a new ClassLibrary
    • Add Reference to the SMWrapperLib.dll
    • Your Main Class Have to implement the IPlugin Interface
    • In the load and unload methods you put your registration stuff
    • Custom Commands:
      • Create a new Class which implements the ICommand Interface
      • The Wrapper gives you the informations about the sender and the args
      • The Execute Method will be called if someone use your command
      • Register The Command(Example is at the end of this spoiler
    • StarMade Events:
      • Create a Method with the Parameters "SMEventType" and "SMArgs"
      • The SMEventType Contains a single String
      • The SMArgs a Dictionary<string,string>
      • The Keys and all Events are saved in the Enum ConsoleManager.EventTypes
      • Register this Method like any other C# Evemt
    But now a very short Example
    C#:
    using SMWrapperLib;
    
    class MyPlugin : IPlugin
    {
    //i "forgot" the common informations like name id...
    public bool isLoaded { get => false; private set => isLoaded = value; }
    ICommand Command = new MyCommand(); //intantiate a Object from your command class which implements ICommand
    public void Load()
    {
         SMWrapperLib.ConsoleManager.OnSMEventOccured += new ConsoleManager.SMEventHandler(Event)
         ObjectHandler.GetCommandHandler.AddCommand(Command);
    
         loaded=true
    }
    public void OnStarMadeEvent(SmEventType, SMArgs)
    {
    //Do something here
    }
    }
    Compare to the Github Project to see all Classes Methods and their return values. Also they are also up to date there
    • IPlugin
    • ICommand
    • IEvent
    • CommandHandler(Access with ObjectHandler.GetCommandHandler)
      • AddCommand(ICommand)
      • RemoveCommand(ICommand)
    • CustomEventHandler(Acces with bjectHandler.GetEventHandler)
      • AddCustomEvent(IEvent)
      • RemoveCustomEvent(IEvent)
    • ConsoleManager(For StarMade Events)
      • delegate void SMEventHandler(SMEventType,SMArgs)
      • event OnCMEventOccured
      • enum EventTypes
      • class SMArgs : EventArgs(Contains Dictionary<string,string>)
      • class SMEventType : EventArgs(Contains String)
    • StarMadeCommands (the most are formatted to dictionaries or lists)
      • Status
      • SectorInfo(x,y,z)
      • Whitelisted(type) //List of all whitelisted by type: name ip account
      • Banned(type) //List of all banned by type: name ip account
      • ServerAdmins
      • FactionMembers(FactionID)
      • FactionPointsGet(FactionID)
      • Faction_List
      • Player_Info(Player)
      • Player_List
      • Command(String[] Args) // put the command into the folling style: {"/give","Alendon","XXXX","2"}
      • List<String> Command // same args returns the output of starnet
    • FactionCommands:
      • Actually Empty
    • PlayerCommands:
      • int? GetPlayerFactionID(player) //return Faction ID, null if player has no faction
    • ServerCommands:
      • StopServer(countdown)
      • ServerBroadcast(message)
      • PlayerMessage(player, message)
    • Logger
      • LogEntry(string logMessage, LogType logType, LogLevel logLevel, IPlugin plugin = null) //Log what you want, set your plugin otherwise it gets into an general unidentified log file
      • enum LogLevel
      • enum LogType
    • PluginCommands // I Know bad name xD
      • SaveString(string toSave, string FileName, IPlugin, string subfolder = null, WriteMode)
      • string Load String(string FileName, IPlugin, string subfolder = null)
      • SaveStringArray(string toSave, string FileName, IPlugin, string subfolder = null, WriteMode)
      • string[] LoadStringArray(string FileName, IPlugin, string subfolder = null)
    • PropManager
      • string GetProp(string field, string defaultProp = null, IPlugin plugin = null) // if plugin = null, it will be written in the wrapper.properties file
      • WriteProp(string field, string value, IPlugin plugin = null)
    • Vote
      • event OnVoteReceived

    The Download Link: https://starmadedock.net/content/dpdds-starmade-wrapper-0-9.7681/
    GitHub: Alendon1/DPDDs-StarMade-Wrapper

    If you want to see the Wrapper in Action our Server runs on them, the links to the server threads:
    LetsKautsch: https://starmadedock.net/threads/lets-kautsch-e-v-fair-play-server.30958/

    Also you can just join our Discord Server if you directly interested: discord.gg/kFftHUK
    Or add me Directly: Alendon#1984
     
    Last edited:

    Alendon

    Programmer
    Joined
    Apr 13, 2016
    Messages
    32
    Reaction score
    19
    Little Update:

    The Wrapper is now providing all needed core mechanics, and the plugin system is working now, it isnt in state for public using, cause of not ready documentations and a few missing commands for easy use and setup. If you want to access it anyways you can contact me and i give you a short instruction for use
     
    • Like
    Reactions: JumpSuit

    Alendon

    Programmer
    Joined
    Apr 13, 2016
    Messages
    32
    Reaction score
    19
    Little Comment: I tried to run the Wrapper on Linux right now, and it works with the tool named mono, check the supported Linux distributions on their Download Page.
     

    Alendon

    Programmer
    Joined
    Apr 13, 2016
    Messages
    32
    Reaction score
    19
    Released the first Public Version, if you have questions or suggestions pls write it
     

    Alendon

    Programmer
    Joined
    Apr 13, 2016
    Messages
    32
    Reaction score
    19
    Little Update:
    Bug Fixing, Wrapper Commands should now work right
    Started at creating Custom Event Support
     

    Alendon

    Programmer
    Joined
    Apr 13, 2016
    Messages
    32
    Reaction score
    19
    Custom Event System is Ready, not fully tested
    Logging System added, access per
    C#:
    SMWrapperLib.Logger.LogEntry(logMessage, LogType, LogLevel, Plugin);
    Fixing few little bugs
     

    Alendon

    Programmer
    Joined
    Apr 13, 2016
    Messages
    32
    Reaction score
    19
    Little Extension of the PluginSystem, with a BeforeServerStart and AfterServerStart Method

    And Fixing few Bugs
     
    Joined
    Jun 27, 2013
    Messages
    896
    Reaction score
    166
    Interesting, especially the asteroid removal plugin.

    Any chance to see the source?
    I'm always a bit reluctant to run arbitrary executables from the Interwebs that may or may not do what they pretend to... not saying yours is doing anything nefarious, but "The better part of valour is discretion" ;)
     

    Alendon

    Programmer
    Joined
    Apr 13, 2016
    Messages
    32
    Reaction score
    19
    Yes its one of my planned things in the very soon future, its just a bit work for preparation and automation. Its the first time for me a project like this
    [doublepost=1546185269,1546182050][/doublepost]I Published the Project on GitHub, its not organized yet or fully documented

    The Github Link: Alendon1/DPDDs-StarMade-Wrapper
     
    • Like
    Reactions: Tsnonak and Valck

    Alendon

    Programmer
    Joined
    Apr 13, 2016
    Messages
    32
    Reaction score
    19
    Added Vote System to the Wrapper, Actually its grant no rewards.
    You Can Access is by register the
    C#:
    SMWrapperLib.Vote.onVoteReceived
    Event, it Contains the Player who voted.
     
    • Like
    Reactions: Valck and Tsnonak

    Alendon

    Programmer
    Joined
    Apr 13, 2016
    Messages
    32
    Reaction score
    19
    Updatet Thread, Following Changes:
    • Moved Custom Event System Planned => Implemented
    • Added The Logging System to Implemented Features
    • Added Timebased Plugin Actions to Planned Features
    • Added Vote Support to Implemented Features
    • Added Property/Config Support for Plugins to Implemented Features
    • Updated List of Important Classes and Methods
    • Updated Config List in How To Install
     

    Alendon

    Programmer
    Joined
    Apr 13, 2016
    Messages
    32
    Reaction score
    19
    Update:
    Bug for incompatibility with Linux better said mono, should be fixed now, if you have still problems or crashes, try to pull the code from GitHub and compile it on your own

    Also added more automated Logs
     

    Alendon

    Programmer
    Joined
    Apr 13, 2016
    Messages
    32
    Reaction score
    19
    Go To Version 1.0
    Added the TimeBasedAction Support, a easy possibility for you to execute specific methods every x minutes
    Edit: Access with ObjectHandler, And only supported at initial wrapper load
    Fixed a Problem that the AutoUpdater doesnt get called at Daily Restart
    Fixed a Bug that the auto Restart on StarMade crash doesnt work right
     
    Last edited:

    Alendon

    Programmer
    Joined
    Apr 13, 2016
    Messages
    32
    Reaction score
    19
    Update 1.0.1:
    Rewritten the Property System, no changes from outside, also "Kajability Tools.dll" no longer Required
    Extended the TimeBasedAction.Class you can now add and remove Jobs dynamically at runtime

    Future Plans:
    Design the Questing Mechanic
    Think about a Discord Bot integrated in the Wrapper

    Tell your thoughts ;)
     

    Alendon

    Programmer
    Joined
    Apr 13, 2016
    Messages
    32
    Reaction score
    19
    "Little" Update about actual Progress and Future Plans and Developement:

    The Planned Time Based Actions are fully implemented yet and provide Time Based Actions based on minutly intervalls.

    The Plans for making a Gui Version of The Wrapper are discarded, instead i want to create a remote Tool.

    As the File Reading Writing... makes larger problems that excepted with the .net framework, i change the common data save system to a data base, the old system still remains, but dont get updates. At this State the System needs a pre installed mySql Database, there are future plans to automate this process and creating own database files beside having a extra db server.

    For the common fluidity of the wrapper i going to update the auto updater, and add support for updating files which get overwritten each time (example -> blocktype.properties), also i add automatic backups

    As the development of the Distort Modding Engine makes large steps forward, their will be a support for this, this means an integrated mod launcher and a SMWrapperMod which works as a Bridge between StarMade and The Wrapper, this will replace the need of using log files and console output and StarNet, also this Mod will act as a Library/Core Mod
     
    • Like
    Reactions: Tsnonak