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.
- Loading branch information
Showing
19 changed files
with
354 additions
and
92 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
6 changes: 3 additions & 3 deletions
6
bukkit/src/main/java/me/confuser/banmanager/bukkit/api/events/PlayerABanEvent.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
6 changes: 3 additions & 3 deletions
6
bukkit/src/main/java/me/confuser/banmanager/bukkit/api/events/PlayerABannedEvent.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
6 changes: 3 additions & 3 deletions
6
bukkit/src/main/java/me/confuser/banmanager/bukkit/api/events/PlayerAUnbanEvent.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
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
6 changes: 3 additions & 3 deletions
6
bungee/src/main/java/me/confuser/banmanager/bungee/api/events/PlayerABanEvent.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
6 changes: 3 additions & 3 deletions
6
bungee/src/main/java/me/confuser/banmanager/bungee/api/events/PlayerABannedEvent.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
6 changes: 3 additions & 3 deletions
6
bungee/src/main/java/me/confuser/banmanager/bungee/api/events/PlayerAUnbanEvent.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
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
85 changes: 85 additions & 0 deletions
85
common/src/main/java/me/confuser/banmanager/common/data/PlayerABanData.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,85 @@ | ||
package me.confuser.banmanager.common.data; | ||
|
||
import lombok.Getter; | ||
import me.confuser.banmanager.common.ormlite.field.DatabaseField; | ||
import me.confuser.banmanager.common.ormlite.table.DatabaseTable; | ||
import me.confuser.banmanager.common.storage.mysql.ByteArray; | ||
|
||
@DatabaseTable | ||
public class PlayerABanData { | ||
|
||
@DatabaseField(generatedId = true) | ||
@Getter | ||
private int id; | ||
@DatabaseField(canBeNull = false, foreign = true, foreignAutoRefresh = true, uniqueIndex = true, persisterClass = ByteArray.class, columnDefinition = "BINARY(16) NOT NULL") | ||
@Getter | ||
private PlayerData player; | ||
@DatabaseField(canBeNull = false) | ||
@Getter | ||
private String reason; | ||
@Getter | ||
@DatabaseField(canBeNull = false, foreign = true, foreignAutoRefresh = true, persisterClass = ByteArray.class, columnDefinition = "BINARY(16) NOT NULL") | ||
private PlayerData actor; | ||
|
||
// Should always be database time | ||
@DatabaseField(index = true, columnDefinition = "BIGINT UNSIGNED NOT NULL") | ||
@Getter | ||
private long created = System.currentTimeMillis() / 1000L; | ||
@DatabaseField(index = true, columnDefinition = "BIGINT UNSIGNED NOT NULL") | ||
@Getter | ||
private long updated = System.currentTimeMillis() / 1000L; | ||
@DatabaseField(index = true, columnDefinition = "BIGINT UNSIGNED NOT NULL") | ||
@Getter | ||
private long expires = 0; | ||
|
||
@DatabaseField | ||
@Getter | ||
private boolean silent = false; | ||
|
||
PlayerABanData() { | ||
|
||
} | ||
|
||
public PlayerABanData(PlayerData player, PlayerData actor, String reason, boolean silent) { | ||
this.player = player; | ||
this.reason = reason; | ||
this.actor = actor; | ||
this.silent = silent; | ||
} | ||
|
||
public PlayerABanData(PlayerData player, PlayerData actor, String reason, boolean silent, long expires) { | ||
this(player, actor, reason, silent); | ||
|
||
this.expires = expires; | ||
} | ||
|
||
// Only use for imports! | ||
public PlayerABanData(PlayerData player, PlayerData actor, String reason, boolean silent, long expires, long created) { | ||
this(player, actor, reason, silent, expires); | ||
|
||
this.created = created; | ||
} | ||
|
||
public PlayerABanData(int id, PlayerData player, PlayerData actor, String reason, boolean silent, long expires, long created, long updated) { | ||
this(player, actor, reason, silent, expires, created); | ||
|
||
this.id = id; | ||
this.updated = updated; | ||
} | ||
|
||
public PlayerABanData(PlayerBanRecord record) { | ||
this(record.getPlayer(), record.getPastActor(), record.getReason(), record.isSilent(), record.getExpired(), record.getPastCreated()); | ||
} | ||
|
||
public boolean hasExpired() { | ||
return getExpires() != 0 && getExpires() <= (System.currentTimeMillis() / 1000L); | ||
} | ||
|
||
public boolean equalsBan(PlayerABanData ban) { | ||
return ban.getReason().equals(this.reason) | ||
&& ban.getExpires() == expires | ||
&& ban.getCreated() == this.created | ||
&& ban.getPlayer().getUUID().equals(this.getPlayer().getUUID()) | ||
&& ban.getActor().getUUID().equals(this.actor.getUUID()); | ||
} | ||
} |
Oops, something went wrong.