-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #37 from TheDeafCreeper/serverclosing
Add the ability to close servers so that they're ignored by the load balancer.
- Loading branch information
Showing
16 changed files
with
480 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
...c/main/java/group/aelysium/rustyconnector/core/lib/packets/variants/LockServerPacket.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package group.aelysium.rustyconnector.core.lib.packets.variants; | ||
|
||
import com.google.gson.JsonObject; | ||
import com.google.gson.JsonPrimitive; | ||
import group.aelysium.rustyconnector.core.lib.packets.GenericPacket; | ||
import group.aelysium.rustyconnector.core.lib.packets.PacketOrigin; | ||
import group.aelysium.rustyconnector.core.lib.packets.PacketType; | ||
import io.lettuce.core.KeyValue; | ||
|
||
import java.net.InetSocketAddress; | ||
import java.util.List; | ||
|
||
public class LockServerPacket extends GenericPacket { | ||
private String serverName; | ||
|
||
public String serverName() { return this.serverName; } | ||
|
||
public LockServerPacket(InetSocketAddress address, PacketOrigin origin, List<KeyValue<String, JsonPrimitive>> parameters) { | ||
super(PacketType.LOCK_SERVER, address, origin); | ||
|
||
parameters.forEach(entry -> { | ||
String key = entry.getKey(); | ||
JsonPrimitive value = entry.getValue(); | ||
|
||
if (key.equals(UnlockServerPacket.ValidParameters.SERVER_NAME)) { | ||
this.serverName = value.getAsString(); | ||
} | ||
}); | ||
} | ||
public LockServerPacket(int messageVersion, String rawMessage, InetSocketAddress address, PacketOrigin origin, List<KeyValue<String, JsonPrimitive>> parameters) { | ||
super(messageVersion, rawMessage, PacketType.LOCK_SERVER, address, origin); | ||
|
||
parameters.forEach(entry -> { | ||
String key = entry.getKey(); | ||
JsonPrimitive value = entry.getValue(); | ||
|
||
if (key.equals(UnlockServerPacket.ValidParameters.SERVER_NAME)) { | ||
this.serverName = value.getAsString(); | ||
} | ||
}); | ||
} | ||
|
||
@Override | ||
public JsonObject toJSON() { | ||
JsonObject object = super.toJSON(); | ||
JsonObject parameters = new JsonObject(); | ||
|
||
parameters.add(UnlockServerPacket.ValidParameters.SERVER_NAME, new JsonPrimitive(this.serverName)); | ||
|
||
object.add(MasterValidParameters.PARAMETERS, parameters); | ||
|
||
return object; | ||
} | ||
} |
66 changes: 66 additions & 0 deletions
66
...main/java/group/aelysium/rustyconnector/core/lib/packets/variants/UnlockServerPacket.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package group.aelysium.rustyconnector.core.lib.packets.variants; | ||
|
||
import com.google.gson.JsonObject; | ||
import com.google.gson.JsonPrimitive; | ||
import group.aelysium.rustyconnector.core.lib.packets.GenericPacket; | ||
import group.aelysium.rustyconnector.core.lib.packets.PacketOrigin; | ||
import group.aelysium.rustyconnector.core.lib.packets.PacketType; | ||
import io.lettuce.core.KeyValue; | ||
|
||
import java.net.InetSocketAddress; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class UnlockServerPacket extends GenericPacket { | ||
private String serverName; | ||
|
||
public String serverName() { return this.serverName; } | ||
|
||
public UnlockServerPacket(InetSocketAddress address, PacketOrigin origin, List<KeyValue<String, JsonPrimitive>> parameters) { | ||
super(PacketType.UNLOCK_SERVER, address, origin); | ||
|
||
parameters.forEach(entry -> { | ||
String key = entry.getKey(); | ||
JsonPrimitive value = entry.getValue(); | ||
|
||
if (key.equals(ValidParameters.SERVER_NAME)) { | ||
this.serverName = value.getAsString(); | ||
} | ||
}); | ||
} | ||
public UnlockServerPacket(int messageVersion, String rawMessage, InetSocketAddress address, PacketOrigin origin, List<KeyValue<String, JsonPrimitive>> parameters) { | ||
super(messageVersion, rawMessage, PacketType.UNLOCK_SERVER, address, origin); | ||
|
||
parameters.forEach(entry -> { | ||
String key = entry.getKey(); | ||
JsonPrimitive value = entry.getValue(); | ||
|
||
if (key.equals(ValidParameters.SERVER_NAME)) { | ||
this.serverName = value.getAsString(); | ||
} | ||
}); | ||
} | ||
|
||
@Override | ||
public JsonObject toJSON() { | ||
JsonObject object = super.toJSON(); | ||
JsonObject parameters = new JsonObject(); | ||
|
||
parameters.add(ValidParameters.SERVER_NAME, new JsonPrimitive(this.serverName)); | ||
|
||
object.add(MasterValidParameters.PARAMETERS, parameters); | ||
|
||
return object; | ||
} | ||
|
||
public interface ValidParameters { | ||
String SERVER_NAME = "s"; | ||
|
||
static List<String> toList() { | ||
List<String> list = new ArrayList<>(); | ||
list.add(SERVER_NAME); | ||
|
||
return list; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.