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;
|
package com.djrapitops.plan.commands.subcommands;
|
||||||
|
|
||||||
import com.djrapitops.plan.delivery.webserver.Addresses;
|
import com.djrapitops.plan.delivery.webserver.Addresses;
|
||||||
|
import com.djrapitops.plan.processing.Processing;
|
||||||
import com.djrapitops.plan.settings.Permissions;
|
import com.djrapitops.plan.settings.Permissions;
|
||||||
import com.djrapitops.plan.settings.locale.Locale;
|
import com.djrapitops.plan.settings.locale.Locale;
|
||||||
import com.djrapitops.plan.settings.locale.lang.CmdHelpLang;
|
import com.djrapitops.plan.settings.locale.lang.CmdHelpLang;
|
||||||
|
@ -38,16 +39,19 @@ public class ListPlayersCommand extends CommandNode {
|
||||||
|
|
||||||
private final Locale locale;
|
private final Locale locale;
|
||||||
private final Addresses addresses;
|
private final Addresses addresses;
|
||||||
|
private final Processing processing;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public ListPlayersCommand(
|
public ListPlayersCommand(
|
||||||
Locale locale,
|
Locale locale,
|
||||||
Addresses addresses
|
Addresses addresses,
|
||||||
|
Processing processing
|
||||||
) {
|
) {
|
||||||
super("players|pl|playerlist|list", Permissions.INSPECT_OTHER.getPermission(), CommandType.CONSOLE);
|
super("players|pl|playerlist|list", Permissions.INSPECT_OTHER.getPermission(), CommandType.CONSOLE);
|
||||||
|
|
||||||
this.locale = locale;
|
this.locale = locale;
|
||||||
this.addresses = addresses;
|
this.addresses = addresses;
|
||||||
|
this.processing = processing;
|
||||||
|
|
||||||
setShortHelp(locale.getString(CmdHelpLang.PLAYERS));
|
setShortHelp(locale.getString(CmdHelpLang.PLAYERS));
|
||||||
setInDepthHelp(locale.getArray(DeepHelpLang.PLAYERS));
|
setInDepthHelp(locale.getArray(DeepHelpLang.PLAYERS));
|
||||||
|
@ -55,7 +59,7 @@ public class ListPlayersCommand extends CommandNode {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCommand(Sender sender, String commandLabel, String[] args) {
|
public void onCommand(Sender sender, String commandLabel, String[] args) {
|
||||||
sendListMsg(sender);
|
processing.submitNonCritical(() -> sendListMsg(sender));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendListMsg(Sender sender) {
|
private void sendListMsg(Sender sender) {
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
package com.djrapitops.plan.commands.subcommands;
|
package com.djrapitops.plan.commands.subcommands;
|
||||||
|
|
||||||
import com.djrapitops.plan.delivery.webserver.Addresses;
|
import com.djrapitops.plan.delivery.webserver.Addresses;
|
||||||
|
import com.djrapitops.plan.processing.Processing;
|
||||||
import com.djrapitops.plan.settings.Permissions;
|
import com.djrapitops.plan.settings.Permissions;
|
||||||
import com.djrapitops.plan.settings.locale.Locale;
|
import com.djrapitops.plan.settings.locale.Locale;
|
||||||
import com.djrapitops.plan.settings.locale.lang.CmdHelpLang;
|
import com.djrapitops.plan.settings.locale.lang.CmdHelpLang;
|
||||||
|
@ -38,16 +39,19 @@ public class NetworkCommand extends CommandNode {
|
||||||
|
|
||||||
private final Locale locale;
|
private final Locale locale;
|
||||||
private final Addresses addresses;
|
private final Addresses addresses;
|
||||||
|
private final Processing processing;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public NetworkCommand(
|
public NetworkCommand(
|
||||||
Locale locale,
|
Locale locale,
|
||||||
Addresses addresses
|
Addresses addresses,
|
||||||
|
Processing processing
|
||||||
) {
|
) {
|
||||||
super("network|n|netw", Permissions.ANALYZE.getPermission(), CommandType.CONSOLE);
|
super("network|n|netw", Permissions.ANALYZE.getPermission(), CommandType.CONSOLE);
|
||||||
|
|
||||||
this.locale = locale;
|
this.locale = locale;
|
||||||
this.addresses = addresses;
|
this.addresses = addresses;
|
||||||
|
this.processing = processing;
|
||||||
|
|
||||||
setShortHelp(locale.getString(CmdHelpLang.NETWORK));
|
setShortHelp(locale.getString(CmdHelpLang.NETWORK));
|
||||||
setInDepthHelp(locale.getArray(DeepHelpLang.NETWORK));
|
setInDepthHelp(locale.getArray(DeepHelpLang.NETWORK));
|
||||||
|
@ -55,7 +59,7 @@ public class NetworkCommand extends CommandNode {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCommand(Sender sender, String commandLabel, String[] args) {
|
public void onCommand(Sender sender, String commandLabel, String[] args) {
|
||||||
sendNetworkMsg(sender);
|
processing.submitNonCritical(() -> sendNetworkMsg(sender));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendNetworkMsg(Sender sender) {
|
private void sendNetworkMsg(Sender sender) {
|
||||||
|
|
|
@ -110,13 +110,15 @@ public class RegisterCommand extends CommandNode {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.length == 0) {
|
if (args.length == 0) {
|
||||||
String url = addresses.getMainAddress().orElseGet(() -> {
|
processing.submitNonCritical(() -> {
|
||||||
sender.sendMessage(locale.getString(CommandLang.NO_ADDRESS_NOTIFY));
|
String url = addresses.getMainAddress().orElseGet(() -> {
|
||||||
return addresses.getFallbackLocalhostAddress();
|
sender.sendMessage(locale.getString(CommandLang.NO_ADDRESS_NOTIFY));
|
||||||
}) + "/register";
|
return addresses.getFallbackLocalhostAddress();
|
||||||
String linkPrefix = locale.getString(CommandLang.LINK_PREFIX);
|
}) + "/register";
|
||||||
sender.sendMessage(linkPrefix);
|
String linkPrefix = locale.getString(CommandLang.LINK_PREFIX);
|
||||||
sender.sendLink(" ", locale.getString(CommandLang.LINK_CLICK_ME), url);
|
sender.sendMessage(linkPrefix);
|
||||||
|
sender.sendLink(" ", locale.getString(CommandLang.LINK_CLICK_ME), url);
|
||||||
|
});
|
||||||
return;
|
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.rendering.html.Html;
|
||||||
import com.djrapitops.plan.delivery.webserver.Addresses;
|
import com.djrapitops.plan.delivery.webserver.Addresses;
|
||||||
|
import com.djrapitops.plan.processing.Processing;
|
||||||
import com.djrapitops.plan.settings.Permissions;
|
import com.djrapitops.plan.settings.Permissions;
|
||||||
import com.djrapitops.plan.settings.locale.Locale;
|
import com.djrapitops.plan.settings.locale.Locale;
|
||||||
import com.djrapitops.plan.settings.locale.lang.CmdHelpLang;
|
import com.djrapitops.plan.settings.locale.lang.CmdHelpLang;
|
||||||
|
@ -42,17 +43,20 @@ import java.util.Arrays;
|
||||||
public class ManageRawDataCommand extends CommandNode {
|
public class ManageRawDataCommand extends CommandNode {
|
||||||
|
|
||||||
private final Locale locale;
|
private final Locale locale;
|
||||||
private Addresses addresses;
|
private final Addresses addresses;
|
||||||
|
private final Processing processing;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public ManageRawDataCommand(
|
public ManageRawDataCommand(
|
||||||
Locale locale,
|
Locale locale,
|
||||||
Addresses addresses
|
Addresses addresses,
|
||||||
|
Processing processing
|
||||||
) {
|
) {
|
||||||
super("raw", Permissions.MANAGE.getPermission(), CommandType.PLAYER_OR_ARGS);
|
super("raw", Permissions.MANAGE.getPermission(), CommandType.PLAYER_OR_ARGS);
|
||||||
|
|
||||||
this.locale = locale;
|
this.locale = locale;
|
||||||
this.addresses = addresses;
|
this.addresses = addresses;
|
||||||
|
this.processing = processing;
|
||||||
|
|
||||||
setArguments("<player>");
|
setArguments("<player>");
|
||||||
setShortHelp(locale.getString(CmdHelpLang.MANAGE_RAW_DATA));
|
setShortHelp(locale.getString(CmdHelpLang.MANAGE_RAW_DATA));
|
||||||
|
@ -64,24 +68,26 @@ public class ManageRawDataCommand extends CommandNode {
|
||||||
Verify.isTrue(args.length >= 1,
|
Verify.isTrue(args.length >= 1,
|
||||||
() -> new IllegalArgumentException(locale.getString(CommandLang.FAIL_REQ_ONE_ARG, Arrays.toString(this.getArguments()))));
|
() -> new IllegalArgumentException(locale.getString(CommandLang.FAIL_REQ_ONE_ARG, Arrays.toString(this.getArguments()))));
|
||||||
|
|
||||||
String playerName = MiscUtils.getPlayerName(args, sender, Permissions.MANAGE);
|
processing.submitNonCritical(() -> {
|
||||||
|
String playerName = MiscUtils.getPlayerName(args, sender, Permissions.MANAGE);
|
||||||
|
|
||||||
sender.sendMessage(locale.getString(CommandLang.HEADER_INSPECT, playerName));
|
sender.sendMessage(locale.getString(CommandLang.HEADER_INSPECT, playerName));
|
||||||
// Link
|
// Link
|
||||||
String address = addresses.getMainAddress().orElseGet(() -> {
|
String address = addresses.getMainAddress().orElseGet(() -> {
|
||||||
sender.sendMessage(locale.getString(CommandLang.NO_ADDRESS_NOTIFY));
|
sender.sendMessage(locale.getString(CommandLang.NO_ADDRESS_NOTIFY));
|
||||||
return addresses.getFallbackLocalhostAddress();
|
return addresses.getFallbackLocalhostAddress();
|
||||||
|
});
|
||||||
|
String url = address + "/player/" + Html.encodeToURL(playerName) + "/raw";
|
||||||
|
String linkPrefix = locale.getString(CommandLang.LINK_PREFIX);
|
||||||
|
boolean console = !CommandUtils.isPlayer(sender);
|
||||||
|
if (console) {
|
||||||
|
sender.sendMessage(linkPrefix + url);
|
||||||
|
} else {
|
||||||
|
sender.sendMessage(linkPrefix);
|
||||||
|
sender.sendLink(" ", locale.getString(CommandLang.LINK_CLICK_ME), url);
|
||||||
|
}
|
||||||
|
|
||||||
|
sender.sendMessage(">");
|
||||||
});
|
});
|
||||||
String url = address + "/player/" + Html.encodeToURL(playerName) + "/raw";
|
|
||||||
String linkPrefix = locale.getString(CommandLang.LINK_PREFIX);
|
|
||||||
boolean console = !CommandUtils.isPlayer(sender);
|
|
||||||
if (console) {
|
|
||||||
sender.sendMessage(linkPrefix + url);
|
|
||||||
} else {
|
|
||||||
sender.sendMessage(linkPrefix);
|
|
||||||
sender.sendLink(" ", locale.getString(CommandLang.LINK_CLICK_ME), url);
|
|
||||||
}
|
|
||||||
|
|
||||||
sender.sendMessage(">");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user