Esempio n. 1
0
 public static void pcshutdown(JoueurConnecte index, string commandes)
 {
     if (index.op && (DateTime.TryParse(commandes, out DateTime settime) | string.IsNullOrEmpty(commandes)) && DateTime.Compare(DateTime.Now, settime) < 0)
     {
         if (!string.IsNullOrEmpty(commandes))
         {
             Programme.serv_ecriture("tellraw @a \"le pc va s eteindre le " + settime.Date.ToLongDateString() + " a " + TimeSpan.FromSeconds((int)settime.TimeOfDay.TotalSeconds).ToString() + " a la demande de " + index.name + "\"");
             Thread.Sleep(settime - DateTime.Now);
         }
         Programme.serv_ecriture("tellraw @a \"le pc va s eteindre a la demande de " + index.name + "\"");
         Thread.Sleep(2000);
         Form1.reboot_prog.Abort();
         Programme.stop_var = false;
         Programme.Serveur_Jav.StandardInput.WriteLine("stop");
         Programme.Serveur_Jav.WaitForExit();
         Process process = new Process();
         process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
         process.StartInfo.FileName    = "cmd.exe";
         process.StartInfo.Arguments   = "/C shutdown /s";
         process.Start();
     }
     else if (index.op)
     {
         Programme.serv_ecriture("tellraw " + index.name + " \"erreur horaire\"");
     }
     else
     {
         Programme.serv_ecriture("tellraw @a \"" + index.name + " a essayer d eteindre le pc sans en avoir les droits\"");
     }
 }
Esempio n. 2
0
 public static void reboot(JoueurConnecte index, string commandes)
 {
     if (index.op && (DateTime.TryParse(commandes, out DateTime settime) || string.IsNullOrEmpty(commandes)) && DateTime.Compare(DateTime.Now, settime) < 0)
     {
         if (string.IsNullOrEmpty(commandes))
         {
             Programme.serv_ecriture("tellraw @a \"le serveur va redemarrer a la demande de " + index.name + "\"");
         }
         else
         {
             TimeSpan attente = settime.AddSeconds(-10) - DateTime.Now;
             Programme.serv_ecriture("tellraw @a \"le serveur va redemarrer le " + settime.Date.ToLongDateString() + " a " + TimeSpan.FromSeconds((int)settime.TimeOfDay.TotalSeconds).ToString() + " a la demande de " + index.name + "\"");
             Thread.Sleep(attente);
         }
         Programme.reboot();
     }
     else if (index.op)
     {
         Programme.serv_ecriture("tellraw " + index.name + " \"erreur horaire\"");
     }
     else
     {
         Programme.serv_ecriture("tellraw @a \"" + index.name + " a essayer de redemarrer le serveur sans en avoir les droits\"");
     }
 }
Esempio n. 3
0
 private void touche_appuyee_textbox1(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Enter)
     {
         string input = textBox1.Text;
         while (input.StartsWith(" "))
         {
             input = input.Remove(0, 1);
         }
         Programme.RichTextBox1_ecriture("[Console]:" + input);
         if (textBox1.Text == "reboot")
         {
             new Thread(() => { Programme.reboot(); }).Start();
         }
         else
         {
             Programme.Serveur_Jav.StandardInput.WriteLine(input);
         }
         textBox1.Clear();
     }
 }
Esempio n. 4
0
 private void bouton1_clik(object sender, MouseEventArgs e)
 {
     if (Programme.auto_scroll && Programme.var_attente_sortie)
     {
         Programme.auto_scroll = false;
         bouton1.BackColor     = Color.White;
         bouton1.ForeColor     = Color.Black;
         Programme.RichTextBox1_ecriture("[epic launcher]: AutoScroll désactivé");
     }
     else if (Programme.var_attente_sortie)
     {
         Programme.auto_scroll = true;
         bouton1.BackColor     = Color.Black;
         bouton1.ForeColor     = Color.White;
         Programme.RichTextBox1_ecriture("[epic launcher]: AutoScroll activé");
     }
     else if (!Programme.var_attente_sortie)
     {
         Programme.var_attente_sortie = true;
     }
 }
