001package net.minecraft.server.integrated; 002 003import cpw.mods.fml.relauncher.Side; 004import cpw.mods.fml.relauncher.SideOnly; 005import java.net.SocketAddress; 006import net.minecraft.entity.player.EntityPlayerMP; 007import net.minecraft.nbt.NBTTagCompound; 008import net.minecraft.server.MinecraftServer; 009import net.minecraft.server.management.ServerConfigurationManager; 010 011@SideOnly(Side.CLIENT) 012public class IntegratedPlayerList extends ServerConfigurationManager 013{ 014 /** 015 * Holds the NBT data for the host player's save file, so this can be written to level.dat. 016 */ 017 private NBTTagCompound hostPlayerData = null; 018 019 public IntegratedPlayerList(IntegratedServer par1IntegratedServer) 020 { 021 super(par1IntegratedServer); 022 this.viewDistance = 10; 023 } 024 025 /** 026 * also stores the NBTTags if this is an intergratedPlayerList 027 */ 028 protected void writePlayerData(EntityPlayerMP par1EntityPlayerMP) 029 { 030 if (par1EntityPlayerMP.getCommandSenderName().equals(this.getIntegratedServer().getServerOwner())) 031 { 032 this.hostPlayerData = new NBTTagCompound(); 033 par1EntityPlayerMP.writeToNBT(this.hostPlayerData); 034 } 035 036 super.writePlayerData(par1EntityPlayerMP); 037 } 038 039 /** 040 * checks ban-lists, then white-lists, then space for the server. Returns null on success, or an error message 041 */ 042 public String allowUserToConnect(SocketAddress par1SocketAddress, String par2Str) 043 { 044 return par2Str.equalsIgnoreCase(this.getIntegratedServer().getServerOwner()) ? "That name is already taken." : super.allowUserToConnect(par1SocketAddress, par2Str); 045 } 046 047 /** 048 * get the associated Integrated Server 049 */ 050 public IntegratedServer getIntegratedServer() 051 { 052 return (IntegratedServer)super.getServerInstance(); 053 } 054 055 /** 056 * On integrated servers, returns the host's player data to be written to level.dat. 057 */ 058 public NBTTagCompound getHostPlayerData() 059 { 060 return this.hostPlayerData; 061 } 062 063 public MinecraftServer getServerInstance() 064 { 065 return this.getIntegratedServer(); 066 } 067}