Skip to content

Commit

Permalink
fix: баги
Browse files Browse the repository at this point in the history
- откат Nukkit-Mot
- добавлен try-catch на отправку пакета
  • Loading branch information
Reider745 committed Dec 16, 2023
1 parent c1bedc7 commit ca15087
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 2 deletions.
Binary file modified iclibs/Nukkit-MOT-SNAPSHOT.jar
Binary file not shown.
8 changes: 8 additions & 0 deletions src/main/java/com/reider745/entity/EntityMethod.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ public static Entity getEntityToLong(long ent){
return null;
}

public static Player getPlayerToLong(long ent){
for (Level level : InnerCoreServer.server.getLevels().values())
for (Player entity : level.getPlayers().values())
if(entity.getId() == ent)
return entity;
return null;
}

public static EntityHuman getEntityHumanToLong(long ent){
for (Level level : InnerCoreServer.server.getLevels().values())
for (Entity entity : level.getEntities())
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/reider745/item/CustomItemClass.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ public CustomItemClass(int id, Integer meta, int count, CustomManager manager) {

CompoundTag tag = getOrCreateNamedTag();

// tag.putInt("Damage", max_damage);

CompoundTag components = tag.getCompound("components");
if(components == null){
components = new CompoundTag();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
package com.zhekasmirnov.apparatus.multiplayer.server;

import cn.nukkit.Player;
import cn.nukkit.network.protocol.SetLocalPlayerAsInitializedPacket;
import com.reider745.InnerCoreServer;
import com.reider745.entity.EntityMethod;
import com.zhekasmirnov.apparatus.multiplayer.Network;
import com.zhekasmirnov.apparatus.multiplayer.ThreadTypeMarker;
import com.zhekasmirnov.apparatus.multiplayer.channel.ChannelInterface;
import com.zhekasmirnov.apparatus.multiplayer.channel.data.DataChannel;
import com.zhekasmirnov.apparatus.util.Java8BackComp;
import com.zhekasmirnov.horizon.runtime.logger.Logger;
import com.zhekasmirnov.innercore.api.InnerCoreConfig;
import com.zhekasmirnov.innercore.api.log.ICLog;
import org.json.JSONObject;

import java.io.IOException;
Expand Down Expand Up @@ -191,11 +195,31 @@ public InitializationPacketException getInitializationPacketFailureCause() {


public void send(String name, Object data) {
channel.send(name, data);
try{
channel.send(name, data);
}catch (Exception e){
ICLog.e("Network", "error send "+playerUid, e);

final Player player = EntityMethod.getPlayerToLong(playerUid);
if(player != null)
player.kick();
else
ICLog.i("Network", "error kick player");
}
}

public<T> void send(String name, T data, Class<T> dataType) {
channel.send(name, data, dataType);
try{
channel.send(name, data, dataType);
}catch (Exception e){
ICLog.e("Network", "error send "+playerUid, e);

final Player player = EntityMethod.getPlayerToLong(playerUid);
if(player != null)
player.kick();
else
ICLog.i("Network", "error kick player");
}
}

public void sendMessage(String message) {
Expand Down

0 comments on commit ca15087

Please sign in to comment.