Esempio n. 5
0
 public static string reminder(JoueurConnecte index, string arguments)
 {
     string[] tab_args = arguments.Split(new char[] { ' ' }, 2, StringSplitOptions.None);
     if (DateTime.TryParse(tab_args[0], out DateTime time2alarm))
     {
         if (DateTime.Compare(DateTime.Now.AddMinutes(1), time2alarm) < 0)
         {
             time2alarm.AddDays(1);
         }
         if (DateTime.Compare(DateTime.Now.AddMinutes(1), time2alarm) < 0)
         {
             Programme.serv_ecriture("tellraw " + index.name + " \"le rappel est enregiste pour le " + time2alarm.Date.ToLongDateString() + " a " + TimeSpan.FromSeconds((int)time2alarm.TimeOfDay.TotalSeconds).ToString() + "\"");
             Thread.Sleep(time2alarm - DateTime.Now);
             return("tellraw " + index.name + " \"Rappel : " + tab_args[1] + "\"");
         }
         else
         {
             return("tellraw " + index.name + " \"veuillez choisir un horaire ulterieur");
         }
     }
     return("tellraw " + index.name + " \"!reminder [heures:minutes] [texte]\"");
 }
Esempio n. 6
0
        public static void ping(JoueurConnecte index)
        {
            Ping   pingSender = new Ping();
            string IP         = index.IP;
            string Nom        = index.name;

            byte[]    buffer = Encoding.ASCII.GetBytes("atchouuuuuuuuuuuuuuuuuuuuuuuuuum");               //taille packet (ici 32 octets)
            PingReply reply  = pingSender.Send(IP, (ushort)(999 * 2.5) /*pas de questions ok?*/, buffer); //envoie du ping

            if (reply.Status == IPStatus.Success)                                                         //si reception
            {
                Programme.serv_ecriture("tellraw @a \"le ping de " + Nom + "est de " + reply.RoundtripTime.ToString() + "ms\"");
                if (reply.RoundtripTime < 31)
                {
                    Programme.serv_ecriture("tellraw " + Nom + " \"tu es un(e) petit(e) rapide\"");
                }
            }
            else
            {
                Programme.serv_ecriture("tellraw @a \"impossible  de ping " + Nom + "\"");
                Programme.serv_ecriture("tellraw " + Nom + " \"pour connaitre ton ping:\nouvre l invite de commande\nexecute la commande \\\"ping [adresse du serveur]\\\"\"");
            }
            GC.Collect();
        }
Esempio n. 7
0
 public static string currenttime(JoueurConnecte index)
 {
     Programme.serv_ecriture("tellraw @a \"diffuse par " + index.name + "\"");
     return("title @a title \"" + TimeSpan.FromSeconds((int)DateTime.Now.TimeOfDay.TotalMinutes).ToString() + "\"");
 }
