本文整理匯總了Java中net.minecraft.server.MinecraftServer.isServerInOnlineMode方法的典型用法代碼示例。如果您正苦於以下問題:Java MinecraftServer.isServerInOnlineMode方法的具體用法?Java MinecraftServer.isServerInOnlineMode怎麽用?Java MinecraftServer.isServerInOnlineMode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類net.minecraft.server.MinecraftServer
的用法示例。
在下文中一共展示了MinecraftServer.isServerInOnlineMode方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: lookupNames
import net.minecraft.server.MinecraftServer; //導入方法依賴的package包/類
private static void lookupNames(MinecraftServer server, Collection<String> names, ProfileLookupCallback callback)
{
String[] astring = (String[])Iterators.toArray(Iterators.filter(names.iterator(), new Predicate<String>()
{
public boolean apply(String p_apply_1_)
{
return !StringUtils.isNullOrEmpty(p_apply_1_);
}
}), String.class);
if (server.isServerInOnlineMode())
{
server.getGameProfileRepository().findProfilesByNames(astring, Agent.MINECRAFT, callback);
}
else
{
for (String s : astring)
{
UUID uuid = EntityPlayer.getUUID(new GameProfile((UUID)null, s));
GameProfile gameprofile = new GameProfile(uuid, s);
callback.onProfileLookupSucceeded(gameprofile);
}
}
}
示例2: getGameProfile
import net.minecraft.server.MinecraftServer; //導入方法依賴的package包/類
/**
* Get a GameProfile given the MinecraftServer and the player's username.
* The UUID of the GameProfile will <b>not</b> be null. If the server is offline, a UUID based on the hash of the
* username will be used.
*/
private static GameProfile getGameProfile(MinecraftServer server, String username)
{
final GameProfile[] agameprofile = new GameProfile[1];
ProfileLookupCallback profilelookupcallback = new ProfileLookupCallback()
{
public void onProfileLookupSucceeded(GameProfile p_onProfileLookupSucceeded_1_)
{
agameprofile[0] = p_onProfileLookupSucceeded_1_;
}
public void onProfileLookupFailed(GameProfile p_onProfileLookupFailed_1_, Exception p_onProfileLookupFailed_2_)
{
agameprofile[0] = null;
}
};
server.getGameProfileRepository().findProfilesByNames(new String[] {username}, Agent.MINECRAFT, profilelookupcallback);
if (!server.isServerInOnlineMode() && agameprofile[0] == null)
{
UUID uuid = EntityPlayer.getUUID(new GameProfile((UUID)null, username));
GameProfile gameprofile = new GameProfile(uuid, username);
profilelookupcallback.onProfileLookupSucceeded(gameprofile);
}
return agameprofile[0];
}
示例3: lookupNames
import net.minecraft.server.MinecraftServer; //導入方法依賴的package包/類
private static void lookupNames(MinecraftServer server, Collection<String> names, ProfileLookupCallback callback)
{
String[] astring = (String[])Iterators.toArray(Iterators.filter(names.iterator(), new Predicate<String>()
{
public boolean apply(@Nullable String p_apply_1_)
{
return !StringUtils.isNullOrEmpty(p_apply_1_);
}
}), String.class);
if (server.isServerInOnlineMode())
{
server.getGameProfileRepository().findProfilesByNames(astring, Agent.MINECRAFT, callback);
}
else
{
for (String s : astring)
{
UUID uuid = EntityPlayer.getUUID(new GameProfile((UUID)null, s));
GameProfile gameprofile = new GameProfile(uuid, s);
callback.onProfileLookupSucceeded(gameprofile);
}
}
}
示例4: getStringUUIDFromName
import net.minecraft.server.MinecraftServer; //導入方法依賴的package包/類
public static String getStringUUIDFromName(String p_152719_0_)
{
if (!StringUtils.isNullOrEmpty(p_152719_0_) && p_152719_0_.length() <= 16)
{
final MinecraftServer minecraftserver = MinecraftServer.getServer();
GameProfile gameprofile = minecraftserver.getPlayerProfileCache().getGameProfileForUsername(p_152719_0_);
if (gameprofile != null && gameprofile.getId() != null)
{
return gameprofile.getId().toString();
}
else if (!minecraftserver.isSinglePlayer() && minecraftserver.isServerInOnlineMode())
{
final List<GameProfile> list = Lists.<GameProfile>newArrayList();
ProfileLookupCallback profilelookupcallback = new ProfileLookupCallback()
{
public void onProfileLookupSucceeded(GameProfile p_onProfileLookupSucceeded_1_)
{
minecraftserver.getPlayerProfileCache().addEntry(p_onProfileLookupSucceeded_1_);
list.add(p_onProfileLookupSucceeded_1_);
}
public void onProfileLookupFailed(GameProfile p_onProfileLookupFailed_1_, Exception p_onProfileLookupFailed_2_)
{
PreYggdrasilConverter.LOGGER.warn((String)("Could not lookup user whitelist entry for " + p_onProfileLookupFailed_1_.getName()), (Throwable)p_onProfileLookupFailed_2_);
}
};
lookupNames(minecraftserver, Lists.newArrayList(new String[] {p_152719_0_}), profilelookupcallback);
return list.size() > 0 && ((GameProfile)list.get(0)).getId() != null ? ((GameProfile)list.get(0)).getId().toString() : "";
}
else
{
return EntityPlayer.getUUID(new GameProfile((UUID)null, p_152719_0_)).toString();
}
}
else
{
return p_152719_0_;
}
}
示例5: convertMobOwnerIfNeeded
import net.minecraft.server.MinecraftServer; //導入方法依賴的package包/類
public static String convertMobOwnerIfNeeded(final MinecraftServer server, String username)
{
if (!StringUtils.isNullOrEmpty(username) && username.length() <= 16)
{
GameProfile gameprofile = server.getPlayerProfileCache().getGameProfileForUsername(username);
if (gameprofile != null && gameprofile.getId() != null)
{
return gameprofile.getId().toString();
}
else if (!server.isSinglePlayer() && server.isServerInOnlineMode())
{
final List<GameProfile> list = Lists.<GameProfile>newArrayList();
ProfileLookupCallback profilelookupcallback = new ProfileLookupCallback()
{
public void onProfileLookupSucceeded(GameProfile p_onProfileLookupSucceeded_1_)
{
server.getPlayerProfileCache().addEntry(p_onProfileLookupSucceeded_1_);
list.add(p_onProfileLookupSucceeded_1_);
}
public void onProfileLookupFailed(GameProfile p_onProfileLookupFailed_1_, Exception p_onProfileLookupFailed_2_)
{
PreYggdrasilConverter.LOGGER.warn("Could not lookup user whitelist entry for {}", new Object[] {p_onProfileLookupFailed_1_.getName(), p_onProfileLookupFailed_2_});
}
};
lookupNames(server, Lists.newArrayList(new String[] {username}), profilelookupcallback);
return !list.isEmpty() && ((GameProfile)list.get(0)).getId() != null ? ((GameProfile)list.get(0)).getId().toString() : "";
}
else
{
return EntityPlayer.getUUID(new GameProfile((UUID)null, username)).toString();
}
}
else
{
return username;
}
}