crwdns131975:0crwdne131975:0

crwdns131977:0:javadoc:crwdnd131977:0:javadoc:crwdne131977:0

Tip

crwdns131979:0:doc:crwdne131979:0

crwdns131981:0crwdne131981:0

crwdns131983:0crwdne131983:0

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

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

crwdns131985:0:javadoc:crwdnd131985:0:javadoc:crwdnd131985:0:javadoc:crwdne131985: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();
        }
    }
}

crwdns131987:0crwdne131987:0

crwdns131989:0:javadoc:crwdnd131989:0:javadoc:crwdne131989: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();

crwdns131991:0crwdne131991:0

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

crwdns131993:0:javadoc:crwdnd131993:0:javadoc:crwdne131993:0

crwdns131995:0crwdne131995:0

crwdns131997:0:javadoc:crwdne131997:0

crwdns131999:0crwdne131999:0

crwdns132001:0:javadoc:crwdne132001:0

crwdns132003:0crwdne132003:0

crwdns132005:0crwdne132005: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);