Skip to content

Commit

Permalink
Development (#69)
Browse files Browse the repository at this point in the history
* Update build.yml

* Update build.yml

* Relase 1.17.0

* a

* Updatre
  • Loading branch information
Crujera27 authored Jul 31, 2024
1 parent acce030 commit 75c33e2
Show file tree
Hide file tree
Showing 17 changed files with 410 additions and 238 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@ jobs:
with:
node-version: 18

- name: Crear la carpeta para el certificado
run: mkdir -p cert
shell: bash


- name: Restaurar el certificado
run: echo ${{ secrets.CERTIFICATE_BASE64 }} | base64 --decode > ./cert/certificate.pfx
shell: bash

- name: Instalar y preparar Python
uses: actions/setup-python@v4
with:
Expand All @@ -34,5 +43,6 @@ jobs:
- name: Build
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CERTIFICATE_FILE: ${{ github.workspace }}/cert/certificate.pfx
run: npm run dist
shell: bash
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@
/.vscode/
/target/
/logs/
/dist/
/dist/
./cert
./cert/*
38 changes: 38 additions & 0 deletions INSTALLER-LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
Licencias aplicables para este producto de VI Software:

https://docs.visoftware.tech/vi-software/guidelines/terminos-de-servicio
https://docs.visoftware.tech/vi-software/guidelines/codigo-de-conducta
https://docs.visoftware.tech/vi-software/guidelines/politica-de-invitacion
https://docs.visoftware.tech/vi-software/guidelines/politica-de-uso-justo-para-la-api
https://docs.visoftware.tech/vi-software/guidelines/contribution-guidelines
https://docs.visoftware.tech/vi-software/guidelines/politica-de-contribucion

Applicable licenses for direct customers of VI Software:

https://docs.visoftware.tech/vi-software/licencias/licencia-cliente

Applicable licenses for VI Software guests:

https://docs.visoftware.tech/vi-software/licencias/licencia-invitado

The code for this software is distributed under the MIT license.

Copyright (c) 2024 VI Software

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
4 changes: 4 additions & 0 deletions app/assets/css/launcher.css
Original file line number Diff line number Diff line change
Expand Up @@ -1845,6 +1845,10 @@ input:checked + .toggleSwitchSlider:before {
pointer-events: none;
}

#settingsDropinrequiredDesc {
font-size: 10px;
pointer-events: none;
}
/* Button to remove drop-in mods. */
.settingsDropinRemoveButton {
background: none;
Expand Down
Binary file added app/assets/images/vis-tray.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions app/assets/js/configmanager.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ const DEFAULT_CONFIG = {
resWidth: 1280,
resHeight: 720,
fullscreen: false,
MinimizeOnLaunch: true,
autoConnect: true,
launchDetached: true
},
Expand Down Expand Up @@ -808,4 +809,23 @@ exports.getAllowPrerelease = function(def = false){
*/
exports.setAllowPrerelease = function(allowPrerelease){
config.settings.launcher.allowPrerelease = allowPrerelease
}

/**
* Check if the launcher should be minimized to the system tray when the game is launch.
*
* @param {boolean} def Optional. If true, the default value will be returned.
* @returns {boolean} Whether or not the launcher should be minimized to the system tray when the game is launch.
*/
exports.getMinimizeOnLaunch = function(def = false){
return !def ? config.settings.game.MinimizeOnLaunch : DEFAULT_CONFIG.settings.game.MinimizeOnLaunch
}

/**
* Change the status if the launcher should be minimized to the system tray when the game is launch.
*
* @param {boolean} MinimizeOnLaunch Whether or not the launcher should be minimized to the system tray when the game is launch.
*/
exports.setMinimizeOnLaunch = function(MinimizeOnLaunch){
config.settings.game.MinimizeOnLaunch = MinimizeOnLaunch
}
77 changes: 37 additions & 40 deletions app/assets/js/processbuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/

const { app } = require('@electron/remote');
const { app } = require('@electron/remote')
const AdmZip = require('adm-zip')
const child_process = require('child_process')
const crypto = require('crypto')
Expand All @@ -26,13 +26,39 @@ const { getMojangOS, isLibraryCompatible, mcVersionAtLeast } = require('vis-lau
const { Type } = require('vis-launcher-distribution-manager')
const os = require('os')
const path = require('path')
const win = remote.getCurrentWindow();
const ConfigManager = require('./configmanager')
const net = require('net');
const logger = LoggerUtil.getLogger('ProcessBuilder')
const disableHttpd = localStorage.getItem('disableHttpd');
const authlibDebug = localStorage.getItem('authlibDebug')



const ConfigManager = require('./configmanager')

const logger = LoggerUtil.getLogger('ProcessBuilder')
/**
* Injects authlib into the JVM arguments as a java agent.
* @param {*} args
*/

async function authLibArgs(args) {
// Sets the path to the Authlib Injector jar
let authlibInjectorPath;
if (process.env.NODE_ENV === 'development' || !app.isPackaged) {
authlibInjectorPath = path.join(app.getAppPath(), 'libraries', 'java', 'authlibinjector.jar');
} else {
authlibInjectorPath = path.join(process.resourcesPath, 'libraries', 'java', 'authlibinjector.jar');
}
const authServerUrl = 'https://authserver.visoftware.tech/authlib-injector';
// Add the Authlib Injector as a Java agent
args.unshift(`-javaagent:${authlibInjectorPath}=${authServerUrl}`);
args.push('-Dauthlibinjector.noShowServerName')
if(disableHttpd){
args.push(args.push('-Dauthlibinjector.disableHttpd'))
}
if(authlibDebug){
args.push('-Dauthlibinjector.debug=' + authlibDebug)
}
}

/**
* Only forge and fabric are top level mod loaders.
Expand Down Expand Up @@ -103,6 +129,10 @@ class ProcessBuilder {
child.unref()
}

if(ConfigManager.getMinimizeOnLaunch()){
win.hide();
}

child.stdout.setEncoding('utf8')
child.stderr.setEncoding('utf8')

Expand All @@ -114,6 +144,7 @@ class ProcessBuilder {
data.trim().split('\n').forEach(x => console.log(`\x1b[31m[Minecraft]\x1b[0m ${x}`))
})
child.on('close', (code, signal) => {
win.show();
logger.info('Exited with code', code)
if(code != 0){
setOverlayContent(
Expand Down Expand Up @@ -401,12 +432,7 @@ class ProcessBuilder {
// Classpath Argument
args.push('-cp')
args.push(this.classpathArg(mods, tempNativePath).join(ProcessBuilder.getClasspathSeparator()))
// Sets the path to the Authlib Injector jar
const authlibInjectorPath = path.join(app.getAppPath(), 'libraries', 'java', 'authlibinjector.jar');
const authServerUrl = 'https://authserver.visoftware.tech/authlib-injector';
// Add the Authlib Injector as a Java agent
args.unshift(`-javaagent:${authlibInjectorPath}=${authServerUrl}`);
args.push('-Dauthlibinjector.noShowServerName')
authLibArgs(args)
// Java Arguments
if(process.platform === 'darwin'){
args.push('-Xdock:name=VISoftwareLauncher')
Expand Down Expand Up @@ -445,12 +471,7 @@ class ProcessBuilder {

// Debug securejarhandler
// args.push('-Dbsl.debug=true')
// Sets the path to the Authlib Injector jar
const authlibInjectorPath = path.join(app.getAppPath(), 'libraries', 'java', 'authlibinjector.jar');
const authServerUrl = 'https://authserver.visoftware.tech/authlib-injector';
// Add the Authlib Injector as a Java agent
args.unshift(`-javaagent:${authlibInjectorPath}=${authServerUrl}`);
args.push('-Dauthlibinjector.noShowServerName')
authLibArgs(args)
if(this.modManifest.arguments.jvm != null) {
for(const argStr of this.modManifest.arguments.jvm) {
args.push(argStr
Expand Down Expand Up @@ -478,26 +499,6 @@ class ProcessBuilder {
// Vanilla Arguments
args = args.concat(this.vanillaManifest.arguments.game)

async function WriteFullscreenToOptions(filePath, lineToReplace, newLine) {
try {
const exists = await fs.pathExists(filePath);

if (exists) {
let fileContent = await fs.readFile(filePath, 'utf8');
if (fileContent.includes(lineToReplace)) {
fileContent = fileContent.replace(lineToReplace, newLine);
await fs.outputFile(filePath, fileContent);
} else {
await fs.outputFile(filePath, newLine);
}
} else {
await fs.outputFile(filePath, newLine);
}
} catch (err) {
logger.info('Error while writing fullscreen to options.txt:', err);
}
}

for(let i=0; i<args.length; i++){
if(typeof args[i] === 'object' && args[i].rules != null){

Expand All @@ -519,14 +520,10 @@ class ProcessBuilder {
// This should be fine for a while.
if(rule.features.has_custom_resolution != null && rule.features.has_custom_resolution === true){
if(ConfigManager.getFullscreen()){
logger.info("gamedir: ", this.gameDir)
WriteFullscreenToOptions(path.join(this.gameDir, "options.txt"), 'fullscreen:false', 'fullscreen:true')
args[i].value = [
'--fullscreen',
'true'
]
}else{
WriteFullscreenToOptions(path.join(this.gameDir, "options.txt"), 'fullscreen:true', 'fullscreen:false');
}
checksum++
}
Expand Down
70 changes: 33 additions & 37 deletions app/assets/js/scripts/landing.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,45 +173,41 @@ document.getElementById('launch_button').addEventListener('click', async e => {
return
}
try {
try {
const response = await fetch('https://api.visoftware.tech/services/moderation/globalban/laccount/' + user.displayName);
const data = await response.json();
if(data.banned){
showLaunchFailure(Lang.queryJS('landing.launch.GlobalAccountDisabledErrorTitle'), Lang.queryJS('landing.launch.GlobalAccountDisabledErrorText'))
loggerLanding.error('Root account is globaly disabled by VI Software.')
return
}
}catch(err){
showLaunchFailure(Lang.queryJS('landing.launch.NoCheckModErrorTitle'), Lang.queryJS('landing.launch.NoCheckModErrorText'))
loggerLanding.error('An error has occurred while attempting to check root account status. Error: ', err)
return
}
try {
const response = await fetch('https://api.visoftware.tech/services/launcher/accounts/' + user.displayName);
const data = await response.json();
if(data.suspended){
showLaunchFailure(Lang.queryJS('landing.launch.AccountDisabledErrorTitle'), Lang.queryJS('landing.launch.AccountDisabledErrorText'))
loggerLanding.error('Account is disabled by experience administrator.')
return
}
}catch(err){
showLaunchFailure(Lang.queryJS('landing.launch.NoCheckModErrorTitle'), Lang.queryJS('landing.launch.NoCheckModErrorText'))
loggerLanding.error('An error has occurred while attempting to check account status. Error: ', err)
const response = await fetch('https://api.visoftware.tech/services/moderation/mystatus', {
method: 'GET',
headers: {
'Content-Type': 'application/json',
'token': user.accessToken
}
});

const userData = await response.json();
if(response.status == 401){
showLaunchFailure(Lang.queryJS('landing.launch.NoCheckModErrorTitle'), Lang.queryJS('landing.launch.NoCheckModErrorText'));
loggerLanding.error('An error has occurred while attempting to verify the account in the moderation system. Error:', userData.error);
return;
}
if(userData.rootbanned){
showLaunchFailure(Lang.queryJS('landing.launch.GlobalAccountDisabledErrorTitle'), Lang.queryJS('landing.launch.GlobalAccountDisabledErrorText'))
loggerLanding.error('Root account is banned by VI Software. Canceling launch.')
return
}
const response = await fetch('https://api.visoftware.tech/services/moderation/warns/account/' + user.displayName);
const data = await response.json();
if(data.some(warning => warning.read === 0)){
}
if(userData.pendingwarns > 0){
showLaunchFailure(Lang.queryJS('landing.launch.WarnsnotreadErrorTitle'), Lang.queryJS('landing.launch.WarnsnotreadErrorText'))
loggerLanding.error('User has unread warnings.')
loggerLanding.error('Root account has pending warnings awaiting to be reviewed. Canceling launch.')
return
}

}catch(err){
showLaunchFailure(Lang.queryJS('landing.launch.NoCheckModErrorTitle'), Lang.queryJS('landing.launch.NoCheckModErrorText'))
loggerLanding.error('An error has occurred while attempting to check unread user\'s warnings. Error: ', err)
return
}
}
if(userData.launcherbanned){
showLaunchFailure(Lang.queryJS('landing.launch.AccountDisabledErrorTitle'), Lang.queryJS('landing.launch.AccountDisabledErrorText'))
loggerLanding.error('Launcher account is disabled by Team Administration. Canceling launch.')
return
}

} catch (err) {
showLaunchFailure(Lang.queryJS('landing.launch.NoCheckModErrorTitle'), Lang.queryJS('landing.launch.NoCheckModErrorText'));
loggerLanding.error('An error has occurred while attempting to verify the account in the moderation system. Error: ', err);
return;
}
const jExe = ConfigManager.getJavaExecutable(ConfigManager.getSelectedServer())
if(jExe == null){
await asyncSystemScan(server.effectiveJavaOptions)
Expand Down Expand Up @@ -1131,4 +1127,4 @@ async function loadNews(){
})

return await promise
}
}
13 changes: 13 additions & 0 deletions app/assets/js/scripts/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,19 @@ function bindFileSelectors(){

bindFileSelectors()

launchDetachedCheckbox = document.querySelector('input[cValue="LaunchDetached"]')
MinimizeOnLaunchCheckbox = document.querySelector('input[cValue="MinimizeOnLaunch"]')


MinimizeOnLaunchCheckbox.addEventListener('change', function() {
if (this.checked) {
MinimizeOnLaunchCheckbox.disabled = true
MinimizeOnLaunchCheckbox.checked = true
} else {
MinimizeOnLaunchCheckbox.disabled = false
}
})


/**
* General Settings Functions
Expand Down
Loading

0 comments on commit 75c33e2

Please sign in to comment.