the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
1#pragma once
2using namespace std;
3
4#include "Packet.h"
5
6class ChatPacket : public Packet, public enable_shared_from_this<ChatPacket>
7{
8 // longest allowed string is "<" + name + "> " + message
9private:
10 static const unsigned int MAX_LENGTH;
11
12public:
13 // 4J - We want to be able to localise the messages sent. The enum also allows for the posibility that there
14 // may be different versions playing the game, so the enum should map to a string id which may be different on
15 // different versions
16 enum EChatPacketMessage
17 {
18 e_ChatCustom = 0, // No localised string, only the text passed in
19 e_ChatBedOccupied,
20 e_ChatBedNoSleep,
21 e_ChatBedNotValid,
22 e_ChatBedNotSafe,
23 e_ChatBedPlayerSleep,
24 e_ChatBedMeSleep,
25 e_ChatPlayerLeftGame,
26 e_ChatPlayerJoinedGame,
27 e_ChatPlayerKickedFromGame,
28 e_ChatCannotPlaceLava,
29
30 e_ChatDeathInFire,
31 e_ChatDeathOnFire,
32 e_ChatDeathLava,
33 e_ChatDeathInWall,
34 e_ChatDeathDrown,
35 e_ChatDeathStarve,
36 e_ChatDeathCactus,
37 e_ChatDeathFall,
38 e_ChatDeathOutOfWorld,
39 e_ChatDeathGeneric,
40 e_ChatDeathExplosion,
41 e_ChatDeathMagic,
42 e_ChatDeathMob,
43 e_ChatDeathPlayer,
44 e_ChatDeathArrow,
45 e_ChatDeathFireball,
46 e_ChatDeathThrown,
47 e_ChatDeathIndirectMagic,
48 e_ChatDeathDragonBreath,
49 e_ChatDeathAnvil,
50 e_ChatDeathFallingBlock,
51 e_ChatDeathThorns,
52
53 e_ChatDeathFellAccidentLadder,
54 e_ChatDeathFellAccidentVines,
55 e_ChatDeathFellAccidentWater,
56 e_ChatDeathFellAccidentGeneric,
57 e_ChatDeathFellKiller,
58 e_ChatDeathFellAssist,
59 e_ChatDeathFellAssistItem,
60 e_ChatDeathFellFinish,
61 e_ChatDeathFellFinishItem,
62 e_ChatDeathInFirePlayer,
63 e_ChatDeathOnFirePlayer,
64 e_ChatDeathLavaPlayer,
65 e_ChatDeathDrownPlayer,
66 e_ChatDeathCactusPlayer,
67 e_ChatDeathExplosionPlayer,
68 e_ChatDeathWither,
69 e_ChatDeathPlayerItem,
70 e_ChatDeathArrowItem,
71 e_ChatDeathFireballItem,
72 e_ChatDeathThrownItem,
73 e_ChatDeathIndirectMagicItem,
74
75 e_ChatPlayerEnteredEnd,
76 e_ChatPlayerLeftEnd,
77
78 e_ChatPlayerMaxPigsSheepCows, // tell the players they can't use the spawn egg
79 e_ChatPlayerMaxChickens, // tell the players they can't use the spawn egg
80 e_ChatPlayerMaxSquid, // tell the players they can't use the spawn egg
81 e_ChatPlayerMaxMooshrooms, // tell the players they can't use the spawn egg
82 e_ChatPlayerMaxWolves, // tell the players they can't use the spawn egg
83 e_ChatPlayerMaxAnimals, // tell the players they can't use the spawn egg
84 e_ChatPlayerMaxEnemies, // tell the players they can't use the spawn egg
85 e_ChatPlayerMaxVillagers, // tell the players they can't use the spawn egg
86 e_ChatPlayerMaxHangingEntities, // tell the players they hit the picture/itemframe limit
87 e_ChatPlayerCantSpawnInPeaceful, // Tell the player they can't spawn enemies in peaceful mode
88 e_ChatPlayerMaxBredAnimals, // Tell the player they can't put this animal in love mode because no breeding can be done
89 e_ChatPlayerMaxBredPigsSheepCows, // Tell the player they can't put this animal in love mode because no breeding can be done
90 e_ChatPlayerMaxBredChickens, // Tell the player they can't put this animal in love mode because no breeding can be done
91 e_ChatPlayerMaxBredMooshrooms, // Tell the player they can't put this animal in love mode because no breeding can be done
92 e_ChatPlayerMaxBredWolves, // Tell the player they can't put this wolf in love mode because no breeding can be done
93 e_ChatPlayerCantShearMooshroom, // Tell the player they can't shear because the limits have been reached
94 e_ChatPlayerMaxBoats,
95 e_ChatPlayerMaxBats,
96
97 e_ChatCommandTeleportSuccess,
98 e_ChatCommandTeleportMe,
99 e_ChatCommandTeleportToMe,
100
101 };
102
103public:
104 vector<wstring> m_stringArgs;
105 vector<int> m_intArgs;
106 EChatPacketMessage m_messageType;
107
108 ChatPacket();
109
110 // 4J: Seperated the one convoluted ctor into three more readable ctors. The last two ctors are only used for death messages and I'd really
111 // like to consolodate them and/or the logic that uses them at some point.
112 ChatPacket(const wstring& message, EChatPacketMessage type = e_ChatCustom, int customData = -1);
113 ChatPacket(const wstring& message, EChatPacketMessage type, int sourceEntityType, const wstring& sourceName);
114 ChatPacket(const wstring& message, EChatPacketMessage type, int sourceEntityType, const wstring& sourceName, const wstring& itemName);
115
116 virtual void read(DataInputStream *dis);
117 virtual void write(DataOutputStream *dos);
118 virtual void handle(PacketListener *listener);
119 virtual int getEstimatedSize();
120
121public:
122 static shared_ptr<Packet> create() { return shared_ptr<Packet>(new ChatPacket()); }
123 virtual int getId() { return 3; }
124};
125