本文整理汇总了Java中net.minecraft.world.WorldServer.getChunkFromChunkCoords方法的典型用法代码示例。如果您正苦于以下问题:Java WorldServer.getChunkFromChunkCoords方法的具体用法?Java WorldServer.getChunkFromChunkCoords怎么用?Java WorldServer.getChunkFromChunkCoords使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.world.WorldServer
的用法示例。
在下文中一共展示了WorldServer.getChunkFromChunkCoords方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execute
import net.minecraft.world.WorldServer; //导入方法依赖的package包/类
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
if (args.length == 0 || args.length > 1) {
throw new WrongUsageException("<Owner>");
}
ForgePlayer forgePlayer = Universe.get().getPlayer(args[0]);
if (forgePlayer == null) {
throw new CommandException(String.format("There is no player called %s that has been on this server", args[0]));
}
ForgeTeam team = forgePlayer.getTeam();
if (team == null) {
throw new CommandException(String.format("Player %s is not in a team", forgePlayer.getName()));
}
Set<ClaimedChunk> teamClaimedChunks = ClaimedChunks.get().getTeamChunks(team);
if (teamClaimedChunks.isEmpty()) {
throw new CommandException(String.format("team %s has not claimed any chunks", team.getName()));
}
ArrayList<PlayerInChunk> playersInChunks = new ArrayList<PlayerInChunk>();
for (ClaimedChunk claimedChunk : teamClaimedChunks) {
ChunkDimPos dimPos = claimedChunk.getPos();
WorldServer world = FMLCommonHandler.instance().getMinecraftServerInstance().getWorld(dimPos.dim);
Chunk chunk = world.getChunkFromChunkCoords(dimPos.posX, dimPos.posZ);
ChunkListOfPlayers chunkListOfPlayers = AllChunks.getChunk(chunk);
if (chunkListOfPlayers == null) {
continue;
}
playersInChunks.addAll(chunkListOfPlayers.playersInChunk);
}
Collections.sort(playersInChunks, new PlayersInChunkListComparator());
for (PlayerInChunk player : playersInChunks) {
String playerName = server.getPlayerProfileCache().getProfileByUUID(player.getPlayer()).getName();
String enterTime = player.getEnterTimeCalendar().format(DateTimeFormatter.ofPattern("u/M/d H:m:s"));
if (player.hasLeft()) {
String leaveTime = player.getLeaveTimeCalendar().format(DateTimeFormatter.ofPattern("u/M/d H:m:s"));
Duration stayTime = player.getStayTime();
Long years = stayTime.toDays() / 365L;
Long months = stayTime.toDays() / 30L;
Long days = stayTime.toDays();
Long hours = stayTime.toHours();
Long minutes = stayTime.toMinutes();
Long seconds = stayTime.getSeconds();
if (months > 11) {
months = months - (years * 12);
}
if (days > 29) {
days = days - (days / 30 * 30);
}
if (hours > 23) {
hours = hours - (hours / 24 * 24);
}
if (minutes > 59) {
minutes = minutes - (minutes / 60 * 60);
}
if (seconds > 59) {
seconds = seconds - (seconds / 60 * 60);
}
sender.sendMessage(new TextComponentString(String.format("Player %s was in one of the chunks from %s to %s for %s years and %s months and %s days and %s hours and %s minutes and %s seconds.", playerName, enterTime, leaveTime, years, months, days, hours, minutes, seconds)));
} else {
sender.sendMessage(new TextComponentString(String.format("Player %s was in one of the chunks from %s and has not left yet", playerName, enterTime)));
}
}
}