当前位置: 首页>>代码示例>>Java>>正文


Java DataGroup类代码示例

本文整理汇总了Java中ethanjones.data.DataGroup的典型用法代码示例。如果您正苦于以下问题:Java DataGroup类的具体用法?Java DataGroup怎么用?Java DataGroup使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DataGroup类属于ethanjones.data包,在下文中一共展示了DataGroup类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: readPlayer

import ethanjones.data.DataGroup; //导入依赖的package包/类
public Player readPlayer(UUID uuid, ClientIdentifier clientIdentifier) {
	if (fileHandle == null)
		return null;
	FileHandle folder = folderPlayer();
	FileHandle file = folder.child(uuid.toString());
	if (!file.exists())
		return null;
	try {
		DataGroup data = (DataGroup) Data.input(file.file());
		Player player = new Player(data.getString("username"), uuid, clientIdentifier);
		player.read(data);
		return player;
	} catch (Exception e) {
		Log.warning("Failed to read player", e);
		return null;
	}
}
 
开发者ID:RedTroop,项目名称:Cubes_2,代码行数:18,代码来源:Save.java

示例2: write

import ethanjones.data.DataGroup; //导入依赖的package包/类
@Override
public DataGroup write() {
	DataGroup dataGroup = new DataGroup();
	dataGroup.put("saveVersion", 0);
	dataGroup.put("worldSeed", worldSeed);
	dataGroup.put("worldSeedStr", worldSeedString);
	dataGroup.put("worldTime", worldTime);
	dataGroup.put("worldType", worldType);
	dataGroup.put("worldGamemode", worldGamemode.name());
	dataGroup.put("idManager", idManager);

	dataGroup.put("lastOpenedTime", System.currentTimeMillis());

	DataGroup version = dataGroup.getGroup("lastVersion");
	version.put("major", Branding.VERSION_MAJOR);
	version.put("minor", Branding.VERSION_MINOR);
	version.put("point", Branding.VERSION_POINT);
	version.put("build", Branding.VERSION_BUILD);
	version.put("hash", Branding.VERSION_HASH);

	return dataGroup;
}
 
开发者ID:RedTroop,项目名称:Cubes_2,代码行数:23,代码来源:SaveOptions.java

示例3: read

import ethanjones.data.DataGroup; //导入依赖的package包/类
@Override
public void read(DataGroup dataGroup) {
	if (dataGroup.getInteger("saveVersion") != 0)
		throw new CubesException("Invalid save version");
	worldSeed = dataGroup.getLong("worldSeed");
	worldSeedString = dataGroup.getString("worldSeedStr");
	worldTime = dataGroup.getInteger("worldTime");
	worldType = dataGroup.getString("worldType");
	worldGamemode = Gamemode.valueOf(dataGroup.getString("worldGamemode"));
	idManager = dataGroup.getGroup("idManager");

	lastOpenedTime = dataGroup.getLong("lastOpenedTime");

	DataGroup version = dataGroup.getGroup("lastVersion");
	lastVersionMajor = version.getInteger("major");
	lastVersionMinor = version.getInteger("minor");
	lastVersionPoint = version.getInteger("point");
	lastVersionBuild = version.getInteger("build");
	lastVersionHash = version.getString("hash");
}
 
开发者ID:RedTroop,项目名称:Cubes_2,代码行数:21,代码来源:SaveOptions.java

示例4: readFor

import ethanjones.data.DataGroup; //导入依赖的package包/类
private void readFor(int dataSize, DataInputStream dataInputStream) {
	for (int i = 0; i < dataSize; i++) {
		int ref = dataInputStream.readInt();
		int x = getX(ref);
		int y = getY(ref);
		int z = getZ(ref);
		Block block = getBlock(x, y, z);
		if (block == null)
			continue;
		int meta = getMeta(x, y, z);
		DataGroup dataGroup = (DataGroup) Data.input(dataInputStream);
		BlockData data = block.createBlockData(this, x, y, z, meta, dataGroup);
		if (data == null)
			continue;
		data.read(dataGroup);
		blockDataList.add(data);
	}
}
 
开发者ID:RedTroop,项目名称:Cubes_2,代码行数:19,代码来源:Area.java

示例5: write

