Skip to content

Commit 05c1639

Browse files
committed
~Pushing just because I don't want to lose anything by mistake.
HOWEVER! THIS IS NOT A NEW VERSION OF NETWORKING! NEW VERSION COMING SOON BASED ON ME AN JYTHONS TALK!
1 parent 07dc6b6 commit 05c1639

26 files changed

+585
-59
lines changed

src/main/java/org/blockserver/core/event/MessageEventListener.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
import org.blockserver.core.Server;
2020
import org.blockserver.core.events.MessageHandleEvent;
21-
import org.blockserver.core.message.Message;
21+
import org.blockserver.core.modules.message.Message;
2222

2323
/**
2424
* Written by Exerosis!
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* This file is part of BlockServer.
3+
*
4+
* BlockServer is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU Lesser General Public License as published by
6+
* the Free Software Foundation, either version 3 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* BlockServer is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU Lesser General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU Lesser General Public License
15+
* along with BlockServer. If not, see <http://www.gnu.org/licenses/>.
16+
*/
17+
package org.blockserver.core.event;
18+
19+
import org.blockserver.core.Server;
20+
21+
/**
22+
* Written by Exerosis!
23+
*/
24+
public class ServerEventListener<B> extends EventListener<B, B> {
25+
public void register(Class<B> listenerType, Server server) {
26+
register(listenerType, server.getEventManager());
27+
}
28+
29+
public ServerEventListener<B> post() {
30+
super.post();
31+
return this;
32+
}
33+
34+
public ServerEventListener<B> priority(Priority priority) {
35+
super.priority(priority);
36+
return this;
37+
}
38+
}

src/main/java/org/blockserver/core/events/MessageHandleEvent.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import lombok.Getter;
2020
import lombok.Setter;
2121
import org.blockserver.core.event.CancellableImplementation;
22-
import org.blockserver.core.message.Message;
22+
import org.blockserver.core.modules.message.Message;
2323

