Uploaded image for project: 'Minecraft: Java Edition'
  1. Minecraft: Java Edition
  2. MC-182362

Score callbacks with a too long name break callback chain

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • 21w37a
    • 1.15.2, 20w18a, 20w20b, 1.16 Pre-release 5, 1.16.1, 1.16.2 Pre-release 1, 1.16.2, 1.16.3, 1.16.4 Pre-release 1, 1.16.4, 20w45a, 20w46a, 20w48a, 20w49a, 20w51a, 21w03a, 1.16.5, 21w10a, 21w11a, 21w15a, 21w16a, 21w19a, 1.17 Pre-release 1, 1.17, 1.17.1
    • Confirmed
    • Commands

      The bug

      If a score callback corresponding to /execute store (result|success) score <targets> <objective> contains targets with 41 or more characters, it throws java.lang.IllegalArgumentException while executing the chained callbacks.
      This causes the remaining callbacks not to be executed.

      How to reproduce

      1. /scoreboard objectives add mc-182362 dummy
      2. /execute store success score a mc-182362 store success score _________________________________________ mc-182362 store success score b mc-182362 run me *

        An unexpected error occurred trying to execute that command (The player name '_________________________________________' is too long!)

      3. /scoreboard players get a mc-182362

        a has 1 [mc-182362], the callback corresponding to /execute store success score a mc-182362 is successfully executed.

      4. /scoreboard players get b mc-182362

        Can't get value of mc-182362 for b; none is set, the callback corresponding to /execute store success score b mc-182362 is not executed.

      Code analysis

      Scoreboard#getOrCreatePlayerScore throws IllegalArgumentException iff target.length() > 40 at runtime. This breaks the callback chain created by CALLBACK_CHAINER.

      // net.minecraft.server.commands.ExecuteCommand
      
      private static CommandSourceStack storeValue(CommandSourceStack source, Collection<String> targets, Objective objective, boolean result) {
          Scoreboard scoreboard = source.getServer().getScoreboard();
          return source.withCallback((c, s, r) -> {
              for (String target : targets) {
                  Score score = scoreboard.getOrCreatePlayerScore(target, objective);
                  int count = result ? r : (s ? 1 : 0);
                  score.setScore(count);
              }
          }, CALLBACK_CHAINER);
      }

            boq [Mojang] Bartosz Bok
            intsuc intsuc
            Votes:
            4 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:
              CHK: