2013-12-27 23:59:59 +01:00
|
|
|
package appeng.core;
|
|
|
|
|
2014-08-30 04:39:36 +02:00
|
|
|
import io.netty.util.concurrent.GenericFutureListener;
|
|
|
|
|
2013-12-27 23:59:59 +01:00
|
|
|
import java.io.File;
|
2014-08-07 08:47:42 +02:00
|
|
|
import java.io.FileInputStream;
|
|
|
|
import java.io.FileOutputStream;
|
2014-03-05 08:27:42 +01:00
|
|
|
import java.io.IOException;
|
2013-12-27 23:59:59 +01:00
|
|
|
import java.lang.ref.WeakReference;
|
2014-03-05 08:27:42 +01:00
|
|
|
import java.util.ArrayList;
|
2014-08-07 08:47:42 +02:00
|
|
|
import java.util.Collection;
|
2014-09-14 07:02:02 +02:00
|
|
|
import java.util.HashMap;
|
2014-08-07 08:47:42 +02:00
|
|
|
import java.util.LinkedList;
|
2014-03-05 08:27:42 +01:00
|
|
|
import java.util.List;
|
2014-09-14 07:02:02 +02:00
|
|
|
import java.util.Map.Entry;
|
|
|
|
import java.util.UUID;
|
2013-12-27 23:59:59 +01:00
|
|
|
import java.util.WeakHashMap;
|
|
|
|
|
2014-09-14 07:02:02 +02:00
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
2014-03-05 08:27:42 +01:00
|
|
|
import net.minecraft.entity.player.EntityPlayerMP;
|
2014-08-07 08:47:42 +02:00
|
|
|
import net.minecraft.nbt.CompressedStreamTools;
|
|
|
|
import net.minecraft.nbt.NBTTagCompound;
|
2014-08-30 04:39:36 +02:00
|
|
|
import net.minecraft.network.NetworkManager;
|
2013-12-27 23:59:59 +01:00
|
|
|
import net.minecraftforge.common.DimensionManager;
|
2014-02-09 02:34:52 +01:00
|
|
|
import net.minecraftforge.common.config.ConfigCategory;
|
2014-02-09 06:08:27 +01:00
|
|
|
import net.minecraftforge.common.config.Configuration;
|
2014-02-09 02:34:52 +01:00
|
|
|
import net.minecraftforge.common.config.Property;
|
2013-12-27 23:59:59 +01:00
|
|
|
import appeng.api.util.WorldCoord;
|
2014-03-05 08:27:42 +01:00
|
|
|
import appeng.core.sync.network.NetworkHandler;
|
|
|
|
import appeng.core.sync.packets.PacketNewStorageDimension;
|
2014-07-21 05:45:08 +02:00
|
|
|
import appeng.hooks.TickHandler;
|
|
|
|
import appeng.hooks.TickHandler.PlayerColor;
|
2013-12-27 23:59:59 +01:00
|
|
|
import appeng.me.GridStorage;
|
|
|
|
import appeng.me.GridStorageSearch;
|
2014-03-02 09:35:11 +01:00
|
|
|
import appeng.services.CompassService;
|
2013-12-27 23:59:59 +01:00
|
|
|
|
2014-07-10 05:18:50 +02:00
|
|
|
import com.mojang.authlib.GameProfile;
|
|
|
|
|
2013-12-27 23:59:59 +01:00
|
|
|
public class WorldSettings extends Configuration
|
|
|
|
{
|
|
|
|
|
|
|
|
private static WorldSettings instance;
|
|
|
|
|
|
|
|
long lastGridStorage = 0;
|
2014-01-27 05:00:36 +01:00
|
|
|
int lastPlayer = 0;
|
2013-12-27 23:59:59 +01:00
|
|
|
|
2014-03-02 09:35:11 +01:00
|
|
|
private CompassService compass;
|
|
|
|
|
|
|
|
File AEFolder;
|
|
|
|
|
2014-09-14 07:02:02 +02:00
|
|
|
public WorldSettings(File aeFolder)
|
|
|
|
{
|
2014-03-02 09:35:11 +01:00
|
|
|
super( new File( aeFolder.getPath() + File.separatorChar + "settings.cfg" ) );
|
|
|
|
AEFolder = aeFolder;
|
|
|
|
|
|
|
|
compass = new CompassService( AEFolder );
|
|
|
|
|
2014-03-07 04:02:15 +01:00
|
|
|
for (int dimID : get( "DimensionManager", "StorageCells", new int[0] ).getIntList())
|
|
|
|
{
|
|
|
|
storageCellDims.add( dimID );
|
|
|
|
DimensionManager.registerDimension( dimID, AEConfig.instance.storageProviderID );
|
|
|
|
}
|
|
|
|
|
2013-12-27 23:59:59 +01:00
|
|
|
try
|
|
|
|
{
|
|
|
|
lastGridStorage = Long.parseLong( get( "Counters", "lastGridStorage", 0 ).getString() );
|
2014-01-27 05:00:36 +01:00
|
|
|
lastPlayer = get( "Counters", "lastPlayer", 0 ).getInt();
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
catch (NumberFormatException err)
|
|
|
|
{
|
|
|
|
lastGridStorage = 0;
|
2014-01-27 05:00:36 +01:00
|
|
|
lastPlayer = 0;
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-08-07 08:47:42 +02:00
|
|
|
NBTTagCompound loadSpawnData(int dim, int chunkX, int chunkZ)
|
|
|
|
{
|
|
|
|
if ( !Thread.holdsLock( WorldSettings.class ) )
|
|
|
|
throw new RuntimeException( "Invalid Request" );
|
|
|
|
|
|
|
|
File f = new File( AEFolder, "spawndata" + File.separatorChar + dim + "_" + (chunkX >> 4) + "_" + (chunkZ >> 4) + ".dat" );
|
|
|
|
|
|
|
|
if ( f.isFile() && f.exists() )
|
|
|
|
{
|
|
|
|
// open
|
|
|
|
FileInputStream fis;
|
|
|
|
try
|
|
|
|
{
|
|
|
|
fis = new FileInputStream( f );
|
|
|
|
|
2014-08-15 19:15:24 +02:00
|
|
|
NBTTagCompound data = null;
|
2014-08-24 00:55:55 +02:00
|
|
|
|
2014-08-15 19:15:24 +02:00
|
|
|
try
|
|
|
|
{
|
|
|
|
data = CompressedStreamTools.readCompressed( fis );
|
|
|
|
}
|
|
|
|
catch (Throwable e)
|
|
|
|
{
|
|
|
|
data = new NBTTagCompound();
|
|
|
|
AELog.error( e );
|
|
|
|
}
|
2014-08-24 00:55:55 +02:00
|
|
|
|
2014-08-15 19:15:24 +02:00
|
|
|
fis.close();
|
2014-08-24 00:55:55 +02:00
|
|
|
|
2014-08-07 08:47:42 +02:00
|
|
|
return data;
|
|
|
|
}
|
|
|
|
catch (Throwable e)
|
|
|
|
{
|
2014-08-15 19:15:24 +02:00
|
|
|
AELog.error( e );
|
2014-08-07 08:47:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return new NBTTagCompound();
|
|
|
|
}
|
|
|
|
|
|
|
|
void writeSpawnData(int dim, int chunkX, int chunkZ, NBTTagCompound data)
|
|
|
|
{
|
|
|
|
if ( !Thread.holdsLock( WorldSettings.class ) )
|
|
|
|
throw new RuntimeException( "Invalid Request" );
|
|
|
|
|
|
|
|
File f = new File( AEFolder, "spawndata" + File.separatorChar + dim + "_" + (chunkX >> 4) + "_" + (chunkZ >> 4) + ".dat" );
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
// save
|
|
|
|
FileOutputStream fos = new FileOutputStream( f );
|
2014-08-24 00:55:55 +02:00
|
|
|
|
2014-08-15 19:15:24 +02:00
|
|
|
try
|
|
|
|
{
|
|
|
|
CompressedStreamTools.writeCompressed( data, fos );
|
|
|
|
}
|
2014-08-24 00:55:55 +02:00
|
|
|
catch (Throwable e)
|
2014-08-15 19:15:24 +02:00
|
|
|
{
|
|
|
|
AELog.error( e );
|
|
|
|
}
|
2014-08-24 00:55:55 +02:00
|
|
|
|
2014-08-07 08:47:42 +02:00
|
|
|
fos.close();
|
|
|
|
}
|
|
|
|
catch (Throwable e)
|
|
|
|
{
|
2014-08-15 19:15:24 +02:00
|
|
|
AELog.error( e );
|
2014-08-07 08:47:42 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-09-21 00:31:18 +02:00
|
|
|
public Collection<NBTTagCompound> getNearByMeteorites(int dim, int chunkX, int chunkZ)
|
2014-08-07 08:47:42 +02:00
|
|
|
{
|
|
|
|
LinkedList<NBTTagCompound> ll = new LinkedList<NBTTagCompound>();
|
|
|
|
|
|
|
|
synchronized (WorldSettings.class)
|
|
|
|
{
|
|
|
|
for (int x = -1; x <= 1; x++)
|
|
|
|
{
|
|
|
|
for (int z = -1; z <= 1; z++)
|
|
|
|
{
|
|
|
|
int cx = x + (chunkX >> 4);
|
|
|
|
int cz = z + (chunkZ >> 4);
|
|
|
|
|
|
|
|
NBTTagCompound data = loadSpawnData( dim, cx << 4, cz << 4 );
|
|
|
|
|
|
|
|
if ( data != null )
|
|
|
|
{
|
|
|
|
// edit.
|
|
|
|
int size = data.getInteger( "num" );
|
|
|
|
for (int s = 0; s < size; s++)
|
|
|
|
ll.add( data.getCompoundTag( "" + s ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return ll;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean hasGenerated(int dim, int chunkX, int chunkZ)
|
|
|
|
{
|
|
|
|
synchronized (WorldSettings.class)
|
|
|
|
{
|
|
|
|
NBTTagCompound data = loadSpawnData( dim, chunkX, chunkZ );
|
|
|
|
return data.getBoolean( chunkX + "," + chunkZ );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setGenerated(int dim, int chunkX, int chunkZ)
|
|
|
|
{
|
|
|
|
synchronized (WorldSettings.class)
|
|
|
|
{
|
|
|
|
NBTTagCompound data = loadSpawnData( dim, chunkX, chunkZ );
|
|
|
|
|
|
|
|
// edit.
|
|
|
|
data.setBoolean( chunkX + "," + chunkZ, true );
|
|
|
|
|
|
|
|
writeSpawnData( dim, chunkX, chunkZ, data );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-09-21 01:31:39 +02:00
|
|
|
public boolean addNearByMeteorites(int dim, int chunkX, int chunkZ, NBTTagCompound newData)
|
2014-08-07 08:47:42 +02:00
|
|
|
{
|
|
|
|
synchronized (WorldSettings.class)
|
|
|
|
{
|
|
|
|
NBTTagCompound data = loadSpawnData( dim, chunkX, chunkZ );
|
|
|
|
|
|
|
|
// edit.
|
|
|
|
int size = data.getInteger( "num" );
|
|
|
|
data.setTag( "" + size, newData );
|
|
|
|
data.setInteger( "num", size + 1 );
|
|
|
|
|
|
|
|
writeSpawnData( dim, chunkX, chunkZ, data );
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-07 04:02:15 +01:00
|
|
|
public void shutdown()
|
|
|
|
{
|
|
|
|
save();
|
|
|
|
|
|
|
|
for (Integer dimID : storageCellDims)
|
|
|
|
DimensionManager.unregisterDimension( dimID );
|
|
|
|
|
|
|
|
storageCellDims.clear();
|
|
|
|
|
|
|
|
compass.kill();
|
|
|
|
instance = null;
|
|
|
|
}
|
|
|
|
|
2014-03-05 08:27:42 +01:00
|
|
|
List<Integer> storageCellDims = new ArrayList();
|
2014-09-14 07:02:02 +02:00
|
|
|
HashMap<Integer, UUID> idToUUID;
|
2014-03-05 08:27:42 +01:00
|
|
|
|
|
|
|
public void addStorageCellDim(int newDim)
|
|
|
|
{
|
|
|
|
storageCellDims.add( newDim );
|
|
|
|
DimensionManager.registerDimension( newDim, AEConfig.instance.storageProviderID );
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
NetworkHandler.instance.sendToAll( new PacketNewStorageDimension( newDim ) );
|
|
|
|
}
|
|
|
|
catch (IOException e)
|
|
|
|
{
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
|
|
|
|
String[] values = new String[storageCellDims.size()];
|
|
|
|
|
|
|
|
for (int x = 0; x < values.length; x++)
|
|
|
|
values[x] = "" + storageCellDims.get( x );
|
|
|
|
|
|
|
|
get( "DimensionManager", "StorageCells", new int[0] ).set( values );
|
|
|
|
save();
|
|
|
|
}
|
|
|
|
|
2014-03-02 09:35:11 +01:00
|
|
|
public CompassService getCompass()
|
|
|
|
{
|
|
|
|
return compass;
|
|
|
|
}
|
|
|
|
|
2013-12-27 23:59:59 +01:00
|
|
|
public static WorldSettings getInstance()
|
|
|
|
{
|
|
|
|
if ( instance == null )
|
|
|
|
{
|
2014-03-04 05:56:08 +01:00
|
|
|
File world = DimensionManager.getCurrentSaveRootDirectory();
|
|
|
|
|
2014-08-24 00:55:55 +02:00
|
|
|
File aeBaseFolder = new File( world.getPath() + File.separatorChar + "AE2" );
|
2014-03-02 09:35:11 +01:00
|
|
|
|
2014-08-24 00:55:55 +02:00
|
|
|
if ( !aeBaseFolder.exists() || !aeBaseFolder.isDirectory() )
|
2014-09-07 01:49:50 +02:00
|
|
|
if ( !aeBaseFolder.mkdir() || !aeBaseFolder.exists() )
|
2014-08-24 00:55:55 +02:00
|
|
|
{
|
|
|
|
throw new RuntimeException( "Failed to create " + aeBaseFolder.getAbsolutePath() );
|
|
|
|
}
|
|
|
|
|
|
|
|
File compass = new File( aeBaseFolder, "compass" );
|
|
|
|
if ( !compass.exists() || !compass.isDirectory() )
|
2014-09-07 01:49:50 +02:00
|
|
|
if ( !compass.mkdir() || !compass.exists() )
|
2014-08-24 00:55:55 +02:00
|
|
|
{
|
|
|
|
throw new RuntimeException( "Failed to create " + compass.getAbsolutePath() );
|
|
|
|
}
|
|
|
|
|
|
|
|
File spawnData = new File( aeBaseFolder, "spawndata" );
|
|
|
|
if ( !spawnData.exists() || !spawnData.isDirectory() )
|
2014-09-07 01:49:50 +02:00
|
|
|
if ( !spawnData.mkdir() || !spawnData.exists() )
|
2014-08-24 00:55:55 +02:00
|
|
|
{
|
|
|
|
throw new RuntimeException( "Failed to create " + spawnData.getAbsolutePath() );
|
|
|
|
}
|
2014-03-02 09:35:11 +01:00
|
|
|
|
2014-08-24 00:55:55 +02:00
|
|
|
instance = new WorldSettings( aeBaseFolder );
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return instance;
|
|
|
|
}
|
|
|
|
|
2014-08-30 04:39:36 +02:00
|
|
|
public void sendToPlayer(NetworkManager manager, EntityPlayerMP player)
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
2014-08-30 04:39:36 +02:00
|
|
|
if ( manager != null )
|
2014-03-05 08:27:42 +01:00
|
|
|
{
|
2014-08-30 04:39:36 +02:00
|
|
|
for (int newDim : get( "DimensionManager", "StorageCells", new int[0] ).getIntList())
|
2014-03-05 08:27:42 +01:00
|
|
|
{
|
2014-08-30 04:39:36 +02:00
|
|
|
try
|
|
|
|
{
|
|
|
|
manager.scheduleOutboundPacket( (new PacketNewStorageDimension( newDim )).getProxy(), new GenericFutureListener[0] );
|
|
|
|
}
|
|
|
|
catch (IOException e)
|
|
|
|
{
|
|
|
|
AELog.error( e );
|
|
|
|
}
|
2014-03-05 08:27:42 +01:00
|
|
|
}
|
|
|
|
}
|
2014-08-30 04:39:36 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
for (PlayerColor pc : TickHandler.instance.getPlayerColors().values())
|
|
|
|
NetworkHandler.instance.sendToAll( pc.getPacket() );
|
|
|
|
}
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public void init()
|
|
|
|
{
|
|
|
|
save();
|
|
|
|
}
|
|
|
|
|
|
|
|
private WeakHashMap<GridStorageSearch, WeakReference<GridStorageSearch>> loadedStorage = new WeakHashMap();
|
|
|
|
|
|
|
|
public WorldCoord getStoredSize(int dim)
|
|
|
|
{
|
|
|
|
int x = get( "StorageCell" + dim, "scaleX", 0 ).getInt();
|
|
|
|
int y = get( "StorageCell" + dim, "scaleY", 0 ).getInt();
|
|
|
|
int z = get( "StorageCell" + dim, "scaleZ", 0 ).getInt();
|
|
|
|
return new WorldCoord( x, y, z );
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setStoredSize(int dim, int targetX, int targetY, int targetZ)
|
|
|
|
{
|
|
|
|
get( "StorageCell" + dim, "scaleX", 0 ).set( targetX );
|
|
|
|
get( "StorageCell" + dim, "scaleY", 0 ).set( targetY );
|
|
|
|
get( "StorageCell" + dim, "scaleZ", 0 ).set( targetZ );
|
|
|
|
save();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* lazy loading, can load any id, even ones that don't exist anymore.
|
|
|
|
*
|
|
|
|
* @param storageID
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
public GridStorage getGridStorage(long storageID)
|
|
|
|
{
|
|
|
|
GridStorageSearch gss = new GridStorageSearch( storageID );
|
|
|
|
WeakReference<GridStorageSearch> result = loadedStorage.get( gss );
|
|
|
|
|
|
|
|
if ( result == null || result.get() == null )
|
|
|
|
{
|
|
|
|
String Data = get( "gridstorage", "" + storageID, "" ).getString();
|
|
|
|
GridStorage thisStorage = new GridStorage( Data, storageID, gss );
|
|
|
|
gss.gridStorage = new WeakReference<GridStorage>( thisStorage );
|
|
|
|
loadedStorage.put( gss, new WeakReference<GridStorageSearch>( gss ) );
|
|
|
|
return thisStorage;
|
|
|
|
}
|
|
|
|
return result.get().gridStorage.get();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* create a new storage
|
|
|
|
*/
|
|
|
|
public GridStorage getNewGridStorage()
|
|
|
|
{
|
|
|
|
long storageID = nextGridStorage();
|
|
|
|
GridStorageSearch gss = new GridStorageSearch( storageID );
|
|
|
|
GridStorage newStorage = new GridStorage( storageID, gss );
|
|
|
|
gss.gridStorage = new WeakReference<GridStorage>( newStorage );
|
|
|
|
loadedStorage.put( gss, new WeakReference<GridStorageSearch>( gss ) );
|
|
|
|
return newStorage;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void destroyGridStorage(long id)
|
|
|
|
{
|
|
|
|
this.getCategory( "gridstorage" ).remove( "" + id );
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void save()
|
|
|
|
{
|
|
|
|
// populate new data
|
|
|
|
for (GridStorageSearch gs : loadedStorage.keySet())
|
|
|
|
{
|
|
|
|
GridStorage thisStorage = gs.gridStorage.get();
|
|
|
|
if ( thisStorage != null && thisStorage.getGrid() != null && !thisStorage.getGrid().isEmpty() )
|
|
|
|
{
|
|
|
|
String value = thisStorage.getValue();
|
|
|
|
get( "gridstorage", "" + thisStorage.getID(), value ).set( value );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// save to files
|
|
|
|
if ( hasChanged() )
|
|
|
|
super.save();
|
|
|
|
}
|
|
|
|
|
|
|
|
private long nextGridStorage()
|
|
|
|
{
|
|
|
|
long r = lastGridStorage++;
|
|
|
|
get( "Counters", "lastGridStorage", lastGridStorage ).set( Long.toString( lastGridStorage ) );
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2014-01-27 05:00:36 +01:00
|
|
|
private long nextPlayer()
|
|
|
|
{
|
|
|
|
long r = lastPlayer++;
|
|
|
|
get( "Counters", "lastPlayer", lastPlayer ).set( lastPlayer );
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2014-05-16 04:18:30 +02:00
|
|
|
public int getNextOrderedValue(String name)
|
|
|
|
{
|
|
|
|
Property p = this.get( "orderedValues", name, 0 );
|
|
|
|
int myValue = p.getInt();
|
|
|
|
p.set( myValue + 1 );
|
|
|
|
return myValue;
|
|
|
|
}
|
|
|
|
|
2014-07-09 22:07:53 +02:00
|
|
|
public int getPlayerID(GameProfile profile)
|
2014-01-27 05:00:36 +01:00
|
|
|
{
|
|
|
|
ConfigCategory playerList = this.getCategory( "players" );
|
2014-07-10 05:18:50 +02:00
|
|
|
|
2014-07-09 22:07:53 +02:00
|
|
|
if ( playerList == null || profile == null || !profile.isComplete() )
|
2014-01-27 05:00:36 +01:00
|
|
|
return -1;
|
|
|
|
|
2014-07-10 05:18:50 +02:00
|
|
|
String uuid = profile.getId().toString();
|
|
|
|
|
2014-07-09 22:07:53 +02:00
|
|
|
Property prop = playerList.get( uuid );
|
2014-01-27 05:00:36 +01:00
|
|
|
if ( prop != null && prop.isIntValue() )
|
|
|
|
return prop.getInt();
|
|
|
|
else
|
|
|
|
{
|
2014-07-09 22:07:53 +02:00
|
|
|
playerList.put( uuid, prop = new Property( uuid, "" + nextPlayer(), Property.Type.INTEGER ) );
|
2014-09-14 07:02:02 +02:00
|
|
|
getUUIDMap().put( prop.getInt(), profile.getId() ); // add to reverse map
|
2014-01-27 05:00:36 +01:00
|
|
|
save();
|
|
|
|
return prop.getInt();
|
|
|
|
}
|
|
|
|
}
|
2014-03-02 09:35:11 +01:00
|
|
|
|
2014-09-14 07:02:02 +02:00
|
|
|
public HashMap<Integer, UUID> getUUIDMap()
|
|
|
|
{
|
|
|
|
if ( idToUUID == null )
|
|
|
|
{
|
|
|
|
idToUUID = new HashMap<Integer, UUID>();
|
|
|
|
|
|
|
|
ConfigCategory playerList = this.getCategory( "players" );
|
|
|
|
|
|
|
|
for (Entry<String, Property> b : playerList.getValues().entrySet())
|
|
|
|
idToUUID.put( b.getValue().getInt(), UUID.fromString( b.getKey() ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
return idToUUID;
|
|
|
|
}
|
|
|
|
|
|
|
|
public EntityPlayer getPlayerFromID(int playerID)
|
|
|
|
{
|
|
|
|
UUID id = getUUIDMap().get( playerID );
|
|
|
|
|
|
|
|
if ( id != null )
|
|
|
|
{
|
|
|
|
for (EntityPlayer player : CommonHelper.proxy.getPlayers())
|
|
|
|
{
|
|
|
|
if ( player.getUniqueID().equals( id ) )
|
|
|
|
return player;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|