crwdns151169:0crwdne151169:0

crwdns151171:0:javadoc:crwdnd151171:0:javadoc:crwdne151171:0

Tip

crwdns151173:0:doc:crwdne151173:0

crwdns151175:0crwdne151175:0

crwdns151177:0crwdne151177:0

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

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

crwdns151179:0:javadoc:crwdnd151179:0:javadoc:crwdnd151179:0:javadoc:crwdne151179: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();
        }
    }
}

crwdns151181:0crwdne151181:0

crwdns151183:0:javadoc:crwdnd151183:0:javadoc:crwdne151183: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();

crwdns151185:0crwdne151185:0

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

crwdns151187:0:javadoc:crwdnd151187:0:javadoc:crwdne151187:0

crwdns151189:0crwdne151189:0

crwdns151191:0:javadoc:crwdne151191:0

crwdns151193:0crwdne151193:0

crwdns151195:0:javadoc:crwdne151195:0

crwdns151197:0crwdne151197:0

crwdns151199:0crwdne151199: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);