mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-09-03 02:10:36 +02:00
Fixed several commands running database queries on server thread
This commit is contained in:
parent
f62e76bcf5
commit
c66af02477
|
@ -17,6 +17,7 @@
|
|||
package com.djrapitops.plan.commands.subcommands;
|
||||
|
||||
import com.djrapitops.plan.delivery.webserver.Addresses;
|
||||
import com.djrapitops.plan.processing.Processing;
|
||||
import com.djrapitops.plan.settings.Permissions;
|
||||
import com.djrapitops.plan.settings.locale.Locale;
|
||||
import com.djrapitops.plan.settings.locale.lang.CmdHelpLang;
|
||||
|
@ -38,16 +39,19 @@ public class ListPlayersCommand extends CommandNode {
|
|||
|
||||
private final Locale locale;
|
||||
private final Addresses addresses;
|
||||
private final Processing processing;
|
||||
|
||||
@Inject
|
||||
public ListPlayersCommand(
|
||||
Locale locale,
|
||||
Addresses addresses
|
||||
Addresses addresses,
|
||||
Processing processing
|
||||
) {
|
||||
super("players|pl|playerlist|list", Permissions.INSPECT_OTHER.getPermission(), CommandType.CONSOLE);
|
||||
|
||||
this.locale = locale;
|
||||
this.addresses = addresses;
|
||||
this.processing = processing;
|
||||
|
||||
setShortHelp(locale.getString(CmdHelpLang.PLAYERS));
|
||||
setInDepthHelp(locale.getArray(DeepHelpLang.PLAYERS));
|
||||
|
@ -55,7 +59,7 @@ public class ListPlayersCommand extends CommandNode {
|
|||
|
||||
@Override
|
||||
public void onCommand(Sender sender, String commandLabel, String[] args) {
|
||||
sendListMsg(sender);
|
||||
processing.submitNonCritical(() -> sendListMsg(sender));
|
||||
}
|
||||
|
||||
private void sendListMsg(Sender sender) {
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
package com.djrapitops.plan.commands.subcommands;
|
||||
|
||||
import com.djrapitops.plan.delivery.webserver.Addresses;
|
||||
import com.djrapitops.plan.processing.Processing;
|
||||
import com.djrapitops.plan.settings.Permissions;
|
||||
import com.djrapitops.plan.settings.locale.Locale;
|
||||
import com.djrapitops.plan.settings.locale.lang.CmdHelpLang;
|
||||
|
@ -38,16 +39,19 @@ public class NetworkCommand extends CommandNode {
|
|||
|
||||
private final Locale locale;
|
||||
private final Addresses addresses;
|
||||
private final Processing processing;
|
||||
|
||||
@Inject
|
||||
public NetworkCommand(
|
||||
Locale locale,
|
||||
Addresses addresses
|
||||
Addresses addresses,
|
||||
Processing processing
|
||||
) {
|
||||
super("network|n|netw", Permissions.ANALYZE.getPermission(), CommandType.CONSOLE);
|
||||
|
||||
this.locale = locale;
|
||||
this.addresses = addresses;
|
||||
this.processing = processing;
|
||||
|
||||
setShortHelp(locale.getString(CmdHelpLang.NETWORK));
|
||||
setInDepthHelp(locale.getArray(DeepHelpLang.NETWORK));
|
||||
|
@ -55,7 +59,7 @@ public class NetworkCommand extends CommandNode {
|
|||
|
||||
@Override
|
||||
public void onCommand(Sender sender, String commandLabel, String[] args) {
|
||||
sendNetworkMsg(sender);
|
||||
processing.submitNonCritical(() -> sendNetworkMsg(sender));
|
||||
}
|
||||
|
||||
private void sendNetworkMsg(Sender sender) {
|
||||
|
|
|
@ -110,6 +110,7 @@ public class RegisterCommand extends CommandNode {
|
|||
}
|
||||
|
||||
if (args.length == 0) {
|
||||
processing.submitNonCritical(() -> {
|
||||
String url = addresses.getMainAddress().orElseGet(() -> {
|
||||
sender.sendMessage(locale.getString(CommandLang.NO_ADDRESS_NOTIFY));
|
||||
return addresses.getFallbackLocalhostAddress();
|
||||
|
@ -117,6 +118,7 @@ public class RegisterCommand extends CommandNode {
|
|||
String linkPrefix = locale.getString(CommandLang.LINK_PREFIX);
|
||||
sender.sendMessage(linkPrefix);
|
||||
sender.sendLink(" ", locale.getString(CommandLang.LINK_CLICK_ME), url);
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@ package com.djrapitops.plan.commands.subcommands.manage;
|
|||
|
||||
import com.djrapitops.plan.delivery.rendering.html.Html;
|
||||
import com.djrapitops.plan.delivery.webserver.Addresses;
|
||||
import com.djrapitops.plan.processing.Processing;
|
||||
import com.djrapitops.plan.settings.Permissions;
|
||||
import com.djrapitops.plan.settings.locale.Locale;
|
||||
import com.djrapitops.plan.settings.locale.lang.CmdHelpLang;
|
||||
|
@ -42,17 +43,20 @@ import java.util.Arrays;
|
|||
public class ManageRawDataCommand extends CommandNode {
|
||||
|
||||
private final Locale locale;
|
||||
private Addresses addresses;
|
||||
private final Addresses addresses;
|
||||
private final Processing processing;
|
||||
|
||||
@Inject
|
||||
public ManageRawDataCommand(
|
||||
Locale locale,
|
||||
Addresses addresses
|
||||
Addresses addresses,
|
||||
Processing processing
|
||||
) {
|
||||
super("raw", Permissions.MANAGE.getPermission(), CommandType.PLAYER_OR_ARGS);
|
||||
|
||||
this.locale = locale;
|
||||
this.addresses = addresses;
|
||||
this.processing = processing;
|
||||
|
||||
setArguments("<player>");
|
||||
setShortHelp(locale.getString(CmdHelpLang.MANAGE_RAW_DATA));
|
||||
|
@ -64,6 +68,7 @@ public class ManageRawDataCommand extends CommandNode {
|
|||
Verify.isTrue(args.length >= 1,
|
||||
() -> new IllegalArgumentException(locale.getString(CommandLang.FAIL_REQ_ONE_ARG, Arrays.toString(this.getArguments()))));
|
||||
|
||||
processing.submitNonCritical(() -> {
|
||||
String playerName = MiscUtils.getPlayerName(args, sender, Permissions.MANAGE);
|
||||
|
||||
sender.sendMessage(locale.getString(CommandLang.HEADER_INSPECT, playerName));
|
||||
|
@ -83,5 +88,6 @@ public class ManageRawDataCommand extends CommandNode {
|
|||
}
|
||||
|
||||
sender.sendMessage(">");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user