forked from GeyserMC/Floodgate
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
127 additions
and
1 deletion.
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
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
48 changes: 48 additions & 0 deletions
48
common/src/main/java/org/geysermc/floodgate/LinkRequest.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,48 @@ | ||
package org.geysermc.floodgate; | ||
|
||
import lombok.Getter; | ||
|
||
import java.time.Instant; | ||
import java.util.UUID; | ||
|
||
@Getter | ||
public class LinkRequest { | ||
/** | ||
* The Java username of the linked player | ||
*/ | ||
private String javaUsername; | ||
/** | ||
* The Java UUID of the linked player | ||
*/ | ||
private UUID javaUniqueId; | ||
/** | ||
* The link code | ||
*/ | ||
private String linkCode; | ||
/** | ||
* The username of player being linked | ||
*/ | ||
private String bedrockUsername; | ||
/** | ||
* The time when the link was requested | ||
*/ | ||
private long unixTime; | ||
|
||
LinkRequest(String username, UUID uuid, String code, String beUsername) { | ||
javaUniqueId = uuid; | ||
javaUsername = username; | ||
linkCode = code; | ||
bedrockUsername = beUsername; | ||
unixTime = Instant.now().getEpochSecond(); | ||
} | ||
|
||
public boolean isExpired() { | ||
long timePassed = Instant.now().getEpochSecond() - unixTime; | ||
return timePassed > PlayerLink.getVerifyLinkTimeout(); | ||
} | ||
|
||
public boolean checkGamerTag(FloodgatePlayer player) { | ||
// Accept the request whether the prefix was used or not | ||
return bedrockUsername.equals(player.getUsername()) || bedrockUsername.equals(player.getJavaUsername()); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
common/src/main/java/org/geysermc/floodgate/LinkedPlayer.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,25 @@ | ||
package org.geysermc.floodgate; | ||
|
||
import lombok.AccessLevel; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.Setter; | ||
|
||
import java.util.UUID; | ||
|
||
@AllArgsConstructor(access = AccessLevel.PACKAGE) | ||
@Getter @Setter | ||
public class LinkedPlayer { | ||
/** | ||
* The Java username of the linked player | ||
*/ | ||
public String javaUsername; | ||
/** | ||
* The Java UUID of the linked player | ||
*/ | ||
public UUID javaUniqueId; | ||
/** | ||
* The UUID of the Bedrock player | ||
*/ | ||
public UUID bedrockId; | ||
} |
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