Search in sources :

Example 16 with OfflinePlayer

use of org.bukkit.OfflinePlayer in project GameCore by Warvale.

the class Initialization method startGame.

public void startGame() {
    new Bosses().initBoss();
    List<Player> players = new ArrayList<>();
    List<Player> red = new ArrayList<>();
    List<Player> blue = new ArrayList<>();
    Main.getTeams().getBlueTeam().getPlayers().stream().filter(OfflinePlayer::isOnline).forEach(offlinePlayer -> {
        players.add(offlinePlayer.getPlayer());
        blue.add(offlinePlayer.getPlayer());
    });
    Main.getTeams().getRedTeam().getPlayers().stream().filter(OfflinePlayer::isOnline).forEach(offlinePlayer -> {
        players.add(offlinePlayer.getPlayer());
        red.add(offlinePlayer.getPlayer());
    });
    players.forEach(player -> {
        player.addPotionEffects(Arrays.asList(new PotionEffect(PotionEffectType.SLOW, 100000, 128, false), new PotionEffect(PotionEffectType.JUMP, 100000, 250, false)));
        String team = player.getScoreboard().getTeam(player.getName()).getName();
        player.sendMessage((String[]) Arrays.asList("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n", ChatUtils.divider, "You are on team " + (team.equals("blue") ? ChatUtils.blue + "blue!" : ChatUtils.red + "red!"), "\n", ChatUtils.gray + "Your goal is to destroy the other teams " + ChatUtils.yellow + "core" + ChatUtils.gray + " 20 times!", "The game is divided into " + ChatUtils.red + "5" + ChatUtils.gray + " stages!", ChatUtils.yellow + "1." + ChatUtils.gray + " During the first " + ChatUtils.red + "20" + ChatUtils.gray + " minutes of the game, your core is invulnerable!", ChatUtils.yellow + "2." + ChatUtils.gray + " At the end of the first stage, a boss spawns in the middle of the map!", ChatUtils.yellow + "3." + ChatUtils.gray + " After that, diamonds will start to appear at middle. Diamonds can be used to craft the strongest armor in the game!", ChatUtils.yellow + "4." + ChatUtils.yellow + " Siege mode!" + ChatUtils.gray + " During this stage of the game, core breaking is 2x as powerful1!", ChatUtils.yellow + "5." + ChatUtils.gray + " During the last stage of the game, cores will be broken instantly!", ChatUtils.divider).toArray());
        new StartTask(this.map).runTaskTimer(Main.get(), 0, 20);
    });
}
Also used : StartTask(net.warvale.core.tasks.StartTask) Player(org.bukkit.entity.Player) OfflinePlayer(org.bukkit.OfflinePlayer) PotionEffect(org.bukkit.potion.PotionEffect) ArrayList(java.util.ArrayList) Bosses(net.warvale.core.game.start.Bosses)

Example 17 with OfflinePlayer

use of org.bukkit.OfflinePlayer in project Bukkit by Bukkit.

the class WhitelistCommand method tabComplete.

@Override
public List<String> tabComplete(CommandSender sender, String alias, String[] args) {
    Validate.notNull(sender, "Sender cannot be null");
    Validate.notNull(args, "Arguments cannot be null");
    Validate.notNull(alias, "Alias cannot be null");
    if (args.length == 1) {
        return StringUtil.copyPartialMatches(args[0], WHITELIST_SUBCOMMANDS, new ArrayList<String>(WHITELIST_SUBCOMMANDS.size()));
    } else if (args.length == 2) {
        if (args[0].equalsIgnoreCase("add")) {
            List<String> completions = new ArrayList<String>();
            for (OfflinePlayer player : Bukkit.getOfflinePlayers()) {
                String name = player.getName();
                if (StringUtil.startsWithIgnoreCase(name, args[1]) && !player.isWhitelisted()) {
                    completions.add(name);
                }
            }
            return completions;
        } else if (args[0].equalsIgnoreCase("remove")) {
            List<String> completions = new ArrayList<String>();
            for (OfflinePlayer player : Bukkit.getWhitelistedPlayers()) {
                String name = player.getName();
                if (StringUtil.startsWithIgnoreCase(name, args[1])) {
                    completions.add(name);
                }
            }
            return completions;
        }
    }
    return ImmutableList.of();
}
Also used : ArrayList(java.util.ArrayList) OfflinePlayer(org.bukkit.OfflinePlayer) List(java.util.List) ImmutableList(com.google.common.collect.ImmutableList) ArrayList(java.util.ArrayList)

Example 18 with OfflinePlayer

use of org.bukkit.OfflinePlayer in project Bukkit by Bukkit.

the class PardonCommand method tabComplete.

@Override
public List<String> tabComplete(CommandSender sender, String alias, String[] args) throws IllegalArgumentException {
    Validate.notNull(sender, "Sender cannot be null");
    Validate.notNull(args, "Arguments cannot be null");
    Validate.notNull(alias, "Alias cannot be null");
    if (args.length == 1) {
        List<String> completions = new ArrayList<String>();
        for (OfflinePlayer player : Bukkit.getBannedPlayers()) {
            String name = player.getName();
            if (StringUtil.startsWithIgnoreCase(name, args[0])) {
                completions.add(name);
            }
        }
        return completions;
    }
    return ImmutableList.of();
}
Also used : ArrayList(java.util.ArrayList) OfflinePlayer(org.bukkit.OfflinePlayer)

