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);
});
}
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();
}
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();
}
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();
}
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;
}
}
Aggregations