0

ban/unban process

This commit is contained in:
2021-05-18 20:29:54 +03:00
parent 4a37364497
commit edd21ef315
9 changed files with 96 additions and 31 deletions

View File

@@ -3,9 +3,12 @@ package ru.dmitriymx.plugin.service;
import org.bukkit.entity.Player;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import ru.dmitriymx.plugin.entity.BannedUserEntity;
import ru.dmitriymx.plugin.repository.BannedUserRepository;
@Service
@Transactional
public class BannedUserService {
private final BannedUserRepository repository;
@@ -15,11 +18,21 @@ public class BannedUserService {
this.repository = repository;
}
public boolean inBanned(Player player) {
return inBanned(player.getName());
public boolean isBanned(Player player) {
return isBanned(player.getName());
}
public boolean inBanned(String playerName) {
public boolean isBanned(String playerName) {
return repository.findByPlayerName(playerName.toLowerCase()).isPresent();
}
public void ban(String playerName) {
BannedUserEntity entity = new BannedUserEntity();
entity.setPlayerName(playerName);
repository.save(entity);
}
public void unban(String playerName) {
repository.deleteByPlayerName(playerName);
}
}