Skip to content

Commit

Permalink
Redesign UUID generate strategy
Browse files Browse the repository at this point in the history
  • Loading branch information
tanyaofei committed Aug 3, 2024
1 parent 19af3f9 commit d60177c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import io.github.hello09x.fakeplayer.core.config.Config;
import io.github.hello09x.fakeplayer.core.constant.MetadataKeys;
import io.github.hello09x.fakeplayer.core.manager.FakeplayerManager;
import io.github.hello09x.fakeplayer.core.repository.FakePlayerProfileRepository;
import io.github.hello09x.fakeplayer.core.repository.UsedIdRepository;
import io.github.hello09x.fakeplayer.core.util.InternalAddressGenerator;
import org.bukkit.Bukkit;
Expand Down Expand Up @@ -39,12 +40,14 @@ public class FakeplayerListener implements Listener {

private final FakeplayerManager manager;
private final UsedIdRepository usedIdRepository;
private final FakePlayerProfileRepository profileRepository;
private final Config config;

@Inject
public FakeplayerListener(FakeplayerManager manager, UsedIdRepository usedIdRepository, Config config) {
public FakeplayerListener(FakeplayerManager manager, UsedIdRepository usedIdRepository, FakePlayerProfileRepository profileRepository, Config config) {
this.manager = manager;
this.usedIdRepository = usedIdRepository;
this.profileRepository = profileRepository;
this.config = config;
}

Expand All @@ -59,7 +62,7 @@ public void onLogin(@NotNull PlayerLoginEvent event) {
return;
}

if (usedIdRepository.contains(player.getUniqueId())) {
if (usedIdRepository.contains(player.getUniqueId()) || profileRepository.existsByUUID(player.getUniqueId())) {
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, textOfChildren(
translatable("fakeplayer.listener.login.deny-used-uuid", RED),
newline(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public void insert(@NotNull String name, @NotNull UUID uuid) {

public boolean existsByUUID(@NotNull UUID uuid) {
var sql = "SELECT EXISTS(SELECT 1 FROM fake_player_profile WHERE uuid = ?)";
return Boolean.TRUE.equals(jdbc.queryForObject(sql, new BooleanRowMapper()));
return Boolean.TRUE.equals(jdbc.queryForObject(sql, new BooleanRowMapper(), uuid.toString()));
}

public @Nullable UUID selectUUIDByName(@NotNull String name) {
Expand Down

0 comments on commit d60177c

Please sign in to comment.