From 4873b12890e7af0c7137c3cb25853d6e20361cd4 Mon Sep 17 00:00:00 2001
From: WolfieMario <wolfiemario@hotmail.com>
Date: Sat, 22 Mar 2014 13:48:04 -0600
Subject: Increment loop index whether or not command succeeded. Fixes
 BUKKIT-5455

When VanillaCommandWrapper dispatches a command containing a
PlayerSelector wtih c>-1 (implicitly true for @a), it loops over the
selected players and exectures the command with each player. However, the
loop index is only incremented if the command fails. As a result, a
successful command is repeated on the same player indefinitely, locking up
the server. This commit fixes the issue by incrementing the loop index
regardless of whether the command succeeds, ensuring the command is only
executed once per player identified by the PlayerSelector.
---
 .../java/org/bukkit/craftbukkit/command/VanillaCommandWrapper.java     | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/src/main/java/org/bukkit/craftbukkit/command/VanillaCommandWrapper.java b/src/main/java/org/bukkit/craftbukkit/command/VanillaCommandWrapper.java
index f63300fc..76fea00d 100644
--- a/src/main/java/org/bukkit/craftbukkit/command/VanillaCommandWrapper.java
+++ b/src/main/java/org/bukkit/craftbukkit/command/VanillaCommandWrapper.java
@@ -101,7 +101,7 @@ public final class VanillaCommandWrapper extends VanillaCommand {
                     String s2 = as[i];
                     EntityPlayer aentityplayer1[] = aentityplayer;
                     int k = aentityplayer1.length;
-                    for (int l = 0; l < k;) {
+                    for (int l = 0; l < k;l++) {
                         EntityPlayer entityplayer = aentityplayer1[l];
                         as[i] = entityplayer.getName();
                         try {
@@ -112,7 +112,6 @@ public final class VanillaCommandWrapper extends VanillaCommand {
                             ChatMessage chatmessage4 = new ChatMessage(commandexception1.getMessage(), commandexception1.a());
                             chatmessage4.getChatModifier().setColor(EnumChatFormat.RED);
                             icommandlistener.sendMessage(chatmessage4);
-                            l++;
                         }
                     }
 
-- 
cgit v1.2.3