aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/net/elytrium/limboauth/command
diff options
context:
space:
mode:
authorPetr Ilin <hevav@hevav.dev>2023-01-02 23:48:06 +0300
committerPetr Ilin <hevav@hevav.dev>2023-01-02 23:48:06 +0300
commitade67d8df404f1e3f264dcd90f815722f719a1cd (patch)
tree55aae66df5ee70d708fc96f5df593ea98d96a0a0 /src/main/java/net/elytrium/limboauth/command
parent711a554a773184610b183405276ccc516907d872 (diff)
downloadLimboAuth-ade67d8df404f1e3f264dcd90f815722f719a1cd.tar.gz
LimboAuth-ade67d8df404f1e3f264dcd90f815722f719a1cd.tar.bz2
LimboAuth-ade67d8df404f1e3f264dcd90f815722f719a1cd.zip
Correctly use Exceptions
Diffstat (limited to 'src/main/java/net/elytrium/limboauth/command')
-rw-r--r--src/main/java/net/elytrium/limboauth/command/ChangePasswordCommand.java3
-rw-r--r--src/main/java/net/elytrium/limboauth/command/ForceChangePasswordCommand.java3
-rw-r--r--src/main/java/net/elytrium/limboauth/command/ForceUnregisterCommand.java3
-rw-r--r--src/main/java/net/elytrium/limboauth/command/LimboAuthCommand.java10
-rw-r--r--src/main/java/net/elytrium/limboauth/command/PremiumCommand.java3
-rw-r--r--src/main/java/net/elytrium/limboauth/command/TotpCommand.java5
-rw-r--r--src/main/java/net/elytrium/limboauth/command/UnregisterCommand.java3
7 files changed, 15 insertions, 15 deletions
diff --git a/src/main/java/net/elytrium/limboauth/command/ChangePasswordCommand.java b/src/main/java/net/elytrium/limboauth/command/ChangePasswordCommand.java
index 26c75eb..c940226 100644
--- a/src/main/java/net/elytrium/limboauth/command/ChangePasswordCommand.java
+++ b/src/main/java/net/elytrium/limboauth/command/ChangePasswordCommand.java
@@ -29,6 +29,7 @@ import net.elytrium.limboauth.LimboAuth;
import net.elytrium.limboauth.Settings;
import net.elytrium.limboauth.handler.AuthSessionHandler;
import net.elytrium.limboauth.model.RegisteredPlayer;
+import net.elytrium.limboauth.model.SQLRuntimeException;
import net.kyori.adventure.text.Component;
public class ChangePasswordCommand implements SimpleCommand {
@@ -96,7 +97,7 @@ public class ChangePasswordCommand implements SimpleCommand {
source.sendMessage(this.successful);
} catch (SQLException e) {
source.sendMessage(this.errorOccurred);
- e.printStackTrace();
+ throw new SQLRuntimeException(e);
}
} else {
source.sendMessage(this.notPlayer);
diff --git a/src/main/java/net/elytrium/limboauth/command/ForceChangePasswordCommand.java b/src/main/java/net/elytrium/limboauth/command/ForceChangePasswordCommand.java
index 899aff6..5c960e1 100644
--- a/src/main/java/net/elytrium/limboauth/command/ForceChangePasswordCommand.java
+++ b/src/main/java/net/elytrium/limboauth/command/ForceChangePasswordCommand.java
@@ -32,6 +32,7 @@ import net.elytrium.limboauth.LimboAuth;
import net.elytrium.limboauth.Settings;
import net.elytrium.limboauth.handler.AuthSessionHandler;
import net.elytrium.limboauth.model.RegisteredPlayer;
+import net.elytrium.limboauth.model.SQLRuntimeException;
import net.kyori.adventure.text.Component;
public class ForceChangePasswordCommand implements SimpleCommand {
@@ -81,7 +82,7 @@ public class ForceChangePasswordCommand implements SimpleCommand {
source.sendMessage(serializer.deserialize(MessageFormat.format(this.successful, nickname)));
} catch (SQLException e) {
source.sendMessage(serializer.deserialize(MessageFormat.format(this.notSuccessful, nickname)));
- e.printStackTrace();
+ throw new SQLRuntimeException(e);
}
} else {
source.sendMessage(this.usage);
diff --git a/src/main/java/net/elytrium/limboauth/command/ForceUnregisterCommand.java b/src/main/java/net/elytrium/limboauth/command/ForceUnregisterCommand.java
index 3d2f9ed..3acc2d0 100644
--- a/src/main/java/net/elytrium/limboauth/command/ForceUnregisterCommand.java
+++ b/src/main/java/net/elytrium/limboauth/command/ForceUnregisterCommand.java
@@ -31,6 +31,7 @@ import net.elytrium.limboauth.LimboAuth;
import net.elytrium.limboauth.Settings;
import net.elytrium.limboauth.event.AuthUnregisterEvent;
import net.elytrium.limboauth.model.RegisteredPlayer;
+import net.elytrium.limboauth.model.SQLRuntimeException;
import net.kyori.adventure.text.Component;
public class ForceUnregisterCommand implements SimpleCommand {
@@ -78,7 +79,7 @@ public class ForceUnregisterCommand implements SimpleCommand {
source.sendMessage(serializer.deserialize(MessageFormat.format(this.successful, playerNick)));
} catch (SQLException e) {
source.sendMessage(serializer.deserialize(MessageFormat.format(this.notSuccessful, playerNick)));
- e.printStackTrace();
+ throw new SQLRuntimeException(e);
}
} else {
source.sendMessage(this.usage);
diff --git a/src/main/java/net/elytrium/limboauth/command/LimboAuthCommand.java b/src/main/java/net/elytrium/limboauth/command/LimboAuthCommand.java
index 669a978..b4587b4 100644
--- a/src/main/java/net/elytrium/limboauth/command/LimboAuthCommand.java
+++ b/src/main/java/net/elytrium/limboauth/command/LimboAuthCommand.java
@@ -100,14 +100,8 @@ public class LimboAuthCommand implements SimpleCommand {
Serializer serializer = LimboAuth.getSerializer();
if (argsAmount == 1) {
if (command.equalsIgnoreCase("reload") && source.hasPermission("limboauth.admin.reload")) {
- try {
- this.plugin.reload();
- source.sendMessage(serializer.deserialize(Settings.IMP.MAIN.STRINGS.RELOAD));
- } catch (Exception e) {
- e.printStackTrace();
- source.sendMessage(serializer.deserialize(Settings.IMP.MAIN.STRINGS.RELOAD_FAILED));
- }
-
+ this.plugin.reload();
+ source.sendMessage(serializer.deserialize(Settings.IMP.MAIN.STRINGS.RELOAD));
return;
}
/*
diff --git a/src/main/java/net/elytrium/limboauth/command/PremiumCommand.java b/src/main/java/net/elytrium/limboauth/command/PremiumCommand.java
index 9257adc..f81ce10 100644
--- a/src/main/java/net/elytrium/limboauth/command/PremiumCommand.java
+++ b/src/main/java/net/elytrium/limboauth/command/PremiumCommand.java
@@ -29,6 +29,7 @@ import net.elytrium.limboauth.LimboAuth;
import net.elytrium.limboauth.Settings;
import net.elytrium.limboauth.handler.AuthSessionHandler;
import net.elytrium.limboauth.model.RegisteredPlayer;
+import net.elytrium.limboauth.model.SQLRuntimeException;
import net.kyori.adventure.text.Component;
public class PremiumCommand implements SimpleCommand {
@@ -85,7 +86,7 @@ public class PremiumCommand implements SimpleCommand {
((Player) source).disconnect(this.successful);
} catch (SQLException e) {
source.sendMessage(this.errorOccurred);
- e.printStackTrace();
+ throw new SQLRuntimeException(e);
}
} else {
source.sendMessage(this.notPremium);
diff --git a/src/main/java/net/elytrium/limboauth/command/TotpCommand.java b/src/main/java/net/elytrium/limboauth/command/TotpCommand.java
index e57cae9..afa4b30 100644
--- a/src/main/java/net/elytrium/limboauth/command/TotpCommand.java
+++ b/src/main/java/net/elytrium/limboauth/command/TotpCommand.java
@@ -36,6 +36,7 @@ import net.elytrium.limboauth.LimboAuth;
import net.elytrium.limboauth.Settings;
import net.elytrium.limboauth.handler.AuthSessionHandler;
import net.elytrium.limboauth.model.RegisteredPlayer;
+import net.elytrium.limboauth.model.SQLRuntimeException;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.event.ClickEvent;
@@ -127,7 +128,7 @@ public class TotpCommand implements SimpleCommand {
updateBuilder.update();
} catch (SQLException e) {
source.sendMessage(this.errorOccurred);
- e.printStackTrace();
+ throw new SQLRuntimeException(e);
}
source.sendMessage(this.successful);
@@ -167,7 +168,7 @@ public class TotpCommand implements SimpleCommand {
source.sendMessage(this.disabled);
} catch (SQLException e) {
source.sendMessage(this.errorOccurred);
- e.printStackTrace();
+ throw new SQLRuntimeException(e);
}
} else {
source.sendMessage(this.wrong);
diff --git a/src/main/java/net/elytrium/limboauth/command/UnregisterCommand.java b/src/main/java/net/elytrium/limboauth/command/UnregisterCommand.java
index 69edc8c..53fe58e 100644
--- a/src/main/java/net/elytrium/limboauth/command/UnregisterCommand.java
+++ b/src/main/java/net/elytrium/limboauth/command/UnregisterCommand.java
@@ -30,6 +30,7 @@ import net.elytrium.limboauth.Settings;
import net.elytrium.limboauth.event.AuthUnregisterEvent;
import net.elytrium.limboauth.handler.AuthSessionHandler;
import net.elytrium.limboauth.model.RegisteredPlayer;
+import net.elytrium.limboauth.model.SQLRuntimeException;
import net.kyori.adventure.text.Component;
public class UnregisterCommand implements SimpleCommand {
@@ -83,7 +84,7 @@ public class UnregisterCommand implements SimpleCommand {
((Player) source).disconnect(this.successful);
} catch (SQLException e) {
source.sendMessage(this.errorOccurred);
- e.printStackTrace();
+ throw new SQLRuntimeException(e);
}
} else {
source.sendMessage(this.wrongPassword);