Skip to content

Commit

Permalink
working
Browse files Browse the repository at this point in the history
  • Loading branch information
xxAROX committed Feb 14, 2024
1 parent ef1c690 commit c17a988
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 44 deletions.
18 changes: 11 additions & 7 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,16 @@
</repositories>

<dependencies>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.22.1</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.22.1</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
Expand Down Expand Up @@ -73,16 +83,10 @@
<version>3.1.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.22.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-transport-native-kqueue</artifactId>
<version>4.1.84.Final</version>
<version>4.1.107.Final</version>
<classifier>osx-x86_64</classifier>
<scope>compile</scope>
</dependency>
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/xxAROX/PresenceMan/Application/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
import lombok.ToString;
import net.arikia.dev.drpc.DiscordEventHandlers;
import net.arikia.dev.drpc.DiscordRPC;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import xxAROX.PresenceMan.Application.entity.APIActivity;
import xxAROX.PresenceMan.Application.entity.DiscordInfo;
import xxAROX.PresenceMan.Application.entity.FeaturedServer;
Expand Down
13 changes: 5 additions & 8 deletions src/main/java/xxAROX/PresenceMan/Application/Bootstrap.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,12 @@
package xxAROX.PresenceMan.Application;

import lombok.SneakyThrows;
import lombok.extern.log4j.Log4j;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.util.Arrays;
import java.util.List;

@Log4j
public class Bootstrap {
@SneakyThrows
public static void main(String[] _args) {
Expand All @@ -40,9 +37,9 @@ public static void main(String[] _args) {
}

protected static Logger initializeLogger(){
PropertyConfigurator.configure(ClassLoader.getSystemResource("log4j.properties"));
var logger = Logger.getLogger(App.class);
logger.setLevel(AppInfo.development ? Level.DEBUG : Level.INFO);
//PropertyConfigurator.configure(ClassLoader.getSystemResource("log4j.properties"));
var logger = LogManager.getLogger(App.class);
//logger.setLevel(AppInfo.development ? Level.DEBUG : Level.INFO);
return logger;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ public class WaterdogScheduler {
public WaterdogScheduler() {
if (instance != null) throw new RuntimeException("Scheduler was already initialized!");
instance = this;

ThreadFactoryBuilder builder = ThreadFactoryBuilder.builder().format("Scheduler Executor - #%d").build();
this.threadedExecutor = new ThreadPoolExecutor(Math.round(Runtime.getRuntime().availableProcessors() /2f), Integer.MAX_VALUE, 60, TimeUnit.SECONDS, new SynchronousQueue<>(), builder);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public void run() {
Semver versionSemver = new Semver(AppInfo.getVersion());
Semver latestVersionSemver = new Semver(latestVersion);
updateAvailable = latestVersionSemver.isGreaterThan(versionSemver);
if (AppInfo.development || versionSemver.isGreaterThan(latestVersionSemver)) App.getLogger().warn("You are running a dev version of PresenceMan");
if (AppInfo.development/* || versionSemver.isGreaterThan(latestVersionSemver)*/) App.getLogger().warn("You are running a dev version of PresenceMan");
} catch (Throwable t) {
updateAvailable = !AppInfo.getVersion().equals(latestVersion);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@

package xxAROX.PresenceMan.Application.ui.tabs;

import net.raphimc.minecraftauth.MinecraftAuth;
import net.raphimc.minecraftauth.step.msa.StepMsaDeviceCode;
import net.raphimc.minecraftauth.util.MicrosoftConstants;
import org.apache.http.impl.client.CloseableHttpClient;
import xxAROX.PresenceMan.Application.App;
import xxAROX.PresenceMan.Application.entity.XboxUserInfo;
import xxAROX.PresenceMan.Application.ui.AUITab;
Expand Down Expand Up @@ -103,8 +102,8 @@ private void closePopup() {

private void login(){
handleLogin(msaDeviceCodeConsumer -> {
try (CloseableHttpClient httpClient = MicrosoftConstants.createHttpClient()) {
return new XboxUserInfo(XboxUserInfo.DEVICE_CODE_LOGIN.getFromInput(httpClient, new StepMsaDeviceCode.MsaDeviceCodeCallback(msaDeviceCodeConsumer)));
try {
return new XboxUserInfo(XboxUserInfo.DEVICE_CODE_LOGIN.getFromInput(MinecraftAuth.createHttpClient(), new StepMsaDeviceCode.MsaDeviceCodeCallback(msaDeviceCodeConsumer)));
} catch (Exception e) {
if (e instanceof InterruptedException) return null;
else if (e instanceof TimeoutException) {
Expand Down
21 changes: 0 additions & 21 deletions src/main/resources/log4j.properties

This file was deleted.

31 changes: 31 additions & 0 deletions src/main/resources/log4j2.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) $originalComment.match("Copyright \(c\) (\d+)", 1, "-", "$today.year")2024. By Jan-Michael Sohn also known as @xxAROX.
~
~ This program is free software: you can redistribute it and/or modify
~ it under the terms of the GNU Affero General Public License as
~ published by the Free Software Foundation, either version 3 of the
~ License, or (at your option) any later version.
~
~ This program is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
~ GNU Affero General Public License for more details.
~
~ You should have received a copy of the GNU Affero General Public License
~ along with this program. If not, see <https://www.gnu.org/licenses/>.
-->

<Configuration status="INFO">
<Appenders>
<Console name="console" target="SYSTEM_OUT">
<PatternLayout pattern="[%d{HH:mm:ss} | Presence-Man | %-5p]: %m%n" />
</Console>
</Appenders>

<Loggers>
<Root level="trace">
<AppenderRef ref="console" />
</Root>
</Loggers>
</Configuration>

0 comments on commit c17a988

Please sign in to comment.