forked from BLOCKFANTASY/LOOHP-Limbo
reorganize classes for a better future
This commit is contained in:
parent
e8a7d68e3b
commit
2d77a0e15c
2
pom.xml
2
pom.xml
|
|
@ -5,7 +5,7 @@
|
||||||
<groupId>com.loohp.limbo</groupId>
|
<groupId>com.loohp.limbo</groupId>
|
||||||
<artifactId>Limbo</artifactId>
|
<artifactId>Limbo</artifactId>
|
||||||
<name>Limbo</name>
|
<name>Limbo</name>
|
||||||
<version>0.4.1-ALPHA</version>
|
<version>0.4.2-ALPHA</version>
|
||||||
|
|
||||||
<description>Standalone Limbo Minecraft Server.</description>
|
<description>Standalone Limbo Minecraft Server.</description>
|
||||||
<url>https://github.com/LOOHP/Limbo</url>
|
<url>https://github.com/LOOHP/Limbo</url>
|
||||||
|
|
|
||||||
|
|
@ -103,10 +103,12 @@ public class Console implements CommandSender {
|
||||||
tabReader.setAutosuggestion(SuggestionType.NONE);
|
tabReader.setAutosuggestion(SuggestionType.NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return CONSOLE;
|
return CONSOLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean hasPermission(String permission) {
|
public boolean hasPermission(String permission) {
|
||||||
return Limbo.getInstance().getPermissionsManager().hasPermission(this, permission);
|
return Limbo.getInstance().getPermissionsManager().hasPermission(this, permission);
|
||||||
}
|
}
|
||||||
|
|
@ -121,6 +123,7 @@ public class Console implements CommandSender {
|
||||||
sendMessage(component);
|
sendMessage(component);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void sendMessage(String message, UUID uuid) {
|
public void sendMessage(String message, UUID uuid) {
|
||||||
sendMessage(message);
|
sendMessage(message);
|
||||||
}
|
}
|
||||||
|
|
@ -135,6 +138,7 @@ public class Console implements CommandSender {
|
||||||
sendMessage(String.join("", Arrays.asList(component).stream().map(each -> each.toLegacyText()).collect(Collectors.toList())));
|
sendMessage(String.join("", Arrays.asList(component).stream().map(each -> each.toLegacyText()).collect(Collectors.toList())));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void sendMessage(String message) {
|
public void sendMessage(String message) {
|
||||||
stashLine();
|
stashLine();
|
||||||
String date = new SimpleDateFormat("HH':'mm':'ss").format(new Date());
|
String date = new SimpleDateFormat("HH':'mm':'ss").format(new Date());
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ package com.loohp.limbo.Entity;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import com.loohp.limbo.Location.Location;
|
||||||
import com.loohp.limbo.Player.Player;
|
import com.loohp.limbo.Player.Player;
|
||||||
import com.loohp.limbo.Utils.NamespacedKey;
|
import com.loohp.limbo.Utils.NamespacedKey;
|
||||||
import com.loohp.limbo.World.World;
|
import com.loohp.limbo.World.World;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package com.loohp.limbo.Events;
|
package com.loohp.limbo.Events.Player;
|
||||||
|
|
||||||
|
import com.loohp.limbo.Events.Cancellable;
|
||||||
import com.loohp.limbo.Player.Player;
|
import com.loohp.limbo.Player.Player;
|
||||||
|
|
||||||
public class PlayerChatEvent extends PlayerEvent implements Cancellable {
|
public class PlayerChatEvent extends PlayerEvent implements Cancellable {
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package com.loohp.limbo.Events;
|
package com.loohp.limbo.Events.Player;
|
||||||
|
|
||||||
|
import com.loohp.limbo.Events.Event;
|
||||||
import com.loohp.limbo.Player.Player;
|
import com.loohp.limbo.Player.Player;
|
||||||
|
|
||||||
public class PlayerEvent extends Event {
|
public class PlayerEvent extends Event {
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package com.loohp.limbo.Events;
|
package com.loohp.limbo.Events.Player;
|
||||||
|
|
||||||
import com.loohp.limbo.Location.Location;
|
import com.loohp.limbo.Location.Location;
|
||||||
import com.loohp.limbo.Player.Player;
|
import com.loohp.limbo.Player.Player;
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
package com.loohp.limbo.Events;
|
package com.loohp.limbo.Events.Player;
|
||||||
|
|
||||||
|
import com.loohp.limbo.Events.Cancellable;
|
||||||
|
import com.loohp.limbo.Events.Event;
|
||||||
import com.loohp.limbo.Server.ClientConnection;
|
import com.loohp.limbo.Server.ClientConnection;
|
||||||
|
|
||||||
import net.md_5.bungee.api.chat.BaseComponent;
|
import net.md_5.bungee.api.chat.BaseComponent;
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package com.loohp.limbo.Events;
|
package com.loohp.limbo.Events.Player;
|
||||||
|
|
||||||
|
import com.loohp.limbo.Events.Cancellable;
|
||||||
import com.loohp.limbo.Location.Location;
|
import com.loohp.limbo.Location.Location;
|
||||||
import com.loohp.limbo.Player.Player;
|
import com.loohp.limbo.Player.Player;
|
||||||
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package com.loohp.limbo.Events;
|
package com.loohp.limbo.Events.Player;
|
||||||
|
|
||||||
import com.loohp.limbo.Player.Player;
|
import com.loohp.limbo.Player.Player;
|
||||||
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package com.loohp.limbo.Events;
|
package com.loohp.limbo.Events.Player;
|
||||||
|
|
||||||
|
import com.loohp.limbo.Events.Cancellable;
|
||||||
import com.loohp.limbo.Player.Player;
|
import com.loohp.limbo.Player.Player;
|
||||||
|
|
||||||
public class PlayerSelectedSlotChangeEvent extends PlayerEvent implements Cancellable {
|
public class PlayerSelectedSlotChangeEvent extends PlayerEvent implements Cancellable {
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package com.loohp.limbo.Events;
|
package com.loohp.limbo.Events.Player;
|
||||||
|
|
||||||
import com.loohp.limbo.Location.Location;
|
import com.loohp.limbo.Location.Location;
|
||||||
import com.loohp.limbo.Player.Player;
|
import com.loohp.limbo.Player.Player;
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
package com.loohp.limbo.Events;
|
package com.loohp.limbo.Events.Status;
|
||||||
|
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
|
|
||||||
|
import com.loohp.limbo.Events.Event;
|
||||||
import com.loohp.limbo.Server.ClientConnection;
|
import com.loohp.limbo.Server.ClientConnection;
|
||||||
|
|
||||||
import net.md_5.bungee.api.chat.BaseComponent;
|
import net.md_5.bungee.api.chat.BaseComponent;
|
||||||
|
|
@ -42,6 +42,7 @@ public class ServerProperties {
|
||||||
private boolean bungeecord;
|
private boolean bungeecord;
|
||||||
private int viewDistance;
|
private int viewDistance;
|
||||||
private double ticksPerSecond;
|
private double ticksPerSecond;
|
||||||
|
private boolean handshakeVerbose;
|
||||||
|
|
||||||
Optional<BufferedImage> favicon;
|
Optional<BufferedImage> favicon;
|
||||||
|
|
||||||
|
|
@ -92,6 +93,7 @@ public class ServerProperties {
|
||||||
bungeecord = Boolean.parseBoolean(prop.getProperty("bungeecord"));
|
bungeecord = Boolean.parseBoolean(prop.getProperty("bungeecord"));
|
||||||
viewDistance = Integer.parseInt(prop.getProperty("view-distance"));
|
viewDistance = Integer.parseInt(prop.getProperty("view-distance"));
|
||||||
ticksPerSecond = Double.parseDouble(prop.getProperty("ticks-per-second"));
|
ticksPerSecond = Double.parseDouble(prop.getProperty("ticks-per-second"));
|
||||||
|
handshakeVerbose = Boolean.parseBoolean(prop.getProperty("handshake-verbose"));
|
||||||
|
|
||||||
File png = new File("server-icon.png");
|
File png = new File("server-icon.png");
|
||||||
if (png.exists()) {
|
if (png.exists()) {
|
||||||
|
|
@ -193,4 +195,8 @@ public class ServerProperties {
|
||||||
return ticksPerSecond;
|
return ticksPerSecond;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean handshakeVerboseEnabled() {
|
||||||
|
return handshakeVerbose;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,8 @@ import com.loohp.limbo.Entity.DataWatcher.WatchableField;
|
||||||
import com.loohp.limbo.Entity.DataWatcher.WatchableObjectType;
|
import com.loohp.limbo.Entity.DataWatcher.WatchableObjectType;
|
||||||
import com.loohp.limbo.Entity.EntityType;
|
import com.loohp.limbo.Entity.EntityType;
|
||||||
import com.loohp.limbo.Entity.LivingEntity;
|
import com.loohp.limbo.Entity.LivingEntity;
|
||||||
import com.loohp.limbo.Events.PlayerChatEvent;
|
import com.loohp.limbo.Events.Player.PlayerChatEvent;
|
||||||
import com.loohp.limbo.Events.PlayerTeleportEvent;
|
import com.loohp.limbo.Events.Player.PlayerTeleportEvent;
|
||||||
import com.loohp.limbo.Location.Location;
|
import com.loohp.limbo.Location.Location;
|
||||||
import com.loohp.limbo.Server.ClientConnection;
|
import com.loohp.limbo.Server.ClientConnection;
|
||||||
import com.loohp.limbo.Server.Packets.PacketPlayOutChat;
|
import com.loohp.limbo.Server.Packets.PacketPlayOutChat;
|
||||||
|
|
|
||||||
|
|
@ -16,14 +16,13 @@ import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.atomic.AtomicLong;
|
import java.util.concurrent.atomic.AtomicLong;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import com.loohp.limbo.DeclareCommands;
|
|
||||||
import com.loohp.limbo.Limbo;
|
import com.loohp.limbo.Limbo;
|
||||||
import com.loohp.limbo.Events.PlayerJoinEvent;
|
import com.loohp.limbo.Events.Player.PlayerJoinEvent;
|
||||||
import com.loohp.limbo.Events.PlayerLoginEvent;
|
import com.loohp.limbo.Events.Player.PlayerLoginEvent;
|
||||||
import com.loohp.limbo.Events.PlayerMoveEvent;
|
import com.loohp.limbo.Events.Player.PlayerMoveEvent;
|
||||||
import com.loohp.limbo.Events.PlayerQuitEvent;
|
import com.loohp.limbo.Events.Player.PlayerQuitEvent;
|
||||||
import com.loohp.limbo.Events.PlayerSelectedSlotChangeEvent;
|
import com.loohp.limbo.Events.Player.PlayerSelectedSlotChangeEvent;
|
||||||
import com.loohp.limbo.Events.StatusPingEvent;
|
import com.loohp.limbo.Events.Status.StatusPingEvent;
|
||||||
import com.loohp.limbo.File.ServerProperties;
|
import com.loohp.limbo.File.ServerProperties;
|
||||||
import com.loohp.limbo.Location.Location;
|
import com.loohp.limbo.Location.Location;
|
||||||
import com.loohp.limbo.Player.Player;
|
import com.loohp.limbo.Player.Player;
|
||||||
|
|
@ -63,6 +62,7 @@ import com.loohp.limbo.Server.Packets.PacketStatusOutPong;
|
||||||
import com.loohp.limbo.Server.Packets.PacketStatusOutResponse;
|
import com.loohp.limbo.Server.Packets.PacketStatusOutResponse;
|
||||||
import com.loohp.limbo.Utils.CustomStringUtils;
|
import com.loohp.limbo.Utils.CustomStringUtils;
|
||||||
import com.loohp.limbo.Utils.DataTypeIO;
|
import com.loohp.limbo.Utils.DataTypeIO;
|
||||||
|
import com.loohp.limbo.Utils.DeclareCommands;
|
||||||
import com.loohp.limbo.Utils.GameMode;
|
import com.loohp.limbo.Utils.GameMode;
|
||||||
import com.loohp.limbo.Utils.MojangAPIUtils;
|
import com.loohp.limbo.Utils.MojangAPIUtils;
|
||||||
import com.loohp.limbo.Utils.MojangAPIUtils.SkinResponse;
|
import com.loohp.limbo.Utils.MojangAPIUtils.SkinResponse;
|
||||||
|
|
@ -157,7 +157,7 @@ public class ClientConnection extends Thread {
|
||||||
} catch (IOException e) {}
|
} catch (IOException e) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void disconnectDuringLogin(BaseComponent[] reason) {
|
private void disconnectDuringLogin(BaseComponent[] reason) {
|
||||||
try {
|
try {
|
||||||
PacketLoginOutDisconnect packet = new PacketLoginOutDisconnect(ComponentSerializer.toString(reason));
|
PacketLoginOutDisconnect packet = new PacketLoginOutDisconnect(ComponentSerializer.toString(reason));
|
||||||
sendPacket(packet);
|
sendPacket(packet);
|
||||||
|
|
@ -205,6 +205,7 @@ public class ClientConnection extends Thread {
|
||||||
UUID bungeeUUID = null;
|
UUID bungeeUUID = null;
|
||||||
SkinResponse bungeeSkin = null;
|
SkinResponse bungeeSkin = null;
|
||||||
|
|
||||||
|
try {
|
||||||
switch (handshake.getHandshakeType()) {
|
switch (handshake.getHandshakeType()) {
|
||||||
case STATUS:
|
case STATUS:
|
||||||
state = ClientState.STATUS;
|
state = ClientState.STATUS;
|
||||||
|
|
@ -216,7 +217,9 @@ public class ClientConnection extends Thread {
|
||||||
//do nothing
|
//do nothing
|
||||||
} else if (packetType.equals(PacketStatusInRequest.class)) {
|
} else if (packetType.equals(PacketStatusInRequest.class)) {
|
||||||
String str = client_socket.getInetAddress().getHostName() + ":" + client_socket.getPort();
|
String str = client_socket.getInetAddress().getHostName() + ":" + client_socket.getPort();
|
||||||
|
if (Limbo.getInstance().getServerProperties().handshakeVerboseEnabled()) {
|
||||||
Limbo.getInstance().getConsole().sendMessage("[/" + str + "] <-> Handshake Status has pinged");
|
Limbo.getInstance().getConsole().sendMessage("[/" + str + "] <-> Handshake Status has pinged");
|
||||||
|
}
|
||||||
ServerProperties p = Limbo.getInstance().getServerProperties();
|
ServerProperties p = Limbo.getInstance().getServerProperties();
|
||||||
StatusPingEvent event = Limbo.getInstance().getEventsManager().callEvent(new StatusPingEvent(this, p.getVersionString(), p.getProtocol(), ComponentSerializer.parse(p.getMotdJson()), p.getMaxPlayers(), Limbo.getInstance().getPlayers().size(), p.getFavicon().orElse(null)));
|
StatusPingEvent event = Limbo.getInstance().getEventsManager().callEvent(new StatusPingEvent(this, p.getVersionString(), p.getProtocol(), ComponentSerializer.parse(p.getMotdJson()), p.getMaxPlayers(), Limbo.getInstance().getPlayers().size(), p.getFavicon().orElse(null)));
|
||||||
PacketStatusOutResponse packet = new PacketStatusOutResponse(Limbo.getInstance().buildServerListResponseJson(event.getVersion(), event.getProtocol(), event.getMotd(), event.getMaxPlayers(), event.getPlayersOnline(), event.getFavicon()));
|
PacketStatusOutResponse packet = new PacketStatusOutResponse(Limbo.getInstance().buildServerListResponseJson(event.getVersion(), event.getProtocol(), event.getMotd(), event.getMaxPlayers(), event.getPlayersOnline(), event.getFavicon()));
|
||||||
|
|
@ -288,6 +291,10 @@ public class ClientConnection extends Thread {
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
client_socket.close();
|
||||||
|
state = ClientState.DISCONNECTED;
|
||||||
|
}
|
||||||
|
|
||||||
if (state == ClientState.PLAY) {
|
if (state == ClientState.PLAY) {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ public class KeepAliveSender extends Thread {
|
||||||
while (true) {
|
while (true) {
|
||||||
try {
|
try {
|
||||||
for (ClientConnection client : Limbo.getInstance().getServerConnection().getClients()) {
|
for (ClientConnection client : Limbo.getInstance().getServerConnection().getClients()) {
|
||||||
if (client.getClientState().equals(ClientState.PLAY)) {
|
if (client.getClientState() != null && client.getClientState().equals(ClientState.PLAY)) {
|
||||||
try {
|
try {
|
||||||
PacketPlayOutKeepAlive packet = new PacketPlayOutKeepAlive(random.nextLong());
|
PacketPlayOutKeepAlive packet = new PacketPlayOutKeepAlive(random.nextLong());
|
||||||
client.setLastKeepAlivePayLoad(packet.getPayload());
|
client.setLastKeepAlivePayLoad(packet.getPayload());
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package com.loohp.limbo;
|
package com.loohp.limbo.Utils;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
|
|
@ -6,9 +6,9 @@ import java.io.IOException;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.loohp.limbo.Limbo;
|
||||||
import com.loohp.limbo.Commands.CommandSender;
|
import com.loohp.limbo.Commands.CommandSender;
|
||||||
import com.loohp.limbo.Server.Packets.PacketPlayOutDeclareCommands;
|
import com.loohp.limbo.Server.Packets.PacketPlayOutDeclareCommands;
|
||||||
import com.loohp.limbo.Utils.DataTypeIO;
|
|
||||||
|
|
||||||
public class DeclareCommands {
|
public class DeclareCommands {
|
||||||
|
|
||||||
|
|
@ -34,6 +34,9 @@ view-distance=6
|
||||||
#Ticks per second of the server
|
#Ticks per second of the server
|
||||||
ticks-per-second=5
|
ticks-per-second=5
|
||||||
|
|
||||||
|
#Should a message be printed to the console when a handshake occurs
|
||||||
|
handshake-verbose=true
|
||||||
|
|
||||||
#Server list message in Json
|
#Server list message in Json
|
||||||
motd={"text":"","extra":[{"text":"Limbo Server!","color":"yellow"}]}
|
motd={"text":"","extra":[{"text":"Limbo Server!","color":"yellow"}]}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue