From e60e66da3e0ada247a2b3139f38302cabfe97788 Mon Sep 17 00:00:00 2001 From: LossyDragon Date: Sat, 10 Aug 2024 22:40:01 -0500 Subject: [PATCH] Remove SteamTrading --- .../handlers/steamtrading/SteamTrading.java | 123 ------------------ .../callback/SessionStartCallback.java | 24 ---- .../callback/TradeProposedCallback.java | 34 ----- .../callback/TradeResultCallback.java | 85 ------------ .../steam/steamclient/SteamClient.java | 2 - 5 files changed, 268 deletions(-) delete mode 100644 src/main/java/in/dragonbra/javasteam/steam/handlers/steamtrading/SteamTrading.java delete mode 100644 src/main/java/in/dragonbra/javasteam/steam/handlers/steamtrading/callback/SessionStartCallback.java delete mode 100644 src/main/java/in/dragonbra/javasteam/steam/handlers/steamtrading/callback/TradeProposedCallback.java delete mode 100644 src/main/java/in/dragonbra/javasteam/steam/handlers/steamtrading/callback/TradeResultCallback.java diff --git a/src/main/java/in/dragonbra/javasteam/steam/handlers/steamtrading/SteamTrading.java b/src/main/java/in/dragonbra/javasteam/steam/handlers/steamtrading/SteamTrading.java deleted file mode 100644 index b7e55d0e..00000000 --- a/src/main/java/in/dragonbra/javasteam/steam/handlers/steamtrading/SteamTrading.java +++ /dev/null @@ -1,123 +0,0 @@ -package in.dragonbra.javasteam.steam.handlers.steamtrading; - -import in.dragonbra.javasteam.base.ClientMsgProtobuf; -import in.dragonbra.javasteam.base.IPacketMsg; -import in.dragonbra.javasteam.enums.EMsg; -import in.dragonbra.javasteam.handlers.ClientMsgHandler; -import in.dragonbra.javasteam.protobufs.steamclient.SteammessagesClientserver2.CMsgTrading_CancelTradeRequest; -import in.dragonbra.javasteam.protobufs.steamclient.SteammessagesClientserver2.CMsgTrading_InitiateTradeRequest; -import in.dragonbra.javasteam.protobufs.steamclient.SteammessagesClientserver2.CMsgTrading_InitiateTradeResponse; -import in.dragonbra.javasteam.protobufs.steamclient.SteammessagesClientserver2.CMsgTrading_StartSession; -import in.dragonbra.javasteam.steam.handlers.steamtrading.callback.SessionStartCallback; -import in.dragonbra.javasteam.steam.handlers.steamtrading.callback.TradeProposedCallback; -import in.dragonbra.javasteam.steam.handlers.steamtrading.callback.TradeResultCallback; -import in.dragonbra.javasteam.types.SteamID; -import in.dragonbra.javasteam.util.compat.Consumer; - -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; - -/** - * This handler is used for initializing Steam trades with other clients. - */ -public class SteamTrading extends ClientMsgHandler { - - private Map> dispatchMap; - - public SteamTrading() { - dispatchMap = new HashMap<>(); - - dispatchMap.put(EMsg.EconTrading_InitiateTradeProposed, this::handleTradeProposed); - dispatchMap.put(EMsg.EconTrading_InitiateTradeResult, this::handleTradeResult); - dispatchMap.put(EMsg.EconTrading_StartSession, this::handleStartSession); - - dispatchMap = Collections.unmodifiableMap(dispatchMap); - } - - /** - * Proposes a trade to another client. - * - * @param user The client to trade. - */ - public void trade(SteamID user) { - if (user == null) { - throw new IllegalArgumentException("user is null"); - } - - ClientMsgProtobuf tradeReq = - new ClientMsgProtobuf<>(CMsgTrading_InitiateTradeRequest.class, EMsg.EconTrading_InitiateTradeRequest); - - tradeReq.getBody().setOtherSteamid(user.convertToUInt64()); - - client.send(tradeReq); - } - - /** - * Responds to a trade proposal. - * - * @param tradeId The trade id of the received proposal. - * @param acceptTrade if set to true, the trade will be accepted. - */ - public void respondToTrade(int tradeId, boolean acceptTrade) { - ClientMsgProtobuf tradeResp = - new ClientMsgProtobuf<>(CMsgTrading_InitiateTradeResponse.class, EMsg.EconTrading_InitiateTradeResponse); - - tradeResp.getBody().setTradeRequestId(tradeId); - tradeResp.getBody().setResponse(acceptTrade ? 1 : 0); - - client.send(tradeResp); - } - - /** - * Cancels an already sent trade proposal. - * - * @param user The user. - */ - public void cancelTrade(SteamID user) { - if (user == null) { - throw new IllegalArgumentException("user is null"); - } - - ClientMsgProtobuf cancelTrade = - new ClientMsgProtobuf<>(CMsgTrading_CancelTradeRequest.class, EMsg.EconTrading_CancelTradeRequest); - - cancelTrade.getBody().setOtherSteamid(user.convertToUInt64()); - - client.send(cancelTrade); - } - - @Override - public void handleMsg(IPacketMsg packetMsg) { - if (packetMsg == null) { - throw new IllegalArgumentException("packetMsg is null"); - } - - Consumer dispatcher = dispatchMap.get(packetMsg.getMsgType()); - if (dispatcher != null) { - dispatcher.accept(packetMsg); - } - } - - private void handleTradeProposed(IPacketMsg packetMsg) { - ClientMsgProtobuf tradeProp = - new ClientMsgProtobuf<>(CMsgTrading_InitiateTradeRequest.class, packetMsg); - - client.postCallback(new TradeProposedCallback(tradeProp.getBody())); - } - - private void handleTradeResult(IPacketMsg packetMsg) { - ClientMsgProtobuf tradeResult = - new ClientMsgProtobuf<>(CMsgTrading_InitiateTradeResponse.class, packetMsg); - - client.postCallback(new TradeResultCallback(tradeResult.getBody())); - } - - private void handleStartSession(IPacketMsg packetMsg) { - ClientMsgProtobuf startSess = - new ClientMsgProtobuf<>(CMsgTrading_StartSession.class, packetMsg); - - client.postCallback(new SessionStartCallback(startSess.getBody())); - - } -} diff --git a/src/main/java/in/dragonbra/javasteam/steam/handlers/steamtrading/callback/SessionStartCallback.java b/src/main/java/in/dragonbra/javasteam/steam/handlers/steamtrading/callback/SessionStartCallback.java deleted file mode 100644 index 834ca2b5..00000000 --- a/src/main/java/in/dragonbra/javasteam/steam/handlers/steamtrading/callback/SessionStartCallback.java +++ /dev/null @@ -1,24 +0,0 @@ -package in.dragonbra.javasteam.steam.handlers.steamtrading.callback; - -import in.dragonbra.javasteam.protobufs.steamclient.SteammessagesClientserver2.CMsgTrading_StartSession; -import in.dragonbra.javasteam.steam.steamclient.callbackmgr.CallbackMsg; -import in.dragonbra.javasteam.types.SteamID; - -/** - * This callback is fired when a trading session has started. - */ -public class SessionStartCallback extends CallbackMsg { - - private final SteamID otherClient; - - public SessionStartCallback(CMsgTrading_StartSession.Builder msg) { - otherClient = new SteamID(msg.getOtherSteamid()); - } - - /** - * @return the SteamID of the client that this the trading session has started with. - */ - public SteamID getOtherClient() { - return otherClient; - } -} diff --git a/src/main/java/in/dragonbra/javasteam/steam/handlers/steamtrading/callback/TradeProposedCallback.java b/src/main/java/in/dragonbra/javasteam/steam/handlers/steamtrading/callback/TradeProposedCallback.java deleted file mode 100644 index beacf1ef..00000000 --- a/src/main/java/in/dragonbra/javasteam/steam/handlers/steamtrading/callback/TradeProposedCallback.java +++ /dev/null @@ -1,34 +0,0 @@ -package in.dragonbra.javasteam.steam.handlers.steamtrading.callback; - -import in.dragonbra.javasteam.protobufs.steamclient.SteammessagesClientserver2.CMsgTrading_InitiateTradeRequest; -import in.dragonbra.javasteam.steam.steamclient.callbackmgr.CallbackMsg; -import in.dragonbra.javasteam.types.SteamID; - -/** - * This callback is fired when this client receives a trade proposal. - */ -public class TradeProposedCallback extends CallbackMsg { - - private final int tradeID; - - private final SteamID otherClient; - - public TradeProposedCallback(CMsgTrading_InitiateTradeRequest.Builder msg) { - tradeID = msg.getTradeRequestId(); - otherClient = new SteamID(msg.getOtherSteamid()); - } - - /** - * @return the Trade ID of his proposal, used for replying. - */ - public int getTradeID() { - return tradeID; - } - - /** - * @return the SteamID of the client that sent the proposal. - */ - public SteamID getOtherClient() { - return otherClient; - } -} diff --git a/src/main/java/in/dragonbra/javasteam/steam/handlers/steamtrading/callback/TradeResultCallback.java b/src/main/java/in/dragonbra/javasteam/steam/handlers/steamtrading/callback/TradeResultCallback.java deleted file mode 100644 index 0c9a800f..00000000 --- a/src/main/java/in/dragonbra/javasteam/steam/handlers/steamtrading/callback/TradeResultCallback.java +++ /dev/null @@ -1,85 +0,0 @@ -package in.dragonbra.javasteam.steam.handlers.steamtrading.callback; - -import in.dragonbra.javasteam.enums.EEconTradeResponse; -import in.dragonbra.javasteam.protobufs.steamclient.SteammessagesClientserver2.CMsgTrading_InitiateTradeResponse; -import in.dragonbra.javasteam.steam.steamclient.callbackmgr.CallbackMsg; -import in.dragonbra.javasteam.types.SteamID; - -/** - * This callback is fired when this client receives the response from a trade proposal. - */ -public class TradeResultCallback extends CallbackMsg { - - private final int tradeID; - - private final EEconTradeResponse response; - - private final SteamID otherClient; - - private final int numDaysSteamGuardRequired; - - private final int numDaysNewDeviceCooldown; - - private final int defaultNumDaysPasswordResetProbation; - - private final int numDaysPasswordResetProbation; - - public TradeResultCallback(CMsgTrading_InitiateTradeResponse.Builder msg) { - tradeID = msg.getTradeRequestId(); - response = EEconTradeResponse.from(msg.getResponse()); - otherClient = new SteamID(msg.getOtherSteamid()); - numDaysSteamGuardRequired = msg.getSteamguardRequiredDays(); - numDaysNewDeviceCooldown = msg.getNewDeviceCooldownDays(); - defaultNumDaysPasswordResetProbation = msg.getDefaultPasswordResetProbationDays(); - numDaysPasswordResetProbation = msg.getPasswordResetProbationDays(); - } - - /** - * @return the Trade ID that this result is for. - */ - public int getTradeID() { - return tradeID; - } - - /** - * @return the response of the trade proposal. - */ - public EEconTradeResponse getResponse() { - return response; - } - - /** - * @return the {@link SteamID} of the client that responded to the proposal. - */ - public SteamID getOtherClient() { - return otherClient; - } - - /** - * @return the number of days Steam Guard is required to have been active on this account. - */ - public int getNumDaysSteamGuardRequired() { - return numDaysSteamGuardRequired; - } - - /** - * @return the number of days a new device cannot trade for. - */ - public int getNumDaysNewDeviceCooldown() { - return numDaysNewDeviceCooldown; - } - - /** - * @return the default number of days one cannot trade for after a password reset. - */ - public int getDefaultNumDaysPasswordResetProbation() { - return defaultNumDaysPasswordResetProbation; - } - - /** - * @return the number of days one cannot trade for after a password reset. - */ - public int getNumDaysPasswordResetProbation() { - return numDaysPasswordResetProbation; - } -} diff --git a/src/main/java/in/dragonbra/javasteam/steam/steamclient/SteamClient.java b/src/main/java/in/dragonbra/javasteam/steam/steamclient/SteamClient.java index 857178ee..ba450389 100644 --- a/src/main/java/in/dragonbra/javasteam/steam/steamclient/SteamClient.java +++ b/src/main/java/in/dragonbra/javasteam/steam/steamclient/SteamClient.java @@ -15,7 +15,6 @@ import in.dragonbra.javasteam.steam.handlers.steamnetworking.SteamNetworking; import in.dragonbra.javasteam.steam.handlers.steamnotifications.SteamNotifications; import in.dragonbra.javasteam.steam.handlers.steamscreenshots.SteamScreenshots; -import in.dragonbra.javasteam.steam.handlers.steamtrading.SteamTrading; import in.dragonbra.javasteam.steam.handlers.steamunifiedmessages.SteamUnifiedMessages; import in.dragonbra.javasteam.steam.handlers.steamuser.SteamUser; import in.dragonbra.javasteam.steam.handlers.steamuserstats.SteamUserStats; @@ -83,7 +82,6 @@ public SteamClient(SteamConfiguration configuration) { addHandler(new SteamMasterServer()); addHandler(new SteamCloud()); addHandler(new SteamWorkshop()); - addHandler(new SteamTrading()); addHandler(new SteamUnifiedMessages()); addHandler(new SteamScreenshots()); addHandler(new SteamNetworking());