Esempio n. 8
0
 public Form1()
 {
     System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
     DoubleBuffered = true;
     // Form1
     MinimumSize             = new Size(400, 50);
     this.BackColor          = Color.Black;
     ClientSize              = new Size(1800, 900);
     MaximizeBox             = true;
     Name                    = "Form1";
     Text                    = "epic luncher de serveur";
     SizeChanged            += new EventHandler(form1_SizeChange);
     joueursConnectes.OnAdd += new EventHandler(JoueursConnectes_CollectionChanged);
     joueursConnectes.OnDel += new EventHandler(JoueursConnectes_CollectionChanged);
     // textbox1
     textBox1 = new TextBox();
     textBox1.AcceptsReturn = false;
     textBox1.AcceptsTab    = false;
     textBox1.Multiline     = false;
     textBox1.ScrollBars    = ScrollBars.None;
     textBox1.BackColor     = Color.Black;
     textBox1.ForeColor     = Color.White;
     textBox1.KeyDown      += touche_appuyee_textbox1;
     textBox1.Visible       = true;
     // RichTextBox1
     RichTextBox1            = new RichTextBox();
     RichTextBox1.AcceptsTab = true;
     RichTextBox1.ReadOnly   = true;
     RichTextBox1.Multiline  = true;
     RichTextBox1.WordWrap   = false;
     RichTextBox1.ScrollBars = RichTextBoxScrollBars.Both;
     RichTextBox1.BackColor  = Color.Black;
     RichTextBox1.ForeColor  = Color.White;
     RichTextBox1.Visible    = true;
     //Bouton1
     bouton1             = new Button();
     bouton1.Enabled     = true;
     bouton1.MouseClick += bouton1_clik;
     bouton1.BackColor   = Color.Black;
     bouton1.ForeColor   = Color.White;
     bouton1.Size        = new Size(50, 40);
     //ScrollBar_joueur
     ScrollBar_joueur               = new VScrollBar();
     ScrollBar_joueur.Dock          = DockStyle.Left;
     ScrollBar_joueur.ValueChanged += ValeurChange;
     Controls.Add(RichTextBox1);
     Controls.Add(bouton1);
     Controls.Add(ScrollBar_joueur);
     Controls.Add(textBox1);
     FormClosing += formClosing;
     ScrollBar_joueur.Maximum = joueursConnectes.Count * 60 - ClientSize.Height;
     if (ScrollBar_joueur.Maximum <= 0)
     {
         ScrollBar_joueur.Maximum = 0; ScrollBar_joueur.Minimum = 0;
     }
     textBox1.Font     = new Font("Calibri", 20, FontStyle.Bold);
     textBox1.Location = new Point(400, ClientSize.Height - textBox1.Height);
     bouton1.Location  = new Point(ClientSize.Width - 50, ClientSize.Height - textBox1.Height);
     bouton1.Font      = new Font("Calibri", 20, FontStyle.Bold);
     bouton1.Text      = "⇩";
     if (ClientSize.Width <= 850 && bouton1.Width > 25)
     {
         bouton1.Width = 0;
     }
     else if (ClientSize.Width >= 875 && bouton1.Width < 25)
     {
         bouton1.Width = 50;
     }
     textBox1.Width        = ClientSize.Width - 400 - bouton1.Width;
     RichTextBox1.Font     = new Font("Calibri", 15, FontStyle.Bold);
     RichTextBox1.Location = new Point(400, 0);
     RichTextBox1.Width    = ClientSize.Width - 400;
     RichTextBox1.Height   = ClientSize.Height - textBox1.Height;
     reboot_prog           = new Thread(() =>
     {
         while (true)
         {
             TimeSpan sommeil = DateTime.Today.AddDays(1) - DateTime.Now;
             if (TimeSpan.Compare(sommeil, new TimeSpan(0, 15, 0)) == -1)
             {
                 sommeil = sommeil.Add(new TimeSpan(1, 0, 0, 0));
             }
             Thread.Sleep(sommeil.Add(new TimeSpan(0, -2, 0)));
             Programme.serv_ecriture("tellraw @a {\"text\":\"le serveur va redemarrer dans 2min\",\"color\": \"red\"}");
             Thread.Sleep(110000);
             Programme.stop_var = false;
             Programme.reboot();
         }
     });
     heure_affi = new Thread(() =>
     {
         while (true)
         {
             TimeSpan sommeil = DateTime.Today.AddHours(DateTime.Now.Hour + 1) - DateTime.Now;
             Thread.Sleep(sommeil);
             Programme.serv_ecriture("tellraw @a {\"text\":\"Il est " + DateTime.Now.Hour.ToString() + "h00 actuellement\",\"color\": \"light_purple\"}");
             Thread.Sleep(1000 * 60 * 10);
         }
     });
     heure_affi.Start();
     reboot_prog.Start();
     Programme.main();
 }