mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-18 20:05:02 -04:00
wip: PacketSender (use this to interact with the server)
This commit is contained in:
parent
17656a82bc
commit
598925ba5b
@ -23,7 +23,6 @@ import de.bixilon.minosoft.protocol.packets.ClientboundPacket;
|
||||
import de.bixilon.minosoft.protocol.packets.ServerboundPacket;
|
||||
import de.bixilon.minosoft.protocol.packets.serverbound.handshaking.PacketHandshake;
|
||||
import de.bixilon.minosoft.protocol.packets.serverbound.login.PacketLoginStart;
|
||||
import de.bixilon.minosoft.protocol.packets.serverbound.play.PacketChatMessage;
|
||||
import de.bixilon.minosoft.protocol.packets.serverbound.status.PacketStatusPing;
|
||||
import de.bixilon.minosoft.protocol.packets.serverbound.status.PacketStatusRequest;
|
||||
import de.bixilon.minosoft.protocol.protocol.*;
|
||||
@ -35,6 +34,7 @@ public class Connection {
|
||||
final int port;
|
||||
final Network network;
|
||||
final PacketHandler handler;
|
||||
final PacketSender sender;
|
||||
final ArrayList<ClientboundPacket> handlingQueue;
|
||||
PluginChannelHandler pluginChannelHandler;
|
||||
Thread handleThread;
|
||||
@ -49,6 +49,7 @@ public class Connection {
|
||||
network = new Network(this);
|
||||
handlingQueue = new ArrayList<>();
|
||||
handler = new PacketHandler(this);
|
||||
sender = new PacketSender(this);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -188,10 +189,6 @@ public class Connection {
|
||||
handleThread.start();
|
||||
}
|
||||
|
||||
public void sendChatMessage(String message) {
|
||||
sendPacket(new PacketChatMessage(message));
|
||||
}
|
||||
|
||||
public PluginChannelHandler getPluginChannelHandler() {
|
||||
return pluginChannelHandler;
|
||||
}
|
||||
@ -220,4 +217,8 @@ public class Connection {
|
||||
public boolean isConnected() {
|
||||
return network.isConnected();
|
||||
}
|
||||
|
||||
public PacketSender getSender() {
|
||||
return sender;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Codename Minosoft
|
||||
* Copyright (C) 2020 Moritz Zwerger
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||
*/
|
||||
|
||||
package de.bixilon.minosoft.protocol.protocol;
|
||||
|
||||
import de.bixilon.minosoft.protocol.network.Connection;
|
||||
import de.bixilon.minosoft.protocol.packets.serverbound.play.PacketChatMessage;
|
||||
import de.bixilon.minosoft.protocol.packets.serverbound.play.PacketHeldItemChangeSending;
|
||||
import de.bixilon.minosoft.protocol.packets.serverbound.play.PacketPlayerAbilitiesSending;
|
||||
import de.bixilon.minosoft.protocol.packets.serverbound.play.PacketSpectate;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class PacketSender {
|
||||
final Connection connection;
|
||||
|
||||
public PacketSender(Connection connection) {
|
||||
this.connection = connection;
|
||||
}
|
||||
|
||||
public void setFlyStatus(boolean flying) {
|
||||
connection.sendPacket(new PacketPlayerAbilitiesSending(flying));
|
||||
}
|
||||
|
||||
public void sendChatMessage(String message) {
|
||||
connection.sendPacket(new PacketChatMessage(message));
|
||||
}
|
||||
|
||||
public void spectateEntity(UUID entityUUID) {
|
||||
connection.sendPacket(new PacketSpectate(entityUUID));
|
||||
}
|
||||
|
||||
public void setSlot(int slotId) {
|
||||
connection.sendPacket(new PacketHeldItemChangeSending(slotId));
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user