2017-08-22 15:02:23 +02:00
|
|
|
package net.ME1312.SubServers.Sync.Network.Packet;
|
|
|
|
|
|
|
|
import net.ME1312.SubServers.Sync.Library.Config.YAMLSection;
|
2018-01-02 23:29:25 +01:00
|
|
|
import net.ME1312.SubServers.Sync.Library.NamedContainer;
|
2017-08-22 15:02:23 +02:00
|
|
|
import net.ME1312.SubServers.Sync.Library.Util;
|
|
|
|
import net.ME1312.SubServers.Sync.Library.Version.Version;
|
|
|
|
import net.ME1312.SubServers.Sync.Network.PacketIn;
|
|
|
|
import net.ME1312.SubServers.Sync.Network.PacketOut;
|
|
|
|
import net.ME1312.SubServers.Sync.SubPlugin;
|
|
|
|
|
2018-01-02 23:29:25 +01:00
|
|
|
import java.lang.reflect.Field;
|
2017-08-22 15:02:23 +02:00
|
|
|
import java.util.Calendar;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Download Lang Packet
|
|
|
|
*/
|
|
|
|
public class PacketDownloadLang implements PacketIn, PacketOut {
|
|
|
|
private SubPlugin plugin;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* New PacketDownloadLang (In)
|
|
|
|
*/
|
|
|
|
public PacketDownloadLang() {}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* New PacketDownloadLang (Out)
|
|
|
|
*
|
|
|
|
* @param plugin SubServers.Client
|
|
|
|
*/
|
|
|
|
public PacketDownloadLang(SubPlugin plugin) {
|
|
|
|
if (Util.isNull(plugin)) throw new NullPointerException();
|
|
|
|
this.plugin = plugin;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2018-04-15 03:53:51 +02:00
|
|
|
public YAMLSection generate() {
|
2017-08-22 15:02:23 +02:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2018-04-15 03:53:51 +02:00
|
|
|
public void execute(YAMLSection data) {
|
2018-01-02 23:29:25 +01:00
|
|
|
try {
|
2019-01-15 00:28:18 +01:00
|
|
|
Util.reflect(SubPlugin.class.getDeclaredField("lang"), plugin, new NamedContainer<>(Calendar.getInstance().getTime().getTime(), data.getSection("Lang").get()));
|
2018-01-02 23:29:25 +01:00
|
|
|
System.out.println("SubData > Lang Settings Downloaded");
|
|
|
|
} catch (IllegalAccessException | NoSuchFieldException e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
2017-08-22 15:02:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Version getVersion() {
|
|
|
|
return new Version("2.11.0a");
|
|
|
|
}
|
|
|
|
}
|