Skip to content

Commit

Permalink
fix: Fix Player asignation between sessions
Browse files Browse the repository at this point in the history
  • Loading branch information
4drian3d committed Apr 24, 2022
1 parent 447eb3f commit f37255a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
Expand Up @@ -23,7 +23,7 @@
* To get the real player, check {@link #getPlayer()}
*/
public final class InfractionPlayer implements ForwardingAudience.Single {
private final Player player;
private Player player;
private String preLastMessage;
private String lastMessage;
private String preLastCommand;
Expand All @@ -39,7 +39,7 @@ public final class InfractionPlayer implements ForwardingAudience.Single {
* @param player the player on which it will be based
*/
@Internal
InfractionPlayer(@NotNull Player player){
InfractionPlayer(final @NotNull Player player){
this.player = Objects.requireNonNull(player);
this.preLastMessage = " .";
this.lastMessage = " ";
Expand Down Expand Up @@ -215,6 +215,9 @@ public long getTimeSinceLastCommand(){
final UUID uuid = Objects.requireNonNull(player).getUniqueId();
InfractionPlayer infractor = ChatRegulator.infractionPlayers.get(uuid);
if(infractor != null){
if(!infractor.isOnline()) {
infractor.player = player;
}
return infractor;
} else {
infractor = new InfractionPlayer(player);
Expand Down
Expand Up @@ -4,7 +4,6 @@
import com.velocitypowered.api.event.PostOrder;
import com.velocitypowered.api.event.Subscribe;
import com.velocitypowered.api.event.connection.PostLoginEvent;
import com.velocitypowered.api.proxy.Player;

import org.jetbrains.annotations.ApiStatus.Internal;

Expand All @@ -22,10 +21,6 @@ public final class JoinListener {
*/
@Subscribe(order = PostOrder.LAST)
public EventTask onPlayerJoin(final PostLoginEvent event){
return EventTask.async(() -> {
final Player player = event.getPlayer();
final InfractionPlayer p = InfractionPlayer.get(player);
p.isOnline(true);
});
return EventTask.async(() -> InfractionPlayer.get(event.getPlayer()).isOnline(true));
}
}

0 comments on commit f37255a

Please sign in to comment.