Skip to content

Commit ecd3817

Browse files
committed
execute as-player packet
1 parent 67b2ce6 commit ecd3817

File tree

3 files changed

+35
-2
lines changed

3 files changed

+35
-2
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
<dependency>
2727
<groupId>net.md-5</groupId>
2828
<artifactId>bungeecord-proxy</artifactId>
29-
<version>1.18-SNAPSHOT</version>
29+
<version>1.19-SNAPSHOT</version>
3030
<scope>system</scope>
3131
<systemPath>${basedir}/lib/BungeeCord.jar</systemPath>
3232
</dependency>

src/main/java/com/denizenscript/depenizen/bungee/DepenizenBungee.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ public void registerPackets() {
7171
packets.put(15, new ExecuteCommandPacketIn());
7272
packets.put(16, new ControlProxyCommandPacketIn());
7373
packets.put(17, new ProxyCommandResultPacketIn());
74+
packets.put(18, new ExecutePlayerCommandPacketIn());
7475
}
7576

7677
@Override
@@ -252,7 +253,8 @@ public void onPlayerHandshake(PlayerHandshakeEvent event) {
252253
}
253254
}
254255
if (!isValid) {
255-
getLogger().warning("INVALID/FAKE Depenizen connection denied from: " + handler.getAddress() + "... if this was meant to be a real connection, make sure the server address in bungee.yml matches the IP shown here.");
256+
getLogger().warning("INVALID/FAKE Depenizen connection denied from: " + handler.getAddress()
257+
+ "... if this was meant to be a real connection, make sure the server address in your Bungee/config.yml matches the IP shown here.");
256258
return;
257259
}
258260
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package com.denizenscript.depenizen.bungee.packets.in;
2+
3+
import com.denizenscript.depenizen.bungee.DepenizenConnection;
4+
import com.denizenscript.depenizen.bungee.PacketIn;
5+
import io.netty.buffer.ByteBuf;
6+
import net.md_5.bungee.api.ProxyServer;
7+
import net.md_5.bungee.api.connection.ProxiedPlayer;
8+
9+
import java.util.UUID;
10+
11+
public class ExecutePlayerCommandPacketIn extends PacketIn {
12+
13+
@Override
14+
public String getName() {
15+
return "ExecutePlayerCommand";
16+
}
17+
18+
@Override
19+
public void process(DepenizenConnection connection, ByteBuf data) {
20+
String player = readString(connection, data, "player");
21+
String command = readString(connection, data, "command");
22+
if (command == null || player == null) {
23+
return;
24+
}
25+
ProxiedPlayer playerObj = ProxyServer.getInstance().getPlayer(UUID.fromString(player));
26+
if (playerObj == null) {
27+
return;
28+
}
29+
ProxyServer.getInstance().getPluginManager().dispatchCommand(playerObj, command);
30+
}
31+
}

0 commit comments

Comments
 (0)