Skip to content

Commit

Permalink
feat: add option to allow server starting without perms plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
oddlama committed May 13, 2024
1 parent 789a51e commit 3821a2a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -180,17 +180,19 @@ private static String encode_favicon(String id, String favicon_path) throws IOEx

}

private static class ServerStart {
public static class ServerStart {

private static final int DEFAULT_TIMEOUT_SECONDS = 10;
public String[] cmd;
public Integer timeout;
public String kick_msg;
public boolean allow_anyone;

public ServerStart(String id, String display_name, CommentedConfig config) {
List<String> cmd = config.get("cmd");
var timeout = config.get("timeout");
var kick_msg = config.get("kick_msg");
var allow_anyone = config.get("allow_anyone");

if (cmd != null) this.cmd = cmd.stream().map(s -> s.replace("{SERVER}", id)).toArray(String[]::new);
else this.cmd = null;
Expand All @@ -202,6 +204,10 @@ public ServerStart(String id, String display_name, CommentedConfig config) {
this.kick_msg = ((String) kick_msg).replace("{SERVER}", id).replace("{SERVER_DISPLAY_NAME}", display_name);
else this.kick_msg = null;

if (allow_anyone != null)
this.allow_anyone = (boolean)allow_anyone;
else this.allow_anyone = false;

if (timeout == null) {
this.timeout = DEFAULT_TIMEOUT_SECONDS;
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ public final void fire() {
// For use inside callback
final var cms = plugin.get_config().managed_servers.get(server_info.getName());

if (!connection.can_start_server(plugin.get_proxy(), server_info.getName())) {
if (!cms.start.allow_anyone && !connection.can_start_server(plugin.get_proxy(), server_info.getName())) {
plugin.get_logger().log(Level.INFO, "Disconnecting '" + connection.get_name() + "' because they don't have the permission to start server '" + server_info.getName() + "'");
// TODO: This could probably use a configurable message?
this.cancel("Server is offline");
this.cancel("Server is offline and you don't have the permission to start it");
return;
}

Expand Down
4 changes: 2 additions & 2 deletions vane-velocity/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ plugins {

dependencies {
compileOnly(fileTree(mapOf("dir" to "external", "include" to listOf("*.jar"))))
implementation(group = "com.velocitypowered", name = "velocity-api", version = "3.0.1")
annotationProcessor(group = "com.velocitypowered", name = "velocity-api", version = "3.0.1")
implementation(group = "com.velocitypowered", name = "velocity-api", version = "3.1.1")
annotationProcessor(group = "com.velocitypowered", name = "velocity-api", version = "3.1.1")
implementation(group = "org.bstats", name = "bstats-velocity", version = "3.0.0")
implementation(group = "org.bstats", name = "bstats-base", version = "3.0.0")
implementation(group = "org.json", name = "json", version = "20200518")
Expand Down

0 comments on commit 3821a2a

Please sign in to comment.