Skip to content

Commit 2193df3

Browse files
author
magiclu550
committed
[JSMOD@2_473_COMMIT] some events
1 parent f008358 commit 2193df3

File tree

86 files changed

+614
-58
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+614
-58
lines changed

JSMod2API/JSMod2API.iml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,6 @@
1414
<orderEntry type="library" name="Maven: cn.jsmod2:jsmod2-core:1.0.3" level="project" />
1515
<orderEntry type="library" name="Maven: cn.jsmod2:jsmod2-protocol:1.0.3" level="project" />
1616
<orderEntry type="library" name="Maven: cn.jsmod2:jsmod2-iapi:1.0.3" level="project" />
17+
<orderEntry type="library" name="Maven: com.alibaba:fastjson:1.2.47" level="project" />
1718
</component>
1819
</module>

JSMod2API/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,11 @@
6767
<artifactId>jsmod2-iapi</artifactId>
6868
<version>1.0.3</version>
6969
</dependency>
70+
<dependency>
71+
<groupId>com.alibaba</groupId>
72+
<artifactId>fastjson</artifactId>
73+
<version>1.2.47</version>
74+
</dependency>
7075
</dependencies>
7176

7277
<repositories>

JSMod2API/src/main/java/cn/jsmod2/api/event/admin/AdminQueryEvent.java

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,13 @@
1010
import cn.jsmod2.api.player.IPlayer;
1111
import cn.jsmod2.api.player.Player;
1212
import cn.jsmod2.core.event.Event;
13+
import cn.jsmod2.network.PacketSender;
1314
import cn.jsmod2.network.protocol.event.admin.AdminQueryAdminSetPacket;
1415
import cn.jsmod2.network.protocol.event.admin.AdminQueryQueryGetPacket;
1516
import cn.jsmod2.network.protocol.event.admin.AdminQueryQuerySetPacket;
17+
import cn.jsmod2.network.protocol.event.newstream.EventValueGetStream;
18+
import cn.jsmod2.network.protocol.event.newstream.EventValueSetStream;
19+
import cn.jsmod2.network.protocol.event.newstream.GetTypes;
1620