2424
/**
2525
* Written by Exerosis!
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* This file is part of BlockServer.
3+
*
4+
* BlockServer is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU Lesser General Public License as published by
6+
* the Free Software Foundation, either version 3 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* BlockServer is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU Lesser General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU Lesser General Public License
15+
* along with BlockServer. If not, see <http://www.gnu.org/licenses/>.
16+
*/
17+
package org.blockserver.core.events.packets;
18+
19+
import lombok.Getter;
20+
import lombok.Setter;
21+
import org.blockserver.core.event.CancellableImplementation;
22+
import org.blockserver.core.modules.network.RawPacket;
23+
24+
/**
25+
* Written by Exerosis!
26+
*/
27+
public class PacketEvent implements CancellableImplementation {
28+
@Getter @Setter private RawPacket packet;
29+
30+
public PacketEvent(RawPacket packet) {
31+
this.packet = packet;
32+
}
33+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* This file is part of BlockServer.
3+
*
4+
* BlockServer is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU Lesser General Public License as published by
6+
* the Free Software Foundation, either version 3 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* BlockServer is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU Lesser General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU Lesser General Public License
15+
* along with BlockServer. If not, see <http://www.gnu.org/licenses/>.
16+
*/
17+
package org.blockserver.core.events.packets;
18+
19+
import org.blockserver.core.modules.network.RawPacket;
20+
21+
/**
22+
* Written by Exerosis!
23+
*/
24+
public class PacketReceiveEvent extends PacketEvent {
25+
public PacketReceiveEvent(RawPacket packet) {
26+
super(packet);
27+
}
28+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* This file is part of BlockServer.
3+
*
4+
* BlockServer is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU Lesser General Public License as published by
6+
* the Free Software Foundation, either version 3 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* BlockServer is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU Lesser General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU Lesser General Public License
15+
* along with BlockServer. If not, see <http://www.gnu.org/licenses/>.
16+
*/
17+
package org.blockserver.core.events.packets;
18+
19+
import org.blockserver.core.modules.network.RawPacket;
20+
21+
/**
22+
* Written by Exerosis!
23+
*/
24+
public class PacketSendEvent extends PacketEvent {
25+
public PacketSendEvent(RawPacket packet) {
26+
super(packet);
27+
}
28+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* This file is part of BlockServer.
3+
*
4+
* BlockServer is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU Lesser General Public License as published by
6+
* the Free Software Foundation, either version 3 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* BlockServer is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU Lesser General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU Lesser General Public License
15+
* along with BlockServer. If not, see <http://www.gnu.org/licenses/>.
16+
*/
17+
package org.blockserver.core.modules.entity;
18+
19+
import org.blockserver.core.modules.world.positions.Location;
20+
21+
/**
22+
* Written by Exerosis!
23+
*/
24+
public class Entity {
25+
private float x;
26+
private float y;
27+
private float z;
28+
29+
public Entity(float x, float y, float z) {
30+
this.x = x;
31+
this.y = y;
32+
this.z = z;
33+
}
34+
35+
public Entity(Location location) {
36+
this(location.getX(), location.getY(), location.getZ());
37+
}
38+
39+
public Location getLocation() {
40+
return new Location(x, y, z);
41+
}
42+
}

src/main/java/org/blockserver/core/message/Message.java renamed to src/main/java/org/blockserver/core/modules/message/Message.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* You should have received a copy of the GNU Lesser General Public License
1515
* along with BlockServer. If not, see <http://www.gnu.org/licenses/>.
1616
*/
17-
package org.blockserver.core.message;
17+
package org.blockserver.core.modules.message;
1818

1919
import lombok.Getter;
2020
import lombok.Setter;

src/main/java/org/blockserver/core/message/MessageInPlayerLogin.java renamed to src/main/java/org/blockserver/core/modules/message/MessageInPlayerLogin.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* You should have received a copy of the GNU Lesser General Public License
1515
* along with BlockServer. If not, see <http://www.gnu.org/licenses/>.
1616
*/
17-
package org.blockserver.core.message;
17+
package org.blockserver.core.modules.message;
1818

1919
import org.blockserver.core.modules.player.Player;
2020

src/main/java/org/blockserver/core/message/MessageModule.java renamed to src/main/java/org/blockserver/core/modules/message/MessageModule.java

+7-5
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,13 @@
1414
* You should have received a copy of the GNU Lesser General Public License
1515
* along with BlockServer. If not, see <http://www.gnu.org/licenses/>.
1616
*/
17-
package org.blockserver.core.message;
17+
package org.blockserver.core.modules.message;
1818

1919
import org.blockserver.core.Server;
2020
import org.blockserver.core.events.MessageHandleEvent;
2121
import org.blockserver.core.events.RawPacketHandleEvent;
2222
import org.blockserver.core.modules.network.NetworkConverter;
2323
import org.blockserver.core.modules.network.NetworkModule;
24-
import org.blockserver.core.modules.network.NetworkProvider;
2524
import org.blockserver.core.modules.scheduler.SchedulerModule;
2625

2726
/**
@@ -30,6 +29,7 @@
3029
public class MessageModule extends NetworkModule {
3130
private final NetworkConverter networkConverter;
3231

32+
//TODO figure out a way to make the converter part async.
3333
public MessageModule(Server server, SchedulerModule schedulerModule, NetworkConverter networkConverter) {
3434
super(server, schedulerModule);
3535
this.networkConverter = networkConverter;
@@ -47,8 +47,10 @@ public MessageModule(Server server, SchedulerModule schedulerModule, NetworkConv
4747

4848

4949
public void sendMessage(Message message) {
50-
for (NetworkProvider provider : getProviders()) {
51-
provider.queueOutboundPackets(networkConverter.toPacket(message));
52-
}
50+
getServer().getExecutorService().execute(() -> {
51+
for (NetworkProvider provider : getProviders()) {
52+
provider.queueOutboundPackets(networkConverter.toPacket(message));
53+
}
54+
});
5355
}
5456
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* This file is part of BlockServer.
3+
*
4+
* BlockServer is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU Lesser General Public License as published by
6+
* the Free Software Foundation, either version 3 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* BlockServer is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU Lesser General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU Lesser General Public License
15+
* along with BlockServer. If not, see <http://www.gnu.org/licenses/>.
16+
*/
17+
package org.blockserver.core.modules.message;
18+
19+
import org.blockserver.core.modules.player.Player;
20+
import org.blockserver.core.utilities.Skin;
21+
22+
import java.util.UUID;
23+
24+
/**
25+
* Written by Exerosis!
26+
*/
27+
public class PlayerLoginMessage extends Message {
28+
public long clientID;
29+
public String username;
30+
public UUID uuid;
31+
public Skin skin;
32+
33+
public PlayerLoginMessage(Player player) {
34+
super(player);
35+
}
36+
}

src/main/java/org/blockserver/core/message/block/MessageOutBlockChange.java renamed to src/main/java/org/blockserver/core/modules/message/block/MessageOutBlockChange.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
* You should have received a copy of the GNU Lesser General Public License
1515
* along with BlockServer. If not, see <http://www.gnu.org/licenses/>.
1616
*/
17-
package org.blockserver.core.message.block;
17+
package org.blockserver.core.modules.message.block;
1818

19-
import org.blockserver.core.message.Message;
19+
import org.blockserver.core.modules.message.Message;
2020
import org.blockserver.core.modules.player.Player;
2121
import org.blockserver.core.modules.world.Block;
2222

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*
2+
* This file is part of BlockServer.
3+
*
4+
* BlockServer is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU Lesser General Public License as published by
6+
* the Free Software Foundation, either version 3 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* BlockServer is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU Lesser General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU Lesser General Public License
15+
* along with BlockServer. If not, see <http://www.gnu.org/licenses/>.
16+
*/
17+
package org.blockserver.core.modules.network;
18+
19+
import java.util.concurrent.BlockingQueue;
20+
import java.util.concurrent.LinkedBlockingQueue;
21+
22+
/**
23+
* Written by Exerosis!
24+
*/
25+
public class LinkedBlockingIOQueue<T> {
26+
private final BlockingQueue<T> input = new LinkedBlockingQueue<>();
27+
private final BlockingQueue<T> output = new LinkedBlockingQueue<>();
28+
29+
public void queueInbound(T object) {
30+
input.add(object);
31+
}
32+
33+
public void queueOutbound(T object) {
34+
output.add(object);
35+
}
36+
37+
38+
public T pollInbound() {
39+
return input.poll();
40+
}
41+
42+
public T pollOutbound() {
43+
return output.poll();
44+
}
45+
46+
47+
public T peekInbound() {
48+
return input.peek();
49+
}
50+
51+
public T peekOutbound() {
52+
return output.peek();
53+
}
54+
}

src/main/java/org/blockserver/core/modules/network/NetworkConverter.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
package org.blockserver.core.modules.network;
1818

1919

20-
import org.blockserver.core.message.Message;
20+
import org.blockserver.core.modules.message.Message;
2121

2222
/**
2323
* Written by Exerosis!

0 commit comments

Comments
 (0)