001package net.minecraft.command; 002 003import java.util.Iterator; 004import net.minecraft.entity.player.EntityPlayerMP; 005import net.minecraft.scoreboard.ServerCommandScoreboard; 006import net.minecraft.scoreboard.ServerCommandTestFor; 007import net.minecraft.server.MinecraftServer; 008import net.minecraft.tileentity.TileEntityCommandBlock; 009import net.minecraft.util.EnumChatFormatting; 010 011public class ServerCommandManager extends CommandHandler implements IAdminCommand 012{ 013 public ServerCommandManager() 014 { 015 this.registerCommand(new CommandTime()); 016 this.registerCommand(new CommandGameMode()); 017 this.registerCommand(new CommandDifficulty()); 018 this.registerCommand(new CommandDefaultGameMode()); 019 this.registerCommand(new CommandKill()); 020 this.registerCommand(new CommandToggleDownfall()); 021 this.registerCommand(new CommandWeather()); 022 this.registerCommand(new CommandXP()); 023 this.registerCommand(new CommandServerTp()); 024 this.registerCommand(new CommandGive()); 025 this.registerCommand(new CommandEffect()); 026 this.registerCommand(new CommandEnchant()); 027 this.registerCommand(new CommandServerEmote()); 028 this.registerCommand(new CommandShowSeed()); 029 this.registerCommand(new CommandHelp()); 030 this.registerCommand(new CommandDebug()); 031 this.registerCommand(new CommandServerMessage()); 032 this.registerCommand(new CommandServerSay()); 033 this.registerCommand(new CommandSetSpawnpoint()); 034 this.registerCommand(new CommandGameRule()); 035 this.registerCommand(new CommandClearInventory()); 036 this.registerCommand(new ServerCommandTestFor()); 037 this.registerCommand(new ServerCommandScoreboard()); 038 039 if (MinecraftServer.getServer().isDedicatedServer()) 040 { 041 this.registerCommand(new CommandServerOp()); 042 this.registerCommand(new CommandServerDeop()); 043 this.registerCommand(new CommandServerStop()); 044 this.registerCommand(new CommandServerSaveAll()); 045 this.registerCommand(new CommandServerSaveOff()); 046 this.registerCommand(new CommandServerSaveOn()); 047 this.registerCommand(new CommandServerBanIp()); 048 this.registerCommand(new CommandServerPardonIp()); 049 this.registerCommand(new CommandServerBan()); 050 this.registerCommand(new CommandServerBanlist()); 051 this.registerCommand(new CommandServerPardon()); 052 this.registerCommand(new CommandServerKick()); 053 this.registerCommand(new CommandServerList()); 054 this.registerCommand(new CommandServerWhitelist()); 055 } 056 else 057 { 058 this.registerCommand(new CommandServerPublishLocal()); 059 } 060 061 CommandBase.setAdminCommander(this); 062 } 063 064 /** 065 * Sends a message to the admins of the server from a given CommandSender with the given resource string and given 066 * extra srings. If the int par2 is even or zero, the original sender is also notified. 067 */ 068 public void notifyAdmins(ICommandSender par1ICommandSender, int par2, String par3Str, Object ... par4ArrayOfObj) 069 { 070 boolean flag = true; 071 072 if (par1ICommandSender instanceof TileEntityCommandBlock && !MinecraftServer.getServer().worldServers[0].getGameRules().getGameRuleBooleanValue("commandBlockOutput")) 073 { 074 flag = false; 075 } 076 077 if (flag) 078 { 079 Iterator iterator = MinecraftServer.getServer().getConfigurationManager().playerEntityList.iterator(); 080 081 while (iterator.hasNext()) 082 { 083 EntityPlayerMP entityplayermp = (EntityPlayerMP)iterator.next(); 084 085 if (entityplayermp != par1ICommandSender && MinecraftServer.getServer().getConfigurationManager().areCommandsAllowed(entityplayermp.username)) 086 { 087 entityplayermp.sendChatToPlayer("" + EnumChatFormatting.GRAY + "" + EnumChatFormatting.ITALIC + "[" + par1ICommandSender.getCommandSenderName() + ": " + entityplayermp.translateString(par3Str, par4ArrayOfObj) + "]"); 088 } 089 } 090 } 091 092 if (par1ICommandSender != MinecraftServer.getServer()) 093 { 094 MinecraftServer.getServer().getLogAgent().logInfo("[" + par1ICommandSender.getCommandSenderName() + ": " + MinecraftServer.getServer().translateString(par3Str, par4ArrayOfObj) + "]"); 095 } 096 097 if ((par2 & 1) != 1) 098 { 099 par1ICommandSender.sendChatToPlayer(par1ICommandSender.translateString(par3Str, par4ArrayOfObj)); 100 } 101 } 102}