mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-18 20:05:02 -04:00
remove deprecated PacketSender
This commit is contained in:
parent
948338a1ac
commit
a69b4b0e23
@ -50,7 +50,6 @@ import de.bixilon.minosoft.protocol.network.connection.Connection
|
|||||||
import de.bixilon.minosoft.protocol.network.connection.play.clientsettings.ClientSettingsManager
|
import de.bixilon.minosoft.protocol.network.connection.play.clientsettings.ClientSettingsManager
|
||||||
import de.bixilon.minosoft.protocol.packets.c2s.handshaking.HandshakeC2SP
|
import de.bixilon.minosoft.protocol.packets.c2s.handshaking.HandshakeC2SP
|
||||||
import de.bixilon.minosoft.protocol.packets.c2s.login.StartC2SP
|
import de.bixilon.minosoft.protocol.packets.c2s.login.StartC2SP
|
||||||
import de.bixilon.minosoft.protocol.protocol.PacketSender
|
|
||||||
import de.bixilon.minosoft.protocol.protocol.ProtocolDefinition
|
import de.bixilon.minosoft.protocol.protocol.ProtocolDefinition
|
||||||
import de.bixilon.minosoft.protocol.protocol.ProtocolStates
|
import de.bixilon.minosoft.protocol.protocol.ProtocolStates
|
||||||
import de.bixilon.minosoft.terminal.CLI
|
import de.bixilon.minosoft.terminal.CLI
|
||||||
@ -76,7 +75,6 @@ class PlayConnection(
|
|||||||
val bossbarManager = BossbarManager()
|
val bossbarManager = BossbarManager()
|
||||||
val util = ConnectionUtil(this)
|
val util = ConnectionUtil(this)
|
||||||
|
|
||||||
@Deprecated(message = "PacketSender is deprecated") val sender = PacketSender(this)
|
|
||||||
val serverInfo = ServerInfo()
|
val serverInfo = ServerInfo()
|
||||||
lateinit var assetsManager: AssetsManager
|
lateinit var assetsManager: AssetsManager
|
||||||
private set
|
private set
|
||||||
|
@ -15,6 +15,7 @@ package de.bixilon.minosoft.protocol.packets.s2c.play
|
|||||||
import de.bixilon.kutil.math.MMath.clamp
|
import de.bixilon.kutil.math.MMath.clamp
|
||||||
import de.bixilon.minosoft.modding.event.events.UpdateHealthEvent
|
import de.bixilon.minosoft.modding.event.events.UpdateHealthEvent
|
||||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
||||||
|
import de.bixilon.minosoft.protocol.packets.c2s.play.ClientActionC2SP
|
||||||
import de.bixilon.minosoft.protocol.packets.factory.LoadPacket
|
import de.bixilon.minosoft.protocol.packets.factory.LoadPacket
|
||||||
import de.bixilon.minosoft.protocol.packets.s2c.PlayS2CPacket
|
import de.bixilon.minosoft.protocol.packets.s2c.PlayS2CPacket
|
||||||
import de.bixilon.minosoft.protocol.protocol.PlayInByteBuffer
|
import de.bixilon.minosoft.protocol.protocol.PlayInByteBuffer
|
||||||
@ -41,8 +42,8 @@ class HealthS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
|||||||
|
|
||||||
connection.fireEvent(UpdateHealthEvent(connection, this))
|
connection.fireEvent(UpdateHealthEvent(connection, this))
|
||||||
if (hp == 0.0f) {
|
if (hp == 0.0f) {
|
||||||
// do respawn
|
// ToDo: remove auto respawn
|
||||||
connection.sender.respawn()
|
connection.network.send(ClientActionC2SP(ClientActionC2SP.ClientActions.PERFORM_RESPAWN))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,72 +0,0 @@
|
|||||||
/*
|
|
||||||
* Minosoft
|
|
||||||
* Copyright (C) 2020-2022 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.data.ChatTextPositions;
|
|
||||||
import de.bixilon.minosoft.data.text.ChatComponent;
|
|
||||||
import de.bixilon.minosoft.modding.event.EventInitiators;
|
|
||||||
import de.bixilon.minosoft.modding.event.events.ChatMessageReceiveEvent;
|
|
||||||
import de.bixilon.minosoft.modding.event.events.ChatMessageSendEvent;
|
|
||||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection;
|
|
||||||
import de.bixilon.minosoft.protocol.packets.c2s.play.ClientActionC2SP;
|
|
||||||
import de.bixilon.minosoft.protocol.packets.c2s.play.chat.ChatMessageC2SP;
|
|
||||||
import de.bixilon.minosoft.util.logging.Log;
|
|
||||||
import de.bixilon.minosoft.util.logging.LogMessageType;
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public class PacketSender {
|
|
||||||
public static final char[] ILLEGAL_CHAT_CHARS = {'§'};
|
|
||||||
private final PlayConnection connection;
|
|
||||||
|
|
||||||
public PacketSender(PlayConnection connection) {
|
|
||||||
this.connection = connection;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void sendChatMessage(String message) {
|
|
||||||
if (StringUtils.isBlank(message)) {
|
|
||||||
// throw new IllegalArgumentException(("Chat message is blank!"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
for (char illegalChar : ILLEGAL_CHAT_CHARS) {
|
|
||||||
if (message.indexOf(illegalChar) != -1) {
|
|
||||||
// throw new IllegalArgumentException(String.format("%s is not allowed in chat", illegalChar));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ChatMessageSendEvent event = new ChatMessageSendEvent(this.connection, message);
|
|
||||||
if (this.connection.fireEvent(event)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Log.log(LogMessageType.CHAT_OUT, message);
|
|
||||||
this.connection.sendPacket(new ChatMessageC2SP(event.getMessage()));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void respawn() {
|
|
||||||
sendClientStatus(ClientActionC2SP.ClientActions.PERFORM_RESPAWN);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void sendClientStatus(ClientActionC2SP.ClientActions status) {
|
|
||||||
this.connection.sendPacket(new ClientActionC2SP(status));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void sendFakeChatMessage(ChatComponent message, ChatTextPositions position) {
|
|
||||||
this.connection.fireEvent(new ChatMessageReceiveEvent(this.connection, EventInitiators.CLIENT, message, position, null));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void sendFakeChatMessage(Object message) {
|
|
||||||
sendFakeChatMessage(ChatComponent.Companion.of(message), ChatTextPositions.CHAT_BOX);
|
|
||||||
}
|
|
||||||
}
|
|
@ -19,8 +19,14 @@ import de.bixilon.minosoft.data.commands.CommandNode;
|
|||||||
import de.bixilon.minosoft.data.commands.CommandRootNode;
|
import de.bixilon.minosoft.data.commands.CommandRootNode;
|
||||||
import de.bixilon.minosoft.data.commands.parser.MessageParser;
|
import de.bixilon.minosoft.data.commands.parser.MessageParser;
|
||||||
import de.bixilon.minosoft.data.commands.parser.exceptions.CommandParseException;
|
import de.bixilon.minosoft.data.commands.parser.exceptions.CommandParseException;
|
||||||
|
import de.bixilon.minosoft.modding.event.events.ChatMessageSendEvent;
|
||||||
|
import de.bixilon.minosoft.protocol.packets.c2s.play.chat.ChatMessageC2SP;
|
||||||
|
import de.bixilon.minosoft.util.logging.Log;
|
||||||
|
import de.bixilon.minosoft.util.logging.LogMessageType;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
public class CommandSendChat extends Command {
|
public class CommandSendChat extends Command {
|
||||||
|
public static final char[] ILLEGAL_CHAT_CHARS = {'§'};
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandNode build(CommandNode parent) {
|
public CommandNode build(CommandNode parent) {
|
||||||
@ -41,7 +47,23 @@ public class CommandSendChat extends Command {
|
|||||||
// return;
|
// return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
connection.getSender().sendChatMessage(message);
|
|
||||||
|
if (StringUtils.isBlank(message)) {
|
||||||
|
// throw new IllegalArgumentException(("Chat message is blank!"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (char illegalChar : ILLEGAL_CHAT_CHARS) {
|
||||||
|
if (message.indexOf(illegalChar) != -1) {
|
||||||
|
// throw new IllegalArgumentException(String.format("%s is not allowed in chat", illegalChar));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ChatMessageSendEvent event = new ChatMessageSendEvent(connection, message);
|
||||||
|
if (connection.fireEvent(event)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Log.log(LogMessageType.CHAT_OUT, message);
|
||||||
|
connection.sendPacket(new ChatMessageC2SP(event.getMessage()));
|
||||||
})));
|
})));
|
||||||
return parent;
|
return parent;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user