本文整理汇总了Java中ethanjones.cubes.core.system.CubesException类的典型用法代码示例。如果您正苦于以下问题:Java CubesException类的具体用法?Java CubesException怎么用?Java CubesException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CubesException类属于ethanjones.cubes.core.system包,在下文中一共展示了CubesException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ZipModInputStream
import ethanjones.cubes.core.system.CubesException; //导入依赖的package包/类
public ZipModInputStream(FileHandle file) {
try {
inputStream = new FileInputStream(file.file());
zipInputStream = new ZipInputStream(inputStream);
fileStream = new FilterInputStream(zipInputStream) {
@Override
public void close() throws IOException {
// no close
}
};
} catch (Exception e) {
try {
close();
} catch (IOException ignored) {
}
throw new CubesException("Failed to create zip mod input stream", e);
}
}
示例2: convertToDex
import ethanjones.cubes.core.system.CubesException; //导入依赖的package包/类
private FileHandle convertToDex(FileHandle fileHandle) throws Exception {
String inputHash = hashFile(fileHandle);
FileHandle cacheDir = new FileHandle(androidCompatibility.androidLauncher.getCacheDir());
FileHandle dexDir = cacheDir.child("converted_mod_dex");
dexDir.mkdirs();
FileHandle dexFile = dexDir.child(inputHash + ".dex");
if (!dexFile.exists()) {
Log.warning("Trying to convert jar to dex: " + fileHandle.file().getAbsolutePath());
com.android.dx.command.dexer.Main.Arguments arguments = new com.android.dx.command.dexer.Main.Arguments();
arguments.parse(new String[]{"--output=" + dexFile.file().getAbsolutePath(), fileHandle.file().getAbsolutePath()});
int result = com.android.dx.command.dexer.Main.run(arguments);
if (result != 0) throw new CubesException("Failed to convert jar to dex [" + result + "]: " + fileHandle.file().getAbsolutePath());
Log.warning("Converted jar to dex: " + fileHandle.file().getAbsolutePath());
}
return dexFile;
}
示例3: hashFile
import ethanjones.cubes.core.system.CubesException; //导入依赖的package包/类
public static String hashFile(FileHandle fileHandle) throws Exception {
InputStream inputStream = fileHandle.read();
try {
MessageDigest digest = MessageDigest.getInstance("SHA-256");
byte[] bytesBuffer = new byte[1024];
int bytesRead;
int n =inputStream.read(bytesBuffer);
while ((bytesRead = n) != -1) {
digest.update(bytesBuffer, 0, bytesRead);
n=inputStream.read(bytesBuffer);
}
byte[] hashedBytes = digest.digest();
return convertByteArrayToHexString(hashedBytes);
} catch (IOException ex) {
throw new CubesException("Could not generate hash from file " + fileHandle.path(), ex);
} finally {
StreamUtils.closeQuietly(inputStream);
}
}
示例4: read
import ethanjones.cubes.core.system.CubesException; //导入依赖的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");
}
示例5: removeArrays
import ethanjones.cubes.core.system.CubesException; //导入依赖的package包/类
private void removeArrays() {
lock.writeLock();
if (unloaded) {
lock.writeUnlock();
throw new CubesException("Area has been unloaded");
}
blocks = null;
light = null;
blockDataList.clear();
AreaRenderer.free(areaRenderer);
areaRenderer = null;
if (renderStatus.length > 0)
renderStatus = new int[0];
maxY = 0;
height = 0;
Arrays.fill(heightmap, 0);
Arrays.fill(neighboursClient, null);
Arrays.fill(neighboursServer, null);
unloaded = true;
lock.writeUnlock();
}
示例6: setupArrays
import ethanjones.cubes.core.system.CubesException; //导入依赖的package包/类
public void setupArrays(int y) {
lock.writeLock();
if (unloaded) {
lock.writeUnlock();
throw new CubesException("Area has been unloaded");
}
if (isBlank()) {
int h = (int) Math.ceil((y + 1) / (float) SIZE_BLOCKS);
blocks = new int[SIZE_BLOCKS_CUBED * h];
light = new byte[SIZE_BLOCKS_CUBED * h];
AreaRenderer.free(areaRenderer);
if (Side.isClient() || isShared()) {
areaRenderer = new AreaRenderer[h];
renderStatus = AreaRenderStatus.create(h);
}
height = h;
maxY = (h * SIZE_BLOCKS) - 1;
} else if (y > maxY) {
expand(y);
}
lock.writeUnlock();
}
示例7: remove
import ethanjones.cubes.core.system.CubesException; //导入依赖的package包/类
@Override
public void remove() {
if (!lock.ownedByCurrentThread())
throw new CubesException("AreaMap should be write locked");
if (current == null)
throw new IllegalStateException();
Area old = current.areas[currentN];
current.areas[currentN] = null;
current.storedAreas--;
if (current.storedAreas == 0) {
// removeNode(current)
current = null;
currentN = -1;
}
synchronized (this) {
this.notifyAll();
}
if (old != null) {
old.setAreaMap(null);
old.unload();
}
}
示例8: update
import ethanjones.cubes.core.system.CubesException; //导入依赖的package包/类
@Override
public void update() {
synchronized (socketMonitor) {
if (getNetworkingState() != NetworkingState.Running) {
Adapter.gotoMenu(exception != null ? new DisconnectedMenu(exception) : new DisconnectedMenu());
}
tickCount++;
if (tickCount % PING_TICKS == 0) {
if (awaitingPingResponse) {
disconnected(socketMonitor, new CubesException("No ping response"));
} else {
awaitingPingResponse = true;
sendPacketToServer(new PacketPingRequest());
}
}
}
}
示例9: getShaderIf
import ethanjones.cubes.core.system.CubesException; //导入依赖的package包/类
private void getShaderIf(int shader, Renderable renderable, boolean fogFlag, boolean aoFlag) {
if (shaders[shader] == null) {
if (shader == 0) {
shaders[shader] = new CubesShader(renderable);
} else {
ArrayList<Feature> f = new ArrayList<Feature>();
if (fogFlag)
f.add(new FogFeature());
if (aoFlag)
f.add(new AmbientOcclusionFeature());
shaders[shader] = new FeatureShader(renderable, f);
}
ShaderProgram program = shaders[shader].program;
if (!program.isCompiled()) {
Log.error("Failed to compile shader");
Log.error("Shader log: \n" + program.getLog());
Log.error("Fragment shader source: \n" + program.getFragmentShaderSource());
Log.error("Vertex shader source: \n" + program.getVertexShaderSource());
throw new CubesException("Failed to compile shader");
}
shaders[shader].init();
}
}
示例10: takeScreenshot
import ethanjones.cubes.core.system.CubesException; //导入依赖的package包/类
public static void takeScreenshot() {
Pixmap pixmap = ScreenUtils.getFrameBufferPixmap(0, 0, Gdx.graphics.getBackBufferWidth(),
Gdx.graphics.getBackBufferHeight());
FileHandle dir = Compatibility.get().getBaseFolder().child("screenshots");
dir.mkdirs();
FileHandle f = dir.child(System.currentTimeMillis() + ".png");
try {
PixmapIO.PNG writer = new PixmapIO.PNG((int) (pixmap.getWidth() * pixmap.getHeight() * 1.5f));
try {
writer.setFlipY(true);
writer.write(f, pixmap);
} finally {
writer.dispose();
}
} catch (IOException ex) {
throw new CubesException("Error writing PNG: " + f, ex);
} finally {
pixmap.dispose();
}
Log.info("Took screenshot '" + f.file().getAbsolutePath() + "'");
}
示例11: loadGraphics
import ethanjones.cubes.core.system.CubesException; //导入依赖的package包/类
@Override
public void loadGraphics() {
if (textures == null) {
super.loadGraphics();
return;
}
textureHandlers = new BlockTextureHandler[meta];
for (int m = 0; m < textureHandlers.length; m++) {
textureHandlers[m] = new BlockTextureHandler(textures[m][0]);
if (textures[m].length == 6) {
for (int s = 1; s < textures[m].length; s++) {
textureHandlers[m].setSide(s, textures[m][s]);
}
} else {
throw new CubesException("Invalid JBlock.textures length for id \"" + id + "\"");
}
}
textures = null;
}
示例12: preInit
import ethanjones.cubes.core.system.CubesException; //导入依赖的package包/类
public static void preInit(AdapterInterface aI) {
if (preInit)
return;
preInit = true;
if (Compatibility.get() == null) {
Log.error(new CubesException("No Compatibility module for this platform: " + Gdx.app.getType().name()
+ ", OS: " + System.getProperty("os.name") + ", Arch:" + System.getProperty("os.arch")));
}
Cubes.adapterInterface = aI;
Compatibility.get().getBaseFolder().mkdirs();
Log.info(Branding.DEBUG); // Can't log till base folder setup
Log.info("https://github.com/ictrobot/Cubes");
Debug.printProperties();
Compatibility.get().logEnvironment();
Executor.init();
Assets.preInit();
}
示例13: startCubes
import ethanjones.cubes.core.system.CubesException; //导入依赖的package包/类
public void startCubes() {
compatibility = this;
Thread.setDefaultUncaughtExceptionHandler(UncaughtExceptionHandler.instance);
Thread.currentThread().setUncaughtExceptionHandler(UncaughtExceptionHandler.instance);
try {
if (applicationType == ApplicationType.HeadlessDesktop) {
run(new ServerAdapter());
} else {
run(new ClientAdapter());
}
} catch (Exception e) {
try {
Log.error("Failed to start", CubesException.get(e));
} catch (Exception ex) {
if (ex instanceof CubesException) {
throw (CubesException) ex;
} else {
throw CubesException.get(e);
}
}
}
}
示例14: load
import ethanjones.cubes.core.system.CubesException; //导入依赖的package包/类
private static Multimap<JsonStage, JsonValue> load(Map<String, FileHandle> map) throws IOException {
try {
Multimap<JsonStage, JsonValue> m = new Multimap<JsonStage, JsonValue>();
for (Map.Entry<String, FileHandle> entry : map.entrySet()) {
JsonStage stage = null;
if (entry.getKey().startsWith("block")) {
stage = JsonStage.BLOCK;
} else if (entry.getKey().startsWith("item")) {
stage = JsonStage.ITEM;
} else if (entry.getKey().startsWith("recipe")) {
stage = JsonStage.RECIPE;
} else {
throw new CubesException("Invalid json file path \"" + entry.getKey() + "\"");
}
Reader reader = entry.getValue().reader();
m.put(stage, Json.parse(reader));
}
}finally {
reader.close();
}
return m;
}
示例15: mapping
import ethanjones.cubes.core.system.CubesException; //导入依赖的package包/类
public static LuaTable mapping(Class<?> c) {
try {
LuaTable luaTable = new LuaTable();
for (Field field : c.getFields()) {
if (!Modifier.isStatic(field.getModifiers()))
continue;
if (LuaValue.class.isAssignableFrom(field.getType())) {
luaTable.set(field.getName(), (LuaValue) field.get(null));
}
if (field.getType().equals(Class.class)) {
luaTable.set(field.getName(), mapping((Class<?>) field.get(null)));
}
}
return new ReadOnlyLuaTable(luaTable);
} catch (Exception e) {
throw new CubesException("Failed to create lua api", e);
}
}