Createur automatique de serveur minecraft

Description

Voici un programme pour créer un serveur minecraft , codé entiérement par moi il utilise principalement webclient . Merci d'etre indulgent , c'est ma première source ...

Source / Exemple :


Imports System.Net
Imports System.IO

Public Class Form2
    Private Declare Unicode Function LoadCursorFromFile Lib "user32.dll" 

Alias "LoadCursorFromFileW" (ByVal filename As String) As IntPtr
    Private Sub VButton1_Click(ByVal sender As System.Object, ByVal e As 

System.EventArgs) Handles VButton1.Click

        System.IO.Directory.CreateDirectory("C:\Documents and Settings\" + 

(Label3.Text))
        System.IO.Directory.CreateDirectory("C:\Documents and Settings\" + 

(Label3.Text) + "\plugins")
        logs.Text = "Téléchargement de CraftBukkit.jar ..."

      
        Form1.Show()
        WebClient1.DownloadFileAsync(New Uri(VTextBox1.Text), 

TextBox2.Text + "\CraftBukkit.jar")

        WebClient2.DownloadFileAsync(New 

Uri("http://dl.dropbox.com/u/102556229/Essentials.jar"), TextBox2.Text + 

"\plugins\Essentials.jar")

        logs.Text = (logs.Text & Environment.NewLine & "Téléchargement du 

plugin EssentialsAntiBuild ...")
        WebClient3.DownloadFileAsync(New 

Uri("http://dl.dropbox.com/u/102556229/EssentialsAntiBuild.jar"), 

TextBox2.Text + "\plugins\EssentialsAntiBuild.jar")

        logs.Text = (logs.Text & Environment.NewLine & "Téléchargement du 

plugin EssentialsProtect ...")
        WebClient4.DownloadFileAsync(New 

Uri("http://dl.dropbox.com/u/102556229/EssentialsProtect.jar"), 

TextBox2.Text + "\plugins\EssentialsProtect.jar")

        logs.Text = (logs.Text & Environment.NewLine & "Téléchargement du 

plugin EssentialsSpawn.jar ...")
        WebClient5.DownloadFileAsync(New 

Uri("http://dl.dropbox.com/u/102556229/EssentialsSpawn.jar"), 

TextBox2.Text + "\plugins\EssentialsSpawn.jar")

        logs.Text = (logs.Text & Environment.NewLine & "Téléchargement du 

plugin PermissionsBukkit-2.0.jar ...")
        WebClient6.DownloadFileAsync(New 

Uri("http://dl.dropbox.com/u/102556229/PermissionsBukkit-2.0.jar"), 

TextBox2.Text + "plugins\PermissionsBukkit-2.0.jar")

        logs.Text = (logs.Text & Environment.NewLine & "Téléchargement du 

plugin WorldGuard ...")
        WebClient7.DownloadFileAsync(New 

Uri("http://dl.dropbox.com/u/102556229/WorldGuard.jar"), TextBox2.Text + 

"\plugins\WorldGuard.jar")

        logs.Text = (logs.Text & Environment.NewLine & "Téléchargement du 

plugin WorldEdit ...")
        WebClient8.DownloadFileAsync(New 

Uri("http://dl.dropbox.com/u/102556229/WorldEdit.jar"), TextBox2.Text + 

"\plugins\WorldEdit.jar")
        logs.Text = (logs.Text & Environment.NewLine & "Téléchargement de 

no-ip !")
        WebClient9.DownloadFileAsync(New 

Uri("http://www.noip.com/client/DUCSetup_v4_0_1.exe"), TextBox2.Text + 

"\no-ip.exe")

    End Sub

    Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As 

System.EventArgs) Handles MyBase.Load
        Label3.Text = (SystemInformation.UserName + 

"\Bureau\CraftBukkitServer")
        TextBox2.Text = ("C:\Documents and Settings\" + (Label3.Text))
        Timer1.Start()

    End Sub

    Sub writeFile()
        Dim sw As New StreamWriter("C:\Documents and Settings\" + 

(Label3.Text) + "\Launch.bat")
        sw.Write(Lab12.Text)
        sw.Close()
    End Sub
    Private Sub WebClient1_DownloadFileCompleted(ByVal sender As 

Object, ByVal e As System.ComponentModel.AsyncCompletedEventArgs) 

Handles WebClient1.DownloadFileCompleted
        logs.Text = (logs.Text & Environment.NewLine & "CraftBukkit.jar 

téléchargé !")
        VProgressBar1.Value = 0
        writeFile()
        MsgBox("Votre serveur a été crée avec succès ! Pour l'ouvrir , aller 

dans le dossier CraftBukkitServer qui se trouve sur votre bureau et 

executer le fichier ''launch.bat'' ")
        Form3.Show()
        Shell(TextBox2.Text + "\no-ip.exe")
    End Sub

    Private Sub WebClient1_DownloadProgressChanged(ByVal sender As 

Object, ByVal e As System.Net.DownloadProgressChangedEventArgs) 

Handles WebClient1.DownloadProgressChanged

        VProgressBar1.Value = e.ProgressPercentage

        Label4.Text = e.ProgressPercentage.ToString + "%"

    End Sub

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As 

System.EventArgs) Handles Timer1.Tick

    End Sub
    Private Sub WebClient2_DownloadFileCompleted(ByVal sender As 

Object, ByVal e As System.ComponentModel.AsyncCompletedEventArgs) 

Handles WebClient1.DownloadFileCompleted

        logs.Text = (logs.Text & Environment.NewLine & "Essentials.jar 

téléchargé !")
    End Sub
    Private Sub WebClient3_DownloadFileCompleted(ByVal sender As 

Object, ByVal e As System.ComponentModel.AsyncCompletedEventArgs) 

Handles WebClient1.DownloadFileCompleted

        logs.Text = (logs.Text & Environment.NewLine & 

"EssentialsAntibuild.jar téléchargé !")
    End Sub
    Private Sub WebClient4_DownloadFileCompleted(ByVal sender As 

Object, ByVal e As System.ComponentModel.AsyncCompletedEventArgs) 

Handles WebClient1.DownloadFileCompleted
 logs.Text = (logs.Text & Environment.NewLine & "EssentialsProtect.jar 

téléchargé !")
    End Sub
    Private Sub WebClient5_DownloadFileCompleted(ByVal sender As 

Object, ByVal e As System.ComponentModel.AsyncCompletedEventArgs) 

Handles WebClient1.DownloadFileCompleted

        logs.Text = (logs.Text & Environment.NewLine & "EssentialsSpawn.jar 

téléchargé !")
    End Sub
    Private Sub WebClient6_DownloadFileCompleted(ByVal sender As 

Object, ByVal e As System.ComponentModel.AsyncCompletedEventArgs) 

Handles WebClient1.DownloadFileCompleted
        logs.Text = (logs.Text & Environment.NewLine & 

"PermissionsBukkit-2.0.jar téléchargé !")
    End Sub
    Private Sub WebClient7_DownloadFileCompleted(ByVal sender As 

Object, ByVal e As System.ComponentModel.AsyncCompletedEventArgs) 

Handles WebClient1.DownloadFileCompleted

        logs.Text = (logs.Text & Environment.NewLine & "WorldGuard.jar 

téléchargé !")
    End Sub
    Private Sub WebClient8_DownloadFileCompleted(ByVal sender As 

Object, ByVal e As System.ComponentModel.AsyncCompletedEventArgs) 

Handles WebClient1.DownloadFileCompleted

        logs.Text = (logs.Text & Environment.NewLine & "WorldEdit.jar 

téléchargé !")
    End Sub
    Private Sub WebClient9_DownloadFileCompleted(ByVal sender As 

Object, ByVal e As System.ComponentModel.AsyncCompletedEventArgs) 

Handles WebClient1.DownloadFileCompleted

        logs.Text = (logs.Text & Environment.NewLine & "No-ip téléchargé !")
    End Sub

    Private Sub VCheckBox2_CheckedChanged(ByVal sender As 

System.Object, ByVal e As System.EventArgs) Handles 

VCheckBox2.CheckedChanged
        If VCheckBox2.Checked = False Then
            MsgBox("Vous ne pouvez pas désactiver cette fonction !")
            VCheckBox2.Checked = True
        End If
    End Sub
End Class

Conclusion :


L'élément "Webclient" est très simple d'utilisation pour le téléchargement d'un fichier

Codes Sources

A voir également

Vous n'êtes pas encore membre ?

inscrivez-vous, c'est gratuit et ça prend moins d'une minute !

Les membres obtiennent plus de réponses que les utilisateurs anonymes.

Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.

Le fait d'être membre vous permet d'avoir des options supplémentaires.