Skip to content

Commit

Permalink
WIP work EngineConnection
Browse files Browse the repository at this point in the history
  • Loading branch information
aromaa committed May 6, 2024
1 parent 41b0b0c commit a459a98
Show file tree
Hide file tree
Showing 22 changed files with 421 additions and 91 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
import org.spongepowered.api.event.Cause;
import org.spongepowered.api.item.inventory.Container;
import org.spongepowered.api.item.inventory.Inventory;
import org.spongepowered.api.network.ServerPlayerConnection;
import org.spongepowered.api.network.ServerSideConnection;
import org.spongepowered.api.resourcepack.ResourcePack;
import org.spongepowered.api.scoreboard.Scoreboard;
import org.spongepowered.api.service.permission.Subject;
Expand Down Expand Up @@ -179,12 +179,12 @@ default SetValue.Mutable<SkinPart> displayedSkinParts() {
}

/**
* Gets the appropriate {@link ServerPlayerConnection} linking this player to a
* Gets the appropriate {@link ServerSideConnection} linking this player to a
* client.
*
* @return The connection
*/
ServerPlayerConnection connection();
ServerSideConnection connection();

/**
* Sends a given {@link ResourcePack} to this player.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,17 @@ public interface ServerSideConnectionEvent extends Event {
ServerSideConnection connection();

/**
* Gets the {@link GameProfile} of the client attempting to connect.
*
* @return The client's profile
* Called asynchronously when the client attempts to connect to
* the server.
*/
default GameProfile profile() {
return this.connection().profile();
interface Intent extends ServerSideConnectionEvent, MessageEvent, Cancellable {

/**
* Gets if the user is intending to connect due to being transferred.
*
* @return If the user is transferring.
*/
boolean isTransfer();
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* This file is part of SpongeAPI, licensed under the MIT License (MIT).
*
* Copyright (c) SpongePowered <https://www.spongepowered.org>
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.spongepowered.api.network;

public interface ClientConnectionConfigurationState extends EngineConnectionConfigurationState, ClientConnectionState {
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,10 @@

import org.spongepowered.api.entity.living.player.client.LocalPlayer;

/**
* Represents a connection of a client to the server where
* the client {@link LocalPlayer player} has successfully joined.
*/
public interface LocalPlayerConnection extends PlayerConnection, ClientSideConnection {
public interface ClientConnectionGameState extends EngineConnectionGameState, ClientConnectionState {

/**
* Gets the associated {@link LocalPlayer player} for this connection.
* Gets the associated {@link LocalPlayer player} for this connection state.
*
* @return The associated player
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* This file is part of SpongeAPI, licensed under the MIT License (MIT).
*
* Copyright (c) SpongePowered <https://www.spongepowered.org>
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.spongepowered.api.network;

public interface ClientConnectionIntentState extends EngineConnectionIntentState, ClientSideConnection {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* This file is part of SpongeAPI, licensed under the MIT License (MIT).
*
* Copyright (c) SpongePowered <https://www.spongepowered.org>
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.spongepowered.api.network;

public interface ClientConnectionLoginState extends EngineConnectionLoginState, ClientConnectionState {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* This file is part of SpongeAPI, licensed under the MIT License (MIT).
*
* Copyright (c) SpongePowered <https://www.spongepowered.org>
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.spongepowered.api.network;

public interface ClientConnectionState extends EngineConnectionState {
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ public interface EngineConnection extends RemoteConnection {
*/
EngineConnectionSide<? extends EngineConnection> side();

/**
* Gets the state this connection is on.
*
* @return The state
*/
EngineConnectionState state();

/**
* Closes the connection, showing the default disconnect reason.
* (the translation key {@code disconnect.disconnected})
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* This file is part of SpongeAPI, licensed under the MIT License (MIT).
*
* Copyright (c) SpongePowered <https://www.spongepowered.org>
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.spongepowered.api.network;

public interface EngineConnectionConfigurationState extends EngineConnectionState {
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,10 @@

import org.spongepowered.api.entity.living.player.Player;

/**
* Represents a connection of a client to the server where
* the {@link Player} has successfully joined.
*/
public interface PlayerConnection extends EngineConnection {
public interface EngineConnectionGameState extends EngineConnectionState {

/**
* Gets the associated {@link Player player} for this connection.
* Gets the associated {@link Player player} for this connection state.
*
* @return The associated player
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* This file is part of SpongeAPI, licensed under the MIT License (MIT).
*
* Copyright (c) SpongePowered <https://www.spongepowered.org>
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.spongepowered.api.network;

public interface EngineConnectionIntentState extends EngineConnectionState {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* This file is part of SpongeAPI, licensed under the MIT License (MIT).
*
* Copyright (c) SpongePowered <https://www.spongepowered.org>
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.spongepowered.api.network;

public interface EngineConnectionLoginState extends EngineConnectionState {
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,43 +25,15 @@
package org.spongepowered.api.network;

/**
* An enumeration of all the possible engine connection types.
* Represents the current state of the connection.
*/
public final class EngineConnectionTypes {
public interface EngineConnectionState {

/**
* The supertype of all the known connection types.
* Gets whatever the connection was established because
* the client was transferred.
*
* @return Whatever the client was transferred.
*/
public static final Class<EngineConnection> ALL = EngineConnection.class;

/**
* The client side connection type.
*/
public static final Class<ClientSideConnection> CLIENT_SIDE = ClientSideConnection.class;

/**
* The client side connection type where the player
* has successfully joined a server.
*/
public static final Class<LocalPlayerConnection> LOCAL_PLAYER = LocalPlayerConnection.class;

/**
* The server or client connection type where the player
* has successfully joined a server.
*/
public static final Class<PlayerConnection> PLAYER = PlayerConnection.class;

/**
* The server side connection type.
*/
public static final Class<ServerSideConnection> SERVER_SIDE = ServerSideConnection.class;

/**
* The server side connection type where the player
* has successfully joined a server.
*/
public static final Class<ServerPlayerConnection> SERVER_PLAYER = ServerPlayerConnection.class;

private EngineConnectionTypes() {
}
boolean transferred();
}
Loading

0 comments on commit a459a98

Please sign in to comment.