import ethanjones.data.DataGroup; //导入依赖的package包/类
@Override
public DataGroup write() {
  DataGroup dataGroup = new DataGroup();
  dataGroup.put("saveVersion", 0);
  dataGroup.put("worldSeed", worldSeed);
  dataGroup.put("worldSeedStr", worldSeedString);
  dataGroup.put("worldTime", worldTime);
  dataGroup.put("worldType", worldType);
  dataGroup.put("worldGamemode", worldGamemode.name());
  dataGroup.put("idManager", idManager);

  dataGroup.put("lastOpenedTime", System.currentTimeMillis());

  DataGroup version = dataGroup.getGroup("lastVersion");
  version.put("major", Branding.VERSION_MAJOR);
  version.put("minor", Branding.VERSION_MINOR);
  version.put("point", Branding.VERSION_POINT);
  version.put("build", Branding.VERSION_BUILD);
  version.put("hash", Branding.VERSION_HASH);
  
  return dataGroup;
}
 
开发者ID:RedTroop,项目名称:Cubes,代码行数:23,代码来源:SaveOptions.java

示例6: read

import ethanjones.data.DataGroup; //导入依赖的package包/类
@Override
public void read(DataGroup dataGroup) {
  if (dataGroup.getInteger("saveVersion") != 0) throw new CubesException("Invalid save version");
  worldSeed = dataGroup.getLong("worldSeed");
  worldSeedString = dataGroup.getString("worldSeedStr");
  worldTime = dataGroup.getInteger("worldTime");
  worldType = dataGroup.getString("worldType");
  worldGamemode = Gamemode.valueOf(dataGroup.getString("worldGamemode"));
  idManager = dataGroup.getGroup("idManager");

  lastOpenedTime = dataGroup.getLong("lastOpenedTime");

  DataGroup version = dataGroup.getGroup("lastVersion");
  lastVersionMajor = version.getInteger("major");
  lastVersionMinor = version.getInteger("minor");
  lastVersionPoint = version.getInteger("point");
  lastVersionBuild = version.getInteger("build");
  lastVersionHash = version.getString("hash");
}
 
开发者ID:RedTroop,项目名称:Cubes,代码行数:20,代码来源:SaveOptions.java

示例7: write

import ethanjones.data.DataGroup; //导入依赖的package包/类
public static boolean write(Save save, Area area) {
	if (save.readOnly)
		return false;
	if (!area.isReady())
		return false;

	AreaMap map = area.areaMap();
	DataGroup[] dataGroups;
	if (map == null || map.world == null || map.world.entities == null) {
		dataGroups = new DataGroup[0];
	} else {
		dataGroups = map.world.entities.getEntitiesForSave(area.areaX, area.areaZ);
	}
	if (!area.modifiedSinceSave(dataGroups))
		return false;
	area.saveModCount();

	Deflater deflater = deflaterThreadLocal.get();

	FileHandle file = file(save, area.areaX, area.areaZ);
	try {
		deflater.reset();
		OutputStream stream = file.write(false, 8192);
		DeflaterOutputStream deflaterStream = new DeflaterOutputStream(stream, deflater);
		BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(deflaterStream);
		DataOutputStream dataOutputStream = new DataOutputStream(bufferedOutputStream);
		area.writeSave(dataOutputStream, dataGroups);
		bufferedOutputStream.flush();
		deflaterStream.finish();
		stream.close();
	} catch (Exception e) {
		Log.error("Failed to write area " + area.areaX + "," + area.areaZ, e);
		return false;
	}

	return true;
}
 
开发者ID:RedTroop,项目名称:Cubes_2,代码行数:38,代码来源:SaveAreaIO.java

示例8: writePlayer

import ethanjones.data.DataGroup; //导入依赖的package包/类
public void writePlayer(Player player) {
	if (readOnly)
		return;
	FileHandle folder = folderPlayer();
	FileHandle file = folder.child(player.uuid.toString());
	DataGroup data = player.write();
	try {
		Data.output(data, file.file());
	} catch (Exception e) {
		Log.warning("Failed to write player", e);
	}
}
 
开发者ID:RedTroop,项目名称:Cubes_2,代码行数:13,代码来源:Save.java

示例9: readSaveOptions

