Skip to content

Commit 6602e65

Browse files
committed
1.0.4
1 parent 2f8ef40 commit 6602e65

6 files changed

Lines changed: 51 additions & 47 deletions

File tree

src/main/java/com/hb/mcfdebugger/McfDebugger.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,5 @@ public static void LOG(Object msgObj){
6666
}
6767
}
6868

69+
public static boolean howeverStop = false;
6970
}

src/main/java/com/hb/mcfdebugger/commands/DebuggerCommand.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ public static void register(CommandDispatcher<ServerCommandSource> dispatcher) {
8383
public static int execute_getScoreByEntity(CommandContext<ServerCommandSource> cmd) throws CommandSyntaxException {
8484
if (!ConfigHolder.debuggerMode.equals("none")) {
8585
ReadScoreboard.parseScoreboardByEntity(cmd);
86+
McfDebugger.howeverStop=true;
8687
throw LOGGER_HIT_EXCEPTION.create();
8788
} else {
8889
return 1;
@@ -93,6 +94,7 @@ public static int execute_getScoreByEntity(CommandContext<ServerCommandSource> c
9394
public static int execute_getScoreByObjective(CommandContext<ServerCommandSource> cmd) throws CommandSyntaxException {
9495
if (!ConfigHolder.debuggerMode.equals("none")) {
9596
ReadScoreboard.parseScoreboardByObjective(cmd);
97+
McfDebugger.howeverStop=true;
9698
throw LOGGER_HIT_EXCEPTION.create();
9799
} else {
98100
return 1;
@@ -102,6 +104,7 @@ public static int execute_getScoreByObjective(CommandContext<ServerCommandSource
102104
public static int getEntity(CommandContext<ServerCommandSource> cmd) throws CommandSyntaxException {
103105
if (!ConfigHolder.debuggerMode.equals("none")) {
104106
GetEntity.get(cmd);
107+
McfDebugger.howeverStop=true;
105108
throw LOGGER_HIT_EXCEPTION.create();
106109
} else {
107110
return 1;

src/main/java/com/hb/mcfdebugger/mixin/ErrorHook.java

Lines changed: 13 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.hb.mcfdebugger.*;
44
import com.hb.mcfdebugger.config.ConfigHolder;
5+
import com.hb.mcfdebugger.mixinHelpers.ReadCommandSource;
56
import net.minecraft.server.command.ServerCommandSource;
67
import net.minecraft.server.function.CommandFunction;
78
import net.minecraft.server.function.CommandFunctionManager;
@@ -26,11 +27,11 @@ public void execute(ArrayDeque<CommandFunctionManager.Entry> stack, int maxChain
2627
try {
2728
element.execute(manager, source, stack, maxChainLength);
2829
} catch (Throwable var4) {
29-
if (!ConfigHolder.debuggerMode.equals("none")&&!ConfigHolder.nonStopOnException) {
30+
if (!ConfigHolder.debuggerMode.equals("none")) {
3031
String exceptionMsg = var4.toString();
3132
if (exceptionMsg != "") {
3233
if (McfDebugger.lastCmdObj!=null && !McfDebugger.lastCmdObj.toSimple().isNext(McfDebugger.nowMuteCmd)) {
33-
sendError(exceptionMsg);
34+
sendError(exceptionMsg,ConfigHolder.nonStopOnException?1:0);
3435

3536
}
3637
}
@@ -40,32 +41,18 @@ public void execute(ArrayDeque<CommandFunctionManager.Entry> stack, int maxChain
4041
McfDebugger.nowMuteCmd.clear();
4142
}
4243
}
43-
public void sendError(String message) {
44+
public void sendError(String message,int mode) {
4445
McfDebugger.lastCmdObj.exception=message;
4546
McfDebugger.lastCmdObj.pause=true;
46-
Map<String,String> sourceMap =new LinkedHashMap<>();
47-
if(source.getEntity()!=null){
48-
sourceMap.put("entityName",source.getEntity().getEntityName());
49-
sourceMap.put("entityUuid",source.getEntity().getUuidAsString());
50-
}else{
51-
sourceMap.put("entityName","None(Server)");
52-
sourceMap.put("entityUuid","None");
53-
}
54-
sourceMap.put("pos" ,source.getPosition().toString());
55-
sourceMap.put("rotation","("+source.getRotation().y+", "+source.getRotation().x+")");
56-
sourceMap.put("world",source.getWorld().getRegistryKey().getValue().toString());
57-
try {
58-
Method levelMethod = source.getClass().getDeclaredMethod("fakeGetLevel");
59-
sourceMap.put("level", String.valueOf(levelMethod.invoke(source)));
60-
} catch (ReflectiveOperationException e) {
61-
sourceMap.put("level","Error");
62-
}
63-
sourceMap.put("commandsLeftToMaxChainLength", String.valueOf(McfDebugger.commandsLeftToMaxChainLength));
64-
SendCmdObj sendCmdObj = new SendCmdObj(McfDebugger.lastCmdObj.funNamespace, McfDebugger.lastCmdObj.funPath, McfDebugger.lastCmdObj.cmdIndex, element.toString(),true,sourceMap);
47+
SendCmdObj sendCmdObj = new SendCmdObj(McfDebugger.lastCmdObj.funNamespace, McfDebugger.lastCmdObj.funPath, McfDebugger.lastCmdObj.cmdIndex, element.toString(),true, ReadCommandSource.read(source));
6548
sendCmdObj.exception=message;
66-
DebugThread.sendObjMsgToDebugger(McfDebugger.stackList,"stackReport");
67-
DebugThread.sendObjMsgToDebugger(sendCmdObj,"errorCommandReport");
68-
69-
PauseWaiter.WaitForNext();
49+
if(mode==0||McfDebugger.howeverStop){
50+
McfDebugger.howeverStop=false;
51+
DebugThread.sendObjMsgToDebugger(McfDebugger.stackList,"stackReport");
52+
DebugThread.sendObjMsgToDebugger(sendCmdObj,"errorCommandReport");
53+
PauseWaiter.WaitForNext();
54+
}else if (mode==1){
55+
DebugThread.sendObjMsgToDebugger(sendCmdObj,"nonStopErrorCommandReport");
56+
}
7057
}
7158
}

src/main/java/com/hb/mcfdebugger/mixinHelpers/FakeCommandFunctionCreate.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public static CommandFunction create(Identifier id, CommandDispatcher<ServerComm
4747
//modified
4848
ParseResults<ServerCommandSource> parseResults;
4949

50-
if(!string.substring(0,2).equals("#@")){
50+
if(!string.startsWith("#@")){
5151
parseResults = commandDispatcher.parse(stringReader, serverCommandSource);
5252
}else{
5353
parseResults = commandDispatcher.parse(new StringReader("debuggerCmd "+string.substring(2)), serverCommandSource);
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package com.hb.mcfdebugger.mixinHelpers;
2+
3+
import com.hb.mcfdebugger.McfDebugger;
4+
import net.minecraft.server.command.ServerCommandSource;
5+
6+
import java.lang.reflect.Method;
7+
import java.util.LinkedHashMap;
8+
import java.util.Map;
9+
10+
public class ReadCommandSource {
11+
public static Map<String,String> read(ServerCommandSource source){
12+
Map<String,String> sourceMap =new LinkedHashMap<>();
13+
if(source.getEntity()!=null){
14+
sourceMap.put("entityName",source.getEntity().getEntityName());
15+
sourceMap.put("entityUuid",source.getEntity().getUuidAsString());
16+
}else{
17+
sourceMap.put("entityName","None(Server)");
18+
sourceMap.put("entityUuid","None");
19+
}
20+
sourceMap.put("pos" ,source.getPosition().toString());
21+
sourceMap.put("rotation","("+source.getRotation().y+", "+source.getRotation().x+")");
22+
sourceMap.put("world",source.getWorld().getRegistryKey().getValue().toString());
23+
try {
24+
Method levelMethod = source.getClass().getDeclaredMethod("fakeGetLevel");
25+
sourceMap.put("level", String.valueOf(levelMethod.invoke(source)));
26+
} catch (ReflectiveOperationException e) {
27+
sourceMap.put("level","Error");
28+
}
29+
sourceMap.put("commandsLeftToMaxChainLength", String.valueOf(McfDebugger.commandsLeftToMaxChainLength));
30+
return sourceMap;
31+
}
32+
}

src/main/java/com/hb/mcfdebugger/mixinHelpers/SendCommandState.java

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -38,26 +38,7 @@ public static void send(CommandFunction.Element element, ServerCommandSource sou
3838
}
3939

4040
if(ConfigHolder.debuggerMode.equals("byStep")|| wsCommandParser.isInPauseList(funNamespace,funPath,cmdIndex)){
41-
42-
Map<String,String> sourceMap =new LinkedHashMap<>();
43-
if(source.getEntity()!=null){
44-
sourceMap.put("entityName",source.getEntity().getEntityName());
45-
sourceMap.put("entityUuid",source.getEntity().getUuidAsString());
46-
}else{
47-
sourceMap.put("entityName","None(Server)");
48-
sourceMap.put("entityUuid","None");
49-
}
50-
sourceMap.put("pos" ,source.getPosition().toString());
51-
sourceMap.put("rotation","("+source.getRotation().x+", "+source.getRotation().y+")");
52-
sourceMap.put("world",source.getWorld().getRegistryKey().getValue().toString());
53-
try {
54-
Method levelMethod = source.getClass().getDeclaredMethod("fakeGetLevel");
55-
sourceMap.put("level",String.valueOf(levelMethod.invoke(source)));
56-
} catch (ReflectiveOperationException e) {
57-
DebugThread.sendObjMsgToDebugger(e.getMessage(),"e");
58-
}
59-
sourceMap.put("commandsLeftToMaxChainLength", String.valueOf(McfDebugger.commandsLeftToMaxChainLength));
60-
SendCmdObj sendCmdObj = new SendCmdObj(funNamespace, funPath, cmdIndex, element.toString(),true,sourceMap);
41+
SendCmdObj sendCmdObj = new SendCmdObj(funNamespace, funPath, cmdIndex, element.toString(),true,ReadCommandSource.read(source));
6142
McfDebugger.lastCmdObj=sendCmdObj;
6243
DebugThread.sendObjMsgToDebugger(McfDebugger.stackList,"stackReport");
6344
DebugThread.sendObjMsgToDebugger(sendCmdObj,"commandReport");

0 commit comments

Comments
 (0)