Java Code Examples for org.bukkit.Bukkit#hasWhitelist()

The following examples show how to use org.bukkit.Bukkit#hasWhitelist() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractNetwork.java    From helper with MIT License 6 votes vote down vote up
private StatusMessage produceStatusMessage() {
    StatusMessage msg = new StatusMessage();
    msg.time = System.currentTimeMillis();
    msg.id = this.instanceData.getId();
    msg.groups = new ArrayList<>(this.instanceData.getGroups());

    msg.players = new HashMap<>();
    Players.forEach(p -> msg.players.put(p.getUniqueId(), p.getName()));

    msg.maxPlayers = Bukkit.getMaxPlayers();
    msg.whitelisted = Bukkit.hasWhitelist();

    // collect server metadata
    msg.metadata = new HashMap<>();
    for (ServerMetadataProvider metadataProvider : this.metadataProviders) {
        try {
            for (ServerMetadata metadata : metadataProvider.provide()) {
                msg.metadata.put(metadata.key(), metadata.data());
            }
        } catch (Exception e) {
            new RuntimeException("Exception calling ServerMetadataProvider " + metadataProvider, e).printStackTrace();
        }
    }

    return msg;
}
 
Example 2
Source File: PlayerLogin.java    From FunnyGuilds with Apache License 2.0 5 votes vote down vote up
@EventHandler
public void onLogin(PlayerLoginEvent event) {
    if (Bukkit.hasWhitelist()) {
        return;
    }
    
    String name = event.getPlayer().getName();
    if (name.length() < 2) {
        event.disallow(Result.KICK_OTHER, ChatUtils.colored("&cNick jest za krotki!"));
    }
    
    if (name.length() > 16) {
        event.disallow(Result.KICK_OTHER, ChatUtils.colored("&cNick jest za dlugi!"));
    }
    
    if (!name.matches(GuildRegex.LETTERS_DIGITS_UNDERSCORE.getPattern())) {
        event.disallow(Result.KICK_OTHER, ChatUtils.colored("&cNick zawiera niedozwolone znaki!"));
    }

    User user = User.get(event.getPlayer());

    if (user == null) {
        return;
    }

    BanUtils.checkIfBanShouldExpire(user);

    if (!user.isBanned()) {
        return;
    }
    
    event.disallow(Result.KICK_BANNED, BanUtils.getBanMessage(user));
}