mirror of
https://github.com/proxiodev/RedisBungee.git
synced 2026-04-08 16:10:26 +00:00
new command infrastructure
This commit is contained in:
@@ -22,6 +22,7 @@ dependencies {
|
||||
}
|
||||
compileOnly(libs.platform.velocity)
|
||||
annotationProcessor(libs.platform.velocity)
|
||||
implementation(project(":RedisBungee-Commands"))
|
||||
implementation(libs.acf.velocity)
|
||||
|
||||
}
|
||||
|
||||
@@ -10,11 +10,14 @@
|
||||
|
||||
package com.imaginarycode.minecraft.redisbungee;
|
||||
|
||||
import co.aikar.commands.VelocityCommandManager;
|
||||
import com.google.inject.Inject;
|
||||
import com.imaginarycode.minecraft.redisbungee.api.PlayerDataManager;
|
||||
import com.imaginarycode.minecraft.redisbungee.api.ProxyDataManager;
|
||||
import com.imaginarycode.minecraft.redisbungee.api.RedisBungeeMode;
|
||||
import com.imaginarycode.minecraft.redisbungee.api.RedisBungeePlugin;
|
||||
import com.imaginarycode.minecraft.redisbungee.commands.CommandLoader;
|
||||
import com.imaginarycode.minecraft.redisbungee.commands.utils.CommandPlatformHelper;
|
||||
import com.imaginarycode.minecraft.redisbungee.api.config.LangConfiguration;
|
||||
import com.imaginarycode.minecraft.redisbungee.api.config.loaders.ConfigLoader;
|
||||
import com.imaginarycode.minecraft.redisbungee.api.config.RedisBungeeConfiguration;
|
||||
@@ -91,6 +94,8 @@ public class RedisBungeeVelocityPlugin implements RedisBungeePlugin<Player>, Con
|
||||
new LegacyChannelIdentifier("legacy:redisbungee")
|
||||
);
|
||||
|
||||
private VelocityCommandManager commandManager;
|
||||
|
||||
@Inject
|
||||
public RedisBungeeVelocityPlugin(ProxyServer server, Logger logger, @DataDirectory Path dataDirectory) {
|
||||
this.server = server;
|
||||
@@ -264,7 +269,6 @@ public class RedisBungeeVelocityPlugin implements RedisBungeePlugin<Player>, Con
|
||||
@Override
|
||||
public void initialize() {
|
||||
logInfo("Initializing RedisBungee.....");
|
||||
;
|
||||
// start heartbeat task
|
||||
// heartbeat and clean up
|
||||
this.heartbeatTask = server.getScheduler().buildTask(this, this.proxyDataManager::publishHeartbeat).repeat(Duration.ofSeconds(1)).schedule();
|
||||
@@ -279,6 +283,11 @@ public class RedisBungeeVelocityPlugin implements RedisBungeePlugin<Player>, Con
|
||||
// register plugin messages
|
||||
IDENTIFIERS.forEach(getProxy().getChannelRegistrar()::register);
|
||||
|
||||
// load commands
|
||||
CommandPlatformHelper.init(new VelocityCommandPlatformHelper());
|
||||
this.commandManager = new VelocityCommandManager(this.getProxy(), this);
|
||||
CommandLoader.initCommands(this.commandManager, configuration());
|
||||
|
||||
logInfo("RedisBungee initialized successfully ");
|
||||
}
|
||||
|
||||
@@ -308,6 +317,7 @@ public class RedisBungeeVelocityPlugin implements RedisBungeePlugin<Player>, Con
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
if (commandManager != null) commandManager.unregisterCommands();
|
||||
logInfo("RedisBungee shutdown complete");
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright (c) 2013-present RedisBungee contributors
|
||||
*
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
*
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
|
||||
package com.imaginarycode.minecraft.redisbungee;
|
||||
|
||||
import co.aikar.commands.CommandIssuer;
|
||||
import co.aikar.commands.VelocityCommandIssuer;
|
||||
import com.imaginarycode.minecraft.redisbungee.commands.utils.CommandPlatformHelper;
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
||||
public class VelocityCommandPlatformHelper extends CommandPlatformHelper {
|
||||
|
||||
@Override
|
||||
public void sendMessage(CommandIssuer issuer, Component component) {
|
||||
VelocityCommandIssuer vIssuer = (VelocityCommandIssuer) issuer;
|
||||
vIssuer.getIssuer().sendMessage(component);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user