mirror of
https://github.com/GTNewHorizons/CraftTweaker.git
synced 2026-11-27 15:23:03 +00:00
Add a chat message length limit to avoid crashing with too big packets sent to clients.
This commit is contained in:
1 parent
236744c74e
commit
8abb3efbfb
6 files changed
+42
-24
No files matched your search
@@ -51,25 +51,25 @@ public class MCPlayer implements IPlayer {
|
||||
public IData getData() {
|
||||
return NBTConverter.from(player.getEntityData(), true);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getXP() {
|
||||
return player.experienceLevel;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setXP(int xp) {
|
||||
player.experienceLevel = 0;
|
||||
player.addExperienceLevel(xp);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void removeXP(int xp) {
|
||||
final int newLvl = Math.max(0, player.experienceLevel - xp);
|
||||
player.experienceLevel = 0;
|
||||
player.addExperienceLevel(newLvl);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void update(IData data) {
|
||||
NBTConverter.updateMap(player.getEntityData(), data);
|
||||
@@ -87,6 +87,10 @@ public class MCPlayer implements IPlayer {
|
||||
|
||||
@Override
|
||||
public void sendChat(String message) {
|
||||
if (message.length() > MAX_CHAT_MESSAGE_LENGTH)
|
||||
{
|
||||
message = message.substring(0, MAX_CHAT_MESSAGE_LENGTH);
|
||||
}
|
||||
player.addChatMessage(new ChatComponentText(message));
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user