Skip to content

Commit

Permalink
fix: Улучшен выхлоп от отладочных команд
Browse files Browse the repository at this point in the history
  • Loading branch information
MaXFeeD committed Jan 7, 2024
1 parent 913af1a commit df01c37
Show file tree
Hide file tree
Showing 10 changed files with 75 additions and 24 deletions.
17 changes: 12 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,12 @@ auto-save-period: 60
# Нужно ли помимо данных модов сохранять еще и миры.
auto-save-world: on

# Включен ли сокетный сервер или нет.
# Сокеты требуют дополнительного порта, подключение через серверные сокеты более стабильное.
# Включен ли сокетный сервер или нет. Сокеты требуют дополнительный порт,
# подключение через серверные сокеты более стабильное.
socket-server-enable: on

# Порт серверного сокета, обычно должен быть между 10000 и 24999.
# Но учтите, что по умолчанию клиент использует порт 2304.
socket-port: 2304
```
Expand All @@ -81,14 +82,20 @@ socket-port: 2304
+ custom_blocks — выводит список кастумных блоков
+ mods — выводит список модификаций на сервере
+ inner_core_network — выводит список подключенных к протоколу игроков на сервере
+ state — выводит state блока по runtimeId
+ state — выводит стейты блока по рантайм идентификатору
> Все команды предназначены для операторов и не могут быть вызваны игроками.
## Лицензия
![Licensing](/.github/license.jpg)
## Служебная информация
## Техническая информация
**Коммит из apparatus на котором основано ядро** - 73194cfd
| Ключ | Значение |
|---|---|
| Версия протокола | 422 (1.16.200) |
| Версия Horizon | 9 (1.2.0-android-12) |
| Коммит Apparatus | `73194cfd` |
| Коммит Instant Referrer | `a264591` |
| Коммит Nukkit-MOT | `2b53fb5` |
9 changes: 7 additions & 2 deletions src/main/java/com/reider745/InnerCoreServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import com.reider745.event.EventListener;
import com.reider745.event.InnerCorePlugin;
import com.reider745.hooks.BiomesHooks;
import com.reider745.hooks.SnowfallEverywhere;
import com.reider745.item.CustomItem;

import com.reider745.item.ItemMethod;
Expand Down Expand Up @@ -301,7 +302,9 @@ public void afterload() {

Logger.info("Registering ZoteCore events...");
pluginManager.registerEvents(new EventListener(), plugin);
// pluginManager.registerEvents(new SnowfallEverywhere(), plugin);
if (SnowfallEverywhere.isActive) {
pluginManager.registerEvents(new SnowfallEverywhere(), plugin);
}

CustomBlock.init();
CustomItem.postInit();
Expand All @@ -320,7 +323,9 @@ public void reload() {
PluginManager pluginManager = Server.getInstance().getPluginManager();
pluginManager.getPlugins().put(plugin.getDescription().getName(), plugin);
pluginManager.registerEvents(new EventListener(), plugin);
// pluginManager.registerEvents(new SnowfallEverywhere(), plugin);
if (SnowfallEverywhere.isActive) {
pluginManager.registerEvents(new SnowfallEverywhere(), plugin);
}
}

public void start() {
Expand Down
8 changes: 5 additions & 3 deletions src/main/java/com/reider745/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import cn.nukkit.Server;
import cn.nukkit.network.Network;

import java.util.Arrays;

import com.reider745.api.hooks.JarEditor;
import com.reider745.hooks.*;
import com.reider745.hooks.bugfix.EntityItemHooks;
Expand Down Expand Up @@ -76,9 +78,9 @@ public static void main(String[] args) throws Throwable {
loader.registerHooksInitializationForClass(ItemUtils.class);
loader.registerHooksInitializationForClass(AndroidHooks.class);

for(String arg : args)
if(arg.equals("-snowfall_everywhere"))
loader.registerHooksInitializationForClass(SnowfallEverywhere.class);
if (Arrays.stream(args).anyMatch("--snowfall-everywhere"::equals)) {
loader.registerHooksInitializationForClass(SnowfallEverywhere.class);
}

// loader.registerHooksInitializationForClass(BiomesHooks.class);
loader.registerHooksInitializationForClass(GlobalBanList.class);
Expand Down
10 changes: 8 additions & 2 deletions src/main/java/com/reider745/commands/CustomBlocksCommands.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import cn.nukkit.command.Command;
import cn.nukkit.command.CommandSender;
import cn.nukkit.utils.TextFormat;

import com.reider745.block.BlockStateRegisters;
import com.reider745.block.CustomBlock;
import com.reider745.item.ItemMethod;
Expand All @@ -22,11 +24,15 @@ public boolean execute(CommandSender commandSender, String commandLabel, String[
ArrayList<String> variants = CustomBlock.getOrgVariants(id);
for (int data = 0; data < variants.size(); data++)
list.append("\n" + ItemMethod.getNameForId(id, data, 0) + " -> " + id + ":" + data
+ " (runtimeId=" + BlockStateRegisters.getStateFor(id, data) + ", textId="
+ " (runtime=" + BlockStateRegisters.getStateFor(id, data) + ", named="
+ CustomBlock.getTextIdForNumber(id) + ")");
}

commandSender.sendMessage("Custom blocks (" + CustomBlock.blocks.size() + "):" + list.toString());
if (list.length() == 0) {
commandSender.sendMessage(TextFormat.YELLOW + "There are no custom blocks.");
} else {
commandSender.sendMessage("Custom blocks (" + CustomBlock.blocks.size() + "):" + list.toString());
}
return true;
}
}
10 changes: 8 additions & 2 deletions src/main/java/com/reider745/commands/CustomItemsCommands.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import cn.nukkit.command.Command;
import cn.nukkit.command.CommandSender;
import cn.nukkit.utils.TextFormat;

import com.reider745.api.CustomManager;
import com.reider745.item.CustomItem;
import com.reider745.item.ItemMethod;
Expand All @@ -19,11 +21,15 @@ public boolean execute(CommandSender commandSender, String commandLabel, String[
StringBuilder list = new StringBuilder();
for (Integer id : CustomItem.items.keySet()) {
CustomManager manager = CustomItem.getItemManager(id);
list.append("\n" + manager.get(ItemMethod.PropertiesNames.NAME) + " -> " + id + " (textId="
list.append("\n" + manager.get(ItemMethod.PropertiesNames.NAME) + " -> " + id + " (named="
+ CustomItem.getTextIdForNumber(id) + ")");
}

commandSender.sendMessage("Custom items (" + CustomItem.items.size() + "):\n"+list);
if (list.length() == 0) {
commandSender.sendMessage(TextFormat.YELLOW + "There are no custom items.");
} else {
commandSender.sendMessage("Custom items (" + CustomItem.items.size() + "):" + list.toString());
}
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,15 @@ public boolean execute(CommandSender commandSender, String s, String[] args) {
}
Player player = EntityMethod.getPlayerById(client.getPlayerUid());
list.append("\n" + (player != null ? player.getName() : "...") + " -> " + client.getPlayerUid()
+ " (state=" + client.getClientState().toString() + ", protocolId="
+ " (state=" + client.getClientState().toString() + ", protocol="
+ client.getChannelInterface().getChannel().getProtocolId() + ")");
}

commandSender.sendMessage("Clients (" + clients.size() + "):" + list.toString());
if (list.length() == 0) {
commandSender.sendMessage(TextFormat.YELLOW + "There are no clients.");
} else {
commandSender.sendMessage("Clients (" + clients.size() + "):" + list.toString());
}
return true;
}
}
6 changes: 5 additions & 1 deletion src/main/java/com/reider745/commands/ModsListCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@ public boolean execute(CommandSender commandSender, String commandLabel, String[
}
}

commandSender.sendMessage("Mods (" + mods.size() + "): " + list.toString());
if (list.length() == 0) {
commandSender.sendMessage(TextFormat.YELLOW + "There are no mods, check if correct modpack is selected.");
} else {
commandSender.sendMessage("Mods (" + mods.size() + "): " + list.toString());
}
return true;
}
}
15 changes: 13 additions & 2 deletions src/main/java/com/reider745/commands/StateCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@
import cn.nukkit.command.CommandSender;
import cn.nukkit.command.data.CommandParamType;
import cn.nukkit.command.data.CommandParameter;
import cn.nukkit.utils.TextFormat;

import java.util.Map;

import com.reider745.block.BlockStateRegisters;

public class StateCommand extends Command {
public StateCommand() {
super("state", "Gets block state of requested runtimeId");
super("state", "Gets block state of requested runtime identifier");
this.commandParameters.clear();
this.commandParameters.put("default", new CommandParameter[] {
new CommandParameter("runtimeId", CommandParamType.INT, false),
Expand All @@ -20,7 +24,14 @@ public boolean execute(CommandSender commandSender, String s, String[] args) {
if (!commandSender.isOp() || args.length < 1)
return false;

commandSender.sendMessage(BlockStateRegisters.getStateFor(Integer.parseInt(args[0])).toString());
Map<String, Integer> states = BlockStateRegisters.getStateFor(Integer.parseInt(args[0]));
if (states == null) {
commandSender.sendMessage(TextFormat.RED + "There are no block with runtime identifier " + args[0] + "!");
} else if (states.size() == 0) {
commandSender.sendMessage(TextFormat.YELLOW + "There are no states with requested identifier.");
} else {
commandSender.sendMessage(states.toString());
}
return true;
}
}
12 changes: 9 additions & 3 deletions src/main/java/com/reider745/hooks/SnowfallEverywhere.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,20 @@
import java.nio.ByteOrder;
import it.unimi.dsi.fastutil.ints.IntSet;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
import javassist.CtClass;

/**
* Special christmas adaptation, do not use anywhere else.
*/
@Hooks
@Hooks(className = "cn.nukkit.level.format.generic.serializer.NetworkChunkSerializer")
public class SnowfallEverywhere implements HookClass, Listener {
public static boolean isActive = false;

@Inject(className = "cn.nukkit.level.format.generic.serializer.NetworkChunkSerializer")
public void init(CtClass clazz) {
isActive = true;
}

@Inject
public static void serialize(IntSet protocols, BaseChunk chunk,
Consumer<NetworkChunkSerializer.NetworkChunkSerializerCallback> callback, DimensionData dimensionData) {
for (int protocolId : protocols) {
Expand All @@ -55,7 +61,7 @@ public static void serialize(IntSet protocols, BaseChunk chunk,

BinaryStream stream = ThreadCache.binaryStream.get().reset();
for (int i = 0; i < subChunkCount; i++) {
sections[i].writeTo(protocolId, stream);
sections[i].writeTo(protocolId, stream, false);
}

stream.put(toSnowfallBiomeIdArray(chunk.getBiomeIdArray()));
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/zotecore.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,5 @@ pack-version-code: 152
# socket-server-enable: off

# Server socket port, usually should be between 10000 and 24999.
# use 2304, since this is the default port on the client
# socket-port: 2304
# But keep in mind that the client uses port 2304 by default.
# socket-port: 19131

0 comments on commit df01c37

Please sign in to comment.