crwdns18409:0crwdne18409:0

crwdns42078:0:javadoc:crwdnd42078:0:javadoc:crwdne42078:0

Tip

crwdns18411:0:doc:crwdne18411:0

crwdns18412:0crwdne18412:0

crwdns42079:0crwdne42079:0

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

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

crwdns18414:0:javadoc:crwdnd18414:0:javadoc:crwdnd18414:0:javadoc:crwdne18414: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();
        }
    }
}

crwdns18415:0crwdne18415:0

crwdns18416:0:javadoc:crwdnd18416:0:javadoc:crwdne18416: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();

crwdns18417:0crwdne18417:0

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

crwdns18418:0:javadoc:crwdnd18418:0:javadoc:crwdne18418:0

crwdns18419:0crwdne18419:0

crwdns18420:0:javadoc:crwdne18420:0

crwdns18421:0crwdne18421:0

crwdns18422:0:javadoc:crwdne18422:0

crwdns18423:0crwdne18423:0

crwdns18424:0crwdne18424: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);