diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index bdb0cab..0000000 --- a/.gitattributes +++ /dev/null @@ -1,17 +0,0 @@ -# Auto detect text files and perform LF normalization -* text=auto - -# Custom for Visual Studio -*.cs diff=csharp - -# Standard to msysgit -*.doc diff=astextplain -*.DOC diff=astextplain -*.docx diff=astextplain -*.DOCX diff=astextplain -*.dot diff=astextplain -*.DOT diff=astextplain -*.pdf diff=astextplain -*.PDF diff=astextplain -*.rtf diff=astextplain -*.RTF diff=astextplain diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 96374c4..0000000 --- a/.gitignore +++ /dev/null @@ -1,43 +0,0 @@ -# Windows image file caches -Thumbs.db -ehthumbs.db - -# Folder config file -Desktop.ini - -# Recycle Bin used on file shares -$RECYCLE.BIN/ - -# Windows Installer files -*.cab -*.msi -*.msm -*.msp - -# Windows shortcuts -*.lnk - -# ========================= -# Operating System Files -# ========================= - -# OSX -# ========================= - -.DS_Store -.AppleDouble -.LSOverride - -# Thumbnails -._* - -# Files that might appear on external disk -.Spotlight-V100 -.Trashes - -# Directories potentially created on remote AFP share -.AppleDB -.AppleDesktop -Network Trash Folder -Temporary Items -.apdisk diff --git a/Dynmap.cs b/Dynmap.cs deleted file mode 100644 index 2c2a929..0000000 --- a/Dynmap.cs +++ /dev/null @@ -1,266 +0,0 @@ -using Rocket.API; -using Rocket.API.Collections; -using Rocket.Core.Logging; -using Rocket.Core.Plugins; -using Rocket.Unturned; -using Rocket.Unturned.Chat; -using Rocket.Unturned.Player; -using SDG.Unturned; -using Steamworks; -using System; -using System.Collections.Generic; -using System.IO; -using System.Net; -using System.Security.Cryptography; -using System.Text; -using System.Timers; -using UnityEngine; - -namespace dynmap.core -{ - public class DynmapConfiguration : IRocketPluginConfiguration - { - //Konfigurační soubor - public string PrivateKey; - public int syncInterval; - public string WebCoreAddress; - - public void LoadDefaults() - { - PrivateKey = "MySecretPrivateKey"; - syncInterval = 5000; - WebCoreAddress = "http://localhost"; - } - } - - public class Dynmap : RocketPlugin - { - //Definice proměnných - public static Dynmap Instance; - public List Nicks = new List(); - public Timer myTimer; - public string directory = Directory.GetCurrentDirectory(); - public string[] maps; - public string sendMaps; - public string data = string.Empty; - public string url = string.Empty; - public string encoded = string.Empty; - public string output = string.Empty; - public string map = string.Empty; - public string[] uploadMaps; - public string PrivateKey; - public string postData; - public bool firstrun = true; - public bool shutdown = false; - public string characterName; - public int rotation; - public string playerStatus; - - - protected override void Load() - { - //Načtení privátního klíče a složky Maps - PrivateKey = Configuration.Instance.PrivateKey; - maps = Directory.GetDirectories(directory + @"/../../../Maps"); - - - //Vypsání map na serveru - foreach (string splitMap in maps) - { - var map = splitMap.Split('\\'); - int length = map.Length; - sendMaps += map[length - 1] + ";"; - } - - //Odeslání map serveru do PHP skriptu - var mapUrl = Configuration.Instance.WebCoreAddress + "/dynmap-core.php?user=server&maps=" + Uri.EscapeDataString(sendMaps); - string postData = "&privatekey=" + PrivateKey; - var post = Encoding.ASCII.GetBytes(postData); - - HttpWebRequest request = (HttpWebRequest)WebRequest.Create(mapUrl); - request.Method = "POST"; - request.ContentType = "application/x-www-form-urlencoded"; - request.ContentLength = post.Length; - using (var stream = request.GetRequestStream()) - { - stream.Write(post, 0, post.Length); - } - - HttpWebResponse response = (HttpWebResponse)request.GetResponse(); - using (Stream stream = response.GetResponseStream()) - { - StreamReader reader = new StreamReader(stream, Encoding.UTF8); - output = reader.ReadToEnd(); - } - - //Deaktivuje plugin, pokud se PrivateKey neshoduje - - if(output == "Error.PrivateKeyNotMatch") - { - Logger.LogError("Priavte keys in dynmap-config.php and in Dynmap.configuration.xml doesn't match!"); - Logger.LogError("Unloading plugin!"); - return; - } - - //Příjem názvů map, které se ještě nenacházejí na serveru - var sentMessage = false; - - uploadMaps = output.Split(';'); - for (var o = 0; o < uploadMaps.Length; o++) - { - if (sentMessage == false) { Logger.LogWarning("Uploading map files to the server! This may take some time!"); sentMessage = true; }; - if (uploadMaps[o] != string.Empty) - { - //Generování TransferID - - RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider(); - byte[] rndNumber = new byte[20]; - rng.GetBytes(rndNumber); - string TransferID = Convert.ToBase64String(rndNumber); - - //TransferID - TransferID = TransferID.Remove(TransferID.Length - 1); - - - //Odeslání TransferID na server - url = Configuration.Instance.WebCoreAddress + "/dynmap-core.php?user=server"; - string TransferIDdata = "TransferID=" + Uri.EscapeDataString(TransferID) + "&privatekey=" + PrivateKey; - var postTransferID = Encoding.ASCII.GetBytes(TransferIDdata); - - CookieContainer cookies = new CookieContainer(); - HttpWebRequest requestTransferID = (HttpWebRequest)WebRequest.Create(url); - - requestTransferID.Method = "POST"; - requestTransferID.ContentType = "application/x-www-form-urlencoded"; - requestTransferID.ContentLength = TransferIDdata.Length; - requestTransferID.CookieContainer = cookies; - using (var stream = requestTransferID.GetRequestStream()) - { - stream.Write(postTransferID, 0, postTransferID.Length); - } - - HttpWebResponse responseTransferID = (HttpWebResponse)requestTransferID.GetResponse(); - using (Stream stream = responseTransferID.GetResponseStream()) - { - StreamReader reader = new StreamReader(stream, Encoding.UTF8); - output = reader.ReadToEnd(); - } - - //Nahrání souborů map na server - System.Net.WebClient Client = new System.Net.WebClient (); - Client.Headers.Add("Content-Type", "binary/octet-stream"); - byte[] result = Client.UploadFile(Configuration.Instance.WebCoreAddress + "/dynmap-core.php?user=server&do=uploadfile&TransferID=" + Uri.EscapeDataString(TransferID) + "&mapname=" + uploadMaps[o], "POST", directory + @"/../../../Maps/" + uploadMaps[o] + @"/Map.png"); - String s = System.Text.Encoding.UTF8.GetString (result,0,result.Length); - - if (s == "Error.UploadDone") - { - Logger.LogWarning("Uploaded " + uploadMaps[o]); - } - else if (s == "1Error.UploadFailed") - { - Logger.LogError("Uploading " + uploadMaps[o] + " failed because the uploaded file exceeds the upload_max_filesize directive in php.ini."); - Logger.LogError("See http://php.net/manual/en/ini.core.php#ini.upload-max-filesize for further information!"); - } - else - { - Logger.LogError("Uploading " + uploadMaps[o] + " failed!"); - } - } - if (o == uploadMaps.Length - 1) { Logger.LogWarning("Uploading done!");}; - - } - - //Časovač odesílající data o pozici na server - myTimer = new System.Timers.Timer(); - myTimer.Elapsed += new ElapsedEventHandler(callFunc); - myTimer.Interval = Configuration.Instance.syncInterval; - myTimer.Enabled = true; - - //Přidání hráčů do listu při načtení pluginu - int f = 0; - foreach (SDG.Unturned.SteamPlayer plr in SDG.Unturned.Provider.Players) - { - UnturnedPlayer unturnedPlayer = UnturnedPlayer.FromSteamPlayer(plr); - Nicks.Add(unturnedPlayer.CSteamID); - f++; - } - - //Přidání hráčů do listu při připojení na server - U.Events.OnPlayerConnected += (UnturnedPlayer player) => - { - Nicks.Add(player.CSteamID); - }; - //Odebrání hráčů z listu při odpojení ze serveru - U.Events.OnPlayerDisconnected += (UnturnedPlayer player) => - { - Nicks.Remove(player.CSteamID); - }; - U.Events.OnShutdown += () => - { - shutdown = true; - ShowCords(); - }; - } - - //Zjištění souřadnic - private void callFunc(object sender, EventArgs e) - { - ShowCords(); - } - - private void ShowCords() - { - int count = Nicks.Count; - data = string.Empty; - url = string.Empty; - encoded = string.Empty; - - //Pro každého hráče zjistí jméno, CSteamID a pozici - for (int i = 1; i <= count; i++) - { - UnturnedPlayer player = UnturnedPlayer.FromCSteamID(Nicks[i - 1]); - characterName = player.CharacterName.Replace(";", ";").Replace("[", "[").Replace("]", "]").Replace("=", "="); - rotation = Convert.ToInt32(player.Rotation); - if (player.IsAdmin == true) { playerStatus = "admin"; } else if (player.IsPro == true) { playerStatus = "pro"; } else { playerStatus = "player"; } - UnturnedChat.Say(player, player.Position + "=Position"); - if (player.Features.VanishMode == false) { data = data + "[Charactername=" + characterName + ";CSteamID=" + player.CSteamID + ";Position=" + player.Position + ";Rotation=" + rotation + ";PlayerStatus=" + playerStatus + "]"; }; - } - - //Odešle data na server - if (data != string.Empty || firstrun == true) - { - url = Configuration.Instance.WebCoreAddress + "/dynmap-core.php?user=server"; - postData = "map=" + SDG.Unturned.Provider.map + "&data=" + Uri.EscapeDataString(data) + "&privatekey=" + PrivateKey; - if (shutdown == true) { postData = "map=" + SDG.Unturned.Provider.map + "&privatekey=" + PrivateKey; }; - var post = Encoding.ASCII.GetBytes(postData); - - HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); - - request.Method = "POST"; - request.ContentType = "application/x-www-form-urlencoded"; - request.ContentLength = post.Length; - using (var stream = request.GetRequestStream()) - { - stream.Write(post, 0, post.Length); - } - - HttpWebResponse response = (HttpWebResponse)request.GetResponse(); - using (Stream stream = response.GetResponseStream()) - { - StreamReader reader = new StreamReader(stream, Encoding.UTF8); - output = reader.ReadToEnd(); - } - - //Deaktivuje plugin, pokud se PrivateKey neshoduje - if (output == "Error.PrivateKeyNotMatch") - { - Logger.LogError("Priavte keys in dynmap-config.php and in Dynmap.configuration.xml doesn't match!"); - Logger.LogError("Unloading plugin!"); - myTimer.Enabled = false; - } - - if (data != string.Empty) { firstrun = true; } else { firstrun = false; }; - } - } - } -} \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..7c8c9bd --- /dev/null +++ b/README.md @@ -0,0 +1,11 @@ +# Unturned Dynmap + +The project is divied in 2 branch: +* [Windows](https://github.com/AnthoDingo/DynmapSource/tree/Windows) +* [Linux](https://github.com/AnthoDingo/DynmapSource/tree/Linux) +* [Web](https://github.com/AnthoDingo/DynmapSource/tree/Web) + + +Windows and Linux are source code for Unturned Plugins. + +Web is required to display players on the map. \ No newline at end of file diff --git a/dynmap-config.php b/dynmap-config.php deleted file mode 100644 index 256f10a..0000000 --- a/dynmap-config.php +++ /dev/null @@ -1,8 +0,0 @@ - color of bars on the sides - $serverIP = ""; //IP address of server without port - $serverPort = ""; //Port of the server -?> \ No newline at end of file diff --git a/dynmap-core.php b/dynmap-core.php deleted file mode 100644 index 0b98d88..0000000 --- a/dynmap-core.php +++ /dev/null @@ -1,102 +0,0 @@ - \ No newline at end of file diff --git a/index.php b/index.php deleted file mode 100644 index 429b660..0000000 --- a/index.php +++ /dev/null @@ -1,502 +0,0 @@ - - - - - - <?php echo $DynmapTitle;?> - - - - - - -
-
- -
-
-
-
-
Version: Beta 0.3.6, Developed by LinhyCZ, http://linhy.cz
- ">
 Connect to server!
- - - - - - \ No newline at end of file