import ethanjones.data.DataGroup; //导入依赖的package包/类
public  SaveOptions readSaveOptions() {
	synchronized(saveOptions){
	if (saveOptions == null) {
		saveOptions = new SaveOptions();
		try {
			DataGroup dataGroup = (DataGroup) Data.input(fileHandle.child("options").file());
			saveOptions.read(dataGroup);
			return saveOptions;
		} catch (Exception e) {
			saveOptions = null;
		}
	}
	return saveOptions;}
}
 
开发者ID:RedTroop,项目名称:Cubes_2,代码行数:15,代码来源:Save.java

示例10: getSaveOptions

import ethanjones.data.DataGroup; //导入依赖的package包/类
public  SaveOptions getSaveOptions() {
	synchronized(saveOptions){
	if (saveOptions == null) {
		saveOptions = new SaveOptions();
		try {
			DataGroup dataGroup = (DataGroup) Data.input(fileHandle.child("options").file());
			saveOptions.read(dataGroup);
		} catch (Exception e) {
			Log.warning("Failed to read save options", e);
			writeSaveOptions();
		}
	}
	return saveOptions;}
}
 
开发者ID:RedTroop,项目名称:Cubes_2,代码行数:15,代码来源:Save.java

示例11: writeSaveOptions

import ethanjones.data.DataGroup; //导入依赖的package包/类
public  SaveOptions writeSaveOptions() {
	synchronized(saveOptions){
	if (!readOnly && saveOptions != null) {
		try {
			DataGroup dataGroup = saveOptions.write();
			Data.output(dataGroup, fileHandle.child("options").file());
		} catch (Exception e) {
			Log.warning("Failed to write save options", e);
		}
	}
	return saveOptions;}
}
 
开发者ID:RedTroop,项目名称:Cubes_2,代码行数:13,代码来源:Save.java

示例12: updateEntity

import ethanjones.data.DataGroup; //导入依赖的package包/类
@Override
public void updateEntity(DataGroup data) {
	entities.lock.writeLock();
	super.updateEntity(data);

	PacketEntityUpdate packet = new PacketEntityUpdate();
	packet.data = data;
	NetworkingManager.sendPacketToAllClients(packet);
	entities.lock.writeUnlock();
}
 
开发者ID:RedTroop,项目名称:Cubes_2,代码行数:11,代码来源:WorldServer.java

示例13: getEntitiesForSave

import ethanjones.data.DataGroup; //导入依赖的package包/类
public DataGroup[] getEntitiesForSave(int areaX, int areaZ) {
	lock.readLock();
	ArrayList<DataGroup> dataGroups = new ArrayList<DataGroup>();
	for (Entity entity : values()) {
		if (areaX == CoordinateConverter.area(entity.position.x)
				&& areaZ == CoordinateConverter.area(entity.position.z) && !(entity instanceof Player)) {
			dataGroups.add(entity.write());
		}
	}
	DataGroup[] array = dataGroups.size() == 0 ? new DataGroup[0]
			: dataGroups.toArray(new DataGroup[dataGroups.size()]);
	lock.readUnlock();
	return array;
}
 
开发者ID:RedTroop,项目名称:Cubes_2,代码行数:15,代码来源:Entities.java

示例14: writeIf2

import ethanjones.data.DataGroup; //导入依赖的package包/类
private void writeIf2(boolean writeEntities, DataGroup[] entities, DataOutputStream dataOutputStream) {
	if (writeEntities && entities != null) {
		dataOutputStream.writeShort(entities.length);
		dataOutputStream.writeShort(blockDataList.size());

		for (DataGroup entity : entities) {
			Data.output(entity, dataOutputStream);
		}
	} else {
		dataOutputStream.writeShort(0);
		dataOutputStream.writeShort(blockDataList.size());
	}
}
 
开发者ID:RedTroop,项目名称:Cubes_2,代码行数:14,代码来源:Area.java

示例15: updateEntity

import ethanjones.data.DataGroup; //导入依赖的package包/类
public void updateEntity(DataGroup data) {
	entities.lock.writeLock();
	UUID uuid = (UUID) data.get("uuid");
	Entity entity = entities.get(uuid);
	if (entity != null) {
		entity.read(data);
	} else {
		Log.warning("No entity with uuid " + uuid.toString());
		addEntity(Entity.readType(data));
	}
	entities.lock.writeUnlock();
}
 
开发者ID:RedTroop,项目名称:Cubes_2,代码行数:13,代码来源:World.java


注:本文中的ethanjones.data.DataGroup类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。