From 8b4a80c3b5ceab8e83a39830f72167b2b631eb69 Mon Sep 17 00:00:00 2001 From: jianmingyong Date: Wed, 23 Dec 2015 00:16:41 +0800 Subject: [PATCH] New update --- .../GUI Component/Main.cs | 6 +- .../Pokemon.3D.Server.Client.GUI.csproj | 2 +- Pokemon.3D.Server.Core/Core.cs | 104 ++++---- .../RCON_Client_Listener/Players/Player.cs | 4 +- .../Downloader/DownloadFile.cs | 25 +- .../SCON/SCONClient.Packets.cs | 14 +- .../SCON_Client_Listener/SCON/SCONClient.cs | 4 +- .../SCON_Client_Listener/Servers/Listener.cs | 16 +- .../Commands/CommandCollection.cs | 2 +- .../Data/Chat_Channels/ChatChannels_Change.cs | 8 +- .../Commands/Data/Client/Update.cs | 14 +- .../Commands/Data/Kick.cs | 24 +- .../Commands/Data/Operator/Add.cs | 16 +- .../Commands/Data/Operator/Remove.cs | 8 +- .../Commands/Data/PvP/League.cs | 10 +- .../Commands/Data/Say.cs | 4 +- .../Commands/Data/World/Player_World.cs | 2 +- .../Commands/Data/World/World.cs | 2 +- .../Commands/Functions.cs | 8 +- .../Packages/PackageHandler.cs | 228 +++++++++--------- .../Players/Networking.cs | 60 +++-- .../Server_Client_Listener/Players/Player.cs | 32 +-- .../Players/PlayerCollection.cs | 63 ++--- .../Servers/Listener.cs | 13 +- .../Settings/Setting.cs | 20 +- .../Server_Client_Listener/Worlds/World.cs | 6 +- .../Shared/jianmingyong/Modules/Functions.cs | 2 +- .../Shared/jianmingyong/Updater.cs | 167 +++++++++---- 28 files changed, 472 insertions(+), 392 deletions(-) diff --git a/Pokemon.3D.Server.Client.GUI/GUI Component/Main.cs b/Pokemon.3D.Server.Client.GUI/GUI Component/Main.cs index 248e44f..e807ab2 100644 --- a/Pokemon.3D.Server.Client.GUI/GUI Component/Main.cs +++ b/Pokemon.3D.Server.Client.GUI/GUI Component/Main.cs @@ -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) @@ -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} "; } diff --git a/Pokemon.3D.Server.Client.GUI/Pokemon.3D.Server.Client.GUI.csproj b/Pokemon.3D.Server.Client.GUI/Pokemon.3D.Server.Client.GUI.csproj index dd14a96..a915bef 100644 --- a/Pokemon.3D.Server.Client.GUI/Pokemon.3D.Server.Client.GUI.csproj +++ b/Pokemon.3D.Server.Client.GUI/Pokemon.3D.Server.Client.GUI.csproj @@ -27,7 +27,7 @@ bin\Debug\Pokemon.3D.Server.Client.GUI.XML default false - true + false AnyCPU diff --git a/Pokemon.3D.Server.Core/Core.cs b/Pokemon.3D.Server.Core/Core.cs index d283f95..3be682c 100644 --- a/Pokemon.3D.Server.Core/Core.cs +++ b/Pokemon.3D.Server.Core/Core.cs @@ -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 { @@ -15,95 +12,93 @@ namespace Pokemon_3D_Server_Core /// public class Core { - #region Pokemon 3D Listener /// - /// Get Pokemon 3D Listener. + /// Get Setting. /// - public static Server_Client_Listener.Servers.Listener Pokemon3DListener { get; } = new Server_Client_Listener.Servers.Listener(); + public static Setting Setting { get; private set; } /// - /// Get Player Collection. + /// Get Logger. /// - public static Server_Client_Listener.Players.PlayerCollection Pokemon3DPlayer { get; } = new Server_Client_Listener.Players.PlayerCollection(); + public static LoggerCollection Logger { get; private set; } /// - /// Get World. + /// Get Updater. /// - 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 /// - /// Get RCON Listener. + /// Get Pokemon 3D Listener. /// - 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; } /// - /// Get RCON Player Collection. + /// Get RCON Listener. /// - 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; } /// - /// Get RCON Upload Queue. + /// Get SCON Listener. /// - 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 /// - /// Get RCON Listener. + /// Get Comamnd List. /// - public static RCON_GUI_Client_Listener.Servers.Listener RCONGUIListener { get; set; } + public static CommandCollection Command { get; private set; } + #region Pokemon 3D Listener /// - /// Get RCON GUI Download Queue. + /// Get Player Collection. /// - 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 /// - /// Get SCON Listener. + /// Get World. /// - 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 /// - /// Get Comamnd List. + /// Get RCON Player Collection. /// - public static CommandCollection Command { get; } = new CommandCollection(); + public static RCON_Client_Listener.Players.PlayerCollection RCONPlayer { get; } = new RCON_Client_Listener.Players.PlayerCollection(); /// - /// Get Logger. + /// Get RCON Upload Queue. /// - 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 /// - /// Get Setting. + /// Get RCON Listener. /// - public static Setting Setting { get; } = new Setting(); + public static RCON_GUI_Client_Listener.Servers.Listener RCONGUIListener { get; set; } /// - /// Get Updater. + /// Get RCON GUI Download Queue. /// - 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 /// /// Server Main Entry Point - Initialize as many things as possible here. /// Order is important here, any additional initialization should be place at the bottom. /// + /// Start Directory. 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(); @@ -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) @@ -153,10 +153,10 @@ public static void Start(string Directory) /// 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(); } } } \ No newline at end of file diff --git a/Pokemon.3D.Server.Core/RCON_Client_Listener/Players/Player.cs b/Pokemon.3D.Server.Core/RCON_Client_Listener/Players/Player.cs index 25f2505..dc5bde3 100644 --- a/Pokemon.3D.Server.Core/RCON_Client_Listener/Players/Player.cs +++ b/Pokemon.3D.Server.Core/RCON_Client_Listener/Players/Player.cs @@ -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)); } } } diff --git a/Pokemon.3D.Server.Core/RCON_GUI_Client_Listener/Downloader/DownloadFile.cs b/Pokemon.3D.Server.Core/RCON_GUI_Client_Listener/Downloader/DownloadFile.cs index 7cbf4ef..8ec4c4b 100644 --- a/Pokemon.3D.Server.Core/RCON_GUI_Client_Listener/Downloader/DownloadFile.cs +++ b/Pokemon.3D.Server.Core/RCON_GUI_Client_Listener/Downloader/DownloadFile.cs @@ -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 { @@ -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(); @@ -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(); @@ -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(); @@ -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"; @@ -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]); @@ -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(); diff --git a/Pokemon.3D.Server.Core/SCON_Client_Listener/SCON/SCONClient.Packets.cs b/Pokemon.3D.Server.Core/SCON_Client_Listener/SCON/SCONClient.Packets.cs index 8629ff3..f2dc1f6 100644 --- a/Pokemon.3D.Server.Core/SCON_Client_Listener/SCON/SCONClient.Packets.cs +++ b/Pokemon.3D.Server.Core/SCON_Client_Listener/SCON/SCONClient.Packets.cs @@ -97,17 +97,17 @@ private void HandlePlayerInfoListRequest(PlayerInfoListRequestPacket packet) } List Player = new List(); - 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 }); } diff --git a/Pokemon.3D.Server.Core/SCON_Client_Listener/SCON/SCONClient.cs b/Pokemon.3D.Server.Core/SCON_Client_Listener/SCON/SCONClient.cs index 8c29773..b8f690f 100644 --- a/Pokemon.3D.Server.Core/SCON_Client_Listener/SCON/SCONClient.cs +++ b/Pokemon.3D.Server.Core/SCON_Client_Listener/SCON/SCONClient.cs @@ -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 -- // @@ -56,7 +56,7 @@ public partial class SCONClient /// /// Client. /// SCONListener. - public SCONClient(ITCPClient client, SCONListener sconListener) + public SCONClient(ITCPClient client, Listener sconListener) { Client = client; Stream = new ProtobufStream(Client); diff --git a/Pokemon.3D.Server.Core/SCON_Client_Listener/Servers/Listener.cs b/Pokemon.3D.Server.Core/SCON_Client_Listener/Servers/Listener.cs index 32fba62..a9414b8 100644 --- a/Pokemon.3D.Server.Core/SCON_Client_Listener/Servers/Listener.cs +++ b/Pokemon.3D.Server.Core/SCON_Client_Listener/Servers/Listener.cs @@ -13,9 +13,9 @@ namespace Pokemon_3D_Server_Core.SCON_Client_Listener.Servers /// /// Class containing Pokemon 3D Listener /// - public class SCONListener : IDisposable + public class Listener : IDisposable { - private ITCPListener Listener { get; set; } + private ITCPListener TcpListener { get; set; } private bool IsActive { get; set; } = false; @@ -26,7 +26,7 @@ public class SCONListener : IDisposable /// /// New SCON Listener. /// - public SCONListener() + public Listener() { AppDomainWrapper.Instance = new AppDomainWrapperInstance(); TCPListenerWrapper.Instance = new TCPServerWrapperInstance(); @@ -56,8 +56,8 @@ public void Start() UpdateCycle.Start(); ThreadCollection.Add(UpdateCycle); - Listener = TCPListenerWrapper.CreateTCPListener(Core.Setting.SCONPort); - Listener.Start(); + TcpListener = TCPListenerWrapper.CreateTCPListener(Core.Setting.SCONPort); + TcpListener.Start(); IsActive = true; } @@ -75,7 +75,7 @@ public void Dispose() { IsActive = false; - if (Listener != null) Listener.Stop(); + if (TcpListener != null) TcpListener.Stop(); for (int i = 0; i < ThreadCollection.Count; i++) { @@ -110,9 +110,9 @@ private void ThreadStartListening() { try { - if (Listener.AvailableClients) + if (TcpListener.AvailableClients) { - SCONClients.Add(new SCONClient(Listener.AcceptTCPClient(), this)); + SCONClients.Add(new SCONClient(TcpListener.AcceptTCPClient(), this)); Core.Logger.Log("New SCON Player Added.", Logger.LogTypes.Debug); } } diff --git a/Pokemon.3D.Server.Core/Server_Client_Listener/Commands/CommandCollection.cs b/Pokemon.3D.Server.Core/Server_Client_Listener/Commands/CommandCollection.cs index ae0b5b5..b335e6b 100644 --- a/Pokemon.3D.Server.Core/Server_Client_Listener/Commands/CommandCollection.cs +++ b/Pokemon.3D.Server.Core/Server_Client_Listener/Commands/CommandCollection.cs @@ -36,7 +36,7 @@ public void HandleAllCommand(Package p) { for (int i = 0; i < Count; i++) { - this[i].Handle(p, p.Client == null ? null : Core.Pokemon3DPlayer.GetPlayer(p.Client)); + this[i].Handle(p, p.Client == null ? null : Core.Player.GetPlayer(p.Client)); } } } diff --git a/Pokemon.3D.Server.Core/Server_Client_Listener/Commands/Data/Chat_Channels/ChatChannels_Change.cs b/Pokemon.3D.Server.Core/Server_Client_Listener/Commands/Data/Chat_Channels/ChatChannels_Change.cs index 5a9e788..a486b07 100644 --- a/Pokemon.3D.Server.Core/Server_Client_Listener/Commands/Data/Chat_Channels/ChatChannels_Change.cs +++ b/Pokemon.3D.Server.Core/Server_Client_Listener/Commands/Data/Chat_Channels/ChatChannels_Change.cs @@ -76,14 +76,14 @@ public void Handle(Package p, Player Player = null) if (Core.Setting.AllowChatChannels) { - for (int i = 0; i < Core.Pokemon3DPlayer.Count; i++) + for (int i = 0; i < Core.Player.Count; i++) { - if (Core.Pokemon3DPlayer[i].CC_CurrentChatChannel == Player.CC_CurrentChatChannel && Core.Pokemon3DPlayer[i] != Player) + if (Core.Player[i].CC_CurrentChatChannel == Player.CC_CurrentChatChannel && Core.Player[i] != Player) { - Core.Pokemon3DPlayer.SentToPlayer(new Package(Package.PackageTypes.ChatMessage, Player.isGameJoltPlayer ? + Core.Player.SentToPlayer(new Package(Package.PackageTypes.ChatMessage, Player.isGameJoltPlayer ? Core.Setting.Token("SERVER_GAMEJOLT", Player.Name, Player.GameJoltID.ToString(), "have joined the current chat channel you are in.") : Core.Setting.Token("SERVER_COMMANDNOGAMEJOLT", Player.Name, "have joined the current chat channel you are in.") - , Core.Pokemon3DPlayer[i].Network.Client)); + , Core.Player[i].Network.Client)); } } diff --git a/Pokemon.3D.Server.Core/Server_Client_Listener/Commands/Data/Client/Update.cs b/Pokemon.3D.Server.Core/Server_Client_Listener/Commands/Data/Client/Update.cs index c61ff90..3761237 100644 --- a/Pokemon.3D.Server.Core/Server_Client_Listener/Commands/Data/Client/Update.cs +++ b/Pokemon.3D.Server.Core/Server_Client_Listener/Commands/Data/Client/Update.cs @@ -1,7 +1,7 @@ -using Pokemon_3D_Server_Core.Server_Client_Listener.Events; -using Pokemon_3D_Server_Core.Server_Client_Listener.Interface; +using Pokemon_3D_Server_Core.Server_Client_Listener.Interface; using Pokemon_3D_Server_Core.Server_Client_Listener.Packages; using Pokemon_3D_Server_Core.Server_Client_Listener.Players; +using Pokemon_3D_Server_Core.Shared.jianmingyong; namespace Pokemon_3D_Server_Core.Server_Client_Listener.Commands.Data.Client { @@ -38,11 +38,17 @@ public void Handle(Package p, Player Player = null) { if (Player != null && this.MatchRequiredPermission(Player)) { - Core.Updater.Update(); + using (Updater Updater = new Updater()) + { + Updater.Update(); + } } else if (Player == null) { - Core.Updater.Update(); + using (Updater Updater = new Updater()) + { + Updater.Update(); + } } } #endregion /Update diff --git a/Pokemon.3D.Server.Core/Server_Client_Listener/Commands/Data/Kick.cs b/Pokemon.3D.Server.Core/Server_Client_Listener/Commands/Data/Kick.cs index 0519435..dfdc086 100644 --- a/Pokemon.3D.Server.Core/Server_Client_Listener/Commands/Data/Kick.cs +++ b/Pokemon.3D.Server.Core/Server_Client_Listener/Commands/Data/Kick.cs @@ -42,7 +42,7 @@ public void Handle(Package p, Player Player = null) if (Player != null && this.MatchRequiredPermission(Player)) { - if (!Core.Pokemon3DPlayer.HasPlayer(Group[0])) + if (!Core.Player.HasPlayer(Group[0])) { Player.CommandFeedback(Core.Setting.Token("SERVER_PLAYERNOTEXIST"), null); return; @@ -54,10 +54,10 @@ public void Handle(Package p, Player Player = null) } else { - Player KickPlayer = Core.Pokemon3DPlayer.GetPlayer(Group[0]); + Player KickPlayer = Core.Player.GetPlayer(Group[0]); string KickPlayerName = KickPlayer.isGameJoltPlayer ? $"{KickPlayer.Name} ({KickPlayer.GameJoltID.ToString()})" : KickPlayer.Name; - Core.Pokemon3DPlayer.Remove(KickPlayer.ID, Core.Setting.Token("SERVER_KICKED", Group[1])); + Core.Player.Remove(KickPlayer.ID, Core.Setting.Token("SERVER_KICKED", Group[1])); Player.CommandFeedback("You have successfully kicked " + KickPlayerName, $"have kick {KickPlayerName} with the following reason: {Group[1]}"); return; @@ -65,17 +65,17 @@ public void Handle(Package p, Player Player = null) } else if (Player == null) { - if (!Core.Pokemon3DPlayer.HasPlayer(Group[0])) + if (!Core.Player.HasPlayer(Group[0])) { Core.Logger.Log(Core.Setting.Token("SERVER_PLAYERNOTEXIST"), Logger.LogTypes.Info); return; } else { - Player KickPlayer = Core.Pokemon3DPlayer.GetPlayer(Group[0]); + Player KickPlayer = Core.Player.GetPlayer(Group[0]); string KickPlayerName = KickPlayer.isGameJoltPlayer ? $"{KickPlayer.Name} ({KickPlayer.GameJoltID.ToString()})" : KickPlayer.Name; - Core.Pokemon3DPlayer.Remove(KickPlayer.ID, Core.Setting.Token("SERVER_KICKED", Group[1])); + Core.Player.Remove(KickPlayer.ID, Core.Setting.Token("SERVER_KICKED", Group[1])); Core.Logger.Log("You have successfully kicked " + KickPlayerName, Logger.LogTypes.Info); return; @@ -91,7 +91,7 @@ public void Handle(Package p, Player Player = null) if (Player != null && this.MatchRequiredPermission(Player)) { - if (!Core.Pokemon3DPlayer.HasPlayer(Group[0])) + if (!Core.Player.HasPlayer(Group[0])) { Player.CommandFeedback(Core.Setting.Token("SERVER_PLAYERNOTEXIST"), null); } @@ -101,26 +101,26 @@ public void Handle(Package p, Player Player = null) } else { - Player KickPlayer = Core.Pokemon3DPlayer.GetPlayer(Group[0]); + Player KickPlayer = Core.Player.GetPlayer(Group[0]); string KickPlayerName = KickPlayer.isGameJoltPlayer ? string.Format("{0} ({1})", KickPlayer.Name, KickPlayer.GameJoltID.ToString()) : KickPlayer.Name; - Core.Pokemon3DPlayer.Remove(KickPlayer.ID, Core.Setting.Token("SERVER_KICKED", "No reason.")); + Core.Player.Remove(KickPlayer.ID, Core.Setting.Token("SERVER_KICKED", "No reason.")); Player.CommandFeedback("You have successfully kicked " + KickPlayerName, string.Format("have kick {0} with the following reason: No reason.", KickPlayerName)); } } else if (Player == null) { - if (!Core.Pokemon3DPlayer.HasPlayer(Group[0])) + if (!Core.Player.HasPlayer(Group[0])) { Core.Logger.Log(Core.Setting.Token("SERVER_PLAYERNOTEXIST"), Logger.LogTypes.Info); } else { - Player KickPlayer = Core.Pokemon3DPlayer.GetPlayer(Group[0]); + Player KickPlayer = Core.Player.GetPlayer(Group[0]); string KickPlayerName = KickPlayer.isGameJoltPlayer ? string.Format("{0} ({1})", KickPlayer.Name, KickPlayer.GameJoltID.ToString()) : KickPlayer.Name; - Core.Pokemon3DPlayer.Remove(KickPlayer.ID, Core.Setting.Token("SERVER_KICKED", "No reason.")); + Core.Player.Remove(KickPlayer.ID, Core.Setting.Token("SERVER_KICKED", "No reason.")); Core.Logger.Log("You have successfully kicked " + KickPlayerName, Logger.LogTypes.Info); } diff --git a/Pokemon.3D.Server.Core/Server_Client_Listener/Commands/Data/Operator/Add.cs b/Pokemon.3D.Server.Core/Server_Client_Listener/Commands/Data/Operator/Add.cs index 7b14600..a4c98e7 100644 --- a/Pokemon.3D.Server.Core/Server_Client_Listener/Commands/Data/Operator/Add.cs +++ b/Pokemon.3D.Server.Core/Server_Client_Listener/Commands/Data/Operator/Add.cs @@ -43,13 +43,13 @@ public void Handle(Package p, Player Player = null) if (Player != null && this.MatchRequiredPermission(Player)) { - if (!Core.Pokemon3DPlayer.HasPlayer(Group[0])) + if (!Core.Player.HasPlayer(Group[0])) { Player.CommandFeedback(Core.Setting.Token("SERVER_PLAYERNOTEXIST"), null); } else { - Player Players = Core.Pokemon3DPlayer.GetPlayer(Group[0]); + Player Players = Core.Player.GetPlayer(Group[0]); string PlayerName = Players.isGameJoltPlayer ? $"{Players.Name} ({ Players.GameJoltID})" : $"{Players.Name}"; if (Players.GameJoltID == 116016 || Player.GameJoltID == 222452) @@ -66,13 +66,13 @@ public void Handle(Package p, Player Player = null) } else if (Player == null) { - if (!Core.Pokemon3DPlayer.HasPlayer(Group[0])) + if (!Core.Player.HasPlayer(Group[0])) { Core.Logger.Log(Core.Setting.Token("SERVER_PLAYERNOTEXIST"), Logger.LogTypes.Info); } else { - Player Players = Core.Pokemon3DPlayer.GetPlayer(Group[0]); + Player Players = Core.Player.GetPlayer(Group[0]); string PlayerName = Players.isGameJoltPlayer ? $"{Players.Name} ({ Players.GameJoltID})" : $"{Players.Name}"; if (Players.GameJoltID == 116016 || Player.GameJoltID == 222452) @@ -97,13 +97,13 @@ public void Handle(Package p, Player Player = null) if (Player != null && this.MatchRequiredPermission(Player)) { - if (!Core.Pokemon3DPlayer.HasPlayer(Group[0])) + if (!Core.Player.HasPlayer(Group[0])) { Player.CommandFeedback(Core.Setting.Token("SERVER_PLAYERNOTEXIST"), null); } else { - Player Players = Core.Pokemon3DPlayer.GetPlayer(Group[0]); + Player Players = Core.Player.GetPlayer(Group[0]); string PlayerName = Players.isGameJoltPlayer ? $"{Players.Name} ({ Players.GameJoltID})" : $"{Players.Name}"; if (Players.GameJoltID == 116016 || Player.GameJoltID == 222452) @@ -120,13 +120,13 @@ public void Handle(Package p, Player Player = null) } else if (Player == null) { - if (!Core.Pokemon3DPlayer.HasPlayer(Group[0])) + if (!Core.Player.HasPlayer(Group[0])) { Core.Logger.Log(Core.Setting.Token("SERVER_PLAYERNOTEXIST"), Logger.LogTypes.Info); } else { - Player Players = Core.Pokemon3DPlayer.GetPlayer(Group[0]); + Player Players = Core.Player.GetPlayer(Group[0]); string PlayerName = Players.isGameJoltPlayer ? $"{Players.Name} ({ Players.GameJoltID})" : $"{Players.Name}"; if (Players.GameJoltID == 116016 || Player.GameJoltID == 222452) diff --git a/Pokemon.3D.Server.Core/Server_Client_Listener/Commands/Data/Operator/Remove.cs b/Pokemon.3D.Server.Core/Server_Client_Listener/Commands/Data/Operator/Remove.cs index de0e30d..66258fe 100644 --- a/Pokemon.3D.Server.Core/Server_Client_Listener/Commands/Data/Operator/Remove.cs +++ b/Pokemon.3D.Server.Core/Server_Client_Listener/Commands/Data/Operator/Remove.cs @@ -43,13 +43,13 @@ public void Handle(Package p, Player Player = null) if (Player != null && this.MatchRequiredPermission(Player)) { - if (!Core.Pokemon3DPlayer.HasPlayer(Group[0])) + if (!Core.Player.HasPlayer(Group[0])) { Player.CommandFeedback(Core.Setting.Token("SERVER_PLAYERNOTEXIST"), null); } else { - Player Players = Core.Pokemon3DPlayer.GetPlayer(Group[0]); + Player Players = Core.Player.GetPlayer(Group[0]); string PlayerName = Players.isGameJoltPlayer ? $"{Players.Name} ({ Players.GameJoltID})" : $"{Players.Name}"; if (Players.IsOperator()) @@ -73,13 +73,13 @@ public void Handle(Package p, Player Player = null) } else if (Player == null) { - if (!Core.Pokemon3DPlayer.HasPlayer(Group[0])) + if (!Core.Player.HasPlayer(Group[0])) { Core.Logger.Log(Core.Setting.Token("SERVER_PLAYERNOTEXIST"), Logger.LogTypes.Info); } else { - Player Players = Core.Pokemon3DPlayer.GetPlayer(Group[0]); + Player Players = Core.Player.GetPlayer(Group[0]); string PlayerName = Players.isGameJoltPlayer ? $"{Players.Name} ({ Players.GameJoltID})" : $"{Players.Name}"; if (Players.IsOperator()) diff --git a/Pokemon.3D.Server.Core/Server_Client_Listener/Commands/Data/PvP/League.cs b/Pokemon.3D.Server.Core/Server_Client_Listener/Commands/Data/PvP/League.cs index 8fd3ab2..5f0d25b 100644 --- a/Pokemon.3D.Server.Core/Server_Client_Listener/Commands/Data/PvP/League.cs +++ b/Pokemon.3D.Server.Core/Server_Client_Listener/Commands/Data/PvP/League.cs @@ -44,14 +44,14 @@ public void Handle(Package p, Player Player = null) Player.PvP_Rules = new List { Player.PvPRules.Custom_League.ToString() }; Player.PvP_Validatated = false; - Core.Pokemon3DPlayer.GetPlayer(Player.PvP_OpponentID).PvP_Rules = new List { Player.PvPRules.Custom_League.ToString() }; - Core.Pokemon3DPlayer.GetPlayer(Player.PvP_OpponentID).PvP_Validatated = false; + Core.Player.GetPlayer(Player.PvP_OpponentID).PvP_Rules = new List { Player.PvPRules.Custom_League.ToString() }; + Core.Player.GetPlayer(Player.PvP_OpponentID).PvP_Validatated = false; Player.CommandFeedback("The PvP match will now obey League rules. For more info refer:", null); - Player.CommandFeedback("http://www.aggressivegaming.org/pokemon/threads/general-league-rules.1052/", null); + Player.CommandFeedback("http://www.aggressivegaming.org/pokemon/link-forums/general-league-rules.219/", null); - Core.Pokemon3DPlayer.GetPlayer(Player.PvP_OpponentID).CommandFeedback("The PvP match will now obey League rules. For more info refer:", null); - Core.Pokemon3DPlayer.GetPlayer(Player.PvP_OpponentID).CommandFeedback("http://www.aggressivegaming.org/pokemon/threads/general-league-rules.1052/", null); + Core.Player.GetPlayer(Player.PvP_OpponentID).CommandFeedback("The PvP match will now obey League rules. For more info refer:", null); + Core.Player.GetPlayer(Player.PvP_OpponentID).CommandFeedback("http://www.aggressivegaming.org/pokemon/link-forums/general-league-rules.219/", null); } } } diff --git a/Pokemon.3D.Server.Core/Server_Client_Listener/Commands/Data/Say.cs b/Pokemon.3D.Server.Core/Server_Client_Listener/Commands/Data/Say.cs index f8da12f..2886cd6 100644 --- a/Pokemon.3D.Server.Core/Server_Client_Listener/Commands/Data/Say.cs +++ b/Pokemon.3D.Server.Core/Server_Client_Listener/Commands/Data/Say.cs @@ -41,13 +41,13 @@ public void Handle(Package p, Player Player = null) if (Player != null && this.MatchRequiredPermission(Player)) { - Core.Pokemon3DPlayer.SendToAllPlayer(new Package(Package.PackageTypes.ChatMessage, Group[0], null)); + Core.Player.SendToAllPlayer(new Package(Package.PackageTypes.ChatMessage, Group[0], null)); Player.CommandFeedback(null, string.Format("have sent a server chat.")); } else if (Player == null) { - Core.Pokemon3DPlayer.SendToAllPlayer(new Package(Package.PackageTypes.ChatMessage, Group[0], null)); + Core.Player.SendToAllPlayer(new Package(Package.PackageTypes.ChatMessage, Group[0], null)); Core.Logger.Log(Group[0], Logger.LogTypes.Server); } diff --git a/Pokemon.3D.Server.Core/Server_Client_Listener/Commands/Data/World/Player_World.cs b/Pokemon.3D.Server.Core/Server_Client_Listener/Commands/Data/World/Player_World.cs index 17c108e..f5a2999 100644 --- a/Pokemon.3D.Server.Core/Server_Client_Listener/Commands/Data/World/Player_World.cs +++ b/Pokemon.3D.Server.Core/Server_Client_Listener/Commands/Data/World/Player_World.cs @@ -40,7 +40,7 @@ public void Handle(Package p, Player Player = null) if (Player != null && this.MatchRequiredPermission(Player)) { OnlineSetting Settings = Player.GetOnlineSetting(); - Core.Pokemon3DPlayer.SentToPlayer(new Package(Package.PackageTypes.ChatMessage, Core.World.ToString(Settings.CurrentWorldSeason,Settings.CurrentWorldWeather), Player.Network.Client)); + Core.Player.SentToPlayer(new Package(Package.PackageTypes.ChatMessage, Core.World.ToString(Settings.CurrentWorldSeason,Settings.CurrentWorldWeather), Player.Network.Client)); } } #endregion /Player.World diff --git a/Pokemon.3D.Server.Core/Server_Client_Listener/Commands/Data/World/World.cs b/Pokemon.3D.Server.Core/Server_Client_Listener/Commands/Data/World/World.cs index 4206812..9d6e902 100644 --- a/Pokemon.3D.Server.Core/Server_Client_Listener/Commands/Data/World/World.cs +++ b/Pokemon.3D.Server.Core/Server_Client_Listener/Commands/Data/World/World.cs @@ -38,7 +38,7 @@ public void Handle(Package p, Player Player = null) { if (Player != null && this.MatchRequiredPermission(Player)) { - Core.Pokemon3DPlayer.SentToPlayer(new Package(Package.PackageTypes.ChatMessage, Core.World.ToString(), Player.Network.Client)); + Core.Player.SentToPlayer(new Package(Package.PackageTypes.ChatMessage, Core.World.ToString(), Player.Network.Client)); } else if (Player == null) { diff --git a/Pokemon.3D.Server.Core/Server_Client_Listener/Commands/Functions.cs b/Pokemon.3D.Server.Core/Server_Client_Listener/Commands/Functions.cs index 87350e8..06f5a71 100644 --- a/Pokemon.3D.Server.Core/Server_Client_Listener/Commands/Functions.cs +++ b/Pokemon.3D.Server.Core/Server_Client_Listener/Commands/Functions.cs @@ -90,7 +90,7 @@ public static bool MatchRequiredPermission(this ICommand Command, Player Player) } else { - Core.Pokemon3DPlayer.SentToPlayer(new Package(Package.PackageTypes.ChatMessage, Core.Setting.Token("SERVER_COMMANDPERMISSION"), Player.Network.Client)); + Core.Player.SentToPlayer(new Package(Package.PackageTypes.ChatMessage, Core.Setting.Token("SERVER_COMMANDPERMISSION"), Player.Network.Client)); Core.Logger.Log(Player.isGameJoltPlayer ? Core.Setting.Token("SERVER_GAMEJOLT", Player.Name, Player.GameJoltID.ToString(), "is unable to use /" + Command.Name + " due to insufficient permission.") : Core.Setting.Token("SERVER_NOGAMEJOLT", Player.Name, "is unable to use /" + Command.Name + " due to insufficient permission."), Logger.LogTypes.Command, Player.Network.Client); @@ -144,12 +144,12 @@ public static void CommandFeedback(this Player Player, string Message, string Me { if (Message != null) { - Core.Pokemon3DPlayer.SentToPlayer(new Package(Package.PackageTypes.ChatMessage, Message, Player.Network.Client)); + Core.Player.SentToPlayer(new Package(Package.PackageTypes.ChatMessage, Message, Player.Network.Client)); } if (Message2 != null) { - Core.Pokemon3DPlayer.SendToAllOperator(new Package(Package.PackageTypes.ChatMessage, Player.isGameJoltPlayer ? + Core.Player.SendToAllOperator(new Package(Package.PackageTypes.ChatMessage, Player.isGameJoltPlayer ? Core.Setting.Token("SERVER_COMMANDGAMEJOLT", Player.Name, Player.GameJoltID.ToString(), Message2) : Core.Setting.Token("SERVER_COMMANDNOGAMEJOLT", Player.Name, Message2) , Player.Network.Client)); @@ -173,7 +173,7 @@ public static void HelpPageGenerator(this ICommand Command, Player Player, param { for (int i = 0; i < Message.Length; i++) { - Core.Pokemon3DPlayer.SentToPlayer(new Package(Package.PackageTypes.ChatMessage, Message[i], Player.Network.Client)); + Core.Player.SentToPlayer(new Package(Package.PackageTypes.ChatMessage, Message[i], Player.Network.Client)); } } else diff --git a/Pokemon.3D.Server.Core/Server_Client_Listener/Packages/PackageHandler.cs b/Pokemon.3D.Server.Core/Server_Client_Listener/Packages/PackageHandler.cs index 2b0fdf1..820ec81 100644 --- a/Pokemon.3D.Server.Core/Server_Client_Listener/Packages/PackageHandler.cs +++ b/Pokemon.3D.Server.Core/Server_Client_Listener/Packages/PackageHandler.cs @@ -116,9 +116,9 @@ public void Handle(Package p) #region Pokemon 3D Data private void HandleGameData(Package p) { - if (Core.Pokemon3DPlayer.HasPlayer(p.Client)) + if (Core.Player.HasPlayer(p.Client)) { - Core.Pokemon3DPlayer.GetPlayer(p.Client).Update(p, true); + Core.Player.GetPlayer(p.Client).Update(p, true); } else { @@ -126,9 +126,9 @@ private void HandleGameData(Package p) Player Player = new Player(p); // Server Space Limit - if (Core.Pokemon3DPlayer.Count >= Core.Setting.MaxPlayers) + if (Core.Player.Count >= Core.Setting.MaxPlayers) { - Core.Pokemon3DPlayer.SentToPlayer(new Package(Package.PackageTypes.Kicked, Core.Setting.Token("SERVER_FULL"), p.Client)); + Core.Player.SentToPlayer(new Package(Package.PackageTypes.Kicked, Core.Setting.Token("SERVER_FULL"), p.Client)); Core.Logger.Log(Player.isGameJoltPlayer ? Core.Setting.Token("SERVER_GAMEJOLT", Player.Name, Player.GameJoltID.ToString(), "is unable to join the server with the following reason: " + Core.Setting.Token("SERVER_FULL")) : Core.Setting.Token("SERVER_NOGAMEJOLT", Player.Name, "is unable to join the server with the following reason: " + Core.Setting.Token("SERVER_FULL")), Logger.LogTypes.Info, p.Client); @@ -138,7 +138,7 @@ private void HandleGameData(Package p) // Offline mode? if (!Core.Setting.OfflineMode && !Player.isGameJoltPlayer && string.IsNullOrWhiteSpace(p.DataItems[2])) { - Core.Pokemon3DPlayer.SentToPlayer(new Package(Package.PackageTypes.Kicked, Core.Setting.Token("SERVER_OFFLINEMODE"), p.Client)); + Core.Player.SentToPlayer(new Package(Package.PackageTypes.Kicked, Core.Setting.Token("SERVER_OFFLINEMODE"), p.Client)); Core.Logger.Log(Player.isGameJoltPlayer ? Core.Setting.Token("SERVER_GAMEJOLT", Player.Name, Player.GameJoltID.ToString(), "is unable to join the server with the following reason: " + Core.Setting.Token("SERVER_OFFLINEMODE")) : Core.Setting.Token("SERVER_NOGAMEJOLT", Player.Name, "is unable to join the server with the following reason: " + Core.Setting.Token("SERVER_OFFLINEMODE")), Logger.LogTypes.Info, p.Client); @@ -169,7 +169,7 @@ private void HandleGameData(Package p) } GameModeAllowed = GameModeAllowed.Remove(GameModeAllowed.LastIndexOf(",")); - Core.Pokemon3DPlayer.SentToPlayer(new Package(Package.PackageTypes.Kicked, Core.Setting.Token("SERVER_WRONGGAMEMODE", GameModeAllowed), p.Client)); + Core.Player.SentToPlayer(new Package(Package.PackageTypes.Kicked, Core.Setting.Token("SERVER_WRONGGAMEMODE", GameModeAllowed), p.Client)); Core.Logger.Log(Player.isGameJoltPlayer ? Core.Setting.Token("SERVER_GAMEJOLT", Player.Name, Player.GameJoltID.ToString(), "is unable to join the server with the following reason: " + Core.Setting.Token("SERVER_WRONGGAMEMODE", GameModeAllowed)) : Core.Setting.Token("SERVER_NOGAMEJOLT", Player.Name, "is unable to join the server with the following reason: " + Core.Setting.Token("SERVER_WRONGGAMEMODE", GameModeAllowed)), Logger.LogTypes.Info, p.Client); @@ -179,7 +179,7 @@ private void HandleGameData(Package p) // BlackList if (Player.IsBlackListed()) { - Core.Pokemon3DPlayer.SentToPlayer(new Package(Package.PackageTypes.Kicked, Core.Setting.Token("SERVER_BLACKLISTED", Player.GetBlackList().Reason, Player.GetBlackList().RemainingTime), p.Client)); + Core.Player.SentToPlayer(new Package(Package.PackageTypes.Kicked, Core.Setting.Token("SERVER_BLACKLISTED", Player.GetBlackList().Reason, Player.GetBlackList().RemainingTime), p.Client)); Core.Logger.Log(Player.isGameJoltPlayer ? Core.Setting.Token("SERVER_GAMEJOLT", Player.Name, Player.GameJoltID.ToString(), "is unable to join the server with the following reason: " + Core.Setting.Token("SERVER_BLACKLISTED", Player.GetBlackList().Reason, Player.GetBlackList().RemainingTime)) : Core.Setting.Token("SERVER_NOGAMEJOLT", Player.Name, "is unable to join the server with the following reason: " + Core.Setting.Token("SERVER_BLACKLISTED", Player.GetBlackList().Reason, Player.GetBlackList().RemainingTime)), Logger.LogTypes.Info, p.Client); @@ -189,7 +189,7 @@ private void HandleGameData(Package p) // IP BlackList if (Player.IsIPBlackListed()) { - Core.Pokemon3DPlayer.SentToPlayer(new Package(Package.PackageTypes.Kicked, Core.Setting.Token("SERVER_IPBLACKLISTED", Player.GetIPBlackList().Reason, Player.GetIPBlackList().RemainingTime), p.Client)); + Core.Player.SentToPlayer(new Package(Package.PackageTypes.Kicked, Core.Setting.Token("SERVER_IPBLACKLISTED", Player.GetIPBlackList().Reason, Player.GetIPBlackList().RemainingTime), p.Client)); Core.Logger.Log(Player.isGameJoltPlayer ? Core.Setting.Token("SERVER_GAMEJOLT", Player.Name, Player.GameJoltID.ToString(), "is unable to join the server with the following reason: " + Core.Setting.Token("SERVER_IPBLACKLISTED", Player.GetIPBlackList().Reason, Player.GetIPBlackList().RemainingTime)) : Core.Setting.Token("SERVER_NOGAMEJOLT", Player.Name, "is unable to join the server with the following reason: " + Core.Setting.Token("SERVER_IPBLACKLISTED", Player.GetIPBlackList().Reason, Player.GetIPBlackList().RemainingTime)), Logger.LogTypes.Info, p.Client); @@ -199,7 +199,7 @@ private void HandleGameData(Package p) // WhiteList if (Core.Setting.WhiteList && !Player.IsWhiteListed()) { - Core.Pokemon3DPlayer.SentToPlayer(new Package(Package.PackageTypes.Kicked, Core.Setting.Token("SERVER_DISALLOW"), p.Client)); + Core.Player.SentToPlayer(new Package(Package.PackageTypes.Kicked, Core.Setting.Token("SERVER_DISALLOW"), p.Client)); Core.Logger.Log(Player.isGameJoltPlayer ? Core.Setting.Token("SERVER_GAMEJOLT", Player.Name, Player.GameJoltID.ToString(), "is unable to join the server with the following reason: " + Core.Setting.Token("SERVER_DISALLOW")) : Core.Setting.Token("SERVER_NOGAMEJOLT", Player.Name, "is unable to join the server with the following reason: " + Core.Setting.Token("SERVER_DISALLOW")), Logger.LogTypes.Info, p.Client); @@ -207,13 +207,13 @@ private void HandleGameData(Package p) } // A Clone GHOST - kidding - for (int i = 0; i < Core.Pokemon3DPlayer.Count; i++) + for (int i = 0; i < Core.Player.Count; i++) { if (Player.isGameJoltPlayer) { - if (Player.GameJoltID == Core.Pokemon3DPlayer[i].GameJoltID) + if (Player.GameJoltID == Core.Player[i].GameJoltID) { - Core.Pokemon3DPlayer.SentToPlayer(new Package(Package.PackageTypes.Kicked, Core.Setting.Token("SERVER_CLONE"), p.Client)); + Core.Player.SentToPlayer(new Package(Package.PackageTypes.Kicked, Core.Setting.Token("SERVER_CLONE"), p.Client)); Core.Logger.Log(Player.isGameJoltPlayer ? Core.Setting.Token("SERVER_GAMEJOLT", Player.Name, Player.GameJoltID.ToString(), "is unable to join the server with the following reason: " + Core.Setting.Token("SERVER_CLONE")) : Core.Setting.Token("SERVER_NOGAMEJOLT", Player.Name, "is unable to join the server with the following reason: " + Core.Setting.Token("SERVER_CLONE")), Logger.LogTypes.Info, p.Client); @@ -222,9 +222,9 @@ private void HandleGameData(Package p) } else { - if (string.Equals(Player.Name, Core.Pokemon3DPlayer[i].Name, StringComparison.Ordinal) && Core.Pokemon3DPlayer[i].GameJoltID == -1) + if (string.Equals(Player.Name, Core.Player[i].Name, StringComparison.Ordinal) && Core.Player[i].GameJoltID == -1) { - Core.Pokemon3DPlayer.SentToPlayer(new Package(Package.PackageTypes.Kicked, Core.Setting.Token("SERVER_CLONE"), p.Client)); + Core.Player.SentToPlayer(new Package(Package.PackageTypes.Kicked, Core.Setting.Token("SERVER_CLONE"), p.Client)); Core.Logger.Log(Player.isGameJoltPlayer ? Core.Setting.Token("SERVER_GAMEJOLT", Player.Name, Player.GameJoltID.ToString(), "is unable to join the server with the following reason: " + Core.Setting.Token("SERVER_CLONE")) : Core.Setting.Token("SERVER_NOGAMEJOLT", Player.Name, "is unable to join the server with the following reason: " + Core.Setting.Token("SERVER_CLONE")), Logger.LogTypes.Info, p.Client); @@ -234,19 +234,19 @@ private void HandleGameData(Package p) } // Else Let it roll :) - Core.Pokemon3DPlayer.Add(p); + Core.Player.Add(p); } } private void HandlePrivateMessage(Package p) { - Player Player = Core.Pokemon3DPlayer.GetPlayer(p.Client); - Player PMPlayer = Core.Pokemon3DPlayer.GetPlayer(p.DataItems[0]); + Player Player = Core.Player.GetPlayer(p.Client); + Player PMPlayer = Core.Player.GetPlayer(p.DataItems[0]); // Check if external player exist. - if (!Core.Pokemon3DPlayer.HasPlayer(p.DataItems[0])) + if (!Core.Player.HasPlayer(p.DataItems[0])) { - Core.Pokemon3DPlayer.SentToPlayer(new Package(Package.PackageTypes.ChatMessage, PMPlayer.isGameJoltPlayer ? + Core.Player.SentToPlayer(new Package(Package.PackageTypes.ChatMessage, PMPlayer.isGameJoltPlayer ? Core.Setting.Token("SERVER_GAMEJOLT", PMPlayer.Name, PMPlayer.GameJoltID.ToString(), "does not exist.") : Core.Setting.Token("SERVER_NOGAMEJOLT", PMPlayer.Name, "does not exist."), p.Client)); Core.Logger.Log(Player.isGameJoltPlayer ? @@ -258,7 +258,7 @@ private void HandlePrivateMessage(Package p) // Check if you are muted Globally if (Player.IsMuteListed()) { - Core.Pokemon3DPlayer.SentToPlayer(new Package(Package.PackageTypes.ChatMessage, Core.Setting.Token("SERVER_MUTED", Player.GetMuteList().Reason, Player.GetMuteList().RemainingTime), p.Client)); + Core.Player.SentToPlayer(new Package(Package.PackageTypes.ChatMessage, Core.Setting.Token("SERVER_MUTED", Player.GetMuteList().Reason, Player.GetMuteList().RemainingTime), p.Client)); Core.Logger.Log(Player.isGameJoltPlayer ? Core.Setting.Token("SERVER_GAMEJOLT", Player.Name, Player.GameJoltID.ToString(), "is unable to PM with the following reason: " + Core.Setting.Token("SERVER_MUTED", Player.GetMuteList().Reason, Player.GetMuteList().RemainingTime)) : Core.Setting.Token("SERVER_NOGAMEJOLT", Player.Name, "is unable to PM with the following reason: " + Core.Setting.Token("SERVER_MUTED", Player.GetMuteList().Reason, Player.GetMuteList().RemainingTime)), Logger.LogTypes.PM, p.Client); @@ -268,7 +268,7 @@ private void HandlePrivateMessage(Package p) // Check if you are muted by the player. if (Player.IsMuteListed(PMPlayer)) { - Core.Pokemon3DPlayer.SentToPlayer(new Package(Package.PackageTypes.ChatMessage, Core.Setting.Token("SERVER_MUTEDTEMP", Player.GetMuteList(PMPlayer).Reason, Player.GetMuteList(PMPlayer).RemainingTime), p.Client)); + Core.Player.SentToPlayer(new Package(Package.PackageTypes.ChatMessage, Core.Setting.Token("SERVER_MUTEDTEMP", Player.GetMuteList(PMPlayer).Reason, Player.GetMuteList(PMPlayer).RemainingTime), p.Client)); Core.Logger.Log(Player.isGameJoltPlayer ? Core.Setting.Token("SERVER_GAMEJOLT", Player.Name, Player.GameJoltID.ToString(), "is unable to PM with the following reason: " + Core.Setting.Token("SERVER_MUTEDTEMP", Player.GetMuteList(PMPlayer).Reason, Player.GetMuteList(PMPlayer).RemainingTime)) : Core.Setting.Token("SERVER_NOGAMEJOLT", Player.Name, "is unable to PM with the following reason: " + Core.Setting.Token("SERVER_MUTEDTEMP", Player.GetMuteList(PMPlayer).Reason, Player.GetMuteList(PMPlayer).RemainingTime)), Logger.LogTypes.PM, p.Client); @@ -281,7 +281,7 @@ private void HandlePrivateMessage(Package p) { Player.AddInfractionCount(1); Player.AddMuteList(3600, "You have swear too much today."); - Core.Pokemon3DPlayer.SentToPlayer(new Package(Package.PackageTypes.ChatMessage, Core.Setting.SwearInfractionCap < 1 ? + Core.Player.SentToPlayer(new Package(Package.PackageTypes.ChatMessage, Core.Setting.SwearInfractionCap < 1 ? Core.Setting.Token("SERVER_SWEAR", p.DataItems[1].SwearWord()) : Core.Setting.Token("SERVER_SWEARWARNING", p.DataItems[1].SwearWord(), Player.GetSwearInfractionList().Points.ToString(), Core.Setting.SwearInfractionCap.ToString()), p.Client)); Core.Logger.Log(Player.isGameJoltPlayer ? @@ -294,8 +294,8 @@ private void HandlePrivateMessage(Package p) if (!string.IsNullOrWhiteSpace(p.DataItems[1])) { - Core.Pokemon3DPlayer.SentToPlayer(new Package(Package.PackageTypes.PrivateMessage, Player.ID, p.DataItems[1], PMPlayer.Network.Client)); - Core.Pokemon3DPlayer.SentToPlayer(new Package(Package.PackageTypes.PrivateMessage, Player.ID, p.DataItems, p.Client)); + Core.Player.SentToPlayer(new Package(Package.PackageTypes.PrivateMessage, Player.ID, p.DataItems[1], PMPlayer.Network.Client)); + Core.Player.SentToPlayer(new Package(Package.PackageTypes.PrivateMessage, Player.ID, p.DataItems, p.Client)); Core.Logger.Log(Player.isGameJoltPlayer ? Core.Setting.Token("SERVER_GAMEJOLT", Player.Name, Player.GameJoltID.ToString(), "have sent a private message to " + p.DataItems[0] + " with the following message: " + p.DataItems[1]) : @@ -305,14 +305,14 @@ private void HandlePrivateMessage(Package p) private void HandleChatMessage(Package p) { - Player Player = Core.Pokemon3DPlayer.GetPlayer(p.Client); + Player Player = Core.Player.GetPlayer(p.Client); if (Core.Setting.AllowChatInServer) { // Check if you are muted Globally if (Player.IsMuteListed()) { - Core.Pokemon3DPlayer.SentToPlayer(new Package(Package.PackageTypes.ChatMessage, Core.Setting.Token("SERVER_MUTED", Player.GetMuteList().Reason, Player.GetMuteList().RemainingTime), p.Client)); + Core.Player.SentToPlayer(new Package(Package.PackageTypes.ChatMessage, Core.Setting.Token("SERVER_MUTED", Player.GetMuteList().Reason, Player.GetMuteList().RemainingTime), p.Client)); Core.Logger.Log(Player.isGameJoltPlayer ? Core.Setting.Token("SERVER_GAMEJOLT", Player.Name, Player.GameJoltID.ToString(), "is unable to chat with the following reason: " + Core.Setting.Token("SERVER_MUTED", Player.GetMuteList().Reason, Player.GetMuteList().RemainingTime)) : Core.Setting.Token("SERVER_NOGAMEJOLT", Player.Name, "is unable to chat with the following reason: " + Core.Setting.Token("SERVER_MUTED", Player.GetMuteList().Reason, Player.GetMuteList().RemainingTime)), Logger.LogTypes.Chat, p.Client); @@ -324,7 +324,7 @@ private void HandleChatMessage(Package p) { if ((DateTime.Now - Player.CC_LastChatTime).TotalSeconds < Core.Setting.SpamResetDuration) { - Core.Pokemon3DPlayer.SentToPlayer(new Package(Package.PackageTypes.ChatMessage, Core.Setting.Token("SERVER_SPAM"), p.Client)); + Core.Player.SentToPlayer(new Package(Package.PackageTypes.ChatMessage, Core.Setting.Token("SERVER_SPAM"), p.Client)); Core.Logger.Log(Player.isGameJoltPlayer ? Core.Setting.Token("SERVER_GAMEJOLT", Player.Name, Player.GameJoltID.ToString(), "is unable to chat with the following reason: " + Core.Setting.Token("SERVER_SPAM")) : Core.Setting.Token("SERVER_NOGAMEJOLT", Player.Name, "is unable to chat with the following reason: " + Core.Setting.Token("SERVER_SPAM")), Logger.LogTypes.Chat, p.Client); @@ -344,7 +344,7 @@ private void HandleChatMessage(Package p) { Player.AddInfractionCount(1); Player.AddMuteList(3600, "You have swear too much today."); - Core.Pokemon3DPlayer.SentToPlayer(new Package(Package.PackageTypes.ChatMessage, Core.Setting.SwearInfractionCap < 1 ? + Core.Player.SentToPlayer(new Package(Package.PackageTypes.ChatMessage, Core.Setting.SwearInfractionCap < 1 ? Core.Setting.Token("SERVER_SWEAR", p.DataItems[0].SwearWord()) : Core.Setting.Token("SERVER_SWEARWARNING", p.DataItems[0].SwearWord(), Player.GetSwearInfractionList().Points.ToString(), Core.Setting.SwearInfractionCap.ToString()), p.Client)); Core.Logger.Log(Player.isGameJoltPlayer ? @@ -355,11 +355,11 @@ private void HandleChatMessage(Package p) // Let's do this. if (!string.IsNullOrWhiteSpace(p.DataItems[0])) { - for (int i = 0; i < Core.Pokemon3DPlayer.Count; i++) + for (int i = 0; i < Core.Player.Count; i++) { - if (!Player.IsMuteListed(Core.Pokemon3DPlayer[i]) && (Player.CC_CurrentChatChannel == Core.Pokemon3DPlayer[i].CC_CurrentChatChannel || Core.Pokemon3DPlayer[i].CC_CurrentChatChannel == Player.ChatChannelType.Default.ToString() || !Core.Setting.AllowChatChannels)) + if (!Player.IsMuteListed(Core.Player[i]) && (Player.CC_CurrentChatChannel == Core.Player[i].CC_CurrentChatChannel || Core.Player[i].CC_CurrentChatChannel == Player.ChatChannelType.Default.ToString() || !Core.Setting.AllowChatChannels)) { - Core.Pokemon3DPlayer.SentToPlayer(new Package(Package.PackageTypes.ChatMessage, Player.ID, p.DataItems[0], Core.Pokemon3DPlayer[i].Network.Client)); + Core.Player.SentToPlayer(new Package(Package.PackageTypes.ChatMessage, Player.ID, p.DataItems[0], Core.Player[i].Network.Client)); } } @@ -373,20 +373,20 @@ private void HandleChatMessage(Package p) } else { - Core.Pokemon3DPlayer.SentToPlayer(new Package(Package.PackageTypes.ChatMessage, Core.Setting.Token("SERVER_NOCHAT"), p.Client)); + Core.Player.SentToPlayer(new Package(Package.PackageTypes.ChatMessage, Core.Setting.Token("SERVER_NOCHAT"), p.Client)); } } private void HandlePing(Package p) { - Player Player = Core.Pokemon3DPlayer.GetPlayer(p.Client); + Player Player = Core.Player.GetPlayer(p.Client); Player.Network.LastValidPing = DateTime.Now; } private void HandleGamestateMessage(Package p) { - Player Player = Core.Pokemon3DPlayer.GetPlayer(p.Client); - Core.Pokemon3DPlayer.SendToAllPlayer(new Package(Package.PackageTypes.ChatMessage, Player.isGameJoltPlayer ? + Player Player = Core.Player.GetPlayer(p.Client); + Core.Player.SendToAllPlayer(new Package(Package.PackageTypes.ChatMessage, Player.isGameJoltPlayer ? "The player " + Core.Setting.Token("SERVER_GAMEJOLT", Player.Name, Player.GameJoltID.ToString(), p.DataItems[0]) : "The player " + Core.Setting.Token("SERVER_NOGAMEJOLT", Player.Name, p.DataItems[0]), null)); Core.Logger.Log(Player.isGameJoltPlayer ? @@ -396,15 +396,15 @@ private void HandleGamestateMessage(Package p) private void HandleTradeRequest(Package p) { - Player Player = Core.Pokemon3DPlayer.GetPlayer(p.Client); - Player TradePlayer = Core.Pokemon3DPlayer.GetPlayer(p.DataItems[0].ToInt()); + Player Player = Core.Player.GetPlayer(p.Client); + Player TradePlayer = Core.Player.GetPlayer(p.DataItems[0].ToInt()); string TradePlayerName = TradePlayer.isGameJoltPlayer ? Core.Setting.Token("SERVER_GAMEJOLT", TradePlayer.Name, TradePlayer.GameJoltID.ToString(), "") : Core.Setting.Token("SERVER_NOGAMEJOLT", TradePlayer.Name, ""); if (!Core.Setting.AllowTrade) { - Core.Pokemon3DPlayer.SentToPlayer(new Package(Package.PackageTypes.ChatMessage, Core.Setting.Token("SERVER_TRADEDISALLOW"), p.Client)); - Core.Pokemon3DPlayer.SentToPlayer(new Package(Package.PackageTypes.TradeQuit, Player.ID, "", p.Client)); + Core.Player.SentToPlayer(new Package(Package.PackageTypes.ChatMessage, Core.Setting.Token("SERVER_TRADEDISALLOW"), p.Client)); + Core.Player.SentToPlayer(new Package(Package.PackageTypes.TradeQuit, Player.ID, "", p.Client)); Core.Logger.Log(Player.isGameJoltPlayer ? Core.Setting.Token("SERVER_GAMEJOLT", Player.Name, Player.GameJoltID.ToString(), "is unable to trade with the following reason: " + Core.Setting.Token("SERVER_TRADEDISALLOW")) : @@ -415,20 +415,20 @@ private void HandleTradeRequest(Package p) // Server Restart Timer. if (Core.Setting.AutoRestartTime >= 10 && (Core.Setting.StartTime.AddSeconds(Core.Setting.AutoRestartTime) - DateTime.Now).TotalSeconds <= 300) { - Core.Pokemon3DPlayer.SentToPlayer(new Package(Package.PackageTypes.ChatMessage, Core.Setting.Token("SERVER_TRADEPVPFAIL", Core.Pokemon3DListener.TimeLeft()), p.Client)); - Core.Pokemon3DPlayer.SentToPlayer(new Package(Package.PackageTypes.TradeQuit, Player.ID, "", p.Client)); + Core.Player.SentToPlayer(new Package(Package.PackageTypes.ChatMessage, Core.Setting.Token("SERVER_TRADEPVPFAIL", Core.Listener.TimeLeft()), p.Client)); + Core.Player.SentToPlayer(new Package(Package.PackageTypes.TradeQuit, Player.ID, "", p.Client)); Core.Logger.Log(Player.isGameJoltPlayer ? - Core.Setting.Token("SERVER_GAMEJOLT", Player.Name, Player.GameJoltID.ToString(), "is unable to trade with the following reason: " + Core.Setting.Token("SERVER_TRADEPVPFAIL", Core.Pokemon3DListener.TimeLeft())) : - Core.Setting.Token("SERVER_NOGAMEJOLT", Player.Name, "is unable to trade with the following reason: " + Core.Setting.Token("SERVER_TRADEPVPFAIL", Core.Pokemon3DListener.TimeLeft())), Logger.LogTypes.Trade, p.Client); + Core.Setting.Token("SERVER_GAMEJOLT", Player.Name, Player.GameJoltID.ToString(), "is unable to trade with the following reason: " + Core.Setting.Token("SERVER_TRADEPVPFAIL", Core.Listener.TimeLeft())) : + Core.Setting.Token("SERVER_NOGAMEJOLT", Player.Name, "is unable to trade with the following reason: " + Core.Setting.Token("SERVER_TRADEPVPFAIL", Core.Listener.TimeLeft())), Logger.LogTypes.Trade, p.Client); return; } // Check if you are blocked. if (Player.IsMuteListed(TradePlayer)) { - Core.Pokemon3DPlayer.SentToPlayer(new Package(Package.PackageTypes.ChatMessage, Core.Setting.Token("SERVER_MUTEDTEMP", Player.GetMuteList(TradePlayer).Reason, Player.GetMuteList(TradePlayer).RemainingTime), p.Client)); - Core.Pokemon3DPlayer.SentToPlayer(new Package(Package.PackageTypes.TradeQuit, Player.ID, "", p.Client)); + Core.Player.SentToPlayer(new Package(Package.PackageTypes.ChatMessage, Core.Setting.Token("SERVER_MUTEDTEMP", Player.GetMuteList(TradePlayer).Reason, Player.GetMuteList(TradePlayer).RemainingTime), p.Client)); + Core.Player.SentToPlayer(new Package(Package.PackageTypes.TradeQuit, Player.ID, "", p.Client)); Core.Logger.Log(Player.isGameJoltPlayer ? Core.Setting.Token("SERVER_GAMEJOLT", Player.Name, Player.GameJoltID.ToString(), "is unable to trade with the following reason: " + Core.Setting.Token("SERVER_MUTEDTEMP", Player.GetMuteList(TradePlayer).Reason, Player.GetMuteList(TradePlayer).RemainingTime)) : @@ -436,7 +436,7 @@ private void HandleTradeRequest(Package p) return; } - Core.Pokemon3DPlayer.SentToPlayer(new Package(Package.PackageTypes.TradeRequest, Player.ID, "", TradePlayer.Network.Client)); + Core.Player.SentToPlayer(new Package(Package.PackageTypes.TradeRequest, Player.ID, "", TradePlayer.Network.Client)); Core.Logger.Log(Player.isGameJoltPlayer ? Core.Setting.Token("SERVER_GAMEJOLT", Player.Name, Player.GameJoltID.ToString(), "have sent a trade request to " + TradePlayerName) : Core.Setting.Token("SERVER_NOGAMEJOLT", Player.Name, "have sent a trade request to " + TradePlayerName), Logger.LogTypes.Trade, p.Client); @@ -444,15 +444,15 @@ private void HandleTradeRequest(Package p) private void HandleTradeJoin(Package p) { - Player Player = Core.Pokemon3DPlayer.GetPlayer(p.Client); - Player TradePlayer = Core.Pokemon3DPlayer.GetPlayer(p.DataItems[0].ToInt()); + Player Player = Core.Player.GetPlayer(p.Client); + Player TradePlayer = Core.Player.GetPlayer(p.DataItems[0].ToInt()); string TradePlayerName = TradePlayer.isGameJoltPlayer ? Core.Setting.Token("SERVER_GAMEJOLT", TradePlayer.Name, TradePlayer.GameJoltID.ToString(), "") : Core.Setting.Token("SERVER_NOGAMEJOLT", TradePlayer.Name, ""); if (!Core.Setting.AllowTrade) { - Core.Pokemon3DPlayer.SentToPlayer(new Package(Package.PackageTypes.ChatMessage, Core.Setting.Token("SERVER_TRADEDISALLOW"), p.Client)); - Core.Pokemon3DPlayer.SentToPlayer(new Package(Package.PackageTypes.TradeQuit, Player.ID, "", p.Client)); + Core.Player.SentToPlayer(new Package(Package.PackageTypes.ChatMessage, Core.Setting.Token("SERVER_TRADEDISALLOW"), p.Client)); + Core.Player.SentToPlayer(new Package(Package.PackageTypes.TradeQuit, Player.ID, "", p.Client)); Core.Logger.Log(Player.isGameJoltPlayer ? Core.Setting.Token("SERVER_GAMEJOLT", Player.Name, Player.GameJoltID.ToString(), "is unable to trade with the following reason: " + Core.Setting.Token("SERVER_TRADEDISALLOW")) : @@ -463,16 +463,16 @@ private void HandleTradeJoin(Package p) // Server Restart Timer. if (Core.Setting.AutoRestartTime >= 10 && (Core.Setting.StartTime.AddSeconds(Core.Setting.AutoRestartTime) - DateTime.Now).TotalSeconds <= 300) { - Core.Pokemon3DPlayer.SentToPlayer(new Package(Package.PackageTypes.ChatMessage, Core.Setting.Token("SERVER_TRADEPVPFAIL", Core.Pokemon3DListener.TimeLeft()), p.Client)); - Core.Pokemon3DPlayer.SentToPlayer(new Package(Package.PackageTypes.TradeQuit, Player.ID, "", p.Client)); + Core.Player.SentToPlayer(new Package(Package.PackageTypes.ChatMessage, Core.Setting.Token("SERVER_TRADEPVPFAIL", Core.Listener.TimeLeft()), p.Client)); + Core.Player.SentToPlayer(new Package(Package.PackageTypes.TradeQuit, Player.ID, "", p.Client)); Core.Logger.Log(Player.isGameJoltPlayer ? - Core.Setting.Token("SERVER_GAMEJOLT", Player.Name, Player.GameJoltID.ToString(), "is unable to trade with the following reason: " + Core.Setting.Token("SERVER_TRADEPVPFAIL", Core.Pokemon3DListener.TimeLeft())) : - Core.Setting.Token("SERVER_NOGAMEJOLT", Player.Name, "is unable to trade with the following reason: " + Core.Setting.Token("SERVER_TRADEPVPFAIL", Core.Pokemon3DListener.TimeLeft())), Logger.LogTypes.Trade, p.Client); + Core.Setting.Token("SERVER_GAMEJOLT", Player.Name, Player.GameJoltID.ToString(), "is unable to trade with the following reason: " + Core.Setting.Token("SERVER_TRADEPVPFAIL", Core.Listener.TimeLeft())) : + Core.Setting.Token("SERVER_NOGAMEJOLT", Player.Name, "is unable to trade with the following reason: " + Core.Setting.Token("SERVER_TRADEPVPFAIL", Core.Listener.TimeLeft())), Logger.LogTypes.Trade, p.Client); return; } - Core.Pokemon3DPlayer.SentToPlayer(new Package(Package.PackageTypes.TradeJoin, Player.ID, "", TradePlayer.Network.Client)); + Core.Player.SentToPlayer(new Package(Package.PackageTypes.TradeJoin, Player.ID, "", TradePlayer.Network.Client)); Core.Logger.Log(Player.isGameJoltPlayer ? Core.Setting.Token("SERVER_GAMEJOLT", Player.Name, Player.GameJoltID.ToString(), "have joined the trade request from " + TradePlayerName) : Core.Setting.Token("SERVER_NOGAMEJOLT", Player.Name, "have joined the trade request from " + TradePlayerName), Logger.LogTypes.Trade, p.Client); @@ -480,12 +480,12 @@ private void HandleTradeJoin(Package p) private void HandleTradeQuit(Package p) { - Player Player = Core.Pokemon3DPlayer.GetPlayer(p.Client); - Player TradePlayer = Core.Pokemon3DPlayer.GetPlayer(p.DataItems[0].ToInt()); + Player Player = Core.Player.GetPlayer(p.Client); + Player TradePlayer = Core.Player.GetPlayer(p.DataItems[0].ToInt()); string TradePlayerName = TradePlayer.isGameJoltPlayer ? Core.Setting.Token("SERVER_GAMEJOLT", TradePlayer.Name, TradePlayer.GameJoltID.ToString(), "") : Core.Setting.Token("SERVER_NOGAMEJOLT", TradePlayer.Name, ""); - Core.Pokemon3DPlayer.SentToPlayer(new Package(Package.PackageTypes.TradeQuit, Player.ID, "", TradePlayer.Network.Client)); + Core.Player.SentToPlayer(new Package(Package.PackageTypes.TradeQuit, Player.ID, "", TradePlayer.Network.Client)); Core.Logger.Log(Player.isGameJoltPlayer ? Core.Setting.Token("SERVER_GAMEJOLT", Player.Name, Player.GameJoltID.ToString(), "have rejected the trade request from " + TradePlayerName) : Core.Setting.Token("SERVER_NOGAMEJOLT", Player.Name, "have rejected the trade request from " + TradePlayerName), Logger.LogTypes.Trade, p.Client); @@ -493,10 +493,10 @@ private void HandleTradeQuit(Package p) private void HandleTradeOffer(Package p) { - Player Player = Core.Pokemon3DPlayer.GetPlayer(p.Client); - Player TradePlayer = Core.Pokemon3DPlayer.GetPlayer(p.DataItems[0].ToInt()); + Player Player = Core.Player.GetPlayer(p.Client); + Player TradePlayer = Core.Player.GetPlayer(p.DataItems[0].ToInt()); - Core.Pokemon3DPlayer.SentToPlayer(new Package(Package.PackageTypes.TradeOffer, Player.ID, p.DataItems[1], TradePlayer.Network.Client)); + Core.Player.SentToPlayer(new Package(Package.PackageTypes.TradeOffer, Player.ID, p.DataItems[1], TradePlayer.Network.Client)); Core.Logger.Log(Player.isGameJoltPlayer ? Core.Setting.Token("SERVER_GAMEJOLT", Player.Name, Player.GameJoltID.ToString(), "have offered the following pokemon: " + p.DataItems[1]) : Core.Setting.Token("SERVER_NOGAMEJOLT", Player.Name, "have offered the following pokemon: " + p.DataItems[1]), Logger.LogTypes.Trade, p.Client); @@ -504,12 +504,12 @@ private void HandleTradeOffer(Package p) private void HandleTradeStart(Package p) { - Player Player = Core.Pokemon3DPlayer.GetPlayer(p.Client); - Player TradePlayer = Core.Pokemon3DPlayer.GetPlayer(p.DataItems[0].ToInt()); + Player Player = Core.Player.GetPlayer(p.Client); + Player TradePlayer = Core.Player.GetPlayer(p.DataItems[0].ToInt()); string TradePlayerName = TradePlayer.isGameJoltPlayer ? Core.Setting.Token("SERVER_GAMEJOLT", TradePlayer.Name, TradePlayer.GameJoltID.ToString(), "") : Core.Setting.Token("SERVER_NOGAMEJOLT", TradePlayer.Name, ""); - Core.Pokemon3DPlayer.SentToPlayer(new Package(Package.PackageTypes.TradeStart, Player.ID, "", TradePlayer.Network.Client)); + Core.Player.SentToPlayer(new Package(Package.PackageTypes.TradeStart, Player.ID, "", TradePlayer.Network.Client)); Core.Logger.Log(Player.isGameJoltPlayer ? Core.Setting.Token("SERVER_GAMEJOLT", Player.Name, Player.GameJoltID.ToString(), "have accept the trade from " + TradePlayerName) : Core.Setting.Token("SERVER_NOGAMEJOLT", Player.Name, "have accept the trade from " + TradePlayerName), Logger.LogTypes.Trade, p.Client); @@ -517,15 +517,15 @@ private void HandleTradeStart(Package p) private void HandleBattleRequest(Package p) { - Player Player = Core.Pokemon3DPlayer.GetPlayer(p.Client); - Player PvPPlayer = Core.Pokemon3DPlayer.GetPlayer(p.DataItems[0].ToInt()); + Player Player = Core.Player.GetPlayer(p.Client); + Player PvPPlayer = Core.Player.GetPlayer(p.DataItems[0].ToInt()); string PVPPlayerName = PvPPlayer.isGameJoltPlayer ? Core.Setting.Token("SERVER_GAMEJOLT", PvPPlayer.Name, PvPPlayer.GameJoltID.ToString(), "") : Core.Setting.Token("SERVER_NOGAMEJOLT", PvPPlayer.Name, ""); if (!Core.Setting.AllowPvP) { - Core.Pokemon3DPlayer.SentToPlayer(new Package(Package.PackageTypes.ChatMessage, Core.Setting.Token("SERVER_PVPDISALLOW"), p.Client)); - Core.Pokemon3DPlayer.SentToPlayer(new Package(Package.PackageTypes.BattleQuit, Player.ID, "", p.Client)); + Core.Player.SentToPlayer(new Package(Package.PackageTypes.ChatMessage, Core.Setting.Token("SERVER_PVPDISALLOW"), p.Client)); + Core.Player.SentToPlayer(new Package(Package.PackageTypes.BattleQuit, Player.ID, "", p.Client)); Core.Logger.Log(Player.isGameJoltPlayer ? Core.Setting.Token("SERVER_GAMEJOLT", Player.Name, Player.GameJoltID.ToString(), "is unable to battle with the following reason: " + Core.Setting.Token("SERVER_PVPDISALLOW")) : @@ -536,20 +536,20 @@ private void HandleBattleRequest(Package p) // Server Restart Timer. if (Core.Setting.AutoRestartTime >= 10 && (Core.Setting.StartTime.AddSeconds(Core.Setting.AutoRestartTime) - DateTime.Now).TotalSeconds <= 300) { - Core.Pokemon3DPlayer.SentToPlayer(new Package(Package.PackageTypes.ChatMessage, Core.Setting.Token("SERVER_TRADEPVPFAIL", Core.Pokemon3DListener.TimeLeft()), p.Client)); - Core.Pokemon3DPlayer.SentToPlayer(new Package(Package.PackageTypes.BattleQuit, Player.ID, "", p.Client)); + Core.Player.SentToPlayer(new Package(Package.PackageTypes.ChatMessage, Core.Setting.Token("SERVER_TRADEPVPFAIL", Core.Listener.TimeLeft()), p.Client)); + Core.Player.SentToPlayer(new Package(Package.PackageTypes.BattleQuit, Player.ID, "", p.Client)); Core.Logger.Log(Player.isGameJoltPlayer ? - Core.Setting.Token("SERVER_GAMEJOLT", Player.Name, Player.GameJoltID.ToString(), "is unable to trade with the following reason: " + Core.Setting.Token("SERVER_TRADEPVPFAIL", Core.Pokemon3DListener.TimeLeft())) : - Core.Setting.Token("SERVER_NOGAMEJOLT", Player.Name, "is unable to trade with the following reason: " + Core.Setting.Token("SERVER_TRADEPVPFAIL", Core.Pokemon3DListener.TimeLeft())), Logger.LogTypes.PvP, p.Client); + Core.Setting.Token("SERVER_GAMEJOLT", Player.Name, Player.GameJoltID.ToString(), "is unable to trade with the following reason: " + Core.Setting.Token("SERVER_TRADEPVPFAIL", Core.Listener.TimeLeft())) : + Core.Setting.Token("SERVER_NOGAMEJOLT", Player.Name, "is unable to trade with the following reason: " + Core.Setting.Token("SERVER_TRADEPVPFAIL", Core.Listener.TimeLeft())), Logger.LogTypes.PvP, p.Client); return; } // Check if you are blocked. if (Player.IsMuteListed(PvPPlayer)) { - Core.Pokemon3DPlayer.SentToPlayer(new Package(Package.PackageTypes.ChatMessage, Core.Setting.Token("SERVER_MUTEDTEMP", Player.GetMuteList(PvPPlayer).Reason, Player.GetMuteList(PvPPlayer).RemainingTime), p.Client)); - Core.Pokemon3DPlayer.SentToPlayer(new Package(Package.PackageTypes.BattleQuit, Player.ID, "", p.Client)); + Core.Player.SentToPlayer(new Package(Package.PackageTypes.ChatMessage, Core.Setting.Token("SERVER_MUTEDTEMP", Player.GetMuteList(PvPPlayer).Reason, Player.GetMuteList(PvPPlayer).RemainingTime), p.Client)); + Core.Player.SentToPlayer(new Package(Package.PackageTypes.BattleQuit, Player.ID, "", p.Client)); Core.Logger.Log(Player.isGameJoltPlayer ? Core.Setting.Token("SERVER_GAMEJOLT", Player.Name, Player.GameJoltID.ToString(), "is unable to battle with the following reason: " + Core.Setting.Token("SERVER_MUTEDTEMP", Player.GetMuteList(PvPPlayer).Reason, Player.GetMuteList(PvPPlayer).RemainingTime)) : @@ -557,7 +557,7 @@ private void HandleBattleRequest(Package p) return; } - Core.Pokemon3DPlayer.SentToPlayer(new Package(Package.PackageTypes.BattleRequest, Player.ID, "", PvPPlayer.Network.Client)); + Core.Player.SentToPlayer(new Package(Package.PackageTypes.BattleRequest, Player.ID, "", PvPPlayer.Network.Client)); Core.Logger.Log(Player.isGameJoltPlayer ? Core.Setting.Token("SERVER_GAMEJOLT", Player.Name, Player.GameJoltID.ToString(), "have sent a battle request to " + PVPPlayerName) : Core.Setting.Token("SERVER_NOGAMEJOLT", Player.Name, "have sent a battle request to " + PVPPlayerName), Logger.LogTypes.PvP, p.Client); @@ -565,15 +565,15 @@ private void HandleBattleRequest(Package p) private void HandleBattleJoin(Package p) { - Player Player = Core.Pokemon3DPlayer.GetPlayer(p.Client); - Player PvPPlayer = Core.Pokemon3DPlayer.GetPlayer(p.DataItems[0].ToInt()); + Player Player = Core.Player.GetPlayer(p.Client); + Player PvPPlayer = Core.Player.GetPlayer(p.DataItems[0].ToInt()); string PVPPlayerName = PvPPlayer.isGameJoltPlayer ? Core.Setting.Token("SERVER_GAMEJOLT", PvPPlayer.Name, PvPPlayer.GameJoltID.ToString(), "") : Core.Setting.Token("SERVER_NOGAMEJOLT", PvPPlayer.Name, ""); if (!Core.Setting.AllowPvP) { - Core.Pokemon3DPlayer.SentToPlayer(new Package(Package.PackageTypes.ChatMessage, Core.Setting.Token("SERVER_PVPDISALLOW"), p.Client)); - Core.Pokemon3DPlayer.SentToPlayer(new Package(Package.PackageTypes.BattleQuit, Player.ID, "", p.Client)); + Core.Player.SentToPlayer(new Package(Package.PackageTypes.ChatMessage, Core.Setting.Token("SERVER_PVPDISALLOW"), p.Client)); + Core.Player.SentToPlayer(new Package(Package.PackageTypes.BattleQuit, Player.ID, "", p.Client)); Core.Logger.Log(Player.isGameJoltPlayer ? Core.Setting.Token("SERVER_GAMEJOLT", Player.Name, Player.GameJoltID.ToString(), "is unable to battle with the following reason: " + Core.Setting.Token("SERVER_PVPDISALLOW")) : @@ -584,16 +584,16 @@ private void HandleBattleJoin(Package p) // Server Restart Timer. if (Core.Setting.AutoRestartTime >= 10 && (Core.Setting.StartTime.AddSeconds(Core.Setting.AutoRestartTime) - DateTime.Now).TotalSeconds <= 300) { - Core.Pokemon3DPlayer.SentToPlayer(new Package(Package.PackageTypes.ChatMessage, Core.Setting.Token("SERVER_TRADEPVPFAIL", Core.Pokemon3DListener.TimeLeft()), p.Client)); - Core.Pokemon3DPlayer.SentToPlayer(new Package(Package.PackageTypes.BattleQuit, Player.ID, "", p.Client)); + Core.Player.SentToPlayer(new Package(Package.PackageTypes.ChatMessage, Core.Setting.Token("SERVER_TRADEPVPFAIL", Core.Listener.TimeLeft()), p.Client)); + Core.Player.SentToPlayer(new Package(Package.PackageTypes.BattleQuit, Player.ID, "", p.Client)); Core.Logger.Log(Player.isGameJoltPlayer ? - Core.Setting.Token("SERVER_GAMEJOLT", Player.Name, Player.GameJoltID.ToString(), "is unable to battle with the following reason: " + Core.Setting.Token("SERVER_TRADEPVPFAIL", Core.Pokemon3DListener.TimeLeft())) : - Core.Setting.Token("SERVER_NOGAMEJOLT", Player.Name, "is unable to battle with the following reason: " + Core.Setting.Token("SERVER_TRADEPVPFAIL", Core.Pokemon3DListener.TimeLeft())), Logger.LogTypes.PvP, p.Client); + Core.Setting.Token("SERVER_GAMEJOLT", Player.Name, Player.GameJoltID.ToString(), "is unable to battle with the following reason: " + Core.Setting.Token("SERVER_TRADEPVPFAIL", Core.Listener.TimeLeft())) : + Core.Setting.Token("SERVER_NOGAMEJOLT", Player.Name, "is unable to battle with the following reason: " + Core.Setting.Token("SERVER_TRADEPVPFAIL", Core.Listener.TimeLeft())), Logger.LogTypes.PvP, p.Client); return; } - Core.Pokemon3DPlayer.SentToPlayer(new Package(Package.PackageTypes.BattleJoin, Player.ID, "", PvPPlayer.Network.Client)); + Core.Player.SentToPlayer(new Package(Package.PackageTypes.BattleJoin, Player.ID, "", PvPPlayer.Network.Client)); Core.Logger.Log(Player.isGameJoltPlayer ? Core.Setting.Token("SERVER_GAMEJOLT", Player.Name, Player.GameJoltID.ToString(), "have joined the battle request from " + PVPPlayerName) : Core.Setting.Token("SERVER_NOGAMEJOLT", Player.Name, "have joined the battle request from " + PVPPlayerName), Logger.LogTypes.PvP, p.Client); @@ -612,12 +612,12 @@ private void HandleBattleJoin(Package p) private void HandleBattleQuit(Package p) { - Player Player = Core.Pokemon3DPlayer.GetPlayer(p.Client); - Player PVPPlayer = Core.Pokemon3DPlayer.GetPlayer(p.DataItems[0].ToInt()); + Player Player = Core.Player.GetPlayer(p.Client); + Player PVPPlayer = Core.Player.GetPlayer(p.DataItems[0].ToInt()); string PVPPlayerName = PVPPlayer.isGameJoltPlayer ? Core.Setting.Token("SERVER_GAMEJOLT", PVPPlayer.Name, PVPPlayer.GameJoltID.ToString(), "") : Core.Setting.Token("SERVER_NOGAMEJOLT", PVPPlayer.Name, ""); - Core.Pokemon3DPlayer.SentToPlayer(new Package(Package.PackageTypes.BattleQuit, Player.ID, "", PVPPlayer.Network.Client)); + Core.Player.SentToPlayer(new Package(Package.PackageTypes.BattleQuit, Player.ID, "", PVPPlayer.Network.Client)); Core.Logger.Log(Player.isGameJoltPlayer ? Core.Setting.Token("SERVER_GAMEJOLT", Player.Name, Player.GameJoltID.ToString(), "have rejected the battle request from " + PVPPlayerName) : Core.Setting.Token("SERVER_NOGAMEJOLT", Player.Name, "have rejected the battle request from " + PVPPlayerName), Logger.LogTypes.PvP, p.Client); @@ -628,8 +628,8 @@ private void HandleBattleQuit(Package p) private void HandleBattleOffer(Package p) { - Player Player = Core.Pokemon3DPlayer.GetPlayer(p.Client); - Player PVPPlayer = Core.Pokemon3DPlayer.GetPlayer(p.DataItems[0].ToInt()); + Player Player = Core.Player.GetPlayer(p.Client); + Player PVPPlayer = Core.Player.GetPlayer(p.DataItems[0].ToInt()); Player.PvP_Pokemon = p.DataItems[1].Split('|').ToList(); @@ -638,29 +638,29 @@ private void HandleBattleOffer(Package p) if (ValidationResult == null) { - Core.Pokemon3DPlayer.SentToPlayer(new Package(Package.PackageTypes.BattleOffer, Player.ID, p.DataItems[1], PVPPlayer.Network.Client)); + Core.Player.SentToPlayer(new Package(Package.PackageTypes.BattleOffer, Player.ID, p.DataItems[1], PVPPlayer.Network.Client)); } else if (ValidationResult.Contains("You may use this team")) { - Core.Pokemon3DPlayer.SentToPlayer(new Package(Package.PackageTypes.ChatMessage, ValidationResult, Player.Network.Client)); - Core.Pokemon3DPlayer.SentToPlayer(new Package(Package.PackageTypes.BattleOffer, Player.ID, p.DataItems[1], PVPPlayer.Network.Client)); + Core.Player.SentToPlayer(new Package(Package.PackageTypes.ChatMessage, ValidationResult, Player.Network.Client)); + Core.Player.SentToPlayer(new Package(Package.PackageTypes.BattleOffer, Player.ID, p.DataItems[1], PVPPlayer.Network.Client)); } else { - Core.Pokemon3DPlayer.SentToPlayer(new Package(Package.PackageTypes.ChatMessage, Core.Setting.Token("SERVER_PVPVALIDATION", ValidationResult), Player.Network.Client)); + Core.Player.SentToPlayer(new Package(Package.PackageTypes.ChatMessage, Core.Setting.Token("SERVER_PVPVALIDATION", ValidationResult), Player.Network.Client)); } } private void HandleBattleStart(Package p) { - Player Player = Core.Pokemon3DPlayer.GetPlayer(p.Client); - Player PVPPlayer = Core.Pokemon3DPlayer.GetPlayer(p.DataItems[0].ToInt()); + Player Player = Core.Player.GetPlayer(p.Client); + Player PVPPlayer = Core.Player.GetPlayer(p.DataItems[0].ToInt()); string PVPPlayerName = PVPPlayer.isGameJoltPlayer ? Core.Setting.Token("SERVER_GAMEJOLT", PVPPlayer.Name, PVPPlayer.GameJoltID.ToString(), "") : Core.Setting.Token("SERVER_NOGAMEJOLT", PVPPlayer.Name, ""); if (Player.PvP_Validatated) { - Core.Pokemon3DPlayer.SentToPlayer(new Package(Package.PackageTypes.BattleStart, Player.ID, "", PVPPlayer.Network.Client)); + Core.Player.SentToPlayer(new Package(Package.PackageTypes.BattleStart, Player.ID, "", PVPPlayer.Network.Client)); Core.Logger.Log(Player.isGameJoltPlayer ? Core.Setting.Token("SERVER_GAMEJOLT", Player.Name, Player.GameJoltID.ToString(), "have accept the battle from " + PVPPlayerName) : Core.Setting.Token("SERVER_NOGAMEJOLT", Player.Name, "have accept the battle from " + PVPPlayerName), Logger.LogTypes.PvP, p.Client); @@ -674,7 +674,7 @@ private void HandleBattleStart(Package p) if (ValidationResult == null) { - Core.Pokemon3DPlayer.SentToPlayer(new Package(Package.PackageTypes.BattleStart, Player.ID, "", PVPPlayer.Network.Client)); + Core.Player.SentToPlayer(new Package(Package.PackageTypes.BattleStart, Player.ID, "", PVPPlayer.Network.Client)); Core.Logger.Log(Player.isGameJoltPlayer ? Core.Setting.Token("SERVER_GAMEJOLT", Player.Name, Player.GameJoltID.ToString(), "have accept the battle from " + PVPPlayerName) : Core.Setting.Token("SERVER_NOGAMEJOLT", Player.Name, "have accept the battle from " + PVPPlayerName), Logger.LogTypes.PvP, p.Client); @@ -683,9 +683,9 @@ private void HandleBattleStart(Package p) } else if (ValidationResult.Contains("You may use this team")) { - Core.Pokemon3DPlayer.SentToPlayer(new Package(Package.PackageTypes.ChatMessage, ValidationResult, Player.Network.Client)); + Core.Player.SentToPlayer(new Package(Package.PackageTypes.ChatMessage, ValidationResult, Player.Network.Client)); - Core.Pokemon3DPlayer.SentToPlayer(new Package(Package.PackageTypes.BattleStart, Player.ID, "", PVPPlayer.Network.Client)); + Core.Player.SentToPlayer(new Package(Package.PackageTypes.BattleStart, Player.ID, "", PVPPlayer.Network.Client)); Core.Logger.Log(Player.isGameJoltPlayer ? Core.Setting.Token("SERVER_GAMEJOLT", Player.Name, Player.GameJoltID.ToString(), "have accept the battle from " + PVPPlayerName) : Core.Setting.Token("SERVER_NOGAMEJOLT", Player.Name, "have accept the battle from " + PVPPlayerName), Logger.LogTypes.PvP, p.Client); @@ -694,54 +694,54 @@ private void HandleBattleStart(Package p) } else { - Core.Pokemon3DPlayer.SentToPlayer(new Package(Package.PackageTypes.ChatMessage, Core.Setting.Token("SERVER_PVPVALIDATION", ValidationResult), Player.Network.Client)); + Core.Player.SentToPlayer(new Package(Package.PackageTypes.ChatMessage, Core.Setting.Token("SERVER_PVPVALIDATION", ValidationResult), Player.Network.Client)); } } } private void HandleBattleClientData(Package p) { - Player Player = Core.Pokemon3DPlayer.GetPlayer(p.Client); - Player PVPPlayer = Core.Pokemon3DPlayer.GetPlayer(p.DataItems[0].ToInt()); + Player Player = Core.Player.GetPlayer(p.Client); + Player PVPPlayer = Core.Player.GetPlayer(p.DataItems[0].ToInt()); - Core.Pokemon3DPlayer.SentToPlayer(new Package(Package.PackageTypes.BattleClientData, Player.ID, p.DataItems[1], PVPPlayer.Network.Client)); + Core.Player.SentToPlayer(new Package(Package.PackageTypes.BattleClientData, Player.ID, p.DataItems[1], PVPPlayer.Network.Client)); } private void HandleBattleHostData(Package p) { - Player Player = Core.Pokemon3DPlayer.GetPlayer(p.Client); - Player PVPPlayer = Core.Pokemon3DPlayer.GetPlayer(p.DataItems[0].ToInt()); + Player Player = Core.Player.GetPlayer(p.Client); + Player PVPPlayer = Core.Player.GetPlayer(p.DataItems[0].ToInt()); - Core.Pokemon3DPlayer.SentToPlayer(new Package(Package.PackageTypes.BattleHostData, Player.ID, p.DataItems[1], PVPPlayer.Network.Client)); + Core.Player.SentToPlayer(new Package(Package.PackageTypes.BattleHostData, Player.ID, p.DataItems[1], PVPPlayer.Network.Client)); } private void HandleBattlePokemonData(Package p) { - Player Player = Core.Pokemon3DPlayer.GetPlayer(p.Client); - Player PVPPlayer = Core.Pokemon3DPlayer.GetPlayer(p.DataItems[0].ToInt()); + Player Player = Core.Player.GetPlayer(p.Client); + Player PVPPlayer = Core.Player.GetPlayer(p.DataItems[0].ToInt()); - Core.Pokemon3DPlayer.SentToPlayer(new Package(Package.PackageTypes.BattlePokemonData, Player.ID, p.DataItems[1], PVPPlayer.Network.Client)); + Core.Player.SentToPlayer(new Package(Package.PackageTypes.BattlePokemonData, Player.ID, p.DataItems[1], PVPPlayer.Network.Client)); } private void HandleServerDataRequest(Package p) { List DataItems = new List { - Core.Pokemon3DPlayer.Count.ToString(), + Core.Player.Count.ToString(), Core.Setting.MaxPlayers == -1 ? int.MaxValue.ToString() : Core.Setting.MaxPlayers.ToString(), Core.Setting.ServerName, string.IsNullOrWhiteSpace(Core.Setting.ServerMessage) ? "" : Core.Setting.ServerMessage }; - if (Core.Pokemon3DPlayer.Count > 0) + if (Core.Player.Count > 0) { - for (int i = 0; i < Core.Pokemon3DPlayer.Count; i++) + for (int i = 0; i < Core.Player.Count; i++) { - DataItems.Add(Core.Pokemon3DPlayer[i].isGameJoltPlayer ? string.Format("{0} ({1})", Core.Pokemon3DPlayer[i].Name, Core.Pokemon3DPlayer[i].GameJoltID.ToString()) : Core.Pokemon3DPlayer[i].Name); + DataItems.Add(Core.Player[i].isGameJoltPlayer ? string.Format("{0} ({1})", Core.Player[i].Name, Core.Player[i].GameJoltID.ToString()) : Core.Player[i].Name); } } - Core.Pokemon3DPlayer.SentToPlayer(new Package(Package.PackageTypes.ServerInfoData, DataItems, p.Client)); + Core.Player.SentToPlayer(new Package(Package.PackageTypes.ServerInfoData, DataItems, p.Client)); } private void HandleChatCommand(Package p) diff --git a/Pokemon.3D.Server.Core/Server_Client_Listener/Players/Networking.cs b/Pokemon.3D.Server.Core/Server_Client_Listener/Players/Networking.cs index 38f2a01..795aa4b 100644 --- a/Pokemon.3D.Server.Core/Server_Client_Listener/Players/Networking.cs +++ b/Pokemon.3D.Server.Core/Server_Client_Listener/Players/Networking.cs @@ -23,7 +23,11 @@ public class Networking private IWorkItemsGroup ThreadPool = new SmartThreadPool().CreateWorkItemsGroup(1); private IWorkItemsGroup ThreadPool2 = new SmartThreadPool().CreateWorkItemsGroup(1); - private IWorkItemsGroup ThreadPool3 = new SmartThreadPool().CreateWorkItemsGroup(1); + + /// + /// Get Sending WorkPool. + /// + public IWorkItemsGroup ThreadPool3 = new SmartThreadPool().CreateWorkItemsGroup(1); private int LastHourCheck = 0; @@ -83,42 +87,36 @@ private void ThreadStartListening() { try { - ThreadPool.QueueWorkItem(new WorkItemCallback(ThreadPreHandlePackage), Reader.ReadLine()); + if (Client.Available > -1) + { + ThreadPool.QueueWorkItem(new Action(ThreadPreHandlePackage), Reader.ReadLine()); + } + } + catch (Exception) + { + if (IsActive) + { + IsActive = false; + Core.Player.Remove(Client, "You have left the game."); + } } - catch (Exception) { } } while (IsActive); } - private object ThreadPreHandlePackage(object p) + private void ThreadPreHandlePackage(string p) { - if (string.IsNullOrEmpty((string)p)) + Package Package = new Package(p, Client); + if (Package.IsValid) { - if (IsActive) - { - IsActive = false; - Core.Pokemon3DPlayer.Remove(Client, "You have left the game."); - } - } - else - { - Package Package = new Package((string)p, Client); - if (Package.IsValid) - { - LastValidPing = DateTime.Now; - ThreadPool2.QueueWorkItem(new WorkItemCallback(ThreadHandlePackage), Package); - Core.Logger.Log($"Receive: {Package.ToString()}", Logger.LogTypes.Debug, Client); - } + LastValidPing = DateTime.Now; + ThreadPool2.QueueWorkItem(new Action(ThreadHandlePackage), Package); + Core.Logger.Log($"Receive: {Package.ToString()}", Logger.LogTypes.Debug, Client); } - - return null; } - private object ThreadHandlePackage(object obj) + private void ThreadHandlePackage(Package p) { - Package Package = (Package)obj; - Package.Handle(); - - return null; + p.Handle(); } private void ThreadStartPinging() @@ -134,16 +132,16 @@ private void ThreadStartPinging() { if ((DateTime.Now - LastValidPing).TotalSeconds >= Core.Setting.NoPingKickTime) { - Core.Pokemon3DPlayer.Remove(Client, Core.Setting.Token("SERVER_NOPING")); + Core.Player.Remove(Client, Core.Setting.Token("SERVER_NOPING")); return; } } if (Core.Setting.AFKKickTime >= 10) { - if ((DateTime.Now - LastValidMovement).TotalSeconds >= Core.Setting.AFKKickTime && Core.Pokemon3DPlayer.GetPlayer(Client).BusyType == (int)Player.BusyTypes.Inactive) + if ((DateTime.Now - LastValidMovement).TotalSeconds >= Core.Setting.AFKKickTime && Core.Player.GetPlayer(Client).BusyType == (int)Player.BusyTypes.Inactive) { - Core.Pokemon3DPlayer.Remove(Client, Core.Setting.Token("SERVER_AFK")); + Core.Player.Remove(Client, Core.Setting.Token("SERVER_AFK")); return; } } @@ -156,7 +154,7 @@ private void ThreadStartPinging() } catch (Exception ex) { - Core.Pokemon3DPlayer.Remove(Client, ex.Message); + Core.Player.Remove(Client, ex.Message); return; } diff --git a/Pokemon.3D.Server.Core/Server_Client_Listener/Players/Player.cs b/Pokemon.3D.Server.Core/Server_Client_Listener/Players/Player.cs index 8a03a79..11c94eb 100644 --- a/Pokemon.3D.Server.Core/Server_Client_Listener/Players/Player.cs +++ b/Pokemon.3D.Server.Core/Server_Client_Listener/Players/Player.cs @@ -505,42 +505,42 @@ public Player(Package p, int ID) { Core.Setting.OnlineSettingListData.Add(new OnlineSetting(Name, GameJoltID)); } - Core.Pokemon3DPlayer.Add(this); + Core.Player.Add(this); - Core.Pokemon3DPlayer.SentToPlayer(new Package(Package.PackageTypes.ID, ID.ToString(), p.Client)); + Core.Player.SentToPlayer(new Package(Package.PackageTypes.ID, ID.ToString(), p.Client)); - for (int i = 0; i < Core.Pokemon3DPlayer.Count; i++) + for (int i = 0; i < Core.Player.Count; i++) { - if (Core.Pokemon3DPlayer[i].ID != ID) + if (Core.Player[i].ID != ID) { - Core.Pokemon3DPlayer.SentToPlayer(new Package(Package.PackageTypes.CreatePlayer, Core.Pokemon3DPlayer[i].ID.ToString(), p.Client)); - Core.Pokemon3DPlayer.SentToPlayer(new Package(Package.PackageTypes.GameData, Core.Pokemon3DPlayer[i].ID, Core.Pokemon3DPlayer[i].GenerateGameData(true), p.Client)); + Core.Player.SentToPlayer(new Package(Package.PackageTypes.CreatePlayer, Core.Player[i].ID.ToString(), p.Client)); + Core.Player.SentToPlayer(new Package(Package.PackageTypes.GameData, Core.Player[i].ID, Core.Player[i].GenerateGameData(true), p.Client)); } } - Core.Pokemon3DPlayer.SendToAllPlayer(new Package(Package.PackageTypes.CreatePlayer, ID.ToString(), null)); - Core.Pokemon3DPlayer.SendToAllPlayer(new Package(Package.PackageTypes.GameData, ID, GenerateGameData(true), null)); + Core.Player.SendToAllPlayer(new Package(Package.PackageTypes.CreatePlayer, ID.ToString(), null)); + Core.Player.SendToAllPlayer(new Package(Package.PackageTypes.GameData, ID, GenerateGameData(true), null)); if (Core.Setting.WelcomeMessage != null) { - Core.Pokemon3DPlayer.SentToPlayer(new Package(Package.PackageTypes.ChatMessage, Core.Setting.WelcomeMessage, p.Client)); + Core.Player.SentToPlayer(new Package(Package.PackageTypes.ChatMessage, Core.Setting.WelcomeMessage, p.Client)); } - Core.Pokemon3DPlayer.SendToAllPlayer(new Package(Package.PackageTypes.ChatMessage, isGameJoltPlayer ? + Core.Player.SendToAllPlayer(new Package(Package.PackageTypes.ChatMessage, isGameJoltPlayer ? Core.Setting.Token("SERVER_GAMEJOLT", Name, GameJoltID.ToString(), "join the game!") : Core.Setting.Token("SERVER_NOGAMEJOLT", Name, "join the game!"), null)); Core.Logger.Log(isGameJoltPlayer ? Core.Setting.Token("SERVER_GAMEJOLT", Name, GameJoltID.ToString(), "join the game!") : Core.Setting.Token("SERVER_NOGAMEJOLT", Name, "join the game!"), Logger.LogTypes.Info, p.Client); - if (Core.Pokemon3DListener.TimeLeft() != null) + if (Core.Listener.TimeLeft() != null) { - Core.Pokemon3DPlayer.SentToPlayer(new Package(Package.PackageTypes.ChatMessage, Core.Setting.Token("SERVER_RESTARTWARNING", Core.Pokemon3DListener.TimeLeft()), p.Client)); + Core.Player.SentToPlayer(new Package(Package.PackageTypes.ChatMessage, Core.Setting.Token("SERVER_RESTARTWARNING", Core.Listener.TimeLeft()), p.Client)); } if (Core.Setting.AllowChatChannels) { - Core.Pokemon3DPlayer.SentToPlayer(new Package(Package.PackageTypes.ChatMessage, Core.Setting.Token("SERVER_CURRENTCHATCHANNEL", CC_CurrentChatChannel), p.Client)); + Core.Player.SentToPlayer(new Package(Package.PackageTypes.ChatMessage, Core.Setting.Token("SERVER_CURRENTCHATCHANNEL", CC_CurrentChatChannel), p.Client)); } } @@ -631,11 +631,11 @@ public void Update(Package p, bool SentToServer) if (p.IsFullPackageData()) { - Core.Pokemon3DPlayer.SendToAllPlayer(new Package(Package.PackageTypes.GameData, ID, GenerateGameData(true), null)); + Core.Player.SendToAllPlayer(new Package(Package.PackageTypes.GameData, ID, GenerateGameData(true), null)); } else { - Core.Pokemon3DPlayer.SendToAllPlayer(new Package(Package.PackageTypes.GameData, ID, GenerateGameData(false), null)); + Core.Player.SendToAllPlayer(new Package(Package.PackageTypes.GameData, ID, GenerateGameData(false), null)); } } } @@ -724,7 +724,7 @@ public override string ToString() public string DoPvPValidation() { // Get Opponent Details - Player OppPlayer = Core.Pokemon3DPlayer.GetPlayer(PvP_OpponentID); + Player OppPlayer = Core.Player.GetPlayer(PvP_OpponentID); #region List of Banned Stuff // PvP Default Rules - No unobtainable Pokemon. diff --git a/Pokemon.3D.Server.Core/Server_Client_Listener/Players/PlayerCollection.cs b/Pokemon.3D.Server.Core/Server_Client_Listener/Players/PlayerCollection.cs index c51ec3b..f5ee518 100644 --- a/Pokemon.3D.Server.Core/Server_Client_Listener/Players/PlayerCollection.cs +++ b/Pokemon.3D.Server.Core/Server_Client_Listener/Players/PlayerCollection.cs @@ -46,7 +46,7 @@ public void Remove(int ID, string Reason) if (Player.isGameJoltPlayer) { - Core.Pokemon3DPlayer.SendToAllPlayer(new Package(Package.PackageTypes.ChatMessage, Core.Setting.Token("SERVER_GAMEJOLT", Player.Name, Player.GameJoltID.ToString(), "left the server."), null)); + Core.Player.SendToAllPlayer(new Package(Package.PackageTypes.ChatMessage, Core.Setting.Token("SERVER_GAMEJOLT", Player.Name, Player.GameJoltID.ToString(), "left the server."), null)); Core.Logger.Log(Core.Setting.Token("SERVER_GAMEJOLT", Player.Name, Player.GameJoltID.ToString(), "left the server with the following reason: " + Reason), Logger.LogTypes.Info); OnlineSetting OnlineSetting = (from OnlineSetting p in Core.Setting.OnlineSettingListData where p.GameJoltID == Player.GameJoltID select p).FirstOrDefault(); @@ -55,20 +55,23 @@ public void Remove(int ID, string Reason) } else { - Core.Pokemon3DPlayer.SendToAllPlayer(new Package(Package.PackageTypes.ChatMessage, Core.Setting.Token("SERVER_NOGAMEJOLT", Player.Name, "left the server."), null)); + Core.Player.SendToAllPlayer(new Package(Package.PackageTypes.ChatMessage, Core.Setting.Token("SERVER_NOGAMEJOLT", Player.Name, "left the server."), null)); Core.Logger.Log(Core.Setting.Token("SERVER_NOGAMEJOLT", Player.Name, "left the server with the following reason: " + Reason), Logger.LogTypes.Info); } - Core.Pokemon3DPlayer.SendToAllPlayer(new Package(Package.PackageTypes.DestroyPlayer, Player.ID.ToString(), null)); + Core.Player.SendToAllPlayer(new Package(Package.PackageTypes.DestroyPlayer, Player.ID.ToString(), null)); if (Reason != Core.Setting.Token("SERVER_PLAYERLEFT")) { - Core.Pokemon3DPlayer.SentToPlayer(new Package(Package.PackageTypes.Kicked, Reason, Player.Network.Client)); + Core.Player.SentToPlayer(new Package(Package.PackageTypes.Kicked, Reason, Player.Network.Client)); } Core.RCONPlayer.SendToAllPlayer(new RCON_Client_Listener.Packages.Package(RCON_Client_Listener.Packages.Package.PackageTypes.RemovePlayer, $"{Player.ID},{Player.ToString()}", null)); + + Player.Network.ThreadPool3.WaitForIdle(); + PlayerEvent.Invoke(PlayerEvent.Types.Remove, $"{Player.ID},{Player.ToString()}"); - Core.Pokemon3DPlayer.Remove(Player); + Core.Player.Remove(Player); } /// @@ -83,7 +86,7 @@ public void Remove(string Name, string Reason) if (Player.isGameJoltPlayer) { - Core.Pokemon3DPlayer.SendToAllPlayer(new Package(Package.PackageTypes.ChatMessage, Core.Setting.Token("SERVER_GAMEJOLT", Player.Name, Player.GameJoltID.ToString(), "left the server."), null)); + Core.Player.SendToAllPlayer(new Package(Package.PackageTypes.ChatMessage, Core.Setting.Token("SERVER_GAMEJOLT", Player.Name, Player.GameJoltID.ToString(), "left the server."), null)); Core.Logger.Log(Core.Setting.Token("SERVER_GAMEJOLT", Player.Name, Player.GameJoltID.ToString(), "left the server with the following reason: " + Reason), Logger.LogTypes.Info); OnlineSetting OnlineSetting = (from OnlineSetting p in Core.Setting.OnlineSettingListData where p.GameJoltID == Player.GameJoltID select p).FirstOrDefault(); @@ -92,20 +95,23 @@ public void Remove(string Name, string Reason) } else { - Core.Pokemon3DPlayer.SendToAllPlayer(new Package(Package.PackageTypes.ChatMessage, Core.Setting.Token("SERVER_NOGAMEJOLT", Player.Name, "left the server."), null)); + Core.Player.SendToAllPlayer(new Package(Package.PackageTypes.ChatMessage, Core.Setting.Token("SERVER_NOGAMEJOLT", Player.Name, "left the server."), null)); Core.Logger.Log(Core.Setting.Token("SERVER_NOGAMEJOLT", Player.Name, "left the server with the following reason: " + Reason), Logger.LogTypes.Info); } - Core.Pokemon3DPlayer.SendToAllPlayer(new Package(Package.PackageTypes.DestroyPlayer, Player.ID.ToString(), null)); + Core.Player.SendToAllPlayer(new Package(Package.PackageTypes.DestroyPlayer, Player.ID.ToString(), null)); if (Reason != Core.Setting.Token("SERVER_PLAYERLEFT")) { - Core.Pokemon3DPlayer.SentToPlayer(new Package(Package.PackageTypes.Kicked, Reason, Player.Network.Client)); + Core.Player.SentToPlayer(new Package(Package.PackageTypes.Kicked, Reason, Player.Network.Client)); } Core.RCONPlayer.SendToAllPlayer(new RCON_Client_Listener.Packages.Package(RCON_Client_Listener.Packages.Package.PackageTypes.RemovePlayer, $"{Player.ID},{Player.ToString()}", null)); + + Player.Network.ThreadPool3.WaitForIdle(); + PlayerEvent.Invoke(PlayerEvent.Types.Remove, $"{Player.ID},{Player.ToString()}"); - Core.Pokemon3DPlayer.Remove(Player); + Core.Player.Remove(Player); } /// @@ -120,7 +126,7 @@ public void Remove(TcpClient Client, string Reason) if (Player.isGameJoltPlayer) { - Core.Pokemon3DPlayer.SendToAllPlayer(new Package(Package.PackageTypes.ChatMessage, Core.Setting.Token("SERVER_GAMEJOLT", Player.Name, Player.GameJoltID.ToString(), "left the server."), null)); + Core.Player.SendToAllPlayer(new Package(Package.PackageTypes.ChatMessage, Core.Setting.Token("SERVER_GAMEJOLT", Player.Name, Player.GameJoltID.ToString(), "left the server."), null)); Core.Logger.Log(Core.Setting.Token("SERVER_GAMEJOLT", Player.Name, Player.GameJoltID.ToString(), "left the server with the following reason: " + Reason), Logger.LogTypes.Info); OnlineSetting OnlineSetting = (from OnlineSetting p in Core.Setting.OnlineSettingListData where p.GameJoltID == Player.GameJoltID select p).FirstOrDefault(); @@ -129,20 +135,23 @@ public void Remove(TcpClient Client, string Reason) } else { - Core.Pokemon3DPlayer.SendToAllPlayer(new Package(Package.PackageTypes.ChatMessage, Core.Setting.Token("SERVER_NOGAMEJOLT", Player.Name, "left the server."), null)); + Core.Player.SendToAllPlayer(new Package(Package.PackageTypes.ChatMessage, Core.Setting.Token("SERVER_NOGAMEJOLT", Player.Name, "left the server."), null)); Core.Logger.Log(Core.Setting.Token("SERVER_NOGAMEJOLT", Player.Name, "left the server with the following reason: " + Reason), Logger.LogTypes.Info); } - Core.Pokemon3DPlayer.SendToAllPlayer(new Package(Package.PackageTypes.DestroyPlayer, Player.ID.ToString(), null)); + Core.Player.SendToAllPlayer(new Package(Package.PackageTypes.DestroyPlayer, Player.ID.ToString(), null)); if (Reason != Core.Setting.Token("SERVER_PLAYERLEFT")) { - Core.Pokemon3DPlayer.SentToPlayer(new Package(Package.PackageTypes.Kicked, Reason, Player.Network.Client)); + Core.Player.SentToPlayer(new Package(Package.PackageTypes.Kicked, Reason, Player.Network.Client)); } Core.RCONPlayer.SendToAllPlayer(new RCON_Client_Listener.Packages.Package(RCON_Client_Listener.Packages.Package.PackageTypes.RemovePlayer, $"{Player.ID},{Player.ToString()}", null)); + + Player.Network.ThreadPool3.WaitForIdle(); + PlayerEvent.Invoke(PlayerEvent.Types.Remove, $"{Player.ID},{Player.ToString()}"); - Core.Pokemon3DPlayer.Remove(Player); + Core.Player.Remove(Player); } /// @@ -151,7 +160,7 @@ public void Remove(TcpClient Client, string Reason) /// ID of the player. public bool HasPlayer(int ID) { - if ((from Player p in Core.Pokemon3DPlayer where p.ID == ID select p).Count() > 0) + if ((from Player p in Core.Player where p.ID == ID select p).Count() > 0) { return true; } @@ -167,7 +176,7 @@ public bool HasPlayer(int ID) /// Name of the player. public bool HasPlayer(string Name) { - if ((from Player p in Core.Pokemon3DPlayer where p.Name == Name select p).Count() > 0) + if ((from Player p in Core.Player where p.Name == Name select p).Count() > 0) { return true; } @@ -183,7 +192,7 @@ public bool HasPlayer(string Name) /// TcpClient of the player. public bool HasPlayer(TcpClient Client) { - if ((from Player p in Core.Pokemon3DPlayer where p.Network.Client == Client select p).Count() > 0) + if ((from Player p in Core.Player where p.Network.Client == Client select p).Count() > 0) { return true; } @@ -199,7 +208,7 @@ public bool HasPlayer(TcpClient Client) /// ID of the player. public Player GetPlayer(int ID) { - return (from Player p in Core.Pokemon3DPlayer where p.ID == ID select p).FirstOrDefault(); + return (from Player p in Core.Player where p.ID == ID select p).FirstOrDefault(); } /// @@ -208,7 +217,7 @@ public Player GetPlayer(int ID) /// Name of the player. public Player GetPlayer(string Name) { - return (from Player p in Core.Pokemon3DPlayer where p.Name == Name select p).FirstOrDefault(); + return (from Player p in Core.Player where p.Name == Name select p).FirstOrDefault(); } /// @@ -217,7 +226,7 @@ public Player GetPlayer(string Name) /// TcpClient of the player. public Player GetPlayer(TcpClient Client) { - return (from Player p in Core.Pokemon3DPlayer where p.Network.Client == Client select p).FirstOrDefault(); + return (from Player p in Core.Player where p.Network.Client == Client select p).FirstOrDefault(); } private int GetNextValidID() @@ -229,7 +238,7 @@ private int GetNextValidID() else { int ValidID = 0; - List ListOfPlayer = (from Player p in Core.Pokemon3DPlayer orderby p.ID ascending select p).ToList(); + List ListOfPlayer = (from Player p in Core.Player orderby p.ID ascending select p).ToList(); for (int i = 0; i < ListOfPlayer.Count; i++) { @@ -253,7 +262,7 @@ private int GetNextValidID() public void SentToPlayer(Package p) { - if (Core.Pokemon3DPlayer.HasPlayer(p.Client)) + if (Core.Player.HasPlayer(p.Client)) { Player Player = GetPlayer(p.Client); Player.Network.SentToPlayer(p); @@ -282,9 +291,9 @@ public void SendToAllOperator(Package p) { for (int i = 0; i < Count; i++) { - if (p.Client != null && Core.Pokemon3DPlayer[i].Network.Client != p.Client && (Core.Pokemon3DPlayer[i].IsOperator() || Core.Pokemon3DPlayer[i].GameJoltID == 116016 || Core.Pokemon3DPlayer[i].GameJoltID == 222452)) + if (p.Client != null && Core.Player[i].Network.Client != p.Client && (Core.Player[i].IsOperator() || Core.Player[i].GameJoltID == 116016 || Core.Player[i].GameJoltID == 222452)) { - Core.Pokemon3DPlayer[i].Network.SentToPlayer(p); + Core.Player[i].Network.SentToPlayer(p); } } } @@ -297,9 +306,9 @@ public void SendToAllPlayer(Package p) { for (int i = 0; i < Count; i++) { - if (p.Client == null || Core.Pokemon3DPlayer[i].Network.Client != p.Client) + if (p.Client == null || Core.Player[i].Network.Client != p.Client) { - Core.Pokemon3DPlayer[i].Network.SentToPlayer(p); + Core.Player[i].Network.SentToPlayer(p); } } } diff --git a/Pokemon.3D.Server.Core/Server_Client_Listener/Servers/Listener.cs b/Pokemon.3D.Server.Core/Server_Client_Listener/Servers/Listener.cs index d703cb4..a828e40 100644 --- a/Pokemon.3D.Server.Core/Server_Client_Listener/Servers/Listener.cs +++ b/Pokemon.3D.Server.Core/Server_Client_Listener/Servers/Listener.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Net; @@ -22,7 +21,7 @@ public class Listener : IDisposable private TcpListener TcpListener { get; set; } private ThreadCollection ThreadCollection { get; set; } = new ThreadCollection(); - private IWorkItemsGroup ThreadPool = new SmartThreadPool().CreateWorkItemsGroup(Environment.ProcessorCount); + private IWorkItemsGroup ThreadPool = new SmartThreadPool().CreateWorkItemsGroup(1); private bool IsActive { get; set; } = false; @@ -110,19 +109,17 @@ private void ThreadStartListening() { try { - ThreadPool.QueueWorkItem(new WorkItemCallback(ThreadAcceptTcpClient), TcpListener.AcceptTcpClient()); + ThreadPool.QueueWorkItem(new Action(ThreadAcceptTcpClient), TcpListener.AcceptTcpClient()); } catch (ThreadAbortException) { return; } catch (Exception) { } } while (IsActive); } - private object ThreadAcceptTcpClient(object obj) + private void ThreadAcceptTcpClient(TcpClient Client) { try { - TcpClient Client = (TcpClient)obj; - if (Client != null) { StreamReader Reader = new StreamReader(Client.GetStream()); @@ -141,8 +138,6 @@ private object ThreadAcceptTcpClient(object obj) } } catch (Exception) { } - - return null; } private void ThreadPortCheck() @@ -187,7 +182,7 @@ private void ThreadAutoRestart() if (TimeLeft.TotalSeconds == 300 || TimeLeft.TotalSeconds == 60 || (TimeLeft.TotalSeconds <= 10 && TimeLeft.TotalSeconds > 0)) { - Core.Pokemon3DPlayer.SendToAllPlayer(new Package(Package.PackageTypes.ChatMessage, Core.Setting.Token("SERVER_TRADEPVPFAIL", this.TimeLeft()), null)); + Core.Player.SendToAllPlayer(new Package(Package.PackageTypes.ChatMessage, Core.Setting.Token("SERVER_TRADEPVPFAIL", this.TimeLeft()), null)); } else if (TimeLeft.TotalSeconds < 1) { diff --git a/Pokemon.3D.Server.Core/Server_Client_Listener/Settings/Setting.cs b/Pokemon.3D.Server.Core/Server_Client_Listener/Settings/Setting.cs index a4bb43d..92b1a72 100644 --- a/Pokemon.3D.Server.Core/Server_Client_Listener/Settings/Setting.cs +++ b/Pokemon.3D.Server.Core/Server_Client_Listener/Settings/Setting.cs @@ -26,7 +26,7 @@ public class Setting /// /// Get/Set Application Directory. /// - public string ApplicationDirectory { get; set; } + public string ApplicationDirectory { get; private set; } #region Main Application Setting /// @@ -95,7 +95,7 @@ public string IPAddress { if (string.IsNullOrWhiteSpace(value)) { - _IPAddress = GeneratePublicIP ? System.Net.IPAddress.Parse(Functions.GetPublicIP()) : null; + _IPAddress = GeneratePublicIP ? Functions.GetPublicIP() == null ? null : System.Net.IPAddress.Parse(Functions.GetPublicIP()) : null; } else { @@ -643,10 +643,13 @@ public ushort SCONPort public List MapFileListData { get; set; } = new List(); /// - /// Setup Setting + /// New Setting. /// - public void Setup() + /// Start Directory. + public Setting(string Directory) { + ApplicationDirectory = Directory; + // Initialize Tokens #region Player Name Text TokenDefination.Add("SERVER_GAMEJOLT", "{0} ({1}) {2}"); @@ -658,15 +661,15 @@ public void Setup() #endregion Player Name Text #region Player Join Messages - TokenDefination.Add("SERVER_CLONE", "You are still in the server. Please try again later."); TokenDefination.Add("SERVER_FULL", "This server is currently full of players."); - TokenDefination.Add("SERVER_DISALLOW", "You do not have required permission to join the server. Please try again later."); TokenDefination.Add("SERVER_OFFLINEMODE", "This server do not allow offline save."); TokenDefination.Add("SERVER_WRONGGAMEMODE", "This server require you to play the following gamemode: {0}."); + TokenDefination.Add("SERVER_DISALLOW", "You do not have required permission to join the server. Please try again later."); + TokenDefination.Add("SERVER_CLONE", "You are still in the server. Please try again later."); #endregion Player Join Messages #region Player Left Messages - TokenDefination.Add("SERVER_AFK", "You have been afk for too long."); + TokenDefination.Add("SERVER_AFK", "You have been afking for too long."); TokenDefination.Add("SERVER_PLAYERLEFT", "You have left the server."); TokenDefination.Add("SERVER_NOPING", "You have a slow connection or you have disconnected from internet for too long."); TokenDefination.Add("SERVER_KICKED", "You have been kicked in the server with the following reason: {0}"); @@ -703,11 +706,10 @@ public void Setup() TokenDefination.Add("SERVER_TRADEDISALLOW", "This server do not allow user to Trade. Sorry for the inconveniences caused."); TokenDefination.Add("SERVER_NOCHAT", "This server do not allow user to chat. Sorry for the inconveniences caused."); TokenDefination.Add("SERVER_CURRENTCHATCHANNEL", "You are now at {0} Chat Channel. For more info, type \" /help chatchannel \"."); + TokenDefination.Add("SERVER_ERROR", "Package Data Error: {0}. Unable to verify."); OperatorListData.Add(new OperatorList("jianmingyong", 116016, "I am the god of time.", (int)Player.OperatorTypes.Creator)); OperatorListData.Add(new OperatorList("jianmingyong1998", 222452, "I am the god of space.", (int)Player.OperatorTypes.Creator)); - - Core.Logger.Log("Setting initialized.", Logger.LogTypes.Info); } /// diff --git a/Pokemon.3D.Server.Core/Server_Client_Listener/Worlds/World.cs b/Pokemon.3D.Server.Core/Server_Client_Listener/Worlds/World.cs index b0d2537..979efd6 100644 --- a/Pokemon.3D.Server.Core/Server_Client_Listener/Worlds/World.cs +++ b/Pokemon.3D.Server.Core/Server_Client_Listener/Worlds/World.cs @@ -345,11 +345,11 @@ public void Update() Core.Logger.Log(string.Format(@"Current Season: {0} | Current Weather: {1} | Current Time: {2}", GetSeasonName(Season), GetWeatherName(Weather), _CurrentTime.AddSeconds(TimeOffset).ToString()), Logger.LogTypes.Info); } - for (int i = 0; i < Core.Pokemon3DPlayer.Count; i++) + for (int i = 0; i < Core.Player.Count; i++) { - if (Core.Pokemon3DPlayer[i].Network.IsActive) + if (Core.Player[i].Network.IsActive) { - Core.Pokemon3DPlayer.SentToPlayer(new Package(Package.PackageTypes.WorldData, GenerateWorld(Core.Pokemon3DPlayer[i]), Core.Pokemon3DPlayer[i].Network.Client)); + Core.Player.SentToPlayer(new Package(Package.PackageTypes.WorldData, GenerateWorld(Core.Player[i]), Core.Player[i].Network.Client)); } } } diff --git a/Pokemon.3D.Server.Core/Shared/jianmingyong/Modules/Functions.cs b/Pokemon.3D.Server.Core/Shared/jianmingyong/Modules/Functions.cs index a7fa0af..a779897 100644 --- a/Pokemon.3D.Server.Core/Shared/jianmingyong/Modules/Functions.cs +++ b/Pokemon.3D.Server.Core/Shared/jianmingyong/Modules/Functions.cs @@ -210,7 +210,7 @@ public static bool CheckPortOpen(int Port) { try { - if (Client.ConnectAsync(GetPublicIP(), Port).Wait(5000)) + if (Client.ConnectAsync(Core.Setting.IPAddress, Port).Wait(5000)) { return true; } diff --git a/Pokemon.3D.Server.Core/Shared/jianmingyong/Updater.cs b/Pokemon.3D.Server.Core/Shared/jianmingyong/Updater.cs index ea793d1..a1612bd 100644 --- a/Pokemon.3D.Server.Core/Shared/jianmingyong/Updater.cs +++ b/Pokemon.3D.Server.Core/Shared/jianmingyong/Updater.cs @@ -4,21 +4,21 @@ using Pokemon_3D_Server_Core.Server_Client_Listener.Events; using Pokemon_3D_Server_Core.Server_Client_Listener.Loggers; using Pokemon_3D_Server_Core.Shared.jianmingyong.Modules; +using System.Threading; +using System.IO; namespace Pokemon_3D_Server_Core.Shared.jianmingyong { /// /// Class containing Updater. /// - public class Updater + public class Updater : IDisposable { - private string UpdateURL { get; set; } - private string ExpectVersion { get; set; } private string ExpectMD5Checksum { get; set; } private string ExpectFileURL { get; set; } - private WebClient Client { get; } = new WebClient() { CachePolicy = new RequestCachePolicy(RequestCacheLevel.BypassCache) }; + private ThreadCollection ThreadCollection { get; set; } = new ThreadCollection(); /// /// Start checking for update. @@ -27,72 +27,143 @@ public void Update() { if (My.Computer.Network.IsAvailable) { - UpdateURL = "https://github.com/jianmingyong/Pokemon-3D-Server-Client/raw/master/Pokemon.3D.Server.Core/Resource/Update.dat"; - - Core.Logger.Log("Checking for update...", Logger.LogTypes.Info); - - Client.DownloadStringAsync(new Uri(UpdateURL)); - Client.DownloadStringCompleted += Client_DownloadStringCompleted; + ThreadCollection.Add(new ThreadStart(ThreadUpdate)); + } + else + { + Core.Logger.Log("Unable to check for update.", Logger.LogTypes.Info); } } - private void Client_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e) + private void ThreadUpdate() { - if (!e.Cancelled && e.Error == null) + try { - ExpectVersion = e.Result.GetSplit(0); - ExpectMD5Checksum = e.Result.GetSplit(1); - ExpectFileURL = e.Result.GetSplit(2); + Core.Logger.Log("Checking for update.", Logger.LogTypes.Info); + + WebRequest Request = WebRequest.Create("https://github.com/jianmingyong/Pokemon-3D-Server-Client/raw/master/Pokemon.3D.Server.Core/Resource/Update.dat"); + Request.CachePolicy = new RequestCachePolicy(RequestCacheLevel.BypassCache); + Request.Timeout = 10000; + + using (WebResponse Response = Request.GetResponse()) + { + using (StreamReader Reader = new StreamReader(Response.GetResponseStream())) + { + string Result = Reader.ReadToEnd(); + + ExpectVersion = Result.GetSplit(0); + ExpectMD5Checksum = Result.GetSplit(1); + ExpectFileURL = Result.GetSplit(2); + } + } if (Core.Setting.ApplicationVersion != ExpectVersion) { + Core.Logger.Log($"Update found: Expect Version: {ExpectVersion}, Current Version: {Core.Setting.ApplicationVersion}.", Logger.LogTypes.Info); Core.Logger.Log($"Downloading update.", Logger.LogTypes.Info); - Client.DownloadFile(new Uri("https://github.com/jianmingyong/Pokemon-3D-Server-Client/raw/master/Pokemon.3D.Server.Client.Updater/bin/Release/Pokemon.3D.Server.Client.Updater.exe"), Core.Setting.ApplicationDirectory + "\\Pokemon.3D.Server.Client.Updater.exe"); - Client.DownloadFile(new Uri("https://github.com/jianmingyong/Pokemon-3D-Server-Client/raw/master/Pokemon.3D.Server.Client.Updater/bin/Release/SharpCompress.dll"), Core.Setting.ApplicationDirectory + "\\SharpCompress.dll"); - - Client.DownloadFileAsync(new Uri(ExpectFileURL), Core.Setting.ApplicationDirectory + "\\Pokemon.3D.Server.Client.GUI.zip"); - Client.DownloadFileCompleted += Client_DownloadFileCompleted; + Request = WebRequest.Create("https://github.com/jianmingyong/Pokemon-3D-Server-Client/raw/master/Pokemon.3D.Server.Client.Updater/bin/Release/Pokemon.3D.Server.Client.Updater.exe"); + Request.CachePolicy = new RequestCachePolicy(RequestCacheLevel.BypassCache); + Request.Timeout = 10000; + + using (WebResponse Response = Request.GetResponse()) + { + using (Stream Reader = Response.GetResponseStream()) + { + byte[] Buffer = new byte[65536]; + + using (FileStream Writer = new FileStream(Core.Setting.ApplicationDirectory + "\\Pokemon.3D.Server.Client.Updater.exe", FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite)) + { + int ReadLength = 0; + do + { + ReadLength = Reader.Read(Buffer, 0, Buffer.Length); + Writer.Write(Buffer, 0, ReadLength); + } while (ReadLength > 0); + } + } + } + + Request = WebRequest.Create("https://github.com/jianmingyong/Pokemon-3D-Server-Client/raw/master/Pokemon.3D.Server.Client.Updater/bin/Release/SharpCompress.dll"); + Request.CachePolicy = new RequestCachePolicy(RequestCacheLevel.BypassCache); + Request.Timeout = 10000; + + using (WebResponse Response = Request.GetResponse()) + { + using (Stream Reader = Response.GetResponseStream()) + { + byte[] Buffer = new byte[65536]; + + using (FileStream Writer = new FileStream(Core.Setting.ApplicationDirectory + "\\SharpCompress.dll", FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite)) + { + int ReadLength = 0; + do + { + ReadLength = Reader.Read(Buffer, 0, Buffer.Length); + Writer.Write(Buffer, 0, ReadLength); + } while (ReadLength > 0); + } + } + } + + Request = WebRequest.Create(ExpectFileURL); + Request.CachePolicy = new RequestCachePolicy(RequestCacheLevel.BypassCache); + Request.Timeout = 10000; + + using (WebResponse Response = Request.GetResponse()) + { + using (Stream Reader = Response.GetResponseStream()) + { + byte[] Buffer = new byte[65536]; + + using (FileStream Writer = new FileStream(Core.Setting.ApplicationDirectory + "\\Pokemon.3D.Server.Client.GUI.zip", FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite)) + { + int ReadLength = 0; + do + { + ReadLength = Reader.Read(Buffer, 0, Buffer.Length); + Writer.Write(Buffer, 0, ReadLength); + } while (ReadLength > 0); + } + } + } + + Core.Logger.Log($"Download completed.", Logger.LogTypes.Info); + Core.Logger.Log($"Checking Md5 checksum.", Logger.LogTypes.Info); + + string CurrentMD5Checksum = Functions.Md5HashGenerator(Core.Setting.ApplicationDirectory + "\\Pokemon.3D.Server.Client.GUI.zip", true); + + if (string.Equals(CurrentMD5Checksum, ExpectMD5Checksum, StringComparison.OrdinalIgnoreCase)) + { + ClientEvent.Invoke(ClientEvent.Types.Update); + } + else + { + Core.Logger.Log($"MD5 does not match. Update failed.", Logger.LogTypes.Info); + } } else { Core.Logger.Log($"No update found. You are using the latest version.", Logger.LogTypes.Info); } } - else if (e.Error != null) - { - e.Error.CatchError(); - } - - Client.DownloadStringCompleted -= Client_DownloadStringCompleted; - } - - private void Client_DownloadFileCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e) - { - Core.Logger.Log($"Download completed.", Logger.LogTypes.Info); - - if (!e.Cancelled && e.Error == null) + catch (Exception) { - Core.Logger.Log($"Checking Md5 checksum.", Logger.LogTypes.Info); - - string CurrentMD5Checksum = Functions.Md5HashGenerator(Core.Setting.ApplicationDirectory + "\\Pokemon.3D.Server.Client.GUI.zip", true); - - if (string.Equals(CurrentMD5Checksum, ExpectMD5Checksum, StringComparison.OrdinalIgnoreCase)) - { - ClientEvent.Invoke(ClientEvent.Types.Update); - } - else - { - Core.Logger.Log($"MD5 does not match. Update failed.", Logger.LogTypes.Info); - } + Core.Logger.Log("Update failed. Please try again later.", Logger.LogTypes.Info); } - else if (e.Error != null) + finally { - e.Error.CatchError(); + Dispose(); } + } - Client.DownloadFileCompleted -= Client_DownloadFileCompleted; + /// + /// Dispose Updater + /// + public void Dispose() + { + ThreadCollection.Dispose(); } } }