-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prevent JMapStages hiding minimap if already hidden
Telling JourneyMap to hide the minimap causes JourneyMap to write its settings out to disk even if they haven't changed; this happens on the render thread and so can cause significant hangs opening the file, serializing and writing. This patch adds a check to see if the minimap is already hidden; if it is then we return early without rewriting the settings
- Loading branch information
Showing
3 changed files
with
38 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
src/main/java/tv/darkosto/sevpatches/core/patches/PatchJMapStagesStutter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package tv.darkosto.sevpatches.core.patches; | ||
|
||
import org.objectweb.asm.Opcodes; | ||
import org.objectweb.asm.tree.*; | ||
import tv.darkosto.sevpatches.core.utils.AsmUtils; | ||
|
||
public class PatchJMapStagesStutter extends Patch { | ||
public PatchJMapStagesStutter(byte[] inputClass) { | ||
super(inputClass); | ||
} | ||
|
||
@Override | ||
protected boolean patch() { | ||
MethodNode toggleMinimap = AsmUtils.findMethod(this.classNode, "toggleMinimap"); | ||
if (toggleMinimap == null) return false; | ||
|
||
InsnList insns = new InsnList(); | ||
LabelNode ln = new LabelNode(); | ||
|
||
/* | ||
if (enable == this.uiManager.isMiniMapEnabled()) return; | ||
*/ | ||
insns.add(new VarInsnNode(Opcodes.ALOAD, 0)); | ||
insns.add(new FieldInsnNode(Opcodes.GETFIELD, "net/darkhax/jmapstages/JMapPermissionHandler", "uiManager", "Ljourneymap/client/ui/UIManager;")); | ||
insns.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL, "journeymap/client/ui/UIManager", "isMiniMapEnabled", "()Z", false)); | ||
insns.add(new VarInsnNode(Opcodes.ILOAD, 1)); | ||
insns.add(new JumpInsnNode(Opcodes.IF_ICMPNE, ln)); | ||
insns.add(new InsnNode(Opcodes.RETURN)); | ||
insns.add(ln); | ||
|
||
toggleMinimap.instructions.insert(insns); | ||
|
||
return true; | ||
} | ||
} |