-
Notifications
You must be signed in to change notification settings - Fork 23
/
PacketExDownloadTemplates.java
50 lines (43 loc) · 1.65 KB
/
PacketExDownloadTemplates.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package net.ME1312.SubServers.Host.Network.Packet;
import net.ME1312.Galaxi.Engine.GalaxiEngine;
import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.Galaxi.Library.UniversalFile;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.SubData.Client.Protocol.PacketOut;
import net.ME1312.SubData.Client.Protocol.PacketStreamIn;
import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubServers.Host.ExHost;
import net.ME1312.SubServers.Host.SubAPI;
import java.io.InputStream;
/**
* External Host Template Download Packet
*/
public class PacketExDownloadTemplates implements PacketOut, PacketStreamIn {
private ExHost host;
/**
* New PacketExDownloadTemplates
*/
public PacketExDownloadTemplates(ExHost host) {
this.host = host;
}
@Override
public void sending(SubDataClient client) throws Throwable {
UniversalFile dir = new UniversalFile(GalaxiEngine.getInstance().getRuntimeDirectory(), "Templates");
if (dir.exists()) Util.deleteDirectory(dir);
host.log.info.println("Downloading Template Files...");
}
@Override
public void receive(SubDataClient client, InputStream stream) {
try {
Util.unzip(stream, new UniversalFile(GalaxiEngine.getInstance().getRuntimeDirectory(), "Templates"));
host.log.info.println("Template Files Downloaded");
} catch (Exception e) {
SubAPI.getInstance().getAppInfo().getLogger().error.println("Problem decoding template files");
SubAPI.getInstance().getAppInfo().getLogger().error.println(e);
}
}
@Override
public int version() {
return 0x0001;
}
}