crwdns140905:0crwdne140905:0

crwdns140909:0:javadoc:crwdnd140909:0:javadoc:crwdne140909:0

Tip

crwdns140911:0:doc:crwdne140911:0

crwdns140913:0crwdne140913:0

crwdns140915:0crwdne140915:0

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

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

crwdns140917:0:javadoc:crwdnd140917:0:javadoc:crwdnd140917:0:javadoc:crwdne140917:0

import java.util.Optional;

import net.kyori.adventure.text.Component;
import org.spongepowered.api.entity.living.player.User;
import org.spongepowered.api.util.ban.Ban;

if (service.isBanned(user.getProfile())) {
    CompletableFuture<Optional<Ban.Profile>> optionalBanFuture = service.find(player.getProfile());
    optionalBanFuture.thenAccept(optionalBan -> {
        if (optionalBan.isPresent()) {
            Ban.Profile profileBan = optionalBan.get();
            Optional<Component> optionalReason = profileBan.getReason();
            if (optionalReason.isPresent()) {
                Component banReason = optionalReason.get();
            }
        }
    });
}

crwdns140919:0crwdne140919:0

crwdns140921:0:javadoc:crwdnd140921:0:javadoc:crwdne140921:0

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

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

crwdns140923:0crwdne140923:0

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

crwdns140925:0:javadoc:crwdnd140925:0:javadoc:crwdne140925:0

crwdns140927:0crwdne140927:0

crwdns140929:0:javadoc:crwdne140929:0

crwdns140931:0crwdne140931:0

crwdns140933:0:javadoc:crwdne140933:0

crwdns140935:0crwdne140935:0

crwdns140937:0crwdne140937:0

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