Skip to content
This repository was archived by the owner on Jan 3, 2020. It is now read-only.

Commit bd26e34

Browse files
committed
disable when typing commands
1 parent b69e85f commit bd26e34

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

src/main/java/org/devinprogress/YAIF/Bridges/GuiChatBridge.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public class GuiChatBridge implements IActionBridge {
2121
private GuiTextField txt=null;
2222
private InputFieldWrapper wrapper=null;
2323

24+
private boolean isCmd=false;
2425
private static Method keyTypedMethod=null;
2526

2627
public GuiChatBridge(GuiTextField textField,GuiChat screen,InputFieldWrapper wrapper){
@@ -39,6 +40,22 @@ public GuiChatBridge(GuiTextField textField,GuiChat screen,InputFieldWrapper wra
3940
}
4041
}
4142
}
43+
44+
for(Field f:screen.getClass().getDeclaredFields()){
45+
if(f.getType().equals(String.class)){
46+
String def="";
47+
try {
48+
f.setAccessible(true);
49+
def=(String)(f.get(screen));
50+
}catch(Exception e){
51+
e.printStackTrace();
52+
}
53+
if(def.equals("/")){
54+
isCmd=true;
55+
break;
56+
}
57+
}
58+
}
4259
}
4360

4461
@Override
@@ -101,4 +118,8 @@ public ActionFeedback onDown(JTextField txt) {
101118
public boolean sameAs(GuiScreen screen, GuiTextField txtField) {
102119
return this.screen==screen && txtField==txt;
103120
}
121+
122+
public boolean isCommand(){
123+
return isCmd;
124+
}
104125
}

src/main/java/org/devinprogress/YAIF/InputFieldWrapper.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,13 @@ public void DoActions(IActionBridge.ActionFeedback action, Object obj){
199199
private IActionBridge getBridge(){//Remember to add cases here if new Bridges added.
200200
if(bridge!=null&&bridge.sameAs(YetAnotherInputFix.currentGuiScreen,YetAnotherInputFix.currentTextField))
201201
return bridge;
202-
if(YetAnotherInputFix.currentGuiScreen instanceof GuiChat)
203-
return new GuiChatBridge(YetAnotherInputFix.currentTextField, (GuiChat)YetAnotherInputFix.currentGuiScreen,this);
202+
if(YetAnotherInputFix.currentGuiScreen instanceof GuiChat) {
203+
GuiChatBridge b = new GuiChatBridge(YetAnotherInputFix.currentTextField, (GuiChat) YetAnotherInputFix.currentGuiScreen, this);
204+
if(b.isCommand())
205+
return null;
206+
else
207+
return b;
208+
}
204209
else if(YetAnotherInputFix.currentGuiScreen instanceof GuiEditSign)
205210
return new EditSignBridge((GuiEditSign)YetAnotherInputFix.currentGuiScreen,this);
206211
else

0 commit comments

Comments
 (0)