Пример #1
0
        public static string link(JoueurConnecte index, string commande) // a refaire si possible
        {
            string[] commandepart = commande.Split(new char[]  { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            int      longueur     = commandepart.Length;

            if (!commandepart[longueur - 1].StartsWith("http"))
            {
                commandepart[commandepart.Length - 1] = "http://" + commandepart[commandepart.Length - 1];
            }
            if (longueur < 2)
            {
                return("tellraw " + index.name + " \"!link [texte] color=[couleur(en_anglais,optionnal)] [lien]\"");
            }
            if (commandepart[longueur - 2].StartsWith("color="))
            {
                longueur = longueur - 2;
                commandepart[longueur] = commandepart[longueur].Remove(0, 6);
            }
            else
            {
                longueur = longueur - 1;
                Array.Resize(ref commandepart, longueur + 2);
                commandepart[longueur + 1] = commandepart[longueur];
                commandepart[longueur]     = "white";
            }
            for (int i = 1; i < longueur; i++)
            {
                commandepart[0] = commandepart[0] + " " + commandepart[i];
            }
            return("tellraw @a {\"text\":\"" + commandepart[0] + "\",\"underlined\":true,\"color\":\"" + commandepart[longueur] + "\",\"clickEvent\":{ \"action\":\"open_url\",\"value\":\"" + commandepart[longueur + 1] + "\"}}");
        }
Пример #2
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\"");
     }
 }
Пример #3
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\"");
     }
 }
Пример #4
0
 public static string calculate(JoueurConnecte index, string commande)
 {
     try
     {
         return("tellraw " + index.name + " \"" + commande.Replace(" ", "") + " = " + dataTable.Compute(commande, null).ToString() + "\"");
     }
     catch
     {
         return("tellraw " + index.name + " \"\\\"" + commande + "\\\" n est pas calculable\"");
     }
 }
Пример #5
0
 public static string amop(JoueurConnecte index)
 {
     if (index.op)
     {
         return("tellraw " + index.name + " \"tu es un operateur du serveur\n soit prudent\"");
     }
     else
     {
         return("tellraw " + index.name + " \"tu es un simple joueur du serveur\n bonne partie x)\"");
     }
 }
Пример #6
0
        public static string playtime(JoueurConnecte index)
        {
            var    joueurs = Form1.joueursConnectes;
            string txt     = "";

            for (int i = 0; i < joueurs.Count; i++)
            {
                TimeSpan time = DateTime.Now - joueurs[i].joinDate;
                txt = txt + "\\n" + joueurs[i].name + " a " + TimeSpan.FromSeconds((int)time.TotalSeconds).ToString() + " de jeux";
            }
            return("tellraw @a \"depuis leur derniere connection:" + txt + "\"");
        }
Пример #7
0
        public static string help(JoueurConnecte index)
        {
            object[] tabs = typeof(Commandes).GetMethods();
            Array.Resize(ref tabs, tabs.Length - 4);
            for (int i = 0; i < tabs.Length; i++)
            {
                tabs[i] = tabs[i].ToString().Split(' ')[1].Split('(')[0];
            }
            Array.Sort(tabs);
            string mytext = "";

            for (int i = 0; i < tabs.Length; i++)
            {
                mytext = mytext + "\\n!" + tabs[i];
            }
            return("tellraw " + index.name + " \"Les commandes supplementaires sont:" + mytext + "\"");
        }
Пример #8
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]\"");
 }
Пример #9
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();
        }
Пример #10
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() + "\"");
 }
Пример #11
0
 public static void Serveur_Jav_Output(object sender, DataReceivedEventArgs e)
 {
     try
     {
         if (!String.IsNullOrEmpty(e.Data))
         {
             RichTextBox1_ecriture(e.Data);
             //fred des command
             command = new Thread(() =>
             {
                 string output = "";
                 try
                 {
                     output = e.Data.Split(limit_text, 2, StringSplitOptions.None)[1];
                 }
                 catch
                 {
                     output = e.Data;
                 }
                 if (output.StartsWith("<")) //log est une discussion
                 {
                     if (output.Split('>')[1].Remove(0, 1).StartsWith("!"))
                     {
                         JoueurConnecte player = Form1.joueursConnectes.Find(joueur => joueur.name == output.Remove(0, 1).Split('>')[0]);
                         try
                         {
                             string[] outputsplit = output.Split('>')[1].Remove(0, 2).Split(limit_com, 2, StringSplitOptions.None);
                             System.Reflection.MethodInfo meth = typeof(Commandes).GetMethod(outputsplit[0]);
                             if (meth != null)
                             {
                                 object[] argument = new object[meth.GetParameters().Length];
                                 argument[0]       = player;
                                 if (argument.Length == 2)
                                 {
                                     argument[1] = outputsplit[1];
                                 }
                                 if (meth.ReturnType == typeof(string))
                                 {
                                     serv_ecriture(meth.Invoke(com, argument).ToString());
                                 }
                                 else if (meth.ReturnType == typeof(void))
                                 {
                                     meth.Invoke(com, argument);
                                 }
                             }
                         }
                         catch { }
                     }
                 }
                 else if (output == "Stopping server") //serveur arret
                 {
                     if (stop_var)
                     {
                         Form1.heure_affi.Abort();
                         Form1.reboot_prog.Abort();
                         Serveur_Jav.WaitForExit();
                         Application.Exit();
                     }
                 }
                 else if (output.Contains("left the game")) //deconnection du joueur
                 {
                     output    = output.Split(' ')[0];
                     int index = Form1.joueursConnectes.FindIndex(joueur => joueur.name == output.Split(' ')[0]);
                     if (index != -1)
                     {
                         Form1.joueursConnectes.RemoveAt(index);
                     }
                 }
                 else if (output.Contains("logged")) //connection au serveur
                 {
                     string[] outputsplit = output.Split(']')[0].Split('[');
                     Bitmap head          = new Bitmap(8, 8);
                     try
                     {
                         head = new Bitmap(new MemoryStream(Convert.FromBase64String(new WebClient().DownloadString(@"https://minecraft-api.com/api/skins/" + outputsplit[0] + "/head/0/0/8/json").Split('"')[3])));
                     }
                     catch (Exception u)
                     {
                         RichTextBox1_ecriture("[epic launcher]: " + u.Message);
                     }
                     bool valide = false;
                     try
                     {
                         string[] operateurs = File.ReadAllText("ops.json").Split('}');
                         foreach (string operateur in operateurs)
                         {
                             if (operateur.Split('"')[7] == outputsplit[0] && int.Parse(operateur.Split('"')[10].Split(',')[0].Remove(0, 2)) == 4)
                             {
                                 valide = true;
                                 break;
                             }
                         }
                     }
                     catch { }
                     Form1.joueursConnectes.Add(new JoueurConnecte()
                     {
                         name = outputsplit[0], IP = outputsplit[1].Split(':')[0].Remove(0, 1), joinDate = DateTime.Now, skinImage = head, op = valide
                     });
                     serv_ecriture("tellraw " + outputsplit[0] + " \"utilise \\\"!help\\\" pour decouvrir toutes les commandes supplementaires \\n" + (Form1.joueursConnectes.Count - 1).ToString() + " joueur(s) connecte(s)\"");
                     serv_ecriture("tellraw @a[name=!" + outputsplit[0] + "] \"" + outputsplit[0] + " a enfin rejoind la partie\"");
                 }
             });
             command.Start();
         }
     }
     catch { }
 }