mirror of
https://github.com/sirjonasxx/G-Earth.git
synced 2025-01-18 16:26:26 +01:00
Merge branch 'development'
This commit is contained in:
commit
acf90073e5
@ -18,6 +18,8 @@ public class HEntity {
|
||||
private HEntityUpdate lastUpdate = null;
|
||||
private Object[] stuff = new Object[0];
|
||||
|
||||
private int unknown1;
|
||||
|
||||
public HEntity(HPacket packet) {
|
||||
id = packet.readInteger();
|
||||
name = packet.readString();
|
||||
@ -27,7 +29,7 @@ public class HEntity {
|
||||
tile = new HPoint(packet.readInteger(), packet.readInteger(),
|
||||
Double.parseDouble(packet.readString()));
|
||||
|
||||
packet.readInteger();
|
||||
unknown1 = packet.readInteger();
|
||||
int entityTypeId = packet.readInteger();
|
||||
entityType = HEntityType.valueOf(entityTypeId);
|
||||
|
||||
@ -43,7 +45,7 @@ public class HEntity {
|
||||
stuff[4] = packet.readBoolean();
|
||||
break;
|
||||
case 2:
|
||||
stuff = new Object[20];
|
||||
stuff = new Object[12];
|
||||
stuff[0] = packet.readInteger();
|
||||
stuff[1] = packet.readInteger();
|
||||
stuff[2] = packet.readString();
|
||||
@ -72,6 +74,48 @@ public class HEntity {
|
||||
}
|
||||
}
|
||||
|
||||
public void appendToPacket(HPacket packet) {
|
||||
packet.appendInt(id);
|
||||
packet.appendString(name);
|
||||
packet.appendString(motto);
|
||||
packet.appendString(figureId);
|
||||
packet.appendInt(index);
|
||||
packet.appendInt(tile.getX());
|
||||
packet.appendInt(tile.getY());
|
||||
packet.appendString(tile.getZ() + "");
|
||||
packet.appendInt(unknown1);
|
||||
packet.appendInt(entityType.getId());
|
||||
//
|
||||
switch (entityType.getId()) {
|
||||
case 1:
|
||||
packet.appendObjects(gender.toString(), stuff[0], stuff[1],
|
||||
favoriteGroup, stuff[2], stuff[3], stuff[4]);
|
||||
break;
|
||||
case 2:
|
||||
packet.appendObjects(stuff);
|
||||
break;
|
||||
case 4:
|
||||
packet.appendObjects(stuff[0], stuff[1], stuff[2]);
|
||||
List<Short> list = (List<Short>) stuff[3];
|
||||
packet.appendInt(list.size());
|
||||
for(short s : list) {
|
||||
packet.appendShort(s);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public static HPacket constructPacket(HEntity[] entities, int headerId) {
|
||||
HPacket packet = new HPacket(headerId);
|
||||
packet.appendInt(entities.length);
|
||||
for (HEntity entity : entities) {
|
||||
entity.appendToPacket(packet);
|
||||
}
|
||||
|
||||
return packet;
|
||||
}
|
||||
|
||||
public static HEntity[] parse(HPacket packet) {
|
||||
HEntity[] entities = new HEntity[packet.readInteger()];
|
||||
|
||||
@ -132,4 +176,44 @@ public class HEntity {
|
||||
public Object[] getStuff() {
|
||||
return stuff;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public void setIndex(int index) {
|
||||
this.index = index;
|
||||
}
|
||||
|
||||
public void setTile(HPoint tile) {
|
||||
this.tile = tile;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public void setMotto(String motto) {
|
||||
this.motto = motto;
|
||||
}
|
||||
|
||||
public void setGender(HGender gender) {
|
||||
this.gender = gender;
|
||||
}
|
||||
|
||||
public void setFigureId(String figureId) {
|
||||
this.figureId = figureId;
|
||||
}
|
||||
|
||||
public void setFavoriteGroup(String favoriteGroup) {
|
||||
this.favoriteGroup = favoriteGroup;
|
||||
}
|
||||
|
||||
public void setLastUpdate(HEntityUpdate lastUpdate) {
|
||||
this.lastUpdate = lastUpdate;
|
||||
}
|
||||
|
||||
public void setStuff(Object[] stuff) {
|
||||
this.stuff = stuff;
|
||||
}
|
||||
}
|
||||
|
@ -17,8 +17,9 @@ import java.util.List;
|
||||
public class Cacher {
|
||||
|
||||
private static final String DEFAULT_CACHE_FILENAME = "cache.json";
|
||||
private static String cacheDir;
|
||||
|
||||
public static String getCacheDir() {
|
||||
static {
|
||||
File GEarthDir = null;
|
||||
try {
|
||||
GEarthDir = new File(Main.class.getProtectionDomain().getCodeSource().getLocation().toURI()).getParentFile();
|
||||
@ -26,15 +27,21 @@ public class Cacher {
|
||||
GEarthDir = GEarthDir.getParentFile();
|
||||
}
|
||||
|
||||
} catch (URISyntaxException e) {
|
||||
// e.printStackTrace();
|
||||
}
|
||||
} catch (URISyntaxException e) { }
|
||||
|
||||
return GEarthDir
|
||||
cacheDir = GEarthDir
|
||||
+ File.separator
|
||||
+ "Cache";
|
||||
}
|
||||
|
||||
public static void setCacheDir(String s) {
|
||||
cacheDir = s;
|
||||
}
|
||||
|
||||
public static String getCacheDir() {
|
||||
return cacheDir;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static boolean cacheFileExists(String cache_filename) {
|
||||
|
@ -120,7 +120,7 @@ public class StoreExtensionDetailsOverview extends HOverview {
|
||||
@Override
|
||||
public void buttonClick(GExtensionStore gExtensionStore) {
|
||||
int mode = mode();
|
||||
if (mode == 2) return;
|
||||
if (mode == 1) return;
|
||||
|
||||
String modeString = mode() == 0 ? "Install" : "Update";
|
||||
HOverview selff = this;
|
||||
@ -149,7 +149,7 @@ public class StoreExtensionDetailsOverview extends HOverview {
|
||||
if (mode() == 0) {
|
||||
StoreExtensionTools.installExtension(extension.getTitle(), storeRepository, listener);
|
||||
}
|
||||
else if (mode() == 1) {
|
||||
else if (mode() == 2) {
|
||||
StoreExtensionTools.updateExtension(extension.getTitle(), storeRepository, listener);
|
||||
}
|
||||
}
|
||||
|
@ -142,10 +142,14 @@ public class StoreExtensionTools {
|
||||
|
||||
} catch (MalformedURLException e) {
|
||||
listener.fail("Invalid extension URL");
|
||||
removeExtension(path); // cleanup
|
||||
try {
|
||||
removeExtension(path); // cleanup
|
||||
} catch (IOException ignore) { }
|
||||
} catch (IOException e) {
|
||||
listener.fail("Extension not available in repository");
|
||||
removeExtension(path); // cleanup
|
||||
try {
|
||||
removeExtension(path); // cleanup
|
||||
} catch (IOException ignore) { }
|
||||
}
|
||||
}
|
||||
else {
|
||||
@ -161,12 +165,8 @@ public class StoreExtensionTools {
|
||||
|
||||
}
|
||||
|
||||
public static void removeExtension(String extensionPath) {
|
||||
try {
|
||||
FileUtils.deleteDirectory(new File(extensionPath));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
public static void removeExtension(String extensionPath) throws IOException {
|
||||
FileUtils.deleteDirectory(new File(extensionPath));
|
||||
}
|
||||
|
||||
public static List<InstalledExtension> getInstalledExtension() {
|
||||
|
Loading…
Reference in New Issue
Block a user