當前位置: 首頁>>代碼示例>>Java>>正文


Java ServerListPingEvent.setServerIcon方法代碼示例

本文整理匯總了Java中org.bukkit.event.server.ServerListPingEvent.setServerIcon方法的典型用法代碼示例。如果您正苦於以下問題:Java ServerListPingEvent.setServerIcon方法的具體用法?Java ServerListPingEvent.setServerIcon怎麽用?Java ServerListPingEvent.setServerIcon使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.bukkit.event.server.ServerListPingEvent的用法示例。


在下文中一共展示了ServerListPingEvent.setServerIcon方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onMotd

import org.bukkit.event.server.ServerListPingEvent; //導入方法依賴的package包/類
@EventHandler(ignoreCancelled = true)
public void onMotd(ServerListPingEvent event) {
    MotdProvider provider = service.getProvider();
    if (provider != null && provider.isEnabled()) {
        String motd = provider.provideMotd();
        if (motd != null) {
            event.setMotd(motd);
        }

        MotdServerIcon serverIcon = provider.provideServerIcon();
        if (serverIcon != null) {
            event.setServerIcon(BukkitMotdServerIcon.wrap(serverIcon)
                    .toCachedServerIcon());
        }
    }
}
 
開發者ID:andylizi,項目名稱:ColorMOTD,代碼行數:17,代碼來源:MotdListener.java

示例2: onServerListPing

import org.bukkit.event.server.ServerListPingEvent; //導入方法依賴的package包/類
@EventHandler
public void onServerListPing(ServerListPingEvent event) {
    UUID uuid = getDatabaseManager().getPlayerUUID(event.getAddress().getHostAddress());
    if (uuid != null) {
        OfflinePlayer player = Bukkit.getOfflinePlayer(uuid);
        try {
            event.setServerIcon(Bukkit.loadServerIcon(getImageHandler().getImageForUser(player.getUniqueId(), player.getName())));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
 
開發者ID:me4502,項目名稱:AdvancedServerListIcons,代碼行數:13,代碼來源:AdvancedServerListIconsSpigot.java

示例3: onPing

import org.bukkit.event.server.ServerListPingEvent; //導入方法依賴的package包/類
@EventHandler @SneakyThrows // Sets the server icon to special party icons.
public void onPing(ServerListPingEvent evt) {
    if (!isPartyTime())
        return;
    File f = new File("./icons/" + getParty().getName() + ".png");
    if (f.exists())
        evt.setServerIcon(Bukkit.loadServerIcon(f));
}
 
開發者ID:Kneesnap,項目名稱:Kineticraft,代碼行數:9,代碼來源:Parties.java

示例4: onPing

import org.bukkit.event.server.ServerListPingEvent; //導入方法依賴的package包/類
@EventHandler
public void onPing(ServerListPingEvent event) {
    if (icon == null) {
        return;
    }
    event.setServerIcon(icon);
}
 
開發者ID:niwaniwa,項目名稱:WhiteEggCore,代碼行數:8,代碼來源:Debug.java

示例5: onServerListPing

import org.bukkit.event.server.ServerListPingEvent; //導入方法依賴的package包/類
@EventHandler
public void onServerListPing(ServerListPingEvent event) {
	event.setMaxPlayers(1);
	
	Iterator<Player> players = event.iterator();
	
	Player player;
	while(players.hasNext()) {
		player = players.next();
		if(plugin.activePlayer == null || !plugin.activePlayer.player.getUniqueId().equals(player.getUniqueId())) { 
			players.remove();
		}
	}
	
	if(plugin.activePlayer != null) {
		long waitleft = (plugin.activePlayer.timeleft - (new Date().getTime()/1000 - plugin.activePlayer.joinedAt)) * 1000;
		Date date = new Date(waitleft);
		String timestring = minutesWait.format(date);
		
		event.setMotd("A player is currently playing. Please wait " + timestring + " more minutes.");
		event.setServerIcon(iconFull);
	}
	else {
		event.setMotd("Nobody is playing. You can join the server.");
		event.setServerIcon(iconEmpty);
	}
}
 
開發者ID:freundTech,項目名稱:OneSlotServer,代碼行數:28,代碼來源:PlayerListener.java

示例6: onServerListPing

import org.bukkit.event.server.ServerListPingEvent; //導入方法依賴的package包/類
@EventHandler
public void onServerListPing(final ServerListPingEvent event) {
    if (bukkit.getCore() == null) return; // Too early, we haven't finished initializing yet
    StatusResponse response = bukkit.getCore().createRequest(event.getAddress()).createResponse(
            bukkit.getCore().getStatus(), new ResponseFetcher() {
                @Override
                public Integer getOnlinePlayers() {
                    return event.getNumPlayers();
                }

                @Override
                public Integer getMaxPlayers() {
                    return event.getMaxPlayers();
                }

                @Override
                public int getProtocolVersion() {
                    return -1;
                }
            });

    // Description
    String message = response.getDescription();
    if (message != null)
        event.setMotd(message);

    // Max players
    Integer max = response.getMaxPlayers();
    if (max != null)
        event.setMaxPlayers(max);

    // Favicon
    FaviconSource favicon = response.getFavicon();
    if (favicon != null) {
        CachedServerIcon icon = bukkit.getFavicon(favicon);
        if (icon != null)
            try {
                event.setServerIcon(icon);
            } catch (UnsupportedOperationException ignored) {}
    }
}
 
開發者ID:Minecrell,項目名稱:ServerListPlus,代碼行數:42,代碼來源:BukkitEventHandler.java


注:本文中的org.bukkit.event.server.ServerListPingEvent.setServerIcon方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。