本文整理汇总了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());
}
}
}
示例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();
}
}
}
示例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));
}
示例4: onPing
import org.bukkit.event.server.ServerListPingEvent; //导入方法依赖的package包/类
@EventHandler
public void onPing(ServerListPingEvent event) {
if (icon == null) {
return;
}
event.setServerIcon(icon);
}
示例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);
}
}
示例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) {}
}
}