Skip to content

Commit

Permalink
1.0.7: added debugMode
Browse files Browse the repository at this point in the history
  • Loading branch information
benfiratkaya committed Apr 12, 2024
1 parent acc1a28 commit d17d92e
Show file tree
Hide file tree
Showing 10 changed files with 63 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import eu.okaeri.configs.annotation.Names;
import lombok.Getter;
import lombok.Setter;
import net.leaderos.shared.model.DebugMode;

/**
* Main config file
Expand Down Expand Up @@ -41,8 +42,14 @@ public static class Settings extends OkaeriConfig {
@Comment("API Key for request")
private String apiKey = "YOUR_API_KEY";

@Comment("Debug mode for API requests")
private boolean debug = false;
@Comment({
"Debug mode for API requests.",
"Available modes:",
"DISABLED: No debug messages",
"ENABLED: All debug messages",
"ONLY_ERRORS: Only error messages"
})
private DebugMode debugMode = DebugMode.ONLY_ERRORS;

@Comment("Time format for plugin")
private String timeFormat= "yyyy-MM-dd HH:mm:ss";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import net.leaderos.plugin.Bukkit;
import net.leaderos.shared.helpers.DebugAPI;
import net.leaderos.shared.model.DebugMode;

/**
* Sends debug to console
Expand All @@ -17,7 +18,10 @@ public class DebugBukkit implements DebugAPI {
*/
@Override
public void send(String message, boolean strict) {
if (Bukkit.getInstance().getConfigFile().getSettings().isDebug() || strict) {
if (
Bukkit.getInstance().getConfigFile().getSettings().getDebugMode() == DebugMode.ENABLED ||
(Bukkit.getInstance().getConfigFile().getSettings().getDebugMode() == DebugMode.ONLY_ERRORS && strict)
) {
Bukkit.getInstance().getLogger().warning(ChatUtil.color(
"&e[DEBUG] &f" + message
));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import eu.okaeri.configs.annotation.Names;
import lombok.Getter;
import lombok.Setter;
import net.leaderos.shared.model.DebugMode;

/**
* Main config file
Expand Down Expand Up @@ -38,8 +39,14 @@ public static class Settings extends OkaeriConfig {
@Comment("Url of your website")
private String url = "https://yourwebsite.com";

@Comment("Debug mode for API requests")
private boolean debug = false;
@Comment({
"Debug mode for API requests.",
"Available modes:",
"DISABLED: No debug messages",
"ENABLED: All debug messages",
"ONLY_ERRORS: Only error messages"
})
private DebugMode debugMode = DebugMode.ONLY_ERRORS;

@Comment("API Key for request")
private String apiKey = "YOUR_API_KEY";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import net.leaderos.bungee.Bungee;
import net.leaderos.shared.helpers.DebugAPI;
import net.leaderos.shared.model.DebugMode;

/**
* Sends debug to console
Expand All @@ -17,7 +18,10 @@ public class DebugBungee implements DebugAPI {
*/
@Override
public void send(String message, boolean strict) {
if (Bungee.getInstance().getConfigFile().getSettings().isDebug() || strict) {
if (
Bungee.getInstance().getConfigFile().getSettings().getDebugMode() == DebugMode.ENABLED ||
(Bungee.getInstance().getConfigFile().getSettings().getDebugMode() == DebugMode.ONLY_ERRORS && strict)
) {
Bungee.getInstance().getLogger().warning(ChatUtil.color(
"&e[DEBUG] &f" + message
));
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<shared.version>1.0.6</shared.version>
<shared.version>1.0.7</shared.version>
</properties>

<!-- Dependencies -->
Expand Down
11 changes: 11 additions & 0 deletions shared/src/main/java/net/leaderos/shared/model/DebugMode.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package net.leaderos.shared.model;

/**
* @author benfiratkaya
* @since 1.0.7
*/
public enum DebugMode {
DISABLED,
ENABLED,
ONLY_ERRORS
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import io.socket.client.IO;
import io.socket.client.Socket;
import io.socket.engineio.client.transports.Polling;
import io.socket.engineio.client.transports.WebSocket;
import lombok.Getter;
import lombok.Setter;
Expand Down Expand Up @@ -43,7 +44,7 @@ public SocketClient(String apiKey, String serverToken) throws URISyntaxException
opts.auth = auth;

// Set transports
opts.transports = new String[] {WebSocket.NAME};
opts.transports = new String[] {WebSocket.NAME, Polling.NAME};

this.socket = IO.socket(url, opts);

Expand All @@ -52,6 +53,11 @@ public SocketClient(String apiKey, String serverToken) throws URISyntaxException
System.out.println("Socket Error: " + Arrays.toString(args));
});

// Disconnect listener
socket.on(Socket.EVENT_DISCONNECT, args -> {
System.out.println("Socket Disconnected: " + Arrays.toString(args));
});

// Connect to socket
socket.on(Socket.EVENT_CONNECT, args -> {
// Join room
Expand Down
4 changes: 2 additions & 2 deletions velocity/src/main/java/net/leaderos/velocity/Velocity.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
@Plugin(
id = "leaderos",
name = "LeaderOS",
version = "1.0.6",
version = "1.0.7",
url = "https://leaderos.net",
description = "LeaderOS Plugin for Velocity",
authors = {"leaderos"}
Expand Down Expand Up @@ -209,7 +209,7 @@ public void setupFiles() {

public void checkUpdate() {
Velocity.getInstance().getServer().getScheduler().buildTask(Velocity.getInstance(), () -> {
PluginUpdater updater = new PluginUpdater("1.0.6");
PluginUpdater updater = new PluginUpdater("1.0.7");
try {
if (updater.checkForUpdates()) {
Component msg = ChatUtil.replacePlaceholders(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import eu.okaeri.configs.annotation.Names;
import lombok.Getter;
import lombok.Setter;
import net.leaderos.shared.model.DebugMode;

/**
* Main config file
Expand Down Expand Up @@ -38,8 +39,14 @@ public static class Settings extends OkaeriConfig {
@Comment("Url of your website")
private String url = "https://yourwebsite.com";

@Comment("Debug mode for API requests")
private boolean debug = false;
@Comment({
"Debug mode for API requests.",
"Available modes:",
"DISABLED: No debug messages",
"ENABLED: All debug messages",
"ONLY_ERRORS: Only error messages"
})
private DebugMode debugMode = DebugMode.ONLY_ERRORS;

@Comment("API Key for request")
private String apiKey = "YOUR_API_KEY";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package net.leaderos.velocity.helpers;

import net.leaderos.shared.helpers.DebugAPI;
import net.leaderos.shared.model.DebugMode;
import net.leaderos.velocity.Velocity;

/**
Expand All @@ -17,7 +18,10 @@ public class DebugVelocity implements DebugAPI {
*/
@Override
public void send(String message, boolean strict) {
if (Velocity.getInstance().getConfigFile().getSettings().isDebug() || strict) {
if (
Velocity.getInstance().getConfigFile().getSettings().getDebugMode() == DebugMode.ENABLED ||
(Velocity.getInstance().getConfigFile().getSettings().getDebugMode() == DebugMode.ONLY_ERRORS && strict)
) {
Velocity.getInstance().getLogger().warn(
"[DEBUG] " + message
);
Expand Down

0 comments on commit d17d92e

Please sign in to comment.