Skip to content

Commit

Permalink
New update
Browse files Browse the repository at this point in the history
  • Loading branch information
jianmingyong committed Dec 22, 2015
1 parent 83a8cd5 commit 8b4a80c
Show file tree
Hide file tree
Showing 28 changed files with 472 additions and 392 deletions.
6 changes: 3 additions & 3 deletions Pokemon.3D.Server.Client.GUI/GUI Component/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ private void Main_FormClosing(object sender, FormClosingEventArgs e)
{
if (Core.Setting.MainEntryPoint == Setting.MainEntryPointType.jianmingyong_Server)
{
for (int i = 0; i < Core.Pokemon3DPlayer.Count; i++)
for (int i = 0; i < Core.Player.Count; i++)
{
Core.Pokemon3DPlayer.SentToPlayer(new Package(Package.PackageTypes.ServerClose, ApplicationRestart ? Core.Setting.Token("SERVER_RESTART") : ApplicationUpdate ? Core.Setting.Token("SERVER_UPDATE") : Core.Setting.Token("SERVER_CLOSE"), Core.Pokemon3DPlayer[i].Network.Client));
Core.Player.SentToPlayer(new Package(Package.PackageTypes.ServerClose, ApplicationRestart ? Core.Setting.Token("SERVER_RESTART") : ApplicationUpdate ? Core.Setting.Token("SERVER_UPDATE") : Core.Setting.Token("SERVER_CLOSE"), Core.Player[i].Network.Client));
}
}
else if (Core.Setting.MainEntryPoint == Setting.MainEntryPointType.Rcon)
Expand Down Expand Up @@ -392,7 +392,7 @@ private void Main_CurrentPlayerOnline_MouseDown(object sender, MouseEventArgs e)

private void KickToolStripMenuItem_Click(object sender, EventArgs e)
{
Player Player = Core.Pokemon3DPlayer.GetPlayer(Regex.Match(Main_CurrentPlayerOnline.Items[Main_CurrentPlayerOnline.SelectedIndex].ToString(), @"ID: (\d+) \|.+").Groups[1].Value.ToInt());
Player Player = Core.Player.GetPlayer(Regex.Match(Main_CurrentPlayerOnline.Items[Main_CurrentPlayerOnline.SelectedIndex].ToString(), @"ID: (\d+) \|.+").Groups[1].Value.ToInt());

Main_Command.Text = $"/kick {Player.Name} <Insert Reason here>";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<DocumentationFile>bin\Debug\Pokemon.3D.Server.Client.GUI.XML</DocumentationFile>
<LangVersion>default</LangVersion>
<CheckForOverflowUnderflow>false</CheckForOverflowUnderflow>
<UseVSHostingProcess>true</UseVSHostingProcess>
<UseVSHostingProcess>false</UseVSHostingProcess>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
Expand Down
104 changes: 52 additions & 52 deletions Pokemon.3D.Server.Core/Core.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
using System;
using Pokemon_3D_Server_Core.SCON_Client_Listener.Servers;
using Pokemon_3D_Server_Core.Server_Client_Listener.Commands;
using Pokemon_3D_Server_Core.Server_Client_Listener.Commands.Data.World;
using Pokemon_3D_Server_Core.Server_Client_Listener.Loggers;
using Pokemon_3D_Server_Core.Server_Client_Listener.Settings;
using Pokemon_3D_Server_Core.Shared.jianmingyong;
using Pokemon_3D_Server_Core.Shared.jianmingyong.Modules;
using Pokemon_3D_Server_Core.Server_Client_Listener.Events;

namespace Pokemon_3D_Server_Core
{
Expand All @@ -15,95 +12,93 @@ namespace Pokemon_3D_Server_Core
/// </summary>
public class Core
{
#region Pokemon 3D Listener
/// <summary>
/// Get Pokemon 3D Listener.
/// Get Setting.
/// </summary>
public static Server_Client_Listener.Servers.Listener Pokemon3DListener { get; } = new Server_Client_Listener.Servers.Listener();
public static Setting Setting { get; private set; }

/// <summary>
/// Get Player Collection.
/// Get Logger.
/// </summary>
public static Server_Client_Listener.Players.PlayerCollection Pokemon3DPlayer { get; } = new Server_Client_Listener.Players.PlayerCollection();
public static LoggerCollection Logger { get; private set; }

/// <summary>
/// Get World.
/// Get Updater.
/// </summary>
public static Server_Client_Listener.Worlds.World World { get; } = new Server_Client_Listener.Worlds.World();
#endregion Pokemon 3D Listener
public static Updater Updater { get; private set; }

#region RCON Listener
/// <summary>
/// Get RCON Listener.
/// Get Pokemon 3D Listener.
/// </summary>
public static RCON_Client_Listener.Servers.Listener RCONListener { get; } = new RCON_Client_Listener.Servers.Listener();
public static Server_Client_Listener.Servers.Listener Listener { get; private set; }

/// <summary>
/// Get RCON Player Collection.
/// Get RCON Listener.
/// </summary>
public static RCON_Client_Listener.Players.PlayerCollection RCONPlayer { get; } = new RCON_Client_Listener.Players.PlayerCollection();
public static RCON_Client_Listener.Servers.Listener RCONListener { get; private set; }

/// <summary>
/// Get RCON Upload Queue.
/// Get SCON Listener.
/// </summary>
public static RCON_Client_Listener.Uploader.UploaderQueue RCONUploadQueue { get; } = new RCON_Client_Listener.Uploader.UploaderQueue();
#endregion
public static SCON_Client_Listener.Servers.Listener SCONListener { get; private set; }

#region RCON GUI Listener
/// <summary>
/// Get RCON Listener.
/// Get Comamnd List.
/// </summary>
public static RCON_GUI_Client_Listener.Servers.Listener RCONGUIListener { get; set; }
public static CommandCollection Command { get; private set; }

#region Pokemon 3D Listener
/// <summary>
/// Get RCON GUI Download Queue.
/// Get Player Collection.
/// </summary>
public static RCON_GUI_Client_Listener.Downloader.DownloaderQueue RCONGUIDownloadQueue { get; } = new RCON_GUI_Client_Listener.Downloader.DownloaderQueue();
#endregion RCON GUI Listener
public static Server_Client_Listener.Players.PlayerCollection Player { get; } = new Server_Client_Listener.Players.PlayerCollection();

#region SCON Listener
/// <summary>
/// Get SCON Listener.
/// Get World.
/// </summary>
public static SCONListener SCONListener { get; } = new SCONListener();
#endregion SCON Listener
public static Server_Client_Listener.Worlds.World World { get; } = new Server_Client_Listener.Worlds.World();
#endregion Pokemon 3D Listener

#region RCON Listener
/// <summary>
/// Get Comamnd List.
/// Get RCON Player Collection.
/// </summary>
public static CommandCollection Command { get; } = new CommandCollection();
public static RCON_Client_Listener.Players.PlayerCollection RCONPlayer { get; } = new RCON_Client_Listener.Players.PlayerCollection();

/// <summary>
/// Get Logger.
/// Get RCON Upload Queue.
/// </summary>
public static LoggerCollection Logger { get; } = new LoggerCollection();
public static RCON_Client_Listener.Uploader.UploaderQueue RCONUploadQueue { get; } = new RCON_Client_Listener.Uploader.UploaderQueue();
#endregion

#region RCON GUI Listener
/// <summary>
/// Get Setting.
/// Get RCON Listener.
/// </summary>
public static Setting Setting { get; } = new Setting();
public static RCON_GUI_Client_Listener.Servers.Listener RCONGUIListener { get; set; }

/// <summary>
/// Get Updater.
/// Get RCON GUI Download Queue.
/// </summary>
public static Updater Updater { get; } = new Updater();
public static RCON_GUI_Client_Listener.Downloader.DownloaderQueue RCONGUIDownloadQueue { get; } = new RCON_GUI_Client_Listener.Downloader.DownloaderQueue();
#endregion RCON GUI Listener

/// <summary>
/// Server Main Entry Point - Initialize as many things as possible here.
/// Order is important here, any additional initialization should be place at the bottom.
/// </summary>
/// <param name="Directory">Start Directory.</param>
public static void Start(string Directory)
{
try
{
Setting.ApplicationDirectory = Directory;
// Initialize Setting
Setting = new Setting(Directory);

// Initialize Logger.
Logger = new LoggerCollection();
Logger.Start();

// Initialize Setting.
Setting.Setup();

if (Setting.Load())
{
Setting.Save();
Expand All @@ -115,31 +110,36 @@ public static void Start(string Directory)
return;
}

// Initialize Updater
if (Setting.CheckForUpdate)
{
Updater = new Updater();
Updater.Update();
}

if (Setting.MainEntryPoint == Setting.MainEntryPointType.jianmingyong_Server)
{
// Initialize Listener.
Pokemon3DListener.Start();
Listener = new Server_Client_Listener.Servers.Listener();
Listener.Start();

// Initialize RCONListener.
if (Setting.RCONEnable)
{
RCONListener = new RCON_Client_Listener.Servers.Listener();
RCONListener.Start();
}

// Initialize SCONListener.
if (Setting.SCONEnable)
{
SCONListener = new SCON_Client_Listener.Servers.Listener();
SCONListener.Start();
}
}

// Initialize Updater
if (Setting.CheckForUpdate)
{
Updater.Update();
}

// Initialize Command.
Command = new CommandCollection();
Command.AddCommand();
}
catch (Exception ex)
Expand All @@ -153,10 +153,10 @@ public static void Start(string Directory)
/// </summary>
public static void Dispose()
{
Pokemon3DListener.Dispose();
RCONListener.Dispose();
SCONListener.Dispose();
Logger.Dispose();
if (Listener != null) Listener.Dispose();
if (RCONListener != null) RCONListener.Dispose();
if (SCONListener != null) SCONListener.Dispose();
if (Logger != null) Logger.Dispose();
}
}
}
4 changes: 2 additions & 2 deletions Pokemon.3D.Server.Core/RCON_Client_Listener/Players/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ public Player(Package p, int ID)

Core.Logger.Log($"RCON Player (ID: {ID.ToString()}) have connected.", Logger.LogTypes.Info, p.Client);

for (int i = 0; i < Core.Pokemon3DPlayer.Count; i++)
for (int i = 0; i < Core.Player.Count; i++)
{
Core.RCONPlayer.SentToPlayer(new Package(Package.PackageTypes.AddPlayer, $"{Core.Pokemon3DPlayer[i].ID},{Core.Pokemon3DPlayer[i].ToString()}", p.Client));
Core.RCONPlayer.SentToPlayer(new Package(Package.PackageTypes.AddPlayer, $"{Core.Player[i].ID},{Core.Player[i].ToString()}", p.Client));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using Pokemon_3D_Server_Core.RCON_GUI_Client_Listener.Packages;
using Pokemon_3D_Server_Core.Shared.jianmingyong.Modules;
using System;
using System.Diagnostics;

namespace Pokemon_3D_Server_Core.RCON_GUI_Client_Listener.Downloader
{
Expand Down Expand Up @@ -142,11 +141,11 @@ public DownloadFile(Package p, FileType Type)
}
else if (TotalBytes_L < 1024 * 1024)
{
TotalBytes = Pokemon_3D_Server_Core.Shared.jianmingyong.Modules.Math.Round(TotalBytes_L / 1024, 2).ToString("F2") + " KB";
TotalBytes = Shared.jianmingyong.Modules.Math.Round(TotalBytes_L / 1024, 2).ToString("F2") + " KB";
}
else if (TotalBytes_L < 1024 * 1024 * 1024)
{
TotalBytes = Pokemon_3D_Server_Core.Shared.jianmingyong.Modules.Math.Round(TotalBytes_L / 1024 / 1024,2).ToString("F2") + " MB";
TotalBytes = Shared.jianmingyong.Modules.Math.Round(TotalBytes_L / 1024 / 1024,2).ToString("F2") + " MB";
}

Status = DownloadStatus.Initializing.ToString();
Expand All @@ -162,7 +161,7 @@ public DownloadFile(Package p, FileType Type)
{
Stream = new FileStream(Core.Setting.ApplicationDirectory + "\\Download\\CrashLogs\\" + Name, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite);

if (Stream.Length == TotalBytes_L || Stream.Length - ASCIIEncoding.UTF8.GetByteCount(Environment.NewLine.ToCharArray()) == TotalBytes_L)
if (Stream.Length == TotalBytes_L || Stream.Length - Encoding.UTF8.GetByteCount(Environment.NewLine.ToCharArray()) == TotalBytes_L)
{
Status = DownloadStatus.Skipped.ToString();

Expand Down Expand Up @@ -193,7 +192,7 @@ public DownloadFile(Package p, FileType Type)
{
Stream = new FileStream(Core.Setting.ApplicationDirectory + "\\Download\\Logger\\" + Name, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite);

if (Stream.Length == TotalBytes_L || Stream.Length - ASCIIEncoding.UTF8.GetByteCount(Environment.NewLine.ToCharArray()) == TotalBytes_L)
if (Stream.Length == TotalBytes_L || Stream.Length - Encoding.UTF8.GetByteCount(Environment.NewLine.ToCharArray()) == TotalBytes_L)
{
Status = DownloadStatus.Skipped.ToString();

Expand Down Expand Up @@ -241,7 +240,7 @@ public void HandlePackage(Package p)
Status = DownloadStatus.Completed.ToString();
Speed = "0 B/s";
}
else if (CurrentBytes_L - ASCIIEncoding.UTF8.GetByteCount(Environment.NewLine.ToCharArray()) == TotalBytes_L)
else if (CurrentBytes_L - Encoding.UTF8.GetByteCount(Environment.NewLine.ToCharArray()) == TotalBytes_L)
{
Status = DownloadStatus.Completed.ToString();
Speed = "0 B/s";
Expand Down Expand Up @@ -284,11 +283,11 @@ private void Download(Package p)
}
else if (CurrentBytes_L < 1024 * 1024)
{
CurrentBytes = Pokemon_3D_Server_Core.Shared.jianmingyong.Modules.Math.Round(CurrentBytes_L / 1024, 2).ToString("F2") + " KB";
CurrentBytes = Shared.jianmingyong.Modules.Math.Round(CurrentBytes_L / 1024, 2).ToString("F2") + " KB";
}
else if (CurrentBytes_L < 1024 * 1024 * 1024)
{
CurrentBytes = Pokemon_3D_Server_Core.Shared.jianmingyong.Modules.Math.Round(CurrentBytes_L / 1024 / 1024,2).ToString("F2") + " MB";
CurrentBytes = Shared.jianmingyong.Modules.Math.Round(CurrentBytes_L / 1024 / 1024,2).ToString("F2") + " MB";
}

Writer.WriteLine(p.DataItems[i + 1]);
Expand Down Expand Up @@ -343,11 +342,11 @@ private void GetDownloadSpeed()
}
else if (Speed_L < 1024 * 1024)
{
Speed = Pokemon_3D_Server_Core.Shared.jianmingyong.Modules.Math.Round(Speed_L / 1024, 2).ToString("F2") + " KB/s";
Speed = Shared.jianmingyong.Modules.Math.Round(Speed_L / 1024, 2).ToString("F2") + " KB/s";
}
else if (Speed_L < 1024 * 1024 * 1024)
{
Speed = Pokemon_3D_Server_Core.Shared.jianmingyong.Modules.Math.Round(Speed_L / 1024 / 1024,2).ToString("f2") + " MB/s";
Speed = Shared.jianmingyong.Modules.Math.Round(Speed_L / 1024 / 1024,2).ToString("f2") + " MB/s";
}

sw.Stop();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,17 +97,17 @@ private void HandlePlayerInfoListRequest(PlayerInfoListRequestPacket packet)
}

List<PlayerInfo> Player = new List<PlayerInfo>();
for (int i = 0; i < Core.Pokemon3DPlayer.Count; i++)
for (int i = 0; i < Core.Player.Count; i++)
{
Player.Add(new PlayerInfo()
{
Name = Core.Pokemon3DPlayer[i].Name,
GameJoltID = Core.Pokemon3DPlayer[i].GameJoltID.ToString().ToLong(),
IP = ((IPEndPoint)Core.Pokemon3DPlayer[i].Network.Client.Client.RemoteEndPoint).Address.ToString(),
LevelFile = Core.Pokemon3DPlayer[i].LevelFile,
Position = new Vector3(Core.Pokemon3DPlayer[i].Position_X, Core.Pokemon3DPlayer[i].Position_Y, Core.Pokemon3DPlayer[i].Position_Z),
Name = Core.Player[i].Name,
GameJoltID = Core.Player[i].GameJoltID.ToString().ToLong(),
IP = ((IPEndPoint)Core.Player[i].Network.Client.Client.RemoteEndPoint).Address.ToString(),
LevelFile = Core.Player[i].LevelFile,
Position = new Vector3(Core.Player[i].Position_X, Core.Player[i].Position_Y, Core.Player[i].Position_Z),
Ping = 0,
PlayTime = DateTime.Now - Core.Pokemon3DPlayer[i].Network.LoginStartTime
PlayTime = DateTime.Now - Core.Player[i].Network.LoginStartTime
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public partial class SCONClient
public ITCPClient Client { get; }
ProtobufStream Stream { get; }

private readonly SCONListener _listener;
private readonly Listener _listener;

#if DEBUG
// -- Debug -- //
Expand All @@ -56,7 +56,7 @@ public partial class SCONClient
/// </summary>
/// <param name="client">Client.</param>
/// <param name="sconListener">SCONListener.</param>
public SCONClient(ITCPClient client, SCONListener sconListener)
public SCONClient(ITCPClient client, Listener sconListener)
{
Client = client;
Stream = new ProtobufStream(Client);
Expand Down
Loading

0 comments on commit 8b4a80c

Please sign in to comment.