ban/unban process
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user