-
-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #394 from Mindgamesnl/feature/one-click-fixes
[feature] Automatically help some users setup the plugin with offlinemode
- Loading branch information
Showing
8 changed files
with
95 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
BUILD_NUM="1132" | ||
BUILD_NUM="1132" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
...in/src/main/java/com/craftmend/openaudiomc/generic/commands/helpers/PromptProxyError.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.craftmend.openaudiomc.generic.commands.helpers; | ||
|
||
import com.craftmend.openaudiomc.generic.platform.OaColor; | ||
import com.craftmend.openaudiomc.generic.platform.Platform; | ||
import com.craftmend.openaudiomc.generic.user.User; | ||
|
||
public class PromptProxyError { | ||
|
||
public static void sendTo(User sender) { | ||
sender.sendMessage(OaColor.RED + "WARNING! This OpenAudioMc can't accept links, because it's running in node mode."); | ||
sender.sendMessage(OaColor.YELLOW + "If you run a proxy (Bunguard, Velocity, Waterfall, etc), then:"); | ||
sender.sendMessage(OaColor.GRAY + " - Install the plugin on your proxy, if you have one."); | ||
sender.sendMessage(OaColor.YELLOW + "Or, if you don't run one or don't know what this means:"); | ||
sender.sendMessage(OaColor.GRAY + " - Enable " + Platform.makeColor("WHITE") + "force-offline-mode" + Platform.makeColor("RED") + " in the config.yml if your host doesn't support proxies."); | ||
sender.sendClickableCommandMessage( | ||
Platform.makeColor("RED") + " - Or click here to do it automatically, but you need to restart your server after doing this.", | ||
"Automatically enable force-offline-mode", | ||
"oa setkv SETTINGS_FORCE_OFFLINE_MODE true" | ||
); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
...src/main/java/com/craftmend/openaudiomc/generic/commands/subcommands/SetKvSubCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package com.craftmend.openaudiomc.generic.commands.subcommands; | ||
|
||
import com.craftmend.openaudiomc.OpenAudioMc; | ||
import com.craftmend.openaudiomc.generic.commands.interfaces.SubCommand; | ||
import com.craftmend.openaudiomc.generic.storage.enums.StorageKey; | ||
import com.craftmend.openaudiomc.generic.user.User; | ||
|
||
public class SetKvSubCommand extends SubCommand { | ||
|
||
private static final StorageKey[] allowedKeys = new StorageKey[] { | ||
StorageKey.SETTINGS_FORCE_OFFLINE_MODE, | ||
StorageKey.SETTINGS_REGIONS_SYNC, | ||
StorageKey.SETTINGS_SPEAKER_SYNC, | ||
StorageKey.SETTINGS_HYDRATE_REGIONS_ON_BOOT, | ||
StorageKey.SETTINGS_VOICE_FILTERS_GAMEMODE, | ||
StorageKey.SETTINGS_VOICE_FILTERS_TEAM | ||
}; | ||
|
||
public SetKvSubCommand() { | ||
super("setkv"); | ||
|
||
// This is a 'hidden' utility command which allows some specific config values to be changed through a command | ||
// which is used by some error messages to help server users configure their server. | ||
// It scares me how many support tickets we get about people not understanding configs, | ||
// or reading an error message for that matter, and providing them with a one-click solution | ||
// to the problem is a great way to improve the user experience. | ||
// values may only be booleans, so we don't need to add a value type argument | ||
|
||
// hide it from the help command, as it's not really a feature or something you should use | ||
this.listed = false; | ||
} | ||
|
||
@Override | ||
public void onExecute(User sender, String[] args) { | ||
if (args.length != 2) { | ||
message(sender, "Invalid arguments. Usage: /openaudio setkv <key> <value>"); | ||
return; | ||
} | ||
|
||
String key = args[0].toUpperCase(); | ||
String value = args[1].toLowerCase(); | ||
|
||
boolean found = false; | ||
for (StorageKey storageKey : allowedKeys) { | ||
if (storageKey.name().equals(key)) { | ||
found = true; | ||
if (value.equals("true") || value.equals("false")) { | ||
// set the value | ||
OpenAudioMc.getInstance().getInvoker().getConfigurationProvider().setBoolean(storageKey, Boolean.parseBoolean(value)); | ||
message(sender, "Set " + key + " to " + value); | ||
message(sender, "Please restart your server to apply this change."); | ||
// flush the change | ||
OpenAudioMc.getInstance().getInvoker().getConfigurationProvider().saveAll(true); | ||
} else { | ||
message(sender, "Invalid value. Usage: /openaudio setkv <key> <value>"); | ||
} | ||
} | ||
} | ||
|
||
if (!found) { | ||
message(sender, "Invalid key. This command can only be used to set some specific keys as part of simple problem solving or support."); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
BUILD_NUM="1132" | ||
BUILD_NUM="1132" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
BUILD_VERSION="1132" | ||
BUILD_COMMIT="e0842006cab8285737dfa84b3a4eeeab0e4e7e13" | ||
BUILD_AUTHOR="Mats" | ||
BUILD_COMMIT="e0842006cab8285737dfa84b3a4eeeab0e4e7e13" |