forked from BanManagement/BanManager
-
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.
Attempt to fix wrong and broken duplicated player data
- Loading branch information
Showing
7 changed files
with
199 additions
and
97 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
78 changes: 78 additions & 0 deletions
78
common/src/main/java/me/confuser/banmanager/common/data/DuplicatePlayerData.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,78 @@ | ||
package me.confuser.banmanager.common.data; | ||
|
||
import lombok.Getter; | ||
import lombok.Setter; | ||
import lombok.ToString; | ||
import me.confuser.banmanager.common.ipaddr.AddressStringException; | ||
import me.confuser.banmanager.common.ipaddr.IPAddress; | ||
import me.confuser.banmanager.common.ipaddr.IPAddressString; | ||
import me.confuser.banmanager.common.ormlite.field.DatabaseField; | ||
import me.confuser.banmanager.common.ormlite.table.DatabaseTable; | ||
import me.confuser.banmanager.common.storage.mysql.ByteArray; | ||
import me.confuser.banmanager.common.storage.mysql.IpAddress; | ||
import me.confuser.banmanager.common.util.UUIDUtils; | ||
|
||
import java.util.UUID; | ||
|
||
@DatabaseTable | ||
@ToString | ||
public class DuplicatePlayerData { | ||
|
||
@DatabaseField(id = true, persisterClass = ByteArray.class, columnDefinition = "BINARY(16) NOT NULL") | ||
@Getter | ||
private byte[] id; | ||
@DatabaseField(index = true, width = 16, columnDefinition = "VARCHAR(16) NOT NULL") | ||
@Getter | ||
@Setter | ||
private String name; | ||
@Getter | ||
@DatabaseField(index = true, persisterClass = IpAddress.class, columnDefinition = "VARBINARY(16) NOT NULL") | ||
private IPAddress ip; | ||
@Getter | ||
@DatabaseField(columnDefinition = "BIGINT UNSIGNED NOT NULL") | ||
private long lastSeen = System.currentTimeMillis() / 1000L; | ||
|
||
private UUID uuid = null; | ||
|
||
DuplicatePlayerData() { | ||
|
||
} | ||
|
||
public DuplicatePlayerData(UUID uuid, String name) { | ||
this.uuid = uuid; | ||
this.id = UUIDUtils.toBytes(uuid); | ||
this.name = name; | ||
|
||
try { | ||
this.ip = new IPAddressString("127.0.0.1").toAddress(); | ||
} catch (AddressStringException e) { | ||
e.printStackTrace(); | ||
} | ||
|
||
this.lastSeen = System.currentTimeMillis() / 1000L; | ||
} | ||
|
||
public DuplicatePlayerData(UUID uuid, String name, IPAddress ip) { | ||
this.uuid = uuid; | ||
this.id = UUIDUtils.toBytes(uuid); | ||
this.name = name; | ||
this.ip = ip; | ||
this.lastSeen = System.currentTimeMillis() / 1000L; | ||
} | ||
|
||
public DuplicatePlayerData(UUID uuid, String name, IPAddress ip, long lastSeen) { | ||
this.uuid = uuid; | ||
this.id = UUIDUtils.toBytes(uuid); | ||
this.name = name; | ||
this.ip = ip; | ||
this.lastSeen = lastSeen; | ||
} | ||
|
||
public UUID getUUID() { | ||
if (uuid == null) { | ||
uuid = UUIDUtils.fromBytes(id); | ||
} | ||
|
||
return uuid; | ||
} | ||
} |
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.