public MainForm() { InitializeComponent(); mc = new MinecraftHandler("rules.txt", "kits.xml", "banned-players.txt", "player.txt", "admins.txt", "MineCraftAdmin.cfg"); Tunnel = new TcpTunnelServer(mc); mc.ServerStarted += new EventHandler(mc_ServerStarted); mc.ServerStopped += new EventHandler(mc_ServerStopped); mc.PlayerJoined += new MinecraftHandler.OnPlayerjoined(mc_PlayerJoined); mc.PlayerLeft += new MinecraftHandler.OnPlayerLeft(mc_PlayerLeft); mc.OutputDataReceived += new MinecraftHandler.OnOutputDataReceived(mc_OutputDataReceived); mc.ServerExited += new MinecraftHandler.OnServerExited(mc_ServerExited); LoadModules(); ReadFromConfig(); //CheckIfRestartOrBackup(); this.Text = "Zicore's Minecraft Admintool - © 2010-2011 - v" + Application.ProductVersion; mc.Version = Application.ProductVersion; restart = new Restart(mc); this.listLoadedPlugins.DataSource = mc.Plugins; //mc.SaveCompleted += new MinecraftHandler.OnSaveCompletedDelegate(mc_SaveCompleted); web = new WebHandler(mc, Tunnel); web.Start(); GenerateTaskColumns(); }
public ConfigForm(MinecraftHandler mc) { InitializeComponent(); InitComboBoxes(); this.Load += new EventHandler(ConfigForm_Load); NetworkInterface[] interfaces = NetworkInterface.GetAllNetworkInterfaces(); //comboBoxSelectedDevice.DataSource = interfaces; //comboBoxSelectedDevice.DisplayMember = "Name"; this.mc = mc; this.numericGiveLimit.Value = mc.Config.GiveLimit; this.tbJavaPath.Text = mc.Config.Java; this.tbMODT.Lines = mc.Config.Modt; this.tbRules.Lines = mc.Config.Rules; this.tbStartparamters.Text = mc.Config.Startparameters; this.tbMinecraftExecutable.Text = mc.Config.Minecraft; this.tbWhitelistFile.Text = mc.Config.WhiteListFile; this.chkWhitelist.Checked = mc.Config.WhiteListMode; this.tbCommandChar.Text = mc.Config.CommandChar; this.chkAutomatedStartServer.Checked = mc.Config.AutomatedServerStart; this.chkForceSaveAndExit.Checked = mc.Config.ForceSaveAndExit; this.chkCommandResponse.Checked = mc.Config.CommandExecutedResponse; this.tbResponsePrefix.Text = mc.Config.ResponsePrefix; this.comboBoxPrivateMessageColor.SelectedValue = mc.Config.ResponseColorChar; this.comboBoxServerMessageColor.SelectedValue = mc.Config.ServerBroadcastColorChar; this.comboFirstChatLine.SelectedValue = mc.Config.LineFirstColorKey; this.comboSecondChatLine.SelectedValue = mc.Config.LineSecondColorKey; this.chkAutoUpdate.Checked = mc.Config.AutomatedUpdates; this.tbChatDateTimeFormatString.Text = mc.Config.ChatDateTimeFormat; this.chkCurrencyEnabled.Checked = mc.Config.CurrencySystemEnabled; this.numericMoneyAmount.Value = mc.Config.CurrencyAmountInCycle; this.numericMoneyCycle.Value = mc.Config.CurrencyCycleMinutes; this.tbCurrencySymbol.Text = mc.Config.CurrencySymbol; this.tbCycleMessage.Text = mc.Config.CurrencyCycleMessage; this.tbServerName.Text = mc.Config.ServerName; //this.chkStreamToServerlist.Checked = mc.Config.StreamEnabled; this.tbDatabaseHost.Text = mc.Config.DatabaseHost; this.numDatabasePort.Value = mc.Config.DatabasePort; this.tbDatabaseUser.Text = mc.Config.DatabaseUser; this.tbDatabasePassword.Text = mc.Config.DatabasePassword; this.numInitialAmount.Value = mc.Config.InitialCurrencyAmount; this.tbBackupFolder.Text = mc.Config.BackupFolder; this.chkForwardUnkown.Checked = mc.Config.ForwardUnkownCommands; this.chkSendUnkownCommand.Checked = mc.Config.SendUnkownCommandResponse; this.chkChannelBasedChat.Checked = mc.Config.ChannelModeChat; this.chkUsingAlternateGive.Checked = mc.Config.UsingAlternateGive; this.tbWorldFolder.Text = mc.Config.WorldPath; this.lbGuid.Text = mc.Config.GuidString; }
public PricesBlocksForm(MinecraftHandler mc) { InitializeComponent(); dgvBadBlocks.AutoGenerateColumns = false; UpdateCombobox(0); GenerateColumns(); this.mc = mc; this._blocks = mc.PricedBlocks; LoadDataSource(); this.Dock = DockStyle.Fill; }
public Playerlist(MinecraftHandler mc) { InitializeComponent(); this.mc = mc; RefreshPlayerlist(); mc.PlayerJoined += new MinecraftHandler.OnPlayerjoined(mc_PlayerJoined); mc.PlayerLeft += new MinecraftHandler.OnPlayerLeft(mc_PlayerLeft); comboBoxPlayers.DataSource = mc.Player; this.Dock = DockStyle.Fill; }
public WebHandler(MinecraftHandler mc, TcpTunnelServer tunnel) { this.tunnel = tunnel; this.mc = mc; string host = mc.Config.DatabaseHost; string user = mc.Config.DatabaseUser; string pass = mc.Config.DatabasePassword; string database = mc.Config.Database; int port = mc.Config.DatabasePort; sql = MySQLConnector.GetInstance(); zma = new ZmaSQLConnection(); }
public ClientNpc(MinecraftHandler mc, String name, String password, String nameTo) { this.name = name; this.password = password; this.mc = mc; worker.WorkerReportsProgress = true; worker.WorkerSupportsCancellation = true; worker.DoWork += new DoWorkEventHandler(worker_DoWork); worker.ProgressChanged += new ProgressChangedEventHandler(worker_ProgressChanged); worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(worker_RunWorkerCompleted); mc.Npcs[name] = this; teleportTo = nameTo; }
public GroupEditor(MinecraftHandler mc) { InitializeComponent(); try { dgvLevels.AutoGenerateColumns = false; GenerateColumns(); this.mc = mc; _levelCollection = GroupCollectionSingletone.GetInstance(); RefreshAvailableCommands(); dgvLevels.DataSource = _levelCollection.Items; UpdateDataGrid(0); } catch { } this.Dock = DockStyle.Fill; }
public KitEditor(MinecraftHandler mc) { InitializeComponent(); this.mc = mc; mc.Items.ReadFromFile(); try { _levels = GroupCollectionSingletone.GetInstance(); comboBoxLevel.DataSource = null; comboBoxLevel.DataSource = _levels.Items; } catch { } RefreshKitlist(); UpdateSelectedKit(); this.Dock = DockStyle.Fill; }
public WhiteList(MinecraftHandler mc) { InitializeComponent(); try { if (!File.Exists(Config.ConfigFolder + mc.Config.WhiteListFile)) { FileStream fs = File.Create(Config.ConfigFolder + mc.Config.WhiteListFile); fs.Close(); } } catch { } this.mc = mc; RefreshPlayerlist(); this.Dock = DockStyle.Fill; }
public Banlist(MinecraftHandler mc) { InitializeComponent(); comboBoxPlayers.DataSource = mc.Player; try { if (!File.Exists(mc.StrBanList)) { FileStream fs = File.Create(Application.StartupPath + Path.DirectorySeparatorChar + mc.StrBanList); fs.Close(); } } catch { } this.mc = mc; RefreshPlayerlist(); this.Dock = DockStyle.Fill; }
public void GetCommands(MinecraftHandler mc, LockFreeQueue<WebActionCommand> webCommands) { try { if (mc.Started && mc.Config.StreamEnabled) { String guid = mc.Config.GuidString; MySqlCommand command = connection.CreateCommand(); String sql = String.Format( "SELECT * FROM zma_app.zma_web_queue w WHERE w.server_guid = '{0}';" , guid); command.CommandText = sql; MySqlDataReader reader = command.ExecuteReader(); List<int> ids = new List<int>(); int id = -1; while (reader.Read()) { id = reader.GetInt32("id"); WebActionType type = WebActionType.None; type = (WebActionType)reader.GetInt32("type"); string message = ""; message = reader.GetString("message"); UserCollectionSingletone users = UserCollectionSingletone.GetInstance(); String userName = ""; try { userName = reader.GetString("name"); } catch { } if (id >= 0) { ids.Add(id); } User user = users.GetUserByName(userName); if (type == WebActionType.Chat && id >= 0 && !user.Generated) { WebActionCommand cmd = new WebActionCommand(id, type, message, user, this); webCommands.Enqueue(cmd); } } reader.Close(); foreach (int i in ids) { command.CommandText = String.Format("DELETE FROM zma_app.zma_web_queue WHERE id = {0};", i); command.ExecuteNonQuery(); } } } catch ( Exception ex) { Log.Append(this,"GetCommands "+ ex.Message, Log.ExceptionsLog); } }
public void UpdatePlayers(MinecraftHandler mc) { lock (mc.Player) { try { foreach (String str in mc.Player) { UpdatePlayer(mc, str, 1); } } catch (Exception ex) { Log.Append(this, ex.Message, Log.ExceptionsLog); } } }
private AddonLoader(MinecraftHandler mc) { //pluginManager = new PluginManager("Plugins"); //pluginManager.PluginsReloaded += new EventHandler(pluginManager_PluginsReloaded); //pluginManager.Start(); }
public void LoadAddons(MinecraftHandler mc) { paths.Clear(); AppDomain.CurrentDomain.AssemblyResolve -= new ResolveEventHandler(CurrentDomain_AssemblyResolve); AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve); string path = Config.PluginFolder; if (Directory.Exists(path)) { try { string[] dirs = Directory.GetDirectories(path, "*", SearchOption.TopDirectoryOnly); foreach (string dir in dirs) { string[] addonFiles = Directory.GetFiles(dir, "*.dll", SearchOption.TopDirectoryOnly); foreach (string str in addonFiles) { try { Assembly bibliothek = Assembly.LoadFile(str); if (str == "MinecraftWrapper.dll") continue; foreach (Type typ in bibliothek.GetExportedTypes()) { try { if (typeof(IPlugin).IsAssignableFrom(typ)) { try { try { paths.Add(typ.FullName, dir); } catch { } IPlugin plugin = typ.Assembly.CreateInstance(typ.FullName) as IPlugin; plugin.StartUpPath = str; plugin.OnPluginLoaded(CommandManager.GetInstance(mc) as ICommandManager, mc); plugins.Add(plugin); } catch (Exception ex) { MessageBox.Show("Couln't load addon: " + str + Environment.NewLine + ex.Message); } } } catch { Log.Append(this, "Couldn't load an addon", Log.ExceptionsLog); } } } catch { Log.Append(this, "Couldn't load an addon", Log.ExceptionsLog); } } } } catch { Log.Append(this, "Couldn't load an addon", Log.ExceptionsLog); } } }
public static AddonLoader GetInstance(MinecraftHandler mc) { // DoubleLock if (instance == null) { lock (m_lock) { if (instance == null) { instance = new AddonLoader(mc); } } } instance.LoadAddons(mc); return instance; }
public static void HandleChat(String text, MinecraftHandler mc, String name, ServerSocket serverSocket, ClientSocket client, ref bool flag2) { }
//id, name, is_online, seconds_online, players_max, players_online, date_time, ip, port,guid, country, version public void UpdateServer(MinecraftHandler mc,int isOnline) { if (mc.Config.StreamEnabled) { try { string name = mc.Config.ServerName; int online = mc.Started ? 1 : 0; int secondsOnline = mc.SecondsOnline; int playersMax = 100; int playersOnline = mc.Player.Count; string ip = mc.Config.ExternalIp; int port = mc.Config.ExternalPort; DateTime dt = DateTime.Now; String guid = mc.Config.GuidString; if (!IsInTable("zma_server", "guid", mc.Config.GuidString)) { String query = String.Format("INSERT INTO zma_server " + "(name,is_online,seconds_online,players_max,players_online,date_last_online, ip, port, guid, country, version) " + "VALUES ('{0}',{1},{2},{3},{4},{5}, '{6}',{7},'{8}', '{9}' , '{10}');", name, online, secondsOnline, playersMax, playersOnline, "NOW()", ip, port, guid, Culture, mc.Version ); ExecuteSQL(query); } else { String query = String.Format("UPDATE zma_server SET " + "name = '{0}' ," + "is_online = {1} ," + "seconds_online = {2} ," + "players_max = {3} ," + "players_online = {4}, " + "date_last_online = {5}, " + "ip = '{6}', " + "port = {7}, " + "country = '{8}', " + "version = '{9}' " + "WHERE guid = '{10}';", name, online, secondsOnline, playersMax, playersOnline, "NOW()", ip, port, Culture, mc.Version, guid ); ExecuteSQL(query); } } catch (Exception ex) { Log.Append(this, ex.Message, Log.ExceptionsLog); } } }
public void UpdatePlayer(MinecraftHandler mc, String playerName, int isOnline) { if (mc.Config.StreamEnabled) { try { string name = mc.Config.ServerName; String guid = mc.Config.GuidString; int id = GetServerId(guid); int online = isOnline; int secondsOnline = mc.SecondsOnline; //int playersMax = 100; int playersOnline = mc.Player.Count; string ip = mc.Config.ExternalIp; int port = mc.Config.ExternalPort; DateTime dt = DateTime.Now; UserCollectionSingletone users = UserCollectionSingletone.GetInstance(); User u = users.GetUserByName(playerName); int hasWebAccess = u.HasWebAccess ? 1 : 0; if(u.Generated) { hasWebAccess = 0; } if (!IsInTable("zma_players", "name", playerName)) { String query = String.Format("INSERT INTO zma_players " + "(is_online,name,seconds_online,date_last_online, fk_server_id, web_login, web_password, has_web_access,fk_web_server_guid) " + "VALUES ({0},'{1}',{2}, {3},{4},'{5}',MD5('{6}'),{7},{8});", online, playerName, secondsOnline, "NOW()", id, u.WebUsername, u.PasswordHash, hasWebAccess, id ); ExecuteSQL(query); } else { String query = String.Format("UPDATE zma_players SET " + "seconds_online = {0} ," + "date_last_online = {1}, " + "is_online = {2}, " + "fk_server_id = {3}, " + "web_login = '******', " + "web_password = MD5('{5}'), " + "has_web_access = {6}, " + "fk_web_server_guid = {7} " + "WHERE name = '{8}';", secondsOnline, "NOW()", online, id, u.WebUsername, u.PasswordHash, hasWebAccess, id, playerName ); ExecuteSQL(query); } } catch (Exception ex) { Log.Append(this, ex.Message, Log.ExceptionsLog); } } }
public ClientNpc(MinecraftHandler mc, String name, String password) : this(mc,name,password,null) { }
public TcpTunnelServer(MinecraftHandler mc) { minecraftHandler = mc; serverSocket = new ServerSocket(this); }
public Restart(MinecraftHandler mc) { this.mc = mc; }
public void AddChatMessage(String message, String user, MinecraftHandler mc) { try { if (mc.Config.StreamEnabled) { String guid = mc.Config.GuidString; int id = GetServerId(guid); String query = String.Format("INSERT INTO zma_chat " + "(message, username, date, fk_server_id) " + "VALUES ('{0}','{1}',{2},{3});", message, user, "NOW()", id ); ExecuteSQL(query); } } catch (Exception ex) { Log.Append(this, ex.Message + " Add Chat message", Log.ExceptionsLog); connection.Close(); } }