Skip to content

Commit

Permalink
Improve ime whitelist
Browse files Browse the repository at this point in the history
  • Loading branch information
kappa-maintainer committed Dec 21, 2024
1 parent effa043 commit 2214135
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
8 changes: 6 additions & 2 deletions src/main/java/com/cleanroommc/client/IMEHandler.java
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
package com.cleanroommc.client;

import com.cleanroommc.client.ime.CocoaIMEHandler;
import com.cleanroommc.client.ime.DummyIMEHandler;
import com.cleanroommc.client.ime.WindowsIMEHandler;
import net.minecraftforge.fml.common.FMLLog;
import org.lwjgl.glfw.GLFW;

import java.util.function.Consumer;

public class IMEHandler {
private static Consumer<Boolean> instance;
private static final Consumer<Boolean> instance;
static {
switch (GLFW.glfwGetPlatform()) {
case GLFW.GLFW_PLATFORM_WIN32 -> instance = new WindowsIMEHandler();
case GLFW.GLFW_PLATFORM_COCOA -> instance = new CocoaIMEHandler();
default -> FMLLog.log.warn("Unsupported platform: {}", GLFW.glfwGetPlatform());
default -> {
instance = new DummyIMEHandler();
FMLLog.log.warn("Unsupported platform: {}", GLFW.glfwGetPlatform());
}
}
}
public static void setIME(boolean active) {
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/net/minecraftforge/client/ForgeClientHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,13 @@
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;

import java.util.Arrays;
import java.util.Set;
import java.util.stream.Collectors;

public class ForgeClientHandler
{
private static final Set<String> classList = Arrays.stream(ForgeModContainer.inputMethodGuiWhiteList).collect(Collectors.toSet());
@SubscribeEvent
public static void registerModels(ModelRegistryEvent event)
{
Expand Down Expand Up @@ -76,11 +81,6 @@ public static void didChangeGui(GuiOpenEvent event) {

private static boolean guiInWhiteList(GuiScreen gui) {
String current = gui.getClass().getName();
for (String guiClazz : ForgeModContainer.inputMethodGuiWhiteList) {
if (guiClazz.equals(current)) {
return true;
}
}
return false;
return classList.contains(current);
}
}

0 comments on commit 2214135

Please sign in to comment.