Fixed server crashes
This commit is contained in:
parent
d4c9695e5c
commit
c28a566c78
2 changed files with 14 additions and 8 deletions
|
@ -29,9 +29,17 @@ public class DataExchangeAPI extends DataExchange {
|
|||
* You should never need to create a custom instance of this Object.
|
||||
*/
|
||||
public DataExchangeAPI() {
|
||||
super((api) -> new ConnectorClientside(api), (api) -> new ConnectorServerside(api));
|
||||
super();
|
||||
}
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
protected ConnectorClientside clientSupplier(DataExchange api) {
|
||||
return new ConnectorClientside(api);
|
||||
}
|
||||
|
||||
protected ConnectorServerside serverSupplier(DataExchange api) {
|
||||
return new ConnectorServerside(api);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a mod to participate in the DataExchange.
|
||||
|
|
|
@ -182,13 +182,11 @@ abstract public class DataExchange {
|
|||
protected final Set<DataHandlerDescriptor> descriptors;
|
||||
protected final List<AutoFileSyncEntry> autoSyncFiles = new ArrayList<>(4);
|
||||
|
||||
private final Function<DataExchange, ConnectorClientside> clientSupplier;
|
||||
private final Function<DataExchange, ConnectorServerside> serverSupplier;
|
||||
abstract protected ConnectorClientside clientSupplier(DataExchange api);
|
||||
abstract protected ConnectorServerside serverSupplier(DataExchange api);
|
||||
|
||||
protected DataExchange(Function<DataExchange, ConnectorClientside> client, Function<DataExchange, ConnectorServerside> server){
|
||||
protected DataExchange(){
|
||||
descriptors = new HashSet<>();
|
||||
this.clientSupplier = client;
|
||||
this.serverSupplier = server;
|
||||
}
|
||||
|
||||
public Set<DataHandlerDescriptor> getDescriptors() { return descriptors; }
|
||||
|
@ -196,7 +194,7 @@ abstract public class DataExchange {
|
|||
@Environment(EnvType.CLIENT)
|
||||
protected void initClientside(){
|
||||
if (client!=null) return;
|
||||
client = clientSupplier.apply(this);
|
||||
client = clientSupplier(this);
|
||||
ClientLoginConnectionEvents.INIT.register((a, b) ->{
|
||||
System.out.println("INIT");
|
||||
});
|
||||
|
@ -210,7 +208,7 @@ abstract public class DataExchange {
|
|||
|
||||
protected void initServerSide(){
|
||||
if (server!=null) return;
|
||||
server = serverSupplier.apply(this);
|
||||
server = serverSupplier(this);
|
||||
|
||||
ServerPlayConnectionEvents.INIT.register(server::onPlayInit);
|
||||
ServerPlayConnectionEvents.JOIN.register(server::onPlayReady);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue