Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-# VARIABLE DECLARATION #-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#
- $currentLocation = Split-Path -parent $PSCommandPath
- $configPath = $currentLocation+'\config.xml'
- $ui = (Get-Host).UI.RawUI
- $consoleName = "Console Master"
- $consoleVersion = '1.0'
- $prefix = "$consoleName $consoleVersion"
- $quitConsole = $false
- #-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-# POWERSHELL CUSTOMIZATION #-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#
- $ui.WindowTitle = "$prefix"
- #-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-# FUNCTION DECLARATION #-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#
- function Setup-Console(){
- Param (
- [Parameter(Mandatory=$True, ValueFromPipeline)]
- [ValidateNotNullOrEmpty()]
- [string]$minecraftVersion
- )
- }
- function Main-Menu() {
- Clear-Host
- Write-Host @"
- ---------------------------------- Main Menu ----------------------------------
- 1. Start Server and Ngrok
- 2. Configurations Menu
- 3. Exit the Console
- -------------------------------------------------------------------------------
- "@
- $answer = read-host "Please Make a Selection"
- switch($answer){
- '1' {
- Clear-Host
- Start-Server
- }
- '2' {
- Clear-Host
- Settings-Menu
- }
- '3' {
- Exit-Script
- }
- default {
- Invaild-Choice
- Main-Menu
- }
- }
- }
- function Start-Server(){
- $consoleServerPrefix = "[+$consoleName+]:"
- $ui.WindowTitle = "$prefix+: Server Running (Jar: , MC )"
- Write-Host @"
- ------------------------------- SERVER LOG START -------------------------------
- $consoleServerPrefix Server Starting!"
- "@
- #-#-#-#-# Ngrok Checking here #-#-#-#-#
- Write-Host "$consoleServerPrefix Checking for Ngrok process..."
- #Already Started
- Write-Host "$consoleServerPrefix Ngrok is Already Running! Skipping Ngrok Startup..."
- #Not Started
- Write-Host "$consoleServerPrefix Ngrok Not Running! Starting Ngrok..."
- start powershell {ngrok tcp 25565}
- Write-Host "$consoleServerPrefix Ngrok Started!"
- #-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#
- Write-Host "$consoleServerPrefix Loading Java Arguments..."
- cd $currentLocation
- java -Xmx1G -jar forge.jar -o True
- #java -Xms1G -Xmx1G -jar C:\Users\novag\Documents\Powershell\forge.jar
- }
- function Settings-Menu() {
- Clear-Host
- Write-Host @"
- -------------------------------- Settings Menu --------------------------------
- 1. Change Version - Change the saved Minecraft version to match
- what the jar file uses
- 2. RAM Allocation - Set the amount of RAM (Random Access Memory)
- to reserve to the server [!]
- 3. Custom Arguments - Set custom arguments besides the RAM [!!]
- 4. Factory Reset - Erase all user defined settings and boot to
- first-time setup [!!!]
- 5. Return To Main Menu
- -------------------------------------------------------------------------------
- "@
- $answer = read-host "Please Make a Selection"
- switch($answer){
- '1' {
- Clear-Host
- Change-Minecraft-Version
- }
- '2' {
- Clear-Host
- Change-RAM
- }
- '3' {
- Clear-Host
- Confirm-Change-Args
- }
- '4' {
- Clear-Host
- Confirm-Factory-Reset
- }
- '5' {Return-Main-Menu}
- default {
- Invaild-Choice
- Settings-Menu
- }
- }
- }
- function Change-Minecraft-Version(){
- Param (
- [Parameter(Mandatory=$True, ValueFromPipeline)]
- [ValidateNotNullOrEmpty()]
- [string]$minecraftVersion
- )
- Write-Host $minecraftVersion
- }
- function Change-RAM(){
- #Write-Host "Please Enter Your Minimum Amount Of RAM To Use Followed By 'M' For Megabytes Or 'G' For Gigabytes"
- Param (
- [ValidateRange(1, [int]::MaxValue)]
- [Parameter(Mandatory=$True, ValueFromPipeline)]
- [int]$ramMin,
- [ValidateRange(1, [int]::MaxValue)]
- [Parameter(Mandatory=$True, ValueFromPipeline)]
- [int]$ramMax
- )
- Write-Host $ramMin, $ramMax
- }
- function Confirm-Change-Args(){
- }
- function Confirm-Factory-Reset(){
- Write-Host "Are you SURE you want to reset back to factory default? This process CANNOT be reversed!!" -ForegroundColor Red
- $answer = read-host "(Y)es or (N)o"
- switch($answer){
- 'Y' {
- Clear-Host
- Preform-Factory-Reset
- }
- 'y' {
- Clear-Host
- Preform-Factory-Reset
- }
- 'N' {
- Clear-Host
- Return-Settings-Menu
- }
- 'n' {
- Clear-Host
- Return-Settings-Menu
- }
- default {
- Invaild-Choice
- Confirm-Factory-Reset
- }
- }
- }
- function Perform-Factory-Reset(){
- Write-Host "Deleting Preferences..." -BackgroundColor Red
- #Delete Preference Method Here
- Write-Host "Factory Reset Completed!"
- Write-Host ""
- Write-Host "Returning to First-Time Setup..." -BackgroundColor Red
- Sleep -Seconds 2
- Setup-Console
- }
- function Exit-Script(){
- Write-Host ""
- Write-Host "Exiting Script..." -BackgroundColor Red
- Start-Sleep -Seconds 5
- $quitConsole = $true
- }
- function Return-Main-Menu(){
- Write-Host ""
- Write-Host "Returning to Main Menu..." -BackgroundColor Red
- Sleep -Seconds 2
- Main-Menu
- }
- function Return-Settings-Menu(){
- Write-Host ""
- Write-Host "Returning to Settings Menu..." -BackgroundColor Red
- Sleep -Seconds 2
- Settings-Menu
- }
- function Invaild-Choice(){
- Write-Warning "INVALID CHOICE! PLEASE ENTER ONE OF THE CHOICES LISTED!"
- Sleep -Seconds 2
- }
- #-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-# BEGIN FUNCTION CALLS #-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#
- Do{
- #-#-#-#-# Setup Checking here #-#-#-#-#
- #If there are no basic files
- #Setup-Console
- #If there are basic files
- Main-Menu
- #-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#
- } Until ($quitConsole = $true)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement