本文整理匯總了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;
}