BreakpointOperation class

Пакет: com.hypixel.hytale.builtin.buildertools.scriptedbrushes.operations.sequential

Файл: com/hypixel/hytale/builtin/buildertools/scriptedbrushes/operations/sequential/BreakpointOperation.java

extends: SequenceBrushOperation

Поля (7)

МодификаторыТипИмя
final HytaleLogger LOGGER
String var10
int var5
BrushConfigCommandExecutor.DebugOutputTarget var6
PlayerRef var7
String var8
boolean var9

Методы (6)

МодификаторыВозвратСигнатура
if if(var9)
if if(this.printState)
if if(this.enterStepMode)
private boolean shouldSendToChatboolean shouldSendToChat(BrushConfigCommandExecutor.DebugOutputTarget var1)
private boolean shouldSendToConsoleboolean shouldSendToConsole(BrushConfigCommandExecutor.DebugOutputTarget var1)
abstract super super("Breakpoint", "Debug breakpoint for scripted brushes", false)

Исходный код

Показать/скрыть
class="kw">package com.hypixel.hytale.builtin.buildertools.scriptedbrushes.operations.sequential;

class="kw">import com.hypixel.hytale.builtin.buildertools.scriptedbrushes.BrushConfig;
class="kw">import com.hypixel.hytale.builtin.buildertools.scriptedbrushes.BrushConfigCommandExecutor;
class="kw">import com.hypixel.hytale.builtin.buildertools.scriptedbrushes.operations.sequential.flowcontrol.JumpIfCompareOperation;
class="kw">import com.hypixel.hytale.builtin.buildertools.scriptedbrushes.operations.system.SequenceBrushOperation;
class="kw">import com.hypixel.hytale.codec.Codec;
class="kw">import com.hypixel.hytale.codec.KeyedCodec;
class="kw">import com.hypixel.hytale.codec.builder.BuilderCodec;
class="kw">import com.hypixel.hytale.component.ComponentAccessor;
class="kw">import com.hypixel.hytale.component.Ref;
class="kw">import com.hypixel.hytale.logger.HytaleLogger;
class="kw">import com.hypixel.hytale.server.core.Message;
class="kw">import com.hypixel.hytale.server.core.universe.PlayerRef;
class="kw">import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
class="kw">import java.util.logging.Level;
class="kw">import javax.annotation.Nonnull;
class="kw">import javax.annotation.Nullable;

class="kw">public class BreakpointOperation class="kw">extends SequenceBrushOperation {
   class="kw">private class="kw">static class="kw">final HytaleLogger LOGGER = HytaleLogger.forEnclosingClass();
   class="kw">public class="kw">static class="kw">final BuilderCodec<BreakpointOperation> CODEC = BuilderCodec.builder(BreakpointOperation.class, BreakpointOperation::new)
      .append(new KeyedCodec<>("Label", Codec.STRING), (var0, var1) -> var0.label = var1, var0 -> var0.label)
      .documentation("Identifier for this breakpoint")
      .add()
      .<Boolean>append(new KeyedCodec<>("PrintMessage", Codec.BOOLEAN), (var0, var1) -> var0.printMessage = var1, var0 -> var0.printMessage)
      .documentation("Print a message when breakpoint is reached")
      .add()
      .<Boolean>append(new KeyedCodec<>("PrintState", Codec.BOOLEAN), (var0, var1) -> var0.printState = var1, var0 -> var0.printState)
      .documentation("Print brush state when breakpoint is reached")
      .add()
      .<Boolean>append(new KeyedCodec<>("EnterStepMode", Codec.BOOLEAN), (var0, var1) -> var0.enterStepMode = var1, var0 -> var0.enterStepMode)
      .documentation("Enter step-through mode (use /sb step to class="kw">continue)")
      .add()
      .<JumpIfCompareOperation.BrushConfigIntegerComparison>append(
         new KeyedCodec<>("Condition", JumpIfCompareOperation.BrushConfigIntegerComparison.CODEC),
         (var0, var1) -> var0.condition = var1,
         var0 -> var0.condition
      )
      .documentation("Optional condition - breakpoint only triggers if condition passes")
      .add()
      .documentation("Debug breakpoint for scripted brushes")
      .build();
   @Nonnull
   class="kw">private String label = "";
   @Nonnull
   class="kw">private Boolean printMessage = false;
   @Nonnull
   class="kw">private Boolean printState = false;
   @Nonnull
   class="kw">private Boolean enterStepMode = false;
   @Nullable
   class="kw">private JumpIfCompareOperation.BrushConfigIntegerComparison condition = null;

   class="kw">public BreakpointOperation() {
      super("Breakpoint", "Debug breakpoint for scripted brushes", false);
   }

   @Override
   class="kw">public void modifyBrushConfig(
      @Nonnull Ref<EntityStore> var1, @Nonnull BrushConfig var2, @Nonnull BrushConfigCommandExecutor var3, @Nonnull ComponentAccessor<EntityStore> var4
   ) {
      if (var3.isEnableBreakpoints()) {
         if (this.condition == null || this.condition.apply(var2)) {
            int var5 = var3.getCurrentOperationIndex();
            BrushConfigCommandExecutor.DebugOutputTarget var6 = var3.getDebugOutputTarget();
            PlayerRef var7 = var4.getComponent(var1, PlayerRef.getComponentType());
            String var8 = this.label.isEmpty() ? "unnamed" : this.label;
            boolean var9 = this.printMessage || this.printState || this.enterStepMode;
            if (var9) {
               if (this.shouldSendToChat(var6) && var7 != null) {
                  var7.sendMessage(Message.translation("server.builderTools.brushConfig.debug.breakpointReached").param("label", var8).param("index", var5));
               }

               if (this.shouldSendToConsole(var6)) {
                  LOGGER.at(Level.INFO).log("[Breakpoint] '%s' reached at operation #%d", var8, var5);
               }
            }

            if (this.printState) {
               String var10 = var2.getInfo();
               if (this.shouldSendToChat(var6) && var7 != null) {
                  var7.sendMessage(Message.translation("server.builderTools.brushConfig.debug.breakpointState").param("index", var5).param("state", var10));
               }

               if (this.shouldSendToConsole(var6)) {
                  LOGGER.at(Level.INFO).log("[Breakpoint] [Operation #%d] %s", var5, var10);
               }
            }

            if (this.enterStepMode) {
               if (this.shouldSendToChat(var6) && var7 != null) {
                  var7.sendMessage(Message.translation("server.builderTools.brushConfig.debug.breakpointEnteringStepMode").param("label", var8));
               }

               if (this.shouldSendToConsole(var6)) {
                  LOGGER.at(Level.INFO).log("[Breakpoint] '%s' - Entering step-through mode", var8);
               }

               var3.setInDebugSteppingMode(true);
            }
         }
      }
   }

   class="kw">private boolean shouldSendToChat(BrushConfigCommandExecutor.DebugOutputTarget var1) {
      class="kw">return var1 == BrushConfigCommandExecutor.DebugOutputTarget.Chat || var1 == BrushConfigCommandExecutor.DebugOutputTarget.Both;
   }

   class="kw">private boolean shouldSendToConsole(BrushConfigCommandExecutor.DebugOutputTarget var1) {
      class="kw">return var1 == BrushConfigCommandExecutor.DebugOutputTarget.Console || var1 == BrushConfigCommandExecutor.DebugOutputTarget.Both;
   }
}