1721
/**
1822
* @author magiclu550 #(code) jsmod2
@@ -58,26 +62,54 @@ public void setQuery(String query) {
5862
}
5963

6064
public String getOutput() {
65+
EventValueGetStream stream = new EventValueGetStream(String.class);
66+
stream.playerName = playerName;
67+
stream.getType = GetTypes.GET;
68+
stream.name = "Output";
69+
output = PacketSender.sendGetPacket(stream,String.class);
6170
return output;
6271
}
6372

6473
public void setOutput(String output) {
74+
EventValueSetStream stream = new EventValueSetStream();
75+
stream.playerName = playerName;
76+
stream.name = "Output";
77+
stream.value = output;
78+
PacketSender.sendSetPacket(stream);
6579
this.output = output;
6680
}
6781

6882
public boolean isHandled() {
83+
EventValueGetStream stream = new EventValueGetStream(Boolean.class);
84+
stream.playerName = playerName;
85+
stream.name = "Handled";
86+
handled = PacketSender.sendGetPacket(stream,Boolean.class);
6987
return handled;
7088
}
7189

7290
public void setHandled(boolean handled) {
91+
EventValueSetStream stream = new EventValueSetStream();
92+
stream.playerName = playerName;
93+
stream.name = "Handled";
94+
stream.value = handled;
95+
PacketSender.sendSetPacket(stream);
7396
this.handled = handled;
7497
}
7598

7699
public boolean isSuccessful() {
100+
EventValueGetStream stream = new EventValueGetStream(Boolean.class);
101+
stream.playerName = playerName;
102+
stream.name = "Successful";
103+
successful = PacketSender.sendGetPacket(stream,Boolean.class);
77104
return successful;
78105
}
79106

80107
public void setSuccessful(boolean successful) {
108+
EventValueSetStream stream = new EventValueSetStream();
109+
stream.playerName = playerName;
110+
stream.name = "Successful";
111+
stream.value = successful;
112+
PacketSender.sendSetPacket(stream);
81113
this.successful = successful;
82114
}
83115

JSMod2API/src/main/java/cn/jsmod2/api/event/admin/AuthCheckEvent.java

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,14 @@
1111
import cn.jsmod2.api.player.IPlayer;
1212
import cn.jsmod2.api.player.Player;
1313
import cn.jsmod2.api.server.AuthType;
14+
import cn.jsmod2.core.ApiId;
1415
import cn.jsmod2.core.event.Event;
16+
import cn.jsmod2.network.PacketSender;
17+
import cn.jsmod2.network.protocol.event.newstream.EventValueGetStream;
18+
import cn.jsmod2.network.protocol.event.newstream.EventValueSetStream;
19+
20+
import static cn.jsmod2.network.PacketSender.sendGetPacket;
21+
import static cn.jsmod2.network.PacketSender.sendSetPacket;
1522

1623

1724
/**
@@ -33,30 +40,62 @@ public IPlayer getRequester() {
3340
}
3441

3542
public void setRequester(IPlayer requester) {
43+
EventValueSetStream stream = new EventValueSetStream();
44+
stream.name = "Requester";
45+
stream.value = requester;
46+
stream.playerName = playerName;
47+
sendSetPacket(stream);
3648
this.requester = requester;
3749
}
3850

3951
public AuthType getType() {
52+
EventValueGetStream stream = new EventValueGetStream(AuthType.class);
53+
stream.name = "AuthType";
54+
stream.playerName = playerName;
55+
type = sendGetPacket(stream,AuthType.class);
4056
return type;
4157
}
4258

4359
public void setType(AuthType type) {
60+
EventValueSetStream stream = new EventValueSetStream();
61+
stream.playerName = playerName;
62+
stream.name = "Type";
63+
stream.value = type;
64+
sendSetPacket(stream);
4465
this.type = type;
4566
}
4667

4768
public boolean isAllow() {
69+
EventValueGetStream stream = new EventValueGetStream(Boolean.class);
70+
stream.playerName = playerName;
71+
stream.name = "Allow";
72+
allow = sendGetPacket(stream,Boolean.class);
4873
return allow;
4974
}
5075

5176
public void setAllow(boolean allow) {
77+
EventValueSetStream stream = new EventValueSetStream();
78+
stream.playerName = playerName;
79+
stream.name = "Allow";
80+
stream.value = allow;
81+
sendSetPacket(stream);
5282
this.allow = allow;
5383
}
5484

5585
public boolean isSuccessful() {
86+
EventValueGetStream stream = new EventValueGetStream(Boolean.class);
87+
stream.playerName = playerName;
88+
stream.name = "Successful";
89+
successful = sendGetPacket(stream,Boolean.class);
5690
return successful;
5791
}
5892

5993
public void setSuccessful(boolean successful) {
94+
EventValueSetStream stream = new EventValueSetStream();
95+
stream.playerName = playerName;
96+
stream.name = "Successful";
97+
stream.value = successful;
98+
sendSetPacket(stream);
6099
this.successful = successful;
61100
}
62101

JSMod2API/src/main/java/cn/jsmod2/api/event/admin/BanEvent.java

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@
1111
import cn.jsmod2.api.player.IPlayer;
1212
import cn.jsmod2.api.player.Player;
1313
import cn.jsmod2.core.event.Event;
14+
import cn.jsmod2.network.protocol.event.newstream.EventValueGetStream;
15+
import cn.jsmod2.network.protocol.event.newstream.EventValueSetStream;
16+
17+
import static cn.jsmod2.network.PacketSender.sendGetPacket;
18+
import static cn.jsmod2.network.PacketSender.sendSetPacket;
1419

1520

1621
/**
@@ -36,6 +41,11 @@ public IPlayer getPlayer() {
3641
}
3742

3843
public void setPlayer(IPlayer player) {
44+
EventValueSetStream stream = new EventValueSetStream();
45+
stream.playerName = playerName;
46+
stream.name = "Player";
47+
stream.value = player;
48+
sendSetPacket(stream);
3949
this.player = player;
4050
}
4151

@@ -44,38 +54,79 @@ public IPlayer getAdmin() {
4454
}
4555

4656
public void setAdmin(IPlayer admin) {
57+
EventValueSetStream stream = new EventValueSetStream();
58+
stream.playerName = playerName;
59+
stream.name = "Admin";
60+
stream.value = admin;
61+
sendSetPacket(stream);
4762
this.admin = admin;
4863
}
4964

5065
public int getDuration() {
66+
EventValueGetStream stream = new EventValueGetStream(Integer.class);
67+
stream.playerName = playerName;
68+
stream.name = "Duration";
69+
duration = sendGetPacket(stream,Integer.class);
5170
return duration;
5271
}
5372

5473
public void setDuration(int duration) {
74+
EventValueSetStream stream = new EventValueSetStream();
75+
stream.name = "Duration";
76+
stream.value = duration;
77+
stream.playerName = playerName;
78+
sendSetPacket(stream);
5579
this.duration = duration;
5680
}
5781

5882
public String getReason() {
83+
EventValueGetStream stream = new EventValueGetStream(String.class);
84+
stream.playerName = playerName;
85+
stream.name = "Reason";
86+
reason = sendGetPacket(stream,String.class);
5987
return reason;
6088
}
6189

6290
public void setReason(String reason) {
91+
EventValueSetStream stream = new EventValueSetStream();
92+
stream.playerName = playerName;
93+
stream.name = "Reason";
94+
stream.value = reason;
95+
sendSetPacket(stream);
6396
this.reason = reason;
6497
}
6598

6699
public String getResult() {
100+
EventValueGetStream stream = new EventValueGetStream(String.class);
101+
stream.playerName = playerName;
102+
stream.name = "Result";
103+
result = sendGetPacket(stream,String.class);
67104
return result;
68105
}
69106

70107
public void setResult(String result) {
108+
EventValueSetStream stream = new EventValueSetStream();
109+
stream.playerName = playerName;
110+
stream.name = "Result";
111+
stream.value = result;
112+
sendSetPacket(stream);
71113
this.result = result;
72114
}
73115

74116
public boolean isAllowBan() {
117+
EventValueGetStream stream = new EventValueGetStream(Boolean.class);
118+
stream.playerName = playerName;
119+
stream.name = "AlloBan";
120+
allowBan = sendGetPacket(stream,Boolean.class);
75121
return allowBan;
76122
}
77123

78124
public void setAllowBan(boolean allowBan) {
125+
EventValueSetStream stream = new EventValueSetStream();
126+
stream.playerName = playerName;
127+
stream.name = "AllowBan";
128+
stream.value = allowBan;
129+
sendSetPacket(stream);
79130
this.allowBan = allowBan;
80131
}
81132

JSMod2API/src/main/java/cn/jsmod2/api/event/config/SetConfigEvent.java

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,12 @@
99
package cn.jsmod2.api.event.config;
1010

1111

12-
import cn.jsmod2.core.annotations.UseForServerInit;
1312
import cn.jsmod2.core.event.Event;
13+
import cn.jsmod2.network.protocol.event.newstream.EventValueGetStream;
14+
import cn.jsmod2.network.protocol.event.newstream.EventValueSetStream;
15+
16+
import static cn.jsmod2.network.PacketSender.sendGetPacket;
17+
import static cn.jsmod2.network.PacketSender.sendSetPacket;
1418

1519
/**
1620
* @author magiclu550 #(code) jsmod2
@@ -31,23 +35,45 @@ public SetConfigEvent(){
3135
}
3236

3337
public String getKey() {
38+
EventValueGetStream stream = new EventValueGetStream(String.class);
39+
stream.playerName = playerName;
40+
stream.name = "Key";
41+
key = sendGetPacket(stream,String.class);
3442
return key;
3543
}
3644

3745
public void setKey(String key) {
46+
EventValueSetStream stream = new EventValueSetStream();
47+
stream.playerName = playerName;
48+
stream.name = "Key";
49+
stream.value = key;
50+
sendSetPacket(stream);
3851
this.key = key;
3952
}
4053

41-
public Object getValue() {
42-
return value;
54+
public <T> T getValue(Class<T> type) {
55+
EventValueGetStream stream = new EventValueGetStream(type);
56+
stream.playerName = playerName;
57+
stream.name = "Value";
58+
value = sendGetPacket(stream,type);
59+
return type.cast(value);
4360
}
4461

4562
public void setValue(Object value) {
63+
EventValueSetStream stream = new EventValueSetStream();
64+
stream.playerName = playerName;
65+
stream.name = "Value";
66+
stream.value = value;
67+
sendSetPacket(stream);
4668
this.value = value;
4769
}
4870

49-
public Object getDefaultValue() {
50-
return defaultValue;
71+
public <T> T getDefaultValue(Class<T> type) {
72+
EventValueGetStream stream = new EventValueGetStream(type);
73+
stream.playerName = playerName;
74+
stream.name = "DefaultValue";
75+
defaultValue = sendGetPacket(stream,type);
76+
return type.cast(defaultValue);
5177
}
5278

5379

0 commit comments

Comments
 (0)