Velocity4.2Official#proxy#velocity
Proxy Hub
Velocity proxy eklentisi başlangıcı.
Tüm hakları saklıdırUse on serverModifyCommercial· Attribution
src/main/java/com/minborai/proxyhub/ProxyHub.java
1package com.minborai.proxyhub;23import com.google.inject.Inject;4import com.velocitypowered.api.command.CommandManager;5import com.velocitypowered.api.command.CommandMeta;6import com.velocitypowered.api.command.SimpleCommand;7import com.velocitypowered.api.event.Subscribe;8import com.velocitypowered.api.event.proxy.ProxyInitializeEvent;9import com.velocitypowered.api.plugin.Plugin;10import com.velocitypowered.api.proxy.ProxyServer;11import net.kyori.adventure.text.Component;12import net.kyori.adventure.text.format.NamedTextColor;13import org.slf4j.Logger;1415@Plugin(16id = "proxyhub",17name = "Proxy Hub",18version = "1.0.0",19description = "Güvenli yetki kontrolüne sahip Velocity komut örneği.",20authors = {"MinborAI"}21)22public final class ProxyHub {2324private final ProxyServer server;25private final Logger logger;2627@Inject28public ProxyHub(ProxyServer server, Logger logger) {29this.server = server;30this.logger = logger;31}3233@Subscribe34public void onProxyInitialize(ProxyInitializeEvent event) {35CommandManager commandManager = server.getCommandManager();3637CommandMeta meta = commandManager.metaBuilder("guvenlikontrol")38.plugin(this)39.build();4041commandManager.register(meta, new SafeAdminCommand());42logger.info("Proxy Hub ve komutlar başarıyla yüklendi.");43}4445private static class SafeAdminCommand implements SimpleCommand {46@Override47public void execute(Invocation invocation) {48// İzin kontrolü: Yetkisi olmayan kullanıcıların komutu tetiklemesi engellenir49if (!invocation.source().hasPermission("proxyhub.admin")) {50invocation.source().sendMessage(51Component.text("Bu komutu kullanmak için yetkiniz yok!", NamedTextColor.RED)52);53return;54}5556invocation.source().sendMessage(57Component.text("Yetki doğrulandı. İşlem güvenli.", NamedTextColor.GREEN)58);59}6061@Override62public boolean hasPermission(Invocation invocation) {63return invocation.source().hasPermission("proxyhub.admin");64}65}66}