crwdns32060:0crwdne32060:0

crwdns32061:0:javadoc:crwdnd32061:0:javadoc:crwdne32061:0

Tip

crwdns32062:0:doc:crwdne32062:0

crwdns32063:0crwdne32063:0

crwdns32064:0crwdne32064:0

import org.spongepowered.api.Sponge;
import org.spongepowered.api.service.ban.BanService;

BanService service = Sponge.getServiceManager().provide(BanService.class).get();

crwdns32065:0:javadoc:crwdnd32065:0:javadoc:crwdnd32065:0:javadoc:crwdne32065:0

import java.util.Optional;

import org.spongepowered.api.entity.living.player.User;
import org.spongepowered.api.text.Text;
import org.spongepowered.api.util.ban.Ban;

if (service.isBanned(user.getProfile())) {
    Optional<Ban.Profile> optionalBan = service.getBanFor(player.getProfile());
    if (optionalBan.isPresent()) {
        Ban.Profile profileBan = optionalBan.get();
        Optional<Text> optionalReason = profileBan.getReason();
        if (optionalReason.isPresent()) {
            Text banReason = optionalReason.get();
        }
    }
}

crwdns32066:0crwdne32066:0

crwdns32067:0:javadoc:crwdnd32067:0:javadoc:crwdne32067:0

import org.spongepowered.api.util.ban.BanTypes;

Ban ban = Ban.builder().type(BanTypes.PROFILE).profile(user.getProfile())
    .reason(Text.of("The Sponge Council has Spoken!")).build();

crwdns32068:0crwdne32068:0

Ban ban = Ban.builder().type(BanTypes.IP)
    .address(player.getConnection().getAddress().getAddress())
    .reason(Text.of("The Sponge Council has Spoken!")).build();

crwdns32069:0:javadoc:crwdnd32069:0:javadoc:crwdne32069:0

crwdns32070:0crwdne32070:0

crwdns32071:0:javadoc:crwdne32071:0

crwdns32072:0crwdne32072:0

crwdns32073:0:javadoc:crwdne32073:0

crwdns32074:0crwdne32074:0

crwdns32075:0crwdne32075:0

BanService service = Sponge.getServiceManager().provide(BanService.class).get();
Ban ban = Ban.builder().type(BanTypes.PROFILE).profile(user.getProfile())
    .reason(Text.of("The Sponge Council has Spoken!")).build();
service.addBan(ban);