    001package net.minecraft.scoreboard;
    002
    003import java.util.ArrayList;
    004import java.util.Arrays;
    005import java.util.Collection;
    006import java.util.HashSet;
    007import java.util.Iterator;
    008import java.util.List;
    009import java.util.Map;
    010import net.minecraft.command.CommandBase;
    011import net.minecraft.command.CommandException;
    012import net.minecraft.command.ICommandSender;
    013import net.minecraft.command.SyntaxErrorException;
    014import net.minecraft.command.WrongUsageException;
    015import net.minecraft.entity.player.EntityPlayer;
    016import net.minecraft.server.MinecraftServer;
    017import net.minecraft.util.EnumChatFormatting;
    018
    019public class ServerCommandScoreboard extends CommandBase
    020{
    021    public String getCommandName()
    022    {
    023        return "scoreboard";
    024    }
    025
    026    /**
    027     * Return the required permission level for this command.
    028     */
    029    public int getRequiredPermissionLevel()
    030    {
    031        return 2;
    032    }
    033
    034    public void processCommand(ICommandSender par1ICommandSender, String[] par2ArrayOfStr)
    035    {
    036        if (par2ArrayOfStr.length >= 1)
    037        {
    038            if (par2ArrayOfStr[0].equalsIgnoreCase("objectives"))
    039            {
    040                if (par2ArrayOfStr.length == 1)
    041                {
    042                    throw new WrongUsageException("commands.scoreboard.objectives.usage", new Object[0]);
    043                }
    044
    045                if (par2ArrayOfStr[1].equalsIgnoreCase("list"))
    046                {
    047                    this.func_96336_d(par1ICommandSender);
    048                }
    049                else if (par2ArrayOfStr[1].equalsIgnoreCase("add"))
    050                {
    051                    if (par2ArrayOfStr.length < 4)
    052                    {
    053                        throw new WrongUsageException("commands.scoreboard.objectives.add.usage", new Object[0]);
    054                    }
    055
    056                    this.func_96350_b(par1ICommandSender, par2ArrayOfStr, 2);
    057                }
    058                else if (par2ArrayOfStr[1].equalsIgnoreCase("remove"))
    059                {
    060                    if (par2ArrayOfStr.length != 3)
    061                    {
    062                        throw new WrongUsageException("commands.scoreboard.objectives.remove.usage", new Object[0]);
    063                    }
    064
    065                    this.func_96337_e(par1ICommandSender, par2ArrayOfStr[2]);
    066                }
    067                else
    068                {
    069                    if (!par2ArrayOfStr[1].equalsIgnoreCase("setdisplay"))
    070                    {
    071                        throw new WrongUsageException("commands.scoreboard.objectives.usage", new Object[0]);
    072                    }
    073
    074                    if (par2ArrayOfStr.length != 3 && par2ArrayOfStr.length != 4)
    075                    {
    076                        throw new WrongUsageException("commands.scoreboard.objectives.setdisplay.usage", new Object[0]);
    077                    }
    078
    079                    this.func_96347_j(par1ICommandSender, par2ArrayOfStr, 2);
    080                }
    081
    082                return;
    083            }
    084
    085            if (par2ArrayOfStr[0].equalsIgnoreCase("players"))
    086            {
    087                if (par2ArrayOfStr.length == 1)
    088                {
    089                    throw new WrongUsageException("commands.scoreboard.players.usage", new Object[0]);
    090                }
    091
    092                if (par2ArrayOfStr[1].equalsIgnoreCase("list"))
    093                {
    094                    if (par2ArrayOfStr.length > 3)
    095                    {
    096                        throw new WrongUsageException("commands.scoreboard.players.list.usage", new Object[0]);
    097                    }
    098
    099                    this.func_96341_k(par1ICommandSender, par2ArrayOfStr, 2);
    100                }
    101                else if (par2ArrayOfStr[1].equalsIgnoreCase("add"))
    102                {
    103                    if (par2ArrayOfStr.length != 5)
    104                    {
    105                        throw new WrongUsageException("commands.scoreboard.players.add.usage", new Object[0]);
    106                    }
    107
    108                    this.func_96339_l(par1ICommandSender, par2ArrayOfStr, 2);
    109                }
    110                else if (par2ArrayOfStr[1].equalsIgnoreCase("remove"))
    111                {
    112                    if (par2ArrayOfStr.length != 5)
    113                    {
    114                        throw new WrongUsageException("commands.scoreboard.players.remove.usage", new Object[0]);
    115                    }
    116
    117                    this.func_96339_l(par1ICommandSender, par2ArrayOfStr, 2);
    118                }
    119                else if (par2ArrayOfStr[1].equalsIgnoreCase("set"))
    120                {
    121                    if (par2ArrayOfStr.length != 5)
    122                    {
    123                        throw new WrongUsageException("commands.scoreboard.players.set.usage", new Object[0]);
    124                    }
    125
    126                    this.func_96339_l(par1ICommandSender, par2ArrayOfStr, 2);
    127                }
    128                else
    129                {
    130                    if (!par2ArrayOfStr[1].equalsIgnoreCase("reset"))
    131                    {
    132                        throw new WrongUsageException("commands.scoreboard.players.usage", new Object[0]);
    133                    }
    134
    135                    if (par2ArrayOfStr.length != 3)
    136                    {
    137                        throw new WrongUsageException("commands.scoreboard.players.reset.usage", new Object[0]);
    138                    }
    139
    140                    this.func_96351_m(par1ICommandSender, par2ArrayOfStr, 2);
    141                }
    142
    143                return;
    144            }
    145
    146            if (par2ArrayOfStr[0].equalsIgnoreCase("teams"))
    147            {
    148                if (par2ArrayOfStr.length == 1)
    149                {
    150                    throw new WrongUsageException("commands.scoreboard.teams.usage", new Object[0]);
    151                }
    152
    153                if (par2ArrayOfStr[1].equalsIgnoreCase("list"))
    154                {
    155                    if (par2ArrayOfStr.length > 3)
    156                    {
    157                        throw new WrongUsageException("commands.scoreboard.teams.list.usage", new Object[0]);
    158                    }
    159
    160                    this.func_96344_f(par1ICommandSender, par2ArrayOfStr, 2);
    161                }
    162                else if (par2ArrayOfStr[1].equalsIgnoreCase("add"))
    163                {
    164                    if (par2ArrayOfStr.length < 3)
    165                    {
    166                        throw new WrongUsageException("commands.scoreboard.teams.add.usage", new Object[0]);
    167                    }
    168
    169                    this.func_96340_c(par1ICommandSender, par2ArrayOfStr, 2);
    170                }
    171                else if (par2ArrayOfStr[1].equalsIgnoreCase("remove"))
    172                {
    173                    if (par2ArrayOfStr.length != 3)
    174                    {
    175                        throw new WrongUsageException("commands.scoreboard.teams.remove.usage", new Object[0]);
    176                    }
    177
    178                    this.func_96343_e(par1ICommandSender, par2ArrayOfStr, 2);
    179                }
    180                else if (par2ArrayOfStr[1].equalsIgnoreCase("empty"))
    181                {
    182                    if (par2ArrayOfStr.length != 3)
    183                    {
    184                        throw new WrongUsageException("commands.scoreboard.teams.empty.usage", new Object[0]);
    185                    }
    186
    187                    this.func_96346_i(par1ICommandSender, par2ArrayOfStr, 2);
    188                }
    189                else if (par2ArrayOfStr[1].equalsIgnoreCase("join"))
    190                {
    191                    if (par2ArrayOfStr.length < 4 && (par2ArrayOfStr.length != 3 || !(par1ICommandSender instanceof EntityPlayer)))
    192                    {
    193                        throw new WrongUsageException("commands.scoreboard.teams.join.usage", new Object[0]);
    194                    }
    195
    196                    this.func_96342_g(par1ICommandSender, par2ArrayOfStr, 2);
    197                }
    198                else if (par2ArrayOfStr[1].equalsIgnoreCase("leave"))
    199                {
    200                    if (par2ArrayOfStr.length < 3 && !(par1ICommandSender instanceof EntityPlayer))
    201                    {
    202                        throw new WrongUsageException("commands.scoreboard.teams.leave.usage", new Object[0]);
    203                    }
    204
    205                    this.func_96349_h(par1ICommandSender, par2ArrayOfStr, 2);
    206                }
    207                else
    208                {
    209                    if (!par2ArrayOfStr[1].equalsIgnoreCase("option"))
    210                    {
    211                        throw new WrongUsageException("commands.scoreboard.teams.usage", new Object[0]);
    212                    }
    213
    214                    if (par2ArrayOfStr.length != 4 && par2ArrayOfStr.length != 5)
    215                    {
    216                        throw new WrongUsageException("commands.scoreboard.teams.option.usage", new Object[0]);
    217                    }
    218
    219                    this.func_96348_d(par1ICommandSender, par2ArrayOfStr, 2);
    220                }
    221
    222                return;
    223            }
    224        }
    225
    226        throw new WrongUsageException("commands.scoreboard.usage", new Object[0]);
    227    }
    228
    229    protected Scoreboard func_96334_d()
    230    {
    231        return MinecraftServer.getServer().worldServerForDimension(0).func_96441_U();
    232    }
    233
    234    protected ScoreObjective func_96345_a(String par1Str, boolean par2)
    235    {
    236        Scoreboard scoreboard = this.func_96334_d();
    237        ScoreObjective scoreobjective = scoreboard.func_96518_b(par1Str);
    238
    239        if (scoreobjective == null)
    240        {
    241            throw new CommandException("commands.scoreboard.objectiveNotFound", new Object[] {par1Str});
    242        }
    243        else if (par2 && scoreobjective.func_96680_c().func_96637_b())
    244        {
    245            throw new CommandException("commands.scoreboard.objectiveReadOnly", new Object[] {par1Str});
    246        }
    247        else
    248        {
    249            return scoreobjective;
    250        }
    251    }
    252
    253    protected ScorePlayerTeam func_96338_a(String par1Str)
    254    {
    255        Scoreboard scoreboard = this.func_96334_d();
    256        ScorePlayerTeam scoreplayerteam = scoreboard.func_96508_e(par1Str);
    257
    258        if (scoreplayerteam == null)
    259        {
    260            throw new CommandException("commands.scoreboard.teamNotFound", new Object[] {par1Str});
    261        }
    262        else
    263        {
    264            return scoreplayerteam;
    265        }
    266    }
    267
    268    protected void func_96350_b(ICommandSender par1ICommandSender, String[] par2ArrayOfStr, int par3)
    269    {
    270        String s = par2ArrayOfStr[par3++];
    271        String s1 = par2ArrayOfStr[par3++];
    272        Scoreboard scoreboard = this.func_96334_d();
    273        ScoreObjectiveCriteria scoreobjectivecriteria = (ScoreObjectiveCriteria)ScoreObjectiveCriteria.field_96643_a.get(s1);
    274
    275        if (scoreobjectivecriteria == null)
    276        {
    277            String[] astring1 = (String[])ScoreObjectiveCriteria.field_96643_a.keySet().toArray(new String[0]);
    278            throw new WrongUsageException("commands.scoreboard.objectives.add.wrongType", new Object[] {joinNiceString(astring1)});
    279        }
    280        else if (scoreboard.func_96518_b(s) != null)
    281        {
    282            throw new CommandException("commands.scoreboard.objectives.add.alreadyExists", new Object[] {s});
    283        }
    284        else if (s.length() > 16)
    285        {
    286            throw new SyntaxErrorException("commands.scoreboard.objectives.add.tooLong", new Object[] {s, Integer.valueOf(16)});
    287        }
    288        else
    289        {
    290            ScoreObjective scoreobjective = scoreboard.func_96535_a(s, scoreobjectivecriteria);
    291
    292            if (par2ArrayOfStr.length > par3)
    293            {
    294                String s2 = func_82360_a(par1ICommandSender, par2ArrayOfStr, par3);
    295
    296                if (s2.length() > 32)
    297                {
    298                    throw new SyntaxErrorException("commands.scoreboard.objectives.add.displayTooLong", new Object[] {s2, Integer.valueOf(32)});
    299                }
    300
    301                if (s2.length() > 0)
    302                {
    303                    scoreobjective.func_96681_a(s2);
    304                }
    305            }
    306
    307            notifyAdmins(par1ICommandSender, "commands.scoreboard.objectives.add.success", new Object[] {s});
    308        }
    309    }
    310
    311    protected void func_96340_c(ICommandSender par1ICommandSender, String[] par2ArrayOfStr, int par3)
    312    {
    313        String s = par2ArrayOfStr[par3++];
    314        Scoreboard scoreboard = this.func_96334_d();
    315
    316        if (scoreboard.func_96508_e(s) != null)
    317        {
    318            throw new CommandException("commands.scoreboard.teams.add.alreadyExists", new Object[] {s});
    319        }
    320        else if (s.length() > 16)
    321        {
    322            throw new SyntaxErrorException("commands.scoreboard.teams.add.tooLong", new Object[] {s, Integer.valueOf(16)});
    323        }
    324        else
    325        {
    326            ScorePlayerTeam scoreplayerteam = scoreboard.func_96527_f(s);
    327
    328            if (par2ArrayOfStr.length > par3)
    329            {
    330                String s1 = func_82360_a(par1ICommandSender, par2ArrayOfStr, par3);
    331
    332                if (s1.length() > 32)
    333                {
    334                    throw new SyntaxErrorException("commands.scoreboard.teams.add.displayTooLong", new Object[] {s1, Integer.valueOf(32)});
    335                }
    336
    337                if (s1.length() > 0)
    338                {
    339                    scoreplayerteam.func_96664_a(s1);
    340                }
    341            }
    342
    343            notifyAdmins(par1ICommandSender, "commands.scoreboard.teams.add.success", new Object[] {s});
    344        }
    345    }
    346
    347    protected void func_96348_d(ICommandSender par1ICommandSender, String[] par2ArrayOfStr, int par3)
    348    {
    349        ScorePlayerTeam scoreplayerteam = this.func_96338_a(par2ArrayOfStr[par3++]);
    350        String s = par2ArrayOfStr[par3++].toLowerCase();
    351
    352        if (!s.equalsIgnoreCase("color") && !s.equalsIgnoreCase("friendlyfire") && !s.equalsIgnoreCase("seeFriendlyInvisibles"))
    353        {
    354            throw new WrongUsageException("commands.scoreboard.teams.option.usage", new Object[0]);
    355        }
    356        else if (par2ArrayOfStr.length == 4)
    357        {
    358            if (s.equalsIgnoreCase("color"))
    359            {
    360                throw new WrongUsageException("commands.scoreboard.teams.option.noValue", new Object[] {s, func_96333_a(EnumChatFormatting.func_96296_a(true, false))});
    361            }
    362            else if (!s.equalsIgnoreCase("friendlyfire") && !s.equalsIgnoreCase("seeFriendlyInvisibles"))
    363            {
    364                throw new WrongUsageException("commands.scoreboard.teams.option.usage", new Object[0]);
    365            }
    366            else
    367            {
    368                throw new WrongUsageException("commands.scoreboard.teams.option.noValue", new Object[] {s, func_96333_a(Arrays.asList(new String[]{"true", "false"}))});
    369            }
    370        }
    371        else
    372        {
    373            String s1 = par2ArrayOfStr[par3++];
    374
    375            if (s.equalsIgnoreCase("color"))
    376            {
    377                EnumChatFormatting enumchatformatting = EnumChatFormatting.func_96300_b(s1);
    378
    379                if (s1 == null)
    380                {
    381                    throw new WrongUsageException("commands.scoreboard.teams.option.noValue", new Object[] {s, func_96333_a(EnumChatFormatting.func_96296_a(true, false))});
    382                }
    383
    384                scoreplayerteam.func_96666_b(enumchatformatting.toString());
    385                scoreplayerteam.func_96662_c(EnumChatFormatting.RESET.toString());
    386            }
    387            else if (s.equalsIgnoreCase("friendlyfire"))
    388            {
    389                if (!s1.equalsIgnoreCase("true") && !s1.equalsIgnoreCase("false"))
    390                {
    391                    throw new WrongUsageException("commands.scoreboard.teams.option.noValue", new Object[] {s, func_96333_a(Arrays.asList(new String[]{"true", "false"}))});
    392                }
    393
    394                scoreplayerteam.func_96660_a(s1.equalsIgnoreCase("true"));
    395            }
    396            else if (s.equalsIgnoreCase("seeFriendlyInvisibles"))
    397            {
    398                if (!s1.equalsIgnoreCase("true") && !s1.equalsIgnoreCase("false"))
    399                {
    400                    throw new WrongUsageException("commands.scoreboard.teams.option.noValue", new Object[] {s, func_96333_a(Arrays.asList(new String[]{"true", "false"}))});
    401                }
    402
    403                scoreplayerteam.func_98300_b(s1.equalsIgnoreCase("true"));
    404            }
    405
    406            notifyAdmins(par1ICommandSender, "commands.scoreboard.teams.option.success", new Object[] {s, scoreplayerteam.func_96661_b(), s1});
    407        }
    408    }
    409
    410    protected void func_96343_e(ICommandSender par1ICommandSender, String[] par2ArrayOfStr, int par3)
    411    {
    412        Scoreboard scoreboard = this.func_96334_d();
    413        ScorePlayerTeam scoreplayerteam = this.func_96338_a(par2ArrayOfStr[par3++]);
    414        scoreboard.func_96511_d(scoreplayerteam);
    415        notifyAdmins(par1ICommandSender, "commands.scoreboard.teams.remove.success", new Object[] {scoreplayerteam.func_96661_b()});
    416    }
    417
    418    protected void func_96344_f(ICommandSender par1ICommandSender, String[] par2ArrayOfStr, int par3)
    419    {
    420        Scoreboard scoreboard = this.func_96334_d();
    421
    422        if (par2ArrayOfStr.length > par3)
    423        {
    424            ScorePlayerTeam scoreplayerteam = this.func_96338_a(par2ArrayOfStr[par3++]);
    425            Collection collection = scoreplayerteam.func_96670_d();
    426
    427            if (collection.size() <= 0)
    428            {
    429                throw new CommandException("commands.scoreboard.teams.list.player.empty", new Object[] {scoreplayerteam.func_96661_b()});
    430            }
    431
    432            par1ICommandSender.sendChatToPlayer(EnumChatFormatting.DARK_GREEN + par1ICommandSender.translateString("commands.scoreboard.teams.list.player.count", new Object[] {Integer.valueOf(collection.size()), scoreplayerteam.func_96661_b()}));
    433            par1ICommandSender.sendChatToPlayer(joinNiceString(collection.toArray()));
    434        }
    435        else
    436        {
    437            Collection collection1 = scoreboard.func_96525_g();
    438
    439            if (collection1.size() <= 0)
    440            {
    441                throw new CommandException("commands.scoreboard.teams.list.empty", new Object[0]);
    442            }
    443
    444            par1ICommandSender.sendChatToPlayer(EnumChatFormatting.DARK_GREEN + par1ICommandSender.translateString("commands.scoreboard.teams.list.count", new Object[] {Integer.valueOf(collection1.size())}));
    445            Iterator iterator = collection1.iterator();
    446
    447            while (iterator.hasNext())
    448            {
    449                ScorePlayerTeam scoreplayerteam1 = (ScorePlayerTeam)iterator.next();
    450                par1ICommandSender.sendChatToPlayer(par1ICommandSender.translateString("commands.scoreboard.teams.list.entry", new Object[] {scoreplayerteam1.func_96661_b(), scoreplayerteam1.func_96669_c(), Integer.valueOf(scoreplayerteam1.func_96670_d().size())}));
    451            }
    452        }
    453    }
    454
    455    protected void func_96342_g(ICommandSender par1ICommandSender, String[] par2ArrayOfStr, int par3)
    456    {
    457        Scoreboard scoreboard = this.func_96334_d();
    458        ScorePlayerTeam scoreplayerteam = scoreboard.func_96508_e(par2ArrayOfStr[par3++]);
    459        HashSet hashset = new HashSet();
    460        String s;
    461
    462        if (par1ICommandSender instanceof EntityPlayer && par3 == par2ArrayOfStr.length)
    463        {
    464            s = getCommandSenderAsPlayer(par1ICommandSender).getEntityName();
    465            scoreboard.func_96521_a(s, scoreplayerteam);
    466            hashset.add(s);
    467        }
    468        else
    469        {
    470            while (par3 < par2ArrayOfStr.length)
    471            {
    472                s = func_96332_d(par1ICommandSender, par2ArrayOfStr[par3++]);
    473                scoreboard.func_96521_a(s, scoreplayerteam);
    474                hashset.add(s);
    475            }
    476        }
    477
    478        if (!hashset.isEmpty())
    479        {
    480            notifyAdmins(par1ICommandSender, "commands.scoreboard.teams.join.success", new Object[] {Integer.valueOf(hashset.size()), scoreplayerteam.func_96661_b(), joinNiceString(hashset.toArray(new String[0]))});
    481        }
    482    }
    483
    484    protected void func_96349_h(ICommandSender par1ICommandSender, String[] par2ArrayOfStr, int par3)
    485    {
    486        Scoreboard scoreboard = this.func_96334_d();
    487        HashSet hashset = new HashSet();
    488        HashSet hashset1 = new HashSet();
    489        String s;
    490
    491        if (par1ICommandSender instanceof EntityPlayer && par3 == par2ArrayOfStr.length)
    492        {
    493            s = getCommandSenderAsPlayer(par1ICommandSender).getEntityName();
    494
    495            if (scoreboard.func_96524_g(s))
    496            {
    497                hashset.add(s);
    498            }
    499            else
    500            {
    501                hashset1.add(s);
    502            }
    503        }
    504        else
    505        {
    506            while (par3 < par2ArrayOfStr.length)
    507            {
    508                s = func_96332_d(par1ICommandSender, par2ArrayOfStr[par3++]);
    509
    510                if (scoreboard.func_96524_g(s))
    511                {
    512                    hashset.add(s);
    513                }
    514                else
    515                {
    516                    hashset1.add(s);
    517                }
    518            }
    519        }
    520
    521        if (!hashset.isEmpty())
    522        {
    523            notifyAdmins(par1ICommandSender, "commands.scoreboard.teams.leave.success", new Object[] {Integer.valueOf(hashset.size()), joinNiceString(hashset.toArray(new String[0]))});
    524        }
    525
    526        if (!hashset1.isEmpty())
    527        {
    528            throw new CommandException("commands.scoreboard.teams.leave.failure", new Object[] {Integer.valueOf(hashset1.size()), joinNiceString(hashset1.toArray(new String[0]))});
    529        }
    530    }
    531
    532    protected void func_96346_i(ICommandSender par1ICommandSender, String[] par2ArrayOfStr, int par3)
    533    {
    534        Scoreboard scoreboard = this.func_96334_d();
    535        ScorePlayerTeam scoreplayerteam = this.func_96338_a(par2ArrayOfStr[par3++]);
    536        ArrayList arraylist = new ArrayList(scoreplayerteam.func_96670_d());
    537
    538        if (arraylist.isEmpty())
    539        {
    540            throw new CommandException("commands.scoreboard.teams.empty.alreadyEmpty", new Object[] {scoreplayerteam.func_96661_b()});
    541        }
    542        else
    543        {
    544            Iterator iterator = arraylist.iterator();
    545
    546            while (iterator.hasNext())
    547            {
    548                String s = (String)iterator.next();
    549                scoreboard.func_96512_b(s, scoreplayerteam);
    550            }
    551
    552            notifyAdmins(par1ICommandSender, "commands.scoreboard.teams.empty.success", new Object[] {Integer.valueOf(arraylist.size()), scoreplayerteam.func_96661_b()});
    553        }
    554    }
    555
    556    protected void func_96337_e(ICommandSender par1ICommandSender, String par2Str)
    557    {
    558        Scoreboard scoreboard = this.func_96334_d();
    559        ScoreObjective scoreobjective = this.func_96345_a(par2Str, false);
    560        scoreboard.func_96519_k(scoreobjective);
    561        notifyAdmins(par1ICommandSender, "commands.scoreboard.objectives.remove.success", new Object[] {par2Str});
    562    }
    563
    564    protected void func_96336_d(ICommandSender par1ICommandSender)
    565    {
    566        Scoreboard scoreboard = this.func_96334_d();
    567        Collection collection = scoreboard.func_96514_c();
    568
    569        if (collection.size() <= 0)
    570        {
    571            throw new CommandException("commands.scoreboard.objectives.list.empty", new Object[0]);
    572        }
    573        else
    574        {
    575            par1ICommandSender.sendChatToPlayer(EnumChatFormatting.DARK_GREEN + par1ICommandSender.translateString("commands.scoreboard.objectives.list.count", new Object[] {Integer.valueOf(collection.size())}));
    576            Iterator iterator = collection.iterator();
    577
    578            while (iterator.hasNext())
    579            {
    580                ScoreObjective scoreobjective = (ScoreObjective)iterator.next();
    581                par1ICommandSender.sendChatToPlayer(par1ICommandSender.translateString("commands.scoreboard.objectives.list.entry", new Object[] {scoreobjective.func_96679_b(), scoreobjective.func_96678_d(), scoreobjective.func_96680_c().func_96636_a()}));
    582            }
    583        }
    584    }
    585
    586    protected void func_96347_j(ICommandSender par1ICommandSender, String[] par2ArrayOfStr, int par3)
    587    {
    588        Scoreboard scoreboard = this.func_96334_d();
    589        String s = par2ArrayOfStr[par3++];
    590        int j = Scoreboard.func_96537_j(s);
    591        ScoreObjective scoreobjective = null;
    592
    593        if (par2ArrayOfStr.length == 4)
    594        {
    595            scoreobjective = this.func_96345_a(par2ArrayOfStr[par3++], false);
    596        }
    597
    598        if (j < 0)
    599        {
    600            throw new CommandException("commands.scoreboard.objectives.setdisplay.invalidSlot", new Object[] {s});
    601        }
    602        else
    603        {
    604            scoreboard.func_96530_a(j, scoreobjective);
    605
    606            if (scoreobjective != null)
    607            {
    608                notifyAdmins(par1ICommandSender, "commands.scoreboard.objectives.setdisplay.successSet", new Object[] {Scoreboard.func_96517_b(j), scoreobjective.func_96679_b()});
    609            }
    610            else
    611            {
    612                notifyAdmins(par1ICommandSender, "commands.scoreboard.objectives.setdisplay.successCleared", new Object[] {Scoreboard.func_96517_b(j)});
    613            }
    614        }
    615    }
    616
    617    protected void func_96341_k(ICommandSender par1ICommandSender, String[] par2ArrayOfStr, int par3)
    618    {
    619        Scoreboard scoreboard = this.func_96334_d();
    620
    621        if (par2ArrayOfStr.length > par3)
    622        {
    623            String s = func_96332_d(par1ICommandSender, par2ArrayOfStr[par3++]);
    624            Map map = scoreboard.func_96510_d(s);
    625
    626            if (map.size() <= 0)
    627            {
    628                throw new CommandException("commands.scoreboard.players.list.player.empty", new Object[] {s});
    629            }
    630
    631            par1ICommandSender.sendChatToPlayer(EnumChatFormatting.DARK_GREEN + par1ICommandSender.translateString("commands.scoreboard.players.list.player.count", new Object[] {Integer.valueOf(map.size()), s}));
    632            Iterator iterator = map.values().iterator();
    633
    634            while (iterator.hasNext())
    635            {
    636                Score score = (Score)iterator.next();
    637                par1ICommandSender.sendChatToPlayer(par1ICommandSender.translateString("commands.scoreboard.players.list.player.entry", new Object[] {Integer.valueOf(score.func_96652_c()), score.func_96645_d().func_96678_d(), score.func_96645_d().func_96679_b()}));
    638            }
    639        }
    640        else
    641        {
    642            Collection collection = scoreboard.func_96526_d();
    643
    644            if (collection.size() <= 0)
    645            {
    646                throw new CommandException("commands.scoreboard.players.list.empty", new Object[0]);
    647            }
    648
    649            par1ICommandSender.sendChatToPlayer(EnumChatFormatting.DARK_GREEN + par1ICommandSender.translateString("commands.scoreboard.players.list.count", new Object[] {Integer.valueOf(collection.size())}));
    650            par1ICommandSender.sendChatToPlayer(joinNiceString(collection.toArray()));
    651        }
    652    }
    653
    654    protected void func_96339_l(ICommandSender par1ICommandSender, String[] par2ArrayOfStr, int par3)
    655    {
    656        String s = par2ArrayOfStr[par3 - 1];
    657        String s1 = func_96332_d(par1ICommandSender, par2ArrayOfStr[par3++]);
    658        ScoreObjective scoreobjective = this.func_96345_a(par2ArrayOfStr[par3++], true);
    659        int j = s.equalsIgnoreCase("set") ? parseInt(par1ICommandSender, par2ArrayOfStr[par3++]) : parseIntWithMin(par1ICommandSender, par2ArrayOfStr[par3++], 1);
    660        Scoreboard scoreboard = this.func_96334_d();
    661        Score score = scoreboard.func_96529_a(s1, scoreobjective);
    662
    663        if (s.equalsIgnoreCase("set"))
    664        {
    665            score.func_96647_c(j);
    666        }
    667        else if (s.equalsIgnoreCase("add"))
    668        {
    669            score.func_96649_a(j);
    670        }
    671        else
    672        {
    673            score.func_96646_b(j);
    674        }
    675
    676        notifyAdmins(par1ICommandSender, "commands.scoreboard.players.set.success", new Object[] {scoreobjective.func_96679_b(), s1, Integer.valueOf(score.func_96652_c())});
    677    }
    678
    679    protected void func_96351_m(ICommandSender par1ICommandSender, String[] par2ArrayOfStr, int par3)
    680    {
    681        Scoreboard scoreboard = this.func_96334_d();
    682        String s = func_96332_d(par1ICommandSender, par2ArrayOfStr[par3++]);
    683        scoreboard.func_96515_c(s);
    684        notifyAdmins(par1ICommandSender, "commands.scoreboard.players.reset.success", new Object[] {s});
    685    }
    686
    687    /**
    688     * Adds the strings available in this command to the given list of tab completion options.
    689     */
    690    public List addTabCompletionOptions(ICommandSender par1ICommandSender, String[] par2ArrayOfStr)
    691    {
    692        if (par2ArrayOfStr.length == 1)
    693        {
    694            return getListOfStringsMatchingLastWord(par2ArrayOfStr, new String[] {"objectives", "players", "teams"});
    695        }
    696        else
    697        {
    698            if (par2ArrayOfStr[0].equalsIgnoreCase("objectives"))
    699            {
    700                if (par2ArrayOfStr.length == 2)
    701                {
    702                    return getListOfStringsMatchingLastWord(par2ArrayOfStr, new String[] {"list", "add", "remove", "setdisplay"});
    703                }
    704
    705                if (par2ArrayOfStr[1].equalsIgnoreCase("add"))
    706                {
    707                    if (par2ArrayOfStr.length == 4)
    708                    {
    709                        return getListOfStringsFromIterableMatchingLastWord(par2ArrayOfStr, ScoreObjectiveCriteria.field_96643_a.keySet());
    710                    }
    711                }
    712                else if (par2ArrayOfStr[1].equalsIgnoreCase("remove"))
    713                {
    714                    if (par2ArrayOfStr.length == 3)
    715                    {
    716                        return getListOfStringsFromIterableMatchingLastWord(par2ArrayOfStr, this.func_96335_a(false));
    717                    }
    718                }
    719                else if (par2ArrayOfStr[1].equalsIgnoreCase("setdisplay"))
    720                {
    721                    if (par2ArrayOfStr.length == 3)
    722                    {
    723                        return getListOfStringsMatchingLastWord(par2ArrayOfStr, new String[] {"list", "sidebar", "belowName"});
    724                    }
    725
    726                    if (par2ArrayOfStr.length == 4)
    727                    {
    728                        return getListOfStringsFromIterableMatchingLastWord(par2ArrayOfStr, this.func_96335_a(false));
    729                    }
    730                }
    731            }
    732            else if (par2ArrayOfStr[0].equalsIgnoreCase("players"))
    733            {
    734                if (par2ArrayOfStr.length == 2)
    735                {
    736                    return getListOfStringsMatchingLastWord(par2ArrayOfStr, new String[] {"set", "add", "remove", "reset", "list"});
    737                }
    738
    739                if (!par2ArrayOfStr[1].equalsIgnoreCase("set") && !par2ArrayOfStr[1].equalsIgnoreCase("add") && !par2ArrayOfStr[1].equalsIgnoreCase("remove"))
    740                {
    741                    if ((par2ArrayOfStr[1].equalsIgnoreCase("reset") || par2ArrayOfStr[1].equalsIgnoreCase("list")) && par2ArrayOfStr.length == 3)
    742                    {
    743                        return getListOfStringsFromIterableMatchingLastWord(par2ArrayOfStr, this.func_96334_d().func_96526_d());
    744                    }
    745                }
    746                else
    747                {
    748                    if (par2ArrayOfStr.length == 3)
    749                    {
    750                        return getListOfStringsMatchingLastWord(par2ArrayOfStr, MinecraftServer.getServer().getAllUsernames());
    751                    }
    752
    753                    if (par2ArrayOfStr.length == 4)
    754                    {
    755                        return getListOfStringsFromIterableMatchingLastWord(par2ArrayOfStr, this.func_96335_a(true));
    756                    }
    757                }
    758            }
    759            else if (par2ArrayOfStr[0].equalsIgnoreCase("teams"))
    760            {
    761                if (par2ArrayOfStr.length == 2)
    762                {
    763                    return getListOfStringsMatchingLastWord(par2ArrayOfStr, new String[] {"add", "remove", "join", "leave", "empty", "list", "option"});
    764                }
    765
    766                if (par2ArrayOfStr[1].equalsIgnoreCase("join"))
    767                {
    768                    if (par2ArrayOfStr.length == 3)
    769                    {
    770                        return getListOfStringsFromIterableMatchingLastWord(par2ArrayOfStr, this.func_96334_d().func_96531_f());
    771                    }
    772
    773                    if (par2ArrayOfStr.length >= 4)
    774                    {
    775                        return getListOfStringsMatchingLastWord(par2ArrayOfStr, MinecraftServer.getServer().getAllUsernames());
    776                    }
    777                }
    778                else
    779                {
    780                    if (par2ArrayOfStr[1].equalsIgnoreCase("leave"))
    781                    {
    782                        return getListOfStringsMatchingLastWord(par2ArrayOfStr, MinecraftServer.getServer().getAllUsernames());
    783                    }
    784
    785                    if (!par2ArrayOfStr[1].equalsIgnoreCase("empty") && !par2ArrayOfStr[1].equalsIgnoreCase("list") && !par2ArrayOfStr[1].equalsIgnoreCase("remove"))
    786                    {
    787                        if (par2ArrayOfStr[1].equalsIgnoreCase("option"))
    788                        {
    789                            if (par2ArrayOfStr.length == 3)
    790                            {
    791                                return getListOfStringsFromIterableMatchingLastWord(par2ArrayOfStr, this.func_96334_d().func_96531_f());
    792                            }
    793
    794                            if (par2ArrayOfStr.length == 4)
    795                            {
    796                                return getListOfStringsMatchingLastWord(par2ArrayOfStr, new String[] {"color", "friendlyfire", "seeFriendlyInvisibles"});
    797                            }
    798
    799                            if (par2ArrayOfStr.length == 5)
    800                            {
    801                                if (par2ArrayOfStr[3].equalsIgnoreCase("color"))
    802                                {
    803                                    return getListOfStringsFromIterableMatchingLastWord(par2ArrayOfStr, EnumChatFormatting.func_96296_a(true, false));
    804                                }
    805
    806                                if (par2ArrayOfStr[3].equalsIgnoreCase("friendlyfire") || par2ArrayOfStr[3].equalsIgnoreCase("seeFriendlyInvisibles"))
    807                                {
    808                                    return getListOfStringsMatchingLastWord(par2ArrayOfStr, new String[] {"true", "false"});
    809                                }
    810                            }
    811                        }
    812                    }
    813                    else if (par2ArrayOfStr.length == 3)
    814                    {
    815                        return getListOfStringsFromIterableMatchingLastWord(par2ArrayOfStr, this.func_96334_d().func_96531_f());
    816                    }
    817                }
    818            }
    819
    820            return null;
    821        }
    822    }
    823
    824    protected List func_96335_a(boolean par1)
    825    {
    826        Collection collection = this.func_96334_d().func_96514_c();
    827        ArrayList arraylist = new ArrayList();
    828        Iterator iterator = collection.iterator();
    829
    830        while (iterator.hasNext())
    831        {
    832            ScoreObjective scoreobjective = (ScoreObjective)iterator.next();
    833
    834            if (!par1 || !scoreobjective.func_96680_c().func_96637_b())
    835            {
    836                arraylist.add(scoreobjective.func_96679_b());
    837            }
    838        }
    839
    840        return arraylist;
    841    }
    842
    843    /**
    844     * Return whether the specified command parameter index is a username parameter.
    845     */
    846    public boolean isUsernameIndex(String[] par1ArrayOfStr, int par2)
    847    {
    848        return par1ArrayOfStr[0].equalsIgnoreCase("players") ? par2 == 2 : (!par1ArrayOfStr[0].equalsIgnoreCase("teams") ? false : par2 == 2 || par2 == 3);
    849    }
    850}