Example 19 with OfflinePlayer

use of org.bukkit.OfflinePlayer in project Bukkit by Bukkit.

the class ScoreboardCommand method offlinePlayerSetToString.

private static String offlinePlayerSetToString(Set<OfflinePlayer> set) {
    StringBuilder string = new StringBuilder();
    String lastValue = null;
    for (OfflinePlayer value : set) {
        string.append(lastValue = value.getName()).append(", ");
    }
    string.delete(string.length() - 2, Integer.MAX_VALUE);
    if (string.length() != lastValue.length()) {
        string.insert(string.length() - lastValue.length(), "and ");
    }
    return string.toString();
}
Also used : OfflinePlayer(org.bukkit.OfflinePlayer)

Example 20 with OfflinePlayer

use of org.bukkit.OfflinePlayer in project Denizen-For-Bukkit by DenizenScript.

the class PermissionCommand method execute.

@Override
public void execute(ScriptEntry scriptEntry) throws CommandExecutionException {
    Element action = scriptEntry.getElement("action");
    Element permission = scriptEntry.getElement("permission");
    Element group = scriptEntry.getElement("group");
    dWorld world = (dWorld) scriptEntry.getObject("world");
    // Report to dB
    dB.report(scriptEntry, getName(), action.debug() + permission.debug() + (group != null ? group.debug() : "") + (world != null ? world.debug() : ""));
    World bukkitWorld = null;
    if (world != null) {
        bukkitWorld = world.getWorld();
    }
    OfflinePlayer player = ((BukkitScriptEntryData) scriptEntry.entryData).hasPlayer() ? ((BukkitScriptEntryData) scriptEntry.entryData).getPlayer().getOfflinePlayer() : null;
    switch(Action.valueOf(action.asString().toUpperCase())) {
        case ADD:
            if (group != null) {
                if (Depends.permissions.groupHas(bukkitWorld, group.asString(), permission.asString())) {
                    dB.echoDebug(scriptEntry, "Group " + group + " already has permission " + permission);
                } else {
                    Depends.permissions.groupAdd(bukkitWorld, group.asString(), permission.asString());
                }
            } else {
                if (Depends.permissions.playerHas(bukkitWorld == null ? null : bukkitWorld.getName(), player, permission.asString())) {
                    dB.echoDebug(scriptEntry, "Player " + player.getName() + " already has permission " + permission);
                } else {
                    Depends.permissions.playerAdd(bukkitWorld == null ? null : bukkitWorld.getName(), player, permission.asString());
                }
            }
            return;
        case REMOVE:
            if (group != null) {
                if (!Depends.permissions.groupHas(bukkitWorld, group.asString(), permission.asString())) {
                    dB.echoDebug(scriptEntry, "Group " + group + " does not have access to permission " + permission);
                } else {
                    Depends.permissions.groupRemove(bukkitWorld, group.asString(), permission.asString());
                }
            } else {
                if (!Depends.permissions.playerHas(bukkitWorld == null ? null : bukkitWorld.getName(), player, permission.asString())) {
                    dB.echoDebug(scriptEntry, "Player " + player.getName() + " does not have access to permission " + permission);
                } else {
                    Depends.permissions.playerRemove(bukkitWorld == null ? null : bukkitWorld.getName(), player, permission.asString());
                }
            }
            return;
    }
}
Also used : BukkitScriptEntryData(net.aufdemrand.denizen.BukkitScriptEntryData) Element(net.aufdemrand.denizencore.objects.Element) OfflinePlayer(org.bukkit.OfflinePlayer) net.aufdemrand.denizen.objects.dWorld(net.aufdemrand.denizen.objects.dWorld) World(org.bukkit.World) net.aufdemrand.denizen.objects.dWorld(net.aufdemrand.denizen.objects.dWorld)

Aggregations

OfflinePlayer (org.bukkit.OfflinePlayer)52 Player (org.bukkit.entity.Player)19 JobsPlayer (com.gamingmesh.jobs.container.JobsPlayer)10 Job (com.gamingmesh.jobs.container.Job)8 InvocationTargetException (java.lang.reflect.InvocationTargetException)8 File (java.io.File)5 ArrayList (java.util.ArrayList)5 Test (org.junit.Test)5 HashSet (java.util.HashSet)4 World (org.bukkit.World)4 CommandSender (org.bukkit.command.CommandSender)4 Matchers.containsString (org.hamcrest.Matchers.containsString)4 JobProgression (com.gamingmesh.jobs.container.JobProgression)2 IOException (java.io.IOException)2 UUID (java.util.UUID)2 net.aufdemrand.denizen.objects.dWorld (net.aufdemrand.denizen.objects.dWorld)2 Element (net.aufdemrand.denizencore.objects.Element)2 GlowOfflinePlayer (net.glowstone.GlowOfflinePlayer)2 User (com.earth2me.essentials.User)1 ImmutableList (com.google.common.collect.ImmutableList)1