crwdns38264:0crwdne38264:0

crwdns38265:0:javadoc:crwdnd38265:0:javadoc:crwdne38265:0

Tip

crwdns38266:0:doc:crwdne38266:0

crwdns38267:0crwdne38267:0

crwdns38268:0crwdne38268:0

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

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

crwdns38269:0:javadoc:crwdnd38269:0:javadoc:crwdnd38269:0:javadoc:crwdne38269: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();
        }
    }
}

crwdns38270:0crwdne38270:0

crwdns38271:0:javadoc:crwdnd38271:0:javadoc:crwdne38271: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();

crwdns38272:0crwdne38272:0

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

crwdns38273:0:javadoc:crwdnd38273:0:javadoc:crwdne38273:0

crwdns38274:0crwdne38274:0

crwdns38275:0:javadoc:crwdne38275:0

crwdns38276:0crwdne38276:0

crwdns38277:0:javadoc:crwdne38277:0

crwdns38278:0crwdne38278:0

crwdns38279:0crwdne38279: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);