Skip to content

Commit

Permalink
fixed bug with empty lines + chat messages
Browse files Browse the repository at this point in the history
  • Loading branch information
hashblen committed Apr 29, 2022
1 parent 530a694 commit d110ffa
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions src/main/java/com/hashblen/macromod/MacroMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -191,16 +191,17 @@ public void onTick(TickEvent.ClientTickEvent e){
if(!srv && !mc.isSingleplayer()){
return;
}
if(lineList.isEmpty()) {
if(lineList==null) {
return;
}
if(tick>=lineList.size()){
if(isRunning && tick>=lineList.size() && !lineList.isEmpty()){
isRunning=false;
endMacro();
tick=0;
mc.thePlayer.addChatMessage(new ChatComponentText("\247cMacroMod: \247rStopped macro " + macroName));
}
if(e.phase==TickEvent.Phase.END ){
if(isRunning) {
if(isRunning && !lineList.isEmpty()) {
runTick(tick);
tick++;
}
Expand Down Expand Up @@ -230,7 +231,7 @@ public void onKey(InputEvent.KeyInputEvent e){
mc.thePlayer.addChatMessage(new ChatComponentText("\247cMacroMod: \247rStop the recording to be able to open the GUI"));
return;
}
if(isRunning){
if(isRunning && !lineList.isEmpty()){
mc.thePlayer.addChatMessage(new ChatComponentText("\247cMacroMod: \247rStop the playback to be able to open the GUI"));
return;
}
Expand All @@ -250,9 +251,16 @@ public void onKey(InputEvent.KeyInputEvent e){
return;
}
loadLines();
if(lineList.isEmpty()){
mc.thePlayer.addChatMessage(new ChatComponentText("\247cMacroMod: \247rMacro " + macroName + " is empty"));
return;
}
if(isRunning){
endMacro();
tick=0;
mc.thePlayer.addChatMessage(new ChatComponentText("\247cMacroMod: \247rStopped " + macroName));
}else{
mc.thePlayer.addChatMessage(new ChatComponentText("\247cMacroMod: \247rStarted " + macroName));
}
isRunning = !isRunning;
}
Expand All @@ -261,11 +269,11 @@ public void onKey(InputEvent.KeyInputEvent e){
mc.thePlayer.addChatMessage(new ChatComponentText("\247cMacroMod: \247rCan't record in GUIs yet"));
return;
}
if(!isRecording && !isRunning){
if(!isRecording && (!isRunning || lineList.isEmpty())){
loadLines();
mc.thePlayer.addChatMessage(new ChatComponentText("\247cMacroMod: \247rRecording started!"));
isRecording=true;
}else if(isRunning){
}else if(!isRecording){
mc.thePlayer.addChatMessage(new ChatComponentText("\247cMacroMod: \247rCan't record when playing!"));
}
else{
Expand Down

0 comments on commit d110ffa

Please sign in to comment.