Skip to content

Commit

Permalink
Some basic improvements to match stuff/rename
Browse files Browse the repository at this point in the history
  • Loading branch information
Nathan Martin committed Jun 8, 2024
1 parent aeba394 commit eea0c7c
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 27 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package group.aelysium.rustyconnector.toolkit.velocity.matchmaking;

import group.aelysium.rustyconnector.toolkit.core.matchmaking.IPlayerRank;
import group.aelysium.rustyconnector.toolkit.velocity.load_balancing.ISortable;
import group.aelysium.rustyconnector.toolkit.velocity.player.IPlayer;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
package group.aelysium.rustyconnector.toolkit.velocity.matchmaking;

import org.jetbrains.annotations.NotNull;

import java.util.List;

public interface IVelocityPlayerRank extends group.aelysium.rustyconnector.toolkit.core.matchmaking.IPlayerRank {
/**
* Returns the computer used to compute new ranks.
*/
IComputor computor();
@NotNull IComputer computer();

interface IComputor {
interface IComputer {
/**
* Compute the new rank of all the winners and losers.
* @param winners The winners.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import group.aelysium.rustyconnector.toolkit.core.matchmaking.IPlayerRank;
import group.aelysium.rustyconnector.toolkit.velocity.matchmaking.IVelocityPlayerRank;
import group.aelysium.rustyconnector.toolkit.velocity.player.IPlayer;
import org.jetbrains.annotations.NotNull;

import java.util.Objects;

Expand All @@ -12,21 +13,21 @@ public class MatchPlayer implements IMatchPlayer {
private final IVelocityPlayerRank rank;
private final String gameId;

public MatchPlayer(IPlayer player, IVelocityPlayerRank rank, String gameId) {
public MatchPlayer(@NotNull IPlayer player, @NotNull IVelocityPlayerRank rank, @NotNull String gameId) {
this.player = player;
this.rank = rank;
this.gameId = gameId;
}

public IPlayer player() {
public @NotNull IPlayer player() {
return this.player;
}

public IVelocityPlayerRank gameRank() {
public @NotNull IVelocityPlayerRank gameRank() {
return this.rank;
}

public String gameId() {
public @NotNull String gameId() {
return this.gameId;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ public void leave(IPlayer player) {

if(settings.quittersLose()) {
Optional<IMatchPlayer> matchPlayer = this.matchmaker.matchPlayer(player);
matchPlayer.ifPresent(mp -> mp.gameRank().computor().compute(List.of(), List.of(mp), matchmaker, this));
matchPlayer.ifPresent(mp -> mp.gameRank().computer().compute(List.of(), List.of(mp), matchmaker, this));
}

if(this.players.size() > this.settings.min()) return;
Expand Down Expand Up @@ -192,12 +192,12 @@ public void end(List<UUID> winners, List<UUID> losers, boolean unlock) {

((Matchmaker) this.matchmaker).remove(this);

IVelocityPlayerRank.IComputor computer = null;
IVelocityPlayerRank.IComputer computer = null;
List<IMatchPlayer> playerWinners = new ArrayList<>();
List<IMatchPlayer> playerLosers = new ArrayList<>();

for (IMatchPlayer matchPlayer : this.players.values()) {
if(computer == null) computer = matchPlayer.gameRank().computor();
computer = matchPlayer.gameRank().computer();

try {
if(winners.contains(matchPlayer.player().uuid())) playerWinners.add(matchPlayer);
Expand Down Expand Up @@ -237,9 +237,9 @@ public void endTied(boolean unlock) {

((Matchmaker) this.matchmaker).remove(this);

IVelocityPlayerRank.IComputor computer = null;
IVelocityPlayerRank.IComputer computer = null;
for (IMatchPlayer matchPlayer : this.players.values()) {
if(computer == null) computer = matchPlayer.gameRank().computor();
if(computer == null) computer = matchPlayer.gameRank().computer();

if(this.active())
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
import com.google.gson.JsonPrimitive;
import group.aelysium.rustyconnector.toolkit.velocity.matchmaking.IMatchPlayer;
import group.aelysium.rustyconnector.toolkit.velocity.matchmaking.IMatchmaker;
import group.aelysium.rustyconnector.toolkit.core.matchmaking.IPlayerRank;
import group.aelysium.rustyconnector.toolkit.velocity.matchmaking.ISession;
import group.aelysium.rustyconnector.toolkit.velocity.matchmaking.IVelocityPlayerRank;
import org.jetbrains.annotations.NotNull;

import java.util.List;

Expand Down Expand Up @@ -34,7 +34,7 @@ public String schemaName() {
return schema();
}

public IComputor computor() {
public @NotNull IComputer computer() {
return Computer.New();
}

Expand All @@ -46,7 +46,7 @@ public JsonObject toJSON() {
return object;
}

public static class Computer implements IComputor {
public static class Computer implements IComputer {
private static final Computer singleton = new Computer();
public static Computer New() {
return singleton;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
import com.google.gson.JsonPrimitive;
import group.aelysium.rustyconnector.toolkit.velocity.matchmaking.IMatchPlayer;
import group.aelysium.rustyconnector.toolkit.velocity.matchmaking.IMatchmaker;
import group.aelysium.rustyconnector.toolkit.core.matchmaking.IPlayerRank;
import group.aelysium.rustyconnector.toolkit.velocity.matchmaking.ISession;
import group.aelysium.rustyconnector.toolkit.velocity.matchmaking.IVelocityPlayerRank;
import org.jetbrains.annotations.NotNull;

import java.util.List;

Expand Down Expand Up @@ -40,7 +40,7 @@ public String schemaName() {
return schema();
}

public IComputor computor() {
public @NotNull IComputer computer() {
return Computer.New();
}

Expand All @@ -53,7 +53,7 @@ public JsonObject toJSON() {
return object;
}

public static class Computer implements IComputor {
public static class Computer implements IComputer {
private static final Computer singleton = new Computer();
public static Computer New() {
return singleton;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
import com.google.gson.JsonPrimitive;
import group.aelysium.rustyconnector.toolkit.velocity.matchmaking.IMatchPlayer;
import group.aelysium.rustyconnector.toolkit.velocity.matchmaking.IMatchmaker;
import group.aelysium.rustyconnector.toolkit.core.matchmaking.IPlayerRank;
import group.aelysium.rustyconnector.toolkit.velocity.matchmaking.ISession;
import group.aelysium.rustyconnector.toolkit.velocity.matchmaking.IVelocityPlayerRank;
import org.jetbrains.annotations.NotNull;

import java.util.List;

Expand All @@ -25,7 +25,7 @@ public String schemaName() {
return schema();
}

public IComputor computor() {
public @NotNull IComputer computer() {
return Computer.New();
}

Expand All @@ -36,7 +36,7 @@ public JsonObject toJSON() {
return object;
}

public static class Computer implements IComputor {
public static class Computer implements IComputer {
private static final Computer singleton = new Computer();
public static Computer New() {
return singleton;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
import com.google.gson.JsonPrimitive;
import group.aelysium.rustyconnector.toolkit.velocity.matchmaking.IMatchPlayer;
import group.aelysium.rustyconnector.toolkit.velocity.matchmaking.IMatchmaker;
import group.aelysium.rustyconnector.toolkit.core.matchmaking.IPlayerRank;
import group.aelysium.rustyconnector.toolkit.velocity.matchmaking.ISession;
import group.aelysium.rustyconnector.toolkit.velocity.matchmaking.IVelocityPlayerRank;
import group.aelysium.rustyconnector.toolkit.velocity.storage.IDatabase;
import org.jetbrains.annotations.NotNull;

import java.util.List;

Expand Down Expand Up @@ -48,7 +48,7 @@ public String schemaName() {
return schema();
}

public IComputor computor() {
public @NotNull IComputer computer() {
return Computer.New();
}

Expand All @@ -61,7 +61,7 @@ public JsonObject toJSON() {
return object;
}

public static class Computer implements IComputor {
public static class Computer implements IComputer {
private static final Computer singleton = new Computer();
public static Computer New() {
return singleton;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@

import group.aelysium.rustyconnector.toolkit.velocity.matchmaking.IMatchPlayer;
import group.aelysium.rustyconnector.toolkit.velocity.matchmaking.IMatchmaker;
import group.aelysium.rustyconnector.toolkit.core.matchmaking.IPlayerRank;
import group.aelysium.rustyconnector.toolkit.velocity.matchmaking.ISession;
import group.aelysium.rustyconnector.toolkit.velocity.matchmaking.IVelocityPlayerRank;
import group.aelysium.rustyconnector.toolkit.velocity.storage.IDatabase;
import org.jetbrains.annotations.NotNull;

import java.util.List;

Expand Down Expand Up @@ -52,7 +52,7 @@ public String schemaName() {
return schema();
}

public IComputor computor() {
public @NotNull IComputer computer() {
return Computer.New();
}

Expand All @@ -66,7 +66,7 @@ public JsonObject toJSON() {
return object;
}

public static class Computer implements IComputor {
public static class Computer implements IComputer {
private static final Computer singleton = new Computer();
public static Computer New() {
return singleton;
Expand Down

0 comments on commit eea0c7c

Please sign in to comment.