Skip to content

Commit

Permalink
feat: add support getGameLanguage
Browse files Browse the repository at this point in the history
- добавлена поддержка getGameLanguage
- обновлён Nukkit-Mot
  • Loading branch information
Reider745 committed Dec 18, 2023
1 parent 1d26c8f commit 48ec25e
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 9 deletions.
Binary file modified iclibs/Nukkit-MOT-SNAPSHOT.jar
Binary file not shown.
15 changes: 13 additions & 2 deletions src/main/java/com/reider745/InnerCoreServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import cn.nukkit.Server;
import cn.nukkit.plugin.PluginDescription;

import cn.nukkit.plugin.PluginManager;
import com.reider745.api.CallbackHelper;
import com.reider745.block.CustomBlock;
import com.reider745.commands.CommandsHelper;
Expand Down Expand Up @@ -61,7 +62,14 @@ public static String getStringParam(String name) {
};
}

public void loadMods() {
public static String getGameLanguage() {
final String lang = server.getLanguage().getLang();

final StringBuilder icLang = new StringBuilder();
for(int i = 0;i < lang.length()-1;i++)
icLang.append(lang.indexOf(i));

return icLang.toString();
}

public void left() {
Expand Down Expand Up @@ -281,7 +289,9 @@ public void preload(Server server) throws Exception {

public void afterload() {
server.getLogger().info("Registering Nukkit-MOT containment...");
server.getPluginManager().registerEvents(new EventListener(), plugin);

Logger.info("Register events ZotCoreLoader");
InnerCoreServer.server.getPluginManager().registerEvents(new EventListener(), InnerCoreServer.plugin);

CustomBlock.init();
CustomItem.init();
Expand Down Expand Up @@ -310,6 +320,7 @@ public static String getName() {
}

public static void useNotSupport(String name) {
if(!isDevelopMode()) return;
String message = "Use not support multiplayer method " + name;
if (isRuntimeException()) {
throw new RuntimeException(message);
Expand Down
9 changes: 4 additions & 5 deletions src/main/java/com/reider745/event/EventListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,13 @@ public static void preventedCallback(Event event, CallbackHelper.ICallbackApply
CallbackHelper.apply(event, apply,false);
}

@EventHandler(priority = EventPriority.LOWEST)
@EventHandler
public void use(PlayerInteractEvent event) {
Vector3 pos = event.getTouchVector();
Block block = event.getBlock();
Player player = event.getPlayer();
PlayerInteractEvent.Action action = event.getAction();

if (action == PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK)
if (event.getAction() == PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK)
preventedCallback(event,
() -> NativeCallback.onItemUsed((int) block.x, (int) block.y, (int) block.z,
event.getFace().getIndex(), (float) pos.x, (float) pos.y, (float) pos.z, true,
Expand All @@ -62,14 +61,14 @@ public static void eventBreakBlock(BlockBreakEvent event, boolean isNukkitPreven
event.getFace().getIndex(), event.getPlayer().getId()), isNukkitPrevent);
}

@EventHandler(priority = EventPriority.LOWEST)
@EventHandler
public void playerEat(PlayerEatFoodEvent event) {
Food food = event.getFood();
preventedCallback(event, () -> NativeCallback.onPlayerEat(food.getRestoreFood(), food.getRestoreSaturation(),
event.getPlayer().getId()));
}

@EventHandler(priority = EventPriority.LOWEST)
@EventHandler
public void placeBlock(BlockPlaceEvent event) {
Block block = event.getBlock();
preventedCallback(event, () -> NativeCallback.onBlockBuild((int) block.x, (int) block.y, (int) block.z, 0,
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/com/zhekasmirnov/innercore/api/NativeAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ public static void getAtlasTextureCoords(String name, int data, float[] result)
}

public static String getGameLanguage() {
// InnerCoreServer.useNotCurrentSupport("NativeAPI.getGameLanguage()");
return "en";
return InnerCoreServer.getGameLanguage();
}

public static void preventPendingAppEvent(int event, int timeout) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import com.reider745.InnerCoreServer;
import com.reider745.entity.EntityMethod;
import com.reider745.event.EventListener;
import com.zhekasmirnov.apparatus.adapter.innercore.EngineConfig;
import com.zhekasmirnov.apparatus.adapter.innercore.game.Minecraft;
import com.zhekasmirnov.apparatus.adapter.innercore.game.block.BlockBreakResult;
Expand Down

0 comments on commit 48ec25e

Please sign in to comment.