azaanpapa804-sketch

make me a plugin for velocity proxy that when i go in server so every servers that are connected to velocity gave a /hub command and it executes and i will go in /server hub make it fast

Kodari AI
KodariMar 24 at 7:10 am 3,956 (v2)

I’ll create a Velocity proxy plugin with a /hub command that sends players to the hub server.

VelocityHub
A lightweight Velocity proxy plugin that provides a /hub command accessible from all connected servers. Players can instantly return to the hub server using this command. Supports configurable hub server name and customizable messages with full Adventure Component support.

Done! Created a Velocity proxy plugin with /hub command that works across all connected servers. The command sends players to the hub server configured in config.yml (defaults to “hub”). Includes /lobby alias and customizable messages.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
settings.gradle
Code
7 253
src/main/java/com/velocityhub/Config.java
package com.velocityhub;

import java.io.*;
import java.util.HashMap;
import java.util.Map;

public class Config {
    
    private final Map<String, String> values;

    public Config(File file) {
        this.values = new HashMap<>();
        
        values.put("hub-server", "hub");
        values.put("message-teleporting", "&ateleporting to hub...");
        values.put("message-already-connected", "&cYou are already connected to the hub!");
        values.put("message-hub-not-found", "&cHub server not found!");
        
        if (file != null && file.exists()) {
            loadFromFile(file);
        } else if (file != null) {
            saveToFile(file);
        }
    }

    private void loadFromFile(File file) {
        try (BufferedReader reader = new BufferedReader(new FileReader(file))) {
            String line;
            while ((line = reader.readLine()) != null) {
                line = line.trim();
                if (line.isEmpty() || line.startsWith("#")) {
                    continue;
                }
                
                String[] parts = line.split(":", 2);
                if (parts.length == 2) {
                    String key = parts[0].trim();
                    String value = parts[1].trim();
                    if (value.startsWith("'") && value.endsWith("'")) {
                        value = value.substring(1, value.length() - 1);
                    } else if (value.startsWith("\"") && value.endsWith("\"")) {
                        value = value.substring(1, value.length() - 1);
                    }
                    values.put(key, value);
                }
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    private void saveToFile(File file) {
        try (BufferedWriter writer = new BufferedWriter(new FileWriter(file))) {
            writer.write("# VelocityHub Configuration\n");
            writer.write("# Hub server name (must match server name in velocity.toml)\n");
            writer.write("hub-server: 'hub'\n\n");
            writer.write("# Messages\n");
            writer.write("message-teleporting: '&aTeleporting to hub...'\n");
            writer.write("message-already-connected: '&cYou are already connected to the hub!'\n");
            writer.write("message-hub-not-found: '&cHub server not found!'\n");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public String getString(String key) {
        return values.getOrDefault(key, "");
    }
}