crwdns121455:0crwdne121455:0

crwdns121457:0:javadoc:crwdnd121457:0:javadoc:crwdne121457:0

Tip

crwdns121459:0:doc:crwdne121459:0

crwdns121461:0crwdne121461:0

crwdns121463:0crwdne121463:0

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

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

crwdns121465:0:javadoc:crwdnd121465:0:javadoc:crwdnd121465:0:javadoc:crwdne121465: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();
        }
    }
}

crwdns121467:0crwdne121467:0

crwdns121469:0:javadoc:crwdnd121469:0:javadoc:crwdne121469: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();

crwdns121471:0crwdne121471:0

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

crwdns121473:0:javadoc:crwdnd121473:0:javadoc:crwdne121473:0

crwdns121475:0crwdne121475:0

crwdns121477:0:javadoc:crwdne121477:0

crwdns121479:0crwdne121479:0

crwdns121481:0:javadoc:crwdne121481:0

crwdns121483:0crwdne121483:0

crwdns121485:0crwdne121485: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);