input dev-01
This commit is contained in:
parent
b8c65cb537
commit
a01b4b4330
@ -56,5 +56,10 @@
|
||||
<option name="name" value="BenCodez Repo" />
|
||||
<option name="url" value="https://nexus.bencodez.com/repository/maven-public/" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="papermc" />
|
||||
<option name="name" value="papermc" />
|
||||
<option name="url" value="https://repo.papermc.io/repository/maven-public/" />
|
||||
</remote-repository>
|
||||
</component>
|
||||
</project>
|
15
pom.xml
15
pom.xml
@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>net.t2code</groupId>
|
||||
<artifactId>T2CodeLib</artifactId>
|
||||
<version>16.7</version>
|
||||
<version>16.7_dev-01</version>
|
||||
<!--version>VERSION_snapshot-0</version-->
|
||||
<!--version>VERSION_beta-0</version-->
|
||||
<!--version>VERSION_dev-0</version-->
|
||||
@ -63,6 +63,10 @@
|
||||
</build>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>papermc</id>
|
||||
<url>https://repo.papermc.io/repository/maven-public/</url>
|
||||
</repository>
|
||||
<!-- Spigot -->
|
||||
<repository>
|
||||
<id>spigot-repo</id>
|
||||
@ -114,6 +118,14 @@
|
||||
|
||||
|
||||
<dependencies>
|
||||
<!-- Velocity -->
|
||||
<dependency>
|
||||
<groupId>com.velocitypowered</groupId>
|
||||
<artifactId>velocity-api</artifactId>
|
||||
<version>3.2.0-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- Spigot-->
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
@ -227,6 +239,7 @@
|
||||
<version>20230227</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
118
src/main/java/net/t2code/t2codelib/Velocity/VelocityMain.java
Normal file
118
src/main/java/net/t2code/t2codelib/Velocity/VelocityMain.java
Normal file
@ -0,0 +1,118 @@
|
||||
package net.t2code.t2codelib.Velocity;
|
||||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
import com.google.common.io.ByteStreams;
|
||||
import com.google.inject.Inject;
|
||||
import com.velocitypowered.api.command.CommandManager;
|
||||
import com.velocitypowered.api.command.CommandSource;
|
||||
import com.velocitypowered.api.event.Subscribe;
|
||||
import com.velocitypowered.api.event.connection.PluginMessageEvent;
|
||||
import com.velocitypowered.api.event.proxy.ProxyInitializeEvent;
|
||||
import com.velocitypowered.api.plugin.Plugin;
|
||||
import com.velocitypowered.api.proxy.ConsoleCommandSource;
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
import com.velocitypowered.api.proxy.ProxyServer;
|
||||
import com.velocitypowered.api.proxy.messages.MinecraftChannelIdentifier;
|
||||
import net.t2code.t2codelib.Util;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
|
||||
|
||||
@Plugin(id = "t2codelib", name = "T2CodeLib", version = "16.7_dev-01", authors = {"JaTiTV"})
|
||||
public class VelocityMain {
|
||||
|
||||
String prefix = "[T2CodeLib]";
|
||||
|
||||
protected final ProxyServer server;
|
||||
protected final Logger logger;
|
||||
public static final MinecraftChannelIdentifier IDENTIFIER = MinecraftChannelIdentifier.from("t2c:bcmd");
|
||||
// public static final MinecraftChannelIdentifier IDENTIFIER2 = MinecraftChannelIdentifier.from("booster:activate");
|
||||
|
||||
@Inject
|
||||
public VelocityMain(ProxyServer server, Logger logger) {
|
||||
long long_ = System.currentTimeMillis();
|
||||
this.server = server;
|
||||
this.logger = logger;
|
||||
|
||||
logger.info("============================= {} =============================", prefix);
|
||||
logger.info("Autor: JaTiTV");
|
||||
logger.info("Version: 16.7_dev-01");
|
||||
logger.info("Plugin loaded successfully. - {}ms", System.currentTimeMillis() - long_);
|
||||
logger.info("============================= {} =============================", prefix);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Subscribe
|
||||
public void onProxyInitialization(ProxyInitializeEvent event) {
|
||||
server.getChannelRegistrar().register(IDENTIFIER);
|
||||
// server.getChannelRegistrar().register(IDENTIFIER2);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onPluginMessageFromPlayer(PluginMessageEvent event) {
|
||||
if (event.getIdentifier() != IDENTIFIER) {
|
||||
return;
|
||||
}
|
||||
ByteArrayDataInput stream = ByteStreams.newDataInput(event.getData());
|
||||
String channel = stream.readUTF();
|
||||
String input = stream.readUTF();
|
||||
String serverID;
|
||||
try {
|
||||
serverID = stream.readUTF();
|
||||
} catch (Exception i) {
|
||||
serverID = "not Found";
|
||||
}
|
||||
|
||||
if (channel.equals("T2Code-Console")) {
|
||||
logger.info("{} [{}] T2C BCMD Command Console: {}", prefix, serverID, input);
|
||||
dispatchCommand(input);
|
||||
} else {
|
||||
Player player = server.getPlayer(channel).orElse(null);
|
||||
if (player != null) {
|
||||
logger.info("{} [{}] T2C BCMD Command {}: {}", prefix, serverID, player, input);
|
||||
executeCommand(player, input);
|
||||
}
|
||||
}
|
||||
event.setResult(PluginMessageEvent.ForwardResult.handled());
|
||||
}
|
||||
|
||||
// public void sendToSpigot(String sender, String boostertype, String step, String starter, String starttime, String starteruuid) {
|
||||
// ByteArrayOutputStream stream = new ByteArrayOutputStream();
|
||||
// DataOutputStream output = new DataOutputStream(stream);
|
||||
// try {
|
||||
// output.writeUTF(boostertype);
|
||||
// output.writeUTF(step);
|
||||
// output.writeUTF(starter);
|
||||
// output.writeUTF(starttime);
|
||||
// output.writeUTF(starteruuid);
|
||||
// } catch (IOException e) {
|
||||
// java.util.logging.Logger.getLogger(e.getMessage());
|
||||
// }
|
||||
// Optional<Player> player = server.getPlayer(sender);
|
||||
// if (!player.isPresent()) {
|
||||
// return;
|
||||
// }
|
||||
// server.getAllServers().forEach((server) -> {
|
||||
// if (server != player.get().getCurrentServer().get().getServer()) {
|
||||
// server.sendPluginMessage(IDENTIFIER2, stream.toByteArray());
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
|
||||
public void dispatchCommand(String input) {
|
||||
// Get the console command source
|
||||
ConsoleCommandSource console = server.getConsoleCommandSource();
|
||||
|
||||
// Dispatch the command
|
||||
server.getCommandManager().executeAsync(console, input).join();
|
||||
}
|
||||
|
||||
public void executeCommand(Player player, String input) {
|
||||
CommandManager commandManager = server.getCommandManager();
|
||||
|
||||
// Dispatch the command
|
||||
commandManager.executeImmediatelyAsync(player, input);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user