Skip to content

Commit 1d3d456

Browse files
author
magiclu550
committed
[JSMOD@2_477_COMMIT] a half of Player
1 parent c2f8b0c commit 1d3d456

File tree

3 files changed

+84
-15
lines changed

3 files changed

+84
-15
lines changed

JSMod2API/src/main/java/cn/jsmod2/api/item/Item.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,5 +90,5 @@ public void setInWorld(boolean inWord) {
9090
packet.setInWorld = inWord;
9191
packet.send();
9292
}
93-
93+
9494
}

JSMod2API/src/main/java/cn/jsmod2/api/player/Player.java

Lines changed: 82 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
import cn.jsmod2.core.CommandSender;
1919
import cn.jsmod2.core.Server;
2020
import cn.jsmod2.core.math.Vector;
21+
import cn.jsmod2.network.DoGetStream;
22+
import cn.jsmod2.network.DoStream;
2123
import cn.jsmod2.network.SimpleGetStream;
2224
import cn.jsmod2.network.SimpleSetStream;
2325

@@ -67,29 +69,40 @@ public String getIpAddress() {
6769

6870
public int getPlayerId() {
6971
SimpleGetStream stream = new SimpleGetStream(Integer.class);
72+
playerId = stream.read(playerName,"PlayerId",Integer.class);
7073
return playerId;
7174
}
7275

7376

7477
public String getSteamId() {
78+
SimpleGetStream stream = new SimpleGetStream(String.class);
79+
steamId = stream.read(playerName,"SteamId",String.class);
7580
return steamId;
7681
}
7782

7883

7984
public RadioStatus getRadioStatus() {
85+
SimpleGetStream stream = new SimpleGetStream(RadioStatus.class);
86+
radioStatus = stream.read(playerName,"RadioStatus",RadioStatus.class);
8087
return radioStatus;
8188
}
8289

8390
public void setRadioStatus(RadioStatus radioStatus) {
91+
SimpleSetStream stream = new SimpleSetStream();
92+
stream.write(playerName,"RadioStatus",radioStatus);
8493
this.radioStatus = radioStatus;
8594
}
8695

8796
public boolean isOverwatchMode() {
97+
SimpleGetStream stream = new SimpleGetStream(Boolean.class);
98+
overwatchMode = stream.read(playerName,"OverWatchMode",Boolean.class);
8899
return overwatchMode;
89100
}
90101

91102

92103
public boolean isDoNotTrack() {
104+
SimpleGetStream stream = new SimpleGetStream(Boolean.class);
105+
doNotTrack = stream.read(playerName,"DoNotTrack",Boolean.class);
93106
return doNotTrack;
94107
}
95108

@@ -100,78 +113,133 @@ public Scp079Data getScp079Data() {
100113

101114

102115
public void kill(DamageType type){
103-
116+
DoStream stream = new DoStream();
117+
stream.method = "Kill";
118+
stream.args = new String[]{"'"+type+"'"};
119+
stream.playerName = playerName;
120+
stream.send();
104121
}
105122

106123
public void kill(){
107124
kill(DamageType.NUKE);
108125
}
109126

110127
public int getHealth(){
111-
return 0;
128+
DoGetStream stream = new DoGetStream(Integer.class);
129+
stream.method = "GetHealth";
130+
return (Integer)stream.send();
112131
}
113132

114133
public void addHealth(int amount){
134+
DoStream stream = new DoStream();
135+
stream.args = new String[]{amount+""};
136+
stream.method = "AddHealth";
137+
stream.playerName = playerName;
138+
stream.send();
115139
//发包
116140
}
117141

118142
public void damage(int amount,DamageType type){
119-
143+
DoStream stream = new DoStream();
144+
stream.playerName = playerName;
145+
stream.method = "Damage";
146+
stream.args = new String[]{amount+"","'"+type+"'"};
147+
stream.send();
120148
}
121149

122150
public void damage(int amount){
123151
damage(amount,DamageType.NUKE);
124152
}
125153

126154
public void setHealth(int amount,DamageType type){
127-
155+
DoStream stream = new DoStream();
156+
stream.method = "SetHealth";
157+
stream.playerName = playerName;
158+
stream.args = new String[]{amount+"","'"+type+"'"};
128159
}
129160

130161
public void setHealth(int amount){
131162
setHealth(amount,DamageType.NUKE);
132163
}
133164

134165
public int getAmmo(AmmoType type){
135-
return 0;
166+
DoGetStream stream = new DoGetStream(AmmoType.class);
167+
stream.method = "GetAmmo";
168+
stream.args = new String[]{"'"+type+"'"};
169+
stream.playerName = playerName;
170+
return (Integer) stream.send();
136171
}
137172

138173
public void setAmmo(AmmoType type,int amount){
139-
174+
DoStream stream = new DoStream();
175+
stream.playerName = playerName;
176+
stream.method = "SetAmmo";
177+
stream.args = new String[]{"'"+type+"'",amount+""};
178+
stream.send();
140179
}
141180

142181
public Vector getPosition(){
143-
return null;
182+
DoGetStream stream = new DoGetStream(Vector.class);
183+
stream.playerName = playerName;
184+
stream.method = "GetPosition";
185+
return (Vector) stream.send();
144186
}
145187

146188
public void teleport(Vector pos,boolean unstuck){
147-
189+
DoGetStream stream = new DoGetStream(Vector.class);
190+
stream.method = "Teleport";
191+
stream.playerName = playerName;
192+
stream.args = new String[]{pos.toString(),unstuck+""};
193+
stream.send();
148194
}
149195

150196
public void teleport(Vector pos){
151197
teleport(pos,false);
152198
}
153199

154200
public void setRank(String color,String text,String group){
155-
201+
DoStream stream = new DoStream();
202+
stream.method = "SetRank";
203+
stream.playerName = playerName;
204+
stream.args = new String[]{color,text,group};
205+
stream.send();
156206
}
157207

158208
public String getRankName(){
159-
return "";
209+
DoGetStream stream = new DoGetStream(String.class);
210+
stream.method = "GetRankName";
211+
stream.playerName = playerName;
212+
return (String) stream.send();
160213
}
161214

162215
public void disConnect(){
163-
216+
DoStream stream = new DoStream();
217+
stream.method = "DisConnect";
218+
stream.playerName = playerName;
219+
stream.send();
164220
}
165221

166222
public void disConnect(String message){
167-
223+
DoStream stream = new DoStream();
224+
stream.playerName = playerName;
225+
stream.method = "DisConnect";
226+
stream.args =new String[]{message};
227+
stream.send();
168228
}
169229
public void ban(int duration){
170-
230+
DoStream stream = new DoStream();
231+
stream.playerName = playerName;
232+
stream.method = "Ban";
233+
stream.args = new String[]{duration+""};
234+
stream.send();
171235
}
172236

173237
public void ban(int duration,String message){
174-
238+
DoStream stream = new DoStream();
239+
stream.method = "Ban";
240+
stream.args = new String[]{duration+"",message};
241+
stream.playerName = playerName;
242+
stream.send();
175243
}
176244

177245
public Item giveItem(ItemType type){

JSMod2Starter/src/test/java/cn/jsmod2/test/foundbug/jsmod2/PacketTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
@ServerApplication(DefaultServer.class)
2828
public class PacketTest {
2929

30+
3031
@Test
3132
public void get(){
3233
String str = ("events.put(0x01, AdminQueryEvent.class);//packet 1\n" +

0 commit comments

Comments
 (0)