Skip to content

Commit ad48ce7

Browse files
author
magiclu550
committed
[JSMOD@2_465_COMMIT] add generator
1 parent 5a984a7 commit ad48ce7

16 files changed

Lines changed: 255 additions & 5 deletions

JSMod2API/src/main/java/cn/jsmod2/api/map/Generator.java

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010

1111
import cn.jsmod2.api.Component;
1212
import cn.jsmod2.core.ApiId;
13-
import cn.jsmod2.core.annotations.UseForServerInit;
1413
import cn.jsmod2.core.math.Vector;
14+
import cn.jsmod2.network.protocol.map.generator.*;
1515

1616
import java.io.Serializable;
1717

@@ -31,9 +31,9 @@ public class Generator extends ApiId implements Component,IGenerator, Serializab
3131
private Room room = new Room();
3232

3333
public void unlock(){
34-
if(locked){
35-
locked = false;
36-
}
34+
UnlockGeneratorPacket packet = new UnlockGeneratorPacket();
35+
packet.playerName = playerName;
36+
packet.send();
3737
}
3838

3939
public Object getComponent(){
@@ -42,44 +42,77 @@ public Object getComponent(){
4242

4343

4444
public boolean isOpen() {
45+
GetGeneratorOpenPacket packet = new GetGeneratorOpenPacket();
46+
packet.playerName = playerName;
47+
open = packet.send();
4548
return open;
4649
}
4750

4851
public void setOpen(boolean open) {
52+
SetGeneratorOpenPacket packet = new SetGeneratorOpenPacket();
53+
packet.open = open;
54+
packet.playerName = playerName;
55+
packet.send();
4956
this.open = open;
5057
}
5158

5259
public boolean isLocked() {
60+
GetGeneratorLockedPacket packet = new GetGeneratorLockedPacket();
61+
packet.playerName = playerName;
62+
locked = packet.send();
5363
return locked;
5464
}
5565

5666
public boolean isHasTablet() {
67+
GetGeneratorHasTabletPacket packet = new GetGeneratorHasTabletPacket();
68+
packet.playerName = playerName;
69+
hasTablet = packet.send();
5770
return hasTablet;
5871
}
5972

6073
public void setHasTablet(boolean hasTablet) {
74+
SetGeneratorHasTabletPacket packet = new SetGeneratorHasTabletPacket();
75+
packet.hasTablet = hasTablet;
76+
packet.playerName = playerName;
77+
packet.send();
6178
this.hasTablet = hasTablet;
6279
}
6380

6481
public boolean isEngaged() {
82+
GetGeneratorEngagedPacket packet = new GetGeneratorEngagedPacket();
83+
packet.playerName = playerName;
84+
engaged = packet.send();
6585
return engaged;
6686
}
6787

6888

6989
public float getStartTime() {
90+
GetGeneratorStartTimePacket packet = new GetGeneratorStartTimePacket();
91+
packet.playerName = playerName;
92+
startTime = packet.send();
7093
return startTime;
7194
}
7295

7396

7497
public float getTimeLeft() {
98+
GetGeneratorTimeLeftPacket packet = new GetGeneratorTimeLeftPacket();
99+
packet.playerName = playerName;
100+
timeLeft = packet.send();
75101
return timeLeft;
76102
}
77103

78104
public void setTimeLeft(float timeLeft) {
105+
SetGeneratorTimeLeftPacket packet = new SetGeneratorTimeLeftPacket();
106+
packet.playerName = playerName;
107+
packet.timeLeft = timeLeft;
108+
packet.send();
79109
this.timeLeft = timeLeft;
80110
}
81111

82112
public Vector getPosition() {
113+
GetGeneratorPositionPacket packet = new GetGeneratorPositionPacket();
114+
packet.playerName = playerName;
115+
position = packet.send();
83116
return position;
84117
}
85118

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package cn.jsmod2.network.protocol.map.generator;
2+
3+
//134
4+
public class GetGeneratorEngagedPacket extends GetGeneratorPacket{
5+
6+
public static final int ID = 134;
7+
8+
public GetGeneratorEngagedPacket() {
9+
super(ID,Boolean.class);
10+
}
11+
12+
@Override
13+
public Boolean send() {
14+
return (Boolean)requester.with("field","engaged").get().get();
15+
}
16+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package cn.jsmod2.network.protocol.map.generator;
2+
3+
//135
4+
public class GetGeneratorHasTabletPacket extends GetGeneratorPacket{
5+
6+
public static final int ID = 135;
7+
8+
public GetGeneratorHasTabletPacket() {
9+
super(ID,Boolean.class);
10+
}
11+
12+
@Override
13+
public Boolean send() {
14+
return (Boolean)requester.with("field","hasTablet").get().get();
15+
}
16+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package cn.jsmod2.network.protocol.map.generator;
2+
3+
//136
4+
public class GetGeneratorLockedPacket extends GetGeneratorPacket{
5+
6+
public static final int ID = 136;
7+
8+
public GetGeneratorLockedPacket() {
9+
super(ID,Boolean.class);
10+
}
11+
12+
@Override
13+
public Boolean send() {
14+
return (Boolean) requester.with("field","locked").get().get();
15+
}
16+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package cn.jsmod2.network.protocol.map.generator;
2+
3+
public class GetGeneratorOpenPacket extends GetGeneratorPacket{
4+
5+
public static final int ID = 132;
6+
7+
public GetGeneratorOpenPacket() {
8+
super(ID, Boolean.class);
9+
}
10+
11+
@Override
12+
public Boolean send() {
13+
return (Boolean) requester.with("field","open").get().get();
14+
}
15+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package cn.jsmod2.network.protocol.map.generator;
2+
3+
import cn.jsmod2.core.protocol.GetPacket;
4+
5+
public abstract class GetGeneratorPacket extends GetPacket {
6+
7+
public GetGeneratorPacket(int id, Class<?> type) {
8+
super(id, type);
9+
requester.with("type","generator");
10+
}
11+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package cn.jsmod2.network.protocol.map.generator;
2+
3+
import cn.jsmod2.core.math.Vector;
4+
5+
//137
6+
public class GetGeneratorPositionPacket extends GetGeneratorPacket{
7+
8+
public static final int ID = 137;
9+
10+
public GetGeneratorPositionPacket() {
11+
super(ID, Vector.class);
12+
}
13+
14+
@Override
15+
public Vector send() {
16+
return (Vector) requester.with("field","position").get().get();
17+
}
18+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package cn.jsmod2.network.protocol.map.generator;
2+
3+
//139
4+
public class GetGeneratorStartTimePacket extends GetGeneratorPacket{
5+
6+
public static final int ID = 139;
7+
8+
public GetGeneratorStartTimePacket() {
9+
super(ID,Float.class);
10+
}
11+
12+
@Override
13+
public Float send() {
14+
return (Float) requester.with("field","startTime").get().get();
15+
}
16+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package cn.jsmod2.network.protocol.map.generator;
2+
3+
//140
4+
public class GetGeneratorTimeLeftPacket extends GetGeneratorPacket{
5+
6+
public static final int ID = 140;
7+
8+
public GetGeneratorTimeLeftPacket() {
9+
super(ID,Float.class);
10+
}
11+
12+
@Override
13+
public Float send() {
14+
return (Float)requester.with("field","timeLeft").get().get();
15+
}
16+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package cn.jsmod2.network.protocol.map.generator;
2+
3+
//141
4+
public class SetGeneratorHasTabletPacket extends SetGeneratorPacket{
5+
6+
public static final int ID = 141;
7+
8+
public boolean hasTablet;
9+
10+
public SetGeneratorHasTabletPacket() {
11+
super(ID);
12+
}
13+
14+
@Override
15+
public void send() {
16+
requester.with("hasTablet",hasTablet).to();
17+
}
18+
}

0 commit comments

Comments
 (0)