本文整理汇总了Java中org.bukkit.Bukkit.getMaxPlayers方法的典型用法代码示例。如果您正苦于以下问题:Java Bukkit.getMaxPlayers方法的具体用法?Java Bukkit.getMaxPlayers怎么用?Java Bukkit.getMaxPlayers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.Bukkit
的用法示例。
在下文中一共展示了Bukkit.getMaxPlayers方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: Kraken
import org.bukkit.Bukkit; //导入方法依赖的package包/类
public Kraken() {
if (Bukkit.getMaxPlayers() < 60) {
throw new NumberFormatException("Player limit must be at least 60!");
}
instance = this;
new BukkitRunnable() {
@Override
public void run() {
for (Player player : Bukkit.getOnlinePlayers()) {
checkPlayer(player);
}
}
}.runTaskLaterAsynchronously(PracticePlugin.getInstance(), 4L);
Bukkit.getPluginManager().registerEvents(this, PracticePlugin.getInstance());
}
示例2: replace
import org.bukkit.Bukkit; //导入方法依赖的package包/类
public String replace(String text){
// most shitty way
String[] values = { p.getName(), p.getDisplayName(), GetTime(), Bukkit.getOnlinePlayers().size() + "", Bukkit.getMaxPlayers() + "",
p.getHealth() + "", p.getAddress().getAddress().toString(), Math.round(p.getLocation().getX()) + " " + Math.round(p.getLocation().getY()) + " " + Math.round(p.getLocation().getBlockZ()) };
int count = 0;
for(String text1 : placeholders){
text = text.replace(text1, values[count]);
count++;
}
return text;
}
示例3: parse
import org.bukkit.Bukkit; //导入方法依赖的package包/类
@Override
public @Nullable FreeForAllModule parse(MapModuleContext context, Logger logger, Document doc) throws InvalidXMLException {
Element elPlayers = doc.getRootElement().getChild("players");
if(context.hasModule(TeamModule.class)) {
if(elPlayers != null) throw new InvalidXMLException("Cannot combine <players> and <teams>", elPlayers);
return null;
} else {
int minPlayers = Config.minimumPlayers();
int maxPlayers = Bukkit.getMaxPlayers();
int maxOverfill = maxPlayers;
org.bukkit.scoreboard.Team.OptionStatus nameTagVisibility = org.bukkit.scoreboard.Team.OptionStatus.ALWAYS;
boolean colors = false;
if(elPlayers != null) {
minPlayers = XMLUtils.parseNumber(elPlayers.getAttribute("min"), Integer.class, minPlayers);
maxPlayers = XMLUtils.parseNumber(elPlayers.getAttribute("max"), Integer.class, maxPlayers);
maxOverfill = XMLUtils.parseNumber(elPlayers.getAttribute("max-overfill"), Integer.class, maxOverfill);
nameTagVisibility = XMLUtils.parseNameTagVisibility(elPlayers, "show-name-tags").optional(nameTagVisibility);
colors = XMLUtils.parseBoolean(elPlayers.getAttribute("colors"), colors);
}
if(minPlayers > maxPlayers) {
throw new InvalidXMLException("min players (" + minPlayers + ") cannot be greater than max players (" + maxPlayers + ")", elPlayers);
}
return new FreeForAllModule(new FreeForAllOptions(minPlayers, maxPlayers, maxOverfill, nameTagVisibility, colors));
}
}
示例4: checkLogin
import org.bukkit.Bukkit; //导入方法依赖的package包/类
private BiTuple<String, PlayerLoginEvent.Result> checkLogin( String name, UUID uuid ) {
if( Bukkit.getIPBans().contains( this.getIpAddress() ) ) {
return new BiTuple<>( "Your IP Address has been banned from the server", PlayerLoginEvent.Result.KICK_BANNED );
}
if( Bukkit.getOnlinePlayers().size() >= Bukkit.getMaxPlayers() ) {
return new BiTuple<>( "The server is full", PlayerLoginEvent.Result.KICK_FULL );
}
return new BiTuple<>( null, PlayerLoginEvent.Result.ALLOWED );
}
示例5: getMaxPlayers
import org.bukkit.Bukkit; //导入方法依赖的package包/类
@Override
protected int getMaxPlayers() {
return Bukkit.getMaxPlayers();
}
示例6: run
import org.bukkit.Bukkit; //导入方法依赖的package包/类
@Override
public void run() {
if (TIME % 20 == 0) {
Kit.load();
}
TOTAL_TIME += 1;
if (Bukkit.getOnlinePlayers().length > 1)
TIME -= 1;
if (TOTAL_TIME > 900 && Bukkit.getOnlinePlayers().length <= 3) {
Bukkit.shutdown();
}
if (Bukkit.getOnlinePlayers().length==Bukkit.getMaxPlayers() && TIME >= 15) {
TIME = 10;
}
if (TIME==0) {
boolean start = true;
for (Team team : Team.list) {
if (team.getMembers().size() <= 2) {
start = false;
break;
}
}
if (start) {
Bukkit.getScheduler().scheduleSyncDelayedTask(Walls.instance, new Runnable() {
@Override
public void run() {
Walls.prep();
}
});
}
else {
Chat.server("&cWe need 2 players per team in order to start the game!");
TIME = Config.getInt("pre-time");
return;
}
return;
}
if (TIME % 20 == 0 || TIME <= 10)
Chat.server("&eGame beginning in &4" + Chat.time(TIME) + "&e!");
}
示例7: execute
import org.bukkit.Bukkit; //导入方法依赖的package包/类
@Override
public boolean execute(CommandSender sender, String[] args) throws CommandException {
if (!(sender instanceof Player)) {
throw new CommandException("Only players can use this command!");
}
Player player = (Player) sender;
int online = Bukkit.getOnlinePlayers().size();
int max = Bukkit.getMaxPlayers();
try {
player.sendMessage(ChatColor.GOLD + "There are " + ChatColor.RED + online + ChatColor.GOLD + " players online out of " + ChatColor.RED + max + ChatColor.GOLD + " players!");
ArrayList<Player> p = new ArrayList<>();
p.addAll(Bukkit.getOnlinePlayers());
StringBuilder sb = new StringBuilder();
player.sendMessage(ChatColor.GOLD + "Online Players:");
for (int i = 0; i < p.size(); i++) {
if (RankManager.getRankId(p.get(i)) == 3) {//Admin
sb.append(ChatColor.translateAlternateColorCodes('&', RankManager.getRankPrefix(p.get(i)) + " " + ChatColor.WHITE + p.get(i).getName()));
sb.append(ChatColor.GOLD + ", ");
}
}
for (int i = 0; i < p.size(); i++) {
if (RankManager.getRankId(p.get(i)) == 8) {//Dev
sb.append(ChatColor.translateAlternateColorCodes('&', RankManager.getRankPrefix(p.get(i)) + " " + ChatColor.WHITE + p.get(i).getName()));
sb.append(ChatColor.GOLD + ", ");
}
}
for (int i = 0; i < p.size(); i++) {
if (RankManager.getRankId(p.get(i)) == 11) {//SrMod
sb.append(ChatColor.translateAlternateColorCodes('&', RankManager.getRankPrefix(p.get(i)) + " " + ChatColor.WHITE + p.get(i).getName()));
sb.append(ChatColor.GOLD + ", ");
}
}
for (int i = 0; i < p.size(); i++) {
if (RankManager.getRankId(p.get(i)) == 5) {//Mod
sb.append(ChatColor.translateAlternateColorCodes('&', RankManager.getRankPrefix(p.get(i)) + " " + ChatColor.WHITE + p.get(i).getName()));
sb.append(ChatColor.GOLD + ", ");
}
}
for (int i = 0; i < p.size(); i++) {
if (RankManager.getRankId(p.get(i)) == 10) {//JrMod
sb.append(ChatColor.translateAlternateColorCodes('&', RankManager.getRankPrefix(p.get(i)) + " " + ChatColor.WHITE + p.get(i).getName()));
sb.append(ChatColor.GOLD + ", ");
}
}
for (int i = 0; i < p.size(); i++) {
if (RankManager.getRankId(p.get(i)) == 4) {//Builder
sb.append(ChatColor.translateAlternateColorCodes('&', RankManager.getRankPrefix(p.get(i)) + " " + ChatColor.WHITE + p.get(i).getName()));
sb.append(ChatColor.GOLD + ", ");
}
}
for (int i = 0; i < p.size(); i++) {
if (RankManager.getRankId(p.get(i)) == 0) {//Default
sb.append(ChatColor.WHITE + p.get(i).getName());
sb.append(ChatColor.GOLD + ", ");
}
}
sb.deleteCharAt(sb.length() - 2);//Removes last comma
player.sendMessage(sb.toString());
} catch (SQLException e) {
e.printStackTrace();
}
return true;
}